@antelopejs/dms 0.20.3 → 0.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (180) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/implementations/dms-builder/engine/compose-page.js +3 -2
  3. package/dist/implementations/dms-builder/engine/compose-page.js.map +1 -1
  4. package/dist/mcp/page-verify/index.d.ts +1 -0
  5. package/dist/mcp/page-verify/index.js +1 -0
  6. package/dist/mcp/page-verify/index.js.map +1 -1
  7. package/dist/mcp/page-verify/redact-report.d.ts +2 -0
  8. package/dist/mcp/page-verify/redact-report.js +120 -0
  9. package/dist/mcp/page-verify/redact-report.js.map +1 -0
  10. package/dist/mcp/page-verify/render.js +4 -1
  11. package/dist/mcp/page-verify/render.js.map +1 -1
  12. package/dist/mcp/redact.d.ts +87 -0
  13. package/dist/mcp/redact.js +139 -0
  14. package/dist/mcp/redact.js.map +1 -0
  15. package/dist/mcp/tools/builder-compose.js +11 -2
  16. package/dist/mcp/tools/builder-compose.js.map +1 -1
  17. package/dist/mcp/tools/builder-project.js +56 -23
  18. package/dist/mcp/tools/builder-project.js.map +1 -1
  19. package/dist/mcp/tools/builder-queries.js +41 -4
  20. package/dist/mcp/tools/builder-queries.js.map +1 -1
  21. package/dist/mcp/tools/builder-shared.d.ts +3 -1
  22. package/dist/mcp/tools/builder-shared.js +5 -0
  23. package/dist/mcp/tools/builder-shared.js.map +1 -1
  24. package/dist/mcp/tools/database.js +3 -2
  25. package/dist/mcp/tools/database.js.map +1 -1
  26. package/dist/mcp/tools/page-verify.js +3 -2
  27. package/dist/mcp/tools/page-verify.js.map +1 -1
  28. package/frontend-vue/eslint-globals.generated.mjs +259 -942
  29. package/frontend-vue/layers/dms-core/app/build/composables/api-error.ts +46 -23
  30. package/frontend-vue/layers/dms-core/app/build/composables/auth/usePermissionPreview.ts +34 -23
  31. package/frontend-vue/layers/dms-core/app/build/composables/user/preferencesCookie.ts +8 -2
  32. package/frontend-vue/layers/dms-core/app/build/composables/user/tablePreferences.ts +11 -5
  33. package/frontend-vue/layers/dms-core/app/build/utils/crossTab.ts +4 -2
  34. package/frontend-vue/layers/dms-core/app/build/utils/json.ts +31 -0
  35. package/frontend-vue/layers/dms-core/app/build/utils/permission-preview.ts +6 -11
  36. package/frontend-vue/layers/dms-core/app/build/utils/record.ts +4 -0
  37. package/frontend-vue/layers/dms-core/app/build/utils/sharedRealtimeConnection.ts +56 -36
  38. package/frontend-vue/layers/dms-core/app/composables/auth/useApiData.ts +2 -2
  39. package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +6 -1
  40. package/frontend-vue/layers/dms-core/app/composables/auth/useCurrentUser.ts +3 -2
  41. package/frontend-vue/layers/dms-core/app/composables/auth/useLogout.ts +3 -2
  42. package/frontend-vue/layers/dms-core/app/composables/auth/useMultiAccount.ts +15 -14
  43. package/frontend-vue/layers/dms-core/app/composables/auth/useSessionRecovery.ts +21 -8
  44. package/frontend-vue/layers/dms-core/app/composables/data-types/useDataType.ts +3 -3
  45. package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +11 -9
  46. package/frontend-vue/layers/dms-core/app/composables/period/periodLink.ts +3 -2
  47. package/frontend-vue/layers/dms-core/app/composables/period/usePeriod.ts +2 -2
  48. package/frontend-vue/layers/dms-core/app/composables/realtime/usePageRealtime.ts +10 -3
  49. package/frontend-vue/layers/dms-core/app/composables/realtime/useSseStream.ts +22 -16
  50. package/frontend-vue/layers/dms-core/app/composables/realtime/useUserRealtime.ts +68 -46
  51. package/frontend-vue/layers/dms-core/app/composables/useApiErrorPresenter.ts +22 -11
  52. package/frontend-vue/layers/dms-core/app/composables/useEventedAction.ts +4 -1
  53. package/frontend-vue/layers/dms-core/app/composables/useFieldErrors.ts +14 -6
  54. package/frontend-vue/layers/dms-core/app/composables/user/usePreferences.ts +8 -3
  55. package/frontend-vue/layers/dms-core/app/composables/watch/useWatch.ts +17 -8
  56. package/frontend-vue/layers/dms-core/app/types/module-store.ts +3 -1
  57. package/frontend-vue/layers/dms-core/app/types/page.ts +3 -1
  58. package/frontend-vue/layers/dms-core/app/utils/dedupedRefresh.ts +2 -2
  59. package/frontend-vue/layers/dms-core/app/utils/formatter.ts +5 -5
  60. package/frontend-vue/layers/dms-core/app/utils/menu.ts +12 -4
  61. package/frontend-vue/layers/dms-core/app/utils/pageQuery.ts +7 -4
  62. package/frontend-vue/layers/dms-core/app/utils/row-action-rule-evaluator.ts +7 -3
  63. package/frontend-vue/layers/dms-core/app/utils/stringTypeParser.ts +8 -10
  64. package/frontend-vue/layers/dms-core/app/utils/type-check.ts +25 -12
  65. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEditOverlay.vue +2 -2
  66. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupIndex.vue +1 -1
  67. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspector.vue +3 -2
  68. package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupInspectorField.vue +5 -2
  69. package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +4 -3
  70. package/frontend-vue/layers/dms-ui/app/build/components/containers/modal/DynamicModal.vue +3 -2
  71. package/frontend-vue/layers/dms-ui/app/build/components/containers/row/RowHeader.vue +2 -1
  72. package/frontend-vue/layers/dms-ui/app/build/components/period/PeriodRangeCalendar.vue +10 -7
  73. package/frontend-vue/layers/dms-ui/app/build/components/sortable/SortableList.vue +2 -2
  74. package/frontend-vue/layers/dms-ui/app/build/components/table/FiltersRow.vue +20 -18
  75. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuColumns.vue +2 -5
  76. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuDensity.vue +3 -4
  77. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuFilter.vue +3 -4
  78. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuImport.vue +2 -5
  79. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuPage.vue +2 -5
  80. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuRoot.vue +3 -4
  81. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuSort.vue +2 -5
  82. package/frontend-vue/layers/dms-ui/app/build/components/table/MenuViewMode.vue +21 -19
  83. package/frontend-vue/layers/dms-ui/app/build/components/table/RowSelection.vue +3 -4
  84. package/frontend-vue/layers/dms-ui/app/build/components/table/Table.types.ts +4 -4
  85. package/frontend-vue/layers/dms-ui/app/build/components/table/TableActions.vue +3 -4
  86. package/frontend-vue/layers/dms-ui/app/build/components/table/TableMenu.vue +3 -4
  87. package/frontend-vue/layers/dms-ui/app/build/components/table/TablePagination.vue +3 -4
  88. package/frontend-vue/layers/dms-ui/app/build/components/table/TableRoot.vue +3 -5
  89. package/frontend-vue/layers/dms-ui/app/build/components/table/TableTabs.vue +2 -5
  90. package/frontend-vue/layers/dms-ui/app/build/components/table/TableViews.vue +3 -4
  91. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentFilters.ts +4 -4
  92. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentPreferences.ts +4 -3
  93. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentRows.ts +4 -3
  94. package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentTheme.ts +11 -0
  95. package/frontend-vue/layers/dms-ui/app/build/components/table-view/CardsDisplay.vue +35 -9
  96. package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +1 -1
  97. package/frontend-vue/layers/dms-ui/app/build/mockups/resync.ts +9 -1
  98. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +34 -25
  99. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +52 -26
  100. package/frontend-vue/layers/dms-ui/app/build/utils/calendarDay.ts +4 -1
  101. package/frontend-vue/layers/dms-ui/app/build/utils/characterCount.ts +1 -1
  102. package/frontend-vue/layers/dms-ui/app/build/utils/dispatchQuickActionTarget.ts +16 -11
  103. package/frontend-vue/layers/dms-ui/app/build/utils/fieldOptionsI18n.ts +23 -21
  104. package/frontend-vue/layers/dms-ui/app/build/utils/json.ts +74 -0
  105. package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +2 -2
  106. package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +4 -4
  107. package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +59 -50
  108. package/frontend-vue/layers/dms-ui/app/build/utils/mockupDrop.ts +1 -1
  109. package/frontend-vue/layers/dms-ui/app/build/utils/mockupEdit.ts +8 -6
  110. package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +34 -28
  111. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStamp.ts +11 -3
  112. package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +5 -2
  113. package/frontend-vue/layers/dms-ui/app/build/utils/streamHighlight.ts +8 -6
  114. package/frontend-vue/layers/dms-ui/app/build/utils/urlVariables.ts +2 -1
  115. package/frontend-vue/layers/dms-ui/app/components/RecursiveComponent.vue +3 -6
  116. package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +5 -4
  117. package/frontend-vue/layers/dms-ui/app/components/blocks/BannerBlock.vue +1 -2
  118. package/frontend-vue/layers/dms-ui/app/components/card/NavCard.vue +4 -1
  119. package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +62 -13
  120. package/frontend-vue/layers/dms-ui/app/components/chart/ChartBlock.vue +18 -6
  121. package/frontend-vue/layers/dms-ui/app/components/code-snippet/CodeSnippet.vue +9 -4
  122. package/frontend-vue/layers/dms-ui/app/components/confirm/ConfirmModal.vue +9 -6
  123. package/frontend-vue/layers/dms-ui/app/components/flow-canvas/FlowCanvas.vue +16 -18
  124. package/frontend-vue/layers/dms-ui/app/components/form/FormBlock.vue +4 -9
  125. package/frontend-vue/layers/dms-ui/app/components/form/LocalizedField.vue +2 -2
  126. package/frontend-vue/layers/dms-ui/app/components/form/components/InputAddress.vue +2 -2
  127. package/frontend-vue/layers/dms-ui/app/components/form/components/InputImage.vue +5 -8
  128. package/frontend-vue/layers/dms-ui/app/components/form/components/RichText.vue +3 -2
  129. package/frontend-vue/layers/dms-ui/app/components/master-detail/MasterDetail.vue +3 -1
  130. package/frontend-vue/layers/dms-ui/app/components/period/usePeriodSelectorInteraction.ts +9 -7
  131. package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanBoard.vue +11 -6
  132. package/frontend-vue/layers/dms-ui/app/components/table-view/KanbanDisplay.vue +40 -3
  133. package/frontend-vue/layers/dms-ui/app/composables/chart/apexDatetimeBuckets.ts +9 -5
  134. package/frontend-vue/layers/dms-ui/app/composables/chart/events.ts +6 -3
  135. package/frontend-vue/layers/dms-ui/app/composables/chart/heatmapColors.ts +1 -1
  136. package/frontend-vue/layers/dms-ui/app/composables/chart/localizeSeries.ts +13 -2
  137. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +27 -4
  138. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.types.ts +3 -2
  139. package/frontend-vue/layers/dms-ui/app/composables/chart/useChartFetch.ts +3 -4
  140. package/frontend-vue/layers/dms-ui/app/composables/confirm/types.ts +5 -1
  141. package/frontend-vue/layers/dms-ui/app/composables/containers/openDynamicContainer.ts +6 -6
  142. package/frontend-vue/layers/dms-ui/app/composables/containers/types.ts +1 -1
  143. package/frontend-vue/layers/dms-ui/app/composables/containers/useDrawer.ts +8 -5
  144. package/frontend-vue/layers/dms-ui/app/composables/containers/useModal.ts +1 -1
  145. package/frontend-vue/layers/dms-ui/app/composables/form/types/props.ts +5 -2
  146. package/frontend-vue/layers/dms-ui/app/composables/form/useForm.ts +80 -39
  147. package/frontend-vue/layers/dms-ui/app/composables/live/usePageLiveRefresh.ts +1 -1
  148. package/frontend-vue/layers/dms-ui/app/composables/resolveDmsComponent.ts +9 -2
  149. package/frontend-vue/layers/dms-ui/app/composables/tab/useTab.ts +2 -2
  150. package/frontend-vue/layers/dms-ui/app/composables/table-view/shortcuts/tableViewShiftA.ts +2 -2
  151. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/action-target.ts +2 -1
  152. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/column.ts +3 -1
  153. package/frontend-vue/layers/dms-ui/app/composables/table-view/types/display.ts +6 -2
  154. package/frontend-vue/layers/dms-ui/app/composables/table-view/useTableViewExport.ts +6 -5
  155. package/frontend-vue/layers/dms-ui/app/composables/unsaved-changes/useUnsavedChanges.ts +1 -1
  156. package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +21 -9
  157. package/frontend-vue/layers/dms-ui/app/utils/blockRefresh.ts +8 -2
  158. package/frontend-vue/layers/dms-ui/app/utils/cascader.ts +18 -8
  159. package/frontend-vue/layers/dms-ui/app/utils/metadataRetry.ts +1 -1
  160. package/frontend-vue/package.json +2 -1
  161. package/frontend-vue/scripts/check-api-error-presentation.mjs +257 -117
  162. package/frontend-vue/scripts/check-autoimport-boundaries.mjs +143 -27
  163. package/frontend-vue/scripts/check-disable-blocks.mjs +26 -4
  164. package/frontend-vue/scripts/check-dms-components.mjs +152 -246
  165. package/frontend-vue/scripts/check-invariants.mjs +100 -42
  166. package/frontend-vue/scripts/check-page-invariants.mjs +103 -40
  167. package/frontend-vue/scripts/dms-components-dependencies.mjs +106 -13
  168. package/frontend-vue/scripts/dms-components-script.mjs +375 -0
  169. package/frontend-vue/scripts/eslint-test-quality.mjs +126 -0
  170. package/frontend-vue/scripts/jsconfig.json +10 -0
  171. package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +4 -2
  172. package/frontend-vue/scripts/probes/frontend-behavior.cjs +217 -47
  173. package/frontend-vue/scripts/probes/frontend-legacy.cjs +159 -8
  174. package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +89 -10
  175. package/frontend-vue/scripts/prove-comment-emit.mjs +33 -4
  176. package/frontend-vue/scripts/prove-component-registration.mjs +110 -24
  177. package/frontend-vue/scripts/test-autoimport-boundaries.mjs +37 -6
  178. package/frontend-vue/scripts/test-dms-components.mjs +51 -2
  179. package/package.json +1 -1
  180. package/frontend-vue/eslint-test-quality.mjs +0 -62
@@ -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 } = load(
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 } = evaluate(
72
+ const { default: setup } = evaluateBuildFile(
27
73
  fs.readFileSync(buildFile, "utf8"),
28
74
  buildFile,
29
75
  {},
30
- { "#dms/frontend-build": { defineDmsFrontendBuild: (value) => value } },
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 = ts.createSourceFile(
40
- "vite.ts",
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 import(
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((item) => item.text)
299
- : [arg.text];
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
- if (name.startsWith(".")) {
334
- const target = path.resolve(path.dirname(file), name);
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 evaluate(
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
- const sdk = new Proxy(
354
- { options: { public: {} } },
355
- {
356
- get(target, key) {
357
- if (key in target) return target[key];
358
- return (...args) =>
359
- events.push([
360
- key,
361
- ...args.map((value) => (value?.loader ? "<component>" : value)),
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
- evaluate(
481
+ evaluateRegister(
380
482
  fs.readFileSync(registerFile, "utf8"),
381
483
  registerFile,
382
- { defineDmsPlugin: (setup) => setup },
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.success) throw new Error("Frontend behavioral tests failed");
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((error) => {
434
- process.stderr.write(`${error.stack}\n`);
435
- process.exitCode = 1;
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
+ );