@tailor-platform/sdk 1.29.0 → 1.30.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 +12 -0
- package/dist/{application-Clwpv84E.mjs → application-Bf8SUAtR.mjs} +89 -73
- package/dist/application-Bf8SUAtR.mjs.map +1 -0
- package/dist/{application-Dl1d7w-b.mjs → application-DAQVP9CS.mjs} +1 -1
- package/dist/cli/index.mjs +66 -35
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +208 -43
- package/dist/cli/lib.mjs +23 -25
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +4 -4
- package/dist/{env-BuMbIknz.d.mts → env-DiWYe80_.d.mts} +2 -2
- package/dist/{index-CbnLNm14.d.mts → index-2WQbf_LH.d.mts} +2 -2
- package/dist/{index-cD9sQLTh.d.mts → index-BU7Cd5I4.d.mts} +4 -4
- package/dist/{index-B0Lrzywd.d.mts → index-DCEMVfJA.d.mts} +2 -2
- package/dist/{index-D1AM_02Y.d.mts → index-HvMUWjvV.d.mts} +2 -2
- package/dist/{index-CyapgSFI.d.mts → index-rH_De6hM.d.mts} +2 -2
- package/dist/plugin/builtin/enum-constants/index.d.mts +1 -1
- package/dist/plugin/builtin/file-utils/index.d.mts +1 -1
- package/dist/plugin/builtin/kysely-type/index.d.mts +1 -1
- package/dist/plugin/builtin/seed/index.d.mts +1 -1
- package/dist/plugin/index.d.mts +2 -2
- package/dist/{plugin-D3a0-qe0.d.mts → plugin-C-UdAM8C.d.mts} +2 -2
- package/dist/{query-B1-hq2Hm.mjs → query-C3oQTLvb.mjs} +604 -108
- package/dist/query-C3oQTLvb.mjs.map +1 -0
- package/dist/schema-BePzTFBV.mjs.map +1 -1
- package/dist/utils/test/index.d.mts +2 -2
- package/dist/{workflow.generated-BsgIlrH-.d.mts → workflow.generated-C5wMcCjB.d.mts} +2 -2
- package/docs/cli/function.md +1 -1
- package/docs/cli/organization.md +426 -0
- package/docs/cli-reference.md +20 -2
- package/package.json +2 -2
- package/dist/application-Clwpv84E.mjs.map +0 -1
- package/dist/query-B1-hq2Hm.mjs.map +0 -1
|
@@ -2,7 +2,7 @@ import { t as db } from "./schema-BePzTFBV.mjs";
|
|
|
2
2
|
import { i as symbols, n as logger, r as styles, t as CIPromptError } from "./logger-CqezTedh.mjs";
|
|
3
3
|
import { A as AuthHookPoint, B as TenantProviderConfig_TenantProviderType, C as PipelineResolver_OperationType, D as ExecutorJobStatus, F as AuthSCIMAttribute_Mutability, G as FilterSchema, H as GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus, I as AuthSCIMAttribute_Type, J as Subgraph_ServiceType, K as PageDirection, L as AuthSCIMAttribute_Uniqueness, M as AuthInvokerSchema, N as AuthOAuth2Client_ClientType, O as ExecutorTargetType, P as AuthOAuth2Client_GrantType, R as AuthSCIMConfig_AuthorizationType, S as TailorDBType_PermitAction, T as FunctionExecution_Status, U as ConditionSchema, V as UserProfileProviderConfig_UserProfileProviderType, W as Condition_Operator, _ as TailorDBGQLPermission_Action, b as TailorDBType_Permission_Operator, d as platformBaseUrl, f as resolveStaticWebsiteUrls, g as WorkflowJobExecution_Status, h as WorkflowExecution_Status, i as fetchMachineUserToken, j as AuthIDPConfig_AuthType, k as ExecutorTriggerType, l as initOperatorClient, m as WorkspacePlatformUserRole, p as userAgent, q as ApplicationSchemaUpdateAttemptStatus, r as fetchAll, v as TailorDBGQLPermission_Operator, w as IdPLang, x as TailorDBType_Permission_Permit, y as TailorDBGQLPermission_Permit } from "./client-CZmQBXAY.mjs";
|
|
4
4
|
import { t as readPackageJson } from "./package-json-D3x2nBPB.mjs";
|
|
5
|
-
import { S as writePlatformConfig, _ as hashFile, a as loadConfig, b as loadWorkspaceId, d as TailorDBTypeSchema, f as stringifyFunction, g as getDistDir, h as createBundleCache, l as OAuth2ClientSchema, m as loadFilesWithIgnores, n as generatePluginFilesIfNeeded, p as tailorUserMap, r as loadApplication, s as createExecutorService, t as defineApplication, x as readPlatformConfig, y as loadAccessToken } from "./application-
|
|
5
|
+
import { S as writePlatformConfig, _ as hashFile, a as loadConfig, b as loadWorkspaceId, d as TailorDBTypeSchema, f as stringifyFunction, g as getDistDir, h as createBundleCache, l as OAuth2ClientSchema, m as loadFilesWithIgnores, n as generatePluginFilesIfNeeded, p as tailorUserMap, r as loadApplication, s as createExecutorService, t as defineApplication, x as readPlatformConfig, y as loadAccessToken } from "./application-Bf8SUAtR.mjs";
|
|
6
6
|
import { r as withSpan } from "./telemetry-BSUlYTs-.mjs";
|
|
7
7
|
import { arg, createDefineCommand, defineCommand, runCommand } from "politty";
|
|
8
8
|
import { z } from "zod";
|
|
@@ -180,6 +180,24 @@ const confirmationArgs = { yes: arg(z.boolean().default(false), {
|
|
|
180
180
|
alias: "y",
|
|
181
181
|
description: "Skip confirmation prompts"
|
|
182
182
|
}) };
|
|
183
|
+
/**
|
|
184
|
+
* Arguments for commands that require organization context
|
|
185
|
+
*/
|
|
186
|
+
const organizationArgs = { "organization-id": arg(z.string(), {
|
|
187
|
+
alias: "o",
|
|
188
|
+
description: "Organization ID",
|
|
189
|
+
env: "TAILOR_PLATFORM_ORGANIZATION_ID",
|
|
190
|
+
completion: { type: "none" }
|
|
191
|
+
}) };
|
|
192
|
+
/**
|
|
193
|
+
* Arguments for commands that require folder context
|
|
194
|
+
*/
|
|
195
|
+
const folderArgs = { "folder-id": arg(z.string(), {
|
|
196
|
+
alias: "f",
|
|
197
|
+
description: "Folder ID",
|
|
198
|
+
env: "TAILOR_PLATFORM_FOLDER_ID",
|
|
199
|
+
completion: { type: "none" }
|
|
200
|
+
}) };
|
|
183
201
|
let verboseMode = false;
|
|
184
202
|
/**
|
|
185
203
|
* Returns whether verbose mode is enabled.
|
|
@@ -351,28 +369,18 @@ function createCacheStore(config) {
|
|
|
351
369
|
const manifest = ensureManifestLoaded();
|
|
352
370
|
delete manifest.entries[key];
|
|
353
371
|
}
|
|
354
|
-
function
|
|
372
|
+
function storeBundleContent(cacheKey, content) {
|
|
355
373
|
const dir = bundlesDir();
|
|
356
374
|
fs$1.mkdirSync(dir, { recursive: true });
|
|
357
|
-
fs$1.
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (fs$1.existsSync(mapSource)) fs$1.copyFileSync(mapSource, cachedMapPath);
|
|
361
|
-
else fs$1.rmSync(cachedMapPath, { force: true });
|
|
362
|
-
}
|
|
363
|
-
function restoreBundleOutput(cacheKey, targetPath) {
|
|
364
|
-
const cached = bundlePath(cacheKey);
|
|
365
|
-
const targetDir = path.dirname(targetPath);
|
|
366
|
-
fs$1.mkdirSync(targetDir, { recursive: true });
|
|
375
|
+
fs$1.writeFileSync(bundlePath(cacheKey), content, "utf-8");
|
|
376
|
+
}
|
|
377
|
+
function restoreBundleContent(cacheKey) {
|
|
367
378
|
try {
|
|
368
|
-
fs$1.
|
|
379
|
+
return fs$1.readFileSync(bundlePath(cacheKey), "utf-8");
|
|
369
380
|
} catch (e) {
|
|
370
|
-
if (e.code === "ENOENT") return
|
|
381
|
+
if (e.code === "ENOENT") return void 0;
|
|
371
382
|
throw e;
|
|
372
383
|
}
|
|
373
|
-
const cachedMap = `${cached}.map`;
|
|
374
|
-
if (fs$1.existsSync(cachedMap)) fs$1.copyFileSync(cachedMap, `${targetPath}.map`);
|
|
375
|
-
return true;
|
|
376
384
|
}
|
|
377
385
|
function clean() {
|
|
378
386
|
fs$1.rmSync(config.cacheDir, {
|
|
@@ -388,8 +396,8 @@ function createCacheStore(config) {
|
|
|
388
396
|
getEntry,
|
|
389
397
|
setEntry,
|
|
390
398
|
deleteEntry,
|
|
391
|
-
|
|
392
|
-
|
|
399
|
+
storeBundleContent,
|
|
400
|
+
restoreBundleContent,
|
|
393
401
|
clean
|
|
394
402
|
};
|
|
395
403
|
}
|
|
@@ -405,9 +413,7 @@ function createCacheManager(options) {
|
|
|
405
413
|
if (!(options.enabled ?? true)) return {
|
|
406
414
|
enabled: false,
|
|
407
415
|
bundleCache: {
|
|
408
|
-
tryRestore() {
|
|
409
|
-
return false;
|
|
410
|
-
},
|
|
416
|
+
tryRestore() {},
|
|
411
417
|
save() {}
|
|
412
418
|
},
|
|
413
419
|
finalize() {}
|
|
@@ -1124,74 +1130,70 @@ function authHookFunctionName(authName, hookPoint) {
|
|
|
1124
1130
|
return `auth-hook--${authName}--${hookPoint}`;
|
|
1125
1131
|
}
|
|
1126
1132
|
/**
|
|
1127
|
-
* Collect all function entries from bundled scripts for all services.
|
|
1133
|
+
* Collect all function entries from in-memory bundled scripts for all services.
|
|
1128
1134
|
* @param application - Application definition
|
|
1129
1135
|
* @param workflowJobs - Collected workflow jobs from config
|
|
1136
|
+
* @param bundledScripts - In-memory bundled code organized by kind
|
|
1130
1137
|
* @returns Array of function entries to register
|
|
1131
1138
|
*/
|
|
1132
|
-
function collectFunctionEntries(application, workflowJobs) {
|
|
1139
|
+
function collectFunctionEntries(application, workflowJobs, bundledScripts) {
|
|
1133
1140
|
const entries = [];
|
|
1134
|
-
const distDir = getDistDir();
|
|
1135
1141
|
for (const app of application.applications) for (const pipeline of app.resolverServices) for (const resolver of Object.values(pipeline.resolvers)) {
|
|
1136
|
-
const
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
name: resolverFunctionName(pipeline.namespace, resolver.name),
|
|
1141
|
-
scriptContent: content,
|
|
1142
|
-
contentHash: computeContentHash(content),
|
|
1143
|
-
description: `Resolver: ${pipeline.namespace}/${resolver.name}`
|
|
1144
|
-
});
|
|
1145
|
-
} catch {
|
|
1146
|
-
logger.warn(`Function file not found: ${scriptPath}`);
|
|
1142
|
+
const content = bundledScripts.resolvers.get(resolver.name);
|
|
1143
|
+
if (!content) {
|
|
1144
|
+
logger.warn(`Bundled code not found for resolver: ${resolver.name}`);
|
|
1145
|
+
continue;
|
|
1147
1146
|
}
|
|
1147
|
+
entries.push({
|
|
1148
|
+
name: resolverFunctionName(pipeline.namespace, resolver.name),
|
|
1149
|
+
scriptContent: content,
|
|
1150
|
+
contentHash: computeContentHash(content),
|
|
1151
|
+
description: `Resolver: ${pipeline.namespace}/${resolver.name}`
|
|
1152
|
+
});
|
|
1148
1153
|
}
|
|
1149
1154
|
if (application.executorService) {
|
|
1150
1155
|
const executors = application.executorService.executors;
|
|
1151
1156
|
for (const executor of Object.values(executors)) if (executor.operation.kind === "function" || executor.operation.kind === "jobFunction") {
|
|
1152
|
-
const
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
name: executorFunctionName(executor.name),
|
|
1157
|
-
scriptContent: content,
|
|
1158
|
-
contentHash: computeContentHash(content),
|
|
1159
|
-
description: `Executor: ${executor.name}`
|
|
1160
|
-
});
|
|
1161
|
-
} catch {
|
|
1162
|
-
logger.warn(`Function file not found: ${scriptPath}`);
|
|
1157
|
+
const content = bundledScripts.executors.get(executor.name);
|
|
1158
|
+
if (!content) {
|
|
1159
|
+
logger.warn(`Bundled code not found for executor: ${executor.name}`);
|
|
1160
|
+
continue;
|
|
1163
1161
|
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
for (const job of workflowJobs) {
|
|
1167
|
-
const scriptPath = path.join(distDir, "workflow-jobs", `${job.name}.js`);
|
|
1168
|
-
try {
|
|
1169
|
-
const content = fs$1.readFileSync(scriptPath, "utf-8");
|
|
1170
1162
|
entries.push({
|
|
1171
|
-
name:
|
|
1163
|
+
name: executorFunctionName(executor.name),
|
|
1172
1164
|
scriptContent: content,
|
|
1173
1165
|
contentHash: computeContentHash(content),
|
|
1174
|
-
description: `
|
|
1166
|
+
description: `Executor: ${executor.name}`
|
|
1175
1167
|
});
|
|
1176
|
-
} catch {
|
|
1177
|
-
logger.warn(`Function file not found: ${scriptPath}`);
|
|
1178
1168
|
}
|
|
1179
1169
|
}
|
|
1170
|
+
for (const job of workflowJobs) {
|
|
1171
|
+
const content = bundledScripts.workflowJobs.get(job.name);
|
|
1172
|
+
if (!content) {
|
|
1173
|
+
logger.warn(`Bundled code not found for workflow job: ${job.name}`);
|
|
1174
|
+
continue;
|
|
1175
|
+
}
|
|
1176
|
+
entries.push({
|
|
1177
|
+
name: workflowJobFunctionName(job.name),
|
|
1178
|
+
scriptContent: content,
|
|
1179
|
+
contentHash: computeContentHash(content),
|
|
1180
|
+
description: `Workflow job: ${job.name}`
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1180
1183
|
for (const app of application.applications) if (app.authService?.config.hooks?.beforeLogin) {
|
|
1181
1184
|
const authName = app.authService.config.name;
|
|
1182
1185
|
const funcName = authHookFunctionName(authName, "before-login");
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
name: funcName,
|
|
1188
|
-
scriptContent: content,
|
|
1189
|
-
contentHash: computeContentHash(content),
|
|
1190
|
-
description: `Auth hook: ${authName}/before-login`
|
|
1191
|
-
});
|
|
1192
|
-
} catch {
|
|
1193
|
-
logger.warn(`Function file not found: ${scriptPath}`);
|
|
1186
|
+
const content = bundledScripts.authHooks.get(funcName);
|
|
1187
|
+
if (!content) {
|
|
1188
|
+
logger.warn(`Bundled code not found for auth hook: ${funcName}`);
|
|
1189
|
+
continue;
|
|
1194
1190
|
}
|
|
1191
|
+
entries.push({
|
|
1192
|
+
name: funcName,
|
|
1193
|
+
scriptContent: content,
|
|
1194
|
+
contentHash: computeContentHash(content),
|
|
1195
|
+
description: `Auth hook: ${authName}/before-login`
|
|
1196
|
+
});
|
|
1195
1197
|
}
|
|
1196
1198
|
return entries;
|
|
1197
1199
|
}
|
|
@@ -5048,7 +5050,6 @@ async function bundleMigrationScript(sourceFile, namespace, migrationNumber) {
|
|
|
5048
5050
|
const outputDir = path.resolve(getDistDir(), "migrations");
|
|
5049
5051
|
fs$1.mkdirSync(outputDir, { recursive: true });
|
|
5050
5052
|
const entryPath = path.join(outputDir, `migration_${namespace}_${migrationNumber}.entry.js`);
|
|
5051
|
-
const outputPath = path.join(outputDir, `migration_${namespace}_${migrationNumber}.js`);
|
|
5052
5053
|
const entryContent = ml`
|
|
5053
5054
|
import { main as _migrationMain } from "${path.resolve(sourceFile).replace(/\\/g, "/")}";
|
|
5054
5055
|
import { Kysely, TailordbDialect } from "@tailor-platform/sdk/kysely";
|
|
@@ -5075,30 +5076,29 @@ async function bundleMigrationScript(sourceFile, namespace, migrationNumber) {
|
|
|
5075
5076
|
} catch {
|
|
5076
5077
|
tsconfig = void 0;
|
|
5077
5078
|
}
|
|
5078
|
-
await rolldown.build(rolldown.defineConfig({
|
|
5079
|
-
input: entryPath,
|
|
5080
|
-
output: {
|
|
5081
|
-
file: outputPath,
|
|
5082
|
-
format: "esm",
|
|
5083
|
-
sourcemap: false,
|
|
5084
|
-
minify: false,
|
|
5085
|
-
codeSplitting: false,
|
|
5086
|
-
globals: { tailordb: "tailordb" }
|
|
5087
|
-
},
|
|
5088
|
-
external: ["tailordb"],
|
|
5089
|
-
resolve: { conditionNames: ["node", "import"] },
|
|
5090
|
-
tsconfig,
|
|
5091
|
-
treeshake: {
|
|
5092
|
-
moduleSideEffects: false,
|
|
5093
|
-
annotations: true,
|
|
5094
|
-
unknownGlobalSideEffects: false
|
|
5095
|
-
},
|
|
5096
|
-
logLevel: "silent"
|
|
5097
|
-
}));
|
|
5098
5079
|
return {
|
|
5099
5080
|
namespace,
|
|
5100
5081
|
migrationNumber,
|
|
5101
|
-
bundledCode:
|
|
5082
|
+
bundledCode: (await rolldown.build({
|
|
5083
|
+
input: entryPath,
|
|
5084
|
+
write: false,
|
|
5085
|
+
output: {
|
|
5086
|
+
format: "esm",
|
|
5087
|
+
sourcemap: false,
|
|
5088
|
+
minify: false,
|
|
5089
|
+
codeSplitting: false,
|
|
5090
|
+
globals: { tailordb: "tailordb" }
|
|
5091
|
+
},
|
|
5092
|
+
external: ["tailordb"],
|
|
5093
|
+
resolve: { conditionNames: ["node", "import"] },
|
|
5094
|
+
tsconfig,
|
|
5095
|
+
treeshake: {
|
|
5096
|
+
moduleSideEffects: false,
|
|
5097
|
+
annotations: true,
|
|
5098
|
+
unknownGlobalSideEffects: false
|
|
5099
|
+
},
|
|
5100
|
+
logLevel: "silent"
|
|
5101
|
+
})).output[0].code
|
|
5102
5102
|
};
|
|
5103
5103
|
}
|
|
5104
5104
|
|
|
@@ -6705,12 +6705,12 @@ async function planWorkflow(client, workspaceId, appName, workflows, mainJobDeps
|
|
|
6705
6705
|
/**
|
|
6706
6706
|
* Apply the configured application to the Tailor platform.
|
|
6707
6707
|
* @param options - Options for apply execution
|
|
6708
|
-
* @returns Promise that resolves when
|
|
6708
|
+
* @returns Promise that resolves to `{ bundledScripts }` when `buildOnly` is true, otherwise void
|
|
6709
6709
|
*/
|
|
6710
6710
|
async function apply(options) {
|
|
6711
6711
|
return withSpan("apply", async (rootSpan) => {
|
|
6712
6712
|
rootSpan.setAttribute("apply.dry_run", options?.dryRun ?? false);
|
|
6713
|
-
const { config, application, workflowBuildResult, buildOnly } = await withSpan("build", async () => {
|
|
6713
|
+
const { config, application, workflowBuildResult, bundledScripts, buildOnly } = await withSpan("build", async () => {
|
|
6714
6714
|
const { config, plugins } = await withSpan("build.loadConfig", () => loadConfig(options?.configPath));
|
|
6715
6715
|
const dryRun = options?.dryRun ?? false;
|
|
6716
6716
|
const buildOnly = options?.buildOnly ?? process.env.TAILOR_PLATFORM_SDK_BUILD_ONLY === "true";
|
|
@@ -6740,6 +6740,7 @@ async function apply(options) {
|
|
|
6740
6740
|
}));
|
|
6741
6741
|
let application;
|
|
6742
6742
|
let workflowBuildResult;
|
|
6743
|
+
let bundledScripts;
|
|
6743
6744
|
try {
|
|
6744
6745
|
const result = await withSpan("build.loadApplication", () => loadApplication({
|
|
6745
6746
|
config,
|
|
@@ -6748,6 +6749,7 @@ async function apply(options) {
|
|
|
6748
6749
|
}));
|
|
6749
6750
|
application = result.application;
|
|
6750
6751
|
workflowBuildResult = result.workflowBuildResult;
|
|
6752
|
+
bundledScripts = result.bundledScripts;
|
|
6751
6753
|
} finally {
|
|
6752
6754
|
cacheManager.finalize();
|
|
6753
6755
|
}
|
|
@@ -6756,11 +6758,12 @@ async function apply(options) {
|
|
|
6756
6758
|
plugins,
|
|
6757
6759
|
application,
|
|
6758
6760
|
workflowBuildResult,
|
|
6761
|
+
bundledScripts,
|
|
6759
6762
|
dryRun,
|
|
6760
6763
|
buildOnly
|
|
6761
6764
|
};
|
|
6762
6765
|
});
|
|
6763
|
-
if (buildOnly) return;
|
|
6766
|
+
if (buildOnly) return { bundledScripts };
|
|
6764
6767
|
const client = await initOperatorClient(await loadAccessToken({
|
|
6765
6768
|
useProfile: true,
|
|
6766
6769
|
profile: options?.profile
|
|
@@ -6772,7 +6775,7 @@ async function apply(options) {
|
|
|
6772
6775
|
rootSpan.setAttribute("app.name", application.name);
|
|
6773
6776
|
rootSpan.setAttribute("workspace.id", workspaceId);
|
|
6774
6777
|
const workflowService = application.workflowService;
|
|
6775
|
-
const functionEntries = collectFunctionEntries(application, workflowService?.jobs ?? []);
|
|
6778
|
+
const functionEntries = collectFunctionEntries(application, workflowService?.jobs ?? [], bundledScripts);
|
|
6776
6779
|
const dryRun = options?.dryRun ?? false;
|
|
6777
6780
|
const yes = options?.yes ?? false;
|
|
6778
6781
|
const { functionRegistry, tailorDB, staticWebsite, idp, auth, pipeline, app, executor, workflow, secretManager } = await withSpan("plan", async () => {
|
|
@@ -7215,7 +7218,7 @@ async function getExecutor(options) {
|
|
|
7215
7218
|
throw error;
|
|
7216
7219
|
}
|
|
7217
7220
|
}
|
|
7218
|
-
const getCommand$
|
|
7221
|
+
const getCommand$5 = defineAppCommand({
|
|
7219
7222
|
name: "get",
|
|
7220
7223
|
description: "Get executor details",
|
|
7221
7224
|
args: z.object({
|
|
@@ -7691,7 +7694,7 @@ async function getWorkflow(options) {
|
|
|
7691
7694
|
throw error;
|
|
7692
7695
|
}
|
|
7693
7696
|
}
|
|
7694
|
-
const getCommand$
|
|
7697
|
+
const getCommand$4 = defineAppCommand({
|
|
7695
7698
|
name: "get",
|
|
7696
7699
|
description: "Get workflow details.",
|
|
7697
7700
|
args: z.object({
|
|
@@ -8310,7 +8313,7 @@ async function listExecutors(options) {
|
|
|
8310
8313
|
return [executors, nextPageToken];
|
|
8311
8314
|
})).map((e) => toExecutorListInfo(e));
|
|
8312
8315
|
}
|
|
8313
|
-
const listCommand$
|
|
8316
|
+
const listCommand$8 = defineAppCommand({
|
|
8314
8317
|
name: "list",
|
|
8315
8318
|
description: "List all executors",
|
|
8316
8319
|
args: z.object({ ...workspaceArgs }).strict(),
|
|
@@ -9511,7 +9514,7 @@ async function listMachineUsers(options) {
|
|
|
9511
9514
|
return [machineUsers, nextPageToken];
|
|
9512
9515
|
})).map(machineUserInfo);
|
|
9513
9516
|
}
|
|
9514
|
-
const listCommand$
|
|
9517
|
+
const listCommand$7 = defineAppCommand({
|
|
9515
9518
|
name: "list",
|
|
9516
9519
|
description: "List all machine users in the application.",
|
|
9517
9520
|
args: z.object({ ...deploymentArgs }).strict(),
|
|
@@ -9666,7 +9669,7 @@ async function getOAuth2Client(options) {
|
|
|
9666
9669
|
throw error;
|
|
9667
9670
|
}
|
|
9668
9671
|
}
|
|
9669
|
-
const getCommand$
|
|
9672
|
+
const getCommand$3 = defineAppCommand({
|
|
9670
9673
|
name: "get",
|
|
9671
9674
|
description: "Get OAuth2 client credentials (including client secret).",
|
|
9672
9675
|
args: z.object({
|
|
@@ -9719,7 +9722,7 @@ async function listOAuth2Clients(options) {
|
|
|
9719
9722
|
return [oauth2Clients, nextPageToken];
|
|
9720
9723
|
})).map(toOAuth2ClientInfo);
|
|
9721
9724
|
}
|
|
9722
|
-
const listCommand$
|
|
9725
|
+
const listCommand$6 = defineAppCommand({
|
|
9723
9726
|
name: "list",
|
|
9724
9727
|
description: "List all OAuth2 clients in the application.",
|
|
9725
9728
|
args: z.object({ ...deploymentArgs }).strict(),
|
|
@@ -9733,6 +9736,501 @@ const listCommand$4 = defineAppCommand({
|
|
|
9733
9736
|
}
|
|
9734
9737
|
});
|
|
9735
9738
|
|
|
9739
|
+
//#endregion
|
|
9740
|
+
//#region src/cli/commands/organization/transform.ts
|
|
9741
|
+
const userOrganizationInfo = (org) => ({
|
|
9742
|
+
organizationId: org.organizationId,
|
|
9743
|
+
organizationName: org.organizationName,
|
|
9744
|
+
rootFolderId: org.rootFolderId,
|
|
9745
|
+
rootFolderName: org.rootFolderName,
|
|
9746
|
+
displayName: org.displayName
|
|
9747
|
+
});
|
|
9748
|
+
const organizationInfo = (org) => ({
|
|
9749
|
+
id: org.id,
|
|
9750
|
+
name: org.name,
|
|
9751
|
+
createdAt: formatTimestamp(org.createTime),
|
|
9752
|
+
updatedAt: formatTimestamp(org.updateTime)
|
|
9753
|
+
});
|
|
9754
|
+
const folderListInfo = (folder) => ({
|
|
9755
|
+
id: folder.id,
|
|
9756
|
+
name: folder.name,
|
|
9757
|
+
organizationId: folder.organizationId,
|
|
9758
|
+
parentFolderId: folder.parentFolderId,
|
|
9759
|
+
hasChildren: folder.hasChildren,
|
|
9760
|
+
createdAt: formatTimestamp(folder.createTime)
|
|
9761
|
+
});
|
|
9762
|
+
const folderInfo = (folder) => ({
|
|
9763
|
+
...folderListInfo(folder),
|
|
9764
|
+
updatedAt: formatTimestamp(folder.updateTime)
|
|
9765
|
+
});
|
|
9766
|
+
|
|
9767
|
+
//#endregion
|
|
9768
|
+
//#region src/cli/commands/organization/folder/create.ts
|
|
9769
|
+
const createFolderOptionsSchema = z.object({
|
|
9770
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
9771
|
+
parentFolderId: z.string().optional(),
|
|
9772
|
+
name: z.string().min(1, "Name must not be empty")
|
|
9773
|
+
});
|
|
9774
|
+
/**
|
|
9775
|
+
* Create a new folder in an organization.
|
|
9776
|
+
* @param options - Folder creation options
|
|
9777
|
+
* @returns Created folder details
|
|
9778
|
+
*/
|
|
9779
|
+
async function createFolder(options) {
|
|
9780
|
+
const result = createFolderOptionsSchema.safeParse(options);
|
|
9781
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
9782
|
+
const response = await (await initOperatorClient(await loadAccessToken())).createOrganizationFolder({
|
|
9783
|
+
organizationId: result.data.organizationId,
|
|
9784
|
+
parentFolderId: result.data.parentFolderId ?? "",
|
|
9785
|
+
folderName: result.data.name
|
|
9786
|
+
});
|
|
9787
|
+
if (!response.folder) throw new Error("Failed to create folder.");
|
|
9788
|
+
return folderInfo(response.folder);
|
|
9789
|
+
}
|
|
9790
|
+
const createCommand$1 = defineAppCommand({
|
|
9791
|
+
name: "create",
|
|
9792
|
+
description: "Create a new folder in an organization.",
|
|
9793
|
+
args: z.object({
|
|
9794
|
+
...organizationArgs,
|
|
9795
|
+
"parent-folder-id": arg(z.string().optional(), { description: "Parent folder ID" }),
|
|
9796
|
+
name: arg(z.string(), {
|
|
9797
|
+
alias: "n",
|
|
9798
|
+
description: "Folder name"
|
|
9799
|
+
})
|
|
9800
|
+
}).strict(),
|
|
9801
|
+
run: async (args) => {
|
|
9802
|
+
const folder = await createFolder({
|
|
9803
|
+
organizationId: args["organization-id"],
|
|
9804
|
+
parentFolderId: args["parent-folder-id"],
|
|
9805
|
+
name: args.name
|
|
9806
|
+
});
|
|
9807
|
+
if (!args.json) logger.success(`Folder "${folder.name}" created successfully.`);
|
|
9808
|
+
logger.out(folder);
|
|
9809
|
+
}
|
|
9810
|
+
});
|
|
9811
|
+
|
|
9812
|
+
//#endregion
|
|
9813
|
+
//#region src/cli/commands/organization/folder/delete.ts
|
|
9814
|
+
const deleteFolderOptionsSchema = z.object({
|
|
9815
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
9816
|
+
folderId: z.uuid({ message: "folder-id must be a valid UUID" })
|
|
9817
|
+
});
|
|
9818
|
+
/**
|
|
9819
|
+
* Delete a folder from an organization.
|
|
9820
|
+
* @param options - Folder deletion options
|
|
9821
|
+
* @returns Promise that resolves when deletion completes
|
|
9822
|
+
*/
|
|
9823
|
+
async function deleteFolder(options) {
|
|
9824
|
+
const result = deleteFolderOptionsSchema.safeParse(options);
|
|
9825
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
9826
|
+
await (await initOperatorClient(await loadAccessToken())).deleteOrganizationFolder({
|
|
9827
|
+
organizationId: result.data.organizationId,
|
|
9828
|
+
folderId: result.data.folderId
|
|
9829
|
+
});
|
|
9830
|
+
}
|
|
9831
|
+
const deleteCommand$1 = defineAppCommand({
|
|
9832
|
+
name: "delete",
|
|
9833
|
+
description: "Delete a folder from an organization.",
|
|
9834
|
+
args: z.object({
|
|
9835
|
+
...organizationArgs,
|
|
9836
|
+
...folderArgs,
|
|
9837
|
+
...confirmationArgs
|
|
9838
|
+
}).strict(),
|
|
9839
|
+
run: async (args) => {
|
|
9840
|
+
const client = await initOperatorClient(await loadAccessToken());
|
|
9841
|
+
let folderName;
|
|
9842
|
+
try {
|
|
9843
|
+
folderName = (await client.getOrganizationFolder({
|
|
9844
|
+
organizationId: args["organization-id"],
|
|
9845
|
+
folderId: args["folder-id"]
|
|
9846
|
+
})).folder?.name;
|
|
9847
|
+
} catch {
|
|
9848
|
+
throw new Error(`Folder "${args["folder-id"]}" not found.`);
|
|
9849
|
+
}
|
|
9850
|
+
if (!args.yes) {
|
|
9851
|
+
if (!await prompt.confirm({ message: `Are you sure you want to delete folder "${folderName}"?` })) {
|
|
9852
|
+
logger.info("Folder deletion cancelled.");
|
|
9853
|
+
return;
|
|
9854
|
+
}
|
|
9855
|
+
}
|
|
9856
|
+
await client.deleteOrganizationFolder({
|
|
9857
|
+
organizationId: args["organization-id"],
|
|
9858
|
+
folderId: args["folder-id"]
|
|
9859
|
+
});
|
|
9860
|
+
logger.success(`Folder "${folderName}" deleted successfully.`);
|
|
9861
|
+
}
|
|
9862
|
+
});
|
|
9863
|
+
|
|
9864
|
+
//#endregion
|
|
9865
|
+
//#region src/cli/commands/organization/folder/get.ts
|
|
9866
|
+
const getFolderOptionsSchema = z.object({
|
|
9867
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
9868
|
+
folderId: z.uuid({ message: "folder-id must be a valid UUID" })
|
|
9869
|
+
});
|
|
9870
|
+
/**
|
|
9871
|
+
* Get detailed information about a folder.
|
|
9872
|
+
* @param options - Folder get options
|
|
9873
|
+
* @returns Folder details
|
|
9874
|
+
*/
|
|
9875
|
+
async function getFolder(options) {
|
|
9876
|
+
const result = getFolderOptionsSchema.safeParse(options);
|
|
9877
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
9878
|
+
const response = await (await initOperatorClient(await loadAccessToken())).getOrganizationFolder({
|
|
9879
|
+
organizationId: result.data.organizationId,
|
|
9880
|
+
folderId: result.data.folderId
|
|
9881
|
+
});
|
|
9882
|
+
if (!response.folder) throw new Error(`Folder "${result.data.folderId}" not found.`);
|
|
9883
|
+
return folderInfo(response.folder);
|
|
9884
|
+
}
|
|
9885
|
+
const getCommand$2 = defineAppCommand({
|
|
9886
|
+
name: "get",
|
|
9887
|
+
description: "Show detailed information about a folder.",
|
|
9888
|
+
args: z.object({
|
|
9889
|
+
...organizationArgs,
|
|
9890
|
+
...folderArgs
|
|
9891
|
+
}).strict(),
|
|
9892
|
+
run: async (args) => {
|
|
9893
|
+
const folder = await getFolder({
|
|
9894
|
+
organizationId: args["organization-id"],
|
|
9895
|
+
folderId: args["folder-id"]
|
|
9896
|
+
});
|
|
9897
|
+
const formattedFolder = args.json ? folder : {
|
|
9898
|
+
...folder,
|
|
9899
|
+
createdAt: humanizeRelativeTime(folder.createdAt),
|
|
9900
|
+
updatedAt: humanizeRelativeTime(folder.updatedAt)
|
|
9901
|
+
};
|
|
9902
|
+
logger.out(formattedFolder);
|
|
9903
|
+
}
|
|
9904
|
+
});
|
|
9905
|
+
|
|
9906
|
+
//#endregion
|
|
9907
|
+
//#region src/cli/commands/organization/folder/list.ts
|
|
9908
|
+
const listFoldersOptionsSchema = z.object({
|
|
9909
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
9910
|
+
parentFolderId: z.string().optional(),
|
|
9911
|
+
limit: z.number().int().positive().optional()
|
|
9912
|
+
});
|
|
9913
|
+
/**
|
|
9914
|
+
* List folders in an organization.
|
|
9915
|
+
* @param options - Folder listing options
|
|
9916
|
+
* @returns List of folders
|
|
9917
|
+
*/
|
|
9918
|
+
async function listFolders(options) {
|
|
9919
|
+
const result = listFoldersOptionsSchema.safeParse(options);
|
|
9920
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
9921
|
+
const { organizationId, parentFolderId, limit } = result.data;
|
|
9922
|
+
const hasLimit = limit !== void 0;
|
|
9923
|
+
const client = await initOperatorClient(await loadAccessToken());
|
|
9924
|
+
const results = [];
|
|
9925
|
+
let pageToken = "";
|
|
9926
|
+
while (true) {
|
|
9927
|
+
if (hasLimit && results.length >= limit) break;
|
|
9928
|
+
const remaining = hasLimit ? limit - results.length : void 0;
|
|
9929
|
+
const pageSize = remaining !== void 0 && remaining > 0 ? remaining : void 0;
|
|
9930
|
+
const response = await client.listOrganizationFolders({
|
|
9931
|
+
organizationId,
|
|
9932
|
+
...parentFolderId ? { parentFolderId } : {},
|
|
9933
|
+
pageToken,
|
|
9934
|
+
...pageSize !== void 0 ? { pageSize } : {}
|
|
9935
|
+
});
|
|
9936
|
+
const mapped = response.folders.map(folderListInfo);
|
|
9937
|
+
if (remaining !== void 0 && mapped.length > remaining) results.push(...mapped.slice(0, remaining));
|
|
9938
|
+
else results.push(...mapped);
|
|
9939
|
+
if (!response.nextPageToken) break;
|
|
9940
|
+
pageToken = response.nextPageToken;
|
|
9941
|
+
}
|
|
9942
|
+
return results;
|
|
9943
|
+
}
|
|
9944
|
+
const listCommand$5 = defineAppCommand({
|
|
9945
|
+
name: "list",
|
|
9946
|
+
description: "List folders in an organization.",
|
|
9947
|
+
args: z.object({
|
|
9948
|
+
...organizationArgs,
|
|
9949
|
+
"parent-folder-id": arg(z.string().optional(), { description: "Parent folder ID to list children of" }),
|
|
9950
|
+
limit: arg(positiveIntArg.optional(), {
|
|
9951
|
+
alias: "l",
|
|
9952
|
+
description: "Maximum number of folders to list"
|
|
9953
|
+
})
|
|
9954
|
+
}).strict(),
|
|
9955
|
+
run: async (args) => {
|
|
9956
|
+
const folders = await listFolders({
|
|
9957
|
+
organizationId: args["organization-id"],
|
|
9958
|
+
parentFolderId: args["parent-folder-id"],
|
|
9959
|
+
limit: args.limit
|
|
9960
|
+
});
|
|
9961
|
+
logger.out(folders, { display: { updatedAt: null } });
|
|
9962
|
+
}
|
|
9963
|
+
});
|
|
9964
|
+
|
|
9965
|
+
//#endregion
|
|
9966
|
+
//#region src/cli/commands/organization/folder/update.ts
|
|
9967
|
+
const updateFolderOptionsSchema = z.object({
|
|
9968
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
9969
|
+
folderId: z.uuid({ message: "folder-id must be a valid UUID" }),
|
|
9970
|
+
name: z.string().min(1, "Name must not be empty")
|
|
9971
|
+
});
|
|
9972
|
+
/**
|
|
9973
|
+
* Update a folder's name.
|
|
9974
|
+
* @param options - Folder update options
|
|
9975
|
+
* @returns Updated folder details
|
|
9976
|
+
*/
|
|
9977
|
+
async function updateFolder(options) {
|
|
9978
|
+
const result = updateFolderOptionsSchema.safeParse(options);
|
|
9979
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
9980
|
+
const response = await (await initOperatorClient(await loadAccessToken())).updateOrganizationFolder({
|
|
9981
|
+
organizationId: result.data.organizationId,
|
|
9982
|
+
folderId: result.data.folderId,
|
|
9983
|
+
folderName: result.data.name
|
|
9984
|
+
});
|
|
9985
|
+
if (!response.folder) throw new Error(`Failed to update folder "${result.data.folderId}".`);
|
|
9986
|
+
return folderInfo(response.folder);
|
|
9987
|
+
}
|
|
9988
|
+
const updateCommand$2 = defineAppCommand({
|
|
9989
|
+
name: "update",
|
|
9990
|
+
description: "Update a folder's name.",
|
|
9991
|
+
args: z.object({
|
|
9992
|
+
...organizationArgs,
|
|
9993
|
+
...folderArgs,
|
|
9994
|
+
name: arg(z.string(), {
|
|
9995
|
+
alias: "n",
|
|
9996
|
+
description: "New folder name"
|
|
9997
|
+
})
|
|
9998
|
+
}).strict(),
|
|
9999
|
+
run: async (args) => {
|
|
10000
|
+
const folder = await updateFolder({
|
|
10001
|
+
organizationId: args["organization-id"],
|
|
10002
|
+
folderId: args["folder-id"],
|
|
10003
|
+
name: args.name
|
|
10004
|
+
});
|
|
10005
|
+
if (!args.json) logger.success(`Folder "${folder.name}" updated successfully.`);
|
|
10006
|
+
logger.out(folder);
|
|
10007
|
+
}
|
|
10008
|
+
});
|
|
10009
|
+
|
|
10010
|
+
//#endregion
|
|
10011
|
+
//#region src/cli/commands/organization/get.ts
|
|
10012
|
+
const getOrganizationOptionsSchema = z.object({ organizationId: z.uuid({ message: "organization-id must be a valid UUID" }) });
|
|
10013
|
+
/**
|
|
10014
|
+
* Get detailed information about an organization.
|
|
10015
|
+
* @param options - Organization get options
|
|
10016
|
+
* @returns Organization details
|
|
10017
|
+
*/
|
|
10018
|
+
async function getOrganization(options) {
|
|
10019
|
+
const result = getOrganizationOptionsSchema.safeParse(options);
|
|
10020
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
10021
|
+
const response = await (await initOperatorClient(await loadAccessToken())).getOrganization({ organizationId: result.data.organizationId });
|
|
10022
|
+
if (!response.organization) throw new Error(`Organization "${result.data.organizationId}" not found.`);
|
|
10023
|
+
return organizationInfo(response.organization);
|
|
10024
|
+
}
|
|
10025
|
+
const getCommand$1 = defineAppCommand({
|
|
10026
|
+
name: "get",
|
|
10027
|
+
description: "Show detailed information about an organization.",
|
|
10028
|
+
args: z.object({ ...organizationArgs }).strict(),
|
|
10029
|
+
run: async (args) => {
|
|
10030
|
+
const organization = await getOrganization({ organizationId: args["organization-id"] });
|
|
10031
|
+
const formattedOrganization = args.json ? organization : {
|
|
10032
|
+
...organization,
|
|
10033
|
+
createdAt: humanizeRelativeTime(organization.createdAt),
|
|
10034
|
+
updatedAt: humanizeRelativeTime(organization.updatedAt)
|
|
10035
|
+
};
|
|
10036
|
+
logger.out(formattedOrganization);
|
|
10037
|
+
}
|
|
10038
|
+
});
|
|
10039
|
+
|
|
10040
|
+
//#endregion
|
|
10041
|
+
//#region src/cli/commands/organization/list.ts
|
|
10042
|
+
/**
|
|
10043
|
+
* List organizations the current user belongs to.
|
|
10044
|
+
* @param options - Organization listing options
|
|
10045
|
+
* @returns List of user organizations
|
|
10046
|
+
*/
|
|
10047
|
+
async function listOrganizations(options) {
|
|
10048
|
+
const limit = options?.limit;
|
|
10049
|
+
const { userOrganizations } = await (await initOperatorClient(await loadAccessToken())).listUserOrganizations({});
|
|
10050
|
+
const results = userOrganizations.map(userOrganizationInfo);
|
|
10051
|
+
if (limit !== void 0) return results.slice(0, limit);
|
|
10052
|
+
return results;
|
|
10053
|
+
}
|
|
10054
|
+
const listCommand$4 = defineAppCommand({
|
|
10055
|
+
name: "list",
|
|
10056
|
+
description: "List organizations you belong to.",
|
|
10057
|
+
args: z.object({ limit: arg(positiveIntArg.optional(), {
|
|
10058
|
+
alias: "l",
|
|
10059
|
+
description: "Maximum number of organizations to list"
|
|
10060
|
+
}) }).strict(),
|
|
10061
|
+
run: async (args) => {
|
|
10062
|
+
const organizations = await listOrganizations({ limit: args.limit });
|
|
10063
|
+
logger.out(organizations);
|
|
10064
|
+
}
|
|
10065
|
+
});
|
|
10066
|
+
|
|
10067
|
+
//#endregion
|
|
10068
|
+
//#region src/cli/commands/organization/tree.ts
|
|
10069
|
+
async function fetchChildFolders(client, organizationId, parentFolderId, currentDepth, maxDepth) {
|
|
10070
|
+
if (maxDepth !== void 0 && currentDepth >= maxDepth) return [];
|
|
10071
|
+
const folders = await fetchAll(async (pageToken, maxPageSize) => {
|
|
10072
|
+
const response = await client.listOrganizationFolders({
|
|
10073
|
+
organizationId,
|
|
10074
|
+
parentFolderId,
|
|
10075
|
+
pageToken,
|
|
10076
|
+
pageSize: maxPageSize
|
|
10077
|
+
});
|
|
10078
|
+
return [response.folders, response.nextPageToken];
|
|
10079
|
+
});
|
|
10080
|
+
const nodes = [];
|
|
10081
|
+
for (const folder of folders) {
|
|
10082
|
+
const children = folder.hasChildren ? await fetchChildFolders(client, organizationId, folder.id, currentDepth + 1, maxDepth) : [];
|
|
10083
|
+
nodes.push({
|
|
10084
|
+
name: folder.name,
|
|
10085
|
+
children
|
|
10086
|
+
});
|
|
10087
|
+
}
|
|
10088
|
+
return nodes;
|
|
10089
|
+
}
|
|
10090
|
+
async function buildFolderTreeJson(client, organizationId, parentFolderId, currentDepth, maxDepth) {
|
|
10091
|
+
if (maxDepth !== void 0 && currentDepth >= maxDepth) return [];
|
|
10092
|
+
const folders = await fetchAll(async (pageToken, maxPageSize) => {
|
|
10093
|
+
const response = await client.listOrganizationFolders({
|
|
10094
|
+
organizationId,
|
|
10095
|
+
parentFolderId,
|
|
10096
|
+
pageToken,
|
|
10097
|
+
pageSize: maxPageSize
|
|
10098
|
+
});
|
|
10099
|
+
return [response.folders, response.nextPageToken];
|
|
10100
|
+
});
|
|
10101
|
+
const result = [];
|
|
10102
|
+
for (const folder of folders) {
|
|
10103
|
+
const children = folder.hasChildren ? await buildFolderTreeJson(client, organizationId, folder.id, currentDepth + 1, maxDepth) : [];
|
|
10104
|
+
result.push({
|
|
10105
|
+
id: folder.id,
|
|
10106
|
+
name: folder.name,
|
|
10107
|
+
children
|
|
10108
|
+
});
|
|
10109
|
+
}
|
|
10110
|
+
return result;
|
|
10111
|
+
}
|
|
10112
|
+
function renderTree(nodes, prefix) {
|
|
10113
|
+
let output = "";
|
|
10114
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
10115
|
+
const isLast = i === nodes.length - 1;
|
|
10116
|
+
const connector = isLast ? "└── " : "├── ";
|
|
10117
|
+
const childPrefix = isLast ? " " : "│ ";
|
|
10118
|
+
output += `${prefix}${connector}${nodes[i].name}\n`;
|
|
10119
|
+
if (nodes[i].children.length > 0) output += renderTree(nodes[i].children, prefix + childPrefix);
|
|
10120
|
+
}
|
|
10121
|
+
return output;
|
|
10122
|
+
}
|
|
10123
|
+
async function buildOrgTree(client, org, depth) {
|
|
10124
|
+
const children = await fetchChildFolders(client, org.organizationId, org.rootFolderId, 0, depth);
|
|
10125
|
+
let output = `${org.organizationName}\n`;
|
|
10126
|
+
output += renderTree(children, "");
|
|
10127
|
+
return output;
|
|
10128
|
+
}
|
|
10129
|
+
/**
|
|
10130
|
+
* Display a tree view of organizations and their folder hierarchy.
|
|
10131
|
+
* @param options - Tree display options
|
|
10132
|
+
* @returns Organization tree as structured data
|
|
10133
|
+
*/
|
|
10134
|
+
async function organizationTree(options) {
|
|
10135
|
+
const client = await initOperatorClient(await loadAccessToken());
|
|
10136
|
+
let orgs;
|
|
10137
|
+
if (options?.organizationId) {
|
|
10138
|
+
orgs = (await listOrganizations()).filter((o) => o.organizationId === options.organizationId);
|
|
10139
|
+
if (orgs.length === 0) throw new Error(`Organization "${options.organizationId}" not found.`);
|
|
10140
|
+
} else orgs = await listOrganizations();
|
|
10141
|
+
const depth = options?.depth;
|
|
10142
|
+
const jsonResult = [];
|
|
10143
|
+
for (const org of orgs) {
|
|
10144
|
+
const folders = await buildFolderTreeJson(client, org.organizationId, org.rootFolderId, 0, depth);
|
|
10145
|
+
jsonResult.push({
|
|
10146
|
+
organizationId: org.organizationId,
|
|
10147
|
+
organizationName: org.organizationName,
|
|
10148
|
+
folders
|
|
10149
|
+
});
|
|
10150
|
+
}
|
|
10151
|
+
return jsonResult;
|
|
10152
|
+
}
|
|
10153
|
+
const treeCommand = defineAppCommand({
|
|
10154
|
+
name: "tree",
|
|
10155
|
+
description: "Display organization folder hierarchy as a tree.",
|
|
10156
|
+
args: z.object({
|
|
10157
|
+
"organization-id": arg(z.string().optional(), {
|
|
10158
|
+
alias: "o",
|
|
10159
|
+
description: "Organization ID (show all if omitted)",
|
|
10160
|
+
env: "TAILOR_PLATFORM_ORGANIZATION_ID"
|
|
10161
|
+
}),
|
|
10162
|
+
depth: arg(positiveIntArg.optional(), {
|
|
10163
|
+
alias: "d",
|
|
10164
|
+
description: "Maximum folder depth to display"
|
|
10165
|
+
})
|
|
10166
|
+
}).strict(),
|
|
10167
|
+
run: async (args) => {
|
|
10168
|
+
const client = await initOperatorClient(await loadAccessToken());
|
|
10169
|
+
let orgs;
|
|
10170
|
+
if (args["organization-id"]) {
|
|
10171
|
+
orgs = (await listOrganizations()).filter((o) => o.organizationId === args["organization-id"]);
|
|
10172
|
+
if (orgs.length === 0) throw new Error(`Organization "${args["organization-id"]}" not found.`);
|
|
10173
|
+
} else orgs = await listOrganizations();
|
|
10174
|
+
if (args.json) {
|
|
10175
|
+
const jsonResult = [];
|
|
10176
|
+
for (const org of orgs) {
|
|
10177
|
+
const folders = await buildFolderTreeJson(client, org.organizationId, org.rootFolderId, 0, args.depth);
|
|
10178
|
+
jsonResult.push({
|
|
10179
|
+
organizationId: org.organizationId,
|
|
10180
|
+
organizationName: org.organizationName,
|
|
10181
|
+
folders
|
|
10182
|
+
});
|
|
10183
|
+
}
|
|
10184
|
+
logger.out(jsonResult);
|
|
10185
|
+
return;
|
|
10186
|
+
}
|
|
10187
|
+
const trees = [];
|
|
10188
|
+
for (const org of orgs) trees.push(await buildOrgTree(client, org, args.depth));
|
|
10189
|
+
logger.log(trees.join("\n"));
|
|
10190
|
+
}
|
|
10191
|
+
});
|
|
10192
|
+
|
|
10193
|
+
//#endregion
|
|
10194
|
+
//#region src/cli/commands/organization/update.ts
|
|
10195
|
+
const updateOrganizationOptionsSchema = z.object({
|
|
10196
|
+
organizationId: z.uuid({ message: "organization-id must be a valid UUID" }),
|
|
10197
|
+
name: z.string().min(1, "Name must not be empty")
|
|
10198
|
+
});
|
|
10199
|
+
/**
|
|
10200
|
+
* Update an organization's name.
|
|
10201
|
+
* @param options - Organization update options
|
|
10202
|
+
* @returns Updated organization details
|
|
10203
|
+
*/
|
|
10204
|
+
async function updateOrganization(options) {
|
|
10205
|
+
const result = updateOrganizationOptionsSchema.safeParse(options);
|
|
10206
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
10207
|
+
const response = await (await initOperatorClient(await loadAccessToken())).updateOrganization({
|
|
10208
|
+
organizationId: result.data.organizationId,
|
|
10209
|
+
organizationName: result.data.name
|
|
10210
|
+
});
|
|
10211
|
+
if (!response.organization) throw new Error(`Failed to update organization "${result.data.organizationId}".`);
|
|
10212
|
+
return organizationInfo(response.organization);
|
|
10213
|
+
}
|
|
10214
|
+
const updateCommand$1 = defineAppCommand({
|
|
10215
|
+
name: "update",
|
|
10216
|
+
description: "Update an organization's name.",
|
|
10217
|
+
args: z.object({
|
|
10218
|
+
...organizationArgs,
|
|
10219
|
+
name: arg(z.string(), {
|
|
10220
|
+
alias: "n",
|
|
10221
|
+
description: "New organization name"
|
|
10222
|
+
})
|
|
10223
|
+
}).strict(),
|
|
10224
|
+
run: async (args) => {
|
|
10225
|
+
const organization = await updateOrganization({
|
|
10226
|
+
organizationId: args["organization-id"],
|
|
10227
|
+
name: args.name
|
|
10228
|
+
});
|
|
10229
|
+
if (!args.json) logger.success(`Organization "${organization.name}" updated successfully.`);
|
|
10230
|
+
logger.out(organization);
|
|
10231
|
+
}
|
|
10232
|
+
});
|
|
10233
|
+
|
|
9736
10234
|
//#endregion
|
|
9737
10235
|
//#region src/cli/commands/remove.ts
|
|
9738
10236
|
async function loadOptions$10(options) {
|
|
@@ -10467,7 +10965,7 @@ async function generate(options) {
|
|
|
10467
10965
|
if (options.init) await handleInitOption(namespacesWithMigrations, options.yes);
|
|
10468
10966
|
let pluginManager;
|
|
10469
10967
|
if (plugins.length > 0) pluginManager = new PluginManager(plugins);
|
|
10470
|
-
const { defineApplication } = await import("./application-
|
|
10968
|
+
const { defineApplication } = await import("./application-DAQVP9CS.mjs");
|
|
10471
10969
|
const application = defineApplication({
|
|
10472
10970
|
config,
|
|
10473
10971
|
pluginManager
|
|
@@ -11751,7 +12249,6 @@ async function bundleQueryScript(engine) {
|
|
|
11751
12249
|
const outputDir = path.resolve(getDistDir(), "query");
|
|
11752
12250
|
fs$1.mkdirSync(outputDir, { recursive: true });
|
|
11753
12251
|
const entryPath = path.join(outputDir, `query_${engine}.entry.ts`);
|
|
11754
|
-
const outputPath = path.join(outputDir, `query_${engine}.js`);
|
|
11755
12252
|
const entryContent = engine === "sql" ? createSqlEntry() : createGqlEntry();
|
|
11756
12253
|
fs$1.writeFileSync(entryPath, entryContent);
|
|
11757
12254
|
let tsconfig;
|
|
@@ -11760,10 +12257,10 @@ async function bundleQueryScript(engine) {
|
|
|
11760
12257
|
} catch {
|
|
11761
12258
|
tsconfig = void 0;
|
|
11762
12259
|
}
|
|
11763
|
-
await rolldown.build(
|
|
12260
|
+
return (await rolldown.build({
|
|
11764
12261
|
input: entryPath,
|
|
12262
|
+
write: false,
|
|
11765
12263
|
output: {
|
|
11766
|
-
file: outputPath,
|
|
11767
12264
|
format: "esm",
|
|
11768
12265
|
sourcemap: false,
|
|
11769
12266
|
minify: false,
|
|
@@ -11779,8 +12276,7 @@ async function bundleQueryScript(engine) {
|
|
|
11779
12276
|
unknownGlobalSideEffects: false
|
|
11780
12277
|
},
|
|
11781
12278
|
logLevel: "silent"
|
|
11782
|
-
}));
|
|
11783
|
-
return fs$1.readFileSync(outputPath, "utf-8");
|
|
12279
|
+
})).output[0].code;
|
|
11784
12280
|
}
|
|
11785
12281
|
|
|
11786
12282
|
//#endregion
|
|
@@ -12645,5 +13141,5 @@ function printGqlResult(result, options = {}) {
|
|
|
12645
13141
|
}
|
|
12646
13142
|
|
|
12647
13143
|
//#endregion
|
|
12648
|
-
export {
|
|
12649
|
-
//# sourceMappingURL=query-
|
|
13144
|
+
export { deleteCommand$1 as $, isValidMigrationNumber as $t, truncate as A, formatKeyValueTable as At, updateOrganization as B, DIFF_FILE_NAME as Bt, listCommand$2 as C, startWorkflow as Ct, resumeWorkflow as D, getWorkflowExecution as Dt, resumeCommand as E, executionsCommand as Et, showCommand as F, waitForExecution$1 as Ft, getCommand$1 as G, compareSnapshots as Gt, treeCommand as H, MIGRATE_FILE_NAME as Ht, logBetaWarning as I, MIGRATION_LABEL_KEY as It, updateFolder as J, getLatestMigrationNumber as Jt, getOrganization as K, createSnapshotFromLocalTypes as Kt, remove as L, parseMigrationLabelNumber as Lt, generate as M, getExecutor as Mt, generateCommand as N, apply as Nt, listCommand$3 as O, listWorkflowExecutions as Ot, show as P, executeScript as Pt, getFolder as Q, getNextMigrationNumber as Qt, removeCommand$1 as R, bundleMigrationScript as Rt, listApps as S, startCommand as St, healthCommand as T, getWorkflow as Tt, listCommand$4 as U, SCHEMA_FILE_NAME as Ut, organizationTree as V, INITIAL_SCHEMA_NUMBER as Vt, listOrganizations as W, compareLocalTypesWithSnapshot as Wt, listFolders as X, getMigrationFilePath as Xt, listCommand$5 as Y, getMigrationDirPath as Yt, getCommand$2 as Z, getMigrationFiles as Zt, getWorkspace as _, workspaceArgs as _n, listExecutors as _t, updateUser as a, getNamespacesWithMigrations as an, getCommand$3 as at, createCommand as b, listExecutorJobs as bt, listCommand as c, trnPrefix as cn, tokenCommand as ct, inviteUser as d, apiCommand as dn, generate$1 as dt, loadDiff as en, deleteFolder as et, restoreCommand as f, defineAppCommand as fn, listWebhookExecutors as ft, getCommand as g, isVerbose as gn, listCommand$8 as gt, listWorkspaces as h, deploymentArgs as hn, triggerExecutor as ht, updateCommand as i, hasChanges as in, listOAuth2Clients as it, truncateCommand as j, getCommand$5 as jt, listWorkflows as k, functionExecutionStatusToString as kt, listUsers as l, generateUserTypes as ln, listCommand$7 as lt, listCommand$1 as m, confirmationArgs as mn, triggerCommand as mt, queryCommand as n, formatDiffSummary as nn, createFolder as nt, removeCommand as o, prompt as on, getOAuth2Client as ot, restoreWorkspace as p, commonArgs as pn, webhookCommand as pt, updateCommand$2 as q, formatMigrationNumber as qt, isCLIError as r, formatMigrationDiff as rn, listCommand$6 as rt, removeUser as s, sdkNameLabelKey as sn, getMachineUserToken as st, query as t, reconstructSnapshotFromMigrations as tn, createCommand$1 as tt, inviteCommand as u, apiCall as un, listMachineUsers as ut, deleteCommand as v, getExecutorJob as vt, getAppHealth as w, getCommand$4 as wt, createWorkspace as x, watchExecutorJob as xt, deleteWorkspace as y, jobsCommand as yt, updateCommand$1 as z, DB_TYPES_FILE_NAME as zt };
|
|
13145
|
+
//# sourceMappingURL=query-C3oQTLvb.mjs.map
|