@tailor-platform/sdk 2.0.0-next.9 → 2.0.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 (170) hide show
  1. package/CHANGELOG.md +611 -0
  2. package/dist/{application-D_oSqto2.mjs → application-CM6hKnSK.mjs} +489 -118
  3. package/dist/application-CM6hKnSK.mjs.map +1 -0
  4. package/dist/application-CXNaUNhv.mjs +3 -0
  5. package/dist/cli/commands/deploy/aigateway.d.mts +1 -1
  6. package/dist/cli/commands/deploy/application.d.mts +1 -1
  7. package/dist/cli/commands/deploy/auth.d.mts +1 -1
  8. package/dist/cli/commands/deploy/deploy.d.mts +1 -0
  9. package/dist/cli/commands/deploy/executor.d.mts +1 -1
  10. package/dist/cli/commands/deploy/function-registry.d.mts +1 -2
  11. package/dist/cli/commands/deploy/idp.d.mts +1 -1
  12. package/dist/cli/commands/deploy/label.d.mts +2 -0
  13. package/dist/cli/commands/deploy/resolver.d.mts +1 -1
  14. package/dist/cli/commands/deploy/staticwebsite.d.mts +1 -1
  15. package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -1
  16. package/dist/cli/commands/deploy/types.d.mts +2 -1
  17. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -2
  18. package/dist/cli/commands/deploy/workflow.d.mts +1 -1
  19. package/dist/cli/commands/executor/get.d.mts +1 -10
  20. package/dist/cli/commands/executor/jobs.d.mts +1 -38
  21. package/dist/cli/commands/executor/trigger.d.mts +1 -11
  22. package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
  23. package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -2
  24. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
  25. package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
  26. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
  27. package/dist/cli/commands/workflow/executions.d.mts +1 -13
  28. package/dist/cli/commands/workflow/get.d.mts +1 -10
  29. package/dist/cli/commands/workflow/start.d.mts +2 -14
  30. package/dist/cli/index.mjs +12 -6561
  31. package/dist/cli/lib.d.mts +9 -12
  32. package/dist/cli/lib.mjs +99 -42
  33. package/dist/cli/lib.mjs.map +1 -1
  34. package/dist/cli/{index.d.mts → main.d.mts} +1 -1
  35. package/dist/cli/main.mjs +6777 -0
  36. package/dist/cli/main.mjs.map +1 -0
  37. package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
  38. package/dist/cli/services/workflow/bundler.d.mts +2 -1
  39. package/dist/cli/shared/client.d.mts +28 -3
  40. package/dist/cli/shared/config-loader.d.mts +11 -4
  41. package/dist/cli/shared/error-json.d.mts +23 -0
  42. package/dist/cli/shared/tsconfig-paths-plugin.d.mts +2 -0
  43. package/dist/cli/shared/type-generator.d.mts +4 -3
  44. package/dist/completion/zsh-worker.zsh +85 -22
  45. package/dist/configure/config/types.d.mts +29 -4
  46. package/dist/configure/index.d.mts +4 -3
  47. package/dist/configure/index.mjs +183 -6
  48. package/dist/configure/index.mjs.map +1 -1
  49. package/dist/configure/services/executor/index.d.mts +2 -2
  50. package/dist/configure/services/executor/trigger/event.d.mts +245 -2
  51. package/dist/configure/services/executor/trigger/index.d.mts +3 -3
  52. package/dist/configure/services/idp/index.d.mts +2 -2
  53. package/dist/configure/services/idp/permission.d.mts +1 -16
  54. package/dist/configure/services/idp/types.d.mts +5 -1
  55. package/dist/configure/services/index.d.mts +4 -3
  56. package/dist/configure/services/resolver/index.d.mts +2 -1
  57. package/dist/configure/services/resolver/permission.d.mts +64 -0
  58. package/dist/configure/services/resolver/resolver.d.mts +14 -2
  59. package/dist/configure/services/tailordb/index.d.mts +0 -1
  60. package/dist/configure/services/tailordb/permission.d.mts +1 -16
  61. package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
  62. package/dist/configure/services/workflow/execution-policy.types.d.mts +1 -1
  63. package/dist/configure/services/workflow/job.d.mts +11 -2
  64. package/dist/configure/services/workflow/workflow.d.mts +10 -0
  65. package/dist/configure/types/permission-operand.types.d.mts +20 -0
  66. package/dist/{crashreport-CxHne11E.mjs → crashreport-B5LqCTfF.mjs} +2 -2
  67. package/dist/{crashreport-CxHne11E.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
  68. package/dist/{crashreport-0ioNRZ4K.mjs → crashreport-eI7ty7ok.mjs} +1 -1
  69. package/dist/{errors-DfnF4ibq.mjs → errors-D7583Zz7.mjs} +2 -44
  70. package/dist/errors-D7583Zz7.mjs.map +1 -0
  71. package/dist/{globals-CBZ0egXT.mjs → globals-TfAVItuK.mjs} +21 -5
  72. package/dist/globals-TfAVItuK.mjs.map +1 -0
  73. package/dist/logger-BtX0suGY.mjs +48 -0
  74. package/dist/logger-BtX0suGY.mjs.map +1 -0
  75. package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
  76. package/dist/logger-CXQq9YIp.mjs.map +1 -0
  77. package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
  78. package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
  79. package/dist/plugin/builtin/enum-constants/index.mjs +115 -2
  80. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -0
  81. package/dist/plugin/builtin/file-utils/index.mjs +149 -2
  82. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -0
  83. package/dist/plugin/builtin/kysely-type/index.mjs +274 -2
  84. package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -0
  85. package/dist/plugin/builtin/seed/index.mjs +1 -1
  86. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +2 -0
  87. package/dist/{register-ts-hook-DgnmGTCt.mjs → register-ts-hook-LYV7zH-e.mjs} +2949 -1001
  88. package/dist/register-ts-hook-LYV7zH-e.mjs.map +1 -0
  89. package/dist/{registry-i7EdJ-D5.mjs → registry-BIGVUrMB.mjs} +3 -3
  90. package/dist/registry-BIGVUrMB.mjs.map +1 -0
  91. package/dist/runtime/globals.d.mts +7 -0
  92. package/dist/runtime/index.d.mts +3 -1
  93. package/dist/runtime/index.mjs +3 -2
  94. package/dist/runtime/logger.d.mts +98 -0
  95. package/dist/runtime/logger.mjs +3 -0
  96. package/dist/runtime/workflow.d.mts +15 -7
  97. package/dist/runtime/workflow.mjs +1 -1
  98. package/dist/{seed-LUVr7jHL.mjs → seed-B-yckgQY.mjs} +42 -3
  99. package/dist/seed-B-yckgQY.mjs.map +1 -0
  100. package/dist/{service-DaeJlBoH.mjs → service-B5WynBHQ.mjs} +3 -3
  101. package/dist/{service-DaeJlBoH.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
  102. package/dist/service-M7OYziQP.mjs +3 -0
  103. package/dist/{service-CXFce28G.mjs → service-k1xy_A5G.mjs} +30 -3
  104. package/dist/{service-CXFce28G.mjs.map → service-k1xy_A5G.mjs.map} +1 -1
  105. package/dist/{service_pb-BoLM0X4K.mjs → service_pb-D5--My_M.mjs} +5 -5
  106. package/dist/service_pb-D5--My_M.mjs.map +1 -0
  107. package/dist/{service_pb-r1T7kpJc.mjs → service_pb-i8CmnQP4.mjs} +1 -1
  108. package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
  109. package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
  110. package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
  111. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
  112. package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
  113. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
  114. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
  115. package/dist/types/auth.generated.d.mts +14 -2
  116. package/dist/types/executor.generated.d.mts +45 -3
  117. package/dist/types/http-adapter.generated.d.mts +5 -0
  118. package/dist/types/idp.generated.d.mts +31 -1
  119. package/dist/types/resolver.generated.d.mts +30 -2
  120. package/dist/types/tailordb.generated.d.mts +15 -1
  121. package/dist/utils/test/index.d.mts +1 -2
  122. package/dist/utils/test/index.mjs +1 -169
  123. package/dist/utils/test/index.mjs.map +1 -1
  124. package/dist/vitest/environment.mjs +1 -1
  125. package/dist/vitest/index.d.mts +6 -4
  126. package/dist/vitest/index.mjs +112 -62
  127. package/dist/vitest/index.mjs.map +1 -1
  128. package/dist/vitest/mock.d.mts +2 -1
  129. package/dist/vitest/mocks/logger.d.mts +45 -0
  130. package/dist/vitest/mocks/workflow.d.mts +8 -8
  131. package/dist/vitest/setup.mjs +1 -1
  132. package/dist/{workflow-CsBvRE3g.mjs → workflow-Bamae_Yc.mjs} +5 -5
  133. package/dist/workflow-Bamae_Yc.mjs.map +1 -0
  134. package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-DXnO2AT-.mjs} +13 -8
  135. package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
  136. package/docs/cli/application.md +5 -1
  137. package/docs/cli/tailordb.md +47 -13
  138. package/docs/cli-reference.md +31 -30
  139. package/docs/configuration.md +53 -1
  140. package/docs/github-actions.md +2 -2
  141. package/docs/migration/v2.md +307 -10
  142. package/docs/runtime.md +5 -1
  143. package/docs/services/executor.md +83 -3
  144. package/docs/services/idp.md +8 -6
  145. package/docs/services/resolver.md +60 -4
  146. package/docs/services/tailordb-migration.md +31 -7
  147. package/docs/services/tailordb.md +7 -5
  148. package/docs/services/workflow.md +33 -3
  149. package/docs/testing.md +34 -7
  150. package/package.json +31 -24
  151. package/dist/application-CtuzFhg8.mjs +0 -3
  152. package/dist/application-D_oSqto2.mjs.map +0 -1
  153. package/dist/cli/index.mjs.map +0 -1
  154. package/dist/enum-constants-j9QBF0cB.mjs +0 -116
  155. package/dist/enum-constants-j9QBF0cB.mjs.map +0 -1
  156. package/dist/errors-DfnF4ibq.mjs.map +0 -1
  157. package/dist/file-utils-yEiIS4nJ.mjs +0 -150
  158. package/dist/file-utils-yEiIS4nJ.mjs.map +0 -1
  159. package/dist/globals-CBZ0egXT.mjs.map +0 -1
  160. package/dist/kysely-type-DqIRgDYR.mjs +0 -275
  161. package/dist/kysely-type-DqIRgDYR.mjs.map +0 -1
  162. package/dist/logger-BwS4ppwO.mjs.map +0 -1
  163. package/dist/register-ts-hook-DgnmGTCt.mjs.map +0 -1
  164. package/dist/registry-i7EdJ-D5.mjs.map +0 -1
  165. package/dist/seed-LUVr7jHL.mjs.map +0 -1
  166. package/dist/service-DjhjpJpm.mjs +0 -3
  167. package/dist/service_pb-BoLM0X4K.mjs.map +0 -1
  168. package/dist/utils/test/mock.d.mts +0 -86
  169. package/dist/workflow-CsBvRE3g.mjs.map +0 -1
  170. package/dist/workspace_resource_pb-Db3fv68L.mjs.map +0 -1
@@ -12,7 +12,7 @@ function jobs() {
12
12
  /**
13
13
  * Register a job body keyed by job name. Called as a side effect by
14
14
  * `createWorkflowJob` so `runWorkflowLocally()` can execute dependent job
15
- * bodies when `globalThis.tailor.workflow.startJobFunction(name, args)` is invoked.
15
+ * bodies when `globalThis.tailor.workflow.execJobFunction(name, args)` is invoked.
16
16
  *
17
17
  * In production builds the bundler rewrites `.start()` calls so this registry
18
18
  * is never read; the gated write is dropped as dead code.
@@ -41,7 +41,7 @@ function requirePlatformWorkflow() {
41
41
  const START_DEFAULT = "00000000-0000-4000-8000-000000000000";
42
42
  function dispatchStartJob(name, args, options) {
43
43
  const workflow = requirePlatformWorkflow();
44
- return arguments.length >= 3 ? workflow.startJobFunction(name, args, options) : workflow.startJobFunction(name, args);
44
+ return arguments.length >= 3 ? workflow.execJobFunction(name, args, options) : workflow.execJobFunction(name, args);
45
45
  }
46
46
  function dispatchStartWorkflow(name, args, options) {
47
47
  const workflow = requirePlatformWorkflow();
@@ -51,4 +51,4 @@ function dispatchStartWorkflow(name, args, options) {
51
51
 
52
52
  //#endregion
53
53
  export { registerJob as a, getRegisteredJob as i, dispatchStartJob as n, dispatchStartWorkflow as r, START_DEFAULT as t };
54
- //# sourceMappingURL=registry-i7EdJ-D5.mjs.map
54
+ //# sourceMappingURL=registry-BIGVUrMB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-BIGVUrMB.mjs","names":[],"sources":["../src/configure/services/workflow/registry.ts"],"sourcesContent":["import type { TailorEnv, TailorPrincipal } from \"#/runtime/types\";\nimport type { ExecJobFunctionOptions, StartWorkflowOptions } from \"#/runtime/workflow\";\n\n/**\n * Body signature shared by workflow jobs at registry-write time.\n * The user's `createWorkflowJob`/`createWorkflow` body uses concrete types,\n * but the registry erases them for storage.\n */\nexport type RegisteredJobBody = (\n args: unknown,\n context: { env: TailorEnv; invoker: TailorPrincipal | null },\n) => unknown | Promise<unknown>;\n\nconst JOB_REGISTRY_KEY: unique symbol = Symbol.for(\"tailor-platform/sdk:job-registry\");\n\ntype PlatformWorkflow = {\n startWorkflow: (name: string, args?: unknown, options?: StartWorkflowOptions) => Promise<string>;\n execJobFunction: (name: string, args?: unknown, options?: ExecJobFunctionOptions) => unknown;\n};\n\ntype GlobalWithRegistry = typeof globalThis & {\n [JOB_REGISTRY_KEY]?: Map<string, RegisteredJobBody>;\n tailor?: { workflow?: PlatformWorkflow };\n};\n\nfunction jobs(): Map<string, RegisteredJobBody> {\n const g = globalThis as GlobalWithRegistry;\n let map = g[JOB_REGISTRY_KEY];\n if (!map) {\n map = new Map();\n g[JOB_REGISTRY_KEY] = map;\n }\n return map;\n}\n\n/**\n * Register a job body keyed by job name. Called as a side effect by\n * `createWorkflowJob` so `runWorkflowLocally()` can execute dependent job\n * bodies when `globalThis.tailor.workflow.execJobFunction(name, args)` is invoked.\n *\n * In production builds the bundler rewrites `.start()` calls so this registry\n * is never read; the gated write is dropped as dead code.\n * @param name - Job name\n * @param body - Job body function\n */\nexport function registerJob(name: string, body: RegisteredJobBody): void {\n jobs().set(name, body);\n}\n\n/**\n * Look up a registered job body by name.\n * @param name - Job name\n * @returns The registered body, or undefined when no job is registered\n */\nexport function getRegisteredJob(name: string): RegisteredJobBody | undefined {\n return jobs().get(name);\n}\n\nfunction currentPlatformWorkflow(): PlatformWorkflow | undefined {\n // globalThis may not have the tailor property at runtime\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n return (globalThis as GlobalWithRegistry).tailor?.workflow;\n}\n\nfunction requirePlatformWorkflow(): PlatformWorkflow {\n const workflow = currentPlatformWorkflow();\n if (!workflow) {\n throw new Error(\n \"tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment and use mockWorkflow(), or use runWorkflowLocally() from @tailor-platform/sdk/vitest for local workflow execution.\",\n );\n }\n return workflow;\n}\n\n// A valid placeholder UUID, so callers that validate the execution id behave the\n// same locally as against the platform.\nexport const START_DEFAULT = \"00000000-0000-4000-8000-000000000000\";\n\n// `.start()` routes through the installed `tailor.workflow` shim. Local body\n// execution is intentionally available only through `runWorkflowLocally()`.\n// Preserve arity: the shim sees a 2-argument call when the caller supplied no\n// options, and a 3-argument call otherwise, mirroring the bundler rewrite so\n// mocks observe the same shape in local execution and in bundled workflows.\nexport function dispatchStartJob(\n name: string,\n args?: unknown,\n options?: ExecJobFunctionOptions,\n): unknown {\n const workflow = requirePlatformWorkflow();\n // oxlint-disable-next-line prefer-rest-params\n return arguments.length >= 3\n ? workflow.execJobFunction(name, args, options)\n : workflow.execJobFunction(name, args);\n}\n\n// Accepts `unknown` because the SDK-side `.start()` accepts a wider options\n// shape than the platform surface (e.g. `authInvoker` may be a machine-user\n// name string that the bundler normalizes at build time). Local execution\n// forwards the value verbatim; only the bundled path enforces the platform\n// contract.\nexport function dispatchStartWorkflow(\n name: string,\n args?: unknown,\n options?: { invoker?: unknown },\n): Promise<string> {\n const workflow = requirePlatformWorkflow();\n // oxlint-disable-next-line prefer-rest-params\n if (arguments.length < 3) {\n return workflow.startWorkflow(name, args);\n }\n return workflow.startWorkflow(\n name,\n args,\n options?.invoker === undefined\n ? (options as StartWorkflowOptions | undefined)\n : ({ authInvoker: options.invoker } as StartWorkflowOptions),\n );\n}\n"],"mappings":";AAaA,MAAM,mBAAkC,OAAO,IAAI,kCAAkC;AAYrF,SAAS,OAAuC;CAC9C,MAAM,IAAI;CACV,IAAI,MAAM,EAAE;CACZ,IAAI,CAAC,KAAK;EACR,sBAAM,IAAI,IAAI;EACd,EAAE,oBAAoB;CACxB;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,YAAY,MAAc,MAA+B;CACvE,KAAK,CAAC,CAAC,IAAI,MAAM,IAAI;AACvB;;;;;;AAOA,SAAgB,iBAAiB,MAA6C;CAC5E,OAAO,KAAK,CAAC,CAAC,IAAI,IAAI;AACxB;AAEA,SAAS,0BAAwD;CAG/D,OAAQ,WAAkC,QAAQ;AACpD;AAEA,SAAS,0BAA4C;CACnD,MAAM,WAAW,wBAAwB;CACzC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,2MACF;CAEF,OAAO;AACT;AAIA,MAAa,gBAAgB;AAO7B,SAAgB,iBACd,MACA,MACA,SACS;CACT,MAAM,WAAW,wBAAwB;CAEzC,OAAO,UAAU,UAAU,IACvB,SAAS,gBAAgB,MAAM,MAAM,OAAO,IAC5C,SAAS,gBAAgB,MAAM,IAAI;AACzC;AAOA,SAAgB,sBACd,MACA,MACA,SACiB;CACjB,MAAM,WAAW,wBAAwB;CAEzC,IAAI,UAAU,SAAS,GACrB,OAAO,SAAS,cAAc,MAAM,IAAI;CAE1C,OAAO,SAAS,cACd,MACA,MACA,SAAS,YAAY,SAChB,UACA,EAAE,aAAa,QAAQ,QAAQ,CACtC;AACF"}
@@ -3,6 +3,7 @@ import { ContextInvoker } from "./context.mjs";
3
3
  import { TailorDBFileErrorCode } from "./file.mjs";
4
4
  import { IconvInstance } from "./iconv.mjs";
5
5
  import { ClientConfig, CreateUserInput, IdpClientInstance, ListUsersOptions, ListUsersResponse, SendPasswordResetEmailInput, UnenrollMfaInput, UpdateUserInput, User, UserQuery } from "./idp.mjs";
6
+ import { LogAttributeValue, LogAttributes } from "./logger.mjs";
6
7
  import { TailorRuntime, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime } from "./index.mjs";
7
8
  //#region src/runtime/globals.d.ts
8
9
  type TailorIdpClientConfig = ClientConfig;
@@ -17,6 +18,8 @@ type TailorIdpUser = User;
17
18
  type TailorIdpUserQuery = UserQuery;
18
19
  type TailorWorkflowInvoker = Invoker;
19
20
  type TailorWorkflowStartWorkflowOptions = StartWorkflowOptions;
21
+ type TailorLoggerLogAttributeValue = LogAttributeValue;
22
+ type TailorLoggerLogAttributes = LogAttributes;
20
23
  declare global {
21
24
  namespace tailordb {
22
25
  type QueryResult<T> = TailordbQueryResult<T>;
@@ -47,6 +50,10 @@ declare global {
47
50
  namespace context {
48
51
  type Invoker = ContextInvoker;
49
52
  }
53
+ namespace logger {
54
+ type LogAttributeValue = TailorLoggerLogAttributeValue;
55
+ type LogAttributes = TailorLoggerLogAttributes;
56
+ }
50
57
  }
51
58
  var tailor: TailorRuntime;
52
59
  /** Custom error class for TailorDB File operations. */
@@ -5,6 +5,7 @@ import { PlatformContextAPI, context } from "./context.mjs";
5
5
  import { TailorDBFileAPI, file } from "./file.mjs";
6
6
  import { TailorIconvAPI, iconv } from "./iconv.mjs";
7
7
  import { TailorIdpAPI, idp } from "./idp.mjs";
8
+ import { TailorLoggerAPI, logger } from "./logger.mjs";
8
9
  import { TailorSecretmanagerAPI, secretmanager } from "./secretmanager.mjs";
9
10
  //#region src/runtime/index.d.ts
10
11
  /** SQL command type recorded on a {@link TailordbQueryResult}. */
@@ -36,6 +37,7 @@ interface TailorRuntime {
36
37
  workflow: PlatformWorkflowAPI;
37
38
  context: PlatformContextAPI;
38
39
  aigateway: TailorAigatewayAPI;
40
+ logger: TailorLoggerAPI;
39
41
  }
40
42
  /** Top-level `tailordb` runtime object. */
41
43
  interface TailordbRuntime {
@@ -43,4 +45,4 @@ interface TailordbRuntime {
43
45
  file: TailorDBFileAPI;
44
46
  }
45
47
  //#endregion
46
- export { TailorRuntime, TailordbClientConstructor, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime, aigateway, authconnection, context, file, iconv, idp, secretmanager, workflow };
48
+ export { TailorRuntime, TailordbClientConstructor, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime, aigateway, authconnection, context, file, iconv, idp, logger, secretmanager, workflow };
@@ -2,9 +2,10 @@ import { t as iconv } from "../iconv-QWaZh0TT.mjs";
2
2
  import { t as secretmanager } from "../secretmanager-CYlpffsz.mjs";
3
3
  import { t as authconnection } from "../authconnection-CZvi9ANm.mjs";
4
4
  import { t as idp } from "../idp-RA_swu-h.mjs";
5
- import { t as workflow } from "../workflow-CsBvRE3g.mjs";
5
+ import { t as workflow } from "../workflow-Bamae_Yc.mjs";
6
6
  import { t as context } from "../context-DYQVYWqZ.mjs";
7
7
  import { t as file } from "../file-BUcmVIH2.mjs";
8
8
  import { t as aigateway } from "../aigateway-DR4Kwuik.mjs";
9
+ import { i as logger } from "../logger-BtX0suGY.mjs";
9
10
 
10
- export { aigateway, authconnection, context, file, iconv, idp, secretmanager, workflow };
11
+ export { aigateway, authconnection, context, file, iconv, idp, logger, secretmanager, workflow };
@@ -0,0 +1,98 @@
1
+ //#region src/runtime/logger.d.ts
2
+ /**
3
+ * Structured logging utilities.
4
+ *
5
+ * Thin typed wrapper around the platform-provided `tailor.logger` runtime API.
6
+ * At runtime this delegates to `globalThis.tailor.logger`. Use `mockLogger`
7
+ * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
8
+ *
9
+ * Unlike `console.*`, each call carries a severity and structured attributes.
10
+ * The message is written to standard output, and the full entry with its
11
+ * attributes is exported over OpenTelemetry, where the attributes are queryable.
12
+ * @example
13
+ * import { logger } from "@tailor-platform/sdk/runtime";
14
+ *
15
+ * logger.setAttributes({ requestId: "r-123" });
16
+ * logger.info("order processed", { orderId: "o-1", total: 99.5 });
17
+ */
18
+ /**
19
+ * A single log attribute value. Values outside this union (`null`, nested
20
+ * objects, mixed-type arrays) are silently dropped by the platform.
21
+ */
22
+ type LogAttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
23
+ /**
24
+ * Structured attributes attached to a log entry. The platform keeps at most 32
25
+ * entries, drops any entry whose key exceeds 128 bytes, and truncates string
26
+ * values over 4096 bytes and arrays over 64 elements.
27
+ */
28
+ type LogAttributes = Record<string, LogAttributeValue>;
29
+ /**
30
+ * Platform API surface for `tailor.logger`. Describes the shape the platform
31
+ * runtime injects on `globalThis.tailor.logger`.
32
+ *
33
+ * Each method below is also re-exported as a top-level named export from this
34
+ * module so callers can either `import * as logger from
35
+ * "@tailor-platform/sdk/runtime/logger"` or pick individual methods.
36
+ */
37
+ interface TailorLoggerAPI {
38
+ /**
39
+ * Emits a `debug`-severity log entry.
40
+ * @param message - The log message
41
+ * @param attributes - Structured attributes to attach to this entry
42
+ */
43
+ debug(message: string, attributes?: LogAttributes): void;
44
+ /**
45
+ * Emits an `info`-severity log entry.
46
+ * @param message - The log message
47
+ * @param attributes - Structured attributes to attach to this entry
48
+ */
49
+ info(message: string, attributes?: LogAttributes): void;
50
+ /**
51
+ * Emits a `warn`-severity log entry.
52
+ * @param message - The log message
53
+ * @param attributes - Structured attributes to attach to this entry
54
+ */
55
+ warn(message: string, attributes?: LogAttributes): void;
56
+ /**
57
+ * Emits an `error`-severity log entry.
58
+ * @param message - The log message
59
+ * @param attributes - Structured attributes to attach to this entry
60
+ */
61
+ error(message: string, attributes?: LogAttributes): void;
62
+ /**
63
+ * Merges attributes into every subsequent log entry from the current
64
+ * execution. Later keys overwrite earlier ones; per-call attributes passed to
65
+ * `debug`/`info`/`warn`/`error` take precedence.
66
+ * @param attributes - Attributes to attach to subsequent entries
67
+ */
68
+ setAttributes(attributes: LogAttributes): void;
69
+ }
70
+ /**
71
+ * See {@link TailorLoggerAPI.debug}.
72
+ * @param args - Forwarded to {@link TailorLoggerAPI.debug}
73
+ */
74
+ declare const debug: TailorLoggerAPI["debug"];
75
+ /**
76
+ * See {@link TailorLoggerAPI.info}.
77
+ * @param args - Forwarded to {@link TailorLoggerAPI.info}
78
+ */
79
+ declare const info: TailorLoggerAPI["info"];
80
+ /**
81
+ * See {@link TailorLoggerAPI.warn}.
82
+ * @param args - Forwarded to {@link TailorLoggerAPI.warn}
83
+ */
84
+ declare const warn: TailorLoggerAPI["warn"];
85
+ /**
86
+ * See {@link TailorLoggerAPI.error}.
87
+ * @param args - Forwarded to {@link TailorLoggerAPI.error}
88
+ */
89
+ declare const error: TailorLoggerAPI["error"];
90
+ /**
91
+ * See {@link TailorLoggerAPI.setAttributes}.
92
+ * @param args - Forwarded to {@link TailorLoggerAPI.setAttributes}
93
+ */
94
+ declare const setAttributes: TailorLoggerAPI["setAttributes"];
95
+ /** `tailor.logger` API object. See {@link TailorLoggerAPI} for method docs. */
96
+ declare const logger: TailorLoggerAPI;
97
+ //#endregion
98
+ export { LogAttributeValue, LogAttributes, TailorLoggerAPI, debug, error, info, logger, setAttributes, warn };
@@ -0,0 +1,3 @@
1
+ import { a as setAttributes, i as logger, n as error, o as warn, r as info, t as debug } from "../logger-BtX0suGY.mjs";
2
+
3
+ export { debug, error, info, logger, setAttributes, warn };
@@ -5,6 +5,11 @@
5
5
  * Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.
6
6
  * At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`
7
7
  * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
8
+ *
9
+ * The canonical names (`startWorkflow`, `execJobFunction`,
10
+ * `resumeWorkflowExecution`) mirror the public `tailor.v1` RPC vocabulary:
11
+ * `Exec*` is a blocking call that returns the job's result, while `Start*`
12
+ * returns only an execution ID.
8
13
  * @example
9
14
  * import { workflow } from "@tailor-platform/sdk/runtime";
10
15
  *
@@ -35,8 +40,8 @@ declare const executionPolicyKeyBrand: unique symbol;
35
40
  type ExecutionPolicyKey = string & {
36
41
  readonly [executionPolicyKeyBrand]: never;
37
42
  };
38
- /** Options for {@link startJobFunction}. */
39
- interface StartJobFunctionOptions {
43
+ /** Options for {@link execJobFunction}. */
44
+ interface ExecJobFunctionOptions {
40
45
  /**
41
46
  * Execution policy key matched by the platform against the policies
42
47
  * declared with `defineWorkflowExecutionPolicies` in `tailor.config.ts`.
@@ -63,13 +68,16 @@ interface PlatformWorkflowAPI {
63
68
  */
64
69
  resumeWorkflowExecution(executionId: string): Promise<string>;
65
70
  /**
66
- * Starts a job function and returns its result.
71
+ * Executes a job function and returns its result via durable suspend/replay.
72
+ *
73
+ * Canonical name under the platform verb convention: `Exec*` blocks and
74
+ * returns the job's result, while `Start*` returns only an execution ID.
67
75
  * @param jobName - Job name as defined in the workflow
68
76
  * @param args - Arguments forwarded to the job
69
- * @param options - Optional start options (e.g. `executionPolicyKey`)
77
+ * @param options - Optional execution options (e.g. `executionPolicyKey`)
70
78
  * @returns The job's return value
71
79
  */
72
- startJobFunction(jobName: string, args?: any, options?: StartJobFunctionOptions): any;
80
+ execJobFunction(jobName: string, args?: any, options?: ExecJobFunctionOptions): any;
73
81
  /**
74
82
  * Suspends the current workflow execution and waits for an external signal to resume.
75
83
  * @param key - Wait point key
@@ -90,9 +98,9 @@ interface PlatformWorkflowAPI {
90
98
  declare const workflow: {
91
99
  readonly startWorkflow: (workflowName: string, args?: any, options?: StartWorkflowOptions) => Promise<string>;
92
100
  readonly resumeWorkflowExecution: (executionId: string) => Promise<string>;
93
- readonly startJobFunction: (jobName: string, args?: any, options?: StartJobFunctionOptions) => any;
101
+ readonly execJobFunction: (jobName: string, args?: any, options?: ExecJobFunctionOptions) => any;
94
102
  readonly wait: (key: string, payload?: any) => any;
95
103
  readonly resolve: (executionId: string, key: string, callback: (waitPayload: any) => any) => Promise<void>;
96
104
  };
97
105
  //#endregion
98
- export { ExecutionPolicyKey, Invoker, PlatformWorkflowAPI, StartJobFunctionOptions, StartWorkflowOptions, workflow };
106
+ export { ExecJobFunctionOptions, ExecutionPolicyKey, Invoker, PlatformWorkflowAPI, StartWorkflowOptions, workflow };
@@ -1,3 +1,3 @@
1
- import { t as workflow } from "../workflow-CsBvRE3g.mjs";
1
+ import { t as workflow } from "../workflow-Bamae_Yc.mjs";
2
2
 
3
3
  export { workflow };
@@ -35,10 +35,46 @@ function generateIdpSeedScriptCode(idpNamespace) {
35
35
  const client = new tailor.idp.Client({ namespace: "${idpNamespace}" });
36
36
  const errors = [];
37
37
  let processed = 0;
38
+ let created = 0;
39
+ let updated = 0;
40
+ let skipped = 0;
41
+ const upsert = input.upsert === true;
38
42
 
39
43
  for (let i = 0; i < input.users.length; i++) {
40
44
  try {
41
- await client.createUser(input.users[i]);
45
+ if (upsert) {
46
+ let existing;
47
+ let lookupError;
48
+ try {
49
+ existing = await client.userByName(input.users[i].name);
50
+ } catch (error) {
51
+ existing = undefined;
52
+ lookupError = error instanceof Error ? error.message : String(error);
53
+ }
54
+
55
+ if (existing) {
56
+ const { name, ...attributes } = input.users[i];
57
+ if (Object.keys(attributes).length === 0) {
58
+ skipped++;
59
+ } else {
60
+ await client.updateUser({ id: existing.id, ...attributes });
61
+ updated++;
62
+ }
63
+ } else {
64
+ try {
65
+ await client.createUser(input.users[i]);
66
+ created++;
67
+ } catch (error) {
68
+ const message = error instanceof Error ? error.message : String(error);
69
+ throw new Error(
70
+ lookupError ? \`create failed (\${message}); lookup failed (\${lookupError})\` : message,
71
+ );
72
+ }
73
+ }
74
+ } else {
75
+ await client.createUser(input.users[i]);
76
+ created++;
77
+ }
42
78
  processed++;
43
79
  console.log(\`[_User] \${i + 1}/\${input.users.length}: \${input.users[i].name}\`);
44
80
  } catch (error) {
@@ -51,6 +87,9 @@ function generateIdpSeedScriptCode(idpNamespace) {
51
87
  return {
52
88
  success: errors.length === 0,
53
89
  processed,
90
+ created,
91
+ updated,
92
+ skipped,
54
93
  errors,
55
94
  };
56
95
  }
@@ -440,5 +479,5 @@ function seedPlugin(options) {
440
479
  }
441
480
 
442
481
  //#endregion
443
- export { processIdpUser as a, generateIdpTruncateScriptCode as i, seedPlugin as n, generateIdpSeedScriptCode as r, SeedGeneratorID as t };
444
- //# sourceMappingURL=seed-LUVr7jHL.mjs.map
482
+ export { generateIdpTruncateScriptCode as a, generateIdpSeedScriptCode as i, seedPlugin as n, processIdpUser as o, processLinesDb as r, SeedGeneratorID as t };
483
+ //# sourceMappingURL=seed-B-yckgQY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed-B-yckgQY.mjs","names":["ml"],"sources":["../src/plugin/builtin/seed/idp-user-processor.ts","../src/plugin/builtin/seed/lines-db-processor.ts","../src/plugin/builtin/seed/index.ts"],"sourcesContent":["import ml from \"#/utils/multiline\";\nimport type { GeneratorAuthInput } from \"#/plugin/types\";\n\nexport interface IdpUserMetadata {\n name: \"_User\";\n dependencies: string[];\n dataFile: string;\n idpNamespace: string;\n schema: {\n usernameField: string;\n userTypeName: string;\n };\n}\n\n/**\n * Processes auth configuration to generate IdP user seed metadata\n * @param auth - Auth configuration from generator\n * @returns IdP user metadata or undefined if not applicable\n */\nexport function processIdpUser(auth: GeneratorAuthInput): IdpUserMetadata | undefined {\n // Only process if idProvider is BuiltInIdP and userProfile is defined\n if (auth.idProvider?.kind !== \"BuiltInIdP\" || !auth.userProfile) {\n return undefined;\n }\n\n const { typeName, usernameField } = auth.userProfile;\n\n return {\n name: \"_User\",\n dependencies: [typeName],\n dataFile: \"data/_User.jsonl\",\n idpNamespace: auth.idProvider.namespace,\n schema: {\n usernameField,\n userTypeName: typeName,\n },\n };\n}\n\n/**\n * Generates the server-side IDP seed script code for testExecScript execution.\n * Uses the global tailor.idp.Client - no bundling required.\n * @param idpNamespace - The IDP namespace name\n * @returns Script code string\n */\nexport function generateIdpSeedScriptCode(idpNamespace: string): string {\n return ml /* ts */ `\n export async function main(input) {\n const client = new tailor.idp.Client({ namespace: \"${idpNamespace}\" });\n const errors = [];\n let processed = 0;\n let created = 0;\n let updated = 0;\n let skipped = 0;\n const upsert = input.upsert === true;\n\n for (let i = 0; i < input.users.length; i++) {\n try {\n if (upsert) {\n let existing;\n let lookupError;\n try {\n existing = await client.userByName(input.users[i].name);\n } catch (error) {\n existing = undefined;\n lookupError = error instanceof Error ? error.message : String(error);\n }\n\n if (existing) {\n const { name, ...attributes } = input.users[i];\n if (Object.keys(attributes).length === 0) {\n skipped++;\n } else {\n await client.updateUser({ id: existing.id, ...attributes });\n updated++;\n }\n } else {\n try {\n await client.createUser(input.users[i]);\n created++;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n lookupError ? \\`create failed (\\${message}); lookup failed (\\${lookupError})\\` : message,\n );\n }\n }\n } else {\n await client.createUser(input.users[i]);\n created++;\n }\n processed++;\n console.log(\\`[_User] \\${i + 1}/\\${input.users.length}: \\${input.users[i].name}\\`);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`Row \\${i} (\\${input.users[i].name}): \\${message}\\`);\n console.error(\\`[_User] Row \\${i} failed: \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n processed,\n created,\n updated,\n skipped,\n errors,\n };\n }\n `;\n}\n\n/**\n * Generates the server-side IDP truncation script code for testExecScript execution.\n * Lists all users with pagination and deletes each one.\n * @param idpNamespace - The IDP namespace name\n * @returns Script code string\n */\nexport function generateIdpTruncateScriptCode(idpNamespace: string): string {\n return ml /* ts */ `\n export async function main() {\n const client = new tailor.idp.Client({ namespace: \"${idpNamespace}\" });\n const errors = [];\n let deleted = 0;\n\n // List all users with pagination\n let after = undefined;\n const allUsers = [];\n do {\n const response = await client.users(after ? { after } : undefined);\n allUsers.push(...(response.users || []));\n after = response.nextPageToken;\n } while (after);\n\n console.log(\\`Found \\${allUsers.length} IDP users to delete\\`);\n\n for (const user of allUsers) {\n try {\n await client.deleteUser(user.id);\n deleted++;\n console.log(\\`[_User] Deleted \\${deleted}/\\${allUsers.length}: \\${user.name}\\`);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n errors.push(\\`User \\${user.id} (\\${user.name}): \\${message}\\`);\n console.error(\\`[_User] Delete failed for \\${user.name}: \\${message}\\`);\n }\n }\n\n return {\n success: errors.length === 0,\n deleted,\n total: allUsers.length,\n errors,\n };\n }\n `;\n}\n\ntype GenerateIdpUserSchemaFileOptions = {\n usernameField: string;\n userTypeName: string;\n /**\n * When `true` (default), emit a foreign key from `_User.name` to the\n * userProfile type's username field so that seed validation rejects `_User`\n * rows without a matching userProfile row. Set to `false` to seed `_User`\n * rows that do not yet have a corresponding userProfile row.\n */\n includeUserProfileFK?: boolean;\n};\n\n/**\n * Generates the schema file content for IdP users. Emits the\n * `_User.name -> <userProfile>.<usernameField>` foreign key by default; pass\n * `includeUserProfileFK: false` to omit it (e.g. when seeding `_User` rows\n * that do not yet have a corresponding userProfile row).\n * @param options - Schema generation options\n * @param options.usernameField - Username field name\n * @param options.userTypeName - TailorDB user type name\n * @param options.includeUserProfileFK - Whether to emit the `_User -> userProfile` foreign key (default `true`)\n * @returns Schema file contents\n */\nexport function generateIdpUserSchemaFile(options: GenerateIdpUserSchemaFileOptions): string {\n const { usernameField, userTypeName, includeUserProfileFK = true } = options;\n const schemaBody = includeUserProfileFK\n ? ml`\n primaryKey: \"name\",\n indexes: [\n { name: \"_user_name_unique_idx\", columns: [\"name\"], unique: true },\n ],\n foreignKeys: [\n {\n column: \"name\",\n references: {\n table: \"${userTypeName}\",\n column: \"${usernameField}\",\n },\n },\n ],\n `\n : ml`\n primaryKey: \"name\",\n indexes: [\n { name: \"_user_name_unique_idx\", columns: [\"name\"], unique: true },\n ],\n `;\n\n return ml /* ts */ `\n import { t } from \"@tailor-platform/sdk\";\n import { defineSchema } from \"@tailor-platform/sdk/seed\";\n import { createStandardSchema } from \"@tailor-platform/sdk/test\";\n\n const schemaType = t.object({\n name: t.string(),\n password: t.string(),\n });\n\n // Simple identity hook for _User (no TailorDB backing type)\n const hook = <T>(data: unknown) => data as T;\n\n export const schema = defineSchema(\n createStandardSchema(schemaType, hook),\n {\n ${schemaBody}\n }\n );\n\n `;\n}\n","import { isPluginGeneratedType } from \"#/parser/service/tailordb/type-source\";\nimport ml from \"#/utils/multiline\";\nimport type {\n PluginGeneratedTypeSource,\n TailorDBType,\n TypeSourceInfoEntry,\n} from \"#/parser/service/tailordb/types\";\nimport type { LinesDbMetadata } from \"./types\";\nimport type { ForeignKeyDefinition, IndexDefinition } from \"@toiroakr/lines-db\";\n\n/**\n * Processes TailorDB types to generate lines-db metadata\n * @param type - Parsed TailorDB type\n * @param source - Source file info\n * @returns Generated lines-db metadata\n */\nexport function processLinesDb(type: TailorDBType, source: TypeSourceInfoEntry): LinesDbMetadata {\n if (isPluginGeneratedType(source)) {\n // Plugin-generated type\n return processLinesDbForPluginType(type, source);\n }\n\n // User-defined type\n if (!source.filePath) {\n throw new Error(`Missing source info for type ${type.name}`);\n }\n if (!source.exportName) {\n throw new Error(`Missing export name for type ${type.name}`);\n }\n\n const { optionalFields, omitFields, indexes, foreignKeys } = extractFieldMetadata(type);\n\n return {\n typeName: type.name,\n exportName: source.exportName,\n importPath: source.filePath,\n optionalFields,\n omitFields,\n foreignKeys,\n indexes,\n };\n}\n\n/**\n * Process lines-db metadata for plugin-generated types\n * @param type - Parsed TailorDB type\n * @param source - Plugin-generated type source info\n * @returns Generated lines-db metadata with plugin source\n */\nfunction processLinesDbForPluginType(\n type: TailorDBType,\n source: PluginGeneratedTypeSource,\n): LinesDbMetadata {\n const { optionalFields, omitFields, indexes, foreignKeys } = extractFieldMetadata(type);\n\n return {\n typeName: type.name,\n exportName: source.exportName,\n importPath: \"\",\n optionalFields,\n omitFields,\n foreignKeys,\n indexes,\n pluginSource: source,\n };\n}\n\n/**\n * Extract field metadata from TailorDB type\n * @param type - Parsed TailorDB type\n * @returns Field metadata including optional fields, omit fields, indexes, and foreign keys\n */\nfunction extractFieldMetadata(type: TailorDBType): {\n optionalFields: string[];\n omitFields: string[];\n indexes: IndexDefinition[];\n foreignKeys: ForeignKeyDefinition[];\n} {\n const optionalFields = [\"id\"]; // id is always optional\n const omitFields: string[] = [];\n const indexes: IndexDefinition[] = [];\n const foreignKeys: ForeignKeyDefinition[] = [];\n\n // Find fields with hooks.create or serial\n for (const [fieldName, field] of Object.entries(type.fields)) {\n if (field.config.hooks?.create) {\n optionalFields.push(fieldName);\n }\n // Serial fields are auto-generated, so they should be optional in seed data\n if (field.config.serial) {\n omitFields.push(fieldName);\n }\n if (field.config.unique) {\n indexes.push({\n name: `${type.name.toLowerCase()}_${fieldName}_unique_idx`,\n columns: [fieldName],\n unique: true,\n });\n }\n }\n\n // Extract indexes\n if (type.indexes) {\n for (const [indexName, indexDef] of Object.entries(type.indexes)) {\n indexes.push({\n name: indexName,\n columns: indexDef.fields,\n unique: indexDef.unique,\n });\n }\n }\n\n // Extract foreign keys from relations\n for (const [fieldName, field] of Object.entries(type.fields)) {\n if (field.relation) {\n foreignKeys.push({\n column: fieldName,\n references: {\n table: field.relation.targetType,\n column: field.relation.key,\n },\n });\n }\n }\n\n return { optionalFields, omitFields, indexes, foreignKeys };\n}\n\n/**\n * Generate schema options code for lines-db\n * @param foreignKeys - Foreign key definitions\n * @param indexes - Index definitions\n * @returns Schema options code string\n */\nfunction generateSchemaOptions(\n foreignKeys: ForeignKeyDefinition[],\n indexes: IndexDefinition[],\n): string {\n const schemaOptions: string[] = [];\n\n if (foreignKeys.length > 0) {\n schemaOptions.push(`foreignKeys: [`);\n foreignKeys.forEach((fk) => {\n schemaOptions.push(` ${JSON.stringify(fk)},`);\n });\n schemaOptions.push(`],`);\n }\n\n if (indexes.length > 0) {\n schemaOptions.push(`indexes: [`);\n indexes.forEach((index) => {\n schemaOptions.push(` ${JSON.stringify(index)},`);\n });\n schemaOptions.push(\"],\");\n }\n\n return schemaOptions.length > 0\n ? [\"\\n {\", ...schemaOptions.map((option) => ` ${option}`), \" }\"].join(\"\\n\")\n : \"\";\n}\n\n/**\n * Generates the schema file content for lines-db (for user-defined types with import)\n * @param metadata - lines-db metadata\n * @param importPath - Import path for the TailorDB type\n * @returns Schema file contents\n */\nexport function generateLinesDbSchemaFile(metadata: LinesDbMetadata, importPath: string): string {\n const { exportName, optionalFields, omitFields, foreignKeys, indexes } = metadata;\n\n const schemaTypeCode = ml /* ts */ `\n const schemaType = t.object({\n ...${exportName}.pickFields(${JSON.stringify(optionalFields)}, { optional: true }),\n ...${exportName}.omitFields(${JSON.stringify([...optionalFields, ...omitFields])}),\n });\n `;\n\n const schemaOptionsCode = generateSchemaOptions(foreignKeys, indexes);\n\n return ml /* ts */ `\n import { t } from \"@tailor-platform/sdk\";\n import { defineSchema } from \"@tailor-platform/sdk/seed\";\n import { createTailorDBHook, createStandardSchema } from \"@tailor-platform/sdk/test\";\n import { ${exportName} } from \"${importPath}\";\n\n ${schemaTypeCode}\n\n const hook = createTailorDBHook(${exportName});\n\n export const schema = defineSchema(\n createStandardSchema(schemaType, hook),${schemaOptionsCode}\n );\n\n `;\n}\n\n/**\n * Parameters for generating plugin-type schema file\n */\nexport interface PluginSchemaParams {\n /** Relative path from schema output to tailor.config.ts */\n configImportPath: string;\n /** Relative import path to the original type file (for type-attached plugins) */\n originalImportPath?: string;\n}\n\n/**\n * Generates the schema file content using getGeneratedType API\n * (for plugin-generated types)\n * @param metadata - lines-db metadata (must have pluginSource)\n * @param params - Plugin import paths\n * @returns Schema file contents\n */\nexport function generateLinesDbSchemaFileWithPluginAPI(\n metadata: LinesDbMetadata,\n params: PluginSchemaParams,\n): string {\n const { typeName, exportName, optionalFields, omitFields, foreignKeys, indexes, pluginSource } =\n metadata;\n\n if (!pluginSource) {\n throw new Error(`pluginSource is required for plugin-generated type \"${typeName}\"`);\n }\n\n const { configImportPath, originalImportPath } = params;\n\n const schemaTypeCode = ml /* ts */ `\n const schemaType = t.object({\n ...${exportName}.pickFields(${JSON.stringify(optionalFields)}, { optional: true }),\n ...${exportName}.omitFields(${JSON.stringify([...optionalFields, ...omitFields])}),\n });\n `;\n\n const schemaOptionsCode = generateSchemaOptions(foreignKeys, indexes);\n\n // Type-attached plugin (e.g., changeset): import original type and use getGeneratedType(configPath, pluginId, type, kind)\n if (pluginSource.originalExportName && originalImportPath && pluginSource.generatedTypeKind) {\n return ml /* ts */ `\n import { join } from \"node:path\";\n import { t } from \"@tailor-platform/sdk\";\n import { getGeneratedType } from \"@tailor-platform/sdk/plugin\";\n import { defineSchema } from \"@tailor-platform/sdk/seed\";\n import { createTailorDBHook, createStandardSchema } from \"@tailor-platform/sdk/test\";\n import { ${pluginSource.originalExportName} } from \"${originalImportPath}\";\n\n const configPath = join(import.meta.dirname, \"${configImportPath}\");\n const ${exportName} = await getGeneratedType(configPath, \"${pluginSource.pluginId}\", ${pluginSource.originalExportName}, \"${pluginSource.generatedTypeKind}\");\n\n ${schemaTypeCode}\n\n const hook = createTailorDBHook(${exportName});\n\n export const schema = defineSchema(\n createStandardSchema(schemaType, hook),${schemaOptionsCode}\n );\n\n `;\n }\n\n // Namespace plugin (e.g., audit-log): use getGeneratedType(configPath, pluginId, null, kind)\n // For namespace plugins, generatedTypeKind is required\n if (!pluginSource.generatedTypeKind) {\n throw new Error(\n `Namespace plugin \"${pluginSource.pluginId}\" must provide generatedTypeKind for type \"${typeName}\"`,\n );\n }\n\n return ml /* ts */ `\n import { join } from \"node:path\";\n import { t } from \"@tailor-platform/sdk\";\n import { getGeneratedType } from \"@tailor-platform/sdk/plugin\";\n import { defineSchema } from \"@tailor-platform/sdk/seed\";\n import { createTailorDBHook, createStandardSchema } from \"@tailor-platform/sdk/test\";\n\n const configPath = join(import.meta.dirname, \"${configImportPath}\");\n const ${exportName} = await getGeneratedType(configPath, \"${pluginSource.pluginId}\", null, \"${pluginSource.generatedTypeKind}\");\n\n ${schemaTypeCode}\n\n const hook = createTailorDBHook(${exportName});\n\n export const schema = defineSchema(\n createStandardSchema(schemaType, hook),${schemaOptionsCode}\n );\n\n `;\n}\n","import * as path from \"pathe\";\nimport { assertDefined } from \"#/utils/assert\";\nimport { processIdpUser, generateIdpUserSchemaFile } from \"./idp-user-processor\";\nimport {\n processLinesDb,\n generateLinesDbSchemaFile,\n generateLinesDbSchemaFileWithPluginAPI,\n type PluginSchemaParams,\n} from \"./lines-db-processor\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\n\n/** Unique identifier for the seed generator plugin. */\nexport const SeedGeneratorID = \"@tailor-platform/seed\";\n\ntype DisableIdpUserSyncDirections = {\n /**\n * Skip emitting the foreign key from `<userProfile>.<usernameField>` to\n * `_User.name`. Defaults to `false` (FK emitted).\n *\n * Set to `true` to seed pre-registration states such as\n * invited-but-not-registered users.\n */\n userToIdp?: boolean;\n /**\n * Skip emitting the foreign key from `_User.name` to\n * `<userProfile>.<usernameField>`. Defaults to `false` (FK emitted).\n *\n * Set to `true` to seed `_User` rows that do not yet have a corresponding\n * userProfile row.\n */\n idpToUser?: boolean;\n};\n\nexport type SeedPluginOptions = {\n distPath: string;\n machineUserName?: string;\n /**\n * Disable individual `_User <-> userProfile` foreign keys emitted into\n * the generated seed schema. Both directions are emitted by default.\n *\n * Set a direction to `true` to relax it — for example to seed invited\n * users that do not yet have an IdP credential.\n */\n disableIdpUserSync?: DisableIdpUserSyncDirections;\n};\n\nfunction resolveIdpUserSyncFKs(option: SeedPluginOptions[\"disableIdpUserSync\"]): {\n emitUserToIdpFK: boolean;\n emitIdpToUserFK: boolean;\n} {\n return {\n emitUserToIdpFK: !(option?.userToIdp ?? false),\n emitIdpToUserFK: !(option?.idpToUser ?? false),\n };\n}\n/**\n * Plugin that generates seed data and schema files consumed by the\n * `tailor seed` commands (@tailor-platform/sdk-plugin-seed).\n * @param options - Plugin options\n * @param options.distPath - Output directory path for generated seed files\n * @param options.machineUserName - Default machine user name for authentication\n * @param options.disableIdpUserSync - Skip emitting individual `_User <-> userProfile` foreign keys. Both directions are emitted by default; set a direction to `true` to relax that side.\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function seedPlugin(options: SeedPluginOptions): Plugin<unknown, SeedPluginOptions> {\n return {\n id: SeedGeneratorID,\n description: \"Generates seed data and schema files for the tailor seed CLI plugin\",\n pluginConfig: options,\n\n async onTailorDBReady(ctx: TailorDBReadyContext<SeedPluginOptions>): Promise<GeneratorResult> {\n const files: GeneratorResult[\"files\"] = [];\n\n // Process IdP user early so we can add reverse FK to the user profile type\n const idpUser = ctx.auth ? (processIdpUser(ctx.auth) ?? null) : null;\n const idpUserSyncFKs = resolveIdpUserSyncFKs(ctx.pluginConfig.disableIdpUserSync);\n\n for (const ns of ctx.tailordb) {\n for (const [typeName, type] of Object.entries(ns.types)) {\n const source = assertDefined(\n ns.sourceInfo.get(typeName),\n `source info missing for type: ${typeName}`,\n );\n const linesDb = processLinesDb(type, source);\n\n // Add reverse FK from userProfile type to _User (opt-out via disableIdpUserSync.userToIdp: true)\n if (\n idpUserSyncFKs.emitUserToIdpFK &&\n idpUser &&\n typeName === idpUser.schema.userTypeName\n ) {\n linesDb.foreignKeys.push({\n column: idpUser.schema.usernameField,\n references: {\n table: \"_User\",\n column: \"name\",\n },\n });\n }\n\n // Generate empty JSONL data file\n files.push({\n path: path.join(ctx.pluginConfig.distPath, \"data\", `${linesDb.typeName}.jsonl`),\n content: \"\",\n skipIfExists: true,\n });\n\n const schemaOutputPath = path.join(\n ctx.pluginConfig.distPath,\n \"data\",\n `${linesDb.typeName}.schema.ts`,\n );\n\n // Plugin-generated type: use getGeneratedType API\n if (linesDb.pluginSource && linesDb.pluginSource.pluginImportPath) {\n // Build original type import path\n let originalImportPath: string | undefined;\n if (linesDb.pluginSource.originalFilePath && linesDb.pluginSource.originalExportName) {\n const relativePath = path.relative(\n path.dirname(schemaOutputPath),\n linesDb.pluginSource.originalFilePath,\n );\n originalImportPath = relativePath.replace(/\\.ts$/, \"\").startsWith(\".\")\n ? relativePath.replace(/\\.ts$/, \"\")\n : `./${relativePath.replace(/\\.ts$/, \"\")}`;\n }\n\n // Compute relative path from schema output to config file\n const configImportPath = path.relative(path.dirname(schemaOutputPath), ctx.configPath);\n\n const params: PluginSchemaParams = {\n configImportPath,\n originalImportPath,\n };\n\n const schemaContent = generateLinesDbSchemaFileWithPluginAPI(linesDb, params);\n\n files.push({\n path: schemaOutputPath,\n content: schemaContent,\n });\n } else {\n // User-defined type: import from source file\n const relativePath = path.relative(path.dirname(schemaOutputPath), linesDb.importPath);\n const typeImportPath = relativePath.replace(/\\.ts$/, \"\").startsWith(\".\")\n ? relativePath.replace(/\\.ts$/, \"\")\n : `./${relativePath.replace(/\\.ts$/, \"\")}`;\n const schemaContent = generateLinesDbSchemaFile(linesDb, typeImportPath);\n\n files.push({\n path: schemaOutputPath,\n content: schemaContent,\n });\n }\n }\n }\n\n if (idpUser) {\n // Generate empty JSONL data file\n files.push({\n path: path.join(ctx.pluginConfig.distPath, idpUser.dataFile),\n content: \"\",\n skipIfExists: true,\n });\n\n // Generate schema file with foreign key (opt-out via disableIdpUserSync.idpToUser: true)\n files.push({\n path: path.join(ctx.pluginConfig.distPath, \"data\", `${idpUser.name}.schema.ts`),\n content: generateIdpUserSchemaFile({\n usernameField: idpUser.schema.usernameField,\n userTypeName: idpUser.schema.userTypeName,\n includeUserProfileFK: idpUserSyncFKs.emitIdpToUserFK,\n }),\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,eAAe,MAAuD;CAEpF,IAAI,KAAK,YAAY,SAAS,gBAAgB,CAAC,KAAK,aAClD;CAGF,MAAM,EAAE,UAAU,kBAAkB,KAAK;CAEzC,OAAO;EACL,MAAM;EACN,cAAc,CAAC,QAAQ;EACvB,UAAU;EACV,cAAc,KAAK,WAAW;EAC9B,QAAQ;GACN;GACA,cAAc;EAChB;CACF;AACF;;;;;;;AAQA,SAAgB,0BAA0B,cAA8B;CACtE,OAAO,SAAY;;2DAEsC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DxE;;;;;;;AAQA,SAAgB,8BAA8B,cAA8B;CAC1E,OAAO,SAAY;;2DAEsC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCxE;;;;;;;;;;;;AAyBA,SAAgB,0BAA0B,SAAmD;CAC3F,MAAM,EAAE,eAAe,cAAc,uBAAuB,SAA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M,gBAAgB,0BAA0B,SAHzB,aAAa,QAAQ,SAAS,EAAE,CAAC,CAAC,WAAW,GAAG,IACnE,aAAa,QAAQ,SAAS,EAAE,IAChC,KAAK,aAAa,QAAQ,SAAS,EAAE,GAC8B;KAEvE,MAAM,KAAK;MACT,MAAM;MACN,SAAS;KACX,CAAC;IACH;GACF;GAGF,IAAI,SAAS;IAEX,MAAM,KAAK;KACT,MAAM,KAAK,KAAK,IAAI,aAAa,UAAU,QAAQ,QAAQ;KAC3D,SAAS;KACT,cAAc;IAChB,CAAC;IAGD,MAAM,KAAK;KACT,MAAM,KAAK,KAAK,IAAI,aAAa,UAAU,QAAQ,GAAG,QAAQ,KAAK,WAAW;KAC9E,SAAS,0BAA0B;MACjC,eAAe,QAAQ,OAAO;MAC9B,cAAc,QAAQ,OAAO;MAC7B,sBAAsB,eAAe;KACvC,CAAC;IACH,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { n as logger, r as styles } from "./logger-BwS4ppwO.mjs";
2
- import { t as createCLIError } from "./errors-DfnF4ibq.mjs";
1
+ import { n as logger, r as styles } from "./logger-CXQq9YIp.mjs";
2
+ import { t as createCLIError } from "./errors-D7583Zz7.mjs";
3
3
  import * as path from "pathe";
4
4
  import { readPackageJSON } from "pkg-types";
5
5
  import { spawnSync } from "node:child_process";
@@ -128,4 +128,4 @@ async function upgrade(options) {
128
128
 
129
129
  //#endregion
130
130
  export { upgrade };
131
- //# sourceMappingURL=service-DaeJlBoH.mjs.map
131
+ //# sourceMappingURL=service-B5WynBHQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-DaeJlBoH.mjs","names":["CLIError"],"sources":["../src/cli/commands/upgrade/version-detector.ts","../src/cli/commands/upgrade/service.ts"],"sourcesContent":["import * as path from \"pathe\";\nimport { readPackageJSON } from \"pkg-types\";\n\nconst SDK_PACKAGE_NAME = \"@tailor-platform/sdk\";\n\n/**\n * Detect the installed SDK version from the user's project.\n * Walks up from projectRoot to find the SDK package in node_modules,\n * matching Node's module resolution for workspace setups with hoisted deps.\n * @param projectRoot - The project root directory to search from\n * @returns The installed SDK version string, or null if not found\n */\nexport async function detectInstalledVersion(projectRoot: string): Promise<string | null> {\n let dir = path.resolve(projectRoot);\n // loop exits when a package.json is found or the root is reached\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n while (true) {\n try {\n const sdkPath = path.join(dir, \"node_modules\", SDK_PACKAGE_NAME);\n const pkg = await readPackageJSON(sdkPath);\n if (pkg.version) return pkg.version;\n } catch {\n // Not found at this level, try parent\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n","import { spawnSync } from \"node:child_process\";\nimport { CLIError } from \"#/cli/shared/errors\";\nimport { logger, styles } from \"#/cli/shared/logger\";\nimport { detectInstalledVersion } from \"./version-detector\";\nimport type { RunOutput } from \"./types\";\n\ninterface UpgradeOptions {\n from: string;\n dryRun: boolean;\n path: string;\n}\n\n/**\n * Print the upgrade summary to the terminal.\n * @param output - The parsed JSON output from sdk-codemod\n * @param dryRun - Whether this was a dry-run\n */\nfunction printUpgradeSummary(output: RunOutput, dryRun: boolean): void {\n if (dryRun) {\n logger.info(`${styles.bold(\"[Dry Run]\")} No files were modified.`);\n logger.log(\"\");\n }\n\n const total = output.codemodsApplied + output.codemodsSkipped + output.errors.length;\n logger.info(\n `Upgrade complete: ${styles.success(`${output.codemodsApplied} applied`)}, ${styles.dim(`${output.codemodsSkipped} skipped`)} (${total} total codemods)`,\n );\n\n if (output.filesModified.length > 0) {\n logger.log(\"\");\n logger.info(\n `${dryRun ? \"Files that would be modified\" : \"Modified files\"} (${output.filesModified.length}):`,\n );\n for (const file of output.filesModified) {\n logger.log(` ${styles.path(file)}`);\n }\n }\n\n if (output.warnings.length > 0) {\n logger.log(\"\");\n logger.warn(`Manual attention needed (${output.warnings.length}):`);\n for (const warning of output.warnings) {\n logger.log(` ${styles.warning(\"!\")} ${warning}`);\n }\n }\n\n if (output.errors.length > 0) {\n logger.log(\"\");\n logger.error(`Failed codemods (${output.errors.length}):`);\n for (const { codemodId, message } of output.errors) {\n logger.log(` ${styles.error(codemodId)}: ${message}`);\n }\n }\n}\n\n/**\n * Run the upgrade pipeline:\n * 1. Detect target SDK version from node_modules\n * 2. Invoke @tailor-platform/sdk-codemod CLI\n * 3. Parse JSON output and display results\n * @param options - Upgrade options\n */\nexport async function upgrade(options: UpgradeOptions): Promise<void> {\n const projectRoot = options.path;\n\n // Step 1: Detect target SDK version (the newly installed version)\n const targetVersion = await detectInstalledVersion(projectRoot);\n if (!targetVersion) {\n throw CLIError({\n message: `Could not detect installed @tailor-platform/sdk version in ${projectRoot}`,\n suggestion:\n \"Ensure @tailor-platform/sdk is installed. Run 'pnpm install' or 'npm install' first.\",\n command: \"upgrade\",\n });\n }\n\n logger.info(\n `Upgrading from ${styles.highlight(options.from)} → ${styles.highlight(targetVersion)}`,\n );\n\n if (options.dryRun) {\n logger.info(`${styles.bold(\"[Dry Run]\")} Changes will be previewed but not applied.`);\n }\n\n logger.log(\"\");\n\n // Step 2: Invoke sdk-codemod CLI\n // Use \"latest\" because sdk-codemod may not be published at the exact same\n // version as @tailor-platform/sdk. Version filtering is handled internally\n // by sdk-codemod's registry via the --from / --to arguments.\n const npxCommand = process.platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n\n const result = spawnSync(\n npxCommand,\n [\n \"@tailor-platform/sdk-codemod@latest\",\n \"--from\",\n options.from,\n \"--to\",\n targetVersion,\n \"--target\",\n projectRoot,\n ...(options.dryRun ? [\"--dry-run\"] : []),\n ],\n {\n cwd: projectRoot,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n encoding: \"utf-8\",\n timeout: 300_000,\n },\n );\n\n if (result.error) {\n throw CLIError({\n message: `Failed to run @tailor-platform/sdk-codemod: ${result.error.message}`,\n suggestion: \"Ensure npx is available and the network is accessible.\",\n command: \"upgrade\",\n });\n }\n\n // Check for non-zero exit without a launch error (e.g. registry/auth/network failures)\n if (result.status !== 0 && !result.stdout.trim()) {\n throw CLIError({\n message: `@tailor-platform/sdk-codemod exited with code ${result.status}`,\n details: result.stderr.trim() || \"(no stderr output)\",\n suggestion:\n \"Review the error above. Common causes: invalid version arguments, network issues, or missing package registry access.\",\n command: \"upgrade\",\n });\n }\n\n // Forward captured stderr so users see dry-run diffs and progress messages\n // written by sdk-codemod. stderr is piped (not inherited) so that the error\n // path above can surface it via CLIError, but on success we still need to\n // replay it verbatim to keep the colorized unified diff output visible.\n if (result.stderr) {\n process.stderr.write(result.stderr);\n }\n\n // Step 3: Parse JSON output\n let output: RunOutput;\n try {\n output = JSON.parse(result.stdout);\n } catch {\n throw CLIError({\n message: \"Failed to parse output from @tailor-platform/sdk-codemod\",\n details: result.stdout || \"(empty stdout)\",\n suggestion: \"This is likely a bug. Please report it.\",\n command: \"upgrade\",\n });\n }\n\n // Step 4: Display results\n // Emit structured data on stdout (honors --json via logger.out) and\n // human-readable summary on stderr (via printUpgradeSummary).\n logger.out(output);\n printUpgradeSummary(output, options.dryRun);\n\n if (output.errors.length > 0) {\n throw CLIError({\n message: `Upgrade completed with ${output.errors.length} error(s)`,\n suggestion: \"Review the errors above and re-run the upgrade after fixing the issues.\",\n command: \"upgrade\",\n });\n }\n}\n"],"mappings":";;;;;;;AAGA,MAAM,mBAAmB;;;;;;;;AASzB,eAAsB,uBAAuB,aAA6C;CACxF,IAAI,MAAM,KAAK,QAAQ,WAAW;CAGlC,OAAO,MAAM;EACX,IAAI;GAEF,MAAM,MAAM,MAAM,gBADF,KAAK,KAAK,KAAK,gBAAgB,gBACP,CAAC;GACzC,IAAI,IAAI,SAAS,OAAO,IAAI;EAC9B,QAAQ,CAER;EACA,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;CACA,OAAO;AACT;;;;;;;;;ACZA,SAAS,oBAAoB,QAAmB,QAAuB;CACrE,IAAI,QAAQ;EACV,O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,QACV,OAAO,KAAK,GAAG,OAAO,KAAK,WAAW,EAAE,4CAA4C;CAGtF,OAAO,IAAI,EAAE;CAQb,MAAM,SAAS,UAFI,QAAQ,aAAa,UAAU,YAAY,OAI5D;EACE;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA,GAAI,QAAQ,SAAS,CAAC,WAAW,IAAI,CAAC;CACxC,GACA;EACE,KAAK;EACL,OAAO;GAAC;GAAU;GAAQ;EAAM;EAChC,UAAU;EACV,SAAS;CACX,CACF;CAEA,IAAI,OAAO,OACT,MAAMA,eAAS;EACb,SAAS,+CAA+C,OAAO,MAAM;EACrE,YAAY;EACZ,SAAS;CACX,CAAC;CAIH,IAAI,OAAO,WAAW,KAAK,CAAC,OAAO,OAAO,KAAK,GAC7C,MAAMA,eAAS;EACb,SAAS,iDAAiD,OAAO;EACjE,SAAS,OAAO,OAAO,KAAK,KAAK;EACjC,YACE;EACF,SAAS;CACX,CAAC;CAOH,IAAI,OAAO,QACT,QAAQ,OAAO,MAAM,OAAO,MAAM;CAIpC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,OAAO,MAAM;CACnC,QAAQ;EACN,MAAMA,eAAS;GACb,SAAS;GACT,SAAS,OAAO,UAAU;GAC1B,YAAY;GACZ,SAAS;EACX,CAAC;CACH;CAKA,OAAO,IAAI,MAAM;CACjB,oBAAoB,QAAQ,QAAQ,MAAM;CAE1C,IAAI,OAAO,OAAO,SAAS,GACzB,MAAMA,eAAS;EACb,SAAS,0BAA0B,OAAO,OAAO,OAAO;EACxD,YAAY;EACZ,SAAS;CACX,CAAC;AAEL"}
1
+ {"version":3,"file":"service-B5WynBHQ.mjs","names":["CLIError"],"sources":["../src/cli/commands/upgrade/version-detector.ts","../src/cli/commands/upgrade/service.ts"],"sourcesContent":["import * as path from \"pathe\";\nimport { readPackageJSON } from \"pkg-types\";\n\nconst SDK_PACKAGE_NAME = \"@tailor-platform/sdk\";\n\n/**\n * Detect the installed SDK version from the user's project.\n * Walks up from projectRoot to find the SDK package in node_modules,\n * matching Node's module resolution for workspace setups with hoisted deps.\n * @param projectRoot - The project root directory to search from\n * @returns The installed SDK version string, or null if not found\n */\nexport async function detectInstalledVersion(projectRoot: string): Promise<string | null> {\n let dir = path.resolve(projectRoot);\n // loop exits when a package.json is found or the root is reached\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n while (true) {\n try {\n const sdkPath = path.join(dir, \"node_modules\", SDK_PACKAGE_NAME);\n const pkg = await readPackageJSON(sdkPath);\n if (pkg.version) return pkg.version;\n } catch {\n // Not found at this level, try parent\n }\n const parent = path.dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n return null;\n}\n","import { spawnSync } from \"node:child_process\";\nimport { CLIError } from \"#/cli/shared/errors\";\nimport { logger, styles } from \"#/cli/shared/logger\";\nimport { detectInstalledVersion } from \"./version-detector\";\nimport type { RunOutput } from \"./types\";\n\ninterface UpgradeOptions {\n from: string;\n dryRun: boolean;\n path: string;\n}\n\n/**\n * Print the upgrade summary to the terminal.\n * @param output - The parsed JSON output from sdk-codemod\n * @param dryRun - Whether this was a dry-run\n */\nfunction printUpgradeSummary(output: RunOutput, dryRun: boolean): void {\n if (dryRun) {\n logger.info(`${styles.bold(\"[Dry Run]\")} No files were modified.`);\n logger.log(\"\");\n }\n\n const total = output.codemodsApplied + output.codemodsSkipped + output.errors.length;\n logger.info(\n `Upgrade complete: ${styles.success(`${output.codemodsApplied} applied`)}, ${styles.dim(`${output.codemodsSkipped} skipped`)} (${total} total codemods)`,\n );\n\n if (output.filesModified.length > 0) {\n logger.log(\"\");\n logger.info(\n `${dryRun ? \"Files that would be modified\" : \"Modified files\"} (${output.filesModified.length}):`,\n );\n for (const file of output.filesModified) {\n logger.log(` ${styles.path(file)}`);\n }\n }\n\n if (output.warnings.length > 0) {\n logger.log(\"\");\n logger.warn(`Manual attention needed (${output.warnings.length}):`);\n for (const warning of output.warnings) {\n logger.log(` ${styles.warning(\"!\")} ${warning}`);\n }\n }\n\n if (output.errors.length > 0) {\n logger.log(\"\");\n logger.error(`Failed codemods (${output.errors.length}):`);\n for (const { codemodId, message } of output.errors) {\n logger.log(` ${styles.error(codemodId)}: ${message}`);\n }\n }\n}\n\n/**\n * Run the upgrade pipeline:\n * 1. Detect target SDK version from node_modules\n * 2. Invoke @tailor-platform/sdk-codemod CLI\n * 3. Parse JSON output and display results\n * @param options - Upgrade options\n */\nexport async function upgrade(options: UpgradeOptions): Promise<void> {\n const projectRoot = options.path;\n\n // Step 1: Detect target SDK version (the newly installed version)\n const targetVersion = await detectInstalledVersion(projectRoot);\n if (!targetVersion) {\n throw CLIError({\n message: `Could not detect installed @tailor-platform/sdk version in ${projectRoot}`,\n suggestion:\n \"Ensure @tailor-platform/sdk is installed. Run 'pnpm install' or 'npm install' first.\",\n command: \"upgrade\",\n });\n }\n\n logger.info(\n `Upgrading from ${styles.highlight(options.from)} → ${styles.highlight(targetVersion)}`,\n );\n\n if (options.dryRun) {\n logger.info(`${styles.bold(\"[Dry Run]\")} Changes will be previewed but not applied.`);\n }\n\n logger.log(\"\");\n\n // Step 2: Invoke sdk-codemod CLI\n // Use \"latest\" because sdk-codemod may not be published at the exact same\n // version as @tailor-platform/sdk. Version filtering is handled internally\n // by sdk-codemod's registry via the --from / --to arguments.\n const npxCommand = process.platform === \"win32\" ? \"npx.cmd\" : \"npx\";\n\n const result = spawnSync(\n npxCommand,\n [\n \"@tailor-platform/sdk-codemod@latest\",\n \"--from\",\n options.from,\n \"--to\",\n targetVersion,\n \"--target\",\n projectRoot,\n ...(options.dryRun ? [\"--dry-run\"] : []),\n ],\n {\n cwd: projectRoot,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n encoding: \"utf-8\",\n timeout: 300_000,\n },\n );\n\n if (result.error) {\n throw CLIError({\n message: `Failed to run @tailor-platform/sdk-codemod: ${result.error.message}`,\n suggestion: \"Ensure npx is available and the network is accessible.\",\n command: \"upgrade\",\n });\n }\n\n // Check for non-zero exit without a launch error (e.g. registry/auth/network failures)\n if (result.status !== 0 && !result.stdout.trim()) {\n throw CLIError({\n message: `@tailor-platform/sdk-codemod exited with code ${result.status}`,\n details: result.stderr.trim() || \"(no stderr output)\",\n suggestion:\n \"Review the error above. Common causes: invalid version arguments, network issues, or missing package registry access.\",\n command: \"upgrade\",\n });\n }\n\n // Forward captured stderr so users see dry-run diffs and progress messages\n // written by sdk-codemod. stderr is piped (not inherited) so that the error\n // path above can surface it via CLIError, but on success we still need to\n // replay it verbatim to keep the colorized unified diff output visible.\n if (result.stderr) {\n process.stderr.write(result.stderr);\n }\n\n // Step 3: Parse JSON output\n let output: RunOutput;\n try {\n output = JSON.parse(result.stdout);\n } catch {\n throw CLIError({\n message: \"Failed to parse output from @tailor-platform/sdk-codemod\",\n details: result.stdout || \"(empty stdout)\",\n suggestion: \"This is likely a bug. Please report it.\",\n command: \"upgrade\",\n });\n }\n\n // Step 4: Display results\n // Emit structured data on stdout (honors --json via logger.out) and\n // human-readable summary on stderr (via printUpgradeSummary).\n logger.out(output);\n printUpgradeSummary(output, options.dryRun);\n\n if (output.errors.length > 0) {\n throw CLIError({\n message: `Upgrade completed with ${output.errors.length} error(s)`,\n suggestion: \"Review the errors above and re-run the upgrade after fixing the issues.\",\n command: \"upgrade\",\n });\n }\n}\n"],"mappings":";;;;;;;AAGA,MAAM,mBAAmB;;;;;;;;AASzB,eAAsB,uBAAuB,aAA6C;CACxF,IAAI,MAAM,KAAK,QAAQ,WAAW;CAGlC,OAAO,MAAM;EACX,IAAI;GAEF,MAAM,MAAM,MAAM,gBADF,KAAK,KAAK,KAAK,gBAAgB,gBACP,CAAC;GACzC,IAAI,IAAI,SAAS,OAAO,IAAI;EAC9B,QAAQ,CAER;EACA,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;CACA,OAAO;AACT;;;;;;;;;ACZA,SAAS,oBAAoB,QAAmB,QAAuB;CACrE,IAAI,QAAQ;EACV,OAAO,KAAK,GA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KAAK,GAAG,OAAO,KAAK,WAAW,EAAE,4CAA4C;CAGtF,OAAO,IAAI,EAAE;CAQb,MAAM,SAAS,UAFI,QAAQ,aAAa,UAAU,YAAY,OAI5D;EACE;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA,GAAI,QAAQ,SAAS,CAAC,WAAW,IAAI,CAAC;CACxC,GACA;EACE,KAAK;EACL,OAAO;GAAC;GAAU;GAAQ;EAAM;EAChC,UAAU;EACV,SAAS;CACX,CACF;CAEA,IAAI,OAAO,OACT,MAAMA,eAAS;EACb,SAAS,+CAA+C,OAAO,MAAM;EACrE,YAAY;EACZ,SAAS;CACX,CAAC;CAIH,IAAI,OAAO,WAAW,KAAK,CAAC,OAAO,OAAO,KAAK,GAC7C,MAAMA,eAAS;EACb,SAAS,iDAAiD,OAAO;EACjE,SAAS,OAAO,OAAO,KAAK,KAAK;EACjC,YACE;EACF,SAAS;CACX,CAAC;CAOH,IAAI,OAAO,QACT,QAAQ,OAAO,MAAM,OAAO,MAAM;CAIpC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,OAAO,MAAM;CACnC,QAAQ;EACN,MAAMA,eAAS;GACb,SAAS;GACT,SAAS,OAAO,UAAU;GAC1B,YAAY;GACZ,SAAS;EACX,CAAC;CACH;CAKA,OAAO,IAAI,MAAM;CACjB,oBAAoB,QAAQ,QAAQ,MAAM;CAE1C,IAAI,OAAO,OAAO,SAAS,GACzB,MAAMA,eAAS;EACb,SAAS,0BAA0B,OAAO,OAAO,OAAO;EACxD,YAAY;EACZ,SAAS;CACX,CAAC;AAEL"}
@@ -0,0 +1,3 @@
1
+ import { t as createExecutorService } from "./service-k1xy_A5G.mjs";
2
+
3
+ export { createExecutorService };
@@ -1,5 +1,5 @@
1
1
  import { n as isSdkBranded } from "./brand-Eo4pLXPJ.mjs";
2
- import { n as logger, r as styles } from "./logger-BwS4ppwO.mjs";
2
+ import { n as logger, r as styles } from "./logger-CXQq9YIp.mjs";
3
3
  import * as path from "pathe";
4
4
  import { z } from "zod";
5
5
  import * as fs from "node:fs";
@@ -648,13 +648,40 @@ const AuthAccessTokenTriggerSchema = z.strictObject({
648
648
  "auth.access_token.revoked"
649
649
  ])).min(1).transform((arr) => [...new Set(arr)]).describe("Auth access token event types to trigger on")
650
650
  });
651
+ const workflowNameSchema = z.string().refine((value) => value.trim().length > 0, "Workflow name cannot be blank").describe("Workflow name to subscribe to.");
652
+ const WorkflowExecutionTriggerSchema = z.strictObject({
653
+ kind: z.literal("workflowExecution").describe("Workflow execution event trigger"),
654
+ events: z.array(z.enum([
655
+ "workflow.workflow_execution.started",
656
+ "workflow.workflow_execution.completed",
657
+ "workflow.workflow_execution.retried",
658
+ "workflow.workflow_execution.resumed",
659
+ "workflow.workflow_execution.wait_started",
660
+ "workflow.workflow_execution.wait_resolved"
661
+ ])).min(1).transform((arr) => [...new Set(arr)]).describe("Workflow execution event types to trigger on"),
662
+ workflowName: workflowNameSchema,
663
+ condition: functionSchema.optional().describe("Condition function to filter events")
664
+ });
665
+ const WorkflowJobExecutionTriggerSchema = z.strictObject({
666
+ kind: z.literal("workflowJobExecution").describe("Workflow job execution event trigger"),
667
+ events: z.array(z.enum([
668
+ "workflow.workflow_execution.job_execution.started",
669
+ "workflow.workflow_execution.job_execution.completed",
670
+ "workflow.workflow_execution.job_execution.wait_started",
671
+ "workflow.workflow_execution.job_execution.wait_resolved"
672
+ ])).min(1).transform((arr) => [...new Set(arr)]).describe("Workflow job execution event types to trigger on"),
673
+ workflowName: workflowNameSchema,
674
+ condition: functionSchema.optional().describe("Condition function to filter events")
675
+ });
651
676
  const TriggerSchema = z.discriminatedUnion("kind", [
652
677
  TailorDBTriggerSchema,
653
678
  ResolverExecutedTriggerSchema,
654
679
  ScheduleTriggerSchema,
655
680
  IncomingWebhookTriggerSchema,
656
681
  IdpUserTriggerSchema,
657
- AuthAccessTokenTriggerSchema
682
+ AuthAccessTokenTriggerSchema,
683
+ WorkflowExecutionTriggerSchema,
684
+ WorkflowJobExecutionTriggerSchema
658
685
  ]);
659
686
  const FunctionOperationSchema = z.strictObject({
660
687
  kind: z.enum(["function", "jobFunction"]),
@@ -834,4 +861,4 @@ function assertUniqueExecutorNames(executors) {
834
861
 
835
862
  //#endregion
836
863
  export { AuthConfigSchema as a, stripTailorDBTypeBuilderHelpers as c, applyRelationMetadataToFieldConfig as d, buildRelationInfo as f, functionSchema as g, loadFilesWithIgnores as h, ExecutorSchema as i, TailorDBServiceConfigSchema as l, validateRelationConfig as m, loadExecutor as n, AuthInvokerSchema as o, processRelationMetadata as p, stripExecutorTriggerArgs as r, TailorFieldSchema as s, createExecutorService as t, TailorDBTypeSchema as u };
837
- //# sourceMappingURL=service-CXFce28G.mjs.map
864
+ //# sourceMappingURL=service-k1xy_A5G.mjs.map