@tailor-platform/sdk 2.2.0 → 2.4.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 (117) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/README.md +1 -1
  3. package/dist/{application-BpLeawBg.mjs → application-C8a0UJ-z.mjs} +312 -166
  4. package/dist/application-C8a0UJ-z.mjs.map +1 -0
  5. package/dist/application-D4zOiLLa.mjs +3 -0
  6. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +47 -24
  7. package/dist/cli/commands/tailordb/migrate/generate.d.mts +6 -0
  8. package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +22 -0
  9. package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +1 -1
  10. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +30 -11
  11. package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
  12. package/dist/cli/lib.mjs +2 -2
  13. package/dist/cli/lib.mjs.map +1 -1
  14. package/dist/cli/main.mjs +366 -137
  15. package/dist/cli/main.mjs.map +1 -1
  16. package/dist/cli/ts-hook.mjs +55 -8
  17. package/dist/completion/zsh-worker.zsh +38 -10
  18. package/dist/configure/config/index.d.mts +1 -1
  19. package/dist/configure/index.d.mts +3 -2
  20. package/dist/configure/index.mjs +92 -25
  21. package/dist/configure/index.mjs.map +1 -1
  22. package/dist/configure/services/aigateway/index.d.mts +5 -4
  23. package/dist/configure/services/aigateway/types.d.mts +6 -1
  24. package/dist/configure/services/auth/types.d.mts +2 -2
  25. package/dist/configure/services/index.d.mts +2 -2
  26. package/dist/configure/services/tailordb/permission.d.mts +1 -1
  27. package/dist/configure/services/tailordb/schema.d.mts +1 -1
  28. package/dist/configure/services/tailordb/types.d.mts +7 -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/configure/types/auth-namespace-name.d.mts +18 -0
  32. package/dist/{crashreport-CINZ5dVN.mjs → crashreport-Cd4TqfZq.mjs} +1 -1
  33. package/dist/{crashreport-CIIfLnoO.mjs → crashreport-Q0pDAlrj.mjs} +8 -4
  34. package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-Q0pDAlrj.mjs.map} +1 -1
  35. package/dist/{errors-CWj21238.mjs → errors-Bxut5_Sy.mjs} +17 -3
  36. package/dist/{errors-CWj21238.mjs.map → errors-Bxut5_Sy.mjs.map} +1 -1
  37. package/dist/file-BUcmVIH2.mjs.map +1 -1
  38. package/dist/kysely/index.d.mts +2 -1
  39. package/dist/kysely/index.mjs +2 -1
  40. package/dist/kysely/index.mjs.map +1 -1
  41. package/dist/{logger-DSdExfor.mjs → logger-D0bEznPv.mjs} +9 -5
  42. package/dist/{logger-DSdExfor.mjs.map → logger-D0bEznPv.mjs.map} +1 -1
  43. package/dist/package-json-8b0O9TlX.mjs.map +1 -1
  44. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  45. package/dist/plugin/builtin/enum-constants/index.mjs +5 -5
  46. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  47. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  48. package/dist/plugin/builtin/file-utils/index.mjs +14 -11
  49. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  50. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  51. package/dist/plugin/builtin/kysely-type/index.mjs +9 -9
  52. package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -1
  53. package/dist/plugin/builtin/seed/index.mjs +1 -1
  54. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -4
  55. package/dist/plugin/get-generated-type.d.mts +4 -4
  56. package/dist/plugin/index.mjs +13 -13
  57. package/dist/plugin/index.mjs.map +1 -1
  58. package/dist/plugin/types.d.mts +2 -2
  59. package/dist/plugin/with-context.d.mts +1 -1
  60. package/dist/{register-ts-hook-CTth1eqj.mjs → register-ts-hook-Vqjza10T.mjs} +2516 -857
  61. package/dist/register-ts-hook-Vqjza10T.mjs.map +1 -0
  62. package/dist/{repl-editor-BCozyiNq.mjs → repl-editor-F9LotMNx.mjs} +3 -2
  63. package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-F9LotMNx.mjs.map} +1 -1
  64. package/dist/runtime/file.d.mts +14 -14
  65. package/dist/{schema--xYWRGfe.mjs → schema-D4TC4BC3.mjs} +4 -3
  66. package/dist/schema-D4TC4BC3.mjs.map +1 -0
  67. package/dist/seed/index.d.mts +4 -4
  68. package/dist/seed/index.mjs +3 -3
  69. package/dist/seed/index.mjs.map +1 -1
  70. package/dist/{seed-xqM9WIHP.mjs → seed-Cibjmtry.mjs} +46 -40
  71. package/dist/seed-Cibjmtry.mjs.map +1 -0
  72. package/dist/{service-goqlJJgA.mjs → service-2grcAOCJ.mjs} +61 -27
  73. package/dist/service-2grcAOCJ.mjs.map +1 -0
  74. package/dist/service-CaBPNDIZ.mjs +3 -0
  75. package/dist/{service-CCwl3Avt.mjs → service-LTfp03ZZ.mjs} +7 -5
  76. package/dist/{service-CCwl3Avt.mjs.map → service-LTfp03ZZ.mjs.map} +1 -1
  77. package/dist/types/aigateway.generated.d.mts +2 -2
  78. package/dist/types/auth.generated.d.mts +3 -3
  79. package/dist/types/executor.generated.d.mts +1 -1
  80. package/dist/types/tailordb.generated.d.mts +12 -12
  81. package/dist/utils/test/index.d.mts +4 -4
  82. package/dist/utils/test/index.mjs +4 -4
  83. package/dist/utils/test/index.mjs.map +1 -1
  84. package/dist/vitest/index.mjs +95 -7
  85. package/dist/vitest/index.mjs.map +1 -1
  86. package/dist/vitest/mocks/workflow.d.mts +13 -1
  87. package/dist/wait-point-invoker-__oE88_P.mjs +148 -0
  88. package/dist/wait-point-invoker-__oE88_P.mjs.map +1 -0
  89. package/dist/wait-point-registry-TL99zotw.mjs +47 -0
  90. package/dist/wait-point-registry-TL99zotw.mjs.map +1 -0
  91. package/docs/cli/application.md +3 -1
  92. package/docs/cli/function.md +17 -13
  93. package/docs/cli/setup.md +14 -1
  94. package/docs/cli/tailordb.md +30 -27
  95. package/docs/cli/workspace.md +2 -2
  96. package/docs/cli-reference.md +23 -22
  97. package/docs/configuration.md +2 -2
  98. package/docs/github-actions.md +73 -28
  99. package/docs/migration/v2.md +58 -4
  100. package/docs/migration/v3.md +41 -0
  101. package/docs/quickstart.md +1 -1
  102. package/docs/services/aigateway.md +33 -9
  103. package/docs/services/executor.md +5 -1
  104. package/docs/services/tailordb-migration.md +146 -44
  105. package/docs/services/tailordb.md +7 -7
  106. package/docs/services/workflow.md +52 -2
  107. package/docs/testing.md +13 -1
  108. package/package.json +8 -8
  109. package/dist/application-BpLeawBg.mjs.map +0 -1
  110. package/dist/application-BxLLiLsr.mjs +0 -3
  111. package/dist/register-ts-hook-CTth1eqj.mjs.map +0 -1
  112. package/dist/schema--xYWRGfe.mjs.map +0 -1
  113. package/dist/seed-xqM9WIHP.mjs.map +0 -1
  114. package/dist/service-_XmjSEGr.mjs +0 -3
  115. package/dist/service-goqlJJgA.mjs.map +0 -1
  116. package/dist/test-env-key-D7UkZp99.mjs +0 -75
  117. package/dist/test-env-key-D7UkZp99.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { i as getRegisteredJob, t as START_DEFAULT } from "../registry-BIGVUrMB.mjs";
