@lucern/sdk 0.2.0-alpha.7 → 0.2.0-alpha.9
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/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/audiencesClient.d.ts +99 -0
- 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/beliefsClient.d.ts +162 -0
- package/dist/beliefsClient.js +477 -0
- package/dist/beliefsClient.js.map +1 -0
- package/dist/client.d.ts +2378 -0
- package/dist/client.js +6134 -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/contextPackCompiler.d.ts +102 -0
- 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/{src/contextPackSchema.ts → dist/contextPackSchema.js} +22 -70
- 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 +92 -0
- package/dist/contracts/api-enums.contract.js.map +1 -0
- package/dist/contracts/auth-session.contract.d.ts +55 -0
- package/dist/contracts/auth-session.contract.js +48 -0
- package/dist/contracts/auth-session.contract.js.map +1 -0
- package/dist/contracts/context-pack.contract.d.ts +492 -0
- 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 +4892 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/lens-filter.contract.d.ts +72 -0
- 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 +2986 -0
- package/dist/contracts/mcp-tools.contract.js.map +1 -0
- package/dist/contracts/mcpTools.d.ts +1 -0
- package/dist/contracts/mcpTools.js +2986 -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 +4134 -0
- package/dist/contracts/sdk-tools.contract.js.map +1 -0
- package/dist/contracts/sdkTools.d.ts +2 -0
- package/dist/contracts/sdkTools.js +4134 -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/controlObjectOwnership.d.ts +310 -0
- package/{src/controlObjectOwnership.ts → dist/controlObjectOwnership.js} +53 -124
- package/dist/controlObjectOwnership.js.map +1 -0
- package/dist/coreClient.d.ts +144 -0
- 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/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/events.d.ts +178 -0
- package/dist/events.js +249 -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/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 +591 -0
- package/dist/gatewayFacades.js +1953 -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/harnessClient.d.ts +314 -0
- 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 +42 -0
- package/dist/index.js +11381 -0
- package/dist/index.js.map +1 -0
- package/dist/learningClient.d.ts +46 -0
- package/dist/learningClient.js +409 -0
- package/dist/learningClient.js.map +1 -0
- package/dist/mcpParityClient.d.ts +74 -0
- package/dist/mcpParityClient.js +516 -0
- package/dist/mcpParityClient.js.map +1 -0
- package/dist/mcpParitySurface.d.ts +12 -0
- package/{src/mcpParitySurface.ts → dist/mcpParitySurface.js} +9 -14
- package/dist/mcpParitySurface.js.map +1 -0
- package/dist/mcpTools-DPZxowDX.d.ts +254 -0
- package/dist/ontologyClient.d.ts +137 -0
- package/dist/ontologyClient.js +513 -0
- package/dist/ontologyClient.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/policyClient.d.ts +299 -0
- package/dist/policyClient.js +625 -0
- package/dist/policyClient.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/{src/realtime/refs.ts → dist/realtime/refs.d.ts} +5 -5
- 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/topicsClient.d.ts +84 -0
- package/dist/topicsClient.js +492 -0
- package/dist/topicsClient.js.map +1 -0
- package/dist/types.d.ts +696 -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/package.json +39 -7
- package/.turbo/turbo-build.log +0 -7
- package/.turbo/turbo-typecheck.log +0 -4
- package/examples/README.md +0 -69
- package/examples/contradiction.ts +0 -94
- package/examples/investigation-context.ts +0 -118
- package/examples/questions-and-tasks.ts +0 -55
- package/examples/quickstart.ts +0 -97
- package/examples/shared.ts +0 -318
- package/examples/strict-public-types.ts +0 -143
- package/examples/worktree-lifecycle.ts +0 -79
- package/src/README.md +0 -6
- package/src/adminClient.ts +0 -789
- package/src/answersClient.ts +0 -29
- package/src/audiencesClient.ts +0 -209
- package/src/auditClient.ts +0 -50
- package/src/beliefsClient.ts +0 -319
- package/src/client.ts +0 -2647
- package/src/contextClient.ts +0 -130
- package/src/contextFacade.ts +0 -15
- package/src/contextPackCompiler.ts +0 -828
- package/src/contextTypes.ts +0 -153
- package/src/contracts/api-enums.contract.ts +0 -202
- package/src/contracts/auth-session.contract.ts +0 -109
- package/src/contracts/context-pack.contract.ts +0 -700
- package/src/contracts/contextPack.ts +0 -1
- package/src/contracts/index.ts +0 -10
- package/src/contracts/lens-filter.contract.ts +0 -183
- package/src/contracts/lens-workflow.contract.ts +0 -162
- package/src/contracts/lensFilter.ts +0 -1
- package/src/contracts/lensWorkflow.ts +0 -1
- package/src/contracts/mcp-tools.contract.ts +0 -3636
- package/src/contracts/mcpTools.ts +0 -1
- package/src/contracts/prompt.contract.ts +0 -50
- package/src/contracts/prompt.ts +0 -1
- package/src/contracts/sdk-tools.contract.ts +0 -1457
- package/src/contracts/sdkTools.ts +0 -1
- package/src/contracts/workflow-runtime.contract.ts +0 -440
- package/src/contracts/workflowRuntime.ts +0 -1
- package/src/coreClient.ts +0 -570
- package/src/customTools.ts +0 -398
- package/src/decisionsClient.ts +0 -286
- package/src/domainContext.ts +0 -15
- package/src/events.ts +0 -531
- package/src/eventsCore.ts +0 -168
- package/src/facade/beliefs.ts +0 -83
- package/src/facade/context.ts +0 -110
- package/src/facade/contradictions.ts +0 -29
- package/src/facade/edges.ts +0 -30
- package/src/facade/events.ts +0 -23
- package/src/facade/evidence.ts +0 -41
- package/src/facade/graph.ts +0 -38
- package/src/facade/identity.ts +0 -16
- package/src/facade/ontologies.ts +0 -34
- package/src/facade/questions.ts +0 -59
- package/src/facade/search.ts +0 -16
- package/src/facade/tasks.ts +0 -37
- package/src/facade/topics.ts +0 -42
- package/src/facade/webhooks.ts +0 -58
- package/src/facade/worktrees.ts +0 -51
- package/src/gatewayFacades.ts +0 -1666
- package/src/graphClient.ts +0 -529
- package/src/harnessClient.ts +0 -585
- package/src/identityClient.ts +0 -278
- package/src/index.ts +0 -49
- package/src/learningClient.ts +0 -95
- package/src/mcpParityClient.ts +0 -240
- package/src/ontologyClient.ts +0 -275
- package/src/packRuntime.ts +0 -3
- package/src/packsClient.ts +0 -260
- package/src/policyClient.ts +0 -572
- package/src/promptCatalog.ts +0 -1
- package/src/realtime/index.ts +0 -51
- package/src/reportsClient.ts +0 -99
- package/src/schemaClient.ts +0 -129
- package/src/sdkSurface.ts +0 -190
- package/src/topicsClient.ts +0 -243
- package/src/types.ts +0 -807
- package/src/version.ts +0 -2
- package/src/workflowClient.ts +0 -826
- package/tsconfig.json +0 -9
package/src/reportsClient.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createGatewayRequestClient,
|
|
3
|
-
type GatewayClientConfig,
|
|
4
|
-
toQueryString,
|
|
5
|
-
} from "./coreClient";
|
|
6
|
-
import { createListResult, mapGatewayData, resolveTopicId } from "./sdkSurface";
|
|
7
|
-
import type {
|
|
8
|
-
TopicIdentifierInput,
|
|
9
|
-
ProjectReportsResponse,
|
|
10
|
-
ReportTemplatesResponse,
|
|
11
|
-
ReportWithSectionsResponse,
|
|
12
|
-
} from "./types";
|
|
13
|
-
|
|
14
|
-
/** Configuration for the reports client. */
|
|
15
|
-
export type ReportsClientConfig = GatewayClientConfig;
|
|
16
|
-
export type {
|
|
17
|
-
ProjectReportsResponse,
|
|
18
|
-
ReportTemplatesResponse,
|
|
19
|
-
ReportWithSectionsResponse,
|
|
20
|
-
} from "./types";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Create the reports client for report templates and generated reports.
|
|
24
|
-
* @param config - Gateway transport configuration.
|
|
25
|
-
* @returns An object with methods to list templates, list reports, and get a report.
|
|
26
|
-
*/
|
|
27
|
-
export function createReportsClient(config: ReportsClientConfig = {}) {
|
|
28
|
-
const gateway = createGatewayRequestClient(config);
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
/**
|
|
32
|
-
* List report templates.
|
|
33
|
-
*/
|
|
34
|
-
async listTemplates(args: { slug?: string } = {}) {
|
|
35
|
-
return gateway.request<ReportTemplatesResponse>({
|
|
36
|
-
path: `/api/platform/v1/reports/templates${toQueryString({
|
|
37
|
-
slug: args.slug,
|
|
38
|
-
})}`,
|
|
39
|
-
}).then((response) =>
|
|
40
|
-
mapGatewayData(response, (data) => {
|
|
41
|
-
const record =
|
|
42
|
-
data && typeof data === "object"
|
|
43
|
-
? (data as Record<string, unknown>)
|
|
44
|
-
: {};
|
|
45
|
-
const rows = Array.isArray(data)
|
|
46
|
-
? data
|
|
47
|
-
: Array.isArray(record.templates)
|
|
48
|
-
? record.templates
|
|
49
|
-
: [];
|
|
50
|
-
return createListResult(rows, "templates") as ReportTemplatesResponse;
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @deprecated Use listTemplates.
|
|
57
|
-
*/
|
|
58
|
-
async getTemplates(args: { slug?: string } = {}) {
|
|
59
|
-
return this.listTemplates(args);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* List reports for a topic scope.
|
|
64
|
-
*/
|
|
65
|
-
async listReports(
|
|
66
|
-
input: TopicIdentifierInput,
|
|
67
|
-
args: { summary?: boolean } = {}
|
|
68
|
-
) {
|
|
69
|
-
const topicId = resolveTopicId(input);
|
|
70
|
-
if (!topicId) {
|
|
71
|
-
throw new Error("topicId is required");
|
|
72
|
-
}
|
|
73
|
-
return gateway.request<ProjectReportsResponse>({
|
|
74
|
-
path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString(
|
|
75
|
-
{
|
|
76
|
-
summary:
|
|
77
|
-
typeof args.summary === "boolean"
|
|
78
|
-
? args.summary
|
|
79
|
-
? "true"
|
|
80
|
-
: "false"
|
|
81
|
-
: undefined,
|
|
82
|
-
}
|
|
83
|
-
)}`,
|
|
84
|
-
}).then((response) =>
|
|
85
|
-
mapGatewayData(response, (data) =>
|
|
86
|
-
createListResult(Array.isArray(data) ? data : [], "reports")
|
|
87
|
-
)
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
/**
|
|
91
|
-
* Get a generated report.
|
|
92
|
-
*/
|
|
93
|
-
async getReport(reportId: string) {
|
|
94
|
-
return gateway.request<ReportWithSectionsResponse>({
|
|
95
|
-
path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`,
|
|
96
|
-
});
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
}
|
package/src/schemaClient.ts
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createGatewayRequestClient,
|
|
3
|
-
type GatewayClientConfig,
|
|
4
|
-
type GatewayScope,
|
|
5
|
-
LucernApiError,
|
|
6
|
-
randomIdempotencyKey,
|
|
7
|
-
toQueryString,
|
|
8
|
-
} from "./coreClient";
|
|
9
|
-
import { createListResult, mapGatewayData } from "./sdkSurface";
|
|
10
|
-
import type { JsonObject } from "./types";
|
|
11
|
-
|
|
12
|
-
export { LucernApiError };
|
|
13
|
-
export type { GatewayScope, PlatformGatewaySuccess } from "./coreClient";
|
|
14
|
-
|
|
15
|
-
/** Configuration for the schema client. */
|
|
16
|
-
export type SchemaClientConfig = GatewayClientConfig;
|
|
17
|
-
|
|
18
|
-
/** Input for installing a schema pack into a tenant scope. */
|
|
19
|
-
export type SchemaPackInstallInput = GatewayScope & {
|
|
20
|
-
packKey: string;
|
|
21
|
-
version?: string;
|
|
22
|
-
autoEnable?: boolean;
|
|
23
|
-
metadata?: JsonObject;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
/** Input for creating or updating a schema entitlement record. */
|
|
27
|
-
export type SchemaEntitlementInput = GatewayScope & {
|
|
28
|
-
packKey: string;
|
|
29
|
-
status: "active" | "disabled" | "revoked";
|
|
30
|
-
allowedLifecycles?: Array<"active" | "beta" | "experimental">;
|
|
31
|
-
minVersion?: string;
|
|
32
|
-
maxVersion?: string;
|
|
33
|
-
metadata?: JsonObject;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Create the schema client for pack catalog and entitlement operations.
|
|
38
|
-
* @param config - Gateway transport configuration.
|
|
39
|
-
* @returns An object with methods to manage schema packs and entitlements.
|
|
40
|
-
*/
|
|
41
|
-
export function createSchemaClient(config: SchemaClientConfig = {}) {
|
|
42
|
-
const gateway = createGatewayRequestClient(config);
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
/**
|
|
46
|
-
* List schema packs.
|
|
47
|
-
*/
|
|
48
|
-
async listPacks(scope: GatewayScope = {}) {
|
|
49
|
-
return gateway.request<unknown>({
|
|
50
|
-
path: `/api/platform/v1/schema/packs${toQueryString(scope)}`,
|
|
51
|
-
}).then((response) =>
|
|
52
|
-
mapGatewayData(response, (data) =>
|
|
53
|
-
createListResult(Array.isArray(data) ? data : [], "packs")
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Install a schema pack.
|
|
60
|
-
*/
|
|
61
|
-
async installPack(input: SchemaPackInstallInput, idempotencyKey?: string) {
|
|
62
|
-
return gateway.request<unknown>({
|
|
63
|
-
path: "/api/platform/v1/schema/packs",
|
|
64
|
-
method: "POST",
|
|
65
|
-
body: input,
|
|
66
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Get a schema pack by identifier.
|
|
72
|
-
*/
|
|
73
|
-
async getPack(packId: string, scope: GatewayScope = {}) {
|
|
74
|
-
return gateway.request<unknown>({
|
|
75
|
-
path: `/api/platform/v1/schema/packs/${encodeURIComponent(packId)}${toQueryString(
|
|
76
|
-
scope
|
|
77
|
-
)}`,
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* List schema entitlements.
|
|
83
|
-
*/
|
|
84
|
-
async listEntitlements(scope: GatewayScope & { packKey?: string } = {}) {
|
|
85
|
-
return gateway.request<unknown>({
|
|
86
|
-
path: `/api/platform/v1/schema/entitlements${toQueryString(scope)}`,
|
|
87
|
-
}).then((response) =>
|
|
88
|
-
mapGatewayData(response, (data) =>
|
|
89
|
-
createListResult(Array.isArray(data) ? data : [], "entitlements")
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Create a schema entitlement.
|
|
96
|
-
*/
|
|
97
|
-
async createEntitlement(
|
|
98
|
-
input: SchemaEntitlementInput,
|
|
99
|
-
idempotencyKey?: string
|
|
100
|
-
) {
|
|
101
|
-
return gateway.request<unknown>({
|
|
102
|
-
path: "/api/platform/v1/schema/entitlements",
|
|
103
|
-
method: "POST",
|
|
104
|
-
body: input,
|
|
105
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Update a schema entitlement.
|
|
111
|
-
*/
|
|
112
|
-
async updateEntitlement(
|
|
113
|
-
input: SchemaEntitlementInput,
|
|
114
|
-
idempotencyKey?: string
|
|
115
|
-
) {
|
|
116
|
-
return this.createEntitlement(input, idempotencyKey);
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @deprecated Use createEntitlement or updateEntitlement.
|
|
121
|
-
*/
|
|
122
|
-
async upsertEntitlement(
|
|
123
|
-
input: SchemaEntitlementInput,
|
|
124
|
-
idempotencyKey?: string
|
|
125
|
-
) {
|
|
126
|
-
return this.createEntitlement(input, idempotencyKey);
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
}
|
package/src/sdkSurface.ts
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import type { PlatformGatewaySuccess } from "./coreClient";
|
|
2
|
-
import type { JsonObject, ListResult } from "./types";
|
|
3
|
-
|
|
4
|
-
type TopicScopedValue = {
|
|
5
|
-
topicId?: string;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
type TextScopedValue = {
|
|
9
|
-
text?: string;
|
|
10
|
-
canonicalText?: string;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
type AnyRecord = Record<string, unknown>;
|
|
14
|
-
|
|
15
|
-
function asRecord(value: unknown): AnyRecord {
|
|
16
|
-
return value && typeof value === "object" ? (value as AnyRecord) : {};
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function cleanString(value: unknown): string | undefined {
|
|
20
|
-
return typeof value === "string" && value.trim().length > 0
|
|
21
|
-
? value.trim()
|
|
22
|
-
: undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function normalizeVerificationStatus(value: unknown): string | undefined {
|
|
26
|
-
const status = cleanString(value);
|
|
27
|
-
if (!status) {
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
if (status === "verified") {
|
|
31
|
-
return "human_verified";
|
|
32
|
-
}
|
|
33
|
-
if (status === "rejected") {
|
|
34
|
-
return "contradicted";
|
|
35
|
-
}
|
|
36
|
-
return status;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function cloneWith<T extends AnyRecord>(value: T, patch: AnyRecord): T {
|
|
40
|
-
return { ...value, ...patch } as T;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Resolve the canonical topic identifier.
|
|
45
|
-
*/
|
|
46
|
-
export function resolveTopicId(value: TopicScopedValue): string | undefined {
|
|
47
|
-
return cleanString(value.topicId);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Resolve the canonical text field from text-first or legacy canonicalText-first inputs.
|
|
52
|
-
*/
|
|
53
|
-
export function resolveText(value: TextScopedValue): string | undefined {
|
|
54
|
-
return cleanString(value.text) ?? cleanString(value.canonicalText);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Attach the topicId to a record.
|
|
59
|
-
*/
|
|
60
|
-
export function withTopicAlias<T extends AnyRecord>(value: T): T {
|
|
61
|
-
const topicId = cleanString(value.topicId) ?? undefined;
|
|
62
|
-
if (!topicId) {
|
|
63
|
-
return value;
|
|
64
|
-
}
|
|
65
|
-
return cloneWith(value, { topicId });
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Attach the text/canonicalText alias pair to a record.
|
|
70
|
-
*/
|
|
71
|
-
export function withTextAlias<T extends AnyRecord>(value: T): T {
|
|
72
|
-
const text =
|
|
73
|
-
cleanString(value.text) ?? cleanString(value.canonicalText) ?? undefined;
|
|
74
|
-
if (!text) {
|
|
75
|
-
return value;
|
|
76
|
-
}
|
|
77
|
-
return cloneWith(value, { text, canonicalText: text });
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Attach topic and text aliases to SDK node-like records.
|
|
82
|
-
*/
|
|
83
|
-
export function withSdkAliases<T extends AnyRecord>(value: T): T {
|
|
84
|
-
return withTopicAlias(withTextAlias(value));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Normalize a belief/question/evidence write payload to the canonical gateway shape.
|
|
89
|
-
*/
|
|
90
|
-
export function normalizeNodeWriteInput<T extends JsonObject>(value: T): T {
|
|
91
|
-
const topicId = resolveTopicId(value);
|
|
92
|
-
const text = resolveText(value);
|
|
93
|
-
const verificationStatus = normalizeVerificationStatus(value.verificationStatus);
|
|
94
|
-
const next = { ...value } as JsonObject;
|
|
95
|
-
|
|
96
|
-
if (topicId) {
|
|
97
|
-
next.topicId = topicId;
|
|
98
|
-
}
|
|
99
|
-
if (text) {
|
|
100
|
-
next.text = text;
|
|
101
|
-
next.canonicalText = text;
|
|
102
|
-
}
|
|
103
|
-
if (verificationStatus) {
|
|
104
|
-
next.verificationStatus = verificationStatus;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return next as T;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function normalizeNodeVerificationStatus(value: unknown) {
|
|
111
|
-
return normalizeVerificationStatus(value);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Build a topic-aware query object.
|
|
116
|
-
*/
|
|
117
|
-
export function normalizeTopicQuery<T extends JsonObject>(value: T): T {
|
|
118
|
-
const topicId = cleanString(value.topicId);
|
|
119
|
-
if (!topicId) {
|
|
120
|
-
return value;
|
|
121
|
-
}
|
|
122
|
-
return { ...value, topicId } as T;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Extract list items from array or list-envelope payloads.
|
|
127
|
-
*/
|
|
128
|
-
export function asListItems<T>(data: unknown, legacyKey?: string): T[] {
|
|
129
|
-
if (Array.isArray(data)) {
|
|
130
|
-
return data as T[];
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const record = asRecord(data);
|
|
134
|
-
if (Array.isArray(record.items)) {
|
|
135
|
-
return record.items as T[];
|
|
136
|
-
}
|
|
137
|
-
if (legacyKey && Array.isArray(record[legacyKey])) {
|
|
138
|
-
return record[legacyKey] as T[];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return [];
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Standardize list data to { items, total } while retaining an optional legacy array key.
|
|
146
|
-
*/
|
|
147
|
-
export function createListResult<T, LegacyKey extends string>(
|
|
148
|
-
items: T[],
|
|
149
|
-
legacyKey?: LegacyKey
|
|
150
|
-
): ListResult<T, LegacyKey> {
|
|
151
|
-
const result = {
|
|
152
|
-
items,
|
|
153
|
-
total: items.length,
|
|
154
|
-
} as ListResult<T, LegacyKey>;
|
|
155
|
-
|
|
156
|
-
if (legacyKey) {
|
|
157
|
-
(result as Record<string, unknown>)[legacyKey] = items;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return result;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Map a gateway success envelope's data while preserving the transport metadata.
|
|
165
|
-
*/
|
|
166
|
-
export function mapGatewayData<T, U>(
|
|
167
|
-
response: PlatformGatewaySuccess<T>,
|
|
168
|
-
mapper: (data: T) => U
|
|
169
|
-
): PlatformGatewaySuccess<U> {
|
|
170
|
-
return {
|
|
171
|
-
...response,
|
|
172
|
-
data: mapper(response.data),
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Apply SDK aliases across all items in a list-like payload.
|
|
178
|
-
*/
|
|
179
|
-
export function mapAliasedList<
|
|
180
|
-
TItem extends AnyRecord,
|
|
181
|
-
LegacyKey extends string,
|
|
182
|
-
>(
|
|
183
|
-
data: unknown,
|
|
184
|
-
legacyKey?: LegacyKey
|
|
185
|
-
): ListResult<TItem, LegacyKey> {
|
|
186
|
-
const items = asListItems<TItem>(data, legacyKey).map((item) =>
|
|
187
|
-
withSdkAliases(item)
|
|
188
|
-
);
|
|
189
|
-
return createListResult(items, legacyKey);
|
|
190
|
-
}
|
package/src/topicsClient.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createGatewayRequestClient,
|
|
3
|
-
type GatewayClientConfig,
|
|
4
|
-
randomIdempotencyKey,
|
|
5
|
-
toQueryString,
|
|
6
|
-
} from "./coreClient";
|
|
7
|
-
import {
|
|
8
|
-
createListResult,
|
|
9
|
-
mapGatewayData,
|
|
10
|
-
resolveTopicId,
|
|
11
|
-
withTopicAlias,
|
|
12
|
-
} from "./sdkSurface";
|
|
13
|
-
import type {
|
|
14
|
-
JsonObject,
|
|
15
|
-
TopicCoverageResponse,
|
|
16
|
-
TopicIdentifierInput,
|
|
17
|
-
TopicListResponse,
|
|
18
|
-
TopicRecord,
|
|
19
|
-
TopicTreeNode,
|
|
20
|
-
TopicTreeResponse,
|
|
21
|
-
} from "./types";
|
|
22
|
-
|
|
23
|
-
/** Configuration for the topics client. Inherits gateway transport settings. */
|
|
24
|
-
export type TopicsClientConfig = GatewayClientConfig;
|
|
25
|
-
|
|
26
|
-
/** Filters for listing topics within a scope. */
|
|
27
|
-
export type TopicListInput = TopicIdentifierInput & {
|
|
28
|
-
ontologyId?: string;
|
|
29
|
-
parentTopicId?: string;
|
|
30
|
-
status?: string;
|
|
31
|
-
type?: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** Input for creating a new topic. Name is required; all other fields are optional. */
|
|
35
|
-
export type TopicCreateInput = TopicIdentifierInput & {
|
|
36
|
-
name: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
type?: string;
|
|
39
|
-
parentTopicId?: string;
|
|
40
|
-
ontologyId?: string;
|
|
41
|
-
tenantId?: string;
|
|
42
|
-
workspaceId?: string;
|
|
43
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
44
|
-
createdBy?: string;
|
|
45
|
-
metadata?: JsonObject;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Input for updating an existing topic's metadata. All fields are optional. */
|
|
49
|
-
export type TopicUpdateInput = TopicIdentifierInput & {
|
|
50
|
-
name?: string;
|
|
51
|
-
description?: string;
|
|
52
|
-
type?: string;
|
|
53
|
-
ontologyId?: string;
|
|
54
|
-
clearOntologyId?: boolean;
|
|
55
|
-
status?: "active" | "archived" | "watching";
|
|
56
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/** Options for retrieving the topic hierarchy. */
|
|
60
|
-
export type TopicTreeQuery = {
|
|
61
|
-
maxDepth?: number;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/** Options for retrieving belief/question/evidence coverage across a topic tree. */
|
|
65
|
-
export type TopicCoverageQuery = {
|
|
66
|
-
includeDescendants?: boolean;
|
|
67
|
-
maxDepth?: number;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/** Input for batch-creating topics. */
|
|
71
|
-
export type TopicBulkCreateInput = {
|
|
72
|
-
topics: Array<
|
|
73
|
-
TopicIdentifierInput & {
|
|
74
|
-
globalId?: string;
|
|
75
|
-
name: string;
|
|
76
|
-
description?: string;
|
|
77
|
-
type: string;
|
|
78
|
-
parentTopicId?: string;
|
|
79
|
-
depth?: number;
|
|
80
|
-
path?: string[];
|
|
81
|
-
tenantId?: string;
|
|
82
|
-
workspaceId?: string;
|
|
83
|
-
graphScopeProjectId?: string;
|
|
84
|
-
status?: "active" | "archived" | "watching";
|
|
85
|
-
visibility?: "private" | "team" | "firm" | "external" | "public";
|
|
86
|
-
metadata?: JsonObject;
|
|
87
|
-
createdBy?: string;
|
|
88
|
-
}
|
|
89
|
-
>;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
function asRecord(value: unknown): Record<string, unknown> {
|
|
93
|
-
return value && typeof value === "object"
|
|
94
|
-
? (value as Record<string, unknown>)
|
|
95
|
-
: {};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function cleanString(value: unknown): string | undefined {
|
|
99
|
-
return typeof value === "string" && value.trim().length > 0
|
|
100
|
-
? value.trim()
|
|
101
|
-
: undefined;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function normalizeTopicRecord(value: unknown): TopicRecord {
|
|
105
|
-
const record = asRecord(value);
|
|
106
|
-
const topicId =
|
|
107
|
-
cleanString(record.topicId) ??
|
|
108
|
-
cleanString(record.id) ??
|
|
109
|
-
cleanString(record._id);
|
|
110
|
-
|
|
111
|
-
return withTopicAlias({
|
|
112
|
-
...record,
|
|
113
|
-
...(topicId ? { topicId } : {}),
|
|
114
|
-
}) as TopicRecord;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function normalizeTopicTreeNode(value: unknown): TopicTreeNode {
|
|
118
|
-
return normalizeTopicRecord(value) as TopicTreeNode;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Create the topics client for managing hierarchical knowledge containers.
|
|
123
|
-
*
|
|
124
|
-
* @param config - Gateway transport configuration.
|
|
125
|
-
* @returns An object with `list`, `get`, `create`, `update`, `getTree`, and `getCoverage` methods.
|
|
126
|
-
*/
|
|
127
|
-
export function createTopicsClient(config: TopicsClientConfig = {}) {
|
|
128
|
-
const gateway = createGatewayRequestClient(config);
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
async list(query: TopicListInput = {}) {
|
|
132
|
-
const topicId = resolveTopicId(query);
|
|
133
|
-
return gateway.request<TopicListResponse>({
|
|
134
|
-
path: `/api/platform/v1/topics${toQueryString({
|
|
135
|
-
...(topicId ? { topicId } : {}),
|
|
136
|
-
ontologyId: query.ontologyId,
|
|
137
|
-
parentTopicId: query.parentTopicId,
|
|
138
|
-
status: query.status,
|
|
139
|
-
type: query.type,
|
|
140
|
-
})}`,
|
|
141
|
-
}).then((response) =>
|
|
142
|
-
mapGatewayData(response, (data) => {
|
|
143
|
-
const record = asRecord(data);
|
|
144
|
-
const items = Array.isArray(record.topics)
|
|
145
|
-
? record.topics.map(normalizeTopicRecord)
|
|
146
|
-
: [];
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
...createListResult(items, "topics"),
|
|
150
|
-
...record,
|
|
151
|
-
topics: items,
|
|
152
|
-
total:
|
|
153
|
-
typeof record.total === "number" ? record.total : items.length,
|
|
154
|
-
} as TopicListResponse;
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
async get(topicId: string) {
|
|
160
|
-
return gateway.request<TopicRecord>({
|
|
161
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}`,
|
|
162
|
-
}).then((response) =>
|
|
163
|
-
mapGatewayData(response, (data) =>
|
|
164
|
-
normalizeTopicRecord(asRecord(data).topic ?? data)
|
|
165
|
-
)
|
|
166
|
-
);
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
async create(input: TopicCreateInput, idempotencyKey?: string) {
|
|
170
|
-
const topicId = resolveTopicId(input);
|
|
171
|
-
return gateway.request<TopicRecord>({
|
|
172
|
-
path: "/api/platform/v1/topics",
|
|
173
|
-
method: "POST",
|
|
174
|
-
body: {
|
|
175
|
-
...input,
|
|
176
|
-
...(topicId ? { topicId } : {}),
|
|
177
|
-
type: input.type ?? "theme",
|
|
178
|
-
} as JsonObject,
|
|
179
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
180
|
-
}).then((response) =>
|
|
181
|
-
mapGatewayData(response, (data) => normalizeTopicRecord(data))
|
|
182
|
-
);
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
async update(
|
|
186
|
-
topicId: string,
|
|
187
|
-
input: TopicUpdateInput,
|
|
188
|
-
idempotencyKey?: string
|
|
189
|
-
) {
|
|
190
|
-
return gateway.request<TopicRecord>({
|
|
191
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}`,
|
|
192
|
-
method: "PATCH",
|
|
193
|
-
body: input as JsonObject,
|
|
194
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
195
|
-
}).then((response) =>
|
|
196
|
-
mapGatewayData(response, (data) => normalizeTopicRecord(data))
|
|
197
|
-
);
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
async getTree(topicId: string, query: TopicTreeQuery = {}) {
|
|
201
|
-
return gateway.request<TopicTreeResponse>({
|
|
202
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/tree${toQueryString(
|
|
203
|
-
query
|
|
204
|
-
)}`,
|
|
205
|
-
}).then((response) =>
|
|
206
|
-
mapGatewayData(response, (data) => {
|
|
207
|
-
const record = asRecord(data);
|
|
208
|
-
return {
|
|
209
|
-
tree: Array.isArray(record.tree)
|
|
210
|
-
? record.tree.map(normalizeTopicTreeNode)
|
|
211
|
-
: [],
|
|
212
|
-
} as TopicTreeResponse;
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
async getCoverage(topicId: string, query: TopicCoverageQuery = {}) {
|
|
218
|
-
return gateway.request<TopicCoverageResponse>({
|
|
219
|
-
path: `/api/platform/v1/topics/${encodeURIComponent(topicId)}/coverage${toQueryString(
|
|
220
|
-
query
|
|
221
|
-
)}`,
|
|
222
|
-
});
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
async remove(topicId: string, idempotencyKey?: string) {
|
|
226
|
-
return gateway.request<Record<string, unknown>>({
|
|
227
|
-
path: "/api/platform/v1/topics/remove",
|
|
228
|
-
method: "POST",
|
|
229
|
-
body: { id: topicId },
|
|
230
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
231
|
-
});
|
|
232
|
-
},
|
|
233
|
-
|
|
234
|
-
async bulkCreate(input: TopicBulkCreateInput, idempotencyKey?: string) {
|
|
235
|
-
return gateway.request<Record<string, unknown>>({
|
|
236
|
-
path: "/api/platform/v1/topics/bulk",
|
|
237
|
-
method: "POST",
|
|
238
|
-
body: input,
|
|
239
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
240
|
-
});
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
}
|