@sanity/runtime-cli 17.7.0-next.g78a5cd2 → 17.7.1-next.g09b9981

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.7.0-next.g78a5cd2/src/commands/blueprints/add.ts)_
93
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/config.ts)_
130
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/deploy.ts)_
186
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/destroy.ts)_
224
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/doctor.ts)_
256
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/info.ts)_
294
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/init.ts)_
358
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/logs.ts)_
404
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/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.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/plan.ts)_
482
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/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.7.0-next.g78a5cd2/src/commands/blueprints/promote.ts)_
518
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/blueprints/promote.ts)_
519
519
 
520
520
  ## `sanity-run blueprints stacks`
521
521
 
@@ -551,7 +551,7 @@ EXAMPLES
551
551
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
552
552
  ```
553
553
 
554
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/blueprints/stacks.ts)_
554
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/blueprints/stacks.ts)_
555
555
 
556
556
  ## `sanity-run functions add`
557
557
 
@@ -603,7 +603,7 @@ EXAMPLES
603
603
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
604
604
  ```
605
605
 
606
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/add.ts)_
606
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/add.ts)_
607
607
 
608
608
  ## `sanity-run functions dev`
609
609
 
@@ -638,7 +638,7 @@ EXAMPLES
638
638
  $ sanity-run functions dev --timeout 60
639
639
  ```
640
640
 
641
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/dev.ts)_
641
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/dev.ts)_
642
642
 
643
643
  ## `sanity-run functions env add NAME KEY VALUE`
644
644
 
@@ -671,7 +671,7 @@ EXAMPLES
671
671
  $ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
672
672
  ```
673
673
 
674
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/env/add.ts)_
674
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/env/add.ts)_
675
675
 
676
676
  ## `sanity-run functions env list NAME`
677
677
 
@@ -701,7 +701,7 @@ EXAMPLES
701
701
  $ sanity-run functions env list --stack <name-or-id> MyFunction
702
702
  ```
703
703
 
704
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/env/list.ts)_
704
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/env/list.ts)_
705
705
 
706
706
  ## `sanity-run functions env remove NAME KEY`
707
707
 
@@ -733,7 +733,7 @@ EXAMPLES
733
733
  $ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
734
734
  ```
735
735
 
736
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/env/remove.ts)_
736
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/env/remove.ts)_
737
737
 
738
738
  ## `sanity-run functions logs [NAME]`
739
739
 
@@ -773,7 +773,7 @@ EXAMPLES
773
773
  $ sanity-run functions logs <name> --delete
774
774
  ```
775
775
 
776
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/logs.ts)_
776
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/logs.ts)_
777
777
 
778
778
  ## `sanity-run functions test [NAME]`
779
779
 
@@ -830,7 +830,7 @@ EXAMPLES
830
830
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
831
831
  ```
832
832
 
833
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.0-next.g78a5cd2/src/commands/functions/test.ts)_
833
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.7.1-next.g09b9981/src/commands/functions/test.ts)_
834
834
 
835
835
  ## `sanity-run help [COMMAND]`
836
836
 
@@ -2,6 +2,8 @@ import { setTimeout as sleep } from 'node:timers/promises';
2
2
  import { createHintCollector } from '../../utils/blueprints/hints.js';
3
3
  import { setupLogPolling } from './logs-polling.js';
4
4
  import { classifyOperationPoll, getOperation, OPERATION_POLL_INITIAL_DELAY_MS, OPERATION_POLL_INTERVAL_MS, OPERATION_POLL_MAX_CONSECUTIVE_ERRORS, } from './operations.js';