2
- import { a as writeWorkflowTestEnv, n as clearWorkflowTestEnv, r as readWorkflowTestEnv, t as buildJobContext } from "../test-env-key-D7UkZp99.mjs";
2
+ import { a as getWaitPointKey, c as readWorkflowTestEnv, i as getWaitPointInvoker, o as buildJobContext, s as clearWorkflowTestEnv, u as writeWorkflowTestEnv } from "../wait-point-invoker-__oE88_P.mjs";
3
3
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
4
4
  import { n as isNodeBuiltinImport, t as getNodeBuiltinMessage } from "../node-builtins-CmaL2Cbq.mjs";
5
5
  import { t as platformSerialize } from "../platform-serialize-RoRtBS0v.mjs";
@@ -253,7 +253,8 @@ function createEnvironmentPlugin(options) {
253
253
  }
254
254
  delete process.env.__TAILOR_RUNTIME_CONFIG;
255
255
  if (options?.config && usesTailorRuntime) {
256
- const configAbsPath = resolve(config.root ?? process.cwd(), options.config);
256
+ const configRoot = config.root ?? process.cwd();
257
+ const configAbsPath = resolve(configRoot, options.config);
257
258
  process.env.__TAILOR_RUNTIME_CONFIG = configAbsPath;
258
259
  }
