@lucern/sdk 0.3.0-alpha.1 → 0.3.0-alpha.11
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 +3 -0
- package/README.md +51 -4
- package/dist/accessControl.d.ts +78 -0
- package/dist/accessControl.js +1118 -0
- package/dist/accessControl.js.map +1 -0
- package/dist/adminClient.d.ts +10 -8
- package/dist/adminClient.js +242 -39
- package/dist/adminClient.js.map +1 -1
- package/dist/answersClient.d.ts +2 -0
- package/dist/answersClient.js +221 -11
- package/dist/answersClient.js.map +1 -1
- package/dist/audience/index.d.ts +2 -1
- package/dist/audience/index.js +1 -3
- package/dist/audience/index.js.map +1 -1
- package/dist/audiencesClient.d.ts +18 -16
- package/dist/audiencesClient.js +297 -90
- package/dist/audiencesClient.js.map +1 -1
- package/dist/auditClient.d.ts +2 -0
- package/dist/auditClient.js +227 -15
- package/dist/auditClient.js.map +1 -1
- package/dist/authContext.d.ts +56 -0
- package/dist/authContext.js +170 -0
- package/dist/authContext.js.map +1 -0
- package/dist/authDeviceClient.d.ts +49 -0
- package/dist/authDeviceClient.js +121 -0
- package/dist/authDeviceClient.js.map +1 -0
- package/dist/beliefs/index.d.ts +26 -5
- package/dist/beliefs/index.js +3625 -1140
- package/dist/beliefs/index.js.map +1 -1
- package/dist/beliefsClient.d.ts +4 -2
- package/dist/beliefsClient.js +230 -26
- package/dist/beliefsClient.js.map +1 -1
- package/dist/boundaryClientSurface.d.ts +20 -0
- package/dist/boundaryClientSurface.js +73 -0
- package/dist/boundaryClientSurface.js.map +1 -0
- package/dist/client.d.ts +2988 -27
- package/dist/client.js +3625 -1140
- package/dist/client.js.map +1 -1
- package/dist/clientHelpers.d.ts +48 -0
- package/dist/clientHelpers.js +137 -0
- package/dist/clientHelpers.js.map +1 -0
- package/dist/contextClient.d.ts +6 -3
- package/dist/contextClient.js +252 -30
- package/dist/contextClient.js.map +1 -1
- package/dist/contextFacade.js +25 -16
- package/dist/contextFacade.js.map +1 -1
- package/dist/contextPackCompiler.js +19 -30
- package/dist/contextPackCompiler.js.map +1 -1
- package/dist/contextPackPolicy.js +7 -17
- package/dist/contextPackPolicy.js.map +1 -1
- package/dist/contextTypes.d.ts +2 -0
- package/dist/contracts/api-enums.contract.d.ts +2 -2
- package/dist/contracts/api-enums.contract.js +6 -1
- package/dist/contracts/api-enums.contract.js.map +1 -1
- package/dist/contracts/index.d.ts +1 -0
- package/dist/contracts/index.js +120 -5
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/lens-filter.contract.js +4 -3
- package/dist/contracts/lens-filter.contract.js.map +1 -1
- package/dist/contracts/lens-workflow.contract.js +4 -3
- package/dist/contracts/lens-workflow.contract.js.map +1 -1
- package/dist/contracts/lensFilter.js +4 -3
- package/dist/contracts/lensFilter.js.map +1 -1
- package/dist/contracts/lensWorkflow.js +4 -3
- package/dist/contracts/lensWorkflow.js.map +1 -1
- package/dist/contracts/mcpTools.d.ts +46 -1
- package/dist/contracts/mcpTools.js +108 -0
- package/dist/contracts/mcpTools.js.map +1 -1
- package/dist/contradictions/index.d.ts +25 -4
- package/dist/contradictions/index.js +3625 -1140
- package/dist/contradictions/index.js.map +1 -1
- package/dist/coreClient.d.ts +11 -1
- package/dist/coreClient.js +222 -14
- package/dist/coreClient.js.map +1 -1
- package/dist/decisions/index.d.ts +35 -14
- package/dist/decisions/index.js +3625 -1140
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisionsClient.d.ts +6 -12
- package/dist/decisionsClient.js +235 -37
- package/dist/decisionsClient.js.map +1 -1
- package/dist/edges/index.d.ts +48 -87
- package/dist/edges/index.js +3625 -1140
- package/dist/edges/index.js.map +1 -1
- package/dist/embeddingsClient.d.ts +106 -0
- package/dist/embeddingsClient.js +731 -0
- package/dist/embeddingsClient.js.map +1 -0
- package/dist/eventingClient.d.ts +96 -0
- package/dist/eventingClient.js +728 -0
- package/dist/eventingClient.js.map +1 -0
- package/dist/events.js +6 -3
- package/dist/events.js.map +1 -1
- package/dist/eventsCore.d.ts +3 -1
- package/dist/eventsCore.js +222 -14
- package/dist/eventsCore.js.map +1 -1
- package/dist/evidence/index.d.ts +25 -4
- package/dist/evidence/index.js +3625 -1140
- package/dist/evidence/index.js.map +1 -1
- package/dist/evidenceClient.d.ts +2 -0
- package/dist/evidenceClient.js +222 -14
- package/dist/evidenceClient.js.map +1 -1
- package/dist/facade/context.d.ts +2 -1
- package/dist/facade/context.js +25 -16
- package/dist/facade/context.js.map +1 -1
- package/dist/functionSurface.d.ts +143 -0
- package/dist/functionSurface.js +1204 -0
- package/dist/functionSurface.js.map +1 -0
- package/dist/functionSurfaceClient.d.ts +8 -0
- package/dist/functionSurfaceClient.js +1204 -0
- package/dist/functionSurfaceClient.js.map +1 -0
- package/dist/gatewayFacades.d.ts +64 -46
- package/dist/gatewayFacades.js +461 -128
- package/dist/gatewayFacades.js.map +1 -1
- package/dist/graphAnalysisClient.d.ts +192 -0
- package/dist/graphAnalysisClient.js +799 -0
- package/dist/graphAnalysisClient.js.map +1 -0
- package/dist/graphClient.d.ts +8 -13
- package/dist/graphClient.js +244 -45
- package/dist/graphClient.js.map +1 -1
- package/dist/graphIntel.d.ts +4 -0
- package/dist/graphIntel.js +3 -0
- package/dist/graphIntel.js.map +1 -0
- package/dist/graphIntelligence.d.ts +2 -0
- package/dist/graphIntelligence.js +47 -0
- package/dist/graphIntelligence.js.map +1 -0
- package/dist/graphRecommendationsClient.d.ts +56 -0
- package/dist/graphRecommendationsClient.js +664 -0
- package/dist/graphRecommendationsClient.js.map +1 -0
- package/dist/graphStateClassifierClient.d.ts +73 -0
- package/dist/graphStateClassifierClient.js +716 -0
- package/dist/graphStateClassifierClient.js.map +1 -0
- package/dist/harnessClient.d.ts +15 -24
- package/dist/harnessClient.js +235 -42
- package/dist/harnessClient.js.map +1 -1
- package/dist/identityClient.d.ts +97 -11
- package/dist/identityClient.js +409 -33
- package/dist/identityClient.js.map +1 -1
- package/dist/index.d.ts +30 -5
- package/dist/index.js +4272 -1225
- package/dist/index.js.map +1 -1
- package/dist/infisicalRuntime.d.ts +43 -0
- package/dist/infisicalRuntime.js +346 -0
- package/dist/infisicalRuntime.js.map +1 -0
- package/dist/jobsClient.d.ts +98 -0
- package/dist/jobsClient.js +726 -0
- package/dist/jobsClient.js.map +1 -0
- package/dist/learningClient.d.ts +8 -6
- package/dist/learningClient.js +252 -44
- package/dist/learningClient.js.map +1 -1
- package/dist/lenses/index.d.ts +77 -38
- package/dist/lenses/index.js +3625 -1140
- package/dist/lenses/index.js.map +1 -1
- package/dist/mcpClient.d.ts +28 -0
- package/dist/mcpClient.js +669 -0
- package/dist/mcpClient.js.map +1 -0
- package/dist/modelRuntimeClient.d.ts +72 -0
- package/dist/modelRuntimeClient.js +704 -0
- package/dist/modelRuntimeClient.js.map +1 -0
- package/dist/nodes/index.d.ts +64 -21
- package/dist/nodes/index.js +3625 -1140
- package/dist/nodes/index.js.map +1 -1
- package/dist/ontologies/index.d.ts +54 -32
- package/dist/ontologies/index.js +3625 -1140
- package/dist/ontologies/index.js.map +1 -1
- package/dist/ontologyClient.d.ts +19 -25
- package/dist/ontologyClient.js +258 -40
- package/dist/ontologyClient.js.map +1 -1
- package/dist/ontologyLinksClient.d.ts +71 -0
- package/dist/ontologyLinksClient.js +697 -0
- package/dist/ontologyLinksClient.js.map +1 -0
- package/dist/orgGraphSearchClient.d.ts +85 -0
- package/dist/orgGraphSearchClient.js +672 -0
- package/dist/orgGraphSearchClient.js.map +1 -0
- package/dist/packsClient.d.ts +11 -23
- package/dist/packsClient.js +234 -46
- package/dist/packsClient.js.map +1 -1
- package/dist/policyClient.d.ts +13 -10
- package/dist/policyClient.js +243 -25
- package/dist/policyClient.js.map +1 -1
- package/dist/questions/index.d.ts +25 -4
- package/dist/questions/index.js +3625 -1140
- package/dist/questions/index.js.map +1 -1
- package/dist/realtime/index.d.ts +1 -1
- package/dist/reportsClient.d.ts +9 -7
- package/dist/reportsClient.js +281 -53
- package/dist/reportsClient.js.map +1 -1
- package/dist/schemaClient.d.ts +5 -3
- package/dist/schemaClient.js +235 -29
- package/dist/schemaClient.js.map +1 -1
- package/dist/sdkSurface.d.ts +8 -3
- package/dist/sdkSurface.js +10 -6
- package/dist/sdkSurface.js.map +1 -1
- package/dist/secrets.d.ts +1 -0
- package/dist/secrets.js +3 -0
- package/dist/secrets.js.map +1 -0
- package/dist/sourcesClient.d.ts +2 -0
- package/dist/sourcesClient.js +222 -14
- package/dist/sourcesClient.js.map +1 -1
- package/dist/telemetryClient.d.ts +94 -0
- package/dist/telemetryClient.js +741 -0
- package/dist/telemetryClient.js.map +1 -0
- package/dist/toolRegistryClient.d.ts +115 -0
- package/dist/toolRegistryClient.js +767 -0
- package/dist/toolRegistryClient.js.map +1 -0
- package/dist/topics/index.d.ts +36 -9
- package/dist/topics/index.js +3627 -1140
- package/dist/topics/index.js.map +1 -1
- package/dist/topicsClient.d.ts +4 -0
- package/dist/topicsClient.js +237 -24
- package/dist/topicsClient.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/workflowClient.d.ts +58 -40
- package/dist/workflowClient.js +243 -58
- package/dist/workflowClient.js.map +1 -1
- package/dist/worktrees/index.d.ts +70 -33
- package/dist/worktrees/index.js +3625 -1140
- package/dist/worktrees/index.js.map +1 -1
- package/package.json +13 -3
- package/dist/client-B6aWUUwp.d.ts +0 -2552
package/dist/gatewayFacades.js
CHANGED
|
@@ -1,3 +1,170 @@
|
|
|
1
|
+
// src/authContext.ts
|
|
2
|
+
var LucernSdkAuthContextError = class extends Error {
|
|
3
|
+
reason;
|
|
4
|
+
constructor(reason, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "LucernSdkAuthContextError";
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
function cleanString(value) {
|
|
11
|
+
const normalized = value?.trim();
|
|
12
|
+
return normalized ? normalized : void 0;
|
|
13
|
+
}
|
|
14
|
+
function cleanStringList(values) {
|
|
15
|
+
if (!values) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return values.map((value) => value.trim()).filter(
|
|
19
|
+
(value, index, list) => value.length > 0 && list.indexOf(value) === index
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
function requireString(value, reason, label) {
|
|
23
|
+
const normalized = cleanString(value);
|
|
24
|
+
if (!normalized) {
|
|
25
|
+
throw new LucernSdkAuthContextError(
|
|
26
|
+
reason,
|
|
27
|
+
`Canonical Lucern SDK auth context is missing ${label}.`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
function requirePrincipalType(principalType) {
|
|
33
|
+
if (!principalType) {
|
|
34
|
+
throw new LucernSdkAuthContextError(
|
|
35
|
+
"principal_missing",
|
|
36
|
+
"Canonical Lucern SDK auth context is missing principalType."
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return principalType;
|
|
40
|
+
}
|
|
41
|
+
function requireAuthMode(authMode) {
|
|
42
|
+
if (!authMode) {
|
|
43
|
+
throw new LucernSdkAuthContextError(
|
|
44
|
+
"principal_missing",
|
|
45
|
+
"Canonical Lucern SDK auth context is missing authMode."
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
return authMode;
|
|
49
|
+
}
|
|
50
|
+
function ensurePermitMatch(args) {
|
|
51
|
+
const actual = cleanString(args.actual);
|
|
52
|
+
if (actual && actual !== args.expected) {
|
|
53
|
+
throw new LucernSdkAuthContextError(
|
|
54
|
+
"policy_denied",
|
|
55
|
+
`Canonical Lucern SDK auth context has conflicting Permit ${args.field}.`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function normalizeCanonicalLucernAuthContext(input) {
|
|
60
|
+
if (!input) {
|
|
61
|
+
throw new LucernSdkAuthContextError(
|
|
62
|
+
"principal_missing",
|
|
63
|
+
"Canonical Lucern SDK auth context is required."
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (input.policyDecision === "deny") {
|
|
67
|
+
throw new LucernSdkAuthContextError(
|
|
68
|
+
"policy_denied",
|
|
69
|
+
"Canonical Lucern SDK auth context carries a denied policy decision."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const principalId = requireString(
|
|
73
|
+
input.principalId,
|
|
74
|
+
"principal_missing",
|
|
75
|
+
"principalId"
|
|
76
|
+
);
|
|
77
|
+
const tenantId = requireString(input.tenantId, "tenant_missing", "tenantId");
|
|
78
|
+
const workspaceId = requireString(
|
|
79
|
+
input.workspaceId,
|
|
80
|
+
"workspace_missing",
|
|
81
|
+
"workspaceId"
|
|
82
|
+
);
|
|
83
|
+
const roles = cleanStringList(input.roles);
|
|
84
|
+
const scopes = cleanStringList(input.scopes);
|
|
85
|
+
const principalType = requirePrincipalType(input.principalType);
|
|
86
|
+
const authMode = requireAuthMode(input.authMode);
|
|
87
|
+
const roleBasedInteractiveAuth = authMode === "interactive_user" && roles.length > 0;
|
|
88
|
+
if (roles.length === 0 || scopes.length === 0 && !roleBasedInteractiveAuth) {
|
|
89
|
+
throw new LucernSdkAuthContextError(
|
|
90
|
+
"membership_missing",
|
|
91
|
+
"Canonical Lucern SDK auth context requires non-empty roles and scopes."
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
const subject = cleanString(input.permit?.subject) ?? principalId;
|
|
95
|
+
const tenant = cleanString(input.permit?.tenant) ?? tenantId;
|
|
96
|
+
const workspace = cleanString(input.permit?.workspace) ?? workspaceId;
|
|
97
|
+
ensurePermitMatch({
|
|
98
|
+
field: "subject",
|
|
99
|
+
expected: principalId,
|
|
100
|
+
actual: subject
|
|
101
|
+
});
|
|
102
|
+
ensurePermitMatch({ field: "tenant", expected: tenantId, actual: tenant });
|
|
103
|
+
ensurePermitMatch({
|
|
104
|
+
field: "workspace",
|
|
105
|
+
expected: workspaceId,
|
|
106
|
+
actual: workspace
|
|
107
|
+
});
|
|
108
|
+
const context = input.permit?.context ? { ...input.permit.context } : void 0;
|
|
109
|
+
return {
|
|
110
|
+
clerkId: cleanString(input.clerkId),
|
|
111
|
+
principalId,
|
|
112
|
+
tenantId,
|
|
113
|
+
workspaceId,
|
|
114
|
+
principalType,
|
|
115
|
+
authMode,
|
|
116
|
+
roles,
|
|
117
|
+
scopes,
|
|
118
|
+
delegationChain: input.delegationChain ? [...input.delegationChain] : [],
|
|
119
|
+
policyTraceId: cleanString(input.policyTraceId),
|
|
120
|
+
correlationId: cleanString(input.correlationId),
|
|
121
|
+
membershipId: cleanString(input.membershipId),
|
|
122
|
+
permit: {
|
|
123
|
+
subject,
|
|
124
|
+
tenant,
|
|
125
|
+
workspace,
|
|
126
|
+
resource: cleanString(input.permit?.resource),
|
|
127
|
+
action: cleanString(input.permit?.action),
|
|
128
|
+
relation: cleanString(input.permit?.relation),
|
|
129
|
+
context
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function createCanonicalAuthHeaders(authContext) {
|
|
134
|
+
const headers = {
|
|
135
|
+
"x-lucern-principal-id": authContext.principalId,
|
|
136
|
+
"x-lucern-principal-type": authContext.principalType,
|
|
137
|
+
"x-lucern-tenant": authContext.tenantId,
|
|
138
|
+
"x-lucern-tenant-id": authContext.tenantId,
|
|
139
|
+
"x-lucern-workspace": authContext.workspaceId,
|
|
140
|
+
"x-lucern-workspace-id": authContext.workspaceId,
|
|
141
|
+
"x-lucern-auth-mode": authContext.authMode,
|
|
142
|
+
"x-lucern-roles": authContext.roles.join(","),
|
|
143
|
+
"x-lucern-scopes": authContext.scopes.join(","),
|
|
144
|
+
"x-lucern-permit-context": JSON.stringify(authContext.permit)
|
|
145
|
+
};
|
|
146
|
+
if (authContext.clerkId) {
|
|
147
|
+
headers["x-lucern-clerk-id"] = authContext.clerkId;
|
|
148
|
+
headers["x-lucern-user-id"] = authContext.clerkId;
|
|
149
|
+
}
|
|
150
|
+
if (authContext.delegationChain.length > 0) {
|
|
151
|
+
headers["x-lucern-delegation-chain"] = JSON.stringify(
|
|
152
|
+
authContext.delegationChain
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
if (authContext.policyTraceId) {
|
|
156
|
+
headers["x-lucern-policy-trace-id"] = authContext.policyTraceId;
|
|
157
|
+
}
|
|
158
|
+
if (authContext.correlationId) {
|
|
159
|
+
headers["x-correlation-id"] = authContext.correlationId;
|
|
160
|
+
headers["x-lucern-correlation-id"] = authContext.correlationId;
|
|
161
|
+
}
|
|
162
|
+
if (authContext.membershipId) {
|
|
163
|
+
headers["x-lucern-membership-id"] = authContext.membershipId;
|
|
164
|
+
}
|
|
165
|
+
return headers;
|
|
166
|
+
}
|
|
167
|
+
|
|
1
168
|
// src/coreClient.ts
|
|
2
169
|
var LucernApiError = class extends Error {
|
|
3
170
|
code;
|
|
@@ -65,9 +232,7 @@ function generatePortableRequestId() {
|
|
|
65
232
|
8
|
|
66
233
|
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
67
234
|
}
|
|
68
|
-
|
|
69
|
-
return generatePortableRequestId();
|
|
70
|
-
}
|
|
235
|
+
var randomIdempotencyKey = generatePortableRequestId;
|
|
71
236
|
function isRetryableStatus(status) {
|
|
72
237
|
return status >= 500 || status === 408 || status === 429;
|
|
73
238
|
}
|
|
@@ -132,8 +297,11 @@ function timeoutError(timeoutMs) {
|
|
|
132
297
|
error.name = "AbortError";
|
|
133
298
|
return error;
|
|
134
299
|
}
|
|
300
|
+
function isRecord(value) {
|
|
301
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
302
|
+
}
|
|
135
303
|
function readPolicySummaryFromDetails(details) {
|
|
136
|
-
if (!
|
|
304
|
+
if (!isRecord(details)) {
|
|
137
305
|
return null;
|
|
138
306
|
}
|
|
139
307
|
const directSummary = details.summary;
|
|
@@ -141,11 +309,11 @@ function readPolicySummaryFromDetails(details) {
|
|
|
141
309
|
return directSummary.trim();
|
|
142
310
|
}
|
|
143
311
|
const policy = details.policy;
|
|
144
|
-
if (!
|
|
312
|
+
if (!isRecord(policy)) {
|
|
145
313
|
return null;
|
|
146
314
|
}
|
|
147
315
|
const explanation = policy.explanation;
|
|
148
|
-
if (!
|
|
316
|
+
if (!isRecord(explanation)) {
|
|
149
317
|
return null;
|
|
150
318
|
}
|
|
151
319
|
const nestedSummary = explanation.summary;
|
|
@@ -154,16 +322,41 @@ function readPolicySummaryFromDetails(details) {
|
|
|
154
322
|
}
|
|
155
323
|
return null;
|
|
156
324
|
}
|
|
325
|
+
async function resolveConfiguredAuthContext(authContext) {
|
|
326
|
+
if (typeof authContext === "function") {
|
|
327
|
+
return await authContext();
|
|
328
|
+
}
|
|
329
|
+
return authContext;
|
|
330
|
+
}
|
|
331
|
+
function mergeHeaderRecord(base, addition) {
|
|
332
|
+
const headers = new Headers(base);
|
|
333
|
+
for (const [key, value] of Object.entries(addition)) {
|
|
334
|
+
const existing = headers.get(key);
|
|
335
|
+
if (existing !== null && existing !== value) {
|
|
336
|
+
throw new LucernSdkAuthContextError(
|
|
337
|
+
"policy_denied",
|
|
338
|
+
`Canonical Lucern SDK auth context conflicts with existing ${key} header.`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
headers.set(key, value);
|
|
342
|
+
}
|
|
343
|
+
return Object.fromEntries(headers.entries());
|
|
344
|
+
}
|
|
157
345
|
function createGatewayRequestClient(config = {}) {
|
|
158
346
|
const fetchImpl = config.fetchImpl ?? fetch;
|
|
159
347
|
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
160
348
|
const maxRetries = config.maxRetries ?? 2;
|
|
161
349
|
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
162
350
|
async function resolveAuthHeaders() {
|
|
163
|
-
|
|
164
|
-
|
|
351
|
+
const base = config.getAuthHeaders ? await config.getAuthHeaders() : {};
|
|
352
|
+
const authContextInput = await resolveConfiguredAuthContext(
|
|
353
|
+
config.authContext
|
|
354
|
+
);
|
|
355
|
+
if (!authContextInput && !config.requireCanonicalAuthContext) {
|
|
356
|
+
return base;
|
|
165
357
|
}
|
|
166
|
-
|
|
358
|
+
const authContext = normalizeCanonicalLucernAuthContext(authContextInput);
|
|
359
|
+
return mergeHeaderRecord(base, createCanonicalAuthHeaders(authContext));
|
|
167
360
|
}
|
|
168
361
|
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
169
362
|
const controller = new AbortController();
|
|
@@ -184,11 +377,11 @@ function createGatewayRequestClient(config = {}) {
|
|
|
184
377
|
if (!text) {
|
|
185
378
|
return null;
|
|
186
379
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
} catch {
|
|
380
|
+
const parsed = tryParseGatewayEnvelopeJson(text);
|
|
381
|
+
if (!parsed.ok) {
|
|
190
382
|
return null;
|
|
191
383
|
}
|
|
384
|
+
return isRecord(parsed.value) ? parsed.value : null;
|
|
192
385
|
}
|
|
193
386
|
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
194
387
|
if (typeof requestTimeoutMs === "number") {
|
|
@@ -200,16 +393,31 @@ function createGatewayRequestClient(config = {}) {
|
|
|
200
393
|
}
|
|
201
394
|
return config.timeoutMs ?? 15e3;
|
|
202
395
|
}
|
|
396
|
+
function tryParseGatewayEnvelopeJson(text) {
|
|
397
|
+
const trimmed = text.trim();
|
|
398
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
399
|
+
return { ok: false, reason: "non-json" };
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
return { ok: true, value: JSON.parse(trimmed) };
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (error instanceof SyntaxError) {
|
|
405
|
+
return { ok: false, reason: "invalid-json", error };
|
|
406
|
+
}
|
|
407
|
+
throw error;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
203
410
|
function buildApiError(args) {
|
|
204
411
|
const failure = args.failure;
|
|
205
|
-
const legacyError = failure &&
|
|
412
|
+
const legacyError = failure && isRecord(failure.error) ? failure.error : failure?.legacyError;
|
|
206
413
|
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
207
414
|
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
208
415
|
const details = failure?.details ?? legacyError?.details;
|
|
209
416
|
const policySummary = readPolicySummaryFromDetails(details);
|
|
417
|
+
const failureMessage = typeof failure?.error === "string" ? failure.error : legacyError?.message;
|
|
210
418
|
return new LucernApiError({
|
|
211
419
|
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
212
|
-
message: policySummary ??
|
|
420
|
+
message: policySummary ?? failureMessage ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed."),
|
|
213
421
|
status: args.response.status,
|
|
214
422
|
invariant: failure?.invariant,
|
|
215
423
|
suggestion: failure?.suggestion,
|
|
@@ -335,14 +543,17 @@ function createGatewayRequestClient(config = {}) {
|
|
|
335
543
|
}
|
|
336
544
|
|
|
337
545
|
// src/sdkSurface.ts
|
|
546
|
+
function isRecord2(value) {
|
|
547
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
548
|
+
}
|
|
338
549
|
function asRecord(value) {
|
|
339
|
-
return value
|
|
550
|
+
return isRecord2(value) ? value : {};
|
|
340
551
|
}
|
|
341
|
-
function
|
|
552
|
+
function cleanString2(value) {
|
|
342
553
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
343
554
|
}
|
|
344
555
|
function normalizeVerificationStatus(value) {
|
|
345
|
-
const status =
|
|
556
|
+
const status = cleanString2(value);
|
|
346
557
|
if (!status) {
|
|
347
558
|
return void 0;
|
|
348
559
|
}
|
|
@@ -358,20 +569,20 @@ function cloneWith(value, patch) {
|
|
|
358
569
|
return { ...value, ...patch };
|
|
359
570
|
}
|
|
360
571
|
function resolveTopicId(value) {
|
|
361
|
-
return
|
|
572
|
+
return cleanString2(value.topicId);
|
|
362
573
|
}
|
|
363
574
|
function resolveText(value) {
|
|
364
|
-
return
|
|
575
|
+
return cleanString2(value.text) ?? cleanString2(value.canonicalText);
|
|
365
576
|
}
|
|
366
577
|
function withTopicAlias(value) {
|
|
367
|
-
const topicId =
|
|
578
|
+
const topicId = cleanString2(value.topicId) ?? void 0;
|
|
368
579
|
if (!topicId) {
|
|
369
580
|
return value;
|
|
370
581
|
}
|
|
371
582
|
return cloneWith(value, { topicId });
|
|
372
583
|
}
|
|
373
584
|
function withTextAlias(value) {
|
|
374
|
-
const text =
|
|
585
|
+
const text = cleanString2(value.text) ?? cleanString2(value.canonicalText) ?? void 0;
|
|
375
586
|
if (!text) {
|
|
376
587
|
return value;
|
|
377
588
|
}
|
|
@@ -397,11 +608,9 @@ function normalizeNodeWriteInput(value) {
|
|
|
397
608
|
}
|
|
398
609
|
return next;
|
|
399
610
|
}
|
|
400
|
-
|
|
401
|
-
return normalizeVerificationStatus(value);
|
|
402
|
-
}
|
|
611
|
+
var normalizeNodeVerificationStatus = normalizeVerificationStatus;
|
|
403
612
|
function normalizeTopicQuery(value) {
|
|
404
|
-
const topicId =
|
|
613
|
+
const topicId = cleanString2(value.topicId);
|
|
405
614
|
if (!topicId) {
|
|
406
615
|
return value;
|
|
407
616
|
}
|
|
@@ -426,7 +635,10 @@ function createListResult(items, legacyKey) {
|
|
|
426
635
|
total: items.length
|
|
427
636
|
};
|
|
428
637
|
if (legacyKey) {
|
|
429
|
-
|
|
638
|
+
return {
|
|
639
|
+
...result,
|
|
640
|
+
[legacyKey]: items
|
|
641
|
+
};
|
|
430
642
|
}
|
|
431
643
|
return result;
|
|
432
644
|
}
|
|
@@ -446,7 +658,7 @@ function mapAliasedList(data, legacyKey) {
|
|
|
446
658
|
// src/ontologyClient.ts
|
|
447
659
|
function createOntologyClient(config = {}) {
|
|
448
660
|
const gateway = createGatewayRequestClient(config);
|
|
449
|
-
|
|
661
|
+
const client = {
|
|
450
662
|
/**
|
|
451
663
|
* List ontology definitions matching optional filters.
|
|
452
664
|
*/
|
|
@@ -455,13 +667,14 @@ function createOntologyClient(config = {}) {
|
|
|
455
667
|
path: `/api/platform/v1/ontologies${toQueryString(filters)}`
|
|
456
668
|
}).then(
|
|
457
669
|
(response) => mapGatewayData(response, (data) => {
|
|
458
|
-
const record =
|
|
459
|
-
const ontologies =
|
|
460
|
-
const
|
|
670
|
+
const record = asRecord(data);
|
|
671
|
+
const ontologies = asListItems(data, "ontologies");
|
|
672
|
+
const definitions = ontologies.length > 0 ? ontologies : asListItems(data, "definitions");
|
|
673
|
+
const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : definitions.length;
|
|
461
674
|
return {
|
|
462
675
|
...record,
|
|
463
|
-
...createListResult(
|
|
464
|
-
ontologies,
|
|
676
|
+
...createListResult(definitions, "definitions"),
|
|
677
|
+
ontologies: definitions,
|
|
465
678
|
total
|
|
466
679
|
};
|
|
467
680
|
})
|
|
@@ -488,18 +701,6 @@ function createOntologyClient(config = {}) {
|
|
|
488
701
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
489
702
|
});
|
|
490
703
|
},
|
|
491
|
-
/**
|
|
492
|
-
* List ontology definitions.
|
|
493
|
-
*/
|
|
494
|
-
async listDefinitions(filters = {}) {
|
|
495
|
-
return this.list(filters);
|
|
496
|
-
},
|
|
497
|
-
/**
|
|
498
|
-
* Get an ontology definition.
|
|
499
|
-
*/
|
|
500
|
-
async getDefinition(id) {
|
|
501
|
-
return this.get(id);
|
|
502
|
-
},
|
|
503
704
|
/**
|
|
504
705
|
* Create an ontology definition.
|
|
505
706
|
*/
|
|
@@ -541,7 +742,7 @@ function createOntologyClient(config = {}) {
|
|
|
541
742
|
}).then(
|
|
542
743
|
(response) => mapGatewayData(
|
|
543
744
|
response,
|
|
544
|
-
(data) => createListResult(
|
|
745
|
+
(data) => createListResult(asListItems(data, "versions"), "versions")
|
|
545
746
|
)
|
|
546
747
|
);
|
|
547
748
|
},
|
|
@@ -589,20 +790,19 @@ function createOntologyClient(config = {}) {
|
|
|
589
790
|
(data) => createListResult(Array.isArray(data) ? data : [], "topics")
|
|
590
791
|
)
|
|
591
792
|
);
|
|
592
|
-
},
|
|
593
|
-
/**
|
|
594
|
-
* @deprecated Use listTopics.
|
|
595
|
-
*/
|
|
596
|
-
async listTopicsByOntology(ontologyId) {
|
|
597
|
-
return this.listTopics(ontologyId);
|
|
598
793
|
}
|
|
599
794
|
};
|
|
795
|
+
return Object.assign(client, {
|
|
796
|
+
listDefinitions: client.list,
|
|
797
|
+
getDefinition: client.get,
|
|
798
|
+
listTopicsByOntology: client.listTopics
|
|
799
|
+
});
|
|
600
800
|
}
|
|
601
801
|
|
|
602
802
|
// src/graphClient.ts
|
|
603
803
|
function createGraphClient(config = {}) {
|
|
604
804
|
const gateway = createGatewayRequestClient(config);
|
|
605
|
-
|
|
805
|
+
const client = {
|
|
606
806
|
/**
|
|
607
807
|
* List graph nodes matching the provided filters.
|
|
608
808
|
*/
|
|
@@ -615,12 +815,6 @@ function createGraphClient(config = {}) {
|
|
|
615
815
|
(response) => mapGatewayData(response, (data) => mapAliasedList(data, "nodes"))
|
|
616
816
|
);
|
|
617
817
|
},
|
|
618
|
-
/**
|
|
619
|
-
* @deprecated Use listNodes.
|
|
620
|
-
*/
|
|
621
|
-
async queryNodes(query) {
|
|
622
|
-
return this.listNodes(query);
|
|
623
|
-
},
|
|
624
818
|
/**
|
|
625
819
|
* Retrieve a single graph node by nodeId or globalId.
|
|
626
820
|
*/
|
|
@@ -731,12 +925,6 @@ function createGraphClient(config = {}) {
|
|
|
731
925
|
)
|
|
732
926
|
);
|
|
733
927
|
},
|
|
734
|
-
/**
|
|
735
|
-
* @deprecated Use listEdges.
|
|
736
|
-
*/
|
|
737
|
-
async queryEdges(query) {
|
|
738
|
-
return this.listEdges(query);
|
|
739
|
-
},
|
|
740
928
|
/**
|
|
741
929
|
* Create a graph edge.
|
|
742
930
|
*/
|
|
@@ -824,12 +1012,6 @@ function createGraphClient(config = {}) {
|
|
|
824
1012
|
body: normalizeTopicQuery(query)
|
|
825
1013
|
});
|
|
826
1014
|
},
|
|
827
|
-
/**
|
|
828
|
-
* Retrieve a graph neighborhood around a root node.
|
|
829
|
-
*/
|
|
830
|
-
async getNeighborhood(query) {
|
|
831
|
-
return this.neighborhood(query);
|
|
832
|
-
},
|
|
833
1015
|
/**
|
|
834
1016
|
* Retrieve the shortest known path between two graph nodes.
|
|
835
1017
|
*/
|
|
@@ -847,6 +1029,48 @@ function createGraphClient(config = {}) {
|
|
|
847
1029
|
});
|
|
848
1030
|
}
|
|
849
1031
|
};
|
|
1032
|
+
return Object.assign(client, {
|
|
1033
|
+
queryNodes: client.listNodes,
|
|
1034
|
+
queryEdges: client.listEdges,
|
|
1035
|
+
getNeighborhood: client.neighborhood
|
|
1036
|
+
});
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
// src/boundaryClientSurface.ts
|
|
1040
|
+
function cleanOptionalString(value) {
|
|
1041
|
+
const normalized = value?.trim();
|
|
1042
|
+
return normalized ? normalized : void 0;
|
|
1043
|
+
}
|
|
1044
|
+
function isRecord3(value) {
|
|
1045
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1046
|
+
}
|
|
1047
|
+
function cleanRequiredString(value, label) {
|
|
1048
|
+
const normalized = cleanOptionalString(value);
|
|
1049
|
+
if (!normalized) {
|
|
1050
|
+
throw new Error(`${label} is required`);
|
|
1051
|
+
}
|
|
1052
|
+
return normalized;
|
|
1053
|
+
}
|
|
1054
|
+
function assertKnownKeys(input, allowed, operation) {
|
|
1055
|
+
const allowedSet = new Set(allowed);
|
|
1056
|
+
const unknownKeys = Object.keys(input).filter((key) => !allowedSet.has(key));
|
|
1057
|
+
if (unknownKeys.length > 0) {
|
|
1058
|
+
throw new Error(
|
|
1059
|
+
`${operation} received unsupported field(s): ${unknownKeys.join(", ")}`
|
|
1060
|
+
);
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
function knownPayload(input, allowed, operation) {
|
|
1064
|
+
assertKnownKeys(input, allowed, operation);
|
|
1065
|
+
return { ...input };
|
|
1066
|
+
}
|
|
1067
|
+
function listResultFromEnvelope(data, legacyKey) {
|
|
1068
|
+
const record = isRecord3(data) ? data : {};
|
|
1069
|
+
const legacyItems = record[legacyKey];
|
|
1070
|
+
return createListResult(
|
|
1071
|
+
Array.isArray(legacyItems) ? legacyItems : Array.isArray(data) ? data : [],
|
|
1072
|
+
legacyKey
|
|
1073
|
+
);
|
|
850
1074
|
}
|
|
851
1075
|
|
|
852
1076
|
// src/identityClient.ts
|
|
@@ -860,6 +1084,37 @@ function createIdentityWhoamiClient(config = {}) {
|
|
|
860
1084
|
}
|
|
861
1085
|
};
|
|
862
1086
|
}
|
|
1087
|
+
var TENANT_IDENTITY_FIELDS = [
|
|
1088
|
+
"tenantId",
|
|
1089
|
+
"workspaceId",
|
|
1090
|
+
"principalId",
|
|
1091
|
+
"integrationKey",
|
|
1092
|
+
"secretRef",
|
|
1093
|
+
"policySubject",
|
|
1094
|
+
"policyAction",
|
|
1095
|
+
"policyResource",
|
|
1096
|
+
"decision",
|
|
1097
|
+
"config",
|
|
1098
|
+
"configKey",
|
|
1099
|
+
"configValue",
|
|
1100
|
+
"provider",
|
|
1101
|
+
"status",
|
|
1102
|
+
"metadata",
|
|
1103
|
+
"limit",
|
|
1104
|
+
"cursor"
|
|
1105
|
+
];
|
|
1106
|
+
function tenantIdentityQuery(input) {
|
|
1107
|
+
return {
|
|
1108
|
+
tenantId: cleanRequiredString(input.tenantId, "tenantId"),
|
|
1109
|
+
workspaceId: input.workspaceId,
|
|
1110
|
+
principalId: input.principalId,
|
|
1111
|
+
limit: input.limit,
|
|
1112
|
+
cursor: input.cursor
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
function tenantIdentityBody(input, operation) {
|
|
1116
|
+
return knownPayload(input, TENANT_IDENTITY_FIELDS, operation);
|
|
1117
|
+
}
|
|
863
1118
|
function createIdentityClient(config = {}) {
|
|
864
1119
|
const gateway = createGatewayRequestClient(config);
|
|
865
1120
|
const whoamiClient = createIdentityWhoamiClient(config);
|
|
@@ -869,6 +1124,13 @@ function createIdentityClient(config = {}) {
|
|
|
869
1124
|
body: input,
|
|
870
1125
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
871
1126
|
});
|
|
1127
|
+
const updatePrincipal = (input, idempotencyKey) => requestPrincipalWrite("PATCH", input, idempotencyKey);
|
|
1128
|
+
const deleteKey = (keyId, input = {}, idempotencyKey) => gateway.request({
|
|
1129
|
+
path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
|
|
1130
|
+
method: "POST",
|
|
1131
|
+
body: input,
|
|
1132
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1133
|
+
});
|
|
872
1134
|
return {
|
|
873
1135
|
/**
|
|
874
1136
|
* Resolve the current authenticated identity summary.
|
|
@@ -917,15 +1179,11 @@ function createIdentityClient(config = {}) {
|
|
|
917
1179
|
/**
|
|
918
1180
|
* Update a principal.
|
|
919
1181
|
*/
|
|
920
|
-
|
|
921
|
-
return requestPrincipalWrite("PATCH", input, idempotencyKey);
|
|
922
|
-
},
|
|
1182
|
+
updatePrincipal,
|
|
923
1183
|
/**
|
|
924
1184
|
* @deprecated Use createPrincipal or updatePrincipal.
|
|
925
1185
|
*/
|
|
926
|
-
|
|
927
|
-
return requestPrincipalWrite("PATCH", input, idempotencyKey);
|
|
928
|
-
},
|
|
1186
|
+
upsertPrincipal: updatePrincipal,
|
|
929
1187
|
/**
|
|
930
1188
|
* List keys in the current identity scope.
|
|
931
1189
|
*/
|
|
@@ -964,20 +1222,11 @@ function createIdentityClient(config = {}) {
|
|
|
964
1222
|
/**
|
|
965
1223
|
* Delete an API key by revoking it.
|
|
966
1224
|
*/
|
|
967
|
-
|
|
968
|
-
return gateway.request({
|
|
969
|
-
path: `/api/platform/v1/identity/keys/${encodeURIComponent(keyId)}/revoke`,
|
|
970
|
-
method: "POST",
|
|
971
|
-
body: input,
|
|
972
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
973
|
-
});
|
|
974
|
-
},
|
|
1225
|
+
deleteKey,
|
|
975
1226
|
/**
|
|
976
1227
|
* @deprecated Use deleteKey.
|
|
977
1228
|
*/
|
|
978
|
-
|
|
979
|
-
return this.deleteKey(keyId, input, idempotencyKey);
|
|
980
|
-
},
|
|
1229
|
+
revokeKey: deleteKey,
|
|
981
1230
|
/**
|
|
982
1231
|
* Search Clerk users by email or display attributes.
|
|
983
1232
|
*/
|
|
@@ -985,20 +1234,120 @@ function createIdentityClient(config = {}) {
|
|
|
985
1234
|
return gateway.request({
|
|
986
1235
|
path: `/api/platform/v1/identity/clerk-users${toQueryString({ q })}`
|
|
987
1236
|
});
|
|
1237
|
+
},
|
|
1238
|
+
async getTenantConfig(input) {
|
|
1239
|
+
return gateway.request({
|
|
1240
|
+
path: `/api/platform/v1/identity/tenant-config${toQueryString(
|
|
1241
|
+
tenantIdentityQuery(input)
|
|
1242
|
+
)}`
|
|
1243
|
+
});
|
|
1244
|
+
},
|
|
1245
|
+
async updateTenantConfig(input, idempotencyKey) {
|
|
1246
|
+
cleanRequiredString(input.tenantId, "tenantId");
|
|
1247
|
+
return gateway.request({
|
|
1248
|
+
path: "/api/platform/v1/identity/tenant-config",
|
|
1249
|
+
method: "PATCH",
|
|
1250
|
+
body: tenantIdentityBody(
|
|
1251
|
+
input,
|
|
1252
|
+
"identity.updateTenantConfig"
|
|
1253
|
+
),
|
|
1254
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1255
|
+
});
|
|
1256
|
+
},
|
|
1257
|
+
async listIntegrations(input) {
|
|
1258
|
+
return gateway.request({
|
|
1259
|
+
path: `/api/platform/v1/identity/integrations${toQueryString(
|
|
1260
|
+
tenantIdentityQuery(input)
|
|
1261
|
+
)}`
|
|
1262
|
+
}).then(
|
|
1263
|
+
(response) => mapGatewayData(
|
|
1264
|
+
response,
|
|
1265
|
+
(data) => listResultFromEnvelope(
|
|
1266
|
+
data,
|
|
1267
|
+
"integrations"
|
|
1268
|
+
)
|
|
1269
|
+
)
|
|
1270
|
+
);
|
|
1271
|
+
},
|
|
1272
|
+
async upsertIntegration(input, idempotencyKey) {
|
|
1273
|
+
cleanRequiredString(input.tenantId, "tenantId");
|
|
1274
|
+
cleanRequiredString(input.integrationKey, "integrationKey");
|
|
1275
|
+
return gateway.request({
|
|
1276
|
+
path: "/api/platform/v1/identity/integrations",
|
|
1277
|
+
method: "PUT",
|
|
1278
|
+
body: tenantIdentityBody(
|
|
1279
|
+
input,
|
|
1280
|
+
"identity.upsertIntegration"
|
|
1281
|
+
),
|
|
1282
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1283
|
+
});
|
|
1284
|
+
},
|
|
1285
|
+
async listSecrets(input) {
|
|
1286
|
+
return gateway.request({
|
|
1287
|
+
path: `/api/platform/v1/identity/secrets${toQueryString(
|
|
1288
|
+
tenantIdentityQuery(input)
|
|
1289
|
+
)}`
|
|
1290
|
+
}).then(
|
|
1291
|
+
(response) => mapGatewayData(
|
|
1292
|
+
response,
|
|
1293
|
+
(data) => listResultFromEnvelope(
|
|
1294
|
+
data,
|
|
1295
|
+
"secrets"
|
|
1296
|
+
)
|
|
1297
|
+
)
|
|
1298
|
+
);
|
|
1299
|
+
},
|
|
1300
|
+
async putSecretReference(input, idempotencyKey) {
|
|
1301
|
+
cleanRequiredString(input.tenantId, "tenantId");
|
|
1302
|
+
cleanRequiredString(input.secretRef, "secretRef");
|
|
1303
|
+
return gateway.request({
|
|
1304
|
+
path: "/api/platform/v1/identity/secrets",
|
|
1305
|
+
method: "PUT",
|
|
1306
|
+
body: tenantIdentityBody(
|
|
1307
|
+
input,
|
|
1308
|
+
"identity.putSecretReference"
|
|
1309
|
+
),
|
|
1310
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1311
|
+
});
|
|
1312
|
+
},
|
|
1313
|
+
async evaluatePolicy(input, idempotencyKey) {
|
|
1314
|
+
cleanRequiredString(input.tenantId, "tenantId");
|
|
1315
|
+
cleanRequiredString(input.policySubject, "policySubject");
|
|
1316
|
+
cleanRequiredString(input.policyAction, "policyAction");
|
|
1317
|
+
cleanRequiredString(input.policyResource, "policyResource");
|
|
1318
|
+
return gateway.request({
|
|
1319
|
+
path: "/api/platform/v1/identity/policy/evaluate",
|
|
1320
|
+
method: "POST",
|
|
1321
|
+
body: tenantIdentityBody(
|
|
1322
|
+
input,
|
|
1323
|
+
"identity.evaluatePolicy"
|
|
1324
|
+
),
|
|
1325
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1326
|
+
});
|
|
1327
|
+
},
|
|
1328
|
+
async recordPolicyDecision(input, idempotencyKey) {
|
|
1329
|
+
cleanRequiredString(input.tenantId, "tenantId");
|
|
1330
|
+
cleanRequiredString(input.decision, "decision");
|
|
1331
|
+
return gateway.request({
|
|
1332
|
+
path: "/api/platform/v1/identity/policy/decisions",
|
|
1333
|
+
method: "POST",
|
|
1334
|
+
body: tenantIdentityBody(
|
|
1335
|
+
input,
|
|
1336
|
+
"identity.recordPolicyDecision"
|
|
1337
|
+
),
|
|
1338
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1339
|
+
});
|
|
988
1340
|
}
|
|
989
1341
|
};
|
|
990
1342
|
}
|
|
991
1343
|
|
|
992
1344
|
// src/topicsClient.ts
|
|
993
|
-
function
|
|
994
|
-
return value && typeof value === "object" ? value : {};
|
|
995
|
-
}
|
|
996
|
-
function cleanString2(value) {
|
|
1345
|
+
function cleanString3(value) {
|
|
997
1346
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
998
1347
|
}
|
|
999
1348
|
function normalizeTopicRecord(value) {
|
|
1000
|
-
const record =
|
|
1001
|
-
const topicId =
|
|
1349
|
+
const record = asRecord(value);
|
|
1350
|
+
const topicId = cleanString3(record.topicId) ?? cleanString3(record.id) ?? cleanString3(record._id);
|
|
1002
1351
|
return withTopicAlias({
|
|
1003
1352
|
...record,
|
|
1004
1353
|
...topicId ? { topicId } : {}
|
|
@@ -1022,7 +1371,7 @@ function createTopicsClient(config = {}) {
|
|
|
1022
1371
|
})}`
|
|
1023
1372
|
}).then(
|
|
1024
1373
|
(response) => mapGatewayData(response, (data) => {
|
|
1025
|
-
const record =
|
|
1374
|
+
const record = asRecord(data);
|
|
1026
1375
|
const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
|
|
1027
1376
|
return {
|
|
1028
1377
|
...createListResult(items, "topics"),
|
|
@@ -1039,7 +1388,7 @@ function createTopicsClient(config = {}) {
|
|
|
1039
1388
|
}).then(
|
|
1040
1389
|
(response) => mapGatewayData(
|
|
1041
1390
|
response,
|
|
1042
|
-
(data) => normalizeTopicRecord(
|
|
1391
|
+
(data) => normalizeTopicRecord(asRecord(data).topic ?? data)
|
|
1043
1392
|
)
|
|
1044
1393
|
);
|
|
1045
1394
|
},
|
|
@@ -1075,7 +1424,7 @@ function createTopicsClient(config = {}) {
|
|
|
1075
1424
|
)}`
|
|
1076
1425
|
}).then(
|
|
1077
1426
|
(response) => mapGatewayData(response, (data) => {
|
|
1078
|
-
const record =
|
|
1427
|
+
const record = asRecord(data);
|
|
1079
1428
|
return {
|
|
1080
1429
|
tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
|
|
1081
1430
|
};
|
|
@@ -1494,7 +1843,7 @@ function createEventsFacade(config = {}) {
|
|
|
1494
1843
|
function createGraphFacade(config = {}) {
|
|
1495
1844
|
const graphClient = createGraphClient(config);
|
|
1496
1845
|
const gateway = createGatewayRequestClient(config);
|
|
1497
|
-
|
|
1846
|
+
const graphFacade = {
|
|
1498
1847
|
async neighborhood(input) {
|
|
1499
1848
|
return graphClient.neighborhood({
|
|
1500
1849
|
globalId: input.globalId,
|
|
@@ -1502,18 +1851,6 @@ function createGraphFacade(config = {}) {
|
|
|
1502
1851
|
maxDepth: input.maxDepth
|
|
1503
1852
|
});
|
|
1504
1853
|
},
|
|
1505
|
-
async traverse(input) {
|
|
1506
|
-
return graphClient.traverse(input);
|
|
1507
|
-
},
|
|
1508
|
-
async analyze(input = {}) {
|
|
1509
|
-
return graphClient.analyze(input);
|
|
1510
|
-
},
|
|
1511
|
-
async bias(input = {}) {
|
|
1512
|
-
return graphClient.bias(input);
|
|
1513
|
-
},
|
|
1514
|
-
async gaps(input) {
|
|
1515
|
-
return graphClient.gaps(input);
|
|
1516
|
-
},
|
|
1517
1854
|
async falsify(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1518
1855
|
return gateway.request({
|
|
1519
1856
|
path: "/api/platform/v1/graph/falsify",
|
|
@@ -1523,6 +1860,12 @@ function createGraphFacade(config = {}) {
|
|
|
1523
1860
|
});
|
|
1524
1861
|
}
|
|
1525
1862
|
};
|
|
1863
|
+
return Object.assign(graphFacade, {
|
|
1864
|
+
traverse: graphClient.traverse,
|
|
1865
|
+
analyze: graphClient.analyze,
|
|
1866
|
+
bias: graphClient.bias,
|
|
1867
|
+
gaps: graphClient.gaps
|
|
1868
|
+
});
|
|
1526
1869
|
}
|
|
1527
1870
|
function createIdentityFacade(config = {}) {
|
|
1528
1871
|
const identityClient = createIdentityClient(config);
|
|
@@ -1536,15 +1879,12 @@ function createIdentityFacade(config = {}) {
|
|
|
1536
1879
|
function createOntologiesFacade(config = {}) {
|
|
1537
1880
|
const ontologyClient = createOntologyClient(config);
|
|
1538
1881
|
const gateway = createGatewayRequestClient(config);
|
|
1539
|
-
|
|
1882
|
+
const ontologyFacade = {
|
|
1540
1883
|
async get(id) {
|
|
1541
1884
|
return gateway.request({
|
|
1542
1885
|
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
|
|
1543
1886
|
});
|
|
1544
1887
|
},
|
|
1545
|
-
async list(query = {}) {
|
|
1546
|
-
return ontologyClient.list(query);
|
|
1547
|
-
},
|
|
1548
1888
|
async bind(input, idempotencyKey) {
|
|
1549
1889
|
return gateway.request({
|
|
1550
1890
|
path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
|
|
@@ -1564,6 +1904,9 @@ function createOntologiesFacade(config = {}) {
|
|
|
1564
1904
|
});
|
|
1565
1905
|
}
|
|
1566
1906
|
};
|
|
1907
|
+
return Object.assign(ontologyFacade, {
|
|
1908
|
+
list: ontologyClient.list
|
|
1909
|
+
});
|
|
1567
1910
|
}
|
|
1568
1911
|
function createQuestionsFacade(config = {}) {
|
|
1569
1912
|
const gateway = createGatewayRequestClient(config);
|
|
@@ -1756,15 +2099,9 @@ function createTasksFacade(config = {}) {
|
|
|
1756
2099
|
function createTopicsFacade(config = {}) {
|
|
1757
2100
|
const topicsClient = createTopicsClient(config);
|
|
1758
2101
|
return {
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
async get(id) {
|
|
1763
|
-
return topicsClient.get(id);
|
|
1764
|
-
},
|
|
1765
|
-
async list(query = {}) {
|
|
1766
|
-
return topicsClient.list(query);
|
|
1767
|
-
},
|
|
2102
|
+
create: topicsClient.create,
|
|
2103
|
+
get: topicsClient.get,
|
|
2104
|
+
list: topicsClient.list,
|
|
1768
2105
|
async update(input, idempotencyKey) {
|
|
1769
2106
|
const { id, ...rest } = input;
|
|
1770
2107
|
return topicsClient.update(id, rest, idempotencyKey);
|
|
@@ -1780,12 +2117,8 @@ function createTopicsFacade(config = {}) {
|
|
|
1780
2117
|
maxDepth: input.maxDepth
|
|
1781
2118
|
});
|
|
1782
2119
|
},
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
},
|
|
1786
|
-
async bulkCreate(input, idempotencyKey = randomIdempotencyKey()) {
|
|
1787
|
-
return topicsClient.bulkCreate(input, idempotencyKey);
|
|
1788
|
-
}
|
|
2120
|
+
remove: topicsClient.remove,
|
|
2121
|
+
bulkCreate: topicsClient.bulkCreate
|
|
1789
2122
|
};
|
|
1790
2123
|
}
|
|
1791
2124
|
function createWebhooksFacade(config = {}) {
|