@sanity/runtime-cli 5.0.4 → 5.1.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/5.0.4 linux-x64 node-v22.15.0
23
+ @sanity/runtime-cli/5.1.0 linux-x64 node-v22.15.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -41,7 +41,6 @@ USAGE
41
41
  * [`sanity-run functions env add NAME KEY VALUE`](#sanity-run-functions-env-add-name-key-value)
42
42
  * [`sanity-run functions env list NAME`](#sanity-run-functions-env-list-name)
43
43
  * [`sanity-run functions env remove NAME KEY`](#sanity-run-functions-env-remove-name-key)
44
- * [`sanity-run functions invoke NAME`](#sanity-run-functions-invoke-name)
45
44
  * [`sanity-run functions logs NAME`](#sanity-run-functions-logs-name)
46
45
  * [`sanity-run functions test NAME`](#sanity-run-functions-test-name)
47
46
  * [`sanity-run help [COMMAND]`](#sanity-run-help-command)
@@ -78,7 +77,7 @@ EXAMPLES
78
77
  $ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
79
78
  ```
80
79
 
81
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/add.ts)_
80
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/add.ts)_
82
81
 
83
82
  ## `sanity-run blueprints config`
84
83
 
@@ -106,7 +105,7 @@ EXAMPLES
106
105
  $ sanity-run blueprints config --edit --project-id <projectId>
107
106
  ```
108
107
 
109
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/config.ts)_
108
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/config.ts)_
110
109
 
111
110
  ## `sanity-run blueprints deploy`
112
111
 
@@ -128,7 +127,7 @@ EXAMPLES
128
127
  $ sanity-run blueprints deploy --no-wait
129
128
  ```
130
129
 
131
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/deploy.ts)_
130
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/deploy.ts)_
132
131
 
133
132
  ## `sanity-run blueprints destroy`
134
133
 
@@ -148,7 +147,7 @@ EXAMPLES
148
147
  $ sanity-run blueprints destroy
149
148
  ```
150
149
 
151
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/destroy.ts)_
150
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/destroy.ts)_
152
151
 
153
152
  ## `sanity-run blueprints info`
154
153
 
@@ -165,7 +164,7 @@ EXAMPLES
165
164
  $ sanity-run blueprints info
166
165
  ```
167
166
 
168
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/info.ts)_
167
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/info.ts)_
169
168
 
170
169
  ## `sanity-run blueprints init [DIR]`
171
170
 
@@ -197,7 +196,7 @@ EXAMPLES
197
196
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId>
198
197
  ```
199
198
 
200
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/init.ts)_
199
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/init.ts)_
201
200
 
202
201
  ## `sanity-run blueprints logs`
203
202
 
@@ -219,7 +218,7 @@ EXAMPLES
219
218
  $ sanity-run blueprints logs --watch
220
219
  ```
221
220
 
222
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/logs.ts)_
221
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/logs.ts)_
223
222
 
224
223
  ## `sanity-run blueprints plan`
225
224
 
@@ -236,7 +235,7 @@ EXAMPLES
236
235
  $ sanity-run blueprints plan
237
236
  ```
238
237
 
239
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/plan.ts)_
238
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/blueprints/plan.ts)_
240
239
 
241
240
  ## `sanity-run functions dev`
242
241
 
@@ -256,7 +255,7 @@ EXAMPLES
256
255
  $ sanity-run functions dev --port 8974
257
256
  ```
258
257
 
259
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/dev.ts)_
258
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/dev.ts)_
260
259
 
261
260
  ## `sanity-run functions env add NAME KEY VALUE`
262
261
 
@@ -278,7 +277,7 @@ EXAMPLES
278
277
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
279
278
  ```
280
279
 
281
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/add.ts)_
280
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/env/add.ts)_
282
281
 
283
282
  ## `sanity-run functions env list NAME`
284
283
 
