@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.
- package/CHANGELOG.md +611 -0
- package/dist/{application-D_oSqto2.mjs → application-CM6hKnSK.mjs} +489 -118
- package/dist/application-CM6hKnSK.mjs.map +1 -0
- package/dist/application-CXNaUNhv.mjs +3 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +1 -1
- package/dist/cli/commands/deploy/application.d.mts +1 -1
- package/dist/cli/commands/deploy/auth.d.mts +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +1 -0
- package/dist/cli/commands/deploy/executor.d.mts +1 -1
- package/dist/cli/commands/deploy/function-registry.d.mts +1 -2
- package/dist/cli/commands/deploy/idp.d.mts +1 -1
- package/dist/cli/commands/deploy/label.d.mts +2 -0
- package/dist/cli/commands/deploy/resolver.d.mts +1 -1
- package/dist/cli/commands/deploy/staticwebsite.d.mts +1 -1
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -1
- package/dist/cli/commands/deploy/types.d.mts +2 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -2
- package/dist/cli/commands/deploy/workflow.d.mts +1 -1
- package/dist/cli/commands/executor/get.d.mts +1 -10
- package/dist/cli/commands/executor/jobs.d.mts +1 -38
- package/dist/cli/commands/executor/trigger.d.mts +1 -11
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -2
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/commands/workflow/executions.d.mts +1 -13
- package/dist/cli/commands/workflow/get.d.mts +1 -10
- package/dist/cli/commands/workflow/start.d.mts +2 -14
- package/dist/cli/index.mjs +12 -6561
- package/dist/cli/lib.d.mts +9 -12
- package/dist/cli/lib.mjs +99 -42
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/{index.d.mts → main.d.mts} +1 -1
- package/dist/cli/main.mjs +6777 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
- package/dist/cli/services/workflow/bundler.d.mts +2 -1
- package/dist/cli/shared/client.d.mts +28 -3
- package/dist/cli/shared/config-loader.d.mts +11 -4
- package/dist/cli/shared/error-json.d.mts +23 -0
- package/dist/cli/shared/tsconfig-paths-plugin.d.mts +2 -0
- package/dist/cli/shared/type-generator.d.mts +4 -3
- package/dist/completion/zsh-worker.zsh +85 -22
- package/dist/configure/config/types.d.mts +29 -4
- package/dist/configure/index.d.mts +4 -3
- package/dist/configure/index.mjs +183 -6
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/executor/index.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +245 -2
- package/dist/configure/services/executor/trigger/index.d.mts +3 -3
- package/dist/configure/services/idp/index.d.mts +2 -2
- package/dist/configure/services/idp/permission.d.mts +1 -16
- package/dist/configure/services/idp/types.d.mts +5 -1
- package/dist/configure/services/index.d.mts +4 -3
- package/dist/configure/services/resolver/index.d.mts +2 -1
- package/dist/configure/services/resolver/permission.d.mts +64 -0
- package/dist/configure/services/resolver/resolver.d.mts +14 -2
- package/dist/configure/services/tailordb/index.d.mts +0 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -16
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/execution-policy.types.d.mts +1 -1
- package/dist/configure/services/workflow/job.d.mts +11 -2
- package/dist/configure/services/workflow/workflow.d.mts +10 -0
- package/dist/configure/types/permission-operand.types.d.mts +20 -0
- package/dist/{crashreport-CxHne11E.mjs → crashreport-B5LqCTfF.mjs} +2 -2
- package/dist/{crashreport-CxHne11E.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
- package/dist/{crashreport-0ioNRZ4K.mjs → crashreport-eI7ty7ok.mjs} +1 -1
- package/dist/{errors-DfnF4ibq.mjs → errors-D7583Zz7.mjs} +2 -44
- package/dist/errors-D7583Zz7.mjs.map +1 -0
- package/dist/{globals-CBZ0egXT.mjs → globals-TfAVItuK.mjs} +21 -5
- package/dist/globals-TfAVItuK.mjs.map +1 -0
- package/dist/logger-BtX0suGY.mjs +48 -0
- package/dist/logger-BtX0suGY.mjs.map +1 -0
- package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
- package/dist/logger-CXQq9YIp.mjs.map +1 -0
- package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
- package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
- package/dist/plugin/builtin/enum-constants/index.mjs +115 -2
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -0
- package/dist/plugin/builtin/file-utils/index.mjs +149 -2
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +274 -2
- package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +2 -0
- package/dist/{register-ts-hook-DgnmGTCt.mjs → register-ts-hook-LYV7zH-e.mjs} +2949 -1001
- package/dist/register-ts-hook-LYV7zH-e.mjs.map +1 -0
- package/dist/{registry-i7EdJ-D5.mjs → registry-BIGVUrMB.mjs} +3 -3
- package/dist/registry-BIGVUrMB.mjs.map +1 -0
- package/dist/runtime/globals.d.mts +7 -0
- package/dist/runtime/index.d.mts +3 -1
- package/dist/runtime/index.mjs +3 -2
- package/dist/runtime/logger.d.mts +98 -0
- package/dist/runtime/logger.mjs +3 -0
- package/dist/runtime/workflow.d.mts +15 -7
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/{seed-LUVr7jHL.mjs → seed-B-yckgQY.mjs} +42 -3
- package/dist/seed-B-yckgQY.mjs.map +1 -0
- package/dist/{service-DaeJlBoH.mjs → service-B5WynBHQ.mjs} +3 -3
- package/dist/{service-DaeJlBoH.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
- package/dist/service-M7OYziQP.mjs +3 -0
- package/dist/{service-CXFce28G.mjs → service-k1xy_A5G.mjs} +30 -3
- package/dist/{service-CXFce28G.mjs.map → service-k1xy_A5G.mjs.map} +1 -1
- package/dist/{service_pb-BoLM0X4K.mjs → service_pb-D5--My_M.mjs} +5 -5
- package/dist/service_pb-D5--My_M.mjs.map +1 -0
- package/dist/{service_pb-r1T7kpJc.mjs → service_pb-i8CmnQP4.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
- package/dist/types/auth.generated.d.mts +14 -2
- package/dist/types/executor.generated.d.mts +45 -3
- package/dist/types/http-adapter.generated.d.mts +5 -0
- package/dist/types/idp.generated.d.mts +31 -1
- package/dist/types/resolver.generated.d.mts +30 -2
- package/dist/types/tailordb.generated.d.mts +15 -1
- package/dist/utils/test/index.d.mts +1 -2
- package/dist/utils/test/index.mjs +1 -169
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +6 -4
- package/dist/vitest/index.mjs +112 -62
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock.d.mts +2 -1
- package/dist/vitest/mocks/logger.d.mts +45 -0
- package/dist/vitest/mocks/workflow.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -1
- package/dist/{workflow-CsBvRE3g.mjs → workflow-Bamae_Yc.mjs} +5 -5
- package/dist/workflow-Bamae_Yc.mjs.map +1 -0
- package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-DXnO2AT-.mjs} +13 -8
- package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
- package/docs/cli/application.md +5 -1
- package/docs/cli/tailordb.md +47 -13
- package/docs/cli-reference.md +31 -30
- package/docs/configuration.md +53 -1
- package/docs/github-actions.md +2 -2
- package/docs/migration/v2.md +307 -10
- package/docs/runtime.md +5 -1
- package/docs/services/executor.md +83 -3
- package/docs/services/idp.md +8 -6
- package/docs/services/resolver.md +60 -4
- package/docs/services/tailordb-migration.md +31 -7
- package/docs/services/tailordb.md +7 -5
- package/docs/services/workflow.md +33 -3
- package/docs/testing.md +34 -7
- package/package.json +31 -24
- package/dist/application-CtuzFhg8.mjs +0 -3
- package/dist/application-D_oSqto2.mjs.map +0 -1
- package/dist/cli/index.mjs.map +0 -1
- package/dist/enum-constants-j9QBF0cB.mjs +0 -116
- package/dist/enum-constants-j9QBF0cB.mjs.map +0 -1
- package/dist/errors-DfnF4ibq.mjs.map +0 -1
- package/dist/file-utils-yEiIS4nJ.mjs +0 -150
- package/dist/file-utils-yEiIS4nJ.mjs.map +0 -1
- package/dist/globals-CBZ0egXT.mjs.map +0 -1
- package/dist/kysely-type-DqIRgDYR.mjs +0 -275
- package/dist/kysely-type-DqIRgDYR.mjs.map +0 -1
- package/dist/logger-BwS4ppwO.mjs.map +0 -1
- package/dist/register-ts-hook-DgnmGTCt.mjs.map +0 -1
- package/dist/registry-i7EdJ-D5.mjs.map +0 -1
- package/dist/seed-LUVr7jHL.mjs.map +0 -1
- package/dist/service-DjhjpJpm.mjs +0 -3
- package/dist/service_pb-BoLM0X4K.mjs.map +0 -1
- package/dist/utils/test/mock.d.mts +0 -86
- package/dist/workflow-CsBvRE3g.mjs.map +0 -1
- package/dist/workspace_resource_pb-Db3fv68L.mjs.map +0 -1
package/dist/vitest/index.mjs
CHANGED
|
@@ -1,52 +1,23 @@
|
|
|
1
|
-
import { i as getRegisteredJob, t as START_DEFAULT } from "../registry-
|
|
1
|
+
import { i as getRegisteredJob, t as START_DEFAULT } from "../registry-BIGVUrMB.mjs";
|
|
2
2
|
import { a as writeWorkflowTestEnv, n as clearWorkflowTestEnv, r as readWorkflowTestEnv, t as buildJobContext } from "../test-env-key-D7UkZp99.mjs";
|
|
3
3
|
import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
|
|
4
|
+
import { n as isNodeBuiltinImport, t as getNodeBuiltinMessage } from "../node-builtins-CmaL2Cbq.mjs";
|
|
4
5
|
import { t as platformSerialize } from "../platform-serialize-RoRtBS0v.mjs";
|
|
5
6
|
import { i as withDispose, n as tailorRoot, r as tailordbRoot, t as mockSecretmanager } from "../secretmanager-IY4UvinW.mjs";
|
|
6
|
-
import { builtinModules } from "node:module";
|
|
7
7
|
import { isEqual } from "es-toolkit";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { dirname, isAbsolute, matchesGlob, relative, resolve } from "node:path";
|
|
10
9
|
import { ColumnNode, InsertQueryNode, Kysely, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler, PrimitiveValueListNode, ReferenceNode, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode } from "kysely";
|
|
10
|
+
import { dirname, isAbsolute, matchesGlob, relative, resolve } from "node:path";
|
|
11
11
|
import { vi } from "vitest";
|
|
12
12
|
|
|
13
13
|
//#region src/vitest/blocked-modules.ts
|
|
14
14
|
/**
|
|
15
|
-
* Blocked Node.js built-in modules and their Web Standard API alternatives.
|
|
16
|
-
*
|
|
17
|
-
* The Tailor Platform runtime only provides Web Standard APIs.
|
|
18
|
-
* These Node.js modules are not available and should be replaced with
|
|
19
|
-
* the suggested alternatives.
|
|
20
|
-
*/
|
|
21
|
-
const SUGGESTIONS = {
|
|
22
|
-
crypto: "Use the Web Crypto API (globalThis.crypto) instead.",
|
|
23
|
-
buffer: "Use Uint8Array or ArrayBuffer instead.",
|
|
24
|
-
fs: "File system access is not available in the Tailor Platform runtime.",
|
|
25
|
-
"fs/promises": "File system access is not available in the Tailor Platform runtime.",
|
|
26
|
-
path: "Use URL or URLPattern for path manipulation.",
|
|
27
|
-
http: "Use the Fetch API (globalThis.fetch) for HTTP requests instead.",
|
|
28
|
-
https: "Use the Fetch API (globalThis.fetch) for HTTPS requests instead.",
|
|
29
|
-
url: "Use the URL and URLSearchParams Web APIs instead.",
|
|
30
|
-
util: "Use Web Standard APIs instead.",
|
|
31
|
-
stream: "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
|
|
32
|
-
"stream/web": "Use Web Streams API (ReadableStream, WritableStream, TransformStream) instead.",
|
|
33
|
-
events: "Use EventTarget instead.",
|
|
34
|
-
zlib: "Use CompressionStream and DecompressionStream Web APIs instead.",
|
|
35
|
-
querystring: "Use URLSearchParams instead.",
|
|
36
|
-
string_decoder: "Use TextDecoder instead."
|
|
37
|
-
};
|
|
38
|
-
const BLOCKED_MODULES = /* @__PURE__ */ new Set();
|
|
39
|
-
for (const mod of builtinModules) {
|
|
40
|
-
BLOCKED_MODULES.add(mod);
|
|
41
|
-
BLOCKED_MODULES.add(`node:${mod}`);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
15
|
* Check if a module specifier is a blocked Node.js built-in.
|
|
45
16
|
* @param specifier - Module specifier to check (e.g. "node:crypto", "fs")
|
|
46
17
|
* @returns Whether the specifier is blocked
|
|
47
18
|
*/
|
|
48
19
|
function isBlockedModule(specifier) {
|
|
49
|
-
return
|
|
20
|
+
return isNodeBuiltinImport(specifier);
|
|
50
21
|
}
|
|
51
22
|
/**
|
|
52
23
|
* Get the error message for a blocked module import.
|
|
@@ -54,10 +25,7 @@ function isBlockedModule(specifier) {
|
|
|
54
25
|
* @returns Error message with optional suggestion for the Web Standard API alternative
|
|
55
26
|
*/
|
|
56
27
|
function getBlockedMessage(specifier) {
|
|
57
|
-
|
|
58
|
-
const suggestion = SUGGESTIONS[bare];
|
|
59
|
-
const base = `"${specifier}" is not available in the Tailor Platform runtime.`;
|
|
60
|
-
return suggestion ? `${base} ${suggestion}` : base;
|
|
28
|
+
return getNodeBuiltinMessage(specifier);
|
|
61
29
|
}
|
|
62
30
|
|
|
63
31
|
//#endregion
|
|
@@ -901,6 +869,86 @@ function mockIdp(options = {}) {
|
|
|
901
869
|
});
|
|
902
870
|
}
|
|
903
871
|
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/vitest/mocks/logger.ts
|
|
874
|
+
/**
|
|
875
|
+
* Acquire a disposable mock for `tailor.logger`. Each method is a `vi.fn`, so
|
|
876
|
+
* calls can be asserted directly; `calls` returns the `debug`/`info`/`warn`/
|
|
877
|
+
* `error` entries in the order they were emitted. Restored on dispose.
|
|
878
|
+
* @param _options - Reserved for future initial fixtures
|
|
879
|
+
* @returns Disposable logger mock control object
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* import { mockLogger } from "@tailor-platform/sdk/vitest";
|
|
883
|
+
*
|
|
884
|
+
* test("logs the processed order", () => {
|
|
885
|
+
* using logger = mockLogger();
|
|
886
|
+
* // …run code that calls tailor.logger.info…
|
|
887
|
+
* expect(logger.info).toHaveBeenCalledWith("order processed", { orderId: "o-1" });
|
|
888
|
+
* });
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
function mockLogger(_options = {}) {
|
|
892
|
+
const root = tailorRoot();
|
|
893
|
+
const prev = root.logger;
|
|
894
|
+
const debug = vi.fn((_message, _attributes) => {});
|
|
895
|
+
const info = vi.fn((_message, _attributes) => {});
|
|
896
|
+
const warn = vi.fn((_message, _attributes) => {});
|
|
897
|
+
const error = vi.fn((_message, _attributes) => {});
|
|
898
|
+
const setAttributes = vi.fn((_attributes) => {});
|
|
899
|
+
root.logger = {
|
|
900
|
+
debug,
|
|
901
|
+
info,
|
|
902
|
+
warn,
|
|
903
|
+
error,
|
|
904
|
+
setAttributes
|
|
905
|
+
};
|
|
906
|
+
const severityFns = {
|
|
907
|
+
debug,
|
|
908
|
+
info,
|
|
909
|
+
warn,
|
|
910
|
+
error
|
|
911
|
+
};
|
|
912
|
+
return withDispose({
|
|
913
|
+
/** The `debug` `vi.fn`. */
|
|
914
|
+
debug,
|
|
915
|
+
/** The `info` `vi.fn`. */
|
|
916
|
+
info,
|
|
917
|
+
/** The `warn` `vi.fn`. */
|
|
918
|
+
warn,
|
|
919
|
+
/** The `error` `vi.fn`. */
|
|
920
|
+
error,
|
|
921
|
+
/** The `setAttributes` `vi.fn`. */
|
|
922
|
+
setAttributes,
|
|
923
|
+
get calls() {
|
|
924
|
+
return Object.entries(severityFns).flatMap(([severity, fn]) => fn.mock.calls.map((args, i) => ({
|
|
925
|
+
order: fn.mock.invocationCallOrder[i] ?? 0,
|
|
926
|
+
call: {
|
|
927
|
+
severity,
|
|
928
|
+
message: args[0],
|
|
929
|
+
attributes: args[1]
|
|
930
|
+
}
|
|
931
|
+
}))).toSorted((a, b) => a.order - b.order).map((e) => e.call);
|
|
932
|
+
},
|
|
933
|
+
clear() {
|
|
934
|
+
debug.mockClear();
|
|
935
|
+
info.mockClear();
|
|
936
|
+
warn.mockClear();
|
|
937
|
+
error.mockClear();
|
|
938
|
+
setAttributes.mockClear();
|
|
939
|
+
},
|
|
940
|
+
reset() {
|
|
941
|
+
debug.mockReset();
|
|
942
|
+
info.mockReset();
|
|
943
|
+
warn.mockReset();
|
|
944
|
+
error.mockReset();
|
|
945
|
+
setAttributes.mockReset();
|
|
946
|
+
}
|
|
947
|
+
}, () => {
|
|
948
|
+
root.logger = prev;
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
|
|
904
952
|
//#endregion
|
|
905
953
|
//#region src/vitest/mocks/tailordb.ts
|
|
906
954
|
function testRegex(regex, value) {
|
|
@@ -1156,6 +1204,7 @@ function replaceStart(definition) {
|
|
|
1156
1204
|
/**
|
|
1157
1205
|
* Acquire a disposable mock for workflow operations (`tailor.workflow`).
|
|
1158
1206
|
* Restored on dispose.
|
|
1207
|
+
|
|
1159
1208
|
* @returns Disposable workflow mock control object
|
|
1160
1209
|
* @example
|
|
1161
1210
|
* ```typescript
|
|
@@ -1178,26 +1227,26 @@ function mockWorkflow() {
|
|
|
1178
1227
|
const workflowSpies = /* @__PURE__ */ new Map();
|
|
1179
1228
|
const waitPointMocks = /* @__PURE__ */ new Map();
|
|
1180
1229
|
const scopedMocks = /* @__PURE__ */ new Set();
|
|
1181
|
-
const
|
|
1230
|
+
const defaultExecJob = (jobName, _args, _options) => {
|
|
1182
1231
|
throw new Error(`No workflow job mock for "${jobName}". Call mockWorkflow().setJobHandler(...) or enqueueResult(...), or use runWorkflowLocally() for local workflow execution.`);
|
|
1183
1232
|
};
|
|
1184
1233
|
const defaultStartWorkflow = async (_workflowName, _args, _options) => {
|
|
1185
1234
|
return START_DEFAULT;
|
|
1186
1235
|
};
|
|
1187
1236
|
const defaultResumeWorkflowExecution = async (executionId) => executionId;
|
|
1188
|
-
const
|
|
1237
|
+
const execJobFunction = vi.fn(defaultExecJob);
|
|
1189
1238
|
const startWorkflow = vi.fn(defaultStartWorkflow);
|
|
1190
1239
|
const resumeWorkflowExecution = vi.fn(defaultResumeWorkflowExecution);
|
|
1191
1240
|
const wait = vi.fn((_key, _payload) => null);
|
|
1192
1241
|
const resolve = vi.fn(async (_executionId, _key, _callback) => {});
|
|
1193
1242
|
const jobFunctionShim = (...call) => {
|
|
1194
|
-
const out = call.length >= 3 ?
|
|
1243
|
+
const out = call.length >= 3 ? execJobFunction(call[0], platformSerialize(call[1]), call[2]) : execJobFunction(call[0], platformSerialize(call[1]));
|
|
1195
1244
|
return out instanceof Promise ? out.then((v) => platformSerialize(v)) : platformSerialize(out);
|
|
1196
1245
|
};
|
|
1197
1246
|
const workflowShim = (...call) => call.length >= 3 ? startWorkflow(call[0], platformSerialize(call[1]), call[2]) : startWorkflow(call[0], platformSerialize(call[1]));
|
|
1198
1247
|
const resumeShim = (executionId) => resumeWorkflowExecution(executionId);
|
|
1199
1248
|
root.workflow = {
|
|
1200
|
-
|
|
1249
|
+
execJobFunction: jobFunctionShim,
|
|
1201
1250
|
startWorkflow: workflowShim,
|
|
1202
1251
|
resumeWorkflowExecution: resumeShim,
|
|
1203
1252
|
wait: (key, payload) => wait(key, platformSerialize(payload)),
|
|
@@ -1207,8 +1256,8 @@ function mockWorkflow() {
|
|
|
1207
1256
|
})
|
|
1208
1257
|
};
|
|
1209
1258
|
return withDispose({
|
|
1210
|
-
/** The `
|
|
1211
|
-
|
|
1259
|
+
/** The `execJobFunction` `vi.fn`. */
|
|
1260
|
+
execJobFunction,
|
|
1212
1261
|
/** The `startWorkflow` `vi.fn`. */
|
|
1213
1262
|
startWorkflow,
|
|
1214
1263
|
/** The `resumeWorkflowExecution` `vi.fn`. */
|
|
@@ -1280,29 +1329,29 @@ function mockWorkflow() {
|
|
|
1280
1329
|
* @param handler - Function returning a result for a job name, args, and options
|
|
1281
1330
|
*/
|
|
1282
1331
|
setJobHandler(handler) {
|
|
1283
|
-
|
|
1332
|
+
execJobFunction.mockImplementation((name, args, options) => handler(name, args, options));
|
|
1284
1333
|
},
|
|
1285
1334
|
/**
|
|
1286
|
-
* Enqueue a single result for the next `
|
|
1335
|
+
* Enqueue a single result for the next `execJobFunction` call (FIFO;
|
|
1287
1336
|
* takes priority over `setJobHandler`).
|
|
1288
1337
|
* @param result - Result to return from the next call
|
|
1289
1338
|
*/
|
|
1290
1339
|
enqueueResult(result) {
|
|
1291
|
-
|
|
1340
|
+
execJobFunction.mockImplementationOnce(() => result);
|
|
1292
1341
|
},
|
|
1293
1342
|
/**
|
|
1294
|
-
* Enqueue results for multiple subsequent `
|
|
1343
|
+
* Enqueue results for multiple subsequent `execJobFunction` calls (FIFO).
|
|
1295
1344
|
* @param results - Results to enqueue, one per upcoming call
|
|
1296
1345
|
*/
|
|
1297
1346
|
enqueueResults(...results) {
|
|
1298
|
-
for (const result of results)
|
|
1347
|
+
for (const result of results) execJobFunction.mockImplementationOnce(() => result);
|
|
1299
1348
|
},
|
|
1300
1349
|
/**
|
|
1301
|
-
* All jobs
|
|
1350
|
+
* All jobs executed via `execJobFunction`, in order.
|
|
1302
1351
|
* @returns Started jobs array
|
|
1303
1352
|
*/
|
|
1304
1353
|
get startedJobs() {
|
|
1305
|
-
return
|
|
1354
|
+
return execJobFunction.mock.calls.map(([jobName, args, options]) => ({
|
|
1306
1355
|
jobName,
|
|
1307
1356
|
args,
|
|
1308
1357
|
...options !== void 0 && { options }
|
|
@@ -1372,7 +1421,7 @@ function mockWorkflow() {
|
|
|
1372
1421
|
},
|
|
1373
1422
|
/** Clear recorded calls while preserving configured responses. */
|
|
1374
1423
|
clear() {
|
|
1375
|
-
|
|
1424
|
+
execJobFunction.mockClear();
|
|
1376
1425
|
startWorkflow.mockClear();
|
|
1377
1426
|
resumeWorkflowExecution.mockClear();
|
|
1378
1427
|
wait.mockClear();
|
|
@@ -1381,8 +1430,8 @@ function mockWorkflow() {
|
|
|
1381
1430
|
},
|
|
1382
1431
|
/** Reset all workflow responses and recorded calls (keeps the mock installed). */
|
|
1383
1432
|
reset() {
|
|
1384
|
-
|
|
1385
|
-
|
|
1433
|
+
execJobFunction.mockReset();
|
|
1434
|
+
execJobFunction.mockImplementation(defaultExecJob);
|
|
1386
1435
|
startWorkflow.mockReset();
|
|
1387
1436
|
startWorkflow.mockImplementation(defaultStartWorkflow);
|
|
1388
1437
|
resumeWorkflowExecution.mockReset();
|
|
@@ -1421,7 +1470,7 @@ async function runWorkflowLocally(workflow, args, options) {
|
|
|
1421
1470
|
if (options?.env !== void 0) writeWorkflowTestEnv({ ...options.env });
|
|
1422
1471
|
root.tailor = {
|
|
1423
1472
|
...previousTailor,
|
|
1424
|
-
workflow: createLocalWorkflowRuntime(previousTailor?.workflow, runner.
|
|
1473
|
+
workflow: createLocalWorkflowRuntime(previousTailor?.workflow, runner.execJobFunction)
|
|
1425
1474
|
};
|
|
1426
1475
|
try {
|
|
1427
1476
|
return await runner.runJob(workflow.mainJob.name, args);
|
|
@@ -1434,7 +1483,7 @@ async function runWorkflowLocally(workflow, args, options) {
|
|
|
1434
1483
|
}
|
|
1435
1484
|
function createLocalJobRunner() {
|
|
1436
1485
|
let activeExecution;
|
|
1437
|
-
const
|
|
1486
|
+
const execJobFunction = (jobName, args) => {
|
|
1438
1487
|
if (!activeExecution) throw new Error(`Cannot start workflow job "${jobName}" outside runWorkflowLocally() job execution.`);
|
|
1439
1488
|
if (activeExecution.pending) throw activeExecution.pending;
|
|
1440
1489
|
const serializedArgs = platformSerialize(args);
|
|
@@ -1483,7 +1532,7 @@ function createLocalJobRunner() {
|
|
|
1483
1532
|
};
|
|
1484
1533
|
return {
|
|
1485
1534
|
runJob,
|
|
1486
|
-
|
|
1535
|
+
execJobFunction
|
|
1487
1536
|
};
|
|
1488
1537
|
}
|
|
1489
1538
|
async function settlePendingStart(records, pending, runJob) {
|
|
@@ -1507,7 +1556,7 @@ function assertSameStart(record, jobName, args) {
|
|
|
1507
1556
|
if (record.jobName === jobName && JSON.stringify(record.args) === JSON.stringify(args)) return;
|
|
1508
1557
|
throw new Error(`Workflow job start sequence changed while replaying. Expected ${record.jobName}(${JSON.stringify(record.args)}), but got ${jobName}(${JSON.stringify(args)}).`);
|
|
1509
1558
|
}
|
|
1510
|
-
function createLocalWorkflowRuntime(previous,
|
|
1559
|
+
function createLocalWorkflowRuntime(previous, execJobFunction) {
|
|
1511
1560
|
const startWorkflow = async (name, args, options) => {
|
|
1512
1561
|
if (previous) return await previous.startWorkflow(name, args, options);
|
|
1513
1562
|
platformSerialize(args);
|
|
@@ -1518,7 +1567,7 @@ function createLocalWorkflowRuntime(previous, startJobFunction) {
|
|
|
1518
1567
|
return executionId;
|
|
1519
1568
|
};
|
|
1520
1569
|
return {
|
|
1521
|
-
|
|
1570
|
+
execJobFunction,
|
|
1522
1571
|
startWorkflow,
|
|
1523
1572
|
resumeWorkflowExecution,
|
|
1524
1573
|
wait: (key, payload) => {
|
|
@@ -1725,7 +1774,8 @@ function createKyselyMock() {
|
|
|
1725
1774
|
*
|
|
1726
1775
|
* 3. **Platform API mocks** (environment) — All platform APIs are auto-injected with
|
|
1727
1776
|
* control objects: `mockTailordb`, `mockWorkflow`, `mockSecretmanager`,
|
|
1728
|
-
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway
|
|
1777
|
+
* `mockAuthconnection`, `mockIdp`, `mockFile`, `mockIconv`, `mockAigateway`,
|
|
1778
|
+
* `mockLogger`. Each
|
|
1729
1779
|
* provides response configuration, call recording, and reset.
|
|
1730
1780
|
*
|
|
1731
1781
|
* 4. **Environment resolution** — Rewrites `environment: "tailor-runtime"` to the
|
|
@@ -1735,8 +1785,8 @@ function createKyselyMock() {
|
|
|
1735
1785
|
*
|
|
1736
1786
|
* - **`process`** and **`require`** are NOT removed or blocked. Vitest's internal
|
|
1737
1787
|
* runner depends on them. On the real Tailor Platform runtime, they do not exist.
|
|
1738
|
-
* - **Dynamic `import()`** of bundled files
|
|
1739
|
-
*
|
|
1788
|
+
* - **Dynamic `import()`** of bundled files bypasses the transform hook since
|
|
1789
|
+
* those files are loaded through Node.js native loader.
|
|
1740
1790
|
* ## Options
|
|
1741
1791
|
*
|
|
1742
1792
|
* - **`config`** — Path to `tailor.config.ts`. Loads `defineSecretManager()` values
|
|
@@ -1763,5 +1813,5 @@ function tailorRuntime(options) {
|
|
|
1763
1813
|
}
|
|
1764
1814
|
|
|
1765
1815
|
//#endregion
|
|
1766
|
-
export { createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockSecretmanager, mockTailordb, mockWorkflow, runWorkflowLocally, tailorRuntime };
|
|
1816
|
+
export { createKyselyMock, mockAigateway, mockAuthconnection, mockFile, mockIconv, mockIdp, mockLogger, mockSecretmanager, mockTailordb, mockWorkflow, runWorkflowLocally, tailorRuntime };
|
|
1767
1817
|
//# sourceMappingURL=index.mjs.map
|