@tailor-platform/sdk 2.0.0-next.6 → 2.0.0-next.8

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 (62) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/{application-BJXRpQj5.mjs → application-GzW98_Xr.mjs} +199 -172
  3. package/dist/application-GzW98_Xr.mjs.map +1 -0
  4. package/dist/application-OM0taSPn.mjs +3 -0
  5. package/dist/cli/index.mjs +12 -9
  6. package/dist/cli/index.mjs.map +1 -1
  7. package/dist/cli/lib.mjs +2 -2
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/config/types.d.mts +5 -1
  10. package/dist/configure/index.mjs +16 -16
  11. package/dist/configure/index.mjs.map +1 -1
  12. package/dist/configure/services/auth/types.d.mts +18 -23
  13. package/dist/configure/services/executor/operation.d.mts +1 -1
  14. package/dist/configure/services/idp/permission.d.mts +4 -4
  15. package/dist/configure/services/tailordb/permission.d.mts +4 -4
  16. package/dist/configure/services/workflow/job.d.mts +10 -10
  17. package/dist/configure/services/workflow/workflow.d.mts +6 -4
  18. package/dist/{globals-D-YbJKW-.mjs → globals-CBZ0egXT.mjs} +3 -6
  19. package/dist/globals-CBZ0egXT.mjs.map +1 -0
  20. package/dist/{register-ts-hook-DL31O2W9.mjs → register-ts-hook-DvEs6YsL.mjs} +35 -78
  21. package/dist/register-ts-hook-DvEs6YsL.mjs.map +1 -0
  22. package/dist/{registry-CC3CbQiF.mjs → registry-i7EdJ-D5.mjs} +10 -10
  23. package/dist/registry-i7EdJ-D5.mjs.map +1 -0
  24. package/dist/runtime/globals.d.mts +1 -4
  25. package/dist/runtime/index.mjs +1 -1
  26. package/dist/runtime/workflow.d.mts +1 -76
  27. package/dist/runtime/workflow.mjs +1 -1
  28. package/dist/service-BJAQ70e5.mjs +3 -0
  29. package/dist/{service-CnHz9rwz.mjs → service-Dmxa2I4i.mjs} +31 -17
  30. package/dist/service-Dmxa2I4i.mjs.map +1 -0
  31. package/dist/utils/test/index.mjs +11 -11
  32. package/dist/utils/test/index.mjs.map +1 -1
  33. package/dist/utils/test/mock.d.mts +6 -6
  34. package/dist/vitest/environment.mjs +1 -1
  35. package/dist/vitest/index.mjs +67 -99
  36. package/dist/vitest/index.mjs.map +1 -1
  37. package/dist/vitest/mocks/workflow.d.mts +21 -41
  38. package/dist/vitest/setup.mjs +1 -1
  39. package/dist/vitest/workflow-local.d.mts +2 -2
  40. package/dist/workflow-CsBvRE3g.mjs +34 -0
  41. package/dist/workflow-CsBvRE3g.mjs.map +1 -0
  42. package/docs/cli/application.md +2 -0
  43. package/docs/cli/function.md +2 -2
  44. package/docs/cli/tailordb.md +2 -2
  45. package/docs/cli-reference.md +1 -1
  46. package/docs/configuration.md +2 -0
  47. package/docs/github-actions.md +2 -2
  48. package/docs/migration/v2.md +128 -11
  49. package/docs/runtime.md +1 -1
  50. package/docs/services/auth.md +7 -7
  51. package/docs/services/workflow.md +43 -43
  52. package/docs/testing.md +9 -9
  53. package/package.json +2 -2
  54. package/dist/application-BJXRpQj5.mjs.map +0 -1
  55. package/dist/application-BV-AXawv.mjs +0 -3
  56. package/dist/globals-D-YbJKW-.mjs.map +0 -1
  57. package/dist/register-ts-hook-DL31O2W9.mjs.map +0 -1
  58. package/dist/registry-CC3CbQiF.mjs.map +0 -1
  59. package/dist/service-CnHz9rwz.mjs.map +0 -1
  60. package/dist/service-nU6ITOHL.mjs +0 -3
  61. package/dist/workflow-9kHGKxF2.mjs +0 -64
  62. package/dist/workflow-9kHGKxF2.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { DefinedFieldMetadata, FieldMetadata, TailorField, TailorFieldType } from "../../types/field.types.mjs";
2
2
  import { TailorEnv } from "../../../runtime/types.mjs";
3
- import { output } from "../../../types/helpers.mjs";
3
+ import { NullableToOptional, output } from "../../../types/helpers.mjs";
4
4
  import { TailorDBInstance } from "../tailordb/types.mjs";
5
5
  import { AuthConnectionConfig } from "../../../types/auth-connection.generated.mjs";
6
6
  import { IdProvider, OAuth2Client, OAuth2ClientInput, SCIMAttribute, SCIMConfig, TenantProvider } from "../../../types/auth.generated.mjs";
@@ -62,37 +62,32 @@ type UserProfile<User extends TailorDBInstance, Attributes extends UserAttribute
62
62
  };
63
63
  type MachineUserAttributeFields = Record<string, TailorField<DefinedFieldMetadata, unknown, FieldMetadata, TailorFieldType>>;
64
64
  type TailorFieldOutputValue<Field> = Field extends TailorField<DefinedFieldMetadata, infer Output, FieldMetadata, TailorFieldType> ? Output : never;
65
- type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = { [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never; };
66
- type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
67
- attributes?: never;
65
+ type MachineUserAttributeValues<Fields extends MachineUserAttributeFields> = NullableToOptional<{ [K in keyof Fields]: TailorFieldOutputValue<Fields[K]> extends ValueOperand | null | undefined ? TailorFieldOutputValue<Fields[K]> : never; }>;
66
+ type OptionalIfNoRequiredKeys<Attributes> = Record<never, never> extends Attributes ? {
67
+ attributes?: Attributes;
68
68
  } : {
69
- attributes: DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>;
70
- }) & {
71
- attributeList?: string[];
69
+ attributes: Attributes;
72
70
  };
