@tailor-platform/sdk 1.70.0 → 1.71.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 (47) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/{application-Df5_I83n.mjs → application-DmjIKQ-a.mjs} +2 -2
  3. package/dist/{application-Df5_I83n.mjs.map → application-DmjIKQ-a.mjs.map} +1 -1
  4. package/dist/application-a_ApFuPh.mjs +4 -0
  5. package/dist/{authconnection-BIYzEh2p.d.mts → authconnection-CqfaJfrC.d.mts} +8 -15
  6. package/dist/{authconnection-Ds2Ahpum.mjs → authconnection-D7lsvsKY.mjs} +2 -2
  7. package/dist/authconnection-D7lsvsKY.mjs.map +1 -0
  8. package/dist/cli/index.mjs +4 -4
  9. package/dist/cli/lib.d.mts +80 -11
  10. package/dist/cli/lib.mjs +2 -2
  11. package/dist/cli/lib.mjs.map +1 -1
  12. package/dist/completion/zsh-worker.zsh +7 -5
  13. package/dist/configure/index.d.mts +5 -4
  14. package/dist/configure/index.mjs.map +1 -1
  15. package/dist/{index-C-vsbx27.d.mts → index-BDBU7x-i.d.mts} +2 -2
  16. package/dist/{index-dKNk8hjo.d.mts → index-BSlv_YrG.d.mts} +2 -2
  17. package/dist/{index-BAEaAqmz.d.mts → index-BzGqTY5x.d.mts} +16 -4
  18. package/dist/{index-CKI0eZP6.d.mts → index-D3_Au3wu.d.mts} +2 -2
  19. package/dist/{index-CrqOgUF2.d.mts → index-DtFRlrww.d.mts} +2 -2
  20. package/dist/{index-DESLU9kI.d.mts → index-jeE3UvF2.d.mts} +2 -2
  21. package/dist/mock-wf5qeZLi.mjs.map +1 -1
  22. package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
  23. package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
  24. package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
  25. package/dist/plugin/builtin/seed/index.d.mts +1 -1
  26. package/dist/runtime/authconnection.d.mts +1 -1
  27. package/dist/runtime/authconnection.mjs +1 -1
  28. package/dist/runtime/globals.d.mts +1 -1
  29. package/dist/runtime/index.d.mts +2 -2
  30. package/dist/runtime/index.mjs +1 -1
  31. package/dist/{runtime-CSY0eD4_.mjs → runtime-Cd375HD-.mjs} +220 -133
  32. package/dist/runtime-Cd375HD-.mjs.map +1 -0
  33. package/dist/{service_pb-DGSmn-aF.mjs → service_pb-BJ9GsAnW.mjs} +1 -1
  34. package/dist/{service_pb-DSNjrcbW.mjs → service_pb-BsBR6yW5.mjs} +22 -7
  35. package/dist/service_pb-BsBR6yW5.mjs.map +1 -0
  36. package/dist/{types-Dynq4AJv.d.mts → types-aqnqTCfO.d.mts} +4 -342
  37. package/dist/types-v_ErzNUF.d.mts +345 -0
  38. package/dist/utils/test/index.d.mts +2 -2
  39. package/dist/vitest/index.d.mts +4 -3
  40. package/dist/{workflow.generated-DJULCuRr.d.mts → workflow.generated-Da1zECDw.d.mts} +3 -2
  41. package/docs/services/auth.md +14 -22
  42. package/docs/testing.md +1 -1
  43. package/package.json +11 -11
  44. package/dist/application-BakHtldG.mjs +0 -4
  45. package/dist/authconnection-Ds2Ahpum.mjs.map +0 -1
  46. package/dist/runtime-CSY0eD4_.mjs.map +0 -1
  47. package/dist/service_pb-DSNjrcbW.mjs.map +0 -1
@@ -1,9 +1,9 @@
1
1
 
2
2
  import { t as db } from "./schema-C4fkpWV_.mjs";
3
- import { $ as CreateUserProfileConfigRequestSchema, A as UpdatePipelineServiceRequestSchema, At as PageDirection, B as UpdateExecutorExecutorRequestSchema, Ct as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, D as CreatePipelineResolverRequestSchema, Dt as ConditionSchema, E as UpdateSecretManagerSecretRequestSchema, Et as Subgraph_ServiceType, F as IdPPermissionOperator, G as CreateAuthHookRequestSchema, H as ExecutorTargetType, I as IdPPermissionPermit, J as CreateAuthOAuth2ClientRequestSchema, K as CreateAuthIDPConfigRequestSchema, L as FunctionExecution_Status, M as CreateIdPServiceRequestSchema, N as UpdateIdPServiceRequestSchema, O as CreatePipelineServiceRequestSchema, Ot as Condition_Operator, P as IdPLang, Q as CreateTenantConfigRequestSchema, S as UpdateStaticWebsiteRequestSchema, St as CreateApplicationRequestSchema, T as CreateSecretManagerVaultRequestSchema, Tt as ApplicationSchemaUpdateAttemptStatus, U as ExecutorTriggerType, V as ExecutorJobStatus, W as CreateAuthConnectionRequestSchema, X as CreateAuthSCIMResourceRequestSchema, Y as CreateAuthSCIMConfigRequestSchema, Z as CreateAuthServiceRequestSchema, _ as TailorDBType_Permission_Operator, _t as AuthSCIMAttribute_Uniqueness, a as WorkspacePlatformUserRole, at as UpdateAuthSCIMResourceRequestSchema, b as AddCustomDomainRequestSchema, bt as TenantProviderConfig_TenantProviderType, c as UpdateWorkflowRequestSchema, ct as UpdateUserProfileConfigRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as AuthIDPConfig_AuthType, et as UpdateAuthHookRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as AuthInvokerSchema, g as TailorDBGQLPermission_Permit, gt as AuthSCIMAttribute_Type, h as TailorDBGQLPermission_Operator, ht as AuthSCIMAttribute_Mutability, it as UpdateAuthSCIMConfigRequestSchema, j as PipelineResolver_OperationType, k as UpdatePipelineResolverRequestSchema, kt as FilterSchema, l as WorkflowExecution_Status, lt as AuthConnection_Type, m as TailorDBGQLPermission_Action, mt as AuthOAuth2Client_GrantType, nt as UpdateAuthMachineUserRequestSchema, o as CreateWorkflowJobFunctionRequestSchema, ot as UpdateAuthServiceRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as AuthOAuth2Client_ClientType, q as CreateAuthMachineUserRequestSchema, rt as UpdateAuthOAuth2ClientRequestSchema, s as CreateWorkflowRequestSchema, st as UpdateTenantConfigRequestSchema, t as OperatorService, tt as UpdateAuthIDPConfigRequestSchema, u as WorkflowJobExecution_Status, ut as AuthHookPoint, v as TailorDBType_Permission_Permit, vt as AuthSCIMConfig_AuthorizationType, w as CreateSecretManagerSecretRequestSchema, wt as UpdateApplicationRequestSchema, x as CreateStaticWebsiteRequestSchema, xt as UserProfileProviderConfig_UserProfileProviderType, y as TailorDBType_PermitAction, z as CreateExecutorExecutorRequestSchema } from "./service_pb-DSNjrcbW.mjs";
3
+ import { $ as CreateUserProfileConfigRequestSchema, A as UpdatePipelineServiceRequestSchema, At as Condition_Operator, B as UpdateExecutorExecutorRequestSchema, Ct as UserProfileProviderConfig_UserProfileProviderType, D as CreatePipelineResolverRequestSchema, Dt as ApplicationSchemaUpdateAttemptStatus, E as UpdateSecretManagerSecretRequestSchema, Et as UpdateApplicationRequestSchema, F as IdPPermissionOperator, G as CreateAuthHookRequestSchema, H as ExecutorTargetType, I as IdPPermissionPermit, J as CreateAuthOAuth2ClientRequestSchema, K as CreateAuthIDPConfigRequestSchema, L as FunctionExecution_Status, M as CreateIdPServiceRequestSchema, Mt as PageDirection, N as UpdateIdPServiceRequestSchema, O as CreatePipelineServiceRequestSchema, Ot as Subgraph_ServiceType, P as IdPLang, Q as CreateTenantConfigRequestSchema, S as UpdateStaticWebsiteRequestSchema, St as TenantProviderConfig_TenantProviderType, T as CreateSecretManagerVaultRequestSchema, Tt as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, U as ExecutorTriggerType, V as ExecutorJobStatus, W as CreateAuthConnectionRequestSchema, X as CreateAuthSCIMResourceRequestSchema, Y as CreateAuthSCIMConfigRequestSchema, Z as CreateAuthServiceRequestSchema, _ as TailorDBType_Permission_Operator, _t as AuthSCIMAttribute_Mutability, a as WorkspacePlatformUserRole, at as UpdateAuthSCIMConfigRequestSchema, b as AddCustomDomainRequestSchema, bt as AuthSCIMConfig_AuthorizationType, c as UpdateWorkflowRequestSchema, ct as UpdateTenantConfigRequestSchema, d as CreateTailorDBServiceRequestSchema, dt as AuthConnection_Type, et as UpdateAuthConnectionRequestSchema, f as CreateTailorDBTypeRequestSchema, ft as AuthHookPoint, g as TailorDBGQLPermission_Permit, gt as AuthOAuth2Client_GrantType, h as TailorDBGQLPermission_Operator, ht as AuthOAuth2Client_ClientType, it as UpdateAuthOAuth2ClientRequestSchema, j as PipelineResolver_OperationType, jt as FilterSchema, k as UpdatePipelineResolverRequestSchema, kt as ConditionSchema, l as WorkflowExecution_Status, lt as UpdateUserProfileConfigRequestSchema, m as TailorDBGQLPermission_Action, mt as AuthInvokerSchema, nt as UpdateAuthIDPConfigRequestSchema, o as CreateWorkflowJobFunctionRequestSchema, ot as UpdateAuthSCIMResourceRequestSchema, p as UpdateTailorDBTypeRequestSchema, pt as AuthIDPConfig_AuthType, q as CreateAuthMachineUserRequestSchema, rt as UpdateAuthMachineUserRequestSchema, s as CreateWorkflowRequestSchema, st as UpdateAuthServiceRequestSchema, t as OperatorService, tt as UpdateAuthHookRequestSchema, u as WorkflowJobExecution_Status, ut as AuthConnection_Status, v as TailorDBType_Permission_Permit, vt as AuthSCIMAttribute_Type, w as CreateSecretManagerSecretRequestSchema, wt as CreateApplicationRequestSchema, x as CreateStaticWebsiteRequestSchema, y as TailorDBType_PermitAction, yt as AuthSCIMAttribute_Uniqueness, z as CreateExecutorExecutorRequestSchema } from "./service_pb-BsBR6yW5.mjs";
4
4
  import { t as assertDefined } from "./assert-CKfwrmCV.mjs";
