@sanity/runtime-cli 1.0.2

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 (50) hide show
  1. package/README.md +548 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/actions/functions/dev.d.ts +1 -0
  7. package/dist/actions/functions/dev.js +5 -0
  8. package/dist/actions/functions/invoke.d.ts +2 -0
  9. package/dist/actions/functions/invoke.js +17 -0
  10. package/dist/actions/functions/logs.d.ts +1 -0
  11. package/dist/actions/functions/logs.js +14 -0
  12. package/dist/actions/functions/test.d.ts +2 -0
  13. package/dist/actions/functions/test.js +13 -0
  14. package/dist/commands/functions/dev.d.ts +9 -0
  15. package/dist/commands/functions/dev.js +15 -0
  16. package/dist/commands/functions/invoke.d.ts +13 -0
  17. package/dist/commands/functions/invoke.js +25 -0
  18. package/dist/commands/functions/logs.d.ts +9 -0
  19. package/dist/commands/functions/logs.js +14 -0
  20. package/dist/commands/functions/test.d.ts +14 -0
  21. package/dist/commands/functions/test.js +43 -0
  22. package/dist/config.d.ts +6 -0
  23. package/dist/config.js +9 -0
  24. package/dist/index.d.ts +5 -0
  25. package/dist/index.js +5 -0
  26. package/dist/server/app.d.ts +3 -0
  27. package/dist/server/app.js +36 -0
  28. package/dist/server/static/api.js +50 -0
  29. package/dist/server/static/components/api-base.js +10 -0
  30. package/dist/server/static/components/app.css +155 -0
  31. package/dist/server/static/components/function-list.js +49 -0
  32. package/dist/server/static/components/network-spinner.js +71 -0
  33. package/dist/server/static/components/payload-panel.js +45 -0
  34. package/dist/server/static/components/response-panel.js +83 -0
  35. package/dist/server/static/index.html +55 -0
  36. package/dist/server/static/sanity-logo-sm.svg +1 -0
  37. package/dist/server/static/vendor/vendor.bundle.js +26857 -0
  38. package/dist/utils/build-payload.d.ts +2 -0
  39. package/dist/utils/build-payload.js +15 -0
  40. package/dist/utils/child-process-wrapper.js +33 -0
  41. package/dist/utils/invoke-local.d.ts +2 -0
  42. package/dist/utils/invoke-local.js +51 -0
  43. package/dist/utils/is-dependency.d.ts +1 -0
  44. package/dist/utils/is-dependency.js +7 -0
  45. package/dist/utils/is-json.d.ts +1 -0
  46. package/dist/utils/is-json.js +12 -0
  47. package/dist/utils/types.d.ts +16 -0
  48. package/dist/utils/types.js +1 -0
  49. package/oclif.manifest.json +179 -0
  50. package/package.json +85 -0
