@tailor-platform/sdk 1.81.0 → 1.83.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 (58) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/application-CP7JKG9R.mjs +3 -0
  3. package/dist/{application-DDe0er6L.mjs → application-Cp0FxIm2.mjs} +26 -10
  4. package/dist/application-Cp0FxIm2.mjs.map +1 -0
  5. package/dist/cli/index.mjs +9 -9
  6. package/dist/cli/lib.mjs +2 -2
  7. package/dist/cli/skills.mjs +1 -1
  8. package/dist/completion/zsh-worker.zsh +1 -1
  9. package/dist/configure/config/types.d.mts +3 -1
  10. package/dist/configure/index.mjs +3 -3
  11. package/dist/configure/index.mjs.map +1 -1
  12. package/dist/configure/services/workflow/execution-policy.d.mts +2 -2
  13. package/dist/{crashreport-BNWUM6Kf.mjs → crashreport-DMYuHnBN.mjs} +2 -2
  14. package/dist/{crashreport-BNWUM6Kf.mjs.map → crashreport-DMYuHnBN.mjs.map} +1 -1
  15. package/dist/{crashreport-BafWvjjX.mjs → crashreport-ecqnz51B.mjs} +1 -1
  16. package/dist/{globals-DUqEetIh.mjs → globals-DraXTdqg.mjs} +6 -5
  17. package/dist/globals-DraXTdqg.mjs.map +1 -0
  18. package/dist/{logger-BwS4ppwO.mjs → logger-CXQq9YIp.mjs} +110 -13
  19. package/dist/logger-CXQq9YIp.mjs.map +1 -0
  20. package/dist/{logger-B-fqZe2W.mjs → logger-t5ASCDZm.mjs} +6 -7
  21. package/dist/{logger-B-fqZe2W.mjs.map → logger-t5ASCDZm.mjs.map} +1 -1
  22. package/dist/{register-typescript-runtime-QAWucsg0.mjs → register-typescript-runtime-CCHyKeXO.mjs} +129 -19
  23. package/dist/register-typescript-runtime-CCHyKeXO.mjs.map +1 -0
  24. package/dist/{registry-CXi7rJq7.mjs → registry-Ct0Wgxp1.mjs} +3 -3
  25. package/dist/registry-Ct0Wgxp1.mjs.map +1 -0
  26. package/dist/runtime/index.mjs +2 -2
  27. package/dist/runtime/logger.mjs +1 -1
  28. package/dist/runtime/workflow.d.mts +39 -21
  29. package/dist/runtime/workflow.mjs +2 -2
  30. package/dist/{service-CDPatibu.mjs → service-B0MaodSg.mjs} +2 -2
  31. package/dist/{service-CDPatibu.mjs.map → service-B0MaodSg.mjs.map} +1 -1
  32. package/dist/{service-Cp0I7ZFe.mjs → service-CIGSGg9I.mjs} +2 -2
  33. package/dist/{service-Cp0I7ZFe.mjs.map → service-CIGSGg9I.mjs.map} +1 -1
  34. package/dist/service-KnAiVofD.mjs +3 -0
  35. package/dist/utils/test/index.mjs +18 -12
  36. package/dist/utils/test/index.mjs.map +1 -1
  37. package/dist/utils/test/mock.d.mts +2 -2
  38. package/dist/vitest/environment.mjs +1 -1
  39. package/dist/vitest/index.mjs +30 -24
  40. package/dist/vitest/index.mjs.map +1 -1
  41. package/dist/vitest/mocks/workflow.d.mts +20 -15
  42. package/dist/vitest/setup.mjs +1 -1
  43. package/dist/{workflow-CkIDJpdg.mjs → workflow-B2mwc7aT.mjs} +17 -9
  44. package/dist/workflow-B2mwc7aT.mjs.map +1 -0
  45. package/docs/configuration.md +3 -1
  46. package/docs/runtime.md +1 -1
  47. package/docs/services/tailordb-migration.md +5 -3
  48. package/docs/services/workflow.md +2 -2
  49. package/docs/testing.md +1 -1
  50. package/package.json +3 -3
  51. package/dist/application-B1_7Wm37.mjs +0 -3
  52. package/dist/application-DDe0er6L.mjs.map +0 -1
  53. package/dist/globals-DUqEetIh.mjs.map +0 -1
  54. package/dist/logger-BwS4ppwO.mjs.map +0 -1
  55. package/dist/register-typescript-runtime-QAWucsg0.mjs.map +0 -1
  56. package/dist/registry-CXi7rJq7.mjs.map +0 -1
  57. package/dist/service-Cg7Qibit.mjs +0 -3
  58. package/dist/workflow-CkIDJpdg.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import { t as db } from "./schema-CYrle8JZ.mjs";
