primitive-functions 0.3.0-alpha.1 → 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 +1767 -205
- 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
|
*
|
|
@@ -143,26 +256,79 @@ export interface FunctionApi {
|
|
|
143
256
|
"sessionId": string | number;
|
|
144
257
|
body: unknown;
|
|
145
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>;
|
|
146
300
|
/** `agentSessions.create` — POST /agent-sessions. Create an agent session (ctx.agents.createSession) */
|
|
147
301
|
"create"(args: {
|
|
148
302
|
body: unknown;
|
|
149
303
|
}): Promise<any>;
|
|
150
|
-
/** `agentSessions.delete` — DELETE /agent-sessions/{sessionId}. Delete an agent session */
|
|
304
|
+
/** `agentSessions.delete` — DELETE /agent-sessions/{sessionId}. Delete an agent session (ctx.agents.deleteSession) */
|
|
151
305
|
"delete"(args: {
|
|
152
306
|
"sessionId": string | number;
|
|
307
|
+
"userId"?: string | number;
|
|
153
308
|
}): Promise<any>;
|
|
154
309
|
/** `agentSessions.get` — GET /agent-sessions/{sessionId}. Get an agent session */
|
|
155
310
|
"get"(args: {
|
|
156
311
|
"sessionId": string | number;
|
|
312
|
+
"userId"?: string | number;
|
|
157
313
|
}): Promise<any>;
|
|
158
314
|
/** `agentSessions.list` — GET /agent-sessions. List one user's agent sessions */
|
|
159
315
|
"list"(args?: {
|
|
160
|
-
"userId"?: string | number
|
|
316
|
+
"userId"?: string | number;
|
|
161
317
|
"agent"?: string | number | boolean;
|
|
162
318
|
"scope"?: string | number | boolean;
|
|
163
319
|
"limit"?: string | number | boolean;
|
|
164
320
|
"cursor"?: string | number | boolean;
|
|
165
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>;
|
|
166
332
|
/** `agentSessions.removeMember` — DELETE /agent-sessions/{sessionId}/members/{userId}. Remove a member from an agent session */
|
|
167
333
|
"removeMember"(args: {
|
|
168
334
|
"sessionId": string | number;
|
|
@@ -173,6 +339,11 @@ export interface FunctionApi {
|
|
|
173
339
|
"sessionId": string | number;
|
|
174
340
|
body: unknown;
|
|
175
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>;
|
|
176
347
|
};
|
|
177
348
|
"analytics": {
|
|
178
349
|
/** `analytics.cohortRetention` — GET /analytics/cohort-retention. Cohort retention metrics */
|
|
@@ -268,13 +439,6 @@ export interface FunctionApi {
|
|
|
268
439
|
"current_timestamp"?: string | number | boolean;
|
|
269
440
|
"_bust"?: string | number | boolean;
|
|
270
441
|
}): Promise<any>;
|
|
271
|
-
/** `analytics.topWorkflows` — GET /analytics/workflows/top. List the most-run workflows */
|
|
272
|
-
"topWorkflows"(args?: {
|
|
273
|
-
"windowDays"?: string | number | boolean;
|
|
274
|
-
"limit"?: string | number | boolean;
|
|
275
|
-
"current_timestamp"?: string | number | boolean;
|
|
276
|
-
"_bust"?: string | number | boolean;
|
|
277
|
-
}): Promise<any>;
|
|
278
442
|
/** `analytics.userDetail` — GET /analytics/users/{userUlid}/detail. Detailed analytics for a single user */
|
|
279
443
|
"userDetail"(args: {
|
|
280
444
|
"userUlid": string | number;
|
|
@@ -395,17 +559,30 @@ export interface FunctionApi {
|
|
|
395
559
|
"get"(args: {
|
|
396
560
|
"collectionId": string | number;
|
|
397
561
|
}): Promise<any>;
|
|
398
|
-
/**
|
|
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
|
+
*/
|
|
399
566
|
"getAccess"(args: {
|
|
400
567
|
"collectionId": string | number;
|
|
401
568
|
}): Promise<any>;
|
|
402
|
-
/**
|
|
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
|
+
*/
|
|
403
573
|
"grantGroupPermission"(args: {
|
|
404
574
|
"collectionId": string | number;
|
|
405
575
|
body: unknown;
|
|
406
576
|
}): Promise<any>;
|
|
407
577
|
/** `collections.list` — GET /collections. List collections */
|
|
408
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;
|
|
409
586
|
"limit"?: string | number | boolean;
|
|
410
587
|
"cursor"?: string | number | boolean;
|
|
411
588
|
}): Promise<any>;
|
|
@@ -415,12 +592,28 @@ export interface FunctionApi {
|
|
|
415
592
|
"limit"?: string | number | boolean;
|
|
416
593
|
"cursor"?: string | number | boolean;
|
|
417
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>;
|
|
418
601
|
/** `collections.listDocuments` — GET /collections/{collectionId}/documents. List documents in a collection */
|
|
419
602
|
"listDocuments"(args: {
|
|
420
603
|
"collectionId": string | number;
|
|
421
604
|
"limit"?: string | number | boolean;
|
|
422
605
|
"cursor"?: string | number | boolean;
|
|
423
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>;
|
|
424
617
|
/** `collections.listPendingInvitations` — GET /collections/{collectionId}/pending-invitations. List a collection's pending invitations */
|
|
425
618
|
"listPendingInvitations"(args: {
|
|
426
619
|
"collectionId": string | number;
|
|
@@ -430,17 +623,36 @@ export interface FunctionApi {
|
|
|
430
623
|
"collectionId": string | number;
|
|
431
624
|
"documentId": string | number;
|
|
432
625
|
}): Promise<any>;
|
|
433
|
-
/** `collections.removeMember` — DELETE /collections/{collectionId}/members/{
|
|
626
|
+
/** `collections.removeMember` — DELETE /collections/{collectionId}/members/{principal}. Remove a member from a collection */
|
|
434
627
|
"removeMember"(args: {
|
|
435
628
|
"collectionId": string | number;
|
|
436
|
-
"
|
|
629
|
+
"principal": string | number;
|
|
630
|
+
}): Promise<any>;
|
|
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;
|
|
437
635
|
}): Promise<any>;
|
|
438
|
-
/**
|
|
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
|
+
*/
|
|
439
640
|
"revokeGroupPermission"(args: {
|
|
440
641
|
"collectionId": string | number;
|
|
441
642
|
"groupType": string | number;
|
|
442
643
|
"groupId": string | number;
|
|
443
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>;
|
|
444
656
|
/** `collections.update` — PATCH /collections/{collectionId}. Update a collection */
|
|
445
657
|
"update"(args: {
|
|
446
658
|
"collectionId": string | number;
|
|
@@ -466,30 +678,14 @@ export interface FunctionApi {
|
|
|
466
678
|
"dryRun"?: string | number | boolean;
|
|
467
679
|
body: unknown;
|
|
468
680
|
}): Promise<any>;
|
|
469
|
-
/** `databaseTypeConfigs.createOperation` — POST /databases/types/{databaseType}/operations. Create an operation for a database type */
|
|
470
|
-
"createOperation"(args: {
|
|
471
|
-
"databaseType": string | number;
|
|
472
|
-
"dryRun"?: string | number | boolean;
|
|
473
|
-
body: unknown;
|
|
474
|
-
}): Promise<any>;
|
|
475
681
|
/** `databaseTypeConfigs.delete` — DELETE /databases/types/{databaseType}. Delete a database type */
|
|
476
682
|
"delete"(args: {
|
|
477
683
|
"databaseType": string | number;
|
|
478
684
|
}): Promise<any>;
|
|
479
|
-
/** `databaseTypeConfigs.deleteOperation` — DELETE /databases/types/{databaseType}/operations/{name}. Delete an operation for a database type */
|
|
480
|
-
"deleteOperation"(args: {
|
|
481
|
-
"databaseType": string | number;
|
|
482
|
-
"name": string | number;
|
|
483
|
-
}): Promise<any>;
|
|
484
685
|
/** `databaseTypeConfigs.get` — GET /databases/types/{databaseType}. Get a database type */
|
|
485
686
|
"get"(args: {
|
|
486
687
|
"databaseType": string | number;
|
|
487
688
|
}): Promise<any>;
|
|
488
|
-
/** `databaseTypeConfigs.getOperation` — GET /databases/types/{databaseType}/operations/{name}. Get an operation for a database type */
|
|
489
|
-
"getOperation"(args: {
|
|
490
|
-
"databaseType": string | number;
|
|
491
|
-
"name": string | number;
|
|
492
|
-
}): Promise<any>;
|
|
493
689
|
/** `databaseTypeConfigs.getReindexStatus` — GET /databases/types/{databaseType}/reindex-status. Status of the index back-provision fan-out for a type */
|
|
494
690
|
"getReindexStatus"(args: {
|
|
495
691
|
"databaseType": string | number;
|
|
@@ -497,54 +693,16 @@ export interface FunctionApi {
|
|
|
497
693
|
}): Promise<any>;
|
|
498
694
|
/** `databaseTypeConfigs.list` — GET /databases/types. List database types */
|
|
499
695
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
500
|
-
/** `databaseTypeConfigs.listOperations` — GET /databases/types/{databaseType}/operations. List operations for a database type */
|
|
501
|
-
"listOperations"(args: {
|
|
502
|
-
"databaseType": string | number;
|
|
503
|
-
}): Promise<any>;
|
|
504
696
|
/** `databaseTypeConfigs.scaffoldSchema` — POST /databases/types/{databaseType}/schema:scaffold. Scaffold a starter schema for a database type */
|
|
505
697
|
"scaffoldSchema"(args: {
|
|
506
698
|
"databaseType": string | number;
|
|
507
699
|
}): Promise<any>;
|
|
508
|
-
"subscriptions": {
|
|
509
|
-
/** `databaseTypeConfigs.subscriptions.create` — POST /databases/types/{databaseType}/subscriptions. Create a subscription for a database type */
|
|
510
|
-
"create"(args: {
|
|
511
|
-
"databaseType": string | number;
|
|
512
|
-
body: unknown;
|
|
513
|
-
}): Promise<any>;
|
|
514
|
-
/** `databaseTypeConfigs.subscriptions.delete` — DELETE /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Delete a database type subscription */
|
|
515
|
-
"delete"(args: {
|
|
516
|
-
"databaseType": string | number;
|
|
517
|
-
"subscriptionKey": string | number;
|
|
518
|
-
}): Promise<any>;
|
|
519
|
-
/** `databaseTypeConfigs.subscriptions.get` — GET /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Get a database type subscription */
|
|
520
|
-
"get"(args: {
|
|
521
|
-
"databaseType": string | number;
|
|
522
|
-
"subscriptionKey": string | number;
|
|
523
|
-
}): Promise<any>;
|
|
524
|
-
/** `databaseTypeConfigs.subscriptions.list` — GET /databases/types/{databaseType}/subscriptions. List subscriptions for a database type */
|
|
525
|
-
"list"(args: {
|
|
526
|
-
"databaseType": string | number;
|
|
527
|
-
}): Promise<any>;
|
|
528
|
-
/** `databaseTypeConfigs.subscriptions.update` — PUT /databases/types/{databaseType}/subscriptions/{subscriptionKey}. Update a database type subscription */
|
|
529
|
-
"update"(args: {
|
|
530
|
-
"databaseType": string | number;
|
|
531
|
-
"subscriptionKey": string | number;
|
|
532
|
-
body: unknown;
|
|
533
|
-
}): Promise<any>;
|
|
534
|
-
};
|
|
535
700
|
/** `databaseTypeConfigs.update` — PATCH /databases/types/{databaseType}. Update a database type */
|
|
536
701
|
"update"(args: {
|
|
537
702
|
"databaseType": string | number;
|
|
538
703
|
"dryRun"?: string | number | boolean;
|
|
539
704
|
body: unknown;
|
|
540
705
|
}): Promise<any>;
|
|
541
|
-
/** `databaseTypeConfigs.updateOperation` — PATCH /databases/types/{databaseType}/operations/{name}. Update an operation for a database type */
|
|
542
|
-
"updateOperation"(args: {
|
|
543
|
-
"databaseType": string | number;
|
|
544
|
-
"name": string | number;
|
|
545
|
-
"dryRun"?: string | number | boolean;
|
|
546
|
-
body: unknown;
|
|
547
|
-
}): Promise<any>;
|
|
548
706
|
};
|
|
549
707
|
"databases": {
|
|
550
708
|
/** `databases.addManager` — PUT /databases/{databaseId}/permissions. Set a user's database permission */
|
|
@@ -560,19 +718,6 @@ export interface FunctionApi {
|
|
|
560
718
|
"delete"(args: {
|
|
561
719
|
"databaseId": string | number;
|
|
562
720
|
}): Promise<any>;
|
|
563
|
-
/** `databases.executeBatch` — POST /databases/{databaseId}/operations/{name}/batch. Execute a database operation in batch */
|
|
564
|
-
"executeBatch"(args: {
|
|
565
|
-
"databaseId": string | number;
|
|
566
|
-
"name": string | number;
|
|
567
|
-
body: unknown;
|
|
568
|
-
}): Promise<any>;
|
|
569
|
-
/** `databases.executeOperation` — POST /databases/{databaseId}/operations/{name}/execute. Execute a database operation */
|
|
570
|
-
"executeOperation"(args: {
|
|
571
|
-
"databaseId": string | number;
|
|
572
|
-
"name": string | number;
|
|
573
|
-
"dryRun"?: string | number | boolean;
|
|
574
|
-
body?: unknown;
|
|
575
|
-
}): Promise<any>;
|
|
576
721
|
/** `databases.get` — GET /databases/{databaseId}. Get a database by id */
|
|
577
722
|
"get"(args: {
|
|
578
723
|
"databaseId": string | number;
|
|
@@ -582,118 +727,108 @@ export interface FunctionApi {
|
|
|
582
727
|
"databaseId": string | number;
|
|
583
728
|
body: unknown;
|
|
584
729
|
}): Promise<any>;
|
|
585
|
-
/** `databases.importBulk` — POST /databases/{databaseId}/operations/{name}/import-bulk. Bulk-import records via a database operation */
|
|
586
|
-
"importBulk"(args: {
|
|
587
|
-
"databaseId": string | number;
|
|
588
|
-
"name": string | number;
|
|
589
|
-
body: unknown;
|
|
590
|
-
}): Promise<any>;
|
|
591
730
|
/** `databases.list` — GET /databases. List databases */
|
|
592
731
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
593
732
|
/** `databases.listGroupPermissions` — GET /databases/{databaseId}/group-permissions. List a database's group permissions */
|
|
594
733
|
"listGroupPermissions"(args: {
|
|
595
734
|
"databaseId": string | number;
|
|
596
735
|
}): Promise<any>;
|
|
597
|
-
/** `databases.listOperations` — GET /databases/{databaseId}/operations. List operations runnable on a database */
|
|
598
|
-
"listOperations"(args: {
|
|
599
|
-
"databaseId": string | number;
|
|
600
|
-
}): Promise<any>;
|
|
601
736
|
/** `databases.listPermissions` — GET /databases/{databaseId}/permissions. List a database's user permissions */
|
|
602
737
|
"listPermissions"(args: {
|
|
603
738
|
"databaseId": string | number;
|
|
604
739
|
}): Promise<any>;
|
|
605
740
|
"records": {
|
|
606
|
-
/** `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) */
|
|
607
742
|
"addToSet"(args: {
|
|
608
743
|
"databaseId": string | number;
|
|
609
744
|
body: unknown;
|
|
610
745
|
}): Promise<any>;
|
|
611
|
-
/** `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) */
|
|
612
747
|
"aggregate"(args: {
|
|
613
748
|
"databaseId": string | number;
|
|
614
749
|
body: unknown;
|
|
615
750
|
}): Promise<any>;
|
|
616
|
-
/** `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) */
|
|
617
752
|
"batch"(args: {
|
|
618
753
|
"databaseId": string | number;
|
|
619
754
|
body: unknown;
|
|
620
755
|
}): Promise<any>;
|
|
621
|
-
/** `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) */
|
|
622
757
|
"count"(args: {
|
|
623
758
|
"databaseId": string | number;
|
|
624
759
|
body: unknown;
|
|
625
760
|
}): Promise<any>;
|
|
626
|
-
/** `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) */
|
|
627
762
|
"delete"(args: {
|
|
628
763
|
"databaseId": string | number;
|
|
629
764
|
body: unknown;
|
|
630
765
|
}): Promise<any>;
|
|
631
|
-
/** `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) */
|
|
632
767
|
"describe"(args: {
|
|
633
768
|
"databaseId": string | number;
|
|
634
769
|
"modelName"?: string | number | boolean;
|
|
635
770
|
}): Promise<any>;
|
|
636
|
-
/** `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) */
|
|
637
772
|
"dropIndex"(args: {
|
|
638
773
|
"databaseId": string | number;
|
|
639
774
|
body: unknown;
|
|
640
775
|
}): Promise<any>;
|
|
641
|
-
/** `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) */
|
|
642
777
|
"dropUniqueConstraint"(args: {
|
|
643
778
|
"databaseId": string | number;
|
|
644
779
|
body: unknown;
|
|
645
780
|
}): Promise<any>;
|
|
646
|
-
/** `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) */
|
|
647
782
|
"increment"(args: {
|
|
648
783
|
"databaseId": string | number;
|
|
649
784
|
body: unknown;
|
|
650
785
|
}): Promise<any>;
|
|
651
|
-
/** `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) */
|
|
652
787
|
"listIndexes"(args: {
|
|
653
788
|
"databaseId": string | number;
|
|
654
789
|
"modelName"?: string | number | boolean;
|
|
655
790
|
}): Promise<any>;
|
|
656
|
-
/** `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) */
|
|
657
792
|
"listUniqueConstraints"(args: {
|
|
658
793
|
"databaseId": string | number;
|
|
659
794
|
"modelName"?: string | number | boolean;
|
|
660
795
|
}): Promise<any>;
|
|
661
|
-
/** `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) */
|
|
662
797
|
"models"(args: {
|
|
663
798
|
"databaseId": string | number;
|
|
664
799
|
"modelName"?: string | number | boolean;
|
|
665
800
|
}): Promise<any>;
|
|
666
|
-
/** `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) */
|
|
667
802
|
"patch"(args: {
|
|
668
803
|
"databaseId": string | number;
|
|
669
804
|
body: unknown;
|
|
670
805
|
}): Promise<any>;
|
|
671
|
-
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (
|
|
806
|
+
/** `databases.records.query` — POST /databases/{databaseId}/records/query. Database records: query (app admin or owner) */
|
|
672
807
|
"query"(args: {
|
|
673
808
|
"databaseId": string | number;
|
|
674
809
|
body: unknown;
|
|
675
810
|
}): Promise<{ items: any[]; hasMore: boolean; nextCursor?: string; prevCursor?: string }>;
|
|
676
|
-
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (
|
|
811
|
+
/** `databases.records.registerIndex` — POST /databases/{databaseId}/records/index/register. Database records: index/register (app admin or owner) */
|
|
677
812
|
"registerIndex"(args: {
|
|
678
813
|
"databaseId": string | number;
|
|
679
814
|
body: unknown;
|
|
680
815
|
}): Promise<any>;
|
|
681
|
-
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (
|
|
816
|
+
/** `databases.records.registerUniqueConstraint` — POST /databases/{databaseId}/records/unique-constraint/register. Database records: unique-constraint/register (app admin or owner) */
|
|
682
817
|
"registerUniqueConstraint"(args: {
|
|
683
818
|
"databaseId": string | number;
|
|
684
819
|
body: unknown;
|
|
685
820
|
}): Promise<any>;
|
|
686
|
-
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (
|
|
821
|
+
/** `databases.records.removeFromSet` — POST /databases/{databaseId}/records/stringset/remove. Database records: stringset/remove (app admin or owner) */
|
|
687
822
|
"removeFromSet"(args: {
|
|
688
823
|
"databaseId": string | number;
|
|
689
824
|
body: unknown;
|
|
690
825
|
}): Promise<any>;
|
|
691
|
-
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (
|
|
826
|
+
/** `databases.records.save` — POST /databases/{databaseId}/records/save. Database records: save (app admin or owner) */
|
|
692
827
|
"save"(args: {
|
|
693
828
|
"databaseId": string | number;
|
|
694
829
|
body: unknown;
|
|
695
830
|
}): Promise<any>;
|
|
696
|
-
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (
|
|
831
|
+
/** `databases.records.syncIndexes` — POST /databases/{databaseId}/records/indexes/sync. Database records: indexes/sync (app admin or owner) */
|
|
697
832
|
"syncIndexes"(args: {
|
|
698
833
|
"databaseId": string | number;
|
|
699
834
|
body: unknown;
|
|
@@ -703,8 +838,17 @@ export interface FunctionApi {
|
|
|
703
838
|
"reindex"(args: {
|
|
704
839
|
"databaseId": string | number;
|
|
705
840
|
}): Promise<any>;
|
|
706
|
-
/** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{
|
|
841
|
+
/** `databases.revokeGroupPermission` — DELETE /databases/{databaseId}/group-permissions/{groupId}. Revoke a group permission on a database */
|
|
707
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: {
|
|
708
852
|
"databaseId": string | number;
|
|
709
853
|
"groupType": string | number;
|
|
710
854
|
"groupId": string | number;
|
|
@@ -714,12 +858,6 @@ export interface FunctionApi {
|
|
|
714
858
|
"databaseId": string | number;
|
|
715
859
|
"userId": string | number;
|
|
716
860
|
}): Promise<any>;
|
|
717
|
-
/** `databases.runOperation` — POST /databases/{databaseId}/operations/{name}/run. Run a database operation under a server function's grants */
|
|
718
|
-
"runOperation"(args: {
|
|
719
|
-
"databaseId": string | number;
|
|
720
|
-
"name": string | number;
|
|
721
|
-
body?: unknown;
|
|
722
|
-
}): Promise<any>;
|
|
723
861
|
/** `databases.transferOwnership` — POST /databases/{databaseId}/permissions/transfer. Transfer database ownership */
|
|
724
862
|
"transferOwnership"(args: {
|
|
725
863
|
"databaseId": string | number;
|
|
@@ -731,6 +869,341 @@ export interface FunctionApi {
|
|
|
731
869
|
body: unknown;
|
|
732
870
|
}): Promise<any>;
|
|
733
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;
|
|
1093
|
+
body: unknown;
|
|
1094
|
+
}): Promise<any>;
|
|
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;
|
|
1101
|
+
body: unknown;
|
|
1102
|
+
}): Promise<any>;
|
|
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;
|
|
1113
|
+
}): Promise<any>;
|
|
1114
|
+
/** `db3.records.save` — POST /db3/{db3Id}/records/{model}. Create or replace a record in a db3 model */
|
|
1115
|
+
"save"(args: {
|
|
1116
|
+
"db3Id": string | number;
|
|
1117
|
+
"model": string | number;
|
|
1118
|
+
"userId"?: string | number;
|
|
1119
|
+
body: unknown;
|
|
1120
|
+
}): Promise<any>;
|
|
1121
|
+
};
|
|
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;
|
|
1146
|
+
}): Promise<any>;
|
|
1147
|
+
/** `db3.revokeGroupPermission` — DELETE /db3/{db3Id}/group-permissions/{groupId}. Revoke a group permission on a db3 */
|
|
1148
|
+
"revokeGroupPermission"(args: {
|
|
1149
|
+
"db3Id": string | number;
|
|
1150
|
+
"groupId": string | number;
|
|
1151
|
+
"groupType"?: string | number | boolean;
|
|
1152
|
+
}): Promise<any>;
|
|
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;
|
|
1159
|
+
}): Promise<any>;
|
|
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;
|
|
1164
|
+
}): Promise<any>;
|
|
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;
|
|
1168
|
+
body: unknown;
|
|
1169
|
+
}): Promise<any>;
|
|
1170
|
+
/** `db3.setOwnerRow` — PUT /db3/{db3Id}/owner-row. Remove or restore a db3's owner row */
|
|
1171
|
+
"setOwnerRow"(args: {
|
|
1172
|
+
"db3Id": string | number;
|
|
1173
|
+
body: unknown;
|
|
1174
|
+
}): Promise<any>;
|
|
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;
|
|
1193
|
+
body: unknown;
|
|
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>;
|
|
1206
|
+
};
|
|
734
1207
|
"documents": {
|
|
735
1208
|
/** `documents.abortIngest` — POST /documents/{documentId}/ingest/{sessionId}/abort. Abort a bulk-load session before its swap */
|
|
736
1209
|
"abortIngest"(args: {
|
|
@@ -748,7 +1221,7 @@ export interface FunctionApi {
|
|
|
748
1221
|
"delete"(args: {
|
|
749
1222
|
"scope": string | number;
|
|
750
1223
|
"aliasKey": string | number;
|
|
751
|
-
"userId"?: string | number
|
|
1224
|
+
"userId"?: string | number;
|
|
752
1225
|
}): Promise<any>;
|
|
753
1226
|
/** `documents.aliases.listForDocument` — GET /documents/{documentId}/aliases. List aliases bound to a document */
|
|
754
1227
|
"listForDocument"(args: {
|
|
@@ -758,7 +1231,7 @@ export interface FunctionApi {
|
|
|
758
1231
|
"resolve"(args: {
|
|
759
1232
|
"scope": string | number;
|
|
760
1233
|
"aliasKey": string | number;
|
|
761
|
-
"userId"?: string | number
|
|
1234
|
+
"userId"?: string | number;
|
|
762
1235
|
}): Promise<any>;
|
|
763
1236
|
/** `documents.aliases.set` — PUT /document-aliases/{scope}/{aliasKey}. Bind a (scope, aliasKey) alias to a document */
|
|
764
1237
|
"set"(args: {
|
|
@@ -806,6 +1279,7 @@ export interface FunctionApi {
|
|
|
806
1279
|
"X-Blob-Filename": string | number;
|
|
807
1280
|
"X-Blob-Size": string | number;
|
|
808
1281
|
"X-Blob-Sha256": string | number;
|
|
1282
|
+
"Content-Type"?: string | number;
|
|
809
1283
|
body: ArrayBuffer | Uint8Array | string;
|
|
810
1284
|
}): Promise<any>;
|
|
811
1285
|
};
|
|
@@ -954,10 +1428,26 @@ export interface FunctionApi {
|
|
|
954
1428
|
"limit"?: string | number | boolean;
|
|
955
1429
|
"cursor"?: string | number | boolean;
|
|
956
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>;
|
|
957
1440
|
/** `documents.listPendingInvitations` — GET /documents/{documentId}/pending-invitations. List a document's pending (deferred) invitations */
|
|
958
1441
|
"listPendingInvitations"(args: {
|
|
959
1442
|
"documentId": string | number;
|
|
960
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>;
|
|
961
1451
|
/** `documents.listSnapshots` — GET /documents/{documentId}/snapshots. List a large document's snapshot builds, newest first */
|
|
962
1452
|
"listSnapshots"(args: {
|
|
963
1453
|
"documentId": string | number;
|
|
@@ -976,7 +1466,7 @@ export interface FunctionApi {
|
|
|
976
1466
|
"documentFormat"?: string | number | boolean;
|
|
977
1467
|
body: unknown;
|
|
978
1468
|
}): Promise<any>;
|
|
979
|
-
/** `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) */
|
|
980
1470
|
"bulk"(args: {
|
|
981
1471
|
"documentId": string | number;
|
|
982
1472
|
"documentFormat"?: string | number | boolean;
|
|
@@ -995,6 +1485,8 @@ export interface FunctionApi {
|
|
|
995
1485
|
"model": string | number;
|
|
996
1486
|
"recordId": string | number;
|
|
997
1487
|
"documentFormat"?: string | number | boolean;
|
|
1488
|
+
"requestId"?: string | number | boolean;
|
|
1489
|
+
"condition"?: string | number | boolean;
|
|
998
1490
|
}): Promise<any>;
|
|
999
1491
|
/** `documents.records.patch` — PATCH /documents/{documentId}/records/{model}/{recordId}. Merge fields into an existing record in a document model */
|
|
1000
1492
|
"patch"(args: {
|
|
@@ -1012,6 +1504,8 @@ export interface FunctionApi {
|
|
|
1012
1504
|
"limit"?: string | number | boolean;
|
|
1013
1505
|
"cursor"?: string | number | boolean;
|
|
1014
1506
|
"filter"?: Record<string, unknown> | string;
|
|
1507
|
+
"sort"?: Record<string, unknown> | string;
|
|
1508
|
+
"include"?: unknown[] | string;
|
|
1015
1509
|
}): Promise<any>;
|
|
1016
1510
|
/** `documents.records.save` — POST /documents/{documentId}/records/{model}. Create or replace a record in a document model */
|
|
1017
1511
|
"save"(args: {
|
|
@@ -1046,12 +1540,28 @@ export interface FunctionApi {
|
|
|
1046
1540
|
"documentId": string | number;
|
|
1047
1541
|
body: unknown;
|
|
1048
1542
|
}): Promise<any>;
|
|
1049
|
-
/** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{
|
|
1543
|
+
/** `documents.revokeGroupPermission` — DELETE /documents/{documentId}/group-permissions/{groupId}. Revoke a group permission on a document */
|
|
1050
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: {
|
|
1051
1554
|
"documentId": string | number;
|
|
1052
1555
|
"groupType": string | number;
|
|
1053
1556
|
"groupId": string | number;
|
|
1054
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>;
|
|
1055
1565
|
/** `documents.setLinkAccess` — PUT /documents/{documentId}/link-access. Set the document's "anyone with the link" access level */
|
|
1056
1566
|
"setLinkAccess"(args: {
|
|
1057
1567
|
"documentId": string | number;
|
|
@@ -1091,7 +1601,17 @@ export interface FunctionApi {
|
|
|
1091
1601
|
}): Promise<any>;
|
|
1092
1602
|
};
|
|
1093
1603
|
"functions": {
|
|
1094
|
-
/** `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 */
|
|
1095
1615
|
"invoke"(args: {
|
|
1096
1616
|
"functionKey": string | number;
|
|
1097
1617
|
body?: unknown;
|
|
@@ -1101,6 +1621,19 @@ export interface FunctionApi {
|
|
|
1101
1621
|
"functionKey": string | number;
|
|
1102
1622
|
body?: unknown;
|
|
1103
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>;
|
|
1104
1637
|
/** `functions.logs` — GET /functions/{functionKey}/logs. List a server function's invocation logs, newest first */
|
|
1105
1638
|
"logs"(args: {
|
|
1106
1639
|
"functionKey": string | number;
|
|
@@ -1113,10 +1646,30 @@ export interface FunctionApi {
|
|
|
1113
1646
|
"functionKey": string | number;
|
|
1114
1647
|
body?: unknown;
|
|
1115
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>;
|
|
1116
1660
|
};
|
|
1117
1661
|
"groups": {
|
|
1118
|
-
/** `groups.addMember` — POST /groups/{
|
|
1662
|
+
/** `groups.addMember` — POST /groups/{groupId}/members. Add a member to a group */
|
|
1119
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: {
|
|
1120
1673
|
"groupType": string | number;
|
|
1121
1674
|
"groupId": string | number;
|
|
1122
1675
|
body: unknown;
|
|
@@ -1125,13 +1678,29 @@ export interface FunctionApi {
|
|
|
1125
1678
|
"create"(args: {
|
|
1126
1679
|
body: unknown;
|
|
1127
1680
|
}): Promise<any>;
|
|
1128
|
-
/** `groups.delete` — DELETE /groups/{
|
|
1681
|
+
/** `groups.delete` — DELETE /groups/{groupId}. Delete a group */
|
|
1129
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: {
|
|
1130
1691
|
"groupType": string | number;
|
|
1131
1692
|
"groupId": string | number;
|
|
1132
1693
|
}): Promise<any>;
|
|
1133
|
-
/** `groups.get` — GET /groups/{
|
|
1694
|
+
/** `groups.get` — GET /groups/{groupId}. Get a group */
|
|
1134
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: {
|
|
1135
1704
|
"groupType": string | number;
|
|
1136
1705
|
"groupId": string | number;
|
|
1137
1706
|
}): Promise<any>;
|
|
@@ -1142,26 +1711,84 @@ export interface FunctionApi {
|
|
|
1142
1711
|
"limit"?: string | number | boolean;
|
|
1143
1712
|
"cursor"?: string | number | boolean;
|
|
1144
1713
|
}): Promise<any>;
|
|
1145
|
-
/** `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 */
|
|
1146
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: {
|
|
1147
1745
|
"groupType": string | number;
|
|
1148
1746
|
"groupId": string | number;
|
|
1747
|
+
"limit"?: string | number | boolean;
|
|
1748
|
+
"cursor"?: string | number | boolean;
|
|
1149
1749
|
}): Promise<any>;
|
|
1150
|
-
/** `groups.listDocuments` — GET /groups/{
|
|
1750
|
+
/** `groups.listDocuments` — GET /groups/{groupId}/documents. List documents shared with a group */
|
|
1151
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: {
|
|
1152
1760
|
"groupType": string | number;
|
|
1153
1761
|
"groupId": string | number;
|
|
1154
1762
|
}): Promise<any>;
|
|
1155
|
-
/** `groups.listMembers` — GET /groups/{
|
|
1763
|
+
/** `groups.listMembers` — GET /groups/{groupId}/members. List a group's members */
|
|
1156
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: {
|
|
1157
1776
|
"groupType": string | number;
|
|
1158
1777
|
"groupId": string | number;
|
|
1159
1778
|
"limit"?: string | number | boolean;
|
|
1160
1779
|
"cursor"?: string | number | boolean;
|
|
1161
1780
|
"include"?: string | number | boolean;
|
|
1162
1781
|
}): Promise<any>;
|
|
1163
|
-
/** `groups.listPendingInvitations` — GET /groups/{
|
|
1782
|
+
/** `groups.listPendingInvitations` — GET /groups/{groupId}/pending-invitations. List a group's pending invitations */
|
|
1164
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: {
|
|
1165
1792
|
"groupType": string | number;
|
|
1166
1793
|
"groupId": string | number;
|
|
1167
1794
|
}): Promise<any>;
|
|
@@ -1171,20 +1798,60 @@ export interface FunctionApi {
|
|
|
1171
1798
|
"includeSystem"?: string | number | boolean;
|
|
1172
1799
|
"type"?: string | number | boolean;
|
|
1173
1800
|
}): Promise<any>;
|
|
1174
|
-
/** `groups.removeMember` — DELETE /groups/{
|
|
1801
|
+
/** `groups.removeMember` — DELETE /groups/{groupId}/members/{userId}. Remove a specific member from a group */
|
|
1175
1802
|
"removeMember"(args: {
|
|
1176
|
-
"groupType": string | number;
|
|
1177
1803
|
"groupId": string | number;
|
|
1178
1804
|
"userId": string | number;
|
|
1805
|
+
"groupType"?: string | number | boolean;
|
|
1179
1806
|
}): Promise<any>;
|
|
1180
|
-
/** `groups.removeMemberByEmail` — DELETE /groups/{
|
|
1807
|
+
/** `groups.removeMemberByEmail` — DELETE /groups/{groupId}/members. Remove a group member or pending invitation by email */
|
|
1181
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: {
|
|
1182
1818
|
"groupType": string | number;
|
|
1183
1819
|
"groupId": string | number;
|
|
1184
1820
|
"email"?: string | number | boolean;
|
|
1185
1821
|
}): Promise<any>;
|
|
1186
|
-
/**
|
|
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 */
|
|
1187
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: {
|
|
1188
1855
|
"groupType": string | number;
|
|
1189
1856
|
"groupId": string | number;
|
|
1190
1857
|
body: unknown;
|
|
@@ -1198,10 +1865,6 @@ export interface FunctionApi {
|
|
|
1198
1865
|
}): Promise<any>;
|
|
1199
1866
|
/** `integrations.list` — GET /integrations. List integrations configured for the app */
|
|
1200
1867
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
1201
|
-
/** `integrations.proxy` — POST /integrations/{integrationKey}/proxy. Proxy a request through a configured integration */
|
|
1202
|
-
"proxy"(args: {
|
|
1203
|
-
"integrationKey": string | number;
|
|
1204
|
-
}): Promise<any>;
|
|
1205
1868
|
};
|
|
1206
1869
|
"locks": {
|
|
1207
1870
|
/** `locks.list` — GET /locks. List all currently-held named locks in the app */
|
|
@@ -1226,19 +1889,26 @@ export interface FunctionApi {
|
|
|
1226
1889
|
"notifications": {
|
|
1227
1890
|
/** `notifications.list` — GET /notifications. List the caller's in-app notification inbox (newest first) */
|
|
1228
1891
|
"list"(args?: {
|
|
1892
|
+
"userId"?: string | number;
|
|
1229
1893
|
"limit"?: string | number | boolean;
|
|
1230
1894
|
"cursor"?: string | number | boolean;
|
|
1231
1895
|
}): Promise<any>;
|
|
1232
1896
|
/** `notifications.listDevices` — GET /me/push-tokens. List the caller's registered push devices */
|
|
1233
|
-
"listDevices"(args?:
|
|
1897
|
+
"listDevices"(args?: {
|
|
1898
|
+
"userId"?: string | number;
|
|
1899
|
+
}): Promise<any>;
|
|
1234
1900
|
/** `notifications.markAllRead` — POST /notifications/read-all. Mark all of the caller's notifications as read */
|
|
1235
|
-
"markAllRead"(args?:
|
|
1901
|
+
"markAllRead"(args?: {
|
|
1902
|
+
"userId"?: string | number;
|
|
1903
|
+
}): Promise<any>;
|
|
1236
1904
|
/** `notifications.markRead` — PATCH /notifications/{notificationId}/read. Mark one of the caller's notifications as read */
|
|
1237
1905
|
"markRead"(args: {
|
|
1238
1906
|
"notificationId": string | number;
|
|
1907
|
+
"userId"?: string | number;
|
|
1239
1908
|
}): Promise<any>;
|
|
1240
1909
|
/** `notifications.registerDevice` — POST /me/push-tokens. Register (upsert) the caller's device push token */
|
|
1241
1910
|
"registerDevice"(args: {
|
|
1911
|
+
"userId"?: string | number;
|
|
1242
1912
|
body: unknown;
|
|
1243
1913
|
}): Promise<any>;
|
|
1244
1914
|
/** `notifications.send` — POST /notifications/send. Send a notification to an app user (durable in-app inbox row + live WS frame) */
|
|
@@ -1246,17 +1916,16 @@ export interface FunctionApi {
|
|
|
1246
1916
|
body: unknown;
|
|
1247
1917
|
}): Promise<any>;
|
|
1248
1918
|
/** `notifications.unreadCount` — GET /notifications/unread-count. Count the caller's unread notifications */
|
|
1249
|
-
"unreadCount"(args?:
|
|
1919
|
+
"unreadCount"(args?: {
|
|
1920
|
+
"userId"?: string | number;
|
|
1921
|
+
}): Promise<any>;
|
|
1250
1922
|
/** `notifications.unregisterDevice` — DELETE /me/push-tokens/{token}. Unregister one of the caller's device push tokens */
|
|
1251
1923
|
"unregisterDevice"(args: {
|
|
1252
1924
|
"token": string | number;
|
|
1925
|
+
"userId"?: string | number;
|
|
1253
1926
|
}): Promise<any>;
|
|
1254
1927
|
};
|
|
1255
1928
|
"prompts": {
|
|
1256
|
-
/** `prompts.execute` — POST /prompts/{promptKey}/execute. Execute a saved prompt */
|
|
1257
|
-
"execute"(args: {
|
|
1258
|
-
"promptKey": string | number;
|
|
1259
|
-
}): Promise<any>;
|
|
1260
1929
|
/** `prompts.run` — POST /prompts/{promptKey}/run. Run a prompt under a server function's grants */
|
|
1261
1930
|
"run"(args: {
|
|
1262
1931
|
"promptKey": string | number;
|
|
@@ -1320,7 +1989,7 @@ export interface FunctionApi {
|
|
|
1320
1989
|
/** `users.list` — GET /users. List app users */
|
|
1321
1990
|
"list"(args?: {
|
|
1322
1991
|
"email"?: string | number | boolean;
|
|
1323
|
-
"userId"?: string | number
|
|
1992
|
+
"userId"?: string | number;
|
|
1324
1993
|
"name"?: string | number | boolean;
|
|
1325
1994
|
"limit"?: string | number | boolean;
|
|
1326
1995
|
"cursor"?: string | number | boolean;
|
|
@@ -1341,6 +2010,11 @@ export interface FunctionApi {
|
|
|
1341
2010
|
"userId": string | number;
|
|
1342
2011
|
body: unknown;
|
|
1343
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>;
|
|
1344
2018
|
/** `users.setRole` — PUT /users/{userId}/role. Set a user's app role */
|
|
1345
2019
|
"setRole"(args: {
|
|
1346
2020
|
"userId": string | number;
|
|
@@ -1541,8 +2215,6 @@ export interface DatabaseHandle<TModels> {
|
|
|
1541
2215
|
operations: Array<Record<string, unknown>>;
|
|
1542
2216
|
atomic?: boolean;
|
|
1543
2217
|
}): Promise<any>;
|
|
1544
|
-
/** Run one of the database type's prepared operations under this function's grants. */
|
|
1545
|
-
runOperation(name: string, params?: Record<string, unknown>): Promise<any>;
|
|
1546
2218
|
}
|
|
1547
2219
|
|
|
1548
2220
|
/**
|
|
@@ -1568,9 +2240,56 @@ export type DocumentModelRow<M extends string> = M extends keyof DocumentSchemas
|
|
|
1568
2240
|
? PlatformRow<DocumentSchemas[M]>
|
|
1569
2241
|
: Record<string, unknown> & { id: string };
|
|
1570
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
|
+
|
|
1571
2272
|
/** The options a document model read takes: a filter object (or its JSON), a page size, a cursor. */
|
|
1572
2273
|
export interface DocumentQueryOptions {
|
|
1573
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
|
+
*/
|
|
1574
2293
|
limit?: number;
|
|
1575
2294
|
cursor?: string;
|
|
1576
2295
|
/**
|
|
@@ -1580,7 +2299,15 @@ export interface DocumentQueryOptions {
|
|
|
1580
2299
|
* Usually stated once on the handle, as ctx.doc(id, { documentFormat: 2 }),
|
|
1581
2300
|
* rather than per read.
|
|
1582
2301
|
*/
|
|
1583
|
-
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;
|
|
1584
2311
|
}
|
|
1585
2312
|
|
|
1586
2313
|
/**
|
|
@@ -1594,21 +2321,38 @@ export interface DocumentQueryOptions {
|
|
|
1594
2321
|
* `model` is NOT a member: the handle already names it and assigns it last, so
|
|
1595
2322
|
* a multi-model blob stays on the raw `ctx.api.documents.records.bulk`
|
|
1596
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.
|
|
1597
2329
|
*/
|
|
1598
2330
|
export type DocumentBatchOp<TRow> =
|
|
1599
2331
|
| { action: "create" | "patch"; id: string; data: Partial<TRow>; precondition?: Record<string, unknown> }
|
|
1600
|
-
| { 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> };
|
|
1601
2334
|
|
|
1602
|
-
/**
|
|
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
|
+
*/
|
|
1603
2340
|
export interface DocumentBulkResult {
|
|
1604
2341
|
applied: number;
|
|
1605
2342
|
added: Array<{ model: string; id: string }>;
|
|
1606
2343
|
updated: Array<{ model: string; id: string }>;
|
|
1607
2344
|
deleted: number;
|
|
2345
|
+
upserted: Array<{ index: number; model: string; id: string; created: boolean }>;
|
|
1608
2346
|
}
|
|
1609
2347
|
|
|
1610
2348
|
export interface DocumentModelHandle<TRow> {
|
|
1611
|
-
|
|
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 }>;
|
|
1612
2356
|
count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
|
|
1613
2357
|
aggregate(body: Record<string, unknown>): Promise<any>;
|
|
1614
2358
|
save(body: { id: string; data: Partial<TRow>; options?: Record<string, unknown> }): Promise<{ record: TRow }>;
|
|
@@ -1631,6 +2375,156 @@ export interface DocumentHandle {
|
|
|
1631
2375
|
model<M extends DocumentModelNames>(modelName: M): DocumentModelHandle<DocumentModelRow<M>>;
|
|
1632
2376
|
}
|
|
1633
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> }>;
|
|
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;
|
|
2439
|
+
}
|
|
2440
|
+
|
|
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 }>;
|
|
2454
|
+
count(options?: { filter?: Record<string, unknown> | string }): Promise<{ count: number }>;
|
|
2455
|
+
/** Counts, sums, averages, minimums and maximums, resolved to the bare row array. */
|
|
2456
|
+
aggregate(body: Record<string, unknown>): Promise<any[]>;
|
|
2457
|
+
/**
|
|
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.
|
|
2462
|
+
*/
|
|
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>;
|
|
2486
|
+
}
|
|
2487
|
+
|
|
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;
|
|
2523
|
+
}
|
|
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
|
+
|
|
1634
2528
|
/**
|
|
1635
2529
|
* One call through a granted integration — #3183.
|
|
1636
2530
|
*
|
|
@@ -1749,13 +2643,23 @@ export interface AgentSessionCreateOptions<K extends SessionAgentKeys> {
|
|
|
1749
2643
|
* Existing users of this app, not the caller, in neither list twice.
|
|
1750
2644
|
*/
|
|
1751
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;
|
|
1752
2652
|
}
|
|
1753
2653
|
|
|
1754
2654
|
/** What `ctx.agents.createSession` answers — #3803. */
|
|
1755
2655
|
export interface AgentSessionCreateResult {
|
|
1756
2656
|
/** The session: what the app keeps and uses for everything but opening. */
|
|
1757
2657
|
sessionId: string;
|
|
1758
|
-
/**
|
|
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
|
+
*/
|
|
1759
2663
|
documentId: string;
|
|
1760
2664
|
}
|
|
1761
2665
|
|
|
@@ -1763,7 +2667,11 @@ export interface AgentSessionCreateResult {
|
|
|
1763
2667
|
export interface AgentSessionInfo {
|
|
1764
2668
|
sessionId: string;
|
|
1765
2669
|
agentKey: string;
|
|
1766
|
-
/**
|
|
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
|
+
*/
|
|
1767
2675
|
documentId: string;
|
|
1768
2676
|
ownerUserId: string;
|
|
1769
2677
|
/** ISO-8601. */
|
|
@@ -1772,10 +2680,55 @@ export interface AgentSessionInfo {
|
|
|
1772
2680
|
scope: string | null;
|
|
1773
2681
|
/** ISO-8601; null when the session's listing row is missing. */
|
|
1774
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;
|
|
1775
2690
|
/** The members, in the order they were added. */
|
|
1776
2691
|
members: { viewers: string[]; participants: string[] };
|
|
1777
|
-
/** The
|
|
2692
|
+
/** The standing on the session of the member the call acted as. */
|
|
1778
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;
|
|
1779
2732
|
}
|
|
1780
2733
|
|
|
1781
2734
|
/** One session in `ctx.agents.listSessions` — #3805. */
|
|
@@ -1783,6 +2736,11 @@ export interface AgentSessionListItem {
|
|
|
1783
2736
|
sessionId: string;
|
|
1784
2737
|
agentKey: string;
|
|
1785
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
|
+
*/
|
|
1786
2744
|
documentId: string;
|
|
1787
2745
|
ownerUserId: string;
|
|
1788
2746
|
role: "owner" | "participant" | "viewer";
|
|
@@ -1790,10 +2748,27 @@ export interface AgentSessionListItem {
|
|
|
1790
2748
|
/** ISO-8601. */
|
|
1791
2749
|
lastActivityAt: string;
|
|
1792
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;
|
|
1793
2762
|
}
|
|
1794
2763
|
|
|
1795
|
-
/** What `ctx.agents.listSessions` takes — #3805.
|
|
2764
|
+
/** What `ctx.agents.listSessions` takes — #3805. */
|
|
1796
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;
|
|
1797
2772
|
/** Only this agent's sessions. */
|
|
1798
2773
|
agent?: string;
|
|
1799
2774
|
/** Only sessions created with exactly this scope. */
|
|
@@ -1804,6 +2779,15 @@ export interface AgentSessionListOptions {
|
|
|
1804
2779
|
cursor?: string;
|
|
1805
2780
|
}
|
|
1806
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
|
+
|
|
1807
2791
|
/** A page of `ctx.agents.listSessions` — #3805. */
|
|
1808
2792
|
export interface AgentSessionListPage {
|
|
1809
2793
|
items: AgentSessionListItem[];
|
|
@@ -1811,6 +2795,33 @@ export interface AgentSessionListPage {
|
|
|
1811
2795
|
nextCursor?: string;
|
|
1812
2796
|
}
|
|
1813
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;
|
|
2822
|
+
documentId: string;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
1814
2825
|
/** One agent's client tools, by name: each one's `input` and `output` (#3798). */
|
|
1815
2826
|
export type AgentClientTools<K extends AgentKeys> = PromptSchemas[K] extends {
|
|
1816
2827
|
agent: { clientTools: infer T };
|
|
@@ -1833,22 +2844,32 @@ export type PromptOutput<K extends string> = K extends keyof PromptSchemas
|
|
|
1833
2844
|
: unknown;
|
|
1834
2845
|
|
|
1835
2846
|
/**
|
|
1836
|
-
* Why a prompt's own answer was refused — #3330. Never
|
|
1837
|
-
* failure, which is what makes "the model returned the wrong
|
|
1838
|
-
* 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.
|
|
1839
2856
|
*/
|
|
1840
2857
|
export type PromptOutputErrorCode =
|
|
1841
2858
|
| "PROMPT_OUTPUT_NOT_JSON"
|
|
1842
|
-
| "PROMPT_OUTPUT_SCHEMA_VIOLATION"
|
|
2859
|
+
| "PROMPT_OUTPUT_SCHEMA_VIOLATION"
|
|
2860
|
+
| "PROMPT_OUTPUT_TRUNCATED";
|
|
1843
2861
|
|
|
1844
2862
|
/**
|
|
1845
2863
|
* Every code the envelope's `errorCode` can carry — #3663, #3813.
|
|
1846
2864
|
*
|
|
1847
|
-
* `PROMPT_UPSTREAM_TIMEOUT`
|
|
1848
|
-
* answer: the provider ran out of time,
|
|
1849
|
-
*
|
|
1850
|
-
*
|
|
1851
|
-
*
|
|
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.
|
|
1852
2873
|
*
|
|
1853
2874
|
* `PROMPT_CRITERIA_INVALID` is the run that never reached a provider: a
|
|
1854
2875
|
* decisions run's `variables.criteria` was refused before the call, so
|
|
@@ -1861,6 +2882,7 @@ export type PromptOutputErrorCode =
|
|
|
1861
2882
|
export type PromptRunErrorCode =
|
|
1862
2883
|
| PromptOutputErrorCode
|
|
1863
2884
|
| "PROMPT_UPSTREAM_TIMEOUT"
|
|
2885
|
+
| "PROMPT_UPSTREAM_REJECTED"
|
|
1864
2886
|
| "PROMPT_CRITERIA_INVALID"
|
|
1865
2887
|
| "PROMPT_STRICT_OUTPUT_SCHEMA_MISSING";
|
|
1866
2888
|
|
|
@@ -1874,6 +2896,12 @@ export interface PromptRunSuccess<TParsed> {
|
|
|
1874
2896
|
errorCode?: null;
|
|
1875
2897
|
metrics?: Record<string, unknown>;
|
|
1876
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;
|
|
1877
2905
|
}
|
|
1878
2906
|
|
|
1879
2907
|
/**
|
|
@@ -1902,6 +2930,12 @@ export interface PromptRunFailure {
|
|
|
1902
2930
|
* empty — so a number here is always the provider's own.
|
|
1903
2931
|
*/
|
|
1904
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;
|
|
1905
2939
|
}
|
|
1906
2940
|
|
|
1907
2941
|
/** The envelope for a key whose declaration says nothing about its output. */
|
|
@@ -1919,6 +2953,12 @@ export interface PromptRunOpenResult {
|
|
|
1919
2953
|
configId: string;
|
|
1920
2954
|
/** The upstream provider's HTTP status on a provider failure — #3663. */
|
|
1921
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;
|
|
1922
2962
|
}
|
|
1923
2963
|
|
|
1924
2964
|
/**
|
|
@@ -2074,6 +3114,16 @@ export interface FunctionContext {
|
|
|
2074
3114
|
/** The HTTP caller, or null for a webhook or cron fire. */
|
|
2075
3115
|
user: FunctionUser | null;
|
|
2076
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;
|
|
2077
3127
|
/**
|
|
2078
3128
|
* Which RUNTIME is hosting this code — #3482.
|
|
2079
3129
|
*
|
|
@@ -2126,7 +3176,42 @@ export interface FunctionContext {
|
|
|
2126
3176
|
* confers nothing: every call is a `documents.records.*` operation on the
|
|
2127
3177
|
* same authority.
|
|
2128
3178
|
*/
|
|
2129
|
-
|
|
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;
|
|
2130
3215
|
/**
|
|
2131
3216
|
* Outbound HTTP, through a granted integration and nowhere else (#3183).
|
|
2132
3217
|
*
|
|
@@ -2144,12 +3229,11 @@ export interface FunctionContext {
|
|
|
2144
3229
|
): Promise<IntegrationCallResult>;
|
|
2145
3230
|
};
|
|
2146
3231
|
/**
|
|
2147
|
-
* Start a TASK
|
|
3232
|
+
* Start another function as a TASK run from inside this one — #3280.
|
|
2148
3233
|
*
|
|
2149
|
-
* The one nested door, and it is a START
|
|
2150
|
-
*
|
|
2151
|
-
* invocation to reach for
|
|
2152
|
-
* `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.
|
|
2153
3237
|
*
|
|
2154
3238
|
* The callee's `access` gate is not consulted — this function's own gate was
|
|
2155
3239
|
* the authorization — and every run in the tree is keyed by whoever started
|
|
@@ -2166,10 +3250,10 @@ export interface FunctionContext {
|
|
|
2166
3250
|
/**
|
|
2167
3251
|
* Run one of the app's prompts, with nothing to declare (#3183, #3279).
|
|
2168
3252
|
*
|
|
2169
|
-
* The
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
*
|
|
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.
|
|
2173
3257
|
*
|
|
2174
3258
|
* TYPED BY KEY (#3330). Where `prompts/<key>.toml` declares an
|
|
2175
3259
|
* `outputSchema`, the platform parses the answer, validates it against that
|
|
@@ -2193,33 +3277,58 @@ export interface FunctionContext {
|
|
|
2193
3277
|
): Promise<PromptRunResult<K>>;
|
|
2194
3278
|
};
|
|
2195
3279
|
/**
|
|
2196
|
-
* 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.
|
|
2197
3283
|
*
|
|
2198
|
-
* `createSession` creates a session
|
|
2199
|
-
*
|
|
2200
|
-
*
|
|
2201
|
-
*
|
|
2202
|
-
*
|
|
2203
|
-
*
|
|
2204
|
-
* `AGENT_SESSION_VARIABLES_INVALID` and `details.errors`.
|
|
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).
|
|
2205
3290
|
*
|
|
2206
|
-
*
|
|
2207
|
-
*
|
|
2208
|
-
*
|
|
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`.
|
|
2209
3296
|
*
|
|
2210
|
-
* `
|
|
2211
|
-
*
|
|
2212
|
-
*
|
|
2213
|
-
*
|
|
2214
|
-
*
|
|
2215
|
-
*
|
|
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.
|
|
2216
3313
|
*/
|
|
2217
3314
|
agents: {
|
|
2218
3315
|
createSession<K extends SessionAgentKeys>(
|
|
2219
3316
|
options: AgentSessionCreateOptions<K>
|
|
2220
3317
|
): Promise<AgentSessionCreateResult>;
|
|
2221
|
-
getSession(
|
|
3318
|
+
getSession(
|
|
3319
|
+
sessionId: string,
|
|
3320
|
+
options?: AgentSessionSubjectOptions
|
|
3321
|
+
): Promise<AgentSessionInfo>;
|
|
2222
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>;
|
|
2223
3332
|
};
|
|
2224
3333
|
/**
|
|
2225
3334
|
* The value of one app secret, under a `secret:<NAME>` grant (#3183).
|
|
@@ -2329,6 +3438,27 @@ export interface FunctionContext {
|
|
|
2329
3438
|
};
|
|
2330
3439
|
}
|
|
2331
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
|
+
|
|
2332
3462
|
/** How the wait between one step's retries grows. */
|
|
2333
3463
|
export type StepBackoff = "constant" | "linear" | "exponential";
|
|
2334
3464
|
|
|
@@ -2426,9 +3556,43 @@ export declare class FunctionRuntimeError extends Error {
|
|
|
2426
3556
|
* {@link FunctionRuntimeError}, which the platform settles as
|
|
2427
3557
|
* `status: "failed"` with `errorCode: "FUNCTION_RUNTIME_REFUSED"` and a
|
|
2428
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.
|
|
2429
3561
|
*/
|
|
2430
3562
|
export declare function assertRuntime(required: "request" | "task"): void;
|
|
2431
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
|
+
|
|
2432
3596
|
/**
|
|
2433
3597
|
* The handler a function exports, typed for one declared key.
|
|
2434
3598
|
*
|
|
@@ -2445,6 +3609,362 @@ export type FunctionHandler<TInput, TOutput> = (
|
|
|
2445
3609
|
step: FunctionStep
|
|
2446
3610
|
) => Promise<TOutput>;
|
|
2447
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
|
+
|
|
2448
3968
|
/**
|
|
2449
3969
|
* Declare a server function's handler, typed from its declaration.
|
|
2450
3970
|
*
|
|
@@ -2459,6 +3979,31 @@ export type FunctionHandler<TInput, TOutput> = (
|
|
|
2459
3979
|
* styles reach the platform bootstrap identically — a plain default export
|
|
2460
3980
|
* taking `(input, ctx, step)` runs exactly as a wrapped one does — so this is
|
|
2461
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.
|
|
2462
4007
|
*/
|
|
2463
4008
|
export declare function defineFunction<K extends FunctionKeys>(
|
|
2464
4009
|
key: K,
|
|
@@ -2468,6 +4013,12 @@ export declare function defineFunction<K extends FunctionKeys>(
|
|
|
2468
4013
|
step: FunctionStep
|
|
2469
4014
|
) => FunctionOutput<K> | Promise<FunctionOutput<K>>
|
|
2470
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
|
+
*/
|
|
2471
4022
|
export declare function defineFunction<TInput = unknown, TOutput = unknown>(
|
|
2472
4023
|
handler: (
|
|
2473
4024
|
input: TInput,
|
|
@@ -2670,11 +4221,22 @@ export declare const stepPolicy: {
|
|
|
2670
4221
|
declare const _default: {
|
|
2671
4222
|
SDK_STUB_VERSION: string;
|
|
2672
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;
|
|
2673
4234
|
defineQuery: typeof defineQuery;
|
|
2674
4235
|
defineMutation: typeof defineMutation;
|
|
2675
4236
|
pMap: typeof pMap;
|
|
2676
4237
|
ulid: typeof ulid;
|
|
2677
4238
|
assertRuntime: typeof assertRuntime;
|
|
4239
|
+
assertTrigger: typeof assertTrigger;
|
|
2678
4240
|
FunctionRuntimeError: typeof FunctionRuntimeError;
|
|
2679
4241
|
};
|
|
2680
4242
|
export default _default;
|