@sanity/runtime-cli 17.15.0-next.gb22a727 → 17.15.0-next.gd07e8fe

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 CHANGED
@@ -90,7 +90,7 @@ EXAMPLES
90
90
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
91
91
  ```
92
92
 
93
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/add.ts)_
93
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/add.ts)_
94
94
 
95
95
  ## `sanity-run blueprints config`
96
96
 
@@ -127,7 +127,7 @@ EXAMPLES
127
127
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
128
128
  ```
129
129
 
130
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/config.ts)_
130
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/config.ts)_
131
131
 
132
132
  ## `sanity-run blueprints deploy`
133
133
 
@@ -183,7 +183,7 @@ EXAMPLES
183
183
  $ sanity-run blueprints deploy --new-stack-name <new-name>
184
184
  ```
185
185
 
186
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/deploy.ts)_
186
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/deploy.ts)_
187
187
 
188
188
  ## `sanity-run blueprints destroy`
189
189
 
@@ -221,7 +221,7 @@ EXAMPLES
221
221
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
222
222
  ```
223
223
 
224
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/destroy.ts)_
224
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/destroy.ts)_
225
225
 
226
226
  ## `sanity-run blueprints doctor`
227
227
 
@@ -253,7 +253,7 @@ EXAMPLES
253
253
  $ sanity-run blueprints doctor --fix
254
254
  ```
255
255
 
256
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/doctor.ts)_
256
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/doctor.ts)_
257
257
 
258
258
  ## `sanity-run blueprints info`
259
259
 
@@ -291,7 +291,7 @@ EXAMPLES
291
291
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
292
292
  ```
293
293
 
294
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/info.ts)_
294
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/info.ts)_
295
295
 
296
296
  ## `sanity-run blueprints init [DIR]`
297
297
 
@@ -355,7 +355,7 @@ EXAMPLES
355
355
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
356
356
  ```
357
357
 
358
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/init.ts)_
358
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/init.ts)_
359
359
 
360
360
  ## `sanity-run blueprints logs`
361
361
 
@@ -401,7 +401,7 @@ EXAMPLES
401
401
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
402
402
  ```
403
403
 
404
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/logs.ts)_
404
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/logs.ts)_
405
405
 
406
406
  ## `sanity-run blueprints mint-deploy-token`
407
407
 
@@ -446,7 +446,7 @@ EXAMPLES
446
446
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
447
447
  ```
448
448
 
449
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/mint-deploy-token.ts)_
449
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/mint-deploy-token.ts)_
450
450
 
451
451
  ## `sanity-run blueprints plan`
452
452
 
@@ -479,7 +479,7 @@ EXAMPLES
479
479
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
480
480
  ```
481
481
 
482
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/plan.ts)_
482
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/plan.ts)_
483
483
 
484
484
  ## `sanity-run blueprints promote`
485
485
 
@@ -515,7 +515,7 @@ EXAMPLES
515
515
  $ sanity-run blueprints promote --new-stack-name <new-name>
516
516
  ```
517
517
 
518
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/promote.ts)_
518
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/promote.ts)_
519
519
 
520
520
  ## `sanity-run blueprints stacks`
521
521
 
@@ -556,7 +556,7 @@ EXAMPLES
556
556
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
557
557
  ```
558
558
 
559
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/blueprints/stacks.ts)_
559
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/blueprints/stacks.ts)_
560
560
 
561
561
  ## `sanity-run functions add`
562
562
 
@@ -608,7 +608,7 @@ EXAMPLES
608
608
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
609
609
  ```
610
610
 
611
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/add.ts)_
611
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/add.ts)_
612
612
 
613
613
  ## `sanity-run functions dev`
614
614
 
@@ -643,7 +643,7 @@ EXAMPLES
643
643
  $ sanity-run functions dev --timeout 60
644
644
  ```
645
645
 
646
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/dev.ts)_
646
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/dev.ts)_
647
647
 
648
648
  ## `sanity-run functions env add NAME KEY VALUE`
649
649
 
@@ -676,7 +676,7 @@ EXAMPLES
676
676
  $ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
677
677
  ```
678
678
 
679
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/env/add.ts)_
679
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/env/add.ts)_
680
680
 
681
681
  ## `sanity-run functions env list NAME`
682
682
 
@@ -706,7 +706,7 @@ EXAMPLES
706
706
  $ sanity-run functions env list --stack <name-or-id> MyFunction
707
707
  ```
708
708
 
709
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/env/list.ts)_
709
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/env/list.ts)_
710
710
 