73
- type MachineUser<User extends TailorDBInstance, Attributes extends UserAttributes<User> = UserAttributes<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
74
- attributes: Record<string, AuthAttributeValue>;
75
- attributeList?: string[];
76
- } : (SelectedAttributeKeys<User, Attributes> extends never ? {
71
+ type MachineUserFromAttributes<Fields extends MachineUserAttributeFields> = (keyof Fields extends never ? {
77
72
  attributes?: never;
78
- } : {
79
- attributes: { [K in SelectedAttributeKeys<User, Attributes>]: K extends keyof output<User> ? output<User>[K] : never; } & { [K in Exclude<keyof output<User>, SelectedAttributeKeys<User, Attributes>>]?: never; };
80
- }) & ([] extends AttributeList ? {
81
- attributeList?: never;
82
- } : {
83
- attributeList: AttributeListToTuple<User, AttributeList>;
84
- }) : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
85
- attributes: Record<string, AuthAttributeValue>;
73
+ } : OptionalIfNoRequiredKeys<DisallowExtraKeys<MachineUserAttributeValues<Fields>, keyof Fields>>) & {
86
74
  attributeList?: string[];
87
- } : (SelectedAttributeKeys<User, Attributes> extends never ? {
75
+ };
76
+ type MachineUserProfileAttributes<User extends TailorDBInstance, Attributes extends UserAttributes<User>> = NullableToOptional<{ [K in SelectedAttributeKeys<User, Attributes>]: K extends keyof output<User> ? output<User>[K] : never; }> & { [K in Exclude<keyof output<User>, SelectedAttributeKeys<User, Attributes>>]?: never; };
77
+ type MachineUserFromUserProfile<User extends TailorDBInstance, Attributes extends UserAttributes<User>, AttributeList extends UserAttributeListKey<User>[]> = (SelectedAttributeKeys<User, Attributes> extends never ? {
88
78
  attributes?: never;
89
- } : {
90
- attributes: { [K in SelectedAttributeKeys<User, Attributes>]: K extends keyof output<User> ? output<User>[K] : never; } & { [K in Exclude<keyof output<User>, SelectedAttributeKeys<User, Attributes>>]?: never; };
91
- }) & ([] extends AttributeList ? {
79
+ } : OptionalIfNoRequiredKeys<MachineUserProfileAttributes<User, Attributes>>) & ([] extends AttributeList ? {
92
80
  attributeList?: never;
93
81
  } : {
94
82
  attributeList: AttributeListToTuple<User, AttributeList>;
95
83
  });
84
+ type MachineUser<User extends TailorDBInstance, Attributes extends UserAttributes<User> = UserAttributes<User>, AttributeList extends UserAttributeListKey<User>[] = [], MachineUserAttributes extends MachineUserAttributeFields | undefined = undefined> = IsAny<MachineUserAttributes> extends true ? IsAny<User> extends true ? {
85
+ attributes?: Record<string, AuthAttributeValue>;
86
+ attributeList?: string[];
87
+ } : MachineUserFromUserProfile<User, Attributes, AttributeList> : [MachineUserAttributes] extends [MachineUserAttributeFields] ? MachineUserFromAttributes<MachineUserAttributes> : IsAny<User> extends true ? {
88
+ attributes?: Record<string, AuthAttributeValue>;
89
+ attributeList?: string[];
90
+ } : MachineUserFromUserProfile<User, Attributes, AttributeList>;
96
91
  /** Upstream OAuth provider that federated a login through the Built-in IdP. */
97
92
  type FederatedIdentityProvider = "google" | "microsoft";
98
93
  /**
@@ -33,7 +33,7 @@ type WebhookOperation<Args> = Omit<WebhookOperation$1, "url" | "requestBody" | "
33
33
  * Extract mainJob's Input type from Workflow.
34
34
  * Workflow<Job> -> Job is WorkflowJob<Name, Input, Output> -> Input
35
35
  */
36
- type WorkflowInput<W extends Workflow> = Parameters<W["trigger"]>[0];
36
+ type WorkflowInput<W extends Workflow> = Parameters<W["start"]>[0];
37
37
  type WorkflowArgs<Args, W extends Workflow> = WorkflowInput<W> | ((args: Args) => WorkflowInput<W>);
38
38
  type WorkflowArgsProperty<Args, W extends Workflow> = undefined extends WorkflowInput<W> ? {
39
39
  args?: WorkflowArgs<Args, W>;
@@ -3,10 +3,10 @@ import { IdPUserField } from "../../../parser/service/idp/types.mjs";
3
3
  //#region src/configure/services/idp/permission.d.ts
4
4
  type EqualityOperator = "=" | "!=";
5
5
  type ContainsOperator = "in" | "not in";
6
- type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never; }[keyof User];
7
- type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never; }[keyof User];
8
- type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never; }[keyof User];
9
- type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never; }[keyof User];
6
+ type StringFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends string ? K : never; }[keyof User];
7
+ type StringArrayFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends string[] ? K : never; }[keyof User];
8
+ type BooleanFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends boolean ? K : never; }[keyof User];
9
+ type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends boolean[] ? K : never; }[keyof User];
10
10
  type UserStringOperand<User extends object = InferredAttributes> = {
11
11
  user: StringFieldKeys<User> | "id";
12
12
  };
@@ -47,10 +47,10 @@ type GqlPermissionAction = "read" | "create" | "update" | "delete" | "aggregate"
47
47
  type EqualityOperator = "=" | "!=";
48
48
  type ContainsOperator = "in" | "not in";
49
49
  type HasAnyOperator = "hasAny" | "not hasAny";
50
- type StringFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string ? K : never; }[keyof User];
51
- type StringArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends string[] ? K : never; }[keyof User];
52
- type BooleanFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean ? K : never; }[keyof User];
53
- type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]: User[K] extends boolean[] ? K : never; }[keyof User];
50
+ type StringFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends string ? K : never; }[keyof User];
51
+ type StringArrayFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends string[] ? K : never; }[keyof User];
52
+ type BooleanFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends boolean ? K : never; }[keyof User];
53
+ type BooleanArrayFieldKeys<User extends object> = { [K in keyof User]-?: Exclude<User[K], undefined> extends boolean[] ? K : never; }[keyof User];
54
54
  type UserStringOperand<User extends object = InferredAttributes> = {
55
55
  user: StringFieldKeys<User> | "id";
56
56
  };
@@ -1,6 +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
+ import { StartJobFunctionOptions } from "../../../runtime/workflow.mjs";
4
4
  //#region src/configure/services/workflow/job.d.ts
5
5
  /**
6
6
  * Context object passed as the second argument to workflow job body functions.
@@ -16,29 +16,29 @@ type WorkflowJobContext = {
16
16
  */
