@tailor-platform/sdk 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +1 -1
  3. package/dist/{application-F-nl107y.mjs → application-C8a0UJ-z.mjs} +201 -149
  4. package/dist/application-C8a0UJ-z.mjs.map +1 -0
  5. package/dist/application-D4zOiLLa.mjs +3 -0
  6. package/dist/cli/commands/tailordb/migrate/diff-calculator.d.mts +4 -4
  7. package/dist/cli/commands/tailordb/migrate/generate.d.mts +3 -3
  8. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +5 -5
  9. package/dist/cli/commands/tailordb/truncate.d.mts +2 -2
  10. package/dist/cli/lib.mjs +2 -2
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/cli/main.mjs +174 -106
  13. package/dist/cli/main.mjs.map +1 -1
  14. package/dist/cli/ts-hook.mjs +3 -1
  15. package/dist/completion/zsh-worker.zsh +19 -11
  16. package/dist/configure/config/index.d.mts +1 -1
  17. package/dist/configure/index.d.mts +2 -1
  18. package/dist/configure/index.mjs +2 -2
  19. package/dist/configure/index.mjs.map +1 -1
  20. package/dist/configure/services/aigateway/index.d.mts +5 -4
  21. package/dist/configure/services/aigateway/types.d.mts +6 -1
  22. package/dist/configure/services/auth/types.d.mts +2 -2
  23. package/dist/configure/services/tailordb/permission.d.mts +1 -1
  24. package/dist/configure/services/tailordb/schema.d.mts +1 -1
  25. package/dist/configure/services/tailordb/types.d.mts +7 -4
  26. package/dist/configure/types/auth-namespace-name.d.mts +18 -0
  27. package/dist/{crashreport-CINZ5dVN.mjs → crashreport-Cd4TqfZq.mjs} +1 -1
  28. package/dist/{crashreport-CIIfLnoO.mjs → crashreport-Q0pDAlrj.mjs} +8 -4
  29. package/dist/{crashreport-CIIfLnoO.mjs.map → crashreport-Q0pDAlrj.mjs.map} +1 -1
  30. package/dist/{errors-BVb6vYGy.mjs → errors-Bxut5_Sy.mjs} +2 -2
  31. package/dist/{errors-BVb6vYGy.mjs.map → errors-Bxut5_Sy.mjs.map} +1 -1
  32. package/dist/file-BUcmVIH2.mjs.map +1 -1
  33. package/dist/kysely/index.mjs +2 -1
  34. package/dist/kysely/index.mjs.map +1 -1
  35. package/dist/{logger-DSdExfor.mjs → logger-D0bEznPv.mjs} +9 -5
  36. package/dist/{logger-DSdExfor.mjs.map → logger-D0bEznPv.mjs.map} +1 -1
  37. package/dist/package-json-8b0O9TlX.mjs.map +1 -1
  38. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  39. package/dist/plugin/builtin/enum-constants/index.mjs +5 -5
  40. package/dist/plugin/builtin/enum-constants/index.mjs.map +1 -1
  41. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  42. package/dist/plugin/builtin/file-utils/index.mjs +14 -11
  43. package/dist/plugin/builtin/file-utils/index.mjs.map +1 -1
  44. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  45. package/dist/plugin/builtin/kysely-type/index.mjs +9 -9
  46. package/dist/plugin/builtin/kysely-type/index.mjs.map +1 -1
  47. package/dist/plugin/builtin/seed/index.mjs +1 -1
  48. package/dist/plugin/builtin/seed/seed-type-processor.d.mts +4 -4
  49. package/dist/plugin/get-generated-type.d.mts +4 -4
  50. package/dist/plugin/index.mjs +13 -13
  51. package/dist/plugin/index.mjs.map +1 -1
  52. package/dist/plugin/types.d.mts +2 -2
  53. package/dist/plugin/with-context.d.mts +1 -1
  54. package/dist/{register-ts-hook-ClI226n2.mjs → register-ts-hook-Vqjza10T.mjs} +552 -416
  55. package/dist/register-ts-hook-Vqjza10T.mjs.map +1 -0
  56. package/dist/{repl-editor-BCozyiNq.mjs → repl-editor-F9LotMNx.mjs} +3 -2
  57. package/dist/{repl-editor-BCozyiNq.mjs.map → repl-editor-F9LotMNx.mjs.map} +1 -1
  58. package/dist/runtime/file.d.mts +14 -14
  59. package/dist/{schema--xYWRGfe.mjs → schema-D4TC4BC3.mjs} +4 -3
  60. package/dist/schema-D4TC4BC3.mjs.map +1 -0
  61. package/dist/seed/index.d.mts +4 -4
  62. package/dist/seed/index.mjs +3 -3
  63. package/dist/seed/index.mjs.map +1 -1
  64. package/dist/{seed-xqM9WIHP.mjs → seed-Cibjmtry.mjs} +46 -40
  65. package/dist/seed-Cibjmtry.mjs.map +1 -0
  66. package/dist/{service-C_WpbKHu.mjs → service-2grcAOCJ.mjs} +24 -24
  67. package/dist/service-2grcAOCJ.mjs.map +1 -0
  68. package/dist/service-CaBPNDIZ.mjs +3 -0
  69. package/dist/{service-hZskxZmg.mjs → service-LTfp03ZZ.mjs} +7 -5
  70. package/dist/{service-hZskxZmg.mjs.map → service-LTfp03ZZ.mjs.map} +1 -1
  71. package/dist/types/aigateway.generated.d.mts +2 -2
  72. package/dist/types/auth.generated.d.mts +3 -3
  73. package/dist/types/executor.generated.d.mts +1 -1
  74. package/dist/types/tailordb.generated.d.mts +12 -12
  75. package/dist/utils/test/index.d.mts +4 -4
  76. package/dist/utils/test/index.mjs +4 -4
  77. package/dist/utils/test/index.mjs.map +1 -1
  78. package/dist/vitest/index.mjs +13 -7
  79. package/dist/vitest/index.mjs.map +1 -1
  80. package/dist/vitest/mocks/file.d.mts +1 -1
  81. package/docs/cli/application.md +3 -1
  82. package/docs/cli/function.md +17 -13
  83. package/docs/cli/tailordb.md +30 -30
  84. package/docs/cli/workspace.md +2 -2
  85. package/docs/cli-reference.md +21 -21
  86. package/docs/configuration.md +2 -2
  87. package/docs/migration/v2.md +4 -4
  88. package/docs/migration/v3.md +41 -0
  89. package/docs/quickstart.md +1 -1
  90. package/docs/services/aigateway.md +33 -9
  91. package/docs/services/executor.md +5 -1
  92. package/docs/services/tailordb-migration.md +47 -47
  93. package/docs/services/tailordb.md +7 -7
  94. package/docs/testing.md +1 -1
  95. package/package.json +6 -6
  96. package/dist/application-BZfk4HKm.mjs +0 -3
  97. package/dist/application-F-nl107y.mjs.map +0 -1
  98. package/dist/register-ts-hook-ClI226n2.mjs.map +0 -1
  99. package/dist/schema--xYWRGfe.mjs.map +0 -1
  100. package/dist/seed-xqM9WIHP.mjs.map +0 -1
  101. package/dist/service-C_WpbKHu.mjs.map +0 -1
  102. package/dist/service-D1RCdzIL.mjs +0 -3
package/dist/cli/main.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import { r as parseInputFields } from "../schema--xYWRGfe.mjs";
2
+ import { r as parseInputFields } from "../schema-D4TC4BC3.mjs";
3
3
  import { At as PATScope, Ct as AuthInvokerSchema, E as CustomDomainStatus, Ft as CloneOperationStatus, W as FunctionExecution_Type } from "../workspace_resource_pb-HNIL_Vfj.mjs";
4
4
  import { t as assertDefined } from "../assert-DBxo8jPo.mjs";
