@collective-intelligence/external-apps-client-sdk 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -3
- package/dist/index.d.ts +50 -2
- package/dist/index.js +29 -12
- package/dist/{resources-BP_TaCP6.js → resources--kU5LiFu.js} +367 -77
- package/dist/{resources-DxMBAy-Z.d.ts → resources-BDcYZzER.d.ts} +193 -59
- package/dist/resources.d.ts +2 -2
- package/dist/resources.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,14 @@ The root entrypoint provides federated login, typed CI operations, and direct or
|
|
|
5
5
|
same-origin proxy transports. It contains no confidential credentials or
|
|
6
6
|
framework state.
|
|
7
7
|
|
|
8
|
+
The typed transport `execute` method supports `users_create_or_get`, `users_get`,
|
|
9
|
+
`users_list`, `users_deactivate`, `roles_list`, `roles_assign`, and `roles_revoke`
|
|
10
|
+
through the dedicated Application HTTP routes. Supply `organizationId` in the
|
|
11
|
+
execution options. Role assignment inputs use `{ userId, roles }`; an empty
|
|
12
|
+
`roles` array is forwarded unchanged. The backend checks the signed-in user's
|
|
13
|
+
current permissions. Server credentials and Server Role selection belong to the
|
|
14
|
+
Server SDK.
|
|
15
|
+
|
|
8
16
|
`createFederatedAuth` implements the public OAuth authorization-code flow with
|
|
9
17
|
PKCE. It validates same-origin return targets, keeps the login transaction in
|
|
10
18
|
session storage, exchanges the callback code, tracks token expiry, and supports
|
|
@@ -134,7 +142,7 @@ authorizes access. They are configuration, never mutation-body authority.
|
|
|
134
142
|
including identity, login, logout, and `runs_follow`. `createFixedWorkflowClient`
|
|
135
143
|
posts a Fixed workflow BFF route and returns `{ runId }`.
|
|
136
144
|
|
|
137
|
-
The common client exposes `list`, `get`, `create`, `update`, `delete`, and
|
|
145
|
+
The common client exposes `list`, `listMembers`, `get`, `create`, `update`, `delete`, and
|
|
138
146
|
`upload` (see [File uploads](#file-uploads)).
|
|
139
147
|
`delete` calls the explicit soft-delete route. Every mutation requires an operation
|
|
140
148
|
key; update/delete also require the revision originally edited. Reads accept an
|
|
@@ -153,6 +161,53 @@ During migration, omitting `protocol` retains the distinct legacy resource facad
|
|
|
153
161
|
including its optional update keys, cursor pagination and explicit lifecycle
|
|
154
162
|
methods. Existing hard-delete behavior is never relabeled as common `delete`.
|
|
155
163
|
|
|
164
|
+
### Relation members
|
|
165
|
+
|
|
166
|
+
`resource.listMembers(parentId, field, query, { signal })` reads a forward or
|
|
167
|
+
inverse relation as an ordinary entity page. `query` uses `EntityListQuery`
|
|
168
|
+
filters, sorting, page pagination and includes on the resolved **member** schema.
|
|
169
|
+
For example:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const members = await leads.listMembers("lead-1", "companies", {
|
|
173
|
+
filter: { field: "industry", operator: "eq", value: "Research" },
|
|
174
|
+
sort: [{ field: "industry", direction: "asc" }],
|
|
175
|
+
pagination: { mode: "page", page: 1, pageSize: 25 }
|
|
176
|
+
})
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
CI transport sends `POST /application/v1/resources/:schemaFqn/records/:parentId/relation-members/search`
|
|
180
|
+
with `{ field, ...query }`. The existing page envelope and exact totals describe
|
|
181
|
+
the authorized filtered membership, including zero/one-member scalar relations.
|
|
182
|
+
Without explicit sorting, forward members use stored position and inverse members
|
|
183
|
+
use source ID order. CI authorizes the parent and members and validates the field.
|
|
184
|
+
A forward field needs no inverse declaration.
|
|
185
|
+
|
|
186
|
+
Member values are `EntityMemberValue` JSON objects, not the parent's generic type;
|
|
187
|
+
the codec validates the entire page and JSON without applying the parent's entity
|
|
188
|
+
schema or query field allowlist. Narrow member values using the member's own
|
|
189
|
+
schema before treating them as a specific application type.
|
|
190
|
+
|
|
191
|
+
Successful pages and root relation-ID values are complete. Included objects
|
|
192
|
+
return complete relation values only for requested next-hop fields; leaf objects
|
|
193
|
+
omit relation fields entirely rather than returning fabricated empty arrays or
|
|
194
|
+
nulls. Ordinary data and File values remain projected. Includes keep the existing
|
|
195
|
+
three-level depth and 100-readable-object per-field cap with explicit `truncated`
|
|
196
|
+
markers; nested include pagination is unavailable. Overall exhaustion fails with
|
|
197
|
+
`invalid_request` and details `{ reason: "read_limit_exceeded", budget }`, where
|
|
198
|
+
`budget` is `work`, `nodes`, `relation_ids` or `bytes`. The `/resources` export
|
|
199
|
+
`isEntityReadLimitError(error)` narrows to `EntityReadLimitDetails`. Narrow the
|
|
200
|
+
query or includes before retrying; these failures expose no member IDs or counts.
|
|
201
|
+
Current request-wide ceilings are 100,000 work units, 2,000 nested object
|
|
202
|
+
occurrences, 50,000 relation-ID occurrences and 8,388,608 accounted bytes.
|
|
203
|
+
Repeated serialized occurrences count even when target reads are deduplicated.
|
|
204
|
+
These are workload ceilings, not a latency or process-memory guarantee. See the
|
|
205
|
+
[limits and measured envelope](../../../docs/reference/knowledge-relation-fields.md#read-limits-and-measured-envelope)
|
|
206
|
+
for scope, recovery and benchmark evidence.
|
|
207
|
+
|
|
208
|
+
Cancellation and malformed responses retain read-only dispatch outcomes and
|
|
209
|
+
correlation IDs.
|
|
210
|
+
|
|
156
211
|
## File uploads
|
|
157
212
|
|
|
158
213
|
A File field holds files of a CI entity. The browser sends the file bytes
|
|
@@ -205,8 +260,8 @@ deletes an unused one after a retention window. Request a new one to retry.
|
|
|
205
260
|
not presign, with `invalid_request` (`details.reason` `not_a_file_field` or
|
|
206
261
|
`type_not_accepted`) for a field or MIME type the schema refuses, and with
|
|
207
262
|
`not_found` for an unknown schema. A write that refuses its write form answers
|
|
208
|
-
`invalid_request` with `details.field` and `details.reason`; a File field
|
|
209
|
-
connector
|
|
263
|
+
`invalid_request` with `details.field` and `details.reason`; a File field a
|
|
264
|
+
connector writes answers `conflict` with `details.field`.
|
|
210
265
|
|
|
211
266
|
## Workspace development
|
|
212
267
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as ResourceSort, A as ResourceCreateRequest, At as ClientFetch, B as ResourceLifecycleInput, C as EntityUploadInput, Ct as ConversationContinueTarget, D as ResourceCapabilities, Dt as QueryFilter, E as PortableResourceSchema, Et as KnowledgeQuery, F as ResourceFilter, Ft as FederatedAuthState, G as ResourceMutationInput, H as ResourceListQuery, I as ResourceGetRequest, It as FederatedSessionIdentity, J as ResourceRecord, K as ResourcePagination, L as ResourceId, Lt as createFederatedAuth, M as ResourceDefinition, Mt as FederatedAuthError, N as ResourceError, Nt as FederatedAuthErrorCode, O as ResourceClient, Ot as SearchQuery, P as ResourceErrorCode, Pt as FederatedAuthOptions, Q as ResourceRevision, R as ResourceIdentityField, S as EntityUpdateInput, St as ApplicationRole, T as IdempotencyKey, Tt as JsonObject, U as ResourceListRequest, V as ResourceLifecycleRequest, W as ResourceListResult, X as ResourceRequestOptions, Y as ResourceRecordId, Z as ResourceResult, _ as EntityPage, _t as OperationExecutionOptions, a as isEntityReadLimitError, at as createProxyTransport, b as EntityRequest, bt as isClientOperationId, c as EntityCreateInput, ct as CiResult, d as EntityFileValue, dt as OperationSuccess, et as ResourceTransport, f as EntityFileWrite, ft as ClientOperationDefinition, g as EntityOperationResult, gt as ClientOperationOutput, h as EntityOperation, ht as ClientOperationMap, i as createEntityProtocol, it as ProxyTransportOptions, j as ResourceCursor, jt as FederatedAuth, k as ResourceCreateInput, kt as WorkflowInvokeTarget, l as EntityDeleteInput, lt as JsonValue, m as EntityMemberValue, mt as ClientOperationInput, n as EntityHttpTransportOptions, nt as ResourceUpdateRequest, o as createResourceClient, ot as CiError, p as EntityListQuery, pt as ClientOperationId, q as ResourcePaginationMode, r as createEntityHttpTransport, rt as ProxyAuthentication, s as EntityClient, st as CiErrorCode, t as EntityHttpDestination, tt as ResourceTransportRequest, u as EntityFileFieldWrite, ut as OperationRequest, v as EntityProtocol, vt as TypedOperationExecutor, w as EntityUploadSlot, wt as ConversationHistory, x as EntityTransport, xt as AgentInvokeTarget, y as EntityReadLimitDetails, yt as clientOperationIds, z as ResourceJsonValue } from "./resources-BDcYZzER.js";
|
|
2
2
|
type ServerSessionAuthOptions = Readonly<{
|
|
3
3
|
basePath: string;
|
|
4
4
|
fetch?: ClientFetch;
|
|
@@ -158,6 +158,54 @@ declare const createDelegatedApplicationRuntime: (options: DelegatedApplicationR
|
|
|
158
158
|
subscribe: (listener: (state: FederatedAuthState) => void) => () => void;
|
|
159
159
|
}>;
|
|
160
160
|
client: ClientSdkClient<Readonly<{
|
|
161
|
+
users_get: ClientOperationDefinition<{
|
|
162
|
+
userId: string;
|
|
163
|
+
}, {
|
|
164
|
+
email: string | null;
|
|
165
|
+
name: string | null;
|
|
166
|
+
userId: string;
|
|
167
|
+
}>;
|
|
168
|
+
users_list: ClientOperationDefinition<{
|
|
169
|
+
page?: number;
|
|
170
|
+
pageSize?: number;
|
|
171
|
+
}, {
|
|
172
|
+
items: Array<{
|
|
173
|
+
email: string | null;
|
|
174
|
+
name: string | null;
|
|
175
|
+
userId: string;
|
|
176
|
+
}>;
|
|
177
|
+
}>;
|
|
178
|
+
users_deactivate: ClientOperationDefinition<{
|
|
179
|
+
userId: string;
|
|
180
|
+
}, {
|
|
181
|
+
userId: string;
|
|
182
|
+
}>;
|
|
183
|
+
roles_list: ClientOperationDefinition<Record<string, never>, {
|
|
184
|
+
items: ApplicationRole[];
|
|
185
|
+
}>;
|
|
186
|
+
roles_assign: ClientOperationDefinition<{
|
|
187
|
+
userId: string;
|
|
188
|
+
roles: string[];
|
|
189
|
+
}, {
|
|
190
|
+
userId: string;
|
|
191
|
+
}>;
|
|
192
|
+
roles_revoke: ClientOperationDefinition<{
|
|
193
|
+
userId: string;
|
|
194
|
+
roles: string[];
|
|
195
|
+
}, {
|
|
196
|
+
userId: string;
|
|
197
|
+
}>;
|
|
198
|
+
users_create_or_get: ClientOperationDefinition<{
|
|
199
|
+
email: string;
|
|
200
|
+
name: string;
|
|
201
|
+
roles: Array<string>;
|
|
202
|
+
}, {
|
|
203
|
+
email: string | null;
|
|
204
|
+
name: string | null;
|
|
205
|
+
userId: string;
|
|
206
|
+
created: boolean;
|
|
207
|
+
kind: "member" | "external_app_user";
|
|
208
|
+
}>;
|
|
161
209
|
context_get: ClientOperationDefinition<Readonly<Record<string, string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | readonly (string | number | boolean | /*elided*/ any | Readonly<{
|
|
162
210
|
readonly [key: string]: string | number | boolean | /*elided*/ any | Readonly< /*elided*/ any> | null;
|
|
163
211
|
}> | null)[] | Readonly<{
|
|
@@ -889,4 +937,4 @@ type DirectTransportOptions = Readonly<{
|
|
|
889
937
|
tenantUrl: string;
|
|
890
938
|
}>;
|
|
891
939
|
declare const createDirectTransport: <Operations extends ClientOperationMap>(options: DirectTransportOptions) => TypedOperationExecutor<Operations>;
|
|
892
|
-
export { type CiError, type CiErrorCode, type CiResult, type CiRunCancellation, type CiStreamEvent, type CiStreamPage, type ClientDomains, type ClientFetch, type ClientOperationDefinition, type ClientOperationId, type ClientOperationInput, type ClientOperationMap, type ClientOperationOutput, type ClientSdkClient, type ClientSdkEntrypoint, DEFAULT_FOLLOW_RUN_DEADLINE_MS, type DelegatedApplicationRuntime, type DelegatedApplicationRuntimeOptions, type DelegatedRuntimeState, type DirectTransportOptions, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityRequest, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type FederatedAuth, FederatedAuthError, type FederatedAuthErrorCode, type FederatedAuthOptions, type FederatedAuthState, type FederatedSessionIdentity, type FixedWorkflowClient, type FixedWorkflowClientOptions, type FollowRunOptions, type FollowRunSource, type IdempotencyKey, type JsonObject, type JsonValue, type KnowledgeQuery, type OperationExecutionOptions, type OperationRequest, type OperationSuccess, type OrganizationClient, type PortableResourceSchema, type ProxyAuthentication, type ProxyTransportOptions, type QueryFilter, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, type SearchQuery, type ServerSessionAuthOptions, type TypedOperationExecutor, type WorkflowInvokeTarget, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFixedWorkflowClient, createProxyTransport, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, nextStreamCursor };
|
|
940
|
+
export { type CiError, type CiErrorCode, type CiResult, type CiRunCancellation, type CiStreamEvent, type CiStreamPage, type ClientDomains, type ClientFetch, type ClientOperationDefinition, type ClientOperationId, type ClientOperationInput, type ClientOperationMap, type ClientOperationOutput, type ClientSdkClient, type ClientSdkEntrypoint, DEFAULT_FOLLOW_RUN_DEADLINE_MS, type DelegatedApplicationRuntime, type DelegatedApplicationRuntimeOptions, type DelegatedRuntimeState, type DirectTransportOptions, type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type FederatedAuth, FederatedAuthError, type FederatedAuthErrorCode, type FederatedAuthOptions, type FederatedAuthState, type FederatedSessionIdentity, type FixedWorkflowClient, type FixedWorkflowClientOptions, type FollowRunOptions, type FollowRunSource, type IdempotencyKey, type JsonObject, type JsonValue, type KnowledgeQuery, type OperationExecutionOptions, type OperationRequest, type OperationSuccess, type OrganizationClient, type PortableResourceSchema, type ProxyAuthentication, type ProxyTransportOptions, type QueryFilter, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, type SearchQuery, type ServerSessionAuthOptions, type TypedOperationExecutor, type WorkflowInvokeTarget, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFixedWorkflowClient, createProxyTransport, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, isEntityReadLimitError, nextStreamCursor };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as createHttpOperationTransport, c as clientOperationIds, i as isEntityReadLimitError, l as isClientOperationId, n as createResourceClient, o as parseMountPath, r as createEntityProtocol, s as parseOriginUrl, t as createEntityHttpTransport } from "./resources--kU5LiFu.js";
|
|
2
2
|
const base64Url = (bytes) => {
|
|
3
3
|
let binary = "";
|
|
4
4
|
for (const byte of bytes) binary += String.fromCodePoint(byte);
|
|
@@ -250,18 +250,35 @@ const readString$1 = (record, key) => {
|
|
|
250
250
|
const candidate = record[key];
|
|
251
251
|
return typeof candidate === "string" ? candidate : null;
|
|
252
252
|
};
|
|
253
|
+
const readStrings = (record, key) => {
|
|
254
|
+
const candidate = record[key];
|
|
255
|
+
if (!Array.isArray(candidate)) return null;
|
|
256
|
+
const items = candidate;
|
|
257
|
+
return items.every((item) => typeof item === "string") ? items : null;
|
|
258
|
+
};
|
|
259
|
+
const readKind = (record) => {
|
|
260
|
+
const { kind } = record;
|
|
261
|
+
return kind === "member" || kind === "external_app_user" ? kind : null;
|
|
262
|
+
};
|
|
253
263
|
const parseIdentity = (value) => {
|
|
254
|
-
const
|
|
255
|
-
if (
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
|
|
264
|
+
const identity = asRecord$2(asRecord$2(value)?.identity);
|
|
265
|
+
if (identity === null) return null;
|
|
266
|
+
const appId = readString$1(identity, "appId");
|
|
267
|
+
const appPermissions = readStrings(identity, "appPermissions");
|
|
268
|
+
const kind = readKind(identity);
|
|
269
|
+
const organizationId = readString$1(identity, "organizationId");
|
|
270
|
+
const roles = readStrings(identity, "roles");
|
|
271
|
+
const userId = readString$1(identity, "userId");
|
|
272
|
+
if (appId === null || appPermissions === null || kind === null || organizationId === null || roles === null || userId === null) return null;
|
|
260
273
|
return {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
274
|
+
appId,
|
|
275
|
+
appPermissions,
|
|
276
|
+
email: readString$1(identity, "email"),
|
|
277
|
+
kind,
|
|
278
|
+
name: readString$1(identity, "name"),
|
|
279
|
+
organizationId,
|
|
280
|
+
roles,
|
|
281
|
+
userId
|
|
265
282
|
};
|
|
266
283
|
};
|
|
267
284
|
/** Browser session client for a sealed-cookie BFF. The access token never leaves the server. */
|
|
@@ -722,4 +739,4 @@ const createDirectTransport = (options) => {
|
|
|
722
739
|
origin: tenantUrl
|
|
723
740
|
});
|
|
724
741
|
};
|
|
725
|
-
export { DEFAULT_FOLLOW_RUN_DEADLINE_MS, FederatedAuthError, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFixedWorkflowClient, createProxyTransport, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, nextStreamCursor };
|
|
742
|
+
export { DEFAULT_FOLLOW_RUN_DEADLINE_MS, FederatedAuthError, clientOperationIds, clientSdkProtocolVersion, createClient, createDelegatedApplicationRuntime, createDirectTransport, createEntityHttpTransport, createEntityProtocol, createFederatedAuth, createFixedWorkflowClient, createProxyTransport, createResourceClient, createServerSessionAuth, followRun, isClientOperationId, isEntityReadLimitError, nextStreamCursor };
|
|
@@ -22,6 +22,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
const completeOperationRegistry = (ids) => ids;
|
|
23
23
|
/** Generated, curated external-application operation authority. */
|
|
24
24
|
const clientOperationIds = completeOperationRegistry([
|
|
25
|
+
"users_get",
|
|
26
|
+
"users_list",
|
|
27
|
+
"users_deactivate",
|
|
28
|
+
"roles_list",
|
|
29
|
+
"roles_assign",
|
|
30
|
+
"roles_revoke",
|
|
31
|
+
"users_create_or_get",
|
|
25
32
|
"context_get",
|
|
26
33
|
"knowledge_query",
|
|
27
34
|
"knowledge_get_entity_schema_snapshot",
|
|
@@ -234,6 +241,47 @@ const dedicatedHttpCall = (operationId, input) => {
|
|
|
234
241
|
if (removedEntityOperation.has(operationId)) return null;
|
|
235
242
|
const record = isRecord$1(input) ? input : {};
|
|
236
243
|
switch (operationId) {
|
|
244
|
+
case "users_create_or_get": return {
|
|
245
|
+
body: input,
|
|
246
|
+
method: "POST",
|
|
247
|
+
parse: "json",
|
|
248
|
+
pathname: "/users"
|
|
249
|
+
};
|
|
250
|
+
case "users_list": {
|
|
251
|
+
const query = {};
|
|
252
|
+
if (typeof record.page === "number") query.page = String(record.page);
|
|
253
|
+
if (typeof record.pageSize === "number") query.pageSize = String(record.pageSize);
|
|
254
|
+
return {
|
|
255
|
+
method: "GET",
|
|
256
|
+
parse: "json",
|
|
257
|
+
pathname: "/users",
|
|
258
|
+
query
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
case "roles_list": return {
|
|
262
|
+
method: "GET",
|
|
263
|
+
parse: "json",
|
|
264
|
+
pathname: "/roles"
|
|
265
|
+
};
|
|
266
|
+
case "users_get":
|
|
267
|
+
case "users_deactivate":
|
|
268
|
+
case "roles_assign":
|
|
269
|
+
case "roles_revoke": {
|
|
270
|
+
const userId = textField(record, "userId");
|
|
271
|
+
if (userId === void 0) return null;
|
|
272
|
+
const pathname = `/users/${encodeURIComponent(userId)}`;
|
|
273
|
+
if (operationId === "users_get" || operationId === "users_deactivate") return {
|
|
274
|
+
method: operationId === "users_get" ? "GET" : "DELETE",
|
|
275
|
+
parse: "json",
|
|
276
|
+
pathname
|
|
277
|
+
};
|
|
278
|
+
return {
|
|
279
|
+
body: { roles: record.roles },
|
|
280
|
+
method: operationId === "roles_assign" ? "POST" : "DELETE",
|
|
281
|
+
parse: "json",
|
|
282
|
+
pathname: `${pathname}/roles`
|
|
283
|
+
};
|
|
284
|
+
}
|
|
237
285
|
case "context_get": return {
|
|
238
286
|
method: "GET",
|
|
239
287
|
parse: "json",
|
|
@@ -7575,6 +7623,36 @@ const objectSchema = (properties, required = Object.keys(properties)) => ({
|
|
|
7575
7623
|
required,
|
|
7576
7624
|
type: "object"
|
|
7577
7625
|
});
|
|
7626
|
+
/**
|
|
7627
|
+
* Include Paths: relation fields whose records a read returns in
|
|
7628
|
+
* `included`, such as `["company", "contacts.company"]`, at most three
|
|
7629
|
+
* levels deep. CI refuses a segment that names no relation field.
|
|
7630
|
+
*/
|
|
7631
|
+
const includeSchema = {
|
|
7632
|
+
items: {
|
|
7633
|
+
minLength: 1,
|
|
7634
|
+
pattern: "^[^.]+(\\.[^.]+){0,2}$",
|
|
7635
|
+
type: "string"
|
|
7636
|
+
},
|
|
7637
|
+
type: "array"
|
|
7638
|
+
};
|
|
7639
|
+
const escapePattern = (value) => value.replaceAll(/[$()*+.?[\\\]^{|}]/gu, "\\$&");
|
|
7640
|
+
/**
|
|
7641
|
+
* The Entity References a declared property holds: `one` uuid string, or
|
|
7642
|
+
* `many` as an array of uuid strings.
|
|
7643
|
+
*/
|
|
7644
|
+
const references = (property) => {
|
|
7645
|
+
if (property === null || typeof property !== "object" || Array.isArray(property)) return;
|
|
7646
|
+
if ("format" in property && property.format === "uuid") return "one";
|
|
7647
|
+
const items = "items" in property ? property.items : void 0;
|
|
7648
|
+
return items !== null && typeof items === "object" && !Array.isArray(items) && "format" in items && items.format === "uuid" ? "many" : void 0;
|
|
7649
|
+
};
|
|
7650
|
+
/**
|
|
7651
|
+
* A path through a field that holds Entity References, such as
|
|
7652
|
+
* `company.industry`: at most three relation fields and a field of the
|
|
7653
|
+
* last target, as CI resolves it.
|
|
7654
|
+
*/
|
|
7655
|
+
const relationPath = (field) => ({ pattern: `^${escapePattern(field)}(\\.[^.]+){1,3}$` });
|
|
7578
7656
|
const pointerKey = (key) => key.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
7579
7657
|
const schemaMaps = /* @__PURE__ */ new Set([
|
|
7580
7658
|
"$defs",
|
|
@@ -7651,42 +7729,95 @@ const entityQuerySchema = (definition) => {
|
|
|
7651
7729
|
...definition.query.sortableFields,
|
|
7652
7730
|
...definition.query.textSearchFields ?? []
|
|
7653
7731
|
]) if (!Object.hasOwn(properties, field)) throw new TypeError(`Query field '${field}' has no declared entity property`);
|
|
7654
|
-
const
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
...predicateProperties,
|
|
7666
|
-
value: valueSchema
|
|
7667
|
-
});
|
|
7732
|
+
const leaves = definition.query.filterableFields.flatMap((field) => {
|
|
7733
|
+
const cardinality = references(properties[field]);
|
|
7734
|
+
const value = { $ref: `#/$defs/filterEntity/properties/${pointerKey(field)}` };
|
|
7735
|
+
const nullable = { anyOf: [cardinality === "many" ? {
|
|
7736
|
+
format: "uuid",
|
|
7737
|
+
type: "string"
|
|
7738
|
+
} : value, { type: "null" }] };
|
|
7739
|
+
const predicate = (operators, valueSchema) => {
|
|
7740
|
+
const predicateProperties = {
|
|
7741
|
+
field: { const: field },
|
|
7742
|
+
operator: { enum: operators }
|
|
7668
7743
|
};
|
|
7669
|
-
return
|
|
7670
|
-
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7674
|
-
|
|
7675
|
-
|
|
7676
|
-
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7744
|
+
if (valueSchema === void 0) return objectSchema(predicateProperties);
|
|
7745
|
+
return objectSchema({
|
|
7746
|
+
...predicateProperties,
|
|
7747
|
+
value: valueSchema
|
|
7748
|
+
});
|
|
7749
|
+
};
|
|
7750
|
+
return [
|
|
7751
|
+
predicate(cardinality === void 0 ? ["is_null", "is_not_null"] : [
|
|
7752
|
+
"is_null",
|
|
7753
|
+
"is_not_null",
|
|
7754
|
+
"is_empty"
|
|
7755
|
+
]),
|
|
7756
|
+
...cardinality === "many" ? [predicate(["contains_any", "contains_all"], {
|
|
7757
|
+
items: { $ref: `${value.$ref}/items` },
|
|
7758
|
+
minItems: 1,
|
|
7759
|
+
type: "array"
|
|
7760
|
+
})] : [],
|
|
7761
|
+
predicate(["eq", "ne"], nullable),
|
|
7762
|
+
predicate([
|
|
7763
|
+
"gt",
|
|
7764
|
+
"gte",
|
|
7765
|
+
"lt",
|
|
7766
|
+
"lte"
|
|
7767
|
+
], { allOf: [value, { type: ["number", "string"] }] }),
|
|
7768
|
+
predicate([
|
|
7769
|
+
"contains",
|
|
7770
|
+
"starts_with",
|
|
7771
|
+
"ends_with"
|
|
7772
|
+
], { allOf: [value, { type: "string" }] }),
|
|
7773
|
+
predicate(["in", "not_in"], {
|
|
7774
|
+
items: nullable,
|
|
7775
|
+
minItems: 1,
|
|
7776
|
+
type: "array"
|
|
7777
|
+
})
|
|
7778
|
+
];
|
|
7779
|
+
});
|
|
7780
|
+
const relationPaths = definition.query.filterableFields.flatMap((field) => references(properties[field]) === void 0 ? [] : [
|
|
7781
|
+
objectSchema({
|
|
7782
|
+
field: relationPath(field),
|
|
7783
|
+
operator: { enum: [
|
|
7784
|
+
"contains",
|
|
7785
|
+
"ends_with",
|
|
7786
|
+
"eq",
|
|
7787
|
+
"gt",
|
|
7788
|
+
"gte",
|
|
7789
|
+
"ne",
|
|
7790
|
+
"lt",
|
|
7791
|
+
"lte",
|
|
7792
|
+
"starts_with"
|
|
7793
|
+
] },
|
|
7794
|
+
value: true
|
|
7795
|
+
}),
|
|
7796
|
+
objectSchema({
|
|
7797
|
+
field: relationPath(field),
|
|
7798
|
+
operator: { enum: [
|
|
7799
|
+
"in",
|
|
7800
|
+
"not_in",
|
|
7801
|
+
"contains_any",
|
|
7802
|
+
"contains_all"
|
|
7803
|
+
] },
|
|
7804
|
+
value: {
|
|
7805
|
+
minItems: 1,
|
|
7806
|
+
type: "array"
|
|
7807
|
+
}
|
|
7689
7808
|
}),
|
|
7809
|
+
objectSchema({
|
|
7810
|
+
field: relationPath(field),
|
|
7811
|
+
operator: { enum: [
|
|
7812
|
+
"is_null",
|
|
7813
|
+
"is_not_null",
|
|
7814
|
+
"is_empty"
|
|
7815
|
+
] }
|
|
7816
|
+
})
|
|
7817
|
+
]);
|
|
7818
|
+
const filter = { oneOf: [
|
|
7819
|
+
...leaves,
|
|
7820
|
+
...relationPaths,
|
|
7690
7821
|
objectSchema({
|
|
7691
7822
|
filters: {
|
|
7692
7823
|
items: { $ref: "#/$defs/filter" },
|
|
@@ -7714,6 +7845,7 @@ const entityQuerySchema = (definition) => {
|
|
|
7714
7845
|
});
|
|
7715
7846
|
const query = objectSchema({
|
|
7716
7847
|
filter: { $ref: "#/$defs/filter" },
|
|
7848
|
+
include: includeSchema,
|
|
7717
7849
|
pagination: page,
|
|
7718
7850
|
sort: {
|
|
7719
7851
|
items: objectSchema({
|
|
@@ -7730,6 +7862,94 @@ const entityQuerySchema = (definition) => {
|
|
|
7730
7862
|
query
|
|
7731
7863
|
};
|
|
7732
7864
|
};
|
|
7865
|
+
/** Member query structure is portable; CI validates fields against the resolved member schema. */
|
|
7866
|
+
const memberQuerySchema = {
|
|
7867
|
+
filter: { oneOf: [
|
|
7868
|
+
objectSchema({
|
|
7869
|
+
field: identifier,
|
|
7870
|
+
operator: { enum: ["eq", "ne"] },
|
|
7871
|
+
value: true
|
|
7872
|
+
}),
|
|
7873
|
+
objectSchema({
|
|
7874
|
+
field: identifier,
|
|
7875
|
+
operator: { enum: [
|
|
7876
|
+
"gt",
|
|
7877
|
+
"gte",
|
|
7878
|
+
"lt",
|
|
7879
|
+
"lte"
|
|
7880
|
+
] },
|
|
7881
|
+
value: { type: ["number", "string"] }
|
|
7882
|
+
}),
|
|
7883
|
+
objectSchema({
|
|
7884
|
+
field: identifier,
|
|
7885
|
+
operator: { enum: [
|
|
7886
|
+
"contains",
|
|
7887
|
+
"starts_with",
|
|
7888
|
+
"ends_with"
|
|
7889
|
+
] },
|
|
7890
|
+
value: { type: "string" }
|
|
7891
|
+
}),
|
|
7892
|
+
objectSchema({
|
|
7893
|
+
field: identifier,
|
|
7894
|
+
operator: { enum: [
|
|
7895
|
+
"in",
|
|
7896
|
+
"not_in",
|
|
7897
|
+
"contains_any",
|
|
7898
|
+
"contains_all"
|
|
7899
|
+
] },
|
|
7900
|
+
value: {
|
|
7901
|
+
minItems: 1,
|
|
7902
|
+
type: "array"
|
|
7903
|
+
}
|
|
7904
|
+
}),
|
|
7905
|
+
objectSchema({
|
|
7906
|
+
field: identifier,
|
|
7907
|
+
operator: { enum: [
|
|
7908
|
+
"is_null",
|
|
7909
|
+
"is_not_null",
|
|
7910
|
+
"is_empty"
|
|
7911
|
+
] }
|
|
7912
|
+
}),
|
|
7913
|
+
objectSchema({
|
|
7914
|
+
filters: {
|
|
7915
|
+
items: { $ref: "#/$defs/memberFilter" },
|
|
7916
|
+
minItems: 1,
|
|
7917
|
+
type: "array"
|
|
7918
|
+
},
|
|
7919
|
+
operator: { enum: ["and", "or"] }
|
|
7920
|
+
}),
|
|
7921
|
+
objectSchema({
|
|
7922
|
+
filter: { $ref: "#/$defs/memberFilter" },
|
|
7923
|
+
operator: { const: "not" }
|
|
7924
|
+
})
|
|
7925
|
+
] },
|
|
7926
|
+
query: objectSchema({
|
|
7927
|
+
filter: { $ref: "#/$defs/memberFilter" },
|
|
7928
|
+
include: includeSchema,
|
|
7929
|
+
pagination: objectSchema({
|
|
7930
|
+
mode: { const: "page" },
|
|
7931
|
+
page: {
|
|
7932
|
+
minimum: 1,
|
|
7933
|
+
type: "integer"
|
|
7934
|
+
},
|
|
7935
|
+
pageSize: {
|
|
7936
|
+
maximum: 100,
|
|
7937
|
+
minimum: 1,
|
|
7938
|
+
type: "integer"
|
|
7939
|
+
}
|
|
7940
|
+
}),
|
|
7941
|
+
sort: {
|
|
7942
|
+
items: objectSchema({
|
|
7943
|
+
direction: { enum: ["asc", "desc"] },
|
|
7944
|
+
field: identifier
|
|
7945
|
+
}),
|
|
7946
|
+
type: "array"
|
|
7947
|
+
},
|
|
7948
|
+
textSearch: { type: "string" }
|
|
7949
|
+
}, ["pagination"])
|
|
7950
|
+
};
|
|
7951
|
+
/** Narrow a decoded resource failure to its documented request-wide read limit. */
|
|
7952
|
+
const isEntityReadLimitError = (error) => error.code === "invalid_request" && error.details?.reason === "read_limit_exceeded" && (error.details.budget === "work" || error.details.budget === "nodes" || error.details.budget === "relation_ids" || error.details.budget === "bytes");
|
|
7733
7953
|
const operationKey = {
|
|
7734
7954
|
pattern: "^[\\w.-]{1,256}$",
|
|
7735
7955
|
type: "string"
|
|
@@ -7739,10 +7959,11 @@ const uploadText = {
|
|
|
7739
7959
|
minLength: 1,
|
|
7740
7960
|
type: "string"
|
|
7741
7961
|
};
|
|
7742
|
-
const requestSchema = (definition, operation, properties) => ({
|
|
7962
|
+
const requestSchema = (definition, operation, properties, optional = {}) => ({
|
|
7743
7963
|
additionalProperties: false,
|
|
7744
7964
|
properties: {
|
|
7745
7965
|
...properties,
|
|
7966
|
+
...optional,
|
|
7746
7967
|
operation: { const: operation },
|
|
7747
7968
|
requestId: identifier,
|
|
7748
7969
|
resourceId: { const: definition.id }
|
|
@@ -7762,6 +7983,12 @@ const correlation = (input, key, fallback) => {
|
|
|
7762
7983
|
else if (key === "correlationId" && "correlationId" in input) value = input.correlationId;
|
|
7763
7984
|
return typeof value === "string" && value.length > 0 ? value : fallback;
|
|
7764
7985
|
};
|
|
7986
|
+
const coherentPage = (validatePageEnvelope) => (input) => {
|
|
7987
|
+
if (!validatePageEnvelope(input)) return false;
|
|
7988
|
+
if (!input.ok) return true;
|
|
7989
|
+
const { value } = input;
|
|
7990
|
+
return value.totalPages === Math.ceil(value.totalItems / value.pageSize) && value.items.length <= value.pageSize && value.items.length <= value.totalItems && (value.page <= value.totalPages || value.items.length === 0);
|
|
7991
|
+
};
|
|
7765
7992
|
/** Common entity wire codec; transport and persistence remain with their owners. */
|
|
7766
7993
|
const createEntityProtocol = (definition) => {
|
|
7767
7994
|
const { filter, filterValues, query } = entityQuerySchema(definition);
|
|
@@ -7775,11 +8002,17 @@ const createEntityProtocol = (definition) => {
|
|
|
7775
8002
|
create: scopeSchema(definition.schemas.create ?? false, "#/$defs/create"),
|
|
7776
8003
|
filter,
|
|
7777
8004
|
filterEntity: scopeSchema(filterValues, "#/$defs/filterEntity"),
|
|
8005
|
+
memberFilter: memberQuerySchema.filter,
|
|
7778
8006
|
update: scopeSchema(definition.schemas.update ?? false, "#/$defs/update")
|
|
7779
8007
|
},
|
|
7780
8008
|
oneOf: [
|
|
7781
8009
|
requestSchema(definition, "list", { query }),
|
|
7782
|
-
requestSchema(definition, "
|
|
8010
|
+
requestSchema(definition, "list_members", {
|
|
8011
|
+
field: identifier,
|
|
8012
|
+
parentId: identifier,
|
|
8013
|
+
query: memberQuerySchema.query
|
|
8014
|
+
}),
|
|
8015
|
+
requestSchema(definition, "get", { id: identifier }, { include: includeSchema }),
|
|
7783
8016
|
requestSchema(definition, "create", {
|
|
7784
8017
|
idempotencyKey: operationKey,
|
|
7785
8018
|
value: { $ref: "#/$defs/create" }
|
|
@@ -7811,40 +8044,68 @@ const createEntityProtocol = (definition) => {
|
|
|
7811
8044
|
type: "string"
|
|
7812
8045
|
},
|
|
7813
8046
|
id: identifier,
|
|
8047
|
+
included: { type: "object" },
|
|
7814
8048
|
revision: identifier,
|
|
8049
|
+
truncated: {
|
|
8050
|
+
items: { type: "string" },
|
|
8051
|
+
type: "array"
|
|
8052
|
+
},
|
|
7815
8053
|
value: { $ref: "#/$defs/entity" }
|
|
7816
8054
|
}, [
|
|
7817
8055
|
"id",
|
|
7818
8056
|
"revision",
|
|
7819
8057
|
"value"
|
|
7820
8058
|
]);
|
|
7821
|
-
const error =
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
8059
|
+
const error = {
|
|
8060
|
+
...objectSchema({
|
|
8061
|
+
code: { enum: [
|
|
8062
|
+
"capability_not_supported",
|
|
8063
|
+
"conflict",
|
|
8064
|
+
"forbidden",
|
|
8065
|
+
"internal",
|
|
8066
|
+
"invalid_request",
|
|
8067
|
+
"not_found",
|
|
8068
|
+
"rate_limited",
|
|
8069
|
+
"transport_error",
|
|
8070
|
+
"unauthenticated",
|
|
8071
|
+
"unavailable",
|
|
8072
|
+
"upload_not_supported"
|
|
8073
|
+
] },
|
|
8074
|
+
details: { type: "object" },
|
|
8075
|
+
message: { type: "string" },
|
|
8076
|
+
outcome: { enum: [
|
|
8077
|
+
"not_dispatched",
|
|
8078
|
+
"rejected",
|
|
8079
|
+
"uncertain"
|
|
8080
|
+
] },
|
|
8081
|
+
retryable: { type: "boolean" }
|
|
8082
|
+
}, [
|
|
8083
|
+
"code",
|
|
8084
|
+
"message",
|
|
8085
|
+
"retryable"
|
|
8086
|
+
]),
|
|
8087
|
+
allOf: [{
|
|
8088
|
+
if: {
|
|
8089
|
+
properties: { details: {
|
|
8090
|
+
properties: { reason: { const: "read_limit_exceeded" } },
|
|
8091
|
+
required: ["reason"]
|
|
8092
|
+
} },
|
|
8093
|
+
required: ["details"]
|
|
8094
|
+
},
|
|
8095
|
+
then: { properties: {
|
|
8096
|
+
code: { const: "invalid_request" },
|
|
8097
|
+
details: objectSchema({
|
|
8098
|
+
budget: { enum: [
|
|
8099
|
+
"work",
|
|
8100
|
+
"nodes",
|
|
8101
|
+
"relation_ids",
|
|
8102
|
+
"bytes"
|
|
8103
|
+
] },
|
|
8104
|
+
reason: { const: "read_limit_exceeded" }
|
|
8105
|
+
})
|
|
8106
|
+
} }
|
|
8107
|
+
}]
|
|
8108
|
+
};
|
|
7848
8109
|
const liveRecord = {
|
|
7849
8110
|
...record,
|
|
7850
8111
|
properties: {
|
|
@@ -7903,17 +8164,28 @@ const createEntityProtocol = (definition) => {
|
|
|
7903
8164
|
uploadId: identifier,
|
|
7904
8165
|
url: identifier
|
|
7905
8166
|
})));
|
|
7906
|
-
const
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
8167
|
+
const validateMemberPage = ajv.compile(resultSchema({
|
|
8168
|
+
...page,
|
|
8169
|
+
properties: {
|
|
8170
|
+
...page.properties,
|
|
8171
|
+
items: {
|
|
8172
|
+
items: {
|
|
8173
|
+
...liveRecord,
|
|
8174
|
+
properties: {
|
|
8175
|
+
...liveRecord.properties,
|
|
8176
|
+
value: { type: "object" }
|
|
8177
|
+
}
|
|
8178
|
+
},
|
|
8179
|
+
type: "array"
|
|
8180
|
+
}
|
|
8181
|
+
}
|
|
8182
|
+
}));
|
|
7912
8183
|
const validateOperationResult = {
|
|
7913
8184
|
create: validateRecord,
|
|
7914
8185
|
delete: validateDeleted,
|
|
7915
8186
|
get: validateRecord,
|
|
7916
|
-
list: coherentPage,
|
|
8187
|
+
list: coherentPage(validatePage),
|
|
8188
|
+
list_members: coherentPage(validateMemberPage),
|
|
7917
8189
|
update: validateRecord,
|
|
7918
8190
|
upload: validateUploadSlot
|
|
7919
8191
|
};
|
|
@@ -7988,6 +8260,7 @@ const createCommonEntityClient = (options) => {
|
|
|
7988
8260
|
delete: "delete",
|
|
7989
8261
|
get: "get",
|
|
7990
8262
|
list: "search",
|
|
8263
|
+
list_members: "search",
|
|
7991
8264
|
update: "update",
|
|
7992
8265
|
upload: "upload"
|
|
7993
8266
|
}[input.operation]] !== true) return {
|
|
@@ -8007,7 +8280,7 @@ const createCommonEntityClient = (options) => {
|
|
|
8007
8280
|
...decoded,
|
|
8008
8281
|
error: {
|
|
8009
8282
|
...decoded.error,
|
|
8010
|
-
outcome: input.operation === "list" || input.operation === "get" ? "rejected" : "uncertain"
|
|
8283
|
+
outcome: input.operation === "list" || input.operation === "list_members" || input.operation === "get" ? "rejected" : "uncertain"
|
|
8011
8284
|
}
|
|
8012
8285
|
} : decoded;
|
|
8013
8286
|
} catch {
|
|
@@ -8016,7 +8289,7 @@ const createCommonEntityClient = (options) => {
|
|
|
8016
8289
|
error: {
|
|
8017
8290
|
code: "transport_error",
|
|
8018
8291
|
message: "The entity transport failed",
|
|
8019
|
-
outcome: input.operation === "list" || input.operation === "get" ? "rejected" : "uncertain",
|
|
8292
|
+
outcome: input.operation === "list" || input.operation === "list_members" || input.operation === "get" ? "rejected" : "uncertain",
|
|
8020
8293
|
retryable: false
|
|
8021
8294
|
},
|
|
8022
8295
|
ok: false
|
|
@@ -8041,6 +8314,12 @@ const createCommonEntityClient = (options) => {
|
|
|
8041
8314
|
operation: "list",
|
|
8042
8315
|
query
|
|
8043
8316
|
}, requestOptions),
|
|
8317
|
+
listMembers: (parentId, field, query, requestOptions) => execute({
|
|
8318
|
+
field,
|
|
8319
|
+
operation: "list_members",
|
|
8320
|
+
parentId,
|
|
8321
|
+
query
|
|
8322
|
+
}, requestOptions),
|
|
8044
8323
|
update: (input) => execute({
|
|
8045
8324
|
...input,
|
|
8046
8325
|
operation: "update"
|
|
@@ -8144,10 +8423,21 @@ const encode = (request) => {
|
|
|
8144
8423
|
method: "POST",
|
|
8145
8424
|
path: "/search"
|
|
8146
8425
|
};
|
|
8147
|
-
case "
|
|
8148
|
-
|
|
8149
|
-
|
|
8426
|
+
case "list_members": return {
|
|
8427
|
+
body: JSON.stringify({
|
|
8428
|
+
...request.query,
|
|
8429
|
+
field: request.field
|
|
8430
|
+
}),
|
|
8431
|
+
method: "POST",
|
|
8432
|
+
path: `/records/${encodeURIComponent(request.parentId)}/relation-members/search`
|
|
8150
8433
|
};
|
|
8434
|
+
case "get": {
|
|
8435
|
+
const query = request.include?.length ? `?include=${encodeURIComponent(request.include.join(","))}` : "";
|
|
8436
|
+
return {
|
|
8437
|
+
method: "GET",
|
|
8438
|
+
path: `/records/${encodeURIComponent(request.id)}${query}`
|
|
8439
|
+
};
|
|
8440
|
+
}
|
|
8151
8441
|
case "create": return {
|
|
8152
8442
|
body: JSON.stringify({
|
|
8153
8443
|
idempotencyKey: request.idempotencyKey,
|
|
@@ -8245,10 +8535,10 @@ const createEntityHttpTransport = (options) => {
|
|
|
8245
8535
|
return failure({
|
|
8246
8536
|
code: "transport_error",
|
|
8247
8537
|
message: "The entity response could not be received",
|
|
8248
|
-
outcome: request.operation === "get" || request.operation === "list" ? "rejected" : "uncertain",
|
|
8538
|
+
outcome: request.operation === "get" || request.operation === "list" || request.operation === "list_members" ? "rejected" : "uncertain",
|
|
8249
8539
|
retryable: false
|
|
8250
8540
|
});
|
|
8251
8541
|
}
|
|
8252
8542
|
} };
|
|
8253
8543
|
};
|
|
8254
|
-
export {
|
|
8544
|
+
export { createHttpOperationTransport as a, clientOperationIds as c, isEntityReadLimitError as i, isClientOperationId as l, createResourceClient as n, parseMountPath as o, createEntityProtocol as r, parseOriginUrl as s, createEntityHttpTransport as t };
|
|
@@ -3,11 +3,22 @@ declare class FederatedAuthError extends Error {
|
|
|
3
3
|
readonly code: FederatedAuthErrorCode;
|
|
4
4
|
constructor(code: FederatedAuthErrorCode, message: string);
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* The signed-in CI user as the application's BFF reports it: the fields of
|
|
8
|
+
* CI's `/oauth/identity`, read live by the server, plus email and name.
|
|
9
|
+
*/
|
|
6
10
|
type FederatedSessionIdentity = Readonly<{
|
|
11
|
+
appId: string;
|
|
12
|
+
/** The App Permissions of the user's effective roles. */
|
|
13
|
+
appPermissions: readonly string[];
|
|
7
14
|
email: string | null;
|
|
8
|
-
|
|
15
|
+
/** A person is a member or an External App User of one Organization, never both. */
|
|
16
|
+
kind: "member" | "external_app_user";
|
|
9
17
|
name: string | null;
|
|
10
18
|
organizationId: string;
|
|
19
|
+
/** The user's effective roles on the app. */
|
|
20
|
+
roles: readonly string[];
|
|
21
|
+
userId: string;
|
|
11
22
|
}>;
|
|
12
23
|
type FederatedAuthState = Readonly<{
|
|
13
24
|
status: "anonymous";
|
|
@@ -51,6 +62,87 @@ type FederatedAuthOptions = Readonly<{
|
|
|
51
62
|
tenantUrl: string;
|
|
52
63
|
}>;
|
|
53
64
|
declare const createFederatedAuth: (options: FederatedAuthOptions) => FederatedAuth;
|
|
65
|
+
type ExternalApplicationsListAppUsersResponses = {
|
|
66
|
+
/**
|
|
67
|
+
* Success
|
|
68
|
+
*/
|
|
69
|
+
200: {
|
|
70
|
+
correlationId: string;
|
|
71
|
+
result: {
|
|
72
|
+
items: Array<{
|
|
73
|
+
email: string | null;
|
|
74
|
+
name: string | null;
|
|
75
|
+
userId: string;
|
|
76
|
+
}>;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
type ExternalApplicationsListAppUsersResponse = ExternalApplicationsListAppUsersResponses[keyof ExternalApplicationsListAppUsersResponses];
|
|
81
|
+
type ExternalApplicationsCreateOrGetAppUserData = {
|
|
82
|
+
body: {
|
|
83
|
+
email: string;
|
|
84
|
+
name: string;
|
|
85
|
+
roles: Array<string>;
|
|
86
|
+
};
|
|
87
|
+
headers: {
|
|
88
|
+
authorization?: string;
|
|
89
|
+
'x-organization-id': string;
|
|
90
|
+
'x-correlation-id'?: string;
|
|
91
|
+
'x-external-audit-issuer'?: string;
|
|
92
|
+
'x-external-audit-subject'?: string;
|
|
93
|
+
'x-external-caller-kind'?: 'anonymous_visitor';
|
|
94
|
+
'x-external-ci-user-id'?: string;
|
|
95
|
+
'x-external-server-role'?: string;
|
|
96
|
+
};
|
|
97
|
+
path?: never;
|
|
98
|
+
query?: never;
|
|
99
|
+
url: '/application/v1/users';
|
|
100
|
+
};
|
|
101
|
+
type ExternalApplicationsCreateOrGetAppUserResponses = {
|
|
102
|
+
/**
|
|
103
|
+
* Success
|
|
104
|
+
*/
|
|
105
|
+
200: {
|
|
106
|
+
correlationId: string;
|
|
107
|
+
result: {
|
|
108
|
+
email: string | null;
|
|
109
|
+
name: string | null;
|
|
110
|
+
userId: string;
|
|
111
|
+
created: boolean;
|
|
112
|
+
kind: 'member' | 'external_app_user';
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
type ExternalApplicationsCreateOrGetAppUserResponse = ExternalApplicationsCreateOrGetAppUserResponses[keyof ExternalApplicationsCreateOrGetAppUserResponses];
|
|
117
|
+
type ExternalApplicationsGetAppUserResponses = {
|
|
118
|
+
/**
|
|
119
|
+
* Success
|
|
120
|
+
*/
|
|
121
|
+
200: {
|
|
122
|
+
correlationId: string;
|
|
123
|
+
result: {
|
|
124
|
+
email: string | null;
|
|
125
|
+
name: string | null;
|
|
126
|
+
userId: string;
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
type ExternalApplicationsGetAppUserResponse = ExternalApplicationsGetAppUserResponses[keyof ExternalApplicationsGetAppUserResponses];
|
|
131
|
+
type ExternalApplicationsListAppRolesResponses = {
|
|
132
|
+
/**
|
|
133
|
+
* Success
|
|
134
|
+
*/
|
|
135
|
+
200: {
|
|
136
|
+
correlationId: string;
|
|
137
|
+
result: {
|
|
138
|
+
items: Array<{
|
|
139
|
+
id: string;
|
|
140
|
+
key: string;
|
|
141
|
+
}>;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
type ExternalApplicationsListAppRolesResponse = ExternalApplicationsListAppRolesResponses[keyof ExternalApplicationsListAppRolesResponses];
|
|
54
146
|
type JsonValue$1 = boolean | null | number | readonly JsonValue$1[] | Readonly<{
|
|
55
147
|
readonly [key: string]: JsonValue$1;
|
|
56
148
|
}> | string;
|
|
@@ -135,6 +227,40 @@ type KnowledgeQuery = {
|
|
|
135
227
|
op: "autocomplete";
|
|
136
228
|
});
|
|
137
229
|
type ExternalApplicationOperationRequest = {
|
|
230
|
+
input: {
|
|
231
|
+
userId: string;
|
|
232
|
+
};
|
|
233
|
+
operationId: "users_get";
|
|
234
|
+
} | {
|
|
235
|
+
input: {
|
|
236
|
+
page?: number;
|
|
237
|
+
pageSize?: number;
|
|
238
|
+
};
|
|
239
|
+
operationId: "users_list";
|
|
240
|
+
} | {
|
|
241
|
+
input: {
|
|
242
|
+
userId: string;
|
|
243
|
+
};
|
|
244
|
+
operationId: "users_deactivate";
|
|
245
|
+
} | {
|
|
246
|
+
input: Record<string, never>;
|
|
247
|
+
operationId: "roles_list";
|
|
248
|
+
} | {
|
|
249
|
+
input: {
|
|
250
|
+
userId: string;
|
|
251
|
+
roles: string[];
|
|
252
|
+
};
|
|
253
|
+
operationId: "roles_assign";
|
|
254
|
+
} | {
|
|
255
|
+
input: {
|
|
256
|
+
userId: string;
|
|
257
|
+
roles: string[];
|
|
258
|
+
};
|
|
259
|
+
operationId: "roles_revoke";
|
|
260
|
+
} | {
|
|
261
|
+
input: ExternalApplicationsCreateOrGetAppUserData["body"];
|
|
262
|
+
operationId: "users_create_or_get";
|
|
263
|
+
} | {
|
|
138
264
|
input: JsonObject | unknown[];
|
|
139
265
|
operationId: "context_get";
|
|
140
266
|
} | {
|
|
@@ -336,7 +462,15 @@ interface EnvelopeSuccess<Id extends string, Result> {
|
|
|
336
462
|
operationId: Id;
|
|
337
463
|
result: Result;
|
|
338
464
|
}
|
|
339
|
-
type ExternalApplicationOperationSuccess = EnvelopeSuccess<"
|
|
465
|
+
type ExternalApplicationOperationSuccess = EnvelopeSuccess<"users_get", ApplicationUser> | EnvelopeSuccess<"users_list", ApplicationUserPage> | EnvelopeSuccess<"users_deactivate", {
|
|
466
|
+
userId: string;
|
|
467
|
+
}> | EnvelopeSuccess<"roles_list", {
|
|
468
|
+
items: ApplicationRole[];
|
|
469
|
+
}> | EnvelopeSuccess<"roles_assign", {
|
|
470
|
+
userId: string;
|
|
471
|
+
}> | EnvelopeSuccess<"roles_revoke", {
|
|
472
|
+
userId: string;
|
|
473
|
+
}> | EnvelopeSuccess<"users_create_or_get", ApplicationUserResolution> | EnvelopeSuccess<"context_get", JsonObject> | EnvelopeSuccess<"knowledge_query", JsonObject> | EnvelopeSuccess<"knowledge_get_entity_schema_snapshot", JsonObject> | EnvelopeSuccess<"knowledge_search_entities", JsonObject> | EnvelopeSuccess<"knowledge_facets", JsonObject> | EnvelopeSuccess<"knowledge_get_schema_query_context", JsonObject> | EnvelopeSuccess<"knowledge_autocomplete", JsonObject> | EnvelopeSuccess<"knowledge_get_entity", JsonObject> | EnvelopeSuccess<"knowledge_create_entity", JsonObject> | EnvelopeSuccess<"knowledge_update_entity", JsonObject> | EnvelopeSuccess<"knowledge_upsert_entity", JsonObject> | EnvelopeSuccess<"knowledge_delete_entity", JsonObject> | EnvelopeSuccess<"knowledge_traverse", JsonObject> | EnvelopeSuccess<"knowledge_create_relation", JsonObject> | EnvelopeSuccess<"knowledge_update_relation", JsonObject> | EnvelopeSuccess<"knowledge_delete_relation", JsonObject> | EnvelopeSuccess<"agents_list", JsonObject> | EnvelopeSuccess<"agents_invoke", {
|
|
340
474
|
runId: string;
|
|
341
475
|
}> | EnvelopeSuccess<"skills_list", JsonObject> | EnvelopeSuccess<"skills_invoke", {
|
|
342
476
|
runId: string;
|
|
@@ -354,28 +488,11 @@ type ExternalApplicationOperationSuccess = EnvelopeSuccess<"context_get", JsonOb
|
|
|
354
488
|
conversationId: string;
|
|
355
489
|
runId: string;
|
|
356
490
|
}> | EnvelopeSuccess<"conversations_history", ConversationHistory>;
|
|
357
|
-
/**
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
/** A person whose only role in the application's Organization is `member`. */
|
|
363
|
-
interface MemberUser {
|
|
364
|
-
email: string | null;
|
|
365
|
-
name: string | null;
|
|
366
|
-
userId: string;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* How create-or-get resolved the email: a new user, an existing CI user who
|
|
370
|
-
* joined the Organization as a member, or a user who already was one.
|
|
371
|
-
*/
|
|
372
|
-
type MemberUserResolution = "created" | "existing" | "linked";
|
|
373
|
-
interface MemberUserPage {
|
|
374
|
-
items: MemberUser[];
|
|
375
|
-
page: number;
|
|
376
|
-
pageSize: number;
|
|
377
|
-
totalItems: number;
|
|
378
|
-
}
|
|
491
|
+
/** User details returned by the application's user-management gateway. */
|
|
492
|
+
type ApplicationUser = ExternalApplicationsGetAppUserResponse["result"];
|
|
493
|
+
type ApplicationUserResolution = ExternalApplicationsCreateOrGetAppUserResponse["result"];
|
|
494
|
+
type ApplicationUserPage = ExternalApplicationsListAppUsersResponse["result"];
|
|
495
|
+
type ApplicationRole = ExternalApplicationsListAppRolesResponse["result"]["items"][number];
|
|
379
496
|
declare const storageFileIdBrand: unique symbol;
|
|
380
497
|
/** A durable private file of the application's Organization. */
|
|
381
498
|
type StorageFileId = string & Readonly<{
|
|
@@ -396,32 +513,9 @@ type ExternalApplicationServiceOperationRequest = {
|
|
|
396
513
|
operationId: "files_upload";
|
|
397
514
|
} | {
|
|
398
515
|
input: {
|
|
399
|
-
|
|
400
|
-
name: string;
|
|
516
|
+
origin: string;
|
|
401
517
|
};
|
|
402
|
-
operationId: "
|
|
403
|
-
} | {
|
|
404
|
-
input: {
|
|
405
|
-
userId: string;
|
|
406
|
-
};
|
|
407
|
-
operationId: "members_get";
|
|
408
|
-
} | {
|
|
409
|
-
input: {
|
|
410
|
-
page?: number;
|
|
411
|
-
pageSize?: number;
|
|
412
|
-
};
|
|
413
|
-
operationId: "members_list";
|
|
414
|
-
} | {
|
|
415
|
-
input: {
|
|
416
|
-
name: string;
|
|
417
|
-
userId: string;
|
|
418
|
-
};
|
|
419
|
-
operationId: "members_update";
|
|
420
|
-
} | {
|
|
421
|
-
input: {
|
|
422
|
-
userId: string;
|
|
423
|
-
};
|
|
424
|
-
operationId: "members_remove";
|
|
518
|
+
operationId: "origins_set_runtime";
|
|
425
519
|
} | {
|
|
426
520
|
input: {
|
|
427
521
|
userId: string;
|
|
@@ -440,10 +534,8 @@ interface UserCompanyLinks {
|
|
|
440
534
|
}
|
|
441
535
|
type ExternalApplicationServiceOperationSuccess = EnvelopeSuccess<"files_upload", {
|
|
442
536
|
storageFileId: StorageFileId;
|
|
443
|
-
}> | EnvelopeSuccess<"
|
|
444
|
-
|
|
445
|
-
}> | EnvelopeSuccess<"members_get", MemberUser> | EnvelopeSuccess<"members_list", MemberUserPage> | EnvelopeSuccess<"members_update", MemberUser> | EnvelopeSuccess<"members_remove", {
|
|
446
|
-
userId: string;
|
|
537
|
+
}> | EnvelopeSuccess<"origins_set_runtime", {
|
|
538
|
+
origin: string;
|
|
447
539
|
}> | EnvelopeSuccess<"users_list_company_links", UserCompanyLinks> | EnvelopeSuccess<"users_link_companies", UserCompanyLinks>;
|
|
448
540
|
/** Every operation a confidential server client may invoke. */
|
|
449
541
|
type ExternalApplicationServerOperationRequest = ExternalApplicationOperationRequest | ExternalApplicationServiceOperationRequest;
|
|
@@ -456,7 +548,7 @@ type ExternalApplicationOperationSuccessFor<Id extends ExternalApplicationServer
|
|
|
456
548
|
operationId: Id;
|
|
457
549
|
}>;
|
|
458
550
|
/** Generated, curated external-application operation authority. */
|
|
459
|
-
declare const clientOperationIds: readonly ["context_get", "knowledge_query", "knowledge_get_entity_schema_snapshot", "knowledge_search_entities", "knowledge_facets", "knowledge_get_schema_query_context", "knowledge_autocomplete", "knowledge_get_entity", "knowledge_create_entity", "knowledge_update_entity", "knowledge_upsert_entity", "knowledge_delete_entity", "knowledge_traverse", "knowledge_create_relation", "knowledge_update_relation", "knowledge_delete_relation", "agents_list", "agents_invoke", "skills_list", "skills_invoke", "workflows_list", "workflows_invoke", "runs_get", "runs_stream", "runs_cancel", "attachments_upload", "attachments_download_url", "conversations_continue", "conversations_history"];
|
|
551
|
+
declare const clientOperationIds: readonly ["users_get", "users_list", "users_deactivate", "roles_list", "roles_assign", "roles_revoke", "users_create_or_get", "context_get", "knowledge_query", "knowledge_get_entity_schema_snapshot", "knowledge_search_entities", "knowledge_facets", "knowledge_get_schema_query_context", "knowledge_autocomplete", "knowledge_get_entity", "knowledge_create_entity", "knowledge_update_entity", "knowledge_upsert_entity", "knowledge_delete_entity", "knowledge_traverse", "knowledge_create_relation", "knowledge_update_relation", "knowledge_delete_relation", "agents_list", "agents_invoke", "skills_list", "skills_invoke", "workflows_list", "workflows_invoke", "runs_get", "runs_stream", "runs_cancel", "attachments_upload", "attachments_download_url", "conversations_continue", "conversations_history"];
|
|
460
552
|
type ClientOperationId = ExternalApplicationOperationId;
|
|
461
553
|
declare const isClientOperationId: (value: string) => value is ClientOperationId;
|
|
462
554
|
interface ClientOperationDefinition<Input, Output> {
|
|
@@ -572,13 +664,21 @@ type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>> = Rea
|
|
|
572
664
|
}>;
|
|
573
665
|
}>;
|
|
574
666
|
type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
|
|
667
|
+
/**
|
|
668
|
+
* A filter predicate. `field` names a declared filterable field, or a path
|
|
669
|
+
* through at most three fields that hold Entity References to a field of
|
|
670
|
+
* the last target, such as `company.industry` or
|
|
671
|
+
* `contacts.company.parent.industry`. On a field that holds Entity
|
|
672
|
+
* References, `is_empty` means no reference, and `contains_any` and
|
|
673
|
+
* `contains_all` compare the ids of a field that holds many.
|
|
674
|
+
*/
|
|
575
675
|
type ResourceFilter = Readonly<{
|
|
576
676
|
field: string;
|
|
577
|
-
operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
|
|
677
|
+
operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
|
|
578
678
|
value: FilterValue;
|
|
579
679
|
}> | Readonly<{
|
|
580
680
|
field: string;
|
|
581
|
-
operator: "is_not_null" | "is_null";
|
|
681
|
+
operator: "is_empty" | "is_not_null" | "is_null";
|
|
582
682
|
}> | Readonly<{
|
|
583
683
|
filters: readonly ResourceFilter[];
|
|
584
684
|
operator: "and" | "or";
|
|
@@ -601,6 +701,11 @@ type ResourcePagination = Readonly<{
|
|
|
601
701
|
}>;
|
|
602
702
|
type ResourceListQuery = Readonly<{
|
|
603
703
|
filter?: ResourceFilter;
|
|
704
|
+
/**
|
|
705
|
+
* Include Paths, such as `["company", "contacts.company"]`: relation
|
|
706
|
+
* fields whose records each item carries in `included`.
|
|
707
|
+
*/
|
|
708
|
+
include?: readonly string[];
|
|
604
709
|
includeDeleted?: boolean;
|
|
605
710
|
pagination: ResourcePagination;
|
|
606
711
|
sort?: readonly ResourceSort[];
|
|
@@ -609,7 +714,15 @@ type ResourceListQuery = Readonly<{
|
|
|
609
714
|
type ResourceRecord<Entity> = Readonly<{
|
|
610
715
|
deletedAt?: string;
|
|
611
716
|
id: ResourceRecordId;
|
|
717
|
+
/**
|
|
718
|
+
* The records of the read's Include Paths by relation field key: one
|
|
719
|
+
* record, or the records of a `many` field in reference order. Untyped:
|
|
720
|
+
* the target schemas are CI's.
|
|
721
|
+
*/
|
|
722
|
+
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
612
723
|
revision: ResourceRevision;
|
|
724
|
+
/** The keys whose included records were cut to the first 100. */
|
|
725
|
+
truncated?: readonly string[];
|
|
613
726
|
value: Entity;
|
|
614
727
|
}>;
|
|
615
728
|
type ResourceListResult<Entity> = Readonly<{
|
|
@@ -627,6 +740,11 @@ type ResourceListResult<Entity> = Readonly<{
|
|
|
627
740
|
type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
|
|
628
741
|
/** The CI Organization storage can not take a presigned File upload. */
|
|
629
742
|
"upload_not_supported";
|
|
743
|
+
/** Stable, content-free diagnostics for request-wide Knowledge read limits. */
|
|
744
|
+
type EntityReadLimitDetails = Readonly<{
|
|
745
|
+
reason: "read_limit_exceeded";
|
|
746
|
+
budget: "work" | "nodes" | "relation_ids" | "bytes";
|
|
747
|
+
}>;
|
|
630
748
|
type ResourceError = Readonly<{
|
|
631
749
|
code: ResourceErrorCode;
|
|
632
750
|
/** Client-observed dispatch outcome; uncertainty never proves rollback. */
|
|
@@ -718,7 +836,7 @@ interface ResourceClient<Entity, Create = Entity, Update = Partial<Entity>> {
|
|
|
718
836
|
readonly update: (input: ResourceMutationInput<Update>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
719
837
|
}
|
|
720
838
|
/** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
|
|
721
|
-
type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
|
|
839
|
+
type EntityOperation = "list_members" | "list" | "get" | "create" | "update" | "delete" | "upload";
|
|
722
840
|
type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
|
|
723
841
|
pagination: Extract<ResourcePagination, {
|
|
724
842
|
mode: "page";
|
|
@@ -727,6 +845,8 @@ type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted">
|
|
|
727
845
|
type EntityPage<Value> = Extract<ResourceListResult<Value>, {
|
|
728
846
|
pagination: "page";
|
|
729
847
|
}>;
|
|
848
|
+
/** Member schemas are resolved by CI, independently of the parent resource. */
|
|
849
|
+
type EntityMemberValue = Readonly<Record<string, ResourceJsonValue>>;
|
|
730
850
|
type EntityCreateInput<Value> = ResourceCreateInput<Value>;
|
|
731
851
|
type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
|
|
732
852
|
idempotencyKey: IdempotencyKey;
|
|
@@ -777,9 +897,15 @@ type EntityRequestIdentity = Readonly<{
|
|
|
777
897
|
type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity & (Readonly<{
|
|
778
898
|
operation: "list";
|
|
779
899
|
query: EntityListQuery;
|
|
900
|
+
}> | Readonly<{
|
|
901
|
+
operation: "list_members";
|
|
902
|
+
parentId: ResourceRecordId;
|
|
903
|
+
field: string;
|
|
904
|
+
query: EntityListQuery;
|
|
780
905
|
}> | Readonly<{
|
|
781
906
|
operation: "get";
|
|
782
907
|
id: ResourceRecordId;
|
|
908
|
+
include?: readonly string[];
|
|
783
909
|
}> | (Readonly<{
|
|
784
910
|
operation: "create";
|
|
785
911
|
}> & EntityCreateInput<Create>) | (Readonly<{
|
|
@@ -789,7 +915,7 @@ type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity &
|
|
|
789
915
|
}> & EntityDeleteInput) | (Readonly<{
|
|
790
916
|
operation: "upload";
|
|
791
917
|
}> & EntityUploadInput));
|
|
792
|
-
type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
|
|
918
|
+
type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list_members" ? EntityPage<EntityMemberValue> : Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
|
|
793
919
|
/** Codecs return safe typed failures without coercing values or performing I/O. */
|
|
794
920
|
type EntityProtocol<Value, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
795
921
|
decodeRequest: (input: unknown) => ResourceResult<EntityRequest<Create, Patch>>;
|
|
@@ -800,10 +926,13 @@ interface EntityTransport {
|
|
|
800
926
|
}
|
|
801
927
|
/** A logical write retains its key, payload and edited revision on explicit resubmission. */
|
|
802
928
|
interface EntityClient<Value, Create = Value, Patch = Partial<Value>> {
|
|
929
|
+
/** Filter, sort and page the resolved member schema; includes remain bounded. */
|
|
930
|
+
readonly listMembers: (parentId: ResourceRecordId, field: string, query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<EntityMemberValue>>>;
|
|
803
931
|
readonly definition: ResourceDefinition<Value, Create, Patch>;
|
|
804
932
|
readonly list: (query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<Value>>>;
|
|
805
933
|
readonly get: (input: Readonly<{
|
|
806
934
|
id: ResourceRecordId;
|
|
935
|
+
include?: readonly string[];
|
|
807
936
|
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
808
937
|
readonly create: (input: EntityCreateInput<Create>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
809
938
|
readonly update: (input: EntityUpdateInput<Patch>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
@@ -822,6 +951,11 @@ declare function createResourceClient<Value, Create = Value, Patch = Partial<Val
|
|
|
822
951
|
declare function createResourceClient<Value, Create = Value, Patch = Partial<Value>>(options: ClientOptions<Value, Create, Patch> & Readonly<{
|
|
823
952
|
transport: ResourceTransport;
|
|
824
953
|
}>): ResourceClient<Value, Create, Patch>;
|
|
954
|
+
/** Narrow a decoded resource failure to its documented request-wide read limit. */
|
|
955
|
+
declare const isEntityReadLimitError: (error: ResourceError) => error is ResourceError & Readonly<{
|
|
956
|
+
code: "invalid_request";
|
|
957
|
+
details: EntityReadLimitDetails;
|
|
958
|
+
}>;
|
|
825
959
|
/** Common entity wire codec; transport and persistence remain with their owners. */
|
|
826
960
|
declare const createEntityProtocol: <Value, Create = Value, Patch = Partial<Value>>(definition: ResourceDefinition<Value, Create, Patch>) => EntityProtocol<Value, Create, Patch>;
|
|
827
961
|
type EntityHttpDestination = Readonly<{
|
|
@@ -839,4 +973,4 @@ type EntityHttpTransportOptions = Readonly<{
|
|
|
839
973
|
fetch?: ClientFetch;
|
|
840
974
|
}>;
|
|
841
975
|
declare const createEntityHttpTransport: (options: EntityHttpTransportOptions) => EntityTransport;
|
|
842
|
-
export {
|
|
976
|
+
export { ResourceSort as $, ResourceCreateRequest as A, ClientFetch as At, ResourceLifecycleInput as B, EntityUploadInput as C, ConversationContinueTarget as Ct, ResourceCapabilities as D, QueryFilter as Dt, PortableResourceSchema as E, KnowledgeQuery as Et, ResourceFilter as F, FederatedAuthState as Ft, ResourceMutationInput as G, ResourceListQuery as H, ResourceGetRequest as I, FederatedSessionIdentity as It, ResourceRecord as J, ResourcePagination as K, ResourceId as L, createFederatedAuth as Lt, ResourceDefinition as M, FederatedAuthError as Mt, ResourceError as N, FederatedAuthErrorCode as Nt, ResourceClient as O, SearchQuery as Ot, ResourceErrorCode as P, FederatedAuthOptions as Pt, ResourceRevision as Q, ResourceIdentityField as R, EntityUpdateInput as S, ApplicationRole as St, IdempotencyKey as T, JsonObject as Tt, ResourceListRequest as U, ResourceLifecycleRequest as V, ResourceListResult as W, ResourceRequestOptions as X, ResourceRecordId as Y, ResourceResult as Z, EntityPage as _, OperationExecutionOptions as _t, isEntityReadLimitError as a, createProxyTransport as at, EntityRequest as b, isClientOperationId as bt, EntityCreateInput as c, CiResult as ct, EntityFileValue as d, OperationSuccess as dt, ResourceTransport as et, EntityFileWrite as f, ClientOperationDefinition as ft, EntityOperationResult as g, ClientOperationOutput as gt, EntityOperation as h, ClientOperationMap as ht, createEntityProtocol as i, ProxyTransportOptions as it, ResourceCursor as j, FederatedAuth as jt, ResourceCreateInput as k, WorkflowInvokeTarget as kt, EntityDeleteInput as l, JsonValue as lt, EntityMemberValue as m, ClientOperationInput as mt, EntityHttpTransportOptions as n, ResourceUpdateRequest as nt, createResourceClient as o, CiError as ot, EntityListQuery as p, ClientOperationId as pt, ResourcePaginationMode as q, createEntityHttpTransport as r, ProxyAuthentication as rt, EntityClient as s, CiErrorCode as st, EntityHttpDestination as t, ResourceTransportRequest as tt, EntityFileFieldWrite as u, OperationRequest as ut, EntityProtocol as v, TypedOperationExecutor as vt, EntityUploadSlot as w, ConversationHistory as wt, EntityTransport as x, AgentInvokeTarget as xt, EntityReadLimitDetails as y, clientOperationIds as yt, ResourceJsonValue as z };
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityRequest, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type IdempotencyKey, type PortableResourceSchema, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, createEntityHttpTransport, createEntityProtocol, createResourceClient };
|
|
1
|
+
import { $ as ResourceSort, A as ResourceCreateRequest, B as ResourceLifecycleInput, C as EntityUploadInput, D as ResourceCapabilities, E as PortableResourceSchema, F as ResourceFilter, G as ResourceMutationInput, H as ResourceListQuery, I as ResourceGetRequest, J as ResourceRecord, K as ResourcePagination, L as ResourceId, M as ResourceDefinition, N as ResourceError, O as ResourceClient, P as ResourceErrorCode, Q as ResourceRevision, R as ResourceIdentityField, S as EntityUpdateInput, T as IdempotencyKey, U as ResourceListRequest, V as ResourceLifecycleRequest, W as ResourceListResult, X as ResourceRequestOptions, Y as ResourceRecordId, Z as ResourceResult, _ as EntityPage, a as isEntityReadLimitError, b as EntityRequest, c as EntityCreateInput, d as EntityFileValue, et as ResourceTransport, f as EntityFileWrite, g as EntityOperationResult, h as EntityOperation, i as createEntityProtocol, j as ResourceCursor, k as ResourceCreateInput, l as EntityDeleteInput, m as EntityMemberValue, n as EntityHttpTransportOptions, nt as ResourceUpdateRequest, o as createResourceClient, p as EntityListQuery, q as ResourcePaginationMode, r as createEntityHttpTransport, s as EntityClient, t as EntityHttpDestination, tt as ResourceTransportRequest, u as EntityFileFieldWrite, v as EntityProtocol, w as EntityUploadSlot, x as EntityTransport, y as EntityReadLimitDetails, z as ResourceJsonValue } from "./resources-BDcYZzER.js";
|
|
2
|
+
export { type EntityClient, type EntityCreateInput, type EntityDeleteInput, type EntityFileFieldWrite, type EntityFileValue, type EntityFileWrite, type EntityHttpDestination, type EntityHttpTransportOptions, type EntityListQuery, type EntityMemberValue, type EntityOperation, type EntityOperationResult, type EntityPage, type EntityProtocol, type EntityReadLimitDetails, type EntityRequest, type EntityTransport, type EntityUpdateInput, type EntityUploadInput, type EntityUploadSlot, type IdempotencyKey, type PortableResourceSchema, type ResourceCapabilities, type ResourceClient, type ResourceCreateInput, type ResourceCreateRequest, type ResourceCursor, type ResourceDefinition, type ResourceError, type ResourceErrorCode, type ResourceFilter, type ResourceGetRequest, type ResourceId, type ResourceIdentityField, type ResourceJsonValue, type ResourceLifecycleInput, type ResourceLifecycleRequest, type ResourceListQuery, type ResourceListRequest, type ResourceListResult, type ResourceMutationInput, type ResourcePagination, type ResourcePaginationMode, type ResourceRecord, type ResourceRecordId, type ResourceRequestOptions, type ResourceResult, type ResourceRevision, type ResourceSort, type ResourceTransport, type ResourceTransportRequest, type ResourceUpdateRequest, createEntityHttpTransport, createEntityProtocol, createResourceClient, isEntityReadLimitError };
|
package/dist/resources.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createResourceClient, r as createEntityProtocol, t as createEntityHttpTransport } from "./resources
|
|
2
|
-
export { createEntityHttpTransport, createEntityProtocol, createResourceClient };
|
|
1
|
+
import { i as isEntityReadLimitError, n as createResourceClient, r as createEntityProtocol, t as createEntityHttpTransport } from "./resources--kU5LiFu.js";
|
|
2
|
+
export { createEntityHttpTransport, createEntityProtocol, createResourceClient, isEntityReadLimitError };
|
package/package.json
CHANGED