@tailor-platform/sdk 1.74.0 → 1.75.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 (89) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/application-BJKNlv8c.mjs +3 -0
  3. package/dist/{application-DwmoI6ZQ.mjs → application-DYshsH-K.mjs} +61 -11
  4. package/dist/application-DYshsH-K.mjs.map +1 -0
  5. package/dist/brand-Eo4pLXPJ.mjs.map +1 -1
  6. package/dist/cli/commands/deploy/workflow-execution-policy.d.mts +1 -0
  7. package/dist/cli/commands/tailordb/migrate/snapshot.d.mts +1 -16
  8. package/dist/cli/index.mjs +23 -34
  9. package/dist/cli/index.mjs.map +1 -1
  10. package/dist/cli/lib.d.mts +2 -2
  11. package/dist/cli/lib.mjs +3 -3
  12. package/dist/cli/lib.mjs.map +1 -1
  13. package/dist/completion/zsh-worker.zsh +9 -9
  14. package/dist/configure/config/types.d.mts +3 -1
  15. package/dist/configure/index.d.mts +3 -1
  16. package/dist/configure/index.mjs +113 -5
  17. package/dist/configure/index.mjs.map +1 -1
  18. package/dist/configure/services/index.d.mts +3 -1
  19. package/dist/configure/services/tailordb/schema.d.mts +5 -19
  20. package/dist/configure/services/workflow/execution-policy.d.mts +71 -0
  21. package/dist/configure/services/workflow/execution-policy.types.d.mts +104 -0
  22. package/dist/configure/services/workflow/index.d.mts +3 -1
  23. package/dist/configure/services/workflow/job.d.mts +7 -3
  24. package/dist/configure/types/field-runtime.d.mts +17 -0
  25. package/dist/configure/types/type.d.mts +1 -18
  26. package/dist/field-runtime-9bfXBAOK.mjs +183 -0
  27. package/dist/field-runtime-9bfXBAOK.mjs.map +1 -0
  28. package/dist/{globals-B8XX5TRB.mjs → globals-CcU1ONiK.mjs} +2 -2
  29. package/dist/globals-CcU1ONiK.mjs.map +1 -0
  30. package/dist/{job-CtU73PGa.mjs → job-D-PbD1P3.mjs} +5 -3
  31. package/dist/job-D-PbD1P3.mjs.map +1 -0
  32. package/dist/plugin/builtin/seed/index.mjs +1 -1
  33. package/dist/{registry-BozuxbPp.mjs → registry-NfSW0BRo.mjs} +4 -3
  34. package/dist/registry-NfSW0BRo.mjs.map +1 -0
  35. package/dist/runtime/globals.d.mts +1 -1
  36. package/dist/runtime/index.d.mts +1 -1
  37. package/dist/runtime/workflow.d.mts +22 -3
  38. package/dist/{runtime-Zkg3SUwi.mjs → runtime-CJ5usBOu.mjs} +456 -397
  39. package/dist/runtime-CJ5usBOu.mjs.map +1 -0
  40. package/dist/{schema-DAdZSFOd.mjs → schema-Dl_y0m9e.mjs} +8 -167
  41. package/dist/schema-Dl_y0m9e.mjs.map +1 -0
  42. package/dist/secretmanager-Bd45j7an.mjs +98 -0
  43. package/dist/secretmanager-Bd45j7an.mjs.map +1 -0
  44. package/dist/{seed-DoMTMLcm.mjs → seed-fm0LeYP2.mjs} +14 -3
  45. package/dist/seed-fm0LeYP2.mjs.map +1 -0
  46. package/dist/{service_pb-CIrhGwHk.mjs → service_pb-4unFyubn.mjs} +16 -6
  47. package/dist/{service_pb-CIrhGwHk.mjs.map → service_pb-4unFyubn.mjs.map} +1 -1
  48. package/dist/{service_pb-DjwIn4jO.mjs → service_pb-D-PXRoMg.mjs} +1 -1
  49. package/dist/tailor-proto/src/tailor/v1/service_pb.d.mts +1 -1
  50. package/dist/tailor-proto/src/tailor/v1/workflow_pb.d.mts +29 -9
  51. package/dist/tailor-proto/src/tailor/v1/workflow_resource_pb.d.mts +35 -1
  52. package/dist/types-BwzB2okW.mjs +199 -0
  53. package/dist/types-BwzB2okW.mjs.map +1 -0
  54. package/dist/types-KlawuVKa.mjs +4 -0
  55. package/dist/utils/test/index.mjs +1 -1
  56. package/dist/utils/test/index.mjs.map +1 -1
  57. package/dist/vitest/environment.mjs +1 -1
  58. package/dist/vitest/index.d.mts +8 -1
  59. package/dist/vitest/index.mjs +779 -1
  60. package/dist/vitest/index.mjs.map +1 -1
  61. package/dist/vitest/mock.d.mts +8 -363
  62. package/dist/vitest/mocks/aigateway.d.mts +30 -0
  63. package/dist/vitest/mocks/authconnection.d.mts +28 -0
  64. package/dist/vitest/mocks/file.d.mts +41 -0
  65. package/dist/vitest/mocks/iconv.d.mts +27 -0
  66. package/dist/vitest/mocks/idp.d.mts +44 -0
  67. package/dist/vitest/mocks/secretmanager.d.mts +33 -0
  68. package/dist/vitest/mocks/tailordb.d.mts +71 -0
  69. package/dist/vitest/mocks/workflow.d.mts +117 -0
  70. package/dist/vitest/setup.mjs +2 -2
  71. package/dist/workflow-DSwnYPPP.mjs.map +1 -1
  72. package/docs/configuration.md +24 -0
  73. package/docs/services/workflow.md +78 -0
  74. package/package.json +8 -8
  75. package/dist/application-BndtMTFY.mjs +0 -3
  76. package/dist/application-DwmoI6ZQ.mjs.map +0 -1
  77. package/dist/field-DOsJCPFa.mjs +0 -22
  78. package/dist/field-DOsJCPFa.mjs.map +0 -1
  79. package/dist/globals-B8XX5TRB.mjs.map +0 -1
  80. package/dist/job-CtU73PGa.mjs.map +0 -1
  81. package/dist/mock-Ce1GCi4-.mjs +0 -871
  82. package/dist/mock-Ce1GCi4-.mjs.map +0 -1
  83. package/dist/registry-BozuxbPp.mjs.map +0 -1
  84. package/dist/runtime-Zkg3SUwi.mjs.map +0 -1
  85. package/dist/schema-DAdZSFOd.mjs.map +0 -1
  86. package/dist/seed-DoMTMLcm.mjs.map +0 -1
  87. package/dist/types-qhFZ8y9B.mjs +0 -4
  88. package/dist/types-ywCGpzDZ.mjs +0 -360
  89. package/dist/types-ywCGpzDZ.mjs.map +0 -1
