@sanity/runtime-cli 4.3.4 → 4.4.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 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/4.3.4 linux-x64 node-v22.14.0
23
+ @sanity/runtime-cli/4.4.0 linux-x64 node-v22.15.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -74,7 +74,7 @@ EXAMPLES
74
74
  $ sanity-run blueprints add function --name my-function --function-type document-publish
75
75
  ```
76
76
 
77
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/add.ts)_
77
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/add.ts)_
78
78
 
79
79
  ## `sanity-run blueprints config`
80
80
 
@@ -103,7 +103,7 @@ EXAMPLES
103
103
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
104
104
  ```
105
105
 
106
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/config.ts)_
106
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/config.ts)_
107
107
 
108
108
  ## `sanity-run blueprints deploy`
109
109
 
@@ -123,7 +123,7 @@ EXAMPLES
123
123
  $ sanity-run blueprints deploy
124
124
  ```
125
125
 
126
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/deploy.ts)_
126
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/deploy.ts)_
127
127
 
128
128
  ## `sanity-run blueprints destroy`
129
129
 
@@ -146,7 +146,7 @@ EXAMPLES
146
146
  $ sanity-run blueprints destroy --id ST-a1b2c3
147
147
  ```
148
148
 
149
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/destroy.ts)_
149
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/destroy.ts)_
150
150
 
151
151
  ## `sanity-run blueprints info`
152
152
 
@@ -168,7 +168,7 @@ EXAMPLES
168
168
  $ sanity-run blueprints info --id ST-a1b2c3
169
169
  ```
170
170
 
171
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/info.ts)_
171
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/info.ts)_
172
172
 
173
173
  ## `sanity-run blueprints init`
174
174
 
@@ -198,7 +198,7 @@ EXAMPLES
198
198
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId> --stack-name <stackName>
199
199
  ```
200
200
 
201
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/init.ts)_
201
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/init.ts)_
202
202
 
203
203
  ## `sanity-run blueprints logs`
204
204
 
@@ -220,7 +220,7 @@ EXAMPLES
220
220
  $ sanity-run blueprints logs --watch
221
221
  ```
222
222
 
223
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/logs.ts)_
223
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/logs.ts)_
224
224
 
225
225
  ## `sanity-run blueprints plan`
226
226
 
@@ -237,7 +237,7 @@ EXAMPLES
237
237
  $ sanity-run blueprints plan
238
238
  ```
239
239
 
240
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/plan.ts)_
240
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/plan.ts)_
241
241
 
242
242
  ## `sanity-run blueprints stacks`
243
243
 
@@ -259,7 +259,7 @@ EXAMPLES
259
259
  $ sanity-run blueprints stacks --projectId a1b2c3
260
260
  ```
261
261
 
262
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/blueprints/stacks.ts)_
262
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/blueprints/stacks.ts)_
263
263
 
264
264
  ## `sanity-run functions dev`
265
265
 
@@ -279,7 +279,7 @@ EXAMPLES
279
279
  $ sanity-run functions dev --port 8974
280
280
  ```
281
281
 
282
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/functions/dev.ts)_
282
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/dev.ts)_
283
283
 
284
284
  ## `sanity-run functions env add NAME KEY VALUE`
285
285
 
@@ -301,7 +301,7 @@ EXAMPLES
301
301
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
302
302
  ```
303
303
 
304
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/functions/env/add.ts)_
304
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/env/add.ts)_
305
305
 
306
306
  ## `sanity-run functions env list NAME`
307
307
 
@@ -321,7 +321,7 @@ EXAMPLES
321
321
  $ sanity-run functions env list MyFunction
322
322
  ```
323
323
 
324
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/functions/env/list.ts)_
324
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/env/list.ts)_
325
325
 
326
326
  ## `sanity-run functions env remove NAME KEY`
327
327
 
@@ -342,7 +342,7 @@ EXAMPLES
342
342
  $ sanity-run functions env remove MyFunction API_URL
343
343
  ```
344
344
 
345
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/functions/env/remove.ts)_
345
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/env/remove.ts)_
346
346
 
347
347
  ## `sanity-run functions invoke NAME`
348
348
 
@@ -368,7 +368,7 @@ EXAMPLES
368
368
  $ sanity-run functions invoke <name> --file 'payload.json'
369
369
  ```
