@collective-intelligence/external-apps-server-sdk 0.1.9 → 0.1.11

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.
@@ -22,13 +22,15 @@ export type ApplicationUserIdentity = Readonly<{
22
22
  * and request/correlation IDs are deliberately not part of that logical identity.
23
23
  */
24
24
  export type EntityInvocationContext = Readonly<{
25
+ /** The App Permissions of the user's effective roles on the app. */
26
+ appPermissions: readonly string[];
25
27
  applicationId: string;
26
28
  issuer: string;
27
29
  organizationId: string;
28
30
  resourceId: string;
31
+ /** The user's effective roles on the app, read from CI at this lookup. */
29
32
  roles: readonly string[];
30
33
  scopes: readonly string[];
31
- groupIds: readonly string[];
32
34
  user: ApplicationUserIdentity;
33
35
  }>;
34
36
  export type ResourceJsonValue = null | boolean | number | string | readonly ResourceJsonValue[] | Readonly<{
@@ -96,13 +98,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
96
98
  }>;
97
99
  }>;
98
100
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
101
+ /**
102
+ * A filter predicate. `field` names a declared filterable field, or a path
103
+ * through at most three fields that hold Entity References to a field of
104
+ * the last target, such as `company.industry` or
105
+ * `contacts.company.parent.industry`. On a field that holds Entity
106
+ * References, `is_empty` means no reference, and `contains_any` and
107
+ * `contains_all` compare the ids of a field that holds many.
108
+ */
99
109
  export type ResourceFilter = Readonly<{
100
110
  field: string;
101
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
111
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
102
112
  value: FilterValue;
103
113
  }> | Readonly<{
104
114
  field: string;
105
- operator: "is_not_null" | "is_null";
115
+ operator: "is_empty" | "is_not_null" | "is_null";
106
116
  }> | Readonly<{
107
117
  filters: readonly ResourceFilter[];
108
118
  operator: "and" | "or";
@@ -125,6 +135,11 @@ export type ResourcePagination = Readonly<{
125
135
  }>;
126
136
  export type ResourceListQuery = Readonly<{
127
137
  filter?: ResourceFilter;
138
+ /**
139
+ * Include Paths, such as `["company", "contacts.company"]`: relation
140
+ * fields whose records each item carries in `included`.
141
+ */
142
+ include?: readonly string[];
128
143
  includeDeleted?: boolean;
129
144
  pagination: ResourcePagination;
130
145
  sort?: readonly ResourceSort[];
@@ -133,7 +148,15 @@ export type ResourceListQuery = Readonly<{
133
148
  export type ResourceRecord<Entity> = Readonly<{
134
149
  deletedAt?: string;
135
150
  id: ResourceRecordId;
151
+ /**
152
+ * The records of the read's Include Paths by relation field key: one
153
+ * record, or the records of a `many` field in reference order. Untyped:
154
+ * the target schemas are CI's.
155
+ */
156
+ included?: Readonly<Record<string, ResourceJsonValue>>;
136
157
  revision: ResourceRevision;
158
+ /** The keys whose included records were cut to the first 100. */
159
+ truncated?: readonly string[];
137
160
  value: Entity;
138
161
  }>;
139
162
  export type ResourceListResult<Entity> = Readonly<{
@@ -222,7 +245,7 @@ export type ResourceCreateInput<Value> = Readonly<{
222
245
  value: Value;
223
246
  }>;
224
247
  /** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
225
- export type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
248
+ export type EntityOperation = "list_members" | "list" | "get" | "create" | "update" | "delete" | "upload";
226
249
  export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
227
250
  pagination: Extract<ResourcePagination, {
228
251
  mode: "page";
@@ -231,6 +254,8 @@ export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDel
231
254
  export type EntityPage<Value> = Extract<ResourceListResult<Value>, {
232
255
  pagination: "page";
233
256
  }>;
257
+ /** Member schemas are resolved by CI, independently of the parent resource. */
258
+ export type EntityMemberValue = Readonly<Record<string, ResourceJsonValue>>;
234
259
  export type EntityCreateInput<Value> = ResourceCreateInput<Value>;
235
260
  export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
236
261
  idempotencyKey: IdempotencyKey;
@@ -258,9 +283,15 @@ export type EntityRequestIdentity = Readonly<{
258
283
  export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity & (Readonly<{
259
284
  operation: "list";
260
285
  query: EntityListQuery;
286
+ }> | Readonly<{
287
+ operation: "list_members";
288
+ parentId: ResourceRecordId;
289
+ field: string;
290
+ query: EntityListQuery;
261
291
  }> | Readonly<{
262
292
  operation: "get";
263
293
  id: ResourceRecordId;
294
+ include?: readonly string[];
264
295
  }> | (Readonly<{
265
296
  operation: "create";
266
297
  }> & EntityCreateInput<Create>) | (Readonly<{
@@ -270,7 +301,7 @@ export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIden
270
301
  }> & EntityDeleteInput) | (Readonly<{
271
302
  operation: "upload";
272
303
  }> & EntityUploadInput));
273
- export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
304
+ export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list_members" ? EntityPage<EntityMemberValue> : Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
274
305
  export type PrincipalKind = "detached_user" | "service_principal";
275
306
  export type DelegatedSubjectPolicy = "allowed" | "forbidden" | "required";
276
307
  export type AuthorizationRequirement = Readonly<{
@@ -1013,6 +1044,63 @@ export type GatewayEffectHandler = (request: Request) => Effect.Effect<Response,
1013
1044
  export type ResourceEffectHandlerOptions<E = never, R = never, Value = unknown, Create = Value, Patch = Partial<Value>> = Omit<ResourceHttpHandlerOptions<Value, Create, Patch>, "authorize"> & Readonly<{
1014
1045
  authorize: (request: Request, operation: Parameters<ResourceHttpHandlerOptions["authorize"]>[1]) => Effect.Effect<EntityInvocationContext | Response, E, R>;
1015
1046
  }>;
1047
+ /** One file of a File field, as every CI read surface returns it. */
1048
+ export declare const EntityFileValue: Schema.Struct<{
1049
+ readonly filename: Schema.String;
1050
+ readonly id: Schema.String;
1051
+ readonly mimeType: Schema.NullOr<Schema.String>;
1052
+ readonly size: Schema.NullOr<Schema.Int>;
1053
+ readonly source: Schema.Literals<readonly [
1054
+ "managed",
1055
+ "external_url"
1056
+ ]>;
1057
+ readonly url: Schema.String;
1058
+ }>;
1059
+ export type EntityFileValue = typeof EntityFileValue.Type;
1060
+ /**
1061
+ * One file of a File field write: `{ upload }` adds the File upload of an
1062
+ * upload slot's `uploadId`; `{ id }` keeps a file, so a File value read before
1063
+ * decodes as the file it names.
1064
+ */
1065
+ export declare const EntityFileWrite: Schema.Union<readonly [
1066
+ Schema.Struct<{
1067
+ readonly id: Schema.optionalKey<Schema.Never>;
1068
+ readonly upload: Schema.String;
1069
+ }>,
1070
+ Schema.Struct<{
1071
+ readonly id: Schema.String;
1072
+ readonly upload: Schema.optionalKey<Schema.Never>;
1073
+ }>
1074
+ ]>;
1075
+ export type EntityFileWrite = typeof EntityFileWrite.Type;
1076
+ /**
1077
+ * The write form of a File field key: one file or `null` for a single field,
1078
+ * an ordered array for a multiple field; `null` removes every file. Omit the
1079
+ * key to keep its files unchanged.
1080
+ */
1081
+ export declare const EntityFileFieldWrite: Schema.NullOr<Schema.Union<readonly [
1082
+ Schema.Union<readonly [
1083
+ Schema.Struct<{
1084
+ readonly id: Schema.optionalKey<Schema.Never>;
1085
+ readonly upload: Schema.String;
1086
+ }>,
1087
+ Schema.Struct<{
1088
+ readonly id: Schema.String;
1089
+ readonly upload: Schema.optionalKey<Schema.Never>;
1090
+ }>
1091
+ ]>,
1092
+ Schema.$Array<Schema.Union<readonly [
1093
+ Schema.Struct<{
1094
+ readonly id: Schema.optionalKey<Schema.Never>;
1095
+ readonly upload: Schema.String;
1096
+ }>,
1097
+ Schema.Struct<{
1098
+ readonly id: Schema.String;
1099
+ readonly upload: Schema.optionalKey<Schema.Never>;
1100
+ }>
1101
+ ]>>
1102
+ ]>>;
1103
+ export type EntityFileFieldWrite = typeof EntityFileFieldWrite.Type;
1016
1104
  export declare const createGatewayEffectHandler: (kernel: GatewayRuntimeKernel) => GatewayEffectHandler;
1017
1105
  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>;
1018
1106
  export declare const DateTimeString: import("effect/Schema").String;