@sanity/runtime-cli 17.16.0 → 17.17.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 (29) hide show
  1. package/README.md +19 -19
  2. package/dist/actions/blueprints/assets.d.ts +3 -3
  3. package/dist/actions/blueprints/assets.js +3 -3
  4. package/dist/actions/blueprints/pre-deploy.js +3 -3
  5. package/dist/actions/blueprints/process-assets.js +3 -2
  6. package/dist/config.js +4 -1
  7. package/dist/cores/functions/logs.d.ts +7 -0
  8. package/dist/cores/functions/logs.js +29 -16
  9. package/dist/cores/functions/test.js +15 -4
  10. package/dist/server/app.js +2 -2
  11. package/dist/server/static/vendor/vendor.bundle.js +21 -42
  12. package/dist/utils/blueprints/group-resources.d.ts +2 -1
  13. package/dist/utils/blueprints/group-resources.js +3 -3
  14. package/dist/utils/blueprints/resolve-deployed-resources.d.ts +2 -2
  15. package/dist/utils/blueprints/resolve-deployed-resources.js +4 -4
  16. package/dist/utils/bundles/prepare-asset.d.ts +3 -3
  17. package/dist/utils/bundles/prepare-asset.js +46 -12
  18. package/dist/utils/functions/child-runtime/durable.js +141 -23
  19. package/dist/utils/functions/child-runtime/getBatchResults.js +75 -0
  20. package/dist/utils/functions/child-runtime/step-history.d.ts +15 -0
  21. package/dist/utils/functions/child-runtime/step-history.js +52 -0
  22. package/dist/utils/functions/invoke/local.js +19 -8
  23. package/dist/utils/functions/invoke/resolve-invoke-type.d.ts +2 -2
  24. package/dist/utils/functions/invoke/resolve-invoke-type.js +2 -2
  25. package/dist/utils/functions/transpile/function.js +3 -0
  26. package/dist/utils/types.d.ts +21 -13
  27. package/dist/utils/types.js +1 -1
  28. package/oclif.manifest.json +1 -1
  29. package/package.json +5 -5
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.16.0/src/commands/blueprints/add.ts)_
93
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/config.ts)_
130
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/deploy.ts)_
186
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/destroy.ts)_
224
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/doctor.ts)_
256
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/info.ts)_
294
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/init.ts)_
358
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/logs.ts)_
404
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/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.17.0/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.16.0/src/commands/blueprints/plan.ts)_
482
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/promote.ts)_
518
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/blueprints/stacks.ts)_
559
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/add.ts)_
611
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/dev.ts)_
646
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/env/add.ts)_
679
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/env/list.ts)_
709
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/env/remove.ts)_
741
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/logs.ts)_
781
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/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.16.0/src/commands/functions/test.ts)_
839
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.17.0/src/commands/functions/test.ts)_
840
840
 
841
841
  ## `sanity-run help [COMMAND]`
842
842
 
@@ -1,5 +1,5 @@
1
1
  import type { BlueprintResource } from '@sanity/blueprints';
2
- import type { AuthParams, InstallerType, PrepAssetFn } from '../../utils/types.js';
2
+ import type { AuthParams, InstallerType, PrepAssetFn, ResolvedResource } from '../../utils/types.js';
3
3
  export declare const assetCheckUrl: string;
4
4
  export declare const assetStashUrl: string;
