@sanity/runtime-cli 15.2.0 → 15.2.1
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/README.md +20 -20
- package/dist/actions/blueprints/logs.js +22 -12
- package/dist/actions/blueprints/operations.d.ts +1 -1
- package/dist/actions/blueprints/operations.js +19 -11
- package/dist/actions/blueprints/stacks.d.ts +30 -16
- package/dist/actions/blueprints/stacks.js +136 -77
- package/dist/cores/blueprints/stacks.js +3 -0
- package/dist/utils/traced-fetch.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/15.2.
|
|
23
|
+
@sanity/runtime-cli/15.2.1 linux-x64 node-v24.16.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -103,7 +103,7 @@ EXAMPLES
|
|
|
103
103
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
106
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/add.ts)_
|
|
107
107
|
|
|
108
108
|
## `sanity-run blueprints config`
|
|
109
109
|
|
|
@@ -140,7 +140,7 @@ EXAMPLES
|
|
|
140
140
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
143
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/config.ts)_
|
|
144
144
|
|
|
145
145
|
## `sanity-run blueprints deploy`
|
|
146
146
|
|
|
@@ -194,7 +194,7 @@ EXAMPLES
|
|
|
194
194
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
195
195
|
```
|
|
196
196
|
|
|
197
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
197
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/deploy.ts)_
|
|
198
198
|
|
|
199
199
|
## `sanity-run blueprints destroy`
|
|
200
200
|
|
|
@@ -232,7 +232,7 @@ EXAMPLES
|
|
|
232
232
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
235
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/destroy.ts)_
|
|
236
236
|
|
|
237
237
|
## `sanity-run blueprints doctor`
|
|
238
238
|
|
|
@@ -263,7 +263,7 @@ EXAMPLES
|
|
|
263
263
|
$ sanity-run blueprints doctor --fix
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
266
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/doctor.ts)_
|
|
267
267
|
|
|
268
268
|
## `sanity-run blueprints info`
|
|
269
269
|
|
|
@@ -300,7 +300,7 @@ EXAMPLES
|
|
|
300
300
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
303
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/info.ts)_
|
|
304
304
|
|
|
305
305
|
## `sanity-run blueprints init [DIR]`
|
|
306
306
|
|
|
@@ -359,7 +359,7 @@ EXAMPLES
|
|
|
359
359
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
360
360
|
```
|
|
361
361
|
|
|
362
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
362
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/init.ts)_
|
|
363
363
|
|
|
364
364
|
## `sanity-run blueprints logs`
|
|
365
365
|
|
|
@@ -405,7 +405,7 @@ EXAMPLES
|
|
|
405
405
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
406
406
|
```
|
|
407
407
|
|
|
408
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
408
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/logs.ts)_
|
|
409
409
|
|
|
410
410
|
## `sanity-run blueprints mint-deploy-token`
|
|
411
411
|
|
|
@@ -450,7 +450,7 @@ EXAMPLES
|
|
|
450
450
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
451
451
|
```
|
|
452
452
|
|
|
453
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
453
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/mint-deploy-token.ts)_
|
|
454
454
|
|
|
455
455
|
## `sanity-run blueprints plan`
|
|
456
456
|
|
|
@@ -483,7 +483,7 @@ EXAMPLES
|
|
|
483
483
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
484
484
|
```
|
|
485
485
|
|
|
486
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
486
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/plan.ts)_
|
|
487
487
|
|
|
488
488
|
## `sanity-run blueprints promote`
|
|
489
489
|
|
|
@@ -519,7 +519,7 @@ EXAMPLES
|
|
|
519
519
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
520
520
|
```
|
|
521
521
|
|
|
522
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
522
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/promote.ts)_
|
|
523
523
|
|
|
524
524
|
## `sanity-run blueprints stacks`
|
|
525
525
|
|
|
@@ -555,7 +555,7 @@ EXAMPLES
|
|
|
555
555
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
556
556
|
```
|
|
557
557
|
|
|
558
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
558
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/blueprints/stacks.ts)_
|
|
559
559
|
|
|
560
560
|
## `sanity-run functions add`
|
|
561
561
|
|
|
@@ -607,7 +607,7 @@ EXAMPLES
|
|
|
607
607
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
608
608
|
```
|
|
609
609
|
|
|
610
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
610
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/add.ts)_
|
|
611
611
|
|
|
612
612
|
## `sanity-run functions dev`
|
|
613
613
|
|
|
@@ -642,7 +642,7 @@ EXAMPLES
|
|
|
642
642
|
$ sanity-run functions dev --timeout 60
|
|
643
643
|
```
|
|
644
644
|
|
|
645
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
645
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/dev.ts)_
|
|
646
646
|
|
|
647
647
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
648
648
|
|
|
@@ -672,7 +672,7 @@ EXAMPLES
|
|
|
672
672
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
673
673
|
```
|
|
674
674
|
|
|
675
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
675
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/env/add.ts)_
|
|
676
676
|
|
|
677
677
|
## `sanity-run functions env list NAME`
|
|
678
678
|
|
|
@@ -699,7 +699,7 @@ EXAMPLES
|
|
|
699
699
|
$ sanity-run functions env list MyFunction
|
|
700
700
|
```
|
|
701
701
|
|
|
702
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
702
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/env/list.ts)_
|
|
703
703
|
|
|
704
704
|
## `sanity-run functions env remove NAME KEY`
|
|
705
705
|
|
|
@@ -728,7 +728,7 @@ EXAMPLES
|
|
|
728
728
|
$ sanity-run functions env remove MyFunction API_URL
|
|
729
729
|
```
|
|
730
730
|
|
|
731
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
731
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/env/remove.ts)_
|
|
732
732
|
|
|
733
733
|
## `sanity-run functions logs [NAME]`
|
|
734
734
|
|
|
@@ -768,7 +768,7 @@ EXAMPLES
|
|
|
768
768
|
$ sanity-run functions logs <name> --delete
|
|
769
769
|
```
|
|
770
770
|
|
|
771
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
771
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/logs.ts)_
|
|
772
772
|
|
|
773
773
|
## `sanity-run functions test [NAME]`
|
|
774
774
|
|
|
@@ -825,7 +825,7 @@ EXAMPLES
|
|
|
825
825
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
826
826
|
```
|
|
827
827
|
|
|
828
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.
|
|
828
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.1/src/commands/functions/test.ts)_
|
|
829
829
|
|
|
830
830
|
## `sanity-run help [COMMAND]`
|
|
831
831
|
|
|
@@ -16,16 +16,26 @@ export async function getLogs(params, auth, logger) {
|
|
|
16
16
|
url.searchParams.append('before', params.before);
|
|
17
17
|
if (params.after)
|
|
18
18
|
url.searchParams.append('after', params.after);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetchFn(url.toString(), {
|
|
21
|
+
headers: getHeaders(auth),
|
|
22
|
+
method: 'GET',
|
|
23
|
+
});
|
|
24
|
+
const result = await response.json();
|
|
25
|
+
const hasMore = response.headers.get('X-Has-More') === 'true';
|
|
26
|
+
return {
|
|
27
|
+
ok: response.ok,
|
|
28
|
+
error: response.ok ? null : result.message || 'Unknown error',
|
|
29
|
+
logs: response.ok ? result : [],
|
|
30
|
+
hasMore: response.ok ? hasMore : false,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
error: error instanceof Error ? error.message : String(error),
|
|
37
|
+
logs: [],
|
|
38
|
+
hasMore: false,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
31
41
|
}
|
|
@@ -17,7 +17,7 @@ export declare function classifyOperationPoll(options: {
|
|
|
17
17
|
operation: StackOperation | undefined;
|
|
18
18
|
}): 'pending' | 'completed' | 'failed' | 'error';
|
|
19
19
|
interface GetOperationResponse extends ActionResponse {
|
|
20
|
-
operation
|
|
20
|
+
operation?: StackOperation;
|
|
21
21
|
response?: Response;
|
|
22
22
|
}
|
|
23
23
|
export declare function getOperation({ stackId, operationId, auth, logger, includeDestroyed, }: {
|
|
@@ -36,15 +36,23 @@ export async function getOperation({ stackId, operationId, auth, logger, include
|
|
|
36
36
|
const url = new URL(`${stacksUrl}/${stackId}/operations/${operationId}`);
|
|
37
37
|
if (includeDestroyed)
|
|
38
38
|
url.searchParams.append('includeDestroyed', 'true');
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
try {
|
|
40
|
+
const response = await fetchFn(url.toString(), {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
headers: getHeaders(auth),
|
|
43
|
+
});
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
return {
|
|
46
|
+
ok: response.ok,
|
|
47
|
+
error: response.ok ? null : data.message,
|
|
48
|
+
operation: data,
|
|
49
|
+
response,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return {
|
|
54
|
+
ok: false,
|
|
55
|
+
error: error instanceof Error ? error.message : String(error),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
50
58
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Blueprint } from '@sanity/blueprints-parser';
|
|
2
2
|
import type { Logger } from '../../utils/logger.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
|
|
4
4
|
export declare const stacksUrl: string;
|
|
5
5
|
type ListStacksResponse = {
|
|
6
6
|
ok: true;
|
|
@@ -9,21 +9,26 @@ type ListStacksResponse = {
|
|
|
9
9
|
} | {
|
|
10
10
|
ok: false;
|
|
11
11
|
error: string;
|
|
12
|
-
stacks
|
|
12
|
+
stacks?: unknown;
|
|
13
13
|
};
|
|
14
14
|
export declare function listStacks(auth: AuthParams, logger: Logger): Promise<ListStacksResponse>;
|
|
15
|
-
|
|
15
|
+
type GetStackResponse = {
|
|
16
|
+
ok: true;
|
|
17
|
+
error: null;
|
|
16
18
|
stack: Stack;
|
|
17
19
|
response?: Response;
|
|
18
|
-
}
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: string;
|
|
23
|
+
stack?: unknown;
|
|
24
|
+
response?: Response;
|
|
25
|
+
};
|
|
19
26
|
export declare function getStack({ stackId, auth, logger, }: {
|
|
20
27
|
stackId: string;
|
|
21
28
|
auth: AuthParams;
|
|
22
29
|
logger: Logger;
|
|
23
30
|
}): Promise<GetStackResponse>;
|
|
24
|
-
|
|
25
|
-
stack: Stack;
|
|
26
|
-
}
|
|
31
|
+
type CreateStackResponse = GetStackResponse;
|
|
27
32
|
export declare function createStack({ stackMutation, auth, logger, }: {
|
|
28
33
|
stackMutation: StackMutation;
|
|
29
34
|
auth: AuthParams;
|
|
@@ -36,11 +41,17 @@ export declare function createEmptyStack({ token, scopeType, scopeId, name, logg
|
|
|
36
41
|
name: string;
|
|
37
42
|
logger: Logger;
|
|
38
43
|
}): Promise<Stack>;
|
|
39
|
-
|
|
44
|
+
type UpdateStackResponse = {
|
|
45
|
+
ok: true;
|
|
46
|
+
error: null;
|
|
40
47
|
stack: Stack & {
|
|
41
48
|
operationId: string;
|
|
42
49
|
};
|
|
43
|
-
}
|
|
50
|
+
} | {
|
|
51
|
+
ok: false;
|
|
52
|
+
error: string;
|
|
53
|
+
stack?: unknown;
|
|
54
|
+
};
|
|
44
55
|
export declare function updateStack({ stackId, stackMutation, auth, logger, }: {
|
|
45
56
|
stackId: string;
|
|
46
57
|
stackMutation: StackMutation;
|
|
@@ -97,24 +108,27 @@ export declare function planStack({ stackId, document, auth, logger, }: {
|
|
|
97
108
|
auth: AuthParams;
|
|
98
109
|
logger: Logger;
|
|
99
110
|
}): Promise<PlanStackResponse>;
|
|
100
|
-
interface DestroyStackResponse extends ActionResponse {
|
|
101
|
-
stack: Stack & {
|
|
102
|
-
operationId: string;
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
111
|
export declare function resolveStackIdByNameOrId(value: string, auth: AuthParams, logger: Logger): Promise<string>;
|
|
106
|
-
|
|
112
|
+
type PromoteStackResponse = {
|
|
113
|
+
ok: true;
|
|
114
|
+
error: null;
|
|
107
115
|
stack: Stack & {
|
|
108
116
|
alreadyPromoted: boolean;
|
|
109
117
|
};
|
|
110
118
|
response?: Response;
|
|
111
|
-
}
|
|
119
|
+
} | {
|
|
120
|
+
ok: false;
|
|
121
|
+
error: string;
|
|
122
|
+
stack?: unknown;
|
|
123
|
+
response?: Response;
|
|
124
|
+
};
|
|
112
125
|
export declare function promoteStack({ stackId, auth, logger, name, }: {
|
|
113
126
|
stackId: string;
|
|
114
127
|
auth: AuthParams;
|
|
115
128
|
logger: Logger;
|
|
116
129
|
name?: string;
|
|
117
130
|
}): Promise<PromoteStackResponse>;
|
|
131
|
+
type DestroyStackResponse = UpdateStackResponse;
|
|
118
132
|
export declare function destroyStack({ stackId, auth, logger, }: {
|
|
119
133
|
stackId: string;
|
|
120
134
|
auth: AuthParams;
|
|
@@ -5,44 +5,69 @@ const { apiUrl } = config;
|
|
|
5
5
|
export const stacksUrl = `${apiUrl}vX/blueprints/stacks`;
|
|
6
6
|
export async function listStacks(auth, logger) {
|
|
7
7
|
const fetchFn = createTracedFetch(logger);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
try {
|
|
9
|
+
const response = await fetchFn(stacksUrl, {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: getHeaders(auth),
|
|
12
|
+
});
|
|
13
|
+
const data = await response.json();
|
|
14
|
+
return {
|
|
15
|
+
ok: response.ok,
|
|
16
|
+
error: response.ok ? null : data.message,
|
|
17
|
+
stacks: data,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: error instanceof Error ? error.message : String(error),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
18
26
|
}
|
|
19
27
|
export async function getStack({ stackId, auth, logger, }) {
|
|
20
28
|
const fetchFn = createTracedFetch(logger);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
31
|
+
method: 'GET',
|
|
32
|
+
headers: getHeaders(auth),
|
|
33
|
+
});
|
|
34
|
+
const data = await response.json();
|
|
35
|
+
return {
|
|
36
|
+
ok: response.ok,
|
|
37
|
+
error: response.ok ? null : data.message,
|
|
38
|
+
stack: data,
|
|
39
|
+
response,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
return {
|
|
44
|
+
ok: false,
|
|
45
|
+
error: error instanceof Error ? error.message : String(error),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
32
48
|
}
|
|
33
49
|
export async function createStack({ stackMutation, auth, logger, }) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
try {
|
|
51
|
+
const fetchFn = createTracedFetch(logger);
|
|
52
|
+
const response = await fetchFn(stacksUrl, {
|
|
53
|
+
method: 'POST',
|
|
54
|
+
headers: getHeaders(auth),
|
|
55
|
+
body: JSON.stringify({ ...stackMutation, useProjectBasedId: false }), // API defaults to true as of 2025-11-26
|
|
56
|
+
});
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
return {
|
|
59
|
+
ok: response.ok,
|
|
60
|
+
error: response.ok ? null : data.message,
|
|
61
|
+
stack: data,
|
|
62
|
+
response,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
ok: false,
|
|
68
|
+
error: error instanceof Error ? error.message : String(error),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
46
71
|
}
|
|
47
72
|
export async function createEmptyStack({ token, scopeType, scopeId, name, logger, }) {
|
|
48
73
|
if (!scopeId) {
|
|
@@ -69,40 +94,58 @@ export async function createEmptyStack({ token, scopeType, scopeId, name, logger
|
|
|
69
94
|
}
|
|
70
95
|
export async function updateStack({ stackId, stackMutation, auth, logger, }) {
|
|
71
96
|
const fetchFn = createTracedFetch(logger);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
97
|
+
try {
|
|
98
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
99
|
+
method: 'PUT',
|
|
100
|
+
headers: getHeaders(auth),
|
|
101
|
+
body: JSON.stringify(stackMutation),
|
|
102
|
+
});
|
|
103
|
+
const data = await response.json();
|
|
104
|
+
return {
|
|
105
|
+
ok: response.ok,
|
|
106
|
+
error: response.ok ? null : data.message,
|
|
107
|
+
stack: data,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
return {
|
|
112
|
+
ok: false,
|
|
113
|
+
error: error instanceof Error ? error.message : String(error),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
83
116
|
}
|
|
84
117
|
export async function planStack({ stackId, document, auth, logger, }) {
|
|
85
118
|
const fetchFn = createTracedFetch(logger);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
try {
|
|
120
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}/plan`, {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
headers: getHeaders(auth),
|
|
123
|
+
body: JSON.stringify({ document }),
|
|
124
|
+
});
|
|
125
|
+
const data = await response.json();
|
|
126
|
+
if (!response.ok) {
|
|
127
|
+
return {
|
|
128
|
+
ok: false,
|
|
129
|
+
error: data.message || 'Failed to retrieve deployment plan',
|
|
130
|
+
problems: response.status === 400 && Array.isArray(data.problems) ? data.problems : null,
|
|
131
|
+
deploymentPlan: null,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return { ok: true, error: null, problems: null, deploymentPlan: data };
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
93
137
|
return {
|
|
94
138
|
ok: false,
|
|
95
|
-
error:
|
|
96
|
-
problems:
|
|
139
|
+
error: error instanceof Error ? error.message : String(error),
|
|
140
|
+
problems: null,
|
|
97
141
|
deploymentPlan: null,
|
|
98
142
|
};
|
|
99
143
|
}
|
|
100
|
-
return { ok: true, error: null, problems: null, deploymentPlan: data };
|
|
101
144
|
}
|
|
102
145
|
export async function resolveStackIdByNameOrId(value, auth, logger) {
|
|
146
|
+
// ID prefixed w 'ST-' standard IDs: 13 old project IDs: 11
|
|
103
147
|
if (value.startsWith('ST-') && (value.length === 13 || value.length === 11))
|
|
104
148
|
return value;
|
|
105
|
-
// ID prefixed w 'ST-' standard IDs: 13 old project IDs: 11
|
|
106
149
|
const result = await listStacks(auth, logger);
|
|
107
150
|
if (!result.ok)
|
|
108
151
|
throw new Error(result.error || 'Failed to list stacks');
|
|
@@ -114,29 +157,45 @@ export async function resolveStackIdByNameOrId(value, auth, logger) {
|
|
|
114
157
|
export async function promoteStack({ stackId, auth, logger, name, }) {
|
|
115
158
|
const fetchFn = createTracedFetch(logger);
|
|
116
159
|
const hasName = typeof name === 'string' && name.length > 0;
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
160
|
+
try {
|
|
161
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}/promote`, {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: getHeaders(auth),
|
|
164
|
+
body: hasName ? JSON.stringify({ name }) : undefined,
|
|
165
|
+
});
|
|
166
|
+
const data = await response.json();
|
|
167
|
+
return {
|
|
168
|
+
ok: response.ok,
|
|
169
|
+
error: response.ok ? null : data.message,
|
|
170
|
+
stack: data,
|
|
171
|
+
response,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
return {
|
|
176
|
+
ok: false,
|
|
177
|
+
error: error instanceof Error ? error.message : String(error),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
129
180
|
}
|
|
130
181
|
export async function destroyStack({ stackId, auth, logger, }) {
|
|
131
182
|
const fetchFn = createTracedFetch(logger);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
183
|
+
try {
|
|
184
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
185
|
+
method: 'DELETE',
|
|
186
|
+
headers: getHeaders(auth),
|
|
187
|
+
});
|
|
188
|
+
const data = await response.json();
|
|
189
|
+
return {
|
|
190
|
+
ok: response.ok,
|
|
191
|
+
error: response.ok ? null : data.message,
|
|
192
|
+
stack: data,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
return {
|
|
197
|
+
ok: false,
|
|
198
|
+
error: error instanceof Error ? error.message : String(error),
|
|
199
|
+
};
|
|
200
|
+
}
|
|
142
201
|
}
|
|
@@ -179,7 +179,7 @@ export function createTracedFetch(logger, options) {
|
|
|
179
179
|
const startTime = performance.now();
|
|
180
180
|
function trace(type, msgTemplate, ...args) {
|
|
181
181
|
const arrow = type === 'req' ? '→' : type === 'res' ? '←' : styleText('red', '✗');
|
|
182
|
-
logger.trace(`${styleText('dim', '[%s]')} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
|
|
182
|
+
logger.trace(`${styleText('dim', '[%s]')} ${styleText('dim', `[${new Date().toISOString()}]`)} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
|
|
183
183
|
}
|
|
184
184
|
// Log request URL
|
|
185
185
|
trace('req', '%s %s', method, url);
|
package/oclif.manifest.json
CHANGED