@@ -1,8 +1,8 @@
1
- import { t as db } from "./schema-DAdZSFOd.mjs";
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";
1
+ import { t as db } from "./schema-Dl_y0m9e.mjs";
2
+ import { $ as CreateAuthServiceRequestSchema, A as CreatePipelineServiceRequestSchema, At as Subgraph_ServiceType, C as CreateStaticWebsiteRequestSchema, D as CreateSecretManagerVaultRequestSchema, Dt as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, E as CreateSecretManagerSecretRequestSchema, Et as CreateApplicationRequestSchema, F as UpdateIdPServiceRequestSchema, G as ExecutorTriggerType, H as UpdateExecutorExecutorRequestSchema, I as IdPLang, J as CreateAuthIDPConfigRequestSchema, K as CreateAuthConnectionRequestSchema, L as IdPPermissionOperator, M as UpdatePipelineServiceRequestSchema, Mt as Condition_Operator, N as PipelineResolver_OperationType, Nt as FilterSchema, O as UpdateSecretManagerSecretRequestSchema, Ot as UpdateApplicationRequestSchema, P as CreateIdPServiceRequestSchema, Pt as PageDirection, Q as CreateAuthSCIMResourceRequestSchema, R as IdPPermissionPermit, S as AddCustomDomainRequestSchema, St as AuthSCIMConfig_AuthorizationType, Tt as UserProfileProviderConfig_UserProfileProviderType, U as ExecutorJobStatus, V as CreateExecutorExecutorRequestSchema, W as ExecutorTargetType, X as CreateAuthOAuth2ClientRequestSchema, Y as CreateAuthMachineUserRequestSchema, Z as CreateAuthSCIMConfigRequestSchema, _ as TailorDBGQLPermission_Operator, _t as AuthOAuth2Client_ClientType, a as WorkspacePlatformUserRole, at as UpdateAuthMachineUserRequestSchema, b as TailorDBType_Permission_Permit, bt as AuthSCIMAttribute_Type, c as CreateWorkflowRequestSchema, ct as UpdateAuthSCIMResourceRequestSchema, d as WorkflowExecution_Status, dt as UpdateUserProfileConfigRequestSchema, et as CreateTenantConfigRequestSchema, f as WorkflowJobExecution_Status, ft as AuthConnection_Status, g as TailorDBGQLPermission_Action, gt as AuthInvokerSchema, h as UpdateTailorDBTypeRequestSchema, ht as AuthIDPConfig_AuthType, it as UpdateAuthIDPConfigRequestSchema, j as UpdatePipelineResolverRequestSchema, jt as ConditionSchema, k as CreatePipelineResolverRequestSchema, kt as ApplicationSchemaUpdateAttemptStatus, l as UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, lt as UpdateAuthServiceRequestSchema, m as CreateTailorDBTypeRequestSchema, mt as AuthHookPoint, nt as UpdateAuthConnectionRequestSchema, o as CreateWorkflowJobFunctionExecutionPolicyRequestSchema, ot as UpdateAuthOAuth2ClientRequestSchema, p as CreateTailorDBServiceRequestSchema, pt as AuthConnection_Type, q as CreateAuthHookRequestSchema, rt as UpdateAuthHookRequestSchema, s as CreateWorkflowJobFunctionRequestSchema, st as UpdateAuthSCIMConfigRequestSchema, t as OperatorService, tt as CreateUserProfileConfigRequestSchema, u as UpdateWorkflowRequestSchema, ut as UpdateTenantConfigRequestSchema, v as TailorDBGQLPermission_Permit, vt as AuthOAuth2Client_GrantType, w as UpdateStaticWebsiteRequestSchema, wt as TenantProviderConfig_TenantProviderType, x as TailorDBType_PermitAction, xt as AuthSCIMAttribute_Uniqueness, y as TailorDBType_Permission_Operator, yt as AuthSCIMAttribute_Mutability, z as FunctionExecution_Status } from "./service_pb-4unFyubn.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 getOAuth2ClientId, B as readPlatformConfig, C as createBundleCache, D as loadConfig, E as hashFile, F as loadMachineUserName, I as loadPlatformClientConfig, J as fetchMachineUserToken, K as fetchAll, M as loadAccessToken, N as loadConfigPath, Q as getConsoleBaseUrl, R as loadWorkspaceId, S as hasGenerationHooks, T as hashContent, U as writePlatformConfig, Y as fetchPaged, _ as platformBundleDefinePlugin, at as resolveStaticWebsiteUrls, d as buildExecutorArgsExpr, et as getOrNull, f as buildResolverOperationHookExpr, g as stringifyFunction, h as TailorDBTypeSchema, i as resolverBundleKey, it as isDefaultPlatform, j as hasUserTokenEntry, l as HTTP_METHODS, m as assertUniqueTailorDBTypeNamesWithExternal, n as generatePluginFilesIfNeeded, o as WorkflowJobFunctionExecutionPolicySchema, ot as byName, p as assertUniqueLocalTailorDBTypeNames, q as fetchAllTolerant, r as loadApplication, rt as initOperatorClient, t as defineApplication, tt as getPlatformBaseUrl, w as getDistDir, x as getPluginGenerationDependencies, z as platformConfigFromProfile } from "./application-DYshsH-K.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) {
@@ -10978,6 +10813,198 @@ function normalizeRetryPolicyForCompare(policy) {
10978
10813
  };
10979
10814
  }