711
711
  ## `sanity-run functions env remove NAME KEY`
712
712
 
@@ -738,7 +738,7 @@ EXAMPLES
738
738
  $ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
739
739
  ```
740
740
 
741
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/env/remove.ts)_
741
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/env/remove.ts)_
742
742
 
743
743
  ## `sanity-run functions logs [NAME]`
744
744
 
@@ -778,7 +778,7 @@ EXAMPLES
778
778
  $ sanity-run functions logs <name> --delete
779
779
  ```
780
780
 
781
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/logs.ts)_
781
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/logs.ts)_
782
782
 
783
783
  ## `sanity-run functions test [NAME]`
784
784
 
@@ -836,7 +836,7 @@ EXAMPLES
836
836
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
837
837
  ```
838
838
 
839
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gb22a727/src/commands/functions/test.ts)_
839
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.15.0-next.gd07e8fe/src/commands/functions/test.ts)_
840
840
 
841
841
  ## `sanity-run help [COMMAND]`
842
842
 
@@ -1,18 +1,17 @@
1
1
  import type { BlueprintResource } from '@sanity/blueprints';
2
+ import { type StackConfig, type ConfigSource as StackConfigSource, type StackIds } from '@sanity/blueprints/resolve';
2
3
  import { type Blueprint } from '@sanity/blueprints-parser';
3
4
  import type { Logger } from '../../utils/logger.js';
4
5
  import type { BlueprintParserError, ScopeType } from '../../utils/types.js';
5
6
  import { type LocatedBlueprintsConfig } from './config.js';
6
- import { type ConfigSource } from './resolve.js';
7
- declare const SUPPORTED_FILE_EXTENSIONS: readonly ['.json', '.js', '.mjs', '.ts'];
8
- type BlueprintFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
7
+ type BlueprintFileExtension = '.json' | '.js' | '.mjs' | '.ts';
9
8
  export declare const JSON_BLUEPRINT_CONTENT: {
10
9
  blueprintVersion: string;
11
10
  resources: never[];
12
11
  };
13
12
  export declare const TS_BLUEPRINT_CONTENT: string;
14
13
  /** Function type with attached attributes */
15
- export type BlueprintModule = ((args?: unknown) => Record<string, unknown>) & {
14
+ export type BlueprintModule = ((args?: unknown) => unknown) & {
16
15
  organizationId?: string;
17
16
  projectId?: string;
18
17
  stackId?: string;
@@ -23,12 +22,22 @@ type FileInfo = {
23
22
  extension: BlueprintFileExtension;
24
23
  };
25
24
  /**
26
- * Finds the blueprint file in the given path or current working directory
25
+ * Finds the blueprint file in the given path or current working directory, searching parent directories
26
+ * @see {@link findBlueprintFilePath} in `@sanity/blueprints/resolve`
27
27
  * @returns The path, file name, and extension of the blueprint file
28
28
  */
29
29
  export declare function findBlueprintFile(blueprintPath?: string): FileInfo | null;
30
- /** @see resolve.ts for the canonical definition */
31
- export type { ConfigSource } from './resolve.js';
30
+ /**
31
+ * Where a resolved id came from: a `@sanity/blueprints/resolve` source,
32
+ * or `inferred` for the legacy `ST-<projectId>` Stack id backfill
33
+ */
34
+ export type ConfigSource = StackConfigSource | 'inferred';
35
+ /** Resolved Stack ids and scope, with the CLI's sources */
36
+ export interface ResolvedIds extends Omit<StackConfig, 'sources'> {
37
+ sources: {
38
+ [K in keyof StackIds]?: ConfigSource;
39
+ };
40
+ }
32
41
  /** Result of loading a blueprint file from disk. */
33
42
  export interface LoadedBlueprintFile {
34
43
  rawBlueprint: Record<string, unknown>;
@@ -69,6 +78,7 @@ export interface ReadBlueprintResult {
69
78
  /**
70
79
  * Load a blueprint file from disk: read JSON or import+execute a JS/TS module.
71
80
  * Returns the raw blueprint data and the module reference (if dynamic).
81
+ * @see {@link loadBlueprintFileFromDisk} in `@sanity/blueprints/resolve`
72
82
  */
73
83
  export declare function loadBlueprintFile(fileInfo: FileInfo): Promise<LoadedBlueprintFile>;
74
84
  /**
@@ -87,7 +97,7 @@ export interface LocalBlueprint extends ParsedBlueprintContent {
87
97
  /**
88
98
  * Find, load, and parse a local blueprint file in one step.
89
99
  * Does not read the config file or resolve IDs -- callers that need
90
- * scope/stack information should use `readConfigFile` + `resolveIds` separately.
100
+ * scope/stack information should use `readConfigFile` + `resolveStackConfig` separately.
91
101
  *
92
102
  * @param blueprintPath Path to a blueprint file or directory containing one
93
103
  * @param options.validateResources Whether to validate function resources
@@ -99,7 +109,7 @@ export declare function loadAndParseBlueprint(blueprintPath?: string, options?:
99
109
  * Reads the blueprint file from disk and parses it.
100
110
  * Resolves IDs from environment > blueprint module > config file.
101
111
  * Can infer stackId from projectId for legacy ST-<projectId> stacks.
102
- * @see {@link loadBlueprintFile} {@link readConfigFile} {@link resolveIds} {@link parseBlueprintContent}
112
+ * @see {@link loadBlueprintFile} {@link readConfigFile} {@link resolveStackConfig} {@link parseBlueprintContent}
103
113
  * @todo deprecate in favor of decomposed functions
104
114
  * @returns Known information about the Blueprint, config, and Stack
105
115
  */
@@ -114,3 +124,4 @@ export declare function addResourceToBlueprint<T extends BlueprintResource>({ bl
114
124
  blueprintFilePath?: string;
115
125
  resource: T;
116
126
  }): T | undefined;
127
+ export {};
@@ -1,20 +1,12 @@
1
- import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
1
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { basename, dirname, extname } from 'node:path';
3
- import { cwd } from 'node:process';
4
3
  import { pathToFileURL } from 'node:url';
4
+ import { findBlueprintFile as findBlueprintFilePath, loadBlueprintFile as loadBlueprintFileFromDisk, resolveStackConfig, } from '@sanity/blueprints/resolve';
5
5
  import blueprintParserValidator from '@sanity/blueprints-parser';
6
- import * as find from 'empathic/find';
7
6
  import { createJiti } from 'jiti';
8
7
  import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_DURABLE, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULED, } from '../../constants.js';
9
8
  import { validateResources } from '../../utils/blueprints/validate-resources.js';
10
9
  import { backfillProjectBasedStackId, readConfigFile, } from './config.js';
11
- import { resolveIds } from './resolve.js';
12
- const SUPPORTED_FILE_EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
13
- let SUPPORTED_FILE_NAMES = SUPPORTED_FILE_EXTENSIONS.map((ext) => `blueprint${ext}`);
14
- SUPPORTED_FILE_NAMES = [
15
- ...SUPPORTED_FILE_NAMES,
16
- ...SUPPORTED_FILE_NAMES.map((name) => `sanity.${name}`),
17
- ];
18
10
  export const JSON_BLUEPRINT_CONTENT = {
19
11
  blueprintVersion: '2024-10-01',
20
12
  resources: [],
@@ -29,88 +21,42 @@ export default defineBlueprint({
29
21
  })
30
22
  `.trim();
