@antelopejs/dms 0.20.7 → 0.20.8-next.919.g0c68f67
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/bin/control/commands-verify.mjs +8 -49
- package/bin/control/options.mjs +0 -1
- package/bin/control/run-state.mjs +1 -1
- package/bin/control/timing.mjs +1 -16
- package/bin/control/timing.test.mjs +0 -11
- package/bin/control/verify/decode.mjs +4 -144
- package/bin/control/verify/decode.test.mjs +1 -149
- package/bin/control/verify/formal.mjs +22 -218
- package/bin/control/verify/formal.test.mjs +60 -117
- package/bin/control/verify/map.test.mjs +0 -73
- package/bin/control/verify/types.mjs +4 -18
- package/bin/dms-control.mjs +0 -2
- package/dist/implementations/dms/page/controller.d.ts +2 -1
- package/dist/implementations/dms/page/controller.js.map +1 -1
- package/dist/implementations/dms-builder/engine/connection-access-config.js +2 -2
- package/dist/implementations/dms-builder/engine/connection-targets.js.map +1 -1
- package/dist/implementations/dms-builder/engine/database-access.d.ts +1 -1
- package/dist/implementations/dms-builder/engine/database-access.js +2 -2
- package/dist/implementations/dms-builder/engine/database-check-input.d.ts +3 -2
- package/dist/implementations/dms-builder/engine/database-check-input.js.map +1 -1
- package/dist/implementations/dms-builder/engine/database-check.js +2 -2
- package/dist/implementations/dms-builder/engine/database-check.js.map +1 -1
- package/dist/implementations/dms-builder/engine/probe-answer.d.ts +44 -1
- package/dist/implementations/dms-builder/engine/probe-answer.js +2 -5
- package/dist/implementations/dms-builder/engine/probe-answer.js.map +1 -1
- package/dist/mockup/files.d.ts +1 -1
- package/dist/mockup/files.js +2 -2
- package/dist/pages/settings/users/roles.js.map +1 -1
- package/dist/store/internal/frontend/frontend-ready.d.ts +2 -1
- package/dist/store/internal/frontend/frontend-ready.js.map +1 -1
- package/dist/store/operations.js +4 -4
- package/dist/store/operations.js.map +1 -1
- package/dist/utils/upload-constraints.d.ts +1 -1
- package/dist/utils/upload-constraints.js +2 -2
- package/dist/utils/upload-constraints.js.map +1 -1
- package/dist/validation/issue-message.d.ts +1 -1
- package/dist/validation/issue-message.js +3 -3
- package/dist/validation/issue-message.js.map +1 -1
- package/frontend-vue/layers/dms-core/app/utils/formatter.ts +1 -0
- package/frontend-vue/layers/dms-layout/app/build/composables/navigation/useVisitNavBadges.ts +11 -14
- package/frontend-vue/layers/dms-layout/app/build/composables/settings/security/useSecurityFormat.ts +5 -5
- package/frontend-vue/layers/dms-layout/app/build/utils/modules-catalog.ts +7 -2
- package/frontend-vue/layers/dms-layout/app/build/utils/notificationPayload.ts +9 -5
- package/frontend-vue/layers/dms-layout/app/composables/page/useModuleHistory.ts +4 -1
- package/frontend-vue/layers/dms-layout/app/composables/page/useModulesListing.ts +7 -17
- package/frontend-vue/layers/dms-layout/app/custom-pages/modules.vue +5 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupCatalog.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSpec.ts +18 -16
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/containers/drawerSize.ts +4 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/relationBadges.ts +2 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/form/fieldComponentProps.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/layout/sidePanelState.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/period/periodQuery.ts +6 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableRowActionValues.ts +13 -13
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/writeError.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +26 -18
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCatalog.ts +7 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +2 -0
- package/frontend-vue/layers/dms-ui/app/composables/useExportJob.ts +2 -2
- package/package.json +9 -8
- package/bin/control/verify/behaviour.mjs +0 -183
- package/bin/control/verify/behaviour.test.mjs +0 -472
- package/bin/control/verify/emit.mjs +0 -539
- package/bin/control/verify/judgement.mjs +0 -101
- package/bin/control/verify/verdict.mjs +0 -327
- package/frontend-vue/scripts/probes/capture-frontend-probe.cjs +0 -23
- package/frontend-vue/scripts/probes/frontend-behavior.cjs +0 -606
- package/frontend-vue/scripts/probes/frontend-legacy.cjs +0 -620
- package/frontend-vue/scripts/probes/frontend-probe-controls.cjs +0 -322
- package/frontend-vue/scripts/prove-comment-emit.mjs +0 -171
- package/frontend-vue/scripts/prove-component-registration.mjs +0 -259
|
@@ -1,606 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("node:fs");
|
|
4
|
-
const os = require("node:os");
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
const vm = require("node:vm");
|
|
7
|
-
const { execFileSync } = require("node:child_process");
|
|
8
|
-
const { createRequire } = require("node:module");
|
|
9
|
-
const { pathToFileURL } = require("node:url");
|
|
10
|
-
|
|
11
|
-
const legacy = require("./frontend-legacy.cjs");
|
|
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
|
-
}
|
|
59
|
-
|
|
60
|
-
async function autoImports() {
|
|
61
|
-
const buildReq = createRequire(
|
|
62
|
-
path.join(frontend, "node_modules/@antelopejs/dms-frontend/package.json"),
|
|
63
|
-
);
|
|
64
|
-
const templates = path.join(
|
|
65
|
-
path.dirname(buildReq.resolve("@antelopejs/dms-frontend/package.json")),
|
|
66
|
-
"templates/vue",
|
|
67
|
-
);
|
|
68
|
-
const { autoImportDirectories } = loadBuildLoader(
|
|
69
|
-
path.join(templates, "frontend-build-loader.ts"),
|
|
70
|
-
);
|
|
71
|
-
const buildFile = path.join(frontend, "dms.frontend.build.ts");
|
|
72
|
-
const { default: setup } = evaluateBuildFile(
|
|
73
|
-
fs.readFileSync(buildFile, "utf8"),
|
|
74
|
-
buildFile,
|
|
75
|
-
{},
|
|
76
|
-
{
|
|
77
|
-
"#dms/frontend-build": {
|
|
78
|
-
/** @param {unknown} value */
|
|
79
|
-
defineDmsFrontendBuild: (value) => value,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
const dirs = autoImportDirectories(
|
|
84
|
-
[{ id: "dms", root: frontend }],
|
|
85
|
-
[{ id: "dms", setup }],
|
|
86
|
-
(message) => {
|
|
87
|
-
throw new Error(message);
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
const { config, configuredImports } = templateImports(templates);
|
|
91
|
-
const defaults = defaultsVm.runInNewContext(
|
|
92
|
-
`[${configuredImports.elements
|
|
93
|
-
.filter(ts.isObjectLiteralExpression)
|
|
94
|
-
.map((node) => node.getText(config))
|
|
95
|
-
.join(",")} ]`.replaceAll("import.meta.dirname", "templateRoot"),
|
|
96
|
-
{
|
|
97
|
-
templateRoot: templates,
|
|
98
|
-
/** @param {unknown} value */
|
|
99
|
-
normalizePath: (value) => value,
|
|
100
|
-
resolve: path.resolve,
|
|
101
|
-
},
|
|
102
|
-
);
|
|
103
|
-
const { createUnimport } = await importUnimport(
|
|
104
|
-
pathToFileURL(buildReq.resolve("unimport")),
|
|
105
|
-
);
|
|
106
|
-
const importer = createUnimport({
|
|
107
|
-
dirs,
|
|
108
|
-
presets: configuredImports.elements
|
|
109
|
-
.filter(ts.isStringLiteral)
|
|
110
|
-
.map((node) => node.text),
|
|
111
|
-
imports: defaults.flatMap((value) =>
|
|
112
|
-
Object.entries(value).flatMap(([from, names]) =>
|
|
113
|
-
names.map((name) => ({ from, name })),
|
|
114
|
-
),
|
|
115
|
-
),
|
|
116
|
-
});
|
|
117
|
-
await importer.init();
|
|
118
|
-
const entries = await importer.getImports();
|
|
119
|
-
const injection = await importer.injectImports(
|
|
120
|
-
`void [${entries
|
|
121
|
-
.filter((entry) => !entry.type)
|
|
122
|
-
.map((entry) => entry.as ?? entry.name)
|
|
123
|
-
.join(",")}];`,
|
|
124
|
-
);
|
|
125
|
-
const injected = new Set(
|
|
126
|
-
injection.imports.map((entry) => entry.as ?? entry.name),
|
|
127
|
-
);
|
|
128
|
-
const temporary = fs.mkdtempSync(
|
|
129
|
-
path.join(os.tmpdir(), "frontend-signatures-"),
|
|
130
|
-
);
|
|
131
|
-
try {
|
|
132
|
-
fs.symlinkSync(
|
|
133
|
-
path.join(frontend, "node_modules"),
|
|
134
|
-
path.join(temporary, "node_modules"),
|
|
135
|
-
);
|
|
136
|
-
const globals = path.join(temporary, "globals.d.ts");
|
|
137
|
-
fs.writeFileSync(globals, await importer.generateTypeDeclarations());
|
|
138
|
-
const options = {
|
|
139
|
-
target: ts.ScriptTarget.ES2022,
|
|
140
|
-
module: ts.ModuleKind.ESNext,
|
|
141
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
142
|
-
strict: true,
|
|
143
|
-
skipLibCheck: true,
|
|
144
|
-
allowImportingTsExtensions: true,
|
|
145
|
-
resolveJsonModule: true,
|
|
146
|
-
types: [],
|
|
147
|
-
noEmit: true,
|
|
148
|
-
baseUrl: frontend,
|
|
149
|
-
paths: {
|
|
150
|
-
"#dms/frontend-module": [path.join(templates, "frontend-module.ts")],
|
|
151
|
-
...Object.fromEntries(
|
|
152
|
-
["auth", "core", "layout", "onboarding", "ui"].map((name) => [
|
|
153
|
-
`#dms-${name}/*`,
|
|
154
|
-
[path.join(frontend, `layers/dms-${name}/*`)],
|
|
155
|
-
]),
|
|
156
|
-
),
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
const files = entries
|
|
160
|
-
.filter((entry) => path.isAbsolute(entry.from))
|
|
161
|
-
.map((entry) => entry.from);
|
|
162
|
-
const program = ts.createProgram([...files, globals], options);
|
|
163
|
-
return signatures(program, { entries, globals, options, injected });
|
|
164
|
-
} finally {
|
|
165
|
-
fs.rmSync(temporary, { recursive: true, force: true });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
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 */
|
|
182
|
-
function describeTypes(program) {
|
|
183
|
-
const checker = program.getTypeChecker();
|
|
184
|
-
const flags =
|
|
185
|
-
ts.TypeFormatFlags.NoTruncation |
|
|
186
|
-
ts.TypeFormatFlags.InTypeAlias |
|
|
187
|
-
ts.TypeFormatFlags.UseStructuralFallback;
|
|
188
|
-
/** @type {Map<string, string>} */
|
|
189
|
-
const dictionaries = new Map();
|
|
190
|
-
for (const source of program.getSourceFiles()) {
|
|
191
|
-
for (const node of source.statements.filter(ts.isTypeAliasDeclaration)) {
|
|
192
|
-
if (
|
|
193
|
-
!source.fileName.startsWith(frontend) &&
|
|
194
|
-
!(
|
|
195
|
-
ts.isTypeReferenceNode(node.type) &&
|
|
196
|
-
node.type.typeName.getText(source) === "Record"
|
|
197
|
-
)
|
|
198
|
-
)
|
|
199
|
-
continue;
|
|
200
|
-
const type = checker.getTypeAtLocation(node);
|
|
201
|
-
const index = type.getStringIndexType();
|
|
202
|
-
if (
|
|
203
|
-
index &&
|
|
204
|
-
!type.getProperties().length &&
|
|
205
|
-
!type.getCallSignatures().length
|
|
206
|
-
)
|
|
207
|
-
dictionaries.set(
|
|
208
|
-
node.name.text,
|
|
209
|
-
`Record<string, ${checker.typeToString(index, undefined, flags)}>`,
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* @param {string} text
|
|
215
|
-
* @returns {string}
|
|
216
|
-
*/
|
|
217
|
-
const normalize = (text) => {
|
|
218
|
-
const normalized = text
|
|
219
|
-
.replaceAll(frontend.replaceAll("\\", "/"), "<frontend>")
|
|
220
|
-
.replace(/import\("[^"]*\/layers\/[^"]*"\)\./g, "")
|
|
221
|
-
.replace(/import\("[^"]*\/node_modules\/([^"]*)"\)\./g, "$1.")
|
|
222
|
-
.replace(
|
|
223
|
-
/\b[A-Za-z_$][\w$]*\b/g,
|
|
224
|
-
(name) => dictionaries.get(name) ?? name,
|
|
225
|
-
)
|
|
226
|
-
.replace(/\{ \[x: string\]: ([^;{}]+); \}/g, "Record<string, $1>")
|
|
227
|
-
.replace(/(__@\w+)@\d+/g, "$1")
|
|
228
|
-
.replace(/"[^"]+"(?: \| "[^"]+")+/g, (union) =>
|
|
229
|
-
union.split(" | ").sort().join(" | "),
|
|
230
|
-
);
|
|
231
|
-
const source = ts.createSourceFile(
|
|
232
|
-
"signature.ts",
|
|
233
|
-
`type Signature = ${normalized};`,
|
|
234
|
-
ts.ScriptTarget.Latest,
|
|
235
|
-
true,
|
|
236
|
-
);
|
|
237
|
-
const declaration = source.statements[0];
|
|
238
|
-
if (!hasParseDiagnostics(source))
|
|
239
|
-
throw new TypeError("The TypeScript parser reports no parse diagnostics");
|
|
240
|
-
if (
|
|
241
|
-
source.parseDiagnostics.length ||
|
|
242
|
-
!ts.isTypeAliasDeclaration(declaration) ||
|
|
243
|
-
!ts.isTypeLiteralNode(declaration.type) ||
|
|
244
|
-
!declaration.type.members.every(ts.isPropertySignature)
|
|
245
|
-
)
|
|
246
|
-
return normalized;
|
|
247
|
-
const members = [...declaration.type.members].sort((left, right) =>
|
|
248
|
-
left.name.getText(source).localeCompare(right.name.getText(source)),
|
|
249
|
-
);
|
|
250
|
-
return `{ ${members.map((member) => member.getText(source)).join(" ")} }`;
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
* @param {import("typescript").Type} type
|
|
254
|
-
* @param {Set<import("typescript").Type>} [seen]
|
|
255
|
-
* @returns {string}
|
|
256
|
-
*/
|
|
257
|
-
const describe = (type, seen = new Set()) => {
|
|
258
|
-
if (seen.has(type))
|
|
259
|
-
return normalize(checker.typeToString(type, undefined, flags));
|
|
260
|
-
const visited = new Set([...seen, type]);
|
|
261
|
-
if (type.isUnion())
|
|
262
|
-
return type.types
|
|
263
|
-
.map((member) => `(${describe(member, visited)})`)
|
|
264
|
-
.sort()
|
|
265
|
-
.join(" | ");
|
|
266
|
-
const index = type.getStringIndexType();
|
|
267
|
-
if (
|
|
268
|
-
index &&
|
|
269
|
-
!type.getProperties().length &&
|
|
270
|
-
!type.getCallSignatures().length
|
|
271
|
-
)
|
|
272
|
-
return `Record<string, ${describe(index, visited)}>`;
|
|
273
|
-
return normalize(checker.typeToString(type, undefined, flags));
|
|
274
|
-
};
|
|
275
|
-
return { describe, normalize };
|
|
276
|
-
}
|
|
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
|
-
*/
|
|
282
|
-
function signatures(program, { entries, globals, options, injected }) {
|
|
283
|
-
const checker = program.getTypeChecker();
|
|
284
|
-
const { describe, normalize } = describeTypes(program);
|
|
285
|
-
const inventory = entries.map((entry) => {
|
|
286
|
-
const from = path.isAbsolute(entry.from)
|
|
287
|
-
? entry.from
|
|
288
|
-
: ts.resolveModuleName(entry.from, globals, options, ts.sys)
|
|
289
|
-
.resolvedModule?.resolvedFileName;
|
|
290
|
-
const source = program.getSourceFile(from);
|
|
291
|
-
if (!source) throw new Error(`Missing auto-import source ${entry.from}`);
|
|
292
|
-
const owner = checker.getSymbolAtLocation(source);
|
|
293
|
-
const exported = (owner ? checker.getExportsOfModule(owner) : []).find(
|
|
294
|
-
(symbol) => symbol.name === entry.name,
|
|
295
|
-
);
|
|
296
|
-
const identity = {
|
|
297
|
-
name: entry.as ?? entry.name,
|
|
298
|
-
typeOnly: !!entry.type,
|
|
299
|
-
injected: !entry.type && injected.has(entry.as ?? entry.name),
|
|
300
|
-
};
|
|
301
|
-
if (!exported)
|
|
302
|
-
return {
|
|
303
|
-
...identity,
|
|
304
|
-
signature: "<unresolved export>",
|
|
305
|
-
declaration: normalize(source.getText()),
|
|
306
|
-
};
|
|
307
|
-
const symbol =
|
|
308
|
-
exported.flags & ts.SymbolFlags.Alias
|
|
309
|
-
? checker.getAliasedSymbol(exported)
|
|
310
|
-
: exported;
|
|
311
|
-
const declaration =
|
|
312
|
-
symbol.valueDeclaration ??
|
|
313
|
-
symbol.declarations?.[0] ??
|
|
314
|
-
exported.declarations[0];
|
|
315
|
-
const type =
|
|
316
|
-
symbol.flags & ts.SymbolFlags.Value
|
|
317
|
-
? checker.getTypeOfSymbolAtLocation(symbol, declaration)
|
|
318
|
-
: checker.getDeclaredTypeOfSymbol(symbol);
|
|
319
|
-
return {
|
|
320
|
-
...identity,
|
|
321
|
-
signature: describe(type),
|
|
322
|
-
members:
|
|
323
|
-
entry.type ||
|
|
324
|
-
type.getConstructSignatures().length ||
|
|
325
|
-
symbol.flags & ts.SymbolFlags.Enum
|
|
326
|
-
? type
|
|
327
|
-
.getProperties()
|
|
328
|
-
.map((member) => ({
|
|
329
|
-
name: member.name.replace(/(__@\w+)@\d+/g, "$1"),
|
|
330
|
-
optional: !!(member.flags & ts.SymbolFlags.Optional),
|
|
331
|
-
signature: describe(
|
|
332
|
-
checker.getTypeOfSymbolAtLocation(member, declaration),
|
|
333
|
-
),
|
|
334
|
-
}))
|
|
335
|
-
.sort((left, right) => left.name.localeCompare(right.name))
|
|
336
|
-
: [],
|
|
337
|
-
};
|
|
338
|
-
});
|
|
339
|
-
return [
|
|
340
|
-
...new Map(
|
|
341
|
-
inventory.map((entry) => [JSON.stringify(entry), entry]),
|
|
342
|
-
).values(),
|
|
343
|
-
].sort((left, right) =>
|
|
344
|
-
JSON.stringify(left).localeCompare(JSON.stringify(right)),
|
|
345
|
-
);
|
|
346
|
-
}
|
|
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
|
-
|
|
377
|
-
function registrations() {
|
|
378
|
-
/** @type {unknown[][]} */
|
|
379
|
-
const events = [];
|
|
380
|
-
/**
|
|
381
|
-
* @param {string} file
|
|
382
|
-
* @returns {FrontendEntry}
|
|
383
|
-
*/
|
|
384
|
-
const evaluateEntry = (file) => {
|
|
385
|
-
/** @type {import("typescript").TransformerFactory<import("typescript").SourceFile>} */
|
|
386
|
-
const transform = (context) => (node) => {
|
|
387
|
-
/** @type {import("typescript").Visitor} */
|
|
388
|
-
const visit = (node) => {
|
|
389
|
-
if (
|
|
390
|
-
ts.isPropertyAccessExpression(node) &&
|
|
391
|
-
node.getText().startsWith("import.meta.env.")
|
|
392
|
-
)
|
|
393
|
-
return ts.factory.createFalse();
|
|
394
|
-
if (
|
|
395
|
-
ts.isCallExpression(node) &&
|
|
396
|
-
node.expression.getText() === "import.meta.glob"
|
|
397
|
-
) {
|
|
398
|
-
const arg = node.arguments[0];
|
|
399
|
-
const patterns = ts.isArrayLiteralExpression(arg)
|
|
400
|
-
? arg.elements.map(patternText)
|
|
401
|
-
: [patternText(arg)];
|
|
402
|
-
const files = fs.globSync(
|
|
403
|
-
patterns.filter((pattern) => !pattern.startsWith("!")),
|
|
404
|
-
{
|
|
405
|
-
cwd: path.dirname(file),
|
|
406
|
-
exclude: patterns
|
|
407
|
-
.filter((pattern) => pattern.startsWith("!"))
|
|
408
|
-
.map((pattern) => pattern.slice(1)),
|
|
409
|
-
},
|
|
410
|
-
);
|
|
411
|
-
return ts.factory.createObjectLiteralExpression(
|
|
412
|
-
files.map((file) =>
|
|
413
|
-
ts.factory.createPropertyAssignment(
|
|
414
|
-
ts.factory.createStringLiteral(
|
|
415
|
-
file.startsWith(".") ? file : `./${file}`,
|
|
416
|
-
),
|
|
417
|
-
ts.factory.createIdentifier("probeLoader"),
|
|
418
|
-
),
|
|
419
|
-
),
|
|
420
|
-
);
|
|
421
|
-
}
|
|
422
|
-
return ts.visitEachChild(node, visit, context);
|
|
423
|
-
};
|
|
424
|
-
return ts.visitNode(node, visit);
|
|
425
|
-
};
|
|
426
|
-
const imports = new Proxy(
|
|
427
|
-
{},
|
|
428
|
-
{
|
|
429
|
-
has: () => true,
|
|
430
|
-
get: (_, name) => {
|
|
431
|
-
if (name === "vue")
|
|
432
|
-
return { defineAsyncComponent: () => ({ loader: true }) };
|
|
433
|
-
if (name === "#dms/frontend-module")
|
|
434
|
-
return { useDmsRuntimeConfig: () => ({ public: {} }) };
|
|
435
|
-
const specifier = String(name);
|
|
436
|
-
if (specifier.startsWith(".")) {
|
|
437
|
-
const target = path.resolve(path.dirname(file), specifier);
|
|
438
|
-
if (target.includes("/app/entries"))
|
|
439
|
-
return evaluateEntry(
|
|
440
|
-
target.endsWith(".ts") ? target : `${target}.ts`,
|
|
441
|
-
);
|
|
442
|
-
}
|
|
443
|
-
return { default: name, __esModule: true };
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
);
|
|
447
|
-
return evaluateFrontendEntry(
|
|
448
|
-
fs.readFileSync(file, "utf8"),
|
|
449
|
-
file,
|
|
450
|
-
{ probeLoader: () => {} },
|
|
451
|
-
imports,
|
|
452
|
-
{ before: [transform] },
|
|
453
|
-
);
|
|
454
|
-
};
|
|
455
|
-
const module = evaluateEntry(path.join(frontend, "dms.frontend.ts")).default;
|
|
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
|
-
]);
|
|
466
|
-
},
|
|
467
|
-
});
|
|
468
|
-
module.setup(sdk);
|
|
469
|
-
const registerFile = path.join(layers, "dms-ui/app/plugins/register.ts");
|
|
470
|
-
const registrations = new Proxy(
|
|
471
|
-
{},
|
|
472
|
-
{
|
|
473
|
-
has: () => true,
|
|
474
|
-
get: () =>
|
|
475
|
-
new Proxy(
|
|
476
|
-
{},
|
|
477
|
-
{ get: (_, name) => () => events.push(["register", String(name)]) },
|
|
478
|
-
),
|
|
479
|
-
},
|
|
480
|
-
);
|
|
481
|
-
evaluateRegister(
|
|
482
|
-
fs.readFileSync(registerFile, "utf8"),
|
|
483
|
-
registerFile,
|
|
484
|
-
{
|
|
485
|
-
/** @param {unknown} setup */
|
|
486
|
-
defineDmsPlugin: (setup) => setup,
|
|
487
|
-
},
|
|
488
|
-
registrations,
|
|
489
|
-
).default();
|
|
490
|
-
return events;
|
|
491
|
-
}
|
|
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
|
-
|
|
552
|
-
function behavioralTests() {
|
|
553
|
-
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "frontend-tests-"));
|
|
554
|
-
const report = path.join(temporary, "report.json");
|
|
555
|
-
try {
|
|
556
|
-
const tests =
|
|
557
|
-
`download-action-target table-row-action-errors table-metric-cells table-pills-cell table-view-sources table-view-reorder table-view-expanded-row-details repeater-table form-create-wording form-submit-clear form-server-field-errors instant-save site-layout-resync site-layout-refresh realtime-shared-connection permission-preview`
|
|
558
|
-
.split(" ")
|
|
559
|
-
.map((name) => `tests/${name}.test.ts`);
|
|
560
|
-
execFileSync(
|
|
561
|
-
"pnpm",
|
|
562
|
-
[
|
|
563
|
-
"exec",
|
|
564
|
-
"vitest",
|
|
565
|
-
"run",
|
|
566
|
-
...tests,
|
|
567
|
-
"--maxWorkers=2",
|
|
568
|
-
"--reporter=json",
|
|
569
|
-
`--outputFile=${report}`,
|
|
570
|
-
],
|
|
571
|
-
{ cwd: frontend, stdio: "pipe", maxBuffer: 16 * 1024 * 1024 },
|
|
572
|
-
);
|
|
573
|
-
/** @type {unknown} */
|
|
574
|
-
const result = JSON.parse(fs.readFileSync(report, "utf8"));
|
|
575
|
-
if (!isVitestReport(result) || !result.success)
|
|
576
|
-
throw new Error("Frontend behavioral tests failed");
|
|
577
|
-
return result.testResults
|
|
578
|
-
.flatMap((file) =>
|
|
579
|
-
file.assertionResults.map((test) => ({
|
|
580
|
-
name: test.fullName,
|
|
581
|
-
status: test.status,
|
|
582
|
-
})),
|
|
583
|
-
)
|
|
584
|
-
.sort((left, right) => left.name.localeCompare(right.name));
|
|
585
|
-
} finally {
|
|
586
|
-
fs.rmSync(temporary, { recursive: true, force: true });
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
(async () => {
|
|
591
|
-
/** @type {Awaited<ReturnType<typeof legacy.observe>> & { autoImports: Awaited<ReturnType<typeof autoImports>>; registrations: ReturnType<typeof registrations>; behavioralTests?: ReturnType<typeof behavioralTests> }} */
|
|
592
|
-
const result = {
|
|
593
|
-
...(await legacy.observe()),
|
|
594
|
-
autoImports: await autoImports(),
|
|
595
|
-
registrations: registrations(),
|
|
596
|
-
};
|
|
597
|
-
if (process.argv.includes("--tests"))
|
|
598
|
-
result.behavioralTests = behavioralTests();
|
|
599
|
-
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
600
|
-
})().catch(
|
|
601
|
-
/** @param {unknown} error */
|
|
602
|
-
(error) => {
|
|
603
|
-
process.stderr.write(`${hasStack(error) ? error.stack : undefined}\n`);
|
|
604
|
-
process.exitCode = 1;
|
|
605
|
-
},
|
|
606
|
-
);
|