@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.
@@ -57,6 +57,8 @@ export type ResourceCapabilities = Readonly<{
57
57
  search: true;
58
58
  softDelete?: boolean;
59
59
  update?: boolean;
60
+ /** File uploads for the File fields of a common entity resource. */
61
+ upload?: boolean;
60
62
  }>;
61
63
  export type ResourcePaginationMode = "cursor" | "page";
62
64
  export type PortableResourceSchema = Readonly<Record<string, ResourceJsonValue>>;
@@ -94,13 +96,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
94
96
  }>;
95
97
  }>;
96
98
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
99
+ /**
100
+ * A filter predicate. `field` names a declared filterable field, or a path
101
+ * through at most three fields that hold Entity References to a field of
102
+ * the last target, such as `company.industry` or
103
+ * `contacts.company.parent.industry`. On a field that holds Entity
104
+ * References, `is_empty` means no reference, and `contains_any` and
105
+ * `contains_all` compare the ids of a field that holds many.
106
+ */
97
107
  export type ResourceFilter = Readonly<{
98
108
  field: string;
99
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
109
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
100
110
  value: FilterValue;
101
111
  }> | Readonly<{
102
112
  field: string;
103
- operator: "is_not_null" | "is_null";
113
+ operator: "is_empty" | "is_not_null" | "is_null";
104
114
  }> | Readonly<{
105
115
  filters: readonly ResourceFilter[];
106
116
  operator: "and" | "or";
@@ -123,6 +133,11 @@ export type ResourcePagination = Readonly<{
123
133
  }>;
124
134
  export type ResourceListQuery = Readonly<{
125
135
  filter?: ResourceFilter;
136
+ /**
137
+ * Include Paths, such as `["company", "contacts.company"]`: relation
138
+ * fields whose records each item carries in `included`.
139
+ */
140
+ include?: readonly string[];
126
141
  includeDeleted?: boolean;
127
142
  pagination: ResourcePagination;
128
143
  sort?: readonly ResourceSort[];
@@ -131,7 +146,15 @@ export type ResourceListQuery = Readonly<{
131
146
  export type ResourceRecord<Entity> = Readonly<{
132
147
  deletedAt?: string;
133
148
  id: ResourceRecordId;
149
+ /**
150
+ * The records of the read's Include Paths by relation field key: one
151
+ * record, or the records of a `many` field in reference order. Untyped:
152
+ * the target schemas are CI's.
153
+ */
154
+ included?: Readonly<Record<string, ResourceJsonValue>>;
134
155
  revision: ResourceRevision;
156
+ /** The keys whose included records were cut to the first 100. */
157
+ truncated?: readonly string[];
135
158
  value: Entity;
136
159
  }>;
137
160
  export type ResourceListResult<Entity> = Readonly<{
@@ -146,7 +169,9 @@ export type ResourceListResult<Entity> = Readonly<{
146
169
  totalItems: number;
147
170
  totalPages: number;
148
171
  }>;
149
- export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable";
172
+ export type ResourceErrorCode = "capability_not_supported" | "conflict" | "forbidden" | "internal" | "invalid_request" | "not_found" | "rate_limited" | "transport_error" | "unauthenticated" | "unavailable" |
173
+ /** The CI Organization storage can not take a presigned File upload. */
174
+ "upload_not_supported";
150
175
  export type ResourceError = Readonly<{
151
176
  code: ResourceErrorCode;
152
177
  /** Client-observed dispatch outcome; uncertainty never proves rollback. */
@@ -218,7 +243,7 @@ export type ResourceCreateInput<Value> = Readonly<{
218
243
  value: Value;
219
244
  }>;
220
245
  /** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
221
- export type EntityOperation = "list" | "get" | "create" | "update" | "delete";
246
+ export type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
222
247
  export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
223
248
  pagination: Extract<ResourcePagination, {
224
249
  mode: "page";
@@ -234,6 +259,19 @@ export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
234
259
  export type EntityDeleteInput = ResourceLifecycleInput & Readonly<{
235
260
  idempotencyKey: IdempotencyKey;
236
261
  }>;
262
+ /** A File upload request for one File field of the entity schema. */
263
+ export type EntityUploadInput = Readonly<{
264
+ field: string;
265
+ filename: string;
266
+ mimeType: string;
267
+ }>;
268
+ /** PUT the file bytes to `url` with `headers`; then write `{ upload: uploadId }`. */
269
+ export type EntityUploadSlot = Readonly<{
270
+ headers: Readonly<Record<string, string>>;
271
+ method: "PUT";
272
+ uploadId: string;
273
+ url: string;
274
+ }>;
237
275
  export type EntityRequestIdentity = Readonly<{
238
276
  requestId: string;
239
277
  resourceId: string;
@@ -244,13 +282,17 @@ export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIden
244
282
  }> | Readonly<{
245
283
  operation: "get";
246
284
  id: ResourceRecordId;
285
+ include?: readonly string[];
247
286
  }> | (Readonly<{
248
287
  operation: "create";
249
288
  }> & EntityCreateInput<Create>) | (Readonly<{
250
289
  operation: "update";
251
290
  }> & EntityUpdateInput<Patch>) | (Readonly<{
252
291
  operation: "delete";
253
- }> & EntityDeleteInput));
292
+ }> & EntityDeleteInput) | (Readonly<{
293
+ operation: "upload";
294
+ }> & EntityUploadInput));
295
+ export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
254
296
  export type PrincipalKind = "detached_user" | "service_principal";
255
297
  export type DelegatedSubjectPolicy = "allowed" | "forbidden" | "required";
256
298
  export type AuthorizationRequirement = Readonly<{
@@ -334,7 +376,7 @@ export type EntityResourceDefinition<Value = unknown, Create = Value, Patch = Pa
334
376
  definition: ResourceDefinition<Value, Create, Patch>;
335
377
  execute: (request: EntityRequest<Create, Patch>, context: EntityInvocationContext, options?: Readonly<{
336
378
  signal?: AbortSignal;
337
- }>) => Promise<ResourceResult<EntityPage<Value> | ResourceRecord<Value>>>;
379
+ }>) => Promise<ResourceResult<EntityOperationResult<Value, EntityOperation>>>;
338
380
  }>;
