@collective-intelligence/external-apps-client-sdk 0.0.0-stage → 0.1.0
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 +123 -2
- package/dist/index.d.ts +892 -0
- package/dist/index.js +725 -0
- package/dist/resources-B9JIzIvl.d.ts +704 -0
- package/dist/resources-BYm1KWAZ.js +8219 -0
- package/dist/resources.d.ts +2 -0
- package/dist/resources.js +2 -0
- package/package.json +53 -4
|
@@ -0,0 +1,704 @@
|
|
|
1
|
+
type FederatedAuthErrorCode = "configuration_error" | "invalid_return_target" | "invalid_callback" | "invalid_state" | "transaction_expired" | "authorization_failed" | "token_exchange_failed" | "reauthorization_required";
|
|
2
|
+
declare class FederatedAuthError extends Error {
|
|
3
|
+
readonly code: FederatedAuthErrorCode;
|
|
4
|
+
constructor(code: FederatedAuthErrorCode, message: string);
|
|
5
|
+
}
|
|
6
|
+
type FederatedSessionIdentity = Readonly<{
|
|
7
|
+
email: string | null;
|
|
8
|
+
id: string;
|
|
9
|
+
name: string | null;
|
|
10
|
+
organizationId: string;
|
|
11
|
+
}>;
|
|
12
|
+
type FederatedAuthState = Readonly<{
|
|
13
|
+
status: "anonymous";
|
|
14
|
+
}> | Readonly<{
|
|
15
|
+
status: "redirecting";
|
|
16
|
+
}> | Readonly<{
|
|
17
|
+
expiresAt: number;
|
|
18
|
+
identity?: FederatedSessionIdentity;
|
|
19
|
+
status: "authenticated";
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
status: "expired";
|
|
22
|
+
}> | Readonly<{
|
|
23
|
+
error: FederatedAuthError;
|
|
24
|
+
status: "error";
|
|
25
|
+
}>;
|
|
26
|
+
type FederatedAuth = Readonly<{
|
|
27
|
+
beginLogin: (options: Readonly<{
|
|
28
|
+
returnTo: string;
|
|
29
|
+
}>) => Promise<string>;
|
|
30
|
+
completeLogin: (callbackUrl: string) => Promise<Readonly<{
|
|
31
|
+
returnTo: string;
|
|
32
|
+
}>>;
|
|
33
|
+
getAccessToken: () => Promise<string>;
|
|
34
|
+
getState: () => FederatedAuthState;
|
|
35
|
+
logout: () => Promise<void>;
|
|
36
|
+
reauthorize: (options?: Readonly<{
|
|
37
|
+
returnTo?: string;
|
|
38
|
+
}>) => Promise<string>;
|
|
39
|
+
subscribe: (listener: (state: FederatedAuthState) => void) => () => void;
|
|
40
|
+
}>;
|
|
41
|
+
type ClientFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
42
|
+
type FederatedAuthOptions = Readonly<{
|
|
43
|
+
clientId: string;
|
|
44
|
+
crypto?: Pick<Crypto, "getRandomValues" | "subtle">;
|
|
45
|
+
fetch?: ClientFetch;
|
|
46
|
+
navigate?: (url: string) => void;
|
|
47
|
+
now?: () => number;
|
|
48
|
+
redirectUri: string;
|
|
49
|
+
scopes: readonly string[];
|
|
50
|
+
sessionStorage?: Pick<Storage, "getItem" | "removeItem" | "setItem">;
|
|
51
|
+
tenantUrl: string;
|
|
52
|
+
}>;
|
|
53
|
+
declare const createFederatedAuth: (options: FederatedAuthOptions) => FederatedAuth;
|
|
54
|
+
type JsonValue$1 = boolean | null | number | readonly JsonValue$1[] | Readonly<{
|
|
55
|
+
readonly [key: string]: JsonValue$1;
|
|
56
|
+
}> | string;
|
|
57
|
+
type JsonObject = Readonly<Record<string, JsonValue$1>>;
|
|
58
|
+
type WorkflowInvokeTarget = {
|
|
59
|
+
workflowId: string;
|
|
60
|
+
workflowFqn?: never;
|
|
61
|
+
} | {
|
|
62
|
+
workflowFqn: string;
|
|
63
|
+
workflowId?: never;
|
|
64
|
+
};
|
|
65
|
+
/** Addresses an Agent by its UUID or its in-organization FQN. */
|
|
66
|
+
type AgentInvokeTarget = {
|
|
67
|
+
agentId: string;
|
|
68
|
+
agentFqn?: never;
|
|
69
|
+
} | {
|
|
70
|
+
agentFqn: string;
|
|
71
|
+
agentId?: never;
|
|
72
|
+
};
|
|
73
|
+
/** Starts a conversation with an Agent, or continues an existing one. */
|
|
74
|
+
type ConversationContinueTarget = (AgentInvokeTarget & {
|
|
75
|
+
conversationId?: never;
|
|
76
|
+
}) | {
|
|
77
|
+
agentFqn?: never;
|
|
78
|
+
agentId?: never;
|
|
79
|
+
conversationId: string;
|
|
80
|
+
};
|
|
81
|
+
type ConversationTurnStatus = "accepted" | "cancelled" | "failed" | "running" | "succeeded";
|
|
82
|
+
/**
|
|
83
|
+
* One conversation turn: the application's input, the Agent's final message
|
|
84
|
+
* once its run succeeded, and the Agent Output the run saved, if any.
|
|
85
|
+
* `runId` identifies the turn and its producing run.
|
|
86
|
+
*/
|
|
87
|
+
interface ConversationTurn {
|
|
88
|
+
completedAt: string | null;
|
|
89
|
+
createdAt: string;
|
|
90
|
+
input: unknown;
|
|
91
|
+
message: string | null;
|
|
92
|
+
output?: unknown;
|
|
93
|
+
runId: string;
|
|
94
|
+
status: ConversationTurnStatus;
|
|
95
|
+
}
|
|
96
|
+
interface ConversationHistory {
|
|
97
|
+
agentId: string;
|
|
98
|
+
conversationId: string;
|
|
99
|
+
createdAt: string;
|
|
100
|
+
turns: ConversationTurn[];
|
|
101
|
+
}
|
|
102
|
+
interface QueryFilter {
|
|
103
|
+
caseSensitive?: boolean;
|
|
104
|
+
field: string;
|
|
105
|
+
op: "eq" | "neq" | "in" | "contains" | "gt" | "gte" | "lt" | "lte" | "exists";
|
|
106
|
+
value?: unknown;
|
|
107
|
+
}
|
|
108
|
+
interface SearchQuery {
|
|
109
|
+
cursor?: string;
|
|
110
|
+
entitySchemaId: string;
|
|
111
|
+
fields?: string[];
|
|
112
|
+
filters?: QueryFilter[];
|
|
113
|
+
limit?: number;
|
|
114
|
+
text?: string;
|
|
115
|
+
}
|
|
116
|
+
type KnowledgeQuery = {
|
|
117
|
+
entityId: string;
|
|
118
|
+
op: "get";
|
|
119
|
+
} | {
|
|
120
|
+
anchorEntityId: string;
|
|
121
|
+
filters?: QueryFilter[];
|
|
122
|
+
limit?: number;
|
|
123
|
+
op: "related";
|
|
124
|
+
relationSchemaId: string;
|
|
125
|
+
text?: string;
|
|
126
|
+
} | (SearchQuery & {
|
|
127
|
+
op: "search";
|
|
128
|
+
}) | {
|
|
129
|
+
entitySchemaId: string;
|
|
130
|
+
fields: string[];
|
|
131
|
+
filters?: QueryFilter[];
|
|
132
|
+
op: "facets";
|
|
133
|
+
text?: string;
|
|
134
|
+
} | (SearchQuery & {
|
|
135
|
+
op: "autocomplete";
|
|
136
|
+
});
|
|
137
|
+
type ExternalApplicationOperationRequest = {
|
|
138
|
+
input: JsonObject | unknown[];
|
|
139
|
+
operationId: "context_get";
|
|
140
|
+
} | {
|
|
141
|
+
input: {
|
|
142
|
+
query: KnowledgeQuery;
|
|
143
|
+
};
|
|
144
|
+
operationId: "knowledge_query";
|
|
145
|
+
} | {
|
|
146
|
+
input: {
|
|
147
|
+
schemaId: string;
|
|
148
|
+
};
|
|
149
|
+
operationId: "knowledge_get_entity_schema_snapshot";
|
|
150
|
+
} | {
|
|
151
|
+
input: SearchQuery;
|
|
152
|
+
operationId: "knowledge_search_entities";
|
|
153
|
+
} | {
|
|
154
|
+
input: {
|
|
155
|
+
entitySchemaId: string;
|
|
156
|
+
fields: string[];
|
|
157
|
+
filters?: QueryFilter[];
|
|
158
|
+
text?: string;
|
|
159
|
+
};
|
|
160
|
+
operationId: "knowledge_facets";
|
|
161
|
+
} | {
|
|
162
|
+
input: {
|
|
163
|
+
entitySchemaId: string;
|
|
164
|
+
};
|
|
165
|
+
operationId: "knowledge_get_schema_query_context";
|
|
166
|
+
} | {
|
|
167
|
+
input: SearchQuery;
|
|
168
|
+
operationId: "knowledge_autocomplete";
|
|
169
|
+
} | {
|
|
170
|
+
input: {
|
|
171
|
+
entityId: string;
|
|
172
|
+
};
|
|
173
|
+
operationId: "knowledge_get_entity";
|
|
174
|
+
} | {
|
|
175
|
+
input: {
|
|
176
|
+
entity: {
|
|
177
|
+
data: JsonObject;
|
|
178
|
+
description?: string;
|
|
179
|
+
entitySchemaId: string;
|
|
180
|
+
name: string;
|
|
181
|
+
};
|
|
182
|
+
idempotencyKey: string;
|
|
183
|
+
};
|
|
184
|
+
operationId: "knowledge_create_entity";
|
|
185
|
+
} | {
|
|
186
|
+
input: {
|
|
187
|
+
entity: {
|
|
188
|
+
data?: JsonObject;
|
|
189
|
+
description?: string;
|
|
190
|
+
name?: string;
|
|
191
|
+
};
|
|
192
|
+
entityId: string;
|
|
193
|
+
expectedVersion: number;
|
|
194
|
+
idempotencyKey: string;
|
|
195
|
+
};
|
|
196
|
+
operationId: "knowledge_update_entity";
|
|
197
|
+
} | {
|
|
198
|
+
input: {
|
|
199
|
+
entity: {
|
|
200
|
+
data: JsonObject;
|
|
201
|
+
description?: string;
|
|
202
|
+
entitySchemaId: string;
|
|
203
|
+
name: string;
|
|
204
|
+
};
|
|
205
|
+
entitySchemaId: string;
|
|
206
|
+
externalIdentity: {
|
|
207
|
+
source: string;
|
|
208
|
+
value: string;
|
|
209
|
+
};
|
|
210
|
+
idempotencyKey: string;
|
|
211
|
+
};
|
|
212
|
+
operationId: "knowledge_upsert_entity";
|
|
213
|
+
} | {
|
|
214
|
+
input: {
|
|
215
|
+
entityId: string;
|
|
216
|
+
expectedVersion: number;
|
|
217
|
+
idempotencyKey: string;
|
|
218
|
+
};
|
|
219
|
+
operationId: "knowledge_delete_entity";
|
|
220
|
+
} | {
|
|
221
|
+
input: {
|
|
222
|
+
anchorEntityId: string;
|
|
223
|
+
direction?: "incoming" | "outgoing" | "both";
|
|
224
|
+
limit?: number;
|
|
225
|
+
maxDepth?: number;
|
|
226
|
+
relationSchemaId?: string;
|
|
227
|
+
};
|
|
228
|
+
operationId: "knowledge_traverse";
|
|
229
|
+
} | {
|
|
230
|
+
input: {
|
|
231
|
+
idempotencyKey: string;
|
|
232
|
+
relation: {
|
|
233
|
+
data?: JsonObject;
|
|
234
|
+
relationSchemaId: string;
|
|
235
|
+
sourceId: string;
|
|
236
|
+
targetId: string;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
operationId: "knowledge_create_relation";
|
|
240
|
+
} | {
|
|
241
|
+
input: {
|
|
242
|
+
expectedVersion: number;
|
|
243
|
+
idempotencyKey: string;
|
|
244
|
+
relation: {
|
|
245
|
+
data?: JsonObject;
|
|
246
|
+
};
|
|
247
|
+
relationId: string;
|
|
248
|
+
};
|
|
249
|
+
operationId: "knowledge_update_relation";
|
|
250
|
+
} | {
|
|
251
|
+
input: {
|
|
252
|
+
expectedVersion: number;
|
|
253
|
+
idempotencyKey: string;
|
|
254
|
+
relationId: string;
|
|
255
|
+
};
|
|
256
|
+
operationId: "knowledge_delete_relation";
|
|
257
|
+
} | {
|
|
258
|
+
input: {
|
|
259
|
+
filter?: JsonObject;
|
|
260
|
+
};
|
|
261
|
+
operationId: "agents_list";
|
|
262
|
+
} | {
|
|
263
|
+
input: {
|
|
264
|
+
idempotencyKey: string;
|
|
265
|
+
input: unknown;
|
|
266
|
+
} & AgentInvokeTarget;
|
|
267
|
+
operationId: "agents_invoke";
|
|
268
|
+
} | {
|
|
269
|
+
input: {
|
|
270
|
+
filter?: JsonObject;
|
|
271
|
+
};
|
|
272
|
+
operationId: "skills_list";
|
|
273
|
+
} | {
|
|
274
|
+
input: {
|
|
275
|
+
idempotencyKey: string;
|
|
276
|
+
input: unknown;
|
|
277
|
+
skillId: string;
|
|
278
|
+
};
|
|
279
|
+
operationId: "skills_invoke";
|
|
280
|
+
} | {
|
|
281
|
+
input: {
|
|
282
|
+
filter?: JsonObject;
|
|
283
|
+
};
|
|
284
|
+
operationId: "workflows_list";
|
|
285
|
+
} | {
|
|
286
|
+
input: {
|
|
287
|
+
idempotencyKey: string;
|
|
288
|
+
input: unknown;
|
|
289
|
+
} & WorkflowInvokeTarget;
|
|
290
|
+
operationId: "workflows_invoke";
|
|
291
|
+
} | {
|
|
292
|
+
input: {
|
|
293
|
+
runId: string;
|
|
294
|
+
};
|
|
295
|
+
operationId: "runs_get";
|
|
296
|
+
} | {
|
|
297
|
+
input: {
|
|
298
|
+
afterCursor?: string;
|
|
299
|
+
runId: string;
|
|
300
|
+
};
|
|
301
|
+
operationId: "runs_stream";
|
|
302
|
+
} | {
|
|
303
|
+
input: {
|
|
304
|
+
runId: string;
|
|
305
|
+
};
|
|
306
|
+
operationId: "runs_cancel";
|
|
307
|
+
} | {
|
|
308
|
+
input: {
|
|
309
|
+
contentBase64: string;
|
|
310
|
+
contentType: string;
|
|
311
|
+
fileName: string;
|
|
312
|
+
runId: string;
|
|
313
|
+
sizeBytes: number;
|
|
314
|
+
};
|
|
315
|
+
operationId: "attachments_upload";
|
|
316
|
+
} | {
|
|
317
|
+
input: {
|
|
318
|
+
attachmentId: string;
|
|
319
|
+
runId: string;
|
|
320
|
+
};
|
|
321
|
+
operationId: "attachments_download_url";
|
|
322
|
+
} | {
|
|
323
|
+
input: {
|
|
324
|
+
idempotencyKey: string;
|
|
325
|
+
input: unknown;
|
|
326
|
+
} & ConversationContinueTarget;
|
|
327
|
+
operationId: "conversations_continue";
|
|
328
|
+
} | {
|
|
329
|
+
input: {
|
|
330
|
+
conversationId: string;
|
|
331
|
+
};
|
|
332
|
+
operationId: "conversations_history";
|
|
333
|
+
};
|
|
334
|
+
interface EnvelopeSuccess<Id extends string, Result> {
|
|
335
|
+
correlationId: string;
|
|
336
|
+
operationId: Id;
|
|
337
|
+
result: Result;
|
|
338
|
+
}
|
|
339
|
+
type ExternalApplicationOperationSuccess = 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
|
+
runId: string;
|
|
341
|
+
}> | EnvelopeSuccess<"skills_list", JsonObject> | EnvelopeSuccess<"skills_invoke", {
|
|
342
|
+
runId: string;
|
|
343
|
+
}> | EnvelopeSuccess<"workflows_list", JsonObject> | EnvelopeSuccess<"workflows_invoke", {
|
|
344
|
+
runId: string;
|
|
345
|
+
}> | EnvelopeSuccess<"runs_get", JsonObject> | EnvelopeSuccess<"runs_stream", {
|
|
346
|
+
events: JsonObject[];
|
|
347
|
+
nextCursor: string | null;
|
|
348
|
+
}> | EnvelopeSuccess<"runs_cancel", JsonObject> | EnvelopeSuccess<"attachments_upload", {
|
|
349
|
+
attachmentId: string;
|
|
350
|
+
}> | EnvelopeSuccess<"attachments_download_url", {
|
|
351
|
+
expiresAt: string;
|
|
352
|
+
url: string;
|
|
353
|
+
}> | EnvelopeSuccess<"conversations_continue", {
|
|
354
|
+
conversationId: string;
|
|
355
|
+
runId: string;
|
|
356
|
+
}> | EnvelopeSuccess<"conversations_history", ConversationHistory>;
|
|
357
|
+
type ExternalApplicationOperationId = ExternalApplicationOperationRequest["operationId"];
|
|
358
|
+
type ExternalApplicationOperationRequestFor<Id extends ExternalApplicationOperationId> = Extract<ExternalApplicationOperationRequest, {
|
|
359
|
+
operationId: Id;
|
|
360
|
+
}>;
|
|
361
|
+
type ExternalApplicationOperationSuccessFor<Id extends ExternalApplicationOperationId> = Extract<ExternalApplicationOperationSuccess, {
|
|
362
|
+
operationId: Id;
|
|
363
|
+
}>;
|
|
364
|
+
/** Generated, curated external-application operation authority. */
|
|
365
|
+
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"];
|
|
366
|
+
type ClientOperationId = ExternalApplicationOperationId;
|
|
367
|
+
declare const isClientOperationId: (value: string) => value is ClientOperationId;
|
|
368
|
+
interface ClientOperationDefinition<Input, Output> {
|
|
369
|
+
readonly input: Input;
|
|
370
|
+
readonly output: Output;
|
|
371
|
+
}
|
|
372
|
+
type ClientOperationMap = Readonly<{ [Id in ClientOperationId]: ClientOperationDefinition<ExternalApplicationOperationRequestFor<Id>["input"], ExternalApplicationOperationSuccessFor<Id>["result"]>; }>;
|
|
373
|
+
type ClientOperationInput<Operations extends ClientOperationMap, Id extends ClientOperationId> = Operations[Id]["input"];
|
|
374
|
+
type ClientOperationOutput<Operations extends ClientOperationMap, Id extends ClientOperationId> = Operations[Id]["output"];
|
|
375
|
+
type OperationExecutionOptions = Readonly<{
|
|
376
|
+
organizationId: string;
|
|
377
|
+
signal?: AbortSignal;
|
|
378
|
+
}>;
|
|
379
|
+
interface TypedOperationExecutor<Operations extends ClientOperationMap> {
|
|
380
|
+
readonly execute: <Id extends ClientOperationId>(operationId: Id, input: ClientOperationInput<Operations, Id>, options?: OperationExecutionOptions) => Promise<CiResult<ClientOperationOutput<Operations, Id>>>;
|
|
381
|
+
}
|
|
382
|
+
type JsonValue = null | boolean | number | string | readonly JsonValue[] | Readonly<{
|
|
383
|
+
[key: string]: JsonValue;
|
|
384
|
+
}>;
|
|
385
|
+
type CiErrorCode = "unauthenticated" | "forbidden" | "not_found" | "conflict" | "invalid_request" | "rate_limited" | "unavailable" | "internal";
|
|
386
|
+
type CiError = Readonly<{
|
|
387
|
+
code: CiErrorCode;
|
|
388
|
+
message: string;
|
|
389
|
+
retryable: boolean;
|
|
390
|
+
details?: Readonly<Record<string, JsonValue>>;
|
|
391
|
+
}>;
|
|
392
|
+
type CiResult<Value> = Readonly<{
|
|
393
|
+
correlationId: string;
|
|
394
|
+
ok: true;
|
|
395
|
+
value: Value;
|
|
396
|
+
}> | Readonly<{
|
|
397
|
+
correlationId: string;
|
|
398
|
+
error: CiError;
|
|
399
|
+
ok: false;
|
|
400
|
+
}>;
|
|
401
|
+
type OperationRequest<Id extends ClientOperationId> = ExternalApplicationOperationRequestFor<Id>;
|
|
402
|
+
type OperationSuccess<Id extends ClientOperationId> = ExternalApplicationOperationSuccessFor<Id>;
|
|
403
|
+
type ProxyAuthentication = Readonly<{
|
|
404
|
+
auth: Readonly<{
|
|
405
|
+
getAccessToken: () => Promise<string> | string;
|
|
406
|
+
}>;
|
|
407
|
+
mode: "federated";
|
|
408
|
+
}> | Readonly<{
|
|
409
|
+
credentials?: RequestCredentials;
|
|
410
|
+
mode: "server_delegated";
|
|
411
|
+
}>;
|
|
412
|
+
type ProxyTransportOptions = Readonly<{
|
|
413
|
+
authentication: ProxyAuthentication;
|
|
414
|
+
fetch?: ClientFetch;
|
|
415
|
+
path: string;
|
|
416
|
+
serverUrl: string;
|
|
417
|
+
}>;
|
|
418
|
+
declare const createProxyTransport: <Operations extends ClientOperationMap>(options: ProxyTransportOptions) => TypedOperationExecutor<Operations>;
|
|
419
|
+
type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
|
|
420
|
+
[key: string]: ResourceJsonValue;
|
|
421
|
+
}>;
|
|
422
|
+
/** Opaque wire identity. Callers must not infer or concatenate its internals. */
|
|
423
|
+
type ResourceId = string;
|
|
424
|
+
type ResourceRecordId = ResourceId;
|
|
425
|
+
/** Opaque concurrency token independent from source timestamps. */
|
|
426
|
+
type ResourceRevision = string;
|
|
427
|
+
/** Opaque pagination position issued and consumed only by a resource adapter. */
|
|
428
|
+
type ResourceCursor = string;
|
|
429
|
+
type IdempotencyKey = string;
|
|
430
|
+
type ResourceIdentityField = Readonly<{
|
|
431
|
+
name: string;
|
|
432
|
+
type: "number" | "string";
|
|
433
|
+
}>;
|
|
434
|
+
type ResourceCapabilities = Readonly<{
|
|
435
|
+
create?: boolean;
|
|
436
|
+
/** Common entity deletion is always soft deletion. */
|
|
437
|
+
delete?: boolean;
|
|
438
|
+
get?: boolean;
|
|
439
|
+
hardDelete?: boolean;
|
|
440
|
+
includeDeleted?: boolean;
|
|
441
|
+
restore?: boolean;
|
|
442
|
+
search: true;
|
|
443
|
+
softDelete?: boolean;
|
|
444
|
+
update?: boolean;
|
|
445
|
+
}>;
|
|
446
|
+
type ResourcePaginationMode = "cursor" | "page";
|
|
447
|
+
type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
|
|
448
|
+
type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>> = Readonly<{
|
|
449
|
+
capabilities: ResourceCapabilities;
|
|
450
|
+
concurrency: "revision";
|
|
451
|
+
id: string;
|
|
452
|
+
identity: Readonly<{
|
|
453
|
+
fields: readonly [ResourceIdentityField, ...ResourceIdentityField[]];
|
|
454
|
+
}>;
|
|
455
|
+
query: Readonly<{
|
|
456
|
+
filterableFields: readonly string[];
|
|
457
|
+
pagination: Readonly<{
|
|
458
|
+
modes: readonly ResourcePaginationMode[];
|
|
459
|
+
}>;
|
|
460
|
+
sortableFields: readonly string[];
|
|
461
|
+
textSearchFields?: readonly string[];
|
|
462
|
+
}>;
|
|
463
|
+
schemas: Readonly<{
|
|
464
|
+
create?: PortableResourceSchema;
|
|
465
|
+
entity: PortableResourceSchema;
|
|
466
|
+
update?: PortableResourceSchema;
|
|
467
|
+
}>;
|
|
468
|
+
version: string;
|
|
469
|
+
/** Portable UI metadata; required/enum/nullability remain in schemas. */
|
|
470
|
+
metadata?: Readonly<Record<string, ResourceJsonValue>>;
|
|
471
|
+
/** Type-only slots keep definition values portable and serializable. */
|
|
472
|
+
readonly __types?: Readonly<{
|
|
473
|
+
create: Create;
|
|
474
|
+
entity: Entity;
|
|
475
|
+
update: Update;
|
|
476
|
+
}>;
|
|
477
|
+
}>;
|
|
478
|
+
type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
|
|
479
|
+
type ResourceFilter = Readonly<{
|
|
480
|
+
field: string;
|
|
481
|
+
operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
|
|
482
|
+
value: FilterValue;
|
|
483
|
+
}> | Readonly<{
|
|
484
|
+
field: string;
|
|
485
|
+
operator: "is_not_null" | "is_null";
|
|
486
|
+
}> | Readonly<{
|
|
487
|
+
filters: readonly ResourceFilter[];
|
|
488
|
+
operator: "and" | "or";
|
|
489
|
+
}> | Readonly<{
|
|
490
|
+
filter: ResourceFilter;
|
|
491
|
+
operator: "not";
|
|
492
|
+
}>;
|
|
493
|
+
type ResourceSort = Readonly<{
|
|
494
|
+
direction: "asc" | "desc";
|
|
495
|
+
field: string;
|
|
496
|
+
}>;
|
|
497
|
+
type ResourcePagination = Readonly<{
|
|
498
|
+
mode: "cursor";
|
|
499
|
+
cursor?: ResourceCursor;
|
|
500
|
+
limit: number;
|
|
501
|
+
}> | Readonly<{
|
|
502
|
+
mode: "page";
|
|
503
|
+
page: number;
|
|
504
|
+
pageSize: number;
|
|
505
|
+
}>;
|
|
506
|
+
type ResourceListQuery = Readonly<{
|
|
507
|
+
filter?: ResourceFilter;
|
|
508
|
+
includeDeleted?: boolean;
|
|
509
|
+
pagination: ResourcePagination;
|
|
510
|
+
sort?: readonly ResourceSort[];
|
|
511
|
+
textSearch?: string;
|
|
512
|
+
}>;
|
|
513
|
+
type ResourceRecord<Entity> = Readonly<{
|
|
514
|
+
deletedAt?: string;
|
|
515
|
+
id: ResourceRecordId;
|
|
516
|
+
revision: ResourceRevision;
|
|
517
|
+
value: Entity;
|
|
518
|
+
}>;
|
|
519
|
+
type ResourceListResult<Entity> = Readonly<{
|
|
520
|
+
items: readonly ResourceRecord<Entity>[];
|
|
521
|
+
nextCursor?: ResourceCursor;
|
|
522
|
+
pagination: "cursor";
|
|
523
|
+
}> | Readonly<{
|
|
524
|
+
items: readonly ResourceRecord<Entity>[];
|
|
525
|
+
page: number;
|
|
526
|
+
pageSize: number;
|
|
527
|
+
pagination: "page";
|
|
528
|
+
totalItems: number;
|
|
529
|
+
totalPages: number;
|
|
530
|
+
}>;
|
|
531
|
+
type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
|
|
532
|
+
type ResourceError = Readonly<{
|
|
533
|
+
code: ResourceErrorCode;
|
|
534
|
+
/** Client-observed dispatch outcome; uncertainty never proves rollback. */
|
|
535
|
+
outcome?: "not_dispatched" | "rejected" | "uncertain";
|
|
536
|
+
details?: Readonly<Record<string, ResourceJsonValue>>;
|
|
537
|
+
message: string;
|
|
538
|
+
retryable: boolean;
|
|
539
|
+
}>;
|
|
540
|
+
type ResourceResult<Value> = Readonly<{
|
|
541
|
+
correlationId: string;
|
|
542
|
+
ok: true;
|
|
543
|
+
value: Value;
|
|
544
|
+
}> | Readonly<{
|
|
545
|
+
correlationId: string;
|
|
546
|
+
error: ResourceError;
|
|
547
|
+
ok: false;
|
|
548
|
+
}>;
|
|
549
|
+
type ResourceRequestOptions = Readonly<{
|
|
550
|
+
signal?: AbortSignal;
|
|
551
|
+
}>;
|
|
552
|
+
type ResourceListRequest = Readonly<{
|
|
553
|
+
operation: "list";
|
|
554
|
+
query: ResourceListQuery;
|
|
555
|
+
requestId: string;
|
|
556
|
+
resourceId: string;
|
|
557
|
+
}>;
|
|
558
|
+
type ResourceGetRequest = Readonly<{
|
|
559
|
+
id: ResourceRecordId;
|
|
560
|
+
includeDeleted?: boolean;
|
|
561
|
+
operation: "get";
|
|
562
|
+
requestId: string;
|
|
563
|
+
resourceId: string;
|
|
564
|
+
}>;
|
|
565
|
+
type ResourceCreateRequest<Create> = Readonly<{
|
|
566
|
+
idempotencyKey: IdempotencyKey;
|
|
567
|
+
operation: "create";
|
|
568
|
+
requestId: string;
|
|
569
|
+
resourceId: string;
|
|
570
|
+
value: Create;
|
|
571
|
+
}>;
|
|
572
|
+
type ResourceUpdateRequest<Update> = Readonly<{
|
|
573
|
+
expectedRevision: ResourceRevision;
|
|
574
|
+
id: ResourceRecordId;
|
|
575
|
+
idempotencyKey?: IdempotencyKey;
|
|
576
|
+
operation: "update";
|
|
577
|
+
requestId: string;
|
|
578
|
+
resourceId: string;
|
|
579
|
+
value: Update;
|
|
580
|
+
}>;
|
|
581
|
+
type ResourceLifecycleRequest = Readonly<{
|
|
582
|
+
expectedRevision: ResourceRevision;
|
|
583
|
+
id: ResourceRecordId;
|
|
584
|
+
idempotencyKey?: IdempotencyKey;
|
|
585
|
+
operation: "hard_delete" | "restore" | "soft_delete";
|
|
586
|
+
requestId: string;
|
|
587
|
+
resourceId: string;
|
|
588
|
+
}>;
|
|
589
|
+
type ResourceTransportRequest = ResourceCreateRequest<unknown> | ResourceGetRequest | ResourceLifecycleRequest | ResourceListRequest | ResourceUpdateRequest<unknown>;
|
|
590
|
+
interface ResourceTransport {
|
|
591
|
+
readonly execute: (request: ResourceTransportRequest, options?: ResourceRequestOptions) => Promise<ResourceResult<unknown>>;
|
|
592
|
+
}
|
|
593
|
+
type ResourceMutationInput<Value> = Readonly<{
|
|
594
|
+
expectedRevision: ResourceRevision;
|
|
595
|
+
id: ResourceRecordId;
|
|
596
|
+
idempotencyKey?: IdempotencyKey;
|
|
597
|
+
value: Value;
|
|
598
|
+
}>;
|
|
599
|
+
type ResourceLifecycleInput = Readonly<{
|
|
600
|
+
expectedRevision: ResourceRevision;
|
|
601
|
+
id: ResourceRecordId;
|
|
602
|
+
idempotencyKey?: IdempotencyKey;
|
|
603
|
+
}>;
|
|
604
|
+
type ResourceCreateInput<Value> = Readonly<{
|
|
605
|
+
idempotencyKey: IdempotencyKey;
|
|
606
|
+
value: Value;
|
|
607
|
+
}>;
|
|
608
|
+
interface ResourceClient<Entity, Create = Entity, Update = Partial<Entity>> {
|
|
609
|
+
readonly capabilities: ResourceCapabilities;
|
|
610
|
+
readonly create: (input: ResourceCreateInput<Create>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
611
|
+
readonly definition: ResourceDefinition<Entity, Create, Update>;
|
|
612
|
+
readonly get: (input: Readonly<{
|
|
613
|
+
id: ResourceRecordId;
|
|
614
|
+
includeDeleted?: boolean;
|
|
615
|
+
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
616
|
+
readonly hardDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<void>>;
|
|
617
|
+
readonly list: (query: ResourceListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceListResult<Entity>>>;
|
|
618
|
+
readonly restore: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
619
|
+
readonly softDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
620
|
+
readonly update: (input: ResourceMutationInput<Update>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
621
|
+
}
|
|
622
|
+
/** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
|
|
623
|
+
type EntityOperation = "list" | "get" | "create" | "update" | "delete";
|
|
624
|
+
type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
|
|
625
|
+
pagination: Extract<ResourcePagination, {
|
|
626
|
+
mode: "page";
|
|
627
|
+
}>;
|
|
628
|
+
}>;
|
|
629
|
+
type EntityPage<Value> = Extract<ResourceListResult<Value>, {
|
|
630
|
+
pagination: "page";
|
|
631
|
+
}>;
|
|
632
|
+
type EntityCreateInput<Value> = ResourceCreateInput<Value>;
|
|
633
|
+
type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
|
|
634
|
+
idempotencyKey: IdempotencyKey;
|
|
635
|
+
}>;
|
|
636
|
+
type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
|
|
637
|
+
idempotencyKey: IdempotencyKey;
|
|
638
|
+
}>;
|
|
639
|
+
type EntityRequestIdentity = Readonly<{
|
|
640
|
+
requestId: string;
|
|
641
|
+
resourceId: string;
|
|
642
|
+
}>;
|
|
643
|
+
type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity & (Readonly<{
|
|
644
|
+
operation: "list";
|
|
645
|
+
query: EntityListQuery;
|
|
646
|
+
}> | Readonly<{
|
|
647
|
+
operation: "get";
|
|
648
|
+
id: ResourceRecordId;
|
|
649
|
+
}> | (Readonly<{
|
|
650
|
+
operation: "create";
|
|
651
|
+
}> & EntityCreateInput<Create>) | (Readonly<{
|
|
652
|
+
operation: "update";
|
|
653
|
+
}> & EntityUpdateInput<Patch>) | (Readonly<{
|
|
654
|
+
operation: "delete";
|
|
655
|
+
}> & EntityDeleteInput));
|
|
656
|
+
type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : ResourceRecord<Value>;
|
|
657
|
+
/** Codecs return safe typed failures without coercing values or performing I/O. */
|
|
658
|
+
type EntityProtocol<Value, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
659
|
+
decodeRequest: (input: unknown) => ResourceResult<EntityRequest<Create, Patch>>;
|
|
660
|
+
decodeResult: <Operation extends EntityOperation>(operation: Operation, input: unknown, correlationId: string) => ResourceResult<EntityOperationResult<Value, Operation>>;
|
|
661
|
+
}>;
|
|
662
|
+
interface EntityTransport {
|
|
663
|
+
readonly execute: (request: EntityRequest, options?: ResourceRequestOptions) => Promise<ResourceResult<unknown>>;
|
|
664
|
+
}
|
|
665
|
+
/** A logical write retains its key, payload and edited revision on explicit resubmission. */
|
|
666
|
+
interface EntityClient<Value, Create = Value, Patch = Partial<Value>> {
|
|
667
|
+
readonly definition: ResourceDefinition<Value, Create, Patch>;
|
|
668
|
+
readonly list: (query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<Value>>>;
|
|
669
|
+
readonly get: (input: Readonly<{
|
|
670
|
+
id: ResourceRecordId;
|
|
671
|
+
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
672
|
+
readonly create: (input: EntityCreateInput<Create>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
673
|
+
readonly update: (input: EntityUpdateInput<Patch>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
674
|
+
readonly delete: (input: EntityDeleteInput) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
675
|
+
}
|
|
676
|
+
type ClientOptions<Value, Create, Patch> = Readonly<{
|
|
677
|
+
definition: ResourceDefinition<Value, Create, Patch>;
|
|
678
|
+
requestId?: () => string;
|
|
679
|
+
}>;
|
|
680
|
+
declare function createResourceClient<Value, Create = Value, Patch = Partial<Value>>(options: ClientOptions<Value, Create, Patch> & Readonly<{
|
|
681
|
+
protocol: "entity";
|
|
682
|
+
transport: EntityTransport;
|
|
683
|
+
}>): EntityClient<Value, Create, Patch>;
|
|
684
|
+
declare function createResourceClient<Value, Create = Value, Patch = Partial<Value>>(options: ClientOptions<Value, Create, Patch> & Readonly<{
|
|
685
|
+
transport: ResourceTransport;
|
|
686
|
+
}>): ResourceClient<Value, Create, Patch>;
|
|
687
|
+
/** Common entity wire codec; transport and persistence remain with their owners. */
|
|
688
|
+
declare const createEntityProtocol: <Value, Create = Value, Patch = Partial<Value>>(definition: ResourceDefinition<Value, Create, Patch>) => EntityProtocol<Value, Create, Patch>;
|
|
689
|
+
type EntityHttpDestination = Readonly<{
|
|
690
|
+
kind: "gateway";
|
|
691
|
+
endpoint: string;
|
|
692
|
+
}> | Readonly<{
|
|
693
|
+
kind: "ci";
|
|
694
|
+
tenantUrl: string;
|
|
695
|
+
schemaFqn: string;
|
|
696
|
+
organizationId: string;
|
|
697
|
+
}>;
|
|
698
|
+
type EntityHttpTransportOptions = Readonly<{
|
|
699
|
+
destination: EntityHttpDestination;
|
|
700
|
+
authentication: ProxyAuthentication;
|
|
701
|
+
fetch?: ClientFetch;
|
|
702
|
+
}>;
|
|
703
|
+
declare const createEntityHttpTransport: (options: EntityHttpTransportOptions) => EntityTransport;
|
|
704
|
+
export { CiErrorCode as $, ResourceIdentityField as A, ResourceRecord as B, ResourceCursor as C, FederatedAuthError as Ct, ResourceFilter as D, FederatedSessionIdentity as Dt, ResourceErrorCode as E, FederatedAuthState as Et, ResourceListRequest as F, ResourceSort as G, ResourceRequestOptions as H, ResourceListResult as I, ResourceUpdateRequest as J, ResourceTransport as K, ResourceMutationInput as L, ResourceLifecycleInput as M, ResourceLifecycleRequest as N, ResourceGetRequest as O, createFederatedAuth as Ot, ResourceListQuery as P, CiError as Q, ResourcePagination as R, ResourceCreateRequest as S, FederatedAuth as St, ResourceError as T, FederatedAuthOptions as Tt, ResourceResult as U, ResourceRecordId as V, ResourceRevision as W, ProxyTransportOptions as X, ProxyAuthentication as Y, createProxyTransport as Z, IdempotencyKey as _, KnowledgeQuery as _t, createResourceClient as a, ClientOperationId as at, ResourceClient as b, WorkflowInvokeTarget as bt, EntityDeleteInput as c, ClientOperationOutput as ct, EntityOperationResult as d, clientOperationIds as dt, CiResult as et, EntityPage as f, isClientOperationId as ft, EntityUpdateInput as g, JsonObject as gt, EntityTransport as h, ConversationHistory as ht, createEntityProtocol as i, ClientOperationDefinition as it, ResourceJsonValue as j, ResourceId as k, EntityListQuery as l, OperationExecutionOptions as lt, EntityRequest as m, ConversationContinueTarget as mt, EntityHttpTransportOptions as n, OperationRequest as nt, EntityClient as o, ClientOperationInput as ot, EntityProtocol as p, AgentInvokeTarget as pt, ResourceTransportRequest as q, createEntityHttpTransport as r, OperationSuccess as rt, EntityCreateInput as s, ClientOperationMap as st, EntityHttpDestination as t, JsonValue as tt, EntityOperation as u, TypedOperationExecutor as ut, PortableResourceSchema as v, QueryFilter as vt, ResourceDefinition as w, FederatedAuthErrorCode as wt, ResourceCreateInput as x, ClientFetch as xt, ResourceCapabilities as y, SearchQuery as yt, ResourcePaginationMode as z };
|