@collective-intelligence/external-apps-server-sdk 0.1.8 → 0.1.10

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.
@@ -387,6 +387,8 @@ export type ResourceCapabilities = Readonly<{
387
387
  search: true;
388
388
  softDelete?: boolean;
389
389
  update?: boolean;
390
+ /** File uploads for the File fields of a common entity resource. */
391
+ upload?: boolean;
390
392
  }>;
391
393
  export type ResourcePaginationMode = "cursor" | "page";
392
394
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -424,13 +426,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
424
426
  }>;
425
427
  }>;
426
428
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
429
+ /**
430
+ * A filter predicate. `field` names a declared filterable field, or a path
431
+ * through at most three fields that hold Entity References to a field of
432
+ * the last target, such as `company.industry` or
433
+ * `contacts.company.parent.industry`. On a field that holds Entity
434
+ * References, `is_empty` means no reference, and `contains_any` and
435
+ * `contains_all` compare the ids of a field that holds many.
436
+ */
427
437
  export type ResourceFilter = Readonly<{
428
438
  field: string;
429
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
439
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
430
440
  value: FilterValue;
431
441
  }> | Readonly<{
432
442
  field: string;
433
- operator: "is_not_null" | "is_null";
443
+ operator: "is_empty" | "is_not_null" | "is_null";
434
444
  }> | Readonly<{
435
445
  filters: readonly ResourceFilter[];
436
446
  operator: "and" | "or";
@@ -453,12 +463,19 @@ export type ResourcePagination = Readonly<{
453
463
  }>;
454
464
  export type ResourceListQuery = Readonly<{
455
465
  filter?: ResourceFilter;
466
+ /**
467
+ * Include Paths, such as `["company", "contacts.company"]`: relation
468
+ * fields whose records each item carries in `included`.
469
+ */
470
+ include?: readonly string[];
456
471
  includeDeleted?: boolean;
457
472
  pagination: ResourcePagination;
458
473
  sort?: readonly ResourceSort[];
459
474
  textSearch?: string;
460
475
  }>;
461
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
476
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
477
+ /** The CI Organization storage can not take a presigned File upload. */
478
+ "upload_not_supported";
462
479
  export type ResourceError = Readonly<{
463
480
  code: ResourceErrorCode;
464
481
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
@@ -28,6 +28,8 @@ export type ResourceCapabilities = Readonly<{
28
28
  search: true;
29
29
  softDelete?: boolean;
30
30
  update?: boolean;
31
+ /** File uploads for the File fields of a common entity resource. */
32
+ upload?: boolean;
31
33
  }>;
32
34
  export type ResourcePaginationMode = "cursor" | "page";
33
35
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -65,13 +67,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
65
67
  }>;
66
68
  }>;
