@sanity/runtime-cli 10.9.2 → 10.10.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 +20 -18
- package/dist/actions/functions/dev.d.ts +2 -1
- package/dist/actions/functions/dev.js +2 -2
- package/dist/commands/functions/dev.d.ts +1 -0
- package/dist/commands/functions/dev.js +5 -0
- package/dist/cores/functions/dev.d.ts +1 -0
- package/dist/cores/functions/dev.js +6 -2
- package/dist/server/app.d.ts +2 -1
- package/dist/server/app.js +3 -3
- package/dist/server/handlers/invoke.d.ts +2 -2
- package/dist/server/handlers/invoke.js +3 -3
- package/oclif.manifest.json +10 -1
- package/package.json +1 -1
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.
|
|
23
|
+
@sanity/runtime-cli/10.10.0 linux-x64 node-v22.20.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -88,7 +88,7 @@ EXAMPLES
|
|
|
88
88
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
91
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/add.ts)_
|
|
92
92
|
|
|
93
93
|
## `sanity-run blueprints config`
|
|
94
94
|
|
|
@@ -119,7 +119,7 @@ EXAMPLES
|
|
|
119
119
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
122
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/config.ts)_
|
|
123
123
|
|
|
124
124
|
## `sanity-run blueprints deploy`
|
|
125
125
|
|
|
@@ -141,7 +141,7 @@ EXAMPLES
|
|
|
141
141
|
$ sanity-run blueprints deploy --no-wait
|
|
142
142
|
```
|
|
143
143
|
|
|
144
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
144
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/deploy.ts)_
|
|
145
145
|
|
|
146
146
|
## `sanity-run blueprints destroy`
|
|
147
147
|
|
|
@@ -166,7 +166,7 @@ EXAMPLES
|
|
|
166
166
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
167
167
|
```
|
|
168
168
|
|
|
169
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
169
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/destroy.ts)_
|
|
170
170
|
|
|
171
171
|
## `sanity-run blueprints info`
|
|
172
172
|
|
|
@@ -188,7 +188,7 @@ EXAMPLES
|
|
|
188
188
|
$ sanity-run blueprints info --stack-id <stackId>
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
191
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/info.ts)_
|
|
192
192
|
|
|
193
193
|
## `sanity-run blueprints init [DIR]`
|
|
194
194
|
|
|
@@ -226,7 +226,7 @@ EXAMPLES
|
|
|
226
226
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
229
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/init.ts)_
|
|
230
230
|
|
|
231
231
|
## `sanity-run blueprints logs`
|
|
232
232
|
|
|
@@ -248,7 +248,7 @@ EXAMPLES
|
|
|
248
248
|
$ sanity-run blueprints logs --watch
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
251
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/logs.ts)_
|
|
252
252
|
|
|
253
253
|
## `sanity-run blueprints plan`
|
|
254
254
|
|
|
@@ -265,7 +265,7 @@ EXAMPLES
|
|
|
265
265
|
$ sanity-run blueprints plan
|
|
266
266
|
```
|
|
267
267
|
|
|
268
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
268
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/plan.ts)_
|
|
269
269
|
|
|
270
270
|
## `sanity-run blueprints stacks`
|
|
271
271
|
|
|
@@ -287,7 +287,7 @@ EXAMPLES
|
|
|
287
287
|
$ sanity-run blueprints stacks --project-id <projectId>
|
|
288
288
|
```
|
|
289
289
|
|
|
290
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
290
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/blueprints/stacks.ts)_
|
|
291
291
|
|
|
292
292
|
## `sanity-run functions dev`
|
|
293
293
|
|
|
@@ -295,10 +295,12 @@ Start the Sanity Function emulator
|
|
|
295
295
|
|
|
296
296
|
```
|
|
297
297
|
USAGE
|
|
298
|
-
$ sanity-run functions dev [-p <value>]
|
|
298
|
+
$ sanity-run functions dev [-p <value>] [-t <value>]
|
|
299
299
|
|
|
300
300
|
FLAGS
|
|
301
|
-
-p, --port=<value>
|
|
301
|
+
-p, --port=<value> Port to start emulator on
|
|
302
|
+
-t, --timeout=<value> Maximum execution time for all functions, in seconds. Takes precedence over function-specific
|
|
303
|
+
`timeout`
|
|
302
304
|
|
|
303
305
|
DESCRIPTION
|
|
304
306
|
Start the Sanity Function emulator
|
|
@@ -307,7 +309,7 @@ EXAMPLES
|
|
|
307
309
|
$ sanity-run functions dev --port 8974
|
|
308
310
|
```
|
|
309
311
|
|
|
310
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
312
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/dev.ts)_
|
|
311
313
|
|
|
312
314
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
313
315
|
|
|
@@ -329,7 +331,7 @@ EXAMPLES
|
|
|
329
331
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
330
332
|
```
|
|
331
333
|
|
|
332
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
334
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/env/add.ts)_
|
|
333
335
|
|
|
334
336
|
## `sanity-run functions env list NAME`
|
|
335
337
|
|
|
@@ -349,7 +351,7 @@ EXAMPLES
|
|
|
349
351
|
$ sanity-run functions env list MyFunction
|
|
350
352
|
```
|
|
351
353
|
|
|
352
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
354
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/env/list.ts)_
|
|
353
355
|
|
|
354
356
|
## `sanity-run functions env remove NAME KEY`
|
|
355
357
|
|
|
@@ -370,7 +372,7 @@ EXAMPLES
|
|
|
370
372
|
$ sanity-run functions env remove MyFunction API_URL
|
|
371
373
|
```
|
|
372
374
|
|
|
373
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
375
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/env/remove.ts)_
|
|
374
376
|
|
|
375
377
|
## `sanity-run functions logs NAME`
|
|
376
378
|
|
|
@@ -404,7 +406,7 @@ EXAMPLES
|
|
|
404
406
|
$ sanity-run functions logs <name> --delete
|
|
405
407
|
```
|
|
406
408
|
|
|
407
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
409
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/logs.ts)_
|
|
408
410
|
|
|
409
411
|
## `sanity-run functions test NAME`
|
|
410
412
|
|
|
@@ -451,7 +453,7 @@ EXAMPLES
|
|
|
451
453
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
452
454
|
```
|
|
453
455
|
|
|
454
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.
|
|
456
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v10.10.0/src/commands/functions/test.ts)_
|
|
455
457
|
|
|
456
458
|
## `sanity-run help [COMMAND]`
|
|
457
459
|
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { InvokeExecutionOptions } from '../../utils/types.js';
|
|
2
|
+
export declare function dev(port: number, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
|
|
@@ -4,6 +4,7 @@ export default class DevCommand extends Command {
|
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
6
|
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
};
|
|
8
9
|
run(): Promise<void>;
|
|
9
10
|
}
|
|
@@ -5,6 +5,11 @@ export default class DevCommand extends Command {
|
|
|
5
5
|
static examples = ['<%= config.bin %> <%= command.id %> --port 8974'];
|
|
6
6
|
static flags = {
|
|
7
7
|
port: Flags.integer({ char: 'p', description: 'Port to start emulator on', required: false }),
|
|
8
|
+
timeout: Flags.integer({
|
|
9
|
+
char: 't',
|
|
10
|
+
description: 'Maximum execution time for all functions, in seconds. Takes precedence over function-specific `timeout`',
|
|
11
|
+
required: false,
|
|
12
|
+
}),
|
|
8
13
|
};
|
|
9
14
|
async run() {
|
|
10
15
|
const { flags } = await this.parse(DevCommand);
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { dev } from '../../actions/functions/dev.js';
|
|
2
2
|
export async function functionDevCore(options) {
|
|
3
3
|
const { log, flags } = options;
|
|
4
|
-
const { port = 8080 } = flags;
|
|
4
|
+
const { port = 8080, timeout } = flags;
|
|
5
|
+
// Construct execution options only if timeout is provided
|
|
6
|
+
const executionOptions = timeout
|
|
7
|
+
? { timeout }
|
|
8
|
+
: undefined;
|
|
5
9
|
try {
|
|
6
|
-
await dev(Number(port));
|
|
10
|
+
await dev(Number(port), executionOptions);
|
|
7
11
|
log(`Server is running on http://localhost:${port}\n`);
|
|
8
12
|
return {
|
|
9
13
|
success: true,
|
package/dist/server/app.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type InvokeExecutionOptions } from '../utils/types.js';
|
|
2
|
+
declare const app: (port: number, executionOptions?: Partial<InvokeExecutionOptions>) => void;
|
|
2
3
|
declare function parseDocumentUrl(url: string): {
|
|
3
4
|
projectId: string;
|
|
4
5
|
dataset: string;
|
package/dist/server/app.js
CHANGED
|
@@ -5,10 +5,10 @@ import { WebSocketServer } from 'ws';
|
|
|
5
5
|
import { readLocalBlueprint } from '../actions/blueprints/blueprint.js';
|
|
6
6
|
import config from '../config.js';
|
|
7
7
|
import { isRecord } from '../utils/is-record.js';
|
|
8
|
-
import { isEventType } from '../utils/types.js';
|
|
8
|
+
import { isEventType, } from '../utils/types.js';
|
|
9
9
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
10
10
|
const host = 'localhost';
|
|
11
|
-
const app = (port) => {
|
|
11
|
+
const app = (port, executionOptions) => {
|
|
12
12
|
const requestListener = async (req, res) => {
|
|
13
13
|
res.setHeader('Content-Type', 'application/json');
|
|
14
14
|
switch (true) {
|
|
@@ -41,7 +41,7 @@ const app = (port) => {
|
|
|
41
41
|
else {
|
|
42
42
|
delete context.clientOptions.token;
|
|
43
43
|
}
|
|
44
|
-
const result = await handleInvokeRequest(functionName, event, metadata, context);
|
|
44
|
+
const result = await handleInvokeRequest(functionName, event, metadata, context, executionOptions);
|
|
45
45
|
// Add Server-Timing header
|
|
46
46
|
const timingHeaders = [];
|
|
47
47
|
for (const [key, value] of Object.entries(result.timings)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InvocationResponse, InvokeContextOptions, InvokePayloadOptions } from '../../utils/types.js';
|
|
2
|
-
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: Pick<InvokePayloadOptions, 'event' | 'before' | 'after'>, context: InvokeContextOptions): Promise<InvocationResponse & {
|
|
1
|
+
import type { InvocationResponse, InvokeContextOptions, InvokeExecutionOptions, InvokePayloadOptions } from '../../utils/types.js';
|
|
2
|
+
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: Pick<InvokePayloadOptions, 'event' | 'before' | 'after'>, context: InvokeContextOptions, executionOptions?: Partial<InvokeExecutionOptions>): Promise<InvocationResponse & {
|
|
3
3
|
timings: Record<string, number>;
|
|
4
4
|
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { readLocalBlueprint } from '../../actions/blueprints/blueprint.js';
|
|
2
2
|
import { findFunctionByName } from '../../utils/find-function.js';
|
|
3
3
|
import invoke from '../../utils/invoke-local.js';
|
|
4
|
-
export async function handleInvokeRequest(functionName, event, metadata, context) {
|
|
4
|
+
export async function handleInvokeRequest(functionName, event, metadata, context, executionOptions) {
|
|
5
5
|
const start = performance.now();
|
|
6
6
|
const { parsedBlueprint } = await readLocalBlueprint();
|
|
7
7
|
const resource = findFunctionByName(parsedBlueprint, functionName);
|
|
@@ -11,8 +11,8 @@ export async function handleInvokeRequest(functionName, event, metadata, context
|
|
|
11
11
|
...metadata,
|
|
12
12
|
};
|
|
13
13
|
const response = await invoke(resource, payload, context, {
|
|
14
|
-
forceColor: false,
|
|
15
|
-
timeout: resource.timeout,
|
|
14
|
+
forceColor: executionOptions?.forceColor ?? false,
|
|
15
|
+
timeout: executionOptions?.timeout ?? resource.timeout,
|
|
16
16
|
});
|
|
17
17
|
const timings = { ...response.timings, 'blueprint:read': readBlueprintTime };
|
|
18
18
|
return { ...response, timings };
|
package/oclif.manifest.json
CHANGED
|
@@ -638,6 +638,15 @@
|
|
|
638
638
|
"hasDynamicHelp": false,
|
|
639
639
|
"multiple": false,
|
|
640
640
|
"type": "option"
|
|
641
|
+
},
|
|
642
|
+
"timeout": {
|
|
643
|
+
"char": "t",
|
|
644
|
+
"description": "Maximum execution time for all functions, in seconds. Takes precedence over function-specific `timeout`",
|
|
645
|
+
"name": "timeout",
|
|
646
|
+
"required": false,
|
|
647
|
+
"hasDynamicHelp": false,
|
|
648
|
+
"multiple": false,
|
|
649
|
+
"type": "option"
|
|
641
650
|
}
|
|
642
651
|
},
|
|
643
652
|
"hasDynamicHelp": false,
|
|
@@ -1132,5 +1141,5 @@
|
|
|
1132
1141
|
]
|
|
1133
1142
|
}
|
|
1134
1143
|
},
|
|
1135
|
-
"version": "10.
|
|
1144
|
+
"version": "10.10.0"
|
|
1136
1145
|
}
|