@rebasepro/server 0.24.0 → 0.24.1-canary.g19596ef
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 +27 -2
- package/dist/GCSStorageController-DEga1ULx.js +402 -0
- package/dist/GCSStorageController-DEga1ULx.js.map +1 -0
- package/dist/S3StorageController-Btx-6bJ5.js +480 -0
- package/dist/S3StorageController-Btx-6bJ5.js.map +1 -0
- package/dist/api/errors.d.ts +32 -0
- package/dist/api/live-schema-routes.d.ts +27 -3
- package/dist/api/mount-path.d.ts +30 -0
- package/dist/api/mount.d.ts +6 -13
- package/dist/api/rest/api-generator.d.ts +53 -1
- package/dist/api/rest/auth-collection-writes.d.ts +28 -21
- package/dist/api/rest/field-access-query.d.ts +28 -8
- package/dist/api/rest/field-ops.d.ts +19 -7
- package/dist/api/rest/query-body.d.ts +10 -0
- package/dist/api/rest/write-validation.d.ts +7 -5
- package/dist/api/schema-editor-routes.d.ts +10 -1
- package/dist/api/sql-export-routes.d.ts +8 -0
- package/dist/api/types.d.ts +35 -0
- package/dist/{ast-schema-editor-CWqS_sLJ.js → ast-schema-editor-mCeSC03x.js} +3 -3
- package/dist/{ast-schema-editor-CWqS_sLJ.js.map → ast-schema-editor-mCeSC03x.js.map} +1 -1
- package/dist/auth/access.d.ts +62 -11
- package/dist/auth/admin-user-ops.d.ts +24 -2
- package/dist/auth/admin-users-route.d.ts +1 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +10 -3
- package/dist/auth/api-keys/api-key-routes.d.ts +4 -1
- package/dist/auth/builtin-auth-adapter.d.ts +13 -0
- package/dist/auth/email-change-routes.d.ts +3 -0
- package/dist/auth/expired-token-sweep.d.ts +5 -1
- package/dist/auth/interfaces.d.ts +10 -0
- package/dist/auth/jwks-routes.d.ts +5 -1
- package/dist/auth/jwt-crypto.d.ts +7 -0
- package/dist/auth/jwt-keys.d.ts +4 -0
- package/dist/auth/jwt.d.ts +282 -166
- package/dist/auth/magic-link-routes.d.ts +3 -0
- package/dist/auth/mfa-crypto.d.ts +9 -3
- package/dist/auth/mfa-gate.d.ts +4 -2
- package/dist/auth/mfa-routes.d.ts +6 -0
- package/dist/auth/middleware.d.ts +9 -2
- package/dist/auth/otp-routes.d.ts +3 -0
- package/dist/auth/rate-limiter.d.ts +61 -34
- package/dist/auth/registration-policy.d.ts +17 -0
- package/dist/auth/require-auth.d.ts +1 -1
- package/dist/auth/routes.d.ts +16 -0
- package/dist/auth/session-routes.d.ts +6 -0
- package/dist/auth/token-revocation.d.ts +6 -0
- package/dist/auth/user-picking.d.ts +37 -0
- package/dist/auth/verify-credential.d.ts +25 -4
- package/dist/{auth-DMLngxn_.js → auth-CSBky1mt.js} +2927 -1882
- package/dist/auth-CSBky1mt.js.map +1 -0
- package/dist/auth_adapter-CIItCTc8.js +21 -0
- package/dist/auth_adapter-CIItCTc8.js.map +1 -0
- package/dist/backend/create-backend.d.ts +281 -0
- package/dist/backend/default-backend.d.ts +35 -0
- package/dist/backend/no-collections.d.ts +19 -0
- package/dist/backend/options.d.ts +912 -0
- package/dist/backend/scope.d.ts +23 -0
- package/dist/backend/services.d.ts +54 -0
- package/dist/backend-DTAOsLQc.js.map +1 -1
- package/dist/backup/backup-common.d.ts +14 -3
- package/dist/backup/backup-routes.d.ts +23 -2
- package/dist/backup/backup-storage.d.ts +3 -1
- package/dist/backup/index.d.ts +3 -1
- package/dist/{backup-CN0s50D2.js → backup-DBGRUVTS.js} +178 -37
- package/dist/backup-DBGRUVTS.js.map +1 -0
- package/dist/boot/boot.d.ts +2 -2
- package/dist/boot/driver.d.ts +3 -0
- package/dist/boot/env.d.ts +9 -2
- package/dist/boot/http-server.d.ts +22 -0
- package/dist/boot/options.d.ts +16 -1
- package/dist/boot/provision.d.ts +4 -2
- package/dist/boot/resource-adapters.d.ts +11 -14
- package/dist/boot/runtime-cors.d.ts +17 -0
- package/dist/boot/sources.d.ts +9 -0
- package/dist/boot/static-routing.d.ts +9 -0
- package/dist/{contract-routes-fz8i4pxs.js → contract-routes-DiFwiLg2.js} +5 -21
- package/dist/contract-routes-DiFwiLg2.js.map +1 -0
- package/dist/cron/cron-loader.d.ts +77 -18
- package/dist/cron/cron-routes.d.ts +1 -1
- package/dist/cron/cron-scheduler.d.ts +69 -3
- package/dist/cron/cron-store.d.ts +33 -5
- package/dist/cron/define-cron.d.ts +6 -2
- package/dist/cron/index.d.ts +3 -3
- package/dist/cron-loader-NHqRfKF0.js +202 -0
- package/dist/cron-loader-NHqRfKF0.js.map +1 -0
- package/dist/{cron-routes-Bc-SB0Se.js → cron-routes-DsH8Jwn5.js} +29 -6
- package/dist/cron-routes-DsH8Jwn5.js.map +1 -0
- package/dist/{cron-scheduler-CYQgco86.js → cron-scheduler-D1DT0nw5.js} +300 -34
- package/dist/cron-scheduler-D1DT0nw5.js.map +1 -0
- package/dist/cron-store-DEpVstUU.js +577 -0
- package/dist/cron-store-DEpVstUU.js.map +1 -0
- package/dist/{ddl-bootstrap-BaqMSa4Y.js → ddl-bootstrap-BNqi2NZe.js} +2 -2
- package/dist/{ddl-bootstrap-BaqMSa4Y.js.map → ddl-bootstrap-BNqi2NZe.js.map} +1 -1
- package/dist/email/smtp-email-service.d.ts +23 -0
- package/dist/email/types.d.ts +18 -0
- package/dist/env.d.ts +0 -37
- package/dist/{errors-D6_y86c5.js → errors-Cqp86KnA.js} +166 -7
- package/dist/errors-Cqp86KnA.js.map +1 -0
- package/dist/filter-dialect-O1HK6Nvr.js +1628 -0
- package/dist/filter-dialect-O1HK6Nvr.js.map +1 -0
- package/dist/{function-loader-D7o5Epjj.js → function-loader-DbCSoNJj.js} +69 -39
- package/dist/function-loader-DbCSoNJj.js.map +1 -0
- package/dist/{function-routes-CaNG4waN.js → function-routes-BSTClQNa.js} +6 -5
- package/dist/function-routes-BSTClQNa.js.map +1 -0
- package/dist/functions/context.d.ts +9 -0
- package/dist/functions/define-function.d.ts +10 -6
- package/dist/functions/function-loader.d.ts +75 -18
- package/dist/functions/function-routes.d.ts +2 -1
- package/dist/functions/index.d.ts +5 -4
- package/dist/functions/index.js +59 -15
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/internal.d.ts +2 -2
- package/dist/functions/proxy.d.ts +6 -2
- package/dist/functions/request-timeout.d.ts +7 -5
- package/dist/history/history-routes.d.ts +9 -0
- package/dist/history/retention-sweep.d.ts +81 -0
- package/dist/{history-recorder-Nr8zLvoU.js → history-recorder-RZ1Ow4YY.js} +4 -4
- package/dist/{history-recorder-Nr8zLvoU.js.map → history-recorder-RZ1Ow4YY.js.map} +1 -1
- package/dist/{history-store-rcAm_xFR.js → history-store-DPofGVDp.js} +2 -2
- package/dist/{history-store-rcAm_xFR.js.map → history-store-DPofGVDp.js.map} +1 -1
- package/dist/index.d.ts +24 -11
- package/dist/index.es.js +24758 -20153
- package/dist/index.es.js.map +1 -1
- package/dist/init/docs.d.ts +35 -10
- package/dist/init/process-safety.d.ts +7 -2
- package/dist/init/shutdown.d.ts +18 -3
- package/dist/init.d.ts +49 -865
- package/dist/internal-tables-L2t39RdT.js +136 -0
- package/dist/internal-tables-L2t39RdT.js.map +1 -0
- package/dist/jobs/job-queue.d.ts +8 -0
- package/dist/jobs/job-store.d.ts +24 -0
- package/dist/jobs/types.d.ts +25 -4
- package/dist/{jobs-DqYNfquG.js → jobs-8G-_agld.js} +235 -25
- package/dist/jobs-8G-_agld.js.map +1 -0
- package/dist/{jwt-R6bSPMjk.js → jwt-CBaFc34Y.js} +530 -455
- package/dist/jwt-CBaFc34Y.js.map +1 -0
- package/dist/{keys-GAVZqbqx.js → keys-COzQ2aE8.js} +2 -2
- package/dist/{keys-GAVZqbqx.js.map → keys-COzQ2aE8.js.map} +1 -1
- package/dist/load-failure-L5hvfDoG.js +80 -0
- package/dist/load-failure-L5hvfDoG.js.map +1 -0
- package/dist/{logger-D-S-hO5e.js → logger-Bt32sHFw.js} +17 -4
- package/dist/logger-Bt32sHFw.js.map +1 -0
- package/dist/{logs-routes-DAdv37GI.js → logs-routes-DQJhrf-b.js} +3 -3
- package/dist/{logs-routes-DAdv37GI.js.map → logs-routes-DQJhrf-b.js.map} +1 -1
- package/dist/mcp/mcp-routes.d.ts +6 -0
- package/dist/mcp/mcp-tools.d.ts +8 -0
- package/dist/mcp/oauth-routes.d.ts +7 -0
- package/dist/metrics/index.d.ts +18 -0
- package/dist/metrics/pool-wait.d.ts +50 -0
- package/dist/offline-QNQgsPOq-B2yGeXkn.js +3305 -0
- package/dist/offline-QNQgsPOq-B2yGeXkn.js.map +1 -0
- package/dist/offline-store-Cm5sAX81-CALiO4Gn.js +1915 -0
- package/dist/offline-store-Cm5sAX81-CALiO4Gn.js.map +1 -0
- package/dist/{openapi-generator-DAq_XVDu.js → openapi-generator-CeGW2dLC.js} +366 -82
- package/dist/openapi-generator-CeGW2dLC.js.map +1 -0
- package/dist/policy-PdzX-Opd.js +121 -0
- package/dist/policy-PdzX-Opd.js.map +1 -0
- package/dist/project_manifest-R6y_KHms.js +59 -0
- package/dist/project_manifest-R6y_KHms.js.map +1 -0
- package/dist/{proxy-qRlqeUmO.js → proxy-BEKbsil6.js} +5 -4
- package/dist/proxy-BEKbsil6.js.map +1 -0
- package/dist/{query-parser-BgiKJKvc.js → query-parser-ECxP0nDw.js} +511 -16
- package/dist/query-parser-ECxP0nDw.js.map +1 -0
- package/dist/{request-timeout-DgH7j8qO.js → request-timeout-BiRelY-U.js} +17 -10
- package/dist/request-timeout-BiRelY-U.js.map +1 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js +24 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js.map +1 -0
- package/dist/schema-edit/apply-schema-change.d.ts +10 -0
- package/dist/schema-edit/local-source.d.ts +29 -0
- package/dist/schema-edit/remote-source.d.ts +13 -3
- package/dist/schema-edit/source-editor.d.ts +28 -0
- package/dist/{schema-editor-routes-oIyuWl3L.js → schema-editor-routes-DRXBAbZy.js} +55 -11
- package/dist/schema-editor-routes-DRXBAbZy.js.map +1 -0
- package/dist/services/outbound-post.d.ts +50 -0
- package/dist/services/outbound-url-guard.d.ts +34 -5
- package/dist/services/routed-realtime-service.d.ts +5 -0
- package/dist/services/webhook-service.d.ts +66 -14
- package/dist/singleton.d.ts +9 -5
- package/dist/soft-delete-params-CBryZXMq.js +668 -0
- package/dist/soft-delete-params-CBryZXMq.js.map +1 -0
- package/dist/sql-export-routes-D8ZaRvoR.js +240 -0
- package/dist/sql-export-routes-D8ZaRvoR.js.map +1 -0
- package/dist/{src-CatHFUym.js → src-D5Y3N-S4.js} +2 -1
- package/dist/{src-CatHFUym.js.map → src-D5Y3N-S4.js.map} +1 -1
- package/dist/storage/GCSStorageController.d.ts +46 -2
- package/dist/storage/LocalStorageController.d.ts +67 -2
- package/dist/storage/S3StorageController.d.ts +37 -3
- package/dist/storage/image-transform.d.ts +15 -0
- package/dist/storage/maintenance-routes.d.ts +23 -0
- package/dist/storage/maintenance.d.ts +126 -0
- package/dist/storage/rendition-cache.d.ts +9 -11
- package/dist/storage/request-principals.d.ts +30 -0
- package/dist/storage/routes.d.ts +20 -0
- package/dist/storage/source-variables.d.ts +10 -0
- package/dist/storage/streams.d.ts +42 -0
- package/dist/storage/tus-handler.d.ts +46 -2
- package/dist/storage/types.d.ts +82 -7
- package/dist/storage/upload-validation.d.ts +13 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js +125 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js.map +1 -0
- package/dist/strings.es-BeZWAodn.js +256 -0
- package/dist/strings.es-BeZWAodn.js.map +1 -0
- package/dist/upload-validation-CVobI5xO.js +172 -0
- package/dist/upload-validation-CVobI5xO.js.map +1 -0
- package/dist/utils/byte-size.d.ts +10 -0
- package/dist/utils/compression.d.ts +6 -0
- package/dist/utils/load-failure.d.ts +14 -0
- package/dist/utils/logger.d.ts +9 -0
- package/package.json +5 -5
- package/dist/GCSStorageController-BSiP1c-f.js +0 -256
- package/dist/GCSStorageController-BSiP1c-f.js.map +0 -1
- package/dist/S3StorageController-CAwFRgjV.js +0 -276
- package/dist/S3StorageController-CAwFRgjV.js.map +0 -1
- package/dist/auth-DMLngxn_.js.map +0 -1
- package/dist/backup-CN0s50D2.js.map +0 -1
- package/dist/contract-routes-fz8i4pxs.js.map +0 -1
- package/dist/cron-loader-CwaANlOG.js +0 -118
- package/dist/cron-loader-CwaANlOG.js.map +0 -1
- package/dist/cron-routes-Bc-SB0Se.js.map +0 -1
- package/dist/cron-scheduler-CYQgco86.js.map +0 -1
- package/dist/cron-store-D2Q9-Aco.js +0 -300
- package/dist/cron-store-D2Q9-Aco.js.map +0 -1
- package/dist/dynamic-import-X40pTZUQ.js +0 -23
- package/dist/dynamic-import-X40pTZUQ.js.map +0 -1
- package/dist/errors-D6_y86c5.js.map +0 -1
- package/dist/function-loader-D7o5Epjj.js.map +0 -1
- package/dist/function-routes-CaNG4waN.js.map +0 -1
- package/dist/jobs-DqYNfquG.js.map +0 -1
- package/dist/jwt-R6bSPMjk.js.map +0 -1
- package/dist/logger-D-S-hO5e.js.map +0 -1
- package/dist/openapi-generator-DAq_XVDu.js.map +0 -1
- package/dist/proxy-qRlqeUmO.js.map +0 -1
- package/dist/query-parser-BgiKJKvc.js.map +0 -1
- package/dist/request-timeout-DgH7j8qO.js.map +0 -1
- package/dist/schema-editor-routes-oIyuWl3L.js.map +0 -1
- package/dist/soft-delete-params-BWPilMPF.js +0 -59
- package/dist/soft-delete-params-BWPilMPF.js.map +0 -1
- package/dist/src-I3aG1PcY.js +0 -6870
- package/dist/src-I3aG1PcY.js.map +0 -1
- package/dist/types-BfKcm9do.js +0 -39
- package/dist/types-BfKcm9do.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context, MiddlewareHandler } from "hono";
|
|
2
|
+
import type { HonoEnv } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where a route group is mounted, read from the request rather than configured.
|
|
5
|
+
*
|
|
6
|
+
* A group — the data API, the functions router — is a Hono sub-app a caller can
|
|
7
|
+
* mount anywhere: `/api/data`, `/v2/data`, `/:tenant/data`. A few of its
|
|
8
|
+
* decisions need that prefix (which collection a path names, which function a
|
|
9
|
+
* scoped key is calling, what URL the listing reports), and it used to be passed
|
|
10
|
+
* in as `${basePath}/data` when the group was built — which pinned the group to
|
|
11
|
+
* the one path its builder assumed.
|
|
12
|
+
*
|
|
13
|
+
* Hono already knows: a middleware registered at the root of a group with
|
|
14
|
+
* `use("/*")` is stored under the merged path `<mount>/*`, however deeply the
|
|
15
|
+
* group was nested, and `routePath(c)` returns the path of the handler running
|
|
16
|
+
* now. Must therefore be called from such a middleware — see
|
|
17
|
+
* {@link recordMountPath}, which is how a group does it.
|
|
18
|
+
*
|
|
19
|
+
* A mount path with parameters (`/:tenant/data`) is resolved against the request
|
|
20
|
+
* segment by segment, so the answer is the concrete prefix (`/acme/data`).
|
|
21
|
+
*/
|
|
22
|
+
export declare function requestMountPath(c: Context): string;
|
|
23
|
+
/**
|
|
24
|
+
* A group's first middleware: record where the group is mounted as
|
|
25
|
+
* `c.var.mountPath`, for everything after it in the same request.
|
|
26
|
+
*
|
|
27
|
+
* Registered with `use("/*")` on the group's own router, before anything else —
|
|
28
|
+
* that registration is what makes {@link requestMountPath} see the mount.
|
|
29
|
+
*/
|
|
30
|
+
export declare function recordMountPath(): MiddlewareHandler<HonoEnv>;
|
package/dist/api/mount.d.ts
CHANGED
|
@@ -23,19 +23,12 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { Hono } from "hono";
|
|
25
25
|
import type { HonoEnv } from "./types.js";
|
|
26
|
-
export interface MountOptions {
|
|
27
|
-
/** Where the surface lives now. */
|
|
28
|
-
canonical: string;
|
|
29
|
-
/** Where it used to live, when it has moved. */
|
|
30
|
-
legacy?: string;
|
|
31
|
-
/** For the boot log — "Cron", "Logs". */
|
|
32
|
-
surface: string;
|
|
33
|
-
}
|
|
34
26
|
/**
|
|
35
|
-
*
|
|
27
|
+
* `router`, served again at a path it has moved from.
|
|
36
28
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* gate
|
|
29
|
+
* Mount the result at the old path, beside `router` at its canonical one. The
|
|
30
|
+
* same router instance serves both, so the two paths cannot drift: there is one
|
|
31
|
+
* set of handlers and one gate, and an alias that forgot to apply the admin gate
|
|
32
|
+
* is not a state this can reach.
|
|
40
33
|
*/
|
|
41
|
-
export declare function
|
|
34
|
+
export declare function deprecatedAlias(router: Hono<HonoEnv>, canonical: string): Hono<HonoEnv>;
|
|
@@ -265,7 +265,9 @@ export declare class RestApiGenerator {
|
|
|
265
265
|
*
|
|
266
266
|
* `respond` is applied to the *stored* result rather than the stored result
|
|
267
267
|
* being a response, so a replay honours the `Prefer` header of the request
|
|
268
|
-
* replaying it rather than the one that first answered.
|
|
268
|
+
* replaying it rather than the one that first answered. `replayed` says
|
|
269
|
+
* the result is the stored one, so a route can restore what it put in a
|
|
270
|
+
* header rather than the body (the `PATCH`'s `ETag`).
|
|
269
271
|
*/
|
|
270
272
|
private runIdempotent;
|
|
271
273
|
/**
|
|
@@ -330,11 +332,61 @@ export declare class RestApiGenerator {
|
|
|
330
332
|
* through a parent. Errors are not re-classified; see {@link createRow}.
|
|
331
333
|
*/
|
|
332
334
|
private updateRow;
|
|
335
|
+
/**
|
|
336
|
+
* The 404 and the `If-Match` of an update or a delete, as a precondition
|
|
337
|
+
* the driver runs inside the write — or, for a driver that cannot, and for
|
|
338
|
+
* the auth collection, the same judgement made here on a read first.
|
|
339
|
+
*
|
|
340
|
+
* Inside the write is the point. The route used to read the row in a
|
|
341
|
+
* transaction of its own, through the admin's view-model walk, before
|
|
342
|
+
* writing it: every declared relation of the row was loaded — all 200,000
|
|
343
|
+
* comments of a post, for a PATCH of its title — and thrown away, and the
|
|
344
|
+
* write's own read of the row then repeated the lookup. And two writes
|
|
345
|
+
* carrying the same tag could both pass: each compared before either had
|
|
346
|
+
* written. Judged on the write's own read, after the row is locked when a
|
|
347
|
+
* tag is sent, the second one reads what the first wrote and is a 412.
|
|
348
|
+
*
|
|
349
|
+
* The auth collection is still read here first, without relations: the
|
|
350
|
+
* adapter's steps run before the write (`prepareUserUpdates`, and a
|
|
351
|
+
* deletion's `beforeUserDelete` veto, a hook of the application's), and an
|
|
352
|
+
* unknown uid must be the 404 before them, as it always was.
|
|
353
|
+
*
|
|
354
|
+
* @returns The precondition to hand the driver, or `undefined` for a driver
|
|
355
|
+
* that does not run one (the row was judged here).
|
|
356
|
+
*/
|
|
357
|
+
private storedRowPrecondition;
|
|
333
358
|
/**
|
|
334
359
|
* Delete one row: `DELETE /<collection>/<id>`, and the same row reached
|
|
335
360
|
* through a parent.
|
|
336
361
|
*/
|
|
337
362
|
private deleteRow;
|
|
363
|
+
/**
|
|
364
|
+
* A listing — `GET /<collection>` and `POST /<collection>/query`, and the
|
|
365
|
+
* same two through a parent — from the parameters as the `GET` reads them
|
|
366
|
+
* off its URL.
|
|
367
|
+
*
|
|
368
|
+
* One method for both verbs is the whole contract of the POST route: the
|
|
369
|
+
* same parser, the same field-access refusals, the same page, count,
|
|
370
|
+
* cursor and include, the same errors. The caller has already checked the
|
|
371
|
+
* credential's scope for `collection`.
|
|
372
|
+
*
|
|
373
|
+
* @param collectionPath a nested listing's `parent/:id/child` path; unset
|
|
374
|
+
* for the collection's own.
|
|
375
|
+
*/
|
|
376
|
+
private listRows;
|
|
377
|
+
/**
|
|
378
|
+
* A collection's count, from the query parameters in `queryDict`: the
|
|
379
|
+
* URL's for `GET …/count`, a body's for `POST …/count`. One method for
|
|
380
|
+
* both, as {@link listRows} is for the listing — the same parser, the same
|
|
381
|
+
* field-access refusals, the same count. The caller has already checked
|
|
382
|
+
* the credential's scope for `collection`.
|
|
383
|
+
*
|
|
384
|
+
* @param collectionPath a nested count's `parent/:id/child` path; unset
|
|
385
|
+
* for the collection's own.
|
|
386
|
+
*/
|
|
387
|
+
private countRows;
|
|
388
|
+
/** A `POST …/query` or `POST …/count` body, as the dictionary {@link listRows} and {@link countRows} read. See `query-body.ts`. */
|
|
389
|
+
private queryDictFromRequest;
|
|
338
390
|
/**
|
|
339
391
|
* Create REST routes for a collection using existing Rebase patterns
|
|
340
392
|
*/
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A write to the auth collection is user administration.
|
|
3
|
-
*
|
|
4
|
-
* The auth collection's rows are the users. `/admin/users` holds a change to
|
|
5
|
-
* one to the auth adapter's rules: a create goes through the adapter's user
|
|
6
|
-
* creation (the password hashed, the email normalized, the collection's
|
|
7
|
-
* `onCreateUser`, the invitation), an update may not leave the project without
|
|
8
|
-
* an administrator and stores an email the way sign-in looks it up, and a
|
|
9
|
-
* deletion runs `beforeUserDelete` (a veto), ends the sessions and runs
|
|
10
|
-
* `afterUserDelete`. The data doors that write the same rows — the REST routes
|
|
11
|
-
* and MCP's write tools — call these, so that no door writes a user by rules
|
|
12
|
-
* of its own. (The Postgres socket calls the adapter's methods directly.)
|
|
13
|
-
*
|
|
14
|
-
* Every function here leaves any other collection, and an adapter without the
|
|
15
|
-
* step, exactly as it was: the rows are then written as any table's.
|
|
16
|
-
*/
|
|
17
1
|
import type { AuthAdapter, CollectionConfig, UserCreationFinalizeResult, UserCreationPrepareResult } from "@rebasepro/types";
|
|
18
2
|
import type { FieldViewer } from "@rebasepro/common";
|
|
19
3
|
/** Whether `collection` is the auth collection — its rows are the users. */
|
|
@@ -26,6 +10,21 @@ export type UserCreatingAdapter = AuthAdapter & Required<Pick<AuthAdapter, "prep
|
|
|
26
10
|
* the door writes the row as any other.
|
|
27
11
|
*/
|
|
28
12
|
export declare function createsUsers(adapter: AuthAdapter | undefined, collection: CollectionConfig): adapter is UserCreatingAdapter;
|
|
13
|
+
/**
|
|
14
|
+
* Refuse an upsert on the auth collection.
|
|
15
|
+
*
|
|
16
|
+
* An upsert is a create or an update, decided inside the write by whether the
|
|
17
|
+
* row is already there, and on the auth collection the two follow different
|
|
18
|
+
* rules: a create sets the password and sends the invitation
|
|
19
|
+
* ({@link createUserThroughAuthCollection}), an update may not demote the last
|
|
20
|
+
* administrator and normalizes the email ({@link prepareAuthCollectionUpdates}).
|
|
21
|
+
* Neither can be applied before the branch is known, so an upsert took
|
|
22
|
+
* neither — `{ id: <the last admin>, roles: ["viewer"] }` demoted them.
|
|
23
|
+
*
|
|
24
|
+
* Only where the adapter administers users; with no such step there is no
|
|
25
|
+
* rule for an upsert to miss. `where` prefixes the message (`Operation 3`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function assertNoUserUpsert(adapter: AuthAdapter | undefined, collection: CollectionConfig, where?: string): void;
|
|
29
28
|
/**
|
|
30
29
|
* Check a create body for the auth collection against what the adapter says a
|
|
31
30
|
* create consumes (`describeUserCreationContract`).
|
|
@@ -43,8 +42,16 @@ export declare function assertUserCreationBodyValid(adapter: AuthAdapter | undef
|
|
|
43
42
|
* through the adapter's `prepareUserCreation` (the password hashed or
|
|
44
43
|
* generated, the email normalized, the collection's `onCreateUser`), in order.
|
|
45
44
|
* The `values` of each result are what the door writes.
|
|
45
|
+
*
|
|
46
|
+
* `caller` is who the door is writing for: an administrator may waive the
|
|
47
|
+
* password policy for an import (`skipPasswordPolicy: true`), anyone else may
|
|
48
|
+
* not.
|
|
49
|
+
*
|
|
50
|
+
* `nameRows` is set by a bulk door: a refusal of one body (a `WEAK_PASSWORD`,
|
|
51
|
+
* a hook's 4xx) is then prefixed `Row <index>: `, as the bulk's other row
|
|
52
|
+
* errors are, so an import can say which line of its file failed.
|
|
46
53
|
*/
|
|
47
|
-
export declare function prepareUserCreations(adapter: UserCreatingAdapter, collection: CollectionConfig, bodies: readonly Record<string, unknown>[]): Promise<UserCreationPrepareResult[]>;
|
|
54
|
+
export declare function prepareUserCreations(adapter: UserCreatingAdapter, collection: CollectionConfig, bodies: readonly Record<string, unknown>[], caller: FieldViewer, nameRows?: boolean): Promise<UserCreationPrepareResult[]>;
|
|
48
55
|
/**
|
|
49
56
|
* The second half, once the rows are written — and only then, so a write that
|
|
50
57
|
* fails invites nobody: the credentials' delivery through
|
|
@@ -55,14 +62,14 @@ export declare function prepareUserCreations(adapter: UserCreatingAdapter, colle
|
|
|
55
62
|
*/
|
|
56
63
|
export declare function completeUserCreations(adapter: UserCreatingAdapter, prepared: readonly UserCreationPrepareResult[], rows: readonly Record<string, unknown>[]): Promise<UserCreationFinalizeResult[]>;
|
|
57
64
|
/**
|
|
58
|
-
* Create one user through the auth collection
|
|
59
|
-
* then `save` (the door's own driver write),
|
|
60
|
-
* {@link completeUserCreations}.
|
|
65
|
+
* Create one user through the auth collection, for `caller`:
|
|
66
|
+
* {@link prepareUserCreations}, then `save` (the door's own driver write),
|
|
67
|
+
* then {@link completeUserCreations}.
|
|
61
68
|
*
|
|
62
69
|
* `undefined` when the create is not a user creation ({@link createsUsers}) —
|
|
63
70
|
* the door then writes the row as any other.
|
|
64
71
|
*/
|
|
65
|
-
export declare function createUserThroughAuthCollection(adapter: AuthAdapter | undefined, collection: CollectionConfig, body: Record<string, unknown>, save: (values: Record<string, unknown>) => Promise<Record<string, unknown>>): Promise<{
|
|
72
|
+
export declare function createUserThroughAuthCollection(adapter: AuthAdapter | undefined, collection: CollectionConfig, body: Record<string, unknown>, caller: FieldViewer, save: (values: Record<string, unknown>) => Promise<Record<string, unknown>>): Promise<{
|
|
66
73
|
row: Record<string, unknown>;
|
|
67
74
|
delivery: UserCreationFinalizeResult;
|
|
68
75
|
} | undefined>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionConfig, IncludeSpec } from "@rebasepro/types";
|
|
2
|
-
import type
|
|
2
|
+
import { type LogicalCondition } from "@rebasepro/types";
|
|
3
3
|
import { type FieldViewer } from "@rebasepro/common";
|
|
4
4
|
/**
|
|
5
5
|
* A read may not name a field the caller cannot read.
|
|
@@ -10,13 +10,22 @@ import { type FieldViewer } from "@rebasepro/common";
|
|
|
10
10
|
* `?orderBy=salary` returns them in order of it. A column no response can carry
|
|
11
11
|
* has to be a column no query can interrogate, or the read rule is decoration.
|
|
12
12
|
*
|
|
13
|
-
* The refusal names
|
|
14
|
-
* published OpenAPI lists every property of every collection,
|
|
15
|
-
* a given caller cannot read, because the document is one
|
|
16
|
-
* off the app rather than off the authenticated data
|
|
17
|
-
* here would protect nothing and would answer a
|
|
18
|
-
* "unknown field", sending them to look for a
|
|
19
|
-
* there.
|
|
13
|
+
* The refusal names a field restricted by role. That is deliberate and it is
|
|
14
|
+
* not a leak: the published OpenAPI lists every property of every collection,
|
|
15
|
+
* including the ones a given caller cannot read, because the document is one
|
|
16
|
+
* document and is served off the app rather than off the authenticated data
|
|
17
|
+
* router. Hiding the name here would protect nothing and would answer a
|
|
18
|
+
* caller's genuine typo with "unknown field", sending them to look for a
|
|
19
|
+
* spelling mistake that is not there. Those field *names* are public; their
|
|
20
|
+
* *values* are not.
|
|
21
|
+
*
|
|
22
|
+
* An `excludeFromApi` field is the exception, because its name is *not*
|
|
23
|
+
* public: OpenAPI, `list_collections` and the generated SDK all leave it out.
|
|
24
|
+
* "`email` is not readable on `authors`" would confirm the one thing those hide,
|
|
25
|
+
* so a filter, sort, projection, include, aggregate or vector search naming one
|
|
26
|
+
* is answered as one naming a field that does not exist — built by the functions the driver answers a
|
|
27
|
+
* typo with (`@rebasepro/common`'s `unknown-field`), so the two answers are the
|
|
28
|
+
* same bytes. See {@link assertNoHiddenNames}.
|
|
20
29
|
*
|
|
21
30
|
* @module
|
|
22
31
|
*/
|
|
@@ -67,4 +76,15 @@ export declare function assertQueryFieldsReadable(options: {
|
|
|
67
76
|
property: string;
|
|
68
77
|
};
|
|
69
78
|
}, collection: CollectionConfig, viewer: FieldViewer | undefined): void;
|
|
79
|
+
/**
|
|
80
|
+
* The aggregate route's `select` and `groupBy`, which it parses itself: an
|
|
81
|
+
* `excludeFromApi` name there is answered exactly as the driver answers a
|
|
82
|
+
* column that does not exist. Walked in the driver's order — each aggregate's
|
|
83
|
+
* field, then each group key — and the first hidden *or* unknown name gets the
|
|
84
|
+
* answer, so a typo before a hidden name is still the one named.
|
|
85
|
+
*/
|
|
86
|
+
export declare function assertNoHiddenAggregateNames(aggregates: readonly {
|
|
87
|
+
fn: string;
|
|
88
|
+
field?: string;
|
|
89
|
+
}[], groupBy: readonly string[], collection: CollectionConfig): void;
|
|
70
90
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CollectionConfig, FieldOperation, FIELD_OPERATORS, isFieldOperation } from "@rebasepro/types";
|
|
1
|
+
import { CollectionConfig, FieldOperation, FIELD_OPERATORS, isFieldOperation, Properties, Property } from "@rebasepro/types";
|
|
2
2
|
/**
|
|
3
3
|
* Writes expressed as a change to the column's current value.
|
|
4
4
|
*
|
|
@@ -38,23 +38,32 @@ export interface ParsedFieldOp {
|
|
|
38
38
|
* this package.
|
|
39
39
|
*/
|
|
40
40
|
export declare const looksLikeFieldOp: typeof isFieldOperation;
|
|
41
|
-
/**
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* True when any value in the payload is (or is attempting to be) an operation.
|
|
43
|
+
* With `properties`, a `map` value is one only when it is `{ <operator>: … }`;
|
|
44
|
+
* see `isFieldOperation`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function hasFieldOps(values: Record<string, unknown> | undefined, properties?: Properties): boolean;
|
|
43
47
|
/**
|
|
44
48
|
* Parse one value as an operation, or report why it is not a legal one.
|
|
45
49
|
*
|
|
46
50
|
* Returns `undefined` for an ordinary value. Throws for a value that reads as
|
|
47
|
-
* an operation and is malformed, so a typo cannot be written as data.
|
|
51
|
+
* an operation and is malformed, so a typo cannot be written as data. Given
|
|
52
|
+
* the field's `property`, a `map` value with `$` keys is data unless it is a
|
|
53
|
+
* single real operator.
|
|
48
54
|
*/
|
|
49
|
-
export declare function parseFieldOp(key: string, value: unknown): ParsedFieldOp | undefined;
|
|
55
|
+
export declare function parseFieldOp(key: string, value: unknown, property?: Property): ParsedFieldOp | undefined;
|
|
50
56
|
/**
|
|
51
57
|
* Split a write payload into ordinary values and field operations.
|
|
52
58
|
*
|
|
53
59
|
* The two travel together in one body — `{ title: "x", views: { $inc: 1 } }` is
|
|
54
60
|
* a single `PATCH` — and are applied in one statement, so a caller never has to
|
|
55
61
|
* choose between setting a column and incrementing another.
|
|
62
|
+
*
|
|
63
|
+
* Pass the collection's `properties`: without them a `map` value carrying `$`
|
|
64
|
+
* keys reads as a (malformed) operation rather than as the document it is.
|
|
56
65
|
*/
|
|
57
|
-
export declare function splitFieldOps(values: Record<string, unknown
|
|
66
|
+
export declare function splitFieldOps(values: Record<string, unknown>, properties?: Properties): {
|
|
58
67
|
values: Record<string, unknown>;
|
|
59
68
|
fieldOps: Record<string, ParsedFieldOp>;
|
|
60
69
|
};
|
|
@@ -79,8 +88,11 @@ export declare function assertFieldOpsValid(values: Record<string, unknown>, col
|
|
|
79
88
|
* are meaningless on an insert — `views + 1` over a row that does not exist yet
|
|
80
89
|
* is just `1`, and accepting it would make `$inc` mean two different things
|
|
81
90
|
* depending on a race the caller cannot observe.
|
|
91
|
+
*
|
|
92
|
+
* `collection` decides how a `map` value is read (see {@link splitFieldOps});
|
|
93
|
+
* every request boundary has it and passes it.
|
|
82
94
|
*/
|
|
83
|
-
export declare function assertNoFieldOpsOnCreate(values: Record<string, unknown>, context: string): void;
|
|
95
|
+
export declare function assertNoFieldOpsOnCreate(values: Record<string, unknown>, context: string, collection?: CollectionConfig): void;
|
|
84
96
|
/** Re-exported so callers type against one definition of the wire shape. */
|
|
85
97
|
export type { FieldOperation };
|
|
86
98
|
export { FIELD_OPERATORS };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The body of a `POST /<collection>/query`, as the dictionary the `GET`
|
|
3
|
+
* listing reads off its URL.
|
|
4
|
+
*
|
|
5
|
+
* @param body the parsed JSON body — already known to be an object
|
|
6
|
+
* @param urlParams the names of any parameters on the request's own URL, which
|
|
7
|
+
* are refused: two places to put one parameter is two answers to "which one
|
|
8
|
+
* applied", and the listing would silently answer one of them
|
|
9
|
+
*/
|
|
10
|
+
export declare function queryDictFromBody(body: Record<string, unknown>, urlParams?: readonly string[]): Record<string, string[]>;
|
|
@@ -91,11 +91,13 @@ export interface WriteViolation {
|
|
|
91
91
|
* from that spec believed the server was checking. Enum membership, `email` and
|
|
92
92
|
* `url` were published the same way and enforced the same amount.
|
|
93
93
|
*
|
|
94
|
-
* `required` is checked only when `options.status` says this
|
|
95
|
-
* row. A `PATCH` legitimately omits keys — this function sees
|
|
96
|
-
* values, not the row they land on — so demanding them there
|
|
97
|
-
* partial update. Callers that do not pass a status get the
|
|
98
|
-
* leave
|
|
94
|
+
* A missing `required` key is checked only when `options.status` says this
|
|
95
|
+
* write creates a row. A `PATCH` legitimately omits keys — this function sees
|
|
96
|
+
* one request's values, not the row they land on — so demanding them there
|
|
97
|
+
* would refuse every partial update. Callers that do not pass a status get the
|
|
98
|
+
* old behaviour and leave a missing key to the database's NOT NULL. A required
|
|
99
|
+
* string sent as `""` is refused on every write, whatever the status: NOT NULL
|
|
100
|
+
* would store it.
|
|
99
101
|
*
|
|
100
102
|
* A value of the wrong *type* is not this function's business — that reaches
|
|
101
103
|
* Postgres, which types every column and gives a 400 through the driver's
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
|
+
import { SchemaSourceEditor } from "../schema-edit/source-editor.js";
|
|
2
3
|
import { HonoEnv } from "./types.js";
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* The editor for `collectionsDir`: one per process, shared by these routes
|
|
6
|
+
* and live schema editing's `/apply`. See {@link SchemaSourceEditor}.
|
|
7
|
+
*
|
|
8
|
+
* Here rather than beside the class because building it loads `ts-morph`, an
|
|
9
|
+
* optional peer dependency this module is imported to probe for.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSchemaSourceEditor(collectionsDir: string): SchemaSourceEditor;
|
|
12
|
+
export declare function createSchemaEditorRoutes(source: SchemaSourceEditor): Hono<HonoEnv>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { type DatabaseAdmin } from "@rebasepro/types";
|
|
3
|
+
import type { HonoEnv } from "./types.js";
|
|
4
|
+
export interface SqlExportRoutesOptions {
|
|
5
|
+
/** The default data source's admin capabilities, read per request. */
|
|
6
|
+
getAdmin: () => DatabaseAdmin | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function createSqlExportRoutes(options: SqlExportRoutesOptions): Hono<HonoEnv>;
|
package/dist/api/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { VectorSearchParams, IncludeSpec, LogicalCondition, FilterValues, N
|
|
|
2
2
|
import type { DecodedCursor } from "@rebasepro/common";
|
|
3
3
|
import type { AuthResult } from "../auth/middleware.js";
|
|
4
4
|
import type { ApiKeyMasked } from "../auth/api-keys/api-key-types.js";
|
|
5
|
+
import type { BackendServices } from "../backend/services.js";
|
|
5
6
|
/**
|
|
6
7
|
* Hono Environment Variables
|
|
7
8
|
* Passed to generic Hono<HonoEnv> to type `c.get()`
|
|
@@ -51,6 +52,12 @@ export type HonoEnv = {
|
|
|
51
52
|
};
|
|
52
53
|
/** Unique request correlation ID (generated or propagated from X-Request-ID header). */
|
|
53
54
|
requestId?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Aborted when a custom function's request outlasts its timeout and is
|
|
57
|
+
* answered 504. Read it with `getSignal(c)` from
|
|
58
|
+
* `@rebasepro/server/functions`. See `functions/request-timeout.ts`.
|
|
59
|
+
*/
|
|
60
|
+
functionSignal?: AbortSignal;
|
|
54
61
|
/**
|
|
55
62
|
* The collection this request is about, when it is about one.
|
|
56
63
|
*
|
|
@@ -97,6 +104,29 @@ export type HonoEnv = {
|
|
|
97
104
|
client: string;
|
|
98
105
|
server: string;
|
|
99
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Where the route group answering this request is mounted, e.g.
|
|
109
|
+
* `/api/data` or `/api/functions` — wherever the application put it.
|
|
110
|
+
*
|
|
111
|
+
* Set by the group's first middleware from the request itself, so a
|
|
112
|
+
* group mounted at a path of the caller's choosing still knows which
|
|
113
|
+
* collection a path names and which URL a function answers at. See
|
|
114
|
+
* `api/mount-path.ts`.
|
|
115
|
+
*/
|
|
116
|
+
mountPath?: string;
|
|
117
|
+
/**
|
|
118
|
+
* The backend answering this request: its JWT keys, access model,
|
|
119
|
+
* API-key store and rate limiters.
|
|
120
|
+
*
|
|
121
|
+
* Set by the first middleware of every route group a backend builds,
|
|
122
|
+
* so a group verifies tokens and checks scopes against its own
|
|
123
|
+
* backend wherever it is mounted, and two backends mounted on one app
|
|
124
|
+
* stay two. Absent on a route mounted outside any backend, where the
|
|
125
|
+
* helpers that read it (`requireScope`, `callerScopes`, `requireAuth`,
|
|
126
|
+
* …) answer for the process default. Set it yourself to make such a
|
|
127
|
+
* route answer for a backend: `c.set("services", backend.services)`.
|
|
128
|
+
*/
|
|
129
|
+
services?: BackendServices;
|
|
100
130
|
};
|
|
101
131
|
};
|
|
102
132
|
/**
|
|
@@ -157,4 +187,9 @@ export interface QueryOptions {
|
|
|
157
187
|
* the point of the feature.
|
|
158
188
|
*/
|
|
159
189
|
withDeleted?: boolean | "only";
|
|
190
|
+
/**
|
|
191
|
+
* From `?count=exact|none` — whether a listing counts `meta.total`. See
|
|
192
|
+
* `FindParams.count`. Unset is `"exact"`.
|
|
193
|
+
*/
|
|
194
|
+
count?: "exact" | "none";
|
|
160
195
|
}
|
|
@@ -2,7 +2,7 @@ import { createRequire as __rebaseCreateRequire } from "module";
|
|
|
2
2
|
import __rebaseProcess from "process";
|
|
3
3
|
globalThis.process ??= __rebaseProcess;
|
|
4
4
|
__rebaseCreateRequire(import.meta.url);
|
|
5
|
-
import "./src-
|
|
5
|
+
import "./src-D5Y3N-S4.js";
|
|
6
6
|
import { a as nestCollectionPatchPaths, l as nestAdminCollectionKeys, n as collectionPatchProblems, o as runtimeOnlyKeyIn, u as nestAdminPropertyKeys } from "./collection_patch-BRu-BvDv.js";
|
|
7
7
|
import * as fs$1 from "fs";
|
|
8
8
|
import * as path$1 from "path";
|
|
@@ -858,6 +858,6 @@ var AstSchemaEditor = class AstSchemaEditor {
|
|
|
858
858
|
}
|
|
859
859
|
};
|
|
860
860
|
//#endregion
|
|
861
|
-
export { AstSchemaEditor };
|
|
861
|
+
export { AstSchemaEditor, nestAdminKeys, nestAdminKeysDeep };
|
|
862
862
|
|
|
863
|
-
//# sourceMappingURL=ast-schema-editor-
|
|
863
|
+
//# sourceMappingURL=ast-schema-editor-mCeSC03x.js.map
|