@sanity/runtime-cli 14.7.2 → 14.8.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.
Files changed (80) hide show
  1. package/README.md +140 -97
  2. package/dist/actions/blueprints/assets.d.ts +4 -3
  3. package/dist/actions/blueprints/assets.js +69 -101
  4. package/dist/actions/blueprints/blueprint.d.ts +2 -2
  5. package/dist/actions/blueprints/blueprint.js +1 -8
  6. package/dist/actions/blueprints/config.d.ts +2 -2
  7. package/dist/actions/blueprints/logs-streaming.d.ts +2 -2
  8. package/dist/actions/blueprints/logs.d.ts +2 -4
  9. package/dist/actions/blueprints/resources.d.ts +1 -1
  10. package/dist/actions/blueprints/stacks.d.ts +15 -25
  11. package/dist/actions/functions/dev.d.ts +1 -1
  12. package/dist/actions/functions/env/list.d.ts +1 -1
  13. package/dist/actions/functions/env/remove.d.ts +1 -1
  14. package/dist/actions/functions/env/update.d.ts +1 -1
  15. package/dist/actions/functions/logs.d.ts +3 -3
  16. package/dist/actions/node.d.ts +1 -1
  17. package/dist/actions/sanity/examples.d.ts +2 -2
  18. package/dist/actions/sanity/projects.d.ts +7 -13
  19. package/dist/baseCommands.js +2 -4
  20. package/dist/commands/blueprints/config.d.ts +1 -1
  21. package/dist/commands/blueprints/config.js +2 -1
  22. package/dist/commands/blueprints/deploy.d.ts +1 -1
  23. package/dist/commands/blueprints/deploy.js +2 -1
  24. package/dist/commands/blueprints/destroy.d.ts +1 -1
  25. package/dist/commands/blueprints/destroy.js +2 -1
  26. package/dist/commands/blueprints/doctor.js +2 -2
  27. package/dist/commands/blueprints/info.d.ts +1 -1
  28. package/dist/commands/blueprints/info.js +2 -1
  29. package/dist/commands/blueprints/plan.d.ts +1 -1
  30. package/dist/commands/blueprints/plan.js +2 -1
  31. package/dist/commands/blueprints/promote.js +2 -2
  32. package/dist/commands/blueprints/stacks.d.ts +1 -1
  33. package/dist/commands/blueprints/stacks.js +2 -1
  34. package/dist/commands/functions/build.d.ts +1 -1
  35. package/dist/commands/functions/build.js +2 -1
  36. package/dist/commands/functions/env/add.d.ts +1 -1
  37. package/dist/commands/functions/env/add.js +2 -1
  38. package/dist/commands/functions/env/list.d.ts +1 -1
  39. package/dist/commands/functions/env/list.js +2 -1
  40. package/dist/commands/functions/env/remove.d.ts +1 -1
  41. package/dist/commands/functions/env/remove.js +2 -1
  42. package/dist/commands/functions/logs.d.ts +0 -1
  43. package/dist/commands/functions/logs.js +0 -5
  44. package/dist/commands/functions/test.d.ts +1 -1
  45. package/dist/commands/functions/test.js +2 -1
  46. package/dist/cores/blueprints/config.js +5 -5
  47. package/dist/cores/blueprints/deploy.js +62 -74
  48. package/dist/cores/blueprints/destroy.js +3 -3
  49. package/dist/cores/blueprints/doctor.js +5 -1
  50. package/dist/cores/blueprints/info.js +1 -1
  51. package/dist/cores/blueprints/init.d.ts +4 -3
  52. package/dist/cores/blueprints/plan.js +7 -1
  53. package/dist/cores/blueprints/promote.js +4 -1
  54. package/dist/cores/blueprints/stacks.js +6 -2
  55. package/dist/cores/functions/build.js +2 -2
  56. package/dist/cores/functions/env/add.js +1 -1
  57. package/dist/cores/functions/env/list.js +1 -1
  58. package/dist/cores/functions/env/remove.js +1 -1
  59. package/dist/cores/functions/test.js +4 -4
  60. package/dist/cores/index.d.ts +9 -2
  61. package/dist/cores/index.js +3 -2
  62. package/dist/server/app.d.ts +1 -1
  63. package/dist/server/handlers/invoke.d.ts +1 -1
  64. package/dist/utils/display/prompt.d.ts +2 -2
  65. package/dist/utils/display/prompt.js +1 -1
  66. package/dist/utils/functions/fetch-document.d.ts +2 -2
  67. package/dist/utils/functions/prepare-asset.d.ts +2 -7
  68. package/dist/utils/functions/prepare-asset.js +2 -2
  69. package/dist/utils/logger.d.ts +2 -0
  70. package/dist/utils/logger.js +2 -0
  71. package/dist/utils/other/github.d.ts +1 -1
  72. package/dist/utils/other/npmjs.d.ts +1 -1
  73. package/dist/utils/traced-fetch.d.ts +1 -1
  74. package/dist/utils/types.d.ts +16 -2
  75. package/dist/utils/types.js +5 -4
  76. package/dist/utils/validate/resource.d.ts +0 -3
  77. package/dist/utils/validate/resource.js +0 -270
  78. package/dist/utils/validated-token.d.ts +2 -2
  79. package/oclif.manifest.json +20 -58
  80. package/package.json +2 -2