31
23
  /**
32
- * Finds the blueprint file in the given path or current working directory
24
+ * Finds the blueprint file in the given path or current working directory, searching parent directories
25
+ * @see {@link findBlueprintFilePath} in `@sanity/blueprints/resolve`
33
26
  * @returns The path, file name, and extension of the blueprint file
34
27
  */
35
28
  export function findBlueprintFile(blueprintPath) {
36
- let dirToSearch = cwd();
37
- if (blueprintPath) {
38
- const pathExists = existsSync(blueprintPath);
39
- if (!pathExists)
40
- return null;
41
- const stat = statSync(blueprintPath);
42
- if (stat.isFile()) {
43
- return {
44
- blueprintFilePath: blueprintPath,
45
- fileName: basename(blueprintPath),
46
- extension: extname(blueprintPath),
47
- };
48
- }
49
- if (stat.isDirectory()) {
50
- dirToSearch = blueprintPath;
51
- }
52
- }
53
- const blueprintFile = find.any(SUPPORTED_FILE_NAMES, { cwd: dirToSearch });
54
- if (!blueprintFile)
29
+ const blueprintFilePath = findBlueprintFilePath(blueprintPath);
30
+ if (!blueprintFilePath)
55
31
  return null;
56
32
  return {
57
- blueprintFilePath: blueprintFile,
58
- fileName: basename(blueprintFile),
59
- extension: extname(blueprintFile),
33
+ blueprintFilePath,
34
+ fileName: basename(blueprintFilePath),
35
+ extension: extname(blueprintFilePath),
60
36
  };
61
37
  }
