@tailor-platform/sdk 0.12.4 → 0.14.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 +85 -0
- package/dist/cli/api.d.mts +1 -1
- package/dist/cli/api.mjs +2 -2
- package/dist/cli/index.mjs +471 -11
- package/dist/cli/index.mjs.map +1 -1
- package/dist/configure/index.d.mts +3 -3
- package/dist/configure/index.mjs +7 -2
- package/dist/configure/index.mjs.map +1 -1
- package/dist/{index-BjdZmtxR.d.mts → index-zRgZdNLm.d.mts} +31 -28
- package/dist/{job-wYkb6yMl.mjs → job-inTmXxpa.mjs} +5 -5
- package/dist/job-inTmXxpa.mjs.map +1 -0
- package/dist/{list-4T6XN_zi.mjs → list-B8Uv3SPW.mjs} +936 -397
- package/dist/list-B8Uv3SPW.mjs.map +1 -0
- package/dist/{types-CrOeSu4i.d.mts → types-DBHXcgFJ.d.mts} +53 -40
- package/dist/utils/test/index.d.mts +2 -2
- package/docs/cli-reference.md +122 -0
- package/docs/core-concepts.md +2 -2
- package/package.json +2 -2
- package/dist/job-wYkb6yMl.mjs.map +0 -1
- package/dist/list-4T6XN_zi.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @tailor-platform/sdk
|
|
2
2
|
|
|
3
|
+
## 0.14.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124](https://github.com/tailor-platform/sdk/pull/124) [`6d96fdb`](https://github.com/tailor-platform/sdk/commit/6d96fdbbecc225e9906b9c0b2225a733dd8fc4d8) Thanks [@toiroakr](https://github.com/toiroakr)! - Add workflow trigger functionality
|
|
8
|
+
- Add `trigger` method to `Workflow` type that allows triggering workflows from resolvers and executors
|
|
9
|
+
- Support `authInvoker` option for authentication when triggering workflows
|
|
10
|
+
|
|
11
|
+
**Breaking Changes**
|
|
12
|
+
- AuthInvoker field names changed:
|
|
13
|
+
- `authName` → `namespace`
|
|
14
|
+
- `machineUser` → `machineUserName`
|
|
15
|
+
- This affects both `auth.invoker()` return value and direct object usage in executor's `authInvoker` option
|
|
16
|
+
- Executor operation field renamed:
|
|
17
|
+
- `invoker` → `authInvoker`
|
|
18
|
+
- SecretValue field names changed:
|
|
19
|
+
- `VaultName` → `vaultName`
|
|
20
|
+
- `SecretKey` → `secretKey`
|
|
21
|
+
|
|
22
|
+
## 0.13.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- [#121](https://github.com/tailor-platform/sdk/pull/121) [`bc7a3e9`](https://github.com/tailor-platform/sdk/commit/bc7a3e96b4805e75fcb153220d286abaced26368) Thanks [@toiroakr](https://github.com/toiroakr)! - Streamline workflow job function registration and trigger handling
|
|
27
|
+
|
|
28
|
+
**Breaking Changes:**
|
|
29
|
+
- Removed `deps` property from `createWorkflowJob()` - jobs no longer declare dependencies explicitly
|
|
30
|
+
- Removed `jobs` object from `WorkflowJobContext` - use `.trigger()` method instead
|
|
31
|
+
- Changed the way workflow jobs call other jobs: from `jobs.job_name()` to `otherJob.trigger()`
|
|
32
|
+
|
|
33
|
+
**Migration Guide:**
|
|
34
|
+
|
|
35
|
+
Before:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
export const fetchCustomer = createWorkflowJob({
|
|
39
|
+
name: "fetch-customer",
|
|
40
|
+
body: async (input: { customerId: string }) => {
|
|
41
|
+
// fetch logic
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const processOrder = createWorkflowJob({
|
|
46
|
+
name: "process-order",
|
|
47
|
+
deps: [fetchCustomer],
|
|
48
|
+
body: async (input, { jobs }) => {
|
|
49
|
+
const customer = await jobs.fetch_customer({
|
|
50
|
+
customerId: input.customerId,
|
|
51
|
+
});
|
|
52
|
+
return { customer };
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
After:
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
export const fetchCustomer = createWorkflowJob({
|
|
61
|
+
name: "fetch-customer",
|
|
62
|
+
body: async (input: { customerId: string }) => {
|
|
63
|
+
// fetch logic
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export const processOrder = createWorkflowJob({
|
|
68
|
+
name: "process-order",
|
|
69
|
+
body: async (input, { env }) => {
|
|
70
|
+
const customer = await fetchCustomer.trigger({
|
|
71
|
+
customerId: input.customerId,
|
|
72
|
+
});
|
|
73
|
+
return { customer };
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Key Changes:**
|
|
79
|
+
- Dependencies are now automatically detected via AST analysis of `.trigger()` calls at bundle time
|
|
80
|
+
- The `.trigger()` method is transformed to `tailor.workflow.triggerJobFunction()` during bundling
|
|
81
|
+
- Job function registration is optimized - all job functions are registered once and shared across workflows
|
|
82
|
+
- Unused jobs (not reachable from any mainJob via trigger calls) are automatically excluded from bundles
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- [#102](https://github.com/tailor-platform/sdk/pull/102) [`ac99d85`](https://github.com/tailor-platform/sdk/commit/ac99d8506693e27512a3ff59c5c8e4fda63b4695) Thanks [@riku99](https://github.com/riku99)! - Add CLI commands for managing Secret Manager vaults and secrets
|
|
87
|
+
|
|
3
88
|
## 0.12.4
|
|
4
89
|
|
|
5
90
|
### Patch Changes
|
package/dist/cli/api.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="./../user-defined.d.ts" />
|
|
2
2
|
|
|
3
|
-
import { AppConfig, CodeGeneratorBase, Executor, Generator, IdProviderConfig, OAuth2Client, Resolver, TailorDBTypeConfig } from "../types-
|
|
3
|
+
import { AppConfig, CodeGeneratorBase, Executor, Generator, IdProviderConfig, OAuth2Client, Resolver, TailorDBTypeConfig } from "../types-DBHXcgFJ.mjs";
|
|
4
4
|
import "citty";
|
|
5
5
|
import "zod";
|
|
6
6
|
import "@bufbuild/protobuf/wkt";
|
package/dist/cli/api.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workspaceCreate, workspaceDelete, workspaceList } from "../list-
|
|
2
|
-
import "../job-
|
|
1
|
+
import { apply, generate, generateUserTypes, loadConfig, machineUserList, machineUserToken, oauth2ClientGet, oauth2ClientList, remove, show, workspaceCreate, workspaceDelete, workspaceList } from "../list-B8Uv3SPW.mjs";
|
|
2
|
+
import "../job-inTmXxpa.mjs";
|
|
3
3
|
import { register } from "node:module";
|
|
4
4
|
|
|
5
5
|
//#region src/cli/api.ts
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, initOAuth2Client, initOperatorClient, listCommand as listCommand$
|
|
3
|
-
import "../job-
|
|
2
|
+
import { PATScope, applyCommand, commonArgs, createCommand, deleteCommand, fetchAll, fetchLatestToken, fetchUserInfo, formatArgs, generateCommand, getCommand, initOAuth2Client, initOperatorClient, listCommand as listCommand$5, listCommand$1 as listCommand$6, listCommand$2 as listCommand, loadAccessToken, loadConfig, loadWorkspaceId, parseFormat, printWithFormat, readPackageJson, readPlatformConfig, removeCommand, showCommand, tokenCommand, withCommonArgs, writePlatformConfig } from "../list-B8Uv3SPW.mjs";
|
|
3
|
+
import "../job-inTmXxpa.mjs";
|
|
4
4
|
import { register } from "node:module";
|
|
5
5
|
import { defineCommand, runCommand, runMain } from "citty";
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import ml from "multiline-ts";
|
|
8
8
|
import { consola } from "consola";
|
|
9
9
|
import { generateCodeVerifier } from "@badgateway/oauth2-client";
|
|
10
|
+
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
|
11
|
+
import { Code, ConnectError } from "@connectrpc/connect";
|
|
10
12
|
import chalk from "chalk";
|
|
11
13
|
import { spawnSync } from "node:child_process";
|
|
12
14
|
import * as crypto from "node:crypto";
|
|
@@ -183,11 +185,11 @@ const machineuserCommand = defineCommand({
|
|
|
183
185
|
description: "Manage machine users"
|
|
184
186
|
},
|
|
185
187
|
subCommands: {
|
|
186
|
-
list: listCommand$
|
|
188
|
+
list: listCommand$6,
|
|
187
189
|
token: tokenCommand
|
|
188
190
|
},
|
|
189
191
|
async run() {
|
|
190
|
-
await runCommand(listCommand$
|
|
192
|
+
await runCommand(listCommand$6, { rawArgs: [] });
|
|
191
193
|
}
|
|
192
194
|
});
|
|
193
195
|
|
|
@@ -200,16 +202,16 @@ const oauth2clientCommand = defineCommand({
|
|
|
200
202
|
},
|
|
201
203
|
subCommands: {
|
|
202
204
|
get: getCommand,
|
|
203
|
-
list: listCommand$
|
|
205
|
+
list: listCommand$5
|
|
204
206
|
},
|
|
205
207
|
async run() {
|
|
206
|
-
await runCommand(listCommand$
|
|
208
|
+
await runCommand(listCommand$5, { rawArgs: [] });
|
|
207
209
|
}
|
|
208
210
|
});
|
|
209
211
|
|
|
210
212
|
//#endregion
|
|
211
213
|
//#region src/cli/profile/create.ts
|
|
212
|
-
const createCommand$
|
|
214
|
+
const createCommand$3 = defineCommand({
|
|
213
215
|
meta: {
|
|
214
216
|
name: "create",
|
|
215
217
|
description: "Create new profile"
|
|
@@ -262,7 +264,7 @@ const createCommand$2 = defineCommand({
|
|
|
262
264
|
|
|
263
265
|
//#endregion
|
|
264
266
|
//#region src/cli/profile/delete.ts
|
|
265
|
-
const deleteCommand$
|
|
267
|
+
const deleteCommand$3 = defineCommand({
|
|
266
268
|
meta: {
|
|
267
269
|
name: "delete",
|
|
268
270
|
description: "Delete profile"
|
|
@@ -286,7 +288,7 @@ const deleteCommand$2 = defineCommand({
|
|
|
286
288
|
|
|
287
289
|
//#endregion
|
|
288
290
|
//#region src/cli/profile/list.ts
|
|
289
|
-
const listCommand$
|
|
291
|
+
const listCommand$4 = defineCommand({
|
|
290
292
|
meta: {
|
|
291
293
|
name: "list",
|
|
292
294
|
description: "List all profiles"
|
|
@@ -377,17 +379,474 @@ const profileCommand = defineCommand({
|
|
|
377
379
|
name: "profile",
|
|
378
380
|
description: "Manage workspace profiles (user + workspace combinations)"
|
|
379
381
|
},
|
|
382
|
+
subCommands: {
|
|
383
|
+
create: createCommand$3,
|
|
384
|
+
delete: deleteCommand$3,
|
|
385
|
+
list: listCommand$4,
|
|
386
|
+
update: updateCommand$1
|
|
387
|
+
},
|
|
388
|
+
async run() {
|
|
389
|
+
await runCommand(listCommand$4, { rawArgs: [] });
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/cli/secret/create.ts
|
|
395
|
+
const createSecretCommand = defineCommand({
|
|
396
|
+
meta: {
|
|
397
|
+
name: "create",
|
|
398
|
+
description: "Create a secret in a vault"
|
|
399
|
+
},
|
|
400
|
+
args: {
|
|
401
|
+
...commonArgs,
|
|
402
|
+
"workspace-id": {
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Workspace ID",
|
|
405
|
+
alias: "w"
|
|
406
|
+
},
|
|
407
|
+
profile: {
|
|
408
|
+
type: "string",
|
|
409
|
+
description: "Workspace profile",
|
|
410
|
+
alias: "p"
|
|
411
|
+
},
|
|
412
|
+
"vault-name": {
|
|
413
|
+
type: "string",
|
|
414
|
+
description: "Vault name",
|
|
415
|
+
required: true
|
|
416
|
+
},
|
|
417
|
+
name: {
|
|
418
|
+
type: "string",
|
|
419
|
+
description: "Secret name",
|
|
420
|
+
required: true
|
|
421
|
+
},
|
|
422
|
+
value: {
|
|
423
|
+
type: "string",
|
|
424
|
+
description: "Secret value",
|
|
425
|
+
required: true
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
run: withCommonArgs(async (args) => {
|
|
429
|
+
const accessToken = await loadAccessToken({
|
|
430
|
+
useProfile: true,
|
|
431
|
+
profile: args.profile
|
|
432
|
+
});
|
|
433
|
+
const client = await initOperatorClient(accessToken);
|
|
434
|
+
const workspaceId = loadWorkspaceId({
|
|
435
|
+
workspaceId: args["workspace-id"],
|
|
436
|
+
profile: args.profile
|
|
437
|
+
});
|
|
438
|
+
try {
|
|
439
|
+
await client.createSecretManagerSecret({
|
|
440
|
+
workspaceId,
|
|
441
|
+
secretmanagerVaultName: args["vault-name"],
|
|
442
|
+
secretmanagerSecretName: args.name,
|
|
443
|
+
secretmanagerSecretValue: args.value
|
|
444
|
+
});
|
|
445
|
+
} catch (error) {
|
|
446
|
+
if (error instanceof ConnectError) {
|
|
447
|
+
if (error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
|
|
448
|
+
if (error.code === Code.AlreadyExists) throw new Error(`Secret "${args.name}" already exists.`);
|
|
449
|
+
}
|
|
450
|
+
throw error;
|
|
451
|
+
}
|
|
452
|
+
consola.success(`Secret: ${args.name} created in vault: ${args["vault-name"]}`);
|
|
453
|
+
})
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/cli/secret/delete.ts
|
|
458
|
+
const deleteSecretCommand = defineCommand({
|
|
459
|
+
meta: {
|
|
460
|
+
name: "delete",
|
|
461
|
+
description: "Delete a secret in a vault"
|
|
462
|
+
},
|
|
463
|
+
args: {
|
|
464
|
+
...commonArgs,
|
|
465
|
+
"workspace-id": {
|
|
466
|
+
type: "string",
|
|
467
|
+
description: "Workspace ID",
|
|
468
|
+
alias: "w"
|
|
469
|
+
},
|
|
470
|
+
profile: {
|
|
471
|
+
type: "string",
|
|
472
|
+
description: "Workspace profile",
|
|
473
|
+
alias: "p"
|
|
474
|
+
},
|
|
475
|
+
"vault-name": {
|
|
476
|
+
type: "string",
|
|
477
|
+
description: "Vault name",
|
|
478
|
+
required: true
|
|
479
|
+
},
|
|
480
|
+
name: {
|
|
481
|
+
type: "string",
|
|
482
|
+
description: "Secret name",
|
|
483
|
+
required: true
|
|
484
|
+
},
|
|
485
|
+
yes: {
|
|
486
|
+
type: "boolean",
|
|
487
|
+
description: "Skip confirmation prompt",
|
|
488
|
+
alias: "y",
|
|
489
|
+
default: false
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
run: withCommonArgs(async (args) => {
|
|
493
|
+
const accessToken = await loadAccessToken({
|
|
494
|
+
useProfile: true,
|
|
495
|
+
profile: args.profile
|
|
496
|
+
});
|
|
497
|
+
const client = await initOperatorClient(accessToken);
|
|
498
|
+
const workspaceId = loadWorkspaceId({
|
|
499
|
+
workspaceId: args["workspace-id"],
|
|
500
|
+
profile: args.profile
|
|
501
|
+
});
|
|
502
|
+
if (!args.yes) {
|
|
503
|
+
if (await consola.prompt(`Enter the secret name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
|
|
504
|
+
consola.info("Secret deletion cancelled.");
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
try {
|
|
509
|
+
await client.deleteSecretManagerSecret({
|
|
510
|
+
workspaceId,
|
|
511
|
+
secretmanagerVaultName: args["vault-name"],
|
|
512
|
+
secretmanagerSecretName: args.name
|
|
513
|
+
});
|
|
514
|
+
} catch (error) {
|
|
515
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
|
|
516
|
+
throw error;
|
|
517
|
+
}
|
|
518
|
+
consola.success(`Secret: ${args.name} deleted from vault: ${args["vault-name"]}`);
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
|
|
522
|
+
//#endregion
|
|
523
|
+
//#region src/cli/secret/list.ts
|
|
524
|
+
function secretInfo(secret) {
|
|
525
|
+
return {
|
|
526
|
+
name: secret.name,
|
|
527
|
+
createdAt: secret.createTime ? timestampDate(secret.createTime).toISOString() : "N/A",
|
|
528
|
+
updatedAt: secret.updateTime ? timestampDate(secret.updateTime).toISOString() : "N/A"
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
async function secretList(options) {
|
|
532
|
+
const accessToken = await loadAccessToken({
|
|
533
|
+
useProfile: true,
|
|
534
|
+
profile: options.profile
|
|
535
|
+
});
|
|
536
|
+
const client = await initOperatorClient(accessToken);
|
|
537
|
+
const workspaceId = loadWorkspaceId({
|
|
538
|
+
workspaceId: options.workspaceId,
|
|
539
|
+
profile: options.profile
|
|
540
|
+
});
|
|
541
|
+
return (await fetchAll(async (pageToken) => {
|
|
542
|
+
const { secrets, nextPageToken } = await client.listSecretManagerSecrets({
|
|
543
|
+
workspaceId,
|
|
544
|
+
secretmanagerVaultName: options.vaultName,
|
|
545
|
+
pageToken
|
|
546
|
+
});
|
|
547
|
+
return [secrets, nextPageToken];
|
|
548
|
+
})).map(secretInfo);
|
|
549
|
+
}
|
|
550
|
+
const listSecretCommand = defineCommand({
|
|
551
|
+
meta: {
|
|
552
|
+
name: "list",
|
|
553
|
+
description: "List secrets in a vault"
|
|
554
|
+
},
|
|
555
|
+
args: {
|
|
556
|
+
...commonArgs,
|
|
557
|
+
...formatArgs,
|
|
558
|
+
"workspace-id": {
|
|
559
|
+
type: "string",
|
|
560
|
+
description: "Workspace ID",
|
|
561
|
+
alias: "w"
|
|
562
|
+
},
|
|
563
|
+
profile: {
|
|
564
|
+
type: "string",
|
|
565
|
+
description: "Workspace profile",
|
|
566
|
+
alias: "p"
|
|
567
|
+
},
|
|
568
|
+
"vault-name": {
|
|
569
|
+
type: "string",
|
|
570
|
+
description: "Vault name",
|
|
571
|
+
required: true
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
run: withCommonArgs(async (args) => {
|
|
575
|
+
const format = parseFormat(args.format);
|
|
576
|
+
try {
|
|
577
|
+
const secrets = await secretList({
|
|
578
|
+
workspaceId: args["workspace-id"],
|
|
579
|
+
profile: args.profile,
|
|
580
|
+
vaultName: args["vault-name"]
|
|
581
|
+
});
|
|
582
|
+
printWithFormat(secrets, format);
|
|
583
|
+
} catch (error) {
|
|
584
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args["vault-name"]}" not found.`);
|
|
585
|
+
throw error;
|
|
586
|
+
}
|
|
587
|
+
})
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/cli/secret/update.ts
|
|
592
|
+
const updateSecretCommand = defineCommand({
|
|
593
|
+
meta: {
|
|
594
|
+
name: "update",
|
|
595
|
+
description: "Update a secret in a vault"
|
|
596
|
+
},
|
|
597
|
+
args: {
|
|
598
|
+
...commonArgs,
|
|
599
|
+
"workspace-id": {
|
|
600
|
+
type: "string",
|
|
601
|
+
description: "Workspace ID",
|
|
602
|
+
alias: "w"
|
|
603
|
+
},
|
|
604
|
+
profile: {
|
|
605
|
+
type: "string",
|
|
606
|
+
description: "Workspace profile",
|
|
607
|
+
alias: "p"
|
|
608
|
+
},
|
|
609
|
+
"vault-name": {
|
|
610
|
+
type: "string",
|
|
611
|
+
description: "Vault name",
|
|
612
|
+
required: true
|
|
613
|
+
},
|
|
614
|
+
name: {
|
|
615
|
+
type: "string",
|
|
616
|
+
description: "Secret name",
|
|
617
|
+
required: true
|
|
618
|
+
},
|
|
619
|
+
value: {
|
|
620
|
+
type: "string",
|
|
621
|
+
description: "Secret value",
|
|
622
|
+
required: true
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
run: withCommonArgs(async (args) => {
|
|
626
|
+
const accessToken = await loadAccessToken({
|
|
627
|
+
useProfile: true,
|
|
628
|
+
profile: args.profile
|
|
629
|
+
});
|
|
630
|
+
const client = await initOperatorClient(accessToken);
|
|
631
|
+
const workspaceId = loadWorkspaceId({
|
|
632
|
+
workspaceId: args["workspace-id"],
|
|
633
|
+
profile: args.profile
|
|
634
|
+
});
|
|
635
|
+
try {
|
|
636
|
+
await client.updateSecretManagerSecret({
|
|
637
|
+
workspaceId,
|
|
638
|
+
secretmanagerVaultName: args["vault-name"],
|
|
639
|
+
secretmanagerSecretName: args.name,
|
|
640
|
+
secretmanagerSecretValue: args.value
|
|
641
|
+
});
|
|
642
|
+
} catch (error) {
|
|
643
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Secret "${args.name}" not found in vault "${args["vault-name"]}".`);
|
|
644
|
+
throw error;
|
|
645
|
+
}
|
|
646
|
+
consola.success(`Secret: ${args.name} updated in vault: ${args["vault-name"]}`);
|
|
647
|
+
})
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/cli/secret/vault/create.ts
|
|
652
|
+
const createCommand$2 = defineCommand({
|
|
653
|
+
meta: {
|
|
654
|
+
name: "create",
|
|
655
|
+
description: "Create a Secret Manager vault"
|
|
656
|
+
},
|
|
657
|
+
args: {
|
|
658
|
+
...commonArgs,
|
|
659
|
+
"workspace-id": {
|
|
660
|
+
type: "string",
|
|
661
|
+
description: "Workspace ID",
|
|
662
|
+
alias: "w"
|
|
663
|
+
},
|
|
664
|
+
profile: {
|
|
665
|
+
type: "string",
|
|
666
|
+
description: "Workspace profile",
|
|
667
|
+
alias: "p"
|
|
668
|
+
},
|
|
669
|
+
name: {
|
|
670
|
+
type: "string",
|
|
671
|
+
description: "Vault name",
|
|
672
|
+
required: true
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
run: withCommonArgs(async (args) => {
|
|
676
|
+
const accessToken = await loadAccessToken({
|
|
677
|
+
useProfile: true,
|
|
678
|
+
profile: args.profile
|
|
679
|
+
});
|
|
680
|
+
const client = await initOperatorClient(accessToken);
|
|
681
|
+
const workspaceId = loadWorkspaceId({
|
|
682
|
+
workspaceId: args["workspace-id"],
|
|
683
|
+
profile: args.profile
|
|
684
|
+
});
|
|
685
|
+
try {
|
|
686
|
+
await client.createSecretManagerVault({
|
|
687
|
+
workspaceId,
|
|
688
|
+
secretmanagerVaultName: args.name
|
|
689
|
+
});
|
|
690
|
+
} catch (error) {
|
|
691
|
+
if (error instanceof ConnectError && error.code === Code.AlreadyExists) throw new Error(`Vault "${args.name}" already exists.`);
|
|
692
|
+
throw error;
|
|
693
|
+
}
|
|
694
|
+
consola.success(`Vault: ${args.name} created`);
|
|
695
|
+
})
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/cli/secret/vault/delete.ts
|
|
700
|
+
const deleteCommand$2 = defineCommand({
|
|
701
|
+
meta: {
|
|
702
|
+
name: "delete",
|
|
703
|
+
description: "Delete a Secret Manager vault"
|
|
704
|
+
},
|
|
705
|
+
args: {
|
|
706
|
+
...commonArgs,
|
|
707
|
+
"workspace-id": {
|
|
708
|
+
type: "string",
|
|
709
|
+
description: "Workspace ID",
|
|
710
|
+
alias: "w"
|
|
711
|
+
},
|
|
712
|
+
profile: {
|
|
713
|
+
type: "string",
|
|
714
|
+
description: "Workspace profile",
|
|
715
|
+
alias: "p"
|
|
716
|
+
},
|
|
717
|
+
name: {
|
|
718
|
+
type: "string",
|
|
719
|
+
description: "Vault name",
|
|
720
|
+
required: true
|
|
721
|
+
},
|
|
722
|
+
yes: {
|
|
723
|
+
type: "boolean",
|
|
724
|
+
description: "Skip confirmation prompt",
|
|
725
|
+
alias: "y",
|
|
726
|
+
default: false
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
run: withCommonArgs(async (args) => {
|
|
730
|
+
const accessToken = await loadAccessToken({
|
|
731
|
+
useProfile: true,
|
|
732
|
+
profile: args.profile
|
|
733
|
+
});
|
|
734
|
+
const client = await initOperatorClient(accessToken);
|
|
735
|
+
const workspaceId = loadWorkspaceId({
|
|
736
|
+
workspaceId: args["workspace-id"],
|
|
737
|
+
profile: args.profile
|
|
738
|
+
});
|
|
739
|
+
if (!args.yes) {
|
|
740
|
+
if (await consola.prompt(`Enter the vault name to confirm deletion ("${args.name}"): `, { type: "text" }) !== args.name) {
|
|
741
|
+
consola.info("Vault deletion cancelled.");
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
try {
|
|
746
|
+
await client.deleteSecretManagerVault({
|
|
747
|
+
workspaceId,
|
|
748
|
+
secretmanagerVaultName: args.name
|
|
749
|
+
});
|
|
750
|
+
} catch (error) {
|
|
751
|
+
if (error instanceof ConnectError && error.code === Code.NotFound) throw new Error(`Vault "${args.name}" not found.`);
|
|
752
|
+
throw error;
|
|
753
|
+
}
|
|
754
|
+
consola.success(`Vault: ${args.name} deleted`);
|
|
755
|
+
})
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/cli/secret/vault/list.ts
|
|
760
|
+
function vaultInfo(vault) {
|
|
761
|
+
return {
|
|
762
|
+
name: vault.name,
|
|
763
|
+
createdAt: vault.createTime ? timestampDate(vault.createTime).toISOString() : "N/A",
|
|
764
|
+
updatedAt: vault.updateTime ? timestampDate(vault.updateTime).toISOString() : "N/A"
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
async function vaultList(options) {
|
|
768
|
+
const accessToken = await loadAccessToken({
|
|
769
|
+
useProfile: true,
|
|
770
|
+
profile: options?.profile
|
|
771
|
+
});
|
|
772
|
+
const client = await initOperatorClient(accessToken);
|
|
773
|
+
const workspaceId = loadWorkspaceId({
|
|
774
|
+
workspaceId: options?.workspaceId,
|
|
775
|
+
profile: options?.profile
|
|
776
|
+
});
|
|
777
|
+
return (await fetchAll(async (pageToken) => {
|
|
778
|
+
const { vaults, nextPageToken } = await client.listSecretManagerVaults({
|
|
779
|
+
workspaceId,
|
|
780
|
+
pageToken
|
|
781
|
+
});
|
|
782
|
+
return [vaults, nextPageToken];
|
|
783
|
+
})).map(vaultInfo);
|
|
784
|
+
}
|
|
785
|
+
const listCommand$3 = defineCommand({
|
|
786
|
+
meta: {
|
|
787
|
+
name: "list",
|
|
788
|
+
description: "List Secret Manager vaults"
|
|
789
|
+
},
|
|
790
|
+
args: {
|
|
791
|
+
...commonArgs,
|
|
792
|
+
...formatArgs,
|
|
793
|
+
"workspace-id": {
|
|
794
|
+
type: "string",
|
|
795
|
+
description: "Workspace ID",
|
|
796
|
+
alias: "w"
|
|
797
|
+
},
|
|
798
|
+
profile: {
|
|
799
|
+
type: "string",
|
|
800
|
+
description: "Workspace profile",
|
|
801
|
+
alias: "p"
|
|
802
|
+
}
|
|
803
|
+
},
|
|
804
|
+
run: withCommonArgs(async (args) => {
|
|
805
|
+
const format = parseFormat(args.format);
|
|
806
|
+
const vaults = await vaultList({
|
|
807
|
+
workspaceId: args["workspace-id"],
|
|
808
|
+
profile: args.profile
|
|
809
|
+
});
|
|
810
|
+
printWithFormat(vaults, format);
|
|
811
|
+
})
|
|
812
|
+
});
|
|
813
|
+
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/cli/secret/vault/index.ts
|
|
816
|
+
const vaultCommand = defineCommand({
|
|
817
|
+
meta: {
|
|
818
|
+
name: "vault",
|
|
819
|
+
description: "Manage Secret Manager vaults"
|
|
820
|
+
},
|
|
380
821
|
subCommands: {
|
|
381
822
|
create: createCommand$2,
|
|
382
823
|
delete: deleteCommand$2,
|
|
383
|
-
list: listCommand$3
|
|
384
|
-
update: updateCommand$1
|
|
824
|
+
list: listCommand$3
|
|
385
825
|
},
|
|
386
826
|
async run() {
|
|
387
827
|
await runCommand(listCommand$3, { rawArgs: [] });
|
|
388
828
|
}
|
|
389
829
|
});
|
|
390
830
|
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region src/cli/secret/index.ts
|
|
833
|
+
const secretCommand = defineCommand({
|
|
834
|
+
meta: {
|
|
835
|
+
name: "secret",
|
|
836
|
+
description: "Manage secrets and vaults"
|
|
837
|
+
},
|
|
838
|
+
subCommands: {
|
|
839
|
+
create: createSecretCommand,
|
|
840
|
+
delete: deleteSecretCommand,
|
|
841
|
+
list: listSecretCommand,
|
|
842
|
+
update: updateSecretCommand,
|
|
843
|
+
vault: vaultCommand
|
|
844
|
+
},
|
|
845
|
+
async run() {
|
|
846
|
+
await runCommand(vaultCommand, { rawArgs: [] });
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
|
|
391
850
|
//#endregion
|
|
392
851
|
//#region src/cli/tailordb/truncate.ts
|
|
393
852
|
async function truncateSingleType(options, client) {
|
|
@@ -948,6 +1407,7 @@ const mainCommand = defineCommand({
|
|
|
948
1407
|
remove: removeCommand,
|
|
949
1408
|
show: showCommand,
|
|
950
1409
|
tailordb: tailordbCommand,
|
|
1410
|
+
secret: secretCommand,
|
|
951
1411
|
user: userCommand,
|
|
952
1412
|
workspace: workspaceCommand
|
|
953
1413
|
}
|