@tailor-platform/sdk 1.66.1 → 1.67.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 +49 -0
- package/dist/application-Djeezk3m.mjs +4 -0
- package/dist/{client-F0a4cWUM.mjs → application-WpWwTyk9.mjs} +5734 -20
- package/dist/application-WpWwTyk9.mjs.map +1 -0
- package/dist/{authconnection-D8SJGMpj.mjs → authconnection-Ds2Ahpum.mjs} +2 -2
- package/dist/{authconnection-D8SJGMpj.mjs.map → authconnection-Ds2Ahpum.mjs.map} +1 -1
- package/dist/cli/index.mjs +18 -64
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +7 -7
- package/dist/cli/lib.mjs +3 -4
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/completion/zsh-worker.zsh +1 -1
- package/dist/configure/index.d.mts +5 -5
- package/dist/configure/index.mjs +2 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{context-s0lxhu8_.mjs → context-CDQqIv4u.mjs} +2 -2
- package/dist/{context-s0lxhu8_.mjs.map → context-CDQqIv4u.mjs.map} +1 -1
- package/dist/{crashreport-Bf6uT6mf.mjs → crashreport-6jpCceOF.mjs} +1 -1
- package/dist/{crashreport-0EHy-ayY.mjs → crashreport-u9y2npiy.mjs} +5 -7
- package/dist/{crashreport-0EHy-ayY.mjs.map → crashreport-u9y2npiy.mjs.map} +1 -1
- package/dist/enum-constants-C7DaWeQo.mjs.map +1 -1
- package/dist/field-C4zdJLW5.mjs.map +1 -1
- package/dist/{file-B58Dm-2P.mjs → file-BkxupbYP.mjs} +2 -2
- package/dist/{file-B58Dm-2P.mjs.map → file-BkxupbYP.mjs.map} +1 -1
- package/dist/file-utils-BHPxPXmn.mjs.map +1 -1
- package/dist/{iconv-DreIffeM.mjs → iconv-D1zmPjvi.mjs} +2 -2
- package/dist/{iconv-DreIffeM.mjs.map → iconv-D1zmPjvi.mjs.map} +1 -1
- package/dist/{idp-Ch95ag8h.mjs → idp-BZPqpcYY.mjs} +2 -2
- package/dist/{idp-Ch95ag8h.mjs.map → idp-BZPqpcYY.mjs.map} +1 -1
- package/dist/{index-Db2RvnEH.d.mts → index-CklcVeMG.d.mts} +2 -2
- package/dist/{index-CZ2r3qiO.d.mts → index-DYhnxXYR.d.mts} +2 -2
- package/dist/{index-QpC0TNbH.d.mts → index-DlDRSzFZ.d.mts} +2 -2
- package/dist/{index-BdLqzJDu.d.mts → index-DvEUb3pX.d.mts} +15 -9
- package/dist/{index-Bhjep8cS.d.mts → index-hXoO-AOC.d.mts} +2 -2
- package/dist/job-BpsFXPbi.mjs.map +1 -1
- package/dist/kysely-type-D1e0Vwkd.mjs.map +1 -1
- package/dist/mock-DMgIygjE.mjs.map +1 -1
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/index.d.mts +2 -3
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/registry-D0uB0OrK.mjs.map +1 -1
- package/dist/runtime/authconnection.mjs +1 -1
- package/dist/runtime/context.mjs +1 -1
- package/dist/runtime/file.mjs +1 -1
- package/dist/runtime/iconv.mjs +1 -1
- package/dist/runtime/idp.mjs +1 -1
- package/dist/runtime/index.mjs +7 -7
- package/dist/runtime/secretmanager.mjs +1 -1
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/{runtime-2nzOZCUb.mjs → runtime-BU6KtCvk.mjs} +9 -35
- package/dist/runtime-BU6KtCvk.mjs.map +1 -0
- package/dist/schema-1msIhXwA.mjs.map +1 -1
- package/dist/{secret-file-CWzF8rry.mjs → secret-file-eB3R3Fil.mjs} +27 -2
- package/dist/{secret-file-CWzF8rry.mjs.map → secret-file-eB3R3Fil.mjs.map} +1 -1
- package/dist/{secretmanager-B9h-U_8U.mjs → secretmanager-h3tBJV8f.mjs} +2 -2
- package/dist/{secretmanager-B9h-U_8U.mjs.map → secretmanager-h3tBJV8f.mjs.map} +1 -1
- package/dist/{seed-BH2FbrPV.mjs → seed-YAbtMy65.mjs} +2 -2
- package/dist/seed-YAbtMy65.mjs.map +1 -0
- package/dist/{service-DMohAx8a2.mjs → service-DMohAx8a.mjs} +1 -1
- package/dist/service-DMohAx8a.mjs.map +1 -0
- package/dist/service-wI3Hvrgx.mjs.map +1 -1
- package/dist/{plugin-DylAsA4Z.d.mts → types-Bzr0RQME.d.mts} +342 -36
- package/dist/types-CmzfQP_m.mjs.map +1 -1
- package/dist/types-DTcZ2Yax.d.mts +74 -0
- package/dist/{tailordb-C-ar4XCX.d.mts → types-DZrtN6-H.d.mts} +89 -239
- package/dist/utils/test/index.d.mts +3 -3
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/index.d.mts +1 -1
- package/dist/{workflow--aPbA8Uq.mjs → workflow-C8I7shjM.mjs} +2 -2
- package/dist/{workflow--aPbA8Uq.mjs.map → workflow-C8I7shjM.mjs.map} +1 -1
- package/dist/{workflow.generated--1Qc15Et.d.mts → workflow.generated-1S50BhEb.d.mts} +17 -241
- package/docs/cli-reference.md +18 -17
- package/docs/github-actions.md +2 -2
- package/package.json +11 -9
- package/dist/actor-D_2aJjYO.d.mts +0 -24
- package/dist/application-DGDmL8i_.mjs +0 -5620
- package/dist/application-DGDmL8i_.mjs.map +0 -1
- package/dist/application-nTydHJm8.mjs +0 -4
- package/dist/client-F0a4cWUM.mjs.map +0 -1
- package/dist/client-boxXYevx.mjs +0 -4
- package/dist/env-B-g-qgE4.d.mts +0 -7
- package/dist/runtime-2nzOZCUb.mjs.map +0 -1
- package/dist/seed-BH2FbrPV.mjs.map +0 -1
- package/dist/service-DMohAx8a2.mjs.map +0 -1
- /package/dist/{chunk-BkoGK1jX.mjs → rolldown-runtime-BkoGK1jX.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"@/runtime/context\";\nimport type { TailorInvoker } from \"@/types/user\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorInvoker): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: () => {\n throw new Error(\n \"tailor.workflow.triggerJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"@/configure/services/workflow/job\";\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;;;;;AAmDA,MAAM,aAAa;;;;;;;AAQnB,SAAgB,kBAAkB,iBAAgC,CAAC,GAGjE;CACA,MAAM,kBAA0D,CAAC;CACjE,MAAM,iBAA2D,CAAC;CAElE,MAAM,mBAAmB;EACvB,AAAQ;EAER,YAAY,EAAE,aAAqC;GACjD,KAAK,SAAS;IAAE;IAAW,OAAO;GAAM;GACxC,eAAe,KAAK,KAAK,MAAM;EACjC;EAEA,MAAM,UAAyB,CAE/B;EAEA,MAAM,MAAqB;GACzB,KAAK,OAAO,QAAQ;EACtB;EAEA,MAAM,YAAY,OAAe,SAAoB,CAAC,GAAiC;GACrF,gBAAgB,KAAK;IAAE;IAAO;GAAO,CAAC;GACtC,OAAO,EAAE,MAAM,SAAS,OAAO,MAAM,EAAE;EACzC;CACF;CAEA,WAAW,WAAW,EACpB,QAAQ,mBACV;CAEA,OAAO;EAAE;EAAiB;CAAe;AAC3C;;;;;;;;;AAUA,SAAgB,kBAAkB,SAEhC;CACA,MAAM,gBAAsD,CAA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IAAI,QAAQ,OAAO,SAAS,UACjC,OAAO,OAAQ,KAAiC;GAElD,OAAO;EACT,GACA,CAAC,CACH;CACF;AACF;;;;;;;;;AAUA,SAAgB,qBAEd,YACA,MACA;CACA,OAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,KAAK;GACzB,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;GACR,CAAC;GACD,IAAI,OAAO,QACT,OAAO;GAET,OAAO,EAAE,OAAO,OAAY;EAC9B;CACF,EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/utils/test/mock.ts","../../../src/utils/test/index.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { ContextInvoker } from \"@/runtime/context\";\nimport type { TailorInvoker } from \"@/runtime/types\";\n\ntype MainFunction = (args: Record<string, unknown>) => unknown | Promise<unknown>;\ntype QueryResolver = (query: string, params: unknown[]) => unknown[];\ntype JobHandler = (jobName: string, args: unknown) => unknown;\ntype WaitHandler = (key: string, payload: unknown) => unknown;\ntype ResolveHandler = (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n) => Promise<void> | void;\n\ninterface TailordbGlobal {\n tailordb?: {\n Client: new (config: { namespace?: string }) => {\n connect(): Promise<void> | void;\n end(): Promise<void> | void;\n queryObject(\n query: string,\n params?: unknown[],\n ): Promise<{ rows: unknown[] }> | { rows: unknown[] };\n };\n };\n tailor?: {\n workflow: {\n triggerJobFunction: (jobName: string, args: unknown) => unknown;\n wait?: (key: string, payload?: unknown) => unknown;\n resolve?: (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => Promise<void>;\n };\n context: {\n getInvoker: () => ContextInvoker | null;\n };\n };\n}\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\ninterface TailorErrorsGlobal {\n TailorErrors?: new (errors: TailorErrorItem[]) => Error;\n}\n\nconst GlobalThis = globalThis as TailordbGlobal & TailorErrorsGlobal;\n\n/**\n * Sets up a mock for `globalThis.tailordb.Client` used in bundled resolver/executor tests.\n * @deprecated Use `mockTailordb` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param resolver - Optional function to resolve query results. Defaults to returning empty arrays.\n * @returns Object containing arrays of executed queries and created clients for assertions.\n */\nexport function setupTailordbMock(resolver: QueryResolver = () => []): {\n executedQueries: { query: string; params: unknown[] }[];\n createdClients: { namespace?: string; ended: boolean }[];\n} {\n const executedQueries: { query: string; params: unknown[] }[] = [];\n const createdClients: { namespace?: string; ended: boolean }[] = [];\n\n class MockTailordbClient {\n private record: { namespace?: string; ended: boolean };\n\n constructor({ namespace }: { namespace?: string }) {\n this.record = { namespace, ended: false };\n createdClients.push(this.record);\n }\n\n async connect(): Promise<void> {\n /* noop */\n }\n\n async end(): Promise<void> {\n this.record.ended = true;\n }\n\n async queryObject(query: string, params: unknown[] = []): Promise<{ rows: unknown[] }> {\n executedQueries.push({ query, params });\n return { rows: resolver(query, params) };\n }\n }\n\n GlobalThis.tailordb = {\n Client: MockTailordbClient,\n } as typeof GlobalThis.tailordb;\n\n return { executedQueries, createdClients };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.workflow.triggerJobFunction` used in bundled workflow tests.\n * `wait`/`resolve` are stubbed to throw a helpful error directing to `mockWorkflow`,\n * so mistakenly calling wait without wait-point mocks produces a clear message instead of a TypeError.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * @param handler - Function that handles triggered job calls and returns results.\n * @returns Object containing an array of triggered jobs for assertions.\n */\nexport function setupWorkflowMock(handler: JobHandler): {\n triggeredJobs: { jobName: string; args: unknown }[];\n} {\n const triggeredJobs: { jobName: string; args: unknown }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n wait: () => {\n throw new Error(\n \"tailor.workflow.wait is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n resolve: async () => {\n throw new Error(\n \"tailor.workflow.resolve is not mocked. Use mockWorkflow from @tailor-platform/sdk/vitest in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n triggerJobFunction: (jobName: string, args: unknown) => {\n triggeredJobs.push({ jobName, args });\n return handler(jobName, args);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { triggeredJobs };\n}\n\n/**\n * Sets up a mock for `globalThis.tailor.context.getInvoker` used in bundled\n * resolver/executor/workflow tests.\n * @deprecated With the `tailor-runtime` environment from `@tailor-platform/sdk/vitest`, drive the invoker via `vi.spyOn(globalThis.tailor.context, \"getInvoker\").mockReturnValue(...)` for bundled tests, or pass `invoker` directly to `.body()` when unit-testing resolvers/executors/workflow jobs against the TypeScript source.\n * @param invoker - The `TailorInvoker` value to return, or `null` for anonymous.\n */\nexport function setupInvokerMock(invoker: TailorInvoker): void {\n const raw: ContextInvoker | null = invoker\n ? {\n id: invoker.id,\n type: invoker.type,\n workspaceId: invoker.workspaceId,\n attributes: invoker.attributeList as string[],\n attributeMap: invoker.attributes as Record<string, unknown>,\n }\n : null;\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n context: {\n getInvoker: () => raw,\n },\n } as typeof GlobalThis.tailor;\n}\n\n/**\n * Sets up a mock for `globalThis.TailorErrors` used in bundled resolver tests.\n * Mimics the PF runtime's TailorErrors class that serializes errors with the `TailorErrors: ` prefix.\n * @deprecated Use the `tailor-runtime` environment from `@tailor-platform/sdk/vitest` which auto-injects TailorErrors.\n */\nexport function setupTailorErrorsMock(): void {\n GlobalThis.TailorErrors = class TailorErrors extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n super(`TailorErrors: ${JSON.stringify({ errors })}`);\n this.name = \"TailorErrors\";\n this.errors = errors;\n }\n };\n}\n\n/**\n * Sets up mocks for `globalThis.tailor.workflow.wait` and `.resolve` used in bundled workflow tests.\n * `triggerJobFunction` is stubbed to throw a helpful error directing to `setupWorkflowMock()`,\n * so mistakenly triggering a job without job mocks produces a clear message instead of silently returning undefined.\n * @deprecated Use `mockWorkflow` from `@tailor-platform/sdk/vitest` with the `tailor-runtime` environment instead.\n * `setWaitHandler` / `setResolveHandler` cover wait/resolve, and `waitCalls` / `resolveCalls` give the same assertion shape.\n * @param config - Optional handlers for wait and resolve calls.\n * @param config.onWait - Handler called when wait is invoked.\n * @param config.onResolve - Handler called when resolve is invoked.\n * @returns Object containing arrays of wait and resolve calls for assertions.\n */\nexport function setupWaitPointMock(config?: { onWait?: WaitHandler; onResolve?: ResolveHandler }): {\n waitCalls: { key: string; payload: unknown }[];\n resolveCalls: { executionId: string; key: string }[];\n} {\n const waitCalls: { key: string; payload: unknown }[] = [];\n const resolveCalls: { executionId: string; key: string }[] = [];\n\n GlobalThis.tailor = {\n ...GlobalThis.tailor,\n workflow: {\n triggerJobFunction: () => {\n throw new Error(\n \"tailor.workflow.triggerJobFunction is not mocked. Use setupWorkflowMock() in tests.\",\n );\n },\n ...GlobalThis.tailor?.workflow,\n wait: (key: string, payload?: unknown) => {\n waitCalls.push({ key, payload });\n return config?.onWait?.(key, payload);\n },\n resolve: async (\n executionId: string,\n key: string,\n callback: (payload: unknown) => unknown,\n ) => {\n resolveCalls.push({ executionId, key });\n await config?.onResolve?.(executionId, key, callback);\n },\n },\n } as typeof GlobalThis.tailor;\n\n return { waitCalls, resolveCalls };\n}\n\n/**\n * Creates a function that imports a bundled JS file and returns its `main` export.\n * Used to test bundled output from `apply --buildOnly`.\n * @param baseDir - Base directory where bundled files are located.\n * @returns An async function that takes a relative path and returns the `main` function.\n * @deprecated This is an SDK-internal testing helper. Bundling integrity is the SDK's responsibility,\n * not the application's — verify your code through unit tests against the TypeScript source and\n * E2E tests against a deployed application instead. This export will be removed in a future release.\n */\nexport function createImportMain(baseDir: string): (relativePath: string) => Promise<MainFunction> {\n return async (relativePath: string): Promise<MainFunction> => {\n const fileUrl = pathToFileURL(path.join(baseDir, relativePath));\n fileUrl.searchParams.set(\"v\", `${Date.now()}-${Math.random()}`);\n const module = await import(fileUrl.href);\n const main = module.main;\n if (typeof main !== \"function\") {\n throw new Error(`Expected \"main\" to be a function in ${relativePath}, got ${typeof main}`);\n }\n return main;\n };\n}\n","import type { output, TailorUser } from \"@/configure\";\nimport type { TailorDBType } from \"@/configure/services/tailordb/schema\";\nimport type { TailorField } from \"@/configure/types/type\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport { WORKFLOW_TEST_ENV_KEY } from \"@/configure/services/workflow/job\";\nexport {\n setupTailordbMock,\n setupTailorErrorsMock,\n setupWorkflowMock,\n setupInvokerMock,\n setupWaitPointMock,\n createImportMain,\n} from \"./mock\";\n\n/** Represents an unauthenticated user in the Tailor platform. */\nexport const unauthenticatedTailorUser = {\n id: \"00000000-0000-0000-0000-000000000000\",\n type: \"\",\n workspaceId: \"00000000-0000-0000-0000-000000000000\",\n attributes: null,\n attributeList: [],\n} as const satisfies TailorUser;\n\n/**\n * Creates a hook function that processes TailorDB type fields\n * - Uses existing id from data if provided, otherwise generates UUID for id fields\n * - Recursively processes nested types\n * - Executes hooks.create for fields with create hooks\n * @template T - The output type of the hook function\n * @param type - TailorDB type definition\n * @returns A function that transforms input data according to field hooks\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function createTailorDBHook<T extends TailorDBType<any, any>>(type: T) {\n return (data: unknown) => {\n return Object.entries(type.fields).reduce(\n (hooked, [key, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const field = value as TailorField<any, any, any>;\n if (key === \"id\") {\n // Use existing id from data if provided, otherwise generate new UUID\n const existingId =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n hooked[key] = existingId ?? crypto.randomUUID();\n } else if (field.type === \"nested\") {\n const nestedValue =\n data && typeof data === \"object\" ? (data as Record<string, unknown>)[key] : undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nestedHook = createTailorDBHook({ fields: field.fields } as any);\n if (field.metadata.array) {\n // For nested array fields, recurse per element and pass through non-array values\n // (e.g. null/undefined for optional fields) so validation sees the original value.\n hooked[key] = Array.isArray(nestedValue)\n ? nestedValue.map((item) => nestedHook(item))\n : nestedValue;\n } else {\n hooked[key] = nestedHook(nestedValue);\n }\n } else if (field.metadata.hooks?.create) {\n hooked[key] = field.metadata.hooks.create({\n value: (data as Record<string, unknown>)[key],\n data: data,\n user: unauthenticatedTailorUser,\n });\n if (hooked[key] instanceof Date) {\n hooked[key] = hooked[key].toISOString();\n }\n } else if (data && typeof data === \"object\") {\n hooked[key] = (data as Record<string, unknown>)[key];\n }\n return hooked;\n },\n {} as Record<string, unknown>,\n ) as Partial<output<T>>;\n };\n}\n\n/**\n * Creates the standard schema definition for lines-db\n * This returns the first argument for defineSchema with the ~standard section\n * @template T - The output type after validation\n * @param schemaType - TailorDB field schema for validation\n * @param hook - Hook function to transform data before validation\n * @returns Schema object with ~standard section for defineSchema\n */\nexport function createStandardSchema<T = Record<string, unknown>>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schemaType: TailorField<any, T>,\n hook: (data: unknown) => Partial<T>,\n) {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"@tailor-platform/sdk\",\n validate: (value: unknown) => {\n const hooked = hook(value);\n const result = schemaType.parse({\n value: hooked,\n data: hooked,\n user: unauthenticatedTailorUser,\n });\n if (result.issues) {\n return result;\n }\n return { value: hooked as T };\n },\n },\n } as const satisfies StandardSchemaV1<T>;\n}\n"],"mappings":";;;;;;AAmDA,MAAM,aAAa;;;;;;;AAQnB,SAAgB,kBAAkB,iBAAgC,CAAC,GAGjE;CACA,MAAM,kBAA0D,CAAC;CACjE,MAAM,iBAA2D,CAAC;CAElE,MAAM,mBAAmB;EACvB,AAAQ;EAER,YAAY,EAAE,aAAqC;GACjD,KAAK,SAAS;IAAE;IAAW,OAAO;GAAM;GACxC,eAAe,KAAK,KA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,MAAM,OAAO,CAAQ;IACrE,IAAI,MAAM,SAAS,OAGjB,OAAO,OAAO,MAAM,QAAQ,WAAW,IACnC,YAAY,KAAK,SAAS,WAAW,IAAI,CAAC,IAC1C;SAEJ,OAAO,OAAO,WAAW,WAAW;GAExC,OAAO,IAAI,MAAM,SAAS,OAAO,QAAQ;IACvC,OAAO,OAAO,MAAM,SAAS,MAAM,OAAO;KACxC,OAAQ,KAAiC;KACnC;KACN,MAAM;IACR,CAAC;IACD,IAAI,OAAO,gBAAgB,MACzB,OAAO,OAAO,OAAO,IAAI,CAAC,YAAY;GAE1C,OAAO,IAAI,QAAQ,OAAO,SAAS,UACjC,OAAO,OAAQ,KAAiC;GAElD,OAAO;EACT,GACA,CAAC,CACH;CACF;AACF;;;;;;;;;AAUA,SAAgB,qBAEd,YACA,MACA;CACA,OAAO,EACL,aAAa;EACX,SAAS;EACT,QAAQ;EACR,WAAW,UAAmB;GAC5B,MAAM,SAAS,KAAK,KAAK;GACzB,MAAM,SAAS,WAAW,MAAM;IAC9B,OAAO;IACP,MAAM;IACN,MAAM;GACR,CAAC;GACD,IAAI,OAAO,QACT,OAAO;GAET,OAAO,EAAE,OAAO,OAAY;EAC9B;CACF,EACF;AACF"}
|
package/dist/vitest/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { t as __exportAll } from "./
|
|
2
|
+
import { t as __exportAll } from "./rolldown-runtime-BkoGK1jX.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/runtime/workflow.ts
|
|
5
5
|
var workflow_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -36,4 +36,4 @@ const resolve = (...args) => api().resolve(...args);
|
|
|
36
36
|
|
|
37
37
|
//#endregion
|
|
38
38
|
export { workflow_exports as a, wait as i, triggerJobFunction as n, triggerWorkflow as r, resolve as t };
|
|
39
|
-
//# sourceMappingURL=workflow
|
|
39
|
+
//# sourceMappingURL=workflow-C8I7shjM.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow
|
|
1
|
+
{"version":3,"file":"workflow-C8I7shjM.mjs","names":[],"sources":["../src/runtime/workflow.ts"],"sourcesContent":["/**\n * Workflow utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.\n * At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`\n * from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { workflow } from \"@tailor-platform/sdk/runtime\";\n *\n * const executionId = await workflow.triggerWorkflow(\"myWorkflow\", { data: \"value\" });\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/**\n * Specifies the machine user that should be used to execute the workflow.\n * This allows workflows to run with specific authentication context.\n */\nexport interface AuthInvoker {\n /** The namespace where the machine user is defined */\n namespace: string;\n /** The name of the machine user to use for workflow execution */\n machineUserName: string;\n}\n\n/** Options for {@link triggerWorkflow}. */\nexport interface TriggerWorkflowOptions {\n /** Optional authentication invoker to specify which machine user should execute the workflow */\n authInvoker?: AuthInvoker;\n}\n\n/**\n * Platform API surface for `tailor.workflow`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.workflow`.\n *\n * Each method below is also re-exported as a top-level named export from this\n * module so callers can either `import * as workflow from\n * \"@tailor-platform/sdk/runtime/workflow\"` or pick individual methods.\n */\nexport interface TailorWorkflowAPI {\n /**\n * Triggers a workflow and returns its execution ID.\n * @param workflowName - Workflow name as defined in tailor.config\n * @param args - Arguments forwarded to the workflow's main job\n * @param options - Optional trigger options (e.g. `authInvoker`)\n * @returns The execution ID of the triggered workflow\n */\n triggerWorkflow(\n workflowName: string,\n args?: any,\n options?: TriggerWorkflowOptions,\n ): Promise<string>;\n\n /**\n * Triggers a job function and returns its result.\n * @param jobName - Job name as defined in the workflow\n * @param args - Arguments forwarded to the job\n * @returns The job's return value\n */\n triggerJobFunction(jobName: string, args?: any): any;\n\n /**\n * Suspends the current workflow execution and waits for an external signal to resume.\n * @param key - Wait point key\n * @param payload - Optional payload to record with the wait point\n * @returns The payload supplied by the corresponding `resolve` call\n */\n wait(key: string, payload?: any): any;\n\n /**\n * Resolves a waiting workflow execution, causing it to resume.\n * @param executionId - The execution to resume\n * @param key - Wait point key to resolve\n * @param callback - Callback receiving the wait payload; its return value is forwarded to `wait`\n * @returns A promise that resolves once the resolve has been recorded\n */\n resolve(executionId: string, key: string, callback: (waitPayload: any) => any): Promise<void>;\n}\n\nconst api = (): TailorWorkflowAPI =>\n (globalThis as { tailor: { workflow: TailorWorkflowAPI } }).tailor.workflow;\n\n/**\n * See {@link TailorWorkflowAPI.triggerWorkflow}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerWorkflow}\n * @returns The execution ID of the triggered workflow\n */\nexport const triggerWorkflow: TailorWorkflowAPI[\"triggerWorkflow\"] = (...args) =>\n api().triggerWorkflow(...args);\n\n/**\n * See {@link TailorWorkflowAPI.triggerJobFunction}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.triggerJobFunction}\n * @returns The job's return value\n */\nexport const triggerJobFunction: TailorWorkflowAPI[\"triggerJobFunction\"] = (...args) =>\n api().triggerJobFunction(...args);\n\n/**\n * See {@link TailorWorkflowAPI.wait}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.wait}\n * @returns The payload supplied by the corresponding `resolve` call\n */\nexport const wait: TailorWorkflowAPI[\"wait\"] = (...args) => api().wait(...args);\n\n/**\n * See {@link TailorWorkflowAPI.resolve}.\n * @param args - Forwarded to {@link TailorWorkflowAPI.resolve}\n * @returns A promise that resolves once the resolve has been recorded\n */\nexport const resolve: TailorWorkflowAPI[\"resolve\"] = (...args) => api().resolve(...args);\n"],"mappings":";;;;;;;;;;AA+EA,MAAM,YACH,WAA2D,OAAO;;;;;;AAOrE,MAAa,mBAAyD,GAAG,SACvE,IAAI,CAAC,CAAC,gBAAgB,GAAG,IAAI;;;;;;AAO/B,MAAa,sBAA+D,GAAG,SAC7E,IAAI,CAAC,CAAC,mBAAmB,GAAG,IAAI;;;;;;AAOlC,MAAa,QAAmC,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG,IAAI;;;;;;AAO9E,MAAa,WAAyC,GAAG,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG,IAAI"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { IsAny, JsonObject, JsonValue, NonEmptyObject } from "type-fest";
|
|
1
|
+
import { c as TailorUser, i as InferredAttributeMap } from "./types-DTcZ2Yax.mjs";
|
|
2
|
+
import { A as Validators, D as TailorField, E as FieldValidateInput, F as output, P as Prettify, S as EnumValue, T as FieldOutput, a as Hooks, b as ArrayFieldOutput, g as TailorDBType$1, h as TailorDBServiceInput, i as Hook, j as InferFieldsOutput, k as TailorToTs, l as RelationType, n as DefinedDBFieldMetadata, o as IndexDef, p as TailorDBField$1, r as ExcludeNestedDBFields, t as DBFieldMetadata, u as SerialConfig, v as TypeFeatures, w as FieldOptions } from "./types-DZrtN6-H.mjs";
|
|
3
|
+
import { it as BuiltinIdP, o as PluginConfigs, z as AuthConfig } from "./types-Bzr0RQME.mjs";
|
|
5
4
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
5
|
|
|
7
6
|
//#region src/configure/types/field.d.ts
|
|
@@ -126,41 +125,6 @@ declare const unsafeAllowAllTypePermission: TailorTypePermission;
|
|
|
126
125
|
*/
|
|
127
126
|
declare const unsafeAllowAllGqlPermission: TailorTypeGqlPermission;
|
|
128
127
|
//#endregion
|
|
129
|
-
//#region src/configure/services/tailordb/types.d.ts
|
|
130
|
-
type HookFn<TValue, TData, TReturn> = (args: {
|
|
131
|
-
value: TValue;
|
|
132
|
-
data: TData extends Record<string, unknown> ? { readonly [K in keyof TData]?: TData[K] | null | undefined } : unknown;
|
|
133
|
-
user: TailorUser;
|
|
134
|
-
}) => TReturn;
|
|
135
|
-
type Hook<TData, TReturn> = {
|
|
136
|
-
create?: HookFn<TReturn | null, TData, TReturn>;
|
|
137
|
-
update?: HookFn<TReturn | null, TData, TReturn>;
|
|
138
|
-
};
|
|
139
|
-
type Hooks<F extends Record<string, TailorAnyDBField$1>, TData = { [K in keyof F]: output<F[K]> }> = NonEmptyObject<{ [K in Exclude<keyof F, "id"> as F[K]["_defined"] extends {
|
|
140
|
-
hooks: unknown;
|
|
141
|
-
} ? never : F[K]["_defined"] extends {
|
|
142
|
-
type: "nested";
|
|
143
|
-
} ? never : K]?: Hook<TData, output<F[K]>> }>;
|
|
144
|
-
type ExcludeNestedDBFields<T extends Record<string, TailorAnyDBField$1>> = { [K in keyof T]: T[K] extends TailorDBField$1<{
|
|
145
|
-
type: "nested";
|
|
146
|
-
array: boolean;
|
|
147
|
-
}, any> ? never : T[K] };
|
|
148
|
-
interface TypeFeatures {
|
|
149
|
-
pluralForm?: string;
|
|
150
|
-
aggregation?: true;
|
|
151
|
-
bulkUpsert?: true;
|
|
152
|
-
/** Configure GraphQL operations for this type. Use "query" for read-only mode, or an object for granular control. */
|
|
153
|
-
gqlOperations?: GqlOperationsConfig;
|
|
154
|
-
/**
|
|
155
|
-
* Enable publishing events for this type.
|
|
156
|
-
* When enabled, record creation/update/deletion events are published.
|
|
157
|
-
* If not specified, this is automatically set to true when an executor uses this type
|
|
158
|
-
* with recordCreated/recordUpdated/recordDeleted triggers. If explicitly set to false
|
|
159
|
-
* while an executor uses this type, an error will be thrown during apply.
|
|
160
|
-
*/
|
|
161
|
-
publishEvents?: boolean;
|
|
162
|
-
}
|
|
163
|
-
//#endregion
|
|
164
128
|
//#region src/configure/services/tailordb/schema.d.ts
|
|
165
129
|
type TailorAnyDBField = TailorDBField<any, any>;
|
|
166
130
|
type TailorAnyDBType = TailorDBType<any, any>;
|
|
@@ -299,7 +263,7 @@ interface TailorDBField<Defined extends DefinedDBFieldMetadata = DefinedDBFieldM
|
|
|
299
263
|
array: NewOpt extends {
|
|
300
264
|
array: true;
|
|
301
265
|
} ? true : Defined["array"];
|
|
302
|
-
}>, FieldOutput
|
|
266
|
+
}>, FieldOutput<TailorToTs[Defined["type"]], NewOpt>>;
|
|
303
267
|
}
|
|
304
268
|
/**
|
|
305
269
|
* Full TailorDBType interface with builder methods.
|
|
@@ -320,7 +284,7 @@ interface TailorDBType<Fields extends Record<string, TailorAnyDBField> = any, Us
|
|
|
320
284
|
array: Opt extends {
|
|
321
285
|
array: true;
|
|
322
286
|
} ? true : D["array"];
|
|
323
|
-
}, FieldOutput
|
|
287
|
+
}, FieldOutput<TailorToTs[D["type"]], Opt>> : never };
|
|
324
288
|
omitFields<K extends keyof Fields>(keys: K[]): Omit<Fields, K>;
|
|
325
289
|
plugin<P extends keyof PluginConfigs<keyof Fields & string>>(config: { [K in P]: PluginConfigs<keyof Fields & string>[K] }): TailorDBType<Fields, User>;
|
|
326
290
|
}
|
|
@@ -489,7 +453,7 @@ declare function _enum<const V extends AllowedValues, const Opt extends FieldOpt
|
|
|
489
453
|
array: Opt extends {
|
|
490
454
|
array: true;
|
|
491
455
|
} ? true : false;
|
|
492
|
-
}, FieldOutput
|
|
456
|
+
}, FieldOutput<AllowedValuesOutput<V>, Opt>>;
|
|
493
457
|
/**
|
|
494
458
|
* Create a nested object field with sub-fields.
|
|
495
459
|
* @param fields - Record of nested field definitions
|
|
@@ -503,7 +467,7 @@ declare function object<const F extends Record<string, TailorAnyDBField> & Exclu
|
|
|
503
467
|
array: Opt extends {
|
|
504
468
|
array: true;
|
|
505
469
|
} ? true : false;
|
|
506
|
-
}, FieldOutput
|
|
470
|
+
}, FieldOutput<InferFieldsOutput<F>, Opt>>;
|
|
507
471
|
declare const idField: TailorDBField<{
|
|
508
472
|
type: "uuid";
|
|
509
473
|
array: false;
|
|
@@ -597,193 +561,6 @@ declare const db: {
|
|
|
597
561
|
};
|
|
598
562
|
};
|
|
599
563
|
//#endregion
|
|
600
|
-
//#region src/types/auth-connection.generated.d.ts
|
|
601
|
-
type AuthConnectionOAuth2Config = {
|
|
602
|
-
/** OAuth2 provider URL */providerUrl: string; /** OAuth2 issuer URL */
|
|
603
|
-
issuerUrl: string; /** OAuth2 client ID */
|
|
604
|
-
clientId: string; /** OAuth2 client secret */
|
|
605
|
-
clientSecret: string; /** OAuth2 authorization endpoint override */
|
|
606
|
-
authUrl?: string | undefined; /** OAuth2 token endpoint override */
|
|
607
|
-
tokenUrl?: string | undefined;
|
|
608
|
-
};
|
|
609
|
-
type AuthConnectionConfig = {
|
|
610
|
-
type: "oauth2";
|
|
611
|
-
providerUrl: string;
|
|
612
|
-
issuerUrl: string;
|
|
613
|
-
clientId: string;
|
|
614
|
-
clientSecret: string;
|
|
615
|
-
authUrl?: string | undefined;
|
|
616
|
-
tokenUrl?: string | undefined;
|
|
617
|
-
};
|
|
618
|
-
//#endregion
|
|
619
|
-
//#region src/types/auth.d.ts
|
|
620
|
-
type OAuth2ClientGrantType = OAuth2Client["grantTypes"][number];
|
|
621
|
-
type SCIMAttributeType = SCIMAttribute["type"];
|
|
622
|
-
type AuthInvokerWithName<M extends string> = Omit<AuthInvoker, "machineUserName"> & {
|
|
623
|
-
machineUserName: M;
|
|
624
|
-
};
|
|
625
|
-
/** Result of retrieving a connection token at runtime. */
|
|
626
|
-
type AuthConnectionTokenResult = {
|
|
627
|
-
access_token: string;
|
|
628
|
-
refresh_token?: string;
|
|
629
|
-
token_type?: string;
|
|
630
|
-
expiry?: string;
|
|
631
|
-
};
|
|
632
|
-
type AuthAttributeValue = ValueOperand | null | undefined;
|
|
633
|
-
type UserFieldKeys<User extends TailorDBInstance$1> = keyof output<User> & string;
|
|
634
|
-
type FieldDefined<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = User["fields"][Key] extends {
|
|
635
|
-
_defined: infer Defined;
|
|
636
|
-
} ? Defined : never;
|
|
637
|
-
type FieldOutput<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = output<User>[Key];
|
|
638
|
-
type FieldIsRequired<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = undefined extends FieldOutput<User, Key> ? false : true;
|
|
639
|
-
type FieldIsOfType<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>, Type extends string> = FieldDefined<User, Key> extends {
|
|
640
|
-
type: Type;
|
|
641
|
-
} ? true : false;
|
|
642
|
-
type FieldIsArray<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
|
|
643
|
-
array: true;
|
|
644
|
-
} ? true : false;
|
|
645
|
-
type FieldIsUnique<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = FieldDefined<User, Key> extends {
|
|
646
|
-
unique: true;
|
|
647
|
-
} ? true : false;
|
|
648
|
-
type FieldSupportsValueOperand<User extends TailorDBInstance$1, Key extends UserFieldKeys<User>> = FieldOutput<User, Key> extends ValueOperand | null | undefined ? true : false;
|
|
649
|
-
type UsernameFieldKey<User extends TailorDBInstance$1> = IsAny<User> extends true ? string : { [K in UserFieldKeys<User>]: FieldIsRequired<User, K> extends true ? FieldIsOfType<User, K, "string"> extends true ? FieldIsArray<User, K> extends true ? never : FieldIsUnique<User, K> extends true ? K : never : never : never }[UserFieldKeys<User>];
|
|
650
|
-
type UserAttributeKey<User extends TailorDBInstance$1> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldSupportsValueOperand<User, K> extends true ? FieldIsOfType<User, K, "datetime" | "date" | "time"> extends true ? never : K : never }[UserFieldKeys<User>];
|
|
651
|
-
type UserAttributeListKey<User extends TailorDBInstance$1> = { [K in UserFieldKeys<User>]: K extends "id" ? never : FieldIsOfType<User, K, "uuid"> extends true ? FieldIsArray<User, K> extends true ? never : K : never }[UserFieldKeys<User>];
|
|
652
|
-
type UserAttributeMap<User extends TailorDBInstance$1> = { [K in UserAttributeKey<User>]?: true };
|
|
653
|
-
type DisallowExtraKeys<T, Allowed extends PropertyKey> = T & { [K in Exclude<keyof T, Allowed>]: never };
|
|
654
|
-
type AttributeListValue<User extends TailorDBInstance$1, Key extends UserAttributeListKey<User>> = Key extends keyof output<User> ? output<User>[Key] : never;
|
|
655
|
-
type AttributeListToTuple<User extends TailorDBInstance$1, AttributeList extends readonly UserAttributeListKey<User>[]> = { [Index in keyof AttributeList]: AttributeList[Index] extends UserAttributeListKey<User> ? AttributeListValue<User, AttributeList[Index]> : never };
|
|
656
|
-
type AttributeMapSelectedKeys<User extends TailorDBInstance$1, AttributeMap extends UserAttributeMap<User>> = Extract<{ [K in keyof AttributeMap]-?: undefined extends AttributeMap[K] ? never : K }[keyof AttributeMap], UserAttributeKey<User>>;
|
|
657
|
-
type UserProfile<User extends TailorDBInstance$1, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[]> = {
|
|
658
|
-
/**
|
|
659
|
-
* TailorDB namespace where the user type is defined.
|
|
660
|
-
*
|
|
661
|
-
* Usually auto-resolved, so you don't need to specify this.
|
|
662
|
-
* Required only when multiple TailorDBs exist and the type is in an external TailorDB.
|
|
663
|
-
*/
|
|
664
|
-
namespace?: string;
|
|
665
|
-
type: User;
|
|
666
|
-
usernameField: UsernameFieldKey<User>;
|
|
667
|
-
attributes?: DisallowExtraKeys<AttributeMap, UserAttributeKey<User>>;
|
|
668
|
-
attributeList?: AttributeList;
|
|
669
|
-
};
|
|
670
|
-
type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
|
|
671
|
-
type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
|
|
672
|
-
type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never };
|
|
673
|
-
type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
|
|
674
|
-
attributes?: never;
|
|
675
|
-
} : {
|
|
676
|
-
attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
|
|
677
|
-
}) & {
|
|
678
|
-
attributeList?: string[];
|
|
679
|
-
};
|
|
680
|
-
type MachineUser<User extends TailorDBInstance$1, AttributeMap extends UserAttributeMap<User> = UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
|
|
681
|
-
attributes: Record<string, AuthAttributeValue>;
|
|
682
|
-
attributeList?: string[];
|
|
683
|
-
} : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
|
|
684
|
-
attributes?: never;
|
|
685
|
-
} : {
|
|
686
|
-
attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
|
|
687
|
-
}) & ([] extends AttributeList ? {
|
|
688
|
-
attributeList?: never;
|
|
689
|
-
} : {
|
|
690
|
-
attributeList: AttributeListToTuple<User, AttributeList>;
|
|
691
|
-
}) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
|
|
692
|
-
attributes: Record<string, AuthAttributeValue>;
|
|
693
|
-
attributeList?: string[];
|
|
694
|
-
} : (AttributeMapSelectedKeys<User, AttributeMap> extends never ? {
|
|
695
|
-
attributes?: never;
|
|
696
|
-
} : {
|
|
697
|
-
attributes: { [K in AttributeMapSelectedKeys<User, AttributeMap>]: K extends keyof output<User> ? output<User>[K] : never } & { [K in Exclude<keyof output<User>, AttributeMapSelectedKeys<User, AttributeMap>>]?: never };
|
|
698
|
-
}) & ([] extends AttributeList ? {
|
|
699
|
-
attributeList?: never;
|
|
700
|
-
} : {
|
|
701
|
-
attributeList: AttributeListToTuple<User, AttributeList>;
|
|
702
|
-
});
|
|
703
|
-
/** Upstream OAuth provider that federated a login through the Built-in IdP. */
|
|
704
|
-
type FederatedIdentityProvider = "google" | "microsoft";
|
|
705
|
-
/**
|
|
706
|
-
* Profile claims forwarded from the upstream OAuth provider's ID token.
|
|
707
|
-
*
|
|
708
|
-
* Commonly present claims are typed; any other claim the provider issues is
|
|
709
|
-
* forwarded as-is and reachable through the index signature. Availability
|
|
710
|
-
* varies by provider (e.g. Microsoft does not issue `picture`).
|
|
711
|
-
*/
|
|
712
|
-
type FederatedIdentityClaims = {
|
|
713
|
-
name?: string;
|
|
714
|
-
given_name?: string;
|
|
715
|
-
family_name?: string;
|
|
716
|
-
picture?: string;
|
|
717
|
-
locale?: string;
|
|
718
|
-
[claim: string]: JsonValue | undefined;
|
|
719
|
-
};
|
|
720
|
-
/**
|
|
721
|
-
* The upstream identity that federated this login, populated when a user signs
|
|
722
|
-
* in through a Built-in IdP OAuth provider (Google or Microsoft).
|
|
723
|
-
*
|
|
724
|
-
* Available on {@link BeforeLoginClaims.federated_identity}; `undefined` for
|
|
725
|
-
* password logins.
|
|
726
|
-
*/
|
|
727
|
-
type FederatedIdentity = {
|
|
728
|
-
provider: FederatedIdentityProvider;
|
|
729
|
-
claims: FederatedIdentityClaims;
|
|
730
|
-
};
|
|
731
|
-
/**
|
|
732
|
-
* Token claims passed to the {@link BeforeLoginHook} handler. Carries the IdP's
|
|
733
|
-
* own claims (e.g. `sub`, `email`) plus, for federated logins, the upstream
|
|
734
|
-
* provider's profile under {@link BeforeLoginClaims.federated_identity}.
|
|
735
|
-
*/
|
|
736
|
-
type BeforeLoginClaims = JsonObject & {
|
|
737
|
-
/** Present only for federated (Google/Microsoft) logins; `undefined` for password logins. */federated_identity?: FederatedIdentity;
|
|
738
|
-
};
|
|
739
|
-
type BeforeLoginHookArgs = {
|
|
740
|
-
claims: BeforeLoginClaims;
|
|
741
|
-
idpConfigName: string; /** Environment variables defined in `defineConfig({ env })`. */
|
|
742
|
-
env: TailorEnv;
|
|
743
|
-
};
|
|
744
|
-
type BeforeLoginHook<MachineUserNames extends string> = {
|
|
745
|
-
handler(args: BeforeLoginHookArgs): Promise<void>;
|
|
746
|
-
invoker: NoInfer<MachineUserNames>;
|
|
747
|
-
};
|
|
748
|
-
type AuthHooks<MachineUserNames extends string> = {
|
|
749
|
-
beforeLogin?: BeforeLoginHook<MachineUserNames>;
|
|
750
|
-
};
|
|
751
|
-
type AuthServiceInput<User extends TailorDBInstance$1, AttributeMap extends UserAttributeMap<User>, AttributeList extends UserAttributeListKey<User>[], MachineUserNames extends string, MachineUserAttributes extends MachineUserAttributeFields | undefined = MachineUserAttributeFields | undefined, ConnectionNames extends string = string> = {
|
|
752
|
-
hooks?: AuthHooks<MachineUserNames>;
|
|
753
|
-
userProfile?: UserProfile<User, AttributeMap, AttributeList>;
|
|
754
|
-
machineUserAttributes?: MachineUserAttributes;
|
|
755
|
-
machineUsers?: Record<MachineUserNames, MachineUser<User, AttributeMap, AttributeList, MachineUserAttributes>>;
|
|
756
|
-
oauth2Clients?: Record<string, OAuth2ClientInput>;
|
|
757
|
-
idProvider?: IdProvider;
|
|
758
|
-
scim?: SCIMConfig;
|
|
759
|
-
tenantProvider?: TenantProvider;
|
|
760
|
-
connections?: Record<ConnectionNames, AuthConnectionConfig>;
|
|
761
|
-
publishSessionEvents?: boolean;
|
|
762
|
-
};
|
|
763
|
-
declare const authDefinitionBrand: unique symbol;
|
|
764
|
-
type AuthDefinitionBrand = {
|
|
765
|
-
readonly [authDefinitionBrand]: true;
|
|
766
|
-
};
|
|
767
|
-
type ConnectionNames<Config> = Config extends {
|
|
768
|
-
connections?: Record<infer K, unknown>;
|
|
769
|
-
} ? K & string : string;
|
|
770
|
-
type DefinedAuth<Name extends string, Config, MachineUserNames extends string> = Config & {
|
|
771
|
-
name: Name;
|
|
772
|
-
/**
|
|
773
|
-
* @deprecated Pass the machine user name directly as a string instead, e.g. `authInvoker: "machine-user-name"`.
|
|
774
|
-
* Using this function pulls config-layer (Node-only) dependencies into runtime bundles.
|
|
775
|
-
*/
|
|
776
|
-
invoker<M extends MachineUserNames>(machineUser: M): AuthInvokerWithName<M>;
|
|
777
|
-
getConnectionToken<C extends ConnectionNames<Config>>(connectionName: C): Promise<AuthConnectionTokenResult>;
|
|
778
|
-
} & AuthDefinitionBrand;
|
|
779
|
-
type AuthExternalConfig = {
|
|
780
|
-
name: string;
|
|
781
|
-
external: true;
|
|
782
|
-
};
|
|
783
|
-
type AuthServiceInputLoose = AuthServiceInput<any, any, any, string, any>;
|
|
784
|
-
type AuthOwnConfig = DefinedAuth<string, AuthServiceInputLoose, string>;
|
|
785
|
-
type AuthConfig = AuthOwnConfig | AuthExternalConfig;
|
|
786
|
-
//#endregion
|
|
787
564
|
//#region src/types/aigateway.generated.d.ts
|
|
788
565
|
type AIGateway = {
|
|
789
566
|
/** AI Gateway name */name: string; /** Auth namespace used to resolve request tokens against the workspace's auth */
|
|
@@ -792,7 +569,7 @@ type AIGateway = {
|
|
|
792
569
|
};
|
|
793
570
|
type AIGatewayInput = AIGateway;
|
|
794
571
|
//#endregion
|
|
795
|
-
//#region src/
|
|
572
|
+
//#region src/configure/services/aigateway/types.d.ts
|
|
796
573
|
declare const aiGatewayDefinitionBrand: unique symbol;
|
|
797
574
|
type AIGatewayDefinitionBrand = {
|
|
798
575
|
readonly [aiGatewayDefinitionBrand]: true;
|
|
@@ -800,9 +577,6 @@ type AIGatewayDefinitionBrand = {
|
|
|
800
577
|
/** Type accepted by `AppConfig.aiGateways`. Only values returned by `defineAIGateway()` satisfy this. */
|
|
801
578
|
type AIGatewayConfig = AIGatewayInput & AIGatewayDefinitionBrand;
|
|
802
579
|
//#endregion
|
|
803
|
-
//#region src/types/app-config.generated.d.ts
|
|
804
|
-
type LogLevelEnum = "DEBUG" | "INFO" | "WARN" | "ERROR" | "SILENT";
|
|
805
|
-
//#endregion
|
|
806
580
|
//#region src/types/idp.generated.d.ts
|
|
807
581
|
/**
|
|
808
582
|
* Configuration for GraphQL operations on IdP users.
|
|
@@ -1291,7 +1065,7 @@ type IdPInput = {
|
|
|
1291
1065
|
} | undefined;
|
|
1292
1066
|
};
|
|
1293
1067
|
//#endregion
|
|
1294
|
-
//#region src/
|
|
1068
|
+
//#region src/configure/services/idp/types.d.ts
|
|
1295
1069
|
declare const idpDefinitionBrand: unique symbol;
|
|
1296
1070
|
type IdpDefinitionBrand = {
|
|
1297
1071
|
readonly [idpDefinitionBrand]: true;
|
|
@@ -1306,7 +1080,6 @@ type IdPExternalConfig = {
|
|
|
1306
1080
|
};
|
|
1307
1081
|
type IdPOwnConfig = Omit<DefinedIdp<string, IdPInput, string>, "provider">;
|
|
1308
1082
|
type IdPConfig = IdPOwnConfig | IdPExternalConfig;
|
|
1309
|
-
type IdPUserField = "id" | "name" | "disabled";
|
|
1310
1083
|
//#endregion
|
|
1311
1084
|
//#region src/types/secrets.generated.d.ts
|
|
1312
1085
|
type Secrets = {
|
|
@@ -1321,7 +1094,7 @@ type Secrets = {
|
|
|
1321
1094
|
};
|
|
1322
1095
|
type SecretsInput = Secrets;
|
|
1323
1096
|
//#endregion
|
|
1324
|
-
//#region src/
|
|
1097
|
+
//#region src/configure/services/secrets/types.d.ts
|
|
1325
1098
|
declare const secretsDefinitionBrand: unique symbol;
|
|
1326
1099
|
type SecretsDefinitionBrand = {
|
|
1327
1100
|
readonly [secretsDefinitionBrand]: true;
|
|
@@ -1338,7 +1111,7 @@ type StaticWebsite = {
|
|
|
1338
1111
|
};
|
|
1339
1112
|
type StaticWebsiteInput = StaticWebsite;
|
|
1340
1113
|
//#endregion
|
|
1341
|
-
//#region src/
|
|
1114
|
+
//#region src/configure/services/staticwebsite/types.d.ts
|
|
1342
1115
|
declare const staticWebsiteDefinitionBrand: unique symbol;
|
|
1343
1116
|
type StaticWebsiteDefinitionBrand = {
|
|
1344
1117
|
readonly [staticWebsiteDefinitionBrand]: true;
|
|
@@ -1346,7 +1119,10 @@ type StaticWebsiteDefinitionBrand = {
|
|
|
1346
1119
|
/** Type accepted by `AppConfig.staticWebsites`. Only values returned by `defineStaticWebSite()` satisfy this. */
|
|
1347
1120
|
type StaticWebsiteConfig = StaticWebsiteInput & StaticWebsiteDefinitionBrand;
|
|
1348
1121
|
//#endregion
|
|
1349
|
-
//#region src/types/app-config.d.ts
|
|
1122
|
+
//#region src/types/app-config.generated.d.ts
|
|
1123
|
+
type LogLevelEnum = "DEBUG" | "INFO" | "WARN" | "ERROR" | "SILENT";
|
|
1124
|
+
//#endregion
|
|
1125
|
+
//#region src/configure/config/types.d.ts
|
|
1350
1126
|
type LogLevel = LogLevelEnum;
|
|
1351
1127
|
type LogLevelInput = LogLevel | (string & {});
|
|
1352
1128
|
type ExecutorServiceConfig = {
|
|
@@ -1467,5 +1243,5 @@ type ConcurrencyPolicy = {
|
|
|
1467
1243
|
/** Maximum number of concurrent executions (1-1000) */maxConcurrentExecutions: number;
|
|
1468
1244
|
};
|
|
1469
1245
|
//#endregion
|
|
1470
|
-
export {
|
|
1471
|
-
//# sourceMappingURL=workflow.generated
|
|
1246
|
+
export { TailorDBInstance as A, IdPInput as C, TailorAnyDBField as D, AIGatewayInput as E, TailorTypePermission as F, unsafeAllowAllGqlPermission as I, unsafeAllowAllTypePermission as L, db as M, PermissionCondition as N, TailorAnyDBType as O, TailorTypeGqlPermission as P, AllowedValues as R, IdPGqlOperationsInput as S, AIGatewayDefinitionBrand as T, IdPConfig as _, ExecutorServiceConfig as a, IdPEmailConfig as b, ResolverServiceConfig as c, WorkflowServiceInput as d, StaticWebsiteConfig as f, SecretsDefinitionBrand as g, SecretsConfig as h, AppConfig as i, TailorDBType as j, TailorDBField as k, ResolverServiceInput as l, StaticWebsiteInput as m, RetryPolicy as n, ExecutorServiceInput as o, StaticWebsiteDefinitionBrand as p, HttpAdapterConfigInput as r, ResolverExternalConfig as s, ConcurrencyPolicy as t, WorkflowServiceConfig as u, IdPExternalConfig as v, AIGatewayConfig as w, IdPGqlOperations as x, IdpDefinitionBrand as y, AllowedValuesOutput as z };
|
|
1247
|
+
//# sourceMappingURL=workflow.generated-1S50BhEb.d.mts.map
|
package/docs/cli-reference.md
CHANGED
|
@@ -65,23 +65,24 @@ tailor-sdk deploy --env-file .env --env-file .env.production
|
|
|
65
65
|
|
|
66
66
|
You can use environment variables to configure workspace and authentication:
|
|
67
67
|
|
|
68
|
-
| Variable | Description
|
|
69
|
-
| -------------------------------------------- |
|
|
70
|
-
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands
|
|
71
|
-
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands
|
|
72
|
-
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands
|
|
73
|
-
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`)
|
|
74
|
-
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead
|
|
75
|
-
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name
|
|
76
|
-
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file
|
|
77
|
-
| `TAILOR_PLATFORM_SDK_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file
|
|
78
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user`
|
|
79
|
-
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user`
|
|
80
|
-
| `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run`, `machineuser token`
|
|
81
|
-
| `TAILOR_BUNDLE_CONCURRENCY` | Max concurrent bundle workers for `deploy` (resolvers/executors/workflows). Defaults to CPU count
|
|
82
|
-
| `
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
68
|
+
| Variable | Description |
|
|
69
|
+
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
|
|
70
|
+
| `TAILOR_PLATFORM_WORKSPACE_ID` | Workspace ID for deployment commands |
|
|
71
|
+
| `TAILOR_PLATFORM_ORGANIZATION_ID` | Organization ID for organization commands |
|
|
72
|
+
| `TAILOR_PLATFORM_FOLDER_ID` | Folder ID for folder commands |
|
|
73
|
+
| `TAILOR_PLATFORM_TOKEN` | Authentication token (alternative to `login`) |
|
|
74
|
+
| `TAILOR_TOKEN` | **Deprecated.** Use `TAILOR_PLATFORM_TOKEN` instead |
|
|
75
|
+
| `TAILOR_PLATFORM_PROFILE` | Workspace profile name |
|
|
76
|
+
| `TAILOR_PLATFORM_SDK_CONFIG_PATH` | Path to SDK config file |
|
|
77
|
+
| `TAILOR_PLATFORM_SDK_DTS_PATH` | Output path for generated `tailor.d.ts` type definition file |
|
|
78
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_ID` | Client ID for `login --machine-user` |
|
|
79
|
+
| `TAILOR_PLATFORM_MACHINE_USER_CLIENT_SECRET` | Client secret for `login --machine-user` |
|
|
80
|
+
| `TAILOR_PLATFORM_MACHINE_USER_NAME` | Default machine user name for `query`, `workflow start`, `function test-run`, `machineuser token` |
|
|
81
|
+
| `TAILOR_BUNDLE_CONCURRENCY` | Max concurrent bundle workers for `deploy` (resolvers/executors/workflows). Defaults to CPU count |
|
|
82
|
+
| `TAILOR_APPLY_CONCURRENCY` | Max concurrent unary platform RPCs during `apply`/`deploy` (streaming uploads are not gated). Defaults to 16 |
|
|
83
|
+
| `VISUAL` / `EDITOR` | Preferred editor for commands that open files (e.g., `vim`, `code`, `nano`) |
|
|
84
|
+
| `TAILOR_CRASH_REPORTS_LOCAL` | Local crash log writing: `on` (default) or `off` |
|
|
85
|
+
| `TAILOR_CRASH_REPORTS_REMOTE` | Automatic crash report submission: `off` (default) or `on` |
|
|
85
86
|
|
|
86
87
|
### Authentication Token Priority
|
|
87
88
|
|
package/docs/github-actions.md
CHANGED
|
@@ -148,8 +148,8 @@ edit or rename them — the SDK tracks them by id.
|
|
|
148
148
|
|
|
149
149
|
You can add your own jobs and steps around the managed ones. To add
|
|
150
150
|
project-specific setup (such as private registry authentication or a system
|
|
151
|
-
dependency), add a step _before_ the managed setup
|
|
152
|
-
extras (such as `playwright install`), add a step _after_
|
|
151
|
+
dependency), add a step _before_ the managed `tailor-setup` step. For
|
|
152
|
+
post-install extras (such as `playwright install`), add a step _after_ it.
|
|
153
153
|
|
|
154
154
|
Note that re-running `setup github` currently regenerates the whole file: if
|
|
155
155
|
the file differs from what the SDK last wrote — whether you edited a managed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.67.0",
|
|
4
4
|
"description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -135,12 +135,12 @@
|
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
137
|
"dependencies": {
|
|
138
|
-
"@0no-co/graphql.web": "1.2
|
|
138
|
+
"@0no-co/graphql.web": "1.3.2",
|
|
139
139
|
"@badgateway/oauth2-client": "3.3.1",
|
|
140
140
|
"@bufbuild/protobuf": "2.12.0",
|
|
141
141
|
"@bufbuild/protovalidate": "1.2.0",
|
|
142
|
-
"@connectrpc/connect": "2.1.
|
|
143
|
-
"@connectrpc/connect-node": "2.1.
|
|
142
|
+
"@connectrpc/connect": "2.1.2",
|
|
143
|
+
"@connectrpc/connect-node": "2.1.2",
|
|
144
144
|
"@inquirer/core": "11.2.1",
|
|
145
145
|
"@inquirer/prompts": "8.5.2",
|
|
146
146
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
@@ -160,10 +160,10 @@
|
|
|
160
160
|
"chokidar": "5.0.0",
|
|
161
161
|
"confbox": "0.2.4",
|
|
162
162
|
"date-fns": "4.4.0",
|
|
163
|
-
"es-toolkit": "1.47.
|
|
163
|
+
"es-toolkit": "1.47.1",
|
|
164
164
|
"find-up-simple": "1.0.1",
|
|
165
165
|
"globals": "17.6.0",
|
|
166
|
-
"graphql": "16.14.
|
|
166
|
+
"graphql": "16.14.2",
|
|
167
167
|
"inflection": "3.0.2",
|
|
168
168
|
"kysely": "0.29.2",
|
|
169
169
|
"madge": "8.0.0",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"pgsql-ast-parser": "12.0.2",
|
|
176
176
|
"pkg-types": "2.3.1",
|
|
177
177
|
"politty": "0.6.0",
|
|
178
|
-
"rolldown": "1.1.
|
|
178
|
+
"rolldown": "1.1.1",
|
|
179
179
|
"semver": "7.8.4",
|
|
180
180
|
"sql-highlight": "6.1.0",
|
|
181
181
|
"std-env": "4.1.0",
|
|
@@ -193,12 +193,12 @@
|
|
|
193
193
|
"@types/mime-types": "3.0.1",
|
|
194
194
|
"@types/node": "24.13.2",
|
|
195
195
|
"@types/semver": "7.7.1",
|
|
196
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
196
|
+
"@typescript/native-preview": "7.0.0-dev.20260613.1",
|
|
197
197
|
"@vitest/coverage-v8": "4.1.8",
|
|
198
198
|
"oxfmt": "0.54.0",
|
|
199
199
|
"oxlint": "1.69.0",
|
|
200
200
|
"oxlint-tsgolint": "0.23.0",
|
|
201
|
-
"sonda": "0.
|
|
201
|
+
"sonda": "0.13.0",
|
|
202
202
|
"tsdown": "0.22.2",
|
|
203
203
|
"typescript": "5.9.3",
|
|
204
204
|
"vitest": "4.1.8",
|
|
@@ -230,6 +230,8 @@
|
|
|
230
230
|
"build": "tsdown && politty generate-worker --bin dist/cli/index.mjs --program tailor-sdk --shell zsh --verify",
|
|
231
231
|
"lint": "oxlint --type-aware .",
|
|
232
232
|
"check:public-api-jsdoc": "tsx scripts/check-public-api-jsdoc.ts",
|
|
233
|
+
"check:zod-isolation": "tsx scripts/check-zod-isolation.ts",
|
|
234
|
+
"check:import-cycles": "tsx scripts/check-import-cycles.ts",
|
|
233
235
|
"lint:fix": "oxlint --type-aware . --fix",
|
|
234
236
|
"typecheck": "tsc --noEmit",
|
|
235
237
|
"typecheck:go": "tsgo",
|