@rebasepro/types 0.11.0 → 0.11.1-canary.g8caabf3

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.
@@ -3,7 +3,7 @@ import { WhereFilterOp } from "./filter-operators";
3
3
  * Describes the capabilities and features supported by a data source (driver).
4
4
  *
5
5
  * Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
6
- * supports. The CMS uses this descriptor to:
6
+ * supports. The admin uses this descriptor to:
7
7
  * - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
8
8
  * - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
9
9
  * - Toggle driver-specific form controls (e.g. `columnType` for SQL)
@@ -93,17 +93,22 @@ export interface DatabaseAdapterInitConfig {
93
93
  /** The shared collection registry to register into. */
94
94
  collectionRegistry: CollectionRegistryInterface;
95
95
  /**
96
- * How the server is being run — see `RebaseBackendConfig.mode`.
96
+ * Whether this driver should describe its own schema.
97
97
  *
98
- * In `"baas"` mode `collections` is empty by design: a driver that can
99
- * describe its own schema should introspect the database and report the
100
- * collections it found back on `InitializedDriver.collections`. Drivers
101
- * that cannot introspect may ignore this.
98
+ * True when the project declared no collections, so there is nothing to
99
+ * serve unless the driver reads the live database and reports what it found
100
+ * on `InitializedDriver.collections`. Drivers that cannot introspect may
101
+ * ignore it — `initializeRebaseBackend` fails the boot with their name
102
+ * rather than serving nothing.
103
+ *
104
+ * This was a `mode: "cms" | "baas"` flag, which was never independent of
105
+ * `collections`: every consumer already required the list to be empty
106
+ * before acting on it, so the flag could only ever agree or contradict.
102
107
  */
103
- mode?: "cms" | "baas";
108
+ introspectCollections?: boolean;
104
109
  /**
105
- * `baas`-mode options — see `RebaseBackendConfig.baas`. Drivers that
106
- * introspect should honour `unprotectedTables`.
110
+ * Options for an introspecting driver — see `RebaseBackendConfig.baas`.
111
+ * Drivers that introspect should honour `unprotectedTables`.
107
112
  */
108
113
  baas?: {
109
114
  unprotectedTables?: "exclude" | "serve";
@@ -69,7 +69,7 @@ export interface AfterReadProps<M extends Record<string, unknown> = Record<strin
69
69
  */
70
70
  collection: CollectionConfig<M>;
71
71
  /**
72
- * Full path of the CMS where this collection is being fetched.
72
+ * Full path of the admin where this collection is being fetched.
73
73
  * Might contain unresolved aliases.
74
74
  */
75
75
  path: string;
@@ -106,7 +106,7 @@ export interface AfterSaveProps<M extends Record<string, unknown> = Record<strin
106
106
  */
107
107
  collection: CollectionConfig<M>;
108
108
  /**
109
- * Full path of the CMS where this entity is being saved.
109
+ * Full path of the admin where this entity is being saved.
110
110
  * Might contain unresolved aliases.
111
111
  */
112
112
  path: string;
@@ -29,24 +29,42 @@
29
29
  *
30
30
  * - `backend` — the collections/hooks/functions that define the project's API.
31
31
  * Exactly one per *project* (not per repository); the registry enforces it.
32
- * - `static` — a pre-built client bundle (SPA, static site) served over CDN.
33
- * - `admin` — the Rebase admin panel, either hosted by the platform or built
34
- * into this repository.
35
- * - `mobile` — a native app. Registration only: it gets client credentials and
36
- * configuration, and is never built or hosted here.
37
- * - `custom` — an arbitrary container image built from a Dockerfile. The eject
38
- * hatch: full control, no managed-runtime guarantees.
32
+ * - `static` — a pre-built client bundle (SPA, static site), served from the
33
+ * backend process at its declared `path` or from a CDN. The admin panel is
34
+ * one of these: it is an app in the user's repository like any other.
35
+ *
36
+ * That is the whole list. Ownership of the server process is a property of the
37
+ * backend app ({@link RebaseBackendAppConfig.runtime}), not an app type.
39
38
  */
40
- export type RebaseAppType = "backend" | "static" | "admin" | "mobile" | "custom";
39
+ export type RebaseAppType = "backend" | "static";
41
40
  /**
42
41
  * The backend app: the project's API surface.
43
42
  *
44
43
  * Paths are relative to the directory holding `rebase.json`. The defaults match
45
44
  * the layout `rebase init` scaffolds, so a stock project may declare simply
46
- * `{ "type": "backend" }`.
45
+ * `{ "type": "backend", "runtime": "managed" }`.
47
46
  */
48
47
  export interface RebaseBackendAppConfig {
49
48
  type: "backend";
49
+ /**
50
+ * Who owns the process this backend runs in.
51
+ *
52
+ * - `managed` — the platform's runtime image boots this project's bundle.
53
+ * You supply collections, functions, crons and schema; Rebase supplies the
54
+ * server.
55
+ * - `custom` — this repository builds its own image and entrypoint. The
56
+ * escape hatch: full control, no managed-runtime guarantees.
57
+ *
58
+ * Independent of *where* it runs. Both run on Rebase Cloud and both
59
+ * self-host — the destination lives in `.rebase/cloud.json`, not here. See
60
+ * `docker/docker-compose.selfhost.yml`, which boots a managed bundle on a
61
+ * developer's own Docker host.
62
+ *
63
+ * This is authored rather than inferred on purpose. It is the single most
64
+ * consequential fact about a deployment, and inferring it is what used to
65
+ * land projects on the custom runtime without anyone choosing it.
66
+ */
67
+ runtime: "managed" | "custom";
50
68
  /** Directory of the config package (collections + index). Default `config`. */
51
69
  config?: string;
52
70
  /** Directory of server functions. Default `backend/functions`. */
@@ -58,22 +76,23 @@ export interface RebaseBackendAppConfig {
58
76
  * Default `backend/src/schema.generated.ts`.
59
77
  */
60
78
  schema?: string;
61
- /**
62
- * Which collections source the runtime uses.
63
- *
64
- * - `cms` (default) — collections come from the config package.
65
- * - `baas` — collections are introspected from the live database at boot and
66
- * the config package is not required.
67
- */
68
- mode?: "cms" | "baas";
69
79
  /**
70
80
  * Module path (relative to `config`) exporting the auth users collection as
71
81
  * its default export. Default `collections/users`.
72
82
  */
73
83
  usersCollection?: string;
84
+ /**
85
+ * `runtime: "custom"` only. Dockerfile path relative to the repository root.
86
+ * Default `Dockerfile`.
87
+ */
88
+ dockerfile?: string;
89
+ /** `runtime: "custom"` only. Build context relative to the root. Default `.`. */
90
+ context?: string;
91
+ /** `runtime: "custom"` only. Port the container listens on. Default 8080. */
92
+ port?: number;
74
93
  }
75
94
  /**
76
- * A static client bundle — SPA or static site — built here and served from CDN.
95
+ * A static client bundle — SPA or static site — built here and served at `path`.
77
96
  */
78
97
  export interface RebaseStaticAppConfig {
79
98
  type: "static";
@@ -84,54 +103,27 @@ export interface RebaseStaticAppConfig {
84
103
  /** Directory of built assets, relative to the repository root. */
85
104
  output: string;
86
105
  /**
87
- * Serve `index.html` for unmatched paths (client-side routing).
106
+ * Public base path this app is served under. Default `/`.
107
+ *
108
+ * Several static apps run in one process, each at its own path — the API at
109
+ * `/api`, a site at `/`, the admin at `/admin` — which is what keeps a
110
+ * self-hosted deployment a single container.
111
+ *
112
+ * **This is a build-time input, not only a serving concern.** An app mounted
113
+ * at `/admin` must be *built* for `/admin` (Vite's `base`), or `index.html`
114
+ * loads and every asset 404s: a blank page with no server error. `rebase
115
+ * build` passes it as `REBASE_APP_BASE` and asserts the emitted HTML honours
116
+ * it. Changing this value requires rebuilding the app.
117
+ */
118
+ path?: string;
119
+ /**
120
+ * Serve `index.html` for unmatched paths under `path` (client-side routing).
88
121
  * Default `true` — the overwhelmingly common case for a client app, and a
89
122
  * static *site* generator emits real files for its routes anyway.
90
123
  */
91
124
  spa?: boolean;
92
125
  }
93
- /**
94
- * The admin panel.
95
- *
96
- * `hosted` is the default and means the platform serves it — nothing is built
97
- * into this repository and nothing ships in the bundle. `bundled` builds it here,
98
- * which is what a self-hosted or air-gapped deployment wants.
99
- */
100
- export interface RebaseAdminAppConfig {
101
- type: "admin";
102
- mode?: "hosted" | "bundled";
103
- /** Only for `bundled`: package directory containing the admin sources. */
104
- root?: string;
105
- /** Only for `bundled`: build command. */
106
- build?: string;
107
- /** Only for `bundled`: directory of built assets. */
108
- output?: string;
109
- }
110
- /**
111
- * A native app. Registered for credentials and configuration; never built here.
112
- */
113
- export interface RebaseMobileAppConfig {
114
- type: "mobile";
115
- platform: "ios" | "android" | "other";
116
- }
117
- /**
118
- * An app built from a Dockerfile into an arbitrary image.
119
- *
120
- * This is the deliberate escape hatch. A project containing one is not eligible
121
- * for the managed runtime — the platform cannot make guarantees about an image
122
- * it did not build — but it still deploys, and nothing else about the project
123
- * changes.
124
- */
125
- export interface RebaseCustomAppConfig {
126
- type: "custom";
127
- /** Dockerfile path relative to the repository root. */
128
- dockerfile?: string;
129
- /** Build context relative to the repository root. Default `.`. */
130
- context?: string;
131
- /** Port the container listens on. Default 8080. */
132
- port?: number;
133
- }
134
- export type RebaseAppConfig = RebaseBackendAppConfig | RebaseStaticAppConfig | RebaseAdminAppConfig | RebaseMobileAppConfig | RebaseCustomAppConfig;
126
+ export type RebaseAppConfig = RebaseBackendAppConfig | RebaseStaticAppConfig;
135
127
  /**
136
128
  * `rebase.json` — the authored project manifest.
137
129
  */
@@ -139,13 +131,17 @@ export interface RebaseProjectManifest {
139
131
  /** JSON Schema URL, for editor completion. Ignored by the tooling. */
140
132
  $schema?: string;
141
133
  /**
142
- * The runtime **major** this project targets, as a semver range
134
+ * The runtime contract **major** this project targets, as a semver range
143
135
  * (e.g. `^1`, `~1.4`, or an exact `1.4.2` to pin).
144
136
  *
145
137
  * The platform upgrades patches and minors underneath a project without
146
138
  * asking; it never crosses a major. See {@link RUNTIME_CONTRACT_VERSION}.
139
+ *
140
+ * Named `rebase` rather than `runtime` so that `runtime` means exactly one
141
+ * thing — {@link RebaseBackendAppConfig.runtime}, who owns the process. It
142
+ * reads like `engines` in a `package.json`, which is what it is.
147
143
  */
148
- runtime: string;
144
+ rebase: string;
149
145
  /**
150
146
  * Apps this repository contributes, keyed by app name. The key is the app's
151
147
  * identity within the project: it is what `rebase deploy <app>` names, what
@@ -192,8 +188,16 @@ export interface ManagedCompatibility {
192
188
  * not read. A runtime accepts any bundle whose `bundleFormat` is less than or
193
189
  * equal to its own — old bundles keep booting on new runtimes, which is the
194
190
  * whole point of separating the artifact from the engine.
191
+ *
192
+ * - **1** — `mode: "cms" | "baas" | "static"`, `entry.static` a single directory
193
+ * string, `entry.admin` for a bundled admin panel.
194
+ * - **2** — `kind: "backend" | "static"`, `entry.static` a list of
195
+ * {@link RebaseBundleStatic}, `entry.admin` removed. A format-1 runtime reading
196
+ * one of these would find no `mode` and an array where it expects a string, so
197
+ * the bump is what turns that into a refusal to boot instead of a bundle that
198
+ * starts and serves nothing.
195
199
  */
196
- export declare const BUNDLE_FORMAT_VERSION = 1;
200
+ export declare const BUNDLE_FORMAT_VERSION = 2;
197
201
  /**
198
202
  * The runtime contract major.
199
203
  *
@@ -217,10 +221,24 @@ export interface RebaseBundleEntrypoints {
217
221
  schema?: string;
218
222
  /** Module exporting the auth users collection (default export). */
219
223
  usersCollection?: string;
220
- /** Built admin assets, when the admin panel is bundled rather than hosted. */
221
- admin?: string;
222
- /** Built static assets to serve from the runtime, when not on a CDN. */
223
- static?: string;
224
+ /**
225
+ * Built static apps to serve from this process, in declaration order.
226
+ *
227
+ * A list rather than a single directory because one process serves several
228
+ * apps at different paths — a site at `/` and the admin at `/admin`. The
229
+ * runtime mounts them longest-path-first so the `/`-rooted app's catch-all
230
+ * does not claim its siblings' URLs.
231
+ */
232
+ static?: RebaseBundleStatic[];
233
+ }
234
+ /** One built static app inside a bundle. */
235
+ export interface RebaseBundleStatic {
236
+ /** Public base path, e.g. `/` or `/admin`. */
237
+ path: string;
238
+ /** Bundle-relative directory holding the built assets. */
239
+ dir: string;
240
+ /** Serve `index.html` for unmatched paths under `path`. */
241
+ spa: boolean;
224
242
  }
225
243
  /**
226
244
  * A native module found in the dependency closure.
@@ -263,15 +281,17 @@ export interface RebaseBundleManifest {
263
281
  /**
264
282
  * What the runtime does with this bundle.
265
283
  *
266
- * - `cms` — a backend with declared collections; the runtime provisions their
267
- * tables and serves the data API.
268
- * - `baas` — a backend that introspects an existing database rather than
269
- * declaring collections.
270
- * - `static` — no backend at all: the bundle is a built SPA (`entry.static`),
271
- * and the runtime only serves those assets. No database, no data sources —
272
- * this is how a `static`/`admin` app runs on the same image as the backend.
284
+ * - `backend` — boot the full server: database, auth and the data API, plus
285
+ * any static apps in `entry.static`.
286
+ * - `static` — no backend at all: serve `entry.static` and nothing else. No
287
+ * database, no auth, no data sources. This is how a static app runs on the
288
+ * same image as the backend.
289
+ *
290
+ * Replaces an earlier `mode: "cms" | "baas" | "static"`. The cms/baas
291
+ * distinction was never a third kind of thing — it is simply whether
292
+ * `entry.config` is present, so it is derived rather than declared.
273
293
  */
274
- mode: "cms" | "baas" | "static";
294
+ kind: "backend" | "static";
275
295
  entry: RebaseBundleEntrypoints;
276
296
  /** Collection slugs contained in the bundle, for quick inspection. */
277
297
  collections?: string[];
@@ -325,7 +345,6 @@ export interface RebaseProjectContract {
325
345
  version: string;
326
346
  contract: number;
327
347
  };
328
- mode: "cms" | "baas";
329
348
  /** Full collection definitions, serialized — the input to SDK generation. */
330
349
  collections: unknown[];
331
350
  /** Collection slugs, for cheap inspection without parsing the definitions. */
@@ -113,7 +113,7 @@ export interface BaseProperty<CustomProps = unknown> {
113
113
  description?: string;
114
114
  /**
115
115
  * You can use this prop to reuse a property that has been defined
116
- * in the top level of the CMS in the prop `fields`.
116
+ * in the top level of the admin in the prop `fields`.
117
117
  * All the configuration will be taken from the inherited config, and
118
118
  * overwritten by the current property config.
119
119
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/types",
3
3
  "type": "module",
4
- "version": "0.11.0",
4
+ "version": "0.11.1-canary.g8caabf3",
5
5
  "description": "Rebase type definitions — shared interfaces and controller types",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -11,7 +11,7 @@ export type CollectionRegistryController<
11
11
  > = {
12
12
 
13
13
  /**
14
- * List of the mapped collections in the CMS.
14
+ * List of the mapped collections in the admin.
15
15
  * Each entry relates to a collection in the root database.
16
16
  * Each of the navigation entries in this field
17
17
  * generates an entry in the main menu.
@@ -116,12 +116,12 @@ export interface FindResponse<M extends Record<string, unknown> = Record<string,
116
116
 
117
117
 
118
118
  /**
119
- * Fluent query builder for the **admin CMS** — resolves to `FindResponse<M>`
119
+ * Fluent query builder for the **admin admin** — resolves to `FindResponse<M>`
120
120
  * (Snapshot-wrapped rows).
121
121
  *
122
122
  * @internal App developers should use {@link SDKQueryBuilderInterface}
123
123
  * (flat rows, returned by `client.data.*` / `context.data.*`). This
124
- * Snapshot-flavored variant backs the admin CMS internals only.
124
+ * Snapshot-flavored variant backs the admin admin internals only.
125
125
  *
126
126
  * @group Data
127
127
  */
@@ -138,13 +138,13 @@ export interface QueryBuilderInterface<M extends Record<string, unknown> = Recor
138
138
  }
139
139
 
140
140
  /**
141
- * A single collection's CRUD accessor for the **admin CMS** — every method
141
+ * A single collection's CRUD accessor for the **admin admin** — every method
142
142
  * resolves to `Snapshot`-wrapped rows (`FindResponse<M>` / `Snapshot<M>`).
143
143
  *
144
144
  * @internal App developers do **not** use this. The public, symmetric surface
145
145
  * is {@link SDKCollectionClient} (flat rows), exposed as `client.data.products`
146
146
  * in the SDK and `context.data.products` in framework callbacks. This
147
- * Snapshot-flavored accessor backs the admin CMS view-model only.
147
+ * Snapshot-flavored accessor backs the admin admin view-model only.
148
148
  *
149
149
  * @group Data
150
150
  */
@@ -269,7 +269,7 @@ export interface SDKQueryBuilderInterface<M extends Record<string, unknown> = Re
269
269
  * SDK collection client — returns flat rows, no Entity wrapper.
270
270
  *
271
271
  * This is the public API surface for app developers using
272
- * `createRebaseClient()`. CMS internals use `CollectionAccessor` instead.
272
+ * `createRebaseClient()`. admin internals use `CollectionAccessor` instead.
273
273
  *
274
274
  * Type parameters:
275
275
  * - `M` — the **Row** shape returned by reads (`find`, `findById`, `listen`).
@@ -406,16 +406,16 @@ export interface SDKCollectionClient<
406
406
  }
407
407
 
408
408
  /**
409
- * The unified data access object for the **admin CMS** (Entity-shaped).
409
+ * The unified data access object for the **admin admin** (Entity-shaped).
410
410
  *
411
411
  * Access collections as dynamic properties: `data.products.find(...)`. Each
412
412
  * accessor returns `Entity`-wrapped records (`{ id, path, values }`) — the
413
- * view-model the CMS renders. This is what `useData()` / the admin
413
+ * view-model the admin renders. This is what `useData()` / the admin
414
414
  * `RebaseContext.data` are backed by.
415
415
  *
416
416
  * @internal App developers do **not** use this — they use
417
417
  * {@link RebaseSdkData} (flat rows), which is what the SDK client and backend
418
- * `context.data` expose. This Entity-shaped map backs the admin CMS only.
418
+ * `context.data` expose. This Entity-shaped map backs the admin admin only.
419
419
  *
420
420
  * @group Data
421
421
  */
@@ -455,7 +455,7 @@ export type RebaseData<DB = unknown> = {
455
455
  *
456
456
  * Every accessor returns flat rows (the table's columns) via
457
457
  * {@link SDKCollectionClient} — access fields directly (`row.title`), never
458
- * `row.values.title`. The admin CMS uses {@link RebaseData} (Entity) instead.
458
+ * `row.values.title`. The admin uses {@link RebaseData} (Entity) instead.
459
459
  *
460
460
  * @example
461
461
  * // Frontend SDK
@@ -404,7 +404,6 @@ export type CollectionConfig<M extends Record<string, unknown> = Record<string,
404
404
  *
405
405
  * @group Models
406
406
  */
407
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
408
407
  export type AnyCollectionConfig = CollectionConfig<any, any>;
409
408
 
410
409
  /**
@@ -4,7 +4,7 @@ import { ALL_WHERE_FILTER_OPS, WhereFilterOp } from "./filter-operators";
4
4
  * Describes the capabilities and features supported by a data source (driver).
5
5
  *
6
6
  * Each driver (Postgres, Firebase, MongoDB, etc.) declares which features it
7
- * supports. The CMS uses this descriptor to:
7
+ * supports. The admin uses this descriptor to:
8
8
  * - Show/hide editor tabs (e.g. Relations for SQL, Subcollections for Firebase)
9
9
  * - Filter the property type picker (e.g. `relation` for SQL, `reference` for Firebase)
10
10
  * - Toggle driver-specific form controls (e.g. `columnType` for SQL)
@@ -119,17 +119,22 @@ export interface DatabaseAdapterInitConfig {
119
119
  /** The shared collection registry to register into. */
120
120
  collectionRegistry: CollectionRegistryInterface;
121
121
  /**
122
- * How the server is being run — see `RebaseBackendConfig.mode`.
122
+ * Whether this driver should describe its own schema.
123
123
  *
124
- * In `"baas"` mode `collections` is empty by design: a driver that can
125
- * describe its own schema should introspect the database and report the
126
- * collections it found back on `InitializedDriver.collections`. Drivers
127
- * that cannot introspect may ignore this.
124
+ * True when the project declared no collections, so there is nothing to
125
+ * serve unless the driver reads the live database and reports what it found
126
+ * on `InitializedDriver.collections`. Drivers that cannot introspect may
127
+ * ignore it — `initializeRebaseBackend` fails the boot with their name
128
+ * rather than serving nothing.
129
+ *
130
+ * This was a `mode: "cms" | "baas"` flag, which was never independent of
131
+ * `collections`: every consumer already required the list to be empty
132
+ * before acting on it, so the flag could only ever agree or contradict.
128
133
  */
129
- mode?: "cms" | "baas";
134
+ introspectCollections?: boolean;
130
135
  /**
131
- * `baas`-mode options — see `RebaseBackendConfig.baas`. Drivers that
132
- * introspect should honour `unprotectedTables`.
136
+ * Options for an introspecting driver — see `RebaseBackendConfig.baas`.
137
+ * Drivers that introspect should honour `unprotectedTables`.
133
138
  */
134
139
  baas?: { unprotectedTables?: "exclude" | "serve" };
135
140
  }
@@ -85,7 +85,7 @@ export interface AfterReadProps<M extends Record<string, unknown> = Record<strin
85
85
  collection: CollectionConfig<M>;
86
86
 
87
87
  /**
88
- * Full path of the CMS where this collection is being fetched.
88
+ * Full path of the admin where this collection is being fetched.
89
89
  * Might contain unresolved aliases.
90
90
  */
91
91
  path: string;
@@ -132,7 +132,7 @@ export interface AfterSaveProps<M extends Record<string, unknown> = Record<strin
132
132
  collection: CollectionConfig<M>;
133
133
 
134
134
  /**
135
- * Full path of the CMS where this entity is being saved.
135
+ * Full path of the admin where this entity is being saved.
136
136
  * Might contain unresolved aliases.
137
137
  */
138
138
  path: string;