@git-stunts/git-warp 10.1.1 → 10.1.2
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/index.js
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* @
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
6
|
+
* Deterministic WARP graph over Git: graph-native storage, traversal,
|
|
7
|
+
* and tooling. All graph state lives as Git commits pointing to the
|
|
8
|
+
* well-known empty tree — invisible to normal Git workflows, but
|
|
9
|
+
* inheriting content-addressing, cryptographic integrity, and
|
|
10
|
+
* distributed replication.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import WarpGraph from "@git-stunts/git-warp";
|
|
15
|
+
*
|
|
16
|
+
* const graph = await WarpGraph.open({ repo: ".", graphName: "myGraph" });
|
|
17
|
+
* const patch = await graph.createPatch("writer-1");
|
|
18
|
+
* patch.addNode("user:alice").setProperty("user:alice", "name", "Alice");
|
|
19
|
+
* await patch.commit();
|
|
20
|
+
* const state = await graph.materialize();
|
|
21
|
+
* ```
|
|
3
22
|
*/
|
|
4
23
|
|
|
5
24
|
import GitGraphAdapter from './src/infrastructure/adapters/GitGraphAdapter.js';
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable value object representing a single graph node backed by a
|
|
3
|
+
* Git commit pointing to the empty tree.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Immutable entity representing a graph node.
|
|
10
|
+
*/
|
|
11
|
+
export default class GraphNode {
|
|
12
|
+
/** Commit SHA */
|
|
13
|
+
readonly sha: string;
|
|
14
|
+
/** Author name */
|
|
15
|
+
readonly author: string | undefined;
|
|
16
|
+
/** Commit date */
|
|
17
|
+
readonly date: string | undefined;
|
|
18
|
+
/** Node message/data */
|
|
19
|
+
readonly message: string;
|
|
20
|
+
/** Array of parent SHAs */
|
|
21
|
+
readonly parents: readonly string[];
|
|
22
|
+
|
|
23
|
+
constructor(data: {
|
|
24
|
+
sha: string;
|
|
25
|
+
message: string;
|
|
26
|
+
author?: string;
|
|
27
|
+
date?: string;
|
|
28
|
+
parents?: string[];
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/* @ts-self-types="./GraphNode.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
6
|
+
* Immutable value object representing a single graph node backed by a
|
|
7
|
+
* Git commit pointing to the empty tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
/**
|
|
2
11
|
* Immutable domain entity representing a node in the graph.
|
|
3
12
|
*
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visualization module for rendering WARP graph data as ASCII tables,
|
|
3
|
+
* SVG diagrams, and interactive browser views.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ASCII renderers
|
|
9
|
+
export declare const colors: Record<string, (s: string) => string>;
|
|
10
|
+
export declare const colorsDefault: Record<string, (s: string) => string>;
|
|
11
|
+
export declare function createBox(content: string, options?: Record<string, unknown>): string;
|
|
12
|
+
export declare function createTable(rows: unknown[], options?: Record<string, unknown>): string;
|
|
13
|
+
export declare function progressBar(current: number, total: number, options?: Record<string, unknown>): string;
|
|
14
|
+
export declare function renderInfoView(data: Record<string, unknown>): string;
|
|
15
|
+
export declare function renderCheckView(data: Record<string, unknown>): string;
|
|
16
|
+
export declare function renderMaterializeView(data: Record<string, unknown>): string;
|
|
17
|
+
export declare function renderHistoryView(data: Record<string, unknown>): string;
|
|
18
|
+
export declare function summarizeOps(ops: unknown[]): string;
|
|
19
|
+
export declare function renderPathView(data: Record<string, unknown>): string;
|
|
20
|
+
export declare function renderGraphView(data: Record<string, unknown>): string;
|
|
21
|
+
|
|
22
|
+
// SVG renderer
|
|
23
|
+
export declare function renderSvg(positionedGraph: Record<string, unknown>, options?: Record<string, unknown>): string;
|
|
24
|
+
|
|
25
|
+
// Layout engine
|
|
26
|
+
export declare function layoutGraph(graphData: { nodes: unknown[]; edges: unknown[] }, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
27
|
+
export declare function queryResultToGraphData(result: Record<string, unknown>): { nodes: unknown[]; edges: unknown[] };
|
|
28
|
+
export declare function pathResultToGraphData(result: Record<string, unknown>): { nodes: unknown[]; edges: unknown[] };
|
|
29
|
+
export declare function rawGraphToGraphData(result: Record<string, unknown>): { nodes: unknown[]; edges: unknown[] };
|
|
30
|
+
export declare function toElkGraph(graphData: { nodes: unknown[]; edges: unknown[] }, options?: Record<string, unknown>): Record<string, unknown>;
|
|
31
|
+
export declare function getDefaultLayoutOptions(): Record<string, string>;
|
|
32
|
+
export declare function runLayout(elkGraph: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
33
|
+
|
|
34
|
+
// Utils
|
|
35
|
+
export declare function truncate(str: string, maxWidth: number): string;
|
|
36
|
+
export declare function timeAgo(dateStr: string): string;
|
|
37
|
+
export declare function formatDuration(ms: number): string;
|
|
38
|
+
export declare function padRight(str: string, width: number): string;
|
|
39
|
+
export declare function padLeft(str: string, width: number): string;
|
|
40
|
+
export declare function center(str: string, width: number): string;
|
|
41
|
+
export declare function stripAnsi(str: string): string;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* @module
|
|
5
|
+
*
|
|
6
|
+
* Visualization module for rendering WARP graph data as ASCII tables,
|
|
7
|
+
* SVG diagrams, and interactive browser views. Includes ELK-based
|
|
8
|
+
* graph layout, ANSI formatting utilities, and CLI renderers.
|
|
3
9
|
*/
|
|
4
10
|
|
|
5
11
|
// ASCII renderers
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
// ANSI escape code regex (inlined from ansi-regex@6 / strip-ansi@7)
|
|
2
|
+
// Valid string terminator sequences: BEL, ESC\, 0x9c
|
|
3
|
+
const ST = '(?:\\u0007|\\u001B\\u005C|\\u009C)';
|
|
4
|
+
const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
|
|
5
|
+
const csi =
|
|
6
|
+
'[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]';
|
|
7
|
+
const ansiRegex = new RegExp(`${osc}|${csi}`, 'g');
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Strips ANSI escape codes from a string.
|
|
@@ -8,7 +14,7 @@ import stripAnsiLib from 'strip-ansi';
|
|
|
8
14
|
* @returns {string} The string with all ANSI codes removed
|
|
9
15
|
*/
|
|
10
16
|
export function stripAnsi(str) {
|
|
11
|
-
return
|
|
17
|
+
return str.replace(ansiRegex, '');
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
export default { stripAnsi };
|