370
370
 
371
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.4/src/commands/functions/invoke.ts)_
371
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/invoke.ts)_
372
372
 
373
373
  ## `sanity-run functions logs NAME`
374
374
 
@@ -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/v4.3.4/src/commands/functions/logs.ts)_
403
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/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/v4.3.4/src/commands/functions/test.ts)_
436
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v4.4.0/src/commands/functions/test.ts)_
437
437
 
438
438
  ## `sanity-run help [COMMAND]`
439
439
 
@@ -1,4 +1,5 @@
1
1
  import { setTimeout } from 'node:timers/promises';
2
+ import { inspect } from 'node:util';
2
3
  import { Command, Flags } from '@oclif/core';
3
4
  import Spinner from 'yocto-spinner';
4
5
  import { stashAsset } from '../../actions/blueprints/assets.js';
@@ -24,9 +25,7 @@ export default class Deploy extends Command {
24
25
  const { errors, projectId, stackId, parsedBlueprint: { resources }, deployedStack, } = await readBlueprintOnDisk({ getStack: true, token });
25
26
  if (errors.length > 0) {
26
27
  // printErrors(errors) // TODO: error printer in formatting
27
- this.log('Blueprint parse errors:');
28
- console.dir(errors, { depth: null });
29
- return;
28
+ this.error(`Blueprint parse errors:\n${inspect(errors, { depth: null })}`);
30
29
  }
31
30
  if (!deployedStack || !stackId || !projectId) {
32
31
  this.error('Before deploying, run `sanity blueprints init`');
@@ -96,7 +95,7 @@ export default class Deploy extends Command {
96
95
  }
97
96
  else {
98
97
  this.debug('STACK ERROR RESPONSE:', stack);
99
- spinner.error(`${red('Failed')} to ${deployedStack ? 'update' : 'create'} stack`);
98
+ spinner.error(`${red('Failed')} to update stack`);
100
99
  this.log(`Error: ${deployError || JSON.stringify(stack, null, 2) || 'Unknown error'}`);
101
100
  }
102
101
  }
@@ -60,6 +60,8 @@
60
60
  -webkit-font-smoothing: antialiased;
61
61
  -moz-osx-font-smoothing: grayscale;
62
62
  font-family: var(--font-family-sans);
63
+
64
+ /* Gutter Gradient Variables */
63
65
  }
64
66
 
65
67
  /* ==========================================================================
@@ -651,12 +653,19 @@
651
653
 
652
654
  html {
653
655
  color-scheme: light dark;
656
+ min-height: 100dvh;
657
+ max-height: 100dvh;
658
+ height: 100%;
659
+ overflow: hidden;
654
660
  }
655
661
 
656
662
  body {
657
663
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Liberation Sans', Helvetica, Arial, system-ui, sans-serif;
658
664
  color: var(--text-color) !important;
659
- min-height: 100vh;
665
+ min-height: 100dvh;
666
+ max-height: 100dvh;
667
+ height: 100%;
668
+ overflow: hidden;
660
669
  display: grid;
661
670
  grid-template-areas:
662
671
  'header'
@@ -667,12 +676,6 @@ body {
667
676
  grid-template-rows: min-content min-content min-content 1fr;
668
677
  }
669
678
 
670
- body,
671
- html {
672
- height: 100%;
673
- overflow: hidden;
674
- }
675
-
676
679
  /* Utilities */