@@ -1,131 +1,102 @@
1
1
  import crypto from 'node:crypto';
2
2
  import fs from 'node:fs';
3
- import os from 'node:os';
4
- import path from 'node:path';
5
3
  import AdmZip from 'adm-zip';
6
4
  import config from '../../config.js';
7
5
  import { CONVERT_BYTES_TO_MB, MAX_ASSET_SIZE } from '../../constants.js';
8
6
  import { detectNativeModules } from '../../utils/functions/detect-native-modules.js';
9
- import { prepareAsset } from '../../utils/functions/prepare-asset.js';
7
+ import { prepareAsset as prepareFunctionAsset } from '../../utils/functions/prepare-asset.js';
10
8
  import getHeaders from '../../utils/get-headers.js';
11
9
  import { createTracedFetch } from '../../utils/traced-fetch.js';
12
- import { isLocalFunctionCollection } from '../../utils/types.js';
10
+ import { isLocalFunctionResource, isStudioResource } from '../../utils/types.js';
13
11
  const { apiUrl } = config;
14
12
  const ASSETS_URL = `${apiUrl}vX/blueprints/assets`;
15
13
  export const ASSET_CHECK_URL = `${ASSETS_URL}/check`;
16
14
  export const ASSET_STASH_URL = `${ASSETS_URL}/stash`;
