@sanity/runtime-cli 10.1.3 → 10.2.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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity-run COMMAND
21
21
  running command...
22
22
  $ sanity-run (--version)
23
- @sanity/runtime-cli/10.1.3 linux-x64 node-v22.18.0
23
+ @sanity/runtime-cli/10.2.0 linux-x64 node-v22.18.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -52,8 +52,9 @@ Add a Resource to a Blueprint
52
52
 
53
53
  ```
54
54
  USAGE
55
- $ sanity-run blueprints add TYPE [--example <value> | -n <value> | --fn-type document-publish | --fn-language
56
- ts|js | --javascript | --fn-helpers | --fn-installer skip|npm|pnpm|yarn] [-i | ]
55
+ $ sanity-run blueprints add TYPE [--example <value> | -n <value> | --fn-type
56
+ document-publish|document-create|document-delete|document-update | --fn-language ts|js | --javascript | --fn-helpers
57
+ | --fn-installer skip|npm|pnpm|yarn] [-i | ]
57
58
 
58
59
  ARGUMENTS
59
60
  TYPE (function) Type of Resource to add (e.g. function)
@@ -68,7 +69,7 @@ FLAGS
68
69
  --fn-language=<option> [default: ts] Language of the new Function
69
70
  <options: ts|js>
70
71
  --fn-type=<option> Type of new Function
71
- <options: document-publish>
72
+ <options: document-publish|document-create|document-delete|document-update>
72
73
  --javascript Use JavaScript instead of TypeScript
73
74
 
74
75
  DESCRIPTION
@@ -83,10 +84,10 @@ EXAMPLES
83
84
 
84
85
  $ sanity-run blueprints add function --name my-function --fn-type document-publish
85
86
 
86
- $ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
87
+ $ sanity-run blueprints add function --name my-function --fn-type document-update --lang js
87
88
  ```
88
89
 
89
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/add.ts)_
90
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/add.ts)_
90
91
 
91
92
  ## `sanity-run blueprints config`
92
93
 
@@ -117,7 +118,7 @@ EXAMPLES
117
118
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
118
119
  ```
119
120
 
120
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/config.ts)_
121
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/config.ts)_
121
122
 
122
123
  ## `sanity-run blueprints deploy`
123
124
 
@@ -139,7 +140,7 @@ EXAMPLES
139
140
  $ sanity-run blueprints deploy --no-wait
140
141
  ```
141
142
 
142
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/deploy.ts)_
143
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/deploy.ts)_
143
144
 
144
145
  ## `sanity-run blueprints destroy`
145
146
 
@@ -164,7 +165,7 @@ EXAMPLES
164
165
  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
165
166
  ```
166
167
 
167
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/destroy.ts)_
168
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/destroy.ts)_
168
169
 
169
170
  ## `sanity-run blueprints info`
170
171
 
@@ -186,7 +187,7 @@ EXAMPLES
186
187
  $ sanity-run blueprints info --stack-id <stackId>
187
188
  ```
188
189
 
189
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/info.ts)_
190
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/info.ts)_
190
191
 
191
192
  ## `sanity-run blueprints init [DIR]`
192
193
 
@@ -224,7 +225,7 @@ EXAMPLES
224
225
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
225
226
  ```
226
227
 
227
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/init.ts)_
228
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/init.ts)_
228
229
 
229
230
  ## `sanity-run blueprints logs`
230
231
 
@@ -246,7 +247,7 @@ EXAMPLES
246
247
  $ sanity-run blueprints logs --watch
247
248
  ```
248
249
 
249
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/logs.ts)_
250
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/logs.ts)_
250
251
 
251
252
  ## `sanity-run blueprints plan`
252
253
 
@@ -263,7 +264,7 @@ EXAMPLES
263
264
  $ sanity-run blueprints plan
264
265
  ```
265
266
 
266
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/plan.ts)_
267
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/plan.ts)_
267
268
 
268
269
  ## `sanity-run blueprints stacks`
269
270
 
@@ -285,7 +286,7 @@ EXAMPLES
285
286
  $ sanity-run blueprints stacks --project-id <projectId>
286
287
  ```
287
288
 
288
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/blueprints/stacks.ts)_
289
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/blueprints/stacks.ts)_
289
290
 