10980
10815
 
10816
+ //#endregion
10817
+ //#region src/cli/commands/deploy/workflow-execution-policy.ts
10818
+ function toConcurrencyPolicyInit(policy) {
10819
+ if (!policy) return void 0;
10820
+ return { maxConcurrentExecutions: policy.maxConcurrentExecutions };
10821
+ }
10822
+ function normalizeComparableConcurrency(policy) {
10823
+ if (!policy || !policy.maxConcurrentExecutions) return void 0;
10824
+ return { maxConcurrentExecutions: policy.maxConcurrentExecutions };
10825
+ }
10826
+ /**
10827
+ * The declared key prefix, regardless of variant. `ExecutionPolicyWildcardInstance`
10828
+ * omits `key` from its public type to force callers through `keyFor()`, but
10829
+ * the underlying value always carries it when produced by
10830
+ * `defineWorkflowExecutionPolicy()` or `defineWorkflowExecutionPolicies()`.
10831
+ * @param policy - Declared policy from the config
10832
+ * @returns The declared key prefix
10833
+ */
10834
+ function declaredKey(policy) {
10835
+ if (policy.matchType === "exact") return policy.key;
10836
+ const key = policy.key;
10837
+ if (typeof key !== "string") throw new Error(`Invalid workflow execution policy "${policy.name}": prefix policies must be created via defineWorkflowExecutionPolicy() or defineWorkflowExecutionPolicies(), not a hand-constructed object.`);
10838
+ return key;
10839
+ }
10840
+ /**
10841
+ * The literal key the platform registers for a declared policy: `key` with a
10842
+ * trailing `*` appended when `matchType` is `"prefix"`.
10843
+ * @param policy - Declared policy from the config
10844
+ * @returns The platform-facing execution policy key
10845
+ */
10846
+ function toPlatformExecutionPolicyKey(policy) {
10847
+ const key = declaredKey(policy);
10848
+ return policy.matchType === "prefix" ? `${key}*` : key;
10849
+ }
10850
+ /**
10851
+ * Validate a declared execution policy against the parser schema. Throws with
10852
+ * a descriptive error when `name` or the platform-facing key violates the
10853
+ * platform grammar.
10854
+ * @param policy - Declared policy from the config
10855
+ */
10856
+ function validatePolicy(policy) {
10857
+ if (declaredKey(policy).endsWith("*")) throw new Error(`Invalid workflow execution policy "${policy.name}": key must not end with '*'; omit the '*' and set matchType: "prefix" for wildcard policies (the SDK appends '*' automatically).`);
10858
+ const parsed = WorkflowJobFunctionExecutionPolicySchema.safeParse({
10859
+ name: policy.name,
10860
+ key: toPlatformExecutionPolicyKey(policy),
10861
+ concurrencyPolicy: policy.concurrencyPolicy
10862
+ });
10863
+ if (!parsed.success) throw new Error(`Invalid workflow execution policy "${policy.name}": ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
10864
+ }
10865
+ /**
10866
+ * Plan workflow job function execution policy changes based on desired
10867
+ * declarations and current remote state.
10868
+ * @param client - Operator client instance
10869
+ * @param workspaceId - Workspace ID
10870
+ * @param appName - Application name
10871
+ * @param appId - Application ID for ownership metadata
10872
+ * @param declared - Policies declared in the config (property name → instance)
10873
+ * @returns Planned execution policy changes
10874
+ */
10875
+ async function planWorkflowJobFunctionExecutionPolicy(client, workspaceId, appName, appId, declared) {
10876
+ const changeSet = createChangeSet("Workflow execution policies");
10877
+ const conflicts = [];
10878
+ const unmanaged = [];
10879
+ const resourceOwners = /* @__PURE__ */ new Set();
10880
+ const declaredList = Object.values(declared);
10881
+ for (const policy of declaredList) validatePolicy(policy);
10882
+ const existing = await fetchExistingResourcesWithLabels({
10883
+ client,
10884
+ fetchPage: async (pageToken, pageSize) => {
10885
+ const response = await client.listWorkflowJobFunctionExecutionPolicies({
10886
+ workspaceId,
10887
+ pageToken,
10888
+ pageSize
10889
+ });
10890
+ return [response.policies, response.nextPageToken];
10891
+ },
10892
+ getName: (resource) => resource.name,
10893
+ getTrn: (name) => resourceTrn(workspaceId, "workflow_job_function_execution_policy", name)
10894
+ });
10895
+ const seenNames = /* @__PURE__ */ new Set();
10896
+ for (const policy of declaredList) {
10897
+ if (seenNames.has(policy.name)) throw new Error(`Duplicate workflow execution policy name "${policy.name}". Each policy must have a unique name within the workspace.`);
10898
+ seenNames.add(policy.name);
10899
+ const metaRequest = await buildMetaRequest({
10900
+ trn: resourceTrn(workspaceId, "workflow_job_function_execution_policy", policy.name),
10901
+ appName,
10902
+ appId
10903
+ });
10904
+ const found = existing[policy.name];
10905
+ if (found) {
10906
+ const owned = trackDesiredResourceOwnership({
10907
+ labels: found.allLabels,
10908
+ ownerLabel: found.label,
10909
+ appName,
10910
+ appId,
10911
+ resourceType: "Workflow execution policy",
10912
+ resourceName: policy.name,
10913
+ conflicts,
10914
+ unmanaged
10915
+ });
10916
+ const remoteKey = found.resource.executionPolicyKey;
10917
+ const desiredKey = toPlatformExecutionPolicyKey(policy);
10918
+ const remoteConcurrency = normalizeComparableConcurrency(found.resource.concurrencyPolicy);
10919
+ const desiredConcurrency = normalizeComparableConcurrency(policy.concurrencyPolicy);
10920
+ if (owned && hasMatchingSdkVersion(found.allLabels, metaRequest.labels) && remoteKey === desiredKey && areNormalizedEqual(remoteConcurrency, desiredConcurrency)) changeSet.unchanged.push({ name: policy.name });
10921
+ else if (remoteKey !== desiredKey) changeSet.replaces.push({
10922
+ name: policy.name,
10923
+ workspaceId,
10924
+ policy,
10925
+ metaRequest
10926
+ });
10927
+ else changeSet.updates.push({
10928
+ name: policy.name,
10929
+ workspaceId,
10930
+ policy,
10931
+ metaRequest
10932
+ });
10933
+ delete existing[policy.name];
10934
+ } else changeSet.creates.push({
10935
+ name: policy.name,
10936
+ workspaceId,
10937
+ policy,
10938
+ metaRequest
10939
+ });
10940
+ }
10941
+ for (const [name, remaining] of Object.entries(existing)) {
10942
+ if (!remaining) continue;
10943
+ if (trackRemainingResourceOwner({
10944
+ labels: remaining.allLabels,
10945
+ ownerLabel: remaining.label,
10946
+ appName,
10947
+ appId,
10948
+ resourceOwners
10949
+ })) changeSet.deletes.push({
10950
+ name,
10951
+ workspaceId
10952
+ });
10953
+ }
10954
+ return {
10955
+ changeSet,
10956
+ conflicts,
10957
+ unmanaged,
10958
+ resourceOwners
10959
+ };
10960
+ }
10961
+ /**
10962
+ * Apply planned workflow execution policy changes for the given phase.
10963
+ * @param client - Operator client instance
10964
+ * @param plan - Result of `planWorkflowJobFunctionExecutionPolicy`
10965
+ * @param phase - Apply phase
10966
+ * @returns Promise that resolves when policies are applied
10967
+ */
10968
+ async function applyWorkflowJobFunctionExecutionPolicy(client, plan, phase = "create-update") {
10969
+ const { changeSet } = plan;
10970
+ if (phase === "create-update") await Promise.all([
10971
+ ...changeSet.replaces.map(async (replace) => {
10972
+ await client.deleteWorkflowJobFunctionExecutionPolicy({
10973
+ workspaceId: replace.workspaceId,
10974
+ executionPolicyName: replace.name
10975
+ });
10976
+ await client.createWorkflowJobFunctionExecutionPolicy({
10977
+ workspaceId: replace.workspaceId,
10978
+ executionPolicyName: replace.policy.name,
10979
+ executionPolicyKey: toPlatformExecutionPolicyKey(replace.policy),
10980
+ concurrencyPolicy: toConcurrencyPolicyInit(replace.policy.concurrencyPolicy)
10981
+ });
10982
+ await client.setMetadata(replace.metaRequest);
10983
+ }),
10984
+ ...changeSet.creates.map(async (create) => {
10985
+ await client.createWorkflowJobFunctionExecutionPolicy({
10986
+ workspaceId: create.workspaceId,
10987
+ executionPolicyName: create.policy.name,
10988
+ executionPolicyKey: toPlatformExecutionPolicyKey(create.policy),
10989
+ concurrencyPolicy: toConcurrencyPolicyInit(create.policy.concurrencyPolicy)
10990
+ });
10991
+ await client.setMetadata(create.metaRequest);
10992
+ }),
10993
+ ...changeSet.updates.map(async (update) => {
10994
+ await client.updateWorkflowJobFunctionExecutionPolicy({
10995
+ workspaceId: update.workspaceId,
10996
+ executionPolicyName: update.policy.name,
10997
+ concurrencyPolicy: toConcurrencyPolicyInit(update.policy.concurrencyPolicy)
10998
+ });
10999
+ await client.setMetadata(update.metaRequest);
11000
+ })
11001
+ ]);
11002
+ else await Promise.all(changeSet.deletes.map((del) => client.deleteWorkflowJobFunctionExecutionPolicy({
11003
+ workspaceId: del.workspaceId,
11004
+ executionPolicyName: del.name
11005
+ })));
11006
+ }
11007
+
10981
11008
  //#endregion
10982
11009
  //#region src/cli/commands/deploy/apply-phases.ts
10983
11010
  /**
@@ -11011,10 +11038,12 @@ async function applyDeploymentPlans(client, workspaceId, deployments) {
11011
11038
  });
11012
11039
  await withSpan("apply.createUpdateDependentServices", async () => {
11013
11040
  await forEachDeployment((d) => applyExecutor(client, d.executor, "create-update"));
11041
+ await forEachDeployment((d) => applyWorkflowJobFunctionExecutionPolicy(client, d.workflowExecutionPolicy, "create-update"));
11014
11042
  await forEachDeployment((d) => applyWorkflow(client, d.workflow, "create-update"));
11015
11043
  });
11016
11044
  await withSpan("apply.deleteDependentServices", async () => {
11017
11045
  await forEachDeployment((d) => applyWorkflow(client, d.workflow, "delete"));
11046
+ await forEachDeployment((d) => applyWorkflowJobFunctionExecutionPolicy(client, d.workflowExecutionPolicy, "delete"));
11018
11047
  await forEachDeployment((d) => applyExecutor(client, d.executor, "delete"));
11019
11048
  await forEachDeployment((d) => applyStaticWebsite(client, d.staticWebsite, "delete"));
11020
11049
  await forEachDeployment((d) => applyAIGateway(client, d.aiGateway, "delete"));
@@ -11339,7 +11368,7 @@ function validateItems(params) {
11339
11368
  * @param input - Plan results from the plan phase
11340
11369
  */
11341
11370
  async function validatePlan(input) {
11342
- const { tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow, secretManager } = input;
11371
+ const { tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow, workflowExecutionPolicy, secretManager } = input;
11343
11372
  const validator = createValidator();
11344
11373
  const violations = [];
11345
11374
  function creates(schema, kind, items) {
@@ -11482,6 +11511,23 @@ async function validatePlan(input) {
11482
11511
  }
11483
11512
  })));
11484
11513
  }
11514
+ creates(CreateWorkflowJobFunctionExecutionPolicyRequestSchema, "Workflow execution policy", [...workflowExecutionPolicy.changeSet.creates, ...workflowExecutionPolicy.changeSet.replaces].map((item) => ({
11515
+ name: item.name,
11516
+ request: {
11517
+ workspaceId: item.workspaceId,
11518
+ executionPolicyName: item.policy.name,
11519
+ executionPolicyKey: toPlatformExecutionPolicyKey(item.policy),
11520
+ ...item.policy.concurrencyPolicy && { concurrencyPolicy: { maxConcurrentExecutions: item.policy.concurrencyPolicy.maxConcurrentExecutions } }
11521
+ }
11522
+ })));
11523
+ updates(UpdateWorkflowJobFunctionExecutionPolicyRequestSchema, "Workflow execution policy", workflowExecutionPolicy.changeSet.updates.map((item) => ({
11524
+ name: item.name,
11525
+ request: {
11526
+ workspaceId: item.workspaceId,
11527
+ executionPolicyName: item.policy.name,
11528
+ ...item.policy.concurrencyPolicy && { concurrencyPolicy: { maxConcurrentExecutions: item.policy.concurrencyPolicy.maxConcurrentExecutions } }
11529
+ }
11530
+ })));
11485
11531
  creates(CreateSecretManagerVaultRequestSchema, "Secret Manager vault", secretManager.vaultChangeSet.creates.map((item) => ({
11486
11532
  name: item.name,
11487
11533
  request: vaultCreateRequest(item)
@@ -11686,13 +11732,13 @@ async function shouldForceApplyAll(client, workspaceId, application, functionEnt
11686
11732
  functionEntries.forEach((entry) => {
11687
11733
  candidateTrns.add(resourceTrn(workspaceId, "function_registry", entry.name));
11688
11734
  });
11689
- for (const trn of candidateTrns) try {
11690
- const { metadata } = await client.getMetadata({ trn });
11735
+ for (const trn of candidateTrns) {
11736
+ const metadata = await getOrNull(async () => {
11737
+ const { metadata } = await client.getMetadata({ trn });
11738
+ return metadata;
11739
+ });
11691
11740
  if (metadata?.labels["sdk-name"] !== application.name) continue;
11692
11741
  if (!hasMatchingSdkVersion(metadata.labels, desiredLabels)) return true;
11693
- } catch (error) {
11694
- if (error instanceof ConnectError && error.code === Code.NotFound) continue;
11695
- throw error;
11696
11742
  }
11697
11743
  return false;
11698
11744
  }
@@ -11714,6 +11760,7 @@ function buildPlanReport(results) {
11714
11760
  const executorEntries = formatExecutorChangeEntries(results.executor.changeSet, buildPlannedExecutorsByName(results.executor.changeSet), results.functionRegistry.executorFunctionChanges);
11715
11761
  const resolverEntries = formatResolverChangeEntries(results.pipeline.changeSet.resolver, results.functionRegistry.resolverFunctionChanges);
11716
11762
  const workflowEntries = formatWorkflowChangeEntries(results.workflow.changeSet, results.functionRegistry.workflowJobChanges);
11763
+ const workflowExecutionPolicyEntries = formatChangeSetEntries(results.workflowExecutionPolicy.changeSet, ["executionPolicy"]);
11717
11764
  const authHookEntries = formatAuthHookChangeEntries(results.auth.changeSet.authHook, results.functionRegistry.authHookFunctionChanges);
11718
11765
  const tailorDBEntries = [...formatTailorDBResourceChangeEntries(results.tailorDB.changeSet.type, results.tailorDB.changeSet.gqlPermission)];
11719
11766
  const pipelineEntries = [...resolverEntries];
@@ -11744,6 +11791,7 @@ function buildPlanReport(results) {
11744
11791
  ...pipelineEntries,
11745
11792
  ...executorEntries,
11746
11793
  ...workflowEntries,
11794
+ ...workflowExecutionPolicyEntries,
11747
11795
  ...idpEntries,
11748
11796
  ...authEntries
11749
11797
  ];
@@ -12116,7 +12164,7 @@ async function planDeploymentTarget(params) {
12116
12164
  };
12117
12165
  const functionRegistry = await withSpan("plan.functionRegistry", () => planFunctionRegistry(client, workspaceId, application.name, application.id, functionEntries));
12118
12166
  const unchangedWorkflowJobs = new Set(functionRegistry.changeSet.unchanged.filter((entry) => entry.name.startsWith(WORKFLOW_PREFIX)).map((entry) => entry.name.slice(WORKFLOW_PREFIX.length)));
12119
- const [tailorDB, staticWebsite, aiGateway, idp, auth, pipeline, app, executor, workflow, secretManager] = await Promise.all([
12167
+ const [tailorDB, staticWebsite, aiGateway, idp, auth, pipeline, app, executor, workflow, workflowExecutionPolicy, secretManager] = await Promise.all([
12120
12168
  withSpan("plan.tailorDB", () => planTailorDB(ctx)),
12121
12169
  withSpan("plan.staticWebsite", () => planStaticWebsite(ctx)),
12122
12170
  withSpan("plan.aiGateway", () => planAIGateway(ctx)),
@@ -12126,6 +12174,7 @@ async function planDeploymentTarget(params) {
12126
12174
  withSpan("plan.application", () => planApplication(ctx, httpAdapterBuildResult)),
12127
12175
  withSpan("plan.executor", () => planExecutor(ctx)),
12128
12176
  withSpan("plan.workflow", () => planWorkflow(client, workspaceId, application.name, application.id, workflowService?.workflows ?? {}, workflowBuildResult?.mainJobDeps ?? {}, unchangedWorkflowJobs)),
12177
+ withSpan("plan.workflowExecutionPolicy", () => planWorkflowJobFunctionExecutionPolicy(client, workspaceId, application.name, application.id, config.workflow?.executionPolicies ?? {})),
12129
12178
  withSpan("plan.secretManager", () => planSecretManager(ctx))
12130
12179
  ]);
12131
12180
  return {
@@ -12140,6 +12189,7 @@ async function planDeploymentTarget(params) {
12140
12189
  app,
12141
12190
  executor,
12142
12191
  workflow,
12192
+ workflowExecutionPolicy,
12143
12193
  secretManager
12144
12194
  };
12145
12195
  });
@@ -12167,6 +12217,7 @@ function collectOwnerConflicts(results) {
12167
12217
  ...results.pipeline.conflicts,
12168
12218
  ...results.executor.conflicts,
12169
12219
  ...results.workflow.conflicts,
12220
+ ...results.workflowExecutionPolicy.conflicts,
12170
12221
  ...results.secretManager.conflicts
12171
12222
  ];
12172
12223
  }
@@ -12181,6 +12232,7 @@ function collectUnmanagedResources(results) {
12181
12232
  ...results.pipeline.unmanaged,
12182
12233
  ...results.executor.unmanaged,
12183
12234
  ...results.workflow.unmanaged,
12235
+ ...results.workflowExecutionPolicy.unmanaged,
12184
12236
  ...results.secretManager.unmanaged
12185
12237
  ];
12186
12238
  }
@@ -12195,6 +12247,7 @@ function collectResourceOwners(results) {
12195
12247
  ...results.pipeline.resourceOwners,
12196
12248
  ...results.executor.resourceOwners,
12197
12249
  ...results.workflow.resourceOwners,
12250
+ ...results.workflowExecutionPolicy.resourceOwners,
12198
12251
  ...results.secretManager.resourceOwners
12199
12252
  ]);
12200
12253
  }
@@ -12340,6 +12393,12 @@ const DEPLOY_MANAGED_RESOURCE_DEFINITIONS = [
12340
12393
  namesOf: (target) => Object.values(target.application.workflowService?.workflows ?? {}).map((workflow) => workflow.name),
12341
12394
  changeSetOf: (results) => results.workflow.changeSet
12342
12395
  },
12396
+ {
12397
+ resourceLabel: "Workflow execution policy",
12398
+ resourceType: "workflow_job_function_execution_policy",
12399
+ namesOf: (target) => Object.values(target.config.workflow?.executionPolicies ?? {}).map((policy) => policy.name),
12400
+ changeSetOf: (results) => results.workflowExecutionPolicy.changeSet
12401
+ },
12343
12402
  {
12344
12403
  resourceLabel: "Auth connection",
12345
12404
  resourceType: "auth.connection",
@@ -17462,7 +17521,7 @@ async function generate(options) {
17462
17521
  if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
17463
17522
  let pluginManager;
17464
17523
  if (plugins.length > 0) pluginManager = new PluginManager(plugins);
17465
- const { defineApplication } = await import("./application-BndtMTFY.mjs");
17524
+ const { defineApplication } = await import("./application-BJKNlv8c.mjs");
17466
17525
  const application = defineApplication({
17467
17526
  config,
17468
17527
  pluginManager
@@ -19727,4 +19786,4 @@ function isDeno() {
19727
19786
 
19728
19787
  //#endregion
19729
19788
  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
19789
+ //# sourceMappingURL=runtime-CJ5usBOu.mjs.map