@lucern/graph-primitives 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/dist/{beliefDecay-DZ6tkLYq.d.ts → beliefDecay-BmkEk5OJ.d.ts} +3 -3
- package/dist/beliefDecay.d.ts +1 -1
- package/dist/beliefDecay.js +448 -314
- package/dist/beliefDecay.js.map +1 -1
- package/dist/{beliefEvidenceLinks-CWOXxxJg.d.ts → beliefEvidenceLinks-BzfjON_6.d.ts} +13 -13
- package/dist/beliefEvidenceLinks.d.ts +1 -1
- package/dist/beliefEvidenceLinks.js +843 -624
- package/dist/beliefEvidenceLinks.js.map +1 -1
- package/dist/beliefEvidenceLinks.operational.d.ts +7 -5
- package/dist/beliefEvidenceLinks.operational.js +91 -18
- package/dist/beliefEvidenceLinks.operational.js.map +1 -1
- package/dist/beliefLifecycle.js.map +1 -1
- package/dist/confidencePropagationDispatch.d.ts +28 -27
- package/dist/confidencePropagationDispatch.js +157 -99
- package/dist/confidencePropagationDispatch.js.map +1 -1
- package/dist/{contradictions-51VLsESq.d.ts → contradictions-BATPuZTL.d.ts} +10 -10
- package/dist/contradictions.d.ts +1 -1
- package/dist/contradictions.js +398 -228
- package/dist/contradictions.js.map +1 -1
- package/dist/convex.d.ts +65 -30
- package/dist/convex.js +7 -3
- package/dist/convex.js.map +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/edgeValidation.js +293 -85
- package/dist/edgeValidation.js.map +1 -1
- package/dist/edges/contains.d.ts +1 -1
- package/dist/edges/contains.js.map +1 -1
- package/dist/edges/contradicts.d.ts +1 -1
- package/dist/edges/contradicts.js.map +1 -1
- package/dist/edges/{dependsOn.d.ts → depends-on.d.ts} +1 -1
- package/dist/edges/{dependsOn.js → depends-on.js} +4 -4
- package/dist/edges/depends-on.js.map +1 -0
- package/dist/edges/{derivedFrom.d.ts → derived-from.d.ts} +1 -1
- package/dist/edges/{derivedFrom.js → derived-from.js} +3 -3
- package/dist/edges/derived-from.js.map +1 -0
- package/dist/edges/elaborates.d.ts +1 -1
- package/dist/edges/elaborates.js.map +1 -1
- package/dist/edges/index.d.ts +7 -3
- package/dist/edges/index.js +7 -4
- package/dist/edges/index.js.map +1 -1
- package/dist/edges/informs.d.ts +1 -1
- package/dist/edges/informs.js.map +1 -1
- package/dist/edges/{propagationTypes.d.ts → propagation-types.d.ts} +14 -14
- package/dist/edges/{propagationTypes.js → propagation-types.js} +3 -3
- package/dist/edges/propagation-types.js.map +1 -0
- package/dist/edges/refutes.d.ts +1 -1
- package/dist/edges/refutes.js.map +1 -1
- package/dist/edges/supports.d.ts +1 -1
- package/dist/edges/supports.js.map +1 -1
- package/dist/edges/tests.d.ts +1 -1
- package/dist/edges/tests.js.map +1 -1
- package/dist/edges/utils.d.ts +1 -1
- package/dist/edges/utils.js.map +1 -1
- package/dist/embeddingTrigger.d.ts +14 -6
- package/dist/embeddingTrigger.js +11 -14
- package/dist/embeddingTrigger.js.map +1 -1
- package/dist/{entityBridge-DMaKooYn.d.ts → entityBridge-BhVDM3pc.d.ts} +5 -5
- package/dist/entityBridge.d.ts +1 -1
- package/dist/entityBridge.js +602 -225
- package/dist/entityBridge.js.map +1 -1
- package/dist/entityCanonicalMatch.d.ts +14 -12
- package/dist/entityCanonicalMatch.js.map +1 -1
- package/dist/{entityLifecycle-CvgSK5FV.d.ts → entityLifecycle-BsfCz9pS.d.ts} +5 -9
- package/dist/entityLifecycle.d.ts +1 -1
- package/dist/entityLifecycle.js +857 -515
- package/dist/entityLifecycle.js.map +1 -1
- package/dist/{entityValidation-KLZ_Xl2D.d.ts → entityValidation-B1yNEHJx.d.ts} +7 -6
- package/dist/entityValidation.d.ts +3 -1
- package/dist/entityValidation.js +60 -8
- package/dist/entityValidation.js.map +1 -1
- package/dist/{epistemicAnswers-C5ib4z6_.d.ts → epistemicAnswers-f47YMu9U.d.ts} +6 -6
- package/dist/epistemicAnswers.d.ts +1 -1
- package/dist/epistemicAnswers.js +587 -545
- package/dist/epistemicAnswers.js.map +1 -1
- package/dist/epistemicBeliefs.admin.d.ts +8 -8
- package/dist/epistemicBeliefs.admin.js +366 -203
- package/dist/epistemicBeliefs.admin.js.map +1 -1
- package/dist/epistemicBeliefs.backfills.d.ts +8 -8
- package/dist/epistemicBeliefs.backfills.js +655 -308
- package/dist/epistemicBeliefs.backfills.js.map +1 -1
- package/dist/epistemicBeliefs.confidence.d.ts +19 -14
- package/dist/epistemicBeliefs.confidence.js +634 -423
- package/dist/epistemicBeliefs.confidence.js.map +1 -1
- package/dist/epistemicBeliefs.core.d.ts +6 -6
- package/dist/epistemicBeliefs.core.js +719 -411
- package/dist/epistemicBeliefs.core.js.map +1 -1
- package/dist/epistemicBeliefs.d.ts +11 -8
- package/dist/epistemicBeliefs.forkEvidence.d.ts +2 -0
- package/dist/epistemicBeliefs.forkEvidence.js +8 -28
- package/dist/epistemicBeliefs.forkEvidence.js.map +1 -1
- package/dist/epistemicBeliefs.helpers.d.ts +69 -74
- package/dist/epistemicBeliefs.helpers.js +359 -248
- package/dist/epistemicBeliefs.helpers.js.map +1 -1
- package/dist/epistemicBeliefs.internal.d.ts +5 -5
- package/dist/epistemicBeliefs.internal.js +1246 -1044
- package/dist/epistemicBeliefs.internal.js.map +1 -1
- package/dist/epistemicBeliefs.js +4922 -3608
- package/dist/epistemicBeliefs.js.map +1 -1
- package/dist/epistemicBeliefs.lifecycle.d.ts +5 -5
- package/dist/epistemicBeliefs.lifecycle.js +1137 -818
- package/dist/epistemicBeliefs.lifecycle.js.map +1 -1
- package/dist/epistemicBeliefs.links.d.ts +7 -7
- package/dist/epistemicBeliefs.links.js +408 -307
- package/dist/epistemicBeliefs.links.js.map +1 -1
- package/dist/epistemicBeliefs.queries.d.ts +4 -4
- package/dist/epistemicBeliefs.queries.js +175 -20
- package/dist/epistemicBeliefs.queries.js.map +1 -1
- package/dist/epistemicBeliefs.topicAnchor.d.ts +6 -4
- package/dist/epistemicBeliefs.topicAnchor.js +12 -5
- package/dist/epistemicBeliefs.topicAnchor.js.map +1 -1
- package/dist/epistemicContracts.d.ts +28 -3
- package/dist/epistemicContracts.evaluators.d.ts +2 -0
- package/dist/epistemicContracts.evaluators.js +1063 -613
- package/dist/epistemicContracts.evaluators.js.map +1 -1
- package/dist/epistemicContracts.handlers.d.ts +15 -32
- package/dist/epistemicContracts.handlers.js +2086 -1644
- package/dist/epistemicContracts.handlers.js.map +1 -1
- package/dist/epistemicContracts.js +1131 -672
- package/dist/epistemicContracts.js.map +1 -1
- package/dist/epistemicContracts.metrics.d.ts +2 -0
- package/dist/epistemicContracts.metrics.js +375 -158
- package/dist/epistemicContracts.metrics.js.map +1 -1
- package/dist/epistemicContracts.types.d.ts +87 -81
- package/dist/epistemicEdgeCreation.d.ts +2 -0
- package/dist/epistemicEdgeCreation.js +87 -16
- package/dist/epistemicEdgeCreation.js.map +1 -1
- package/dist/{epistemicEdges-BF-cn4i3.d.ts → epistemicEdges-BGBh0QSP.d.ts} +4 -7
- package/dist/epistemicEdges.d.ts +6 -5
- package/dist/epistemicEdges.handlers.d.ts +3 -3
- package/dist/epistemicEdges.handlers.js +129 -24
- package/dist/epistemicEdges.handlers.js.map +1 -1
- package/dist/epistemicEdges.helpers.d.ts +6 -4
- package/dist/epistemicEdges.helpers.js +37 -2
- package/dist/epistemicEdges.helpers.js.map +1 -1
- package/dist/epistemicEdges.js +1969 -1205
- package/dist/epistemicEdges.js.map +1 -1
- package/dist/epistemicEdges.mutations.d.ts +7 -7
- package/dist/epistemicEdges.mutations.js +960 -583
- package/dist/epistemicEdges.mutations.js.map +1 -1
- package/dist/epistemicEdges.queries.d.ts +16 -16
- package/dist/epistemicEdges.queries.js +639 -367
- package/dist/epistemicEdges.queries.js.map +1 -1
- package/dist/epistemicEdges.types.d.ts +10 -8
- package/dist/epistemicEvidence.d.ts +4 -1
- package/dist/epistemicEvidence.js +937 -536
- package/dist/epistemicEvidence.js.map +1 -1
- package/dist/epistemicEvidenceHelpers.d.ts +26 -10
- package/dist/epistemicEvidenceHelpers.js +239 -200
- package/dist/epistemicEvidenceHelpers.js.map +1 -1
- package/dist/epistemicEvidenceMutations.d.ts +8 -8
- package/dist/epistemicEvidenceMutations.js +844 -696
- package/dist/epistemicEvidenceMutations.js.map +1 -1
- package/dist/epistemicEvidenceQueries.d.ts +8 -8
- package/dist/epistemicEvidenceQueries.js +514 -238
- package/dist/epistemicEvidenceQueries.js.map +1 -1
- package/dist/epistemicHelpers.d.ts +4 -2
- package/dist/epistemicHelpers.js +308 -134
- package/dist/epistemicHelpers.js.map +1 -1
- package/dist/epistemicInsert.d.ts +16 -4
- package/dist/epistemicInsert.js +6 -3
- package/dist/epistemicInsert.js.map +1 -1
- package/dist/epistemicLayerRules.d.ts +10 -8
- package/dist/epistemicLayerRules.js +1 -5
- package/dist/epistemicLayerRules.js.map +1 -1
- package/dist/{epistemicLinking-CfE00tHJ.d.ts → epistemicLinking-CsCDv2cN.d.ts} +3 -3
- package/dist/epistemicLinking.d.ts +1 -1
- package/dist/epistemicLinking.js +177 -100
- package/dist/epistemicLinking.js.map +1 -1
- package/dist/epistemicNodeCreation.d.ts +2 -0
- package/dist/epistemicNodeCreation.js +203 -40
- package/dist/epistemicNodeCreation.js.map +1 -1
- package/dist/{epistemicNodes-BCQxpYx_.d.ts → epistemicNodes-CokAgBHg.d.ts} +3 -3
- package/dist/epistemicNodes.d.ts +3 -3
- package/dist/epistemicNodes.helpers.d.ts +24 -15
- package/dist/epistemicNodes.helpers.js.map +1 -1
- package/dist/epistemicNodes.internal.d.ts +6 -6
- package/dist/epistemicNodes.internal.js +389 -319
- package/dist/epistemicNodes.internal.js.map +1 -1
- package/dist/epistemicNodes.js +704 -508
- package/dist/epistemicNodes.js.map +1 -1
- package/dist/epistemicNodes.mutations.d.ts +6 -6
- package/dist/epistemicNodes.mutations.js +564 -467
- package/dist/epistemicNodes.mutations.js.map +1 -1
- package/dist/epistemicNodes.queries.d.ts +8 -8
- package/dist/epistemicNodes.queries.js +311 -314
- package/dist/epistemicNodes.queries.js.map +1 -1
- package/dist/epistemicNodes.validators.d.ts +2 -2
- package/dist/epistemicNodes.validators.js.map +1 -1
- package/dist/epistemicQuestions.conviction.d.ts +8 -8
- package/dist/epistemicQuestions.conviction.js +665 -484
- package/dist/epistemicQuestions.conviction.js.map +1 -1
- package/dist/epistemicQuestions.create.d.ts +4 -4
- package/dist/epistemicQuestions.create.js +640 -612
- package/dist/epistemicQuestions.create.js.map +1 -1
- package/dist/epistemicQuestions.d.ts +8 -5
- package/dist/epistemicQuestions.evidence.d.ts +2 -2
- package/dist/epistemicQuestions.evidence.js +475 -383
- package/dist/epistemicQuestions.evidence.js.map +1 -1
- package/dist/epistemicQuestions.helpers.d.ts +125 -24
- package/dist/epistemicQuestions.helpers.js +240 -209
- package/dist/epistemicQuestions.helpers.js.map +1 -1
- package/dist/epistemicQuestions.js +3474 -2823
- package/dist/epistemicQuestions.js.map +1 -1
- package/dist/epistemicQuestions.lifecycle.d.ts +2 -2
- package/dist/epistemicQuestions.lifecycle.js +607 -546
- package/dist/epistemicQuestions.lifecycle.js.map +1 -1
- package/dist/epistemicQuestions.queries.d.ts +12 -7
- package/dist/epistemicQuestions.queries.js +305 -244
- package/dist/epistemicQuestions.queries.js.map +1 -1
- package/dist/epistemicQuestions.sprint.d.ts +2 -2
- package/dist/epistemicQuestions.sprint.js +600 -394
- package/dist/epistemicQuestions.sprint.js.map +1 -1
- package/dist/epistemicQuestions.tail.d.ts +6 -6
- package/dist/epistemicQuestions.tail.js +572 -433
- package/dist/epistemicQuestions.tail.js.map +1 -1
- package/dist/{epistemicSources-dlKj58Jp.d.ts → epistemicSources-DQtaEkWs.d.ts} +4 -4
- package/dist/epistemicSources.d.ts +1 -1
- package/dist/epistemicSources.js +352 -312
- package/dist/epistemicSources.js.map +1 -1
- package/dist/evaluators/index.d.ts +8 -6
- package/dist/evaluators/index.js +399 -167
- package/dist/evaluators/index.js.map +1 -1
- package/dist/evaluators/lint-checker-evaluator.d.ts +16 -0
- package/dist/evaluators/{lintCheckerEvaluator.js → lint-checker-evaluator.js} +10 -5
- package/dist/evaluators/lint-checker-evaluator.js.map +1 -0
- package/dist/evaluators/{sentryCheckerEvaluator.d.ts → sentry-checker-evaluator.d.ts} +7 -2
- package/dist/evaluators/{sentryCheckerEvaluator.js → sentry-checker-evaluator.js} +3 -3
- package/dist/evaluators/sentry-checker-evaluator.js.map +1 -0
- package/dist/evaluators/shared.d.ts +2 -2
- package/dist/evaluators/shared.js +3 -1
- package/dist/evaluators/shared.js.map +1 -1
- package/dist/evaluators/{testRunnerEvaluator.d.ts → test-runner-evaluator.d.ts} +6 -1
- package/dist/evaluators/{testRunnerEvaluator.js → test-runner-evaluator.js} +6 -4
- package/dist/evaluators/test-runner-evaluator.js.map +1 -0
- package/dist/evaluators/tsc-checker-evaluator.d.ts +16 -0
- package/dist/evaluators/{tscCheckerEvaluator.js → tsc-checker-evaluator.js} +10 -5
- package/dist/evaluators/tsc-checker-evaluator.js.map +1 -0
- package/dist/graphTypes.js +6 -2
- package/dist/graphTypes.js.map +1 -1
- package/dist/helpers.d.ts +2 -0
- package/dist/helpers.js +313 -93
- package/dist/helpers.js.map +1 -1
- package/dist/{index-C-Kyd7hD.d.ts → index-DZxyC9Pb.d.ts} +7 -6
- package/dist/index.d.ts +87 -83
- package/dist/index.js +15677 -10594
- package/dist/index.js.map +1 -1
- package/dist/invariantEnforcement.d.ts +3 -3
- package/dist/invariantEnforcement.js.map +1 -1
- package/dist/logicalRoleInference.d.ts +2 -0
- package/dist/logicalRoleInference.js +1 -1
- package/dist/logicalRoleInference.js.map +1 -1
- package/dist/matcherFeedbackUtils.d.ts +2 -2
- package/dist/matcherFeedbackUtils.js.map +1 -1
- package/dist/{ontology-matching-C6rrz2VP.d.ts → ontology-matching-C-mYFrir.d.ts} +16 -16
- package/dist/ontology-matching.d.ts +1 -1
- package/dist/{ontologyApproval-CFYmqKmk.d.ts → ontologyApproval-BVt0feJi.d.ts} +10 -10
- package/dist/ontologyApproval.d.ts +1 -1
- package/dist/ontologyApproval.js +7 -1
- package/dist/ontologyApproval.js.map +1 -1
- package/dist/ontologyDefinitions.d.ts +14 -24
- package/dist/ontologyDefinitions.js +269 -34
- package/dist/ontologyDefinitions.js.map +1 -1
- package/dist/ontologyHelpers.d.ts +13 -13
- package/dist/ontologyHelpers.js.map +1 -1
- package/dist/{ontologyRegistry-B67rPJ16.d.ts → ontologyRegistry-CljS-ENv.d.ts} +2 -2
- package/dist/ontologyRegistry.d.ts +1 -1
- package/dist/ontologyRegistry.js +34 -6
- package/dist/ontologyRegistry.js.map +1 -1
- package/dist/{projectionReconciliation-jww2fBI0.d.ts → projectionReconciliation-DnrSgHSQ.d.ts} +4 -4
- package/dist/projectionReconciliation.d.ts +1 -1
- package/dist/projectionReconciliation.js +57 -10
- package/dist/projectionReconciliation.js.map +1 -1
- package/dist/{projectionStaleness-CmdbpjVK.d.ts → projectionStaleness-C8ImQ2zP.d.ts} +17 -17
- package/dist/projectionStaleness.d.ts +1 -1
- package/dist/projectionStaleness.js +8 -2
- package/dist/projectionStaleness.js.map +1 -1
- package/dist/proof-attestation.json +1 -1
- package/dist/{questionEvidenceLinks-DFlyPpAj.d.ts → questionEvidenceLinks-_nPRa-LY.d.ts} +10 -10
- package/dist/questionEvidenceLinks.d.ts +1 -1
- package/dist/questionEvidenceLinks.js +564 -347
- package/dist/questionEvidenceLinks.js.map +1 -1
- package/dist/{resolverTypes-CC8Ea2E2.d.ts → resolverTypes-BOXPxLET.d.ts} +8 -7
- package/dist/resolverTypes.d.ts +4 -2
- package/dist/{resolvers-Br1a6eLV.d.ts → resolvers-B1TIBmRO.d.ts} +3 -1
- package/dist/resolvers.d.ts +5 -3
- package/dist/resolvers.js +121 -77
- package/dist/resolvers.js.map +1 -1
- package/dist/scopeResolverCompat.d.ts +10 -7
- package/dist/scopeResolverCompat.js +106 -123
- package/dist/scopeResolverCompat.js.map +1 -1
- package/dist/{text-matching-DNg4M5Wd.d.ts → text-matching-DzFooju6.d.ts} +7 -7
- package/dist/text-matching.d.ts +1 -1
- package/dist/topicOntologyResolver.d.ts +22 -21
- package/dist/topicOntologyResolver.js +54 -32
- package/dist/topicOntologyResolver.js.map +1 -1
- package/dist/topicProjectOverlay.d.ts +30 -20
- package/dist/topicProjectOverlay.js +120 -76
- package/dist/topicProjectOverlay.js.map +1 -1
- package/dist/{topicScope-7zhyeGl7.d.ts → topicScope-DJVa0mLa.d.ts} +22 -7
- package/dist/topicScope.d.ts +3 -1
- package/dist/topicScope.js +104 -119
- package/dist/topicScope.js.map +1 -1
- package/dist/workflowBridge.d.ts +26 -15
- package/dist/workflowBridge.js +140 -144
- package/dist/workflowBridge.js.map +1 -1
- package/dist/workspaceIsolation.d.ts +14 -12
- package/dist/workspaceIsolation.js +108 -122
- package/dist/workspaceIsolation.js.map +1 -1
- package/package.json +4 -4
- package/dist/edges/dependsOn.js.map +0 -1
- package/dist/edges/derivedFrom.js.map +0 -1
- package/dist/edges/propagationTypes.js.map +0 -1
- package/dist/evaluators/lintCheckerEvaluator.d.ts +0 -11
- package/dist/evaluators/lintCheckerEvaluator.js.map +0 -1
- package/dist/evaluators/sentryCheckerEvaluator.js.map +0 -1
- package/dist/evaluators/testRunnerEvaluator.js.map +0 -1
- package/dist/evaluators/tscCheckerEvaluator.d.ts +0 -11
- package/dist/evaluators/tscCheckerEvaluator.js.map +0 -1
- package/dist/{epistemicQuestions-bwHd2FWE.d.ts → epistemicQuestions-Do1fhYm5.d.ts} +4 -4
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { unsafeConvexAnyApi } from '@lucern/contracts/convex/unsafeAnyApi';
|
|
2
|
+
import { componentsGeneric, internalMutationGeneric, internalQueryGeneric, mutationGeneric, queryGeneric } from 'convex/server';
|
|
2
3
|
import { v } from 'convex/values';
|
|
3
4
|
|
|
4
5
|
// src/convex.ts
|
|
5
|
-
var
|
|
6
|
+
var unsafeApi = unsafeConvexAnyApi(
|
|
7
|
+
"graph-primitives top-level module bundle lacks a committed Convex _generated/api surface"
|
|
8
|
+
);
|
|
9
|
+
var api = unsafeApi;
|
|
6
10
|
componentsGeneric();
|
|
7
|
-
var internal =
|
|
11
|
+
var internal = unsafeApi;
|
|
8
12
|
var internalMutation = internalMutationGeneric;
|
|
9
13
|
var internalQuery = internalQueryGeneric;
|
|
10
14
|
var mutation = mutationGeneric;
|
|
@@ -59,6 +63,10 @@ function readStringArray(value) {
|
|
|
59
63
|
function readMetadata(topic) {
|
|
60
64
|
return topic.metadata && typeof topic.metadata === "object" ? topic.metadata : {};
|
|
61
65
|
}
|
|
66
|
+
function omitMetadataKey(metadata, key) {
|
|
67
|
+
const { [key]: _omitted, ...rest } = metadata;
|
|
68
|
+
return rest;
|
|
69
|
+
}
|
|
62
70
|
function readLegacyProjectId(value) {
|
|
63
71
|
if (!value) {
|
|
64
72
|
return;
|
|
@@ -139,9 +147,12 @@ async function resolveTopicDoc(ctx, scopeId) {
|
|
|
139
147
|
);
|
|
140
148
|
}
|
|
141
149
|
try {
|
|
142
|
-
const topic = await ctx.runQuery(
|
|
143
|
-
|
|
144
|
-
|
|
150
|
+
const topic = await ctx.runQuery(
|
|
151
|
+
api.topics.getByLegacyScopeId,
|
|
152
|
+
{
|
|
153
|
+
projectId: String(scopeId)
|
|
154
|
+
}
|
|
155
|
+
);
|
|
145
156
|
if (topic?.name !== void 0 && topic?.type !== void 0) {
|
|
146
157
|
return topic;
|
|
147
158
|
}
|
|
@@ -161,8 +172,18 @@ function materializeTopicProjectOverlay(topic, idMode = "legacy") {
|
|
|
161
172
|
const outwardId = idMode === "topic" ? topicId : storageProjectId;
|
|
162
173
|
const visibility = coerceVisibility(topic.visibility) || coerceVisibility(metadata.visibility) || "private";
|
|
163
174
|
const status = coerceStatus(topic.status) || coerceStatus(metadata.status) || "active";
|
|
164
|
-
|
|
165
|
-
|
|
175
|
+
let createdAt = 0;
|
|
176
|
+
if (typeof topic.createdAt === "number") {
|
|
177
|
+
createdAt = topic.createdAt;
|
|
178
|
+
} else if (typeof topic._creationTime === "number") {
|
|
179
|
+
createdAt = topic._creationTime;
|
|
180
|
+
}
|
|
181
|
+
let updatedAt = createdAt;
|
|
182
|
+
if (typeof topic.updatedAt === "number") {
|
|
183
|
+
updatedAt = topic.updatedAt;
|
|
184
|
+
} else if (typeof metadata.updatedAt === "number") {
|
|
185
|
+
updatedAt = metadata.updatedAt;
|
|
186
|
+
}
|
|
166
187
|
return {
|
|
167
188
|
...metadata,
|
|
168
189
|
_id: outwardId,
|
|
@@ -231,90 +252,113 @@ async function patchTopicProjectOverlay(ctx, scopeId, value) {
|
|
|
231
252
|
if (!topic) {
|
|
232
253
|
return null;
|
|
233
254
|
}
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
255
|
+
const plan = buildTopicProjectOverlayPatchPlan(topic, value);
|
|
256
|
+
await applyTopicProjectOverlayPatch(ctx, topic, plan);
|
|
257
|
+
return materializeTopicProjectOverlay({
|
|
258
|
+
...topic,
|
|
259
|
+
...plan.patch,
|
|
260
|
+
metadata: plan.nextMetadata
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
function buildTopicProjectOverlayPatchPlan(topic, value) {
|
|
264
|
+
const plan = {
|
|
265
|
+
nextMetadata: { ...readMetadata(topic) },
|
|
266
|
+
patch: {},
|
|
267
|
+
topicUpdateArgs: {
|
|
268
|
+
id: String(topic._id)
|
|
269
|
+
}
|
|
238
270
|
};
|
|
239
271
|
for (const [key, rawValue] of Object.entries(value)) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
272
|
+
applyTopicProjectOverlayPatchEntry(plan, key, rawValue);
|
|
273
|
+
}
|
|
274
|
+
plan.patch.updatedAt = Date.now();
|
|
275
|
+
plan.patch.metadata = plan.nextMetadata;
|
|
276
|
+
plan.topicUpdateArgs.metadata = plan.nextMetadata;
|
|
277
|
+
return plan;
|
|
278
|
+
}
|
|
279
|
+
function applyTopicProjectOverlayPatchEntry(plan, key, rawValue) {
|
|
280
|
+
switch (key) {
|
|
281
|
+
case "_id":
|
|
282
|
+
case "projectId":
|
|
283
|
+
case "topicId":
|
|
284
|
+
case "legacyProjectId":
|
|
285
|
+
case "storageProjectId":
|
|
286
|
+
case "updatedAt":
|
|
287
|
+
case "createdAt":
|
|
288
|
+
return;
|
|
289
|
+
case "name":
|
|
290
|
+
case "description":
|
|
291
|
+
plan.patch[key] = rawValue;
|
|
292
|
+
plan.topicUpdateArgs[key] = rawValue;
|
|
293
|
+
return;
|
|
294
|
+
case "tenantId":
|
|
295
|
+
case "workspaceId":
|
|
296
|
+
case "ownerId":
|
|
297
|
+
throw new Error(
|
|
298
|
+
`patchTopicProjectOverlay cannot mutate ${key} via component-owned topics`
|
|
299
|
+
);
|
|
300
|
+
case "status":
|
|
301
|
+
applyTopicStatusPatch(plan, rawValue);
|
|
302
|
+
return;
|
|
303
|
+
case "visibility":
|
|
304
|
+
applyTopicVisibilityPatch(plan, rawValue);
|
|
305
|
+
return;
|
|
306
|
+
case "type":
|
|
307
|
+
applyTopicProjectTypePatch(plan, rawValue);
|
|
308
|
+
return;
|
|
309
|
+
default:
|
|
310
|
+
applyTopicMetadataPatch(plan, key, rawValue);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function applyTopicStatusPatch(plan, rawValue) {
|
|
314
|
+
const status = coerceStatus(rawValue);
|
|
315
|
+
if (status) {
|
|
316
|
+
plan.patch.status = status;
|
|
317
|
+
plan.topicUpdateArgs.status = status;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function applyTopicVisibilityPatch(plan, rawValue) {
|
|
321
|
+
const visibility = coerceVisibility(rawValue);
|
|
322
|
+
if (visibility) {
|
|
323
|
+
plan.patch.visibility = visibility;
|
|
324
|
+
plan.topicUpdateArgs.visibility = visibility;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
function applyTopicProjectTypePatch(plan, rawValue) {
|
|
328
|
+
const projectType = readNonEmptyString(rawValue);
|
|
329
|
+
if (projectType) {
|
|
330
|
+
plan.nextMetadata.projectType = projectType;
|
|
331
|
+
return;
|
|
293
332
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
333
|
+
plan.nextMetadata = omitMetadataKey(plan.nextMetadata, "projectType");
|
|
334
|
+
}
|
|
335
|
+
function applyTopicMetadataPatch(plan, key, rawValue) {
|
|
336
|
+
if (rawValue === void 0) {
|
|
337
|
+
plan.nextMetadata = omitMetadataKey(plan.nextMetadata, key);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
plan.nextMetadata[key] = rawValue;
|
|
341
|
+
}
|
|
342
|
+
async function applyTopicProjectOverlayPatch(ctx, topic, plan) {
|
|
297
343
|
if (typeof ctx.runMutation === "function") {
|
|
298
344
|
try {
|
|
299
|
-
await ctx.runMutation(api.topics.update, topicUpdateArgs);
|
|
345
|
+
await ctx.runMutation(api.topics.update, plan.topicUpdateArgs);
|
|
300
346
|
} catch (error) {
|
|
301
|
-
if (!
|
|
347
|
+
if (!canPatchTopicViaLocalDb(ctx, error)) {
|
|
302
348
|
throw error;
|
|
303
349
|
}
|
|
304
|
-
await ctx.db.patch(
|
|
350
|
+
await ctx.db.patch(topic._id, plan.patch);
|
|
305
351
|
}
|
|
306
352
|
} else if (ctx?.db && typeof ctx.db.patch === "function") {
|
|
307
|
-
await ctx.db.patch(
|
|
353
|
+
await ctx.db.patch(topic._id, plan.patch);
|
|
308
354
|
} else {
|
|
309
355
|
throw new Error(
|
|
310
356
|
"Cannot patch topic without component adapter (ctx.runMutation unavailable)"
|
|
311
357
|
);
|
|
312
358
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
metadata: nextMetadata
|
|
317
|
-
});
|
|
359
|
+
}
|
|
360
|
+
function canPatchTopicViaLocalDb(ctx, error) {
|
|
361
|
+
return isMissingLucernChildComponentError(error) && Boolean(ctx?.db) && typeof ctx.db?.patch === "function";
|
|
318
362
|
}
|
|
319
363
|
|
|
320
364
|
// src/resolvers.ts
|
|
@@ -342,7 +386,7 @@ async function patchProjectWithTolerance(ctx, projectId, value) {
|
|
|
342
386
|
try {
|
|
343
387
|
await patchTopicProjectOverlay(ctx, projectId, value);
|
|
344
388
|
} catch (error) {
|
|
345
|
-
if (!isAdvisoryTopicPatch(value)
|
|
389
|
+
if (!(isAdvisoryTopicPatch(value) && isMissingLucernChildComponentError2(error))) {
|
|
346
390
|
throw error;
|
|
347
391
|
}
|
|
348
392
|
console.warn(
|
|
@@ -409,13 +453,15 @@ function asMappedProjectId(topic) {
|
|
|
409
453
|
if (!topic) {
|
|
410
454
|
return;
|
|
411
455
|
}
|
|
412
|
-
const directLegacyProjectId = normalizeScopeValue(
|
|
456
|
+
const directLegacyProjectId = normalizeScopeValue(
|
|
457
|
+
topic[LEGACY_SCOPE_FIELD2]
|
|
458
|
+
);
|
|
413
459
|
if (directLegacyProjectId) {
|
|
414
460
|
return directLegacyProjectId;
|
|
415
461
|
}
|
|
416
462
|
const metadata = topic.metadata || {};
|
|
417
463
|
const candidate = metadata[LEGACY_SCOPE_FIELD2] || metadata.legacyProjectId || metadata.projectId || metadata.scopeProjectId;
|
|
418
|
-
return candidate ? candidate : void 0;
|
|
464
|
+
return typeof candidate === "string" ? normalizeScopeValue(candidate) : void 0;
|
|
419
465
|
}
|
|
420
466
|
function normalizeScopeValue(value) {
|
|
421
467
|
if (typeof value !== "string") {
|
|
@@ -440,8 +486,9 @@ function pickPrimaryTopic(candidates) {
|
|
|
440
486
|
})[0];
|
|
441
487
|
}
|
|
442
488
|
async function findTopicsByScopeAlias(ctx, scopeId) {
|
|
489
|
+
const query2 = ctx.db.query("topics");
|
|
443
490
|
try {
|
|
444
|
-
return await
|
|
491
|
+
return await query2.withIndex(
|
|
445
492
|
"by_graph_scope_project",
|
|
446
493
|
(q) => q.eq(LEGACY_SCOPE_FIELD2, scopeId)
|
|
447
494
|
).collect();
|
|
@@ -453,7 +500,7 @@ async function findTopicsByScopeAlias(ctx, scopeId) {
|
|
|
453
500
|
scopeId
|
|
454
501
|
}
|
|
455
502
|
);
|
|
456
|
-
const topics = await
|
|
503
|
+
const topics = await query2.collect();
|
|
457
504
|
return topics.filter((topic) => {
|
|
458
505
|
const normalizedGlobalId = normalizeScopeValue(topic.globalId);
|
|
459
506
|
const mappedProjectId = asMappedProjectId(topic);
|
|
@@ -509,137 +556,115 @@ async function resolveInheritedWorkspaceScope(ctx, topic) {
|
|
|
509
556
|
let current = topic;
|
|
510
557
|
for (let i = 0; i < MAX_DEPTH && current?.parentTopicId; i++) {
|
|
511
558
|
current = await ctx.db.get(current.parentTopicId);
|
|
512
|
-
if (!current)
|
|
559
|
+
if (!current) {
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
513
562
|
if (!tenantId) {
|
|
514
563
|
tenantId = normalizeScopeValue(current.tenantId);
|
|
515
564
|
}
|
|
516
565
|
if (!workspaceId) {
|
|
517
566
|
workspaceId = normalizeScopeValue(current.workspaceId);
|
|
518
567
|
}
|
|
519
|
-
if (tenantId && workspaceId)
|
|
568
|
+
if (tenantId && workspaceId) {
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
520
571
|
}
|
|
521
572
|
return { tenantId, workspaceId };
|
|
522
573
|
}
|
|
523
574
|
async function resolveTopicProjectScope(ctx, args) {
|
|
524
575
|
if (args.topicId) {
|
|
525
|
-
|
|
526
|
-
try {
|
|
527
|
-
topic = await ctx.db.get(
|
|
528
|
-
args.topicId
|
|
529
|
-
);
|
|
530
|
-
} catch (error) {
|
|
531
|
-
debugGraphPrimitiveFallback(
|
|
532
|
-
"[topicScope] Failed to load topic by direct id",
|
|
533
|
-
{
|
|
534
|
-
error,
|
|
535
|
-
topicId: args.topicId
|
|
536
|
-
}
|
|
537
|
-
);
|
|
538
|
-
}
|
|
539
|
-
if (!topic) {
|
|
540
|
-
topic = await tryResolveHostTopicById(ctx, String(args.topicId));
|
|
541
|
-
}
|
|
542
|
-
if (!topic) {
|
|
543
|
-
topic = pickPrimaryTopic(
|
|
544
|
-
await findTopicsByScopeAlias(ctx, String(args.topicId))
|
|
545
|
-
) ?? null;
|
|
546
|
-
}
|
|
547
|
-
if (!topic) {
|
|
548
|
-
const nodeScope = await resolveTopicNodeScopeOrNull(
|
|
549
|
-
ctx,
|
|
550
|
-
String(args.topicId)
|
|
551
|
-
);
|
|
552
|
-
if (nodeScope) {
|
|
553
|
-
return nodeScope;
|
|
554
|
-
}
|
|
555
|
-
throw new Error(`Topic not found: ${String(args.topicId)}`);
|
|
556
|
-
}
|
|
557
|
-
const inherited = await resolveInheritedWorkspaceScope(ctx, topic);
|
|
558
|
-
const mapped = asMappedProjectId(topic);
|
|
559
|
-
if (mapped) {
|
|
560
|
-
return {
|
|
561
|
-
topicId: topic._id,
|
|
562
|
-
projectId: mapped,
|
|
563
|
-
tenantId: inherited.tenantId,
|
|
564
|
-
workspaceId: inherited.workspaceId,
|
|
565
|
-
source: "topic"
|
|
566
|
-
};
|
|
567
|
-
}
|
|
568
|
-
return {
|
|
569
|
-
topicId: topic._id,
|
|
570
|
-
tenantId: inherited.tenantId,
|
|
571
|
-
workspaceId: inherited.workspaceId,
|
|
572
|
-
source: "topic"
|
|
573
|
-
};
|
|
576
|
+
return await resolveScopeFromTopicId(ctx, args.topicId);
|
|
574
577
|
}
|
|
575
578
|
if (args.projectId) {
|
|
576
|
-
|
|
577
|
-
try {
|
|
578
|
-
directTopic = await ctx.db.get(
|
|
579
|
-
args.projectId
|
|
580
|
-
);
|
|
581
|
-
} catch (error) {
|
|
582
|
-
debugGraphPrimitiveFallback(
|
|
583
|
-
"[topicScope] Failed to load direct project topic",
|
|
584
|
-
{
|
|
585
|
-
error,
|
|
586
|
-
projectId: args.projectId
|
|
587
|
-
}
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
if (directTopic) {
|
|
591
|
-
const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
|
|
592
|
-
const mapped = asMappedProjectId(directTopic);
|
|
593
|
-
return {
|
|
594
|
-
topicId: directTopic._id,
|
|
595
|
-
projectId: mapped ?? args.projectId,
|
|
596
|
-
tenantId: inherited.tenantId,
|
|
597
|
-
workspaceId: inherited.workspaceId,
|
|
598
|
-
source: "topic_inferred"
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
directTopic = await tryResolveHostTopicByLegacyScope(ctx, args.projectId);
|
|
602
|
-
if (directTopic) {
|
|
603
|
-
const inherited = await resolveInheritedWorkspaceScope(ctx, directTopic);
|
|
604
|
-
const mapped = asMappedProjectId(directTopic);
|
|
605
|
-
return {
|
|
606
|
-
topicId: directTopic._id,
|
|
607
|
-
projectId: mapped ?? args.projectId,
|
|
608
|
-
tenantId: inherited.tenantId,
|
|
609
|
-
workspaceId: inherited.workspaceId,
|
|
610
|
-
source: "topic_inferred"
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
const topics = await findTopicsByScopeAlias(ctx, args.projectId);
|
|
614
|
-
const primary = pickPrimaryTopic(topics);
|
|
615
|
-
if (primary) {
|
|
616
|
-
const inherited = await resolveInheritedWorkspaceScope(ctx, primary);
|
|
617
|
-
return {
|
|
618
|
-
topicId: primary._id,
|
|
619
|
-
projectId: args.projectId,
|
|
620
|
-
tenantId: inherited.tenantId,
|
|
621
|
-
workspaceId: inherited.workspaceId,
|
|
622
|
-
source: "project_mapped_topic"
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
const nodeScope = await resolveTopicNodeScopeOrNull(
|
|
626
|
-
ctx,
|
|
627
|
-
String(args.projectId)
|
|
628
|
-
);
|
|
629
|
-
if (nodeScope) {
|
|
630
|
-
return {
|
|
631
|
-
...nodeScope,
|
|
632
|
-
projectId: nodeScope.projectId ?? String(args.projectId)
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
throw new Error(
|
|
636
|
-
`Legacy project scope ${String(args.projectId)} has no mapped topic.`
|
|
637
|
-
);
|
|
579
|
+
return await resolveScopeFromLegacyProjectId(ctx, args.projectId);
|
|
638
580
|
}
|
|
639
581
|
throw new Error(
|
|
640
582
|
"Missing scope: provide topicId (preferred) or legacy projectId alias."
|
|
641
583
|
);
|
|
642
584
|
}
|
|
585
|
+
async function resolveScopeFromTopicId(ctx, topicId) {
|
|
586
|
+
const topic = await resolveTopicDocFromTopicId(ctx, topicId);
|
|
587
|
+
if (topic) {
|
|
588
|
+
return await buildTopicScope(ctx, topic, "topic");
|
|
589
|
+
}
|
|
590
|
+
const nodeScope = await resolveTopicNodeScopeOrNull(ctx, String(topicId));
|
|
591
|
+
if (nodeScope) {
|
|
592
|
+
return nodeScope;
|
|
593
|
+
}
|
|
594
|
+
throw new Error(`Topic not found: ${String(topicId)}`);
|
|
595
|
+
}
|
|
596
|
+
async function resolveTopicDocFromTopicId(ctx, topicId) {
|
|
597
|
+
const direct = await tryReadTopicDoc(ctx, topicId, {
|
|
598
|
+
failureLog: "[topicScope] Failed to load topic by direct id",
|
|
599
|
+
idLogKey: "topicId"
|
|
600
|
+
});
|
|
601
|
+
if (direct) {
|
|
602
|
+
return direct;
|
|
603
|
+
}
|
|
604
|
+
const hostTopic = await tryResolveHostTopicById(ctx, String(topicId));
|
|
605
|
+
if (hostTopic) {
|
|
606
|
+
return hostTopic;
|
|
607
|
+
}
|
|
608
|
+
return pickPrimaryTopic(await findTopicsByScopeAlias(ctx, String(topicId))) ?? null;
|
|
609
|
+
}
|
|
610
|
+
async function resolveScopeFromLegacyProjectId(ctx, legacyProjectId) {
|
|
611
|
+
const directTopic = await resolveDirectLegacyProjectTopic(
|
|
612
|
+
ctx,
|
|
613
|
+
legacyProjectId
|
|
614
|
+
);
|
|
615
|
+
if (directTopic) {
|
|
616
|
+
return await buildTopicScope(ctx, directTopic, "topic_inferred", {
|
|
617
|
+
fallbackProjectId: legacyProjectId
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
const primary = pickPrimaryTopic(
|
|
621
|
+
await findTopicsByScopeAlias(ctx, legacyProjectId)
|
|
622
|
+
);
|
|
623
|
+
if (primary) {
|
|
624
|
+
return await buildTopicScope(ctx, primary, "project_mapped_topic", {
|
|
625
|
+
fallbackProjectId: legacyProjectId
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
const nodeScope = await resolveTopicNodeScopeOrNull(ctx, legacyProjectId);
|
|
629
|
+
if (nodeScope) {
|
|
630
|
+
return {
|
|
631
|
+
...nodeScope,
|
|
632
|
+
projectId: nodeScope.projectId ?? legacyProjectId
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
throw new Error(
|
|
636
|
+
`Legacy project scope ${legacyProjectId} has no mapped topic.`
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
async function resolveDirectLegacyProjectTopic(ctx, legacyProjectId) {
|
|
640
|
+
const directTopic = await tryReadTopicDoc(ctx, legacyProjectId, {
|
|
641
|
+
failureLog: "[topicScope] Failed to load direct project topic",
|
|
642
|
+
idLogKey: "projectId"
|
|
643
|
+
});
|
|
644
|
+
return directTopic ?? tryResolveHostTopicByLegacyScope(ctx, legacyProjectId);
|
|
645
|
+
}
|
|
646
|
+
async function tryReadTopicDoc(ctx, id, log) {
|
|
647
|
+
try {
|
|
648
|
+
return await ctx.db.get(id);
|
|
649
|
+
} catch (error) {
|
|
650
|
+
debugGraphPrimitiveFallback(log.failureLog, {
|
|
651
|
+
error,
|
|
652
|
+
[log.idLogKey]: id
|
|
653
|
+
});
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
async function buildTopicScope(ctx, topic, source, options = {}) {
|
|
658
|
+
const inherited = await resolveInheritedWorkspaceScope(ctx, topic);
|
|
659
|
+
const mapped = asMappedProjectId(topic);
|
|
660
|
+
return {
|
|
661
|
+
topicId: topic._id,
|
|
662
|
+
...mapped || options.fallbackProjectId ? { projectId: mapped ?? options.fallbackProjectId } : {},
|
|
663
|
+
tenantId: inherited.tenantId,
|
|
664
|
+
workspaceId: inherited.workspaceId,
|
|
665
|
+
source
|
|
666
|
+
};
|
|
667
|
+
}
|
|
643
668
|
({
|
|
644
669
|
projectId: v.optional(v.string()),
|
|
645
670
|
topicId: v.optional(v.string())
|
|
@@ -653,9 +678,14 @@ var defineEpistemicInternalQuery = internalQuery;
|
|
|
653
678
|
function generateContentHash(text) {
|
|
654
679
|
const content = `question:${text.trim().toLowerCase().replace(/\s+/g, " ")}`;
|
|
655
680
|
let hash = 5381;
|
|
681
|
+
const maxSigned32Bit = 2147483647;
|
|
682
|
+
const uint32Size = 4294967296;
|
|
656
683
|
for (let i = 0; i < content.length; i++) {
|
|
657
|
-
hash = (hash
|
|
658
|
-
hash
|
|
684
|
+
hash = Math.imul(hash, 33) + content.charCodeAt(i);
|
|
685
|
+
hash %= uint32Size;
|
|
686
|
+
if (hash > maxSigned32Bit) {
|
|
687
|
+
hash -= uint32Size;
|
|
688
|
+
}
|
|
659
689
|
}
|
|
660
690
|
return Math.abs(hash).toString(16).padStart(8, "0");
|
|
661
691
|
}
|
|
@@ -663,9 +693,10 @@ function buildTestsEdgeGlobalId(fromGlobalId, toGlobalId) {
|
|
|
663
693
|
return `edge-${fromGlobalId}-tests-${toGlobalId}`;
|
|
664
694
|
}
|
|
665
695
|
async function markProjectGraphDirty(ctx, projectId, topicId) {
|
|
696
|
+
const markCacheStaleByTopic = internal.graphAnalysisCache.markCacheStaleByTopic;
|
|
666
697
|
const normalizedProjectId = typeof projectId === "string" && projectId.trim().length > 0 ? projectId : void 0;
|
|
667
698
|
const normalizedTopicId = typeof topicId === "string" && topicId.trim().length > 0 ? topicId : void 0;
|
|
668
|
-
if (!normalizedProjectId
|
|
699
|
+
if (!(normalizedProjectId || normalizedTopicId)) {
|
|
669
700
|
return;
|
|
670
701
|
}
|
|
671
702
|
if (normalizedProjectId) {
|
|
@@ -678,17 +709,17 @@ async function markProjectGraphDirty(ctx, projectId, topicId) {
|
|
|
678
709
|
);
|
|
679
710
|
}
|
|
680
711
|
if (normalizedTopicId) {
|
|
681
|
-
await ctx.scheduler.runAfter(
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
712
|
+
await ctx.scheduler.runAfter(0, markCacheStaleByTopic, {
|
|
713
|
+
topicId: normalizedTopicId
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
const resolvedProjectId = normalizedTopicId ?? normalizedProjectId;
|
|
717
|
+
if (!resolvedProjectId) {
|
|
718
|
+
return;
|
|
688
719
|
}
|
|
689
720
|
await resolveGraphPrimitivesAppResolvers().patchProject(
|
|
690
721
|
ctx,
|
|
691
|
-
|
|
722
|
+
resolvedProjectId,
|
|
692
723
|
{
|
|
693
724
|
lastActivityAt: Date.now()
|
|
694
725
|
}
|
|
@@ -750,7 +781,7 @@ function logQuestionFallback(message, error, context) {
|
|
|
750
781
|
});
|
|
751
782
|
}
|
|
752
783
|
async function resolveQuestionScopeOrNull(ctx, args) {
|
|
753
|
-
if (!args.projectId
|
|
784
|
+
if (!(args.projectId || args.topicId)) {
|
|
754
785
|
return null;
|
|
755
786
|
}
|
|
756
787
|
try {
|
|
@@ -824,7 +855,7 @@ function flattenQuestionNode(n) {
|
|
|
824
855
|
linkedBeliefId: meta.linkedBeliefNodeId || null,
|
|
825
856
|
testType: meta.testType || "validates",
|
|
826
857
|
importance: meta.importance || 5,
|
|
827
|
-
isKeyQuestion: meta.isKeyQuestion
|
|
858
|
+
isKeyQuestion: Boolean(meta.isKeyQuestion),
|
|
828
859
|
answer: meta.answer || null,
|
|
829
860
|
convictionStage: meta.convictionStage || null,
|
|
830
861
|
conviction: meta.conviction ?? null,
|
|
@@ -859,7 +890,7 @@ function getQuestionStatusCandidates(node) {
|
|
|
859
890
|
);
|
|
860
891
|
}
|
|
861
892
|
function isActiveQuestionNode(node) {
|
|
862
|
-
if (INACTIVE_NODE_STATUSES.has(node.status)) {
|
|
893
|
+
if (typeof node.status === "string" && INACTIVE_NODE_STATUSES.has(node.status)) {
|
|
863
894
|
return false;
|
|
864
895
|
}
|
|
865
896
|
return !getQuestionStatusCandidates(node).some(
|