5
5
  export type StashAssetResult = {
@@ -18,8 +18,8 @@ export type StashAssetResult = {
18
18
  success: false;
19
19
  error: string;
20
20
  };
21
- export declare function stashAsset<R extends BlueprintResource>({ resource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }: {
22
- resource: R;
21
+ export declare function stashAsset<R extends BlueprintResource>({ resolvedResource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }: {
22
+ resolvedResource: ResolvedResource<R>;
23
23
  prepAsset: PrepAssetFn<R>;
24
24
  auth: AuthParams;
25
25
  blueprintFileDir: string;
@@ -4,10 +4,10 @@ import getHeaders from '../../utils/get-headers.js';
4
4
  const assetsUrl = blueprintsUrl('assets');
5
5
  export const assetCheckUrl = `${assetsUrl}/check`;
6
6
  export const assetStashUrl = `${assetsUrl}/stash`;
7
- export async function stashAsset({ resource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }) {
7
+ export async function stashAsset({ resolvedResource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }) {
8
8
  let cleanup = async () => { };
9
9
  try {
10
- const prepResult = await prepAsset({ resource, blueprintFileDir, installer });
10
+ const prepResult = await prepAsset({ resolvedResource, blueprintFileDir, installer });
11
11
  if (prepResult.success === false) {
12
12
  await prepResult.cleanup();
13
13
  return {
@@ -26,7 +26,7 @@ export async function stashAsset({ resource, prepAsset, auth, blueprintFileDir,
26
26
  assetParameter: prepResult.assetParameter,
27
27
  metadata: prepResult.metadata,
28
28
  cleanup,
29
- resourceName: resource.name,
29
+ resourceName: resolvedResource.resource.name,
30
30
  auth,
31
31
  fetchFn,
32
32
  });
@@ -18,7 +18,7 @@ const preDeployConfigs = [
18
18
  resourceType: (type) => type in BUNDLE_SPECS,
19
19
  async prepareAsset(options) {
20
20
  return prepareBundleAsset({
21
- resource: options.resource,
21
+ resolvedResource: options.resolvedResource,
22
22
  blueprintFileDir: options.blueprintFileDir,
23
23
  });
24
24
  },
@@ -30,7 +30,7 @@ const preDeployConfigs = [
30
30
  resourceType: (type) => type.startsWith(SANITY_FUNCTION_PREFIX),
31
31
  async prepareAsset(options) {
32
32
  return prepareFunctionAsset({
33
- resource: options.resource,
33
+ resource: options.resolvedResource.resource,
34
34
  blueprintFileDir: options.blueprintFileDir,
35
35
  installer: options.installer,
36
36
  });
@@ -74,7 +74,7 @@ export async function preDeploy(options) {
74
74
  });
75
75
  const assetResources = [];
76
76
  for (const r of resolvedResources) {
77
- const config = getPredeployConfig(r);
77
+ const config = getPredeployConfig(r.resource);
78
78
  if (typeof config !== 'undefined' && typeof config.prepareAsset === 'function') {
79
79
  assetResources.push({ resource: r, prepareAsset: config.prepareAsset });
80
80
  }
@@ -42,13 +42,14 @@ function getAssetConcurrency() {
42
42
  const configured = Number(env.SANITY_ASSET_CONCURRENCY);
43
43
  return Number.isSafeInteger(configured) && configured > 0 ? configured : DEFAULT_ASSET_CONCURRENCY;
44
44
  }
45
- async function processAsset(resource, prepAsset, options) {
45
+ async function processAsset(resolvedResource, prepAsset, options) {
46
+ const { resource } = resolvedResource;
46
47
  const { auth, blueprintFileDir, installer, fetchFn } = options;
47
48
  let assetTimeoutTimer;
48
49
  let result;
49
50
  try {
50
51
  result = await Promise.race([
51
- stashAsset({ resource, prepAsset, blueprintFileDir, auth, fetchFn, installer }),
52
+ stashAsset({ resolvedResource, prepAsset, blueprintFileDir, auth, fetchFn, installer }),
52
53
  new Promise((_, reject) => {
53
54
  assetTimeoutTimer = setTimeout(() => {
54
55
  reject(new Error(`Processing ${resource.name} timed out after ${assetTimeoutS}s`));
package/dist/config.js CHANGED
@@ -38,7 +38,10 @@ const apiUrls = {
38
38
  staging: 'https://api.sanity.work/',
39
39
  default: 'http://api.sanity/',
40
40
  };
41
- const apiUrl = sanityEnv ? (apiUrls[sanityEnv] ?? sanityEnv) : apiUrls.default;
41
+ const ensureTrailingSlash = (url) => (url.endsWith('/') ? url : `${url}/`);
42
+ const apiUrl = sanityEnv
43
+ ? (apiUrls[sanityEnv] ?? ensureTrailingSlash(sanityEnv))
44
+ : apiUrls.default;
42
45
  const studioDomains = {
43
46
  production: 'sanity.studio',
44
47
  staging: 'studio.sanity.work',
@@ -15,3 +15,10 @@ export interface FunctionLogsOptions extends DeployedBlueprintConfig {
15
15
  helpText: string;
16
16
  }
17
17
  export declare function functionLogsCore(options: FunctionLogsOptions): Promise<CoreResult>;
18
+ /**
19
+ * Formats a date as `[YYYY-MM-DD, HH:mm:ss]` in either UTC or local time.
20
+ * The shape is identical in both cases so `--utc` only changes the timezone.
21
+ * @param date
22
+ * @param utc
23
+ */
24
+ export declare function formatTimestamp(date: Date, utc: boolean | undefined): [string, string];
@@ -45,7 +45,7 @@ async function deleteLogs({ name, externalId, auth, force, log, }) {
45
45
  spinner.succeed('Logs deleted');
46
46
  return { success: true };
47
47
  }
48
- async function streamLogs({ name, externalId, auth, log, }) {
48
+ async function streamLogs({ name, externalId, auth, utc, log, }) {
49
49
  const spinner = log.ora(`Setting up streaming logs session for function ${niceId(name)}`).start();
50
50
  try {
51
51
  spinner.stop();
@@ -58,7 +58,7 @@ async function streamLogs({ name, externalId, auth, log, }) {
58
58
  alreadyOpened = true;
59
59
  };
60
60
  const renderLog = (logEntry) => {
61
- log(formatLog(logEntry, true));
61
+ log(formatLog(logEntry, utc));
62
62
  };
63
63
  streamLogsAction(externalId, auth, renderLog, onOpen, (error) => log.error(`${styleText('red', 'Error:')} ${error}`), log);
64
64
  // Return a special key for streaming mode
@@ -96,8 +96,8 @@ async function getLogs({ name, externalId, auth, limit, json, utc, log, }) {
96
96
  }
97
97
  }
98
98
  else {
99
- const cleaned = filteredLogs.map(({ time, level, message, operationName, attempt, requestId, executionArn, }) => {
100
- const isDurable = executionArn !== undefined;
99
+ const cleaned = filteredLogs.map(({ time, level, message, operationName, attempt, requestId, executionArn, executionId, }) => {
100
+ const isDurable = executionArn !== undefined || executionId !== undefined;
101
101
  const isStep = operationName !== undefined || attempt !== undefined;
102
102
  const durableContext = isDurable ? (isStep ? 'step' : 'handler') : undefined;
103
103
  return {
@@ -120,12 +120,10 @@ async function getLogs({ name, externalId, auth, limit, json, utc, log, }) {
120
120
  * @param utc
121
121
  */
122
122
  function formatLog(entry, utc) {
123
- const { time, level, message, operationName, attempt, executionArn } = entry;
124
- const date = new Date(time);
125
- const [dateString, timeString] = utc
126
- ? date.toISOString().slice(0, 19).split('T')
127
- : [date.toLocaleDateString(), date.toLocaleTimeString()];
128
- const durableAnnotation = durableLogAnnotation({ operationName, attempt, executionArn });
123
+ const { time, level, message, operationName, attempt, executionArn, executionId } = entry;
124
+ const execId = executionId || executionArn;
125
+ const [dateString, timeString] = formatTimestamp(new Date(time), utc);
126
+ const durableAnnotation = durableLogAnnotation({ operationName, attempt, executionId: execId });
129
127
  return [
130
128
  styleText('bold', dateString),
131
129
  styleText(['bold', 'blue'], timeString),
@@ -134,20 +132,35 @@ function formatLog(entry, utc) {
134
132
  message,
135
133
  ].join(' ');
136
134
  }
135
+ /**
136
+ * Formats a date as `[YYYY-MM-DD, HH:mm:ss]` in either UTC or local time.
137
+ * The shape is identical in both cases so `--utc` only changes the timezone.
138
+ * @param date
139
+ * @param utc
140
+ */
141
+ export function formatTimestamp(date, utc) {
142
+ if (utc)
143
+ return date.toISOString().slice(0, 19).split('T');
144
+ const pad = (n) => n.toString().padStart(2, '0');
145
+ const dateString = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
146
+ const timeString = `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
147
+ return [dateString, timeString];
148
+ }
137
149
  /**
138
150
  * Log annotation for durable functions.
139
151
  * @param operationName
140
152
  * @param attempt
141
- * @param executionArn
153
+ * @param executionId
142
154
  */
143
- function durableLogAnnotation({ operationName, attempt, executionArn, }) {
155
+ function durableLogAnnotation({ operationName, attempt, executionArn, executionId, }) {
144
156
  /**
145
- * executionArn is included on durable function logs, but not on regular function logs.
146
- * If executionArn is defined, we can assume the log is from a durable function.
147
- * If executionArn is defined and operationName and attempt are undefined, the logger is in the handler context
157
+ * executionId is included on durable function logs, but not on regular function logs.
158
+ * If executionId is defined, we can assume the log is from a durable function.
159
+ * If executionId is defined and operationName and attempt are undefined, the logger is in the handler context
148
160
  */
161
+ const execId = executionId || executionArn;
149
162
  const annotationParts = [
150
- executionArn !== undefined && operationName === undefined && attempt === undefined
163
+ execId !== undefined && operationName === undefined && attempt === undefined
151
164
  ? 'handler'
152
165
  : undefined,
153
166
  ...(operationName ? [operationName] : []),
@@ -55,7 +55,7 @@ export async function functionTestCore(options) {
55
55
  apiHost: config.apiUrl,
56
56
  token: config.token || undefined,
57
57
  withUserToken,
58
- resources: resolvedResources,
58
+ resolvedResources,
59
59
  blueprintFileDir: dirname(blueprint.fileInfo.blueprintFilePath),
60
60
  log,
61
61
  };
@@ -116,7 +116,9 @@ export async function functionTestCore(options) {
116
116
  }
117
117
  };
118
118
  const logNestedRuns = () => {
119
- for (const run of [...nestedRuns].sort((a, b) => a.order - b.order)) {
119
+ // Remove buffered logs for durable runs
120
+ const runs = plan.isDurable ? nestedRuns.splice(0) : [...nestedRuns];
121
+ for (const run of runs.sort((a, b) => a.order - b.order)) {
120
122
  // Skip if is Durable so log ordering is retained
121
123
  if (run.isLiveDurable)
122
124
  continue;
@@ -155,10 +157,19 @@ export async function functionTestCore(options) {
155
157
  if (event.kind === 'delegate') {
156
158
  logNestedRuns();
157
159
  }
158
- const glyph = STEP_PHASE_GLYPH[event.phase] ?? '•';
160
+ const willRetry = event.phase === 'error' && typeof event.retryDelayMs === 'number';
161
+ const glyph = willRetry ? '⟳' : (STEP_PHASE_GLYPH[event.phase] ?? '•');
159
162
  const duration = typeof event.durationMs === 'number' ? ` (${Math.round(event.durationMs)}ms)` : '';
163
+ const retriesPerformed = (event.attempt ?? 1) - 1;
164
+ let retryNote = '';
165
+ if (willRetry) {
166
+ retryNote = ` retry ${event.attempt} of ${event.maxAttempts}`;
167
+ }
168
+ else if (event.phase === 'error' && retriesPerformed > 0) {
169
+ retryNote = ` failed after ${retriesPerformed} retries`;
170
+ }
160
171
  const detail = event.phase === 'error' && event.error ? ` ${event.error.message}` : '';
161
- lines.push(` ${glyph} ${event.name} [${event.kind}]${duration}${detail}`);
172
+ lines.push(` ${glyph} ${event.name} [${event.kind}]${duration}${detail}${retryNote}`);
162
173
  }
163
174
  return lines;
164
175
  }
@@ -8,7 +8,7 @@ import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/
8
8
  import { readConfigFile } from '../actions/blueprints/config.js';
9
9
  import config from '../config.js';
10
10
  import { isRecord } from '../utils/is-record.js';
11
- import { isEventType, isGroqContextOptions, } from '../utils/types.js';
11
+ import { isEventType, } from '../utils/types.js';
12
12
  import { handleInvokeRequest } from './handlers/invoke.js';
13
13
  const app = (host, port, validateResources, executionOptions) => {
14
14
  // Send a JSON envelope to every connected UI client.
@@ -75,7 +75,7 @@ const app = (host, port, validateResources, executionOptions) => {
75
75
  const { data, func: functionName, metadata, } = parseInvokeRequest(Buffer.concat(body), dirname(fileInfo.blueprintFilePath));
76
76
  const { context, event } = data;
77
77
  // replace user token if required
78
- if (isGroqContextOptions(context)) {
78
+ if ('clientOptions' in context) {
79
79
  if (context.clientOptions.token) {
80
80
  context.clientOptions.token = config.token || undefined;
81
81
  }
@@ -1,4 +1,4 @@
1
- //#region node_modules/@lezer/common/dist/index.js
1
+ // node_modules/@lezer/common/dist/index.js
2
2
  /**
3
3
  The default maximum length of a `TreeBuffer` node.
4
4
  */
@@ -1517,8 +1517,7 @@ var StringInput = class {
1517
1517
  }
1518
1518
  };
1519
1519
  new NodeProp({ perNode: true });
1520
- //#endregion
1521
- //#region node_modules/@lezer/lr/dist/index.js
1520
+ // node_modules/@lezer/lr/dist/index.js
1522
1521
  /**
1523
1522
  A parse stack. These are used internally by the parser to track
1524
1523
  parsing progress. They also provide some properties and methods
@@ -2963,8 +2962,7 @@ function getSpecializer(spec) {
2963
2962
  }
2964
2963
  return spec.get;
2965
2964
  }
2966
- //#endregion
2967
- //#region node_modules/@lezer/highlight/dist/index.js
2965
+ // node_modules/@lezer/highlight/dist/index.js
2968
2966
  var nextTagID = 0;
2969
2967
  /**
2970
2968
  Highlighting tags are markers that denote a highlighting category.
@@ -3836,8 +3834,7 @@ tagHighlighter([
3836
3834
  class: "tok-punctuation"
3837
3835
  }
3838
3836
  ]);
3839
- //#endregion
3840
- //#region node_modules/@lezer/json/dist/index.js
3837
+ // node_modules/@lezer/json/dist/index.js
3841
3838
  var jsonHighlighting = styleTags({
3842
3839
  String: tags.string,
3843
3840
  Number: tags.number,
@@ -3886,8 +3883,7 @@ var parser = LRParser.deserialize({
3886
3883
  topRules: { "JsonText": [0, 1] },
3887
3884
  tokenPrec: 0
3888
3885
  });
3889
- //#endregion
3890
- //#region node_modules/@marijn/find-cluster-break/src/index.js
3886
+ // node_modules/@marijn/find-cluster-break/src/index.js
3891
3887
  var rangeFrom = [];
3892
3888
  var rangeTo = [];
3893
3889
  (() => {
@@ -3957,8 +3953,7 @@ function surrogateHigh$1(ch) {
3957
3953
  function codePointSize$1(code) {
3958
3954
  return code < 65536 ? 1 : 2;
3959
3955
  }
3960
- //#endregion
3961
- //#region node_modules/@codemirror/state/dist/index.js
3956
+ // node_modules/@codemirror/state/dist/index.js
3962
3957
  /**
3963
3958
  The data structure for documents. @nonabstract
3964
3959
  */
@@ -7368,8 +7363,7 @@ function findColumn(string, col, tabSize, strict) {
7368
7363
  }
7369
7364
  return strict === true ? -1 : string.length;
7370
7365
  }
7371
- //#endregion
7372
- //#region node_modules/style-mod/src/style-mod.js
7366
+ // node_modules/style-mod/src/style-mod.js
7373
7367
  var C = "ͼ";
7374
7368
  var COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
7375
7369
  var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
@@ -7460,8 +7454,7 @@ var StyleSet = class {
7460
7454
  if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
7461
7455
  }
7462
7456
  };
7463
- //#endregion
7464
- //#region node_modules/w3c-keyname/index.js
7457
+ // node_modules/w3c-keyname/index.js
7465
7458
  var base = {
7466
7459
  8: "Backspace",
7467
7460
  9: "Tab",
@@ -7561,8 +7554,7 @@ function keyName(event) {
7561
7554
  if (name == "Down") name = "ArrowDown";
7562
7555
  return name;
7563
7556
  }
7564
- //#endregion
7565
- //#region node_modules/crelt/index.js
7557
+ // node_modules/crelt/index.js
7566
7558
  function crelt() {
7567
7559
  var elt = arguments[0];
7568
7560
  if (typeof elt == "string") elt = document.createElement(elt);
@@ -7584,8 +7576,7 @@ function add(elt, child) {
7584
7576
  else if (Array.isArray(child)) for (var i = 0; i < child.length; i++) add(elt, child[i]);
7585
7577
  else throw new RangeError("Unsupported child node: " + child);
7586
7578
  }
7587
- //#endregion
7588
- //#region node_modules/@codemirror/view/dist/index.js
7579
+ // node_modules/@codemirror/view/dist/index.js
7589
7580
  var nav = typeof navigator != "undefined" ? navigator : {
7590
7581
  userAgent: "",
7591
7582
  vendor: "",
@@ -17373,8 +17364,7 @@ line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
17373
17364
  function highlightActiveLineGutter() {
17374
17365
  return activeLineGutterHighlighter;
17375
17366
  }
17376
- //#endregion
17377
- //#region node_modules/@codemirror/language/dist/index.js
17367
+ // node_modules/@codemirror/language/dist/index.js
17378
17368
  var _a;
17379
17369
  /**
17380
17370
  Node prop stored in a parser's top syntax node to provide the
@@ -19120,8 +19110,7 @@ function createTokenType(extra, tagStr) {
19120
19110
  return type.id;
19121
19111
  }
19122
19112
  Direction.RTL, Direction.LTR;
19123
- //#endregion
19124
- //#region node_modules/@codemirror/lang-json/dist/index.js
19113
+ // node_modules/@codemirror/lang-json/dist/index.js
19125
19114
  /**
19126
19115
  A language provider that provides JSON parsing.
19127
19116
  */
@@ -19146,8 +19135,7 @@ JSON language support.
19146
19135
  function json() {
19147
19136
  return new LanguageSupport(jsonLanguage);
19148
19137
  }
19149
- //#endregion
19150
- //#region node_modules/@enhance/store/index.mjs
19138
+ // node_modules/@enhance/store/index.mjs
19151
19139
  var _state = {};
19152
19140
  var dirtyProps = [];
19153
19141
  var listeners = [];
@@ -19217,8 +19205,7 @@ function notify() {
19217
19205
  });
19218
19206
  dirtyProps.length = 0;
19219
19207
  }
19220
- //#endregion
19221
- //#region node_modules/@codemirror/commands/dist/index.js
19208
+ // node_modules/@codemirror/commands/dist/index.js
19222
19209
  /**
19223
19210
  Comment or uncomment the current selection. Will use line comments
19224
19211
  if available, otherwise falling back to block comments.
@@ -20929,8 +20916,7 @@ var defaultKeymap = /*@__PURE__*/ [
20929
20916
  run: toggleTabFocusMode
20930
20917
  }
20931
20918
  ].concat(standardKeymap);
20932
- //#endregion
20933
- //#region node_modules/@codemirror/search/dist/index.js
20919
+ // node_modules/@codemirror/search/dist/index.js
20934
20920
  var basicNormalize = typeof String.prototype.normalize == "function" ? (x) => x.normalize("NFKD") : (x) => x;
20935
20921
  /**
20936
20922
  A search cursor provides an iterator over text matches in a
@@ -22070,8 +22056,7 @@ var searchExtensions = [
22070
22056
  /*@__PURE__*/ Prec.low(searchHighlighter),
22071
22057
  baseTheme$2
22072
22058
  ];
22073
- //#endregion
22074
- //#region node_modules/@codemirror/autocomplete/dist/index.js
22059
+ // node_modules/@codemirror/autocomplete/dist/index.js
22075
22060
  /**
22076
22061
  An instance of this is passed to completion source functions.
22077
22062
  */
@@ -23549,8 +23534,7 @@ var completionKeymap = [
23549
23534
  }
23550
23535
  ];
23551
23536
  var completionKeymapExt = /*@__PURE__*/ Prec.highest(/*@__PURE__*/ keymap.computeN([completionConfig], (state) => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
23552
- //#endregion
23553
- //#region node_modules/@codemirror/lint/dist/index.js
23537
+ // node_modules/@codemirror/lint/dist/index.js
23554
23538
  var SelectedDiagnostic = class {
23555
23539
  constructor(from, to, diagnostic) {
23556
23540
  this.from = from;
@@ -24112,8 +24096,7 @@ var lintExtensions = [
24112
24096
  lintHover,
24113
24097
  baseTheme
24114
24098
  ];
24115
- //#endregion
24116
- //#region node_modules/codemirror/dist/index.js
24099
+ // node_modules/codemirror/dist/index.js
24117
24100
  /**
24118
24101
  This is an extension value that just pulls together a number of
24119
24102
  extensions that you might want in a basic editor. It is meant as a
@@ -24179,8 +24162,7 @@ var basicSetup = /*@__PURE__*/ (() => [
24179
24162
  ...lintKeymap
24180
24163
  ])
24181
24164
  ])();
24182
- //#endregion
24183
- //#region node_modules/pretty-bytes/index.js
24165
+ // node_modules/pretty-bytes/index.js
24184
24166
  var BYTE_UNITS = [
24185
24167
  "B",
24186
24168
  "kB",
@@ -24296,8 +24278,7 @@ function prettyBytes(number, options) {
24296
24278
  }
24297
24279
  return applyFixedWidth(prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[exponent], options.fixedWidth);
24298
24280
  }
24299
- //#endregion
24300
- //#region node_modules/parse-ms/index.js
24281
+ // node_modules/parse-ms/index.js
24301
24282
  var toZeroIfInfinity = (value) => Number.isFinite(value) ? value : 0;
24302
24283
  function parseNumber(milliseconds) {
24303
24284
  return {
@@ -24330,8 +24311,7 @@ function parseMilliseconds(milliseconds) {
24330
24311
  }
24331
24312
  throw new TypeError("Expected a finite number or bigint");
24332
24313
  }
24333
- //#endregion
24334
- //#region node_modules/pretty-ms/index.js
24314
+ // node_modules/pretty-ms/index.js
24335
24315
  var isZero = (value) => value === 0 || value === 0n;
24336
24316
  var pluralize = (word, count) => count === 1 || count === 1n ? word : `${word}s`;
24337
24317
  var SECOND_ROUNDING_EPSILON = 1e-7;
@@ -24410,5 +24390,4 @@ function prettyMilliseconds(milliseconds, options) {
24410
24390
  if (typeof options.unitCount === "number") result = result.slice(0, Math.max(options.unitCount, 1));
24411
24391
  return sign + result.join(separator);
24412
24392
  }
24413
- //#endregion
24414
24393
  export { Compartment, EditorState, EditorView, HighlightStyle, Store, basicSetup, json, prettyBytes, prettyMilliseconds, syntaxHighlighting, tags };
@@ -1,8 +1,9 @@
1
1
  import type { BlueprintResource } from '@sanity/blueprints';
2
+ import type { ResolvedResource } from '../types.js';
2
3
  export type GroupedBlueprintResource = {
3
4
  id: string;
4
5
  name: string;
5
6
  type: string;
6
7
  };
7
8
  export type GroupedBlueprintResources = Record<string, GroupedBlueprintResource[]>;
8
- export declare function groupBlueprintResources(blueprintResources: BlueprintResource[]): GroupedBlueprintResources;
9
+ export declare function groupBlueprintResources(blueprintResources: ResolvedResource<BlueprintResource>[]): GroupedBlueprintResources;