@tailor-platform/sdk 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/{dist/cli/index.mjs → bin/tailor.mjs} +1 -1
  3. package/dist/application-BZfk4HKm.mjs +3 -0
  4. package/dist/{application-D77KJFKD.mjs → application-F-nl107y.mjs} +121 -27
  5. package/dist/application-F-nl107y.mjs.map +1 -0
  6. package/dist/cli/commands/deploy/tailordb/index.d.mts +2 -1
  7. package/dist/cli/commands/deploy/types.d.mts +2 -1
  8. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +52 -22
  9. package/dist/cli/commands/tailordb/migrate/file-state.d.mts +1 -0
  10. package/dist/cli/commands/tailordb/migrate/generate.d.mts +6 -0
  11. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +22 -0
  12. package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +2 -2
  13. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +9 -2
  14. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +30 -9
  15. package/dist/cli/lib.d.mts +4 -4
  16. package/dist/cli/lib.mjs +3 -482
  17. package/dist/cli/lib.mjs.map +1 -1
  18. package/dist/cli/main.mjs +1151 -208
  19. package/dist/cli/main.mjs.map +1 -1
  20. package/dist/cli/ts-hook.mjs +52 -7
  21. package/dist/completion/zsh-worker.zsh +167 -4
  22. package/dist/configure/index.d.mts +3 -3
  23. package/dist/configure/index.mjs +90 -23
  24. package/dist/configure/index.mjs.map +1 -1
  25. package/dist/configure/services/index.d.mts +3 -2
  26. package/dist/configure/services/tailordb/index.d.mts +2 -1
  27. package/dist/configure/services/tailordb/schema.d.mts +46 -46
  28. package/dist/configure/services/tailordb/types.d.mts +30 -4
  29. package/dist/configure/services/workflow/index.d.mts +2 -2
  30. package/dist/configure/services/workflow/wait-point.d.mts +72 -13
  31. package/dist/{crashreport-B5LqCTfF.mjs → crashreport-CIIfLnoO.mjs} +2 -2
  32. package/dist/{crashreport-B5LqCTfF.mjs.map → crashreport-CIIfLnoO.mjs.map} +1 -1
  33. package/dist/{crashreport-eI7ty7ok.mjs → crashreport-CINZ5dVN.mjs} +1 -1
  34. package/dist/errors-BVb6vYGy.mjs +89 -0
  35. package/dist/errors-BVb6vYGy.mjs.map +1 -0
  36. package/dist/kysely/index.d.mts +53 -5
  37. package/dist/kysely/index.mjs +7 -2
  38. package/dist/kysely/index.mjs.map +1 -1
  39. package/dist/{logger-CXQq9YIp.mjs → logger-DSdExfor.mjs} +83 -42
  40. package/dist/logger-DSdExfor.mjs.map +1 -0
  41. package/dist/plugin/builtin/seed/index.mjs +1 -1
  42. package/dist/{register-ts-hook-BU18uU44.mjs → register-ts-hook-ClI226n2.mjs} +3541 -703
  43. package/dist/register-ts-hook-ClI226n2.mjs.map +1 -0
  44. package/dist/schema--xYWRGfe.mjs.map +1 -1
  45. package/dist/seed/index.d.mts +52 -3
  46. package/dist/seed/index.mjs +200 -44
  47. package/dist/seed/index.mjs.map +1 -1
  48. package/dist/{seed-B-yckgQY.mjs → seed-xqM9WIHP.mjs} +8 -8
  49. package/dist/seed-xqM9WIHP.mjs.map +1 -0
  50. package/dist/{service-k1xy_A5G.mjs → service-C_WpbKHu.mjs} +39 -5
  51. package/dist/service-C_WpbKHu.mjs.map +1 -0
  52. package/dist/service-D1RCdzIL.mjs +3 -0
  53. package/dist/{service-B5WynBHQ.mjs → service-hZskxZmg.mjs} +3 -3
  54. package/dist/{service-B5WynBHQ.mjs.map → service-hZskxZmg.mjs.map} +1 -1
  55. package/dist/{service_pb-D5--My_M.mjs → service_pb-BEWj1pOV.mjs} +2 -2
  56. package/dist/{service_pb-D5--My_M.mjs.map → service_pb-BEWj1pOV.mjs.map} +1 -1
  57. package/dist/{service_pb-i8CmnQP4.mjs → service_pb-BjlhvK9E.mjs} +1 -1
  58. package/dist/utils/test/index.d.mts +6 -3
  59. package/dist/utils/test/index.mjs +25 -13
  60. package/dist/utils/test/index.mjs.map +1 -1
  61. package/dist/vitest/index.d.mts +2 -1
  62. package/dist/vitest/index.mjs +167 -3
  63. package/dist/vitest/index.mjs.map +1 -1
  64. package/dist/vitest/mocks/workflow.d.mts +13 -1
  65. package/dist/vitest/pglite-kysely.d.mts +43 -0
  66. package/dist/wait-point-invoker-__oE88_P.mjs +148 -0
  67. package/dist/wait-point-invoker-__oE88_P.mjs.map +1 -0
  68. package/dist/wait-point-registry-TL99zotw.mjs +47 -0
  69. package/dist/wait-point-registry-TL99zotw.mjs.map +1 -0
  70. package/dist/{workspace_resource_pb-DXnO2AT-.mjs → workspace_resource_pb-HNIL_Vfj.mjs} +10 -2
  71. package/dist/{workspace_resource_pb-DXnO2AT-.mjs.map → workspace_resource_pb-HNIL_Vfj.mjs.map} +1 -1
  72. package/docs/cli/setup.md +14 -1
  73. package/docs/cli/tailordb.md +96 -28
  74. package/docs/cli-reference.md +15 -12
  75. package/docs/configuration.md +1 -1
  76. package/docs/github-actions.md +73 -28
  77. package/docs/migration/v2.md +55 -1
  78. package/docs/plugin/custom.md +48 -48
  79. package/docs/plugin/index.md +24 -24
  80. package/docs/services/auth.md +10 -10
  81. package/docs/services/executor.md +1 -1
  82. package/docs/services/resolver.md +2 -2
  83. package/docs/services/tailordb-migration.md +485 -84
  84. package/docs/services/tailordb.md +28 -28
  85. package/docs/services/workflow.md +52 -2
  86. package/docs/testing.md +14 -0
  87. package/package.json +12 -7
  88. package/dist/application-Af1zIqSI.mjs +0 -3
  89. package/dist/application-D77KJFKD.mjs.map +0 -1
  90. package/dist/errors-D7583Zz7.mjs +0 -58
  91. package/dist/errors-D7583Zz7.mjs.map +0 -1
  92. package/dist/logger-CXQq9YIp.mjs.map +0 -1
  93. package/dist/register-ts-hook-BU18uU44.mjs.map +0 -1
  94. package/dist/seed-B-yckgQY.mjs.map +0 -1
  95. package/dist/service-M7OYziQP.mjs +0 -3
  96. package/dist/service-k1xy_A5G.mjs.map +0 -1
  97. package/dist/test-env-key-D7UkZp99.mjs +0 -75
  98. package/dist/test-env-key-D7UkZp99.mjs.map +0 -1
