@rebasepro/types 0.12.0 → 0.12.1-canary.g06f263c
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/dist/controllers/client.d.ts +34 -0
- package/dist/index.es.js +38 -4
- package/dist/index.es.js.map +1 -1
- package/dist/types/backend.d.ts +19 -0
- package/dist/types/cron.d.ts +31 -0
- package/dist/types/database_adapter.d.ts +26 -0
- package/dist/types/policy.d.ts +34 -2
- package/package.json +4 -4
- package/src/controllers/client.ts +37 -0
- package/src/types/backend.ts +22 -0
- package/src/types/cron.ts +32 -0
- package/src/types/database_adapter.ts +32 -0
- package/src/types/policy.ts +38 -2
|
@@ -83,6 +83,20 @@ export interface AuthClient {
|
|
|
83
83
|
* Manually refresh the session token
|
|
84
84
|
*/
|
|
85
85
|
refreshSession(): Promise<RebaseSession>;
|
|
86
|
+
/**
|
|
87
|
+
* Whether a session could exist that this client has not loaded yet.
|
|
88
|
+
*
|
|
89
|
+
* `false` means the only way this client can hold a session is an explicit
|
|
90
|
+
* sign-in during this page's lifetime: it neither persists sessions nor
|
|
91
|
+
* carries an httpOnly auth cookie, so there is nothing on disk or in the
|
|
92
|
+
* browser to restore from. A caller that would otherwise probe the server
|
|
93
|
+
* — `getUser()` on mount, say — can skip it, because the answer is already
|
|
94
|
+
* known and the request can only ever fail.
|
|
95
|
+
*
|
|
96
|
+
* Optional so that alternative {@link AuthClient} implementations need not
|
|
97
|
+
* supply it; treat a missing implementation as "unknown, go ahead and ask".
|
|
98
|
+
*/
|
|
99
|
+
canRestoreSession?: () => boolean;
|
|
86
100
|
}
|
|
87
101
|
/**
|
|
88
102
|
* User record as returned by the Admin API (`GET /admin/users`, etc.).
|
|
@@ -337,6 +351,16 @@ export interface RebaseClient<DB = unknown> {
|
|
|
337
351
|
apiKeys?: ApiKeysAPI;
|
|
338
352
|
/** Base HTTP URL of the backend server */
|
|
339
353
|
baseUrl?: string;
|
|
354
|
+
/**
|
|
355
|
+
* The path every API route is mounted under, appended to {@link baseUrl}.
|
|
356
|
+
*
|
|
357
|
+
* `"/api"` unless the backend was configured with a different `basePath`
|
|
358
|
+
* and the client told to match. Exposed because code that builds a URL by
|
|
359
|
+
* hand — rather than going through the client's own methods — otherwise has
|
|
360
|
+
* to guess, and guessing `/api` is wrong for exactly the projects that set
|
|
361
|
+
* the option.
|
|
362
|
+
*/
|
|
363
|
+
apiPath?: string;
|
|
340
364
|
/** WebSocket client for realtime subscriptions */
|
|
341
365
|
ws?: RebaseWebSocket;
|
|
342
366
|
/** Set the auth token for subsequent requests */
|
|
@@ -435,6 +459,16 @@ export interface RebaseBrowserClient<DB = unknown> {
|
|
|
435
459
|
apiKeys?: ApiKeysAPI;
|
|
436
460
|
/** Base HTTP URL of the backend server */
|
|
437
461
|
baseUrl?: string;
|
|
462
|
+
/**
|
|
463
|
+
* The path every API route is mounted under, appended to {@link baseUrl}.
|
|
464
|
+
*
|
|
465
|
+
* `"/api"` unless the backend was configured with a different `basePath`
|
|
466
|
+
* and the client told to match. Exposed because code that builds a URL by
|
|
467
|
+
* hand — rather than going through the client's own methods — otherwise has
|
|
468
|
+
* to guess, and guessing `/api` is wrong for exactly the projects that set
|
|
469
|
+
* the option.
|
|
470
|
+
*/
|
|
471
|
+
apiPath?: string;
|
|
438
472
|
/** WebSocket client for realtime subscriptions */
|
|
439
473
|
ws?: RebaseWebSocket;
|
|
440
474
|
/** Set the auth token for subsequent requests */
|
package/dist/index.es.js
CHANGED
|
@@ -222,7 +222,7 @@ var REST_TO_CANONICAL = {
|
|
|
222
222
|
* Operators that test for null/not-null and therefore ignore their value.
|
|
223
223
|
* Codecs normalize the value of these conditions to `null`.
|
|
224
224
|
*/
|
|
225
|
-
var NULL_OPS = new Set(["is-null", "is-not-null"]);
|
|
225
|
+
var NULL_OPS = /* @__PURE__ */ new Set(["is-null", "is-not-null"]);
|
|
226
226
|
/**
|
|
227
227
|
* Every canonical operator, in a stable order. Useful for engine capability
|
|
228
228
|
* declarations ({@link DataSourceCapabilities.filterOperators}) and for
|
|
@@ -602,12 +602,46 @@ function isToMany(relation) {
|
|
|
602
602
|
*
|
|
603
603
|
* The consequence for policy authors is that **`auth.uid() IS NOT NULL` is a
|
|
604
604
|
* tautology on the user path** — it is true for anonymous visitors too. Use
|
|
605
|
-
* {@link policy.authenticated}
|
|
606
|
-
*
|
|
605
|
+
* {@link policy.authenticated} to mean "signed in", and
|
|
606
|
+
* {@link policy.serverContext} to mean "the trusted server context". Do not
|
|
607
|
+
* hand-write the comparison: see {@link ANONYMOUS_USER_IDS} for why one
|
|
608
|
+
* literal is not enough.
|
|
607
609
|
*
|
|
608
610
|
* @group Models
|
|
609
611
|
*/
|
|
610
612
|
var ANONYMOUS_USER_ID = "anonymous";
|
|
613
|
+
/**
|
|
614
|
+
* Every uid that has ever meant "nobody is signed in" — newest first.
|
|
615
|
+
*
|
|
616
|
+
* There are two because there were two. The types, the policy compiler, the
|
|
617
|
+
* JavaScript evaluator and the linter were all built on
|
|
618
|
+
* {@link ANONYMOUS_USER_ID}, while the request path scoped unauthenticated
|
|
619
|
+
* callers as `'anon'` — so `policy.authenticated()`, which compiled to
|
|
620
|
+
* `auth.uid() <> 'anonymous'`, was *true* for an anonymous visitor. The
|
|
621
|
+
* sanctioned way to write "signed in" granted to everyone, and the linter
|
|
622
|
+
* flagged the spelling that actually worked as a foreign convention.
|
|
623
|
+
*
|
|
624
|
+
* The request path now reports {@link ANONYMOUS_USER_ID}. `'anon'` stays here
|
|
625
|
+
* because policies outlive the server that generated them: a database still
|
|
626
|
+
* holding policies from before the fix, or a project whose server has not been
|
|
627
|
+
* upgraded yet, must not become a grant in either direction. Compile against
|
|
628
|
+
* this list, not against a single literal.
|
|
629
|
+
*
|
|
630
|
+
* No real user id is ever one of these, so a match is always "not signed in".
|
|
631
|
+
*
|
|
632
|
+
* @group Models
|
|
633
|
+
*/
|
|
634
|
+
var ANONYMOUS_USER_IDS = [ANONYMOUS_USER_ID, "anon"];
|
|
635
|
+
/**
|
|
636
|
+
* Whether a uid stands for "no one is signed in", in any spelling rebase has
|
|
637
|
+
* used. `null`/`undefined` is the trusted server context, not an anonymous
|
|
638
|
+
* caller, and is therefore **not** anonymous — see {@link ANONYMOUS_USER_ID}.
|
|
639
|
+
*
|
|
640
|
+
* @group Models
|
|
641
|
+
*/
|
|
642
|
+
function isAnonymousUid(uid) {
|
|
643
|
+
return typeof uid === "string" && ANONYMOUS_USER_IDS.includes(uid);
|
|
644
|
+
}
|
|
611
645
|
/** @group Models */
|
|
612
646
|
var policy = {
|
|
613
647
|
true: () => ({ kind: "true" }),
|
|
@@ -1145,6 +1179,6 @@ function isPublicStoragePath(path) {
|
|
|
1145
1179
|
return p.startsWith("public/") || p.startsWith(`default/public/`);
|
|
1146
1180
|
}
|
|
1147
1181
|
//#endregion
|
|
1148
|
-
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_LIST_LIMIT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REST_TO_CANONICAL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, canonicalSchemaPayload, computeSchemaVersion, deserializeCollections, findStorageSuffixCollision, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasForeignKeyOnTarget, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isRelationalCollectionConfig, isSQLAdmin, isSchemaAdmin, isSerializedCollectionRef, isToMany, normalizeStorageSources, policy, registerDataSourceCapabilities, resolveClientListLimit, serializeCollections, storageEnvSuffix, toCanonicalOp };
|
|
1182
|
+
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, ANONYMOUS_USER_IDS, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_LIST_LIMIT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIREBASE_CAPABILITIES, GeoPoint, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REST_TO_CANONICAL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, canonicalSchemaPayload, computeSchemaVersion, deserializeCollections, findStorageSuffixCollision, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasForeignKeyOnTarget, isAnonymousUid, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isRelationalCollectionConfig, isSQLAdmin, isSchemaAdmin, isSerializedCollectionRef, isToMany, normalizeStorageSources, policy, registerDataSourceCapabilities, resolveClientListLimit, serializeCollections, storageEnvSuffix, toCanonicalOp };
|
|
1149
1183
|
|
|
1150
1184
|
//# sourceMappingURL=index.es.js.map
|