@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.
- package/CHANGELOG.md +183 -0
- package/README.md +1 -1
- package/dist/{application-BpLeawBg.mjs → application-C8a0UJ-z.mjs} +312 -166
- package/dist/application-C8a0UJ-z.mjs.map +1 -0
- package/dist/application-D4zOiLLa.mjs +3 -0
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +47 -24
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +6 -0
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +22 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +30 -11
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.mjs +2 -2
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +366 -137
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/ts-hook.mjs +55 -8
- package/dist/completion/zsh-worker.zsh +38 -10
- package/dist/configure/config/index.d.mts +1 -1
- package/dist/configure/index.d.mts +3 -2
- package/dist/configure/index.mjs +92 -25
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/aigateway/index.d.mts +5 -4
- package/dist/configure/services/aigateway/types.d.mts +6 -1
- package/dist/configure/services/auth/types.d.mts +2 -2
- package/dist/configure/services/index.d.mts +2 -2
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +1 -1
- package/dist/configure/services/tailordb/types.d.mts +7 -4
- package/dist/configure/services/workflow/index.d.mts +2 -2
- package/dist/configure/services/workflow/wait-point.d.mts +72 -13
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/{crashreport-CINZ5dVN.mjs → crashreport-Cd4TqfZq.mjs} +1 -1
- package/dist/{crashreport-CIIfLnoO.mjs → crashreport-Q0pDAlrj.mjs} +8 -4
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-Q0pDAlrj.mjs.map} +1 -1
- package/dist/{errors-CWj21238.mjs → errors-Bxut5_Sy.mjs} +17 -3
- package/dist/{errors-CWj21238.mjs.map → errors-Bxut5_Sy.mjs.map} +1 -1
- package/dist/file-BUcmVIH2.mjs.map +1 -1
- package/dist/kysely/index.d.mts +2 -1
- package/dist/kysely/index.mjs +2 -1
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/{logger-DSdExfor.mjs → logger-D0bEznPv.mjs} +9 -5
- package/dist/{logger-DSdExfor.mjs.map → logger-D0bEznPv.mjs.map} +1 -1
- package/dist/package-json-8b0O9TlX.mjs.map +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -5
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.mjs +14 -11
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.mjs +9 -9
- package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -4
- package/dist/plugin/get-generated-type.d.mts +4 -4
- package/dist/plugin/index.mjs +13 -13
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +2 -2
- package/dist/plugin/with-context.d.mts +1 -1
- package/dist/{register-ts-hook-CTth1eqj.mjs → register-ts-hook-Vqjza10T.mjs} +2516 -857
- package/dist/register-ts-hook-Vqjza10T.mjs.map +1 -0
- package/dist/{repl-editor-BCozyiNq.mjs → repl-editor-F9LotMNx.mjs} +3 -2
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-F9LotMNx.mjs.map} +1 -1
- package/dist/runtime/file.d.mts +14 -14
- package/dist/{schema--xYWRGfe.mjs → schema-D4TC4BC3.mjs} +4 -3
- package/dist/schema-D4TC4BC3.mjs.map +1 -0
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +3 -3
- package/dist/seed/index.mjs.map +1 -1
- package/dist/{seed-xqM9WIHP.mjs → seed-Cibjmtry.mjs} +46 -40
- package/dist/seed-Cibjmtry.mjs.map +1 -0
- package/dist/{service-goqlJJgA.mjs → service-2grcAOCJ.mjs} +61 -27
- package/dist/service-2grcAOCJ.mjs.map +1 -0
- package/dist/service-CaBPNDIZ.mjs +3 -0
- package/dist/{service-CCwl3Avt.mjs → service-LTfp03ZZ.mjs} +7 -5
- package/dist/{service-CCwl3Avt.mjs.map → service-LTfp03ZZ.mjs.map} +1 -1
- package/dist/types/aigateway.generated.d.mts +2 -2
- package/dist/types/auth.generated.d.mts +3 -3
- package/dist/types/executor.generated.d.mts +1 -1
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +4 -4
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/index.mjs +95 -7
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/workflow.d.mts +13 -1
- package/dist/wait-point-invoker-__oE88_P.mjs +148 -0
- package/dist/wait-point-invoker-__oE88_P.mjs.map +1 -0
- package/dist/wait-point-registry-TL99zotw.mjs +47 -0
- package/dist/wait-point-registry-TL99zotw.mjs.map +1 -0
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +17 -13
- package/docs/cli/setup.md +14 -1
- package/docs/cli/tailordb.md +30 -27
- package/docs/cli/workspace.md +2 -2
- package/docs/cli-reference.md +23 -22
- package/docs/configuration.md +2 -2
- package/docs/github-actions.md +73 -28
- package/docs/migration/v2.md +58 -4
- package/docs/migration/v3.md +41 -0
- package/docs/quickstart.md +1 -1
- package/docs/services/aigateway.md +33 -9
- package/docs/services/executor.md +5 -1
- package/docs/services/tailordb-migration.md +146 -44
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +52 -2
- package/docs/testing.md +13 -1
- package/package.json +8 -8
- package/dist/application-BpLeawBg.mjs.map +0 -1
- package/dist/application-BxLLiLsr.mjs +0 -3
- package/dist/register-ts-hook-CTth1eqj.mjs.map +0 -1
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-_XmjSEGr.mjs +0 -3
- package/dist/service-goqlJJgA.mjs.map +0 -1
- package/dist/test-env-key-D7UkZp99.mjs +0 -75
- package/dist/test-env-key-D7UkZp99.mjs.map +0 -1
package/dist/vitest/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as getRegisteredJob, t as START_DEFAULT } from "../registry-BIGVUrMB.mjs";
|
|
2
|
-
import { a as
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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)
|
|
1481
|
-
|
|
1566
|
+
if (options?.env !== void 0) {
|
|
1567
|
+
if (hasPreviousEnv) writeWorkflowTestEnv(previousEnv);
|
|
1568
|
+
else clearWorkflowTestEnv();
|
|
1569
|
+
}
|
|
1482
1570
|
}
|
|
1483
1571
|
}
|
|
1484
1572
|
function createLocalJobRunner() {
|