2
2
  import { $ as CreateAuthHookRequestSchema, B as IdPLang, Bt as Subgraph_ServiceType, C as CreateStaticWebsiteRequestSchema, Ct as AuthInvokerSchema, D as CreateSecretManagerSecretRequestSchema, Dt as AuthSCIMAttribute_Type, Et as AuthSCIMAttribute_Mutability, Ft as CreateApplicationRequestSchema, H as IdPPermissionPermit, Ht as UpdateAIGatewayRequestSchema, I as PipelineResolver_OperationType, It as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, Jt as FilterSchema, K as CreateExecutorExecutorRequestSchema, Kt as ConditionSchema, L as CreateIdPServiceRequestSchema, Lt as UpdateApplicationRequestSchema, M as CreatePipelineServiceRequestSchema, Mt as UserProfileProviderConfig_UserProfileProviderType, N as UpdatePipelineResolverRequestSchema, O as CreateSecretManagerVaultRequestSchema, Ot as AuthSCIMAttribute_Uniqueness, P as UpdatePipelineServiceRequestSchema, Q as CreateAuthConnectionRequestSchema, R as UpdateIdPServiceRequestSchema, S as AddCustomDomainRequestSchema, St as AuthIDPConfig_AuthType, Tt as AuthOAuth2Client_GrantType, U as FunctionExecution_Status, V as IdPPermissionOperator, Vt as CreateAIGatewayRequestSchema, X as ExecutorTargetType, Y as ExecutorJobStatus, Yt as PageDirection, Z as ExecutorTriggerType, _ as TailorDBGQLPermission_Permit, _t as UpdateUserProfileConfigRequestSchema, a as CreateWorkflowRequestSchema, at as CreateAuthServiceRequestSchema, b as TailorDBType_Permission_Permit, bt as AuthConnection_Type, ct as UpdateAuthConnectionRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as UpdateAuthMachineUserRequestSchema, et as CreateAuthIDPConfigRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as UpdateAuthOAuth2ClientRequestSchema, g as TailorDBGQLPermission_Operator, gt as UpdateTenantConfigRequestSchema, h as TailorDBGQLPermission_Action, ht as UpdateAuthServiceRequestSchema, i as CreateWorkflowJobFunctionRequestSchema, it as CreateAuthSCIMResourceRequestSchema, j as CreatePipelineResolverRequestSchema, jt as TenantProviderConfig_TenantProviderType, k as UpdateSecretManagerSecretRequestSchema, kt as AuthSCIMConfig_AuthorizationType, l as WorkflowExecution_Status, lt as UpdateAuthHookRequestSchema, mt as UpdateAuthSCIMResourceRequestSchema, nt as CreateAuthOAuth2ClientRequestSchema, o as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as CreateTenantConfigRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as UpdateAuthSCIMConfigRequestSchema, q as UpdateExecutorExecutorRequestSchema, qt as Condition_Operator, r as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, rt as CreateAuthSCIMConfigRequestSchema, s as UpdateWorkflowRequestSchema, st as CreateUserProfileConfigRequestSchema, t as WorkspacePlatformUserRole, tt as CreateAuthMachineUserRequestSchema, u as WorkflowJobExecution_Status, ut as UpdateAuthIDPConfigRequestSchema, v as TailorDBTypeSchema, w as UpdateStaticWebsiteRequestSchema, wt as AuthOAuth2Client_ClientType, x as TailorDBType_PermitAction, xt as AuthHookPoint, y as TailorDBType_Permission_Operator, yt as AuthConnection_Status, zt as ApplicationSchemaUpdateAttemptStatus } from "./workspace_resource_pb-UGK1SSn_.mjs";
