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
36const executor = await createExecutor({36const executor = await createExecutor({
37 backend: createSqliteExecutorBackend({37 backend: createSqliteExecutorBackend({
38 databasePath: "./executor.sqlite",38 databasePath: "./executor.sqlite",
39 scopeName: "Acme",
40 }),39 }),
41});40});
42```41```
examples/sqlite-sdk-consumer/src/main.ts+0−2
@@ -8,8 +8,6 @@ const databasePath = process.env.DATABASE_PATH · 7 unmodified lines
8const executor = await createExecutor({8const executor = await createExecutor({
9 backend: createSqliteExecutorBackend({9 backend: createSqliteExecutorBackend({
10 databasePath,10 databasePath,
11 scopeName: "SQLite Example Workspace",
12 scopeRoot: process.cwd(),
13 }),11 }),
14});12});
15 13
examples/sqlite-sdk-consumer/src/sqlite-backend.ts+6−8
@@ -23,7 +23,7 @@ import type { · 22 unmodified lines
23 Execution,23 Execution,
24 ExecutionInteraction,24 ExecutionInteraction,
25 ExecutionStep,25 ExecutionStep,
26 LocalExecutorConfig,26 ExecutorScopeConfig,
27 LocalInstallation,27 LocalInstallation,
28 SecretMaterial,28 SecretMaterial,
29 SecretRef,29 SecretRef,
@@ -35,6 +35,9 @@ import { · 5 unmodified lines
35 SourceCatalogIdSchema,35 SourceCatalogIdSchema,
36 SourceCatalogRevisionIdSchema,36 SourceCatalogRevisionIdSchema,
37} from "@executor/platform-sdk/schema";37} from "@executor/platform-sdk/schema";
38import type {
39 SecretMaterialStoredDataRecord,
40} from "@executor/platform-sdk/runtime";
38import {41import {
39 contentHash,42 contentHash,
40 snapshotFromSourceCatalogSyncResult,43 snapshotFromSourceCatalogSyncResult,
@@ -42,8 +45,6 @@ import { · 1 unmodified line
42 45
43export type CreateSqliteExecutorBackendOptions = {46export type CreateSqliteExecutorBackendOptions = {
44 databasePath?: string;47 databasePath?: string;
45 scopeName?: string;
46 scopeRoot?: string | null;
47 scopeId?: string;48 scopeId?: string;
48 actorScopeId?: string;49 actorScopeId?: string;
49};50};
@@ -382,7 +383,7 @@ const createStorageDomains = ( · 332 unmodified lines
382 }383 }
383 : null;384 : null;
384 },385 },
385 upsert: (record: { secretId: SecretMaterial["id"]; data: unknown }) => {386 upsert: (record: SecretMaterialStoredDataRecord) => {
386 store.db.insert(secretMaterialStoredData).values({387 store.db.insert(secretMaterialStoredData).values({
387 secretId: record.secretId,388 secretId: record.secretId,
388 json: JSON.stringify(record.data),389 json: JSON.stringify(record.data),
@@ -568,8 +569,6 @@ export const createSqliteExecutorBackend = ( · 179 unmodified lines
568 569
569 return {570 return {
570 scope: {571 scope: {
571 scopeName: options.scopeName ?? "SQLite SDK Example",
572 scopeRoot: options.scopeRoot ?? null,
573 metadata: {572 metadata: {
574 kind: "sqlite",573 kind: "sqlite",
575 databasePath,574 databasePath,
@@ -601,7 +600,7 @@ export const createSqliteExecutorBackend = ( · 25 unmodified lines
601 load: () => {600 load: () => {
602 const row = store.db.select().from(scopeConfigs).where(eq(scopeConfigs.key, "project")).get();601 const row = store.db.select().from(scopeConfigs).where(eq(scopeConfigs.key, "project")).get();
603 const projectConfig = row602 const projectConfig = row
604 ? parseJson<LocalExecutorConfig>(row.projectConfigJson)603 ? parseJson<ExecutorScopeConfig>(row.projectConfigJson)
605 : {};604 : {};
606 return {605 return {
607 config: projectConfig,606 config: projectConfig,
@@ -618,7 +617,6 @@ export const createSqliteExecutorBackend = ( · 10 unmodified lines
618 set: { projectConfigJson: JSON.stringify(config) },617 set: { projectConfigJson: JSON.stringify(config) },
619 }).run();618 }).run();
620 },619 },
621 resolveRelativePath: ({ path, scopeRoot }) => resolvePath(scopeRoot, path),
622 },620 },
623 state: {621 state: {
624 load: () => {622 load: () => {
packages/platform/sdk-file/src/index.ts+0−5
@@ -33,7 +33,6 @@ import { · 32 unmodified lines
33 type LoadedExecutorScopeConfig,33 type LoadedExecutorScopeConfig,
34 type ResolvedLocalWorkspaceContext,34 type ResolvedLocalWorkspaceContext,
35 loadExecutorScopeConfig,35 loadExecutorScopeConfig,
36 resolveConfigRelativePath,
37 resolveLocalWorkspaceContext,36 resolveLocalWorkspaceContext,
38 writeProjectExecutorScopeConfig,37 writeProjectExecutorScopeConfig,
39} from "./config";38} from "./config";
@@ -120,7 +119,6 @@ const createBoundWorkspaceConfigStore = ( · 80 unmodified lines
120): {119): {
121 load: () => Effect.Effect<LoadedExecutorScopeConfig, Error, never>;120 load: () => Effect.Effect<LoadedExecutorScopeConfig, Error, never>;
122 writeProject: (config: ExecutorScopeConfig) => Effect.Effect<void, Error, never>;121 writeProject: (config: ExecutorScopeConfig) => Effect.Effect<void, Error, never>;
123 resolveRelativePath: typeof resolveConfigRelativePath;
124} => ({122} => ({
125 load: () =>123 load: () =>
126 bindFileSystem(fileSystem, loadExecutorScopeConfig(context)).pipe(124 bindFileSystem(fileSystem, loadExecutorScopeConfig(context)).pipe(
@@ -131,7 +129,6 @@ const createBoundWorkspaceConfigStore = ( · 4 unmodified lines
131 fileSystem,129 fileSystem,
132 writeProjectExecutorScopeConfig({ context, config }),130 writeProjectExecutorScopeConfig({ context, config }),
133 ).pipe(Effect.mapError(toError)),131 ).pipe(Effect.mapError(toError)),
134 resolveRelativePath: resolveConfigRelativePath,
135});132});
136 133
137const createBoundWorkspaceStateStore = (134const createBoundWorkspaceStateStore = (
@@ -213,8 +210,6 @@ const createBoundSourceTypeDeclarationsRefresher = ( · 75 unmodified lines
213const toExecutorScopeContext = (210const toExecutorScopeContext = (
214 context: ResolvedLocalWorkspaceContext,211 context: ResolvedLocalWorkspaceContext,
215): ExecutorScopeDescriptor => ({212): ExecutorScopeDescriptor => ({
216 scopeName: context.workspaceName,
217 scopeRoot: context.workspaceRoot,
218 metadata: {213 metadata: {
219 kind: "file",214 kind: "file",
220 configDirectory: context.configDirectory,215 configDirectory: context.configDirectory,
packages/platform/sdk/src/backend.ts+0−1
@@ -125,7 +125,6 @@ const toScopeConfigBackend = ( · 124 unmodified lines
125): BoundScopeConfigStore => ({125): BoundScopeConfigStore => ({
126 load: () => toEffect(input.load()),126 load: () => toEffect(input.load()),
127 writeProject: (config) => toEffect(input.writeProject(config)),127 writeProject: (config) => toEffect(input.writeProject(config)),
128 resolveRelativePath: input.resolveRelativePath,
129});128});
130 129
131const toScopeStateBackend = (130const toScopeStateBackend = (
packages/platform/sdk/src/policies/operations.ts+7−22
@@ -47,10 +47,7 @@ const policyOps = { · 46 unmodified lines
47 47
48const cloneJson = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;48const cloneJson = <T>(value: T): T => JSON.parse(JSON.stringify(value)) as T;
49 49
50const scopePolicyStableKey = (input: {50const scopePolicyStableKey = (scopeId: ScopeId): string => scopeId;
51 scopeId: ScopeId;
52 scopeRoot?: string | null;
53}): string => input.scopeRoot?.trim() || input.scopeId;
54 51
55const localPolicyIdForKey = (input: {52const localPolicyIdForKey = (input: {
56 scopeStableKey: string;53 scopeStableKey: string;
@@ -97,10 +94,7 @@ export const loadRuntimeLocalScopePolicies = (scopeId: ScopeId) => · 40 unmodified lines
97 ([key, policyConfig]) =>94 ([key, policyConfig]) =>
98 toLocalScopePolicy({95 toLocalScopePolicy({
99 scopeId,96 scopeId,
100 scopeStableKey: scopePolicyStableKey({97 scopeStableKey: scopePolicyStableKey(scopeId),
101 scopeId,
102 scopeRoot: runtimeLocalScope.scope.scopeRoot,
103 }),
104 key,98 key,
105 policyConfig,99 policyConfig,
106 state: scopeState.policies[key],100 state: scopeState.policies[key],
@@ -175,7 +169,7 @@ export const createPolicy = (input: { · 68 unmodified lines
175 payload: CreatePolicyPayload;169 payload: CreatePolicyPayload;
176}) =>170}) =>
177 Effect.gen(function* () {171 Effect.gen(function* () {
178 const runtimeLocalScope = yield* loadScopePolicyContext(172 yield* loadScopePolicyContext(
179 policyOps.create,173 policyOps.create,
180 input.scopeId,174 input.scopeId,
181 );175 );
@@ -227,10 +221,7 @@ export const createPolicy = (input: { · 45 unmodified lines
227 id:221 id:
228 existingState?.id ??222 existingState?.id ??
229 localPolicyIdForKey({223 localPolicyIdForKey({
230 scopeStableKey: scopePolicyStableKey({224 scopeStableKey: scopePolicyStableKey(input.scopeId),
231 scopeId: input.scopeId,
232 scopeRoot: runtimeLocalScope.scope.scopeRoot,
233 }),
234 key,225 key,
235 }),226 }),
236 createdAt: existingState?.createdAt ?? now,227 createdAt: existingState?.createdAt ?? now,
@@ -252,10 +243,7 @@ export const createPolicy = (input: { · 15 unmodified lines
252 243
253 return toLocalScopePolicy({244 return toLocalScopePolicy({
254 scopeId: input.scopeId,245 scopeId: input.scopeId,
255 scopeStableKey: scopePolicyStableKey({246 scopeStableKey: scopePolicyStableKey(input.scopeId),
256 scopeId: input.scopeId,
257 scopeRoot: runtimeLocalScope.scope.scopeRoot,
258 }),
259 key,247 key,
260 policyConfig: policies[key]!,248 policyConfig: policies[key]!,
261 state: scopeState.policies[key],249 state: scopeState.policies[key],
@@ -297,7 +285,7 @@ export const updatePolicy = (input: { · 35 unmodified lines
297 payload: UpdatePolicyPayload;285 payload: UpdatePolicyPayload;
298}) =>286}) =>
299 Effect.gen(function* () {287 Effect.gen(function* () {
300 const runtimeLocalScope = yield* loadScopePolicyContext(288 yield* loadScopePolicyContext(
301 policyOps.update,289 policyOps.update,
302 input.scopeId,290 input.scopeId,
303 );291 );
@@ -379,10 +367,7 @@ export const updatePolicy = (input: { · 75 unmodified lines
379 367
380 return toLocalScopePolicy({368 return toLocalScopePolicy({
381 scopeId: input.scopeId,369 scopeId: input.scopeId,
382 scopeStableKey: scopePolicyStableKey({370 scopeStableKey: scopePolicyStableKey(input.scopeId),
383 scopeId: input.scopeId,
384 scopeRoot: runtimeLocalScope.scope.scopeRoot,
385 }),
386 key: existing.key,371 key: existing.key,
387 policyConfig: policies[existing.key]!,372 policyConfig: policies[existing.key]!,
388 state: scopeState.policies[existing.key],373 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
53const noopScopeConfigStore = {53const noopScopeConfigStore = {
54 load: () => Effect.die("unexpected config load"),54 load: () => Effect.die("unexpected config load"),
55 writeProject: () => Effect.void,55 writeProject: () => Effect.void,
56 resolveRelativePath: (path: string) => Effect.succeed(path),
57} as any;56} as any;
58 57
59const noopScopeStateStore = {58const noopScopeStateStore = {
packages/platform/sdk/src/runtime/index.ts+0−2
@@ -188,7 +188,6 @@ export type BoundScopeConfigStore = { · 187 unmodified lines
188 writeProject: (188 writeProject: (
189 config: ExecutorScopeConfig,189 config: ExecutorScopeConfig,
190 ) => Effect.Effect<void, Error, never>;190 ) => Effect.Effect<void, Error, never>;
191 resolveRelativePath: ScopeConfigStoreShape["resolveRelativePath"];
192};191};
193 192
194export type BoundScopeStateStore = {193export type BoundScopeStateStore = {
@@ -303,7 +302,6 @@ const toScopeConfigStoreShape = ( · 108 unmodified lines
303): ScopeConfigStoreShape => ({302): ScopeConfigStoreShape => ({
304 load: input.load,303 load: input.load,
305 writeProject: ({ config }) => input.writeProject(config),304 writeProject: ({ config }) => input.writeProject(config),
306 resolveRelativePath: input.resolveRelativePath,
307});305});
308 306
309const toScopeStateStoreShape = (307const toScopeStateStoreShape = (
packages/platform/sdk/src/runtime/scope/storage.ts+0−1
@@ -35,7 +35,6 @@ export type ScopeConfigStoreShape = { · 34 unmodified lines
35 writeProject: (input: {35 writeProject: (input: {
36 config: ExecutorScopeConfig;36 config: ExecutorScopeConfig;
37 }) => import("effect/Effect").Effect<void, Error, never>;37 }) => import("effect/Effect").Effect<void, Error, never>;
38 resolveRelativePath: (input: { path: string; scopeRoot: string }) => string;
39};38};
40 39
41export class ScopeConfigStore extends Context.Tag(40export class ScopeConfigStore extends Context.Tag(
packages/platform/sdk/src/scope.ts+0−2
@@ -3,8 +3,6 @@ import type { · 2 unmodified lines
3} from "./schema";3} from "./schema";
4 4
5export type ExecutorScopeDescriptor = {5export type ExecutorScopeDescriptor = {
6 scopeName: string;
7 scopeRoot?: string | null;
8 actorScopeId?: ScopeId | null;6 actorScopeId?: ScopeId | null;
9 resolutionScopeIds?: ReadonlyArray<ScopeId>;7 resolutionScopeIds?: ReadonlyArray<ScopeId>;
10 metadata?: Readonly<Record<string, unknown>>;8 metadata?: Readonly<Record<string, unknown>>;