@rebasepro/types 0.21.0 → 0.21.1
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/README.md +16 -19
- package/dist/controllers/data_driver.d.ts +10 -1
- package/dist/index.es.js +55 -1
- package/dist/index.es.js.map +1 -1
- package/dist/types/auth_adapter.d.ts +11 -1
- package/dist/types/backend.d.ts +11 -4
- package/dist/types/backup.d.ts +7 -0
- package/dist/types/collections.d.ts +17 -3
- package/dist/types/env_boolean.d.ts +35 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/websockets.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,31 +9,31 @@ pnpm add @rebasepro/types
|
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
ESM-only: `"type": "module"` with no CommonJS build, so it is loaded with
|
|
12
|
-
`import`.
|
|
13
|
-
`require(esm)
|
|
12
|
+
`import`. It needs Node `>=22.22.0` (its `engines` floor), where `require()`
|
|
13
|
+
of it resolves too: Node has supported `require(esm)` since 22.12.
|
|
14
14
|
|
|
15
15
|
## What This Package Does
|
|
16
16
|
|
|
17
|
-
Provides the canonical type definitions used across all Rebase packages — both client-side and server-side.
|
|
17
|
+
Provides the canonical type definitions used across all Rebase packages — both client-side and server-side. It has no runtime dependencies, but it is not types-only: it also exports the constants and small runtime helpers those packages share (`ADMIN_PROPERTY_KEYS`, `GeoPoint`, `declaredDataSources`, …). Every other `@rebasepro/*` package depends on it.
|
|
18
18
|
|
|
19
19
|
## Key Exports
|
|
20
20
|
|
|
21
|
-
### Collection &
|
|
21
|
+
### Collection & Entity Types
|
|
22
22
|
|
|
23
23
|
| Export | Description |
|
|
24
24
|
|--------|-------------|
|
|
25
25
|
| `CollectionConfig` | Full collection definition (name, slug, properties, callbacks, security rules, views) |
|
|
26
26
|
| `Property` | Union type for all property configurations (text, number, date, reference, array, map, etc.) |
|
|
27
|
-
| `
|
|
28
|
-
| `CollectionCallbacks` | Lifecycle hooks (`
|
|
29
|
-
| `
|
|
27
|
+
| `Entity` | Generic entity record type |
|
|
28
|
+
| `CollectionCallbacks` | Lifecycle hooks (`afterRead`, `beforeSave`, `afterSave`, `afterSaveError`, `beforeDelete`, `afterDelete`) |
|
|
29
|
+
| `EntityValues` | Record of property values for an entity |
|
|
30
30
|
| `SecurityRule` | RLS-style access control rule for a collection |
|
|
31
31
|
|
|
32
32
|
### Backend & Driver Interfaces
|
|
33
33
|
|
|
34
34
|
| Export | Description |
|
|
35
35
|
|--------|-------------|
|
|
36
|
-
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `
|
|
36
|
+
| `DataDriver` | Abstract interface for database drivers (`fetchCollection`, `fetchOne`, `save`, `delete`, etc.) |
|
|
37
37
|
| `DatabaseAdapter` | Pluggable database adapter interface (used by `server`) |
|
|
38
38
|
| `BackendBootstrapper` | Lifecycle interface for initializing database drivers, auth, history, and realtime |
|
|
39
39
|
| `DatabaseAdmin` | Admin operations interface (SQL execution, collection stats, table metadata) |
|
|
@@ -48,29 +48,26 @@ Provides the canonical type definitions used across all Rebase packages — both
|
|
|
48
48
|
| Export | Description |
|
|
49
49
|
|--------|-------------|
|
|
50
50
|
| `AuthAdapter` | Pluggable auth adapter interface (for Clerk, Auth0, custom auth) |
|
|
51
|
-
| `
|
|
52
|
-
| `RebaseUser` | User record type |
|
|
53
|
-
| `Role` | Role definition type |
|
|
51
|
+
| `User` | User record type |
|
|
54
52
|
|
|
55
53
|
### Controller Interfaces
|
|
56
54
|
|
|
57
55
|
| Export | Description |
|
|
58
56
|
|--------|-------------|
|
|
59
57
|
| `RebaseClient` | Top-level client interface (data, auth, storage, email) |
|
|
60
|
-
| `
|
|
58
|
+
| `RebaseServerClient` | The server-side `rebase` singleton: `RebaseClient` without `data`, plus `dataAsAdmin` |
|
|
61
59
|
| `StorageSource` | File storage interface |
|
|
62
60
|
| `CollectionRegistryInterface` | Collection lookup and registration |
|
|
63
|
-
| `NavigationController` | App navigation interface |
|
|
64
61
|
|
|
65
62
|
### Other
|
|
66
63
|
|
|
67
64
|
| Export | Description |
|
|
68
65
|
|--------|-------------|
|
|
69
66
|
| `CronJobDefinition` | Cron job configuration type |
|
|
70
|
-
| `CollectionCallbacks` | Lifecycle callbacks for
|
|
71
|
-
| `PluginConfig` | Plugin system types |
|
|
67
|
+
| `CollectionCallbacks` | Lifecycle callbacks for entity CRUD operations |
|
|
72
68
|
| `WebSocketMessage` | WebSocket protocol message types |
|
|
73
|
-
|
|
69
|
+
|
|
70
|
+
The admin panel's own types — `AuthController`, the plugin type `RebasePlugin`, `Locale` — live in `@rebasepro/cms-types`.
|
|
74
71
|
|
|
75
72
|
## Quick Start
|
|
76
73
|
|
|
@@ -79,7 +76,7 @@ import type {
|
|
|
79
76
|
CollectionConfig,
|
|
80
77
|
DataDriver,
|
|
81
78
|
DatabaseAdapter,
|
|
82
|
-
|
|
79
|
+
User,
|
|
83
80
|
Property,
|
|
84
81
|
} from "@rebasepro/types";
|
|
85
82
|
```
|
|
@@ -93,5 +90,5 @@ Every `@rebasepro/*` package depends on this one. Key consumers:
|
|
|
93
90
|
| `@rebasepro/server` | `DataDriver`, `DatabaseAdapter`, `BackendBootstrapper`, `AuthAdapter` |
|
|
94
91
|
| `@rebasepro/server-postgres` | `BackendBootstrapper`, `InitializedDriver`, `RealtimeProvider` |
|
|
95
92
|
| `@rebasepro/server-mongo` | `BackendBootstrapper`, `DataDriver`, `CollectionConfig` |
|
|
96
|
-
| `@rebasepro/client` | `RebaseClient`, `
|
|
97
|
-
| `@rebasepro/cms` | `CollectionConfig`, `Property`,
|
|
93
|
+
| `@rebasepro/client` | `RebaseClient`, `StorageSource` |
|
|
94
|
+
| `@rebasepro/cms` | `CollectionConfig`, `Property`, controller interfaces |
|
|
@@ -251,10 +251,19 @@ export interface UpdateManyProps<M extends Record<string, unknown> = Record<stri
|
|
|
251
251
|
* @internal
|
|
252
252
|
*/
|
|
253
253
|
export interface DeleteProps<M extends Record<string, unknown> = Record<string, unknown>> {
|
|
254
|
+
/**
|
|
255
|
+
* The row's address, and nothing about its contents.
|
|
256
|
+
*
|
|
257
|
+
* The driver reads the row itself, under the caller's own scope, and that
|
|
258
|
+
* read is what `beforeDelete` and `afterDelete` receive and what history
|
|
259
|
+
* records. This used to carry `values`, and the driver took them as the
|
|
260
|
+
* row — so over the WebSocket, which forwarded the client's frame, the
|
|
261
|
+
* caller wrote the audit record of their own deletion and could get past a
|
|
262
|
+
* `beforeDelete` that refused on a column by sending `values: {}`.
|
|
263
|
+
*/
|
|
254
264
|
row: {
|
|
255
265
|
id: string | number;
|
|
256
266
|
path: string;
|
|
257
|
-
values?: Partial<EntityValues<M>>;
|
|
258
267
|
};
|
|
259
268
|
collection?: CollectionConfig<M>;
|
|
260
269
|
/**
|
package/dist/index.es.js
CHANGED
|
@@ -1906,6 +1906,60 @@ function declaredStorageSources() {
|
|
|
1906
1906
|
return declaredResources("bucket").map(resourceToStorageSource);
|
|
1907
1907
|
}
|
|
1908
1908
|
//#endregion
|
|
1909
|
+
//#region src/types/env_boolean.ts
|
|
1910
|
+
var YES = /* @__PURE__ */ new Set([
|
|
1911
|
+
"true",
|
|
1912
|
+
"1",
|
|
1913
|
+
"yes",
|
|
1914
|
+
"on"
|
|
1915
|
+
]);
|
|
1916
|
+
var NO = /* @__PURE__ */ new Set([
|
|
1917
|
+
"false",
|
|
1918
|
+
"0",
|
|
1919
|
+
"no",
|
|
1920
|
+
"off"
|
|
1921
|
+
]);
|
|
1922
|
+
/**
|
|
1923
|
+
* Read a boolean environment variable — one spelling rule for every reader.
|
|
1924
|
+
*
|
|
1925
|
+
* `true`, `1`, `yes` and `on` are true; `false`, `0`, `no` and `off` are
|
|
1926
|
+
* false. Case and surrounding whitespace are ignored. Anything else — unset,
|
|
1927
|
+
* blank, or a value that spells neither — is `undefined`, so the caller's
|
|
1928
|
+
* default decides and a typo lands on the side the caller chose:
|
|
1929
|
+
*
|
|
1930
|
+
* ```ts
|
|
1931
|
+
* parseEnvBoolean(env.FORCE_LOCAL_STORAGE) === true // off unless said
|
|
1932
|
+
* parseEnvBoolean(env.REBASE_MCP_OPEN_REGISTRATION) !== false // on unless said
|
|
1933
|
+
* ```
|
|
1934
|
+
*
|
|
1935
|
+
* It exists because every reader used to spell this itself, and they
|
|
1936
|
+
* disagreed. The reader that mattered tested the raw string for truthiness —
|
|
1937
|
+
* `!process.env.FORCE_LOCAL_STORAGE` — and every non-empty string is truthy,
|
|
1938
|
+
* so `FORCE_LOCAL_STORAGE=false`, written to say "there is no durable volume
|
|
1939
|
+
* here", switched the production storage guard off and sent uploads to a
|
|
1940
|
+
* container filesystem the next redeploy erased. Beside it, `=== "true"` made
|
|
1941
|
+
* `DISABLE_DB_ROLE_SWITCHING=1` do nothing and `!== "false"` made
|
|
1942
|
+
* `REBASE_MCP_OPEN_REGISTRATION=0` leave registration open.
|
|
1943
|
+
*
|
|
1944
|
+
* The boot schemas in `@rebasepro/server` (`loadEnv`, `loadBootEnv`) accept a
|
|
1945
|
+
* strict subset — `true`, `false` and blank — and refuse any other value
|
|
1946
|
+
* before the server starts. On that subset they read exactly what this reads,
|
|
1947
|
+
* so a variable a schema declares and something else reads lazily cannot mean
|
|
1948
|
+
* two different things.
|
|
1949
|
+
*
|
|
1950
|
+
* It lives in this package, with no dependencies, for the reason
|
|
1951
|
+
* {@link storageEnvSuffix} does: the runtime, its drivers and the CLI all read
|
|
1952
|
+
* these variables, and a second parser is a second chance to disagree.
|
|
1953
|
+
*
|
|
1954
|
+
* @group Models
|
|
1955
|
+
*/
|
|
1956
|
+
function parseEnvBoolean(value) {
|
|
1957
|
+
if (value === void 0) return void 0;
|
|
1958
|
+
const spelled = value.trim().toLowerCase();
|
|
1959
|
+
if (YES.has(spelled)) return true;
|
|
1960
|
+
if (NO.has(spelled)) return false;
|
|
1961
|
+
}
|
|
1962
|
+
//#endregion
|
|
1909
1963
|
//#region src/types/component_ref.ts
|
|
1910
1964
|
/**
|
|
1911
1965
|
* Type guard: checks if a value is a `LazyComponentRef` produced by the
|
|
@@ -2418,6 +2472,6 @@ function isPublicStoragePath(path) {
|
|
|
2418
2472
|
return p.startsWith("public/") || p.startsWith(`default/public/`);
|
|
2419
2473
|
}
|
|
2420
2474
|
//#endregion
|
|
2421
|
-
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, ANONYMOUS_USER_IDS, BATCH_REF_KEY, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_COMMIT_PATHS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_FUZZY_THRESHOLD, DEFAULT_LIST_LIMIT, DEFAULT_RESOURCE_KEY, DEFAULT_SEARCH_COLUMN, DEFAULT_SEARCH_LANGUAGE, DEFAULT_SEARCH_WEIGHT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_TENANT_BYPASS_ROLES, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIELD_OPERATORS, FIREBASE_CAPABILITIES, GeoPoint, JUNCTION_PIVOT_KEY, LEGACY_RLS_JWT_SQL, LEGACY_RLS_ROLES_SQL, LEGACY_RLS_SCHEMA, LEGACY_RLS_UID_SQL, LIST_OPS, ListLimitError, MAX_INCLUDE_DEPTH, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REBASE_SCHEMA, RELEVANCE_SORT_FIELD, RESERVED_BACKEND_PREFIXES, RESOURCE_GRAPH_VERSION, REST_TO_CANONICAL, RLS_IS_ANONYMOUS_SQL, RLS_JWT_SQL, RLS_ROLES_SQL, RLS_UID_SQL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, amendResourceKind, bucket, buildResourceGraph, canonicalSchemaPayload, computeSchemaVersion, database, declareCron, declareFunction, declareResource, declaredDataSources, declaredDatabaseExtensions, declaredQueueConsumers, declaredResources, declaredStorageSources, declaredSubscriptions, deserializeCollections, encodeRelationAggregateSort, envBasesForResource, findEnvSuffixCollision, findStorageSuffixCollision, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasFieldOperation, hasForeignKeyOnTarget, isAnonymousUid, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFieldOperation, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isRelationAggregateSort, isRelationalCollectionConfig, isResourceHandle, isSQLAdmin, isSchemaAdmin, isSchemaEditingAdmin, isSerializedCollectionRef, isTenantClaimSource, isTenantMembershipSource, isToMany, isUnsupported, isValidEngine, nestAdminCollectionKeys, nestAdminKeysOf, nestAdminPropertyKeys, parseRelationAggregateSort, policy, queue, registerDataSourceCapabilities, registerResourceKind, reservedPrefixFor, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resolveClientListLimit, resolveResourceRefs, resourceEnvSuffix, resourceId, resourceKeyOf, resourceKind, resourceKinds, resourceToDataSource, resourceToStorageSource, rewriteLegacyRlsFunctions, serializeCollections, setQueueRuntime, setTopicRuntime, sortKeyToString, storageEnvSuffix, toCanonicalOp, topic, unsupportedMethod, usesLegacyRlsFunctions };
|
|
2475
|
+
export { ADMIN_COLLECTION_KEYS, ADMIN_PROPERTY_KEYS, ALL_WHERE_FILTER_OPS, ANONYMOUS_USER_ID, ANONYMOUS_USER_IDS, BATCH_REF_KEY, BUNDLE_FORMAT_VERSION, CANONICAL_TO_REST, DEFAULT_CAPABILITIES, DEFAULT_COMMIT_PATHS, DEFAULT_DATA_SOURCE_KEY, DEFAULT_FILTERABLE_RELATION_KINDS, DEFAULT_FUZZY_THRESHOLD, DEFAULT_LIST_LIMIT, DEFAULT_RESOURCE_KEY, DEFAULT_SEARCH_COLUMN, DEFAULT_SEARCH_LANGUAGE, DEFAULT_SEARCH_WEIGHT, DEFAULT_STORAGE_SOURCE_KEY, DEFAULT_TENANT_BYPASS_ROLES, DEFAULT_VECTOR_LIST_LIMIT, EntityReference, EntityRelation, FIELD_OPERATORS, FIREBASE_CAPABILITIES, GeoPoint, JUNCTION_PIVOT_KEY, LEGACY_RLS_JWT_SQL, LEGACY_RLS_ROLES_SQL, LEGACY_RLS_SCHEMA, LEGACY_RLS_UID_SQL, LIST_OPS, ListLimitError, MAX_INCLUDE_DEPTH, MAX_LIST_LIMIT, MONGODB_CAPABILITIES, NULL_OPS, POSTGRES_CAPABILITIES, PUBLIC_STORAGE_PREFIX, REBASE_SCHEMA, RELEVANCE_SORT_FIELD, RESERVED_BACKEND_PREFIXES, RESOURCE_GRAPH_VERSION, REST_TO_CANONICAL, RLS_IS_ANONYMOUS_SQL, RLS_JWT_SQL, RLS_ROLES_SQL, RLS_UID_SQL, RUNTIME_CONTRACT_VERSION, RebaseApiError, RebaseClientError, SCHEMA_VERSION_HEADER, Vector, amendResourceKind, bucket, buildResourceGraph, canonicalSchemaPayload, computeSchemaVersion, database, declareCron, declareFunction, declareResource, declaredDataSources, declaredDatabaseExtensions, declaredQueueConsumers, declaredResources, declaredStorageSources, declaredSubscriptions, deserializeCollections, encodeRelationAggregateSort, envBasesForResource, findEnvSuffixCollision, findStorageSuffixCollision, getCollectionDataPath, getDataSourceCapabilities, getDeclaredSubcollections, hasFieldOperation, hasForeignKeyOnTarget, isAnonymousUid, isBranchAdmin, isChannelBusInstance, isDocumentAdmin, isFieldOperation, isFirebaseCollectionConfig, isLazyComponentRef, isManyToMany, isMongoDBCollectionConfig, isPostgresCollectionConfig, isPublicStoragePath, isRelationAggregateSort, isRelationalCollectionConfig, isResourceHandle, isSQLAdmin, isSchemaAdmin, isSchemaEditingAdmin, isSerializedCollectionRef, isTenantClaimSource, isTenantMembershipSource, isToMany, isUnsupported, isValidEngine, nestAdminCollectionKeys, nestAdminKeysOf, nestAdminPropertyKeys, parseEnvBoolean, parseRelationAggregateSort, policy, queue, registerDataSourceCapabilities, registerResourceKind, reservedPrefixFor, resetDeclaredQueueConsumers, resetDeclaredResources, resetDeclaredSubscriptions, resolveClientListLimit, resolveResourceRefs, resourceEnvSuffix, resourceId, resourceKeyOf, resourceKind, resourceKinds, resourceToDataSource, resourceToStorageSource, rewriteLegacyRlsFunctions, serializeCollections, setQueueRuntime, setTopicRuntime, sortKeyToString, storageEnvSuffix, toCanonicalOp, topic, unsupportedMethod, usesLegacyRlsFunctions };
|
|
2422
2476
|
|
|
2423
2477
|
//# sourceMappingURL=index.es.js.map
|