@0xsarwagya/ontoly-core 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +453 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sarwagya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @0xsarwagya/ontoly-core
|
|
2
|
+
|
|
3
|
+
Software Graph schema, stable IDs, indexes, and graph helpers for Ontoly.
|
|
4
|
+
|
|
5
|
+
This package is part of [Ontoly](https://github.com/0xsarwagya/ontoly), a TypeScript-native software intelligence engine that builds a deterministic Software Graph.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @0xsarwagya/ontoly-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Status
|
|
14
|
+
|
|
15
|
+
Alpha package for Ontoly v0.1.0-alpha.1. The public API is versioned with the Software Graph and RFC process.
|
|
16
|
+
|
|
17
|
+
## Links
|
|
18
|
+
|
|
19
|
+
- [Repository](https://github.com/0xsarwagya/ontoly)
|
|
20
|
+
- [Documentation](https://oss.sarwagya.wtf/ontoly)
|
|
21
|
+
- [Issues](https://github.com/0xsarwagya/ontoly/issues)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export declare const SOFTWARE_GRAPH_VERSION = "1.0.0";
|
|
2
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
3
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
4
|
+
export type JsonObject = {
|
|
5
|
+
readonly [key: string]: JsonValue | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare const NODE_TYPES: readonly ["Workspace", "Application", "Function", "Method", "Class", "Interface", "TypeAlias", "Enum", "Namespace", "Module", "Package", "Script", "Dependency", "Task", "Pipeline", "BuildTarget", "Configuration", "Container", "Workflow", "Job", "Step", "Framework", "Decorator", "Import", "Export", "Route", "Resource", "Operation", "Model", "Field", "Middleware", "Provider", "Factory", "Service", "Repository", "DatabaseTable", "EnvironmentVariable", "Event", "Permission", "Exception", "Controller", "Guard"];
|
|
8
|
+
export type NodeType = (typeof NODE_TYPES)[number];
|
|
9
|
+
export declare const RELATIONSHIP_TYPES: readonly ["CALLS", "IMPORTS", "EXPORTS", "USES", "RETURNS", "THROWS", "READS", "WRITES", "CREATES", "IMPLEMENTS", "EXTENDS", "DEPENDS_ON", "DECORATES", "INJECTS", "REGISTERED_IN", "REGISTERS", "DECLARES", "MOUNTS", "PROVIDES", "CONSUMES", "CONFIGURES", "EXECUTES", "GENERATES", "HANDLES", "OVERRIDES", "AUTHORIZES", "BELONGS_TO", "PUBLISHES", "SUBSCRIBES", "CONTAINS", "EXPOSES", "REFERENCES"];
|
|
10
|
+
export type RelationshipType = (typeof RELATIONSHIP_TYPES)[number];
|
|
11
|
+
export type DiagnosticSeverity = "info" | "warning" | "error";
|
|
12
|
+
export interface SourceSpan {
|
|
13
|
+
readonly file: string;
|
|
14
|
+
readonly startLine: number;
|
|
15
|
+
readonly startColumn: number;
|
|
16
|
+
readonly endLine: number;
|
|
17
|
+
readonly endColumn: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SoftwareGraphRepository {
|
|
20
|
+
readonly root: string;
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly packageManager?: string | undefined;
|
|
23
|
+
readonly packageName?: string | undefined;
|
|
24
|
+
}
|
|
25
|
+
export interface SoftwareGraphNode {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
readonly type: NodeType;
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly file?: string | undefined;
|
|
30
|
+
readonly package?: string | undefined;
|
|
31
|
+
readonly span?: SourceSpan | undefined;
|
|
32
|
+
readonly metadata?: JsonObject | undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface EdgeEvidence {
|
|
35
|
+
readonly kind: "syntax" | "resolver" | "config" | "semantic" | "plugin";
|
|
36
|
+
readonly confidence: "exact" | "inferred" | "low";
|
|
37
|
+
readonly span?: SourceSpan | undefined;
|
|
38
|
+
readonly description?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface SoftwareGraphEdge {
|
|
41
|
+
readonly id: string;
|
|
42
|
+
readonly type: RelationshipType;
|
|
43
|
+
readonly from: string;
|
|
44
|
+
readonly to: string;
|
|
45
|
+
readonly evidence?: readonly EdgeEvidence[] | undefined;
|
|
46
|
+
readonly metadata?: JsonObject | undefined;
|
|
47
|
+
}
|
|
48
|
+
export interface SoftwareGraphDiagnostic {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly code: string;
|
|
51
|
+
readonly severity: DiagnosticSeverity;
|
|
52
|
+
readonly message: string;
|
|
53
|
+
readonly nodeId?: string | undefined;
|
|
54
|
+
readonly edgeId?: string | undefined;
|
|
55
|
+
readonly span?: SourceSpan | undefined;
|
|
56
|
+
readonly metadata?: JsonObject | undefined;
|
|
57
|
+
}
|
|
58
|
+
export interface GraphIndexes {
|
|
59
|
+
readonly nodeIdsByType: Partial<Record<NodeType, readonly string[]>>;
|
|
60
|
+
readonly edgeIdsByType: Partial<Record<RelationshipType, readonly string[]>>;
|
|
61
|
+
readonly inboundEdgeIdsByNodeId: Record<string, readonly string[]>;
|
|
62
|
+
readonly outboundEdgeIdsByNodeId: Record<string, readonly string[]>;
|
|
63
|
+
readonly edgeIdsBySourceAndType: Record<string, readonly string[]>;
|
|
64
|
+
}
|
|
65
|
+
export interface SoftwareGraphMetadata {
|
|
66
|
+
readonly generatedAt: string;
|
|
67
|
+
readonly deterministicHash: string;
|
|
68
|
+
readonly fileCount: number;
|
|
69
|
+
readonly nodeCount: number;
|
|
70
|
+
readonly edgeCount: number;
|
|
71
|
+
readonly parserVersions: Record<string, string>;
|
|
72
|
+
readonly durationMs?: number | undefined;
|
|
73
|
+
}
|
|
74
|
+
export interface SoftwareGraph {
|
|
75
|
+
readonly version: string;
|
|
76
|
+
readonly repository: SoftwareGraphRepository;
|
|
77
|
+
readonly nodes: readonly SoftwareGraphNode[];
|
|
78
|
+
readonly edges: readonly SoftwareGraphEdge[];
|
|
79
|
+
readonly diagnostics: readonly SoftwareGraphDiagnostic[];
|
|
80
|
+
readonly indexes: GraphIndexes;
|
|
81
|
+
readonly metadata: SoftwareGraphMetadata;
|
|
82
|
+
}
|
|
83
|
+
export interface CreateNodeIdInput {
|
|
84
|
+
readonly type: NodeType;
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly file?: string | undefined;
|
|
87
|
+
readonly signature?: string | undefined;
|
|
88
|
+
}
|
|
89
|
+
export interface OntolyPluginContext {
|
|
90
|
+
readonly graph: SoftwareGraph;
|
|
91
|
+
}
|
|
92
|
+
export interface OntolyPluginResult {
|
|
93
|
+
readonly artifacts?: readonly PluginArtifact[] | undefined;
|
|
94
|
+
readonly diagnostics?: readonly SoftwareGraphDiagnostic[] | undefined;
|
|
95
|
+
}
|
|
96
|
+
export interface PluginArtifact {
|
|
97
|
+
readonly path: string;
|
|
98
|
+
readonly contents: string;
|
|
99
|
+
readonly mediaType: string;
|
|
100
|
+
}
|
|
101
|
+
export interface OntolyPlugin {
|
|
102
|
+
readonly name: string;
|
|
103
|
+
readonly version: string;
|
|
104
|
+
readonly run: (context: OntolyPluginContext) => Promise<OntolyPluginResult> | OntolyPluginResult;
|
|
105
|
+
}
|
|
106
|
+
export declare function normalizePath(path: string): string;
|
|
107
|
+
export declare function stableStringify(value: unknown): string;
|
|
108
|
+
export declare function stableHash(input: string): string;
|
|
109
|
+
export declare function createNodeId(input: CreateNodeIdInput): string;
|
|
110
|
+
export declare function createEdgeId(type: RelationshipType, from: string, to: string): string;
|
|
111
|
+
export declare function createDiagnosticId(code: string, message: string, location?: string): string;
|
|
112
|
+
export declare function createSyntaxEvidence(span: SourceSpan, description?: string, confidence?: EdgeEvidence["confidence"]): EdgeEvidence;
|
|
113
|
+
export declare function createGraphBuilder(repository: SoftwareGraphRepository): GraphBuilder;
|
|
114
|
+
export declare class GraphBuilder {
|
|
115
|
+
#private;
|
|
116
|
+
constructor(repository: SoftwareGraphRepository);
|
|
117
|
+
setFileCount(fileCount: number): void;
|
|
118
|
+
setParserVersion(name: string, version: string): void;
|
|
119
|
+
addNode(node: SoftwareGraphNode): SoftwareGraphNode;
|
|
120
|
+
addEdge(edge: Omit<SoftwareGraphEdge, "id"> & {
|
|
121
|
+
readonly id?: string | undefined;
|
|
122
|
+
}): SoftwareGraphEdge;
|
|
123
|
+
addDiagnostic(diagnostic: SoftwareGraphDiagnostic): SoftwareGraphDiagnostic;
|
|
124
|
+
toGraph(durationMs?: number): SoftwareGraph;
|
|
125
|
+
}
|
|
126
|
+
export interface CreateSoftwareGraphInput {
|
|
127
|
+
readonly repository: SoftwareGraphRepository;
|
|
128
|
+
readonly nodes: readonly SoftwareGraphNode[];
|
|
129
|
+
readonly edges: readonly SoftwareGraphEdge[];
|
|
130
|
+
readonly diagnostics?: readonly SoftwareGraphDiagnostic[] | undefined;
|
|
131
|
+
readonly fileCount?: number | undefined;
|
|
132
|
+
readonly parserVersions?: Record<string, string> | undefined;
|
|
133
|
+
readonly durationMs?: number | undefined;
|
|
134
|
+
}
|
|
135
|
+
export declare function createSoftwareGraph(input: CreateSoftwareGraphInput): SoftwareGraph;
|
|
136
|
+
export declare function buildIndexes(nodes: readonly SoftwareGraphNode[], edges: readonly SoftwareGraphEdge[]): GraphIndexes;
|
|
137
|
+
export declare function summarizeGraph(graph: SoftwareGraph): string;
|
|
138
|
+
export declare function getNode(graph: SoftwareGraph, id: string): SoftwareGraphNode | undefined;
|
|
139
|
+
export declare function getEdge(graph: SoftwareGraph, id: string): SoftwareGraphEdge | undefined;
|
|
140
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAE9C,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,SAAS,EAAE,CAAC;AACjE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CAC/C,CAAC;AAEF,eAAO,M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;CAC1C;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,aAAa,CAoClF;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,iBAAiB,EAAE,EACnC,KAAK,EAAE,SAAS,iBAAiB,EAAE,GAClC,YAAY,CAyBd;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAY3D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEvF;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAEvF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
var SOFTWARE_GRAPH_VERSION = "1.0.0";
|
|
3
|
+
var NODE_TYPES = [
|
|
4
|
+
"Workspace",
|
|
5
|
+
"Application",
|
|
6
|
+
"Function",
|
|
7
|
+
"Method",
|
|
8
|
+
"Class",
|
|
9
|
+
"Interface",
|
|
10
|
+
"TypeAlias",
|
|
11
|
+
"Enum",
|
|
12
|
+
"Namespace",
|
|
13
|
+
"Module",
|
|
14
|
+
"Package",
|
|
15
|
+
"Script",
|
|
16
|
+
"Dependency",
|
|
17
|
+
"Task",
|
|
18
|
+
"Pipeline",
|
|
19
|
+
"BuildTarget",
|
|
20
|
+
"Configuration",
|
|
21
|
+
"Container",
|
|
22
|
+
"Workflow",
|
|
23
|
+
"Job",
|
|
24
|
+
"Step",
|
|
25
|
+
"Framework",
|
|
26
|
+
"Decorator",
|
|
27
|
+
"Import",
|
|
28
|
+
"Export",
|
|
29
|
+
"Route",
|
|
30
|
+
"Resource",
|
|
31
|
+
"Operation",
|
|
32
|
+
"Model",
|
|
33
|
+
"Field",
|
|
34
|
+
"Middleware",
|
|
35
|
+
"Provider",
|
|
36
|
+
"Factory",
|
|
37
|
+
"Service",
|
|
38
|
+
"Repository",
|
|
39
|
+
"DatabaseTable",
|
|
40
|
+
"EnvironmentVariable",
|
|
41
|
+
"Event",
|
|
42
|
+
"Permission",
|
|
43
|
+
"Exception",
|
|
44
|
+
"Controller",
|
|
45
|
+
"Guard"
|
|
46
|
+
];
|
|
47
|
+
var RELATIONSHIP_TYPES = [
|
|
48
|
+
"CALLS",
|
|
49
|
+
"IMPORTS",
|
|
50
|
+
"EXPORTS",
|
|
51
|
+
"USES",
|
|
52
|
+
"RETURNS",
|
|
53
|
+
"THROWS",
|
|
54
|
+
"READS",
|
|
55
|
+
"WRITES",
|
|
56
|
+
"CREATES",
|
|
57
|
+
"IMPLEMENTS",
|
|
58
|
+
"EXTENDS",
|
|
59
|
+
"DEPENDS_ON",
|
|
60
|
+
"DECORATES",
|
|
61
|
+
"INJECTS",
|
|
62
|
+
"REGISTERED_IN",
|
|
63
|
+
"REGISTERS",
|
|
64
|
+
"DECLARES",
|
|
65
|
+
"MOUNTS",
|
|
66
|
+
"PROVIDES",
|
|
67
|
+
"CONSUMES",
|
|
68
|
+
"CONFIGURES",
|
|
69
|
+
"EXECUTES",
|
|
70
|
+
"GENERATES",
|
|
71
|
+
"HANDLES",
|
|
72
|
+
"OVERRIDES",
|
|
73
|
+
"AUTHORIZES",
|
|
74
|
+
"BELONGS_TO",
|
|
75
|
+
"PUBLISHES",
|
|
76
|
+
"SUBSCRIBES",
|
|
77
|
+
"CONTAINS",
|
|
78
|
+
"EXPOSES",
|
|
79
|
+
"REFERENCES"
|
|
80
|
+
];
|
|
81
|
+
var NODE_TYPE_PREFIX = {
|
|
82
|
+
Workspace: "workspace",
|
|
83
|
+
Application: "app",
|
|
84
|
+
Function: "fn",
|
|
85
|
+
Method: "method",
|
|
86
|
+
Class: "class",
|
|
87
|
+
Interface: "iface",
|
|
88
|
+
TypeAlias: "type",
|
|
89
|
+
Enum: "enum",
|
|
90
|
+
Namespace: "ns",
|
|
91
|
+
Module: "mod",
|
|
92
|
+
Package: "pkg",
|
|
93
|
+
Script: "script",
|
|
94
|
+
Dependency: "dep",
|
|
95
|
+
Task: "task",
|
|
96
|
+
Pipeline: "pipeline",
|
|
97
|
+
BuildTarget: "target",
|
|
98
|
+
Configuration: "config",
|
|
99
|
+
Container: "container",
|
|
100
|
+
Workflow: "workflow",
|
|
101
|
+
Job: "job",
|
|
102
|
+
Step: "step",
|
|
103
|
+
Framework: "framework",
|
|
104
|
+
Decorator: "decorator",
|
|
105
|
+
Import: "import",
|
|
106
|
+
Export: "export",
|
|
107
|
+
Route: "route",
|
|
108
|
+
Resource: "resource",
|
|
109
|
+
Operation: "op",
|
|
110
|
+
Model: "model",
|
|
111
|
+
Field: "field",
|
|
112
|
+
Middleware: "middleware",
|
|
113
|
+
Provider: "provider",
|
|
114
|
+
Factory: "factory",
|
|
115
|
+
Service: "service",
|
|
116
|
+
Repository: "repo",
|
|
117
|
+
DatabaseTable: "table",
|
|
118
|
+
EnvironmentVariable: "env",
|
|
119
|
+
Event: "event",
|
|
120
|
+
Permission: "permission",
|
|
121
|
+
Exception: "exception",
|
|
122
|
+
Controller: "controller",
|
|
123
|
+
Guard: "guard"
|
|
124
|
+
};
|
|
125
|
+
function normalizePath(path) {
|
|
126
|
+
return path.replace(/\\/g, "/").replace(/\/+/g, "/").replace(/^\.\//, "");
|
|
127
|
+
}
|
|
128
|
+
function stableStringify(value) {
|
|
129
|
+
if (value === null || typeof value !== "object") {
|
|
130
|
+
return JSON.stringify(value);
|
|
131
|
+
}
|
|
132
|
+
if (Array.isArray(value)) {
|
|
133
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
134
|
+
}
|
|
135
|
+
const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([left], [right]) => left.localeCompare(right));
|
|
136
|
+
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`).join(",")}}`;
|
|
137
|
+
}
|
|
138
|
+
function stableHash(input) {
|
|
139
|
+
let hash = 2166136261;
|
|
140
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
141
|
+
hash ^= input.charCodeAt(index);
|
|
142
|
+
hash = Math.imul(hash, 16777619);
|
|
143
|
+
}
|
|
144
|
+
return (hash >>> 0).toString(36).padStart(7, "0");
|
|
145
|
+
}
|
|
146
|
+
function createNodeId(input) {
|
|
147
|
+
const prefix = NODE_TYPE_PREFIX[input.type];
|
|
148
|
+
const name = input.name.trim();
|
|
149
|
+
const normalizedFile = input.file ? normalizePath(input.file) : void 0;
|
|
150
|
+
if (normalizedFile) {
|
|
151
|
+
return `${prefix}:${normalizedFile}:${name}`;
|
|
152
|
+
}
|
|
153
|
+
if (input.signature) {
|
|
154
|
+
return `${prefix}:${name}:${stableHash(input.signature)}`;
|
|
155
|
+
}
|
|
156
|
+
return `${prefix}:${name}`;
|
|
157
|
+
}
|
|
158
|
+
function createEdgeId(type, from, to) {
|
|
159
|
+
return `edge:${type.toLowerCase()}:${stableHash(`${type}|${from}|${to}`)}`;
|
|
160
|
+
}
|
|
161
|
+
function createDiagnosticId(code, message, location = "") {
|
|
162
|
+
return `diag:${code.toLowerCase()}:${stableHash(`${code}|${message}|${location}`)}`;
|
|
163
|
+
}
|
|
164
|
+
function createSyntaxEvidence(span, description, confidence = "exact") {
|
|
165
|
+
const evidence = {
|
|
166
|
+
kind: "syntax",
|
|
167
|
+
confidence,
|
|
168
|
+
span
|
|
169
|
+
};
|
|
170
|
+
if (description) {
|
|
171
|
+
return { ...evidence, description };
|
|
172
|
+
}
|
|
173
|
+
return evidence;
|
|
174
|
+
}
|
|
175
|
+
function createGraphBuilder(repository) {
|
|
176
|
+
return new GraphBuilder(repository);
|
|
177
|
+
}
|
|
178
|
+
var GraphBuilder = class {
|
|
179
|
+
#repository;
|
|
180
|
+
#nodes = /* @__PURE__ */ new Map();
|
|
181
|
+
#edges = /* @__PURE__ */ new Map();
|
|
182
|
+
#diagnostics = /* @__PURE__ */ new Map();
|
|
183
|
+
#fileCount = 0;
|
|
184
|
+
#parserVersions = {};
|
|
185
|
+
constructor(repository) {
|
|
186
|
+
this.#repository = repository;
|
|
187
|
+
}
|
|
188
|
+
setFileCount(fileCount) {
|
|
189
|
+
this.#fileCount = fileCount;
|
|
190
|
+
}
|
|
191
|
+
setParserVersion(name, version) {
|
|
192
|
+
this.#parserVersions = {
|
|
193
|
+
...this.#parserVersions,
|
|
194
|
+
[name]: version
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
addNode(node) {
|
|
198
|
+
const normalizedNode = normalizeNode(node);
|
|
199
|
+
const existing = this.#nodes.get(normalizedNode.id);
|
|
200
|
+
if (!existing) {
|
|
201
|
+
this.#nodes.set(normalizedNode.id, normalizedNode);
|
|
202
|
+
return normalizedNode;
|
|
203
|
+
}
|
|
204
|
+
const merged = mergeNode(existing, normalizedNode);
|
|
205
|
+
this.#nodes.set(merged.id, merged);
|
|
206
|
+
return merged;
|
|
207
|
+
}
|
|
208
|
+
addEdge(edge) {
|
|
209
|
+
const normalizedEdge = normalizeEdge({
|
|
210
|
+
...edge,
|
|
211
|
+
id: edge.id ?? createEdgeId(edge.type, edge.from, edge.to)
|
|
212
|
+
});
|
|
213
|
+
const existing = this.#edges.get(normalizedEdge.id);
|
|
214
|
+
if (!existing) {
|
|
215
|
+
this.#edges.set(normalizedEdge.id, normalizedEdge);
|
|
216
|
+
return normalizedEdge;
|
|
217
|
+
}
|
|
218
|
+
const merged = mergeEdge(existing, normalizedEdge);
|
|
219
|
+
this.#edges.set(merged.id, merged);
|
|
220
|
+
return merged;
|
|
221
|
+
}
|
|
222
|
+
addDiagnostic(diagnostic) {
|
|
223
|
+
const existing = this.#diagnostics.get(diagnostic.id);
|
|
224
|
+
if (existing) {
|
|
225
|
+
return existing;
|
|
226
|
+
}
|
|
227
|
+
this.#diagnostics.set(diagnostic.id, diagnostic);
|
|
228
|
+
return diagnostic;
|
|
229
|
+
}
|
|
230
|
+
toGraph(durationMs) {
|
|
231
|
+
return createSoftwareGraph({
|
|
232
|
+
repository: this.#repository,
|
|
233
|
+
nodes: [...this.#nodes.values()],
|
|
234
|
+
edges: [...this.#edges.values()],
|
|
235
|
+
diagnostics: [...this.#diagnostics.values()],
|
|
236
|
+
fileCount: this.#fileCount,
|
|
237
|
+
parserVersions: this.#parserVersions,
|
|
238
|
+
durationMs
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
function createSoftwareGraph(input) {
|
|
243
|
+
const nodes = [...input.nodes].map(normalizeNode).sort(compareNodes);
|
|
244
|
+
const edges = [...input.edges].map(normalizeEdge).sort(compareEdges);
|
|
245
|
+
const diagnostics = [...input.diagnostics ?? []].sort(compareDiagnostics);
|
|
246
|
+
const indexes = buildIndexes(nodes, edges);
|
|
247
|
+
const deterministicHash = stableHash(
|
|
248
|
+
stableStringify({
|
|
249
|
+
repository: input.repository,
|
|
250
|
+
nodes,
|
|
251
|
+
edges,
|
|
252
|
+
diagnostics,
|
|
253
|
+
version: SOFTWARE_GRAPH_VERSION
|
|
254
|
+
})
|
|
255
|
+
);
|
|
256
|
+
const metadata = {
|
|
257
|
+
generatedAt: "1970-01-01T00:00:00.000Z",
|
|
258
|
+
deterministicHash,
|
|
259
|
+
fileCount: input.fileCount ?? 0,
|
|
260
|
+
nodeCount: nodes.length,
|
|
261
|
+
edgeCount: edges.length,
|
|
262
|
+
parserVersions: input.parserVersions ?? {}
|
|
263
|
+
};
|
|
264
|
+
const metadataWithDuration = input.durationMs === void 0 ? metadata : { ...metadata, durationMs: input.durationMs };
|
|
265
|
+
return {
|
|
266
|
+
version: SOFTWARE_GRAPH_VERSION,
|
|
267
|
+
repository: input.repository,
|
|
268
|
+
nodes,
|
|
269
|
+
edges,
|
|
270
|
+
diagnostics,
|
|
271
|
+
indexes,
|
|
272
|
+
metadata: metadataWithDuration
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function buildIndexes(nodes, edges) {
|
|
276
|
+
const nodeIdsByType = {};
|
|
277
|
+
const edgeIdsByType = {};
|
|
278
|
+
const inboundEdgeIdsByNodeId = {};
|
|
279
|
+
const outboundEdgeIdsByNodeId = {};
|
|
280
|
+
const edgeIdsBySourceAndType = {};
|
|
281
|
+
for (const node of nodes) {
|
|
282
|
+
pushIndexValue(nodeIdsByType, node.type, node.id);
|
|
283
|
+
}
|
|
284
|
+
for (const edge of edges) {
|
|
285
|
+
pushIndexValue(edgeIdsByType, edge.type, edge.id);
|
|
286
|
+
pushRecordValue(outboundEdgeIdsByNodeId, edge.from, edge.id);
|
|
287
|
+
pushRecordValue(inboundEdgeIdsByNodeId, edge.to, edge.id);
|
|
288
|
+
pushRecordValue(edgeIdsBySourceAndType, `${edge.from}:${edge.type}`, edge.id);
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
nodeIdsByType: sortIndex(nodeIdsByType),
|
|
292
|
+
edgeIdsByType: sortIndex(edgeIdsByType),
|
|
293
|
+
inboundEdgeIdsByNodeId: sortRecord(inboundEdgeIdsByNodeId),
|
|
294
|
+
outboundEdgeIdsByNodeId: sortRecord(outboundEdgeIdsByNodeId),
|
|
295
|
+
edgeIdsBySourceAndType: sortRecord(edgeIdsBySourceAndType)
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function summarizeGraph(graph) {
|
|
299
|
+
const nodeSummary = summarizeCounts(graph.nodes.map((node) => node.type));
|
|
300
|
+
const edgeSummary = summarizeCounts(graph.edges.map((edge) => edge.type));
|
|
301
|
+
return [
|
|
302
|
+
`Repository: ${graph.repository.name}`,
|
|
303
|
+
`Files: ${graph.metadata.fileCount}`,
|
|
304
|
+
`Nodes: ${graph.nodes.length}${nodeSummary ? ` (${nodeSummary})` : ""}`,
|
|
305
|
+
`Edges: ${graph.edges.length}${edgeSummary ? ` (${edgeSummary})` : ""}`,
|
|
306
|
+
`Diagnostics: ${graph.diagnostics.length}`,
|
|
307
|
+
`Hash: ${graph.metadata.deterministicHash}`
|
|
308
|
+
].join("\n");
|
|
309
|
+
}
|
|
310
|
+
function getNode(graph, id) {
|
|
311
|
+
return graph.nodes.find((node) => node.id === id);
|
|
312
|
+
}
|
|
313
|
+
function getEdge(graph, id) {
|
|
314
|
+
return graph.edges.find((edge) => edge.id === id);
|
|
315
|
+
}
|
|
316
|
+
function normalizeNode(node) {
|
|
317
|
+
const normalized = {
|
|
318
|
+
id: node.id,
|
|
319
|
+
type: node.type,
|
|
320
|
+
name: node.name
|
|
321
|
+
};
|
|
322
|
+
return withOptionalProperties(normalized, {
|
|
323
|
+
file: node.file ? normalizePath(node.file) : void 0,
|
|
324
|
+
package: node.package,
|
|
325
|
+
span: node.span ? normalizeSpan(node.span) : void 0,
|
|
326
|
+
metadata: node.metadata
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
function normalizeEdge(edge) {
|
|
330
|
+
const normalized = {
|
|
331
|
+
id: edge.id,
|
|
332
|
+
type: edge.type,
|
|
333
|
+
from: edge.from,
|
|
334
|
+
to: edge.to
|
|
335
|
+
};
|
|
336
|
+
return withOptionalProperties(normalized, {
|
|
337
|
+
evidence: edge.evidence?.map((item) => ({
|
|
338
|
+
...item,
|
|
339
|
+
span: item.span ? normalizeSpan(item.span) : void 0
|
|
340
|
+
})),
|
|
341
|
+
metadata: edge.metadata
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function normalizeSpan(span) {
|
|
345
|
+
return {
|
|
346
|
+
...span,
|
|
347
|
+
file: normalizePath(span.file)
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function mergeNode(left, right) {
|
|
351
|
+
const merged = {
|
|
352
|
+
...left,
|
|
353
|
+
metadata: mergeJsonObject(left.metadata, right.metadata)
|
|
354
|
+
};
|
|
355
|
+
return withOptionalProperties(merged, {
|
|
356
|
+
span: left.span ?? right.span,
|
|
357
|
+
file: left.file ?? right.file,
|
|
358
|
+
package: left.package ?? right.package
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function mergeEdge(left, right) {
|
|
362
|
+
const evidence = dedupeEvidence([...left.evidence ?? [], ...right.evidence ?? []]);
|
|
363
|
+
const merged = {
|
|
364
|
+
...left,
|
|
365
|
+
metadata: mergeJsonObject(left.metadata, right.metadata)
|
|
366
|
+
};
|
|
367
|
+
return withOptionalProperties(merged, {
|
|
368
|
+
evidence: evidence.length > 0 ? evidence : void 0
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function mergeJsonObject(left, right) {
|
|
372
|
+
if (!left && !right) {
|
|
373
|
+
return void 0;
|
|
374
|
+
}
|
|
375
|
+
return {
|
|
376
|
+
...left ?? {},
|
|
377
|
+
...right ?? {}
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
function dedupeEvidence(evidence) {
|
|
381
|
+
const seen = /* @__PURE__ */ new Set();
|
|
382
|
+
const deduped = [];
|
|
383
|
+
for (const item of evidence) {
|
|
384
|
+
const key = stableStringify(item);
|
|
385
|
+
if (!seen.has(key)) {
|
|
386
|
+
seen.add(key);
|
|
387
|
+
deduped.push(item);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return deduped.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));
|
|
391
|
+
}
|
|
392
|
+
function pushIndexValue(index, key, value) {
|
|
393
|
+
const values = index[key] ?? [];
|
|
394
|
+
values.push(value);
|
|
395
|
+
index[key] = values;
|
|
396
|
+
}
|
|
397
|
+
function pushRecordValue(index, key, value) {
|
|
398
|
+
const values = index[key] ?? [];
|
|
399
|
+
values.push(value);
|
|
400
|
+
index[key] = values;
|
|
401
|
+
}
|
|
402
|
+
function sortIndex(index) {
|
|
403
|
+
const sortedEntries = Object.entries(index).map(([key, values]) => [key, [...values].sort()]).sort(([left], [right]) => left.localeCompare(right));
|
|
404
|
+
return Object.fromEntries(sortedEntries);
|
|
405
|
+
}
|
|
406
|
+
function sortRecord(index) {
|
|
407
|
+
return Object.fromEntries(
|
|
408
|
+
Object.entries(index).map(([key, values]) => [key, [...values].sort()]).sort(([left], [right]) => left.localeCompare(right))
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function summarizeCounts(values) {
|
|
412
|
+
const counts = /* @__PURE__ */ new Map();
|
|
413
|
+
for (const value of values) {
|
|
414
|
+
counts.set(value, (counts.get(value) ?? 0) + 1);
|
|
415
|
+
}
|
|
416
|
+
return [...counts.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([value, count]) => `${value} ${count}`).join(", ");
|
|
417
|
+
}
|
|
418
|
+
function compareNodes(left, right) {
|
|
419
|
+
return left.id.localeCompare(right.id);
|
|
420
|
+
}
|
|
421
|
+
function compareEdges(left, right) {
|
|
422
|
+
return left.id.localeCompare(right.id);
|
|
423
|
+
}
|
|
424
|
+
function compareDiagnostics(left, right) {
|
|
425
|
+
return left.id.localeCompare(right.id);
|
|
426
|
+
}
|
|
427
|
+
function withOptionalProperties(target, optional) {
|
|
428
|
+
const entries = Object.entries(optional).filter(([, value]) => value !== void 0);
|
|
429
|
+
return {
|
|
430
|
+
...target,
|
|
431
|
+
...Object.fromEntries(entries)
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
export {
|
|
435
|
+
GraphBuilder,
|
|
436
|
+
NODE_TYPES,
|
|
437
|
+
RELATIONSHIP_TYPES,
|
|
438
|
+
SOFTWARE_GRAPH_VERSION,
|
|
439
|
+
buildIndexes,
|
|
440
|
+
createDiagnosticId,
|
|
441
|
+
createEdgeId,
|
|
442
|
+
createGraphBuilder,
|
|
443
|
+
createNodeId,
|
|
444
|
+
createSoftwareGraph,
|
|
445
|
+
createSyntaxEvidence,
|
|
446
|
+
getEdge,
|
|
447
|
+
getNode,
|
|
448
|
+
normalizePath,
|
|
449
|
+
stableHash,
|
|
450
|
+
stableStringify,
|
|
451
|
+
summarizeGraph
|
|
452
|
+
};
|
|
453
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export const SOFTWARE_GRAPH_VERSION = \"1.0.0\";\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = {\n readonly [key: string]: JsonValue | undefined;\n};\n\nexport const NODE_TYPES = [\n \"Workspace\",\n \"Application\",\n \"Function\",\n \"Method\",\n \"Class\",\n \"Interface\",\n \"TypeAlias\",\n \"Enum\",\n \"Namespace\",\n \"Module\",\n \"Package\",\n \"Script\",\n \"Dependency\",\n \"Task\",\n \"Pipeline\",\n \"BuildTarget\",\n \"Configuration\",\n \"Container\",\n \"Workflow\",\n \"Job\",\n \"Step\",\n \"Framework\",\n \"Decorator\",\n \"Import\",\n \"Export\",\n \"Route\",\n \"Resource\",\n \"Operation\",\n \"Model\",\n \"Field\",\n \"Middleware\",\n \"Provider\",\n \"Factory\",\n \"Service\",\n \"Repository\",\n \"DatabaseTable\",\n \"EnvironmentVariable\",\n \"Event\",\n \"Permission\",\n \"Exception\",\n \"Controller\",\n \"Guard\",\n] as const;\n\nexport type NodeType = (typeof NODE_TYPES)[number];\n\nexport const RELATIONSHIP_TYPES = [\n \"CALLS\",\n \"IMPORTS\",\n \"EXPORTS\",\n \"USES\",\n \"RETURNS\",\n \"THROWS\",\n \"READS\",\n \"WRITES\",\n \"CREATES\",\n \"IMPLEMENTS\",\n \"EXTENDS\",\n \"DEPENDS_ON\",\n \"DECORATES\",\n \"INJECTS\",\n \"REGISTERED_IN\",\n \"REGISTERS\",\n \"DECLARES\",\n \"MOUNTS\",\n \"PROVIDES\",\n \"CONSUMES\",\n \"CONFIGURES\",\n \"EXECUTES\",\n \"GENERATES\",\n \"HANDLES\",\n \"OVERRIDES\",\n \"AUTHORIZES\",\n \"BELONGS_TO\",\n \"PUBLISHES\",\n \"SUBSCRIBES\",\n \"CONTAINS\",\n \"EXPOSES\",\n \"REFERENCES\",\n] as const;\n\nexport type RelationshipType = (typeof RELATIONSHIP_TYPES)[number];\n\nexport type DiagnosticSeverity = \"info\" | \"warning\" | \"error\";\n\nexport interface SourceSpan {\n readonly file: string;\n readonly startLine: number;\n readonly startColumn: number;\n readonly endLine: number;\n readonly endColumn: number;\n}\n\nexport interface SoftwareGraphRepository {\n readonly root: string;\n readonly name: string;\n readonly packageManager?: string | undefined;\n readonly packageName?: string | undefined;\n}\n\nexport interface SoftwareGraphNode {\n readonly id: string;\n readonly type: NodeType;\n readonly name: string;\n readonly file?: string | undefined;\n readonly package?: string | undefined;\n readonly span?: SourceSpan | undefined;\n readonly metadata?: JsonObject | undefined;\n}\n\nexport interface EdgeEvidence {\n readonly kind: \"syntax\" | \"resolver\" | \"config\" | \"semantic\" | \"plugin\";\n readonly confidence: \"exact\" | \"inferred\" | \"low\";\n readonly span?: SourceSpan | undefined;\n readonly description?: string | undefined;\n}\n\nexport interface SoftwareGraphEdge {\n readonly id: string;\n readonly type: RelationshipType;\n readonly from: string;\n readonly to: string;\n readonly evidence?: readonly EdgeEvidence[] | undefined;\n readonly metadata?: JsonObject | undefined;\n}\n\nexport interface SoftwareGraphDiagnostic {\n readonly id: string;\n readonly code: string;\n readonly severity: DiagnosticSeverity;\n readonly message: string;\n readonly nodeId?: string | undefined;\n readonly edgeId?: string | undefined;\n readonly span?: SourceSpan | undefined;\n readonly metadata?: JsonObject | undefined;\n}\n\nexport interface GraphIndexes {\n readonly nodeIdsByType: Partial<Record<NodeType, readonly string[]>>;\n readonly edgeIdsByType: Partial<Record<RelationshipType, readonly string[]>>;\n readonly inboundEdgeIdsByNodeId: Record<string, readonly string[]>;\n readonly outboundEdgeIdsByNodeId: Record<string, readonly string[]>;\n readonly edgeIdsBySourceAndType: Record<string, readonly string[]>;\n}\n\nexport interface SoftwareGraphMetadata {\n readonly generatedAt: string;\n readonly deterministicHash: string;\n readonly fileCount: number;\n readonly nodeCount: number;\n readonly edgeCount: number;\n readonly parserVersions: Record<string, string>;\n readonly durationMs?: number | undefined;\n}\n\nexport interface SoftwareGraph {\n readonly version: string;\n readonly repository: SoftwareGraphRepository;\n readonly nodes: readonly SoftwareGraphNode[];\n readonly edges: readonly SoftwareGraphEdge[];\n readonly diagnostics: readonly SoftwareGraphDiagnostic[];\n readonly indexes: GraphIndexes;\n readonly metadata: SoftwareGraphMetadata;\n}\n\nexport interface CreateNodeIdInput {\n readonly type: NodeType;\n readonly name: string;\n readonly file?: string | undefined;\n readonly signature?: string | undefined;\n}\n\nexport interface OntolyPluginContext {\n readonly graph: SoftwareGraph;\n}\n\nexport interface OntolyPluginResult {\n readonly artifacts?: readonly PluginArtifact[] | undefined;\n readonly diagnostics?: readonly SoftwareGraphDiagnostic[] | undefined;\n}\n\nexport interface PluginArtifact {\n readonly path: string;\n readonly contents: string;\n readonly mediaType: string;\n}\n\nexport interface OntolyPlugin {\n readonly name: string;\n readonly version: string;\n readonly run: (context: OntolyPluginContext) => Promise<OntolyPluginResult> | OntolyPluginResult;\n}\n\nconst NODE_TYPE_PREFIX: Record<NodeType, string> = {\n Workspace: \"workspace\",\n Application: \"app\",\n Function: \"fn\",\n Method: \"method\",\n Class: \"class\",\n Interface: \"iface\",\n TypeAlias: \"type\",\n Enum: \"enum\",\n Namespace: \"ns\",\n Module: \"mod\",\n Package: \"pkg\",\n Script: \"script\",\n Dependency: \"dep\",\n Task: \"task\",\n Pipeline: \"pipeline\",\n BuildTarget: \"target\",\n Configuration: \"config\",\n Container: \"container\",\n Workflow: \"workflow\",\n Job: \"job\",\n Step: \"step\",\n Framework: \"framework\",\n Decorator: \"decorator\",\n Import: \"import\",\n Export: \"export\",\n Route: \"route\",\n Resource: \"resource\",\n Operation: \"op\",\n Model: \"model\",\n Field: \"field\",\n Middleware: \"middleware\",\n Provider: \"provider\",\n Factory: \"factory\",\n Service: \"service\",\n Repository: \"repo\",\n DatabaseTable: \"table\",\n EnvironmentVariable: \"env\",\n Event: \"event\",\n Permission: \"permission\",\n Exception: \"exception\",\n Controller: \"controller\",\n Guard: \"guard\",\n};\n\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\").replace(/\\/+/g, \"/\").replace(/^\\.\\//, \"\");\n}\n\nexport function stableStringify(value: unknown): string {\n if (value === null || typeof value !== \"object\") {\n return JSON.stringify(value);\n }\n\n if (Array.isArray(value)) {\n return `[${value.map((item) => stableStringify(item)).join(\",\")}]`;\n }\n\n const entries = Object.entries(value as Record<string, unknown>)\n .filter(([, entryValue]) => entryValue !== undefined)\n .sort(([left], [right]) => left.localeCompare(right));\n\n return `{${entries\n .map(([key, entryValue]) => `${JSON.stringify(key)}:${stableStringify(entryValue)}`)\n .join(\",\")}}`;\n}\n\nexport function stableHash(input: string): string {\n let hash = 0x811c9dc5;\n\n for (let index = 0; index < input.length; index += 1) {\n hash ^= input.charCodeAt(index);\n hash = Math.imul(hash, 0x01000193);\n }\n\n return (hash >>> 0).toString(36).padStart(7, \"0\");\n}\n\nexport function createNodeId(input: CreateNodeIdInput): string {\n const prefix = NODE_TYPE_PREFIX[input.type];\n const name = input.name.trim();\n const normalizedFile = input.file ? normalizePath(input.file) : undefined;\n\n if (normalizedFile) {\n return `${prefix}:${normalizedFile}:${name}`;\n }\n\n if (input.signature) {\n return `${prefix}:${name}:${stableHash(input.signature)}`;\n }\n\n return `${prefix}:${name}`;\n}\n\nexport function createEdgeId(type: RelationshipType, from: string, to: string): string {\n return `edge:${type.toLowerCase()}:${stableHash(`${type}|${from}|${to}`)}`;\n}\n\nexport function createDiagnosticId(code: string, message: string, location = \"\"): string {\n return `diag:${code.toLowerCase()}:${stableHash(`${code}|${message}|${location}`)}`;\n}\n\nexport function createSyntaxEvidence(\n span: SourceSpan,\n description?: string,\n confidence: EdgeEvidence[\"confidence\"] = \"exact\",\n): EdgeEvidence {\n const evidence: EdgeEvidence = {\n kind: \"syntax\",\n confidence,\n span,\n };\n\n if (description) {\n return { ...evidence, description };\n }\n\n return evidence;\n}\n\nexport function createGraphBuilder(repository: SoftwareGraphRepository): GraphBuilder {\n return new GraphBuilder(repository);\n}\n\nexport class GraphBuilder {\n readonly #repository: SoftwareGraphRepository;\n readonly #nodes = new Map<string, SoftwareGraphNode>();\n readonly #edges = new Map<string, SoftwareGraphEdge>();\n readonly #diagnostics = new Map<string, SoftwareGraphDiagnostic>();\n #fileCount = 0;\n #parserVersions: Record<string, string> = {};\n\n constructor(repository: SoftwareGraphRepository) {\n this.#repository = repository;\n }\n\n setFileCount(fileCount: number): void {\n this.#fileCount = fileCount;\n }\n\n setParserVersion(name: string, version: string): void {\n this.#parserVersions = {\n ...this.#parserVersions,\n [name]: version,\n };\n }\n\n addNode(node: SoftwareGraphNode): SoftwareGraphNode {\n const normalizedNode = normalizeNode(node);\n const existing = this.#nodes.get(normalizedNode.id);\n\n if (!existing) {\n this.#nodes.set(normalizedNode.id, normalizedNode);\n return normalizedNode;\n }\n\n const merged = mergeNode(existing, normalizedNode);\n this.#nodes.set(merged.id, merged);\n return merged;\n }\n\n addEdge(edge: Omit<SoftwareGraphEdge, \"id\"> & { readonly id?: string | undefined }): SoftwareGraphEdge {\n const normalizedEdge = normalizeEdge({\n ...edge,\n id: edge.id ?? createEdgeId(edge.type, edge.from, edge.to),\n });\n const existing = this.#edges.get(normalizedEdge.id);\n\n if (!existing) {\n this.#edges.set(normalizedEdge.id, normalizedEdge);\n return normalizedEdge;\n }\n\n const merged = mergeEdge(existing, normalizedEdge);\n this.#edges.set(merged.id, merged);\n return merged;\n }\n\n addDiagnostic(diagnostic: SoftwareGraphDiagnostic): SoftwareGraphDiagnostic {\n const existing = this.#diagnostics.get(diagnostic.id);\n\n if (existing) {\n return existing;\n }\n\n this.#diagnostics.set(diagnostic.id, diagnostic);\n return diagnostic;\n }\n\n toGraph(durationMs?: number): SoftwareGraph {\n return createSoftwareGraph({\n repository: this.#repository,\n nodes: [...this.#nodes.values()],\n edges: [...this.#edges.values()],\n diagnostics: [...this.#diagnostics.values()],\n fileCount: this.#fileCount,\n parserVersions: this.#parserVersions,\n durationMs,\n });\n }\n}\n\nexport interface CreateSoftwareGraphInput {\n readonly repository: SoftwareGraphRepository;\n readonly nodes: readonly SoftwareGraphNode[];\n readonly edges: readonly SoftwareGraphEdge[];\n readonly diagnostics?: readonly SoftwareGraphDiagnostic[] | undefined;\n readonly fileCount?: number | undefined;\n readonly parserVersions?: Record<string, string> | undefined;\n readonly durationMs?: number | undefined;\n}\n\nexport function createSoftwareGraph(input: CreateSoftwareGraphInput): SoftwareGraph {\n const nodes = [...input.nodes].map(normalizeNode).sort(compareNodes);\n const edges = [...input.edges].map(normalizeEdge).sort(compareEdges);\n const diagnostics = [...(input.diagnostics ?? [])].sort(compareDiagnostics);\n const indexes = buildIndexes(nodes, edges);\n const deterministicHash = stableHash(\n stableStringify({\n repository: input.repository,\n nodes,\n edges,\n diagnostics,\n version: SOFTWARE_GRAPH_VERSION,\n }),\n );\n\n const metadata: SoftwareGraphMetadata = {\n generatedAt: \"1970-01-01T00:00:00.000Z\",\n deterministicHash,\n fileCount: input.fileCount ?? 0,\n nodeCount: nodes.length,\n edgeCount: edges.length,\n parserVersions: input.parserVersions ?? {},\n };\n\n const metadataWithDuration =\n input.durationMs === undefined ? metadata : { ...metadata, durationMs: input.durationMs };\n\n return {\n version: SOFTWARE_GRAPH_VERSION,\n repository: input.repository,\n nodes,\n edges,\n diagnostics,\n indexes,\n metadata: metadataWithDuration,\n };\n}\n\nexport function buildIndexes(\n nodes: readonly SoftwareGraphNode[],\n edges: readonly SoftwareGraphEdge[],\n): GraphIndexes {\n const nodeIdsByType: Partial<Record<NodeType, string[]>> = {};\n const edgeIdsByType: Partial<Record<RelationshipType, string[]>> = {};\n const inboundEdgeIdsByNodeId: Record<string, string[]> = {};\n const outboundEdgeIdsByNodeId: Record<string, string[]> = {};\n const edgeIdsBySourceAndType: Record<string, string[]> = {};\n\n for (const node of nodes) {\n pushIndexValue(nodeIdsByType, node.type, node.id);\n }\n\n for (const edge of edges) {\n pushIndexValue(edgeIdsByType, edge.type, edge.id);\n pushRecordValue(outboundEdgeIdsByNodeId, edge.from, edge.id);\n pushRecordValue(inboundEdgeIdsByNodeId, edge.to, edge.id);\n pushRecordValue(edgeIdsBySourceAndType, `${edge.from}:${edge.type}`, edge.id);\n }\n\n return {\n nodeIdsByType: sortIndex(nodeIdsByType),\n edgeIdsByType: sortIndex(edgeIdsByType),\n inboundEdgeIdsByNodeId: sortRecord(inboundEdgeIdsByNodeId),\n outboundEdgeIdsByNodeId: sortRecord(outboundEdgeIdsByNodeId),\n edgeIdsBySourceAndType: sortRecord(edgeIdsBySourceAndType),\n };\n}\n\nexport function summarizeGraph(graph: SoftwareGraph): string {\n const nodeSummary = summarizeCounts(graph.nodes.map((node) => node.type));\n const edgeSummary = summarizeCounts(graph.edges.map((edge) => edge.type));\n\n return [\n `Repository: ${graph.repository.name}`,\n `Files: ${graph.metadata.fileCount}`,\n `Nodes: ${graph.nodes.length}${nodeSummary ? ` (${nodeSummary})` : \"\"}`,\n `Edges: ${graph.edges.length}${edgeSummary ? ` (${edgeSummary})` : \"\"}`,\n `Diagnostics: ${graph.diagnostics.length}`,\n `Hash: ${graph.metadata.deterministicHash}`,\n ].join(\"\\n\");\n}\n\nexport function getNode(graph: SoftwareGraph, id: string): SoftwareGraphNode | undefined {\n return graph.nodes.find((node) => node.id === id);\n}\n\nexport function getEdge(graph: SoftwareGraph, id: string): SoftwareGraphEdge | undefined {\n return graph.edges.find((edge) => edge.id === id);\n}\n\nfunction normalizeNode(node: SoftwareGraphNode): SoftwareGraphNode {\n const normalized: SoftwareGraphNode = {\n id: node.id,\n type: node.type,\n name: node.name,\n };\n\n return withOptionalProperties(normalized, {\n file: node.file ? normalizePath(node.file) : undefined,\n package: node.package,\n span: node.span ? normalizeSpan(node.span) : undefined,\n metadata: node.metadata,\n });\n}\n\nfunction normalizeEdge(edge: SoftwareGraphEdge): SoftwareGraphEdge {\n const normalized: SoftwareGraphEdge = {\n id: edge.id,\n type: edge.type,\n from: edge.from,\n to: edge.to,\n };\n\n return withOptionalProperties(normalized, {\n evidence: edge.evidence?.map((item) => ({\n ...item,\n span: item.span ? normalizeSpan(item.span) : undefined,\n })),\n metadata: edge.metadata,\n });\n}\n\nfunction normalizeSpan(span: SourceSpan): SourceSpan {\n return {\n ...span,\n file: normalizePath(span.file),\n };\n}\n\nfunction mergeNode(left: SoftwareGraphNode, right: SoftwareGraphNode): SoftwareGraphNode {\n const merged: SoftwareGraphNode = {\n ...left,\n metadata: mergeJsonObject(left.metadata, right.metadata),\n };\n\n return withOptionalProperties(merged, {\n span: left.span ?? right.span,\n file: left.file ?? right.file,\n package: left.package ?? right.package,\n });\n}\n\nfunction mergeEdge(left: SoftwareGraphEdge, right: SoftwareGraphEdge): SoftwareGraphEdge {\n const evidence = dedupeEvidence([...(left.evidence ?? []), ...(right.evidence ?? [])]);\n const merged: SoftwareGraphEdge = {\n ...left,\n metadata: mergeJsonObject(left.metadata, right.metadata),\n };\n\n return withOptionalProperties(merged, {\n evidence: evidence.length > 0 ? evidence : undefined,\n });\n}\n\nfunction mergeJsonObject(\n left: JsonObject | undefined,\n right: JsonObject | undefined,\n): JsonObject | undefined {\n if (!left && !right) {\n return undefined;\n }\n\n return {\n ...(left ?? {}),\n ...(right ?? {}),\n };\n}\n\nfunction dedupeEvidence(evidence: readonly EdgeEvidence[]): readonly EdgeEvidence[] {\n const seen = new Set<string>();\n const deduped: EdgeEvidence[] = [];\n\n for (const item of evidence) {\n const key = stableStringify(item);\n\n if (!seen.has(key)) {\n seen.add(key);\n deduped.push(item);\n }\n }\n\n return deduped.sort((left, right) => stableStringify(left).localeCompare(stableStringify(right)));\n}\n\nfunction pushIndexValue<T extends string>(\n index: Partial<Record<T, string[]>>,\n key: T,\n value: string,\n): void {\n const values = index[key] ?? [];\n values.push(value);\n index[key] = values;\n}\n\nfunction pushRecordValue(index: Record<string, string[]>, key: string, value: string): void {\n const values = index[key] ?? [];\n values.push(value);\n index[key] = values;\n}\n\nfunction sortIndex<T extends string>(\n index: Partial<Record<T, string[]>>,\n): Partial<Record<T, readonly string[]>> {\n const sortedEntries = Object.entries(index)\n .map(([key, values]) => [key, [...(values as string[])].sort()] as const)\n .sort(([left], [right]) => left.localeCompare(right));\n\n return Object.fromEntries(sortedEntries) as unknown as Partial<Record<T, readonly string[]>>;\n}\n\nfunction sortRecord(index: Record<string, string[]>): Record<string, readonly string[]> {\n return Object.fromEntries(\n Object.entries(index)\n .map(([key, values]) => [key, [...values].sort()] as const)\n .sort(([left], [right]) => left.localeCompare(right)),\n );\n}\n\nfunction summarizeCounts(values: readonly string[]): string {\n const counts = new Map<string, number>();\n\n for (const value of values) {\n counts.set(value, (counts.get(value) ?? 0) + 1);\n }\n\n return [...counts.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([value, count]) => `${value} ${count}`)\n .join(\", \");\n}\n\nfunction compareNodes(left: SoftwareGraphNode, right: SoftwareGraphNode): number {\n return left.id.localeCompare(right.id);\n}\n\nfunction compareEdges(left: SoftwareGraphEdge, right: SoftwareGraphEdge): number {\n return left.id.localeCompare(right.id);\n}\n\nfunction compareDiagnostics(\n left: SoftwareGraphDiagnostic,\n right: SoftwareGraphDiagnostic,\n): number {\n return left.id.localeCompare(right.id);\n}\n\nfunction withOptionalProperties<T extends object, O extends object>(target: T, optional: O): T & O {\n const entries = Object.entries(optional).filter(([, value]) => value !== undefined);\n return {\n ...target,\n ...Object.fromEntries(entries),\n } as T & O;\n}\n"],"mappings":";AAAO,IAAM,yBAAyB;AAQ/B,IAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAEA,SAAO,CAAC,GAAG,OAAO,QAAQ,CAAC,EACxB,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,cAAc,KAAK,CAAC,EACnD,IAAI,CAAC,CAAC,OAAO,KAAK,MAAM,GAAG,KAAK,IAAI,KAAK,EAAE,EAC3C,KAAK,IAAI;AACd;AAEA,SAAS,aAAa,MAAyB,OAAkC;AAC/E,SAAO,KAAK,GAAG,cAAc,MAAM,EAAE;AACvC;AAEA,SAAS,aAAa,MAAyB,OAAkC;AAC/E,SAAO,KAAK,GAAG,cAAc,MAAM,EAAE;AACvC;AAEA,SAAS,mBACP,MACA,OACQ;AACR,SAAO,KAAK,GAAG,cAAc,MAAM,EAAE;AACvC;AAEA,SAAS,uBAA2D,QAAW,UAAoB;AACjG,QAAM,UAAU,OAAO,QAAQ,QAAQ,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAClF,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG,OAAO,YAAY,OAAO;AAAA,EAC/B;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0xsarwagya/ontoly-core",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Software Graph schema, stable IDs, indexes, and graph helpers for Ontoly.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/0xsarwagya/ontoly.git",
|
|
10
|
+
"directory": "packages/core"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://oss.sarwagya.wtf/ontoly",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.15.3",
|
|
30
|
+
"tsup": "^8.3.5",
|
|
31
|
+
"typescript": "5.9.2",
|
|
32
|
+
"vitest": "^3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/0xsarwagya/ontoly/issues"
|
|
36
|
+
},
|
|
37
|
+
"funding": {
|
|
38
|
+
"type": "github",
|
|
39
|
+
"url": "https://github.com/sponsors/0xsarwagya"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=22.0.0",
|
|
43
|
+
"pnpm": ">=11.0.0"
|
|
44
|
+
},
|
|
45
|
+
"main": "./dist/index.js",
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"ontoly",
|
|
49
|
+
"software-graph",
|
|
50
|
+
"typescript",
|
|
51
|
+
"static-analysis",
|
|
52
|
+
"developer-tools",
|
|
53
|
+
"schema",
|
|
54
|
+
"stable-ids"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
58
|
+
"check-types": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run tests"
|
|
60
|
+
}
|
|
61
|
+
}
|