@rebasepro/types 0.26.0 → 0.27.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.
@@ -70,9 +70,22 @@ export interface AuthClient {
70
70
  */
71
71
  getUser(): Promise<User | null>;
72
72
  /**
73
- * Get the currently active session
73
+ * The session as it is now, or `null`.
74
+ *
75
+ * A snapshot: renewing the access token (about hourly) replaces the
76
+ * session with a new object, so one kept from an earlier call carries a
77
+ * token the server refuses once it expires. Read it when you need it, and
78
+ * use {@link getAccessToken} for a token to send.
74
79
  */
75
80
  getSession(): RebaseSession | null;
81
+ /**
82
+ * The access token to send on a request of your own, renewed first when
83
+ * it has expired or is about to; `null` when no one is signed in.
84
+ *
85
+ * Optional so that alternative {@link AuthClient} implementations need not
86
+ * supply it.
87
+ */
88
+ getAccessToken?: () => Promise<string | null>;
76
89
  /**
77
90
  * Get the current user's active sessions
78
91
  */
@@ -162,6 +175,38 @@ export interface PickedUser {
162
175
  displayName: string | null;
163
176
  photoURL: string | null;
164
177
  }
178
+ /**
179
+ * A guest as `GET /admin/guests` lists one: a row anonymous sign-in made, that
180
+ * has not become an account.
181
+ *
182
+ * @group Admin
183
+ */
184
+ export interface AdminGuest {
185
+ uid: string;
186
+ createdAt: string;
187
+ /**
188
+ * The last time this guest's session was issued or refreshed: `createdAt`
189
+ * for one that has no refresh token left.
190
+ */
191
+ lastSeenAt: string;
192
+ }
193
+ /**
194
+ * One batch of `DELETE /admin/guests`. Repeat the call while `remaining` is not
195
+ * 0, passing how many have been skipped so far as `offset`.
196
+ *
197
+ * @group Admin
198
+ */
199
+ export interface DeleteGuestsResult {
200
+ deleted: number;
201
+ /** The guests left in place, and why: a `beforeUserDelete` veto, a row of the project's own that requires them. */
202
+ skipped: Array<{
203
+ uid: string;
204
+ code: string;
205
+ message: string;
206
+ }>;
207
+ /** How many matching guests this batch did not reach. */
208
+ remaining: number;
209
+ }
165
210
  /**
166
211
  * Client-side Admin API interface.
167
212
  * Provides user management operations.
@@ -520,7 +565,7 @@ export interface RebaseClient<DB = unknown> {
520
565
  * call through it is refused with `403 SIMULATION_READ_ONLY`, since it
521
566
  * would run as the simulated identity rather than the administrator.
522
567
  */
523
- simulate?(simulation: AccessSimulation): RebaseClient<Record<string, unknown>>;
568
+ simulate?(simulation: AccessSimulation): RebaseClient<DB>;
524
569
  /**
525
570
  * POST to an arbitrary path on the backend — the escape hatch, not the way
526
571
  * to call a function.
@@ -179,6 +179,70 @@ export declare interface DownloadMetadata {
179
179
  */
180
180
  public?: boolean;
181
181
  }
