@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
|
@@ -2,14 +2,59 @@ import { readFileSync, globSync } from "node:fs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join, relative, resolve, basename, sep } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { compileFunction } from "node:vm";
|
|
5
6
|
import ts from "typescript";
|
|
6
7
|
import { parse } from "vue/compiler-sfc";
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {object} ScannedExport
|
|
11
|
+
* @property {string} name
|
|
12
|
+
* @property {string} from
|
|
13
|
+
* @property {string} [as]
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {object} UnimportModule
|
|
18
|
+
* @property {(directories: string[]) => Promise<ScannedExport[]>} scanDirExports
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @typedef {object} BuildRegistration
|
|
23
|
+
* @property {(directories: string[]) => void} registerAutoImports
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {object} LayerRoot
|
|
28
|
+
* @property {string} id
|
|
29
|
+
* @property {string} root
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @typedef {object} LayerSetup
|
|
34
|
+
* @property {string} id
|
|
35
|
+
* @property {(build: BuildRegistration) => void} setup
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {(layers: LayerRoot[], setups: LayerSetup[], fail: (message: string) => never) => string[]} AutoImportDirectories
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/** @typedef {NonNullable<NonNullable<import("vue/compiler-sfc").SFCDescriptor["template"]>["ast"]>} TemplateRoot */
|
|
43
|
+
/** @typedef {TemplateRoot | TemplateRoot["children"][number]} TemplateNode */
|
|
44
|
+
/** @typedef {{ base: string, patterns: string[] }} ComponentGlob */
|
|
45
|
+
/** @typedef {{ file: string, name: string }} NamedImport */
|
|
46
|
+
|
|
8
47
|
const frontend = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
48
|
const root = resolve(frontend, "../../..");
|
|
10
49
|
const require = createRequire(import.meta.url);
|
|
50
|
+
/** @param {string} path */
|
|
11
51
|
const posixPath = (path) => path.split(sep).join("/");
|
|
12
|
-
|
|
52
|
+
/** @type {(id: string) => import("../../../../.dependency-cruiser.cjs").Area} */
|
|
53
|
+
const loadArea = createRequire(import.meta.url);
|
|
54
|
+
const rules = loadArea(
|
|
55
|
+
"../../../../.dependency-cruiser/frontend.cjs",
|
|
56
|
+
).forbidden;
|
|
57
|
+
/** @type {(id: string) => UnimportModule} */
|
|
13
58
|
const importer = createRequire(require.resolve("unplugin-auto-import"));
|
|
14
59
|
const { scanDirExports } = importer("unimport");
|
|
15
60
|
const loader = join(
|
|
@@ -19,19 +64,37 @@ const loader = join(
|
|
|
19
64
|
const compiled = ts.transpileModule(readFileSync(loader, "utf8"), {
|
|
20
65
|
compilerOptions: { module: ts.ModuleKind.CommonJS },
|
|
21
66
|
}).outputText;
|
|
67
|
+
/** @type {{ autoImportDirectories?: AutoImportDirectories }} */
|
|
22
68
|
const loaderExports = {};
|
|
23
|
-
|
|
69
|
+
compileFunction(compiled, ["require", "exports"]).call(
|
|
70
|
+
undefined,
|
|
24
71
|
createRequire(loader),
|
|
25
72
|
loaderExports,
|
|
26
73
|
);
|
|
27
74
|
const { autoImportDirectories } = loaderExports;
|
|
75
|
+
if (!autoImportDirectories)
|
|
76
|
+
throw new Error(`${loader} does not export autoImportDirectories`);
|
|
28
77
|
const declaration = ts.createSourceFile(
|
|
29
78
|
"build.ts",
|
|
30
79
|
readFileSync(join(frontend, "dms.frontend.build.ts"), "utf8"),
|
|
31
80
|
ts.ScriptTarget.Latest,
|
|
32
81
|
true,
|
|
33
82
|
);
|
|
83
|
+
/**
|
|
84
|
+
* @param {readonly ts.Node[]} nodes
|
|
85
|
+
* @returns {string[] | undefined}
|
|
86
|
+
*/
|
|
87
|
+
function literalTexts(nodes) {
|
|
88
|
+
const texts = [];
|
|
89
|
+
for (const node of nodes) {
|
|
90
|
+
if (!ts.isStringLiteral(node)) return undefined;
|
|
91
|
+
texts.push(node.text);
|
|
92
|
+
}
|
|
93
|
+
return texts;
|
|
94
|
+
}
|
|
95
|
+
/** @type {string[]} */
|
|
34
96
|
const directories = [];
|
|
97
|
+
/** @param {ts.Node} node */
|
|
35
98
|
function declared(node) {
|
|
36
99
|
if (
|
|
37
100
|
ts.isCallExpression(node) &&
|
|
@@ -39,14 +102,14 @@ function declared(node) {
|
|
|
39
102
|
node.expression.name.text === "registerAutoImports"
|
|
40
103
|
) {
|
|
41
104
|
const entries = node.arguments[0];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)
|
|
105
|
+
const texts = ts.isArrayLiteralExpression(entries)
|
|
106
|
+
? literalTexts(entries.elements)
|
|
107
|
+
: undefined;
|
|
108
|
+
if (texts === undefined)
|
|
46
109
|
throw new Error(
|
|
47
110
|
"Auto-import audit requires literal declared directories",
|
|
48
111
|
);
|
|
49
|
-
directories.push(...
|
|
112
|
+
directories.push(...texts);
|
|
50
113
|
}
|
|
51
114
|
ts.forEachChild(node, declared);
|
|
52
115
|
}
|
|
@@ -63,8 +126,15 @@ const globs = autoImportDirectories(
|
|
|
63
126
|
throw new Error(message);
|
|
64
127
|
},
|
|
65
128
|
);
|
|
129
|
+
/** @type {Map<string, Set<string>>} */
|
|
66
130
|
const owners = new Map();
|
|
131
|
+
/** @type {Map<string, Set<string>>} */
|
|
67
132
|
const components = new Map();
|
|
133
|
+
/**
|
|
134
|
+
* @param {string} name
|
|
135
|
+
* @param {string} path
|
|
136
|
+
* @param {Map<string, Set<string>>} [registry]
|
|
137
|
+
*/
|
|
68
138
|
function own(name, path, registry = owners) {
|
|
69
139
|
const file = posixPath(path);
|
|
70
140
|
const layer = /\/layers\/dms-([^/]+)\//.exec(file)?.[1];
|
|
@@ -73,13 +143,16 @@ function own(name, path, registry = owners) {
|
|
|
73
143
|
entries.add(file);
|
|
74
144
|
registry.set(name, entries);
|
|
75
145
|
}
|
|
146
|
+
/** @type {string[]} */
|
|
76
147
|
const unresolved = [];
|
|
77
148
|
const warn = console.warn;
|
|
149
|
+
/** @param {unknown[]} args */
|
|
78
150
|
console.warn = (...args) => {
|
|
79
151
|
const message = args.join(" ");
|
|
80
152
|
if (message.startsWith("[unimport]")) unresolved.push(message);
|
|
81
153
|
else warn(...args);
|
|
82
154
|
};
|
|
155
|
+
/** @type {ScannedExport[]} */
|
|
83
156
|
let scanned;
|
|
84
157
|
try {
|
|
85
158
|
scanned = await scanDirExports(globs);
|
|
@@ -97,9 +170,16 @@ const registry = ts.createSourceFile(
|
|
|
97
170
|
ts.ScriptTarget.Latest,
|
|
98
171
|
true,
|
|
99
172
|
);
|
|
173
|
+
/** @type {ComponentGlob[]} */
|
|
100
174
|
const componentGlobs = [];
|
|
175
|
+
/** @type {Map<string, string>} */
|
|
101
176
|
const componentAliases = new Map();
|
|
177
|
+
/** @type {Set<string>} */
|
|
102
178
|
const registryBindings = new Set();
|
|
179
|
+
/**
|
|
180
|
+
* @param {string} file
|
|
181
|
+
* @param {string} name
|
|
182
|
+
*/
|
|
103
183
|
function registryBinding(file, name) {
|
|
104
184
|
const key = `${file}:${name}`;
|
|
105
185
|
if (registryBindings.has(key)) return;
|
|
@@ -110,13 +190,17 @@ function registryBinding(file, name) {
|
|
|
110
190
|
ts.ScriptTarget.Latest,
|
|
111
191
|
true,
|
|
112
192
|
);
|
|
193
|
+
/** @type {Map<string, ts.Expression | undefined>} */
|
|
113
194
|
const bindings = new Map();
|
|
195
|
+
/** @type {Map<string, NamedImport>} */
|
|
114
196
|
const imports = new Map();
|
|
197
|
+
/** @param {ts.Node} node */
|
|
115
198
|
const declarations = (node) => {
|
|
116
199
|
if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name))
|
|
117
200
|
bindings.set(node.name.text, node.initializer);
|
|
118
201
|
if (
|
|
119
202
|
ts.isImportDeclaration(node) &&
|
|
203
|
+
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
120
204
|
node.moduleSpecifier.text.startsWith(".")
|
|
121
205
|
) {
|
|
122
206
|
const named = node.importClause?.namedBindings;
|
|
@@ -130,6 +214,7 @@ function registryBinding(file, name) {
|
|
|
130
214
|
ts.forEachChild(node, declarations);
|
|
131
215
|
};
|
|
132
216
|
declarations(source);
|
|
217
|
+
/** @param {ts.Node | undefined} node */
|
|
133
218
|
const expression = (node) => {
|
|
134
219
|
if (!node) return;
|
|
135
220
|
if (
|
|
@@ -137,15 +222,14 @@ function registryBinding(file, name) {
|
|
|
137
222
|
node.expression.getText() === "import.meta.glob"
|
|
138
223
|
) {
|
|
139
224
|
const argument = node.arguments[0];
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
225
|
+
const patterns = literalTexts(
|
|
226
|
+
ts.isArrayLiteralExpression(argument)
|
|
227
|
+
? [...argument.elements]
|
|
228
|
+
: [argument],
|
|
229
|
+
);
|
|
230
|
+
if (patterns === undefined)
|
|
144
231
|
throw new Error("Component audit requires literal discovery globs");
|
|
145
|
-
componentGlobs.push({
|
|
146
|
-
base: dirname(file),
|
|
147
|
-
patterns: entries.map((entry) => entry.text),
|
|
148
|
-
});
|
|
232
|
+
componentGlobs.push({ base: dirname(file), patterns });
|
|
149
233
|
return;
|
|
150
234
|
}
|
|
151
235
|
if (ts.isIdentifier(node)) {
|
|
@@ -157,10 +241,12 @@ function registryBinding(file, name) {
|
|
|
157
241
|
};
|
|
158
242
|
expression(bindings.get(name));
|
|
159
243
|
}
|
|
244
|
+
/** @param {ts.Node} node */
|
|
160
245
|
function registered(node) {
|
|
161
246
|
if (
|
|
162
247
|
ts.isVariableDeclaration(node) &&
|
|
163
248
|
node.name.getText() === "COMPONENT_ALIASES" &&
|
|
249
|
+
node.initializer &&
|
|
164
250
|
ts.isObjectLiteralExpression(node.initializer)
|
|
165
251
|
) {
|
|
166
252
|
for (const property of node.initializer.properties)
|
|
@@ -191,10 +277,12 @@ for (const { base, patterns } of componentGlobs)
|
|
|
191
277
|
.map((part) => part[0].toUpperCase() + part.slice(1))
|
|
192
278
|
.join("");
|
|
193
279
|
own(name, file, components);
|
|
194
|
-
|
|
195
|
-
|
|
280
|
+
const alias = componentAliases.get(name);
|
|
281
|
+
if (alias !== undefined) own(alias, file, components);
|
|
196
282
|
}
|
|
283
|
+
/** @type {Map<string, string>} */
|
|
197
284
|
const sources = new Map();
|
|
285
|
+
/** @type {Map<string, number>} */
|
|
198
286
|
const templateOffsets = new Map();
|
|
199
287
|
for (const file of globSync(
|
|
200
288
|
join(frontend, "layers/**/*.{ts,tsx,js,mjs,vue}"),
|
|
@@ -203,10 +291,13 @@ for (const file of globSync(
|
|
|
203
291
|
let text = readFileSync(file, "utf8");
|
|
204
292
|
if (file.endsWith(".vue")) {
|
|
205
293
|
const { descriptor } = parse(text, { filename: file });
|
|
294
|
+
/** @type {string[]} */
|
|
206
295
|
const tags = [];
|
|
296
|
+
/** @param {TemplateNode} node */
|
|
207
297
|
const template = (node) => {
|
|
208
298
|
if (node.type === 1 && node.tagType === 1) tags.push(node.tag);
|
|
209
|
-
|
|
299
|
+
if (node.type === 0 || node.type === 1)
|
|
300
|
+
for (const child of node.children) template(child);
|
|
210
301
|
};
|
|
211
302
|
if (descriptor.template?.ast) template(descriptor.template.ast);
|
|
212
303
|
text = [descriptor.script?.content, descriptor.scriptSetup?.content]
|
|
@@ -233,24 +324,47 @@ for (const file of globSync(
|
|
|
233
324
|
}
|
|
234
325
|
const options = { noLib: true, noResolve: true };
|
|
235
326
|
const host = ts.createCompilerHost(options);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
327
|
+
/**
|
|
328
|
+
* @param {string} file
|
|
329
|
+
* @param {ts.ScriptTarget | ts.CreateSourceFileOptions} version
|
|
330
|
+
*/
|
|
331
|
+
host.getSourceFile = (file, version) => {
|
|
332
|
+
const text = sources.get(file);
|
|
333
|
+
return text === undefined
|
|
334
|
+
? undefined
|
|
335
|
+
: ts.createSourceFile(file, text, version, true);
|
|
336
|
+
};
|
|
240
337
|
const program = ts.createProgram([...sources.keys()], options, host);
|
|
241
338
|
const checker = program.getTypeChecker();
|
|
339
|
+
/**
|
|
340
|
+
* @param {(typeof rules)[number]["from"]} condition
|
|
341
|
+
* @param {string} path
|
|
342
|
+
*/
|
|
242
343
|
function matches(condition, path) {
|
|
243
344
|
return (
|
|
244
|
-
(!condition.path || new RegExp(condition.path).test(path)) &&
|
|
245
|
-
(!condition.pathNot || !new RegExp(condition.pathNot).test(path))
|
|
345
|
+
(!condition.path || new RegExp(String(condition.path)).test(path)) &&
|
|
346
|
+
(!condition.pathNot || !new RegExp(String(condition.pathNot)).test(path))
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
/** @param {(typeof rules)[number]["to"]} to */
|
|
350
|
+
function requiresLocalDependency(to) {
|
|
351
|
+
return (
|
|
352
|
+
"dependencyTypes" in to &&
|
|
353
|
+
Array.isArray(to.dependencyTypes) &&
|
|
354
|
+
to.dependencyTypes.includes("local")
|
|
246
355
|
);
|
|
247
356
|
}
|
|
248
357
|
let failures = 0;
|
|
358
|
+
/**
|
|
359
|
+
* @param {string} caller
|
|
360
|
+
* @param {string} name
|
|
361
|
+
* @param {string} owner
|
|
362
|
+
*/
|
|
249
363
|
function checkOwner(caller, name, owner) {
|
|
250
364
|
const target = posixPath(relative(root, owner));
|
|
251
365
|
for (const rule of rules) {
|
|
252
366
|
if (
|
|
253
|
-
rule.to
|
|
367
|
+
requiresLocalDependency(rule.to) ||
|
|
254
368
|
!matches(rule.from, caller) ||
|
|
255
369
|
!matches(rule.to, target)
|
|
256
370
|
)
|
|
@@ -265,14 +379,16 @@ for (const file of program.getSourceFiles()) {
|
|
|
265
379
|
const caller = posixPath(
|
|
266
380
|
relative(root, file.fileName.replace(/\.audit\.ts$/, "")),
|
|
267
381
|
);
|
|
382
|
+
/** @param {ts.Node} node */
|
|
268
383
|
const visit = (node) => {
|
|
269
384
|
const registry =
|
|
270
385
|
node.pos >= (templateOffsets.get(file.fileName) ?? Infinity)
|
|
271
386
|
? components
|
|
272
387
|
: owners;
|
|
388
|
+
const holders = ts.isIdentifier(node) ? registry.get(node.text) : undefined;
|
|
273
389
|
if (
|
|
274
390
|
ts.isIdentifier(node) &&
|
|
275
|
-
|
|
391
|
+
holders &&
|
|
276
392
|
!checker.getSymbolAtLocation(node)
|
|
277
393
|
) {
|
|
278
394
|
const parent = node.parent;
|
|
@@ -283,7 +399,7 @@ for (const file of program.getSourceFiles()) {
|
|
|
283
399
|
ts.isPropertySignature(parent)) &&
|
|
284
400
|
parent.name === node;
|
|
285
401
|
if (!property)
|
|
286
|
-
for (const owner of
|
|
402
|
+
for (const owner of holders) {
|
|
287
403
|
checkOwner(caller, node.text, owner);
|
|
288
404
|
}
|
|
289
405
|
}
|
|
@@ -19,7 +19,13 @@ const SCRIPT_EXTENSIONS = new Set([
|
|
|
19
19
|
const DIRECTIVE =
|
|
20
20
|
/^(oxlint|eslint)-(disable|enable)(?:\s+(.*?))?\s*(?:--.*)?$/su;
|
|
21
21
|
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Every comment of a script, each once, in source order.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} source
|
|
26
|
+
* @param {string} file
|
|
27
|
+
* @returns {{ line: number; text: string }[]}
|
|
28
|
+
*/
|
|
23
29
|
function commentsOf(source, file) {
|
|
24
30
|
const kind = /\.[jt]sx$/u.test(file) ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
25
31
|
const tree = ts.createSourceFile(
|
|
@@ -29,7 +35,9 @@ function commentsOf(source, file) {
|
|
|
29
35
|
true,
|
|
30
36
|
kind,
|
|
31
37
|
);
|
|
38
|
+
/** @type {Map<number, import("typescript").CommentRange>} */
|
|
32
39
|
const ranges = new Map();
|
|
40
|
+
/** @param {import("typescript").Node} node */
|
|
33
41
|
const collect = (node) => {
|
|
34
42
|
for (const range of [
|
|
35
43
|
...(ts.getLeadingCommentRanges(source, node.getFullStart()) ?? []),
|
|
@@ -51,9 +59,18 @@ function commentsOf(source, file) {
|
|
|
51
59
|
}));
|
|
52
60
|
}
|
|
53
61
|
|
|
54
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* The block directives a script leaves open at its end.
|
|
64
|
+
*
|
|
65
|
+
* @param {string} source
|
|
66
|
+
* @param {string} file
|
|
67
|
+
* @param {number} lineOffset
|
|
68
|
+
* @returns {string[]}
|
|
69
|
+
*/
|
|
55
70
|
function unclosedBlocks(source, file, lineOffset) {
|
|
71
|
+
/** @type {Map<string, string>} */
|
|
56
72
|
const open = new Map();
|
|
73
|
+
/** @type {string[]} */
|
|
57
74
|
const failures = [];
|
|
58
75
|
for (const { line, text } of commentsOf(source, file)) {
|
|
59
76
|
const match = DIRECTIVE.exec(text);
|
|
@@ -65,7 +82,7 @@ function unclosedBlocks(source, file, lineOffset) {
|
|
|
65
82
|
for (const rule of rules.length ? rules : ["*"])
|
|
66
83
|
if (!open.has(`${tool} ${rule}`)) open.set(`${tool} ${rule}`, at);
|
|
67
84
|
} else if (!rules.length) {
|
|
68
|
-
for (const key of
|
|
85
|
+
for (const key of open.keys())
|
|
69
86
|
if (key.startsWith(`${tool} `)) open.delete(key);
|
|
70
87
|
} else {
|
|
71
88
|
for (const rule of rules)
|
|
@@ -85,7 +102,12 @@ function unclosedBlocks(source, file, lineOffset) {
|
|
|
85
102
|
return failures;
|
|
86
103
|
}
|
|
87
104
|
|
|
88
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* The unclosed block directives of one authored file.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} file
|
|
109
|
+
* @returns {string[]}
|
|
110
|
+
*/
|
|
89
111
|
function checkFile(file) {
|
|
90
112
|
const source = readFileSync(join(ROOT, file), "utf8");
|
|
91
113
|
if (!/(?:oxlint|eslint)-(?:disable|enable)/u.test(source)) return [];
|