290
291
  ## `sanity-run functions dev`
291
292
 
@@ -305,7 +306,7 @@ EXAMPLES
305
306
  $ sanity-run functions dev --port 8974
306
307
  ```
307
308
 
308
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/dev.ts)_
309
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/dev.ts)_
309
310
 
310
311
  ## `sanity-run functions env add NAME KEY VALUE`
311
312
 
@@ -327,7 +328,7 @@ EXAMPLES
327
328
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
328
329
  ```
329
330
 
330
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/env/add.ts)_
331
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/env/add.ts)_
331
332
 
332
333
  ## `sanity-run functions env list NAME`
333
334
 
@@ -347,7 +348,7 @@ EXAMPLES
347
348
  $ sanity-run functions env list MyFunction
348
349
  ```
349
350
 
350
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/env/list.ts)_
351
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/env/list.ts)_
351
352
 
352
353
  ## `sanity-run functions env remove NAME KEY`
353
354
 
@@ -368,7 +369,7 @@ EXAMPLES
368
369
  $ sanity-run functions env remove MyFunction API_URL
369
370
  ```
370
371
 
371
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/env/remove.ts)_
372
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/env/remove.ts)_
372
373
 
373
374
  ## `sanity-run functions logs NAME`
374
375
 
@@ -402,7 +403,7 @@ EXAMPLES
402
403
  $ sanity-run functions logs <name> --delete
403
404
  ```
404
405
 
405
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/logs.ts)_
406
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/logs.ts)_
406
407
 
407
408
  ## `sanity-run functions test NAME`
408
409
 
@@ -437,7 +438,7 @@ EXAMPLES
437
438
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
438
439
  ```
439
440
 
440
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.1.3/src/commands/functions/test.ts)_
441
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.2.0/src/commands/functions/test.ts)_
441
442
 
442
443
  ## `sanity-run help [COMMAND]`
443
444
 
@@ -227,7 +227,7 @@ export function readConfigFile(blueprintFilePath) {
227
227
  const config = JSON.parse(readFileSync(configPath, 'utf8'));
228
228
  return { configPath, ...config };
229
229
  }
230
- catch (err) {
230
+ catch {
231
231
  return null;
232
232
  }
233
233
  }
@@ -239,7 +239,7 @@ export function readConfigFile(blueprintFilePath) {
239
239
  const config = JSON.parse(readFileSync(configFilePath, 'utf8'));
240
240
  return config || null;
241
241
  }
242
- catch (err) {
242
+ catch {
243
243
  return null;
244
244
  }
245
245
  }
@@ -255,7 +255,7 @@ export function writeConfigFile({ blueprintFilePath, projectId, stackId, }) {
255
255
  try {
256
256
  config = JSON.parse(readFileSync(configPath, 'utf8'));
257
257
  }
258
- catch (err) {
258
+ catch {
259
259
  // config broken, start fresh
260
260
  }
261
261
  }
@@ -81,7 +81,7 @@ export function streamLogs({ stackId, after, auth, onLog, onOpen, onError, }) {
81
81
  console.error('Error parsing logs event:', err);
82
82
  }
83
83
  });
