@rebasepro/types 0.17.3 → 0.18.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.
Files changed (71) hide show
  1. package/README.md +4 -0
  2. package/dist/call_context.d.ts +20 -0
  3. package/dist/controllers/client.d.ts +36 -4
  4. package/dist/controllers/data.d.ts +120 -10
  5. package/dist/errors.d.ts +83 -4
  6. package/dist/index.es.js +522 -160
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/types/admin_block.d.ts +2 -2
  9. package/dist/types/auth_adapter.d.ts +41 -6
  10. package/dist/types/backend.d.ts +48 -0
  11. package/dist/types/collections.d.ts +25 -1
  12. package/dist/types/cron.d.ts +34 -0
  13. package/dist/types/database_adapter.d.ts +39 -0
  14. package/dist/types/entity_callbacks.d.ts +14 -1
  15. package/dist/types/filter-operators.d.ts +24 -1
  16. package/dist/types/policy.d.ts +29 -1
  17. package/dist/types/properties.d.ts +216 -3
  18. package/dist/types/relations.d.ts +65 -7
  19. package/dist/types/resource_kinds.d.ts +173 -17
  20. package/dist/types/resources.d.ts +108 -7
  21. package/dist/types/rls-functions.d.ts +11 -0
  22. package/dist/types/storage_source.d.ts +12 -23
  23. package/package.json +24 -23
  24. package/src/call_context.ts +0 -120
  25. package/src/controllers/auth_state.ts +0 -24
  26. package/src/controllers/client.ts +0 -494
  27. package/src/controllers/collection_registry.ts +0 -62
  28. package/src/controllers/data.ts +0 -1012
  29. package/src/controllers/data_driver.ts +0 -576
  30. package/src/controllers/effective_role.ts +0 -4
  31. package/src/controllers/email.ts +0 -91
  32. package/src/controllers/index.ts +0 -11
  33. package/src/controllers/storage.ts +0 -252
  34. package/src/errors.ts +0 -119
  35. package/src/index.ts +0 -5
  36. package/src/types/admin_block.ts +0 -209
  37. package/src/types/api_keys.ts +0 -108
  38. package/src/types/auth_adapter.ts +0 -580
  39. package/src/types/backend.ts +0 -987
  40. package/src/types/backup.ts +0 -26
  41. package/src/types/channel_bus.ts +0 -202
  42. package/src/types/chips.ts +0 -34
  43. package/src/types/collection_contract.ts +0 -278
  44. package/src/types/collections.ts +0 -763
  45. package/src/types/component_ref.ts +0 -92
  46. package/src/types/cron.ts +0 -213
  47. package/src/types/data_source.ts +0 -357
  48. package/src/types/database_adapter.ts +0 -267
  49. package/src/types/entities.ts +0 -226
  50. package/src/types/entity_callbacks.ts +0 -229
  51. package/src/types/filter-operators.ts +0 -444
  52. package/src/types/history.ts +0 -66
  53. package/src/types/index.ts +0 -36
  54. package/src/types/indexes.ts +0 -180
  55. package/src/types/policy.ts +0 -328
  56. package/src/types/postgres_introspection.ts +0 -101
  57. package/src/types/project_manifest.ts +0 -598
  58. package/src/types/properties.ts +0 -1368
  59. package/src/types/relations.ts +0 -417
  60. package/src/types/resource_kinds.ts +0 -390
  61. package/src/types/resources.ts +0 -368
  62. package/src/types/rls-functions.ts +0 -98
  63. package/src/types/schema_editing.ts +0 -157
  64. package/src/types/schema_version.ts +0 -112
  65. package/src/types/search.ts +0 -247
  66. package/src/types/security_rules.ts +0 -344
  67. package/src/types/storage_authorize.ts +0 -77
  68. package/src/types/storage_source.ts +0 -248
  69. package/src/types/websockets.ts +0 -117
  70. package/src/users/index.ts +0 -2
  71. package/src/users/user.ts +0 -69
