@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
|
@@ -9,7 +9,53 @@ const { createRequire } = require("node:module");
|
|
|
9
9
|
const { pathToFileURL } = require("node:url");
|
|
10
10
|
|
|
11
11
|
const legacy = require("./frontend-legacy.cjs");
|
|
12
|
-
const { frontend, layers, ts, evaluate, load } = legacy;
|
|
12
|
+
const { frontend, layers, ts, evaluate, load, isObjectLike } = legacy;
|
|
13
|
+
|
|
14
|
+
/** @typedef {{ dirs: string[]; presets: string[]; imports: Array<{ from: string; name: string }> }} UnimportInput */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {URL} url
|
|
18
|
+
* @returns {Promise<{ createUnimport: (options: UnimportInput) => import("unimport").Unimport }>}
|
|
19
|
+
*/
|
|
20
|
+
const importUnimport = (url) => import(url);
|
|
21
|
+
|
|
22
|
+
/** @type {(filename: string) => { autoImportDirectories: (roots: Array<{ id: string; root: string }>, builds: Array<{ id: string; setup: unknown }>, fail: (message: string) => never) => string[] }} */
|
|
23
|
+
const loadBuildLoader = load;
|
|
24
|
+
|
|
25
|
+
/** @type {(source: string, filename: string, globals: legacy.ProbeBindings, imports: legacy.ProbeBindings) => { default: unknown }} */
|
|
26
|
+
const evaluateBuildFile = evaluate;
|
|
27
|
+
|
|
28
|
+
/** @type {{ runInNewContext: (code: string, context: object) => Array<Record<string, string[]>> }} */
|
|
29
|
+
const defaultsVm = vm;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} templates
|
|
33
|
+
* @returns {{ config: import("typescript").SourceFile; configuredImports: import("typescript").ArrayLiteralExpression }}
|
|
34
|
+
*/
|
|
35
|
+
function templateImports(templates) {
|
|
36
|
+
const config = ts.createSourceFile(
|
|
37
|
+
"vite.ts",
|
|
38
|
+
fs.readFileSync(path.join(templates, "vite.config.ts"), "utf8"),
|
|
39
|
+
ts.ScriptTarget.Latest,
|
|
40
|
+
true,
|
|
41
|
+
);
|
|
42
|
+
/** @type {{ initializer?: import("typescript").Expression }} */
|
|
43
|
+
const configured = {};
|
|
44
|
+
/** @param {import("typescript").Node} node */
|
|
45
|
+
const visit = (node) => {
|
|
46
|
+
if (
|
|
47
|
+
ts.isPropertyAssignment(node) &&
|
|
48
|
+
node.name.getText(config) === "imports"
|
|
49
|
+
)
|
|
50
|
+
configured.initializer = node.initializer;
|
|
51
|
+
ts.forEachChild(node, visit);
|
|
52
|
+
};
|
|
53
|
+
visit(config);
|
|
54
|
+
const configuredImports = configured.initializer;
|
|
55
|
+
if (!configuredImports || !ts.isArrayLiteralExpression(configuredImports))
|
|
56
|
+
throw new TypeError("The template Vite config has no imports array");
|
|
57
|
+
return { config, configuredImports };
|
|
58
|
+
}
|
|
13
59
|
|
|
14
60
|
async function autoImports() {
|
|
15
61
|
const buildReq = createRequire(
|
|
@@ -19,15 +65,20 @@ async function autoImports() {
|
|
|
19
65
|
path.dirname(buildReq.resolve("@antelopejs/dms-frontend/package.json")),
|
|
20
66
|
"templates/vue",
|
|
21
67
|
);
|
|
22
|
-
const { autoImportDirectories } =
|
|
68
|
+
const { autoImportDirectories } = loadBuildLoader(
|
|
23
69
|
path.join(templates, "frontend-build-loader.ts"),
|
|
24
70
|
);
|
|
25
71
|
const buildFile = path.join(frontend, "dms.frontend.build.ts");
|
|
26
|
-
const { default: setup } =
|
|
72
|
+
const { default: setup } = evaluateBuildFile(
|
|
27
73
|
fs.readFileSync(buildFile, "utf8"),
|
|
28
74
|
buildFile,
|
|
29
75
|
{},
|
|
30
|
-
{
|
|
76
|
+
{
|
|
77
|
+
"#dms/frontend-build": {
|
|
78
|
+
/** @param {unknown} value */
|
|
79
|
+
defineDmsFrontendBuild: (value) => value,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
31
82
|
);
|
|
32
83
|
const dirs = autoImportDirectories(
|
|
33
84
|
[{ id: "dms", root: frontend }],
|
|
@@ -36,35 +87,21 @@ async function autoImports() {
|
|
|
36
87
|
throw new Error(message);
|
|
37
88
|
},
|
|
38
89
|
);
|
|
39
|
-
const config =
|
|
40
|
-
|
|
41
|
-
fs.readFileSync(path.join(templates, "vite.config.ts"), "utf8"),
|
|
42
|
-
ts.ScriptTarget.Latest,
|
|
43
|
-
true,
|
|
44
|
-
);
|
|
45
|
-
let configuredImports;
|
|
46
|
-
const visit = (node) => {
|
|
47
|
-
if (
|
|
48
|
-
ts.isPropertyAssignment(node) &&
|
|
49
|
-
node.name.getText(config) === "imports"
|
|
50
|
-
)
|
|
51
|
-
configuredImports = node.initializer;
|
|
52
|
-
ts.forEachChild(node, visit);
|
|
53
|
-
};
|
|
54
|
-
visit(config);
|
|
55
|
-
const defaults = vm.runInNewContext(
|
|
90
|
+
const { config, configuredImports } = templateImports(templates);
|
|
91
|
+
const defaults = defaultsVm.runInNewContext(
|
|
56
92
|
`[${configuredImports.elements
|
|
57
93
|
.filter(ts.isObjectLiteralExpression)
|
|
58
94
|
.map((node) => node.getText(config))
|
|
59
95
|
.join(",")} ]`.replaceAll("import.meta.dirname", "templateRoot"),
|
|
60
96
|
{
|
|
61
97
|
templateRoot: templates,
|
|
98
|
+
/** @param {unknown} value */
|
|
62
99
|
normalizePath: (value) => value,
|
|
63
100
|
resolve: path.resolve,
|
|
64
101
|
},
|
|
65
102
|
);
|
|
66
|
-
const { createUnimport } = await
|
|
67
|
-
pathToFileURL(buildReq.resolve("unimport"))
|
|
103
|
+
const { createUnimport } = await importUnimport(
|
|
104
|
+
pathToFileURL(buildReq.resolve("unimport")),
|
|
68
105
|
);
|
|
69
106
|
const importer = createUnimport({
|
|
70
107
|
dirs,
|
|
@@ -129,12 +166,26 @@ async function autoImports() {
|
|
|
129
166
|
}
|
|
130
167
|
}
|
|
131
168
|
|
|
169
|
+
/**
|
|
170
|
+
* @param {import("typescript").SourceFile} source
|
|
171
|
+
* @returns {source is import("typescript").SourceFile & { parseDiagnostics: readonly unknown[] }}
|
|
172
|
+
*/
|
|
173
|
+
function hasParseDiagnostics(source) {
|
|
174
|
+
return (
|
|
175
|
+
Object.hasOwn(source, "parseDiagnostics") &&
|
|
176
|
+
"parseDiagnostics" in source &&
|
|
177
|
+
Array.isArray(source.parseDiagnostics)
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** @param {import("typescript").Program} program */
|
|
132
182
|
function describeTypes(program) {
|
|
133
183
|
const checker = program.getTypeChecker();
|
|
134
184
|
const flags =
|
|
135
185
|
ts.TypeFormatFlags.NoTruncation |
|
|
136
186
|
ts.TypeFormatFlags.InTypeAlias |
|
|
137
187
|
ts.TypeFormatFlags.UseStructuralFallback;
|
|
188
|
+
/** @type {Map<string, string>} */
|
|
138
189
|
const dictionaries = new Map();
|
|
139
190
|
for (const source of program.getSourceFiles()) {
|
|
140
191
|
for (const node of source.statements.filter(ts.isTypeAliasDeclaration)) {
|
|
@@ -159,6 +210,10 @@ function describeTypes(program) {
|
|
|
159
210
|
);
|
|
160
211
|
}
|
|
161
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* @param {string} text
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
162
217
|
const normalize = (text) => {
|
|
163
218
|
const normalized = text
|
|
164
219
|
.replaceAll(frontend.replaceAll("\\", "/"), "<frontend>")
|
|
@@ -180,6 +235,8 @@ function describeTypes(program) {
|
|
|
180
235
|
true,
|
|
181
236
|
);
|
|
182
237
|
const declaration = source.statements[0];
|
|
238
|
+
if (!hasParseDiagnostics(source))
|
|
239
|
+
throw new TypeError("The TypeScript parser reports no parse diagnostics");
|
|
183
240
|
if (
|
|
184
241
|
source.parseDiagnostics.length ||
|
|
185
242
|
!ts.isTypeAliasDeclaration(declaration) ||
|
|
@@ -192,6 +249,11 @@ function describeTypes(program) {
|
|
|
192
249
|
);
|
|
193
250
|
return `{ ${members.map((member) => member.getText(source)).join(" ")} }`;
|
|
194
251
|
};
|
|
252
|
+
/**
|
|
253
|
+
* @param {import("typescript").Type} type
|
|
254
|
+
* @param {Set<import("typescript").Type>} [seen]
|
|
255
|
+
* @returns {string}
|
|
256
|
+
*/
|
|
195
257
|
const describe = (type, seen = new Set()) => {
|
|
196
258
|
if (seen.has(type))
|
|
197
259
|
return normalize(checker.typeToString(type, undefined, flags));
|
|
@@ -213,6 +275,10 @@ function describeTypes(program) {
|
|
|
213
275
|
return { describe, normalize };
|
|
214
276
|
}
|
|
215
277
|
|
|
278
|
+
/**
|
|
279
|
+
* @param {import("typescript").Program} program
|
|
280
|
+
* @param {{ entries: import("unimport").Import[]; globals: string; options: import("typescript").CompilerOptions; injected: Set<string> }} context
|
|
281
|
+
*/
|
|
216
282
|
function signatures(program, { entries, globals, options, injected }) {
|
|
217
283
|
const checker = program.getTypeChecker();
|
|
218
284
|
const { describe, normalize } = describeTypes(program);
|
|
@@ -279,10 +345,46 @@ function signatures(program, { entries, globals, options, injected }) {
|
|
|
279
345
|
);
|
|
280
346
|
}
|
|
281
347
|
|
|
348
|
+
/**
|
|
349
|
+
* @typedef {{ default: { setup: (sdk: object) => void } }} FrontendEntry
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
/** @type {(source: string, filename: string, globals: legacy.ProbeBindings, imports: legacy.ProbeBindings, transformers: import("typescript").CustomTransformers) => FrontendEntry} */
|
|
353
|
+
const evaluateFrontendEntry = evaluate;
|
|
354
|
+
|
|
355
|
+
/** @type {(source: string, filename: string, globals: legacy.ProbeBindings, imports: legacy.ProbeBindings) => { default: () => void }} */
|
|
356
|
+
const evaluateRegister = evaluate;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @param {unknown} value
|
|
360
|
+
* @returns {value is { loader: unknown }}
|
|
361
|
+
*/
|
|
362
|
+
function hasLoader(value) {
|
|
363
|
+
const holder = isObjectLike(value) || typeof value === "function";
|
|
364
|
+
return holder && "loader" in value && Boolean(value.loader);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* @param {import("typescript").Expression} expression
|
|
369
|
+
* @returns {string}
|
|
370
|
+
*/
|
|
371
|
+
function patternText(expression) {
|
|
372
|
+
if (!ts.isStringLiteralLike(expression))
|
|
373
|
+
throw new TypeError("import.meta.glob takes string literal patterns");
|
|
374
|
+
return expression.text;
|
|
375
|
+
}
|
|
376
|
+
|
|
282
377
|
function registrations() {
|
|
378
|
+
/** @type {unknown[][]} */
|
|
283
379
|
const events = [];
|
|
380
|
+
/**
|
|
381
|
+
* @param {string} file
|
|
382
|
+
* @returns {FrontendEntry}
|
|
383
|
+
*/
|
|
284
384
|
const evaluateEntry = (file) => {
|
|
385
|
+
/** @type {import("typescript").TransformerFactory<import("typescript").SourceFile>} */
|
|
285
386
|
const transform = (context) => (node) => {
|
|
387
|
+
/** @type {import("typescript").Visitor} */
|
|
286
388
|
const visit = (node) => {
|
|
287
389
|
if (
|
|
288
390
|
ts.isPropertyAccessExpression(node) &&
|
|
@@ -295,8 +397,8 @@ function registrations() {
|
|
|
295
397
|
) {
|
|
296
398
|
const arg = node.arguments[0];
|
|
297
399
|
const patterns = ts.isArrayLiteralExpression(arg)
|
|
298
|
-
? arg.elements.map(
|
|
299
|
-
: [arg
|
|
400
|
+
? arg.elements.map(patternText)
|
|
401
|
+
: [patternText(arg)];
|
|
300
402
|
const files = fs.globSync(
|
|
301
403
|
patterns.filter((pattern) => !pattern.startsWith("!")),
|
|
302
404
|
{
|
|
@@ -330,8 +432,9 @@ function registrations() {
|
|
|
330
432
|
return { defineAsyncComponent: () => ({ loader: true }) };
|
|
331
433
|
if (name === "#dms/frontend-module")
|
|
332
434
|
return { useDmsRuntimeConfig: () => ({ public: {} }) };
|
|
333
|
-
|
|
334
|
-
|
|
435
|
+
const specifier = String(name);
|
|
436
|
+
if (specifier.startsWith(".")) {
|
|
437
|
+
const target = path.resolve(path.dirname(file), specifier);
|
|
335
438
|
if (target.includes("/app/entries"))
|
|
336
439
|
return evaluateEntry(
|
|
337
440
|
target.endsWith(".ts") ? target : `${target}.ts`,
|
|
@@ -341,7 +444,7 @@ function registrations() {
|
|
|
341
444
|
},
|
|
342
445
|
},
|
|
343
446
|
);
|
|
344
|
-
return
|
|
447
|
+
return evaluateFrontendEntry(
|
|
345
448
|
fs.readFileSync(file, "utf8"),
|
|
346
449
|
file,
|
|
347
450
|
{ probeLoader: () => {} },
|
|
@@ -350,19 +453,18 @@ function registrations() {
|
|
|
350
453
|
);
|
|
351
454
|
};
|
|
352
455
|
const module = evaluateEntry(path.join(frontend, "dms.frontend.ts")).default;
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
},
|
|
456
|
+
/** @type {Record<PropertyKey, unknown>} */
|
|
457
|
+
const sdkTarget = { options: { public: {} } };
|
|
458
|
+
const sdk = new Proxy(sdkTarget, {
|
|
459
|
+
get(target, key) {
|
|
460
|
+
if (key in target) return target[key];
|
|
461
|
+
return /** @param {...unknown} args */ (...args) =>
|
|
462
|
+
events.push([
|
|
463
|
+
key,
|
|
464
|
+
...args.map((value) => (hasLoader(value) ? "<component>" : value)),
|
|
465
|
+
]);
|
|
364
466
|
},
|
|
365
|
-
);
|
|
467
|
+
});
|
|
366
468
|
module.setup(sdk);
|
|
367
469
|
const registerFile = path.join(layers, "dms-ui/app/plugins/register.ts");
|
|
368
470
|
const registrations = new Proxy(
|
|
@@ -376,15 +478,77 @@ function registrations() {
|
|
|
376
478
|
),
|
|
377
479
|
},
|
|
378
480
|
);
|
|
379
|
-
|
|
481
|
+
evaluateRegister(
|
|
380
482
|
fs.readFileSync(registerFile, "utf8"),
|
|
381
483
|
registerFile,
|
|
382
|
-
{
|
|
484
|
+
{
|
|
485
|
+
/** @param {unknown} setup */
|
|
486
|
+
defineDmsPlugin: (setup) => setup,
|
|
487
|
+
},
|
|
383
488
|
registrations,
|
|
384
489
|
).default();
|
|
385
490
|
return events;
|
|
386
491
|
}
|
|
387
492
|
|
|
493
|
+
/**
|
|
494
|
+
* @typedef {{
|
|
495
|
+
* success: boolean;
|
|
496
|
+
* testResults: Array<{ assertionResults: Array<{ fullName: string; status: string }> }>;
|
|
497
|
+
* }} VitestReport
|
|
498
|
+
*/
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* @param {unknown} value
|
|
502
|
+
* @returns {value is { fullName: string; status: string }}
|
|
503
|
+
*/
|
|
504
|
+
function isAssertionResult(value) {
|
|
505
|
+
return (
|
|
506
|
+
isObjectLike(value) &&
|
|
507
|
+
Object.hasOwn(value, "fullName") &&
|
|
508
|
+
typeof value.fullName === "string" &&
|
|
509
|
+
Object.hasOwn(value, "status") &&
|
|
510
|
+
typeof value.status === "string"
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* @param {unknown} value
|
|
516
|
+
* @returns {value is { assertionResults: Array<{ fullName: string; status: string }> }}
|
|
517
|
+
*/
|
|
518
|
+
function isFileResult(value) {
|
|
519
|
+
return (
|
|
520
|
+
isObjectLike(value) &&
|
|
521
|
+
Object.hasOwn(value, "assertionResults") &&
|
|
522
|
+
Array.isArray(value.assertionResults) &&
|
|
523
|
+
value.assertionResults.every(isAssertionResult)
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @param {unknown} value
|
|
529
|
+
* @returns {value is VitestReport}
|
|
530
|
+
*/
|
|
531
|
+
function isVitestReport(value) {
|
|
532
|
+
return (
|
|
533
|
+
isObjectLike(value) &&
|
|
534
|
+
Object.hasOwn(value, "success") &&
|
|
535
|
+
typeof value.success === "boolean" &&
|
|
536
|
+
Object.hasOwn(value, "testResults") &&
|
|
537
|
+
Array.isArray(value.testResults) &&
|
|
538
|
+
value.testResults.every(isFileResult)
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @param {unknown} error
|
|
544
|
+
* @returns {error is { stack: string }}
|
|
545
|
+
*/
|
|
546
|
+
function hasStack(error) {
|
|
547
|
+
return (
|
|
548
|
+
isObjectLike(error) && "stack" in error && typeof error.stack === "string"
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
|
|
388
552
|
function behavioralTests() {
|
|
389
553
|
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "frontend-tests-"));
|
|
390
554
|
const report = path.join(temporary, "report.json");
|
|
@@ -406,8 +570,10 @@ function behavioralTests() {
|
|
|
406
570
|
],
|
|
407
571
|
{ cwd: frontend, stdio: "pipe", maxBuffer: 16 * 1024 * 1024 },
|
|
408
572
|
);
|
|
573
|
+
/** @type {unknown} */
|
|
409
574
|
const result = JSON.parse(fs.readFileSync(report, "utf8"));
|
|
410
|
-
if (!result
|
|
575
|
+
if (!isVitestReport(result) || !result.success)
|
|
576
|
+
throw new Error("Frontend behavioral tests failed");
|
|
411
577
|
return result.testResults
|
|
412
578
|
.flatMap((file) =>
|
|
413
579
|
file.assertionResults.map((test) => ({
|
|
@@ -422,6 +588,7 @@ function behavioralTests() {
|
|
|
422
588
|
}
|
|
423
589
|
|
|
424
590
|
(async () => {
|
|
591
|
+
/** @type {Awaited<ReturnType<typeof legacy.observe>> & { autoImports: Awaited<ReturnType<typeof autoImports>>; registrations: ReturnType<typeof registrations>; behavioralTests?: ReturnType<typeof behavioralTests> }} */
|
|
425
592
|
const result = {
|
|
426
593
|
...(await legacy.observe()),
|
|
427
594
|
autoImports: await autoImports(),
|
|
@@ -430,7 +597,10 @@ function behavioralTests() {
|
|
|
430
597
|
if (process.argv.includes("--tests"))
|
|
431
598
|
result.behavioralTests = behavioralTests();
|
|
432
599
|
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
433
|
-
})().catch(
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
});
|
|
600
|
+
})().catch(
|
|
601
|
+
/** @param {unknown} error */
|
|
602
|
+
(error) => {
|
|
603
|
+
process.stderr.write(`${hasStack(error) ? error.stack : undefined}\n`);
|
|
604
|
+
process.exitCode = 1;
|
|
605
|
+
},
|
|
606
|
+
);
|