5
+ const IDLE_SPINNER_DELAY_MS = 30_000;
6
+ const IDLE_SPINNER_UPDATE_INTERVAL_MS = 15_000;
5
7
  /**
6
8
  * Stream logs and poll an operation until it settles.
7
9
  * handles log-stream lifecycle, retry budget, and idle messaging;
@@ -11,10 +13,19 @@ export async function waitForOperation(options) {
11
13
  const { stackId, operationId, auth, log, bin, verbose = false, includeDestroyed, progressNoun, } = options;
12
14
  const logHints = createHintCollector(bin);
13
15
  let logStreamCleanup = null;
16
+ let idleSpinner;
17
+ const stopIdleSpinner = (restoreOperationProgress = false) => {
18
+ if (!idleSpinner)
19
+ return;
20
+ idleSpinner.stop();
21
+ idleSpinner = undefined;
22
+ if (restoreOperationProgress)
23
+ log.showProgress();
24
+ };
14
25
  try {
15
26
  log.showProgress();
16
27
  let lastLogAt = Date.now();
17
- let idleMessageShown = false;
28
+ let nextIdleSpinnerUpdateAt = IDLE_SPINNER_DELAY_MS;
18
29
  let consecutiveErrors = 0;
19
30
  let lastStatus;
20
31
  logStreamCleanup = setupLogPolling({
@@ -25,6 +36,8 @@ export async function waitForOperation(options) {
25
36
  verbose,
26
37
  onActivity: () => {
27
38
  lastLogAt = Date.now();
39
+ nextIdleSpinnerUpdateAt = IDLE_SPINNER_DELAY_MS;
40
+ stopIdleSpinner(true);
28
41
  },
29
42
  onLogEntry: (logEntry) => logHints.inspectLog(logEntry),
30
43
  });
@@ -43,12 +56,14 @@ export async function waitForOperation(options) {
43
56
  if (state === 'completed') {
44
57
  if (logStreamCleanup)
45
58
  logStreamCleanup();
59
+ stopIdleSpinner();
46
60
  log('');
47
61
  return { type: 'completed' };
48
62
  }
49
63
  if (state === 'failed') {
50
64
  if (logStreamCleanup)
51
65
  logStreamCleanup();
66
+ stopIdleSpinner();
52
67
  log('');
53
68
  return { type: 'failed', logHints: logHints.getSuggestions() };
54
69
  }
@@ -59,6 +74,7 @@ export async function waitForOperation(options) {
59
74
  if (consecutiveErrors >= OPERATION_POLL_MAX_CONSECUTIVE_ERRORS) {
60
75
  if (logStreamCleanup)
61
76
  logStreamCleanup();
77
+ stopIdleSpinner();
62
78
  log('');
63
79
  return { type: 'unconfirmed', error: pollError ?? undefined };
64
80
  }
@@ -73,10 +89,18 @@ export async function waitForOperation(options) {
73
89
  lastStatus = operation.status;
74
90
  }
75
91
  }
76
- if (!idleMessageShown && Date.now() - lastLogAt > 60_000) {
77
- log(`No new activity for 60 seconds. The ${progressNoun} is still running on Sanity servers.`);
78
- log(`You can safely exit and check status later with \`npx ${bin} blueprints info\`.`);
79
- idleMessageShown = true;
92
+ const idleFor = Date.now() - lastLogAt;
93
+ if (idleFor >= nextIdleSpinnerUpdateAt) {
94
+ const elapsedIdleMs = IDLE_SPINNER_DELAY_MS +
95
+ Math.floor((idleFor - IDLE_SPINNER_DELAY_MS) / IDLE_SPINNER_UPDATE_INTERVAL_MS) *
96
+ IDLE_SPINNER_UPDATE_INTERVAL_MS;
97
+ const elapsedIdleSeconds = elapsedIdleMs / 1000;
98
+ const text = `No new activity for ${elapsedIdleSeconds} seconds. The ${progressNoun} is still running on Sanity servers. You can safely exit and check status later with \`npx ${bin} blueprints info\`.`;
99
+ if (idleSpinner)
100
+ idleSpinner.start(text);
101
+ else
102
+ idleSpinner = log.ora(text).start();
103
+ nextIdleSpinnerUpdateAt = elapsedIdleMs + IDLE_SPINNER_UPDATE_INTERVAL_MS;
80
104
  }
81
105
  await sleep(OPERATION_POLL_INTERVAL_MS);
82
106
  }
@@ -87,6 +111,7 @@ export async function waitForOperation(options) {
87
111
  throw error;
88
112
  }
89
113
  finally {
114
+ stopIdleSpinner();
90
115
  log.clearProgress();
91
116
  }
92
117
  }
@@ -83,9 +83,11 @@ function resourceName(res, displayNameAttribute) {
83
83
  }
84
84
  function deployedResourceName(res, displayNameAttribute, verbose = false) {
85
85
  const nameParts = [styleText(['bold', 'green'], res.name)];
86
- const displayName = displayNameAttribute &&
87
- typeof res.parameters[displayNameAttribute] === 'string' &&
88
- res.parameters[displayNameAttribute];
86
+ // deployed state: prefer the resolved value, fall back to the authored one
87
+ const nameValue = displayNameAttribute
88
+ ? (res.resolvedParameters?.[displayNameAttribute] ?? res.parameters[displayNameAttribute])
89
+ : undefined;
90
+ const displayName = typeof nameValue === 'string' && nameValue;
89
91
  if (displayName && displayName !== res.name)
90
92
  nameParts.push(styleText('green', `"${displayName}"`));
91
93
  if (verbose)
@@ -158,7 +160,9 @@ function buildOutputTree(resources, createName, mapToResource, verbose = false)
158
160
  export function formatDeployedResourceTree(resources, verbose = false) {
159
161
  if (!resources || resources.length === 0)
160
162
  return ' Zero deployed resources';
161
- const output = buildOutputTree(resources, (category, res, v) => deployedResourceName(res, category.displayNameAttribute, v), (res) => ({ name: res.name, type: res.type, ...res.parameters }), verbose);
163
+ const output = buildOutputTree(resources, (category, res, v) => deployedResourceName(res, category.displayNameAttribute, v),
164
+ // deployed state: prefer resolved values, fall back to authored ones
165
+ (res) => ({ name: res.name, type: res.type, ...(res.resolvedParameters ?? res.parameters) }), verbose);
162
166
  return `${treeify(output)}\n`;
163
167
  }
164
168
  export function formatResourceTree(resources, verbose = false) {
@@ -8,7 +8,11 @@ function formatLabeledValue(label, value) {
8
8
  return `${styleText('dim', `${label}:`)} ${value}`;
9
9
  }
10
10
  export function arrayifyCors(resource) {
11
- return [formatLabeledValue('origin', resource.origin)];
11
+ const details = [formatLabeledValue('origin', resource.origin)];
12
+ if (resource.allowCredentials !== undefined) {
13
+ details.push(formatLabeledValue('allowCredentials', resource.allowCredentials));
14
+ }
15
+ return details;
12
16
  }
13
17
  export function arrayifyDataset(resource) {
14
18
  const details = [formatLabeledValue('title', resource.datasetName)];
@@ -1,4 +1,15 @@
1
1
  import { ORGANIZATION_SCOPED_FUNCTION_TYPES, PROJECT_SCOPED_FUNCTION_TYPES } from '../../constants.js';
2
+ const REFERENCE_PREFIX = '$.resources.';
3
+ /**
4
+ * A scope ID the API can use: a literal, never an unresolved Blueprint reference.
5
+ * Overly defensive and checks resource.parameters as fallback.
6
+ */
7
+ function literalScopeId(resource, key) {
8
+ const value = resource.resolvedParameters?.[key] ?? resource.parameters[key];
9
+ if (typeof value !== 'string' || value.startsWith(REFERENCE_PREFIX))
10
+ return undefined;
11
+ return value;
12
+ }
2
13
  /**
3
14
  * Resolves the correct auth scope for a function API request.
4
15
  *
@@ -8,11 +19,13 @@ import { ORGANIZATION_SCOPED_FUNCTION_TYPES, PROJECT_SCOPED_FUNCTION_TYPES } fro
8
19
  */
