@lucern/sdk 0.2.0-alpha.1 → 0.2.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 +13 -0
- package/README.md +691 -61
- package/dist/adminClient.d.ts +409 -0
- package/dist/adminClient.js +755 -0
- package/dist/adminClient.js.map +1 -0
- package/dist/answersClient.d.ts +23 -0
- package/dist/answersClient.js +333 -0
- package/dist/answersClient.js.map +1 -0
- package/dist/audience/index.d.ts +38 -0
- package/dist/audience/index.js +110 -0
- package/dist/audience/index.js.map +1 -0
- package/dist/{packages/sdk/src/audiencesClient.d.ts → audiencesClient.d.ts} +30 -18
- package/dist/audiencesClient.js +472 -0
- package/dist/audiencesClient.js.map +1 -0
- package/dist/auditClient.d.ts +29 -0
- package/dist/auditClient.js +386 -0
- package/dist/auditClient.js.map +1 -0
- package/dist/beliefs/index.d.ts +465 -0
- package/dist/beliefs/index.js +6433 -0
- package/dist/beliefs/index.js.map +1 -0
- package/dist/beliefs/lifecycle.d.ts +24 -0
- package/dist/beliefs/lifecycle.js +98 -0
- package/dist/beliefs/lifecycle.js.map +1 -0
- package/dist/beliefsClient.d.ts +241 -0
- package/dist/beliefsClient.js +646 -0
- package/dist/beliefsClient.js.map +1 -0
- package/dist/client.d.ts +2398 -0
- package/dist/client.js +6411 -0
- package/dist/client.js.map +1 -0
- package/dist/contextClient.d.ts +27 -0
- package/dist/contextClient.js +396 -0
- package/dist/contextClient.js.map +1 -0
- package/dist/contextFacade.d.ts +2 -0
- package/dist/contextFacade.js +73 -0
- package/dist/contextFacade.js.map +1 -0
- package/dist/{lucern/packages/domain-context/src/context-pack-compiler.d.ts → contextPackCompiler.d.ts} +11 -10
- package/dist/contextPackCompiler.js +1091 -0
- package/dist/contextPackCompiler.js.map +1 -0
- package/dist/contextPackPolicy.d.ts +84 -0
- package/dist/contextPackPolicy.js +347 -0
- package/dist/contextPackPolicy.js.map +1 -0
- package/dist/contextPackSchema.d.ts +7 -0
- package/dist/contextPackSchema.js +203 -0
- package/dist/contextPackSchema.js.map +1 -0
- package/dist/contextTypes.d.ts +135 -0
- package/dist/contextTypes.js +3 -0
- package/dist/contextTypes.js.map +1 -0
- package/dist/contracts/api-enums.contract.d.ts +81 -0
- package/dist/contracts/api-enums.contract.js +98 -0
- package/dist/contracts/api-enums.contract.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/auth-session.contract.d.ts +14 -12
- package/dist/contracts/auth-session.contract.js +48 -0
- package/dist/contracts/auth-session.contract.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/context-pack.contract.d.ts +56 -58
- package/dist/contracts/context-pack.contract.js +98 -0
- package/dist/contracts/context-pack.contract.js.map +1 -0
- package/dist/contracts/contextPack.d.ts +1 -0
- package/dist/contracts/contextPack.js +98 -0
- package/dist/contracts/contextPack.js.map +1 -0
- package/dist/contracts/index.d.ts +9 -0
- package/dist/contracts/index.js +4928 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/{lucern/contracts/src → contracts}/lens-filter.contract.d.ts +10 -8
- package/dist/contracts/lens-filter.contract.js +71 -0
- package/dist/contracts/lens-filter.contract.js.map +1 -0
- package/dist/contracts/lens-workflow.contract.d.ts +87 -0
- package/dist/contracts/lens-workflow.contract.js +123 -0
- package/dist/contracts/lens-workflow.contract.js.map +1 -0
- package/dist/contracts/lensFilter.d.ts +1 -0
- package/dist/contracts/lensFilter.js +71 -0
- package/dist/contracts/lensFilter.js.map +1 -0
- package/dist/contracts/lensWorkflow.d.ts +2 -0
- package/dist/contracts/lensWorkflow.js +123 -0
- package/dist/contracts/lensWorkflow.js.map +1 -0
- package/dist/contracts/mcp-tools.contract.d.ts +1 -0
- package/dist/contracts/mcp-tools.contract.js +3016 -0
- package/dist/contracts/mcp-tools.contract.js.map +1 -0
- package/dist/contracts/mcpTools.d.ts +1 -0
- package/dist/contracts/mcpTools.js +3016 -0
- package/dist/contracts/mcpTools.js.map +1 -0
- package/dist/contracts/prompt.contract.d.ts +26 -0
- package/dist/contracts/prompt.contract.js +12 -0
- package/dist/contracts/prompt.contract.js.map +1 -0
- package/dist/contracts/prompt.d.ts +1 -0
- package/dist/contracts/prompt.js +12 -0
- package/dist/contracts/prompt.js.map +1 -0
- package/dist/contracts/sdk-tools.contract.d.ts +2 -0
- package/dist/contracts/sdk-tools.contract.js +4164 -0
- package/dist/contracts/sdk-tools.contract.js.map +1 -0
- package/dist/contracts/sdkTools.d.ts +2 -0
- package/dist/contracts/sdkTools.js +4164 -0
- package/dist/contracts/sdkTools.js.map +1 -0
- package/dist/contracts/workflow-runtime.contract.d.ts +163 -0
- package/dist/contracts/workflow-runtime.contract.js +245 -0
- package/dist/contracts/workflow-runtime.contract.js.map +1 -0
- package/dist/contracts/workflowRuntime.d.ts +1 -0
- package/dist/contracts/workflowRuntime.js +245 -0
- package/dist/contracts/workflowRuntime.js.map +1 -0
- package/dist/contradictions/index.d.ts +158 -0
- package/dist/contradictions/index.js +6427 -0
- package/dist/contradictions/index.js.map +1 -0
- package/dist/{packages/sdk/src/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +35 -18
- package/dist/controlObjectOwnership.js +215 -0
- package/dist/controlObjectOwnership.js.map +1 -0
- package/dist/{packages/sdk/src/coreClient.d.ts → coreClient.d.ts} +38 -14
- package/dist/coreClient.js +339 -0
- package/dist/coreClient.js.map +1 -0
- package/dist/customTools.d.ts +88 -0
- package/dist/customTools.js +248 -0
- package/dist/customTools.js.map +1 -0
- package/dist/decisions/index.d.ts +68 -0
- package/dist/decisions/index.js +6429 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/decisionsClient.d.ts +111 -0
- package/dist/decisionsClient.js +522 -0
- package/dist/decisionsClient.js.map +1 -0
- package/dist/domainContext.d.ts +1 -0
- package/dist/domainContext.js +3 -0
- package/dist/domainContext.js.map +1 -0
- package/dist/edges/index.d.ts +204 -0
- package/dist/edges/index.js +6428 -0
- package/dist/edges/index.js.map +1 -0
- package/dist/events.d.ts +178 -0
- package/dist/events.js +251 -0
- package/dist/events.js.map +1 -0
- package/dist/eventsCore.d.ts +49 -0
- package/dist/eventsCore.js +429 -0
- package/dist/eventsCore.js.map +1 -0
- package/dist/evidence/index.d.ts +295 -0
- package/dist/evidence/index.js +6428 -0
- package/dist/evidence/index.js.map +1 -0
- package/dist/evidenceClient.d.ts +119 -0
- package/dist/evidenceClient.js +350 -0
- package/dist/evidenceClient.js.map +1 -0
- package/dist/facade/context.d.ts +18 -0
- package/dist/facade/context.js +73 -0
- package/dist/facade/context.js.map +1 -0
- package/dist/gatewayFacades.d.ts +589 -0
- package/dist/gatewayFacades.js +2006 -0
- package/dist/gatewayFacades.js.map +1 -0
- package/dist/graphClient.d.ts +271 -0
- package/dist/graphClient.js +698 -0
- package/dist/graphClient.js.map +1 -0
- package/dist/{packages/sdk/src/harnessClient.d.ts → harnessClient.d.ts} +127 -35
- package/dist/harnessClient.js +607 -0
- package/dist/harnessClient.js.map +1 -0
- package/dist/identityClient.d.ts +140 -0
- package/dist/identityClient.js +497 -0
- package/dist/identityClient.js.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +5284 -2568
- package/dist/index.js.map +1 -1
- package/dist/learningClient.d.ts +46 -0
- package/dist/learningClient.js +409 -0
- package/dist/learningClient.js.map +1 -0
- package/dist/lenses/index.d.ts +194 -0
- package/dist/lenses/index.js +6427 -0
- package/dist/lenses/index.js.map +1 -0
- package/dist/{packages/sdk/src/mcpParityClient.d.ts → mcpParityClient.d.ts} +11 -5
- package/dist/mcpParityClient.js +516 -0
- package/dist/mcpParityClient.js.map +1 -0
- package/dist/mcpParitySurface.d.ts +12 -0
- package/dist/mcpParitySurface.js +65 -0
- package/dist/mcpParitySurface.js.map +1 -0
- package/dist/mcpTools-DPZxowDX.d.ts +254 -0
- package/dist/nodes/index.d.ts +62 -0
- package/dist/nodes/index.js +6429 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/ontologies/index.d.ts +178 -0
- package/dist/ontologies/index.js +6430 -0
- package/dist/ontologies/index.js.map +1 -0
- package/dist/{packages/sdk/src/ontologyClient.d.ts → ontologyClient.d.ts} +44 -22
- package/dist/ontologyClient.js +513 -0
- package/dist/ontologyClient.js.map +1 -0
- package/dist/opinion.d.ts +11 -0
- package/dist/opinion.js +35 -0
- package/dist/opinion.js.map +1 -0
- package/dist/packRuntime.d.ts +2 -0
- package/dist/packRuntime.js +3 -0
- package/dist/packRuntime.js.map +1 -0
- package/dist/packsClient.d.ts +131 -0
- package/dist/packsClient.js +525 -0
- package/dist/packsClient.js.map +1 -0
- package/dist/{packages/sdk/src/policyClient.d.ts → policyClient.d.ts} +113 -18
- package/dist/policyClient.js +625 -0
- package/dist/policyClient.js.map +1 -0
- package/dist/questions/index.d.ts +297 -0
- package/dist/questions/index.js +6430 -0
- package/dist/questions/index.js.map +1 -0
- package/dist/realtime/index.d.ts +29 -0
- package/dist/realtime/index.js +23 -0
- package/dist/realtime/index.js.map +1 -0
- package/dist/realtime/refs.d.ts +17 -0
- package/dist/realtime/refs.js +9 -0
- package/dist/realtime/refs.js.map +1 -0
- package/dist/reportsClient.d.ts +41 -0
- package/dist/reportsClient.js +418 -0
- package/dist/reportsClient.js.map +1 -0
- package/dist/schemaClient.d.ts +64 -0
- package/dist/schemaClient.js +434 -0
- package/dist/schemaClient.js.map +1 -0
- package/dist/sdkSurface.d.ts +61 -0
- package/dist/sdkSurface.js +112 -0
- package/dist/sdkSurface.js.map +1 -0
- package/dist/sdkTools-CwXJDACb.d.ts +150 -0
- package/dist/sourcesClient.d.ts +24 -0
- package/dist/sourcesClient.js +339 -0
- package/dist/sourcesClient.js.map +1 -0
- package/dist/topics/index.d.ts +68 -0
- package/dist/topics/index.js +6428 -0
- package/dist/topics/index.js.map +1 -0
- package/dist/topicsClient.d.ts +84 -0
- package/dist/topicsClient.js +492 -0
- package/dist/topicsClient.js.map +1 -0
- package/dist/types.d.ts +715 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/workflowClient.d.ts +316 -0
- package/dist/workflowClient.js +830 -0
- package/dist/workflowClient.js.map +1 -0
- package/dist/worktrees/index.d.ts +210 -0
- package/dist/worktrees/index.js +6430 -0
- package/dist/worktrees/index.js.map +1 -0
- package/package.json +92 -37
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
- package/dist/lucern/mcp-server/src/context-pack-policy.d.ts +0 -119
- package/dist/lucern/mcp-server/src/context-pack-schema.d.ts +0 -18
- package/dist/lucern/modules/graph-primitives/src/ontology-matching.d.ts +0 -78
- package/dist/lucern/modules/graph-primitives/src/text-matching.d.ts +0 -53
- package/dist/lucern/packages/client-core/src/beliefs.d.ts +0 -30
- package/dist/lucern/packages/client-core/src/context.d.ts +0 -29
- package/dist/lucern/packages/client-core/src/contradictions.d.ts +0 -11
- package/dist/lucern/packages/client-core/src/edges.d.ts +0 -11
- package/dist/lucern/packages/client-core/src/events.d.ts +0 -9
- package/dist/lucern/packages/client-core/src/evidence.d.ts +0 -21
- package/dist/lucern/packages/client-core/src/graph.d.ts +0 -17
- package/dist/lucern/packages/client-core/src/identity.d.ts +0 -7
- package/dist/lucern/packages/client-core/src/ids.d.ts +0 -7
- package/dist/lucern/packages/client-core/src/ontologies.d.ts +0 -13
- package/dist/lucern/packages/client-core/src/questions.d.ts +0 -39
- package/dist/lucern/packages/client-core/src/search.d.ts +0 -7
- package/dist/lucern/packages/client-core/src/tasks.d.ts +0 -13
- package/dist/lucern/packages/client-core/src/topics.d.ts +0 -17
- package/dist/lucern/packages/client-core/src/webhooks.d.ts +0 -35
- package/dist/lucern/packages/client-core/src/worktrees.d.ts +0 -17
- package/dist/lucern/packages/domain-beliefs/src/beliefs.d.ts +0 -283
- package/dist/lucern/packages/domain-beliefs/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-context/src/compile.d.ts +0 -11
- package/dist/lucern/packages/domain-context/src/index.d.ts +0 -4
- package/dist/lucern/packages/domain-context/src/ports.d.ts +0 -58
- package/dist/lucern/packages/domain-context/src/public-types.d.ts +0 -1
- package/dist/lucern/packages/domain-edges/src/contradictions.d.ts +0 -59
- package/dist/lucern/packages/domain-edges/src/edges.d.ts +0 -91
- package/dist/lucern/packages/domain-edges/src/index.d.ts +0 -2
- package/dist/lucern/packages/domain-evidence/src/evidence.d.ts +0 -115
- package/dist/lucern/packages/domain-evidence/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-graph/src/graph.d.ts +0 -150
- package/dist/lucern/packages/domain-identity/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-identity/src/whoami.d.ts +0 -13
- package/dist/lucern/packages/domain-ontologies/src/ontologies.d.ts +0 -123
- package/dist/lucern/packages/domain-questions/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-questions/src/questions.d.ts +0 -147
- package/dist/lucern/packages/domain-search/src/search.d.ts +0 -97
- package/dist/lucern/packages/domain-tasks/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-tasks/src/tasks.d.ts +0 -102
- package/dist/lucern/packages/domain-topics/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-topics/src/topics.d.ts +0 -147
- package/dist/lucern/packages/domain-worktrees/src/index.d.ts +0 -1
- package/dist/lucern/packages/domain-worktrees/src/worktrees.d.ts +0 -185
- package/dist/lucern/packages/events/src/index.d.ts +0 -4
- package/dist/lucern/packages/events/src/matching.d.ts +0 -3
- package/dist/lucern/packages/events/src/outbox.d.ts +0 -15
- package/dist/lucern/packages/events/src/types.d.ts +0 -151
- package/dist/lucern/packages/events/src/webhooks.d.ts +0 -9
- package/dist/lucern/packages/sdk-typescript/src/facade/beliefs.d.ts +0 -15
- package/dist/lucern/packages/sdk-typescript/src/facade/context.d.ts +0 -12
- package/dist/lucern/packages/sdk-typescript/src/facade/contradictions.d.ts +0 -7
- package/dist/lucern/packages/sdk-typescript/src/facade/edges.d.ts +0 -7
- package/dist/lucern/packages/sdk-typescript/src/facade/events.d.ts +0 -6
- package/dist/lucern/packages/sdk-typescript/src/facade/evidence.d.ts +0 -21
- package/dist/lucern/packages/sdk-typescript/src/facade/graph.d.ts +0 -10
- package/dist/lucern/packages/sdk-typescript/src/facade/identity.d.ts +0 -5
- package/dist/lucern/packages/sdk-typescript/src/facade/ontologies.d.ts +0 -8
- package/dist/lucern/packages/sdk-typescript/src/facade/questions.d.ts +0 -39
- package/dist/lucern/packages/sdk-typescript/src/facade/search.d.ts +0 -5
- package/dist/lucern/packages/sdk-typescript/src/facade/tasks.d.ts +0 -8
- package/dist/lucern/packages/sdk-typescript/src/facade/topics.d.ts +0 -10
- package/dist/lucern/packages/sdk-typescript/src/facade/webhooks.d.ts +0 -16
- package/dist/lucern/packages/sdk-typescript/src/facade/worktrees.d.ts +0 -10
- package/dist/lucern/packages/sdk-typescript/src/index.d.ts +0 -28
- package/dist/packages/sdk/src/adminClient.d.ts +0 -89
- package/dist/packages/sdk/src/answersClient.d.ts +0 -5
- package/dist/packages/sdk/src/auditClient.d.ts +0 -23
- package/dist/packages/sdk/src/beliefsClient.d.ts +0 -54
- package/dist/packages/sdk/src/client.d.ts +0 -1610
- package/dist/packages/sdk/src/contextClient.d.ts +0 -9
- package/dist/packages/sdk/src/contracts/api-enums.contract.d.ts +0 -58
- package/dist/packages/sdk/src/customTools.d.ts +0 -65
- package/dist/packages/sdk/src/decisionsClient.d.ts +0 -110
- package/dist/packages/sdk/src/graphClient.d.ts +0 -209
- package/dist/packages/sdk/src/identityClient.d.ts +0 -104
- package/dist/packages/sdk/src/index.d.ts +0 -28
- package/dist/packages/sdk/src/learningClient.d.ts +0 -43
- package/dist/packages/sdk/src/mcpParitySurface.d.ts +0 -8
- package/dist/packages/sdk/src/packsClient.d.ts +0 -101
- package/dist/packages/sdk/src/reportsClient.d.ts +0 -31
- package/dist/packages/sdk/src/schemaClient.d.ts +0 -54
- package/dist/packages/sdk/src/sdkSurface.d.ts +0 -56
- package/dist/packages/sdk/src/topicsClient.d.ts +0 -45
- package/dist/packages/sdk/src/types.d.ts +0 -489
- package/dist/packages/sdk/src/version.d.ts +0 -2
- package/dist/packages/sdk/src/workflowClient.d.ts +0 -274
|
@@ -1,23 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { JsonObject, ListResult } from './types.js';
|
|
2
|
+
import { GatewayClientConfig, GatewayScope, PlatformGatewaySuccess } from './coreClient.js';
|
|
3
|
+
import './contracts/workflow-runtime.contract.js';
|
|
4
|
+
import './contracts/lens-workflow.contract.js';
|
|
5
|
+
import './contracts/lens-filter.contract.js';
|
|
6
|
+
|
|
7
|
+
/** Configuration for the ontology client. */
|
|
8
|
+
type OntologyClientConfig = GatewayClientConfig;
|
|
9
|
+
/** Input for binding an ontology to a topic. */
|
|
10
|
+
type OntologyBindingInput = GatewayScope & {
|
|
5
11
|
ontologyId: string;
|
|
6
12
|
topicId: string;
|
|
7
13
|
};
|
|
8
|
-
|
|
14
|
+
/** Input for creating an ontology definition. */
|
|
15
|
+
type OntologyDefinitionInput = GatewayScope & {
|
|
9
16
|
ontologyKey: string;
|
|
10
17
|
name: string;
|
|
11
18
|
description?: string;
|
|
12
19
|
tenantId?: string;
|
|
13
20
|
tier?: "platform" | "pack" | "tenant";
|
|
14
21
|
};
|
|
15
|
-
|
|
22
|
+
/** Input for updating mutable fields on an ontology definition. */
|
|
23
|
+
type OntologyDefinitionUpdateInput = GatewayScope & {
|
|
16
24
|
name?: string;
|
|
17
25
|
description?: string;
|
|
18
26
|
status?: "draft" | "active" | "deprecated";
|
|
19
27
|
};
|
|
20
|
-
|
|
28
|
+
/** Input for creating a versioned snapshot of entity and edge type definitions. */
|
|
29
|
+
type OntologyVersionInput = GatewayScope & {
|
|
21
30
|
version: string;
|
|
22
31
|
entityTypes: Array<{
|
|
23
32
|
value: string;
|
|
@@ -42,20 +51,31 @@ export type OntologyVersionInput = GatewayScope & {
|
|
|
42
51
|
};
|
|
43
52
|
/**
|
|
44
53
|
* Create the ontology client for ontology definitions and versions.
|
|
54
|
+
* @param config - Gateway transport configuration.
|
|
55
|
+
* @returns An object with methods to manage ontology definitions, versions, and bindings.
|
|
45
56
|
*/
|
|
46
|
-
|
|
57
|
+
declare function createOntologyClient(config?: OntologyClientConfig): {
|
|
58
|
+
/**
|
|
59
|
+
* List ontology definitions matching optional filters.
|
|
60
|
+
*/
|
|
47
61
|
list(filters?: GatewayScope & {
|
|
48
62
|
tenantId?: string;
|
|
49
63
|
tier?: string;
|
|
50
64
|
status?: string;
|
|
51
|
-
}): Promise<
|
|
65
|
+
}): Promise<PlatformGatewaySuccess<{
|
|
52
66
|
ontologies: any[];
|
|
53
67
|
total: number;
|
|
54
68
|
items: any[];
|
|
55
69
|
definitions: any[];
|
|
56
70
|
}>>;
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Get an ontology definition by identifier.
|
|
73
|
+
*/
|
|
74
|
+
get(id: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
75
|
+
/**
|
|
76
|
+
* Bind an ontology definition to a topic.
|
|
77
|
+
*/
|
|
78
|
+
bind(input: OntologyBindingInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
59
79
|
/**
|
|
60
80
|
* List ontology definitions.
|
|
61
81
|
*/
|
|
@@ -63,7 +83,7 @@ export declare function createOntologyClient(config?: OntologyClientConfig): {
|
|
|
63
83
|
tenantId?: string;
|
|
64
84
|
tier?: string;
|
|
65
85
|
status?: string;
|
|
66
|
-
}): Promise<
|
|
86
|
+
}): Promise<PlatformGatewaySuccess<{
|
|
67
87
|
ontologies: any[];
|
|
68
88
|
total: number;
|
|
69
89
|
items: any[];
|
|
@@ -72,44 +92,46 @@ export declare function createOntologyClient(config?: OntologyClientConfig): {
|
|
|
72
92
|
/**
|
|
73
93
|
* Get an ontology definition.
|
|
74
94
|
*/
|
|
75
|
-
getDefinition(id: string): Promise<
|
|
95
|
+
getDefinition(id: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
76
96
|
/**
|
|
77
97
|
* Create an ontology definition.
|
|
78
98
|
*/
|
|
79
|
-
createDefinition(input: OntologyDefinitionInput, idempotencyKey?: string): Promise<
|
|
99
|
+
createDefinition(input: OntologyDefinitionInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
80
100
|
/**
|
|
81
101
|
* Update an ontology definition.
|
|
82
102
|
*/
|
|
83
|
-
updateDefinition(id: string, input: OntologyDefinitionUpdateInput, idempotencyKey?: string): Promise<
|
|
103
|
+
updateDefinition(id: string, input: OntologyDefinitionUpdateInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
84
104
|
/**
|
|
85
105
|
* Archive an ontology definition.
|
|
86
106
|
*/
|
|
87
|
-
archiveDefinition(id: string, idempotencyKey?: string): Promise<
|
|
107
|
+
archiveDefinition(id: string, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
88
108
|
/**
|
|
89
109
|
* List versions for an ontology definition.
|
|
90
110
|
*/
|
|
91
111
|
listVersions(ontologyId: string, filters?: GatewayScope & {
|
|
92
112
|
status?: string;
|
|
93
|
-
}): Promise<
|
|
113
|
+
}): Promise<PlatformGatewaySuccess<ListResult<any, "versions">>>;
|
|
94
114
|
/**
|
|
95
115
|
* Create an ontology version.
|
|
96
116
|
*/
|
|
97
|
-
createVersion(ontologyId: string, input: OntologyVersionInput, idempotencyKey?: string): Promise<
|
|
117
|
+
createVersion(ontologyId: string, input: OntologyVersionInput, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
98
118
|
/**
|
|
99
119
|
* Publish an ontology version.
|
|
100
120
|
*/
|
|
101
|
-
publishVersion(ontologyId: string, versionId: string, idempotencyKey?: string): Promise<
|
|
121
|
+
publishVersion(ontologyId: string, versionId: string, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
102
122
|
/**
|
|
103
123
|
* Deprecate an ontology version.
|
|
104
124
|
*/
|
|
105
|
-
deprecateVersion(ontologyId: string, versionId: string, idempotencyKey?: string): Promise<
|
|
125
|
+
deprecateVersion(ontologyId: string, versionId: string, idempotencyKey?: string): Promise<PlatformGatewaySuccess<unknown>>;
|
|
106
126
|
/**
|
|
107
127
|
* List topics directly bound to a specific ontology definition.
|
|
108
128
|
* Uses the topics gateway with ontologyId filter.
|
|
109
129
|
*/
|
|
110
|
-
listTopics(ontologyId: string): Promise<
|
|
130
|
+
listTopics(ontologyId: string): Promise<PlatformGatewaySuccess<ListResult<any, "topics">>>;
|
|
111
131
|
/**
|
|
112
132
|
* @deprecated Use listTopics.
|
|
113
133
|
*/
|
|
114
|
-
listTopicsByOntology(ontologyId: string): Promise<
|
|
134
|
+
listTopicsByOntology(ontologyId: string): Promise<PlatformGatewaySuccess<ListResult<any, "topics">>>;
|
|
115
135
|
};
|
|
136
|
+
|
|
137
|
+
export { type OntologyBindingInput, type OntologyClientConfig, type OntologyDefinitionInput, type OntologyDefinitionUpdateInput, type OntologyVersionInput, createOntologyClient };
|
|
@@ -0,0 +1,513 @@
|
|
|
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/ontologyClient.ts
|
|
356
|
+
function createOntologyClient(config = {}) {
|
|
357
|
+
const gateway = createGatewayRequestClient(config);
|
|
358
|
+
return {
|
|
359
|
+
/**
|
|
360
|
+
* List ontology definitions matching optional filters.
|
|
361
|
+
*/
|
|
362
|
+
async list(filters = {}) {
|
|
363
|
+
return gateway.request({
|
|
364
|
+
path: `/api/platform/v1/ontologies${toQueryString(filters)}`
|
|
365
|
+
}).then(
|
|
366
|
+
(response) => mapGatewayData(response, (data) => {
|
|
367
|
+
const record = data && typeof data === "object" && !Array.isArray(data) ? data : {};
|
|
368
|
+
const ontologies = Array.isArray(record.ontologies) ? record.ontologies : Array.isArray(record.definitions) ? record.definitions : Array.isArray(data) ? data : [];
|
|
369
|
+
const total = typeof record.total === "number" && Number.isFinite(record.total) ? record.total : ontologies.length;
|
|
370
|
+
return {
|
|
371
|
+
...record,
|
|
372
|
+
...createListResult(ontologies, "definitions"),
|
|
373
|
+
ontologies,
|
|
374
|
+
total
|
|
375
|
+
};
|
|
376
|
+
})
|
|
377
|
+
);
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Get an ontology definition by identifier.
|
|
381
|
+
*/
|
|
382
|
+
async get(id) {
|
|
383
|
+
return gateway.request({
|
|
384
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`
|
|
385
|
+
});
|
|
386
|
+
},
|
|
387
|
+
/**
|
|
388
|
+
* Bind an ontology definition to a topic.
|
|
389
|
+
*/
|
|
390
|
+
async bind(input, idempotencyKey) {
|
|
391
|
+
return gateway.request({
|
|
392
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(input.ontologyId)}/bind`,
|
|
393
|
+
method: "POST",
|
|
394
|
+
body: {
|
|
395
|
+
topicId: input.topicId
|
|
396
|
+
},
|
|
397
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
398
|
+
});
|
|
399
|
+
},
|
|
400
|
+
/**
|
|
401
|
+
* List ontology definitions.
|
|
402
|
+
*/
|
|
403
|
+
async listDefinitions(filters = {}) {
|
|
404
|
+
return this.list(filters);
|
|
405
|
+
},
|
|
406
|
+
/**
|
|
407
|
+
* Get an ontology definition.
|
|
408
|
+
*/
|
|
409
|
+
async getDefinition(id) {
|
|
410
|
+
return this.get(id);
|
|
411
|
+
},
|
|
412
|
+
/**
|
|
413
|
+
* Create an ontology definition.
|
|
414
|
+
*/
|
|
415
|
+
async createDefinition(input, idempotencyKey) {
|
|
416
|
+
return gateway.request({
|
|
417
|
+
path: "/api/platform/v1/ontologies",
|
|
418
|
+
method: "POST",
|
|
419
|
+
body: input,
|
|
420
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
/**
|
|
424
|
+
* Update an ontology definition.
|
|
425
|
+
*/
|
|
426
|
+
async updateDefinition(id, input, idempotencyKey) {
|
|
427
|
+
return gateway.request({
|
|
428
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
|
|
429
|
+
method: "PATCH",
|
|
430
|
+
body: input,
|
|
431
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
432
|
+
});
|
|
433
|
+
},
|
|
434
|
+
/**
|
|
435
|
+
* Archive an ontology definition.
|
|
436
|
+
*/
|
|
437
|
+
async archiveDefinition(id, idempotencyKey) {
|
|
438
|
+
return gateway.request({
|
|
439
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(id)}`,
|
|
440
|
+
method: "DELETE",
|
|
441
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
442
|
+
});
|
|
443
|
+
},
|
|
444
|
+
/**
|
|
445
|
+
* List versions for an ontology definition.
|
|
446
|
+
*/
|
|
447
|
+
async listVersions(ontologyId, filters = {}) {
|
|
448
|
+
return gateway.request({
|
|
449
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions${toQueryString(filters)}`
|
|
450
|
+
}).then(
|
|
451
|
+
(response) => mapGatewayData(
|
|
452
|
+
response,
|
|
453
|
+
(data) => createListResult(Array.isArray(data) ? data : [], "versions")
|
|
454
|
+
)
|
|
455
|
+
);
|
|
456
|
+
},
|
|
457
|
+
/**
|
|
458
|
+
* Create an ontology version.
|
|
459
|
+
*/
|
|
460
|
+
async createVersion(ontologyId, input, idempotencyKey) {
|
|
461
|
+
return gateway.request({
|
|
462
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions`,
|
|
463
|
+
method: "POST",
|
|
464
|
+
body: input,
|
|
465
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
/**
|
|
469
|
+
* Publish an ontology version.
|
|
470
|
+
*/
|
|
471
|
+
async publishVersion(ontologyId, versionId, idempotencyKey) {
|
|
472
|
+
return gateway.request({
|
|
473
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/publish`,
|
|
474
|
+
method: "POST",
|
|
475
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
/**
|
|
479
|
+
* Deprecate an ontology version.
|
|
480
|
+
*/
|
|
481
|
+
async deprecateVersion(ontologyId, versionId, idempotencyKey) {
|
|
482
|
+
return gateway.request({
|
|
483
|
+
path: `/api/platform/v1/ontologies/${encodeURIComponent(ontologyId)}/versions/${encodeURIComponent(versionId)}/deprecate`,
|
|
484
|
+
method: "POST",
|
|
485
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
/**
|
|
489
|
+
* List topics directly bound to a specific ontology definition.
|
|
490
|
+
* Uses the topics gateway with ontologyId filter.
|
|
491
|
+
*/
|
|
492
|
+
async listTopics(ontologyId) {
|
|
493
|
+
return gateway.request({
|
|
494
|
+
path: `/api/platform/v1/topics?ontologyId=${encodeURIComponent(ontologyId)}`
|
|
495
|
+
}).then(
|
|
496
|
+
(response) => mapGatewayData(
|
|
497
|
+
response,
|
|
498
|
+
(data) => createListResult(Array.isArray(data) ? data : [], "topics")
|
|
499
|
+
)
|
|
500
|
+
);
|
|
501
|
+
},
|
|
502
|
+
/**
|
|
503
|
+
* @deprecated Use listTopics.
|
|
504
|
+
*/
|
|
505
|
+
async listTopicsByOntology(ontologyId) {
|
|
506
|
+
return this.listTopics(ontologyId);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
export { createOntologyClient };
|
|
512
|
+
//# sourceMappingURL=ontologyClient.js.map
|
|
513
|
+
//# sourceMappingURL=ontologyClient.js.map
|