@holistics/anfra-sdk 0.13.5 → 0.14.1
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/README.md +1 -1
- package/dist/app.d.ts +4 -3
- package/dist/app.js +17 -7
- package/dist/{bootstrap-BbsNvZ8s.d.ts → bootstrap-MhTSkiA1.d.ts} +96 -3
- package/dist/build.d.ts +2 -0
- package/dist/chunk-A3LNZMT6.js +10 -0
- package/dist/chunk-CYZQ7ZTJ.js +237 -0
- package/dist/chunk-DITKCHFQ.js +166 -0
- package/dist/chunk-F6MRA7J4.js +65 -0
- package/dist/chunk-GBXK7F2V.js +431 -0
- package/dist/chunk-GOUDXWG4.js +750 -0
- package/dist/chunk-GV7SVWEK.js +84 -0
- package/dist/chunk-H52PO7MP.js +105 -0
- package/dist/chunk-HI3ZAXJK.js +8 -0
- package/dist/{chunk-KI5CAVAR.js → chunk-HRV45ULB.js} +477 -25
- package/dist/chunk-K633QHGO.js +51 -0
- package/dist/chunk-KFD6CHLI.js +38 -0
- package/dist/{chunk-OJ5WIKWE.js → chunk-Q46CZIEK.js} +1 -1
- package/dist/{chunk-ADWBOQW2.js → chunk-S6XLP6U4.js} +31 -1
- package/dist/{chunk-TQ7S5DRE.js → chunk-WI5VJ2Z6.js} +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +14 -4
- package/dist/data-UCCW2VWH.js +233 -0
- package/dist/declaration-GVDOGQY6.js +218 -0
- package/dist/host.d.ts +42 -4
- package/dist/host.js +412 -9
- package/dist/menu-CdGVKc4_.d.ts +151 -0
- package/dist/overview-XXND2V5V.js +358 -0
- package/dist/plugin-BmIDirTx.d.ts +303 -0
- package/dist/plugins.d.ts +6 -8
- package/dist/plugins.js +98 -69
- package/dist/queries-2OHKMTPC.js +661 -0
- package/dist/structure-WRDUXHD4.js +256 -0
- package/dist/tab-HMQOITVM.js +932 -0
- package/dist/testing.js +4 -4
- package/package.json +1 -1
- package/dist/bridge-WC7GliCH.d.ts +0 -73
- package/dist/chunk-33B2D4U5.js +0 -6
- package/dist/plugin-056-SKwd.d.ts +0 -132
- /package/dist/{chunk-52LXBYQM.js → chunk-UUKXJSE4.js} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
wiringChecks
|
|
3
|
+
} from "./chunk-K633QHGO.js";
|
|
4
|
+
import {
|
|
5
|
+
formatCondition,
|
|
6
|
+
handleFor
|
|
7
|
+
} from "./chunk-H52PO7MP.js";
|
|
8
|
+
|
|
9
|
+
// src/plugins/inspect/model/changes.ts
|
|
10
|
+
function originalCondition(app, name, kind) {
|
|
11
|
+
if (kind === "dateDrill") {
|
|
12
|
+
const grain = app.declaration.dateDrills[name]?.default;
|
|
13
|
+
return grain ? { operator: "transform_date_drill", values: [`datetrunc ${grain}`] } : { operator: "none" };
|
|
14
|
+
}
|
|
15
|
+
return app.declaration.filters[name]?.default ?? { operator: "is", values: [] };
|
|
16
|
+
}
|
|
17
|
+
var same = (a, b) => a.operator === b.operator && (a.modifier ?? "") === (b.modifier ?? "") && JSON.stringify((a.values ?? []).map(String)) === JSON.stringify((b.values ?? []).map(String));
|
|
18
|
+
function describe(condition) {
|
|
19
|
+
if (condition.operator === "none") return "none";
|
|
20
|
+
if (condition.operator === "transform_date_drill") {
|
|
21
|
+
return String(condition.values?.[0] ?? "").replace("datetrunc ", "") || "none";
|
|
22
|
+
}
|
|
23
|
+
return (condition.values ?? []).length === 0 && condition.operator === "is" ? "no value" : formatCondition(condition);
|
|
24
|
+
}
|
|
25
|
+
var isChanged = (app, name, control) => !same(originalCondition(app, name, control.kind), control.condition);
|
|
26
|
+
function changesOf(apps) {
|
|
27
|
+
return apps.flatMap(
|
|
28
|
+
(app, index) => Object.entries(app.controls).flatMap(([name, control]) => {
|
|
29
|
+
const original = originalCondition(app, name, control.kind);
|
|
30
|
+
return same(original, control.condition) ? [] : [
|
|
31
|
+
{
|
|
32
|
+
app: index,
|
|
33
|
+
name,
|
|
34
|
+
kind: control.kind,
|
|
35
|
+
from: describe(original),
|
|
36
|
+
to: describe(control.condition)
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/plugins/inspect/model/issues.ts
|
|
44
|
+
function problemNodes(nodes) {
|
|
45
|
+
return nodes.flatMap((node) => [...node.problems.length ? [node] : [], ...problemNodes(node.children)]);
|
|
46
|
+
}
|
|
47
|
+
function appIssues(app, index, checks = wiringChecks(app)) {
|
|
48
|
+
const issues = [];
|
|
49
|
+
for (const [name, query] of Object.entries(app.queries)) {
|
|
50
|
+
if (query.state !== "error") continue;
|
|
51
|
+
issues.push({ level: "error", message: `${name} failed: ${query.error?.message ?? "no message"}`, target: { entity: "query", app: index, name } });
|
|
52
|
+
}
|
|
53
|
+
checks.forEach((check, i) => {
|
|
54
|
+
if (check.level === "info") return;
|
|
55
|
+
issues.push({ level: check.level, message: check.message, target: { check: i, app: index } });
|
|
56
|
+
});
|
|
57
|
+
return issues;
|
|
58
|
+
}
|
|
59
|
+
function issuesOf(snapshot, checks) {
|
|
60
|
+
const issues = snapshot.apps.flatMap((app, index) => appIssues(app, index, checks?.[index]));
|
|
61
|
+
for (const node of problemNodes(snapshot.structure.nodes)) {
|
|
62
|
+
for (const problem of node.problems) issues.push({ level: "warn", message: `${handleFor(node)}: ${problem}`, target: { node: node.key } });
|
|
63
|
+
}
|
|
64
|
+
return [...issues.filter((i) => i.level === "error"), ...issues.filter((i) => i.level === "warn")];
|
|
65
|
+
}
|
|
66
|
+
function queryCounts(apps) {
|
|
67
|
+
const counts = { success: 0, error: 0, executing: 0, idle: 0, dirty: 0, total: 0, dirtyControls: 0 };
|
|
68
|
+
for (const app of apps) {
|
|
69
|
+
for (const query of Object.values(app.queries)) {
|
|
70
|
+
counts[query.state]++;
|
|
71
|
+
counts.total++;
|
|
72
|
+
if (query.isDirty) counts.dirty++;
|
|
73
|
+
}
|
|
74
|
+
for (const control of Object.values(app.controls)) if (control.isDirty) counts.dirtyControls++;
|
|
75
|
+
}
|
|
76
|
+
return counts;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
isChanged,
|
|
81
|
+
changesOf,
|
|
82
|
+
issuesOf,
|
|
83
|
+
queryCounts
|
|
84
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/plugins/inspect/model/format.ts
|
|
2
|
+
function formatCondition(condition) {
|
|
3
|
+
if (!condition) return "not applied yet";
|
|
4
|
+
const parts = [condition.operator, condition.modifier, ...(condition.values ?? []).map(String)];
|
|
5
|
+
return parts.filter((part) => part !== void 0 && part !== "").join(" ");
|
|
6
|
+
}
|
|
7
|
+
function formatTime(value) {
|
|
8
|
+
if (!value) return "";
|
|
9
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
10
|
+
return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleTimeString();
|
|
11
|
+
}
|
|
12
|
+
function formatAgo(value, now = Date.now()) {
|
|
13
|
+
if (!value) return "";
|
|
14
|
+
const time = (value instanceof Date ? value : new Date(value)).getTime();
|
|
15
|
+
if (Number.isNaN(time)) return String(value);
|
|
16
|
+
const seconds = Math.max(0, Math.floor((now - time) / 1e3));
|
|
17
|
+
if (seconds < 60) return "< 1m ago";
|
|
18
|
+
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
|
19
|
+
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
|
20
|
+
return `${Math.floor(seconds / 86400)}d ago`;
|
|
21
|
+
}
|
|
22
|
+
var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
23
|
+
var entityKey = (kind, app, name) => `${kind}:${app}/${name}`;
|
|
24
|
+
function entityAttribute(kind, app, name) {
|
|
25
|
+
return `data-anfra-${kind}="${app === 0 ? "" : `${app}/`}${name}"`;
|
|
26
|
+
}
|
|
27
|
+
function attributeFor(node) {
|
|
28
|
+
return node.kind === "container" || node.kind === "block" ? `data-anfra-${node.kind}="${node.id ?? ""}"` : entityAttribute(node.kind, node.app ?? 0, node.name ?? "");
|
|
29
|
+
}
|
|
30
|
+
function handleFor(node) {
|
|
31
|
+
const attribute = attributeFor(node);
|
|
32
|
+
return node.label ? `[${node.label}](${attribute})` : attribute;
|
|
33
|
+
}
|
|
34
|
+
function usageOf(structure, kind, app, name) {
|
|
35
|
+
return structure?.usage[entityKey(kind, app, name)];
|
|
36
|
+
}
|
|
37
|
+
function findNode(nodes, key) {
|
|
38
|
+
for (const node of nodes) {
|
|
39
|
+
if (node.key === key) return node;
|
|
40
|
+
const inner = findNode(node.children, key);
|
|
41
|
+
if (inner) return inner;
|
|
42
|
+
}
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
function countProblems(nodes) {
|
|
46
|
+
return nodes.reduce((n, node) => n + node.problems.length + countProblems(node.children), 0);
|
|
47
|
+
}
|
|
48
|
+
function blockNodeKey(structure, id, kind, app, name) {
|
|
49
|
+
const blocks = [];
|
|
50
|
+
const holds = (node) => node.children.some((child) => child.kind === kind && (child.app ?? 0) === app && child.name === name || holds(child));
|
|
51
|
+
const walk = (nodes) => {
|
|
52
|
+
for (const node of nodes) {
|
|
53
|
+
if (node.kind === "block" && node.id === id) blocks.push(node);
|
|
54
|
+
walk(node.children);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
walk(structure?.nodes ?? []);
|
|
58
|
+
return (blocks.find(holds) ?? blocks[0])?.key;
|
|
59
|
+
}
|
|
60
|
+
function entityNodeKey(nodes, kind, app, name) {
|
|
61
|
+
for (const node of nodes) {
|
|
62
|
+
if (node.kind === kind && (node.app ?? 0) === app && node.name === name) return node.key;
|
|
63
|
+
const found = entityNodeKey(node.children, kind, app, name);
|
|
64
|
+
if (found) return found;
|
|
65
|
+
}
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
function dedent(text) {
|
|
69
|
+
const lines = text.replace(/\t/g, " ").trim().split("\n");
|
|
70
|
+
const indentOf = (line) => line.length - line.trimStart().length;
|
|
71
|
+
const rest = lines.slice(1).filter((line) => line.trim());
|
|
72
|
+
const indent = rest.length ? Math.min(...rest.map(indentOf)) : 0;
|
|
73
|
+
return lines.map((line, i) => (i ? line.slice(Math.min(indent, indentOf(line))) : line).trimEnd()).join("\n");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/plugins/inspect/model/types.ts
|
|
77
|
+
var OVERVIEW_TAB = "inspect.overview";
|
|
78
|
+
var DATA_TAB = "inspect.data";
|
|
79
|
+
var QUERIES_TAB = "inspect.queries";
|
|
80
|
+
var STRUCTURE_TAB = "inspect.structure";
|
|
81
|
+
var DECLARATION_TAB = "inspect.declaration";
|
|
82
|
+
var LINEAGE_TAB = "lineage.lineage";
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
formatCondition,
|
|
86
|
+
formatTime,
|
|
87
|
+
formatAgo,
|
|
88
|
+
plural,
|
|
89
|
+
entityKey,
|
|
90
|
+
entityAttribute,
|
|
91
|
+
attributeFor,
|
|
92
|
+
handleFor,
|
|
93
|
+
usageOf,
|
|
94
|
+
findNode,
|
|
95
|
+
countProblems,
|
|
96
|
+
blockNodeKey,
|
|
97
|
+
entityNodeKey,
|
|
98
|
+
dedent,
|
|
99
|
+
OVERVIEW_TAB,
|
|
100
|
+
DATA_TAB,
|
|
101
|
+
QUERIES_TAB,
|
|
102
|
+
STRUCTURE_TAB,
|
|
103
|
+
DECLARATION_TAB,
|
|
104
|
+
LINEAGE_TAB
|
|
105
|
+
};
|