@@ -2,7 +2,7 @@ import { TailorEnv } from "../../runtime/types.mjs";
2
2
  import { ExecJobFunctionOptions, StartWorkflowOptions } from "../../runtime/workflow.mjs";
3
3
  import { WorkflowJob } from "../../configure/services/workflow/job.mjs";
4
4
  import { Workflow } from "../../configure/services/workflow/workflow.mjs";
5
- import { WaitPointInstance } from "../../configure/services/workflow/wait-point.mjs";
5
+ import { ParameterizedWaitPointInstance, WaitPointInstance } from "../../configure/services/workflow/wait-point.mjs";
6
6
  import { Mock } from "vitest";
7
7
  //#region src/vitest/mocks/workflow.d.ts
8
8
  type JobHandler = (jobName: string, args: unknown, options?: ExecJobFunctionOptions) => unknown;
@@ -72,6 +72,18 @@ declare function mockWorkflow(): {
72
72
  resolve: Mock<WaitPointInstance<Payload, Result>["resolve"]>;
73
73
  setResolvePayload(payload: WaitPayload<Payload>): void;
74
74
  };
75
+ /**
76
+ * Get stable, typed mocks for one param binding of a parameterized wait point.
77
+ * Calls made with other bindings fall through to the platform mock.
78
+ * @param definition - Parameterized wait point definition to mock
79
+ * @param params - Param binding to intercept, as passed to `.with()`
80
+ * @returns Typed wait point mock control object
81
+ */
82
+ waitPointWith<Params extends object, Payload, Result>(definition: ParameterizedWaitPointInstance<Params, Payload, Result>, params: Params): {
83
+ wait: Mock<WaitPointInstance<Payload, Result>["wait"]>;
84
+ resolve: Mock<WaitPointInstance<Payload, Result>["resolve"]>;
85
+ setResolvePayload(payload: WaitPayload<Payload>): void;
86
+ };
75
87
  /**
76
88
  * Set a fallback job handler. Called when the enqueue queue is empty.
77
89
  * @param handler - Function returning a result for a job name, args, and options
@@ -0,0 +1,43 @@
1
+ import { Kysely } from "kysely";
2
+ //#region src/vitest/pglite-kysely.d.ts
3
+ /**
4
+ * The subset of a `@electric-sql/pglite` `PGlite` instance used by
5
+ * {@link createKyselyPGlite}. Any client with a compatible `query`/`close`
6
+ * pair works.
7
+ */
8
+ interface PGliteClient {
9
+ /** Run a single SQL statement with positional (`$1`, `$2`, ...) parameters. */
10
+ query(query: string, params?: unknown[]): Promise<{
11
+ rows: unknown[];
12
+ affectedRows?: number;
13
+ }>;
14
+ /** Release the underlying database. Called by `db.destroy()`. */
15
+ close(): Promise<void>;
16
+ }
17
+ /**
18
+ * Create a Kysely instance backed by a PGlite in-memory Postgres, for
19
+ * executing a migration script's queries against real data in tests.
20
+ * Pass the migration's schema as the type argument, e.g.
21
+ * `createKyselyPGlite<Database>(new PGlite())`.
22
+ *
23
+ * PGlite runs full PostgreSQL while TailorDB supports a subset of it, so a
24
+ * statement passing here can still be rejected by the platform; keep a
25
+ * statement-level test (see `createKyselyMock`) alongside.
26
+ * @param client - A `PGlite` instance from `@electric-sql/pglite`
27
+ * @returns A Kysely instance that executes queries on the client and closes it on `destroy()`
28
+ * @example
29
+ * ```typescript
30
+ * // migrations/0005/migrate.test.ts
31
+ * import { PGlite } from "@electric-sql/pglite";
32
+ * import { createKyselyPGlite } from "@tailor-platform/sdk/vitest";
33
+ * import type { Database } from "./db";
34
+ * import { main } from "./migrate";
35
+ *
36
+ * const db = createKyselyPGlite<Database>(new PGlite());
37
+ * // create tables matching db.ts, insert rows, then:
38
+ * await db.transaction().execute((trx) => main(trx));
39
+ * ```
40
+ */
41
+ declare function createKyselyPGlite<DB = Record<string, never>>(client: PGliteClient): Kysely<DB>;
42
+ //#endregion
43
+ export { PGliteClient, createKyselyPGlite };
@@ -0,0 +1,148 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+
3
+ //#region src/configure/services/workflow/test-env-key.ts
4
+ /**
5
+ * Typed accessors for the test-time globalThis slot used to pass `env` from
6
+ * `mockWorkflow().setEnv()` (in `@tailor-platform/sdk/vitest`) to
7
+ * `runWorkflowLocally()` job bodies. The slot key is private to this
8
+ * module; callers go through the get/set/clear functions below so both sides
9
+ * share the same access path.
10
+ *
11
+ * Lives in its own file (with no `@/` imports) so `vitest/mock.ts` can load
12
+ * it from nested Vitest configs that do not resolve `@/` aliases.
13
+ * @internal
14
+ */
15
+ const SLOT_KEY = "__tailorWorkflowTestEnv";
16
+ let invokerStorage;
17
+ function workflowInvokerStorage() {
18
+ if (!invokerStorage) invokerStorage = new AsyncLocalStorage();
19
+ return invokerStorage;
20
+ }
21
+ /**
22
+ * Read the test-time env slot.
23
+ * @returns Current env, or `undefined` when unset.
24
+ * @internal
25
+ */
26
+ function readWorkflowTestEnv() {
27
+ return globalThis[SLOT_KEY];
28
+ }
29
+ /**
30
+ * Write the test-time env slot.
31
+ * @param env - Env value to expose to `runWorkflowLocally()` job bodies.
32
+ * @internal
33
+ */
34
+ function writeWorkflowTestEnv(env) {
35
+ globalThis[SLOT_KEY] = env;
36
+ }
37
+ /**
38
+ * Clear the test-time env slot.
39
+ * @internal
40
+ */
41
+ function clearWorkflowTestEnv() {
42
+ delete globalThis[SLOT_KEY];
43
+ }
44
+ function withWorkflowTestInvoker(invoker, run) {
45
+ return workflowInvokerStorage().run(invoker, run);
46
+ }
47
+ function readRuntimeInvoker() {
48
+ const runtime = globalThis.tailor?.context?.getInvoker;
49
+ const raw = runtime?.();
50
+ if (!raw) return null;
51
+ return {
52
+ id: raw.id,
53
+ type: raw.type,
54
+ workspaceId: raw.workspaceId,
55
+ attributes: raw.attributeMap ?? (Array.isArray(raw.attributes) ? {} : raw.attributes ?? {}),
56
+ attributeList: raw.attributeList ?? (Array.isArray(raw.attributes) ? raw.attributes : [])
57
+ };
58
+ }
59
+ function buildJobContext() {
60
+ const storedInvoker = invokerStorage?.getStore();
61
+ const invoker = storedInvoker === void 0 ? readRuntimeInvoker() : storedInvoker;
62
+ const fromGlobal = readWorkflowTestEnv();
63
+ if (fromGlobal !== void 0) return {
64
+ env: { ...fromGlobal },
65
+ invoker
66
+ };
67
+ return {
68
+ env: {},
69
+ invoker
70
+ };
71
+ }
72
+
73
+ //#endregion
74
+ //#region src/configure/services/workflow/wait-point-invoker.ts
75
+ const WAIT_POINT_INVOKER = Symbol.for("tailor-platform/sdk:wait-point-invoker");
76
+ const WAIT_POINT_KEY = Symbol.for("tailor-platform/sdk:wait-point-key");
77
+ function getPlatformWorkflow() {
78
+ const workflow = globalThis.tailor?.workflow;
79
+ if (!workflow) throw new Error("tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment, or acquire mockWorkflow() from @tailor-platform/sdk/vitest and set a wait/resolve handler.");
80
+ return workflow;
81
+ }
82
+ /**
83
+ * Create the invoker a single wait point definition delegates to.
84
+ * @returns An invoker bound to the platform runtime
85
+ */
86
+ function createWaitPointInvoker() {
87
+ return {
88
+ wait(key, payload) {
89
+ return getPlatformWorkflow().wait(key, payload);
90
+ },
91
+ async resolve(key, executionId, callback) {
92
+ await getPlatformWorkflow().resolve(executionId, key, callback);
93
+ }
94
+ };
95
+ }
96
+ /**
97
+ * Attach an invoker to a wait point definition so test doubles can intercept it.
98
+ *
99
+ * The slot itself is fixed once attached; a double swaps the invoker's `wait` /
100
+ * `resolve` methods rather than the invoker object.
101
+ * @param target - Wait point definition to attach to
102
+ * @param invoker - Invoker the definition delegates to
103
+ * @returns The same definition
104
+ */
105
+ function attachWaitPointInvoker(target, invoker) {
106
+ Object.defineProperty(target, WAIT_POINT_INVOKER, {
107
+ value: invoker,
108
+ enumerable: false,
109
+ configurable: false,
110
+ writable: false
111
+ });
112
+ return target;
113
+ }
114
+ /**
115
+ * Read the invoker attached to a wait point definition.
116
+ * @param target - Wait point definition to read from
117
+ * @returns The attached invoker, or undefined when the value is not a wait point
118
+ */
119
+ function getWaitPointInvoker(target) {
120
+ return target[WAIT_POINT_INVOKER];
121
+ }
122
+ /**
123
+ * Record the resolved key on a wait point bound by `.with()`.
124
+ * @param target - Bound wait point to attach to
125
+ * @param key - Resolved runtime key
126
+ * @returns The same bound wait point
127
+ */
128
+ function attachWaitPointKey(target, key) {
129
+ Object.defineProperty(target, WAIT_POINT_KEY, {
130
+ value: key,
131
+ enumerable: false,
132
+ configurable: false,
133
+ writable: false
134
+ });
135
+ return target;
136
+ }
137
+ /**
138
+ * Read the resolved key recorded on a bound wait point.
139
+ * @param target - Bound wait point to read from
140
+ * @returns The resolved key, or undefined when the value is not a bound wait point
141
+ */
142
+ function getWaitPointKey(target) {
143
+ return target[WAIT_POINT_KEY];
144
+ }
145
+
146
+ //#endregion
147
+ export { getWaitPointKey as a, readWorkflowTestEnv as c, getWaitPointInvoker as i, withWorkflowTestInvoker as l, attachWaitPointKey as n, buildJobContext as o, createWaitPointInvoker as r, clearWorkflowTestEnv as s, attachWaitPointInvoker as t, writeWorkflowTestEnv as u };
148
+ //# sourceMappingURL=wait-point-invoker-__oE88_P.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-point-invoker-__oE88_P.mjs","names":["platform"],"sources":["../src/configure/services/workflow/test-env-key.ts","../src/configure/services/workflow/wait-point-invoker.ts"],"sourcesContent":["/**\n * Typed accessors for the test-time globalThis slot used to pass `env` from\n * `mockWorkflow().setEnv()` (in `@tailor-platform/sdk/vitest`) to\n * `runWorkflowLocally()` job bodies. The slot key is private to this\n * module; callers go through the get/set/clear functions below so both sides\n * share the same access path.\n *\n * Lives in its own file (with no `@/` imports) so `vitest/mock.ts` can load\n * it from nested Vitest configs that do not resolve `@/` aliases.\n * @internal\n */\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport type { TailorEnv, TailorPrincipal } from \"../../../runtime/types\";\n\nconst SLOT_KEY = \"__tailorWorkflowTestEnv\";\n\ntype AsyncLocalStorageLike<T> = {\n getStore(): T | undefined;\n run<R>(store: T, callback: () => R): R;\n};\n\nlet invokerStorage: AsyncLocalStorageLike<TailorPrincipal | null> | undefined;\n\nfunction workflowInvokerStorage(): AsyncLocalStorageLike<TailorPrincipal | null> {\n if (!invokerStorage) {\n invokerStorage = new AsyncLocalStorage<TailorPrincipal | null>();\n }\n return invokerStorage;\n}\n\n/**\n * Read the test-time env slot.\n * @returns Current env, or `undefined` when unset.\n * @internal\n */\nexport function readWorkflowTestEnv(): TailorEnv | undefined {\n return (globalThis as unknown as Record<string, TailorEnv | undefined>)[SLOT_KEY];\n}\n\n/**\n * Write the test-time env slot.\n * @param env - Env value to expose to `runWorkflowLocally()` job bodies.\n * @internal\n */\nexport function writeWorkflowTestEnv(env: TailorEnv): void {\n (globalThis as unknown as Record<string, TailorEnv>)[SLOT_KEY] = env;\n}\n\n/**\n * Clear the test-time env slot.\n * @internal\n */\nexport function clearWorkflowTestEnv(): void {\n delete (globalThis as unknown as Record<string, unknown>)[SLOT_KEY];\n}\n\nexport function withWorkflowTestInvoker<T>(invoker: TailorPrincipal | null, run: () => T): T {\n return workflowInvokerStorage().run(invoker, run);\n}\n\ntype RuntimeInvoker = {\n id: string;\n type: \"user\" | \"machine_user\";\n workspaceId: string;\n attributes?: string[] | TailorPrincipal[\"attributes\"];\n attributeMap?: TailorPrincipal[\"attributes\"];\n attributeList?: TailorPrincipal[\"attributeList\"];\n};\n\nfunction readRuntimeInvoker(): TailorPrincipal | null {\n const runtime = (\n globalThis as unknown as {\n tailor?: { context?: { getInvoker?: () => RuntimeInvoker | null } };\n }\n ).tailor?.context?.getInvoker;\n const raw = runtime?.();\n if (!raw) return null;\n return {\n id: raw.id,\n type: raw.type,\n workspaceId: raw.workspaceId,\n attributes: raw.attributeMap ?? (Array.isArray(raw.attributes) ? {} : (raw.attributes ?? {})),\n attributeList: (raw.attributeList ??\n (Array.isArray(raw.attributes) ? raw.attributes : [])) as TailorPrincipal[\"attributeList\"],\n };\n}\n\n// Shallow-copied to isolate against cross-trigger mutation.\nexport function buildJobContext(): { env: TailorEnv; invoker: TailorPrincipal | null } {\n const storedInvoker = invokerStorage?.getStore();\n const invoker = storedInvoker === undefined ? readRuntimeInvoker() : storedInvoker;\n const fromGlobal = readWorkflowTestEnv();\n if (fromGlobal !== undefined) return { env: { ...fromGlobal }, invoker };\n return { env: {} as TailorEnv, invoker };\n}\n","import type { PlatformWorkflowAPI } from \"#/runtime/workflow\";\n\n// Not re-exported from the workflow barrel: the slot exists so the Vitest mock\n// can intercept parameterized wait points, whose `wait`/`resolve` live on\n// short-lived objects returned by `.with()` rather than on the definition.\nconst WAIT_POINT_INVOKER: unique symbol = Symbol.for(\"tailor-platform/sdk:wait-point-invoker\");\nconst WAIT_POINT_KEY: unique symbol = Symbol.for(\"tailor-platform/sdk:wait-point-key\");\n\n/** Indirection every wait point call routes through, keyed by resolved key. */\nexport interface WaitPointInvoker {\n wait(key: string, payload: unknown): unknown;\n resolve(\n key: string,\n executionId: string,\n callback: (payload: unknown) => unknown | Promise<unknown>,\n ): Promise<void>;\n}\n\nfunction getPlatformWorkflow(): PlatformWorkflowAPI {\n const platform = globalThis as { tailor?: { workflow?: PlatformWorkflowAPI } };\n const workflow = platform.tailor?.workflow;\n if (!workflow) {\n throw new Error(\n \"tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment, \" +\n \"or acquire mockWorkflow() from @tailor-platform/sdk/vitest and set a wait/resolve handler.\",\n );\n }\n return workflow;\n}\n\n/**\n * Create the invoker a single wait point definition delegates to.\n * @returns An invoker bound to the platform runtime\n */\nexport function createWaitPointInvoker(): WaitPointInvoker {\n return {\n wait(key, payload) {\n return getPlatformWorkflow().wait(key, payload);\n },\n async resolve(key, executionId, callback) {\n await getPlatformWorkflow().resolve(executionId, key, callback);\n },\n };\n}\n\n/**\n * Attach an invoker to a wait point definition so test doubles can intercept it.\n *\n * The slot itself is fixed once attached; a double swaps the invoker's `wait` /\n * `resolve` methods rather than the invoker object.\n * @param target - Wait point definition to attach to\n * @param invoker - Invoker the definition delegates to\n * @returns The same definition\n */\nexport function attachWaitPointInvoker<T extends object>(target: T, invoker: WaitPointInvoker): T {\n Object.defineProperty(target, WAIT_POINT_INVOKER, {\n value: invoker,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return target;\n}\n\n/**\n * Read the invoker attached to a wait point definition.\n * @param target - Wait point definition to read from\n * @returns The attached invoker, or undefined when the value is not a wait point\n */\nexport function getWaitPointInvoker(target: object): WaitPointInvoker | undefined {\n return (target as Record<symbol, WaitPointInvoker | undefined>)[WAIT_POINT_INVOKER];\n}\n\n/**\n * Record the resolved key on a wait point bound by `.with()`.\n * @param target - Bound wait point to attach to\n * @param key - Resolved runtime key\n * @returns The same bound wait point\n */\nexport function attachWaitPointKey<T extends object>(target: T, key: string): T {\n Object.defineProperty(target, WAIT_POINT_KEY, {\n value: key,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n return target;\n}\n\n/**\n * Read the resolved key recorded on a bound wait point.\n * @param target - Bound wait point to read from\n * @returns The resolved key, or undefined when the value is not a bound wait point\n */\nexport function getWaitPointKey(target: object): string | undefined {\n return (target as Record<symbol, string | undefined>)[WAIT_POINT_KEY];\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,WAAW;AAOjB,IAAI;AAEJ,SAAS,yBAAwE;CAC/E,IAAI,CAAC,gBACH,iBAAiB,IAAI,kBAA0C;CAEjE,OAAO;AACT;;;;;;AAOA,SAAgB,sBAA6C;CAC3D,OAAQ,WAAgE;AAC1E;;;;;;AAOA,SAAgB,qBAAqB,KAAsB;CACzD,AAAC,WAAoD,YAAY;AACnE;;;;;AAMA,SAAgB,uBAA6B;CAC3C,OAAQ,WAAkD;AAC5D;AAEA,SAAgB,wBAA2B,SAAiC,KAAiB;CAC3F,OAAO,uBAAuB,CAAC,CAAC,IAAI,SAAS,GAAG;AAClD;AAWA,SAAS,qBAA6C;CACpD,MAAM,UACJ,WAGA,QAAQ,SAAS;CACnB,MAAM,MAAM,UAAU;CACtB,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO;EACL,IAAI,IAAI;EACR,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,YAAY,IAAI,iBAAiB,MAAM,QAAQ,IAAI,UAAU,IAAI,CAAC,IAAK,IAAI,cAAc,CAAC;EAC1F,eAAgB,IAAI,kBACjB,MAAM,QAAQ,IAAI,UAAU,IAAI,IAAI,aAAa,CAAC;CACvD;AACF;AAGA,SAAgB,kBAAuE;CACrF,MAAM,gBAAgB,gBAAgB,SAAS;CAC/C,MAAM,UAAU,kBAAkB,SAAY,mBAAmB,IAAI;CACrE,MAAM,aAAa,oBAAoB;CACvC,IAAI,eAAe,QAAW,OAAO;EAAE,KAAK,EAAE,GAAG,WAAW;EAAG;CAAQ;CACvE,OAAO;EAAE,KAAK,CAAC;EAAgB;CAAQ;AACzC;;;;ACzFA,MAAM,qBAAoC,OAAO,IAAI,wCAAwC;AAC7F,MAAM,iBAAgC,OAAO,IAAI,oCAAoC;AAYrF,SAAS,sBAA2C;CAElD,MAAM,WAAWA,WAAS,QAAQ;CAClC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,oLAEF;CAEF,OAAO;AACT;;;;;AAMA,SAAgB,yBAA2C;CACzD,OAAO;EACL,KAAK,KAAK,SAAS;GACjB,OAAO,oBAAoB,CAAC,CAAC,KAAK,KAAK,OAAO;EAChD;EACA,MAAM,QAAQ,KAAK,aAAa,UAAU;GACxC,MAAM,oBAAoB,CAAC,CAAC,QAAQ,aAAa,KAAK,QAAQ;EAChE;CACF;AACF;;;;;;;;;;AAWA,SAAgB,uBAAyC,QAAW,SAA8B;CAChG,OAAO,eAAe,QAAQ,oBAAoB;EAChD,OAAO;EACP,YAAY;EACZ,cAAc;EACd,UAAU;CACZ,CAAC;CACD,OAAO;AACT;;;;;;AAOA,SAAgB,oBAAoB,QAA8C;CAChF,OAAQ,OAAwD;AAClE;;;;;;;AAQA,SAAgB,mBAAqC,QAAW,KAAgB;CAC9E,OAAO,eAAe,QAAQ,gBAAgB;EAC5C,OAAO;EACP,YAAY;EACZ,cAAc;EACd,UAAU;CACZ,CAAC;CACD,OAAO;AACT;;;;;;AAOA,SAAgB,gBAAgB,QAAoC;CAClE,OAAQ,OAA8C;AACxD"}
@@ -0,0 +1,47 @@
1
+ //#region src/utils/wait-point-registry.ts
2
+ const WAIT_POINT_REGISTRY_KEY = Symbol.for("tailor-platform/sdk:wait-point-registry");
3
+ function registry() {
4
+ const g = globalThis;
5
+ let state = g[WAIT_POINT_REGISTRY_KEY];
6
+ if (!state) {
7
+ state = {
8
+ entries: [],
9
+ scopeStart: 0
10
+ };
11
+ g[WAIT_POINT_REGISTRY_KEY] = state;
12
+ }
13
+ return state;
14
+ }
15
+ /**
16
+ * Record a declared wait point key so the CLI can check it against the key
17
+ * rules once the declaring module has loaded.
18
+ * @param entry - The key and the declaration it came from
19
+ */
20
+ function registerWaitPoint(entry) {
21
+ registry().entries.push(entry);
22
+ }
23
+ /**
24
+ * Start a scope here, so what a run declares can be told apart from what an
25
+ * earlier one left behind.
26
+ *
27
+ * The registry is process-wide, and a run that fails partway still leaves its
28
+ * keys in it. Without a scope, a second run in the same process would be judged
29
+ * on the first run's keys as well as its own.
30
+ */
31
+ function beginWaitPointScope() {
32
+ const state = registry();
33
+ state.scopeStart = state.entries.length;
34
+ }
35
+ /**
36
+ * Read the wait points declared since {@link beginWaitPointScope}, or every one
37
+ * of them when no scope was started.
38
+ * @returns The wait points registered in the current scope, in declaration order
39
+ */
40
+ function getScopedWaitPoints() {
41
+ const state = registry();
42
+ return state.entries.slice(state.scopeStart);
43
+ }
44
+
45
+ //#endregion
46
+ export { getScopedWaitPoints as n, registerWaitPoint as r, beginWaitPointScope as t };
47
+ //# sourceMappingURL=wait-point-registry-TL99zotw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wait-point-registry-TL99zotw.mjs","names":[],"sources":["../src/utils/wait-point-registry.ts"],"sourcesContent":["/**\n * How a wait point key reached the SDK. The declaration decides what the key\n * may contain: only `define` sees the key as a literal type, so only it can\n * type the `$params` a key carries.\n */\nexport type WaitPointDeclaration = \"createWaitPoint\" | \"define\" | \"property\";\n\n/** A wait point key as declared, before the deploy-time key rules run. */\nexport interface RegisteredWaitPoint {\n key: string;\n declaredBy: WaitPointDeclaration;\n}\n\nconst WAIT_POINT_REGISTRY_KEY: unique symbol = Symbol.for(\n \"tailor-platform/sdk:wait-point-registry\",\n);\n\ninterface Registry {\n entries: RegisteredWaitPoint[];\n scopeStart: number;\n}\n\ntype GlobalWithRegistry = typeof globalThis & {\n [WAIT_POINT_REGISTRY_KEY]?: Registry;\n};\n\nfunction registry(): Registry {\n const g = globalThis as GlobalWithRegistry;\n let state = g[WAIT_POINT_REGISTRY_KEY];\n if (!state) {\n state = { entries: [], scopeStart: 0 };\n g[WAIT_POINT_REGISTRY_KEY] = state;\n }\n return state;\n}\n\n/**\n * Record a declared wait point key so the CLI can check it against the key\n * rules once the declaring module has loaded.\n * @param entry - The key and the declaration it came from\n */\nexport function registerWaitPoint(entry: RegisteredWaitPoint): void {\n registry().entries.push(entry);\n}\n\n/**\n * Read every wait point declared by the modules loaded so far.\n * @returns The registered wait points, in declaration order\n */\nexport function getRegisteredWaitPoints(): readonly RegisteredWaitPoint[] {\n return registry().entries;\n}\n\n/**\n * Start a scope here, so what a run declares can be told apart from what an\n * earlier one left behind.\n *\n * The registry is process-wide, and a run that fails partway still leaves its\n * keys in it. Without a scope, a second run in the same process would be judged\n * on the first run's keys as well as its own.\n */\nexport function beginWaitPointScope(): void {\n const state = registry();\n state.scopeStart = state.entries.length;\n}\n\n/**\n * Read the wait points declared since {@link beginWaitPointScope}, or every one\n * of them when no scope was started.\n * @returns The wait points registered in the current scope, in declaration order\n */\nexport function getScopedWaitPoints(): readonly RegisteredWaitPoint[] {\n const state = registry();\n return state.entries.slice(state.scopeStart);\n}\n\n/**\n * Drop everything registered after a mark, where the mark is the length\n * {@link getRegisteredWaitPoints} returned earlier.\n *\n * The registry is process-wide, so a test that declares a key `deploy` rejects\n * would otherwise leave it for the deploy-time check another test file runs.\n * Nothing outside a test needs this: a CLI run declares one project's keys and\n * checks all of them.\n * @param mark - The registry length to return to\n */\nexport function restoreWaitPointRegistry(mark: number): void {\n const state = registry();\n state.entries.length = mark;\n if (state.scopeStart > mark) state.scopeStart = mark;\n}\n"],"mappings":";AAaA,MAAM,0BAAyC,OAAO,IACpD,yCACF;AAWA,SAAS,WAAqB;CAC5B,MAAM,IAAI;CACV,IAAI,QAAQ,EAAE;CACd,IAAI,CAAC,OAAO;EACV,QAAQ;GAAE,SAAS,CAAC;GAAG,YAAY;EAAE;EACrC,EAAE,2BAA2B;CAC/B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,kBAAkB,OAAkC;CAClE,SAAS,CAAC,CAAC,QAAQ,KAAK,KAAK;AAC/B;;;;;;;;;AAkBA,SAAgB,sBAA4B;CAC1C,MAAM,QAAQ,SAAS;CACvB,MAAM,aAAa,MAAM,QAAQ;AACnC;;;;;;AAOA,SAAgB,sBAAsD;CACpE,MAAM,QAAQ,SAAS;CACvB,OAAO,MAAM,QAAQ,MAAM,MAAM,UAAU;AAC7C"}
@@ -159,6 +159,14 @@ const GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatusSchema = /
159
159
  * @generated from enum tailor.v1.GetApplicationSchemaHealthResponse.ApplicationSchemaHealthStatus
