@tailor-platform/sdk 2.0.0-next.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +631 -0
- package/dist/{application-GzW98_Xr.mjs → application-CM6hKnSK.mjs} +489 -118
- package/dist/application-CM6hKnSK.mjs.map +1 -0
- package/dist/application-CXNaUNhv.mjs +3 -0
- package/dist/cli/commands/deploy/aigateway.d.mts +2 -2
- package/dist/cli/commands/deploy/application.d.mts +2 -2
- package/dist/cli/commands/deploy/auth.d.mts +2 -2
- package/dist/cli/commands/deploy/deploy.d.mts +1 -0
- package/dist/cli/commands/deploy/executor.d.mts +2 -2
- package/dist/cli/commands/deploy/function-registry.d.mts +1 -2
- package/dist/cli/commands/deploy/idp.d.mts +2 -2
- package/dist/cli/commands/deploy/label.d.mts +2 -0
- package/dist/cli/commands/deploy/resolver.d.mts +2 -2
- package/dist/cli/commands/deploy/secret-manager.d.mts +1 -1
- package/dist/cli/commands/deploy/staticwebsite.d.mts +2 -2
- package/dist/cli/commands/deploy/tailordb/index.d.mts +4 -2
- package/dist/cli/commands/deploy/types.d.mts +2 -1
- package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -2
- package/dist/cli/commands/deploy/workflow.d.mts +2 -2
- package/dist/cli/commands/executor/get.d.mts +1 -10
- package/dist/cli/commands/executor/jobs.d.mts +1 -38
- package/dist/cli/commands/executor/trigger.d.mts +1 -11
- package/dist/cli/commands/generate/seed/bundler.d.mts +2 -1
- package/dist/cli/commands/tailordb/migrate/bundler.d.mts +3 -2
- package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +11 -1
- package/dist/cli/commands/tailordb/migrate/schema-checks.d.mts +5 -0
- package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -1
- package/dist/cli/commands/workflow/executions.d.mts +1 -13
- package/dist/cli/commands/workflow/get.d.mts +1 -10
- package/dist/cli/commands/workflow/start.d.mts +2 -14
- package/dist/cli/index.mjs +12 -6552
- package/dist/cli/lib.d.mts +14 -15
- package/dist/cli/lib.mjs +203 -46
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/cli/{index.d.mts → main.d.mts} +1 -1
- package/dist/cli/main.mjs +6777 -0
- package/dist/cli/main.mjs.map +1 -0
- package/dist/cli/services/http-adapter/bundler.d.mts +1 -0
- package/dist/cli/services/workflow/bundler.d.mts +2 -1
- package/dist/cli/shared/client.d.mts +28 -3
- package/dist/cli/shared/config-loader.d.mts +11 -4
- package/dist/cli/shared/error-json.d.mts +23 -0
- package/dist/cli/shared/script-executor.d.mts +6 -3
- package/dist/cli/shared/seed-chunker.d.mts +2 -7
- package/dist/cli/shared/seed-context.d.mts +49 -0
- package/dist/cli/shared/tailordb-namespaces.d.mts +7 -4
- package/dist/cli/shared/tsconfig-paths-plugin.d.mts +2 -0
- package/dist/cli/shared/type-generator.d.mts +4 -3
- package/dist/completion/zsh-worker.zsh +85 -22
- package/dist/configure/config/types.d.mts +29 -4
- package/dist/configure/index.d.mts +4 -3
- package/dist/configure/index.mjs +183 -6
- package/dist/configure/index.mjs.map +1 -1
- package/dist/configure/services/executor/index.d.mts +2 -2
- package/dist/configure/services/executor/trigger/event.d.mts +245 -2
- package/dist/configure/services/executor/trigger/index.d.mts +3 -3
- package/dist/configure/services/idp/index.d.mts +2 -2
- package/dist/configure/services/idp/permission.d.mts +1 -16
- package/dist/configure/services/idp/types.d.mts +5 -1
- package/dist/configure/services/index.d.mts +4 -3
- package/dist/configure/services/resolver/index.d.mts +2 -1
- package/dist/configure/services/resolver/permission.d.mts +64 -0
- package/dist/configure/services/resolver/resolver.d.mts +14 -2
- package/dist/configure/services/tailordb/index.d.mts +0 -1
- package/dist/configure/services/tailordb/permission.d.mts +1 -16
- package/dist/configure/services/workflow/execution-policy.d.mts +3 -3
- package/dist/configure/services/workflow/execution-policy.types.d.mts +1 -1
- package/dist/configure/services/workflow/job.d.mts +11 -2
- package/dist/configure/services/workflow/workflow.d.mts +10 -0
- package/dist/configure/types/permission-operand.types.d.mts +20 -0
- package/dist/{crashreport-CxHne11E.mjs → crashreport-B5LqCTfF.mjs} +2 -2
- package/dist/{crashreport-CxHne11E.mjs.map → crashreport-B5LqCTfF.mjs.map} +1 -1
- package/dist/{crashreport-0ioNRZ4K.mjs → crashreport-eI7ty7ok.mjs} +1 -1
- package/dist/{errors-DfnF4ibq.mjs → errors-D7583Zz7.mjs} +2 -44
- package/dist/errors-D7583Zz7.mjs.map +1 -0
- package/dist/{globals-CBZ0egXT.mjs → globals-TfAVItuK.mjs} +21 -5
- package/dist/globals-TfAVItuK.mjs.map +1 -0
- package/dist/logger-BtX0suGY.mjs +48 -0
- package/dist/logger-BtX0suGY.mjs.map +1 -0
- package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
- package/dist/logger-CXQq9YIp.mjs.map +1 -0
- package/dist/node-builtins-CmaL2Cbq.mjs +36 -0
- package/dist/node-builtins-CmaL2Cbq.mjs.map +1 -0
- package/dist/plugin/builtin/enum-constants/index.mjs +115 -2
- package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -0
- package/dist/plugin/builtin/file-utils/index.mjs +149 -2
- package/dist/plugin/builtin/file-utils/index.mjs.map +1 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +274 -2
- package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -0
- package/dist/plugin/builtin/seed/index.d.mts +3 -2
- package/dist/plugin/builtin/seed/index.mjs +1 -1
- package/dist/plugin/builtin/seed/seed-type-processor.d.mts +21 -0
- package/dist/plugin/builtin/seed/types.d.mts +2 -0
- package/dist/{register-ts-hook-DvEs6YsL.mjs → register-ts-hook-LYV7zH-e.mjs} +2953 -996
- package/dist/register-ts-hook-LYV7zH-e.mjs.map +1 -0
- package/dist/{registry-i7EdJ-D5.mjs → registry-BIGVUrMB.mjs} +3 -3
- package/dist/registry-BIGVUrMB.mjs.map +1 -0
- package/dist/runtime/globals.d.mts +7 -0
- package/dist/runtime/index.d.mts +3 -1
- package/dist/runtime/index.mjs +3 -2
- package/dist/runtime/logger.d.mts +98 -0
- package/dist/runtime/logger.mjs +3 -0
- package/dist/runtime/workflow.d.mts +15 -7
- package/dist/runtime/workflow.mjs +1 -1
- package/dist/seed-B-yckgQY.mjs +483 -0
- package/dist/seed-B-yckgQY.mjs.map +1 -0
- package/dist/{service-DaeJlBoH.mjs → service-B5WynBHQ.mjs} +3 -3
- package/dist/{service-DaeJlBoH.mjs.map → service-B5WynBHQ.mjs.map} +1 -1
- package/dist/service-M7OYziQP.mjs +3 -0
- package/dist/{service-Dmxa2I4i.mjs → service-k1xy_A5G.mjs} +30 -4
- package/dist/service-k1xy_A5G.mjs.map +1 -0
- package/dist/{service_pb-BoLM0X4K.mjs → service_pb-D5--My_M.mjs} +5 -5
- package/dist/service_pb-D5--My_M.mjs.map +1 -0
- package/dist/{service_pb-r1T7kpJc.mjs → service_pb-i8CmnQP4.mjs} +1 -1
- package/dist/tailor-proto/src/tailor/v1/application_pb.d.mts +106 -1
- package/dist/tailor-proto/src/tailor/v1/auth_resource_pb.d.mts +6 -1
- package/dist/tailor-proto/src/tailor/v1/executor_resource_pb.d.mts +24 -1
- package/dist/tailor-proto/src/tailor/v1/function_pb.d.mts +49 -1
- package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +89 -6
- package/dist/tailor-proto/src/tailor/v1/telemetryrouter_resource_pb.d.mts +26 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +101 -1
- package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +22 -1
- package/dist/types/auth.generated.d.mts +14 -2
- package/dist/types/executor.generated.d.mts +45 -3
- package/dist/types/http-adapter.generated.d.mts +5 -0
- package/dist/types/idp.generated.d.mts +31 -1
- package/dist/types/resolver.generated.d.mts +30 -2
- package/dist/types/tailordb.generated.d.mts +15 -3
- package/dist/utils/test/index.d.mts +1 -2
- package/dist/utils/test/index.mjs +1 -169
- package/dist/utils/test/index.mjs.map +1 -1
- package/dist/vitest/environment.mjs +1 -1
- package/dist/vitest/index.d.mts +6 -4
- package/dist/vitest/index.mjs +112 -62
- package/dist/vitest/index.mjs.map +1 -1
- package/dist/vitest/mock.d.mts +2 -1
- package/dist/vitest/mocks/logger.d.mts +45 -0
- package/dist/vitest/mocks/workflow.d.mts +8 -8
- package/dist/vitest/setup.mjs +1 -1
- package/dist/{workflow-CsBvRE3g.mjs → workflow-Bamae_Yc.mjs} +5 -5
- package/dist/workflow-Bamae_Yc.mjs.map +1 -0
- package/dist/{workspace_resource_pb-Db3fv68L.mjs → workspace_resource_pb-DXnO2AT-.mjs} +13 -8
- package/dist/workspace_resource_pb-DXnO2AT-.mjs.map +1 -0
- package/docs/cli/application.md +5 -1
- package/docs/cli/tailordb.md +47 -13
- package/docs/cli-reference.md +38 -30
- package/docs/configuration.md +54 -2
- package/docs/github-actions.md +2 -2
- package/docs/migration/v2.md +408 -5
- package/docs/runtime.md +5 -1
- package/docs/services/executor.md +83 -3
- package/docs/services/idp.md +8 -6
- package/docs/services/resolver.md +60 -4
- package/docs/services/tailordb-migration.md +31 -7
- package/docs/services/tailordb.md +7 -5
- package/docs/services/workflow.md +33 -3
- package/docs/testing.md +34 -7
- package/package.json +31 -24
- package/dist/application-GzW98_Xr.mjs.map +0 -1
- package/dist/application-OM0taSPn.mjs +0 -3
- package/dist/cli/index.mjs.map +0 -1
- package/dist/enum-constants-j9QBF0cB.mjs +0 -116
- package/dist/enum-constants-j9QBF0cB.mjs.map +0 -1
- package/dist/errors-DfnF4ibq.mjs.map +0 -1
- package/dist/file-utils-yEiIS4nJ.mjs +0 -150
- package/dist/file-utils-yEiIS4nJ.mjs.map +0 -1
- package/dist/globals-CBZ0egXT.mjs.map +0 -1
- package/dist/kysely-type-DqIRgDYR.mjs +0 -275
- package/dist/kysely-type-DqIRgDYR.mjs.map +0 -1
- package/dist/logger-BwS4ppwO.mjs.map +0 -1
- package/dist/register-ts-hook-DvEs6YsL.mjs.map +0 -1
- package/dist/registry-i7EdJ-D5.mjs.map +0 -1
- package/dist/seed-CRSQJI_z.mjs +0 -1170
- package/dist/seed-CRSQJI_z.mjs.map +0 -1
- package/dist/service-BJAQ70e5.mjs +0 -3
- package/dist/service-Dmxa2I4i.mjs.map +0 -1
- package/dist/service_pb-BoLM0X4K.mjs.map +0 -1
- package/dist/utils/test/mock.d.mts +0 -86
- package/dist/workflow-CsBvRE3g.mjs.map +0 -1
- package/dist/workspace_resource_pb-Db3fv68L.mjs.map +0 -1
|
@@ -12,7 +12,7 @@ function jobs() {
|
|
|
12
12
|
/**
|
|
13
13
|
* Register a job body keyed by job name. Called as a side effect by
|
|
14
14
|
* `createWorkflowJob` so `runWorkflowLocally()` can execute dependent job
|
|
15
|
-
* bodies when `globalThis.tailor.workflow.
|
|
15
|
+
* bodies when `globalThis.tailor.workflow.execJobFunction(name, args)` is invoked.
|
|
16
16
|
*
|
|
17
17
|
* In production builds the bundler rewrites `.start()` calls so this registry
|
|
18
18
|
* is never read; the gated write is dropped as dead code.
|
|
@@ -41,7 +41,7 @@ function requirePlatformWorkflow() {
|
|
|
41
41
|
const START_DEFAULT = "00000000-0000-4000-8000-000000000000";
|
|
42
42
|
function dispatchStartJob(name, args, options) {
|
|
43
43
|
const workflow = requirePlatformWorkflow();
|
|
44
|
-
return arguments.length >= 3 ? workflow.
|
|
44
|
+
return arguments.length >= 3 ? workflow.execJobFunction(name, args, options) : workflow.execJobFunction(name, args);
|
|
45
45
|
}
|
|
46
46
|
function dispatchStartWorkflow(name, args, options) {
|
|
47
47
|
const workflow = requirePlatformWorkflow();
|
|
@@ -51,4 +51,4 @@ function dispatchStartWorkflow(name, args, options) {
|
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
export { registerJob as a, getRegisteredJob as i, dispatchStartJob as n, dispatchStartWorkflow as r, START_DEFAULT as t };
|
|
54
|
-
//# sourceMappingURL=registry-
|
|
54
|
+
//# sourceMappingURL=registry-BIGVUrMB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-BIGVUrMB.mjs","names":[],"sources":["../src/configure/services/workflow/registry.ts"],"sourcesContent":["import type { TailorEnv, TailorPrincipal } from \"#/runtime/types\";\nimport type { ExecJobFunctionOptions, StartWorkflowOptions } from \"#/runtime/workflow\";\n\n/**\n * Body signature shared by workflow jobs at registry-write time.\n * The user's `createWorkflowJob`/`createWorkflow` body uses concrete types,\n * but the registry erases them for storage.\n */\nexport type RegisteredJobBody = (\n args: unknown,\n context: { env: TailorEnv; invoker: TailorPrincipal | null },\n) => unknown | Promise<unknown>;\n\nconst JOB_REGISTRY_KEY: unique symbol = Symbol.for(\"tailor-platform/sdk:job-registry\");\n\ntype PlatformWorkflow = {\n startWorkflow: (name: string, args?: unknown, options?: StartWorkflowOptions) => Promise<string>;\n execJobFunction: (name: string, args?: unknown, options?: ExecJobFunctionOptions) => unknown;\n};\n\ntype GlobalWithRegistry = typeof globalThis & {\n [JOB_REGISTRY_KEY]?: Map<string, RegisteredJobBody>;\n tailor?: { workflow?: PlatformWorkflow };\n};\n\nfunction jobs(): Map<string, RegisteredJobBody> {\n const g = globalThis as GlobalWithRegistry;\n let map = g[JOB_REGISTRY_KEY];\n if (!map) {\n map = new Map();\n g[JOB_REGISTRY_KEY] = map;\n }\n return map;\n}\n\n/**\n * Register a job body keyed by job name. Called as a side effect by\n * `createWorkflowJob` so `runWorkflowLocally()` can execute dependent job\n * bodies when `globalThis.tailor.workflow.execJobFunction(name, args)` is invoked.\n *\n * In production builds the bundler rewrites `.start()` calls so this registry\n * is never read; the gated write is dropped as dead code.\n * @param name - Job name\n * @param body - Job body function\n */\nexport function registerJob(name: string, body: RegisteredJobBody): void {\n jobs().set(name, body);\n}\n\n/**\n * Look up a registered job body by name.\n * @param name - Job name\n * @returns The registered body, or undefined when no job is registered\n */\nexport function getRegisteredJob(name: string): RegisteredJobBody | undefined {\n return jobs().get(name);\n}\n\nfunction currentPlatformWorkflow(): PlatformWorkflow | undefined {\n // globalThis may not have the tailor property at runtime\n // oxlint-disable-next-line typescript/no-unnecessary-condition\n return (globalThis as GlobalWithRegistry).tailor?.workflow;\n}\n\nfunction requirePlatformWorkflow(): PlatformWorkflow {\n const workflow = currentPlatformWorkflow();\n if (!workflow) {\n throw new Error(\n \"tailor.workflow is not available. Run tests in the `tailor-runtime` Vitest environment and use mockWorkflow(), or use runWorkflowLocally() from @tailor-platform/sdk/vitest for local workflow execution.\",\n );\n }\n return workflow;\n}\n\n// A valid placeholder UUID, so callers that validate the execution id behave the\n// same locally as against the platform.\nexport const START_DEFAULT = \"00000000-0000-4000-8000-000000000000\";\n\n// `.start()` routes through the installed `tailor.workflow` shim. Local body\n// execution is intentionally available only through `runWorkflowLocally()`.\n// Preserve arity: the shim sees a 2-argument call when the caller supplied no\n// options, and a 3-argument call otherwise, mirroring the bundler rewrite so\n// mocks observe the same shape in local execution and in bundled workflows.\nexport function dispatchStartJob(\n name: string,\n args?: unknown,\n options?: ExecJobFunctionOptions,\n): unknown {\n const workflow = requirePlatformWorkflow();\n // oxlint-disable-next-line prefer-rest-params\n return arguments.length >= 3\n ? workflow.execJobFunction(name, args, options)\n : workflow.execJobFunction(name, args);\n}\n\n// Accepts `unknown` because the SDK-side `.start()` accepts a wider options\n// shape than the platform surface (e.g. `authInvoker` may be a machine-user\n// name string that the bundler normalizes at build time). Local execution\n// forwards the value verbatim; only the bundled path enforces the platform\n// contract.\nexport function dispatchStartWorkflow(\n name: string,\n args?: unknown,\n options?: { invoker?: unknown },\n): Promise<string> {\n const workflow = requirePlatformWorkflow();\n // oxlint-disable-next-line prefer-rest-params\n if (arguments.length < 3) {\n return workflow.startWorkflow(name, args);\n }\n return workflow.startWorkflow(\n name,\n args,\n options?.invoker === undefined\n ? (options as StartWorkflowOptions | undefined)\n : ({ authInvoker: options.invoker } as StartWorkflowOptions),\n );\n}\n"],"mappings":";AAaA,MAAM,mBAAkC,OAAO,IAAI,kCAAkC;AAYrF,SAAS,OAAuC;CAC9C,MAAM,IAAI;CACV,IAAI,MAAM,EAAE;CACZ,IAAI,CAAC,KAAK;EACR,sBAAM,IAAI,IAAI;EACd,EAAE,oBAAoB;CACxB;CACA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,YAAY,MAAc,MAA+B;CACvE,KAAK,CAAC,CAAC,IAAI,MAAM,IAAI;AACvB;;;;;;AAOA,SAAgB,iBAAiB,MAA6C;CAC5E,OAAO,KAAK,CAAC,CAAC,IAAI,IAAI;AACxB;AAEA,SAAS,0BAAwD;CAG/D,OAAQ,WAAkC,QAAQ;AACpD;AAEA,SAAS,0BAA4C;CACnD,MAAM,WAAW,wBAAwB;CACzC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,2MACF;CAEF,OAAO;AACT;AAIA,MAAa,gBAAgB;AAO7B,SAAgB,iBACd,MACA,MACA,SACS;CACT,MAAM,WAAW,wBAAwB;CAEzC,OAAO,UAAU,UAAU,IACvB,SAAS,gBAAgB,MAAM,MAAM,OAAO,IAC5C,SAAS,gBAAgB,MAAM,IAAI;AACzC;AAOA,SAAgB,sBACd,MACA,MACA,SACiB;CACjB,MAAM,WAAW,wBAAwB;CAEzC,IAAI,UAAU,SAAS,GACrB,OAAO,SAAS,cAAc,MAAM,IAAI;CAE1C,OAAO,SAAS,cACd,MACA,MACA,SAAS,YAAY,SAChB,UACA,EAAE,aAAa,QAAQ,QAAQ,CACtC;AACF"}
|
|
@@ -3,6 +3,7 @@ import { ContextInvoker } from "./context.mjs";
|
|
|
3
3
|
import { TailorDBFileErrorCode } from "./file.mjs";
|
|
4
4
|
import { IconvInstance } from "./iconv.mjs";
|
|
5
5
|
import { ClientConfig, CreateUserInput, IdpClientInstance, ListUsersOptions, ListUsersResponse, SendPasswordResetEmailInput, UnenrollMfaInput, UpdateUserInput, User, UserQuery } from "./idp.mjs";
|
|
6
|
+
import { LogAttributeValue, LogAttributes } from "./logger.mjs";
|
|
6
7
|
import { TailorRuntime, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime } from "./index.mjs";
|
|
7
8
|
//#region src/runtime/globals.d.ts
|
|
8
9
|
type TailorIdpClientConfig = ClientConfig;
|
|
@@ -17,6 +18,8 @@ type TailorIdpUser = User;
|
|
|
17
18
|
type TailorIdpUserQuery = UserQuery;
|
|
18
19
|
type TailorWorkflowInvoker = Invoker;
|
|
19
20
|
type TailorWorkflowStartWorkflowOptions = StartWorkflowOptions;
|
|
21
|
+
type TailorLoggerLogAttributeValue = LogAttributeValue;
|
|
22
|
+
type TailorLoggerLogAttributes = LogAttributes;
|
|
20
23
|
declare global {
|
|
21
24
|
namespace tailordb {
|
|
22
25
|
type QueryResult<T> = TailordbQueryResult<T>;
|
|
@@ -47,6 +50,10 @@ declare global {
|
|
|
47
50
|
namespace context {
|
|
48
51
|
type Invoker = ContextInvoker;
|
|
49
52
|
}
|
|
53
|
+
namespace logger {
|
|
54
|
+
type LogAttributeValue = TailorLoggerLogAttributeValue;
|
|
55
|
+
type LogAttributes = TailorLoggerLogAttributes;
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
var tailor: TailorRuntime;
|
|
52
59
|
/** Custom error class for TailorDB File operations. */
|
package/dist/runtime/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import { PlatformContextAPI, context } from "./context.mjs";
|
|
|
5
5
|
import { TailorDBFileAPI, file } from "./file.mjs";
|
|
6
6
|
import { TailorIconvAPI, iconv } from "./iconv.mjs";
|
|
7
7
|
import { TailorIdpAPI, idp } from "./idp.mjs";
|
|
8
|
+
import { TailorLoggerAPI, logger } from "./logger.mjs";
|
|
8
9
|
import { TailorSecretmanagerAPI, secretmanager } from "./secretmanager.mjs";
|
|
9
10
|
//#region src/runtime/index.d.ts
|
|
10
11
|
/** SQL command type recorded on a {@link TailordbQueryResult}. */
|
|
@@ -36,6 +37,7 @@ interface TailorRuntime {
|
|
|
36
37
|
workflow: PlatformWorkflowAPI;
|
|
37
38
|
context: PlatformContextAPI;
|
|
38
39
|
aigateway: TailorAigatewayAPI;
|
|
40
|
+
logger: TailorLoggerAPI;
|
|
39
41
|
}
|
|
40
42
|
/** Top-level `tailordb` runtime object. */
|
|
41
43
|
interface TailordbRuntime {
|
|
@@ -43,4 +45,4 @@ interface TailordbRuntime {
|
|
|
43
45
|
file: TailorDBFileAPI;
|
|
44
46
|
}
|
|
45
47
|
//#endregion
|
|
46
|
-
export { TailorRuntime, TailordbClientConstructor, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime, aigateway, authconnection, context, file, iconv, idp, secretmanager, workflow };
|
|
48
|
+
export { TailorRuntime, TailordbClientConstructor, TailordbClientInstance, TailordbCommandType, TailordbQueryResult, TailordbRuntime, aigateway, authconnection, context, file, iconv, idp, logger, secretmanager, workflow };
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -2,9 +2,10 @@ import { t as iconv } from "../iconv-QWaZh0TT.mjs";
|
|
|
2
2
|
import { t as secretmanager } from "../secretmanager-CYlpffsz.mjs";
|
|
3
3
|
import { t as authconnection } from "../authconnection-CZvi9ANm.mjs";
|
|
4
4
|
import { t as idp } from "../idp-RA_swu-h.mjs";
|
|
5
|
-
import { t as workflow } from "../workflow-
|
|
5
|
+
import { t as workflow } from "../workflow-Bamae_Yc.mjs";
|
|
6
6
|
import { t as context } from "../context-DYQVYWqZ.mjs";
|
|
7
7
|
import { t as file } from "../file-BUcmVIH2.mjs";
|
|
8
8
|
import { t as aigateway } from "../aigateway-DR4Kwuik.mjs";
|
|
9
|
+
import { i as logger } from "../logger-BtX0suGY.mjs";
|
|
9
10
|
|
|
10
|
-
export { aigateway, authconnection, context, file, iconv, idp, secretmanager, workflow };
|
|
11
|
+
export { aigateway, authconnection, context, file, iconv, idp, logger, secretmanager, workflow };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//#region src/runtime/logger.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Structured logging utilities.
|
|
4
|
+
*
|
|
5
|
+
* Thin typed wrapper around the platform-provided `tailor.logger` runtime API.
|
|
6
|
+
* At runtime this delegates to `globalThis.tailor.logger`. Use `mockLogger`
|
|
7
|
+
* from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
|
|
8
|
+
*
|
|
9
|
+
* Unlike `console.*`, each call carries a severity and structured attributes.
|
|
10
|
+
* The message is written to standard output, and the full entry with its
|
|
11
|
+
* attributes is exported over OpenTelemetry, where the attributes are queryable.
|
|
12
|
+
* @example
|
|
13
|
+
* import { logger } from "@tailor-platform/sdk/runtime";
|
|
14
|
+
*
|
|
15
|
+
* logger.setAttributes({ requestId: "r-123" });
|
|
16
|
+
* logger.info("order processed", { orderId: "o-1", total: 99.5 });
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* A single log attribute value. Values outside this union (`null`, nested
|
|
20
|
+
* objects, mixed-type arrays) are silently dropped by the platform.
|
|
21
|
+
*/
|
|
22
|
+
type LogAttributeValue = string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
|
|
23
|
+
/**
|
|
24
|
+
* Structured attributes attached to a log entry. The platform keeps at most 32
|
|
25
|
+
* entries, drops any entry whose key exceeds 128 bytes, and truncates string
|
|
26
|
+
* values over 4096 bytes and arrays over 64 elements.
|
|
27
|
+
*/
|
|
28
|
+
type LogAttributes = Record<string, LogAttributeValue>;
|
|
29
|
+
/**
|
|
30
|
+
* Platform API surface for `tailor.logger`. Describes the shape the platform
|
|
31
|
+
* runtime injects on `globalThis.tailor.logger`.
|
|
32
|
+
*
|
|
33
|
+
* Each method below is also re-exported as a top-level named export from this
|
|
34
|
+
* module so callers can either `import * as logger from
|
|
35
|
+
* "@tailor-platform/sdk/runtime/logger"` or pick individual methods.
|
|
36
|
+
*/
|
|
37
|
+
interface TailorLoggerAPI {
|
|
38
|
+
/**
|
|
39
|
+
* Emits a `debug`-severity log entry.
|
|
40
|
+
* @param message - The log message
|
|
41
|
+
* @param attributes - Structured attributes to attach to this entry
|
|
42
|
+
*/
|
|
43
|
+
debug(message: string, attributes?: LogAttributes): void;
|
|
44
|
+
/**
|
|
45
|
+
* Emits an `info`-severity log entry.
|
|
46
|
+
* @param message - The log message
|
|
47
|
+
* @param attributes - Structured attributes to attach to this entry
|
|
48
|
+
*/
|
|
49
|
+
info(message: string, attributes?: LogAttributes): void;
|
|
50
|
+
/**
|
|
51
|
+
* Emits a `warn`-severity log entry.
|
|
52
|
+
* @param message - The log message
|
|
53
|
+
* @param attributes - Structured attributes to attach to this entry
|
|
54
|
+
*/
|
|
55
|
+
warn(message: string, attributes?: LogAttributes): void;
|
|
56
|
+
/**
|
|
57
|
+
* Emits an `error`-severity log entry.
|
|
58
|
+
* @param message - The log message
|
|
59
|
+
* @param attributes - Structured attributes to attach to this entry
|
|
60
|
+
*/
|
|
61
|
+
error(message: string, attributes?: LogAttributes): void;
|
|
62
|
+
/**
|
|
63
|
+
* Merges attributes into every subsequent log entry from the current
|
|
64
|
+
* execution. Later keys overwrite earlier ones; per-call attributes passed to
|
|
65
|
+
* `debug`/`info`/`warn`/`error` take precedence.
|
|
66
|
+
* @param attributes - Attributes to attach to subsequent entries
|
|
67
|
+
*/
|
|
68
|
+
setAttributes(attributes: LogAttributes): void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* See {@link TailorLoggerAPI.debug}.
|
|
72
|
+
* @param args - Forwarded to {@link TailorLoggerAPI.debug}
|
|
73
|
+
*/
|
|
74
|
+
declare const debug: TailorLoggerAPI["debug"];
|
|
75
|
+
/**
|
|
76
|
+
* See {@link TailorLoggerAPI.info}.
|
|
77
|
+
* @param args - Forwarded to {@link TailorLoggerAPI.info}
|
|
78
|
+
*/
|
|
79
|
+
declare const info: TailorLoggerAPI["info"];
|
|
80
|
+
/**
|
|
81
|
+
* See {@link TailorLoggerAPI.warn}.
|
|
82
|
+
* @param args - Forwarded to {@link TailorLoggerAPI.warn}
|
|
83
|
+
*/
|
|
84
|
+
declare const warn: TailorLoggerAPI["warn"];
|
|
85
|
+
/**
|
|
86
|
+
* See {@link TailorLoggerAPI.error}.
|
|
87
|
+
* @param args - Forwarded to {@link TailorLoggerAPI.error}
|
|
88
|
+
*/
|
|
89
|
+
declare const error: TailorLoggerAPI["error"];
|
|
90
|
+
/**
|
|
91
|
+
* See {@link TailorLoggerAPI.setAttributes}.
|
|
92
|
+
* @param args - Forwarded to {@link TailorLoggerAPI.setAttributes}
|
|
93
|
+
*/
|
|
94
|
+
declare const setAttributes: TailorLoggerAPI["setAttributes"];
|
|
95
|
+
/** `tailor.logger` API object. See {@link TailorLoggerAPI} for method docs. */
|
|
96
|
+
declare const logger: TailorLoggerAPI;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { LogAttributeValue, LogAttributes, TailorLoggerAPI, debug, error, info, logger, setAttributes, warn };
|
|
@@ -5,6 +5,11 @@
|
|
|
5
5
|
* Thin typed wrapper around the platform-provided `tailor.workflow` runtime API.
|
|
6
6
|
* At runtime this delegates to `globalThis.tailor.workflow`. Use `mockWorkflow`
|
|
7
7
|
* from `@tailor-platform/sdk/vitest` to mock these calls in unit tests.
|
|
8
|
+
*
|
|
9
|
+
* The canonical names (`startWorkflow`, `execJobFunction`,
|
|
10
|
+
* `resumeWorkflowExecution`) mirror the public `tailor.v1` RPC vocabulary:
|
|
11
|
+
* `Exec*` is a blocking call that returns the job's result, while `Start*`
|
|
12
|
+
* returns only an execution ID.
|
|
8
13
|
* @example
|
|
9
14
|
* import { workflow } from "@tailor-platform/sdk/runtime";
|
|
10
15
|
*
|
|
@@ -35,8 +40,8 @@ declare const executionPolicyKeyBrand: unique symbol;
|
|
|
35
40
|
type ExecutionPolicyKey = string & {
|
|
36
41
|
readonly [executionPolicyKeyBrand]: never;
|
|
37
42
|
};
|
|
38
|
-
/** Options for {@link
|
|
39
|
-
interface
|
|
43
|
+
/** Options for {@link execJobFunction}. */
|
|
44
|
+
interface ExecJobFunctionOptions {
|
|
40
45
|
/**
|
|
41
46
|
* Execution policy key matched by the platform against the policies
|
|
42
47
|
* declared with `defineWorkflowExecutionPolicies` in `tailor.config.ts`.
|
|
@@ -63,13 +68,16 @@ interface PlatformWorkflowAPI {
|
|
|
63
68
|
*/
|
|
64
69
|
resumeWorkflowExecution(executionId: string): Promise<string>;
|
|
65
70
|
/**
|
|
66
|
-
*
|
|
71
|
+
* Executes a job function and returns its result via durable suspend/replay.
|
|
72
|
+
*
|
|
73
|
+
* Canonical name under the platform verb convention: `Exec*` blocks and
|
|
74
|
+
* returns the job's result, while `Start*` returns only an execution ID.
|
|
67
75
|
* @param jobName - Job name as defined in the workflow
|
|
68
76
|
* @param args - Arguments forwarded to the job
|
|
69
|
-
* @param options - Optional
|
|
77
|
+
* @param options - Optional execution options (e.g. `executionPolicyKey`)
|
|
70
78
|
* @returns The job's return value
|
|
71
79
|
*/
|
|
72
|
-
|
|
80
|
+
execJobFunction(jobName: string, args?: any, options?: ExecJobFunctionOptions): any;
|
|
73
81
|
/**
|
|
74
82
|
* Suspends the current workflow execution and waits for an external signal to resume.
|
|
75
83
|
* @param key - Wait point key
|
|
@@ -90,9 +98,9 @@ interface PlatformWorkflowAPI {
|
|
|
90
98
|
declare const workflow: {
|
|
91
99
|
readonly startWorkflow: (workflowName: string, args?: any, options?: StartWorkflowOptions) => Promise<string>;
|
|
92
100
|
readonly resumeWorkflowExecution: (executionId: string) => Promise<string>;
|
|
93
|
-
readonly
|
|
101
|
+
readonly execJobFunction: (jobName: string, args?: any, options?: ExecJobFunctionOptions) => any;
|
|
94
102
|
readonly wait: (key: string, payload?: any) => any;
|
|
95
103
|
readonly resolve: (executionId: string, key: string, callback: (waitPayload: any) => any) => Promise<void>;
|
|
96
104
|
};
|
|
97
105
|
//#endregion
|
|
98
|
-
export { ExecutionPolicyKey, Invoker, PlatformWorkflowAPI,
|
|
106
|
+
export { ExecJobFunctionOptions, ExecutionPolicyKey, Invoker, PlatformWorkflowAPI, StartWorkflowOptions, workflow };
|