backd-js 0.1.15 → 0.2.0

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.
@@ -0,0 +1,709 @@
1
+ import { Job } from './functions.js';
2
+ export type Client = import('./client.js').Client;
3
+ export type RequestOptions = import('./client.js').RequestOptions;
4
+ export type AdminUser = {
5
+ id: string;
6
+ email: string;
7
+ email_verified: boolean;
8
+ locale: string;
9
+ roles: string[];
10
+ disabled: boolean;
11
+ /**
12
+ * CIDR networks the user's admin requests must come from; empty: no own restriction.
13
+ */
14
+ admin_networks: string[];
15
+ /**
16
+ * CIDR networks the user's login and session must be used from; empty: anywhere.
17
+ */
18
+ login_networks: string[];
19
+ created_at: string;
20
+ updated_at: string;
21
+ /**
22
+ * When the user was erased; a tombstone keeps only its id (and a placeholder email).
23
+ */
24
+ erased_at: string | null;
25
+ };
26
+ export type UserPage = {
27
+ items: AdminUser[];
28
+ limit: number;
29
+ skip: number;
30
+ has_more: boolean;
31
+ };
32
+ export type Invitation = {
33
+ id: string;
34
+ /**
35
+ * Only this email may use it; null for anyone.
36
+ */
37
+ email: string | null;
38
+ created_by: string;
39
+ created_at: string;
40
+ expires_at: string;
41
+ };
42
+ export type OwnedReport = {
43
+ user: {
44
+ id: string;
45
+ status: 'active' | 'deactivated' | 'erased';
46
+ };
47
+ /**
48
+ * `owned` counts the documents the user owns; `pull` and `unset` count, per field, the documents that hold the user.
49
+ */
50
+ collections: Array<{
51
+ database: string;
52
+ collection: string;
53
+ action: 'delete' | 'anonymize' | null;
54
+ owned: number;
55
+ remove?: string[];
56
+ replace?: string[];
57
+ pull?: Record<string, number>;
58
+ unset?: Record<string, number>;
59
+ }>;
60
+ /**
61
+ * `<database>.<collection>` of the collections an erase leaves alone.
62
+ */
63
+ without_policy: string[];
64
+ };
65
+ export type NewInvitation = Invitation & {
66
+ token: string;
67
+ };
68
+ export type SentInvitation = Invitation & {
69
+ sent: true;
70
+ };
71
+ export type APIKeyInfo = {
72
+ name: string;
73
+ role: 'data' | 'admin';
74
+ /**
75
+ * First characters of the key.
76
+ */
77
+ prefix: string;
78
+ /**
79
+ * Where it may be used from; empty: anywhere.
80
+ */
81
+ networks: string[];
82
+ created_at: string;
83
+ last_used_at: string | null;
84
+ expires_at: string | null;
85
+ };
86
+ export type NewAPIKey = APIKeyInfo & {
87
+ key: string;
88
+ };
89
+ export type AuditRecord = {
90
+ id: string;
91
+ at: string;
92
+ /**
93
+ * Such as `user.create`, `role.add`, `apikey.create`, `admin.login`.
94
+ */
95
+ action: string;
96
+ /**
97
+ * `user:<id>`, `key:<name>`, `anonymous`, `config:realm.yaml` or `cli:bootstrap`.
98
+ */
99
+ actor: string;
100
+ /**
101
+ * `user:<id>`, `key:<name>`, `invitation:<id>`, or null.
102
+ */
103
+ target: string | null;
104
+ details: Record<string, unknown>;
105
+ request_id: string | null;
106
+ client_ip: string | null;
107
+ };
108
+ export type SecretInfo = {
109
+ /**
110
+ * Its database scope; empty means the realm scope.
111
+ */
112
+ database: string;
113
+ name: string;
114
+ created_at: string;
115
+ updated_at: string;
116
+ /**
117
+ * Who last set it, such as `user:<id>` or `key:<name>`.
118
+ */
119
+ updated_by: string;
120
+ };
121
+ export type InvocationRecord = {
122
+ id: string;
123
+ at: string;
124
+ /**
125
+ * `<database>/<name>`.
126
+ */
127
+ function: string;
128
+ /**
129
+ * `user:<id>`, `key:<name>`, `anonymous`, ...
130
+ */
131
+ actor: string;
132
+ /**
133
+ * `sync` or `async`.
134
+ */
135
+ mode: string;
136
+ /**
137
+ * `ok`, `function_error`, `timeout`, `memory`, `cpu`, `crash`, `output_too_large`, `busy` or `bundle`.
138
+ */
139
+ status: string;
140
+ /**
141
+ * The function's own error code.
142
+ */
143
+ code: string | null;
144
+ duration_ms: number;
145
+ request_id: string | null;
146
+ /**
147
+ * The async job this call ran for.
148
+ */
149
+ job_id: string | null;
150
+ /**
151
+ * The invocation that called this one with `ctx.call`.
152
+ */
153
+ parent_id: string | null;
154
+ /**
155
+ * `http`, `function`, `cron`, `admin` or `backd:<event>`.
156
+ */
157
+ origin: string | null;
158
+ logs: {
159
+ level: string;
160
+ line: string;
161
+ }[];
162
+ };
163
+ export type InvocationsPage = {
164
+ /**
165
+ * Newest first.
166
+ */
167
+ items: InvocationRecord[];
168
+ limit: number;
169
+ skip: number;
170
+ has_more: boolean;
171
+ };
172
+ export type AuditPage = {
173
+ /**
174
+ * Newest first.
175
+ */
176
+ items: AuditRecord[];
177
+ limit: number;
178
+ skip: number;
179
+ has_more: boolean;
180
+ };
181
+ export type JobSummary = {
182
+ /**
183
+ * For cron runs, `cron_<database>_<function>_<yyyymmddhhmm>` (UTC).
184
+ */
185
+ id: string;
186
+ /**
187
+ * `<database>/<name>`.
188
+ */
189
+ function: string;
190
+ status: 'queued' | 'running' | 'done';
191
+ /**
192
+ * True for a cron run.
193
+ */
194
+ scheduled: boolean;
195
+ /**
196
+ * More than 1 after a worker was lost mid-run.
197
+ */
198
+ attempts: number;
199
+ created_at: string;
200
+ completed_at: string | null;
201
+ /**
202
+ * Null until `done`.
203
+ */
204
+ result: {
205
+ status: string;
206
+ code: string | null;
207
+ duration_ms: number;
208
+ } | null;
209
+ };
210
+ export type JobsPage = {
211
+ /**
212
+ * Newest first.
213
+ */
214
+ items: JobSummary[];
215
+ limit: number;
216
+ skip: number;
217
+ has_more: boolean;
218
+ };
219
+ /**
220
+ * @typedef {import('./client.js').Client} Client
221
+ * @typedef {import('./client.js').RequestOptions} RequestOptions
222
+ */
223
+ /**
224
+ * A user as the admin API shows it.
225
+ * @typedef {object} AdminUser
226
+ * @property {string} id
227
+ * @property {string} email
228
+ * @property {boolean} email_verified
229
+ * @property {string} locale
230
+ * @property {string[]} roles
231
+ * @property {boolean} disabled
232
+ * @property {string[]} admin_networks CIDR networks the user's admin requests must come from; empty: no own restriction.
233
+ * @property {string[]} login_networks CIDR networks the user's login and session must be used from; empty: anywhere.
234
+ * @property {string} created_at
235
+ * @property {string} updated_at
236
+ * @property {string | null} erased_at When the user was erased; a tombstone keeps only its id (and a placeholder email).
237
+ */
238
+ /**
239
+ * @typedef {object} UserPage
240
+ * @property {AdminUser[]} items
241
+ * @property {number} limit
242
+ * @property {number} skip
243
+ * @property {boolean} has_more
244
+ */
245
+ /**
246
+ * @typedef {object} Invitation
247
+ * @property {string} id
248
+ * @property {string | null} email Only this email may use it; null for anyone.
249
+ * @property {string} created_by
250
+ * @property {string} created_at
251
+ * @property {string} expires_at
252
+ */
253
+ /**
254
+ * What erasing a user would do, for the collections that declare a policy
255
+ * (`collection.yaml`); the others are only named in `without_policy`.
256
+ * @typedef {object} OwnedReport
257
+ * @property {{ id: string, status: 'active' | 'deactivated' | 'erased' }} user
258
+ * @property {Array<{ database: string, collection: string, action: 'delete' | 'anonymize' | null, owned: number, remove?: string[], replace?: string[], pull?: Record<string, number>, unset?: Record<string, number> }>} collections
259
+ * `owned` counts the documents the user owns; `pull` and `unset` count, per field, the documents that hold the user.
260
+ * @property {string[]} without_policy `<database>.<collection>` of the collections an erase leaves alone.
261
+ */
262
+ /**
263
+ * @typedef {Invitation & { token: string }} NewInvitation
264
+ * `token` (`bdi_…`) is returned only when the invitation is created.
265
+ */
266
+ /**
267
+ * @typedef {Invitation & { sent: true }} SentInvitation
268
+ * An invitation that was emailed: nobody holds its token.
269
+ */
270
+ /**
271
+ * An API key as the admin API lists it (never the key itself).
272
+ * @typedef {object} APIKeyInfo
273
+ * @property {string} name
274
+ * @property {'data' | 'admin'} role
275
+ * @property {string} prefix First characters of the key.
276
+ * @property {string[]} networks Where it may be used from; empty: anywhere.
277
+ * @property {string} created_at
278
+ * @property {string | null} last_used_at
279
+ * @property {string | null} expires_at
280
+ */
281
+ /**
282
+ * @typedef {APIKeyInfo & { key: string }} NewAPIKey
283
+ * `key` (`bdk_…`) is returned only when the key is created.
284
+ */
285
+ /**
286
+ * One entry of the realm's audit trail. Never holds secrets or emails.
287
+ * @typedef {object} AuditRecord
288
+ * @property {string} id
289
+ * @property {string} at
290
+ * @property {string} action Such as `user.create`, `role.add`, `apikey.create`, `admin.login`.
291
+ * @property {string} actor `user:<id>`, `key:<name>`, `anonymous`, `config:realm.yaml` or `cli:bootstrap`.
292
+ * @property {string | null} target `user:<id>`, `key:<name>`, `invitation:<id>`, or null.
293
+ * @property {Record<string, unknown>} details
294
+ * @property {string | null} request_id
295
+ * @property {string | null} client_ip
296
+ */
297
+ /**
298
+ * A function secret's metadata, as listed: never its value.
299
+ * @typedef {object} SecretInfo
300
+ * @property {string} database Its database scope; empty means the realm scope.
301
+ * @property {string} name
302
+ * @property {string} created_at
303
+ * @property {string} updated_at
304
+ * @property {string} updated_by Who last set it, such as `user:<id>` or `key:<name>`.
305
+ */
306
+ /**
307
+ * One function call in the invocation history: what happened and the
308
+ * function's own console lines, never its input or output.
309
+ * @typedef {object} InvocationRecord
310
+ * @property {string} id
311
+ * @property {string} at
312
+ * @property {string} function `<database>/<name>`.
313
+ * @property {string} actor `user:<id>`, `key:<name>`, `anonymous`, ...
314
+ * @property {string} mode `sync` or `async`.
315
+ * @property {string} status `ok`, `function_error`, `timeout`, `memory`, `cpu`, `crash`, `output_too_large`, `busy` or `bundle`.
316
+ * @property {string | null} code The function's own error code.
317
+ * @property {number} duration_ms
318
+ * @property {string | null} request_id
319
+ * @property {string | null} job_id The async job this call ran for.
320
+ * @property {string | null} parent_id The invocation that called this one with `ctx.call`.
321
+ * @property {string | null} origin `http`, `function`, `cron`, `admin` or `backd:<event>`.
322
+ * @property {{ level: string, line: string }[]} logs
323
+ */
324
+ /**
325
+ * @typedef {object} InvocationsPage
326
+ * @property {InvocationRecord[]} items Newest first.
327
+ * @property {number} limit
328
+ * @property {number} skip
329
+ * @property {boolean} has_more
330
+ */
331
+ /**
332
+ * @typedef {object} AuditPage
333
+ * @property {AuditRecord[]} items Newest first.
334
+ * @property {number} limit
335
+ * @property {number} skip
336
+ * @property {boolean} has_more
337
+ */
338
+ /**
339
+ * An async or scheduled job as the admin listing shows it: its state and
340
+ * how it ended, never its input or output.
341
+ * @typedef {object} JobSummary
342
+ * @property {string} id For cron runs, `cron_<database>_<function>_<yyyymmddhhmm>` (UTC).
343
+ * @property {string} function `<database>/<name>`.
344
+ * @property {'queued' | 'running' | 'done'} status
345
+ * @property {boolean} scheduled True for a cron run.
346
+ * @property {number} attempts More than 1 after a worker was lost mid-run.
347
+ * @property {string} created_at
348
+ * @property {string | null} completed_at
349
+ * @property {{ status: string, code: string | null, duration_ms: number } | null} result Null until `done`.
350
+ */
351
+ /**
352
+ * @typedef {object} JobsPage
353
+ * @property {JobSummary[]} items Newest first.
354
+ * @property {number} limit
355
+ * @property {number} skip
356
+ * @property {boolean} has_more
357
+ */
358
+ /**
359
+ * The admin API: `client.admin`. Needs a client created with an admin API
360
+ * key, or signed in as a user holding one of the realm's admin roles.
361
+ */
362
+ export declare class Admin {
363
+ /** @internal */
364
+ client: import("./client.js").Client;
365
+ /** Users and their roles. */
366
+ users: AdminUsers;
367
+ /** Invitations for realms with `signup: invite`. */
368
+ invitations: AdminInvitations;
369
+ /** The realm's API keys. */
370
+ apiKeys: AdminAPIKeys;
371
+ /** The realm's audit trail (read-only). */
372
+ audit: AdminAudit;
373
+ /** The realm's async and scheduled jobs (read-only). */
374
+ jobs: AdminJobs;
375
+ /** Function secrets: set and delete their values, list their metadata. */
376
+ secrets: AdminSecrets;
377
+ /** The realm's function invocation history (read-only). */
378
+ invocations: AdminInvocations;
379
+ /** @param {Client} client */
380
+ constructor(client: Client);
381
+ /**
382
+ * Runs a function by hand, internal ones included: to re-run a clean-up
383
+ * that failed, or to test a scheduled function. `function` is
384
+ * `<database>/<name>`. With `as` (a user's email) the function runs with
385
+ * that user as `ctx.user`; without it there is no user. Returns the
386
+ * output of a `sync` function, and a `Job` handle for an `async` one,
387
+ * like `db.fn()`. The function's `invoke` rule and `rate_limit` don't
388
+ * apply; every run is audited.
389
+ * @param {string} fn
390
+ * @param {{ input?: unknown, as?: string, idempotencyKey?: string }} [params]
391
+ * @param {RequestOptions} [opts]
392
+ * @returns {Promise<unknown | Job>}
393
+ */
394
+ invokeFunction(fn: string, { input, as, idempotencyKey }?: {
395
+ input?: unknown;
396
+ as?: string;
397
+ idempotencyKey?: string;
398
+ }, opts?: RequestOptions): Promise<unknown | Job>;
399
+ /**
400
+ * @internal
401
+ * @param {import('./client.js').RequestInit} req
402
+ */
403
+ _request(req: import('./client.js').RequestInit): Promise<import("./client.js").RawResponse>;
404
+ }
405
+ declare class AdminUsers {
406
+ /** @internal */
407
+ admin: Admin;
408
+ /** @param {Admin} admin */
409
+ constructor(admin: Admin);
410
+ /**
411
+ * A page of users, sorted by email.
412
+ * @param {{ limit?: number, skip?: number }} [params]
413
+ * @param {RequestOptions} [opts]
414
+ * @returns {Promise<UserPage>}
415
+ */
416
+ list(params?: {
417
+ limit?: number;
418
+ skip?: number;
419
+ }, opts?: RequestOptions): Promise<UserPage>;
420
+ /**
421
+ * The user with this email (case-insensitive), or null.
422
+ * @param {string} email
423
+ * @param {RequestOptions} [opts]
424
+ * @returns {Promise<AdminUser | null>}
425
+ */
426
+ find(email: string, opts?: RequestOptions): Promise<AdminUser | null>;
427
+ /**
428
+ * @param {string} id
429
+ * @param {RequestOptions} [opts]
430
+ * @returns {Promise<AdminUser>}
431
+ */
432
+ get(id: string, opts?: RequestOptions): Promise<AdminUser>;
433
+ /**
434
+ * Creates a user. Without a password they can't sign in until one is set.
435
+ * @param {{ email: string, password?: string }} input
436
+ * @param {RequestOptions} [opts]
437
+ * @returns {Promise<AdminUser>}
438
+ */
439
+ create({ email, password }: {
440
+ email: string;
441
+ password?: string;
442
+ }, opts?: RequestOptions): Promise<AdminUser>;
443
+ /**
444
+ * Changes a user's flags. Disabling ends all their sessions. Emails can't change.
445
+ * @param {string} id
446
+ * @param {{ emailVerified?: boolean, disabled?: boolean }} changes
447
+ * @param {RequestOptions} [opts]
448
+ * @returns {Promise<AdminUser>}
449
+ */
450
+ update(id: string, { emailVerified, disabled }: {
451
+ emailVerified?: boolean;
452
+ disabled?: boolean;
453
+ }, opts?: RequestOptions): Promise<AdminUser>;
454
+ /**
455
+ * Erases a user. **Irreversible.** The user becomes a tombstone at once (the
456
+ * id stays, the email becomes `erased-<id>@erased.invalid`, and their
457
+ * sessions, sign-in methods and email tokens are deleted); a worker then
458
+ * applies the `collection.yaml` policy of every collection that declares one.
459
+ * Resolves with the erase job (`origin: backd:account.erase` in
460
+ * `admin.jobs.list()`); the counts land in the audit trail as `user.erased`.
461
+ * To keep the data, deactivate with `update(id, { disabled: true })`.
462
+ * @param {string} id
463
+ * @param {RequestOptions} [opts]
464
+ * @returns {Promise<{ id: string, status: 'queued' | 'running' | 'done' }>}
465
+ */
466
+ delete(id: string, opts?: RequestOptions): Promise<{
467
+ id: string;
468
+ status: 'queued' | 'running' | 'done';
469
+ }>;
470
+ /**
471
+ * Sets a user's password and ends all their sessions.
472
+ * @param {string} id
473
+ * @param {string} password
474
+ * @param {RequestOptions} [opts]
475
+ * @returns {Promise<void>}
476
+ */
477
+ setPassword(id: string, password: string, opts?: RequestOptions): Promise<void>;
478
+ /**
479
+ * What erasing a user would do: counts per collection that declares a policy,
480
+ * and the collections an erase leaves alone. No document content.
481
+ * @param {string} id
482
+ * @param {RequestOptions} [opts]
483
+ * @returns {Promise<OwnedReport>}
484
+ */
485
+ owned(id: string, opts?: RequestOptions): Promise<OwnedReport>;
486
+ /**
487
+ * Changes a user's email address at once, in a realm with `email`: the new
488
+ * address counts as verified, the user's sessions end, the old address is
489
+ * sent a link to undo the change and the new one is told.
490
+ * @param {string} id
491
+ * @param {string} email
492
+ * @param {RequestOptions} [opts]
493
+ * @returns {Promise<AdminUser>}
494
+ */
495
+ changeEmail(id: string, email: string, opts?: RequestOptions): Promise<AdminUser>;
496
+ /**
497
+ * Assigns a role declared in realm.yaml.
498
+ * @param {string} id
499
+ * @param {string} role
500
+ * @param {RequestOptions} [opts]
501
+ * @returns {Promise<AdminUser>}
502
+ */
503
+ addRole(id: string, role: string, opts?: RequestOptions): Promise<AdminUser>;
504
+ /**
505
+ * Takes a role away.
506
+ * @param {string} id
507
+ * @param {string} role
508
+ * @param {RequestOptions} [opts]
509
+ * @returns {Promise<AdminUser>}
510
+ */
511
+ removeRole(id: string, role: string, opts?: RequestOptions): Promise<AdminUser>;
512
+ /**
513
+ * Replaces the user's network restrictions (IP addresses or CIDR
514
+ * networks); empty lists remove them. Settings in realm.yaml win at the
515
+ * next startup.
516
+ * @param {string} id
517
+ * @param {{ adminNetworks?: string[], loginNetworks?: string[] }} networks
518
+ * @param {RequestOptions} [opts]
519
+ * @returns {Promise<AdminUser>}
520
+ */
521
+ setNetworks(id: string, { adminNetworks, loginNetworks }: {
522
+ adminNetworks?: string[];
523
+ loginNetworks?: string[];
524
+ }, opts?: RequestOptions): Promise<AdminUser>;
525
+ }
526
+ declare class AdminAPIKeys {
527
+ /** @internal */
528
+ admin: Admin;
529
+ /** @param {Admin} admin */
530
+ constructor(admin: Admin);
531
+ /**
532
+ * The realm's API keys, by name; never the keys themselves.
533
+ * @param {RequestOptions} [opts]
534
+ * @returns {Promise<APIKeyInfo[]>}
535
+ */
536
+ list(opts?: RequestOptions): Promise<APIKeyInfo[]>;
537
+ /**
538
+ * Creates a key; store its `key` now, it is never shown again.
539
+ * @param {{ name: string, role?: 'data' | 'admin', expiresIn?: string, networks?: string[] }} input
540
+ * `role` defaults to data; `expiresIn`: days (`90d`) or Go durations (`12h`).
541
+ * @param {RequestOptions} [opts]
542
+ * @returns {Promise<NewAPIKey>}
543
+ */
544
+ create({ name, role, expiresIn, networks }: {
545
+ name: string;
546
+ role?: 'data' | 'admin';
547
+ expiresIn?: string;
548
+ networks?: string[];
549
+ }, opts?: RequestOptions): Promise<NewAPIKey>;
550
+ /**
551
+ * Revokes a key: it stops working at once.
552
+ * @param {string} name
553
+ * @param {RequestOptions} [opts]
554
+ * @returns {Promise<void>}
555
+ */
556
+ revoke(name: string, opts?: RequestOptions): Promise<void>;
557
+ }
558
+ declare class AdminAudit {
559
+ /** @internal */
560
+ admin: Admin;
561
+ /** @param {Admin} admin */
562
+ constructor(admin: Admin);
563
+ /**
564
+ * A page of the audit trail, newest first. `since` and `until` are dates
565
+ * or RFC 3339 strings.
566
+ * @param {{ action?: string, actor?: string, target?: string, since?: Date | string, until?: Date | string, limit?: number, skip?: number }} [params]
567
+ * @param {RequestOptions} [opts]
568
+ * @returns {Promise<AuditPage>}
569
+ */
570
+ list(params?: {
571
+ action?: string;
572
+ actor?: string;
573
+ target?: string;
574
+ since?: Date | string;
575
+ until?: Date | string;
576
+ limit?: number;
577
+ skip?: number;
578
+ }, opts?: RequestOptions): Promise<AuditPage>;
579
+ }
580
+ declare class AdminSecrets {
581
+ /** @internal */
582
+ admin: Admin;
583
+ /** @param {Admin} admin */
584
+ constructor(admin: Admin);
585
+ /**
586
+ * The realm's secrets: scope, name and who last changed them. Values are
587
+ * write-only and never returned.
588
+ * @param {RequestOptions} [opts]
589
+ * @returns {Promise<SecretInfo[]>}
590
+ */
591
+ list(opts?: RequestOptions): Promise<SecretInfo[]>;
592
+ /**
593
+ * Creates a secret or replaces its value; functions read it as
594
+ * `ctx.secrets` within about a minute. Without `database` it is the
595
+ * realm's secret (`realm.NAME` in function.yaml); with it, that
596
+ * database's (`NAME`).
597
+ * @param {string} name Upper-case letters, digits and `_`.
598
+ * @param {string} value
599
+ * @param {{ database?: string }} [scope]
600
+ * @param {RequestOptions} [opts]
601
+ * @returns {Promise<void>}
602
+ */
603
+ set(name: string, value: string, { database }?: {
604
+ database?: string;
605
+ }, opts?: RequestOptions): Promise<void>;
606
+ /**
607
+ * Removes a secret's value: a function that declares it answers
608
+ * `secret_missing` again.
609
+ * @param {string} name
610
+ * @param {{ database?: string }} [scope]
611
+ * @param {RequestOptions} [opts]
612
+ * @returns {Promise<void>}
613
+ */
614
+ delete(name: string, { database }?: {
615
+ database?: string;
616
+ }, opts?: RequestOptions): Promise<void>;
617
+ }
618
+ declare class AdminInvocations {
619
+ /** @internal */
620
+ admin: Admin;
621
+ /** @param {Admin} admin */
622
+ constructor(admin: Admin);
623
+ /**
624
+ * A page of the function invocation history, newest first. `function` is
625
+ * `<database>/<name>`; `since` and `until` are dates or RFC 3339 strings.
626
+ * @param {{ function?: string, requestId?: string, since?: Date | string, until?: Date | string, limit?: number, skip?: number }} [params]
627
+ * @param {RequestOptions} [opts]
628
+ * @returns {Promise<InvocationsPage>}
629
+ */
630
+ list(params?: {
631
+ function?: string;
632
+ requestId?: string;
633
+ since?: Date | string;
634
+ until?: Date | string;
635
+ limit?: number;
636
+ skip?: number;
637
+ }, opts?: RequestOptions): Promise<InvocationsPage>;
638
+ }
639
+ declare class AdminJobs {
640
+ /** @internal */
641
+ admin: Admin;
642
+ /** @param {Admin} admin */
643
+ constructor(admin: Admin);
644
+ /**
645
+ * A page of jobs, newest first: their state and outcome, never their
646
+ * input or output (read one job in full with `Job.status()`/`wait()`).
647
+ * `function` is `<database>/<name>`; `since` and `until` are dates or
648
+ * RFC 3339 strings, on the job's creation time.
649
+ * @param {{ function?: string, status?: 'queued' | 'running' | 'done', scheduled?: boolean, since?: Date | string, until?: Date | string, limit?: number, skip?: number }} [params]
650
+ * @param {RequestOptions} [opts]
651
+ * @returns {Promise<JobsPage>}
652
+ */
653
+ list(params?: {
654
+ function?: string;
655
+ status?: 'queued' | 'running' | 'done';
656
+ scheduled?: boolean;
657
+ since?: Date | string;
658
+ until?: Date | string;
659
+ limit?: number;
660
+ skip?: number;
661
+ }, opts?: RequestOptions): Promise<JobsPage>;
662
+ }
663
+ declare class AdminInvitations {
664
+ /** @internal */
665
+ admin: Admin;
666
+ /** @param {Admin} admin */
667
+ constructor(admin: Admin);
668
+ /**
669
+ * Creates an invitation; deliver its `token` to the invitee.
670
+ * @param {{ email?: string, expiresIn?: string }} [input] `expiresIn`: days (`7d`) or Go durations (`12h`).
671
+ * @param {RequestOptions} [opts]
672
+ * @returns {Promise<NewInvitation>}
673
+ */
674
+ create({ email, expiresIn }?: {
675
+ email?: string;
676
+ expiresIn?: string;
677
+ }, opts?: RequestOptions): Promise<NewInvitation>;
678
+ /**
679
+ * Creates an invitation and has `backd` email it to `email` (needs `email`
680
+ * in the realm's `realm.yaml`): the link opens a page where the person
681
+ * chooses a password, or your own page with `email.links.invitation` (see
682
+ * `auth.acceptInvitation`). There is no token to deliver. `redirectTo` is
683
+ * where the page after accepting may send them (within
684
+ * `email.allowed_redirects`); `locale` is the language of the email.
685
+ * @param {{ email: string, expiresIn?: string, redirectTo?: string, locale?: string }} input
686
+ * @param {RequestOptions} [opts]
687
+ * @returns {Promise<SentInvitation>}
688
+ */
689
+ send({ email, expiresIn, redirectTo, locale }: {
690
+ email: string;
691
+ expiresIn?: string;
692
+ redirectTo?: string;
693
+ locale?: string;
694
+ }, opts?: RequestOptions): Promise<SentInvitation>;
695
+ /**
696
+ * Unused, unexpired invitations, newest first. Tokens are never listed.
697
+ * @param {RequestOptions} [opts]
698
+ * @returns {Promise<Invitation[]>}
699
+ */
700
+ list(opts?: RequestOptions): Promise<Invitation[]>;
701
+ /**
702
+ * Revokes an invitation.
703
+ * @param {string} id
704
+ * @param {RequestOptions} [opts]
705
+ * @returns {Promise<void>}
706
+ */
707
+ revoke(id: string, opts?: RequestOptions): Promise<void>;
708
+ }
709
+ export {};