@tailor-platform/sdk 2.0.0-next.3 → 2.0.0-next.4

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.
Files changed (118) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/dist/aigateway-DR4Kwuik.mjs +9 -0
  3. package/dist/{aigateway-B3oZZE6v.mjs.map → aigateway-DR4Kwuik.mjs.map} +1 -1
  4. package/dist/application-BO4ZF8wP.mjs +3 -0
  5. package/dist/{application-eHp9jXld.mjs → application-BX13RArL.mjs} +293 -17
  6. package/dist/application-BX13RArL.mjs.map +1 -0
  7. package/dist/authconnection-CZvi9ANm.mjs +9 -0
  8. package/dist/authconnection-CZvi9ANm.mjs.map +1 -0
  9. package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
  10. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -0
  11. package/dist/cli/index.mjs +138 -38
  12. package/dist/cli/index.mjs.map +1 -1
  13. package/dist/cli/lib.mjs +4 -4
  14. package/dist/cli/query/index.d.mts +4 -0
  15. package/dist/cli/ts-hook.mjs +43 -13
  16. package/dist/completion/zsh-worker.zsh +10 -10
  17. package/dist/configure/config/types.d.mts +3 -1
  18. package/dist/configure/index.d.mts +3 -1
  19. package/dist/configure/index.mjs +114 -4
  20. package/dist/configure/index.mjs.map +1 -1
  21. package/dist/configure/services/index.d.mts +3 -1
  22. package/dist/configure/services/tailordb/schema.d.mts +20 -20
  23. package/dist/configure/services/workflow/execution-policy.d.mts +71 -0
  24. package/dist/configure/services/workflow/execution-policy.types.d.mts +104 -0
  25. package/dist/configure/services/workflow/index.d.mts +3 -1
  26. package/dist/configure/services/workflow/job.d.mts +7 -2
  27. package/dist/{context-Bd266-ru.mjs → context-DYQVYWqZ.mjs} +4 -5
  28. package/dist/{context-Bd266-ru.mjs.map → context-DYQVYWqZ.mjs.map} +1 -1
  29. package/dist/{file-BbdFGdMV.mjs → file-BUcmVIH2.mjs} +12 -14
  30. package/dist/file-BUcmVIH2.mjs.map +1 -0
  31. package/dist/{file-utils-CYZnO1pX.mjs → file-utils-yEiIS4nJ.mjs} +2 -2
  32. package/dist/file-utils-yEiIS4nJ.mjs.map +1 -0
  33. package/dist/{globals-DhwZj0RB.mjs → globals-BjhJJ2dN.mjs} +2 -2
  34. package/dist/globals-BjhJJ2dN.mjs.map +1 -0
  35. package/dist/iconv-QWaZh0TT.mjs +38 -0
  36. package/dist/iconv-QWaZh0TT.mjs.map +1 -0
  37. package/dist/{idp-Bx25ZBdN.mjs → idp-RA_swu-h.mjs} +4 -5
  38. package/dist/idp-RA_swu-h.mjs.map +1 -0
  39. package/dist/{kysely-type-5eAChaHO.mjs → kysely-type-D-zflMGf.mjs} +1 -3
  40. package/dist/kysely-type-D-zflMGf.mjs.map +1 -0
  41. package/dist/plugin/builtin/file-utils/index.mjs +1 -1
  42. package/dist/plugin/builtin/kysely-type/index.mjs +1 -1
  43. package/dist/{register-ts-hook-ZpBacA07.mjs → register-ts-hook-BM1caLT0.mjs} +255 -256
  44. package/dist/register-ts-hook-BM1caLT0.mjs.map +1 -0
  45. package/dist/{registry-DH4m7eYo.mjs → registry-BSbq6SPo.mjs} +4 -3
  46. package/dist/registry-BSbq6SPo.mjs.map +1 -0
  47. package/dist/resource_pb-BRv7AMXK.mjs +49 -0
  48. package/dist/resource_pb-BRv7AMXK.mjs.map +1 -0
  49. package/dist/runtime/aigateway.d.mts +5 -14
  50. package/dist/runtime/aigateway.mjs +2 -2
  51. package/dist/runtime/authconnection.d.mts +5 -14
  52. package/dist/runtime/authconnection.mjs +2 -2
  53. package/dist/runtime/context.d.mts +14 -5
  54. package/dist/runtime/context.mjs +2 -2
  55. package/dist/runtime/file.d.mts +14 -54
  56. package/dist/runtime/file.mjs +2 -2
  57. package/dist/runtime/globals.d.mts +1 -1
  58. package/dist/runtime/iconv.d.mts +5 -53
  59. package/dist/runtime/iconv.mjs +2 -2
  60. package/dist/runtime/idp.d.mts +13 -70
  61. package/dist/runtime/idp.mjs +2 -2
  62. package/dist/runtime/index.d.mts +11 -11
  63. package/dist/runtime/index.mjs +9 -9
  64. package/dist/runtime/secretmanager.d.mts +7 -20
  65. package/dist/runtime/secretmanager.mjs +2 -2
  66. package/dist/runtime/workflow.d.mts +42 -41
  67. package/dist/runtime/workflow.mjs +2 -2
  68. package/dist/{schema-89dYxNC2.mjs → schema-C4LYbXVG.mjs} +5 -5
  69. package/dist/{schema-89dYxNC2.mjs.map → schema-C4LYbXVG.mjs.map} +1 -1
  70. package/dist/secretmanager-CYlpffsz.mjs +13 -0
  71. package/dist/secretmanager-CYlpffsz.mjs.map +1 -0
  72. package/dist/{service_pb-DjwIn4jO.mjs → service_pb-B2FF59sP.mjs} +1 -1
  73. package/dist/{service_pb-CIrhGwHk.mjs → service_pb-B5w9rjPY.mjs} +17 -50
  74. package/dist/service_pb-B5w9rjPY.mjs.map +1 -0
  75. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -1
  76. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -9
  77. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -1
  78. package/dist/utils/test/index.mjs.map +1 -1
  79. package/dist/vitest/environment.mjs +1 -1
  80. package/dist/vitest/index.mjs +11 -11
  81. package/dist/vitest/index.mjs.map +1 -1
  82. package/dist/vitest/mocks/workflow.d.mts +5 -3
  83. package/dist/vitest/setup.mjs +1 -1
  84. package/dist/workflow-GNuSnsTx.mjs +22 -0
  85. package/dist/workflow-GNuSnsTx.mjs.map +1 -0
  86. package/docs/cli/auth.md +3 -3
  87. package/docs/cli/setup.md +8 -8
  88. package/docs/configuration.md +24 -0
  89. package/docs/migration/v2.md +111 -0
  90. package/docs/plugin/custom.md +4 -4
  91. package/docs/plugin/index.md +2 -2
  92. package/docs/runtime.md +4 -2
  93. package/docs/services/auth.md +2 -2
  94. package/docs/services/resolver.md +1 -1
  95. package/docs/services/tailordb-migration.md +1 -1
  96. package/docs/services/tailordb.md +31 -31
  97. package/docs/services/workflow.md +78 -0
  98. package/package.json +1 -1
  99. package/dist/aigateway-B3oZZE6v.mjs +0 -15
  100. package/dist/application-D2hSK1ZL.mjs +0 -3
  101. package/dist/application-eHp9jXld.mjs.map +0 -1
  102. package/dist/authconnection-BGQM8FZI.mjs +0 -15
  103. package/dist/authconnection-BGQM8FZI.mjs.map +0 -1
  104. package/dist/file-BbdFGdMV.mjs.map +0 -1
  105. package/dist/file-utils-CYZnO1pX.mjs.map +0 -1
  106. package/dist/globals-DhwZj0RB.mjs.map +0 -1
  107. package/dist/iconv-D2vi8G36.mjs +0 -63
  108. package/dist/iconv-D2vi8G36.mjs.map +0 -1
  109. package/dist/idp-Bx25ZBdN.mjs.map +0 -1
  110. package/dist/kysely-type-5eAChaHO.mjs.map +0 -1
  111. package/dist/register-ts-hook-ZpBacA07.mjs.map +0 -1
  112. package/dist/registry-DH4m7eYo.mjs.map +0 -1
  113. package/dist/rolldown-runtime-DXywRVcq.mjs +0 -20
  114. package/dist/secretmanager-BVxw3ih_.mjs +0 -24
  115. package/dist/secretmanager-BVxw3ih_.mjs.map +0 -1
  116. package/dist/service_pb-CIrhGwHk.mjs.map +0 -1
  117. package/dist/workflow-Bo59B75H.mjs +0 -50
  118. package/dist/workflow-Bo59B75H.mjs.map +0 -1
@@ -366,19 +366,19 @@ declare function object<const F extends Record<string, TailorAnyDBField> & Exclu
366
366
  }, FieldOutput<InferFieldsOutput<F>, Opt>>;
367
367
  declare const idField: TailorDBFieldInstance<"uuid", FieldOptions, string>;
368
368
  type idField = typeof idField;
