@lucern/sdk 0.2.0-alpha.12 → 0.2.0-alpha.2
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/README.md +166 -609
- package/dist/index.js +3539 -6269
- package/dist/index.js.map +1 -1
- package/dist/{contracts → lucern/contracts/src}/auth-session.contract.d.ts +12 -14
- package/dist/{contracts → lucern/contracts/src}/context-pack.contract.d.ts +58 -56
- package/dist/{contracts → lucern/contracts/src}/lens-filter.contract.d.ts +8 -10
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +84 -0
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +151 -0
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +161 -0
- package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +119 -0
- package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +18 -0
- package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +78 -0
- package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +53 -0
- package/dist/lucern/packages/client-core/src/beliefs.d.ts +30 -0
- package/dist/lucern/packages/client-core/src/context.d.ts +29 -0
- package/dist/lucern/packages/client-core/src/contradictions.d.ts +11 -0
- package/dist/lucern/packages/client-core/src/edges.d.ts +11 -0
- package/dist/lucern/packages/client-core/src/events.d.ts +9 -0
- package/dist/lucern/packages/client-core/src/evidence.d.ts +21 -0
- package/dist/lucern/packages/client-core/src/graph.d.ts +17 -0
- package/dist/lucern/packages/client-core/src/identity.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/ids.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/ontologies.d.ts +13 -0
- package/dist/lucern/packages/client-core/src/questions.d.ts +39 -0
- package/dist/lucern/packages/client-core/src/search.d.ts +7 -0
- package/dist/lucern/packages/client-core/src/tasks.d.ts +13 -0
- package/dist/lucern/packages/client-core/src/topics.d.ts +17 -0
- package/dist/lucern/packages/client-core/src/webhooks.d.ts +35 -0
- package/dist/lucern/packages/client-core/src/worktrees.d.ts +17 -0
- package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +283 -0
- package/dist/lucern/packages/domain-beliefs/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-context/src/compile.d.ts +11 -0
- package/dist/{contextPackCompiler.d.ts → lucern/packages/domain-context/src/context-pack-compiler.d.ts} +10 -11
- package/dist/lucern/packages/domain-context/src/index.d.ts +4 -0
- package/dist/lucern/packages/domain-context/src/ports.d.ts +58 -0
- package/dist/lucern/packages/domain-context/src/public-types.d.ts +1 -0
- package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +59 -0
- package/dist/lucern/packages/domain-edges/src/edges.d.ts +91 -0
- package/dist/lucern/packages/domain-edges/src/index.d.ts +2 -0
- package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +115 -0
- package/dist/lucern/packages/domain-evidence/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-graph/src/graph.d.ts +150 -0
- package/dist/lucern/packages/domain-identity/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-identity/src/whoami.d.ts +13 -0
- package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +123 -0
- package/dist/lucern/packages/domain-questions/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-questions/src/questions.d.ts +147 -0
- package/dist/lucern/packages/domain-search/src/search.d.ts +97 -0
- package/dist/lucern/packages/domain-tasks/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +102 -0
- package/dist/lucern/packages/domain-topics/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-topics/src/topics.d.ts +147 -0
- package/dist/lucern/packages/domain-worktrees/src/index.d.ts +1 -0
- package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +185 -0
- package/dist/lucern/packages/events/src/index.d.ts +4 -0
- package/dist/lucern/packages/events/src/matching.d.ts +3 -0
- package/dist/lucern/packages/events/src/outbox.d.ts +15 -0
- package/dist/lucern/packages/events/src/types.d.ts +151 -0
- package/dist/lucern/packages/events/src/webhooks.d.ts +9 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +15 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +12 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +7 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +7 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +6 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +21 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +5 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +8 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +39 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +5 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +8 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +16 -0
- package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +10 -0
- package/dist/lucern/packages/sdk-typescript/src/index.d.ts +28 -0
- package/dist/packages/sdk/src/adminClient.d.ts +89 -0
- package/dist/packages/sdk/src/answersClient.d.ts +5 -0
- package/dist/{audiencesClient.d.ts → packages/sdk/src/audiencesClient.d.ts} +18 -30
- package/dist/packages/sdk/src/auditClient.d.ts +21 -0
- package/dist/packages/sdk/src/beliefsClient.d.ts +52 -0
- package/dist/packages/sdk/src/client.d.ts +1558 -0
- package/dist/packages/sdk/src/contextClient.d.ts +9 -0
- package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +58 -0
- package/dist/{controlObjectOwnership.d.ts → packages/sdk/src/controlObjectOwnership.d.ts} +18 -35
- package/dist/{coreClient.d.ts → packages/sdk/src/coreClient.d.ts} +14 -38
- package/dist/packages/sdk/src/customTools.d.ts +65 -0
- package/dist/packages/sdk/src/decisionsClient.d.ts +97 -0
- package/dist/packages/sdk/src/graphClient.d.ts +191 -0
- package/dist/{harnessClient.d.ts → packages/sdk/src/harnessClient.d.ts} +33 -127
- package/dist/packages/sdk/src/identityClient.d.ts +104 -0
- package/dist/packages/sdk/src/index.d.ts +28 -0
- package/dist/packages/sdk/src/learningClient.d.ts +37 -0
- package/dist/{mcpParityClient.d.ts → packages/sdk/src/mcpParityClient.d.ts} +5 -11
- package/dist/packages/sdk/src/mcpParitySurface.d.ts +8 -0
- package/dist/{ontologyClient.d.ts → packages/sdk/src/ontologyClient.d.ts} +22 -44
- package/dist/packages/sdk/src/packsClient.d.ts +101 -0
- package/dist/{policyClient.d.ts → packages/sdk/src/policyClient.d.ts} +18 -113
- package/dist/packages/sdk/src/reportsClient.d.ts +31 -0
- package/dist/packages/sdk/src/schemaClient.d.ts +54 -0
- package/dist/packages/sdk/src/sdkSurface.d.ts +55 -0
- package/dist/packages/sdk/src/topicsClient.d.ts +45 -0
- package/dist/packages/sdk/src/types.d.ts +470 -0
- package/dist/packages/sdk/src/version.d.ts +2 -0
- package/dist/packages/sdk/src/workflowClient.d.ts +252 -0
- package/package.json +37 -92
- package/CHANGELOG.md +0 -13
- package/dist/adminClient.d.ts +0 -409
- package/dist/adminClient.js +0 -755
- package/dist/adminClient.js.map +0 -1
- package/dist/answersClient.d.ts +0 -23
- package/dist/answersClient.js +0 -333
- package/dist/answersClient.js.map +0 -1
- package/dist/audience/index.d.ts +0 -38
- package/dist/audience/index.js +0 -110
- package/dist/audience/index.js.map +0 -1
- package/dist/audiencesClient.js +0 -472
- package/dist/audiencesClient.js.map +0 -1
- package/dist/auditClient.d.ts +0 -29
- package/dist/auditClient.js +0 -386
- package/dist/auditClient.js.map +0 -1
- package/dist/beliefs/index.d.ts +0 -465
- package/dist/beliefs/index.js +0 -6433
- package/dist/beliefs/index.js.map +0 -1
- package/dist/beliefs/lifecycle.d.ts +0 -24
- package/dist/beliefs/lifecycle.js +0 -98
- package/dist/beliefs/lifecycle.js.map +0 -1
- package/dist/beliefsClient.d.ts +0 -241
- package/dist/beliefsClient.js +0 -646
- package/dist/beliefsClient.js.map +0 -1
- package/dist/client.d.ts +0 -2398
- package/dist/client.js +0 -6411
- package/dist/client.js.map +0 -1
- package/dist/contextClient.d.ts +0 -27
- package/dist/contextClient.js +0 -396
- package/dist/contextClient.js.map +0 -1
- package/dist/contextFacade.d.ts +0 -2
- package/dist/contextFacade.js +0 -73
- package/dist/contextFacade.js.map +0 -1
- package/dist/contextPackCompiler.js +0 -1091
- package/dist/contextPackCompiler.js.map +0 -1
- package/dist/contextPackPolicy.d.ts +0 -84
- package/dist/contextPackPolicy.js +0 -347
- package/dist/contextPackPolicy.js.map +0 -1
- package/dist/contextPackSchema.d.ts +0 -7
- package/dist/contextPackSchema.js +0 -203
- package/dist/contextPackSchema.js.map +0 -1
- package/dist/contextTypes.d.ts +0 -135
- package/dist/contextTypes.js +0 -3
- package/dist/contextTypes.js.map +0 -1
- package/dist/contracts/api-enums.contract.d.ts +0 -81
- package/dist/contracts/api-enums.contract.js +0 -98
- package/dist/contracts/api-enums.contract.js.map +0 -1
- package/dist/contracts/auth-session.contract.js +0 -48
- package/dist/contracts/auth-session.contract.js.map +0 -1
- package/dist/contracts/context-pack.contract.js +0 -98
- package/dist/contracts/context-pack.contract.js.map +0 -1
- package/dist/contracts/contextPack.d.ts +0 -1
- package/dist/contracts/contextPack.js +0 -98
- package/dist/contracts/contextPack.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -9
- package/dist/contracts/index.js +0 -4928
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/lens-filter.contract.js +0 -71
- package/dist/contracts/lens-filter.contract.js.map +0 -1
- package/dist/contracts/lens-workflow.contract.d.ts +0 -87
- package/dist/contracts/lens-workflow.contract.js +0 -123
- package/dist/contracts/lens-workflow.contract.js.map +0 -1
- package/dist/contracts/lensFilter.d.ts +0 -1
- package/dist/contracts/lensFilter.js +0 -71
- package/dist/contracts/lensFilter.js.map +0 -1
- package/dist/contracts/lensWorkflow.d.ts +0 -2
- package/dist/contracts/lensWorkflow.js +0 -123
- package/dist/contracts/lensWorkflow.js.map +0 -1
- package/dist/contracts/mcp-tools.contract.d.ts +0 -1
- package/dist/contracts/mcp-tools.contract.js +0 -3016
- package/dist/contracts/mcp-tools.contract.js.map +0 -1
- package/dist/contracts/mcpTools.d.ts +0 -1
- package/dist/contracts/mcpTools.js +0 -3016
- package/dist/contracts/mcpTools.js.map +0 -1
- package/dist/contracts/prompt.contract.d.ts +0 -26
- package/dist/contracts/prompt.contract.js +0 -12
- package/dist/contracts/prompt.contract.js.map +0 -1
- package/dist/contracts/prompt.d.ts +0 -1
- package/dist/contracts/prompt.js +0 -12
- package/dist/contracts/prompt.js.map +0 -1
- package/dist/contracts/sdk-tools.contract.d.ts +0 -2
- package/dist/contracts/sdk-tools.contract.js +0 -4164
- package/dist/contracts/sdk-tools.contract.js.map +0 -1
- package/dist/contracts/sdkTools.d.ts +0 -2
- package/dist/contracts/sdkTools.js +0 -4164
- package/dist/contracts/sdkTools.js.map +0 -1
- package/dist/contracts/workflow-runtime.contract.d.ts +0 -163
- package/dist/contracts/workflow-runtime.contract.js +0 -245
- package/dist/contracts/workflow-runtime.contract.js.map +0 -1
- package/dist/contracts/workflowRuntime.d.ts +0 -1
- package/dist/contracts/workflowRuntime.js +0 -245
- package/dist/contracts/workflowRuntime.js.map +0 -1
- package/dist/contradictions/index.d.ts +0 -158
- package/dist/contradictions/index.js +0 -6427
- package/dist/contradictions/index.js.map +0 -1
- package/dist/controlObjectOwnership.js +0 -215
- package/dist/controlObjectOwnership.js.map +0 -1
- package/dist/coreClient.js +0 -339
- package/dist/coreClient.js.map +0 -1
- package/dist/customTools.d.ts +0 -88
- package/dist/customTools.js +0 -248
- package/dist/customTools.js.map +0 -1
- package/dist/decisions/index.d.ts +0 -68
- package/dist/decisions/index.js +0 -6429
- package/dist/decisions/index.js.map +0 -1
- package/dist/decisionsClient.d.ts +0 -111
- package/dist/decisionsClient.js +0 -522
- package/dist/decisionsClient.js.map +0 -1
- package/dist/domainContext.d.ts +0 -1
- package/dist/domainContext.js +0 -3
- package/dist/domainContext.js.map +0 -1
- package/dist/edges/index.d.ts +0 -204
- package/dist/edges/index.js +0 -6428
- package/dist/edges/index.js.map +0 -1
- package/dist/events.d.ts +0 -178
- package/dist/events.js +0 -251
- package/dist/events.js.map +0 -1
- package/dist/eventsCore.d.ts +0 -49
- package/dist/eventsCore.js +0 -429
- package/dist/eventsCore.js.map +0 -1
- package/dist/evidence/index.d.ts +0 -295
- package/dist/evidence/index.js +0 -6428
- package/dist/evidence/index.js.map +0 -1
- package/dist/evidenceClient.d.ts +0 -119
- package/dist/evidenceClient.js +0 -350
- package/dist/evidenceClient.js.map +0 -1
- package/dist/facade/context.d.ts +0 -18
- package/dist/facade/context.js +0 -73
- package/dist/facade/context.js.map +0 -1
- package/dist/gatewayFacades.d.ts +0 -589
- package/dist/gatewayFacades.js +0 -2006
- package/dist/gatewayFacades.js.map +0 -1
- package/dist/graphClient.d.ts +0 -271
- package/dist/graphClient.js +0 -698
- package/dist/graphClient.js.map +0 -1
- package/dist/harnessClient.js +0 -607
- package/dist/harnessClient.js.map +0 -1
- package/dist/identityClient.d.ts +0 -140
- package/dist/identityClient.js +0 -497
- package/dist/identityClient.js.map +0 -1
- package/dist/index.d.ts +0 -45
- package/dist/learningClient.d.ts +0 -46
- package/dist/learningClient.js +0 -409
- package/dist/learningClient.js.map +0 -1
- package/dist/lenses/index.d.ts +0 -194
- package/dist/lenses/index.js +0 -6427
- package/dist/lenses/index.js.map +0 -1
- package/dist/mcpParityClient.js +0 -516
- package/dist/mcpParityClient.js.map +0 -1
- package/dist/mcpParitySurface.d.ts +0 -12
- package/dist/mcpParitySurface.js +0 -65
- package/dist/mcpParitySurface.js.map +0 -1
- package/dist/mcpTools-DPZxowDX.d.ts +0 -254
- package/dist/nodes/index.d.ts +0 -62
- package/dist/nodes/index.js +0 -6429
- package/dist/nodes/index.js.map +0 -1
- package/dist/ontologies/index.d.ts +0 -178
- package/dist/ontologies/index.js +0 -6430
- package/dist/ontologies/index.js.map +0 -1
- package/dist/ontologyClient.js +0 -513
- package/dist/ontologyClient.js.map +0 -1
- package/dist/opinion.d.ts +0 -11
- package/dist/opinion.js +0 -35
- package/dist/opinion.js.map +0 -1
- package/dist/packRuntime.d.ts +0 -2
- package/dist/packRuntime.js +0 -3
- package/dist/packRuntime.js.map +0 -1
- package/dist/packsClient.d.ts +0 -131
- package/dist/packsClient.js +0 -525
- package/dist/packsClient.js.map +0 -1
- package/dist/policyClient.js +0 -625
- package/dist/policyClient.js.map +0 -1
- package/dist/questions/index.d.ts +0 -297
- package/dist/questions/index.js +0 -6430
- package/dist/questions/index.js.map +0 -1
- package/dist/realtime/index.d.ts +0 -29
- package/dist/realtime/index.js +0 -23
- package/dist/realtime/index.js.map +0 -1
- package/dist/realtime/refs.d.ts +0 -17
- package/dist/realtime/refs.js +0 -9
- package/dist/realtime/refs.js.map +0 -1
- package/dist/reportsClient.d.ts +0 -41
- package/dist/reportsClient.js +0 -418
- package/dist/reportsClient.js.map +0 -1
- package/dist/schemaClient.d.ts +0 -64
- package/dist/schemaClient.js +0 -434
- package/dist/schemaClient.js.map +0 -1
- package/dist/sdkSurface.d.ts +0 -61
- package/dist/sdkSurface.js +0 -112
- package/dist/sdkSurface.js.map +0 -1
- package/dist/sdkTools-CwXJDACb.d.ts +0 -150
- package/dist/sourcesClient.d.ts +0 -24
- package/dist/sourcesClient.js +0 -339
- package/dist/sourcesClient.js.map +0 -1
- package/dist/topics/index.d.ts +0 -68
- package/dist/topics/index.js +0 -6428
- package/dist/topics/index.js.map +0 -1
- package/dist/topicsClient.d.ts +0 -84
- package/dist/topicsClient.js +0 -492
- package/dist/topicsClient.js.map +0 -1
- package/dist/types.d.ts +0 -715
- package/dist/types.js +0 -3
- package/dist/types.js.map +0 -1
- package/dist/version.d.ts +0 -4
- package/dist/version.js +0 -6
- package/dist/version.js.map +0 -1
- package/dist/workflowClient.d.ts +0 -316
- package/dist/workflowClient.js +0 -830
- package/dist/workflowClient.js.map +0 -1
- package/dist/worktrees/index.d.ts +0 -210
- package/dist/worktrees/index.js +0 -6430
- package/dist/worktrees/index.js.map +0 -1
package/dist/adminClient.js
DELETED
|
@@ -1,755 +0,0 @@
|
|
|
1
|
-
// src/coreClient.ts
|
|
2
|
-
var LucernApiError = class extends Error {
|
|
3
|
-
code;
|
|
4
|
-
status;
|
|
5
|
-
invariant;
|
|
6
|
-
suggestion;
|
|
7
|
-
details;
|
|
8
|
-
requestId;
|
|
9
|
-
correlationId;
|
|
10
|
-
policyTraceId;
|
|
11
|
-
constructor(args) {
|
|
12
|
-
super(args.message);
|
|
13
|
-
this.name = "LucernApiError";
|
|
14
|
-
this.code = args.code;
|
|
15
|
-
this.status = args.status;
|
|
16
|
-
this.invariant = args.invariant;
|
|
17
|
-
this.suggestion = args.suggestion;
|
|
18
|
-
this.details = args.details;
|
|
19
|
-
this.requestId = args.requestId;
|
|
20
|
-
this.correlationId = args.correlationId;
|
|
21
|
-
this.policyTraceId = args.policyTraceId;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
function toQueryString(scope) {
|
|
25
|
-
const params = new URLSearchParams();
|
|
26
|
-
if (scope.tenantId) {
|
|
27
|
-
params.set("tenantId", scope.tenantId);
|
|
28
|
-
}
|
|
29
|
-
if (scope.workspaceId) {
|
|
30
|
-
params.set("workspaceId", scope.workspaceId);
|
|
31
|
-
}
|
|
32
|
-
for (const [key, value] of Object.entries(scope)) {
|
|
33
|
-
if (key === "tenantId" || key === "workspaceId") {
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (value === void 0) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
params.set(key, String(value));
|
|
40
|
-
}
|
|
41
|
-
const serialized = params.toString();
|
|
42
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
43
|
-
}
|
|
44
|
-
function fillRandomBytes(length) {
|
|
45
|
-
const bytes = new Uint8Array(length);
|
|
46
|
-
if (typeof globalThis.crypto?.getRandomValues === "function") {
|
|
47
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
48
|
-
return bytes;
|
|
49
|
-
}
|
|
50
|
-
for (let index = 0; index < length; index += 1) {
|
|
51
|
-
bytes[index] = Math.floor(Math.random() * 256);
|
|
52
|
-
}
|
|
53
|
-
return bytes;
|
|
54
|
-
}
|
|
55
|
-
function generatePortableRequestId() {
|
|
56
|
-
if (typeof globalThis.crypto?.randomUUID === "function") {
|
|
57
|
-
return globalThis.crypto.randomUUID();
|
|
58
|
-
}
|
|
59
|
-
const bytes = fillRandomBytes(16);
|
|
60
|
-
bytes[6] = bytes[6] & 15 | 64;
|
|
61
|
-
bytes[8] = bytes[8] & 63 | 128;
|
|
62
|
-
const hex = Array.from(bytes, (value) => value.toString(16).padStart(2, "0"));
|
|
63
|
-
return `${hex.slice(0, 4).join("")}-${hex.slice(4, 6).join("")}-${hex.slice(
|
|
64
|
-
6,
|
|
65
|
-
8
|
|
66
|
-
).join("")}-${hex.slice(8, 10).join("")}-${hex.slice(10).join("")}`;
|
|
67
|
-
}
|
|
68
|
-
function randomIdempotencyKey() {
|
|
69
|
-
return generatePortableRequestId();
|
|
70
|
-
}
|
|
71
|
-
function isRetryableStatus(status) {
|
|
72
|
-
return status >= 500 || status === 408 || status === 429;
|
|
73
|
-
}
|
|
74
|
-
function fallbackErrorCode(status) {
|
|
75
|
-
if (status === 401) {
|
|
76
|
-
return "AUTHENTICATION_REQUIRED";
|
|
77
|
-
}
|
|
78
|
-
if (status === 403) {
|
|
79
|
-
return "FORBIDDEN";
|
|
80
|
-
}
|
|
81
|
-
if (status === 404) {
|
|
82
|
-
return "NOT_FOUND";
|
|
83
|
-
}
|
|
84
|
-
if (status === 408) {
|
|
85
|
-
return "UPSTREAM_ERROR";
|
|
86
|
-
}
|
|
87
|
-
if (status === 409) {
|
|
88
|
-
return "CONFLICT";
|
|
89
|
-
}
|
|
90
|
-
if (status === 429) {
|
|
91
|
-
return "RATE_LIMIT_EXCEEDED";
|
|
92
|
-
}
|
|
93
|
-
if (status >= 500) {
|
|
94
|
-
return "UPSTREAM_ERROR";
|
|
95
|
-
}
|
|
96
|
-
return "INTERNAL_ERROR";
|
|
97
|
-
}
|
|
98
|
-
function delay(ms) {
|
|
99
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
100
|
-
}
|
|
101
|
-
function parseRetryAfterMs(value) {
|
|
102
|
-
if (!value) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
const trimmed = value.trim();
|
|
106
|
-
if (!trimmed) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const numeric = Number(trimmed);
|
|
110
|
-
if (Number.isFinite(numeric)) {
|
|
111
|
-
return Math.max(0, Math.round(numeric * 1e3));
|
|
112
|
-
}
|
|
113
|
-
const parsedDate = Date.parse(trimmed);
|
|
114
|
-
if (Number.isFinite(parsedDate)) {
|
|
115
|
-
return Math.max(0, parsedDate - Date.now());
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
function computeRetryDelayMs(args) {
|
|
120
|
-
const baseDelay = args.status === 429 ? Math.max(
|
|
121
|
-
args.retryAfterMs ?? 0,
|
|
122
|
-
Math.min(1e3 * 2 ** args.attempt, 1e4)
|
|
123
|
-
) : Math.min(1e3 * 2 ** args.attempt, 4e3);
|
|
124
|
-
if (args.status !== 429) {
|
|
125
|
-
return baseDelay;
|
|
126
|
-
}
|
|
127
|
-
const jitterWindow = Math.max(250, Math.round(baseDelay * 0.25));
|
|
128
|
-
return baseDelay + Math.round(Math.random() * jitterWindow);
|
|
129
|
-
}
|
|
130
|
-
function timeoutError(timeoutMs) {
|
|
131
|
-
const error = new Error(`Request timed out after ${timeoutMs}ms`);
|
|
132
|
-
error.name = "AbortError";
|
|
133
|
-
return error;
|
|
134
|
-
}
|
|
135
|
-
function readPolicySummaryFromDetails(details) {
|
|
136
|
-
if (!details || typeof details !== "object" || Array.isArray(details)) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const directSummary = details.summary;
|
|
140
|
-
if (typeof directSummary === "string" && directSummary.trim().length > 0) {
|
|
141
|
-
return directSummary.trim();
|
|
142
|
-
}
|
|
143
|
-
const policy = details.policy;
|
|
144
|
-
if (!policy || typeof policy !== "object" || Array.isArray(policy)) {
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
const explanation = policy.explanation;
|
|
148
|
-
if (!explanation || typeof explanation !== "object" || Array.isArray(explanation)) {
|
|
149
|
-
return null;
|
|
150
|
-
}
|
|
151
|
-
const nestedSummary = explanation.summary;
|
|
152
|
-
if (typeof nestedSummary === "string" && nestedSummary.trim().length > 0) {
|
|
153
|
-
return nestedSummary.trim();
|
|
154
|
-
}
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
function createGatewayRequestClient(config = {}) {
|
|
158
|
-
const fetchImpl = config.fetchImpl ?? fetch;
|
|
159
|
-
const baseUrl = config.baseUrl?.replace(/\/+$/, "") ?? "";
|
|
160
|
-
const maxRetries = config.maxRetries ?? 2;
|
|
161
|
-
const requestIdFactory = config.requestIdFactory ?? (() => generatePortableRequestId());
|
|
162
|
-
async function resolveAuthHeaders() {
|
|
163
|
-
if (!config.getAuthHeaders) {
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
|
-
return await config.getAuthHeaders();
|
|
167
|
-
}
|
|
168
|
-
async function fetchWithTimeout(url, init, timeoutMs) {
|
|
169
|
-
const controller = new AbortController();
|
|
170
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
171
|
-
try {
|
|
172
|
-
return await fetchImpl(url, { ...init, signal: controller.signal });
|
|
173
|
-
} catch (error) {
|
|
174
|
-
if (controller.signal.aborted) {
|
|
175
|
-
throw timeoutError(timeoutMs);
|
|
176
|
-
}
|
|
177
|
-
throw error;
|
|
178
|
-
} finally {
|
|
179
|
-
clearTimeout(timer);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async function parsePayload(response) {
|
|
183
|
-
const text = await response.text();
|
|
184
|
-
if (!text) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
return JSON.parse(text);
|
|
189
|
-
} catch {
|
|
190
|
-
return null;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function resolveTimeoutMs(method, requestTimeoutMs) {
|
|
194
|
-
if (typeof requestTimeoutMs === "number") {
|
|
195
|
-
return requestTimeoutMs;
|
|
196
|
-
}
|
|
197
|
-
const methodTimeoutMs = config.timeoutMsByMethod?.[method];
|
|
198
|
-
if (typeof methodTimeoutMs === "number") {
|
|
199
|
-
return methodTimeoutMs;
|
|
200
|
-
}
|
|
201
|
-
return config.timeoutMs ?? 15e3;
|
|
202
|
-
}
|
|
203
|
-
function buildApiError(args) {
|
|
204
|
-
const failure = args.failure;
|
|
205
|
-
const legacyError = failure && typeof failure.error === "object" && failure.error !== null ? failure.error : failure?.legacyError;
|
|
206
|
-
const correlationId = failure?.correlationId ?? args.response.headers.get("x-lucern-correlation-id")?.trim() ?? args.requestId;
|
|
207
|
-
const policyTraceId = failure?.policyTraceId ?? args.response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null;
|
|
208
|
-
const details = failure?.details ?? legacyError?.details;
|
|
209
|
-
const policySummary = readPolicySummaryFromDetails(details);
|
|
210
|
-
return new LucernApiError({
|
|
211
|
-
code: failure?.code ?? legacyError?.code ?? fallbackErrorCode(args.response.status),
|
|
212
|
-
message: policySummary ?? (typeof failure?.error === "string" ? failure.error : legacyError?.message ?? (args.response.ok ? "Platform API returned an invalid success payload." : "Platform API request failed.")),
|
|
213
|
-
status: args.response.status,
|
|
214
|
-
invariant: failure?.invariant,
|
|
215
|
-
suggestion: failure?.suggestion,
|
|
216
|
-
details,
|
|
217
|
-
requestId: args.requestId,
|
|
218
|
-
correlationId,
|
|
219
|
-
policyTraceId
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
async function request(args) {
|
|
223
|
-
const authHeaders = await resolveAuthHeaders();
|
|
224
|
-
const method = args.method ?? "GET";
|
|
225
|
-
const timeoutMs = resolveTimeoutMs(method, args.timeoutMs);
|
|
226
|
-
const headers = new Headers({
|
|
227
|
-
"content-type": "application/json",
|
|
228
|
-
...authHeaders
|
|
229
|
-
});
|
|
230
|
-
if (args.idempotencyKey) {
|
|
231
|
-
headers.set("idempotency-key", args.idempotencyKey);
|
|
232
|
-
}
|
|
233
|
-
const requestId = headers.get("x-correlation-id")?.trim() || headers.get("x-request-id")?.trim() || args.requestId || requestIdFactory();
|
|
234
|
-
if (!headers.has("x-correlation-id") && !headers.has("x-request-id")) {
|
|
235
|
-
headers.set("x-correlation-id", requestId);
|
|
236
|
-
}
|
|
237
|
-
const url = `${baseUrl}${args.path}`;
|
|
238
|
-
const serializedBody = args.body ? JSON.stringify(args.body) : void 0;
|
|
239
|
-
const init = {
|
|
240
|
-
method,
|
|
241
|
-
headers,
|
|
242
|
-
body: serializedBody
|
|
243
|
-
};
|
|
244
|
-
let lastError;
|
|
245
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
246
|
-
const hookRequestContext = {
|
|
247
|
-
requestId,
|
|
248
|
-
attempt,
|
|
249
|
-
maxRetries,
|
|
250
|
-
method,
|
|
251
|
-
path: args.path,
|
|
252
|
-
url,
|
|
253
|
-
headers: new Headers(headers),
|
|
254
|
-
body: serializedBody,
|
|
255
|
-
timeoutMs
|
|
256
|
-
};
|
|
257
|
-
await config.onRequest?.(hookRequestContext);
|
|
258
|
-
const startedAt = Date.now();
|
|
259
|
-
try {
|
|
260
|
-
const response = await fetchWithTimeout(url, init, timeoutMs);
|
|
261
|
-
const responseClone = response.clone();
|
|
262
|
-
const payload = await parsePayload(response);
|
|
263
|
-
const retryAfterMs = parseRetryAfterMs(
|
|
264
|
-
response.headers.get("Retry-After")
|
|
265
|
-
);
|
|
266
|
-
if (!response.ok || !payload?.success) {
|
|
267
|
-
const failure = payload && !payload.success ? payload : null;
|
|
268
|
-
const apiError = buildApiError({
|
|
269
|
-
requestId,
|
|
270
|
-
response,
|
|
271
|
-
failure
|
|
272
|
-
});
|
|
273
|
-
const willRetry = attempt < maxRetries && isRetryableStatus(response.status);
|
|
274
|
-
await config.onResponse?.({
|
|
275
|
-
...hookRequestContext,
|
|
276
|
-
durationMs: Date.now() - startedAt,
|
|
277
|
-
status: response.status,
|
|
278
|
-
response: responseClone,
|
|
279
|
-
error: apiError,
|
|
280
|
-
correlationId: apiError.correlationId ?? requestId,
|
|
281
|
-
policyTraceId: apiError.policyTraceId ?? null,
|
|
282
|
-
retryAfterMs,
|
|
283
|
-
willRetry
|
|
284
|
-
});
|
|
285
|
-
if (willRetry) {
|
|
286
|
-
lastError = apiError;
|
|
287
|
-
await delay(
|
|
288
|
-
computeRetryDelayMs({
|
|
289
|
-
attempt,
|
|
290
|
-
status: response.status,
|
|
291
|
-
retryAfterMs
|
|
292
|
-
})
|
|
293
|
-
);
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
throw apiError;
|
|
297
|
-
}
|
|
298
|
-
const successPayload = payload;
|
|
299
|
-
await config.onResponse?.({
|
|
300
|
-
...hookRequestContext,
|
|
301
|
-
durationMs: Date.now() - startedAt,
|
|
302
|
-
status: response.status,
|
|
303
|
-
response: responseClone,
|
|
304
|
-
correlationId: successPayload.correlationId ?? response.headers.get("x-lucern-correlation-id")?.trim() ?? requestId,
|
|
305
|
-
policyTraceId: successPayload.policyTraceId ?? response.headers.get("x-lucern-policy-trace-id")?.trim() ?? null,
|
|
306
|
-
idempotentReplay: successPayload.idempotentReplay,
|
|
307
|
-
retryAfterMs,
|
|
308
|
-
willRetry: false
|
|
309
|
-
});
|
|
310
|
-
return successPayload;
|
|
311
|
-
} catch (fetchError) {
|
|
312
|
-
if (fetchError instanceof LucernApiError) {
|
|
313
|
-
throw fetchError;
|
|
314
|
-
}
|
|
315
|
-
const willRetry = attempt < maxRetries;
|
|
316
|
-
await config.onResponse?.({
|
|
317
|
-
...hookRequestContext,
|
|
318
|
-
durationMs: Date.now() - startedAt,
|
|
319
|
-
error: fetchError,
|
|
320
|
-
correlationId: requestId,
|
|
321
|
-
policyTraceId: null,
|
|
322
|
-
willRetry
|
|
323
|
-
});
|
|
324
|
-
lastError = fetchError;
|
|
325
|
-
if (willRetry) {
|
|
326
|
-
await delay(computeRetryDelayMs({ attempt }));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
throw lastError instanceof Error ? lastError : new Error("Platform API request failed after retries.");
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
request
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// src/sdkSurface.ts
|
|
338
|
-
function createListResult(items, legacyKey) {
|
|
339
|
-
const result = {
|
|
340
|
-
items,
|
|
341
|
-
total: items.length
|
|
342
|
-
};
|
|
343
|
-
if (legacyKey) {
|
|
344
|
-
result[legacyKey] = items;
|
|
345
|
-
}
|
|
346
|
-
return result;
|
|
347
|
-
}
|
|
348
|
-
function mapGatewayData(response, mapper) {
|
|
349
|
-
return {
|
|
350
|
-
...response,
|
|
351
|
-
data: mapper(response.data)
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// src/adminClient.ts
|
|
356
|
-
function asTenantApiKeyRecord(data) {
|
|
357
|
-
if (!data || typeof data !== "object") {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
return data;
|
|
361
|
-
}
|
|
362
|
-
function asTenantApiKeyArray(data) {
|
|
363
|
-
if (!Array.isArray(data)) {
|
|
364
|
-
return [];
|
|
365
|
-
}
|
|
366
|
-
return data.map(asTenantApiKeyRecord).filter((row) => Boolean(row));
|
|
367
|
-
}
|
|
368
|
-
function asTenantVaultSecretRecord(data) {
|
|
369
|
-
if (!data || typeof data !== "object") {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
return data;
|
|
373
|
-
}
|
|
374
|
-
function asTenantVaultSecretArray(data) {
|
|
375
|
-
if (!Array.isArray(data)) {
|
|
376
|
-
return [];
|
|
377
|
-
}
|
|
378
|
-
return data.map(asTenantVaultSecretRecord).filter((row) => Boolean(row));
|
|
379
|
-
}
|
|
380
|
-
function createAdminClient(config = {}) {
|
|
381
|
-
const gateway = createGatewayRequestClient(config);
|
|
382
|
-
return {
|
|
383
|
-
/**
|
|
384
|
-
* List tenants visible to the current principal.
|
|
385
|
-
*/
|
|
386
|
-
async listTenants(query = {}) {
|
|
387
|
-
return gateway.request({
|
|
388
|
-
path: `/api/platform/v1/tenants${toQueryString(query)}`
|
|
389
|
-
}).then(
|
|
390
|
-
(response) => mapGatewayData(
|
|
391
|
-
response,
|
|
392
|
-
(data) => createListResult(
|
|
393
|
-
Array.isArray(data) ? data : [],
|
|
394
|
-
"tenants"
|
|
395
|
-
)
|
|
396
|
-
)
|
|
397
|
-
);
|
|
398
|
-
},
|
|
399
|
-
/**
|
|
400
|
-
* Create a tenant.
|
|
401
|
-
*/
|
|
402
|
-
async createTenant(input, idempotencyKey) {
|
|
403
|
-
return gateway.request({
|
|
404
|
-
path: "/api/platform/v1/tenants",
|
|
405
|
-
method: "POST",
|
|
406
|
-
body: input,
|
|
407
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
408
|
-
});
|
|
409
|
-
},
|
|
410
|
-
/**
|
|
411
|
-
* Get the control-object ownership contract.
|
|
412
|
-
*/
|
|
413
|
-
async getControlObjectOwnership() {
|
|
414
|
-
return gateway.request({
|
|
415
|
-
path: "/api/platform/v1/admin/control-ownership"
|
|
416
|
-
});
|
|
417
|
-
},
|
|
418
|
-
/**
|
|
419
|
-
* @deprecated Use getControlObjectOwnership.
|
|
420
|
-
*/
|
|
421
|
-
async getControlObjectOwnershipContract() {
|
|
422
|
-
return gateway.request({
|
|
423
|
-
path: "/api/platform/v1/admin/control-ownership"
|
|
424
|
-
});
|
|
425
|
-
},
|
|
426
|
-
/**
|
|
427
|
-
* List workspaces for the current admin scope.
|
|
428
|
-
*/
|
|
429
|
-
async listWorkspaces(query = {}) {
|
|
430
|
-
return gateway.request({
|
|
431
|
-
path: `/api/platform/v1/workspaces${toQueryString(query)}`
|
|
432
|
-
}).then(
|
|
433
|
-
(response) => mapGatewayData(
|
|
434
|
-
response,
|
|
435
|
-
(data) => createListResult(
|
|
436
|
-
Array.isArray(data) ? data : [],
|
|
437
|
-
"workspaces"
|
|
438
|
-
)
|
|
439
|
-
)
|
|
440
|
-
);
|
|
441
|
-
},
|
|
442
|
-
/**
|
|
443
|
-
* Create a workspace.
|
|
444
|
-
*/
|
|
445
|
-
async createWorkspace(input, idempotencyKey) {
|
|
446
|
-
return gateway.request({
|
|
447
|
-
path: "/api/platform/v1/workspaces",
|
|
448
|
-
method: "POST",
|
|
449
|
-
body: input,
|
|
450
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
451
|
-
});
|
|
452
|
-
},
|
|
453
|
-
/**
|
|
454
|
-
* List memberships for the current admin scope.
|
|
455
|
-
*/
|
|
456
|
-
async listMemberships(query = {}) {
|
|
457
|
-
return gateway.request({
|
|
458
|
-
path: `/api/platform/v1/memberships${toQueryString(query)}`
|
|
459
|
-
}).then(
|
|
460
|
-
(response) => mapGatewayData(
|
|
461
|
-
response,
|
|
462
|
-
(data) => createListResult(
|
|
463
|
-
Array.isArray(data) ? data : [],
|
|
464
|
-
"memberships"
|
|
465
|
-
)
|
|
466
|
-
)
|
|
467
|
-
);
|
|
468
|
-
},
|
|
469
|
-
/**
|
|
470
|
-
* Create a membership.
|
|
471
|
-
*/
|
|
472
|
-
async createMembership(input, idempotencyKey) {
|
|
473
|
-
return gateway.request({
|
|
474
|
-
path: "/api/platform/v1/memberships",
|
|
475
|
-
method: "POST",
|
|
476
|
-
body: input,
|
|
477
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
478
|
-
});
|
|
479
|
-
},
|
|
480
|
-
/**
|
|
481
|
-
* Update a membership.
|
|
482
|
-
*/
|
|
483
|
-
async updateMembership(input, idempotencyKey) {
|
|
484
|
-
return this.createMembership(input, idempotencyKey);
|
|
485
|
-
},
|
|
486
|
-
/**
|
|
487
|
-
* @deprecated Use createMembership or updateMembership.
|
|
488
|
-
*/
|
|
489
|
-
async upsertMembership(input, idempotencyKey) {
|
|
490
|
-
return this.createMembership(input, idempotencyKey);
|
|
491
|
-
},
|
|
492
|
-
/**
|
|
493
|
-
* List tenant API keys in the current admin scope.
|
|
494
|
-
*/
|
|
495
|
-
async listTenantApiKeys(scope) {
|
|
496
|
-
const response = await gateway.request({
|
|
497
|
-
path: `/api/platform/v1/tenant-api-keys${toQueryString(scope)}`
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
...response,
|
|
501
|
-
data: {
|
|
502
|
-
keys: asTenantApiKeyArray(response.data?.keys)
|
|
503
|
-
}
|
|
504
|
-
};
|
|
505
|
-
},
|
|
506
|
-
/**
|
|
507
|
-
* Create a tenant API key.
|
|
508
|
-
*/
|
|
509
|
-
async createTenantApiKey(input, idempotencyKey) {
|
|
510
|
-
const response = await gateway.request({
|
|
511
|
-
path: "/api/platform/v1/tenant-api-keys",
|
|
512
|
-
method: "POST",
|
|
513
|
-
body: input,
|
|
514
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
515
|
-
});
|
|
516
|
-
return {
|
|
517
|
-
...response,
|
|
518
|
-
data: {
|
|
519
|
-
key: asTenantApiKeyRecord(response.data?.key),
|
|
520
|
-
plaintextKey: typeof response.data?.plaintextKey === "string" ? response.data.plaintextKey : void 0
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
|
-
},
|
|
524
|
-
/**
|
|
525
|
-
* Revoke a tenant API key.
|
|
526
|
-
*/
|
|
527
|
-
async revokeTenantApiKey(keyId, input = {}, idempotencyKey) {
|
|
528
|
-
return gateway.request({
|
|
529
|
-
path: `/api/platform/v1/tenant-api-keys/${encodeURIComponent(keyId)}/revoke`,
|
|
530
|
-
method: "POST",
|
|
531
|
-
body: input,
|
|
532
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
533
|
-
});
|
|
534
|
-
},
|
|
535
|
-
/**
|
|
536
|
-
* List tenant vault secrets.
|
|
537
|
-
*/
|
|
538
|
-
async listTenantVaultSecrets(scope) {
|
|
539
|
-
const response = await gateway.request({
|
|
540
|
-
path: `/api/platform/v1/tenant-vault-secrets${toQueryString(scope)}`
|
|
541
|
-
});
|
|
542
|
-
return {
|
|
543
|
-
...response,
|
|
544
|
-
data: {
|
|
545
|
-
secrets: asTenantVaultSecretArray(response.data?.secrets)
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
},
|
|
549
|
-
/**
|
|
550
|
-
* Create a tenant vault secret.
|
|
551
|
-
*/
|
|
552
|
-
async createTenantVaultSecret(input, idempotencyKey) {
|
|
553
|
-
const response = await gateway.request({
|
|
554
|
-
path: "/api/platform/v1/tenant-vault-secrets",
|
|
555
|
-
method: "POST",
|
|
556
|
-
body: input,
|
|
557
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
558
|
-
});
|
|
559
|
-
return {
|
|
560
|
-
...response,
|
|
561
|
-
data: {
|
|
562
|
-
secret: asTenantVaultSecretRecord(response.data?.secret)
|
|
563
|
-
}
|
|
564
|
-
};
|
|
565
|
-
},
|
|
566
|
-
/**
|
|
567
|
-
* Update a tenant vault secret.
|
|
568
|
-
*/
|
|
569
|
-
async updateTenantVaultSecret(secretId, input, idempotencyKey) {
|
|
570
|
-
const response = await gateway.request({
|
|
571
|
-
path: `/api/platform/v1/tenant-vault-secrets/${encodeURIComponent(secretId)}`,
|
|
572
|
-
method: "PATCH",
|
|
573
|
-
body: input,
|
|
574
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
575
|
-
});
|
|
576
|
-
return {
|
|
577
|
-
...response,
|
|
578
|
-
data: {
|
|
579
|
-
secret: asTenantVaultSecretRecord(response.data?.secret)
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
},
|
|
583
|
-
/**
|
|
584
|
-
* Delete a tenant vault secret.
|
|
585
|
-
*/
|
|
586
|
-
async deleteTenantVaultSecret(secretId, scope, idempotencyKey) {
|
|
587
|
-
return gateway.request({
|
|
588
|
-
path: `/api/platform/v1/tenant-vault-secrets/${encodeURIComponent(
|
|
589
|
-
secretId
|
|
590
|
-
)}${toQueryString(scope)}`,
|
|
591
|
-
method: "DELETE",
|
|
592
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
593
|
-
});
|
|
594
|
-
},
|
|
595
|
-
/**
|
|
596
|
-
* List tenant provider secrets.
|
|
597
|
-
*/
|
|
598
|
-
async listTenantSecrets(scope) {
|
|
599
|
-
return gateway.request({
|
|
600
|
-
path: `/api/platform/v1/tenant-secrets${toQueryString(scope)}`
|
|
601
|
-
});
|
|
602
|
-
},
|
|
603
|
-
/**
|
|
604
|
-
* Upsert a tenant provider secret.
|
|
605
|
-
*/
|
|
606
|
-
async upsertTenantSecret(input, idempotencyKey) {
|
|
607
|
-
return gateway.request({
|
|
608
|
-
path: "/api/platform/v1/tenant-secrets",
|
|
609
|
-
method: "POST",
|
|
610
|
-
body: input,
|
|
611
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
612
|
-
});
|
|
613
|
-
},
|
|
614
|
-
/**
|
|
615
|
-
* Revoke a tenant provider secret.
|
|
616
|
-
*/
|
|
617
|
-
async revokeTenantSecret(secretRef, input, idempotencyKey) {
|
|
618
|
-
return gateway.request({
|
|
619
|
-
path: `/api/platform/v1/tenant-secrets/${encodeURIComponent(secretRef)}/revoke`,
|
|
620
|
-
method: "POST",
|
|
621
|
-
body: input,
|
|
622
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
623
|
-
});
|
|
624
|
-
},
|
|
625
|
-
/**
|
|
626
|
-
* Get tenant configuration.
|
|
627
|
-
*/
|
|
628
|
-
async getTenantConfig(scope) {
|
|
629
|
-
return gateway.request({
|
|
630
|
-
path: `/api/platform/v1/tenant-config${toQueryString(scope)}`
|
|
631
|
-
});
|
|
632
|
-
},
|
|
633
|
-
/**
|
|
634
|
-
* Get tenant model routing.
|
|
635
|
-
*/
|
|
636
|
-
async getTenantModelRouting(scope) {
|
|
637
|
-
return gateway.request({
|
|
638
|
-
path: `/api/platform/v1/tenant-config/model-routing${toQueryString(scope)}`
|
|
639
|
-
});
|
|
640
|
-
},
|
|
641
|
-
/**
|
|
642
|
-
* Upsert tenant configuration.
|
|
643
|
-
*/
|
|
644
|
-
async upsertTenantConfig(input, idempotencyKey) {
|
|
645
|
-
return gateway.request({
|
|
646
|
-
path: "/api/platform/v1/tenant-config",
|
|
647
|
-
method: "POST",
|
|
648
|
-
body: input,
|
|
649
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
650
|
-
});
|
|
651
|
-
},
|
|
652
|
-
/**
|
|
653
|
-
* List groups.
|
|
654
|
-
*/
|
|
655
|
-
async listGroups(scope = {}) {
|
|
656
|
-
return gateway.request({
|
|
657
|
-
path: `/api/platform/v1/groups${toQueryString(scope)}`
|
|
658
|
-
});
|
|
659
|
-
},
|
|
660
|
-
/**
|
|
661
|
-
* Create a group.
|
|
662
|
-
*/
|
|
663
|
-
async createGroup(input, idempotencyKey) {
|
|
664
|
-
return gateway.request({
|
|
665
|
-
path: "/api/platform/v1/groups",
|
|
666
|
-
method: "POST",
|
|
667
|
-
body: input,
|
|
668
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
669
|
-
});
|
|
670
|
-
},
|
|
671
|
-
/**
|
|
672
|
-
* Update a group.
|
|
673
|
-
*/
|
|
674
|
-
async updateGroup(groupId, input, idempotencyKey) {
|
|
675
|
-
return gateway.request({
|
|
676
|
-
path: `/api/platform/v1/groups/${encodeURIComponent(groupId)}`,
|
|
677
|
-
method: "PATCH",
|
|
678
|
-
body: input,
|
|
679
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
680
|
-
});
|
|
681
|
-
},
|
|
682
|
-
/**
|
|
683
|
-
* Delete a group.
|
|
684
|
-
*/
|
|
685
|
-
async deleteGroup(groupId, input = {}, idempotencyKey) {
|
|
686
|
-
return gateway.request({
|
|
687
|
-
path: `/api/platform/v1/groups/${encodeURIComponent(groupId)}${toQueryString(input)}`,
|
|
688
|
-
method: "DELETE",
|
|
689
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
690
|
-
});
|
|
691
|
-
},
|
|
692
|
-
/**
|
|
693
|
-
* List group members.
|
|
694
|
-
*/
|
|
695
|
-
async listGroupMembers(query) {
|
|
696
|
-
return gateway.request({
|
|
697
|
-
path: `/api/platform/v1/groups/members${toQueryString(query)}`
|
|
698
|
-
});
|
|
699
|
-
},
|
|
700
|
-
/**
|
|
701
|
-
* Add a group member.
|
|
702
|
-
*/
|
|
703
|
-
async addGroupMember(input, idempotencyKey) {
|
|
704
|
-
return gateway.request({
|
|
705
|
-
path: "/api/platform/v1/groups/members",
|
|
706
|
-
method: "POST",
|
|
707
|
-
body: input,
|
|
708
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
709
|
-
});
|
|
710
|
-
},
|
|
711
|
-
/**
|
|
712
|
-
* Remove a group member.
|
|
713
|
-
*/
|
|
714
|
-
async removeGroupMember(input, idempotencyKey) {
|
|
715
|
-
return gateway.request({
|
|
716
|
-
path: `/api/platform/v1/groups/members${toQueryString(input)}`,
|
|
717
|
-
method: "DELETE",
|
|
718
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
719
|
-
});
|
|
720
|
-
},
|
|
721
|
-
/**
|
|
722
|
-
* List pack-to-group assignments.
|
|
723
|
-
*/
|
|
724
|
-
async listPackGroupAssignments(query = {}) {
|
|
725
|
-
return gateway.request({
|
|
726
|
-
path: `/api/platform/v1/groups/packs${toQueryString(query)}`
|
|
727
|
-
});
|
|
728
|
-
},
|
|
729
|
-
/**
|
|
730
|
-
* Assign a pack to a group.
|
|
731
|
-
*/
|
|
732
|
-
async assignPackToGroup(input, idempotencyKey) {
|
|
733
|
-
return gateway.request({
|
|
734
|
-
path: "/api/platform/v1/groups/packs",
|
|
735
|
-
method: "POST",
|
|
736
|
-
body: input,
|
|
737
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
738
|
-
});
|
|
739
|
-
},
|
|
740
|
-
/**
|
|
741
|
-
* Remove a pack from a group.
|
|
742
|
-
*/
|
|
743
|
-
async removePackFromGroup(input, idempotencyKey) {
|
|
744
|
-
return gateway.request({
|
|
745
|
-
path: `/api/platform/v1/groups/packs${toQueryString(input)}`,
|
|
746
|
-
method: "DELETE",
|
|
747
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
export { LucernApiError, createAdminClient };
|
|
754
|
-
//# sourceMappingURL=adminClient.js.map
|
|
755
|
-
//# sourceMappingURL=adminClient.js.map
|