@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.
@@ -23,13 +23,15 @@ export type ApplicationUserSession = Readonly<{
23
23
  * and request/correlation IDs are deliberately not part of that logical identity.
24
24
  */
25
25
  export type EntityInvocationContext = Readonly<{
26
+ /** The App Permissions of the user's effective roles on the app. */
27
+ appPermissions: readonly string[];
26
28
  applicationId: string;
27
29
  issuer: string;
28
30
  organizationId: string;
29
31
  resourceId: string;
32
+ /** The user's effective roles on the app, read from CI at this lookup. */
30
33
  roles: readonly string[];
31
34
  scopes: readonly string[];
32
- groupIds: readonly string[];
33
35
  user: ApplicationUserIdentity;
34
36
  }>;
35
37
  export type ApplicationUserAuth = Readonly<{
@@ -38,7 +40,7 @@ export type ApplicationUserAuth = Readonly<{
38
40
  /** Returns null only when the request has no valid application session. */
39
41
  getSession: (request: Request) => Promise<ApplicationUserSession | null>;
40
42
  /** Server-only current CI authority. The host still owns resource/operation policy.
41
- * Null means no valid CI session or no current role/group policy supplied by CI.
43
+ * Null means no valid CI session, including a user without a role on the app.
42
44
  */
43
45
  getEntityContext: (request: Request, resourceId: string) => Promise<EntityInvocationContext | null>;
44
46
  /** Server-only Delegated access token. Absent for local application login. */
@@ -114,13 +116,21 @@ export type ResourceDefinition<Entity, Create = Entity, Update = Partial<Entity>
114
116
  }>;
115
117
  }>;
116
118
  export type FilterValue = ResourceJsonValue | readonly ResourceJsonValue[];
119
+ /**
120
+ * A filter predicate. `field` names a declared filterable field, or a path
121
+ * through at most three fields that hold Entity References to a field of
122
+ * the last target, such as `company.industry` or
123
+ * `contacts.company.parent.industry`. On a field that holds Entity
124
+ * References, `is_empty` means no reference, and `contains_any` and
125
+ * `contains_all` compare the ids of a field that holds many.
126
+ */
117
127
  export type ResourceFilter = Readonly<{
118
128
  field: string;
119
- operator: "contains" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
129
+ operator: "contains" | "contains_all" | "contains_any" | "ends_with" | "eq" | "gt" | "gte" | "in" | "lt" | "lte" | "ne" | "not_in" | "starts_with";
120
130
  value: FilterValue;
121
131
  }> | Readonly<{
122
132
  field: string;
123
- operator: "is_not_null" | "is_null";
133
+ operator: "is_empty" | "is_not_null" | "is_null";
124
134
  }> | Readonly<{
125
135
  filters: readonly ResourceFilter[];
126
136
  operator: "and" | "or";
@@ -143,6 +153,11 @@ export type ResourcePagination = Readonly<{
143
153
  }>;
144
154
  export type ResourceListQuery = Readonly<{
145
155
  filter?: ResourceFilter;
156
+ /**
157
+ * Include Paths, such as `["company", "contacts.company"]`: relation
158
+ * fields whose records each item carries in `included`.
159
+ */
160
+ include?: readonly string[];
146
161
  includeDeleted?: boolean;
147
162
  pagination: ResourcePagination;
148
163
  sort?: readonly ResourceSort[];
@@ -151,7 +166,15 @@ export type ResourceListQuery = Readonly<{
151
166
  export type ResourceRecord<Entity> = Readonly<{
152
167
  deletedAt?: string;
153
168
  id: ResourceRecordId;
169
+ /**
170
+ * The records of the read's Include Paths by relation field key: one
171
+ * record, or the records of a `many` field in reference order. Untyped:
172
+ * the target schemas are CI's.
173
+ */
174
+ included?: Readonly<Record<string, ResourceJsonValue>>;
154
175
  revision: ResourceRevision;
176
+ /** The keys whose included records were cut to the first 100. */
177
+ truncated?: readonly string[];
155
178
  value: Entity;
156
179
  }>;
157
180
  export type ResourceListResult<Entity> = Readonly<{
@@ -240,7 +263,7 @@ export type ResourceCreateInput<Value> = Readonly<{
240
263
  value: Value;
241
264
  }>;
242
265
  /** Common entity operations. Generic resource lifecycle/cursor APIs remain separate. */
243
- export type EntityOperation = "list" | "get" | "create" | "update" | "delete" | "upload";
266
+ export type EntityOperation = "list_members" | "list" | "get" | "create" | "update" | "delete" | "upload";
244
267
  export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDeleted"> & Readonly<{
245
268
  pagination: Extract<ResourcePagination, {
246
269
  mode: "page";
@@ -249,6 +272,8 @@ export type EntityListQuery = Omit<ResourceListQuery, "pagination" | "includeDel
249
272
  export type EntityPage<Value> = Extract<ResourceListResult<Value>, {
250
273
  pagination: "page";
251
274
  }>;
275
+ /** Member schemas are resolved by CI, independently of the parent resource. */
276
+ export type EntityMemberValue = Readonly<Record<string, ResourceJsonValue>>;
252
277
  export type EntityCreateInput<Value> = ResourceCreateInput<Value>;
253
278
  export type EntityUpdateInput<Patch> = ResourceMutationInput<Patch> & Readonly<{
254
279
  idempotencyKey: IdempotencyKey;
@@ -276,9 +301,15 @@ export type EntityRequestIdentity = Readonly<{
276
301
  export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIdentity & (Readonly<{
277
302
  operation: "list";
278
303
  query: EntityListQuery;
304
+ }> | Readonly<{
305
+ operation: "list_members";
306
+ parentId: ResourceRecordId;
307
+ field: string;
308
+ query: EntityListQuery;
279
309
  }> | Readonly<{
280
310
  operation: "get";
281
311
  id: ResourceRecordId;
312
+ include?: readonly string[];
282
313
  }> | (Readonly<{
283
314
  operation: "create";
284
315
  }> & EntityCreateInput<Create>) | (Readonly<{
@@ -288,7 +319,7 @@ export type EntityRequest<Create = unknown, Patch = unknown> = EntityRequestIden
288
319
  }> & EntityDeleteInput) | (Readonly<{
289
320
  operation: "upload";
290
321
  }> & EntityUploadInput));
291
- export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
322
+ export type EntityOperationResult<Value, Operation extends EntityOperation> = Operation extends "list_members" ? EntityPage<EntityMemberValue> : Operation extends "list" ? EntityPage<Value> : Operation extends "upload" ? EntityUploadSlot : ResourceRecord<Value>;
292
323
  export interface ConfidentialCredentials {
293
324
  readonly clientId: string;
294
325
  readonly clientSecret: string;