@tailor-platform/sdk 1.9.0 → 1.9.2
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 +16 -0
- package/dist/cli/index.mjs +41 -7
- package/dist/cli/index.mjs.map +1 -1
- package/dist/cli/lib.d.mts +150 -3
- package/dist/cli/lib.mjs +2 -2
- package/dist/cli/lib.mjs.map +1 -1
- package/dist/configure/index.d.mts +2 -2
- package/dist/{index-Bd255ayy.d.mts → index-B07hXFjo.d.mts} +10 -10
- package/dist/{index-DFEsnnHR.d.mts → index-x4xcWJm1.d.mts} +7 -7
- package/dist/{list-CYsYjREc.mjs → update-DZs1loy_.mjs} +603 -25
- package/dist/update-DZs1loy_.mjs.map +1 -0
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli/tailordb.md +8 -8
- package/docs/cli/workspace.md +234 -5
- package/package.json +1 -1
- package/dist/list-CYsYjREc.mjs.map +0 -1
|
@@ -223,6 +223,14 @@ const Subgraph_ServiceTypeSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_appli
|
|
|
223
223
|
* @generated from enum tailor.v1.Subgraph.ServiceType
|
|
224
224
|
*/
|
|
225
225
|
const Subgraph_ServiceType = /* @__PURE__ */ tsEnum(Subgraph_ServiceTypeSchema);
|
|
226
|
+
/**
|
|
227
|
+
* Describes the enum tailor.v1.ApplicationSchemaUpdateAttemptStatus.
|
|
228
|
+
*/
|
|
229
|
+
const ApplicationSchemaUpdateAttemptStatusSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_application_resource, 0);
|
|
230
|
+
/**
|
|
231
|
+
* @generated from enum tailor.v1.ApplicationSchemaUpdateAttemptStatus
|
|
232
|
+
*/
|
|
233
|
+
const ApplicationSchemaUpdateAttemptStatus = /* @__PURE__ */ tsEnum(ApplicationSchemaUpdateAttemptStatusSchema);
|
|
226
234
|
|
|
227
235
|
//#endregion
|
|
228
236
|
//#region ../tailor-proto/src/tailor/v1/resource_pb.js
|
|
@@ -270,6 +278,14 @@ const file_tailor_v1_application = /* @__PURE__ */ fileDesc("Cht0YWlsb3IvdjEvYXB
|
|
|
270
278
|
file_tailor_v1_application_resource,
|
|
271
279
|
file_tailor_v1_resource
|
|
272
280
|
]);
|
|
281
|
+
/**
|
|
282
|
+
* Describes the enum tailor.v1.GetApplicationSchemaHealthResponse.ApplicationSchemaHealthStatus.
|
|
283
|
+
*/
|
|
284
|
+
const GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatusSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_application, 11, 0);
|
|
285
|
+
/**
|
|
286
|
+
* @generated from enum tailor.v1.GetApplicationSchemaHealthResponse.ApplicationSchemaHealthStatus
|
|
287
|
+
*/
|
|
288
|
+
const GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus = /* @__PURE__ */ tsEnum(GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatusSchema);
|
|
273
289
|
|
|
274
290
|
//#endregion
|
|
275
291
|
//#region ../tailor-proto/src/tailor/v1/secret_manager_resource_pb.js
|
|
@@ -748,6 +764,14 @@ const file_tailor_v1_workflow = /* @__PURE__ */ fileDesc("Chh0YWlsb3IvdjEvd29ya2
|
|
|
748
764
|
* Describes the file tailor/v1/workspace_resource.proto.
|
|
749
765
|
*/
|
|
750
766
|
const file_tailor_v1_workspace_resource = /* @__PURE__ */ fileDesc("CiJ0YWlsb3IvdjEvd29ya3NwYWNlX3Jlc291cmNlLnByb3RvEgl0YWlsb3IudjEilAEKDE9yZ2FuaXphdGlvbhIKCgJpZBgBIAEoCRIMCgRuYW1lGAIgASgJEjQKC2NyZWF0ZV90aW1lGAMgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID4EEDEjQKC3VwZGF0ZV90aW1lGAQgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID4EEDIpQDChJPcmdhbml6YXRpb25BY2Nlc3MSFwoPb3JnYW5pemF0aW9uX2lk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AESFQoRVEVBTV9ST0xFX01BTkFHRVIQAhIUChBURUFNX1JPTEVfTUVNQkVSEAMqwwEKGVdvcmtzcGFjZVBsYXRmb3JtVXNlclJvbGUSLAooV09SS1NQQUNFX1BMQVRGT1JNX1VTRVJfUk9MRV9VTlNQRUNJRklFRBAAEiYKIldPUktTUEFDRV9QTEFURk9STV9VU0VSX1JPTEVfQURNSU4QARInCiNXT1JLU1BBQ0VfUExBVEZPUk1fVVNFUl9ST0xFX0VESVRPUhACEicKI1dPUktTUEFDRV9QTEFURk9STV9VU0VSX1JPTEVfVklFV0VSEAMqkQEKF1BsYXRmb3JtQWNjb3VudFBsYW5UeXBlEioKJlBMQVRGT1JNX0FDQ09VTlRfUExBTl9UWVBFX1VOU1BFQ0lGSUVEEAASJAogUExBVEZPUk1fQUNDT1VOVF9QTEFOX1RZUEVfVFJJQUwQARIkCiBQTEFURk9STV9BQ0NPVU5UX1BMQU5fVFlQRV9CQVNJQxACYgZwcm90bzM", [file_google_api_field_behavior, file_google_protobuf_timestamp]);
|
|
767
|
+
/**
|
|
768
|
+
* Describes the enum tailor.v1.WorkspacePlatformUserRole.
|
|
769
|
+
*/
|
|
770
|
+
const WorkspacePlatformUserRoleSchema = /* @__PURE__ */ enumDesc(file_tailor_v1_workspace_resource, 3);
|
|
771
|
+
/**
|
|
772
|
+
* @generated from enum tailor.v1.WorkspacePlatformUserRole
|
|
773
|
+
*/
|
|
774
|
+
const WorkspacePlatformUserRole = /* @__PURE__ */ tsEnum(WorkspacePlatformUserRoleSchema);
|
|
751
775
|
|
|
752
776
|
//#endregion
|
|
753
777
|
//#region ../tailor-proto/src/tailor/v1/workspace_pb.js
|
|
@@ -8872,6 +8896,17 @@ const applyCommand = defineCommand({
|
|
|
8872
8896
|
//#endregion
|
|
8873
8897
|
//#region src/cli/utils/format.ts
|
|
8874
8898
|
/**
|
|
8899
|
+
* Format a protobuf Timestamp to ISO string.
|
|
8900
|
+
* @param timestamp - Protobuf timestamp
|
|
8901
|
+
* @returns Date object or null if invalid
|
|
8902
|
+
*/
|
|
8903
|
+
function formatTimestamp(timestamp) {
|
|
8904
|
+
if (!timestamp) return null;
|
|
8905
|
+
const date = timestampDate(timestamp);
|
|
8906
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
8907
|
+
return date;
|
|
8908
|
+
}
|
|
8909
|
+
/**
|
|
8875
8910
|
* Formats a table with consistent single-line border style.
|
|
8876
8911
|
* Use this instead of importing `table` directly.
|
|
8877
8912
|
* @param data - Table data
|
|
@@ -8892,6 +8927,17 @@ function formatTable(data, config) {
|
|
|
8892
8927
|
function formatKeyValueTable(data) {
|
|
8893
8928
|
return formatTable(data, { singleLine: true });
|
|
8894
8929
|
}
|
|
8930
|
+
/**
|
|
8931
|
+
* Format a Date or ISO timestamp string as a human-readable relative time.
|
|
8932
|
+
* @param value - Date object, ISO date string, or null
|
|
8933
|
+
* @returns Relative time (e.g., "5 minutes ago") or "N/A" for null/invalid
|
|
8934
|
+
*/
|
|
8935
|
+
function humanizeRelativeTime(value) {
|
|
8936
|
+
if (value === null) return "N/A";
|
|
8937
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
8938
|
+
if (Number.isNaN(date.getTime())) return typeof value === "string" ? value : "N/A";
|
|
8939
|
+
return formatDistanceToNowStrict(date, { addSuffix: true });
|
|
8940
|
+
}
|
|
8895
8941
|
|
|
8896
8942
|
//#endregion
|
|
8897
8943
|
//#region src/cli/workflow/args.ts
|
|
@@ -9303,7 +9349,7 @@ async function getWorkflow(options) {
|
|
|
9303
9349
|
throw error;
|
|
9304
9350
|
}
|
|
9305
9351
|
}
|
|
9306
|
-
const getCommand$
|
|
9352
|
+
const getCommand$2 = defineCommand({
|
|
9307
9353
|
name: "get",
|
|
9308
9354
|
description: "Get workflow details.",
|
|
9309
9355
|
args: z.object({
|
|
@@ -10947,7 +10993,7 @@ async function listMachineUsers(options) {
|
|
|
10947
10993
|
return [machineUsers, nextPageToken];
|
|
10948
10994
|
})).map(machineUserInfo);
|
|
10949
10995
|
}
|
|
10950
|
-
const listCommand$
|
|
10996
|
+
const listCommand$5 = defineCommand({
|
|
10951
10997
|
name: "list",
|
|
10952
10998
|
description: "List all machine users in the application.",
|
|
10953
10999
|
args: z.object({
|
|
@@ -11108,7 +11154,7 @@ async function getOAuth2Client(options) {
|
|
|
11108
11154
|
throw error;
|
|
11109
11155
|
}
|
|
11110
11156
|
}
|
|
11111
|
-
const getCommand = defineCommand({
|
|
11157
|
+
const getCommand$1 = defineCommand({
|
|
11112
11158
|
name: "get",
|
|
11113
11159
|
description: "Get OAuth2 client credentials (including client secret).",
|
|
11114
11160
|
args: z.object({
|
|
@@ -11162,7 +11208,7 @@ async function listOAuth2Clients(options) {
|
|
|
11162
11208
|
return [oauth2Clients, nextPageToken];
|
|
11163
11209
|
})).map(toOAuth2ClientInfo);
|
|
11164
11210
|
}
|
|
11165
|
-
const listCommand$
|
|
11211
|
+
const listCommand$4 = defineCommand({
|
|
11166
11212
|
name: "list",
|
|
11167
11213
|
description: "List all OAuth2 clients in the application.",
|
|
11168
11214
|
args: z.object({
|
|
@@ -11182,7 +11228,7 @@ const listCommand$2 = defineCommand({
|
|
|
11182
11228
|
|
|
11183
11229
|
//#endregion
|
|
11184
11230
|
//#region src/cli/remove.ts
|
|
11185
|
-
async function loadOptions$
|
|
11231
|
+
async function loadOptions$9(options) {
|
|
11186
11232
|
const client = await initOperatorClient(await loadAccessToken({
|
|
11187
11233
|
useProfile: true,
|
|
11188
11234
|
profile: options?.profile
|
|
@@ -11236,10 +11282,10 @@ async function execRemove(client, workspaceId, application, config, confirm) {
|
|
|
11236
11282
|
* @returns Promise that resolves when removal completes
|
|
11237
11283
|
*/
|
|
11238
11284
|
async function remove(options) {
|
|
11239
|
-
const { client, workspaceId, application, config } = await loadOptions$
|
|
11285
|
+
const { client, workspaceId, application, config } = await loadOptions$9(options);
|
|
11240
11286
|
await execRemove(client, workspaceId, application, config);
|
|
11241
11287
|
}
|
|
11242
|
-
const removeCommand = defineCommand({
|
|
11288
|
+
const removeCommand$1 = defineCommand({
|
|
11243
11289
|
name: "remove",
|
|
11244
11290
|
description: "Remove all resources managed by the application from the workspace.",
|
|
11245
11291
|
args: z.object({
|
|
@@ -11248,7 +11294,7 @@ const removeCommand = defineCommand({
|
|
|
11248
11294
|
...confirmationArgs
|
|
11249
11295
|
}),
|
|
11250
11296
|
run: withCommonArgs(async (args) => {
|
|
11251
|
-
const { client, workspaceId, application, config } = await loadOptions$
|
|
11297
|
+
const { client, workspaceId, application, config } = await loadOptions$9({
|
|
11252
11298
|
workspaceId: args["workspace-id"],
|
|
11253
11299
|
profile: args.profile,
|
|
11254
11300
|
configPath: args.config
|
|
@@ -11304,13 +11350,13 @@ async function show(options) {
|
|
|
11304
11350
|
workspaceId,
|
|
11305
11351
|
applicationName: config.name
|
|
11306
11352
|
})]);
|
|
11307
|
-
const { name, ...appInfo } = applicationInfo(resp.application);
|
|
11353
|
+
const { name, ...appInfo$1 } = applicationInfo(resp.application);
|
|
11308
11354
|
return {
|
|
11309
11355
|
name,
|
|
11310
11356
|
workspaceId,
|
|
11311
11357
|
workspaceName: workspaceResp.workspace?.name ?? "",
|
|
11312
11358
|
workspaceRegion: workspaceResp.workspace?.region ?? "",
|
|
11313
|
-
...appInfo
|
|
11359
|
+
...appInfo$1
|
|
11314
11360
|
};
|
|
11315
11361
|
}
|
|
11316
11362
|
const showCommand = defineCommand({
|
|
@@ -11322,12 +11368,12 @@ const showCommand = defineCommand({
|
|
|
11322
11368
|
...deploymentArgs
|
|
11323
11369
|
}),
|
|
11324
11370
|
run: withCommonArgs(async (args) => {
|
|
11325
|
-
const appInfo = await show({
|
|
11371
|
+
const appInfo$1 = await show({
|
|
11326
11372
|
workspaceId: args["workspace-id"],
|
|
11327
11373
|
profile: args.profile,
|
|
11328
11374
|
configPath: args.config
|
|
11329
11375
|
});
|
|
11330
|
-
logger.out(appInfo);
|
|
11376
|
+
logger.out(appInfo$1);
|
|
11331
11377
|
})
|
|
11332
11378
|
});
|
|
11333
11379
|
|
|
@@ -12185,7 +12231,7 @@ async function listWorkflows(options) {
|
|
|
12185
12231
|
return [workflows, nextPageToken];
|
|
12186
12232
|
})).map(toWorkflowListInfo);
|
|
12187
12233
|
}
|
|
12188
|
-
const listCommand$
|
|
12234
|
+
const listCommand$3 = defineCommand({
|
|
12189
12235
|
name: "list",
|
|
12190
12236
|
description: "List all workflows in the workspace.",
|
|
12191
12237
|
args: z.object({
|
|
@@ -12282,13 +12328,174 @@ const resumeCommand = defineCommand({
|
|
|
12282
12328
|
});
|
|
12283
12329
|
|
|
12284
12330
|
//#endregion
|
|
12285
|
-
//#region src/cli/workspace/transform.ts
|
|
12286
|
-
const
|
|
12287
|
-
|
|
12288
|
-
|
|
12289
|
-
|
|
12290
|
-
|
|
12331
|
+
//#region src/cli/workspace/app/transform.ts
|
|
12332
|
+
const statusToString = (status) => {
|
|
12333
|
+
switch (status) {
|
|
12334
|
+
case GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus.OK: return "ok";
|
|
12335
|
+
case GetApplicationSchemaHealthResponse_ApplicationSchemaHealthStatus.COMPOSITION_ERROR: return "composition_error";
|
|
12336
|
+
default: return "unknown";
|
|
12337
|
+
}
|
|
12338
|
+
};
|
|
12339
|
+
const attemptStatusToString = (status) => {
|
|
12340
|
+
switch (status) {
|
|
12341
|
+
case ApplicationSchemaUpdateAttemptStatus.SUCCEEDED: return "success";
|
|
12342
|
+
case ApplicationSchemaUpdateAttemptStatus.FAILED: return "failure";
|
|
12343
|
+
default: return "unknown";
|
|
12344
|
+
}
|
|
12345
|
+
};
|
|
12346
|
+
const appInfo = (app) => {
|
|
12347
|
+
return {
|
|
12348
|
+
name: app.name,
|
|
12349
|
+
domain: app.domain,
|
|
12350
|
+
authNamespace: app.authNamespace,
|
|
12351
|
+
createdAt: formatTimestamp(app.createTime),
|
|
12352
|
+
updatedAt: formatTimestamp(app.updateTime)
|
|
12353
|
+
};
|
|
12354
|
+
};
|
|
12355
|
+
const appHealthInfo = (name, health) => {
|
|
12356
|
+
const attempt = health.lastSchemaUpdateAttempt;
|
|
12357
|
+
return {
|
|
12358
|
+
name,
|
|
12359
|
+
status: statusToString(health.status),
|
|
12360
|
+
currentServingSchemaUpdatedAt: formatTimestamp(health.currentServingSchemaUpdateTime),
|
|
12361
|
+
lastAttemptStatus: attempt ? attemptStatusToString(attempt.status) : "N/A",
|
|
12362
|
+
lastAttemptAt: formatTimestamp(attempt?.attemptTime),
|
|
12363
|
+
lastAttemptError: attempt?.error ?? ""
|
|
12364
|
+
};
|
|
12291
12365
|
};
|
|
12366
|
+
|
|
12367
|
+
//#endregion
|
|
12368
|
+
//#region src/cli/workspace/app/health.ts
|
|
12369
|
+
const healthOptionsSchema = z.object({
|
|
12370
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12371
|
+
profile: z.string().optional(),
|
|
12372
|
+
name: z.string().min(1, { message: "name is required" })
|
|
12373
|
+
});
|
|
12374
|
+
async function loadOptions$8(options) {
|
|
12375
|
+
const result = healthOptionsSchema.safeParse(options);
|
|
12376
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12377
|
+
return {
|
|
12378
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12379
|
+
workspaceId: loadWorkspaceId({
|
|
12380
|
+
workspaceId: result.data.workspaceId,
|
|
12381
|
+
profile: result.data.profile
|
|
12382
|
+
}),
|
|
12383
|
+
name: result.data.name
|
|
12384
|
+
};
|
|
12385
|
+
}
|
|
12386
|
+
/**
|
|
12387
|
+
* Get application schema health status.
|
|
12388
|
+
* @param options - Health check options
|
|
12389
|
+
* @returns Application health information
|
|
12390
|
+
*/
|
|
12391
|
+
async function getAppHealth(options) {
|
|
12392
|
+
const { client, workspaceId, name } = await loadOptions$8(options);
|
|
12393
|
+
return appHealthInfo(name, await client.getApplicationSchemaHealth({
|
|
12394
|
+
workspaceId,
|
|
12395
|
+
applicationName: name
|
|
12396
|
+
}));
|
|
12397
|
+
}
|
|
12398
|
+
const healthCommand = defineCommand({
|
|
12399
|
+
name: "health",
|
|
12400
|
+
description: "Check application schema health",
|
|
12401
|
+
args: z.object({
|
|
12402
|
+
...commonArgs,
|
|
12403
|
+
...jsonArgs,
|
|
12404
|
+
...workspaceArgs,
|
|
12405
|
+
name: arg(z.string(), {
|
|
12406
|
+
description: "Application name",
|
|
12407
|
+
alias: "n"
|
|
12408
|
+
})
|
|
12409
|
+
}),
|
|
12410
|
+
run: withCommonArgs(async (args) => {
|
|
12411
|
+
const health = await getAppHealth({
|
|
12412
|
+
workspaceId: args["workspace-id"],
|
|
12413
|
+
profile: args.profile,
|
|
12414
|
+
name: args.name
|
|
12415
|
+
});
|
|
12416
|
+
const formattedHealth = args.json ? health : {
|
|
12417
|
+
...health,
|
|
12418
|
+
currentServingSchemaUpdatedAt: humanizeRelativeTime(health.currentServingSchemaUpdatedAt),
|
|
12419
|
+
lastAttemptAt: humanizeRelativeTime(health.lastAttemptAt)
|
|
12420
|
+
};
|
|
12421
|
+
logger.out(formattedHealth);
|
|
12422
|
+
})
|
|
12423
|
+
});
|
|
12424
|
+
|
|
12425
|
+
//#endregion
|
|
12426
|
+
//#region src/cli/workspace/app/list.ts
|
|
12427
|
+
const listAppsOptionsSchema = z.object({
|
|
12428
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12429
|
+
profile: z.string().optional(),
|
|
12430
|
+
limit: z.coerce.number().int().positive().optional()
|
|
12431
|
+
});
|
|
12432
|
+
async function loadOptions$7(options) {
|
|
12433
|
+
const result = listAppsOptionsSchema.safeParse(options);
|
|
12434
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12435
|
+
return {
|
|
12436
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12437
|
+
workspaceId: loadWorkspaceId({
|
|
12438
|
+
workspaceId: result.data.workspaceId,
|
|
12439
|
+
profile: result.data.profile
|
|
12440
|
+
}),
|
|
12441
|
+
limit: result.data.limit
|
|
12442
|
+
};
|
|
12443
|
+
}
|
|
12444
|
+
/**
|
|
12445
|
+
* List applications in a workspace with an optional limit.
|
|
12446
|
+
* @param options - Application listing options
|
|
12447
|
+
* @returns List of applications
|
|
12448
|
+
*/
|
|
12449
|
+
async function listApps(options) {
|
|
12450
|
+
const { client, workspaceId, limit } = await loadOptions$7(options);
|
|
12451
|
+
const hasLimit = limit !== void 0;
|
|
12452
|
+
const results = [];
|
|
12453
|
+
let pageToken = "";
|
|
12454
|
+
while (true) {
|
|
12455
|
+
if (hasLimit && results.length >= limit) break;
|
|
12456
|
+
const remaining = hasLimit ? limit - results.length : void 0;
|
|
12457
|
+
const pageSize = remaining !== void 0 && remaining > 0 ? remaining : void 0;
|
|
12458
|
+
const { applications, nextPageToken } = await client.listApplications({
|
|
12459
|
+
workspaceId,
|
|
12460
|
+
pageToken,
|
|
12461
|
+
...pageSize !== void 0 ? { pageSize } : {}
|
|
12462
|
+
});
|
|
12463
|
+
const mapped = applications.map(appInfo);
|
|
12464
|
+
if (remaining !== void 0 && mapped.length > remaining) results.push(...mapped.slice(0, remaining));
|
|
12465
|
+
else results.push(...mapped);
|
|
12466
|
+
if (!nextPageToken) break;
|
|
12467
|
+
pageToken = nextPageToken;
|
|
12468
|
+
}
|
|
12469
|
+
return results;
|
|
12470
|
+
}
|
|
12471
|
+
const listCommand$2 = defineCommand({
|
|
12472
|
+
name: "list",
|
|
12473
|
+
description: "List applications in a workspace",
|
|
12474
|
+
args: z.object({
|
|
12475
|
+
...commonArgs,
|
|
12476
|
+
...jsonArgs,
|
|
12477
|
+
...workspaceArgs,
|
|
12478
|
+
limit: arg(positiveIntArg.optional(), {
|
|
12479
|
+
alias: "l",
|
|
12480
|
+
description: "Maximum number of applications to list"
|
|
12481
|
+
})
|
|
12482
|
+
}),
|
|
12483
|
+
run: withCommonArgs(async (args) => {
|
|
12484
|
+
const apps = await listApps({
|
|
12485
|
+
workspaceId: args["workspace-id"],
|
|
12486
|
+
profile: args.profile,
|
|
12487
|
+
limit: args.limit
|
|
12488
|
+
});
|
|
12489
|
+
const formattedApps = args.json ? apps : apps.map(({ updatedAt: _, createdAt, ...rest }) => ({
|
|
12490
|
+
...rest,
|
|
12491
|
+
createdAt: humanizeRelativeTime(createdAt)
|
|
12492
|
+
}));
|
|
12493
|
+
logger.out(formattedApps);
|
|
12494
|
+
})
|
|
12495
|
+
});
|
|
12496
|
+
|
|
12497
|
+
//#endregion
|
|
12498
|
+
//#region src/cli/workspace/transform.ts
|
|
12292
12499
|
const workspaceInfo = (workspace) => {
|
|
12293
12500
|
return {
|
|
12294
12501
|
id: workspace.id,
|
|
@@ -12298,6 +12505,14 @@ const workspaceInfo = (workspace) => {
|
|
|
12298
12505
|
updatedAt: formatTimestamp(workspace.updateTime)
|
|
12299
12506
|
};
|
|
12300
12507
|
};
|
|
12508
|
+
const workspaceDetails = (workspace) => {
|
|
12509
|
+
return {
|
|
12510
|
+
...workspaceInfo(workspace),
|
|
12511
|
+
deleteProtection: workspace.deleteProtection,
|
|
12512
|
+
organizationId: workspace.organizationId,
|
|
12513
|
+
folderId: workspace.folderId
|
|
12514
|
+
};
|
|
12515
|
+
};
|
|
12301
12516
|
|
|
12302
12517
|
//#endregion
|
|
12303
12518
|
//#region src/cli/workspace/create.ts
|
|
@@ -12417,7 +12632,7 @@ const createCommand = defineCommand({
|
|
|
12417
12632
|
//#endregion
|
|
12418
12633
|
//#region src/cli/workspace/delete.ts
|
|
12419
12634
|
const deleteWorkspaceOptionsSchema = z.object({ workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }) });
|
|
12420
|
-
async function loadOptions(options) {
|
|
12635
|
+
async function loadOptions$6(options) {
|
|
12421
12636
|
const result = deleteWorkspaceOptionsSchema.safeParse(options);
|
|
12422
12637
|
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12423
12638
|
return {
|
|
@@ -12431,7 +12646,7 @@ async function loadOptions(options) {
|
|
|
12431
12646
|
* @returns Promise that resolves when deletion completes
|
|
12432
12647
|
*/
|
|
12433
12648
|
async function deleteWorkspace(options) {
|
|
12434
|
-
const { client, workspaceId } = await loadOptions(options);
|
|
12649
|
+
const { client, workspaceId } = await loadOptions$6(options);
|
|
12435
12650
|
await client.deleteWorkspace({ workspaceId });
|
|
12436
12651
|
}
|
|
12437
12652
|
const deleteCommand = defineCommand({
|
|
@@ -12446,7 +12661,7 @@ const deleteCommand = defineCommand({
|
|
|
12446
12661
|
...confirmationArgs
|
|
12447
12662
|
}),
|
|
12448
12663
|
run: withCommonArgs(async (args) => {
|
|
12449
|
-
const { client, workspaceId } = await loadOptions({ workspaceId: args["workspace-id"] });
|
|
12664
|
+
const { client, workspaceId } = await loadOptions$6({ workspaceId: args["workspace-id"] });
|
|
12450
12665
|
let workspace;
|
|
12451
12666
|
try {
|
|
12452
12667
|
workspace = await client.getWorkspace({ workspaceId });
|
|
@@ -12471,6 +12686,56 @@ const deleteCommand = defineCommand({
|
|
|
12471
12686
|
})
|
|
12472
12687
|
});
|
|
12473
12688
|
|
|
12689
|
+
//#endregion
|
|
12690
|
+
//#region src/cli/workspace/get.ts
|
|
12691
|
+
const getWorkspaceOptionsSchema = z.object({
|
|
12692
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12693
|
+
profile: z.string().optional()
|
|
12694
|
+
});
|
|
12695
|
+
async function loadOptions$5(options) {
|
|
12696
|
+
const result = getWorkspaceOptionsSchema.safeParse(options);
|
|
12697
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12698
|
+
return {
|
|
12699
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12700
|
+
workspaceId: loadWorkspaceId({
|
|
12701
|
+
workspaceId: result.data.workspaceId,
|
|
12702
|
+
profile: result.data.profile
|
|
12703
|
+
})
|
|
12704
|
+
};
|
|
12705
|
+
}
|
|
12706
|
+
/**
|
|
12707
|
+
* Get detailed information about a workspace.
|
|
12708
|
+
* @param options - Workspace get options
|
|
12709
|
+
* @returns Workspace details
|
|
12710
|
+
*/
|
|
12711
|
+
async function getWorkspace(options) {
|
|
12712
|
+
const { client, workspaceId } = await loadOptions$5(options);
|
|
12713
|
+
const response = await client.getWorkspace({ workspaceId });
|
|
12714
|
+
if (!response.workspace) throw new Error(`Workspace "${workspaceId}" not found.`);
|
|
12715
|
+
return workspaceDetails(response.workspace);
|
|
12716
|
+
}
|
|
12717
|
+
const getCommand = defineCommand({
|
|
12718
|
+
name: "get",
|
|
12719
|
+
description: "Show detailed information about a workspace",
|
|
12720
|
+
args: z.object({
|
|
12721
|
+
...commonArgs,
|
|
12722
|
+
...jsonArgs,
|
|
12723
|
+
...workspaceArgs
|
|
12724
|
+
}),
|
|
12725
|
+
run: withCommonArgs(async (args) => {
|
|
12726
|
+
const workspace = await getWorkspace({
|
|
12727
|
+
workspaceId: args["workspace-id"],
|
|
12728
|
+
profile: args.profile
|
|
12729
|
+
});
|
|
12730
|
+
const formattedWorkspace = args.json ? workspace : {
|
|
12731
|
+
...workspace,
|
|
12732
|
+
createdAt: humanizeRelativeTime(workspace.createdAt),
|
|
12733
|
+
updatedAt: humanizeRelativeTime(workspace.updatedAt)
|
|
12734
|
+
};
|
|
12735
|
+
logger.out(formattedWorkspace);
|
|
12736
|
+
})
|
|
12737
|
+
});
|
|
12738
|
+
|
|
12474
12739
|
//#endregion
|
|
12475
12740
|
//#region src/cli/workspace/list.ts
|
|
12476
12741
|
/**
|
|
@@ -12500,7 +12765,7 @@ async function listWorkspaces(options) {
|
|
|
12500
12765
|
}
|
|
12501
12766
|
return results;
|
|
12502
12767
|
}
|
|
12503
|
-
const listCommand = defineCommand({
|
|
12768
|
+
const listCommand$1 = defineCommand({
|
|
12504
12769
|
name: "list",
|
|
12505
12770
|
description: "List all Tailor Platform workspaces.",
|
|
12506
12771
|
args: z.object({
|
|
@@ -12518,5 +12783,318 @@ const listCommand = defineCommand({
|
|
|
12518
12783
|
});
|
|
12519
12784
|
|
|
12520
12785
|
//#endregion
|
|
12521
|
-
|
|
12522
|
-
|
|
12786
|
+
//#region src/cli/workspace/restore.ts
|
|
12787
|
+
const restoreWorkspaceOptionsSchema = z.object({ workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }) });
|
|
12788
|
+
async function loadOptions$4(options) {
|
|
12789
|
+
const result = restoreWorkspaceOptionsSchema.safeParse(options);
|
|
12790
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12791
|
+
return {
|
|
12792
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12793
|
+
workspaceId: result.data.workspaceId
|
|
12794
|
+
};
|
|
12795
|
+
}
|
|
12796
|
+
/**
|
|
12797
|
+
* Restore a deleted workspace by ID.
|
|
12798
|
+
* @param options - Workspace restore options
|
|
12799
|
+
* @returns Promise that resolves when restoration completes
|
|
12800
|
+
*/
|
|
12801
|
+
async function restoreWorkspace(options) {
|
|
12802
|
+
const { client, workspaceId } = await loadOptions$4(options);
|
|
12803
|
+
await client.restoreWorkspace({ workspaceId });
|
|
12804
|
+
}
|
|
12805
|
+
const restoreCommand = defineCommand({
|
|
12806
|
+
name: "restore",
|
|
12807
|
+
description: "Restore a deleted workspace",
|
|
12808
|
+
args: z.object({
|
|
12809
|
+
...commonArgs,
|
|
12810
|
+
"workspace-id": arg(z.string(), {
|
|
12811
|
+
alias: "w",
|
|
12812
|
+
description: "Workspace ID"
|
|
12813
|
+
}),
|
|
12814
|
+
...confirmationArgs
|
|
12815
|
+
}),
|
|
12816
|
+
run: withCommonArgs(async (args) => {
|
|
12817
|
+
const { client, workspaceId } = await loadOptions$4({ workspaceId: args["workspace-id"] });
|
|
12818
|
+
if (!args.yes) {
|
|
12819
|
+
if (await logger.prompt(`Are you sure you want to restore workspace "${workspaceId}"? (yes/no):`, { type: "text" }) !== "yes") {
|
|
12820
|
+
logger.info("Workspace restoration cancelled.");
|
|
12821
|
+
return;
|
|
12822
|
+
}
|
|
12823
|
+
}
|
|
12824
|
+
await client.restoreWorkspace({ workspaceId });
|
|
12825
|
+
logger.success(`Workspace "${workspaceId}" restored successfully.`);
|
|
12826
|
+
})
|
|
12827
|
+
});
|
|
12828
|
+
|
|
12829
|
+
//#endregion
|
|
12830
|
+
//#region src/cli/workspace/user/transform.ts
|
|
12831
|
+
const roleToString = (role) => {
|
|
12832
|
+
switch (role) {
|
|
12833
|
+
case WorkspacePlatformUserRole.ADMIN: return "admin";
|
|
12834
|
+
case WorkspacePlatformUserRole.EDITOR: return "editor";
|
|
12835
|
+
case WorkspacePlatformUserRole.VIEWER: return "viewer";
|
|
12836
|
+
default: return "unknown";
|
|
12837
|
+
}
|
|
12838
|
+
};
|
|
12839
|
+
const stringToRole = (role) => {
|
|
12840
|
+
switch (role.toLowerCase()) {
|
|
12841
|
+
case "admin": return WorkspacePlatformUserRole.ADMIN;
|
|
12842
|
+
case "editor": return WorkspacePlatformUserRole.EDITOR;
|
|
12843
|
+
case "viewer": return WorkspacePlatformUserRole.VIEWER;
|
|
12844
|
+
default: throw new Error(`Invalid role: ${role}. Valid roles: admin, editor, viewer`);
|
|
12845
|
+
}
|
|
12846
|
+
};
|
|
12847
|
+
const userInfo = (user) => {
|
|
12848
|
+
return {
|
|
12849
|
+
userId: user.platformUser?.userId ?? "",
|
|
12850
|
+
email: user.platformUser?.email ?? "",
|
|
12851
|
+
role: roleToString(user.role)
|
|
12852
|
+
};
|
|
12853
|
+
};
|
|
12854
|
+
const validRoles = [
|
|
12855
|
+
"admin",
|
|
12856
|
+
"editor",
|
|
12857
|
+
"viewer"
|
|
12858
|
+
];
|
|
12859
|
+
|
|
12860
|
+
//#endregion
|
|
12861
|
+
//#region src/cli/workspace/user/invite.ts
|
|
12862
|
+
const inviteUserOptionsSchema = z.object({
|
|
12863
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12864
|
+
profile: z.string().optional(),
|
|
12865
|
+
email: z.email({ message: "email must be a valid email address" }),
|
|
12866
|
+
role: z.enum(validRoles, { message: `role must be one of: ${validRoles.join(", ")}` })
|
|
12867
|
+
});
|
|
12868
|
+
async function loadOptions$3(options) {
|
|
12869
|
+
const result = inviteUserOptionsSchema.safeParse(options);
|
|
12870
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12871
|
+
return {
|
|
12872
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12873
|
+
workspaceId: loadWorkspaceId({
|
|
12874
|
+
workspaceId: result.data.workspaceId,
|
|
12875
|
+
profile: result.data.profile
|
|
12876
|
+
}),
|
|
12877
|
+
email: result.data.email,
|
|
12878
|
+
role: stringToRole(result.data.role)
|
|
12879
|
+
};
|
|
12880
|
+
}
|
|
12881
|
+
/**
|
|
12882
|
+
* Invite a user to a workspace.
|
|
12883
|
+
* @param options - User invite options
|
|
12884
|
+
* @returns Promise that resolves when invitation is sent
|
|
12885
|
+
*/
|
|
12886
|
+
async function inviteUser(options) {
|
|
12887
|
+
const { client, workspaceId, email, role } = await loadOptions$3(options);
|
|
12888
|
+
await client.inviteWorkspacePlatformUser({
|
|
12889
|
+
workspaceId,
|
|
12890
|
+
email,
|
|
12891
|
+
role
|
|
12892
|
+
});
|
|
12893
|
+
}
|
|
12894
|
+
const inviteCommand = defineCommand({
|
|
12895
|
+
name: "invite",
|
|
12896
|
+
description: "Invite a user to a workspace",
|
|
12897
|
+
args: z.object({
|
|
12898
|
+
...commonArgs,
|
|
12899
|
+
...workspaceArgs,
|
|
12900
|
+
email: arg(z.email(), { description: "Email address of the user to invite" }),
|
|
12901
|
+
role: arg(z.enum(validRoles), {
|
|
12902
|
+
description: `Role to assign (${validRoles.join(", ")})`,
|
|
12903
|
+
alias: "r"
|
|
12904
|
+
})
|
|
12905
|
+
}),
|
|
12906
|
+
run: withCommonArgs(async (args) => {
|
|
12907
|
+
await inviteUser({
|
|
12908
|
+
workspaceId: args["workspace-id"],
|
|
12909
|
+
profile: args.profile,
|
|
12910
|
+
email: args.email,
|
|
12911
|
+
role: args.role
|
|
12912
|
+
});
|
|
12913
|
+
logger.success(`User "${args.email}" invited successfully with role "${args.role}".`);
|
|
12914
|
+
})
|
|
12915
|
+
});
|
|
12916
|
+
|
|
12917
|
+
//#endregion
|
|
12918
|
+
//#region src/cli/workspace/user/list.ts
|
|
12919
|
+
const listUsersOptionsSchema = z.object({
|
|
12920
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12921
|
+
profile: z.string().optional(),
|
|
12922
|
+
limit: z.coerce.number().int().positive().optional()
|
|
12923
|
+
});
|
|
12924
|
+
async function loadOptions$2(options) {
|
|
12925
|
+
const result = listUsersOptionsSchema.safeParse(options);
|
|
12926
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12927
|
+
return {
|
|
12928
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12929
|
+
workspaceId: loadWorkspaceId({
|
|
12930
|
+
workspaceId: result.data.workspaceId,
|
|
12931
|
+
profile: result.data.profile
|
|
12932
|
+
}),
|
|
12933
|
+
limit: result.data.limit
|
|
12934
|
+
};
|
|
12935
|
+
}
|
|
12936
|
+
/**
|
|
12937
|
+
* List users in a workspace with an optional limit.
|
|
12938
|
+
* @param options - User listing options
|
|
12939
|
+
* @returns List of workspace users
|
|
12940
|
+
*/
|
|
12941
|
+
async function listUsers(options) {
|
|
12942
|
+
const { client, workspaceId, limit } = await loadOptions$2(options);
|
|
12943
|
+
const hasLimit = limit !== void 0;
|
|
12944
|
+
const results = [];
|
|
12945
|
+
let pageToken = "";
|
|
12946
|
+
while (true) {
|
|
12947
|
+
if (hasLimit && results.length >= limit) break;
|
|
12948
|
+
const remaining = hasLimit ? limit - results.length : void 0;
|
|
12949
|
+
const pageSize = remaining !== void 0 && remaining > 0 ? remaining : void 0;
|
|
12950
|
+
const { workspacePlatformUsers, nextPageToken } = await client.listWorkspacePlatformUsers({
|
|
12951
|
+
workspaceId,
|
|
12952
|
+
pageToken,
|
|
12953
|
+
...pageSize !== void 0 ? { pageSize } : {}
|
|
12954
|
+
});
|
|
12955
|
+
const mapped = workspacePlatformUsers.map(userInfo);
|
|
12956
|
+
if (remaining !== void 0 && mapped.length > remaining) results.push(...mapped.slice(0, remaining));
|
|
12957
|
+
else results.push(...mapped);
|
|
12958
|
+
if (!nextPageToken) break;
|
|
12959
|
+
pageToken = nextPageToken;
|
|
12960
|
+
}
|
|
12961
|
+
return results;
|
|
12962
|
+
}
|
|
12963
|
+
const listCommand = defineCommand({
|
|
12964
|
+
name: "list",
|
|
12965
|
+
description: "List users in a workspace",
|
|
12966
|
+
args: z.object({
|
|
12967
|
+
...commonArgs,
|
|
12968
|
+
...jsonArgs,
|
|
12969
|
+
...workspaceArgs,
|
|
12970
|
+
limit: arg(positiveIntArg.optional(), {
|
|
12971
|
+
alias: "l",
|
|
12972
|
+
description: "Maximum number of users to list"
|
|
12973
|
+
})
|
|
12974
|
+
}),
|
|
12975
|
+
run: withCommonArgs(async (args) => {
|
|
12976
|
+
const users = await listUsers({
|
|
12977
|
+
workspaceId: args["workspace-id"],
|
|
12978
|
+
profile: args.profile,
|
|
12979
|
+
limit: args.limit
|
|
12980
|
+
});
|
|
12981
|
+
logger.out(users);
|
|
12982
|
+
})
|
|
12983
|
+
});
|
|
12984
|
+
|
|
12985
|
+
//#endregion
|
|
12986
|
+
//#region src/cli/workspace/user/remove.ts
|
|
12987
|
+
const removeUserOptionsSchema = z.object({
|
|
12988
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
12989
|
+
profile: z.string().optional(),
|
|
12990
|
+
email: z.string().email({ message: "email must be a valid email address" })
|
|
12991
|
+
});
|
|
12992
|
+
async function loadOptions$1(options) {
|
|
12993
|
+
const result = removeUserOptionsSchema.safeParse(options);
|
|
12994
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
12995
|
+
return {
|
|
12996
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
12997
|
+
workspaceId: loadWorkspaceId({
|
|
12998
|
+
workspaceId: result.data.workspaceId,
|
|
12999
|
+
profile: result.data.profile
|
|
13000
|
+
}),
|
|
13001
|
+
email: result.data.email
|
|
13002
|
+
};
|
|
13003
|
+
}
|
|
13004
|
+
/**
|
|
13005
|
+
* Remove a user from a workspace.
|
|
13006
|
+
* @param options - User remove options
|
|
13007
|
+
* @returns Promise that resolves when removal completes
|
|
13008
|
+
*/
|
|
13009
|
+
async function removeUser(options) {
|
|
13010
|
+
const { client, workspaceId, email } = await loadOptions$1(options);
|
|
13011
|
+
await client.removeWorkspacePlatformUser({
|
|
13012
|
+
workspaceId,
|
|
13013
|
+
email
|
|
13014
|
+
});
|
|
13015
|
+
}
|
|
13016
|
+
const removeCommand = defineCommand({
|
|
13017
|
+
name: "remove",
|
|
13018
|
+
description: "Remove a user from a workspace",
|
|
13019
|
+
args: z.object({
|
|
13020
|
+
...commonArgs,
|
|
13021
|
+
...workspaceArgs,
|
|
13022
|
+
email: arg(z.email(), { description: "Email address of the user to remove" }),
|
|
13023
|
+
...confirmationArgs
|
|
13024
|
+
}),
|
|
13025
|
+
run: withCommonArgs(async (args) => {
|
|
13026
|
+
if (!args.yes) {
|
|
13027
|
+
if (await logger.prompt(`Are you sure you want to remove user "${args.email}" from the workspace? (yes/no):`, { type: "text" }) !== "yes") {
|
|
13028
|
+
logger.info("User removal cancelled.");
|
|
13029
|
+
return;
|
|
13030
|
+
}
|
|
13031
|
+
}
|
|
13032
|
+
await removeUser({
|
|
13033
|
+
workspaceId: args["workspace-id"],
|
|
13034
|
+
profile: args.profile,
|
|
13035
|
+
email: args.email
|
|
13036
|
+
});
|
|
13037
|
+
logger.success(`User "${args.email}" removed from workspace.`);
|
|
13038
|
+
})
|
|
13039
|
+
});
|
|
13040
|
+
|
|
13041
|
+
//#endregion
|
|
13042
|
+
//#region src/cli/workspace/user/update.ts
|
|
13043
|
+
const updateUserOptionsSchema = z.object({
|
|
13044
|
+
workspaceId: z.uuid({ message: "workspace-id must be a valid UUID" }).optional(),
|
|
13045
|
+
profile: z.string().optional(),
|
|
13046
|
+
email: z.string().email({ message: "email must be a valid email address" }),
|
|
13047
|
+
role: z.enum(validRoles, { message: `role must be one of: ${validRoles.join(", ")}` })
|
|
13048
|
+
});
|
|
13049
|
+
async function loadOptions(options) {
|
|
13050
|
+
const result = updateUserOptionsSchema.safeParse(options);
|
|
13051
|
+
if (!result.success) throw new Error(result.error.issues[0].message);
|
|
13052
|
+
return {
|
|
13053
|
+
client: await initOperatorClient(await loadAccessToken()),
|
|
13054
|
+
workspaceId: loadWorkspaceId({
|
|
13055
|
+
workspaceId: result.data.workspaceId,
|
|
13056
|
+
profile: result.data.profile
|
|
13057
|
+
}),
|
|
13058
|
+
email: result.data.email,
|
|
13059
|
+
role: stringToRole(result.data.role)
|
|
13060
|
+
};
|
|
13061
|
+
}
|
|
13062
|
+
/**
|
|
13063
|
+
* Update a user's role in a workspace.
|
|
13064
|
+
* @param options - User update options
|
|
13065
|
+
* @returns Promise that resolves when update completes
|
|
13066
|
+
*/
|
|
13067
|
+
async function updateUser(options) {
|
|
13068
|
+
const { client, workspaceId, email, role } = await loadOptions(options);
|
|
13069
|
+
await client.updateWorkspacePlatformUser({
|
|
13070
|
+
workspaceId,
|
|
13071
|
+
email,
|
|
13072
|
+
role
|
|
13073
|
+
});
|
|
13074
|
+
}
|
|
13075
|
+
const updateCommand = defineCommand({
|
|
13076
|
+
name: "update",
|
|
13077
|
+
description: "Update a user's role in a workspace",
|
|
13078
|
+
args: z.object({
|
|
13079
|
+
...commonArgs,
|
|
13080
|
+
...workspaceArgs,
|
|
13081
|
+
email: arg(z.email(), { description: "Email address of the user to update" }),
|
|
13082
|
+
role: arg(z.enum(validRoles), {
|
|
13083
|
+
description: `New role to assign (${validRoles.join(", ")})`,
|
|
13084
|
+
alias: "r"
|
|
13085
|
+
})
|
|
13086
|
+
}),
|
|
13087
|
+
run: withCommonArgs(async (args) => {
|
|
13088
|
+
await updateUser({
|
|
13089
|
+
workspaceId: args["workspace-id"],
|
|
13090
|
+
profile: args.profile,
|
|
13091
|
+
email: args.email,
|
|
13092
|
+
role: args.role
|
|
13093
|
+
});
|
|
13094
|
+
logger.success(`User "${args.email}" updated to role "${args.role}".`);
|
|
13095
|
+
})
|
|
13096
|
+
});
|
|
13097
|
+
|
|
13098
|
+
//#endregion
|
|
13099
|
+
export { startWorkflow as $, generateCommand as A, trnPrefix as At, getMachineUserToken as B, fetchAll as Bt, resumeCommand as C, isValidMigrationNumber as Ct, truncate as D, formatMigrationDiff as Dt, listWorkflows as E, formatDiffSummary as Et, removeCommand$1 as F, fetchLatestToken as Ft, generateCommand$1 as G, PATScope as Gt, listCommand$5 as H, initOAuth2Client as Ht, listCommand$4 as I, loadAccessToken as It, getExecutorJob as J, deploymentArgs as Jt, triggerCommand as K, commonArgs as Kt, listOAuth2Clients as L, loadWorkspaceId as Lt, show as M, loadConfig as Mt, showCommand as N, apiCall as Nt, truncateCommand as O, hasChanges as Ot, remove as P, apiCommand as Pt, startCommand as Q, getCommand$1 as R, readPlatformConfig as Rt, healthCommand as S, getNextMigrationNumber as St, listCommand$3 as T, reconstructSnapshotFromMigrations as Tt, listMachineUsers as U, initOperatorClient as Ut, tokenCommand as V, fetchUserInfo as Vt, generate$1 as W, readPackageJson as Wt, listExecutorJobs as X, withCommonArgs as Xt, jobsCommand as Y, jsonArgs as Yt, watchExecutorJob as Z, workspaceArgs as Zt, createCommand as _, formatMigrationNumber as _t, listCommand as a, apply as at, listCommand$2 as b, getMigrationFilePath as bt, inviteUser as c, parseMigrationLabelNumber as ct, listCommand$1 as d, INITIAL_SCHEMA_NUMBER as dt, getCommand$2 as et, listWorkspaces as f, MIGRATE_FILE_NAME as ft, deleteWorkspace as g, createSnapshotFromLocalTypes as gt, deleteCommand as h, compareSnapshots as ht, removeUser as i, listWorkflowExecutions as it, logBetaWarning as j, generateUserTypes as jt, generate as k, getNamespacesWithMigrations as kt, restoreCommand as l, DB_TYPES_FILE_NAME as lt, getWorkspace as m, compareLocalTypesWithSnapshot as mt, updateUser as n, executionsCommand as nt, listUsers as o, applyCommand as ot, getCommand as p, SCHEMA_FILE_NAME as pt, triggerExecutor as q, confirmationArgs as qt, removeCommand as r, getWorkflowExecution as rt, inviteCommand as s, MIGRATION_LABEL_KEY as st, updateCommand as t, getWorkflow as tt, restoreWorkspace as u, DIFF_FILE_NAME as ut, createWorkspace as v, getLatestMigrationNumber as vt, resumeWorkflow as w, loadDiff as wt, getAppHealth as x, getMigrationFiles as xt, listApps as y, getMigrationDirPath as yt, getOAuth2Client as z, writePlatformConfig as zt };
|
|
13100
|
+
//# sourceMappingURL=update-DZs1loy_.mjs.map
|