17
17
  type JobBody<I, O> = [null] extends [I] ? TypeLevelError<"Input cannot be null at the top level"> : [I] extends [undefined] ? [O] extends [JsonCompatible<O> | undefined | void] ? (input: I, context: WorkflowJobContext) => O | Promise<O> : TypeLevelError<"Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)"> : [undefined] extends [I] ? TypeLevelError<"Input cannot include undefined at the top level"> : [I] extends [JsonCompatible<I>] ? [O] extends [JsonCompatible<O> | undefined | void] ? (input: I, context: WorkflowJobContext) => O | Promise<O> : TypeLevelError<"Output must be JsonValue-compatible (plain objects/arrays; no class instances or functions)"> : TypeLevelError<"Input must be JsonValue-compatible (plain objects/arrays; no class instances or functions)">;
18
18
  /**
19
- * WorkflowJob represents a job that can be triggered in a workflow.
19
+ * WorkflowJob represents a job that can be started from a workflow.
20
20
  *
21
21
  * Type constraints:
22
22
  * - Input: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions) or undefined.
23
23
  * - Output: Must be JsonValue-compatible (plain objects/arrays; no class instances or functions), undefined, or void.
24
- * - Trigger returns `Awaited<Output>` as-is (no Promise or Jsonify transformation).
24
+ * - Start returns `Awaited<Output>` as-is (no Promise or Jsonify transformation).
25
25
  */
26
26
  interface WorkflowJob<Name extends string = string, Input = undefined, Output = undefined> {
27
27
  name: Name;
28
28
  /**
29
- * Trigger this job with the given input and return the job's output value.
29
+ * Start this job with the given input and return the job's output value.
30
30
  * Accepts an optional second argument to pass `executionPolicyKey` for
31
31
  * platform-side concurrency enforcement.
32
32
  * @example
33
33
  * body: async (input) => {
34
- * const a = jobA.trigger({ id: input.id });
35
- * const b = jobB.trigger({ id: input.id }, {
34
+ * const a = jobA.start({ id: input.id });
35
+ * const b = jobB.start({ id: input.id }, {
36
36
  * executionPolicyKey: `tenant-api.${input.tenantId}`,
37
37
  * });
38
38
  * return { a, b };
39
39
  * }
40
40
  */
41
- trigger: [Input] extends [undefined] ? (input?: undefined, options?: TriggerJobFunctionOptions) => Awaited<Output> : (input: Input, options?: TriggerJobFunctionOptions) => Awaited<Output>;
41
+ start: [Input] extends [undefined] ? (input?: undefined, options?: StartJobFunctionOptions) => Awaited<Output> : (input: Input, options?: StartJobFunctionOptions) => Awaited<Output>;
42
42
  body: (input: Input, context: WorkflowJobContext) => Output | Promise<Output>;
43
43
  }