84
- eventSource.onerror = (err) => {
84
+ eventSource.onerror = () => {
85
85
  onError('Connection to log stream failed or was closed');
86
86
  if (eventSource.readyState === eventSource.CLOSED) {
87
87
  console.log('Connection is CLOSED');
@@ -66,7 +66,7 @@ export function streamLogs(id, auth, onLog, onOpen, onError) {
66
66
  console.error('Error parsing logs event:', err);
67
67
  }
68
68
  });
69
- eventSource.onerror = (err) => {
69
+ eventSource.onerror = () => {
70
70
  onError('Connection to log stream failed or was closed');
71
71
  if (eventSource.readyState === eventSource.CLOSED) {
72
72
  console.log('Connection is CLOSED');
@@ -124,7 +124,7 @@ function extractFunctionConfig(exampleFiles) {
124
124
  packageJsonContent.blueprintResourceItem = undefined;
125
125
  exampleFiles['package.json'] = JSON.stringify(packageJsonContent, null, 2);
126
126
  }
127
- catch (error) {
127
+ catch {
128
128
  return null;
129
129
  }
130
130
  return functionConfig;
@@ -144,7 +144,7 @@ function extractInstructions(exampleFiles) {
144
144
  packageJsonContent.exampleInstructions = undefined;
145
145
  exampleFiles['package.json'] = JSON.stringify(packageJsonContent, null, 2);
146
146
  }
147
- catch (error) {
147
+ catch {
148
148
  return null;
149
149
  }
150
150
  return instructions;
@@ -8,7 +8,7 @@ export default class AddCommand extends BlueprintCommand {
8
8
  '<%= config.bin %> <%= command.id %> function --helpers',
9
9
  '<%= config.bin %> <%= command.id %> function --name my-function',
10
10
  '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish',
11
- '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish --lang js',
11
+ '<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-update --lang js',
12
12
  ];
13
13
  static args = {
14
14
  type: Args.string({
@@ -29,7 +29,7 @@ export default class AddCommand extends BlueprintCommand {
29
29
  }),
30
30
  'fn-type': Flags.string({
31
31
  description: 'Type of new Function',
32
- options: ['document-publish' /*, 'document-create', 'document-delete'*/],
32
+ options: ['document-publish', 'document-create', 'document-delete', 'document-update'],
33
33
  aliases: ['function-type'],
34
34
  dependsOn: ['name'],
35
35
  }),
@@ -8,17 +8,17 @@ import { createFunctionResource } from '../../actions/blueprints/resources.js';
8
8
  import { verifyExampleExists, writeExample } from '../../actions/sanity/examples.js';
9
9
  import { check, indent, warn } from '../../utils/display/presenters.js';
10
10
  import { validateFunctionName } from '../../utils/validate/resource.js';
11
- const FUNCTION_BLUEPRINT_RESOURCE_TEMPLATE = `
11
+ const generateFunctionBlueprintResourceTemplate = (fnName, eventName) => `
12
12
  export default defineBlueprint({
13
13
  resources: [
14
14
  // ...
15
- defineDocumentFunction({name: '{{fnName}}'}), // ← add this line
15
+ defineDocumentFunction({name: '${fnName}', event: {on: ['${eventName}']}}), // ← add this line
16
16
  ],
17
17
  })
18
18
  `;
19
19
  export async function blueprintAddCore(options) {
20
20
  const root = cwd();
21
- const { bin = 'sanity', log, blueprint, args, flags } = options;
21
+ const { log, blueprint, args, flags } = options;
22
22
  const { blueprintFilePath } = blueprint.fileInfo;
23
23
  const { type: resourceType } = args;
24
24
  const { example: flagExample, name: flagResourceName, 'fn-type': flagFnType, javascript: flagJs, 'fn-helpers': flagFnHelpers, install: flagI, 'fn-installer': flagFnInstaller, // can be 'skip'!
@@ -116,8 +116,8 @@ export async function blueprintAddCore(options) {
116
116
  }
117
117
  const fnType = flagFnType || (await promptForFunctionType());
118
118
  const fnLang = flagFnLang || (await promptForFunctionLang());
119
- if (!['document-publish', 'document-create', 'document-delete'].includes(fnType)) {
120
- throw new Error('Invalid function type. Must be one of: document-publish, document-create, document-delete');
119
+ if (!['document-publish', 'document-create', 'document-delete', 'document-update'].includes(fnType)) {
120
+ throw new Error('Invalid function type. Must be one of: document-publish, document-create, document-delete, document-update');
121
121
  }
122
122
  let addHelpers;
123
123
  let installCommand;
@@ -163,7 +163,7 @@ export async function blueprintAddCore(options) {
163
163
  case '.ts':
164
164
  case '.js':
165
165
  case '.mjs': {
166
- log(highlight(FUNCTION_BLUEPRINT_RESOURCE_TEMPLATE.replace('{{fnName}}', fnName)));
166
+ log(highlight(generateFunctionBlueprintResourceTemplate(fnName, fnType.split('-')[1])));
167
167
  break;
168
168
  }
169
169
  default:
@@ -205,8 +205,9 @@ async function promptForFunctionType() {
205
205
  message: 'Choose function type:',
206
206
  choices: [
207
207
  { name: 'Document Publish', value: 'document-publish' },
208
- { name: 'Document Create', value: 'document-create', disabled: '(Coming soon)' },
209
- { name: 'Document Delete', value: 'document-delete', disabled: '(Coming soon)' },
208
+ { name: 'Document Create', value: 'document-create' },
209
+ { name: 'Document Delete', value: 'document-delete' },
210
+ { name: 'Document Update', value: 'document-update' },
210
211
  ],
211
212
  default: 'document-publish',
212
213
  },
@@ -119,7 +119,7 @@ export async function blueprintConfigCore(options) {
119
119
  log('Configuration updated successfully.');
120
120
  return { success: true };
121
121
  }
122
- catch (error) {
122
+ catch {
123
123
  log(`Unable to update config. These values should be set in ${BLUEPRINT_DIR}/${BLUEPRINT_CONFIG_FILE}`);
124
124
  log(highlight(JSON.stringify({ metadata: { projectId: updatedProjectId, stackId: updatedStackId } }, null, 2)));
125
125
  return {
@@ -131,7 +131,7 @@ export async function blueprintConfigCore(options) {
131
131
  // Default return (shouldn't reach here with proper flow control)
132
132
  return { success: true };
133
133
  }
134
- catch (error) {
134
+ catch {
135
135
  return { success: false, error: 'Unknown error' };
136
136
  }
137
137
  }
@@ -6,7 +6,7 @@ import { destroyStack, getStack } from '../../actions/blueprints/stacks.js';
6
6
  import { setupLogStreaming } from '../../utils/display/blueprints-logs-streaming.js';
7
7
  import { niceId } from '../../utils/display/presenters.js';
8
8
  export async function blueprintDestroyCore(options) {
9
- const { bin = 'sanity', log, token, blueprint, flags } = options;
9
+ const { log, token, blueprint, flags } = options;
10
10
  const { force = false, 'project-id': flagProjectId, 'stack-id': flagStackId, 'no-wait': noWait = false, } = flags;
11
11
  // 3-flag combo: just destroy it
12
12
  if (flagProjectId && flagStackId && force) {
@@ -138,7 +138,7 @@ export async function blueprintInitCore(options) {
138
138
  });
139
139
  log(check(`${chalk.bold('Added dependency:')} @sanity/blueprints`));
140
140
  }
141
- catch (err) {
141
+ catch {
142
142
  log(warn('Unable to add @sanity/blueprints to your project.'));
143
143
  }
144
144
  }
@@ -30,13 +30,12 @@ export async function blueprintLogsCore(options) {
30
30
  log(`No recent logs found for deployment ${niceId(stackId)}`);
31
31
  }
32
32
  // Set up streaming log display
33
- const streamCleanup = await setupLogStreaming({
33
+ await setupLogStreaming({
34
34
  stackId,
35
35
  auth,
36
36
  log,
37
37
  showBanner: true,
38
38
  });
39
- // Note: don't call streamCleanup() here, it will close the stream
40
39
  // Return a special key for streaming mode
41
40
  return {
42
41
  success: true,
@@ -16,7 +16,7 @@ export async function functionLogsCore(options) {
16
16
  return streamLogs({ name, externalId, auth, json, utc, log });
17
17
  return getLogs({ name, externalId, auth, limit, json, utc, log });
18
18
  }
19
- async function deleteLogs({ name, externalId, auth, force, log, }) {
19
+ async function deleteLogs({ name, externalId, auth, force, }) {
20
20
  if (!force) {
21
21
  const { certain } = await inquirer.prompt({
22
22
  type: 'confirm',
@@ -36,14 +36,14 @@ async function deleteLogs({ name, externalId, auth, force, log, }) {
36
36
  spinner.succeed('Logs deleted');
37
37
  return { success: true };
38
38
  }
39
- async function streamLogs({ name, externalId, auth, json, utc, log, }) {
39
+ async function streamLogs({ name, externalId, auth, log, }) {
40
40
  const spinner = ora(`Setting up streaming logs session for function ${niceId(name)}`).start();
41
41
  try {
42
42
  spinner.stop();
43
43
  log(`Streaming log session for function ${niceId(name)}`);
44
44
  log(`Watching for new logs... ${chalk.bold('ctrl+c')} to stop`);
45
45
  const onOpen = () => {
46
- // TODO delete line 97 and uncomment 101 when Fns service is updated
46
+ // TODO delete log("Watching for new logs...") and uncomment this when Fns service is updated
47
47
  // log(`Watching for new logs... ${chalk.bold('ctrl+c')} to stop`)
48
48
  };
49
49
  const renderLog = (logEntry) => {
@@ -39,7 +39,6 @@ const app = (port) => {
39
39
  context.clientOptions.token = config.token || undefined;
40
40
  }
41
41
  else {
42
- // biome-ignore lint/performance/noDelete: but we love delete
43
42
  delete context.clientOptions.token;
44
43
  }
45
44
  const start = performance.now();
@@ -82,7 +81,7 @@ const app = (port) => {
82
81
  res.writeHead(200);
83
82
  res.end(JSON.stringify(json));
84
83
  }
85
- catch (error) {
84
+ catch {
86
85
  res.writeHead(200);
87
86
  res.end(JSON.stringify([]));
88
87
  }
@@ -106,7 +105,7 @@ const app = (port) => {
106
105
  res.writeHead(200);
107
106
  res.end(JSON.stringify(json));
108
107
  }
109
- catch (error) {
108
+ catch {
110
109
  res.writeHead(200);
111
110
  res.end(JSON.stringify([]));
112
111
  }
@@ -135,7 +134,7 @@ const app = (port) => {
135
134
  res.writeHead(200);
136
135
  res.end(JSON.stringify(json));
137
136
  }
138
- catch (error) {
137
+ catch {
139
138
  res.writeHead(200);
140
139
  res.end(JSON.stringify([]));
141
140
  }
@@ -761,22 +761,22 @@ body {
761
761
  }
762
762
 
763
763
  /* Layout */
764
- body > header {
764
+ header {
765
765
  grid-area: header;
766
766
  }
767
- body > filters-component {
767
+ filters-component {
768
768
  grid-area: filters;
769
769
  }
770
- body > nav {
770
+ nav {
771
771
  grid-area: left-sidebar;
772
772
  }
773
- body > main {
773
+ main {
774
774
  grid-area: main;
775
775
  /* Ensure main takes up available space if body is grid/flex */
776
776
  overflow: hidden; /* Prevent main itself from scrolling */
777
777
  min-height: 0; /* Needed for grid children height */
778
778
  }
779
- body > footer {
779
+ footer {
780
780
  grid-area: footer;
781
781
  }
782
782
 
@@ -1,7 +1,7 @@
1
1
  import {HighlightStyle, syntaxHighlighting, tags as t} from '../vendor/vendor.bundle.js'
2
2
 
3
3
  const red = 'light-dark(var(--red-600), var(--red-400))'
4
- const orange = 'light-dark(var(--orange-600), var(--orange-400))'
4
+ // const orange = 'light-dark(var(--orange-600), var(--orange-400))'
5
5
  const yellow = 'light-dark(var(--yellow-600), var(--yellow-400))'
6
6
  const green = 'light-dark(var(--green-600), var(--green-400))'
7
7
  const blue = 'light-dark(var(--blue-600), var(--blue-400))'
@@ -36,7 +36,7 @@ class ResponsePanel extends ApiBaseElement {
36
36
  updateResponse = ({result}) => {
37
37
  if (!result) return
38
38
 
39
- const {error, json, time, timings} = result
39
+ const {error, json, timings} = result
40
40
  if (!error) {
41
41
  const transaction = this.api.store.response.state.update({
42
42
  changes: {
@@ -26710,7 +26710,8 @@ function prettyBytes(number, options) {
26710
26710
  number = divide(number, (options.binary ? 1024 : 1000) ** exponent);
26711
26711
 
26712
26712
  if (!localeOptions) {
26713
- number = number.toPrecision(3);
26713
+ const minPrecision = Math.max(3, Number.parseInt(number, 10).toString().length);
26714
+ number = number.toPrecision(minPrecision);
26714
26715
  }
26715
26716
 
26716
26717
  const numberString = toLocaleString(Number(number), options.locale, localeOptions);
@@ -50,7 +50,7 @@ console.table = (data, columns) => {
50
50
  const originalWrite = process.stdout.write.bind(process.stdout)
51
51
  let buffer = ''
52
52
 
53
- process.stdout.write = (chunk, encoding, callback) => {
53
+ process.stdout.write = (chunk, _encoding, callback) => {
54
54
  buffer += chunk
55
55
  if (typeof callback === 'function') callback()
56
56
  }
@@ -8,7 +8,7 @@ import { formatLogEntry } from './logs-formatting.js';
8
8
  */
9
9
  export async function setupLogStreaming(config) {
10
10
  const { stackId, auth, log, showBanner, after } = config;
11
- let newestTimestamp = new Date().getTime();
11
+ let newestTimestamp = Date.now();
12
12
  const onLogReceived = (logEntry) => {
13
13
  if (!isNewerLog(logEntry, newestTimestamp))
14
14
  return;
@@ -4,7 +4,7 @@ async function getUserAgent() {
4
4
  const pkg = await (await import('../../package.json', { with: { type: 'json' } })).default;
5
5
  return `${pkg.name}@${pkg.version}`;
6
6
  }
7
- catch (err) {
7
+ catch {
8
8
  return 'unknown@0.0.0';
9
9
  }
10
10
  }
@@ -52,7 +52,7 @@ export async function applyGroqRule(resource, data) {
52
52
  // TODO can this be multiple documents?
53
53
  return currentFunctionDocumentSet[0] || {};
54
54
  }
55
- catch (e) {
55
+ catch {
56
56
  // parsing/validating the groq rule we do up front as part of functions HTTP API
57
57
  // so this likely would be triggered by evaluating the query, if anything
58
58
  throw Error('⚠️ failed parsing/evaluating GROQ rule! Skipping invoke.');
@@ -7,7 +7,7 @@ export async function getLatestNpmVersion(pkg) {
7
7
  const data = await res.json();
8
8
  return data.version;
9
9
  }
10
- catch (error) {
10
+ catch {
11
11
  return 'latest';
12
12
  }
13
13
  }
@@ -15,6 +15,8 @@ export interface AuthParams {
15
15
  export interface GroqRule {
16
16
  on: Array<string>;
17
17
  filter?: string;
18
+ includeDrafts?: boolean;
19
+ includeAllVersions?: boolean;
18
20
  projection?: string;
19
21
  }
20
22
  /** @internal */
@@ -3,6 +3,7 @@ export function validateFunctionName(name) {
3
3
  // must be 6+ characters, no special characters, no spaces, allow _ and -
4
4
  return /^[a-zA-Z0-9][a-zA-Z0-9_-]{5,}$/.test(name);
5
5
  }
6
+ const validFunctionEventNames = ['publish', 'create', 'update', 'delete'];
6
7
  export function validateFunctionResource(resource) {
7
8
  const { name: fnName } = resource;
8
9
  const msgPrefix = `Function "${fnName}":`;
@@ -25,9 +26,9 @@ export function validateFunctionResource(resource) {
25
26
  type: BlueprintParserErrorType.MissingRequiredProperty,
26
27
  });
27
28
  }
28
- else if (resource.event.on[0] !== 'publish') {
29
+ else if (!resource.event.on.every((evt) => validFunctionEventNames.includes(evt))) {
29
30
  errors.push({
30
- message: `${msgPrefix} First event.on value must be "publish"`,
31
+ message: `${msgPrefix} event.on values must be one of ${validFunctionEventNames.map((e) => `"${e}"`).join(', ')}`,
31
32
  type: BlueprintParserErrorType.InvalidValue,
32
33
  });
33
34
  }
@@ -43,6 +44,19 @@ export function validateFunctionResource(resource) {
43
44
  type: BlueprintParserErrorType.InvalidType,
44
45
  });
45
46
  }
47
+ if (resource.event?.includeDrafts && typeof resource.event.includeDrafts !== 'boolean') {
48
+ errors.push({
49
+ message: `${msgPrefix} event.includeDrafts must be a boolean`,
50
+ type: BlueprintParserErrorType.InvalidType,
51
+ });
52
+ }
53
+ if (resource.event?.includeAllVersions &&
54
+ typeof resource.event.includeAllVersions !== 'boolean') {
55
+ errors.push({
56
+ message: `${msgPrefix} event.includeAllVersions must be a boolean`,
57
+ type: BlueprintParserErrorType.InvalidType,
58
+ });
59
+ }
46
60
  if (resource.memory !== undefined) {
47
61
  if (!Number.isInteger(resource.memory)) {
48
62
  errors.push({
@@ -18,7 +18,7 @@
18
18
  "<%= config.bin %> <%= command.id %> function --helpers",
19
19
  "<%= config.bin %> <%= command.id %> function --name my-function",
20
20
  "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish",
21
- "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-publish --lang js"
21
+ "<%= config.bin %> <%= command.id %> function --name my-function --fn-type document-update --lang js"
22
22
  ],
23
23
  "flags": {
24
24
  "example": {
@@ -59,7 +59,10 @@
59
59
  "hasDynamicHelp": false,
60
60
  "multiple": false,
61
61
  "options": [
62
- "document-publish"
62
+ "document-publish",
63
+ "document-create",
64
+ "document-delete",
65
+ "document-update"
63
66
  ],
64
67
  "type": "option"
65
68
  },
@@ -901,5 +904,5 @@
901
904
  ]
902
905
  }
903
906
  },
904
- "version": "10.1.3"
907
+ "version": "10.2.0"
905
908
  }
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": "10.1.3",
4
+ "version": "10.2.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -79,33 +79,33 @@
79
79
  "@architect/inventory": "^4.0.9",
80
80
  "@oclif/core": "^4.5.2",
81
81
  "@oclif/plugin-help": "^6.2.32",
82
- "@sanity/client": "^7.8.1",
82
+ "@sanity/client": "^7.8.2",
83
83
  "adm-zip": "^0.5.16",
84
84
  "array-treeify": "^0.1.5",
85
85
  "cardinal": "^2.1.1",
86
- "chalk": "^5.4.1",
86
+ "chalk": "^5.5.0",
87
87
  "eventsource": "^4.0.0",
88
88
  "find-up": "^7.0.0",
89
89
  "get-folder-size": "^5.0.0",
90
90
  "groq-js": "^1.17.3",
91
- "inquirer": "^12.9.0",
91
+ "inquirer": "^12.9.2",
92
92
  "jiti": "^2.5.1",
93
93
  "mime-types": "^3.0.1",
94
94
  "ora": "^8.2.0",
95
95
  "tar-stream": "^3.1.7",
96
- "vite": "^6.3.5",
96
+ "vite": "^7.1.2",
97
97
  "vite-tsconfig-paths": "^5.1.4",
98
98
  "ws": "^8.18.3",
99
99
  "xdg-basedir": "^5.1.0"
100
100
  },
101
101
  "devDependencies": {
102
- "@biomejs/biome": "2.1.4",
102
+ "@biomejs/biome": "2.2.0",
103
103
  "@codemirror/lang-json": "^6.0.2",
104
104
  "@codemirror/state": "^6.5.2",
105
105
  "@enhance/store": "^1.0.2",
106
106
  "@lezer/highlight": "^1.2.1",
107
107
  "@oclif/test": "^4.1.13",
108
- "@playwright/test": "^1.54.1",
108
+ "@playwright/test": "^1.54.2",
109
109
  "@rollup/plugin-node-resolve": "^16.0.1",
110
110
  "@sanity/blueprints": "^0.1.0",
111
111
  "@sanity/functions": "^1.0.3",
@@ -117,13 +117,13 @@
117
117
  "@types/ws": "^8.18.1",
118
118
  "codemirror": "^6.0.2",
119
119
  "mentoss": "^0.11.0",
120
- "oclif": "^4.22.5",
121
- "pretty-bytes": "^7.0.0",
120
+ "oclif": "^4.22.9",
121
+ "pretty-bytes": "^7.0.1",
122
122
  "pretty-ms": "^9.2.0",
123
123
  "rollup": "^4.46.2",
124
124
  "shx": "^0.4.0",
125
125
  "ts-node": "^10.9.2",
126
- "typescript": "^5.8.3",
126
+ "typescript": "^5.9.2",
127
127
  "vitest": "3.2.4"
128
128
  },
129
129
  "oclif": {