@tailor-platform/sdk 1.17.1 → 1.19.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.
- package/CHANGELOG.md +37 -0
- package/dist/{application-BMDE8KqK.mjs → application-A6PZjujv.mjs} +192 -1673
- package/dist/application-A6PZjujv.mjs.map +1 -0
- package/dist/application-nPS5veK6.mjs +9 -0
- package/dist/brand-BZJCv6UY.mjs +28 -0
- package/dist/brand-BZJCv6UY.mjs.map +1 -0
- package/dist/cli/index.mjs +40 -20
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +16 -33
- package/dist/cli/lib.mjs +12 -5
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/configure/index.mjs +10 -19
- package/dist/configure/index.mjs.map +1 -1
- package/dist/enum-constants-CGVvu3dd.mjs +115 -0
- package/dist/enum-constants-CGVvu3dd.mjs.map +1 -0
- package/dist/file-utils-GX_tGWl4.mjs +139 -0
- package/dist/file-utils-GX_tGWl4.mjs.map +1 -0
- package/dist/index-B6pvy1MK.d.mts +20 -0
- package/dist/index-B91ZpOcd.d.mts +18 -0
- package/dist/index-CPzbMghQ.d.mts +18 -0
- package/dist/{index-CVcYqZSf.d.mts → index-ClLZCbcm.d.mts} +18 -5
- package/dist/index-DDqKNFh4.d.mts +18 -0
- package/dist/interceptor-D8MeZOxX.mjs +33 -0
- package/dist/interceptor-D8MeZOxX.mjs.map +1 -0
- package/dist/{jiti-BrELlEYT.mjs → jiti-DfS9jItj.mjs} +2 -2
- package/dist/{jiti-BrELlEYT.mjs.map → jiti-DfS9jItj.mjs.map} +1 -1
- package/dist/{job-CULA2Pvf.mjs → job-2Q82qQ6N.mjs} +27 -5
- package/dist/job-2Q82qQ6N.mjs.map +1 -0
- package/dist/kysely-type-Cpq5TNGY.mjs +260 -0
- package/dist/kysely-type-Cpq5TNGY.mjs.map +1 -0
- package/dist/package-json-DUY2kB6z.mjs +17 -0
- package/dist/package-json-DUY2kB6z.mjs.map +1 -0
- package/dist/package-json-Dd1AnA5F.mjs +3 -0
- package/dist/plugin/builtin/enum-constants/index.d.mts +4 -0
- package/dist/plugin/builtin/enum-constants/index.mjs +3 -0
- package/dist/plugin/builtin/file-utils/index.d.mts +4 -0
- package/dist/plugin/builtin/file-utils/index.mjs +3 -0
- package/dist/plugin/builtin/kysely-type/index.d.mts +4 -0
- package/dist/plugin/builtin/kysely-type/index.mjs +3 -0
- package/dist/plugin/builtin/seed/index.d.mts +4 -0
- package/dist/plugin/builtin/seed/index.mjs +3 -0
- package/dist/plugin/index.d.mts +3 -3
- package/dist/plugin/index.mjs +11 -11
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/{schema-R5TxC5Pn.mjs → schema-D5Cpd8fQ.mjs} +48 -5
- package/dist/schema-D5Cpd8fQ.mjs.map +1 -0
- package/dist/seed-CeUEANfQ.mjs +1050 -0
- package/dist/seed-CeUEANfQ.mjs.map +1 -0
- package/dist/{src-DMROgdcL.mjs → src-Bb1UVstT.mjs} +2 -2
- package/dist/{src-DMROgdcL.mjs.map → src-Bb1UVstT.mjs.map} +1 -1
- package/dist/telemetry-9A1BZqbl.mjs +3 -0
- package/dist/telemetry-rFq0QdvJ.mjs +84 -0
- package/dist/telemetry-rFq0QdvJ.mjs.map +1 -0
- package/dist/types-CJF3Y1x8.d.mts +158 -0
- package/dist/{types-CZZBCaxB.d.mts → types-CblXasFV.d.mts} +1405 -1045
- package/dist/{types-b-ig8nW_.mjs → types-ClK_HJ0G.mjs} +1 -1
- package/dist/{types-b-ig8nW_.mjs.map → types-ClK_HJ0G.mjs.map} +1 -1
- package/dist/{update-CUBVjZbL.mjs → update-Cr5c7h1r.mjs} +485 -244
- package/dist/update-Cr5c7h1r.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +4 -4
- package/dist/utils/test/index.mjs +3 -2
- package/dist/utils/test/index.mjs.map +1 -1
- package/docs/cli/application.md +106 -14
- package/docs/cli/auth.md +92 -12
- package/docs/cli/completion.md +18 -2
- package/docs/cli/executor.md +122 -14
- package/docs/cli/function.md +32 -4
- package/docs/cli/secret.md +134 -18
- package/docs/cli/staticwebsite.md +60 -8
- package/docs/cli/tailordb.md +148 -20
- package/docs/cli/user.md +154 -22
- package/docs/cli/workflow.md +100 -12
- package/docs/cli/workspace.md +274 -38
- package/docs/generator/custom.md +2 -2
- package/docs/plugin/custom.md +270 -163
- package/docs/plugin/index.md +48 -2
- package/package.json +28 -2
- package/dist/application-BMDE8KqK.mjs.map +0 -1
- package/dist/application-Dni_W16P.mjs +0 -4
- package/dist/job-CULA2Pvf.mjs.map +0 -1
- package/dist/schema-R5TxC5Pn.mjs.map +0 -1
- package/dist/types-DthzUFfx.d.mts +0 -372
- package/dist/update-CUBVjZbL.mjs.map +0 -1
- /package/dist/{chunk-GMkBE123.mjs → chunk-CqAI0b6X.mjs} +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { t as db } from "./schema-
|
|
2
|
-
import { $ as
|
|
1
|
+
import { t as db } from "./schema-D5Cpd8fQ.mjs";
|
|
2
|
+
import { $ as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, A as TailorDBGQLPermission_Operator, B as ExecutorTargetType, C as platformBaseUrl, D as WorkflowExecution_Status, E as WorkspacePlatformUserRole, F as PipelineResolver_OperationType, G as AuthOAuth2Client_GrantType, H as AuthIDPConfig_AuthType, I as IdPLang, J as AuthSCIMAttribute_Uniqueness, K as AuthSCIMAttribute_Mutability, L as FunctionExecution_Status, M as TailorDBType_Permission_Operator, N as TailorDBType_Permission_Permit, O as WorkflowJobExecution_Status, P as TailorDBType_PermitAction, Q as UserProfileProviderConfig_UserProfileProviderType, S as initOperatorClient, T as userAgent, U as AuthInvokerSchema, V as ExecutorTriggerType, W as AuthOAuth2Client_ClientType, Y as AuthSCIMConfig_AuthorizationType, Z as TenantProviderConfig_TenantProviderType, _ as writePlatformConfig, a as buildExecutorArgsExpr, at as Subgraph_ServiceType, c as createExecutorService, ct as symbols, et as ConditionSchema, f as loadAccessToken, g as readPlatformConfig, h as loadWorkspaceId, i as loadConfig, it as ApplicationSchemaUpdateAttemptStatus, j as TailorDBGQLPermission_Permit, k as TailorDBGQLPermission_Action, l as OAuth2ClientSchema, m as loadOrganizationId, n as generatePluginFilesIfNeeded, nt as FilterSchema, o as buildResolverOperationHookExpr, ot as logger, p as loadFolderId, q as AuthSCIMAttribute_Type, r as loadApplication, rt as PageDirection, s as getDistDir, st as styles, t as defineApplication, tt as Condition_Operator, u as stringifyFunction, v as fetchAll, w as resolveStaticWebsiteUrls, y as fetchMachineUserToken, z as ExecutorJobStatus } from "./application-A6PZjujv.mjs";
|
|
3
|
+
import { t as readPackageJson } from "./package-json-DUY2kB6z.mjs";
|
|
4
|
+
import { r as withSpan } from "./telemetry-rFq0QdvJ.mjs";
|
|
3
5
|
import { createRequire } from "node:module";
|
|
4
6
|
import { arg, defineCommand, runCommand } from "politty";
|
|
5
7
|
import { z } from "zod";
|
|
@@ -159,6 +161,8 @@ const withCommonArgs = (handler) => async (args) => {
|
|
|
159
161
|
try {
|
|
160
162
|
if ("json" in args && typeof args.json === "boolean") logger.jsonMode = args.json;
|
|
161
163
|
loadEnvFiles(args["env-file"], args["env-file-if-exists"]);
|
|
164
|
+
const { initTelemetry } = await import("./telemetry-9A1BZqbl.mjs");
|
|
165
|
+
await initTelemetry();
|
|
162
166
|
await handler(args);
|
|
163
167
|
} catch (error) {
|
|
164
168
|
if (isCLIError(error)) {
|
|
@@ -169,6 +173,9 @@ const withCommonArgs = (handler) => async (args) => {
|
|
|
169
173
|
if (args.verbose && error.stack) logger.debug(`\nStack trace:\n${error.stack}`);
|
|
170
174
|
} else logger.error(`Unknown error: ${error}`);
|
|
171
175
|
process.exit(1);
|
|
176
|
+
} finally {
|
|
177
|
+
const { shutdownTelemetry } = await import("./telemetry-9A1BZqbl.mjs");
|
|
178
|
+
await shutdownTelemetry();
|
|
172
179
|
}
|
|
173
180
|
process.exit(0);
|
|
174
181
|
};
|
|
@@ -373,6 +380,35 @@ function resolvePackageDirectory(startDir) {
|
|
|
373
380
|
}
|
|
374
381
|
}
|
|
375
382
|
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/parser/plugin-config/generation-types.ts
|
|
385
|
+
/**
|
|
386
|
+
* Derives generation-time dependency set from hook presence on a plugin.
|
|
387
|
+
* @param plugin - Plugin to check for generation hooks
|
|
388
|
+
* @param plugin.onTailorDBReady - TailorDB phase-complete hook
|
|
389
|
+
* @param plugin.onResolverReady - Resolver phase-complete hook
|
|
390
|
+
* @param plugin.onExecutorReady - Executor phase-complete hook
|
|
391
|
+
* @returns Set of dependency kinds based on which hooks are implemented
|
|
392
|
+
*/
|
|
393
|
+
function getPluginGenerationDependencies(plugin) {
|
|
394
|
+
const deps = /* @__PURE__ */ new Set();
|
|
395
|
+
if (plugin.onTailorDBReady) deps.add("tailordb");
|
|
396
|
+
if (plugin.onResolverReady) deps.add("resolver");
|
|
397
|
+
if (plugin.onExecutorReady) deps.add("executor");
|
|
398
|
+
return deps;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Checks if a plugin has any generation-time hooks.
|
|
402
|
+
* @param plugin - Plugin to check
|
|
403
|
+
* @param plugin.onTailorDBReady - TailorDB phase-complete hook
|
|
404
|
+
* @param plugin.onResolverReady - Resolver phase-complete hook
|
|
405
|
+
* @param plugin.onExecutorReady - Executor phase-complete hook
|
|
406
|
+
* @returns True if the plugin has at least one generation hook
|
|
407
|
+
*/
|
|
408
|
+
function hasGenerationHooks(plugin) {
|
|
409
|
+
return !!(plugin.onTailorDBReady || plugin.onResolverReady || plugin.onExecutorReady);
|
|
410
|
+
}
|
|
411
|
+
|
|
376
412
|
//#endregion
|
|
377
413
|
//#region src/plugin/manager.ts
|
|
378
414
|
/**
|
|
@@ -409,13 +445,13 @@ var PluginManager = class {
|
|
|
409
445
|
success: false,
|
|
410
446
|
error: `Plugin "${plugin.id}" requires typeConfig, but none was provided for type "${context.type.name}".`
|
|
411
447
|
};
|
|
412
|
-
if (!plugin.
|
|
448
|
+
if (!plugin.onTypeLoaded) return {
|
|
413
449
|
success: false,
|
|
414
|
-
error: `Plugin "${plugin.id}" does not support type-attached processing (missing
|
|
450
|
+
error: `Plugin "${plugin.id}" does not support type-attached processing (missing onTypeLoaded method). Use onNamespaceLoaded via definePlugins() instead.`
|
|
415
451
|
};
|
|
416
452
|
let output;
|
|
417
453
|
try {
|
|
418
|
-
output = await plugin.
|
|
454
|
+
output = await plugin.onTypeLoaded({
|
|
419
455
|
type: context.type,
|
|
420
456
|
typeConfig: context.typeConfig,
|
|
421
457
|
pluginConfig: plugin.pluginConfig,
|
|
@@ -453,14 +489,14 @@ var PluginManager = class {
|
|
|
453
489
|
}
|
|
454
490
|
/**
|
|
455
491
|
* Process namespace plugins that don't require a source type.
|
|
456
|
-
* This method is called once per namespace for plugins with
|
|
492
|
+
* This method is called once per namespace for plugins with onNamespaceLoaded method.
|
|
457
493
|
* @param namespace - The target namespace for generated types
|
|
458
494
|
* @returns Array of results with plugin outputs and configs
|
|
459
495
|
*/
|
|
460
496
|
async processNamespacePlugins(namespace) {
|
|
461
497
|
const results = [];
|
|
462
498
|
for (const [pluginId, plugin] of this.plugins) {
|
|
463
|
-
if (!plugin.
|
|
499
|
+
if (!plugin.onNamespaceLoaded) continue;
|
|
464
500
|
const config = plugin.pluginConfig;
|
|
465
501
|
const context = {
|
|
466
502
|
pluginConfig: config,
|
|
@@ -468,7 +504,7 @@ var PluginManager = class {
|
|
|
468
504
|
};
|
|
469
505
|
let output;
|
|
470
506
|
try {
|
|
471
|
-
output = await plugin.
|
|
507
|
+
output = await plugin.onNamespaceLoaded(context);
|
|
472
508
|
} catch (error) {
|
|
473
509
|
const message = error instanceof Error ? error.message : String(error);
|
|
474
510
|
results.push({
|
|
@@ -520,11 +556,11 @@ var PluginManager = class {
|
|
|
520
556
|
return results;
|
|
521
557
|
}
|
|
522
558
|
/**
|
|
523
|
-
* Get plugins that have
|
|
559
|
+
* Get plugins that have onNamespaceLoaded method
|
|
524
560
|
* @returns Array of plugin IDs that support namespace processing
|
|
525
561
|
*/
|
|
526
562
|
getNamespacePluginIds() {
|
|
527
|
-
return Array.from(this.plugins.entries()).filter(([, plugin]) => plugin.
|
|
563
|
+
return Array.from(this.plugins.entries()).filter(([, plugin]) => plugin.onNamespaceLoaded !== void 0).map(([id]) => id);
|
|
528
564
|
}
|
|
529
565
|
/**
|
|
530
566
|
* Get the count of registered plugins
|
|
@@ -582,6 +618,23 @@ var PluginManager = class {
|
|
|
582
618
|
return this.generatedExecutors.filter((info) => info.namespace === namespace);
|
|
583
619
|
}
|
|
584
620
|
/**
|
|
621
|
+
* Get plugins that have any generation-time hooks.
|
|
622
|
+
* @returns Array of plugins with generation hooks
|
|
623
|
+
*/
|
|
624
|
+
getPluginsWithGenerationHooks() {
|
|
625
|
+
return Array.from(this.plugins.values()).filter((plugin) => hasGenerationHooks(plugin));
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Get the generation-time dependencies for a specific plugin.
|
|
629
|
+
* @param pluginId - The plugin ID to look up
|
|
630
|
+
* @returns Set of dependency kinds, or empty set if plugin not found
|
|
631
|
+
*/
|
|
632
|
+
getPluginGenerationDependencies(pluginId) {
|
|
633
|
+
const plugin = this.plugins.get(pluginId);
|
|
634
|
+
if (!plugin) return /* @__PURE__ */ new Set();
|
|
635
|
+
return getPluginGenerationDependencies(plugin);
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
585
638
|
* Generate plugin files (types and executors) and store the executor file paths.
|
|
586
639
|
* @param params - Parameters for file generation
|
|
587
640
|
* @returns Generated executor file paths
|
|
@@ -738,11 +791,12 @@ function trn$6(workspaceId, name) {
|
|
|
738
791
|
async function planApplication(context) {
|
|
739
792
|
const { client, workspaceId, application, forRemoval } = context;
|
|
740
793
|
const changeSet = createChangeSet("Applications");
|
|
741
|
-
const existingApplications = await fetchAll(async (pageToken) => {
|
|
794
|
+
const existingApplications = await fetchAll(async (pageToken, maxPageSize) => {
|
|
742
795
|
try {
|
|
743
796
|
const { applications, nextPageToken } = await client.listApplications({
|
|
744
797
|
workspaceId,
|
|
745
|
-
pageToken
|
|
798
|
+
pageToken,
|
|
799
|
+
pageSize: maxPageSize
|
|
746
800
|
});
|
|
747
801
|
return [applications, nextPageToken];
|
|
748
802
|
} catch (error) {
|
|
@@ -769,12 +823,13 @@ async function planApplication(context) {
|
|
|
769
823
|
if (idProvider) authIdpConfigName = idProvider.name;
|
|
770
824
|
} else if (application.config.auth) {
|
|
771
825
|
authNamespace = application.config.auth.name;
|
|
772
|
-
const idpConfigs = await fetchAll(async (pageToken) => {
|
|
826
|
+
const idpConfigs = await fetchAll(async (pageToken, maxPageSize) => {
|
|
773
827
|
try {
|
|
774
828
|
const { idpConfigs: idpConfigs$1, nextPageToken } = await client.listAuthIDPConfigs({
|
|
775
829
|
workspaceId,
|
|
776
830
|
namespaceName: authNamespace,
|
|
777
|
-
pageToken
|
|
831
|
+
pageToken,
|
|
832
|
+
pageSize: maxPageSize
|
|
778
833
|
});
|
|
779
834
|
return [idpConfigs$1, nextPageToken];
|
|
780
835
|
} catch (error) {
|
|
@@ -953,11 +1008,12 @@ async function planServices$3(client, workspaceId, appName, idps) {
|
|
|
953
1008
|
const conflicts = [];
|
|
954
1009
|
const unmanaged = [];
|
|
955
1010
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
956
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
1011
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
957
1012
|
try {
|
|
958
1013
|
const { idpServices, nextPageToken } = await client.listIdPServices({
|
|
959
1014
|
workspaceId,
|
|
960
|
-
pageToken
|
|
1015
|
+
pageToken,
|
|
1016
|
+
pageSize: maxPageSize
|
|
961
1017
|
});
|
|
962
1018
|
return [idpServices, nextPageToken];
|
|
963
1019
|
} catch (error) {
|
|
@@ -1049,12 +1105,13 @@ async function planServices$3(client, workspaceId, appName, idps) {
|
|
|
1049
1105
|
async function planClients(client, workspaceId, idps, deletedServices) {
|
|
1050
1106
|
const changeSet = createChangeSet("IdP clients");
|
|
1051
1107
|
const fetchClients = (namespaceName) => {
|
|
1052
|
-
return fetchAll(async (pageToken) => {
|
|
1108
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
1053
1109
|
try {
|
|
1054
1110
|
const { clients, nextPageToken } = await client.listIdPClients({
|
|
1055
1111
|
workspaceId,
|
|
1056
1112
|
namespaceName,
|
|
1057
|
-
pageToken
|
|
1113
|
+
pageToken,
|
|
1114
|
+
pageSize: maxPageSize
|
|
1058
1115
|
});
|
|
1059
1116
|
return [clients, nextPageToken];
|
|
1060
1117
|
} catch (error) {
|
|
@@ -1063,9 +1120,11 @@ async function planClients(client, workspaceId, idps, deletedServices) {
|
|
|
1063
1120
|
}
|
|
1064
1121
|
});
|
|
1065
1122
|
};
|
|
1066
|
-
|
|
1123
|
+
const clientsByIdp = await Promise.all(idps.map((idp) => fetchClients(idp.name)));
|
|
1124
|
+
for (let i = 0; i < idps.length; i++) {
|
|
1125
|
+
const idp = idps[i];
|
|
1067
1126
|
const namespaceName = idp.name;
|
|
1068
|
-
const existingClients =
|
|
1127
|
+
const existingClients = clientsByIdp[i];
|
|
1069
1128
|
const existingNameMap = /* @__PURE__ */ new Map();
|
|
1070
1129
|
existingClients.forEach((client$1) => {
|
|
1071
1130
|
existingNameMap.set(client$1.name, client$1.clientSecret);
|
|
@@ -1097,16 +1156,20 @@ async function planClients(client, workspaceId, idps, deletedServices) {
|
|
|
1097
1156
|
});
|
|
1098
1157
|
});
|
|
1099
1158
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1159
|
+
const deletedClientsByService = await Promise.all(deletedServices.map((namespaceName) => fetchClients(namespaceName)));
|
|
1160
|
+
for (let i = 0; i < deletedServices.length; i++) {
|
|
1161
|
+
const namespaceName = deletedServices[i];
|
|
1162
|
+
deletedClientsByService[i].forEach((client$1) => {
|
|
1163
|
+
changeSet.deletes.push({
|
|
1164
|
+
name: client$1.name,
|
|
1165
|
+
request: {
|
|
1166
|
+
workspaceId,
|
|
1167
|
+
namespaceName,
|
|
1168
|
+
name: client$1.name
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1108
1171
|
});
|
|
1109
|
-
}
|
|
1172
|
+
}
|
|
1110
1173
|
return changeSet;
|
|
1111
1174
|
}
|
|
1112
1175
|
function convertLang(lang) {
|
|
@@ -1184,13 +1247,15 @@ async function planAuth(context) {
|
|
|
1184
1247
|
}
|
|
1185
1248
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices$2(client, workspaceId, application.name, auths);
|
|
1186
1249
|
const deletedServices = serviceChangeSet.deletes.map((del) => del.name);
|
|
1187
|
-
const idpConfigChangeSet
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1250
|
+
const [idpConfigChangeSet, userProfileConfigChangeSet, tenantConfigChangeSet, machineUserChangeSet, oauth2ClientChangeSet, scimChangeSet, scimResourceChangeSet] = await Promise.all([
|
|
1251
|
+
planIdPConfigs(client, workspaceId, auths, deletedServices),
|
|
1252
|
+
planUserProfileConfigs(client, workspaceId, auths, deletedServices),
|
|
1253
|
+
planTenantConfigs(client, workspaceId, auths, deletedServices),
|
|
1254
|
+
planMachineUsers(client, workspaceId, auths, deletedServices),
|
|
1255
|
+
planOAuth2Clients(client, workspaceId, auths, deletedServices),
|
|
1256
|
+
planSCIMConfigs(client, workspaceId, auths, deletedServices),
|
|
1257
|
+
planSCIMResources(client, workspaceId, auths, deletedServices)
|
|
1258
|
+
]);
|
|
1194
1259
|
serviceChangeSet.print();
|
|
1195
1260
|
idpConfigChangeSet.print();
|
|
1196
1261
|
userProfileConfigChangeSet.print();
|
|
@@ -1223,11 +1288,12 @@ async function planServices$2(client, workspaceId, appName, auths) {
|
|
|
1223
1288
|
const conflicts = [];
|
|
1224
1289
|
const unmanaged = [];
|
|
1225
1290
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
1226
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
1291
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
1227
1292
|
try {
|
|
1228
1293
|
const { authServices, nextPageToken } = await client.listAuthServices({
|
|
1229
1294
|
workspaceId,
|
|
1230
|
-
pageToken
|
|
1295
|
+
pageToken,
|
|
1296
|
+
pageSize: maxPageSize
|
|
1231
1297
|
});
|
|
1232
1298
|
return [authServices, nextPageToken];
|
|
1233
1299
|
} catch (error) {
|
|
@@ -1299,12 +1365,13 @@ async function planServices$2(client, workspaceId, appName, auths) {
|
|
|
1299
1365
|
async function planIdPConfigs(client, workspaceId, auths, deletedServices) {
|
|
1300
1366
|
const changeSet = createChangeSet("Auth idpConfigs");
|
|
1301
1367
|
const fetchIdPConfigs = (namespaceName) => {
|
|
1302
|
-
return fetchAll(async (pageToken) => {
|
|
1368
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
1303
1369
|
try {
|
|
1304
1370
|
const { idpConfigs, nextPageToken } = await client.listAuthIDPConfigs({
|
|
1305
1371
|
workspaceId,
|
|
1306
1372
|
namespaceName,
|
|
1307
|
-
pageToken
|
|
1373
|
+
pageToken,
|
|
1374
|
+
pageSize: maxPageSize
|
|
1308
1375
|
});
|
|
1309
1376
|
return [idpConfigs, nextPageToken];
|
|
1310
1377
|
} catch (error) {
|
|
@@ -1602,12 +1669,13 @@ function protoTenantConfig(tenantConfig) {
|
|
|
1602
1669
|
async function planMachineUsers(client, workspaceId, auths, deletedServices) {
|
|
1603
1670
|
const changeSet = createChangeSet("Auth machineUsers");
|
|
1604
1671
|
const fetchMachineUsers = (authNamespace) => {
|
|
1605
|
-
return fetchAll(async (pageToken) => {
|
|
1672
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
1606
1673
|
try {
|
|
1607
1674
|
const { machineUsers, nextPageToken } = await client.listAuthMachineUsers({
|
|
1608
1675
|
workspaceId,
|
|
1609
1676
|
authNamespace,
|
|
1610
|
-
pageToken
|
|
1677
|
+
pageToken,
|
|
1678
|
+
pageSize: maxPageSize
|
|
1611
1679
|
});
|
|
1612
1680
|
return [machineUsers, nextPageToken];
|
|
1613
1681
|
} catch (error) {
|
|
@@ -1680,12 +1748,13 @@ function protoMachineUserAttributeMap(attributeMap) {
|
|
|
1680
1748
|
async function planOAuth2Clients(client, workspaceId, auths, deletedServices) {
|
|
1681
1749
|
const changeSet = createChangeSet("Auth oauth2Clients");
|
|
1682
1750
|
const fetchOAuth2Clients = (namespaceName) => {
|
|
1683
|
-
return fetchAll(async (pageToken) => {
|
|
1751
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
1684
1752
|
try {
|
|
1685
1753
|
const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
|
|
1686
1754
|
workspaceId,
|
|
1687
1755
|
namespaceName,
|
|
1688
|
-
pageToken
|
|
1756
|
+
pageToken,
|
|
1757
|
+
pageSize: maxPageSize
|
|
1689
1758
|
});
|
|
1690
1759
|
return [oauth2Clients, nextPageToken];
|
|
1691
1760
|
} catch (error) {
|
|
@@ -2195,11 +2264,12 @@ async function planFunctionRegistry(client, workspaceId, appName, entries) {
|
|
|
2195
2264
|
const conflicts = [];
|
|
2196
2265
|
const unmanaged = [];
|
|
2197
2266
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
2198
|
-
const existingFunctions = await fetchAll(async (pageToken) => {
|
|
2267
|
+
const existingFunctions = await fetchAll(async (pageToken, maxPageSize) => {
|
|
2199
2268
|
try {
|
|
2200
2269
|
const response = await client.listFunctionRegistries({
|
|
2201
2270
|
workspaceId,
|
|
2202
|
-
pageToken
|
|
2271
|
+
pageToken,
|
|
2272
|
+
pageSize: maxPageSize
|
|
2203
2273
|
});
|
|
2204
2274
|
return [response.functions.map((f) => ({
|
|
2205
2275
|
name: f.name,
|
|
@@ -2362,11 +2432,12 @@ async function planExecutor(context) {
|
|
|
2362
2432
|
const conflicts = [];
|
|
2363
2433
|
const unmanaged = [];
|
|
2364
2434
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
2365
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
2435
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
2366
2436
|
try {
|
|
2367
2437
|
const { executors: executors$1, nextPageToken } = await client.listExecutorExecutors({
|
|
2368
2438
|
workspaceId,
|
|
2369
|
-
pageToken
|
|
2439
|
+
pageToken,
|
|
2440
|
+
pageSize: maxPageSize
|
|
2370
2441
|
});
|
|
2371
2442
|
return [executors$1, nextPageToken];
|
|
2372
2443
|
} catch (error) {
|
|
@@ -2433,33 +2504,11 @@ async function planExecutor(context) {
|
|
|
2433
2504
|
resourceOwners
|
|
2434
2505
|
};
|
|
2435
2506
|
}
|
|
2436
|
-
const actorTransformExpr = `actor: args.actor ? (({ attributeMap, attributes: attrList, ...rest }) => ({ ...rest, attributes: attributeMap, attributeList: attrList }))(args.actor) : null`;
|
|
2437
|
-
/**
|
|
2438
|
-
* Build args expression for resolverExecuted trigger.
|
|
2439
|
-
* Transforms server's succeeded/failed fields to success/result/error fields.
|
|
2440
|
-
* @param additionalFields - Additional fields to include in the args expression
|
|
2441
|
-
* @returns JavaScript expression for resolverExecuted trigger args
|
|
2442
|
-
*/
|
|
2443
|
-
function buildResolverExecutedArgsExpr(additionalFields) {
|
|
2444
|
-
const baseFields = `...args, appNamespace: args.namespaceName, ${actorTransformExpr}, success: !!args.succeeded, result: args.succeeded?.result.resolver, error: args.failed?.error`;
|
|
2445
|
-
return additionalFields ? `({ ${baseFields}, ${additionalFields} })` : `({ ${baseFields} })`;
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* Build args expression for incomingWebhook trigger.
|
|
2449
|
-
* Transforms server's raw_body field to rawBody field.
|
|
2450
|
-
* @param additionalFields - Additional fields to include in the args expression
|
|
2451
|
-
* @returns JavaScript expression for incomingWebhook trigger args
|
|
2452
|
-
*/
|
|
2453
|
-
function buildIncomingWebhookArgsExpr(additionalFields) {
|
|
2454
|
-
const baseFields = `...args, appNamespace: args.namespaceName, rawBody: args.raw_body`;
|
|
2455
|
-
return additionalFields ? `({ ${baseFields}, ${additionalFields} })` : `({ ${baseFields} })`;
|
|
2456
|
-
}
|
|
2457
2507
|
function protoExecutor(appName, executor, env) {
|
|
2458
2508
|
const trigger = executor.trigger;
|
|
2459
2509
|
let triggerType;
|
|
2460
2510
|
let triggerConfig;
|
|
2461
|
-
const
|
|
2462
|
-
const baseArgsExpr = `({ ...args, appNamespace: args.namespaceName, ${actorTransformExpr}, ${envField} })`;
|
|
2511
|
+
const argsExpr = buildExecutorArgsExpr(trigger.kind, env);
|
|
2463
2512
|
const eventType = {
|
|
2464
2513
|
recordCreated: "tailordb.type_record.created",
|
|
2465
2514
|
recordUpdated: "tailordb.type_record.updated",
|
|
@@ -2491,7 +2540,7 @@ function protoExecutor(appName, executor, env) {
|
|
|
2491
2540
|
case: "event",
|
|
2492
2541
|
value: {
|
|
2493
2542
|
eventType: eventType[trigger.kind],
|
|
2494
|
-
condition: { expr: [`args.typeName === "${trigger.typeName}"`, ...trigger.condition ? [`(${stringifyFunction(trigger.condition)})(${
|
|
2543
|
+
condition: { expr: [`args.typeName === "${trigger.typeName}"`, ...trigger.condition ? [`(${stringifyFunction(trigger.condition)})(${argsExpr})`] : []].join(" && ") }
|
|
2495
2544
|
}
|
|
2496
2545
|
} };
|
|
2497
2546
|
break;
|
|
@@ -2501,7 +2550,7 @@ function protoExecutor(appName, executor, env) {
|
|
|
2501
2550
|
case: "event",
|
|
2502
2551
|
value: {
|
|
2503
2552
|
eventType: eventType[trigger.kind],
|
|
2504
|
-
condition: { expr: [`args.resolverName === "${trigger.resolverName}"`, ...trigger.condition ? [`(${stringifyFunction(trigger.condition)})(${
|
|
2553
|
+
condition: { expr: [`args.resolverName === "${trigger.resolverName}"`, ...trigger.condition ? [`(${stringifyFunction(trigger.condition)})(${argsExpr})`] : []].join(" && ") }
|
|
2505
2554
|
}
|
|
2506
2555
|
} };
|
|
2507
2556
|
break;
|
|
@@ -2529,7 +2578,6 @@ function protoExecutor(appName, executor, env) {
|
|
|
2529
2578
|
const target = executor.operation;
|
|
2530
2579
|
let targetType;
|
|
2531
2580
|
let targetConfig;
|
|
2532
|
-
const argsExpr = trigger.kind === "resolverExecuted" ? buildResolverExecutedArgsExpr(envField) : trigger.kind === "incomingWebhook" ? buildIncomingWebhookArgsExpr(envField) : baseArgsExpr;
|
|
2533
2581
|
switch (target.kind) {
|
|
2534
2582
|
case "webhook":
|
|
2535
2583
|
targetType = ExecutorTargetType.WEBHOOK;
|
|
@@ -2628,6 +2676,10 @@ const SCALAR_TYPE_MAP = {
|
|
|
2628
2676
|
kind: "ScalarType",
|
|
2629
2677
|
name: "Float"
|
|
2630
2678
|
},
|
|
2679
|
+
decimal: {
|
|
2680
|
+
kind: "CustomScalarType",
|
|
2681
|
+
name: "Decimal"
|
|
2682
|
+
},
|
|
2631
2683
|
boolean: {
|
|
2632
2684
|
kind: "ScalarType",
|
|
2633
2685
|
name: "Boolean"
|
|
@@ -2701,11 +2753,12 @@ async function planServices$1(client, workspaceId, appName, pipelines) {
|
|
|
2701
2753
|
const conflicts = [];
|
|
2702
2754
|
const unmanaged = [];
|
|
2703
2755
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
2704
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
2756
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
2705
2757
|
try {
|
|
2706
2758
|
const { pipelineServices, nextPageToken } = await client.listPipelineServices({
|
|
2707
2759
|
workspaceId,
|
|
2708
|
-
pageToken
|
|
2760
|
+
pageToken,
|
|
2761
|
+
pageSize: maxPageSize
|
|
2709
2762
|
});
|
|
2710
2763
|
return [pipelineServices, nextPageToken];
|
|
2711
2764
|
} catch (error) {
|
|
@@ -2774,12 +2827,13 @@ async function planServices$1(client, workspaceId, appName, pipelines) {
|
|
|
2774
2827
|
async function planResolvers(client, workspaceId, pipelines, executors, deletedServices, env) {
|
|
2775
2828
|
const changeSet = createChangeSet("Pipeline resolvers");
|
|
2776
2829
|
const fetchResolvers = (namespaceName) => {
|
|
2777
|
-
return fetchAll(async (pageToken) => {
|
|
2830
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
2778
2831
|
try {
|
|
2779
2832
|
const { pipelineResolvers, nextPageToken } = await client.listPipelineResolvers({
|
|
2780
2833
|
workspaceId,
|
|
2781
2834
|
namespaceName,
|
|
2782
|
-
pageToken
|
|
2835
|
+
pageToken,
|
|
2836
|
+
pageSize: maxPageSize
|
|
2783
2837
|
});
|
|
2784
2838
|
return [pipelineResolvers, nextPageToken];
|
|
2785
2839
|
} catch (error) {
|
|
@@ -2844,7 +2898,7 @@ function processResolver(namespace, resolver, executorUsedResolvers, env) {
|
|
|
2844
2898
|
description: `${resolver.name} function body`,
|
|
2845
2899
|
operationType: PipelineResolver_OperationType.FUNCTION,
|
|
2846
2900
|
operationSourceRef: resolverFunctionName(namespace, resolver.name),
|
|
2847
|
-
operationHook: { expr:
|
|
2901
|
+
operationHook: { expr: buildResolverOperationHookExpr(env) },
|
|
2848
2902
|
postScript: `args.body`
|
|
2849
2903
|
}];
|
|
2850
2904
|
const typeBaseName = inflection.camelize(resolver.name);
|
|
@@ -2931,11 +2985,12 @@ async function planStaticWebsite(context) {
|
|
|
2931
2985
|
const conflicts = [];
|
|
2932
2986
|
const unmanaged = [];
|
|
2933
2987
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
2934
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
2988
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
2935
2989
|
try {
|
|
2936
2990
|
const { staticwebsites, nextPageToken } = await client.listStaticWebsites({
|
|
2937
2991
|
workspaceId,
|
|
2938
|
-
pageToken
|
|
2992
|
+
pageToken,
|
|
2993
|
+
pageSize: maxPageSize
|
|
2939
2994
|
});
|
|
2940
2995
|
return [staticwebsites, nextPageToken];
|
|
2941
2996
|
} catch (error) {
|
|
@@ -3309,6 +3364,7 @@ function createSnapshotFieldConfig(field) {
|
|
|
3309
3364
|
...field.config.serial.maxValue !== void 0 && { maxValue: field.config.serial.maxValue },
|
|
3310
3365
|
...field.config.serial.format && { format: field.config.serial.format }
|
|
3311
3366
|
};
|
|
3367
|
+
if (field.config.scale !== void 0) config.scale = field.config.scale;
|
|
3312
3368
|
if (field.config.fields && Object.keys(field.config.fields).length > 0) {
|
|
3313
3369
|
config.fields = {};
|
|
3314
3370
|
for (const [nestedName, nestedConfig] of Object.entries(field.config.fields)) config.fields[nestedName] = createSnapshotFieldConfigFromOperatorConfig(nestedConfig);
|
|
@@ -3353,6 +3409,7 @@ function createSnapshotFieldConfigFromOperatorConfig(fieldConfig) {
|
|
|
3353
3409
|
...fieldConfig.serial.maxValue !== void 0 && { maxValue: fieldConfig.serial.maxValue },
|
|
3354
3410
|
...fieldConfig.serial.format && { format: fieldConfig.serial.format }
|
|
3355
3411
|
};
|
|
3412
|
+
if (fieldConfig.scale !== void 0) config.scale = fieldConfig.scale;
|
|
3356
3413
|
if (fieldConfig.fields && Object.keys(fieldConfig.fields).length > 0) {
|
|
3357
3414
|
config.fields = {};
|
|
3358
3415
|
for (const [nestedName, nestedConfig] of Object.entries(fieldConfig.fields)) config.fields[nestedName] = createSnapshotFieldConfigFromOperatorConfig(nestedConfig);
|
|
@@ -3739,6 +3796,7 @@ function areFieldsDifferent(oldField, newField) {
|
|
|
3739
3796
|
if (oldSerial.maxValue !== newSerial.maxValue) return true;
|
|
3740
3797
|
if ((oldSerial.format ?? "") !== (newSerial.format ?? "")) return true;
|
|
3741
3798
|
}
|
|
3799
|
+
if (oldField.scale !== newField.scale) return true;
|
|
3742
3800
|
const oldFields = oldField.fields ?? {};
|
|
3743
3801
|
const newFields = newField.fields ?? {};
|
|
3744
3802
|
const oldFieldNames = Object.keys(oldFields);
|
|
@@ -4161,6 +4219,7 @@ function convertRemoteFieldsToSnapshot(remoteType) {
|
|
|
4161
4219
|
...remoteField.serial.maxValue && { maxValue: Number(remoteField.serial.maxValue) },
|
|
4162
4220
|
...remoteField.serial.format && { format: remoteField.serial.format }
|
|
4163
4221
|
};
|
|
4222
|
+
if (remoteField.scale !== void 0) config.scale = remoteField.scale;
|
|
4164
4223
|
fields[fieldName] = config;
|
|
4165
4224
|
}
|
|
4166
4225
|
return fields;
|
|
@@ -4205,6 +4264,7 @@ function compareFields(typeName, fieldName, remoteField, snapshotField) {
|
|
|
4205
4264
|
const remoteVector = remoteField.vector ?? false;
|
|
4206
4265
|
const snapshotVector = snapshotField.vector ?? false;
|
|
4207
4266
|
if (remoteVector !== snapshotVector) differences.push(`vector: remote=${remoteVector}, expected=${snapshotVector}`);
|
|
4267
|
+
if (remoteField.scale !== snapshotField.scale) differences.push(`scale: remote=${remoteField.scale}, expected=${snapshotField.scale}`);
|
|
4208
4268
|
if (differences.length > 0) return {
|
|
4209
4269
|
typeName,
|
|
4210
4270
|
kind: "field_mismatch",
|
|
@@ -4652,12 +4712,13 @@ function groupMigrationsByNamespace(migrations) {
|
|
|
4652
4712
|
* @returns {Promise<ProtoTailorDBType[]>} Remote TailorDB types
|
|
4653
4713
|
*/
|
|
4654
4714
|
async function fetchRemoteTypes(client, workspaceId, namespace) {
|
|
4655
|
-
return fetchAll(async (pageToken) => {
|
|
4715
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
4656
4716
|
try {
|
|
4657
4717
|
const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
|
|
4658
4718
|
workspaceId,
|
|
4659
4719
|
namespaceName: namespace,
|
|
4660
|
-
pageToken
|
|
4720
|
+
pageToken,
|
|
4721
|
+
pageSize: maxPageSize
|
|
4661
4722
|
});
|
|
4662
4723
|
return [tailordbTypes, nextPageToken];
|
|
4663
4724
|
} catch (error) {
|
|
@@ -5123,8 +5184,7 @@ async function planTailorDB(context) {
|
|
|
5123
5184
|
const executors = forRemoval ? [] : Object.values(await application.executorService?.loadExecutors() ?? {});
|
|
5124
5185
|
const { changeSet: serviceChangeSet, conflicts, unmanaged, resourceOwners } = await planServices(client, workspaceId, application.name, tailordbs);
|
|
5125
5186
|
const deletedServices = serviceChangeSet.deletes.map((del) => del.name);
|
|
5126
|
-
const typeChangeSet = await planTypes(client, workspaceId, tailordbs, executors, deletedServices);
|
|
5127
|
-
const gqlPermissionChangeSet = await planGqlPermissions(client, workspaceId, tailordbs, deletedServices);
|
|
5187
|
+
const [typeChangeSet, gqlPermissionChangeSet] = await Promise.all([planTypes(client, workspaceId, tailordbs, executors, deletedServices), planGqlPermissions(client, workspaceId, tailordbs, deletedServices)]);
|
|
5128
5188
|
serviceChangeSet.print();
|
|
5129
5189
|
typeChangeSet.print();
|
|
5130
5190
|
gqlPermissionChangeSet.print();
|
|
@@ -5153,11 +5213,12 @@ async function planServices(client, workspaceId, appName, tailordbs) {
|
|
|
5153
5213
|
const conflicts = [];
|
|
5154
5214
|
const unmanaged = [];
|
|
5155
5215
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5156
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
5216
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
5157
5217
|
try {
|
|
5158
5218
|
const { tailordbServices, nextPageToken } = await client.listTailorDBServices({
|
|
5159
5219
|
workspaceId,
|
|
5160
|
-
pageToken
|
|
5220
|
+
pageToken,
|
|
5221
|
+
pageSize: maxPageSize
|
|
5161
5222
|
});
|
|
5162
5223
|
return [tailordbServices, nextPageToken];
|
|
5163
5224
|
} catch (error) {
|
|
@@ -5224,12 +5285,13 @@ async function planServices(client, workspaceId, appName, tailordbs) {
|
|
|
5224
5285
|
async function planTypes(client, workspaceId, tailordbs, executors, deletedServices, filteredTypesByNamespace) {
|
|
5225
5286
|
const changeSet = createChangeSet("TailorDB types");
|
|
5226
5287
|
const fetchTypes = (namespaceName) => {
|
|
5227
|
-
return fetchAll(async (pageToken) => {
|
|
5288
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
5228
5289
|
try {
|
|
5229
5290
|
const { tailordbTypes, nextPageToken } = await client.listTailorDBTypes({
|
|
5230
5291
|
workspaceId,
|
|
5231
5292
|
namespaceName,
|
|
5232
|
-
pageToken
|
|
5293
|
+
pageToken,
|
|
5294
|
+
pageSize: maxPageSize
|
|
5233
5295
|
});
|
|
5234
5296
|
return [tailordbTypes, nextPageToken];
|
|
5235
5297
|
} catch (error) {
|
|
@@ -5337,7 +5399,8 @@ function generateTailorDBTypeManifest(type, executorUsedTypes, namespaceGqlOpera
|
|
|
5337
5399
|
start: fieldConfig.serial.start,
|
|
5338
5400
|
...fieldConfig.serial.maxValue && { maxValue: fieldConfig.serial.maxValue },
|
|
5339
5401
|
...fieldConfig.serial.format && { format: fieldConfig.serial.format }
|
|
5340
|
-
} }
|
|
5402
|
+
} },
|
|
5403
|
+
...fieldConfig.scale !== void 0 && { scale: fieldConfig.scale }
|
|
5341
5404
|
};
|
|
5342
5405
|
if (fieldConfig.type === "nested" && fieldConfig.fields) fieldEntry.fields = processNestedFields(fieldConfig.fields);
|
|
5343
5406
|
fields[fieldName] = fieldEntry;
|
|
@@ -5421,7 +5484,8 @@ function processNestedFields(fields) {
|
|
|
5421
5484
|
foreignKey: false,
|
|
5422
5485
|
vector: false,
|
|
5423
5486
|
...toProtoFieldHooks(nestedFieldConfig),
|
|
5424
|
-
fields: deepNestedFields
|
|
5487
|
+
fields: deepNestedFields,
|
|
5488
|
+
...nestedFieldConfig.scale !== void 0 && { scale: nestedFieldConfig.scale }
|
|
5425
5489
|
};
|
|
5426
5490
|
} else nestedFields[nestedFieldName] = {
|
|
5427
5491
|
type: nestedType,
|
|
@@ -5439,7 +5503,8 @@ function processNestedFields(fields) {
|
|
|
5439
5503
|
start: nestedFieldConfig.serial.start,
|
|
5440
5504
|
...nestedFieldConfig.serial.maxValue && { maxValue: nestedFieldConfig.serial.maxValue },
|
|
5441
5505
|
...nestedFieldConfig.serial.format && { format: nestedFieldConfig.serial.format }
|
|
5442
|
-
} }
|
|
5506
|
+
} },
|
|
5507
|
+
...nestedFieldConfig.scale !== void 0 && { scale: nestedFieldConfig.scale }
|
|
5443
5508
|
};
|
|
5444
5509
|
});
|
|
5445
5510
|
return nestedFields;
|
|
@@ -5524,12 +5589,13 @@ function protoOperand(operand) {
|
|
|
5524
5589
|
async function planGqlPermissions(client, workspaceId, tailordbs, deletedServices) {
|
|
5525
5590
|
const changeSet = createChangeSet("TailorDB gqlPermissions");
|
|
5526
5591
|
const fetchGqlPermissions = (namespaceName) => {
|
|
5527
|
-
return fetchAll(async (pageToken) => {
|
|
5592
|
+
return fetchAll(async (pageToken, maxPageSize) => {
|
|
5528
5593
|
try {
|
|
5529
5594
|
const { permissions, nextPageToken } = await client.listTailorDBGQLPermissions({
|
|
5530
5595
|
workspaceId,
|
|
5531
5596
|
namespaceName,
|
|
5532
|
-
pageToken
|
|
5597
|
+
pageToken,
|
|
5598
|
+
pageSize: maxPageSize
|
|
5533
5599
|
});
|
|
5534
5600
|
return [permissions, nextPageToken];
|
|
5535
5601
|
} catch (error) {
|
|
@@ -5809,10 +5875,11 @@ async function registerJobFunctions(client, changeSet, appName) {
|
|
|
5809
5875
|
const { workspaceId } = firstWorkflow;
|
|
5810
5876
|
const allUsedJobNames = /* @__PURE__ */ new Set();
|
|
5811
5877
|
for (const item of [...changeSet.creates, ...changeSet.updates]) for (const jobName of item.usedJobNames) allUsedJobNames.add(jobName);
|
|
5812
|
-
const existingJobFunctions = await fetchAll(async (pageToken) => {
|
|
5878
|
+
const existingJobFunctions = await fetchAll(async (pageToken, maxPageSize) => {
|
|
5813
5879
|
const response = await client.listWorkflowJobFunctions({
|
|
5814
5880
|
workspaceId,
|
|
5815
|
-
pageToken
|
|
5881
|
+
pageToken,
|
|
5882
|
+
pageSize: maxPageSize
|
|
5816
5883
|
});
|
|
5817
5884
|
return [response.jobFunctions.map((j) => j.name), response.nextPageToken];
|
|
5818
5885
|
});
|
|
@@ -5864,10 +5931,11 @@ async function planWorkflow(client, workspaceId, appName, workflows, mainJobDeps
|
|
|
5864
5931
|
const conflicts = [];
|
|
5865
5932
|
const unmanaged = [];
|
|
5866
5933
|
const resourceOwners = /* @__PURE__ */ new Set();
|
|
5867
|
-
const withoutLabel = await fetchAll(async (pageToken) => {
|
|
5934
|
+
const withoutLabel = await fetchAll(async (pageToken, maxPageSize) => {
|
|
5868
5935
|
const response = await client.listWorkflows({
|
|
5869
5936
|
workspaceId,
|
|
5870
|
-
pageToken
|
|
5937
|
+
pageToken,
|
|
5938
|
+
pageSize: maxPageSize
|
|
5871
5939
|
});
|
|
5872
5940
|
return [response.workflows.map((w) => ({
|
|
5873
5941
|
id: w.id,
|
|
@@ -5940,131 +6008,174 @@ async function planWorkflow(client, workspaceId, appName, workflows, mainJobDeps
|
|
|
5940
6008
|
* @returns Promise that resolves when apply completes
|
|
5941
6009
|
*/
|
|
5942
6010
|
async function apply(options) {
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
client
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6011
|
+
return withSpan("apply", async (rootSpan) => {
|
|
6012
|
+
rootSpan.setAttribute("apply.dry_run", options?.dryRun ?? false);
|
|
6013
|
+
const { config, application, workflowBuildResult, buildOnly } = await withSpan("build", async () => {
|
|
6014
|
+
const { config: config$1, plugins } = await withSpan("build.loadConfig", () => loadConfig(options?.configPath));
|
|
6015
|
+
const dryRun$1 = options?.dryRun ?? false;
|
|
6016
|
+
const buildOnly$1 = options?.buildOnly ?? process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY === "true";
|
|
6017
|
+
let pluginManager;
|
|
6018
|
+
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
6019
|
+
await withSpan("build.generateUserTypes", () => generateUserTypes({
|
|
6020
|
+
config: config$1,
|
|
6021
|
+
configPath: config$1.path
|
|
6022
|
+
}));
|
|
6023
|
+
const { application: application$1, workflowBuildResult: workflowBuildResult$1 } = await withSpan("build.loadApplication", () => loadApplication({
|
|
6024
|
+
config: config$1,
|
|
6025
|
+
pluginManager
|
|
6026
|
+
}));
|
|
6027
|
+
return {
|
|
6028
|
+
config: config$1,
|
|
6029
|
+
plugins,
|
|
6030
|
+
application: application$1,
|
|
6031
|
+
workflowBuildResult: workflowBuildResult$1,
|
|
6032
|
+
dryRun: dryRun$1,
|
|
6033
|
+
buildOnly: buildOnly$1
|
|
6034
|
+
};
|
|
6035
|
+
});
|
|
6036
|
+
if (buildOnly) return;
|
|
6037
|
+
const client = await initOperatorClient(await loadAccessToken({
|
|
6038
|
+
useProfile: true,
|
|
6039
|
+
profile: options?.profile
|
|
6040
|
+
}));
|
|
6041
|
+
const workspaceId = loadWorkspaceId({
|
|
6042
|
+
workspaceId: options?.workspaceId,
|
|
6043
|
+
profile: options?.profile
|
|
6044
|
+
});
|
|
6045
|
+
rootSpan.setAttribute("app.name", application.name);
|
|
6046
|
+
rootSpan.setAttribute("workspace.id", workspaceId);
|
|
6047
|
+
const workflowService = application.workflowService;
|
|
6048
|
+
const functionEntries = collectFunctionEntries(application, workflowService?.jobs ?? []);
|
|
6049
|
+
const dryRun = options?.dryRun ?? false;
|
|
6050
|
+
const yes = options?.yes ?? false;
|
|
6051
|
+
const { functionRegistry, tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow } = await withSpan("plan", async () => {
|
|
6052
|
+
const ctx = {
|
|
6053
|
+
client,
|
|
6054
|
+
workspaceId,
|
|
6055
|
+
application,
|
|
6056
|
+
forRemoval: false,
|
|
6057
|
+
config,
|
|
6058
|
+
noSchemaCheck: options?.noSchemaCheck
|
|
6059
|
+
};
|
|
6060
|
+
const [functionRegistry$1, tailorDB$1, staticWebsite$1, idp$1, auth$1, pipeline$1, app$1, executor$1, workflow$1] = await Promise.all([
|
|
6061
|
+
withSpan("plan.functionRegistry", () => planFunctionRegistry(client, workspaceId, application.name, functionEntries)),
|
|
6062
|
+
withSpan("plan.tailorDB", () => planTailorDB(ctx)),
|
|
6063
|
+
withSpan("plan.staticWebsite", () => planStaticWebsite(ctx)),
|
|
6064
|
+
withSpan("plan.idp", () => planIdP(ctx)),
|
|
6065
|
+
withSpan("plan.auth", () => planAuth(ctx)),
|
|
6066
|
+
withSpan("plan.pipeline", () => planPipeline(ctx)),
|
|
6067
|
+
withSpan("plan.application", () => planApplication(ctx)),
|
|
6068
|
+
withSpan("plan.executor", () => planExecutor(ctx)),
|
|
6069
|
+
withSpan("plan.workflow", () => planWorkflow(client, workspaceId, application.name, workflowService?.workflows ?? {}, workflowBuildResult?.mainJobDeps ?? {}))
|
|
6070
|
+
]);
|
|
6071
|
+
return {
|
|
6072
|
+
functionRegistry: functionRegistry$1,
|
|
6073
|
+
tailorDB: tailorDB$1,
|
|
6074
|
+
staticWebsite: staticWebsite$1,
|
|
6075
|
+
idp: idp$1,
|
|
6076
|
+
auth: auth$1,
|
|
6077
|
+
pipeline: pipeline$1,
|
|
6078
|
+
app: app$1,
|
|
6079
|
+
executor: executor$1,
|
|
6080
|
+
workflow: workflow$1
|
|
6081
|
+
};
|
|
6082
|
+
});
|
|
6083
|
+
await withSpan("confirm", async () => {
|
|
6084
|
+
const allConflicts = [
|
|
6085
|
+
...functionRegistry.conflicts,
|
|
6086
|
+
...tailorDB.conflicts,
|
|
6087
|
+
...staticWebsite.conflicts,
|
|
6088
|
+
...idp.conflicts,
|
|
6089
|
+
...auth.conflicts,
|
|
6090
|
+
...pipeline.conflicts,
|
|
6091
|
+
...executor.conflicts,
|
|
6092
|
+
...workflow.conflicts
|
|
6093
|
+
];
|
|
6094
|
+
await confirmOwnerConflict(allConflicts, application.name, yes);
|
|
6095
|
+
await confirmUnmanagedResources([
|
|
6096
|
+
...functionRegistry.unmanaged,
|
|
6097
|
+
...tailorDB.unmanaged,
|
|
6098
|
+
...staticWebsite.unmanaged,
|
|
6099
|
+
...idp.unmanaged,
|
|
6100
|
+
...auth.unmanaged,
|
|
6101
|
+
...pipeline.unmanaged,
|
|
6102
|
+
...executor.unmanaged,
|
|
6103
|
+
...workflow.unmanaged
|
|
6104
|
+
], application.name, yes);
|
|
6105
|
+
const importantDeletions = [];
|
|
6106
|
+
for (const del of tailorDB.changeSet.type.deletes) importantDeletions.push({
|
|
6107
|
+
resourceType: "TailorDB type",
|
|
6108
|
+
resourceName: del.name
|
|
6109
|
+
});
|
|
6110
|
+
for (const del of staticWebsite.changeSet.deletes) importantDeletions.push({
|
|
6111
|
+
resourceType: "StaticWebsite",
|
|
6112
|
+
resourceName: del.name
|
|
6113
|
+
});
|
|
6114
|
+
for (const del of auth.changeSet.oauth2Client.deletes) importantDeletions.push({
|
|
6115
|
+
resourceType: "OAuth2 client",
|
|
6116
|
+
resourceName: del.name
|
|
6117
|
+
});
|
|
6118
|
+
for (const replace of auth.changeSet.oauth2Client.replaces) importantDeletions.push({
|
|
6119
|
+
resourceType: "OAuth2 client (client type change)",
|
|
6120
|
+
resourceName: replace.name
|
|
6121
|
+
});
|
|
6122
|
+
await confirmImportantResourceDeletion(importantDeletions, yes);
|
|
6123
|
+
const resourceOwners = new Set([
|
|
6124
|
+
...functionRegistry.resourceOwners,
|
|
6125
|
+
...tailorDB.resourceOwners,
|
|
6126
|
+
...staticWebsite.resourceOwners,
|
|
6127
|
+
...idp.resourceOwners,
|
|
6128
|
+
...auth.resourceOwners,
|
|
6129
|
+
...pipeline.resourceOwners,
|
|
6130
|
+
...executor.resourceOwners,
|
|
6131
|
+
...workflow.resourceOwners
|
|
6132
|
+
]);
|
|
6133
|
+
const emptyApps = [...new Set(allConflicts.map((c) => c.currentOwner))].filter((owner) => !resourceOwners.has(owner));
|
|
6134
|
+
for (const emptyApp of emptyApps) app.deletes.push({
|
|
6135
|
+
name: emptyApp,
|
|
6136
|
+
request: {
|
|
6137
|
+
workspaceId,
|
|
6138
|
+
applicationName: emptyApp
|
|
6139
|
+
}
|
|
6140
|
+
});
|
|
6141
|
+
});
|
|
6142
|
+
if (dryRun) {
|
|
6143
|
+
logger.info("Dry run enabled. No changes applied.");
|
|
6144
|
+
return;
|
|
6040
6145
|
}
|
|
6146
|
+
await withSpan("apply.createUpdateServices", async () => {
|
|
6147
|
+
await applyFunctionRegistry(client, workspaceId, functionRegistry, "create-update");
|
|
6148
|
+
await applyStaticWebsite(client, staticWebsite, "create-update");
|
|
6149
|
+
await applyIdP(client, idp, "create-update");
|
|
6150
|
+
await applyAuth(client, auth, "create-update");
|
|
6151
|
+
await applyTailorDB(client, tailorDB, "create-update");
|
|
6152
|
+
await applyPipeline(client, pipeline, "create-update");
|
|
6153
|
+
});
|
|
6154
|
+
await withSpan("apply.deleteSubgraphResources", async () => {
|
|
6155
|
+
await applyPipeline(client, pipeline, "delete-resources");
|
|
6156
|
+
await applyAuth(client, auth, "delete-resources");
|
|
6157
|
+
await applyIdP(client, idp, "delete-resources");
|
|
6158
|
+
});
|
|
6159
|
+
await withSpan("apply.createUpdateApplication", () => applyApplication(client, app, "create-update"));
|
|
6160
|
+
await withSpan("apply.createUpdateDependentServices", async () => {
|
|
6161
|
+
await applyExecutor(client, executor, "create-update");
|
|
6162
|
+
await applyWorkflow(client, workflow, "create-update");
|
|
6163
|
+
});
|
|
6164
|
+
await withSpan("apply.deleteDependentServices", async () => {
|
|
6165
|
+
await applyWorkflow(client, workflow, "delete");
|
|
6166
|
+
await applyExecutor(client, executor, "delete");
|
|
6167
|
+
await applyStaticWebsite(client, staticWebsite, "delete");
|
|
6168
|
+
});
|
|
6169
|
+
await withSpan("apply.deleteApplication", () => applyApplication(client, app, "delete"));
|
|
6170
|
+
await withSpan("apply.deleteSubgraphServices", async () => {
|
|
6171
|
+
await applyPipeline(client, pipeline, "delete-services");
|
|
6172
|
+
await applyAuth(client, auth, "delete-services");
|
|
6173
|
+
await applyIdP(client, idp, "delete-services");
|
|
6174
|
+
await applyTailorDB(client, tailorDB, "delete-services");
|
|
6175
|
+
});
|
|
6176
|
+
await withSpan("apply.cleanup", () => applyFunctionRegistry(client, workspaceId, functionRegistry, "delete"));
|
|
6177
|
+
logger.success("Successfully applied changes.");
|
|
6041
6178
|
});
|
|
6042
|
-
if (dryRun) {
|
|
6043
|
-
logger.info("Dry run enabled. No changes applied.");
|
|
6044
|
-
return;
|
|
6045
|
-
}
|
|
6046
|
-
await applyFunctionRegistry(client, workspaceId, functionRegistry, "create-update");
|
|
6047
|
-
await applyStaticWebsite(client, staticWebsite, "create-update");
|
|
6048
|
-
await applyIdP(client, idp, "create-update");
|
|
6049
|
-
await applyAuth(client, auth, "create-update");
|
|
6050
|
-
await applyTailorDB(client, tailorDB, "create-update");
|
|
6051
|
-
await applyPipeline(client, pipeline, "create-update");
|
|
6052
|
-
await applyPipeline(client, pipeline, "delete-resources");
|
|
6053
|
-
await applyAuth(client, auth, "delete-resources");
|
|
6054
|
-
await applyIdP(client, idp, "delete-resources");
|
|
6055
|
-
await applyApplication(client, app, "create-update");
|
|
6056
|
-
await applyExecutor(client, executor, "create-update");
|
|
6057
|
-
await applyWorkflow(client, workflow, "create-update");
|
|
6058
|
-
await applyWorkflow(client, workflow, "delete");
|
|
6059
|
-
await applyExecutor(client, executor, "delete");
|
|
6060
|
-
await applyStaticWebsite(client, staticWebsite, "delete");
|
|
6061
|
-
await applyApplication(client, app, "delete");
|
|
6062
|
-
await applyPipeline(client, pipeline, "delete-services");
|
|
6063
|
-
await applyAuth(client, auth, "delete-services");
|
|
6064
|
-
await applyIdP(client, idp, "delete-services");
|
|
6065
|
-
await applyTailorDB(client, tailorDB, "delete-services");
|
|
6066
|
-
await applyFunctionRegistry(client, workspaceId, functionRegistry, "delete");
|
|
6067
|
-
logger.success("Successfully applied changes.");
|
|
6068
6179
|
}
|
|
6069
6180
|
const applyCommand = defineCommand({
|
|
6070
6181
|
name: "apply",
|
|
@@ -6654,10 +6765,11 @@ async function listWorkflowExecutions(options) {
|
|
|
6654
6765
|
}) }));
|
|
6655
6766
|
}
|
|
6656
6767
|
const filter = filters.length > 0 ? create(FilterSchema, { and: filters }) : void 0;
|
|
6657
|
-
return (await fetchAll(async (pageToken) => {
|
|
6768
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
6658
6769
|
const { executions, nextPageToken } = await client.listWorkflowExecutions({
|
|
6659
6770
|
workspaceId,
|
|
6660
6771
|
pageToken,
|
|
6772
|
+
pageSize: maxPageSize,
|
|
6661
6773
|
pageDirection: PageDirection.DESC,
|
|
6662
6774
|
filter
|
|
6663
6775
|
});
|
|
@@ -7154,11 +7266,12 @@ async function getExecutorJob(options) {
|
|
|
7154
7266
|
if (!job) throw new Error(`Job '${options.jobId}' not found.`);
|
|
7155
7267
|
const jobInfo = toExecutorJobInfo(job);
|
|
7156
7268
|
if (options.attempts) {
|
|
7157
|
-
const attempts = await fetchAll(async (pageToken) => {
|
|
7269
|
+
const attempts = await fetchAll(async (pageToken, maxPageSize) => {
|
|
7158
7270
|
const { attempts: attempts$1, nextPageToken } = await client.listExecutorJobAttempts({
|
|
7159
7271
|
workspaceId,
|
|
7160
7272
|
jobId: options.jobId,
|
|
7161
7273
|
pageToken,
|
|
7274
|
+
pageSize: maxPageSize,
|
|
7162
7275
|
pageDirection: PageDirection.DESC
|
|
7163
7276
|
});
|
|
7164
7277
|
return [attempts$1, nextPageToken];
|
|
@@ -7210,11 +7323,12 @@ async function watchExecutorJob(options) {
|
|
|
7210
7323
|
const coloredStatus = colorizeExecutorJobStatus(jobInfo.status);
|
|
7211
7324
|
if (job.status === ExecutorJobStatus.SUCCESS) spinner.succeed(`Executor job completed: ${coloredStatus}`);
|
|
7212
7325
|
else spinner.fail(`Executor job completed: ${coloredStatus}`);
|
|
7213
|
-
const attemptInfos = (await fetchAll(async (pageToken) => {
|
|
7326
|
+
const attemptInfos = (await fetchAll(async (pageToken, maxPageSize) => {
|
|
7214
7327
|
const { attempts, nextPageToken } = await client.listExecutorJobAttempts({
|
|
7215
7328
|
workspaceId,
|
|
7216
7329
|
jobId: options.jobId,
|
|
7217
7330
|
pageToken,
|
|
7331
|
+
pageSize: maxPageSize,
|
|
7218
7332
|
pageDirection: PageDirection.DESC
|
|
7219
7333
|
});
|
|
7220
7334
|
return [attempts, nextPageToken];
|
|
@@ -7486,10 +7600,11 @@ async function listExecutors(options) {
|
|
|
7486
7600
|
workspaceId: options?.workspaceId,
|
|
7487
7601
|
profile: options?.profile
|
|
7488
7602
|
});
|
|
7489
|
-
return (await fetchAll(async (pageToken) => {
|
|
7603
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
7490
7604
|
const { executors, nextPageToken } = await client.listExecutorExecutors({
|
|
7491
7605
|
workspaceId,
|
|
7492
|
-
pageToken
|
|
7606
|
+
pageToken,
|
|
7607
|
+
pageSize: maxPageSize
|
|
7493
7608
|
});
|
|
7494
7609
|
return [executors, nextPageToken];
|
|
7495
7610
|
})).map((e) => toExecutorListInfo(e));
|
|
@@ -7756,10 +7871,11 @@ async function listWebhookExecutors(options) {
|
|
|
7756
7871
|
workspaceId: options?.workspaceId,
|
|
7757
7872
|
profile: options?.profile
|
|
7758
7873
|
});
|
|
7759
|
-
return (await fetchAll(async (pageToken) => {
|
|
7874
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
7760
7875
|
const { executors, nextPageToken } = await client.listExecutorExecutors({
|
|
7761
7876
|
workspaceId,
|
|
7762
|
-
pageToken
|
|
7877
|
+
pageToken,
|
|
7878
|
+
pageSize: maxPageSize
|
|
7763
7879
|
});
|
|
7764
7880
|
return [executors, nextPageToken];
|
|
7765
7881
|
})).filter((e) => e.triggerType === ExecutorTriggerType.INCOMING_WEBHOOK).map((e) => ({
|
|
@@ -7798,6 +7914,19 @@ const webhookCommand = defineCommand({
|
|
|
7798
7914
|
}
|
|
7799
7915
|
});
|
|
7800
7916
|
|
|
7917
|
+
//#endregion
|
|
7918
|
+
//#region src/cli/generator/types.ts
|
|
7919
|
+
/**
|
|
7920
|
+
* Type guard to check if a generator has a specific dependency.
|
|
7921
|
+
* @template D
|
|
7922
|
+
* @param generator - Code generator instance
|
|
7923
|
+
* @param dependency - Dependency kind to check
|
|
7924
|
+
* @returns True if the generator has the dependency
|
|
7925
|
+
*/
|
|
7926
|
+
function hasDependency(generator, dependency) {
|
|
7927
|
+
return generator.dependencies.includes(dependency);
|
|
7928
|
+
}
|
|
7929
|
+
|
|
7801
7930
|
//#endregion
|
|
7802
7931
|
//#region src/cli/generator/watch/index.ts
|
|
7803
7932
|
/**
|
|
@@ -8198,6 +8327,7 @@ function createGenerationManager(params) {
|
|
|
8198
8327
|
};
|
|
8199
8328
|
let watcher = null;
|
|
8200
8329
|
const generatorResults = {};
|
|
8330
|
+
const generationPlugins = pluginManager?.getPluginsWithGenerationHooks() ?? [];
|
|
8201
8331
|
function getDeps(gen) {
|
|
8202
8332
|
return new Set(gen.dependencies);
|
|
8203
8333
|
}
|
|
@@ -8318,12 +8448,112 @@ function createGenerationManager(params) {
|
|
|
8318
8448
|
baseDir: path.join(baseDir, gen.id),
|
|
8319
8449
|
configPath: config.path
|
|
8320
8450
|
});
|
|
8451
|
+
await writeGeneratedFiles(gen.id, result);
|
|
8452
|
+
}
|
|
8453
|
+
/**
|
|
8454
|
+
* Build TailorDB namespace data array from loaded services.
|
|
8455
|
+
* @returns Array of TailorDB namespace data
|
|
8456
|
+
*/
|
|
8457
|
+
function buildTailorDBData() {
|
|
8458
|
+
return Object.entries(services.tailordb).map(([namespace, info]) => ({
|
|
8459
|
+
namespace,
|
|
8460
|
+
types: info.types,
|
|
8461
|
+
sourceInfo: new Map(Object.entries(info.sourceInfo)),
|
|
8462
|
+
pluginAttachments: info.pluginAttachments
|
|
8463
|
+
}));
|
|
8464
|
+
}
|
|
8465
|
+
/**
|
|
8466
|
+
* Build resolver namespace data array from loaded services.
|
|
8467
|
+
* @returns Array of resolver namespace data
|
|
8468
|
+
*/
|
|
8469
|
+
function buildResolverData() {
|
|
8470
|
+
return Object.entries(services.resolver).map(([namespace, resolvers]) => ({
|
|
8471
|
+
namespace,
|
|
8472
|
+
resolvers
|
|
8473
|
+
}));
|
|
8474
|
+
}
|
|
8475
|
+
/**
|
|
8476
|
+
* Run a plugin's phase-complete hook and write any generated files.
|
|
8477
|
+
* @param plugin - Plugin to run the hook on
|
|
8478
|
+
* @param hookName - Name of the hook to call
|
|
8479
|
+
* @returns Promise that resolves when hook completes
|
|
8480
|
+
*/
|
|
8481
|
+
async function runPluginPhaseHook(plugin, hookName) {
|
|
8482
|
+
if (!plugin[hookName]) return;
|
|
8483
|
+
const pluginBaseDir = path.join(baseDir, plugin.id);
|
|
8484
|
+
const auth = getAuthInput();
|
|
8485
|
+
const tailordb = buildTailorDBData();
|
|
8486
|
+
let result;
|
|
8487
|
+
switch (hookName) {
|
|
8488
|
+
case "onTailorDBReady":
|
|
8489
|
+
result = await plugin.onTailorDBReady({
|
|
8490
|
+
tailordb,
|
|
8491
|
+
auth,
|
|
8492
|
+
baseDir: pluginBaseDir,
|
|
8493
|
+
configPath: config.path,
|
|
8494
|
+
pluginConfig: plugin.pluginConfig
|
|
8495
|
+
});
|
|
8496
|
+
break;
|
|
8497
|
+
case "onResolverReady":
|
|
8498
|
+
result = await plugin.onResolverReady({
|
|
8499
|
+
tailordb,
|
|
8500
|
+
resolvers: buildResolverData(),
|
|
8501
|
+
auth,
|
|
8502
|
+
baseDir: pluginBaseDir,
|
|
8503
|
+
configPath: config.path,
|
|
8504
|
+
pluginConfig: plugin.pluginConfig
|
|
8505
|
+
});
|
|
8506
|
+
break;
|
|
8507
|
+
case "onExecutorReady":
|
|
8508
|
+
result = await plugin.onExecutorReady({
|
|
8509
|
+
tailordb,
|
|
8510
|
+
resolvers: buildResolverData(),
|
|
8511
|
+
executors: { ...services.executor },
|
|
8512
|
+
auth,
|
|
8513
|
+
baseDir: pluginBaseDir,
|
|
8514
|
+
configPath: config.path,
|
|
8515
|
+
pluginConfig: plugin.pluginConfig
|
|
8516
|
+
});
|
|
8517
|
+
break;
|
|
8518
|
+
}
|
|
8519
|
+
await writeGeneratedFiles(plugin.id, result);
|
|
8520
|
+
}
|
|
8521
|
+
/**
|
|
8522
|
+
* Run a specific generation-time hook for all plugins that implement it.
|
|
8523
|
+
* Each hook runs at its natural pipeline phase, ensuring outputs from earlier
|
|
8524
|
+
* phases are available when later phases load resolvers/executors.
|
|
8525
|
+
* @param hookName - Name of the hook to call
|
|
8526
|
+
* @param watch - Whether running in watch mode (suppresses throws)
|
|
8527
|
+
*/
|
|
8528
|
+
async function runPluginHook(hookName, watch$1) {
|
|
8529
|
+
const plugins = generationPlugins.filter((p) => p[hookName] != null);
|
|
8530
|
+
if (plugins.length === 0) return;
|
|
8531
|
+
const results = await Promise.allSettled(plugins.map(async (plugin) => {
|
|
8532
|
+
try {
|
|
8533
|
+
await runPluginPhaseHook(plugin, hookName);
|
|
8534
|
+
} catch (error) {
|
|
8535
|
+
logger.error(`Error processing plugin ${styles.bold(plugin.id)} (${hookName})`);
|
|
8536
|
+
logger.error(String(error));
|
|
8537
|
+
if (!watch$1) throw error;
|
|
8538
|
+
}
|
|
8539
|
+
}));
|
|
8540
|
+
if (!watch$1) {
|
|
8541
|
+
const failures = results.filter((r) => r.status === "rejected");
|
|
8542
|
+
if (failures.length > 0) throw new AggregateError(failures.map((f) => f.reason));
|
|
8543
|
+
}
|
|
8544
|
+
}
|
|
8545
|
+
/**
|
|
8546
|
+
* Write generated files to disk.
|
|
8547
|
+
* @param sourceId - Generator or plugin ID for logging
|
|
8548
|
+
* @param result - Generator result containing files to write
|
|
8549
|
+
*/
|
|
8550
|
+
async function writeGeneratedFiles(sourceId, result) {
|
|
8321
8551
|
await Promise.all(result.files.map(async (file) => {
|
|
8322
8552
|
fs$2.mkdirSync(path.dirname(file.path), { recursive: true });
|
|
8323
8553
|
return new Promise((resolve, reject) => {
|
|
8324
8554
|
if (file.skipIfExists && fs$2.existsSync(file.path)) {
|
|
8325
8555
|
const relativePath = path.relative(process.cwd(), file.path);
|
|
8326
|
-
logger.debug(`${
|
|
8556
|
+
logger.debug(`${sourceId} | skip existing: ${relativePath}`);
|
|
8327
8557
|
return resolve();
|
|
8328
8558
|
}
|
|
8329
8559
|
fs$2.writeFile(file.path, file.content, (err) => {
|
|
@@ -8334,7 +8564,7 @@ function createGenerationManager(params) {
|
|
|
8334
8564
|
reject(err);
|
|
8335
8565
|
} else {
|
|
8336
8566
|
const relativePath = path.relative(process.cwd(), file.path);
|
|
8337
|
-
logger.log(`${
|
|
8567
|
+
logger.log(`${sourceId} | generate: ${styles.success(relativePath)}`);
|
|
8338
8568
|
if (file.executable) fs$2.chmod(file.path, 493, (chmodErr) => {
|
|
8339
8569
|
if (chmodErr) {
|
|
8340
8570
|
const relativePath$1 = path.relative(process.cwd(), file.path);
|
|
@@ -8363,7 +8593,7 @@ function createGenerationManager(params) {
|
|
|
8363
8593
|
await aggregate(gen);
|
|
8364
8594
|
}
|
|
8365
8595
|
async function runGenerators(gens, watch$1) {
|
|
8366
|
-
await Promise.allSettled(gens.map(async (gen) => {
|
|
8596
|
+
const results = await Promise.allSettled(gens.map(async (gen) => {
|
|
8367
8597
|
try {
|
|
8368
8598
|
await processGenerator(gen);
|
|
8369
8599
|
} catch (error) {
|
|
@@ -8372,6 +8602,10 @@ function createGenerationManager(params) {
|
|
|
8372
8602
|
if (!watch$1) throw error;
|
|
8373
8603
|
}
|
|
8374
8604
|
}));
|
|
8605
|
+
if (!watch$1) {
|
|
8606
|
+
const failures = results.filter((r) => r.status === "rejected");
|
|
8607
|
+
if (failures.length > 0) throw new AggregateError(failures.map((f) => f.reason));
|
|
8608
|
+
}
|
|
8375
8609
|
}
|
|
8376
8610
|
async function restartWatchProcess() {
|
|
8377
8611
|
logger.newline();
|
|
@@ -8433,8 +8667,9 @@ function createGenerationManager(params) {
|
|
|
8433
8667
|
if (app.authService) await app.authService.resolveNamespaces();
|
|
8434
8668
|
if (app.tailorDBServices.length > 0 || pluginExecutorFiles.length > 0) logger.newline();
|
|
8435
8669
|
const tailordbOnlyGens = generators.filter((g) => onlyHas(g, "tailordb"));
|
|
8436
|
-
|
|
8437
|
-
|
|
8670
|
+
const hasOnTailorDBReady = generationPlugins.some((p) => p.onTailorDBReady != null);
|
|
8671
|
+
if (tailordbOnlyGens.length > 0 || hasOnTailorDBReady) {
|
|
8672
|
+
await Promise.all([runGenerators(tailordbOnlyGens, watch$1), runPluginHook("onTailorDBReady", watch$1)]);
|
|
8438
8673
|
logger.newline();
|
|
8439
8674
|
}
|
|
8440
8675
|
for (const resolverService of app.resolverServices) {
|
|
@@ -8452,8 +8687,9 @@ function createGenerationManager(params) {
|
|
|
8452
8687
|
}
|
|
8453
8688
|
}
|
|
8454
8689
|
const nonExecutorGens = generators.filter((g) => !tailordbOnlyGens.includes(g) && hasNone(g, "executor"));
|
|
8455
|
-
|
|
8456
|
-
|
|
8690
|
+
const hasOnResolverReady = generationPlugins.some((p) => p.onResolverReady != null);
|
|
8691
|
+
if (nonExecutorGens.length > 0 || hasOnResolverReady) {
|
|
8692
|
+
await Promise.all([runGenerators(nonExecutorGens, watch$1), runPluginHook("onResolverReady", watch$1)]);
|
|
8457
8693
|
logger.newline();
|
|
8458
8694
|
}
|
|
8459
8695
|
if (executorService) {
|
|
@@ -8465,8 +8701,9 @@ function createGenerationManager(params) {
|
|
|
8465
8701
|
services.executor[key] = executor;
|
|
8466
8702
|
});
|
|
8467
8703
|
const executorGens = generators.filter((g) => hasAll(g, "executor"));
|
|
8468
|
-
|
|
8469
|
-
|
|
8704
|
+
const hasOnExecutorReady = generationPlugins.some((p) => p.onExecutorReady != null);
|
|
8705
|
+
if (executorGens.length > 0 || hasOnExecutorReady) {
|
|
8706
|
+
await Promise.all([runGenerators(executorGens, watch$1), runPluginHook("onExecutorReady", watch$1)]);
|
|
8470
8707
|
logger.newline();
|
|
8471
8708
|
}
|
|
8472
8709
|
},
|
|
@@ -8574,10 +8811,11 @@ async function listMachineUsers(options) {
|
|
|
8574
8811
|
applicationName: config.name
|
|
8575
8812
|
});
|
|
8576
8813
|
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
8577
|
-
return (await fetchAll(async (pageToken) => {
|
|
8814
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
8578
8815
|
const { machineUsers, nextPageToken } = await client.listAuthMachineUsers({
|
|
8579
8816
|
workspaceId,
|
|
8580
8817
|
pageToken,
|
|
8818
|
+
pageSize: maxPageSize,
|
|
8581
8819
|
authNamespace: application.authNamespace
|
|
8582
8820
|
});
|
|
8583
8821
|
return [machineUsers, nextPageToken];
|
|
@@ -8789,10 +9027,11 @@ async function listOAuth2Clients(options) {
|
|
|
8789
9027
|
applicationName: config.name
|
|
8790
9028
|
});
|
|
8791
9029
|
if (!application?.authNamespace) throw new Error(`Application ${config.name} does not have an auth configuration.`);
|
|
8792
|
-
return (await fetchAll(async (pageToken) => {
|
|
9030
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
8793
9031
|
const { oauth2Clients, nextPageToken } = await client.listAuthOAuth2Clients({
|
|
8794
9032
|
workspaceId,
|
|
8795
9033
|
pageToken,
|
|
9034
|
+
pageSize: maxPageSize,
|
|
8796
9035
|
namespaceName: application.authNamespace
|
|
8797
9036
|
});
|
|
8798
9037
|
return [oauth2Clients, nextPageToken];
|
|
@@ -9133,7 +9372,8 @@ function generateTableType(type, breakingChangeFields) {
|
|
|
9133
9372
|
function mapToTsType(fieldType) {
|
|
9134
9373
|
switch (fieldType) {
|
|
9135
9374
|
case "uuid":
|
|
9136
|
-
case "string":
|
|
9375
|
+
case "string":
|
|
9376
|
+
case "decimal": return {
|
|
9137
9377
|
type: "string",
|
|
9138
9378
|
usedTimestamp: false
|
|
9139
9379
|
};
|
|
@@ -9488,7 +9728,7 @@ async function generate(options) {
|
|
|
9488
9728
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
9489
9729
|
let pluginManager;
|
|
9490
9730
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
9491
|
-
const { defineApplication: defineApplication$1 } = await import("./application-
|
|
9731
|
+
const { defineApplication: defineApplication$1 } = await import("./application-nPS5veK6.mjs");
|
|
9492
9732
|
const application = defineApplication$1({
|
|
9493
9733
|
config,
|
|
9494
9734
|
pluginManager
|
|
@@ -9826,10 +10066,11 @@ async function listWorkflows(options) {
|
|
|
9826
10066
|
workspaceId: options?.workspaceId,
|
|
9827
10067
|
profile: options?.profile
|
|
9828
10068
|
});
|
|
9829
|
-
return (await fetchAll(async (pageToken) => {
|
|
10069
|
+
return (await fetchAll(async (pageToken, maxPageSize) => {
|
|
9830
10070
|
const { workflows, nextPageToken } = await client.listWorkflows({
|
|
9831
10071
|
workspaceId,
|
|
9832
|
-
pageToken
|
|
10072
|
+
pageToken,
|
|
10073
|
+
pageSize: maxPageSize
|
|
9833
10074
|
});
|
|
9834
10075
|
return [workflows, nextPageToken];
|
|
9835
10076
|
})).map(toWorkflowListInfo);
|
|
@@ -10700,4 +10941,4 @@ const updateCommand = defineCommand({
|
|
|
10700
10941
|
|
|
10701
10942
|
//#endregion
|
|
10702
10943
|
export { jobsCommand as $, generateCommand as A, getMigrationDirPath as At, getMachineUserToken as B, getNamespacesWithMigrations as Bt, resumeCommand as C, MIGRATE_FILE_NAME as Ct, truncate as D, createSnapshotFromLocalTypes as Dt, listWorkflows as E, compareSnapshots as Et, removeCommand$1 as F, loadDiff as Ft, generateCommand$1 as G, commonArgs as Gt, listCommand$5 as H, generateUserTypes as Ht, listCommand$4 as I, reconstructSnapshotFromMigrations as It, triggerCommand as J, jsonArgs as Jt, listWebhookExecutors as K, confirmationArgs as Kt, listOAuth2Clients as L, formatDiffSummary as Lt, show as M, getMigrationFiles as Mt, showCommand as N, getNextMigrationNumber as Nt, truncateCommand as O, formatMigrationNumber as Ot, remove as P, isValidMigrationNumber as Pt, getExecutorJob as Q, getCommand$1 as R, formatMigrationDiff as Rt, healthCommand as S, INITIAL_SCHEMA_NUMBER as St, listCommand$3 as T, compareLocalTypesWithSnapshot as Tt, listMachineUsers as U, apiCall as Ut, tokenCommand as V, trnPrefix as Vt, generate$1 as W, apiCommand as Wt, listCommand$6 as X, workspaceArgs as Xt, triggerExecutor as Y, withCommonArgs as Yt, listExecutors as Z, createCommand as _, MIGRATION_LABEL_KEY as _t, listCommand as a, getWorkflow as at, listCommand$2 as b, DB_TYPES_FILE_NAME as bt, inviteUser as c, listWorkflowExecutions as ct, listCommand$1 as d, getCommand$3 as dt, listExecutorJobs as et, listWorkspaces as f, getExecutor as ft, deleteWorkspace as g, waitForExecution$1 as gt, deleteCommand as h, executeScript as ht, removeUser as i, getCommand$2 as it, logBetaWarning as j, getMigrationFilePath as jt, generate as k, getLatestMigrationNumber as kt, restoreCommand as l, functionExecutionStatusToString as lt, getWorkspace as m, applyCommand as mt, updateUser as n, startCommand as nt, listUsers as o, executionsCommand as ot, getCommand as p, apply as pt, webhookCommand as q, deploymentArgs as qt, removeCommand as r, startWorkflow as rt, inviteCommand as s, getWorkflowExecution as st, updateCommand as t, watchExecutorJob as tt, restoreWorkspace as u, formatKeyValueTable as ut, createWorkspace as v, parseMigrationLabelNumber as vt, resumeWorkflow as w, SCHEMA_FILE_NAME as wt, getAppHealth as x, DIFF_FILE_NAME as xt, listApps as y, bundleMigrationScript as yt, getOAuth2Client as z, hasChanges as zt };
|
|
10703
|
-
//# sourceMappingURL=update-
|
|
10944
|
+
//# sourceMappingURL=update-Cr5c7h1r.mjs.map
|