@yejiming/dsh-data-agent 0.0.13 → 0.1.0
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.en.md +43 -8
- package/README.md +43 -8
- package/conformance/dsh-ecosystem/inventory.json +26 -3
- package/conformance/dsh-ecosystem/restrictions.json +2 -2
- package/cordis.patch.yml +6 -3
- package/dsh-plugin.json +9 -4
- package/lib/catalog-DEJqOXRo.js +1944 -0
- package/lib/catalog-identity-CVftmvQL.js +96 -0
- package/lib/client.js +2217 -109
- package/lib/client.js.map +1 -1
- package/lib/command-CzzSPmag.js +1719 -0
- package/lib/command.js +2 -2
- package/lib/{connections-CHY4uB6z.js → connections-CFXOZTHZ.js} +223 -9
- package/lib/index.js +366 -16
- package/lib/routes.js +257 -4
- package/lib/{tool-ZTOS4B33.js → tool-DNkywSph.js} +364 -3
- package/lib/tool.js +1 -1
- package/lib/types/catalog-adapters.d.ts +52 -0
- package/lib/types/catalog-ai.d.ts +49 -0
- package/lib/types/catalog-command.d.ts +28 -0
- package/lib/types/catalog-identity.d.ts +23 -0
- package/lib/types/catalog-storage.d.ts +265 -0
- package/lib/types/catalog-tools.d.ts +5 -0
- package/lib/types/catalog-tui.d.ts +18 -0
- package/lib/types/catalog-types.d.ts +1376 -0
- package/lib/types/catalog.d.ts +59 -0
- package/lib/types/client/CatalogPanel.d.ts +15 -0
- package/lib/types/client/catalog-client.d.ts +57 -0
- package/lib/types/client/locales.d.ts +242 -0
- package/lib/types/command.d.ts +14 -3
- package/lib/types/connections.d.ts +9 -0
- package/lib/types/defaults.d.ts +22 -0
- package/lib/types/index.d.ts +42 -5
- package/lib/types/tui-connection-form.d.ts +11 -5
- package/package.json +4 -2
- package/preset/data-agent/agent.cordis.yml +9 -1
- package/lib/command-utC5MHd9.js +0 -916
- package/lib/defaults-Cngd8Tf8.js +0 -131
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
//#region src/catalog-identity.ts
|
|
3
|
+
/** Deterministic identity, normalization, and fingerprint helpers. */
|
|
4
|
+
const CASE_INSENSITIVE_DIALECTS = /* @__PURE__ */ new Set([
|
|
5
|
+
"mysql",
|
|
6
|
+
"doris",
|
|
7
|
+
"sqlite",
|
|
8
|
+
"hive",
|
|
9
|
+
"impala",
|
|
10
|
+
"sqlserver"
|
|
11
|
+
]);
|
|
12
|
+
/** Strip unsafe controls, normalize Unicode, and enforce one explicit bound. */
|
|
13
|
+
function normalizeCatalogText(value, maxChars) {
|
|
14
|
+
const normalized = value.normalize("NFKC").replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, " ").replace(/\s+/g, " ").trim();
|
|
15
|
+
if (normalized.length <= maxChars) return {
|
|
16
|
+
value: normalized,
|
|
17
|
+
truncated: false
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
value: normalized.slice(0, maxChars),
|
|
21
|
+
truncated: true
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Normalize an observed identifier according to the dialect's identity rules. */
|
|
25
|
+
function normalizeCatalogIdentifier(type, value) {
|
|
26
|
+
const normalized = normalizeCatalogText(value, 256).value;
|
|
27
|
+
if (normalized.length === 0) throw new Error("Catalog identifier must not be empty");
|
|
28
|
+
if (type === "oracle") return normalized.toUpperCase();
|
|
29
|
+
return CASE_INSENSITIVE_DIALECTS.has(type) ? normalized.toLowerCase() : normalized;
|
|
30
|
+
}
|
|
31
|
+
/** v1 source identity is deliberately the stable connection profile id. */
|
|
32
|
+
function catalogSourceId(profileId) {
|
|
33
|
+
const normalized = normalizeCatalogText(profileId, 256).value;
|
|
34
|
+
if (normalized.length === 0) throw new Error("Catalog scan requires a stable profileId");
|
|
35
|
+
return normalized;
|
|
36
|
+
}
|
|
37
|
+
/** Build canonical structured identity without parsing display paths. */
|
|
38
|
+
function canonicalCatalogIdentity(type, identity) {
|
|
39
|
+
return {
|
|
40
|
+
sourceId: catalogSourceId(identity.sourceId),
|
|
41
|
+
database: normalizeCatalogIdentifier(type, identity.database),
|
|
42
|
+
schema: normalizeCatalogIdentifier(type, identity.schema),
|
|
43
|
+
kind: identity.kind,
|
|
44
|
+
...identity.relation !== void 0 ? { relation: normalizeCatalogIdentifier(type, identity.relation) } : {},
|
|
45
|
+
name: normalizeCatalogIdentifier(type, identity.name)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Stable opaque asset id derived only from structured identity components. */
|
|
49
|
+
function catalogAssetId(type, identity) {
|
|
50
|
+
const canonical = canonicalCatalogIdentity(type, identity);
|
|
51
|
+
return `asset_${createHash("sha256").update(stableJson(canonical)).digest("hex").slice(0, 32)}`;
|
|
52
|
+
}
|
|
53
|
+
function catalogSemanticId(sourceId, kind, name) {
|
|
54
|
+
const key = {
|
|
55
|
+
sourceId: catalogSourceId(sourceId),
|
|
56
|
+
kind,
|
|
57
|
+
name: normalizeCatalogText(name, 256).value.toLocaleLowerCase("en-US")
|
|
58
|
+
};
|
|
59
|
+
return `${kind}_${createHash("sha256").update(stableJson(key)).digest("hex").slice(0, 32)}`;
|
|
60
|
+
}
|
|
61
|
+
/** Technical fingerprint excludes run-specific provenance and display-only truncation facts. */
|
|
62
|
+
function catalogTechnicalFingerprint(payload, status = "observed") {
|
|
63
|
+
const canonical = {
|
|
64
|
+
status,
|
|
65
|
+
identity: payload.identity,
|
|
66
|
+
name: payload.name,
|
|
67
|
+
parentId: payload.parentId,
|
|
68
|
+
objectType: payload.objectType,
|
|
69
|
+
dataType: payload.dataType,
|
|
70
|
+
nullable: payload.nullable,
|
|
71
|
+
ordinal: payload.ordinal,
|
|
72
|
+
comment: payload.comment,
|
|
73
|
+
referencedAssetIds: payload.referencedAssetIds,
|
|
74
|
+
attributes: payload.attributes,
|
|
75
|
+
capabilities: payload.capabilities
|
|
76
|
+
};
|
|
77
|
+
return createHash("sha256").update(stableJson(canonical)).digest("hex");
|
|
78
|
+
}
|
|
79
|
+
/** Deterministic JSON encoding for hashes and cursor order keys. */
|
|
80
|
+
function stableJson(value) {
|
|
81
|
+
return JSON.stringify(sortValue(value));
|
|
82
|
+
}
|
|
83
|
+
function sortValue(value) {
|
|
84
|
+
if (Array.isArray(value)) return value.map(sortValue);
|
|
85
|
+
if (value === null || typeof value !== "object") return value;
|
|
86
|
+
const record = value;
|
|
87
|
+
return Object.fromEntries(Object.keys(record).sort().map((key) => [key, sortValue(record[key])]));
|
|
88
|
+
}
|
|
89
|
+
function catalogRevisionId(assetId, revision) {
|
|
90
|
+
return `${assetId}:r${String(revision).padStart(8, "0")}`;
|
|
91
|
+
}
|
|
92
|
+
function catalogSemanticRevisionId(semanticId, version) {
|
|
93
|
+
return `${semanticId}:v${String(version).padStart(8, "0")}`;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { catalogSemanticRevisionId as a, normalizeCatalogIdentifier as c, catalogSemanticId as i, normalizeCatalogText as l, catalogAssetId as n, catalogSourceId as o, catalogRevisionId as r, catalogTechnicalFingerprint as s, canonicalCatalogIdentity as t, stableJson as u };
|