primitive-functions 0.3.0-alpha.0 → 0.3.0-alpha.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.
- package/index.d.ts +1904 -253
- package/index.js +71 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -8,6 +8,25 @@
|
|
|
8
8
|
* against (#3180). The published package's RUNTIME is a stub that throws from
|
|
9
9
|
* every export on purpose: the platform substitutes its own copy at invoke
|
|
10
10
|
* time, and reaching the stub means it did not.
|
|
11
|
+
*
|
|
12
|
+
* WHICH USER A CALL IS ABOUT. Every `ctx.api` and `ctx.agents` call that is
|
|
13
|
+
* about one user says which user in `userId`. Omitted, it means the invoking
|
|
14
|
+
* user (`ctx.user`); in a run with no caller (cron, a webhook, the system
|
|
15
|
+
* door, a nested start under one of them) it must be named, or the call
|
|
16
|
+
* rejects with `FUNCTION_SUBJECT_REQUIRED`. Naming a user other than the
|
|
17
|
+
* invoking user — whether `userId` is optional or required on the call — is
|
|
18
|
+
* allowed in a run with no caller or one an app owner or admin invoked, with
|
|
19
|
+
* the role read at the call. An ordinary member's run may name another member
|
|
20
|
+
* only when its function's TOML declares `users:readAny` (on a read: their
|
|
21
|
+
* memberships, collections, documents, root document, inbox, devices and
|
|
22
|
+
* agent sessions) or `users:actAsAny` (on a call that acts as them:
|
|
23
|
+
* notifications read and devices, `ctx.agents` session calls,
|
|
24
|
+
* `ctx.db3` `asUser`, their aliases); otherwise, and in every run an
|
|
25
|
+
* agent drives (a tool, context or history run and anything it starts), it
|
|
26
|
+
* rejects with `SUBJECT_USER_FORBIDDEN`. A named user who is not a member of
|
|
27
|
+
* the app rejects with `SUBJECT_USER_NOT_FOUND`. Calls that hand something
|
|
28
|
+
* to a user (`notifications.send`, `users.setProfile`, a channel grant)
|
|
29
|
+
* and app-wide reads are outside this rule.
|
|
11
30
|
*/
|
|
12
31
|
|
|
13
32
|
/**
|
|
@@ -51,7 +70,7 @@ export type FunctionTrigger =
|
|
|
51
70
|
/** The provider's event id (`X-Webhook-Event-Id`), when it sent one. */
|
|
52
71
|
externalEventId: string | null;
|
|
53
72
|
}
|
|
54
|
-
/** A cron entry firing, scheduled or from the `
|
|
73
|
+
/** A cron entry firing, scheduled or from the `functions triggers fire` diagnostic. */
|
|
55
74
|
| {
|
|
56
75
|
kind: "cron";
|
|
57
76
|
/** The `[[function.triggers.cron]]` entry's `name`. */
|
|
@@ -63,15 +82,6 @@ export type FunctionTrigger =
|
|
|
63
82
|
/** Present, and true, only on the diagnostic fire: nothing was scheduled. */
|
|
64
83
|
manual?: true;
|
|
65
84
|
}
|
|
66
|
-
/**
|
|
67
|
-
* A DSL workflow's `workflow.call` step reached this function (#3288).
|
|
68
|
-
*
|
|
69
|
-
* TRANSITIONAL: the bridge exists so a workflow tree can migrate leaf-first
|
|
70
|
-
* during the transition, and it retires with the workflow engine in phase 7,
|
|
71
|
-
* taking this variant with it. `workflowKey` names the PARENT workflow, and
|
|
72
|
-
* `runId`/`stepId` locate the step inside its run.
|
|
73
|
-
*/
|
|
74
|
-
| { kind: "workflow"; workflowKey: string; runId: string; stepId: string }
|
|
75
85
|
/**
|
|
76
86
|
* Another function started this one with `ctx.functions.start` (#3280).
|
|
77
87
|
*
|
|
@@ -94,7 +104,110 @@ export type FunctionTrigger =
|
|
|
94
104
|
* attribution, never the principal the code runs as. `runKey` is the key
|
|
95
105
|
* the admin's start named, or null (#3562).
|
|
96
106
|
*/
|
|
97
|
-
| { kind: "manual"; userId: string; runKey: string | null }
|
|
107
|
+
| { kind: "manual"; userId: string; runKey: string | null }
|
|
108
|
+
/**
|
|
109
|
+
* An agent turn called this function as one of its tools.
|
|
110
|
+
*
|
|
111
|
+
* `ctx.user` is the turn's initiator, whose `access` gate the call
|
|
112
|
+
* passed, and `ctx.tool` carries the session's ids, members and
|
|
113
|
+
* variables, and the turn's context, timezone and locale. `callId` is the same on every attempt of the call, so use
|
|
114
|
+
* it as an idempotency key. `toolName` is the declared tool name, which
|
|
115
|
+
* may differ from the function's key.
|
|
116
|
+
*/
|
|
117
|
+
| {
|
|
118
|
+
kind: "tool";
|
|
119
|
+
sessionId: string;
|
|
120
|
+
turnId: string;
|
|
121
|
+
callId: string;
|
|
122
|
+
toolName: string;
|
|
123
|
+
}
|
|
124
|
+
/** An agent turn asked this function for its turn context. */
|
|
125
|
+
| { kind: "context"; sessionId: string; turnId: string }
|
|
126
|
+
/** An agent turn asked this function for the history to send the model. */
|
|
127
|
+
| { kind: "history"; sessionId: string; turnId: string }
|
|
128
|
+
/**
|
|
129
|
+
* One flush of a db3 of a type a `[[function.triggers.db3]]` entry
|
|
130
|
+
* watches: a client's socket batch, a records-route write or a partial
|
|
131
|
+
* bulk that accepted at least one entry. `from` and `to` are the flush's
|
|
132
|
+
* first and last log numbers. The run's input carries the changed records'
|
|
133
|
+
* keys and change kinds, not their values: read what you need through
|
|
134
|
+
* `ctx.db3(trigger.db3Id, trigger.type)`.
|
|
135
|
+
*
|
|
136
|
+
* A watcher that writes the db3 it watches starts another run per flush,
|
|
137
|
+
* bounded only by its `ratePerMinute`; branch on
|
|
138
|
+
* `ctx.trigger.kind === "db3"` to skip the writes a flush of your own
|
|
139
|
+
* started.
|
|
140
|
+
*/
|
|
141
|
+
| {
|
|
142
|
+
kind: "db3";
|
|
143
|
+
db3Id: string;
|
|
144
|
+
type: string;
|
|
145
|
+
triggerId: string;
|
|
146
|
+
from: number;
|
|
147
|
+
to: number;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** The door names `ctx.trigger.kind` can hold. */
|
|
151
|
+
export type FunctionTriggerKind = FunctionTrigger["kind"];
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The agent session a tool call belongs to — `ctx.tool`, set only when
|
|
155
|
+
* `ctx.trigger.kind === "tool"`.
|
|
156
|
+
*
|
|
157
|
+
* Variables and members describe the session; they grant nothing. Check what
|
|
158
|
+
* `ctx.user` (the turn's initiator) may do before acting for them.
|
|
159
|
+
*/
|
|
160
|
+
export interface FunctionToolContext {
|
|
161
|
+
readonly sessionId: string;
|
|
162
|
+
/**
|
|
163
|
+
* The session's document, which holds its messages.
|
|
164
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
165
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
166
|
+
*/
|
|
167
|
+
readonly documentId: string;
|
|
168
|
+
readonly turnId: string;
|
|
169
|
+
/** The call's id, the same on every attempt: an idempotency key. */
|
|
170
|
+
readonly callId: string;
|
|
171
|
+
/** The tool's declared name. */
|
|
172
|
+
readonly toolName: string;
|
|
173
|
+
/** The session's owner. */
|
|
174
|
+
readonly ownerUserId: string;
|
|
175
|
+
/** The session's members by role, besides the owner. */
|
|
176
|
+
readonly members: {
|
|
177
|
+
readonly viewerUserIds: string[];
|
|
178
|
+
readonly participantUserIds: string[];
|
|
179
|
+
};
|
|
180
|
+
/** The session's variables, set when it was created. */
|
|
181
|
+
readonly variables: Record<string, unknown>;
|
|
182
|
+
/**
|
|
183
|
+
* The turn's validated context: the object the member's send carried,
|
|
184
|
+
* checked against the agent's `turnContext.schema`, or the return of the
|
|
185
|
+
* agent's context function. The same values the system prompt rendered as
|
|
186
|
+
* `turn.*`. Null when the turn carried none.
|
|
187
|
+
*/
|
|
188
|
+
readonly context: Record<string, unknown> | null;
|
|
189
|
+
/**
|
|
190
|
+
* The IANA timezone the turn's send carried, such as
|
|
191
|
+
* `"Pacific/Auckland"`; the prompt's `turn.timezone`. Null when it
|
|
192
|
+
* carried none.
|
|
193
|
+
*/
|
|
194
|
+
readonly timezone: string | null;
|
|
195
|
+
/**
|
|
196
|
+
* The BCP 47 locale the turn's send carried, such as `"en-NZ"`; the
|
|
197
|
+
* prompt's `turn.locale`. Null when it carried none.
|
|
198
|
+
*/
|
|
199
|
+
readonly locale: string | null;
|
|
200
|
+
/**
|
|
201
|
+
* Attach an app-only artifact to this call's row, replacing any earlier
|
|
202
|
+
* one. The model never sees it; your app reads it from the call's row —
|
|
203
|
+
* `artifact`, or, for one over 64 KiB of JSON or past the agent's
|
|
204
|
+
* `maxRowBytes`, the blob on the session's document named by
|
|
205
|
+
* `artifactBlobId`. At most 4 MiB of JSON: a larger value rejects with
|
|
206
|
+
* `AGENT_ARTIFACT_TOO_LARGE`, and a call that already has its result with
|
|
207
|
+
* `AGENT_CALL_NOT_RUNNING`.
|
|
208
|
+
*/
|
|
209
|
+
attachArtifact(value: unknown): Promise<void>;
|
|
210
|
+
}
|
|
98
211
|
|
|
99
212
|
/** The result shape of an operation that answers in response headers. */
|
|
100
213
|
export interface HeaderResult {
|
|
@@ -113,14 +226,14 @@ export interface PrimitivePlatformError extends Error {
|
|
|
113
226
|
/**
|
|
114
227
|
* The route's structured `details`, or null when its refusal carries none
|
|
115
228
|
* (#3803). `AGENT_SESSION_VARIABLES_INVALID` lists `errors` as
|
|
116
|
-
* `{ path, message }
|
|
229
|
+
* `{ path, message }`.
|
|
117
230
|
*/
|
|
118
231
|
details: unknown;
|
|
119
232
|
}
|
|
120
233
|
|
|
121
234
|
/**
|
|
122
235
|
* The typed HTTP profile, generated from the platform's OpenAPI document. Its
|
|
123
|
-
* namespaces mirror the operation ids: agentSessions, analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.
|
|
236
|
+
* namespaces mirror the operation ids: agentSessions, analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, db3, documents, email, functions, groups, integrations, locks, notifications, prompts, resourceMetadata, secrets, users.
|
|
124
237
|
* Methods take one options object carrying the operation's path parameters,
|
|
125
238
|
* query parameters, request headers (under their wire names) and `body`.
|
|
126
239
|
*
|
|
@@ -138,10 +251,99 @@ export interface PrimitivePlatformError extends Error {
|
|
|
138
251
|
*/
|
|
139
252
|
export interface FunctionApi {
|
|
140
253
|
"agentSessions": {
|
|
254
|
+
/** `agentSessions.addMember` — POST /agent-sessions/{sessionId}/members. Add a member to an agent session, or change their role */
|
|
255
|
+
"addMember"(args: {
|
|
256
|
+
"sessionId": string | number;
|
|
257
|
+
body: unknown;
|
|
258
|
+
}): Promise<any>;
|
|
259
|
+
/** `agentSessions.answer` — POST /agent-sessions/{sessionId}/calls/{callId}/answer. Answer a paused agent turn's call */
|
|
260
|
+
"answer"(args: {
|
|
261
|
+
"sessionId": string | number;
|
|
262
|
+
"callId": string | number;
|
|
263
|
+
body: unknown;
|
|
264
|
+
}): Promise<any>;
|
|
265
|
+
/** `agentSessions.attachArtifact` — POST /agent-sessions/{sessionId}/calls/{callId}/artifact. Attach an artifact to a running agent tool call (ctx.tool.attachArtifact) */
|
|
266
|
+
"attachArtifact"(args: {
|
|
267
|
+
"sessionId": string | number;
|
|
268
|
+
"callId": string | number;
|
|
269
|
+
body: unknown;
|
|
270
|
+
}): Promise<any>;
|
|
271
|
+
"attachments": {
|
|
272
|
+
/** `agentSessions.attachments.downloadHeaders` — HEAD /agent-sessions/{sessionId}/attachments/{blobId}/download. Get an agent session attachment's download headers */
|
|
273
|
+
"downloadHeaders"(args: {
|
|
274
|
+
"sessionId": string | number;
|
|
275
|
+
"blobId": string | number;
|
|
276
|
+
"disposition"?: string | number | boolean;
|
|
277
|
+
}): Promise<HeaderResult>;
|
|
278
|
+
/** `agentSessions.attachments.downloadUrl` — GET /agent-sessions/{sessionId}/attachments/{blobId}/download. Download an agent session attachment */
|
|
279
|
+
"downloadUrl"(args: {
|
|
280
|
+
"sessionId": string | number;
|
|
281
|
+
"blobId": string | number;
|
|
282
|
+
"disposition"?: string | number | boolean;
|
|
283
|
+
}): Promise<Uint8Array>;
|
|
284
|
+
/** `agentSessions.attachments.upload` — PUT /agent-sessions/{sessionId}/attachments/{blobId}. Upload an agent session attachment */
|
|
285
|
+
"upload"(args: {
|
|
286
|
+
"sessionId": string | number;
|
|
287
|
+
"blobId": string | number;
|
|
288
|
+
"X-Blob-Filename": string | number;
|
|
289
|
+
"X-Blob-Size": string | number;
|
|
290
|
+
"X-Blob-Sha256": string | number;
|
|
291
|
+
"Content-Type"?: string | number;
|
|
292
|
+
body: ArrayBuffer | Uint8Array | string;
|
|
293
|
+
}): Promise<any>;
|
|
294
|
+
};
|
|
295
|
+
/** `agentSessions.cancel` — POST /agent-sessions/{sessionId}/cancel. Cancel an agent session's active turn */
|
|
296
|
+
"cancel"(args: {
|
|
297
|
+
"sessionId": string | number;
|
|
298
|
+
body: unknown;
|
|
299
|
+
}): Promise<any>;
|
|
141
300
|
/** `agentSessions.create` — POST /agent-sessions. Create an agent session (ctx.agents.createSession) */
|
|
142
301
|
"create"(args: {
|
|
143
302
|
body: unknown;
|
|
144
303
|
}): Promise<any>;
|
|
304
|
+
/** `agentSessions.delete` — DELETE /agent-sessions/{sessionId}. Delete an agent session (ctx.agents.deleteSession) */
|
|
305
|
+
"delete"(args: {
|
|
306
|
+
"sessionId": string | number;
|
|
307
|
+
"userId"?: string | number;
|
|
308
|
+
}): Promise<any>;
|
|
309
|
+
/** `agentSessions.get` — GET /agent-sessions/{sessionId}. Get an agent session */
|
|
310
|
+
"get"(args: {
|
|
311
|
+
"sessionId": string | number;
|
|
312
|
+
"userId"?: string | number;
|
|
313
|
+
}): Promise<any>;
|
|
314
|
+
/** `agentSessions.list` — GET /agent-sessions. List one user's agent sessions */
|
|
315
|
+
"list"(args?: {
|
|
316
|
+
"userId"?: string | number;
|
|
317
|
+
"agent"?: string | number | boolean;
|
|
318
|
+
"scope"?: string | number | boolean;
|
|
319
|
+
"limit"?: string | number | boolean;
|
|
320
|
+
"cursor"?: string | number | boolean;
|
|
321
|
+
}): Promise<any>;
|
|
322
|
+
/** `agentSessions.markRead` — POST /agent-sessions/{sessionId}/read. Mark an agent session read */
|
|
323
|
+
"markRead"(args: {
|
|
324
|
+
"sessionId": string | number;
|
|
325
|
+
}): Promise<any>;
|
|
326
|
+
/** `agentSessions.recordEvent` — POST /agent-sessions/{sessionId}/events. Record an event in an agent session (ctx.agents.recordEvent) */
|
|
327
|
+
"recordEvent"(args: {
|
|
328
|
+
"sessionId": string | number;
|
|
329
|
+
"userId"?: string | number;
|
|
330
|
+
body: unknown;
|
|
331
|
+
}): Promise<any>;
|
|
332
|
+
/** `agentSessions.removeMember` — DELETE /agent-sessions/{sessionId}/members/{userId}. Remove a member from an agent session */
|
|
333
|
+
"removeMember"(args: {
|
|
334
|
+
"sessionId": string | number;
|
|
335
|
+
"userId": string | number;
|
|
336
|
+
}): Promise<any>;
|
|
337
|
+
/** `agentSessions.rename` — PATCH /agent-sessions/{sessionId}. Rename an agent session */
|
|
338
|
+
"rename"(args: {
|
|
339
|
+
"sessionId": string | number;
|
|
340
|
+
body: unknown;
|
|
341
|
+
}): Promise<any>;
|
|
342
|
+
/** `agentSessions.send` — POST /agent-sessions/{sessionId}/messages. Send a message to an agent session */
|
|
343
|
+
"send"(args: {
|
|
344
|
+
"sessionId": string | number;
|
|
345
|
+
body: unknown;
|
|
346
|
+
}): Promise<any>;
|
|
145
347
|
};
|
|
146
348
|
"analytics": {
|
|
147
349
|
/** `analytics.cohortRetention` — GET /analytics/cohort-retention. Cohort retention metrics */
|
|
@@ -237,13 +439,6 @@ export interface FunctionApi {
|
|
|
237
439
|
"current_timestamp"?: string | number | boolean;
|
|
238
440
|
"_bust"?: string | number | boolean;
|
|
239
441
|
}): Promise<any>;
|
|
240
|
-
/** `analytics.topWorkflows` — GET /analytics/workflows/top. List the most-run workflows */
|
|
241
|
-
"topWorkflows"(args?: {
|
|
242
|
-
"windowDays"?: string | number | boolean;
|
|
243
|
-
"limit"?: string | number | boolean;
|
|
244
|
-
"current_timestamp"?: string | number | boolean;
|
|
245
|
-
"_bust"?: string | number | boolean;
|
|
246
|
-
}): Promise<any>;
|
|
247
442
|
/** `analytics.userDetail` — GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */
|
|
248
443
|
"userDetail"(args: {
|
|
249
444
|
"userUlid": string | number;
|
|
@@ -364,17 +559,30 @@ export interface FunctionApi {
|
|
|
364
559
|
"get"(args: {
|
|
365
560
|
"collectionId": string | number;
|
|
366
561
|
}): Promise<any>;
|
|
367
|
-
/**
|
|
562
|
+
/**
|
|
563
|
+
* `collections.getAccess` — GET /collections/{collectionId}/access. DEPRECATED — Get a collection's access summary; use GET /collections/{collectionId}/members (removal: #4718)
|
|
564
|
+
* @deprecated Use GET /collections/{collectionId}/members (removal: #4718)
|
|
565
|
+
*/
|
|
368
566
|
"getAccess"(args: {
|
|
369
567
|
"collectionId": string | number;
|
|
370
568
|
}): Promise<any>;
|
|
371
|
-
/**
|
|
569
|
+
/**
|
|
570
|
+
* `collections.grantGroupPermission` — POST /collections/{collectionId}/group-permissions. DEPRECATED — Grant a group permission on a collection; use POST /collections/{collectionId}/members with groupId and role (removal: #4718)
|
|
571
|
+
* @deprecated Use POST /collections/{collectionId}/members with groupId and role (removal: #4718)
|
|
572
|
+
*/
|
|
372
573
|
"grantGroupPermission"(args: {
|
|
373
574
|
"collectionId": string | number;
|
|
374
575
|
body: unknown;
|
|
375
576
|
}): Promise<any>;
|
|
376
577
|
/** `collections.list` — GET /collections. List collections */
|
|
377
578
|
"list"(args?: {
|
|
579
|
+
"userId"?: string | number;
|
|
580
|
+
"limit"?: string | number | boolean;
|
|
581
|
+
"cursor"?: string | number | boolean;
|
|
582
|
+
}): Promise<any>;
|
|
583
|
+
/** `collections.listByCustodian` — GET /holdings/collections. List the collections one custodian holds, from a server function */
|
|
584
|
+
"listByCustodian"(args?: {
|
|
585
|
+
"custodian"?: string | number | boolean;
|
|
378
586
|
"limit"?: string | number | boolean;
|
|
379
587
|
"cursor"?: string | number | boolean;
|
|
380
588
|
}): Promise<any>;
|
|
@@ -384,12 +592,28 @@ export interface FunctionApi {
|
|
|
384
592
|
"limit"?: string | number | boolean;
|
|
385
593
|
"cursor"?: string | number | boolean;
|
|
386
594
|
}): Promise<any>;
|
|
595
|
+
/** `collections.listDb3` — GET /collections/{collectionId}/db3. List db3s in a collection */
|
|
596
|
+
"listDb3"(args: {
|
|
597
|
+
"collectionId": string | number;
|
|
598
|
+
"limit"?: string | number | boolean;
|
|
599
|
+
"cursor"?: string | number | boolean;
|
|
600
|
+
}): Promise<any>;
|
|
387
601
|
/** `collections.listDocuments` — GET /collections/{collectionId}/documents. List documents in a collection */
|
|
388
602
|
"listDocuments"(args: {
|
|
389
603
|
"collectionId": string | number;
|
|
390
604
|
"limit"?: string | number | boolean;
|
|
391
605
|
"cursor"?: string | number | boolean;
|
|
392
606
|
}): Promise<any>;
|
|
607
|
+
/** `collections.listForUser` — GET /users/{userId}/collections. List the collections an app user is a direct member of */
|
|
608
|
+
"listForUser"(args: {
|
|
609
|
+
"userId": string | number;
|
|
610
|
+
"limit"?: string | number | boolean;
|
|
611
|
+
"cursor"?: string | number | boolean;
|
|
612
|
+
}): Promise<any>;
|
|
613
|
+
/** `collections.listMembers` — GET /collections/{collectionId}/members. List a collection's members */
|
|
614
|
+
"listMembers"(args: {
|
|
615
|
+
"collectionId": string | number;
|
|
616
|
+
}): Promise<any>;
|
|
393
617
|
/** `collections.listPendingInvitations` — GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */
|
|
394
618
|
"listPendingInvitations"(args: {
|
|
395
619
|
"collectionId": string | number;
|
|
@@ -399,17 +623,36 @@ export interface FunctionApi {
|
|
|
399
623
|
"collectionId": string | number;
|
|
400
624
|
"documentId": string | number;
|
|
401
625
|
}): Promise<any>;
|
|
402
|
-
/** `collections.removeMember` — DELETE /collections/{collectionId}/members/{
|
|
626
|
+
/** `collections.removeMember` — DELETE /collections/{collectionId}/members/{principal}. Remove a member from a collection */
|
|
403
627
|
"removeMember"(args: {
|
|
404
628
|
"collectionId": string | number;
|
|
405
|
-
"
|
|
629
|
+
"principal": string | number;
|
|
406
630
|
}): Promise<any>;
|
|
407
|
-
/** `collections.
|
|
631
|
+
/** `collections.resolveRole` — GET /collections/{collectionId}/role. Resolve a user's role on a collection */
|
|
632
|
+
"resolveRole"(args: {
|
|
633
|
+
"collectionId": string | number;
|
|
634
|
+
"userId"?: string | number;
|
|
635
|
+
}): Promise<any>;
|
|
636
|
+
/**
|
|
637
|
+
* `collections.revokeGroupPermission` — DELETE /collections/{collectionId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a collection, by type; use DELETE /collections/{collectionId}/members/group:{groupId} (removal: #4718)
|
|
638
|
+
* @deprecated Use DELETE /collections/{collectionId}/members/group:{groupId} (removal: #4718)
|
|
639
|
+
*/
|
|
408
640
|
"revokeGroupPermission"(args: {
|
|
409
641
|
"collectionId": string | number;
|
|
410
642
|
"groupType": string | number;
|
|
411
643
|
"groupId": string | number;
|
|
412
644
|
}): Promise<any>;
|
|
645
|
+
/** `collections.setMemberRole` — PATCH /collections/{collectionId}/members/{principal}. Change a collection member's role */
|
|
646
|
+
"setMemberRole"(args: {
|
|
647
|
+
"collectionId": string | number;
|
|
648
|
+
"principal": string | number;
|
|
649
|
+
body: unknown;
|
|
650
|
+
}): Promise<any>;
|
|
651
|
+
/** `collections.transfer` — POST /collections/{collectionId}/transfer. Transfer a collection to another user or to the app */
|
|
652
|
+
"transfer"(args: {
|
|
653
|
+
"collectionId": string | number;
|
|
654
|
+
body: unknown;
|
|
655
|
+
}): Promise<any>;
|
|
413
656
|
/** `collections.update` — PATCH /collections/{collectionId}. Update a collection */
|
|
414
657
|
"update"(args: {
|
|
415
658
|
"collectionId": string | number;
|
|
@@ -435,30 +678,14 @@ export interface FunctionApi {
|
|
|
435
678
|
"dryRun"?: string | number | boolean;
|
|
436
679
|
body: unknown;
|
|
437
680
|
}): Promise<any>;
|
|
438
|
-
/** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */
|
|
439
|
-
"createOperation"(args: {
|
|
440
|
-
"databaseType": string | number;
|
|
441
|
-
"dryRun"?: string | number | boolean;
|
|
442
|
-
body: unknown;
|
|
443
|
-
}): Promise<any>;
|
|
444
681
|
/** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */
|
|
445
682
|
"delete"(args: {
|
|
446
683
|
"databaseType": string | number;
|
|
447
684
|
}): Promise<any>;
|
|
448
|
-
/** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */
|
|
449
|
-
"deleteOperation"(args: {
|
|
450
|
-
"databaseType": string | number;
|
|
451
|
-
"name": string | number;
|
|
452
|
-
}): Promise<any>;
|
|
453
685
|
/** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */
|
|
454
686
|
"get"(args: {
|
|
455
687
|
"databaseType": string | number;
|
|
456
688
|
}): Promise<any>;
|
|
457
|
-
/** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */
|
|
458
|
-
"getOperation"(args: {
|
|
459
|
-
"databaseType": string | number;
|
|
460
|
-
"name": string | number;
|
|
461
|
-
}): Promise<any>;
|
|
462
689
|
/** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */
|
|
463
690
|
"getReindexStatus"(args: {
|
|
464
691
|
"databaseType": string | number;
|
|
@@ -466,54 +693,16 @@ export interface FunctionApi {
|
|
|
466
693
|
}): Promise<any>;
|
|
467
694
|
/** `databaseTypeConfigs.list` — GET /databases/types. List database types */
|
|
468
695
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
469
|
-
/** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */
|
|
470
|
-
"listOperations"(args: {
|
|
471
|
-
"databaseType": string | number;
|
|
472
|
-
}): Promise<any>;
|
|
473
696
|
/** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */
|
|
474
697
|
"scaffoldSchema"(args: {
|
|
475
698
|
"databaseType": string | number;
|
|
476
699
|
}): Promise<any>;
|
|
477
|
-
"subscriptions": {
|
|
478
|
-
/** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */
|
|
479
|
-
"create"(args: {
|
|
480
|
-
"databaseType": string | number;
|
|
481
|
-
body: unknown;
|
|
482
|
-
}): Promise<any>;
|
|
483
|
-
/** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */
|
|
484
|
-
"delete"(args: {
|
|
485
|
-
"databaseType": string | number;
|
|
486
|
-
"subscriptionKey": string | number;
|
|
487
|
-
}): Promise<any>;
|
|
488
|
-
/** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */
|
|
489
|
-
"get"(args: {
|
|
490
|
-
"databaseType": string | number;
|
|
491
|
-
"subscriptionKey": string | number;
|
|
492
|
-
}): Promise<any>;
|
|
493
|
-
/** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */
|
|
494
|
-
"list"(args: {
|
|
495
|
-
"databaseType": string | number;
|
|
496
|
-
}): Promise<any>;
|
|
497
|
-
/** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */
|
|
498
|
-
"update"(args: {
|
|
499
|
-
"databaseType": string | number;
|
|
500
|
-
"subscriptionKey": string | number;
|
|
501
|
-
body: unknown;
|
|
502
|
-
}): Promise<any>;
|
|
503
|
-
};
|
|
504
700
|
/** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */
|
|
505
701
|
"update"(args: {
|
|
506
702
|
"databaseType": string | number;
|
|
507
703
|
"dryRun"?: string | number | boolean;
|
|
508
704
|
body: unknown;
|
|
509
705
|
}): Promise<any>;
|
|
510
|
-
/** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */
|
|
511
|
-
"updateOperation"(args: {
|
|
512
|
-
"databaseType": string | number;
|
|
513
|
-
"name": string | number;
|
|
514
|
-
"dryRun"?: string | number | boolean;
|
|
515
|
-
body: unknown;
|
|
516
|
-
}): Promise<any>;
|
|
517
706
|
};
|
|
518
707
|
"databases": {
|
|
519
708
|
/** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */
|
|
@@ -529,191 +718,491 @@ export interface FunctionApi {
|
|
|
529
718
|
"delete"(args: {
|
|
530
719
|
"databaseId": string | number;
|
|
531
720
|
}): Promise<any>;
|
|
532
|
-
/** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */
|
|
533
|
-
"executeBatch"(args: {
|
|
534
|
-
"databaseId": string | number;
|
|
535
|
-
"name": string | number;
|
|
536
|
-
body: unknown;
|
|
537
|
-
}): Promise<any>;
|
|
538
|
-
/** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */
|
|
539
|
-
"executeOperation"(args: {
|
|
540
|
-
"databaseId": string | number;
|
|
541
|
-
"name": string | number;
|
|
542
|
-
"dryRun"?: string | number | boolean;
|
|
543
|
-
body?: unknown;
|
|
544
|
-
}): Promise<any>;
|
|
545
721
|
/** `databases.get` — GET /databases/{databaseId}. Get a database by id */
|
|
546
722
|
"get"(args: {
|
|
547
723
|
"databaseId": string | number;
|
|
548
724
|
}): Promise<any>;
|
|
549
|
-
/**
|
|
550
|
-
* `databases.getMetadata` — GET /databases/{databaseId}/metadata. DEPRECATED — get database metadata; use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
551
|
-
* @deprecated Use resource metadata categories (resources/database/:databaseId/metadata/:category)
|
|
552
|
-
*/
|
|
553
|
-
"getMetadata"(args: {
|
|
554
|
-
"databaseId": string | number;
|
|
555
|
-
}): Promise<any>;
|
|
556
725
|
/** `databases.grantGroupPermission` — POST /databases/{databaseId}/group-permissions. Grant a group permission on a database */
|
|
557
726
|
"grantGroupPermission"(args: {
|
|
558
727
|
"databaseId": string | number;
|
|
559
728
|
body: unknown;
|
|
560
729
|
}): Promise<any>;
|
|
561
|
-
/** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */
|
|
562
|
-
"importBulk"(args: {
|
|
563
|
-
"databaseId": string | number;
|
|
564
|
-
"name": string | number;
|
|
565
|
-
body: unknown;
|
|
566
|
-
}): Promise<any>;
|
|
567
730
|
/** `databases.list` — GET /databases. List databases */
|
|
568
731
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
569
732
|
/** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */
|
|
570
733
|
"listGroupPermissions"(args: {
|
|
571
734
|
"databaseId": string | number;
|
|
572
735
|
}): Promise<any>;
|
|
573
|
-
/** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */
|
|
574
|
-
"listOperations"(args: {
|
|
575
|
-
"databaseId": string | number;
|
|
576
|
-
}): Promise<any>;
|
|
577
736
|
/** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */
|
|
578
737
|
"listPermissions"(args: {
|
|
579
738
|
"databaseId": string | number;
|
|
580
739
|
}): Promise<any>;
|
|
581
740
|
"records": {
|
|
582
|
-
/** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (
|
|
741
|
+
/** `databases.records.addToSet` — POST /databases/{databaseId}/records/stringset/add. Database records: stringset/add (app admin or owner) */
|
|
583
742
|
"addToSet"(args: {
|
|
584
743
|
"databaseId": string | number;
|
|
585
744
|
body: unknown;
|
|
586
745
|
}): Promise<any>;
|
|
587
|
-
/** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (
|
|
746
|
+
/** `databases.records.aggregate` — POST /databases/{databaseId}/records/aggregate. Database records: aggregate (app admin or owner) */
|
|
588
747
|
"aggregate"(args: {
|
|
589
748
|
"databaseId": string | number;
|
|
590
749
|
body: unknown;
|
|
591
750
|
}): Promise<any>;
|
|
592
|
-
/** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (
|
|
751
|
+
/** `databases.records.batch` — POST /databases/{databaseId}/records/batch. Database records: batch (app admin or owner) */
|
|
593
752
|
"batch"(args: {
|
|
594
753
|
"databaseId": string | number;
|
|
595
754
|
body: unknown;
|
|
596
755
|
}): Promise<any>;
|
|
597
|
-
/** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (
|
|
756
|
+
/** `databases.records.count` — POST /databases/{databaseId}/records/count. Database records: count (app admin or owner) */
|
|
598
757
|
"count"(args: {
|
|
599
758
|
"databaseId": string | number;
|
|
600
759
|
body: unknown;
|
|
601
760
|
}): Promise<any>;
|
|
602
|
-
/** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (
|
|
761
|
+
/** `databases.records.delete` — POST /databases/{databaseId}/records/delete. Database records: delete (app admin or owner) */
|
|
603
762
|
"delete"(args: {
|
|
604
763
|
"databaseId": string | number;
|
|
605
764
|
body: unknown;
|
|
606
765
|
}): Promise<any>;
|
|
607
|
-
/** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (
|
|
766
|
+
/** `databases.records.describe` — GET /databases/{databaseId}/records/describe. Database records: describe (app admin or owner) */
|
|
608
767
|
"describe"(args: {
|
|
609
768
|
"databaseId": string | number;
|
|
610
769
|
"modelName"?: string | number | boolean;
|
|
611
770
|
}): Promise<any>;
|
|
612
|
-
/** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (
|
|
771
|
+
/** `databases.records.dropIndex` — POST /databases/{databaseId}/records/index/drop. Database records: index/drop (app admin or owner) */
|
|
613
772
|
"dropIndex"(args: {
|
|
614
773
|
"databaseId": string | number;
|
|
615
774
|
body: unknown;
|
|
616
775
|
}): Promise<any>;
|
|
617
|
-
/** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (
|
|
776
|
+
/** `databases.records.dropUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/drop. Database records: unique-constraint/drop (app admin or owner) */
|
|
618
777
|
"dropUniqueConstraint"(args: {
|
|
619
778
|
"databaseId": string | number;
|
|
620
779
|
body: unknown;
|
|
621
780
|
}): Promise<any>;
|
|
622
|
-
/** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (
|
|
781
|
+
/** `databases.records.increment` — POST /databases/{databaseId}/records/increment. Database records: increment (app admin or owner) */
|
|
623
782
|
"increment"(args: {
|
|
624
783
|
"databaseId": string | number;
|
|
625
784
|
body: unknown;
|
|
626
785
|
}): Promise<any>;
|
|
627
|
-
/** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (
|
|
786
|
+
/** `databases.records.listIndexes` — GET /databases/{databaseId}/records/indexes. Database records: indexes (app admin or owner) */
|
|
628
787
|
"listIndexes"(args: {
|
|
629
788
|
"databaseId": string | number;
|
|
630
789
|
"modelName"?: string | number | boolean;
|
|
631
790
|
}): Promise<any>;
|
|
632
|
-
/** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (
|
|
791
|
+
/** `databases.records.listUniqueConstraints` — GET /databases/{databaseId}/records/unique-constraints. Database records: unique-constraints (app admin or owner) */
|
|
633
792
|
"listUniqueConstraints"(args: {
|
|
634
793
|
"databaseId": string | number;
|
|
635
794
|
"modelName"?: string | number | boolean;
|
|
636
795
|
}): Promise<any>;
|
|
637
|
-
/** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (
|
|
796
|
+
/** `databases.records.models` — GET /databases/{databaseId}/records/models. Database records: models (app admin or owner) */
|
|
638
797
|
"models"(args: {
|
|
639
798
|
"databaseId": string | number;
|
|
640
799
|
"modelName"?: string | number | boolean;
|
|
641
800
|
}): Promise<any>;
|
|
642
|
-
/** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (
|
|
801
|
+
/** `databases.records.patch` — POST /databases/{databaseId}/records/patch. Database records: patch (app admin or owner) */
|
|
643
802
|
"patch"(args: {
|
|
644
803
|
"databaseId": string | number;
|
|
645
804
|
body: unknown;
|
|
646
805
|
}): Promise<any>;
|
|
647
|
-
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (
|
|
648
|
-
"query"(args: {
|
|
649
|
-
"databaseId": string | number;
|
|
650
|
-
body: unknown;
|
|
651
|
-
}): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;
|
|
652
|
-
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (
|
|
653
|
-
"registerIndex"(args: {
|
|
654
|
-
"databaseId": string | number;
|
|
806
|
+
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (app admin or owner) */
|
|
807
|
+
"query"(args: {
|
|
808
|
+
"databaseId": string | number;
|
|
809
|
+
body: unknown;
|
|
810
|
+
}): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;
|
|
811
|
+
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (app admin or owner) */
|
|
812
|
+
"registerIndex"(args: {
|
|
813
|
+
"databaseId": string | number;
|
|
814
|
+
body: unknown;
|
|
815
|
+
}): Promise<any>;
|
|
816
|
+
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (app admin or owner) */
|
|
817
|
+
"registerUniqueConstraint"(args: {
|
|
818
|
+
"databaseId": string | number;
|
|
819
|
+
body: unknown;
|
|
820
|
+
}): Promise<any>;
|
|
821
|
+
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (app admin or owner) */
|
|
822
|
+
"removeFromSet"(args: {
|
|
823
|
+
"databaseId": string | number;
|
|
824
|
+
body: unknown;
|
|
825
|
+
}): Promise<any>;
|
|
826
|
+
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (app admin or owner) */
|
|
827
|
+
"save"(args: {
|
|
828
|
+
"databaseId": string | number;
|
|
829
|
+
body: unknown;
|
|
830
|
+
}): Promise<any>;
|
|
831
|
+
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (app admin or owner) */
|
|
832
|
+
"syncIndexes"(args: {
|
|
833
|
+
"databaseId": string | number;
|
|
834
|
+
body: unknown;
|
|
835
|
+
}): Promise<any>;
|
|
836
|
+
};
|
|
837
|
+
/** `databases.reindex` — POST /databases/{databaseId}/reindex. Reindex a database */
|
|
838
|
+
"reindex"(args: {
|
|
839
|
+
"databaseId": string | number;
|
|
840
|
+
}): Promise<any>;
|
|
841
|
+
/** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{groupId}. Revoke a group permission on a database */
|
|
842
|
+
"revokeGroupPermission"(args: {
|
|
843
|
+
"databaseId": string | number;
|
|
844
|
+
"groupId": string | number;
|
|
845
|
+
"groupType"?: string | number | boolean;
|
|
846
|
+
}): Promise<any>;
|
|
847
|
+
/**
|
|
848
|
+
* `databases.revokeGroupPermissionByType` — DELETE /databases/{databaseId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a database, by type; use DELETE /databases/{databaseId}/group-permissions/{groupId} (removal: #4718)
|
|
849
|
+
* @deprecated Use DELETE /databases/{databaseId}/group-permissions/{groupId} (removal: #4718)
|
|
850
|
+
*/
|
|
851
|
+
"revokeGroupPermissionByType"(args: {
|
|
852
|
+
"databaseId": string | number;
|
|
853
|
+
"groupType": string | number;
|
|
854
|
+
"groupId": string | number;
|
|
855
|
+
}): Promise<any>;
|
|
856
|
+
/** `databases.revokePermission` — DELETE /databases/{databaseId}/permissions/{userId}. Remove a user's database permission */
|
|
857
|
+
"revokePermission"(args: {
|
|
858
|
+
"databaseId": string | number;
|
|
859
|
+
"userId": string | number;
|
|
860
|
+
}): Promise<any>;
|
|
861
|
+
/** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */
|
|
862
|
+
"transferOwnership"(args: {
|
|
863
|
+
"databaseId": string | number;
|
|
864
|
+
body: unknown;
|
|
865
|
+
}): Promise<any>;
|
|
866
|
+
/** `databases.update` — PATCH /databases/{databaseId}. Update a database */
|
|
867
|
+
"update"(args: {
|
|
868
|
+
"databaseId": string | number;
|
|
869
|
+
body: unknown;
|
|
870
|
+
}): Promise<any>;
|
|
871
|
+
};
|
|
872
|
+
"db3": {
|
|
873
|
+
/** `db3.abortIngest` — POST /db3/{db3Id}/ingest/{sessionId}/abort. Abort a db3 bulk load */
|
|
874
|
+
"abortIngest"(args: {
|
|
875
|
+
"db3Id": string | number;
|
|
876
|
+
"sessionId": string | number;
|
|
877
|
+
body: unknown;
|
|
878
|
+
}): Promise<any>;
|
|
879
|
+
/** `db3.addTag` — POST /db3/{db3Id}/tags. Add a tag to a db3 */
|
|
880
|
+
"addTag"(args: {
|
|
881
|
+
"db3Id": string | number;
|
|
882
|
+
body: unknown;
|
|
883
|
+
}): Promise<any>;
|
|
884
|
+
"aliases": {
|
|
885
|
+
/** `db3.aliases.listForDocument` — GET /db3/{db3Id}/aliases. List aliases bound to a db3 */
|
|
886
|
+
"listForDocument"(args: {
|
|
887
|
+
"db3Id": string | number;
|
|
888
|
+
}): Promise<any>;
|
|
889
|
+
};
|
|
890
|
+
/** `db3.approveAccessRequest` — POST /db3/{db3Id}/access-requests/{requestId}/approve. Approve a db3 access request */
|
|
891
|
+
"approveAccessRequest"(args: {
|
|
892
|
+
"db3Id": string | number;
|
|
893
|
+
"requestId": string | number;
|
|
894
|
+
body?: unknown;
|
|
895
|
+
}): Promise<any>;
|
|
896
|
+
"blobs": {
|
|
897
|
+
/** `db3.blobs.delete` — DELETE /db3/{db3Id}/blobs/{blobId}. Delete a db3 blob */
|
|
898
|
+
"delete"(args: {
|
|
899
|
+
"db3Id": string | number;
|
|
900
|
+
"blobId": string | number;
|
|
901
|
+
}): Promise<any>;
|
|
902
|
+
/** `db3.blobs.downloadHeaders` — HEAD /db3/{db3Id}/blobs/{blobId}/download. Get db3 blob download headers (ETag/304 support) */
|
|
903
|
+
"downloadHeaders"(args: {
|
|
904
|
+
"db3Id": string | number;
|
|
905
|
+
"blobId": string | number;
|
|
906
|
+
}): Promise<HeaderResult>;
|
|
907
|
+
/** `db3.blobs.downloadUrl` — GET /db3/{db3Id}/blobs/{blobId}/download. Download a db3 blob's bytes */
|
|
908
|
+
"downloadUrl"(args: {
|
|
909
|
+
"db3Id": string | number;
|
|
910
|
+
"blobId": string | number;
|
|
911
|
+
"disposition"?: string | number | boolean;
|
|
912
|
+
}): Promise<Uint8Array>;
|
|
913
|
+
/** `db3.blobs.get` — GET /db3/{db3Id}/blobs/{blobId}. Get a db3 blob's metadata */
|
|
914
|
+
"get"(args: {
|
|
915
|
+
"db3Id": string | number;
|
|
916
|
+
"blobId": string | number;
|
|
917
|
+
}): Promise<any>;
|
|
918
|
+
/** `db3.blobs.list` — GET /db3/{db3Id}/blobs. List blobs attached to a db3 */
|
|
919
|
+
"list"(args: {
|
|
920
|
+
"db3Id": string | number;
|
|
921
|
+
}): Promise<any>;
|
|
922
|
+
/** `db3.blobs.upload` — PUT /db3/{db3Id}/blobs/{blobId}. Upload a db3 blob with a client-specified id (immutable + idempotent) */
|
|
923
|
+
"upload"(args: {
|
|
924
|
+
"db3Id": string | number;
|
|
925
|
+
"blobId": string | number;
|
|
926
|
+
"X-Blob-Filename": string | number;
|
|
927
|
+
"X-Blob-Size": string | number;
|
|
928
|
+
"X-Blob-Sha256": string | number;
|
|
929
|
+
"Content-Type"?: string | number;
|
|
930
|
+
body: ArrayBuffer | Uint8Array | string;
|
|
931
|
+
}): Promise<any>;
|
|
932
|
+
};
|
|
933
|
+
/** `db3.clearLinkAccess` — DELETE /db3/{db3Id}/link-access. Turn off the db3's link access */
|
|
934
|
+
"clearLinkAccess"(args: {
|
|
935
|
+
"db3Id": string | number;
|
|
936
|
+
}): Promise<any>;
|
|
937
|
+
/** `db3.commitIngest` — POST /db3/{db3Id}/ingest/{sessionId}/commit. Commit a db3 bulk load: its rows apply in the background */
|
|
938
|
+
"commitIngest"(args: {
|
|
939
|
+
"db3Id": string | number;
|
|
940
|
+
"sessionId": string | number;
|
|
941
|
+
body: unknown;
|
|
942
|
+
}): Promise<any>;
|
|
943
|
+
/** `db3.create` — POST /db3. Create a db3 */
|
|
944
|
+
"create"(args: {
|
|
945
|
+
body: unknown;
|
|
946
|
+
}): Promise<any>;
|
|
947
|
+
/** `db3.createIngest` — POST /db3/{db3Id}/ingest. Open a bulk-load session on a db3 */
|
|
948
|
+
"createIngest"(args: {
|
|
949
|
+
"db3Id": string | number;
|
|
950
|
+
body: unknown;
|
|
951
|
+
}): Promise<any>;
|
|
952
|
+
/** `db3.delete` — DELETE /db3/{db3Id}. Delete a db3 */
|
|
953
|
+
"delete"(args: {
|
|
954
|
+
"db3Id": string | number;
|
|
955
|
+
}): Promise<any>;
|
|
956
|
+
/** `db3.denyAccessRequest` — POST /db3/{db3Id}/access-requests/{requestId}/deny. Deny a db3 access request */
|
|
957
|
+
"denyAccessRequest"(args: {
|
|
958
|
+
"db3Id": string | number;
|
|
959
|
+
"requestId": string | number;
|
|
960
|
+
body?: unknown;
|
|
961
|
+
}): Promise<any>;
|
|
962
|
+
/** `db3.exportChain` — GET /db3/{db3Id}/export/chain. Export a db3's chain: its current segment, signed for download */
|
|
963
|
+
"exportChain"(args: {
|
|
964
|
+
"db3Id": string | number;
|
|
965
|
+
}): Promise<any>;
|
|
966
|
+
/** `db3.get` — GET /db3/{db3Id}. Get a db3 */
|
|
967
|
+
"get"(args: {
|
|
968
|
+
"db3Id": string | number;
|
|
969
|
+
}): Promise<any>;
|
|
970
|
+
/** `db3.getAppAccess` — GET /db3/{db3Id}/app-access. Read a db3's app access */
|
|
971
|
+
"getAppAccess"(args: {
|
|
972
|
+
"db3Id": string | number;
|
|
973
|
+
}): Promise<any>;
|
|
974
|
+
/** `db3.getIngest` — GET /db3/{db3Id}/ingest/{sessionId}. Get one db3 bulk-load session */
|
|
975
|
+
"getIngest"(args: {
|
|
976
|
+
"db3Id": string | number;
|
|
977
|
+
"sessionId": string | number;
|
|
978
|
+
}): Promise<any>;
|
|
979
|
+
/** `db3.getLinkAccess` — GET /db3/{db3Id}/link-access. Get the db3's "anyone with the link" access level */
|
|
980
|
+
"getLinkAccess"(args: {
|
|
981
|
+
"db3Id": string | number;
|
|
982
|
+
}): Promise<any>;
|
|
983
|
+
/** `db3.getOrCreateWithAlias` — POST /db3/get-or-create-with-alias. Get the db3 bound to an alias, creating it if absent */
|
|
984
|
+
"getOrCreateWithAlias"(args: {
|
|
985
|
+
body: unknown;
|
|
986
|
+
}): Promise<any>;
|
|
987
|
+
/** `db3.getPermissions` — GET /db3/{db3Id}/permissions. List a db3's user permissions */
|
|
988
|
+
"getPermissions"(args: {
|
|
989
|
+
"db3Id": string | number;
|
|
990
|
+
}): Promise<any>;
|
|
991
|
+
/** `db3.getSchema` — GET /db3/{db3Id}/schema. Introspect a db3's model schema */
|
|
992
|
+
"getSchema"(args: {
|
|
993
|
+
"db3Id": string | number;
|
|
994
|
+
}): Promise<any>;
|
|
995
|
+
/** `db3.getSnapshot` — GET /db3/{db3Id}/snapshots/{buildId}. Get one of a db3's segment exports */
|
|
996
|
+
"getSnapshot"(args: {
|
|
997
|
+
"db3Id": string | number;
|
|
998
|
+
"buildId": string | number;
|
|
999
|
+
}): Promise<any>;
|
|
1000
|
+
/** `db3.getStats` — GET /db3/{db3Id}/stats. Get a db3's stats */
|
|
1001
|
+
"getStats"(args: {
|
|
1002
|
+
"db3Id": string | number;
|
|
1003
|
+
}): Promise<any>;
|
|
1004
|
+
/** `db3.getSync` — GET /db3/{db3Id}/sync. Read whether a db3 is synced */
|
|
1005
|
+
"getSync"(args: {
|
|
1006
|
+
"db3Id": string | number;
|
|
1007
|
+
}): Promise<any>;
|
|
1008
|
+
/** `db3.getType` — GET /db3/{db3Id}/type. Read a db3's type */
|
|
1009
|
+
"getType"(args: {
|
|
1010
|
+
"db3Id": string | number;
|
|
1011
|
+
}): Promise<any>;
|
|
1012
|
+
/** `db3.grantGroupPermission` — POST /db3/{db3Id}/group-permissions. Grant a group permission on a db3 */
|
|
1013
|
+
"grantGroupPermission"(args: {
|
|
1014
|
+
"db3Id": string | number;
|
|
1015
|
+
body: unknown;
|
|
1016
|
+
}): Promise<any>;
|
|
1017
|
+
"indexes": {
|
|
1018
|
+
/** `db3.indexes.drop` — DELETE /db3/{db3Id}/indexes/{name}. Drop a db3's registered index */
|
|
1019
|
+
"drop"(args: {
|
|
1020
|
+
"db3Id": string | number;
|
|
1021
|
+
"name": string | number;
|
|
1022
|
+
}): Promise<any>;
|
|
1023
|
+
/** `db3.indexes.list` — GET /db3/{db3Id}/indexes. List a db3's indexes */
|
|
1024
|
+
"list"(args: {
|
|
1025
|
+
"db3Id": string | number;
|
|
1026
|
+
}): Promise<any>;
|
|
1027
|
+
/** `db3.indexes.register` — POST /db3/{db3Id}/indexes. Register an index on a db3 */
|
|
1028
|
+
"register"(args: {
|
|
1029
|
+
"db3Id": string | number;
|
|
1030
|
+
body: unknown;
|
|
1031
|
+
}): Promise<any>;
|
|
1032
|
+
};
|
|
1033
|
+
/** `db3.listAccessRequests` — GET /db3/{db3Id}/access-requests. List access requests for a db3 */
|
|
1034
|
+
"listAccessRequests"(args: {
|
|
1035
|
+
"db3Id": string | number;
|
|
1036
|
+
}): Promise<any>;
|
|
1037
|
+
/** `db3.listGroupPermissions` — GET /db3/{db3Id}/group-permissions. List a db3's group permissions */
|
|
1038
|
+
"listGroupPermissions"(args: {
|
|
1039
|
+
"db3Id": string | number;
|
|
1040
|
+
}): Promise<any>;
|
|
1041
|
+
/** `db3.listIngests` — GET /db3/{db3Id}/ingest. List a db3's bulk-load sessions, newest first */
|
|
1042
|
+
"listIngests"(args: {
|
|
1043
|
+
"db3Id": string | number;
|
|
1044
|
+
"limit"?: string | number | boolean;
|
|
1045
|
+
"cursor"?: string | number | boolean;
|
|
1046
|
+
}): Promise<any>;
|
|
1047
|
+
/** `db3.listPendingInvitations` — GET /db3/{db3Id}/pending-invitations. List a db3's pending (deferred) invitations */
|
|
1048
|
+
"listPendingInvitations"(args: {
|
|
1049
|
+
"db3Id": string | number;
|
|
1050
|
+
}): Promise<any>;
|
|
1051
|
+
/** `db3.listSnapshots` — GET /db3/{db3Id}/snapshots. List a db3's segment exports, newest first */
|
|
1052
|
+
"listSnapshots"(args: {
|
|
1053
|
+
"db3Id": string | number;
|
|
1054
|
+
"limit"?: string | number | boolean;
|
|
1055
|
+
"cursor"?: string | number | boolean;
|
|
1056
|
+
}): Promise<any>;
|
|
1057
|
+
"records": {
|
|
1058
|
+
/** `db3.records.aggregate` — POST /db3/{db3Id}/records/{model}/aggregate. Aggregate records in a db3 model */
|
|
1059
|
+
"aggregate"(args: {
|
|
1060
|
+
"db3Id": string | number;
|
|
1061
|
+
"model": string | number;
|
|
1062
|
+
"userId"?: string | number;
|
|
1063
|
+
body: unknown;
|
|
1064
|
+
}): Promise<any>;
|
|
1065
|
+
/** `db3.records.bulk` — POST /db3/{db3Id}/records/bulk. Apply an atomic multi-model record blob to a db3 (create/patch/delete/upsert) */
|
|
1066
|
+
"bulk"(args: {
|
|
1067
|
+
"db3Id": string | number;
|
|
1068
|
+
"userId"?: string | number;
|
|
1069
|
+
body: unknown;
|
|
1070
|
+
}): Promise<any>;
|
|
1071
|
+
/** `db3.records.count` — GET /db3/{db3Id}/records/{model}/count. Count records in a db3 model */
|
|
1072
|
+
"count"(args: {
|
|
1073
|
+
"db3Id": string | number;
|
|
1074
|
+
"model": string | number;
|
|
1075
|
+
"userId"?: string | number;
|
|
1076
|
+
"filter"?: Record<string, unknown> | string;
|
|
1077
|
+
}): Promise<any>;
|
|
1078
|
+
/** `db3.records.delete` — DELETE /db3/{db3Id}/records/{model}/{recordId}. Delete a record from a db3 model */
|
|
1079
|
+
"delete"(args: {
|
|
1080
|
+
"db3Id": string | number;
|
|
1081
|
+
"model": string | number;
|
|
1082
|
+
"recordId": string | number;
|
|
1083
|
+
"requestId"?: string | number | boolean;
|
|
1084
|
+
"condition"?: string | number | boolean;
|
|
1085
|
+
"userId"?: string | number;
|
|
1086
|
+
}): Promise<any>;
|
|
1087
|
+
/** `db3.records.increment` — POST /db3/{db3Id}/records/{model}/{recordId}/increment. Increment numeric fields of a record in a db3 model */
|
|
1088
|
+
"increment"(args: {
|
|
1089
|
+
"db3Id": string | number;
|
|
1090
|
+
"model": string | number;
|
|
1091
|
+
"recordId": string | number;
|
|
1092
|
+
"userId"?: string | number;
|
|
655
1093
|
body: unknown;
|
|
656
1094
|
}): Promise<any>;
|
|
657
|
-
/** `
|
|
658
|
-
"
|
|
659
|
-
"
|
|
1095
|
+
/** `db3.records.patch` — PATCH /db3/{db3Id}/records/{model}/{recordId}. Merge fields into an existing record in a db3 model */
|
|
1096
|
+
"patch"(args: {
|
|
1097
|
+
"db3Id": string | number;
|
|
1098
|
+
"model": string | number;
|
|
1099
|
+
"recordId": string | number;
|
|
1100
|
+
"userId"?: string | number;
|
|
660
1101
|
body: unknown;
|
|
661
1102
|
}): Promise<any>;
|
|
662
|
-
/** `
|
|
663
|
-
"
|
|
664
|
-
"
|
|
665
|
-
|
|
1103
|
+
/** `db3.records.query` — GET /db3/{db3Id}/records/{model}. Query records in a db3 model */
|
|
1104
|
+
"query"(args: {
|
|
1105
|
+
"db3Id": string | number;
|
|
1106
|
+
"model": string | number;
|
|
1107
|
+
"limit"?: string | number | boolean;
|
|
1108
|
+
"cursor"?: string | number | boolean;
|
|
1109
|
+
"userId"?: string | number;
|
|
1110
|
+
"filter"?: Record<string, unknown> | string;
|
|
1111
|
+
"sort"?: Record<string, unknown> | string;
|
|
1112
|
+
"include"?: unknown[] | string;
|
|
666
1113
|
}): Promise<any>;
|
|
667
|
-
/** `
|
|
1114
|
+
/** `db3.records.save` — POST /db3/{db3Id}/records/{model}. Create or replace a record in a db3 model */
|
|
668
1115
|
"save"(args: {
|
|
669
|
-
"
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (requires manager-or-higher on the database, or an app-admin/owner role) */
|
|
673
|
-
"syncIndexes"(args: {
|
|
674
|
-
"databaseId": string | number;
|
|
1116
|
+
"db3Id": string | number;
|
|
1117
|
+
"model": string | number;
|
|
1118
|
+
"userId"?: string | number;
|
|
675
1119
|
body: unknown;
|
|
676
1120
|
}): Promise<any>;
|
|
677
1121
|
};
|
|
678
|
-
/** `
|
|
679
|
-
"
|
|
680
|
-
"
|
|
1122
|
+
/** `db3.removePermissionByEmail` — DELETE /db3/{db3Id}/permissions. Revoke a user's permission on a db3 by email (?email=) */
|
|
1123
|
+
"removePermissionByEmail"(args: {
|
|
1124
|
+
"db3Id": string | number;
|
|
1125
|
+
"email"?: string | number | boolean;
|
|
1126
|
+
}): Promise<any>;
|
|
1127
|
+
/** `db3.removePermissionByUserId` — DELETE /db3/{db3Id}/permissions/{userId}. Revoke a user's permission on a db3 by user id */
|
|
1128
|
+
"removePermissionByUserId"(args: {
|
|
1129
|
+
"db3Id": string | number;
|
|
1130
|
+
"userId": string | number;
|
|
1131
|
+
}): Promise<any>;
|
|
1132
|
+
/** `db3.removeTag` — DELETE /db3/{db3Id}/tags/{tag}. Remove a tag from a db3 */
|
|
1133
|
+
"removeTag"(args: {
|
|
1134
|
+
"db3Id": string | number;
|
|
1135
|
+
"tag": string | number;
|
|
1136
|
+
}): Promise<any>;
|
|
1137
|
+
/** `db3.requestAccess` — POST /db3/{db3Id}/access-requests. Request access to a db3 */
|
|
1138
|
+
"requestAccess"(args: {
|
|
1139
|
+
"db3Id": string | number;
|
|
1140
|
+
body: unknown;
|
|
1141
|
+
}): Promise<any>;
|
|
1142
|
+
/** `db3.requestSnapshot` — POST /db3/{db3Id}/snapshots. Start a segment export of a db3 now */
|
|
1143
|
+
"requestSnapshot"(args: {
|
|
1144
|
+
"db3Id": string | number;
|
|
1145
|
+
body: unknown;
|
|
681
1146
|
}): Promise<any>;
|
|
682
|
-
/** `
|
|
1147
|
+
/** `db3.revokeGroupPermission` — DELETE /db3/{db3Id}/group-permissions/{groupId}. Revoke a group permission on a db3 */
|
|
683
1148
|
"revokeGroupPermission"(args: {
|
|
684
|
-
"
|
|
685
|
-
"groupType": string | number;
|
|
1149
|
+
"db3Id": string | number;
|
|
686
1150
|
"groupId": string | number;
|
|
1151
|
+
"groupType"?: string | number | boolean;
|
|
687
1152
|
}): Promise<any>;
|
|
688
|
-
/** `
|
|
689
|
-
"
|
|
690
|
-
"
|
|
691
|
-
"
|
|
1153
|
+
/** `db3.room` — GET /db3/{db3Id}/room. Inspect a db3's room */
|
|
1154
|
+
"room"(args: {
|
|
1155
|
+
"db3Id": string | number;
|
|
1156
|
+
"refused"?: string | number | boolean;
|
|
1157
|
+
"limit"?: string | number | boolean;
|
|
1158
|
+
"cursor"?: string | number | boolean;
|
|
692
1159
|
}): Promise<any>;
|
|
693
|
-
/** `
|
|
694
|
-
"
|
|
695
|
-
"
|
|
696
|
-
|
|
697
|
-
body?: unknown;
|
|
1160
|
+
/** `db3.setAppAccess` — PUT /db3/{db3Id}/app-access. Grant a db3 to every user of the app */
|
|
1161
|
+
"setAppAccess"(args: {
|
|
1162
|
+
"db3Id": string | number;
|
|
1163
|
+
body: unknown;
|
|
698
1164
|
}): Promise<any>;
|
|
699
|
-
/** `
|
|
700
|
-
"
|
|
701
|
-
"
|
|
1165
|
+
/** `db3.setLinkAccess` — PUT /db3/{db3Id}/link-access. Set the db3's "anyone with the link" access level */
|
|
1166
|
+
"setLinkAccess"(args: {
|
|
1167
|
+
"db3Id": string | number;
|
|
702
1168
|
body: unknown;
|
|
703
1169
|
}): Promise<any>;
|
|
704
|
-
/** `
|
|
705
|
-
"
|
|
706
|
-
"
|
|
1170
|
+
/** `db3.setOwnerRow` — PUT /db3/{db3Id}/owner-row. Remove or restore a db3's owner row */
|
|
1171
|
+
"setOwnerRow"(args: {
|
|
1172
|
+
"db3Id": string | number;
|
|
707
1173
|
body: unknown;
|
|
708
1174
|
}): Promise<any>;
|
|
709
|
-
/**
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
1175
|
+
/** `db3.setSync` — PUT /db3/{db3Id}/sync. Turn a db3's sync on or off */
|
|
1176
|
+
"setSync"(args: {
|
|
1177
|
+
"db3Id": string | number;
|
|
1178
|
+
body: unknown;
|
|
1179
|
+
}): Promise<any>;
|
|
1180
|
+
/** `db3.setType` — PUT /db3/{db3Id}/type. Attach a type to a db3 */
|
|
1181
|
+
"setType"(args: {
|
|
1182
|
+
"db3Id": string | number;
|
|
1183
|
+
body: unknown;
|
|
1184
|
+
}): Promise<any>;
|
|
1185
|
+
/** `db3.transfer` — POST /db3/{db3Id}/transfer. Transfer a db3 to another user or to the app */
|
|
1186
|
+
"transfer"(args: {
|
|
1187
|
+
"db3Id": string | number;
|
|
1188
|
+
body: unknown;
|
|
1189
|
+
}): Promise<any>;
|
|
1190
|
+
/** `db3.updatePermissions` — PUT /db3/{db3Id}/permissions. Grant or update a user's permission on a db3 */
|
|
1191
|
+
"updatePermissions"(args: {
|
|
1192
|
+
"db3Id": string | number;
|
|
715
1193
|
body: unknown;
|
|
716
1194
|
}): Promise<any>;
|
|
1195
|
+
/** `db3.uploadIngestChunk` — POST /db3/{db3Id}/ingest/{sessionId}/chunks. Upload one chunk of a db3 bulk load */
|
|
1196
|
+
"uploadIngestChunk"(args: {
|
|
1197
|
+
"db3Id": string | number;
|
|
1198
|
+
"sessionId": string | number;
|
|
1199
|
+
body: FormData | ArrayBuffer | Uint8Array | string;
|
|
1200
|
+
}): Promise<any>;
|
|
1201
|
+
/** `db3.validateAccess` — POST /db3/{db3Id}/validate-access. Resolve effective access to a db3, for the caller or a named user */
|
|
1202
|
+
"validateAccess"(args: {
|
|
1203
|
+
"db3Id": string | number;
|
|
1204
|
+
body?: unknown;
|
|
1205
|
+
}): Promise<any>;
|
|
717
1206
|
};
|
|
718
1207
|
"documents": {
|
|
719
1208
|
/** `documents.abortIngest` — POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */
|
|
@@ -732,7 +1221,7 @@ export interface FunctionApi {
|
|
|
732
1221
|
"delete"(args: {
|
|
733
1222
|
"scope": string | number;
|
|
734
1223
|
"aliasKey": string | number;
|
|
735
|
-
"userId"?: string | number
|
|
1224
|
+
"userId"?: string | number;
|
|
736
1225
|
}): Promise<any>;
|
|
737
1226
|
/** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
|
|
738
1227
|
"listForDocument"(args: {
|
|
@@ -742,7 +1231,7 @@ export interface FunctionApi {
|
|
|
742
1231
|
"resolve"(args: {
|
|
743
1232
|
"scope": string | number;
|
|
744
1233
|
"aliasKey": string | number;
|
|
745
|
-
"userId"?: string | number
|
|
1234
|
+
"userId"?: string | number;
|
|
746
1235
|
}): Promise<any>;
|
|
747
1236
|
/** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
|
|
748
1237
|
"set"(args: {
|
|
@@ -790,6 +1279,7 @@ export interface FunctionApi {
|
|
|
790
1279
|
"X-Blob-Filename": string | number;
|
|
791
1280
|
"X-Blob-Size": string | number;
|
|
792
1281
|
"X-Blob-Sha256": string | number;
|
|
1282
|
+
"Content-Type"?: string | number;
|
|
793
1283
|
body: ArrayBuffer | Uint8Array | string;
|
|
794
1284
|
}): Promise<any>;
|
|
795
1285
|
};
|
|
@@ -938,10 +1428,26 @@ export interface FunctionApi {
|
|
|
938
1428
|
"limit"?: string | number | boolean;
|
|
939
1429
|
"cursor"?: string | number | boolean;
|
|
940
1430
|
}): Promise<any>;
|
|
1431
|
+
/** `documents.listOwnedByUser` — GET /users/{userId}/owned-documents. List the documents an app user owns */
|
|
1432
|
+
"listOwnedByUser"(args: {
|
|
1433
|
+
"userId": string | number;
|
|
1434
|
+
"limit"?: string | number | boolean;
|
|
1435
|
+
"cursor"?: string | number | boolean;
|
|
1436
|
+
"tag"?: string | number | boolean;
|
|
1437
|
+
"includeRoot"?: string | number | boolean;
|
|
1438
|
+
"forward"?: string | number | boolean;
|
|
1439
|
+
}): Promise<any>;
|
|
941
1440
|
/** `documents.listPendingInvitations` — GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */
|
|
942
1441
|
"listPendingInvitations"(args: {
|
|
943
1442
|
"documentId": string | number;
|
|
944
1443
|
}): Promise<any>;
|
|
1444
|
+
/** `documents.listSharedWithUser` — GET /users/{userId}/shared-documents. List the documents directly shared with an app user */
|
|
1445
|
+
"listSharedWithUser"(args: {
|
|
1446
|
+
"userId": string | number;
|
|
1447
|
+
"limit"?: string | number | boolean;
|
|
1448
|
+
"cursor"?: string | number | boolean;
|
|
1449
|
+
"tag"?: string | number | boolean;
|
|
1450
|
+
}): Promise<any>;
|
|
945
1451
|
/** `documents.listSnapshots` — GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */
|
|
946
1452
|
"listSnapshots"(args: {
|
|
947
1453
|
"documentId": string | number;
|
|
@@ -960,7 +1466,7 @@ export interface FunctionApi {
|
|
|
960
1466
|
"documentFormat"?: string | number | boolean;
|
|
961
1467
|
body: unknown;
|
|
962
1468
|
}): Promise<any>;
|
|
963
|
-
/** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete) */
|
|
1469
|
+
/** `documents.records.bulk` — POST /documents/{documentId}/records/bulk. Apply an atomic multi-model record blob to a document (create/patch/delete/upsert) */
|
|
964
1470
|
"bulk"(args: {
|
|
965
1471
|
"documentId": string | number;
|
|
966
1472
|
"documentFormat"?: string | number | boolean;
|
|
@@ -979,6 +1485,8 @@ export interface FunctionApi {
|
|
|
979
1485
|
"model": string | number;
|
|
980
1486
|
"recordId": string | number;
|
|
981
1487
|
"documentFormat"?: string | number | boolean;
|
|
1488
|
+
"requestId"?: string | number | boolean;
|
|
1489
|
+
"condition"?: string | number | boolean;
|
|
982
1490
|
}): Promise<any>;
|
|
983
1491
|
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
984
1492
|
"patch"(args: {
|
|
@@ -996,6 +1504,8 @@ export interface FunctionApi {
|
|
|
996
1504
|
"limit"?: string | number | boolean;
|
|
997
1505
|
"cursor"?: string | number | boolean;
|
|
998
1506
|
"filter"?: Record<string, unknown> | string;
|
|
1507
|
+
"sort"?: Record<string, unknown> | string;
|
|
1508
|
+
"include"?: unknown[] | string;
|
|
999
1509
|
}): Promise<any>;
|
|
1000
1510
|
/** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */
|
|
1001
1511
|
"save"(args: {
|
|
@@ -1030,12 +1540,28 @@ export interface FunctionApi {
|
|
|
1030
1540
|
"documentId": string | number;
|
|
1031
1541
|
body: unknown;
|
|
1032
1542
|
}): Promise<any>;
|
|
1033
|
-
/** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{
|
|
1543
|
+
/** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupId}. Revoke a group permission on a document */
|
|
1034
1544
|
"revokeGroupPermission"(args: {
|
|
1545
|
+
"documentId": string | number;
|
|
1546
|
+
"groupId": string | number;
|
|
1547
|
+
"groupType"?: string | number | boolean;
|
|
1548
|
+
}): Promise<any>;
|
|
1549
|
+
/**
|
|
1550
|
+
* `documents.revokeGroupPermissionByType` — DELETE /documents/{documentId}/group-permissions/{groupType}/{groupId}. DEPRECATED — Revoke a group permission on a document, by type; use DELETE /documents/{documentId}/group-permissions/{groupId} (removal: #4718)
|
|
1551
|
+
* @deprecated Use DELETE /documents/{documentId}/group-permissions/{groupId} (removal: #4718)
|
|
1552
|
+
*/
|
|
1553
|
+
"revokeGroupPermissionByType"(args: {
|
|
1035
1554
|
"documentId": string | number;
|
|
1036
1555
|
"groupType": string | number;
|
|
1037
1556
|
"groupId": string | number;
|
|
1038
1557
|
}): Promise<any>;
|
|
1558
|
+
/** `documents.room` — GET /documents/{documentId}/room. Inspect a record-log document's room */
|
|
1559
|
+
"room"(args: {
|
|
1560
|
+
"documentId": string | number;
|
|
1561
|
+
"refused"?: string | number | boolean;
|
|
1562
|
+
"limit"?: string | number | boolean;
|
|
1563
|
+
"cursor"?: string | number | boolean;
|
|
1564
|
+
}): Promise<any>;
|
|
1039
1565
|
/** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's "anyone with the link" access level */
|
|
1040
1566
|
"setLinkAccess"(args: {
|
|
1041
1567
|
"documentId": string | number;
|
|
@@ -1075,7 +1601,17 @@ export interface FunctionApi {
|
|
|
1075
1601
|
}): Promise<any>;
|
|
1076
1602
|
};
|
|
1077
1603
|
"functions": {
|
|
1078
|
-
/** `functions.
|
|
1604
|
+
/** `functions.getStatus` — GET /functions/runs/{runId}/status. Get the status of a function run by run id */
|
|
1605
|
+
"getStatus"(args: {
|
|
1606
|
+
"runId": string | number;
|
|
1607
|
+
}): Promise<any>;
|
|
1608
|
+
/** `functions.getStatusByRunKey` — GET /functions/{functionKey}/instances/{runKey}/status. Get the status of a function run by run key */
|
|
1609
|
+
"getStatusByRunKey"(args: {
|
|
1610
|
+
"functionKey": string | number;
|
|
1611
|
+
"runKey": string | number;
|
|
1612
|
+
"contextDocId"?: string | number | boolean;
|
|
1613
|
+
}): Promise<any>;
|
|
1614
|
+
/** `functions.invoke` — POST /functions/{functionKey}. Invoke a server function and answer its result */
|
|
1079
1615
|
"invoke"(args: {
|
|
1080
1616
|
"functionKey": string | number;
|
|
1081
1617
|
body?: unknown;
|
|
@@ -1085,6 +1621,19 @@ export interface FunctionApi {
|
|
|
1085
1621
|
"functionKey": string | number;
|
|
1086
1622
|
body?: unknown;
|
|
1087
1623
|
}): Promise<any>;
|
|
1624
|
+
/** `functions.listRunSteps` — GET /functions/runs/{runId}/steps. List a function run's steps, oldest first */
|
|
1625
|
+
"listRunSteps"(args: {
|
|
1626
|
+
"runId": string | number;
|
|
1627
|
+
}): Promise<any>;
|
|
1628
|
+
/** `functions.listRuns` — GET /functions/runs. List the caller's own function runs */
|
|
1629
|
+
"listRuns"(args?: {
|
|
1630
|
+
"functionKey"?: string | number | boolean;
|
|
1631
|
+
"contextDocId"?: string | number | boolean;
|
|
1632
|
+
"status"?: string | number | boolean;
|
|
1633
|
+
"limit"?: string | number | boolean;
|
|
1634
|
+
"cursor"?: string | number | boolean;
|
|
1635
|
+
"forward"?: string | number | boolean;
|
|
1636
|
+
}): Promise<any>;
|
|
1088
1637
|
/** `functions.logs` — GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */
|
|
1089
1638
|
"logs"(args: {
|
|
1090
1639
|
"functionKey": string | number;
|
|
@@ -1097,10 +1646,30 @@ export interface FunctionApi {
|
|
|
1097
1646
|
"functionKey": string | number;
|
|
1098
1647
|
body?: unknown;
|
|
1099
1648
|
}): Promise<any>;
|
|
1649
|
+
/** `functions.startAsSystem` — POST /functions/{functionKey}/start-as-system. Start a server function as a task run, as the system */
|
|
1650
|
+
"startAsSystem"(args: {
|
|
1651
|
+
"functionKey": string | number;
|
|
1652
|
+
body?: unknown;
|
|
1653
|
+
}): Promise<any>;
|
|
1654
|
+
/** `functions.terminate` — POST /functions/{functionKey}/instances/{runKey}/terminate. Terminate a function run */
|
|
1655
|
+
"terminate"(args: {
|
|
1656
|
+
"functionKey": string | number;
|
|
1657
|
+
"runKey": string | number;
|
|
1658
|
+
"contextDocId"?: string | number | boolean;
|
|
1659
|
+
}): Promise<any>;
|
|
1100
1660
|
};
|
|
1101
1661
|
"groups": {
|
|
1102
|
-
/** `groups.addMember` — POST /groups/{
|
|
1662
|
+
/** `groups.addMember` — POST /groups/{groupId}/members. Add a member to a group */
|
|
1103
1663
|
"addMember"(args: {
|
|
1664
|
+
"groupId": string | number;
|
|
1665
|
+
"groupType"?: string | number | boolean;
|
|
1666
|
+
body: unknown;
|
|
1667
|
+
}): Promise<any>;
|
|
1668
|
+
/**
|
|
1669
|
+
* `groups.addMemberByType` — POST /groups/{groupType}/{groupId}/members. DEPRECATED — Add a member to a group, by type; use POST /groups/{groupId}/members (removal: #4718)
|
|
1670
|
+
* @deprecated Use POST /groups/{groupId}/members (removal: #4718)
|
|
1671
|
+
*/
|
|
1672
|
+
"addMemberByType"(args: {
|
|
1104
1673
|
"groupType": string | number;
|
|
1105
1674
|
"groupId": string | number;
|
|
1106
1675
|
body: unknown;
|
|
@@ -1109,13 +1678,29 @@ export interface FunctionApi {
|
|
|
1109
1678
|
"create"(args: {
|
|
1110
1679
|
body: unknown;
|
|
1111
1680
|
}): Promise<any>;
|
|
1112
|
-
/** `groups.delete` — DELETE /groups/{
|
|
1681
|
+
/** `groups.delete` — DELETE /groups/{groupId}. Delete a group */
|
|
1113
1682
|
"delete"(args: {
|
|
1683
|
+
"groupId": string | number;
|
|
1684
|
+
"groupType"?: string | number | boolean;
|
|
1685
|
+
}): Promise<any>;
|
|
1686
|
+
/**
|
|
1687
|
+
* `groups.deleteByType` — DELETE /groups/{groupType}/{groupId}. DEPRECATED — Delete a group, by type; use DELETE /groups/{groupId} (removal: #4718)
|
|
1688
|
+
* @deprecated Use DELETE /groups/{groupId} (removal: #4718)
|
|
1689
|
+
*/
|
|
1690
|
+
"deleteByType"(args: {
|
|
1114
1691
|
"groupType": string | number;
|
|
1115
1692
|
"groupId": string | number;
|
|
1116
1693
|
}): Promise<any>;
|
|
1117
|
-
/** `groups.get` — GET /groups/{
|
|
1694
|
+
/** `groups.get` — GET /groups/{groupId}. Get a group */
|
|
1118
1695
|
"get"(args: {
|
|
1696
|
+
"groupId": string | number;
|
|
1697
|
+
"groupType"?: string | number | boolean;
|
|
1698
|
+
}): Promise<any>;
|
|
1699
|
+
/**
|
|
1700
|
+
* `groups.getByType` — GET /groups/{groupType}/{groupId}. DEPRECATED — Get a group, by type; use GET /groups/{groupId} (removal: #4718)
|
|
1701
|
+
* @deprecated Use GET /groups/{groupId} (removal: #4718)
|
|
1702
|
+
*/
|
|
1703
|
+
"getByType"(args: {
|
|
1119
1704
|
"groupType": string | number;
|
|
1120
1705
|
"groupId": string | number;
|
|
1121
1706
|
}): Promise<any>;
|
|
@@ -1126,26 +1711,84 @@ export interface FunctionApi {
|
|
|
1126
1711
|
"limit"?: string | number | boolean;
|
|
1127
1712
|
"cursor"?: string | number | boolean;
|
|
1128
1713
|
}): Promise<any>;
|
|
1129
|
-
/** `groups.
|
|
1714
|
+
/** `groups.listByCustodian` — GET /holdings/groups. List the groups one custodian holds, from a server function */
|
|
1715
|
+
"listByCustodian"(args?: {
|
|
1716
|
+
"custodian"?: string | number | boolean;
|
|
1717
|
+
"limit"?: string | number | boolean;
|
|
1718
|
+
"cursor"?: string | number | boolean;
|
|
1719
|
+
}): Promise<any>;
|
|
1720
|
+
/** `groups.listDatabases` — GET /groups/{groupId}/databases. List databases shared with a group */
|
|
1130
1721
|
"listDatabases"(args: {
|
|
1722
|
+
"groupId": string | number;
|
|
1723
|
+
"groupType"?: string | number | boolean;
|
|
1724
|
+
}): Promise<any>;
|
|
1725
|
+
/**
|
|
1726
|
+
* `groups.listDatabasesByType` — GET /groups/{groupType}/{groupId}/databases. DEPRECATED — List databases shared with a group, by type; use GET /groups/{groupId}/databases (removal: #4718)
|
|
1727
|
+
* @deprecated Use GET /groups/{groupId}/databases (removal: #4718)
|
|
1728
|
+
*/
|
|
1729
|
+
"listDatabasesByType"(args: {
|
|
1730
|
+
"groupType": string | number;
|
|
1731
|
+
"groupId": string | number;
|
|
1732
|
+
}): Promise<any>;
|
|
1733
|
+
/** `groups.listDb3` — GET /groups/{groupId}/db3. List db3s shared with a group */
|
|
1734
|
+
"listDb3"(args: {
|
|
1735
|
+
"groupId": string | number;
|
|
1736
|
+
"limit"?: string | number | boolean;
|
|
1737
|
+
"cursor"?: string | number | boolean;
|
|
1738
|
+
"groupType"?: string | number | boolean;
|
|
1739
|
+
}): Promise<any>;
|
|
1740
|
+
/**
|
|
1741
|
+
* `groups.listDb3ByType` — GET /groups/{groupType}/{groupId}/db3. DEPRECATED — List db3s shared with a group, by type; use GET /groups/{groupId}/db3 (removal: #4718)
|
|
1742
|
+
* @deprecated Use GET /groups/{groupId}/db3 (removal: #4718)
|
|
1743
|
+
*/
|
|
1744
|
+
"listDb3ByType"(args: {
|
|
1131
1745
|
"groupType": string | number;
|
|
1132
1746
|
"groupId": string | number;
|
|
1747
|
+
"limit"?: string | number | boolean;
|
|
1748
|
+
"cursor"?: string | number | boolean;
|
|
1133
1749
|
}): Promise<any>;
|
|
1134
|
-
/** `groups.listDocuments` — GET /groups/{
|
|
1750
|
+
/** `groups.listDocuments` — GET /groups/{groupId}/documents. List documents shared with a group */
|
|
1135
1751
|
"listDocuments"(args: {
|
|
1752
|
+
"groupId": string | number;
|
|
1753
|
+
"groupType"?: string | number | boolean;
|
|
1754
|
+
}): Promise<any>;
|
|
1755
|
+
/**
|
|
1756
|
+
* `groups.listDocumentsByType` — GET /groups/{groupType}/{groupId}/documents. DEPRECATED — List documents shared with a group, by type; use GET /groups/{groupId}/documents (removal: #4718)
|
|
1757
|
+
* @deprecated Use GET /groups/{groupId}/documents (removal: #4718)
|
|
1758
|
+
*/
|
|
1759
|
+
"listDocumentsByType"(args: {
|
|
1136
1760
|
"groupType": string | number;
|
|
1137
1761
|
"groupId": string | number;
|
|
1138
1762
|
}): Promise<any>;
|
|
1139
|
-
/** `groups.listMembers` — GET /groups/{
|
|
1763
|
+
/** `groups.listMembers` — GET /groups/{groupId}/members. List a group's members */
|
|
1140
1764
|
"listMembers"(args: {
|
|
1765
|
+
"groupId": string | number;
|
|
1766
|
+
"limit"?: string | number | boolean;
|
|
1767
|
+
"cursor"?: string | number | boolean;
|
|
1768
|
+
"include"?: string | number | boolean;
|
|
1769
|
+
"groupType"?: string | number | boolean;
|
|
1770
|
+
}): Promise<any>;
|
|
1771
|
+
/**
|
|
1772
|
+
* `groups.listMembersByType` — GET /groups/{groupType}/{groupId}/members. DEPRECATED — List a group's members, by type; use GET /groups/{groupId}/members (removal: #4718)
|
|
1773
|
+
* @deprecated Use GET /groups/{groupId}/members (removal: #4718)
|
|
1774
|
+
*/
|
|
1775
|
+
"listMembersByType"(args: {
|
|
1141
1776
|
"groupType": string | number;
|
|
1142
1777
|
"groupId": string | number;
|
|
1143
1778
|
"limit"?: string | number | boolean;
|
|
1144
1779
|
"cursor"?: string | number | boolean;
|
|
1145
1780
|
"include"?: string | number | boolean;
|
|
1146
1781
|
}): Promise<any>;
|
|
1147
|
-
/** `groups.listPendingInvitations` — GET /groups/{
|
|
1782
|
+
/** `groups.listPendingInvitations` — GET /groups/{groupId}/pending-invitations. List a group's pending invitations */
|
|
1148
1783
|
"listPendingInvitations"(args: {
|
|
1784
|
+
"groupId": string | number;
|
|
1785
|
+
"groupType"?: string | number | boolean;
|
|
1786
|
+
}): Promise<any>;
|
|
1787
|
+
/**
|
|
1788
|
+
* `groups.listPendingInvitationsByType` — GET /groups/{groupType}/{groupId}/pending-invitations. DEPRECATED — List a group's pending invitations, by type; use GET /groups/{groupId}/pending-invitations (removal: #4718)
|
|
1789
|
+
* @deprecated Use GET /groups/{groupId}/pending-invitations (removal: #4718)
|
|
1790
|
+
*/
|
|
1791
|
+
"listPendingInvitationsByType"(args: {
|
|
1149
1792
|
"groupType": string | number;
|
|
1150
1793
|
"groupId": string | number;
|
|
1151
1794
|
}): Promise<any>;
|
|
@@ -1155,20 +1798,60 @@ export interface FunctionApi {
|
|
|
1155
1798
|
"includeSystem"?: string | number | boolean;
|
|
1156
1799
|
"type"?: string | number | boolean;
|
|
1157
1800
|
}): Promise<any>;
|
|
1158
|
-
/** `groups.removeMember` — DELETE /groups/{
|
|
1801
|
+
/** `groups.removeMember` — DELETE /groups/{groupId}/members/{userId}. Remove a specific member from a group */
|
|
1159
1802
|
"removeMember"(args: {
|
|
1160
|
-
"groupType": string | number;
|
|
1161
1803
|
"groupId": string | number;
|
|
1162
1804
|
"userId": string | number;
|
|
1805
|
+
"groupType"?: string | number | boolean;
|
|
1163
1806
|
}): Promise<any>;
|
|
1164
|
-
/** `groups.removeMemberByEmail` — DELETE /groups/{
|
|
1807
|
+
/** `groups.removeMemberByEmail` — DELETE /groups/{groupId}/members. Remove a group member or pending invitation by email */
|
|
1165
1808
|
"removeMemberByEmail"(args: {
|
|
1809
|
+
"groupId": string | number;
|
|
1810
|
+
"email"?: string | number | boolean;
|
|
1811
|
+
"groupType"?: string | number | boolean;
|
|
1812
|
+
}): Promise<any>;
|
|
1813
|
+
/**
|
|
1814
|
+
* `groups.removeMemberByEmailByType` — DELETE /groups/{groupType}/{groupId}/members. DEPRECATED — Remove a group member or pending invitation by email, by type; use DELETE /groups/{groupId}/members (removal: #4718)
|
|
1815
|
+
* @deprecated Use DELETE /groups/{groupId}/members (removal: #4718)
|
|
1816
|
+
*/
|
|
1817
|
+
"removeMemberByEmailByType"(args: {
|
|
1166
1818
|
"groupType": string | number;
|
|
1167
1819
|
"groupId": string | number;
|
|
1168
1820
|
"email"?: string | number | boolean;
|
|
1169
1821
|
}): Promise<any>;
|
|
1170
|
-
/**
|
|
1822
|
+
/**
|
|
1823
|
+
* `groups.removeMemberByType` — DELETE /groups/{groupType}/{groupId}/members/{userId}. DEPRECATED — Remove a specific member from a group, by type; use DELETE /groups/{groupId}/members/{userId} (removal: #4718)
|
|
1824
|
+
* @deprecated Use DELETE /groups/{groupId}/members/{userId} (removal: #4718)
|
|
1825
|
+
*/
|
|
1826
|
+
"removeMemberByType"(args: {
|
|
1827
|
+
"groupType": string | number;
|
|
1828
|
+
"groupId": string | number;
|
|
1829
|
+
"userId": string | number;
|
|
1830
|
+
}): Promise<any>;
|
|
1831
|
+
/** `groups.setMemberRole` — PATCH /groups/{groupId}/members/{userId}. Change a member's role */
|
|
1832
|
+
"setMemberRole"(args: {
|
|
1833
|
+
"groupId": string | number;
|
|
1834
|
+
"userId": string | number;
|
|
1835
|
+
"groupType"?: string | number | boolean;
|
|
1836
|
+
body: unknown;
|
|
1837
|
+
}): Promise<any>;
|
|
1838
|
+
/** `groups.transfer` — POST /groups/{groupId}/transfer. Transfer a group to another user or to the app */
|
|
1839
|
+
"transfer"(args: {
|
|
1840
|
+
"groupId": string | number;
|
|
1841
|
+
"groupType"?: string | number | boolean;
|
|
1842
|
+
body: unknown;
|
|
1843
|
+
}): Promise<any>;
|
|
1844
|
+
/** `groups.update` — PATCH /groups/{groupId}. Update a group */
|
|
1171
1845
|
"update"(args: {
|
|
1846
|
+
"groupId": string | number;
|
|
1847
|
+
"groupType"?: string | number | boolean;
|
|
1848
|
+
body: unknown;
|
|
1849
|
+
}): Promise<any>;
|
|
1850
|
+
/**
|
|
1851
|
+
* `groups.updateByType` — PATCH /groups/{groupType}/{groupId}. DEPRECATED — Update a group, by type; use PATCH /groups/{groupId} (removal: #4718)
|
|
1852
|
+
* @deprecated Use PATCH /groups/{groupId} (removal: #4718)
|
|
1853
|
+
*/
|
|
1854
|
+
"updateByType"(args: {
|
|
1172
1855
|
"groupType": string | number;
|
|
1173
1856
|
"groupId": string | number;
|
|
1174
1857
|
body: unknown;
|
|
@@ -1182,10 +1865,6 @@ export interface FunctionApi {
|
|
|
1182
1865
|
}): Promise<any>;
|
|
1183
1866
|
/** `integrations.list` — GET /integrations. List integrations configured for the app */
|
|
1184
1867
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
1185
|
-
/** `integrations.proxy` — POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */
|
|
1186
|
-
"proxy"(args: {
|
|
1187
|
-
"integrationKey": string | number;
|
|
1188
|
-
}): Promise<any>;
|
|
1189
1868
|
};
|
|
1190
1869
|
"locks": {
|
|
1191
1870
|
/** `locks.list` — GET /locks. List all currently-held named locks in the app */
|
|
@@ -1210,19 +1889,26 @@ export interface FunctionApi {
|
|
|
1210
1889
|
"notifications": {
|
|
1211
1890
|
/** `notifications.list` — GET /notifications. List the caller's in-app notification inbox (newest first) */
|
|
1212
1891
|
"list"(args?: {
|
|
1892
|
+
"userId"?: string | number;
|
|
1213
1893
|
"limit"?: string | number | boolean;
|
|
1214
1894
|
"cursor"?: string | number | boolean;
|
|
1215
1895
|
}): Promise<any>;
|
|
1216
1896
|
/** `notifications.listDevices` — GET /me/push-tokens. List the caller's registered push devices */
|
|
1217
|
-
"listDevices"(args?:
|
|
1897
|
+
"listDevices"(args?: {
|
|
1898
|
+
"userId"?: string | number;
|
|
1899
|
+
}): Promise<any>;
|
|
1218
1900
|
/** `notifications.markAllRead` — POST /notifications/read-all. Mark all of the caller's notifications as read */
|
|
1219
|
-
"markAllRead"(args?:
|
|
1901
|
+
"markAllRead"(args?: {
|
|
1902
|
+
"userId"?: string | number;
|
|
1903
|
+
}): Promise<any>;
|
|
1220
1904
|
/** `notifications.markRead` — PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */
|
|
1221
1905
|
"markRead"(args: {
|
|
1222
1906
|
"notificationId": string | number;
|
|
1907
|
+
"userId"?: string | number;
|
|
1223
1908
|
}): Promise<any>;
|
|
1224
1909
|
/** `notifications.registerDevice` — POST /me/push-tokens. Register (upsert) the caller's device push token */
|
|
1225
1910
|
"registerDevice"(args: {
|
|
1911
|
+
"userId"?: string | number;
|
|
1226
1912
|
body: unknown;
|
|
1227
1913
|
}): Promise<any>;
|
|
1228
1914
|
/** `notifications.send` — POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */
|
|
@@ -1230,17 +1916,16 @@ export interface FunctionApi {
|
|
|
1230
1916
|
body: unknown;
|
|
1231
1917
|
}): Promise<any>;
|
|
1232
1918
|
/** `notifications.unreadCount` — GET /notifications/unread-count. Count the caller's unread notifications */
|
|
1233
|
-
"unreadCount"(args?:
|
|
1919
|
+
"unreadCount"(args?: {
|
|
1920
|
+
"userId"?: string | number;
|
|
1921
|
+
}): Promise<any>;
|
|
1234
1922
|
/** `notifications.unregisterDevice` — DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */
|
|
1235
1923
|
"unregisterDevice"(args: {
|
|
1236
1924
|
"token": string | number;
|
|
1925
|
+
"userId"?: string | number;
|
|
1237
1926
|
}): Promise<any>;
|
|
1238
1927
|
};
|
|
1239
1928
|
"prompts": {
|
|
1240
|
-
/** `prompts.execute` — POST /prompts/{promptKey}/execute. Execute a saved prompt */
|
|
1241
|
-
"execute"(args: {
|
|
1242
|
-
"promptKey": string | number;
|
|
1243
|
-
}): Promise<any>;
|
|
1244
1929
|
/** `prompts.run` — POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */
|
|
1245
1930
|
"run"(args: {
|
|
1246
1931
|
"promptKey": string | number;
|
|
@@ -1304,7 +1989,7 @@ export interface FunctionApi {
|
|
|
1304
1989
|
/** `users.list` — GET /users. List app users */
|
|
1305
1990
|
"list"(args?: {
|
|
1306
1991
|
"email"?: string | number | boolean;
|
|
1307
|
-
"userId"?: string | number
|
|
1992
|
+
"userId"?: string | number;
|
|
1308
1993
|
"name"?: string | number | boolean;
|
|
1309
1994
|
"limit"?: string | number | boolean;
|
|
1310
1995
|
"cursor"?: string | number | boolean;
|
|
@@ -1325,6 +2010,11 @@ export interface FunctionApi {
|
|
|
1325
2010
|
"userId": string | number;
|
|
1326
2011
|
body: unknown;
|
|
1327
2012
|
}): Promise<any>;
|
|
2013
|
+
/** `users.setProfile` — PATCH /users/{userId}/profile. Set a user's display name and avatar */
|
|
2014
|
+
"setProfile"(args: {
|
|
2015
|
+
"userId": string | number;
|
|
2016
|
+
body: unknown;
|
|
2017
|
+
}): Promise<any>;
|
|
1328
2018
|
/** `users.setRole` — PUT /users/{userId}/role. Set a user's app role */
|
|
1329
2019
|
"setRole"(args: {
|
|
1330
2020
|
"userId": string | number;
|
|
@@ -1525,8 +2215,6 @@ export interface DatabaseHandle<TModels> {
|
|
|
1525
2215
|
operations: Array<Record<string, unknown>>;
|
|
1526
2216
|
atomic?: boolean;
|
|
1527
2217
|
}): Promise<any>;
|
|
1528
|
-
/** Run one of the database type's prepared operations under this function's grants. */
|
|
1529
|
-
runOperation(name: string, params?: Record<string, unknown>): Promise<any>;
|
|
1530
2218
|
}
|
|
1531
2219
|
|
|
1532
2220
|
/**
|
|
@@ -1552,9 +2240,56 @@ export type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas
|
|
|
1552
2240
|
? PlatformRow<DocumentSchemas[M]>
|
|
1553
2241
|
: Record<string, unknown> & { id: string };
|
|
1554
2242
|
|
|
2243
|
+
/**
|
|
2244
|
+
* One related-records spec of a document model read's `include` (#4692),
|
|
2245
|
+
* answered on a db3 (a format-3 document) as `_related` on each record.
|
|
2246
|
+
*/
|
|
2247
|
+
export interface DocumentIncludeSpec {
|
|
2248
|
+
/** The related model. */
|
|
2249
|
+
model: string;
|
|
2250
|
+
/**
|
|
2251
|
+
* `refersTo`: this record's `sourceField` holds the related id (one record
|
|
2252
|
+
* or null). `hasMany`: the related `foreignKey` holds this record's
|
|
2253
|
+
* `localField` (an array). `refersToMany`: this record's `sourceField`
|
|
2254
|
+
* holds an array of ids (the records in member order, missing ones dropped).
|
|
2255
|
+
*/
|
|
2256
|
+
type: "refersTo" | "hasMany" | "refersToMany";
|
|
2257
|
+
sourceField?: string;
|
|
2258
|
+
foreignKey?: string;
|
|
2259
|
+
/** The field the related `foreignKey` matches; `id` when omitted. */
|
|
2260
|
+
localField?: string;
|
|
2261
|
+
/** The key in `_related`; the model name when omitted. */
|
|
2262
|
+
as?: string;
|
|
2263
|
+
filter?: Record<string, unknown>;
|
|
2264
|
+
sort?: Record<string, 1 | -1>;
|
|
2265
|
+
/** Related rows per parent, `hasMany` only. */
|
|
2266
|
+
limit?: number;
|
|
2267
|
+
projection?: Record<string, 0 | 1>;
|
|
2268
|
+
/** Nested specs for the related records, to depth 3 in all. */
|
|
2269
|
+
include?: DocumentIncludeSpec[];
|
|
2270
|
+
}
|
|
2271
|
+
|
|
1555
2272
|
/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */
|
|
1556
2273
|
export interface DocumentQueryOptions {
|
|
1557
2274
|
filter?: Record<string, unknown> | string;
|
|
2275
|
+
/**
|
|
2276
|
+
* The order of the rows: each field maps to 1 (ascending) or -1
|
|
2277
|
+
* (descending), and key order is precedence, as in { createdAt: -1 }. `id`
|
|
2278
|
+
* breaks ties unless you name it. `limit` and `cursor` apply to the
|
|
2279
|
+
* ordered rows; pass the same sort with a `cursor`, since a cursor from
|
|
2280
|
+
* another sort is refused with a 400.
|
|
2281
|
+
*/
|
|
2282
|
+
sort?: Record<string, 1 | -1>;
|
|
2283
|
+
/**
|
|
2284
|
+
* Records per page: 100 when omitted, at most 10,000; a larger value is
|
|
2285
|
+
* refused with a 400 naming the maximum, never clamped. A page also ends
|
|
2286
|
+
* before the record that would take it past 8 MiB (the sum of each
|
|
2287
|
+
* record's JSON in UTF-8 bytes; the envelope is not counted), answering
|
|
2288
|
+
* `hasMore: true` and a `nextCursor` that continues from the last record
|
|
2289
|
+
* returned; a single record larger than 8 MiB is answered alone. A page
|
|
2290
|
+
* that fills `limit` exactly also answers `hasMore: true`; loop on
|
|
2291
|
+
* `hasMore` rather than counting rows.
|
|
2292
|
+
*/
|
|
1558
2293
|
limit?: number;
|
|
1559
2294
|
cursor?: string;
|
|
1560
2295
|
/**
|
|
@@ -1564,7 +2299,15 @@ export interface DocumentQueryOptions {
|
|
|
1564
2299
|
* Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
|
|
1565
2300
|
* rather than per read.
|
|
1566
2301
|
*/
|
|
1567
|
-
documentFormat?: 1 | 2;
|
|
2302
|
+
documentFormat?: 1 | 2 | 3;
|
|
2303
|
+
/**
|
|
2304
|
+
* Related records to answer with each record on a db3 (a format-3
|
|
2305
|
+
* document), as `_related`; ignored on a format-1 document. Nested to depth
|
|
2306
|
+
* 3. The response, `_related` included, is at most 8 MiB and a `hasMany`
|
|
2307
|
+
* spec reads at most 1,000 related rows per request; past either the read is
|
|
2308
|
+
* refused with a 400 DB3_PAGE_TOO_LARGE, never cut.
|
|
2309
|
+
*/
|
|
2310
|
+
include?: DocumentIncludeSpec[] | string;
|
|
1568
2311
|
}
|
|
1569
2312
|
|
|
1570
2313
|
/**
|
|
@@ -1578,43 +2321,210 @@ export interface DocumentQueryOptions {
|
|
|
1578
2321
|
* `model` is NOT a member: the handle already names it and assigns it last, so
|
|
1579
2322
|
* a multi-model blob stays on the raw `ctx.api.documents.records.bulk`
|
|
1580
2323
|
* operation rather than becoming a second way to say the same thing.
|
|
2324
|
+
*
|
|
2325
|
+
* `upsert` addresses the record by a unique constraint the model declares:
|
|
2326
|
+
* `data` carries every field of `constraint`, the record holding that key
|
|
2327
|
+
* gets `data` merged into it, and when none does one is created (at `id`
|
|
2328
|
+
* when given, else at a new id) with the model's defaults.
|
|
1581
2329
|
*/
|
|
1582
2330
|
export type DocumentBatchOp<TRow> =
|
|
1583
2331
|
| { action: "create" | "patch"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }
|
|
1584
|
-
| { action: "delete"; id: string; precondition?: Record<string, unknown> }
|
|
2332
|
+
| { action: "delete"; id: string; precondition?: Record<string, unknown> }
|
|
2333
|
+
| { action: "upsert"; constraint: string; id?: string; data: Partial<TRow>; precondition?: Record<string, unknown> };
|
|
1585
2334
|
|
|
1586
|
-
/**
|
|
2335
|
+
/**
|
|
2336
|
+
* What `documents.records.bulk` answers: the blob's aggregate effect.
|
|
2337
|
+
* `upserted` has one entry per `upsert` op, in input order: the op's
|
|
2338
|
+
* `index`, the record's `id`, and whether the op `created` it.
|
|
2339
|
+
*/
|
|
1587
2340
|
export interface DocumentBulkResult {
|
|
1588
2341
|
applied: number;
|
|
1589
|
-
added: Array<{ model: string; id: string }>;
|
|
1590
|
-
updated: Array<{ model: string; id: string }>;
|
|
2342
|
+
added: Array<{ model: string; id: string }>;
|
|
2343
|
+
updated: Array<{ model: string; id: string }>;
|
|
2344
|
+
deleted: number;
|
|
2345
|
+
upserted: Array<{ index: number; model: string; id: string; created: boolean }>;
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
export interface DocumentModelHandle<TRow> {
|
|
2349
|
+
/**
|
|
2350
|
+
* One page of the model's records: 100 by default, up to 10,000 with
|
|
2351
|
+
* `limit`, and at most 8 MiB of record JSON unless a single larger record
|
|
2352
|
+
* is answered alone. Pass `nextCursor` back as `cursor` while
|
|
2353
|
+
* `hasMore` is true.
|
|
2354
|
+
*/
|
|
2355
|
+
query(options?: DocumentQueryOptions): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
|
|
2356
|
+
count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
|
|
2357
|
+
aggregate(body: Record<string, unknown>): Promise<any>;
|
|
2358
|
+
save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;
|
|
2359
|
+
patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;
|
|
2360
|
+
delete(recordId: string): Promise<{ deleted: boolean }>;
|
|
2361
|
+
/**
|
|
2362
|
+
* Apply an ordered blob of this model's ops in ONE transaction — all of it
|
|
2363
|
+
* commits or none of it does, and connected clients see one update.
|
|
2364
|
+
*
|
|
2365
|
+
* One model's ops, by construction: every op's `model` is this handle's.
|
|
2366
|
+
* A blob that spans models is the raw `ctx.api.documents.records.bulk`
|
|
2367
|
+
* operation's job.
|
|
2368
|
+
*/
|
|
2369
|
+
batch(ops: Array<DocumentBatchOp<TRow>>): Promise<DocumentBulkResult>;
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
/** A document, addressed once; its models are typed from `DocumentSchemas`. */
|
|
2373
|
+
export interface DocumentHandle {
|
|
2374
|
+
documentId: string;
|
|
2375
|
+
model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
/**
|
|
2379
|
+
* The app's db3 types, model by model — EMPTY here and filled by the
|
|
2380
|
+
* declaration `primitive config push` writes into the config tree's
|
|
2381
|
+
* `functions/` directory (`primitive-db3-types.d.ts`, from `db3-types/` and
|
|
2382
|
+
* `database-type-configs/`). A tree that has not pushed gets the open form
|
|
2383
|
+
* and still compiles.
|
|
2384
|
+
*/
|
|
2385
|
+
export interface Db3Schemas {}
|
|
2386
|
+
|
|
2387
|
+
/**
|
|
2388
|
+
* The type keys `ctx.db3` accepts: every key the augmentation declares and
|
|
2389
|
+
* nothing else once a tree has pushed, and any string before that.
|
|
2390
|
+
*/
|
|
2391
|
+
export type Db3TypeKeys = [keyof Db3Schemas] extends [never]
|
|
2392
|
+
? string
|
|
2393
|
+
: keyof Db3Schemas & string;
|
|
2394
|
+
|
|
2395
|
+
/** A db3 type's models, or an open record for a type with no schema. */
|
|
2396
|
+
export type Db3Models<K extends string> = K extends keyof Db3Schemas
|
|
2397
|
+
? Db3Schemas[K]
|
|
2398
|
+
: Record<string, Record<string, unknown>>;
|
|
2399
|
+
|
|
2400
|
+
/** The model names a db3 type declares, or `string` for one that declares none. */
|
|
2401
|
+
export type Db3ModelNames<TModels> = [keyof TModels] extends [never]
|
|
2402
|
+
? string
|
|
2403
|
+
: keyof TModels & string;
|
|
2404
|
+
|
|
2405
|
+
/** One db3 model's row shape, carrying the platform's record identity. */
|
|
2406
|
+
export type Db3ModelRow<TModels, M extends string> = M extends keyof TModels
|
|
2407
|
+
? PlatformRow<TModels[M]>
|
|
2408
|
+
: Record<string, unknown> & { id: string };
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* One op of a db3 `bulk`, typed to a model's row. `condition` is a guard in
|
|
2412
|
+
* the query filter grammar: the op applies only when the record is live and
|
|
2413
|
+
* matches it.
|
|
2414
|
+
*/
|
|
2415
|
+
export type Db3BulkOp<TRow = Record<string, unknown>> =
|
|
2416
|
+
| { action: "create"; id?: string; data: Partial<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
2417
|
+
| { action: "patch"; id: string; data: Partial<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
2418
|
+
| { action: "delete"; id: string; condition?: Record<string, unknown>; requestId?: string }
|
|
2419
|
+
| { action: "upsert"; constraint: string; id?: string; data: Partial<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
2420
|
+
| { action: "increment"; id: string; fields: Record<string, number>; condition?: Record<string, unknown>; requestId?: string };
|
|
2421
|
+
|
|
2422
|
+
/**
|
|
2423
|
+
* What `db3.records.bulk` answers. With `atomic: false` each op is applied on
|
|
2424
|
+
* its own and `results` names each one, a refused op carrying its `code`.
|
|
2425
|
+
*/
|
|
2426
|
+
export interface Db3BulkResult {
|
|
2427
|
+
applied: number;
|
|
2428
|
+
added: Array<{ model: string; id: string; appliedFields?: Record<string, unknown> }>;
|
|
2429
|
+
updated: Array<{ model: string; id: string; appliedFields?: Record<string, unknown> }>;
|
|
1591
2430
|
deleted: number;
|
|
2431
|
+
upserted?: Array<{ index: number; model: string; id: string; created: boolean; appliedFields?: Record<string, unknown> }>;
|
|
2432
|
+
incremented?: Array<{ index: number; model: string; id: string; values: Record<string, number> }>;
|
|
2433
|
+
atomic?: boolean;
|
|
2434
|
+
results?: Array<
|
|
2435
|
+
| { index: number; model: string; id: string; ok: true; kind: string; values?: Record<string, number>; appliedFields?: Record<string, unknown>; requestId?: string }
|
|
2436
|
+
| { index: number; model: string; id?: string; ok: false; code: string; status: number; error: string; reason?: string; requestId?: string }
|
|
2437
|
+
>;
|
|
2438
|
+
requestId?: string;
|
|
1592
2439
|
}
|
|
1593
2440
|
|
|
1594
|
-
|
|
1595
|
-
|
|
2441
|
+
/**
|
|
2442
|
+
* One db3 model, bound to its db3 and its model name — a thin binding over
|
|
2443
|
+
* `ctx.api.db3.records.*` with the routes' own answers. A refusal rejects
|
|
2444
|
+
* with the route's error: a failing `condition` is 409
|
|
2445
|
+
* `DB3_CONDITION_NOT_MET`, a missing record on `increment` 404
|
|
2446
|
+
* `DB3_RECORD_NOT_FOUND`, a model the type does not declare 400
|
|
2447
|
+
* `DB3_MODEL_NOT_DECLARED`.
|
|
2448
|
+
*/
|
|
2449
|
+
export interface Db3ModelHandle<TRow> {
|
|
2450
|
+
/** The record with this id, or `null` when there is none. */
|
|
2451
|
+
get(recordId: string): Promise<TRow | null>;
|
|
2452
|
+
/** One page of records: pass `nextCursor` back as `cursor` while `hasMore` is true. */
|
|
2453
|
+
query(options?: DocumentQueryOptions): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
|
|
1596
2454
|
count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
patch(recordId: string, body: { data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;
|
|
1600
|
-
delete(recordId: string): Promise<{ deleted: boolean }>;
|
|
2455
|
+
/** Counts, sums, averages, minimums and maximums, resolved to the bare row array. */
|
|
2456
|
+
aggregate(body: Record<string, unknown>): Promise<any[]>;
|
|
1601
2457
|
/**
|
|
1602
|
-
*
|
|
1603
|
-
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1606
|
-
* A blob that spans models is the raw `ctx.api.documents.records.bulk`
|
|
1607
|
-
* operation's job.
|
|
2458
|
+
* Create or replace a record; the id is minted when omitted. `ifNotExists`
|
|
2459
|
+
* applies only when no record has the id, `upsertOn` lands on the record
|
|
2460
|
+
* holding the same unique key. `appliedFields` names what the type's hook
|
|
2461
|
+
* rules wrote.
|
|
1608
2462
|
*/
|
|
1609
|
-
|
|
2463
|
+
save(body: {
|
|
2464
|
+
id?: string;
|
|
2465
|
+
data: Partial<TRow>;
|
|
2466
|
+
condition?: Record<string, unknown>;
|
|
2467
|
+
ifNotExists?: boolean;
|
|
2468
|
+
upsertOn?: string;
|
|
2469
|
+
requestId?: string;
|
|
2470
|
+
}): Promise<{ record: TRow; appliedFields?: Record<string, unknown> }>;
|
|
2471
|
+
/** Merge fields into an existing record. */
|
|
2472
|
+
patch(
|
|
2473
|
+
recordId: string,
|
|
2474
|
+
body: { data: Partial<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
2475
|
+
): Promise<{ record: TRow; appliedFields?: Record<string, unknown> }>;
|
|
2476
|
+
/** Delete a record; deleting one that does not exist is not an error unless a `condition` asks. */
|
|
2477
|
+
delete(recordId: string, body?: { condition?: Record<string, unknown>; requestId?: string }): Promise<{ deleted: boolean }>;
|
|
2478
|
+
/** Add each delta to its numeric field, and answer each field's new value. */
|
|
2479
|
+
increment(
|
|
2480
|
+
recordId: string,
|
|
2481
|
+
fields: Record<string, number>,
|
|
2482
|
+
options?: { condition?: Record<string, unknown>; requestId?: string }
|
|
2483
|
+
): Promise<{ record: TRow; values: Record<string, number> }>;
|
|
2484
|
+
/** This model's ops in one request: one transaction, or each on its own with `atomic: false`. */
|
|
2485
|
+
bulk(ops: Array<Db3BulkOp<TRow>>, options?: { atomic?: boolean; requestId?: string }): Promise<Db3BulkResult>;
|
|
1610
2486
|
}
|
|
1611
2487
|
|
|
1612
|
-
/**
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
2488
|
+
/**
|
|
2489
|
+
* A db3, addressed once and typed by the type its `ctx.db3` call names.
|
|
2490
|
+
* Every call is a `db3.records.*` operation on the app's own authority: the
|
|
2491
|
+
* handle confers nothing and needs no grant.
|
|
2492
|
+
*/
|
|
2493
|
+
export interface Db3Handle<TModels> {
|
|
2494
|
+
db3Id: string;
|
|
2495
|
+
/** The type key this handle was opened with. */
|
|
2496
|
+
type: string;
|
|
2497
|
+
model<M extends Db3ModelNames<TModels>>(modelName: M): Db3ModelHandle<Db3ModelRow<TModels, M>>;
|
|
2498
|
+
/** Ops across models in one request; each op names its `model`. */
|
|
2499
|
+
bulk(
|
|
2500
|
+
ops: Array<Db3BulkOp & { model: Db3ModelNames<TModels> }>,
|
|
2501
|
+
options?: { atomic?: boolean; requestId?: string }
|
|
2502
|
+
): Promise<Db3BulkResult>;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* How a `ctx.db3` handle's calls are judged — #4806.
|
|
2507
|
+
*
|
|
2508
|
+
* `asUser` names the member every call is judged by: their grant on the
|
|
2509
|
+
* db3 and nothing else, with no app or function authority, and the room's
|
|
2510
|
+
* hook rules see them as `user.userId`. A sync-off db3 refuses every
|
|
2511
|
+
* member (403). Naming a member other than the invoking user needs a run
|
|
2512
|
+
* with no caller, one an app owner or admin invoked, or a function declaring
|
|
2513
|
+
* `users:actAsAny` (`SUBJECT_USER_FORBIDDEN` otherwise); a user who is not a member is
|
|
2514
|
+
* `SUBJECT_USER_NOT_FOUND`.
|
|
2515
|
+
*
|
|
2516
|
+
* ```ts
|
|
2517
|
+
* const mine = ctx.db3(input.db3Id, "orders", { asUser: ctx.user.userId });
|
|
2518
|
+
* await mine.model("Order").query(); // only what this member may read
|
|
2519
|
+
* ```
|
|
2520
|
+
*/
|
|
2521
|
+
export interface Db3HandleOptions {
|
|
2522
|
+
asUser?: string;
|
|
1616
2523
|
}
|
|
1617
2524
|
|
|
2525
|
+
/** A db3 opened with no type: the model API over open record shapes, and no `type`. */
|
|
2526
|
+
export type Db3UntypedHandle = Omit<Db3Handle<Record<string, Record<string, unknown>>>, "type">;
|
|
2527
|
+
|
|
1618
2528
|
/**
|
|
1619
2529
|
* One call through a granted integration — #3183.
|
|
1620
2530
|
*
|
|
@@ -1722,13 +2632,193 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
|
|
|
1722
2632
|
scope?: string;
|
|
1723
2633
|
/** 1 to 255 characters; defaults to the agent's display name. */
|
|
1724
2634
|
title?: string;
|
|
2635
|
+
/**
|
|
2636
|
+
* Initial participants, who send messages and hold a `read-write` grant
|
|
2637
|
+
* on the session's document — #3805. Existing users of this app, not the
|
|
2638
|
+
* caller; with `viewers`, at most 50.
|
|
2639
|
+
*/
|
|
2640
|
+
participants?: string[];
|
|
2641
|
+
/**
|
|
2642
|
+
* Initial viewers, who read the session and hold a `reader` grant — #3805.
|
|
2643
|
+
* Existing users of this app, not the caller, in neither list twice.
|
|
2644
|
+
*/
|
|
2645
|
+
viewers?: string[];
|
|
2646
|
+
/**
|
|
2647
|
+
* The member who owns the session; omitted, the invoking user. A run with
|
|
2648
|
+
* no caller must name one; naming another member follows the header's
|
|
2649
|
+
* subject rule. Initial members may not name the owner.
|
|
2650
|
+
*/
|
|
2651
|
+
userId?: string;
|
|
1725
2652
|
}
|
|
1726
2653
|
|
|
1727
2654
|
/** What `ctx.agents.createSession` answers — #3803. */
|
|
1728
2655
|
export interface AgentSessionCreateResult {
|
|
1729
2656
|
/** The session: what the app keeps and uses for everything but opening. */
|
|
1730
2657
|
sessionId: string;
|
|
1731
|
-
/**
|
|
2658
|
+
/**
|
|
2659
|
+
* The session's conversation document, opened with the document client.
|
|
2660
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
2661
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
2662
|
+
*/
|
|
2663
|
+
documentId: string;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
/** What `ctx.agents.getSession` answers — #3805. Never the document's rows. */
|
|
2667
|
+
export interface AgentSessionInfo {
|
|
2668
|
+
sessionId: string;
|
|
2669
|
+
agentKey: string;
|
|
2670
|
+
/**
|
|
2671
|
+
* Open this with the document client to read the conversation.
|
|
2672
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
2673
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
2674
|
+
*/
|
|
2675
|
+
documentId: string;
|
|
2676
|
+
ownerUserId: string;
|
|
2677
|
+
/** ISO-8601. */
|
|
2678
|
+
createdAt: string;
|
|
2679
|
+
title: string | null;
|
|
2680
|
+
scope: string | null;
|
|
2681
|
+
/** ISO-8601; null when the session's listing row is missing. */
|
|
2682
|
+
lastActivityAt: string | null;
|
|
2683
|
+
/**
|
|
2684
|
+
* Whether the invoking user has activity in the session they have not
|
|
2685
|
+
* marked read (their client marks it); false for an admin with no role.
|
|
2686
|
+
*/
|
|
2687
|
+
hasUnread: boolean;
|
|
2688
|
+
/** When the invoking user last marked the session read (ISO-8601), or null. */
|
|
2689
|
+
lastReadAt: string | null;
|
|
2690
|
+
/** The members, in the order they were added. */
|
|
2691
|
+
members: { viewers: string[]; participants: string[] };
|
|
2692
|
+
/** The standing on the session of the member the call acted as. */
|
|
2693
|
+
role: "owner" | "participant" | "viewer" | "admin";
|
|
2694
|
+
/**
|
|
2695
|
+
* The session's status, decided from the session object (never the
|
|
2696
|
+
* session row): the active turn's phase, else how the last turn ended.
|
|
2697
|
+
*/
|
|
2698
|
+
status: AgentSessionStatus;
|
|
2699
|
+
/** The active turn, or null when none runs. */
|
|
2700
|
+
turn: AgentSessionTurnSummary | null;
|
|
2701
|
+
}
|
|
2702
|
+
|
|
2703
|
+
/** A session's status: `idle` between turns, the active turn's phase, or how the last turn ended. */
|
|
2704
|
+
export type AgentSessionStatus =
|
|
2705
|
+
| "idle"
|
|
2706
|
+
| "thinking"
|
|
2707
|
+
| "running_tool"
|
|
2708
|
+
| "awaiting_answer"
|
|
2709
|
+
| "failed"
|
|
2710
|
+
| "expired"
|
|
2711
|
+
| "cancelled";
|
|
2712
|
+
|
|
2713
|
+
/** The active turn of a session, as `ctx.agents.getSession` answers it. */
|
|
2714
|
+
export interface AgentSessionTurnSummary {
|
|
2715
|
+
turnId: string;
|
|
2716
|
+
/** The member whose messages started the turn. */
|
|
2717
|
+
initiatorUserId: string;
|
|
2718
|
+
/** ISO-8601; null until the turn has started. */
|
|
2719
|
+
startedAt: string | null;
|
|
2720
|
+
/** `model` while a model call runs, `tools` while server tools run, `paused` while a call waits on a person. */
|
|
2721
|
+
phase: "model" | "tools" | "paused" | "draining";
|
|
2722
|
+
/** Model rounds begun. */
|
|
2723
|
+
rounds: number;
|
|
2724
|
+
/** ISO-8601; until when the turn's runner holds it. */
|
|
2725
|
+
leaseUntil: string | null;
|
|
2726
|
+
/** Who may answer the turn's calls, as pinned at the turn's start. */
|
|
2727
|
+
answeredBy: string | null;
|
|
2728
|
+
/** The calls waiting on a person and until when, or null. */
|
|
2729
|
+
pause: { callIds: string[]; since: string; expiresAt: string } | null;
|
|
2730
|
+
/** A transition being made, or null. */
|
|
2731
|
+
pending: { kind: "answer" | "end" } | null;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/** One session in `ctx.agents.listSessions` — #3805. */
|
|
2735
|
+
export interface AgentSessionListItem {
|
|
2736
|
+
sessionId: string;
|
|
2737
|
+
agentKey: string;
|
|
2738
|
+
scope: string | null;
|
|
2739
|
+
/**
|
|
2740
|
+
* The session's conversation document.
|
|
2741
|
+
* @deprecated Use `sessionId` with the session API (`ctx.agents`,
|
|
2742
|
+
* `ctx.api.agentSessions`); the field remains until a later breaking release.
|
|
2743
|
+
*/
|
|
2744
|
+
documentId: string;
|
|
2745
|
+
ownerUserId: string;
|
|
2746
|
+
role: "owner" | "participant" | "viewer";
|
|
2747
|
+
title: string | null;
|
|
2748
|
+
/** ISO-8601. */
|
|
2749
|
+
lastActivityAt: string;
|
|
2750
|
+
createdAt: string | null;
|
|
2751
|
+
/** Whether the user has activity in the session they have not marked read. */
|
|
2752
|
+
hasUnread: boolean;
|
|
2753
|
+
/** When the user last marked the session read (ISO-8601), or null. */
|
|
2754
|
+
lastReadAt: string | null;
|
|
2755
|
+
/**
|
|
2756
|
+
* The session's status as of its last listed activity, or null for an
|
|
2757
|
+
* entry written before the status was listed. It may lag a status change
|
|
2758
|
+
* that came with no activity (a server tool's round); `getSession` reads
|
|
2759
|
+
* the current one.
|
|
2760
|
+
*/
|
|
2761
|
+
status: AgentSessionStatus | null;
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
/** What `ctx.agents.listSessions` takes — #3805. */
|
|
2765
|
+
export interface AgentSessionListOptions {
|
|
2766
|
+
/**
|
|
2767
|
+
* Whose sessions; omitted, the invoking user's. A run with no caller must
|
|
2768
|
+
* name one, and naming another follows the header's subject rule. A user
|
|
2769
|
+
* with no sessions here, member or not, answers an empty page.
|
|
2770
|
+
*/
|
|
2771
|
+
userId?: string;
|
|
2772
|
+
/** Only this agent's sessions. */
|
|
2773
|
+
agent?: string;
|
|
2774
|
+
/** Only sessions created with exactly this scope. */
|
|
2775
|
+
scope?: string;
|
|
2776
|
+
/** Page size, at most 100 (default 50). */
|
|
2777
|
+
limit?: number;
|
|
2778
|
+
/** The `nextCursor` of the previous page. */
|
|
2779
|
+
cursor?: string;
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
/**
|
|
2783
|
+
* Which member `ctx.agents.getSession`, `recordEvent` and
|
|
2784
|
+
* `deleteSession` act as. Omitted, the invoking user; a run with no caller
|
|
2785
|
+
* must name one, and naming another follows the header's subject rule.
|
|
2786
|
+
*/
|
|
2787
|
+
export interface AgentSessionSubjectOptions {
|
|
2788
|
+
userId?: string;
|
|
2789
|
+
}
|
|
2790
|
+
|
|
2791
|
+
/** A page of `ctx.agents.listSessions` — #3805. */
|
|
2792
|
+
export interface AgentSessionListPage {
|
|
2793
|
+
items: AgentSessionListItem[];
|
|
2794
|
+
hasMore: boolean;
|
|
2795
|
+
nextCursor?: string;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
/** What `ctx.agents.recordEvent` takes — #3807. */
|
|
2799
|
+
export interface AgentSessionEvent {
|
|
2800
|
+
/** An event kind the session's agent declares. */
|
|
2801
|
+
kind: string;
|
|
2802
|
+
/** The payload, validated against the kind's schema; at most 64 KiB of JSON. */
|
|
2803
|
+
data: unknown;
|
|
2804
|
+
/** Your own id for the event, 1 to 128 characters: a repeat with the same content records nothing. */
|
|
2805
|
+
eventId?: string;
|
|
2806
|
+
/** A call of this session (`call_<ULID>`) the event is about. */
|
|
2807
|
+
refersTo?: string;
|
|
2808
|
+
}
|
|
2809
|
+
|
|
2810
|
+
/** What `ctx.agents.recordEvent` answers — #3807. */
|
|
2811
|
+
export interface AgentSessionEventResult {
|
|
2812
|
+
messageId: string;
|
|
2813
|
+
seq: number;
|
|
2814
|
+
/** Set when the `eventId` was already recorded with this content: the first event's ids. */
|
|
2815
|
+
duplicate?: boolean;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
/** What `ctx.agents.deleteSession` answers: the session and the document deleted with it. */
|
|
2819
|
+
export interface AgentSessionDeleteResult {
|
|
2820
|
+
deleted: true;
|
|
2821
|
+
sessionId: string;
|
|
1732
2822
|
documentId: string;
|
|
1733
2823
|
}
|
|
1734
2824
|
|
|
@@ -1754,22 +2844,32 @@ export type PromptOutput<K extends string> = K extends keyof PromptSchemas
|
|
|
1754
2844
|
: unknown;
|
|
1755
2845
|
|
|
1756
2846
|
/**
|
|
1757
|
-
* Why a prompt's own answer was refused — #3330. Never
|
|
1758
|
-
* failure, which is what makes "the model returned the wrong
|
|
1759
|
-
* distinguishable from "the model failed".
|
|
2847
|
+
* Why a prompt's own answer was refused or incomplete — #3330, #4146. Never
|
|
2848
|
+
* set on a PROVIDER failure, which is what makes "the model returned the wrong
|
|
2849
|
+
* shape" distinguishable from "the model failed".
|
|
2850
|
+
*
|
|
2851
|
+
* `PROMPT_OUTPUT_TRUNCATED` is the answer cut off at the output token limit
|
|
2852
|
+
* (`truncated` is `true` beside it): a declared-JSON answer that stopped
|
|
2853
|
+
* before it was finished, whatever its shape, or a completion that spent the
|
|
2854
|
+
* whole limit and came back empty. Raise the config's `maxTokens` rather
|
|
2855
|
+
* than rewording the prompt.
|
|
1760
2856
|
*/
|
|
1761
2857
|
export type PromptOutputErrorCode =
|
|
1762
2858
|
| "PROMPT_OUTPUT_NOT_JSON"
|
|
1763
|
-
| "PROMPT_OUTPUT_SCHEMA_VIOLATION"
|
|
2859
|
+
| "PROMPT_OUTPUT_SCHEMA_VIOLATION"
|
|
2860
|
+
| "PROMPT_OUTPUT_TRUNCATED";
|
|
1764
2861
|
|
|
1765
2862
|
/**
|
|
1766
2863
|
* Every code the envelope's `errorCode` can carry — #3663, #3813.
|
|
1767
2864
|
*
|
|
1768
|
-
* `PROMPT_UPSTREAM_TIMEOUT`
|
|
1769
|
-
* answer: the provider ran out of time,
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
1772
|
-
*
|
|
2865
|
+
* `PROMPT_UPSTREAM_TIMEOUT` and `PROMPT_UPSTREAM_REJECTED` are NOT about the
|
|
2866
|
+
* prompt's own answer: the provider ran out of time, or refused the request as
|
|
2867
|
+
* invalid (`upstreamStatus` 400 — a setting the model does not support, such
|
|
2868
|
+
* as a reasoning level, with the provider's message in `error`), so there was
|
|
2869
|
+
* no answer to refuse. They are the only provider failures that set
|
|
2870
|
+
* `errorCode`, which is what leaves "the model returned the wrong shape"
|
|
2871
|
+
* distinguishable from "the model failed" while still letting a caller retry
|
|
2872
|
+
* a timeout and fix the config for a refusal.
|
|
1773
2873
|
*
|
|
1774
2874
|
* `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a
|
|
1775
2875
|
* decisions run's `variables.criteria` was refused before the call, so
|
|
@@ -1782,6 +2882,7 @@ export type PromptOutputErrorCode =
|
|
|
1782
2882
|
export type PromptRunErrorCode =
|
|
1783
2883
|
| PromptOutputErrorCode
|
|
1784
2884
|
| "PROMPT_UPSTREAM_TIMEOUT"
|
|
2885
|
+
| "PROMPT_UPSTREAM_REJECTED"
|
|
1785
2886
|
| "PROMPT_CRITERIA_INVALID"
|
|
1786
2887
|
| "PROMPT_STRICT_OUTPUT_SCHEMA_MISSING";
|
|
1787
2888
|
|
|
@@ -1795,6 +2896,12 @@ export interface PromptRunSuccess<TParsed> {
|
|
|
1795
2896
|
errorCode?: null;
|
|
1796
2897
|
metrics?: Record<string, unknown>;
|
|
1797
2898
|
configId: string;
|
|
2899
|
+
/**
|
|
2900
|
+
* `true` when the provider stopped at the output token limit
|
|
2901
|
+
* (`maxTokens`) before the answer was finished; absent otherwise. On
|
|
2902
|
+
* Gemini, reasoning tokens count against the same limit.
|
|
2903
|
+
*/
|
|
2904
|
+
truncated?: true;
|
|
1798
2905
|
}
|
|
1799
2906
|
|
|
1800
2907
|
/**
|
|
@@ -1823,6 +2930,12 @@ export interface PromptRunFailure {
|
|
|
1823
2930
|
* empty — so a number here is always the provider's own.
|
|
1824
2931
|
*/
|
|
1825
2932
|
upstreamStatus?: number;
|
|
2933
|
+
/**
|
|
2934
|
+
* `true` when the provider stopped at the output token limit
|
|
2935
|
+
* (`maxTokens`) before the answer was finished; absent otherwise. On
|
|
2936
|
+
* Gemini, reasoning tokens count against the same limit.
|
|
2937
|
+
*/
|
|
2938
|
+
truncated?: true;
|
|
1826
2939
|
}
|
|
1827
2940
|
|
|
1828
2941
|
/** The envelope for a key whose declaration says nothing about its output. */
|
|
@@ -1840,6 +2953,12 @@ export interface PromptRunOpenResult {
|
|
|
1840
2953
|
configId: string;
|
|
1841
2954
|
/** The upstream provider's HTTP status on a provider failure — #3663. */
|
|
1842
2955
|
upstreamStatus?: number;
|
|
2956
|
+
/**
|
|
2957
|
+
* `true` when the provider stopped at the output token limit
|
|
2958
|
+
* (`maxTokens`) before the answer was finished; absent otherwise. On
|
|
2959
|
+
* Gemini, reasoning tokens count against the same limit.
|
|
2960
|
+
*/
|
|
2961
|
+
truncated?: true;
|
|
1843
2962
|
}
|
|
1844
2963
|
|
|
1845
2964
|
/**
|
|
@@ -1995,6 +3114,16 @@ export interface FunctionContext {
|
|
|
1995
3114
|
/** The HTTP caller, or null for a webhook or cron fire. */
|
|
1996
3115
|
user: FunctionUser | null;
|
|
1997
3116
|
trigger: FunctionTrigger;
|
|
3117
|
+
/**
|
|
3118
|
+
* The agent session this tool call belongs to, when an agent turn called
|
|
3119
|
+
* the function as a tool (`ctx.trigger.kind === "tool"`); otherwise
|
|
3120
|
+
* absent.
|
|
3121
|
+
*
|
|
3122
|
+
* Checking `ctx.trigger.kind` narrows `ctx.trigger` and not this
|
|
3123
|
+
* member, so call `assertTrigger(ctx, "tool")` first to read it without a
|
|
3124
|
+
* guard.
|
|
3125
|
+
*/
|
|
3126
|
+
tool?: FunctionToolContext;
|
|
1998
3127
|
/**
|
|
1999
3128
|
* Which RUNTIME is hosting this code — #3482.
|
|
2000
3129
|
*
|
|
@@ -2047,7 +3176,42 @@ export interface FunctionContext {
|
|
|
2047
3176
|
* confers nothing: every call is a `documents.records.*` operation on the
|
|
2048
3177
|
* same authority.
|
|
2049
3178
|
*/
|
|
2050
|
-
|
|
3179
|
+
/**
|
|
3180
|
+
* A typed handle over one db3, typed from the pushed db3 types
|
|
3181
|
+
* (`primitive-db3-types.d.ts`):
|
|
3182
|
+
*
|
|
3183
|
+
* ```ts
|
|
3184
|
+
* const orders = ctx.db3(input.db3Id, "orders").model("Order");
|
|
3185
|
+
* const { record } = await orders.save({ data: { total: 12 } });
|
|
3186
|
+
* await orders.increment(record.id, { total: 3 });
|
|
3187
|
+
* ```
|
|
3188
|
+
*
|
|
3189
|
+
* It confers nothing: every call is a `db3.records.*` operation on the
|
|
3190
|
+
* app's own authority, as `ctx.doc`'s are. A function that watches the
|
|
3191
|
+
* db3 it writes (`[[function.triggers.db3]]`) starts a run per flush of its
|
|
3192
|
+
* own writes; check `ctx.trigger.kind === "db3"` before writing back.
|
|
3193
|
+
*
|
|
3194
|
+
* A db3's lifecycle (create, get, delete, sync, type, app access, custody)
|
|
3195
|
+
* is `ctx.api.db3.*`, as `ctx.db`'s is `ctx.api.databases.*`.
|
|
3196
|
+
*/
|
|
3197
|
+
db3<K extends Db3TypeKeys>(db3Id: string, type: K): Db3Handle<Db3Models<K>>;
|
|
3198
|
+
/**
|
|
3199
|
+
* The typed handle, with every call judged by the member `options.asUser`
|
|
3200
|
+
* names (`Db3HandleOptions`).
|
|
3201
|
+
*/
|
|
3202
|
+
db3<K extends Db3TypeKeys>(db3Id: string, type: K, options: Db3HandleOptions): Db3Handle<Db3Models<K>>;
|
|
3203
|
+
/**
|
|
3204
|
+
* An untyped db3, from any tree: the same model API over open record
|
|
3205
|
+
* shapes, and no `type`.
|
|
3206
|
+
*
|
|
3207
|
+
* ```ts
|
|
3208
|
+
* const notes = ctx.db3(input.db3Id).model("Note");
|
|
3209
|
+
* ```
|
|
3210
|
+
*/
|
|
3211
|
+
db3(db3Id: string): Db3UntypedHandle;
|
|
3212
|
+
/** An untyped db3, with every call judged by the member `options.asUser` names. */
|
|
3213
|
+
db3(db3Id: string, type: undefined, options: Db3HandleOptions): Db3UntypedHandle;
|
|
3214
|
+
doc(documentId: string, options?: { documentFormat?: 1 | 2 | 3 }): DocumentHandle;
|
|
2051
3215
|
/**
|
|
2052
3216
|
* Outbound HTTP, through a granted integration and nowhere else (#3183).
|
|
2053
3217
|
*
|
|
@@ -2065,12 +3229,11 @@ export interface FunctionContext {
|
|
|
2065
3229
|
): Promise<IntegrationCallResult>;
|
|
2066
3230
|
};
|
|
2067
3231
|
/**
|
|
2068
|
-
* Start a TASK
|
|
3232
|
+
* Start another function as a TASK run from inside this one — #3280.
|
|
2069
3233
|
*
|
|
2070
|
-
* The one nested door, and it is a START
|
|
2071
|
-
*
|
|
2072
|
-
* invocation to reach for
|
|
2073
|
-
* `FUNCTION_MODE_MISMATCH`.
|
|
3234
|
+
* The one nested door, and it is a START: code that wants a result composes
|
|
3235
|
+
* by IMPORTING the other function, so there is no synchronous nested
|
|
3236
|
+
* invocation to reach for.
|
|
2074
3237
|
*
|
|
2075
3238
|
* The callee's `access` gate is not consulted — this function's own gate was
|
|
2076
3239
|
* the authorization — and every run in the tree is keyed by whoever started
|
|
@@ -2087,10 +3250,10 @@ export interface FunctionContext {
|
|
|
2087
3250
|
/**
|
|
2088
3251
|
* Run one of the app's prompts, with nothing to declare (#3183, #3279).
|
|
2089
3252
|
*
|
|
2090
|
-
* The
|
|
2091
|
-
*
|
|
2092
|
-
*
|
|
2093
|
-
*
|
|
3253
|
+
* The calling function's `authorize` is the authorization: it decided who
|
|
3254
|
+
* may invoke the function, and so who may run the prompt, which carries no
|
|
3255
|
+
* rule of its own. The provider request is bounded by the invocation's own
|
|
3256
|
+
* deadline.
|
|
2094
3257
|
*
|
|
2095
3258
|
* TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an
|
|
2096
3259
|
* `outputSchema`, the platform parses the answer, validates it against that
|
|
@@ -2114,23 +3277,58 @@ export interface FunctionContext {
|
|
|
2114
3277
|
): Promise<PromptRunResult<K>>;
|
|
2115
3278
|
};
|
|
2116
3279
|
/**
|
|
2117
|
-
* Agent sessions (#3803, project `agents`)
|
|
3280
|
+
* Agent sessions (#3803, project `agents`), on the header's subject rule:
|
|
3281
|
+
* each call acts for `userId`, else the invoking user, and from any kind of
|
|
3282
|
+
* run — a run with no caller must name the member.
|
|
3283
|
+
*
|
|
3284
|
+
* `createSession` creates a session that member owns and answers
|
|
3285
|
+
* `{ sessionId, documentId }`. Variables failing the agent's
|
|
3286
|
+
* `inputSchema` reject with `AGENT_SESSION_VARIABLES_INVALID` and
|
|
3287
|
+
* `details.errors`. Once a tree has pushed, a key that is not an agent,
|
|
3288
|
+
* and variables the agent's schema refuses, are compile errors.
|
|
3289
|
+
* `participants` and `viewers` name initial members (#3805).
|
|
2118
3290
|
*
|
|
2119
|
-
* `
|
|
2120
|
-
*
|
|
2121
|
-
*
|
|
2122
|
-
*
|
|
2123
|
-
*
|
|
2124
|
-
* it. Variables failing the agent's `inputSchema` reject with
|
|
2125
|
-
* `AGENT_SESSION_VARIABLES_INVALID` and `details.errors`.
|
|
3291
|
+
* `getSession` and `listSessions` (#3805) read the member's sessions —
|
|
3292
|
+
* the ones they own or are a member of — as that member, with no admin arm
|
|
3293
|
+
* whoever invoked the function: a session they are not in answers
|
|
3294
|
+
* `AGENT_SESSION_NOT_FOUND`, and function code never sees a session's
|
|
3295
|
+
* `object`, `turnContexts` or `lastTurn`.
|
|
2126
3296
|
*
|
|
2127
|
-
*
|
|
2128
|
-
*
|
|
3297
|
+
* `deleteSession` deletes a session the member owns, with the same
|
|
3298
|
+
* outcome as the owner's delete from a client: the session, its document
|
|
3299
|
+
* and every member's listing go, and a repeat answers the same. A session
|
|
3300
|
+
* whose document is already gone can still be deleted. A participant or
|
|
3301
|
+
* viewer is refused `AGENT_SESSION_OWNER_ONLY`, anyone else
|
|
3302
|
+
* `AGENT_SESSION_NOT_FOUND`, with no admin arm. A `userId` that is
|
|
3303
|
+
* present but not a string (`null`, a number) is refused
|
|
3304
|
+
* `SUBJECT_USER_INVALID`, never read as the invoking user. Renaming and
|
|
3305
|
+
* changing members are the owner's, from a client.
|
|
3306
|
+
*
|
|
3307
|
+
* `recordEvent` (#3807) records an event as the member, who must be the
|
|
3308
|
+
* session's owner or a participant (`AGENT_SESSION_PARTICIPANT_ONLY` for a
|
|
3309
|
+
* viewer); the row is authored `app`. The kind must be one the agent
|
|
3310
|
+
* declares (`AGENT_EVENT_KIND_UNKNOWN`) and the data must match its schema
|
|
3311
|
+
* (`AGENT_EVENT_INVALID`). An event never starts a turn; the model reads
|
|
3312
|
+
* it in a later turn.
|
|
2129
3313
|
*/
|
|
2130
3314
|
agents: {
|
|
2131
3315
|
createSession<K extends SessionAgentKeys>(
|
|
2132
3316
|
options: AgentSessionCreateOptions<K>
|
|
2133
3317
|
): Promise<AgentSessionCreateResult>;
|
|
3318
|
+
getSession(
|
|
3319
|
+
sessionId: string,
|
|
3320
|
+
options?: AgentSessionSubjectOptions
|
|
3321
|
+
): Promise<AgentSessionInfo>;
|
|
3322
|
+
listSessions(options?: AgentSessionListOptions): Promise<AgentSessionListPage>;
|
|
3323
|
+
recordEvent(
|
|
3324
|
+
sessionId: string,
|
|
3325
|
+
event: AgentSessionEvent,
|
|
3326
|
+
options?: AgentSessionSubjectOptions
|
|
3327
|
+
): Promise<AgentSessionEventResult>;
|
|
3328
|
+
deleteSession(
|
|
3329
|
+
sessionId: string,
|
|
3330
|
+
options?: AgentSessionSubjectOptions
|
|
3331
|
+
): Promise<AgentSessionDeleteResult>;
|
|
2134
3332
|
};
|
|
2135
3333
|
/**
|
|
2136
3334
|
* The value of one app secret, under a `secret:<NAME>` grant (#3183).
|
|
@@ -2240,6 +3438,27 @@ export interface FunctionContext {
|
|
|
2240
3438
|
};
|
|
2241
3439
|
}
|
|
2242
3440
|
|
|
3441
|
+
/**
|
|
3442
|
+
* `FunctionContext` as `assertTrigger(ctx, kind)` leaves it: `trigger`
|
|
3443
|
+
* is the arm for `K`, `tool` is set for a tool call and `undefined` for
|
|
3444
|
+
* every other door, and `user` is the turn's initiator, never null, for the
|
|
3445
|
+
* three doors an agent turn opens (`tool`, `context` and `history`).
|
|
3446
|
+
*
|
|
3447
|
+
* Annotate a helper's parameter with it to take a context the caller has
|
|
3448
|
+
* already asserted:
|
|
3449
|
+
*
|
|
3450
|
+
* ```ts
|
|
3451
|
+
* async function lookup(ctx: FunctionContextFor<"tool">) {
|
|
3452
|
+
* return ctx.tool.variables.householdId;
|
|
3453
|
+
* }
|
|
3454
|
+
* ```
|
|
3455
|
+
*/
|
|
3456
|
+
export type FunctionContextFor<K extends FunctionTriggerKind> = FunctionContext & {
|
|
3457
|
+
trigger: Extract<FunctionTrigger, { kind: K }>;
|
|
3458
|
+
tool: K extends "tool" ? FunctionToolContext : undefined;
|
|
3459
|
+
user: K extends "tool" | "context" | "history" ? FunctionUser : FunctionUser | null;
|
|
3460
|
+
};
|
|
3461
|
+
|
|
2243
3462
|
/** How the wait between one step's retries grows. */
|
|
2244
3463
|
export type StepBackoff = "constant" | "linear" | "exponential";
|
|
2245
3464
|
|
|
@@ -2337,9 +3556,43 @@ export declare class FunctionRuntimeError extends Error {
|
|
|
2337
3556
|
* {@link FunctionRuntimeError}, which the platform settles as
|
|
2338
3557
|
* `status: "failed"` with `errorCode: "FUNCTION_RUNTIME_REFUSED"` and a
|
|
2339
3558
|
* message naming both runtimes and the verb that takes the one required.
|
|
3559
|
+
* When `primitive config push` loads the module to check its export, no
|
|
3560
|
+
* runtime is running and every assertion returns.
|
|
2340
3561
|
*/
|
|
2341
3562
|
export declare function assertRuntime(required: "request" | "task"): void;
|
|
2342
3563
|
|
|
3564
|
+
/**
|
|
3565
|
+
* Refuse every door but the one this function was written for, and narrow
|
|
3566
|
+
* `ctx` to it.
|
|
3567
|
+
*
|
|
3568
|
+
* Make it the first line of a tool function: an agent turn calls it with
|
|
3569
|
+
* `ctx.tool` set, but the same function is also reachable over plain HTTP.
|
|
3570
|
+
* After the call, `ctx.trigger` is the named arm, `ctx.tool` needs no
|
|
3571
|
+
* guard, and `ctx.user` is the turn's initiator:
|
|
3572
|
+
*
|
|
3573
|
+
* ```ts
|
|
3574
|
+
* import { assertTrigger, defineFunction } from "primitive-functions";
|
|
3575
|
+
*
|
|
3576
|
+
* export default defineFunction(async (_input, ctx) => {
|
|
3577
|
+
* assertTrigger(ctx, "tool");
|
|
3578
|
+
* const { householdId } = ctx.tool.variables as { householdId: string };
|
|
3579
|
+
* await assertHouseholdMember(ctx.user.userId, householdId);
|
|
3580
|
+
* return { callId: ctx.trigger.callId };
|
|
3581
|
+
* });
|
|
3582
|
+
* ```
|
|
3583
|
+
*
|
|
3584
|
+
* Returns when `ctx.trigger.kind` is `kind`. Otherwise it throws an
|
|
3585
|
+
* `Error` naming both kinds, which the platform settles as
|
|
3586
|
+
* `status: "failed"` with `errorCode: "FUNCTION_THREW"`. A `kind` that is
|
|
3587
|
+
* not a trigger kind, or a first argument that is not a context, throws a
|
|
3588
|
+
* `TypeError`. It takes `ctx`, so it runs inside the handler, never at
|
|
3589
|
+
* module scope.
|
|
3590
|
+
*/
|
|
3591
|
+
export declare function assertTrigger<K extends FunctionTriggerKind>(
|
|
3592
|
+
ctx: FunctionContext,
|
|
3593
|
+
kind: K
|
|
3594
|
+
): asserts ctx is FunctionContextFor<K>;
|
|
3595
|
+
|
|
2343
3596
|
/**
|
|
2344
3597
|
* The handler a function exports, typed for one declared key.
|
|
2345
3598
|
*
|
|
@@ -2356,6 +3609,362 @@ export type FunctionHandler<TInput, TOutput> = (
|
|
|
2356
3609
|
step: FunctionStep
|
|
2357
3610
|
) => Promise<TOutput>;
|
|
2358
3611
|
|
|
3612
|
+
/** The codes a `deny` carries. */
|
|
3613
|
+
export type AuthorizeCode = "FORBIDDEN" | "NOT_FOUND" | "INVALID";
|
|
3614
|
+
|
|
3615
|
+
/**
|
|
3616
|
+
* What `allow(resolved)` returns. `resolved` is what the handler reads as
|
|
3617
|
+
* `ctx.auth`; `allow()` resolves `null`.
|
|
3618
|
+
*/
|
|
3619
|
+
export interface AllowDecision<T = null> {
|
|
3620
|
+
readonly decision: "allow";
|
|
3621
|
+
readonly resolved: T;
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
/** What `deny(code, message?, { expose? })` returns. */
|
|
3625
|
+
export interface DenyDecision {
|
|
3626
|
+
readonly decision: "deny";
|
|
3627
|
+
readonly code: AuthorizeCode;
|
|
3628
|
+
/** The message, or `null` when none was given. */
|
|
3629
|
+
readonly message: string | null;
|
|
3630
|
+
/** Whether the deny asked for its code to be shown to the caller. */
|
|
3631
|
+
readonly expose: boolean;
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
/** Either decision. `T` is what an allow resolves. */
|
|
3635
|
+
export type AuthorizeDecision<T = unknown> = AllowDecision<T> | DenyDecision;
|
|
3636
|
+
|
|
3637
|
+
/** The caller `authorize` decides about. */
|
|
3638
|
+
export interface FunctionAuthUser extends FunctionUser {
|
|
3639
|
+
/** The caller's role in the app, or `null` when it has none. */
|
|
3640
|
+
role: string | null;
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
/** An app role, as `requireRole` ranks it: owner > admin > member. */
|
|
3644
|
+
export type AppRole = "owner" | "admin" | "member";
|
|
3645
|
+
|
|
3646
|
+
/** A role on a group, ranked owner > manager > member. */
|
|
3647
|
+
export type GroupRole = "owner" | "manager" | "member";
|
|
3648
|
+
|
|
3649
|
+
/** A role on a collection, ranked owner > manager > editor > contributor > viewer. */
|
|
3650
|
+
export type CollectionRole = "owner" | "manager" | "editor" | "contributor" | "viewer";
|
|
3651
|
+
|
|
3652
|
+
/** The caller's permission on a document. */
|
|
3653
|
+
export type DocumentPermission = "owner" | "read-write" | "reader";
|
|
3654
|
+
|
|
3655
|
+
/** One group the caller belongs to, with the role they hold on it. */
|
|
3656
|
+
export interface AuthMembership {
|
|
3657
|
+
groupType: string;
|
|
3658
|
+
groupId: string;
|
|
3659
|
+
role: GroupRole;
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3662
|
+
/** One database model, for reading inside `authorize`. */
|
|
3663
|
+
export interface AuthDatabaseModelHandle<TRow> {
|
|
3664
|
+
/** The row with this id, or `null` when there is none. */
|
|
3665
|
+
get(recordId: string): Promise<TRow | null>;
|
|
3666
|
+
/** One page of rows, in the same envelope `ctx.db` answers. */
|
|
3667
|
+
query(body?: ModelScopedBody): Promise<{ items: TRow[]; hasMore: boolean; nextCursor?: string }>;
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
/** One database, typed by its type key the way `ctx.db` is, with reads only. */
|
|
3671
|
+
export interface AuthDatabaseHandle<TModels> {
|
|
3672
|
+
model<M extends DatabaseModelNames<TModels>>(
|
|
3673
|
+
modelName: M
|
|
3674
|
+
): AuthDatabaseModelHandle<DatabaseModelRow<TModels, M>>;
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
/** One document model, for reading inside `authorize`. */
|
|
3678
|
+
export interface AuthDocumentModelHandle<TRow> {
|
|
3679
|
+
/** The record with this id, or `null` when there is none. */
|
|
3680
|
+
get(recordId: string): Promise<TRow | null>;
|
|
3681
|
+
/** One page of records, in the same envelope `ctx.doc` answers. */
|
|
3682
|
+
query(options?: DocumentQueryOptions): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
/** One db3 model, for reading inside `authorize`. */
|
|
3686
|
+
export interface AuthDb3ModelHandle<TRow> {
|
|
3687
|
+
/** The record with this id, or `null` when there is none. */
|
|
3688
|
+
get(recordId: string): Promise<TRow | null>;
|
|
3689
|
+
/** One page of records, in the same envelope `ctx.db3` answers. */
|
|
3690
|
+
query(options?: DocumentQueryOptions): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
|
|
3691
|
+
}
|
|
3692
|
+
|
|
3693
|
+
/** One db3, typed by its type the way `ctx.db3` is, with reads only. */
|
|
3694
|
+
export interface AuthDb3Handle<TModels> {
|
|
3695
|
+
model<M extends Db3ModelNames<TModels>>(modelName: M): AuthDb3ModelHandle<Db3ModelRow<TModels, M>>;
|
|
3696
|
+
/** The caller's level on the db3, or `null`: none, not a db3 of this app, or its sync is off. One read. */
|
|
3697
|
+
permissions(): Promise<DocumentPermission | null>;
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
/** One document, for reading inside `authorize`; its models are typed the way `ctx.doc`'s are. */
|
|
3701
|
+
export interface AuthDocumentHandle {
|
|
3702
|
+
/** The document, or `null` when this app has none with that id. */
|
|
3703
|
+
get(): Promise<Record<string, any> | null>;
|
|
3704
|
+
/** The caller's permission on the document, or `null` when they have none. */
|
|
3705
|
+
permissions(): Promise<DocumentPermission | null>;
|
|
3706
|
+
/** The document's tags, or `null` when this app has no such document. */
|
|
3707
|
+
tags(): Promise<string[] | null>;
|
|
3708
|
+
model<M extends DocumentModelNames>(modelName: M): AuthDocumentModelHandle<DocumentModelRow<M>>;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
/**
|
|
3712
|
+
* What `authorize` is handed beside the input. It only reads: there is no
|
|
3713
|
+
* write, secret, integration or start here, and the platform refuses one
|
|
3714
|
+
* reached any other way.
|
|
3715
|
+
*/
|
|
3716
|
+
export interface FunctionAuthContext {
|
|
3717
|
+
/** The caller, or `null` when no user started this invocation. */
|
|
3718
|
+
readonly user: FunctionAuthUser | null;
|
|
3719
|
+
/** What started this invocation. */
|
|
3720
|
+
readonly trigger: FunctionTrigger;
|
|
3721
|
+
/** Whether the caller's app role is exactly `role`: `hasRole("admin")` is false for an owner. */
|
|
3722
|
+
hasRole(role: string): boolean;
|
|
3723
|
+
/** Every group the caller belongs to, loaded whole. */
|
|
3724
|
+
memberships(): Promise<AuthMembership[]>;
|
|
3725
|
+
/** Whether the caller belongs to the group. */
|
|
3726
|
+
isMemberOf(groupId: string): Promise<boolean>;
|
|
3727
|
+
/** The ids of the groups the caller belongs to. */
|
|
3728
|
+
memberGroups(): Promise<string[]>;
|
|
3729
|
+
/** Whether the caller holds `role` or above on the group. */
|
|
3730
|
+
hasGroupRole(groupId: string, role: GroupRole): Promise<boolean>;
|
|
3731
|
+
readonly collections: {
|
|
3732
|
+
/** The caller's role on the collection, or `null` when they have none. */
|
|
3733
|
+
resolveRole(collectionId: string): Promise<CollectionRole | null>;
|
|
3734
|
+
};
|
|
3735
|
+
/** One document, read-only. */
|
|
3736
|
+
doc(documentId: string): AuthDocumentHandle;
|
|
3737
|
+
/** One database, read-only, typed by its type key. */
|
|
3738
|
+
db<K extends DatabaseTypeKeys>(
|
|
3739
|
+
databaseId: string,
|
|
3740
|
+
databaseType: K
|
|
3741
|
+
): AuthDatabaseHandle<DatabaseModels<K>>;
|
|
3742
|
+
/** One db3, read-only, typed by its type. */
|
|
3743
|
+
db3<K extends Db3TypeKeys>(db3Id: string, type: K): AuthDb3Handle<Db3Models<K>>;
|
|
3744
|
+
/** An app config var's value. */
|
|
3745
|
+
configVar(name: string): Promise<string>;
|
|
3746
|
+
}
|
|
3747
|
+
|
|
3748
|
+
/**
|
|
3749
|
+
* An `authorize` method: it decides from the input and the read-only
|
|
3750
|
+
* `auth` context, and what its `allow` resolves is `TAuth`.
|
|
3751
|
+
*/
|
|
3752
|
+
export type AuthorizeFn<TInput = any, TAuth = unknown> = (
|
|
3753
|
+
input: TInput,
|
|
3754
|
+
auth: FunctionAuthContext
|
|
3755
|
+
) => AuthorizeDecision<TAuth> | Promise<AuthorizeDecision<TAuth>>;
|
|
3756
|
+
|
|
3757
|
+
// A conditional rather than the function type itself, on purpose: the
|
|
3758
|
+
// compiler sets aside a generic call that returns a function type while it
|
|
3759
|
+
// infers `defineFunction`'s type arguments, so `ctx.auth` would be fixed
|
|
3760
|
+
// before `authorize: requireMember(...)` was read. Deferred, the helper's
|
|
3761
|
+
// result is read first and types both the selector's input and `ctx.auth`.
|
|
3762
|
+
/**
|
|
3763
|
+
* What a helper that reads its input returns: an {@link AuthorizeFn} over
|
|
3764
|
+
* that input.
|
|
3765
|
+
*/
|
|
3766
|
+
export type AuthorizeHelper<TInput, TAuth> = [TInput] extends [unknown]
|
|
3767
|
+
? AuthorizeFn<TInput, TAuth>
|
|
3768
|
+
: never;
|
|
3769
|
+
|
|
3770
|
+
/**
|
|
3771
|
+
* Admit the caller. The value passed is what the handler reads as
|
|
3772
|
+
* `ctx.auth`, and it must be JSON-serializable.
|
|
3773
|
+
*
|
|
3774
|
+
* ```ts
|
|
3775
|
+
* import { allow, defineFunction, deny } from "primitive-functions";
|
|
3776
|
+
*
|
|
3777
|
+
* export default defineFunction({
|
|
3778
|
+
* authorize: async (input: { orgId: string }, auth) =>
|
|
3779
|
+
* auth.user ? allow({ orgId: input.orgId }) : deny("FORBIDDEN"),
|
|
3780
|
+
* handler: async (input, ctx) => ({ orgId: ctx.auth.orgId }),
|
|
3781
|
+
* });
|
|
3782
|
+
* ```
|
|
3783
|
+
*/
|
|
3784
|
+
export declare function allow(): AllowDecision<null>;
|
|
3785
|
+
export declare function allow<const T>(resolved: T): AllowDecision<T>;
|
|
3786
|
+
|
|
3787
|
+
/**
|
|
3788
|
+
* Refuse the caller with one of the three codes. A code outside them, a
|
|
3789
|
+
* message that is not a string, or an `expose` that is not a boolean throws
|
|
3790
|
+
* a `TypeError` where the deny is written.
|
|
3791
|
+
*/
|
|
3792
|
+
export declare function deny(
|
|
3793
|
+
code: AuthorizeCode,
|
|
3794
|
+
message?: string,
|
|
3795
|
+
options?: { expose?: boolean }
|
|
3796
|
+
): DenyDecision;
|
|
3797
|
+
|
|
3798
|
+
/**
|
|
3799
|
+
* Fail the invocation with your own code. It throws, so nothing after it
|
|
3800
|
+
* runs. The caller gets `status: "failed"` with `errorCode` set to
|
|
3801
|
+
* `code` and `error` set to `message` (or the code when no message is
|
|
3802
|
+
* given):
|
|
3803
|
+
*
|
|
3804
|
+
* ```ts
|
|
3805
|
+
* import { defineFunction, fail, requireSignedIn } from "primitive-functions";
|
|
3806
|
+
*
|
|
3807
|
+
* export default defineFunction({
|
|
3808
|
+
* authorize: requireSignedIn(),
|
|
3809
|
+
* handler: async (input: { quantity: number }) => {
|
|
3810
|
+
* if (input.quantity > 100) fail("ORDER_TOO_LARGE", "orders are capped at 100 units");
|
|
3811
|
+
* return { accepted: input.quantity };
|
|
3812
|
+
* },
|
|
3813
|
+
* });
|
|
3814
|
+
* ```
|
|
3815
|
+
*
|
|
3816
|
+
* Any non-empty string is a code. Under the task runtime the run fails with
|
|
3817
|
+
* `errorCode: "FUNCTION_THREW"` and an `errorMessage` of
|
|
3818
|
+
* `FUNCTION_THREW: <code>: <message>`. Called inside `authorize`, it is a
|
|
3819
|
+
* throw, so the caller is denied. A code that is not a non-empty string, or a
|
|
3820
|
+
* message that is not a string, throws a `TypeError` instead.
|
|
3821
|
+
*/
|
|
3822
|
+
export declare function fail(code: string, message?: string): never;
|
|
3823
|
+
|
|
3824
|
+
/**
|
|
3825
|
+
* An `authorize` that admits every caller the function's routes already
|
|
3826
|
+
* admit, with no check. It reads nothing and resolves `null`. To require a
|
|
3827
|
+
* signed-in caller, use {@link requireSignedIn}.
|
|
3828
|
+
*/
|
|
3829
|
+
export declare function allowAnyone(): AuthorizeFn<any, null>;
|
|
3830
|
+
|
|
3831
|
+
/** An `authorize` that admits a signed-in caller, resolving `{ userId }`. */
|
|
3832
|
+
export declare function requireSignedIn(): AuthorizeFn<any, { userId: string }>;
|
|
3833
|
+
|
|
3834
|
+
/**
|
|
3835
|
+
* An `authorize` that admits a caller whose app role is `role` or above,
|
|
3836
|
+
* ranked owner > admin > member, so `requireRole("admin")` admits an owner.
|
|
3837
|
+
* Resolves `{ userId, role }`.
|
|
3838
|
+
*/
|
|
3839
|
+
export declare function requireRole(
|
|
3840
|
+
role: AppRole
|
|
3841
|
+
): AuthorizeFn<any, { userId: string; role: AppRole }>;
|
|
3842
|
+
|
|
3843
|
+
/**
|
|
3844
|
+
* An `authorize` that admits a member of the group `groupIdOf(input)`
|
|
3845
|
+
* names, at `role` or above when one is given. Resolves
|
|
3846
|
+
* `{ userId, groupId, role }` with the highest role the caller holds there.
|
|
3847
|
+
* An input that names no group id is denied `INVALID`.
|
|
3848
|
+
*
|
|
3849
|
+
* ```ts
|
|
3850
|
+
* import { defineFunction, requireMember } from "primitive-functions";
|
|
3851
|
+
*
|
|
3852
|
+
* export default defineFunction("team-report", {
|
|
3853
|
+
* authorize: requireMember((input) => input.teamId, "manager"),
|
|
3854
|
+
* handler: async (input, ctx) => ({ team: ctx.auth.groupId, as: ctx.auth.role }),
|
|
3855
|
+
* });
|
|
3856
|
+
* ```
|
|
3857
|
+
*/
|
|
3858
|
+
export declare function requireMember<TInput = any>(
|
|
3859
|
+
groupIdOf: (input: TInput) => string,
|
|
3860
|
+
role?: GroupRole
|
|
3861
|
+
): AuthorizeHelper<TInput, { userId: string; groupId: string; role: GroupRole }>;
|
|
3862
|
+
|
|
3863
|
+
/**
|
|
3864
|
+
* An `authorize` that admits a caller whose role on the collection
|
|
3865
|
+
* `collectionIdOf(input)` names is `minRole` or above, ranked owner >
|
|
3866
|
+
* manager > editor > contributor > viewer. Resolves
|
|
3867
|
+
* `{ userId, collectionId, role }`.
|
|
3868
|
+
*/
|
|
3869
|
+
export declare function requireCollectionRole<TInput = any>(
|
|
3870
|
+
collectionIdOf: (input: TInput) => string,
|
|
3871
|
+
minRole: CollectionRole
|
|
3872
|
+
): AuthorizeHelper<TInput, { userId: string; collectionId: string; role: CollectionRole }>;
|
|
3873
|
+
|
|
3874
|
+
/**
|
|
3875
|
+
* An `authorize` that admits the owner of the document
|
|
3876
|
+
* `documentIdOf(input)` names, resolving `{ userId, documentId }`.
|
|
3877
|
+
*/
|
|
3878
|
+
export declare function requireDocumentOwner<TInput = any>(
|
|
3879
|
+
documentIdOf: (input: TInput) => string
|
|
3880
|
+
): AuthorizeHelper<TInput, { userId: string; documentId: string }>;
|
|
3881
|
+
|
|
3882
|
+
/**
|
|
3883
|
+
* Which doors {@link allowCallers} admits. `users` decides on `http` only.
|
|
3884
|
+
* The agent doors (`tool`, `context`, `history`) are admitted only
|
|
3885
|
+
* through `agents`: `true` applies the `users` rule there too, and a
|
|
3886
|
+
* function is a rule of its own, which may resolve something other than the
|
|
3887
|
+
* `users` rule does.
|
|
3888
|
+
*/
|
|
3889
|
+
export interface CallerRules<TInput = any, TAuth = unknown, TAgentAuth = TAuth> {
|
|
3890
|
+
webhook?: boolean;
|
|
3891
|
+
cron?: boolean;
|
|
3892
|
+
manual?: boolean;
|
|
3893
|
+
/** A flush of a db3 of a type a `[[function.triggers.db3]]` entry watches. */
|
|
3894
|
+
db3?: boolean;
|
|
3895
|
+
/** The parent functions whose nested start is admitted, by key. */
|
|
3896
|
+
functions?: readonly string[];
|
|
3897
|
+
agents?: boolean | AuthorizeFn<TInput, TAgentAuth>;
|
|
3898
|
+
users?: AuthorizeFn<TInput, TAuth>;
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
/**
|
|
3902
|
+
* An `authorize` that admits by the door. `webhook`, `cron`,
|
|
3903
|
+
* `manual` and `db3` admit with `true` and resolve `null`, as does a nested start
|
|
3904
|
+
* from a parent `functions` lists. `http` takes the `users` rule's own
|
|
3905
|
+
* decision, and the agent doors take `agents`. A door with no rule is
|
|
3906
|
+
* denied, including one added later:
|
|
3907
|
+
*
|
|
3908
|
+
* ```ts
|
|
3909
|
+
* import { allowCallers, defineFunction, requireRole } from "primitive-functions";
|
|
3910
|
+
*
|
|
3911
|
+
* export default defineFunction({
|
|
3912
|
+
* authorize: allowCallers({ cron: true, manual: true, users: requireRole("admin") }),
|
|
3913
|
+
* handler: async () => ({ swept: true }),
|
|
3914
|
+
* });
|
|
3915
|
+
* ```
|
|
3916
|
+
*
|
|
3917
|
+
* An unknown key, or a value of the wrong type, throws a `TypeError` when
|
|
3918
|
+
* the module loads.
|
|
3919
|
+
*/
|
|
3920
|
+
export declare function allowCallers<TInput = any, TAuth = never, TAgentAuth = never>(
|
|
3921
|
+
rules: CallerRules<TInput, TAuth, TAgentAuth>
|
|
3922
|
+
): AuthorizeHelper<TInput, TAuth | TAgentAuth | null>;
|
|
3923
|
+
|
|
3924
|
+
/**
|
|
3925
|
+
* What the object form's handler reads beside `FunctionContext`: the value
|
|
3926
|
+
* `authorize` resolved when the invocation was admitted, and a way to ask
|
|
3927
|
+
* `authorize` again.
|
|
3928
|
+
*/
|
|
3929
|
+
export interface FunctionAuthorizedContext<TAuth> {
|
|
3930
|
+
/** What `authorize` resolved at admission. A task run keeps it on every resume. */
|
|
3931
|
+
auth: TAuth;
|
|
3932
|
+
/**
|
|
3933
|
+
* Run this version's `authorize` again against current state, for the
|
|
3934
|
+
* user it admitted, with this invocation's input and trigger. Resolves the
|
|
3935
|
+
* fresh value and leaves `ctx.auth` as it was; a deny throws the error
|
|
3936
|
+
* `fail(code, message)` throws, with the decision on it:
|
|
3937
|
+
*
|
|
3938
|
+
* ```ts
|
|
3939
|
+
* await step.sleep("cool-off", "1 hour");
|
|
3940
|
+
* await ctx.reauthorize(); // throws FORBIDDEN if the member left the group
|
|
3941
|
+
* ```
|
|
3942
|
+
*/
|
|
3943
|
+
reauthorize(): Promise<TAuth>;
|
|
3944
|
+
}
|
|
3945
|
+
|
|
3946
|
+
/**
|
|
3947
|
+
* The object form's definition: an `authorize` method beside the handler.
|
|
3948
|
+
* `TAuth` is what `authorize`'s `allow` resolves, and the handler reads
|
|
3949
|
+
* it as `ctx.auth`.
|
|
3950
|
+
*/
|
|
3951
|
+
export interface FunctionDefinition<TInput, TOutput, TAuth> {
|
|
3952
|
+
authorize: AuthorizeFn<TInput, TAuth>;
|
|
3953
|
+
handler: (
|
|
3954
|
+
input: TInput,
|
|
3955
|
+
ctx: FunctionContext & FunctionAuthorizedContext<TAuth>,
|
|
3956
|
+
step: FunctionStep
|
|
3957
|
+
) => TOutput | Promise<TOutput>;
|
|
3958
|
+
}
|
|
3959
|
+
|
|
3960
|
+
/** What the object form returns: the handler, carrying its `authorize`. */
|
|
3961
|
+
export type AuthorizedFunctionHandler<TInput, TOutput, TAuth> = FunctionHandler<
|
|
3962
|
+
TInput,
|
|
3963
|
+
TOutput
|
|
3964
|
+
> & {
|
|
3965
|
+
authorize: FunctionDefinition<TInput, TOutput, TAuth>["authorize"];
|
|
3966
|
+
};
|
|
3967
|
+
|
|
2359
3968
|
/**
|
|
2360
3969
|
* Declare a server function's handler, typed from its declaration.
|
|
2361
3970
|
*
|
|
@@ -2370,6 +3979,31 @@ export type FunctionHandler<TInput, TOutput> = (
|
|
|
2370
3979
|
* styles reach the platform bootstrap identically — a plain default export
|
|
2371
3980
|
* taking `(input, ctx, step)` runs exactly as a wrapped one does — so this is
|
|
2372
3981
|
* a typing and intent marker, not a different calling convention.
|
|
3982
|
+
*
|
|
3983
|
+
* The OBJECT form, `defineFunction(key?, { authorize, handler })`, adds an
|
|
3984
|
+
* `authorize` method that decides who may run the handler; what its
|
|
3985
|
+
* `allow` resolves is the handler's `ctx.auth`. A definition with any
|
|
3986
|
+
* other key, or a member that is not a function, throws a `TypeError` when
|
|
3987
|
+
* the module loads.
|
|
3988
|
+
*/
|
|
3989
|
+
export declare function defineFunction<K extends FunctionKeys, TAuth = null>(
|
|
3990
|
+
key: K,
|
|
3991
|
+
definition: FunctionDefinition<FunctionInput<K>, FunctionOutput<K>, TAuth>
|
|
3992
|
+
): AuthorizedFunctionHandler<FunctionInput<K>, FunctionOutput<K>, TAuth> & {
|
|
3993
|
+
functionKey: K;
|
|
3994
|
+
};
|
|
3995
|
+
export declare function defineFunction<
|
|
3996
|
+
TInput = unknown,
|
|
3997
|
+
TOutput = unknown,
|
|
3998
|
+
TAuth = unknown
|
|
3999
|
+
>(
|
|
4000
|
+
definition: FunctionDefinition<TInput, TOutput, TAuth>
|
|
4001
|
+
): AuthorizedFunctionHandler<TInput, TOutput, TAuth>;
|
|
4002
|
+
/**
|
|
4003
|
+
* A bare handler, keyed.
|
|
4004
|
+
*
|
|
4005
|
+
* @deprecated Define the object form, `defineFunction(key?, { authorize, handler })`:
|
|
4006
|
+
* a push that would create a new version of a bare handler is refused.
|
|
2373
4007
|
*/
|
|
2374
4008
|
export declare function defineFunction<K extends FunctionKeys>(
|
|
2375
4009
|
key: K,
|
|
@@ -2379,6 +4013,12 @@ export declare function defineFunction<K extends FunctionKeys>(
|
|
|
2379
4013
|
step: FunctionStep
|
|
2380
4014
|
) => FunctionOutput<K> | Promise<FunctionOutput<K>>
|
|
2381
4015
|
): FunctionHandler<FunctionInput<K>, FunctionOutput<K>> & { functionKey: K };
|
|
4016
|
+
/**
|
|
4017
|
+
* A bare handler, unkeyed.
|
|
4018
|
+
*
|
|
4019
|
+
* @deprecated Define the object form, `defineFunction(key?, { authorize, handler })`:
|
|
4020
|
+
* a push that would create a new version of a bare handler is refused.
|
|
4021
|
+
*/
|
|
2382
4022
|
export declare function defineFunction<TInput = unknown, TOutput = unknown>(
|
|
2383
4023
|
handler: (
|
|
2384
4024
|
input: TInput,
|
|
@@ -2581,11 +4221,22 @@ export declare const stepPolicy: {
|
|
|
2581
4221
|
declare const _default: {
|
|
2582
4222
|
SDK_STUB_VERSION: string;
|
|
2583
4223
|
defineFunction: typeof defineFunction;
|
|
4224
|
+
allow: typeof allow;
|
|
4225
|
+
deny: typeof deny;
|
|
4226
|
+
fail: typeof fail;
|
|
4227
|
+
allowAnyone: typeof allowAnyone;
|
|
4228
|
+
allowCallers: typeof allowCallers;
|
|
4229
|
+
requireSignedIn: typeof requireSignedIn;
|
|
4230
|
+
requireRole: typeof requireRole;
|
|
4231
|
+
requireMember: typeof requireMember;
|
|
4232
|
+
requireCollectionRole: typeof requireCollectionRole;
|
|
4233
|
+
requireDocumentOwner: typeof requireDocumentOwner;
|
|
2584
4234
|
defineQuery: typeof defineQuery;
|
|
2585
4235
|
defineMutation: typeof defineMutation;
|
|
2586
4236
|
pMap: typeof pMap;
|
|
2587
4237
|
ulid: typeof ulid;
|
|
2588
4238
|
assertRuntime: typeof assertRuntime;
|
|
4239
|
+
assertTrigger: typeof assertTrigger;
|
|
2589
4240
|
FunctionRuntimeError: typeof FunctionRuntimeError;
|
|
2590
4241
|
};
|
|
2591
4242
|
export default _default;
|