@memberjunction/core-entities 6.2.2 → 6.3.0-edge.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.
Files changed (188) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/custom/AnchoredConversationSecurity.d.ts +10 -1
  3. package/dist/custom/AnchoredConversationSecurity.d.ts.map +1 -1
  4. package/dist/custom/AnchoredConversationSecurity.js +15 -0
  5. package/dist/custom/AnchoredConversationSecurity.js.map +1 -1
  6. package/dist/custom/ArtifactLockValidation.d.ts +28 -0
  7. package/dist/custom/ArtifactLockValidation.d.ts.map +1 -0
  8. package/dist/custom/ArtifactLockValidation.js +867 -0
  9. package/dist/custom/ArtifactLockValidation.js.map +1 -0
  10. package/dist/custom/ArtifactPermissionDelegate.d.ts +267 -0
  11. package/dist/custom/ArtifactPermissionDelegate.d.ts.map +1 -0
  12. package/dist/custom/ArtifactPermissionDelegate.js +1232 -0
  13. package/dist/custom/ArtifactPermissionDelegate.js.map +1 -0
  14. package/dist/custom/ArtifactPreviewSnapshot.d.ts +199 -0
  15. package/dist/custom/ArtifactPreviewSnapshot.d.ts.map +1 -0
  16. package/dist/custom/ArtifactPreviewSnapshot.js +772 -0
  17. package/dist/custom/ArtifactPreviewSnapshot.js.map +1 -0
  18. package/dist/custom/ArtifactSynthesisEngine.d.ts +151 -0
  19. package/dist/custom/ArtifactSynthesisEngine.d.ts.map +1 -0
  20. package/dist/custom/ArtifactSynthesisEngine.js +1124 -0
  21. package/dist/custom/ArtifactSynthesisEngine.js.map +1 -0
  22. package/dist/custom/ConversationWriteAccess.d.ts +27 -0
  23. package/dist/custom/ConversationWriteAccess.d.ts.map +1 -1
  24. package/dist/custom/ConversationWriteAccess.js +53 -0
  25. package/dist/custom/ConversationWriteAccess.js.map +1 -1
  26. package/dist/custom/DocumentLiveBlockEngine.d.ts +612 -0
  27. package/dist/custom/DocumentLiveBlockEngine.d.ts.map +1 -0
  28. package/dist/custom/DocumentLiveBlockEngine.js +2352 -0
  29. package/dist/custom/DocumentLiveBlockEngine.js.map +1 -0
  30. package/dist/custom/MJQueryEntityExtended.d.ts.map +1 -1
  31. package/dist/custom/MJQueryEntityExtended.js +27 -11
  32. package/dist/custom/MJQueryEntityExtended.js.map +1 -1
  33. package/dist/custom/MJUserViewEntityExtended.d.ts +4 -7
  34. package/dist/custom/MJUserViewEntityExtended.d.ts.map +1 -1
  35. package/dist/custom/MJUserViewEntityExtended.js +15 -97
  36. package/dist/custom/MJUserViewEntityExtended.js.map +1 -1
  37. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.d.ts.map +1 -1
  38. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js +31 -7
  39. package/dist/custom/PermissionProviders/ArtifactPermissionProvider.js.map +1 -1
  40. package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts +3 -4
  41. package/dist/custom/PermissionProviders/CollectionPermissionProvider.d.ts.map +1 -1
  42. package/dist/custom/PermissionProviders/CollectionPermissionProvider.js +334 -47
  43. package/dist/custom/PermissionProviders/CollectionPermissionProvider.js.map +1 -1
  44. package/dist/custom/Permissions/BaseShareEntityExtended.d.ts +19 -3
  45. package/dist/custom/Permissions/BaseShareEntityExtended.d.ts.map +1 -1
  46. package/dist/custom/Permissions/BaseShareEntityExtended.js +139 -13
  47. package/dist/custom/Permissions/BaseShareEntityExtended.js.map +1 -1
  48. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts +8 -6
  49. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.d.ts.map +1 -1
  50. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js +93 -41
  51. package/dist/custom/Permissions/MJArtifactPermissionEntityExtended.js.map +1 -1
  52. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts +12 -5
  53. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.d.ts.map +1 -1
  54. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js +240 -37
  55. package/dist/custom/Permissions/MJCollectionPermissionEntityExtended.js.map +1 -1
  56. package/dist/custom/SlideDeckEngine.d.ts +427 -0
  57. package/dist/custom/SlideDeckEngine.d.ts.map +1 -0
  58. package/dist/custom/SlideDeckEngine.js +1669 -0
  59. package/dist/custom/SlideDeckEngine.js.map +1 -0
  60. package/dist/custom/SlideDeckPptxEngine.d.ts +25 -0
  61. package/dist/custom/SlideDeckPptxEngine.d.ts.map +1 -0
  62. package/dist/custom/SlideDeckPptxEngine.js +1237 -0
  63. package/dist/custom/SlideDeckPptxEngine.js.map +1 -0
  64. package/dist/custom/SpreadsheetEngine.d.ts +1370 -0
  65. package/dist/custom/SpreadsheetEngine.d.ts.map +1 -0
  66. package/dist/custom/SpreadsheetEngine.js +17580 -0
  67. package/dist/custom/SpreadsheetEngine.js.map +1 -0
  68. package/dist/custom/approvals.d.ts +7 -1
  69. package/dist/custom/approvals.d.ts.map +1 -1
  70. package/dist/custom/approvals.js +8 -1
  71. package/dist/custom/approvals.js.map +1 -1
  72. package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts +7 -0
  73. package/dist/custom/operations/ArtifactComplianceAuditOperation.d.ts.map +1 -0
  74. package/dist/custom/operations/ArtifactComplianceAuditOperation.js +7 -0
  75. package/dist/custom/operations/ArtifactComplianceAuditOperation.js.map +1 -0
  76. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts +7 -0
  77. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.d.ts.map +1 -0
  78. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js +7 -0
  79. package/dist/custom/operations/ArtifactEvaluateAiFormulaOperation.js.map +1 -0
  80. package/dist/custom/operations/ArtifactGuestShareOperations.d.ts +60 -0
  81. package/dist/custom/operations/ArtifactGuestShareOperations.d.ts.map +1 -0
  82. package/dist/custom/operations/ArtifactGuestShareOperations.js +6 -0
  83. package/dist/custom/operations/ArtifactGuestShareOperations.js.map +1 -0
  84. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts +7 -0
  85. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.d.ts.map +1 -0
  86. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js +7 -0
  87. package/dist/custom/operations/SynthesizeArtifactFromSourcesOperation.js.map +1 -0
  88. package/dist/custom/typedQuery.d.ts +162 -0
  89. package/dist/custom/typedQuery.d.ts.map +1 -0
  90. package/dist/custom/typedQuery.js +296 -0
  91. package/dist/custom/typedQuery.js.map +1 -0
  92. package/dist/engines/CanonGraphEngine.d.ts +122 -0
  93. package/dist/engines/CanonGraphEngine.d.ts.map +1 -0
  94. package/dist/engines/CanonGraphEngine.js +500 -0
  95. package/dist/engines/CanonGraphEngine.js.map +1 -0
  96. package/dist/engines/EncryptionEngineBase.js +2 -2
  97. package/dist/engines/EncryptionEngineBase.js.map +1 -1
  98. package/dist/engines/QueryEngine.js +2 -2
  99. package/dist/engines/QueryEngine.js.map +1 -1
  100. package/dist/engines/SearchEngineBase.d.ts +17 -3
  101. package/dist/engines/SearchEngineBase.d.ts.map +1 -1
  102. package/dist/engines/SearchEngineBase.js +100 -28
  103. package/dist/engines/SearchEngineBase.js.map +1 -1
  104. package/dist/engines/UserInfoEngine.d.ts +8 -0
  105. package/dist/engines/UserInfoEngine.d.ts.map +1 -1
  106. package/dist/engines/UserInfoEngine.js +62 -10
  107. package/dist/engines/UserInfoEngine.js.map +1 -1
  108. package/dist/engines/conversations.d.ts +213 -12
  109. package/dist/engines/conversations.d.ts.map +1 -1
  110. package/dist/engines/conversations.js +578 -30
  111. package/dist/engines/conversations.js.map +1 -1
  112. package/dist/generated/entities/__mj.d.ts +4265 -25257
  113. package/dist/generated/entities/__mj.d.ts.map +1 -1
  114. package/dist/generated/entities/__mj.js +3793 -40542
  115. package/dist/generated/entities/__mj.js.map +1 -1
  116. package/dist/generated/queries/__mj.d.ts +269 -0
  117. package/dist/generated/queries/__mj.d.ts.map +1 -0
  118. package/dist/generated/queries/__mj.js +100 -0
  119. package/dist/generated/queries/__mj.js.map +1 -0
  120. package/dist/generated/queries/index.d.ts +2 -0
  121. package/dist/generated/queries/index.d.ts.map +1 -0
  122. package/dist/generated/queries/index.js +4 -0
  123. package/dist/generated/queries/index.js.map +1 -0
  124. package/dist/generated/remote_operations.d.ts +275 -22
  125. package/dist/generated/remote_operations.d.ts.map +1 -1
  126. package/dist/generated/remote_operations.js +98 -3
  127. package/dist/generated/remote_operations.js.map +1 -1
  128. package/dist/generated/schemas/__mj.d.ts +25489 -0
  129. package/dist/generated/schemas/__mj.d.ts.map +1 -0
  130. package/dist/generated/schemas/__mj.js +41768 -0
  131. package/dist/generated/schemas/__mj.js.map +1 -0
  132. package/dist/generated/schemas.d.ts +2 -0
  133. package/dist/generated/schemas.d.ts.map +1 -0
  134. package/dist/generated/schemas.js +2 -0
  135. package/dist/generated/schemas.js.map +1 -0
  136. package/dist/graph/BaseGraphEdgeProvider.d.ts +158 -0
  137. package/dist/graph/BaseGraphEdgeProvider.d.ts.map +1 -0
  138. package/dist/graph/BaseGraphEdgeProvider.js +70 -0
  139. package/dist/graph/BaseGraphEdgeProvider.js.map +1 -0
  140. package/dist/graph/GraphEngine.d.ts +274 -0
  141. package/dist/graph/GraphEngine.d.ts.map +1 -0
  142. package/dist/graph/GraphEngine.js +1156 -0
  143. package/dist/graph/GraphEngine.js.map +1 -0
  144. package/dist/graph/GraphExpansion.d.ts +142 -0
  145. package/dist/graph/GraphExpansion.d.ts.map +1 -0
  146. package/dist/graph/GraphExpansion.js +87 -0
  147. package/dist/graph/GraphExpansion.js.map +1 -0
  148. package/dist/graph/index.d.ts +15 -0
  149. package/dist/graph/index.d.ts.map +1 -0
  150. package/dist/graph/index.js +30 -0
  151. package/dist/graph/index.js.map +1 -0
  152. package/dist/graph/providers/AlternateBaseViewEdgeProvider.d.ts +16 -0
  153. package/dist/graph/providers/AlternateBaseViewEdgeProvider.d.ts.map +1 -0
  154. package/dist/graph/providers/AlternateBaseViewEdgeProvider.js +115 -0
  155. package/dist/graph/providers/AlternateBaseViewEdgeProvider.js.map +1 -0
  156. package/dist/graph/providers/EntityMetadataEdgeProvider.d.ts +17 -0
  157. package/dist/graph/providers/EntityMetadataEdgeProvider.d.ts.map +1 -0
  158. package/dist/graph/providers/EntityMetadataEdgeProvider.js +145 -0
  159. package/dist/graph/providers/EntityMetadataEdgeProvider.js.map +1 -0
  160. package/dist/graph/providers/ForeignKeyEdgeProvider.d.ts +25 -0
  161. package/dist/graph/providers/ForeignKeyEdgeProvider.d.ts.map +1 -0
  162. package/dist/graph/providers/ForeignKeyEdgeProvider.js +131 -0
  163. package/dist/graph/providers/ForeignKeyEdgeProvider.js.map +1 -0
  164. package/dist/graph/providers/JoinEntityEdgeProvider.d.ts +37 -0
  165. package/dist/graph/providers/JoinEntityEdgeProvider.d.ts.map +1 -0
  166. package/dist/graph/providers/JoinEntityEdgeProvider.js +170 -0
  167. package/dist/graph/providers/JoinEntityEdgeProvider.js.map +1 -0
  168. package/dist/graph/providers/QueryEdgeProvider.d.ts +33 -0
  169. package/dist/graph/providers/QueryEdgeProvider.d.ts.map +1 -0
  170. package/dist/graph/providers/QueryEdgeProvider.js +120 -0
  171. package/dist/graph/providers/QueryEdgeProvider.js.map +1 -0
  172. package/dist/graph/providers/QueryMetadataEdgeProvider.d.ts +18 -0
  173. package/dist/graph/providers/QueryMetadataEdgeProvider.d.ts.map +1 -0
  174. package/dist/graph/providers/QueryMetadataEdgeProvider.js +163 -0
  175. package/dist/graph/providers/QueryMetadataEdgeProvider.js.map +1 -0
  176. package/dist/graph/providers/RecordLinkEdgeProvider.d.ts +20 -0
  177. package/dist/graph/providers/RecordLinkEdgeProvider.d.ts.map +1 -0
  178. package/dist/graph/providers/RecordLinkEdgeProvider.js +172 -0
  179. package/dist/graph/providers/RecordLinkEdgeProvider.js.map +1 -0
  180. package/dist/index.d.ts +15 -0
  181. package/dist/index.d.ts.map +1 -1
  182. package/dist/index.js +23 -0
  183. package/dist/index.js.map +1 -1
  184. package/dist/schemas.d.ts +6 -0
  185. package/dist/schemas.d.ts.map +1 -0
  186. package/dist/schemas.js +6 -0
  187. package/dist/schemas.js.map +1 -0
  188. package/package.json +17 -6
