@sanity/runtime-cli 9.1.1 → 9.1.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 +18 -17
- package/dist/commands/functions/test.d.ts +1 -0
- package/dist/commands/functions/test.js +4 -0
- package/dist/cores/functions/test.d.ts +1 -0
- package/dist/cores/functions/test.js +6 -1
- package/dist/server/app.js +8 -0
- package/dist/server/static/components/app.css +0 -2
- package/dist/server/static/components/console-panel.js +3 -2
- package/dist/server/static/components/filters.js +27 -8
- package/dist/server/static/components/run-panel.js +1 -0
- package/dist/server/static/components/select-dropdown.js +118 -0
- package/dist/server/static/components/toggle-switch.d.ts +2 -1
- package/dist/server/static/components/toggle-switch.js +40 -29
- package/dist/server/static/index.html +1 -2
- package/dist/utils/invoke-local.js +0 -1
- package/dist/utils/types.d.ts +1 -0
- package/oclif.manifest.json +7 -1
- package/package.json +1 -1
- package/dist/server/static/components/dataset-dropdown.js +0 -47
- package/dist/server/static/components/projects-dropdown.d.ts +0 -1
- package/dist/server/static/components/projects-dropdown.js +0 -44
- /package/dist/server/static/components/{dataset-dropdown.d.ts → select-dropdown.d.ts} +0 -0
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/9.1.
|
|
23
|
+
@sanity/runtime-cli/9.1.2 linux-x64 node-v22.16.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -86,7 +86,7 @@ EXAMPLES
|
|
|
86
86
|
$ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
89
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/add.ts)_
|
|
90
90
|
|
|
91
91
|
## `sanity-run blueprints config`
|
|
92
92
|
|
|
@@ -117,7 +117,7 @@ EXAMPLES
|
|
|
117
117
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
120
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/config.ts)_
|
|
121
121
|
|
|
122
122
|
## `sanity-run blueprints deploy`
|
|
123
123
|
|
|
@@ -139,7 +139,7 @@ EXAMPLES
|
|
|
139
139
|
$ sanity-run blueprints deploy --no-wait
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
142
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/deploy.ts)_
|
|
143
143
|
|
|
144
144
|
## `sanity-run blueprints destroy`
|
|
145
145
|
|
|
@@ -164,7 +164,7 @@ EXAMPLES
|
|
|
164
164
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
167
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/destroy.ts)_
|
|
168
168
|
|
|
169
169
|
## `sanity-run blueprints info`
|
|
170
170
|
|
|
@@ -186,7 +186,7 @@ EXAMPLES
|
|
|
186
186
|
$ sanity-run blueprints info --stack-id <stackId>
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
189
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/info.ts)_
|
|
190
190
|
|
|
191
191
|
## `sanity-run blueprints init [DIR]`
|
|
192
192
|
|
|
@@ -224,7 +224,7 @@ EXAMPLES
|
|
|
224
224
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
227
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/init.ts)_
|
|
228
228
|
|
|
229
229
|
## `sanity-run blueprints logs`
|
|
230
230
|
|
|
@@ -246,7 +246,7 @@ EXAMPLES
|
|
|
246
246
|
$ sanity-run blueprints logs --watch
|
|
247
247
|
```
|
|
248
248
|
|
|
249
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
249
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/logs.ts)_
|
|
250
250
|
|
|
251
251
|
## `sanity-run blueprints plan`
|
|
252
252
|
|
|
@@ -263,7 +263,7 @@ EXAMPLES
|
|
|
263
263
|
$ sanity-run blueprints plan
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
266
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/plan.ts)_
|
|
267
267
|
|
|
268
268
|
## `sanity-run blueprints stacks`
|
|
269
269
|
|
|
@@ -285,7 +285,7 @@ EXAMPLES
|
|
|
285
285
|
$ sanity-run blueprints stacks --project-id <projectId>
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
288
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/blueprints/stacks.ts)_
|
|
289
289
|
|
|
290
290
|
## `sanity-run functions dev`
|
|
291
291
|
|
|
@@ -305,7 +305,7 @@ EXAMPLES
|
|
|
305
305
|
$ sanity-run functions dev --port 8974
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
308
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/dev.ts)_
|
|
309
309
|
|
|
310
310
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
311
311
|
|
|
@@ -327,7 +327,7 @@ EXAMPLES
|
|
|
327
327
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
328
328
|
```
|
|
329
329
|
|
|
330
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
330
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/env/add.ts)_
|
|
331
331
|
|
|
332
332
|
## `sanity-run functions env list NAME`
|
|
333
333
|
|
|
@@ -347,7 +347,7 @@ EXAMPLES
|
|
|
347
347
|
$ sanity-run functions env list MyFunction
|
|
348
348
|
```
|
|
349
349
|
|
|
350
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
350
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/env/list.ts)_
|
|
351
351
|
|
|
352
352
|
## `sanity-run functions env remove NAME KEY`
|
|
353
353
|
|
|
@@ -368,7 +368,7 @@ EXAMPLES
|
|
|
368
368
|
$ sanity-run functions env remove MyFunction API_URL
|
|
369
369
|
```
|
|
370
370
|
|
|
371
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
371
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/env/remove.ts)_
|
|
372
372
|
|
|
373
373
|
## `sanity-run functions logs NAME`
|
|
374
374
|
|
|
@@ -402,7 +402,7 @@ EXAMPLES
|
|
|
402
402
|
$ sanity-run functions logs <name> --delete
|
|
403
403
|
```
|
|
404
404
|
|
|
405
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
405
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/logs.ts)_
|
|
406
406
|
|
|
407
407
|
## `sanity-run functions test NAME`
|
|
408
408
|
|
|
@@ -411,7 +411,7 @@ Invoke a local Sanity Function
|
|
|
411
411
|
```
|
|
412
412
|
USAGE
|
|
413
413
|
$ sanity-run functions test NAME [-d <value>] [-f <value>] [-t <value>] [-a <value>] [--dataset <value>]
|
|
414
|
-
[--project-id <value>]
|
|
414
|
+
[--project-id <value>] [--with-user-token]
|
|
415
415
|
|
|
416
416
|
ARGUMENTS
|
|
417
417
|
NAME The name of the Sanity Function
|
|
@@ -423,6 +423,7 @@ FLAGS
|
|
|
423
423
|
-t, --timeout=<value> Execution timeout value in seconds
|
|
424
424
|
--dataset=<value> The Sanity dataset to use
|
|
425
425
|
--project-id=<value> Sanity Project ID to use
|
|
426
|
+
--with-user-token Prime access token from CLI config
|
|
426
427
|
|
|
427
428
|
DESCRIPTION
|
|
428
429
|
Invoke a local Sanity Function
|
|
@@ -435,7 +436,7 @@ EXAMPLES
|
|
|
435
436
|
$ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
|
|
436
437
|
```
|
|
437
438
|
|
|
438
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.
|
|
439
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v9.1.2/src/commands/functions/test.ts)_
|
|
439
440
|
|
|
440
441
|
## `sanity-run help [COMMAND]`
|
|
441
442
|
|
|
@@ -12,6 +12,7 @@ export default class TestCommand extends BlueprintCommand<typeof TestCommand> {
|
|
|
12
12
|
api: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
13
|
dataset: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
14
|
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'with-user-token': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
16
|
};
|
|
16
17
|
run(): Promise<void>;
|
|
17
18
|
}
|
|
@@ -37,6 +37,10 @@ export default class TestCommand extends BlueprintCommand {
|
|
|
37
37
|
aliases: ['project', 'projectId'],
|
|
38
38
|
required: false,
|
|
39
39
|
}),
|
|
40
|
+
'with-user-token': Flags.boolean({
|
|
41
|
+
description: 'Prime access token from CLI config',
|
|
42
|
+
default: false,
|
|
43
|
+
}),
|
|
40
44
|
};
|
|
41
45
|
async run() {
|
|
42
46
|
const { success, error } = await functionTestCore({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { testAction } from '../../actions/functions/test.js';
|
|
2
|
+
import config from '../../config.js';
|
|
2
3
|
import buildPayload from '../../utils/build-payload.js';
|
|
3
4
|
import { findFunctionByName } from '../../utils/find-function.js';
|
|
4
5
|
export async function functionTestCore(options) {
|
|
5
6
|
const { blueprint, log, args, flags } = options;
|
|
6
7
|
const { name: fnName } = args;
|
|
7
|
-
const { data, file, timeout, api, dataset } = flags;
|
|
8
|
+
const { data, file, timeout, api, dataset, 'with-user-token': withUserToken } = flags;
|
|
8
9
|
let { 'project-id': projectId } = flags;
|
|
9
10
|
const { parsedBlueprint } = blueprint;
|
|
10
11
|
if (!projectId && blueprint?.projectId) {
|
|
@@ -23,6 +24,10 @@ export async function functionTestCore(options) {
|
|
|
23
24
|
projectId,
|
|
24
25
|
},
|
|
25
26
|
};
|
|
27
|
+
// If the user sets the flag to use the real token set it in our options
|
|
28
|
+
if (withUserToken) {
|
|
29
|
+
contextOptions.clientOptions.token = config.token || undefined;
|
|
30
|
+
}
|
|
26
31
|
const { json, logs, error } = await testAction(resource, invokeOptions, contextOptions);
|
|
27
32
|
if (error) {
|
|
28
33
|
return {
|
package/dist/server/app.js
CHANGED
|
@@ -34,6 +34,14 @@ const app = (port) => {
|
|
|
34
34
|
try {
|
|
35
35
|
const { data, func: functionName } = parseInvokeRequest(Buffer.concat(body));
|
|
36
36
|
const { context, event } = data;
|
|
37
|
+
// replace user token if required
|
|
38
|
+
if (context.clientOptions.token) {
|
|
39
|
+
context.clientOptions.token = config.token || undefined;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// biome-ignore lint/performance/noDelete:
|
|
43
|
+
delete context.clientOptions.token;
|
|
44
|
+
}
|
|
37
45
|
const start = performance.now();
|
|
38
46
|
const { parsedBlueprint } = await readLocalBlueprint();
|
|
39
47
|
const resource = findFunctionByName(parsedBlueprint, functionName);
|
|
@@ -9,8 +9,9 @@ const template = `
|
|
|
9
9
|
Console
|
|
10
10
|
</h3>
|
|
11
11
|
<div style="background: var(--base-background-color); display: flex; justify-content: flex-end; align-items: center; padding: var(--space-0); padding-block-end: var(--space-2)">
|
|
12
|
-
<toggle-switch
|
|
13
|
-
|
|
12
|
+
<toggle-switch toggle-key="preserveLog">
|
|
13
|
+
<span class="slab-text" style="margin-left: var(--space-1);">Preserve Log</span>
|
|
14
|
+
</toggle-switch>
|
|
14
15
|
<clear-button></clear-button>
|
|
15
16
|
</div>
|
|
16
17
|
</div>
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
class FiltersComponent extends HTMLElement {
|
|
2
2
|
connectedCallback() {
|
|
3
3
|
this.innerHTML = `
|
|
4
|
-
<form style="gap: 8px;padding-left: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--card-border-color);">
|
|
5
|
-
<
|
|
6
|
-
|
|
4
|
+
<form style="gap: 8px; padding-left: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--card-border-color);">
|
|
5
|
+
<fieldset style="display: flex; gap: var(--space-2);">
|
|
6
|
+
<legend class="config-label">Client Options</legend>
|
|
7
|
+
<select-dropdown
|
|
8
|
+
label="Project"
|
|
9
|
+
store-key="projects"
|
|
10
|
+
selected-key="selectedProject"
|
|
11
|
+
value-prop="id"
|
|
12
|
+
label-prop="displayName"
|
|
13
|
+
trigger-fetch
|
|
14
|
+
></select-dropdown>
|
|
15
|
+
<select-dropdown
|
|
16
|
+
label="Dataset"
|
|
17
|
+
store-key="datasets"
|
|
18
|
+
selected-key="selectedDataset"
|
|
19
|
+
value-prop="name"
|
|
20
|
+
label-prop="name"
|
|
21
|
+
subscribe-to="selectedProject"
|
|
22
|
+
></select-dropdown>
|
|
7
23
|
<fieldset class="mar-t-sm">
|
|
8
|
-
<label class="
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<input name="apiVersion" id="apiversion" style="background: transparent; border-color: light-dark(var(--gray-200), var(--gray-700))">
|
|
24
|
+
<label class="slab-text">
|
|
25
|
+
<span style="display: block; margin-bottom: var(--space-1);">API Version</span>
|
|
26
|
+
<input name="apiVersion" id="apiversion" style="background: transparent; border-color: light-dark(var(--gray-200), var(--gray-700)); height: 2.5rem;">
|
|
12
27
|
</label>
|
|
13
28
|
</fieldset>
|
|
14
|
-
|
|
29
|
+
|
|
30
|
+
<fieldset class="mar-t-sm" style="display: flex; flex-direction: column; margin-top: 12px !important;">
|
|
31
|
+
<span class="slab-text" style="display: block; margin-bottom: var(--space-1);">With Token</span>
|
|
32
|
+
<toggle-switch toggle-key="withToken" style="display: flex; height: 2.5rem;"></toggle-switch>
|
|
33
|
+
</fieldset>
|
|
15
34
|
|
|
16
35
|
</form>
|
|
17
36
|
`
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/* globals customElements */
|
|
2
|
+
import {ApiBaseElement} from './api-base.js'
|
|
3
|
+
|
|
4
|
+
const dropdownTemplate = ({label}) => `
|
|
5
|
+
<fieldset class="mar-t-sm">
|
|
6
|
+
<label class="slab-text">
|
|
7
|
+
<span style="display: block; margin-bottom: var(--space-1);">${label}</span>
|
|
8
|
+
<div data-ui="Select" style="position: relative; display: inline-block; width: 100%;">
|
|
9
|
+
<select
|
|
10
|
+
data-ui="Select"
|
|
11
|
+
style="
|
|
12
|
+
width: 100%;
|
|
13
|
+
appearance: none;
|
|
14
|
+
-webkit-appearance: none;
|
|
15
|
+
-moz-appearance: none;
|
|
16
|
+
background: transparent;
|
|
17
|
+
color: light-dark(var(--gray-950), var(--gray-300));
|
|
18
|
+
padding-right: 2rem;
|
|
19
|
+
border: 1px solid var(--gray-400);
|
|
20
|
+
border-radius: var(--radius-2);
|
|
21
|
+
height: var(--input-height, 2.5rem);
|
|
22
|
+
"
|
|
23
|
+
></select>
|
|
24
|
+
<div
|
|
25
|
+
data-as="div"
|
|
26
|
+
data-ui="Box"
|
|
27
|
+
style="
|
|
28
|
+
position: absolute;
|
|
29
|
+
top: 50%;
|
|
30
|
+
right: 0.4rem;
|
|
31
|
+
transform: translateY(-50%);
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
height: 100%;
|
|
36
|
+
"
|
|
37
|
+
>
|
|
38
|
+
<svg
|
|
39
|
+
data-sanity-icon="chevron-down"
|
|
40
|
+
width="1.5rem"
|
|
41
|
+
height="1.5rem"
|
|
42
|
+
viewBox="0 0 25 25"
|
|
43
|
+
fill="none"
|
|
44
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
+
>
|
|
46
|
+
<path
|
|
47
|
+
d="M17 10L12.5 14.5L8 10"
|
|
48
|
+
stroke="currentColor"
|
|
49
|
+
stroke-width="1.2"
|
|
50
|
+
stroke-linejoin="round"
|
|
51
|
+
></path>
|
|
52
|
+
</svg>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</label>
|
|
56
|
+
</fieldset>
|
|
57
|
+
`
|
|
58
|
+
|
|
59
|
+
class SelectDropdown extends ApiBaseElement {
|
|
60
|
+
connectedCallback() {
|
|
61
|
+
this.label = this.getAttribute('label') || 'Select'
|
|
62
|
+
this.storeKey = this.getAttribute('store-key')
|
|
63
|
+
this.selectedKey = this.getAttribute('selected-key')
|
|
64
|
+
this.valueProp = this.getAttribute('value-prop') || 'id'
|
|
65
|
+
this.labelProp = this.getAttribute('label-prop') || 'displayName'
|
|
66
|
+
this.subscribeTo = this.getAttribute('subscribe-to')
|
|
67
|
+
|
|
68
|
+
this.innerHTML = dropdownTemplate({label: this.label})
|
|
69
|
+
this.select = this.querySelector('select')
|
|
70
|
+
this.select.addEventListener('change', this.handleSelect)
|
|
71
|
+
|
|
72
|
+
this.api.subscribe(this.renderOptions, [this.storeKey])
|
|
73
|
+
|
|
74
|
+
if (this.hasAttribute('trigger-fetch')) {
|
|
75
|
+
// e.g. this.api.projects()
|
|
76
|
+
this.api[this.storeKey]?.()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (this.subscribeTo) {
|
|
80
|
+
this.api.subscribe(this.refreshOnChange, [this.subscribeTo])
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
disconnectedCallback() {
|
|
85
|
+
this.select.removeEventListener('change', this.handleSelect)
|
|
86
|
+
this.api.unsubscribe(this.renderOptions)
|
|
87
|
+
if (this.subscribeTo) {
|
|
88
|
+
this.api.unsubscribe(this.refreshOnChange)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
handleSelect = (event) => {
|
|
93
|
+
this.api.store[this.selectedKey] = event.target.value
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
renderOptions = () => {
|
|
97
|
+
const items = this.api.store?.[this.storeKey] || []
|
|
98
|
+
const selectedVal = this.api.store?.[this.selectedKey]
|
|
99
|
+
if (items.length === 0) {
|
|
100
|
+
this.select.innerHTML = `<option>No ${this.label}s found</option>`
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
this.select.innerHTML = items
|
|
104
|
+
.map((item) => {
|
|
105
|
+
const val = item[this.valueProp]
|
|
106
|
+
const label = item[this.labelProp] ?? val
|
|
107
|
+
const selected = selectedVal === val ? 'selected' : ''
|
|
108
|
+
return `<option value="${val}" ${selected}>${label}</option>`
|
|
109
|
+
})
|
|
110
|
+
.join('')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
refreshOnChange = () => {
|
|
114
|
+
this.api[this.storeKey]?.(this.api.store[this.subscribeTo])
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
customElements.define('select-dropdown', SelectDropdown)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export class ToggleSwitch extends ApiBaseElement {
|
|
2
2
|
static get observedAttributes(): string[];
|
|
3
3
|
connectedCallback(): void;
|
|
4
|
+
toggleKey: string | null | undefined;
|
|
4
5
|
disconnectedCallback(): void;
|
|
5
|
-
attributeChangedCallback(name: any
|
|
6
|
+
attributeChangedCallback(name: any): void;
|
|
6
7
|
set checked(value: boolean);
|
|
7
8
|
get checked(): boolean;
|
|
8
9
|
toggle: () => void;
|
|
@@ -4,38 +4,48 @@ import {ApiBaseElement} from './api-base.js'
|
|
|
4
4
|
const template = document.createElement('template')
|
|
5
5
|
template.innerHTML = `
|
|
6
6
|
<style>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
line-height: 1;
|
|
11
|
-
}
|
|
7
|
+
:host {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
}
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
text-align: left;
|
|
18
|
-
}
|
|
11
|
+
.switch-container {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
}
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
[part="track"] {
|
|
17
|
+
width: 1.5rem;
|
|
18
|
+
height: 0.75rem;
|
|
19
|
+
background-color: #dddddd;
|
|
20
|
+
text-align: left;
|
|
21
|
+
border-radius: 10px;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
position: relative;
|
|
24
|
+
}
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
[part="slider"] {
|
|
27
|
+
width: 50%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
background-color: #777777;
|
|
30
|
+
transition: all 256ms;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0;
|
|
33
|
+
left: 0;
|
|
34
|
+
border-radius: 10px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:host([checked]) [part="slider"] {
|
|
38
|
+
transform: translateX(100%);
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
30
41
|
|
|
31
|
-
:host([checked]) [part="slider"] {
|
|
32
|
-
transform: translateX(100%);
|
|
33
|
-
}
|
|
34
|
-
</style>
|
|
35
42
|
|
|
36
|
-
<
|
|
37
|
-
<span part="
|
|
38
|
-
|
|
43
|
+
<div class="switch-container">
|
|
44
|
+
<span part="track">
|
|
45
|
+
<span part="slider"></span>
|
|
46
|
+
</span>
|
|
47
|
+
<slot></slot>
|
|
48
|
+
</div>
|
|
39
49
|
`
|
|
40
50
|
|
|
41
51
|
export class ToggleSwitch extends ApiBaseElement {
|
|
@@ -51,6 +61,7 @@ export class ToggleSwitch extends ApiBaseElement {
|
|
|
51
61
|
connectedCallback() {
|
|
52
62
|
this.setAttribute('role', 'switch')
|
|
53
63
|
this.setAttribute('tabindex', '0')
|
|
64
|
+
this.toggleKey = this.getAttribute('toggle-key')
|
|
54
65
|
this.addEventListener('click', this.toggle)
|
|
55
66
|
}
|
|
56
67
|
|
|
@@ -58,7 +69,7 @@ export class ToggleSwitch extends ApiBaseElement {
|
|
|
58
69
|
this.removeEventListener('click', this.toggle)
|
|
59
70
|
}
|
|
60
71
|
|
|
61
|
-
attributeChangedCallback(name
|
|
72
|
+
attributeChangedCallback(name) {
|
|
62
73
|
if (name === 'checked') {
|
|
63
74
|
this.setAttribute('aria-checked', this.checked.toString())
|
|
64
75
|
}
|
|
@@ -73,7 +84,7 @@ export class ToggleSwitch extends ApiBaseElement {
|
|
|
73
84
|
|
|
74
85
|
toggle = () => {
|
|
75
86
|
this.checked = !this.checked
|
|
76
|
-
this.api.store.
|
|
87
|
+
this.api.store[this.toggleKey] = this.checked
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
|
|
@@ -46,8 +46,7 @@
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
<script src="./components/filters.js" type="module"></script>
|
|
49
|
-
<script src="./components/
|
|
50
|
-
<script src="./components/projects-dropdown.js" type="module"></script>
|
|
49
|
+
<script src="./components/select-dropdown.js" type="module"></script>
|
|
51
50
|
<script src="./components/function-list.js" type="module"></script>
|
|
52
51
|
<script src="./components/network-spinner.js" type="module"></script>
|
|
53
52
|
<script src="./components/payload-panel.js" type="module"></script>
|
package/dist/utils/types.d.ts
CHANGED
package/oclif.manifest.json
CHANGED
|
@@ -748,6 +748,12 @@
|
|
|
748
748
|
"hasDynamicHelp": false,
|
|
749
749
|
"multiple": false,
|
|
750
750
|
"type": "option"
|
|
751
|
+
},
|
|
752
|
+
"with-user-token": {
|
|
753
|
+
"description": "Prime access token from CLI config",
|
|
754
|
+
"name": "with-user-token",
|
|
755
|
+
"allowNo": false,
|
|
756
|
+
"type": "boolean"
|
|
751
757
|
}
|
|
752
758
|
},
|
|
753
759
|
"hasDynamicHelp": false,
|
|
@@ -871,5 +877,5 @@
|
|
|
871
877
|
]
|
|
872
878
|
}
|
|
873
879
|
},
|
|
874
|
-
"version": "9.1.
|
|
880
|
+
"version": "9.1.2"
|
|
875
881
|
}
|
package/package.json
CHANGED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/* globals customElements */
|
|
2
|
-
import {ApiBaseElement} from './api-base.js'
|
|
3
|
-
|
|
4
|
-
const template = `<fieldset class="mar-t-sm">
|
|
5
|
-
<label class="config-label">
|
|
6
|
-
<span>Dataset</span>
|
|
7
|
-
<select id="datasetname" style="background: transparent; color: light-dark(var(--gray-950), var(--gray-300));">
|
|
8
|
-
</select>
|
|
9
|
-
</label>
|
|
10
|
-
</fieldset>
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
class DatasetDropdown extends ApiBaseElement {
|
|
14
|
-
datasetSelected = (event) => {
|
|
15
|
-
this.api.store.selectedDataset = event.srcElement.value
|
|
16
|
-
}
|
|
17
|
-
renderDatasets = () => {
|
|
18
|
-
if (this.api.store?.datasets?.length > 0) {
|
|
19
|
-
this.select.innerHTML = this.api.store.datasets
|
|
20
|
-
.map((dataset) => {
|
|
21
|
-
const selected = this.api.store.selectedDataset === dataset.name ? 'selected' : ''
|
|
22
|
-
return `<option value="${dataset.name}" ${selected}>${dataset.name}</option>`
|
|
23
|
-
})
|
|
24
|
-
.join('')
|
|
25
|
-
} else {
|
|
26
|
-
this.select.innerHTML = '<option>No Datasets found</option>'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
queryDatasets = () => {
|
|
30
|
-
this.api.datasets(this.api.store.selectedProject)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
connectedCallback() {
|
|
34
|
-
this.innerHTML = template
|
|
35
|
-
this.select = this.querySelector('select')
|
|
36
|
-
this.select.addEventListener('change', this.datasetSelected)
|
|
37
|
-
this.api.subscribe(this.renderDatasets, ['datasets'])
|
|
38
|
-
this.api.subscribe(this.queryDatasets, ['selectedProject'])
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
disconnectedCallback() {
|
|
42
|
-
this.select.removeEventListener('change', this.datasetSelected)
|
|
43
|
-
this.api.unsubscribe(this.renderProjects)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
customElements.define('dataset-dropdown', DatasetDropdown)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* globals customElements */
|
|
2
|
-
import {ApiBaseElement} from './api-base.js'
|
|
3
|
-
|
|
4
|
-
const template = `<fieldset class="mar-t-sm">
|
|
5
|
-
<label class='config-label'>
|
|
6
|
-
<span>Project</span>
|
|
7
|
-
<select id="project" style="background: transparent; color: light-dark(var(--gray-950), var(--gray-300));">
|
|
8
|
-
</select>
|
|
9
|
-
</label>
|
|
10
|
-
</fieldset>
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
class ProjectsDropdown extends ApiBaseElement {
|
|
14
|
-
projectSelected = (event) => {
|
|
15
|
-
this.api.store.selectedProject = event.srcElement.value
|
|
16
|
-
}
|
|
17
|
-
renderProjects = () => {
|
|
18
|
-
if (this.api.store.projects.length > 0) {
|
|
19
|
-
this.select.innerHTML = this.api.store.projects
|
|
20
|
-
.map((proj) => {
|
|
21
|
-
const selected = this.api.store.selectedProject === proj.id ? 'selected' : ''
|
|
22
|
-
return `<option value="${proj.id}" ${selected}>${proj.displayName}</option>`
|
|
23
|
-
})
|
|
24
|
-
.join('')
|
|
25
|
-
} else {
|
|
26
|
-
this.select.innerHTML = '<option>No Projects found</option>'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
connectedCallback() {
|
|
31
|
-
this.innerHTML = template
|
|
32
|
-
this.select = this.querySelector('select')
|
|
33
|
-
this.select.addEventListener('change', this.projectSelected)
|
|
34
|
-
this.api.subscribe(this.renderProjects, ['projects'])
|
|
35
|
-
this.api.projects()
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
disconnectedCallback() {
|
|
39
|
-
this.select.removeEventListener('change', this.projectSelected)
|
|
40
|
-
this.api.unsubscribe(this.renderProjects)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
customElements.define('projects-dropdown', ProjectsDropdown)
|
|
File without changes
|