5
- import { n as logger, r as styles } from "../logger-DSdExfor.mjs";
6
- import { $ as treeCommand, $n as sanitizeMigrationLabel, An as MIGRATION_FILE_NAMES, Ar as readPlatformConfig, B as MIGRATION_REVIEW_REQUIRED_MARKER, Bn as getLatestMigrationNumber, Br as deploymentArgs, Bt as getCommand$6, C as healthCommand, Cn as captureFileState, Cr as loadConfigPath, Ct as listCommand$9, Dr as loadStoredUserTokens, E as resumeCommand, Er as loadPlatformClientConfig, F as chunkSeedData, Fn as assertValidMigrationFiles, Fr as writePlatformConfig, Ft as jobsCommand, G as showCommand, Gn as loadDiff, Gr as resolveMachineUserInputSource, Gt as functionExecutionStatusToString, H as deployCommand$1, Hn as getMigrationFilePath, Hr as multiConfigArg, Ht as executionsCommand, I as bundleSeedScript, In as compareLocalTypesWithSnapshot, Ir as defineAppCommand, Jn as reconstructSnapshotFromMigrations, K as extractOwnedNamespaces, Kn as loadSnapshot, Kr as toPageDirection, Kt as getCommand$1, Ln as compareSnapshots, Lr as commonArgs, M as loadSeedContext, Mr as resolveConfigUser, N as loadApplicationNamespaces, Nn as UnsupportedMigrationFileVersionError, Nr as resolveUserTokenKey, O as listCommand$14, Or as loadWorkspaceId, Ot as webhookCommand, Pn as assertMigrationNumberExists, Pr as saveUserTokens, Qn as handleOptionalToRequiredError, Qt as listCommand$17, R as generateCommand$1, Rn as createSnapshotFromLocalTypes, Rr as configArg, Rt as startCommand, Sn as protoGqlPermission, Sr as loadAccessToken, St as generate, Tr as loadMachineUserName, Tt as getCommand$2, Un as getMigrationFiles, Ur as pagedLogArgs, V as generateSchemaFile, Vr as isVerbose, Wr as paginationArgs, X as updateCommand$3, Xn as MIGRATION_LABEL_KEY, Xt as deployMigrationTestBaseline, Y as removeCommand$1, Yn as MIGRATION_HISTORY_LABEL_KEY, Yt as deployFromCLI, Zn as createMigrationHistoryId, Zt as deployMigrationTestTarget, _n as verifyRemoteSchema, _r as loadConfig, a as queryCommand, an as ensureConfigId, ar as resourceTrn, bn as compareSnapshotWithRemote, br as hasAnyUserTokenEntry, bt as listCommand$10, c as removeCommand, cn as executeScript, cr as sdkVersionLabelKey, ct as getCommand$4, dn as bundleMigrationScript, en as createCommand$4, er as formatDiffSummary, et as listCommand$13, f as inviteCommand, fn as checkMigrationDiffs, fr as formatMigrationNumber, ft as createCommand$3, g as getCommand$7, gn as toTailorDBDeployInput, gr as assertWritable, gt as getCommand$3, hn as logRemoteDriftGuidance, hr as apiCall, in as workspaceNameSchema, ir as selectTargetNamespace, it as updateCommand$2, j as truncateCommand, jn as MIGRATION_NUMBER_PATTERN, jr as removeLegacyUserAlias, jt as listCommand$8, kr as platformConfigFromProfile, kt as triggerCommand, lr as writeMetadataLabels, m as restoreCommand, mn as formatRemoteVerificationResults, mr as prompt, mt as listCommand$11, nr as hasChanges, nt as getCommand$5, o as updateCommand$4, on as getMigrationMachineUser, or as sdkAppIdLabelKey, ot as listCommand$12, pn as fetchRemoteSchemaSnapshot, pr as parseMigrationNumberArg, q as logBetaWarning, qn as normalizeSchemaSnapshot, qr as workspaceArgs, r as serializeError, rn as formatKeyValueTable, rr as getNamespacesWithMigrations, sn as updateMigrationLabel, sr as sdkNameLabelKey, t as registerTsHook, tn as createValidatedWorkspaceWithClient, tr as formatMigrationDiff, u as listCommand$16, un as formatMigrationScriptCommand, ur as PluginManager, ut as deleteCommand$4, v as deleteCommand$5, vn as fetchRemoteMigrationNumber, vr as deleteUserTokens, w as waitCommand, wn as captureMigrationFileState, wr as loadConsoleBaseUrl, x as listCommand$15, xn as generateAllTypeManifestsFromSnapshot, xr as hasUserTokenEntry, yn as fetchRemoteMigrationState, yr as fetchLatestToken, yt as tokenCommand$1, z as scriptCommand, zn as formatSchemaDrifts, zr as confirmationArgs } from "../register-ts-hook-ClI226n2.mjs";
7
- import { B as fetchPaged, C as resolveTSConfigWithFallback, D as resolveBundleLogLevel, E as createLogLevelTreeshakeOptions, F as closeConnectionPool, G as getOrNull, H as fetchUserInfo, I as defaultPlatformBaseUrl, J as initOperatorClient, K as getPlatformBaseUrl, L as fetchAll, M as getDistDir, O as createBundleLog, R as fetchAllTolerant, S as createTsconfigPathsPlugin, T as composeFunctionTreeshakeOptions, V as fetchPlatformMachineUserToken, W as getOAuth2ClientId, Y as isDefaultPlatform, a as resolveInlineSourcemap, c as WorkflowJobSchema, f as INVOKER_EXPR, g as assertUniqueLocalTailorDBTypeNames, h as buildResolverPermissionAndInputCheckExpr, l as resolveResolverDefaultPermissionForFile, q as initOAuth2Client, u as ResolverSchema, w as platformBundleDefinePlugin, x as createGeneratedEntryResolverPlugin } from "../application-F-nl107y.mjs";
8
- import { h as loadFilesWithIgnores, i as ExecutorSchema, r as stripExecutorTriggerArgs } from "../service-C_WpbKHu.mjs";
5
+ import { n as logger, r as styles } from "../logger-D0bEznPv.mjs";
6
+ import { $ as treeCommand, $n as sanitizeMigrationLabel, An as MIGRATION_FILE_NAMES, Ar as readPlatformConfig, B as MIGRATION_REVIEW_REQUIRED_MARKER, Bn as getLatestMigrationNumber, Br as deploymentArgs, Bt as getCommand$6, C as healthCommand, Cn as captureFileState, Cr as loadConfigPath, Ct as listCommand$9, Dr as loadStoredUserTokens, E as resumeCommand, Er as loadPlatformClientConfig, F as chunkSeedData, Fn as assertValidMigrationFiles, Fr as writePlatformConfig, Ft as jobsCommand, G as showCommand, Gn as loadDiff, Gr as resolveMachineUserInputSource, Gt as functionExecutionStatusToString, H as deployCommand$1, Hn as getMigrationFilePath, Hr as multiConfigArg, Ht as executionsCommand, I as bundleSeedScript, In as compareLocalTypesWithSnapshot, Ir as defineAppCommand, Jn as reconstructSnapshotFromMigrations, K as extractOwnedNamespaces, Kn as loadSnapshot, Kr as toPageDirection, Kt as getCommand$1, Ln as compareSnapshots, Lr as commonArgs, M as loadSeedContext, Mr as resolveConfigUser, N as loadApplicationNamespaces, Nn as UnsupportedMigrationFileVersionError, Nr as resolveUserTokenKey, O as listCommand$14, Or as loadWorkspaceId, Ot as webhookCommand, Pn as assertMigrationNumberExists, Pr as saveUserTokens, Qn as handleOptionalToRequiredError, Qt as listCommand$17, R as generateCommand$1, Rn as createSnapshotFromLocalTypes, Rr as configArg, Rt as startCommand, Sn as protoGqlPermission, Sr as loadAccessToken, St as generate, Tr as loadMachineUserName, Tt as getCommand$2, Un as getMigrationFiles, Ur as pagedLogArgs, V as generateSchemaFile, Vr as isVerbose, Wr as paginationArgs, X as updateCommand$3, Xn as MIGRATION_LABEL_KEY, Xt as deployMigrationTestBaseline, Y as removeCommand$1, Yn as MIGRATION_HISTORY_LABEL_KEY, Yt as deployFromCLI, Zn as createMigrationHistoryId, Zt as deployMigrationTestTarget, _n as verifyRemoteSchema, _r as loadConfig, a as queryCommand, an as ensureConfigId, ar as resourceTrn, bn as compareSnapshotWithRemote, br as hasAnyUserTokenEntry, bt as listCommand$10, c as removeCommand, cn as executeScript, cr as sdkVersionLabelKey, ct as getCommand$4, dn as bundleMigrationScript, en as createCommand$4, er as formatDiffSummary, et as listCommand$13, f as inviteCommand, fn as checkMigrationDiffs, fr as formatMigrationNumber, ft as createCommand$3, g as getCommand$7, gn as toTailorDBDeployInput, gr as assertWritable, gt as getCommand$3, hn as logRemoteDriftGuidance, hr as apiCall, in as workspaceNameSchema, ir as selectTargetNamespace, it as updateCommand$2, j as truncateCommand, jn as MIGRATION_NUMBER_PATTERN, jr as removeLegacyUserAlias, jt as listCommand$8, kr as platformConfigFromProfile, kt as triggerCommand, lr as writeMetadataLabels, m as restoreCommand, mn as formatRemoteVerificationResults, mr as prompt, mt as listCommand$11, nr as hasChanges, nt as getCommand$5, o as updateCommand$4, on as getMigrationMachineUser, or as sdkAppIdLabelKey, ot as listCommand$12, pn as fetchRemoteSchemaSnapshot, pr as parseMigrationNumberArg, q as logBetaWarning, qn as normalizeSchemaSnapshot, qr as workspaceArgs, r as serializeError, rn as formatKeyValueTable, rr as getNamespacesWithMigrations, sn as updateMigrationLabel, sr as sdkNameLabelKey, t as registerTsHook, tn as createValidatedWorkspaceWithClient, tr as formatMigrationDiff, u as listCommand$16, un as formatMigrationScriptCommand, ur as PluginManager, ut as deleteCommand$4, v as deleteCommand$5, vn as fetchRemoteMigrationNumber, vr as deleteUserTokens, w as waitCommand, wn as captureMigrationFileState, wr as loadConsoleBaseUrl, x as listCommand$15, xn as generateAllTypeManifestsFromSnapshot, xr as hasUserTokenEntry, yn as fetchRemoteMigrationState, yr as fetchLatestToken, yt as tokenCommand$1, z as scriptCommand, zn as formatSchemaDrifts, zr as confirmationArgs } from "../register-ts-hook-Vqjza10T.mjs";
7
+ import { C as createTsconfigPathsPlugin, D as createLogLevelTreeshakeOptions, E as composeFunctionTreeshakeOptions, G as getOAuth2ClientId, H as fetchPlatformMachineUserToken, I as closeConnectionPool, J as initOAuth2Client, K as getOrNull, L as defaultPlatformBaseUrl, N as getDistDir, O as resolveBundleLogLevel, R as fetchAll, S as createGeneratedEntryResolverPlugin, T as platformBundleDefinePlugin, U as fetchUserInfo, V as fetchPaged, X as isDefaultPlatform, Y as initOperatorClient, _ as assertUniqueLocalTailorDBTypeNames, a as resolveInlineSourcemap, d as ResolverSchema, g as buildResolverPermissionAndInputCheckExpr, k as createBundleLog, l as WorkflowJobSchema, p as INVOKER_EXPR, q as getPlatformBaseUrl, u as resolveResolverDefaultPermissionForFile, w as resolveTSConfigWithFallback, z as fetchAllTolerant } from "../application-C8a0UJ-z.mjs";
8
+ import { h as loadFilesWithIgnores, i as ExecutorSchema, r as stripExecutorTriggerArgs } from "../service-2grcAOCJ.mjs";
9
9
  import { t as multiline } from "../multiline-sfHpTZZK.mjs";