@@ -0,0 +1,2 @@
1
+ export * from './schemas/__mj.js';
2
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './schemas/__mj.js';
2
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/generated/schemas.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,158 @@
1
+ import type { IMetadataProvider, IRunQueryProvider, IRunViewProvider, UserInfo } from '@memberjunction/core';
2
+ import type { MJGraphEntity } from '../generated/entity_subclasses.js';
3
+ /**
4
+ * Polymorphic reference to any entity record node in a semantic graph (`EntityName` + `RecordID`).
5
+ */
6
+ export interface GraphNodeRef {
7
+ EntityName: string;
8
+ RecordID: string;
9
+ EntityID?: string;
10
+ }
11
+ /**
12
+ * Resolved view of a semantic graph node with display label, icon, and description.
13
+ *
14
+ * `Hop`, `PathWeight`, `ParentKey` and `ViaEdgeID` are set by {@link GraphEngine.Subgraph}: they
15
+ * record the best path that reached the node, so a caller can explain how it got there.
16
+ */
17
+ export interface GraphNodeView {
18
+ /** Canonical node key (`<normalizedEntityID>|<recordID>` or `<normalizedEntityName>|<recordID>`). */
19
+ Key: string;
20
+ EntityName: string;
21
+ RecordID: string;
22
+ Label: string;
23
+ Icon: string | null;
24
+ Description: string | null;
25
+ EntityID?: string;
26
+ /** Hops from the nearest seed (`0` for a seed). */
27
+ Hop?: number;
28
+ /** Best-first path score: product of edge weights, decayed per hop (`1` for a seed). */
29
+ PathWeight?: number;
30
+ /** Key of the node this one was reached from (`null` for a seed). */
31
+ ParentKey?: string | null;
32
+ /** ID of the edge this node was reached through (`null` for a seed). */
33
+ ViaEdgeID?: string | null;
34
+ }
35
+ /**
36
+ * Resolved view of a stored or derived semantic graph edge.
37
+ */
38
+ export interface GraphEdgeView {
39
+ /** Stored edge ID, or `'derived:<provider>:<type>:<sourceKey>:<targetKey>'`. */
40
+ ID: string;
41
+ GraphName: string;
42
+ TypeName: string;
43
+ Source: GraphNodeRef;
44
+ Target: GraphNodeRef;
45
+ IsDirected: boolean;
46
+ Weight: number;
47
+ Description: string | null;
48
+ Attributes: Record<string, unknown> | null;
49
+ Origin: 'Derived' | 'Declared' | 'Inferred';
50
+ Status: 'Proposed' | 'Approved' | 'Rejected';
51
+ Confidence: number | null;
52
+ InverseTypeName?: string | null;
53
+ }
54
+ /**
55
+ * Alias for {@link GraphEdgeView} used in RAG and provider slice contracts.
56
+ */
57
+ export type GraphEdgeSlice = GraphEdgeView;
58
+ /**
59
+ * Options controlling bounded graph traversal (`GetEdges` and `Subgraph`).
60
+ */
61
+ export interface GraphTraversalOptions {
62
+ /** Traversal direction relative to seed/frontier nodes (`'Both'` by default). */
63
+ Direction?: 'Out' | 'In' | 'Both';
64
+ /** Optional allow-list of edge type names. */
65
+ EdgeTypes?: string[];
66
+ /** Minimum edge weight in `[0, 1]`. */
67
+ MinWeight?: number;
68
+ /** When `true`, include `'Proposed'` stored edges alongside `'Approved'` ones (`false` by default). */
69
+ IncludeProposed?: boolean;
70
+ /** Maximum hop depth (`2` by default, clamped to `1..4`). */
71
+ Depth?: number;
72
+ /** Alias for {@link Depth} used by RAG/pipeline callers. */
73
+ MaxDepth?: number;
74
+ /** Maximum expanded nodes (`50` by default, clamped to `1..200`). */
75
+ MaxNodes?: number;
76
+ /**
77
+ * Everyone besides the caller who will see the result (a run's audience). A node is admitted only
78
+ * when the caller AND every reader may see it, checked during traversal, so a node reachable only
79
+ * through a node some reader cannot see is never reached.
80
+ */
81
+ AudienceReaders?: readonly UserInfo[];
82
+ }
83
+ /**
84
+ * Bounded subgraph returned by {@link GraphEngine.Subgraph}.
85
+ */
86
+ export interface GraphSubgraph {
87
+ Nodes: GraphNodeView[];
88
+ Edges: GraphEdgeView[];
89
+ /** Why the result is empty or partial: an unknown or inactive graph, or a cap that was reached. */
90
+ Message?: string;
91
+ }
92
+ /**
93
+ * Request passed to a {@link BaseGraphEdgeProvider} for one expansion step.
94
+ */
95
+ export interface GraphEdgeRequest {
96
+ /** Frontier nodes to expand around. Providers return only edges incident to these nodes. */
97
+ Nodes: GraphNodeRef[];
98
+ Direction: 'Out' | 'In' | 'Both';
99
+ EdgeTypes?: string[];
100
+ }
101
+ /**
102
+ * A provider that can answer metadata lookups, `RunView` and `RunQuery` — what graph traversal and
103
+ * every edge provider read through. `ProviderBase` implements all three; the interfaces are separate
104
+ * in `@memberjunction/core`, so {@link IsGraphDataProvider} narrows to this without a cast.
105
+ */
106
+ export type GraphDataProvider = IMetadataProvider & IRunViewProvider & IRunQueryProvider;
107
+ /**
108
+ * True when `candidate` implements {@link GraphDataProvider}. Used instead of an `as unknown as`
109
+ * cast wherever a provider arrives typed as only one of the three interfaces.
110
+ */
111
+ export declare function IsGraphDataProvider(candidate: object | null | undefined): candidate is GraphDataProvider;
112
+ /**
113
+ * Execution context passed to {@link BaseGraphEdgeProvider.GetEdges}.
114
+ */
115
+ export interface GraphProviderContext<TConfig = Record<string, unknown>> {
116
+ Graph: MJGraphEntity;
117
+ Config: TConfig;
118
+ /** The caller. Every data read runs as this user so entity permissions and row-level security apply. */
119
+ User: UserInfo;
120
+ Provider: GraphDataProvider;
121
+ }
122
+ /** Default per-step row cap for data-scale providers (`MaxRowsPerStep` in their configuration). */
123
+ export declare const DEFAULT_GRAPH_PROVIDER_MAX_ROWS_PER_STEP = 200;
124
+ /**
125
+ * Build a canonical, case-normalized key for a `(EntityID/EntityName, RecordID)` pair.
126
+ */
127
+ export declare function FormatGraphNodeKey(entityIdOrName: string, recordId: string): string;
128
+ /**
129
+ * Check whether an edge type name passes an optional `EdgeTypes` filter (case-insensitive).
130
+ */
131
+ export declare function MatchesEdgeTypeFilter(typeName: string, allowedTypes?: readonly string[]): boolean;
132
+ /**
133
+ * Abstract base class for derived semantic graph edge providers (`@RegisterClass(BaseGraphEdgeProvider, '<DriverClass>')`).
134
+ *
135
+ * Providers are called once per expansion step with the step's frontier and must return only edges
136
+ * incident to it. Metadata-scale providers read loaded metadata and `QueryEngine` caches (no I/O);
137
+ * data-scale providers batch one bounded, ordered read per step.
138
+ */
139
+ export declare abstract class BaseGraphEdgeProvider<TConfig = Record<string, unknown>> {
140
+ /**
141
+ * Project derived edges for `request`. Every data read must go through `RunView` or `RunQuery`
142
+ * with `ctx.User` so entity permissions and row-level security apply.
143
+ */
144
+ abstract GetEdges(request: GraphEdgeRequest, ctx: GraphProviderContext<TConfig>): Promise<GraphEdgeView[]>;
145
+ /**
146
+ * Log that a per-step read hit its row cap, so a truncated neighborhood is visible rather than
147
+ * silently partial.
148
+ */
149
+ protected LogTruncation(providerName: string, source: string, maxRows: number, graphName: string): void;
150
+ }
151
+ /** Hard ceiling on any provider's per-step row cap. */
152
+ export declare const MAX_GRAPH_PROVIDER_ROWS_PER_STEP = 1000;
153
+ /**
154
+ * A provider's per-step row cap from its configuration: `DEFAULT_GRAPH_PROVIDER_MAX_ROWS_PER_STEP`
155
+ * when unset, clamped to `1..MAX_GRAPH_PROVIDER_ROWS_PER_STEP`.
156
+ */
157
+ export declare function ResolveMaxRowsPerStep(configured: number | undefined): number;
158
+ //# sourceMappingURL=BaseGraphEdgeProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseGraphEdgeProvider.d.ts","sourceRoot":"","sources":["../../src/graph/BaseGraphEdgeProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAG9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,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AAE,OAAO,CAAC;IACnE,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,wGAAwG;IACxG,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,iBAAiB,CAAC;CAC/B;AAED,mGAAmG;AACnG,eAAO,MAAM,wCAAwC,MAAM,CAAC;AAE5D;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUnF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAMjG;AAED;;;;;;GAMG;AACH,8BAAsB,qBAAqB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzE;;;OAGG;aACa,QAAQ,CACpB,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,oBAAoB,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,aAAa,EAAE,CAAC;IAE3B;;;OAGG;IACH,SAAS,CAAC,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;CAM1G;AAED,uDAAuD;AACvD,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAErD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG5E"}
@@ -0,0 +1,70 @@
1
+ import { LogStatus } from '@memberjunction/core';
2
+ import { NormalizeUUID } from '@memberjunction/global';
3
+ /**
4
+ * True when `candidate` implements {@link GraphDataProvider}. Used instead of an `as unknown as`
5
+ * cast wherever a provider arrives typed as only one of the three interfaces.
6
+ */
7
+ export function IsGraphDataProvider(candidate) {
8
+ return (candidate != null &&
9
+ 'Entities' in candidate &&
10
+ 'EntityByName' in candidate &&
11
+ typeof candidate.EntityByName === 'function' &&
12
+ 'RunView' in candidate &&
13
+ typeof candidate.RunView === 'function' &&
14
+ 'RunViews' in candidate &&
15
+ typeof candidate.RunViews === 'function' &&
16
+ 'RunQuery' in candidate &&
17
+ typeof candidate.RunQuery === 'function');
18
+ }
19
+ /** Default per-step row cap for data-scale providers (`MaxRowsPerStep` in their configuration). */
20
+ export const DEFAULT_GRAPH_PROVIDER_MAX_ROWS_PER_STEP = 200;
21
+ /**
22
+ * Build a canonical, case-normalized key for a `(EntityID/EntityName, RecordID)` pair.
23
+ */
24
+ export function FormatGraphNodeKey(entityIdOrName, recordId) {
25
+ const normalizedEntity = NormalizeUUID(entityIdOrName.trim());
26
+ const trimmedRecordId = String(recordId).trim();
27
+ // Normalize UUID record IDs so SQL Server upper-case and PostgreSQL lower-case keys match
28
+ const normalizedRecord = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(trimmedRecordId)
29
+ ? NormalizeUUID(trimmedRecordId)
30
+ : trimmedRecordId;
31
+ return `${normalizedEntity}|${normalizedRecord}`;
32
+ }
33
+ /**
34
+ * Check whether an edge type name passes an optional `EdgeTypes` filter (case-insensitive).
35
+ */
36
+ export function MatchesEdgeTypeFilter(typeName, allowedTypes) {
37
+ if (!allowedTypes || allowedTypes.length === 0) {
38
+ return true;
39
+ }
40
+ const target = typeName.trim().toLowerCase();
41
+ return allowedTypes.some((t) => t.trim().toLowerCase() === target);
42
+ }
43
+ /**
44
+ * Abstract base class for derived semantic graph edge providers (`@RegisterClass(BaseGraphEdgeProvider, '<DriverClass>')`).
45
+ *
46
+ * Providers are called once per expansion step with the step's frontier and must return only edges
47
+ * incident to it. Metadata-scale providers read loaded metadata and `QueryEngine` caches (no I/O);
48
+ * data-scale providers batch one bounded, ordered read per step.
49
+ */
50
+ export class BaseGraphEdgeProvider {
51
+ /**
52
+ * Log that a per-step read hit its row cap, so a truncated neighborhood is visible rather than
53
+ * silently partial.
54
+ */
55
+ LogTruncation(providerName, source, maxRows, graphName) {
56
+ LogStatus(`${providerName}: the per-step read of "${source}" in graph "${graphName}" reached its ${maxRows}-row cap; ` +
57
+ 'this expansion step may be missing edges. Raise MaxRowsPerStep or narrow the frontier.');
58
+ }
59
+ }
60
+ /** Hard ceiling on any provider's per-step row cap. */
61
+ export const MAX_GRAPH_PROVIDER_ROWS_PER_STEP = 1000;
62
+ /**
63
+ * A provider's per-step row cap from its configuration: `DEFAULT_GRAPH_PROVIDER_MAX_ROWS_PER_STEP`
64
+ * when unset, clamped to `1..MAX_GRAPH_PROVIDER_ROWS_PER_STEP`.
65
+ */
66
+ export function ResolveMaxRowsPerStep(configured) {
67
+ const value = configured != null && Number.isFinite(configured) ? Math.floor(configured) : DEFAULT_GRAPH_PROVIDER_MAX_ROWS_PER_STEP;
68
+ return Math.max(1, Math.min(MAX_GRAPH_PROVIDER_ROWS_PER_STEP, value));
69
+ }
70
+ //# sourceMappingURL=BaseGraphEdgeProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseGraphEdgeProvider.js","sourceRoot":"","sources":["../../src/graph/BaseGraphEdgeProvider.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAmHvD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAoC;IACpE,OAAO,CACH,SAAS,IAAI,IAAI;QACjB,UAAU,IAAI,SAAS;QACvB,cAAc,IAAI,SAAS;QAC3B,OAAO,SAAS,CAAC,YAAY,KAAK,UAAU;QAC5C,SAAS,IAAI,SAAS;QACtB,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU;QACvC,UAAU,IAAI,SAAS;QACvB,OAAO,SAAS,CAAC,QAAQ,KAAK,UAAU;QACxC,UAAU,IAAI,SAAS;QACvB,OAAO,SAAS,CAAC,QA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C;AAErD;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,UAA8B;IAChE,MAAM,KAAK,GAAG,UAAU,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,wCAAwC,CAAC;IACpI,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,274 @@
1
+ import { BaseEngine, BaseEnginePropertyConfig, BaseEntityEvent, EntityInfo, IMetadataProvider, UserInfo } from '@memberjunction/core';
2
+ import { UUIDSet } from '@memberjunction/global';
3
+ import { MJGraphAuthorityTierEntity, MJGraphConceptEntity, MJGraphConceptTypeEntity, MJGraphEdgeProviderEntity, MJGraphEdgeTypeEndpointEntity, MJGraphEdgeTypeEntity, MJGraphEntity, MJGraphTypeEntity } from '../generated/entity_subclasses.js';
4
+ import type { MJGraphEntityType } from '../generated/entities/__mj.js';
5
+ import { type GraphEdgeView, type GraphNodeRef, type GraphNodeView, type GraphSubgraph, type GraphTraversalOptions } from './BaseGraphEdgeProvider.js';
6
+ /** Depth used when the caller gives none. */
7
+ export declare const GRAPH_DEFAULT_DEPTH = 2;
8
+ /** Hard upper bound on traversal depth. */
9
+ export declare const GRAPH_MAX_DEPTH = 4;
10
+ /** Node budget used when the caller gives none. */
11
+ export declare const GRAPH_DEFAULT_MAX_NODES = 50;
12
+ /** Hard upper bound on nodes a traversal returns. */
13
+ export declare const GRAPH_MAX_NODES = 200;
14
+ /** Row cap on the stored edges one expansion step reads on demand. */
15
+ export declare const GRAPH_MAX_STORED_EDGES_PER_STEP = 1000;
16
+ /**
17
+ * Server operation key (`ServerOperationScopeManager`) under which the Content Pipeline `Graph` stage
18
+ * saves the `Inferred` edges its content source's `GraphOverlay` policy approves (every
19
+ * `ConceptTaxonomyMode` except `propose-only`). `MJGraphEdgeEntityServer` lets a new `Inferred` edge
20
+ * start `Approved` without `Graph: Approve Edges` only inside this scope. Client CRUD entry points
21
+ * (GraphQL, REST, transaction groups) run inside a client CRUD boundary that masks every outer scope,
22
+ * so an API caller cannot enter it; only server code that names this key can.
23
+ */
24
+ export declare const GRAPH_PIPELINE_EDGE_APPROVAL_OPERATION = "ContentPipeline.GraphStage.ApproveInferredEdges";
25
+ /** True when a graph belongs to a Canon graph type or carries the primary Canon graph name. */
26
+ export declare function IsCanonGraph(graph: Pick<MJGraphEntityType, 'Name' | 'GraphTypeID'>, canonTypeIds: UUIDSet): boolean;
27
+ /** Options for {@link GraphEngine.FilterNodesForUser}. */
28
+ export interface GraphNodeFilterOptions {
29
+ /** When `true`, `Proposed` concepts are visible alongside `Approved` ones (`false` by default). */
30
+ IncludeProposed?: boolean;
31
+ /** Provider for the visibility reads (the engine's own when omitted). */
32
+ Provider?: IMetadataProvider;
33
+ }
34
+ /**
35
+ * Semantic Graph Engine (`WS-4.2` / `plans/canon-semantic-graph.md`).
36
+ *
37
+ * Caches graph metadata (graphs, edge types, endpoints, providers, concepts, lookup tables) and,
38
+ * for `Preload` graphs only, their approved stored edges, loaded per graph on its first traversal
39
+ * and reloaded per graph after a change. `OnDemand` graphs read stored edges per expansion step with
40
+ * one bounded RunView. Derived edges come from the graph's active `MJ: Graph Edge Providers`.
41
+ *
42
+ * **Lazily configured.** Nothing loads at startup; the first caller of `Config` pays for it.
43
+ *
44
+ * **Whose data the cache holds.** On a server `BaseEngine` loads every config as the MJ system user,
45
+ * so the shared cache never takes the first caller's scope. Nothing cached is handed to a caller
46
+ * unchecked: every node returned is checked AS THE CALLER (and as every audience reader) at the hop
47
+ * it is reached, with one batched `RunViews` per principal per hop (`[pk] IN (...)` per entity, so
48
+ * entity permissions and row-level security apply), and cached stored edges are used only for a
49
+ * principal who could read every one of them anyway.
50
+ */
51
+ export declare class GraphEngine extends BaseEngine<GraphEngine> {
52
+ static get Instance(): GraphEngine;
53
+ private _graphs;
54
+ private _graphTypes;
55
+ private _edgeTypes;
56
+ private _edgeTypeEndpoints;
57
+ private _edgeProviders;
58
+ private _concepts;
59
+ private _conceptTypes;
60
+ private _authorityTiers;
61
+ /**
62
+ * Approved stored edges of the `Preload` graphs traversed so far, one entry per graph, loaded on a
63
+ * graph's first traversal. A change drops only the entries it affects (see
64
+ * {@link HandleIndividualBaseEntityEvent}); the next traversal of that graph reloads it alone.
65
+ */
66
+ private preloadedEdges;
67
+ /** In-flight preload reads by graph ID, so concurrent traversals share one read per graph. */
68
+ private preloadReads;
69
+ /** Bumped by every invalidation, so a read that started before one is not cached after it. */
70
+ private preloadGeneration;
71
+ /** Field and alternate-view lookups for metadata nodes; rebuilt when the provider's entity list changes. */
72
+ private metadataNodeIndex;
73
+ /** Cached result of the lightweight unloaded Canon-graph existence probe, keyed by provider. */
74
+ private activeCanonGraphCache;
75
+ /** In-flight lightweight Canon-graph probes so concurrent callers share one query per provider. */
76
+ private activeCanonGraphInFlight;
77
+ /** Monotonic counter incremented when graph/type metadata changes so stale probes do not cache. */
78
+ private activeCanonProbeGeneration;
79
+ Config(forceRefresh?: boolean, contextUser?: UserInfo, provider?: IMetadataProvider): Promise<void>;
80
+ /**
81
+ * Returns `true` when at least one active Canon graph exists. When `GraphEngine` is already
82
+ * loaded for the resolved provider, evaluates strictly in memory; otherwise runs a single
83
+ * lightweight `RunView` probe cached per provider so callers can skip loading all 8 graph entities
84
+ * on deployments with no active Canon graphs.
85
+ */
86
+ HasActiveCanonGraphs(contextUser?: UserInfo, provider?: IMetadataProvider): Promise<boolean>;
87
+ private probeActiveCanonGraphs;
88
+ private invalidateActiveCanonGraphCache;
89
+ /** A first or forced (re)load also drops every preloaded graph; each reloads on its next traversal. */
90
+ protected Load(configs: Partial<BaseEnginePropertyConfig>[], provider: IMetadataProvider, forceRefresh?: boolean, contextUser?: UserInfo): Promise<void>;
91
+ /**
92
+ * Drops the preload entries a change affects, and nothing else.
93
+ *
94
+ * There is deliberately no `AdditionalLoading` override: `BaseEngine` turns off in-place cache
95
+ * updates for an engine that has one, so every concept or edge-type save would reload that whole
96
+ * config and then every Preload graph's edges. Without it, the cached configs update in place and
97
+ * stored edges load per graph, lazily:
98
+ * - a `MJ: Graph Edges` save or delete drops the edge's graph, and any graph whose entry holds that
99
+ * edge ID (an edge moved to another graph);
100
+ * - a `MJ: Graphs` save or delete drops that graph (its `LoadMode` or `Status` may have changed);
101
+ * - a change that does not say which row (a remote invalidation) drops every entry.
102
+ */
103
+ protected HandleIndividualBaseEntityEvent(event: BaseEntityEvent): Promise<boolean>;
104
+ /** Drops the preload entries whose graph ID matches `affects` (every entry when `null`). */
105
+ private invalidatePreloadedEdges;
106
+ private preloadHoldsEdge;
107
+ get Graphs(): MJGraphEntity[];
108
+ get GraphTypes(): MJGraphTypeEntity[];
109
+ get EdgeTypes(): MJGraphEdgeTypeEntity[];
110
+ get EdgeTypeEndpoints(): MJGraphEdgeTypeEndpointEntity[];
111
+ get EdgeProviders(): MJGraphEdgeProviderEntity[];
112
+ /**
113
+ * Every cached concept, loaded as the engine's identity. Never hand these to a caller directly:
114
+ * check them with {@link FilterNodesForUser} first (as `CanonGraphEngine.FindConcepts` does).
115
+ */
116
+ get Concepts(): MJGraphConceptEntity[];
117
+ get ConceptTypes(): MJGraphConceptTypeEntity[];
118
+ get AuthorityTiers(): MJGraphAuthorityTierEntity[];
119
+ /**
120
+ * Find an ACTIVE `MJ: Graphs` row by `Name` (case-insensitive) or `ID`. An unknown or disabled
121
+ * graph returns `undefined`; traversal of it returns nothing.
122
+ */
123
+ GetGraph(graphNameOrId: string): MJGraphEntity | undefined;
124
+ /**
125
+ * Validate whether `entityId` is permitted on `side` (`'Source'` or `'Target'`) of `edgeTypeId`
126
+ * according to `MJ: Graph Edge Type Endpoints`. When no endpoint rows exist for `(edgeTypeId, side)`,
127
+ * any entity is permitted.
128
+ */
129
+ ValidateEdgeEndpoint(edgeTypeId: string, side: 'Source' | 'Target', entityId: string): boolean;
130
+ /**
131
+ * The canonical key of a node (`<entityID>|<recordID>`), resolving the entity through metadata.
132
+ */
133
+ GetNodeKey(node: GraphNodeRef): string;
134
+ /**
135
+ * The nodes in `nodes` that `user` — and every one of `audienceReaders` — may see, with display
136
+ * labels, keyed by node key. Data records (including concepts) are read as each principal with one
137
+ * batched `RunViews` per principal, so entity permissions and row-level security apply; metadata
138
+ * nodes use entity `CanRead`, `UserCanRun` (queries) and `CanRead` + `IsUsable` (alternate views).
139
+ * A concept appears only when {@link IsGraphConceptStatusVisible} for `options.IncludeProposed`.
140
+ */
141
+ FilterNodesForUser(nodes: GraphNodeRef[], user: UserInfo, audienceReaders?: readonly UserInfo[], options?: GraphNodeFilterOptions): Promise<Map<string, GraphNodeView>>;
142
+ /**
143
+ * Stored and derived edges incident to `node` in `graphName` whose endpoints the caller (and any
144
+ * `options.AudienceReaders`) may see. An unknown or inactive graph yields no edges. Every read made
145
+ * for the caller goes through `provider` when one is given (see {@link Subgraph}).
146
+ */
147
+ GetEdges(graphName: string, node: GraphNodeRef, options: GraphTraversalOptions, user: UserInfo, provider?: IMetadataProvider): Promise<GraphEdgeView[]>;
148
+ /**
149
+ * Best-first bounded expansion around `seeds` in `graphName`.
150
+ *
151
+ * Each step reads the frontier's edges, ranks candidate neighbors by path score (product of edge
152
+ * weights, decayed per hop; ties broken by node key then edge ID), checks the candidates'
153
+ * visibility for the caller and every audience reader in one batch, and admits visible ones until
154
+ * `MaxNodes`. Only admitted nodes are expanded, so traversal never crosses a node some principal
155
+ * cannot see. Every admitted node carries the path that reached it.
156
+ *
157
+ * An unknown or inactive graph returns an empty subgraph with a `Message`.
158
+ *
159
+ * `provider`, when given, carries every read made for the caller and the readers (node visibility,
160
+ * on-demand stored edges, derived-edge providers), e.g. the request's own provider on a server. The
161
+ * engine's cached metadata and Preload edges still come from the provider the engine was configured
162
+ * with.
163
+ */
164
+ Subgraph(graphName: string, seeds: GraphNodeRef[], options: GraphTraversalOptions, user: UserInfo, provider?: IMetadataProvider): Promise<GraphSubgraph>;
165
+ /**
166
+ * Alias for {@link Subgraph} used by RAG and pipeline callers.
167
+ */
168
+ Expand(graphName: string, seeds: GraphNodeRef[], options: GraphTraversalOptions, user: UserInfo, provider?: IMetadataProvider): Promise<GraphSubgraph>;
169
+ /**
170
+ * Render a {@link GraphSubgraph} as a compact, deterministic Markdown block for LLM prompt injection.
171
+ */
172
+ DescribeForPrompt(subgraph: GraphSubgraph): string;
173
+ /** `requested` when it can serve graph reads, else the provider the engine is bound to. */
174
+ private graphProvider;
175
+ /** `[user, ...readers]` with each user once (by ID) and the caller first. */
176
+ private principals;
177
+ private admitSeeds;
178
+ /** Candidate neighbors of the frontier, best first, with a deterministic tie-break. */
179
+ private rankCandidates;
180
+ private uniqueNeighborRefs;
181
+ /** Admit visible candidates in rank order until `maxNodes`; the best path to each node wins. */
182
+ private admitCandidates;
183
+ /**
184
+ * Every edge (that the traversal options allow) between two admitted nodes. Reads the admitted
185
+ * set's edges once more so edges among nodes reached on different branches are included.
186
+ */
187
+ private collectEdgesBetween;
188
+ private getEdgesForFrontier;
189
+ private touchesFrontier;
190
+ private toStoredEdgeView;
191
+ /**
192
+ * Whether every principal may read a stored edge's `Description` and `Attributes`. A field-level
193
+ * denial still returns the row (only the column is dropped), and the preload cache holds every
194
+ * column, so an edge's text is shown only when no principal is denied it.
195
+ */
196
+ private storedEdgeTextReadable;
197
+ /**
198
+ * Stored edges incident to the frontier, as every principal may read them.
199
+ *
200
+ * Served from the preload cache only for an active `Preload` graph, approved edges only, and only
201
+ * when every principal can read `MJ: Graph Edges` with no row-level filter (so the cache, loaded
202
+ * as the engine's identity, holds exactly what each of them could read). Otherwise each principal
203
+ * reads the frontier's edges itself — one bounded, ordered RunView per principal — and an edge is
204
+ * kept only if every principal read it.
205
+ */
206
+ private loadStoredEdges;
207
+ private preloadEdgesFor;
208
+ private readStoredEdgesAsPrincipals;
209
+ private buildStoredEdgeParams;
210
+ /**
211
+ * The approved stored edges of one `Preload` graph, loaded on first use as the engine's own identity
212
+ * (the system user on a server) and kept until a change drops them. `null` when the read fails: the
213
+ * caller then reads on demand as each principal.
214
+ */
215
+ private preloadedEdgesOf;
216
+ private readPreloadedEdges;
217
+ /**
218
+ * Derived edges every principal derives. Data-scale providers read as the user they run for, so an
219
+ * edge one principal derives from a row another cannot read (a membership, a link) would reveal that
220
+ * row; each principal runs the providers and only edges all of them produce are kept. Each read
221
+ * also applied that principal's field-level security, so an edge keeps only the text every
222
+ * principal's version carries (see {@link sharedEdgeText}).
223
+ */
224
+ private derivedEdgesForEveryPrincipal;
225
+ /** Derived edges from the graph's active providers, read as `caller`. */
226
+ private runDerivedProviders;
227
+ /** Nodes visible to EVERY principal; labels come from the caller's read. */
228
+ private resolveVisibleNodes;
229
+ /**
230
+ * Data-node labels and descriptions come from the caller's read. Field-level security drops a
231
+ * denied column but still returns the row, so a reader denied the name field still counts the node
232
+ * as visible; its label and description are shown only when EVERY principal may read the field,
233
+ * and otherwise replaced by the neutral `<entity name> <record ID>` label and no description.
234
+ * (Metadata nodes take their text from metadata, which entity permissions already gate.)
235
+ */
236
+ private neutralizeUnsharedText;
237
+ /**
238
+ * Nodes `principal` may see. Metadata nodes are checked against metadata; every data record —
239
+ * concepts included — is read as `principal` in one batched `RunViews` (`[pk] IN (...)` per
240
+ * entity), and a record that does not come back is invisible. A concept whose `Status` (as this
241
+ * principal read it) is not {@link IsGraphConceptStatusVisible} is invisible too.
242
+ */
243
+ private resolveNodesForPrincipal;
244
+ private resolveMetadataNode;
245
+ private metadataIndex;
246
+ private resolveDataNodes;
247
+ private buildNodeReadParams;
248
+ private addReturnedRows;
249
+ private normalizeNodeRef;
250
+ private nodeKey;
251
+ }
252
+ /** The label a node gets when its name field may not be shown: the entity name and the record key. */
253
+ export declare function NeutralGraphNodeLabel(entityName: string, recordId: string): string;
254
+ /** True when every principal may read `fieldName` on `entity` (MJ field-level security). */
255
+ export declare function IsFieldReadableByAll(entity: EntityInfo, fieldName: string, principals: readonly UserInfo[]): boolean;
256
+ /** `MJ: Graph Concepts.Status` values, from the generated entity. */
257
+ export type GraphConceptStatus = MJGraphConceptEntity['Status'];
258
+ /**
259
+ * Whether a concept with this `Status` may seed a traversal or appear in one. Only `Approved`
260
+ * concepts are canon; `Proposed` ones appear only when the caller asked for proposed content
261
+ * (`IncludeProposed`); `Draft` (the column default: still being written) and `Deprecated` never do.
262
+ * Anything else, including a status the reader could not read, is not visible.
263
+ */
264
+ export declare function IsGraphConceptStatusVisible(status: unknown, includeProposed: boolean): boolean;
265
+ /**
266
+ * Entity read permission with MJ's own semantics (`EntityInfo.GetUserPermisions`): role-based allow
267
+ * minus deny, no bypass for any user type. Anything unknown is denied.
268
+ */
269
+ export declare function CanUserReadEntity(entity: EntityInfo | undefined, user: UserInfo | undefined): boolean;
270
+ /** Clamp a requested traversal depth to `1..4` (default `2`). */
271
+ export declare function ClampGraphDepth(requested: number | undefined): number;
272
+ /** Clamp a requested node budget to `1..200` (default `50`, or `fallback`). */
273
+ export declare function ClampGraphMaxNodes(requested: number | undefined, fallback?: number): number;
274
+ //# sourceMappingURL=GraphEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphEngine.d.ts","sourceRoot":"","sources":["../../src/graph/GraphEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,wBAAwB,EACxB,eAAe,EAGf,UAAU,EAEV,iBAAiB,EAKjB,QAAQ,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAmD,OAAO,EAAc,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EACH,0BAA0B,EAC1B,oBAAoB,EACpB,wBAAwB,EAExB,yBAAyB,EACzB,6BAA6B,EAC7B,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAyB,iBAAiB,EAAyB,MAAM,4BAA4B,CAAC;AAElH,OAAO,EAOH,KAAK,aAAa,EAClB,K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