History

clean up sources

Rhys Sullivan committed 7 months ago

Commit c45a85b1 parent 6f6f1b121 files · +25 −138Browse files

Unified · Split

21 files
  1. .executor/executor.jsonc +2 −52
  2. apps/web/src/components/shell.tsx +1 −1
  3. apps/web/src/views/home.tsx +1 −1
  4. examples/sqlite-sdk-consumer/src/sqlite-backend.ts +0 −2
  5. packages/platform/sdk-file/src/capture-release-workspace-fixture.ts +1 −6
  6. packages/platform/sdk-file/src/config.test.ts +2 −8
  7. packages/platform/sdk/src/runtime/catalog/source/runtime.ts +0 −3
  8. packages/platform/sdk/src/runtime/catalog/source/sync.ts +5 −4
  9. packages/platform/sdk/src/runtime/sources/source-definitions.ts +0 −8
  10. packages/platform/sdk/src/runtime/sources/source-plugins/internal.ts +1 −1
  11. packages/platform/sdk/src/runtime/sources/source-store/config.ts +0 −3
  12. packages/platform/sdk/src/runtime/sources/source-store/lifecycle.ts +2 −2
  13. packages/platform/sdk/src/runtime/sources/source-store/records.ts +0 −3
  14. packages/platform/sdk/src/schema/models/local-config.ts +0 −5
  15. packages/platform/sdk/src/schema/models/source.ts +0 −15
  16. packages/platform/sdk/src/sources/operations.ts +0 −1
  17. packages/sources/core/src/catalog-fragment.ts +3 −3
  18. packages/sources/core/src/catalog-shared.ts +4 −6
  19. packages/sources/core/src/source-models.ts +0 −3
  20. plugins/openapi/react/index.tsx +0 −4
  21. plugins/openapi/sdk/index.ts +3 −7