3
3
  import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
4
- import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-BwS4ppwO.mjs";
5
- import { A as defaultPlatformBaseUrl, B as getPlatformBaseUrl, C as getPluginGenerationDependencies, D as hashContent, E as getDistDir, G as rememberPlatformConfigForToken, H as initOperatorClient, J as createApplyLimiter, K as resolveStaticWebsiteUrls, L as getConsoleBaseUrl, M as fetchAllTolerant, N as fetchMachineUserToken, O as hashFile, P as fetchPaged, R as getOAuth2ClientId, T as createBundleCache, U as isDefaultPlatform, V as initOAuth2Client, W as normalizeBaseUrl, Y as LOG_LEVELS, _ as stringifyFunction, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, g as TailorDBTypeSchema$1, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, j as fetchAll, l as HTTP_METHODS, m as assertUniqueLocalTailorDBTypeNames, n as generatePluginFilesIfNeeded, o as WorkflowJobFunctionExecutionPolicySchema, q as byName, r as loadApplication, t as defineApplication, v as resolveTSConfigWithFallback, w as hasGenerationHooks, y as platformBundleDefinePlugin, z as getOrNull } from "./application-DDe0er6L.mjs";
6
- import { o as loadFilesWithIgnores, s as functionSchema, t as createExecutorService } from "./service-CDPatibu.mjs";
4
+ import { a as parseBoolean, i as symbols, n as logger, o as renderTable, r as styles, t as CIPromptError } from "./logger-CXQq9YIp.mjs";
5
+ import { A as defaultPlatformBaseUrl, B as getPlatformBaseUrl, C as getPluginGenerationDependencies, D as hashContent, E as getDistDir, G as rememberPlatformConfigForToken, H as initOperatorClient, J as createApplyLimiter, K as resolveStaticWebsiteUrls, L as getConsoleBaseUrl, M as fetchAllTolerant, N as fetchMachineUserToken, O as hashFile, P as fetchPaged, R as getOAuth2ClientId, T as createBundleCache, U as isDefaultPlatform, V as initOAuth2Client, W as normalizeBaseUrl, Y as LOG_LEVELS, _ as stringifyFunction, d as buildExecutorArgsExpr, f as buildResolverOperationHookExpr, g as TailorDBTypeSchema$1, h as assertUniqueTailorDBTypeNamesWithExternal, i as resolverBundleKey, j as fetchAll, l as HTTP_METHODS, m as assertUniqueLocalTailorDBTypeNames, n as generatePluginFilesIfNeeded, o as WorkflowJobFunctionExecutionPolicySchema, q as byName, r as loadApplication, t as defineApplication, v as resolveTSConfigWithFallback, w as hasGenerationHooks, y as platformBundleDefinePlugin, z as getOrNull } from "./application-Cp0FxIm2.mjs";
6
+ import { o as loadFilesWithIgnores, s as functionSchema, t as createExecutorService } from "./service-B0MaodSg.mjs";
7
7
  import { n as enumConstantsPlugin, t as EnumConstantsGeneratorID } from "./enum-constants-j9QBF0cB.mjs";
8
8
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
9
9
  import { n as fileUtilsPlugin, t as FileUtilsGeneratorID } from "./file-utils-DcyIPFQh.mjs";
@@ -25,7 +25,6 @@ import { ValueSchema, timestampDate } from "@bufbuild/protobuf/wkt";
25
25
  import * as path from "pathe";
26
26
  import { basename, dirname, join, resolve } from "pathe";
27
27
  import { formatDistanceToNowStrict } from "date-fns";
28
- import { getBorderCharacters, table } from "table";
29
28
  import { pathToFileURL } from "node:url";
30
29
  import * as os from "node:os";
31
30
  import { tmpdir } from "node:os";
@@ -7965,6 +7964,29 @@ function compareTypeFields(ctx, typeName, prevType, currType) {
7965
7964
  }