369
- type DBType<F extends {
369
+ type DBTable<F extends {
370
370
  id?: never;
371
371
  } & Record<string, TailorAnyDBField>> = TailorDBInstance<{
372
372
  id: idField;
373
373
  } & F>;
374
374
  /**
375
- * Creates a new database type with the specified fields.
376
- * An `id` field (UUID) is automatically added to every type.
377
- * @param name - The name of the type, or a tuple of [name, pluralForm]
378
- * @param fields - The field definitions for the type
379
- * @returns A new TailorDBType instance
375
+ * Creates a new database table with the specified fields.
376
+ * An `id` field (UUID) is automatically added to every table.
377
+ * @param name - The name of the table, or a tuple of [name, pluralForm]
378
+ * @param fields - The field definitions for the table
379
+ * @returns A new TailorDB table instance
380
380
  * @example
381
- * export const user = db.type("User", {
381
+ * export const user = db.table("User", {
382
382
  * name: db.string(),
383
383
  * email: db.string(),
384
384
  * age: db.int({ optional: true }),
@@ -388,23 +388,23 @@ type DBType<F extends {
388
388
  * // Always export both the value and type:
389
389
  * export type user = typeof user;
390
390
  */
391
- declare function dbType<const F extends {
391
+ declare function dbTable<const F extends {
392
392
  id?: never;
393
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBType<F>;
393
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], fields: F): DBTable<F>;
394
394
  /**
395
- * Creates a new database type with the specified fields and description.
396
- * An `id` field (UUID) is automatically added to every type.
397
- * @param name - The name of the type, or a tuple of [name, pluralForm]
398
- * @param description - A description of the type
399
- * @param fields - The field definitions for the type
400
- * @returns A new TailorDBType instance
395
+ * Creates a new database table with the specified fields and description.
396
+ * An `id` field (UUID) is automatically added to every table.
397
+ * @param name - The name of the table, or a tuple of [name, pluralForm]
398
+ * @param description - A description of the table
399
+ * @param fields - The field definitions for the table
400
+ * @returns A new TailorDB table instance
401
401
  */
402
- declare function dbType<const F extends {
402
+ declare function dbTable<const F extends {
403
403
  id?: never;
404
- } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBType<F>;
405
- /** TailorDB schema builder utilities for defining types and fields. */
404
+ } & Record<string, TailorAnyDBField>>(name: string | [string, string], description: string, fields: F): DBTable<F>;
405
+ /** TailorDB schema builder utilities for defining tables and fields. */
406
406
  declare const db: {
407
- type: typeof dbType;
407
+ table: typeof dbTable;
408
408
  uuid: typeof uuid;
409
409
  string: typeof string;
410
410
  bool: typeof bool;
@@ -424,7 +424,7 @@ declare const db: {
424
424
  * historical records); the current time is used only when the value is omitted.
425
425
  * @returns An object with createdAt and updatedAt fields
426
426
  * @example
427
- * const model = db.type("Model", {
427
+ * const model = db.table("Model", {
428
428
  * name: db.string(),
429
429
  * ...db.fields.timestamps(),
430
430
  * });
@@ -0,0 +1,71 @@
1
+ import { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance } from "./execution-policy.types.mjs";
2
+
3
+ //#region src/configure/services/workflow/execution-policy.d.ts
4
+ type ResolveKey<Def, Fallback extends string> = Def extends {
5
+ key: infer K extends string;
6
+ } ? K : Fallback;
7
+ type ResolveMatchType<Def> = Def extends {
8
+ matchType: infer M extends "exact" | "prefix";
9
+ } ? M : "exact";
10
+ /**
11
+ * Define a single workflow job function execution policy.
12
+ *
13
+ * Use this when declaring a policy outside the
14
+ * {@link defineWorkflowExecutionPolicies} builder — for example, when the
15
+ * runtime key prefix needs to differ from the corresponding workspace-unique
16
+ * name.
17
+ *
18
+ * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
19
+ * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
20
+ * @param name - Workspace-unique name. Must match `^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$`.
21
+ * @param def - Optional overrides for `key` (defaults to `name`), `matchType`, `separator` (the `keyFor` join character, defaults to `.`), and concurrency
22
+ * @returns An execution policy instance
23
+ * @example
24
+ * export const perTenant = defineWorkflowExecutionPolicy("tenant-api", {
25
+ * matchType: "prefix",
26
+ * concurrencyPolicy: { maxConcurrentExecutions: 3 },
27
+ * });
28
+ *
29
+ * perTenant.keyFor(tenantId); // "tenant-api.<tenantId>"
30
+ */
31
+ declare function defineWorkflowExecutionPolicy<const N extends string, const D extends (Omit<ExecutionPolicyDefInput, "name"> & {
32
+ separator?: string;
33
+ }) | undefined = undefined>(name: N, def?: D): ResolvedExecutionPolicyInstance<ResolveKey<D, N>, ResolveMatchType<D>>;
34
+ /**
35
+ * Define a group of workflow job function execution policies. Property names
36
+ * become the workspace-unique `name` and default `key` verbatim, matching the
37
+ * mental model of {@link defineWaitPoints}. Provide `name` / `key` explicitly
38
+ * to override the property-name default (for example, when the property name
39
+ * is not valid for the execution policy grammar or when the runtime key
40
+ * prefix needs to differ).
41
+ *
42
+ * When `matchType: "prefix"` is set, the returned instance has `keyFor(suffix)`
43
+ * instead of a directly-usable `key` (see {@link ExecutionPolicyWildcardInstance}).
44
+ * `matchType` can be combined with an explicit `key`, or left to apply to
45
+ * the property-name-derived prefix.
46
+ *
47
+ * The return type mirrors the builder's return type so JSDoc on each property
48
+ * is preserved in IDE autocompletion.
49
+ * @param builder - Callback that receives a `define` factory and returns a record of policies
50
+ * @param options - Group-wide options; `separator` overrides the `.` `keyFor` uses to join the prefix and suffix for every prefix policy in the group
51
+ * @returns The same object returned by the builder (with `name` / `key` resolved on each instance)
52
+ * @example
53
+ * export const executionPolicies = defineWorkflowExecutionPolicies((define) => ({
54
+ * premium: define({ concurrencyPolicy: { maxConcurrentExecutions: 5 } }),
55
+ * "tenant-api": define({
56
+ * matchType: "prefix",
57
+ * concurrencyPolicy: { maxConcurrentExecutions: 3 },
58
+ * }),
59
+ * }));
60
+ *
61
+ * // In a workflow job function:
62
+ * await tailor.workflow.triggerJobFunction("worker", args, {
63
+ * executionPolicyKey: executionPolicies.premium.key,
64
+ * });
65
+ * await tailor.workflow.triggerJobFunction("worker", args, {
66
+ * executionPolicyKey: executionPolicies["tenant-api"].keyFor(input.tenantId),
67
+ * });
68
+ */
69
+ declare function defineWorkflowExecutionPolicies<T extends Record<string, ExecutionPolicyInstance>>(builder: (define: <const D extends ExecutionPolicyDefInput | undefined = undefined>(def?: D) => ResolvedExecutionPolicyInstance<ResolveKey<D, string>, ResolveMatchType<D>>) => T, options?: ExecutionPolicyGroupOptions): T;
70
+ //#endregion
71
+ export { type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ResolvedExecutionPolicyInstance, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy };
@@ -0,0 +1,104 @@
1
+ import { ExecutionPolicyKey } from "../../../runtime/workflow.mjs";
2
+
3
+ //#region src/configure/services/workflow/execution-policy.types.d.ts
4
+ /**
5
+ * Optional per-key concurrency cap applied to job function dispatches that
6
+ * resolve to a policy's `executionPolicyKey`.
7
+ */
8
+ interface ExecutionPolicyConcurrency {
9
+ /** Maximum number of concurrent executions allowed per resolved key. */
10
+ maxConcurrentExecutions: number;
11
+ }
12
+ /** Fields shared by both {@link ExecutionPolicyExactInstance} and {@link ExecutionPolicyWildcardInstance}. */
13
+ interface ExecutionPolicyBase {
14
+ /** Workspace-unique name for this policy. */
15
+ readonly name: string;
16
+ /** Optional per-key concurrency cap. */
17
+ readonly concurrencyPolicy?: ExecutionPolicyConcurrency;
18
+ }
19
+ /**
20
+ * An execution policy declared with `matchType: "exact"` (the default).
21
+ * `key` is branded as {@link ExecutionPolicyKey}, so it can be passed
22
+ * directly as the `executionPolicyKey` option.
23
+ */
24
+ interface ExecutionPolicyExactInstance<Key extends string = string> extends ExecutionPolicyBase {
25
+ /** Declared key; the platform registers it verbatim. */
26
+ readonly key: Key & ExecutionPolicyKey;
27
+ readonly matchType: "exact";
28
+ }
29
+ /**
30
+ * An execution policy declared with `matchType: "prefix"`. The platform
31
+ * registers the declared key prefix with a trailing `*`, and matches every
32
+ * dispatch whose runtime key begins with that prefix. There is no
33
+ * directly-usable `key` — use `keyFor` to build a concrete, branded runtime
34
+ * key at the call site instead of hand-concatenating the prefix and a
35
+ * suffix.
36
+ */
37
+ interface ExecutionPolicyWildcardInstance extends ExecutionPolicyBase {
38
+ readonly matchType: "prefix";
39
+ /**
40
+ * Build a concrete runtime key by appending `suffix` after this policy's
41
+ * declared key prefix, separated by `.` unless a different separator was
42
+ * configured where this policy was declared.
43
+ * @param suffix - Value appended after the wildcard prefix
44
+ * @returns The concrete key to pass as `executionPolicyKey`
45
+ * @throws If the resulting key does not match the execution policy key
46
+ * grammar (for example, an empty `suffix`)
47
+ * @example
48
+ * // key: "tenant-api", matchType: "prefix"
49
+ * tenantApi.keyFor(tenantId); // "tenant-api.<tenantId>"
50
+ */
51
+ keyFor(suffix: string): ExecutionPolicyKey;
52
+ }
53
+ /**
54
+ * A declared workflow job function execution policy — either
55
+ * {@link ExecutionPolicyExactInstance} or {@link ExecutionPolicyWildcardInstance}.
56
+ */
57
+ type ExecutionPolicyInstance<Key extends string = string> = ExecutionPolicyExactInstance<Key> | ExecutionPolicyWildcardInstance;
58
+ /**
59
+ * Resolves to {@link ExecutionPolicyWildcardInstance} when `MatchType` is
60
+ * known at the type level to be `"prefix"`, to {@link ExecutionPolicyExactInstance}
61
+ * when it's known to be `"exact"`, or to their union when `MatchType` is the
62
+ * unnarrowed `"exact" | "prefix"` (e.g. a caller passed a non-literal
63
+ * `matchType`) — narrowing to one branch in that case would claim a `key` or
64
+ * `keyFor` that may not exist on the actual runtime instance.
65
+ */
66
+ type ResolvedExecutionPolicyInstance<Key extends string, MatchType extends "exact" | "prefix"> = "exact" | "prefix" extends MatchType ? ExecutionPolicyExactInstance<Key> | ExecutionPolicyWildcardInstance : MatchType extends "prefix" ? ExecutionPolicyWildcardInstance : ExecutionPolicyExactInstance<Key>;
67
+ /**
68
+ * Body of an execution policy declaration.
69
+ *
70
+ * When both `name` and `key` are omitted in the `defineWorkflowExecutionPolicies`
71
+ * builder, the property name is used verbatim for both (like
72
+ * `defineWaitPoints`). Provide `name` when the property identifier is not
73
+ * valid execution policy grammar, and provide `key` when the runtime key
74
+ * prefix needs to differ from `name` (e.g. it needs `:` or `.`).
75
+ */
76
+ interface ExecutionPolicyDefInput {
77
+ /** Overrides the property-name-derived `name`. 3-63 characters from `[a-z0-9-]`; must start and end with `[a-z0-9]`. */
78
+ name?: string;
79
+ /** Overrides the property-name-derived `key` prefix. Independent of `matchType` — both may be set together. */
80
+ key?: string;
81
+ /**
82
+ * `"exact"` (the default) matches a dispatch whose runtime key equals
83
+ * `key` (or the resolved `name`, if `key` is omitted). `"prefix"`
84
+ * registers `key` as a wildcard prefix — the platform appends a trailing
85
+ * `*`, and the resulting instance exposes `keyFor(suffix)` to build
86
+ * concrete dispatch keys instead of a directly-usable `key`.
87
+ */
88
+ matchType?: "exact" | "prefix";
89
+ /** Optional per-key concurrency cap. */
90
+ concurrencyPolicy?: ExecutionPolicyConcurrency;
91
+ }
92
+ /**
93
+ * Options for {@link defineWorkflowExecutionPolicies}, applying to every
94
+ * policy declared by the builder (not settable per policy).
95
+ */
96
+ interface ExecutionPolicyGroupOptions {
97
+ /**
98
+ * Separator `keyFor(suffix)` inserts between a wildcard policy's declared
99
+ * `key` prefix and `suffix`. Defaults to `.`.
100
+ */
101
+ separator?: string;
102
+ }
103
+ //#endregion
104
+ export { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance };
@@ -1,6 +1,8 @@
1
+ import { ExecutionPolicyConcurrency, ExecutionPolicyDefInput, ExecutionPolicyExactInstance, ExecutionPolicyGroupOptions, ExecutionPolicyInstance, ExecutionPolicyWildcardInstance, ResolvedExecutionPolicyInstance } from "./execution-policy.types.mjs";
1
2
  import { WorkflowServiceConfig, WorkflowServiceInput } from "../../config/types.mjs";
2
3
  import { ConcurrencyPolicy, RetryPolicy } from "../../../types/workflow.generated.mjs";
3
4
  import { WorkflowJob, WorkflowJobContext, createWorkflowJob } from "./job.mjs";
4
5
  import { Workflow, WorkflowConfig, createWorkflow } from "./workflow.mjs";
6
+ import { defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy } from "./execution-policy.mjs";
5
7
  import { WaitPointInstance, createWaitPoint, createWaitPoints } from "./wait-point.mjs";
6
- export { type ConcurrencyPolicy, type RetryPolicy, WaitPointInstance, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, type WorkflowServiceConfig, type WorkflowServiceInput, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob };
8
+ export { type ConcurrencyPolicy, type ExecutionPolicyConcurrency, type ExecutionPolicyDefInput, type ExecutionPolicyExactInstance, type ExecutionPolicyGroupOptions, type ExecutionPolicyInstance, type ExecutionPolicyWildcardInstance, type ResolvedExecutionPolicyInstance, type RetryPolicy, WaitPointInstance, Workflow, WorkflowConfig, WorkflowJob, WorkflowJobContext, type WorkflowServiceConfig, type WorkflowServiceInput, createWaitPoint, createWaitPoints, createWorkflow, createWorkflowJob, defineWorkflowExecutionPolicies, defineWorkflowExecutionPolicy };
@@ -1,5 +1,6 @@
1
1
  import { TailorEnv, TailorPrincipal } from "../../../runtime/types.mjs";
2
2
  import { JsonCompatible, TypeLevelError } from "../../../types/helpers.mjs";
3
+ import { TriggerJobFunctionOptions } from "../../../runtime/workflow.mjs";
3
4
 
4
5
  //#region src/configure/services/workflow/job.d.ts
5
6
  /**
@@ -27,14 +28,18 @@ interface WorkflowJob<Name extends string = string, Input = undefined, Output =
27
28
  name: Name;
28
29
  /**
29
30
  * Trigger this job with the given input and return the job's output value.
31
+ * Accepts an optional second argument to pass `executionPolicyKey` for
32
+ * platform-side concurrency enforcement.
30
33
  * @example
31
34
  * body: async (input) => {
32
35
  * const a = jobA.trigger({ id: input.id });
33
- * const b = jobB.trigger({ id: input.id });
36
+ * const b = jobB.trigger({ id: input.id }, {
37
+ * executionPolicyKey: `tenant-api.${input.tenantId}`,
38
+ * });
34
39
  * return { a, b };
35
40
  * }
36
41
  */
37
- trigger: [Input] extends [undefined] ? () => Awaited<Output> : (input: Input) => Awaited<Output>;
42
+ trigger: [Input] extends [undefined] ? (input?: undefined, options?: TriggerJobFunctionOptions) => Awaited<Output> : (input: Input, options?: TriggerJobFunctionOptions) => Awaited<Output>;
38
43
  body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;
39
44
  }
40
45
  interface CreateWorkflowJobConfig<Name extends string, I, O> {
@@ -1,7 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DXywRVcq.mjs";
2
-
3
1
  //#region src/runtime/context.ts
4
- var context_exports = /* @__PURE__ */ __exportAll({ getInvoker: () => getInvoker });
5
2
  /**
6
3
  * Returns information about the invoker of the current function execution,
7
4
  * or `null` for anonymous invocations.
@@ -18,7 +15,9 @@ function getInvoker() {
18
15
  attributeList: raw.attributes
19
16
  };
20
17
  }
18
+ /** Runtime wrapper namespace for `tailor.context`. */
19
+ const context = { getInvoker };
21
20
 
22
21
  //#endregion
23
- export { getInvoker as n, context_exports as t };
24
- //# sourceMappingURL=context-Bd266-ru.mjs.map
22
+ export { context as t };
23
+ //# sourceMappingURL=context-DYQVYWqZ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-Bd266-ru.mjs","names":[],"sources":["../src/runtime/context.ts"],"sourcesContent":["/**\n * Execution context utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.context` runtime API.\n * At runtime this delegates to `globalThis.tailor.context`.\n * @example\n * import { context } from \"@tailor-platform/sdk/runtime\";\n *\n * const invoker = context.getInvoker();\n * if (invoker) {\n * console.log(invoker.id, invoker.type, invoker.attributes, invoker.attributeList);\n * }\n */\n\nimport type { TailorPrincipal } from \"#/runtime/types\";\n\n/**\n * Information about the invoker of the current function execution.\n *\n * Matches the public `TailorPrincipal` shape — `attributes` is the attribute\n * map and `attributeList` is the array of attribute IDs.\n */\nexport type Invoker = TailorPrincipal;\n\n/**\n * Raw platform-side invoker payload returned by `tailor.context.getInvoker()`.\n * The wrapper normalizes this into {@link Invoker}.\n * @internal\n */\nexport interface ContextInvoker {\n /** The invoker's ID */\n id: string;\n /** The invoker's type */\n type: \"user\" | \"machine_user\";\n /** The workspace ID */\n workspaceId: string;\n /** The invoker's attribute IDs */\n attributes: string[];\n /** The invoker's attribute map */\n attributeMap: Record<string, unknown>;\n}\n\n/**\n * Platform API surface for `tailor.context`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.context`.\n * @internal\n */\nexport interface TailorContextAPI {\n getInvoker(): ContextInvoker | null;\n}\n\n/**\n * Returns information about the invoker of the current function execution,\n * or `null` for anonymous invocations.\n * @returns Invoker details, or `null` when the call is anonymous\n */\nexport function getInvoker(): Invoker | null {\n const raw = (globalThis as { tailor: { context: TailorContextAPI } }).tailor.context.getInvoker();\n if (!raw) return null;\n return {\n id: raw.id,\n type: raw.type,\n workspaceId: raw.workspaceId,\n attributes: raw.attributeMap as Invoker[\"attributes\"],\n attributeList: raw.attributes as Invoker[\"attributeList\"],\n };\n}\n"],"mappings":";;;;;;;;;AAwDA,SAAgB,aAA6B;CAC3C,MAAM,MAAO,WAAyD,OAAO,QAAQ,WAAW;CAChG,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO;EACL,IAAI,IAAI;EACR,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,YAAY,IAAI;EAChB,eAAe,IAAI;CACrB;AACF"}
1
+ {"version":3,"file":"context-DYQVYWqZ.mjs","names":[],"sources":["../src/runtime/context.ts"],"sourcesContent":["/**\n * Execution context utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.context` runtime API.\n * At runtime this delegates to `globalThis.tailor.context`.\n * @example\n * import { context } from \"@tailor-platform/sdk/runtime\";\n *\n * const invoker = context.getInvoker();\n * if (invoker) {\n * console.log(invoker.id, invoker.type, invoker.attributes, invoker.attributeList);\n * }\n */\n\nimport type { TailorPrincipal } from \"#/runtime/types\";\n\n/**\n * Information about the invoker of the current function execution.\n *\n * Matches the public `TailorPrincipal` shape — `attributes` is the attribute\n * map and `attributeList` is the array of attribute IDs.\n */\nexport type Invoker = TailorPrincipal;\n\n/**\n * Raw platform-side invoker payload returned by `tailor.context.getInvoker()`.\n * The wrapper normalizes this into {@link Invoker}.\n * @internal\n */\nexport interface ContextInvoker {\n /** The invoker's ID */\n id: string;\n /** The invoker's type */\n type: \"user\" | \"machine_user\";\n /** The workspace ID */\n workspaceId: string;\n /** The invoker's attribute IDs */\n attributes: string[];\n /** The invoker's attribute map */\n attributeMap: Record<string, unknown>;\n}\n\n/**\n * Platform API surface for `tailor.context`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.context`.\n * @internal\n */\nexport interface PlatformContextAPI {\n getInvoker(): ContextInvoker | null;\n}\n\n/** Runtime wrapper API for execution context utilities. */\nexport interface TailorContextAPI {\n /**\n * Returns information about the current invoker.\n * @returns Invoker details, or `null` for anonymous invocations\n */\n getInvoker(): Invoker | null;\n}\n\n/**\n * Returns information about the invoker of the current function execution,\n * or `null` for anonymous invocations.\n * @returns Invoker details, or `null` when the call is anonymous\n */\nfunction getInvoker(): Invoker | null {\n const raw = (\n globalThis as unknown as { tailor: { context: PlatformContextAPI } }\n ).tailor.context.getInvoker();\n if (!raw) return null;\n return {\n id: raw.id,\n type: raw.type,\n workspaceId: raw.workspaceId,\n attributes: raw.attributeMap as Invoker[\"attributes\"],\n attributeList: raw.attributes as Invoker[\"attributeList\"],\n };\n}\n\n/** Runtime wrapper namespace for `tailor.context`. */\nexport const context = { getInvoker } as const satisfies TailorContextAPI;\n"],"mappings":";;;;;;AAiEA,SAAS,aAA6B;CACpC,MAAM,MACJ,WACA,OAAO,QAAQ,WAAW;CAC5B,IAAI,CAAC,KAAK,OAAO;CACjB,OAAO;EACL,IAAI,IAAI;EACR,MAAM,IAAI;EACV,aAAa,IAAI;EACjB,YAAY,IAAI;EAChB,eAAe,IAAI;CACrB;AACF;;AAGA,MAAa,UAAU,EAAE,WAAW"}
@@ -1,16 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DXywRVcq.mjs";
2
-
3
1
  //#region src/runtime/file.ts
4
- var file_exports = /* @__PURE__ */ __exportAll({
5
- delete: () => deleteFile,
6
- deleteFile: () => deleteFile,
7
- download: () => download,
8
- downloadAsBase64: () => downloadAsBase64,
9
- downloadStream: () => downloadStream,
10
- getMetadata: () => getMetadata,
11
- upload: () => upload,
12
- uploadStream: () => uploadStream
13
- });
14
2
  const api = () => globalThis.tailordb.file;
15
3
  /**
16
4
  * See {@link TailorDBFileAPI.upload}.
@@ -54,7 +42,17 @@ const downloadStream = (...args) => api().downloadStream(...args);
54
42
  * @returns Upload response containing the file metadata
55
43
  */
56
44
  const uploadStream = (...args) => api().uploadStream(...args);
45
+ /** Runtime wrapper namespace for `tailordb.file`. */
46
+ const file = {
47
+ upload,
48
+ download,
49
+ downloadAsBase64,
50
+ delete: deleteFile,
51
+ getMetadata,
52
+ downloadStream,
53
+ uploadStream
54
+ };
57
55
 
58
56
  //#endregion
59
- export { file_exports as a, uploadStream as c, downloadStream as i, download as n, getMetadata as o, downloadAsBase64 as r, upload as s, deleteFile as t };
60
- //# sourceMappingURL=file-BbdFGdMV.mjs.map
57
+ export { file as t };
58
+ //# sourceMappingURL=file-BUcmVIH2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-BUcmVIH2.mjs","names":[],"sources":["../src/runtime/file.ts"],"sourcesContent":["/**\n * TailorDB file (BLOB) utilities.\n *\n * Thin typed wrapper around the platform-provided `tailordb.file` runtime API.\n * At runtime this delegates to `globalThis.tailordb.file`. Use `mockFile` from\n * `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { file } from \"@tailor-platform/sdk/runtime\";\n *\n * const { metadata } = await file.upload(\n * \"my-namespace\",\n * \"Document\",\n * \"attachment\",\n * recordId,\n * bytes,\n * );\n */\n\n/** Upload response metadata. */\nexport interface UploadMetadata {\n fileSize: number;\n sha256sum: string;\n}\n\n/** Download response metadata. */\nexport interface DownloadMetadata {\n contentType: string;\n fileSize: number;\n sha256sum: string;\n lastUploadedAt: string;\n}\n\n/** File metadata (for {@link TailorDBFileAPI.getMetadata}). */\nexport interface FileMetadata {\n contentType: string;\n fileSize: number;\n sha256sum: string;\n urlPath: string;\n lastUploadedAt?: string;\n}\n\n/** Upload options. */\nexport interface FileUploadOptions {\n contentType?: string;\n}\n\n/** Upload stream options. */\nexport interface FileUploadStreamOptions {\n contentType?: string;\n fileSize?: number;\n}\n\n/** Upload response. */\nexport interface FileUploadResponse {\n metadata: UploadMetadata;\n}\n\n/** Download response. */\nexport interface FileDownloadResponse {\n data: Uint8Array;\n metadata: DownloadMetadata;\n}\n\n/** Download-as-Base64 response. */\nexport interface FileDownloadAsBase64Response {\n data: string;\n metadata: DownloadMetadata;\n}\n\n/** Download stream response. */\nexport interface FileDownloadStreamResponse {\n body: ReadableStream<Uint8Array>;\n metadata: DownloadMetadata;\n}\n\n/** Error code emitted by {@link TailorDBFileError}. */\nexport type TailorDBFileErrorCode =\n | \"INVALID_PARAMS\"\n | \"INVALID_DATA_TYPE\"\n | \"OPERATION_FAILED\"\n | \"DELETE_FAILED\"\n | \"STREAM_OPEN_FAILED\"\n | \"STREAM_READ_ERROR\"\n | \"STREAM_ERROR\"\n | \"FILE_TOO_LARGE\";\n\n/**\n * Type-only shape of the `TailorDBFileError` runtime class. The class itself\n * is provided by the platform runtime (and by `injectMocks` in tests); this\n * interface mirrors it so callers can `import type { TailorDBFileError }` from\n * the wrapper module without depending on any ambient declaration.\n */\nexport interface TailorDBFileError extends Error {\n name: \"TailorDBFileError\";\n code?: TailorDBFileErrorCode;\n cause?: unknown;\n}\n\n/**\n * Platform API surface for `tailordb.file`. Describes the shape the platform\n * runtime injects on `globalThis.tailordb.file`.\n */\nexport interface TailorDBFileAPI {\n /**\n * Upload a file to TailorDB.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @param data - File contents\n * @param options - Upload options (e.g. `contentType`)\n * @returns Upload response containing the file metadata\n */\n upload(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n data: string | ArrayBuffer | Uint8Array | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse>;\n\n /**\n * Download a file from TailorDB.\n *\n * Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file\n * exceeds 10MB — use {@link downloadStream} for large files.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Bytes and metadata for the file\n */\n download(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileDownloadResponse>;\n\n /**\n * Download a file from TailorDB as a Base64-encoded string.\n *\n * Throws `TailorDBFileError` with code `FILE_TOO_LARGE` when the file\n * exceeds 10MB — use {@link downloadStream} for large files.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Base64-encoded contents and metadata for the file\n */\n downloadAsBase64(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileDownloadAsBase64Response>;\n\n /**\n * Delete a file from TailorDB.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Resolves once the file has been deleted\n */\n delete(namespace: string, typeName: string, fieldName: string, recordId: string): Promise<void>;\n\n /**\n * Get file metadata from TailorDB.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns Metadata for the stored file\n */\n getMetadata(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileMetadata>;\n\n /**\n * Download a file as a ReadableStream.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @returns ReadableStream body and metadata for the file\n */\n downloadStream(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n ): Promise<FileDownloadStreamResponse>;\n\n /**\n * Upload a file using a ReadableStream.\n * @param namespace - TailorDB namespace\n * @param typeName - TailorDB type name\n * @param fieldName - File field name on the type\n * @param recordId - Record ID owning the field\n * @param readableStream - ReadableStream providing the file data\n * @param options - Upload stream options (e.g. `contentType`, `fileSize`)\n * @returns Upload response containing the file metadata\n */\n uploadStream(\n namespace: string,\n typeName: string,\n fieldName: string,\n recordId: string,\n readableStream: ReadableStream<Uint8Array | ArrayBuffer>,\n options?: FileUploadStreamOptions,\n ): Promise<FileUploadResponse>;\n}\n\nconst api = (): TailorDBFileAPI =>\n (globalThis as unknown as { tailordb: { file: TailorDBFileAPI } }).tailordb.file;\n\n/**\n * See {@link TailorDBFileAPI.upload}.\n * @param args - Forwarded to {@link TailorDBFileAPI.upload}\n * @returns Upload response containing the file metadata\n */\nconst upload: TailorDBFileAPI[\"upload\"] = (...args) => api().upload(...args);\n\n/**\n * See {@link TailorDBFileAPI.download}.\n * @param args - Forwarded to {@link TailorDBFileAPI.download}\n * @returns Bytes and metadata for the file\n */\nconst download: TailorDBFileAPI[\"download\"] = (...args) => api().download(...args);\n\n/**\n * See {@link TailorDBFileAPI.downloadAsBase64}.\n * @param args - Forwarded to {@link TailorDBFileAPI.downloadAsBase64}\n * @returns Base64-encoded contents and metadata for the file\n */\nconst downloadAsBase64: TailorDBFileAPI[\"downloadAsBase64\"] = (...args) =>\n api().downloadAsBase64(...args);\n\n/**\n * See {@link TailorDBFileAPI.delete}.\n * @param args - Forwarded to {@link TailorDBFileAPI.delete}\n * @returns Resolves once the file has been deleted\n */\nconst deleteFile: TailorDBFileAPI[\"delete\"] = (...args) => api().delete(...args);\n\n/**\n * See {@link TailorDBFileAPI.getMetadata}.\n * @param args - Forwarded to {@link TailorDBFileAPI.getMetadata}\n * @returns Metadata for the stored file\n */\nconst getMetadata: TailorDBFileAPI[\"getMetadata\"] = (...args) => api().getMetadata(...args);\n\n/**\n * See {@link TailorDBFileAPI.downloadStream}.\n * @param args - Forwarded to {@link TailorDBFileAPI.downloadStream}\n * @returns ReadableStream body and metadata for the file\n */\nconst downloadStream: TailorDBFileAPI[\"downloadStream\"] = (...args) =>\n api().downloadStream(...args);\n\n/**\n * See {@link TailorDBFileAPI.uploadStream}.\n * @param args - Forwarded to {@link TailorDBFileAPI.uploadStream}\n * @returns Upload response containing the file metadata\n */\nconst uploadStream: TailorDBFileAPI[\"uploadStream\"] = (...args) => api().uploadStream(...args);\n\n/** Runtime wrapper namespace for `tailordb.file`. */\nexport const file = {\n upload,\n download,\n downloadAsBase64,\n delete: deleteFile,\n getMetadata,\n downloadStream,\n uploadStream,\n} as const satisfies TailorDBFileAPI;\n"],"mappings":";AA0NA,MAAM,YACH,WAAkE,SAAS;;;;;;AAO9E,MAAM,UAAqC,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI;;;;;;AAO3E,MAAM,YAAyC,GAAG,SAAS,IAAI,CAAC,CAAC,SAAS,GAAG,IAAI;;;;;;AAOjF,MAAM,oBAAyD,GAAG,SAChE,IAAI,CAAC,CAAC,iBAAiB,GAAG,IAAI;;;;;;AAOhC,MAAM,cAAyC,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI;;;;;;AAO/E,MAAM,eAA+C,GAAG,SAAS,IAAI,CAAC,CAAC,YAAY,GAAG,IAAI;;;;;;AAO1F,MAAM,kBAAqD,GAAG,SAC5D,IAAI,CAAC,CAAC,eAAe,GAAG,IAAI;;;;;;AAO9B,MAAM,gBAAiD,GAAG,SAAS,IAAI,CAAC,CAAC,aAAa,GAAG,IAAI;;AAG7F,MAAa,OAAO;CAClB;CACA;CACA;CACA,QAAQ;CACR;CACA;CACA;AACF"}
@@ -20,7 +20,7 @@ function generateUnifiedFileUtils(namespaceData) {
20
20
  }).join("\n");
21
21
  return [
22
22
  multiline`
23
- import * as file from "@tailor-platform/sdk/runtime/file";
23
+ import { file } from "@tailor-platform/sdk/runtime/file";
24
24
  import type {
25
25
  FileUploadOptions,
26
26
  FileUploadResponse,
@@ -147,4 +147,4 @@ function fileUtilsPlugin(options) {
147
147
 
148
148
  //#endregion
149
149
  export { fileUtilsPlugin as n, FileUtilsGeneratorID as t };
150
- //# sourceMappingURL=file-utils-CYZnO1pX.mjs.map
150
+ //# sourceMappingURL=file-utils-yEiIS4nJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-utils-yEiIS4nJ.mjs","names":[],"sources":["../src/plugin/builtin/file-utils/generate-file-utils.ts","../src/plugin/builtin/file-utils/process-file-type.ts","../src/plugin/builtin/file-utils/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Generate unified file utility functions from collected metadata.\n * @param namespaceData - Namespace data with file utility metadata\n * @returns Generated file utility code\n */\nexport function generateUnifiedFileUtils(\n namespaceData: { namespace: string; types: FileUtilMetadata[] }[],\n): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Collect all types with their namespace\n const typeNamespaceMap = new Map<string, string>();\n const typeFieldsMap = new Map<string, string[]>();\n\n for (const { namespace, types } of namespaceData) {\n for (const type of types) {\n typeNamespaceMap.set(type.name, namespace);\n typeFieldsMap.set(type.name, type.fileFields);\n }\n }\n\n if (typeNamespaceMap.size === 0) {\n return \"\";\n }\n\n // Generate interface fields\n const interfaceFields = Array.from(typeFieldsMap.entries())\n .map(([typeName, fields]) => {\n const fieldNamesUnion = fields.map((field) => `\"${field}\"`).join(\" | \");\n return ` ${typeName}: {\\n fields: ${fieldNamesUnion};\\n };`;\n })\n .join(\"\\n\");\n\n const importStatement =\n multiline /* ts */ `\n import { file } from \"@tailor-platform/sdk/runtime/file\";\n import type {\n FileUploadOptions,\n FileUploadResponse,\n FileMetadata,\n FileDownloadStreamResponse,\n } from \"@tailor-platform/sdk/runtime/file\";\n ` + \"\\n\";\n\n const interfaceDefinition =\n multiline /* ts */ `\n export interface TypeWithFiles {\n ${interfaceFields}\n }\n ` + \"\\n\";\n\n // Generate namespaces object\n const namespaceEntries = Array.from(typeNamespaceMap.entries())\n .map(([typeName, namespace]) => ` ${typeName}: \"${namespace}\"`)\n .join(\",\\n\");\n\n const namespacesDefinition =\n multiline /* ts */ `\n const namespaces: Record<keyof TypeWithFiles, string> = {\n ${namespaceEntries},\n };\n ` + \"\\n\";\n\n // Generate downloadFile helper function\n const downloadFunction =\n multiline /* ts */ `\n export async function downloadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ) {\n return await file.download(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate uploadFile helper function\n const uploadFunction =\n multiline /* ts */ `\n export async function uploadFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n data: string | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[],\n options?: FileUploadOptions,\n ): Promise<FileUploadResponse> {\n return await file.upload(namespaces[type], type, field, recordId, data, options);\n }\n ` + \"\\n\";\n\n // Generate deleteFile helper function\n const deleteFunction =\n multiline /* ts */ `\n export async function deleteFile<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<void> {\n return await file.delete(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate getFileMetadata helper function\n const getMetadataFunction =\n multiline /* ts */ `\n export async function getFileMetadata<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileMetadata> {\n return await file.getMetadata(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n // Generate downloadFileStream helper function\n const downloadStreamFunction =\n multiline /* ts */ `\n export async function downloadFileStream<T extends keyof TypeWithFiles>(\n type: T,\n field: TypeWithFiles[T][\"fields\"],\n recordId: string,\n ): Promise<FileDownloadStreamResponse> {\n return await file.downloadStream(namespaces[type], type, field, recordId);\n }\n ` + \"\\n\";\n\n return [\n importStatement,\n interfaceDefinition,\n namespacesDefinition,\n downloadFunction,\n uploadFunction,\n deleteFunction,\n getMetadataFunction,\n downloadStreamFunction,\n ].join(\"\\n\");\n}\n","import type { TailorDBType } from \"#/parser/service/tailordb/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/**\n * Process a TailorDB type and extract file field metadata.\n * @param type - The parsed TailorDB type to process\n * @returns File utility metadata for the type\n */\nexport async function processFileType(type: TailorDBType): Promise<FileUtilMetadata> {\n const fileFields: string[] = [];\n\n if (type.files) {\n for (const fileFieldName of Object.keys(type.files)) {\n fileFields.push(fileFieldName);\n }\n }\n\n return {\n name: type.name,\n fileFields,\n };\n}\n","import { generateUnifiedFileUtils } from \"./generate-file-utils\";\nimport { processFileType } from \"./process-file-type\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { FileUtilMetadata } from \"./types\";\n\n/** Unique identifier for the file utilities generator plugin. */\nexport const FileUtilsGeneratorID = \"@tailor-platform/file-utils\";\n\ntype FileUtilsPluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates TypeWithFiles interface from TailorDB type definitions.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated file utilities\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function fileUtilsPlugin(\n options: FileUtilsPluginOptions,\n): Plugin<unknown, FileUtilsPluginOptions> {\n return {\n id: FileUtilsGeneratorID,\n description: \"Generates TypeWithFiles interface from TailorDB type definitions\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<FileUtilsPluginOptions>,\n ): Promise<GeneratorResult> {\n const namespaceData: { namespace: string; types: FileUtilMetadata[] }[] = [];\n\n for (const ns of ctx.tailordb) {\n const typesWithFiles: FileUtilMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processFileType(type);\n if (metadata.fileFields.length > 0) {\n typesWithFiles.push(metadata);\n }\n }\n\n if (typesWithFiles.length > 0) {\n namespaceData.push({\n namespace: ns.namespace,\n types: typesWithFiles,\n });\n }\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (namespaceData.length > 0) {\n const content = generateUnifiedFileUtils(namespaceData);\n if (content) {\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB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ACL,IAAI;EACJ,aAAa;EACb,cAAc;EAEd,MAAM,gBACJ,KAC0B;GAC1B,MAAM,gBAAoE,CAAC;GAE3E,KAAK,MAAM,MAAM,IAAI,UAAU;IAC7B,MAAM,iBAAqC,CAAC;IAE5C,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,KAAK,GAAG;KAC1C,MAAM,WAAW,MAAM,gBAAgB,IAAI;KAC3C,IAAI,SAAS,WAAW,SAAS,GAC/B,eAAe,KAAK,QAAQ;IAEhC;IAEA,IAAI,eAAe,SAAS,GAC1B,cAAc,KAAK;KACjB,WAAW,GAAG;KACd,OAAO;IACT,CAAC;GAEL;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,cAAc,SAAS,GAAG;IAC5B,MAAM,UAAU,yBAAyB,aAAa;IACtD,IAAI,SACF,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GAEL;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { t as TRIGGER_DEFAULT } from "./registry-DH4m7eYo.mjs";
1
+ import { t as TRIGGER_DEFAULT } from "./registry-BSbq6SPo.mjs";
2
2
  import { t as platformSerialize } from "./platform-serialize-RoRtBS0v.mjs";
3
3
 
4
4
  //#region src/vitest/workflow-runtime.ts
@@ -112,4 +112,4 @@ function cleanupPlatformGlobals(global) {
112
112
 
113
113
  //#endregion
114
114
  export { cleanupPlatformGlobals as n, installPlatformGlobals as r, RUNTIME_FLAG_KEY as t };
115
- //# sourceMappingURL=globals-DhwZj0RB.mjs.map
115
+ //# sourceMappingURL=globals-BjhJJ2dN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals-BjhJJ2dN.mjs","names":[],"sources":["../src/vitest/workflow-runtime.ts","../src/vitest/globals.ts"],"sourcesContent":["// Default `tailor.workflow` runner installed by the `tailor-runtime` environment.\n// Must stay free of `vitest` (`vi`): it loads via `./globals` in the environment\n// realm where `vi` is unavailable, hence relative imports only (no `@/` alias).\nimport { TRIGGER_DEFAULT } from \"../configure/services/workflow/registry\";\nimport { platformSerialize } from \"../utils/test/platform-serialize\";\nimport type { TriggerJobFunctionOptions } from \"../runtime/workflow\";\n\nexport interface DefaultWorkflowRuntime {\n triggerJobFunction: (\n name: string,\n args?: unknown,\n options?: TriggerJobFunctionOptions,\n ) => unknown;\n triggerWorkflow: (name: string, args?: unknown, options?: unknown) => Promise<string>;\n resumeWorkflow: (executionId: string) => Promise<string>;\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\nexport function createDefaultWorkflowRuntime(): DefaultWorkflowRuntime {\n return {\n triggerJobFunction: (name) => {\n throw new Error(\n `No workflow job mock for \"${name}\". Acquire mockWorkflow() and call setJobHandler(...) or enqueueResult(...), or use runWorkflowLocally() for local workflow execution.`,\n );\n },\n triggerWorkflow: async (_name, args) => {\n platformSerialize(args);\n return TRIGGER_DEFAULT;\n },\n resumeWorkflow: async (executionId: string): Promise<string> => executionId,\n wait: (key: string): unknown => {\n throw new Error(\n `No wait handler for \"${key}\". Acquire mockWorkflow() and call setWaitHandler(...).`,\n );\n },\n resolve: async (): Promise<void> => {\n throw new Error(\n \"No resolve handler. Acquire mockWorkflow() and call setResolveHandler(...).\",\n );\n },\n };\n}\n","/**\n * Base platform globals for the tailor-runtime test environment.\n *\n * This module is intentionally free of any `vitest` (`vi`) dependency so it can\n * be imported from the Vitest *environment* module (which runs in a realm where\n * `vi` is not available). It installs only the always-present structural pieces:\n *\n * - `globalThis.tailor` / `globalThis.tailordb` container objects\n * - `globalThis.tailor.context.getInvoker` default stub\n * - the platform error classes (`TailorErrors`, `TailorErrorMessage`,\n * `TailorDBFileError`)\n * - the `__tailorRuntimeActive` sentinel flag\n *\n * The per-namespace mock behavior (TailorDB client, workflow, secretmanager, …)\n * is installed on demand by the `xMock()` factories in `./mock`, which run in\n * test context where `vi` *is* available.\n */\n\nimport { createDefaultWorkflowRuntime } from \"./workflow-runtime\";\nimport type { ContextInvoker } from \"../runtime/context\";\nimport type { TailorDBFileErrorCode } from \"../runtime/file\";\n\n// Sentinel set when the tailor-runtime environment is active. setup.ts reads it\n// to decide whether to run its blocked-globals lifecycle and config-secret\n// loading.\nexport const RUNTIME_FLAG_KEY = \"__tailorRuntimeActive\";\n\n// ---------------------------------------------------------------------------\n// Error class mocks\n// ---------------------------------------------------------------------------\n\ninterface TailorErrorItem {\n message: string;\n path: (string | number)[];\n}\n\nclass TailorErrorsMock extends Error {\n errors: TailorErrorItem[];\n\n constructor(errors: TailorErrorItem[]) {\n if (!Array.isArray(errors)) {\n throw new TypeError(\"TailorErrors: errors must be an array\");\n }\n const validated = errors.map((e, i) => {\n if (typeof e.message !== \"string\") {\n throw new TypeError(`TailorErrors: errors[${i}].message must be a string`);\n }\n if (!Array.isArray(e.path)) {\n throw new TypeError(`TailorErrors: errors[${i}].path must be an array`);\n }\n return { message: e.message, path: e.path };\n });\n // Match the PF runtime's TailorErrors serialization, which prefixes the\n // JSON payload with \"TailorErrors: \". Other SDK code (e.g. apply\n // integration fixtures) strips this prefix before JSON.parse.\n super(`TailorErrors: ${JSON.stringify({ errors: validated })}`);\n this.name = \"TailorErrors\";\n this.errors = validated;\n }\n}\n\nclass TailorErrorMessageMock extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"TailorErrorMessage\";\n }\n}\n\nclass TailorDBFileErrorMock extends Error {\n code?: TailorDBFileErrorCode;\n override cause: unknown;\n\n constructor(message: string, code?: TailorDBFileErrorCode, cause?: unknown) {\n super(message);\n this.name = \"TailorDBFileError\";\n this.code = code;\n this.cause = cause;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Base install / cleanup\n// ---------------------------------------------------------------------------\n\n// Stub-only injection. SDK consumers configure invokers at the body level\n// (resolver/executor/workflow `.body()` `invoker` arg) or, for bundled tests,\n// via `vi.spyOn(globalThis.tailor.context, \"getInvoker\")`.\nfunction defaultGetInvoker(): ContextInvoker | null {\n return null;\n}\n\n/**\n * Install the always-present base platform globals (containers, context stub,\n * error classes, runtime flag). Per-namespace mocks are layered on top by the\n * `xMock()` factories in `./mock`.\n * @param global - The global object to install into (typically `globalThis`)\n */\nexport function installPlatformGlobals(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n\n g[RUNTIME_FLAG_KEY] = true;\n\n // Containers. Namespace mocks (secretmanager, …) are added to these by the\n // corresponding `xMock()` on acquisition. `workflow` carries a default runner\n // so `.trigger()` runs the real job chain locally without `mockWorkflow()`;\n // `mockWorkflow()` overlays and restores it.\n g.tailor = {\n context: { getInvoker: defaultGetInvoker },\n workflow: createDefaultWorkflowRuntime(),\n };\n g.tailordb = {};\n\n g.TailorErrors = TailorErrorsMock;\n g.TailorErrorMessage = TailorErrorMessageMock;\n g.TailorDBFileError = TailorDBFileErrorMock;\n}\n\n/**\n * Remove the base platform globals (and anything the namespace mocks layered on\n * top, since they live under the same containers).\n * @param global - The global object to clean up (typically `globalThis`)\n */\nexport function cleanupPlatformGlobals(global: typeof globalThis): void {\n const g = global as Record<string, unknown>;\n delete g.tailordb;\n delete g.tailor;\n delete g.TailorErrors;\n delete g.TailorErrorMessage;\n delete g.TailorDBFileError;\n delete g[RUNTIME_FLAG_KEY];\n}\n"],"mappings":";;;;AAuBA,SAAgB,+BAAuD;CACrE,OAAO;EACL,qBAAqB,SAAS;GAC5B,MAAM,IAAI,MACR,6BAA6B,KAAK,uIACpC;EACF;EACA,iBAAiB,OAAO,OAAO,SAAS;GACtC,kBAAkB,IAAI;GACtB,OAAO;EACT;EACA,gBAAgB,OAAO,gBAAyC;EAChE,OAAO,QAAyB;GAC9B,MAAM,IAAI,MACR,wBAAwB,IAAI,wDAC9B;EACF;EACA,SAAS,YAA2B;GAClC,MAAM,IAAI,MACR,6EACF;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;ACrBA,MAAa,mBAAmB;AAWhC,IAAM,mBAAN,cAA+B,MAAM;CACnC;CAEA,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tailor.iconv;
3
+ const convert = (...args) => api().convert(...args);
4
+ const convertBuffer = (...args) => api().convertBuffer(...args);
5
+ const decode = (...args) => api().decode(...args);
6
+ const encode = (...args) => api().encode(...args);
7
+ const encodings = () => api().encodings();
8
+ /**
9
+ * Stateful converter for repeated conversions between a fixed encoding pair.
10
+ * Compatible with the `node-iconv` API surface.
11
+ */
12
+ var Iconv = class {
13
+ impl;
14
+ constructor(fromEncoding, toEncoding) {
15
+ this.impl = new (api()).Iconv(fromEncoding, toEncoding);
16
+ }
17
+ /**
18
+ * Convert input using this converter's fixed encoding pair.
19
+ * @param input - Bytes or string to convert
20
+ * @returns Encoded output (string for UTF-8 targets, otherwise `Uint8Array`).
21
+ */
22
+ convert(input) {
23
+ return this.impl.convert(input);
24
+ }
25
+ };
26
+ /** Runtime API for `tailor.iconv`. */
27
+ const iconv = {
28
+ convert,
29
+ convertBuffer,
30
+ decode,
31
+ encode,
32
+ encodings,
33
+ Iconv
34
+ };
35
+
36
+ //#endregion
37
+ export { iconv as t };
38
+ //# sourceMappingURL=iconv-QWaZh0TT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iconv-QWaZh0TT.mjs","names":[],"sources":["../src/runtime/iconv.ts"],"sourcesContent":["/**\n * Character encoding conversion utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.iconv` runtime API.\n * At runtime this delegates to `globalThis.tailor.iconv`, which is provided by\n * the Tailor Platform Function runtime. Use `mockIconv` from\n * `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { iconv } from \"@tailor-platform/sdk/runtime\";\n *\n * const utf8 = iconv.convert(sjisBuffer, \"Shift_JIS\", \"UTF-8\"); // string\n * const sjis = iconv.convert(\"こんにちは\", \"UTF-8\", \"Shift_JIS\"); // Uint8Array\n *\n * const conv = new iconv.Iconv(\"Shift_JIS\", \"UTF-8\");\n * const out = conv.convert(sjisBuffer);\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/** Instance methods exposed by `tailor.iconv.Iconv`. */\nexport interface IconvInstance {\n convert(input: string | Uint8Array | ArrayBuffer): string | Uint8Array;\n}\n\n/** Constructor shape for `tailor.iconv.Iconv`. */\nexport interface IconvConstructor {\n new (fromEncoding: string, toEncoding: string): IconvInstance;\n}\n\n/**\n * Platform API surface for `tailor.iconv`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.iconv` so the wrapper and ambient\n * globals stay in sync.\n */\nexport interface TailorIconvAPI {\n /**\n * Convert a string or buffer between encodings.\n * @param str - Input data to convert\n * @param fromEncoding - Source encoding name\n * @param toEncoding - Target encoding name\n * @returns `string` when `toEncoding` is `\"UTF8\"` or `\"UTF-8\"`, otherwise `Uint8Array`.\n */\n convert<T extends string>(\n str: string | Uint8Array | ArrayBuffer,\n fromEncoding: string,\n toEncoding: T,\n ): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array;\n\n /**\n * Convert a buffer between encodings.\n * @param buffer - Input bytes to convert\n * @param fromEncoding - Source encoding name\n * @param toEncoding - Target encoding name\n * @returns `string` when `toEncoding` is `\"UTF8\"` or `\"UTF-8\"`, otherwise `Uint8Array`.\n */\n convertBuffer<T extends string>(\n buffer: Uint8Array | ArrayBuffer,\n fromEncoding: string,\n toEncoding: T,\n ): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array;\n\n /**\n * Decode a buffer to a UTF-8 string using the given source encoding.\n * @param buffer - Input bytes\n * @param encoding - Source encoding name\n * @returns Decoded UTF-8 string\n */\n decode(buffer: Uint8Array | ArrayBuffer, encoding: string): string;\n\n /**\n * Encode a UTF-8 string into the given target encoding.\n * @param str - Input string\n * @param encoding - Target encoding name\n * @returns `string` when `encoding` is `\"UTF8\"` or `\"UTF-8\"`, otherwise `Uint8Array`.\n */\n encode<T extends string>(\n str: string,\n encoding: T,\n ): T extends \"UTF8\" | \"UTF-8\" ? string : Uint8Array;\n\n /**\n * Returns the list of supported encoding names.\n * @returns Array of encoding names supported by the platform iconv runtime\n */\n encodings(): string[];\n\n /** Constructor for the stateful converter. */\n Iconv: IconvConstructor;\n}\n\nconst api = (): TailorIconvAPI =>\n (globalThis as unknown as { tailor: { iconv: TailorIconvAPI } }).tailor.iconv;\n\nconst convert: TailorIconvAPI[\"convert\"] = (...args) => api().convert(...args);\n\nconst convertBuffer: TailorIconvAPI[\"convertBuffer\"] = (...args) => api().convertBuffer(...args);\n\nconst decode: TailorIconvAPI[\"decode\"] = (...args) => api().decode(...args);\n\nconst encode: TailorIconvAPI[\"encode\"] = (...args) => api().encode(...args);\n\nconst encodings: TailorIconvAPI[\"encodings\"] = () => api().encodings();\n\n/**\n * Stateful converter for repeated conversions between a fixed encoding pair.\n * Compatible with the `node-iconv` API surface.\n */\nclass Iconv {\n private impl: IconvInstance;\n\n constructor(fromEncoding: string, toEncoding: string) {\n this.impl = new (api().Iconv)(fromEncoding, toEncoding);\n }\n\n /**\n * Convert input using this converter's fixed encoding pair.\n * @param input - Bytes or string to convert\n * @returns Encoded output (string for UTF-8 targets, otherwise `Uint8Array`).\n */\n convert(input: string | Uint8Array | ArrayBuffer): string | Uint8Array {\n return this.impl.convert(input);\n }\n}\n\n// Keep the object typed to the public API so the private wrapper class does not leak into d.ts.\n/** Runtime API for `tailor.iconv`. */\nexport const iconv: TailorIconvAPI = {\n convert,\n convertBuffer,\n decode,\n encode,\n encodings,\n Iconv,\n};\n"],"mappings":";AA0FA,MAAM,YACH,WAAgE,OAAO;AAE1E,MAAM,WAAsC,GAAG,SAAS,IAAI,CAAC,CAAC,QAAQ,GAAG,IAAI;AAE7E,MAAM,iBAAkD,GAAG,SAAS,IAAI,CAAC,CAAC,cAAc,GAAG,IAAI;AAE/F,MAAM,UAAoC,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI;AAE1E,MAAM,UAAoC,GAAG,SAAS,IAAI,CAAC,CAAC,OAAO,GAAG,IAAI;AAE1E,MAAM,kBAA+C,IAAI,CAAC,CAAC,UAAU;;;;;AAMrE,IAAM,QAAN,MAAY;CACV,AAAQ;CAER,YAAY,cAAsB,YAAoB;EACpD,KAAK,OAAO,KAAK,IAAI,EAAC,CAAC,MAAO,cAAc,UAAU;CACxD;;;;;;CAOA,QAAQ,OAA+D;EACrE,OAAO,KAAK,KAAK,QAAQ,KAAK;CAChC;AACF;;AAIA,MAAa,QAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,7 +1,4 @@
1
- import { t as __exportAll } from "./rolldown-runtime-DXywRVcq.mjs";
2
-
3
1
  //#region src/runtime/idp.ts
4
- var idp_exports = /* @__PURE__ */ __exportAll({ Client: () => Client });
5
2
  /**
6
3
  * IDP Client for user management operations.
7
4
  *
@@ -77,7 +74,9 @@ var Client = class {
77
74
  return this.#impl.unenrollMfa(input);
78
75
  }
79
76
  };
77
+ /** Runtime API for `tailor.idp`. */
78
+ const idp = { Client };
80
79
 
81
80
  //#endregion
82
- export { idp_exports as n, Client as t };
83
- //# sourceMappingURL=idp-Bx25ZBdN.mjs.map
81
+ export { idp as t };
82
+ //# sourceMappingURL=idp-RA_swu-h.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idp-RA_swu-h.mjs","names":["#impl"],"sources":["../src/runtime/idp.ts"],"sourcesContent":["/**\n * IDP (Identity Provider) utilities.\n *\n * Thin typed wrapper around the platform-provided `tailor.idp` runtime API.\n * At runtime this delegates to `globalThis.tailor.idp`. Use `mockIdp` from\n * `@tailor-platform/sdk/vitest` to mock these calls in unit tests.\n * @example\n * import { idp } from \"@tailor-platform/sdk/runtime\";\n *\n * const client = new idp.Client({ namespace: \"my-namespace\" });\n * const { users } = await client.users({ first: 10 });\n */\n\n/** Configuration object for `idp.Client`. */\nexport interface ClientConfig {\n namespace: string;\n}\n\n/** User record returned by IDP operations. */\nexport interface User {\n id: string;\n name: string;\n disabled: boolean;\n createdAt?: string;\n /**\n * True when the user has at least one enrolled MFA second factor. False when\n * the namespace has MFA disabled or the user has not enrolled a factor.\n */\n mfaEnrolled: boolean;\n /**\n * Enrolled MFA second factor IDs. Pass an entry into\n * `idp.Client.unenrollMfa()` to remove that factor.\n */\n mfaFactorIds: string[];\n}\n\n/** Filter options for `idp.Client.users()`. */\nexport interface UserQuery {\n /** Filter by user IDs */\n ids?: string[];\n /** Filter by user names */\n names?: string[];\n}\n\n/** Pagination/filter options for `idp.Client.users()`. */\nexport interface ListUsersOptions {\n /** Maximum number of users to return */\n first?: number;\n /** Page token for pagination */\n after?: string;\n /** Query filter for users */\n query?: UserQuery;\n}\n\n/** Response shape for `idp.Client.users()`. */\nexport interface ListUsersResponse {\n users: User[];\n nextPageToken: string | null;\n totalCount: number;\n}\n\n/** Input for `idp.Client.createUser()`. */\nexport interface CreateUserInput {\n /** The user's name (typically email) */\n name: string;\n /** The user's password. If omitted, the user is created without a password (cannot log in with any password). */\n password?: string;\n /** Whether the user is disabled */\n disabled?: boolean;\n}\n\n/** Input for `idp.Client.updateUser()`. */\nexport interface UpdateUserInput {\n /** The user's ID */\n id: string;\n /** New name for the user */\n name?: string;\n /** New password for the user. Cannot be used with clearPassword. */\n password?: string;\n /** If true, remove the user's password. Cannot be used with password. */\n clearPassword?: boolean;\n /** New disabled status for the user */\n disabled?: boolean;\n}\n\n/** Input for `idp.Client.sendPasswordResetEmail()`. */\nexport interface SendPasswordResetEmailInput {\n /** The ID of the user */\n userId: string;\n /** The URI to redirect to after password reset */\n redirectUri: string;\n /** The sender display name. Defaults to 'Tailor Platform IdP'. */\n fromName?: string;\n /** The email subject line. Defaults to the localized default subject. */\n subject?: string;\n}\n\n/** Input for `idp.Client.unenrollMfa()`. */\nexport interface UnenrollMfaInput {\n /** The ID of the user whose factor will be unenrolled. */\n userId: string;\n /**\n * The ID of the factor to unenroll. Factor IDs are exposed on the user\n * record (see {@link User.mfaFactorIds}).\n */\n mfaFactorId: string;\n}\n\n/** Instance methods exposed by `tailor.idp.Client`. */\nexport interface IdpClientInstance {\n users(options?: ListUsersOptions): Promise<ListUsersResponse>;\n user(userId: string): Promise<User>;\n userByName(name: string): Promise<User>;\n createUser(input: CreateUserInput): Promise<User>;\n updateUser(input: UpdateUserInput): Promise<User>;\n deleteUser(userId: string): Promise<boolean>;\n sendPasswordResetEmail(input: SendPasswordResetEmailInput): Promise<boolean>;\n unenrollMfa(input: UnenrollMfaInput): Promise<boolean>;\n}\n\n/**\n * Constructor shape for `tailor.idp.Client`.\n * @internal\n */\nexport interface IdpClientConstructor {\n new (config: ClientConfig): IdpClientInstance;\n}\n\n/**\n * Platform API surface for `tailor.idp`. Describes the shape the platform\n * runtime injects on `globalThis.tailor.idp`.\n * @internal\n */\nexport interface TailorIdpAPI {\n Client: IdpClientConstructor;\n}\n\n/**\n * IDP Client for user management operations.\n *\n * Wraps the platform-provided `tailor.idp.Client` and exposes the same surface.\n */\nclass Client {\n #impl: IdpClientInstance;\n\n constructor(config: ClientConfig) {\n this.#impl = new (globalThis as unknown as { tailor: { idp: TailorIdpAPI } }).tailor.idp.Client(\n config,\n );\n }\n\n /**\n * List users in the namespace with optional filtering and pagination.\n * @param options - Pagination and filter options\n * @returns Page of users with `nextPageToken` and `totalCount`\n */\n users(options?: ListUsersOptions): Promise<ListUsersResponse> {\n return this.#impl.users(options);\n }\n\n /**\n * Get a user by ID.\n * @param userId - IDP user ID\n * @returns The matching user\n */\n user(userId: string): Promise<User> {\n return this.#impl.user(userId);\n }\n\n /**\n * Get a user by name.\n * @param name - IDP user name\n * @returns The matching user\n */\n userByName(name: string): Promise<User> {\n return this.#impl.userByName(name);\n }\n\n /**\n * Create a new user.\n * @param input - User attributes\n * @returns The newly created user\n */\n createUser(input: CreateUserInput): Promise<User> {\n return this.#impl.createUser(input);\n }\n\n /**\n * Update an existing user.\n * @param input - User ID plus attributes to update\n * @returns The updated user\n */\n updateUser(input: UpdateUserInput): Promise<User> {\n return this.#impl.updateUser(input);\n }\n\n /**\n * Delete a user by ID.\n * @param userId - IDP user ID\n * @returns `true` when the user was deleted\n */\n deleteUser(userId: string): Promise<boolean> {\n return this.#impl.deleteUser(userId);\n }\n\n /**\n * Send a password reset email to a user.\n * @param input - Target user ID and redirect URI\n * @returns `true` when the email was queued\n */\n sendPasswordResetEmail(input: SendPasswordResetEmailInput): Promise<boolean> {\n return this.#impl.sendPasswordResetEmail(input);\n }\n\n /**\n * Unenroll an MFA factor from a user.\n * @param input - Target user ID and factor ID (see {@link User.mfaFactorIds})\n * @returns `true` when the factor was removed\n */\n unenrollMfa(input: UnenrollMfaInput): Promise<boolean> {\n return this.#impl.unenrollMfa(input);\n }\n}\n\n// Keep the object typed to the public API so the private wrapper class does not leak into d.ts.\n/** Runtime API for `tailor.idp`. */\nexport const idp: TailorIdpAPI = { Client };\n"],"mappings":";;;;;;AA8IA,IAAM,SAAN,MAAa;CACX;CAEA,YAAY,QAAsB;EAChC,KAAKA,QAAQ,IAAK,WAA4D,OAAO,IAAI,OACvF,MACF;CACF;;;;;;CAOA,MAAM,SAAwD;EAC5D,OAAO,KAAKA,MAAM,MAAM,OAAO;CACjC;;;;;;CAOA,KAAK,QAA+B;EAClC,OAAO,KAAKA,MAAM,KAAK,MAAM;CAC/B;;;;;;CAOA,WAAW,MAA6B;EACtC,OAAO,KAAKA,MAAM,WAAW,IAAI;CACnC;;;;;;CAOA,WAAW,OAAuC;EAChD,OAAO,KAAKA,MAAM,WAAW,KAAK;CACpC;;;;;;CAOA,WAAW,OAAuC;EAChD,OAAO,KAAKA,MAAM,WAAW,KAAK;CACpC;;;;;;CAOA,WAAW,QAAkC;EAC3C,OAAO,KAAKA,MAAM,WAAW,MAAM;CACrC;;;;;;CAOA,uBAAuB,OAAsD;EAC3E,OAAO,KAAKA,MAAM,uBAAuB,KAAK;CAChD;;;;;;CAOA,YAAY,OAA2C;EACrD,OAAO,KAAKA,MAAM,YAAY,KAAK;CACrC;AACF;;AAIA,MAAa,MAAoB,EAAE,OAAO"}
@@ -76,8 +76,6 @@ function getBaseType(fieldConfig) {
76
76
  type = "number";
77
77
  break;
78
78
  case "date":
79
- type = "string";
80
- break;
81
79
  case "datetime":
82
80
  usedUtilityTypes.Timestamp = true;
83
81
  type = "Timestamp";
@@ -273,4 +271,4 @@ function kyselyTypePlugin(options) {
273
271
 
274
272
  //#endregion
275
273
  export { kyselyTypePlugin as n, KyselyGeneratorID as t };
276
- //# sourceMappingURL=kysely-type-5eAChaHO.mjs.map
274
+ //# sourceMappingURL=kysely-type-D-zflMGf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely-type-D-zflMGf.mjs","names":[],"sources":["../src/plugin/builtin/kysely-type/type-processor.ts","../src/plugin/builtin/kysely-type/index.ts"],"sourcesContent":["import multiline from \"#/utils/multiline\";\nimport { type KyselyNamespaceMetadata, type KyselyTypeMetadata } from \"./types\";\nimport type { OperatorFieldConfig, TailorDBType } from \"#/parser/service/tailordb/types\";\n\ntype UsedUtilityTypes = { Timestamp: boolean; Serial: boolean };\n\ntype FieldTypeResult = {\n type: string;\n usedUtilityTypes: UsedUtilityTypes;\n};\n\n/**\n * Get the enum type definition.\n * @param fieldConfig - The field configuration\n * @returns The enum type as a string union\n */\nfunction getEnumType(fieldConfig: OperatorFieldConfig): string {\n const allowedValues = fieldConfig.allowedValues;\n\n if (allowedValues && Array.isArray(allowedValues)) {\n return allowedValues\n .map((v: string | { value: string }) => {\n const value = typeof v === \"string\" ? v : v.value;\n return `\"${value}\"`;\n })\n .join(\" | \");\n }\n return \"string\";\n}\n\n/**\n * Get the nested object type definition.\n * @param fieldConfig - The field configuration\n * @returns The nested type with used utility types\n */\nfunction getNestedType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fields = fieldConfig.fields;\n if (!fields || typeof fields !== \"object\") {\n return {\n type: \"string\",\n usedUtilityTypes: { Timestamp: false, Serial: false },\n };\n }\n\n const fieldResults = Object.entries(fields).map(([fieldName, config]) => {\n const result = generateFieldType(config);\n const optional = config.required !== true ? \"?\" : \"\";\n return {\n fieldType: `${fieldName}${optional}: ${result.type}`,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n });\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const fieldTypes = fieldResults.map((r) => r.fieldType);\n const obj = `{\\n ${fieldTypes.join(\";\\n \")}${fieldTypes.length > 0 ? \";\" : \"\"}\\n}`;\n\n const hasOptionalFields = Object.values(fields).some((config) => config.required !== true);\n if (aggregatedUtilityTypes.Timestamp || hasOptionalFields) {\n return { type: `ObjectColumnType<${obj}>`, usedUtilityTypes: aggregatedUtilityTypes };\n }\n return { type: obj, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Get the base Kysely type for a field (without array/null modifiers).\n * @param fieldConfig - The field configuration\n * @returns The base type with used utility types\n */\nfunction getBaseType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const fieldType = fieldConfig.type;\n const usedUtilityTypes = { Timestamp: false, Serial: false };\n\n let type: string;\n switch (fieldType) {\n case \"uuid\":\n case \"string\":\n case \"decimal\":\n type = \"string\";\n break;\n case \"integer\":\n case \"float\":\n type = \"number\";\n break;\n case \"date\":\n case \"datetime\":\n usedUtilityTypes.Timestamp = true;\n type = \"Timestamp\";\n break;\n case \"bool\":\n case \"boolean\":\n type = \"boolean\";\n break;\n case \"enum\":\n type = getEnumType(fieldConfig);\n break;\n case \"nested\": {\n const nestedResult = getNestedType(fieldConfig);\n return nestedResult;\n }\n default:\n type = \"string\";\n break;\n }\n\n return { type, usedUtilityTypes };\n}\n\n/**\n * Generate the complete field type including array and null modifiers.\n * @param fieldConfig - The field configuration\n * @returns The complete field type with used utility types\n */\nfunction generateFieldType(fieldConfig: OperatorFieldConfig): FieldTypeResult {\n const baseTypeResult = getBaseType(fieldConfig);\n const usedUtilityTypes = { ...baseTypeResult.usedUtilityTypes };\n\n const isArray = fieldConfig.array === true;\n const isNullable = fieldConfig.required !== true;\n\n // Types that use ColumnType internally (Timestamp, ObjectColumnType) cannot be\n // directly wrapped with [] for arrays, because Kysely only resolves ColumnType at\n // the top-level table property. Use ArrayColumnType/ObjectArrayColumnType to keep\n // the ColumnType at the top level with arrays inside.\n const columnTypeBaseTypes = new Set([\"Timestamp\"]);\n const isColumnTypeBase = columnTypeBaseTypes.has(baseTypeResult.type);\n\n let finalType = baseTypeResult.type;\n if (isArray) {\n if (isColumnTypeBase || finalType.startsWith(\"ObjectColumnType<\")) {\n finalType = `ArrayColumnType<${baseTypeResult.type}>`;\n } else {\n const needsParens = fieldConfig.type === \"enum\";\n finalType = needsParens ? `(${baseTypeResult.type})[]` : `${baseTypeResult.type}[]`;\n }\n }\n if (isNullable) {\n finalType = `${finalType} | null`;\n }\n\n if (fieldConfig.serial) {\n usedUtilityTypes.Serial = true;\n finalType = `Serial<${finalType}>`;\n }\n if (fieldConfig.hooks?.create) {\n finalType = `Generated<${finalType}>`;\n }\n\n return { type: finalType, usedUtilityTypes };\n}\n\n/**\n * Generate the table interface.\n * @param type - The parsed TailorDB type\n * @returns The type definition and used utility types\n */\nfunction generateTableInterface(type: TailorDBType): {\n typeDef: string;\n usedUtilityTypes: UsedUtilityTypes;\n} {\n const fieldEntries = Object.entries(type.fields).filter(([fieldName]) => fieldName !== \"id\");\n\n const fieldResults = fieldEntries.map(([fieldName, parsedField]) => ({\n fieldName,\n ...generateFieldType(parsedField.config),\n }));\n\n const fields = [\n \"id: Generated<string>;\",\n ...fieldResults.map((result) => `${result.fieldName}: ${result.type};`),\n ];\n\n const aggregatedUtilityTypes = fieldResults.reduce(\n (acc, result) => ({\n Timestamp: acc.Timestamp || result.usedUtilityTypes.Timestamp,\n\n Serial: acc.Serial || result.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const typeDef = multiline /* ts */ `\n ${type.name}: {\n ${fields.join(\"\\n\")}\n }\n `;\n\n return { typeDef, usedUtilityTypes: aggregatedUtilityTypes };\n}\n\n/**\n * Convert a TailorDBType into KyselyTypeMetadata.\n * @param type - Parsed TailorDB type\n * @returns Generated Kysely type metadata\n */\nexport async function processKyselyType(type: TailorDBType): Promise<KyselyTypeMetadata> {\n const result = generateTableInterface(type);\n\n return {\n name: type.name,\n typeDef: result.typeDef,\n usedUtilityTypes: result.usedUtilityTypes,\n };\n}\n\n/**\n * Generate unified types file from multiple namespaces.\n * @param namespaceData - Namespace metadata\n * @returns Generated types file contents\n */\nexport function generateUnifiedKyselyTypes(namespaceData: KyselyNamespaceMetadata[]): string {\n if (namespaceData.length === 0) {\n return \"\";\n }\n\n // Aggregate used utility types from all namespaces\n const globalUsedUtilityTypes = namespaceData.reduce(\n (acc, ns) => ({\n Timestamp: acc.Timestamp || ns.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || ns.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n const utilityTypeImports: string[] = [\"type Generated\"];\n if (globalUsedUtilityTypes.Timestamp) {\n utilityTypeImports.push(\"type Timestamp\");\n }\n const hasObjectColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ObjectColumnType<\")),\n );\n if (hasObjectColumnType) {\n utilityTypeImports.push(\"type ObjectColumnType\");\n }\n const hasArrayColumnType = namespaceData.some((ns) =>\n ns.types.some((t) => t.typeDef.includes(\"ArrayColumnType<\")),\n );\n if (hasArrayColumnType) {\n utilityTypeImports.push(\"type ArrayColumnType\");\n }\n if (globalUsedUtilityTypes.Serial) {\n utilityTypeImports.push(\"type Serial\");\n }\n\n const importsSection = multiline /* ts */ `\n import {\n createGetDB,\n ${utilityTypeImports.join(\",\\n\")},\n type NamespaceDB,\n type NamespaceInsertable,\n type NamespaceSelectable,\n type NamespaceTable,\n type NamespaceTableName,\n type NamespaceTransaction,\n type NamespaceUpdateable,\n } from \"@tailor-platform/sdk/kysely\";\n `;\n\n // Generate Namespace interface with multiple namespaces\n const namespaceInterfaces = namespaceData\n .map(({ namespace, types }) => {\n const typeDefsWithIndent = types\n .map((type) => {\n return type.typeDef\n .split(\"\\n\")\n .map((line) => (line.trim() ? ` ${line}` : \"\"))\n .join(\"\\n\");\n })\n .join(\"\\n\\n\");\n\n return ` \"${namespace}\": {\\n${typeDefsWithIndent}\\n }`;\n })\n .join(\",\\n\");\n\n const namespaceInterface = `export interface Namespace {\\n${namespaceInterfaces}\\n}`;\n\n const getDBFunction = multiline /* ts */ `\n export const getDB = createGetDB<Namespace>();\n\n export type DB<N extends keyof Namespace = keyof Namespace> = NamespaceDB<Namespace, N>;\n `;\n\n const utilityTypeExports = multiline /* ts */ `\n export type Transaction<K extends keyof Namespace | DB = keyof Namespace> =\n NamespaceTransaction<Namespace, K>;\n\n type TableName = NamespaceTableName<Namespace>;\n export type Table<T extends TableName> = NamespaceTable<Namespace, T>;\n\n export type Insertable<T extends TableName> = NamespaceInsertable<Namespace, T>;\n export type Selectable<T extends TableName> = NamespaceSelectable<Namespace, T>;\n export type Updateable<T extends TableName> = NamespaceUpdateable<Namespace, T>;\n `;\n\n return (\n [importsSection, namespaceInterface, getDBFunction, utilityTypeExports].join(\"\\n\\n\") + \"\\n\"\n );\n}\n","import { processKyselyType, generateUnifiedKyselyTypes } from \"./type-processor\";\nimport type { Plugin, GeneratorResult, TailorDBReadyContext } from \"#/plugin/types\";\nimport type { KyselyTypeMetadata, KyselyNamespaceMetadata } from \"./types\";\n\n/** Unique identifier for the Kysely type generator plugin. */\nexport const KyselyGeneratorID = \"@tailor-platform/kysely-type\";\n\ntype KyselyTypePluginOptions = {\n distPath: string;\n};\n\n/**\n * Plugin that generates Kysely type definitions for TailorDB types.\n * @param options - Plugin options\n * @param options.distPath - Output file path for generated types\n * @returns Plugin instance with onTailorDBReady hook\n */\nexport function kyselyTypePlugin(\n options: KyselyTypePluginOptions,\n): Plugin<unknown, KyselyTypePluginOptions> {\n return {\n id: KyselyGeneratorID,\n description: \"Generates Kysely type definitions for TailorDB types\",\n pluginConfig: options,\n\n async onTailorDBReady(\n ctx: TailorDBReadyContext<KyselyTypePluginOptions>,\n ): Promise<GeneratorResult> {\n const allNamespaceData: KyselyNamespaceMetadata[] = [];\n\n for (const ns of ctx.tailordb) {\n const typeMetadataList: KyselyTypeMetadata[] = [];\n\n for (const type of Object.values(ns.types)) {\n const metadata = await processKyselyType(type);\n typeMetadataList.push(metadata);\n }\n\n if (typeMetadataList.length === 0) continue;\n\n const usedUtilityTypes = typeMetadataList.reduce(\n (acc, type) => ({\n Timestamp: acc.Timestamp || type.usedUtilityTypes.Timestamp,\n Serial: acc.Serial || type.usedUtilityTypes.Serial,\n }),\n { Timestamp: false, Serial: false },\n );\n\n allNamespaceData.push({\n namespace: ns.namespace,\n types: typeMetadataList,\n usedUtilityTypes,\n });\n }\n\n const files: GeneratorResult[\"files\"] = [];\n if (allNamespaceData.length > 0) {\n const content = generateUnifiedKyselyTypes(allNamespaceData);\n files.push({\n path: ctx.pluginConfig.distPath,\n content,\n });\n }\n\n return { files };\n },\n };\n}\n"],"mappings":";;;;;;;;AAgBA,SAAS,YAAY,aAA0C;CAC7D,MAAM,gBAAgB,YAAY;CAElC,IAAI,iBAAiB,MAAM,QAAQ,aAAa,GAC9C,OAAO,cACJ,KAAK,MAAkC;EAEtC,OAAO,IADO,OAAO,MAAM,WAAW,IAAI,EAAE,MAC3B;CACnB,CAAC,CAAC,CACD,KAAK,KAAK;CAEf,OAAO;AACT;;;;;;AAOA,SAAS,cAAc,aAAmD;CACxE,MAAM,SAAS,YAAY;CAC3B,IAAI,CAAC,UAAU,OAAO,WAAW,UAC/B,OAAO;EACL,MAAM;EACN,kBAAkB;GAAE,WAAW;GAAO,QAAQ;EAAM;CACtD;CAGF,MAAM,eAAe,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,WAAW,YAAY;EACvE,MAAM,SAAS,kBAAkB,MAAM;EAEvC,OAAO;GACL,WAAW,GAAG,YAFC,OAAO,aAAa,OAAO,MAAM,GAEb,IAAI,OAAO;GAC9C,kBAAkB,OAAO;EAC3B;CACF,CAAC;CAED,MAA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C,CAAC;IAEhD,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,KAAK,GAAG;KAC1C,MAAM,WAAW,MAAM,kBAAkB,IAAI;KAC7C,iBAAiB,KAAK,QAAQ;IAChC;IAEA,IAAI,iBAAiB,WAAW,GAAG;IAEnC,MAAM,mBAAmB,iBAAiB,QACvC,KAAK,UAAU;KACd,WAAW,IAAI,aAAa,KAAK,iBAAiB;KAClD,QAAQ,IAAI,UAAU,KAAK,iBAAiB;IAC9C,IACA;KAAE,WAAW;KAAO,QAAQ;IAAM,CACpC;IAEA,iBAAiB,KAAK;KACpB,WAAW,GAAG;KACd,OAAO;KACP;IACF,CAAC;GACH;GAEA,MAAM,QAAkC,CAAC;GACzC,IAAI,iBAAiB,SAAS,GAAG;IAC/B,MAAM,UAAU,2BAA2B,gBAAgB;IAC3D,MAAM,KAAK;KACT,MAAM,IAAI,aAAa;KACvB;IACF,CAAC;GACH;GAEA,OAAO,EAAE,MAAM;EACjB;CACF;AACF"}
@@ -1,3 +1,3 @@
1
- import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../file-utils-CYZnO1pX.mjs";
1
+ import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "../../../file-utils-yEiIS4nJ.mjs";
2
2
 
3
3
  export { FileUtilsGeneratorID, fileUtilsPlugin };