.executor/executor.jsonc+2−52
@@ -2,63 +2,13 @@ · 1 unmodified line
22 "sources": {
33 "github": {
44 "kind": "openapi",
5− "name": "GitHub",
65 "connection": {
7− "endpoint": "https://api.github.com"
6+ "endpoint": "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/ghes-3.9/%7Bprotocol%7D://%7Bhostname%7D/api/v3"
87 },
98 "binding": {
10− "specUrl": "https://example.com/github-openapi.yaml",
9+ "specUrl": "https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/ghes-3.9/ghes-3.9.yaml",
1110 "defaultHeaders": null
1211 }
13− },
14− "google-gmail": {
15− "name": "Gmail",
16− "namespace": "google.gmail",
17− "connection": {
18− "endpoint": "https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest"
19− },
20− "kind": "google_discovery",
21− "binding": {
22− "service": "gmail",
23− "version": "v1",
24− "discoveryUrl": "https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest",
25− "defaultHeaders": null,
26− "scopes": [
27− "scope:gmail.readonly"
28− ]
29− }
30− },
31− "google-calendar": {
32− "name": "Google Calendar",
33− "namespace": "google.calendar",
34− "connection": {
35− "endpoint": "https://calendar-json.googleapis.com/$discovery/rest?version=v3"
36− },
37− "kind": "google_discovery",
38− "binding": {
39− "service": "calendar",
40− "version": "v3",
41− "discoveryUrl": "https://calendar-json.googleapis.com/$discovery/rest?version=v3",
42− "defaultHeaders": null,
43− "scopes": [
44− "scope:calendar.readonly"
45− ]
46− }
47− },
48− "google-drive": {
49− "name": "Drive",
50− "namespace": "google.drive",
51− "connection": {
52− "endpoint": "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"
53− },
54− "kind": "google_discovery",
55− "binding": {
56− "service": "drive",
57− "version": "v3",
58− "discoveryUrl": "https://www.googleapis.com/discovery/v1/apis/drive/v3/rest",
59− "defaultHeaders": null,
60− "scopes": []
61− }
6212 }
6313 }
6414 }
apps/web/src/components/shell.tsx+1−1
@@ -331,7 +331,7 @@ function SourceItem(props: { · 330 unmodified lines
331331 )}
332332 >
333333 <div className="flex size-3 shrink-0 items-center justify-center text-muted-foreground/50">
334− <SourceFavicon endpoint={source.endpoint} kind={source.kind} className="size-3" />
334+ <SourceFavicon kind={source.kind} className="size-3" />
335335 </div>
336336 <span className="flex-1 truncate">{source.name}</span>
337337 <span
apps/web/src/views/home.tsx+1−1
@@ -58,7 +58,7 @@ export function HomePage() { · 57 unmodified lines
5858 {source.name}
5959 </div>
6060 <div className="mt-1 text-xs text-muted-foreground">
61− {source.endpoint}
61+ {source.kind}
6262 </div>
6363 </div>
6464 <Badge
examples/sqlite-sdk-consumer/src/sqlite-backend.ts+0−2
@@ -127,11 +127,9 @@ const createSourceArtifact = (input: SourceArtifactBuildInput): SourceArtifact = · 126 unmodified lines
127127 const snapshot = snapshotFromSourceCatalogSyncResult(input.syncResult);
128128 const sourceConfigJson = JSON.stringify({
129129 kind: input.source.kind,
130− endpoint: input.source.endpoint,
131130 namespace: input.source.namespace,
132131 name: input.source.name,
133132 enabled: input.source.enabled,
134− sourceHash: input.source.sourceHash,
135133 });
136134 const importMetadataJson = JSON.stringify(snapshot.import);
137135 const catalogId = SourceCatalogIdSchema.make(`src_catalog_${makeHash(sourceConfigJson)}`);
packages/platform/sdk-file/src/capture-release-workspace-fixture.ts+1−6
@@ -187,12 +187,7 @@ const copyRecursive = ( · 186 unmodified lines
187187
188188 const sanitizeSourceConfig = (
189189 sourceConfig: NonNullable<LocalExecutorConfig["sources"]>[string],
190−): NonNullable<LocalExecutorConfig["sources"]>[string] => {
191− return {
192− ...sourceConfig,
193− connection: sourceConfig.connection,
194− };
195−};
190+): NonNullable<LocalExecutorConfig["sources"]>[string] => sourceConfig;
196191
197192 const main = Effect.gen(function* () {
198193 const args = yield* Effect.try({
packages/platform/sdk-file/src/config.test.ts+2−8
@@ -38,9 +38,6 @@ describe("local-config", () => { · 37 unmodified lines
3838 "sources": {
3939 "github": {
4040 "kind": "openapi",
41− "connection": {
42− "endpoint": "https://api.github.com",
43− },
4441 "binding": {
4542 "specUrl": "https://example.com/openapi.json",
4643 },
@@ -54,9 +51,6 @@ describe("local-config", () => { · 7 unmodified lines
5451 const loaded = yield* loadLocalExecutorConfig(context);
5552
5653 expect(loaded.config?.sources?.github?.kind).toBe("openapi");
57− expect(loaded.config?.sources?.github?.connection.endpoint).toBe(
58− "https://api.github.com",
59− );
6054 expect(loaded.config?.runtime).toBe("ses");
6155 expect(context.homeStateDirectory.toLowerCase()).toContain("executor");
6256 }).pipe(Effect.provide(NodeFileSystem.layer)),
@@ -74,8 +68,8 @@ describe("local-config", () => { · 11 unmodified lines
7468 "sources": {
7569 "github": {
7670 "kind": "openapi"
77− "connection": {
78− "endpoint": "https://api.github.com"
71+ "binding": {
72+ "specUrl": "https://api.github.com/openapi.json"
7973 }
8074 }
8175 }
packages/platform/sdk/src/runtime/catalog/source/runtime.ts+0−3
@@ -675,12 +675,9 @@ const sourceRecordFromCatalogArtifact = (input: { · 674 unmodified lines
675675 catalogRevisionId: input.artifact.revision.id,
676676 name: input.source.name,
677677 kind: input.source.kind,
678− endpoint: input.source.endpoint,
679678 status: input.source.status,
680679 enabled: input.source.enabled,
681680 namespace: input.source.namespace,
682− sourceHash: input.source.sourceHash,
683− lastError: input.source.lastError,
684681 createdAt: input.source.createdAt,
685682 updatedAt: input.source.updatedAt,
686683 });
packages/platform/sdk/src/runtime/catalog/source/sync.ts+5−4
@@ -89,7 +89,8 @@ const syncSourceCatalogWithDeps = ( · 88 unmodified lines
8989
9090 if (!shouldIndexSource(input.source)) {
9191 const state = yield* deps.scopeStateStore.load();
92− const existingSourceState = state.sources[input.source.id];
92+ const existingSourceState =
93+ state.sources[input.source.id] as LocalScopeState["sources"][string] | undefined;
9394 const nextState: LocalScopeState = {
9495 ...state,
9596 sources: {
@@ -97,7 +98,7 @@ const syncSourceCatalogWithDeps = ( · 1 unmodified line
9798 [input.source.id]: {
9899 status: (input.source.enabled ? input.source.status : "draft") as SourceStatus,
99100 lastError: null,
100− sourceHash: input.source.sourceHash,
101+ sourceHash: existingSourceState?.sourceHash ?? null,
101102 createdAt: existingSourceState?.createdAt ?? input.source.createdAt,
102103 updatedAt: Date.now(),
103104 },
@@ -127,7 +128,8 @@ const syncSourceCatalogWithDeps = ( · 23 unmodified lines
127128 });
128129
129130 const state = yield* deps.scopeStateStore.load();
130− const existingSourceState = state.sources[input.source.id];
131+ const existingSourceState =
132+ state.sources[input.source.id] as LocalScopeState["sources"][string] | undefined;
131133 const nextState: LocalScopeState = {
132134 ...state,
133135 sources: {
@@ -155,7 +157,6 @@ const syncSourceCatalogWithDeps = ( · 21 unmodified lines
155157 "executor.source.id": input.source.id,
156158 "executor.source.kind": input.source.kind,
157159 "executor.source.namespace": input.source.namespace,
158− "executor.source.endpoint": input.source.endpoint,
159160 },
160161 }),
161162 );
packages/platform/sdk/src/runtime/sources/source-definitions.ts+0−8
@@ -34,7 +34,6 @@ const sourceConfigFromSource = (source: Source): SourceCatalogSourceConfig => · 33 unmodified lines
3434 source,
3535 }) ?? {
3636 kind: source.kind,
37− endpoint: source.endpoint,
3837 namespace: source.namespace,
3938 };
4039
@@ -60,7 +59,6 @@ export const sourceConfigSignature = (source: Source): string => · 19 unmodified lines
6059 sourceId: source.id,
6160 kind: source.kind,
6261 name: source.name,
63− endpoint: source.endpoint,
6462 namespace: source.namespace,
6563 enabled: source.enabled,
6664 updatedAt: source.updatedAt,
@@ -91,12 +89,9 @@ export const normalizeSourceForCreate = (input: { · 24 unmodified lines
9189 scopeId: input.scopeId,
9290 name: input.source.name.trim(),
9391 kind: input.source.kind,
94− endpoint: input.source.endpoint.trim(),
9592 status: input.source.status,
9693 enabled: input.source.enabled,
9794 namespace: trimOrNull(input.source.namespace),
98− sourceHash: trimOrNull(input.source.sourceHash),
99− lastError: trimOrNull(input.source.lastError),
10095 createdAt: input.now,
10196 updatedAt: input.now,
10297 });
@@ -108,10 +103,7 @@ export const normalizeSourceForSave = (input: { · 5 unmodified lines
108103 validateSourceByKind({
109104 ...input.source,
110105 name: input.source.name.trim(),
111− endpoint: input.source.endpoint.trim(),
112106 namespace: trimOrNull(input.source.namespace),
113− sourceHash: trimOrNull(input.source.sourceHash),
114− lastError: trimOrNull(input.source.lastError),
115107 updatedAt: input.now,
116108 });
117109
packages/platform/sdk/src/runtime/sources/source-plugins/internal.ts+1−1
@@ -17,7 +17,7 @@ export const InternalSourceSdkPlugin = { · 16 unmodified lines
1717 catalogKind: "internal",
1818 catalogIdentity: ({ source }) => ({
1919 kind: "internal",
20− endpoint: source.endpoint,
20+ sourceId: source.id,
2121 }),
2222 getIrModel: ({ source }) =>
2323 Effect.succeed(
packages/platform/sdk/src/runtime/sources/source-store/config.ts+0−3
@@ -50,8 +50,5 @@ export const configSourceFromLocalSource = (input: { · 49 unmodified lines
5050 ? { namespace: input.source.namespace ?? undefined }
5151 : {}),
5252 ...(input.source.enabled === false ? { enabled: false } : {}),
53− connection: {
54− endpoint: input.source.endpoint,
55− },
5653 } as LocalConfigSource;
5754 };
packages/platform/sdk/src/runtime/sources/source-store/lifecycle.ts+2−2
@@ -110,8 +110,8 @@ export const persistSourceWithDeps = ( · 109 unmodified lines
110110 ...localScope.scopeState.sources,
111111 [nextSource.id]: {
112112 status: nextSource.status,
113− lastError: nextSource.lastError,
114− sourceHash: nextSource.sourceHash,
113+ lastError: existingSourceState?.lastError ?? null,
114+ sourceHash: existingSourceState?.sourceHash ?? null,
115115 createdAt: existingSourceState?.createdAt ?? nextSource.createdAt,
116116 updatedAt: nextSource.updatedAt,
117117 },
packages/platform/sdk/src/runtime/sources/source-store/records.ts+0−3
@@ -47,14 +47,11 @@ export const buildLocalSourceRecord = (input: { · 46 unmodified lines
4747 scopeId: input.scopeId,
4848 name: trimOrNull(sourceConfig.name) ?? input.sourceId,
4949 kind: sourceConfig.kind,
50− endpoint: sourceConfig.connection.endpoint.trim(),
5150 status:
5251 existingState?.status ??
5352 (sourceConfig.enabled ?? true ? "connected" : "draft"),
5453 enabled: sourceConfig.enabled ?? true,
5554 namespace: trimOrNull(sourceConfig.namespace) ?? input.sourceId,
56− sourceHash: existingState?.sourceHash ?? null,
57− lastError: existingState?.lastError ?? null,
5855 createdAt: existingState?.createdAt ?? Date.now(),
5956 updatedAt: existingState?.updatedAt ?? Date.now(),
6057 };
packages/platform/sdk/src/schema/models/local-config.ts+0−5
@@ -56,15 +56,10 @@ export const LocalConfigSecretInputSchema = Schema.Union( · 55 unmodified lines
5656 LocalConfigExplicitSecretRefSchema,
5757 );
5858
59−export const LocalConfigSourceConnectionSchema = Schema.Struct({
60− endpoint: Schema.String,
61−});
62−
6359 const LocalConfigSourceEntryBaseSchema = Schema.Struct({
6460 name: Schema.optional(Schema.String),
6561 namespace: Schema.optional(Schema.String),
6662 enabled: Schema.optional(Schema.Boolean),
67− connection: LocalConfigSourceConnectionSchema,
6863 });
6964
7065 export const LocalConfigSourceSchema = Schema.extend(
packages/platform/sdk/src/schema/models/source.ts+0−15
@@ -36,12 +36,9 @@ const SourceStorageRowSchema = Schema.Struct({ · 35 unmodified lines
3636 catalogRevisionId: SourceCatalogRevisionIdSchema,
3737 name: Schema.String,
3838 kind: SourceKindSchema,
39− endpoint: Schema.String,
4039 status: SourceStatusSchema,
4140 enabled: Schema.Boolean,
4241 namespace: Schema.NullOr(Schema.String),
43− sourceHash: Schema.NullOr(Schema.String),
44− lastError: Schema.NullOr(Schema.String),
4542 createdAt: TimestampMsSchema,
4643 updatedAt: TimestampMsSchema,
4744 });
@@ -55,12 +52,9 @@ export const StoredSourceRecordSchema = Schema.transform( · 7 unmodified lines
5552 catalogRevisionId: SourceCatalogRevisionIdSchema,
5653 name: Schema.String,
5754 kind: SourceKindSchema,
58− endpoint: Schema.String,
5955 status: SourceStatusSchema,
6056 enabled: Schema.Boolean,
6157 namespace: Schema.NullOr(Schema.String),
62− sourceHash: Schema.NullOr(Schema.String),
63− lastError: Schema.NullOr(Schema.String),
6458 createdAt: TimestampMsSchema,
6559 updatedAt: TimestampMsSchema,
6660 }),
@@ -73,12 +67,9 @@ export const StoredSourceRecordSchema = Schema.transform( · 6 unmodified lines
7367 catalogRevisionId: row.catalogRevisionId,
7468 name: row.name,
7569 kind: row.kind,
76− endpoint: row.endpoint,
7770 status: row.status,
7871 enabled: row.enabled,
7972 namespace: row.namespace,
80− sourceHash: row.sourceHash,
81− lastError: row.lastError,
8273 createdAt: row.createdAt,
8374 updatedAt: row.updatedAt,
8475 }),
@@ -89,12 +80,9 @@ export const StoredSourceRecordSchema = Schema.transform( · 4 unmodified lines
8980 catalogRevisionId: source.catalogRevisionId,
9081 name: source.name,
9182 kind: source.kind,
92− endpoint: source.endpoint,
9383 status: source.status,
9484 enabled: source.enabled,
9585 namespace: source.namespace,
96− sourceHash: source.sourceHash,
97− lastError: source.lastError,
9886 createdAt: source.createdAt,
9987 updatedAt: source.updatedAt,
10088 }),
@@ -106,12 +94,9 @@ export const SourceSchema = Schema.Struct({ · 5 unmodified lines
10694 scopeId: ScopeIdSchema,
10795 name: Schema.String,
10896 kind: SourceKindSchema,
109− endpoint: Schema.String,
11097 status: SourceStatusSchema,
11198 enabled: Schema.Boolean,
11299 namespace: Schema.NullOr(Schema.String),
113− sourceHash: Schema.NullOr(Schema.String),
114− lastError: Schema.NullOr(Schema.String),
115100 createdAt: TimestampMsSchema,
116101 updatedAt: TimestampMsSchema,
117102 });
packages/platform/sdk/src/sources/operations.ts+0−1
@@ -62,7 +62,6 @@ const syncArtifactsForSource = (input: { · 61 unmodified lines
6262 source: {
6363 ...input.source,
6464 status: "error",
65− lastError: error.message,
6665 },
6766 now: Date.now(),
6867 }).pipe(
packages/sources/core/src/catalog-fragment.ts+3−3
@@ -117,7 +117,7 @@ const createServiceScope = (input: { · 116 unmodified lines
117117 export const buildCatalogFragment = (input: {
118118 source: Pick<
119119 Source,
120− "id" | "kind" | "name" | "endpoint" | "namespace"
120+ "id" | "kind" | "name" | "namespace"
121121 >;
122122 documents: readonly CatalogSourceDocumentInput[];
123123 serviceScopeDefaults?: Scope["defaults"];
@@ -131,14 +131,14 @@ export const buildCatalogFragment = (input: { · 7 unmodified lines
131131 : [
132132 {
133133 documentKind: "synthetic",
134− documentKey: input.source.endpoint,
134+ documentKey: input.source.id,
135135 fetchedAt: Date.now(),
136136 contentText: "{}",
137137 },
138138 ];
139139 const primaryDocument = documents[0]!;
140140 const primaryDocumentKey =
141− primaryDocument.documentKey ?? input.source.endpoint ?? input.source.id;
141+ primaryDocument.documentKey ?? input.source.id;
142142 const primaryDocumentId = documentIdFor(
143143 input.source,
144144 `${primaryDocument.documentKind}:${primaryDocument.documentKey}`,
packages/sources/core/src/catalog-shared.ts+4−6
@@ -120,18 +120,16 @@ export const interactionForEffect = ( · 119 unmodified lines
120120 });
121121
122122 export const createCatalogImportMetadata = (input: {
123− source: Pick<Source, "kind" | "endpoint" | "sourceHash">;
123+ source: Pick<Source, "id" | "kind">;
124124 pluginKey: string;
125125 }): ImportMetadata => ({
126126 sourceKind: sourceKindFromSource(input.source),
127127 pluginKey: input.pluginKey,
128128 importerVersion: "ir.v1.snapshot_builder",
129129 importedAt: new Date().toISOString(),
130− sourceConfigHash:
131− input.source.sourceHash ??
132− stableHash({
133− endpoint: input.source.endpoint,
134− }),
130+ sourceConfigHash: stableHash({
131+ sourceId: input.source.id,
132+ }),
135133 });
136134
137135 export const docsFrom = (input: {
packages/sources/core/src/source-models.ts+0−3
@@ -73,12 +73,9 @@ export const SourceSchema = Schema.Struct({ · 72 unmodified lines
7373 scopeId: Schema.String,
7474 name: Schema.String,
7575 kind: SourceKindSchema,
76− endpoint: Schema.String,
7776 status: SourceStatusSchema,
7877 enabled: Schema.Boolean,
7978 namespace: Schema.NullOr(Schema.String),
80− sourceHash: Schema.NullOr(Schema.String),
81− lastError: Schema.NullOr(Schema.String),
8279 createdAt: Schema.Number,
8380 updatedAt: Schema.Number,
8481 });
plugins/openapi/react/index.tsx+0−4
@@ -400,8 +400,6 @@ function OpenApiEditSourcePage(props: { · 399 unmodified lines
400400 {JSON.stringify({
401401 id: props.source.id,
402402 kind: props.source.kind,
403− endpoint: props.source.endpoint,
404− sourceHash: props.source.sourceHash,
405403 }, null, 2)}
406404 </pre>
407405 </Section>
@@ -423,9 +421,7 @@ function OpenApiSourceDetailPage(props: { · 15 unmodified lines
423421 id: props.source.id,
424422 name: props.source.name,
425423 kind: props.source.kind,
426− endpoint: props.source.endpoint,
427424 status: props.source.status,
428− sourceHash: props.source.sourceHash,
429425 }, null, 2)}
430426 </pre>
431427 </Section>
plugins/openapi/sdk/index.ts+3−7
@@ -76,7 +76,7 @@ const createOpenApiSourceRuntime = ( · 75 unmodified lines
7676 catalogKind: "imported",
7777 catalogIdentity: ({ source }) => ({
7878 kind: "openapi",
79− endpoint: source.endpoint,
79+ sourceId: source.id,
8080 }),
8181 getIrModel: ({ source }) =>
8282 Effect.gen(function* () {
@@ -96,10 +96,9 @@ const createOpenApiSourceRuntime = ( · 13 unmodified lines
9696 }),
9797 importerVersion: "ir.v1.openapi",
9898 sourceConfigHash:
99− stored === null ? source.sourceHash ?? "openapi" : stableSourceHash(stored),
99+ stored === null ? "openapi" : stableSourceHash(stored),
100100 },
101− sourceHash:
102− stored === null ? source.sourceHash ?? null : stableSourceHash(stored),
101+ sourceHash: stored === null ? null : stableSourceHash(stored),
103102 });
104103 }),
105104 invoke: () =>
@@ -125,12 +124,9 @@ export const openApiSdkPlugin = ( · 19 unmodified lines
125124 source: {
126125 name: input.name.trim(),
127126 kind: "openapi",
128− endpoint: stored.baseUrl ?? stored.specUrl,
129127 status: "connected",
130128 enabled: true,
131129 namespace: null,
132− sourceHash: stableSourceHash(stored),
133− lastError: null,
134130 },
135131 });
136132