@lucern/sdk 1.0.11 → 1.0.13
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 +10 -0
- package/README.md +24 -27
- package/dist/.generated +2 -0
- package/dist/accessControl.d.ts +19 -26
- package/dist/accessControl.js +195 -1423
- package/dist/adminClient.d.ts +52 -59
- package/dist/adminClient.js +364 -1142
- package/dist/answersClient.d.ts +5 -14
- package/dist/answersClient.js +19 -737
- package/dist/audience/index.d.ts +18 -18
- package/dist/audience/index.js +87 -90
- package/dist/audiencesClient.d.ts +19 -27
- package/dist/audiencesClient.js +107 -868
- package/dist/auditClient.d.ts +8 -15
- package/dist/auditClient.js +18 -791
- package/dist/authContext.d.ts +11 -16
- package/dist/authContext.js +122 -154
- package/dist/authDeviceClient.d.ts +8 -17
- package/dist/authDeviceClient.js +113 -102
- package/dist/beliefs/index.d.ts +16 -67
- package/dist/beliefs/index.js +20 -10181
- package/dist/beliefs/lifecycle.d.ts +10 -11
- package/dist/beliefs/lifecycle.js +78 -80
- package/dist/beliefsClient.d.ts +30 -35
- package/dist/beliefsClient.js +238 -994
- package/dist/boundaryClientSurface.d.ts +11 -16
- package/dist/boundaryClientSurface.js +49 -68
- package/dist/client.d.ts +82 -113
- package/dist/client.js +232 -10155
- package/dist/clientAssemblyTypes.d.ts +3 -3
- package/dist/clientAssemblyTypes.js +1 -2
- package/dist/clientConfig.d.ts +45 -59
- package/dist/clientConfig.js +1 -2
- package/dist/clientEvidenceCompat.d.ts +24 -14
- package/dist/clientEvidenceCompat.js +56 -64
- package/dist/clientGraphNamespaces.d.ts +3 -5
- package/dist/clientGraphNamespaces.js +170 -245
- package/dist/clientHelpers.d.ts +20 -25
- package/dist/clientHelpers.js +104 -127
- package/dist/clientKnowledgeNamespaces.d.ts +24 -54
- package/dist/clientKnowledgeNamespaces.js +506 -506
- package/dist/clientLocalHelpers.d.ts +11 -56
- package/dist/clientLocalHelpers.js +503 -732
- package/dist/clientPlatformNamespaces.d.ts +5 -53
- package/dist/clientPlatformNamespaces.js +229 -323
- package/dist/clientRuntime.d.ts +5 -53
- package/dist/clientRuntime.js +26 -30
- package/dist/clientWorkflowNamespaces.d.ts +6 -15
- package/dist/clientWorkflowNamespaces.js +529 -596
- package/dist/contextClient.d.ts +9 -17
- package/dist/contextClient.js +92 -805
- package/dist/contextFacade.d.ts +11 -2
- package/dist/contextFacade.js +10 -81
- package/dist/contextPackCompiler.d.ts +10 -11
- package/dist/contextPackCompiler.js +494 -1040
- package/dist/contextPackPolicy.d.ts +14 -15
- package/dist/contextPackPolicy.js +227 -305
- package/dist/contextPackSchema.d.ts +3 -3
- package/dist/contextPackSchema.js +169 -176
- package/dist/contextTypes.d.ts +14 -15
- package/dist/contextTypes.js +1 -2
- package/dist/contracts/api-enums.contract.d.ts +29 -30
- package/dist/contracts/api-enums.contract.js +162 -88
- package/dist/contracts/auth-session.contract.d.ts +13 -14
- package/dist/contracts/auth-session.contract.js +55 -52
- package/dist/contracts/context-pack.contract.d.ts +54 -55
- package/dist/contracts/context-pack.contract.js +160 -88
- package/dist/contracts/contextPack.d.ts +2 -1
- package/dist/contracts/contextPack.js +1 -97
- package/dist/contracts/index.d.ts +11 -12
- package/dist/contracts/index.js +10 -854
- package/dist/contracts/lens-filter.contract.d.ts +9 -10
- package/dist/contracts/lens-filter.contract.js +82 -58
- package/dist/contracts/lens-workflow.contract.d.ts +21 -23
- package/dist/contracts/lens-workflow.contract.js +48 -117
- package/dist/contracts/lensFilter.d.ts +2 -1
- package/dist/contracts/lensFilter.js +1 -71
- package/dist/contracts/lensWorkflow.d.ts +2 -2
- package/dist/contracts/lensWorkflow.js +1 -123
- package/dist/contracts/mcpTools.d.ts +16 -18
- package/dist/contracts/mcpTools.js +89 -123
- package/dist/contracts/prompt.contract.d.ts +4 -5
- package/dist/contracts/prompt.contract.js +23 -10
- package/dist/contracts/prompt.d.ts +2 -1
- package/dist/contracts/prompt.js +1 -11
- package/dist/contracts/sdk-tools.contract.d.ts +2 -1
- package/dist/contracts/sdk-tools.contract.js +1 -2
- package/dist/contracts/sdkTools.d.ts +2 -1
- package/dist/contracts/sdkTools.js +1 -26
- package/dist/contracts/tool-contracts.d.ts +2 -1
- package/dist/contracts/tool-contracts.js +1 -2
- package/dist/contracts/workflow-runtime.contract.d.ts +45 -46
- package/dist/contracts/workflow-runtime.contract.js +241 -228
- package/dist/contracts/workflowRuntime.d.ts +2 -1
- package/dist/contracts/workflowRuntime.js +1 -244
- package/dist/contradictions/index.d.ts +8 -60
- package/dist/contradictions/index.js +11 -10175
- package/dist/control-plane.d.ts +17 -24
- package/dist/control-plane.js +124 -840
- package/dist/controlObjectOwnership.d.ts +19 -20
- package/dist/controlObjectOwnership.js +207 -201
- package/dist/coreClient.d.ts +23 -28
- package/dist/coreClient.js +567 -692
- package/dist/customTools.d.ts +17 -21
- package/dist/customTools.js +221 -221
- package/dist/decisions/index.d.ts +7 -58
- package/dist/decisions/index.js +14 -10177
- package/dist/decisionsClient.d.ts +25 -32
- package/dist/decisionsClient.js +113 -913
- package/dist/domainContext.d.ts +2 -1
- package/dist/domainContext.js +1 -2
- package/dist/edges/index.d.ts +21 -73
- package/dist/edges/index.js +12 -10176
- package/dist/embeddingsClient.d.ts +22 -30
- package/dist/embeddingsClient.js +73 -922
- package/dist/eventingClient.d.ts +23 -31
- package/dist/eventingClient.js +89 -918
- package/dist/events.d.ts +48 -49
- package/dist/events.js +257 -241
- package/dist/eventsCore.d.ts +20 -29
- package/dist/eventsCore.js +86 -830
- package/dist/evidence/index.d.ts +42 -61
- package/dist/evidence/index.js +13 -10176
- package/dist/evidenceClient.d.ts +13 -22
- package/dist/evidenceClient.js +34 -751
- package/dist/facade/context.d.ts +7 -8
- package/dist/facade/context.js +73 -72
- package/dist/functionSurface.d.ts +2 -156
- package/dist/functionSurface.js +1 -1460
- package/dist/functionSurfaceClient.d.ts +2 -9
- package/dist/functionSurfaceClient.js +1 -1460
- package/dist/gatewayFacades.d.ts +93 -296
- package/dist/gatewayFacades.factories.d.ts +209 -14
- package/dist/gatewayFacades.factories.js +545 -2228
- package/dist/gatewayFacades.js +284 -2627
- package/dist/generated/functionSurface.d.ts +149 -0
- package/dist/generated/functionSurface.js +749 -0
- package/dist/graphAnalysisClient.d.ts +41 -49
- package/dist/graphAnalysisClient.js +185 -974
- package/dist/graphClient.d.ts +53 -60
- package/dist/graphClient.js +219 -1090
- package/dist/graphIntel.d.ts +2 -4
- package/dist/graphIntel.js +1 -2
- package/dist/graphIntelligence.d.ts +4 -2
- package/dist/graphIntelligence.js +2 -46
- package/dist/graphRecommendationsClient.d.ts +15 -23
- package/dist/graphRecommendationsClient.js +70 -849
- package/dist/graphStateClassifierClient.d.ts +17 -25
- package/dist/graphStateClassifierClient.js +67 -908
- package/dist/harnessClient.d.ts +40 -47
- package/dist/harnessClient.js +198 -993
- package/dist/identityClient.d.ts +25 -33
- package/dist/identityClient.js +245 -1186
- package/dist/index.d.ts +73 -69
- package/dist/index.js +72 -13313
- package/dist/infisicalRuntime.d.ts +12 -14
- package/dist/infisicalRuntime.js +290 -297
- package/dist/jobsClient.d.ts +24 -32
- package/dist/jobsClient.js +101 -916
- package/dist/learningClient.d.ts +8 -16
- package/dist/learningClient.js +45 -809
- package/dist/lenses/index.d.ts +13 -65
- package/dist/lenses/index.js +11 -10175
- package/dist/mcpClient.d.ts +14 -23
- package/dist/mcpClient.js +115 -856
- package/dist/modelRuntimeClient.d.ts +18 -26
- package/dist/modelRuntimeClient.js +74 -894
- package/dist/nodes/index.d.ts +7 -58
- package/dist/nodes/index.js +14 -10177
- package/dist/ontologies/index.d.ts +21 -73
- package/dist/ontologies/index.js +14 -10178
- package/dist/ontologyClient.d.ts +23 -31
- package/dist/ontologyClient.js +138 -924
- package/dist/ontologyLinksClient.d.ts +16 -24
- package/dist/ontologyLinksClient.js +76 -886
- package/dist/opinion.d.ts +5 -6
- package/dist/opinion.js +21 -25
- package/dist/orgGraphSearchClient.d.ts +19 -27
- package/dist/orgGraphSearchClient.js +89 -857
- package/dist/packRuntime.d.ts +2 -2
- package/dist/packRuntime.js +1 -2
- package/dist/packsClient.d.ts +30 -37
- package/dist/packsClient.js +131 -906
- package/dist/policyClient.d.ts +21 -29
- package/dist/policyClient.js +267 -1026
- package/dist/proof-attestation.json +1 -1
- package/dist/questions/index.d.ts +9 -60
- package/dist/questions/index.js +15 -10178
- package/dist/realtime/index.d.ts +20 -16
- package/dist/realtime/index.js +30 -19
- package/dist/realtime/refs.d.ts +4 -6
- package/dist/realtime/refs.js +12 -7
- package/dist/realtime-refs.d.ts +1 -0
- package/dist/realtime-refs.js +1 -0
- package/dist/realtime.d.ts +1 -0
- package/dist/realtime.js +1 -0
- package/dist/reportsClient.d.ts +10 -19
- package/dist/reportsClient.js +48 -836
- package/dist/schemaClient.d.ts +16 -23
- package/dist/schemaClient.js +62 -832
- package/dist/sdkSurface.d.ts +18 -25
- package/dist/sdkSurface.js +135 -106
- package/dist/secrets.d.ts +2 -1
- package/dist/secrets.js +1 -2
- package/dist/sourcesClient.d.ts +11 -18
- package/dist/sourcesClient.js +18 -741
- package/dist/telemetryClient.d.ts +22 -30
- package/dist/telemetryClient.js +107 -931
- package/dist/toolRegistryClient.d.ts +27 -35
- package/dist/toolRegistryClient.js +116 -954
- package/dist/topics/index.d.ts +13 -64
- package/dist/topics/index.js +15 -10178
- package/dist/topicsClient.d.ts +19 -27
- package/dist/topicsClient.js +106 -894
- package/dist/types.d.ts +84 -87
- package/dist/types.js +1 -2
- package/dist/version.d.ts +2 -3
- package/dist/version.js +2 -5
- package/dist/workflowClient.d.ts +60 -65
- package/dist/workflowClient.js +343 -1219
- package/dist/worktrees/index.d.ts +16 -68
- package/dist/worktrees/index.js +14 -10178
- package/package.json +6 -6
- package/dist/accessControl.js.map +0 -1
- package/dist/adminClient.js.map +0 -1
- package/dist/answersClient.js.map +0 -1
- package/dist/audience/index.js.map +0 -1
- package/dist/audiencesClient.js.map +0 -1
- package/dist/auditClient.js.map +0 -1
- package/dist/authContext.js.map +0 -1
- package/dist/authDeviceClient.js.map +0 -1
- package/dist/beliefs/index.js.map +0 -1
- package/dist/beliefs/lifecycle.js.map +0 -1
- package/dist/beliefsClient.js.map +0 -1
- package/dist/boundaryClientSurface.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/clientAssemblyTypes.js.map +0 -1
- package/dist/clientConfig.js.map +0 -1
- package/dist/clientEvidenceCompat.js.map +0 -1
- package/dist/clientGraphNamespaces.js.map +0 -1
- package/dist/clientHelpers.js.map +0 -1
- package/dist/clientKnowledgeNamespaces.js.map +0 -1
- package/dist/clientLocalHelpers.js.map +0 -1
- package/dist/clientPlatformNamespaces.js.map +0 -1
- package/dist/clientRuntime.js.map +0 -1
- package/dist/clientWorkflowNamespaces.js.map +0 -1
- package/dist/contextClient.js.map +0 -1
- package/dist/contextFacade.js.map +0 -1
- package/dist/contextPackCompiler.js.map +0 -1
- package/dist/contextPackPolicy.js.map +0 -1
- package/dist/contextPackSchema.js.map +0 -1
- package/dist/contextTypes.js.map +0 -1
- package/dist/contracts/api-enums.contract.js.map +0 -1
- package/dist/contracts/auth-session.contract.js.map +0 -1
- package/dist/contracts/context-pack.contract.js.map +0 -1
- package/dist/contracts/contextPack.js.map +0 -1
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lens-filter.contract.js.map +0 -1
- package/dist/contracts/lens-workflow.contract.js.map +0 -1
- package/dist/contracts/lensFilter.js.map +0 -1
- package/dist/contracts/lensWorkflow.js.map +0 -1
- package/dist/contracts/mcpTools.js.map +0 -1
- package/dist/contracts/prompt.contract.js.map +0 -1
- package/dist/contracts/prompt.js.map +0 -1
- package/dist/contracts/sdk-tools.contract.js.map +0 -1
- package/dist/contracts/sdkTools.js.map +0 -1
- package/dist/contracts/tool-contracts.js.map +0 -1
- package/dist/contracts/workflow-runtime.contract.js.map +0 -1
- package/dist/contracts/workflowRuntime.js.map +0 -1
- package/dist/contradictions/index.js.map +0 -1
- package/dist/control-plane.js.map +0 -1
- package/dist/controlObjectOwnership.js.map +0 -1
- package/dist/coreClient.js.map +0 -1
- package/dist/customTools.js.map +0 -1
- package/dist/decisions/index.js.map +0 -1
- package/dist/decisionsClient.js.map +0 -1
- package/dist/domainContext.js.map +0 -1
- package/dist/edges/index.js.map +0 -1
- package/dist/embeddingsClient.js.map +0 -1
- package/dist/eventingClient.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/eventsCore.js.map +0 -1
- package/dist/evidence/index.js.map +0 -1
- package/dist/evidenceClient.js.map +0 -1
- package/dist/facade/context.js.map +0 -1
- package/dist/functionSurface.js.map +0 -1
- package/dist/functionSurfaceClient.js.map +0 -1
- package/dist/gatewayFacades.factories.js.map +0 -1
- package/dist/gatewayFacades.js.map +0 -1
- package/dist/graphAnalysisClient.js.map +0 -1
- package/dist/graphClient.js.map +0 -1
- package/dist/graphIntel.js.map +0 -1
- package/dist/graphIntelligence.js.map +0 -1
- package/dist/graphRecommendationsClient.js.map +0 -1
- package/dist/graphStateClassifierClient.js.map +0 -1
- package/dist/harnessClient.js.map +0 -1
- package/dist/identityClient.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infisicalRuntime.js.map +0 -1
- package/dist/jobsClient.js.map +0 -1
- package/dist/learningClient.js.map +0 -1
- package/dist/lenses/index.js.map +0 -1
- package/dist/mcpClient.js.map +0 -1
- package/dist/modelRuntimeClient.js.map +0 -1
- package/dist/nodes/index.js.map +0 -1
- package/dist/ontologies/index.js.map +0 -1
- package/dist/ontologyClient.js.map +0 -1
- package/dist/ontologyLinksClient.js.map +0 -1
- package/dist/opinion.js.map +0 -1
- package/dist/orgGraphSearchClient.js.map +0 -1
- package/dist/packRuntime.js.map +0 -1
- package/dist/packsClient.js.map +0 -1
- package/dist/policyClient.js.map +0 -1
- package/dist/questions/index.js.map +0 -1
- package/dist/realtime/index.js.map +0 -1
- package/dist/realtime/refs.js.map +0 -1
- package/dist/reportsClient.js.map +0 -1
- package/dist/schemaClient.js.map +0 -1
- package/dist/sdk-tools.contract-B4c1Zr1o.d.ts +0 -22
- package/dist/sdkSurface.js.map +0 -1
- package/dist/secrets.js.map +0 -1
- package/dist/sourcesClient.js.map +0 -1
- package/dist/telemetryClient.js.map +0 -1
- package/dist/tool-contracts-BUiL9P6z.d.ts +0 -22
- package/dist/toolRegistryClient.js.map +0 -1
- package/dist/topics/index.js.map +0 -1
- package/dist/topicsClient.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/workflowClient.js.map +0 -1
- package/dist/worktrees/index.js.map +0 -1
package/dist/gatewayFacades.js
CHANGED
|
@@ -1,2649 +1,306 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const normalized = value?.trim();
|
|
19
|
-
return normalized ? normalized : void 0;
|
|
20
|
-
}
|
|
21
|
-
function cleanStringList(values) {
|
|
22
|
-
if (!values) {
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
return values.map((value) => value.trim()).filter(
|
|
26
|
-
(value, index, list) => value.length > 0 && list.indexOf(value) === index
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
function requireString(value, reason, label) {
|
|
30
|
-
const normalized = cleanString(value);
|
|
31
|
-
if (!normalized) {
|
|
32
|
-
throw new LucernSdkAuthContextError(
|
|
33
|
-
reason,
|
|
34
|
-
`Canonical Lucern SDK auth context is missing ${label}.`
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
return normalized;
|
|
38
|
-
}
|
|
39
|
-
function requirePrincipalType(principalType2) {
|
|
40
|
-
if (!principalType2) {
|
|
41
|
-
throw new LucernSdkAuthContextError(
|
|
42
|
-
"principal_missing",
|
|
43
|
-
"Canonical Lucern SDK auth context is missing principalType."
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
return principalType2;
|
|
47
|
-
}
|
|
48
|
-
function requireAuthMode(authMode) {
|
|
49
|
-
if (!authMode) {
|
|
50
|
-
throw new LucernSdkAuthContextError(
|
|
51
|
-
"principal_missing",
|
|
52
|
-
"Canonical Lucern SDK auth context is missing authMode."
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
return authMode;
|
|
56
|
-
}
|
|
57
|
-
function ensurePermitMatch(args) {
|
|
58
|
-
const actual = cleanString(args.actual);
|
|
59
|
-
if (actual && actual !== args.expected) {
|
|
60
|
-
throw new LucernSdkAuthContextError(
|
|
61
|
-
"policy_denied",
|
|
62
|
-
`Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function normalizeCanonicalLucernAuthContext(input) {
|
|
67
|
-
if (!input) {
|
|
68
|
-
throw new LucernSdkAuthContextError(
|
|
69
|
-
"principal_missing",
|
|
70
|
-
"Canonical Lucern SDK auth context is required."
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
if (input.policyDecision === "deny") {
|
|
74
|
-
throw new LucernSdkAuthContextError(
|
|
75
|
-
"policy_denied",
|
|
76
|
-
"Canonical Lucern SDK auth context carries a denied policy decision."
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
const principalId = requireString(
|
|
80
|
-
input.principalId,
|
|
81
|
-
"principal_missing",
|
|
82
|
-
"principalId"
|
|
83
|
-
);
|
|
84
|
-
const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
|
|
85
|
-
const workspaceId = requireString(
|
|
86
|
-
input.workspaceId,
|
|
87
|
-
"workspace_missing",
|
|
88
|
-
"workspaceId"
|
|
89
|
-
);
|
|
90
|
-
const roles = cleanStringList(input.roles);
|
|
91
|
-
const scopes = cleanStringList(input.scopes);
|
|
92
|
-
const principalType2 = requirePrincipalType(input.principalType);
|
|
93
|
-
const authMode = requireAuthMode(input.authMode);
|
|
94
|
-
const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
|
|
95
|
-
if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
|
|
96
|
-
throw new LucernSdkAuthContextError(
|
|
97
|
-
"membership_missing",
|
|
98
|
-
"Canonical Lucern SDK auth context requires non-empty roles and scopes."
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
const subject = cleanString(input.permit?.subject) ?? principalId;
|
|
102
|
-
const tenant = cleanString(input.permit?.tenant) ?? tenantId;
|
|
103
|
-
const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
|
|
104
|
-
ensurePermitMatch({
|
|
105
|
-
field: "subject",
|
|
106
|
-
expected: principalId,
|
|
107
|
-
actual: subject
|
|
108
|
-
});
|
|
109
|
-
ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
|
|
110
|
-
ensurePermitMatch({
|
|
111
|
-
field: "workspace",
|
|
112
|
-
expected: workspaceId,
|
|
113
|
-
actual: workspace
|
|
114
|
-
});
|
|
115
|
-
const context = input.permit?.context ? { ...input.permit.context } : void 0;
|
|
116
|
-
return {
|
|
117
|
-
clerkId: cleanString(input.clerkId),
|
|
118
|
-
principalId,
|
|
119
|
-
tenantId,
|
|
120
|
-
workspaceId,
|
|
121
|
-
principalType: principalType2,
|
|
122
|
-
authMode,
|
|
123
|
-
roles,
|
|
124
|
-
scopes,
|
|
125
|
-
delegationChain: input.delegationChain ? [...input.delegationChain] : [],
|
|
126
|
-
policyTraceId: cleanString(input.policyTraceId),
|
|
127
|
-
correlationId: cleanString(input.correlationId),
|
|
128
|
-
membershipId: cleanString(input.membershipId),
|
|
129
|
-
permit: {
|
|
130
|
-
subject,
|
|
131
|
-
tenant,
|
|
132
|
-
workspace,
|
|
133
|
-
resource: cleanString(input.permit?.resource),
|
|
134
|
-
action: cleanString(input.permit?.action),
|
|
135
|
-
relation: cleanString(input.permit?.relation),
|
|
136
|
-
context
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function createCanonicalAuthHeaders(authContext) {
|
|
141
|
-
const headers = {
|
|
142
|
-
"x-lucern-principal-id": authContext.principalId,
|
|
143
|
-
"x-lucern-principal-type": authContext.principalType,
|
|
144
|
-
"x-lucern-tenant": authContext.tenantId,
|
|
145
|
-
"x-lucern-tenant-id": authContext.tenantId,
|
|
146
|
-
"x-lucern-workspace": authContext.workspaceId,
|
|
147
|
-
"x-lucern-workspace-id": authContext.workspaceId,
|
|
148
|
-
"x-lucern-auth-mode": authContext.authMode,
|
|
149
|
-
"x-lucern-roles": authContext.roles.join(","),
|
|
150
|
-
"x-lucern-scopes": authContext.scopes.join(","),
|
|
151
|
-
"x-lucern-permit-context": JSON.stringify(authContext.permit)
|
|
152
|
-
};
|
|
153
|
-
if (authContext.clerkId) {
|
|
154
|
-
headers["x-lucern-clerk-id"] = authContext.clerkId;
|
|
155
|
-
headers["x-lucern-user-id"] = authContext.clerkId;
|
|
156
|
-
}
|
|
157
|
-
if (authContext.delegationChain.length > 0) {
|
|
158
|
-
headers["x-lucern-delegation-chain"] = JSON.stringify(
|
|
159
|
-
authContext.delegationChain
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
if (authContext.policyTraceId) {
|
|
163
|
-
headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
|
|
164
|
-
}
|
|
165
|
-
if (authContext.correlationId) {
|
|
166
|
-
headers["x-correlation-id"] = authContext.correlationId;
|
|
167
|
-
headers["x-lucern-correlation-id"] = authContext.correlationId;
|
|
168
|
-
}
|
|
169
|
-
if (authContext.membershipId) {
|
|
170
|
-
headers["x-lucern-membership-id"] = authContext.membershipId;
|
|
171
|
-
}
|
|
172
|
-
return headers;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// src/coreClient.ts
|
|
176
|
-
var DEFAULT_GATEWAY_TIMEOUT_MS = 15e3;
|
|
177
|
-
var DEFAULT_GATEWAY_MAX_RETRIES = 2;
|
|
178
|
-
var DEFAULT_ENV_TIMEOUT_MS = "LUCERN_REQUEST_TIMEOUT_MS";
|
|
179
|
-
var DEFAULT_ENV_MAX_RETRIES = "LUCERN_GATEWAY_MAX_RETRIES";
|
|
180
|
-
var ENV_TIMEOUT_BY_METHOD_PREFIX = "LUCERN_REQUEST_TIMEOUT_MS_";
|
|
181
|
-
var GatewayTimeoutError = class extends Error {
|
|
182
|
-
retryable = true;
|
|
183
|
-
timeoutMs;
|
|
184
|
-
constructor(timeoutMs) {
|
|
185
|
-
super(`Request timed out after ${timeoutMs}ms`);
|
|
186
|
-
this.name = "AbortError";
|
|
187
|
-
this.timeoutMs = timeoutMs;
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
var GatewayTransportError = class extends Error {
|
|
191
|
-
retryable;
|
|
192
|
-
cause;
|
|
193
|
-
constructor(message, options) {
|
|
194
|
-
super(message);
|
|
195
|
-
this.name = "GatewayTransportError";
|
|
196
|
-
this.retryable = options?.retryable ?? true;
|
|
197
|
-
this.cause = options?.cause;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
function isGatewayRetryableError(error) {
|
|
201
|
-
return error instanceof GatewayTimeoutError && error.retryable || error instanceof GatewayTransportError && error.retryable || false;
|
|
202
|
-
}
|
|
203
|
-
var LucernApiError = class extends Error {
|
|
204
|
-
code;
|
|
205
|
-
status;
|
|
206
|
-
invariant;
|
|
207
|
-
suggestion;
|
|
208
|
-
details;
|
|
209
|
-
requestId;
|
|
210
|
-
correlationId;
|
|
211
|
-
policyTraceId;
|
|
212
|
-
constructor(args) {
|
|
213
|
-
super(args.message);
|
|
214
|
-
this.name = "LucernApiError";
|
|
215
|
-
this.code = args.code;
|
|
216
|
-
this.status = args.status;
|
|
217
|
-
this.invariant = args.invariant;
|
|
218
|
-
this.suggestion = args.suggestion;
|
|
219
|
-
this.details = args.details;
|
|
220
|
-
this.requestId = args.requestId;
|
|
221
|
-
this.correlationId = args.correlationId;
|
|
222
|
-
this.policyTraceId = args.policyTraceId;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
function toQueryString(scope) {
|
|
226
|
-
const params = new URLSearchParams();
|
|
227
|
-
if (scope.tenantId) {
|
|
228
|
-
params.set("tenantId", scope.tenantId);
|
|
229
|
-
}
|
|
230
|
-
if (scope.workspaceId) {
|
|
231
|
-
params.set("workspaceId", scope.workspaceId);
|
|
232
|
-
}
|
|
233
|
-
for (const [key, value] of Object.entries(scope)) {
|
|
234
|
-
if (key === "tenantId" || key === "workspaceId") {
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
if (value === void 0) {
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
params.set(key, String(value));
|
|
241
|
-
}
|
|
242
|
-
const serialized = params.toString();
|
|
243
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
244
|
-
}
|
|
245
|
-
function fillRandomBytes(length) {
|
|
246
|
-
const bytes = new Uint8Array(length);
|
|
247
|
-
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
248
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
249
|
-
return bytes;
|
|
250
|
-
}
|
|
251
|
-
for (let index = 0; index < length; index += 1) {
|
|
252
|
-
bytes[index] = Math.floor(Math.random() * 256);
|
|
253
|
-
}
|
|
254
|
-
return bytes;
|
|
255
|
-
}
|
|
256
|
-
function generatePortableRequestId() {
|
|
257
|
-
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
258
|
-
return globalThis.crypto.randomUUID();
|
|
259
|
-
}
|
|
260
|
-
const bytes = fillRandomBytes(16);
|
|
261
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
262
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
263
|
-
const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
|
|
264
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
|
|
265
|
-
6,
|
|
266
|
-
8
|
|
267
|
-
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
268
|
-
}
|
|
269
|
-
function resolveEnvironment() {
|
|
270
|
-
const processEnv = typeof globalThis === "object" && globalThis !== null && "process" in globalThis ? globalThis.process : void 0;
|
|
271
|
-
const env = processEnv !== void 0 && typeof processEnv === "object" && processEnv !== null && typeof processEnv.env === "object" ? processEnv.env : void 0;
|
|
272
|
-
return {
|
|
273
|
-
get: (name) => {
|
|
274
|
-
const value = env?.[name];
|
|
275
|
-
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function telemetryEnvironmentRecord(environment) {
|
|
280
|
-
const names = [
|
|
281
|
-
"LUCERN_TELEMETRY_ENABLED",
|
|
282
|
-
"AXIOM_TELEMETRY_ENABLED",
|
|
283
|
-
"LUCERN_AXIOM_TOKEN",
|
|
284
|
-
"AXIOM_TOKEN",
|
|
285
|
-
"LUCERN_AXIOM_EVENTS_DATASET",
|
|
286
|
-
"LUCERN_AXIOM_DATASET",
|
|
287
|
-
"AXIOM_EVENTS_DATASET",
|
|
288
|
-
"AXIOM_DATASET",
|
|
289
|
-
"LUCERN_AXIOM_API_URL",
|
|
290
|
-
"AXIOM_URL",
|
|
291
|
-
"LUCERN_ENVIRONMENT",
|
|
292
|
-
"NODE_ENV",
|
|
293
|
-
"LUCERN_RELEASE",
|
|
294
|
-
"SENTRY_RELEASE",
|
|
295
|
-
"VERCEL_GIT_COMMIT_SHA"
|
|
296
|
-
];
|
|
297
|
-
return Object.fromEntries(
|
|
298
|
-
names.map((name) => [name, environment.get(name)])
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
function resolveRequestProfile(config, environment) {
|
|
302
|
-
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
303
|
-
const parsedMaxRetries = parseIntegerFromString(
|
|
304
|
-
config.maxRetries,
|
|
305
|
-
environment.get(DEFAULT_ENV_MAX_RETRIES)
|
|
306
|
-
);
|
|
307
|
-
const parsedTimeoutMs = parseIntegerFromString(
|
|
308
|
-
config.timeoutMs,
|
|
309
|
-
environment.get(DEFAULT_ENV_TIMEOUT_MS)
|
|
310
|
-
);
|
|
311
|
-
const methodTimeouts = {
|
|
312
|
-
...config.timeoutMsByMethod
|
|
313
|
-
};
|
|
314
|
-
for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE"]) {
|
|
315
|
-
const envKey = `${ENV_TIMEOUT_BY_METHOD_PREFIX}${method}`;
|
|
316
|
-
const raw = environment.get(envKey);
|
|
317
|
-
if (!raw || methodTimeouts[method] !== void 0) {
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
const parsed = parseIntegerFromString(void 0, raw);
|
|
321
|
-
if (typeof parsed === "number") {
|
|
322
|
-
methodTimeouts[method] = parsed;
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return {
|
|
326
|
-
maxRetries: parsedMaxRetries ?? DEFAULT_GATEWAY_MAX_RETRIES,
|
|
327
|
-
timeoutMs: parsedTimeoutMs ?? DEFAULT_GATEWAY_TIMEOUT_MS,
|
|
328
|
-
timeoutMsByMethod: methodTimeouts,
|
|
329
|
-
requestIdFactory
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
function createGatewayRuntime(config, environment) {
|
|
333
|
-
return {
|
|
334
|
-
fetch: config.fetchImpl ?? fetch,
|
|
335
|
-
now: () => Date.now(),
|
|
336
|
-
sleep: (ms) => delay(ms),
|
|
337
|
-
env: environment,
|
|
338
|
-
redaction: resolveRequestRedactionValue,
|
|
339
|
-
profile: resolveRequestProfile(config, environment)
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
function parseIntegerFromString(value, rawValue) {
|
|
343
|
-
if (typeof value === "number" && Number.isInteger(value) && value >= 0) {
|
|
344
|
-
return value;
|
|
345
|
-
}
|
|
346
|
-
if (typeof rawValue !== "string" || !rawValue.trim()) {
|
|
347
|
-
return void 0;
|
|
348
|
-
}
|
|
349
|
-
const parsed = Number.parseInt(rawValue, 10);
|
|
350
|
-
return Number.isInteger(parsed) && parsed >= 0 ? parsed : void 0;
|
|
351
|
-
}
|
|
352
|
-
function resolveRequestRedactionValue(value) {
|
|
353
|
-
return redactDiagnosticValue(value);
|
|
354
|
-
}
|
|
355
|
-
function resolveGatewayBaseUrl(configBaseUrl, environment) {
|
|
356
|
-
const envBaseUrl = environment.get("LUCERN_API_URL") ?? environment.get("LUCERN_BASE_URL") ?? environment.get("LUCERN_GATEWAY_BASE_URL");
|
|
357
|
-
return (configBaseUrl ?? envBaseUrl ?? "").replace(/\/+$/, "");
|
|
358
|
-
}
|
|
359
|
-
function normalizeGatewayEnvironment(value) {
|
|
360
|
-
return value === "sandbox" || value === "production" ? value : void 0;
|
|
361
|
-
}
|
|
362
|
-
var randomIdempotencyKey = generatePortableRequestId;
|
|
363
|
-
function fallbackErrorCode(status) {
|
|
364
|
-
if (status === 401) {
|
|
365
|
-
return "AUTHENTICATION_REQUIRED";
|
|
366
|
-
}
|
|
367
|
-
if (status === 403) {
|
|
368
|
-
return "FORBIDDEN";
|
|
369
|
-
}
|
|
370
|
-
if (status === 404) {
|
|
371
|
-
return "NOT_FOUND";
|
|
372
|
-
}
|
|
373
|
-
if (status === 408) {
|
|
374
|
-
return "UPSTREAM_ERROR";
|
|
375
|
-
}
|
|
376
|
-
if (status === 409) {
|
|
377
|
-
return "CONFLICT";
|
|
378
|
-
}
|
|
379
|
-
if (status === 429) {
|
|
380
|
-
return "RATE_LIMIT_EXCEEDED";
|
|
381
|
-
}
|
|
382
|
-
if (status >= 500) {
|
|
383
|
-
return "UPSTREAM_ERROR";
|
|
384
|
-
}
|
|
385
|
-
return "INTERNAL_ERROR";
|
|
386
|
-
}
|
|
387
|
-
function delay(ms) {
|
|
388
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
389
|
-
}
|
|
390
|
-
function computeRetryDelayMs(args) {
|
|
391
|
-
const baseDelay = args.status === 429 ? Math.max(
|
|
392
|
-
args.retryAfterMs ?? 0,
|
|
393
|
-
Math.min(1e3 * 2 ** args.attempt, 1e4)
|
|
394
|
-
) : Math.min(1e3 * 2 ** args.attempt, 4e3);
|
|
395
|
-
if (args.status !== 429) {
|
|
396
|
-
return baseDelay;
|
|
397
|
-
}
|
|
398
|
-
const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
|
|
399
|
-
return baseDelay + Math.round(Math.random() * jitterWindow);
|
|
400
|
-
}
|
|
401
|
-
function classifyGatewayErrorForRetry(error) {
|
|
402
|
-
return isGatewayRetryableError(error) || classifyRetry({ error }).retryable;
|
|
403
|
-
}
|
|
404
|
-
function isRecord(value) {
|
|
405
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
406
|
-
}
|
|
407
|
-
function readPolicySummaryFromDetails(details) {
|
|
408
|
-
if (!isRecord(details)) {
|
|
409
|
-
return null;
|
|
410
|
-
}
|
|
411
|
-
const directSummary = details.summary;
|
|
412
|
-
if (typeof directSummary === "string" && directSummary.trim().length > 0) {
|
|
413
|
-
return directSummary.trim();
|
|
414
|
-
}
|
|
415
|
-
const policy = details.policy;
|
|
416
|
-
if (!isRecord(policy)) {
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
const explanation = policy.explanation;
|
|
420
|
-
if (!isRecord(explanation)) {
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
const nestedSummary = explanation.summary;
|
|
424
|
-
if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
|
|
425
|
-
return nestedSummary.trim();
|
|
426
|
-
}
|
|
427
|
-
return null;
|
|
428
|
-
}
|
|
429
|
-
function redactJsonDiagnosticValue(value) {
|
|
430
|
-
return value === void 0 ? void 0 : redactDiagnosticValue(value);
|
|
431
|
-
}
|
|
432
|
-
async function resolveConfiguredAuthContext(authContext) {
|
|
433
|
-
if (typeof authContext === "function") {
|
|
434
|
-
return await authContext();
|
|
435
|
-
}
|
|
436
|
-
return authContext;
|
|
437
|
-
}
|
|
438
|
-
function mergeHeaderRecord(base, addition) {
|
|
439
|
-
const headers = new Headers(base);
|
|
440
|
-
for (const [key, value] of Object.entries(addition)) {
|
|
441
|
-
const existing = headers.get(key);
|
|
442
|
-
if (existing !== null && existing !== value) {
|
|
443
|
-
throw new LucernSdkAuthContextError(
|
|
444
|
-
"policy_denied",
|
|
445
|
-
`Canonical Lucern SDK auth context conflicts with existing ${key} header.`
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
headers.set(key, value);
|
|
449
|
-
}
|
|
450
|
-
return Object.fromEntries(headers.entries());
|
|
451
|
-
}
|
|
452
|
-
function cleanHeaderValue(value) {
|
|
453
|
-
const normalized = value?.trim();
|
|
454
|
-
return normalized ? normalized : void 0;
|
|
455
|
-
}
|
|
456
|
-
function createGatewayRequestClient(config = {}) {
|
|
457
|
-
const env = resolveEnvironment();
|
|
458
|
-
const runtime = createGatewayRuntime(config, env);
|
|
459
|
-
const baseUrl = resolveGatewayBaseUrl(config.baseUrl, env);
|
|
460
|
-
const maxRetries = runtime.profile.maxRetries;
|
|
461
|
-
const requestIdFactory = runtime.profile.requestIdFactory;
|
|
462
|
-
const requestTimeoutByMethod = runtime.profile.timeoutMsByMethod;
|
|
463
|
-
const defaultRequestTimeoutMs = runtime.profile.timeoutMs;
|
|
464
|
-
const normalizedEnvironment = normalizeGatewayEnvironment(config.environment);
|
|
465
|
-
const telemetryExporter = config.telemetryEnabled === false ? null : config.telemetryExporter ?? createTelemetryExporterFromEnv(telemetryEnvironmentRecord(env), {
|
|
466
|
-
service: "lucern-sdk",
|
|
467
|
-
environment: normalizedEnvironment
|
|
468
|
-
});
|
|
469
|
-
async function resolveAuthHeaders() {
|
|
470
|
-
const provided = config.getAuthHeaders ? await config.getAuthHeaders() : {};
|
|
471
|
-
const headers = new Headers(provided);
|
|
472
|
-
const setIfAbsent = (name, value) => {
|
|
473
|
-
const normalized = cleanHeaderValue(value);
|
|
474
|
-
if (normalized && !headers.has(name)) {
|
|
475
|
-
headers.set(name, normalized);
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
setIfAbsent("x-lucern-key", config.apiKey);
|
|
479
|
-
setIfAbsent("x-lucern-session-token", config.userToken);
|
|
480
|
-
setIfAbsent("x-lucern-environment", normalizedEnvironment);
|
|
481
|
-
setIfAbsent("x-lucern-clerk-id", config.clerkId);
|
|
482
|
-
setIfAbsent("x-lucern-user-id", config.userId ?? config.clerkId);
|
|
483
|
-
setIfAbsent("x-lucern-deployment-host", config.deploymentHost);
|
|
484
|
-
const base = Object.fromEntries(headers.entries());
|
|
485
|
-
const authContextInput = await resolveConfiguredAuthContext(
|
|
486
|
-
config.authContext
|
|
487
|
-
);
|
|
488
|
-
if (!authContextInput && !config.requireCanonicalAuthContext) {
|
|
489
|
-
return base;
|
|
490
|
-
}
|
|
491
|
-
const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
|
|
492
|
-
return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
|
|
493
|
-
}
|
|
494
|
-
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
495
|
-
const normalizeTransportError = (error, isTimeout) => {
|
|
496
|
-
if (isTimeout) {
|
|
497
|
-
return new GatewayTimeoutError(timeoutMs);
|
|
498
|
-
}
|
|
499
|
-
return error instanceof GatewayTimeoutError || error instanceof GatewayTransportError ? error : new GatewayTransportError(
|
|
500
|
-
error instanceof Error ? error.message : "Gateway transport error",
|
|
501
|
-
{
|
|
502
|
-
cause: error,
|
|
503
|
-
retryable: classifyGatewayErrorForRetry(error)
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
};
|
|
507
|
-
const controller = new AbortController();
|
|
508
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
509
|
-
const requestEffect = Effect.tryPromise({
|
|
510
|
-
try: () => runtime.fetch(url, { ...init, signal: controller.signal }),
|
|
511
|
-
catch: (error) => normalizeTransportError(error, controller.signal.aborted)
|
|
512
|
-
});
|
|
513
|
-
try {
|
|
514
|
-
const exit = await Effect.runPromiseExit(requestEffect);
|
|
515
|
-
if (Exit.isSuccess(exit)) {
|
|
516
|
-
return exit.value;
|
|
517
|
-
}
|
|
518
|
-
const failure = Array.from(Cause.failures(exit.cause))[0];
|
|
519
|
-
if (failure !== void 0) {
|
|
520
|
-
throw failure;
|
|
521
|
-
}
|
|
522
|
-
throw Cause.squash(exit.cause);
|
|
523
|
-
} finally {
|
|
524
|
-
clearTimeout(timer);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
async function emitSdkResponseTelemetry(context) {
|
|
528
|
-
const retry = classifyRetry({
|
|
529
|
-
status: context.status,
|
|
530
|
-
error: context.error,
|
|
531
|
-
retryAfter: context.retryAfterMs !== null && context.retryAfterMs !== void 0 ? String(context.retryAfterMs / 1e3) : void 0
|
|
532
|
-
});
|
|
533
|
-
await emitTelemetrySignal(telemetryExporter, {
|
|
534
|
-
signalType: "trace",
|
|
535
|
-
surface: "sdk-retry",
|
|
536
|
-
eventName: context.willRetry ? "sdk.retry" : context.error ? "sdk.request.error" : "sdk.request.complete",
|
|
537
|
-
severity: context.error ? context.willRetry ? "warn" : "error" : "info",
|
|
538
|
-
durationMs: context.durationMs,
|
|
539
|
-
metricName: "sdk.request.duration_ms",
|
|
540
|
-
metricValue: context.durationMs,
|
|
541
|
-
correlationId: context.correlationId ?? context.requestId,
|
|
542
|
-
policyTraceId: context.policyTraceId ?? null,
|
|
543
|
-
tenantId: context.headers.get("x-lucern-tenant-id") ?? context.headers.get("x-lucern-tenant") ?? void 0,
|
|
544
|
-
workspaceId: context.headers.get("x-lucern-workspace-id") ?? context.headers.get("x-lucern-workspace") ?? void 0,
|
|
545
|
-
attributes: {
|
|
546
|
-
service: "lucern-sdk",
|
|
547
|
-
operation: "gateway.request",
|
|
548
|
-
path: context.path,
|
|
549
|
-
httpMethod: context.method,
|
|
550
|
-
httpStatus: context.status,
|
|
551
|
-
attempt: context.attempt,
|
|
552
|
-
maxRetries: context.maxRetries,
|
|
553
|
-
retryReason: retry.reason,
|
|
554
|
-
retryAfterMs: context.retryAfterMs ?? retry.retryAfterMs,
|
|
555
|
-
willRetry: context.willRetry,
|
|
556
|
-
retryable: retry.retryable,
|
|
557
|
-
errorName: context.error instanceof Error ? context.error.name : void 0,
|
|
558
|
-
errorMessage: context.error instanceof Error ? context.error.message : void 0
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
async function parsePayload(response) {
|
|
563
|
-
const text = await response.text();
|
|
564
|
-
if (!text) {
|
|
565
|
-
return null;
|
|
566
|
-
}
|
|
567
|
-
const parsed = tryParseGatewayEnvelopeJson(text);
|
|
568
|
-
if (!parsed.ok) {
|
|
569
|
-
return null;
|
|
570
|
-
}
|
|
571
|
-
return isRecord(parsed.value) ? parsed.value : null;
|
|
572
|
-
}
|
|
573
|
-
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
574
|
-
if (typeof requestTimeoutMs === "number") {
|
|
575
|
-
return requestTimeoutMs;
|
|
576
|
-
}
|
|
577
|
-
const methodTimeoutMs = requestTimeoutByMethod?.[method];
|
|
578
|
-
if (typeof methodTimeoutMs === "number") {
|
|
579
|
-
return methodTimeoutMs;
|
|
580
|
-
}
|
|
581
|
-
return defaultRequestTimeoutMs;
|
|
582
|
-
}
|
|
583
|
-
function tryParseGatewayEnvelopeJson(text) {
|
|
584
|
-
const trimmed = text.trim();
|
|
585
|
-
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
586
|
-
return { ok: false, reason: "non-json" };
|
|
587
|
-
}
|
|
588
|
-
try {
|
|
589
|
-
return { ok: true, value: JSON.parse(trimmed) };
|
|
590
|
-
} catch (error) {
|
|
591
|
-
if (error instanceof SyntaxError) {
|
|
592
|
-
return { ok: false, reason: "invalid-json", error };
|
|
593
|
-
}
|
|
594
|
-
throw error;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function buildApiError(args) {
|
|
598
|
-
const failure = args.failure;
|
|
599
|
-
const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
|
|
600
|
-
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
601
|
-
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
602
|
-
const details = runtime.redaction(
|
|
603
|
-
redactJsonDiagnosticValue(failure?.details ?? legacyError?.details)
|
|
604
|
-
);
|
|
605
|
-
const policySummary = readPolicySummaryFromDetails(details);
|
|
606
|
-
const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
|
|
607
|
-
return new LucernApiError({
|
|
608
|
-
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
609
|
-
message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
|
|
610
|
-
status: args.response.status,
|
|
611
|
-
invariant: failure?.invariant,
|
|
612
|
-
suggestion: failure?.suggestion,
|
|
613
|
-
details,
|
|
614
|
-
requestId: args.requestId,
|
|
615
|
-
correlationId,
|
|
616
|
-
policyTraceId
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
async function request(args) {
|
|
620
|
-
const authHeaders = await resolveAuthHeaders();
|
|
621
|
-
const method = args.method ?? "GET";
|
|
622
|
-
const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
|
|
623
|
-
const headers = new Headers({
|
|
624
|
-
"content-type": "application/json",
|
|
625
|
-
...authHeaders
|
|
626
|
-
});
|
|
627
|
-
if (args.idempotencyKey) {
|
|
628
|
-
headers.set("idempotency-key", args.idempotencyKey);
|
|
629
|
-
}
|
|
630
|
-
const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
|
|
631
|
-
if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
|
|
632
|
-
headers.set("x-correlation-id", requestId);
|
|
633
|
-
}
|
|
634
|
-
const url = `${baseUrl}${args.path}`;
|
|
635
|
-
const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
|
|
636
|
-
const init = {
|
|
637
|
-
method,
|
|
638
|
-
headers,
|
|
639
|
-
body: serializedBody
|
|
1
|
+
import { createGatewayRequestClient, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
|
|
2
|
+
import { createTopicsClient, } from "./topicsClient.js";
|
|
3
|
+
function normalizeBeliefConfidenceInput(input) {
|
|
4
|
+
const opinion = input.opinion;
|
|
5
|
+
return {
|
|
6
|
+
belief: opinion.b,
|
|
7
|
+
disbelief: opinion.d,
|
|
8
|
+
uncertainty: opinion.u,
|
|
9
|
+
baseRate: opinion.a,
|
|
10
|
+
trigger: input.trigger,
|
|
11
|
+
rationale: input.rationale,
|
|
12
|
+
triggeringEvidenceId: input.triggeringEvidenceId,
|
|
13
|
+
triggeringQuestionId: input.triggeringQuestionId,
|
|
14
|
+
triggeringAnswerId: input.triggeringAnswerId,
|
|
15
|
+
triggeringContradictionId: input.triggeringContradictionId,
|
|
16
|
+
triggeringWorktreeId: input.triggeringWorktreeId,
|
|
17
|
+
maxInlinePropagationTargets: input.maxInlinePropagationTargets,
|
|
640
18
|
};
|
|
641
|
-
let lastError;
|
|
642
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
643
|
-
const hookRequestContext = {
|
|
644
|
-
requestId,
|
|
645
|
-
attempt,
|
|
646
|
-
maxRetries,
|
|
647
|
-
method,
|
|
648
|
-
path: args.path,
|
|
649
|
-
url,
|
|
650
|
-
headers: new Headers(headers),
|
|
651
|
-
body: serializedBody,
|
|
652
|
-
timeoutMs
|
|
653
|
-
};
|
|
654
|
-
await config.onRequest?.(hookRequestContext);
|
|
655
|
-
const startedAt = Date.now();
|
|
656
|
-
try {
|
|
657
|
-
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
658
|
-
const responseClone = response.clone();
|
|
659
|
-
const payload = await parsePayload(response);
|
|
660
|
-
const retry = classifyRetry({
|
|
661
|
-
status: response.status,
|
|
662
|
-
retryAfter: response.headers.get("Retry-After")
|
|
663
|
-
});
|
|
664
|
-
const retryAfterMs = retry.retryAfterMs ?? null;
|
|
665
|
-
if (!response.ok || !payload?.success) {
|
|
666
|
-
const failure = payload && !payload.success ? payload : null;
|
|
667
|
-
const apiError = buildApiError({
|
|
668
|
-
requestId,
|
|
669
|
-
response,
|
|
670
|
-
failure
|
|
671
|
-
});
|
|
672
|
-
const willRetry = attempt < maxRetries && retry.retryable;
|
|
673
|
-
const responseContext2 = {
|
|
674
|
-
...hookRequestContext,
|
|
675
|
-
durationMs: Date.now() - startedAt,
|
|
676
|
-
status: response.status,
|
|
677
|
-
response: responseClone,
|
|
678
|
-
error: apiError,
|
|
679
|
-
correlationId: apiError.correlationId ?? requestId,
|
|
680
|
-
policyTraceId: apiError.policyTraceId ?? null,
|
|
681
|
-
retryAfterMs,
|
|
682
|
-
willRetry
|
|
683
|
-
};
|
|
684
|
-
await config.onResponse?.(responseContext2);
|
|
685
|
-
await emitSdkResponseTelemetry(responseContext2);
|
|
686
|
-
if (willRetry) {
|
|
687
|
-
lastError = apiError;
|
|
688
|
-
await delay(
|
|
689
|
-
computeRetryDelayMs({
|
|
690
|
-
attempt,
|
|
691
|
-
status: response.status,
|
|
692
|
-
retryAfterMs
|
|
693
|
-
})
|
|
694
|
-
);
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
throw apiError;
|
|
698
|
-
}
|
|
699
|
-
const successPayload = payload;
|
|
700
|
-
const responseContext = {
|
|
701
|
-
...hookRequestContext,
|
|
702
|
-
durationMs: Date.now() - startedAt,
|
|
703
|
-
status: response.status,
|
|
704
|
-
response: responseClone,
|
|
705
|
-
correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
|
|
706
|
-
policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
|
|
707
|
-
idempotentReplay: successPayload.idempotentReplay,
|
|
708
|
-
retryAfterMs,
|
|
709
|
-
willRetry: false
|
|
710
|
-
};
|
|
711
|
-
await config.onResponse?.(responseContext);
|
|
712
|
-
await emitSdkResponseTelemetry(responseContext);
|
|
713
|
-
return successPayload;
|
|
714
|
-
} catch (fetchError) {
|
|
715
|
-
if (fetchError instanceof LucernApiError) {
|
|
716
|
-
throw fetchError;
|
|
717
|
-
}
|
|
718
|
-
const willRetry = attempt < maxRetries && classifyGatewayErrorForRetry(fetchError);
|
|
719
|
-
const responseContext = {
|
|
720
|
-
...hookRequestContext,
|
|
721
|
-
durationMs: Date.now() - startedAt,
|
|
722
|
-
error: fetchError,
|
|
723
|
-
correlationId: requestId,
|
|
724
|
-
policyTraceId: null,
|
|
725
|
-
willRetry
|
|
726
|
-
};
|
|
727
|
-
await config.onResponse?.(responseContext);
|
|
728
|
-
await emitSdkResponseTelemetry(responseContext);
|
|
729
|
-
lastError = fetchError;
|
|
730
|
-
if (willRetry) {
|
|
731
|
-
await delay(computeRetryDelayMs({ attempt }));
|
|
732
|
-
}
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
|
|
736
|
-
}
|
|
737
|
-
return {
|
|
738
|
-
request
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
// src/sdkSurface.ts
|
|
743
|
-
function isRecord2(value) {
|
|
744
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
745
|
-
}
|
|
746
|
-
function asRecord(value) {
|
|
747
|
-
return isRecord2(value) ? value : {};
|
|
748
|
-
}
|
|
749
|
-
function cleanString2(value) {
|
|
750
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
751
|
-
}
|
|
752
|
-
function normalizeVerificationStatus(value) {
|
|
753
|
-
const status = cleanString2(value);
|
|
754
|
-
if (!status) {
|
|
755
|
-
return void 0;
|
|
756
|
-
}
|
|
757
|
-
if (status === "verified") {
|
|
758
|
-
return "human_verified";
|
|
759
|
-
}
|
|
760
|
-
if (status === "rejected") {
|
|
761
|
-
return "contradicted";
|
|
762
|
-
}
|
|
763
|
-
return status;
|
|
764
|
-
}
|
|
765
|
-
function cloneWith(value, patch) {
|
|
766
|
-
return { ...value, ...patch };
|
|
767
|
-
}
|
|
768
|
-
function resolveTopicId(value) {
|
|
769
|
-
return cleanString2(value.topicId);
|
|
770
|
-
}
|
|
771
|
-
function resolveText(value) {
|
|
772
|
-
return cleanString2(value.text) ?? cleanString2(value.canonicalText);
|
|
773
|
-
}
|
|
774
|
-
function withTopicAlias(value) {
|
|
775
|
-
const topicId = cleanString2(value.topicId) ?? void 0;
|
|
776
|
-
if (!topicId) {
|
|
777
|
-
return value;
|
|
778
|
-
}
|
|
779
|
-
return cloneWith(value, { topicId });
|
|
780
19
|
}
|
|
781
|
-
function
|
|
782
|
-
|
|
783
|
-
if (!text) {
|
|
784
|
-
return value;
|
|
785
|
-
}
|
|
786
|
-
return cloneWith(value, { text, canonicalText: text });
|
|
787
|
-
}
|
|
788
|
-
function withSdkAliases(value) {
|
|
789
|
-
return withTopicAlias(withTextAlias(value));
|
|
790
|
-
}
|
|
791
|
-
function normalizeNodeWriteInput(value) {
|
|
792
|
-
const topicId = resolveTopicId(value);
|
|
793
|
-
const text = resolveText(value);
|
|
794
|
-
const verificationStatus = normalizeVerificationStatus(value.verificationStatus);
|
|
795
|
-
const next = { ...value };
|
|
796
|
-
if (topicId) {
|
|
797
|
-
next.topicId = topicId;
|
|
798
|
-
}
|
|
799
|
-
if (text) {
|
|
800
|
-
next.text = text;
|
|
801
|
-
next.canonicalText = text;
|
|
802
|
-
}
|
|
803
|
-
if (verificationStatus) {
|
|
804
|
-
next.verificationStatus = verificationStatus;
|
|
805
|
-
}
|
|
806
|
-
return next;
|
|
807
|
-
}
|
|
808
|
-
var normalizeNodeVerificationStatus = normalizeVerificationStatus;
|
|
809
|
-
function normalizeTopicQuery(value) {
|
|
810
|
-
const topicId = cleanString2(value.topicId);
|
|
811
|
-
if (!topicId) {
|
|
812
|
-
return value;
|
|
813
|
-
}
|
|
814
|
-
return { ...value, topicId };
|
|
815
|
-
}
|
|
816
|
-
function asListItems(data, legacyKey) {
|
|
817
|
-
if (Array.isArray(data)) {
|
|
818
|
-
return data;
|
|
819
|
-
}
|
|
820
|
-
const record = asRecord(data);
|
|
821
|
-
if (Array.isArray(record.items)) {
|
|
822
|
-
return record.items;
|
|
823
|
-
}
|
|
824
|
-
if (legacyKey && Array.isArray(record[legacyKey])) {
|
|
825
|
-
return record[legacyKey];
|
|
826
|
-
}
|
|
827
|
-
return [];
|
|
20
|
+
function serializeTypes(types) {
|
|
21
|
+
return Array.isArray(types) && types.length > 0 ? types.join(",") : undefined;
|
|
828
22
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
total: items.length
|
|
833
|
-
};
|
|
834
|
-
if (legacyKey) {
|
|
23
|
+
export { createBeliefsFacade, createContradictionsFacade, createEdgesFacade, createEvidenceFacade, createEventsFacade, createGraphFacade, createIdentityFacade, createOntologiesFacade, createQuestionsFacade } from "./gatewayFacades.factories.js";
|
|
24
|
+
export function createSearchFacade(config = {}) {
|
|
25
|
+
const gateway = createGatewayRequestClient(config);
|
|
835
26
|
return {
|
|
836
|
-
|
|
837
|
-
|
|
27
|
+
async query(input) {
|
|
28
|
+
return gateway.request({
|
|
29
|
+
path: "/api/platform/v1/search",
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: input,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
838
34
|
};
|
|
839
|
-
}
|
|
840
|
-
return result;
|
|
841
|
-
}
|
|
842
|
-
function mapGatewayData(response, mapper) {
|
|
843
|
-
return {
|
|
844
|
-
...response,
|
|
845
|
-
data: mapper(response.data)
|
|
846
|
-
};
|
|
847
35
|
}
|
|
848
|
-
function
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
}
|
|
859
|
-
function normalizeTopicRecord(value) {
|
|
860
|
-
const record = asRecord(value);
|
|
861
|
-
const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
|
|
862
|
-
return withTopicAlias({
|
|
863
|
-
...record,
|
|
864
|
-
...topicId ? { topicId } : {}
|
|
865
|
-
});
|
|
866
|
-
}
|
|
867
|
-
function normalizeTopicTreeNode(value) {
|
|
868
|
-
return normalizeTopicRecord(value);
|
|
869
|
-
}
|
|
870
|
-
function createTopicsClient(config = {}) {
|
|
871
|
-
const gateway = createGatewayRequestClient(config);
|
|
872
|
-
return {
|
|
873
|
-
async list(query = {}) {
|
|
874
|
-
const topicId = resolveTopicId(query);
|
|
875
|
-
return gateway.request({
|
|
876
|
-
path: `/api/platform/v1/topics${toQueryString({
|
|
877
|
-
...topicId ? { topicId } : {},
|
|
878
|
-
ontologyId: query.ontologyId,
|
|
879
|
-
parentTopicId: query.parentTopicId,
|
|
880
|
-
status: query.status,
|
|
881
|
-
type: query.type
|
|
882
|
-
})}`
|
|
883
|
-
}).then(
|
|
884
|
-
(response) => mapGatewayData(response, (data) => {
|
|
885
|
-
const record = asRecord(data);
|
|
886
|
-
const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
|
|
887
|
-
return {
|
|
888
|
-
...createListResult(items, "topics"),
|
|
889
|
-
...record,
|
|
890
|
-
topics: items,
|
|
891
|
-
total: typeof record.total === "number" ? record.total : items.length
|
|
892
|
-
};
|
|
893
|
-
})
|
|
894
|
-
);
|
|
895
|
-
},
|
|
896
|
-
async get(topicId) {
|
|
897
|
-
return gateway.request({
|
|
898
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}`
|
|
899
|
-
}).then(
|
|
900
|
-
(response) => mapGatewayData(
|
|
901
|
-
response,
|
|
902
|
-
(data) => normalizeTopicRecord(asRecord(data).topic ?? data)
|
|
903
|
-
)
|
|
904
|
-
);
|
|
905
|
-
},
|
|
906
|
-
async create(input, idempotencyKey) {
|
|
907
|
-
const topicId = resolveTopicId(input);
|
|
908
|
-
return gateway.request({
|
|
909
|
-
path: "/api/platform/v1/topics",
|
|
910
|
-
method: "POST",
|
|
911
|
-
body: {
|
|
912
|
-
...input,
|
|
913
|
-
...topicId ? { topicId } : {},
|
|
914
|
-
type: input.type ?? "theme"
|
|
36
|
+
export function createTasksFacade(config = {}) {
|
|
37
|
+
const gateway = createGatewayRequestClient(config);
|
|
38
|
+
return {
|
|
39
|
+
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
40
|
+
return gateway.request({
|
|
41
|
+
path: "/api/platform/v1/tasks",
|
|
42
|
+
method: "POST",
|
|
43
|
+
body: input,
|
|
44
|
+
idempotencyKey,
|
|
45
|
+
});
|
|
915
46
|
},
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
query
|
|
935
|
-
)}`
|
|
936
|
-
}).then(
|
|
937
|
-
(response) => mapGatewayData(response, (data) => {
|
|
938
|
-
const record = asRecord(data);
|
|
939
|
-
return {
|
|
940
|
-
tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
|
|
941
|
-
};
|
|
942
|
-
})
|
|
943
|
-
);
|
|
944
|
-
},
|
|
945
|
-
async getCoverage(topicId, query = {}) {
|
|
946
|
-
return gateway.request({
|
|
947
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(
|
|
948
|
-
query
|
|
949
|
-
)}`
|
|
950
|
-
});
|
|
951
|
-
},
|
|
952
|
-
async remove(topicId, idempotencyKey) {
|
|
953
|
-
return gateway.request({
|
|
954
|
-
path: "/api/platform/v1/topics/remove",
|
|
955
|
-
method: "POST",
|
|
956
|
-
body: { id: topicId },
|
|
957
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
958
|
-
});
|
|
959
|
-
},
|
|
960
|
-
async bulkCreate(input, idempotencyKey) {
|
|
961
|
-
return gateway.request({
|
|
962
|
-
path: "/api/platform/v1/topics/bulk",
|
|
963
|
-
method: "POST",
|
|
964
|
-
body: input,
|
|
965
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
966
|
-
});
|
|
967
|
-
}
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
// src/graphClient.ts
|
|
972
|
-
function createGraphClient(config = {}) {
|
|
973
|
-
const gateway = createGatewayRequestClient(config);
|
|
974
|
-
const client = {
|
|
975
|
-
/**
|
|
976
|
-
* List graph nodes matching the provided filters.
|
|
977
|
-
*/
|
|
978
|
-
async listNodes(query) {
|
|
979
|
-
return gateway.request({
|
|
980
|
-
path: `/api/platform/v1/graph/nodes${toQueryString(
|
|
981
|
-
normalizeTopicQuery(query)
|
|
982
|
-
)}`
|
|
983
|
-
}).then(
|
|
984
|
-
(response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
|
|
985
|
-
);
|
|
986
|
-
},
|
|
987
|
-
/**
|
|
988
|
-
* Retrieve a single graph node by nodeId or globalId.
|
|
989
|
-
*/
|
|
990
|
-
async getNode(query) {
|
|
991
|
-
return gateway.request({
|
|
992
|
-
path: `/api/platform/v1/graph/nodes${toQueryString(query)}`
|
|
993
|
-
}).then(
|
|
994
|
-
(response) => mapGatewayData(
|
|
995
|
-
response,
|
|
996
|
-
(data) => withSdkAliases(data)
|
|
997
|
-
)
|
|
998
|
-
);
|
|
999
|
-
},
|
|
1000
|
-
/**
|
|
1001
|
-
* Create a graph node.
|
|
1002
|
-
*/
|
|
1003
|
-
async createNode(input, idempotencyKey) {
|
|
1004
|
-
return gateway.request({
|
|
1005
|
-
path: "/api/platform/v1/graph/nodes",
|
|
1006
|
-
method: "POST",
|
|
1007
|
-
body: normalizeNodeWriteInput(input),
|
|
1008
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1009
|
-
}).then(
|
|
1010
|
-
(response) => mapGatewayData(
|
|
1011
|
-
response,
|
|
1012
|
-
(data) => withSdkAliases(data)
|
|
1013
|
-
)
|
|
1014
|
-
);
|
|
1015
|
-
},
|
|
1016
|
-
/**
|
|
1017
|
-
* Update a graph node.
|
|
1018
|
-
*/
|
|
1019
|
-
async updateNode(input, idempotencyKey) {
|
|
1020
|
-
return gateway.request({
|
|
1021
|
-
path: "/api/platform/v1/graph/nodes",
|
|
1022
|
-
method: "PUT",
|
|
1023
|
-
body: normalizeNodeWriteInput(input),
|
|
1024
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1025
|
-
}).then(
|
|
1026
|
-
(response) => mapGatewayData(
|
|
1027
|
-
response,
|
|
1028
|
-
(data) => withSdkAliases(data)
|
|
1029
|
-
)
|
|
1030
|
-
);
|
|
1031
|
-
},
|
|
1032
|
-
/**
|
|
1033
|
-
* Batch create graph nodes through the admin route surface.
|
|
1034
|
-
*/
|
|
1035
|
-
async batchCreateNodes(input, idempotencyKey) {
|
|
1036
|
-
return gateway.request({
|
|
1037
|
-
path: "/api/platform/v1/graph/nodes/batch",
|
|
1038
|
-
method: "POST",
|
|
1039
|
-
body: {
|
|
1040
|
-
nodes: input.nodes.map((node) => normalizeNodeWriteInput(node))
|
|
47
|
+
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
48
|
+
return gateway.request({
|
|
49
|
+
path: `/api/platform/v1/tasks/${encodeURIComponent(input.id)}`,
|
|
50
|
+
method: "PATCH",
|
|
51
|
+
body: {
|
|
52
|
+
title: input.title,
|
|
53
|
+
description: input.description,
|
|
54
|
+
priority: input.priority,
|
|
55
|
+
status: input.status,
|
|
56
|
+
assigneeId: input.assigneeId,
|
|
57
|
+
blockedReason: input.blockedReason,
|
|
58
|
+
linkedBeliefId: input.linkedBeliefId,
|
|
59
|
+
linkedQuestionId: input.linkedQuestionId,
|
|
60
|
+
linkedWorktreeId: input.linkedWorktreeId,
|
|
61
|
+
metadata: input.metadata,
|
|
62
|
+
},
|
|
63
|
+
idempotencyKey,
|
|
64
|
+
});
|
|
1041
65
|
},
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
method: "POST",
|
|
1052
|
-
body: input,
|
|
1053
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1054
|
-
});
|
|
1055
|
-
},
|
|
1056
|
-
/**
|
|
1057
|
-
* Update a node's verification status.
|
|
1058
|
-
*/
|
|
1059
|
-
async verifyNode(input, idempotencyKey) {
|
|
1060
|
-
const verificationStatus = normalizeNodeVerificationStatus(input.verificationStatus) ?? input.verificationStatus;
|
|
1061
|
-
return gateway.request({
|
|
1062
|
-
path: "/api/platform/v1/graph/nodes/verify",
|
|
1063
|
-
method: "POST",
|
|
1064
|
-
body: {
|
|
1065
|
-
...input,
|
|
1066
|
-
verificationStatus
|
|
66
|
+
async complete(input, idempotencyKey = randomIdempotencyKey()) {
|
|
67
|
+
return gateway.request({
|
|
68
|
+
path: `/api/platform/v1/tasks/${encodeURIComponent(input.id)}/complete`,
|
|
69
|
+
method: "POST",
|
|
70
|
+
body: {
|
|
71
|
+
outputSummary: input.outputSummary,
|
|
72
|
+
},
|
|
73
|
+
idempotencyKey,
|
|
74
|
+
});
|
|
1067
75
|
},
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
method: "POST",
|
|
1078
|
-
body: input,
|
|
1079
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1080
|
-
});
|
|
1081
|
-
},
|
|
1082
|
-
/**
|
|
1083
|
-
* List graph edges matching the provided filters.
|
|
1084
|
-
*/
|
|
1085
|
-
async listEdges(query) {
|
|
1086
|
-
return gateway.request({
|
|
1087
|
-
path: `/api/platform/v1/graph/edges${toQueryString(
|
|
1088
|
-
normalizeTopicQuery(query)
|
|
1089
|
-
)}`
|
|
1090
|
-
}).then(
|
|
1091
|
-
(response) => mapGatewayData(
|
|
1092
|
-
response,
|
|
1093
|
-
(data) => mapAliasedList(data, "edges")
|
|
1094
|
-
)
|
|
1095
|
-
);
|
|
1096
|
-
},
|
|
1097
|
-
/**
|
|
1098
|
-
* Create a graph edge.
|
|
1099
|
-
*/
|
|
1100
|
-
async createEdge(input, idempotencyKey) {
|
|
1101
|
-
return gateway.request({
|
|
1102
|
-
path: "/api/platform/v1/graph/edges",
|
|
1103
|
-
method: "POST",
|
|
1104
|
-
body: normalizeTopicQuery(input),
|
|
1105
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1106
|
-
});
|
|
1107
|
-
},
|
|
1108
|
-
/**
|
|
1109
|
-
* Delete one or more edges matching the provided filter.
|
|
1110
|
-
*/
|
|
1111
|
-
async deleteEdge(query, idempotencyKey) {
|
|
1112
|
-
return gateway.request({
|
|
1113
|
-
path: `/api/platform/v1/graph/edges${toQueryString(query)}`,
|
|
1114
|
-
method: "DELETE",
|
|
1115
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1116
|
-
});
|
|
1117
|
-
},
|
|
1118
|
-
/**
|
|
1119
|
-
* Retrieve a graph neighborhood around a root node.
|
|
1120
|
-
*/
|
|
1121
|
-
async neighborhood(query) {
|
|
1122
|
-
return gateway.request({
|
|
1123
|
-
path: `/api/platform/v1/graph/neighborhood${toQueryString(query)}`
|
|
1124
|
-
});
|
|
1125
|
-
},
|
|
1126
|
-
/**
|
|
1127
|
-
* Traverse the graph from a starting node.
|
|
1128
|
-
*/
|
|
1129
|
-
async traverse(query) {
|
|
1130
|
-
return gateway.request({
|
|
1131
|
-
path: "/api/platform/v1/graph/traverse",
|
|
1132
|
-
method: "POST",
|
|
1133
|
-
body: normalizeTopicQuery(query)
|
|
1134
|
-
});
|
|
1135
|
-
},
|
|
1136
|
-
/**
|
|
1137
|
-
* Analyze graph structure for a topic.
|
|
1138
|
-
*/
|
|
1139
|
-
async analyze(query = {}) {
|
|
1140
|
-
const normalized = normalizeTopicQuery(query);
|
|
1141
|
-
return gateway.request({
|
|
1142
|
-
path: `/api/platform/v1/graph/analyze${toQueryString({
|
|
1143
|
-
topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
|
|
1144
|
-
metric: typeof normalized.metric === "string" ? normalized.metric : void 0,
|
|
1145
|
-
limit: typeof normalized.limit === "number" ? normalized.limit : void 0
|
|
1146
|
-
})}`
|
|
1147
|
-
});
|
|
1148
|
-
},
|
|
1149
|
-
/**
|
|
1150
|
-
* Detect confirmation-bias patterns for a topic graph.
|
|
1151
|
-
*/
|
|
1152
|
-
async bias(query = {}) {
|
|
1153
|
-
const normalized = normalizeTopicQuery(query);
|
|
1154
|
-
return gateway.request({
|
|
1155
|
-
path: `/api/platform/v1/graph/bias${toQueryString({
|
|
1156
|
-
topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
|
|
1157
|
-
threshold: typeof normalized.threshold === "number" ? normalized.threshold : void 0,
|
|
1158
|
-
limit: typeof normalized.limit === "number" ? normalized.limit : void 0
|
|
1159
|
-
})}`
|
|
1160
|
-
});
|
|
1161
|
-
},
|
|
1162
|
-
/**
|
|
1163
|
-
* Find graph gaps for beliefs that still need testing.
|
|
1164
|
-
*/
|
|
1165
|
-
async gaps(query) {
|
|
1166
|
-
const normalized = normalizeTopicQuery(query);
|
|
1167
|
-
return gateway.request({
|
|
1168
|
-
path: `/api/platform/v1/graph/gaps${toQueryString({
|
|
1169
|
-
topicId: typeof normalized.topicId === "string" ? normalized.topicId : void 0,
|
|
1170
|
-
minConfidence: typeof normalized.minConfidence === "number" ? normalized.minConfidence : void 0
|
|
1171
|
-
})}`
|
|
1172
|
-
});
|
|
1173
|
-
},
|
|
1174
|
-
/**
|
|
1175
|
-
* Search across graph resources within a topic.
|
|
1176
|
-
*/
|
|
1177
|
-
async search(query) {
|
|
1178
|
-
return gateway.request({
|
|
1179
|
-
path: "/api/platform/v1/search",
|
|
1180
|
-
method: "POST",
|
|
1181
|
-
body: normalizeTopicQuery(query)
|
|
1182
|
-
});
|
|
1183
|
-
},
|
|
1184
|
-
/**
|
|
1185
|
-
* Retrieve the shortest known path between two graph nodes.
|
|
1186
|
-
*/
|
|
1187
|
-
async getPath(query) {
|
|
1188
|
-
return gateway.request({
|
|
1189
|
-
path: `/api/platform/v1/graph/path${toQueryString(query)}`
|
|
1190
|
-
});
|
|
1191
|
-
},
|
|
1192
|
-
/**
|
|
1193
|
-
* Retrieve graph analytics for the requested metric.
|
|
1194
|
-
*/
|
|
1195
|
-
async getAnalytics(query = {}) {
|
|
1196
|
-
return gateway.request({
|
|
1197
|
-
path: `/api/platform/v1/graph/analytics${toQueryString(query)}`
|
|
1198
|
-
});
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
return Object.assign(client, {
|
|
1202
|
-
queryNodes: client.listNodes,
|
|
1203
|
-
queryEdges: client.listEdges,
|
|
1204
|
-
getNeighborhood: client.neighborhood
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
// src/boundaryClientSurface.ts
|
|
1209
|
-
function cleanOptionalString(value) {
|
|
1210
|
-
const normalized = value?.trim();
|
|
1211
|
-
return normalized ? normalized : void 0;
|
|
1212
|
-
}
|
|
1213
|
-
function isRecord3(value) {
|
|
1214
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1215
|
-
}
|
|
1216
|
-
function cleanRequiredString(value, label) {
|
|
1217
|
-
const normalized = cleanOptionalString(value);
|
|
1218
|
-
if (!normalized) {
|
|
1219
|
-
throw new Error(`${label} is required`);
|
|
1220
|
-
}
|
|
1221
|
-
return normalized;
|
|
1222
|
-
}
|
|
1223
|
-
function assertKnownKeys(input, allowed, operation) {
|
|
1224
|
-
const allowedSet = new Set(allowed);
|
|
1225
|
-
const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
|
|
1226
|
-
if (unknownKeys.length > 0) {
|
|
1227
|
-
throw new Error(
|
|
1228
|
-
`${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
|
|
1229
|
-
);
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
function knownPayload(input, allowed, operation) {
|
|
1233
|
-
assertKnownKeys(input, allowed, operation);
|
|
1234
|
-
return { ...input };
|
|
1235
|
-
}
|
|
1236
|
-
function listResultFromEnvelope(data, legacyKey) {
|
|
1237
|
-
const record = isRecord3(data) ? data : {};
|
|
1238
|
-
const legacyItems = record[legacyKey];
|
|
1239
|
-
return createListResult(
|
|
1240
|
-
Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
|
|
1241
|
-
legacyKey
|
|
1242
|
-
);
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
// src/control-plane.ts
|
|
1246
|
-
var LucernControlPlaneIdentityError = class extends Error {
|
|
1247
|
-
reason;
|
|
1248
|
-
principalStatus;
|
|
1249
|
-
tenantStatus;
|
|
1250
|
-
workspaceStatus;
|
|
1251
|
-
details;
|
|
1252
|
-
constructor(failure) {
|
|
1253
|
-
super(failure.message);
|
|
1254
|
-
this.name = "LucernControlPlaneIdentityError";
|
|
1255
|
-
this.reason = failure.reason;
|
|
1256
|
-
this.principalStatus = failure.principalStatus;
|
|
1257
|
-
this.tenantStatus = failure.tenantStatus;
|
|
1258
|
-
this.workspaceStatus = failure.workspaceStatus;
|
|
1259
|
-
this.details = failure.details;
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
function cleanString4(value) {
|
|
1263
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
1264
|
-
}
|
|
1265
|
-
function stringList(value) {
|
|
1266
|
-
if (!Array.isArray(value)) {
|
|
1267
|
-
return [];
|
|
1268
|
-
}
|
|
1269
|
-
return [
|
|
1270
|
-
...new Set(
|
|
1271
|
-
value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean)
|
|
1272
|
-
)
|
|
1273
|
-
];
|
|
1274
|
-
}
|
|
1275
|
-
function principalType(value) {
|
|
1276
|
-
switch (value) {
|
|
1277
|
-
case "service":
|
|
1278
|
-
case "service_principal":
|
|
1279
|
-
return "service";
|
|
1280
|
-
case "agent":
|
|
1281
|
-
return "agent";
|
|
1282
|
-
case "group":
|
|
1283
|
-
return "group";
|
|
1284
|
-
case "external_viewer":
|
|
1285
|
-
case "external_stakeholder":
|
|
1286
|
-
return "external_viewer";
|
|
1287
|
-
default:
|
|
1288
|
-
return "human";
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
function adminFlags(roles) {
|
|
1292
|
-
const normalized = roles.map((role) => role.toLowerCase());
|
|
1293
|
-
const isPlatformAdmin = normalized.includes("platform_admin");
|
|
1294
|
-
const isTenantAdmin = isPlatformAdmin || normalized.includes("tenant_admin");
|
|
1295
|
-
const isWorkspaceAdmin = isTenantAdmin || normalized.includes("workspace_admin") || normalized.includes("workspace_owner");
|
|
1296
|
-
return { isPlatformAdmin, isTenantAdmin, isWorkspaceAdmin };
|
|
1297
|
-
}
|
|
1298
|
-
function normalizeResolvedInteractivePrincipal(payload) {
|
|
1299
|
-
if ("ok" in payload && payload.ok === false) {
|
|
1300
|
-
throw new LucernControlPlaneIdentityError(payload);
|
|
1301
|
-
}
|
|
1302
|
-
const principalId = cleanString4(payload.principalId);
|
|
1303
|
-
const clerkId = cleanString4(payload.clerkId);
|
|
1304
|
-
const tenantId = cleanString4(payload.tenantId);
|
|
1305
|
-
if (!principalId || !clerkId || !tenantId) {
|
|
1306
|
-
throw new LucernControlPlaneIdentityError({
|
|
1307
|
-
ok: false,
|
|
1308
|
-
reason: "resolver_unavailable",
|
|
1309
|
-
message: "Control-plane principal resolver returned an incomplete principal context.",
|
|
1310
|
-
principalStatus: payload.principalStatus ?? "missing",
|
|
1311
|
-
tenantStatus: payload.tenantStatus,
|
|
1312
|
-
workspaceStatus: payload.workspaceStatus
|
|
1313
|
-
});
|
|
1314
|
-
}
|
|
1315
|
-
const roles = stringList(payload.roles);
|
|
1316
|
-
const scopes = stringList(payload.scopes);
|
|
1317
|
-
const workspaceId = cleanString4(payload.workspaceId) ?? null;
|
|
1318
|
-
const flags = adminFlags(roles);
|
|
1319
|
-
return {
|
|
1320
|
-
principalId,
|
|
1321
|
-
principalType: principalType(payload.principalType),
|
|
1322
|
-
clerkId,
|
|
1323
|
-
tenantId,
|
|
1324
|
-
workspaceId,
|
|
1325
|
-
roles,
|
|
1326
|
-
scopes,
|
|
1327
|
-
groupIds: stringList(payload.groupIds),
|
|
1328
|
-
permittedToolNames: stringList(payload.permittedToolNames),
|
|
1329
|
-
permittedPackKeys: stringList(payload.permittedPackKeys),
|
|
1330
|
-
principalStatus: cleanString4(payload.principalStatus) ?? "active",
|
|
1331
|
-
tenantStatus: cleanString4(payload.tenantStatus) ?? "active",
|
|
1332
|
-
workspaceStatus: cleanString4(payload.workspaceStatus) ?? (workspaceId ? "active" : "none"),
|
|
1333
|
-
isPlatformAdmin: typeof payload.isPlatformAdmin === "boolean" ? payload.isPlatformAdmin : flags.isPlatformAdmin,
|
|
1334
|
-
isTenantAdmin: typeof payload.isTenantAdmin === "boolean" ? payload.isTenantAdmin : flags.isTenantAdmin,
|
|
1335
|
-
isWorkspaceAdmin: typeof payload.isWorkspaceAdmin === "boolean" ? payload.isWorkspaceAdmin : flags.isWorkspaceAdmin,
|
|
1336
|
-
permit: {
|
|
1337
|
-
subject: cleanString4(payload.permit?.subject) ?? principalId,
|
|
1338
|
-
tenant: cleanString4(payload.permit?.tenant) ?? tenantId,
|
|
1339
|
-
...workspaceId ? { workspace: cleanString4(payload.permit?.workspace) ?? workspaceId } : {}
|
|
1340
|
-
},
|
|
1341
|
-
authMode: "interactive_user",
|
|
1342
|
-
sessionId: payload.sessionId,
|
|
1343
|
-
delegatedBy: payload.delegatedBy,
|
|
1344
|
-
expiresAt: payload.expiresAt
|
|
1345
|
-
};
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
// src/identityClient.ts
|
|
1349
|
-
function createIdentityWhoamiClient(config = {}) {
|
|
1350
|
-
const gateway = createGatewayRequestClient(config);
|
|
1351
|
-
return {
|
|
1352
|
-
async whoami() {
|
|
1353
|
-
return gateway.request({
|
|
1354
|
-
path: "/api/platform/v1/identity/whoami"
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
};
|
|
1358
|
-
}
|
|
1359
|
-
var TENANT_IDENTITY_FIELDS = [
|
|
1360
|
-
"tenantId",
|
|
1361
|
-
"workspaceId",
|
|
1362
|
-
"principalId",
|
|
1363
|
-
"integrationKey",
|
|
1364
|
-
"secretRef",
|
|
1365
|
-
"policySubject",
|
|
1366
|
-
"policyAction",
|
|
1367
|
-
"policyResource",
|
|
1368
|
-
"decision",
|
|
1369
|
-
"config",
|
|
1370
|
-
"configKey",
|
|
1371
|
-
"configValue",
|
|
1372
|
-
"provider",
|
|
1373
|
-
"status",
|
|
1374
|
-
"metadata",
|
|
1375
|
-
"limit",
|
|
1376
|
-
"cursor"
|
|
1377
|
-
];
|
|
1378
|
-
function tenantIdentityQuery(input) {
|
|
1379
|
-
return {
|
|
1380
|
-
tenantId: cleanRequiredString(input.tenantId, "tenantId"),
|
|
1381
|
-
workspaceId: input.workspaceId,
|
|
1382
|
-
principalId: input.principalId,
|
|
1383
|
-
limit: input.limit,
|
|
1384
|
-
cursor: input.cursor
|
|
1385
|
-
};
|
|
1386
|
-
}
|
|
1387
|
-
function tenantIdentityBody(input, operation) {
|
|
1388
|
-
return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
|
|
1389
|
-
}
|
|
1390
|
-
function createIdentityClient(config = {}) {
|
|
1391
|
-
const gateway = createGatewayRequestClient(config);
|
|
1392
|
-
const whoamiClient = createIdentityWhoamiClient(config);
|
|
1393
|
-
const requestPrincipalWrite = (method, input, idempotencyKey) => gateway.request({
|
|
1394
|
-
path: "/api/platform/v1/identity/principals",
|
|
1395
|
-
method,
|
|
1396
|
-
body: input,
|
|
1397
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1398
|
-
});
|
|
1399
|
-
const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
|
|
1400
|
-
const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
|
|
1401
|
-
path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
|
|
1402
|
-
method: "POST",
|
|
1403
|
-
body: input,
|
|
1404
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1405
|
-
});
|
|
1406
|
-
return {
|
|
1407
|
-
/**
|
|
1408
|
-
* Resolve the current authenticated identity summary.
|
|
1409
|
-
*/
|
|
1410
|
-
async whoami() {
|
|
1411
|
-
return whoamiClient.whoami().then(
|
|
1412
|
-
(response) => mapGatewayData(response, (data) => ({
|
|
1413
|
-
principalId: data.principalId,
|
|
1414
|
-
principalType: data.principalType,
|
|
1415
|
-
clerkId: data.clerkId,
|
|
1416
|
-
tenantId: data.tenantId ?? null,
|
|
1417
|
-
workspaceId: data.workspaceId ?? null,
|
|
1418
|
-
scopes: Array.isArray(data.scopes) ? data.scopes : [],
|
|
1419
|
-
roles: Array.isArray(data.roles) ? data.roles : [],
|
|
1420
|
-
groupIds: Array.isArray(data.groupIds) ? data.groupIds : [],
|
|
1421
|
-
permittedToolNames: Array.isArray(data.permittedToolNames) ? data.permittedToolNames : [],
|
|
1422
|
-
permittedPackKeys: Array.isArray(data.permittedPackKeys) ? data.permittedPackKeys : [],
|
|
1423
|
-
principalStatus: data.principalStatus,
|
|
1424
|
-
tenantStatus: data.tenantStatus,
|
|
1425
|
-
workspaceStatus: data.workspaceStatus,
|
|
1426
|
-
isPlatformAdmin: data.isPlatformAdmin === true,
|
|
1427
|
-
isTenantAdmin: data.isTenantAdmin === true,
|
|
1428
|
-
isWorkspaceAdmin: data.isWorkspaceAdmin === true,
|
|
1429
|
-
permit: data.permit ?? (data.tenantId ? {
|
|
1430
|
-
subject: data.principalId,
|
|
1431
|
-
tenant: data.tenantId,
|
|
1432
|
-
...data.workspaceId ? { workspace: data.workspaceId } : {}
|
|
1433
|
-
} : void 0),
|
|
1434
|
-
authMode: data.authMode,
|
|
1435
|
-
sessionId: data.sessionId,
|
|
1436
|
-
delegatedBy: data.delegatedBy,
|
|
1437
|
-
expiresAt: data.expiresAt
|
|
1438
|
-
}))
|
|
1439
|
-
);
|
|
1440
|
-
},
|
|
1441
|
-
/**
|
|
1442
|
-
* Resolve a Clerk subject through the tenant control-plane Permit projection.
|
|
1443
|
-
* @deprecated Prefer lucern.controlPlane.identity.resolveInteractivePrincipal().
|
|
1444
|
-
*/
|
|
1445
|
-
async resolveInteractivePrincipal(input) {
|
|
1446
|
-
return gateway.request({
|
|
1447
|
-
path: "/api/platform/v1/control-plane/identity/resolve-interactive-principal",
|
|
1448
|
-
method: "POST",
|
|
1449
|
-
body: input
|
|
1450
|
-
}).then(
|
|
1451
|
-
(response) => mapGatewayData(response, normalizeResolvedInteractivePrincipal)
|
|
1452
|
-
);
|
|
1453
|
-
},
|
|
1454
|
-
/**
|
|
1455
|
-
* List principals in the current identity scope.
|
|
1456
|
-
*/
|
|
1457
|
-
async listPrincipals(query = {}) {
|
|
1458
|
-
return gateway.request({
|
|
1459
|
-
path: `/api/platform/v1/identity/principals${toQueryString(query)}`
|
|
1460
|
-
}).then(
|
|
1461
|
-
(response) => mapGatewayData(
|
|
1462
|
-
response,
|
|
1463
|
-
(data) => createListResult(
|
|
1464
|
-
Array.isArray(data) ? data : [],
|
|
1465
|
-
"principals"
|
|
1466
|
-
)
|
|
1467
|
-
)
|
|
1468
|
-
);
|
|
1469
|
-
},
|
|
1470
|
-
/**
|
|
1471
|
-
* Create a principal.
|
|
1472
|
-
*/
|
|
1473
|
-
async createPrincipal(input, idempotencyKey) {
|
|
1474
|
-
return requestPrincipalWrite("POST", input, idempotencyKey);
|
|
1475
|
-
},
|
|
1476
|
-
/**
|
|
1477
|
-
* Update a principal.
|
|
1478
|
-
*/
|
|
1479
|
-
updatePrincipal,
|
|
1480
|
-
/**
|
|
1481
|
-
* @deprecated Use createPrincipal or updatePrincipal.
|
|
1482
|
-
*/
|
|
1483
|
-
upsertPrincipal: updatePrincipal,
|
|
1484
|
-
/**
|
|
1485
|
-
* List keys in the current identity scope.
|
|
1486
|
-
*/
|
|
1487
|
-
async listKeys(query = {}) {
|
|
1488
|
-
return gateway.request({
|
|
1489
|
-
path: `/api/platform/v1/identity/keys${toQueryString(query)}`
|
|
1490
|
-
}).then(
|
|
1491
|
-
(response) => mapGatewayData(
|
|
1492
|
-
response,
|
|
1493
|
-
(data) => createListResult(Array.isArray(data) ? data : [], "keys")
|
|
1494
|
-
)
|
|
1495
|
-
);
|
|
1496
|
-
},
|
|
1497
|
-
/**
|
|
1498
|
-
* Create an API key.
|
|
1499
|
-
*/
|
|
1500
|
-
async createKey(input, idempotencyKey) {
|
|
1501
|
-
return gateway.request({
|
|
1502
|
-
path: "/api/platform/v1/identity/keys",
|
|
1503
|
-
method: "POST",
|
|
1504
|
-
body: input,
|
|
1505
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1506
|
-
});
|
|
1507
|
-
},
|
|
1508
|
-
/**
|
|
1509
|
-
* Rotate an API key.
|
|
1510
|
-
*/
|
|
1511
|
-
async rotateKey(keyId, input = {}, idempotencyKey) {
|
|
1512
|
-
return gateway.request({
|
|
1513
|
-
path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/rotate`,
|
|
1514
|
-
method: "POST",
|
|
1515
|
-
body: input,
|
|
1516
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1517
|
-
});
|
|
1518
|
-
},
|
|
1519
|
-
/**
|
|
1520
|
-
* Delete an API key by revoking it.
|
|
1521
|
-
*/
|
|
1522
|
-
deleteKey,
|
|
1523
|
-
/**
|
|
1524
|
-
* @deprecated Use deleteKey.
|
|
1525
|
-
*/
|
|
1526
|
-
revokeKey: deleteKey,
|
|
1527
|
-
/**
|
|
1528
|
-
* Search Clerk users by email or display attributes.
|
|
1529
|
-
*/
|
|
1530
|
-
async searchClerkUsers(q) {
|
|
1531
|
-
return gateway.request({
|
|
1532
|
-
path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
|
|
1533
|
-
});
|
|
1534
|
-
},
|
|
1535
|
-
async getTenantConfig(input) {
|
|
1536
|
-
return gateway.request({
|
|
1537
|
-
path: `/api/platform/v1/identity/tenant-config${toQueryString(
|
|
1538
|
-
tenantIdentityQuery(input)
|
|
1539
|
-
)}`
|
|
1540
|
-
});
|
|
1541
|
-
},
|
|
1542
|
-
async updateTenantConfig(input, idempotencyKey) {
|
|
1543
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
1544
|
-
return gateway.request({
|
|
1545
|
-
path: "/api/platform/v1/identity/tenant-config",
|
|
1546
|
-
method: "PATCH",
|
|
1547
|
-
body: tenantIdentityBody(
|
|
1548
|
-
input,
|
|
1549
|
-
"identity.updateTenantConfig"
|
|
1550
|
-
),
|
|
1551
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1552
|
-
});
|
|
1553
|
-
},
|
|
1554
|
-
async listIntegrations(input) {
|
|
1555
|
-
return gateway.request({
|
|
1556
|
-
path: `/api/platform/v1/identity/integrations${toQueryString(
|
|
1557
|
-
tenantIdentityQuery(input)
|
|
1558
|
-
)}`
|
|
1559
|
-
}).then(
|
|
1560
|
-
(response) => mapGatewayData(
|
|
1561
|
-
response,
|
|
1562
|
-
(data) => listResultFromEnvelope(
|
|
1563
|
-
data,
|
|
1564
|
-
"integrations"
|
|
1565
|
-
)
|
|
1566
|
-
)
|
|
1567
|
-
);
|
|
1568
|
-
},
|
|
1569
|
-
async upsertIntegration(input, idempotencyKey) {
|
|
1570
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
1571
|
-
cleanRequiredString(input.integrationKey, "integrationKey");
|
|
1572
|
-
return gateway.request({
|
|
1573
|
-
path: "/api/platform/v1/identity/integrations",
|
|
1574
|
-
method: "PUT",
|
|
1575
|
-
body: tenantIdentityBody(
|
|
1576
|
-
input,
|
|
1577
|
-
"identity.upsertIntegration"
|
|
1578
|
-
),
|
|
1579
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1580
|
-
});
|
|
1581
|
-
},
|
|
1582
|
-
async listSecrets(input) {
|
|
1583
|
-
return gateway.request({
|
|
1584
|
-
path: `/api/platform/v1/identity/secrets${toQueryString(
|
|
1585
|
-
tenantIdentityQuery(input)
|
|
1586
|
-
)}`
|
|
1587
|
-
}).then(
|
|
1588
|
-
(response) => mapGatewayData(
|
|
1589
|
-
response,
|
|
1590
|
-
(data) => listResultFromEnvelope(
|
|
1591
|
-
data,
|
|
1592
|
-
"secrets"
|
|
1593
|
-
)
|
|
1594
|
-
)
|
|
1595
|
-
);
|
|
1596
|
-
},
|
|
1597
|
-
async putSecretReference(input, idempotencyKey) {
|
|
1598
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
1599
|
-
cleanRequiredString(input.secretRef, "secretRef");
|
|
1600
|
-
return gateway.request({
|
|
1601
|
-
path: "/api/platform/v1/identity/secrets",
|
|
1602
|
-
method: "PUT",
|
|
1603
|
-
body: tenantIdentityBody(
|
|
1604
|
-
input,
|
|
1605
|
-
"identity.putSecretReference"
|
|
1606
|
-
),
|
|
1607
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1608
|
-
});
|
|
1609
|
-
},
|
|
1610
|
-
async evaluatePolicy(input, idempotencyKey) {
|
|
1611
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
1612
|
-
cleanRequiredString(input.policySubject, "policySubject");
|
|
1613
|
-
cleanRequiredString(input.policyAction, "policyAction");
|
|
1614
|
-
cleanRequiredString(input.policyResource, "policyResource");
|
|
1615
|
-
return gateway.request({
|
|
1616
|
-
path: "/api/platform/v1/identity/policy/evaluate",
|
|
1617
|
-
method: "POST",
|
|
1618
|
-
body: tenantIdentityBody(
|
|
1619
|
-
input,
|
|
1620
|
-
"identity.evaluatePolicy"
|
|
1621
|
-
),
|
|
1622
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1623
|
-
});
|
|
1624
|
-
},
|
|
1625
|
-
async recordPolicyDecision(input, idempotencyKey) {
|
|
1626
|
-
cleanRequiredString(input.tenantId, "tenantId");
|
|
1627
|
-
cleanRequiredString(input.decision, "decision");
|
|
1628
|
-
return gateway.request({
|
|
1629
|
-
path: "/api/platform/v1/identity/policy/decisions",
|
|
1630
|
-
method: "POST",
|
|
1631
|
-
body: tenantIdentityBody(
|
|
1632
|
-
input,
|
|
1633
|
-
"identity.recordPolicyDecision"
|
|
1634
|
-
),
|
|
1635
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
};
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
// src/ontologyClient.ts
|
|
1642
|
-
function createOntologyClient(config = {}) {
|
|
1643
|
-
const gateway = createGatewayRequestClient(config);
|
|
1644
|
-
const client = {
|
|
1645
|
-
/**
|
|
1646
|
-
* List ontology definitions matching optional filters.
|
|
1647
|
-
*/
|
|
1648
|
-
async list(filters = {}) {
|
|
1649
|
-
return gateway.request({
|
|
1650
|
-
path: `/api/platform/v1/ontologies${toQueryString(filters)}`
|
|
1651
|
-
}).then(
|
|
1652
|
-
(response) => mapGatewayData(response, (data) => {
|
|
1653
|
-
const record = asRecord(data);
|
|
1654
|
-
const ontologies = asListItems(data, "ontologies");
|
|
1655
|
-
const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
|
|
1656
|
-
const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
|
|
1657
|
-
return {
|
|
1658
|
-
...record,
|
|
1659
|
-
...createListResult(definitions, "definitions"),
|
|
1660
|
-
ontologies: definitions,
|
|
1661
|
-
total
|
|
1662
|
-
};
|
|
1663
|
-
})
|
|
1664
|
-
);
|
|
1665
|
-
},
|
|
1666
|
-
/**
|
|
1667
|
-
* Get an ontology definition by identifier.
|
|
1668
|
-
*/
|
|
1669
|
-
async get(id) {
|
|
1670
|
-
return gateway.request({
|
|
1671
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
|
|
1672
|
-
});
|
|
1673
|
-
},
|
|
1674
|
-
/**
|
|
1675
|
-
* Bind an ontology definition to a topic.
|
|
1676
|
-
*/
|
|
1677
|
-
async bind(input, idempotencyKey) {
|
|
1678
|
-
return gateway.request({
|
|
1679
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
|
|
1680
|
-
method: "POST",
|
|
1681
|
-
body: {
|
|
1682
|
-
topicId: input.topicId
|
|
76
|
+
async list(query) {
|
|
77
|
+
return gateway.request({
|
|
78
|
+
path: `/api/platform/v1/tasks${toQueryString({
|
|
79
|
+
topicId: query.topicId,
|
|
80
|
+
worktreeId: query.worktreeId,
|
|
81
|
+
status: query.status,
|
|
82
|
+
limit: query.limit,
|
|
83
|
+
})}`,
|
|
84
|
+
});
|
|
1683
85
|
},
|
|
1684
|
-
|
|
1685
|
-
});
|
|
1686
|
-
},
|
|
1687
|
-
/**
|
|
1688
|
-
* Create an ontology definition.
|
|
1689
|
-
*/
|
|
1690
|
-
async createDefinition(input, idempotencyKey) {
|
|
1691
|
-
return gateway.request({
|
|
1692
|
-
path: "/api/platform/v1/ontologies",
|
|
1693
|
-
method: "POST",
|
|
1694
|
-
body: input,
|
|
1695
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1696
|
-
});
|
|
1697
|
-
},
|
|
1698
|
-
/**
|
|
1699
|
-
* Update an ontology definition.
|
|
1700
|
-
*/
|
|
1701
|
-
async updateDefinition(id, input, idempotencyKey) {
|
|
1702
|
-
return gateway.request({
|
|
1703
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
|
|
1704
|
-
method: "PATCH",
|
|
1705
|
-
body: input,
|
|
1706
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1707
|
-
});
|
|
1708
|
-
},
|
|
1709
|
-
/**
|
|
1710
|
-
* Archive an ontology definition.
|
|
1711
|
-
*/
|
|
1712
|
-
async archiveDefinition(id, idempotencyKey) {
|
|
1713
|
-
return gateway.request({
|
|
1714
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
|
|
1715
|
-
method: "DELETE",
|
|
1716
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1717
|
-
});
|
|
1718
|
-
},
|
|
1719
|
-
/**
|
|
1720
|
-
* List versions for an ontology definition.
|
|
1721
|
-
*/
|
|
1722
|
-
async listVersions(ontologyId, filters = {}) {
|
|
1723
|
-
return gateway.request({
|
|
1724
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions${toQueryString(filters)}`
|
|
1725
|
-
}).then(
|
|
1726
|
-
(response) => mapGatewayData(
|
|
1727
|
-
response,
|
|
1728
|
-
(data) => createListResult(asListItems(data, "versions"), "versions")
|
|
1729
|
-
)
|
|
1730
|
-
);
|
|
1731
|
-
},
|
|
1732
|
-
/**
|
|
1733
|
-
* Create an ontology version.
|
|
1734
|
-
*/
|
|
1735
|
-
async createVersion(ontologyId, input, idempotencyKey) {
|
|
1736
|
-
return gateway.request({
|
|
1737
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions`,
|
|
1738
|
-
method: "POST",
|
|
1739
|
-
body: input,
|
|
1740
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1741
|
-
});
|
|
1742
|
-
},
|
|
1743
|
-
/**
|
|
1744
|
-
* Publish an ontology version.
|
|
1745
|
-
*/
|
|
1746
|
-
async publishVersion(ontologyId, versionId, idempotencyKey) {
|
|
1747
|
-
return gateway.request({
|
|
1748
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/publish`,
|
|
1749
|
-
method: "POST",
|
|
1750
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1751
|
-
});
|
|
1752
|
-
},
|
|
1753
|
-
/**
|
|
1754
|
-
* Deprecate an ontology version.
|
|
1755
|
-
*/
|
|
1756
|
-
async deprecateVersion(ontologyId, versionId, idempotencyKey) {
|
|
1757
|
-
return gateway.request({
|
|
1758
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/deprecate`,
|
|
1759
|
-
method: "POST",
|
|
1760
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1761
|
-
});
|
|
1762
|
-
},
|
|
1763
|
-
/**
|
|
1764
|
-
* List topics directly bound to a specific ontology definition.
|
|
1765
|
-
* Uses the topics gateway with ontologyId filter.
|
|
1766
|
-
*/
|
|
1767
|
-
async listTopics(ontologyId) {
|
|
1768
|
-
return gateway.request({
|
|
1769
|
-
path: `/api/platform/v1/topics?ontologyId=${encodeURIComponent(ontologyId)}`
|
|
1770
|
-
}).then(
|
|
1771
|
-
(response) => mapGatewayData(
|
|
1772
|
-
response,
|
|
1773
|
-
(data) => createListResult(Array.isArray(data) ? data : [], "topics")
|
|
1774
|
-
)
|
|
1775
|
-
);
|
|
1776
|
-
}
|
|
1777
|
-
};
|
|
1778
|
-
return Object.assign(client, {
|
|
1779
|
-
listDefinitions: client.list,
|
|
1780
|
-
getDefinition: client.get,
|
|
1781
|
-
listTopicsByOntology: client.listTopics
|
|
1782
|
-
});
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
// src/gatewayFacades.factories.ts
|
|
1786
|
-
function normalizeBeliefConfidenceInput(input) {
|
|
1787
|
-
const opinion = input.opinion;
|
|
1788
|
-
return {
|
|
1789
|
-
belief: opinion.b,
|
|
1790
|
-
disbelief: opinion.d,
|
|
1791
|
-
uncertainty: opinion.u,
|
|
1792
|
-
baseRate: opinion.a,
|
|
1793
|
-
trigger: input.trigger,
|
|
1794
|
-
rationale: input.rationale,
|
|
1795
|
-
triggeringEvidenceId: input.triggeringEvidenceId,
|
|
1796
|
-
triggeringQuestionId: input.triggeringQuestionId,
|
|
1797
|
-
triggeringAnswerId: input.triggeringAnswerId,
|
|
1798
|
-
triggeringContradictionId: input.triggeringContradictionId,
|
|
1799
|
-
triggeringWorktreeId: input.triggeringWorktreeId,
|
|
1800
|
-
maxInlinePropagationTargets: input.maxInlinePropagationTargets
|
|
1801
|
-
};
|
|
1802
|
-
}
|
|
1803
|
-
function serializeTypes(types) {
|
|
1804
|
-
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
1805
|
-
}
|
|
1806
|
-
function createBeliefsFacade(config = {}) {
|
|
1807
|
-
const gateway = createGatewayRequestClient(config);
|
|
1808
|
-
return {
|
|
1809
|
-
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1810
|
-
return gateway.request({
|
|
1811
|
-
path: "/api/platform/v1/beliefs",
|
|
1812
|
-
method: "POST",
|
|
1813
|
-
body: input,
|
|
1814
|
-
idempotencyKey
|
|
1815
|
-
});
|
|
1816
|
-
},
|
|
1817
|
-
async get(id) {
|
|
1818
|
-
return gateway.request({
|
|
1819
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`
|
|
1820
|
-
});
|
|
1821
|
-
},
|
|
1822
|
-
async list(query) {
|
|
1823
|
-
return gateway.request({
|
|
1824
|
-
path: `/api/platform/v1/beliefs${toQueryString({
|
|
1825
|
-
topicId: query.topicId,
|
|
1826
|
-
status: query.status,
|
|
1827
|
-
worktreeId: query.worktreeId,
|
|
1828
|
-
minConfidence: query.minConfidence,
|
|
1829
|
-
limit: query.limit,
|
|
1830
|
-
cursor: query.cursor
|
|
1831
|
-
})}`
|
|
1832
|
-
});
|
|
1833
|
-
},
|
|
1834
|
-
async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
1835
|
-
return gateway.request({
|
|
1836
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
|
|
1837
|
-
method: "PATCH",
|
|
1838
|
-
body: input,
|
|
1839
|
-
idempotencyKey
|
|
1840
|
-
});
|
|
1841
|
-
},
|
|
1842
|
-
async fork(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
1843
|
-
return gateway.request({
|
|
1844
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/fork`,
|
|
1845
|
-
method: "POST",
|
|
1846
|
-
body: input,
|
|
1847
|
-
idempotencyKey
|
|
1848
|
-
});
|
|
1849
|
-
},
|
|
1850
|
-
async updateConfidence(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
1851
|
-
return gateway.request({
|
|
1852
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
|
|
1853
|
-
method: "POST",
|
|
1854
|
-
body: normalizeBeliefConfidenceInput(input),
|
|
1855
|
-
idempotencyKey
|
|
1856
|
-
});
|
|
1857
|
-
},
|
|
1858
|
-
async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1859
|
-
return gateway.request({
|
|
1860
|
-
path: "/api/platform/v1/beliefs/update-status",
|
|
1861
|
-
method: "POST",
|
|
1862
|
-
body: input,
|
|
1863
|
-
idempotencyKey
|
|
1864
|
-
});
|
|
1865
|
-
},
|
|
1866
|
-
async updateRationale(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1867
|
-
return gateway.request({
|
|
1868
|
-
path: "/api/platform/v1/beliefs/update-rationale",
|
|
1869
|
-
method: "POST",
|
|
1870
|
-
body: input,
|
|
1871
|
-
idempotencyKey
|
|
1872
|
-
});
|
|
1873
|
-
},
|
|
1874
|
-
async linkBeliefs(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1875
|
-
return gateway.request({
|
|
1876
|
-
path: "/api/platform/v1/beliefs/link",
|
|
1877
|
-
method: "POST",
|
|
1878
|
-
body: input,
|
|
1879
|
-
idempotencyKey
|
|
1880
|
-
});
|
|
1881
|
-
},
|
|
1882
|
-
async unlinkEvidence(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1883
|
-
return gateway.request({
|
|
1884
|
-
path: "/api/platform/v1/beliefs/unlink-evidence",
|
|
1885
|
-
method: "POST",
|
|
1886
|
-
body: input,
|
|
1887
|
-
idempotencyKey
|
|
1888
|
-
});
|
|
1889
|
-
},
|
|
1890
|
-
async updateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1891
|
-
return gateway.request({
|
|
1892
|
-
path: "/api/platform/v1/beliefs/update-criticality",
|
|
1893
|
-
method: "POST",
|
|
1894
|
-
body: input,
|
|
1895
|
-
idempotencyKey
|
|
1896
|
-
});
|
|
1897
|
-
},
|
|
1898
|
-
async batchUpdateCriticality(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1899
|
-
return gateway.request({
|
|
1900
|
-
path: "/api/platform/v1/beliefs/batch-update-criticality",
|
|
1901
|
-
method: "POST",
|
|
1902
|
-
body: input,
|
|
1903
|
-
idempotencyKey
|
|
1904
|
-
});
|
|
1905
|
-
},
|
|
1906
|
-
async reassignTopic(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1907
|
-
return gateway.request({
|
|
1908
|
-
path: "/api/platform/v1/beliefs/reassign-topic",
|
|
1909
|
-
method: "POST",
|
|
1910
|
-
body: input,
|
|
1911
|
-
idempotencyKey
|
|
1912
|
-
});
|
|
1913
|
-
},
|
|
1914
|
-
async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
1915
|
-
return gateway.request({
|
|
1916
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}`,
|
|
1917
|
-
method: "DELETE",
|
|
1918
|
-
body: input,
|
|
1919
|
-
idempotencyKey
|
|
1920
|
-
});
|
|
1921
|
-
},
|
|
1922
|
-
async lineage(id) {
|
|
1923
|
-
return gateway.request({
|
|
1924
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/lineage`
|
|
1925
|
-
});
|
|
1926
|
-
},
|
|
1927
|
-
async confidenceHistory(id) {
|
|
1928
|
-
return gateway.request({
|
|
1929
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
1930
|
-
});
|
|
1931
|
-
},
|
|
1932
|
-
async opinionHistory(id) {
|
|
1933
|
-
return gateway.request({
|
|
1934
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
1935
|
-
});
|
|
1936
|
-
},
|
|
1937
|
-
async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
1938
|
-
return gateway.request({
|
|
1939
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
|
|
1940
|
-
method: "POST",
|
|
1941
|
-
body: input,
|
|
1942
|
-
idempotencyKey
|
|
1943
|
-
});
|
|
1944
|
-
},
|
|
1945
|
-
async bisect(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
1946
|
-
return gateway.request({
|
|
1947
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/bisect`,
|
|
1948
|
-
method: "POST",
|
|
1949
|
-
body: input,
|
|
1950
|
-
idempotencyKey
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
function createContradictionsFacade(config = {}) {
|
|
1956
|
-
const gateway = createGatewayRequestClient(config);
|
|
1957
|
-
return {
|
|
1958
|
-
async flag(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1959
|
-
return gateway.request({
|
|
1960
|
-
path: "/api/platform/v1/contradictions",
|
|
1961
|
-
method: "POST",
|
|
1962
|
-
body: input,
|
|
1963
|
-
idempotencyKey
|
|
1964
|
-
});
|
|
1965
|
-
},
|
|
1966
|
-
async list(query) {
|
|
1967
|
-
return gateway.request({
|
|
1968
|
-
path: `/api/platform/v1/contradictions${toQueryString({
|
|
1969
|
-
topicId: query.topicId,
|
|
1970
|
-
status: query.status,
|
|
1971
|
-
limit: query.limit,
|
|
1972
|
-
cursor: query.cursor
|
|
1973
|
-
})}`
|
|
1974
|
-
});
|
|
1975
|
-
},
|
|
1976
|
-
async get(id) {
|
|
1977
|
-
return gateway.request({
|
|
1978
|
-
path: `/api/platform/v1/contradictions/${encodeURIComponent(id)}`
|
|
1979
|
-
});
|
|
1980
|
-
}
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
function createEdgesFacade(config = {}) {
|
|
1984
|
-
const gateway = createGatewayRequestClient(config);
|
|
1985
|
-
return {
|
|
1986
|
-
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1987
|
-
return gateway.request({
|
|
1988
|
-
path: "/api/platform/v1/edges",
|
|
1989
|
-
method: "POST",
|
|
1990
|
-
body: input,
|
|
1991
|
-
idempotencyKey
|
|
1992
|
-
});
|
|
1993
|
-
},
|
|
1994
|
-
async list(query) {
|
|
1995
|
-
return gateway.request({
|
|
1996
|
-
path: `/api/platform/v1/edges${toQueryString({
|
|
1997
|
-
sourceId: query.sourceId,
|
|
1998
|
-
edgeType: query.edgeType,
|
|
1999
|
-
limit: query.limit,
|
|
2000
|
-
cursor: query.cursor
|
|
2001
|
-
})}`
|
|
2002
|
-
});
|
|
2003
|
-
},
|
|
2004
|
-
async traverse(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2005
|
-
return gateway.request({
|
|
2006
|
-
path: "/api/platform/v1/edges/traverse",
|
|
2007
|
-
method: "POST",
|
|
2008
|
-
body: input,
|
|
2009
|
-
idempotencyKey
|
|
2010
|
-
});
|
|
2011
|
-
},
|
|
2012
|
-
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2013
|
-
return gateway.request({
|
|
2014
|
-
path: "/api/platform/v1/edges/update",
|
|
2015
|
-
method: "POST",
|
|
2016
|
-
body: input,
|
|
2017
|
-
idempotencyKey
|
|
2018
|
-
});
|
|
2019
|
-
},
|
|
2020
|
-
async remove(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2021
|
-
return gateway.request({
|
|
2022
|
-
path: "/api/platform/v1/edges/remove",
|
|
2023
|
-
method: "POST",
|
|
2024
|
-
body: input,
|
|
2025
|
-
idempotencyKey
|
|
2026
|
-
});
|
|
2027
|
-
},
|
|
2028
|
-
async removeBetween(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2029
|
-
return gateway.request({
|
|
2030
|
-
path: "/api/platform/v1/edges/remove-between",
|
|
2031
|
-
method: "POST",
|
|
2032
|
-
body: input,
|
|
2033
|
-
idempotencyKey
|
|
2034
|
-
});
|
|
2035
|
-
},
|
|
2036
|
-
async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2037
|
-
return gateway.request({
|
|
2038
|
-
path: "/api/platform/v1/edges/batch",
|
|
2039
|
-
method: "POST",
|
|
2040
|
-
body: input,
|
|
2041
|
-
idempotencyKey
|
|
2042
|
-
});
|
|
2043
|
-
},
|
|
2044
|
-
async delete(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2045
|
-
return gateway.request({
|
|
2046
|
-
path: "/api/platform/v1/edges/delete",
|
|
2047
|
-
method: "POST",
|
|
2048
|
-
body: input,
|
|
2049
|
-
idempotencyKey
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
};
|
|
86
|
+
};
|
|
2053
87
|
}
|
|
2054
|
-
function
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
});
|
|
2064
|
-
},
|
|
2065
|
-
async get(id) {
|
|
2066
|
-
return gateway.request({
|
|
2067
|
-
path: `/api/platform/v1/evidence/${encodeURIComponent(id)}`
|
|
2068
|
-
});
|
|
2069
|
-
},
|
|
2070
|
-
async list(query) {
|
|
2071
|
-
return gateway.request({
|
|
2072
|
-
path: `/api/platform/v1/evidence${toQueryString({
|
|
2073
|
-
topicId: query.topicId,
|
|
2074
|
-
targetId: query.targetId,
|
|
2075
|
-
limit: query.limit,
|
|
2076
|
-
cursor: query.cursor
|
|
2077
|
-
})}`
|
|
2078
|
-
});
|
|
2079
|
-
},
|
|
2080
|
-
async link(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2081
|
-
return gateway.request({
|
|
2082
|
-
path: `/api/platform/v1/evidence/${encodeURIComponent(input.evidenceId)}/link`,
|
|
2083
|
-
method: "POST",
|
|
2084
|
-
body: {
|
|
2085
|
-
targetId: input.targetId,
|
|
2086
|
-
targetType: input.targetType,
|
|
2087
|
-
weight: input.weight,
|
|
2088
|
-
rationale: input.rationale
|
|
88
|
+
export function createTopicsFacade(config = {}) {
|
|
89
|
+
const topicsClient = createTopicsClient(config);
|
|
90
|
+
return {
|
|
91
|
+
create: topicsClient.create,
|
|
92
|
+
get: topicsClient.get,
|
|
93
|
+
list: topicsClient.list,
|
|
94
|
+
async update(input, idempotencyKey) {
|
|
95
|
+
const { id, ...rest } = input;
|
|
96
|
+
return topicsClient.update(id, rest, idempotencyKey);
|
|
2089
97
|
},
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
return gateway.request({
|
|
2095
|
-
path: "/api/platform/v1/evidence/search",
|
|
2096
|
-
method: "POST",
|
|
2097
|
-
body: query,
|
|
2098
|
-
idempotencyKey
|
|
2099
|
-
});
|
|
2100
|
-
},
|
|
2101
|
-
async updateStatus(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2102
|
-
return gateway.request({
|
|
2103
|
-
path: "/api/platform/v1/evidence/update-status",
|
|
2104
|
-
method: "POST",
|
|
2105
|
-
body: input,
|
|
2106
|
-
idempotencyKey
|
|
2107
|
-
});
|
|
2108
|
-
},
|
|
2109
|
-
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2110
|
-
return gateway.request({
|
|
2111
|
-
path: "/api/platform/v1/evidence/update",
|
|
2112
|
-
method: "POST",
|
|
2113
|
-
body: input,
|
|
2114
|
-
idempotencyKey
|
|
2115
|
-
});
|
|
2116
|
-
},
|
|
2117
|
-
async flagIncorrect(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2118
|
-
return gateway.request({
|
|
2119
|
-
path: "/api/platform/v1/evidence/flag-incorrect",
|
|
2120
|
-
method: "POST",
|
|
2121
|
-
body: input,
|
|
2122
|
-
idempotencyKey
|
|
2123
|
-
});
|
|
2124
|
-
},
|
|
2125
|
-
async remove(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2126
|
-
return gateway.request({
|
|
2127
|
-
path: "/api/platform/v1/evidence/remove",
|
|
2128
|
-
method: "POST",
|
|
2129
|
-
body: input,
|
|
2130
|
-
idempotencyKey
|
|
2131
|
-
});
|
|
2132
|
-
},
|
|
2133
|
-
async updateVerificationStatus(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2134
|
-
return gateway.request({
|
|
2135
|
-
path: "/api/platform/v1/evidence/update-verification-status",
|
|
2136
|
-
method: "POST",
|
|
2137
|
-
body: input,
|
|
2138
|
-
idempotencyKey
|
|
2139
|
-
});
|
|
2140
|
-
}
|
|
2141
|
-
};
|
|
2142
|
-
}
|
|
2143
|
-
function createEventsFacade(config = {}) {
|
|
2144
|
-
const gateway = createGatewayRequestClient(config);
|
|
2145
|
-
return {
|
|
2146
|
-
async list(query = {}) {
|
|
2147
|
-
return gateway.request({
|
|
2148
|
-
path: `/api/platform/v1/events${toQueryString({
|
|
2149
|
-
topicId: query.topicId,
|
|
2150
|
-
after: query.after,
|
|
2151
|
-
types: serializeTypes(query.types),
|
|
2152
|
-
startTime: query.startTime,
|
|
2153
|
-
endTime: query.endTime,
|
|
2154
|
-
limit: query.limit
|
|
2155
|
-
})}`
|
|
2156
|
-
});
|
|
2157
|
-
},
|
|
2158
|
-
async replay(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2159
|
-
return gateway.request({
|
|
2160
|
-
path: "/api/platform/v1/events/replay",
|
|
2161
|
-
method: "POST",
|
|
2162
|
-
body: input,
|
|
2163
|
-
idempotencyKey
|
|
2164
|
-
});
|
|
2165
|
-
}
|
|
2166
|
-
};
|
|
2167
|
-
}
|
|
2168
|
-
function createGraphFacade(config = {}) {
|
|
2169
|
-
const graphClient = createGraphClient(config);
|
|
2170
|
-
const gateway = createGatewayRequestClient(config);
|
|
2171
|
-
const graphFacade = {
|
|
2172
|
-
async neighborhood(input) {
|
|
2173
|
-
return graphClient.neighborhood({
|
|
2174
|
-
globalId: input.globalId,
|
|
2175
|
-
globalIds: Array.isArray(input.globalIds) ? input.globalIds.join(",") : input.globalIds,
|
|
2176
|
-
maxDepth: input.maxDepth
|
|
2177
|
-
});
|
|
2178
|
-
},
|
|
2179
|
-
async falsify(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2180
|
-
return gateway.request({
|
|
2181
|
-
path: "/api/platform/v1/graph/falsify",
|
|
2182
|
-
method: "POST",
|
|
2183
|
-
body: input,
|
|
2184
|
-
idempotencyKey
|
|
2185
|
-
});
|
|
2186
|
-
}
|
|
2187
|
-
};
|
|
2188
|
-
return Object.assign(graphFacade, {
|
|
2189
|
-
traverse: graphClient.traverse,
|
|
2190
|
-
analyze: graphClient.analyze,
|
|
2191
|
-
bias: graphClient.bias,
|
|
2192
|
-
gaps: graphClient.gaps
|
|
2193
|
-
});
|
|
2194
|
-
}
|
|
2195
|
-
function createIdentityFacade(config = {}) {
|
|
2196
|
-
const identityClient = createIdentityClient(config);
|
|
2197
|
-
return {
|
|
2198
|
-
async whoami() {
|
|
2199
|
-
const response = await identityClient.whoami();
|
|
2200
|
-
return Object.assign({}, response, response.data);
|
|
2201
|
-
}
|
|
2202
|
-
};
|
|
2203
|
-
}
|
|
2204
|
-
function createOntologiesFacade(config = {}) {
|
|
2205
|
-
const ontologyClient = createOntologyClient(config);
|
|
2206
|
-
const gateway = createGatewayRequestClient(config);
|
|
2207
|
-
const ontologyFacade = {
|
|
2208
|
-
async get(id) {
|
|
2209
|
-
return gateway.request({
|
|
2210
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
|
|
2211
|
-
});
|
|
2212
|
-
},
|
|
2213
|
-
async bind(input, idempotencyKey) {
|
|
2214
|
-
return gateway.request({
|
|
2215
|
-
path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
|
|
2216
|
-
method: "POST",
|
|
2217
|
-
body: {
|
|
2218
|
-
topicId: input.topicId
|
|
98
|
+
async tree(input) {
|
|
99
|
+
return topicsClient.getTree(input.id, {
|
|
100
|
+
maxDepth: input.maxDepth,
|
|
101
|
+
});
|
|
2219
102
|
},
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
};
|
|
2232
|
-
return Object.assign(ontologyFacade, {
|
|
2233
|
-
list: ontologyClient.list
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
function createQuestionsFacade(config = {}) {
|
|
2237
|
-
const gateway = createGatewayRequestClient(config);
|
|
2238
|
-
return {
|
|
2239
|
-
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2240
|
-
return gateway.request({
|
|
2241
|
-
path: "/api/platform/v1/questions",
|
|
2242
|
-
method: "POST",
|
|
2243
|
-
body: input,
|
|
2244
|
-
idempotencyKey
|
|
2245
|
-
});
|
|
2246
|
-
},
|
|
2247
|
-
async get(id) {
|
|
2248
|
-
return gateway.request({
|
|
2249
|
-
path: `/api/platform/v1/questions/${encodeURIComponent(id)}`
|
|
2250
|
-
});
|
|
2251
|
-
},
|
|
2252
|
-
async list(query) {
|
|
2253
|
-
return gateway.request({
|
|
2254
|
-
path: `/api/platform/v1/questions${toQueryString({
|
|
2255
|
-
topicId: query.topicId,
|
|
2256
|
-
status: query.status,
|
|
2257
|
-
priority: query.priority,
|
|
2258
|
-
worktreeId: query.worktreeId,
|
|
2259
|
-
limit: query.limit,
|
|
2260
|
-
cursor: query.cursor
|
|
2261
|
-
})}`
|
|
2262
|
-
});
|
|
2263
|
-
},
|
|
2264
|
-
async answer(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2265
|
-
return gateway.request({
|
|
2266
|
-
path: `/api/platform/v1/questions/${encodeURIComponent(id)}/answer`,
|
|
2267
|
-
method: "POST",
|
|
2268
|
-
body: input,
|
|
2269
|
-
idempotencyKey
|
|
2270
|
-
});
|
|
2271
|
-
},
|
|
2272
|
-
async refine(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2273
|
-
return gateway.request({
|
|
2274
|
-
path: `/api/platform/v1/questions/${encodeURIComponent(id)}/refine`,
|
|
2275
|
-
method: "POST",
|
|
2276
|
-
body: input,
|
|
2277
|
-
idempotencyKey
|
|
2278
|
-
});
|
|
2279
|
-
},
|
|
2280
|
-
async archive(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
2281
|
-
return gateway.request({
|
|
2282
|
-
path: `/api/platform/v1/questions/${encodeURIComponent(id)}`,
|
|
2283
|
-
method: "DELETE",
|
|
2284
|
-
body: input,
|
|
2285
|
-
idempotencyKey
|
|
2286
|
-
});
|
|
2287
|
-
},
|
|
2288
|
-
async updateStatus(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2289
|
-
return gateway.request({
|
|
2290
|
-
path: `/api/platform/v1/questions/${encodeURIComponent(id)}/status`,
|
|
2291
|
-
method: "PATCH",
|
|
2292
|
-
body: input,
|
|
2293
|
-
idempotencyKey
|
|
2294
|
-
});
|
|
2295
|
-
},
|
|
2296
|
-
async batchCreate(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2297
|
-
return gateway.request({
|
|
2298
|
-
path: "/api/platform/v1/questions/batch",
|
|
2299
|
-
method: "POST",
|
|
2300
|
-
body: input,
|
|
2301
|
-
idempotencyKey
|
|
2302
|
-
});
|
|
2303
|
-
},
|
|
2304
|
-
async add(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2305
|
-
return gateway.request({
|
|
2306
|
-
path: "/api/platform/v1/questions/add",
|
|
2307
|
-
method: "POST",
|
|
2308
|
-
body: input,
|
|
2309
|
-
idempotencyKey
|
|
2310
|
-
});
|
|
2311
|
-
},
|
|
2312
|
-
async updatePriority(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2313
|
-
return gateway.request({
|
|
2314
|
-
path: "/api/platform/v1/questions/update-priority",
|
|
2315
|
-
method: "POST",
|
|
2316
|
-
body: input,
|
|
2317
|
-
idempotencyKey
|
|
2318
|
-
});
|
|
2319
|
-
},
|
|
2320
|
-
async advanceToConviction(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2321
|
-
return gateway.request({
|
|
2322
|
-
path: "/api/platform/v1/questions/advance-to-conviction",
|
|
2323
|
-
method: "POST",
|
|
2324
|
-
body: input,
|
|
2325
|
-
idempotencyKey
|
|
2326
|
-
});
|
|
2327
|
-
},
|
|
2328
|
-
async updateConviction(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2329
|
-
return gateway.request({
|
|
2330
|
-
path: "/api/platform/v1/questions/update-conviction",
|
|
2331
|
-
method: "POST",
|
|
2332
|
-
body: input,
|
|
2333
|
-
idempotencyKey
|
|
2334
|
-
});
|
|
2335
|
-
},
|
|
2336
|
-
async finalizeConviction(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2337
|
-
return gateway.request({
|
|
2338
|
-
path: "/api/platform/v1/questions/finalize-conviction",
|
|
2339
|
-
method: "POST",
|
|
2340
|
-
body: input,
|
|
2341
|
-
idempotencyKey
|
|
2342
|
-
});
|
|
2343
|
-
},
|
|
2344
|
-
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2345
|
-
return gateway.request({
|
|
2346
|
-
path: "/api/platform/v1/questions/update",
|
|
2347
|
-
method: "POST",
|
|
2348
|
-
body: input,
|
|
2349
|
-
idempotencyKey
|
|
2350
|
-
});
|
|
2351
|
-
},
|
|
2352
|
-
async delete(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2353
|
-
return gateway.request({
|
|
2354
|
-
path: "/api/platform/v1/questions/delete",
|
|
2355
|
-
method: "POST",
|
|
2356
|
-
body: input,
|
|
2357
|
-
idempotencyKey
|
|
2358
|
-
});
|
|
2359
|
-
}
|
|
2360
|
-
};
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
// src/gatewayFacades.ts
|
|
2364
|
-
function createSearchFacade(config = {}) {
|
|
2365
|
-
const gateway = createGatewayRequestClient(config);
|
|
2366
|
-
return {
|
|
2367
|
-
async query(input) {
|
|
2368
|
-
return gateway.request({
|
|
2369
|
-
path: "/api/platform/v1/search",
|
|
2370
|
-
method: "POST",
|
|
2371
|
-
body: input
|
|
2372
|
-
});
|
|
2373
|
-
}
|
|
2374
|
-
};
|
|
103
|
+
async coverage(input) {
|
|
104
|
+
return topicsClient.getCoverage(input.id, {
|
|
105
|
+
includeDescendants: input.includeDescendants,
|
|
106
|
+
maxDepth: input.maxDepth,
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
remove: topicsClient.remove,
|
|
110
|
+
bulkCreate: topicsClient.bulkCreate,
|
|
111
|
+
};
|
|
2375
112
|
}
|
|
2376
|
-
function
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
},
|
|
2387
|
-
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2388
|
-
return gateway.request({
|
|
2389
|
-
path: `/api/platform/v1/tasks/${encodeURIComponent(input.id)}`,
|
|
2390
|
-
method: "PATCH",
|
|
2391
|
-
body: {
|
|
2392
|
-
title: input.title,
|
|
2393
|
-
description: input.description,
|
|
2394
|
-
priority: input.priority,
|
|
2395
|
-
status: input.status,
|
|
2396
|
-
assigneeId: input.assigneeId,
|
|
2397
|
-
blockedReason: input.blockedReason,
|
|
2398
|
-
linkedBeliefId: input.linkedBeliefId,
|
|
2399
|
-
linkedQuestionId: input.linkedQuestionId,
|
|
2400
|
-
linkedWorktreeId: input.linkedWorktreeId,
|
|
2401
|
-
metadata: input.metadata
|
|
113
|
+
export function createWebhooksFacade(config = {}) {
|
|
114
|
+
const gateway = createGatewayRequestClient(config);
|
|
115
|
+
return {
|
|
116
|
+
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
117
|
+
return gateway.request({
|
|
118
|
+
path: "/api/platform/v1/webhooks",
|
|
119
|
+
method: "POST",
|
|
120
|
+
body: input,
|
|
121
|
+
idempotencyKey,
|
|
122
|
+
});
|
|
2402
123
|
},
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
method: "POST",
|
|
2410
|
-
body: {
|
|
2411
|
-
outputSummary: input.outputSummary
|
|
124
|
+
async list(query = {}) {
|
|
125
|
+
return gateway.request({
|
|
126
|
+
path: `/api/platform/v1/webhooks${toQueryString({
|
|
127
|
+
topicId: query.topicId,
|
|
128
|
+
})}`,
|
|
129
|
+
});
|
|
2412
130
|
},
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
const gateway = createGatewayRequestClient(config);
|
|
2455
|
-
return {
|
|
2456
|
-
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
2457
|
-
return gateway.request({
|
|
2458
|
-
path: "/api/platform/v1/webhooks",
|
|
2459
|
-
method: "POST",
|
|
2460
|
-
body: input,
|
|
2461
|
-
idempotencyKey
|
|
2462
|
-
});
|
|
2463
|
-
},
|
|
2464
|
-
async list(query = {}) {
|
|
2465
|
-
return gateway.request({
|
|
2466
|
-
path: `/api/platform/v1/webhooks${toQueryString({
|
|
2467
|
-
topicId: query.topicId
|
|
2468
|
-
})}`
|
|
2469
|
-
});
|
|
2470
|
-
},
|
|
2471
|
-
async get(id) {
|
|
2472
|
-
return gateway.request({
|
|
2473
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`
|
|
2474
|
-
});
|
|
2475
|
-
},
|
|
2476
|
-
async update(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2477
|
-
return gateway.request({
|
|
2478
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`,
|
|
2479
|
-
method: "PATCH",
|
|
2480
|
-
body: input,
|
|
2481
|
-
idempotencyKey
|
|
2482
|
-
});
|
|
2483
|
-
},
|
|
2484
|
-
async delete(id, idempotencyKey = randomIdempotencyKey()) {
|
|
2485
|
-
return gateway.request({
|
|
2486
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`,
|
|
2487
|
-
method: "DELETE",
|
|
2488
|
-
idempotencyKey
|
|
2489
|
-
});
|
|
2490
|
-
},
|
|
2491
|
-
async test(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
2492
|
-
return gateway.request({
|
|
2493
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/test`,
|
|
2494
|
-
method: "POST",
|
|
2495
|
-
body: input,
|
|
2496
|
-
idempotencyKey
|
|
2497
|
-
});
|
|
2498
|
-
},
|
|
2499
|
-
async deliveries(id, query = {}) {
|
|
2500
|
-
return gateway.request({
|
|
2501
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
|
|
2502
|
-
limit: query.limit
|
|
2503
|
-
})}`
|
|
2504
|
-
});
|
|
2505
|
-
},
|
|
2506
|
-
async health(id) {
|
|
2507
|
-
return gateway.request({
|
|
2508
|
-
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/health`
|
|
2509
|
-
});
|
|
2510
|
-
}
|
|
2511
|
-
};
|
|
131
|
+
async get(id) {
|
|
132
|
+
return gateway.request({
|
|
133
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`,
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
async update(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
137
|
+
return gateway.request({
|
|
138
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`,
|
|
139
|
+
method: "PATCH",
|
|
140
|
+
body: input,
|
|
141
|
+
idempotencyKey,
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
async delete(id, idempotencyKey = randomIdempotencyKey()) {
|
|
145
|
+
return gateway.request({
|
|
146
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}`,
|
|
147
|
+
method: "DELETE",
|
|
148
|
+
idempotencyKey,
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
async test(id, input = {}, idempotencyKey = randomIdempotencyKey()) {
|
|
152
|
+
return gateway.request({
|
|
153
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/test`,
|
|
154
|
+
method: "POST",
|
|
155
|
+
body: input,
|
|
156
|
+
idempotencyKey,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
async deliveries(id, query = {}) {
|
|
160
|
+
return gateway.request({
|
|
161
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/deliveries${toQueryString({
|
|
162
|
+
limit: query.limit,
|
|
163
|
+
})}`,
|
|
164
|
+
});
|
|
165
|
+
},
|
|
166
|
+
async health(id) {
|
|
167
|
+
return gateway.request({
|
|
168
|
+
path: `/api/platform/v1/webhooks/${encodeURIComponent(id)}/health`,
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
};
|
|
2512
172
|
}
|
|
2513
|
-
function createWorktreesFacade(config = {}) {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
173
|
+
export function createWorktreesFacade(config = {}) {
|
|
174
|
+
const gateway = createGatewayRequestClient(config);
|
|
175
|
+
return {
|
|
176
|
+
async create(input, idempotencyKey = randomIdempotencyKey()) {
|
|
177
|
+
return gateway.request({
|
|
178
|
+
path: "/api/platform/v1/worktrees",
|
|
179
|
+
method: "POST",
|
|
180
|
+
body: input,
|
|
181
|
+
idempotencyKey,
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
async list(query) {
|
|
185
|
+
return gateway.request({
|
|
186
|
+
path: `/api/platform/v1/worktrees${toQueryString({
|
|
187
|
+
topicId: query.topicId,
|
|
188
|
+
status: query.status,
|
|
189
|
+
groupBy: query.groupBy,
|
|
190
|
+
lane: query.lane,
|
|
191
|
+
campaign: query.campaign,
|
|
192
|
+
limit: query.limit,
|
|
193
|
+
})}`,
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
async listCampaigns(query = {}) {
|
|
197
|
+
return gateway.request({
|
|
198
|
+
path: `/api/platform/v1/worktrees/campaigns${toQueryString({
|
|
199
|
+
topicId: query.topicId,
|
|
200
|
+
status: query.status,
|
|
201
|
+
limit: query.limit,
|
|
202
|
+
})}`,
|
|
203
|
+
});
|
|
204
|
+
},
|
|
205
|
+
async activate(input, idempotencyKey = randomIdempotencyKey()) {
|
|
206
|
+
return gateway.request({
|
|
207
|
+
path: `/api/platform/v1/worktrees/${encodeURIComponent(input.id)}/activate`,
|
|
208
|
+
method: "POST",
|
|
209
|
+
body: {},
|
|
210
|
+
idempotencyKey,
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
async update(input, idempotencyKey = randomIdempotencyKey()) {
|
|
214
|
+
return gateway.request({
|
|
215
|
+
path: `/api/platform/v1/worktrees/${encodeURIComponent(input.id)}`,
|
|
216
|
+
method: "PATCH",
|
|
217
|
+
body: {
|
|
218
|
+
objective: input.objective,
|
|
219
|
+
hypothesis: input.hypothesis,
|
|
220
|
+
rationale: input.rationale,
|
|
221
|
+
campaign: input.campaign,
|
|
222
|
+
lane: input.lane,
|
|
223
|
+
laneOrderInCampaign: input.laneOrderInCampaign,
|
|
224
|
+
orderInLane: input.orderInLane,
|
|
225
|
+
dependsOn: input.dependsOn,
|
|
226
|
+
blocks: input.blocks,
|
|
227
|
+
gate: input.gate,
|
|
228
|
+
status: input.status,
|
|
229
|
+
topicId: input.topicId,
|
|
230
|
+
additionalTopicIds: input.additionalTopicIds,
|
|
231
|
+
proofArtifacts: input.proofArtifacts,
|
|
232
|
+
staffingHint: input.staffingHint,
|
|
233
|
+
lastReconciledAt: input.lastReconciledAt,
|
|
234
|
+
autoFixPolicy: input.autoFixPolicy,
|
|
235
|
+
lensId: input.lensId,
|
|
236
|
+
},
|
|
237
|
+
idempotencyKey,
|
|
238
|
+
});
|
|
2576
239
|
},
|
|
2577
|
-
idempotencyKey
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
240
|
+
async merge(input, idempotencyKey = randomIdempotencyKey()) {
|
|
241
|
+
return gateway.request({
|
|
242
|
+
path: `/api/platform/v1/worktrees/${encodeURIComponent(input.id)}/merge`,
|
|
243
|
+
method: "POST",
|
|
244
|
+
body: {
|
|
245
|
+
summary: input.summary,
|
|
246
|
+
outcomes: input.outcomes,
|
|
247
|
+
},
|
|
248
|
+
idempotencyKey,
|
|
249
|
+
});
|
|
2587
250
|
},
|
|
2588
|
-
idempotencyKey
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
251
|
+
async updateTargets(input, idempotencyKey = randomIdempotencyKey()) {
|
|
252
|
+
return gateway.request({
|
|
253
|
+
path: `/api/platform/v1/worktrees/${encodeURIComponent(input.id)}/targets`,
|
|
254
|
+
method: "POST",
|
|
255
|
+
body: {
|
|
256
|
+
addBeliefIds: input.addBeliefIds,
|
|
257
|
+
addQuestionIds: input.addQuestionIds,
|
|
258
|
+
removeBeliefIds: input.removeBeliefIds,
|
|
259
|
+
removeQuestionIds: input.removeQuestionIds,
|
|
260
|
+
},
|
|
261
|
+
idempotencyKey,
|
|
262
|
+
});
|
|
2600
263
|
},
|
|
2601
|
-
idempotencyKey
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
idempotencyKey
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
idempotencyKey
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
idempotencyKey
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
idempotencyKey
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2644
|
-
};
|
|
264
|
+
async complete(input, idempotencyKey = randomIdempotencyKey()) {
|
|
265
|
+
return gateway.request({
|
|
266
|
+
path: "/api/platform/v1/worktrees/complete",
|
|
267
|
+
method: "POST",
|
|
268
|
+
body: input,
|
|
269
|
+
idempotencyKey,
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
async advancePhase(input, idempotencyKey = randomIdempotencyKey()) {
|
|
273
|
+
return gateway.request({
|
|
274
|
+
path: "/api/platform/v1/worktrees/advance-phase",
|
|
275
|
+
method: "POST",
|
|
276
|
+
body: input,
|
|
277
|
+
idempotencyKey,
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
async setPhase(input, idempotencyKey = randomIdempotencyKey()) {
|
|
281
|
+
return gateway.request({
|
|
282
|
+
path: "/api/platform/v1/worktrees/set-phase",
|
|
283
|
+
method: "POST",
|
|
284
|
+
body: input,
|
|
285
|
+
idempotencyKey,
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
async patchState(input, idempotencyKey = randomIdempotencyKey()) {
|
|
289
|
+
return gateway.request({
|
|
290
|
+
path: "/api/platform/v1/worktrees/patch-state",
|
|
291
|
+
method: "POST",
|
|
292
|
+
body: input,
|
|
293
|
+
idempotencyKey,
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
async bulkCreate(input, idempotencyKey = randomIdempotencyKey()) {
|
|
297
|
+
return gateway.request({
|
|
298
|
+
path: "/api/platform/v1/worktrees/bulk",
|
|
299
|
+
method: "POST",
|
|
300
|
+
body: input,
|
|
301
|
+
idempotencyKey,
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
};
|
|
2645
305
|
}
|
|
2646
|
-
|
|
2647
|
-
export { createBeliefsFacade, createContradictionsFacade, createEdgesFacade, createEventsFacade, createEvidenceFacade, createGraphFacade, createIdentityFacade, createOntologiesFacade, createQuestionsFacade, createSearchFacade, createTasksFacade, createTopicsFacade, createWebhooksFacade, createWorktreesFacade };
|
|
2648
|
-
//# sourceMappingURL=gatewayFacades.js.map
|
|
2649
306
|
//# sourceMappingURL=gatewayFacades.js.map
|