@tailor-platform/sdk 1.25.1 → 1.25.2

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 (89) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/{application-iRp2OYMz.mjs → application-BGO3TtXi.mjs} +105 -63
  3. package/dist/application-BGO3TtXi.mjs.map +1 -0
  4. package/dist/application-C0lXqKBr.mjs +9 -0
  5. package/dist/{brand-BOaOlsiP.mjs → brand-GZnI4eYb.mjs} +1 -1
  6. package/dist/{brand-BOaOlsiP.mjs.map → brand-GZnI4eYb.mjs.map} +1 -1
  7. package/dist/chunk-Cz-A8uMR.mjs +3 -0
  8. package/dist/cli/index.d.mts +2 -3
  9. package/dist/cli/index.mjs +167 -211
  10. package/dist/cli/index.mjs.map +1 -1
  11. package/dist/cli/lib.d.mts +706 -1108
  12. package/dist/cli/lib.mjs +28 -16
  13. package/dist/cli/lib.mjs.map +1 -1
  14. package/dist/cli/skills.mjs +2 -1
  15. package/dist/cli/skills.mjs.map +1 -1
  16. package/dist/configure/index.d.mts +5 -5
  17. package/dist/configure/index.mjs +4 -3
  18. package/dist/configure/index.mjs.map +1 -1
  19. package/dist/{enum-constants-BxdLbhsW.mjs → enum-constants-6uK0VI_s.mjs} +1 -1
  20. package/dist/{enum-constants-BxdLbhsW.mjs.map → enum-constants-6uK0VI_s.mjs.map} +1 -1
  21. package/dist/{env-jndw86T4.d.mts → env-uBeVwE9B.d.mts} +4 -7
  22. package/dist/{file-utils-C2r3AVbI.mjs → file-utils-2T9w20FP.mjs} +1 -1
  23. package/dist/{file-utils-C2r3AVbI.mjs.map → file-utils-2T9w20FP.mjs.map} +1 -1
  24. package/dist/{index-Do7zo7z-.d.mts → index-BD-K97-C.d.mts} +2 -2
  25. package/dist/{index-VZq4IAEK.d.mts → index-CT53egux.d.mts} +2 -2
  26. package/dist/{index-DZRZdh71.d.mts → index-D1J5SfyK.d.mts} +2 -2
  27. package/dist/{index-BuWllBxZ.d.mts → index-DuZRAsc3.d.mts} +14 -11
  28. package/dist/{index-DoxGF8-i.d.mts → index-cZilKprY.d.mts} +2 -2
  29. package/dist/{interceptor-DVy32eIG.mjs → interceptor-BPiIBTk_.mjs} +2 -1
  30. package/dist/{interceptor-DVy32eIG.mjs.map → interceptor-BPiIBTk_.mjs.map} +1 -1
  31. package/dist/{job-BQDunsd7.mjs → job-DdfW7vH3.mjs} +3 -3
  32. package/dist/{job-BQDunsd7.mjs.map → job-DdfW7vH3.mjs.map} +1 -1
  33. package/dist/kysely/index.d.mts +3 -4
  34. package/dist/kysely/index.mjs +1 -0
  35. package/dist/kysely/index.mjs.map +1 -1
  36. package/dist/{kysely-type-DzLBuVp6.mjs → kysely-type-cMNbsQ6k.mjs} +1 -1
  37. package/dist/{kysely-type-DzLBuVp6.mjs.map → kysely-type-cMNbsQ6k.mjs.map} +1 -1
  38. package/dist/package-json-Bj76LPsV.mjs +4 -0
  39. package/dist/{package-json-DnbGCOkg.mjs → package-json-CVUv8Y9T.mjs} +1 -1
  40. package/dist/{package-json-DnbGCOkg.mjs.map → package-json-CVUv8Y9T.mjs.map} +1 -1
  41. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -2
  42. package/dist/plugin/builtin/enum-constants/index.mjs +2 -1
  43. package/dist/plugin/builtin/file-utils/index.d.mts +1 -2
  44. package/dist/plugin/builtin/file-utils/index.mjs +2 -1
  45. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -2
  46. package/dist/plugin/builtin/kysely-type/index.mjs +2 -1
  47. package/dist/plugin/builtin/seed/index.d.mts +1 -2
  48. package/dist/plugin/builtin/seed/index.mjs +2 -1
  49. package/dist/plugin/index.d.mts +2 -3
  50. package/dist/plugin/index.mjs +5 -4
  51. package/dist/plugin/index.mjs.map +1 -1
  52. package/dist/{plugin-3sT6Tcq0.d.mts → plugin-zY5wvV82.d.mts} +117 -225
  53. package/dist/{query-D3UyoG68.mjs → query-CRSZGUmD.mjs} +445 -509
  54. package/dist/query-CRSZGUmD.mjs.map +1 -0
  55. package/dist/{schema-Fbfeq9gi.mjs → schema-BePzTFBV.mjs} +9 -9
  56. package/dist/schema-BePzTFBV.mjs.map +1 -0
  57. package/dist/seed/index.d.mts +1 -4
  58. package/dist/seed/index.mjs +1 -0
  59. package/dist/seed/index.mjs.map +1 -1
  60. package/dist/{seed-DkKAheSe.mjs → seed-CCVRLibh.mjs} +24 -10
  61. package/dist/seed-CCVRLibh.mjs.map +1 -0
  62. package/dist/{telemetry-d_lgTL33.mjs → telemetry-0w8OupuQ.mjs} +2 -2
  63. package/dist/{telemetry-d_lgTL33.mjs.map → telemetry-0w8OupuQ.mjs.map} +1 -1
  64. package/dist/telemetry-DDQZRqHK.mjs +4 -0
  65. package/dist/utils/test/index.d.mts +2 -3
  66. package/dist/utils/test/index.mjs +3 -2
  67. package/dist/utils/test/index.mjs.map +1 -1
  68. package/dist/{app-config-QzNOFnEy.d.mts → workflow.generated-v1LXRuB6.d.mts} +19 -22
  69. package/docs/cli/application.md +73 -33
  70. package/docs/cli/auth.md +56 -24
  71. package/docs/cli/completion.md +6 -0
  72. package/docs/cli/executor.md +73 -36
  73. package/docs/cli/function.md +30 -14
  74. package/docs/cli/secret.md +93 -41
  75. package/docs/cli/staticwebsite.md +38 -17
  76. package/docs/cli/tailordb.md +106 -48
  77. package/docs/cli/user.md +74 -10
  78. package/docs/cli/workflow.md +70 -39
  79. package/docs/cli/workspace.md +166 -60
  80. package/docs/cli-reference.md +22 -12
  81. package/docs/services/workflow.md +26 -0
  82. package/package.json +5 -5
  83. package/dist/application-B4ORumjE.mjs +0 -8
  84. package/dist/application-iRp2OYMz.mjs.map +0 -1
  85. package/dist/package-json-BKA36WTo.mjs +0 -3
  86. package/dist/query-D3UyoG68.mjs.map +0 -1
  87. package/dist/schema-Fbfeq9gi.mjs.map +0 -1
  88. package/dist/seed-DkKAheSe.mjs.map +0 -1
  89. package/dist/telemetry-J6dpByo2.mjs +0 -3
@@ -1,8 +1,8 @@
1
- import { t as db } from "./schema-Fbfeq9gi.mjs";
2
- import { $ as AuthSCIMAttribute_Mutability, A as platformBaseUrl, B as TailorDBType_Permission_Permit, C as readPlatformConfig, E as fetchMachineUserToken, F as WorkflowJobExecution_Status, H as PipelineResolver_OperationType, I as TailorDBGQLPermission_Action, J as ExecutorTriggerType, K as ExecutorJobStatus, L as TailorDBGQLPermission_Operator, M as userAgent, N as WorkspacePlatformUserRole, P as WorkflowExecution_Status, Q as AuthOAuth2Client_GrantType, R as TailorDBGQLPermission_Permit, S as loadWorkspaceId, T as fetchAll, U as IdPLang, V as TailorDBType_PermitAction, W as FunctionExecution_Status, X as AuthInvokerSchema, Y as AuthIDPConfig_AuthType, Z as AuthOAuth2Client_ClientType, _ as hashFile, a as loadConfig, at as UserProfileProviderConfig_UserProfileProviderType, b as loadFolderId, ct as Condition_Operator, d as TailorDBTypeSchema, dt as ApplicationSchemaUpdateAttemptStatus, et as AuthSCIMAttribute_Type, f as stringifyFunction, ft as Subgraph_ServiceType, g as getDistDir, h as createBundleCache, ht as symbols, it as TenantProviderConfig_TenantProviderType, j as resolveStaticWebsiteUrls, k as initOperatorClient, l as OAuth2ClientSchema, lt as FilterSchema, m as loadFilesWithIgnores, mt as styles, n as generatePluginFilesIfNeeded, nt as AuthSCIMConfig_AuthorizationType, ot as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, p as tailorUserMap, pt as logger, q as ExecutorTargetType, r as loadApplication, s as createExecutorService, st as ConditionSchema, t as defineApplication, tt as AuthSCIMAttribute_Uniqueness, ut as PageDirection, w as writePlatformConfig, x as loadOrganizationId, y as loadAccessToken, z as TailorDBType_Permission_Operator } from "./application-iRp2OYMz.mjs";
3
- import { t as readPackageJson } from "./package-json-DnbGCOkg.mjs";
4
- import { r as withSpan } from "./telemetry-d_lgTL33.mjs";
5
- import { arg, defineCommand, runCommand } from "politty";
1
+ import { t as db } from "./schema-BePzTFBV.mjs";
2
+ import { $ as AuthSCIMAttribute_Uniqueness, A as userAgent, B as PipelineResolver_OperationType, C as fetchAll, D as initOperatorClient, F as TailorDBGQLPermission_Operator, G as ExecutorTargetType, H as FunctionExecution_Status, I as TailorDBGQLPermission_Permit, J as AuthInvokerSchema, K as ExecutorTriggerType, L as TailorDBType_Permission_Operator, M as WorkflowExecution_Status, N as WorkflowJobExecution_Status, O as platformBaseUrl, P as TailorDBGQLPermission_Action, Q as AuthSCIMAttribute_Type, R as TailorDBType_Permission_Permit, S as writePlatformConfig, V as IdPLang, W as ExecutorJobStatus, X as AuthOAuth2Client_GrantType, Y as AuthOAuth2Client_ClientType, Z as AuthSCIMAttribute_Mutability, _ as hashFile, a as loadConfig, at as ConditionSchema, b as loadWorkspaceId, ct as PageDirection, d as TailorDBTypeSchema, dt as logger, et as AuthSCIMConfig_AuthorizationType, f as stringifyFunction, ft as styles, g as getDistDir, h as createBundleCache, it as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, j as WorkspacePlatformUserRole, k as resolveStaticWebsiteUrls, l as OAuth2ClientSchema, lt as ApplicationSchemaUpdateAttemptStatus, m as loadFilesWithIgnores, n as generatePluginFilesIfNeeded, nt as TenantProviderConfig_TenantProviderType, ot as Condition_Operator, p as tailorUserMap, pt as symbols, q as AuthIDPConfig_AuthType, r as loadApplication, rt as UserProfileProviderConfig_UserProfileProviderType, s as createExecutorService, st as FilterSchema, t as defineApplication, ut as Subgraph_ServiceType, w as fetchMachineUserToken, x as readPlatformConfig, y as loadAccessToken, z as TailorDBType_PermitAction } from "./application-BGO3TtXi.mjs";
3
+ import { t as readPackageJson } from "./package-json-CVUv8Y9T.mjs";
4
+ import { r as withSpan } from "./telemetry-0w8OupuQ.mjs";
5
+ import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
6
6
  import { z } from "zod";
7
7
  import * as fs$1 from "node:fs";
8
8
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
@@ -34,44 +34,6 @@ import { createInterface } from "node:readline/promises";
34
34
  import { astVisitor, parse, toSql } from "pgsql-ast-parser";
35
35
  import { parse as parse$1 } from "@0no-co/graphql.web";
36
36
 
37
- //#region src/cli/shared/errors.ts
38
- /**
39
- * Format CLI error for output
40
- * @param error - CLIError instance to format
41
- * @returns Formatted error message
42
- */
43
- function formatError(error) {
44
- const parts = [chalk.red(`Error${error.code ? ` [${error.code}]` : ""}: ${error.message}`)];
45
- if (error.details) parts.push(`\n ${chalk.gray("Details:")} ${error.details}`);
46
- if (error.suggestion) parts.push(`\n ${chalk.cyan("Suggestion:")} ${error.suggestion}`);
47
- if (error.command) parts.push(`\n ${chalk.gray("Help:")} Run \`tailor-sdk ${error.command} --help\` for usage information.`);
48
- return parts.join("");
49
- }
50
- /**
51
- * Create a CLI error with formatted output
52
- * @param options - Options to construct a CLIError
53
- * @returns Constructed CLIError instance
54
- */
55
- function createCLIError(options) {
56
- const error = new Error(options.message);
57
- error.name = "CLIError";
58
- error.code = options.code;
59
- error.details = options.details;
60
- error.suggestion = options.suggestion;
61
- error.command = options.command;
62
- error.format = () => formatError(error);
63
- return error;
64
- }
65
- /**
66
- * Type guard to check if an error is a CLIError
67
- * @param error - Error to check
68
- * @returns True if the error is a CLIError
69
- */
70
- function isCLIError(error) {
71
- return error instanceof Error && error.name === "CLIError";
72
- }
73
-
74
- //#endregion
75
37
  //#region src/cli/shared/args.ts
76
38
  const unitToMs = {
77
39
  ms: 1,
@@ -151,9 +113,24 @@ const commonArgs = {
151
113
  completion: {
152
114
  type: "file",
153
115
  matcher: [".env.*", ".env"]
116
+ },
117
+ effect: (_value, { args }) => {
118
+ loadEnvFiles(args["env-file"], args["env-file-if-exists"]);
154
119
  }
155
120
  }),
156
- verbose: arg(z.boolean().default(false), { description: "Enable verbose logging" })
121
+ verbose: arg(z.boolean().default(false), {
122
+ description: "Enable verbose logging",
123
+ effect: (value) => {
124
+ verboseMode = value;
125
+ }
126
+ }),
127
+ json: arg(z.boolean().default(false), {
128
+ alias: "j",
129
+ description: "Output as JSON",
130
+ effect: (value) => {
131
+ logger.jsonMode = value;
132
+ }
133
+ })
157
134
  };
158
135
  /**
159
136
  * Arguments for commands that require workspace context
@@ -162,11 +139,13 @@ const workspaceArgs = {
162
139
  "workspace-id": arg(z.string().optional(), {
163
140
  alias: "w",
164
141
  description: "Workspace ID",
142
+ env: "TAILOR_PLATFORM_WORKSPACE_ID",
165
143
  completion: { type: "none" }
166
144
  }),
167
145
  profile: arg(z.string().optional(), {
168
146
  alias: "p",
169
147
  description: "Workspace profile",
148
+ env: "TAILOR_PLATFORM_PROFILE",
170
149
  completion: { type: "none" }
171
150
  })
172
151
  };
@@ -176,6 +155,7 @@ const workspaceArgs = {
176
155
  const configArg = { config: arg(z.string().default("tailor.config.ts"), {
177
156
  alias: "c",
178
157
  description: "Path to SDK config file",
158
+ env: "TAILOR_PLATFORM_SDK_CONFIG_PATH",
179
159
  completion: {
180
160
  type: "file",
181
161
  extensions: ["ts"]
@@ -195,44 +175,24 @@ const confirmationArgs = { yes: arg(z.boolean().default(false), {
195
175
  alias: "y",
196
176
  description: "Skip confirmation prompts"
197
177
  }) };
178
+ let verboseMode = false;
198
179
  /**
199
- * Arguments for JSON output
180
+ * Returns whether verbose mode is enabled.
181
+ * Used by the global cleanup handler which doesn't have access to parsed args.
182
+ * @returns Whether verbose mode is enabled
200
183
  */
201
- const jsonArgs = { json: arg(z.boolean().default(false), {
202
- alias: "j",
203
- description: "Output as JSON"
204
- }) };
184
+ function isVerbose() {
185
+ return verboseMode;
186
+ }
187
+
188
+ //#endregion
189
+ //#region src/cli/shared/command.ts
205
190
  /**
206
- * Wrapper for command handlers that provides:
207
- * - Environment file loading
208
- * - Error handling with formatted output
209
- * - Exit code management
210
- * @template T
211
- * @param handler - Command handler function
212
- * @returns Wrapped handler
191
+ * defineCommand with global args type (CommonArgsType).
192
+ * Use this for leaf commands with `run` to get type-safe access to global args.
193
+ * Parent commands with only `subCommands` can use `defineCommand` from politty directly.
213
194
  */