10
10
  import { t as readPackageJson } from "../package-json-8b0O9TlX.mjs";
11
11
  import { t as userAgent } from "../user-agent-Bgsszb5I.mjs";
12
- import { a as typeOnlyImportHint, i as isCLIError, r as formatNextAction, t as createCLIError } from "../errors-BVb6vYGy.mjs";
12
+ import { a as typeOnlyImportHint, i as isCLIError, r as formatNextAction, t as createCLIError } from "../errors-Bxut5_Sy.mjs";
13
13
  import { t as OperatorService } from "../service_pb-BEWj1pOV.mjs";
14
- import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-CIIfLnoO.mjs";
14
+ import { a as JSON_FOOTER_MARKER, i as CRASH_LOG_EXTENSION, o as parseCrashReportConfig, r as sendCrashReport, t as initCrashReporting } from "../crashreport-Q0pDAlrj.mjs";
15
15
  import * as path from "pathe";
16
16
  import { dirname, resolve } from "pathe";
17
17
  import { resolvePackageJSON } from "pkg-types";
@@ -650,7 +650,8 @@ const authorizeAuthConnectionCommand = defineAppCommand({
650
650
  }),
651
651
  run: async (args) => {
652
652
  await assertWritable({ profile: args.profile });
653
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
653
+ const accessToken = await loadAccessToken({ profile: args.profile });
654
+ const client = await initOperatorClient(accessToken);
654
655
  const workspaceId = await loadWorkspaceId({
655
656
  workspaceId: args["workspace-id"],
656
657
  profile: args.profile
@@ -713,7 +714,7 @@ const authorizeAuthConnectionCommand = defineAppCommand({
713
714
  const timeout = setTimeout(() => {
714
715
  server.close();
715
716
  reject(/* @__PURE__ */ new Error("Authorization timeout exceeded (5 minutes)."));
716
- }, 300 * 1e3);
717
+ }, 3e5);
717
718
  server.on("close", () => {
718
719
  clearTimeout(timeout);
719
720
  });
@@ -751,7 +752,8 @@ const deleteAuthConnectionCommand = defineAppCommand({
751
752
  }),
752
753
  run: async (args) => {
753
754
  await assertWritable({ profile: args.profile });
754
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
755
+ const accessToken = await loadAccessToken({ profile: args.profile });
756
+ const client = await initOperatorClient(accessToken);
755
757
  const workspaceId = await loadWorkspaceId({
756
758
  workspaceId: args["workspace-id"],
757
759
  profile: args.profile
@@ -798,7 +800,8 @@ const listAuthConnectionCommand = defineAppCommand({
798
800
  ...paginationArgs()
799
801
  }),
800
802
  run: async (args) => {
801
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
803
+ const accessToken = await loadAccessToken({ profile: args.profile });
804
+ const client = await initOperatorClient(accessToken);
802
805
  const workspaceId = await loadWorkspaceId({
803
806
  workspaceId: args["workspace-id"],
804
807
  profile: args.profile
@@ -878,7 +881,8 @@ const revokeAuthConnectionCommand = defineAppCommand({
878
881
  }),
879
882
  run: async (args) => {
880
883
  await assertWritable({ profile: args.profile });
881
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
884
+ const accessToken = await loadAccessToken({ profile: args.profile });
885
+ const client = await initOperatorClient(accessToken);
882
886
  const workspaceId = await loadWorkspaceId({
883
887
  workspaceId: args["workspace-id"],
884
888
  profile: args.profile
@@ -1196,7 +1200,7 @@ async function downloadFunctionScript(options) {
1196
1200
  //#region src/cli/shared/stack-trace.ts
1197
1201
  /**
1198
1202
  * Stack trace parsing, sourcemap-based source identification, and
1199
- * formatted error display for the test-run command.
1203
+ * formatted error display for the function run command.
1200
1204
  *
1201
1205
  * The platform runtime automatically applies inline sourcemaps to V8
1202
1206
  * stack traces, so frame positions are already original source positions.
@@ -1246,7 +1250,8 @@ function extractInlineSourcemap(bundledCode) {
1246
1250
  if (!match) return null;
1247
1251
  try {
1248
1252
  const decoded = Buffer.from(assertDefined(match[1], "sourcemap base64 data missing"), "base64").toString("utf-8");
1249
- return new TraceMap(JSON.parse(decoded));
1253
+ const rawSourceMap = JSON.parse(decoded);
1254
+ return new TraceMap(rawSourceMap);
1250
1255
  } catch {
1251
1256
  return null;
1252
1257
  }
@@ -1396,7 +1401,7 @@ function formatMappedError(errorMessage, frames, traceMap, bundleDir) {
1396
1401
  }
1397
1402
  /**
1398
1403
  * Format an error string with sourcemap-based source locations.
1399
- * This is the main entry point for test-run error display.
1404
+ * This is the main entry point for function run error display.
1400
1405
  *
1401
1406
  * The platform runtime applies inline sourcemaps automatically, so V8
1402
1407
  * stack frames already contain original source positions. This function
@@ -1510,7 +1515,8 @@ function formatExecutionErrorFallback(error) {
1510
1515
  */
1511
1516
  function formatExecutionError(error, bundledCode) {
1512
1517
  if (bundledCode && error.stackTrace) {
1513
- const formatted = formatErrorWithSourcemap(composeExecutionErrorString(error), bundledCode, process.cwd());
1518
+ const errorString = composeExecutionErrorString(error);
1519
+ const formatted = formatErrorWithSourcemap(errorString, bundledCode, process.cwd());
1514
1520
  if (formatted) return formatted;
1515
1521
  }
1516
1522
  return formatExecutionErrorFallback(error);
@@ -1576,7 +1582,7 @@ async function downloadScriptForMapping(options) {
1576
1582
  const { client, workspaceId, scriptName, executionType, executionContentHash } = options;
1577
1583
  const registryName = scriptNameToRegistryName(scriptName, executionType);
1578
1584
  if (registryName == null) {
1579
- logger.debug(`Script "${scriptName}" is not a deployed registry script (e.g. test-run or seed); skipping sourcemap mapping.`);
1585
+ logger.debug(`Script "${scriptName}" is not a deployed registry script (e.g. function run or seed); skipping sourcemap mapping.`);
1580
1586
  return null;
1581
1587
  }
1582
1588
  if (executionContentHash === "") {
@@ -1598,7 +1604,7 @@ async function downloadScriptForMapping(options) {
1598
1604
  const logsCommand = defineAppCommand({
1599
1605
  name: "logs",
1600
1606
  description: "List or get function execution logs.",
1601
- notes: `When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to your original source files (clickable file links and code snippets, matching \`function test-run\` output).
1607
+ notes: `When viewing a specific execution that failed, the command displays error details with the stack trace mapped back to your original source files (clickable file links and code snippets, matching \`function run\` output).
1602
1608
 
1603
1609
  Stack traces are mapped only when the execution includes a content hash for the exact build that ran. If the content hash is missing or the build is no longer available, the command falls back to a plain-text error display.`,
1604
1610
  examples: [
@@ -1628,7 +1634,8 @@ Stack traces are mapped only when the execution includes a content hash for the
1628
1634
  })
1629
1635
  }),
1630
1636
  run: async (args) => {
1631
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
1637
+ const accessToken = await loadAccessToken({ profile: args.profile });
1638
+ const client = await initOperatorClient(accessToken);
1632
1639
  const workspaceId = await loadWorkspaceId({
1633
1640
  workspaceId: args["workspace-id"],
1634
1641
  profile: args.profile
@@ -1674,18 +1681,18 @@ Stack traces are mapped only when the execution includes a content hash for the
1674
1681
  //#endregion
1675
1682
  //#region src/cli/commands/function/bundle.ts
1676
1683
  /**
1677
- * Bundler for function test-run command
1684
+ * Bundler for the function run command
1678
1685
  *
1679
1686
  * Bundles a single function file for execution via the TestExecScript API.
1680
1687
  * Generates an entry file based on the detected function type and bundles
1681
1688
  * with rolldown, following the same patterns as the existing bundlers.
1682
1689
  */
1683
1690
  /**
1684
- * Bundle a function file for test-run execution via TestExecScript API.
1691
+ * Bundle a function file for `function run` execution via the TestExecScript API.
1685
1692
  * @param options - Bundle options
1686
1693
  * @returns Bundled code and script name
1687
1694
  */
1688
- async function bundleForTestRun(options) {
1695
+ async function bundleForRun(options) {
1689
1696
  const { detected, sourceFile, baseDir, env = {}, machineUser, workspaceId } = options;
1690
1697
  const inlineSourcemap = resolveInlineSourcemap(options.inlineSourcemap);
1691
1698
  const bundleLogLevel = resolveBundleLogLevel(options.logLevel);
@@ -1820,7 +1827,7 @@ function buildMachinePrincipalExpr(machineUser, workspaceId) {
1820
1827
  //#endregion
1821
1828
  //#region src/cli/commands/function/detect.ts
1822
1829
  /**
1823
- * Function type detection for test-run command
1830
+ * Function type detection for the function run command
1824
1831
  *
1825
1832
  * Detects the function type (resolver, executor, workflow job, or plain function)
1826
1833
  * by dynamically importing the module and checking against known schemas.
@@ -1932,15 +1939,16 @@ function deriveNameFromPath(filePath) {
1932
1939
  }
1933
1940
 
1934
1941
  //#endregion
1935
- //#region src/cli/commands/function/test-run.ts
1942
+ //#region src/cli/commands/function/run.ts
1936
1943
  /**
1937
- * `tailor function test-run` command
1944
+ * `tailor function run` command
1938
1945
  *
1939
1946
  * Bundles and executes a function on the Tailor Platform server
1940
1947
  * without deploying (applying) the application.
1941
1948
  */
1942
- const testRunCommand = defineAppCommand({
1943
- name: "test-run",
1949
+ const runFunctionCommand = defineAppCommand({
1950
+ name: "run",
1951
+ aliases: ["test-run"],
1944
1952
  description: "Run a function on the Tailor Platform server without deploying.",
1945
1953
  args: z.object({
1946
1954
  ...workspaceArgs,
@@ -1969,8 +1977,10 @@ const testRunCommand = defineAppCommand({
1969
1977
  notes: `You can pass either a source file (\`.ts\`) or a pre-bundled file (\`.js\`).
1970
1978
  When a \`.js\` file is provided, detection and bundling are skipped and the file is executed as-is.
1971
1979
 
1980
+ \`test-run\` is a deprecated alias of this command and will be removed in v3.
1981
+
1972
1982
  > [!WARNING]
1973
- > Workflow job \`.start()\` calls do not work in test-run mode.
1983
+ > Workflow job \`.start()\` calls do not work in this mode.
1974
1984
  > Started jobs are not executed; only the target job's \`body\` function runs in isolation.`,
1975
1985
  examples: [
1976
1986
  {
@@ -1987,6 +1997,7 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1987
1997
  }
1988
1998
  ],
1989
1999
  run: async (args) => {
2000
+ if (invokedViaTestRunAlias(process.argv)) logger.warn("`tailor function test-run` is deprecated and will be removed in v3. Use `tailor function run` instead.");
1990
2001
  const jsonOutput = logger.jsonMode;
1991
2002
  const filePath = path.resolve(args.file);
1992
2003
  if (!fs.existsSync(filePath)) throw new Error(`File not found: ${filePath}`);
@@ -1998,7 +2009,8 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
1998
2009
  profile: args.profile,
1999
2010
  authConfig: config.auth
2000
2011
  });
2001
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
2012
+ const accessToken = await loadAccessToken({ profile: args.profile });
2013
+ const client = await initOperatorClient(accessToken);
2002
2014
  const workspaceId = await loadWorkspaceId({
2003
2015
  workspaceId: args["workspace-id"],
2004
2016
  profile: args.profile
@@ -2035,7 +2047,7 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
2035
2047
  }
2036
2048
  logger.info("Bundling...");
2037
2049
  const baseDir = path.dirname(config.path);
2038
- ({bundledCode, scriptName} = await bundleForTestRun({
2050
+ ({bundledCode, scriptName} = await bundleForRun({
2039
2051
  detected,
2040
2052
  sourceFile: filePath,
2041
2053
  baseDir,
@@ -2107,6 +2119,16 @@ When a \`.js\` file is provided, detection and bundling are skipped and the file
2107
2119
  }
2108
2120
  });
2109
2121
  /**
2122
+ * Detect whether the command was invoked through the deprecated `test-run`
2123
+ * alias. politty resolves aliases before dispatch, so the invoked name is only
2124
+ * observable from the raw argv.
2125
+ * @param argv - Process argv tokens
2126
+ * @returns true when the `test-run` alias follows the `function` subcommand
2127
+ */
2128
+ function invokedViaTestRunAlias(argv) {
2129
+ return argv.some((token, i) => token === "function" && argv[i + 1] === "test-run");
2130
+ }
2131
+ /**
2110
2132
  * Resolve auth namespace from config.
2111
2133
  * @param authConfig - Auth configuration from tailor.config.ts
2112
2134
  * @returns Resolved auth namespace
@@ -2181,7 +2203,7 @@ const functionCommand = defineCommand({
2181
2203
  get: getCommand$2,
2182
2204
  list: listCommand$9,
2183
2205
  logs: logsCommand,
2184
- "test-run": testRunCommand
2206
+ run: runFunctionCommand
2185
2207
  },
2186
2208
  async run() {
2187
2209
  await runCommand(listCommand$9, []);
@@ -2352,7 +2374,7 @@ const startAuthServer = async (args = {}) => {
2352
2374
  const timeout = setTimeout(() => {
2353
2375
  server.close();
2354
2376
  reject(/* @__PURE__ */ new Error("Login timeout exceeded"));
2355
- }, 300 * 1e3);
2377
+ }, 3e5);
2356
2378
  server.on("close", () => {
2357
2379
  clearTimeout(timeout);
2358
2380
  });
@@ -3097,7 +3119,7 @@ const createCommand$2 = defineAppCommand({
3097
3119
  permission: arg(z.enum(["write", "read"]).default("write"), { description: "Profile permission. 'read' blocks all write commands while the profile is active." }),
3098
3120
  "machine-user": arg(z.string().optional(), {
3099
3121
  alias: "m",
3100
- description: "Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token)."
3122
+ description: "Default machine user name for application-data commands (query, workflow start, function run, machineuser token)."
3101
3123
  }),
3102
3124
  "machine-user-override": arg(z.enum(["allow", "deny"]).optional(), { description: "Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user." }),
3103
3125
  "platform-url": arg(z.url().optional(), {
@@ -3238,7 +3260,7 @@ const updateCommand$1 = defineAppCommand({
3238
3260
  permission: arg(z.enum(["write", "read"]).optional(), { description: "Profile permission. 'read' blocks all write commands; 'write' lifts the restriction." }),
3239
3261
  "machine-user": arg(z.string().optional(), {
3240
3262
  alias: "m",
3241
- description: "Default machine user name for application-data commands (query, workflow start, function test-run, machineuser token). Pass an empty string to clear."
3263
+ description: "Default machine user name for application-data commands (query, workflow start, function run, machineuser token). Pass an empty string to clear."
3242
3264
  }),
3243
3265
  "machine-user-override": arg(z.enum(["allow", "deny"]).optional(), { description: "Whether the command line or TAILOR_PLATFORM_MACHINE_USER_NAME may override the profile's machine user. 'deny' requires --machine-user; 'allow' lifts the restriction." }),
3244
3266
  "platform-url": arg(z.union([z.url(), z.literal("")]).optional(), { description: "Platform API base URL for this profile. Pass an empty string to clear." }),
@@ -3287,16 +3309,24 @@ const updateCommand$1 = defineAppCommand({
3287
3309
  profile.workspace_id = newWorkspaceId;
3288
3310
  if (args.permission === "read") profile.readonly = true;
3289
3311
  else if (args.permission === "write") delete profile.readonly;
3290
- if (args["machine-user"] !== void 0) if (args["machine-user"] === "") delete profile.machine_user;
3291
- else profile.machine_user = args["machine-user"];
3312
+ if (args["machine-user"] !== void 0) {
3313
+ if (args["machine-user"] === "") delete profile.machine_user;
3314
+ else profile.machine_user = args["machine-user"];
3315
+ }
3292
3316
  if (args["machine-user-override"] === "deny") profile.machine_user_override = "deny";
3293
3317
  else if (args["machine-user-override"] === "allow") delete profile.machine_user_override;
3294
- if (args["platform-url"] !== void 0) if (args["platform-url"] === "") delete profile.platform_url;
3295
- else profile.platform_url = args["platform-url"];
3296
- if (args["oauth2-client-id"] !== void 0) if (args["oauth2-client-id"] === "") delete profile.oauth2_client_id;
3297
- else profile.oauth2_client_id = args["oauth2-client-id"];
3298
- if (args["console-url"] !== void 0) if (args["console-url"] === "") delete profile.console_url;
3299
- else profile.console_url = args["console-url"];
3318
+ if (args["platform-url"] !== void 0) {
3319
+ if (args["platform-url"] === "") delete profile.platform_url;
3320
+ else profile.platform_url = args["platform-url"];
3321
+ }
3322
+ if (args["oauth2-client-id"] !== void 0) {
3323
+ if (args["oauth2-client-id"] === "") delete profile.oauth2_client_id;
3324
+ else profile.oauth2_client_id = args["oauth2-client-id"];
3325
+ }
3326
+ if (args["console-url"] !== void 0) {
3327
+ if (args["console-url"] === "") delete profile.console_url;
3328
+ else profile.console_url = args["console-url"];
3329
+ }
3300
3330
  writePlatformConfig(config);
3301
3331
  if (!args.json) logger.success(`Profile "${args.name}" updated successfully`);
3302
3332
  const profileInfo = {
@@ -3434,7 +3464,8 @@ const createSecretCommand = defineAppCommand({
3434
3464
  }),
3435
3465
  run: async (args) => {
3436
3466
  await assertWritable({ profile: args.profile });
3437
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
3467
+ const accessToken = await loadAccessToken({ profile: args.profile });
3468
+ const client = await initOperatorClient(accessToken);
3438
3469
  const workspaceId = await loadWorkspaceId({
3439
3470
  workspaceId: args["workspace-id"],
3440
3471
  profile: args.profile
@@ -3484,7 +3515,8 @@ const deleteSecretCommand = defineAppCommand({
3484
3515
  }),
3485
3516
  run: async (args) => {
3486
3517
  await assertWritable({ profile: args.profile });
3487
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
3518
+ const accessToken = await loadAccessToken({ profile: args.profile });
3519
+ const client = await initOperatorClient(accessToken);
3488
3520
  const workspaceId = await loadWorkspaceId({
3489
3521
  workspaceId: args["workspace-id"],
3490
3522
  profile: args.profile
@@ -3533,7 +3565,8 @@ function secretInfo(secret) {
3533
3565
  * @returns List of secrets
3534
3566
  */
3535
3567
  async function secretList(options) {
3536
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }));
3568
+ const accessToken = await loadAccessToken({ profile: options.profile });
3569
+ const client = await initOperatorClient(accessToken);
3537
3570
  const workspaceId = await loadWorkspaceId({
3538
3571
  workspaceId: options.workspaceId,
3539
3572
  profile: options.profile
@@ -3587,7 +3620,8 @@ const updateSecretCommand = defineAppCommand({
3587
3620
  }),
3588
3621
  run: async (args) => {
3589
3622
  await assertWritable({ profile: args.profile });
3590
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
3623
+ const accessToken = await loadAccessToken({ profile: args.profile });
3624
+ const client = await initOperatorClient(accessToken);
3591
3625
  const workspaceId = await loadWorkspaceId({
3592
3626
  workspaceId: args["workspace-id"],
3593
3627
  profile: args.profile
@@ -3640,7 +3674,8 @@ const createCommand$1 = defineAppCommand({
3640
3674
  }),
3641
3675
  run: async (args) => {
3642
3676
  await assertWritable({ profile: args.profile });
3643
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
3677
+ const accessToken = await loadAccessToken({ profile: args.profile });
3678
+ const client = await initOperatorClient(accessToken);
3644
3679
  const workspaceId = await loadWorkspaceId({
3645
3680
  workspaceId: args["workspace-id"],
3646
3681
  profile: args.profile
@@ -3670,7 +3705,8 @@ const deleteCommand$2 = defineAppCommand({
3670
3705
  }),
3671
3706
  run: async (args) => {
3672
3707
  await assertWritable({ profile: args.profile });
3673
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
3708
+ const accessToken = await loadAccessToken({ profile: args.profile });
3709
+ const client = await initOperatorClient(accessToken);
3674
3710
  const workspaceId = await loadWorkspaceId({
3675
3711
  workspaceId: args["workspace-id"],
3676
3712
  profile: args.profile
@@ -3715,7 +3751,8 @@ function vaultInfo(vault) {
3715
3751
  * @returns List of vaults
3716
3752
  */
3717
3753
  async function vaultList(options) {
3718
- const client = await initOperatorClient(await loadAccessToken({ profile: options?.profile }));
3754
+ const accessToken = await loadAccessToken({ profile: options?.profile });
3755
+ const client = await initOperatorClient(accessToken);
3719
3756
  const workspaceId = await loadWorkspaceId({
3720
3757
  workspaceId: options?.workspaceId,
3721
3758
  profile: options?.profile
@@ -4547,7 +4584,8 @@ function decideAction(obj) {
4547
4584
  }
4548
4585
  if (!fileExists) return { action: "restore" };
4549
4586
  if (currentContent !== null) {
4550
- if (hashContent(normalize ? normalize(currentContent) : currentContent) === existing.contentHash) return { action: "regenerate" };
4587
+ const normalizedContent = normalize ? normalize(currentContent) : currentContent;
4588
+ if (hashContent(normalizedContent) === existing.contentHash) return { action: "regenerate" };
4551
4589
  }
4552
4590
  if (force) return { action: "regenerate" };
4553
4591
  return {
@@ -5379,7 +5417,8 @@ const domainGetCommand = defineAppCommand({
5379
5417
  })
5380
5418
  }),
5381
5419
  run: async (args) => {
5382
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
5420
+ const accessToken = await loadAccessToken({ profile: args.profile });
5421
+ const client = await initOperatorClient(accessToken);
5383
5422
  const workspaceId = await loadWorkspaceId({
5384
5423
  workspaceId: args["workspace-id"],
5385
5424
  profile: args.profile
@@ -5419,7 +5458,8 @@ const domainListCommand = defineAppCommand({
5419
5458
  })
5420
5459
  }),
5421
5460
  run: async (args) => {
5422
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
5461
+ const accessToken = await loadAccessToken({ profile: args.profile });
5462
+ const client = await initOperatorClient(accessToken);
5423
5463
  const workspaceId = await loadWorkspaceId({
5424
5464
  workspaceId: args["workspace-id"],
5425
5465
  profile: args.profile
@@ -5471,7 +5511,8 @@ const getCommand = defineAppCommand({
5471
5511
  })
5472
5512
  }),
5473
5513
  run: async (args) => {
5474
- const client = await initOperatorClient(await loadAccessToken({ profile: args.profile }));
5514
+ const accessToken = await loadAccessToken({ profile: args.profile });
5515
+ const client = await initOperatorClient(accessToken);
5475
5516
  const workspaceId = await loadWorkspaceId({
5476
5517
  workspaceId: args["workspace-id"],
5477
5518
  profile: args.profile
@@ -5506,7 +5547,8 @@ const getCommand = defineAppCommand({
5506
5547
  * @returns List of static websites
5507
5548
  */
5508
5549
  async function listStaticWebsites(options) {
5509
- const client = await initOperatorClient(await loadAccessToken({ profile: options?.profile }));
5550
+ const accessToken = await loadAccessToken({ profile: options?.profile });
5551
+ const client = await initOperatorClient(accessToken);
5510
5552
  const workspaceId = await loadWorkspaceId({
5511
5553
  workspaceId: options?.workspaceId,
5512
5554
  profile: options?.profile
@@ -5597,13 +5639,15 @@ async function activateBaseline(migrationsDir, snapshot, namespace, rebaseline)
5597
5639
  force: true
5598
5640
  });
5599
5641
  }
5600
- loadSnapshot((await generateSchemaFile({
5642
+ const stagedSnapshot = {
5601
5643
  ...snapshot,
5602
5644
  namespace,
5603
5645
  version: 5,
5604
5646
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5605
5647
  rebaseline
5606
- }, stagingDir, 0)).filePath);
5648
+ };
5649
+ const result = await generateSchemaFile(stagedSnapshot, stagingDir, 0);
5650
+ loadSnapshot(result.filePath);
5607
5651
  await fsPromises.rename(resolvedMigrationsDir, backupDir);
5608
5652
  movedLiveDirectory = true;
5609
5653
  try {
@@ -5653,7 +5697,7 @@ async function rebaseline(options) {
5653
5697
  const currentHistoryId = reconstructSnapshotFromMigrations(target.migrationsDir, 0)?.rebaseline?.historyId ?? null;
5654
5698
  const initialFileState = captureMigrationFileState([target])[target.namespace];
5655
5699
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
5656
- const { defineApplication } = await import("../application-BZfk4HKm.mjs");
5700
+ const { defineApplication } = await import("../application-D4zOiLLa.mjs");
5657
5701
  const application = defineApplication({
5658
5702
  config,
5659
5703
  pluginManager
@@ -5676,7 +5720,8 @@ async function rebaseline(options) {
5676
5720
  const localSourceFiles = () => [config.path, ...loadFilesWithIgnores(targetService.config, configDir)];
5677
5721
  assertLocalTypesReady();
5678
5722
  const initialLocalFileState = captureFileState(localSourceFiles());
5679
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }));
5723
+ const accessToken = await loadAccessToken({ profile: options.profile });
5724
+ const client = await initOperatorClient(accessToken);
5680
5725
  const workspaceId = await loadWorkspaceId({
5681
5726
  workspaceId: options.workspaceId,
5682
5727
  profile: options.profile
@@ -5744,7 +5789,7 @@ async function rebaseline(options) {
5744
5789
  }
5745
5790
  assertValidMigrationFiles(target.migrationsDir, target.namespace);
5746
5791
  if (captureMigrationFileState([target])[target.namespace] !== initialFileState) throw new Error("Migration files changed while waiting for confirmation. Run the command again.");
5747
- if (captureFileState(localSourceFiles()) !== initialLocalFileState) throw new Error("Local TailorDB type or config files changed. Run the command again.");
5792
+ if (captureFileState(localSourceFiles()) !== initialLocalFileState) throw new Error("Local TailorDB table or config files changed. Run the command again.");
5748
5793
  assertLocalTypesReady();
5749
5794
  await assertConnectedWorkspaceReady(currentHistoryId, "confirmation");
5750
5795
  const rebaselineMarker = {
@@ -5794,16 +5839,20 @@ async function set(options) {
5794
5839
  logBetaWarning("tailordb migration");
5795
5840
  const migrationNumber = parseMigrationNumberArg(options.number);
5796
5841
  const { config } = await loadConfig(options.configPath);
5797
- const target = selectTargetNamespace(getNamespacesWithMigrations(config, path.dirname(config.path)), options.namespace);
5842
+ const configDir = path.dirname(config.path);
5843
+ const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);
5844
+ const target = selectTargetNamespace(namespacesWithMigrations, options.namespace);
5798
5845
  const targetNamespace = target.namespace;
5799
5846
  assertValidMigrationFiles(target.migrationsDir, targetNamespace);
5800
5847
  assertMigrationNumberExists(target.migrationsDir, migrationNumber);
5801
5848
  const historyId = reconstructSnapshotFromMigrations(target.migrationsDir, 0)?.rebaseline?.historyId;
5802
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }));
5803
- const trn = resourceTrn(await loadWorkspaceId({
5849
+ const accessToken = await loadAccessToken({ profile: options.profile });
5850
+ const client = await initOperatorClient(accessToken);
5851
+ const workspaceId = await loadWorkspaceId({
5804
5852
  workspaceId: options.workspaceId,
5805
5853
  profile: options.profile
5806
- }), "tailordb", targetNamespace);
5854
+ });
5855
+ const trn = resourceTrn(workspaceId, "tailordb", targetNamespace);
5807
5856
  const currentState = await fetchRemoteMigrationState(client, trn);
5808
5857
  const current = currentState.number;
5809
5858
  const currentMigration = current ?? 0;
@@ -5882,7 +5931,8 @@ function isStatusFailure(row) {
5882
5931
  }
5883
5932
  async function collectMigrationStatuses(options) {
5884
5933
  const { config } = await loadConfig(options.configPath);
5885
- const namespacesWithMigrations = getNamespacesWithMigrations(config, path.dirname(config.path));
5934
+ const configDir = path.dirname(config.path);
5935
+ const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);
5886
5936
  if (namespacesWithMigrations.length === 0) throw new Error("No TailorDB services with migrations configuration found");
5887
5937
  const targetNamespaces = options.namespace ? namespacesWithMigrations.filter((ns) => ns.namespace === options.namespace) : namespacesWithMigrations;
5888
5938
  if (targetNamespaces.length === 0) throw new Error(`Namespace "${options.namespace}" not found or does not have migrations configured`);
@@ -5918,7 +5968,8 @@ async function collectMigrationStatuses(options) {
5918
5968
  namespace,
5919
5969
  error: localFailures.get(namespace) ?? "Failed to read local migration history."
5920
5970
  }));
5921
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }));
5971
+ const accessToken = await loadAccessToken({ profile: options.profile });
5972
+ const client = await initOperatorClient(accessToken);
5922
5973
  const workspaceId = await loadWorkspaceId({
5923
5974
  workspaceId: options.workspaceId,
5924
5975
  profile: options.profile
@@ -6091,7 +6142,7 @@ async function fetchRemoteTypes(client, workspaceId, namespace) {
6091
6142
  async function assertMigrationsReproduceLocalTypes(loaded, target) {
6092
6143
  const { config, plugins } = loaded;
6093
6144
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
6094
- const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-BZfk4HKm.mjs");
6145
+ const { defineApplication, generatePluginFilesIfNeeded } = await import("../application-D4zOiLLa.mjs");
6095
6146
  const application = defineApplication({
6096
6147
  config,
6097
6148
  pluginManager
@@ -6103,7 +6154,7 @@ async function assertMigrationsReproduceLocalTypes(loaded, target) {
6103
6154
  await service.processNamespacePlugins();
6104
6155
  }
6105
6156
  const pluginExecutorFiles = generatePluginFilesIfNeeded(pluginManager, application.tailorDBServices, config.path);
6106
- const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-D1RCdzIL.mjs")).createExecutorService({
6157
+ const executorService = application.executorService ?? (pluginExecutorFiles.length > 0 ? (await import("../service-CaBPNDIZ.mjs")).createExecutorService({
6107
6158
  config: { files: [] },
6108
6159
  baseDir: path.dirname(config.path)
6109
6160
  }) : void 0);
@@ -6117,14 +6168,15 @@ async function assertMigrationsReproduceLocalTypes(loaded, target) {
6117
6168
  };
6118
6169
  const latestSnapshot = reconstructSnapshotFromMigrations(target.migrationsDir);
6119
6170
  if (!latestSnapshot) return manifestOptions;
6120
- const diff = compareLocalTypesWithSnapshot(latestSnapshot, createSnapshotFromLocalTypes(tailordbService.types, target.namespace).tables, target.namespace);
6171
+ const currentSnapshot = createSnapshotFromLocalTypes(tailordbService.types, target.namespace);
6172
+ const diff = compareLocalTypesWithSnapshot(latestSnapshot, currentSnapshot.tables, target.namespace);
6121
6173
  if (!hasChanges(diff)) return manifestOptions;
6122
6174
  logger.error(`Migration history does not reproduce the current local schema for namespace ${styles.bold(target.namespace)}:`);
6123
6175
  logger.log(formatMigrationDiff(diff));
6124
6176
  logger.newline();
6125
6177
  logger.info("This usually means one of the following:");
6126
- logger.info(" - Migration files were edited and replaying them no longer matches the type definitions — fix the migration files.", { mode: "plain" });
6127
- logger.info(" - Type definitions changed without a new migration — run 'tailor tailordb migration generate' first.", { mode: "plain" });
6178
+ logger.info(" - Migration files were edited and replaying them no longer matches the table definitions — fix the migration files.", { mode: "plain" });
6179
+ logger.info(" - Table definitions changed without a new migration — run 'tailor tailordb migration generate' first.", { mode: "plain" });
6128
6180
  logger.newline();
6129
6181
  throw new Error("Refusing to sync: the migration history must reproduce the current local schema before it can be applied to the remote.");
6130
6182
  }
@@ -6148,13 +6200,16 @@ async function sync(options) {
6148
6200
  const targetVersion = parseMigrationNumberArg(options.number);
6149
6201
  const loaded = await loadConfig(options.configPath);
6150
6202
  const { config } = loaded;
6151
- const target = selectTargetNamespace(getNamespacesWithMigrations(config, path.dirname(config.path)), options.namespace);
6203
+ const configDir = path.dirname(config.path);
6204
+ const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);
6205
+ const target = selectTargetNamespace(namespacesWithMigrations, options.namespace);
6152
6206
  assertValidMigrationFiles(target.migrationsDir, target.namespace);
6153
6207
  const latest = assertMigrationNumberExists(target.migrationsDir, targetVersion);
6154
6208
  const snapshot = reconstructSnapshotFromMigrations(target.migrationsDir, targetVersion);
6155
6209
  if (!snapshot) throw new Error(`No initial schema snapshot found in ${target.migrationsDir}. Expected 0000/schema.json.`);
6156
6210
  const manifestOptions = await assertMigrationsReproduceLocalTypes(loaded, target);
6157
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }));
6211
+ const accessToken = await loadAccessToken({ profile: options.profile });
6212
+ const client = await initOperatorClient(accessToken);
6158
6213
  const workspaceId = await loadWorkspaceId({
6159
6214
  workspaceId: options.workspaceId,
6160
6215
  profile: options.profile
@@ -6162,7 +6217,8 @@ async function sync(options) {
6162
6217
  const trn = resourceTrn(workspaceId, "tailordb", target.namespace);
6163
6218
  const current = await fetchRemoteMigrationNumber(client, trn);
6164
6219
  const remoteTypes = await fetchRemoteTypes(client, workspaceId, target.namespace);
6165
- const { creates, updates, deletes } = compareSnapshotWithRemote(snapshot, new Set(remoteTypes.map((t) => t.name)));
6220
+ const existingTypeNames = new Set(remoteTypes.map((t) => t.name));
6221
+ const { creates, updates, deletes } = compareSnapshotWithRemote(snapshot, existingTypeNames);
6166
6222
  const remoteGqlPermissions = await fetchRemoteGqlPermissions(client, workspaceId, target.namespace);
6167
6223
  const remoteGqlPermissionTypes = new Set(remoteGqlPermissions.map((p) => p.typeName));
6168
6224
  const desiredGqlPermissions = Object.entries(snapshot.tables).flatMap(([typeName, snapshotType]) => snapshotType.permissions?.gql ? [{
@@ -6175,16 +6231,16 @@ async function sync(options) {
6175
6231
  logger.info(`Namespace: ${styles.bold(target.namespace)}`);
6176
6232
  logger.log(` Current migration: ${current === null ? "<unset>" : styles.bold(formatMigrationNumber(current))}`);
6177
6233
  logger.log(` Target migration: ${styles.bold(formatMigrationNumber(targetVersion))}`);
6178
- logger.log(` Types to create: ${styles.bold(String(creates.length))}`);
6179
- logger.log(` Types to update: ${styles.bold(String(updates.length))}`);
6180
- logger.log(` Types to delete: ${styles.bold(String(deletes.length))}`);
6234
+ logger.log(` Tables to create: ${styles.bold(String(creates.length))}`);
6235
+ logger.log(` Tables to update: ${styles.bold(String(updates.length))}`);
6236
+ logger.log(` Tables to delete: ${styles.bold(String(deletes.length))}`);
6181
6237
  logger.log(` GQL permissions to set: ${styles.bold(String(desiredGqlPermissions.length))}`);
6182
6238
  logger.log(` GQL permissions to delete: ${styles.bold(String(gqlPermissionDeletes.length))}`);
6183
6239
  logger.newline();
6184
- if (creates.length + updates.length + deletes.length + desiredGqlPermissions.length + gqlPermissionDeletes.length === 0) logger.info("No types to apply; only the migration label will be updated.");
6240
+ if (creates.length + updates.length + deletes.length + desiredGqlPermissions.length + gqlPermissionDeletes.length === 0) logger.info("No tables to apply; only the migration label will be updated.");
6185
6241
  else {
6186
- logger.warn("This operation will overwrite remote TailorDB types to match the selected snapshot.");
6187
- if (deletes.length > 0) logger.warn("Existing data in deleted types will be lost.");
6242
+ logger.warn("This operation will overwrite remote TailorDB tables to match the selected snapshot.");
6243
+ if (deletes.length > 0) logger.warn("Existing data in deleted tables will be lost.");
6188
6244
  logger.newline();
6189
6245
  }
6190
6246
  logger.warn("Sync never runs migrate.ts scripts; it only applies the schema snapshot and moves the migration label.");
@@ -6209,7 +6265,7 @@ async function sync(options) {
6209
6265
  const manifests = generateAllTypeManifestsFromSnapshot(snapshot, manifestOptions);
6210
6266
  const manifestFor = (typeName) => {
6211
6267
  const manifest = manifests.get(typeName);
6212
- if (!manifest) throw new Error(`Internal error: no manifest generated for type "${typeName}". No changes were applied.`);
6268
+ if (!manifest) throw new Error(`Internal error: no manifest generated for table "${typeName}". No changes were applied.`);
6213
6269
  return manifest;
6214
6270
  };
6215
6271
  const createManifests = creates.map((typeName) => manifestFor(typeName));
@@ -6291,7 +6347,7 @@ const syncCommand = defineAppCommand({
6291
6347
  //#endregion
6292
6348
  //#region src/cli/commands/tailordb/migrate/test-runtime.ts
6293
6349
  const CLONE_POLL_INTERVAL = 1e3;
6294
- const CLONE_TIMEOUT = 300 * 1e3;
6350
+ const CLONE_TIMEOUT = 3e5;
6295
6351
  function delay(milliseconds) {
6296
6352
  return milliseconds > 0 ? new Promise((resolve) => setTimeout(resolve, milliseconds)) : Promise.resolve();
6297
6353
  }
@@ -6502,7 +6558,8 @@ async function assertSourceBaselineFresh(state, prepared, sourceWorkspaceId) {
6502
6558
  for (const input of unmigratedInputs) {
6503
6559
  const snapshot = prepared.baselineSnapshots.get(input.namespace);
6504
6560
  if (!snapshot) continue;
6505
- if (compareSnapshots(snapshot, await fetchRemoteSchemaSnapshot(state.client, sourceWorkspaceId, input.namespace)).changes.length > 0) throw new Error(`Source namespace "${input.namespace}" schema changed after migration test preparation. Run the migration test again.`);
6561
+ const current = await fetchRemoteSchemaSnapshot(state.client, sourceWorkspaceId, input.namespace);
6562
+ if (compareSnapshots(snapshot, current).changes.length > 0) throw new Error(`Source namespace "${input.namespace}" schema changed after migration test preparation. Run the migration test again.`);
6506
6563
  }
6507
6564
  }
6508
6565
  /**
@@ -6553,7 +6610,9 @@ async function prepareMigrationTest(options) {
6553
6610
  }
6554
6611
  if (options.assertionPath) assertAssertionScript(options.assertionPath);
6555
6612
  const inputs = loaded.application.tailorDBServices.map(toTailorDBDeployInput);
6556
- const client = await initOperatorClient(await loadAccessToken({ profile: options.profile }), await loadPlatformClientConfig({ profile: options.profile }));
6613
+ const accessToken = await loadAccessToken({ profile: options.profile });
6614
+ const platformConfig = await loadPlatformClientConfig({ profile: options.profile });
6615
+ const client = await initOperatorClient(accessToken, platformConfig);
6557
6616
  const sourceWorkspaceId = await loadWorkspaceId({
6558
6617
  workspaceId: options.workspaceId,
6559
6618
  profile: options.profile
@@ -6644,7 +6703,8 @@ function createMigrationTestDependencies() {
6644
6703
  return prepared;
6645
6704
  },
6646
6705
  createWorkspace: async (prepared) => {
6647
- const workspace = await createValidatedWorkspaceWithClient(stateOrThrow(runtimeState).client, prepared.temporaryWorkspace);
6706
+ const state = stateOrThrow(runtimeState);
6707
+ const workspace = await createValidatedWorkspaceWithClient(state.client, prepared.temporaryWorkspace);
6648
6708
  logger.info(`Created temporary workspace ${workspace.name} (${workspace.id}).`);
6649
6709
  return {
6650
6710
  id: workspace.id,
@@ -6995,12 +7055,13 @@ function buildValidationReports(options) {
6995
7055
  */
6996
7056
  async function collectValidationReports(options) {
6997
7057
  const { config, plugins } = await loadConfig(options.configPath);
6998
- const namespacesWithMigrations = getNamespacesWithMigrations(config, path.dirname(config.path));
7058
+ const configDir = path.dirname(config.path);
7059
+ const namespacesWithMigrations = getNamespacesWithMigrations(config, configDir);
6999
7060
  if (namespacesWithMigrations.length === 0) throw new Error("No TailorDB services with migrations configuration found");
7000
7061
  const targetNamespaces = options.namespace ? namespacesWithMigrations.filter((ns) => ns.namespace === options.namespace) : namespacesWithMigrations;
7001
7062
  if (targetNamespaces.length === 0) throw new Error(`Namespace "${options.namespace}" not found or does not have migrations configured`);
7002
7063
  const pluginManager = plugins.length > 0 ? new PluginManager(plugins) : void 0;
7003
- const { defineApplication } = await import("../application-BZfk4HKm.mjs");
7064
+ const { defineApplication } = await import("../application-D4zOiLLa.mjs");
7004
7065
  const application = defineApplication({
7005
7066
  config,
7006
7067
  pluginManager
@@ -7034,10 +7095,13 @@ async function collectValidationReports(options) {
7034
7095
  if (checkableNamespaces.length === 0) return { reports: buildValidationReports(localReportOptions) };
7035
7096
  let remoteResults;
7036
7097
  try {
7037
- remoteResults = await verifyRemoteSchema(await initOperatorClient(await loadAccessToken({ profile: options.profile })), await loadWorkspaceId({
7098
+ const accessToken = await loadAccessToken({ profile: options.profile });
7099
+ const client = await initOperatorClient(accessToken);
7100
+ const workspaceId = await loadWorkspaceId({
7038
7101
  workspaceId: options.workspaceId,
7039
7102
  profile: options.profile
7040
- }), checkableNamespaces, config, tailorDBInputs);
7103
+ });
7104
+ remoteResults = await verifyRemoteSchema(client, workspaceId, checkableNamespaces, config, tailorDBInputs);
7041
7105
  } catch (remoteError) {
7042
7106
  return {
7043
7107
  reports: buildValidationReports(localReportOptions),
@@ -7060,12 +7124,13 @@ function printValidationReports(reports) {
7060
7124
  }
7061
7125
  logger.log(` Migration files: ${styles.success("OK")}`);
7062
7126
  const local = report.localSchema;
7063
- if (local?.hasDiff) if (local.diff) {
7064
- logger.log(` Local schema: ${styles.error("changes not in migration files")}`);
7065
- logger.log(` ${formatDiffSummary(local.diff)}`);
7066
- logger.log(formatMigrationDiff(local.diff));
7067
- } else logger.log(` Local schema: ${styles.error("no migration snapshot found")}`);
7068
- else logger.log(` Local schema: ${styles.success("OK")}`);
7127
+ if (local?.hasDiff) {
7128
+ if (local.diff) {
7129
+ logger.log(` Local schema: ${styles.error("changes not in migration files")}`);
7130
+ logger.log(` ${formatDiffSummary(local.diff)}`);
7131
+ logger.log(formatMigrationDiff(local.diff));
7132
+ } else logger.log(` Local schema: ${styles.error("no migration snapshot found")}`);
7133
+ } else logger.log(` Local schema: ${styles.success("OK")}`);
7069
7134
  const remote = report.remoteSchema;
7070
7135
  if (remote?.skipped === "check_failed") logger.log(` Remote schema: ${styles.error("not checked")}`);
7071
7136
  else if (remote?.checkpointRepair) logger.log(` Remote schema: ${styles.success("OK")} (next deploy will reset the checkpoint to 0000 from ${formatMigrationNumber(remote.checkpointRepair.from)})`);
@@ -7078,14 +7143,16 @@ function printValidationReports(reports) {
7078
7143
  else if (remote?.skipped === "no_snapshot") logger.log(` Remote schema: ${styles.dim(`skipped (no local snapshot for remote migration ${formatMigrationNumber(remote.remoteMigrationNumber)})`)}`);
7079
7144
  else if (remote) logger.log(` Remote schema: ${styles.success("OK")} (remote migration: ${formatMigrationNumber(remote.remoteMigrationNumber)})`);
7080
7145
  const acknowledgments = report.warningAcknowledgments;
7081
- if (acknowledgments) if (acknowledgments.valid) logger.log(` Warning acknowledgments: ${styles.success("OK")}`);
7082
- else {
7083
- logger.log(` Warning acknowledgments: ${styles.error("missing for pending migration(s) with possible data loss")}`);
7084
- for (const migration of acknowledgments.missing) {
7085
- const label = formatMigrationNumber(migration.migrationNumber);
7086
- for (const warning of migration.warnings) {
7087
- const field = warning.fieldName ? `.${warning.fieldName}` : "";
7088
- logger.log(` ${label}: ${warning.tableName}${field}: ${warning.reason}`);
7146
+ if (acknowledgments) {
7147
+ if (acknowledgments.valid) logger.log(` Warning acknowledgments: ${styles.success("OK")}`);
7148
+ else {
7149
+ logger.log(` Warning acknowledgments: ${styles.error("missing for pending migration(s) with possible data loss")}`);
7150
+ for (const migration of acknowledgments.missing) {
7151
+ const label = formatMigrationNumber(migration.migrationNumber);
7152
+ for (const warning of migration.warnings) {
7153
+ const field = warning.fieldName ? `.${warning.fieldName}` : "";
7154
+ logger.log(` ${label}: ${warning.tableName}${field}: ${warning.reason}`);
7155
+ }
7089
7156
  }
7090
7157
  }
7091
7158
  }
@@ -7128,7 +7195,7 @@ async function validate(options) {
7128
7195
  }
7129
7196
  const validateCommand = defineAppCommand({
7130
7197
  name: "validate",
7131
- description: "Validate the full migration history, unreviewed generated migration scripts, and schema drift (local types vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.",
7198
+ description: "Validate the full migration history, unreviewed generated migration scripts, and schema drift (local tables vs. migration snapshot, remote schema vs. migration checkpoint) without deploying. This includes the migration and schema-drift checks used by 'deploy' and exits with a non-zero code when issues are found.",
7132
7199
  args: z.strictObject({
7133
7200
  ...deploymentArgs,
7134
7201
  namespace: arg(z.string().optional(), {
@@ -7210,7 +7277,7 @@ const upgradeCommand = defineAppCommand({
7210
7277
  run: async (args) => {
7211
7278
  const { initTelemetry } = await import("../telemetry-CkbkeJxl.mjs");
7212
7279
  await initTelemetry();
7213
- const { upgrade } = await import("../service-hZskxZmg.mjs");
7280
+ const { upgrade } = await import("../service-LTfp03ZZ.mjs");
7214
7281
  await upgrade({
7215
7282
  from: args.from,
7216
7283
  dryRun: args["dry-run"],
@@ -7623,7 +7690,8 @@ initCrashReporting();
7623
7690
  const packageJson = await readPackageJson();
7624
7691
  const cliName = Object.keys(packageJson.bin ?? {})[0] || "tailor";
7625
7692
  const packageName = packageJson.name ?? "@tailor-platform/sdk";
7626
- const bundledSkillsDir = resolve(dirname(await resolvePackageJSON(import.meta.url)), "agent-skills");
7693
+ const packageJsonPath = await resolvePackageJSON(import.meta.url);
7694
+ const bundledSkillsDir = resolve(dirname(packageJsonPath), "agent-skills");
7627
7695
  function defaultSkillsRunToAdd(command) {
7628
7696
  const add = (command.subCommands ?? {}).add;
7629
7697
  return {
@@ -7719,7 +7787,7 @@ runMain(mainCommand, {
7719
7787
  if (isVerbose() && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
7720
7788
  } else logger.error(`Unknown error: ${error}`);
7721
7789
  if (!isCLIError(error) && (!(error instanceof Error) || error instanceof TypeError || error instanceof RangeError)) {
7722
- const { reportCrash } = await import("../crashreport-CINZ5dVN.mjs");
7790
+ const { reportCrash } = await import("../crashreport-Cd4TqfZq.mjs");
7723
7791
  await reportCrash(error, "handledError");
7724
7792
  }
7725
7793
  }