339
381
  export type GatewayResourceOperation = ResourceTransportRequest["operation"];
340
382
  export type GatewayResourceAuthorization = Readonly<Partial<Record<GatewayResourceOperation, AuthorizationRequirement>>>;
@@ -993,6 +1035,63 @@ export type GatewayEffectHandler = (request: Request) => Effect.Effect<Response,
993
1035
  export type ResourceEffectHandlerOptions<E = never, R = never, Value = unknown, Create = Value, Patch = Partial<Value>> = Omit<ResourceHttpHandlerOptions<Value, Create, Patch>, "authorize"> & Readonly<{
994
1036
  authorize: (request: Request, operation: Parameters<ResourceHttpHandlerOptions["authorize"]>[1]) => Effect.Effect<EntityInvocationContext | Response, E, R>;
995
1037
  }>;
1038
+ /** One file of a File field, as every CI read surface returns it. */
1039
+ export declare const EntityFileValue: Schema.Struct<{
1040
+ readonly filename: Schema.String;
1041
+ readonly id: Schema.String;
1042
+ readonly mimeType: Schema.NullOr<Schema.String>;
1043
+ readonly size: Schema.NullOr<Schema.Int>;
1044
+ readonly source: Schema.Literals<readonly [
1045
+ "managed",
1046
+ "external_url"
1047
+ ]>;
1048
+ readonly url: Schema.String;
1049
+ }>;
1050
+ export type EntityFileValue = typeof EntityFileValue.Type;
1051
+ /**
1052
+ * One file of a File field write: `{ upload }` adds the File upload of an
1053
+ * upload slot's `uploadId`; `{ id }` keeps a file, so a File value read before
1054
+ * decodes as the file it names.
1055
+ */
1056
+ export declare const EntityFileWrite: Schema.Union<readonly [
1057
+ Schema.Struct<{
1058
+ readonly id: Schema.optionalKey<Schema.Never>;
1059
+ readonly upload: Schema.String;
1060
+ }>,
1061
+ Schema.Struct<{
1062
+ readonly id: Schema.String;
1063
+ readonly upload: Schema.optionalKey<Schema.Never>;
1064
+ }>
1065
+ ]>;
1066
+ export type EntityFileWrite = typeof EntityFileWrite.Type;
1067
+ /**
1068
+ * The write form of a File field key: one file or `null` for a single field,
1069
+ * an ordered array for a multiple field; `null` removes every file. Omit the
1070
+ * key to keep its files unchanged.
1071
+ */
1072
+ export declare const EntityFileFieldWrite: Schema.NullOr<Schema.Union<readonly [
1073
+ Schema.Union<readonly [
1074
+ Schema.Struct<{
1075
+ readonly id: Schema.optionalKey<Schema.Never>;
1076
+ readonly upload: Schema.String;
1077
+ }>,
1078
+ Schema.Struct<{
1079
+ readonly id: Schema.String;
1080
+ readonly upload: Schema.optionalKey<Schema.Never>;
1081
+ }>
1082
+ ]>,
1083
+ Schema.$Array<Schema.Union<readonly [
1084
+ Schema.Struct<{
1085
+ readonly id: Schema.optionalKey<Schema.Never>;
1086
+ readonly upload: Schema.String;
1087
+ }>,
1088
+ Schema.Struct<{
1089
+ readonly id: Schema.String;
1090
+ readonly upload: Schema.optionalKey<Schema.Never>;
1091
+ }>
1092
+ ]>>
1093
+ ]>>;
1094
+ export type EntityFileFieldWrite = typeof EntityFileFieldWrite.Type;
996
1095
  export declare const createGatewayEffectHandler: (kernel: GatewayRuntimeKernel) => GatewayEffectHandler;
997
1096
  export declare const createResourceEffectHandler: <E, R, Value = unknown, Create = Value, Patch = Partial<Value>>(options: ResourceEffectHandlerOptions<E, R, Value, Create, Patch>) => (request: Request) => import("effect/Effect").Effect<Response, E | GatewayEffectRuntimeError, R>;
998
1097
  export declare const DateTimeString: import("effect/Schema").String;