17
15
  export async function stashAsset({ resource, auth, logger, installer, }) {
18
- const isCollection = isLocalFunctionCollection(resource);
19
- const functions = isCollection ? resource.functions : [resource];
20
- const combinedAsset = [];
21
- const prepareErrors = [];
22
16
  try {
23
- for (const func of functions) {
24
- const prepResult = await prepareAsset({ resource: func }, { installer });
25
- if (prepResult.success && prepResult.outputPath && prepResult.cleanup) {
26
- combinedAsset.push({
27
- name: func.name,
28
- partAsset: { outputPath: prepResult.outputPath, cleanup: prepResult.cleanup },
29
- });
17
+ let b64;
18
+ let hash;
19
+ let extension;
20
+ let cleanup;
21
+ if (isLocalFunctionResource(resource)) {
22
+ const prepResult = await prepareFunctionAsset({ resource }, { installer });
23
+ if (prepResult.success === false) {
24
+ return {
25
+ success: false,
26
+ error: prepResult.error,
27
+ };
30
28
  }
31
- else if (prepResult.error) {
32
- prepareErrors.push({ name: func.name, error: prepResult.error });
29
+ const zipResult = await pathToB64ZipHash(prepResult.outputPath);
30
+ b64 = zipResult.b64;
31
+ hash = zipResult.hash;
32
+ extension = 'zip';
33
+ cleanup = prepResult.cleanup;
34
+ }
35
+ else if (isStudioResource(resource)) {
36
+ const prepResult = await prepareStudioAsset({ resource });
37
+ if (prepResult.success === false) {
38
+ return {
39
+ success: false,
40
+ error: prepResult.error,
41
+ };
33
42
  }
43
+ const buffer = await fs.promises.readFile(prepResult.outputPath);
44
+ b64 = buffer.toString('base64');
45
+ hash = hashBuffer(buffer);
46
+ extension = 'tar.gz';
47
+ cleanup = prepResult.cleanup;
34
48
  }
35
- if (combinedAsset.length !== functions.length) {
36
- const processedNames = new Set(combinedAsset.map((asset) => asset.name));
37
- const failedFunctions = functions.filter((func) => !processedNames.has(func.name));
38
- const failedNames = failedFunctions.map((f) => f.name).join(', ');
39
- const errorDetails = prepareErrors.map((e) => `${e.name}: ${e.error}`).join('; ');
49
+ else {
40
50
  return {
41
51
  success: false,
42
- error: `Failed to prepare ${failedFunctions.length} function(s) in blueprint: ${failedNames}${errorDetails ? `. Details: ${errorDetails}` : ''}`,
52
+ error: `Invalid resource type ${resource.type} for asset processing`,
43
53
  };
44
54
  }
45
- let result = { success: false };
46
- if (isCollection) {
47
- const combinedResult = await combineAssets(combinedAsset);
48
- if (combinedResult.combinedPath && combinedResult.cleanup) {
49
- result = await stashSingleAsset({
50
- outputPath: combinedResult.combinedPath,
51
- cleanup: combinedResult.cleanup,
52
- resource: resource,
53
- auth,
54
- logger,
55
- collectionInfo: {
56
- name: resource.name,
57
- functionCount: resource.functions.length,
58
- },
59
- });
60
- }
61
- else if (combinedResult.error) {
62
- result = { success: false, error: combinedResult.error };
63
- }
64
- }
65
- else {
66
- result = await stashSingleAsset({
67
- outputPath: combinedAsset[0].partAsset.outputPath,
68
- cleanup: combinedAsset[0].partAsset.cleanup,
69
- resource: resource,
70
- auth,
71
- logger,
72
- });
73
- }
74
- return result;
55
+ return await stashSingleAsset({
56
+ b64,
57
+ hash,
58
+ extension,
59
+ cleanup,
60
+ resource,
61
+ auth,
62
+ logger,
63
+ });
75
64
  }
76
65
  catch (err) {
77
66
  return { success: false, error: err instanceof Error ? err.message : `${err}` };
78
67
  }
79
68
  }
80
- async function combineAssets(allAssets) {
81
- const combinedPath = path.join(os.tmpdir(), `assets-${Date.now()}`);
82
- await fs.promises.mkdir(combinedPath, { recursive: true });
83
- try {
84
- for (const asset of allAssets) {
85
- try {
86
- await fs.promises.mkdir(path.join(combinedPath, asset.name), { recursive: true });
87
- await fs.promises.cp(asset.partAsset.outputPath, path.join(combinedPath, asset.name), {
88
- recursive: true,
89
- });
90
- await asset.partAsset.cleanup();
91
- }
92
- catch (err) {
93
- // Clean up any partial work
94
- try {
95
- await fs.promises.rm(combinedPath, { recursive: true, force: true });
96
- }
97
- catch {
98
- // Ignore cleanup errors
99
- }
100
- // Clean up remaining individual assets
101
- await Promise.allSettled(allAssets.map((a) => a.partAsset.cleanup()));
102
- return {
103
- error: `Failed to combine asset for function '${asset.name}': ${err instanceof Error ? err.message : String(err)}`,
104
- };
105
- }
106
- }
107
- const cleanupCombined = async () => {
108
- await fs.promises.rm(combinedPath, { recursive: true, force: true });
69
+ async function prepareStudioAsset({ resource }) {
70
+ if (!('src' in resource) || typeof resource.src !== 'string') {
71
+ return {
72
+ success: false,
73
+ async cleanup() {
74
+ // no op
75
+ },
76
+ error: `Resource of type '${resource.type}' must have a 'src' property`,
109
77
  };
110
- return { combinedPath, cleanup: cleanupCombined };
111
78
  }
112
- catch (err) {
113
- // Clean up any partial work
114
- try {
115
- await fs.promises.rm(combinedPath, { recursive: true, force: true });
116
- }
117
- catch {
118
- // Ignore cleanup errors
119
- }
120
- // Clean up individual assets that were successfully prepared
121
- await Promise.allSettled(allAssets.map((asset) => asset.partAsset.cleanup()));
122
- return { error: err instanceof Error ? err.message : `${err}` };
79
+ else if (!fs.existsSync(resource.src)) {
80
+ return {
81
+ success: false,
82
+ async cleanup() {
83
+ // no op
84
+ },
85
+ error: `Property 'src' on resource with type '${resource.type}' must be a directory`,
86
+ };
123
87
  }
88
+ return {
89
+ success: true,
90
+ async cleanup() {
91
+ // no op
92
+ },
93
+ // studio must be pre built (e.g. with `npm run build`) and tarred/gzipped
94
+ outputPath: resource.src,
95
+ };
124
96
  }
125
- async function stashSingleAsset({ outputPath, cleanup, resource, auth, logger, collectionInfo, }) {
97
+ async function stashSingleAsset({ b64, hash, cleanup, resource, auth, logger, extension = 'zip', }) {
126
98
  const fetchFn = createTracedFetch(logger);
127
99
  try {
128
- const { b64, hash } = await pathToB64ZipHash(outputPath);
129
100
  try {
130
101
  const checkResponse = await fetchFn(`${ASSET_CHECK_URL}/${hash}`, {
131
102
  method: 'GET',
@@ -143,19 +114,16 @@ async function stashSingleAsset({ outputPath, cleanup, resource, auth, logger, c
143
114
  headers: getHeaders(auth),
144
115
  body: JSON.stringify({
145
116
  file: b64,
146
- filename: `${resource.name}.zip`,
117
+ filename: `${resource.name}.${extension}`,
147
118
  }),
148
119
  });
149
120
  const assetJson = await assetResponse.json();
150
121
  if (assetResponse.ok) {
151
122
  return { success: true, assetId: assetJson.id, exists: false, hash };
152
123
  }
153
- const contextMsg = collectionInfo
154
- ? ` (part of collection '${collectionInfo.name}' with ${collectionInfo.functionCount} functions)`
155
- : '';
156
124
  return {
157
125
  success: false,
158
- error: `Failed to stash asset for ${resource.name}${contextMsg}: ${assetJson.message || 'Unknown error'}`,
126
+ error: `Failed to stash asset for ${resource.name}: ${assetJson.message || 'Unknown error'}`,
159
127
  };
160
128
  }
161
129
  catch (err) {
@@ -1,7 +1,7 @@
1
1
  import type { BlueprintResource } from '@sanity/blueprints';
2
2
  import { type Blueprint } from '@sanity/blueprints-parser';
3
3
  import type { Logger } from '../../utils/logger.js';
4
- import { type BlueprintParserError, type ScopeType } from '../../utils/types.js';
4
+ import type { BlueprintParserError, ScopeType } from '../../utils/types.js';
5
5
  import { type LocatedBlueprintsConfig } from './config.js';
6
6
  declare const SUPPORTED_FILE_EXTENSIONS: readonly [".json", ".js", ".mjs", ".ts"];
7
7
  type BlueprintFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
@@ -65,7 +65,7 @@ export interface ReadBlueprintResult {
65
65
  * @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
66
66
  * @returns Known information about the Blueprint, config, and Stack
67
67
  */
68
- export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>, validate: {
68
+ export declare function readLocalBlueprint(logger: Logger, validate: {
69
69
  resources: boolean;
70
70
  }, blueprintPath?: string): Promise<ReadBlueprintResult>;
71
71
  export declare function writeBlueprintToDisk({ blueprintFilePath, jsonContent, }: {
@@ -6,9 +6,7 @@ import blueprintParserValidator from '@sanity/blueprints-parser';
6
6
  import * as find from 'empathic/find';
7
7
  import { createJiti } from 'jiti';
8
8
  import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, } from '../../constants.js';
9
- import { isLocalFunctionResource, } from '../../utils/types.js';
10
9
  import { validateResources } from '../../utils/validate/index.js';
11
- import { validateFunctionResource } from '../../utils/validate/resource.js';
12
10
  import { backfillOrganizationId, backfillProjectBasedStackId, readConfigFile, } from './config.js';
13
11
  const SUPPORTED_FILE_EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
14
12
  let SUPPORTED_FILE_NAMES = SUPPORTED_FILE_EXTENSIONS.map((ext) => `blueprint${ext}`);
@@ -215,6 +213,7 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
215
213
  scopeId = organizationId;
216
214
  }
217
215
  const parserResult = blueprintParserValidator(rawBlueprint, {
216
+ // Prevents the following resources from being referenced.
218
217
  invalidReferenceTypes: [
219
218
  SANITY_FUNCTION_DOCUMENT,
220
219
  SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
@@ -229,12 +228,6 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
229
228
  // validate function resources
230
229
  errors.push(...validateResources(parsedBlueprint.resources));
231
230
  }
232
- else {
233
- // backwards compat: fallback to the previous validation if validation was not explicitly enabled
234
- const functionResources = parsedBlueprint.resources.filter(isLocalFunctionResource);
235
- const fnErrors = functionResources.map((r) => validateFunctionResource(r));
236
- errors.push(...fnErrors.flat());
237
- }
238
231
  }
239
232
  return {
240
233
  fileInfo: { blueprintFilePath: foundFilePath, fileName, extension },
@@ -53,10 +53,10 @@ export declare function patchConfigFile(blueprintFilePath: string, updateablePro
53
53
  export declare function backfillOrganizationId({ blueprintFilePath, projectId, logger, }: {
54
54
  blueprintFilePath: string;
55
55
  projectId: string;
56
- logger: ReturnType<typeof Logger>;
56
+ logger: Logger;
57
57
  }): Promise<string>;
58
58
  export declare function backfillProjectBasedStackId({ blueprintFilePath, projectId, logger, }: {
59
59
  blueprintFilePath: string;
60
60
  projectId: string;
61
- logger: ReturnType<typeof Logger>;
61
+ logger: Logger;
62
62
  }): Promise<string | undefined>;
@@ -6,7 +6,7 @@ export interface LogStreamingConfig {
6
6
  auth: AuthParams;
7
7
  showBanner?: boolean;
8
8
  verbose?: boolean;
9
- log: ReturnType<typeof Logger>;
9
+ log: Logger;
10
10
  onActivity?: () => void;
11
11
  }
12
12
  export interface StreamLogsOptions {
@@ -16,7 +16,7 @@ export interface StreamLogsOptions {
16
16
  onLog: (log: BlueprintLog) => void;
17
17
  onOpen: () => void;
18
18
  onError: (error: string) => void;
19
- logger: ReturnType<typeof Logger>;
19
+ logger: Logger;
20
20
  }
21
21
  export declare function streamLogs({ stackId, after, auth, onLog, onOpen, onError, logger, }: StreamLogsOptions): () => void;
22
22
  /** Check if a log is newer than a given timestamp */
@@ -1,9 +1,7 @@
1
1
  import type { Logger } from '../../utils/logger.js';
2
- import type { AuthParams, BlueprintLog } from '../../utils/types.js';
2
+ import type { ActionResponse, AuthParams, BlueprintLog } from '../../utils/types.js';
3
3
  export declare const logsUrl: string;
4
- export declare function getLogs(stackId: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
4
+ export declare function getLogs(stackId: string, auth: AuthParams, logger: Logger): Promise<ActionResponse & {
5
5
  logs: BlueprintLog[];
6
- ok: boolean;
7
- error: string | null;
8
6
  }>;
9
7
  export declare function getRecentLogs(logs: BlueprintLog[], limit?: number): BlueprintLog[];
@@ -11,7 +11,7 @@ interface FunctionResourceOptions {
11
11
  /**
12
12
  * Creates a new function resource file and adds it to the blueprint
13
13
  */
14
- export declare function createFunctionResource(options: FunctionResourceOptions, logger: ReturnType<typeof Logger>): Promise<{
14
+ export declare function createFunctionResource(options: FunctionResourceOptions, logger: Logger): Promise<{
15
15
  filePath: string;
16
16
  resourceAdded: boolean;
17
17
  resource: FunctionResourceBase;
@@ -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 { AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
3
+ import type { ActionResponse, AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
4
4
  export declare const stacksUrl: string;
5
5
  type ListStacksResponse = {
6
6
  ok: true;
@@ -11,45 +11,39 @@ type ListStacksResponse = {
11
11
  error: string;
12
12
  stacks: unknown;
13
13
  };
14
- export declare function listStacks(auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<ListStacksResponse>;
15
- interface GetStackResponse {
16
- ok: boolean;
17
- error: string | null;
14
+ export declare function listStacks(auth: AuthParams, logger: Logger): Promise<ListStacksResponse>;
15
+ interface GetStackResponse extends ActionResponse {
18
16
  stack: Stack;
19
17
  response?: Response;
20
18
  }
21
19
  export declare function getStack({ stackId, auth, logger, }: {
22
20
  stackId: string;
23
21
  auth: AuthParams;
24
- logger: ReturnType<typeof Logger>;
22
+ logger: Logger;
25
23
  }): Promise<GetStackResponse>;
26
- interface CreateStackResponse {
27
- ok: boolean;
28
- error: string | null;
24
+ interface CreateStackResponse extends ActionResponse {
29
25
  stack: Stack;
30
26
  }
31
27
  export declare function createStack({ stackMutation, auth, logger, }: {
32
28
  stackMutation: StackMutation;
33
29
  auth: AuthParams;
34
- logger: ReturnType<typeof Logger>;
30
+ logger: Logger;
35
31
  }): Promise<CreateStackResponse>;
36
32
  export declare function createEmptyStack({ token, scopeType, scopeId, name, logger, }: {
37
33
  token: string;
38
34
  scopeType: ScopeType;
39
35
  scopeId: string;
40
36
  name: string;
41
- logger: ReturnType<typeof Logger>;
37
+ logger: Logger;
42
38
  }): Promise<Stack>;
43
- interface UpdateStackResponse {
44
- ok: boolean;
45
- error: string | null;
39
+ interface UpdateStackResponse extends ActionResponse {
46
40
  stack: Stack;
47
41
  }
48
42
  export declare function updateStack({ stackId, stackMutation, auth, logger, }: {
49
43
  stackId: string;
50
44
  stackMutation: StackMutation;
51
45
  auth: AuthParams;
52
- logger: ReturnType<typeof Logger>;
46
+ logger: Logger;
53
47
  }): Promise<UpdateStackResponse>;
54
48
  interface PlanResourceSnapshot {
55
49
  name: string;
@@ -99,17 +93,13 @@ export declare function planStack({ stackId, document, auth, logger, }: {
99
93
  stackId: string;
100
94
  document: Blueprint;
101
95
  auth: AuthParams;
102
- logger: ReturnType<typeof Logger>;
96
+ logger: Logger;
103
97
  }): Promise<PlanStackResponse>;
104
- interface DestroyStackResponse {
105
- ok: boolean;
106
- error: string | null;
98
+ interface DestroyStackResponse extends ActionResponse {
107
99
  stack: Stack;
108
100
  }
109
- export declare function resolveStackIdByNameOrId(value: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<string>;
110
- interface PromoteStackResponse {
111
- ok: boolean;
112
- error: string | null;
101
+ export declare function resolveStackIdByNameOrId(value: string, auth: AuthParams, logger: Logger): Promise<string>;
102
+ interface PromoteStackResponse extends ActionResponse {
113
103
  stack: Stack & {
114
104
  alreadyPromoted: boolean;
115
105
  };
@@ -117,11 +107,11 @@ interface PromoteStackResponse {
117
107
  export declare function promoteStack({ stackId, auth, logger, }: {
118
108
  stackId: string;
119
109
  auth: AuthParams;
120
- logger: ReturnType<typeof Logger>;
110
+ logger: Logger;
121
111
  }): Promise<PromoteStackResponse>;
122
112
  export declare function destroyStack({ stackId, auth, logger, }: {
123
113
  stackId: string;
124
114
  auth: AuthParams;
125
- logger: ReturnType<typeof Logger>;
115
+ logger: Logger;
126
116
  }): Promise<DestroyStackResponse>;
127
117
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { Logger } from '../../utils/logger.js';
2
2
  import type { InvokeExecutionOptions } from '../../utils/types.js';
3
- export declare function dev(host: string, port: number, logger: ReturnType<typeof Logger>, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
3
+ export declare function dev(host: string, port: number, logger: Logger, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from '../../../utils/logger.js';
2
2
  import type { AuthParams } from '../../../utils/types.js';
3
- export declare function list(id: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
3
+ export declare function list(id: string, auth: AuthParams, logger: Logger): Promise<{
4
4
  ok: boolean;
5
5
  envvars: any;
6
6
  error: any;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from '../../../utils/logger.js';
2
2
  import type { AuthParams } from '../../../utils/types.js';
3
- export declare function remove(id: string, key: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
3
+ export declare function remove(id: string, key: string, auth: AuthParams, logger: Logger): Promise<{
4
4
  ok: boolean;
5
5
  error: any;
6
6
  }>;
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from '../../../utils/logger.js';
2
2
  import type { AuthParams } from '../../../utils/types.js';
3
- export declare function update(id: string, key: string, value: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
3
+ export declare function update(id: string, key: string, value: string, auth: AuthParams, logger: Logger): Promise<{
4
4
  ok: boolean;
5
5
  error: any;
6
6
  }>;
@@ -4,13 +4,13 @@ import type { AuthParams, FunctionLog } from '../../utils/types.js';
4
4
  export interface LoggingOptions {
5
5
  limit: number;
6
6
  }
7
- export declare function logs(id: string, options: LoggingOptions, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
7
+ export declare function logs(id: string, options: LoggingOptions, auth: AuthParams, logger: Logger): Promise<{
8
8
  ok: boolean;
9
9
  error: any;
10
10
  logs: any;
11
11
  }>;
12
- export declare function deleteLogs(id: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<{
12
+ export declare function deleteLogs(id: string, auth: AuthParams, logger: Logger): Promise<{
13
13
  ok: boolean;
14
14
  error: any;
15
15
  }>;
16
- export declare function streamLogs(id: string, auth: AuthParams, onLog: (log: FunctionLog) => void, onOpen: () => void, onError: (error: string) => void, logger: ReturnType<typeof Logger>): () => void;
16
+ export declare function streamLogs(id: string, auth: AuthParams, onLog: (log: FunctionLog) => void, onOpen: () => void, onError: (error: string) => void, logger: Logger): () => void;
@@ -1,2 +1,2 @@
1
1
  import type { Logger } from '../utils/logger.js';
2
- export declare function writeOrUpdateNodeDependency(nearFilePath: string, dependency: string, logger: ReturnType<typeof Logger>): Promise<void>;
2
+ export declare function writeOrUpdateNodeDependency(nearFilePath: string, dependency: string, logger: Logger): Promise<void>;
@@ -7,7 +7,7 @@ declare const EXAMPLE_TYPES: {
7
7
  export declare function verifyExampleExists({ type, name, logger, }: {
8
8
  type: keyof typeof EXAMPLE_TYPES;
9
9
  name: string;
10
- logger: ReturnType<typeof Logger>;
10
+ logger: Logger;
11
11
  }): Promise<boolean>;
12
12
  /**
13
13
  * Downloads an example from the examples repo and writes it to disk.
@@ -19,7 +19,7 @@ export declare function writeExample({ ownerRepo, exampleType, exampleName, dir,
19
19
  exampleType: keyof typeof EXAMPLE_TYPES;
20
20
  exampleName: string;
21
21
  dir?: string;
22
- logger: ReturnType<typeof Logger>;
22
+ logger: Logger;
23
23
  }): Promise<false | {
24
24
  files: Record<string, string>;
25
25
  dir: string;
@@ -1,5 +1,5 @@
1
1
  import type { Logger } from '../../utils/logger.js';
2
- import type { ScopeType } from '../../utils/types.js';
2
+ import type { ActionResponse, ScopeType } from '../../utils/types.js';
3
3
  export declare const projectsApiPath: string;
4
4
  export declare const orgsApiPath: string;
5
5
  export interface Project {
@@ -14,18 +14,14 @@ export interface Project {
14
14
  createdAt: string;
15
15
  updatedAt: string;
16
16
  }
17
- interface ListProjectsResponse {
18
- ok: boolean;
19
- error: string | null;
17
+ interface ListProjectsResponse extends ActionResponse {
20
18
  projects: Project[];
21
19
  }
22
20
  export declare function listProjects({ token, logger, }: {
23
21
  token: string;
24
- logger: ReturnType<typeof Logger>;
22
+ logger: Logger;
25
23
  }): Promise<ListProjectsResponse>;
26
- interface GroupedProjectsByOrganizationResponse {
27
- ok: boolean;
28
- error: string | null;
24
+ interface GroupedProjectsByOrganizationResponse extends ActionResponse {
29
25
  organizations: GroupedProjects[];
30
26
  }
31
27
  interface GroupedProjects {
@@ -37,17 +33,15 @@ interface GroupedProjects {
37
33
  }
38
34
  export declare function groupProjectsByOrganization({ token, logger, }: {
39
35
  token: string;
40
- logger: ReturnType<typeof Logger>;
36
+ logger: Logger;
41
37
  }): Promise<GroupedProjectsByOrganizationResponse>;
42
- interface GetProjectResponse {
43
- ok: boolean;
44
- error: string | null;
38
+ interface GetProjectResponse extends ActionResponse {
45
39
  project: Project;
46
40
  }
47
41
  export declare function getProject({ token, scopeId, scopeType, logger, }: {
48
42
  token: string;
49
43
  scopeId: string;
50
44
  scopeType: ScopeType;
51
- logger: ReturnType<typeof Logger>;
45
+ logger: Logger;
52
46
  }): Promise<GetProjectResponse>;
53
47
  export {};
@@ -6,8 +6,7 @@ const hidden = true;
6
6
  export const baseFlags = {
7
7
  json: OclifFlags.boolean({
8
8
  // override defaults from oclif's built-in --json flag
9
- description: 'Format output as json.',
10
- hidden,
9
+ description: 'Format output as json',
11
10
  }),
12
11
  path: OclifFlags.string({
13
12
  description: 'Path to a Blueprint file or directory containing one',
@@ -23,9 +22,8 @@ export const baseFlags = {
23
22
  }),
24
23
  'validate-resources': OclifFlags.boolean({
25
24
  description: 'Validate resources',
26
- default: false,
25
+ default: true,
27
26
  allowNo: true,
28
- hidden, // TODO: reveal this once support is added in main CLI
29
27
  }),
30
28
  verbose: OclifFlags.boolean({
31
29
  description: 'Verbose output',
@@ -9,5 +9,5 @@ export default class ConfigCommand extends LocalBlueprintCommand<typeof ConfigCo
9
9
  'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
10
  stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  };
12
- run(): Promise<void>;
12
+ run(): Promise<Record<string, unknown> | undefined>;
13
13
  }
@@ -39,7 +39,7 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
39
39
  }),
40
40
  };
41
41
  async run() {
42
- const { success, error } = await blueprintConfigCore({
42
+ const { success, error, json } = await blueprintConfigCore({
43
43
  bin: this.config.bin,
44
44
  log: Logger(this.log.bind(this), this.flags),
45
45
  blueprint: this.blueprint,
@@ -49,5 +49,6 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
49
49
  });
50
50
  if (!success)
51
51
  this.error(error);
52
+ return json;
52
53
  }
53
54
  }
@@ -9,5 +9,5 @@ export default class DeployCommand extends DeployedStackCommand<typeof DeployCom
9
9
  'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
10
  'new-stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  };
12
- run(): Promise<void>;
12
+ run(): Promise<Record<string, unknown> | undefined>;
13
13
  }
@@ -37,7 +37,7 @@ Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for process
37
37
  }),
38
38
  };
39
39
  async run() {
40
- const { success, error } = await blueprintDeployCore({
40
+ const { success, error, json } = await blueprintDeployCore({
41
41
  bin: this.config.bin,
42
42
  log: Logger(this.log.bind(this), this.flags),
43
43
  auth: this.auth,
@@ -51,5 +51,6 @@ Set SANITY_ASSET_TIMEOUT (seconds) to override the 60-second timeout for process
51
51
  });
52
52
  if (!success)
53
53
  this.error(error);
54
+ return json;
54
55
  }
55
56
  }
@@ -10,5 +10,5 @@ export default class DestroyCommand extends LocalBlueprintCommand<typeof Destroy
10
10
  stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
11
  'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
12
  };
13
- run(): Promise<void>;
13
+ run(): Promise<Record<string, unknown> | undefined>;
14
14
  }
@@ -42,7 +42,7 @@ Use this to clean up test environments or decommission a Stack you no longer nee
42
42
  }),
43
43
  };
44
44
  async run() {
45
- const { success, error } = await blueprintDestroyCore({
45
+ const { success, error, json } = await blueprintDestroyCore({
46
46
  bin: this.config.bin,
47
47
  log: Logger(this.log.bind(this), this.flags),
48
48
  token: this.sanityToken,
@@ -52,5 +52,6 @@ Use this to clean up test environments or decommission a Stack you no longer nee
52
52
  });
53
53
  if (!success)
54
54
  this.error(error);
55
+ return json;
55
56
  }
56
57
  }