@lucern/sdk 0.2.0-alpha.6 → 0.2.0-alpha.8
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/dist/{lib/platform/sdk/adminClient.d.ts → adminClient.d.ts} +56 -51
- 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/{lib/platform/sdk/audiencesClient.d.ts → audiencesClient.d.ts} +24 -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/{lib/platform/sdk/beliefsClient.d.ts → beliefsClient.d.ts} +32 -27
- package/dist/beliefsClient.js +477 -0
- package/dist/beliefsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/client.d.ts → client.d.ts} +404 -395
- package/dist/client.js +6134 -0
- package/dist/client.js.map +1 -0
- package/dist/{lib/platform/sdk/contextClient.d.ts → contextClient.d.ts} +13 -7
- 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/{lib/platform/sdk/contextPackCompiler.d.ts → contextPackCompiler.d.ts} +11 -9
- 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/{lib/platform/sdk/contextTypes.d.ts → contextTypes.d.ts} +15 -13
- 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/{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 +4892 -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 +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/{lucern/contracts/src → contracts}/prompt.contract.d.ts +5 -3
- 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/{lib/platform/sdk/controlObjectOwnership.d.ts → controlObjectOwnership.d.ts} +20 -18
- package/dist/controlObjectOwnership.js +215 -0
- package/dist/controlObjectOwnership.js.map +1 -0
- package/dist/{lib/platform/sdk/coreClient.d.ts → coreClient.d.ts} +19 -14
- package/dist/coreClient.js +339 -0
- package/dist/coreClient.js.map +1 -0
- package/dist/{lib/platform/sdk/customTools.d.ts → customTools.d.ts} +21 -16
- package/dist/customTools.js +248 -0
- package/dist/customTools.js.map +1 -0
- package/dist/{lib/platform/sdk/decisionsClient.d.ts → decisionsClient.d.ts} +29 -24
- 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/{lib/platform/sdk/gatewayFacades.d.ts → gatewayFacades.d.ts} +31 -26
- package/dist/gatewayFacades.js +1953 -0
- package/dist/gatewayFacades.js.map +1 -0
- package/dist/{lib/platform/sdk/graphClient.d.ts → graphClient.d.ts} +57 -52
- package/dist/graphClient.js +698 -0
- package/dist/graphClient.js.map +1 -0
- package/dist/{lib/platform/sdk/harnessClient.d.ts → harnessClient.d.ts} +44 -39
- package/dist/harnessClient.js +607 -0
- package/dist/harnessClient.js.map +1 -0
- package/dist/{lib/platform/sdk/identityClient.d.ts → identityClient.d.ts} +17 -11
- package/dist/identityClient.js +497 -0
- package/dist/identityClient.js.map +1 -0
- package/dist/index.d.ts +42 -3
- package/dist/index.js +11381 -3
- package/dist/index.js.map +1 -0
- package/dist/{lib/platform/sdk/learningClient.d.ts → learningClient.d.ts} +13 -7
- package/dist/learningClient.js +409 -0
- package/dist/learningClient.js.map +1 -0
- package/dist/{lib/platform/sdk/mcpParityClient.d.ts → mcpParityClient.d.ts} +10 -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/{lib/platform/sdk/ontologyClient.d.ts → ontologyClient.d.ts} +28 -22
- 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/{lib/platform/sdk/packsClient.d.ts → packsClient.d.ts} +34 -29
- package/dist/packsClient.js +525 -0
- package/dist/packsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/policyClient.d.ts → policyClient.d.ts} +26 -20
- 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/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/{lib/platform/sdk/schemaClient.d.ts → schemaClient.d.ts} +20 -15
- 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/{lib/platform/sdk/topicsClient.d.ts → topicsClient.d.ts} +24 -18
- package/dist/topicsClient.js +492 -0
- package/dist/topicsClient.js.map +1 -0
- package/dist/{lib/platform/sdk/types.d.ts → types.d.ts} +84 -80
- 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/{lib/platform/sdk/workflowClient.d.ts → workflowClient.d.ts} +60 -57
- package/dist/workflowClient.js +830 -0
- package/dist/workflowClient.js.map +1 -0
- package/package.json +25 -43
- package/dist/.generated +0 -2
- 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.js +0 -384
- package/dist/lib/platform/sdk/answersClient.d.ts +0 -16
- package/dist/lib/platform/sdk/answersClient.js +0 -21
- 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.js +0 -124
- package/dist/lib/platform/sdk/client.js +0 -1831
- package/dist/lib/platform/sdk/contextClient.js +0 -86
- package/dist/lib/platform/sdk/contextFacade.d.ts +0 -10
- package/dist/lib/platform/sdk/contextFacade.js +0 -10
- package/dist/lib/platform/sdk/contextPackCompiler.js +0 -534
- package/dist/lib/platform/sdk/contextTypes.js +0 -1
- package/dist/lib/platform/sdk/controlObjectOwnership.js +0 -220
- package/dist/lib/platform/sdk/coreClient.js +0 -366
- package/dist/lib/platform/sdk/customTools.js +0 -247
- 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/eventsCore.d.ts +0 -13
- package/dist/lib/platform/sdk/eventsCore.js +0 -13
- package/dist/lib/platform/sdk/gatewayFacades.js +0 -845
- package/dist/lib/platform/sdk/graphClient.js +0 -235
- package/dist/lib/platform/sdk/harnessClient.js +0 -219
- package/dist/lib/platform/sdk/identityClient.js +0 -131
- package/dist/lib/platform/sdk/index.d.ts +0 -49
- package/dist/lib/platform/sdk/index.js +0 -49
- package/dist/lib/platform/sdk/learningClient.js +0 -53
- 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.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.js +0 -157
- 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.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.js +0 -118
- package/dist/lib/platform/sdk/types.js +0 -1
- package/dist/lib/platform/sdk/version.d.ts +0 -2
- package/dist/lib/platform/sdk/version.js +0 -2
- 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/auth-context.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-context.contract.js +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/auth-session.contract.js +0 -8
- package/dist/lucern/contracts/src/auth.contract.d.ts +0 -88
- package/dist/lucern/contracts/src/auth.contract.js +0 -57
- package/dist/lucern/contracts/src/context-pack.contract.js +0 -169
- package/dist/lucern/contracts/src/convex-admin.contract.d.ts +0 -5
- package/dist/lucern/contracts/src/convex-admin.contract.js +0 -1
- package/dist/lucern/contracts/src/events-types.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/events-types.contract.js +0 -8
- package/dist/lucern/contracts/src/events.contract.d.ts +0 -176
- package/dist/lucern/contracts/src/events.contract.js +0 -159
- package/dist/lucern/contracts/src/gateway.contract.d.ts +0 -74
- package/dist/lucern/contracts/src/gateway.contract.js +0 -19
- package/dist/lucern/contracts/src/ids.contract.d.ts +0 -7
- package/dist/lucern/contracts/src/ids.contract.js +0 -24
- package/dist/lucern/contracts/src/index.d.ts +0 -29
- package/dist/lucern/contracts/src/index.js +0 -29
- 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/lucern/contracts/src/ontology-matching.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/ontology-matching.contract.js +0 -8
- package/dist/lucern/contracts/src/prompt.contract.js +0 -24
- package/dist/lucern/contracts/src/sdk-methods.contract.d.ts +0 -358
- package/dist/lucern/contracts/src/sdk-methods.contract.js +0 -19
- package/dist/lucern/contracts/src/sdk-tools.contract.d.ts +0 -92
- package/dist/lucern/contracts/src/sdk-tools.contract.js +0 -1398
- package/dist/lucern/contracts/src/text-matching.contract.d.ts +0 -53
- package/dist/lucern/contracts/src/text-matching.contract.js +0 -277
- package/dist/lucern/contracts/src/topic-scope.contract.d.ts +0 -8
- package/dist/lucern/contracts/src/topic-scope.contract.js +0 -8
- package/dist/lucern/contracts/src/workflow-runtime.contract.d.ts +0 -161
- package/dist/lucern/contracts/src/workflow-runtime.contract.js +0 -257
- package/dist/realtime-refs.d.ts +0 -1
- package/dist/realtime-refs.js +0 -1
- package/dist/realtime.d.ts +0 -1
- package/dist/realtime.js +0 -1
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { createGatewayRequestClient, LucernApiError, randomIdempotencyKey, toQueryString, } from "./coreClient.js";
|
|
2
|
-
import { createListResult, mapGatewayData } from "./sdkSurface.js";
|
|
3
|
-
export { LucernApiError };
|
|
4
|
-
function asTopicArray(data) {
|
|
5
|
-
if (Array.isArray(data)) {
|
|
6
|
-
return data.filter((row) => Boolean(row) && typeof row === "object");
|
|
7
|
-
}
|
|
8
|
-
return [];
|
|
9
|
-
}
|
|
10
|
-
function asWritePolicyRecord(data) {
|
|
11
|
-
if (!data || typeof data !== "object") {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
return data;
|
|
15
|
-
}
|
|
16
|
-
function asWritePolicyArray(data) {
|
|
17
|
-
if (!Array.isArray(data)) {
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
return data
|
|
21
|
-
.map(asWritePolicyRecord)
|
|
22
|
-
.filter((row) => Boolean(row));
|
|
23
|
-
}
|
|
24
|
-
function asRolePolicyRecord(data) {
|
|
25
|
-
if (!data || typeof data !== "object") {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
function asRolePolicyArray(data) {
|
|
31
|
-
if (!Array.isArray(data)) {
|
|
32
|
-
return [];
|
|
33
|
-
}
|
|
34
|
-
return data
|
|
35
|
-
.map(asRolePolicyRecord)
|
|
36
|
-
.filter((row) => Boolean(row));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create the policy client for permission checks, grants, and write policies.
|
|
40
|
-
* @param config - Gateway transport configuration.
|
|
41
|
-
* @returns An object with methods to check permissions, manage grants, and manage write policies.
|
|
42
|
-
*/
|
|
43
|
-
export function createPolicyClient(config = {}) {
|
|
44
|
-
const gateway = createGatewayRequestClient(config);
|
|
45
|
-
return {
|
|
46
|
-
/**
|
|
47
|
-
* List policy decisions in the current scope.
|
|
48
|
-
*/
|
|
49
|
-
async listDecisions(query = {}) {
|
|
50
|
-
return gateway.request({
|
|
51
|
-
path: `/api/platform/v1/policy/decisions${toQueryString(query)}`,
|
|
52
|
-
}).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "decisions")));
|
|
53
|
-
},
|
|
54
|
-
/**
|
|
55
|
-
* Create a permission grant.
|
|
56
|
-
*/
|
|
57
|
-
async grant(input, idempotencyKey) {
|
|
58
|
-
return gateway.request({
|
|
59
|
-
path: "/api/platform/v1/policy/grant",
|
|
60
|
-
method: "POST",
|
|
61
|
-
body: input,
|
|
62
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* Delete a permission grant by revoking it.
|
|
67
|
-
*/
|
|
68
|
-
async revoke(input, idempotencyKey) {
|
|
69
|
-
return gateway.request({
|
|
70
|
-
path: "/api/platform/v1/policy/revoke",
|
|
71
|
-
method: "POST",
|
|
72
|
-
body: input,
|
|
73
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
74
|
-
});
|
|
75
|
-
},
|
|
76
|
-
/**
|
|
77
|
-
* List write policy rules for the current scope.
|
|
78
|
-
*/
|
|
79
|
-
async listWritePolicies(query = {}) {
|
|
80
|
-
const response = await gateway.request({
|
|
81
|
-
path: `/api/platform/v1/policy/write-policies${toQueryString(query)}`,
|
|
82
|
-
});
|
|
83
|
-
const rawPolicies = response.data && typeof response.data === "object"
|
|
84
|
-
? response.data.policies
|
|
85
|
-
: response.data;
|
|
86
|
-
return {
|
|
87
|
-
...response,
|
|
88
|
-
data: {
|
|
89
|
-
policies: asWritePolicyArray(rawPolicies),
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
/**
|
|
94
|
-
* Create a write policy rule.
|
|
95
|
-
*/
|
|
96
|
-
async createWritePolicy(input, idempotencyKey) {
|
|
97
|
-
const response = await gateway.request({
|
|
98
|
-
path: "/api/platform/v1/policy/write-policies",
|
|
99
|
-
method: "POST",
|
|
100
|
-
body: input,
|
|
101
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
102
|
-
});
|
|
103
|
-
return {
|
|
104
|
-
...response,
|
|
105
|
-
data: {
|
|
106
|
-
id: typeof response.data?.id === "string" ? response.data.id : undefined,
|
|
107
|
-
created: response.data?.created === true,
|
|
108
|
-
policy: asWritePolicyRecord(response.data?.policy),
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Update an existing write policy rule by identifier.
|
|
114
|
-
*/
|
|
115
|
-
async updateWritePolicy(id, input, idempotencyKey) {
|
|
116
|
-
const response = await gateway.request({
|
|
117
|
-
path: `/api/platform/v1/policy/write-policies/${encodeURIComponent(id)}`,
|
|
118
|
-
method: "PATCH",
|
|
119
|
-
body: input,
|
|
120
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
121
|
-
});
|
|
122
|
-
return {
|
|
123
|
-
...response,
|
|
124
|
-
data: {
|
|
125
|
-
id: typeof response.data?.id === "string" ? response.data.id : undefined,
|
|
126
|
-
updated: response.data?.updated === true,
|
|
127
|
-
policy: asWritePolicyRecord(response.data?.policy),
|
|
128
|
-
},
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
/**
|
|
132
|
-
* Delete a write policy rule by identifier.
|
|
133
|
-
*/
|
|
134
|
-
async deleteWritePolicy(id, scope = {}, idempotencyKey) {
|
|
135
|
-
return gateway.request({
|
|
136
|
-
path: `/api/platform/v1/policy/write-policies/${encodeURIComponent(id)}${toQueryString(scope)}`,
|
|
137
|
-
method: "DELETE",
|
|
138
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
/**
|
|
142
|
-
* List tenant role policies for the current scope.
|
|
143
|
-
*/
|
|
144
|
-
async listRolePolicies(query = {}) {
|
|
145
|
-
const response = await gateway.request({
|
|
146
|
-
path: `/api/platform/v1/policy/roles${toQueryString(query)}`,
|
|
147
|
-
});
|
|
148
|
-
return {
|
|
149
|
-
...response,
|
|
150
|
-
data: {
|
|
151
|
-
policies: asRolePolicyArray(response.data?.policies),
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
},
|
|
155
|
-
/**
|
|
156
|
-
* Create a tenant role policy.
|
|
157
|
-
*/
|
|
158
|
-
async createRolePolicy(input, idempotencyKey) {
|
|
159
|
-
const response = await gateway.request({
|
|
160
|
-
path: "/api/platform/v1/policy/roles",
|
|
161
|
-
method: "POST",
|
|
162
|
-
body: input,
|
|
163
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
164
|
-
});
|
|
165
|
-
return {
|
|
166
|
-
...response,
|
|
167
|
-
data: {
|
|
168
|
-
policy: asRolePolicyRecord(response.data?.policy),
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
/**
|
|
173
|
-
* Update a tenant role policy by identifier.
|
|
174
|
-
*/
|
|
175
|
-
async updateRolePolicy(id, input, idempotencyKey) {
|
|
176
|
-
const response = await gateway.request({
|
|
177
|
-
path: `/api/platform/v1/policy/roles/${encodeURIComponent(id)}`,
|
|
178
|
-
method: "PATCH",
|
|
179
|
-
body: input,
|
|
180
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
181
|
-
});
|
|
182
|
-
return {
|
|
183
|
-
...response,
|
|
184
|
-
data: {
|
|
185
|
-
policy: asRolePolicyRecord(response.data?.policy),
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
/**
|
|
190
|
-
* Delete a tenant role policy by identifier.
|
|
191
|
-
*/
|
|
192
|
-
async deleteRolePolicy(id, scope = {}, idempotencyKey) {
|
|
193
|
-
return gateway.request({
|
|
194
|
-
path: `/api/platform/v1/policy/roles/${encodeURIComponent(id)}${toQueryString(scope)}`,
|
|
195
|
-
method: "DELETE",
|
|
196
|
-
idempotencyKey: idempotencyKey ?? randomIdempotencyKey(),
|
|
197
|
-
});
|
|
198
|
-
},
|
|
199
|
-
/**
|
|
200
|
-
* Check a permission decision for a topic or project scope.
|
|
201
|
-
*/
|
|
202
|
-
async checkPermission(query) {
|
|
203
|
-
if (!query.topicId) {
|
|
204
|
-
throw new Error("topicId is required");
|
|
205
|
-
}
|
|
206
|
-
return gateway.request({
|
|
207
|
-
path: `/api/platform/v1/policy/check${toQueryString(query)}`,
|
|
208
|
-
});
|
|
209
|
-
},
|
|
210
|
-
/**
|
|
211
|
-
* List accessible topics for a principal.
|
|
212
|
-
*/
|
|
213
|
-
async listAccessibleTopics(query = {}) {
|
|
214
|
-
const permission = query.permission ?? "read";
|
|
215
|
-
const principal = query.principal ?? query.principalId;
|
|
216
|
-
const response = await gateway.request({
|
|
217
|
-
path: `/api/platform/v1/policy/topics${toQueryString({
|
|
218
|
-
tenantId: query.tenantId,
|
|
219
|
-
workspaceId: query.workspaceId,
|
|
220
|
-
permission,
|
|
221
|
-
includeShared: query.includeShared,
|
|
222
|
-
principal,
|
|
223
|
-
limit: query.limit,
|
|
224
|
-
})}`,
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
...response,
|
|
228
|
-
data: {
|
|
229
|
-
permission,
|
|
230
|
-
topics: asTopicArray(response.data?.topics),
|
|
231
|
-
total: typeof response.data?.total === "number"
|
|
232
|
-
? response.data.total
|
|
233
|
-
: asTopicArray(response.data?.topics).length,
|
|
234
|
-
deniedTopics: Array.isArray(response.data?.deniedTopics)
|
|
235
|
-
? response.data.deniedTopics
|
|
236
|
-
: [],
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
},
|
|
240
|
-
/**
|
|
241
|
-
* Filter topic identifiers by permission.
|
|
242
|
-
*/
|
|
243
|
-
async filterByPermission(input) {
|
|
244
|
-
const permission = input.permission ?? "read";
|
|
245
|
-
const principal = input.principal ?? input.principalId;
|
|
246
|
-
const uniqueTopicIds = [...new Set(input.topicIds ?? [])].filter((topicId) => typeof topicId === "string" && topicId.trim().length > 0);
|
|
247
|
-
const response = await gateway.request({
|
|
248
|
-
path: "/api/platform/v1/policy/filter",
|
|
249
|
-
method: "POST",
|
|
250
|
-
body: {
|
|
251
|
-
tenantId: input.tenantId,
|
|
252
|
-
workspaceId: input.workspaceId,
|
|
253
|
-
topicIds: uniqueTopicIds,
|
|
254
|
-
permission,
|
|
255
|
-
principal,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
const allowedTopicIds = Array.isArray(response.data?.allowedTopicIds)
|
|
259
|
-
? response.data.allowedTopicIds
|
|
260
|
-
: [];
|
|
261
|
-
const deniedTopics = Array.isArray(response.data?.deniedTopics)
|
|
262
|
-
? response.data.deniedTopics
|
|
263
|
-
: [];
|
|
264
|
-
return {
|
|
265
|
-
success: true,
|
|
266
|
-
data: {
|
|
267
|
-
permission,
|
|
268
|
-
allowedTopicIds,
|
|
269
|
-
deniedTopics,
|
|
270
|
-
count: typeof response.data?.count === "number"
|
|
271
|
-
? response.data.count
|
|
272
|
-
: allowedTopicIds.length,
|
|
273
|
-
},
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
};
|
|
277
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getPromptCatalogSnapshot } from "@/lib/langfuse/prompt-catalog";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getPromptCatalogSnapshot } from "@/lib/langfuse/prompt-catalog";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type GatewayClientConfig } from "./coreClient";
|
|
2
|
-
import type { TopicIdentifierInput, ReportTemplatesResponse, ReportWithSectionsResponse } from "./types";
|
|
3
|
-
/** Configuration for the reports client. */
|
|
4
|
-
export type ReportsClientConfig = GatewayClientConfig;
|
|
5
|
-
export type { ProjectReportsResponse, ReportTemplatesResponse, ReportWithSectionsResponse, } from "./types";
|
|
6
|
-
/**
|
|
7
|
-
* Create the reports client for report templates and generated reports.
|
|
8
|
-
* @param config - Gateway transport configuration.
|
|
9
|
-
* @returns An object with methods to list templates, list reports, and get a report.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createReportsClient(config?: ReportsClientConfig): {
|
|
12
|
-
/**
|
|
13
|
-
* List report templates.
|
|
14
|
-
*/
|
|
15
|
-
listTemplates(args?: {
|
|
16
|
-
slug?: string;
|
|
17
|
-
}): Promise<import("./coreClient").PlatformGatewaySuccess<ReportTemplatesResponse>>;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated Use listTemplates.
|
|
20
|
-
*/
|
|
21
|
-
getTemplates(args?: {
|
|
22
|
-
slug?: string;
|
|
23
|
-
}): Promise<import("./coreClient").PlatformGatewaySuccess<ReportTemplatesResponse>>;
|
|
24
|
-
/**
|
|
25
|
-
* List reports for a topic scope.
|
|
26
|
-
*/
|
|
27
|
-
listReports(input: TopicIdentifierInput, args?: {
|
|
28
|
-
summary?: boolean;
|
|
29
|
-
}): Promise<import("./coreClient").PlatformGatewaySuccess<import("./types").ListResult<any, "reports">>>;
|
|
30
|
-
/**
|
|
31
|
-
* Get a generated report.
|
|
32
|
-
*/
|
|
33
|
-
getReport(reportId: string): Promise<import("./coreClient").PlatformGatewaySuccess<ReportWithSectionsResponse>>;
|
|
34
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { createGatewayRequestClient, toQueryString, } from "./coreClient.js";
|
|
2
|
-
import { createListResult, mapGatewayData, resolveTopicId } from "./sdkSurface.js";
|
|
3
|
-
/**
|
|
4
|
-
* Create the reports client for report templates and generated reports.
|
|
5
|
-
* @param config - Gateway transport configuration.
|
|
6
|
-
* @returns An object with methods to list templates, list reports, and get a report.
|
|
7
|
-
*/
|
|
8
|
-
export function createReportsClient(config = {}) {
|
|
9
|
-
const gateway = createGatewayRequestClient(config);
|
|
10
|
-
return {
|
|
11
|
-
/**
|
|
12
|
-
* List report templates.
|
|
13
|
-
*/
|
|
14
|
-
async listTemplates(args = {}) {
|
|
15
|
-
return gateway.request({
|
|
16
|
-
path: `/api/platform/v1/reports/templates${toQueryString({
|
|
17
|
-
slug: args.slug,
|
|
18
|
-
})}`,
|
|
19
|
-
}).then((response) => mapGatewayData(response, (data) => {
|
|
20
|
-
const record = data && typeof data === "object"
|
|
21
|
-
? data
|
|
22
|
-
: {};
|
|
23
|
-
const rows = Array.isArray(data)
|
|
24
|
-
? data
|
|
25
|
-
: Array.isArray(record.templates)
|
|
26
|
-
? record.templates
|
|
27
|
-
: [];
|
|
28
|
-
return createListResult(rows, "templates");
|
|
29
|
-
}));
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* @deprecated Use listTemplates.
|
|
33
|
-
*/
|
|
34
|
-
async getTemplates(args = {}) {
|
|
35
|
-
return this.listTemplates(args);
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* List reports for a topic scope.
|
|
39
|
-
*/
|
|
40
|
-
async listReports(input, args = {}) {
|
|
41
|
-
const topicId = resolveTopicId(input);
|
|
42
|
-
if (!topicId) {
|
|
43
|
-
throw new Error("topicId is required");
|
|
44
|
-
}
|
|
45
|
-
return gateway.request({
|
|
46
|
-
path: `/api/platform/v1/reports/topics/${encodeURIComponent(topicId)}${toQueryString({
|
|
47
|
-
summary: typeof args.summary === "boolean"
|
|
48
|
-
? args.summary
|
|
49
|
-
? "true"
|
|
50
|
-
: "false"
|
|
51
|
-
: undefined,
|
|
52
|
-
})}`,
|
|
53
|
-
}).then((response) => mapGatewayData(response, (data) => createListResult(Array.isArray(data) ? data : [], "reports")));
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Get a generated report.
|
|
57
|
-
*/
|
|
58
|
-
async getReport(reportId) {
|
|
59
|
-
return gateway.request({
|
|
60
|
-
path: `/api/platform/v1/reports/${encodeURIComponent(reportId)}`,
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -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
|
-
}
|