History

remove scopeRoot / scopeName

Rhys Sullivan committed 7 months ago

Commit a7601031 parent 7dd9a5d10 files · +13 −45Browse files

Unified · Split

10 files
  1. examples/sqlite-sdk-consumer/README.md +0 −1
  2. examples/sqlite-sdk-consumer/src/main.ts +0 −2
  3. examples/sqlite-sdk-consumer/src/sqlite-backend.ts +6 −8
  4. packages/platform/sdk-file/src/index.ts +0 −5
  5. packages/platform/sdk/src/backend.ts +0 −1
  6. packages/platform/sdk/src/policies/operations.ts +7 −22
  7. packages/platform/sdk/src/runtime/execution/scope/source-catalog.test.ts +0 −1
  8. packages/platform/sdk/src/runtime/index.ts +0 −2
  9. packages/platform/sdk/src/runtime/scope/storage.ts +0 −1
  10. packages/platform/sdk/src/scope.ts +0 −2
examples/sqlite-sdk-consumer/README.md+0−1
@@ -36,7 +36,6 @@ import { createSqliteExecutorBackend } from "@executor/sqlite-sdk-consumer-examp · 35 unmodified lines
3636 const executor = await createExecutor({
3737 backend: createSqliteExecutorBackend({
3838 databasePath: "./executor.sqlite",
39− scopeName: "Acme",
4039 }),
4140 });
4241 ```
examples/sqlite-sdk-consumer/src/main.ts+0−2
@@ -8,8 +8,6 @@ const databasePath = process.env.DATABASE_PATH · 7 unmodified lines
88 const executor = await createExecutor({
99 backend: createSqliteExecutorBackend({
1010 databasePath,
11− scopeName: "SQLite Example Workspace",
12− scopeRoot: process.cwd(),
1311 }),
1412 });
1513
examples/sqlite-sdk-consumer/src/sqlite-backend.ts+6−8
@@ -23,7 +23,7 @@ import type { · 22 unmodified lines
2323 Execution,
2424 ExecutionInteraction,
2525 ExecutionStep,
26− LocalExecutorConfig,
26+ ExecutorScopeConfig,
2727 LocalInstallation,
2828 SecretMaterial,
2929 SecretRef,
@@ -35,6 +35,9 @@ import { · 5 unmodified lines
3535 SourceCatalogIdSchema,
3636 SourceCatalogRevisionIdSchema,
3737 } from "@executor/platform-sdk/schema";
38+import type {
39+ SecretMaterialStoredDataRecord,
40+} from "@executor/platform-sdk/runtime";
3841 import {
3942 contentHash,
4043 snapshotFromSourceCatalogSyncResult,
@@ -42,8 +45,6 @@ import { · 1 unmodified line
4245
4346 export type CreateSqliteExecutorBackendOptions = {
4447 databasePath?: string;
45− scopeName?: string;
46− scopeRoot?: string | null;
4748 scopeId?: string;
4849 actorScopeId?: string;
4950 };
@@ -382,7 +383,7 @@ const createStorageDomains = ( · 332 unmodified lines
382383 }
383384 : null;
384385 },
385− upsert: (record: { secretId: SecretMaterial["id"]; data: unknown }) => {
386+ upsert: (record: SecretMaterialStoredDataRecord) => {
386387 store.db.insert(secretMaterialStoredData).values({
387388 secretId: record.secretId,
388389 json: JSON.stringify(record.data),
@@ -568,8 +569,6 @@ export const createSqliteExecutorBackend = ( · 179 unmodified lines
568569
569570 return {
570571 scope: {
571− scopeName: options.scopeName ?? "SQLite SDK Example",
572− scopeRoot: options.scopeRoot ?? null,
573572 metadata: {
574573 kind: "sqlite",
575574 databasePath,
@@ -601,7 +600,7 @@ export const createSqliteExecutorBackend = ( · 25 unmodified lines
601600 load: () => {
602601 const row = store.db.select().from(scopeConfigs).where(eq(scopeConfigs.key, "project")).get();
603602 const projectConfig = row
604− ? parseJson<LocalExecutorConfig>(row.projectConfigJson)
603+ ? parseJson<ExecutorScopeConfig>(row.projectConfigJson)
605604 : {};
606605 return {
607606 config: projectConfig,
@@ -618,7 +617,6 @@ export const createSqliteExecutorBackend = ( · 10 unmodified lines
618617 set: { projectConfigJson: JSON.stringify(config) },
619618 }).run();
620619 },
621− resolveRelativePath: ({ path, scopeRoot }) => resolvePath(scopeRoot, path),
622620 },
623621 state: {
624622 load: () => {
packages/platform/sdk-file/src/index.ts+0−5
@@ -33,7 +33,6 @@ import { · 32 unmodified lines
3333 type LoadedExecutorScopeConfig,
3434 type ResolvedLocalWorkspaceContext,
3535 loadExecutorScopeConfig,
36− resolveConfigRelativePath,
3736 resolveLocalWorkspaceContext,
3837 writeProjectExecutorScopeConfig,
3938 } from "./config";
@@ -120,7 +119,6 @@ const createBoundWorkspaceConfigStore = ( · 80 unmodified lines
120119 ): {
121120 load: () => Effect.Effect<LoadedExecutorScopeConfig, Error, never>;
122121 writeProject: (config: ExecutorScopeConfig) => Effect.Effect<void, Error, never>;
123− resolveRelativePath: typeof resolveConfigRelativePath;
124122 } => ({
125123 load: () =>
126124 bindFileSystem(fileSystem, loadExecutorScopeConfig(context)).pipe(
@@ -131,7 +129,6 @@ const createBoundWorkspaceConfigStore = ( · 4 unmodified lines
131129 fileSystem,
132130 writeProjectExecutorScopeConfig({ context, config }),
133131 ).pipe(Effect.mapError(toError)),
134− resolveRelativePath: resolveConfigRelativePath,
135132 });
136133
137134 const createBoundWorkspaceStateStore = (
@@ -213,8 +210,6 @@ const createBoundSourceTypeDeclarationsRefresher = ( · 75 unmodified lines
213210 const toExecutorScopeContext = (
214211 context: ResolvedLocalWorkspaceContext,
215212 ): ExecutorScopeDescriptor => ({
216− scopeName: context.workspaceName,
217− scopeRoot: context.workspaceRoot,
218213 metadata: {
219214 kind: "file",
220215 configDirectory: context.configDirectory,
packages/platform/sdk/src/backend.ts+0−1
@@ -125,7 +125,6 @@ const toScopeConfigBackend = ( · 124 unmodified lines
125125 ): BoundScopeConfigStore => ({
126126 load: () => toEffect(input.load()),
127127 writeProject: (config) => toEffect(input.writeProject(config)),
128− resolveRelativePath: input.resolveRelativePath,
129128 });
130129
131130 const toScopeStateBackend = (
packages/platform/sdk/src/policies/operations.ts+7−22
@@ -47,10 +47,7 @@ const policyOps = { · 46 unmodified lines
4747
4848 const cloneJson = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
4949
50−const scopePolicyStableKey = (input: {
51− scopeId: ScopeId;
52− scopeRoot?: string | null;
53−}): string => input.scopeRoot?.trim() || input.scopeId;
50+const scopePolicyStableKey = (scopeId: ScopeId): string => scopeId;
5451
5552 const localPolicyIdForKey = (input: {
5653 scopeStableKey: string;
@@ -97,10 +94,7 @@ export const loadRuntimeLocalScopePolicies = (scopeId: ScopeId) => · 40 unmodified lines
9794 ([key, policyConfig]) =>
9895 toLocalScopePolicy({
9996 scopeId,
100− scopeStableKey: scopePolicyStableKey({
101− scopeId,
102− scopeRoot: runtimeLocalScope.scope.scopeRoot,
103− }),
97+ scopeStableKey: scopePolicyStableKey(scopeId),
10498 key,
10599 policyConfig,
106100 state: scopeState.policies[key],
@@ -175,7 +169,7 @@ export const createPolicy = (input: { · 68 unmodified lines
175169 payload: CreatePolicyPayload;
176170 }) =>
177171 Effect.gen(function* () {
178− const runtimeLocalScope = yield* loadScopePolicyContext(
172+ yield* loadScopePolicyContext(
179173 policyOps.create,
180174 input.scopeId,
181175 );
@@ -227,10 +221,7 @@ export const createPolicy = (input: { · 45 unmodified lines
227221 id:
228222 existingState?.id ??
229223 localPolicyIdForKey({
230− scopeStableKey: scopePolicyStableKey({
231− scopeId: input.scopeId,
232− scopeRoot: runtimeLocalScope.scope.scopeRoot,
233− }),
224+ scopeStableKey: scopePolicyStableKey(input.scopeId),
234225 key,
235226 }),
236227 createdAt: existingState?.createdAt ?? now,
@@ -252,10 +243,7 @@ export const createPolicy = (input: { · 15 unmodified lines
252243
253244 return toLocalScopePolicy({
254245 scopeId: input.scopeId,
255− scopeStableKey: scopePolicyStableKey({
256− scopeId: input.scopeId,
257− scopeRoot: runtimeLocalScope.scope.scopeRoot,
258− }),
246+ scopeStableKey: scopePolicyStableKey(input.scopeId),
259247 key,
260248 policyConfig: policies[key]!,
261249 state: scopeState.policies[key],
@@ -297,7 +285,7 @@ export const updatePolicy = (input: { · 35 unmodified lines
297285 payload: UpdatePolicyPayload;
298286 }) =>
299287 Effect.gen(function* () {
300− const runtimeLocalScope = yield* loadScopePolicyContext(
288+ yield* loadScopePolicyContext(
301289 policyOps.update,
302290 input.scopeId,
303291 );
@@ -379,10 +367,7 @@ export const updatePolicy = (input: { · 75 unmodified lines
379367
380368 return toLocalScopePolicy({
381369 scopeId: input.scopeId,
382− scopeStableKey: scopePolicyStableKey({
383− scopeId: input.scopeId,
384− scopeRoot: runtimeLocalScope.scope.scopeRoot,
385− }),
370+ scopeStableKey: scopePolicyStableKey(input.scopeId),
386371 key: existing.key,
387372 policyConfig: policies[existing.key]!,
388373 state: scopeState.policies[existing.key],
packages/platform/sdk/src/runtime/execution/scope/source-catalog.test.ts+0−1
@@ -53,7 +53,6 @@ const makeLoadedCatalog = (input: { · 52 unmodified lines
5353 const noopScopeConfigStore = {
5454 load: () => Effect.die("unexpected config load"),
5555 writeProject: () => Effect.void,
56− resolveRelativePath: (path: string) => Effect.succeed(path),
5756 } as any;
5857
5958 const noopScopeStateStore = {
packages/platform/sdk/src/runtime/index.ts+0−2
@@ -188,7 +188,6 @@ export type BoundScopeConfigStore = { · 187 unmodified lines
188188 writeProject: (
189189 config: ExecutorScopeConfig,
190190 ) => Effect.Effect<void, Error, never>;
191− resolveRelativePath: ScopeConfigStoreShape["resolveRelativePath"];
192191 };
193192
194193 export type BoundScopeStateStore = {
@@ -303,7 +302,6 @@ const toScopeConfigStoreShape = ( · 108 unmodified lines
303302 ): ScopeConfigStoreShape => ({
304303 load: input.load,
305304 writeProject: ({ config }) => input.writeProject(config),
306− resolveRelativePath: input.resolveRelativePath,
307305 });
308306
309307 const toScopeStateStoreShape = (
packages/platform/sdk/src/runtime/scope/storage.ts+0−1
@@ -35,7 +35,6 @@ export type ScopeConfigStoreShape = { · 34 unmodified lines
3535 writeProject: (input: {
3636 config: ExecutorScopeConfig;
3737 }) => import("effect/Effect").Effect<void, Error, never>;
38− resolveRelativePath: (input: { path: string; scopeRoot: string }) => string;
3938 };
4039
4140 export class ScopeConfigStore extends Context.Tag(
packages/platform/sdk/src/scope.ts+0−2
@@ -3,8 +3,6 @@ import type { · 2 unmodified lines
33 } from "./schema";
44
55 export type ExecutorScopeDescriptor = {
6− scopeName: string;
7− scopeRoot?: string | null;
86 actorScopeId?: ScopeId | null;
97 resolutionScopeIds?: ReadonlyArray<ScopeId>;
108 metadata?: Readonly<Record<string, unknown>>;