@tailor-platform/sdk 1.74.0 → 1.74.1

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 (55) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/{application-DwmoI6ZQ.mjs → application-BsH6tkZC.mjs} +43 -5
  3. package/dist/application-BsH6tkZC.mjs.map +1 -0
  4. package/dist/application-CSUhZMb5.mjs +3 -0
  5. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -16
  6. package/dist/cli/index.mjs +22 -33
  7. package/dist/cli/index.mjs.map +1 -1
  8. package/dist/cli/lib.d.mts +2 -2
  9. package/dist/cli/lib.mjs +3 -3
  10. package/dist/cli/lib.mjs.map +1 -1
  11. package/dist/completion/zsh-worker.zsh +1 -1
  12. package/dist/configure/index.mjs +2 -2
  13. package/dist/configure/services/tailordb/schema.d.mts +5 -19
  14. package/dist/configure/types/field-runtime.d.mts +17 -0
  15. package/dist/configure/types/type.d.mts +1 -18
  16. package/dist/field-runtime-9bfXBAOK.mjs +183 -0
  17. package/dist/field-runtime-9bfXBAOK.mjs.map +1 -0
  18. package/dist/plugin/builtin/seed/index.mjs +1 -1
  19. package/dist/{runtime-Zkg3SUwi.mjs → runtime-DV1EnfMs.mjs} +229 -394
  20. package/dist/runtime-DV1EnfMs.mjs.map +1 -0
  21. package/dist/{schema-DAdZSFOd.mjs → schema-Dl_y0m9e.mjs} +8 -167
  22. package/dist/schema-Dl_y0m9e.mjs.map +1 -0
  23. package/dist/secretmanager-Bd45j7an.mjs +98 -0
  24. package/dist/secretmanager-Bd45j7an.mjs.map +1 -0
  25. package/dist/{seed-DoMTMLcm.mjs → seed-fm0LeYP2.mjs} +14 -3
  26. package/dist/seed-fm0LeYP2.mjs.map +1 -0
  27. package/dist/types-BwzB2okW.mjs +199 -0
  28. package/dist/types-BwzB2okW.mjs.map +1 -0
  29. package/dist/types-KlawuVKa.mjs +4 -0
  30. package/dist/vitest/index.d.mts +8 -1
  31. package/dist/vitest/index.mjs +776 -1
  32. package/dist/vitest/index.mjs.map +1 -1
  33. package/dist/vitest/mock.d.mts +8 -363
  34. package/dist/vitest/mocks/aigateway.d.mts +30 -0
  35. package/dist/vitest/mocks/authconnection.d.mts +28 -0
  36. package/dist/vitest/mocks/file.d.mts +41 -0
  37. package/dist/vitest/mocks/iconv.d.mts +27 -0
  38. package/dist/vitest/mocks/idp.d.mts +44 -0
  39. package/dist/vitest/mocks/secretmanager.d.mts +33 -0
  40. package/dist/vitest/mocks/tailordb.d.mts +71 -0
  41. package/dist/vitest/mocks/workflow.d.mts +115 -0
  42. package/dist/vitest/setup.mjs +1 -1
  43. package/package.json +8 -8
  44. package/dist/application-BndtMTFY.mjs +0 -3
  45. package/dist/application-DwmoI6ZQ.mjs.map +0 -1
  46. package/dist/field-DOsJCPFa.mjs +0 -22
  47. package/dist/field-DOsJCPFa.mjs.map +0 -1
  48. package/dist/mock-Ce1GCi4-.mjs +0 -871
  49. package/dist/mock-Ce1GCi4-.mjs.map +0 -1
  50. package/dist/runtime-Zkg3SUwi.mjs.map +0 -1
  51. package/dist/schema-DAdZSFOd.mjs.map +0 -1
  52. package/dist/seed-DoMTMLcm.mjs.map +0 -1
  53. package/dist/types-qhFZ8y9B.mjs +0 -4
  54. package/dist/types-ywCGpzDZ.mjs +0 -360
  55. package/dist/types-ywCGpzDZ.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
- import { t as db } from "./schema-DAdZSFOd.mjs";
1
+ import { t as db } from "./schema-Dl_y0m9e.mjs";
2
2
  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-CIrhGwHk.mjs";
3
3
  import { t as assertDefined } from "./assert-DBxo8jPo.mjs";