5
5
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-DKF-JsAK.mjs";
6
- import { $ as initOperatorClient, A as loadAccessToken, G as fetchMachineUserToken, I as loadWorkspaceId, K as fetchPaged, L as platformConfigFromProfile, N as loadMachineUserName, P as loadPlatformClientConfig, R as readPlatformConfig, S as getDistDir, T as loadConfig, V as writePlatformConfig, W as fetchAll, X as getOAuth2ClientId, Y as getConsoleBaseUrl, Z as getPlatformBaseUrl, b as hasGenerationHooks, d as assertUniqueLocalTailorDBTypeNames, et as isDefaultPlatform, f as assertUniqueTailorDBTypeNamesWithExternal, h as platformBundleDefinePlugin, j as loadConfigPath, k as hasUserTokenEntry, l as buildExecutorArgsExpr, m as stringifyFunction, n as generatePluginFilesIfNeeded, nt as byName, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, tt as resolveStaticWebsiteUrls, u as buildResolverOperationHookExpr, w as hashFile, x as createBundleCache, y as getPluginGenerationDependencies } from "./application-Df5_I83n.mjs";
6
+ import { $ as initOperatorClient, A as loadAccessToken, G as fetchMachineUserToken, I as loadWorkspaceId, K as fetchPaged, L as platformConfigFromProfile, N as loadMachineUserName, P as loadPlatformClientConfig, R as readPlatformConfig, S as getDistDir, T as loadConfig, V as writePlatformConfig, W as fetchAll, X as getOAuth2ClientId, Y as getConsoleBaseUrl, Z as getPlatformBaseUrl, b as hasGenerationHooks, d as assertUniqueLocalTailorDBTypeNames, et as isDefaultPlatform, f as assertUniqueTailorDBTypeNamesWithExternal, h as platformBundleDefinePlugin, j as loadConfigPath, k as hasUserTokenEntry, l as buildExecutorArgsExpr, m as stringifyFunction, n as generatePluginFilesIfNeeded, nt as byName, p as TailorDBTypeSchema, r as loadApplication, s as HTTP_METHODS, t as defineApplication, tt as resolveStaticWebsiteUrls, u as buildResolverOperationHookExpr, w as hashFile, x as createBundleCache, y as getPluginGenerationDependencies } from "./application-DmjIKQ-a.mjs";
7
7
  import { o as loadFilesWithIgnores, t as createExecutorService } from "./service-B2Jd9CxS.mjs";
8
8
  import { t as multiline } from "./multiline-Cf9ODpr1.mjs";
9
9
  import { t as readPackageJson } from "./package-json-DcQApfPQ.mjs";
