@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.
@@ -75,6 +75,8 @@ export type ResourceCapabilities = Readonly<{
75
75
  search: true;
76
76
  softDelete?: boolean;
77
77
  update?: boolean;
78
+ /** File uploads for the File fields of a common entity resource. */
79
+ upload?: boolean;
78
80
  }>;
79
81
  export type ResourcePaginationMode = "cursor" | "page";
80
82
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -112,13 +114,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
112
114
  }>;
113
115
  }>;
114
116
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
117
+ /**
118
+ * A filter predicate. `field` names a declared filterable field, or a path
119
+ * through at most three fields that hold Entity References to a field of
120
+ * the last target, such as `company.industry` or
121
+ * `contacts.company.parent.industry`. On a field that holds Entity
122
+ * References, `is_empty` means no reference, and `contains_any` and
123
+ * `contains_all` compare the ids of a field that holds many.
124
+ */
115
125
  export type ResourceFilter = Readonly<{
116
126
  field: string;
117
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
127
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
118
128
  value: FilterValue;
119
129
  }> | Readonly<{
120
130
  field: string;
121
- operator: "is_not_null" | "is_null";
131
+ operator: "is_empty" | "is_not_null" | "is_null";
122
132
  }> | Readonly<{
123
133
  filters: readonly ResourceFilter[];
124
134
  operator: "and" | "or";
@@ -141,6 +151,11 @@ export type ResourcePagination = Readonly<{
141
151
  }>;
142
152
  export type ResourceListQuery = Readonly<{
143
153
  filter?: ResourceFilter;
154
+ /**
155
+ * Include Paths, such as `["company", "contacts.company"]`: relation
156
+ * fields whose records each item carries in `included`.
157
+ */
158
+ include?: readonly string[];
144
159
  includeDeleted?: boolean;
145
160
  pagination: ResourcePagination;
146
161
  sort?: readonly ResourceSort[];
@@ -149,7 +164,15 @@ export type ResourceListQuery = Readonly<{
149
164
  export type ResourceRecord<Entity> = Readonly<{
150
165
  deletedAt?: string;
151
166
  id: ResourceRecordId;
167
+ /**
168
+ * The records of the read's Include Paths by relation field key: one
169
+ * record, or the records of a `many` field in reference order. Untyped:
170
+ * the target schemas are CI's.
171
+ */
172
+ included?: Readonly<Record<string, ResourceJsonValue>>;
152
173
  revision: ResourceRevision;
174
+ /** The keys whose included records were cut to the first 100. */
175
+ truncated?: readonly string[];
153
176
  value: Entity;
154
177
  }>;
155
178
  export type ResourceListResult<Entity> = Readonly<{
@@ -164,7 +187,9 @@ export type ResourceListResult<Entity> = Readonly<{
164
187
  totalItems: number;
165
188
  totalPages: number;
166
189
  }>;
167
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
190
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
191
+ /** The CI Organization storage can not take a presigned File upload. */
192
+ "upload_not_supported";
168
193
  export type ResourceError = Readonly<{
169
194
  code: ResourceErrorCode;
170
195
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
@@ -236,7 +261,7 @@ export type ResourceCreateInput<Value> = Readonly<{
236
261
  value: Value;
237
262
  }>;
238
263
  /** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
239
- export type EntityOperation = "list" | "get" | "create" | "update" | "delete";
264
+ export type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
240
265
  export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
241
266
  pagination: Extract<ResourcePagination, {
242
267
  mode: "page";
@@ -252,6 +277,19 @@ export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
252
277
  export type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
253
278
  idempotencyKey: IdempotencyKey;
254
279
  }>;
280
+ /** A File upload request for one File field of the entity schema. */
281
+ export type EntityUploadInput = Readonly<{
282
+ field: string;
283
+ filename: string;
284
+ mimeType: string;
285
+ }>;
286
+ /** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
287
+ export type EntityUploadSlot = Readonly<{
288
+ headers: Readonly<Record<string, string>>;
289
+ method: "PUT";
290
+ uploadId: string;
291
+ url: string;
292
+ }>;
255
293
  export type EntityRequestIdentity = Readonly<{
256
294
  requestId: string;
257
295
  resourceId: string;
@@ -262,13 +300,17 @@ export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIden
262
300
  }> | Readonly<{
263
301
  operation: "get";
264
302
  id: ResourceRecordId;
303
+ include?: readonly string[];
265
304
  }> | (Readonly<{
266
305
  operation: "create";
267
306
  }> & EntityCreateInput<Create>) | (Readonly<{
268
307
  operation: "update";
269
308
  }> & EntityUpdateInput<Patch>) | (Readonly<{
270
309
  operation: "delete";
271
- }> & EntityDeleteInput));
310
+ }> & EntityDeleteInput) | (Readonly<{
311
+ operation: "upload";
312
+ }> & EntityUploadInput));
313
+ export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
272
314
  export interface ConfidentialCredentials {
273
315
  readonly clientId: string;
274
316
  readonly clientSecret: string;
@@ -376,7 +418,7 @@ export type EntityResourceDefinition<Value = unknown, Create = Value, Patch = Pa
376
418
  definition: ResourceDefinition<Value, Create, Patch>;
377
419
  execute: (request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
378
420
  signal?: AbortSignal;
379
- }>) => Promise<ResourceResult<EntityPage<Value> | ResourceRecord<Value>>>;
421
+ }>) => Promise<ResourceResult<EntityOperationResult<Value, EntityOperation>>>;
380
422
  }>;
381
423
  export type GatewayResourceOperation = ResourceTransportRequest["operation"];
382
424
  export type GatewayResourceAuthorization = Readonly<Partial<Record<GatewayResourceOperation, AuthorizationRequirement>>>;