4
4
  import { a as parseBoolean, i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-BEiZZ3qT.mjs";
5
- import { A as hasUserTokenEntry, C as getDistDir, E as loadConfig, F as loadPlatformClientConfig, G as fetchAll, H as writePlatformConfig, K as fetchMachineUserToken, L as loadWorkspaceId, M as loadConfigPath, P as loadMachineUserName, Q as getPlatformBaseUrl, R as platformConfigFromProfile, S as createBundleCache, T as hashFile, X as getConsoleBaseUrl, Z as getOAuth2ClientId, b as getPluginGenerationDependencies, c as HTTP_METHODS, d as buildResolverOperationHookExpr, et as initOperatorClient, f as assertUniqueLocalTailorDBTypeNames, g as platformBundleDefinePlugin, h as stringifyFunction, i as resolverBundleKey, j as loadAccessToken, m as TailorDBTypeSchema, n as generatePluginFilesIfNeeded, nt as resolveStaticWebsiteUrls, p as assertUniqueTailorDBTypeNamesWithExternal, q as fetchPaged, r as loadApplication, rt as byName, t as defineApplication, tt as isDefaultPlatform, u as buildExecutorArgsExpr, w as hashContent, x as hasGenerationHooks, z as readPlatformConfig } from "./application-DwmoI6ZQ.mjs";
5
+ import { $ as getOrNull, A as hasUserTokenEntry, C as getDistDir, E as loadConfig, F as loadPlatformClientConfig, G as fetchAll, H as writePlatformConfig, J as fetchPaged, K as fetchAllTolerant, L as loadWorkspaceId, M as loadConfigPath, P as loadMachineUserName, Q as getOAuth2ClientId, R as platformConfigFromProfile, S as createBundleCache, T as hashFile, Z as getConsoleBaseUrl, at as byName, b as getPluginGenerationDependencies, c as HTTP_METHODS, d as buildResolverOperationHookExpr, et as getPlatformBaseUrl, f as assertUniqueLocalTailorDBTypeNames, g as platformBundleDefinePlugin, h as stringifyFunction, i as resolverBundleKey, it as resolveStaticWebsiteUrls, j as loadAccessToken, m as TailorDBTypeSchema, n as generatePluginFilesIfNeeded, nt as initOperatorClient, p as assertUniqueTailorDBTypeNamesWithExternal, q as fetchMachineUserToken, r as loadApplication, rt as isDefaultPlatform, t as defineApplication, u as buildExecutorArgsExpr, w as hashContent, x as hasGenerationHooks, z as readPlatformConfig } from "./application-BsH6tkZC.mjs";
6
6
  import { o as loadFilesWithIgnores, t as createExecutorService } from "./service-BCRJ-3NV.mjs";
7
7
  import { t as multiline } from "./multiline-sfHpTZZK.mjs";
8
8
  import { t as readPackageJson } from "./package-json-8b0O9TlX.mjs";
@@ -1849,14 +1849,7 @@ async function buildMetaRequest(params) {
1849
1849
  */
1850
1850
  async function fetchExistingResourcesWithLabels(params) {
1851
1851
  const { client, fetchPage, getName, getTrn } = params;
1852
- const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
1853
- try {
1854
- return await fetchPage(pageToken, maxPageSize);
1855
- } catch (error) {
1856
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
1857
- throw error;
1858
- }
1859
- });
1852
+ const withoutLabel = await fetchAllTolerant(fetchPage);
1860
1853
  const existingResources = {};
1861
1854
  await Promise.all(withoutLabel.map(async (resource) => {
1862
1855
  const name = getName(resource);
@@ -2062,23 +2055,20 @@ async function planStaticWebsite(context) {
2062
2055
  const existingDomainsByWebsite = /* @__PURE__ */ new Map();
2063
2056
  const websitesToFetchDomains = [...ownedWebsiteNames].filter((name) => !changeSet.creates.some((c) => c.name === name));
2064
2057
  await Promise.all(websitesToFetchDomains.map(async (name) => {
2065
- try {
2058
+ const domainsWithLabels = await getOrNull(async () => {
2066
2059
  const { customDomains } = await client.listCustomDomains({
2067
2060
  workspaceId,
2068
2061
  staticWebsiteName: name
2069
2062
  });
2070
- const domainsWithLabels = await Promise.all(customDomains.map(async (d) => {
2063
+ return await Promise.all(customDomains.map(async (d) => {
2071
2064
  const { metadata } = await client.getMetadata({ trn: customDomainTrn(workspaceId, name, d.domain) });
2072
2065
  return {
2073
2066
  domain: d.domain,
2074
2067
  allLabels: metadata?.labels
2075
2068
  };
2076
2069
  }));
2077
- existingDomainsByWebsite.set(name, domainsWithLabels);
2078
- } catch (error) {
2079
- if (error instanceof ConnectError && error.code === Code.NotFound) return;
2080
- throw error;
2081
- }
2070
+ });
2071
+ if (domainsWithLabels) existingDomainsByWebsite.set(name, domainsWithLabels);
2082
2072
  }));
2083
2073
  for (const name of ownedWebsiteNames) {
2084
2074
  const desired = new Set(desiredDomainsByWebsite.get(name) ?? []);
@@ -2346,18 +2336,13 @@ function areApplicationsEqual(existing, desired) {
2346
2336
  async function planApplication(context, httpAdapterBuildResult) {
2347
2337
  const { client, workspaceId, application, forRemoval } = context;
2348
2338
  const changeSet = createChangeSet("Applications");
2349
- const existingApplications = await fetchAll(async (pageToken, maxPageSize) => {
2350
- try {
2351
- const { applications, nextPageToken } = await client.listApplications({
2352
- workspaceId,
2353
- pageToken,
2354
- pageSize: maxPageSize
2355
- });
2356
- return [applications, nextPageToken];
2357
- } catch (error) {
2358
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
2359
- throw error;
2360
- }
2339
+ const existingApplications = await fetchAllTolerant(async (pageToken, maxPageSize) => {
2340
+ const { applications, nextPageToken } = await client.listApplications({
2341
+ workspaceId,
2342
+ pageToken,
2343
+ pageSize: maxPageSize
2344
+ });
2345
+ return [applications, nextPageToken];
2361
2346
  });
2362
2347
  if (forRemoval) {
2363
2348
  const candidates = application.id ? existingApplications : existingApplications.filter((app) => app.name === application.name);
@@ -2384,19 +2369,14 @@ async function planApplication(context, httpAdapterBuildResult) {
2384
2369
  authNamespace = application.config.auth.name;
2385
2370
  if (context.externalAuthIdpConfigNames?.has(authNamespace)) authIdpConfigName = context.externalAuthIdpConfigNames.get(authNamespace);
2386
2371
  else {
2387
- const idpConfigs = await fetchAll(async (pageToken, maxPageSize) => {
2388
- try {
2389
- const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
2390
- workspaceId,
2391
- namespaceName: assertDefined(authNamespace, "authNamespace must be set before listing IDP configs"),
2392
- pageToken,
2393
- pageSize: maxPageSize
2394
- });
2395
- return [idpConfigs, nextPageToken];
2396
- } catch (error) {
2397
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
2398
- throw error;
2399
- }
2372
+ const idpConfigs = await fetchAllTolerant(async (pageToken, maxPageSize) => {
2373
+ const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
2374
+ workspaceId,
2375
+ namespaceName: assertDefined(authNamespace, "authNamespace must be set before listing IDP configs"),
2376
+ pageToken,
2377
+ pageSize: maxPageSize
2378
+ });
2379
+ return [idpConfigs, nextPageToken];
2400
2380
  });
2401
2381
  if (idpConfigs.length > 0) {
2402
2382
  const [firstConfig] = idpConfigs;
@@ -2463,13 +2443,10 @@ async function planApplication(context, httpAdapterBuildResult) {
2463
2443
  return changeSet;
2464
2444
  }
2465
2445
  async function fetchAppLabels(client, workspaceId, appName) {
2466
- try {
2446
+ return (await getOrNull(async () => {
2467
2447
  const { metadata } = await client.getMetadata({ trn: resourceTrn(workspaceId, "application", appName) });
2468
- return metadata?.labels;
2469
- } catch (error) {
2470
- if (error instanceof ConnectError && error.code === Code.NotFound) return;
2471
- throw error;
2472
- }
2448
+ return metadata;
2449
+ }))?.labels;
2473
2450
  }
2474
2451
  /**
2475
2452
  * Build per-adapter diff lines for the application plan display. The platform
@@ -2653,18 +2630,13 @@ async function planAuthConnections(client, workspaceId, appName, appId, auths) {
2653
2630
  const resourceOwners = /* @__PURE__ */ new Set();
2654
2631
  const desiredConnections = {};
2655
2632
  for (const auth of auths) for (const [name, config] of Object.entries(auth.connections)) desiredConnections[name] = config;
2656
- const existingList = await fetchAll(async (pageToken, maxPageSize) => {
2657
- try {
2658
- const { connections, nextPageToken } = await client.listAuthConnections({
2659
- workspaceId,
2660
- pageToken,
2661
- pageSize: maxPageSize
2662
- });
2663
- return [connections, nextPageToken];
2664
- } catch (error) {
2665
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
2666
- throw error;
2667
- }
2633
+ const existingList = await fetchAllTolerant(async (pageToken, maxPageSize) => {
2634
+ const { connections, nextPageToken } = await client.listAuthConnections({
2635
+ workspaceId,
2636
+ pageToken,
2637
+ pageSize: maxPageSize
2638
+ });
2639
+ return [connections, nextPageToken];
2668
2640
  });
2669
2641
  const existingConnections = {};
2670
2642
  await Promise.all(existingList.map(async (resource) => {
@@ -3510,15 +3482,12 @@ async function applyIdP(client, result, phase = "create-update") {
3510
3482
  }), ...changeSet.client.updates.map(async (update) => {
3511
3483
  const vaultName = idpClientVaultName(update.namespaceName, update.name);
3512
3484
  const secretName = idpClientSecretName(update.namespaceName, update.name);
3513
- try {
3514
- await client.getSecretManagerVault({
3485
+ if (await getOrNull(async () => {
3486
+ return await client.getSecretManagerVault({
3515
3487
  workspaceId: update.workspaceId,
3516
3488
  secretmanagerVaultName: vaultName
3517
3489
  });
3518
- return;
3519
- } catch (error) {
3520
- if (!(error instanceof ConnectError && error.code === Code.NotFound)) throw error;
3521
- }
3490
+ })) return;
3522
3491
  await client.createSecretManagerVault({
3523
3492
  workspaceId: update.workspaceId,
3524
3493
  secretmanagerVaultName: vaultName
@@ -3766,19 +3735,14 @@ async function planServices$3(client, workspaceId, appName, appId, idps, idpUser
3766
3735
  async function planClients(client, workspaceId, idps, deletedServices, forceApplyAll = false) {
3767
3736
  const changeSet = createChangeSet("IdP clients");
3768
3737
  const fetchClients = (namespaceName) => {
3769
- return fetchAll(async (pageToken, maxPageSize) => {
3770
- try {
3771
- const { clients, nextPageToken } = await client.listIdPClients({
3772
- workspaceId,
3773
- namespaceName,
3774
- pageToken,
3775
- pageSize: maxPageSize
3776
- });
3777
- return [clients, nextPageToken];
3778
- } catch (error) {
3779
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
3780
- throw error;
3781
- }
3738
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
3739
+ const { clients, nextPageToken } = await client.listIdPClients({
3740
+ workspaceId,
3741
+ namespaceName,
3742
+ pageToken,
3743
+ pageSize: maxPageSize
3744
+ });
3745
+ return [clients, nextPageToken];
3782
3746
  });
3783
3747
  };
3784
3748
  const clientsByIdp = await Promise.all(idps.map((idp) => fetchClients(idp.name)));
@@ -4121,19 +4085,14 @@ async function planServices$2(client, workspaceId, appName, appId, auths, forceA
4121
4085
  async function planIdPConfigs(client, workspaceId, auths, deletedServices, forceApplyAll = false) {
4122
4086
  const changeSet = createChangeSet("Auth idpConfigs");
4123
4087
  const fetchIdPConfigs = (namespaceName) => {
4124
- return fetchAll(async (pageToken, maxPageSize) => {
4125
- try {
4126
- const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
4127
- workspaceId,
4128
- namespaceName,
4129
- pageToken,
4130
- pageSize: maxPageSize
4131
- });
4132
- return [idpConfigs, nextPageToken];
4133
- } catch (error) {
4134
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
4135
- throw error;
4136
- }
4088
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
4089
+ const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
4090
+ workspaceId,
4091
+ namespaceName,
4092
+ pageToken,
4093
+ pageSize: maxPageSize
4094
+ });
4095
+ return [idpConfigs, nextPageToken];
4137
4096
  });
4138
4097
  };
4139
4098
  for (const authService of auths) {
@@ -4290,27 +4249,21 @@ async function protoBuiltinIdPConfig(client, workspaceId, builtinIdPConfig) {
4290
4249
  return config;
4291
4250
  }
4292
4251
  async function tryProtoBuiltinIdPConfig(client, workspaceId, builtinIdPConfig) {
4293
- let idpService;
4294
- try {
4295
- idpService = await client.getIdPService({
4252
+ const idpService = await getOrNull(async () => {
4253
+ return await client.getIdPService({
4296
4254
  workspaceId,
4297
4255
  namespaceName: builtinIdPConfig.namespace
4298
4256
  });
4299
- } catch (error) {
4300
- if (error instanceof ConnectError && error.code === Code.NotFound) return;
4301
- throw error;
4302
- }
4303
- let idpClient;
4304
- try {
4305
- idpClient = await client.getIdPClient({
4257
+ });
4258
+ if (!idpService) return void 0;
4259
+ const idpClient = await getOrNull(async () => {
4260
+ return await client.getIdPClient({
4306
4261
  workspaceId,
4307
4262
  namespaceName: builtinIdPConfig.namespace,
4308
4263
  name: builtinIdPConfig.clientName
4309
4264
  });
4310
- } catch (error) {
4311
- if (error instanceof ConnectError && error.code === Code.NotFound) return;
4312
- throw error;
4313
- }
4265
+ });
4266
+ if (!idpClient) return void 0;
4314
4267
  const vaultName = idpClientVaultName(builtinIdPConfig.namespace, builtinIdPConfig.clientName);
4315
4268
  const secretKey = idpClientSecretName(builtinIdPConfig.namespace, builtinIdPConfig.clientName);
4316
4269
  return { config: {
@@ -4331,56 +4284,51 @@ async function planUserProfileConfigs(client, workspaceId, auths, deletedService
4331
4284
  for (const auth of auths) {
4332
4285
  const { config } = auth;
4333
4286
  const name = `${config.name}-user-profile-config`;
4334
- try {
4335
- const { userProfileProviderConfig } = await client.getUserProfileConfig({
4287
+ const existing = await getOrNull(async () => {
4288
+ return await client.getUserProfileConfig({
4336
4289
  workspaceId,
4337
4290
  namespaceName: config.name
4338
4291
  });
4292
+ });
4293
+ if (!existing) {
4339
4294
  const userProfileForUpdate = auth.userProfile;
4340
- if (userProfileForUpdate) {
4341
- const desired = protoUserProfileConfig(userProfileForUpdate);
4342
- if (!forceApplyAll && areUserProfileConfigsEqual(userProfileProviderConfig ?? {}, desired)) changeSet.unchanged.push({ name });
4343
- else changeSet.updates.push({
4344
- name,
4345
- request: {
4346
- workspaceId,
4347
- namespaceName: config.name,
4348
- userProfileProviderConfig: desired
4349
- }
4350
- });
4351
- } else changeSet.deletes.push({
4295
+ if (userProfileForUpdate) changeSet.creates.push({
4352
4296
  name,
4353
4297
  request: {
4354
4298
  workspaceId,
4355
- namespaceName: config.name
4299
+ namespaceName: config.name,
4300
+ userProfileProviderConfig: protoUserProfileConfig(userProfileForUpdate)
4356
4301
  }
4357
4302
  });
4358
- } catch (error) {
4359
- if (error instanceof ConnectError && error.code === Code.NotFound) {
4360
- const userProfileForCreate = auth.userProfile;
4361
- if (userProfileForCreate) changeSet.creates.push({
4362
- name,
4363
- request: {
4364
- workspaceId,
4365
- namespaceName: config.name,
4366
- userProfileProviderConfig: protoUserProfileConfig(userProfileForCreate)
4367
- }
4368
- });
4369
- continue;
4370
- }
4371
- throw error;
4303
+ continue;
4372
4304
  }
4305
+ const userProfileForUpdate = auth.userProfile;
4306
+ if (userProfileForUpdate) {
4307
+ const desired = protoUserProfileConfig(userProfileForUpdate);
4308
+ if (!forceApplyAll && areUserProfileConfigsEqual(existing.userProfileProviderConfig ?? {}, desired)) changeSet.unchanged.push({ name });
4309
+ else changeSet.updates.push({
4310
+ name,
4311
+ request: {
4312
+ workspaceId,
4313
+ namespaceName: config.name,
4314
+ userProfileProviderConfig: desired
4315
+ }
4316
+ });
4317
+ } else changeSet.deletes.push({
4318
+ name,
4319
+ request: {
4320
+ workspaceId,
4321
+ namespaceName: config.name
4322
+ }
4323
+ });
4373
4324
  }
4374
4325
  for (const namespaceName of deletedServices) {
4375
- try {
4376
- await client.getUserProfileConfig({
4326
+ if (!await getOrNull(async () => {
4327
+ return await client.getUserProfileConfig({
4377
4328
  workspaceId,
4378
4329
  namespaceName
4379
4330
  });
4380
- } catch (error) {
4381
- if (error instanceof ConnectError && error.code === Code.NotFound) continue;
4382
- throw error;
4383
- }
4331
+ })) continue;
4384
4332
  changeSet.deletes.push({
4385
4333
  name: `${namespaceName}-user-profile-config`,
4386
4334
  request: {
@@ -4414,54 +4362,49 @@ async function planTenantConfigs(client, workspaceId, auths, deletedServices, fo
4414
4362
  for (const auth of auths) {
4415
4363
  const { config } = auth;
4416
4364
  const name = `${config.name}-tenant-config`;
4417
- try {
4418
- const { tenantProviderConfig } = await client.getTenantConfig({
4365
+ const existing = await getOrNull(async () => {
4366
+ return await client.getTenantConfig({
4419
4367
  workspaceId,
4420
4368
  namespaceName: config.name
4421
4369
  });
4422
- if (config.tenantProvider) {
4423
- const desired = protoTenantConfig(config.tenantProvider);
4424
- if (!forceApplyAll && areTenantProviderConfigsEqual(tenantProviderConfig, desired)) changeSet.unchanged.push({ name });
4425
- else changeSet.updates.push({
4426
- name,
4427
- request: {
4428
- workspaceId,
4429
- namespaceName: config.name,
4430
- tenantProviderConfig: desired
4431
- }
4432
- });
4433
- } else changeSet.deletes.push({
4370
+ });
4371
+ if (!existing) {
4372
+ if (config.tenantProvider) changeSet.creates.push({
4434
4373
  name,
4435
4374
  request: {
4436
4375
  workspaceId,
4437
- namespaceName: config.name
4376
+ namespaceName: config.name,
4377
+ tenantProviderConfig: protoTenantConfig(config.tenantProvider)
4438
4378
  }
4439
4379
  });
4440
- } catch (error) {
4441
- if (error instanceof ConnectError && error.code === Code.NotFound) {
4442
- if (config.tenantProvider) changeSet.creates.push({
4443
- name,
4444
- request: {
4445
- workspaceId,
4446
- namespaceName: config.name,
4447
- tenantProviderConfig: protoTenantConfig(config.tenantProvider)
4448
- }
4449
- });
4450
- continue;
4451
- }
4452
- throw error;
4380
+ continue;
4453
4381
  }
4382
+ if (config.tenantProvider) {
4383
+ const desired = protoTenantConfig(config.tenantProvider);
4384
+ if (!forceApplyAll && areTenantProviderConfigsEqual(existing.tenantProviderConfig, desired)) changeSet.unchanged.push({ name });
4385
+ else changeSet.updates.push({
4386
+ name,
4387
+ request: {
4388
+ workspaceId,
4389
+ namespaceName: config.name,
4390
+ tenantProviderConfig: desired
4391
+ }
4392
+ });
4393
+ } else changeSet.deletes.push({
4394
+ name,
4395
+ request: {
4396
+ workspaceId,
4397
+ namespaceName: config.name
4398
+ }
4399
+ });
4454
4400
  }
4455
4401
  for (const namespaceName of deletedServices) {
4456
- try {
4457
- await client.getTenantConfig({
4402
+ if (!await getOrNull(async () => {
4403
+ return await client.getTenantConfig({
4458
4404
  workspaceId,
4459
4405
  namespaceName
4460
4406
  });
4461
- } catch (error) {
4462
- if (error instanceof ConnectError && error.code === Code.NotFound) continue;
4463
- throw error;
4464
- }
4407
+ })) continue;
4465
4408
  changeSet.deletes.push({
4466
4409
  name: `${namespaceName}-tenant-config`,
4467
4410
  request: {
@@ -4488,19 +4431,14 @@ function protoTenantConfig(tenantConfig) {
4488
4431
  async function planMachineUsers(client, workspaceId, auths, deletedServices, forceApplyAll = false) {
4489
4432
  const changeSet = createChangeSet("Auth machineUsers");
4490
4433
  const fetchMachineUsers = (authNamespace) => {
4491
- return fetchAll(async (pageToken, maxPageSize) => {
4492
- try {
4493
- const { machineUsers, nextPageToken } = await client.listAuthMachineUsers({
4494
- workspaceId,
4495
- authNamespace,
4496
- pageToken,
4497
- pageSize: maxPageSize
4498
- });
4499
- return [machineUsers, nextPageToken];
4500
- } catch (error) {
4501
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
4502
- throw error;
4503
- }
4434
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
4435
+ const { machineUsers, nextPageToken } = await client.listAuthMachineUsers({
4436
+ workspaceId,
4437
+ authNamespace,
4438
+ pageToken,
4439
+ pageSize: maxPageSize
4440
+ });
4441
+ return [machineUsers, nextPageToken];
4504
4442
  });
4505
4443
  };
4506
4444
  for (const auth of auths) {
@@ -4627,19 +4565,14 @@ function areOAuth2ClientsEqual(existing, desired) {
4627
4565
  async function planOAuth2Clients(client, workspaceId, auths, deletedServices, expectedLocalWebsites, forceApplyAll = false) {
4628
4566
  const changeSet = createChangeSet("Auth oauth2Clients");
4629
4567
  const fetchOAuth2Clients = (namespaceName) => {
4630
- return fetchAll(async (pageToken, maxPageSize) => {
4631
- try {
4632
- const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
4633
- workspaceId,
4634
- namespaceName,
4635
- pageToken,
4636
- pageSize: maxPageSize
4637
- });
4638
- return [oauth2Clients, nextPageToken];
4639
- } catch (error) {
4640
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
4641
- throw error;
4642
- }
4568
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
4569
+ const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
4570
+ workspaceId,
4571
+ namespaceName,
4572
+ pageToken,
4573
+ pageSize: maxPageSize
4574
+ });
4575
+ return [oauth2Clients, nextPageToken];
4643
4576
  });
4644
4577
  };
4645
4578
  for (const auth of auths) {
@@ -4756,26 +4689,21 @@ async function planSCIMConfigs(client, workspaceId, auths, deletedServices) {
4756
4689
  for (const auth of auths) {
4757
4690
  const { config } = auth;
4758
4691
  const name = `${config.name}-scim-config`;
4759
- try {
4760
- await client.getAuthSCIMConfig({
4692
+ if (!await getOrNull(async () => {
4693
+ return await client.getAuthSCIMConfig({
4761
4694
  workspaceId,
4762
4695
  namespaceName: config.name
4763
4696
  });
4764
- } catch (error) {
4765
- if (error instanceof ConnectError && error.code === Code.NotFound) {
4766
- if (config.scim) changeSet.creates.push({
4767
- name,
4768
- request: {
4769
- workspaceId,
4770
- namespaceName: config.name,
4771
- scimConfig: protoSCIMConfig(config.scim)
4772
- }
4773
- });
4774
- continue;
4775
- }
4776
- throw error;
4777
- }
4778
- if (config.scim) changeSet.updates.push({
4697
+ })) {
4698
+ if (config.scim) changeSet.creates.push({
4699
+ name,
4700
+ request: {
4701
+ workspaceId,
4702
+ namespaceName: config.name,
4703
+ scimConfig: protoSCIMConfig(config.scim)
4704
+ }
4705
+ });
4706
+ } else if (config.scim) changeSet.updates.push({
4779
4707
  name,
4780
4708
  request: {
4781
4709
  workspaceId,
@@ -4792,15 +4720,12 @@ async function planSCIMConfigs(client, workspaceId, auths, deletedServices) {
4792
4720
  });
4793
4721
  }
4794
4722
  for (const namespaceName of deletedServices) {
4795
- try {
4796
- await client.getAuthSCIMConfig({
4723
+ if (!await getOrNull(async () => {
4724
+ return await client.getAuthSCIMConfig({
4797
4725
  workspaceId,
4798
4726
  namespaceName
4799
4727
  });
4800
- } catch (error) {
4801
- if (error instanceof ConnectError && error.code === Code.NotFound) continue;
4802
- throw error;
4803
- }
4728
+ })) continue;
4804
4729
  changeSet.deletes.push({
4805
4730
  name: `${namespaceName}-scim-config`,
4806
4731
  request: {
@@ -4837,16 +4762,13 @@ function protoSCIMConfig(scimConfig) {
4837
4762
  async function planSCIMResources(client, workspaceId, auths, deletedServices) {
4838
4763
  const changeSet = createChangeSet("Auth scimResources");
4839
4764
  const fetchSCIMResources = async (namespaceName) => {
4840
- try {
4765
+ return await getOrNull(async () => {
4841
4766
  const { scimResources } = await client.getAuthSCIMResources({
4842
4767
  workspaceId,
4843
4768
  namespaceName
4844
4769
  });
4845
4770
  return scimResources;
4846
- } catch (error) {
4847
- if (error instanceof ConnectError && error.code === Code.NotFound) return [];
4848
- throw error;
4849
- }
4771
+ }) ?? [];
4850
4772
  };
4851
4773
  for (const auth of auths) {
4852
4774
  const { config } = auth;
@@ -5004,18 +4926,14 @@ async function planAuthHooks(client, workspaceId, auths, deletedServices, forceA
5004
4926
  for (const auth of auths) {
5005
4927
  const { config } = auth;
5006
4928
  const beforeLogin = config.hooks?.beforeLogin;
5007
- let existingHook;
5008
- try {
4929
+ const existingHook = await getOrNull(async () => {
5009
4930
  const { hook } = await client.getAuthHook({
5010
4931
  workspaceId,
5011
4932
  namespaceName: config.name,
5012
4933
  hookPoint: AuthHookPoint.BEFORE_LOGIN
5013
4934
  });
5014
- existingHook = hook;
5015
- } catch (error) {
5016
- if (error instanceof ConnectError && error.code === Code.NotFound) existingHook = void 0;
5017
- else throw error;
5018
- }
4935
+ return hook;
4936
+ });
5019
4937
  if (beforeLogin) {
5020
4938
  const hookRequest = {
5021
4939
  workspaceId,
@@ -5047,23 +4965,20 @@ async function planAuthHooks(client, workspaceId, auths, deletedServices, forceA
5047
4965
  }
5048
4966
  });
5049
4967
  }
5050
- for (const namespaceName of deletedServices) try {
5051
- await client.getAuthHook({
4968
+ for (const namespaceName of deletedServices) if (await getOrNull(async () => {
4969
+ return await client.getAuthHook({
5052
4970
  workspaceId,
5053
4971
  namespaceName,
5054
4972
  hookPoint: AuthHookPoint.BEFORE_LOGIN
5055
4973
  });
5056
- changeSet.deletes.push({
5057
- name: `${namespaceName}/before-login`,
5058
- request: {
5059
- workspaceId,
5060
- namespaceName,
5061
- hookPoint: AuthHookPoint.BEFORE_LOGIN
5062
- }
5063
- });
5064
- } catch (error) {
5065
- if (error instanceof ConnectError && error.code === Code.NotFound) {} else throw error;
5066
- }
4974
+ })) changeSet.deletes.push({
4975
+ name: `${namespaceName}/before-login`,
4976
+ request: {
4977
+ workspaceId,
4978
+ namespaceName,
4979
+ hookPoint: AuthHookPoint.BEFORE_LOGIN
4980
+ }
4981
+ });
5067
4982
  return changeSet;
5068
4983
  }
5069
4984
 
@@ -5702,19 +5617,14 @@ async function planServices$1(client, workspaceId, appName, appId, pipelines) {
5702
5617
  async function planResolvers(client, workspaceId, pipelines, executors, initialExecutorUsedResolvers, deletedServices, env, authNamespace, forceApplyAll = false) {
5703
5618
  const changeSet = createChangeSet("Pipeline resolvers");
5704
5619
  const fetchResolvers = (namespaceName) => {
5705
- return fetchAll(async (pageToken, maxPageSize) => {
5706
- try {
5707
- const { pipelineResolvers, nextPageToken } = await client.listPipelineResolvers({
5708
- workspaceId,
5709
- namespaceName,
5710
- pageToken,
5711
- pageSize: maxPageSize
5712
- });
5713
- return [pipelineResolvers, nextPageToken];
5714
- } catch (error) {
5715
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
5716
- throw error;
5717
- }
5620
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
5621
+ const { pipelineResolvers, nextPageToken } = await client.listPipelineResolvers({
5622
+ workspaceId,
5623
+ namespaceName,
5624
+ pageToken,
5625
+ pageSize: maxPageSize
5626
+ });
5627
+ return [pipelineResolvers, nextPageToken];
5718
5628
  });
5719
5629
  };
5720
5630
  const executorUsedResolvers = new Set(initialExecutorUsedResolvers);
@@ -5998,19 +5908,14 @@ async function planSecretManager(context) {
5998
5908
  workspaceId
5999
5909
  });
6000
5910
  let existingSecrets = [];
6001
- if (existing) existingSecrets = (await fetchAll(async (pageToken, maxPageSize) => {
6002
- try {
6003
- const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
6004
- workspaceId,
6005
- secretmanagerVaultName: vaultName,
6006
- pageToken,
6007
- pageSize: maxPageSize
6008
- });
6009
- return [secrets, nextPageToken];
6010
- } catch (error) {
6011
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
6012
- throw error;
6013
- }
5911
+ if (existing) existingSecrets = (await fetchAllTolerant(async (pageToken, maxPageSize) => {
5912
+ const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
5913
+ workspaceId,
5914
+ secretmanagerVaultName: vaultName,
5915
+ pageToken,
5916
+ pageSize: maxPageSize
5917
+ });
5918
+ return [secrets, nextPageToken];
6014
5919
  })).map((s) => s.name);
6015
5920
  const existingSet = new Set(existingSecrets);
6016
5921
  for (const secret of vault.secrets) {
@@ -6054,19 +5959,14 @@ async function planSecretManager(context) {
6054
5959
  appId: application.id,
6055
5960
  resourceOwners
6056
5961
  })) {
6057
- const secrets = await fetchAll(async (pageToken, maxPageSize) => {
6058
- try {
6059
- const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
6060
- workspaceId,
6061
- secretmanagerVaultName: name,
6062
- pageToken,
6063
- pageSize: maxPageSize
6064
- });
6065
- return [secrets, nextPageToken];
6066
- } catch (error) {
6067
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
6068
- throw error;
6069
- }
5962
+ const secrets = await fetchAllTolerant(async (pageToken, maxPageSize) => {
5963
+ const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
5964
+ workspaceId,
5965
+ secretmanagerVaultName: name,
5966
+ pageToken,
5967
+ pageSize: maxPageSize
5968
+ });
5969
+ return [secrets, nextPageToken];
6070
5970
  });
6071
5971
  for (const secret of secrets) secretChangeSet.deletes.push({
6072
5972
  name: `${name}/${secret.name}`,
@@ -6868,52 +6768,7 @@ function getMigrationFilePath(migrationsDir, num, type) {
6868
6768
  return path.join(migrationDir, MIGRATION_FILE_NAMES[type]);
6869
6769
  }
6870
6770
  /**
6871
- * Create a snapshot field config from a parsed field
6872
- * @param {ParsedField} field - Parsed field definition
6873
- * @returns {SnapshotFieldConfig} Snapshot field configuration
6874
- */
6875
- function createSnapshotFieldConfig(field) {
6876
- const config = {
6877
- type: field.config.type,
6878
- required: field.config.required !== false
6879
- };
6880
- if (field.config.array) config.array = true;
6881
- if (field.config.index) config.index = true;
6882
- if (field.config.unique) config.unique = true;
6883
- if (field.config.allowedValues && field.config.allowedValues.length > 0) config.allowedValues = field.config.allowedValues.map((v) => ({
6884
- value: v.value,
6885
- ...v.description && { description: v.description }
6886
- }));
6887
- if (field.config.foreignKey) {
6888
- config.foreignKey = true;
6889
- if (field.config.foreignKeyType) config.foreignKeyType = field.config.foreignKeyType;
6890
- if (field.config.foreignKeyField) config.foreignKeyField = field.config.foreignKeyField;
6891
- }
6892
- if (field.config.description) config.description = field.config.description;
6893
- if (field.config.vector) config.vector = true;
6894
- if (field.config.hooks) {
6895
- config.hooks = {};
6896
- if (field.config.hooks.create) config.hooks.create = { expr: field.config.hooks.create.expr };
6897
- if (field.config.hooks.update) config.hooks.update = { expr: field.config.hooks.update.expr };
6898
- }
6899
- if (field.config.validate && field.config.validate.length > 0) config.validate = field.config.validate.map((v) => ({
6900
- script: { expr: v.script.expr },
6901
- errorMessage: v.errorMessage
6902
- }));
6903
- if (field.config.serial) config.serial = {
6904
- start: field.config.serial.start,
6905
- ...field.config.serial.maxValue !== void 0 && { maxValue: field.config.serial.maxValue },
6906
- ...field.config.serial.format && { format: field.config.serial.format }
6907
- };
6908
- if (field.config.scale !== void 0) config.scale = field.config.scale;
6909
- if (field.config.fields && Object.keys(field.config.fields).length > 0) {
6910
- config.fields = {};
6911
- for (const [nestedName, nestedConfig] of Object.entries(field.config.fields)) config.fields[nestedName] = createSnapshotFieldConfigFromOperatorConfig(nestedConfig);
6912
- }
6913
- return normalizeSnapshotField(config);
6914
- }
6915
- /**
6916
- * Create a snapshot field config from an OperatorFieldConfig (for nested fields)
6771
+ * Create a snapshot field config from an OperatorFieldConfig.
6917
6772
  * @param {import("#/parser/service/tailordb/types").OperatorFieldConfig} fieldConfig - Field configuration
6918
6773
  * @returns {SnapshotFieldConfig} Snapshot field configuration
6919
6774
  */
@@ -6964,7 +6819,7 @@ function createSnapshotFieldConfigFromOperatorConfig(fieldConfig) {
6964
6819
  */
6965
6820
  function createSnapshotType(type) {
6966
6821
  const fields = createSnapshotRecord();
6967
- for (const [fieldName, field] of Object.entries(type.fields)) fields[fieldName] = createSnapshotFieldConfig(field);
6822
+ for (const [fieldName, field] of Object.entries(type.fields)) fields[fieldName] = createSnapshotFieldConfigFromOperatorConfig(field.config);
6968
6823
  const snapshotType = {
6969
6824
  name: type.name,
6970
6825
  pluralForm: type.pluralForm || inflection.pluralize(type.name),
@@ -9511,35 +9366,25 @@ function groupMigrationsByNamespace(migrations) {
9511
9366
  * @returns {Promise<ProtoTailorDBType[]>} Remote TailorDB types
9512
9367
  */
9513
9368
  async function fetchRemoteTypes(client, workspaceId, namespace) {
9514
- return fetchAll(async (pageToken, maxPageSize) => {
9515
- try {
9516
- const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
9517
- workspaceId,
9518
- namespaceName: namespace,
9519
- pageToken,
9520
- pageSize: maxPageSize
9521
- });
9522
- return [tailordbTypes, nextPageToken];
9523
- } catch (error) {
9524
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
9525
- throw error;
9526
- }
9369
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
9370
+ const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
9371
+ workspaceId,
9372
+ namespaceName: namespace,
9373
+ pageToken,
9374
+ pageSize: maxPageSize
9375
+ });
9376
+ return [tailordbTypes, nextPageToken];
9527
9377
  });
9528
9378
  }
9529
9379
  async function fetchRemoteGqlPermissions(client, workspaceId, namespace) {
9530
- return fetchAll(async (pageToken, maxPageSize) => {
9531
- try {
9532
- const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
9533
- workspaceId,
9534
- namespaceName: namespace,
9535
- pageToken,
9536
- pageSize: maxPageSize
9537
- });
9538
- return [permissions, nextPageToken];
9539
- } catch (error) {
9540
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
9541
- throw error;
9542
- }
9380
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
9381
+ const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
9382
+ workspaceId,
9383
+ namespaceName: namespace,
9384
+ pageToken,
9385
+ pageSize: maxPageSize
9386
+ });
9387
+ return [permissions, nextPageToken];
9543
9388
  });
9544
9389
  }
9545
9390
  function definedWhenNotEmpty(value) {
@@ -10328,19 +10173,14 @@ async function planServices(client, workspaceId, appName, appId, tailordbs) {
10328
10173
  async function planTypes(client, workspaceId, tailordbs, executorUsedTypes, deletedServices, filteredTypesByNamespace, forceApplyAll = false) {
10329
10174
  const changeSet = createChangeSet("TailorDB types");
10330
10175
  const fetchTypes = (namespaceName) => {
10331
- return fetchAll(async (pageToken, maxPageSize) => {
10332
- try {
10333
- const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
10334
- workspaceId,
10335
- namespaceName,
10336
- pageToken,
10337
- pageSize: maxPageSize
10338
- });
10339
- return [tailordbTypes, nextPageToken];
10340
- } catch (error) {
10341
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
10342
- throw error;
10343
- }
10176
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
10177
+ const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
10178
+ workspaceId,
10179
+ namespaceName,
10180
+ pageToken,
10181
+ pageSize: maxPageSize
10182
+ });
10183
+ return [tailordbTypes, nextPageToken];
10344
10184
  });
10345
10185
  };
10346
10186
  for (const tailordb of tailordbs) {
@@ -10475,19 +10315,14 @@ function isNumericLikeValue(value) {
10475
10315
  async function planGqlPermissions(client, workspaceId, tailordbs, deletedServices, forceApplyAll = false) {
10476
10316
  const changeSet = createChangeSet("TailorDB gqlPermissions");
10477
10317
  const fetchGqlPermissions = (namespaceName) => {
10478
- return fetchAll(async (pageToken, maxPageSize) => {
10479
- try {
10480
- const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
10481
- workspaceId,
10482
- namespaceName,
10483
- pageToken,
10484
- pageSize: maxPageSize
10485
- });
10486
- return [permissions, nextPageToken];
10487
- } catch (error) {
10488
- if (error instanceof ConnectError && error.code === Code.NotFound) return [[], ""];
10489
- throw error;
10490
- }
10318
+ return fetchAllTolerant(async (pageToken, maxPageSize) => {
10319
+ const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
10320
+ workspaceId,
10321
+ namespaceName,
10322
+ pageToken,
10323
+ pageSize: maxPageSize
10324
+ });
10325
+ return [permissions, nextPageToken];
10491
10326
  });
10492
10327
  };
10493
10328
  for (const tailordb of tailordbs) {
@@ -11686,13 +11521,13 @@ async function shouldForceApplyAll(client, workspaceId, application, functionEnt
11686
11521
  functionEntries.forEach((entry) => {
11687
11522
  candidateTrns.add(resourceTrn(workspaceId, "function_registry", entry.name));
11688
11523
  });
11689
- for (const trn of candidateTrns) try {
11690
- const { metadata } = await client.getMetadata({ trn });
11524
+ for (const trn of candidateTrns) {
11525
+ const metadata = await getOrNull(async () => {
11526
+ const { metadata } = await client.getMetadata({ trn });
11527
+ return metadata;
11528
+ });
11691
11529
  if (metadata?.labels["sdk-name"] !== application.name) continue;
11692
11530
  if (!hasMatchingSdkVersion(metadata.labels, desiredLabels)) return true;
11693
- } catch (error) {
11694
- if (error instanceof ConnectError && error.code === Code.NotFound) continue;
11695
- throw error;
11696
11531
  }
11697
11532
  return false;
11698
11533
  }
@@ -17462,7 +17297,7 @@ async function generate(options) {
17462
17297
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
17463
17298
  let pluginManager;
17464
17299
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
17465
- const { defineApplication } = await import("./application-BndtMTFY.mjs");
17300
+ const { defineApplication } = await import("./application-CSUhZMb5.mjs");
17466
17301
  const application = defineApplication({
17467
17302
  config,
17468
17303
  pluginManager
@@ -19727,4 +19562,4 @@ function isDeno() {
19727
19562
 
19728
19563
  //#endregion
19729
19564
  export { getOrganization as $, compareSnapshotWithRemote as $t, listCommand$3 as A, apiCommand as An, getExecutorWaitFailureMessage as At, show as B, pagedLogArgs as Bn, listWorkflowExecutions as Bt, listCommand$2 as C, hasChanges 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, toPageDirection as Hn, formatKeyValueTable as Ht, generateMigrationScript as I, confirmationArgs as In, getCommand$5 as It, organizationTree as J, waitForExecution as Jt, updateCommand$1 as K, ensureConfigId 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, parseMigrationLabelNumber as Qt, getConfiguredEditorCommand as R, isVerbose as Rn, executionsCommand as Rt, listApps as S, formatMigrationDiff as Sn, getFunctionRegistry as St, healthCommand as T, resourceTrn as Tn, triggerCommand as Tt, logBetaWarning as U, workspaceArgs as Un, getCommand$6 as Ut, showCommand as V, paginationArgs as Vn, functionExecutionStatusToString as Vt, remove as W, getExecutor as Wt, listCommand$4 as X, MIGRATION_LABEL_KEY as Xt, treeCommand as Y, bundleMigrationScript as Yt, listOrganizations as Z, handleOptionalToRequiredError as Zt, getWorkspace as _, loadDiff as _n, listMachineUsers as _t, updateUser as a, MIGRATE_FILE_NAME as an, getFolder as at, createCommand as b, parseMigrationNumberArg as bn, listFunctionRegistries as bt, listCommand as c, compareLocalTypesWithSnapshot as cn, createCommand$1 as ct, inviteUser as d, getLatestMigrationNumber as dn, listOAuth2Clients as dt, generateAllTypeManifestsFromSnapshot as en, updateCommand$2 as et, restoreCommand as f, getMigrationDirPath as fn, getCommand$3 as ft, getCommand as g, isValidMigrationNumber as gn, listCommand$7 as gt, listWorkspaces as h, getNextMigrationNumber as hn, tokenCommand as ht, updateCommand as i, INITIAL_SCHEMA_NUMBER 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, compareSnapshots as ln, createFolder as lt, listCommand$1 as m, getMigrationFiles as mn, getMachineUserToken as mt, query as n, DB_TYPES_FILE_NAME as nn, listCommand$5 as nt, removeCommand as o, SCHEMA_FILE_NAME as on, deleteCommand$1 as ot, restoreWorkspace as p, getMigrationFilePath as pn, getOAuth2Client as pt, updateOrganization as q, executeScript as qt, queryCommand as r, DIFF_FILE_NAME as rn, listFolders as rt, removeUser as s, assertValidMigrationFiles as sn, deleteFolder as st, isNativeTypeScriptRuntime as t, protoGqlPermission as tn, updateFolder as tt, inviteCommand as u, createSnapshotFromLocalTypes as un, listCommand$6 as ut, deleteCommand as v, reconstructSnapshotFromMigrations as vn, generate$1 as vt, getAppHealth as w, getNamespacesWithMigrations as wn, webhookCommand as wt, createWorkspace as x, formatDiffSummary as xn, getCommand$4 as xt, deleteWorkspace as y, formatMigrationNumber as yn, listCommand$8 as yt, openInConfiguredEditor as z, multiConfigArg as zn, getWorkflowExecution as zt };
19730
- //# sourceMappingURL=runtime-Zkg3SUwi.mjs.map
19565
+ //# sourceMappingURL=runtime-DV1EnfMs.mjs.map