214
- const withCommonArgs = (handler) => async (args) => {
215
- try {
216
- if ("json" in args && typeof args.json === "boolean") logger.jsonMode = args.json;
217
- loadEnvFiles(args["env-file"], args["env-file-if-exists"]);
218
- const { initTelemetry } = await import("./telemetry-J6dpByo2.mjs");
219
- await initTelemetry();
220
- await handler(args);
221
- } catch (error) {
222
- if (isCLIError(error)) {
223
- logger.log(error.format());
224
- if (args.verbose && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
225
- } else if (error instanceof Error) {
226
- logger.error(error.message);
227
- if (args.verbose && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
228
- } else logger.error(`Unknown error: ${error}`);
229
- process.exit(1);
230
- } finally {
231
- const { shutdownTelemetry } = await import("./telemetry-J6dpByo2.mjs");
232
- await shutdownTelemetry();
233
- }
234
- process.exit(0);
235
- };
195
+ const defineAppCommand = createDefineCommand();
236
196
 
237
197
  //#endregion
238
198
  //#region src/cli/commands/api.ts
@@ -267,12 +227,10 @@ async function apiCall(options) {
267
227
  data
268
228
  };
269
229
  }
270
- const apiCommand = defineCommand({
230
+ const apiCommand = defineAppCommand({
271
231
  name: "api",
272
232
  description: "Call Tailor Platform API endpoints directly.",
273
233
  args: z.object({
274
- ...commonArgs,
275
- ...jsonArgs,
276
234
  ...workspaceArgs,
277
235
  body: arg(z.string().default("{}"), {
278
236
  alias: "b",
@@ -283,7 +241,7 @@ const apiCommand = defineCommand({
283
241
  description: "API endpoint to call (e.g., 'GetApplication' or 'tailor.v1.OperatorService/GetApplication')"
284
242
  })
285
243
  }).strict(),
286
- run: withCommonArgs(async (args) => {
244
+ run: async (args) => {
287
245
  const result = await apiCall({
288
246
  profile: args.profile,
289
247
  endpoint: args.endpoint,
@@ -291,7 +249,7 @@ const apiCommand = defineCommand({
291
249
  });
292
250
  if (args.json) logger.log(JSON.stringify(result.data, null, 2));
293
251
  else logger.log(JSON.stringify(result.data, null, 2));
294
- })
252
+ }
295
253
  });
296
254
 
297
255
  //#endregion
@@ -958,11 +916,11 @@ const sdkNameLabelKey = "sdk-name";
958
916
  * @param existingLabels - Existing labels to preserve (optional)
959
917
  * @returns Metadata request
960
918
  */
961
- async function buildMetaRequest(trn$7, appName, existingLabels) {
919
+ async function buildMetaRequest(trn, appName, existingLabels) {
962
920
  const packageJson = await readPackageJson();
963
921
  const sdkVersion = packageJson.version ? `v${packageJson.version.replace(/\./g, "-")}` : "unknown";
964
922
  return {
965
- trn: trn$7,
923
+ trn,
966
924
  labels: {
967
925
  ...existingLabels ?? {},
968
926
  [sdkNameLabelKey]: appName,
@@ -981,10 +939,10 @@ async function buildMetaRequest(trn$7, appName, existingLabels) {
981
939
  * @returns Promise that resolves when applications are applied
982
940
  */
983
941
  async function applyApplication(client, changeSet, phase = "create-update") {
984
- if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
985
- create$1.request.cors = await resolveStaticWebsiteUrls(client, create$1.request.workspaceId, create$1.request.cors, "CORS");
986
- await client.createApplication(create$1.request);
987
- await client.setMetadata(create$1.metaRequest);
942
+ if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create) => {
943
+ create.request.cors = await resolveStaticWebsiteUrls(client, create.request.workspaceId, create.request.cors, "CORS");
944
+ await client.createApplication(create.request);
945
+ await client.setMetadata(create.metaRequest);
988
946
  }), ...changeSet.updates.map(async (update) => {
989
947
  update.request.cors = await resolveStaticWebsiteUrls(client, update.request.workspaceId, update.request.cors, "CORS");
990
948
  await client.updateApplication(update.request);
@@ -1043,13 +1001,13 @@ async function planApplication(context) {
1043
1001
  authNamespace = application.config.auth.name;
1044
1002
  const idpConfigs = await fetchAll(async (pageToken, maxPageSize) => {
1045
1003
  try {
1046
- const { idpConfigs: idpConfigs$1, nextPageToken } = await client.listAuthIDPConfigs({
1004
+ const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
1047
1005
  workspaceId,
1048
1006
  namespaceName: authNamespace,
1049
1007
  pageToken,
1050
1008
  pageSize: maxPageSize
1051
1009
  });
1052
- return [idpConfigs$1, nextPageToken];
1010
+ return [idpConfigs, nextPageToken];
1053
1011
  } catch (error) {
1054
1012
  if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
1055
1013
  throw error;
@@ -1142,23 +1100,23 @@ function idpClientSecretName(namespaceName, clientName) {
1142
1100
  async function applyIdP(client, result, phase = "create-update") {
1143
1101
  const { changeSet } = result;
1144
1102
  if (phase === "create-update") {
1145
- await Promise.all([...changeSet.service.creates.map(async (create$1) => {
1146
- await client.createIdPService(create$1.request);
1147
- await client.setMetadata(create$1.metaRequest);
1103
+ await Promise.all([...changeSet.service.creates.map(async (create) => {
1104
+ await client.createIdPService(create.request);
1105
+ await client.setMetadata(create.metaRequest);
1148
1106
  }), ...changeSet.service.updates.map(async (update) => {
1149
1107
  await client.updateIdPService(update.request);
1150
1108
  await client.setMetadata(update.metaRequest);
1151
1109
  })]);
1152
- await Promise.all([...changeSet.client.creates.map(async (create$1) => {
1153
- const resp = await client.createIdPClient(create$1.request);
1154
- const vaultName = idpClientVaultName(create$1.request.namespaceName, create$1.request.client?.name || "");
1155
- const secretName = idpClientSecretName(create$1.request.namespaceName, create$1.request.client?.name || "");
1110
+ await Promise.all([...changeSet.client.creates.map(async (create) => {
1111
+ const resp = await client.createIdPClient(create.request);
1112
+ const vaultName = idpClientVaultName(create.request.namespaceName, create.request.client?.name || "");
1113
+ const secretName = idpClientSecretName(create.request.namespaceName, create.request.client?.name || "");
1156
1114
  await client.createSecretManagerVault({
1157
- workspaceId: create$1.request.workspaceId,
1115
+ workspaceId: create.request.workspaceId,
1158
1116
  secretmanagerVaultName: vaultName
1159
1117
  });
1160
1118
  await client.createSecretManagerSecret({
1161
- workspaceId: create$1.request.workspaceId,
1119
+ workspaceId: create.request.workspaceId,
1162
1120
  secretmanagerVaultName: vaultName,
1163
1121
  secretmanagerSecretName: secretName,
1164
1122
  secretmanagerSecretValue: resp.client?.clientSecret
@@ -1346,8 +1304,8 @@ async function planClients(client, workspaceId, idps, deletedServices) {
1346
1304
  const namespaceName = idp.name;
1347
1305
  const existingClients = clientsByIdp[i];
1348
1306
  const existingNameMap = /* @__PURE__ */ new Map();
1349
- existingClients.forEach((client$1) => {
1350
- existingNameMap.set(client$1.name, client$1.clientSecret);
1307
+ existingClients.forEach((client) => {
1308
+ existingNameMap.set(client.name, client.clientSecret);
1351
1309
  });
1352
1310
  for (const name of idp.clients) if (existingNameMap.has(name)) {
1353
1311
  changeSet.updates.push({
@@ -1379,13 +1337,13 @@ async function planClients(client, workspaceId, idps, deletedServices) {
1379
1337
  const deletedClientsByService = await Promise.all(deletedServices.map((namespaceName) => fetchClients(namespaceName)));
1380
1338
  for (let i = 0; i < deletedServices.length; i++) {
1381
1339
  const namespaceName = deletedServices[i];
1382
- deletedClientsByService[i].forEach((client$1) => {
1340
+ deletedClientsByService[i].forEach((client) => {
1383
1341
  changeSet.deletes.push({
1384
- name: client$1.name,
1342
+ name: client.name,
1385
1343
  request: {
1386
1344
  workspaceId,
1387
1345
  namespaceName,
1388
- name: client$1.name
1346
+ name: client.name
1389
1347
  }
1390
1348
  });
1391
1349
  });
@@ -1422,26 +1380,26 @@ function convertGqlOperationsToDisable(gqlOperations) {
1422
1380
  async function applyAuth(client, result, phase = "create-update") {
1423
1381
  const { changeSet } = result;
1424
1382
  if (phase === "create-update") {
1425
- await Promise.all([...changeSet.service.creates.map(async (create$1) => {
1426
- await client.createAuthService(create$1.request);
1427
- await client.setMetadata(create$1.metaRequest);
1383
+ await Promise.all([...changeSet.service.creates.map(async (create) => {
1384
+ await client.createAuthService(create.request);
1385
+ await client.setMetadata(create.metaRequest);
1428
1386
  }), ...changeSet.service.updates.map(async (update) => {
1429
1387
  await client.updateAuthService(update.request);
1430
1388
  await client.setMetadata(update.metaRequest);
1431
1389
  })]);
1432
- await Promise.all([...changeSet.idpConfig.creates.map(async (create$1) => {
1433
- if (create$1.idpConfig.kind === "BuiltInIdP") create$1.request.idpConfig.config = await protoBuiltinIdPConfig(client, create$1.request.workspaceId, create$1.idpConfig);
1434
- return client.createAuthIDPConfig(create$1.request);
1390
+ await Promise.all([...changeSet.idpConfig.creates.map(async (create) => {
1391
+ if (create.idpConfig.kind === "BuiltInIdP") create.request.idpConfig.config = await protoBuiltinIdPConfig(client, create.request.workspaceId, create.idpConfig);
1392
+ return client.createAuthIDPConfig(create.request);
1435
1393
  }), ...changeSet.idpConfig.updates.map(async (update) => {
1436
1394
  if (update.idpConfig.kind === "BuiltInIdP") update.request.idpConfig.config = await protoBuiltinIdPConfig(client, update.request.workspaceId, update.idpConfig);
1437
1395
  return client.updateAuthIDPConfig(update.request);
1438
1396
  })]);
1439
- await Promise.all([...changeSet.userProfileConfig.creates.map((create$1) => client.createUserProfileConfig(create$1.request)), ...changeSet.userProfileConfig.updates.map((update) => client.updateUserProfileConfig(update.request))]);
1440
- await Promise.all([...changeSet.tenantConfig.creates.map((create$1) => client.createTenantConfig(create$1.request)), ...changeSet.tenantConfig.updates.map((update) => client.updateTenantConfig(update.request))]);
1441
- await Promise.all([...changeSet.machineUser.creates.map((create$1) => client.createAuthMachineUser(create$1.request)), ...changeSet.machineUser.updates.map((update) => client.updateAuthMachineUser(update.request))]);
1442
- await Promise.all([...changeSet.oauth2Client.creates.map(async (create$1) => {
1443
- create$1.request.oauth2Client.redirectUris = await resolveStaticWebsiteUrls(client, create$1.request.workspaceId, create$1.request.oauth2Client.redirectUris, "OAuth2 redirect URIs");
1444
- return client.createAuthOAuth2Client(create$1.request);
1397
+ await Promise.all([...changeSet.userProfileConfig.creates.map((create) => client.createUserProfileConfig(create.request)), ...changeSet.userProfileConfig.updates.map((update) => client.updateUserProfileConfig(update.request))]);
1398
+ await Promise.all([...changeSet.tenantConfig.creates.map((create) => client.createTenantConfig(create.request)), ...changeSet.tenantConfig.updates.map((update) => client.updateTenantConfig(update.request))]);
1399
+ await Promise.all([...changeSet.machineUser.creates.map((create) => client.createAuthMachineUser(create.request)), ...changeSet.machineUser.updates.map((update) => client.updateAuthMachineUser(update.request))]);
1400
+ await Promise.all([...changeSet.oauth2Client.creates.map(async (create) => {
1401
+ create.request.oauth2Client.redirectUris = await resolveStaticWebsiteUrls(client, create.request.workspaceId, create.request.oauth2Client.redirectUris, "OAuth2 redirect URIs");
1402
+ return client.createAuthOAuth2Client(create.request);
1445
1403
  }), ...changeSet.oauth2Client.updates.map(async (update) => {
1446
1404
  update.request.oauth2Client.redirectUris = await resolveStaticWebsiteUrls(client, update.request.workspaceId, update.request.oauth2Client.redirectUris, "OAuth2 redirect URIs");
1447
1405
  return client.updateAuthOAuth2Client(update.request);
@@ -1451,8 +1409,8 @@ async function applyAuth(client, result, phase = "create-update") {
1451
1409
  replace.createRequest.oauth2Client.redirectUris = await resolveStaticWebsiteUrls(client, replace.createRequest.workspaceId, replace.createRequest.oauth2Client.redirectUris, "OAuth2 redirect URIs");
1452
1410
  await client.createAuthOAuth2Client(replace.createRequest);
1453
1411
  }
1454
- await Promise.all([...changeSet.scim.creates.map((create$1) => client.createAuthSCIMConfig(create$1.request)), ...changeSet.scim.updates.map((update) => client.updateAuthSCIMConfig(update.request))]);
1455
- await Promise.all([...changeSet.scimResource.creates.map((create$1) => client.createAuthSCIMResource(create$1.request)), ...changeSet.scimResource.updates.map((update) => client.updateAuthSCIMResource(update.request))]);
1412
+ await Promise.all([...changeSet.scim.creates.map((create) => client.createAuthSCIMConfig(create.request)), ...changeSet.scim.updates.map((update) => client.updateAuthSCIMConfig(update.request))]);
1413
+ await Promise.all([...changeSet.scimResource.creates.map((create) => client.createAuthSCIMResource(create.request)), ...changeSet.scimResource.updates.map((update) => client.updateAuthSCIMResource(update.request))]);
1456
1414
  } else if (phase === "delete-resources") {
1457
1415
  await Promise.all(changeSet.scimResource.deletes.map((del) => client.deleteAuthSCIMResource(del.request)));
1458
1416
  await Promise.all(changeSet.scim.deletes.map((del) => client.deleteAuthSCIMConfig(del.request)));
@@ -1614,8 +1572,8 @@ async function planIdPConfigs(client, workspaceId, auths, deletedServices) {
1614
1572
  const { parsedConfig: config } = authService;
1615
1573
  const existingIdPConfigs = await fetchIdPConfigs(config.name);
1616
1574
  const existingNameSet = /* @__PURE__ */ new Set();
1617
- existingIdPConfigs.forEach((idpConfig$1) => {
1618
- existingNameSet.add(idpConfig$1.name);
1575
+ existingIdPConfigs.forEach((idpConfig) => {
1576
+ existingNameSet.add(idpConfig.name);
1619
1577
  });
1620
1578
  const idpConfig = config.idProvider;
1621
1579
  if (idpConfig) if (existingNameSet.has(idpConfig.name)) {
@@ -2297,7 +2255,7 @@ function protoSCIMAttribute(attr) {
2297
2255
  multiValued: attr.multiValued,
2298
2256
  uniqueness,
2299
2257
  canonicalValues: attr.canonicalValues ?? void 0,
2300
- subAttributes: attr.subAttributes?.map((attr$1) => protoSCIMAttribute(attr$1))
2258
+ subAttributes: attr.subAttributes?.map((attr) => protoSCIMAttribute(attr))
2301
2259
  };
2302
2260
  }
2303
2261
 
@@ -2681,9 +2639,9 @@ async function uploadFunctionScript(client, workspaceId, entry, isCreate) {
2681
2639
  async function applyFunctionRegistry(client, workspaceId, result, phase = "create-update") {
2682
2640
  const { changeSet } = result;
2683
2641
  if (phase === "create-update") {
2684
- for (const create$1 of changeSet.creates) {
2685
- await uploadFunctionScript(client, workspaceId, create$1.entry, true);
2686
- await client.setMetadata(create$1.metaRequest);
2642
+ for (const create of changeSet.creates) {
2643
+ await uploadFunctionScript(client, workspaceId, create.entry, true);
2644
+ await client.setMetadata(create.metaRequest);
2687
2645
  }
2688
2646
  for (const update of changeSet.updates) {
2689
2647
  await uploadFunctionScript(client, workspaceId, update.entry, false);
@@ -2706,9 +2664,9 @@ async function applyFunctionRegistry(client, workspaceId, result, phase = "creat
2706
2664
  */
2707
2665
  async function applyExecutor(client, result, phase = "create-update") {
2708
2666
  const { changeSet } = result;
2709
- if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
2710
- await client.createExecutorExecutor(create$1.request);
2711
- await client.setMetadata(create$1.metaRequest);
2667
+ if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create) => {
2668
+ await client.createExecutorExecutor(create.request);
2669
+ await client.setMetadata(create.metaRequest);
2712
2670
  }), ...changeSet.updates.map(async (update) => {
2713
2671
  await client.updateExecutorExecutor(update.request);
2714
2672
  await client.setMetadata(update.metaRequest);
@@ -2731,12 +2689,12 @@ async function planExecutor(context) {
2731
2689
  const resourceOwners = /* @__PURE__ */ new Set();
2732
2690
  const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
2733
2691
  try {
2734
- const { executors: executors$1, nextPageToken } = await client.listExecutorExecutors({
2692
+ const { executors, nextPageToken } = await client.listExecutorExecutors({
2735
2693
  workspaceId,
2736
2694
  pageToken,
2737
2695
  pageSize: maxPageSize
2738
2696
  });
2739
- return [executors$1, nextPageToken];
2697
+ return [executors, nextPageToken];
2740
2698
  } catch (error) {
2741
2699
  if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
2742
2700
  throw error;
@@ -3004,14 +2962,14 @@ const SCALAR_TYPE_MAP = {
3004
2962
  async function applyPipeline(client, result, phase = "create-update") {
3005
2963
  const { changeSet } = result;
3006
2964
  if (phase === "create-update") {
3007
- await Promise.all([...changeSet.service.creates.map(async (create$1) => {
3008
- await client.createPipelineService(create$1.request);
3009
- await client.setMetadata(create$1.metaRequest);
2965
+ await Promise.all([...changeSet.service.creates.map(async (create) => {
2966
+ await client.createPipelineService(create.request);
2967
+ await client.setMetadata(create.metaRequest);
3010
2968
  }), ...changeSet.service.updates.map(async (update) => {
3011
2969
  await client.updatePipelineService(update.request);
3012
2970
  await client.setMetadata(update.metaRequest);
3013
2971
  })]);
3014
- await Promise.all([...changeSet.resolver.creates.map((create$1) => client.createPipelineResolver(create$1.request)), ...changeSet.resolver.updates.map((update) => client.updatePipelineResolver(update.request))]);
2972
+ await Promise.all([...changeSet.resolver.creates.map((create) => client.createPipelineResolver(create.request)), ...changeSet.resolver.updates.map((update) => client.updatePipelineResolver(update.request))]);
3015
2973
  } else if (phase === "delete-resources") await Promise.all(changeSet.resolver.deletes.map((del) => client.deletePipelineResolver(del.request)));
3016
2974
  else if (phase === "delete-services") await Promise.all(changeSet.service.deletes.map((del) => client.deletePipelineService(del.request)));
3017
2975
  }
@@ -3400,13 +3358,13 @@ async function planSecretManager(context) {
3400
3358
  if (label === application.name) {
3401
3359
  const secrets = await fetchAll(async (pageToken, maxPageSize) => {
3402
3360
  try {
3403
- const { secrets: secrets$1, nextPageToken } = await client.listSecretManagerSecrets({
3361
+ const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
3404
3362
  workspaceId,
3405
3363
  secretmanagerVaultName: name,
3406
3364
  pageToken,
3407
3365
  pageSize: maxPageSize
3408
3366
  });
3409
- return [secrets$1, nextPageToken];
3367
+ return [secrets, nextPageToken];
3410
3368
  } catch (error) {
3411
3369
  if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
3412
3370
  throw error;
@@ -3448,13 +3406,13 @@ function vaultTrn(workspaceId, name) {
3448
3406
  async function applySecretManager(client, result, phase = "create-update", application) {
3449
3407
  const { vaultChangeSet, secretChangeSet } = result;
3450
3408
  if (phase === "create-update") {
3451
- await Promise.all(vaultChangeSet.creates.map(async (create$1) => {
3409
+ await Promise.all(vaultChangeSet.creates.map(async (create) => {
3452
3410
  await client.createSecretManagerVault({
3453
- workspaceId: create$1.workspaceId,
3454
- secretmanagerVaultName: create$1.name
3411
+ workspaceId: create.workspaceId,
3412
+ secretmanagerVaultName: create.name
3455
3413
  });
3456
3414
  if (application) {
3457
- const metaRequest = await buildMetaRequest(vaultTrn(create$1.workspaceId, create$1.name), application.name);
3415
+ const metaRequest = await buildMetaRequest(vaultTrn(create.workspaceId, create.name), application.name);
3458
3416
  await client.setMetadata(metaRequest);
3459
3417
  }
3460
3418
  }));
@@ -3462,11 +3420,11 @@ async function applySecretManager(client, result, phase = "create-update", appli
3462
3420
  const metaRequest = await buildMetaRequest(vaultTrn(update.workspaceId, update.name), application.name);
3463
3421
  await client.setMetadata(metaRequest);
3464
3422
  }));
3465
- await Promise.all(secretChangeSet.creates.map((create$1) => client.createSecretManagerSecret({
3466
- workspaceId: create$1.workspaceId,
3467
- secretmanagerVaultName: create$1.vaultName,
3468
- secretmanagerSecretName: create$1.secretName,
3469
- secretmanagerSecretValue: create$1.value
3423
+ await Promise.all(secretChangeSet.creates.map((create) => client.createSecretManagerSecret({
3424
+ workspaceId: create.workspaceId,
3425
+ secretmanagerVaultName: create.vaultName,
3426
+ secretmanagerSecretName: create.secretName,
3427
+ secretmanagerSecretValue: create.value
3470
3428
  })));
3471
3429
  await Promise.all(secretChangeSet.updates.map((update) => client.updateSecretManagerSecret({
3472
3430
  workspaceId: update.workspaceId,
@@ -3515,9 +3473,9 @@ async function applySecretManager(client, result, phase = "create-update", appli
3515
3473
  */
3516
3474
  async function applyStaticWebsite(client, result, phase = "create-update") {
3517
3475
  const { changeSet } = result;
3518
- if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create$1) => {
3519
- await client.createStaticWebsite(create$1.request);
3520
- await client.setMetadata(create$1.metaRequest);
3476
+ if (phase === "create-update") await Promise.all([...changeSet.creates.map(async (create) => {
3477
+ await client.createStaticWebsite(create.request);
3478
+ await client.setMetadata(create.metaRequest);
3521
3479
  }), ...changeSet.updates.map(async (update) => {
3522
3480
  await client.updateStaticWebsite(update.request);
3523
3481
  await client.setMetadata(update.metaRequest);
@@ -3657,10 +3615,6 @@ function getNamespacesWithMigrations(config, configDir) {
3657
3615
  //#endregion
3658
3616
  //#region src/cli/commands/tailordb/migrate/diff-calculator.ts
3659
3617
  /**
3660
- * Current schema snapshot format version
3661
- */
3662
- const SCHEMA_SNAPSHOT_VERSION = 1;
3663
- /**
3664
3618
  * Check if a migration diff has any changes
3665
3619
  * @param {MigrationDiff} diff - Migration diff to check
3666
3620
  * @returns {boolean} True if diff has changes
@@ -4065,7 +4019,7 @@ function createSnapshotFromLocalTypes(types, namespace) {
4065
4019
  const snapshotTypes = {};
4066
4020
  for (const [typeName, type] of Object.entries(types)) snapshotTypes[typeName] = createSnapshotType(type);
4067
4021
  return {
4068
- version: SCHEMA_SNAPSHOT_VERSION,
4022
+ version: 1,
4069
4023
  namespace,
4070
4024
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4071
4025
  types: snapshotTypes
@@ -4127,7 +4081,7 @@ function getMigrationFiles(migrationsDir) {
4127
4081
  */
4128
4082
  function getNextMigrationNumber(migrationsDir) {
4129
4083
  const files = getMigrationFiles(migrationsDir);
4130
- if (files.length === 0) return INITIAL_SCHEMA_NUMBER;
4084
+ if (files.length === 0) return 0;
4131
4085
  return Math.max(...files.map((f) => f.number)) + 1;
4132
4086
  }
4133
4087
  /**
@@ -4280,8 +4234,8 @@ function applyDiffToSnapshot(snapshot, diff) {
4280
4234
  function reconstructSnapshotFromMigrations(migrationsDir, maxVersion) {
4281
4235
  const files = getMigrationFiles(migrationsDir);
4282
4236
  if (files.length === 0) return null;
4283
- const schemaFile = files.find((f) => f.type === "schema" && f.number === INITIAL_SCHEMA_NUMBER);
4284
- if (!schemaFile) throw new Error(`No initial schema file found in ${migrationsDir}. Expected ${formatMigrationNumber(INITIAL_SCHEMA_NUMBER)}/schema.json`);
4237
+ const schemaFile = files.find((f) => f.type === "schema" && f.number === 0);
4238
+ if (!schemaFile) throw new Error(`No initial schema file found in ${migrationsDir}. Expected ${formatMigrationNumber(0)}/schema.json`);
4285
4239
  let snapshot = loadSnapshot(schemaFile.path);
4286
4240
  for (const file of files) if (file.type === "diff" && file.number > schemaFile.number) {
4287
4241
  if (maxVersion !== void 0 && file.number > maxVersion) continue;
@@ -4650,7 +4604,7 @@ function compareSnapshots(previous, current) {
4650
4604
  comparePermissions(ctx, typeName, prevType.permissions?.record, currType.permissions?.record, prevType.permissions?.gql, currType.permissions?.gql);
4651
4605
  }
4652
4606
  return {
4653
- version: SCHEMA_SNAPSHOT_VERSION,
4607
+ version: 1,
4654
4608
  namespace: current.namespace,
4655
4609
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4656
4610
  changes: ctx.changes,
@@ -4689,30 +4643,30 @@ function validateMigrationFiles(migrationsDir) {
4689
4643
  const diffFiles = [];
4690
4644
  for (const file of migrationFiles) if (file.type === "schema") schemaFiles.push(file.number);
4691
4645
  else if (file.type === "diff") diffFiles.push(file.number);
4692
- if (!schemaFiles.includes(INITIAL_SCHEMA_NUMBER)) errors.push({
4646
+ if (!schemaFiles.includes(0)) errors.push({
4693
4647
  type: "missing_schema",
4694
- message: `Initial schema snapshot (${formatMigrationNumber(INITIAL_SCHEMA_NUMBER)}/schema.json) is missing`,
4695
- migrationNumber: INITIAL_SCHEMA_NUMBER
4648
+ message: `Initial schema snapshot (${formatMigrationNumber(0)}/schema.json) is missing`,
4649
+ migrationNumber: 0
4696
4650
  });
4697
- for (const num of schemaFiles) if (num !== INITIAL_SCHEMA_NUMBER) errors.push({
4651
+ for (const num of schemaFiles) if (num !== 0) errors.push({
4698
4652
  type: "invalid_schema_number",
4699
- message: `Schema file found at migration ${formatMigrationNumber(num)}, but schema should only exist at ${formatMigrationNumber(INITIAL_SCHEMA_NUMBER)}`,
4653
+ message: `Schema file found at migration ${formatMigrationNumber(num)}, but schema should only exist at ${formatMigrationNumber(0)}`,
4700
4654
  migrationNumber: num
4701
4655
  });
4702
4656
  const allNumbers = [...new Set([...schemaFiles, ...diffFiles])].sort((a, b) => a - b);
4703
4657
  if (allNumbers.length === 0) return errors;
4704
- for (const num of schemaFiles) if (num !== INITIAL_SCHEMA_NUMBER && diffFiles.includes(num)) errors.push({
4658
+ for (const num of schemaFiles) if (num !== 0 && diffFiles.includes(num)) errors.push({
4705
4659
  type: "duplicate",
4706
4660
  message: `Migration ${formatMigrationNumber(num)} has both schema and diff files`,
4707
4661
  migrationNumber: num
4708
4662
  });
4709
4663
  const maxNum = Math.max(...allNumbers);
4710
- for (let i = INITIAL_SCHEMA_NUMBER; i <= maxNum; i++) if (!allNumbers.includes(i)) errors.push({
4664
+ for (let i = 0; i <= maxNum; i++) if (!allNumbers.includes(i)) errors.push({
4711
4665
  type: "gap",
4712
4666
  message: `Migration ${formatMigrationNumber(i)} is missing (gap in sequence)`,
4713
4667
  migrationNumber: i
4714
4668
  });
4715
- for (const num of allNumbers) if (num > INITIAL_SCHEMA_NUMBER && !diffFiles.includes(num)) errors.push({
4669
+ for (const num of allNumbers) if (num > 0 && !diffFiles.includes(num)) errors.push({
4716
4670
  type: "missing_diff",
4717
4671
  message: `Migration ${formatMigrationNumber(num)} is missing diff file`,
4718
4672
  migrationNumber: num
@@ -4961,7 +4915,7 @@ async function bundleMigrationScript(sourceFile, namespace, migrationNumber) {
4961
4915
  format: "esm",
4962
4916
  sourcemap: false,
4963
4917
  minify: false,
4964
- inlineDynamicImports: true,
4918
+ codeSplitting: false,
4965
4919
  globals: { tailordb: "tailordb" }
4966
4920
  },
4967
4921
  external: ["tailordb"],
@@ -4997,7 +4951,7 @@ const MIGRATION_LABEL_KEY = "sdk-migration";
4997
4951
  * @returns {number | null} Parsed number or null if invalid
4998
4952
  */
4999
4953
  function parseMigrationLabelNumber(label) {
5000
- if (!label.startsWith(MIGRATION_LABEL_PREFIX)) return null;
4954
+ if (!label.startsWith("m")) return null;
5001
4955
  const numStr = label.slice(1);
5002
4956
  const num = parseInt(numStr, 10);
5003
4957
  return isNaN(num) ? null : num;
@@ -5039,7 +4993,7 @@ async function waitForExecution$1(client, workspaceId, executionId, pollInterval
5039
4993
  logs: execution.logs,
5040
4994
  result: execution.result
5041
4995
  };
5042
- await new Promise((resolve$1) => setTimeout(resolve$1, pollInterval));
4996
+ await new Promise((resolve) => setTimeout(resolve, pollInterval));
5043
4997
  }
5044
4998
  }
5045
4999
  /**
@@ -5053,12 +5007,12 @@ async function waitForExecution$1(client, workspaceId, executionId, pollInterval
5053
5007
  * @returns {Promise<ScriptExecutionResult>} Execution result
5054
5008
  */
5055
5009
  async function executeScript(options) {
5056
- const { client, workspaceId, name, code, arg: arg$1, invoker, pollInterval } = options;
5010
+ const { client, workspaceId, name, code, arg, invoker, pollInterval } = options;
5057
5011
  const response = await client.testExecScript({
5058
5012
  workspaceId,
5059
5013
  name,
5060
5014
  code,
5061
- arg: arg$1 ?? JSON.stringify({}),
5015
+ arg: arg ?? JSON.stringify({}),
5062
5016
  invoker
5063
5017
  });
5064
5018
  const executionId = response.executionId;
@@ -5092,8 +5046,8 @@ async function executeScript(options) {
5092
5046
  */
5093
5047
  async function getCurrentMigrationNumber(client, workspaceId, namespace) {
5094
5048
  try {
5095
- const trn$7 = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5096
- const { metadata } = await client.getMetadata({ trn: trn$7 });
5049
+ const trn = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5050
+ const { metadata } = await client.getMetadata({ trn });
5097
5051
  const label = metadata?.labels[MIGRATION_LABEL_KEY];
5098
5052
  if (!label) return 0;
5099
5053
  return parseMigrationLabelNumber(label) ?? 0;
@@ -5171,12 +5125,12 @@ async function executeSingleMigration(options, migration) {
5171
5125
  * @returns {Promise<void>}
5172
5126
  */
5173
5127
  async function updateMigrationLabel(client, workspaceId, namespace, migrationNumber) {
5174
- const trn$7 = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5175
- const { metadata } = await client.getMetadata({ trn: trn$7 });
5128
+ const trn = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5129
+ const { metadata } = await client.getMetadata({ trn });
5176
5130
  const existingLabels = metadata?.labels ?? {};
5177
5131
  const newLabel = `m${formatMigrationNumber(migrationNumber)}`;
5178
5132
  await client.setMetadata({
5179
- trn: trn$7,
5133
+ trn,
5180
5134
  labels: {
5181
5135
  ...existingLabels,
5182
5136
  [MIGRATION_LABEL_KEY]: newLabel
@@ -5288,8 +5242,8 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
5288
5242
  */
5289
5243
  async function getRemoteMigrationNumber(client, workspaceId, namespace) {
5290
5244
  try {
5291
- const trn$7 = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5292
- const { metadata } = await client.getMetadata({ trn: trn$7 });
5245
+ const trn = `${trnPrefix(workspaceId)}:tailordb:${namespace}`;
5246
+ const { metadata } = await client.getMetadata({ trn });
5293
5247
  const label = metadata?.labels?.["sdk-migration"];
5294
5248
  if (!label) return null;
5295
5249
  const match = label.match(/^m(\d+)$/);
@@ -5467,16 +5421,16 @@ async function applyTailorDB(client, result, phase = "create-update") {
5467
5421
  });
5468
5422
  if (remainingGqlPermissionDeletes.length > 0) await Promise.all(remainingGqlPermissionDeletes.map((del) => client.deleteTailorDBGQLPermission(del.request)));
5469
5423
  } else {
5470
- await Promise.all([...changeSet.service.creates.map(async (create$1) => {
5471
- await client.createTailorDBService(create$1.request);
5472
- await client.setMetadata(create$1.metaRequest);
5424
+ await Promise.all([...changeSet.service.creates.map(async (create) => {
5425
+ await client.createTailorDBService(create.request);
5426
+ await client.setMetadata(create.metaRequest);
5473
5427
  }), ...changeSet.service.updates.map((update) => client.setMetadata(update.metaRequest))]);
5474
5428
  try {
5475
- await Promise.all([...changeSet.type.creates.map((create$1) => client.createTailorDBType(create$1.request)), ...changeSet.type.updates.map((update) => client.updateTailorDBType(update.request))]);
5429
+ await Promise.all([...changeSet.type.creates.map((create) => client.createTailorDBType(create.request)), ...changeSet.type.updates.map((update) => client.updateTailorDBType(update.request))]);
5476
5430
  } catch (error) {
5477
5431
  handleOptionalToRequiredError(error, ["Run 'tailor-sdk tailordb migration generate' to create migration files.", "Migration scripts allow you to handle existing data before applying the schema change."]);
5478
5432
  }
5479
- await Promise.all([...changeSet.gqlPermission.creates.map((create$1) => client.createTailorDBGQLPermission(create$1.request)), ...changeSet.gqlPermission.updates.map((update) => client.updateTailorDBGQLPermission(update.request))]);
5433
+ await Promise.all([...changeSet.gqlPermission.creates.map((create) => client.createTailorDBGQLPermission(create.request)), ...changeSet.gqlPermission.updates.map((update) => client.updateTailorDBGQLPermission(update.request))]);
5480
5434
  await Promise.all(changeSet.gqlPermission.deletes.map((del) => client.deleteTailorDBGQLPermission(del.request)));
5481
5435
  await Promise.all(changeSet.type.deletes.map((del) => client.deleteTailorDBType(del.request)));
5482
5436
  }
@@ -5568,9 +5522,9 @@ function getDeletedTypeNames(migration) {
5568
5522
  * @returns {Promise<void>} Promise that resolves when services are created
5569
5523
  */
5570
5524
  async function executeServicesCreation(client, changeSet) {
5571
- await Promise.all([...changeSet.service.creates.map(async (create$1) => {
5572
- await client.createTailorDBService(create$1.request);
5573
- await client.setMetadata(create$1.metaRequest);
5525
+ await Promise.all([...changeSet.service.creates.map(async (create) => {
5526
+ await client.createTailorDBService(create.request);
5527
+ await client.setMetadata(create.metaRequest);
5574
5528
  }), ...changeSet.service.updates.map((update) => client.setMetadata(update.metaRequest))]);
5575
5529
  }
5576
5530
  /**
@@ -5598,35 +5552,35 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration) {
5598
5552
  const affectedTypes = getAffectedTypeNames(migration);
5599
5553
  const createdBeforeMigration = new Set(processedTypes.created);
5600
5554
  await Promise.all([
5601
- ...changeSet.type.creates.filter((create$1) => {
5602
- const typeName = create$1.request.tailordbType?.name;
5555
+ ...changeSet.type.creates.filter((create) => {
5556
+ const typeName = create.request.tailordbType?.name;
5603
5557
  return typeName && affectedTypes.has(typeName) && !createdBeforeMigration.has(typeName);
5604
- }).map((create$1) => {
5605
- const typeName = create$1.request.tailordbType?.name;
5558
+ }).map((create) => {
5559
+ const typeName = create.request.tailordbType?.name;
5606
5560
  if (typeName) processedTypes.created.add(typeName);
5607
5561
  const typeChanges = typeName ? breakingChanges.get(typeName) : void 0;
5608
- if (!typeChanges || typeChanges.size === 0) return client.createTailorDBType(create$1.request);
5609
- const clonedRequest = structuredClone(create$1.request);
5562
+ if (!typeChanges || typeChanges.size === 0) return client.createTailorDBType(create.request);
5563
+ const clonedRequest = structuredClone(create.request);
5610
5564
  if (clonedRequest.tailordbType?.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
5611
5565
  return client.createTailorDBType(clonedRequest);
5612
5566
  }),
5613
- ...changeSet.type.creates.filter((create$1) => {
5614
- const typeName = create$1.request.tailordbType?.name;
5567
+ ...changeSet.type.creates.filter((create) => {
5568
+ const typeName = create.request.tailordbType?.name;
5615
5569
  return typeName && affectedTypes.has(typeName) && createdBeforeMigration.has(typeName);
5616
- }).map((create$1) => {
5617
- const typeName = create$1.request.tailordbType?.name;
5570
+ }).map((create) => {
5571
+ const typeName = create.request.tailordbType?.name;
5618
5572
  if (typeName) processedTypes.updated.add(typeName);
5619
5573
  const typeChanges = typeName ? breakingChanges.get(typeName) : void 0;
5620
5574
  if (!typeChanges || typeChanges.size === 0) return client.updateTailorDBType({
5621
- workspaceId: create$1.request.workspaceId,
5622
- namespaceName: create$1.request.namespaceName,
5623
- tailordbType: create$1.request.tailordbType
5575
+ workspaceId: create.request.workspaceId,
5576
+ namespaceName: create.request.namespaceName,
5577
+ tailordbType: create.request.tailordbType
5624
5578
  });
5625
- const clonedRequest = structuredClone(create$1.request);
5579
+ const clonedRequest = structuredClone(create.request);
5626
5580
  if (clonedRequest.tailordbType?.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
5627
5581
  return client.updateTailorDBType({
5628
- workspaceId: create$1.request.workspaceId,
5629
- namespaceName: create$1.request.namespaceName,
5582
+ workspaceId: create.request.workspaceId,
5583
+ namespaceName: create.request.namespaceName,
5630
5584
  tailordbType: clonedRequest.tailordbType
5631
5585
  });
5632
5586
  }),
@@ -5644,20 +5598,20 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration) {
5644
5598
  })
5645
5599
  ]);
5646
5600
  if (!processedTypes.gqlPermissionsProcessed.has(migration.namespace)) {
5647
- const gqlPermissionCreatesForNamespace = changeSet.gqlPermission.creates.filter((create$1) => create$1.request.namespaceName === migration.namespace);
5601
+ const gqlPermissionCreatesForNamespace = changeSet.gqlPermission.creates.filter((create) => create.request.namespaceName === migration.namespace);
5648
5602
  const gqlPermissionUpdatesForNamespace = changeSet.gqlPermission.updates.filter((update) => update.request.namespaceName === migration.namespace);
5649
- const gqlPermissionTypeNames = new Set(gqlPermissionCreatesForNamespace.map((create$1) => create$1.name));
5650
- const missingTypeCreates = changeSet.type.creates.filter((create$1) => {
5651
- const typeName = create$1.request.tailordbType?.name;
5652
- return create$1.request.namespaceName === migration.namespace && typeName && gqlPermissionTypeNames.has(typeName) && !processedTypes.created.has(typeName);
5603
+ const gqlPermissionTypeNames = new Set(gqlPermissionCreatesForNamespace.map((create) => create.name));
5604
+ const missingTypeCreates = changeSet.type.creates.filter((create) => {
5605
+ const typeName = create.request.tailordbType?.name;
5606
+ return create.request.namespaceName === migration.namespace && typeName && gqlPermissionTypeNames.has(typeName) && !processedTypes.created.has(typeName);
5653
5607
  });
5654
- if (missingTypeCreates.length > 0) await Promise.all(missingTypeCreates.map((create$1) => {
5655
- const typeName = create$1.request.tailordbType?.name;
5608
+ if (missingTypeCreates.length > 0) await Promise.all(missingTypeCreates.map((create) => {
5609
+ const typeName = create.request.tailordbType?.name;
5656
5610
  if (typeName) processedTypes.created.add(typeName);
5657
- return client.createTailorDBType(create$1.request);
5611
+ return client.createTailorDBType(create.request);
5658
5612
  }));
5659
5613
  processedTypes.gqlPermissionsProcessed.add(migration.namespace);
5660
- await Promise.all([...gqlPermissionCreatesForNamespace.map((create$1) => client.createTailorDBGQLPermission(create$1.request)), ...gqlPermissionUpdatesForNamespace.map((update) => client.updateTailorDBGQLPermission(update.request))]);
5614
+ await Promise.all([...gqlPermissionCreatesForNamespace.map((create) => client.createTailorDBGQLPermission(create.request)), ...gqlPermissionUpdatesForNamespace.map((update) => client.updateTailorDBGQLPermission(update.request))]);
5661
5615
  }
5662
5616
  }
5663
5617
  /**
@@ -5683,13 +5637,13 @@ async function executeSingleMigrationPostPhase(client, changeSet, migration) {
5683
5637
  const affectedTypes = getAffectedTypeNames(migration);
5684
5638
  const deletedTypeNames = getDeletedTypeNames(migration);
5685
5639
  try {
5686
- await Promise.all([...changeSet.type.creates.filter((create$1) => {
5687
- const typeName = create$1.request.tailordbType?.name;
5640
+ await Promise.all([...changeSet.type.creates.filter((create) => {
5641
+ const typeName = create.request.tailordbType?.name;
5688
5642
  return typeName && affectedTypes.has(typeName) && breakingChanges.has(typeName);
5689
- }).map((create$1) => client.updateTailorDBType({
5690
- workspaceId: create$1.request.workspaceId,
5691
- namespaceName: create$1.request.namespaceName,
5692
- tailordbType: create$1.request.tailordbType
5643
+ }).map((create) => client.updateTailorDBType({
5644
+ workspaceId: create.request.workspaceId,
5645
+ namespaceName: create.request.namespaceName,
5646
+ tailordbType: create.request.tailordbType
5693
5647
  })), ...changeSet.type.updates.filter((update) => {
5694
5648
  const typeName = update.request.tailordbType?.name;
5695
5649
  return typeName && affectedTypes.has(typeName) && breakingChanges.has(typeName);
@@ -6383,22 +6337,24 @@ async function applyWorkflow(client, result, phase = "create-update") {
6383
6337
  const { changeSet, appName } = result;
6384
6338
  if (phase === "create-update") {
6385
6339
  const jobFunctionVersions = await registerJobFunctions(client, changeSet, appName);
6386
- await Promise.all([...changeSet.creates.map(async (create$1) => {
6387
- const filteredVersions = filterJobFunctionVersions(jobFunctionVersions, create$1.usedJobNames);
6340
+ await Promise.all([...changeSet.creates.map(async (create) => {
6341
+ const filteredVersions = filterJobFunctionVersions(jobFunctionVersions, create.usedJobNames);
6388
6342
  await client.createWorkflow({
6389
- workspaceId: create$1.workspaceId,
6390
- workflowName: create$1.workflow.name,
6391
- mainJobFunctionName: create$1.workflow.mainJob.name,
6392
- jobFunctions: filteredVersions
6343
+ workspaceId: create.workspaceId,
6344
+ workflowName: create.workflow.name,
6345
+ mainJobFunctionName: create.workflow.mainJob.name,
6346
+ jobFunctions: filteredVersions,
6347
+ ...create.workflow.retryPolicy && { retryPolicy: toRetryPolicy(create.workflow.retryPolicy) }
6393
6348
  });
6394
- await client.setMetadata(create$1.metaRequest);
6349
+ await client.setMetadata(create.metaRequest);
6395
6350
  }), ...changeSet.updates.map(async (update) => {
6396
6351
  const filteredVersions = filterJobFunctionVersions(jobFunctionVersions, update.usedJobNames);
6397
6352
  await client.updateWorkflow({
6398
6353
  workspaceId: update.workspaceId,
6399
6354
  workflowName: update.workflow.name,
6400
6355
  mainJobFunctionName: update.workflow.mainJob.name,
6401
- jobFunctions: filteredVersions
6356
+ jobFunctions: filteredVersions,
6357
+ ...update.workflow.retryPolicy && { retryPolicy: toRetryPolicy(update.workflow.retryPolicy) }
6402
6358
  });
6403
6359
  await client.setMetadata(update.metaRequest);
6404
6360
  })]);
@@ -6464,13 +6420,30 @@ async function registerJobFunctions(client, changeSet, appName) {
6464
6420
  const unusedJobFunctions = existingJobFunctions.filter((jobName) => !allUsedJobNames.has(jobName));
6465
6421
  await Promise.all(unusedJobFunctions.map(async (jobName) => {
6466
6422
  const { metadata } = await client.getMetadata({ trn: jobFunctionTrn(workspaceId, jobName) });
6467
- if (metadata?.labels?.[sdkNameLabelKey] === appName) await client.setMetadata({
6423
+ if (metadata?.labels?.["sdk-name"] === appName) await client.setMetadata({
6468
6424
  trn: jobFunctionTrn(workspaceId, jobName),
6469
6425
  labels: { [sdkNameLabelKey]: "" }
6470
6426
  });
6471
6427
  }));
6472
6428
  return jobFunctionVersions;
6473
6429
  }
6430
+ function parseDurationToProto(duration) {
6431
+ const ms = parseDuration(duration);
6432
+ const seconds = Math.floor(ms / 1e3);
6433
+ const nanos = ms % 1e3 * 1e6;
6434
+ return {
6435
+ seconds: BigInt(seconds),
6436
+ nanos
6437
+ };
6438
+ }
6439
+ function toRetryPolicy(policy) {
6440
+ return {
6441
+ maxRetries: policy.maxRetries,
6442
+ initialBackoff: parseDurationToProto(policy.initialBackoff),
6443
+ maxBackoff: parseDurationToProto(policy.maxBackoff),
6444
+ backoffMultiplier: policy.backoffMultiplier
6445
+ };
6446
+ }
6474
6447
  function workflowTrn(workspaceId, name) {
6475
6448
  return `trn:v1:workspace:${workspaceId}:workflow:${name}`;
6476
6449
  }
@@ -6571,9 +6544,9 @@ async function apply(options) {
6571
6544
  return withSpan("apply", async (rootSpan) => {
6572
6545
  rootSpan.setAttribute("apply.dry_run", options?.dryRun ?? false);
6573
6546
  const { config, application, workflowBuildResult, buildOnly } = await withSpan("build", async () => {
6574
- const { config: config$1, plugins } = await withSpan("build.loadConfig", () => loadConfig(options?.configPath));
6575
- const dryRun$1 = options?.dryRun ?? false;
6576
- const buildOnly$1 = options?.buildOnly ?? process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY === "true";
6547
+ const { config, plugins } = await withSpan("build.loadConfig", () => loadConfig(options?.configPath));
6548
+ const dryRun = options?.dryRun ?? false;
6549
+ const buildOnly = options?.buildOnly ?? process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY === "true";
6577
6550
  const noCache = options?.noCache ?? false;
6578
6551
  const packageJson = await readPackageJson();
6579
6552
  const cacheDir = path.resolve(getDistDir(), "cache");
@@ -6584,7 +6557,7 @@ async function apply(options) {
6584
6557
  });
6585
6558
  logger.info("Bundle cache cleaned");
6586
6559
  }
6587
- const configDir = path.dirname(config$1.path);
6560
+ const configDir = path.dirname(config.path);
6588
6561
  const lockfilePath = findUpSync("pnpm-lock.yaml", { cwd: configDir }) ?? findUpSync("package-lock.json", { cwd: configDir }) ?? findUpSync("yarn.lock", { cwd: configDir }) ?? findUpSync("bun.lock", { cwd: configDir });
6589
6562
  const cacheManager = createCacheManager({
6590
6563
  enabled: !noCache,
@@ -6595,29 +6568,29 @@ async function apply(options) {
6595
6568
  let pluginManager;
6596
6569
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
6597
6570
  await withSpan("build.generateUserTypes", () => generateUserTypes({
6598
- config: config$1,
6599
- configPath: config$1.path
6571
+ config,
6572
+ configPath: config.path
6600
6573
  }));
6601
- let application$1;
6602
- let workflowBuildResult$1;
6574
+ let application;
6575
+ let workflowBuildResult;
6603
6576
  try {
6604
6577
  const result = await withSpan("build.loadApplication", () => loadApplication({
6605
- config: config$1,
6578
+ config,
6606
6579
  pluginManager,
6607
6580
  bundleCache: cacheManager.bundleCache
6608
6581
  }));
6609
- application$1 = result.application;
6610
- workflowBuildResult$1 = result.workflowBuildResult;
6582
+ application = result.application;
6583
+ workflowBuildResult = result.workflowBuildResult;
6611
6584
  } finally {
6612
6585
  cacheManager.finalize();
6613
6586
  }
6614
6587
  return {
6615
- config: config$1,
6588
+ config,
6616
6589
  plugins,
6617
- application: application$1,
6618
- workflowBuildResult: workflowBuildResult$1,
6619
- dryRun: dryRun$1,
6620
- buildOnly: buildOnly$1
6590
+ application,
6591
+ workflowBuildResult,
6592
+ dryRun,
6593
+ buildOnly
6621
6594
  };
6622
6595
  });
6623
6596
  if (buildOnly) return;
@@ -6644,7 +6617,7 @@ async function apply(options) {
6644
6617
  config,
6645
6618
  noSchemaCheck: options?.noSchemaCheck
6646
6619
  };
6647
- const [functionRegistry$1, tailorDB$1, staticWebsite$1, idp$1, auth$1, pipeline$1, app$1, executor$1, workflow$1, secretManager$1] = await Promise.all([
6620
+ const [functionRegistry, tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow, secretManager] = await Promise.all([
6648
6621
  withSpan("plan.functionRegistry", () => planFunctionRegistry(client, workspaceId, application.name, functionEntries)),
6649
6622
  withSpan("plan.tailorDB", () => planTailorDB(ctx)),
6650
6623
  withSpan("plan.staticWebsite", () => planStaticWebsite(ctx)),
@@ -6657,16 +6630,16 @@ async function apply(options) {
6657
6630
  withSpan("plan.secretManager", () => planSecretManager(ctx))
6658
6631
  ]);
6659
6632
  return {
6660
- functionRegistry: functionRegistry$1,
6661
- tailorDB: tailorDB$1,
6662
- staticWebsite: staticWebsite$1,
6663
- idp: idp$1,
6664
- auth: auth$1,
6665
- pipeline: pipeline$1,
6666
- app: app$1,
6667
- executor: executor$1,
6668
- workflow: workflow$1,
6669
- secretManager: secretManager$1
6633
+ functionRegistry,
6634
+ tailorDB,
6635
+ staticWebsite,
6636
+ idp,
6637
+ auth,
6638
+ pipeline,
6639
+ app,
6640
+ executor,
6641
+ workflow,
6642
+ secretManager
6670
6643
  };
6671
6644
  });
6672
6645
  await withSpan("confirm", async () => {
@@ -7075,16 +7048,14 @@ async function getExecutor(options) {
7075
7048
  throw error;
7076
7049
  }
7077
7050
  }
7078
- const getCommand$3 = defineCommand({
7051
+ const getCommand$3 = defineAppCommand({
7079
7052
  name: "get",
7080
7053
  description: "Get executor details",
7081
7054
  args: z.object({
7082
- ...commonArgs,
7083
- ...jsonArgs,
7084
7055
  ...workspaceArgs,
7085
7056
  ...nameArgs$1
7086
7057
  }).strict(),
7087
- run: withCommonArgs(async (args) => {
7058
+ run: async (args) => {
7088
7059
  const executor = await getExecutor({
7089
7060
  name: args.name,
7090
7061
  workspaceId: args["workspace-id"],
@@ -7094,7 +7065,7 @@ const getCommand$3 = defineCommand({
7094
7065
  triggerConfig: null,
7095
7066
  targetConfig: null
7096
7067
  } });
7097
- })
7068
+ }
7098
7069
  });
7099
7070
 
7100
7071
  //#endregion
@@ -7286,7 +7257,7 @@ function toWorkflowExecutionInfo(execution) {
7286
7257
  //#endregion
7287
7258
  //#region src/cli/commands/workflow/executions.ts
7288
7259
  function sleep$1(ms) {
7289
- return new Promise((resolve$1) => setTimeout(resolve$1, ms));
7260
+ return new Promise((resolve) => setTimeout(resolve, ms));
7290
7261
  }
7291
7262
  function formatTime$2(date) {
7292
7263
  return date.toLocaleTimeString("en-US", { hour12: false });
@@ -7323,14 +7294,6 @@ async function listWorkflowExecutions(options) {
7323
7294
  profile: options?.profile
7324
7295
  });
7325
7296
  const filters = [];
7326
- if (workflowName) filters.push(create(FilterSchema, { condition: create(ConditionSchema, {
7327
- field: "workflow_name",
7328
- operator: Condition_Operator.EQ,
7329
- value: { kind: {
7330
- case: "stringValue",
7331
- value: workflowName
7332
- } }
7333
- }) }));
7334
7297
  if (options?.status) {
7335
7298
  const statusValue = parseStatus(options.status);
7336
7299
  filters.push(create(FilterSchema, { condition: create(ConditionSchema, {
@@ -7346,6 +7309,7 @@ async function listWorkflowExecutions(options) {
7346
7309
  return (await fetchAll(async (pageToken, maxPageSize) => {
7347
7310
  const { executions, nextPageToken } = await client.listWorkflowExecutions({
7348
7311
  workspaceId,
7312
+ workflowName: workflowName ?? "",
7349
7313
  pageToken,
7350
7314
  pageSize: maxPageSize,
7351
7315
  pageDirection: PageDirection.DESC,
@@ -7480,18 +7444,16 @@ function printExecutionWithLogs(execution) {
7480
7444
  }
7481
7445
  }
7482
7446
  }
7483
- const executionsCommand = defineCommand({
7447
+ const executionsCommand = defineAppCommand({
7484
7448
  name: "executions",
7485
7449
  description: "List or get workflow executions.",
7486
7450
  args: z.object({
7487
- ...commonArgs,
7488
- ...jsonArgs,
7489
7451
  ...workspaceArgs,
7490
7452
  executionId: arg(z.string().optional(), {
7491
7453
  positional: true,
7492
7454
  description: "Execution ID (if provided, shows details)"
7493
7455
  }),
7494
- "workflow-name": arg(z.string().optional(), {
7456
+ "workflow-name": arg(z.string().regex(/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$/, "Must be 3-63 lowercase alphanumeric characters or hyphens, starting and ending with alphanumeric").optional(), {
7495
7457
  alias: "n",
7496
7458
  description: "Filter by workflow name (list mode only)"
7497
7459
  }),
@@ -7502,7 +7464,7 @@ const executionsCommand = defineCommand({
7502
7464
  ...waitArgs,
7503
7465
  logs: arg(z.boolean().default(false), { description: "Display job execution logs (detail mode only)" })
7504
7466
  }).strict(),
7505
- run: withCommonArgs(async (args) => {
7467
+ run: async (args) => {
7506
7468
  if (args.executionId) {
7507
7469
  const interval = parseDuration(args.interval);
7508
7470
  const { execution, wait } = await getWorkflowExecution({
@@ -7525,7 +7487,7 @@ const executionsCommand = defineCommand({
7525
7487
  });
7526
7488
  logger.out(executions);
7527
7489
  }
7528
- })
7490
+ }
7529
7491
  });
7530
7492
 
7531
7493
  //#endregion
@@ -7562,29 +7524,27 @@ async function getWorkflow(options) {
7562
7524
  throw error;
7563
7525
  }
7564
7526
  }
7565
- const getCommand$2 = defineCommand({
7527
+ const getCommand$2 = defineAppCommand({
7566
7528
  name: "get",
7567
7529
  description: "Get workflow details.",
7568
7530
  args: z.object({
7569
- ...commonArgs,
7570
- ...jsonArgs,
7571
7531
  ...workspaceArgs,
7572
7532
  ...nameArgs
7573
7533
  }).strict(),
7574
- run: withCommonArgs(async (args) => {
7534
+ run: async (args) => {
7575
7535
  const workflow = await getWorkflow({
7576
7536
  name: args.name,
7577
7537
  workspaceId: args["workspace-id"],
7578
7538
  profile: args.profile
7579
7539
  });
7580
7540
  logger.out(workflow);
7581
- })
7541
+ }
7582
7542
  });
7583
7543
 
7584
7544
  //#endregion
7585
7545
  //#region src/cli/commands/workflow/start.ts
7586
7546
  function sleep(ms) {
7587
- return new Promise((resolve$1) => setTimeout(resolve$1, ms));
7547
+ return new Promise((resolve) => setTimeout(resolve, ms));
7588
7548
  }
7589
7549
  function formatTime$1(date) {
7590
7550
  return date.toLocaleTimeString("en-US", { hour12: false });
@@ -7672,12 +7632,12 @@ async function startWorkflowCore(options) {
7672
7632
  try {
7673
7633
  const workflow = await resolveWorkflow(client, workspaceId, workflowName);
7674
7634
  const authInvoker = create(AuthInvokerSchema, options.authInvoker);
7675
- const arg$1 = options.arg === void 0 ? void 0 : typeof options.arg === "string" ? options.arg : JSON.stringify(options.arg);
7635
+ const arg = options.arg === void 0 ? void 0 : typeof options.arg === "string" ? options.arg : JSON.stringify(options.arg);
7676
7636
  const { executionId } = await client.testStartWorkflow({
7677
7637
  workspaceId,
7678
7638
  workflowId: workflow.id,
7679
7639
  authInvoker,
7680
- arg: arg$1
7640
+ arg
7681
7641
  });
7682
7642
  return {
7683
7643
  executionId,
@@ -7739,12 +7699,10 @@ async function startWorkflow(options) {
7739
7699
  interval: options.interval
7740
7700
  });
7741
7701
  }
7742
- const startCommand = defineCommand({
7702
+ const startCommand = defineAppCommand({
7743
7703
  name: "start",
7744
7704
  description: "Start a workflow execution.",
7745
7705
  args: z.object({
7746
- ...commonArgs,
7747
- ...jsonArgs,
7748
7706
  ...deploymentArgs,
7749
7707
  ...nameArgs,
7750
7708
  machineuser: arg(z.string(), {
@@ -7757,7 +7715,7 @@ const startCommand = defineCommand({
7757
7715
  }),
7758
7716
  ...waitArgs
7759
7717
  }).strict(),
7760
- run: withCommonArgs(async (args) => {
7718
+ run: async (args) => {
7761
7719
  const { executionId, wait } = await startWorkflowByName({
7762
7720
  name: args.name,
7763
7721
  machineUser: args.machineuser,
@@ -7780,7 +7738,7 @@ const startCommand = defineCommand({
7780
7738
  printExecutionWithLogs(execution);
7781
7739
  } else logger.out(result);
7782
7740
  } else logger.out({ executionId });
7783
- })
7741
+ }
7784
7742
  });
7785
7743
 
7786
7744
  //#endregion
@@ -7845,14 +7803,14 @@ async function getExecutorJob(options) {
7845
7803
  const jobInfo = toExecutorJobInfo(job);
7846
7804
  if (options.attempts) {
7847
7805
  const attempts = await fetchAll(async (pageToken, maxPageSize) => {
7848
- const { attempts: attempts$1, nextPageToken } = await client.listExecutorJobAttempts({
7806
+ const { attempts, nextPageToken } = await client.listExecutorJobAttempts({
7849
7807
  workspaceId,
7850
7808
  jobId: options.jobId,
7851
7809
  pageToken,
7852
7810
  pageSize: maxPageSize,
7853
7811
  pageDirection: PageDirection.DESC
7854
7812
  });
7855
- return [attempts$1, nextPageToken];
7813
+ return [attempts, nextPageToken];
7856
7814
  });
7857
7815
  return {
7858
7816
  ...jobInfo,
@@ -7936,10 +7894,10 @@ async function watchExecutorJob(options) {
7936
7894
  profile: options.profile,
7937
7895
  logs: true
7938
7896
  });
7939
- if (execWithLogs.jobDetails) workflowJobLogs = execWithLogs.jobDetails.filter((job$1) => job$1.logs || job$1.result).map((job$1) => ({
7940
- jobName: job$1.stackedJobName || job$1.id,
7941
- logs: job$1.logs,
7942
- result: job$1.result
7897
+ if (execWithLogs.jobDetails) workflowJobLogs = execWithLogs.jobDetails.filter((job) => job.logs || job.result).map((job) => ({
7898
+ jobName: job.stackedJobName || job.id,
7899
+ logs: job.logs,
7900
+ result: job.result
7943
7901
  }));
7944
7902
  }
7945
7903
  return {
@@ -8027,7 +7985,7 @@ function printJobWithAttempts(job) {
8027
7985
  }
8028
7986
  }
8029
7987
  }
8030
- const jobsCommand = defineCommand({
7988
+ const jobsCommand = defineAppCommand({
8031
7989
  name: "jobs",
8032
7990
  description: "List or get executor jobs.",
8033
7991
  examples: [
@@ -8061,8 +8019,6 @@ const jobsCommand = defineCommand({
8061
8019
  }
8062
8020
  ],
8063
8021
  args: z.object({
8064
- ...commonArgs,
8065
- ...jsonArgs,
8066
8022
  ...workspaceArgs,
8067
8023
  executorName: arg(z.string(), {
8068
8024
  positional: true,
@@ -8091,7 +8047,7 @@ const jobsCommand = defineCommand({
8091
8047
  }),
8092
8048
  limit: arg(positiveIntArg.optional(), { description: "Maximum number of jobs to list (default: 50, max: 1000) (list mode only)" })
8093
8049
  }).strict(),
8094
- run: withCommonArgs(async (args) => {
8050
+ run: async (args) => {
8095
8051
  if (args.jobId) {
8096
8052
  if (args.wait) {
8097
8053
  const result = await watchExecutorJob({
@@ -8159,7 +8115,7 @@ const jobsCommand = defineCommand({
8159
8115
  });
8160
8116
  logger.out(jobs);
8161
8117
  }
8162
- })
8118
+ }
8163
8119
  });
8164
8120
 
8165
8121
  //#endregion
@@ -8187,15 +8143,11 @@ async function listExecutors(options) {
8187
8143
  return [executors, nextPageToken];
8188
8144
  })).map((e) => toExecutorListInfo(e));
8189
8145
  }
8190
- const listCommand$6 = defineCommand({
8146
+ const listCommand$6 = defineAppCommand({
8191
8147
  name: "list",
8192
8148
  description: "List all executors",
8193
- args: z.object({
8194
- ...commonArgs,
8195
- ...jsonArgs,
8196
- ...workspaceArgs
8197
- }).strict(),
8198
- run: withCommonArgs(async (args) => {
8149
+ args: z.object({ ...workspaceArgs }).strict(),
8150
+ run: async (args) => {
8199
8151
  const executors = await listExecutors({
8200
8152
  workspaceId: args["workspace-id"],
8201
8153
  profile: args.profile
@@ -8208,7 +8160,7 @@ const listCommand$6 = defineCommand({
8208
8160
  if (!args.json) {
8209
8161
  if (executors.some((e) => e.triggerType === "webhook")) logger.info("To see webhook URLs, run: tailor-sdk executor webhook list");
8210
8162
  }
8211
- })
8163
+ }
8212
8164
  });
8213
8165
 
8214
8166
  //#endregion
@@ -8271,7 +8223,7 @@ async function triggerExecutor(options) {
8271
8223
  profile: options.profile
8272
8224
  });
8273
8225
  }
8274
- const triggerCommand = defineCommand({
8226
+ const triggerCommand = defineAppCommand({
8275
8227
  name: "trigger",
8276
8228
  description: "Trigger an executor manually.",
8277
8229
  notes: `Only executors with \`INCOMING_WEBHOOK\` or \`SCHEDULE\` trigger types can be triggered manually.
@@ -8311,8 +8263,6 @@ The \`--logs\` option displays logs from the downstream execution when available
8311
8263
  }
8312
8264
  ],
8313
8265
  args: z.object({
8314
- ...commonArgs,
8315
- ...jsonArgs,
8316
8266
  ...workspaceArgs,
8317
8267
  executorName: arg(z.string(), {
8318
8268
  positional: true,
@@ -8340,7 +8290,7 @@ The \`--logs\` option displays logs from the downstream execution when available
8340
8290
  description: "Display function execution logs after completion (requires --wait)"
8341
8291
  })
8342
8292
  }).strict(),
8343
- run: withCommonArgs(async (args) => {
8293
+ run: async (args) => {
8344
8294
  const client = await initOperatorClient(await loadAccessToken({
8345
8295
  useProfile: true,
8346
8296
  profile: args.profile
@@ -8421,7 +8371,7 @@ The \`--logs\` option displays logs from the downstream execution when available
8421
8371
  }
8422
8372
  } else logger.out(watchResult);
8423
8373
  }
8424
- })
8374
+ }
8425
8375
  });
8426
8376
 
8427
8377
  //#endregion
@@ -8462,15 +8412,11 @@ async function listWebhookExecutors(options) {
8462
8412
  disabled: e.disabled
8463
8413
  }));
8464
8414
  }
8465
- const listWebhookCommand = defineCommand({
8415
+ const listWebhookCommand = defineAppCommand({
8466
8416
  name: "list",
8467
8417
  description: "List executors with incoming webhook triggers",
8468
- args: z.object({
8469
- ...commonArgs,
8470
- ...jsonArgs,
8471
- ...workspaceArgs
8472
- }).strict(),
8473
- run: withCommonArgs(async (args) => {
8418
+ args: z.object({ ...workspaceArgs }).strict(),
8419
+ run: async (args) => {
8474
8420
  const executors = await listWebhookExecutors({
8475
8421
  workspaceId: args["workspace-id"],
8476
8422
  profile: args.profile
@@ -8481,7 +8427,7 @@ const listWebhookCommand = defineCommand({
8481
8427
  }
8482
8428
  logger.out(executors, { display: { disabled: (v) => v ? styles.warning("true") : styles.dim("false") } });
8483
8429
  if (!args.json) logger.info("To test a webhook, run: tailor-sdk executor trigger <name> -d '{\"key\":\"value\"}'");
8484
- })
8430
+ }
8485
8431
  });
8486
8432
  const webhookCommand = defineCommand({
8487
8433
  name: "webhook",
@@ -8959,10 +8905,10 @@ function createGenerationManager(params) {
8959
8905
  const results = generatorResults[gen.id];
8960
8906
  results.resolverResults[namespace] = {};
8961
8907
  if (!gen.processResolver) return;
8962
- const processResolver$1 = gen.processResolver;
8908
+ const processResolver = gen.processResolver;
8963
8909
  await Promise.allSettled(Object.entries(resolvers).map(async ([resolverName, resolver]) => {
8964
8910
  try {
8965
- results.resolverResults[namespace][resolverName] = await processResolver$1({
8911
+ results.resolverResults[namespace][resolverName] = await processResolver({
8966
8912
  resolver,
8967
8913
  namespace
8968
8914
  });
@@ -9093,7 +9039,7 @@ function createGenerationManager(params) {
9093
9039
  * @param hookName - Name of the hook to call
9094
9040
  * @param watch - Whether running in watch mode (suppresses throws)
9095
9041
  */
9096
- async function runPluginHook(hookName, watch$1) {
9042
+ async function runPluginHook(hookName, watch) {
9097
9043
  const plugins = generationPlugins.filter((p) => p[hookName] != null);
9098
9044
  if (plugins.length === 0) return;
9099
9045
  const results = await Promise.allSettled(plugins.map(async (plugin) => {
@@ -9102,10 +9048,10 @@ function createGenerationManager(params) {
9102
9048
  } catch (error) {
9103
9049
  logger.error(`Error processing plugin ${styles.bold(plugin.id)} (${hookName})`);
9104
9050
  logger.error(String(error));
9105
- if (!watch$1) throw error;
9051
+ if (!watch) throw error;
9106
9052
  }
9107
9053
  }));
9108
- if (!watch$1) {
9054
+ if (!watch) {
9109
9055
  const failures = results.filter((r) => r.status === "rejected");
9110
9056
  if (failures.length > 0) throw new AggregateError(failures.map((f) => f.reason));
9111
9057
  }
@@ -9118,11 +9064,11 @@ function createGenerationManager(params) {
9118
9064
  async function writeGeneratedFiles(sourceId, result) {
9119
9065
  await Promise.all(result.files.map(async (file) => {
9120
9066
  fs$1.mkdirSync(path.dirname(file.path), { recursive: true });
9121
- return new Promise((resolve$1, reject) => {
9067
+ return new Promise((resolve, reject) => {
9122
9068
  if (file.skipIfExists && fs$1.existsSync(file.path)) {
9123
9069
  const relativePath = path.relative(process.cwd(), file.path);
9124
9070
  logger.debug(`${sourceId} | skip existing: ${relativePath}`);
9125
- return resolve$1();
9071
+ return resolve();
9126
9072
  }
9127
9073
  fs$1.writeFile(file.path, file.content, (err) => {
9128
9074
  if (err) {
@@ -9135,13 +9081,13 @@ function createGenerationManager(params) {
9135
9081
  logger.log(`${sourceId} | generate: ${styles.success(relativePath)}`);
9136
9082
  if (file.executable) fs$1.chmod(file.path, 493, (chmodErr) => {
9137
9083
  if (chmodErr) {
9138
- const relativePath$1 = path.relative(process.cwd(), file.path);
9139
- logger.error(`Error setting executable permission on ${styles.bold(relativePath$1)}`);
9084
+ const relativePath = path.relative(process.cwd(), file.path);
9085
+ logger.error(`Error setting executable permission on ${styles.bold(relativePath)}`);
9140
9086
  logger.error(String(chmodErr));
9141
9087
  reject(chmodErr);
9142
- } else resolve$1();
9088
+ } else resolve();
9143
9089
  });
9144
- else resolve$1();
9090
+ else resolve();
9145
9091
  }
9146
9092
  });
9147
9093
  });
@@ -9160,7 +9106,7 @@ function createGenerationManager(params) {
9160
9106
  if (hasDependency(gen, "executor")) await processExecutors(gen);
9161
9107
  await aggregate(gen);
9162
9108
  }
9163
- async function runGenerators(gens, watch$1) {
9109
+ async function runGenerators(gens, watch) {
9164
9110
  const results = await Promise.allSettled(gens.map(async (gen) => {
9165
9111
  await withSpan(`generate.generator.${gen.id}`, async () => {
9166
9112
  try {
@@ -9168,11 +9114,11 @@ function createGenerationManager(params) {
9168
9114
  } catch (error) {
9169
9115
  logger.error(`Error processing generator ${styles.bold(gen.id)}`);
9170
9116
  logger.error(String(error));
9171
- if (!watch$1) throw error;
9117
+ if (!watch) throw error;
9172
9118
  }
9173
9119
  });
9174
9120
  }));
9175
- if (!watch$1) {
9121
+ if (!watch) {
9176
9122
  const failures = results.filter((r) => r.status === "rejected");
9177
9123
  if (failures.length > 0) throw new AggregateError(failures.map((f) => f.reason));
9178
9124
  }
@@ -9212,36 +9158,36 @@ function createGenerationManager(params) {
9212
9158
  processResolverNamespace,
9213
9159
  processExecutors,
9214
9160
  aggregate,
9215
- async generate(watch$1) {
9161
+ async generate(watch) {
9216
9162
  logger.newline();
9217
9163
  logger.log(`Generation for application: ${styles.highlight(application.config.name)}`);
9218
9164
  const app = application;
9219
9165
  await withSpan("generate.loadTailorDBTypes", async (span) => {
9220
9166
  span.setAttribute("generate.namespace_count", app.tailorDBServices.length);
9221
- for (const db$1 of app.tailorDBServices) {
9222
- const namespace = db$1.namespace;
9167
+ for (const db of app.tailorDBServices) {
9168
+ const namespace = db.namespace;
9223
9169
  await withSpan(`generate.loadTypes.${namespace}`, async () => {
9224
9170
  try {
9225
- await db$1.loadTypes();
9226
- await db$1.processNamespacePlugins();
9171
+ await db.loadTypes();
9172
+ await db.processNamespacePlugins();
9227
9173
  services.tailordb[namespace] = {
9228
- types: db$1.types,
9229
- sourceInfo: db$1.typeSourceInfo,
9230
- pluginAttachments: db$1.pluginAttachments
9174
+ types: db.types,
9175
+ sourceInfo: db.typeSourceInfo,
9176
+ pluginAttachments: db.pluginAttachments
9231
9177
  };
9232
9178
  } catch (error) {
9233
9179
  logger.error(`Error loading types for TailorDB service ${styles.bold(namespace)}`);
9234
9180
  logger.error(String(error));
9235
- if (!watch$1) throw error;
9181
+ if (!watch) throw error;
9236
9182
  }
9237
9183
  });
9238
9184
  }
9239
9185
  });
9240
9186
  const { pluginExecutorFiles, executorService } = await withSpan("generate.pluginFiles", async () => {
9241
- const pluginExecutorFiles$1 = generatePluginFilesIfNeeded(pluginManager, app.tailorDBServices, config.path);
9187
+ const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, app.tailorDBServices, config.path);
9242
9188
  return {
9243
- pluginExecutorFiles: pluginExecutorFiles$1,
9244
- executorService: app.executorService ?? (pluginExecutorFiles$1.length > 0 ? createExecutorService({ config: { files: [] } }) : void 0)
9189
+ pluginExecutorFiles,
9190
+ executorService: app.executorService ?? (pluginExecutorFiles.length > 0 ? createExecutorService({ config: { files: [] } }) : void 0)
9245
9191
  };
9246
9192
  });
9247
9193
  if (app.authService) await withSpan("generate.resolveAuthNamespaces", async () => app.authService.resolveNamespaces());
@@ -9250,7 +9196,7 @@ function createGenerationManager(params) {
9250
9196
  const hasOnTailorDBReady = generationPlugins.some((p) => p.onTailorDBReady != null);
9251
9197
  if (readyAfterTailorDB.length > 0 || hasOnTailorDBReady) {
9252
9198
  await withSpan("generate.onTailorDBReady", async () => {
9253
- await Promise.all([runGenerators(readyAfterTailorDB, watch$1), runPluginHook("onTailorDBReady", watch$1)]);
9199
+ await Promise.all([runGenerators(readyAfterTailorDB, watch), runPluginHook("onTailorDBReady", watch)]);
9254
9200
  });
9255
9201
  logger.newline();
9256
9202
  }
@@ -9267,7 +9213,7 @@ function createGenerationManager(params) {
9267
9213
  } catch (error) {
9268
9214
  logger.error(`Error loading resolvers for Resolver service ${styles.bold(namespace)}`);
9269
9215
  logger.error(String(error));
9270
- if (!watch$1) throw error;
9216
+ if (!watch) throw error;
9271
9217
  }
9272
9218
  });
9273
9219
  }
@@ -9276,7 +9222,7 @@ function createGenerationManager(params) {
9276
9222
  const hasOnResolverReady = generationPlugins.some((p) => p.onResolverReady != null);
9277
9223
  if (readyAfterResolvers.length > 0 || hasOnResolverReady) {
9278
9224
  await withSpan("generate.onResolversReady", async () => {
9279
- await Promise.all([runGenerators(readyAfterResolvers, watch$1), runPluginHook("onResolverReady", watch$1)]);
9225
+ await Promise.all([runGenerators(readyAfterResolvers, watch), runPluginHook("onResolverReady", watch)]);
9280
9226
  });
9281
9227
  logger.newline();
9282
9228
  }
@@ -9294,7 +9240,7 @@ function createGenerationManager(params) {
9294
9240
  const hasOnExecutorReady = generationPlugins.some((p) => p.onExecutorReady != null);
9295
9241
  if (readyAfterExecutors.length > 0 || hasOnExecutorReady) {
9296
9242
  await withSpan("generate.onExecutorsReady", async () => {
9297
- await Promise.all([runGenerators(readyAfterExecutors, watch$1), runPluginHook("onExecutorReady", watch$1)]);
9243
+ await Promise.all([runGenerators(readyAfterExecutors, watch), runPluginHook("onExecutorReady", watch)]);
9298
9244
  });
9299
9245
  logger.newline();
9300
9246
  }
@@ -9306,9 +9252,9 @@ function createGenerationManager(params) {
9306
9252
  });
9307
9253
  await watcher.addWatchGroup("Config", [config.path]);
9308
9254
  const app = application;
9309
- for (const db$1 of app.tailorDBServices) {
9310
- const dbNamespace = db$1.namespace;
9311
- await watcher?.addWatchGroup(`TailorDB/${dbNamespace}`, db$1.config.files);
9255
+ for (const db of app.tailorDBServices) {
9256
+ const dbNamespace = db.namespace;
9257
+ await watcher?.addWatchGroup(`TailorDB/${dbNamespace}`, db.config.files);
9312
9258
  }
9313
9259
  for (const resolverService of app.resolverServices) {
9314
9260
  const resolverNamespace = resolverService.namespace;
@@ -9326,8 +9272,8 @@ function createGenerationManager(params) {
9326
9272
  async function generate$1(options) {
9327
9273
  return withSpan("generate", async (rootSpan) => {
9328
9274
  const { config, generators, plugins } = await withSpan("generate.loadConfig", async () => loadConfig(options?.configPath));
9329
- const watch$1 = options?.watch ?? false;
9330
- rootSpan.setAttribute("generate.watch", watch$1);
9275
+ const watch = options?.watch ?? false;
9276
+ rootSpan.setAttribute("generate.watch", watch);
9331
9277
  rootSpan.setAttribute("generate.generators.count", generators.length);
9332
9278
  await withSpan("generate.generateUserTypes", async () => generateUserTypes({
9333
9279
  config,
@@ -9346,8 +9292,8 @@ async function generate$1(options) {
9346
9292
  generators,
9347
9293
  pluginManager
9348
9294
  });
9349
- await manager.generate(watch$1);
9350
- if (watch$1) await manager.watch();
9295
+ await manager.generate(watch);
9296
+ if (watch) await manager.watch();
9351
9297
  });
9352
9298
  }
9353
9299
 
@@ -9398,15 +9344,11 @@ async function listMachineUsers(options) {
9398
9344
  return [machineUsers, nextPageToken];
9399
9345
  })).map(machineUserInfo);
9400
9346
  }
9401
- const listCommand$5 = defineCommand({
9347
+ const listCommand$5 = defineAppCommand({
9402
9348
  name: "list",
9403
9349
  description: "List all machine users in the application.",
9404
- args: z.object({
9405
- ...commonArgs,
9406
- ...jsonArgs,
9407
- ...deploymentArgs
9408
- }).strict(),
9409
- run: withCommonArgs(async (args) => {
9350
+ args: z.object({ ...deploymentArgs }).strict(),
9351
+ run: async (args) => {
9410
9352
  const machineUsers = await listMachineUsers({
9411
9353
  workspaceId: args["workspace-id"],
9412
9354
  profile: args.profile,
@@ -9416,7 +9358,7 @@ const listCommand$5 = defineCommand({
9416
9358
  createdAt: null,
9417
9359
  updatedAt: null
9418
9360
  } });
9419
- })
9361
+ }
9420
9362
  });
9421
9363
 
9422
9364
  //#endregion
@@ -9456,19 +9398,17 @@ async function getMachineUserToken(options) {
9456
9398
  expiresAt: expiresAt.toISOString()
9457
9399
  };
9458
9400
  }
9459
- const tokenCommand = defineCommand({
9401
+ const tokenCommand = defineAppCommand({
9460
9402
  name: "token",
9461
9403
  description: "Get an access token for a machine user.",
9462
9404
  args: z.object({
9463
- ...commonArgs,
9464
- ...jsonArgs,
9465
9405
  ...deploymentArgs,
9466
9406
  name: arg(z.string(), {
9467
9407
  positional: true,
9468
9408
  description: "Machine user name"
9469
9409
  })
9470
9410
  }).strict(),
9471
- run: withCommonArgs(async (args) => {
9411
+ run: async (args) => {
9472
9412
  const token = await getMachineUserToken({
9473
9413
  name: args.name,
9474
9414
  workspaceId: args["workspace-id"],
@@ -9481,7 +9421,7 @@ const tokenCommand = defineCommand({
9481
9421
  expires_at: token.expiresAt
9482
9422
  };
9483
9423
  logger.out(tokenInfo);
9484
- })
9424
+ }
9485
9425
  });
9486
9426
 
9487
9427
  //#endregion
@@ -9559,19 +9499,17 @@ async function getOAuth2Client(options) {
9559
9499
  throw error;
9560
9500
  }
9561
9501
  }
9562
- const getCommand$1 = defineCommand({
9502
+ const getCommand$1 = defineAppCommand({
9563
9503
  name: "get",
9564
9504
  description: "Get OAuth2 client credentials (including client secret).",
9565
9505
  args: z.object({
9566
- ...commonArgs,
9567
- ...jsonArgs,
9568
9506
  ...deploymentArgs,
9569
9507
  name: arg(z.string(), {
9570
9508
  positional: true,
9571
9509
  description: "OAuth2 client name"
9572
9510
  })
9573
9511
  }).strict(),
9574
- run: withCommonArgs(async (args) => {
9512
+ run: async (args) => {
9575
9513
  const credentials = await getOAuth2Client({
9576
9514
  name: args.name,
9577
9515
  workspaceId: args["workspace-id"],
@@ -9579,7 +9517,7 @@ const getCommand$1 = defineCommand({
9579
9517
  configPath: args.config
9580
9518
  });
9581
9519
  logger.out(credentials);
9582
- })
9520
+ }
9583
9521
  });
9584
9522
 
9585
9523
  //#endregion
@@ -9614,22 +9552,18 @@ async function listOAuth2Clients(options) {
9614
9552
  return [oauth2Clients, nextPageToken];
9615
9553
  })).map(toOAuth2ClientInfo);
9616
9554
  }
9617
- const listCommand$4 = defineCommand({
9555
+ const listCommand$4 = defineAppCommand({
9618
9556
  name: "list",
9619
9557
  description: "List all OAuth2 clients in the application.",
9620
- args: z.object({
9621
- ...commonArgs,
9622
- ...jsonArgs,
9623
- ...deploymentArgs
9624
- }).strict(),
9625
- run: withCommonArgs(async (args) => {
9558
+ args: z.object({ ...deploymentArgs }).strict(),
9559
+ run: async (args) => {
9626
9560
  const oauth2Clients = await listOAuth2Clients({
9627
9561
  workspaceId: args["workspace-id"],
9628
9562
  profile: args.profile,
9629
9563
  configPath: args.config
9630
9564
  });
9631
9565
  logger.out(oauth2Clients);
9632
- })
9566
+ }
9633
9567
  });
9634
9568
 
9635
9569
  //#endregion
@@ -9695,15 +9629,14 @@ async function remove(options) {
9695
9629
  const { client, workspaceId, application, config } = await loadOptions$10(options);
9696
9630
  await execRemove(client, workspaceId, application, config);
9697
9631
  }
9698
- const removeCommand$1 = defineCommand({
9632
+ const removeCommand$1 = defineAppCommand({
9699
9633
  name: "remove",
9700
9634
  description: "Remove all resources managed by the application from the workspace.",
9701
9635
  args: z.object({
9702
- ...commonArgs,
9703
9636
  ...deploymentArgs,
9704
9637
  ...confirmationArgs
9705
9638
  }).strict(),
9706
- run: withCommonArgs(async (args) => {
9639
+ run: async (args) => {
9707
9640
  const { client, workspaceId, application, config } = await loadOptions$10({
9708
9641
  workspaceId: args["workspace-id"],
9709
9642
  profile: args.profile,
@@ -9723,7 +9656,7 @@ const removeCommand$1 = defineCommand({
9723
9656
  } else logger.success("Removing all resources (--yes flag specified)...");
9724
9657
  });
9725
9658
  logger.success(`Successfully removed all resources managed by "${application.name}".`);
9726
- })
9659
+ }
9727
9660
  });
9728
9661
 
9729
9662
  //#endregion
@@ -9760,31 +9693,27 @@ async function show(options) {
9760
9693
  workspaceId,
9761
9694
  applicationName: config.name
9762
9695
  })]);
9763
- const { name, ...appInfo$1 } = applicationInfo(resp.application);
9696
+ const { name, ...appInfo } = applicationInfo(resp.application);
9764
9697
  return {
9765
9698
  name,
9766
9699
  workspaceId,
9767
9700
  workspaceName: workspaceResp.workspace?.name ?? "",
9768
9701
  workspaceRegion: workspaceResp.workspace?.region ?? "",
9769
- ...appInfo$1
9702
+ ...appInfo
9770
9703
  };
9771
9704
  }
9772
- const showCommand = defineCommand({
9705
+ const showCommand = defineAppCommand({
9773
9706
  name: "show",
9774
9707
  description: "Show information about the deployed application.",
9775
- args: z.object({
9776
- ...commonArgs,
9777
- ...jsonArgs,
9778
- ...deploymentArgs
9779
- }).strict(),
9780
- run: withCommonArgs(async (args) => {
9781
- const appInfo$1 = await show({
9708
+ args: z.object({ ...deploymentArgs }).strict(),
9709
+ run: async (args) => {
9710
+ const appInfo = await show({
9782
9711
  workspaceId: args["workspace-id"],
9783
9712
  profile: args.profile,
9784
9713
  configPath: args.config
9785
9714
  });
9786
- logger.out(appInfo$1);
9787
- })
9715
+ logger.out(appInfo);
9716
+ }
9788
9717
  });
9789
9718
 
9790
9719
  //#endregion
@@ -9835,7 +9764,7 @@ function parseEditorCommand(editor) {
9835
9764
  */
9836
9765
  async function openInEditor(filePath, editor = getEditorCommand()) {
9837
9766
  const { command, args } = parseEditorCommand(editor);
9838
- await new Promise((resolve$1, reject) => {
9767
+ await new Promise((resolve, reject) => {
9839
9768
  const child = spawn(command, [...args, filePath], {
9840
9769
  stdio: "inherit",
9841
9770
  detached: false
@@ -9843,7 +9772,7 @@ async function openInEditor(filePath, editor = getEditorCommand()) {
9843
9772
  child.once("error", (error) => reject(error));
9844
9773
  child.once("close", (code) => {
9845
9774
  if (code == null || code === 0) {
9846
- resolve$1();
9775
+ resolve();
9847
9776
  return;
9848
9777
  }
9849
9778
  reject(/* @__PURE__ */ new Error(`Editor exited with code ${code}.`));
@@ -10371,8 +10300,8 @@ async function generate(options) {
10371
10300
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
10372
10301
  let pluginManager;
10373
10302
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
10374
- const { defineApplication: defineApplication$1 } = await import("./application-B4ORumjE.mjs");
10375
- const application = defineApplication$1({
10303
+ const { defineApplication } = await import("./application-C0lXqKBr.mjs");
10304
+ const application = defineApplication({
10376
10305
  config,
10377
10306
  pluginManager
10378
10307
  });
@@ -10403,7 +10332,7 @@ async function generate(options) {
10403
10332
  * @returns {Promise<void>} Promise that resolves when snapshot is generated
10404
10333
  */
10405
10334
  async function generateInitialSnapshot(snapshot, migrationsDir) {
10406
- const result = await generateSchemaFile(snapshot, migrationsDir, INITIAL_SCHEMA_NUMBER);
10335
+ const result = await generateSchemaFile(snapshot, migrationsDir, 0);
10407
10336
  logger.success(`Generated initial schema snapshot`);
10408
10337
  logger.info(` File: ${result.filePath}`);
10409
10338
  logger.info(` Types: ${Object.keys(snapshot.types).length}`);
@@ -10489,11 +10418,10 @@ async function generateDiffFromSnapshot(previousSnapshot, currentSnapshot, migra
10489
10418
  /**
10490
10419
  * CLI command definition for generate
10491
10420
  */
10492
- const generateCommand = defineCommand({
10421
+ const generateCommand = defineAppCommand({
10493
10422
  name: "generate",
10494
10423
  description: "Generate migration files by detecting schema differences between current local types and the previous migration snapshot.",
10495
10424
  args: z.object({
10496
- ...commonArgs,
10497
10425
  ...confirmationArgs,
10498
10426
  ...configArg,
10499
10427
  name: arg(z.string().optional(), {
@@ -10502,14 +10430,14 @@ const generateCommand = defineCommand({
10502
10430
  }),
10503
10431
  init: arg(z.boolean().default(false), { description: "Delete existing migrations and start fresh" })
10504
10432
  }).strict(),
10505
- run: withCommonArgs(async (args) => {
10433
+ run: async (args) => {
10506
10434
  await generate({
10507
10435
  configPath: args.config,
10508
10436
  name: args.name,
10509
10437
  yes: args.yes,
10510
10438
  init: args.init
10511
10439
  });
10512
- })
10440
+ }
10513
10441
  });
10514
10442
 
10515
10443
  //#endregion
@@ -10683,11 +10611,10 @@ async function $truncate(options) {
10683
10611
  }
10684
10612
  }
10685
10613
  }
10686
- const truncateCommand = defineCommand({
10614
+ const truncateCommand = defineAppCommand({
10687
10615
  name: "truncate",
10688
10616
  description: "Truncate (delete all records from) TailorDB tables.",
10689
10617
  args: z.object({
10690
- ...commonArgs,
10691
10618
  ...deploymentArgs,
10692
10619
  ...confirmationArgs,
10693
10620
  types: arg(z.string().array().optional(), {
@@ -10703,7 +10630,7 @@ const truncateCommand = defineCommand({
10703
10630
  description: "Truncate all tables in specified namespace"
10704
10631
  })
10705
10632
  }).strict(),
10706
- run: withCommonArgs(async (args) => {
10633
+ run: async (args) => {
10707
10634
  const types = args.types && args.types.length > 0 ? args.types : void 0;
10708
10635
  await $truncate({
10709
10636
  workspaceId: args["workspace-id"],
@@ -10714,7 +10641,7 @@ const truncateCommand = defineCommand({
10714
10641
  types,
10715
10642
  yes: args.yes
10716
10643
  });
10717
- })
10644
+ }
10718
10645
  });
10719
10646
 
10720
10647
  //#endregion
@@ -10742,15 +10669,11 @@ async function listWorkflows(options) {
10742
10669
  return [workflows, nextPageToken];
10743
10670
  })).map(toWorkflowListInfo);
10744
10671
  }
10745
- const listCommand$3 = defineCommand({
10672
+ const listCommand$3 = defineAppCommand({
10746
10673
  name: "list",
10747
10674
  description: "List all workflows in the workspace.",
10748
- args: z.object({
10749
- ...commonArgs,
10750
- ...jsonArgs,
10751
- ...workspaceArgs
10752
- }).strict(),
10753
- run: withCommonArgs(async (args) => {
10675
+ args: z.object({ ...workspaceArgs }).strict(),
10676
+ run: async (args) => {
10754
10677
  const workflows = await listWorkflows({
10755
10678
  workspaceId: args["workspace-id"],
10756
10679
  profile: args.profile
@@ -10760,7 +10683,7 @@ const listCommand$3 = defineCommand({
10760
10683
  return;
10761
10684
  }
10762
10685
  logger.out(workflows);
10763
- })
10686
+ }
10764
10687
  });
10765
10688
 
10766
10689
  //#endregion
@@ -10802,12 +10725,10 @@ async function resumeWorkflow(options) {
10802
10725
  throw error;
10803
10726
  }
10804
10727
  }
10805
- const resumeCommand = defineCommand({
10728
+ const resumeCommand = defineAppCommand({
10806
10729
  name: "resume",
10807
10730
  description: "Resume a failed or pending workflow execution.",
10808
10731
  args: z.object({
10809
- ...commonArgs,
10810
- ...jsonArgs,
10811
10732
  ...workspaceArgs,
10812
10733
  executionId: arg(z.string(), {
10813
10734
  positional: true,
@@ -10815,7 +10736,7 @@ const resumeCommand = defineCommand({
10815
10736
  }),
10816
10737
  ...waitArgs
10817
10738
  }).strict(),
10818
- run: withCommonArgs(async (args) => {
10739
+ run: async (args) => {
10819
10740
  const { executionId, wait } = await resumeWorkflow({
10820
10741
  executionId: args.executionId,
10821
10742
  workspaceId: args["workspace-id"],
@@ -10835,7 +10756,7 @@ const resumeCommand = defineCommand({
10835
10756
  printExecutionWithLogs(execution);
10836
10757
  } else logger.out(result);
10837
10758
  } else logger.out({ executionId });
10838
- })
10759
+ }
10839
10760
  });
10840
10761
 
10841
10762
  //#endregion
@@ -10906,19 +10827,17 @@ async function getAppHealth(options) {
10906
10827
  applicationName: name
10907
10828
  }));
10908
10829
  }
10909
- const healthCommand = defineCommand({
10830
+ const healthCommand = defineAppCommand({
10910
10831
  name: "health",
10911
10832
  description: "Check application schema health",
10912
10833
  args: z.object({
10913
- ...commonArgs,
10914
- ...jsonArgs,
10915
10834
  ...workspaceArgs,
10916
10835
  name: arg(z.string(), {
10917
10836
  description: "Application name",
10918
10837
  alias: "n"
10919
10838
  })
10920
10839
  }).strict(),
10921
- run: withCommonArgs(async (args) => {
10840
+ run: async (args) => {
10922
10841
  const health = await getAppHealth({
10923
10842
  workspaceId: args["workspace-id"],
10924
10843
  profile: args.profile,
@@ -10930,7 +10849,7 @@ const healthCommand = defineCommand({
10930
10849
  lastAttemptAt: humanizeRelativeTime(health.lastAttemptAt)
10931
10850
  };
10932
10851
  logger.out(formattedHealth);
10933
- })
10852
+ }
10934
10853
  });
10935
10854
 
10936
10855
  //#endregion
@@ -10979,19 +10898,17 @@ async function listApps(options) {
10979
10898
  }
10980
10899
  return results;
10981
10900
  }
10982
- const listCommand$2 = defineCommand({
10901
+ const listCommand$2 = defineAppCommand({
10983
10902
  name: "list",
10984
10903
  description: "List applications in a workspace",
10985
10904
  args: z.object({
10986
- ...commonArgs,
10987
- ...jsonArgs,
10988
10905
  ...workspaceArgs,
10989
10906
  limit: arg(positiveIntArg.optional(), {
10990
10907
  alias: "l",
10991
10908
  description: "Maximum number of applications to list"
10992
10909
  })
10993
10910
  }).strict(),
10994
- run: withCommonArgs(async (args) => {
10911
+ run: async (args) => {
10995
10912
  const apps = await listApps({
10996
10913
  workspaceId: args["workspace-id"],
10997
10914
  profile: args.profile,
@@ -11002,7 +10919,7 @@ const listCommand$2 = defineCommand({
11002
10919
  createdAt: humanizeRelativeTime(createdAt)
11003
10920
  }));
11004
10921
  logger.out(formattedApps);
11005
- })
10922
+ }
11006
10923
  });
11007
10924
 
11008
10925
  //#endregion
@@ -11054,22 +10971,18 @@ async function createWorkspace(options) {
11054
10971
  const validated = result.data;
11055
10972
  const client = await initOperatorClient(await loadAccessToken());
11056
10973
  await validateRegion(validated.region, client);
11057
- const organizationId = loadOrganizationId(validated.organizationId);
11058
- const folderId = loadFolderId(validated.folderId);
11059
10974
  return workspaceInfo((await client.createWorkspace({
11060
10975
  workspaceName: validated.name,
11061
10976
  workspaceRegion: validated.region,
11062
10977
  deleteProtection: validated.deleteProtection ?? false,
11063
- organizationId,
11064
- folderId
10978
+ organizationId: validated.organizationId,
10979
+ folderId: validated.folderId
11065
10980
  })).workspace);
11066
10981
  }
11067
- const createCommand = defineCommand({
10982
+ const createCommand = defineAppCommand({
11068
10983
  name: "create",
11069
10984
  description: "Create a new Tailor Platform workspace.",
11070
10985
  args: z.object({
11071
- ...commonArgs,
11072
- ...jsonArgs,
11073
10986
  name: arg(z.string(), {
11074
10987
  alias: "n",
11075
10988
  description: "Workspace name"
@@ -11084,11 +10997,13 @@ const createCommand = defineCommand({
11084
10997
  }),
11085
10998
  "organization-id": arg(z.string().optional(), {
11086
10999
  alias: "o",
11087
- description: "Organization ID to workspace associate with"
11000
+ description: "Organization ID to workspace associate with",
11001
+ env: "TAILOR_PLATFORM_ORGANIZATION_ID"
11088
11002
  }),
11089
11003
  "folder-id": arg(z.string().optional(), {
11090
11004
  alias: "f",
11091
- description: "Folder ID to workspace associate with"
11005
+ description: "Folder ID to workspace associate with",
11006
+ env: "TAILOR_PLATFORM_FOLDER_ID"
11092
11007
  }),
11093
11008
  "profile-name": arg(z.string().optional(), {
11094
11009
  alias: "p",
@@ -11096,7 +11011,7 @@ const createCommand = defineCommand({
11096
11011
  }),
11097
11012
  "profile-user": arg(z.string().optional(), { description: "User email for the profile (defaults to current user)" })
11098
11013
  }).strict(),
11099
- run: withCommonArgs(async (args) => {
11014
+ run: async (args) => {
11100
11015
  const workspace = await createWorkspace({
11101
11016
  name: args.name,
11102
11017
  region: args.region,
@@ -11137,7 +11052,7 @@ const createCommand = defineCommand({
11137
11052
  logger.out("Profile:");
11138
11053
  logger.out(profileInfo);
11139
11054
  }
11140
- })
11055
+ }
11141
11056
  });
11142
11057
 
11143
11058
  //#endregion
@@ -11160,18 +11075,17 @@ async function deleteWorkspace(options) {
11160
11075
  const { client, workspaceId } = await loadOptions$7(options);
11161
11076
  await client.deleteWorkspace({ workspaceId });
11162
11077
  }
11163
- const deleteCommand = defineCommand({
11078
+ const deleteCommand = defineAppCommand({
11164
11079
  name: "delete",
11165
11080
  description: "Delete a Tailor Platform workspace.",
11166
11081
  args: z.object({
11167
- ...commonArgs,
11168
11082
  "workspace-id": arg(z.string(), {
11169
11083
  alias: "w",
11170
11084
  description: "Workspace ID"
11171
11085
  }),
11172
11086
  ...confirmationArgs
11173
11087
  }).strict(),
11174
- run: withCommonArgs(async (args) => {
11088
+ run: async (args) => {
11175
11089
  const { client, workspaceId } = await loadOptions$7({ workspaceId: args["workspace-id"] });
11176
11090
  let workspace;
11177
11091
  try {
@@ -11194,7 +11108,7 @@ const deleteCommand = defineCommand({
11194
11108
  }
11195
11109
  if (profilesToDelete.length > 0) logger.success(`Workspace "${args["workspace-id"]}" and ${profilesToDelete.length} associated profile(s) deleted successfully.`);
11196
11110
  else logger.success(`Workspace "${args["workspace-id"]}" deleted successfully.`);
11197
- })
11111
+ }
11198
11112
  });
11199
11113
 
11200
11114
  //#endregion
@@ -11225,15 +11139,11 @@ async function getWorkspace(options) {
11225
11139
  if (!response.workspace) throw new Error(`Workspace "${workspaceId}" not found.`);
11226
11140
  return workspaceDetails(response.workspace);
11227
11141
  }
11228
- const getCommand = defineCommand({
11142
+ const getCommand = defineAppCommand({
11229
11143
  name: "get",
11230
11144
  description: "Show detailed information about a workspace",
11231
- args: z.object({
11232
- ...commonArgs,
11233
- ...jsonArgs,
11234
- ...workspaceArgs
11235
- }).strict(),
11236
- run: withCommonArgs(async (args) => {
11145
+ args: z.object({ ...workspaceArgs }).strict(),
11146
+ run: async (args) => {
11237
11147
  const workspace = await getWorkspace({
11238
11148
  workspaceId: args["workspace-id"],
11239
11149
  profile: args.profile
@@ -11244,7 +11154,7 @@ const getCommand = defineCommand({
11244
11154
  updatedAt: humanizeRelativeTime(workspace.updatedAt)
11245
11155
  };
11246
11156
  logger.out(formattedWorkspace);
11247
- })
11157
+ }
11248
11158
  });
11249
11159
 
11250
11160
  //#endregion
@@ -11276,21 +11186,17 @@ async function listWorkspaces(options) {
11276
11186
  }
11277
11187
  return results;
11278
11188
  }
11279
- const listCommand$1 = defineCommand({
11189
+ const listCommand$1 = defineAppCommand({
11280
11190
  name: "list",
11281
11191
  description: "List all Tailor Platform workspaces.",
11282
- args: z.object({
11283
- ...commonArgs,
11284
- ...jsonArgs,
11285
- limit: arg(positiveIntArg.optional(), {
11286
- alias: "l",
11287
- description: "Maximum number of workspaces to list"
11288
- })
11289
- }).strict(),
11290
- run: withCommonArgs(async (args) => {
11192
+ args: z.object({ limit: arg(positiveIntArg.optional(), {
11193
+ alias: "l",
11194
+ description: "Maximum number of workspaces to list"
11195
+ }) }).strict(),
11196
+ run: async (args) => {
11291
11197
  const workspaces = await listWorkspaces({ limit: args.limit });
11292
11198
  logger.out(workspaces, { display: { updatedAt: null } });
11293
- })
11199
+ }
11294
11200
  });
11295
11201
 
11296
11202
  //#endregion
@@ -11313,18 +11219,17 @@ async function restoreWorkspace(options) {
11313
11219
  const { client, workspaceId } = await loadOptions$5(options);
11314
11220
  await client.restoreWorkspace({ workspaceId });
11315
11221
  }
11316
- const restoreCommand = defineCommand({
11222
+ const restoreCommand = defineAppCommand({
11317
11223
  name: "restore",
11318
11224
  description: "Restore a deleted workspace",
11319
11225
  args: z.object({
11320
- ...commonArgs,
11321
11226
  "workspace-id": arg(z.string(), {
11322
11227
  alias: "w",
11323
11228
  description: "Workspace ID"
11324
11229
  }),
11325
11230
  ...confirmationArgs
11326
11231
  }).strict(),
11327
- run: withCommonArgs(async (args) => {
11232
+ run: async (args) => {
11328
11233
  const { client, workspaceId } = await loadOptions$5({ workspaceId: args["workspace-id"] });
11329
11234
  if (!args.yes) {
11330
11235
  if (await logger.prompt(`Are you sure you want to restore workspace "${workspaceId}"? (yes/no):`, { type: "text" }) !== "yes") {
@@ -11334,7 +11239,7 @@ const restoreCommand = defineCommand({
11334
11239
  }
11335
11240
  await client.restoreWorkspace({ workspaceId });
11336
11241
  logger.success(`Workspace "${workspaceId}" restored successfully.`);
11337
- })
11242
+ }
11338
11243
  });
11339
11244
 
11340
11245
  //#endregion
@@ -11402,11 +11307,10 @@ async function inviteUser(options) {
11402
11307
  role
11403
11308
  });
11404
11309
  }
11405
- const inviteCommand = defineCommand({
11310
+ const inviteCommand = defineAppCommand({
11406
11311
  name: "invite",
11407
11312
  description: "Invite a user to a workspace",
11408
11313
  args: z.object({
11409
- ...commonArgs,
11410
11314
  ...workspaceArgs,
11411
11315
  email: arg(z.email(), { description: "Email address of the user to invite" }),
11412
11316
  role: arg(z.enum(validRoles), {
@@ -11414,7 +11318,7 @@ const inviteCommand = defineCommand({
11414
11318
  alias: "r"
11415
11319
  })
11416
11320
  }).strict(),
11417
- run: withCommonArgs(async (args) => {
11321
+ run: async (args) => {
11418
11322
  await inviteUser({
11419
11323
  workspaceId: args["workspace-id"],
11420
11324
  profile: args.profile,
@@ -11422,7 +11326,7 @@ const inviteCommand = defineCommand({
11422
11326
  role: args.role
11423
11327
  });
11424
11328
  logger.success(`User "${args.email}" invited successfully with role "${args.role}".`);
11425
- })
11329
+ }
11426
11330
  });
11427
11331
 
11428
11332
  //#endregion
@@ -11471,26 +11375,24 @@ async function listUsers(options) {
11471
11375
  }
11472
11376
  return results;
11473
11377
  }
11474
- const listCommand = defineCommand({
11378
+ const listCommand = defineAppCommand({
11475
11379
  name: "list",
11476
11380
  description: "List users in a workspace",
11477
11381
  args: z.object({
11478
- ...commonArgs,
11479
- ...jsonArgs,
11480
11382
  ...workspaceArgs,
11481
11383
  limit: arg(positiveIntArg.optional(), {
11482
11384
  alias: "l",
11483
11385
  description: "Maximum number of users to list"
11484
11386
  })
11485
11387
  }).strict(),
11486
- run: withCommonArgs(async (args) => {
11388
+ run: async (args) => {
11487
11389
  const users = await listUsers({
11488
11390
  workspaceId: args["workspace-id"],
11489
11391
  profile: args.profile,
11490
11392
  limit: args.limit
11491
11393
  });
11492
11394
  logger.out(users);
11493
- })
11395
+ }
11494
11396
  });
11495
11397
 
11496
11398
  //#endregion
@@ -11524,16 +11426,15 @@ async function removeUser(options) {
11524
11426
  email
11525
11427
  });
11526
11428
  }
11527
- const removeCommand = defineCommand({
11429
+ const removeCommand = defineAppCommand({
11528
11430
  name: "remove",
11529
11431
  description: "Remove a user from a workspace",
11530
11432
  args: z.object({
11531
- ...commonArgs,
11532
11433
  ...workspaceArgs,
11533
11434
  email: arg(z.email(), { description: "Email address of the user to remove" }),
11534
11435
  ...confirmationArgs
11535
11436
  }).strict(),
11536
- run: withCommonArgs(async (args) => {
11437
+ run: async (args) => {
11537
11438
  if (!args.yes) {
11538
11439
  if (await logger.prompt(`Are you sure you want to remove user "${args.email}" from the workspace? (yes/no):`, { type: "text" }) !== "yes") {
11539
11440
  logger.info("User removal cancelled.");
@@ -11546,7 +11447,7 @@ const removeCommand = defineCommand({
11546
11447
  email: args.email
11547
11448
  });
11548
11449
  logger.success(`User "${args.email}" removed from workspace.`);
11549
- })
11450
+ }
11550
11451
  });
11551
11452
 
11552
11453
  //#endregion
@@ -11583,11 +11484,10 @@ async function updateUser(options) {
11583
11484
  role
11584
11485
  });
11585
11486
  }
11586
- const updateCommand = defineCommand({
11487
+ const updateCommand = defineAppCommand({
11587
11488
  name: "update",
11588
11489
  description: "Update a user's role in a workspace",
11589
11490
  args: z.object({
11590
- ...commonArgs,
11591
11491
  ...workspaceArgs,
11592
11492
  email: arg(z.email(), { description: "Email address of the user to update" }),
11593
11493
  role: arg(z.enum(validRoles), {
@@ -11595,7 +11495,7 @@ const updateCommand = defineCommand({
11595
11495
  alias: "r"
11596
11496
  })
11597
11497
  }).strict(),
11598
- run: withCommonArgs(async (args) => {
11498
+ run: async (args) => {
11599
11499
  await updateUser({
11600
11500
  workspaceId: args["workspace-id"],
11601
11501
  profile: args.profile,
@@ -11603,7 +11503,7 @@ const updateCommand = defineCommand({
11603
11503
  role: args.role
11604
11504
  });
11605
11505
  logger.success(`User "${args.email}" updated to role "${args.role}".`);
11606
- })
11506
+ }
11607
11507
  });
11608
11508
 
11609
11509
  //#endregion
@@ -11702,7 +11602,7 @@ async function bundleQueryScript(engine) {
11702
11602
  format: "esm",
11703
11603
  sourcemap: false,
11704
11604
  minify: false,
11705
- inlineDynamicImports: true,
11605
+ codeSplitting: false,
11706
11606
  globals: { tailordb: "tailordb" }
11707
11607
  },
11708
11608
  external: engine === "sql" ? ["tailordb"] : [],
@@ -11718,6 +11618,44 @@ async function bundleQueryScript(engine) {
11718
11618
  return fs$1.readFileSync(outputPath, "utf-8");
11719
11619
  }
11720
11620
 
11621
+ //#endregion
11622
+ //#region src/cli/shared/errors.ts
11623
+ /**
11624
+ * Format CLI error for output
11625
+ * @param error - CLIError instance to format
11626
+ * @returns Formatted error message
11627
+ */
11628
+ function formatError(error) {
11629
+ const parts = [chalk.red(`Error${error.code ? ` [${error.code}]` : ""}: ${error.message}`)];
11630
+ if (error.details) parts.push(`\n ${chalk.gray("Details:")} ${error.details}`);
11631
+ if (error.suggestion) parts.push(`\n ${chalk.cyan("Suggestion:")} ${error.suggestion}`);
11632
+ if (error.command) parts.push(`\n ${chalk.gray("Help:")} Run \`tailor-sdk ${error.command} --help\` for usage information.`);
11633
+ return parts.join("");
11634
+ }
11635
+ /**
11636
+ * Create a CLI error with formatted output
11637
+ * @param options - Options to construct a CLIError
11638
+ * @returns Constructed CLIError instance
11639
+ */
11640
+ function createCLIError(options) {
11641
+ const error = new Error(options.message);
11642
+ error.name = "CLIError";
11643
+ error.code = options.code;
11644
+ error.details = options.details;
11645
+ error.suggestion = options.suggestion;
11646
+ error.command = options.command;
11647
+ error.format = () => formatError(error);
11648
+ return error;
11649
+ }
11650
+ /**
11651
+ * Type guard to check if an error is a CLIError
11652
+ * @param error - Error to check
11653
+ * @returns True if the error is a CLIError
11654
+ */
11655
+ function isCLIError(error) {
11656
+ return error instanceof Error && error.name === "CLIError";
11657
+ }
11658
+
11721
11659
  //#endregion
11722
11660
  //#region src/cli/query/errors.ts
11723
11661
  function toErrorMessage(error) {
@@ -11871,10 +11809,10 @@ function isSqlInputComplete(input) {
11871
11809
  * @param query - SQL query
11872
11810
  * @returns Type names referenced by query
11873
11811
  */
11874
- function extractTypeNamesFromSql(query$1) {
11812
+ function extractTypeNamesFromSql(query) {
11875
11813
  let statements;
11876
11814
  try {
11877
- statements = parse(query$1);
11815
+ statements = parse(query);
11878
11816
  } catch (error) {
11879
11817
  const message = error instanceof Error ? error.message : String(error);
11880
11818
  throw new Error(`SQL parse error: ${message}\nIf your table name is a reserved keyword (e.g. User), wrap it in double quotes: SELECT * FROM "User"`);
@@ -11909,9 +11847,9 @@ function collectAliasMap(fromClauses) {
11909
11847
  * @param query - SQL query
11910
11848
  * @returns Column slots if wildcards are present, null otherwise
11911
11849
  */
11912
- function extractColumnTemplate(query$1) {
11850
+ function extractColumnTemplate(query) {
11913
11851
  try {
11914
- const statements = parse(query$1);
11852
+ const statements = parse(query);
11915
11853
  for (const statement of statements) {
11916
11854
  if (statement.type !== "select" || !statement.columns) continue;
11917
11855
  const aliasMap = collectAliasMap(statement.from ?? []);
@@ -11981,10 +11919,10 @@ const queryBaseOptionsSchema = z.object({
11981
11919
  machineUser: z.string()
11982
11920
  });
11983
11921
  const queryOptionsSchema = queryBaseOptionsSchema.extend({ query: z.string() });
11984
- async function getNamespaceFromSqlQuery(workspaceId, query$1, client, namespaces) {
11922
+ async function getNamespaceFromSqlQuery(workspaceId, query, client, namespaces) {
11985
11923
  if (namespaces.length === 0) throw new Error("No namespaces found in configuration.");
11986
11924
  if (namespaces.length === 1) return namespaces[0];
11987
- const typeNames = extractTypeNamesFromSql(query$1);
11925
+ const typeNames = extractTypeNamesFromSql(query);
11988
11926
  if (typeNames.length === 0) throw new Error(`Could not infer namespace from query. Detected namespaces: ${namespaces.join(", ")}.`);
11989
11927
  const typeNamespaceMap = await resolveTypeNamespaces({
11990
11928
  workspaceId,
@@ -12278,9 +12216,9 @@ async function runRepl(options) {
12278
12216
  if (statement.length === 0) continue;
12279
12217
  try {
12280
12218
  if (options.engine === "sql") {
12281
- const result$1 = await execute(statement);
12282
- if (result$1.engine !== "sql") throw new Error(`Expected sql engine result but got: ${result$1.engine}`);
12283
- printSqlResult(result$1, { json: options.json });
12219
+ const result = await execute(statement);
12220
+ if (result.engine !== "sql") throw new Error(`Expected sql engine result but got: ${result.engine}`);
12221
+ printSqlResult(result, { json: options.json });
12284
12222
  continue;
12285
12223
  }
12286
12224
  const result = await execute(statement);
@@ -12346,9 +12284,9 @@ async function queryGql(options) {
12346
12284
  if (result.engine !== "gql") throw new Error(`Expected gql engine result but got: ${result.engine}`);
12347
12285
  return result;
12348
12286
  }
12349
- async function reorderSqlColumns(result, config, namespace, sqlQuery$1) {
12287
+ async function reorderSqlColumns(result, config, namespace, sqlQuery) {
12350
12288
  if (!isSQLExecutionResult(result.result) || result.result.rows.length === 0) return result;
12351
- const template = extractColumnTemplate(sqlQuery$1);
12289
+ const template = extractColumnTemplate(sqlQuery);
12352
12290
  if (!template) return result;
12353
12291
  try {
12354
12292
  const expectedOrder = buildExpectedColumnOrder(template, await loadTypeFieldOrder(config, namespace));
@@ -12391,12 +12329,10 @@ function reorderRowByTemplate(row, expectedOrder) {
12391
12329
  for (const key of rowKeys) ordered[key] = row[key];
12392
12330
  return ordered;
12393
12331
  }
12394
- const queryCommand = defineCommand({
12332
+ const queryCommand = defineAppCommand({
12395
12333
  name: "query",
12396
12334
  description: "Run SQL/GraphQL query.",
12397
12335
  args: z.object({
12398
- ...commonArgs,
12399
- ...jsonArgs,
12400
12336
  ...deploymentArgs,
12401
12337
  engine: arg(queryEngineSchema, { description: "Query engine (sql or gql)" }),
12402
12338
  query: arg(z.string().optional(), {
@@ -12429,7 +12365,7 @@ const queryCommand = defineCommand({
12429
12365
  message: "Pass only one of --edit, -q/--query, or -f/--file."
12430
12366
  });
12431
12367
  }).strict(),
12432
- run: withCommonArgs(async (args) => {
12368
+ run: async (args) => {
12433
12369
  const mode = await resolveQueryCommandInput({
12434
12370
  query: args.query,
12435
12371
  file: args.file,
@@ -12466,7 +12402,7 @@ const queryCommand = defineCommand({
12466
12402
  ...sharedOptions,
12467
12403
  query: directQuery
12468
12404
  }), { json: args.json });
12469
- })
12405
+ }
12470
12406
  });
12471
12407
  function isSQLExecutionResult(value) {
12472
12408
  if (!value || typeof value !== "object") return false;
@@ -12495,13 +12431,13 @@ function printSingleSqlResult(execResult, options = {}) {
12495
12431
  logger.out(execResult.rows, { showNull: true });
12496
12432
  logger.out(`rows: ${execResult.rowCount}`);
12497
12433
  }
12498
- function splitSqlStatements(query$1) {
12434
+ function splitSqlStatements(query) {
12499
12435
  try {
12500
- const statements = parse(query$1);
12436
+ const statements = parse(query);
12501
12437
  if (statements.length === 0) return [];
12502
12438
  return statements.map((s) => toSql.statement(s));
12503
12439
  } catch {
12504
- const trimmed = query$1.trim();
12440
+ const trimmed = query.trim();
12505
12441
  return trimmed.length > 0 ? [trimmed] : [];
12506
12442
  }
12507
12443
  }
@@ -12544,5 +12480,5 @@ function printGqlResult(result, options = {}) {
12544
12480
  }
12545
12481
 
12546
12482
  //#endregion
12547
- export { getExecutorJob as $, truncateCommand as A, getMigrationDirPath as At, getCommand$1 as B, getNamespacesWithMigrations as Bt, getAppHealth as C, MIGRATE_FILE_NAME as Ct, listCommand$3 as D, createSnapshotFromLocalTypes as Dt, resumeWorkflow as E, compareSnapshots as Et, showCommand as F, loadDiff as Ft, listMachineUsers as G, commonArgs as Gt, getMachineUserToken as H, generateUserTypes as Ht, remove as I, reconstructSnapshotFromMigrations as It, webhookCommand as J, jsonArgs as Jt, generate$1 as K, confirmationArgs as Kt, removeCommand$1 as L, formatDiffSummary as Lt, generateCommand as M, getMigrationFiles as Mt, logBetaWarning as N, getNextMigrationNumber as Nt, listWorkflows as O, formatMigrationNumber as Ot, show as P, isValidMigrationNumber as Pt, listExecutors as Q, listCommand$4 as R, formatMigrationDiff as Rt, listCommand$2 as S, INITIAL_SCHEMA_NUMBER as St, resumeCommand as T, compareLocalTypesWithSnapshot as Tt, tokenCommand as U, apiCall as Ut, getOAuth2Client as V, trnPrefix as Vt, listCommand$5 as W, apiCommand as Wt, triggerExecutor as X, workspaceArgs as Xt, triggerCommand as Y, withCommonArgs as Yt, listCommand$6 as Z, deleteCommand as _, MIGRATION_LABEL_KEY as _t, removeCommand as a, getCommand$2 as at, createWorkspace as b, DB_TYPES_FILE_NAME as bt, listUsers as c, getWorkflowExecution as ct, restoreCommand as d, formatKeyValueTable as dt, jobsCommand as et, restoreWorkspace as f, getCommand$3 as ft, getWorkspace as g, waitForExecution$1 as gt, getCommand as h, executeScript as ht, updateUser as i, startWorkflow as it, generate as j, getMigrationFilePath as jt, truncate as k, getLatestMigrationNumber as kt, inviteCommand as l, listWorkflowExecutions as lt, listWorkspaces as m, apply as mt, queryCommand as n, watchExecutorJob as nt, removeUser as o, getWorkflow as ot, listCommand$1 as p, getExecutor as pt, listWebhookExecutors as q, deploymentArgs as qt, updateCommand as r, startCommand as rt, listCommand as s, executionsCommand as st, query as t, listExecutorJobs as tt, inviteUser as u, functionExecutionStatusToString as ut, deleteWorkspace as v, parseMigrationLabelNumber as vt, healthCommand as w, SCHEMA_FILE_NAME as wt, listApps as x, DIFF_FILE_NAME as xt, createCommand as y, bundleMigrationScript as yt, listOAuth2Clients as z, hasChanges as zt };
12548
- //# sourceMappingURL=query-D3UyoG68.mjs.map
12483
+ export { listExecutors as $, truncate as A, getLatestMigrationNumber as At, listOAuth2Clients as B, hasChanges as Bt, listCommand$2 as C, INITIAL_SCHEMA_NUMBER as Ct, resumeWorkflow as D, compareSnapshots as Dt, resumeCommand as E, compareLocalTypesWithSnapshot as Et, show as F, isValidMigrationNumber as Ft, listCommand$5 as G, apiCommand as Gt, getOAuth2Client as H, trnPrefix as Ht, showCommand as I, loadDiff as It, listWebhookExecutors as J, confirmationArgs as Jt, listMachineUsers as K, defineAppCommand as Kt, remove as L, reconstructSnapshotFromMigrations as Lt, generate as M, getMigrationFilePath as Mt, generateCommand as N, getMigrationFiles as Nt, listCommand$3 as O, createSnapshotFromLocalTypes as Ot, logBetaWarning as P, getNextMigrationNumber as Pt, listCommand$6 as Q, removeCommand$1 as R, formatDiffSummary as Rt, listApps as S, DIFF_FILE_NAME as St, healthCommand as T, SCHEMA_FILE_NAME as Tt, getMachineUserToken as U, generateUserTypes as Ut, getCommand$1 as V, getNamespacesWithMigrations as Vt, tokenCommand as W, apiCall as Wt, triggerCommand as X, isVerbose as Xt, webhookCommand as Y, deploymentArgs as Yt, triggerExecutor as Z, workspaceArgs as Zt, getWorkspace as _, waitForExecution$1 as _t, updateUser as a, startWorkflow as at, createCommand as b, bundleMigrationScript as bt, listCommand as c, executionsCommand as ct, inviteUser as d, functionExecutionStatusToString as dt, getExecutorJob as et, restoreCommand as f, formatKeyValueTable as ft, getCommand as g, executeScript as gt, listWorkspaces as h, apply as ht, updateCommand as i, startCommand as it, truncateCommand as j, getMigrationDirPath as jt, listWorkflows as k, formatMigrationNumber as kt, listUsers as l, getWorkflowExecution as lt, listCommand$1 as m, getExecutor as mt, queryCommand as n, listExecutorJobs as nt, removeCommand as o, getCommand$2 as ot, restoreWorkspace as p, getCommand$3 as pt, generate$1 as q, commonArgs as qt, isCLIError as r, watchExecutorJob as rt, removeUser as s, getWorkflow as st, query as t, jobsCommand as tt, inviteCommand as u, listWorkflowExecutions as ut, deleteCommand as v, MIGRATION_LABEL_KEY as vt, getAppHealth as w, MIGRATE_FILE_NAME as wt, createWorkspace as x, DB_TYPES_FILE_NAME as xt, deleteWorkspace as y, parseMigrationLabelNumber as yt, listCommand$4 as z, formatMigrationDiff as zt };
12484
+ //# sourceMappingURL=query-CRSZGUmD.mjs.map