package/README.md ADDED
@@ -0,0 +1,548 @@
1
+ @sanity/runtime-cli
2
+ =================
3
+
4
+ A new CLI generated with oclif
5
+
6
+
7
+ [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
8
+ [![Version](https://img.shields.io/npm/v/@sanity/runtime-cli.svg)](https://npmjs.org/package/@sanity/runtime-cli)
9
+ [![Downloads/week](https://img.shields.io/npm/dw/@sanity/runtime-cli.svg)](https://npmjs.org/package/@sanity/runtime-cli)
10
+
11
+
12
+ <!-- toc -->
13
+ * [Usage](#usage)
14
+ * [Commands](#commands)
15
+ <!-- tocstop -->
16
+ # Usage
17
+ <!-- usage -->
18
+ ```sh-session
19
+ $ npm install -g @sanity/runtime-cli
20
+ $ sanity COMMAND
21
+ running command...
22
+ $ sanity (--version)
23
+ @sanity/runtime-cli/1.0.2 linux-x64 node-v22.13.1
24
+ $ sanity --help [COMMAND]
25
+ USAGE
26
+ $ sanity COMMAND
27
+ ...
28
+ ```
29
+ <!-- usagestop -->
30
+ # Commands
31
+ <!-- commands -->
32
+ * [`sanity functions dev`](#sanity-functions-dev)
33
+ * [`sanity functions invoke ID`](#sanity-functions-invoke-id)
34
+ * [`sanity functions logs ID`](#sanity-functions-logs-id)
35
+ * [`sanity functions test PATH`](#sanity-functions-test-path)
36
+ * [`sanity help [COMMAND]`](#sanity-help-command)
37
+ * [`sanity plugins`](#sanity-plugins)
38
+ * [`sanity plugins add PLUGIN`](#sanity-plugins-add-plugin)
39
+ * [`sanity plugins:inspect PLUGIN...`](#sanity-pluginsinspect-plugin)
40
+ * [`sanity plugins install PLUGIN`](#sanity-plugins-install-plugin)
41
+ * [`sanity plugins link PATH`](#sanity-plugins-link-path)
42
+ * [`sanity plugins remove [PLUGIN]`](#sanity-plugins-remove-plugin)
43
+ * [`sanity plugins reset`](#sanity-plugins-reset)
44
+ * [`sanity plugins uninstall [PLUGIN]`](#sanity-plugins-uninstall-plugin)
45
+ * [`sanity plugins unlink [PLUGIN]`](#sanity-plugins-unlink-plugin)
46
+ * [`sanity plugins update`](#sanity-plugins-update)
47
+
48
+ ## `sanity functions dev`
49
+
50
+ Start the Sanity Function emulator
51
+
52
+ ```
53
+ USAGE
54
+ $ sanity functions dev [-p <value>]
55
+
56
+ FLAGS
57
+ -p, --port=<value> Port to start emulator on
58
+
59
+ DESCRIPTION
60
+ Start the Sanity Function emulator
61
+
62
+ EXAMPLES
63
+ $ sanity functions dev --port 8974
64
+ ```
65
+
66
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/dev.ts)_
67
+
68
+ ## `sanity functions invoke ID`
69
+
70
+ Invoke a remote Sanity Function
71
+
72
+ ```
73
+ USAGE
74
+ $ sanity functions invoke ID [-d <value>] [-f <value>]
75
+
76
+ ARGUMENTS
77
+ ID The ID of the function to invoke
78
+
79
+ FLAGS
80
+ -d, --data=<value> Data to send to the function
81
+ -f, --file=<value> Read data from file and send to the function
82
+
83
+ DESCRIPTION
84
+ Invoke a remote Sanity Function
85
+
86
+ EXAMPLES
87
+ $ sanity functions invoke <ID> --data '{ "id": 1 }'
88
+
89
+ $ sanity functions invoke <ID> --file 'payload.json'
90
+ ```
91
+
92
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/invoke.ts)_
93
+
94
+ ## `sanity functions logs ID`
95
+
96
+ Retrieve logs for a Sanity Function
97
+
98
+ ```
99
+ USAGE
100
+ $ sanity functions logs ID
101
+
102
+ ARGUMENTS
103
+ ID The ID of the function to retrieve logs for
104
+
105
+ DESCRIPTION
106
+ Retrieve logs for a Sanity Function
107
+
108
+ EXAMPLES
109
+ $ sanity functions logs <ID>
110
+ ```
111
+
112
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/logs.ts)_
113
+
114
+ ## `sanity functions test PATH`
115
+
116
+ Invoke a local Sanity Function
117
+
118
+ ```
119
+ USAGE
120
+ $ sanity functions test PATH [-d <value>] [-f <value>] [-t <value>]
121
+
122
+ ARGUMENTS
123
+ PATH The path to the function source code
124
+
125
+ FLAGS
126
+ -d, --data=<value> Data to send to the function
127
+ -f, --file=<value> Read data from file and send to the function
128
+ -t, --timeout=<value> Execution timeout value in seconds
129
+
130
+ DESCRIPTION
131
+ Invoke a local Sanity Function
132
+
133
+ EXAMPLES
134
+ $ sanity functions test ./test.ts --data '{ "id": 1 }'
135
+
136
+ $ sanity functions test ./test.js --file 'payload.json'
137
+
138
+ $ sanity functions test ./test.ts --data '{ "id": 1 }' --timeout 60
139
+ ```
140
+
141
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.0.2/src/commands/functions/test.ts)_
142
+
143
+ ## `sanity help [COMMAND]`
144
+
145
+ Display help for sanity.
146
+
147
+ ```
148
+ USAGE
149
+ $ sanity help [COMMAND...] [-n]
150
+
151
+ ARGUMENTS
152
+ COMMAND... Command to show help for.
153
+
154
+ FLAGS
155
+ -n, --nested-commands Include all nested commands in the output.
156
+
157
+ DESCRIPTION
158
+ Display help for sanity.
159
+ ```
160
+
161
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.25/src/commands/help.ts)_
162
+
163
+ ## `sanity plugins`
164
+
165
+ List installed plugins.
166
+
167
+ ```
168
+ USAGE
169
+ $ sanity plugins [--json] [--core]
170
+
171
+ FLAGS
172
+ --core Show core plugins.
173
+
174
+ GLOBAL FLAGS
175
+ --json Format output as json.
176
+
177
+ DESCRIPTION
178
+ List installed plugins.
179
+
180
+ EXAMPLES
181
+ $ sanity plugins
182
+ ```
183
+
184
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/index.ts)_
185
+
186
+ ## `sanity plugins add PLUGIN`
187
+
188
+ Installs a plugin into sanity.
189
+
190
+ ```
191
+ USAGE
192
+ $ sanity plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
193
+
194
+ ARGUMENTS
195
+ PLUGIN... Plugin to install.
196
+
197
+ FLAGS
198
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
199
+ -h, --help Show CLI help.
200
+ -s, --silent Silences npm output.
201
+ -v, --verbose Show verbose npm output.
202
+
203
+ GLOBAL FLAGS
204
+ --json Format output as json.
205
+
206
+ DESCRIPTION
207
+ Installs a plugin into sanity.
208
+
209
+ Uses npm to install plugins.
210
+
211
+ Installation of a user-installed plugin will override a core plugin.
212
+
213
+ Use the SANITY_NPM_LOG_LEVEL environment variable to set the npm loglevel.
214
+ Use the SANITY_NPM_REGISTRY environment variable to set the npm registry.
215
+
216
+ ALIASES
217
+ $ sanity plugins add
218
+
219
+ EXAMPLES
220
+ Install a plugin from npm registry.
221
+
222
+ $ sanity plugins add myplugin
223
+
224
+ Install a plugin from a github url.
225
+
226
+ $ sanity plugins add https://github.com/someuser/someplugin
227
+
228
+ Install a plugin from a github slug.
229
+
230
+ $ sanity plugins add someuser/someplugin
231
+ ```
232
+
233
+ ## `sanity plugins:inspect PLUGIN...`
234
+
235
+ Displays installation properties of a plugin.
236
+
237
+ ```
238
+ USAGE
239
+ $ sanity plugins inspect PLUGIN...
240
+
241
+ ARGUMENTS
242
+ PLUGIN... [default: .] Plugin to inspect.
243
+
244
+ FLAGS
245
+ -h, --help Show CLI help.
246
+ -v, --verbose
247
+
248
+ GLOBAL FLAGS
249
+ --json Format output as json.
250
+
251
+ DESCRIPTION
252
+ Displays installation properties of a plugin.
253
+
254
+ EXAMPLES
255
+ $ sanity plugins inspect myplugin
256
+ ```
257
+
258
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/inspect.ts)_
259
+
260
+ ## `sanity plugins install PLUGIN`
261
+
262
+ Installs a plugin into sanity.
263
+
264
+ ```
265
+ USAGE
266
+ $ sanity plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
267
+
268
+ ARGUMENTS
269
+ PLUGIN... Plugin to install.
270
+
271
+ FLAGS
272
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
273
+ -h, --help Show CLI help.
274
+ -s, --silent Silences npm output.
275
+ -v, --verbose Show verbose npm output.
276
+
277
+ GLOBAL FLAGS
278
+ --json Format output as json.
279
+
280
+ DESCRIPTION
281
+ Installs a plugin into sanity.
282
+
283
+ Uses npm to install plugins.
284
+
285
+ Installation of a user-installed plugin will override a core plugin.
286
+
287
+ Use the SANITY_NPM_LOG_LEVEL environment variable to set the npm loglevel.
288
+ Use the SANITY_NPM_REGISTRY environment variable to set the npm registry.
289
+
290
+ ALIASES
291
+ $ sanity plugins add
292
+
293
+ EXAMPLES
294
+ Install a plugin from npm registry.
295
+
296
+ $ sanity plugins install myplugin
297
+
298
+ Install a plugin from a github url.
299
+
300
+ $ sanity plugins install https://github.com/someuser/someplugin
301
+
302
+ Install a plugin from a github slug.
303
+
304
+ $ sanity plugins install someuser/someplugin
305
+ ```
306
+
307
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/install.ts)_
308
+
309
+ ## `sanity plugins link PATH`
310
+
311
+ Links a plugin into the CLI for development.
312
+
313
+ ```
314
+ USAGE
315
+ $ sanity plugins link PATH [-h] [--install] [-v]
316
+
317
+ ARGUMENTS
318
+ PATH [default: .] path to plugin
319
+
320
+ FLAGS
321
+ -h, --help Show CLI help.
322
+ -v, --verbose
323
+ --[no-]install Install dependencies after linking the plugin.
324
+
325
+ DESCRIPTION
326
+ Links a plugin into the CLI for development.
327
+
328
+ Installation of a linked plugin will override a user-installed or core plugin.
329
+
330
+ e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
331
+ command will override the user-installed or core plugin implementation. This is useful for development work.
332
+
333
+
334
+ EXAMPLES
335
+ $ sanity plugins link myplugin
336
+ ```
337
+
338
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/link.ts)_
339
+
340
+ ## `sanity plugins remove [PLUGIN]`
341
+
342
+ Removes a plugin from the CLI.
343
+
344
+ ```
345
+ USAGE
346
+ $ sanity plugins remove [PLUGIN...] [-h] [-v]
347
+
348
+ ARGUMENTS
349
+ PLUGIN... plugin to uninstall
350
+
351
+ FLAGS
352
+ -h, --help Show CLI help.
353
+ -v, --verbose
354
+
355
+ DESCRIPTION
356
+ Removes a plugin from the CLI.
357
+
358
+ ALIASES
359
+ $ sanity plugins unlink
360
+ $ sanity plugins remove
361
+
362
+ EXAMPLES
363
+ $ sanity plugins remove myplugin
364
+ ```
365
+
366
+ ## `sanity plugins reset`
367
+
368
+ Remove all user-installed and linked plugins.
369
+
370
+ ```
371
+ USAGE
372
+ $ sanity plugins reset [--hard] [--reinstall]
373
+
374
+ FLAGS
375
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
376
+ --reinstall Reinstall all plugins after uninstalling.
377
+ ```
378
+
379
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/reset.ts)_
380
+
381
+ ## `sanity plugins uninstall [PLUGIN]`
382
+
383
+ Removes a plugin from the CLI.
384
+
385
+ ```
386
+ USAGE
387
+ $ sanity plugins uninstall [PLUGIN...] [-h] [-v]
388
+
389
+ ARGUMENTS
390
+ PLUGIN... plugin to uninstall
391
+
392
+ FLAGS
393
+ -h, --help Show CLI help.
394
+ -v, --verbose
395
+
396
+ DESCRIPTION
397
+ Removes a plugin from the CLI.
398
+
399
+ ALIASES
400
+ $ sanity plugins unlink
401
+ $ sanity plugins remove
402
+
403
+ EXAMPLES
404
+ $ sanity plugins uninstall myplugin
405
+ ```
406
+
407
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/uninstall.ts)_
408
+
409
+ ## `sanity plugins unlink [PLUGIN]`
410
+
411
+ Removes a plugin from the CLI.
412
+
413
+ ```
414
+ USAGE
415
+ $ sanity plugins unlink [PLUGIN...] [-h] [-v]
416
+
417
+ ARGUMENTS
418
+ PLUGIN... plugin to uninstall
419
+
420
+ FLAGS
421
+ -h, --help Show CLI help.
422
+ -v, --verbose
423
+
424
+ DESCRIPTION
425
+ Removes a plugin from the CLI.
426
+
427
+ ALIASES
428
+ $ sanity plugins unlink
429
+ $ sanity plugins remove
430
+
431
+ EXAMPLES
432
+ $ sanity plugins unlink myplugin
433
+ ```
434
+
435
+ ## `sanity plugins update`
436
+
437
+ Update installed plugins.
438
+
439
+ ```
440
+ USAGE
441
+ $ sanity plugins update [-h] [-v]
442
+
443
+ FLAGS
444
+ -h, --help Show CLI help.
445
+ -v, --verbose
446
+
447
+ DESCRIPTION
448
+ Update installed plugins.
449
+ ```
450
+
451
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/update.ts)_
452
+ <!-- commandsstop -->
453
+ * [`sanity functions dev`](#sanity-functions-dev)
454
+ * [`sanity functions invoke`](#sanity-functions-invoke)
455
+ * [`sanity functions logs`](#sanity-functions-logs)
456
+ * [`sanity functions test`](#sanity-functions-test)
457
+
458
+ ## `sanity functions dev`
459
+
460
+ Start the Sanity Function emulator
461
+
462
+ ```
463
+ USAGE
464
+ $ sanity functions dev [-p <value>]
465
+
466
+ FLAGS
467
+ -p, --port=<value> Port to start emulator on
468
+
469
+ DESCRIPTION
470
+ Start the Sanity Function emulator
471
+
472
+ EXAMPLES
473
+ $ sanity functions dev --port 8974
474
+ ```
475
+
476
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli-demos/blob/v0.0.0/src/commands/functions/dev.ts)_
477
+
478
+ ## `sanity functions invoke`
479
+
480
+ Invoke a remote Sanity Function
481
+
482
+ ```
483
+ USAGE
484
+ $ sanity functions invoke ID [-d <value>] [-f <value>]
485
+
486
+ ARGUMENTS
487
+ ID The ID of the function to invoke
488
+
489
+ FLAGS
490
+ -d, --data=<value> Data to send to the function
491
+ -f, --file=<value> Read data from file and send to the function
492
+
493
+ DESCRIPTION
494
+ Invoke a remote Sanity Function
495
+
496
+ EXAMPLES
497
+ $ sanity functions invoke <ID> --data '{ "id": 1 }'
498
+
499
+ $ sanity functions invoke <ID> --file 'payload.json'
500
+ ```
501
+
502
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli-demos/blob/v0.0.0/src/commands/functions/invoke.ts)_
503
+
504
+ ## `sanity functions logs`
505
+
506
+ Retrieve logs for a Sanity Function
507
+
508
+ ```
509
+ USAGE
510
+ $ sanity functions logs ID
511
+
512
+ ARGUMENTS
513
+ ID The ID of the function to retrieve logs for
514
+
515
+ DESCRIPTION
516
+ Retrieve logs for a Sanity Function
517
+
518
+ EXAMPLES
519
+ $ sanity functions logs <ID>
520
+ ```
521
+
522
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli-demos/blob/v0.0.0/src/commands/functions/logs.ts)_
523
+
524
+ ## `sanity functions test`
525
+
526
+ Invoke a local Sanity Function
527
+
528
+ ```
529
+ USAGE
530
+ $ sanity functions test PATH [-d <value>] [-f <value>]
531
+
532
+ ARGUMENTS
533
+ PATH The path to the function source code
534
+
535
+ FLAGS
536
+ -d, --data=<value> Data to send to the function
537
+ -f, --file=<value> Read data from file and send to the function
538
+
539
+ DESCRIPTION
540
+ Invoke a local Sanity Function
541
+
542
+ EXAMPLES
543
+ $ sanity functions test ./test.ts --data '{ "id": 1 }'
544
+
545
+ $ sanity functions test ./test.js --file 'payload.json'
546
+ ```
547
+
548
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli-demos/blob/v0.0.0/src/commands/functions/test.ts)_
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --disable-warning=ExperimentalWarning
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({development: true, dir: import.meta.url})
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -0,0 +1 @@
1
+ export declare function dev(port: number): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { serve } from '@hono/node-server';
2
+ import app from '../../server/app.js';
3
+ export async function dev(port) {
4
+ serve({ fetch: app.fetch, port: Number(port) });
5
+ }
@@ -0,0 +1,2 @@
1
+ import type { PayloadOptions } from '../../utils/types.js';
2
+ export declare function invoke(id: string, options: PayloadOptions): Promise<object>;
@@ -0,0 +1,17 @@
1
+ import config from '../../config.js';
2
+ import buildPayload from '../../utils/build-payload.js';
3
+ const { url } = config.server;
4
+ export async function invoke(id, options) {
5
+ const payload = buildPayload(options);
6
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
7
+ const response = await fetch(`${url}/api/vX/functions/${id}/invoke`, {
8
+ body: JSON.stringify({ data: payload }),
9
+ headers: {
10
+ Accept: 'application/json',
11
+ 'Content-Type': 'application/json',
12
+ },
13
+ method: 'POST',
14
+ });
15
+ const json = await response.json();
16
+ return json;
17
+ }
@@ -0,0 +1 @@
1
+ export declare function logs(id: string): Promise<object>;
@@ -0,0 +1,14 @@
1
+ import config from '../../config.js';
2
+ const { url } = config.server;
3
+ export async function logs(id) {
4
+ // eslint-disable-next-line n/no-unsupported-features/node-builtins
5
+ const response = await fetch(`${url}/api/vX/functions/${id}/logs`, {
6
+ headers: {
7
+ Accept: 'application/json',
8
+ 'Content-Type': 'application/json',
9
+ },
10
+ method: 'GET',
11
+ });
12
+ const json = await response.json();
13
+ return json;
14
+ }
@@ -0,0 +1,2 @@
1
+ import type { InvocationResponse, PayloadOptions } from '../../utils/types.js';
2
+ export declare function testAction(srcPath: string, options: PayloadOptions): Promise<InvocationResponse>;
@@ -0,0 +1,13 @@
1
+ import buildPayload from '../../utils/build-payload.js';
2
+ import invoke from '../../utils/invoke-local.js';
3
+ export async function testAction(srcPath, options) {
4
+ const payload = buildPayload(options);
5
+ const { timeout } = options;
6
+ try {
7
+ const { json, logs } = await invoke(srcPath, payload, timeout);
8
+ return { error: undefined, json, logs };
9
+ }
10
+ catch (error) {
11
+ return { error, json: undefined, logs: undefined };
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Dev extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static flags: {
6
+ port: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,15 @@
1
+ import { Command, Flags } from '@oclif/core';
2
+ import { dev } from '../../actions/functions/dev.js';
3
+ export default class Dev extends Command {
4
+ static description = 'Start the Sanity Function emulator';
5
+ static examples = ['<%= config.bin %> <%= command.id %> --port 8974'];
6
+ static flags = {
7
+ port: Flags.string({ char: 'p', description: 'Port to start emulator on', required: false }),
8
+ };
9
+ async run() {
10
+ const { flags } = await this.parse(Dev);
11
+ const { port = 8080 } = flags;
12
+ dev(Number(port));
13
+ this.log(`Server is running on port ${port}\n`);
14
+ }
15
+ }
@@ -0,0 +1,13 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Invoke extends Command {
3
+ static args: {
4
+ id: 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
+ }