7966
7965
  }
7967
7966
  /**
7967
+ * Determine if a type-level index change is breaking. Mirrors the field-level
7968
+ * unique reasoning: enforcing a unique constraint over existing rows can fail
7969
+ * on duplicates, so both adding a unique index and re-pointing an existing
7970
+ * unique index at a different field set require a data migration.
7971
+ * @param {string} typeName - Name of the type containing the index
7972
+ * @param {string} indexName - Name of the index being changed
7973
+ * @param {SnapshotIndexConfig | undefined} oldIndex - Old index configuration
7974
+ * @param {SnapshotIndexConfig | undefined} newIndex - New index configuration
7975
+ * @returns {BreakingChangeInfo | null} Breaking change info or null if not breaking
7976
+ */
7977
+ function isBreakingIndexChange(typeName, indexName, oldIndex, newIndex) {
7978
+ if (!newIndex || !(newIndex.unique ?? false)) return null;
7979
+ if (!oldIndex || !(oldIndex.unique ?? false)) return {
7980
+ typeName,
7981
+ reason: `Unique constraint added to index "${indexName}"`
7982
+ };
7983
+ if (JSON.stringify(oldIndex.fields.toSorted()) !== JSON.stringify(newIndex.fields.toSorted())) return {
7984
+ typeName,
7985
+ reason: `Unique index fields changed on index "${indexName}"`
7986
+ };
7987
+ return null;
7988
+ }
7989
+ /**
7968
7990
  * Compare type-level indexes
7969
7991
  * @param {DiffContext} ctx - Diff context
7970
7992
  * @param {string} typeName - Type name
@@ -7975,12 +7997,16 @@ function compareTypeFields(ctx, typeName, prevType, currType) {
7975
7997
  function compareIndexes(ctx, typeName, oldIndexes, newIndexes) {
7976
7998
  const oldKeys = new Set(Object.keys(oldIndexes || {}));
7977
7999
  const newKeys = new Set(Object.keys(newIndexes || {}));
7978
- for (const [indexName, indexConfig] of Object.entries(newIndexes ?? {})) if (!oldKeys.has(indexName)) ctx.changes.push({
7979
- kind: "index_added",
7980
- typeName,
7981
- indexName,
7982
- after: indexConfig
7983
- });
8000
+ for (const [indexName, indexConfig] of Object.entries(newIndexes ?? {})) if (!oldKeys.has(indexName)) {
8001
+ ctx.changes.push({
8002
+ kind: "index_added",
8003
+ typeName,
8004
+ indexName,
8005
+ after: indexConfig
8006
+ });
8007
+ const breaking = isBreakingIndexChange(typeName, indexName, void 0, indexConfig);
8008
+ if (breaking) ctx.breakingChanges.push(breaking);
8009
+ }
7984
8010
  for (const [indexName, indexConfig] of Object.entries(oldIndexes ?? {})) if (!newKeys.has(indexName)) ctx.changes.push({
7985
8011
  kind: "index_removed",
7986
8012
  typeName,
@@ -8003,6 +8029,8 @@ function compareIndexes(ctx, typeName, oldIndexes, newIndexes) {
8003
8029
  before: oldIndex,
8004
8030
  after: newIndex
8005
8031
  });
8032
+ const breaking = isBreakingIndexChange(typeName, indexName, oldIndex, newIndex);
8033
+ if (breaking) ctx.breakingChanges.push(breaking);
8006
8034
  }
8007
8035
  }
8008
8036
  }
@@ -9327,6 +9355,12 @@ function protoGqlOperand(operand) {
9327
9355
  * - `field_modified` optional→required, unique constraint added, enum
9328
9356
  * value removed: keep the looser side until Post-phase.
9329
9357
  *
9358
+ * and the type-level index adjustments:
9359
+ *
9360
+ * - `index_added` with `unique: true`: withhold the index until Post-phase.
9361
+ * - `index_modified` that gains a unique constraint or re-points a unique
9362
+ * index at different fields: keep the previous definition until Post-phase.
9363
+ *
9330
9364
  * Type-level deletions (`type_removed`) are handled by the deploy flow,
9331
9365
  * which retains the type until Post-phase rather than via this module.
9332
9366
  *
@@ -9408,6 +9442,45 @@ function applyPreMigrationFieldAdjustments(fields, typeChanges) {
9408
9442
  }
9409
9443
  }
9410
9444
  }
9445
+ /**
9446
+ * Build a map of type-level index changes that require pre-migration schema
9447
+ * adjustment (the breaking ones — see {@link isBreakingIndexChange}).
9448
+ * @param {PendingMigration[]} pendingMigrations - Pending migrations to scan
9449
+ * @returns {PreMigrationIndexChangesMap} Map of changes keyed by typeName/indexName
9450
+ */
9451
+ function buildPreMigrationIndexChangesMap(pendingMigrations) {
9452
+ const map = /* @__PURE__ */ new Map();
9453
+ for (const migration of pendingMigrations) for (const change of migration.diff.changes) {
9454
+ if (change.kind !== "index_added" && change.kind !== "index_modified") continue;
9455
+ const before = change.kind === "index_modified" ? change.before : void 0;
9456
+ if (!isBreakingIndexChange(change.typeName, change.indexName, before, change.after)) continue;
9457
+ const perType = map.get(change.typeName) ?? /* @__PURE__ */ new Map();
9458
+ perType.set(change.indexName, change);
9459
+ map.set(change.typeName, perType);
9460
+ }
9461
+ return map;
9462
+ }
9463
+ /**
9464
+ * Apply pre-migration schema adjustments to a type's index map in place.
9465
+ *
9466
+ * The indexes map is the proto-shape `TailorDBType.schema.indexes` that will
9467
+ * be sent in the Pre-phase. We mutate it so that:
9468
+ *
9469
+ * - Newly added unique indexes are withheld until Post-phase.
9470
+ * - Modified indexes keep their previous definition until Post-phase.
9471
+ *
9472
+ * @param {Record<string, MessageInitShape<typeof TailorDBType_IndexSchema>>} indexes - Index map to adjust (mutated in place)
9473
+ * @param {Map<string, IndexDiffChange>} typeIndexChanges - Changes for this type, keyed by indexName
9474
+ */
9475
+ function applyPreMigrationIndexAdjustments(indexes, typeIndexChanges) {
9476
+ for (const [indexName, change] of typeIndexChanges) {
9477
+ if (change.kind === "index_added") {
9478
+ delete indexes[indexName];
9479
+ continue;
9480
+ }
9481
+ if (change.kind === "index_modified") indexes[indexName] = convertIndexToProto(change.before);
9482
+ }
9483
+ }
9411
9484
 