677
680
  .flex {
678
681
  display: flex;
@@ -768,21 +771,103 @@ body > nav {
768
771
  }
769
772
  body > main {
770
773
  grid-area: main;
774
+ /* Ensure main takes up available space if body is grid/flex */
775
+ overflow: hidden; /* Prevent main itself from scrolling */
776
+ min-height: 0; /* Needed for grid children height */
771
777
  }
772
778
 
773
- @media (min-width: 40rem) {
774
- body {
775
- grid-template:
776
- 'header header' min-content
777
- 'filters filters' min-content
778
- 'left-sidebar main ' 1fr
779
- / minmax(auto, 320px) minmax(var(--layout-min-content-width, 16rem), 1fr);
780
- }
779
+ /* Add styles for filters-component form */
780
+ /* Default (Mobile) Styles */
781
+ filters-component form {
782
+ display: block; /* Stack direct children */
783
+ padding: var(--space-3); /* Consistent padding */
784
+ border-bottom: 1px solid var(--card-border-color);
785
+ }
786
+
787
+ filters-component form > * {
788
+ /* Target direct children: dropdowns, fieldset */
789
+ display: block; /* Ensure they are block level */
790
+ width: 100%; /* Make them take full width */
791
+ margin-bottom: var(--space-3); /* Add space below each item when stacked */
792
+ }
793
+
794
+ filters-component form > *:last-child {
795
+ margin-bottom: 0; /* Remove margin from the last stacked item */
796
+ }
797
+
798
+ filters-component form label {
799
+ display: block; /* Ensure label stacks above input if needed */
800
+ margin-bottom: var(--space-1); /* Small space between label and input */
801
+ }
802
+
803
+ filters-component form input {
804
+ width: 100%; /* Make input fill its container */
805
+ box-sizing: border-box; /* Include padding/border in width calculation */
806
+ }
807
+ /* End of Mobile Styles */
808
+
809
+ /* Apply grid styles to main#main-content */
810
+ #main-content {
811
+ display: grid;
812
+ grid-template-areas:
813
+ 'payload response'
814
+ 'console console';
815
+ grid-template-columns: 1fr 1fr;
816
+ /* Let console height be flexible based on content, up to a max */
817
+ grid-template-rows: 1fr 1fr;
818
+ /* Ensure grid takes full height of its container (main) */
819
+ height: 100%;
820
+ max-height: 100%;
821
+ min-height: 0; /* Important for nested overflow/height */
822
+ }
823
+
824
+ payload-panel {
825
+ grid-area: payload;
826
+ max-height: 100%; /* Fit within allocated grid row space */
827
+ overflow: hidden; /* Let internal elements scroll */
828
+ min-height: 0; /* Allow shrinking */
829
+ }
830
+
831
+ response-panel {
832
+ grid-area: response;
833
+ max-height: 100%;
834
+ overflow: hidden;
835
+ min-height: 0;
836
+ }
837
+
838
+ /* Target console-panel for grid area and height constraints */
839
+ console-panel {
840
+ grid-area: console;
841
+ overflow: hidden; /* The inner div handles scrolling */
781
842
  }
782
843
 
783
844
  @media (max-width: 40rem) {
784
- button {
785
- width: 100%;
845
+ /* Mobile layout: stack elements vertically */
846
+ #main-content {
847
+ grid-template-areas:
848
+ 'payload'
849
+ 'response'
850
+ 'console';
851
+ grid-template-columns: 1fr;
852
+ /* Adjust row heights for mobile, maybe allow content to determine height */
853
+ grid-template-rows: auto auto auto;
854
+ height: auto; /* Allow main content to scroll if needed */
855
+ max-height: none;
856
+ overflow-y: auto; /* Allow scrolling for the whole main area */
857
+ }
858
+
859
+ /* Reset max-heights on mobile if they cause layout issues */
860
+ payload-panel,
861
+ response-panel,
862
+ console-panel {
863
+ max-height: none;
864
+ min-height: 200px; /* Give some minimum space on mobile */
865
+ overflow: auto; /* Allow individual scrolling if content is large */
866
+ }
867
+
868
+ /* Ensure console has reasonable height on mobile */
869
+ console-panel {
870
+ max-height: 400px; /* Allow more console height on mobile maybe */
786
871
  }
787
872
 
788
873
  .block-lg {
@@ -794,6 +879,40 @@ body > main {
794
879
  }
795
880
  }
796
881
 
882
+ @media (min-width: 40em) {
883
+ body {
884
+ grid-template:
885
+ 'header header' min-content
886
+ 'filters filters' min-content
887
+ 'left-sidebar main ' 1fr
888
+ / minmax(auto, 320px) 1fr;
889
+ }
890
+ .border-top-none-l {
891
+ border-top: 0;
892
+ }
893
+
894
+ /* Revert filters-component form to horizontal layout on larger screens */
895
+ filters-component form {
896
+ display: flex;
897
+ flex-direction: row;
898
+ align-items: flex-end; /* Align form elements along their bottom edge */
899
+ gap: var(--space-3); /* Space between elements */
900
+ padding-left: var(--space-3);
901
+ padding-bottom: var(--space-3);
902
+ }
903
+
904
+ filters-component form > * {
905
+ width: auto; /* Allow elements to size based on content/flex rules */
906
+ margin-bottom: 0; /* Remove stacking margin */
907
+ }
908
+
909
+ /* Optional: Give API version input a specific width or allow growth */
910
+ filters-component form fieldset {
911
+ min-width: 150px; /* Example minimum width */
912
+ /* flex-grow: 1; */ /* Uncomment to allow it to fill space */
913
+ }
914
+ }
915
+
797
916
  header {
798
917
  border-bottom: 1px solid var(--card-border-color);
799
918
  background: light-dark(white, var(--gray-950));
@@ -811,7 +930,7 @@ footer {
811
930
 
812
931
  .logo-image {
813
932
  height: 25px;
814
- width: auto;
933
+ width: 25px;
815
934
  }
816
935
 
817
936
  .logo-image img {
@@ -842,6 +961,7 @@ footer {
842
961
  line-height: 1;
843
962
  padding: 0px 12px !important;
844
963
  height: 24px !important;
964
+ max-width: 160px;
845
965
  }
846
966
 
847
967
  .sanity-button:hover {
@@ -930,7 +1050,19 @@ m-tabs {
930
1050
  }
931
1051
 
932
1052
  .gutter-gradient {
933
- background-image: linear-gradient(to right, light-dark(var(--gray-50), var(--gray-900)) 30px, light-dark(var(--gray-100), var(--gray-800)) 30.0001px, light-dark(var(--gray-100), var(--gray-800)) 31px, transparent 31px);
1053
+ --gutter-width: 30px;
1054
+ --gutter-border-width: 1px;
1055
+
1056
+ /* Light mode default gradient */
1057
+ background-image: linear-gradient(to right, var(--gray-50) var(--gutter-width), var(--gray-100) var(--gutter-width), var(--gray-100) calc(var(--gutter-width) + var(--gutter-border-width)), transparent calc(var(--gutter-width) + var(--gutter-border-width)));
1058
+ }
1059
+
1060
+ /* Apply dark mode gradient override */
1061
+ @media (prefers-color-scheme: dark) {
1062
+ .gutter-gradient {
1063
+ background-image: linear-gradient(to right, var(--gray-900) var(--gutter-width), var(--gray-800) var(--gutter-width), var(--gray-800) calc(var(--gutter-width) + var(--gutter-border-width)), transparent calc(var(--gutter-width) + var(--gutter-border-width)));
1064
+ }
1065
+ /* Add other dark-mode specific overrides here if needed */
934
1066
  }
935
1067
 
936
1068
  .bg {
@@ -960,6 +1092,42 @@ m-tabs {
960
1092
  background-color: light-dark(rgba(0, 0, 0, 0.025), rgba(255, 255, 255, 0.1)) !important;
961
1093
  }
962
1094
 
1095
+ .slab-stat {
1096
+ font-family: var(--font-family-mono);
1097
+ display: flex;
1098
+ align-items: center;
1099
+ gap: 0 8px;
1100
+ font-size: var(--font-size-text-2);
1101
+ margin: 0;
1102
+ padding: var(--space-3);
1103
+ }
1104
+
1105
+ .slab-stat dt {
1106
+ font-weight: 400;
1107
+ text-transform: none;
1108
+ margin: 0;
1109
+ padding: 0;
1110
+ }
1111
+
1112
+ .slab-stat dd {
1113
+ font-weight: 700;
1114
+ text-transform: none;
1115
+ margin: 0;
1116
+ padding: 0;
1117
+ }
1118
+
963
1119
  pre {
1120
+ color: var(--base-text-color) !important;
964
1121
  background-color: transparent !important;
965
1122
  }
1123
+
1124
+ time {
1125
+ font-family: var(--font-family-mono);
1126
+ }
1127
+
1128
+ response-panel,
1129
+ payload-panel {
1130
+ max-height: 100%;
1131
+ height: 100%;
1132
+ overflow: hidden;
1133
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ /* globals customElements document */
2
+ import {ApiBaseElement} from './api-base.js'
3
+
4
+ // Template for the console panel
5
+ const template = `
6
+ <div id="console-container" style='position: relative; background: var(--base-background-color); padding: var(--space-0) var(--space-3) var(--space-7) var(--space-4);overflow-y:scroll; border-top: 1px solid var(--card-border-color); height: 100%; max-height: 100%;'>
7
+ <h3 class="config-label" style="padding-top: var(--space-3); padding-bottom: var(--space-3); z-index: 32; background: var(--base-background-color); position: sticky; top: 0; left: 0; right: 0; margin-top:0;margin-bottom:0;">Console</h3>
8
+ <pre id="console-output" style="padding: 0; margin: 0 0 var(--space-4) 0; white-space: pre-wrap; word-wrap: break-word;"></pre>
9
+ </div>
10
+ `
11
+
12
+ class ConsolePanel extends ApiBaseElement {
13
+ updateConsole = ({result}) => {
14
+ // Guard against element not being ready or API not injected yet
15
+ if (!this.consoleOutput || !result) return
16
+
17
+ const {error, logs} = result
18
+ if (error) {
19
+ // Display error details in the console
20
+ this.consoleOutput.innerText = error?.details?.error ?? 'An error occurred.'
21
+ } else {
22
+ // Display regular logs
23
+ this.consoleOutput.innerText = logs ?? '' // Handle case where logs might be null/undefined
24
+ }
25
+ }
26
+
27
+ connectedCallback() {
28
+ this.innerHTML = template
29
+ this.consoleOutput = this.querySelector('#console-output')
30
+
31
+ // Subscribe to changes in the result state to update the console
32
+ if (this.api) {
33
+ this.api.subscribe(this.updateConsole, ['result'])
34
+ // Initial update in case result is already populated
35
+ if (this.api.store.result) {
36
+ this.updateConsole({result: this.api.store.result})
37
+ }
38
+ } else {
39
+ console.error('API context not available for console-panel on connect.')
40
+ // Optionally, set up a mechanism to wait for API initialization if needed
41
+ }
42
+ }
43
+
44
+ disconnectedCallback() {
45
+ // Unsubscribe when the element is removed from the DOM
46
+ if (this.api) {
47
+ this.api.unsubscribe(this.updateConsole)
48
+ }
49
+ }
50
+ }
51
+
52
+ // Define the new custom element
53
+ customElements.define('console-panel', ConsolePanel)
@@ -1,8 +1,9 @@
1
1
  class FiltersComponent extends HTMLElement {
2
2
  connectedCallback() {
3
3
  this.innerHTML = `
4
- <form style="display:flex; gap: 8px;padding-left: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--card-border-color);">
5
- <dataset-dropdown></dataset-dropdown>
4
+ <form style="gap: 8px;padding-left: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--card-border-color);">
5
+ <projects-dropdown></projects-dropdown>
6
+ <dataset-dropdown></dataset-dropdown>
6
7
  <fieldset class="mar-t-sm">
7
8
  <label class="config-label">
8
9
  <span>API Version</span>
@@ -10,7 +11,7 @@ class FiltersComponent extends HTMLElement {
10
11
  <input name="apiVersion" id="apiversion" style="background: transparent; border-color: light-dark(var(--gray-200), var(--gray-700))">
11
12
  </label>
12
13
  </fieldset>
13
- <projects-dropdown></projects-dropdown>
14
+
14
15
 
15
16
  </form>
16
17
  `
@@ -2,7 +2,7 @@
2
2
  import {ApiBaseElement} from './api-base.js'
3
3
 
4
4
  const template = `<ol class="hidden-lg" type="content" style="padding:0 16px;"></ol>
5
- <fieldset class="pad-sm hidden block-lg"><select></select></fieldset>
5
+ <fieldset class="hidden block-lg" style="padding:0 var(--space-3); margin-bottom: var(--space-3);"><select></select></fieldset>
6
6
  `
7
7
 
8
8
  class FunctionList extends ApiBaseElement {
@@ -2,13 +2,13 @@
2
2
  import {EditorView, basicSetup, json} from '../vendor/vendor.bundle.js'
3
3
  import {ApiBaseElement} from './api-base.js'
4
4
 
5
- const template = `<div class="gutter-gradient relative h-100 max-h-100 y-scroll">
5
+ const template = `<div class="gutter-gradient relative h-100 max-h-100 y-scroll border-top border-top-none-l">
6
6
  <div class="bg gutter-gradient sticky top-0 right-0 left-0 z-100">
7
7
  <div class="flex items-center space-between" style="padding: 8px 20px 8px 48px;">
8
8
  <h2 class="config-label mar-t-0 mar-b-0">Event</h2>
9
9
  <button ord="primary" class="sanity-button">
10
10
  <span>Run</span>
11
- <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>
11
+ <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>
12
12
  </button>
13
13
  </div>
14
14
  <hr class='hr-border' style='margin-left: 31px; ' />
@@ -35,7 +35,8 @@ class PayloadPanel extends ApiBaseElement {
35
35
  this.button.innerHTML = '<network-spinner></network-spinner>'
36
36
  } else {
37
37
  this.button.removeAttribute('disabled')
38
- this.button.innerText = 'Run'
38
+ this.button.innerHTML = `<span>Run</span>
39
+ <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>`
39
40
  }
40
41
  }
41
42
 
@@ -10,43 +10,31 @@ import {
10
10
  } from '../vendor/vendor.bundle.js'
11
11
  import {ApiBaseElement} from './api-base.js'
12
12
 
13
- const template = `<div class="gutter-gradient border-left h-100">
14
- <m-tabs id="response-tabs" role="tablist">
15
- <button class="tab" id="a" role="tab" aria-selected="true">Response</button>
16
- <button class="tab" id="b" role="tab">Console</button>
17
- </m-tabs>
18
- <hr class="hr-border" style="margin-left: 31px" />
19
- <div role="tabpanel" data-tab-id="a" class="h-100">
20
- <div>
21
- <span id="time"></span> <span id="size"></span>
13
+ const template = `<div class="border-left border-top border-top-none-l h-100 gutter-gradient" style='height: 100%; max-height: 100%; overflow: hidden; display:grid;grid-template-rows: auto 1fr; grid-template-columns: 1fr;' >
14
+ <!-- Response Section -->
15
+ <div style='overflow-y:scroll; min-height: 0;'>
16
+ <div style='padding-bottom: var(--space-6)'>
17
+ <h3 class="config-label" style='display: none; margin-top: 0;'>Response</h3>
18
+ <header class='flex space-between'>
19
+ <dl class='slab-stat'>
20
+ <dt style='white-space:nowrap;'>Response size</dt>
21
+ <dd id="size" style='white-space:nowrap;'></dd>
22
+ </dl>
23
+ <dl class='slab-stat'>
24
+ <dt>Time</dt>
25
+ <dd><time id="time" datetime=""></time></dd>
26
+ </dl>
27
+ </header>
28
+ <div id="response" name="response" class="cm-s-dracula"></div>
22
29
  </div>
23
- <div id="response" name="response"></div>
24
- </div>
25
- <div role="tabpanel" data-tab-id="b" class="pad-t-sm h-100" hidden><pre></pre></div>
30
+ </div>
26
31
  </div>
27
32
  `
28
33
  class ResponsePanel extends ApiBaseElement {
29
- switchTab = (e) => {
30
- const tabElement = e.target.closest('[role=tab]')
31
- // If the click wasn't on a tab button, do nothing
32
- if (!tabElement) {
33
- return
34
- }
35
- const selectedTabId = tabElement.id
36
-
37
- // Select the tab and its panel
38
- // Use e.currentTarget which refers to the element the listener was attached to (m-tabs)
39
- for (const tab of e.currentTarget.querySelectorAll('[role=tab]')) {
40
- tab.ariaSelected = tab.id === selectedTabId
41
- }
42
-
43
- // Find panels relative to the component itself to avoid affecting other potential tab panels on the page
44
- for (const panel of this.querySelectorAll('[role=tabpanel]')) {
45
- panel.hidden = panel.dataset.tabId !== selectedTabId
46
- }
47
- }
48
34
  updateResponse = ({result}) => {
49
- const {error, json, logs, time} = result
35
+ if (!result) return
36
+
37
+ const {error, json, time} = result
50
38
  if (!error) {
51
39
  const transaction = this.api.store.response.state.update({
52
40
  changes: {
@@ -59,9 +47,15 @@ class ResponsePanel extends ApiBaseElement {
59
47
 
60
48
  this.size.innerText = json ? prettyBytes(JSON.stringify(json).length) : ''
61
49
  this.time.innerText = prettyMilliseconds(time)
62
- this.consoleTab.innerText = logs
50
+ this.time.dateTime = `PT${time / 1000}S`
63
51
  } else {
64
- this.consoleTab.innerText = error?.details?.error
52
+ const transaction = this.api.store.response.state.update({
53
+ changes: {from: 0, to: this.api.store.response.state.doc.length, insert: ''},
54
+ })
55
+ this.api.store.response.dispatch(transaction)
56
+ this.size.innerText = ''
57
+ this.time.innerText = ''
58
+ this.time.removeAttribute('datetime')
65
59
  }
66
60
  }
67
61
 
@@ -70,10 +64,14 @@ class ResponsePanel extends ApiBaseElement {
70
64
  this.response = this.querySelector('#response')
71
65
  this.size = this.querySelector('#size')
72
66
  this.time = this.querySelector('#time')
73
- this.consoleTab = this.querySelector('pre')
74
- this.tabs = this.querySelector('m-tabs')
75
- this.tabs.addEventListener('click', this.switchTab)
76
- this.api.subscribe(this.updateResponse, ['result'])
67
+ if (this.api) {
68
+ this.api.subscribe(this.updateResponse, ['result'])
69
+ if (this.api.store.result) {
70
+ this.updateResponse({result: this.api.store.result})
71
+ }
72
+ } else {
73
+ console.error('API context not available for response-panel on connect.')
74
+ }
77
75
 
78
76
  this.api.store.response = new EditorView({
79
77
  doc: '\n\n\n\n',
@@ -83,8 +81,9 @@ class ResponsePanel extends ApiBaseElement {
83
81
  }
84
82
 
85
83
  disconnectedCallback() {
86
- this.tabs.removeEventListener('click', this.switchTab)
87
- this.api.unsubscribe(this.updateResponse)
84
+ if (this.api) {
85
+ this.api.unsubscribe(this.updateResponse)
86
+ }
88
87
  }
89
88
  }
90
89
 
@@ -1,9 +1,11 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
+ <title>Sanity Functions</title>
4
5
  <link href="https://unpkg.com/m-@3.2.0/dist/m-.woff2" rel="preload" as="font" crossorigin>
5
- <link href="./components/app.css" rel="stylesheet">
6
6
  <link href="https://unpkg.com/m-@3.2.0/dist/m-.css" rel="stylesheet">
7
+ <link href="./components/app.css" rel="stylesheet">
8
+
7
9
  </head>
8
10
  <body>
9
11
  <header data-slot="header">
@@ -16,12 +18,13 @@
16
18
  </header>
17
19
  <filters-component></filters-component>
18
20
  <nav style="padding-top: var(--size-5); border-right: 1px solid var(--card-border-color);max-height: 100%; overflow-y: scroll;">
19
- <h4 class="config-label mar-t-0" style="padding-left: 12px;">Functions</h4>
21
+ <h4 class="config-label mar-t-0" style="padding-left: var(--space-3); margin-bottom:var(--space-3);">Functions</h4>
20
22
  <function-list></function-list>
21
23
  </nav>
22
- <main style='display: grid; grid-template-columns: 1fr 1fr;grid-template-rows: 1fr;'>
24
+ <main id="main-content" style='max-height: 100%; overflow: hidden;'>
23
25
  <payload-panel></payload-panel>
24
26
  <response-panel></response-panel>
27
+ <console-panel></console-panel>
25
28
  </main>
26
29
 
27
30
 
@@ -32,5 +35,6 @@
32
35
  <script src="./components/network-spinner.js" type="module"></script>
33
36
  <script src="./components/payload-panel.js" type="module"></script>
34
37
  <script src="./components/response-panel.js" type="module"></script>
38
+ <script src="./components/console-panel.js" type="module"></script>
35
39
  </body>
36
40
  </html>
@@ -769,5 +769,5 @@
769
769
  ]
770
770
  }
771
771
  },
772
- "version": "4.3.4"
772
+ "version": "4.4.0"
773
773
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "Sanity's Runtime CLI for Blueprints and Functions",
4
- "version": "4.3.4",
4
+ "version": "4.4.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",