@sanity/runtime-cli 12.3.0 → 13.0.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 +190 -76
- package/dist/actions/blueprints/assets.d.ts +3 -1
- package/dist/actions/blueprints/assets.js +15 -5
- package/dist/actions/blueprints/blueprint.d.ts +2 -1
- package/dist/actions/blueprints/blueprint.js +3 -1
- package/dist/actions/blueprints/config.d.ts +5 -2
- package/dist/actions/blueprints/config.js +4 -4
- package/dist/actions/blueprints/logs-streaming.d.ts +4 -2
- package/dist/actions/blueprints/logs-streaming.js +5 -2
- package/dist/actions/blueprints/logs.d.ts +2 -1
- package/dist/actions/blueprints/logs.js +4 -2
- package/dist/actions/blueprints/resources.d.ts +2 -1
- package/dist/actions/blueprints/resources.js +2 -2
- package/dist/actions/blueprints/stacks.d.ts +12 -6
- package/dist/actions/blueprints/stacks.js +18 -11
- package/dist/actions/functions/dev.d.ts +2 -1
- package/dist/actions/functions/dev.js +2 -2
- package/dist/actions/functions/env/list.d.ts +2 -1
- package/dist/actions/functions/env/list.js +4 -2
- package/dist/actions/functions/env/remove.d.ts +2 -1
- package/dist/actions/functions/env/remove.js +4 -2
- package/dist/actions/functions/env/update.d.ts +2 -1
- package/dist/actions/functions/env/update.js +4 -2
- package/dist/actions/functions/logs.d.ts +4 -3
- package/dist/actions/functions/logs.js +10 -6
- package/dist/actions/node.d.ts +2 -1
- package/dist/actions/node.js +2 -2
- package/dist/actions/sanity/examples.d.ts +5 -2
- package/dist/actions/sanity/examples.js +6 -6
- package/dist/actions/sanity/projects.d.ts +7 -3
- package/dist/actions/sanity/projects.js +11 -7
- package/dist/baseCommands.d.ts +47 -7
- package/dist/baseCommands.js +90 -12
- package/dist/commands/blueprints/add.d.ts +3 -2
- package/dist/commands/blueprints/add.js +14 -10
- package/dist/commands/blueprints/config.d.ts +3 -2
- package/dist/commands/blueprints/config.js +12 -6
- package/dist/commands/blueprints/deploy.d.ts +3 -2
- package/dist/commands/blueprints/deploy.js +10 -4
- package/dist/commands/blueprints/destroy.d.ts +3 -2
- package/dist/commands/blueprints/destroy.js +10 -4
- package/dist/commands/blueprints/doctor.d.ts +6 -4
- package/dist/commands/blueprints/doctor.js +17 -14
- package/dist/commands/blueprints/info.d.ts +3 -2
- package/dist/commands/blueprints/info.js +11 -5
- package/dist/commands/blueprints/init.d.ts +3 -2
- package/dist/commands/blueprints/init.js +26 -20
- package/dist/commands/blueprints/logs.d.ts +3 -2
- package/dist/commands/blueprints/logs.js +10 -4
- package/dist/commands/blueprints/plan.d.ts +3 -2
- package/dist/commands/blueprints/plan.js +8 -4
- package/dist/commands/blueprints/stacks.d.ts +3 -2
- package/dist/commands/blueprints/stacks.js +10 -6
- package/dist/commands/functions/add.d.ts +3 -2
- package/dist/commands/functions/add.js +10 -4
- package/dist/commands/functions/dev.d.ts +3 -2
- package/dist/commands/functions/dev.js +16 -5
- package/dist/commands/functions/env/add.d.ts +4 -3
- package/dist/commands/functions/env/add.js +8 -4
- package/dist/commands/functions/env/list.d.ts +4 -3
- package/dist/commands/functions/env/list.js +8 -4
- package/dist/commands/functions/env/remove.d.ts +4 -3
- package/dist/commands/functions/env/remove.js +8 -4
- package/dist/commands/functions/logs.d.ts +5 -4
- package/dist/commands/functions/logs.js +11 -5
- package/dist/commands/functions/test.d.ts +5 -4
- package/dist/commands/functions/test.js +13 -6
- package/dist/cores/blueprints/config.d.ts +2 -5
- package/dist/cores/blueprints/config.js +9 -9
- package/dist/cores/blueprints/deploy.js +14 -17
- package/dist/cores/blueprints/destroy.d.ts +2 -5
- package/dist/cores/blueprints/destroy.js +6 -6
- package/dist/cores/blueprints/doctor.js +32 -29
- package/dist/cores/blueprints/info.js +5 -5
- package/dist/cores/blueprints/init.d.ts +3 -3
- package/dist/cores/blueprints/init.js +15 -8
- package/dist/cores/blueprints/logs.js +6 -7
- package/dist/cores/blueprints/plan.js +1 -0
- package/dist/cores/blueprints/stacks.d.ts +2 -5
- package/dist/cores/blueprints/stacks.js +4 -4
- package/dist/cores/functions/add.js +8 -3
- package/dist/cores/functions/dev.js +2 -2
- package/dist/cores/functions/env/add.js +3 -4
- package/dist/cores/functions/env/list.js +3 -4
- package/dist/cores/functions/env/remove.js +3 -4
- package/dist/cores/functions/index.d.ts +3 -9
- package/dist/cores/functions/logs.d.ts +3 -1
- package/dist/cores/functions/logs.js +19 -11
- package/dist/cores/functions/test.d.ts +3 -1
- package/dist/cores/functions/test.js +18 -10
- package/dist/cores/index.d.ts +4 -7
- package/dist/cores/index.js +3 -3
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/server/app.d.ts +2 -1
- package/dist/server/app.js +4 -4
- package/dist/server/handlers/invoke.d.ts +2 -1
- package/dist/server/handlers/invoke.js +2 -2
- package/dist/server/static/components/app.css +0 -116
- package/dist/server/static/components/clear-button.js +1 -1
- package/dist/server/static/components/console-panel.js +27 -6
- package/dist/server/static/components/fetch-button.js +1 -1
- package/dist/server/static/components/filter-api-version.js +39 -3
- package/dist/server/static/components/filter-document-id.js +39 -3
- package/dist/server/static/components/filter-with-token.js +27 -4
- package/dist/server/static/components/filters.js +127 -62
- package/dist/server/static/components/function-list.js +33 -13
- package/dist/server/static/components/network-spinner.js +6 -4
- package/dist/server/static/components/payload-panel.js +46 -24
- package/dist/server/static/components/response-panel.js +33 -6
- package/dist/server/static/components/rule-panel.js +13 -4
- package/dist/server/static/components/run-panel.js +14 -7
- package/dist/server/static/components/select-dropdown.js +34 -5
- package/dist/server/static/components/shared-styles.js +31 -0
- package/dist/server/static/components/toggle-switch.js +11 -2
- package/dist/utils/display/blueprints-formatting.d.ts +2 -2
- package/dist/utils/display/blueprints-formatting.js +31 -26
- package/dist/utils/display/prompt.d.ts +5 -2
- package/dist/utils/display/prompt.js +5 -4
- package/dist/utils/find-function.d.ts +4 -0
- package/dist/utils/find-function.js +6 -0
- package/dist/utils/functions/fetch-document.d.ts +3 -2
- package/dist/utils/functions/fetch-document.js +7 -6
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.js +61 -0
- package/dist/utils/other/github.d.ts +2 -1
- package/dist/utils/other/github.js +4 -2
- package/dist/utils/other/npmjs.d.ts +2 -1
- package/dist/utils/other/npmjs.js +4 -2
- package/dist/utils/traced-fetch.d.ts +35 -0
- package/dist/utils/traced-fetch.js +238 -0
- package/dist/utils/validated-token.d.ts +3 -2
- package/dist/utils/validated-token.js +6 -4
- package/oclif.manifest.json +455 -75
- package/package.json +14 -6
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {ApiBaseElement} from './api-base.js'
|
|
2
|
+
|
|
3
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
4
|
+
|
|
5
|
+
const template = document.createElement('template')
|
|
6
|
+
template.innerHTML = `
|
|
4
7
|
<fieldset class="mar-t-2">
|
|
5
8
|
<label class="slab-text">
|
|
6
9
|
<span class="block mar-b-1">
|
|
@@ -20,6 +23,39 @@ class DocumentIdFilter extends HTMLElement {
|
|
|
20
23
|
</label>
|
|
21
24
|
</fieldset>
|
|
22
25
|
`
|
|
26
|
+
|
|
27
|
+
class DocumentIdFilter extends ApiBaseElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super()
|
|
30
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async connectedCallback() {
|
|
34
|
+
const sheets = await getSharedStyleSheets()
|
|
35
|
+
|
|
36
|
+
// Create a component-specific stylesheet that will be applied after shared styles
|
|
37
|
+
const componentSheet = new CSSStyleSheet()
|
|
38
|
+
await componentSheet.replace(`
|
|
39
|
+
:host {
|
|
40
|
+
align-self: flex-end;
|
|
41
|
+
}
|
|
42
|
+
fieldset {
|
|
43
|
+
margin-top: 0 !important;
|
|
44
|
+
}
|
|
45
|
+
input {
|
|
46
|
+
background: transparent !important;
|
|
47
|
+
color: light-dark(var(--gray-950), var(--gray-300)) !important;
|
|
48
|
+
}
|
|
49
|
+
`)
|
|
50
|
+
|
|
51
|
+
this.shadowRoot.adoptedStyleSheets = [...sheets, componentSheet]
|
|
52
|
+
|
|
53
|
+
this.input = this.shadowRoot.querySelector('input')
|
|
54
|
+
this.input.addEventListener('input', this.updateDocId)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
updateDocId = (event) => {
|
|
58
|
+
this.api.store.docId = event.target.value
|
|
23
59
|
}
|
|
24
60
|
}
|
|
25
61
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
2
|
+
|
|
3
|
+
const template = document.createElement('template')
|
|
4
|
+
template.innerHTML = `
|
|
5
|
+
<fieldset class="mar-t-2 flex flex-col">
|
|
5
6
|
<span class="slab-text block mar-b-1">
|
|
6
7
|
<span class="flex items-center">
|
|
7
8
|
With Token
|
|
@@ -15,6 +16,28 @@ class WithTokenComponent extends HTMLElement {
|
|
|
15
16
|
<toggle-switch toggle-key="withToken" class="flex component-height"></toggle-switch>
|
|
16
17
|
</fieldset>
|
|
17
18
|
`
|
|
19
|
+
|
|
20
|
+
class WithTokenComponent extends HTMLElement {
|
|
21
|
+
constructor() {
|
|
22
|
+
super()
|
|
23
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async connectedCallback() {
|
|
27
|
+
const sheets = await getSharedStyleSheets()
|
|
28
|
+
|
|
29
|
+
// Create a component-specific stylesheet that will be applied after shared styles
|
|
30
|
+
const componentSheet = new CSSStyleSheet()
|
|
31
|
+
await componentSheet.replace(`
|
|
32
|
+
:host {
|
|
33
|
+
align-self: flex-end;
|
|
34
|
+
}
|
|
35
|
+
fieldset {
|
|
36
|
+
margin-top: 0 !important;
|
|
37
|
+
}
|
|
38
|
+
`)
|
|
39
|
+
|
|
40
|
+
this.shadowRoot.adoptedStyleSheets = [...sheets, componentSheet]
|
|
18
41
|
}
|
|
19
42
|
}
|
|
20
43
|
|
|
@@ -1,75 +1,140 @@
|
|
|
1
1
|
import {ApiBaseElement} from './api-base.js'
|
|
2
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
3
|
+
|
|
4
|
+
const template = document.createElement('template')
|
|
5
|
+
template.innerHTML = `
|
|
6
|
+
<style>
|
|
7
|
+
:host {
|
|
8
|
+
grid-area: filters;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
form {
|
|
12
|
+
display: block;
|
|
13
|
+
padding: var(--m-space-3);
|
|
14
|
+
border-bottom: 1px solid var(--card-border-color);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
form > * {
|
|
18
|
+
display: block;
|
|
19
|
+
width: 100%;
|
|
20
|
+
margin-bottom: var(--m-space-3);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
form > *:last-child {
|
|
24
|
+
margin-bottom: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
form label {
|
|
28
|
+
display: block;
|
|
29
|
+
margin-bottom: var(--m-space-1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
form input {
|
|
33
|
+
width: 100%;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media (min-width: 40em) {
|
|
38
|
+
form {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
align-items: flex-end;
|
|
42
|
+
gap: var(--m-space-3);
|
|
43
|
+
padding-left: var(--m-space-3);
|
|
44
|
+
padding-bottom: var(--m-space-3);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
form > * {
|
|
48
|
+
width: auto;
|
|
49
|
+
margin-bottom: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
form fieldset {
|
|
53
|
+
min-width: 150px;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</style>
|
|
57
|
+
<form class="gap-2 pad-l-3 pad-b-3 border-bottom">
|
|
58
|
+
<fieldset class="flex gap-2">
|
|
59
|
+
<legend class="config-label">Client Options</legend>
|
|
60
|
+
<div id="dynamic-dropdowns" class="flex gap-2"></div>
|
|
61
|
+
<select-dropdown
|
|
62
|
+
label="Event"
|
|
63
|
+
store-key="events"
|
|
64
|
+
selected-key="selectedEvent"
|
|
65
|
+
value-prop="name"
|
|
66
|
+
label-prop="name"
|
|
67
|
+
></select-dropdown>
|
|
68
|
+
<api-version></api-version>
|
|
69
|
+
<with-token></with-token>
|
|
70
|
+
<document-id></document-id>
|
|
71
|
+
</fieldset>
|
|
72
|
+
</form>
|
|
73
|
+
`
|
|
2
74
|
|
|
3
75
|
class FiltersComponent extends ApiBaseElement {
|
|
76
|
+
constructor() {
|
|
77
|
+
super()
|
|
78
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async connectedCallback() {
|
|
82
|
+
const sheets = await getSharedStyleSheets()
|
|
83
|
+
this.shadowRoot.adoptedStyleSheets = sheets
|
|
84
|
+
|
|
85
|
+
this.renderFilters()
|
|
86
|
+
this.api.subscribe(this.renderFilters, ['selectedFunctionType'])
|
|
87
|
+
}
|
|
88
|
+
|
|
4
89
|
renderFilters = () => {
|
|
5
90
|
const docFunction = this.api.store.selectedFunctionType === 'sanity.function.document'
|
|
6
91
|
const mediaFunction = this.api.store.selectedFunctionType?.startsWith(
|
|
7
92
|
'sanity.function.media-library',
|
|
8
93
|
)
|
|
9
94
|
|
|
10
|
-
|
|
11
|
-
<form class="gap-2 pad-l-3 pad-b-3 border-bottom">
|
|
12
|
-
<fieldset class="flex gap-2">
|
|
13
|
-
<legend class="config-label">Client Options</legend>
|
|
14
|
-
${
|
|
15
|
-
docFunction
|
|
16
|
-
? `<select-dropdown
|
|
17
|
-
label="Project"
|
|
18
|
-
store-key="projects"
|
|
19
|
-
selected-key="selectedProject"
|
|
20
|
-
value-prop="id"
|
|
21
|
-
label-prop="displayName"
|
|
22
|
-
trigger-fetch
|
|
23
|
-
></select-dropdown>
|
|
24
|
-
<select-dropdown
|
|
25
|
-
label="Dataset"
|
|
26
|
-
store-key="datasets"
|
|
27
|
-
selected-key="selectedDataset"
|
|
28
|
-
value-prop="name"
|
|
29
|
-
label-prop="name"
|
|
30
|
-
subscribe-to="selectedProject"
|
|
31
|
-
></select-dropdown>`
|
|
32
|
-
: ''
|
|
33
|
-
}
|
|
34
|
-
${
|
|
35
|
-
mediaFunction
|
|
36
|
-
? `<select-dropdown
|
|
37
|
-
label="Organization"
|
|
38
|
-
store-key="organizations"
|
|
39
|
-
selected-key="selectedOrganization"
|
|
40
|
-
value-prop="id"
|
|
41
|
-
label-prop="name"
|
|
42
|
-
trigger-fetch
|
|
43
|
-
></select-dropdown>
|
|
44
|
-
<select-dropdown
|
|
45
|
-
label="Media Library"
|
|
46
|
-
store-key="mediaLibraries"
|
|
47
|
-
selected-key="selectedMediaLibrary"
|
|
48
|
-
value-prop="id"
|
|
49
|
-
label-prop="id"
|
|
50
|
-
subscribe-to="selectedOrganization"
|
|
51
|
-
></select-dropdown>`
|
|
52
|
-
: ''
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
<select-dropdown
|
|
56
|
-
label="Event"
|
|
57
|
-
store-key="events"
|
|
58
|
-
selected-key="selectedEvent"
|
|
59
|
-
value-prop="name"
|
|
60
|
-
label-prop="name"
|
|
61
|
-
></select-dropdown>
|
|
62
|
-
|
|
63
|
-
<api-version></api-version>
|
|
64
|
-
<with-token></with-token>
|
|
65
|
-
<document-id></document-id>
|
|
66
|
-
</form>
|
|
67
|
-
`
|
|
68
|
-
}
|
|
95
|
+
const container = this.shadowRoot.querySelector('#dynamic-dropdowns')
|
|
69
96
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
97
|
+
if (docFunction) {
|
|
98
|
+
container.innerHTML = `
|
|
99
|
+
<select-dropdown
|
|
100
|
+
label="Project"
|
|
101
|
+
store-key="projects"
|
|
102
|
+
selected-key="selectedProject"
|
|
103
|
+
value-prop="id"
|
|
104
|
+
label-prop="displayName"
|
|
105
|
+
trigger-fetch
|
|
106
|
+
></select-dropdown>
|
|
107
|
+
<select-dropdown
|
|
108
|
+
label="Dataset"
|
|
109
|
+
store-key="datasets"
|
|
110
|
+
selected-key="selectedDataset"
|
|
111
|
+
value-prop="name"
|
|
112
|
+
label-prop="name"
|
|
113
|
+
subscribe-to="selectedProject"
|
|
114
|
+
></select-dropdown>
|
|
115
|
+
`
|
|
116
|
+
} else if (mediaFunction) {
|
|
117
|
+
container.innerHTML = `
|
|
118
|
+
<select-dropdown
|
|
119
|
+
label="Organization"
|
|
120
|
+
store-key="organizations"
|
|
121
|
+
selected-key="selectedOrganization"
|
|
122
|
+
value-prop="id"
|
|
123
|
+
label-prop="name"
|
|
124
|
+
trigger-fetch
|
|
125
|
+
></select-dropdown>
|
|
126
|
+
<select-dropdown
|
|
127
|
+
label="Media Library"
|
|
128
|
+
store-key="mediaLibraries"
|
|
129
|
+
selected-key="selectedMediaLibrary"
|
|
130
|
+
value-prop="id"
|
|
131
|
+
label-prop="id"
|
|
132
|
+
subscribe-to="selectedOrganization"
|
|
133
|
+
></select-dropdown>
|
|
134
|
+
`
|
|
135
|
+
} else {
|
|
136
|
+
container.innerHTML = ''
|
|
137
|
+
}
|
|
73
138
|
}
|
|
74
139
|
|
|
75
140
|
disconnectedCallback() {
|
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
/* globals customElements */
|
|
2
2
|
import {ApiBaseElement} from './api-base.js'
|
|
3
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
3
4
|
|
|
4
|
-
const template =
|
|
5
|
+
const template = document.createElement('template')
|
|
6
|
+
template.innerHTML = `
|
|
7
|
+
<ol class="hidden-lg pad-t-0 pad-b-0 pad-r-4 pad-l-4" type="content"></ol>
|
|
5
8
|
<fieldset class="hidden block-lg pad-t-0 pad-b-0 pad-r-3 pad-l-3 mar-b-3"><select class="dropdown-select"></select></fieldset>
|
|
6
9
|
`
|
|
7
10
|
|
|
8
11
|
class FunctionList extends ApiBaseElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
super()
|
|
14
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async connectedCallback() {
|
|
18
|
+
const sheets = await getSharedStyleSheets()
|
|
19
|
+
|
|
20
|
+
// Create a component-specific stylesheet that will be applied after shared styles
|
|
21
|
+
const componentSheet = new CSSStyleSheet()
|
|
22
|
+
await componentSheet.replace(`
|
|
23
|
+
select {
|
|
24
|
+
background: transparent !important;
|
|
25
|
+
color: light-dark(var(--gray-950), var(--gray-300)) !important;
|
|
26
|
+
}
|
|
27
|
+
`)
|
|
28
|
+
|
|
29
|
+
this.shadowRoot.adoptedStyleSheets = [...sheets, componentSheet]
|
|
30
|
+
|
|
31
|
+
this.list = this.shadowRoot.querySelector('ol')
|
|
32
|
+
this.select = this.shadowRoot.querySelector('select')
|
|
33
|
+
this.list.addEventListener('click', this.functionClicked)
|
|
34
|
+
this.select.addEventListener('change', this.functionSelected)
|
|
35
|
+
this.api.subscribe(this.renderFunctions, ['functions', 'selectedIndex'])
|
|
36
|
+
this.api.blueprint()
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
functionClicked = (event) => {
|
|
10
|
-
const name = event.
|
|
40
|
+
const name = event.target.closest('li').dataset.name
|
|
11
41
|
const target = this.api.store.functions.find((func) => func.name === name)
|
|
12
42
|
this.api.store.selectedIndex = target.name
|
|
13
43
|
this.api.store.selectedFunctionType = target.type
|
|
14
44
|
}
|
|
15
45
|
functionSelected = (event) => {
|
|
16
|
-
this.api.store.selectedIndex = event.
|
|
46
|
+
this.api.store.selectedIndex = event.target.value
|
|
17
47
|
}
|
|
18
48
|
renderListItem = (func) => {
|
|
19
49
|
const selected = this.api.store.selectedIndex === func.name ? 'selected' : ''
|
|
@@ -53,16 +83,6 @@ class FunctionList extends ApiBaseElement {
|
|
|
53
83
|
}
|
|
54
84
|
}
|
|
55
85
|
|
|
56
|
-
connectedCallback() {
|
|
57
|
-
this.innerHTML = template
|
|
58
|
-
this.list = this.querySelector('ol')
|
|
59
|
-
this.select = this.querySelector('select')
|
|
60
|
-
this.list.addEventListener('click', this.functionClicked)
|
|
61
|
-
this.select.addEventListener('change', this.functionSelected)
|
|
62
|
-
this.api.subscribe(this.renderFunctions, ['functions', 'selectedIndex'])
|
|
63
|
-
this.api.blueprint()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
86
|
disconnectedCallback() {
|
|
67
87
|
this.list.removeEventListener('click', this.functionClicked)
|
|
68
88
|
this.select.removeEventListener('change', this.functionSelected)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* globals customElements HTMLElement */
|
|
2
|
-
const template =
|
|
3
|
-
|
|
2
|
+
const template = document.createElement('template')
|
|
3
|
+
template.innerHTML = `<style>
|
|
4
|
+
:host {
|
|
4
5
|
--track-width: 2px;
|
|
5
6
|
--track-color: var(--card-border-color);
|
|
6
7
|
--indicator-color: var(--text-color);
|
|
@@ -63,8 +64,9 @@ const template = `<style>
|
|
|
63
64
|
</svg>`
|
|
64
65
|
|
|
65
66
|
class NetworkSpinner extends HTMLElement {
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
constructor() {
|
|
68
|
+
super()
|
|
69
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
68
70
|
}
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -3,11 +3,28 @@
|
|
|
3
3
|
import {basicSetup, EditorView, json} from '../vendor/vendor.bundle.js'
|
|
4
4
|
import {ApiBaseElement} from './api-base.js'
|
|
5
5
|
import {sanityCodeMirrorTheme} from './codemirror-theme.js'
|
|
6
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const template = document.createElement('template')
|
|
9
|
+
template.innerHTML = `
|
|
10
|
+
<style>
|
|
11
|
+
:host {
|
|
12
|
+
grid-area: payload;
|
|
13
|
+
max-height: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
min-height: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (max-width: 40rem) {
|
|
20
|
+
:host {
|
|
21
|
+
max-height: none;
|
|
22
|
+
min-height: 200px;
|
|
23
|
+
overflow: auto;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</style>
|
|
27
|
+
<div id="payloadContainer" class="gutter-gradient relative h-100 max-h-100 y-scroll border-top border-top-none-l">
|
|
11
28
|
<div class="bg gutter-gradient sticky top-0 right-0 left-0 z-100">
|
|
12
29
|
<div class="flex items-center space-between pad-t-2 pad-r-5 pad-b-2 pad-l-12">
|
|
13
30
|
<h2 class="config-label mar-t-0 mar-b-0">Document</h2>
|
|
@@ -16,7 +33,7 @@ function template({selectedEvent}) {
|
|
|
16
33
|
</div>
|
|
17
34
|
<div id="payload" name="payload" class='max-h-100 min-h-0'></div>
|
|
18
35
|
</div>
|
|
19
|
-
<div id="deltaPayloadContainer" class="gutter-gradient relative h-100 max-h-100 y-scroll border-top border-top-none-l"
|
|
36
|
+
<div id="deltaPayloadContainer" class="gutter-gradient relative h-100 max-h-100 y-scroll border-top border-top-none-l" style="display: none;">
|
|
20
37
|
<div class="bg gutter-gradient sticky top-0 right-0 left-0 z-100">
|
|
21
38
|
<div class="flex items-center space-between pad-t-2 pad-r-5 pad-b-2 pad-l-12">
|
|
22
39
|
<h2 class="config-label mar-t-0 mar-b-0">Before Document</h2>
|
|
@@ -34,9 +51,30 @@ function template({selectedEvent}) {
|
|
|
34
51
|
<div id="afterPayload" name="afterPayload" class='max-h-50 min-h-0'></div>
|
|
35
52
|
</div>
|
|
36
53
|
`
|
|
37
|
-
}
|
|
38
54
|
|
|
39
55
|
class PayloadPanel extends ApiBaseElement {
|
|
56
|
+
constructor() {
|
|
57
|
+
super()
|
|
58
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async connectedCallback() {
|
|
62
|
+
const sheets = await getSharedStyleSheets()
|
|
63
|
+
this.shadowRoot.adoptedStyleSheets = sheets
|
|
64
|
+
|
|
65
|
+
const beforePayloadElem = this.shadowRoot.querySelector('#beforePayload')
|
|
66
|
+
const afterPayloadElem = this.shadowRoot.querySelector('#afterPayload')
|
|
67
|
+
|
|
68
|
+
this.api.store.beforePayload = attachEditorView(beforePayloadElem)
|
|
69
|
+
this.api.store.afterPayload = attachEditorView(afterPayloadElem)
|
|
70
|
+
|
|
71
|
+
const payloadElem = this.shadowRoot.querySelector('#payload')
|
|
72
|
+
this.api.store.payload = attachEditorView(payloadElem)
|
|
73
|
+
|
|
74
|
+
this.api.subscribe(this.updatePayload, ['document'])
|
|
75
|
+
this.api.subscribe(this.updateSelectedEvent, ['selectedEvent'])
|
|
76
|
+
}
|
|
77
|
+
|
|
40
78
|
updatePayload = ({document}) => {
|
|
41
79
|
if (!document) return
|
|
42
80
|
|
|
@@ -57,30 +95,14 @@ class PayloadPanel extends ApiBaseElement {
|
|
|
57
95
|
updateSelectedEvent = ({selectedEvent}) => {
|
|
58
96
|
console.log('updateSelectedEvent', selectedEvent)
|
|
59
97
|
|
|
60
|
-
const payloadContainer = this.querySelector('#payloadContainer')
|
|
61
|
-
const deltaPayloadContainer = this.querySelector('#deltaPayloadContainer')
|
|
98
|
+
const payloadContainer = this.shadowRoot.querySelector('#payloadContainer')
|
|
99
|
+
const deltaPayloadContainer = this.shadowRoot.querySelector('#deltaPayloadContainer')
|
|
62
100
|
|
|
63
101
|
const isUpdateEvent = selectedEvent === 'update'
|
|
64
102
|
payloadContainer.style.display = isUpdateEvent ? 'none' : 'block'
|
|
65
103
|
deltaPayloadContainer.style.display = isUpdateEvent ? 'block' : 'none'
|
|
66
104
|
}
|
|
67
|
-
connectedCallback() {
|
|
68
|
-
this.innerHTML = template({
|
|
69
|
-
selectedEvent: this.api.store.selectedEvent,
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
const beforePayloadElem = this.querySelector('#beforePayload')
|
|
73
|
-
const afterPayloadElem = this.querySelector('#afterPayload')
|
|
74
|
-
|
|
75
|
-
this.api.store.beforePayload = attachEditorView(beforePayloadElem)
|
|
76
|
-
this.api.store.afterPayload = attachEditorView(afterPayloadElem)
|
|
77
|
-
|
|
78
|
-
const payloadElem = this.querySelector('#payload')
|
|
79
|
-
this.api.store.payload = attachEditorView(payloadElem)
|
|
80
105
|
|
|
81
|
-
this.api.subscribe(this.updatePayload, ['document'])
|
|
82
|
-
this.api.subscribe(this.updateSelectedEvent, ['selectedEvent'])
|
|
83
|
-
}
|
|
84
106
|
disconnectedCallback() {
|
|
85
107
|
if (this.api) {
|
|
86
108
|
this.api.unsubscribe(this.updatePayload)
|
|
@@ -11,8 +11,28 @@ import {
|
|
|
11
11
|
} from '../vendor/vendor.bundle.js'
|
|
12
12
|
import {ApiBaseElement} from './api-base.js'
|
|
13
13
|
import {sanityCodeMirrorTheme} from './codemirror-theme.js'
|
|
14
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
14
15
|
|
|
15
|
-
const template =
|
|
16
|
+
const template = document.createElement('template')
|
|
17
|
+
template.innerHTML = `
|
|
18
|
+
<style>
|
|
19
|
+
:host {
|
|
20
|
+
grid-area: response;
|
|
21
|
+
max-height: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
min-height: 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (max-width: 40rem) {
|
|
28
|
+
:host {
|
|
29
|
+
max-height: none;
|
|
30
|
+
min-height: 200px;
|
|
31
|
+
overflow: auto;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
</style>
|
|
35
|
+
<div class="border-left border-top border-top-none-l h-100 gutter-gradient max-h-100 overflow-hidden response-panel-grid">
|
|
16
36
|
<!-- Response Section -->
|
|
17
37
|
<div class="y-scroll min-h-0">
|
|
18
38
|
<div class="pad-b-12">
|
|
@@ -32,7 +52,12 @@ const template = `<div class="border-left border-top border-top-none-l h-100 gut
|
|
|
32
52
|
</div>
|
|
33
53
|
</div>
|
|
34
54
|
`
|
|
55
|
+
|
|
35
56
|
class ResponsePanel extends ApiBaseElement {
|
|
57
|
+
constructor() {
|
|
58
|
+
super()
|
|
59
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
60
|
+
}
|
|
36
61
|
updateResponse = ({result}) => {
|
|
37
62
|
if (!result) return
|
|
38
63
|
|
|
@@ -72,11 +97,13 @@ class ResponsePanel extends ApiBaseElement {
|
|
|
72
97
|
}
|
|
73
98
|
}
|
|
74
99
|
|
|
75
|
-
connectedCallback() {
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
this.
|
|
100
|
+
async connectedCallback() {
|
|
101
|
+
const sheets = await getSharedStyleSheets()
|
|
102
|
+
this.shadowRoot.adoptedStyleSheets = sheets
|
|
103
|
+
|
|
104
|
+
this.response = this.shadowRoot.querySelector('#response')
|
|
105
|
+
this.size = this.shadowRoot.querySelector('#size')
|
|
106
|
+
this.time = this.shadowRoot.querySelector('#time')
|
|
80
107
|
if (this.api) {
|
|
81
108
|
this.api.subscribe(this.updateResponse, ['result'])
|
|
82
109
|
if (this.api.store.result) {
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
import {basicSetup, EditorState, EditorView, json} from '../vendor/vendor.bundle.js'
|
|
5
5
|
import {ApiBaseElement} from './api-base.js'
|
|
6
6
|
import {sanityCodeMirrorTheme} from './codemirror-theme.js'
|
|
7
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
7
8
|
|
|
8
|
-
const template =
|
|
9
|
+
const template = document.createElement('template')
|
|
10
|
+
template.innerHTML = `<div class="border-left y-scroll min-h-0">
|
|
9
11
|
<div>
|
|
10
12
|
<h3 class="config-label mar-t-0 hidden">Filter/Projection</h3>
|
|
11
13
|
<header class='flex space-between'>
|
|
@@ -17,7 +19,12 @@ const template = `<div class="border-left y-scroll min-h-0">
|
|
|
17
19
|
</div>
|
|
18
20
|
</div>
|
|
19
21
|
`
|
|
22
|
+
|
|
20
23
|
class RulePanel extends ApiBaseElement {
|
|
24
|
+
constructor() {
|
|
25
|
+
super()
|
|
26
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
27
|
+
}
|
|
21
28
|
updateRule = () => {
|
|
22
29
|
const {functions, rule, selectedIndex} = this.api.store
|
|
23
30
|
const func = functions.find((func) => func.name === selectedIndex)
|
|
@@ -34,9 +41,11 @@ class RulePanel extends ApiBaseElement {
|
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
|
|
39
|
-
this.
|
|
44
|
+
async connectedCallback() {
|
|
45
|
+
const sheets = await getSharedStyleSheets()
|
|
46
|
+
this.shadowRoot.adoptedStyleSheets = sheets
|
|
47
|
+
|
|
48
|
+
this.rule = this.shadowRoot.querySelector('#rule')
|
|
40
49
|
|
|
41
50
|
if (this.api) {
|
|
42
51
|
this.api.subscribe(this.updateRule, ['selectedIndex', 'functions'])
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* globals customElements document */
|
|
2
2
|
import {ApiBaseElement} from './api-base.js'
|
|
3
|
+
import {getSharedStyleSheets} from './shared-styles.js'
|
|
3
4
|
|
|
4
5
|
const runTemplate = `<svg data-sanity-icon="play" width="1em" height="1em" viewBox="0 0 25 25" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.5 18.5V6.5L17.5 12.5L7.5 18.5Z" fill="currentColor" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"></path></svg>
|
|
5
6
|
<span title="Type CTRL + Enter to Run">Run</span>`
|
|
6
7
|
|
|
7
|
-
const template =
|
|
8
|
+
const template = document.createElement('template')
|
|
9
|
+
template.innerHTML = `<div class="pad-3">
|
|
8
10
|
<button ord="primary" class="items-center sanity-button">
|
|
9
11
|
<span class="flex pad-3 gap-25 justify-content-center flex-row">
|
|
10
12
|
${runTemplate}
|
|
@@ -12,7 +14,12 @@ const template = `<div class="pad-3">
|
|
|
12
14
|
</button>
|
|
13
15
|
</div>
|
|
14
16
|
`
|
|
17
|
+
|
|
15
18
|
class RunPanel extends ApiBaseElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super()
|
|
21
|
+
this.attachShadow({mode: 'open'}).appendChild(template.content.cloneNode(true))
|
|
22
|
+
}
|
|
16
23
|
invoke = () => {
|
|
17
24
|
const selectedEvent = this.api.store.selectedEvent
|
|
18
25
|
const docFunction = this.api.store.selectedFunctionType === this.SANITY_FUNCTION_DOCUMENT
|
|
@@ -41,7 +48,7 @@ class RunPanel extends ApiBaseElement {
|
|
|
41
48
|
}
|
|
42
49
|
const context = {
|
|
43
50
|
clientOptions: {
|
|
44
|
-
apiVersion:
|
|
51
|
+
apiVersion: this.api.store.apiVersion,
|
|
45
52
|
dataset: this.api.store.selectedDataset,
|
|
46
53
|
projectId: this.api.store.selectedProject,
|
|
47
54
|
token: this.api.store.withToken,
|
|
@@ -86,11 +93,11 @@ class RunPanel extends ApiBaseElement {
|
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
95
|
|
|
89
|
-
connectedCallback() {
|
|
90
|
-
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
this.button = this.querySelector('button')
|
|
96
|
+
async connectedCallback() {
|
|
97
|
+
const sheets = await getSharedStyleSheets()
|
|
98
|
+
this.shadowRoot.adoptedStyleSheets = sheets
|
|
99
|
+
|
|
100
|
+
this.button = this.shadowRoot.querySelector('button')
|
|
94
101
|
this.buttonText = this.button.querySelector('span')
|
|
95
102
|
this.button.addEventListener('click', this.invoke)
|
|
96
103
|
document.addEventListener('keydown', this.onKeyDown)
|