9
20
  export function resolveFunctionAuth(auth, deployedStack, resource) {
10
21
  // 1. explicit resource-level scope takes highest priority
11
- if (typeof resource.parameters.project === 'string') {
12
- return { ...auth, scopeType: 'project', scopeId: resource.parameters.project };
22
+ const project = literalScopeId(resource, 'project');
23
+ if (project) {
24
+ return { ...auth, scopeType: 'project', scopeId: project };
13
25
  }
14
- if (typeof resource.parameters.organization === 'string') {
15
- return { ...auth, scopeType: 'organization', scopeId: resource.parameters.organization };
26
+ const organization = literalScopeId(resource, 'organization');
27
+ if (organization) {
28
+ return { ...auth, scopeType: 'organization', scopeId: organization };
16
29
  }
17
30
  // 2. project-scoped function types: resolve a project ID or fail
18
31
  if (PROJECT_SCOPED_FUNCTION_TYPES.has(resource.type)) {
@@ -33,7 +33,10 @@ export interface AuthParams {
33
33
  export interface BlueprintResourceRecord extends BlueprintResource {
34
34
  id: string;
35
35
  externalId?: string | null;
36
+ /** Authored values; a value can be an unresolved `$.resources.<name>` reference */
36
37
  parameters: Record<string, unknown>;
38
+ /** Values deployment used, with references resolved */
39
+ resolvedParameters?: Record<string, unknown>;
37
40
  }
38
41
  /** The deployed resource; complete with external ID */
39
42
  export interface DeployedResource extends BlueprintResourceRecord {
@@ -3127,5 +3127,5 @@
3127
3127
  ]
3128
3128
  }
3129
3129
  },
3130
- "version": "17.7.0-next.g78a5cd2"
3130
+ "version": "17.7.1-next.g09b9981"
3131
3131
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "17.7.0-next.g78a5cd2",
4
+ "version": "17.7.1-next.g09b9981",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",