@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.
- package/CHANGELOG.md +21 -0
- package/dist/implementations/dms-builder/engine/compose-page.js +3 -2
- package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
- package/dist/mcp/page-verify/index.d.ts +1 -0
- package/dist/mcp/page-verify/index.js +1 -0
- package/dist/mcp/page-verify/index.js.map +1 -1
- package/dist/mcp/page-verify/redact-report.d.ts +2 -0
- package/dist/mcp/page-verify/redact-report.js +120 -0
- package/dist/mcp/page-verify/redact-report.js.map +1 -0
- package/dist/mcp/page-verify/render.js +4 -1
- package/dist/mcp/page-verify/render.js.map +1 -1
- package/dist/mcp/redact.d.ts +87 -0
- package/dist/mcp/redact.js +139 -0
- package/dist/mcp/redact.js.map +1 -0
- package/dist/mcp/tools/builder-compose.js +11 -2
- package/dist/mcp/tools/builder-compose.js.map +1 -1
- package/dist/mcp/tools/builder-project.js +56 -23
- package/dist/mcp/tools/builder-project.js.map +1 -1
- package/dist/mcp/tools/builder-queries.js +41 -4
- package/dist/mcp/tools/builder-queries.js.map +1 -1
- package/dist/mcp/tools/builder-shared.d.ts +3 -1
- package/dist/mcp/tools/builder-shared.js +5 -0
- package/dist/mcp/tools/builder-shared.js.map +1 -1
- package/dist/mcp/tools/database.js +3 -2
- package/dist/mcp/tools/database.js.map +1 -1
- package/dist/mcp/tools/page-verify.js +3 -2
- package/dist/mcp/tools/page-verify.js.map +1 -1
- package/frontend-vue/eslint-globals.generated.mjs +259 -942
- package/frontend-vue/layers/dms-core/app/build/composables/api-error.ts +46 -23
- package/frontend-vue/layers/dms-core/app/build/composables/auth/usePermissionPreview.ts +34 -23
- package/frontend-vue/layers/dms-core/app/build/composables/user/preferencesCookie.ts +8 -2
- package/frontend-vue/layers/dms-core/app/build/composables/user/tablePreferences.ts +11 -5
- package/frontend-vue/layers/dms-core/app/build/utils/crossTab.ts +4 -2
- package/frontend-vue/layers/dms-core/app/build/utils/json.ts +31 -0
- package/frontend-vue/layers/dms-core/app/build/utils/permission-preview.ts +6 -11
- package/frontend-vue/layers/dms-core/app/build/utils/record.ts +4 -0
- package/frontend-vue/layers/dms-core/app/build/utils/sharedRealtimeConnection.ts +56 -36
- package/frontend-vue/layers/dms-core/app/composables/auth/useApiData.ts +2 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +6 -1
- package/frontend-vue/layers/dms-core/app/composables/auth/useCurrentUser.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useLogout.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/auth/useMultiAccount.ts +15 -14
- package/frontend-vue/layers/dms-core/app/composables/auth/useSessionRecovery.ts +21 -8
- package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +3 -3
- package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +11 -9
- package/frontend-vue/layers/dms-core/app/composables/period/periodLink.ts +3 -2
- package/frontend-vue/layers/dms-core/app/composables/period/usePeriod.ts +2 -2
- package/frontend-vue/layers/dms-core/app/composables/realtime/usePageRealtime.ts +10 -3
- package/frontend-vue/layers/dms-core/app/composables/realtime/useSseStream.ts +22 -16
- package/frontend-vue/layers/dms-core/app/composables/realtime/useUserRealtime.ts +68 -46
- package/frontend-vue/layers/dms-core/app/composables/useApiErrorPresenter.ts +22 -11
- package/frontend-vue/layers/dms-core/app/composables/useEventedAction.ts +4 -1
- package/frontend-vue/layers/dms-core/app/composables/useFieldErrors.ts +14 -6
- package/frontend-vue/layers/dms-core/app/composables/user/usePreferences.ts +8 -3
- package/frontend-vue/layers/dms-core/app/composables/watch/useWatch.ts +17 -8
- package/frontend-vue/layers/dms-core/app/types/module-store.ts +3 -1
- package/frontend-vue/layers/dms-core/app/types/page.ts +3 -1
- package/frontend-vue/layers/dms-core/app/utils/dedupedRefresh.ts +2 -2
- package/frontend-vue/layers/dms-core/app/utils/formatter.ts +5 -5
- package/frontend-vue/layers/dms-core/app/utils/menu.ts +12 -4
- package/frontend-vue/layers/dms-core/app/utils/pageQuery.ts +7 -4
- package/frontend-vue/layers/dms-core/app/utils/row-action-rule-evaluator.ts +7 -3
- package/frontend-vue/layers/dms-core/app/utils/stringTypeParser.ts +8 -10
- package/frontend-vue/layers/dms-core/app/utils/type-check.ts +25 -12
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEditOverlay.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupIndex.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspector.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspectorField.vue +5 -2
- package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/containers/modal/DynamicModal.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/build/components/containers/row/RowHeader.vue +2 -1
- package/frontend-vue/layers/dms-ui/app/build/components/period/PeriodRangeCalendar.vue +10 -7
- package/frontend-vue/layers/dms-ui/app/build/components/sortable/SortableList.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/build/components/table/FiltersRow.vue +20 -18
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuColumns.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuDensity.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuFilter.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuImport.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuPage.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuRoot.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuSort.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/MenuViewMode.vue +21 -19
- package/frontend-vue/layers/dms-ui/app/build/components/table/RowSelection.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/Table.types.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableActions.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableMenu.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TablePagination.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableRoot.vue +3 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableTabs.vue +2 -5
- package/frontend-vue/layers/dms-ui/app/build/components/table/TableViews.vue +3 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentFilters.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentPreferences.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentRows.ts +4 -3
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentTheme.ts +11 -0
- package/frontend-vue/layers/dms-ui/app/build/components/table-view/CardsDisplay.vue +35 -9
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/mockups/resync.ts +9 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +34 -25
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +52 -26
- package/frontend-vue/layers/dms-ui/app/build/utils/calendarDay.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/characterCount.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/dispatchQuickActionTarget.ts +16 -11
- package/frontend-vue/layers/dms-ui/app/build/utils/fieldOptionsI18n.ts +23 -21
- package/frontend-vue/layers/dms-ui/app/build/utils/json.ts +74 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +59 -50
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupDrop.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupEdit.ts +8 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +34 -28
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStamp.ts +11 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/streamHighlight.ts +8 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/components/RecursiveComponent.vue +3 -6
- package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +5 -4
- package/frontend-vue/layers/dms-ui/app/components/blocks/BannerBlock.vue +1 -2
- package/frontend-vue/layers/dms-ui/app/components/card/NavCard.vue +4 -1
- package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +62 -13
- package/frontend-vue/layers/dms-ui/app/components/chart/ChartBlock.vue +18 -6
- package/frontend-vue/layers/dms-ui/app/components/code-snippet/CodeSnippet.vue +9 -4
- package/frontend-vue/layers/dms-ui/app/components/confirm/ConfirmModal.vue +9 -6
- package/frontend-vue/layers/dms-ui/app/components/flow-canvas/FlowCanvas.vue +16 -18
- package/frontend-vue/layers/dms-ui/app/components/form/FormBlock.vue +4 -9
- package/frontend-vue/layers/dms-ui/app/components/form/LocalizedField.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputAddress.vue +2 -2
- package/frontend-vue/layers/dms-ui/app/components/form/components/InputImage.vue +5 -8
- package/frontend-vue/layers/dms-ui/app/components/form/components/RichText.vue +3 -2
- package/frontend-vue/layers/dms-ui/app/components/master-detail/MasterDetail.vue +3 -1
- package/frontend-vue/layers/dms-ui/app/components/period/usePeriodSelectorInteraction.ts +9 -7
- package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanBoard.vue +11 -6
- package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanDisplay.vue +40 -3
- package/frontend-vue/layers/dms-ui/app/composables/chart/apexDatetimeBuckets.ts +9 -5
- package/frontend-vue/layers/dms-ui/app/composables/chart/events.ts +6 -3
- package/frontend-vue/layers/dms-ui/app/composables/chart/heatmapColors.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/chart/localizeSeries.ts +13 -2
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +27 -4
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.types.ts +3 -2
- package/frontend-vue/layers/dms-ui/app/composables/chart/useChartFetch.ts +3 -4
- package/frontend-vue/layers/dms-ui/app/composables/confirm/types.ts +5 -1
- package/frontend-vue/layers/dms-ui/app/composables/containers/openDynamicContainer.ts +6 -6
- package/frontend-vue/layers/dms-ui/app/composables/containers/types.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/containers/useDrawer.ts +8 -5
- package/frontend-vue/layers/dms-ui/app/composables/containers/useModal.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/form/types/props.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +80 -39
- package/frontend-vue/layers/dms-ui/app/composables/live/usePageLiveRefresh.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/resolveDmsComponent.ts +9 -2
- package/frontend-vue/layers/dms-ui/app/composables/tab/useTab.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/shortcuts/tableViewShiftA.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/action-target.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/column.ts +3 -1
- package/frontend-vue/layers/dms-ui/app/composables/table-view/types/display.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/useTableViewExport.ts +6 -5
- package/frontend-vue/layers/dms-ui/app/composables/unsaved-changes/useUnsavedChanges.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +21 -9
- package/frontend-vue/layers/dms-ui/app/utils/blockRefresh.ts +8 -2
- package/frontend-vue/layers/dms-ui/app/utils/cascader.ts +18 -8
- package/frontend-vue/layers/dms-ui/app/utils/metadataRetry.ts +1 -1
- package/frontend-vue/package.json +2 -1
- package/frontend-vue/scripts/check-api-error-presentation.mjs +257 -117
- package/frontend-vue/scripts/check-autoimport-boundaries.mjs +143 -27
- package/frontend-vue/scripts/check-disable-blocks.mjs +26 -4
- package/frontend-vue/scripts/check-dms-components.mjs +152 -246
- package/frontend-vue/scripts/check-invariants.mjs +100 -42
- package/frontend-vue/scripts/check-page-invariants.mjs +103 -40
- package/frontend-vue/scripts/dms-components-dependencies.mjs +106 -13
- package/frontend-vue/scripts/dms-components-script.mjs +375 -0
- package/frontend-vue/scripts/eslint-test-quality.mjs +126 -0
- package/frontend-vue/scripts/jsconfig.json +10 -0
- package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +4 -2
- package/frontend-vue/scripts/probes/frontend-behavior.cjs +217 -47
- package/frontend-vue/scripts/probes/frontend-legacy.cjs +159 -8
- package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +89 -10
- package/frontend-vue/scripts/prove-comment-emit.mjs +33 -4
- package/frontend-vue/scripts/prove-component-registration.mjs +110 -24
- package/frontend-vue/scripts/test-autoimport-boundaries.mjs +37 -6
- package/frontend-vue/scripts/test-dms-components.mjs +51 -2
- package/package.json +1 -1
- 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?:
|
|
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?:
|
|
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:
|
|
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(
|
|
123
|
-
|
|
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 && !
|
|
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
|
-
|
|
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
|
-
|
|
139
|
-
|
|
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
|
|
147
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
|
236
|
-
|
|
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
|
|
240
|
-
|
|
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
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
-
|
|
266
|
-
|
|
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:
|
|
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(
|
|
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) ?
|
|
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):
|
|
58
|
+
export function dispatchQuickActionTarget(target: QuickActionTarget): boolean {
|
|
59
59
|
const handler = targetHandlers[target.type];
|
|
60
|
-
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
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(
|
|
50
|
-
|
|
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
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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 (
|
|
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
|
-
|
|
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:
|
|
175
|
+
value: string | null | undefined | readonly (string | null)[],
|
|
176
176
|
): string | undefined {
|
|
177
|
-
const first =
|
|
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
|
|
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" &&
|