@@ -1117,9 +1117,10 @@ function extractAttributesFromConfig(config) {
1117
1117
  * @param env - Environment configuration
1118
1118
  * @param machineUserNames - Registered machine user names (used to narrow `authInvoker` strings)
1119
1119
  * @param idpNames - Registered IdP names (used to narrow `idpUser*Trigger({ idp })` strings)
1120
+ * @param connectionNames - Registered auth connection names (used to narrow `getConnectionToken()` strings)
1120
1121
  * @returns Generated type definition source
1121
1122
  */
1122
- function generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames) {
1123
+ function generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames) {
1123
1124
  const mapFields = attributeMap ? Object.entries(attributeMap).map(([key, value]) => ` ${key}: ${value};`).join("\n") : "";
1124
1125
  const mapBody = !attributeMap || Object.keys(attributeMap).length === 0 ? "{}" : `{
1125
1126
  ${mapFields}
@@ -1139,6 +1140,10 @@ ${envFields}
1139
1140
  ${machineUserFields}
1140
1141
  }`;
1141
1142
  const idpNameFields = idpNames?.length ? idpNames.map((name) => ` ${isValidIdentifier(name) ? name : JSON.stringify(name)}: true;`).join("\n") : "";
1143
+ const idpNameBody = !idpNames || idpNames.length === 0 ? "{}" : `{
1144
+ ${idpNameFields}
1145
+ }`;
1146
+ const connectionNameFields = connectionNames?.length ? connectionNames.map((name) => ` ${isValidIdentifier(name) ? name : JSON.stringify(name)}: true;`).join("\n") : "";
1142
1147
  return multiline`
1143
1148
  // This file is auto-generated by @tailor-platform/sdk
1144
1149
  // Do not edit this file manually
@@ -1149,8 +1154,9 @@ declare module "@tailor-platform/sdk" {
1149
1154
  interface AttributeList ${listBody}
1150
1155
  interface Env ${envBody}
1151
1156
  interface MachineUserNameRegistry ${machineUserBody}
1152
- interface IdpNameRegistry ${!idpNames || idpNames.length === 0 ? "{}" : `{
1153
- ${idpNameFields}
1157
+ interface IdpNameRegistry ${idpNameBody}
1158
+ interface ConnectionNameRegistry ${!connectionNames || connectionNames.length === 0 ? "{}" : `{
1159
+ ${connectionNameFields}
1154
1160
  }`}
1155
1161
  }
1156
1162
 
@@ -1164,6 +1170,8 @@ function collectAttributesFromConfig(config) {
1164
1170
  if (!auth || typeof auth !== "object") return idpNames ? { idpNames } : {};
1165
1171
  const machineUsersObj = auth.machineUsers;
1166
1172
  const machineUserNames = machineUsersObj && typeof machineUsersObj === "object" ? Object.keys(machineUsersObj) : void 0;
1173
+ const connectionsObj = auth.connections;
1174
+ const connectionNames = connectionsObj && typeof connectionsObj === "object" ? Object.keys(connectionsObj) : void 0;
1167
1175
  const inferAttributeType = (field) => {
1168
1176
  const type = field?.type;
1169
1177
  const metadata = field?.metadata;
@@ -1186,14 +1194,16 @@ function collectAttributesFromConfig(config) {
1186
1194
  }, {}) : void 0,
1187
1195
  attributeList,
1188
1196
  machineUserNames,
1189
- idpNames
1197
+ idpNames,
1198
+ connectionNames
1190
1199
  };
1191
1200
  }
1192
1201
  if ("machineUserAttributes" in auth) {
1193
1202
  const machineUserAttributes = auth.machineUserAttributes;
1194
1203
  if (!machineUserAttributes) return {
1195
1204
  machineUserNames,
1196
- idpNames
1205
+ idpNames,
1206
+ connectionNames
1197
1207
  };
1198
1208
  return {
1199
1209
  attributeMap: Object.entries(machineUserAttributes).reduce((acc, [key, field]) => {
@@ -1201,12 +1211,14 @@ function collectAttributesFromConfig(config) {
1201
1211
  return acc;
1202
1212
  }, {}),
1203
1213
  machineUserNames,
1204
- idpNames
1214
+ idpNames,
1215
+ connectionNames
1205
1216
  };
1206
1217
  }
1207
1218
  return {
1208
1219
  machineUserNames,
1209
- idpNames
1220
+ idpNames,
1221
+ connectionNames
1210
1222
  };
1211
1223
  }
1212
1224
  /**
@@ -1231,15 +1243,16 @@ function resolveTypeDefinitionPath(configPath) {
1231
1243
  async function generateUserTypes(options) {
1232
1244
  const { config, configPath } = options;
1233
1245
  try {
1234
- const { attributeMap, attributeList, machineUserNames, idpNames } = extractAttributesFromConfig(config);
1246
+ const { attributeMap, attributeList, machineUserNames, idpNames, connectionNames } = extractAttributesFromConfig(config);
1235
1247
  if (!attributeMap && !attributeList) logger.info("No attributes found in configuration", { mode: "plain" });
1236
1248
  if (attributeMap) logger.debug(`Extracted AttributeMap: ${JSON.stringify(attributeMap)}`);
1237
1249
  if (attributeList) logger.debug(`Extracted AttributeList: ${JSON.stringify(attributeList)}`);
1238
1250
  if (machineUserNames?.length) logger.debug(`Extracted MachineUserNames: ${JSON.stringify(machineUserNames)}`);
1239
1251
  if (idpNames?.length) logger.debug(`Extracted IdpNames: ${JSON.stringify(idpNames)}`);
1252
+ if (connectionNames?.length) logger.debug(`Extracted ConnectionNames: ${JSON.stringify(connectionNames)}`);
1240
1253
  const env = config.env;
1241
1254
  if (env) logger.debug(`Extracted Env: ${JSON.stringify(env)}`);
1242
- const typeDefContent = generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames);
1255
+ const typeDefContent = generateTypeDefinition(attributeMap, attributeList, env, machineUserNames, idpNames, connectionNames);
1243
1256
  const outputPath = resolveTypeDefinitionPath(configPath);
1244
1257
  fs$1.mkdirSync(path.dirname(outputPath), { recursive: true });
1245
1258
  fs$1.writeFileSync(outputPath, typeDefContent);
@@ -2360,21 +2373,28 @@ function buildConnectionRequest(workspaceId, name, config) {
2360
2373
  }
2361
2374
  };
2362
2375
  }
2363
- function hashConnectionConfig(config) {
2364
- return hashValue(JSON.stringify({
2365
- type: config.type,
2366
- providerUrl: config.providerUrl,
2367
- issuerUrl: config.issuerUrl,
2368
- clientId: config.clientId,
2369
- clientSecret: config.clientSecret,
2370
- authUrl: config.authUrl ?? "",
2371
- tokenUrl: config.tokenUrl ?? ""
2372
- }));
2373
- }
2374
- function hasNonSecretFieldChanged(existing, desired) {
2375
- if (existing.config.case !== "oauth2") return true;
2376
- const oauth2 = existing.config.value;
2377
- return oauth2.providerUrl !== desired.providerUrl || oauth2.issuerUrl !== desired.issuerUrl || oauth2.clientId !== desired.clientId || oauth2.authUrl !== (desired.authUrl ?? "") || oauth2.tokenUrl !== (desired.tokenUrl ?? "");
2376
+ function buildUpdateMask(existing, desired, secretChanged) {
2377
+ if (existing.config.case !== "oauth2") {
2378
+ const paths = [
2379
+ "type",
2380
+ "oauth2.provider_url",
2381
+ "oauth2.issuer_url",
2382
+ "oauth2.client_id",
2383
+ "oauth2.auth_url",
2384
+ "oauth2.token_url"
2385
+ ];
2386
+ if (desired.clientSecret) paths.push("oauth2.client_secret");
2387
+ return { paths };
2388
+ }
2389
+ const paths = [];
2390
+ const v = existing.config.value;
2391
+ if (v.providerUrl !== desired.providerUrl) paths.push("oauth2.provider_url");
2392
+ if (v.issuerUrl !== desired.issuerUrl) paths.push("oauth2.issuer_url");
2393
+ if (v.clientId !== desired.clientId) paths.push("oauth2.client_id");
2394
+ if (v.authUrl !== (desired.authUrl ?? "")) paths.push("oauth2.auth_url");
2395
+ if (v.tokenUrl !== (desired.tokenUrl ?? "")) paths.push("oauth2.token_url");
2396
+ if (secretChanged && desired.clientSecret) paths.push("oauth2.client_secret");
2397
+ return { paths };
2378
2398
  }
2379
2399
  /**
2380
2400
  * Plan auth connection changes based on current and desired state.
@@ -2432,15 +2452,14 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2432
2452
  resourceType: "Auth connection",
2433
2453
  resourceName: name
2434
2454
  });
2435
- const currentHash = hashConnectionConfig(config);
2436
- const storedHash = state.connections?.[name];
2437
- if (hasNonSecretFieldChanged(existing.resource, config) || currentHash !== storedHash) changeSet.replaces.push({
2455
+ const secretChanged = hashValue(config.clientSecret) !== state.connections?.[name];
2456
+ const updateMask = buildUpdateMask(existing.resource, config, secretChanged);
2457
+ if (updateMask.paths.length > 0) changeSet.replaces.push({
2438
2458
  name,
2439
- deleteRequest: {
2440
- workspaceId,
2441
- connectionName: name
2459
+ updateRequest: {
2460
+ ...buildConnectionRequest(workspaceId, name, config),
2461
+ updateMask
2442
2462
  },
2443
- createRequest: buildConnectionRequest(workspaceId, name, config),
2444
2463
  metaRequest
2445
2464
  });
2446
2465
  else if (!existing.label) changeSet.updates.push({
@@ -2477,21 +2496,6 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2477
2496
  resourceOwners
2478
2497
  };
2479
2498
  }
2480
- function extractOAuth2Config(connection) {
2481
- if (!connection) return void 0;
2482
- const config = connection.config;
2483
- if (!config || config.case !== "oauth2") return void 0;
2484
- const v = config.value;
2485
- return {
2486
- type: "oauth2",
2487
- providerUrl: v.providerUrl ?? "",
2488
- issuerUrl: v.issuerUrl ?? "",
2489
- clientId: v.clientId ?? "",
2490
- clientSecret: v.clientSecret ?? "",
2491
- authUrl: v.authUrl || void 0,
2492
- tokenUrl: v.tokenUrl || void 0
2493
- };
2494
- }
2495
2499
  /**
2496
2500
  * Apply auth connection changes for the given phase.
2497
2501
  * @param client - Operator client instance
@@ -2504,10 +2508,10 @@ async function applyAuthConnections(client, result, phase) {
2504
2508
  await Promise.all(changeSet.creates.map(async (create) => {
2505
2509
  await client.createAuthConnection(create.request);
2506
2510
  await client.setMetadata(create.metaRequest);
2511
+ logger.info(`Connection "${create.name}" was created. Authorize it with:\n tailor-sdk authconnection authorize --name ${create.name}\nOr via the Console: tailor-sdk authconnection open`);
2507
2512
  }));
2508
2513
  for (const replace of changeSet.replaces) {
2509
- await client.deleteAuthConnection(replace.deleteRequest);
2510
- await client.createAuthConnection(replace.createRequest);
2514
+ if ((await client.updateAuthConnection(replace.updateRequest)).connection?.status === AuthConnection_Status.UNAUTHORIZED) logger.warn(`Connection "${replace.name}" requires re-authorization. Authorize with:\n tailor-sdk authconnection authorize --name ${replace.name}\nOr via the Console: tailor-sdk authconnection open`);
2511
2515
  await client.setMetadata(replace.metaRequest);
2512
2516
  }
2513
2517
  await Promise.all(changeSet.updates.map(async (update) => {
@@ -2516,12 +2520,12 @@ async function applyAuthConnections(client, result, phase) {
2516
2520
  const state = loadSecretsState();
2517
2521
  if (!state.connections) state.connections = {};
2518
2522
  for (const create of changeSet.creates) {
2519
- const oauth2 = extractOAuth2Config(create.request.connection);
2520
- if (oauth2) state.connections[create.name] = hashConnectionConfig(oauth2);
2523
+ const conn = create.request.connection;
2524
+ if (conn?.config?.case === "oauth2") state.connections[create.name] = hashValue(conn.config.value.clientSecret ?? "");
2521
2525
  }
2522
2526
  for (const replace of changeSet.replaces) {
2523
- const oauth2 = extractOAuth2Config(replace.createRequest.connection);
2524
- if (oauth2) state.connections[replace.name] = hashConnectionConfig(oauth2);
2527
+ const conn = replace.updateRequest.connection;
2528
+ if (conn?.config?.case === "oauth2" && replace.updateRequest.updateMask?.paths?.includes("oauth2.client_secret")) state.connections[replace.name] = hashValue(conn.config.value.clientSecret ?? "");
2525
2529
  }
2526
2530
  saveSecretsState(state);
2527
2531
  } else {
@@ -6563,6 +6567,23 @@ function parseMigrationNumberArg(numberStr) {
6563
6567
  * All object schemas use `z.looseObject` so that unknown keys written
6564
6568
  * by newer CLI versions survive a load → save round-trip.
6565
6569
  */
