@sanity/runtime-cli 4.3.3 → 4.3.5-bundle.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.
Files changed (51) hide show
  1. package/README.md +17 -17
  2. package/dist/actions/blueprints/assets.d.ts +1 -0
  3. package/dist/actions/blueprints/assets.js +21 -4
  4. package/dist/actions/functions/test.d.ts +2 -2
  5. package/dist/actions/functions/test.js +2 -2
  6. package/dist/commands/blueprints/config.d.ts +1 -1
  7. package/dist/commands/blueprints/config.js +8 -8
  8. package/dist/commands/blueprints/deploy.js +3 -4
  9. package/dist/commands/blueprints/init.d.ts +1 -1
  10. package/dist/commands/blueprints/init.js +8 -8
  11. package/dist/commands/functions/logs.d.ts +1 -1
  12. package/dist/commands/functions/logs.js +8 -8
  13. package/dist/commands/functions/test.js +3 -6
  14. package/dist/server/app.js +80 -12
  15. package/dist/server/static/api.js +24 -3
  16. package/dist/server/static/components/app.css +915 -54
  17. package/dist/server/static/components/dataset-dropdown.js +5 -3
  18. package/dist/server/static/components/filters.d.ts +1 -0
  19. package/dist/server/static/components/filters.js +20 -0
  20. package/dist/server/static/components/function-list.js +7 -7
  21. package/dist/server/static/components/payload-panel.js +18 -17
  22. package/dist/server/static/components/projects-dropdown.js +5 -3
  23. package/dist/server/static/components/response-panel.js +38 -28
  24. package/dist/server/static/index.html +11 -30
  25. package/dist/server/static/vendor/vendor.bundle.d.ts +2 -2
  26. package/dist/utils/build-payload.d.ts +1 -1
  27. package/dist/utils/build-payload.js +3 -3
  28. package/dist/utils/bundle/bundle-function.d.ts +8 -0
  29. package/dist/utils/bundle/bundle-function.js +125 -0
  30. package/dist/utils/bundle/cleanup-source-maps.d.ts +10 -0
  31. package/dist/utils/bundle/cleanup-source-maps.js +53 -0
  32. package/dist/utils/bundle/find-up.d.ts +16 -0
  33. package/dist/utils/bundle/find-up.js +39 -0
  34. package/dist/utils/bundle/verify-handler.d.ts +2 -0
  35. package/dist/utils/bundle/verify-handler.js +13 -0
  36. package/dist/utils/child-process-wrapper.js +8 -6
  37. package/dist/utils/functions/find-entry-point.d.ts +11 -0
  38. package/dist/utils/functions/find-entry-point.js +75 -0
  39. package/dist/utils/functions/should-bundle.d.ts +2 -0
  40. package/dist/utils/functions/should-bundle.js +23 -0
  41. package/dist/utils/invoke-local.d.ts +2 -2
  42. package/dist/utils/invoke-local.js +48 -7
  43. package/dist/utils/is-record.d.ts +1 -0
  44. package/dist/utils/is-record.js +3 -0
  45. package/dist/utils/parse-json-object.d.ts +1 -0
  46. package/dist/utils/parse-json-object.js +10 -0
  47. package/dist/utils/types.d.ts +3 -1
  48. package/oclif.manifest.json +1 -1
  49. package/package.json +4 -1
  50. package/dist/utils/is-json.d.ts +0 -1
  51. package/dist/utils/is-json.js +0 -12
@@ -30,12 +30,15 @@ function invoke(payloadText = '{}') {
30
30
  },
31
31
  method: 'POST',
32
32
  })
33
- .then((response) => response.json())
34
- .then((data) => {
33
+ .then((response) => {
34
+ return response.json().then((data) => ({data, timings: getServerTimings(response)}))
35
+ })
36
+ .then(({data, timings}) => {
35
37
  store.inprogress = false
36
38
  store.result = {
37
39
  ...data,
38
40
  time: Date.now() - start,
41
+ timings,
39
42
  }
40
43
  })
41
44
  }
@@ -47,7 +50,7 @@ function blueprint() {
47
50
  const functions = blueprint?.resources.filter((r) => r.type.startsWith('sanity.function.'))
48
51
 
49
52
  store.functions = functions
50
- store.selectedIndex = functions[0].src
53
+ store.selectedIndex = functions[0].name
51
54
  })
52
55
  .catch(() => {
53
56
  store.functions = []
@@ -77,3 +80,21 @@ function datasets(selectedProject) {
77
80
  store.datasets = []
78
81
  })
79
82
  }
83
+
84
+ function getServerTimings(response) {
85
+ const timings = {}
86
+ const serverTiming = response.headers.get('Server-Timing')
87
+ if (!serverTiming) {
88
+ return timings
89
+ }
90
+
91
+ for (const entry of serverTiming.split(',')) {
92
+ const [name, ...params] = entry.split(';')
93
+ const durationParam = params.find((p) => p.startsWith('dur='))
94
+ if (durationParam) {
95
+ timings[name.trim()] = Number.parseFloat(durationParam.slice(4))
96
+ }
97
+ }
98
+
99
+ return timings
100
+ }