@memberjunction/record-graph 0.0.1-seed.1 → 6.2.0-edge.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/LICENSE +183 -0
- package/README.md +87 -3
- package/dist/DependencyGraphWalker.d.ts +129 -0
- package/dist/DependencyGraphWalker.d.ts.map +1 -0
- package/dist/DependencyGraphWalker.js +847 -0
- package/dist/DependencyGraphWalker.js.map +1 -0
- package/dist/collection-resolver.d.ts +25 -0
- package/dist/collection-resolver.d.ts.map +1 -0
- package/dist/collection-resolver.js +120 -0
- package/dist/collection-resolver.js.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +17 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +23 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +35 -0
- package/dist/keys.js.map +1 -0
- package/dist/links.d.ts +13 -0
- package/dist/links.d.ts.map +1 -0
- package/dist/links.js +14 -0
- package/dist/links.js.map +1 -0
- package/dist/sort.d.ts +23 -0
- package/dist/sort.d.ts.map +1 -0
- package/dist/sort.js +73 -0
- package/dist/sort.js.map +1 -0
- package/dist/sql.d.ts +24 -0
- package/dist/sql.d.ts.map +1 -0
- package/dist/sql.js +43 -0
- package/dist/sql.js.map +1 -0
- package/dist/types.d.ts +148 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +25 -5
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { CompositeKey, EntityInfo, EntityRelationshipInfo } from '@memberjunction/core';
|
|
2
|
+
/**
|
|
3
|
+
* Kind of edge connecting two record nodes in the dependency graph.
|
|
4
|
+
*/
|
|
5
|
+
export type EdgeKind = 'IsASubtype' | 'Collection' | 'Embedded' | 'Relationship' | 'InboundFK' | 'ForwardFK' | 'SoftLink' | 'Hierarchy' | 'SelfPointer';
|
|
6
|
+
/**
|
|
7
|
+
* Backward-compatibility alias for clone plan consumers.
|
|
8
|
+
*/
|
|
9
|
+
export type CloneEdgeKind = EdgeKind;
|
|
10
|
+
/**
|
|
11
|
+
* Policy decision returned by the EdgePolicy callback.
|
|
12
|
+
* - 'Deep': traverse and recurse children.
|
|
13
|
+
* - 'Reference': record the target node / edge but do not recurse into its reverse children.
|
|
14
|
+
* - 'Skip': do not traverse or include the target node.
|
|
15
|
+
*/
|
|
16
|
+
export type EdgePolicyDecision = 'Deep' | 'Reference' | 'Skip';
|
|
17
|
+
/**
|
|
18
|
+
* Information about a candidate edge presented to an EdgePolicy callback before traversal.
|
|
19
|
+
*/
|
|
20
|
+
export interface GraphEdgeCandidate {
|
|
21
|
+
Kind: EdgeKind;
|
|
22
|
+
SourceEntityName: string;
|
|
23
|
+
SourceKey: CompositeKey;
|
|
24
|
+
SourceRecordData: Record<string, unknown>;
|
|
25
|
+
TargetEntityName: string;
|
|
26
|
+
TargetKey?: CompositeKey;
|
|
27
|
+
JoinField: string;
|
|
28
|
+
Relationship?: EntityRelationshipInfo | null;
|
|
29
|
+
CollectionName?: string;
|
|
30
|
+
IsSoftLink?: boolean;
|
|
31
|
+
EntityIDFieldName?: string;
|
|
32
|
+
Depth: number;
|
|
33
|
+
/**
|
|
34
|
+
* For `Hierarchy` edges: `Down` to a child row (its parent FK points at the source), `Up` to the
|
|
35
|
+
* source's own parent (the source's parent FK). A subtree walk goes down; up is the parent it hangs from.
|
|
36
|
+
*/
|
|
37
|
+
HierarchyDirection?: 'Up' | 'Down';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A resolved edge in the record graph.
|
|
41
|
+
*/
|
|
42
|
+
export interface GraphEdge {
|
|
43
|
+
Kind: EdgeKind;
|
|
44
|
+
FromKey: string;
|
|
45
|
+
ToKey: string;
|
|
46
|
+
SourceEntityName: string;
|
|
47
|
+
TargetEntityName: string;
|
|
48
|
+
JoinField: string;
|
|
49
|
+
Relationship?: EntityRelationshipInfo | null;
|
|
50
|
+
CollectionName?: string;
|
|
51
|
+
IsSoftLink?: boolean;
|
|
52
|
+
EntityIDFieldName?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A node in the record dependency graph representing a single entity record.
|
|
56
|
+
*/
|
|
57
|
+
export interface DependencyNode {
|
|
58
|
+
/** Entity name */
|
|
59
|
+
EntityName: string;
|
|
60
|
+
/** Entity metadata */
|
|
61
|
+
EntityInfo: EntityInfo;
|
|
62
|
+
/** The record's primary key */
|
|
63
|
+
RecordKey: CompositeKey;
|
|
64
|
+
/** The record's primary key as a concatenated string */
|
|
65
|
+
RecordID: string;
|
|
66
|
+
/** Current field values of the record */
|
|
67
|
+
RecordData: Record<string, unknown>;
|
|
68
|
+
/** Relationship from parent to this node (null for root) */
|
|
69
|
+
Relationship: EntityRelationshipInfo | null;
|
|
70
|
+
/** Child/dependent record nodes */
|
|
71
|
+
Children: DependencyNode[];
|
|
72
|
+
/** Depth in the graph (0 = root) */
|
|
73
|
+
Depth: number;
|
|
74
|
+
/** The edge that led to the discovery of this node (null for root) */
|
|
75
|
+
DiscoveringEdge?: GraphEdge | null;
|
|
76
|
+
/** Whether this node is an IS-A subtype row */
|
|
77
|
+
IsSubtypeRow?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Alias for DependencyNode in generalized graph contexts.
|
|
81
|
+
*/
|
|
82
|
+
export type GraphNode = DependencyNode;
|
|
83
|
+
/**
|
|
84
|
+
* A full record dependency graph model containing root, flattened nodes, edges, and optional key map.
|
|
85
|
+
*/
|
|
86
|
+
export interface RecordGraph {
|
|
87
|
+
Root: DependencyNode;
|
|
88
|
+
Nodes: DependencyNode[];
|
|
89
|
+
Edges: GraphEdge[];
|
|
90
|
+
KeyMap?: Record<string, string>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Mapping between source record keys and target/new record keys.
|
|
94
|
+
*/
|
|
95
|
+
export type KeyMap = Record<string, string>;
|
|
96
|
+
/**
|
|
97
|
+
* Options controlling graph traversal.
|
|
98
|
+
*/
|
|
99
|
+
export interface WalkOptions {
|
|
100
|
+
/** Maximum recursion depth (default: 10 for Version History, 3 for cloning) */
|
|
101
|
+
MaxDepth?: number;
|
|
102
|
+
/** Only include these entities */
|
|
103
|
+
EntityFilter?: string[];
|
|
104
|
+
/** Skip these entities */
|
|
105
|
+
ExcludeEntities?: string[];
|
|
106
|
+
/** Include soft-deleted records (default: false) */
|
|
107
|
+
IncludeDeleted?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Whether to require entities to have TrackRecordChanges enabled.
|
|
110
|
+
* Version History passes true (or defaults to true); cloning passes false.
|
|
111
|
+
* Default: true
|
|
112
|
+
*/
|
|
113
|
+
RequireTrackRecordChanges?: boolean;
|
|
114
|
+
/** Follow inbound EntityID/RecordID soft links as reverse edges. Default false. */
|
|
115
|
+
IncludeSoftLinks?: boolean;
|
|
116
|
+
/** Add IS-A subtype rows of every discovered record as nodes (via FindISAChildEntities). Default false. */
|
|
117
|
+
IncludeSubtypes?: boolean;
|
|
118
|
+
/** Allow same-entity recursion on fields whose Configuration.Hierarchy.IsHierarchy is true, up to HierarchyMaxDepth. Default false. */
|
|
119
|
+
FollowHierarchies?: boolean;
|
|
120
|
+
/** List (without loading) inbound FK relationships that are not curated EntityRelationship rows, so a caller can show "available" edges. Default false. */
|
|
121
|
+
ListNonCuratedInbound?: boolean;
|
|
122
|
+
/** Called per candidate edge before traversal; returning Skip prunes the walk, Reference records the target without recursing, Deep recurses. */
|
|
123
|
+
EdgePolicy?: (edge: GraphEdgeCandidate) => EdgePolicyDecision;
|
|
124
|
+
/**
|
|
125
|
+
* Called when the rows of an edge the walk follows can't be loaded (no read permission, a
|
|
126
|
+
* failed query). The walk goes on without them, so a caller that must not act on a partial
|
|
127
|
+
* graph (cloning) reports it. Default: the failure is only logged.
|
|
128
|
+
*/
|
|
129
|
+
OnLoadFailure?: (failure: GraphLoadFailure) => void;
|
|
130
|
+
}
|
|
131
|
+
/** An edge whose rows could not be loaded during a walk. */
|
|
132
|
+
export interface GraphLoadFailure {
|
|
133
|
+
Edge: GraphEdgeCandidate;
|
|
134
|
+
/** What the edge policy decided before the load (Deep when there is no policy). */
|
|
135
|
+
Decision: EdgePolicyDecision;
|
|
136
|
+
Message: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Accumulator for graph traversal statistics.
|
|
140
|
+
*/
|
|
141
|
+
export interface WalkStats {
|
|
142
|
+
EntityCounts: Map<string, number>;
|
|
143
|
+
TotalRecords: number;
|
|
144
|
+
AncestorSkips: number;
|
|
145
|
+
VisitedSkips: number;
|
|
146
|
+
ForwardOnlySuppressions: number;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE7F;;GAEG;AACH,MAAM,MAAM,QAAQ,GACd,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,cAAc,GACd,WAAW,GACX,WAAW,GACX,UAAU,GACV,WAAW,GACX,aAAa,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;AAErC;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,QAAQ,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,YAAY,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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F;IACnF,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACtB,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,MAAM,CAAC;CACnC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/record-graph",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "6.2.0-edge.3",
|
|
5
|
+
"description": "MemberJunction: Generalized record dependency graph walker, relationship collection resolver, topological sort, link value encoding, and graph models. Shared by Version History, Record Cloning, and Metadata Sync.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"/dist"
|
|
10
|
+
],
|
|
11
|
+
"author": "MemberJunction.com",
|
|
12
|
+
"license": "BUSL-1.1",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@memberjunction/core": "6.2.0-edge.3",
|
|
15
|
+
"@memberjunction/global": "6.2.0-edge.3"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "24.10.11",
|
|
19
|
+
"typescript": "^5.9.3"
|
|
20
|
+
},
|
|
6
21
|
"repository": {
|
|
7
22
|
"type": "git",
|
|
8
|
-
"url": "
|
|
23
|
+
"url": "https://github.com/MemberJunction/MJ"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc && tsc-alias -f",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest"
|
|
9
29
|
}
|
|
10
|
-
}
|
|
30
|
+
}
|