67
69
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
70
+ /**
71
+ * A filter predicate. `field` names a declared filterable field, or a path
72
+ * through at most three fields that hold Entity References to a field of
73
+ * the last target, such as `company.industry` or
74
+ * `contacts.company.parent.industry`. On a field that holds Entity
75
+ * References, `is_empty` means no reference, and `contains_any` and
76
+ * `contains_all` compare the ids of a field that holds many.
77
+ */
68
78
  export type ResourceFilter = Readonly<{
69
79
  field: string;
70
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
80
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
71
81
  value: FilterValue;
72
82
  }> | Readonly<{
73
83
  field: string;
74
- operator: "is_not_null" | "is_null";
84
+ operator: "is_empty" | "is_not_null" | "is_null";
75
85
  }> | Readonly<{
76
86
  filters: readonly ResourceFilter[];
77
87
  operator: "and" | "or";
@@ -94,6 +104,11 @@ export type ResourcePagination = Readonly<{
94
104
  }>;
95
105
  export type ResourceListQuery = Readonly<{
96
106
  filter?: ResourceFilter;
107
+ /**
108
+ * Include Paths, such as `["company", "contacts.company"]`: relation
109
+ * fields whose records each item carries in `included`.
110
+ */
111
+ include?: readonly string[];
97
112
  includeDeleted?: boolean;
98
113
  pagination: ResourcePagination;
99
114
  sort?: readonly ResourceSort[];
@@ -102,7 +117,15 @@ export type ResourceListQuery = Readonly<{
102
117
  export type ResourceRecord<Entity> = Readonly<{
103
118
  deletedAt?: string;
104
119
  id: ResourceRecordId;
120
+ /**
121
+ * The records of the read's Include Paths by relation field key: one
122
+ * record, or the records of a `many` field in reference order. Untyped:
123
+ * the target schemas are CI's.
124
+ */
125
+ included?: Readonly<Record<string, ResourceJsonValue>>;
105
126
  revision: ResourceRevision;
127
+ /** The keys whose included records were cut to the first 100. */
128
+ truncated?: readonly string[];
106
129
  value: Entity;
107
130
  }>;
108
131
  export type ResourceListResult<Entity> = Readonly<{
@@ -117,7 +140,9 @@ export type ResourceListResult<Entity> = Readonly<{
117
140
  totalItems: number;
118
141
  totalPages: number;
119
142
  }>;
120
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
143
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
144
+ /** The CI Organization storage can not take a presigned File upload. */
145
+ "upload_not_supported";
121
146
  export type ResourceError = Readonly<{
122
147
  code: ResourceErrorCode;
123
148
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
@@ -189,7 +214,7 @@ export type ResourceCreateInput<Value> = Readonly<{
189
214
  value: Value;
190
215
  }>;
191
216
  /** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
192
- export type EntityOperation = "list" | "get" | "create" | "update" | "delete";
217
+ export type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
193
218
  export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
194
219
  pagination: Extract<ResourcePagination, {
195
220
  mode: "page";
@@ -205,6 +230,19 @@ export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
205
230
  export type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
206
231
  idempotencyKey: IdempotencyKey;
207
232
  }>;
233
+ /** A File upload request for one File field of the entity schema. */
234
+ export type EntityUploadInput = Readonly<{
235
+ field: string;
236
+ filename: string;
237
+ mimeType: string;
238
+ }>;
239
+ /** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
240
+ export type EntityUploadSlot = Readonly<{
241
+ headers: Readonly<Record<string, string>>;
242
+ method: "PUT";
243
+ uploadId: string;
244
+ url: string;
245
+ }>;
208
246
  export type EntityRequestIdentity = Readonly<{
209
247
  requestId: string;
210
248
  resourceId: string;
@@ -215,13 +253,17 @@ export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIden
215
253
  }> | Readonly<{
216
254
  operation: "get";
217
255
  id: ResourceRecordId;
256
+ include?: readonly string[];
218
257
  }> | (Readonly<{
219
258
  operation: "create";
220
259
  }> & EntityCreateInput<Create>) | (Readonly<{
221
260
  operation: "update";
222
261
  }> & EntityUpdateInput<Patch>) | (Readonly<{
223
262
  operation: "delete";
224
- }> & EntityDeleteInput));
263
+ }> & EntityDeleteInput) | (Readonly<{
264
+ operation: "upload";
265
+ }> & EntityUploadInput));
266
+ export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
225
267
  /** Application login identities are separate from gateway machine callers. */
226
268
  export type ApplicationUserIdentity = Readonly<{
227
269
  kind: "local_user";
@@ -294,7 +336,7 @@ export type EntityResourceDefinition<Value = unknown, Create = Value, Patch = Pa
294
336
  definition: ResourceDefinition<Value, Create, Patch>;
295
337
  execute: (request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
296
338
  signal?: AbortSignal;
297
- }>) => Promise<ResourceResult<EntityPage<Value> | ResourceRecord<Value>>>;
339
+ }>) => Promise<ResourceResult<EntityOperationResult<Value, EntityOperation>>>;
298
340
  }>;
299
341
  export type GatewayResourceOperation = ResourceTransportRequest["operation"];
300
342
  export type GatewayResourceAuthorization = Readonly<Partial<Record<GatewayResourceOperation, AuthorizationRequirement>>>;