@@ -298,7 +297,7 @@ EXAMPLES
298
297
  $ sanity-run functions env list MyFunction
299
298
  ```
300
299
 
301
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/list.ts)_
300
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/env/list.ts)_
302
301
 
303
302
  ## `sanity-run functions env remove NAME KEY`
304
303
 
@@ -319,33 +318,7 @@ EXAMPLES
319
318
  $ sanity-run functions env remove MyFunction API_URL
320
319
  ```
321
320
 
322
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/remove.ts)_
323
-
324
- ## `sanity-run functions invoke NAME`
325
-
326
- Invoke a remote Sanity Function
327
-
328
- ```
329
- USAGE
330
- $ sanity-run functions invoke NAME [-d <value>] [-f <value>]
331
-
332
- ARGUMENTS
333
- NAME The name of the Sanity Function
334
-
335
- FLAGS
336
- -d, --data=<value> Data to send to the function
337
- -f, --file=<value> Read data from file and send to the function
338
-
339
- DESCRIPTION
340
- Invoke a remote Sanity Function
341
-
342
- EXAMPLES
343
- $ sanity-run functions invoke <name> --data '{ "id": 1 }'
344
-
345
- $ sanity-run functions invoke <name> --file 'payload.json'
346
- ```
347
-
348
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/invoke.ts)_
321
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/env/remove.ts)_
349
322
 
350
323
  ## `sanity-run functions logs NAME`
351
324
 
@@ -377,7 +350,7 @@ EXAMPLES
377
350
  $ sanity-run functions logs <name> --delete
378
351
  ```
379
352
 
380
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/logs.ts)_
353
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/logs.ts)_
381
354
 
382
355
  ## `sanity-run functions test NAME`
383
356
 
@@ -410,7 +383,7 @@ EXAMPLES
410
383
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
411
384
  ```
412
385
 
413
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/test.ts)_
386
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v5.1.0/src/commands/functions/test.ts)_
414
387
 
415
388
  ## `sanity-run help [COMMAND]`
416
389
 
@@ -1,5 +1,4 @@
1
1
  export * as dev from './dev.js';
2
2
  export * as env from './env/index.js';
3
- export * as invoke from './invoke.js';
4
3
  export * as logs from './logs.js';
5
4
  export * as test from './test.js';
@@ -1,5 +1,4 @@
1
1
  export * as dev from './dev.js';
2
2
  export * as env from './env/index.js';
3
- export * as invoke from './invoke.js';
4
3
  export * as logs from './logs.js';
5
4
  export * as test from './test.js';
@@ -500,55 +500,6 @@
500
500
  "dev.js"
501
501
  ]
502
502
  },
503
- "functions:invoke": {
504
- "aliases": [],
505
- "args": {
506
- "name": {
507
- "description": "The name of the Sanity Function",
508
- "name": "name",
509
- "required": true
510
- }
511
- },
512
- "description": "Invoke a remote Sanity Function",
513
- "examples": [
514
- "<%= config.bin %> <%= command.id %> <name> --data '{ \"id\": 1 }'",
515
- "<%= config.bin %> <%= command.id %> <name> --file 'payload.json'"
516
- ],
517
- "flags": {
518
- "data": {
519
- "char": "d",
520
- "description": "Data to send to the function",
521
- "name": "data",
522
- "required": false,
523
- "hasDynamicHelp": false,
524
- "multiple": false,
525
- "type": "option"
526
- },
527
- "file": {
528
- "char": "f",
529
- "description": "Read data from file and send to the function",
530
- "name": "file",
531
- "required": false,
532
- "hasDynamicHelp": false,
533
- "multiple": false,
534
- "type": "option"
535
- }
536
- },
537
- "hasDynamicHelp": false,
538
- "hiddenAliases": [],
539
- "id": "functions:invoke",
540
- "pluginAlias": "@sanity/runtime-cli",
541
- "pluginName": "@sanity/runtime-cli",
542
- "pluginType": "core",
543
- "strict": true,
544
- "isESM": true,
545
- "relativePath": [
546
- "dist",
547
- "commands",
548
- "functions",
549
- "invoke.js"
550
- ]
551
- },
552
503
  "functions:logs": {
553
504
  "aliases": [],
554
505
  "args": {
@@ -817,5 +768,5 @@
817
768
  ]
818
769
  }
