@lucern/sdk 0.2.0-alpha.5 → 0.2.0-alpha.7
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/.turbo/turbo-build.log +7 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/CHANGELOG.md +13 -0
- package/examples/README.md +69 -0
- package/examples/contradiction.ts +94 -0
- package/examples/investigation-context.ts +118 -0
- package/examples/questions-and-tasks.ts +55 -0
- package/examples/quickstart.ts +97 -0
- package/examples/shared.ts +318 -0
- package/examples/strict-public-types.ts +143 -0
- package/examples/worktree-lifecycle.ts +79 -0
- package/package.json +16 -59
- package/src/README.md +6 -0
- package/src/adminClient.ts +789 -0
- package/{dist/lib/platform/sdk/answersClient.d.ts → src/answersClient.ts} +17 -4
- package/src/audiencesClient.ts +209 -0
- package/src/auditClient.ts +50 -0
- package/src/beliefsClient.ts +319 -0
- package/src/client.ts +2647 -0
- package/src/contextClient.ts +130 -0
- package/src/contextFacade.ts +15 -0
- package/src/contextPackCompiler.ts +828 -0
- package/src/contextPackSchema.ts +251 -0
- package/src/contextTypes.ts +153 -0
- package/src/contracts/api-enums.contract.ts +202 -0
- package/src/contracts/auth-session.contract.ts +109 -0
- package/src/contracts/context-pack.contract.ts +700 -0
- package/src/contracts/contextPack.ts +1 -0
- package/src/contracts/index.ts +10 -0
- package/src/contracts/lens-filter.contract.ts +183 -0
- package/src/contracts/lens-workflow.contract.ts +162 -0
- package/src/contracts/lensFilter.ts +1 -0
- package/src/contracts/lensWorkflow.ts +1 -0
- package/src/contracts/mcp-tools.contract.ts +3636 -0
- package/src/contracts/mcpTools.ts +1 -0
- package/src/contracts/prompt.contract.ts +50 -0
- package/src/contracts/prompt.ts +1 -0
- package/src/contracts/sdk-tools.contract.ts +1457 -0
- package/src/contracts/sdkTools.ts +1 -0
- package/src/contracts/workflow-runtime.contract.ts +440 -0
- package/src/contracts/workflowRuntime.ts +1 -0
- package/src/controlObjectOwnership.ts +286 -0
- package/src/coreClient.ts +570 -0
- package/src/customTools.ts +398 -0
- package/src/decisionsClient.ts +286 -0
- package/src/domainContext.ts +15 -0
- package/src/events.ts +531 -0
- package/src/eventsCore.ts +168 -0
- package/src/facade/beliefs.ts +83 -0
- package/src/facade/context.ts +110 -0
- package/src/facade/contradictions.ts +29 -0
- package/src/facade/edges.ts +30 -0
- package/src/facade/events.ts +23 -0
- package/src/facade/evidence.ts +41 -0
- package/src/facade/graph.ts +38 -0
- package/src/facade/identity.ts +16 -0
- package/src/facade/ontologies.ts +34 -0
- package/src/facade/questions.ts +59 -0
- package/src/facade/search.ts +16 -0
- package/src/facade/tasks.ts +37 -0
- package/src/facade/topics.ts +42 -0
- package/src/facade/webhooks.ts +58 -0
- package/src/facade/worktrees.ts +51 -0
- package/src/gatewayFacades.ts +1666 -0
- package/src/graphClient.ts +529 -0
- package/src/harnessClient.ts +585 -0
- package/src/identityClient.ts +278 -0
- package/{dist/lib/platform/sdk/index.d.ts → src/index.ts} +3 -0
- package/src/learningClient.ts +95 -0
- package/src/mcpParityClient.ts +240 -0
- package/src/mcpParitySurface.ts +70 -0
- package/src/ontologyClient.ts +275 -0
- package/src/packRuntime.ts +3 -0
- package/src/packsClient.ts +260 -0
- package/src/policyClient.ts +572 -0
- package/src/promptCatalog.ts +1 -0
- package/src/realtime/index.ts +51 -0
- package/src/realtime/refs.ts +17 -0
- package/src/reportsClient.ts +99 -0
- package/src/schemaClient.ts +129 -0
- package/src/sdkSurface.ts +190 -0
- package/src/topicsClient.ts +243 -0
- package/src/types.ts +807 -0
- package/src/workflowClient.ts +826 -0
- package/tsconfig.json +9 -0
- package/dist/.generated +0 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/lib/platform/auth/credentials.d.ts +0 -5
- package/dist/lib/platform/auth/credentials.js +0 -40
- package/dist/lib/platform/sdk/adminClient.d.ts +0 -404
- package/dist/lib/platform/sdk/adminClient.js +0 -384
- package/dist/lib/platform/sdk/answersClient.js +0 -21
- package/dist/lib/platform/sdk/audiencesClient.d.ts +0 -93
- package/dist/lib/platform/sdk/audiencesClient.js +0 -111
- package/dist/lib/platform/sdk/auditClient.d.ts +0 -24
- package/dist/lib/platform/sdk/auditClient.js +0 -21
- package/dist/lib/platform/sdk/beliefsClient.d.ts +0 -157
- package/dist/lib/platform/sdk/beliefsClient.js +0 -124
- package/dist/lib/platform/sdk/client.d.ts +0 -2369
- package/dist/lib/platform/sdk/client.js +0 -1831
- package/dist/lib/platform/sdk/contextClient.d.ts +0 -21
- package/dist/lib/platform/sdk/contextClient.js +0 -86
- package/dist/lib/platform/sdk/contextPackCompiler.d.ts +0 -100
- package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
- package/dist/lib/platform/sdk/contextTypes.d.ts +0 -133
- package/dist/lib/platform/sdk/contextTypes.js +0 -1
- package/dist/lib/platform/sdk/controlObjectOwnership.d.ts +0 -308
- package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
- package/dist/lib/platform/sdk/coreClient.d.ts +0 -139
- package/dist/lib/platform/sdk/coreClient.js +0 -366
- package/dist/lib/platform/sdk/customTools.d.ts +0 -83
- package/dist/lib/platform/sdk/customTools.js +0 -247
- package/dist/lib/platform/sdk/decisionsClient.d.ts +0 -106
- package/dist/lib/platform/sdk/decisionsClient.js +0 -129
- package/dist/lib/platform/sdk/domainContext.d.ts +0 -1
- package/dist/lib/platform/sdk/domainContext.js +0 -1
- package/dist/lib/platform/sdk/events.d.ts +0 -176
- package/dist/lib/platform/sdk/events.js +0 -261
- package/dist/lib/platform/sdk/gatewayFacades.d.ts +0 -586
- package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
- package/dist/lib/platform/sdk/graphClient.d.ts +0 -266
- package/dist/lib/platform/sdk/graphClient.js +0 -235
- package/dist/lib/platform/sdk/harnessClient.d.ts +0 -309
- package/dist/lib/platform/sdk/harnessClient.js +0 -219
- package/dist/lib/platform/sdk/identityClient.d.ts +0 -134
- package/dist/lib/platform/sdk/identityClient.js +0 -131
- package/dist/lib/platform/sdk/index.js +0 -46
- package/dist/lib/platform/sdk/learningClient.d.ts +0 -40
- package/dist/lib/platform/sdk/learningClient.js +0 -53
- package/dist/lib/platform/sdk/mcpParityClient.d.ts +0 -69
- package/dist/lib/platform/sdk/mcpParityClient.js +0 -196
- package/dist/lib/platform/sdk/mcpParitySurface.d.ts +0 -10
- package/dist/lib/platform/sdk/mcpParitySurface.js +0 -57
- package/dist/lib/platform/sdk/ontologyClient.d.ts +0 -131
- package/dist/lib/platform/sdk/ontologyClient.js +0 -161
- package/dist/lib/platform/sdk/packRuntime.d.ts +0 -1
- package/dist/lib/platform/sdk/packRuntime.js +0 -1
- package/dist/lib/platform/sdk/packsClient.d.ts +0 -126
- package/dist/lib/platform/sdk/packsClient.js +0 -157
- package/dist/lib/platform/sdk/policyClient.d.ts +0 -293
- package/dist/lib/platform/sdk/policyClient.js +0 -277
- package/dist/lib/platform/sdk/promptCatalog.d.ts +0 -1
- package/dist/lib/platform/sdk/promptCatalog.js +0 -1
- package/dist/lib/platform/sdk/reportsClient.d.ts +0 -34
- package/dist/lib/platform/sdk/reportsClient.js +0 -64
- package/dist/lib/platform/sdk/schemaClient.d.ts +0 -59
- package/dist/lib/platform/sdk/schemaClient.js +0 -71
- package/dist/lib/platform/sdk/sdkSurface.d.ts +0 -56
- package/dist/lib/platform/sdk/sdkSurface.js +0 -140
- package/dist/lib/platform/sdk/topicsClient.d.ts +0 -78
- package/dist/lib/platform/sdk/topicsClient.js +0 -118
- package/dist/lib/platform/sdk/types.d.ts +0 -692
- package/dist/lib/platform/sdk/types.js +0 -1
- package/dist/lib/platform/sdk/version.d.ts +0 -2
- package/dist/lib/platform/sdk/workflowClient.d.ts +0 -313
- package/dist/lib/platform/sdk/workflowClient.js +0 -366
- package/dist/lucern/contracts/src/api-enums.contract.d.ts +0 -58
- package/dist/lucern/contracts/src/api-enums.contract.js +0 -147
- package/dist/lucern/contracts/src/lens-filter.contract.d.ts +0 -70
- package/dist/lucern/contracts/src/lens-filter.contract.js +0 -95
- package/dist/lucern/contracts/src/lens-workflow.contract.d.ts +0 -84
- package/dist/lucern/contracts/src/lens-workflow.contract.js +0 -54
- package/dist/lucern/contracts/src/mcp-tools.contract.d.ts +0 -151
- package/dist/lucern/contracts/src/mcp-tools.contract.js +0 -3281
- /package/{dist/lib/platform/sdk/version.js → src/version.ts} +0 -0
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type GatewayClientConfig, type GatewayScope, LucernApiError } from "./coreClient";
|
|
2
|
-
import type { JsonObject } from "./types";
|
|
3
|
-
export { LucernApiError };
|
|
4
|
-
export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
|
|
5
|
-
/** Configuration for the schema client. */
|
|
6
|
-
export type SchemaClientConfig = GatewayClientConfig;
|
|
7
|
-
/** Input for installing a schema pack into a tenant scope. */
|
|
8
|
-
export type SchemaPackInstallInput = GatewayScope & {
|
|
9
|
-
packKey: string;
|
|
10
|
-
version?: string;
|
|
11
|
-
autoEnable?: boolean;
|
|
12
|
-
metadata?: JsonObject;
|
|
13
|
-
};
|
|
14
|
-
/** Input for creating or updating a schema entitlement record. */
|
|
15
|
-
export type SchemaEntitlementInput = GatewayScope & {
|
|
16
|
-
packKey: string;
|
|
17
|
-
status: "active" | "disabled" | "revoked";
|
|
18
|
-
allowedLifecycles?: Array<"active" | "beta" | "experimental">;
|
|
19
|
-
minVersion?: string;
|
|
20
|
-
maxVersion?: string;
|
|
21
|
-
metadata?: JsonObject;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Create the schema client for pack catalog and entitlement operations.
|
|
25
|
-
* @param config - Gateway transport configuration.
|
|
26
|
-
* @returns An object with methods to manage schema packs and entitlements.
|
|
27
|
-
*/
|
|
28
|
-
export declare function createSchemaClient(config?: SchemaClientConfig): {
|
|
29
|
-
/**
|
|
30
|
-
* List schema packs.
|
|
31
|
-
*/
|
|
32
|
-
listPacks(scope?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "packs">>>;
|
|
33
|
-
/**
|
|
34
|
-
* Install a schema pack.
|
|
35
|
-
*/
|
|
36
|
-
installPack(input: SchemaPackInstallInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
|
|
37
|
-
/**
|
|
38
|
-
* Get a schema pack by identifier.
|
|
39
|
-
*/
|
|
40
|
-
getPack(packId: string, scope?: GatewayScope): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
|
|
41
|
-
/**
|
|
42
|
-
* List schema entitlements.
|
|
43
|
-
*/
|
|
44
|
-
listEntitlements(scope?: GatewayScope & {
|
|
45
|
-
packKey?: string;
|
|
46
|
-
}): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "entitlements">>>;
|
|
47
|
-
/**
|
|
48
|
-
* Create a schema entitlement.
|
|
49
|
-
*/
|
|
50
|
-
createEntitlement(input: SchemaEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
|
|
51
|
-
/**
|
|
52
|
-
* Update a schema entitlement.
|
|
53
|
-
*/
|
|
54
|
-
updateEntitlement(input: SchemaEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated Use createEntitlement or updateEntitlement.
|
|
57
|
-
*/
|
|
58
|
-
upsertEntitlement(input: SchemaEntitlementInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<unknown>>;
|
|
59
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { createGatewayRequestClient, LucernApiError, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
|
|
2
|
-
import { createListResult, mapGatewayData } from "./sdkSurface.js";
|
|
3
|
-
export { LucernApiError };
|
|
4
|
-
/**
|
|
5
|
-
* Create the schema client for pack catalog and entitlement operations.
|
|
6
|
-
* @param config - Gateway transport configuration.
|
|
7
|
-
* @returns An object with methods to manage schema packs and entitlements.
|
|
8
|
-
*/
|
|
9
|
-
export function createSchemaClient(config = {}) {
|
|
10
|
-
const gateway = createGatewayRequestClient(config);
|
|
11
|
-
return {
|
|
12
|
-
/**
|
|
13
|
-
* List schema packs.
|
|
14
|
-
*/
|
|
15
|
-
async listPacks(scope = {}) {
|
|
16
|
-
return gateway.request({
|
|
17
|
-
path: `/api/platform/v1/schema/packs${toQueryString(scope)}`,
|
|
18
|
-
}).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "packs")));
|
|
19
|
-
},
|
|
20
|
-
/**
|
|
21
|
-
* Install a schema pack.
|
|
22
|
-
*/
|
|
23
|
-
async installPack(input, idempotencyKey) {
|
|
24
|
-
return gateway.request({
|
|
25
|
-
path: "/api/platform/v1/schema/packs",
|
|
26
|
-
method: "POST",
|
|
27
|
-
body: input,
|
|
28
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Get a schema pack by identifier.
|
|
33
|
-
*/
|
|
34
|
-
async getPack(packId, scope = {}) {
|
|
35
|
-
return gateway.request({
|
|
36
|
-
path: `/api/platform/v1/schema/packs/${encodeURIComponent(packId)}${toQueryString(scope)}`,
|
|
37
|
-
});
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* List schema entitlements.
|
|
41
|
-
*/
|
|
42
|
-
async listEntitlements(scope = {}) {
|
|
43
|
-
return gateway.request({
|
|
44
|
-
path: `/api/platform/v1/schema/entitlements${toQueryString(scope)}`,
|
|
45
|
-
}).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "entitlements")));
|
|
46
|
-
},
|
|
47
|
-
/**
|
|
48
|
-
* Create a schema entitlement.
|
|
49
|
-
*/
|
|
50
|
-
async createEntitlement(input, idempotencyKey) {
|
|
51
|
-
return gateway.request({
|
|
52
|
-
path: "/api/platform/v1/schema/entitlements",
|
|
53
|
-
method: "POST",
|
|
54
|
-
body: input,
|
|
55
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* Update a schema entitlement.
|
|
60
|
-
*/
|
|
61
|
-
async updateEntitlement(input, idempotencyKey) {
|
|
62
|
-
return this.createEntitlement(input, idempotencyKey);
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated Use createEntitlement or updateEntitlement.
|
|
66
|
-
*/
|
|
67
|
-
async upsertEntitlement(input, idempotencyKey) {
|
|
68
|
-
return this.createEntitlement(input, idempotencyKey);
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { PlatformGatewaySuccess } from "./coreClient";
|
|
2
|
-
import type { JsonObject, ListResult } from "./types";
|
|
3
|
-
type TopicScopedValue = {
|
|
4
|
-
topicId?: string;
|
|
5
|
-
};
|
|
6
|
-
type TextScopedValue = {
|
|
7
|
-
text?: string;
|
|
8
|
-
canonicalText?: string;
|
|
9
|
-
};
|
|
10
|
-
type AnyRecord = Record<string, unknown>;
|
|
11
|
-
/**
|
|
12
|
-
* Resolve the canonical topic identifier.
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveTopicId(value: TopicScopedValue): string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Resolve the canonical text field from text-first or legacy canonicalText-first inputs.
|
|
17
|
-
*/
|
|
18
|
-
export declare function resolveText(value: TextScopedValue): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Attach the topicId to a record.
|
|
21
|
-
*/
|
|
22
|
-
export declare function withTopicAlias<T extends AnyRecord>(value: T): T;
|
|
23
|
-
/**
|
|
24
|
-
* Attach the text/canonicalText alias pair to a record.
|
|
25
|
-
*/
|
|
26
|
-
export declare function withTextAlias<T extends AnyRecord>(value: T): T;
|
|
27
|
-
/**
|
|
28
|
-
* Attach topic and text aliases to SDK node-like records.
|
|
29
|
-
*/
|
|
30
|
-
export declare function withSdkAliases<T extends AnyRecord>(value: T): T;
|
|
31
|
-
/**
|
|
32
|
-
* Normalize a belief/question/evidence write payload to the canonical gateway shape.
|
|
33
|
-
*/
|
|
34
|
-
export declare function normalizeNodeWriteInput<T extends JsonObject>(value: T): T;
|
|
35
|
-
export declare function normalizeNodeVerificationStatus(value: unknown): string | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Build a topic-aware query object.
|
|
38
|
-
*/
|
|
39
|
-
export declare function normalizeTopicQuery<T extends JsonObject>(value: T): T;
|
|
40
|
-
/**
|
|
41
|
-
* Extract list items from array or list-envelope payloads.
|
|
42
|
-
*/
|
|
43
|
-
export declare function asListItems<T>(data: unknown, legacyKey?: string): T[];
|
|
44
|
-
/**
|
|
45
|
-
* Standardize list data to { items, total } while retaining an optional legacy array key.
|
|
46
|
-
*/
|
|
47
|
-
export declare function createListResult<T, LegacyKey extends string>(items: T[], legacyKey?: LegacyKey): ListResult<T, LegacyKey>;
|
|
48
|
-
/**
|
|
49
|
-
* Map a gateway success envelope's data while preserving the transport metadata.
|
|
50
|
-
*/
|
|
51
|
-
export declare function mapGatewayData<T, U>(response: PlatformGatewaySuccess<T>, mapper: (data: T) => U): PlatformGatewaySuccess<U>;
|
|
52
|
-
/**
|
|
53
|
-
* Apply SDK aliases across all items in a list-like payload.
|
|
54
|
-
*/
|
|
55
|
-
export declare function mapAliasedList<TItem extends AnyRecord, LegacyKey extends string>(data: unknown, legacyKey?: LegacyKey): ListResult<TItem, LegacyKey>;
|
|
56
|
-
export {};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
function asRecord(value) {
|
|
2
|
-
return value && typeof value === "object" ? value : {};
|
|
3
|
-
}
|
|
4
|
-
function cleanString(value) {
|
|
5
|
-
return typeof value === "string" && value.trim().length > 0
|
|
6
|
-
? value.trim()
|
|
7
|
-
: undefined;
|
|
8
|
-
}
|
|
9
|
-
function normalizeVerificationStatus(value) {
|
|
10
|
-
const status = cleanString(value);
|
|
11
|
-
if (!status) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
if (status === "verified") {
|
|
15
|
-
return "human_verified";
|
|
16
|
-
}
|
|
17
|
-
if (status === "rejected") {
|
|
18
|
-
return "contradicted";
|
|
19
|
-
}
|
|
20
|
-
return status;
|
|
21
|
-
}
|
|
22
|
-
function cloneWith(value, patch) {
|
|
23
|
-
return { ...value, ...patch };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Resolve the canonical topic identifier.
|
|
27
|
-
*/
|
|
28
|
-
export function resolveTopicId(value) {
|
|
29
|
-
return cleanString(value.topicId);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Resolve the canonical text field from text-first or legacy canonicalText-first inputs.
|
|
33
|
-
*/
|
|
34
|
-
export function resolveText(value) {
|
|
35
|
-
return cleanString(value.text) ?? cleanString(value.canonicalText);
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Attach the topicId to a record.
|
|
39
|
-
*/
|
|
40
|
-
export function withTopicAlias(value) {
|
|
41
|
-
const topicId = cleanString(value.topicId) ?? undefined;
|
|
42
|
-
if (!topicId) {
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
return cloneWith(value, { topicId });
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Attach the text/canonicalText alias pair to a record.
|
|
49
|
-
*/
|
|
50
|
-
export function withTextAlias(value) {
|
|
51
|
-
const text = cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;
|
|
52
|
-
if (!text) {
|
|
53
|
-
return value;
|
|
54
|
-
}
|
|
55
|
-
return cloneWith(value, { text, canonicalText: text });
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Attach topic and text aliases to SDK node-like records.
|
|
59
|
-
*/
|
|
60
|
-
export function withSdkAliases(value) {
|
|
61
|
-
return withTopicAlias(withTextAlias(value));
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Normalize a belief/question/evidence write payload to the canonical gateway shape.
|
|
65
|
-
*/
|
|
66
|
-
export function normalizeNodeWriteInput(value) {
|
|
67
|
-
const topicId = resolveTopicId(value);
|
|
68
|
-
const text = resolveText(value);
|
|
69
|
-
const verificationStatus = normalizeVerificationStatus(value.verificationStatus);
|
|
70
|
-
const next = { ...value };
|
|
71
|
-
if (topicId) {
|
|
72
|
-
next.topicId = topicId;
|
|
73
|
-
}
|
|
74
|
-
if (text) {
|
|
75
|
-
next.text = text;
|
|
76
|
-
next.canonicalText = text;
|
|
77
|
-
}
|
|
78
|
-
if (verificationStatus) {
|
|
79
|
-
next.verificationStatus = verificationStatus;
|
|
80
|
-
}
|
|
81
|
-
return next;
|
|
82
|
-
}
|
|
83
|
-
export function normalizeNodeVerificationStatus(value) {
|
|
84
|
-
return normalizeVerificationStatus(value);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Build a topic-aware query object.
|
|
88
|
-
*/
|
|
89
|
-
export function normalizeTopicQuery(value) {
|
|
90
|
-
const topicId = cleanString(value.topicId);
|
|
91
|
-
if (!topicId) {
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
return { ...value, topicId };
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Extract list items from array or list-envelope payloads.
|
|
98
|
-
*/
|
|
99
|
-
export function asListItems(data, legacyKey) {
|
|
100
|
-
if (Array.isArray(data)) {
|
|
101
|
-
return data;
|
|
102
|
-
}
|
|
103
|
-
const record = asRecord(data);
|
|
104
|
-
if (Array.isArray(record.items)) {
|
|
105
|
-
return record.items;
|
|
106
|
-
}
|
|
107
|
-
if (legacyKey && Array.isArray(record[legacyKey])) {
|
|
108
|
-
return record[legacyKey];
|
|
109
|
-
}
|
|
110
|
-
return [];
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Standardize list data to { items, total } while retaining an optional legacy array key.
|
|
114
|
-
*/
|
|
115
|
-
export function createListResult(items, legacyKey) {
|
|
116
|
-
const result = {
|
|
117
|
-
items,
|
|
118
|
-
total: items.length,
|
|
119
|
-
};
|
|
120
|
-
if (legacyKey) {
|
|
121
|
-
result[legacyKey] = items;
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Map a gateway success envelope's data while preserving the transport metadata.
|
|
127
|
-
*/
|
|
128
|
-
export function mapGatewayData(response, mapper) {
|
|
129
|
-
return {
|
|
130
|
-
...response,
|
|
131
|
-
data: mapper(response.data),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Apply SDK aliases across all items in a list-like payload.
|
|
136
|
-
*/
|
|
137
|
-
export function mapAliasedList(data, legacyKey) {
|
|
138
|
-
const items = asListItems(data, legacyKey).map((item) => withSdkAliases(item));
|
|
139
|
-
return createListResult(items, legacyKey);
|
|
140
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { type GatewayClientConfig } from "./coreClient";
|
|
2
|
-
import type { JsonObject, TopicCoverageResponse, TopicIdentifierInput, TopicListResponse, TopicRecord, TopicTreeResponse } from "./types";
|
|
3
|
-
/** Configuration for the topics client. Inherits gateway transport settings. */
|
|
4
|
-
export type TopicsClientConfig = GatewayClientConfig;
|
|
5
|
-
/** Filters for listing topics within a scope. */
|
|
6
|
-
export type TopicListInput = TopicIdentifierInput & {
|
|
7
|
-
ontologyId?: string;
|
|
8
|
-
parentTopicId?: string;
|
|
9
|
-
status?: string;
|
|
10
|
-
type?: string;
|
|
11
|
-
};
|
|
12
|
-
/** Input for creating a new topic. Name is required; all other fields are optional. */
|
|
13
|
-
export type TopicCreateInput = TopicIdentifierInput & {
|
|
14
|
-
name: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
type?: string;
|
|
17
|
-
parentTopicId?: string;
|
|
18
|
-
ontologyId?: string;
|
|
19
|
-
tenantId?: string;
|
|
20
|
-
workspaceId?: string;
|
|
21
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
22
|
-
createdBy?: string;
|
|
23
|
-
metadata?: JsonObject;
|
|
24
|
-
};
|
|
25
|
-
/** Input for updating an existing topic's metadata. All fields are optional. */
|
|
26
|
-
export type TopicUpdateInput = TopicIdentifierInput & {
|
|
27
|
-
name?: string;
|
|
28
|
-
description?: string;
|
|
29
|
-
type?: string;
|
|
30
|
-
ontologyId?: string;
|
|
31
|
-
clearOntologyId?: boolean;
|
|
32
|
-
status?: "active" | "archived" | "watching";
|
|
33
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
34
|
-
};
|
|
35
|
-
/** Options for retrieving the topic hierarchy. */
|
|
36
|
-
export type TopicTreeQuery = {
|
|
37
|
-
maxDepth?: number;
|
|
38
|
-
};
|
|
39
|
-
/** Options for retrieving belief/question/evidence coverage across a topic tree. */
|
|
40
|
-
export type TopicCoverageQuery = {
|
|
41
|
-
includeDescendants?: boolean;
|
|
42
|
-
maxDepth?: number;
|
|
43
|
-
};
|
|
44
|
-
/** Input for batch-creating topics. */
|
|
45
|
-
export type TopicBulkCreateInput = {
|
|
46
|
-
topics: Array<TopicIdentifierInput & {
|
|
47
|
-
globalId?: string;
|
|
48
|
-
name: string;
|
|
49
|
-
description?: string;
|
|
50
|
-
type: string;
|
|
51
|
-
parentTopicId?: string;
|
|
52
|
-
depth?: number;
|
|
53
|
-
path?: string[];
|
|
54
|
-
tenantId?: string;
|
|
55
|
-
workspaceId?: string;
|
|
56
|
-
graphScopeProjectId?: string;
|
|
57
|
-
status?: "active" | "archived" | "watching";
|
|
58
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
59
|
-
metadata?: JsonObject;
|
|
60
|
-
createdBy?: string;
|
|
61
|
-
}>;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Create the topics client for managing hierarchical knowledge containers.
|
|
65
|
-
*
|
|
66
|
-
* @param config - Gateway transport configuration.
|
|
67
|
-
* @returns An object with `list`, `get`, `create`, `update`, `getTree`, and `getCoverage` methods.
|
|
68
|
-
*/
|
|
69
|
-
export declare function createTopicsClient(config?: TopicsClientConfig): {
|
|
70
|
-
list(query?: TopicListInput): Promise<import("./coreClient").PlatformGatewaySuccess<TopicListResponse>>;
|
|
71
|
-
get(topicId: string): Promise<import("./coreClient").PlatformGatewaySuccess<TopicRecord>>;
|
|
72
|
-
create(input: TopicCreateInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<TopicRecord>>;
|
|
73
|
-
update(topicId: string, input: TopicUpdateInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<TopicRecord>>;
|
|
74
|
-
getTree(topicId: string, query?: TopicTreeQuery): Promise<import("./coreClient").PlatformGatewaySuccess<TopicTreeResponse>>;
|
|
75
|
-
getCoverage(topicId: string, query?: TopicCoverageQuery): Promise<import("./coreClient").PlatformGatewaySuccess<TopicCoverageResponse>>;
|
|
76
|
-
remove(topicId: string, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<Record<string, unknown>>>;
|
|
77
|
-
bulkCreate(input: TopicBulkCreateInput, idempotencyKey?: string): Promise<import("./coreClient").PlatformGatewaySuccess<Record<string, unknown>>>;
|
|
78
|
-
};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { createGatewayRequestClient, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
|
|
2
|
-
import { createListResult, mapGatewayData, resolveTopicId, withTopicAlias, } from "./sdkSurface.js";
|
|
3
|
-
function asRecord(value) {
|
|
4
|
-
return value && typeof value === "object"
|
|
5
|
-
? value
|
|
6
|
-
: {};
|
|
7
|
-
}
|
|
8
|
-
function cleanString(value) {
|
|
9
|
-
return typeof value === "string" && value.trim().length > 0
|
|
10
|
-
? value.trim()
|
|
11
|
-
: undefined;
|
|
12
|
-
}
|
|
13
|
-
function normalizeTopicRecord(value) {
|
|
14
|
-
const record = asRecord(value);
|
|
15
|
-
const topicId = cleanString(record.topicId) ??
|
|
16
|
-
cleanString(record.id) ??
|
|
17
|
-
cleanString(record._id);
|
|
18
|
-
return withTopicAlias({
|
|
19
|
-
...record,
|
|
20
|
-
...(topicId ? { topicId } : {}),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function normalizeTopicTreeNode(value) {
|
|
24
|
-
return normalizeTopicRecord(value);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create the topics client for managing hierarchical knowledge containers.
|
|
28
|
-
*
|
|
29
|
-
* @param config - Gateway transport configuration.
|
|
30
|
-
* @returns An object with `list`, `get`, `create`, `update`, `getTree`, and `getCoverage` methods.
|
|
31
|
-
*/
|
|
32
|
-
export function createTopicsClient(config = {}) {
|
|
33
|
-
const gateway = createGatewayRequestClient(config);
|
|
34
|
-
return {
|
|
35
|
-
async list(query = {}) {
|
|
36
|
-
const topicId = resolveTopicId(query);
|
|
37
|
-
return gateway.request({
|
|
38
|
-
path: `/api/platform/v1/topics${toQueryString({
|
|
39
|
-
...(topicId ? { topicId } : {}),
|
|
40
|
-
ontologyId: query.ontologyId,
|
|
41
|
-
parentTopicId: query.parentTopicId,
|
|
42
|
-
status: query.status,
|
|
43
|
-
type: query.type,
|
|
44
|
-
})}`,
|
|
45
|
-
}).then((response) => mapGatewayData(response, (data) => {
|
|
46
|
-
const record = asRecord(data);
|
|
47
|
-
const items = Array.isArray(record.topics)
|
|
48
|
-
? record.topics.map(normalizeTopicRecord)
|
|
49
|
-
: [];
|
|
50
|
-
return {
|
|
51
|
-
...createListResult(items, "topics"),
|
|
52
|
-
...record,
|
|
53
|
-
topics: items,
|
|
54
|
-
total: typeof record.total === "number" ? record.total : items.length,
|
|
55
|
-
};
|
|
56
|
-
}));
|
|
57
|
-
},
|
|
58
|
-
async get(topicId) {
|
|
59
|
-
return gateway.request({
|
|
60
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}`,
|
|
61
|
-
}).then((response) => mapGatewayData(response, (data) => normalizeTopicRecord(asRecord(data).topic ?? data)));
|
|
62
|
-
},
|
|
63
|
-
async create(input, idempotencyKey) {
|
|
64
|
-
const topicId = resolveTopicId(input);
|
|
65
|
-
return gateway.request({
|
|
66
|
-
path: "/api/platform/v1/topics",
|
|
67
|
-
method: "POST",
|
|
68
|
-
body: {
|
|
69
|
-
...input,
|
|
70
|
-
...(topicId ? { topicId } : {}),
|
|
71
|
-
type: input.type ?? "theme",
|
|
72
|
-
},
|
|
73
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
74
|
-
}).then((response) => mapGatewayData(response, (data) => normalizeTopicRecord(data)));
|
|
75
|
-
},
|
|
76
|
-
async update(topicId, input, idempotencyKey) {
|
|
77
|
-
return gateway.request({
|
|
78
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}`,
|
|
79
|
-
method: "PATCH",
|
|
80
|
-
body: input,
|
|
81
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
82
|
-
}).then((response) => mapGatewayData(response, (data) => normalizeTopicRecord(data)));
|
|
83
|
-
},
|
|
84
|
-
async getTree(topicId, query = {}) {
|
|
85
|
-
return gateway.request({
|
|
86
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/tree${toQueryString(query)}`,
|
|
87
|
-
}).then((response) => mapGatewayData(response, (data) => {
|
|
88
|
-
const record = asRecord(data);
|
|
89
|
-
return {
|
|
90
|
-
tree: Array.isArray(record.tree)
|
|
91
|
-
? record.tree.map(normalizeTopicTreeNode)
|
|
92
|
-
: [],
|
|
93
|
-
};
|
|
94
|
-
}));
|
|
95
|
-
},
|
|
96
|
-
async getCoverage(topicId, query = {}) {
|
|
97
|
-
return gateway.request({
|
|
98
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(query)}`,
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
async remove(topicId, idempotencyKey) {
|
|
102
|
-
return gateway.request({
|
|
103
|
-
path: "/api/platform/v1/topics/remove",
|
|
104
|
-
method: "POST",
|
|
105
|
-
body: { id: topicId },
|
|
106
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
async bulkCreate(input, idempotencyKey) {
|
|
110
|
-
return gateway.request({
|
|
111
|
-
path: "/api/platform/v1/topics/bulk",
|
|
112
|
-
method: "POST",
|
|
113
|
-
body: input,
|
|
114
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
}
|