@antelopejs/dms 0.20.3 → 0.20.4

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 (180) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/implementations/dms-builder/engine/compose-page.js +3 -2
  3. package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
  4. package/dist/mcp/page-verify/index.d.ts +1 -0
  5. package/dist/mcp/page-verify/index.js +1 -0
  6. package/dist/mcp/page-verify/index.js.map +1 -1
  7. package/dist/mcp/page-verify/redact-report.d.ts +2 -0
  8. package/dist/mcp/page-verify/redact-report.js +120 -0
  9. package/dist/mcp/page-verify/redact-report.js.map +1 -0
  10. package/dist/mcp/page-verify/render.js +4 -1
  11. package/dist/mcp/page-verify/render.js.map +1 -1
  12. package/dist/mcp/redact.d.ts +87 -0
  13. package/dist/mcp/redact.js +139 -0
  14. package/dist/mcp/redact.js.map +1 -0
  15. package/dist/mcp/tools/builder-compose.js +11 -2
  16. package/dist/mcp/tools/builder-compose.js.map +1 -1
  17. package/dist/mcp/tools/builder-project.js +56 -23
  18. package/dist/mcp/tools/builder-project.js.map +1 -1
  19. package/dist/mcp/tools/builder-queries.js +41 -4
  20. package/dist/mcp/tools/builder-queries.js.map +1 -1
  21. package/dist/mcp/tools/builder-shared.d.ts +3 -1
  22. package/dist/mcp/tools/builder-shared.js +5 -0
  23. package/dist/mcp/tools/builder-shared.js.map +1 -1
  24. package/dist/mcp/tools/database.js +3 -2
  25. package/dist/mcp/tools/database.js.map +1 -1
  26. package/dist/mcp/tools/page-verify.js +3 -2
  27. package/dist/mcp/tools/page-verify.js.map +1 -1
  28. package/frontend-vue/eslint-globals.generated.mjs +259 -942
  29. package/frontend-vue/layers/dms-core/app/build/composables/api-error.ts +46 -23
  30. package/frontend-vue/layers/dms-core/app/build/composables/auth/usePermissionPreview.ts +34 -23
  31. package/frontend-vue/layers/dms-core/app/build/composables/user/preferencesCookie.ts +8 -2
  32. package/frontend-vue/layers/dms-core/app/build/composables/user/tablePreferences.ts +11 -5
  33. package/frontend-vue/layers/dms-core/app/build/utils/crossTab.ts +4 -2
  34. package/frontend-vue/layers/dms-core/app/build/utils/json.ts +31 -0
  35. package/frontend-vue/layers/dms-core/app/build/utils/permission-preview.ts +6 -11
  36. package/frontend-vue/layers/dms-core/app/build/utils/record.ts +4 -0
  37. package/frontend-vue/layers/dms-core/app/build/utils/sharedRealtimeConnection.ts +56 -36
  38. package/frontend-vue/layers/dms-core/app/composables/auth/useApiData.ts +2 -2
  39. package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +6 -1
  40. package/frontend-vue/layers/dms-core/app/composables/auth/useCurrentUser.ts +3 -2
  41. package/frontend-vue/layers/dms-core/app/composables/auth/useLogout.ts +3 -2
  42. package/frontend-vue/layers/dms-core/app/composables/auth/useMultiAccount.ts +15 -14
  43. package/frontend-vue/layers/dms-core/app/composables/auth/useSessionRecovery.ts +21 -8
  44. package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +3 -3
  45. package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +11 -9
  46. package/frontend-vue/layers/dms-core/app/composables/period/periodLink.ts +3 -2
  47. package/frontend-vue/layers/dms-core/app/composables/period/usePeriod.ts +2 -2
  48. package/frontend-vue/layers/dms-core/app/composables/realtime/usePageRealtime.ts +10 -3
  49. package/frontend-vue/layers/dms-core/app/composables/realtime/useSseStream.ts +22 -16
  50. package/frontend-vue/layers/dms-core/app/composables/realtime/useUserRealtime.ts +68 -46
  51. package/frontend-vue/layers/dms-core/app/composables/useApiErrorPresenter.ts +22 -11
  52. package/frontend-vue/layers/dms-core/app/composables/useEventedAction.ts +4 -1
  53. package/frontend-vue/layers/dms-core/app/composables/useFieldErrors.ts +14 -6
  54. package/frontend-vue/layers/dms-core/app/composables/user/usePreferences.ts +8 -3
  55. package/frontend-vue/layers/dms-core/app/composables/watch/useWatch.ts +17 -8
  56. package/frontend-vue/layers/dms-core/app/types/module-store.ts +3 -1
  57. package/frontend-vue/layers/dms-core/app/types/page.ts +3 -1
  58. package/frontend-vue/layers/dms-core/app/utils/dedupedRefresh.ts +2 -2
  59. package/frontend-vue/layers/dms-core/app/utils/formatter.ts +5 -5
  60. package/frontend-vue/layers/dms-core/app/utils/menu.ts +12 -4
  61. package/frontend-vue/layers/dms-core/app/utils/pageQuery.ts +7 -4
  62. package/frontend-vue/layers/dms-core/app/utils/row-action-rule-evaluator.ts +7 -3
  63. package/frontend-vue/layers/dms-core/app/utils/stringTypeParser.ts +8 -10
  64. package/frontend-vue/layers/dms-core/app/utils/type-check.ts +25 -12
  65. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEditOverlay.vue +2 -2
  66. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupIndex.vue +1 -1
  67. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspector.vue +3 -2
  68. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspectorField.vue +5 -2
  69. package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +4 -3
  70. package/frontend-vue/layers/dms-ui/app/build/components/containers/modal/DynamicModal.vue +3 -2
  71. package/frontend-vue/layers/dms-ui/app/build/components/containers/row/RowHeader.vue +2 -1
  72. package/frontend-vue/layers/dms-ui/app/build/components/period/PeriodRangeCalendar.vue +10 -7
  73. package/frontend-vue/layers/dms-ui/app/build/components/sortable/SortableList.vue +2 -2
  74. package/frontend-vue/layers/dms-ui/app/build/components/table/FiltersRow.vue +20 -18
  75. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuColumns.vue +2 -5
  76. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuDensity.vue +3 -4
  77. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuFilter.vue +3 -4
  78. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuImport.vue +2 -5
  79. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuPage.vue +2 -5
  80. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuRoot.vue +3 -4
  81. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuSort.vue +2 -5
  82. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuViewMode.vue +21 -19
  83. package/frontend-vue/layers/dms-ui/app/build/components/table/RowSelection.vue +3 -4
  84. package/frontend-vue/layers/dms-ui/app/build/components/table/Table.types.ts +4 -4
  85. package/frontend-vue/layers/dms-ui/app/build/components/table/TableActions.vue +3 -4
  86. package/frontend-vue/layers/dms-ui/app/build/components/table/TableMenu.vue +3 -4
  87. package/frontend-vue/layers/dms-ui/app/build/components/table/TablePagination.vue +3 -4
  88. package/frontend-vue/layers/dms-ui/app/build/components/table/TableRoot.vue +3 -5
  89. package/frontend-vue/layers/dms-ui/app/build/components/table/TableTabs.vue +2 -5
  90. package/frontend-vue/layers/dms-ui/app/build/components/table/TableViews.vue +3 -4
  91. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentFilters.ts +4 -4
  92. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentPreferences.ts +4 -3
  93. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentRows.ts +4 -3
  94. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentTheme.ts +11 -0
  95. package/frontend-vue/layers/dms-ui/app/build/components/table-view/CardsDisplay.vue +35 -9
  96. package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +1 -1
  97. package/frontend-vue/layers/dms-ui/app/build/mockups/resync.ts +9 -1
  98. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +34 -25
  99. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +52 -26
  100. package/frontend-vue/layers/dms-ui/app/build/utils/calendarDay.ts +4 -1
  101. package/frontend-vue/layers/dms-ui/app/build/utils/characterCount.ts +1 -1
  102. package/frontend-vue/layers/dms-ui/app/build/utils/dispatchQuickActionTarget.ts +16 -11
  103. package/frontend-vue/layers/dms-ui/app/build/utils/fieldOptionsI18n.ts +23 -21
  104. package/frontend-vue/layers/dms-ui/app/build/utils/json.ts +74 -0
  105. package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +2 -2
  106. package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +4 -4
  107. package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +59 -50
  108. package/frontend-vue/layers/dms-ui/app/build/utils/mockupDrop.ts +1 -1
  109. package/frontend-vue/layers/dms-ui/app/build/utils/mockupEdit.ts +8 -6
  110. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +34 -28
  111. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStamp.ts +11 -3
  112. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +5 -2
  113. package/frontend-vue/layers/dms-ui/app/build/utils/streamHighlight.ts +8 -6
  114. package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +2 -1
  115. package/frontend-vue/layers/dms-ui/app/components/RecursiveComponent.vue +3 -6
  116. package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +5 -4
  117. package/frontend-vue/layers/dms-ui/app/components/blocks/BannerBlock.vue +1 -2
  118. package/frontend-vue/layers/dms-ui/app/components/card/NavCard.vue +4 -1
  119. package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +62 -13
  120. package/frontend-vue/layers/dms-ui/app/components/chart/ChartBlock.vue +18 -6
  121. package/frontend-vue/layers/dms-ui/app/components/code-snippet/CodeSnippet.vue +9 -4
  122. package/frontend-vue/layers/dms-ui/app/components/confirm/ConfirmModal.vue +9 -6
  123. package/frontend-vue/layers/dms-ui/app/components/flow-canvas/FlowCanvas.vue +16 -18
  124. package/frontend-vue/layers/dms-ui/app/components/form/FormBlock.vue +4 -9
  125. package/frontend-vue/layers/dms-ui/app/components/form/LocalizedField.vue +2 -2
  126. package/frontend-vue/layers/dms-ui/app/components/form/components/InputAddress.vue +2 -2
  127. package/frontend-vue/layers/dms-ui/app/components/form/components/InputImage.vue +5 -8
  128. package/frontend-vue/layers/dms-ui/app/components/form/components/RichText.vue +3 -2
  129. package/frontend-vue/layers/dms-ui/app/components/master-detail/MasterDetail.vue +3 -1
  130. package/frontend-vue/layers/dms-ui/app/components/period/usePeriodSelectorInteraction.ts +9 -7
  131. package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanBoard.vue +11 -6
  132. package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanDisplay.vue +40 -3
  133. package/frontend-vue/layers/dms-ui/app/composables/chart/apexDatetimeBuckets.ts +9 -5
  134. package/frontend-vue/layers/dms-ui/app/composables/chart/events.ts +6 -3
  135. package/frontend-vue/layers/dms-ui/app/composables/chart/heatmapColors.ts +1 -1
  136. package/frontend-vue/layers/dms-ui/app/composables/chart/localizeSeries.ts +13 -2
  137. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +27 -4
  138. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.types.ts +3 -2
  139. package/frontend-vue/layers/dms-ui/app/composables/chart/useChartFetch.ts +3 -4
  140. package/frontend-vue/layers/dms-ui/app/composables/confirm/types.ts +5 -1
  141. package/frontend-vue/layers/dms-ui/app/composables/containers/openDynamicContainer.ts +6 -6
  142. package/frontend-vue/layers/dms-ui/app/composables/containers/types.ts +1 -1
  143. package/frontend-vue/layers/dms-ui/app/composables/containers/useDrawer.ts +8 -5
  144. package/frontend-vue/layers/dms-ui/app/composables/containers/useModal.ts +1 -1
  145. package/frontend-vue/layers/dms-ui/app/composables/form/types/props.ts +5 -2
  146. package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +80 -39
  147. package/frontend-vue/layers/dms-ui/app/composables/live/usePageLiveRefresh.ts +1 -1
  148. package/frontend-vue/layers/dms-ui/app/composables/resolveDmsComponent.ts +9 -2
  149. package/frontend-vue/layers/dms-ui/app/composables/tab/useTab.ts +2 -2
  150. package/frontend-vue/layers/dms-ui/app/composables/table-view/shortcuts/tableViewShiftA.ts +2 -2
  151. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/action-target.ts +2 -1
  152. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/column.ts +3 -1
  153. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/display.ts +6 -2
  154. package/frontend-vue/layers/dms-ui/app/composables/table-view/useTableViewExport.ts +6 -5
  155. package/frontend-vue/layers/dms-ui/app/composables/unsaved-changes/useUnsavedChanges.ts +1 -1
  156. package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +21 -9
  157. package/frontend-vue/layers/dms-ui/app/utils/blockRefresh.ts +8 -2
  158. package/frontend-vue/layers/dms-ui/app/utils/cascader.ts +18 -8
  159. package/frontend-vue/layers/dms-ui/app/utils/metadataRetry.ts +1 -1
  160. package/frontend-vue/package.json +2 -1
  161. package/frontend-vue/scripts/check-api-error-presentation.mjs +257 -117
  162. package/frontend-vue/scripts/check-autoimport-boundaries.mjs +143 -27
  163. package/frontend-vue/scripts/check-disable-blocks.mjs +26 -4
  164. package/frontend-vue/scripts/check-dms-components.mjs +152 -246
  165. package/frontend-vue/scripts/check-invariants.mjs +100 -42
  166. package/frontend-vue/scripts/check-page-invariants.mjs +103 -40
  167. package/frontend-vue/scripts/dms-components-dependencies.mjs +106 -13
  168. package/frontend-vue/scripts/dms-components-script.mjs +375 -0
  169. package/frontend-vue/scripts/eslint-test-quality.mjs +126 -0
  170. package/frontend-vue/scripts/jsconfig.json +10 -0
  171. package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +4 -2
  172. package/frontend-vue/scripts/probes/frontend-behavior.cjs +217 -47
  173. package/frontend-vue/scripts/probes/frontend-legacy.cjs +159 -8
  174. package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +89 -10
  175. package/frontend-vue/scripts/prove-comment-emit.mjs +33 -4
  176. package/frontend-vue/scripts/prove-component-registration.mjs +110 -24
  177. package/frontend-vue/scripts/test-autoimport-boundaries.mjs +37 -6
  178. package/frontend-vue/scripts/test-dms-components.mjs +51 -2
  179. package/package.json +1 -1
  180. package/frontend-vue/eslint-test-quality.mjs +0 -62