9412
9485
  //#endregion
9413
9486
  //#region src/cli/commands/tailordb/migrate/types.ts
@@ -10402,6 +10475,7 @@ async function awaitAllSettledOrThrow(promises) {
10402
10475
  */
10403
10476
  async function executeSingleMigrationPrePhase(client, changeSet, migration, tailorDBInputs, executorUsedTypes) {
10404
10477
  const preMigrationChanges = buildPreMigrationChangesMap([migration]);
10478
+ const preMigrationIndexChanges = buildPreMigrationIndexChangesMap([migration]);
10405
10479
  const affectedTypes = getAffectedTypeNames(migration);
10406
10480
  const createdBeforeMigration = new Set(processedTypes.created);
10407
10481
  for (const create of changeSet.type.creates) {
@@ -10413,6 +10487,8 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration, tail
10413
10487
  clonedRequest.tailordbType = snapshotType;
10414
10488
  const typeChanges = preMigrationChanges.get(typeName);
10415
10489
  if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
10490
+ const indexChanges = preMigrationIndexChanges.get(typeName);
10491
+ if (indexChanges && indexChanges.size > 0 && clonedRequest.tailordbType.schema?.indexes) applyPreMigrationIndexAdjustments(clonedRequest.tailordbType.schema.indexes, indexChanges);
10416
10492
  processedTypes.created.add(typeName);
10417
10493
  await client.createTailorDBType(clonedRequest);
10418
10494
  }
@@ -10424,6 +10500,8 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration, tail
10424
10500
  const clonedTypeRequest = structuredClone(snapshotType);
10425
10501
  const typeChanges = preMigrationChanges.get(typeName);
10426
10502
  if (typeChanges && typeChanges.size > 0 && clonedTypeRequest.schema?.fields) applyPreMigrationFieldAdjustments(clonedTypeRequest.schema.fields, typeChanges);
10503
+ const indexChanges = preMigrationIndexChanges.get(typeName);
10504
+ if (indexChanges && indexChanges.size > 0 && clonedTypeRequest.schema?.indexes) applyPreMigrationIndexAdjustments(clonedTypeRequest.schema.indexes, indexChanges);
10427
10505
  processedTypes.updated.add(typeName);
10428
10506
  await client.updateTailorDBType({
10429
10507
  workspaceId: create.request.workspaceId,
@@ -10440,6 +10518,8 @@ async function executeSingleMigrationPrePhase(client, changeSet, migration, tail
10440
10518
  clonedRequest.tailordbType = snapshotType;
10441
10519
  const typeChanges = preMigrationChanges.get(typeName);
10442
10520
  if (typeChanges && typeChanges.size > 0 && clonedRequest.tailordbType.schema?.fields) applyPreMigrationFieldAdjustments(clonedRequest.tailordbType.schema.fields, typeChanges);
10521
+ const indexChanges = preMigrationIndexChanges.get(typeName);
10522
+ if (indexChanges && indexChanges.size > 0 && clonedRequest.tailordbType.schema?.indexes) applyPreMigrationIndexAdjustments(clonedRequest.tailordbType.schema.indexes, indexChanges);
10443
10523
  processedTypes.updated.add(typeName);
10444
10524
  await client.updateTailorDBType(clonedRequest);
10445
10525
  }
@@ -10482,12 +10562,14 @@ const deletedResources = {
10482
10562
  */
10483
10563
  async function executeSingleMigrationPostPhase(client, changeSet, migration, tailorDBInputs, executorUsedTypes) {
10484
10564
  const preMigrationChanges = buildPreMigrationChangesMap([migration]);
10565
+ const preMigrationIndexChanges = buildPreMigrationIndexChangesMap([migration]);
10566
+ const adjustedTypes = /* @__PURE__ */ new Set([...preMigrationChanges.keys(), ...preMigrationIndexChanges.keys()]);
10485
10567
  const affectedTypes = getAffectedTypeNames(migration);
10486
10568
  const deletedTypeNames = getDeletedTypeNames(migration);
10487
10569
  try {
10488
10570
  for (const create of changeSet.type.creates) {
10489
10571
  const typeName = create.request.tailordbType?.name;
10490
- if (!typeName || !affectedTypes.has(typeName) || !preMigrationChanges.has(typeName)) continue;
10572
+ if (!typeName || !affectedTypes.has(typeName) || !adjustedTypes.has(typeName)) continue;
10491
10573
  const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
10492
10574
  if (!snapshotType) continue;
10493
10575
  await client.updateTailorDBType({
@@ -10498,7 +10580,7 @@ async function executeSingleMigrationPostPhase(client, changeSet, migration, tai
10498
10580
  }
10499
10581
  for (const update of changeSet.type.updates) {
10500
10582
  const typeName = update.request.tailordbType?.name;
10501
- if (!typeName || !affectedTypes.has(typeName) || !preMigrationChanges.has(typeName)) continue;
10583
+ if (!typeName || !affectedTypes.has(typeName) || !adjustedTypes.has(typeName)) continue;
10502
10584
  const snapshotType = buildSnapshotTypeManifest(migration, typeName, tailorDBInputs, executorUsedTypes);
10503
10585
  if (!snapshotType) continue;
10504
10586
  await client.updateTailorDBType({
@@ -12210,16 +12292,13 @@ function formatTimestamp(timestamp) {
12210
12292
  }
12211
12293
  /**
12212
12294
  * Formats a table with consistent single-line border style.
12213
- * Use this instead of importing `table` directly.
12295
+ * Use this instead of importing a table-rendering package directly.
12214
12296
  * @param data - Table data
12215
12297
  * @param config - Table configuration
12216
12298
  * @returns Formatted table string
12217
12299
  */
12218
12300
  function formatTable(data, config) {
12219
- return table(data, {
12220
- ...config,
12221
- border: getBorderCharacters("norc")
12222
- });
12301
+ return renderTable(data, config);
12223
12302
  }
12224
12303
  /**
12225
12304
  * Formats a key-value table with single-line border style.
@@ -18812,6 +18891,37 @@ ${updates.join("\n\n")}
18812
18891
  * @returns {string | null} Script content or null if no script needed
18813
18892
  */
18814
18893
  function generateChangeScript(change) {
18894
+ if (change.kind === "index_added" || change.kind === "index_modified") {
18895
+ const before = change.kind === "index_modified" ? change.before : void 0;
18896
+ if (!isBreakingIndexChange(change.typeName, change.indexName, before, change.after)) return null;
18897
+ const fields = change.after.fields;
18898
+ const fieldList = fields.map((f) => `"${f}"`).join(", ");
18899
+ const whereClauses = fields.map((f) => `.where("${f}", "=", dup.${f})`).join("\n ");
18900
+ return ` // Resolve duplicate (${fields.join(", ")}) combinations before unique index "${change.indexName}" is enforced
18901
+ {
18902
+ const duplicates = await trx
18903
+ .selectFrom("${change.typeName}")
18904
+ .select([${fieldList}])
18905
+ .groupBy([${fieldList}])
18906
+ .having((eb) => eb.fn.count("id"), ">", 1)
18907
+ .execute();
18908
+ for (const dup of duplicates) {
18909
+ const records = await trx
18910
+ .selectFrom("${change.typeName}")
18911
+ .select(["id"])
18912
+ ${whereClauses}
18913
+ .execute();
18914
+ // Keep the first record; update or delete the others so the combination becomes unique
18915
+ for (let i = 1; i < records.length; i++) {
18916
+ await trx
18917
+ .updateTable("${change.typeName}")
18918
+ .set({ ${fields[0]}: null }) // TODO: Set appropriate unique value
18919
+ .where("id", "=", records[i].id)
18920
+ .execute();
18921
+ }
18922
+ }
18923
+ }`;
18924
+ }
18815
18925
  if (change.kind === "field_added") {
18816
18926
  if (change.after.required) return ` // Populate ${change.fieldName} for existing ${change.typeName} records
18817
18927
  await trx
@@ -18953,7 +19063,7 @@ async function generate(options) {
18953
19063
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
18954
19064
  let pluginManager;
18955
19065
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
18956
- const { defineApplication } = await import("./application-B1_7Wm37.mjs");
19066
+ const { defineApplication } = await import("./application-CP7JKG9R.mjs");
18957
19067
  const application = defineApplication({
18958
19068
  config,
18959
19069
  pluginManager
@@ -21082,4 +21192,4 @@ async function registerTypeScriptRuntime(hookUrl) {
21082
21192
 
21083
21193
  //#endregion
21084
21194
  export { listFolders as $, deploymentArgs as $n, handleOptionalToRequiredError as $t, generate as A, generateUserTypes as An, startCommand as At, remove as B, loadConsoleBaseUrl as Bn, deploy as Bt, waitWorkflowExecution as C, formatDiffSummary as Cn, listCommand$8 as Ct, listWorkflows as D, resourceTrn as Dn, jobsCommand as Dt, listCommand$2 as E, getNamespacesWithMigrations as En, getExecutorWaitFailureMessage as Et, openInConfiguredEditor as F, deleteUserTokens as Fn, getWorkflowExecution as Ft, treeCommand as G, readPlatformConfig as Gn, createWorkspace$1 as Gt, updateCommand$1 as H, loadStoredUserTokens as Hn, listCommand$9 as Ht, show as I, fetchLatestToken as In, listWorkflowExecutions as It, getCommand$1 as J, writePlatformConfig as Jn, ensureConfigId as Jt, listCommand$3 as K, resolveUserTokenKey as Kn, formatKeyValueTable as Kt, showCommand as L, hasAnyUserTokenEntry as Ln, functionExecutionStatusToString as Lt, generateMigrationScript as M, apiCall as Mn, getCommand$5 as Mt, writeDbTypesFile as N, assertWritable as Nn, getWorkflow as Nt, truncate as O, sdkNameLabelKey as On, listExecutorJobs as Ot, getConfiguredEditorCommand as P, loadConfig as Pn, executionsCommand as Pt, listCommand$4 as Q, confirmationArgs as Qn, MIGRATION_LABEL_KEY as Qt, extractOwnedNamespaces as R, hasUserTokenEntry as Rn, getCommand$6 as Rt, waitCommand as S, parseMigrationNumberArg as Sn, triggerExecutor as St, resumeWorkflow as T, hasChanges as Tn, getExecutorJob as Tt, updateOrganization as U, loadWorkspaceId as Un, listWorkspaces as Ut, removeCommand$1 as V, loadMachineUserName as Vn, deployFromCLI as Vt, organizationTree as W, platformConfigFromProfile as Wn, createCommand$1 as Wt, updateCommand$2 as X, commonArgs as Xn, waitForExecution as Xt, getOrganization as Y, defineAppCommand as Yn, executeScript as Yt, updateFolder as Z, configArg as Zn, bundleMigrationScript as Zt, deleteWorkspace as _, getNextMigrationNumber as _n, getCommand$4 as _t, updateUser as a, DIFF_FILE_NAME as an, toPageDirection as ar, createFolder as at, getAppHealth as b, reconstructSnapshotFromMigrations as bn, webhookCommand as bt, listCommand as c, SCHEMA_FILE_NAME as cn, getCommand$3 as ct, inviteUser as d, compareSnapshots as dn, tokenCommand as dt, parseMigrationLabelNumber as en, isVerbose as er, getCommand$2 as et, restoreCommand as f, createSnapshotFromLocalTypes as fn, listCommand$6 as ft, deleteCommand as g, getMigrationFiles as gn, listFunctionRegistries as gt, getWorkspace as h, getMigrationFilePath as hn, listCommand$7 as ht, updateCommand as i, DB_TYPES_FILE_NAME as in, resolveMachineUserInputSource as ir, createCommand as it, generateCommand as j, prompt as jn, startWorkflow as jt, truncateCommand as k, PluginManager as kn, watchExecutorJob as kt, listUsers as l, assertValidMigrationFiles as ln, getOAuth2Client as lt, getCommand as m, getMigrationDirPath as mn, generate$1 as mt, query as n, generateAllTypeManifestsFromSnapshot as nn, pagedLogArgs as nr, deleteCommand$1 as nt, removeCommand as o, INITIAL_SCHEMA_NUMBER as on, workspaceArgs as or, listCommand$5 as ot, restoreWorkspace as p, getLatestMigrationNumber as pn, listMachineUsers as pt, listOrganizations as q, saveUserTokens as qn, workspaceNameSchema as qt, queryCommand as r, protoGqlPermission as rn, paginationArgs as rr, deleteFolder as rt, removeUser as s, MIGRATE_FILE_NAME as sn, listOAuth2Clients as st, registerTypeScriptRuntime as t, compareSnapshotWithRemote as tn, multiConfigArg as tr, getFolder as tt, inviteCommand as u, compareLocalTypesWithSnapshot as un, getMachineUserToken as ut, listApps as v, isValidMigrationNumber as vn, getFunctionRegistry as vt, resumeCommand as w, formatMigrationDiff as wn, listExecutors as wt, healthCommand as x, formatMigrationNumber as xn, triggerCommand as xt, listCommand$1 as y, loadDiff as yn, listWebhookExecutors as yt, logBetaWarning as z, loadAccessToken as zn, getExecutor as zt };
21085
- //# sourceMappingURL=register-typescript-runtime-QAWucsg0.mjs.map
21195
+ //# sourceMappingURL=register-typescript-runtime-CCHyKeXO.mjs.map