62
38
  /**
63
39
  * Load a blueprint file from disk: read JSON or import+execute a JS/TS module.
64
40
  * Returns the raw blueprint data and the module reference (if dynamic).
41
+ * @see {@link loadBlueprintFileFromDisk} in `@sanity/blueprints/resolve`
65
42
  */
66
43
  export async function loadBlueprintFile(fileInfo) {
67
- const { blueprintFilePath, fileName, extension } = fileInfo;
68
- let rawBlueprint;
69
- let blueprintModule;
44
+ const { blueprintFilePath, fileName } = fileInfo;
70
45
  try {
71
- switch (extension) {
72
- case '.json': {
73
- const blueprintString = readFileSync(blueprintFilePath, 'utf8').toString();
74
- rawBlueprint = JSON.parse(blueprintString);
75
- break;
76
- }
77
- case '.js':
78
- case '.mjs': {
79
- const mod = await import(blueprintFilePath);
80
- blueprintModule = mod.default;
81
- break;
82
- }
83
- case '.ts': {
84
- const jiti = createJiti(dirname(blueprintFilePath));
85
- const modDefault = await jiti.import(pathToFileURL(blueprintFilePath).href, { default: true });
86
- blueprintModule = modDefault;
87
- break;
88
- }
89
- default:
90
- throw Error(`Unsupported Blueprint manifest extension: ${extension}`);
91
- }
46
+ const { blueprint, module } = await loadBlueprintFileFromDisk(blueprintFilePath, {
47
+ // Use jiti without module cache to avoid stale loads
48
+ loader: (path) => {
49
+ return createJiti(path, { moduleCache: false }).import(pathToFileURL(path).href, {
50
+ default: true,
51
+ });
52
+ },
53
+ });
54
+ return { rawBlueprint: { ...blueprint }, module };
92
55
  }
93
56
  catch (err) {
94
- throw Error(`Could not parse Blueprint manifest: ${fileName}\n${err}`);
95
- }
96
- // Dynamic modules: extract attached properties, then execute to get raw blueprint
97
- if (blueprintModule) {
98
- if (typeof blueprintModule === 'function') {
99
- try {
100
- rawBlueprint = blueprintModule();
101
- }
102
- catch {
103
- throw Error(`Error executing Blueprint manifest: ${fileName}`);
104
- }
105
- }
106
- else {
107
- throw Error(`Blueprint manifest ${fileName} must export a default function.`);
108
- }
109
- }
110
- if (typeof rawBlueprint === 'undefined') {
111
- throw Error('Could not read Blueprint manifest.');
57
+ const message = err instanceof Error ? err.message : String(err);
58
+ throw Error(`Could not parse Blueprint manifest: ${fileName}\n${message}`);
112
59
  }
113
- return { rawBlueprint, module: blueprintModule };
114
60
  }
115
61
  /**
116
62
  * Run the blueprint parser/validator on raw blueprint data.
@@ -142,7 +88,7 @@ export function parseBlueprintContent(rawBlueprint, options) {
142
88
  /**
143
89
  * Find, load, and parse a local blueprint file in one step.
144
90
  * Does not read the config file or resolve IDs -- callers that need
145
- * scope/stack information should use `readConfigFile` + `resolveIds` separately.
91
+ * scope/stack information should use `readConfigFile` + `resolveStackConfig` separately.
146
92
  *
147
93
  * @param blueprintPath Path to a blueprint file or directory containing one
148
94
  * @param options.validateResources Whether to validate function resources
@@ -165,7 +111,7 @@ export async function loadAndParseBlueprint(blueprintPath, options = { validateR
165
111
  * Reads the blueprint file from disk and parses it.
166
112
  * Resolves IDs from environment > blueprint module > config file.
167
113
  * Can infer stackId from projectId for legacy ST-<projectId> stacks.
168
- * @see {@link loadBlueprintFile} {@link readConfigFile} {@link resolveIds} {@link parseBlueprintContent}
114
+ * @see {@link loadBlueprintFile} {@link readConfigFile} {@link resolveStackConfig} {@link parseBlueprintContent}
169
115
  * @todo deprecate in favor of decomposed functions
170
116
  * @returns Known information about the Blueprint, config, and Stack
171
117
  */
@@ -180,7 +126,7 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
180
126
  // 2. Read the config file
181
127
  const blueprintConfig = readConfigFile(fileInfo.blueprintFilePath);
