@yesprasad/fluent-graph 0.2.2 → 0.2.3
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/dist/cli/index.js +32 -49
- package/dist/index.d.ts +117 -3
- package/dist/index.js +1 -19
- package/package.json +5 -5
- package/dist/blast/traversal.d.ts +0 -48
- package/dist/blast/traversal.js +0 -141
- package/dist/cli/commands/blast.d.ts +0 -2
- package/dist/cli/commands/blast.js +0 -296
- package/dist/cli/commands/extract.d.ts +0 -6
- package/dist/cli/commands/extract.js +0 -125
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/utils/banner.d.ts +0 -2
- package/dist/cli/utils/banner.js +0 -25
- package/dist/cli/utils/display.d.ts +0 -3
- package/dist/cli/utils/display.js +0 -137
- package/dist/extractor/edges.d.ts +0 -13
- package/dist/extractor/edges.js +0 -136
- package/dist/extractor/index.d.ts +0 -3
- package/dist/extractor/index.js +0 -24
- package/dist/extractor/metadata.d.ts +0 -6
- package/dist/extractor/metadata.js +0 -37
- package/dist/extractor/nodes.d.ts +0 -2
- package/dist/extractor/nodes.js +0 -64
- package/dist/graph/extractor.d.ts +0 -7
- package/dist/graph/extractor.js +0 -36
- package/dist/output/writer.d.ts +0 -9
- package/dist/output/writer.js +0 -28
- package/dist/sdk/detector.d.ts +0 -6
- package/dist/sdk/detector.js +0 -32
- package/dist/sdk/loader.d.ts +0 -7
- package/dist/sdk/loader.js +0 -19
- package/dist/sdk/registry.d.ts +0 -30
- package/dist/sdk/registry.js +0 -128
- package/dist/types/graphs.d.ts +0 -35
- package/dist/types/graphs.js +0 -2
package/dist/extractor/edges.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractReferenceEdges = extractReferenceEdges;
|
|
4
|
-
exports.extractCompositionEdges = extractCompositionEdges;
|
|
5
|
-
/**
|
|
6
|
-
* UNIVERSAL EDGE EXTRACTOR
|
|
7
|
-
*
|
|
8
|
-
* Strategy:
|
|
9
|
-
* 1. Property-based schema relationship detection (internal_type=reference)
|
|
10
|
-
* 2. Logic attachment via table/collection property
|
|
11
|
-
* 3. ACL name parsing — detected via registry plugin name
|
|
12
|
-
* 4. Universal RecordId scan across all properties
|
|
13
|
-
*/
|
|
14
|
-
function extractReferenceEdges(records, allNodes, registry) {
|
|
15
|
-
const edges = [];
|
|
16
|
-
for (const record of records.query()) {
|
|
17
|
-
const fromId = record.getId()?.getValue()?.toString();
|
|
18
|
-
const props = record.setProperties || {};
|
|
19
|
-
const recordTable = record.getTable()?.toString();
|
|
20
|
-
// === STRATEGY 1: SCHEMA RELATIONSHIPS ===
|
|
21
|
-
// Detect by properties: any record with internal_type=reference and a reference property
|
|
22
|
-
const internalType = props.internal_type?.getValue?.()?.toString();
|
|
23
|
-
const refTable = props.reference?.getValue?.()?.toString();
|
|
24
|
-
const elementName = props.element?.getValue?.()?.toString();
|
|
25
|
-
if (internalType === 'reference' && refTable) {
|
|
26
|
-
const targetNode = allNodes.find(n => n.name === refTable);
|
|
27
|
-
edges.push({
|
|
28
|
-
from: fromId,
|
|
29
|
-
to: targetNode?.id || `platform:${refTable}`,
|
|
30
|
-
via: elementName || 'reference',
|
|
31
|
-
type: 'schema_relationship'
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
// === STRATEGY 2: LOGIC ATTACHMENTS ===
|
|
35
|
-
// Any artifact with 'table' or 'collection' property
|
|
36
|
-
const tableRef = props.table?.getValue?.()?.toString() ||
|
|
37
|
-
props.collection?.getValue?.()?.toString();
|
|
38
|
-
if (tableRef) {
|
|
39
|
-
const targetNode = allNodes.find(n => n.name === tableRef);
|
|
40
|
-
edges.push({
|
|
41
|
-
from: fromId,
|
|
42
|
-
to: targetNode?.id || `platform:${tableRef}`,
|
|
43
|
-
via: props.table ? 'table' : 'collection',
|
|
44
|
-
type: 'dependency',
|
|
45
|
-
targetTable: tableRef
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
// === STRATEGY 3: ACL NAME PARSING ===
|
|
49
|
-
// Detect ACL records by plugin name (registry-derived) rather than hardcoded table name
|
|
50
|
-
if (registry.getPluginName(recordTable) === 'AclPlugin') {
|
|
51
|
-
const aclName = props.name?.getValue?.()?.toString();
|
|
52
|
-
if (aclName && aclName.includes('.')) {
|
|
53
|
-
const [targetTable] = aclName.split('.');
|
|
54
|
-
const targetNode = allNodes.find(n => n.name === targetTable);
|
|
55
|
-
edges.push({
|
|
56
|
-
from: fromId,
|
|
57
|
-
to: targetNode?.id || `platform:${targetTable}`,
|
|
58
|
-
via: 'name',
|
|
59
|
-
type: 'dependency',
|
|
60
|
-
targetTable
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// === STRATEGY 4: UNIVERSAL REFERENCE SCAN ===
|
|
65
|
-
// Scan ALL properties for RecordId and Record types (sys_id references).
|
|
66
|
-
// RecordId: getValue() = sys_id, getTable() = table name.
|
|
67
|
-
// Record: getId().getValue() = sys_id; table resolved via allNodes lookup.
|
|
68
|
-
// Used by SDK for cross-artifact references like flow_designer_flow on CatalogItem.
|
|
69
|
-
for (const [key, val] of Object.entries(props)) {
|
|
70
|
-
if (Array.isArray(val)) {
|
|
71
|
-
val.forEach((item) => {
|
|
72
|
-
if (item && item.constructor?.name === 'RecordId') {
|
|
73
|
-
const targetId = item.getValue?.()?.toString();
|
|
74
|
-
const targetTable = item.getTable?.()?.toString();
|
|
75
|
-
if (targetId && registry.getPluginName(targetTable) !== 'TablePlugin') {
|
|
76
|
-
edges.push({
|
|
77
|
-
from: fromId,
|
|
78
|
-
to: targetId,
|
|
79
|
-
via: key,
|
|
80
|
-
type: 'dependency',
|
|
81
|
-
targetTable
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
else if (val && val.constructor?.name === 'RecordId') {
|
|
88
|
-
const targetId = val.getValue?.()?.toString();
|
|
89
|
-
const targetTable = val.getTable?.()?.toString();
|
|
90
|
-
if (targetId && registry.getPluginName(targetTable) !== 'TablePlugin') {
|
|
91
|
-
edges.push({
|
|
92
|
-
from: fromId,
|
|
93
|
-
to: targetId,
|
|
94
|
-
via: key,
|
|
95
|
-
type: 'dependency',
|
|
96
|
-
targetTable
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (val && val.constructor?.name === 'Record') {
|
|
101
|
-
const targetId = val.getId?.()?.getValue?.()?.toString();
|
|
102
|
-
if (targetId) {
|
|
103
|
-
const targetNode = allNodes.find(n => n.id === targetId);
|
|
104
|
-
if (targetNode && registry.getPluginName(targetNode.table) !== 'TablePlugin') {
|
|
105
|
-
edges.push({
|
|
106
|
-
from: fromId,
|
|
107
|
-
to: targetId,
|
|
108
|
-
via: key,
|
|
109
|
-
type: 'dependency',
|
|
110
|
-
targetTable: targetNode.table
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return edges;
|
|
118
|
-
}
|
|
119
|
-
function extractCompositionEdges(records) {
|
|
120
|
-
const edges = [];
|
|
121
|
-
for (const record of records.query()) {
|
|
122
|
-
const parentId = record.getId()?.getValue()?.toString();
|
|
123
|
-
const children = record.getRelated?.() || [];
|
|
124
|
-
for (const child of children) {
|
|
125
|
-
const childId = child.getId()?.getValue()?.toString();
|
|
126
|
-
if (childId && parentId) {
|
|
127
|
-
edges.push({
|
|
128
|
-
from: parentId,
|
|
129
|
-
to: childId,
|
|
130
|
-
type: 'composition'
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return edges;
|
|
136
|
-
}
|
package/dist/extractor/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractLineageGraph = extractLineageGraph;
|
|
4
|
-
const nodes_1 = require("./nodes");
|
|
5
|
-
const edges_1 = require("./edges");
|
|
6
|
-
const metadata_1 = require("./metadata");
|
|
7
|
-
async function extractLineageGraph(project, registry) {
|
|
8
|
-
// Get raw records from the ServiceNow SDK Project
|
|
9
|
-
const records = await project.getRecords();
|
|
10
|
-
const rootDir = project.getRootDir();
|
|
11
|
-
// 1. Extract Nodes (Includes dynamic attributes like order, when, active)
|
|
12
|
-
const nodes = (0, nodes_1.extractNodes)(records, rootDir);
|
|
13
|
-
// 2. Extract Edges (Requires node list for implicit string-to-table resolution)
|
|
14
|
-
const referenceEdges = (0, edges_1.extractReferenceEdges)(records, nodes, registry);
|
|
15
|
-
const compositionEdges = (0, edges_1.extractCompositionEdges)(records);
|
|
16
|
-
const edges = [...referenceEdges, ...compositionEdges];
|
|
17
|
-
// 3. Generate Summary Metadata
|
|
18
|
-
const metadata = (0, metadata_1.generateMetadata)(project, records.query().length, referenceEdges.length, compositionEdges.length);
|
|
19
|
-
return {
|
|
20
|
-
metadata,
|
|
21
|
-
nodes,
|
|
22
|
-
edges
|
|
23
|
-
};
|
|
24
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GraphMetadata } from '../types/graphs';
|
|
2
|
-
/**
|
|
3
|
-
* Generates the Global Graph Summary.
|
|
4
|
-
* provide architectural context for the extracted lineage.
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateMetadata(project: any, recordCount: number, referenceCount: number, compositionCount: number): GraphMetadata;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateMetadata = generateMetadata;
|
|
4
|
-
/**
|
|
5
|
-
* Generates the Global Graph Summary.
|
|
6
|
-
* provide architectural context for the extracted lineage.
|
|
7
|
-
*/
|
|
8
|
-
function generateMetadata(project, recordCount, referenceCount, compositionCount) {
|
|
9
|
-
// These calls safely interact with the SDK Project Proxy
|
|
10
|
-
const config = project.getConfig() || {};
|
|
11
|
-
const pkg = project.getPackage() || {};
|
|
12
|
-
return {
|
|
13
|
-
projectRoot: project.getRootDir() || process.cwd(),
|
|
14
|
-
/**
|
|
15
|
-
* Identification:
|
|
16
|
-
* Essential for determining the "Home Scope" of the graph.
|
|
17
|
-
*/
|
|
18
|
-
scopeId: config.scopeId || 'unknown',
|
|
19
|
-
scopeName: config.scope || 'Global',
|
|
20
|
-
/**
|
|
21
|
-
* Quantitative Metrics:
|
|
22
|
-
* recordCount represents the Vertex count (Nodes).
|
|
23
|
-
* referenceCount + compositionCount represents the Edge density.
|
|
24
|
-
*/
|
|
25
|
-
recordCount,
|
|
26
|
-
referenceCount,
|
|
27
|
-
compositionCount,
|
|
28
|
-
/**
|
|
29
|
-
* Temporal & Environment context:
|
|
30
|
-
* Helps the CLI determine if the graph file is stale.
|
|
31
|
-
*/
|
|
32
|
-
generatedAt: new Date().toISOString(),
|
|
33
|
-
sdkVersion: pkg.dependencies?.['@servicenow/sdk'] ||
|
|
34
|
-
pkg.devDependencies?.['@servicenow/sdk'] ||
|
|
35
|
-
'unknown'
|
|
36
|
-
};
|
|
37
|
-
}
|
package/dist/extractor/nodes.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.extractNodes = extractNodes;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
/**
|
|
9
|
-
* UNIVERSAL NODE EXTRACTOR
|
|
10
|
-
*
|
|
11
|
-
* Strategy:
|
|
12
|
-
* - Extract ALL primitive attributes (strings, numbers, booleans)
|
|
13
|
-
* - Ignore complex objects (they become edges)
|
|
14
|
-
* - Preserve metadata like 'element', 'name', 'type' for display logic
|
|
15
|
-
*/
|
|
16
|
-
function sanitizeAttributes(props) {
|
|
17
|
-
const clean = {};
|
|
18
|
-
for (const [key, val] of Object.entries(props)) {
|
|
19
|
-
if (!val)
|
|
20
|
-
continue;
|
|
21
|
-
try {
|
|
22
|
-
// Extract the primitive value if it's a SDK wrapper
|
|
23
|
-
const plainValue = typeof val.getValue === 'function'
|
|
24
|
-
? val.getValue()
|
|
25
|
-
: val;
|
|
26
|
-
// Only keep primitives and arrays of primitives
|
|
27
|
-
if (typeof plainValue !== 'object' || plainValue === null || Array.isArray(plainValue)) {
|
|
28
|
-
clean[key] = plainValue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return clean;
|
|
36
|
-
}
|
|
37
|
-
function extractNodes(records, projectRoot) {
|
|
38
|
-
const nodes = [];
|
|
39
|
-
for (const record of records.query()) {
|
|
40
|
-
const props = record.setProperties || {};
|
|
41
|
-
const idValue = record.getId()?.getValue()?.toString() || '';
|
|
42
|
-
const tableName = record.getTable()?.toString() || '';
|
|
43
|
-
// Determine a human-readable name
|
|
44
|
-
const name = props.name?.getValue?.()?.toString() ||
|
|
45
|
-
props.label?.getValue?.()?.toString() ||
|
|
46
|
-
props.sys_name?.getValue?.()?.toString() ||
|
|
47
|
-
idValue;
|
|
48
|
-
// Capture file source (relative to project root)
|
|
49
|
-
const rawFile = record.getOriginalFilePath()?.toString() || '';
|
|
50
|
-
const relativeFile = rawFile ? path_1.default.relative(projectRoot, rawFile) : '';
|
|
51
|
-
nodes.push({
|
|
52
|
-
id: idValue,
|
|
53
|
-
table: tableName,
|
|
54
|
-
action: record.getAction(),
|
|
55
|
-
name,
|
|
56
|
-
attributes: sanitizeAttributes(props),
|
|
57
|
-
source: {
|
|
58
|
-
file: relativeFile,
|
|
59
|
-
type: record.getOriginalSource()?.getKindName?.() || 'SourceFile'
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return nodes;
|
|
64
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ArtifactTypeRegistry } from '../sdk/registry';
|
|
2
|
-
import type { LineageGraph } from '../types/graphs';
|
|
3
|
-
/**
|
|
4
|
-
* The Orchestrator: Converts raw SDK records into a formal Directed Graph.
|
|
5
|
-
* It treats every artifact as a node and every relationship as an iterable edge.
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractLineageGraph(project: any, registry?: ArtifactTypeRegistry): Promise<LineageGraph>;
|
package/dist/graph/extractor.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractLineageGraph = extractLineageGraph;
|
|
4
|
-
const nodes_1 = require("../extractor/nodes");
|
|
5
|
-
const edges_1 = require("../extractor/edges");
|
|
6
|
-
const metadata_1 = require("../extractor/metadata");
|
|
7
|
-
const registry_1 = require("../sdk/registry");
|
|
8
|
-
/**
|
|
9
|
-
* The Orchestrator: Converts raw SDK records into a formal Directed Graph.
|
|
10
|
-
* It treats every artifact as a node and every relationship as an iterable edge.
|
|
11
|
-
*/
|
|
12
|
-
async function extractLineageGraph(project, registry) {
|
|
13
|
-
const records = project.getRecords();
|
|
14
|
-
const projectRoot = project.getRootDir();
|
|
15
|
-
const reg = registry ?? new registry_1.ArtifactTypeRegistry();
|
|
16
|
-
// 1. PHASE ONE: Vertex Extraction (Nodes)
|
|
17
|
-
// We only extract the "winning" records to avoid conflict noise.
|
|
18
|
-
// This creates the list of local artifacts.
|
|
19
|
-
const nodes = (0, nodes_1.extractNodes)(records, projectRoot);
|
|
20
|
-
// 2. PHASE TWO: Edge Extraction (Relationships)
|
|
21
|
-
// We pass the 'nodes' array into extractReferenceEdges.
|
|
22
|
-
// This allows the edge extractor to differentiate between:
|
|
23
|
-
// a) A reference to a local table (e.g. x_1566039_seventh_account)
|
|
24
|
-
// b) A reference to a platform table (e.g. platform:incident)
|
|
25
|
-
const refEdges = (0, edges_1.extractReferenceEdges)(records, nodes, reg);
|
|
26
|
-
const compEdges = (0, edges_1.extractCompositionEdges)(records);
|
|
27
|
-
const allEdges = [...refEdges, ...compEdges];
|
|
28
|
-
// 3. PHASE THREE: Metadata & Context
|
|
29
|
-
// Calculate graph-wide statistics and SDK versioning.
|
|
30
|
-
const metadata = (0, metadata_1.generateMetadata)(project, nodes.length, refEdges.length, compEdges.length);
|
|
31
|
-
return {
|
|
32
|
-
metadata,
|
|
33
|
-
nodes,
|
|
34
|
-
edges: allEdges
|
|
35
|
-
};
|
|
36
|
-
}
|
package/dist/output/writer.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { LineageGraph } from '../types/graphs';
|
|
2
|
-
/**
|
|
3
|
-
* Write lineage graph to JSON file
|
|
4
|
-
*/
|
|
5
|
-
export declare function writeGraph(graph: LineageGraph, outputPath: string): void;
|
|
6
|
-
/**
|
|
7
|
-
* Generate default output filename with timestamp
|
|
8
|
-
*/
|
|
9
|
-
export declare function getDefaultOutputPath(projectRoot: string): string;
|
package/dist/output/writer.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.writeGraph = writeGraph;
|
|
7
|
-
exports.getDefaultOutputPath = getDefaultOutputPath;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
/**
|
|
11
|
-
* Write lineage graph to JSON file
|
|
12
|
-
*/
|
|
13
|
-
function writeGraph(graph, outputPath) {
|
|
14
|
-
const formatted = JSON.stringify(graph, null, 2);
|
|
15
|
-
// Ensure directory exists
|
|
16
|
-
const dir = path_1.default.dirname(outputPath);
|
|
17
|
-
if (!fs_1.default.existsSync(dir)) {
|
|
18
|
-
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
19
|
-
}
|
|
20
|
-
fs_1.default.writeFileSync(outputPath, formatted, 'utf-8');
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Generate default output filename with timestamp
|
|
24
|
-
*/
|
|
25
|
-
function getDefaultOutputPath(projectRoot) {
|
|
26
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
27
|
-
return path_1.default.join(projectRoot, `fluent-graph-${timestamp}.json`);
|
|
28
|
-
}
|
package/dist/sdk/detector.d.ts
DELETED
package/dist/sdk/detector.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.detectSDK = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const detectSDK = async (cwd) => {
|
|
10
|
-
// Step 1: Check if node_modules exist
|
|
11
|
-
const nodeModulesPath = path_1.default.join(cwd, 'node_modules');
|
|
12
|
-
if (!fs_1.default.existsSync(nodeModulesPath)) {
|
|
13
|
-
return {
|
|
14
|
-
found: false,
|
|
15
|
-
error: 'node_modules not found. Run npm install first.'
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
// Step 2: Check if @servicenow/sdk exists
|
|
19
|
-
const sdkPath = path_1.default.join(nodeModulesPath, '@servicenow', 'sdk');
|
|
20
|
-
if (!fs_1.default.existsSync(sdkPath)) {
|
|
21
|
-
return {
|
|
22
|
-
found: false,
|
|
23
|
-
error: '@servicenow/sdk not found. This is not a ServiceNow Fluent project.'
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
// Step 3: Success
|
|
27
|
-
return {
|
|
28
|
-
found: true,
|
|
29
|
-
sdkPath
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
exports.detectSDK = detectSDK;
|
package/dist/sdk/loader.d.ts
DELETED
package/dist/sdk/loader.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadWorkspaceSDK = loadWorkspaceSDK;
|
|
7
|
-
const module_1 = require("module");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const registry_1 = require("./registry");
|
|
10
|
-
function loadWorkspaceSDK(sdkPath) {
|
|
11
|
-
const requireFromWorkspace = (0, module_1.createRequire)(path_1.default.join(sdkPath, 'package.json'));
|
|
12
|
-
const registry = new registry_1.ArtifactTypeRegistry();
|
|
13
|
-
registry.load(sdkPath);
|
|
14
|
-
return {
|
|
15
|
-
buildCore: requireFromWorkspace('@servicenow/sdk-build-core'),
|
|
16
|
-
sdkapi: requireFromWorkspace('@servicenow/sdk-api'),
|
|
17
|
-
registry,
|
|
18
|
-
};
|
|
19
|
-
}
|
package/dist/sdk/registry.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
interface TableInfo {
|
|
2
|
-
table: string;
|
|
3
|
-
pluginName: string;
|
|
4
|
-
isChild: boolean;
|
|
5
|
-
parentTable?: string;
|
|
6
|
-
parentVia?: string;
|
|
7
|
-
children: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare class ArtifactTypeRegistry {
|
|
10
|
-
private tables;
|
|
11
|
-
load(sdkPath: string): void;
|
|
12
|
-
private register;
|
|
13
|
-
/**
|
|
14
|
-
* Parse the top-level relationships map:
|
|
15
|
-
* { parentTable: { childTable: { via, descendant, relationships: { grandchild: ... } } } }
|
|
16
|
-
*/
|
|
17
|
-
private parseRelationships;
|
|
18
|
-
private processChildren;
|
|
19
|
-
get(table: string): TableInfo | undefined;
|
|
20
|
-
getPluginName(table: string): string;
|
|
21
|
-
getDisplayGroupName(table: string): string;
|
|
22
|
-
isChild(table: string): boolean;
|
|
23
|
-
getParentTable(table: string): string | undefined;
|
|
24
|
-
getChildren(table: string): string[];
|
|
25
|
-
getTablesByPlugin(pluginName: string): string[];
|
|
26
|
-
getAllPluginNames(): string[];
|
|
27
|
-
getAllTables(): string[];
|
|
28
|
-
isKnown(table: string): boolean;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
package/dist/sdk/registry.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ArtifactTypeRegistry = void 0;
|
|
7
|
-
const module_1 = require("module");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
class ArtifactTypeRegistry {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.tables = new Map();
|
|
12
|
-
}
|
|
13
|
-
load(sdkPath) {
|
|
14
|
-
try {
|
|
15
|
-
const requireFromWorkspace = (0, module_1.createRequire)(path_1.default.join(sdkPath, 'package.json'));
|
|
16
|
-
const buildPlugins = requireFromWorkspace('@servicenow/sdk-build-plugins');
|
|
17
|
-
for (const [, value] of Object.entries(buildPlugins)) {
|
|
18
|
-
const plugin = value;
|
|
19
|
-
if (!plugin?.config?.name)
|
|
20
|
-
continue;
|
|
21
|
-
const pluginName = plugin.config.name;
|
|
22
|
-
const tables = Object.keys(plugin.config.records || {}).filter(k => k !== '*');
|
|
23
|
-
if (tables.length === 0)
|
|
24
|
-
continue;
|
|
25
|
-
for (const table of tables) {
|
|
26
|
-
this.register(table, pluginName);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const rels = plugin.getRelationships();
|
|
30
|
-
if (rels && typeof rels === 'object') {
|
|
31
|
-
this.parseRelationships(rels, pluginName);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// safe to skip — needs compiler context
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// sdk-build-plugins unavailable; registry stays empty, fallback behavior applies
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
register(table, pluginName) {
|
|
44
|
-
if (!this.tables.has(table)) {
|
|
45
|
-
this.tables.set(table, { table, pluginName, isChild: false, children: [] });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Parse the top-level relationships map:
|
|
50
|
-
* { parentTable: { childTable: { via, descendant, relationships: { grandchild: ... } } } }
|
|
51
|
-
*/
|
|
52
|
-
parseRelationships(rels, pluginName) {
|
|
53
|
-
for (const [parentTable, childDefs] of Object.entries(rels)) {
|
|
54
|
-
this.register(parentTable, pluginName);
|
|
55
|
-
if (childDefs && typeof childDefs === 'object') {
|
|
56
|
-
this.processChildren(childDefs, pluginName, parentTable);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
processChildren(childDefs, pluginName, parentTable) {
|
|
61
|
-
for (const [key, def] of Object.entries(childDefs)) {
|
|
62
|
-
// Skip meta-keys and self-referential entries
|
|
63
|
-
if (key === 'via' || key === 'descendant' || key === 'relationships')
|
|
64
|
-
continue;
|
|
65
|
-
if (key === parentTable)
|
|
66
|
-
continue;
|
|
67
|
-
const childTable = key;
|
|
68
|
-
this.register(childTable, pluginName);
|
|
69
|
-
const entry = this.tables.get(childTable);
|
|
70
|
-
if (!entry.isChild) {
|
|
71
|
-
entry.isChild = true;
|
|
72
|
-
entry.parentTable = parentTable;
|
|
73
|
-
if (def && typeof def === 'object' && typeof def.via === 'string') {
|
|
74
|
-
entry.parentVia = def.via;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
// Add to parent's children list
|
|
78
|
-
const parentEntry = this.tables.get(parentTable);
|
|
79
|
-
if (parentEntry && !parentEntry.children.includes(childTable)) {
|
|
80
|
-
parentEntry.children.push(childTable);
|
|
81
|
-
}
|
|
82
|
-
// Recurse into nested relationships
|
|
83
|
-
if (def && typeof def === 'object' && def.relationships && typeof def.relationships === 'object') {
|
|
84
|
-
this.processChildren(def.relationships, pluginName, childTable);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
get(table) {
|
|
89
|
-
return this.tables.get(table);
|
|
90
|
-
}
|
|
91
|
-
getPluginName(table) {
|
|
92
|
-
return this.tables.get(table)?.pluginName ?? 'Record';
|
|
93
|
-
}
|
|
94
|
-
getDisplayGroupName(table) {
|
|
95
|
-
const entry = this.tables.get(table);
|
|
96
|
-
if (!entry)
|
|
97
|
-
return 'Other';
|
|
98
|
-
return entry.pluginName
|
|
99
|
-
.replace(/Plugin$/, '')
|
|
100
|
-
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
101
|
-
.replace(/^./, c => c.toUpperCase())
|
|
102
|
-
.trim();
|
|
103
|
-
}
|
|
104
|
-
isChild(table) {
|
|
105
|
-
return this.tables.get(table)?.isChild ?? false;
|
|
106
|
-
}
|
|
107
|
-
getParentTable(table) {
|
|
108
|
-
return this.tables.get(table)?.parentTable;
|
|
109
|
-
}
|
|
110
|
-
getChildren(table) {
|
|
111
|
-
return this.tables.get(table)?.children ?? [];
|
|
112
|
-
}
|
|
113
|
-
getTablesByPlugin(pluginName) {
|
|
114
|
-
return [...this.tables.values()]
|
|
115
|
-
.filter(t => t.pluginName === pluginName)
|
|
116
|
-
.map(t => t.table);
|
|
117
|
-
}
|
|
118
|
-
getAllPluginNames() {
|
|
119
|
-
return [...new Set([...this.tables.values()].map(t => t.pluginName))].sort();
|
|
120
|
-
}
|
|
121
|
-
getAllTables() {
|
|
122
|
-
return [...this.tables.keys()];
|
|
123
|
-
}
|
|
124
|
-
isKnown(table) {
|
|
125
|
-
return this.tables.has(table);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
exports.ArtifactTypeRegistry = ArtifactTypeRegistry;
|
package/dist/types/graphs.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export interface ArtifactNode {
|
|
2
|
-
id: string;
|
|
3
|
-
table: string;
|
|
4
|
-
name: string;
|
|
5
|
-
label?: string;
|
|
6
|
-
action: 'INSERT_OR_UPDATE' | 'DELETE';
|
|
7
|
-
attributes: Record<string, any>;
|
|
8
|
-
source: {
|
|
9
|
-
file: string;
|
|
10
|
-
type: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export interface ArtifactEdge {
|
|
14
|
-
from: string;
|
|
15
|
-
to: string;
|
|
16
|
-
via?: string;
|
|
17
|
-
type: 'reference' | 'composition' | 'dependency' | 'inheritance' | 'schema_relationship';
|
|
18
|
-
targetTable?: string;
|
|
19
|
-
childTable?: string;
|
|
20
|
-
}
|
|
21
|
-
export interface GraphMetadata {
|
|
22
|
-
projectRoot: string;
|
|
23
|
-
scopeId: string;
|
|
24
|
-
scopeName: string;
|
|
25
|
-
recordCount: number;
|
|
26
|
-
referenceCount: number;
|
|
27
|
-
compositionCount: number;
|
|
28
|
-
generatedAt: string;
|
|
29
|
-
sdkVersion: string;
|
|
30
|
-
}
|
|
31
|
-
export interface LineageGraph {
|
|
32
|
-
nodes: ArtifactNode[];
|
|
33
|
-
edges: ArtifactEdge[];
|
|
34
|
-
metadata: GraphMetadata;
|
|
35
|
-
}
|
package/dist/types/graphs.js
DELETED