@collective-intelligence/external-apps-client-sdk 0.5.0 → 0.6.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/AGENTS.md +8 -3
- package/README.md +165 -10
- package/dist/chat.d.ts +65 -3
- package/dist/chat.js +224 -20
- package/dist/{index-BwHhPzAs.d.ts → client-NsqWRz1M.d.ts} +655 -61
- package/dist/effect.d.ts +5 -7
- package/dist/effect.js +4 -4
- package/dist/index.d.ts +3 -5
- package/dist/index.js +74 -12
- package/dist/{proxy-B4MA1pat.d.ts → resources-D_PdfDpJ.d.ts} +1034 -12
- package/dist/{resources-DCOTahAB.js → resources-Vd7ESXEA.js} +2 -2
- package/dist/resources.d.ts +2 -2
- package/dist/resources.js +2 -2
- package/dist/{service-w6n_gspU.js → service-B0QOswoK.js} +59 -5
- package/dist/{service-CM4fS7mV.js → service-DCSU2Gqc.js} +125 -12
- package/docs/chat.md +18 -0
- package/docs/effect.md +4 -0
- package/docs/errors.md +5 -0
- package/docs/guide/platform/entrypoints.md +9 -6
- package/package.json +4 -4
- package/dist/client-C-o7Az4B.d.ts +0 -424
- package/dist/resources-Du03G6Wo.d.ts +0 -582
- package/dist/{errors-B4-Jo4j3.js → errors-DRzZfurr.js} +1 -1
|
@@ -1,582 +0,0 @@
|
|
|
1
|
-
import { D as CiError, i as ClientFetch, k as CiTransportError, t as ProxyAuthentication } from "./proxy-B4MA1pat.js";
|
|
2
|
-
import * as Config from "effect/Config";
|
|
3
|
-
import * as Context from "effect/Context";
|
|
4
|
-
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as Layer from "effect/Layer";
|
|
6
|
-
import "effect/ManagedRuntime";
|
|
7
|
-
type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
|
|
8
|
-
[key: string]: ResourceJsonValue;
|
|
9
|
-
}>;
|
|
10
|
-
/** Opaque wire identity. Callers must not infer or concatenate its internals. */
|
|
11
|
-
type ResourceId = string;
|
|
12
|
-
type ResourceRecordId = ResourceId;
|
|
13
|
-
/** Opaque concurrency token independent from source timestamps. */
|
|
14
|
-
type ResourceRevision = string;
|
|
15
|
-
/** Opaque pagination position issued and consumed only by a resource adapter. */
|
|
16
|
-
type ResourceCursor = string;
|
|
17
|
-
type IdempotencyKey = string;
|
|
18
|
-
type ResourceIdentityField = Readonly<{
|
|
19
|
-
name: string;
|
|
20
|
-
type: "number" | "string";
|
|
21
|
-
}>;
|
|
22
|
-
type ResourceCapabilities = Readonly<{
|
|
23
|
-
/** All-or-nothing entity batches; each op also needs its own capability. */
|
|
24
|
-
batch?: boolean;
|
|
25
|
-
create?: boolean;
|
|
26
|
-
/** Common entity deletion is always soft deletion. */
|
|
27
|
-
delete?: boolean;
|
|
28
|
-
get?: boolean;
|
|
29
|
-
hardDelete?: boolean;
|
|
30
|
-
includeDeleted?: boolean;
|
|
31
|
-
restore?: boolean;
|
|
32
|
-
search: true;
|
|
33
|
-
softDelete?: boolean;
|
|
34
|
-
update?: boolean;
|
|
35
|
-
/** File uploads for the File fields of a common entity resource. */
|
|
36
|
-
upload?: boolean;
|
|
37
|
-
}>;
|
|
38
|
-
type ResourcePaginationMode = "cursor" | "page";
|
|
39
|
-
type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
|
|
40
|
-
type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>> = Readonly<{
|
|
41
|
-
capabilities: ResourceCapabilities;
|
|
42
|
-
concurrency: "revision";
|
|
43
|
-
id: string;
|
|
44
|
-
identity: Readonly<{
|
|
45
|
-
fields: readonly [ResourceIdentityField, ...ResourceIdentityField[]];
|
|
46
|
-
}>;
|
|
47
|
-
query: Readonly<{
|
|
48
|
-
filterableFields: readonly string[];
|
|
49
|
-
pagination: Readonly<{
|
|
50
|
-
modes: readonly ResourcePaginationMode[];
|
|
51
|
-
}>;
|
|
52
|
-
sortableFields: readonly string[];
|
|
53
|
-
textSearchFields?: readonly string[];
|
|
54
|
-
}>;
|
|
55
|
-
schemas: Readonly<{
|
|
56
|
-
create?: PortableResourceSchema;
|
|
57
|
-
entity: PortableResourceSchema;
|
|
58
|
-
update?: PortableResourceSchema;
|
|
59
|
-
}>;
|
|
60
|
-
version: string;
|
|
61
|
-
/** Portable UI metadata; required/enum/nullability remain in schemas. */
|
|
62
|
-
metadata?: Readonly<Record<string, ResourceJsonValue>>;
|
|
63
|
-
/** Type-only slots keep definition values portable and serializable. */
|
|
64
|
-
readonly __types?: Readonly<{
|
|
65
|
-
create: Create;
|
|
66
|
-
entity: Entity;
|
|
67
|
-
update: Update;
|
|
68
|
-
}>;
|
|
69
|
-
}>;
|
|
70
|
-
type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
|
|
71
|
-
/**
|
|
72
|
-
* A filter predicate. `field` names a declared filterable field, or a path
|
|
73
|
-
* through at most three fields that hold Entity References to a field of
|
|
74
|
-
* the last target, such as `company.industry` or
|
|
75
|
-
* `contacts.company.parent.industry`. On a field that holds Entity
|
|
76
|
-
* References, `is_empty` means no reference. User fields accept identity
|
|
77
|
-
* predicates for one ID and `contains_any`, `contains_all`, `contains_none`
|
|
78
|
-
* for multiple IDs, plus empty/not-empty aliases. CI validates operators
|
|
79
|
-
* against the actual field semantic; UUID shape alone does not declare User.
|
|
80
|
-
*/
|
|
81
|
-
type ResourceFilter = Readonly<{
|
|
82
|
-
field: string;
|
|
83
|
-
operator: "contains" | "contains_all" | "contains_any" | "contains_none" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
|
|
84
|
-
value: FilterValue;
|
|
85
|
-
}> | Readonly<{
|
|
86
|
-
field: string;
|
|
87
|
-
operator: "is_empty" | "is_not_empty" | "is_not_null" | "is_null";
|
|
88
|
-
}> | Readonly<{
|
|
89
|
-
filters: readonly ResourceFilter[];
|
|
90
|
-
operator: "and" | "or";
|
|
91
|
-
}> | Readonly<{
|
|
92
|
-
filter: ResourceFilter;
|
|
93
|
-
operator: "not";
|
|
94
|
-
}>;
|
|
95
|
-
type ResourceSort = Readonly<{
|
|
96
|
-
direction: "asc" | "desc";
|
|
97
|
-
field: string;
|
|
98
|
-
}>;
|
|
99
|
-
type ResourcePagination = Readonly<{
|
|
100
|
-
mode: "cursor";
|
|
101
|
-
cursor?: ResourceCursor;
|
|
102
|
-
limit: number;
|
|
103
|
-
}> | Readonly<{
|
|
104
|
-
mode: "page";
|
|
105
|
-
page: number;
|
|
106
|
-
pageSize: number;
|
|
107
|
-
}>;
|
|
108
|
-
type ResourceListQuery = Readonly<{
|
|
109
|
-
filter?: ResourceFilter;
|
|
110
|
-
/**
|
|
111
|
-
* Include Paths, such as `["company", "contacts.company"]`: relation
|
|
112
|
-
* fields whose records each item carries in `included`.
|
|
113
|
-
*/
|
|
114
|
-
include?: readonly string[];
|
|
115
|
-
includeDeleted?: boolean;
|
|
116
|
-
pagination: ResourcePagination;
|
|
117
|
-
sort?: readonly ResourceSort[];
|
|
118
|
-
textSearch?: string;
|
|
119
|
-
}>;
|
|
120
|
-
type ResourceRecord<Entity> = Readonly<{
|
|
121
|
-
deletedAt?: string;
|
|
122
|
-
id: ResourceRecordId;
|
|
123
|
-
/**
|
|
124
|
-
* The records of the read's Include Paths by relation field key: one
|
|
125
|
-
* record, or the records of a `many` field in reference order. Untyped:
|
|
126
|
-
* the target schemas are CI's.
|
|
127
|
-
*/
|
|
128
|
-
included?: Readonly<Record<string, ResourceJsonValue>>;
|
|
129
|
-
revision: ResourceRevision;
|
|
130
|
-
/** The keys whose included records were cut to the first 100. */
|
|
131
|
-
truncated?: readonly string[];
|
|
132
|
-
value: Entity;
|
|
133
|
-
}>;
|
|
134
|
-
type ResourceListResult<Entity> = Readonly<{
|
|
135
|
-
items: readonly ResourceRecord<Entity>[];
|
|
136
|
-
nextCursor?: ResourceCursor;
|
|
137
|
-
pagination: "cursor";
|
|
138
|
-
}> | Readonly<{
|
|
139
|
-
items: readonly ResourceRecord<Entity>[];
|
|
140
|
-
page: number;
|
|
141
|
-
pageSize: number;
|
|
142
|
-
pagination: "page";
|
|
143
|
-
totalItems: number;
|
|
144
|
-
totalPages: number;
|
|
145
|
-
}>;
|
|
146
|
-
type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
|
|
147
|
-
/** The CI Organization storage can not take a presigned File upload. */
|
|
148
|
-
"upload_not_supported";
|
|
149
|
-
/** Stable, content-free diagnostics for request-wide Knowledge read limits. */
|
|
150
|
-
type EntityReadLimitDetails = Readonly<{
|
|
151
|
-
reason: "read_limit_exceeded";
|
|
152
|
-
budget: "work" | "nodes" | "relation_ids" | "bytes";
|
|
153
|
-
}>;
|
|
154
|
-
type ResourceError = Readonly<{
|
|
155
|
-
code: ResourceErrorCode;
|
|
156
|
-
/** Client-observed dispatch outcome; uncertainty never proves rollback. */
|
|
157
|
-
outcome?: "not_dispatched" | "rejected" | "uncertain";
|
|
158
|
-
details?: Readonly<Record<string, ResourceJsonValue>>;
|
|
159
|
-
message: string;
|
|
160
|
-
retryable: boolean;
|
|
161
|
-
}>;
|
|
162
|
-
type ResourceResult<Value> = Readonly<{
|
|
163
|
-
correlationId: string;
|
|
164
|
-
ok: true;
|
|
165
|
-
value: Value;
|
|
166
|
-
}> | Readonly<{
|
|
167
|
-
correlationId: string;
|
|
168
|
-
error: ResourceError;
|
|
169
|
-
ok: false;
|
|
170
|
-
}>;
|
|
171
|
-
type ResourceRequestOptions = Readonly<{
|
|
172
|
-
signal?: AbortSignal;
|
|
173
|
-
}>;
|
|
174
|
-
type ResourceListRequest = Readonly<{
|
|
175
|
-
operation: "list";
|
|
176
|
-
query: ResourceListQuery;
|
|
177
|
-
requestId: string;
|
|
178
|
-
resourceId: string;
|
|
179
|
-
}>;
|
|
180
|
-
type ResourceGetRequest = Readonly<{
|
|
181
|
-
id: ResourceRecordId;
|
|
182
|
-
includeDeleted?: boolean;
|
|
183
|
-
operation: "get";
|
|
184
|
-
requestId: string;
|
|
185
|
-
resourceId: string;
|
|
186
|
-
}>;
|
|
187
|
-
type ResourceCreateRequest<Create> = Readonly<{
|
|
188
|
-
idempotencyKey: IdempotencyKey;
|
|
189
|
-
operation: "create";
|
|
190
|
-
requestId: string;
|
|
191
|
-
resourceId: string;
|
|
192
|
-
value: Create;
|
|
193
|
-
}>;
|
|
194
|
-
type ResourceUpdateRequest<Update> = Readonly<{
|
|
195
|
-
expectedRevision: ResourceRevision;
|
|
196
|
-
id: ResourceRecordId;
|
|
197
|
-
idempotencyKey?: IdempotencyKey;
|
|
198
|
-
operation: "update";
|
|
199
|
-
requestId: string;
|
|
200
|
-
resourceId: string;
|
|
201
|
-
value: Update;
|
|
202
|
-
}>;
|
|
203
|
-
type ResourceLifecycleRequest = Readonly<{
|
|
204
|
-
expectedRevision: ResourceRevision;
|
|
205
|
-
id: ResourceRecordId;
|
|
206
|
-
idempotencyKey?: IdempotencyKey;
|
|
207
|
-
operation: "hard_delete" | "restore" | "soft_delete";
|
|
208
|
-
requestId: string;
|
|
209
|
-
resourceId: string;
|
|
210
|
-
}>;
|
|
211
|
-
type ResourceTransportRequest = ResourceCreateRequest<unknown> | ResourceGetRequest | ResourceLifecycleRequest | ResourceListRequest | ResourceUpdateRequest<unknown>;
|
|
212
|
-
interface ResourceTransport {
|
|
213
|
-
readonly execute: (request: ResourceTransportRequest, options?: ResourceRequestOptions) => Promise<ResourceResult<unknown>>;
|
|
214
|
-
}
|
|
215
|
-
type ResourceMutationInput<Value> = Readonly<{
|
|
216
|
-
expectedRevision: ResourceRevision;
|
|
217
|
-
id: ResourceRecordId;
|
|
218
|
-
idempotencyKey?: IdempotencyKey;
|
|
219
|
-
value: Value;
|
|
220
|
-
}>;
|
|
221
|
-
type ResourceLifecycleInput = Readonly<{
|
|
222
|
-
expectedRevision: ResourceRevision;
|
|
223
|
-
id: ResourceRecordId;
|
|
224
|
-
idempotencyKey?: IdempotencyKey;
|
|
225
|
-
}>;
|
|
226
|
-
type ResourceCreateInput<Value> = Readonly<{
|
|
227
|
-
idempotencyKey: IdempotencyKey;
|
|
228
|
-
value: Value;
|
|
229
|
-
}>;
|
|
230
|
-
interface ResourceClient<Entity, Create = Entity, Update = Partial<Entity>> {
|
|
231
|
-
readonly capabilities: ResourceCapabilities;
|
|
232
|
-
readonly create: (input: ResourceCreateInput<Create>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
233
|
-
readonly definition: ResourceDefinition<Entity, Create, Update>;
|
|
234
|
-
readonly get: (input: Readonly<{
|
|
235
|
-
id: ResourceRecordId;
|
|
236
|
-
includeDeleted?: boolean;
|
|
237
|
-
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
238
|
-
readonly hardDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<void>>;
|
|
239
|
-
readonly list: (query: ResourceListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceListResult<Entity>>>;
|
|
240
|
-
readonly restore: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
241
|
-
readonly softDelete: (input: ResourceLifecycleInput, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
242
|
-
readonly update: (input: ResourceMutationInput<Update>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Entity>>>;
|
|
243
|
-
}
|
|
244
|
-
/** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
|
|
245
|
-
type EntityOperation = "list_members" | "list" | "get" | "create" | "update" | "delete" | "restore" | "upload" | "batch";
|
|
246
|
-
/**
|
|
247
|
-
* An entity search. It pages by the `nextCursor` of the previous page, or by
|
|
248
|
-
* number for a page-numbered view; CI refuses a page past its first 10,000
|
|
249
|
-
* records. `textSearch` searches all text of the record.
|
|
250
|
-
*/
|
|
251
|
-
type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
|
|
252
|
-
/** Count every match; else CI stops the total at 10,000. */
|
|
253
|
-
exactTotal?: boolean;
|
|
254
|
-
pagination: ResourcePagination;
|
|
255
|
-
}>;
|
|
256
|
-
/**
|
|
257
|
-
* A page of an entity search. `total` is the Capped Total: exact up to
|
|
258
|
-
* 10,000 records unless the search asks for `exactTotal`;
|
|
259
|
-
* `totalIsLowerBound` tells that more records match. `facetsPartial` tells
|
|
260
|
-
* that facets count only the first 100,000 candidates. `nextCursor` pages
|
|
261
|
-
* the same search; it is null on the last page.
|
|
262
|
-
*/
|
|
263
|
-
type EntityPage<Value> = Readonly<{
|
|
264
|
-
facetsPartial: boolean;
|
|
265
|
-
items: readonly ResourceRecord<Value>[];
|
|
266
|
-
nextCursor: ResourceCursor | null;
|
|
267
|
-
total: number;
|
|
268
|
-
totalIsLowerBound: boolean;
|
|
269
|
-
}> & (Readonly<{
|
|
270
|
-
pagination: "cursor";
|
|
271
|
-
}> | Readonly<{
|
|
272
|
-
pagination: "page";
|
|
273
|
-
page: number;
|
|
274
|
-
pageSize: number;
|
|
275
|
-
}>);
|
|
276
|
-
/** Member schemas are resolved by CI, independently of the parent resource. */
|
|
277
|
-
type EntityMemberValue = Readonly<Record<string, ResourceJsonValue>>;
|
|
278
|
-
type EntityCreateInput<Value> = ResourceCreateInput<Value>;
|
|
279
|
-
type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
|
|
280
|
-
idempotencyKey: IdempotencyKey;
|
|
281
|
-
}>;
|
|
282
|
-
type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
|
|
283
|
-
idempotencyKey: IdempotencyKey;
|
|
284
|
-
}>;
|
|
285
|
-
/** A restore of a soft-deleted record at the revision its delete gave. */
|
|
286
|
-
type EntityRestoreInput = EntityDeleteInput;
|
|
287
|
-
/** One op of an entity batch: the single write it stands for, without a key. */
|
|
288
|
-
type EntityBatchOp<Create = unknown, Patch = unknown> = Readonly<{
|
|
289
|
-
op: "create";
|
|
290
|
-
value: Create;
|
|
291
|
-
}> | Readonly<{
|
|
292
|
-
op: "update";
|
|
293
|
-
id: ResourceRecordId;
|
|
294
|
-
expectedRevision: ResourceRevision;
|
|
295
|
-
value: Patch;
|
|
296
|
-
}> | Readonly<{
|
|
297
|
-
op: "delete" | "restore";
|
|
298
|
-
id: ResourceRecordId;
|
|
299
|
-
expectedRevision: ResourceRevision;
|
|
300
|
-
}>;
|
|
301
|
-
/**
|
|
302
|
-
* 1 to 100 ops on the records of one resource, under one key. CI commits
|
|
303
|
-
* every op or none; the same key with the same ops replays the answer, and
|
|
304
|
-
* with other ops answers `conflict`.
|
|
305
|
-
*/
|
|
306
|
-
type EntityBatchInput<Create = unknown, Patch = unknown> = Readonly<{
|
|
307
|
-
idempotencyKey: IdempotencyKey;
|
|
308
|
-
ops: readonly EntityBatchOp<Create, Patch>[];
|
|
309
|
-
}>;
|
|
310
|
-
/** An op that CI refused; `id` is absent for a `create`. */
|
|
311
|
-
type EntityBatchRefusal = Readonly<{
|
|
312
|
-
index: number;
|
|
313
|
-
id?: ResourceRecordId;
|
|
314
|
-
reason: "conflict" | "forbidden" | "invalid_request" | "not_found";
|
|
315
|
-
}>;
|
|
316
|
-
/**
|
|
317
|
-
* The `details` of a refused batch, which CI wrote nothing for. The error
|
|
318
|
-
* `code` is the `reason` of the first refused op. `refused` holds the
|
|
319
|
-
* refused ops that CI found: CI checks the ops in stages and stops at the
|
|
320
|
-
* first stage that refuses an op, so an op that a later stage would refuse
|
|
321
|
-
* can be absent.
|
|
322
|
-
*/
|
|
323
|
-
type EntityBatchRefusedDetails = Readonly<{
|
|
324
|
-
reason: "batch_refused";
|
|
325
|
-
refused: readonly EntityBatchRefusal[];
|
|
326
|
-
}>;
|
|
327
|
-
/** A File upload request for one File field of the entity schema. */
|
|
328
|
-
type EntityUploadInput = Readonly<{
|
|
329
|
-
field: string;
|
|
330
|
-
filename: string;
|
|
331
|
-
mimeType: string;
|
|
332
|
-
/**
|
|
333
|
-
* The file size in bytes, a non-negative integer such as `File.size`. CI
|
|
334
|
-
* refuses a slot over the field's limit with `invalid_request` and
|
|
335
|
-
* `details.reason: "file_too_large"`; storage may refuse a PUT of another
|
|
336
|
-
* size.
|
|
337
|
-
*/
|
|
338
|
-
size: number;
|
|
339
|
-
}>;
|
|
340
|
-
/** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
|
|
341
|
-
type EntityUploadSlot = Readonly<{
|
|
342
|
-
headers: Readonly<Record<string, string>>;
|
|
343
|
-
method: "PUT";
|
|
344
|
-
uploadId: string;
|
|
345
|
-
url: string;
|
|
346
|
-
}>;
|
|
347
|
-
/** The read-time value of one file of a File field. */
|
|
348
|
-
type EntityFileValue = Readonly<{
|
|
349
|
-
id: string;
|
|
350
|
-
url: string;
|
|
351
|
-
filename: string;
|
|
352
|
-
mimeType: string | null;
|
|
353
|
-
size: number | null;
|
|
354
|
-
source: "managed" | "external_url";
|
|
355
|
-
}>;
|
|
356
|
-
/** `{ upload }` adds a File upload; `{ id }`, or a File value read before, keeps that file. */
|
|
357
|
-
type EntityFileWrite = Readonly<{
|
|
358
|
-
upload: string;
|
|
359
|
-
id?: never;
|
|
360
|
-
}> | Readonly<{
|
|
361
|
-
id: string;
|
|
362
|
-
upload?: never;
|
|
363
|
-
}>;
|
|
364
|
-
/**
|
|
365
|
-
* The write form of a File field key: one file or `null` for a single field,
|
|
366
|
-
* an ordered array for a multiple field, `null` removes every file. Omit the
|
|
367
|
-
* key to keep its files unchanged.
|
|
368
|
-
*/
|
|
369
|
-
type EntityFileFieldWrite = EntityFileWrite | readonly EntityFileWrite[] | null;
|
|
370
|
-
type EntityRequestIdentity = Readonly<{
|
|
371
|
-
requestId: string;
|
|
372
|
-
resourceId: string;
|
|
373
|
-
}>;
|
|
374
|
-
type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity & (Readonly<{
|
|
375
|
-
operation: "list";
|
|
376
|
-
query: EntityListQuery;
|
|
377
|
-
}> | Readonly<{
|
|
378
|
-
operation: "list_members";
|
|
379
|
-
parentId: ResourceRecordId;
|
|
380
|
-
field: string;
|
|
381
|
-
query: EntityListQuery;
|
|
382
|
-
}> | Readonly<{
|
|
383
|
-
operation: "get";
|
|
384
|
-
id: ResourceRecordId;
|
|
385
|
-
include?: readonly string[];
|
|
386
|
-
}> | (Readonly<{
|
|
387
|
-
operation: "create";
|
|
388
|
-
}> & EntityCreateInput<Create>) | (Readonly<{
|
|
389
|
-
operation: "update";
|
|
390
|
-
}> & EntityUpdateInput<Patch>) | (Readonly<{
|
|
391
|
-
operation: "delete";
|
|
392
|
-
}> & EntityDeleteInput) | (Readonly<{
|
|
393
|
-
operation: "restore";
|
|
394
|
-
}> & EntityRestoreInput) | (Readonly<{
|
|
395
|
-
operation: "upload";
|
|
396
|
-
}> & EntityUploadInput) | (Readonly<{
|
|
397
|
-
operation: "batch";
|
|
398
|
-
}> & EntityBatchInput<Create, Patch>));
|
|
399
|
-
type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list_members" ? EntityPage<EntityMemberValue> : Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : Operation extends "batch" ? readonly ResourceRecord<Value>[] : ResourceRecord<Value>;
|
|
400
|
-
/** Codecs return safe typed failures without coercing values or performing I/O. */
|
|
401
|
-
type EntityProtocol<Value, Create = Value, Patch = Partial<Value>> = Readonly<{
|
|
402
|
-
decodeRequest: (input: unknown) => ResourceResult<EntityRequest<Create, Patch>>;
|
|
403
|
-
decodeResult: <Operation extends EntityOperation>(operation: Operation, input: unknown, correlationId: string) => ResourceResult<EntityOperationResult<Value, Operation>>;
|
|
404
|
-
}>;
|
|
405
|
-
interface EntityTransport {
|
|
406
|
-
readonly execute: (request: EntityRequest, options?: ResourceRequestOptions) => Promise<ResourceResult<unknown>>;
|
|
407
|
-
}
|
|
408
|
-
/** A logical write retains its key, payload and edited revision on explicit resubmission. */
|
|
409
|
-
interface EntityClient<Value, Create = Value, Patch = Partial<Value>> {
|
|
410
|
-
/** Filter, sort and page the resolved member schema; includes remain bounded. */
|
|
411
|
-
readonly listMembers: (parentId: ResourceRecordId, field: string, query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<EntityMemberValue>>>;
|
|
412
|
-
readonly definition: ResourceDefinition<Value, Create, Patch>;
|
|
413
|
-
readonly list: (query: EntityListQuery, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityPage<Value>>>;
|
|
414
|
-
readonly get: (input: Readonly<{
|
|
415
|
-
id: ResourceRecordId;
|
|
416
|
-
include?: readonly string[];
|
|
417
|
-
}>, options?: ResourceRequestOptions) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
418
|
-
readonly create: (input: EntityCreateInput<Create>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
419
|
-
readonly update: (input: EntityUpdateInput<Patch>) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
420
|
-
readonly delete: (input: EntityDeleteInput) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
421
|
-
/**
|
|
422
|
-
* Makes a soft-deleted record live again; requires the `restore`
|
|
423
|
-
* capability. A stale revision answers `conflict`; a live record answers
|
|
424
|
-
* itself unchanged. A connector record whose delete also removed its
|
|
425
|
-
* remote ref answers `conflict` and stays deleted.
|
|
426
|
-
*/
|
|
427
|
-
readonly restore: (input: EntityRestoreInput) => Promise<ResourceResult<ResourceRecord<Value>>>;
|
|
428
|
-
/** A single-use File upload slot; requires the `upload` capability. */
|
|
429
|
-
readonly upload: (input: EntityUploadInput, options?: ResourceRequestOptions) => Promise<ResourceResult<EntityUploadSlot>>;
|
|
430
|
-
/**
|
|
431
|
-
* Commits every op or none, each by the rules of its single write;
|
|
432
|
-
* requires the `batch` capability and the capability of each op. The
|
|
433
|
-
* answer holds the record of each op in op order. A refused batch writes
|
|
434
|
-
* nothing and lists the refused ops that CI found in
|
|
435
|
-
* `EntityBatchRefusedDetails`. A second op on one record is `conflict`:
|
|
436
|
-
* the caller cannot know the revision that the first op gives.
|
|
437
|
-
*/
|
|
438
|
-
readonly batch: (input: EntityBatchInput<Create, Patch>) => Promise<ResourceResult<readonly ResourceRecord<Value>[]>>;
|
|
439
|
-
}
|
|
440
|
-
type ClientOptions<Value, Create, Patch> = Readonly<{
|
|
441
|
-
definition: ResourceDefinition<Value, Create, Patch>;
|
|
442
|
-
requestId?: () => string;
|
|
443
|
-
}>;
|
|
444
|
-
declare function createResourceClient<Value, Create = Value, Patch = Partial<Value>>(options: ClientOptions<Value, Create, Patch> & Readonly<{
|
|
445
|
-
protocol: "entity";
|
|
446
|
-
transport: EntityTransport;
|
|
447
|
-
}>): EntityClient<Value, Create, Patch> & Readonly<{
|
|
448
|
-
close: () => Promise<void>;
|
|
449
|
-
}>;
|
|
450
|
-
declare function createResourceClient<Value, Create = Value, Patch = Partial<Value>>(options: ClientOptions<Value, Create, Patch> & Readonly<{
|
|
451
|
-
transport: ResourceTransport;
|
|
452
|
-
}>): ResourceClient<Value, Create, Patch> & Readonly<{
|
|
453
|
-
close: () => Promise<void>;
|
|
454
|
-
}>;
|
|
455
|
-
/** Narrow a decoded resource failure to its documented request-wide read limit. */
|
|
456
|
-
declare const isEntityReadLimitError: (error: ResourceError) => error is ResourceError & Readonly<{
|
|
457
|
-
code: "invalid_request";
|
|
458
|
-
details: EntityReadLimitDetails;
|
|
459
|
-
}>;
|
|
460
|
-
/** Narrow a decoded resource failure to a refused batch and its refused ops. */
|
|
461
|
-
declare const isEntityBatchRefusedError: (error: ResourceError) => error is ResourceError & Readonly<{
|
|
462
|
-
details: EntityBatchRefusedDetails;
|
|
463
|
-
}>;
|
|
464
|
-
/** Common entity wire codec; transport and persistence remain with their owners. */
|
|
465
|
-
declare const createEntityProtocol: <Value, Create = Value, Patch = Partial<Value>>(definition: ResourceDefinition<Value, Create, Patch>) => EntityProtocol<Value, Create, Patch>;
|
|
466
|
-
/** One entity request as its envelope; only a transport failure fails. */
|
|
467
|
-
type EntityExecute = (request: EntityRequest, options: ResourceRequestOptions) => Effect.Effect<ResourceResult<unknown>, CiTransportError>;
|
|
468
|
-
type ResourceFailure = CiError | CiTransportError;
|
|
469
|
-
/** The entity client of one Resource Definition for `./effect`. */
|
|
470
|
-
type ResourceEntityClient<Value, Create, Patch> = Readonly<{
|
|
471
|
-
definition: ResourceDefinition<Value, Create, Patch>;
|
|
472
|
-
get: (input: Readonly<{
|
|
473
|
-
id: ResourceRecordId;
|
|
474
|
-
include?: readonly string[];
|
|
475
|
-
}>) => Effect.Effect<ResourceRecord<Value>, ResourceFailure>;
|
|
476
|
-
list: (query: EntityListQuery) => Effect.Effect<EntityPage<Value>, ResourceFailure>;
|
|
477
|
-
listMembers: (parentId: ResourceRecordId, field: string, query: EntityListQuery) => Effect.Effect<EntityPage<EntityMemberValue>, ResourceFailure>;
|
|
478
|
-
create: (input: EntityCreateInput<Create>) => Effect.Effect<ResourceRecord<Value>, ResourceFailure>;
|
|
479
|
-
update: (input: EntityUpdateInput<Patch>) => Effect.Effect<ResourceRecord<Value>, ResourceFailure>;
|
|
480
|
-
delete: (input: EntityDeleteInput) => Effect.Effect<ResourceRecord<Value>, ResourceFailure>;
|
|
481
|
-
restore: (input: EntityRestoreInput) => Effect.Effect<ResourceRecord<Value>, ResourceFailure>;
|
|
482
|
-
upload: (input: EntityUploadInput) => Effect.Effect<EntityUploadSlot, ResourceFailure>;
|
|
483
|
-
/** Every op or none; a refused batch fails with its refused ops in `details`. */
|
|
484
|
-
batch: (input: EntityBatchInput<Create, Patch>) => Effect.Effect<readonly ResourceRecord<Value>[], ResourceFailure>;
|
|
485
|
-
}>;
|
|
486
|
-
type ResourcesValue = Readonly<{
|
|
487
|
-
/** The entity client of `definition`; a bad destination dies with `TypeError`. */
|
|
488
|
-
bind: <Value, Create = Value, Patch = Partial<Value>>(definition: ResourceDefinition<Value, Create, Patch>) => ResourceEntityClient<Value, Create, Patch>;
|
|
489
|
-
}>;
|
|
490
|
-
declare const Resources_base: Context.ServiceClass<Resources, "@collective-intelligence/external-apps-client-sdk/Resources", Readonly<{
|
|
491
|
-
/** The entity client of `definition`; a bad destination dies with `TypeError`. */
|
|
492
|
-
bind: <Value, Create = Value, Patch = Partial<Value>>(definition: ResourceDefinition<Value, Create, Patch>) => ResourceEntityClient<Value, Create, Patch>;
|
|
493
|
-
}>>;
|
|
494
|
-
declare class Resources extends Resources_base {}
|
|
495
|
-
type ResourcesLayerOptions = Readonly<{
|
|
496
|
-
authentication: ProxyAuthentication;
|
|
497
|
-
/** The HTTP destination of each Resource Definition, by its id. */
|
|
498
|
-
destination: (resourceId: string) => EntityHttpDestination;
|
|
499
|
-
fetch?: ClientFetch;
|
|
500
|
-
requestId?: () => string;
|
|
501
|
-
}>;
|
|
502
|
-
/** `Resources` over the entity HTTP routes of `destination`. */
|
|
503
|
-
declare const layer: (options: ResourcesLayerOptions) => Layer.Layer<Resources, never, never>;
|
|
504
|
-
/** `layer` with options that Effect `Config` reads. */
|
|
505
|
-
declare const layerConfig: (config: Config.Wrap<ResourcesLayerOptions>) => Layer.Layer<Resources, Config.ConfigError, never>;
|
|
506
|
-
type ResourcesFromEntityTransportOptions = Readonly<{
|
|
507
|
-
requestId?: () => string;
|
|
508
|
-
transport: EntityTransport;
|
|
509
|
-
}>;
|
|
510
|
-
/**
|
|
511
|
-
* `Resources` over an `EntityTransport` of the app, as
|
|
512
|
-
* `createResourceClient` with `protocol: "entity"`. A rejection of the
|
|
513
|
-
* transport fails with `CiTransportError`.
|
|
514
|
-
*/
|
|
515
|
-
declare const layerFromEntityTransport: (options: ResourcesFromEntityTransportOptions) => Layer.Layer<Resources, never, never>;
|
|
516
|
-
/**
|
|
517
|
-
* The legacy resource client of one Resource Definition for `./effect`,
|
|
518
|
-
* with the lifecycle operations. It fails as a `Resources` client does.
|
|
519
|
-
*/
|
|
520
|
-
type LegacyResourceClient<Entity, Create, Update> = Readonly<{
|
|
521
|
-
create: (input: ResourceCreateInput<Create>) => Effect.Effect<ResourceRecord<Entity>, ResourceFailure>;
|
|
522
|
-
definition: ResourceDefinition<Entity, Create, Update>;
|
|
523
|
-
get: (input: Readonly<{
|
|
524
|
-
id: ResourceRecordId;
|
|
525
|
-
includeDeleted?: boolean;
|
|
526
|
-
}>) => Effect.Effect<ResourceRecord<Entity>, ResourceFailure>;
|
|
527
|
-
hardDelete: (input: ResourceLifecycleInput) => Effect.Effect<void, ResourceFailure>;
|
|
528
|
-
list: (query: ResourceListQuery) => Effect.Effect<ResourceListResult<Entity>, ResourceFailure>;
|
|
529
|
-
restore: (input: ResourceLifecycleInput) => Effect.Effect<ResourceRecord<Entity>, ResourceFailure>;
|
|
530
|
-
softDelete: (input: ResourceLifecycleInput) => Effect.Effect<ResourceRecord<Entity>, ResourceFailure>;
|
|
531
|
-
update: (input: ResourceMutationInput<Update>) => Effect.Effect<ResourceRecord<Entity>, ResourceFailure>;
|
|
532
|
-
}>;
|
|
533
|
-
type LegacyResourcesValue = Readonly<{
|
|
534
|
-
/** The legacy client of `definition` over the `ResourceTransport` of the layer. */
|
|
535
|
-
bind: <Entity, Create = Entity, Update = Partial<Entity>>(definition: ResourceDefinition<Entity, Create, Update>) => LegacyResourceClient<Entity, Create, Update>;
|
|
536
|
-
}>;
|
|
537
|
-
declare const LegacyResources_base: Context.ServiceClass<LegacyResources, "@collective-intelligence/external-apps-client-sdk/LegacyResources", Readonly<{
|
|
538
|
-
/** The legacy client of `definition` over the `ResourceTransport` of the layer. */
|
|
539
|
-
bind: <Entity, Create = Entity, Update = Partial<Entity>>(definition: ResourceDefinition<Entity, Create, Update>) => LegacyResourceClient<Entity, Create, Update>;
|
|
540
|
-
}>>;
|
|
541
|
-
/** The `./effect` form of `createResourceClient` over a `ResourceTransport`. */
|
|
542
|
-
declare class LegacyResources extends LegacyResources_base {}
|
|
543
|
-
type LegacyResourcesLayerOptions = Readonly<{
|
|
544
|
-
requestId?: () => string;
|
|
545
|
-
transport: ResourceTransport;
|
|
546
|
-
}>;
|
|
547
|
-
/** `LegacyResources` over the `ResourceTransport` of `options`. */
|
|
548
|
-
declare const layerLegacy: (options: LegacyResourcesLayerOptions) => Layer.Layer<LegacyResources, never, never>;
|
|
549
|
-
/** `layerLegacy` with options that Effect `Config` reads. */
|
|
550
|
-
declare const layerLegacyConfig: (config: Config.Wrap<LegacyResourcesLayerOptions>) => Layer.Layer<LegacyResources, Config.ConfigError, never>;
|
|
551
|
-
type EntityHttpDestination = Readonly<{
|
|
552
|
-
kind: "gateway";
|
|
553
|
-
endpoint: string;
|
|
554
|
-
}> | Readonly<{
|
|
555
|
-
kind: "ci";
|
|
556
|
-
tenantUrl: string;
|
|
557
|
-
schemaFqn: string;
|
|
558
|
-
organizationId: string;
|
|
559
|
-
}>;
|
|
560
|
-
type EntityHttpTransportOptions = Readonly<{
|
|
561
|
-
destination: EntityHttpDestination;
|
|
562
|
-
authentication: ProxyAuthentication;
|
|
563
|
-
fetch?: ClientFetch;
|
|
564
|
-
}>;
|
|
565
|
-
/**
|
|
566
|
-
* The entity HTTP adapter of one destination, the `./effect` form of
|
|
567
|
-
* `createEntityHttpTransport`: each request is an Effect that runs in the
|
|
568
|
-
* fiber of its caller. Early cancellation and a failed login stay envelopes,
|
|
569
|
-
* as the request was not sent; a request that does not reach the server, or
|
|
570
|
-
* an answer that cannot be read, fails with `CiTransportError`. A
|
|
571
|
-
* destination without its CI selectors, or an endpoint with credentials,
|
|
572
|
-
* query or fragment, throws `TypeError`.
|
|
573
|
-
*/
|
|
574
|
-
declare const makeEntityHttpExecute: (options: EntityHttpTransportOptions) => EntityExecute;
|
|
575
|
-
/**
|
|
576
|
-
* The Vanilla Facade of the entity HTTP adapter, in a runtime of its own;
|
|
577
|
-
* `close` disposes it.
|
|
578
|
-
*/
|
|
579
|
-
declare const createEntityHttpTransport: (options: EntityHttpTransportOptions) => EntityTransport & Readonly<{
|
|
580
|
-
close: () => Promise<void>;
|
|
581
|
-
}>;
|
|
582
|
-
export { ResourceDefinition as $, EntityFileFieldWrite as A, EntityRequest as B, EntityBatchInput as C, ResourceUpdateRequest as Ct, EntityClient as D, EntityBatchRefusedDetails as E, EntityOperation as F, EntityUploadSlot as G, EntityTransport as H, EntityOperationResult as I, ResourceCapabilities as J, IdempotencyKey as K, EntityPage as L, EntityFileWrite as M, EntityListQuery as N, EntityCreateInput as O, EntityMemberValue as P, ResourceCursor as Q, EntityProtocol as R, createResourceClient as S, ResourceTransportRequest as St, EntityBatchRefusal as T, EntityUpdateInput as U, EntityRestoreInput as V, EntityUploadInput as W, ResourceCreateInput as X, ResourceClient as Y, ResourceCreateRequest as Z, layerLegacy as _, ResourceRequestOptions as _t, LegacyResourceClient as a, ResourceIdentityField as at, isEntityBatchRefusedError as b, ResourceSort as bt, LegacyResourcesValue as c, ResourceLifecycleRequest as ct, ResourcesFromEntityTransportOptions as d, ResourceListResult as dt, ResourceError as et, ResourcesLayerOptions as f, ResourceMutationInput as ft, layerFromEntityTransport as g, ResourceRecordId as gt, layerConfig as h, ResourceRecord as ht, makeEntityHttpExecute as i, ResourceId as it, EntityFileValue as j, EntityDeleteInput as k, ResourceEntityClient as l, ResourceListQuery as lt, layer as m, ResourcePaginationMode as mt, EntityHttpTransportOptions as n, ResourceFilter as nt, LegacyResources as o, ResourceJsonValue as ot, ResourcesValue as p, ResourcePagination as pt, PortableResourceSchema as q, createEntityHttpTransport as r, ResourceGetRequest as rt, LegacyResourcesLayerOptions as s, ResourceLifecycleInput as st, EntityHttpDestination as t, ResourceErrorCode as tt, Resources as u, ResourceListRequest as ut, layerLegacyConfig as v, ResourceResult as vt, EntityBatchOp as w, isEntityReadLimitError as x, ResourceTransport as xt, createEntityProtocol as y, ResourceRevision as yt, EntityReadLimitDetails as z };
|