@lucern/graph-sync 1.0.28 → 1.0.30
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/CHANGELOG.md +8 -0
- package/dist/index.d.ts +198 -17
- package/dist/index.js +465 -373
- package/dist/index.js.map +1 -1
- package/dist/neo4jDriver.js +2 -4
- package/dist/neo4jDriver.js.map +1 -1
- package/dist/neo4jEdgeAPI.d.ts +93 -5
- package/dist/neo4jEdgeAPI.js +118 -107
- package/dist/neo4jEdgeAPI.js.map +1 -1
- package/dist/neo4jQueries-D14Putpd.d.ts +839 -0
- package/dist/neo4jQueries.d.ts +2 -1
- package/dist/neo4jQueries.js +72 -44
- package/dist/neo4jQueries.js.map +1 -1
- package/dist/neo4jQueryRoute.js +92 -45
- package/dist/neo4jQueryRoute.js.map +1 -1
- package/dist/neo4jSync.d.ts +106 -10
- package/dist/neo4jSync.js +159 -162
- package/dist/neo4jSync.js.map +1 -1
- package/dist/neo4jSyncHelpers-DWr-lF-A.d.ts +208 -0
- package/dist/neo4jSyncHelpers.d.ts +3 -1
- package/dist/neo4jSyncHelpers.js +44 -26
- package/dist/neo4jSyncHelpers.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/package.json +3 -3
- package/dist/neo4jQueries-j3LrFKpY.d.ts +0 -301
- package/dist/neo4jSyncHelpers-vxe1-Gvw.d.ts +0 -58
package/dist/neo4jQueries.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'convex/server';
|
|
2
|
+
export { f as findPotentialContradictions, g as getAnchoringBiasDetection, a as getBeliefEvidenceGraph, b as getBeliefHalfLife, c as getBeliefsByCompany, d as getBeliefsByEpistemicStatus, e as getCausalChains, h as getChallengedBeliefs, i as getCompaniesByTheme, j as getConfirmationBiasScore, k as getConnectedNodesGraph, l as getContradictionTensionMap, m as getCrossThemeBeliefs, o as getEvidenceByCompany, p as getEvidenceByMethodology, q as getEvidenceToBeliefPath, r as getFalsificationQuestions, s as getFunctionsByValueChain, t as getGraphStats, u as getHighPriorityQuestions, v as getKnowledgeFrontier, w as getMeetingPrepBrief, x as getMinimumFalsificationSet, y as getMissingQuestionDetection, z as getNecessaryEvidence, A as getNodeLineageGraph, B as getNodeRelationships, C as getNonConsensusBeliefs, D as getPeopleByCompany, E as getPeopleByTheme, F as getPortfolioConviction, G as getPredictions, H as getProprietaryEvidence, I as getProprietarySignals, J as getQuestionsByTheme, K as getQuestionsByValueChain, L as getReasoningDepthScore, M as getSemanticBridges, N as getSemanticOrphans, O as getSoftContradictions, P as getSourceConcentrationRisk, Q as getStaleThemes, R as getSurpriseDetection, S as getThemeBeliefsGraph, T as getThemeStats, U as getThemeSubgraph, V as getThemeValueChainCandidates, W as getThemesImpactingCompany, X as getValueChainsByTheme, Y as graphAwareSearch, Z as queryGraph, _ as searchAllNodes, $ as semanticSearch } from './neo4jQueries-D14Putpd.js';
|
package/dist/neo4jQueries.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { v } from 'convex/values';
|
|
2
1
|
import { permissiveReturn } from '@lucern/contracts/schema-helpers/validators';
|
|
2
|
+
import { v } from 'convex/values';
|
|
3
|
+
import { unsafeConvexAnyApi } from '@lucern/contracts/convex/unsafeAnyApi';
|
|
3
4
|
import { actionGeneric } from 'convex/server';
|
|
4
5
|
|
|
5
6
|
// src/neo4jQueries.ts
|
|
7
|
+
unsafeConvexAnyApi(
|
|
8
|
+
"graph-sync top-level module bundle lacks a committed Convex _generated/api surface"
|
|
9
|
+
);
|
|
6
10
|
var action = actionGeneric;
|
|
7
11
|
|
|
8
12
|
// src/neo4jQueriesCore.ts
|
|
13
|
+
var TRAILING_SLASH_REGEX = /\/+$/u;
|
|
14
|
+
var NEO4J_QUERY_TIMEOUT_MS = 1e4;
|
|
9
15
|
function toInt(value, defaultValue) {
|
|
10
16
|
if (value === void 0 || value === null) {
|
|
11
17
|
return defaultValue;
|
|
@@ -45,15 +51,69 @@ function createNeo4jQueryTransportFailure(error) {
|
|
|
45
51
|
function resolveProxyBaseUrl(apiBaseUrl) {
|
|
46
52
|
const resolved = apiBaseUrl || process.env.LUCERN_GRAPH_SYNC_QUERY_BASE_URL || process.env.NEXT_PUBLIC_APP_URL;
|
|
47
53
|
const normalized = resolved?.trim();
|
|
48
|
-
return normalized ? normalized.replace(
|
|
54
|
+
return normalized ? normalized.replace(TRAILING_SLASH_REGEX, "") : null;
|
|
49
55
|
}
|
|
50
56
|
function buildProxyEndpoint(proxyBaseUrl) {
|
|
51
57
|
const endpoint = new URL(proxyBaseUrl);
|
|
52
58
|
if (!endpoint.pathname.endsWith("/api/neo4j-query")) {
|
|
53
|
-
endpoint.pathname = `${endpoint.pathname.replace(
|
|
59
|
+
endpoint.pathname = `${endpoint.pathname.replace(
|
|
60
|
+
TRAILING_SLASH_REGEX,
|
|
61
|
+
""
|
|
62
|
+
)}/api/neo4j-query`;
|
|
54
63
|
}
|
|
55
64
|
return endpoint.toString();
|
|
56
65
|
}
|
|
66
|
+
function tenantContextFromParams(params) {
|
|
67
|
+
const explicitTenant = typeof params.tenantId === "string" ? params.tenantId.trim() : "";
|
|
68
|
+
const scopedTopic = typeof params.topicId === "string" ? params.topicId.trim() : "";
|
|
69
|
+
const legacyProjectScope = typeof params.projectId === "string" ? params.projectId.trim() : "";
|
|
70
|
+
const scopedTopicId = scopedTopic || legacyProjectScope;
|
|
71
|
+
const projectTenant = scopedTopicId ? `project:${scopedTopicId}` : "";
|
|
72
|
+
const defaultTenant = process.env.LUCERN_DEFAULT_TENANT_ID?.trim() || "";
|
|
73
|
+
return explicitTenant || projectTenant || defaultTenant;
|
|
74
|
+
}
|
|
75
|
+
function neo4jQueryHeaders(syncSecret, apiBaseUrl) {
|
|
76
|
+
const headers = {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
Authorization: `Bearer ${syncSecret}`
|
|
79
|
+
};
|
|
80
|
+
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
81
|
+
if (bypassSecret && apiBaseUrl) {
|
|
82
|
+
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
83
|
+
}
|
|
84
|
+
return headers;
|
|
85
|
+
}
|
|
86
|
+
async function postNeo4jQuery(args) {
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
const timeoutId = setTimeout(
|
|
89
|
+
() => controller.abort(),
|
|
90
|
+
NEO4J_QUERY_TIMEOUT_MS
|
|
91
|
+
);
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(buildProxyEndpoint(args.proxyUrl), {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: neo4jQueryHeaders(args.syncSecret, args.apiBaseUrl),
|
|
96
|
+
body: JSON.stringify({
|
|
97
|
+
queryName: args.queryName,
|
|
98
|
+
params: args.params
|
|
99
|
+
}),
|
|
100
|
+
signal: controller.signal
|
|
101
|
+
});
|
|
102
|
+
const result = await response.json();
|
|
103
|
+
if (!response.ok) {
|
|
104
|
+
return createNeo4jQueryTransportFailure(result.error || "Query failed");
|
|
105
|
+
}
|
|
106
|
+
return createNeo4jQueryTransportSuccess(result.data || []);
|
|
107
|
+
} catch (fetchError) {
|
|
108
|
+
if (fetchError instanceof Error && fetchError.name === "AbortError") {
|
|
109
|
+
console.warn("[Neo4j Queries] Request timed out for:", args.queryName);
|
|
110
|
+
return createNeo4jQueryTransportFailure("Query timed out (10s)");
|
|
111
|
+
}
|
|
112
|
+
throw fetchError;
|
|
113
|
+
} finally {
|
|
114
|
+
clearTimeout(timeoutId);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
57
117
|
function withTopicScope(args, params) {
|
|
58
118
|
return args.topicId ? { ...params, topicId: args.topicId } : params;
|
|
59
119
|
}
|
|
@@ -74,55 +134,23 @@ async function callNeo4jQuery(queryName, params, apiBaseUrl) {
|
|
|
74
134
|
const syncSecret = process.env.NEO4J_SYNC_SECRET;
|
|
75
135
|
if (!syncSecret) {
|
|
76
136
|
console.error("[Neo4j Queries] NEO4J_SYNC_SECRET not configured");
|
|
77
|
-
return createNeo4jQueryTransportFailure(
|
|
78
|
-
"Neo4j sync secret not configured"
|
|
79
|
-
);
|
|
137
|
+
return createNeo4jQueryTransportFailure("Neo4j sync secret not configured");
|
|
80
138
|
}
|
|
81
139
|
try {
|
|
82
|
-
const
|
|
83
|
-
const scopedTopic = typeof params.topicId === "string" ? params.topicId.trim() : "";
|
|
84
|
-
const legacyProject = typeof params.projectId === "string" ? params.projectId.trim() : "";
|
|
85
|
-
const scopedTopicId = scopedTopic || legacyProject;
|
|
86
|
-
const projectTenant = scopedTopicId ? `project:${scopedTopicId}` : "";
|
|
87
|
-
const defaultTenant = process.env.LUCERN_DEFAULT_TENANT_ID?.trim() || "";
|
|
88
|
-
const tenantId = explicitTenant || projectTenant || defaultTenant;
|
|
140
|
+
const tenantId = tenantContextFromParams(params);
|
|
89
141
|
if (!tenantId) {
|
|
90
142
|
return createNeo4jQueryTransportFailure(
|
|
91
143
|
"Missing required tenant context (tenantId or topicId)"
|
|
92
144
|
);
|
|
93
145
|
}
|
|
94
146
|
const scopedParams = { ...params, tenantId };
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
const controller = new AbortController();
|
|
104
|
-
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
105
|
-
try {
|
|
106
|
-
const response = await fetch(buildProxyEndpoint(proxyUrl), {
|
|
107
|
-
method: "POST",
|
|
108
|
-
headers,
|
|
109
|
-
body: JSON.stringify({ queryName, params: scopedParams }),
|
|
110
|
-
signal: controller.signal
|
|
111
|
-
});
|
|
112
|
-
clearTimeout(timeoutId);
|
|
113
|
-
const result = await response.json();
|
|
114
|
-
if (!response.ok) {
|
|
115
|
-
return createNeo4jQueryTransportFailure(result.error || "Query failed");
|
|
116
|
-
}
|
|
117
|
-
return createNeo4jQueryTransportSuccess(result.data || []);
|
|
118
|
-
} catch (fetchError) {
|
|
119
|
-
clearTimeout(timeoutId);
|
|
120
|
-
if (fetchError instanceof Error && fetchError.name === "AbortError") {
|
|
121
|
-
console.warn("[Neo4j Queries] Request timed out for:", queryName);
|
|
122
|
-
return createNeo4jQueryTransportFailure("Query timed out (10s)");
|
|
123
|
-
}
|
|
124
|
-
throw fetchError;
|
|
125
|
-
}
|
|
147
|
+
return await postNeo4jQuery({
|
|
148
|
+
apiBaseUrl,
|
|
149
|
+
params: scopedParams,
|
|
150
|
+
proxyUrl,
|
|
151
|
+
queryName,
|
|
152
|
+
syncSecret
|
|
153
|
+
});
|
|
126
154
|
} catch (error) {
|
|
127
155
|
console.error("[Neo4j Queries] Error in callNeo4jQuery:", queryName, error);
|
|
128
156
|
return createNeo4jQueryTransportFailure(
|