@sanity/runtime-cli 14.10.0 → 14.11.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 +18 -18
- package/dist/actions/blueprints/logs-streaming.d.ts +1 -0
- package/dist/actions/blueprints/logs-streaming.js +1 -0
- package/dist/cores/blueprints/deploy.js +4 -0
- package/dist/cores/blueprints/destroy.js +4 -0
- package/dist/server/static/components/api-base.js +1 -0
- package/dist/server/static/components/filters.js +10 -3
- package/dist/server/static/components/function-list.js +1 -0
- package/dist/server/static/components/payload-panel.js +55 -5
- package/dist/server/static/components/rule-panel.js +14 -1
- package/dist/utils/blueprints/log-hints.d.ts +25 -0
- package/dist/utils/blueprints/log-hints.js +46 -0
- package/dist/utils/child-process-wrapper.js +6 -1
- package/dist/utils/invoke-local.js +1 -1
- 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/14.
|
|
23
|
+
@sanity/runtime-cli/14.11.0 linux-x64 node-v24.14.1
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -101,7 +101,7 @@ EXAMPLES
|
|
|
101
101
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
104
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/add.ts)_
|
|
105
105
|
|
|
106
106
|
## `sanity-run blueprints config`
|
|
107
107
|
|
|
@@ -140,7 +140,7 @@ EXAMPLES
|
|
|
140
140
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
143
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/config.ts)_
|
|
144
144
|
|
|
145
145
|
## `sanity-run blueprints deploy`
|
|
146
146
|
|
|
@@ -182,7 +182,7 @@ EXAMPLES
|
|
|
182
182
|
$ sanity-run blueprints deploy --fn-installer npm
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
185
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/deploy.ts)_
|
|
186
186
|
|
|
187
187
|
## `sanity-run blueprints destroy`
|
|
188
188
|
|
|
@@ -218,7 +218,7 @@ EXAMPLES
|
|
|
218
218
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
221
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/destroy.ts)_
|
|
222
222
|
|
|
223
223
|
## `sanity-run blueprints doctor`
|
|
224
224
|
|
|
@@ -250,7 +250,7 @@ EXAMPLES
|
|
|
250
250
|
$ sanity-run blueprints doctor --fix
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
253
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/doctor.ts)_
|
|
254
254
|
|
|
255
255
|
## `sanity-run blueprints info`
|
|
256
256
|
|
|
@@ -282,7 +282,7 @@ EXAMPLES
|
|
|
282
282
|
$ sanity-run blueprints info --stack <name-or-id>
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
285
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/info.ts)_
|
|
286
286
|
|
|
287
287
|
## `sanity-run blueprints init [DIR]`
|
|
288
288
|
|
|
@@ -336,7 +336,7 @@ EXAMPLES
|
|
|
336
336
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
337
337
|
```
|
|
338
338
|
|
|
339
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
339
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/init.ts)_
|
|
340
340
|
|
|
341
341
|
## `sanity-run blueprints logs`
|
|
342
342
|
|
|
@@ -367,7 +367,7 @@ EXAMPLES
|
|
|
367
367
|
$ sanity-run blueprints logs --watch
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
370
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/logs.ts)_
|
|
371
371
|
|
|
372
372
|
## `sanity-run blueprints plan`
|
|
373
373
|
|
|
@@ -395,7 +395,7 @@ EXAMPLES
|
|
|
395
395
|
$ sanity-run blueprints plan
|
|
396
396
|
```
|
|
397
397
|
|
|
398
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
398
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/plan.ts)_
|
|
399
399
|
|
|
400
400
|
## `sanity-run blueprints stacks`
|
|
401
401
|
|
|
@@ -427,7 +427,7 @@ EXAMPLES
|
|
|
427
427
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
430
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/blueprints/stacks.ts)_
|
|
431
431
|
|
|
432
432
|
## `sanity-run functions add`
|
|
433
433
|
|
|
@@ -480,7 +480,7 @@ EXAMPLES
|
|
|
480
480
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
481
481
|
```
|
|
482
482
|
|
|
483
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
483
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/add.ts)_
|
|
484
484
|
|
|
485
485
|
## `sanity-run functions dev`
|
|
486
486
|
|
|
@@ -516,7 +516,7 @@ EXAMPLES
|
|
|
516
516
|
$ sanity-run functions dev --timeout 60
|
|
517
517
|
```
|
|
518
518
|
|
|
519
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
519
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/dev.ts)_
|
|
520
520
|
|
|
521
521
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
522
522
|
|
|
@@ -547,7 +547,7 @@ EXAMPLES
|
|
|
547
547
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
548
548
|
```
|
|
549
549
|
|
|
550
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
550
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/env/add.ts)_
|
|
551
551
|
|
|
552
552
|
## `sanity-run functions env list NAME`
|
|
553
553
|
|
|
@@ -575,7 +575,7 @@ EXAMPLES
|
|
|
575
575
|
$ sanity-run functions env list MyFunction
|
|
576
576
|
```
|
|
577
577
|
|
|
578
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
578
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/env/list.ts)_
|
|
579
579
|
|
|
580
580
|
## `sanity-run functions env remove NAME KEY`
|
|
581
581
|
|
|
@@ -605,7 +605,7 @@ EXAMPLES
|
|
|
605
605
|
$ sanity-run functions env remove MyFunction API_URL
|
|
606
606
|
```
|
|
607
607
|
|
|
608
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
608
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/env/remove.ts)_
|
|
609
609
|
|
|
610
610
|
## `sanity-run functions logs [NAME]`
|
|
611
611
|
|
|
@@ -647,7 +647,7 @@ EXAMPLES
|
|
|
647
647
|
$ sanity-run functions logs <name> --delete
|
|
648
648
|
```
|
|
649
649
|
|
|
650
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
650
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/logs.ts)_
|
|
651
651
|
|
|
652
652
|
## `sanity-run functions test [NAME]`
|
|
653
653
|
|
|
@@ -705,7 +705,7 @@ EXAMPLES
|
|
|
705
705
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
706
706
|
```
|
|
707
707
|
|
|
708
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.
|
|
708
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.11.0/src/commands/functions/test.ts)_
|
|
709
709
|
|
|
710
710
|
## `sanity-run help [COMMAND]`
|
|
711
711
|
|
|
@@ -80,6 +80,7 @@ export async function setupLogStreaming(config) {
|
|
|
80
80
|
return;
|
|
81
81
|
newestTimestamp = new Date(logEntry.timestamp).getTime();
|
|
82
82
|
config.onActivity?.();
|
|
83
|
+
config.onLogEntry?.(logEntry);
|
|
83
84
|
log(formatLogEntry(logEntry, verbose, previousLog));
|
|
84
85
|
previousLog = logEntry;
|
|
85
86
|
};
|
|
@@ -2,6 +2,7 @@ import { setTimeout as sleep } from 'node:timers/promises';
|
|
|
2
2
|
import { stashAsset } from '../../actions/blueprints/assets.js';
|
|
3
3
|
import { setupLogStreaming } from '../../actions/blueprints/logs-streaming.js';
|
|
4
4
|
import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
|
|
5
|
+
import { createLogHintCollector } from '../../utils/blueprints/log-hints.js';
|
|
5
6
|
import { niceId } from '../../utils/display/presenters.js';
|
|
6
7
|
import { styleText } from '../../utils/style-text.js';
|
|
7
8
|
import { isAssetResource } from '../../utils/types.js';
|
|
@@ -81,6 +82,7 @@ export async function blueprintDeployCore(options) {
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
log(styleText('dim', 'Stack deployment progress:'));
|
|
85
|
+
const logHints = createLogHintCollector(bin);
|
|
84
86
|
let logStreamCleanup = null;
|
|
85
87
|
try {
|
|
86
88
|
let lastLogAt = Date.now();
|
|
@@ -94,6 +96,7 @@ export async function blueprintDeployCore(options) {
|
|
|
94
96
|
onActivity: () => {
|
|
95
97
|
lastLogAt = Date.now();
|
|
96
98
|
},
|
|
99
|
+
onLogEntry: (logEntry) => logHints.inspect(logEntry),
|
|
97
100
|
});
|
|
98
101
|
while (true) {
|
|
99
102
|
const { ok, stack: currentStack } = await getStack({ stackId: stack.id, auth, logger: log });
|
|
@@ -122,6 +125,7 @@ export async function blueprintDeployCore(options) {
|
|
|
122
125
|
success: false,
|
|
123
126
|
error: 'Stack deployment failed',
|
|
124
127
|
suggestions: [
|
|
128
|
+
...logHints.getSuggestions(),
|
|
125
129
|
`Run \`npx ${bin} blueprints logs\` to review deployment logs.`,
|
|
126
130
|
`Run \`npx ${bin} blueprints plan\` to identify issues with your Blueprint.`,
|
|
127
131
|
],
|
|
@@ -2,6 +2,7 @@ import { setTimeout as sleep } from 'node:timers/promises';
|
|
|
2
2
|
import { confirm } from '@inquirer/prompts';
|
|
3
3
|
import { setupLogStreaming } from '../../actions/blueprints/logs-streaming.js';
|
|
4
4
|
import { destroyStack, getStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
5
|
+
import { createLogHintCollector } from '../../utils/blueprints/log-hints.js';
|
|
5
6
|
import { niceId } from '../../utils/display/presenters.js';
|
|
6
7
|
import { styleText } from '../../utils/style-text.js';
|
|
7
8
|
export async function blueprintDestroyCore(options) {
|
|
@@ -103,6 +104,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
103
104
|
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
104
105
|
}
|
|
105
106
|
log(styleText('dim', 'Stack destruction progress:'));
|
|
107
|
+
const logHints = createLogHintCollector(bin);
|
|
106
108
|
let logStreamCleanup = null;
|
|
107
109
|
try {
|
|
108
110
|
let lastLogAt = Date.now();
|
|
@@ -115,6 +117,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
115
117
|
onActivity: () => {
|
|
116
118
|
lastLogAt = Date.now();
|
|
117
119
|
},
|
|
120
|
+
onLogEntry: (logEntry) => logHints.inspect(logEntry),
|
|
118
121
|
});
|
|
119
122
|
while (true) {
|
|
120
123
|
const { ok, stack: currentStack } = await getStack({ stackId: stack.id, auth, logger: log });
|
|
@@ -134,6 +137,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
134
137
|
success: false,
|
|
135
138
|
error: 'Stack destruction failed',
|
|
136
139
|
suggestions: [
|
|
140
|
+
...logHints.getSuggestions(),
|
|
137
141
|
`Run \`npx ${bin} blueprints logs\` to review destruction logs.`,
|
|
138
142
|
`Run \`npx ${bin} blueprints info\` to view current Stack status.`,
|
|
139
143
|
],
|
|
@@ -10,5 +10,6 @@ export class ApiBaseElement extends HTMLElement {
|
|
|
10
10
|
this.SANITY_FUNCTION_DOCUMENT = 'sanity.function.document'
|
|
11
11
|
this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = 'sanity.function.media-library.asset'
|
|
12
12
|
this.SANITY_FUNCTION_SCHEDULED = 'sanity.function.cron'
|
|
13
|
+
this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE = 'sanity.function.sync-tag-invalidate'
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -80,17 +80,24 @@ class FiltersComponent extends ApiBaseElement {
|
|
|
80
80
|
this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
|
|
81
81
|
)
|
|
82
82
|
const scheduleFunction = this.api.store.selectedFunctionType === this.SANITY_FUNCTION_SCHEDULED
|
|
83
|
+
const stiFunction =
|
|
84
|
+
this.api.store.selectedFunctionType === this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE
|
|
83
85
|
|
|
84
86
|
const container = this.shadowRoot.querySelector('fieldset')
|
|
85
|
-
container.innerHTML = this.buildFilters(
|
|
87
|
+
container.innerHTML = this.buildFilters(
|
|
88
|
+
docFunction,
|
|
89
|
+
mediaFunction,
|
|
90
|
+
scheduleFunction,
|
|
91
|
+
stiFunction,
|
|
92
|
+
)
|
|
86
93
|
}
|
|
87
94
|
|
|
88
|
-
buildFilters = (docFunction, mediaFunction, scheduleFunction) => {
|
|
95
|
+
buildFilters = (docFunction, mediaFunction, scheduleFunction, stiFunction) => {
|
|
89
96
|
return `
|
|
90
97
|
<legend class="config-label">Client Options</legend>
|
|
91
98
|
<div id="dynamic-dropdowns" class="flex gap-2">
|
|
92
99
|
${
|
|
93
|
-
docFunction || scheduleFunction
|
|
100
|
+
docFunction || scheduleFunction || stiFunction
|
|
94
101
|
? `<select-dropdown
|
|
95
102
|
label="Project"
|
|
96
103
|
store-key="projects"
|
|
@@ -29,7 +29,7 @@ template.innerHTML = `
|
|
|
29
29
|
<div id="payloadContainer" class="gutter-gradient relative h-100 max-h-100 y-scroll border-top border-top-none-l">
|
|
30
30
|
<div class="bg gutter-gradient sticky top-0 right-0 left-0 z-100">
|
|
31
31
|
<div class="flex items-center space-between pad-t-2 pad-r-5 pad-b-2 pad-l-12">
|
|
32
|
-
<h2 class="config-label mar-t-0 mar-b-0">Document</h2>
|
|
32
|
+
<h2 id="payloadTitle" class="config-label mar-t-0 mar-b-0">Document</h2>
|
|
33
33
|
</div>
|
|
34
34
|
<hr class='hr-border mar-l-specific' />
|
|
35
35
|
</div>
|
|
@@ -75,11 +75,35 @@ class PayloadPanel extends ApiBaseElement {
|
|
|
75
75
|
|
|
76
76
|
this.api.subscribe(this.updatePayload, ['document'])
|
|
77
77
|
this.api.subscribe(this.updateSelectedEvent, ['selectedEvent'])
|
|
78
|
-
this.api.subscribe(this.updateCodeMirror, ['
|
|
78
|
+
this.api.subscribe(this.updateCodeMirror, ['selectedIndex', 'functions'])
|
|
79
|
+
this.api.subscribe(this.updatePanelTitle, ['selectedFunctionType'])
|
|
80
|
+
this.documentCacheByFunction = {}
|
|
81
|
+
this.currentIndex = -1
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
updateCodeMirror = (
|
|
82
|
-
|
|
84
|
+
updateCodeMirror = () => {
|
|
85
|
+
const {
|
|
86
|
+
functions,
|
|
87
|
+
selectedIndex: selectedFuncName,
|
|
88
|
+
payload: {state},
|
|
89
|
+
} = this.api.store
|
|
90
|
+
const docText = state.doc.text.join('')
|
|
91
|
+
// save the previous payload in the cache before we do anything else
|
|
92
|
+
if (docText) {
|
|
93
|
+
const currentDoc = JSON.parse(docText)
|
|
94
|
+
this.documentCacheByFunction[this.currentIndex] = currentDoc
|
|
95
|
+
} else {
|
|
96
|
+
this.documentCacheByFunction[this.currentIndex] = ''
|
|
97
|
+
}
|
|
98
|
+
const selectedIndex = functions.findIndex((f) => f.name === selectedFuncName)
|
|
99
|
+
if (selectedIndex === this.currentIndex) return
|
|
100
|
+
const selectedFunction = functions[selectedIndex]
|
|
101
|
+
// flip editable of code mirror textarea based on function type
|
|
102
|
+
if (
|
|
103
|
+
[this.SANITY_FUNCTION_SCHEDULED, this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE].includes(
|
|
104
|
+
selectedFunction.type,
|
|
105
|
+
)
|
|
106
|
+
) {
|
|
83
107
|
this.api.store.beforePayload.dispatch({
|
|
84
108
|
effects: editableCompartment.reconfigure(EditorView.editable.of(false)),
|
|
85
109
|
})
|
|
@@ -100,6 +124,16 @@ class PayloadPanel extends ApiBaseElement {
|
|
|
100
124
|
effects: editableCompartment.reconfigure(EditorView.editable.of(true)),
|
|
101
125
|
})
|
|
102
126
|
}
|
|
127
|
+
// for certain other specific function types, set the payload to something specific, or reload whatever was loaded into its document payload before
|
|
128
|
+
switch (selectedFunction.type) {
|
|
129
|
+
case this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE:
|
|
130
|
+
this.#updateCodeView(this.api.store.payload, {data: {syncTags: ['s1:1234', 's2:5678']}})
|
|
131
|
+
break
|
|
132
|
+
default:
|
|
133
|
+
this.#updateCodeView(this.api.store.payload, this.documentCacheByFunction[selectedIndex])
|
|
134
|
+
break
|
|
135
|
+
}
|
|
136
|
+
this.currentIndex = selectedIndex
|
|
103
137
|
}
|
|
104
138
|
updatePayload = ({document}) => {
|
|
105
139
|
if (!document) return
|
|
@@ -112,7 +146,7 @@ class PayloadPanel extends ApiBaseElement {
|
|
|
112
146
|
const transaction = view.state.update({
|
|
113
147
|
changes: {
|
|
114
148
|
from: 0,
|
|
115
|
-
insert: JSON.stringify(document, null, 2),
|
|
149
|
+
insert: document ? JSON.stringify(document, null, 2) : '',
|
|
116
150
|
to: view.state.doc.length,
|
|
117
151
|
},
|
|
118
152
|
})
|
|
@@ -126,6 +160,22 @@ class PayloadPanel extends ApiBaseElement {
|
|
|
126
160
|
payloadContainer.style.display = isUpdateEvent ? 'none' : 'block'
|
|
127
161
|
deltaPayloadContainer.style.display = isUpdateEvent ? 'block' : 'none'
|
|
128
162
|
}
|
|
163
|
+
updatePanelTitle = ({selectedFunctionType}) => {
|
|
164
|
+
const payloadTitle = this.shadowRoot.querySelector('#payloadTitle')
|
|
165
|
+
let title = 'Document'
|
|
166
|
+
switch (selectedFunctionType) {
|
|
167
|
+
case this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE:
|
|
168
|
+
title = 'Sync Tag Payload'
|
|
169
|
+
break
|
|
170
|
+
case this.SANITY_FUNCTION_SCHEDULED:
|
|
171
|
+
title = 'Schedule Payload'
|
|
172
|
+
break
|
|
173
|
+
case this.SANITY_FUNCTION_DOCUMENT:
|
|
174
|
+
case this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET:
|
|
175
|
+
title = 'Document'
|
|
176
|
+
}
|
|
177
|
+
payloadTitle.innerHTML = title
|
|
178
|
+
}
|
|
129
179
|
|
|
130
180
|
disconnectedCallback() {
|
|
131
181
|
if (this.api) {
|
|
@@ -14,7 +14,7 @@ template.innerHTML = `<div class="border-left y-scroll min-h-0">
|
|
|
14
14
|
<h3 class="config-label mar-t-0 hidden">Filter/Projection</h3>
|
|
15
15
|
<header class='flex space-between'>
|
|
16
16
|
<dl class='flex items-center margin-0 pad-3 slab-stat'>
|
|
17
|
-
<dt class=
|
|
17
|
+
<dt id="ruleTitle" class="nowrap">Filter/Projection</dt>
|
|
18
18
|
</dl>
|
|
19
19
|
</header>
|
|
20
20
|
<div id="rule" name="rule" class="cm-s-dracula"></div>
|
|
@@ -30,6 +30,18 @@ class RulePanel extends ApiBaseElement {
|
|
|
30
30
|
updateRule = () => {
|
|
31
31
|
const {functions, rule, selectedIndex} = this.api.store
|
|
32
32
|
const func = functions.find((func) => func.name === selectedIndex)
|
|
33
|
+
switch (func.type) {
|
|
34
|
+
case this.SANITY_FUNCTION_SCHEDULED:
|
|
35
|
+
this.ruleTitle.innerHTML = 'Schedule Rule'
|
|
36
|
+
break
|
|
37
|
+
case this.SANITY_FUNCTION_DOCUMENT:
|
|
38
|
+
case this.SANITY_FUNCTION_MEDIA_LIBRARY_ASSET:
|
|
39
|
+
this.ruleTitle.innerHTML = 'Filter/Projection'
|
|
40
|
+
break
|
|
41
|
+
case this.SANITY_FUNCTION_SYNC_TAG_INVALIDATE:
|
|
42
|
+
this.ruleTitle.innerHTML = 'Resource'
|
|
43
|
+
break
|
|
44
|
+
}
|
|
33
45
|
|
|
34
46
|
if (func.event) {
|
|
35
47
|
const transaction = rule.state.update({
|
|
@@ -48,6 +60,7 @@ class RulePanel extends ApiBaseElement {
|
|
|
48
60
|
this.shadowRoot.adoptedStyleSheets = sheets
|
|
49
61
|
|
|
50
62
|
this.rule = this.shadowRoot.querySelector('#rule')
|
|
63
|
+
this.ruleTitle = this.shadowRoot.querySelector('#ruleTitle')
|
|
51
64
|
|
|
52
65
|
if (this.api) {
|
|
53
66
|
this.api.subscribe(this.updateRule, ['selectedIndex', 'functions'])
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BlueprintLog } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A pattern that matches a log message and produces oclif suggestions
|
|
4
|
+
* The regex is tested against `BlueprintLog.message`
|
|
5
|
+
* capture groups are forwarded to the factory so suggestions can include dynamic values
|
|
6
|
+
*/
|
|
7
|
+
type LogHintPattern = [RegExp, (match: RegExpMatchArray, bin: string) => string[]];
|
|
8
|
+
/**
|
|
9
|
+
* Patterns matched against ERROR/FATAL log entries during streaming operations
|
|
10
|
+
* like deploy and destroy. Each entry is a [regex, suggestionFactory] tuple.
|
|
11
|
+
*
|
|
12
|
+
* Add new patterns here -- no other code changes required.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LOG_HINT_PATTERNS: LogHintPattern[];
|
|
15
|
+
/**
|
|
16
|
+
* Creates a collector to create suggestions
|
|
17
|
+
* Use getSuggestions() after all logs are inspected
|
|
18
|
+
*/
|
|
19
|
+
export declare function createLogHintCollector(bin: string): {
|
|
20
|
+
/** Check a log entry against hint patterns; only ERROR/FATAL levels are inspected. */
|
|
21
|
+
inspect(log: BlueprintLog): void;
|
|
22
|
+
/** Return unique collected suggestions. */
|
|
23
|
+
getSuggestions(): string[];
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patterns matched against ERROR/FATAL log entries during streaming operations
|
|
3
|
+
* like deploy and destroy. Each entry is a [regex, suggestionFactory] tuple.
|
|
4
|
+
*
|
|
5
|
+
* Add new patterns here -- no other code changes required.
|
|
6
|
+
*/
|
|
7
|
+
export const LOG_HINT_PATTERNS = [
|
|
8
|
+
[
|
|
9
|
+
// tester
|
|
10
|
+
/\[TEST\] '(.+)' TEST/,
|
|
11
|
+
(match) => [`TEST SUGGESTION for '${match[1]}'.`],
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
// Function requires organization scope
|
|
15
|
+
/\[Functions\] Failed.+: (.+must be attached to an organization scoped stack)/,
|
|
16
|
+
(_match, bin) => [
|
|
17
|
+
`Run \`npx ${bin} blueprints promote\` to move from project to organization scope.`,
|
|
18
|
+
],
|
|
19
|
+
],
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* Creates a collector to create suggestions
|
|
23
|
+
* Use getSuggestions() after all logs are inspected
|
|
24
|
+
*/
|
|
25
|
+
export function createLogHintCollector(bin) {
|
|
26
|
+
const collected = [];
|
|
27
|
+
return {
|
|
28
|
+
/** Check a log entry against hint patterns; only ERROR/FATAL levels are inspected. */
|
|
29
|
+
inspect(log) {
|
|
30
|
+
const level = log.level.toUpperCase();
|
|
31
|
+
if (level !== 'ERROR' && level !== 'FATAL')
|
|
32
|
+
return;
|
|
33
|
+
for (const [pattern, factory] of LOG_HINT_PATTERNS) {
|
|
34
|
+
const match = log.message.match(pattern);
|
|
35
|
+
if (match) {
|
|
36
|
+
collected.push(...factory(match, bin));
|
|
37
|
+
break; // first matching pattern wins per entry
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
/** Return unique collected suggestions. */
|
|
42
|
+
getSuggestions() {
|
|
43
|
+
return [...new Set(collected)];
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -117,7 +117,12 @@ process.on('message', async (data) => {
|
|
|
117
117
|
)
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
json = await eventHandler({
|
|
120
|
+
json = await eventHandler({
|
|
121
|
+
context,
|
|
122
|
+
event,
|
|
123
|
+
// mock sync-tag-invalidate done callback
|
|
124
|
+
done: async (_tags) => new Response(null, {status: 204}),
|
|
125
|
+
})
|
|
121
126
|
|
|
122
127
|
// Restore streams
|
|
123
128
|
process.stdout.write = originalStdoutWrite
|
|
@@ -70,7 +70,7 @@ export default async function invoke(resource, payload, context, options) {
|
|
|
70
70
|
createTempPackageJson(functionPath);
|
|
71
71
|
}
|
|
72
72
|
const { forceColor = true, timeout = 10 } = options;
|
|
73
|
-
let filteredData = {};
|
|
73
|
+
let filteredData = payload?.payload?.data || {};
|
|
74
74
|
if (resource.type === 'sanity.function.document' ||
|
|
75
75
|
resource.type === 'sanity.function.media-library.asset') {
|
|
76
76
|
if (!isGroqContextOptions(context)) {
|
package/oclif.manifest.json
CHANGED