@@ -1,598 +0,0 @@
1
- /**
2
- * The project manifest (`rebase.json`) and the build artifacts derived from it.
3
- *
4
- * Three separate documents live in this file, and keeping them distinct matters:
5
- *
6
- * 1. {@link RebaseProjectManifest} — `rebase.json`. **Authored** by the developer,
7
- * committed to the repository. Declares topology only: which runtime major the
8
- * project targets, and which apps *this repository* contributes to the project.
9
- * Schema, security rules, hooks and functions stay in TypeScript under the
10
- * config package — nothing that needs a type system belongs here.
11
- *
12
- * 2. {@link RebaseProjectLink} — the per-checkout link (`.rebase/cloud.json`).
13
- * **Not committed**, because it is per-developer like a git remote. Says which
14
- * deployed project this working copy points at, whether that is a Rebase Cloud
15
- * project or the base URL of a self-hosted backend.
16
- *
17
- * 3. {@link RebaseBundleManifest} — `manifest.json` inside a built bundle.
18
- * **Generated**, never hand-edited. It is the lockfile analogue: the exact
19
- * contract a built artifact claims to satisfy, which the runtime validates
20
- * before it boots and a control plane validates before it deploys.
21
- *
22
- * A repository declares only the apps it contains. The set of apps belonging to a
23
- * project is held by the project itself, which is what makes multi-repo projects
24
- * work: two repositories never need to know about each other, only about the
25
- * project.
26
- */
27
-
28
- import type { StorageSourceDefinition } from "./storage_source";
29
- import type { ResourceGraph } from "./resources";
30
-
31
- /**
32
- * Which kind of thing an app is.
33
- *
34
- * - `backend` — the collections/hooks/functions that define the project's API.
35
- * Exactly one per *project* (not per repository); the registry enforces it.
36
- * - `static` — a pre-built client bundle (SPA, static site), served from the
37
- * backend process at its declared `path` or from a CDN. The admin panel is
38
- * one of these: it is an app in the user's repository like any other.
39
- *
40
- * That is the whole list. Ownership of the server process is a property of the
41
- * backend app ({@link RebaseBackendAppConfig.runtime}), not an app type.
42
- */
43
- export type RebaseAppType = "backend" | "static";
44
-
45
- /**
46
- * The backend app: the project's API surface.
47
- *
48
- * Paths are relative to the directory holding `rebase.json`. The defaults match
49
- * the layout `rebase init` scaffolds, so a stock project may declare simply
50
- * `{ "type": "backend", "runtime": "managed" }`.
51
- */
52
- export interface RebaseBackendAppConfig {
53
- type: "backend";
54
- /**
55
- * Who owns the process this backend runs in.
56
- *
57
- * - `managed` — the platform's runtime image boots this project's bundle.
58
- * You supply collections, functions, crons and schema; Rebase supplies the
59
- * server.
60
- * - `custom` — this repository builds its own image and entrypoint. The
61
- * escape hatch: full control, no managed-runtime guarantees.
62
- *
63
- * Independent of *where* it runs. Both run on Rebase Cloud and both
64
- * self-host — the destination lives in `.rebase/cloud.json`, not here. See
65
- * `infra/docker/docker-compose.selfhost.yml`, which boots a managed bundle on a
66
- * developer's own Docker host.
67
- *
68
- * This is authored rather than inferred on purpose. It is the single most
69
- * consequential fact about a deployment, and inferring it is what used to
70
- * land projects on the custom runtime without anyone choosing it.
71
- */
72
- runtime: "managed" | "custom";
73
- /** Directory of the config package (collections + index). Default `config`. */
74
- config?: string;
75
- /** Directory of server functions. Default `backend/functions`. */
76
- functions?: string;
77
- /** Directory of cron job definitions. Default `backend/crons` when present. */
78
- crons?: string;
79
- /**
80
- * Path to the generated Drizzle schema module (tables/enums/relations).
81
- * Default `backend/src/schema.generated.ts`.
82
- */
83
- schema?: string;
84
- /**
85
- * Module path (relative to `config`) exporting the auth users collection as
86
- * its default export. Default `collections/users`.
87
- */
88
- usersCollection?: string;
89
-
90
- /**
91
- * `runtime: "custom"` only. Dockerfile path relative to the repository root.
92
- * Default `Dockerfile`.
93
- */
94
- dockerfile?: string;
95
- /** `runtime: "custom"` only. Build context relative to the root. Default `.`. */
96
- context?: string;
97
- /** `runtime: "custom"` only. Port the container listens on. Default 8080. */
98
- port?: number;
99
- }
100
-
101
- /**
102
- * A static client bundle — SPA or static site — built here and served at `path`.
103
- */
104
- export interface RebaseStaticAppConfig {
105
- type: "static";
106
- /** Package directory containing the client sources. */
107
- root: string;
108
- /** Command that produces `output`. Run from the repository root. */
109
- build?: string;
110
- /** Directory of built assets, relative to the repository root. */
111
- output: string;
112
- /**
113
- * Public base path this app is served under. Default `/`.
114
- *
115
- * Several static apps run in one process, each at its own path — the API at
116
- * `/api`, a site at `/`, the admin at `/admin` — which is what keeps a
117
- * self-hosted deployment a single container.
118
- *
119
- * **This is a build-time input, not only a serving concern.** An app mounted
120
- * at `/admin` must be *built* for `/admin` (Vite's `base`), or `index.html`
121
- * loads and every asset 404s: a blank page with no server error. `rebase
122
- * build` passes it as `REBASE_APP_BASE` and asserts the emitted HTML honours
123
- * it. Changing this value requires rebuilding the app.
124
- */
125
- path?: string;
126
- /**
127
- * Serve `index.html` for unmatched paths under `path` (client-side routing).
128
- * Default `true` — the overwhelmingly common case for a client app, and a
129
- * static *site* generator emits real files for its routes anyway.
130
- */
131
- spa?: boolean;
132
- }
133
-
134
- export type RebaseAppConfig = RebaseBackendAppConfig | RebaseStaticAppConfig;
135
-
136
- /**
137
- * Path prefixes the backend owns, which no static app may claim.
138
- *
139
- * One process — and, on the platform, one hostname — serves both the API and
140
- * however many static apps a project has. Mounting is longest-path-first, so an
141
- * app declaring `/api` would win against the API itself and every request to it
142
- * would be answered with that app's `index.html`: a 200 carrying HTML where the
143
- * caller expected JSON, from a project that looks deployed and healthy.
144
- *
145
- * Declared here rather than in either enforcer because both must agree. The CLI
146
- * checks it so a developer finds out while editing `rebase.json`; the control
147
- * plane checks it again at deploy intake, because the front door's correctness
148
- * cannot rest on a check that ran in somebody else's CLI — and a repository can
149
- * be deployed by a CLI older than this rule.
150
- */
151
- export const RESERVED_BACKEND_PREFIXES = ["/api", "/health", "/healthz", "/livez", "/readyz", "/metrics"] as const;
152
-
153
- /**
154
- * Whether `path` collides with a prefix the backend owns.
155
- *
156
- * Compares at segment boundaries, so `/api` and `/api/v2` collide while
157
- * `/apidocs` does not — the same rule the router matches with, because a check
158
- * that is stricter than the router rejects paths that would have worked, and one
159
- * that is looser admits paths that will not.
160
- */
161
- export function reservedPrefixFor(path: string): string | undefined {
162
- const normalized = path.endsWith("/") && path !== "/" ? path.slice(0, -1) : path;
163
- return RESERVED_BACKEND_PREFIXES.find(
164
- reserved => normalized === reserved || normalized.startsWith(`${reserved}/`)
165
- );
166
- }
167
-
168
- /**
169
- * One declared storage source, as authored in `rebase.json`.
170
- *
171
- * The key comes from the enclosing record, so this is
172
- * {@link StorageSourceDefinition} minus its `key` — the same document the
173
- * runtime registry and the frontend router consume, expressed the way a JSON
174
- * object naturally expresses "a set of named things".
175
- */
176
- export interface RebaseStorageSourceConfig {
177
- /** Engine backing this source: `local`, `s3`, `gcs`, or a custom id. */
178
- engine: string;
179
- /**
180
- * How the frontend reaches it. Default `server` (proxied through
181
- * `/api/storage`). `direct` means a provider SDK talks to the bucket and the
182
- * backend is not in the upload path.
183
- */
184
- transport?: "server" | "direct";
185
- /** Human-readable label for the console and the admin UI. */
186
- label?: string;
187
- }
188
-
189
- /**
190
- * `rebase.json` — the authored project manifest.
191
- */
192
- export interface RebaseProjectManifest {
193
- /** JSON Schema URL, for editor completion. Ignored by the tooling. */
194
- $schema?: string;
195
- /**
196
- * The runtime contract **major** this project targets, as a semver range
197
- * (e.g. `^1`, `~1.4`, or an exact `1.4.2` to pin).
198
- *
199
- * The platform upgrades patches and minors underneath a project without
200
- * asking; it never crosses a major. See {@link RUNTIME_CONTRACT_VERSION}.
201
- *
202
- * Named `rebase` rather than `runtime` so that `runtime` means exactly one
203
- * thing — {@link RebaseBackendAppConfig.runtime}, who owns the process. It
204
- * reads like `engines` in a `package.json`, which is what it is.
205
- */
206
- rebase: string;
207
- /**
208
- * Apps this repository contributes, keyed by app name. The key is the app's
209
- * identity within the project: it is what `rebase deploy <app>` names, what
210
- * client credentials are issued against, and what a second repository must
211
- * not collide with.
212
- */
213
- apps: Record<string, RebaseAppConfig>;
214
- /**
215
- * Buckets are NOT declared here any more.
216
- *
217
- * They were, and the runtime merged this block with the declarations in
218
- * config code — a bucket named in both had one engine kept and the other
219
- * silently discarded. Two homes for one concept, with a merge to decide
220
- * between them, is the shape this whole model replaced.
221
- *
222
- * `bucket("media", { engine: "s3" })` in the project's config declares one
223
- * now, and `rebase resources --write` generates `rebase.resources.json`,
224
- * which is what a host reads before a build. A `storage` block left in this
225
- * file is refused by the validator, by name, with the replacement in the
226
- * message — not ignored, because a key that still parses and does nothing
227
- * is the failure this removed.
228
- */
229
- /**
230
- * Repository-wide opt-out from anonymous CLI usage sharing.
231
- *
232
- * **Only `false` does anything.** It suppresses sharing for everyone who
233
- * clones this repository, overriding each developer's own opt-in — an
234
- * organisation setting policy for work done on its behalf, the same shape
235
- * as a committed `.npmrc`.
236
- *
237
- * `true` is deliberately ignored, and the CLI says so rather than obeying
238
- * quietly. This file is committed, so a `true` here would be one developer
239
- * answering a privacy question for every colleague who later clones the
240
- * repo — consent by proxy, which is the exact thing opt-in exists to
241
- * prevent. Individuals opt in with `rebase telemetry enable`.
242
- */
243
- telemetry?: boolean;
244
- }
245
-
246
- /**
247
- * The per-checkout project link.
248
- *
249
- * Deliberately separate from `rebase.json`: the manifest is committed and shared,
250
- * while the link is per-developer. Keeping them in one file would mean either
251
- * committing someone's project id or gitignoring the topology.
252
- */
253
- export interface RebaseProjectLink {
254
- /**
255
- * A Rebase Cloud project id, or the base URL of any running Rebase backend
256
- * (`https://api.example.com`). Both are first-class: every command that
257
- * accepts a project reference accepts either, so a self-hosted project has
258
- * the same tooling as a cloud one.
259
- */
260
- project: string;
261
- /** Organization slug. Cloud projects only. */
262
- org?: string;
263
- /** Explicit API base URL, when it differs from the project's default. */
264
- apiUrl?: string;
265
- }
266
-
267
- /**
268
- * Whether a project can run on the managed runtime, and if not, precisely why.
269
- *
270
- * The reasons are returned rather than summarised so tooling can print something
271
- * a developer can act on. "Not eligible" is never a dead end — it selects the
272
- * custom-runtime path, which still deploys.
273
- */
274
- export interface ManagedCompatibility {
275
- eligible: boolean;
276
- reasons: string[];
277
- }
278
-
279
- // ─────────────────────────────────────────────────────────────────────────────
280
- // Bundle
281
- // ─────────────────────────────────────────────────────────────────────────────
282
-
283
- /**
284
- * Version of the bundle *format* itself.
285
- *
286
- * Bumped only when the on-disk layout changes in a way an older runtime could
287
- * not read. A runtime accepts any bundle whose `bundleFormat` is less than or
288
- * equal to its own — old bundles keep booting on new runtimes, which is the
289
- * whole point of separating the artifact from the engine.
290
- *
291
- * - **1** — `mode: "cms" | "baas" | "static"`, `entry.static` a single directory
292
- * string, `entry.admin` for a bundled admin panel.
293
- * - **2** — `kind: "backend" | "static"`, `entry.static` a list of
294
- * {@link RebaseBundleStatic}, `entry.admin` removed. A format-1 runtime reading
295
- * one of these would find no `mode` and an array where it expects a string, so
296
- * the bump is what turns that into a refusal to boot instead of a bundle that
297
- * starts and serves nothing.
298
- */
299
- export const BUNDLE_FORMAT_VERSION = 2;
300
-
301
- /**
302
- * The runtime contract major.
303
- *
304
- * Distinct from the `@rebasepro/server` package version: the package may release
305
- * any number of minors and patches while this stays put. It changes only when
306
- * the bundle/runtime contract breaks compatibility, and a project's
307
- * `manifest.runtime` range is matched against *this*.
308
- *
309
- * ## v2 — resources are declared, not configured
310
- *
311
- * `RebaseBackendConfig.dataSources` and `.storageSources` are gone. A project
312
- * declares its databases and buckets with `database()` / `bucket()` in its
313
- * config, and the runtime reads those declarations.
314
- *
315
- * This had to be a major, and the reason is the managed tier: it moves projects
316
- * onto new images WITHOUT rebuilding them. A bundle built against v1 exports
317
- * those keys, and a v2 runtime refuses them at boot — so without this bump, one
318
- * image rollout would crash-loop every tenant that had ever declared a second
319
- * database or bucket, in a wave, with the cause in a container log nobody is
320
- * watching.
321
- *
322
- * With the bump, a v1 bundle on a v2 runtime is refused by
323
- * `assertBundleCompatibility` with the remedy in the message, and the platform
324
- * keeps it on a v1 image until it is rebuilt. That is the whole purpose of this
325
- * number.
326
- *
327
- * **Release order matters and is not optional.** The control plane is the side
328
- * that rejects, so it ships FIRST: raise `SUPPORTED_RUNTIME_CONTRACT` in the
329
- * saas repo (it rejects only `contract >` its own, so it then accepts both),
330
- * deploy that, and only then release a runtime implementing v2. Shipping the
331
- * runtime first turns every deploy into a rejected intake blaming the tenant's
332
- * bundle.
333
- */
334
- export const RUNTIME_CONTRACT_VERSION = 1;
335
-
336
- /** Where the runtime finds each part of the bundle. Paths are bundle-relative. */
337
- export interface RebaseBundleEntrypoints {
338
- /** Compiled config package directory (collections live under it). */
339
- config?: string;
340
- /** Compiled collections directory, when it differs from `<config>/collections`. */
341
- collections?: string;
342
- /** Compiled functions directory. */
343
- functions?: string;
344
- /** Compiled crons directory. */
345
- crons?: string;
346
- /** Compiled Drizzle schema module. */
347
- schema?: string;
348
- /** Module exporting the auth users collection (default export). */
349
- usersCollection?: string;
350
- /**
351
- * Built static apps to serve from this process, in declaration order.
352
- *
353
- * A list rather than a single directory because one process serves several
354
- * apps at different paths — a site at `/` and the admin at `/admin`. The
355
- * runtime mounts them longest-path-first so the `/`-rooted app's catch-all
356
- * does not claim its siblings' URLs.
357
- */
358
- static?: RebaseBundleStatic[];
359
- }
360
-
361
- /** One built static app inside a bundle. */
362
- export interface RebaseBundleStatic {
363
- /** Public base path, e.g. `/` or `/admin`. */
364
- path: string;
365
- /** Bundle-relative directory holding the built assets. */
366
- dir: string;
367
- /** Serve `index.html` for unmatched paths under `path`. */
368
- spa: boolean;
369
- }
370
-
371
- /**
372
- * A native module found in the dependency closure.
373
- *
374
- * Recorded rather than merely counted so a rejection can name the offending
375
- * package instead of saying "something here is native".
376
- */
377
- export interface NativeDependency {
378
- name: string;
379
- /** Why it was flagged — a `.node` binary, a gyp build, or an install script. */
380
- reason: string;
381
- }
382
-
383
- /**
384
- * `manifest.json` — generated, and the document the runtime and control plane
385
- * both validate against.
386
- */
387
- /**
388
- * One custom function, as recorded in a built bundle.
389
- *
390
- * @see RebaseBundleManifest.functions
391
- */
392
- export interface RebaseBundleFunction {
393
- /**
394
- * The filename without its extension — which is also the URL segment it
395
- * mounts at (`/api/functions/<name>`), the API-key permission that grants
396
- * it, and the name `REBASE_FUNCTIONS_ONLY` selects by. One identity, used
397
- * everywhere.
398
- */
399
- name: string;
400
- /** Path inside the bundle, so a host can point at the file. */
401
- file: string;
402
- /**
403
- * `false` when the function's own source imports a Node built-in or a
404
- * package that needs one.
405
- *
406
- * Descriptive, never a gate: nothing refuses to build or deploy on this. It
407
- * says where this function *could* run, not where it should.
408
- */
409
- portable: boolean;
410
- /**
411
- * Why it is not portable — one short phrase per reason, deduplicated.
412
- * Absent when it is.
413
- */
414
- requires?: string[];
415
- }
416
-
417
- export interface RebaseBundleManifest {
418
- /** @see BUNDLE_FORMAT_VERSION */
419
- bundleFormat: number;
420
- runtime: {
421
- /** The `runtime` range copied from `rebase.json`. */
422
- range: string;
423
- /** Exact `@rebasepro/server` version this bundle was built against. */
424
- builtAgainst: string;
425
- /** Runtime contract major this bundle requires. */
426
- contract: number;
427
- };
428
- /**
429
- * Hash of the compiled collection definitions.
430
- *
431
- * This is the contract stamp. A generated SDK records the value it was built
432
- * from, a client sends it back, and a mismatch is what lets the platform say
433
- * "this app was built against an older schema" instead of failing mysteriously
434
- * at the first request. It covers collections only — a hook edit does not
435
- * change a client's contract, so it must not invalidate every SDK.
436
- */
437
- schemaVersion: string;
438
- /** Which app in `rebase.json` this bundle was built from. */
439
- app: string;
440
- /**
441
- * What the runtime does with this bundle.
442
- *
443
- * - `backend` — boot the full server: database, auth and the data API, plus
444
- * any static apps in `entry.static`.
445
- * - `static` — no backend at all: serve `entry.static` and nothing else. No
446
- * database, no auth, no data sources. This is how a static app runs on the
447
- * same image as the backend.
448
- *
449
- * Replaces an earlier `mode: "cms" | "baas" | "static"`. The cms/baas
450
- * distinction was never a third kind of thing — it is simply whether
451
- * `entry.config` is present, so it is derived rather than declared.
452
- */
453
- kind: "backend" | "static";
454
- entry: RebaseBundleEntrypoints;
455
- /** Collection slugs contained in the bundle, for quick inspection. */
456
- collections?: string[];
457
- /**
458
- * Every custom function in the bundle, named and classified.
459
- *
460
- * Two things are recorded per function, and both are answers a host would
461
- * otherwise have to get by importing user code:
462
- *
463
- * - **What it is called.** That name is the function's identity everywhere —
464
- * the URL segment it mounts at, the `functions/<name>` API-key
465
- * permission, the value `REBASE_FUNCTIONS_ONLY` selects by. A host that
466
- * wants to give one slow function its own replica count currently has to
467
- * boot the bundle to discover what is in it.
468
- * - **Whether it needs Node.** Purely descriptive: a function that opens a
469
- * file or runs raw SQL is a fine function, and every deployment today is
470
- * a Node process. It is recorded because the question "which of these
471
- * could run somewhere else" has to be answerable from the artifact, and
472
- * because answering it per-file after the fact — across a codebase
473
- * already written — is the expensive version of the same question.
474
- *
475
- * Absent on a bundle built before this field existed, which is why every
476
- * consumer must treat it as optional rather than as an empty list.
477
- */
478
- functions?: RebaseBundleFunction[];
479
- hooks: {
480
- /**
481
- * Whether the dependency closure contains native code.
482
- *
483
- * The managed runtime refuses these: a prebuilt binary cannot be run on
484
- * an image the platform did not build it for, and the honest failure is
485
- * at deploy time rather than at 3am in a crash loop.
486
- */
487
- native: boolean;
488
- nativeModules?: NativeDependency[];
489
- };
490
- /**
491
- * What the bundle's config says about storage access control.
492
- *
493
- * Storage is not under RLS and its keys share one flat namespace, so a
494
- * deployment with file storage enabled and no access model serves every
495
- * user's files to every signed-in user. The runtime refuses to boot in that
496
- * state — which, on a hosted platform that enables storage from the *console*
497
- * rather than from the bundle, surfaces as a crash loop the developer cannot
498
- * read.
499
- *
500
- * Recording it here lets a host reject the deploy with the reason instead.
501
- * Absent on bundles built before this field existed.
502
- */
503
- storage?: {
504
- /** Whether the config package exports a `storageAuthorize` hook. */
505
- authorize: boolean;
506
- /**
507
- * Buckets, on bundles built before {@link RebaseBundleManifest.resources}.
508
- *
509
- * No longer written. A host reads `resources`, which carries every kind
510
- * in one list; this stays declared so a control plane can keep reading
511
- * the bundles a project shipped before it was rebuilt.
512
- */
513
- sources?: StorageSourceDefinition[];
514
- };
515
- /**
516
- * Everything the project declares it needs — databases, buckets, topics,
517
- * and whatever kind is registered next.
518
- *
519
- * Recorded so a host can tell, from the artifact alone and before starting
520
- * anything, what a deploy will need provisioned. That question used to be
521
- * answerable for buckets and for nothing else, because buckets were the
522
- * only kind written into an artifact — which is how a project's databases
523
- * became invisible to the platform that runs them.
524
- *
525
- * Absent on bundles built before this field existed.
526
- */
527
- resources?: ResourceGraph;
528
- deps: {
529
- /** Runtime dependencies of user code, as declared. */
530
- declared: Record<string, string>;
531
- /**
532
- * The dependency tree ships *inside* the bundle, already installed.
533
- *
534
- * Absent or false means the tree is declared but not present, and
535
- * whoever boots the bundle has to install it. On the managed runtime that
536
- * install runs in an init container on **every** pod start — the bundle
537
- * lives on a volume that is wiped each time — and it is the single
538
- * largest cost in a managed pod's life: 35–55 seconds of a 40–60 second
539
- * cold start. Since a pod restarts on every eviction, node failure, OOM
540
- * and runtime rollout, that number is not a startup detail. It is what an
541
- * outage costs.
542
- *
543
- * Vendoring moves the install to build time, where it happens once. It is
544
- * skipped when the closure contains native code, because a prebuilt
545
- * binary is only valid for the platform it was built for — see
546
- * {@link vendorTarget} for what "the platform" means here.
547
- */
548
- vendored?: boolean;
549
- /**
550
- * What {@link vendored} was resolved for, recorded so a mismatch can be
551
- * refused rather than discovered at import time.
552
- *
553
- * Cross-platform vendoring is safe for pure JavaScript and unsafe for
554
- * anything compiled, and the boundary between them is not always visible
555
- * in a dependency list: `esbuild` is pure-JS with a *platform-specific
556
- * optional dependency* holding the actual binary, so an install run on a
557
- * developer's Mac silently produces a tree that cannot run on the Linux
558
- * image. The install therefore resolves optional dependencies for the
559
- * target explicitly rather than for the machine it runs on, and records
560
- * the answer here.
561
- */
562
- vendorTarget?: {
563
- /** npm `--os`, e.g. `linux`. */
564
- os: string;
565
- /** npm `--cpu`, e.g. `x64`. */
566
- cpu: string;
567
- /** Node major the tree was resolved for. */
568
- node: string;
569
- };
570
- };
571
- build: {
572
- /** `@rebasepro/cli` version that produced this bundle. */
573
- cli: string;
574
- /** Node major the bundle was compiled on. */
575
- node: string;
576
- /** ISO-8601. */
577
- createdAt: string;
578
- };
579
- }
580
-
581
- /** The contract a running backend serves at `GET /api/meta/contract`. */
582
- export interface RebaseProjectContract {
583
- /** Matches {@link RebaseBundleManifest.schemaVersion}. */
584
- schemaVersion: string;
585
- runtime: {
586
- /** `@rebasepro/server` version currently running. */
587
- version: string;
588
- contract: number;
589
- };
590
- /** Full collection definitions, serialized — the input to SDK generation. */
591
- collections: unknown[];
592
- /** Collection slugs, for cheap inspection without parsing the definitions. */
593
- collectionSlugs: string[];
594
- generatedAt: string;
595
- }
596
-
597
- /** Header carrying the schema version an SDK was generated from. */
598
- export const SCHEMA_VERSION_HEADER = "x-rebase-schema";