@@ -12,12 +12,19 @@ import {
12
12
  isBoolean,
13
13
  isNumber,
14
14
  } from "../../../../dms-core/app/utils/type-check";
15
+ import {
16
+ isJsonWritable,
17
+ isWritableObject,
18
+ type JsonObject,
19
+ type JsonWritable,
20
+ type JsonWritableObject,
21
+ } from "./json";
15
22
  export interface PreviewNode {
16
23
  /** Block registry type, e.g. `KpiCard`. Wins over `componentName`. */
17
24
  type?: string;
18
25
  /** Component a registered block type emits, e.g. `dms-kpi-card`. */
19
26
  componentName?: string;
20
- options?: Record<string, unknown>;
27
+ options?: JsonWritableObject;
21
28
  children?: PreviewChildNode[];
22
29
  }
23
30
 
@@ -47,7 +54,7 @@ export interface PreviewState {
47
54
  export interface PreviewBlockType {
48
55
  componentName: string;
49
56
  /** Options the factory sets whatever its caller passes. */
50
- fixedOptions?: Record<string, unknown>;
57
+ fixedOptions?: JsonObject;
51
58
  /** Takes a controller class: drawn only when built from a route instead. */
52
59
  needsController?: boolean;
53
60
  }
@@ -91,7 +98,7 @@ export interface PreviewIssue {
91
98
  export interface PreviewResolvedNode {
92
99
  id: string;
93
100
  componentName?: string;
94
- options: Record<string, unknown>;
101
+ options: JsonWritableObject;
95
102
  children: PreviewResolvedNode[];
96
103
  slot?: string;
97
104
  colSpan?: number;
@@ -119,41 +126,43 @@ function isOptionalString(value: Parameters<typeof isString>[0]): boolean {
119
126
  return value === undefined || isString(value);
120
127
  }
121
128
 
122
- function isPreviewNode(value: unknown): value is PreviewNode {
123
- if (!isRecord(value)) return false;
129
+ function isPreviewNode(
130
+ value: JsonWritable,
131
+ ): value is JsonWritableObject & PreviewNode {
132
+ if (!isWritableObject(value)) return false;
124
133
  if (!isOptionalString(value.type)) return false;
125
134
  if (!isOptionalString(value.componentName)) return false;
126
- if (value.options !== undefined && !isRecord(value.options)) return false;
135
+ if (value.options !== undefined && !isWritableObject(value.options))
136
+ return false;
127
137
  if (value.children === undefined) return true;
128
138
  return Array.isArray(value.children) && value.children.every(isPreviewNode);
129
139
  }
130
140
 
131
- /** Whether `value` is a node or a list of nodes. */
132
- export function isPreviewTree(value: unknown): value is PreviewTree {
141
+ function isTreeValue(value: JsonWritable): value is JsonWritable & PreviewTree {
133
142
  return Array.isArray(value)
134
143
  ? value.every(isPreviewNode)
135
144
  : isPreviewNode(value);
136
145
  }
137
146
 
138
- export function isPreviewTheme(value: unknown): value is PreviewTheme {
139
- return PREVIEW_THEMES.some((theme) => theme === value);
140
- }
141
-
142
- function isOptionalBoolean(value: Parameters<typeof isBoolean>[0]): boolean {
143
- return value === undefined || isBoolean(value);
147
+ /** Whether `value` is JSON, and a node or a list of nodes. */
148
+ export function isPreviewTree(value: unknown): value is PreviewTree {
149
+ return isJsonWritable(value) && isTreeValue(value);
144
150
  }
145
151
 
146
- function hasValidStateExtras(value: Record<string, unknown>): boolean {
147
- if (value.theme !== undefined && !isPreviewTheme(value.theme)) return false;
148
- if (!isOptionalString(value.locale)) return false;
149
- return (
150
- isOptionalBoolean(value.padding) && isOptionalBoolean(value.transparent)
151
- );
152
+ export function isPreviewTheme(value: unknown): value is PreviewTheme {
153
+ return PREVIEW_THEMES.some((theme) => theme === value);
152
154
  }
153
155
 
154
156
  function isPreviewState(value: unknown): value is PreviewState {
155
157
  return (
156
- isRecord(value) && isPreviewTree(value.tree) && hasValidStateExtras(value)
158
+ isJsonWritable(value) &&
159
+ isWritableObject(value) &&
160
+ value.tree !== undefined &&
161
+ isTreeValue(value.tree) &&
162
+ (value.theme === undefined || isPreviewTheme(value.theme)) &&
163
+ (value.locale === undefined || isString(value.locale)) &&
164
+ (value.padding === undefined || isBoolean(value.padding)) &&
165
+ (value.transparent === undefined || isBoolean(value.transparent))
157
166
  );
158
167
  }
159
168
 
@@ -291,7 +300,7 @@ function matchBlockType(
291
300
  * (`TableView.fromSource`): it reads `source.fetchUrl`, which a preview can
292
301
  * call like any other block's URL.
293
302
  */
294
- function readsRouteSource(options: Record<string, unknown>): boolean {
303
+ function readsRouteSource(options: JsonWritableObject): boolean {
295
304
  const source = options[ROUTE_SOURCE_OPTION];
296
305
  return isRecord(source) && isString(source.fetchUrl);
297
306
  }
@@ -303,7 +312,7 @@ function readsRouteSource(options: Record<string, unknown>): boolean {
303
312
  */
304
313
  function readsSerializedForm(
305
314
  blockType: PreviewBlockType,
306
- options: Record<string, unknown>,
315
+ options: JsonWritableObject,
307
316
  ): boolean {
308
317
  return (
309
318
  blockType.componentName === "dms-form-block" &&
@@ -316,7 +325,7 @@ function readsSerializedForm(
316
325
  function issueFor(
317
326
  node: PreviewNode,
318
327
  match: MatchedBlockType | undefined,
319
- options: Record<string, unknown>,
328
+ options: JsonWritableObject,
320
329
  ): PreviewIssue | undefined {
321
330
  if (!match) {
322
331
  return {
@@ -353,7 +362,7 @@ function clampSketchHeight(height: unknown): number {
353
362
  * default instead of refusing the sketch.
354
363
  */
355
364
  function parseSketch(
356
- options: Record<string, unknown> | undefined,
365
+ options: JsonWritableObject | undefined,
357
366
  ): PreviewSketch | undefined {
358
367
  if (!options || !isString(options.html)) return undefined;
359
368
  const sketch: PreviewSketch = {
@@ -168,6 +168,10 @@ function isRecord(
168
168
  return isObject(value) && value !== null && !Array.isArray(value);
169
169
  }
170
170
 
171
+ function isOptionalString(value: Parameters<typeof isString>[0]): boolean {
172
+ return value === undefined || isString(value);
173
+ }
174
+
171
175
  function isNavigationItem(value: unknown): value is PreviewNavigationItem {
172
176
  return (
173
177
  isRecord(value) &&
@@ -232,28 +236,43 @@ function parseBlockRects(value: unknown): PreviewBlockRect[] | undefined {
232
236
  return blocks.every((block) => block !== undefined) ? blocks : undefined;
233
237
  }
234
238
 
235
- function isOptionalString(value: Parameters<typeof isString>[0]): boolean {
236
- return value === undefined || isString(value);
239
+ function isRenderMessage(
240
+ value: Parameters<typeof isRecord>[0],
241
+ ): value is PreviewRenderMessage {
242
+ return (
243
+ isRecord(value) &&
244
+ value.channel === PREVIEW_CHANNEL &&
245
+ value.type === "render" &&
246
+ isPreviewTree(value.tree) &&
247
+ (value.theme === undefined || isPreviewTheme(value.theme)) &&
248
+ (value.locale === undefined || isString(value.locale)) &&
249
+ (value.transparent === undefined || isBoolean(value.transparent)) &&
250
+ (value.padding === undefined || isBoolean(value.padding)) &&
251
+ (value.navigation === undefined || isPreviewNavigation(value.navigation))
252
+ );
237
253
  }
238
254
 
239
- function isOptionalBoolean(value: Parameters<typeof isBoolean>[0]): boolean {
240
- return value === undefined || isBoolean(value);
255
+ function isThemeMessage(
256
+ value: Parameters<typeof isRecord>[0],
257
+ ): value is PreviewThemeMessage {
258
+ return (
259
+ isRecord(value) &&
260
+ value.channel === PREVIEW_CHANNEL &&
261
+ value.type === "theme" &&
262
+ isPreviewTheme(value.theme)
263
+ );
241
264
  }
242
265
 
243
- const INBOUND_VALIDATORS: Record<
244
- Extract<Parameters<typeof Object.hasOwn>[1], string>,
245
- (data: Record<string, unknown>) => boolean
246
- > = {
247
- render: (data) =>
248
- isPreviewTree(data.tree) &&
249
- (data.theme === undefined || isPreviewTheme(data.theme)) &&
250
- isOptionalString(data.locale) &&
251
- isOptionalBoolean(data.transparent) &&
252
- isOptionalBoolean(data.padding) &&
253
- (data.navigation === undefined || isPreviewNavigation(data.navigation)),
254
- theme: (data) => isPreviewTheme(data.theme),
255
- inspect: (data) => isBoolean(data.enabled),
256
- };
266
+ function isInspectMessage(
267
+ value: Parameters<typeof isRecord>[0],
268
+ ): value is PreviewInspectMessage {
269
+ return (
270
+ isRecord(value) &&
271
+ value.channel === PREVIEW_CHANNEL &&
272
+ value.type === "inspect" &&
273
+ isBoolean(value.enabled)
274
+ );
275
+ }
257
276
 
258
277
  /**
259
278
  * The preview message `data` is, or undefined for anything else posted to the
@@ -262,14 +281,9 @@ const INBOUND_VALIDATORS: Record<
262
281
  export function parsePreviewMessage(
263
282
  data: Parameters<typeof isRecord>[0],
264
283
  ): PreviewInboundMessage | undefined {
265
- if (!isRecord(data) || data.channel !== PREVIEW_CHANNEL) return undefined;
266
- const isKnownType =
267
- isString(data.type) && Object.hasOwn(INBOUND_VALIDATORS, data.type);
268
- const validate = isKnownType
269
- ? INBOUND_VALIDATORS[data.type as string]
284
+ return isRenderMessage(data) || isThemeMessage(data) || isInspectMessage(data)
285
+ ? data
270
286
  : undefined;
271
- if (!validate?.(data)) return undefined;
272
- return data as PreviewInboundMessage & typeof data;
273
287
  }
274
288
 
275
289
  export function previewReadyMessage(): PreviewReadyMessage {
@@ -319,9 +333,21 @@ export function previewInspectMessage(enabled: boolean): PreviewInspectMessage {
319
333
  return { channel: PREVIEW_CHANNEL, type: "inspect", enabled };
320
334
  }
321
335
 
336
+ /** The fields of a posted message the outbound parsers read, unchecked. */
337
+ interface PostedFields {
338
+ height?: unknown;
339
+ message?: unknown;
340
+ path?: unknown;
341
+ blocks?: unknown;
342
+ text?: unknown;
343
+ rect?: unknown;
344
+ font?: unknown;
345
+ id?: unknown;
346
+ }
347
+
322
348
  const OUTBOUND_PARSERS: Record<
323
349
  Extract<Parameters<typeof Object.hasOwn>[1], string>,
324
- (data: Record<string, unknown>) => PreviewOutboundMessage | undefined
350
+ (data: PostedFields) => PreviewOutboundMessage | undefined
325
351
  > = {
326
352
  ready: () => previewReadyMessage(),
327
353
  resize: ({ height }) =>
@@ -4,12 +4,15 @@ import {
4
4
  ZonedDateTime,
5
5
  toCalendarDate,
6
6
  } from "@internationalized/date";
7
+ import type { isString } from "../../../../dms-core/app/utils/type-check";
7
8
 
8
9
  /**
9
10
  * The day a calendar value falls on: a `CalendarDate` as it is, the date part
10
11
  * of a `CalendarDateTime` or `ZonedDateTime`, and nothing for any other value.
11
12
  */
12
- export function toCalendarDay(value: unknown): CalendarDate | undefined {
13
+ export function toCalendarDay(
14
+ value: Parameters<typeof isString>[0],
15
+ ): CalendarDate | undefined {
13
16
  if (value instanceof CalendarDate) return value;
14
17
  if (value instanceof CalendarDateTime || value instanceof ZonedDateTime) {
15
18
  return toCalendarDate(value);
@@ -8,6 +8,6 @@ export function characterCountText(
8
8
  value: Parameters<typeof isString>[0],
9
9
  maxLength?: number,
10
10
  ): string {
11
- const count = isString(value) ? [...value].length : 0;
11
+ const count = isString(value) ? Array.from(value).length : 0;
12
12
  return maxLength === undefined ? String(count) : `${count} / ${maxLength}`;
13
13
  }
@@ -6,20 +6,18 @@ import {
6
6
  QUICK_ACTION_QUERY_KEY,
7
7
  } from "../../types/quick-actions";
8
8
 
9
- type QuickActionTargetHandler = (
10
- target: QuickActionTarget,
11
- ) => ReturnType<typeof navigateDms> | void;
9
+ type QuickActionTargetHandler = (target: QuickActionTarget) => Promise<void>;
12
10
 
13
11
  const targetHandlers: Record<
14
12
  QuickActionTarget["type"],
15
13
  QuickActionTargetHandler
16
14
  > = {
17
- navigate: (target) => {
15
+ navigate: async (target) => {
18
16
  if (target.type !== "navigate") return;
19
17
  return navigateDms({ path: target.to, query: target.query });
20
18
  },
21
19
 
22
- openForm: (target) => {
20
+ openForm: async (target) => {
23
21
  if (target.type !== "openForm") return;
24
22
  return navigateDms({
25
23
  path: target.to,
@@ -29,7 +27,7 @@ const targetHandlers: Record<
29
27
  },
30
28
  });
31
29
  },
32
- button: (target) => {
30
+ button: async (target) => {
33
31
  if (target.type !== "button") return;
34
32
  return navigateDms({
35
33
  path: target.to,
@@ -40,7 +38,7 @@ const targetHandlers: Record<
40
38
  },
41
39
  });
42
40
  },
43
- event: (target) => {
41
+ event: async (target) => {
44
42
  if (target.type !== "event") return;
45
43
  if (typeof window === "undefined") return;
46
44
  window.dispatchEvent(
@@ -53,11 +51,17 @@ const targetHandlers: Record<
53
51
  * Runs the client-side behavior a quick action declares through its
54
52
  * discriminated `target`: `navigate`, `openForm` and `button` route to the
55
53
  * action's page, `event` dispatches a window `CustomEvent` in place for whoever
56
- * listens.
54
+ * listens. A navigation that fails is logged, not thrown.
55
+ *
56
+ * @returns Whether a handler took the target: false for a type none handles.
57
57
  */
58
- export function dispatchQuickActionTarget(target: QuickActionTarget): unknown {
58
+ export function dispatchQuickActionTarget(target: QuickActionTarget): boolean {
59
59
  const handler = targetHandlers[target.type];
60
- return handler?.(target);
60
+ if (!handler) return false;
61
+ handler(target).catch((error: unknown) => {
62
+ console.error("[dms] Quick action target failed:", error);
63
+ });
64
+ return true;
61
65
  }
62
66
 
63
67
  /**
@@ -70,5 +74,6 @@ export function findServedQuickAction(
70
74
  key: string,
71
75
  ): QuickActionInfo | undefined {
72
76
  if (!served) return undefined;
73
- return served[key] ?? Object.values(served).find((entry) => entry.id === key);
77
+ const direct = Object.hasOwn(served, key) ? served[key] : undefined;
78
+ return direct ?? Object.values(served).find((entry) => entry.id === key);
74
79
  }
@@ -1,5 +1,7 @@
1
+ import { isString } from "../../../../dms-core/app/utils/type-check";
2
+ import { type JsonWritableObject, isJsonWritableObject } from "./json";
3
+
1
4
  /** An input component, with the options its field declares. */
2
- import { isString, isObject } from "../../../../dms-core/app/utils/type-check";
3
5
  interface ComponentWithOptions {
4
6
  options?: object;
5
7
  }
@@ -10,7 +12,6 @@ interface FieldWithOptions {
10
12
  }
11
13
 
12
14
  type Translate = (key: string) => string;
13
- type Options = Record<string, unknown>;
14
15
 
15
16
  const TEXT_OPTIONS = [
16
17
  "placeholder",
@@ -24,19 +25,15 @@ const TEXT_OPTIONS = [
24
25
  const LIST_OPTIONS = ["items", "columns"] as const;
25
26
  const ENTRY_TEXTS = ["label", "description"] as const;
26
27
 
27
- const isText = (value: unknown): value is string => isString(value);
28
-
29
- const isOptions = (value: unknown): value is Options =>
30
- isObject(value) && value !== null && !Array.isArray(value);
31
-
32
28
  function translateTexts(
33
- source: Options,
29
+ source: JsonWritableObject,
34
30
  keys: readonly string[],
35
31
  processI18n: Translate,
36
- ) {
32
+ ): JsonWritableObject {
37
33
  const translated = { ...source };
38
34
  for (const key of keys) {
39
- if (isText(source[key])) translated[key] = processI18n(source[key]);
35
+ const text = Object.hasOwn(source, key) ? source[key] : undefined;
36
+ if (isString(text)) translated[key] = processI18n(text);
40
37
  }
41
38
  return translated;
42
39
  }
@@ -46,8 +43,11 @@ function translateTexts(
46
43
  * editor's value) has the options of that field's component translated too,
47
44
  * so a select inside a repeater shows its options in the reader's language.
48
45
  */
49
- function translateNestedField(entry: Options, processI18n: Translate) {
50
- if (!isOptions(entry.component)) return entry;
46
+ function translateNestedField(
47
+ entry: JsonWritableObject,
48
+ processI18n: Translate,
49
+ ): JsonWritableObject {
50
+ if (!isJsonWritableObject(entry.component)) return entry;
51
51
  return {
52
52
  ...entry,
53
53
  component: translateComponent(entry.component, processI18n),
@@ -58,21 +58,23 @@ function translateComponent<C extends ComponentWithOptions>(
58
58
  component: C,
59
59
  processI18n: Translate,
60
60
  ): C {
61
- const opts = component.options as Options | undefined;
62
- if (!opts) return component;
61
+ const opts = component.options;
62
+ if (!isJsonWritableObject(opts)) return component;
63
63
 
64
64
  const options = translateTexts(opts, TEXT_OPTIONS, processI18n);
65
65
  for (const key of LIST_OPTIONS) {
66
- const list = opts[key];
66
+ const list = Object.hasOwn(opts, key) ? opts[key] : undefined;
67
67
  if (!Array.isArray(list)) continue;
68
- options[key] = list.map((entry: Options) =>
69
- translateNestedField(
70
- translateTexts(entry, ENTRY_TEXTS, processI18n),
71
- processI18n,
72
- ),
68
+ options[key] = list.map((entry) =>
69
+ isJsonWritableObject(entry)
70
+ ? translateNestedField(
71
+ translateTexts(entry, ENTRY_TEXTS, processI18n),
72
+ processI18n,
73
+ )
74
+ : entry,
73
75
  );
74
76
  }
75
- if (isOptions(opts.value)) {
77
+ if (isJsonWritableObject(opts.value)) {
76
78
  options.value = translateNestedField(opts.value, processI18n);
77
79
  }
78
80
 
@@ -0,0 +1,74 @@
1
+ import type {
2
+ JsonPrimitive,
3
+ JsonValue,
4
+ } from "../../../../dms-core/app/types/json";
5
+
6
+ /** A JSON object, as a parsed response or a `spec.json` holds one. */
7
+ export type JsonObject = { [key: string]: JsonValue };
8
+
9
+ /** Whether `value` and every value it holds is JSON, walked without recursion so that no nesting depth `JSON.parse` accepts exhausts the stack. */
10
+ export function isJsonValue(value: unknown): value is JsonValue {
11
+ const pending: unknown[] = [value];
12
+ while (pending.length > 0) {
13
+ const next = pending.pop();
14
+ if (next === null || ["string", "number", "boolean"].includes(typeof next))
15
+ continue;
16
+ if (typeof next !== "object") return false;
17
+ for (const held of Array.isArray(next) ? next : Object.values(next))
18
+ pending.push(held);
19
+ }
20
+ return true;
21
+ }
22
+
23
+ /** Whether `value` is a JSON object: not `null`, not a list, and JSON all the way down. */
24
+ export function isJsonObject(value: unknown): value is JsonObject {
25
+ return (
26
+ typeof value === "object" &&
27
+ value !== null &&
28
+ !Array.isArray(value) &&
29
+ isJsonValue(value)
30
+ );
31
+ }
32
+
33
+ /** Whether a value already known to be JSON is an object: not `null`, not a list. */
34
+ export function isObjectValue(
35
+ value: JsonValue | undefined,
36
+ ): value is JsonObject {
37
+ return typeof value === "object" && value !== null && !Array.isArray(value);
38
+ }
39
+
40
+ /** A JSON object as code writes one: a field set to `undefined` is absent, as `JSON.stringify` leaves it out. */
41
+ export type JsonWritableObject = { [key: string]: JsonWritable | undefined };
42
+
43
+ /** A value `JSON.stringify` writes as the same JSON: JSON whose objects may hold `undefined` fields. */
44
+ export type JsonWritable = JsonPrimitive | JsonWritable[] | JsonWritableObject;
45
+
46
+ /** Whether `value` is {@link JsonWritable} all the way down, walked without recursion like {@link isJsonValue}. */
47
+ export function isJsonWritable(value: unknown): value is JsonWritable {
48
+ const pending: unknown[] = [value];
49
+ while (pending.length > 0) {
50
+ const next = pending.pop();
51
+ if (next === null || ["string", "number", "boolean"].includes(typeof next))
52
+ continue;
53
+ if (typeof next !== "object") return false;
54
+ const held = Array.isArray(next)
55
+ ? next
56
+ : Object.values(next).filter((field) => field !== undefined);
57
+ for (const entry of held) pending.push(entry);
58
+ }
59
+ return true;
60
+ }
61
+
62
+ /** Whether a value already known to be {@link JsonWritable} is an object: not `null`, not a list. */
63
+ export function isWritableObject(
64
+ value: JsonWritable | undefined,
65
+ ): value is JsonWritableObject {
66
+ return typeof value === "object" && value !== null && !Array.isArray(value);
67
+ }
68
+
69
+ /** Whether `value` is a {@link JsonWritableObject}: not `null`, not a list, and {@link JsonWritable} all the way down. */
70
+ export function isJsonWritableObject(
71
+ value: unknown,
72
+ ): value is JsonWritableObject {
73
+ return isJsonWritable(value) && isWritableObject(value);
74
+ }
@@ -51,10 +51,10 @@ export function buttonLinkProps(declared: string | undefined) {
51
51
  to,
52
52
  external: true,
53
53
  noRel: true,
54
- onClick: (event: MouseEvent) => {
54
+ onClick: async (event: MouseEvent) => {
55
55
  if (!isPlainClick(event)) return;
56
56
  event.preventDefault();
57
- void navigateDms(pathOnThisSite(to));
57
+ await navigateDms(pathOnThisSite(to));
58
58
  },
59
59
  };
60
60
  }
@@ -172,9 +172,9 @@ export function isMockupWidth(value: string | undefined): value is MockupWidth {
172
172
 
173
173
  /** The first value of a query parameter, `undefined` when it is absent or empty. */
174
174
  export function readQueryValue(
175
- value: Parameters<typeof isString>[0] | readonly unknown[],
175
+ value: string | null | undefined | readonly (string | null)[],
176
176
  ): string | undefined {
177
- const first = Array.isArray(value) ? value[0] : value;
177
+ const first = isString(value) ? value : value?.[0];
178
178
  return isString(first) && first !== "" ? first : undefined;
179
179
  }
180
180
 
@@ -311,7 +311,7 @@ function isBuiltPage(
311
311
 
312
312
  function isSummaryBase(
313
313
  value: Parameters<typeof isObject>[0],
314
- ): value is Record<string, unknown> & MockupSummaryBase {
314
+ ): value is MockupSummaryBase {
315
315
  return (
316
316
  isRecord(value) &&
317
317
  isString(value.name) &&
@@ -326,7 +326,7 @@ function isSummaryBase(
326
326
  function isSummary(
327
327
  value: Parameters<typeof isObject>[0],
328
328
  ): value is MockupSummary {
329
- if (!isSummaryBase(value)) return false;
329
+ if (!isRecord(value) || !isSummaryBase(value)) return false;
330
330
  if (value.status === "draft") return true;
331
331
  return (
332
332
  value.status === "built" &&