@antelopejs/dms 0.20.3 → 0.20.5
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 +33 -0
- package/README.md +1 -1
- 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/implementations/dms-builder/engine/database-access.d.ts +1 -16
- package/dist/implementations/dms-builder/engine/database-access.js +13 -44
- package/dist/implementations/dms-builder/engine/database-access.js.map +1 -1
- package/dist/implementations/dms-builder/engine/database-check.d.ts +1 -2
- package/dist/implementations/dms-builder/engine/database-check.js +28 -15
- package/dist/implementations/dms-builder/engine/database-check.js.map +1 -1
- package/dist/implementations/dms-builder/engine/driver-packages.d.ts +1 -0
- package/dist/implementations/dms-builder/engine/driver-packages.js +4 -0
- package/dist/implementations/dms-builder/engine/driver-packages.js.map +1 -1
- package/dist/implementations/dms-builder/engine/driver-probe.d.ts +27 -0
- package/dist/implementations/dms-builder/engine/driver-probe.js +53 -0
- package/dist/implementations/dms-builder/engine/driver-probe.js.map +1 -0
- package/dist/implementations/dms-builder/engine/index.d.ts +2 -6
- package/dist/implementations/dms-builder/engine/index.js +2 -6
- package/dist/implementations/dms-builder/engine/index.js.map +1 -1
- package/dist/implementations/dms-builder/engine/probe-answer.d.ts +4 -0
- package/dist/implementations/dms-builder/engine/probe-answer.js +90 -0
- package/dist/implementations/dms-builder/engine/probe-answer.js.map +1 -0
- package/dist/implementations/dms-builder/engine/probe-child.d.ts +1 -0
- package/dist/implementations/dms-builder/engine/probe-child.js +70 -0
- package/dist/implementations/dms-builder/engine/probe-child.js.map +1 -0
- package/dist/implementations/dms-builder/engine/probe-process.d.ts +2 -0
- package/dist/implementations/dms-builder/engine/probe-process.js +132 -0
- package/dist/implementations/dms-builder/engine/probe-process.js.map +1 -0
- package/dist/implementations/dms-builder/engine/probe-protocol.d.ts +46 -0
- package/dist/implementations/dms-builder/engine/probe-protocol.js +18 -0
- package/dist/implementations/dms-builder/engine/probe-protocol.js.map +1 -0
- 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/dist/mockup/fixtures.d.ts +1 -1
- package/dist/routes/system-state.d.ts +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 +5 -19
- package/dist/implementations/dms-builder/engine/access-mongodb.d.ts +0 -20
- package/dist/implementations/dms-builder/engine/access-mongodb.js +0 -30
- package/dist/implementations/dms-builder/engine/access-mongodb.js.map +0 -1
- package/dist/implementations/dms-builder/engine/access-mysql.d.ts +0 -8
- package/dist/implementations/dms-builder/engine/access-mysql.js +0 -11
- package/dist/implementations/dms-builder/engine/access-mysql.js.map +0 -1
- package/dist/implementations/dms-builder/engine/access-postgres.d.ts +0 -8
- package/dist/implementations/dms-builder/engine/access-postgres.js +0 -11
- package/dist/implementations/dms-builder/engine/access-postgres.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-client.d.ts +0 -19
- package/dist/implementations/dms-builder/engine/probe-client.js +0 -50
- package/dist/implementations/dms-builder/engine/probe-client.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-connections.d.ts +0 -10
- package/dist/implementations/dms-builder/engine/probe-connections.js +0 -43
- package/dist/implementations/dms-builder/engine/probe-connections.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-mongodb.d.ts +0 -2
- package/dist/implementations/dms-builder/engine/probe-mongodb.js +0 -148
- package/dist/implementations/dms-builder/engine/probe-mongodb.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-mysql.d.ts +0 -2
- package/dist/implementations/dms-builder/engine/probe-mysql.js +0 -189
- package/dist/implementations/dms-builder/engine/probe-mysql.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-postgres.d.ts +0 -2
- package/dist/implementations/dms-builder/engine/probe-postgres.js +0 -164
- package/dist/implementations/dms-builder/engine/probe-postgres.js.map +0 -1
- package/dist/implementations/dms-builder/engine/probe-rethinkdb.d.ts +0 -2
- package/dist/implementations/dms-builder/engine/probe-rethinkdb.js +0 -92
- package/dist/implementations/dms-builder/engine/probe-rethinkdb.js.map +0 -1
- package/dist/implementations/dms-builder/engine/rethinkdb-client.d.ts +0 -34
- package/dist/implementations/dms-builder/engine/rethinkdb-client.js +0 -3
- package/dist/implementations/dms-builder/engine/rethinkdb-client.js.map +0 -1
- package/dist/implementations/dms-builder/engine/scram-bound.d.ts +0 -5
- package/dist/implementations/dms-builder/engine/scram-bound.js +0 -60
- package/dist/implementations/dms-builder/engine/scram-bound.js.map +0 -1
- package/frontend-vue/eslint-test-quality.mjs +0 -62
|
@@ -10,31 +10,45 @@ import { assertDmsComponents } from "./check-dms-components.mjs";
|
|
|
10
10
|
import "./test-dms-components.mjs";
|
|
11
11
|
import "./check-autoimport-boundaries.mjs";
|
|
12
12
|
import "./test-autoimport-boundaries.mjs";
|
|
13
|
-
import "./check-page-invariants.mjs";
|
|
13
|
+
import { dig } from "./check-page-invariants.mjs";
|
|
14
14
|
import "../../../../checks/notification-tone-contract.mjs";
|
|
15
15
|
|
|
16
16
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
17
17
|
const LAYERS_DIR = join(ROOT, "layers");
|
|
18
18
|
|
|
19
|
+
const JsonObject = z.record(z.string(), z.unknown());
|
|
20
|
+
const NonBlankText = z.string().regex(/\S/);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} file
|
|
24
|
+
* @returns {unknown}
|
|
25
|
+
*/
|
|
26
|
+
function readJson(file) {
|
|
27
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
function checkCoreErrorFallback() {
|
|
20
31
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
21
|
-
const messages =
|
|
22
|
-
|
|
23
|
-
join(LAYERS_DIR, `dms-core/i18n/locales/core-${locale}.json`),
|
|
24
|
-
"utf8",
|
|
25
|
-
),
|
|
32
|
+
const messages = readJson(
|
|
33
|
+
join(LAYERS_DIR, `dms-core/i18n/locales/core-${locale}.json`),
|
|
26
34
|
);
|
|
27
35
|
assert.ok(
|
|
28
|
-
messages
|
|
36
|
+
NonBlankText.safeParse(dig(messages, ["error", "500", "description"]))
|
|
37
|
+
.success,
|
|
29
38
|
`${locale}: always load error.500.description`,
|
|
30
39
|
);
|
|
31
40
|
assert.ok(
|
|
32
|
-
messages
|
|
41
|
+
NonBlankText.safeParse(dig(messages, ["error", "read_only_demo"]))
|
|
42
|
+
.success,
|
|
33
43
|
`${locale}: translate error.read_only_demo`,
|
|
34
44
|
);
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {string} dir
|
|
50
|
+
* @returns {string[]}
|
|
51
|
+
*/
|
|
38
52
|
function collectSources(dir) {
|
|
39
53
|
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
40
54
|
const file = join(dir, entry.name);
|
|
@@ -102,14 +116,11 @@ function checkCompareModeLabels() {
|
|
|
102
116
|
);
|
|
103
117
|
const missing = [];
|
|
104
118
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
105
|
-
const messages =
|
|
106
|
-
|
|
107
|
-
join(LAYERS_DIR, `dms-ui/i18n/locales/ui-${locale}.json`),
|
|
108
|
-
"utf8",
|
|
109
|
-
),
|
|
119
|
+
const messages = readJson(
|
|
120
|
+
join(LAYERS_DIR, `dms-ui/i18n/locales/ui-${locale}.json`),
|
|
110
121
|
);
|
|
111
122
|
for (const mode of modes) {
|
|
112
|
-
if (!messages
|
|
123
|
+
if (!dig(messages, ["dms", "table", "compare_mode", mode]))
|
|
113
124
|
missing.push(`${locale}:${mode}`);
|
|
114
125
|
}
|
|
115
126
|
}
|
|
@@ -118,30 +129,55 @@ function checkCompareModeLabels() {
|
|
|
118
129
|
|
|
119
130
|
function checkFormErrorSummaryLabels() {
|
|
120
131
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
121
|
-
const messages =
|
|
122
|
-
|
|
123
|
-
join(LAYERS_DIR, `dms-ui/i18n/locales/ui-${locale}.json`),
|
|
124
|
-
"utf8",
|
|
125
|
-
),
|
|
132
|
+
const messages = readJson(
|
|
133
|
+
join(LAYERS_DIR, `dms-ui/i18n/locales/ui-${locale}.json`),
|
|
126
134
|
);
|
|
127
|
-
const resolved = messages
|
|
135
|
+
const resolved = dig(messages, [
|
|
136
|
+
"dms",
|
|
137
|
+
"form",
|
|
138
|
+
"error_summary",
|
|
139
|
+
"resolved",
|
|
140
|
+
]);
|
|
128
141
|
assert.ok(
|
|
129
|
-
|
|
142
|
+
NonBlankText.safeParse(resolved).success,
|
|
130
143
|
`${locale}: translate dms.form.error_summary.resolved`,
|
|
131
144
|
);
|
|
132
145
|
}
|
|
133
146
|
}
|
|
134
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @param {Record<string, unknown>} messages
|
|
150
|
+
* @param {string} [prefix]
|
|
151
|
+
* @returns {string[]}
|
|
152
|
+
*/
|
|
135
153
|
function messageKeys(messages, prefix = "") {
|
|
136
154
|
return Object.entries(messages).flatMap(([key, value]) => {
|
|
137
155
|
const path = prefix ? `${prefix}.${key}` : key;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
: [path];
|
|
156
|
+
const nested = JsonObject.safeParse(value);
|
|
157
|
+
return nested.success ? messageKeys(nested.data, path) : [path];
|
|
141
158
|
});
|
|
142
159
|
}
|
|
143
160
|
|
|
161
|
+
/**
|
|
162
|
+
* @param {string} layer
|
|
163
|
+
* @param {{ name: string; keys: Set<string> }[]} catalogs
|
|
164
|
+
* @returns {string[]}
|
|
165
|
+
*/
|
|
166
|
+
function catalogGaps(layer, catalogs) {
|
|
167
|
+
/** @type {string[]} */
|
|
168
|
+
const gaps = [];
|
|
169
|
+
for (const { name, keys } of catalogs) {
|
|
170
|
+
for (const other of catalogs) {
|
|
171
|
+
for (const key of other.keys) {
|
|
172
|
+
if (!keys.has(key)) gaps.push(`${layer}/${name}: ${key}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return gaps;
|
|
177
|
+
}
|
|
178
|
+
|
|
144
179
|
function checkLocaleKeyParity() {
|
|
180
|
+
/** @type {string[]} */
|
|
145
181
|
const gaps = [];
|
|
146
182
|
for (const layer of readdirSync(LAYERS_DIR)) {
|
|
147
183
|
const dir = join(LAYERS_DIR, layer, "i18n/locales");
|
|
@@ -150,32 +186,37 @@ function checkLocaleKeyParity() {
|
|
|
150
186
|
.filter((name) => name.endsWith(".json"))
|
|
151
187
|
.map((name) => ({
|
|
152
188
|
name,
|
|
153
|
-
keys: new Set(
|
|
154
|
-
messageKeys(JSON.parse(readFileSync(join(dir, name), "utf8"))),
|
|
155
|
-
),
|
|
189
|
+
keys: new Set(messageKeys(JsonObject.parse(readJson(join(dir, name))))),
|
|
156
190
|
}));
|
|
157
|
-
|
|
158
|
-
for (const other of catalogs) {
|
|
159
|
-
for (const key of other.keys) {
|
|
160
|
-
if (!keys.has(key)) gaps.push(`${layer}/${name}: ${key}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
191
|
+
gaps.push(...catalogGaps(layer, catalogs));
|
|
164
192
|
}
|
|
165
193
|
assert.deepEqual(gaps, [], "Translate every key in every locale of a layer");
|
|
166
194
|
}
|
|
167
195
|
|
|
196
|
+
/**
|
|
197
|
+
* @param {string} key
|
|
198
|
+
* @param {string} source
|
|
199
|
+
* @returns {string}
|
|
200
|
+
*/
|
|
168
201
|
function staticPrefix(key, source) {
|
|
169
|
-
const resolved = key.replace(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
202
|
+
const resolved = key.replace(
|
|
203
|
+
/\$\{(\w+)\}/g,
|
|
204
|
+
/**
|
|
205
|
+
* @param {string} interpolation
|
|
206
|
+
* @param {string} name
|
|
207
|
+
*/
|
|
208
|
+
(interpolation, name) => {
|
|
209
|
+
const declaration = source.match(
|
|
210
|
+
new RegExp(`\\bconst ${name} = ("[^"]*"|'[^']*'|\`[^\`$]*\`)`),
|
|
211
|
+
);
|
|
212
|
+
return declaration ? declaration[1].slice(1, -1) : interpolation;
|
|
213
|
+
},
|
|
214
|
+
);
|
|
175
215
|
return resolved.split("${")[0] ?? "";
|
|
176
216
|
}
|
|
177
217
|
|
|
178
218
|
function checkAsyncDataKeyOwners() {
|
|
219
|
+
/** @type {Map<string, Set<string>>} */
|
|
179
220
|
const owners = new Map();
|
|
180
221
|
for (const { file, source } of sources) {
|
|
181
222
|
for (const match of source.matchAll(
|
|
@@ -261,6 +302,11 @@ const WINDOWS_PLATFORM = 3;
|
|
|
261
302
|
const WINDOWS_UNICODE_BMP = 1;
|
|
262
303
|
const SEGMENT_MAPPING_FORMAT = 4;
|
|
263
304
|
|
|
305
|
+
/**
|
|
306
|
+
* @param {Buffer} data
|
|
307
|
+
* @param {{ at: number }} cursor
|
|
308
|
+
* @returns {number}
|
|
309
|
+
*/
|
|
264
310
|
function readBase128(data, cursor) {
|
|
265
311
|
let value = 0;
|
|
266
312
|
for (;;) {
|
|
@@ -271,6 +317,10 @@ function readBase128(data, cursor) {
|
|
|
271
317
|
}
|
|
272
318
|
}
|
|
273
319
|
|
|
320
|
+
/**
|
|
321
|
+
* @param {Buffer} file
|
|
322
|
+
* @returns {Buffer}
|
|
323
|
+
*/
|
|
274
324
|
function readCmap(file) {
|
|
275
325
|
const numTables = file.readUInt16BE(NUM_TABLES_OFFSET);
|
|
276
326
|
const cursor = { at: HEADER_SIZE };
|
|
@@ -300,6 +350,11 @@ function readCmap(file) {
|
|
|
300
350
|
throw new Error("no cmap table");
|
|
301
351
|
}
|
|
302
352
|
|
|
353
|
+
/**
|
|
354
|
+
* @param {Buffer} cmap
|
|
355
|
+
* @param {number} codePoint
|
|
356
|
+
* @returns {number}
|
|
357
|
+
*/
|
|
303
358
|
function glyphOf(cmap, codePoint) {
|
|
304
359
|
const count = cmap.readUInt16BE(2);
|
|
305
360
|
for (let index = 0; index < count; index++) {
|
|
@@ -356,7 +411,8 @@ function checkGeistNarrowSpace() {
|
|
|
356
411
|
}
|
|
357
412
|
}
|
|
358
413
|
|
|
359
|
-
|
|
414
|
+
/** @type {[string, () => unknown][]} */
|
|
415
|
+
const CHECKS = [
|
|
360
416
|
["API error presentation", () => assertApiErrorPresentation([LAYERS_DIR])],
|
|
361
417
|
[
|
|
362
418
|
"DMS components",
|
|
@@ -373,7 +429,9 @@ for (const [name, check] of [
|
|
|
373
429
|
["Geist narrow no-break spaces", checkGeistNarrowSpace],
|
|
374
430
|
["font asset URLs", checkFontAssetUrls],
|
|
375
431
|
["onboarding page meta", checkOnboardingPageMeta],
|
|
376
|
-
]
|
|
432
|
+
];
|
|
433
|
+
|
|
434
|
+
for (const [name, check] of CHECKS) {
|
|
377
435
|
try {
|
|
378
436
|
await check();
|
|
379
437
|
console.log(`PASS ${name}`);
|
|
@@ -3,11 +3,45 @@ import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
|
3
3
|
import { registerHooks } from "node:module";
|
|
4
4
|
import { dirname, join, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
|
|
7
8
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
9
|
const layers = join(root, "layers");
|
|
10
|
+
const JsonObject = z.record(z.string(), z.unknown());
|
|
11
|
+
const Text = z.string();
|
|
12
|
+
const ShortLabels = z.record(z.string(), z.string());
|
|
13
|
+
const Manifest = z.object({ dependencies: z.record(z.string(), z.unknown()) });
|
|
14
|
+
const ShortcutKeys = z.object({ key: z.array(z.string()) });
|
|
15
|
+
const SearchMetadata = ShortcutKeys.extend({
|
|
16
|
+
descriptionKey: z.string(),
|
|
17
|
+
condition: z.object({ descriptionKey: z.string() }),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} path
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
9
24
|
const read = (path) => readFileSync(join(layers, path), "utf8");
|
|
10
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @param {unknown} node
|
|
28
|
+
* @param {string[]} path
|
|
29
|
+
* @returns {unknown}
|
|
30
|
+
*/
|
|
31
|
+
export function dig(node, path) {
|
|
32
|
+
let current = node;
|
|
33
|
+
for (const key of path) {
|
|
34
|
+
const record = JsonObject.safeParse(current);
|
|
35
|
+
if (!record.success || !Object.hasOwn(record.data, key)) return undefined;
|
|
36
|
+
current = record.data[key];
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} dir
|
|
43
|
+
* @returns {string[]}
|
|
44
|
+
*/
|
|
11
45
|
function files(dir) {
|
|
12
46
|
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
13
47
|
const path = join(dir, entry.name);
|
|
@@ -75,11 +109,19 @@ function checkServerRouteOwnership() {
|
|
|
75
109
|
}
|
|
76
110
|
|
|
77
111
|
function checkSortableDependency() {
|
|
78
|
-
const manifest =
|
|
112
|
+
const manifest = Manifest.parse(
|
|
113
|
+
JSON.parse(readFileSync(join(root, "package.json"), "utf8")),
|
|
114
|
+
);
|
|
79
115
|
assert.ok(!Object.hasOwn(manifest.dependencies, "vuedraggable"));
|
|
80
116
|
assert.ok(Object.hasOwn(manifest.dependencies, "sortablejs"));
|
|
81
117
|
}
|
|
82
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @param {string} layer
|
|
121
|
+
* @param {string} prefix
|
|
122
|
+
* @param {string} locale
|
|
123
|
+
* @returns {unknown}
|
|
124
|
+
*/
|
|
83
125
|
function readLocale(layer, prefix, locale) {
|
|
84
126
|
return JSON.parse(read(`${layer}/i18n/locales/${prefix}-${locale}.json`));
|
|
85
127
|
}
|
|
@@ -99,7 +141,9 @@ function checkFormLoadErrorLabels() {
|
|
|
99
141
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
100
142
|
const messages = readLocale("dms-ui", "ui", locale);
|
|
101
143
|
assert.deepEqual(
|
|
102
|
-
Object.keys(
|
|
144
|
+
Object.keys(
|
|
145
|
+
JsonObject.parse(dig(messages, ["dms", "form", "load_error"])),
|
|
146
|
+
).sort(),
|
|
103
147
|
keys,
|
|
104
148
|
`${locale} form load error labels`,
|
|
105
149
|
);
|
|
@@ -124,66 +168,74 @@ async function checkShortcutTranslations() {
|
|
|
124
168
|
const { default: registry } = await import(
|
|
125
169
|
"../layers/dms-ui/app/config/shortcuts-registry.ts"
|
|
126
170
|
);
|
|
127
|
-
const
|
|
128
|
-
GLOBAL_SLASH_METADATA,
|
|
129
|
-
GLOBAL_META_SLASH_METADATA,
|
|
130
|
-
NAV_SEARCH_SHORTCUT,
|
|
131
|
-
PAGE_SEARCH_HINT_KEYS,
|
|
132
|
-
} = await import(
|
|
171
|
+
const searchShortcuts = await import(
|
|
133
172
|
"../layers/dms-ui/app/entries/composables/global/searchShortcuts"
|
|
134
173
|
);
|
|
135
|
-
|
|
174
|
+
const { NAV_SEARCH_SHORTCUT, PAGE_SEARCH_HINT_KEYS } = searchShortcuts;
|
|
175
|
+
/** @type {unknown[]} */
|
|
176
|
+
const registered = [
|
|
177
|
+
searchShortcuts.GLOBAL_SLASH_METADATA,
|
|
178
|
+
searchShortcuts.GLOBAL_META_SLASH_METADATA,
|
|
179
|
+
];
|
|
180
|
+
const search = registered.map((metadata) => SearchMetadata.parse(metadata));
|
|
181
|
+
const [slash, metaSlash] = search;
|
|
182
|
+
assert.deepEqual(slash?.key, [NAV_SEARCH_SHORTCUT]);
|
|
136
183
|
assert.deepEqual(
|
|
137
|
-
|
|
184
|
+
metaSlash?.key,
|
|
138
185
|
PAGE_SEARCH_HINT_KEYS.map((key) =>
|
|
139
186
|
key === "meta" ? "$keyboard.meta" : key,
|
|
140
187
|
),
|
|
141
188
|
"displayed search shortcut matches the input hint",
|
|
142
189
|
);
|
|
143
|
-
const search = [GLOBAL_SLASH_METADATA, GLOBAL_META_SLASH_METADATA];
|
|
144
190
|
const global = registry.find((group) => group.component === "Global");
|
|
145
|
-
for (const metadata of
|
|
191
|
+
for (const metadata of registered) {
|
|
146
192
|
assert.ok(
|
|
147
193
|
global?.shortcuts.includes(metadata),
|
|
148
194
|
"search shortcut registration",
|
|
149
195
|
);
|
|
150
196
|
}
|
|
197
|
+
/** @param {string[]} keys */
|
|
151
198
|
const signature = (keys) => keys.join("+").toLowerCase();
|
|
152
199
|
const keys = search.map((metadata) => signature(metadata.key));
|
|
153
200
|
const clashes = registry
|
|
154
|
-
.flatMap(
|
|
201
|
+
.flatMap(
|
|
202
|
+
/** @returns {unknown[]} */
|
|
203
|
+
(group) => group.shortcuts,
|
|
204
|
+
)
|
|
155
205
|
.filter(
|
|
156
206
|
(shortcut) =>
|
|
157
|
-
!
|
|
207
|
+
!registered.includes(shortcut) &&
|
|
208
|
+
keys.includes(signature(ShortcutKeys.parse(shortcut).key)),
|
|
158
209
|
);
|
|
159
210
|
assert.deepEqual(clashes, [], "search shortcut key conflicts");
|
|
160
211
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
161
212
|
const messages = readLocale("dms-ui", "ui", locale);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
.split(".")
|
|
166
|
-
.reduce((value, part) => value?.[part], messages);
|
|
167
|
-
for (const metadata of [
|
|
168
|
-
GLOBAL_SLASH_METADATA,
|
|
169
|
-
GLOBAL_META_SLASH_METADATA,
|
|
170
|
-
]) {
|
|
213
|
+
/** @param {string} key */
|
|
214
|
+
const lookup = (key) => dig(messages, key.slice(1).split("."));
|
|
215
|
+
for (const metadata of search) {
|
|
171
216
|
for (const item of [metadata, metadata.condition]) {
|
|
172
|
-
assert.
|
|
173
|
-
lookup(item.descriptionKey),
|
|
174
|
-
/^/,
|
|
217
|
+
assert.ok(
|
|
218
|
+
Text.safeParse(lookup(item.descriptionKey)).success,
|
|
175
219
|
`${locale} ${item.descriptionKey}`,
|
|
176
220
|
);
|
|
177
221
|
}
|
|
178
222
|
}
|
|
179
|
-
const
|
|
180
|
-
.shortcuts.groups;
|
|
223
|
+
const layoutMessages = readLocale("dms-layout", "layout", locale);
|
|
181
224
|
for (const { component } of registry) {
|
|
182
|
-
const group =
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
225
|
+
const group = [
|
|
226
|
+
"page",
|
|
227
|
+
"settings",
|
|
228
|
+
"shortcuts",
|
|
229
|
+
"groups",
|
|
230
|
+
component.toLowerCase(),
|
|
231
|
+
];
|
|
232
|
+
assert.ok(
|
|
233
|
+
Text.safeParse(dig(layoutMessages, [...group, "title"])).success,
|
|
234
|
+
`${locale} ${component} title`,
|
|
235
|
+
);
|
|
236
|
+
assert.ok(
|
|
237
|
+
Text.safeParse(dig(layoutMessages, [...group, "description"]))
|
|
238
|
+
.success,
|
|
187
239
|
`${locale} ${component} description`,
|
|
188
240
|
);
|
|
189
241
|
}
|
|
@@ -195,7 +247,7 @@ async function checkShortcutTranslations() {
|
|
|
195
247
|
|
|
196
248
|
function checkLiveLabels() {
|
|
197
249
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
198
|
-
const
|
|
250
|
+
const messages = readLocale("dms-ui", "ui", locale);
|
|
199
251
|
for (const key of [
|
|
200
252
|
"direct",
|
|
201
253
|
"paused",
|
|
@@ -208,15 +260,18 @@ function checkLiveLabels() {
|
|
|
208
260
|
"held_sorted",
|
|
209
261
|
"held_scrolled",
|
|
210
262
|
]) {
|
|
211
|
-
assert.ok(live
|
|
263
|
+
assert.ok(dig(messages, ["dms", "live", key]), `${locale} ${key}`);
|
|
212
264
|
}
|
|
213
265
|
}
|
|
214
266
|
}
|
|
215
267
|
|
|
216
268
|
async function checkPeriodLabels() {
|
|
217
|
-
const
|
|
269
|
+
const periodShortLabels = await import(
|
|
218
270
|
"../layers/dms-ui/app/entries/composables/period/periodShortLabels.ts"
|
|
219
271
|
);
|
|
272
|
+
const PRESET_SHORT_LABELS = ShortLabels.parse(
|
|
273
|
+
periodShortLabels.PRESET_SHORT_LABELS,
|
|
274
|
+
);
|
|
220
275
|
const source = readFileSync(
|
|
221
276
|
resolve(root, "../../interface-dms/src/base/period-selector.ts"),
|
|
222
277
|
"utf8",
|
|
@@ -236,8 +291,13 @@ async function checkPeriodLabels() {
|
|
|
236
291
|
"every non-custom period needs a short code",
|
|
237
292
|
);
|
|
238
293
|
for (const locale of ["en-GB", "fr-FR"]) {
|
|
239
|
-
const labels =
|
|
240
|
-
|
|
294
|
+
const labels = ShortLabels.parse(
|
|
295
|
+
dig(readLocale("dms-core", "core", locale), [
|
|
296
|
+
"dms",
|
|
297
|
+
"period",
|
|
298
|
+
"short_presets",
|
|
299
|
+
]),
|
|
300
|
+
);
|
|
241
301
|
assert.deepEqual(
|
|
242
302
|
Object.keys(labels).sort(),
|
|
243
303
|
Object.keys(PRESET_SHORT_LABELS).sort(),
|
|
@@ -264,7 +324,8 @@ function checkDevelopmentPlugin() {
|
|
|
264
324
|
);
|
|
265
325
|
}
|
|
266
326
|
|
|
267
|
-
|
|
327
|
+
/** @type {[string, () => unknown][]} */
|
|
328
|
+
const CHECKS = [
|
|
268
329
|
["instant-save page registry", checkInstantSavePages],
|
|
269
330
|
["server route ownership", checkServerRouteOwnership],
|
|
270
331
|
["sortable dependency", checkSortableDependency],
|
|
@@ -273,7 +334,9 @@ for (const [name, check] of [
|
|
|
273
334
|
["live labels", checkLiveLabels],
|
|
274
335
|
["period short codes", checkPeriodLabels],
|
|
275
336
|
["development plugin registration", checkDevelopmentPlugin],
|
|
276
|
-
]
|
|
337
|
+
];
|
|
338
|
+
|
|
339
|
+
for (const [name, check] of CHECKS) {
|
|
277
340
|
await check();
|
|
278
341
|
console.log(`PASS ${name}`);
|
|
279
342
|
}
|
|
@@ -5,8 +5,58 @@ import { pathToFileURL } from "node:url";
|
|
|
5
5
|
|
|
6
6
|
export const RENDERER = "@antelopejs/dms-frontend";
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The parsers and the renderer's globals the check works with.
|
|
10
|
+
*
|
|
11
|
+
* @typedef {object} DmsComponentsTools
|
|
12
|
+
* @property {typeof import("typescript")} ts
|
|
13
|
+
* @property {typeof import("vue/compiler-sfc").parse} parse
|
|
14
|
+
* @property {string | undefined} rendererGlobals
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {unknown} value
|
|
19
|
+
* @returns {value is string}
|
|
20
|
+
*/
|
|
21
|
+
function isString(value) {
|
|
22
|
+
return typeof value === "string";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {unknown} value
|
|
27
|
+
* @returns {value is Record<string, unknown>}
|
|
28
|
+
*/
|
|
29
|
+
function isRecord(value) {
|
|
30
|
+
return typeof value === "object" && value !== null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {unknown} value
|
|
35
|
+
* @returns {value is Record<string, string>}
|
|
36
|
+
*/
|
|
37
|
+
function isStringRecord(value) {
|
|
38
|
+
return isRecord(value) && Object.values(value).every(isString);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} path
|
|
43
|
+
* @returns {{ peerDependencies: Record<string, string>, engines: Record<string, string> }}
|
|
44
|
+
*/
|
|
8
45
|
function manifest(path) {
|
|
9
|
-
|
|
46
|
+
/** @type {unknown} */
|
|
47
|
+
const parsed = JSON.parse(
|
|
48
|
+
readFileSync(new URL(path, import.meta.url), "utf8"),
|
|
49
|
+
);
|
|
50
|
+
if (
|
|
51
|
+
!isRecord(parsed) ||
|
|
52
|
+
!isStringRecord(parsed.peerDependencies) ||
|
|
53
|
+
!isStringRecord(parsed.engines)
|
|
54
|
+
)
|
|
55
|
+
throw new Error(`${path} lists no peerDependencies and engines of strings`);
|
|
56
|
+
return {
|
|
57
|
+
peerDependencies: parsed.peerDependencies,
|
|
58
|
+
engines: parsed.engines,
|
|
59
|
+
};
|
|
10
60
|
}
|
|
11
61
|
|
|
12
62
|
const FRONTEND = manifest("../package.json");
|
|
@@ -16,6 +66,8 @@ const FRONTEND = manifest("../package.json");
|
|
|
16
66
|
* installed `@antelopejs/dms` declares for each. `typescript` and `vue` parse
|
|
17
67
|
* the layer's files; the renderer only lists the components it registers
|
|
18
68
|
* itself, such as `DmsLink`.
|
|
69
|
+
*
|
|
70
|
+
* @type {Readonly<Record<"typescript" | "vue" | typeof RENDERER, string>>}
|
|
19
71
|
*/
|
|
20
72
|
const DMS_COMPONENTS_DEPENDENCIES = Object.freeze({
|
|
21
73
|
typescript: manifest("../../package.json").peerDependencies.typescript,
|
|
@@ -23,7 +75,11 @@ const DMS_COMPONENTS_DEPENDENCIES = Object.freeze({
|
|
|
23
75
|
[RENDERER]: FRONTEND.engines[RENDERER],
|
|
24
76
|
});
|
|
25
77
|
|
|
26
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* How the package manager running the check adds a development dependency.
|
|
80
|
+
*
|
|
81
|
+
* @type {Readonly<Record<string, string>>}
|
|
82
|
+
*/
|
|
27
83
|
const ADD_DEV_DEPENDENCY = {
|
|
28
84
|
pnpm: "pnpm add -D",
|
|
29
85
|
npm: "npm install -D",
|
|
@@ -31,7 +87,12 @@ const ADD_DEV_DEPENDENCY = {
|
|
|
31
87
|
bun: "bun add -d",
|
|
32
88
|
};
|
|
33
89
|
|
|
34
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The command that adds `packages` at their range, for the package manager running the check.
|
|
92
|
+
*
|
|
93
|
+
* @param {(keyof typeof DMS_COMPONENTS_DEPENDENCIES)[]} packages
|
|
94
|
+
* @returns {string}
|
|
95
|
+
*/
|
|
35
96
|
export function addCommand(packages) {
|
|
36
97
|
const manager = (process.env.npm_config_user_agent ?? "").split("/")[0];
|
|
37
98
|
const add = Object.hasOwn(ADD_DEV_DEPENDENCY, manager)
|
|
@@ -43,6 +104,11 @@ export function addCommand(packages) {
|
|
|
43
104
|
return `${add} ${specs.join(" ")}`;
|
|
44
105
|
}
|
|
45
106
|
|
|
107
|
+
/**
|
|
108
|
+
* @param {NodeJS.Require[]} requires
|
|
109
|
+
* @param {string} specifier
|
|
110
|
+
* @returns {string | undefined}
|
|
111
|
+
*/
|
|
46
112
|
function resolveFirst(requires, specifier) {
|
|
47
113
|
for (const require of requires) {
|
|
48
114
|
try {
|
|
@@ -57,6 +123,9 @@ function resolveFirst(requires, specifier) {
|
|
|
57
123
|
/**
|
|
58
124
|
* Resolves `typescript` and `vue` from the layer, then from the installed
|
|
59
125
|
* `@antelopejs/dms`, and the renderer from the layer alone.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} layer
|
|
128
|
+
* @returns {DmsComponentsTools}
|
|
60
129
|
*/
|
|
61
130
|
export function dependencies(layer) {
|
|
62
131
|
const manifest = join(layer, "package.json");
|
|
@@ -65,25 +134,49 @@ export function dependencies(layer) {
|
|
|
65
134
|
const parsers = [fromLayer, createRequire(import.meta.url)];
|
|
66
135
|
const typescript = resolveFirst(parsers, "typescript");
|
|
67
136
|
const sfc = resolveFirst(parsers, "vue/compiler-sfc");
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (
|
|
137
|
+
/** @type {("typescript" | "vue")[]} */
|
|
138
|
+
const missing = [];
|
|
139
|
+
if (!typescript) missing.push("typescript");
|
|
140
|
+
if (!sfc) missing.push("vue");
|
|
141
|
+
if (!typescript || !sfc)
|
|
73
142
|
throw new Error(
|
|
74
143
|
`The DMS component check parses the layer with typescript and vue, and ${missing.join(" and ")} cannot be resolved from ${layer}. In ${layer}, run: ${addCommand(missing)}`,
|
|
75
144
|
);
|
|
76
145
|
const require = createRequire(import.meta.url);
|
|
146
|
+
/** @type {(id: string) => typeof import("typescript")} */
|
|
147
|
+
const loadTypeScript = require;
|
|
148
|
+
/** @type {(id: string) => typeof import("vue/compiler-sfc")} */
|
|
149
|
+
const loadSfc = require;
|
|
77
150
|
return {
|
|
78
|
-
ts:
|
|
79
|
-
parse:
|
|
151
|
+
ts: loadTypeScript(typescript),
|
|
152
|
+
parse: loadSfc(sfc).parse,
|
|
80
153
|
rendererGlobals: resolveFirst([fromLayer], `${RENDERER}/eslint-globals`),
|
|
81
154
|
};
|
|
82
155
|
}
|
|
83
156
|
|
|
84
|
-
/**
|
|
157
|
+
/**
|
|
158
|
+
* @param {unknown} loaded
|
|
159
|
+
* @returns {loaded is { default: Record<string, unknown> }}
|
|
160
|
+
*/
|
|
161
|
+
function hasGlobals(loaded) {
|
|
162
|
+
return (
|
|
163
|
+
isRecord(loaded) &&
|
|
164
|
+
Object.hasOwn(loaded, "default") &&
|
|
165
|
+
isRecord(loaded.default)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The `Dms` components the `@antelopejs/dms-frontend` renderer registers itself, or none when it is not installed.
|
|
171
|
+
*
|
|
172
|
+
* @param {string | undefined} globalsPath
|
|
173
|
+
* @returns {Promise<string[]>}
|
|
174
|
+
*/
|
|
85
175
|
export async function rendererComponentNames(globalsPath) {
|
|
86
176
|
if (!globalsPath) return [];
|
|
87
|
-
|
|
88
|
-
|
|
177
|
+
/** @type {unknown} */
|
|
178
|
+
const loaded = await import(pathToFileURL(globalsPath).href);
|
|
179
|
+
if (!hasGlobals(loaded))
|
|
180
|
+
throw new Error(`${globalsPath} exports no globals object by default`);
|
|
181
|
+
return Object.keys(loaded.default).filter((name) => /^Dms[A-Z]/.test(name));
|
|
89
182
|
}
|