@lucern/graph-primitives 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entityLifecycle.js +1 -12
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/epistemicAnswers.js +1 -12
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/epistemicBeliefs.core.js +4 -15
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.internal.js +4 -15
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +62 -19
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.links.js +59 -16
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicBeliefs.topicAnchor.js +3 -3
- package/dist/epistemicBeliefs.topicAnchor.js.map +1 -1
- package/dist/epistemicContracts.handlers.js +1 -12
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +1 -12
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicEdgeCreation.js +1 -12
- package/dist/epistemicEdgeCreation.js.map +1 -1
- package/dist/epistemicEdges.helpers.d.ts +1 -1
- package/dist/epistemicEvidence.js +1 -12
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceMutations.js +1 -12
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicHelpers.js +1 -12
- package/dist/epistemicHelpers.js.map +1 -1
- package/dist/epistemicNodeCreation.js +1 -10
- package/dist/epistemicNodeCreation.js.map +1 -1
- package/dist/epistemicQuestions.create.js +1 -12
- package/dist/epistemicQuestions.create.js.map +1 -1
- package/dist/epistemicQuestions.evidence.js +1 -12
- package/dist/epistemicQuestions.evidence.js.map +1 -1
- package/dist/epistemicQuestions.js +1 -12
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/epistemicQuestions.tail.js +1 -12
- package/dist/epistemicQuestions.tail.js.map +1 -1
- package/dist/epistemicSources.js +1 -12
- package/dist/epistemicSources.js.map +1 -1
- package/dist/globalId-4y9SPpC_.d.ts +10 -0
- package/dist/globalId.d.ts +1 -1
- package/dist/globalId.js +1 -13
- package/dist/globalId.js.map +1 -1
- package/dist/helpers.js +1 -12
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +65 -18
- package/dist/index.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/package.json +4 -4
- package/dist/globalId-DKh9d_uD.d.ts +0 -20
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { componentsGeneric, anyApi, internalMutationGeneric, mutationGeneric, qu
|
|
|
7
7
|
import { isNodeType, getLayerForNodeType } from '@lucern/contracts/schema-helpers/spine/tables/epistemicNodes';
|
|
8
8
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
9
9
|
import { assertSchemaEnumValue } from '@lucern/contracts/schema-helpers/enumValidation';
|
|
10
|
+
import { generateGlobalId, isUuidV7, generateUuidV7 } from '@lucern/contracts/ids';
|
|
10
11
|
import { listAudienceRegistryRows } from '@lucern/access-control/audienceRegistry';
|
|
11
12
|
import { scoreEntityTypeMatch, scoreEntityConnection, rankEntityTypeMatches, rankEntityConnections } from '@lucern/contracts/v1/ontologies/v1';
|
|
12
13
|
import { wordTokenize, wordOverlapScore, tokenizeSearchText, tokenOverlapScore, stemToken, scoreLexicalSignals, scoreLexicalSignal, rerankLexicalWindow, rankWindowScore, prepareLexicalQuery, jaccardSimilarity, bigramTokenize } from '@lucern/contracts/text-matching.contract';
|
|
@@ -2561,7 +2562,7 @@ function scopeFromTopicAnchor(topicNode) {
|
|
|
2561
2562
|
}
|
|
2562
2563
|
async function createRequiredBeliefTopicEdge(ctx, args) {
|
|
2563
2564
|
const topicGlobalId = args.topicNode.globalId;
|
|
2564
|
-
const edgeGlobalId = `edge:${args.beliefGlobalId}:${topicGlobalId}:
|
|
2565
|
+
const edgeGlobalId = `edge:${args.beliefGlobalId}:${topicGlobalId}:belongs_to`;
|
|
2565
2566
|
const now = Date.now();
|
|
2566
2567
|
const existing = await ctx.db.query("epistemicEdges").withIndex("by_globalId", (q) => q.eq("globalId", edgeGlobalId)).first();
|
|
2567
2568
|
if (!existing) {
|
|
@@ -2571,7 +2572,7 @@ async function createRequiredBeliefTopicEdge(ctx, args) {
|
|
|
2571
2572
|
toNodeId: String(args.topicNode._id),
|
|
2572
2573
|
sourceGlobalId: args.beliefGlobalId,
|
|
2573
2574
|
targetGlobalId: topicGlobalId,
|
|
2574
|
-
edgeType: "
|
|
2575
|
+
edgeType: "belongs_to",
|
|
2575
2576
|
weight: 1,
|
|
2576
2577
|
confidence: 1,
|
|
2577
2578
|
context: "Belief creation topic anchor invariant.",
|
|
@@ -2595,7 +2596,7 @@ async function createRequiredBeliefTopicEdge(ctx, args) {
|
|
|
2595
2596
|
globalId: edgeGlobalId,
|
|
2596
2597
|
fromGlobalId: args.beliefGlobalId,
|
|
2597
2598
|
toGlobalId: topicGlobalId,
|
|
2598
|
-
edgeType: "
|
|
2599
|
+
edgeType: "belongs_to",
|
|
2599
2600
|
weight: 1,
|
|
2600
2601
|
confidence: 1,
|
|
2601
2602
|
context: "Belief creation topic anchor invariant.",
|
|
@@ -2642,18 +2643,10 @@ async function scheduleEmbeddingGeneration(args) {
|
|
|
2642
2643
|
// src/globalId.ts
|
|
2643
2644
|
var globalId_exports = {};
|
|
2644
2645
|
__export(globalId_exports, {
|
|
2645
|
-
generateGlobalId: () => generateGlobalId
|
|
2646
|
+
generateGlobalId: () => generateGlobalId,
|
|
2647
|
+
generateUuidV7: () => generateUuidV7,
|
|
2648
|
+
isUuidV7: () => isUuidV7
|
|
2646
2649
|
});
|
|
2647
|
-
function generateGlobalId() {
|
|
2648
|
-
const bytes = new Uint8Array(16);
|
|
2649
|
-
crypto.getRandomValues(bytes);
|
|
2650
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
2651
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
2652
|
-
const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2653
|
-
""
|
|
2654
|
-
);
|
|
2655
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
2656
|
-
}
|
|
2657
2650
|
|
|
2658
2651
|
// src/epistemicBeliefs.core.ts
|
|
2659
2652
|
var create = mutation({
|
|
@@ -4163,6 +4156,39 @@ var getWithEvidence = query({
|
|
|
4163
4156
|
};
|
|
4164
4157
|
}
|
|
4165
4158
|
});
|
|
4159
|
+
async function collectRelationshipNodeRefs(ctx, nodeId) {
|
|
4160
|
+
const refs = /* @__PURE__ */ new Set([String(nodeId)]);
|
|
4161
|
+
const node = await ctx.db.get(nodeId);
|
|
4162
|
+
const globalId = typeof node?.globalId === "string" ? node.globalId.trim() : "";
|
|
4163
|
+
if (globalId.length > 0) {
|
|
4164
|
+
refs.add(globalId);
|
|
4165
|
+
}
|
|
4166
|
+
return [...refs];
|
|
4167
|
+
}
|
|
4168
|
+
function endpointMatches(q, fields, refs) {
|
|
4169
|
+
return q.or(
|
|
4170
|
+
...fields.flatMap(
|
|
4171
|
+
(field) => refs.map((ref) => q.eq(q.field(field), ref))
|
|
4172
|
+
)
|
|
4173
|
+
);
|
|
4174
|
+
}
|
|
4175
|
+
async function resolveRelationshipEndpoint(ctx, endpointId, globalEndpointId) {
|
|
4176
|
+
const candidates = [endpointId, globalEndpointId].map((value) => typeof value === "string" ? value.trim() : "").filter((value, index, values) => value.length > 0 && values.indexOf(value) === index);
|
|
4177
|
+
for (const candidate of candidates) {
|
|
4178
|
+
try {
|
|
4179
|
+
const direct = await ctx.db.get(candidate);
|
|
4180
|
+
if (direct) {
|
|
4181
|
+
return direct;
|
|
4182
|
+
}
|
|
4183
|
+
} catch {
|
|
4184
|
+
}
|
|
4185
|
+
const byGlobalId = await ctx.db.query("epistemicNodes").withIndex("by_globalId", (q) => q.eq("globalId", candidate)).first();
|
|
4186
|
+
if (byGlobalId) {
|
|
4187
|
+
return byGlobalId;
|
|
4188
|
+
}
|
|
4189
|
+
}
|
|
4190
|
+
return null;
|
|
4191
|
+
}
|
|
4166
4192
|
var getRelationships = query({
|
|
4167
4193
|
args: {
|
|
4168
4194
|
nodeId: v.id("epistemicNodes"),
|
|
@@ -4177,17 +4203,38 @@ var getRelationships = query({
|
|
|
4177
4203
|
incoming: [],
|
|
4178
4204
|
outgoing: []
|
|
4179
4205
|
};
|
|
4206
|
+
const nodeRefs = await collectRelationshipNodeRefs(ctx, args.nodeId);
|
|
4180
4207
|
if (direction === "in" || direction === "both") {
|
|
4181
|
-
const inEdges = await ctx.db.query("epistemicEdges").filter(
|
|
4208
|
+
const inEdges = await ctx.db.query("epistemicEdges").filter(
|
|
4209
|
+
(q) => endpointMatches(
|
|
4210
|
+
q,
|
|
4211
|
+
["toNodeId", "targetGlobalId", "toGlobalId", "toUuid"],
|
|
4212
|
+
nodeRefs
|
|
4213
|
+
)
|
|
4214
|
+
).collect();
|
|
4182
4215
|
for (const edge of inEdges) {
|
|
4183
|
-
const sourceNode = await
|
|
4216
|
+
const sourceNode = await resolveRelationshipEndpoint(
|
|
4217
|
+
ctx,
|
|
4218
|
+
edge.fromNodeId,
|
|
4219
|
+
edge.sourceGlobalId ?? edge.fromGlobalId ?? edge.fromUuid
|
|
4220
|
+
);
|
|
4184
4221
|
results.incoming.push({ edge, node: sourceNode });
|
|
4185
4222
|
}
|
|
4186
4223
|
}
|
|
4187
4224
|
if (direction === "out" || direction === "both") {
|
|
4188
|
-
const outEdges = await ctx.db.query("epistemicEdges").filter(
|
|
4225
|
+
const outEdges = await ctx.db.query("epistemicEdges").filter(
|
|
4226
|
+
(q) => endpointMatches(
|
|
4227
|
+
q,
|
|
4228
|
+
["fromNodeId", "sourceGlobalId", "fromGlobalId", "fromUuid"],
|
|
4229
|
+
nodeRefs
|
|
4230
|
+
)
|
|
4231
|
+
).collect();
|
|
4189
4232
|
for (const edge of outEdges) {
|
|
4190
|
-
const targetNode =
|
|
4233
|
+
const targetNode = await resolveRelationshipEndpoint(
|
|
4234
|
+
ctx,
|
|
4235
|
+
edge.toNodeId,
|
|
4236
|
+
edge.targetGlobalId ?? edge.toGlobalId ?? edge.toUuid
|
|
4237
|
+
);
|
|
4191
4238
|
results.outgoing.push({ edge, node: targetNode });
|
|
4192
4239
|
}
|
|
4193
4240
|
}
|