@tailor-platform/sdk 2.3.0 → 2.5.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 +171 -0
- package/README.md +1 -1
- package/dist/aigateway-DsWDjzk4.mjs +2 -0
- package/dist/{aigateway-DR4Kwuik.mjs.map → aigateway-DsWDjzk4.mjs.map} +1 -1
- package/dist/application-DFOUovmN.mjs +1 -0
- package/dist/application-D_4vg1KR.mjs +192 -0
- package/dist/application-D_4vg1KR.mjs.map +1 -0
- package/dist/assert-WeXvmG4j.mjs +2 -0
- package/dist/{assert-DBxo8jPo.mjs.map → assert-WeXvmG4j.mjs.map} +1 -1
- package/dist/authconnection-CynFBIv8.mjs +2 -0
- package/dist/{authconnection-CZvi9ANm.mjs.map → authconnection-CynFBIv8.mjs.map} +1 -1
- package/dist/brand-C8nMKhJC.mjs +2 -0
- package/dist/{brand-Eo4pLXPJ.mjs.map → brand-C8nMKhJC.mjs.map} +1 -1
- package/dist/cli/commands/deploy/deploy.d.mts +2 -2
- package/dist/cli/commands/deploy/deployment-target.d.mts +2 -0
- package/dist/cli/commands/deploy/event-subscriptions.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/apply.d.mts +3 -0
- package/dist/cli/commands/deploy/tailordb/index.d.mts +3 -10
- package/dist/cli/commands/deploy/tailordb/migration-validation.d.mts +5 -0
- package/dist/cli/commands/deploy/tailordb/plan.d.mts +8 -0
- package/dist/cli/commands/executor/jobs.d.mts +1 -1
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -2
- package/dist/cli/commands/show.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +15 -15
- package/dist/cli/commands/tailordb/migrate/generate.d.mts +7 -3
- package/dist/cli/commands/tailordb/migrate/rename-detection.d.mts +1 -1
- package/dist/cli/commands/tailordb/migrate/snapshot-comparison.d.mts +43 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-files.d.mts +62 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-local.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-migrations.d.mts +12 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-remote.d.mts +1 -0
- package/dist/cli/commands/tailordb/migrate/snapshot-types.d.mts +3 -1
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -117
- package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
- package/dist/cli/lib.d.mts +8 -4
- package/dist/cli/lib.mjs +1 -9
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/main.mjs +1170 -7686
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/shared/seed-chunker.d.mts +5 -5
- package/dist/cli/ts-hook.mjs +3 -1
- package/dist/completion/zsh-worker.zsh +99 -18
- package/dist/configure/config/index.d.mts +2 -2
- package/dist/configure/config/types.d.mts +2 -2
- package/dist/configure/index.d.mts +49 -12
- package/dist/configure/index.mjs +1 -1267
- 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 +3 -3
- package/dist/configure/services/idp/types.d.mts +1 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -1
- package/dist/configure/services/tailordb/schema.d.mts +5 -9
- package/dist/configure/services/tailordb/types.d.mts +8 -5
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/job.d.mts +12 -2
- package/dist/configure/types/auth-namespace-name.d.mts +18 -0
- package/dist/configure/types/field.types.d.mts +1 -1
- package/dist/configure/types/permission-operand.types.d.mts +1 -1
- package/dist/context-D0QjfxzD.mjs +2 -0
- package/dist/{context-DYQVYWqZ.mjs.map → context-D0QjfxzD.mjs.map} +1 -1
- package/dist/crashreport-B-_HTKLr.mjs +42 -0
- package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-B-_HTKLr.mjs.map} +1 -1
- package/dist/crashreport-BmsRIdpy.mjs +1 -0
- package/dist/errors-DSEXKRVD.mjs +2 -0
- package/dist/errors-DSEXKRVD.mjs.map +1 -0
- package/dist/file-COPYfju_.mjs +2 -0
- package/dist/file-COPYfju_.mjs.map +1 -0
- package/dist/globals-CMHSnj4w.mjs +2 -0
- package/dist/{globals-B2nlxBrz.mjs.map → globals-CMHSnj4w.mjs.map} +1 -1
- package/dist/iconv-DlFMt2gW.mjs +2 -0
- package/dist/{iconv-QWaZh0TT.mjs.map → iconv-DlFMt2gW.mjs.map} +1 -1
- package/dist/idp-G_ojPBB5.mjs +2 -0
- package/dist/{idp-RA_swu-h.mjs.map → idp-G_ojPBB5.mjs.map} +1 -1
- package/dist/interceptor-DQg3cR_9.mjs +2 -0
- package/dist/{interceptor-e33JtsC-.mjs.map → interceptor-DQg3cR_9.mjs.map} +1 -1
- package/dist/kysely/index.mjs +1 -31
- package/dist/kysely/index.mjs.map +1 -1
- package/dist/kysely-type-BTi3BMtL.mjs +43 -0
- package/dist/kysely-type-BTi3BMtL.mjs.map +1 -0
- package/dist/logger-BcGy-u7G.mjs +9 -0
- package/dist/{logger-DSdExfor.mjs.map → logger-BcGy-u7G.mjs.map} +1 -1
- package/dist/logger-DP2BjQ93.mjs +2 -0
- package/dist/{logger-BtX0suGY.mjs.map → logger-DP2BjQ93.mjs.map} +1 -1
- package/dist/multiline-EyzjEwn9.mjs +3 -0
- package/dist/{multiline-sfHpTZZK.mjs.map → multiline-EyzjEwn9.mjs.map} +1 -1
- package/dist/node-builtins-oBl7EbyV.mjs +2 -0
- package/dist/{node-builtins-CmaL2Cbq.mjs.map → node-builtins-oBl7EbyV.mjs.map} +1 -1
- package/dist/package-json-C690ceex.mjs +2 -0
- package/dist/{package-json-8b0O9TlX.mjs.map → package-json-C690ceex.mjs.map} +1 -1
- package/dist/package-json-CmqhDJ__.mjs +1 -0
- package/dist/parser/service/tailordb/type-source.d.mts +5 -5
- package/dist/parser/service/tailordb/types.d.mts +4 -4
- package/dist/platform-serialize-DkiTdHOt.mjs +2 -0
- package/dist/{platform-serialize-RoRtBS0v.mjs.map → platform-serialize-DkiTdHOt.mjs.map} +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/enum-constants/index.mjs +5 -114
- 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 +22 -101
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +9 -2
- package/dist/plugin/builtin/kysely-type/index.mjs +1 -275
- package/dist/plugin/builtin/seed/index.d.mts +5 -0
- package/dist/plugin/builtin/seed/index.mjs +1 -3
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -6
- package/dist/plugin/get-generated-table.d.mts +16 -0
- package/dist/plugin/index.d.mts +3 -2
- package/dist/plugin/index.mjs +1 -251
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/types.d.mts +32 -25
- package/dist/plugin/with-context.d.mts +4 -4
- package/dist/register-ts-hook-Drnaproy.mjs +640 -0
- package/dist/register-ts-hook-Drnaproy.mjs.map +1 -0
- package/dist/registry-HlEaGvl5.mjs +2 -0
- package/dist/{registry-BIGVUrMB.mjs.map → registry-HlEaGvl5.mjs.map} +1 -1
- package/dist/repl-editor-BG1aDOfH.mjs +2 -0
- package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-BG1aDOfH.mjs.map} +1 -1
- package/dist/runtime/aigateway.mjs +1 -3
- package/dist/runtime/authconnection.mjs +1 -3
- package/dist/runtime/context.mjs +1 -3
- package/dist/runtime/file.d.mts +28 -28
- package/dist/runtime/file.mjs +1 -3
- package/dist/runtime/globals.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -3
- package/dist/runtime/idp.mjs +1 -3
- package/dist/runtime/index.mjs +1 -11
- package/dist/runtime/logger.mjs +1 -3
- package/dist/runtime/secretmanager.mjs +1 -3
- package/dist/runtime/types.d.mts +1 -1
- package/dist/runtime/workflow.mjs +1 -3
- package/dist/schema-Ze_dI5VX.mjs +2 -0
- package/dist/schema-Ze_dI5VX.mjs.map +1 -0
- package/dist/secret-file-C9wp_FCX.mjs +2 -0
- package/dist/{secret-file-C3J4Gy8r.mjs.map → secret-file-C9wp_FCX.mjs.map} +1 -1
- package/dist/secretmanager-5olfnI1b.mjs +2 -0
- package/dist/{secretmanager-IY4UvinW.mjs.map → secretmanager-5olfnI1b.mjs.map} +1 -1
- package/dist/secretmanager-vHQoXdQz.mjs +2 -0
- package/dist/{secretmanager-CYlpffsz.mjs.map → secretmanager-vHQoXdQz.mjs.map} +1 -1
- package/dist/seed/index.d.mts +4 -4
- package/dist/seed/index.mjs +8 -244
- package/dist/seed/index.mjs.map +1 -1
- package/dist/seed-DwqRFdqP.mjs +207 -0
- package/dist/seed-DwqRFdqP.mjs.map +1 -0
- package/dist/service-BVe9u2Rt.mjs +7 -0
- package/dist/service-BVe9u2Rt.mjs.map +1 -0
- package/dist/service-CpZELSBa.mjs +1 -0
- package/dist/service-DlgaUO4V.mjs +2 -0
- package/dist/{service-hZskxZmg.mjs.map → service-DlgaUO4V.mjs.map} +1 -1
- package/dist/service_pb-DGKCLuAs.mjs +2 -0
- package/dist/{service_pb-BEWj1pOV.mjs.map → service_pb-DGKCLuAs.mjs.map} +1 -1
- package/dist/service_pb-_aeFE-Nv.mjs +1 -0
- package/dist/telemetry-Bklv9kQY.mjs +2 -0
- package/dist/{telemetry-BRVdwh14.mjs.map → telemetry-Bklv9kQY.mjs.map} +1 -1
- package/dist/telemetry-DXHP3VVi.mjs +1 -0
- package/dist/type-source--ZNcV8RJ.mjs +2 -0
- package/dist/type-source--ZNcV8RJ.mjs.map +1 -0
- 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 +2 -2
- package/dist/types/tailordb.generated.d.mts +12 -12
- package/dist/user-agent-vdHYF3QL.mjs +2 -0
- package/dist/{user-agent-Bgsszb5I.mjs.map → user-agent-vdHYF3QL.mjs.map} +1 -1
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +1 -109
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -41
- package/dist/vitest/environment.mjs.map +1 -1
- package/dist/vitest/index.mjs +1 -1980
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mocks/file.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -140
- package/dist/vitest/setup.mjs.map +1 -1
- package/dist/wait-point-invoker-eiP-IIux.mjs +2 -0
- package/dist/wait-point-invoker-eiP-IIux.mjs.map +1 -0
- package/dist/wait-point-registry-BrkwfyjS.mjs +2 -0
- package/dist/{wait-point-registry-TL99zotw.mjs.map → wait-point-registry-BrkwfyjS.mjs.map} +1 -1
- package/dist/workflow-Cs9ISw6j.mjs +2 -0
- package/dist/{workflow-Bamae_Yc.mjs.map → workflow-Cs9ISw6j.mjs.map} +1 -1
- package/dist/workspace_resource_pb--GeYQPXu.mjs +2 -0
- package/dist/{workspace_resource_pb-HNIL_Vfj.mjs.map → workspace_resource_pb--GeYQPXu.mjs.map} +1 -1
- package/docs/cli/application.md +3 -1
- package/docs/cli/function.md +77 -13
- package/docs/cli/setup.md +24 -14
- package/docs/cli/tailordb.md +32 -30
- 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 +10 -9
- package/docs/migration/v2.md +16 -4
- package/docs/migration/v3.md +123 -0
- package/docs/plugin/custom.md +130 -85
- package/docs/plugin/index.md +3 -3
- 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 +68 -54
- package/docs/services/tailordb.md +7 -7
- package/docs/services/workflow.md +10 -9
- package/docs/testing.md +1 -1
- package/package.json +16 -16
- package/postinstall.mjs +1 -1
- package/dist/aigateway-DR4Kwuik.mjs +0 -9
- package/dist/application-BZfk4HKm.mjs +0 -3
- package/dist/application-F-nl107y.mjs +0 -6019
- package/dist/application-F-nl107y.mjs.map +0 -1
- package/dist/assert-DBxo8jPo.mjs +0 -9
- package/dist/authconnection-CZvi9ANm.mjs +0 -9
- package/dist/brand-Eo4pLXPJ.mjs +0 -36
- package/dist/context-DYQVYWqZ.mjs +0 -23
- package/dist/crashreport-CIIfLnoO.mjs +0 -423
- package/dist/crashreport-CINZ5dVN.mjs +0 -3
- package/dist/errors-BVb6vYGy.mjs +0 -89
- package/dist/errors-BVb6vYGy.mjs.map +0 -1
- package/dist/file-BUcmVIH2.mjs +0 -58
- package/dist/file-BUcmVIH2.mjs.map +0 -1
- package/dist/globals-B2nlxBrz.mjs +0 -126
- package/dist/iconv-QWaZh0TT.mjs +0 -38
- package/dist/idp-RA_swu-h.mjs +0 -82
- package/dist/interceptor-e33JtsC-.mjs +0 -33
- package/dist/logger-BtX0suGY.mjs +0 -48
- package/dist/logger-DSdExfor.mjs +0 -358
- package/dist/multiline-sfHpTZZK.mjs +0 -38
- package/dist/node-builtins-CmaL2Cbq.mjs +0 -36
- package/dist/package-json-8b0O9TlX.mjs +0 -17
- package/dist/package-json-Cv2Z-TqQ.mjs +0 -3
- package/dist/platform-serialize-RoRtBS0v.mjs +0 -46
- package/dist/plugin/builtin/kysely-type/index.mjs.map +0 -1
- package/dist/plugin/builtin/seed/types.d.mts +0 -2
- package/dist/plugin/get-generated-type.d.mts +0 -16
- package/dist/register-ts-hook-ClI226n2.mjs +0 -25543
- package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
- package/dist/registry-BIGVUrMB.mjs +0 -54
- package/dist/repl-editor-BCozyiNq.mjs +0 -251
- package/dist/schema--xYWRGfe.mjs +0 -639
- package/dist/schema--xYWRGfe.mjs.map +0 -1
- package/dist/secret-file-C3J4Gy8r.mjs +0 -64
- package/dist/secretmanager-CYlpffsz.mjs +0 -13
- package/dist/secretmanager-IY4UvinW.mjs +0 -131
- package/dist/seed-xqM9WIHP.mjs +0 -483
- package/dist/seed-xqM9WIHP.mjs.map +0 -1
- package/dist/service-C_WpbKHu.mjs +0 -898
- package/dist/service-C_WpbKHu.mjs.map +0 -1
- package/dist/service-D1RCdzIL.mjs +0 -3
- package/dist/service-hZskxZmg.mjs +0 -131
- package/dist/service_pb-BEWj1pOV.mjs +0 -167
- package/dist/service_pb-BjlhvK9E.mjs +0 -3
- package/dist/telemetry-BRVdwh14.mjs +0 -84
- package/dist/telemetry-CkbkeJxl.mjs +0 -3
- package/dist/type-source-DH_LH20p.mjs +0 -13
- package/dist/type-source-DH_LH20p.mjs.map +0 -1
- package/dist/user-agent-Bgsszb5I.mjs +0 -28
- package/dist/wait-point-invoker-__oE88_P.mjs +0 -148
- package/dist/wait-point-invoker-__oE88_P.mjs.map +0 -1
- package/dist/wait-point-registry-TL99zotw.mjs +0 -47
- package/dist/workflow-Bamae_Yc.mjs +0 -34
- package/dist/workspace_resource_pb-HNIL_Vfj.mjs +0 -860
|
@@ -1,898 +0,0 @@
|
|
|
1
|
-
import { n as isSdkBranded } from "./brand-Eo4pLXPJ.mjs";
|
|
2
|
-
import { n as logger, r as styles } from "./logger-DSdExfor.mjs";
|
|
3
|
-
import * as path from "pathe";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
7
|
-
|
|
8
|
-
//#region src/parser/service/common.ts
|
|
9
|
-
const functionSchema = z.custom((val) => typeof val === "function");
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/cli/shared/user-modules.ts
|
|
13
|
-
const IMPORT_NONCE_PARAM = "tailorImportNonce";
|
|
14
|
-
let runCounter = 0;
|
|
15
|
-
/**
|
|
16
|
-
* Start a fresh user-module run. Modules imported through
|
|
17
|
-
* {@link importUserModule} after this call bypass the ESM cache entries of
|
|
18
|
-
* earlier runs, so a repeated in-process run re-evaluates user code instead
|
|
19
|
-
* of reusing stale modules.
|
|
20
|
-
*/
|
|
21
|
-
function beginUserModuleRun() {
|
|
22
|
-
runCounter += 1;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Read the cache-busting nonce of the current user-module run.
|
|
26
|
-
* @returns The nonce, or undefined when no run was started
|
|
27
|
-
*/
|
|
28
|
-
function currentImportNonce() {
|
|
29
|
-
return runCounter === 0 ? void 0 : String(runCounter);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Import a user module (config, workflow, resolver, executor, ...) with the
|
|
33
|
-
* current run's cache-busting nonce applied. Outside a run this is a plain
|
|
34
|
-
* import.
|
|
35
|
-
* @param filePath - Absolute path of the user module
|
|
36
|
-
* @returns The imported module namespace
|
|
37
|
-
*/
|
|
38
|
-
function importUserModule(filePath) {
|
|
39
|
-
const url = pathToFileURL(filePath);
|
|
40
|
-
const nonce = currentImportNonce();
|
|
41
|
-
if (nonce) url.searchParams.set(IMPORT_NONCE_PARAM, nonce);
|
|
42
|
-
return import(url.href);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
//#region src/cli/services/file-loader.ts
|
|
47
|
-
const DEFAULT_IGNORE_PATTERNS = ["**/*.test.ts", "**/*.spec.ts"];
|
|
48
|
-
const warnedFallbacks = /* @__PURE__ */ new Set();
|
|
49
|
-
/**
|
|
50
|
-
* Load files matching the given patterns, excluding files that match ignore patterns.
|
|
51
|
-
* By default, test files (*.test.ts, *.spec.ts) are excluded unless ignores is explicitly specified.
|
|
52
|
-
* @param config - Configuration with files patterns and optional ignores patterns
|
|
53
|
-
* @param baseDir - Directory relative patterns are resolved against
|
|
54
|
-
* @returns Array of absolute file paths
|
|
55
|
-
*/
|
|
56
|
-
function loadFilesWithIgnores(config, baseDir) {
|
|
57
|
-
if (config.files.length === 0) return [];
|
|
58
|
-
const resolved = resolveFiles(config, baseDir);
|
|
59
|
-
const allPatternsAbsolute = config.files.every((pattern) => path.isAbsolute(pattern));
|
|
60
|
-
if (resolved.matchedAnyPattern || baseDir === process.cwd() || allPatternsAbsolute) return resolved.files;
|
|
61
|
-
const fallbackKey = `${baseDir}\0${config.files.join("\0")}`;
|
|
62
|
-
if (!warnedFallbacks.has(fallbackKey)) {
|
|
63
|
-
warnedFallbacks.add(fallbackKey);
|
|
64
|
-
logger.warn(`No files matched "${config.files.join(", ")}" relative to "${baseDir}"; falling back to process.cwd(). Update this config's file patterns to be relative to its own directory before v2, when this fallback will be removed.`);
|
|
65
|
-
}
|
|
66
|
-
return resolveFiles(config, process.cwd()).files;
|
|
67
|
-
}
|
|
68
|
-
function resolveFiles(config, baseDir) {
|
|
69
|
-
const isDefaultIgnores = config.ignores === void 0;
|
|
70
|
-
const ignorePatterns = config.ignores ?? DEFAULT_IGNORE_PATTERNS;
|
|
71
|
-
const resolvedIgnorePatterns = isDefaultIgnores ? ignorePatterns : ignorePatterns.map((ignorePattern) => path.resolve(baseDir, ignorePattern));
|
|
72
|
-
const files = [];
|
|
73
|
-
let matchedAnyPattern = false;
|
|
74
|
-
for (const pattern of config.files) {
|
|
75
|
-
const absolutePattern = path.resolve(baseDir, pattern);
|
|
76
|
-
try {
|
|
77
|
-
const matchedFiles = fs.globSync(absolutePattern);
|
|
78
|
-
if (matchedFiles.length > 0) matchedAnyPattern = true;
|
|
79
|
-
const filteredFiles = matchedFiles.filter((file) => !resolvedIgnorePatterns.some((ignorePattern) => path.matchesGlob(file, ignorePattern)));
|
|
80
|
-
files.push(...filteredFiles);
|
|
81
|
-
} catch (error) {
|
|
82
|
-
matchedAnyPattern = true;
|
|
83
|
-
logger.warn(`Failed to glob pattern "${pattern}": ${String(error)}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return {
|
|
87
|
-
files,
|
|
88
|
-
matchedAnyPattern
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
//#endregion
|
|
93
|
-
//#region src/parser/service/tailordb/relation.ts
|
|
94
|
-
const relationTypes = {
|
|
95
|
-
"1-1": "1-1",
|
|
96
|
-
oneToOne: "1-1",
|
|
97
|
-
"n-1": "n-1",
|
|
98
|
-
manyToOne: "n-1",
|
|
99
|
-
"N-1": "n-1",
|
|
100
|
-
keyOnly: "keyOnly"
|
|
101
|
-
};
|
|
102
|
-
const relationTypesKeys = Object.keys(relationTypes);
|
|
103
|
-
function fieldRef(context) {
|
|
104
|
-
return `Field "${context.fieldName}" on type "${context.typeName}"`;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Validate relation configuration.
|
|
108
|
-
* @param rawRelation - Raw relation configuration from TailorDB type definition
|
|
109
|
-
* @param context - Context information for the relation (type name, field name, all type names)
|
|
110
|
-
*/
|
|
111
|
-
function validateRelationConfig(rawRelation, context) {
|
|
112
|
-
if (!rawRelation.type) throw new Error(`${fieldRef(context)} has a relation but is missing the required 'type' property. Valid values: ${relationTypesKeys.join(", ")}.`);
|
|
113
|
-
if (!(rawRelation.type in relationTypes)) throw new Error(`${fieldRef(context)} has invalid relation type '${rawRelation.type}'. Valid values: ${relationTypesKeys.join(", ")}.`);
|
|
114
|
-
if (rawRelation.toward.type !== "self" && !context.allTypeNames.has(rawRelation.toward.type)) throw new Error(`${fieldRef(context)} references unknown type "${rawRelation.toward.type}".`);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Process raw relation config and compute derived metadata values.
|
|
118
|
-
* @param rawRelation - Raw relation configuration
|
|
119
|
-
* @param context - Context information for the relation
|
|
120
|
-
* @param isArrayField - Whether the target field is an array field
|
|
121
|
-
* @returns Computed relation metadata to apply to field config
|
|
122
|
-
*/
|
|
123
|
-
function processRelationMetadata(rawRelation, context, isArrayField = false) {
|
|
124
|
-
const isUnique = relationTypes[rawRelation.type] === "1-1";
|
|
125
|
-
const key = rawRelation.toward.key ?? "id";
|
|
126
|
-
const targetTypeName = rawRelation.toward.type === "self" ? context.typeName : rawRelation.toward.type;
|
|
127
|
-
const shouldSetIndex = !isArrayField;
|
|
128
|
-
const shouldSetUnique = !isArrayField && isUnique;
|
|
129
|
-
return {
|
|
130
|
-
index: shouldSetIndex,
|
|
131
|
-
foreignKey: true,
|
|
132
|
-
relationType: rawRelation.type,
|
|
133
|
-
unique: shouldSetUnique,
|
|
134
|
-
foreignKeyType: targetTypeName,
|
|
135
|
-
foreignKeyField: key
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Build relation info for creating forward/backward relationships.
|
|
140
|
-
* Returns undefined for keyOnly relations.
|
|
141
|
-
* @param rawRelation - Raw relation configuration
|
|
142
|
-
* @param context - Context information for the relation
|
|
143
|
-
* @returns Relation information or undefined for keyOnly relations
|
|
144
|
-
*/
|
|
145
|
-
function buildRelationInfo(rawRelation, context) {
|
|
146
|
-
if (rawRelation.type === "keyOnly") return;
|
|
147
|
-
const isUnique = relationTypes[rawRelation.type] === "1-1";
|
|
148
|
-
const key = rawRelation.toward.key ?? "id";
|
|
149
|
-
const targetTypeName = rawRelation.toward.type === "self" ? context.typeName : rawRelation.toward.type;
|
|
150
|
-
let forwardName = rawRelation.toward.as;
|
|
151
|
-
if (!forwardName) forwardName = context.fieldName.replace(/(ID|Id|id)$/u, "");
|
|
152
|
-
return {
|
|
153
|
-
targetType: targetTypeName,
|
|
154
|
-
forwardName,
|
|
155
|
-
backwardName: rawRelation.backward ?? "",
|
|
156
|
-
key,
|
|
157
|
-
unique: isUnique
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Apply processed relation metadata to field config.
|
|
162
|
-
* @param fieldConfig - Original operator field configuration
|
|
163
|
-
* @param metadata - Processed relation metadata to apply
|
|
164
|
-
* @returns Field config with relation metadata applied
|
|
165
|
-
*/
|
|
166
|
-
function applyRelationMetadataToFieldConfig(fieldConfig, metadata) {
|
|
167
|
-
return {
|
|
168
|
-
...fieldConfig,
|
|
169
|
-
index: metadata.index,
|
|
170
|
-
foreignKey: metadata.foreignKey,
|
|
171
|
-
unique: metadata.unique,
|
|
172
|
-
foreignKeyType: metadata.foreignKeyType,
|
|
173
|
-
foreignKeyField: metadata.foreignKeyField
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region src/parser/service/tailordb/schema.ts
|
|
179
|
-
/**
|
|
180
|
-
* Normalize GqlOperationsConfig (alias or object) to GqlOperations object.
|
|
181
|
-
* "query" alias expands to read-only mode: { create: false, update: false, delete: false, read: true }
|
|
182
|
-
* @param config - The config to normalize
|
|
183
|
-
* @returns The normalized GqlOperations object
|
|
184
|
-
*/
|
|
185
|
-
function normalizeGqlOperations(config) {
|
|
186
|
-
if (config === "query") return {
|
|
187
|
-
create: false,
|
|
188
|
-
update: false,
|
|
189
|
-
delete: false,
|
|
190
|
-
read: true
|
|
191
|
-
};
|
|
192
|
-
return config;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Zod schema for GqlOperations configuration with normalization transform.
|
|
196
|
-
* Accepts "query" alias or detailed object, normalizes to GqlOperations object.
|
|
197
|
-
*/
|
|
198
|
-
const GqlOperationsSchema = z.union([z.literal("query"), z.strictObject({
|
|
199
|
-
create: z.boolean().optional().describe("Enable create mutation (default: true)"),
|
|
200
|
-
update: z.boolean().optional().describe("Enable update mutation (default: true)"),
|
|
201
|
-
delete: z.boolean().optional().describe("Enable delete mutation (default: true)"),
|
|
202
|
-
read: z.boolean().optional().describe("Enable read queries - get, list, aggregation (default: true)")
|
|
203
|
-
})]).describe("Configuration for GraphQL operations on a TailorDB type.\nAll operations are enabled by default (undefined or true = enabled, false = disabled).").transform((val) => normalizeGqlOperations(val));
|
|
204
|
-
const TailorFieldTypeSchema$1 = z.enum([
|
|
205
|
-
"uuid",
|
|
206
|
-
"string",
|
|
207
|
-
"boolean",
|
|
208
|
-
"integer",
|
|
209
|
-
"float",
|
|
210
|
-
"decimal",
|
|
211
|
-
"enum",
|
|
212
|
-
"date",
|
|
213
|
-
"datetime",
|
|
214
|
-
"time",
|
|
215
|
-
"nested"
|
|
216
|
-
]);
|
|
217
|
-
const AllowedValueSchema$1 = z.strictObject({
|
|
218
|
-
value: z.string(),
|
|
219
|
-
description: z.string().optional()
|
|
220
|
-
});
|
|
221
|
-
const DBFieldMetadataSchema = z.strictObject({
|
|
222
|
-
required: z.boolean().optional().describe("Whether the field is required"),
|
|
223
|
-
array: z.boolean().optional().describe("Whether the field is an array"),
|
|
224
|
-
description: z.string().optional().describe("Field description"),
|
|
225
|
-
typeName: z.string().optional().describe("Type name for nested or enum fields"),
|
|
226
|
-
allowedValues: z.array(AllowedValueSchema$1).optional().describe("Allowed values for enum fields"),
|
|
227
|
-
index: z.boolean().optional().describe("Whether the field is indexed for faster queries"),
|
|
228
|
-
unique: z.boolean().optional().describe("Whether the field value must be unique"),
|
|
229
|
-
vector: z.boolean().optional().describe("Whether the field is a vector field for similarity search"),
|
|
230
|
-
foreignKey: z.boolean().optional().describe("Whether the field is a foreign key"),
|
|
231
|
-
foreignKeyType: z.string().optional().describe("Target type name for foreign key relations"),
|
|
232
|
-
foreignKeyField: z.string().optional().describe("Target field name for foreign key relations"),
|
|
233
|
-
hooks: z.strictObject({
|
|
234
|
-
create: functionSchema.optional().describe("Hook function called on record creation"),
|
|
235
|
-
update: functionSchema.optional().describe("Hook function called on record update")
|
|
236
|
-
}).optional().describe("Lifecycle hooks for the field"),
|
|
237
|
-
validate: z.array(functionSchema).optional().describe("Validation functions for the field"),
|
|
238
|
-
serial: z.strictObject({
|
|
239
|
-
start: z.number().describe("Starting value for the serial sequence"),
|
|
240
|
-
maxValue: z.number().optional().describe("Maximum value for the serial sequence"),
|
|
241
|
-
format: z.string().optional().describe("Format string for serial value (string type only)")
|
|
242
|
-
}).optional().describe("Serial (auto-increment) configuration"),
|
|
243
|
-
scale: z.number().int().min(0).max(12).optional().describe("Decimal scale (number of digits after decimal point, 0-12)"),
|
|
244
|
-
default: z.unknown().optional().describe("Default value for the field on create")
|
|
245
|
-
});
|
|
246
|
-
const RelationTypeSchema = z.enum(relationTypesKeys);
|
|
247
|
-
const RawRelationConfigSchema = z.strictObject({
|
|
248
|
-
type: RelationTypeSchema.describe("Relation cardinality type"),
|
|
249
|
-
toward: z.strictObject({
|
|
250
|
-
type: z.string().describe("Target type name, or 'self' for self-relations"),
|
|
251
|
-
as: z.string().optional().describe("Custom forward relation name"),
|
|
252
|
-
key: z.string().optional().describe("Target field to join on (default: 'id')")
|
|
253
|
-
}),
|
|
254
|
-
backward: z.string().optional().describe("Backward relation name on the target type")
|
|
255
|
-
});
|
|
256
|
-
const TailorDBFieldSchema = z.lazy(() => z.object({
|
|
257
|
-
type: TailorFieldTypeSchema$1,
|
|
258
|
-
fields: z.record(z.string(), TailorDBFieldSchema).optional(),
|
|
259
|
-
metadata: DBFieldMetadataSchema,
|
|
260
|
-
rawRelation: RawRelationConfigSchema.optional()
|
|
261
|
-
}));
|
|
262
|
-
/**
|
|
263
|
-
* Schema for TailorDB type settings.
|
|
264
|
-
* Normalizes gqlOperations from alias ("query") to object format.
|
|
265
|
-
*/
|
|
266
|
-
const TailorDBTypeSettingsSchema = z.strictObject({
|
|
267
|
-
pluralForm: z.string().optional().describe("Custom plural form of the type name for GraphQL"),
|
|
268
|
-
aggregation: z.boolean().optional().describe("Enable aggregation queries for this type"),
|
|
269
|
-
bulkUpsert: z.boolean().optional().describe("Enable bulk upsert mutation for this type"),
|
|
270
|
-
gqlOperations: GqlOperationsSchema.optional().describe("Configure GraphQL operations for this type. Use \"query\" for read-only mode, or an object for granular control."),
|
|
271
|
-
publishEvents: z.boolean().optional().describe("Enable publishing events for this type.\nWhen enabled, record creation/update/deletion events are published.\nIf not specified, this is automatically set to true when an executor uses this type\nwith recordCreated/recordUpdated/recordDeleted triggers. If explicitly set to false\nwhile an executor uses this type, an error will be thrown during apply.")
|
|
272
|
-
});
|
|
273
|
-
const GQL_PERMISSION_INVALID_OPERAND_MESSAGE = "operand is not supported in gqlPermission. Use permission() for record-level conditions.";
|
|
274
|
-
const GqlPermissionOperandSchema = z.union([
|
|
275
|
-
z.strictObject({ user: z.string() }),
|
|
276
|
-
z.string(),
|
|
277
|
-
z.boolean(),
|
|
278
|
-
z.array(z.string()),
|
|
279
|
-
z.array(z.boolean())
|
|
280
|
-
], { error: (issue) => {
|
|
281
|
-
if (typeof issue.input === "object" && issue.input !== null) {
|
|
282
|
-
const keys = Object.keys(issue.input);
|
|
283
|
-
if (keys.length === 1) return `"${keys[0]}" ${GQL_PERMISSION_INVALID_OPERAND_MESSAGE}`;
|
|
284
|
-
return "Operand object must have exactly 1 key";
|
|
285
|
-
}
|
|
286
|
-
return "Invalid operand in gqlPermission";
|
|
287
|
-
} });
|
|
288
|
-
const RecordPermissionOperandSchema = z.union([
|
|
289
|
-
GqlPermissionOperandSchema,
|
|
290
|
-
z.strictObject({ record: z.string() }),
|
|
291
|
-
z.strictObject({ oldRecord: z.string() }),
|
|
292
|
-
z.strictObject({ newRecord: z.string() })
|
|
293
|
-
]);
|
|
294
|
-
const PermissionOperatorSchema = z.enum([
|
|
295
|
-
"=",
|
|
296
|
-
"!=",
|
|
297
|
-
"in",
|
|
298
|
-
"not in",
|
|
299
|
-
"hasAny",
|
|
300
|
-
"not hasAny"
|
|
301
|
-
]);
|
|
302
|
-
const RecordPermissionConditionSchema = z.tuple([
|
|
303
|
-
RecordPermissionOperandSchema,
|
|
304
|
-
PermissionOperatorSchema,
|
|
305
|
-
RecordPermissionOperandSchema
|
|
306
|
-
]).readonly();
|
|
307
|
-
const GqlPermissionConditionSchema = z.tuple([
|
|
308
|
-
GqlPermissionOperandSchema,
|
|
309
|
-
PermissionOperatorSchema,
|
|
310
|
-
GqlPermissionOperandSchema
|
|
311
|
-
]).readonly();
|
|
312
|
-
const ActionPermissionSchema = z.union([
|
|
313
|
-
z.strictObject({
|
|
314
|
-
conditions: z.union([RecordPermissionConditionSchema, z.array(RecordPermissionConditionSchema).readonly()]),
|
|
315
|
-
description: z.string().optional(),
|
|
316
|
-
permit: z.boolean().optional()
|
|
317
|
-
}),
|
|
318
|
-
z.tuple([
|
|
319
|
-
RecordPermissionOperandSchema,
|
|
320
|
-
PermissionOperatorSchema,
|
|
321
|
-
RecordPermissionOperandSchema
|
|
322
|
-
]).readonly(),
|
|
323
|
-
z.tuple([
|
|
324
|
-
RecordPermissionOperandSchema,
|
|
325
|
-
PermissionOperatorSchema,
|
|
326
|
-
RecordPermissionOperandSchema,
|
|
327
|
-
z.boolean()
|
|
328
|
-
]).readonly(),
|
|
329
|
-
z.array(z.union([RecordPermissionConditionSchema, z.boolean()])).refine((arr) => {
|
|
330
|
-
const boolIndex = arr.findIndex((item) => typeof item === "boolean");
|
|
331
|
-
return boolIndex === -1 || boolIndex === arr.length - 1;
|
|
332
|
-
}, { message: "Boolean permit flag must only appear at the end" }).readonly()
|
|
333
|
-
]);
|
|
334
|
-
const GqlPermissionActionSchema = z.enum([
|
|
335
|
-
"read",
|
|
336
|
-
"create",
|
|
337
|
-
"update",
|
|
338
|
-
"delete",
|
|
339
|
-
"aggregate",
|
|
340
|
-
"bulkUpsert"
|
|
341
|
-
]);
|
|
342
|
-
const GqlPermissionPolicySchema = z.strictObject({
|
|
343
|
-
conditions: z.array(GqlPermissionConditionSchema).readonly(),
|
|
344
|
-
actions: z.union([z.literal("all"), z.array(GqlPermissionActionSchema).readonly()]),
|
|
345
|
-
permit: z.boolean().optional(),
|
|
346
|
-
description: z.string().optional()
|
|
347
|
-
});
|
|
348
|
-
const RawPermissionsSchema = z.strictObject({
|
|
349
|
-
record: z.strictObject({
|
|
350
|
-
create: z.array(ActionPermissionSchema).readonly(),
|
|
351
|
-
read: z.array(ActionPermissionSchema).readonly(),
|
|
352
|
-
update: z.array(ActionPermissionSchema).readonly(),
|
|
353
|
-
delete: z.array(ActionPermissionSchema).readonly()
|
|
354
|
-
}).optional(),
|
|
355
|
-
gql: z.array(GqlPermissionPolicySchema).readonly().optional()
|
|
356
|
-
});
|
|
357
|
-
const TailorDBTypeSchema = z.strictObject({
|
|
358
|
-
name: z.string(),
|
|
359
|
-
fields: z.record(z.string(), TailorDBFieldSchema),
|
|
360
|
-
metadata: z.object({
|
|
361
|
-
name: z.string(),
|
|
362
|
-
description: z.string().optional(),
|
|
363
|
-
settings: TailorDBTypeSettingsSchema.optional(),
|
|
364
|
-
permissions: RawPermissionsSchema,
|
|
365
|
-
files: z.record(z.string(), z.string()),
|
|
366
|
-
indexes: z.record(z.string(), z.strictObject({
|
|
367
|
-
fields: z.array(z.string()),
|
|
368
|
-
unique: z.boolean().optional()
|
|
369
|
-
})).optional(),
|
|
370
|
-
typeHook: z.strictObject({
|
|
371
|
-
create: functionSchema.optional(),
|
|
372
|
-
update: functionSchema.optional()
|
|
373
|
-
}).optional(),
|
|
374
|
-
typeValidate: functionSchema.optional()
|
|
375
|
-
}).strict()
|
|
376
|
-
});
|
|
377
|
-
const TailorDBMigrationConfigSchema = z.strictObject({
|
|
378
|
-
directory: z.string().describe("Directory containing migration files"),
|
|
379
|
-
machineUser: z.string().optional().describe("Machine user name for migration execution")
|
|
380
|
-
});
|
|
381
|
-
/**
|
|
382
|
-
* Schema for TailorDB service configuration.
|
|
383
|
-
* Normalizes gqlOperations from alias ("query") to object format.
|
|
384
|
-
*/
|
|
385
|
-
const TailorDBServiceConfigSchema = z.strictObject({
|
|
386
|
-
files: z.array(z.string()).describe("Glob patterns for TailorDB type definition files"),
|
|
387
|
-
ignores: z.array(z.string()).optional().describe("Glob patterns to exclude from type discovery"),
|
|
388
|
-
migration: TailorDBMigrationConfigSchema.optional().describe("Migration configuration"),
|
|
389
|
-
gqlOperations: GqlOperationsSchema.optional().describe("Default GraphQL operations for all types in this service")
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
//#endregion
|
|
393
|
-
//#region src/parser/service/tailordb/builder-helpers.ts
|
|
394
|
-
const TAILORDB_TYPE_SCHEMA_KEYS = TailorDBTypeSchema.keyof().options;
|
|
395
|
-
function stripTailorDBTypeBuilderHelpers(type) {
|
|
396
|
-
if (!isSdkBranded(type, "tailordb-type")) return type;
|
|
397
|
-
const config = {};
|
|
398
|
-
const input = type;
|
|
399
|
-
for (const key of TAILORDB_TYPE_SCHEMA_KEYS) if (Object.prototype.hasOwnProperty.call(input, key)) config[key] = input[key];
|
|
400
|
-
return config;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
//#endregion
|
|
404
|
-
//#region src/parser/service/auth-connection/schema.ts
|
|
405
|
-
const AuthConnectionOAuth2ConfigSchema = z.strictObject({
|
|
406
|
-
providerUrl: z.string().describe("OAuth2 provider URL"),
|
|
407
|
-
issuerUrl: z.string().describe("OAuth2 issuer URL"),
|
|
408
|
-
clientId: z.string().describe("OAuth2 client ID"),
|
|
409
|
-
clientSecret: z.string().describe("OAuth2 client secret"),
|
|
410
|
-
authUrl: z.string().optional().describe("OAuth2 authorization endpoint override"),
|
|
411
|
-
tokenUrl: z.string().optional().describe("OAuth2 token endpoint override")
|
|
412
|
-
});
|
|
413
|
-
const AuthConnectionConfigSchema = AuthConnectionOAuth2ConfigSchema.extend({ type: z.literal("oauth2").describe("Connection type") });
|
|
414
|
-
|
|
415
|
-
//#endregion
|
|
416
|
-
//#region src/parser/service/field/schema.ts
|
|
417
|
-
const TailorFieldTypeSchema = z.enum([
|
|
418
|
-
"uuid",
|
|
419
|
-
"string",
|
|
420
|
-
"boolean",
|
|
421
|
-
"integer",
|
|
422
|
-
"float",
|
|
423
|
-
"decimal",
|
|
424
|
-
"enum",
|
|
425
|
-
"date",
|
|
426
|
-
"datetime",
|
|
427
|
-
"time",
|
|
428
|
-
"nested"
|
|
429
|
-
]);
|
|
430
|
-
const AllowedValueSchema = z.strictObject({
|
|
431
|
-
value: z.string().describe("The allowed value"),
|
|
432
|
-
description: z.string().optional().describe("Description of the allowed value")
|
|
433
|
-
});
|
|
434
|
-
const FieldMetadataSchema = z.strictObject({
|
|
435
|
-
required: z.boolean().optional().describe("Whether the field is required"),
|
|
436
|
-
array: z.boolean().optional().describe("Whether the field is an array"),
|
|
437
|
-
description: z.string().optional().describe("Field description"),
|
|
438
|
-
allowedValues: z.array(AllowedValueSchema).optional().describe("Allowed values for enum fields"),
|
|
439
|
-
hooks: z.strictObject({
|
|
440
|
-
create: functionSchema.optional().describe("Hook function called on creation"),
|
|
441
|
-
update: functionSchema.optional().describe("Hook function called on update")
|
|
442
|
-
}).optional().describe("Lifecycle hooks"),
|
|
443
|
-
validate: z.array(functionSchema).optional().describe("Validation functions for the field"),
|
|
444
|
-
typeName: z.string().optional().describe("Type name for nested or enum fields"),
|
|
445
|
-
default: z.unknown().optional().describe("Default value for the field on create")
|
|
446
|
-
});
|
|
447
|
-
const TailorFieldSchema = z.object({
|
|
448
|
-
type: TailorFieldTypeSchema.describe("Field data type"),
|
|
449
|
-
metadata: FieldMetadataSchema.describe("Field metadata configuration"),
|
|
450
|
-
get fields() {
|
|
451
|
-
return z.record(z.string(), TailorFieldSchema);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/parser/service/auth/schema.ts
|
|
457
|
-
const AuthInvokerObjectSchema = z.strictObject({
|
|
458
|
-
namespace: z.string().describe("Auth namespace"),
|
|
459
|
-
machineUserName: z.string().describe("Machine user name for authentication")
|
|
460
|
-
});
|
|
461
|
-
const AuthInvokerSchema = z.union([z.string().describe("Machine user name (namespace auto-resolved from auth service)"), AuthInvokerObjectSchema]);
|
|
462
|
-
const secretValueSchema = z.strictObject({
|
|
463
|
-
vaultName: z.string().describe("Vault name containing the secret"),
|
|
464
|
-
secretKey: z.string().describe("Key of the secret in the vault")
|
|
465
|
-
});
|
|
466
|
-
const OIDCSchema = z.strictObject({
|
|
467
|
-
name: z.string().describe("Identity provider name"),
|
|
468
|
-
kind: z.literal("OIDC"),
|
|
469
|
-
clientID: z.string().describe("OAuth2 client ID"),
|
|
470
|
-
clientSecret: secretValueSchema.describe("OAuth2 client secret"),
|
|
471
|
-
providerURL: z.string().describe("OIDC provider URL"),
|
|
472
|
-
issuerURL: z.string().optional().describe("OIDC issuer URL (defaults to providerURL)"),
|
|
473
|
-
usernameClaim: z.string().optional().describe("JWT claim to use as username")
|
|
474
|
-
});
|
|
475
|
-
const SAMLSchema = z.strictObject({
|
|
476
|
-
name: z.string().describe("Identity provider name"),
|
|
477
|
-
kind: z.literal("SAML"),
|
|
478
|
-
enableSignRequest: z.boolean().default(false).describe("Enable signing of SAML requests"),
|
|
479
|
-
metadataURL: z.string().optional().describe("URL to fetch SAML metadata (mutually exclusive with rawMetadata)"),
|
|
480
|
-
rawMetadata: z.string().optional().describe("Raw SAML metadata XML (mutually exclusive with metadataURL)"),
|
|
481
|
-
defaultRedirectURL: z.string().optional().describe("URL to redirect to when SAML ACS receives a response with an empty RelayState.")
|
|
482
|
-
}).refine((value) => {
|
|
483
|
-
return value.metadataURL !== void 0 !== (value.rawMetadata !== void 0);
|
|
484
|
-
}, "Provide either metadataURL or rawMetadata");
|
|
485
|
-
const IDTokenSchema = z.strictObject({
|
|
486
|
-
name: z.string().describe("Identity provider name"),
|
|
487
|
-
kind: z.literal("IDToken"),
|
|
488
|
-
providerURL: z.string().describe("ID token provider URL"),
|
|
489
|
-
issuerURL: z.string().optional().describe("ID token issuer URL"),
|
|
490
|
-
clientID: z.string().describe("Client ID for ID token validation"),
|
|
491
|
-
usernameClaim: z.string().optional().describe("JWT claim to use as username")
|
|
492
|
-
});
|
|
493
|
-
const BuiltinIdPSchema = z.strictObject({
|
|
494
|
-
name: z.string().describe("Identity provider name"),
|
|
495
|
-
kind: z.literal("BuiltInIdP"),
|
|
496
|
-
namespace: z.string().describe("IdP namespace"),
|
|
497
|
-
clientName: z.string().describe("OAuth2 client name in the IdP")
|
|
498
|
-
});
|
|
499
|
-
const IdProviderSchema = z.discriminatedUnion("kind", [
|
|
500
|
-
OIDCSchema,
|
|
501
|
-
SAMLSchema,
|
|
502
|
-
IDTokenSchema,
|
|
503
|
-
BuiltinIdPSchema
|
|
504
|
-
]);
|
|
505
|
-
const OAuth2ClientGrantTypeSchema = z.union([z.literal("authorization_code"), z.literal("refresh_token")]).describe("OAuth2 grant type");
|
|
506
|
-
const OAuth2ClientSchema = z.strictObject({
|
|
507
|
-
description: z.string().optional().describe("Client description"),
|
|
508
|
-
grantTypes: z.array(OAuth2ClientGrantTypeSchema).default(["authorization_code", "refresh_token"]).describe("Allowed OAuth2 grant types"),
|
|
509
|
-
redirectURIs: z.array(z.union([
|
|
510
|
-
z.templateLiteral(["https://", z.string()]),
|
|
511
|
-
z.templateLiteral(["http://", z.string()]),
|
|
512
|
-
z.templateLiteral([z.string(), ":url"]),
|
|
513
|
-
z.templateLiteral([
|
|
514
|
-
z.string(),
|
|
515
|
-
":url/",
|
|
516
|
-
z.string()
|
|
517
|
-
])
|
|
518
|
-
])).describe("Allowed redirect URIs"),
|
|
519
|
-
clientType: z.union([
|
|
520
|
-
z.literal("confidential"),
|
|
521
|
-
z.literal("public"),
|
|
522
|
-
z.literal("browser")
|
|
523
|
-
]).optional().describe("OAuth2 client type"),
|
|
524
|
-
accessTokenLifetimeSeconds: z.number().int().min(60, "Minimum access token lifetime is 60 seconds").max(86400, "Maximum access token lifetime is 1 day (86400 seconds)").optional().describe("Access token lifetime in seconds (60-86400)").transform((val) => val ? {
|
|
525
|
-
seconds: BigInt(val),
|
|
526
|
-
nanos: 0
|
|
527
|
-
} : void 0),
|
|
528
|
-
refreshTokenLifetimeSeconds: z.number().int().min(60, "Minimum refresh token lifetime is 60 seconds").max(604800, "Maximum refresh token lifetime is 7 days (604800 seconds)").optional().describe("Refresh token lifetime in seconds (60-604800)").transform((val) => val ? {
|
|
529
|
-
seconds: BigInt(val),
|
|
530
|
-
nanos: 0
|
|
531
|
-
} : void 0),
|
|
532
|
-
requireDpop: z.boolean().optional().describe("Require DPoP (Demonstrating Proof-of-Possession) for token requests")
|
|
533
|
-
}).refine((data) => !(data.clientType === "browser" && data.requireDpop === true), {
|
|
534
|
-
message: "requireDpop cannot be set to true for browser clients as they don't support DPoP",
|
|
535
|
-
path: ["requireDpop"]
|
|
536
|
-
});
|
|
537
|
-
const SCIMAuthorizationSchema = z.strictObject({
|
|
538
|
-
type: z.union([z.literal("oauth2"), z.literal("bearer")]).describe("SCIM authorization type"),
|
|
539
|
-
bearerSecret: secretValueSchema.optional().describe("Bearer token secret (required for bearer type)")
|
|
540
|
-
});
|
|
541
|
-
const SCIMAttributeTypeSchema = z.union([
|
|
542
|
-
z.literal("string"),
|
|
543
|
-
z.literal("number"),
|
|
544
|
-
z.literal("boolean"),
|
|
545
|
-
z.literal("datetime"),
|
|
546
|
-
z.literal("complex")
|
|
547
|
-
]).describe("SCIM attribute data type");
|
|
548
|
-
const SCIMAttributeSchema = z.strictObject({
|
|
549
|
-
type: SCIMAttributeTypeSchema.describe("Attribute data type"),
|
|
550
|
-
name: z.string().describe("Attribute name"),
|
|
551
|
-
description: z.string().optional().describe("Attribute description"),
|
|
552
|
-
mutability: z.union([
|
|
553
|
-
z.literal("readOnly"),
|
|
554
|
-
z.literal("readWrite"),
|
|
555
|
-
z.literal("writeOnly")
|
|
556
|
-
]).optional().describe("Attribute mutability"),
|
|
557
|
-
required: z.boolean().optional().describe("Whether the attribute is required"),
|
|
558
|
-
multiValued: z.boolean().optional().describe("Whether the attribute can have multiple values"),
|
|
559
|
-
uniqueness: z.union([
|
|
560
|
-
z.literal("none"),
|
|
561
|
-
z.literal("server"),
|
|
562
|
-
z.literal("global")
|
|
563
|
-
]).optional().describe("Uniqueness constraint"),
|
|
564
|
-
canonicalValues: z.array(z.string()).nullable().optional().describe("List of canonical values"),
|
|
565
|
-
get subAttributes() {
|
|
566
|
-
return z.array(SCIMAttributeSchema).nullable().optional();
|
|
567
|
-
}
|
|
568
|
-
});
|
|
569
|
-
const SCIMSchemaSchema = z.strictObject({
|
|
570
|
-
name: z.string().describe("SCIM schema name"),
|
|
571
|
-
attributes: z.array(SCIMAttributeSchema).describe("Schema attributes")
|
|
572
|
-
});
|
|
573
|
-
const SCIMAttributeMappingSchema = z.strictObject({
|
|
574
|
-
tailorDBField: z.string().describe("TailorDB field name to map to"),
|
|
575
|
-
scimPath: z.string().describe("SCIM attribute path")
|
|
576
|
-
});
|
|
577
|
-
const SCIMResourceSchema = z.strictObject({
|
|
578
|
-
name: z.string().describe("SCIM resource name"),
|
|
579
|
-
tailorDBNamespace: z.string().describe("TailorDB namespace for the resource"),
|
|
580
|
-
tailorDBType: z.string().describe("TailorDB type name for the resource"),
|
|
581
|
-
coreSchema: SCIMSchemaSchema.describe("Core SCIM schema definition"),
|
|
582
|
-
attributeMapping: z.array(SCIMAttributeMappingSchema).describe("Attribute mapping configuration")
|
|
583
|
-
});
|
|
584
|
-
const SCIMSchema = z.strictObject({
|
|
585
|
-
machineUserName: z.string().describe("Machine user name for SCIM operations"),
|
|
586
|
-
authorization: SCIMAuthorizationSchema.describe("SCIM authorization configuration"),
|
|
587
|
-
resources: z.array(SCIMResourceSchema).describe("SCIM resource definitions")
|
|
588
|
-
});
|
|
589
|
-
const TenantProviderSchema = z.strictObject({
|
|
590
|
-
namespace: z.string().describe("TailorDB namespace for the tenant type"),
|
|
591
|
-
type: z.string().describe("TailorDB type name for tenants"),
|
|
592
|
-
signatureField: z.string().describe("Field used as the tenant signature")
|
|
593
|
-
});
|
|
594
|
-
const UserProfileSchema = z.strictObject({
|
|
595
|
-
namespace: z.string().optional().describe("TailorDB namespace where the user type is defined"),
|
|
596
|
-
type: z.custom().transform(stripTailorDBTypeBuilderHelpers).pipe(TailorDBTypeSchema),
|
|
597
|
-
usernameField: z.string(),
|
|
598
|
-
attributes: z.record(z.string(), z.literal(true)).optional(),
|
|
599
|
-
attributeList: z.array(z.string()).optional()
|
|
600
|
-
});
|
|
601
|
-
const ValueOperandSchema = z.union([
|
|
602
|
-
z.string(),
|
|
603
|
-
z.boolean(),
|
|
604
|
-
z.array(z.string()),
|
|
605
|
-
z.array(z.boolean())
|
|
606
|
-
]);
|
|
607
|
-
const MachineUserSchema = z.strictObject({
|
|
608
|
-
attributes: z.record(z.string(), ValueOperandSchema.nullish()).transform((attributes) => Object.fromEntries(Object.entries(attributes).filter((entry) => entry[1] != null))).optional(),
|
|
609
|
-
attributeList: z.array(z.uuid()).optional()
|
|
610
|
-
});
|
|
611
|
-
const BeforeLoginHookSchema = z.strictObject({
|
|
612
|
-
handler: z.function(),
|
|
613
|
-
invoker: z.string()
|
|
614
|
-
});
|
|
615
|
-
const AuthConfigBaseSchema = z.strictObject({
|
|
616
|
-
name: z.string().describe("Auth service name"),
|
|
617
|
-
hooks: z.strictObject({ beforeLogin: BeforeLoginHookSchema.optional().describe("Before login auth hook") }).optional().describe("Auth hooks"),
|
|
618
|
-
machineUsers: z.record(z.string(), MachineUserSchema).optional().describe("Machine user definitions"),
|
|
619
|
-
oauth2Clients: z.record(z.string(), OAuth2ClientSchema).optional().describe("OAuth2 client definitions"),
|
|
620
|
-
idProvider: IdProviderSchema.optional().describe("Identity provider configuration"),
|
|
621
|
-
scim: SCIMSchema.optional().describe("SCIM provisioning configuration"),
|
|
622
|
-
tenantProvider: TenantProviderSchema.optional().describe("Multi-tenant provider configuration"),
|
|
623
|
-
connections: z.record(z.string(), AuthConnectionConfigSchema).optional().describe("Auth connection definitions for external OAuth2 providers"),
|
|
624
|
-
publishSessionEvents: z.boolean().optional().describe("Enable publishing session events")
|
|
625
|
-
});
|
|
626
|
-
const AuthConfigSchema = z.xor([AuthConfigBaseSchema.extend({
|
|
627
|
-
userProfile: UserProfileSchema.optional().describe("User profile configuration"),
|
|
628
|
-
machineUserAttributes: z.undefined().optional()
|
|
629
|
-
}), AuthConfigBaseSchema.extend({
|
|
630
|
-
userProfile: z.undefined().optional(),
|
|
631
|
-
machineUserAttributes: z.record(z.string(), TailorFieldSchema).describe("Machine user attribute fields")
|
|
632
|
-
})], { error: (iss) => {
|
|
633
|
-
if (iss.code !== "invalid_union") return void 0;
|
|
634
|
-
if (iss.errors.length < 2) return void 0;
|
|
635
|
-
if (iss.errors.every((variantErrors) => variantErrors.every((e) => e.path.length === 1 && (e.path[0] === "userProfile" || e.path[0] === "machineUserAttributes")))) return "Specify either `userProfile` or `machineUserAttributes`, not both.";
|
|
636
|
-
} }).brand("AuthConfig");
|
|
637
|
-
|
|
638
|
-
//#endregion
|
|
639
|
-
//#region src/parser/service/executor/schema.ts
|
|
640
|
-
const TailorDBTriggerSchema = z.strictObject({
|
|
641
|
-
kind: z.literal("tailordb").describe("TailorDB record event trigger"),
|
|
642
|
-
events: z.array(z.enum([
|
|
643
|
-
"tailordb.type_record.created",
|
|
644
|
-
"tailordb.type_record.updated",
|
|
645
|
-
"tailordb.type_record.deleted"
|
|
646
|
-
])).min(1).transform((arr) => [...new Set(arr)]).describe("TailorDB event types to trigger on"),
|
|
647
|
-
typeName: z.string().describe("TailorDB type name to watch for events"),
|
|
648
|
-
condition: functionSchema.optional().describe("Condition function to filter events")
|
|
649
|
-
});
|
|
650
|
-
const ResolverExecutedTriggerSchema = z.strictObject({
|
|
651
|
-
kind: z.literal("resolverExecuted"),
|
|
652
|
-
resolverName: z.string().describe("Name of the resolver to trigger on"),
|
|
653
|
-
condition: functionSchema.optional().describe("Condition function to filter events")
|
|
654
|
-
});
|
|
655
|
-
const ScheduleTriggerSchema = z.strictObject({
|
|
656
|
-
kind: z.literal("schedule"),
|
|
657
|
-
cron: z.string().describe("CRON expression for the schedule"),
|
|
658
|
-
timezone: z.string().optional().default("UTC").describe("Timezone for the CRON schedule (default: UTC)")
|
|
659
|
-
});
|
|
660
|
-
const IncomingWebhookTriggerResponseSchema = z.strictObject({
|
|
661
|
-
body: functionSchema.optional().describe("Function returning the response body"),
|
|
662
|
-
statusCode: z.number().int().optional().describe("HTTP status code for the response")
|
|
663
|
-
});
|
|
664
|
-
const IncomingWebhookTriggerSchema = z.strictObject({
|
|
665
|
-
kind: z.literal("incomingWebhook"),
|
|
666
|
-
response: IncomingWebhookTriggerResponseSchema.optional().describe("Response configuration")
|
|
667
|
-
});
|
|
668
|
-
const IdpUserTriggerSchema = z.strictObject({
|
|
669
|
-
kind: z.literal("idpUser").describe("IdP user event trigger"),
|
|
670
|
-
events: z.array(z.enum([
|
|
671
|
-
"idp.user.created",
|
|
672
|
-
"idp.user.updated",
|
|
673
|
-
"idp.user.deleted"
|
|
674
|
-
])).min(1).transform((arr) => [...new Set(arr)]).describe("IdP user event types to trigger on"),
|
|
675
|
-
idp: z.string().optional().describe("IdP namespace name to subscribe to. If omitted, the project's only IdP is used; throws when multiple IdPs exist.")
|
|
676
|
-
});
|
|
677
|
-
const AuthAccessTokenTriggerSchema = z.strictObject({
|
|
678
|
-
kind: z.literal("authAccessToken").describe("Auth access token event trigger"),
|
|
679
|
-
events: z.array(z.enum([
|
|
680
|
-
"auth.access_token.issued",
|
|
681
|
-
"auth.access_token.refreshed",
|
|
682
|
-
"auth.access_token.revoked"
|
|
683
|
-
])).min(1).transform((arr) => [...new Set(arr)]).describe("Auth access token event types to trigger on")
|
|
684
|
-
});
|
|
685
|
-
const workflowNameSchema = z.string().refine((value) => value.trim().length > 0, "Workflow name cannot be blank").describe("Workflow name to subscribe to.");
|
|
686
|
-
const WorkflowExecutionTriggerSchema = z.strictObject({
|
|
687
|
-
kind: z.literal("workflowExecution").describe("Workflow execution event trigger"),
|
|
688
|
-
events: z.array(z.enum([
|
|
689
|
-
"workflow.workflow_execution.started",
|
|
690
|
-
"workflow.workflow_execution.completed",
|
|
691
|
-
"workflow.workflow_execution.retried",
|
|
692
|
-
"workflow.workflow_execution.resumed",
|
|
693
|
-
"workflow.workflow_execution.wait_started",
|
|
694
|
-
"workflow.workflow_execution.wait_resolved"
|
|
695
|
-
])).min(1).transform((arr) => [...new Set(arr)]).describe("Workflow execution event types to trigger on"),
|
|
696
|
-
workflowName: workflowNameSchema,
|
|
697
|
-
condition: functionSchema.optional().describe("Condition function to filter events")
|
|
698
|
-
});
|
|
699
|
-
const WorkflowJobExecutionTriggerSchema = z.strictObject({
|
|
700
|
-
kind: z.literal("workflowJobExecution").describe("Workflow job execution event trigger"),
|
|
701
|
-
events: z.array(z.enum([
|
|
702
|
-
"workflow.workflow_execution.job_execution.started",
|
|
703
|
-
"workflow.workflow_execution.job_execution.completed",
|
|
704
|
-
"workflow.workflow_execution.job_execution.wait_started",
|
|
705
|
-
"workflow.workflow_execution.job_execution.wait_resolved"
|
|
706
|
-
])).min(1).transform((arr) => [...new Set(arr)]).describe("Workflow job execution event types to trigger on"),
|
|
707
|
-
workflowName: workflowNameSchema,
|
|
708
|
-
condition: functionSchema.optional().describe("Condition function to filter events")
|
|
709
|
-
});
|
|
710
|
-
const TriggerSchema = z.discriminatedUnion("kind", [
|
|
711
|
-
TailorDBTriggerSchema,
|
|
712
|
-
ResolverExecutedTriggerSchema,
|
|
713
|
-
ScheduleTriggerSchema,
|
|
714
|
-
IncomingWebhookTriggerSchema,
|
|
715
|
-
IdpUserTriggerSchema,
|
|
716
|
-
AuthAccessTokenTriggerSchema,
|
|
717
|
-
WorkflowExecutionTriggerSchema,
|
|
718
|
-
WorkflowJobExecutionTriggerSchema
|
|
719
|
-
]);
|
|
720
|
-
const FunctionOperationSchema = z.strictObject({
|
|
721
|
-
kind: z.enum(["function", "jobFunction"]),
|
|
722
|
-
body: functionSchema.describe("Function implementation"),
|
|
723
|
-
invoker: AuthInvokerSchema.optional().describe("Invoker for the function execution")
|
|
724
|
-
});
|
|
725
|
-
const GqlOperationSchema = z.strictObject({
|
|
726
|
-
kind: z.literal("graphql"),
|
|
727
|
-
appName: z.string().optional().describe("Target application name for the GraphQL query"),
|
|
728
|
-
query: z.preprocess((val) => String(val), z.string().describe("GraphQL query string")),
|
|
729
|
-
variables: functionSchema.optional().describe("Function to compute GraphQL variables"),
|
|
730
|
-
invoker: AuthInvokerSchema.optional().describe("Invoker for the GraphQL execution")
|
|
731
|
-
});
|
|
732
|
-
const WebhookOperationSchema = z.strictObject({
|
|
733
|
-
kind: z.literal("webhook"),
|
|
734
|
-
url: functionSchema.describe("Function returning the webhook URL"),
|
|
735
|
-
requestBody: functionSchema.optional().describe("Function to compute the request body"),
|
|
736
|
-
headers: z.record(z.string(), z.union([z.string(), z.strictObject({
|
|
737
|
-
vault: z.string(),
|
|
738
|
-
key: z.string()
|
|
739
|
-
})])).optional().describe("HTTP headers for the webhook request")
|
|
740
|
-
});
|
|
741
|
-
const JsonValueSchema = z.lazy(() => z.union([
|
|
742
|
-
z.string(),
|
|
743
|
-
z.number(),
|
|
744
|
-
z.boolean(),
|
|
745
|
-
z.null(),
|
|
746
|
-
z.array(JsonValueSchema),
|
|
747
|
-
z.record(z.string(), JsonValueSchema)
|
|
748
|
-
]));
|
|
749
|
-
const WorkflowInputSchema = z.union([
|
|
750
|
-
z.string(),
|
|
751
|
-
z.number(),
|
|
752
|
-
z.boolean(),
|
|
753
|
-
z.array(JsonValueSchema),
|
|
754
|
-
z.record(z.string(), JsonValueSchema)
|
|
755
|
-
]);
|
|
756
|
-
const WorkflowOperationArgsSchema = z.union([WorkflowInputSchema, functionSchema]).describe("Arguments to pass to the workflow");
|
|
757
|
-
const workflowOperationShape = {
|
|
758
|
-
kind: z.literal("workflow"),
|
|
759
|
-
args: WorkflowOperationArgsSchema.optional(),
|
|
760
|
-
invoker: AuthInvokerSchema.optional().describe("Invoker for the workflow execution")
|
|
761
|
-
};
|
|
762
|
-
const WorkflowOperationByNameSchema = z.strictObject({
|
|
763
|
-
...workflowOperationShape,
|
|
764
|
-
workflowName: z.string().describe("Name of the workflow to execute"),
|
|
765
|
-
workflow: z.never().optional()
|
|
766
|
-
});
|
|
767
|
-
const WorkflowOperationByReferenceSchema = z.strictObject({
|
|
768
|
-
...workflowOperationShape,
|
|
769
|
-
workflow: z.looseObject({ name: z.string() }),
|
|
770
|
-
workflowName: z.string().optional()
|
|
771
|
-
}).transform(({ workflow, ...operation }) => ({
|
|
772
|
-
...operation,
|
|
773
|
-
workflowName: workflow.name
|
|
774
|
-
}));
|
|
775
|
-
const WorkflowOperationSchema = z.union([WorkflowOperationByReferenceSchema, WorkflowOperationByNameSchema]);
|
|
776
|
-
const OperationSchema = z.union([
|
|
777
|
-
FunctionOperationSchema,
|
|
778
|
-
GqlOperationSchema,
|
|
779
|
-
WebhookOperationSchema,
|
|
780
|
-
WorkflowOperationSchema
|
|
781
|
-
]);
|
|
782
|
-
const ExecutorSchema = z.strictObject({
|
|
783
|
-
name: z.string().describe("Executor name"),
|
|
784
|
-
description: z.string().optional().describe("Executor description"),
|
|
785
|
-
disabled: z.boolean().optional().default(false).describe("Whether the executor is disabled"),
|
|
786
|
-
trigger: TriggerSchema.describe("Event trigger configuration"),
|
|
787
|
-
operation: OperationSchema.describe("Operation to execute when triggered")
|
|
788
|
-
});
|
|
789
|
-
|
|
790
|
-
//#endregion
|
|
791
|
-
//#region src/cli/services/executor/loader.ts
|
|
792
|
-
function stripExecutorTriggerArgs(executor) {
|
|
793
|
-
if (!isSdkBranded(executor, "executor")) return executor;
|
|
794
|
-
const trigger = executor.trigger;
|
|
795
|
-
if (trigger === null || typeof trigger !== "object" || !("__args" in trigger)) return executor;
|
|
796
|
-
const { __args: _args, ...triggerConfig } = trigger;
|
|
797
|
-
return {
|
|
798
|
-
...executor,
|
|
799
|
-
trigger: triggerConfig
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Load and validate an executor definition from a file.
|
|
804
|
-
* @param executorFilePath - Path to the executor file
|
|
805
|
-
* @returns Parsed executor or null if invalid
|
|
806
|
-
*/
|
|
807
|
-
async function loadExecutor(executorFilePath) {
|
|
808
|
-
const executor = (await importUserModule(executorFilePath)).default;
|
|
809
|
-
const parseResult = ExecutorSchema.safeParse(stripExecutorTriggerArgs(executor));
|
|
810
|
-
if (!parseResult.success) return null;
|
|
811
|
-
return parseResult.data;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
//#endregion
|
|
815
|
-
//#region src/cli/services/executor/service.ts
|
|
816
|
-
/**
|
|
817
|
-
* Creates a new ExecutorService instance.
|
|
818
|
-
* @param params - Parameters for creating the service
|
|
819
|
-
* @returns A new ExecutorService instance
|
|
820
|
-
*/
|
|
821
|
-
function createExecutorService(params) {
|
|
822
|
-
const { config, baseDir } = params;
|
|
823
|
-
const executors = {};
|
|
824
|
-
const pluginExecutors = [];
|
|
825
|
-
let loadPromise;
|
|
826
|
-
const loadExecutorForFile = async (executorFile) => {
|
|
827
|
-
try {
|
|
828
|
-
const executorModule = await importUserModule(executorFile);
|
|
829
|
-
const result = ExecutorSchema.safeParse(stripExecutorTriggerArgs(executorModule.default));
|
|
830
|
-
if (result.success) {
|
|
831
|
-
const relativePath = path.relative(process.cwd(), executorFile);
|
|
832
|
-
logger.log(`Executor: ${styles.successBright(`"${result.data.name}"`)} loaded from ${styles.path(relativePath)}`);
|
|
833
|
-
executors[executorFile] = result.data;
|
|
834
|
-
return result.data;
|
|
835
|
-
}
|
|
836
|
-
if (isSdkBranded(executorModule.default, "executor")) throw result.error;
|
|
837
|
-
} catch (error) {
|
|
838
|
-
const relativePath = path.relative(process.cwd(), executorFile);
|
|
839
|
-
logger.error(`Failed to load executor from ${styles.bold(relativePath)}`);
|
|
840
|
-
logger.error(String(error));
|
|
841
|
-
throw error;
|
|
842
|
-
}
|
|
843
|
-
};
|
|
844
|
-
return {
|
|
845
|
-
config,
|
|
846
|
-
get executors() {
|
|
847
|
-
return executors;
|
|
848
|
-
},
|
|
849
|
-
get pluginExecutors() {
|
|
850
|
-
return pluginExecutors;
|
|
851
|
-
},
|
|
852
|
-
loadExecutors: async () => {
|
|
853
|
-
if (!loadPromise) loadPromise = (async () => {
|
|
854
|
-
if (config.files.length === 0) return;
|
|
855
|
-
const executorFiles = loadFilesWithIgnores(config, baseDir);
|
|
856
|
-
logger.newline();
|
|
857
|
-
logger.log(`Found ${styles.highlight(executorFiles.length.toString())} executor files`);
|
|
858
|
-
await Promise.all(executorFiles.map((executorFile) => loadExecutorForFile(executorFile)));
|
|
859
|
-
assertUniqueExecutorNames(executors);
|
|
860
|
-
return executors;
|
|
861
|
-
})();
|
|
862
|
-
return loadPromise;
|
|
863
|
-
},
|
|
864
|
-
loadPluginExecutorFiles: async (filePaths) => {
|
|
865
|
-
if (filePaths.length === 0) return;
|
|
866
|
-
logger.newline();
|
|
867
|
-
logger.log(`Loading ${styles.highlight(filePaths.length.toString())} plugin-generated executor files`);
|
|
868
|
-
for (const filePath of filePaths) {
|
|
869
|
-
const executor = await loadExecutorForFile(filePath);
|
|
870
|
-
if (executor) pluginExecutors.push({
|
|
871
|
-
executor,
|
|
872
|
-
pluginId: "plugin-generated",
|
|
873
|
-
sourceTypeName: void 0
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
assertUniqueExecutorNames(executors);
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Assert that every loaded executor has a unique name.
|
|
882
|
-
* Executors are stored by source file, so two files declaring the same
|
|
883
|
-
* `name` would otherwise silently share a single bundle cache entry.
|
|
884
|
-
* @param executors - Loaded executors keyed by source file
|
|
885
|
-
*/
|
|
886
|
-
function assertUniqueExecutorNames(executors) {
|
|
887
|
-
const seenNames = /* @__PURE__ */ new Map();
|
|
888
|
-
for (const [file, executor] of Object.entries(executors)) {
|
|
889
|
-
const relativePath = path.relative(process.cwd(), file);
|
|
890
|
-
const existing = seenNames.get(executor.name);
|
|
891
|
-
if (existing) throw new Error(`Duplicate executor name "${executor.name}" found:\n - ${existing}\n - ${relativePath}\nEach executor must have a unique name.`);
|
|
892
|
-
seenNames.set(executor.name, relativePath);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
//#endregion
|
|
897
|
-
export { beginUserModuleRun as _, AuthConfigSchema as a, functionSchema as b, stripTailorDBTypeBuilderHelpers as c, applyRelationMetadataToFieldConfig as d, buildRelationInfo as f, IMPORT_NONCE_PARAM 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, currentImportNonce as v, importUserModule as y };
|
|
898
|
-
//# sourceMappingURL=service-C_WpbKHu.mjs.map
|