primitive-functions 0.3.0-alpha.11 → 0.3.0-alpha.12
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 +136 -9
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -265,7 +265,7 @@ export interface CollectionCreateBody {
|
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
267
|
* The typed HTTP profile, generated from the platform's OpenAPI document. Its
|
|
268
|
-
* 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.
|
|
268
|
+
* namespaces mirror the operation ids: agentSessions, analytics, blobBuckets, channels, collections, configVars, connections, databaseTypeConfigs, databases, db3, documents, email, functions, groups, integrations, invitations, locks, notifications, prompts, resourceMetadata, secrets, users.
|
|
269
269
|
* Methods take one options object carrying the operation's path parameters,
|
|
270
270
|
* query parameters, request headers (under their wire names) and `body`.
|
|
271
271
|
*
|
|
@@ -3199,6 +3199,8 @@ export interface FunctionApi {
|
|
|
3199
3199
|
metadata?: Record<string, unknown>;
|
|
3200
3200
|
/** A db3 type of this app. Creating, its current revision is installed before the db3 answers; on an alias that already names a db3, a db3 of another type (or of none) is refused `DB3_TYPE_MISMATCH`. */
|
|
3201
3201
|
type?: string;
|
|
3202
|
+
/** The alias user's level on a db3 this call creates (default `owner`). `reader` or `read-write` writes no owner row and one row for the alias user at that level, so a `reader` never holds write access; it needs an app owner or admin, a console admin, or a function declaring `db3:setOwnerRow`. Ignored when the alias already names a db3. */
|
|
3203
|
+
permission?: "owner" | "read-write" | "reader";
|
|
3202
3204
|
};
|
|
3203
3205
|
}): Promise<{
|
|
3204
3206
|
id: string;
|
|
@@ -7444,6 +7446,100 @@ export interface FunctionApi {
|
|
|
7444
7446
|
/** `integrations.list` — GET /integrations. List integrations configured for the app */
|
|
7445
7447
|
"list"(args?: Record<string, never>): Promise<any>;
|
|
7446
7448
|
};
|
|
7449
|
+
"invitations": {
|
|
7450
|
+
/** `invitations.accept` — POST /invitations/accept. Accept an app invitation */
|
|
7451
|
+
"accept"(args: {
|
|
7452
|
+
body: {
|
|
7453
|
+
inviteToken: string;
|
|
7454
|
+
};
|
|
7455
|
+
}): Promise<{
|
|
7456
|
+
status: "accepted";
|
|
7457
|
+
invitationId: string;
|
|
7458
|
+
grantsResolved: {
|
|
7459
|
+
groups: number;
|
|
7460
|
+
documents: number;
|
|
7461
|
+
};
|
|
7462
|
+
}>;
|
|
7463
|
+
/** `invitations.create` — POST /invitations. Create an app invitation */
|
|
7464
|
+
"create"(args: {
|
|
7465
|
+
body: {
|
|
7466
|
+
/** Who to invite. Stored trimmed and lowercased. */
|
|
7467
|
+
email: string;
|
|
7468
|
+
/** The role the invitee gets at sign-up. Defaults to `member`; a server function may invite only at `member`. */
|
|
7469
|
+
role?: "member" | "admin";
|
|
7470
|
+
/** When the invitation expires (ISO 8601). Defaults to seven days. */
|
|
7471
|
+
expiresAt?: string;
|
|
7472
|
+
source?: string;
|
|
7473
|
+
note?: string;
|
|
7474
|
+
/** Send the platform's invitation email from the caller. Needs the app's `baseUrl`. */
|
|
7475
|
+
sendEmail?: boolean;
|
|
7476
|
+
};
|
|
7477
|
+
}): Promise<{
|
|
7478
|
+
invitationId: string;
|
|
7479
|
+
email: string;
|
|
7480
|
+
role: string;
|
|
7481
|
+
invitedBy: string;
|
|
7482
|
+
invitedAt: string;
|
|
7483
|
+
expiresAt: string;
|
|
7484
|
+
accepted: boolean;
|
|
7485
|
+
appId: string;
|
|
7486
|
+
source: string | null;
|
|
7487
|
+
note: string | null;
|
|
7488
|
+
inviteToken: string | null;
|
|
7489
|
+
}>;
|
|
7490
|
+
/** `invitations.delete` — DELETE /invitations/{invitationId}. Delete an app invitation */
|
|
7491
|
+
"delete"(args: {
|
|
7492
|
+
"invitationId": string | number;
|
|
7493
|
+
}): Promise<{
|
|
7494
|
+
success: boolean;
|
|
7495
|
+
message: string;
|
|
7496
|
+
}>;
|
|
7497
|
+
/** `invitations.get` — GET /invitations/{invitationId}. Get an app invitation by id */
|
|
7498
|
+
"get"(args: {
|
|
7499
|
+
"invitationId": string | number;
|
|
7500
|
+
}): Promise<{
|
|
7501
|
+
invitationId: string;
|
|
7502
|
+
email: string;
|
|
7503
|
+
role: string;
|
|
7504
|
+
invitedBy: string;
|
|
7505
|
+
invitedAt: string;
|
|
7506
|
+
expiresAt: string | null;
|
|
7507
|
+
accepted: boolean;
|
|
7508
|
+
acceptedAt: string | null;
|
|
7509
|
+
source: string | null;
|
|
7510
|
+
note: string | null;
|
|
7511
|
+
inviteToken: string | null;
|
|
7512
|
+
status: "pending" | "expired" | "accepted";
|
|
7513
|
+
}>;
|
|
7514
|
+
/** `invitations.list` — GET /invitations. List app invitations */
|
|
7515
|
+
"list"(args?: {
|
|
7516
|
+
"limit"?: string | number | boolean;
|
|
7517
|
+
"cursor"?: string | number | boolean;
|
|
7518
|
+
}): Promise<{
|
|
7519
|
+
items: {
|
|
7520
|
+
invitationId: string;
|
|
7521
|
+
email: string;
|
|
7522
|
+
role: string;
|
|
7523
|
+
invitedBy: string;
|
|
7524
|
+
invitedAt: string;
|
|
7525
|
+
expiresAt: string | null;
|
|
7526
|
+
accepted: boolean;
|
|
7527
|
+
acceptedAt: string | null;
|
|
7528
|
+
source: string | null;
|
|
7529
|
+
note: string | null;
|
|
7530
|
+
}[];
|
|
7531
|
+
hasMore: boolean;
|
|
7532
|
+
nextCursor?: string;
|
|
7533
|
+
prevCursor?: string;
|
|
7534
|
+
}>;
|
|
7535
|
+
/** `invitations.quota` — GET /invitations/quota. Get the current user's invitation quota */
|
|
7536
|
+
"quota"(args?: Record<string, never>): Promise<{
|
|
7537
|
+
used: number;
|
|
7538
|
+
limit: number;
|
|
7539
|
+
remaining: number;
|
|
7540
|
+
unlimited: boolean;
|
|
7541
|
+
}>;
|
|
7542
|
+
};
|
|
7447
7543
|
"locks": {
|
|
7448
7544
|
/** `locks.forceRelease` — POST /locks/force-release. Free a held named lock with no handle (operator's door) */
|
|
7449
7545
|
"forceRelease"(args: {
|
|
@@ -8300,18 +8396,45 @@ export type Db3ModelRow<TModels, M extends string> = M extends keyof TModels
|
|
|
8300
8396
|
? PlatformRow<TModels[M]>
|
|
8301
8397
|
: Record<string, unknown> & { id: string };
|
|
8302
8398
|
|
|
8399
|
+
/**
|
|
8400
|
+
* A change to a string-set field, in place of the whole set: `$add` and
|
|
8401
|
+
* `$remove` merge with concurrent writers' changes, `$clear` empties it.
|
|
8402
|
+
*
|
|
8403
|
+
* ```ts
|
|
8404
|
+
* await tasks.patch(id, { data: { tags: { $add: ["urgent"], $remove: ["low"] } } });
|
|
8405
|
+
* ```
|
|
8406
|
+
*/
|
|
8407
|
+
export interface Db3StringSetChange {
|
|
8408
|
+
$add?: string[];
|
|
8409
|
+
$remove?: string[];
|
|
8410
|
+
$clear?: true;
|
|
8411
|
+
}
|
|
8412
|
+
|
|
8413
|
+
/**
|
|
8414
|
+
* The `data` a db3 write takes: any of the row's fields, each optional, and a
|
|
8415
|
+
* `Db3StringSetChange` on a string-set field beside the set itself.
|
|
8416
|
+
*/
|
|
8417
|
+
export type Db3WriteData<TRow> = {
|
|
8418
|
+
[K in keyof TRow]?: TRow[K] | (NonNullable<TRow[K]> extends string[] ? Db3StringSetChange : never);
|
|
8419
|
+
};
|
|
8420
|
+
|
|
8303
8421
|
/**
|
|
8304
8422
|
* One op of a db3 `bulk`, typed to a model's row. `condition` is a guard in
|
|
8305
8423
|
* the query filter grammar: the op applies only when the record is live and
|
|
8306
8424
|
* matches it.
|
|
8307
8425
|
*/
|
|
8308
8426
|
export type Db3BulkOp<TRow = Record<string, unknown>> =
|
|
8309
|
-
| { action: "create"; id?: string; data:
|
|
8310
|
-
| { action: "patch"; id: string; data:
|
|
8427
|
+
| { action: "create"; id?: string; data: Db3WriteData<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
8428
|
+
| { action: "patch"; id: string; data: Db3WriteData<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
8311
8429
|
| { action: "delete"; id: string; condition?: Record<string, unknown>; requestId?: string }
|
|
8312
|
-
| { action: "upsert"; constraint: string; id?: string; data:
|
|
8430
|
+
| { action: "upsert"; constraint: string; id?: string; data: Db3WriteData<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
8313
8431
|
| { action: "increment"; id: string; fields: Record<string, number>; condition?: Record<string, unknown>; requestId?: string };
|
|
8314
8432
|
|
|
8433
|
+
/** One op of a handle-level `bulk`: its `model` picks the row its `data` is typed to. */
|
|
8434
|
+
export type Db3HandleBulkOp<TModels> = {
|
|
8435
|
+
[M in Db3ModelNames<TModels>]: Db3BulkOp<Db3ModelRow<TModels, M>> & { model: M };
|
|
8436
|
+
}[Db3ModelNames<TModels>];
|
|
8437
|
+
|
|
8315
8438
|
/**
|
|
8316
8439
|
* What `db3.records.bulk` answers. With `atomic: false` each op is applied on
|
|
8317
8440
|
* its own and `results` names each one, a refused op carrying its `code`.
|
|
@@ -8334,7 +8457,8 @@ export interface Db3BulkResult {
|
|
|
8334
8457
|
/**
|
|
8335
8458
|
* One db3 model, bound to its db3 and its model name — a thin binding over
|
|
8336
8459
|
* `ctx.api.db3.records.*` with the routes' own answers. A refusal rejects
|
|
8337
|
-
* with the route's error: a
|
|
8460
|
+
* with the route's error: a db3 that does not exist in this app (never
|
|
8461
|
+
* created, or deleted) is 404 `DB3_NOT_FOUND`, a failing `condition` 409
|
|
8338
8462
|
* `DB3_CONDITION_NOT_MET`, a missing record on `increment` 404
|
|
8339
8463
|
* `DB3_RECORD_NOT_FOUND`, a model the type does not declare 400
|
|
8340
8464
|
* `DB3_MODEL_NOT_DECLARED`.
|
|
@@ -8355,7 +8479,7 @@ export interface Db3ModelHandle<TRow> {
|
|
|
8355
8479
|
*/
|
|
8356
8480
|
save(body: {
|
|
8357
8481
|
id?: string;
|
|
8358
|
-
data:
|
|
8482
|
+
data: Db3WriteData<TRow>;
|
|
8359
8483
|
condition?: Record<string, unknown>;
|
|
8360
8484
|
ifNotExists?: boolean;
|
|
8361
8485
|
upsertOn?: string;
|
|
@@ -8364,7 +8488,7 @@ export interface Db3ModelHandle<TRow> {
|
|
|
8364
8488
|
/** Merge fields into an existing record. */
|
|
8365
8489
|
patch(
|
|
8366
8490
|
recordId: string,
|
|
8367
|
-
body: { data:
|
|
8491
|
+
body: { data: Db3WriteData<TRow>; condition?: Record<string, unknown>; requestId?: string }
|
|
8368
8492
|
): Promise<{ record: TRow; appliedFields?: Record<string, unknown> }>;
|
|
8369
8493
|
/** Delete a record; deleting one that does not exist is not an error unless a `condition` asks. */
|
|
8370
8494
|
delete(recordId: string, body?: { condition?: Record<string, unknown>; requestId?: string }): Promise<{ deleted: boolean }>;
|
|
@@ -8390,7 +8514,7 @@ export interface Db3Handle<TModels> {
|
|
|
8390
8514
|
model<M extends Db3ModelNames<TModels>>(modelName: M): Db3ModelHandle<Db3ModelRow<TModels, M>>;
|
|
8391
8515
|
/** Ops across models in one request; each op names its `model`. */
|
|
8392
8516
|
bulk(
|
|
8393
|
-
ops: Array<
|
|
8517
|
+
ops: Array<Db3HandleBulkOp<TModels>>,
|
|
8394
8518
|
options?: { atomic?: boolean; requestId?: string }
|
|
8395
8519
|
): Promise<Db3BulkResult>;
|
|
8396
8520
|
}
|
|
@@ -9556,7 +9680,10 @@ export interface AuthDocumentModelHandle<TRow> {
|
|
|
9556
9680
|
query(options?: DocumentQueryOptions): Promise<{ items: Array<TRow & { _related?: Record<string, any> }>; hasMore: boolean; nextCursor?: string }>;
|
|
9557
9681
|
}
|
|
9558
9682
|
|
|
9559
|
-
/**
|
|
9683
|
+
/**
|
|
9684
|
+
* One db3 model, for reading inside `authorize`. A db3 that does not exist in
|
|
9685
|
+
* this app rejects 404 `DB3_NOT_FOUND`.
|
|
9686
|
+
*/
|
|
9560
9687
|
export interface AuthDb3ModelHandle<TRow> {
|
|
9561
9688
|
/** The record with this id, or `null` when there is none. */
|
|
9562
9689
|
get(recordId: string): Promise<TRow | null>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primitive-functions",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.12",
|
|
4
4
|
"description": "The module a Primitive server function imports. Supplied by the platform at invoke time; reserved here so the name is ours before the runtime lands.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Primitive LLC",
|