@sanity/runtime-cli 8.0.1 → 8.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.
- package/README.md +16 -16
- package/dist/utils/invoke-local.js +12 -4
- package/oclif.manifest.json +1 -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/8.0.
|
|
23
|
+
@sanity/runtime-cli/8.0.2 linux-x64 node-v22.16.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -85,7 +85,7 @@ EXAMPLES
|
|
|
85
85
|
$ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
88
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/add.ts)_
|
|
89
89
|
|
|
90
90
|
## `sanity-run blueprints config`
|
|
91
91
|
|
|
@@ -116,7 +116,7 @@ EXAMPLES
|
|
|
116
116
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
119
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/config.ts)_
|
|
120
120
|
|
|
121
121
|
## `sanity-run blueprints deploy`
|
|
122
122
|
|
|
@@ -138,7 +138,7 @@ EXAMPLES
|
|
|
138
138
|
$ sanity-run blueprints deploy --no-wait
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
141
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/deploy.ts)_
|
|
142
142
|
|
|
143
143
|
## `sanity-run blueprints destroy`
|
|
144
144
|
|
|
@@ -163,7 +163,7 @@ EXAMPLES
|
|
|
163
163
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
166
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/destroy.ts)_
|
|
167
167
|
|
|
168
168
|
## `sanity-run blueprints info`
|
|
169
169
|
|
|
@@ -185,7 +185,7 @@ EXAMPLES
|
|
|
185
185
|
$ sanity-run blueprints info --stack-id <stackId>
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
188
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/info.ts)_
|
|
189
189
|
|
|
190
190
|
## `sanity-run blueprints init [DIR]`
|
|
191
191
|
|
|
@@ -222,7 +222,7 @@ EXAMPLES
|
|
|
222
222
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
223
223
|
```
|
|
224
224
|
|
|
225
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
225
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/init.ts)_
|
|
226
226
|
|
|
227
227
|
## `sanity-run blueprints logs`
|
|
228
228
|
|
|
@@ -244,7 +244,7 @@ EXAMPLES
|
|
|
244
244
|
$ sanity-run blueprints logs --watch
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
247
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/logs.ts)_
|
|
248
248
|
|
|
249
249
|
## `sanity-run blueprints plan`
|
|
250
250
|
|
|
@@ -261,7 +261,7 @@ EXAMPLES
|
|
|
261
261
|
$ sanity-run blueprints plan
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
264
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/plan.ts)_
|
|
265
265
|
|
|
266
266
|
## `sanity-run blueprints stacks`
|
|
267
267
|
|
|
@@ -283,7 +283,7 @@ EXAMPLES
|
|
|
283
283
|
$ sanity-run blueprints stacks --project-id <projectId>
|
|
284
284
|
```
|
|
285
285
|
|
|
286
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
286
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/blueprints/stacks.ts)_
|
|
287
287
|
|
|
288
288
|
## `sanity-run functions dev`
|
|
289
289
|
|
|
@@ -303,7 +303,7 @@ EXAMPLES
|
|
|
303
303
|
$ sanity-run functions dev --port 8974
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
306
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/dev.ts)_
|
|
307
307
|
|
|
308
308
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
309
309
|
|
|
@@ -325,7 +325,7 @@ EXAMPLES
|
|
|
325
325
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
328
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/env/add.ts)_
|
|
329
329
|
|
|
330
330
|
## `sanity-run functions env list NAME`
|
|
331
331
|
|
|
@@ -345,7 +345,7 @@ EXAMPLES
|
|
|
345
345
|
$ sanity-run functions env list MyFunction
|
|
346
346
|
```
|
|
347
347
|
|
|
348
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
348
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/env/list.ts)_
|
|
349
349
|
|
|
350
350
|
## `sanity-run functions env remove NAME KEY`
|
|
351
351
|
|
|
@@ -366,7 +366,7 @@ EXAMPLES
|
|
|
366
366
|
$ sanity-run functions env remove MyFunction API_URL
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
369
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/env/remove.ts)_
|
|
370
370
|
|
|
371
371
|
## `sanity-run functions logs NAME`
|
|
372
372
|
|
|
@@ -400,7 +400,7 @@ EXAMPLES
|
|
|
400
400
|
$ sanity-run functions logs <name> --delete
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
403
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/logs.ts)_
|
|
404
404
|
|
|
405
405
|
## `sanity-run functions test NAME`
|
|
406
406
|
|
|
@@ -433,7 +433,7 @@ EXAMPLES
|
|
|
433
433
|
$ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
|
|
434
434
|
```
|
|
435
435
|
|
|
436
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.
|
|
436
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.2/src/commands/functions/test.ts)_
|
|
437
437
|
|
|
438
438
|
## `sanity-run help [COMMAND]`
|
|
439
439
|
|
|
@@ -24,16 +24,24 @@ export function isDefaultGROQRule(rule) {
|
|
|
24
24
|
rule.filter === DEFAULT_GROQ_RULE.filter &&
|
|
25
25
|
rule.projection === DEFAULT_GROQ_RULE.projection);
|
|
26
26
|
}
|
|
27
|
+
function getEvent(rule) {
|
|
28
|
+
return {
|
|
29
|
+
on: rule.on || DEFAULT_GROQ_RULE.on,
|
|
30
|
+
filter: rule.filter || DEFAULT_GROQ_RULE.filter,
|
|
31
|
+
projection: rule.projection || DEFAULT_GROQ_RULE.projection,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
27
34
|
export async function applyGroqRule(resource, data) {
|
|
28
35
|
// If there is no rule set return everything
|
|
29
36
|
if (!resource.event)
|
|
30
37
|
return data;
|
|
31
38
|
// default groq rule is: gimme full doc content. otherwise, parse + eval custom rule
|
|
32
39
|
// applying the GROQ filter may result in a slimmer set of documents
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
40
|
+
const event = getEvent(resource.event);
|
|
41
|
+
if (!isDefaultGROQRule(event)) {
|
|
42
|
+
const hasProjection = event.projection?.length;
|
|
43
|
+
const projection = hasProjection ? `{${event?.projection}}` : '';
|
|
44
|
+
const query = `*[${event?.filter}]${projection}`;
|
|
37
45
|
try {
|
|
38
46
|
const rule = groq.parse(query);
|
|
39
47
|
const queryResults = await groq.evaluate(rule, { dataset: [data] });
|
package/oclif.manifest.json
CHANGED