819
770
  },
820
- "version": "5.0.4"
771
+ "version": "5.1.0"
821
772
  }
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": "5.0.4",
4
+ "version": "5.1.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- import type { AuthParams, InvokePayloadOptions } from '../../utils/types.js';
2
- export declare function invoke(id: string, options: InvokePayloadOptions, auth: AuthParams): Promise<{
3
- ok: boolean;
4
- error: any;
5
- json: any;
6
- }>;
@@ -1,18 +0,0 @@
1
- import config from '../../config.js';
2
- import buildPayload from '../../utils/build-payload.js';
3
- import getHeaders from '../../utils/get-headers.js';
4
- const { apiUrl } = config;
5
- export async function invoke(id, options, auth) {
6
- const payload = buildPayload(options);
7
- const response = await fetch(`${apiUrl}vX/functions/${id}/invoke`, {
8
- body: JSON.stringify({ data: payload }),
9
- headers: getHeaders(auth),
10
- method: 'POST',
11
- });
12
- const json = await response.json();
13
- return {
14
- ok: response.ok,
15
- error: response.ok ? null : json?.error?.message,
16
- json: response.ok ? json : undefined,
17
- };
18
- }
@@ -1,13 +0,0 @@
1
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
2
- export default class InvokeCommand extends DeployedBlueprintCommand<typeof InvokeCommand> {
3
- static args: {
4
- name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
- };
6
- static description: string;
7
- static examples: string[];
8
- static flags: {
9
- data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
- file: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
- };
12
- run(): Promise<void>;
13
- }
@@ -1,42 +0,0 @@
1
- import { Args, Flags } from '@oclif/core';
2
- import Spinner from 'yocto-spinner';
3
- import { invoke } from '../../actions/functions/invoke.js';
4
- import { DeployedBlueprintCommand } from '../../baseCommands.js';
5
- import { red } from '../../utils/display/colors.js';
6
- import { findFunctionByName } from '../../utils/find-function.js';
7
- export default class InvokeCommand extends DeployedBlueprintCommand {
8
- static args = {
9
- name: Args.string({ description: 'The name of the Sanity Function', required: true }),
10
- };
11
- static description = 'Invoke a remote Sanity Function';
12
- static examples = [
13
- `<%= config.bin %> <%= command.id %> <name> --data '{ "id": 1 }'`,
14
- `<%= config.bin %> <%= command.id %> <name> --file 'payload.json'`,
15
- ];
16
- static flags = {
17
- data: Flags.string({ char: 'd', description: 'Data to send to the function', required: false }),
18
- file: Flags.string({
19
- char: 'f',
20
- description: 'Read data from file and send to the function',
21
- required: false,
22
- }),
23
- };
24
- async run() {
25
- const args = this.args;
26
- const flags = this.flags;
27
- const spinner = Spinner({ text: `Invoking function "${args.name}"` }).start();
28
- const { externalId } = findFunctionByName(this.deployedStack, args.name);
29
- const result = await invoke(externalId, { data: flags.data, file: flags.file }, this.auth);
30
- if (result.ok) {
31
- spinner.success(`Invocation of ${args.name} succeeded`);
32
- if (result.json?.data?.type === 'Buffer') {
33
- return;
34
- }
35
- this.log(JSON.stringify(result.json, null, 2));
36
- }
37
- else {
38
- spinner.error(`${red('Failed')} to invoke function`);
39
- this.log(`Error: ${result.error || 'Unknown error'}`);
40
- }
41
- }
42
- }