182
+ /**
183
+ * What serving an object needs to know before deciding whether to read it.
184
+ * See {@link StorageSource.statObject}.
185
+ *
186
+ * @group Models
187
+ */
188
+ export interface StoredObjectInfo {
189
+ /** The whole object's size in bytes. */
190
+ size: number;
191
+ /** The stored content type — the uploader's claim, not a sniffed one. */
192
+ contentType: string;
193
+ /**
194
+ * The object's own modification time, in milliseconds since the epoch.
195
+ * The routes build `ETag`, `Last-Modified` and the transform cache key from
196
+ * it, so it must be the object's version, not the time of the read.
197
+ */
198
+ lastModified: number;
199
+ }
200
+ /**
201
+ * An inclusive byte range, as `Range: bytes=start-end` names one.
202
+ *
203
+ * @group Models
204
+ */
205
+ export interface StoredObjectRange {
206
+ start: number;
207
+ end: number;
208
+ }
209
+ /**
210
+ * An object's bytes as a stream. See {@link StorageSource.getObjectStream}.
211
+ *
212
+ * @group Models
213
+ */
214
+ export interface StoredObjectStream extends StoredObjectInfo {
215
+ /** The bytes: the range when {@link range} is set, the whole object otherwise. */
216
+ stream: ReadableStream<Uint8Array>;
217
+ /**
218
+ * The range {@link stream} holds — the one asked for — or absent when it
219
+ * holds the whole object. A controller may answer a range with the whole
220
+ * object, as HTTP lets a server do; the caller then serves it whole.
221
+ */
222
+ range?: StoredObjectRange;
223
+ }
224
+ /**
225
+ * A write of bytes whose length is not known yet. See
226
+ * {@link StorageSource.putObjectStream}.
227
+ *
228
+ * @group Models
229
+ */
230
+ export interface PutObjectStreamProps {
231
+ /** Read once, to its end. A controller cannot retry a stream it has consumed. */
232
+ stream: ReadableStream<Uint8Array>;
233
+ key: string;
234
+ contentType?: string;
235
+ bucket?: string;
236
+ /** Refuse the write once the stream passes this many bytes. */
237
+ maxBytes?: number;
238
+ }
239
+ /**
240
+ * @group Models
241
+ */
242
+ export interface PutObjectStreamResult extends UploadFileResult {
243
+ /** How many bytes were written. */
244
+ size: number;
245
+ }
182
246
  /**
183
247
  * @group Models
184
248
  */
@@ -204,6 +268,32 @@ export interface StorageSource {
204
268
  * @param bucket
205
269
  */
206
270
  getObject: (key: string, bucket?: string) => Promise<File | null>;
271
+ /**
272
+ * Describe an object without reading its bytes, or `null` when there is no
273
+ * such object. Server-side storage only.
274
+ */
275
+ statObject?: (key: string, bucket?: string) => Promise<StoredObjectInfo | null>;
276
+ /**
277
+ * Read an object, or one byte range of it, as a stream, or `null` when
278
+ * there is no such object. Server-side storage only.
279
+ *
280
+ * The stream holds a file or a connection until it is read to the end or
281
+ * cancelled, so a caller that decides not to read it must cancel it.
282
+ */
283
+ getObjectStream?: (key: string, options?: {
284
+ bucket?: string;
285
+ range?: StoredObjectRange;
286
+ }) => Promise<StoredObjectStream | null>;
287
+ /**
288
+ * Write an object from a stream, holding a chunk at a time however large it
289
+ * is. Server-side storage only.
290
+ *
291
+ * Rejects with `ObjectTooLargeError` past `maxBytes`, and on that or any
292
+ * other failure leaves no object at the key. The controller's upload limits
293
+ * do not apply: this is how the server stores something of its own, and
294
+ * `maxBytes` is its limit.
295
+ */
296
+ putObjectStream?: (props: PutObjectStreamProps) => Promise<PutObjectStreamResult>;
207
297
  /**
208
298
  * Delete an object.
209
299
  * @param key
@@ -221,6 +311,28 @@ export interface StorageSource {
221
311
  pageToken?: string;
222
312
  }) => Promise<StorageListResult>;
223
313
  }
314
+ /**
315
+ * What the SDK's `putObject` takes. The server's controllers need a key; the
316
+ * SDK does not: with none, the server names the object after the uploaded
317
+ * file. And the SDK uploads any `Blob` — one that is not a `File` travels as a
318
+ * file called "blob".
319
+ *
320
+ * @group Models
321
+ */
322
+ export interface ClientUploadFileProps extends Omit<UploadFileProps, "key" | "file"> {
323
+ file: Blob;
324
+ key?: string;
325
+ }
326
+ /**
327
+ * The SDK's storage source (`client.storage`). A {@link StorageSource} whose
328
+ * upload takes {@link ClientUploadFileProps} — a wider argument, so it is
329
+ * still a `StorageSource` wherever one is asked for.
330
+ *
331
+ * @group Models
332
+ */
333
+ export interface ClientStorageSource extends Omit<StorageSource, "putObject"> {
334
+ putObject: (props: ClientUploadFileProps) => Promise<UploadFileResult>;
335
+ }
224
336
  /**
225
337
  * Result returned by list().
226
338
  * @public