6570
+ function snapshotRecordSchema(valueSchema) {
6571
+ return z.custom((value) => typeof value === "object" && value !== null && !Array.isArray(value), { message: "Expected record" }).transform((value, ctx) => {
6572
+ const record = Object.create(null);
6573
+ for (const key of Object.keys(value)) {
6574
+ const result = valueSchema.safeParse(value[key]);
6575
+ if (!result.success) {
6576
+ for (const issue of result.error.issues) ctx.addIssue({
6577
+ ...issue,
6578
+ path: [key, ...issue.path]
6579
+ });
6580
+ continue;
6581
+ }
6582
+ record[key] = result.data;
6583
+ }
6584
+ return record;
6585
+ });
6586
+ }
6566
6587
  const snapshotHookSchema = z.looseObject({ expr: z.string() });
6567
6588
  const snapshotValidationSchema = z.looseObject({
6568
6589
  script: z.looseObject({ expr: z.string() }).optional(),
@@ -6596,7 +6617,7 @@ const snapshotFieldConfigSchema = z.looseObject({
6596
6617
  validate: z.array(snapshotValidationSchema).optional(),
6597
6618
  serial: snapshotSerialSchema.optional(),
6598
6619
  scale: z.number().optional(),
6599
- fields: z.lazy(() => z.record(z.string(), snapshotFieldConfigSchema)).optional()
6620
+ fields: z.lazy(() => snapshotRecordSchema(snapshotFieldConfigSchema)).optional()
6600
6621
  });
6601
6622
  const snapshotIndexConfigSchema = z.looseObject({
6602
6623
  fields: z.array(z.string()),
@@ -6667,7 +6688,7 @@ const tailorDBSnapshotTypeSchema = z.looseObject({
6667
6688
  name: z.string(),
6668
6689
  pluralForm: z.string().optional(),
6669
6690
  description: z.string().optional(),
6670
- fields: z.record(z.string(), snapshotFieldConfigSchema),
6691
+ fields: snapshotRecordSchema(snapshotFieldConfigSchema),
6671
6692
  settings: z.looseObject({
6672
6693
  aggregation: z.boolean().optional(),
6673
6694
  bulkUpsert: z.boolean().optional(),
@@ -6679,10 +6700,10 @@ const tailorDBSnapshotTypeSchema = z.looseObject({
6679
6700
  }).optional(),
6680
6701
  publishEvents: z.boolean().optional()
6681
6702
  }).optional(),
6682
- indexes: z.record(z.string(), snapshotIndexConfigSchema).optional(),
6683
- files: z.record(z.string(), z.string()).optional(),
6684
- forwardRelationships: z.record(z.string(), snapshotRelationshipSchema).optional(),
6685
- backwardRelationships: z.record(z.string(), snapshotRelationshipSchema).optional(),
6703
+ indexes: snapshotRecordSchema(snapshotIndexConfigSchema).optional(),
6704
+ files: snapshotRecordSchema(z.string()).optional(),
6705
+ forwardRelationships: snapshotRecordSchema(snapshotRelationshipSchema).optional(),
6706
+ backwardRelationships: snapshotRecordSchema(snapshotRelationshipSchema).optional(),
6686
6707
  permissions: z.looseObject({
6687
6708
  record: snapshotRecordPermissionSchema.optional(),
6688
6709
  gql: snapshotGqlPermissionSchema.optional()
@@ -6692,11 +6713,11 @@ const schemaSnapshotSchema = z.looseObject({
6692
6713
  version: z.number(),
6693
6714
  namespace: z.string(),
6694
6715
  createdAt: z.string(),
6695
- types: z.record(z.string(), tailorDBSnapshotTypeSchema)
6716
+ types: snapshotRecordSchema(tailorDBSnapshotTypeSchema)
6696
6717
  });
6697
6718
  const typeSettingsPatchSchema = z.looseObject({
6698
- indexes: z.record(z.string(), snapshotIndexConfigSchema).optional(),
6699
- files: z.record(z.string(), z.string()).optional()
6719
+ indexes: snapshotRecordSchema(snapshotIndexConfigSchema).optional(),
6720
+ files: snapshotRecordSchema(z.string()).optional()
6700
6721
  });
6701
6722
  const snapshotPermissionStateSchema = z.looseObject({
6702
6723
  recordPermission: snapshotRecordPermissionSchema.optional(),
@@ -6902,16 +6923,26 @@ const MIGRATION_NUMBER_PATTERN = /^\d{4}$/;
6902
6923
  * Must stay in sync with the platform's default decimal scale.
6903
6924
  */
6904
6925
  const DEFAULT_DECIMAL_SCALE = 6;
6926
+ function createSnapshotRecord() {
6927
+ return Object.create(null);
6928
+ }
6929
+ function copySnapshotRecord(record) {
6930
+ const copy = createSnapshotRecord();
6931
+ for (const [key, value] of Object.entries(record ?? {})) copy[key] = value;
6932
+ return copy;
6933
+ }
6905
6934
  /**
6906
6935
  * Normalize a snapshot field in place so the snapshot becomes the canonical
6907
6936
  * form for comparison. Currently fills in the platform default decimal scale
6908
6937
  * when omitted, which avoids false drift between local schemas (where scale
6909
6938
  * may be omitted) and the platform (which always materializes a scale).
6910
6939
  * @param {SnapshotFieldConfig} field - Field configuration to normalize
6940
+ * @returns The same field object after normalization
6911
6941
  */
6912
6942
  function normalizeSnapshotField(field) {
6913
6943
  if (field.type === "decimal" && field.scale === void 0) field.scale = 6;
6914
6944
  if (field.fields) for (const nested of Object.values(field.fields)) normalizeSnapshotField(nested);
6945
+ return field;
6915
6946
  }
6916
6947
  /**
6917
6948
  * Normalize a snapshot type in place to the canonical comparison shape.
@@ -6922,10 +6953,21 @@ function normalizeSnapshotField(field) {
6922
6953
  *
6923
6954
  * Idempotent — safe to call multiple times on the same input.
6924
6955
  * @param {TailorDBSnapshotType} type - Snapshot type to normalize
6956
+ * @returns The same snapshot type object after normalization
6925
6957
  */
6926
6958
  function normalizeSnapshotType(type) {
6927
6959
  if (!type.pluralForm) type.pluralForm = inflection.pluralize(type.name);
6928
6960
  for (const field of Object.values(type.fields)) normalizeSnapshotField(field);
6961
+ return type;
6962
+ }
6963
+ /**
6964
+ * Normalize a schema snapshot in place to the canonical comparison shape.
6965
+ * @param {SchemaSnapshot} snapshot - Schema snapshot to normalize
6966
+ * @returns The same schema snapshot object branded as normalized
6967
+ */
6968
+ function normalizeSchemaSnapshot(snapshot) {
6969
+ for (const type of Object.values(snapshot.types)) normalizeSnapshotType(type);
6970
+ return snapshot;
6929
6971
  }
6930
6972
  /**
6931
6973
  * Validate that a migration number follows the expected format (4-digit number)
@@ -7063,7 +7105,7 @@ function createSnapshotFieldConfigFromOperatorConfig(fieldConfig) {
7063
7105
  * @returns {TailorDBSnapshotType} Snapshot type configuration
7064
7106
  */
7065
7107
  function createSnapshotType(type) {
7066
- const fields = {};
7108
+ const fields = createSnapshotRecord();
7067
7109
  for (const [fieldName, field] of Object.entries(type.fields)) fields[fieldName] = createSnapshotFieldConfig(field);
7068
7110
  const snapshotType = {
7069
7111
  name: type.name,
@@ -7127,7 +7169,7 @@ function createSnapshotType(type) {
7127
7169
  ...policy.description && { description: policy.description }
7128
7170
  }));
7129
7171
  }
7130
- return snapshotType;
7172
+ return normalizeSnapshotType(snapshotType);
7131
7173
  }
7132
7174
  /**
7133
7175
  * Convert an action permission to snapshot format
@@ -7145,22 +7187,22 @@ function convertActionPermission(permission) {
7145
7187
  * Create a schema snapshot from local type definitions
7146
7188
  * @param {Record<string, TailorDBType>} types - Local type definitions
7147
7189
  * @param {string} namespace - Namespace for the snapshot
7148
- * @returns {SchemaSnapshot} Schema snapshot
7190
+ * @returns {NormalizedSchemaSnapshot} Normalized schema snapshot
7149
7191
  */
7150
7192
  function createSnapshotFromLocalTypes(types, namespace) {
7151
- const snapshotTypes = {};
7193
+ const snapshotTypes = createSnapshotRecord();
7152
7194
  for (const [typeName, type] of Object.entries(types)) snapshotTypes[typeName] = createSnapshotType(type);
7153
- return {
7195
+ return normalizeSchemaSnapshot({
7154
7196
  version: 1,
7155
7197
  namespace,
7156
7198
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
7157
7199
  types: snapshotTypes
7158
- };
7200
+ });
7159
7201
  }
7160
7202
  /**
7161
7203
  * Load a schema snapshot from a file
7162
7204
  * @param {string} filePath - Path to the snapshot file
7163
- * @returns {SchemaSnapshot} Loaded schema snapshot
7205
+ * @returns {NormalizedSchemaSnapshot} Loaded normalized schema snapshot
7164
7206
  */
7165
7207
  function loadSnapshot(filePath) {
7166
7208
  const content = fs$1.readFileSync(filePath, "utf-8");
@@ -7173,8 +7215,7 @@ function loadSnapshot(filePath) {
7173
7215
  const result = schemaSnapshotSchema.safeParse(raw);
7174
7216
  if (!result.success) throw new Error(`Invalid schema snapshot at ${filePath}: ${z.prettifyError(result.error)}`, { cause: result.error });
7175
7217
  const snapshot = result.data;
7176
- for (const type of Object.values(snapshot.types)) normalizeSnapshotType(type);
7177
- return snapshot;
7218
+ return normalizeSchemaSnapshot(snapshot);
7178
7219
  }
7179
7220
  /**
7180
7221
  * Load a migration diff from a file
@@ -7243,10 +7284,10 @@ function getNextMigrationNumber(migrationsDir) {
7243
7284
  * Apply a diff to a snapshot to get the resulting snapshot
7244
7285
  * @param {SchemaSnapshot} snapshot - Base snapshot to apply diff to
7245
7286
  * @param {MigrationDiff} diff - Diff to apply
7246
- * @returns {SchemaSnapshot} Resulting snapshot after applying diff
7287
+ * @returns {NormalizedSchemaSnapshot} Normalized snapshot after applying diff
7247
7288
  */
7248
7289
  function applyDiffToSnapshot(snapshot, diff) {
7249
- const types = { ...snapshot.types };
7290
+ const types = copySnapshotRecord(snapshot.types);
7250
7291
  for (const change of diff.changes) switch (change.kind) {
7251
7292
  case "type_added":
7252
7293
  types[change.typeName] = change.after;
@@ -7269,19 +7310,21 @@ function applyDiffToSnapshot(snapshot, diff) {
7269
7310
  case "field_added":
7270
7311
  case "field_modified": {
7271
7312
  const existing = types[change.typeName];
7272
- if (existing) types[change.typeName] = {
7273
- ...existing,
7274
- fields: {
7275
- ...existing.fields,
7276
- [change.fieldName]: change.after
7277
- }
7278
- };
7313
+ if (existing) {
7314
+ const fields = copySnapshotRecord(existing.fields);
7315
+ fields[change.fieldName] = change.after;
7316
+ types[change.typeName] = {
7317
+ ...existing,
7318
+ fields
7319
+ };
7320
+ }
7279
7321
  break;
7280
7322
  }
7281
7323
  case "field_removed": {
7282
7324
  const existing = types[change.typeName];
7283
7325
  if (existing) {
7284
- const { [change.fieldName]: _, ...remainingFields } = existing.fields;
7326
+ const remainingFields = copySnapshotRecord(existing.fields);
7327
+ delete remainingFields[change.fieldName];
7285
7328
  types[change.typeName] = {
7286
7329
  ...existing,
7287
7330
  fields: remainingFields
@@ -7292,19 +7335,21 @@ function applyDiffToSnapshot(snapshot, diff) {
7292
7335
  case "index_added":
7293
7336
  case "index_modified": {
7294
7337
  const existing = types[change.typeName];
7295
- if (existing) types[change.typeName] = {
7296
- ...existing,
7297
- indexes: {
7298
- ...existing.indexes,
7299
- [change.indexName]: change.after
7300
- }
7301
- };
7338
+ if (existing) {
7339
+ const indexes = copySnapshotRecord(existing.indexes);
7340
+ indexes[change.indexName] = change.after;
7341
+ types[change.typeName] = {
7342
+ ...existing,
7343
+ indexes
7344
+ };
7345
+ }
7302
7346
  break;
7303
7347
  }
7304
7348
  case "index_removed": {
7305
7349
  const existing = types[change.typeName];
7306
7350
  if (existing && existing.indexes) {
7307
- const { [change.indexName]: _, ...remainingIndexes } = existing.indexes;
7351
+ const remainingIndexes = copySnapshotRecord(existing.indexes);
7352
+ delete remainingIndexes[change.indexName];
7308
7353
  types[change.typeName] = {
7309
7354
  ...existing,
7310
7355
  indexes: Object.keys(remainingIndexes).length > 0 ? remainingIndexes : void 0
@@ -7315,19 +7360,21 @@ function applyDiffToSnapshot(snapshot, diff) {
7315
7360
  case "file_added":
7316
7361
  case "file_modified": {
7317
7362
  const existing = types[change.typeName];
7318
- if (existing) types[change.typeName] = {
7319
- ...existing,
7320
- files: {
7321
- ...existing.files,
7322
- [change.fieldName]: change.after
7323
- }
7324
- };
7363
+ if (existing) {
7364
+ const files = copySnapshotRecord(existing.files);
7365
+ files[change.fieldName] = change.after;
7366
+ types[change.typeName] = {
7367
+ ...existing,
7368
+ files
7369
+ };
7370
+ }
7325
7371
  break;
7326
7372
  }
7327
7373
  case "file_removed": {
7328
7374
  const existing = types[change.typeName];
7329
7375
  if (existing && existing.files) {
7330
- const { [change.fieldName]: _, ...remainingFiles } = existing.files;
7376
+ const remainingFiles = copySnapshotRecord(existing.files);
7377
+ delete remainingFiles[change.fieldName];
7331
7378
  types[change.typeName] = {
7332
7379
  ...existing,
7333
7380
  files: Object.keys(remainingFiles).length > 0 ? remainingFiles : void 0
@@ -7340,20 +7387,21 @@ function applyDiffToSnapshot(snapshot, diff) {
7340
7387
  const existing = types[change.typeName];
7341
7388
  if (existing) {
7342
7389
  const rel = change.after;
7343
- if ((change.relationshipType ?? (existing.forwardRelationships?.[change.relationshipName] ? "forward" : existing.backwardRelationships?.[change.relationshipName] ? "backward" : "forward")) === "forward") types[change.typeName] = {
7344
- ...existing,
7345
- forwardRelationships: {
7346
- ...existing.forwardRelationships,
7347
- [change.relationshipName]: rel
7348
- }
7349
- };
7350
- else types[change.typeName] = {
7351
- ...existing,
7352
- backwardRelationships: {
7353
- ...existing.backwardRelationships,
7354
- [change.relationshipName]: rel
7355
- }
7356
- };
7390
+ if ((change.relationshipType ?? (existing.forwardRelationships?.[change.relationshipName] ? "forward" : existing.backwardRelationships?.[change.relationshipName] ? "backward" : "forward")) === "forward") {
7391
+ const forwardRelationships = copySnapshotRecord(existing.forwardRelationships);
7392
+ forwardRelationships[change.relationshipName] = rel;
7393
+ types[change.typeName] = {
7394
+ ...existing,
7395
+ forwardRelationships
7396
+ };
7397
+ } else {
7398
+ const backwardRelationships = copySnapshotRecord(existing.backwardRelationships);
7399
+ backwardRelationships[change.relationshipName] = rel;
7400
+ types[change.typeName] = {
7401
+ ...existing,
7402
+ backwardRelationships
7403
+ };
7404
+ }
7357
7405
  }
7358
7406
  break;
7359
7407
  }
@@ -7362,13 +7410,15 @@ function applyDiffToSnapshot(snapshot, diff) {
7362
7410
  if (type) {
7363
7411
  const targetType = change.relationshipType ?? (type.forwardRelationships?.[change.relationshipName] ? "forward" : type.backwardRelationships?.[change.relationshipName] ? "backward" : null);
7364
7412
  if (targetType === "forward" && type.forwardRelationships?.[change.relationshipName]) {
7365
- const { [change.relationshipName]: _, ...remaining } = type.forwardRelationships;
7413
+ const remaining = copySnapshotRecord(type.forwardRelationships);
7414
+ delete remaining[change.relationshipName];
7366
7415
  types[change.typeName] = {
7367
7416
  ...type,
7368
7417
  forwardRelationships: Object.keys(remaining).length > 0 ? remaining : void 0
7369
7418
  };
7370
7419
  } else if (targetType === "backward" && type.backwardRelationships?.[change.relationshipName]) {
7371
- const { [change.relationshipName]: _, ...remaining } = type.backwardRelationships;
7420
+ const remaining = copySnapshotRecord(type.backwardRelationships);
7421
+ delete remaining[change.relationshipName];
7372
7422
  types[change.typeName] = {
7373
7423
  ...type,
7374
7424
  backwardRelationships: Object.keys(remaining).length > 0 ? remaining : void 0
@@ -7392,18 +7442,18 @@ function applyDiffToSnapshot(snapshot, diff) {
7392
7442
  break;
7393
7443
  }
7394
7444
  }
7395
- return {
7445
+ return normalizeSchemaSnapshot({
7396
7446
  ...snapshot,
7397
7447
  types,
7398
7448
  createdAt: diff.createdAt
7399
- };
7449
+ });
7400
7450
  }
7401
7451
  /**
7402
7452
  * Reconstruct the latest schema snapshot from all migration files
7403
7453
  * Returns null if no migrations exist
7404
7454
  * @param {string} migrationsDir - Migrations directory path
7405
7455
  * @param {number} [maxVersion] - Optional maximum migration version to apply
7406
- * @returns {SchemaSnapshot | null} Reconstructed snapshot or null if no migrations exist
7456
+ * @returns {NormalizedSchemaSnapshot | null} Reconstructed normalized snapshot or null if no migrations exist
7407
7457
  */
7408
7458
  function reconstructSnapshotFromMigrations(migrationsDir, maxVersion) {
7409
7459
  const files = getMigrationFiles(migrationsDir);
@@ -7766,8 +7816,9 @@ function comparePermissions(ctx, typeName, oldRecordPerm, newRecordPerm, oldGqlP
7766
7816
  * @returns {MigrationDiff} Migration diff between snapshots
7767
7817
  */
7768
7818
  function compareSnapshots(previous, current) {
7769
- for (const type of Object.values(previous.types)) normalizeSnapshotType(type);
7770
- for (const type of Object.values(current.types)) normalizeSnapshotType(type);
7819
+ return compareNormalizedSnapshots(normalizeSchemaSnapshot(previous), normalizeSchemaSnapshot(current));
7820
+ }
7821
+ function compareNormalizedSnapshots(previous, current) {
7771
7822
  const ctx = {
7772
7823
  changes: [],
7773
7824
  breakingChanges: [],
@@ -7902,7 +7953,7 @@ function assertValidMigrationFiles(migrationsDir, namespace) {
7902
7953
  * @returns {Record<string, SnapshotFieldConfig>} Converted field configs
7903
7954
  */
7904
7955
  function convertRemoteFieldsToSnapshot(remoteType) {
7905
- const fields = {};
7956
+ const fields = createSnapshotRecord();
7906
7957
  const remoteFields = remoteType.schema?.fields ?? {};
7907
7958
  for (const [fieldName, remoteField] of Object.entries(remoteFields)) {
7908
7959
  const config = {
@@ -7938,11 +7989,35 @@ function convertRemoteFieldsToSnapshot(remoteType) {
7938
7989
  ...remoteField.serial.format && { format: remoteField.serial.format }
7939
7990
  };
7940
7991
  if (remoteField.scale !== void 0) config.scale = remoteField.scale;
7941
- normalizeSnapshotField(config);
7942
7992
  fields[fieldName] = config;
7943
7993
  }
7944
7994
  return fields;
7945
7995
  }
7996
+ function convertRemoteTypeToSnapshot(remoteType) {
7997
+ const snapshotType = {
7998
+ name: remoteType.name,
7999
+ pluralForm: remoteType.schema?.settings?.pluralForm || inflection.pluralize(remoteType.name),
8000
+ fields: convertRemoteFieldsToSnapshot(remoteType)
8001
+ };
8002
+ if (remoteType.schema?.description) snapshotType.description = remoteType.schema.description;
8003
+ return snapshotType;
8004
+ }
8005
+ /**
8006
+ * Convert remote TailorDB types into the normalized snapshot shape used by drift checks.
8007
+ * @param {ProtoTailorDBType[]} remoteTypes - Remote TailorDB types from the API
8008
+ * @param {string} namespace - Namespace for the reconstructed snapshot
8009
+ * @returns {NormalizedSchemaSnapshot} Normalized snapshot-shaped remote state
8010
+ */
8011
+ function createSnapshotFromRemoteTypes(remoteTypes, namespace) {
8012
+ const types = createSnapshotRecord();
8013
+ for (const remoteType of remoteTypes) types[remoteType.name] = convertRemoteTypeToSnapshot(remoteType);
8014
+ return normalizeSchemaSnapshot({
8015
+ version: 1,
8016
+ namespace,
8017
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
8018
+ types
8019
+ });
8020
+ }
7946
8021
  /**
7947
8022
  * Compare a single field between remote and snapshot
7948
8023
  * @param {string} typeName - Name of the type
@@ -8003,12 +8078,13 @@ const SYSTEM_FIELDS = /* @__PURE__ */ new Set(["id"]);
8003
8078
  * @returns {SchemaDrift[]} List of drifts detected
8004
8079
  */
8005
8080
  function compareRemoteWithSnapshot(remoteTypes, snapshot) {
8006
- for (const type of Object.values(snapshot.types)) normalizeSnapshotType(type);
8081
+ return compareNormalizedRemoteWithSnapshot(createSnapshotFromRemoteTypes(remoteTypes, snapshot.namespace), normalizeSchemaSnapshot(snapshot));
8082
+ }
8083
+ function compareNormalizedRemoteWithSnapshot(remoteSnapshot, snapshot) {
8007
8084
  const drifts = [];
8008
- const remoteTypeMap = /* @__PURE__ */ new Map();
8009
- for (const remoteType of remoteTypes) remoteTypeMap.set(remoteType.name, remoteType);
8085
+ const remoteTypeMap = new Map(Object.entries(remoteSnapshot.types));
8010
8086
  const snapshotTypeNames = new Set(Object.keys(snapshot.types));
8011
- const remoteTypeNames = new Set(remoteTypeMap.keys());
8087
+ const remoteTypeNames = new Set(Object.keys(remoteSnapshot.types));
8012
8088
  for (const typeName of snapshotTypeNames) if (!remoteTypeNames.has(typeName)) drifts.push({
8013
8089
  typeName,
8014
8090
  kind: "type_missing_remote",
@@ -8023,7 +8099,7 @@ function compareRemoteWithSnapshot(remoteTypes, snapshot) {
8023
8099
  if (!remoteTypeNames.has(typeName)) continue;
8024
8100
  const remoteType = assertDefined(remoteTypeMap.get(typeName), `type "${typeName}" missing from remoteTypeMap`);
8025
8101
  const snapshotType = assertDefined(snapshot.types[typeName], `type "${typeName}" missing from snapshot`);
8026
- const remoteFields = convertRemoteFieldsToSnapshot(remoteType);
8102
+ const remoteFields = remoteType.fields;
8027
8103
  const snapshotFields = snapshotType.fields;
8028
8104
  const remoteFieldNames = new Set(Object.keys(remoteFields).filter((f) => !SYSTEM_FIELDS.has(f)));
8029
8105
  const snapshotFieldNames = new Set(Object.keys(snapshotFields).filter((f) => !SYSTEM_FIELDS.has(f)));
@@ -10264,11 +10340,11 @@ async function registerJobFunctions(client, changeSet, appName, appId, unchanged
10264
10340
  const allUsedJobNames = /* @__PURE__ */ new Set();
10265
10341
  unchangedWorkflowJobNames.forEach((jobName) => allUsedJobNames.add(jobName));
10266
10342
  for (const item of [...changeSet.creates, ...changeSet.updates]) for (const jobName of item.usedJobNames) allUsedJobNames.add(jobName);
10267
- const existingJobFunctions = await fetchAll(async (pageToken, maxPageSize) => {
10343
+ const existingJobFunctions = await fetchAll(async (pageToken, _maxPageSize) => {
10268
10344
  const response = await client.listWorkflowJobFunctions({
10269
10345
  workspaceId,
10270
10346
  pageToken,
10271
- pageSize: maxPageSize
10347
+ pageSize: 100
10272
10348
  });
10273
10349
  return [response.jobFunctions.map((j) => j.name), response.nextPageToken];
10274
10350
  });
@@ -10449,11 +10525,11 @@ async function planWorkflow(client, workspaceId, appName, appId, workflows, main
10449
10525
  }
10450
10526
  async function planWorkflowJobFunctionDeletes(params) {
10451
10527
  const { client, workspaceId, appName, appId, retainedWorkflowJobNames } = params;
10452
- const existingJobFunctions = await fetchAll(async (pageToken, maxPageSize) => {
10528
+ const existingJobFunctions = await fetchAll(async (pageToken, _maxPageSize) => {
10453
10529
  const response = await client.listWorkflowJobFunctions({
10454
10530
  workspaceId,
10455
10531
  pageToken,
10456
- pageSize: maxPageSize
10532
+ pageSize: 100
10457
10533
  });
10458
10534
  return [response.jobFunctions.map((jobFunction) => jobFunction.name), response.nextPageToken];
10459
10535
  });
@@ -10609,6 +10685,17 @@ async function validatePlan(input) {
10609
10685
  violations
10610
10686
  });
10611
10687
  }
10688
+ function inPlaceReplaces(schema, kind, items) {
10689
+ validateItems({
10690
+ validator,
10691
+ schema,
10692
+ kind,
10693
+ action: "replace",
10694
+ items,
10695
+ requestKey: "updateRequest",
10696
+ violations
10697
+ });
10698
+ }
10612
10699
  creates(CreateTailorDBServiceRequestSchema, "TailorDB service", tailorDB.changeSet.service.creates);
10613
10700
  creates(CreateTailorDBTypeRequestSchema, "TailorDB type", tailorDB.changeSet.type.creates);
10614
10701
  updates(UpdateTailorDBTypeRequestSchema, "TailorDB type", tailorDB.changeSet.type.updates);
@@ -10732,7 +10819,7 @@ async function validatePlan(input) {
10732
10819
  }
10733
10820
  })));
10734
10821
  creates(CreateAuthConnectionRequestSchema, "Auth connection", auth.changeSet.connection.creates);
10735
- replaces(CreateAuthConnectionRequestSchema, "Auth connection", auth.changeSet.connection.replaces);
10822
+ inPlaceReplaces(UpdateAuthConnectionRequestSchema, "Auth connection", auth.changeSet.connection.replaces);
10736
10823
  if (violations.length === 0) return;
10737
10824
  const resourceNames = new Set(violations.map((v) => `${v.kind}:${v.name}`));
10738
10825
  logger.error(`Pre-flight validation found ${violations.length} violation(s) across ${resourceNames.size} resource(s):`);
@@ -16122,7 +16209,7 @@ async function generate(options) {
16122
16209
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
16123
16210
  let pluginManager;
16124
16211
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
16125
- const { defineApplication } = await import("./application-BakHtldG.mjs");
16212
+ const { defineApplication } = await import("./application-a_ApFuPh.mjs");
16126
16213
  const application = defineApplication({
16127
16214
  config,
16128
16215
  pluginManager
@@ -18387,4 +18474,4 @@ function isDeno() {
18387
18474
 
18388
18475
  //#endregion
18389
18476
  export { getOrganization as $, generateAllTypeManifestsFromSnapshot as $t, listCommand$3 as A, apiCommand as An, getExecutorWaitFailureMessage as At, show as B, paginationArgs as Bn, listWorkflowExecutions as Bt, listCommand$2 as C, getNamespacesWithMigrations as Cn, listWebhookExecutors as Ct, waitWorkflowExecution as D, PluginManager as Dn, listCommand$9 as Dt, waitCommand as E, sdkNameLabelKey as En, triggerExecutor as Et, generateCommand as F, configArg as Fn, startWorkflow as Ft, removeCommand$1 as G, deploy as Gt, extractOwnedNamespaces as H, workspaceArgs as Hn, formatKeyValueTable as Ht, generateMigrationScript as I, confirmationArgs as In, getCommand$5 as It, organizationTree as J, bundleMigrationScript as Jt, updateCommand$1 as K, executeScript as Kt, writeDbTypesFile as L, deploymentArgs as Ln, getWorkflow as Lt, truncate as M, assertWritable as Mn, listExecutorJobs as Mt, truncateCommand as N, defineAppCommand as Nn, watchExecutorJob as Nt, resumeCommand as O, generateUserTypes as On, listExecutors as Ot, generate as P, commonArgs as Pn, startCommand as Pt, getCommand$1 as Q, compareSnapshotWithRemote as Qt, getConfiguredEditorCommand as R, isVerbose as Rn, executionsCommand as Rt, listApps as S, hasChanges as Sn, getFunctionRegistry as St, healthCommand as T, resourceTrn as Tn, triggerCommand as Tt, logBetaWarning as U, getCommand$6 as Ut, showCommand as V, toPageDirection as Vn, functionExecutionStatusToString as Vt, remove as W, getExecutor as Wt, listCommand$4 as X, handleOptionalToRequiredError as Xt, treeCommand as Y, MIGRATION_LABEL_KEY as Yt, listOrganizations as Z, parseMigrationLabelNumber as Zt, getWorkspace as _, reconstructSnapshotFromMigrations as _n, listMachineUsers as _t, updateUser as a, SCHEMA_FILE_NAME as an, getFolder as at, createCommand as b, formatDiffSummary as bn, listFunctionRegistries as bt, listCommand as c, compareSnapshots as cn, createCommand$1 as ct, inviteUser as d, getMigrationDirPath as dn, listOAuth2Clients as dt, protoGqlPermission as en, updateCommand$2 as et, restoreCommand as f, getMigrationFilePath as fn, getCommand$3 as ft, getCommand as g, loadDiff as gn, listCommand$7 as gt, listWorkspaces as h, isValidMigrationNumber as hn, tokenCommand as ht, updateCommand as i, MIGRATE_FILE_NAME as in, getCommand$2 as it, listWorkflows as j, apiCall as jn, jobsCommand as jt, resumeWorkflow as k, prompt as kn, getExecutorJob as kt, listUsers as l, createSnapshotFromLocalTypes as ln, createFolder as lt, listCommand$1 as m, getNextMigrationNumber as mn, getMachineUserToken as mt, query as n, DIFF_FILE_NAME as nn, listCommand$5 as nt, removeCommand as o, assertValidMigrationFiles as on, deleteCommand$1 as ot, restoreWorkspace as p, getMigrationFiles as pn, getOAuth2Client as pt, updateOrganization as q, waitForExecution as qt, queryCommand as r, INITIAL_SCHEMA_NUMBER as rn, listFolders as rt, removeUser as s, compareLocalTypesWithSnapshot as sn, deleteFolder as st, isNativeTypeScriptRuntime as t, DB_TYPES_FILE_NAME as tn, updateFolder as tt, inviteCommand as u, getLatestMigrationNumber as un, listCommand$6 as ut, deleteCommand as v, formatMigrationNumber as vn, generate$1 as vt, getAppHealth as w, ensureConfigId as wn, webhookCommand as wt, createWorkspace as x, formatMigrationDiff as xn, getCommand$4 as xt, deleteWorkspace as y, parseMigrationNumberArg as yn, listCommand$8 as yt, openInConfiguredEditor as z, pagedLogArgs as zn, getWorkflowExecution as zt };
18390
- //# sourceMappingURL=runtime-CSY0eD4_.mjs.map
18477
+ //# sourceMappingURL=runtime-Cd375HD-.mjs.map