259
260
  if (testConfig && typeof testConfig.setupFiles === "string") testConfig.setupFiles = [testConfig.setupFiles];
@@ -521,7 +522,7 @@ function mockFile(options = {}) {
521
522
  function allMocks() {
522
523
  return FILE_METHODS.map((method) => mocks[method]);
523
524
  }
524
- return withDispose({
525
+ const facade = {
525
526
  ...mocks,
526
527
  setResolver(value) {
527
528
  resolver = value;
@@ -555,7 +556,8 @@ function mockFile(options = {}) {
555
556
  resolver = () => null;
556
557
  for (const mock of allMocks()) mock.mockReset();
557
558
  }
558
- }, () => {
559
+ };
560
+ return withDispose(facade, () => {
559
561
  root.file = prev;
560
562
  });
561
563
  }
@@ -1177,6 +1179,8 @@ function mockTailordb(options = {}) {
1177
1179
 
1178
1180
  //#endregion
1179
1181
  //#region src/vitest/mocks/workflow.ts
1182
+ const baseInvokerWait = /* @__PURE__ */ new WeakMap();
1183
+ const baseInvokerResolve = /* @__PURE__ */ new WeakMap();
1180
1184
  const originalProcedures = /* @__PURE__ */ new WeakMap();
1181
1185
  function replaceProcedure(target, key, current) {
1182
1186
  const original = originalProcedures.get(current) ?? current;
@@ -1226,7 +1230,56 @@ function mockWorkflow() {
1226
1230
  const jobSpies = /* @__PURE__ */ new Map();
1227
1231
  const workflowSpies = /* @__PURE__ */ new Map();
1228
1232
  const waitPointMocks = /* @__PURE__ */ new Map();
1233
+ const keyDispatchers = /* @__PURE__ */ new Map();
1229
1234
  const scopedMocks = /* @__PURE__ */ new Set();
1235
+ const installKeyDispatcher = (definition) => {
1236
+ const cached = keyDispatchers.get(definition);
1237
+ if (cached) return cached;
1238
+ const invoker = getWaitPointInvoker(definition);
1239
+ if (!invoker) throw new Error("waitPointWith expects a wait point definition created by createWaitPoint or createWaitPoints.");
1240
+ const record = invoker;
1241
+ const prevWait = invoker.wait;
1242
+ const prevResolve = invoker.resolve;
1243
+ const baseWait = baseInvokerWait.get(prevWait) ?? prevWait;
1244
+ const baseResolve = baseInvokerResolve.get(prevResolve) ?? prevResolve;
1245
+ const slot = {
1246
+ perKey: /* @__PURE__ */ new Map(),
1247
+ originalWait: (key, payload) => baseWait.call(invoker, key, payload),
1248
+ originalResolve: (key, executionId, callback) => baseResolve.call(invoker, key, executionId, callback)
1249
+ };
1250
+ const dispatchWait = (key, payload) => {
1251
+ const mock = slot.perKey.get(key);
1252
+ if (!mock) return slot.originalWait(key, payload);
1253
+ return payload === void 0 ? mock.wait() : mock.wait(payload);
1254
+ };
1255
+ const dispatchResolve = async (key, executionId, callback) => {
1256
+ const mock = slot.perKey.get(key);
1257
+ if (!mock) return slot.originalResolve(key, executionId, callback);
1258
+ await mock.resolve(executionId, callback);
1259
+ };
1260
+ baseInvokerWait.set(dispatchWait, baseWait);
1261
+ baseInvokerResolve.set(dispatchResolve, baseResolve);
1262
+ record.wait = dispatchWait;
1263
+ record.resolve = dispatchResolve;
1264
+ const eachSpy = (fn) => {
1265
+ for (const mock of slot.perKey.values()) {
1266
+ const pair = mock;
1267
+ fn(pair.wait);
1268
+ fn(pair.resolve);
1269
+ }
1270
+ };
1271
+ scopedMocks.add({
1272
+ mockClear: () => eachSpy((spy) => spy.mockClear()),
1273
+ mockReset: () => eachSpy((spy) => spy.mockReset()),
1274
+ restore: () => {
1275
+ record.wait = prevWait;
1276
+ record.resolve = prevResolve;
1277
+ keyDispatchers.delete(definition);
1278
+ }
1279
+ });
1280
+ keyDispatchers.set(definition, slot);
1281
+ return slot;
1282
+ };
1230
1283
  const defaultExecJob = (jobName, _args, _options) => {
1231
1284
  throw new Error(`No workflow job mock for "${jobName}". Call mockWorkflow().setJobHandler(...) or enqueueResult(...), or use runWorkflowLocally() for local workflow execution.`);
1232
1285
  };
@@ -1317,7 +1370,8 @@ function mockWorkflow() {
1317
1370
  */
1318
1371
  setResolvePayload(payload) {
1319
1372
  resolveSpy.mockImplementation(async (_executionId, callback) => {
1320
- platformSerialize(await callback(platformSerialize(payload)));
1373
+ const result = await callback(platformSerialize(payload));
1374
+ platformSerialize(result);
1321
1375
  });
1322
1376
  }
1323
1377
  };
@@ -1325,6 +1379,38 @@ function mockWorkflow() {
1325
1379
  return waitPointMock;
1326
1380
  },
1327
1381
  /**
1382
+ * Get stable, typed mocks for one param binding of a parameterized wait point.
1383
+ * Calls made with other bindings fall through to the platform mock.
1384
+ * @param definition - Parameterized wait point definition to mock
1385
+ * @param params - Param binding to intercept, as passed to `.with()`
1386
+ * @returns Typed wait point mock control object
1387
+ */
1388
+ waitPointWith(definition, params) {
1389
+ const key = getWaitPointKey(definition.with(params));
1390
+ if (key === void 0) throw new Error("waitPointWith expects a wait point declared with $params. Use waitPoint() for a wait point with a fixed key.");
1391
+ const slot = installKeyDispatcher(definition);
1392
+ const existing = slot.perKey.get(key);
1393
+ if (existing) return existing;
1394
+ const waitSpy = vi.fn((payload) => Promise.resolve(slot.originalWait(key, payload)));
1395
+ const resolveSpy = vi.fn((executionId, callback) => slot.originalResolve(key, executionId, callback));
1396
+ const waitPointMock = {
1397
+ wait: waitSpy,
1398
+ resolve: resolveSpy,
1399
+ /**
1400
+ * Invoke the next and subsequent resolve callbacks with a wait payload.
1401
+ * @param payload - Payload originally supplied to the wait point
1402
+ */
1403
+ setResolvePayload(payload) {
1404
+ resolveSpy.mockImplementation(async (_executionId, callback) => {
1405
+ const result = await callback(platformSerialize(payload));
1406
+ platformSerialize(result);
1407
+ });
1408
+ }
1409
+ };
1410
+ slot.perKey.set(key, waitPointMock);
1411
+ return waitPointMock;
1412
+ },
1413
+ /**
1328
1414
  * Set a fallback job handler. Called when the enqueue queue is empty.
1329
1415
  * @param handler - Function returning a result for a job name, args, and options
1330
1416
  */
@@ -1477,8 +1563,10 @@ async function runWorkflowLocally(workflow, args, options) {
1477
1563
  } finally {
1478
1564
  if (previousTailor) root.tailor = previousTailor;
1479
1565
  else delete root.tailor;
1480
- if (options?.env !== void 0) if (hasPreviousEnv) writeWorkflowTestEnv(previousEnv);
1481
- else clearWorkflowTestEnv();
1566
+ if (options?.env !== void 0) {
1567
+ if (hasPreviousEnv) writeWorkflowTestEnv(previousEnv);
1568
+ else clearWorkflowTestEnv();
1569
+ }
1482
1570
  }
1483
1571
  }
1484
1572
  function createLocalJobRunner() {