44
44
  interface CreateWorkflowJobConfig<Name extends string, I, O> {
@@ -57,7 +57,7 @@ interface CreateWorkflowJobConfig<Name extends string, I, O> {
57
57
  * @param config - Job configuration with name and body function.
58
58
  * @param config.name - Unique job name across the project.
59
59
  * @param config.body - Function that processes the job input.
60
- * @returns A WorkflowJob that can be triggered from other jobs.
60
+ * @returns A WorkflowJob that can be started from other jobs.
61
61
  * @example
62
62
  * // Simple job with async body:
63
63
  * export const fetchData = createWorkflowJob({
@@ -72,8 +72,8 @@ interface CreateWorkflowJobConfig<Name extends string, I, O> {
72
72
  * export const orchestrate = createWorkflowJob({
73
73
  * name: "orchestrate",
74
74
  * body: (input: { orderId: string }) => {
75
- * const inventory = checkInventory.trigger({ orderId: input.orderId });
76
- * const payment = processPayment.trigger({ orderId: input.orderId });
75
+ * const inventory = checkInventory.start({ orderId: input.orderId });
76
+ * const payment = processPayment.start({ orderId: input.orderId });
77
77
  * return { inventory, payment };
78
78
  * },
79
79
  * });
@@ -14,7 +14,9 @@ interface Workflow<Job extends WorkflowJob<any, any, any> = WorkflowJob<any, any
14
14
  mainJob: Job;
15
15
  retryPolicy?: RetryPolicy;
16
16
  concurrencyPolicy?: ConcurrencyPolicy;
17
- trigger: (args: Parameters<Job["trigger"]>[0], options?: {
17
+ start: [Parameters<Job["start"]>[0]] extends [undefined] ? (args?: undefined, options?: {
18
+ invoker: MachineUserName;
19
+ }) => Promise<string> : (args: Parameters<Job["start"]>[0], options?: {
18
20
  invoker: MachineUserName;
19
21
  }) => Promise<string>;
20
22
  }
@@ -25,8 +27,8 @@ interface WorkflowDefinition<Job extends WorkflowJob<any, any, any>> {
25
27
  concurrencyPolicy?: ConcurrencyPolicy;
26
28
  }
27
29
  /**
28
- * Create a workflow definition that can be triggered via the Tailor SDK.
29
- * In production, bundler transforms .trigger() calls to tailor.workflow.triggerWorkflow().
30
+ * Create a workflow definition that can be started via the Tailor SDK.
31
+ * In production, the bundler rewrites `.start()` calls into direct platform workflow calls.
30
32
  *
31
33
  * The workflow MUST be the default export of the file.
32
34
  * All jobs referenced by the workflow MUST be named exports.
@@ -38,7 +40,7 @@ interface WorkflowDefinition<Job extends WorkflowJob<any, any, any>> {
38
40
  * export const processData = createWorkflowJob({
39
41
  * name: "process-data",
40
42
  * body: (input: { id: string }) => {
41
- * const data = fetchData.trigger({ id: input.id });
43
+ * const data = fetchData.start({ id: input.id });
42
44
  * return { data };
43
45
  * },
44
46
  * });
@@ -1,4 +1,4 @@
1
- import { t as TRIGGER_DEFAULT } from "./registry-CC3CbQiF.mjs";
1
+ import { t as START_DEFAULT } from "./registry-i7EdJ-D5.mjs";
2
2
  import { t as platformSerialize } from "./platform-serialize-RoRtBS0v.mjs";
3
3
 
4
4
  //#region src/vitest/workflow-runtime.ts
@@ -8,16 +8,13 @@ function createDefaultWorkflowRuntime() {
8
8
  };
9
9
  const startWorkflow = async (_name, args) => {
10
10
  platformSerialize(args);
11
- return TRIGGER_DEFAULT;
11
+ return START_DEFAULT;
12
12
  };
13
13
  const resumeWorkflowExecution = async (executionId) => executionId;
14
14
  return {
15
15
  startJobFunction,
16
- triggerJobFunction: startJobFunction,
17
16
  startWorkflow,
18
- triggerWorkflow: startWorkflow,
19
17
  resumeWorkflowExecution,
20
- resumeWorkflow: resumeWorkflowExecution,
21
18
  wait: (key) => {
22
19
  throw new Error(`No wait handler for "${key}". Acquire mockWorkflow() and call setWaitHandler(...).`);
23
20
  },
@@ -118,4 +115,4 @@ function cleanupPlatformGlobals(global) {
118
115
 
119
116
  //#endregion
120
117
  export { cleanupPlatformGlobals as n, installPlatformGlobals as r, RUNTIME_FLAG_KEY as t };
121
- //# sourceMappingURL=globals-D-YbJKW-.mjs.map
118
+ //# sourceMappingURL=globals-CBZ0egXT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals-CBZ0egXT.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 { START_DEFAULT } from \"../configure/services/workflow/registry\";\nimport { platformSerialize } from \"../utils/test/platform-serialize\";\nimport type { StartJobFunctionOptions, StartWorkflowOptions } from \"../runtime/workflow\";\n\nexport interface DefaultWorkflowRuntime {\n startJobFunction: (name: string, args?: unknown, options?: StartJobFunctionOptions) => unknown;\n startWorkflow: (name: string, args?: unknown, options?: StartWorkflowOptions) => Promise<string>;\n resumeWorkflowExecution: (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 const startJobFunction: DefaultWorkflowRuntime[\"startJobFunction\"] = (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 const startWorkflow: DefaultWorkflowRuntime[\"startWorkflow\"] = async (_name, args) => {\n platformSerialize(args);\n return START_DEFAULT;\n };\n const resumeWorkflowExecution: DefaultWorkflowRuntime[\"resumeWorkflowExecution\"] = async (\n executionId,\n ) => executionId;\n return {\n startJobFunction,\n startWorkflow,\n resumeWorkflowExecution,\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\n // runner: job/wait/resolve calls throw a helpful error, and workflow starts\n // return a placeholder execution id, unless overlaid by `mockWorkflow()` or\n // `runWorkflowLocally()`.\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":";;;;AAmBA,SAAgB,+BAAuD;CACrE,MAAM,oBAAgE,SAAS;EAC7E,MAAM,IAAI,MACR,6BAA6B,KAAK,uIACpC;CACF;CACA,MAAM,gBAAyD,OAAO,OAAO,SAAS;EACpF,kBAAkB,IAAI;EACtB,OAAO;CACT;CACA,MAAM,0BAA6E,OACjF,gBACG;CACL,OAAO;EACL;EACA;EACA;EACA,OAAO,QAAyB;GAC9B,MAAM,IAAI,MACR,wBAAwB,IAAI,wDAC9B;EACF;EACA,SAAS,YAA2B;GAClC,MAAM,IAAI,MACR,6EACF;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;ACtBA,MAAa,mBAAmB;AAWhC,IAAM,mBAAN,cAA+B,MAAM;CACnC;CAEA,YAAY,QAA2B;EACrC,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,MAAM,IAAI,UAAU,uCAAuC;EAE7D,MAAM,YAAY,OAAO,KAAK,GAAG,MAAM;GACrC,IAAI,OAAO,EAAE,YAAY,UACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,2BAA2B;GAE3E,IAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,GACvB,MAAM,IAAI,UAAU,wBAAwB,EAAE,wBAAwB;GAExE,OAAO;IAAE,SAAS,EAAE;IAAS,MAAM,EAAE;GAAK;EAC5C,CAAC;EAID,MAAM,iBAAiB,KAAK,UAAU,EAAE,QAAQ,UAAU,CAAC,GAAG;EAC9D,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAEA,IAAM,yBAAN,cAAqC,MAAM;CACzC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,IAAM,wBAAN,cAAoC,MAAM;CACxC;CACA,AAAS;CAET,YAAY,SAAiB,MAA8B,OAAiB;EAC1E,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;AASA,SAAS,oBAA2C;CAClD,OAAO;AACT;;;;;;;AAQA,SAAgB,uBAAuB,QAAiC;CACtE,MAAM,IAAI;CAEV,EAAE,oBAAoB;CAOtB,EAAE,SAAS;EACT,SAAS,EAAE,YAAY,kBAAkB;EACzC,UAAU,6BAA6B;CACzC;CACA,EAAE,WAAW,CAAC;CAEd,EAAE,eAAe;CACjB,EAAE,qBAAqB;CACvB,EAAE,oBAAoB;AACxB;;;;;;AAOA,SAAgB,uBAAuB,QAAiC;CACtE,MAAM,IAAI;CACV,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;CACT,OAAO,EAAE;AACX"}
@@ -2,8 +2,8 @@ import { t as db } from "./schema--xYWRGfe.mjs";
2
2
  import { $ as CreateAuthIDPConfigRequestSchema, A as CreatePipelineResolverRequestSchema, At as TenantProviderConfig_TenantProviderType, B as IdPPermissionOperator, Bt as CreateAIGatewayRequestSchema, C as UpdateStaticWebsiteRequestSchema, Ct as AuthOAuth2Client_ClientType, D as CreateSecretManagerVaultRequestSchema, Dt as AuthSCIMAttribute_Uniqueness, E as CreateSecretManagerSecretRequestSchema, Et as AuthSCIMAttribute_Type, F as PipelineResolver_OperationType, Ft as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, G as CreateExecutorExecutorRequestSchema, Gt as ConditionSchema, H as FunctionExecution_Status, I as CreateIdPServiceRequestSchema, It as UpdateApplicationRequestSchema, J as ExecutorJobStatus, Jt as PageDirection, K as UpdateExecutorExecutorRequestSchema, Kt as Condition_Operator, L as UpdateIdPServiceRequestSchema, M as UpdatePipelineResolverRequestSchema, N as UpdatePipelineServiceRequestSchema, O as UpdateSecretManagerSecretRequestSchema, Ot as AuthSCIMConfig_AuthorizationType, Pt as CreateApplicationRequestSchema, Q as CreateAuthHookRequestSchema, Rt as ApplicationSchemaUpdateAttemptStatus, S as CreateStaticWebsiteRequestSchema, St as AuthInvokerSchema, Tt as AuthSCIMAttribute_Mutability, V as IdPPermissionPermit, Vt as UpdateAIGatewayRequestSchema, X as ExecutorTriggerType, Y as ExecutorTargetType, Z as CreateAuthConnectionRequestSchema, _ as TailorDBGQLPermission_Permit, a as CreateWorkflowRequestSchema, at as CreateTenantConfigRequestSchema, b as TailorDBType_PermitAction, bt as AuthHookPoint, ct as UpdateAuthHookRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as UpdateAuthOAuth2ClientRequestSchema, et as CreateAuthMachineUserRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as UpdateAuthSCIMConfigRequestSchema, g as TailorDBGQLPermission_Operator, gt as UpdateUserProfileConfigRequestSchema, h as TailorDBGQLPermission_Action, ht as UpdateTenantConfigRequestSchema, i as CreateWorkflowJobFunctionRequestSchema, it as CreateAuthServiceRequestSchema, j as CreatePipelineServiceRequestSchema, jt as UserProfileProviderConfig_UserProfileProviderType, l as WorkflowExecution_Status, lt as UpdateAuthIDPConfigRequestSchema, mt as UpdateAuthServiceRequestSchema, nt as CreateAuthSCIMConfigRequestSchema, o as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as CreateUserProfileConfigRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as UpdateAuthSCIMResourceRequestSchema, qt as FilterSchema, r as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, rt as CreateAuthSCIMResourceRequestSchema, s as UpdateWorkflowRequestSchema, st as UpdateAuthConnectionRequestSchema, t as WorkspacePlatformUserRole, tt as CreateAuthOAuth2ClientRequestSchema, u as WorkflowJobExecution_Status, ut as UpdateAuthMachineUserRequestSchema, v as TailorDBType_Permission_Operator, vt as AuthConnection_Status, wt as AuthOAuth2Client_GrantType, x as AddCustomDomainRequestSchema, xt as AuthIDPConfig_AuthType, y as TailorDBType_Permission_Permit, yt as AuthConnection_Type, z as IdPLang, zt as Subgraph_ServiceType } from "./workspace_resource_pb-Db3fv68L.mjs";
3
3
  import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
4
4
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-BwS4ppwO.mjs";
5
- import { A as fetchAllTolerant, B as initOperatorClient, C as createBundleCache, E as hashFile, F as getConsoleBaseUrl, G as byName, H as normalizeBaseUrl, I as getOAuth2ClientId, K as LOG_LEVELS, L as getOrNull, M as fetchPaged, O as defaultPlatformBaseUrl, P as fetchUserInfo, R as getPlatformBaseUrl, S as hasGenerationHooks, T as hashContent, U as rememberPlatformConfigForToken, V as isDefaultPlatform, W as resolveStaticWebsiteUrls, _ as platformBundleDefinePlugin, f as buildExecutorArgsExpr, g as stringifyFunction, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, j as fetchMachineUserToken, k as fetchAll, m as assertUniqueLocalTailorDBTypeNames, n as generatePluginFilesIfNeeded, o as getApplicationAuthNamespace, p as buildResolverOperationHookExpr, r as loadApplication, s as WorkflowJobFunctionExecutionPolicySchema, t as defineApplication, u as HTTP_METHODS, w as getDistDir, x as getPluginGenerationDependencies, z as initOAuth2Client } from "./application-BJXRpQj5.mjs";
6
- import { c as stripTailorDBTypeBuilderHelpers, g as functionSchema, h as loadFilesWithIgnores, t as createExecutorService, u as TailorDBTypeSchema } from "./service-CnHz9rwz.mjs";
5
+ import { A as fetchAllTolerant, B as initOperatorClient, C as createBundleCache, E as hashFile, F as getConsoleBaseUrl, G as byName, H as normalizeBaseUrl, I as getOAuth2ClientId, K as LOG_LEVELS, L as getOrNull, M as fetchPaged, O as defaultPlatformBaseUrl, P as fetchUserInfo, R as getPlatformBaseUrl, S as hasGenerationHooks, T as hashContent, U as rememberPlatformConfigForToken, V as isDefaultPlatform, W as resolveStaticWebsiteUrls, _ as platformBundleDefinePlugin, f as buildExecutorArgsExpr, g as stringifyFunction, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, j as fetchMachineUserToken, k as fetchAll, m as assertUniqueLocalTailorDBTypeNames, n as generatePluginFilesIfNeeded, o as getApplicationAuthNamespace, p as buildResolverOperationHookExpr, r as loadApplication, s as WorkflowJobFunctionExecutionPolicySchema, t as defineApplication, u as HTTP_METHODS, w as getDistDir, x as getPluginGenerationDependencies, z as initOAuth2Client } from "./application-GzW98_Xr.mjs";
6
+ import { c as stripTailorDBTypeBuilderHelpers, g as functionSchema, h as loadFilesWithIgnores, t as createExecutorService, u as TailorDBTypeSchema } from "./service-Dmxa2I4i.mjs";
7
7
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
8
8
  import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
9
9
  import { t as userAgent } from "./user-agent-Bgsszb5I.mjs";
@@ -39,14 +39,14 @@ import * as rolldown from "rolldown";
39
39
  import { parseSync } from "oxc-parser";
40
40
  import * as inflection from "inflection";
41
41
  import { tmpdir } from "node:os";
42
- import * as fs$1 from "node:fs/promises";
43
- import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
44
42
  import { pathToString } from "@bufbuild/protobuf/reflect";
45
43
  import { createValidator } from "@bufbuild/protovalidate";
44
+ import * as fs from "node:fs/promises";
45
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
46
46
  import { setTimeout as setTimeout$1 } from "timers/promises";
47
47
  import { setTimeout as setTimeout$2 } from "node:timers/promises";
48
48
  import { spawn } from "node:child_process";
49
- import * as fs from "fs";
49
+ import * as fs$1 from "fs";
50
50
  import { lookup } from "mime-types";
51
51
  import { createPrompt } from "@toiroakr/read-multiline";
52
52
  import { astVisitor, parse } from "pgsql-ast-parser";
@@ -1458,54 +1458,6 @@ function createCacheManager(options) {
1458
1458
  };
1459
1459
  }
1460
1460
 
1461
- //#endregion
1462
- //#region src/cli/services/stale-cleanup.ts
1463
- const legacyBundleDirectories = [
1464
- {
1465
- name: "resolvers",
1466
- suffixes: [".entry.js"]
1467
- },
1468
- {
1469
- name: "executors",
1470
- suffixes: [".entry.js"]
1471
- },
1472
- {
1473
- name: "workflow-jobs",
1474
- suffixes: [".js", ".js.map"]
1475
- },
1476
- {
1477
- name: "auth-hooks",
1478
- suffixes: [".entry.js"]
1479
- },
1480
- {
1481
- name: "http-adapters",
1482
- suffixes: [".entry.js"]
1483
- }
1484
- ];
1485
- /**
1486
- * Remove bundle artifacts created by SDK versions that used disk-backed entries.
1487
- *
1488
- * Concurrent callers are safe because current bundlers no longer create files
1489
- * in these directories and each removal uses `force: true`.
1490
- * @param outputRoot - SDK output directory
1491
- */
1492
- async function removeLegacyBundleFiles(outputRoot) {
1493
- await Promise.all([...legacyBundleDirectories.map(({ name, suffixes }) => removeMatchingFiles(path.join(outputRoot, name), suffixes)), fs$1.rm(path.join(outputRoot, "hooks-validate-scripts"), {
1494
- recursive: true,
1495
- force: true
1496
- })]);
1497
- }
1498
- async function removeMatchingFiles(outputDir, suffixes) {
1499
- let files;
1500
- try {
1501
- files = await fs$1.readdir(outputDir);
1502
- } catch (error) {
1503
- if (error.code === "ENOENT") return;
1504
- throw error;
1505
- }
1506
- for (const file of files) if (suffixes.some((suffix) => file.endsWith(suffix))) await fs$1.rm(path.join(outputDir, file), { force: true });
1507
- }
1508
-
1509
1461
  //#endregion
1510
1462
  //#region src/cli/shared/type-generator.ts
1511
1463
  /**
@@ -1529,7 +1481,7 @@ function extractAttributesFromConfig(config) {
1529
1481
  * @returns Generated type definition source
1530
1482
  */
1531
1483
  function generateTypeDefinition(attributes, attributeList, env, machineUserNames, idpNames, connectionNames, aiGatewayNames) {
1532
- const attributeFields = attributes ? Object.entries(attributes).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
1484
+ const attributeFields = attributes ? Object.entries(attributes).map(([key, { type, optional }]) => ` ${key}${optional ? "?" : ""}: ${type};`).join("\n") : "";
1533
1485
  const attributesBody = !attributes || Object.keys(attributes).length === 0 ? "{}" : `{
1534
1486
  ${attributeFields}
1535
1487
  }`;
@@ -1592,12 +1544,15 @@ function collectAttributesFromConfig(config) {
1592
1544
  const inferAttributeType = (field) => {
1593
1545
  const type = field?.type;
1594
1546
  const metadata = field?.metadata;
1595
- if (!metadata) return "string";
1547
+ if (!metadata) return { type: "string" };
1596
1548
  let typeStr = "string";
1597
1549
  if (type === "boolean") typeStr = "boolean";
1598
1550
  else if (type === "enum" && metadata.allowedValues) typeStr = metadata.allowedValues.map((v) => `"${v.value}"`).join(" | ");
1599
1551
  if (metadata.array) typeStr = typeStr.includes(" | ") ? `(${typeStr})[]` : `${typeStr}[]`;
1600
- return typeStr;
1552
+ return {
1553
+ type: typeStr,
1554
+ optional: metadata.required === false
1555
+ };
1601
1556
  };
1602
1557
  if ("userProfile" in auth) {
1603
1558
  const userProfile = auth.userProfile;
@@ -13634,7 +13589,6 @@ async function loadDeployConfig(params) {
13634
13589
  }
13635
13590
  async function buildDeploymentTargets(params) {
13636
13591
  const { configPaths, loadedConfigs, buildTarget = buildDeploymentTarget, ...targetParams } = params;
13637
- await removeLegacyBundleFiles(path.resolve(getDistDir()));
13638
13592
  return Promise.all(configPaths.map((configPath, index) => buildTarget({
13639
13593
  ...targetParams,
13640
13594
  configPath,
@@ -16781,7 +16735,10 @@ function createGenerationManager(params) {
16781
16735
  const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, app.tailorDBServices, config.path);
16782
16736
  return {
16783
16737
  pluginExecutorFiles,
16784
- executorService: app.executorService ?? (pluginExecutorFiles.length > 0 ? createExecutorService({ config: { files: [] } }) : void 0)
16738
+ executorService: app.executorService ?? (pluginExecutorFiles.length > 0 ? createExecutorService({
16739
+ config: { files: [] },
16740
+ baseDir: path.dirname(config.path)
16741
+ }) : void 0)
16785
16742
  };
16786
16743
  });
16787
16744
  if (app.authService) {
@@ -17989,7 +17946,7 @@ async function uploadDirectory(client, workspaceId, deploymentId, rootDir, showP
17989
17946
  */
17990
17947
  async function collectFiles(rootDir, currentDir = "") {
17991
17948
  const dirPath = path.join(rootDir, currentDir);
17992
- const entries = await fs.promises.readdir(dirPath, { withFileTypes: true });
17949
+ const entries = await fs$1.promises.readdir(dirPath, { withFileTypes: true });
17993
17950
  const files = [];
17994
17951
  for (const entry of entries) {
17995
17952
  const rel = path.join(currentDir, entry.name);
@@ -18008,7 +17965,7 @@ async function uploadSingleFile(client, workspaceId, deploymentId, rootDir, file
18008
17965
  return;
18009
17966
  }
18010
17967
  const contentType = mime;
18011
- const readStream = fs.createReadStream(absPath, { highWaterMark: CHUNK_SIZE });
17968
+ const readStream = fs$1.createReadStream(absPath, { highWaterMark: CHUNK_SIZE });
18012
17969
  async function* requestStream() {
18013
17970
  yield { payload: {
18014
17971
  case: "initialMetadata",
@@ -18071,7 +18028,7 @@ const deployCommand = defineAppCommand({
18071
18028
  workspaceId: args["workspace-id"],
18072
18029
  profile: args.profile
18073
18030
  });
18074
- if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) throw new Error(`Directory not found or not a directory: ${dir}`);
18031
+ if (!fs$1.existsSync(dir) || !fs$1.statSync(dir).isDirectory()) throw new Error(`Directory not found or not a directory: ${dir}`);
18075
18032
  const { url, skippedFiles } = await withTimeout(deployStaticWebsite(client, workspaceId, name, dir, !args.json), 10 * 6e4, "Deployment timed out after 10 minutes.");
18076
18033
  if (args.json) logger.out({
18077
18034
  name,
@@ -18420,7 +18377,7 @@ function generateFieldType(config, isOptionalToRequired, enumValueChange) {
18420
18377
  async function writeDbTypesFile(snapshot, migrationsDir, migrationNumber, diff) {
18421
18378
  const content = generateDbTypesFromSnapshot(snapshot, diff);
18422
18379
  const filePath = getMigrationFilePath(migrationsDir, migrationNumber, "db");
18423
- await fs$1.writeFile(filePath, content);
18380
+ await fs.writeFile(filePath, content);
18424
18381
  return filePath;
18425
18382
  }
18426
18383
 
@@ -18442,7 +18399,7 @@ async function writeDbTypesFile(snapshot, migrationsDir, migrationNumber, diff)
18442
18399
  */
18443
18400
  async function fileExists(filePath) {
18444
18401
  try {
18445
- await fs$1.access(filePath);
18402
+ await fs.access(filePath);
18446
18403
  return true;
18447
18404
  } catch {
18448
18405
  return false;
@@ -18465,10 +18422,10 @@ async function ensureFileNotExists(filePath) {
18465
18422
  */
18466
18423
  async function generateSchemaFile(snapshot, migrationsDir, migrationNumber) {
18467
18424
  const migrationDir = getMigrationDirPath(migrationsDir, migrationNumber);
18468
- await fs$1.mkdir(migrationDir, { recursive: true });
18425
+ await fs.mkdir(migrationDir, { recursive: true });
18469
18426
  const filePath = getMigrationFilePath(migrationsDir, migrationNumber, "schema");
18470
18427
  await ensureFileNotExists(filePath);
18471
- await fs$1.writeFile(filePath, JSON.stringify(snapshot, null, 2));
18428
+ await fs.writeFile(filePath, JSON.stringify(snapshot, null, 2));
18472
18429
  return {
18473
18430
  filePath,
18474
18431
  migrationNumber
@@ -18485,7 +18442,7 @@ async function generateSchemaFile(snapshot, migrationsDir, migrationNumber) {
18485
18442
  */
18486
18443
  async function generateDiffFiles(diff, migrationsDir, migrationNumber, previousSnapshot, description) {
18487
18444
  const migrationDir = getMigrationDirPath(migrationsDir, migrationNumber);
18488
- await fs$1.mkdir(migrationDir, { recursive: true });
18445
+ await fs.mkdir(migrationDir, { recursive: true });
18489
18446
  const diffFilePath = getMigrationFilePath(migrationsDir, migrationNumber, "diff");
18490
18447
  const migrateFilePath = getMigrationFilePath(migrationsDir, migrationNumber, "migrate");
18491
18448
  const dbTypesFilePath = getMigrationFilePath(migrationsDir, migrationNumber, "db");
@@ -18498,14 +18455,14 @@ async function generateDiffFiles(diff, migrationsDir, migrationNumber, previousS
18498
18455
  ...diff,
18499
18456
  description
18500
18457
  };
18501
- await fs$1.writeFile(diffFilePath, JSON.stringify(diff, null, 2));
18458
+ await fs.writeFile(diffFilePath, JSON.stringify(diff, null, 2));
18502
18459
  const result = {
18503
18460
  diffFilePath,
18504
18461
  migrationNumber
18505
18462
  };
18506
18463
  if (diff.requiresMigrationScript) {
18507
18464
  const scriptContent = generateMigrationScript(diff);
18508
- await fs$1.writeFile(migrateFilePath, scriptContent);
18465
+ await fs.writeFile(migrateFilePath, scriptContent);
18509
18466
  result.migrateFilePath = migrateFilePath;
18510
18467
  await writeDbTypesFile(previousSnapshot, migrationsDir, migrationNumber, diff);
18511
18468
  result.dbTypesFilePath = dbTypesFilePath;
@@ -18662,7 +18619,7 @@ async function handleInitOption(namespaces, skipConfirmation) {
18662
18619
  logger.newline();
18663
18620
  }
18664
18621
  for (const { namespace, migrationsDir } of existingDirs) try {
18665
- await fs$1.rm(migrationsDir, {
18622
+ await fs.rm(migrationsDir, {
18666
18623
  recursive: true,
18667
18624
  force: true
18668
18625
  });
@@ -18692,7 +18649,7 @@ async function generate(options) {
18692
18649
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
18693
18650
  let pluginManager;
18694
18651
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
18695
- const { defineApplication } = await import("./application-BV-AXawv.mjs");
18652
+ const { defineApplication } = await import("./application-OM0taSPn.mjs");
18696
18653
  const application = defineApplication({
18697
18654
  config,
18698
18655
  pluginManager
@@ -18794,7 +18751,7 @@ async function generateDiffFromSnapshot(previousSnapshot, currentSnapshot, migra
18794
18751
  const editor = getConfiguredEditorCommand();
18795
18752
  if (!editor) return;
18796
18753
  try {
18797
- await fs$1.access(result.migrateFilePath);
18754
+ await fs.access(result.migrateFilePath);
18798
18755
  } catch {
18799
18756
  return;
18800
18757
  }
@@ -20171,7 +20128,7 @@ async function loadTypeFieldOrder(config, namespace) {
20171
20128
  const fieldOrder = /* @__PURE__ */ new Map();
20172
20129
  const dbConfig = config.db?.[namespace];
20173
20130
  if (!dbConfig || !("files" in dbConfig) || dbConfig.files.length === 0) return fieldOrder;
20174
- const typeFiles = loadFilesWithIgnores(dbConfig);
20131
+ const typeFiles = loadFilesWithIgnores(dbConfig, path.dirname(config.path));
20175
20132
  await Promise.all(typeFiles.map(async (typeFile) => {
20176
20133
  try {
20177
20134
  const module = await import(pathToFileURL(typeFile).href);
@@ -20321,7 +20278,7 @@ async function resolveQueryCommandInput(args) {
20321
20278
  };
20322
20279
  if (args.file != null) return {
20323
20280
  mode: "query",
20324
- query: await fs$1.readFile(args.file, "utf-8")
20281
+ query: await fs.readFile(args.file, "utf-8")
20325
20282
  };
20326
20283
  if (args.edit) return await resolveEditedQueryInput(args.engine);
20327
20284
  return { mode: "repl" };
@@ -20329,25 +20286,25 @@ async function resolveQueryCommandInput(args) {
20329
20286
  async function resolveEditedQueryInput(engine) {
20330
20287
  if (!process.stdin.isTTY || !process.stdout.isTTY) throw new Error("Non-interactive terminals are not supported. Pass -q/--query or -f/--file to run a query.");
20331
20288
  const editor = getEditorCommand();
20332
- const tempDir = await fs$1.mkdtemp(path.join(tmpdir(), "tailor-query-"));
20289
+ const tempDir = await fs.mkdtemp(path.join(tmpdir(), "tailor-query-"));
20333
20290
  const fileExtension = engine === "sql" ? "sql" : "graphql";
20334
20291
  const filePath = path.join(tempDir, `query.${fileExtension}`);
20335
20292
  const initialQuery = "";
20336
20293
  try {
20337
- await fs$1.writeFile(filePath, initialQuery, "utf-8");
20294
+ await fs.writeFile(filePath, initialQuery, "utf-8");
20338
20295
  try {
20339
20296
  await openInEditor(filePath, editor);
20340
20297
  } catch (error) {
20341
20298
  throw new Error(`Failed to open query editor "${editor}": ${error instanceof Error ? error.message : String(error)}`, { cause: error });
20342
20299
  }
20343
- const editedQuery = await fs$1.readFile(filePath, "utf-8");
20300
+ const editedQuery = await fs.readFile(filePath, "utf-8");
20344
20301
  if (editedQuery.trim().length === 0 || editedQuery === initialQuery) return { mode: "abort" };
20345
20302
  return {
20346
20303
  mode: "query",
20347
20304
  query: editedQuery
20348
20305
  };
20349
20306
  } finally {
20350
- await fs$1.rm(tempDir, {
20307
+ await fs.rm(tempDir, {
20351
20308
  recursive: true,
20352
20309
  force: true
20353
20310
  });
@@ -20788,4 +20745,4 @@ async function registerTsHook(tsHookUrl) {
20788
20745
 
20789
20746
  //#endregion
20790
20747
  export { updateFolder as $, saveUserTokens as $n, bundleMigrationScript as $t, generate as A, sdkNameLabelKey as An, listExecutorJobs as At, extractOwnedNamespaces as B, hasUserTokenEntry as Bn, getCommand$6 as Bt, waitWorkflowExecution as C, formatMigrationNumber as Cn, triggerCommand as Ct, listWorkflows as D, hasChanges as Dn, getExecutorJob as Dt, listCommand$2 as E, formatMigrationDiff as En, listExecutors as Et, openInConfiguredEditor as F, assertWritable as Fn, getWorkflow as Ft, updateOrganization as G, loadPlatformClientConfig as Gn, listWorkspaces as Gt, remove as H, loadConfigPath as Hn, deploy as Ht, deployCommand as I, loadConfig as In, executionsCommand as It, listCommand$3 as J, platformConfigFromProfile as Jn, formatKeyValueTable as Jt, organizationTree as K, loadStoredUserTokens as Kn, createCommand$1 as Kt, deployStaticWebsite as L, deleteUserTokens as Ln, getWorkflowExecution as Lt, generateMigrationScript as M, generateUserTypes as Mn, startCommand as Mt, writeDbTypesFile as N, prompt as Nn, startWorkflow as Nt, truncate as O, getNamespacesWithMigrations as On, getExecutorWaitFailureMessage as Ot, getConfiguredEditorCommand as P, apiCall as Pn, getCommand$5 as Pt, updateCommand$2 as Q, resolveUserTokenKey as Qn, waitForExecution as Qt, show as R, fetchLatestToken as Rn, listWorkflowExecutions as Rt, waitCommand as S, reconstructSnapshotFromMigrations as Sn, webhookCommand as St, resumeWorkflow as T, formatDiffSummary as Tn, listCommand$8 as Tt, removeCommand$1 as U, loadConsoleBaseUrl as Un, deployFromCLI as Ut, logBetaWarning as V, loadAccessToken as Vn, getExecutor as Vt, updateCommand$1 as W, loadMachineUserName as Wn, listCommand$9 as Wt, getCommand$1 as X, removeLegacyUserAlias as Xn, ensureConfigId as Xt, listOrganizations as Y, readPlatformConfig as Yn, workspaceNameSchema as Yt, getOrganization as Z, resolveConfigUser as Zn, executeScript as Zt, deleteWorkspace as _, getMigrationFilePath as _n, listCommand$7 as _t, updateUser as a, protoGqlPermission as an, deploymentArgs as ar, deleteFolder as at, getAppHealth as b, isValidMigrationNumber as bn, getFunctionRegistry as bt, listCommand as c, INITIAL_SCHEMA_NUMBER as cn, pagedLogArgs as cr, listCommand$5 as ct, inviteUser as d, assertValidMigrationFiles as dn, toPageDirection as dr, getOAuth2Client as dt, MIGRATION_LABEL_KEY as en, writePlatformConfig as er, listCommand$4 as et, restoreCommand as f, compareLocalTypesWithSnapshot as fn, workspaceArgs as fr, getMachineUserToken as ft, deleteCommand as g, getMigrationDirPath as gn, generate$1 as gt, getWorkspace as h, getLatestMigrationNumber as hn, listMachineUsers as ht, updateCommand as i, generateAllTypeManifestsFromSnapshot as in, confirmationArgs as ir, deleteCommand$1 as it, generateCommand as j, PluginManager as jn, watchExecutorJob as jt, truncateCommand as k, resourceTrn as kn, jobsCommand as kt, listUsers as l, MIGRATE_FILE_NAME as ln, paginationArgs as lr, listOAuth2Clients as lt, getCommand as m, createSnapshotFromLocalTypes as mn, listCommand$6 as mt, query as n, parseMigrationLabelNumber as nn, commonArgs as nr, getCommand$2 as nt, removeCommand as o, DB_TYPES_FILE_NAME as on, isVerbose as or, createCommand as ot, restoreWorkspace as p, compareSnapshots as pn, tokenCommand as pt, treeCommand as q, loadWorkspaceId as qn, createWorkspace$1 as qt, queryCommand as r, compareSnapshotWithRemote as rn, configArg as rr, getFolder as rt, removeUser as s, DIFF_FILE_NAME as sn, multiConfigArg as sr, createFolder as st, registerTsHook as t, handleOptionalToRequiredError as tn, defineAppCommand as tr, listFolders as tt, inviteCommand as u, SCHEMA_FILE_NAME as un, resolveMachineUserInputSource as ur, getCommand$3 as ut, listApps as v, getMigrationFiles as vn, listFunctionRegistries as vt, resumeCommand as w, parseMigrationNumberArg as wn, triggerExecutor as wt, healthCommand as x, loadDiff as xn, listWebhookExecutors as xt, listCommand$1 as y, getNextMigrationNumber as yn, getCommand$4 as yt, showCommand as z, hasAnyUserTokenEntry as zn, functionExecutionStatusToString as zt };
20791
- //# sourceMappingURL=register-ts-hook-DL31O2W9.mjs.map
20748
+ //# sourceMappingURL=register-ts-hook-DvEs6YsL.mjs.map