160
160
  */
161
161
  const GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus = /*@__PURE__*/ tsEnum(GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatusSchema);
162
+ /**
163
+ * Describes the enum tailor.v1.CloneOperationStatus.
164
+ */
165
+ const CloneOperationStatusSchema = /*@__PURE__*/ enumDesc(file_tailor_v1_application, 0);
166
+ /**
167
+ * @generated from enum tailor.v1.CloneOperationStatus
168
+ */
169
+ const CloneOperationStatus = /*@__PURE__*/ tsEnum(CloneOperationStatusSchema);
162
170
 
163
171
  //#endregion
164
172
  //#region ../tailor-proto/src/tailor/v1/secret_manager_resource_pb.js
@@ -848,5 +856,5 @@ const WorkspacePlatformUserRoleSchema = /*@__PURE__*/ enumDesc(file_tailor_v1_wo
848
856
  const WorkspacePlatformUserRole = /*@__PURE__*/ tsEnum(WorkspacePlatformUserRoleSchema);
849
857
 
850
858
  //#endregion
851
- export { CreateAuthHookRequestSchema as $, file_tailor_v1_secret_manager as A, PATScope as At, IdPLang as B, Subgraph_ServiceType as Bt, CreateStaticWebsiteRequestSchema as C, AuthInvokerSchema as Ct, CreateSecretManagerSecretRequestSchema as D, AuthSCIMAttribute_Type as Dt, CustomDomainStatus as E, AuthSCIMAttribute_Mutability as Et, file_tailor_v1_pipeline as F, CreateApplicationRequestSchema as Ft, file_tailor_v1_function_resource as G, file_tailor_fieldmask_v1_option as Gt, IdPPermissionPermit as H, UpdateAIGatewayRequestSchema as Ht, PipelineResolver_OperationType as I, GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus as It, file_tailor_v1_executor as J, FilterSchema as Jt, CreateExecutorExecutorRequestSchema as K, ConditionSchema as Kt, CreateIdPServiceRequestSchema as L, UpdateApplicationRequestSchema as Lt, CreatePipelineServiceRequestSchema as M, UserProfileProviderConfig_UserProfileProviderType as Mt, UpdatePipelineResolverRequestSchema as N, file_tailor_v1_auth_resource as Nt, CreateSecretManagerVaultRequestSchema as O, AuthSCIMAttribute_Uniqueness as Ot, UpdatePipelineServiceRequestSchema as P, file_tailor_v1_secret_manager_resource as Pt, CreateAuthConnectionRequestSchema as Q, UpdateIdPServiceRequestSchema as R, file_tailor_v1_application as Rt, AddCustomDomainRequestSchema as S, AuthIDPConfig_AuthType as St, file_tailor_v1_staticwebsite as T, AuthOAuth2Client_GrantType as Tt, FunctionExecution_Status as U, file_tailor_v1_aigateway as Ut, IdPPermissionOperator as V, CreateAIGatewayRequestSchema as Vt, FunctionExecution_Type as W, file_google_api_field_behavior as Wt, ExecutorTargetType as X, file_tailor_v1_resource as Xt, ExecutorJobStatus as Y, PageDirection as Yt, ExecutorTriggerType as Z, file_buf_validate_validate as Zt, TailorDBGQLPermission_Permit as _, UpdateUserProfileConfigRequestSchema as _t, CreateWorkflowRequestSchema as a, CreateAuthServiceRequestSchema as at, TailorDBType_Permission_Permit as b, AuthConnection_Type as bt, file_tailor_v1_workflow as c, UpdateAuthConnectionRequestSchema as ct, CreateTailorDBServiceRequestSchema as d, UpdateAuthMachineUserRequestSchema as dt, CreateAuthIDPConfigRequestSchema as et, CreateTailorDBTypeRequestSchema as f, UpdateAuthOAuth2ClientRequestSchema as ft, TailorDBGQLPermission_Operator as g, UpdateTenantConfigRequestSchema as gt, TailorDBGQLPermission_Action as h, UpdateAuthServiceRequestSchema as ht, CreateWorkflowJobFunctionRequestSchema as i, CreateAuthSCIMResourceRequestSchema as it, CreatePipelineResolverRequestSchema as j, TenantProviderConfig_TenantProviderType as jt, UpdateSecretManagerSecretRequestSchema as k, AuthSCIMConfig_AuthorizationType as kt, WorkflowExecution_Status as l, UpdateAuthHookRequestSchema as lt, file_tailor_v1_tailordb as m, UpdateAuthSCIMResourceRequestSchema as mt, file_tailor_v1_workspace_resource as n, CreateAuthOAuth2ClientRequestSchema as nt, UpdateWorkflowJobFunctionExecutionPolicyRequestSchema as o, CreateTenantConfigRequestSchema as ot, UpdateTailorDBTypeRequestSchema as p, UpdateAuthSCIMConfigRequestSchema as pt, UpdateExecutorExecutorRequestSchema as q, Condition_Operator as qt, CreateWorkflowJobFunctionExecutionPolicyRequestSchema as r, CreateAuthSCIMConfigRequestSchema as rt, UpdateWorkflowRequestSchema as s, CreateUserProfileConfigRequestSchema as st, WorkspacePlatformUserRole as t, CreateAuthMachineUserRequestSchema as tt, WorkflowJobExecution_Status as u, UpdateAuthIDPConfigRequestSchema as ut, TailorDBTypeSchema as v, file_tailor_v1_auth as vt, UpdateStaticWebsiteRequestSchema as w, AuthOAuth2Client_ClientType as wt, TailorDBType_PermitAction as x, AuthHookPoint as xt, TailorDBType_Permission_Operator as y, AuthConnection_Status as yt, file_tailor_v1_idp as z, ApplicationSchemaUpdateAttemptStatus as zt };
852
- //# sourceMappingURL=workspace_resource_pb-DXnO2AT-.mjs.map
859
+ export { CreateAuthHookRequestSchema as $, file_tailor_v1_secret_manager as A, PATScope as At, IdPLang as B, ApplicationSchemaUpdateAttemptStatus as Bt, CreateStaticWebsiteRequestSchema as C, AuthInvokerSchema as Ct, CreateSecretManagerSecretRequestSchema as D, AuthSCIMAttribute_Type as Dt, CustomDomainStatus as E, AuthSCIMAttribute_Mutability as Et, file_tailor_v1_pipeline as F, CloneOperationStatus as Ft, file_tailor_v1_function_resource as G, file_google_api_field_behavior as Gt, IdPPermissionPermit as H, CreateAIGatewayRequestSchema as Ht, PipelineResolver_OperationType as I, CreateApplicationRequestSchema as It, file_tailor_v1_executor as J, Condition_Operator as Jt, CreateExecutorExecutorRequestSchema as K, file_tailor_fieldmask_v1_option as Kt, CreateIdPServiceRequestSchema as L, GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus as Lt, CreatePipelineServiceRequestSchema as M, UserProfileProviderConfig_UserProfileProviderType as Mt, UpdatePipelineResolverRequestSchema as N, file_tailor_v1_auth_resource as Nt, CreateSecretManagerVaultRequestSchema as O, AuthSCIMAttribute_Uniqueness as Ot, UpdatePipelineServiceRequestSchema as P, file_tailor_v1_secret_manager_resource as Pt, CreateAuthConnectionRequestSchema as Q, file_buf_validate_validate as Qt, UpdateIdPServiceRequestSchema as R, UpdateApplicationRequestSchema as Rt, AddCustomDomainRequestSchema as S, AuthIDPConfig_AuthType as St, file_tailor_v1_staticwebsite as T, AuthOAuth2Client_GrantType as Tt, FunctionExecution_Status as U, UpdateAIGatewayRequestSchema as Ut, IdPPermissionOperator as V, Subgraph_ServiceType as Vt, FunctionExecution_Type as W, file_tailor_v1_aigateway as Wt, ExecutorTargetType as X, PageDirection as Xt, ExecutorJobStatus as Y, FilterSchema as Yt, ExecutorTriggerType as Z, file_tailor_v1_resource as Zt, TailorDBGQLPermission_Permit as _, UpdateUserProfileConfigRequestSchema as _t, CreateWorkflowRequestSchema as a, CreateAuthServiceRequestSchema as at, TailorDBType_Permission_Permit as b, AuthConnection_Type as bt, file_tailor_v1_workflow as c, UpdateAuthConnectionRequestSchema as ct, CreateTailorDBServiceRequestSchema as d, UpdateAuthMachineUserRequestSchema as dt, CreateAuthIDPConfigRequestSchema as et, CreateTailorDBTypeRequestSchema as f, UpdateAuthOAuth2ClientRequestSchema as ft, TailorDBGQLPermission_Operator as g, UpdateTenantConfigRequestSchema as gt, TailorDBGQLPermission_Action as h, UpdateAuthServiceRequestSchema as ht, CreateWorkflowJobFunctionRequestSchema as i, CreateAuthSCIMResourceRequestSchema as it, CreatePipelineResolverRequestSchema as j, TenantProviderConfig_TenantProviderType as jt, UpdateSecretManagerSecretRequestSchema as k, AuthSCIMConfig_AuthorizationType as kt, WorkflowExecution_Status as l, UpdateAuthHookRequestSchema as lt, file_tailor_v1_tailordb as m, UpdateAuthSCIMResourceRequestSchema as mt, file_tailor_v1_workspace_resource as n, CreateAuthOAuth2ClientRequestSchema as nt, UpdateWorkflowJobFunctionExecutionPolicyRequestSchema as o, CreateTenantConfigRequestSchema as ot, UpdateTailorDBTypeRequestSchema as p, UpdateAuthSCIMConfigRequestSchema as pt, UpdateExecutorExecutorRequestSchema as q, ConditionSchema as qt, CreateWorkflowJobFunctionExecutionPolicyRequestSchema as r, CreateAuthSCIMConfigRequestSchema as rt, UpdateWorkflowRequestSchema as s, CreateUserProfileConfigRequestSchema as st, WorkspacePlatformUserRole as t, CreateAuthMachineUserRequestSchema as tt, WorkflowJobExecution_Status as u, UpdateAuthIDPConfigRequestSchema as ut, TailorDBTypeSchema as v, file_tailor_v1_auth as vt, UpdateStaticWebsiteRequestSchema as w, AuthOAuth2Client_ClientType as wt, TailorDBType_PermitAction as x, AuthHookPoint as xt, TailorDBType_Permission_Operator as y, AuthConnection_Status as yt, file_tailor_v1_idp as z, file_tailor_v1_application as zt };
860
+ //# sourceMappingURL=workspace_resource_pb-HNIL_Vfj.mjs.map