182
128
  // 3. Resolve IDs: env > module > config
183
- const resolved = resolveIds({
129
+ const resolved = resolveStackConfig({
184
130
  module: loaded.module,
185
131
  config: blueprintConfig,
186
132
  });
@@ -9,6 +9,7 @@ export interface BlueprintsConfig extends ConfigUpdate {
9
9
  blueprintConfigVersion?: typeof BLUEPRINT_CONFIG_VERSION;
10
10
  runtimeCliVersion?: typeof RUNTIME_CLI_VERSION;
11
11
  updatedAt?: number;
12
+ internalEnv?: string;
12
13
  }
13
14
  export interface LocatedBlueprintsConfig extends BlueprintsConfig {
14
15
  configPath: string;
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { dirname, join } from 'node:path';
3
- import { cwd } from 'node:process';
3
+ import { cwd, env } from 'node:process';
4
4
  import config, { BLUEPRINT_CONFIG_DIR, BLUEPRINT_CONFIG_FILE, BLUEPRINT_CONFIG_VERSION, RUNTIME_CLI_VERSION, } from '../../config.js';
5
5
  import { getProject } from '../sanity/projects.js';
6
6
  import { listStacks } from './stacks.js';
@@ -48,6 +48,12 @@ export function writeConfigFile(blueprintFilePath, options) {
48
48
  config.blueprintConfigVersion = BLUEPRINT_CONFIG_VERSION;
49
49
  config.runtimeCliVersion = RUNTIME_CLI_VERSION;
50
50
  config.updatedAt = Date.now();
51
+ if (env.SANITY_INTERNAL_ENV) {
52
+ config.internalEnv = env.SANITY_INTERNAL_ENV;
53
+ }
54
+ else {
55
+ delete config.internalEnv;
56
+ }
51
57
  writeFileSync(configPath, JSON.stringify(config, null, 2));
52
58
  return config;
53
59
  }
@@ -1,8 +1,8 @@
1
1
  // * https://oclif.io/docs/base_class
2
2
  import { Command, CommandHelp, Errors, Flags as OclifFlags } from '@oclif/core';
3
+ import { resolveStackConfig } from '@sanity/blueprints/resolve';
3
4
  import { findBlueprintFile, loadBlueprintFile, parseBlueprintContent, } from './actions/blueprints/blueprint.js';
4
5
  import { backfillProjectBasedStackId, readConfigFile, } from './actions/blueprints/config.js';
5
- import { resolveIds } from './actions/blueprints/resolve.js';
6
6
  import { getStack, resolveStackIdByNameOrId } from './actions/blueprints/stacks.js';
7
7
  import config from './config.js';
8
8
  import { CI_SETUP_DOCS_URL } from './constants.js';
@@ -295,8 +295,8 @@ export class ResolvedCommand extends RuntimeCommand {
295
295
  };
296
296
  }
297
297
  // 4. Resolve IDs
298
- const resolved = resolveIds({
299
- flags: {
298
+ const resolved = resolveStackConfig({
299
+ overrides: {
300
300
  projectId: this.flags['project-id'],
301
301
  organizationId: this.flags['organization-id'],
302
302
  },
package/dist/config.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  export declare const BLUEPRINT_CONFIG_VERSION = "v2025-05-08";
2
2
  export declare const BLUEPRINTS_API_VERSION: string;
3
- export declare const BLUEPRINT_CONFIG_DIR = ".sanity";
4
- export declare const BLUEPRINT_CONFIG_FILE = "blueprint.config.json";
3
+ export { STACK_CONFIG_DIR as BLUEPRINT_CONFIG_DIR, STACK_CONFIG_FILE as BLUEPRINT_CONFIG_FILE, } from '@sanity/blueprints/resolve';
5
4
  export declare const RUNTIME_CLI_NAME = "@sanity/runtime-cli";
6
5
  export declare let RUNTIME_CLI_VERSION: string | undefined;
7
6
  export declare const RUNTIME_CLI_USER_AGENT: string;
package/dist/config.js CHANGED
@@ -8,8 +8,7 @@ export const BLUEPRINT_CONFIG_VERSION = 'v2025-05-08';
8
8
  // Default API version for Blueprints service calls.
9
9
  // Overridable globally via env, or per-endpoint via the `version` arg to `blueprintsUrl`.
10
10
  export const BLUEPRINTS_API_VERSION = env.SANITY_BLUEPRINTS_API_VERSION ?? 'v2026-06-15';
11
- export const BLUEPRINT_CONFIG_DIR = '.sanity';
12
- export const BLUEPRINT_CONFIG_FILE = 'blueprint.config.json';
11
+ export { STACK_CONFIG_DIR as BLUEPRINT_CONFIG_DIR, STACK_CONFIG_FILE as BLUEPRINT_CONFIG_FILE, } from '@sanity/blueprints/resolve';
13
12
  export const RUNTIME_CLI_NAME = '@sanity/runtime-cli';
14
13
  export let RUNTIME_CLI_VERSION;
15
14
  try {
@@ -1,11 +1,11 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { dirname } from 'node:path';
3
3
  import { arch, cwd, env, version as nodeVersion, platform } from 'node:process';
4
+ import { resolveStackConfig } from '@sanity/blueprints/resolve';
4
5
  import { formatDateTime } from '@sanity/cli-core/dates';
5
6
  import * as resolve from 'empathic/resolve';
6
7
  import { loadAndParseBlueprint, } from '../../actions/blueprints/blueprint.js';
7
8
  import { readConfigFile } from '../../actions/blueprints/config.js';
8
- import { resolveIds } from '../../actions/blueprints/resolve.js';
9
9
  import { getStack } from '../../actions/blueprints/stacks.js';
10
10
  import config, { RUNTIME_CLI_VERSION } from '../../config.js';
11
11
  import { presentBlueprintParserErrors } from '../../utils/display/errors.js';
@@ -92,7 +92,7 @@ export async function blueprintDoctorCore(options) {
92
92
  validateResources: options.validateResources || false,
93
93
  });
94
94
  const blueprintConfig = readConfigFile(blueprint.fileInfo.blueprintFilePath);
95
- const resolved = resolveIds({
95
+ const resolved = resolveStackConfig({
96
96
  module: blueprint.module,
97
97
  config: blueprintConfig,
98
98
  });
@@ -1,11 +1,11 @@
1
1
  import { existsSync, readFileSync, watchFile } from 'node:fs';
2
2
  import * as http from 'node:http';
3
3
  import { dirname } from 'node:path';
4
+ import { resolveStackConfig } from '@sanity/blueprints/resolve';
4
5
  import { default as mime } from 'mime-types';
5
6
  import { WebSocket, WebSocketServer } from 'ws';
6
7
  import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/blueprint.js';
7
8
  import { readConfigFile } from '../actions/blueprints/config.js';
8
- import { resolveIds } from '../actions/blueprints/resolve.js';
9
9
  import config from '../config.js';
10
10
  import { isRecord } from '../utils/is-record.js';
11
11
  import { isEventType, isGroqContextOptions, } from '../utils/types.js';
@@ -47,7 +47,7 @@ const app = (host, port, validateResources, executionOptions) => {
47
47
  const blueprint = await loadAndParseBlueprint(undefined, { validateResources });
48
48
  const { parsedBlueprint, fileInfo, module: blueprintModule } = blueprint;
49
49
  const blueprintConfig = readConfigFile(fileInfo.blueprintFilePath);
50
- const { projectId, organizationId } = resolveIds({
50
+ const { projectId, organizationId } = resolveStackConfig({
51
51
  module: blueprintModule,
52
52
  config: blueprintConfig,
53
53
  });
@@ -5,7 +5,7 @@ import { SANITY_FUNCTION_DURABLE } from '../../constants.js';
5
5
  import { isLocalFunctionResource } from '../types.js';
6
6
  import { findFunctionEntryPoint } from './find-entry-point.js';
7
7
  import { transpileFunction } from './transpile/function.js';
8
- const DURABLE_CONFIG_KEYS = ['event', 'concurrency', 'debounce', 'debounceKey'];
8
+ const DURABLE_CONFIG_KEYS = ['event', 'concurrency', 'debounce'];
9
9
  /**
10
10
  * Extracts the blueprint config from the function source code and mutates it to the resource object.
11
11
  * This is used for durable functions that may not have a config defined in the blueprint.
@@ -47,9 +47,6 @@ export const extractDurableConfig = async (resource, blueprintFileDir) => {
47
47
  if (resource.debounce === undefined && config?.debounce !== undefined) {
48
48
  resource.debounce = config.debounce;
49
49
  }
50
- if (resource.debounceKey === undefined && config?.debounceKey !== undefined) {
51
- resource.debounceKey = config.debounceKey;
52
- }
53
50
  // Validate the resource after merging the config values
54
51
  const errors = validateDurableFunction(resource);
55
52
  if (errors.length > 0) {