@rebasepro/server 0.16.0 → 0.16.1-canary.g041c925

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 (210) hide show
  1. package/dist/{GCSStorageController-BEmDYFKc.js → GCSStorageController-Bl7nmhdv.js} +7 -6
  2. package/dist/{GCSStorageController-BEmDYFKc.js.map → GCSStorageController-Bl7nmhdv.js.map} +1 -1
  3. package/dist/{S3StorageController-B2EDXXMH.js → S3StorageController-CWvvrRpF.js} +7 -6
  4. package/dist/{S3StorageController-B2EDXXMH.js.map → S3StorageController-CWvvrRpF.js.map} +1 -1
  5. package/dist/{admin_block-DLILvzle.js → admin_block-BeypnEfb.js} +6 -6
  6. package/dist/admin_block-BeypnEfb.js.map +1 -0
  7. package/dist/api/ast-schema-editor.d.ts +23 -0
  8. package/dist/api/contract-routes.d.ts +1 -1
  9. package/dist/api/errors.d.ts +1 -1
  10. package/dist/api/index.d.ts +3 -3
  11. package/dist/api/live-schema-routes.d.ts +122 -0
  12. package/dist/api/logs-routes.d.ts +1 -1
  13. package/dist/api/mount.d.ts +41 -0
  14. package/dist/api/rest/api-generator.d.ts +2 -2
  15. package/dist/api/rest/index.d.ts +1 -1
  16. package/dist/api/rest/query-parser.d.ts +1 -1
  17. package/dist/api/schema-editor-routes.d.ts +1 -1
  18. package/dist/api/types.d.ts +12 -4
  19. package/dist/{schema-editor-routes-CV9k0w3G.js → ast-schema-editor-CDGgrIn7.js} +37 -45
  20. package/dist/ast-schema-editor-CDGgrIn7.js.map +1 -0
  21. package/dist/auth/adapter-middleware.d.ts +2 -2
  22. package/dist/auth/admin-roles-route.d.ts +2 -2
  23. package/dist/auth/admin-user-ops.d.ts +3 -3
  24. package/dist/auth/admin-users-route.d.ts +4 -6
  25. package/dist/auth/api-keys/api-key-middleware.d.ts +2 -2
  26. package/dist/auth/api-keys/api-key-permission-guard.d.ts +1 -1
  27. package/dist/auth/api-keys/api-key-routes.d.ts +2 -2
  28. package/dist/auth/api-keys/api-key-store.d.ts +1 -1
  29. package/dist/auth/api-keys/index.d.ts +9 -9
  30. package/dist/auth/apple-oauth.d.ts +2 -2
  31. package/dist/auth/auth-hooks.d.ts +4 -4
  32. package/dist/auth/bitbucket-oauth.d.ts +2 -2
  33. package/dist/auth/builtin-auth-adapter.d.ts +8 -4
  34. package/dist/auth/capabilities.d.ts +51 -0
  35. package/dist/auth/captcha.d.ts +86 -0
  36. package/dist/auth/cookie-utils.d.ts +2 -2
  37. package/dist/auth/discord-oauth.d.ts +2 -2
  38. package/dist/auth/facebook-oauth.d.ts +2 -2
  39. package/dist/auth/github-oauth.d.ts +2 -2
  40. package/dist/auth/gitlab-oauth.d.ts +2 -2
  41. package/dist/auth/google-oauth.d.ts +1 -1
  42. package/dist/auth/index.d.ts +58 -54
  43. package/dist/auth/jwks-routes.d.ts +1 -1
  44. package/dist/auth/jwt.d.ts +1 -1
  45. package/dist/auth/linkedin-oauth.d.ts +2 -2
  46. package/dist/auth/magic-link-routes.d.ts +10 -3
  47. package/dist/auth/mfa-gate.d.ts +1 -1
  48. package/dist/auth/mfa-routes.d.ts +3 -3
  49. package/dist/auth/microsoft-oauth.d.ts +2 -2
  50. package/dist/auth/middleware.d.ts +6 -7
  51. package/dist/auth/otp-routes.d.ts +89 -0
  52. package/dist/auth/rate-limiter.d.ts +2 -2
  53. package/dist/auth/require-auth.d.ts +1 -1
  54. package/dist/auth/reset-password-admin.d.ts +4 -4
  55. package/dist/auth/routes.d.ts +18 -10
  56. package/dist/auth/session-routes.d.ts +3 -3
  57. package/dist/auth/slack-oauth.d.ts +2 -2
  58. package/dist/auth/spotify-oauth.d.ts +2 -2
  59. package/dist/auth/token-revocation.d.ts +2 -2
  60. package/dist/auth/twitter-oauth.d.ts +2 -2
  61. package/dist/{auth-5Et5mnUA.js → auth-DzarZhLS.js} +603 -4376
  62. package/dist/auth-DzarZhLS.js.map +1 -0
  63. package/dist/backup/backup-common.d.ts +1 -1
  64. package/dist/backup/backup-routes.d.ts +3 -3
  65. package/dist/backup/index.d.ts +3 -3
  66. package/dist/{backup-C6ljYVTp.js → backup-CRdZkA6c.js} +7 -6
  67. package/dist/{backup-C6ljYVTp.js.map → backup-CRdZkA6c.js.map} +1 -1
  68. package/dist/boot/bindings.d.ts +81 -0
  69. package/dist/boot/boot.d.ts +5 -5
  70. package/dist/boot/bundle.d.ts +10 -1
  71. package/dist/boot/driver.d.ts +1 -1
  72. package/dist/boot/env.d.ts +28 -1
  73. package/dist/boot/fetch-bundle.d.ts +144 -1
  74. package/dist/boot/local-provisioner.d.ts +30 -0
  75. package/dist/boot/options.d.ts +30 -6
  76. package/dist/boot/resource-adapters.d.ts +31 -0
  77. package/dist/boot/resource-loading.d.ts +10 -0
  78. package/dist/boot/role.d.ts +3 -2
  79. package/dist/boot/sources.d.ts +1 -1
  80. package/dist/boot/version-skew.d.ts +1 -1
  81. package/dist/collections/BackendCollectionRegistry.d.ts +1 -1
  82. package/dist/collections/loader.d.ts +1 -1
  83. package/dist/{contract-routes-DZ-LBpSL.js → contract-routes-DDSRyGSl.js} +8 -7
  84. package/dist/contract-routes-DDSRyGSl.js.map +1 -0
  85. package/dist/cron/cron-routes.d.ts +2 -2
  86. package/dist/cron/cron-scheduler.d.ts +3 -3
  87. package/dist/cron/index.d.ts +8 -8
  88. package/dist/{cron-loader-YhhQeVBM.js → cron-loader-d9WMFENB.js} +8 -7
  89. package/dist/{cron-loader-YhhQeVBM.js.map → cron-loader-d9WMFENB.js.map} +1 -1
  90. package/dist/{cron-routes-maM_RlUu.js → cron-routes-B_GKclr5.js} +9 -8
  91. package/dist/cron-routes-B_GKclr5.js.map +1 -0
  92. package/dist/{cron-scheduler-DIpYBmZP.js → cron-scheduler-BB82dWuU.js} +9 -9
  93. package/dist/cron-scheduler-BB82dWuU.js.map +1 -0
  94. package/dist/{cron-store-DfH_4Cd9.js → cron-store-BTZqwkM1.js} +10 -9
  95. package/dist/{cron-store-DfH_4Cd9.js.map → cron-store-BTZqwkM1.js.map} +1 -1
  96. package/dist/{ddl-bootstrap-Cywoj8Ta.js → ddl-bootstrap-euwN8FOy.js} +21 -6
  97. package/dist/ddl-bootstrap-euwN8FOy.js.map +1 -0
  98. package/dist/deploy/pod-contract.d.ts +139 -0
  99. package/dist/dev-secrets.d.ts +52 -0
  100. package/dist/{dynamic-import-Dvh-K5fl.js → dynamic-import-X40pTZUQ.js} +5 -4
  101. package/dist/{dynamic-import-Dvh-K5fl.js.map → dynamic-import-X40pTZUQ.js.map} +1 -1
  102. package/dist/email/dev-sink.d.ts +88 -0
  103. package/dist/email/index.d.ts +9 -7
  104. package/dist/email/link-base.d.ts +1 -1
  105. package/dist/email/smtp-email-service.d.ts +2 -2
  106. package/dist/email/templates.d.ts +12 -0
  107. package/dist/email/types.d.ts +18 -6
  108. package/dist/env.d.ts +1 -1
  109. package/dist/{errors-EBYiaJ2E.js → errors-DBwpj9N8.js} +8 -7
  110. package/dist/errors-DBwpj9N8.js.map +1 -0
  111. package/dist/{function-loader-DDS1v7YX.js → function-loader-LLdmBFoL.js} +9 -8
  112. package/dist/{function-loader-DDS1v7YX.js.map → function-loader-LLdmBFoL.js.map} +1 -1
  113. package/dist/{function-routes-Btcez1T-.js → function-routes-ClT6UQpD.js} +8 -7
  114. package/dist/function-routes-ClT6UQpD.js.map +1 -0
  115. package/dist/functions/context.d.ts +141 -0
  116. package/dist/functions/define-function.d.ts +1 -1
  117. package/dist/functions/function-routes.d.ts +9 -3
  118. package/dist/functions/guards.d.ts +76 -0
  119. package/dist/functions/index.d.ts +96 -5
  120. package/dist/functions/index.js +919 -0
  121. package/dist/functions/index.js.map +1 -0
  122. package/dist/functions/internal.d.ts +26 -0
  123. package/dist/functions/proxy.d.ts +1 -1
  124. package/dist/functions/request-timeout.d.ts +9 -1
  125. package/dist/functions/runtime-env.d.ts +92 -0
  126. package/dist/functions/wait-until.d.ts +74 -0
  127. package/dist/history/history-routes.d.ts +2 -2
  128. package/dist/history/index.d.ts +1 -1
  129. package/dist/index.d.ts +65 -54
  130. package/dist/index.es.js +3498 -305
  131. package/dist/index.es.js.map +1 -1
  132. package/dist/init/docs.d.ts +1 -1
  133. package/dist/init/middlewares.d.ts +1 -1
  134. package/dist/init/shutdown.d.ts +4 -0
  135. package/dist/init/storage.d.ts +1 -1
  136. package/dist/init/surfaces.d.ts +10 -0
  137. package/dist/init.d.ts +171 -22
  138. package/dist/jobs/index.d.ts +5 -5
  139. package/dist/{jobs-CyOKXXlu.js → jobs-CeZzdeR8.js} +10 -9
  140. package/dist/{jobs-CyOKXXlu.js.map → jobs-CeZzdeR8.js.map} +1 -1
  141. package/dist/{jwt-DxH9fLPt.js → jwt-CpMqxVct.js} +9 -8
  142. package/dist/{jwt-DxH9fLPt.js.map → jwt-CpMqxVct.js.map} +1 -1
  143. package/dist/{logger-DfvF_8r-.js → logger-DS03e908.js} +104 -10
  144. package/dist/logger-DS03e908.js.map +1 -0
  145. package/dist/{logs-routes-CWBLQj2l.js → logs-routes-DB72iQSr.js} +36 -9
  146. package/dist/logs-routes-DB72iQSr.js.map +1 -0
  147. package/dist/metrics/index.d.ts +1 -1
  148. package/dist/{openapi-generator-BCKJRUS4.js → openapi-generator-wFJo22gg.js} +7 -11
  149. package/dist/{openapi-generator-BCKJRUS4.js.map → openapi-generator-wFJo22gg.js.map} +1 -1
  150. package/dist/{proxy-Bj5DVllb.js → proxy-CMymhnwG.js} +9 -6
  151. package/dist/{proxy-Bj5DVllb.js.map → proxy-CMymhnwG.js.map} +1 -1
  152. package/dist/query-parser-C3hHu17g.js +355 -0
  153. package/dist/query-parser-C3hHu17g.js.map +1 -0
  154. package/dist/{request-timeout-BuFoEKwT.js → request-timeout-C8gkc-j7.js} +21 -6
  155. package/dist/request-timeout-C8gkc-j7.js.map +1 -0
  156. package/dist/rls-audit/index.d.ts +111 -0
  157. package/dist/{rolldown-runtime-DSJWtz9O.js → rolldown-runtime-dW7B1o5h.js} +4 -3
  158. package/dist/schema-edit/apply-schema-change.d.ts +141 -0
  159. package/dist/schema-edit/github-repository.d.ts +67 -0
  160. package/dist/schema-edit/local-git-repository.d.ts +28 -0
  161. package/dist/schema-edit/project-root.d.ts +43 -0
  162. package/dist/schema-edit/remote-source.d.ts +25 -0
  163. package/dist/schema-edit/schema-edit-permissions.d.ts +129 -0
  164. package/dist/schema-editor-routes-CRKMZnXu.js +87 -0
  165. package/dist/schema-editor-routes-CRKMZnXu.js.map +1 -0
  166. package/dist/schemas-DBxgjM9A.js +4153 -0
  167. package/dist/schemas-DBxgjM9A.js.map +1 -0
  168. package/dist/{selection-_z6TM1DB.js → selection-CRpqKUbt.js} +6 -5
  169. package/dist/{selection-_z6TM1DB.js.map → selection-CRpqKUbt.js.map} +1 -1
  170. package/dist/services/webhook-service.d.ts +1 -1
  171. package/dist/singleton.d.ts +7 -0
  172. package/dist/{src-CrCxd8km.js → src-6VqGNeDB.js} +122 -5
  173. package/dist/src-6VqGNeDB.js.map +1 -0
  174. package/dist/{src-BPfYOeN4.js → src-C5vFEj-t.js} +8 -6
  175. package/dist/src-C5vFEj-t.js.map +1 -0
  176. package/dist/storage/GCSStorageController.d.ts +1 -1
  177. package/dist/storage/LocalStorageController.d.ts +1 -1
  178. package/dist/storage/S3StorageController.d.ts +1 -1
  179. package/dist/storage/cache-headers.d.ts +87 -0
  180. package/dist/storage/index.d.ts +11 -11
  181. package/dist/storage/path-pattern.d.ts +58 -0
  182. package/dist/storage/policies.d.ts +88 -0
  183. package/dist/storage/range.d.ts +63 -0
  184. package/dist/storage/rendition-cache.d.ts +45 -0
  185. package/dist/storage/routes.d.ts +17 -5
  186. package/dist/storage/storage-registry.d.ts +1 -1
  187. package/dist/storage/triggers.d.ts +66 -0
  188. package/dist/storage/tus-handler.d.ts +34 -3
  189. package/dist/topics/runtime.d.ts +68 -0
  190. package/dist/{types-DSnOC4mF.js → types-BfKcm9do.js} +5 -4
  191. package/dist/{types-DSnOC4mF.js.map → types-BfKcm9do.js.map} +1 -1
  192. package/dist/utils/host.d.ts +58 -0
  193. package/dist/utils/logger.d.ts +0 -15
  194. package/dist/utils/request-id.d.ts +1 -1
  195. package/functions/package.json +24 -0
  196. package/package.json +13 -7
  197. package/dist/admin_block-DLILvzle.js.map +0 -1
  198. package/dist/auth-5Et5mnUA.js.map +0 -1
  199. package/dist/contract-routes-DZ-LBpSL.js.map +0 -1
  200. package/dist/cron-routes-maM_RlUu.js.map +0 -1
  201. package/dist/cron-scheduler-DIpYBmZP.js.map +0 -1
  202. package/dist/ddl-bootstrap-Cywoj8Ta.js.map +0 -1
  203. package/dist/errors-EBYiaJ2E.js.map +0 -1
  204. package/dist/function-routes-Btcez1T-.js.map +0 -1
  205. package/dist/logger-DfvF_8r-.js.map +0 -1
  206. package/dist/logs-routes-CWBLQj2l.js.map +0 -1
  207. package/dist/request-timeout-BuFoEKwT.js.map +0 -1
  208. package/dist/schema-editor-routes-CV9k0w3G.js.map +0 -1
  209. package/dist/src-BPfYOeN4.js.map +0 -1
  210. package/dist/src-CrCxd8km.js.map +0 -1
@@ -1,5 +1,96 @@
1
- export { loadFunctionsFromDirectory } from "./function-loader";
2
- export type { LoadedFunction } from "./function-loader";
3
- export { createFunctionRoutes } from "./function-routes";
4
- export { defineFunction } from "./define-function";
5
- export type { RebaseFunctionContext } from "./define-function";
1
+ /**
2
+ * `@rebasepro/server/functions` — the portable authoring surface.
3
+ *
4
+ * Everything a custom function needs, and nothing that ties it to one runtime.
5
+ * Import from here rather than from `@rebasepro/server`:
6
+ *
7
+ * ```ts
8
+ * import { defineFunction, requireAuth, getUser, rebase } from "@rebasepro/server/functions";
9
+ * ```
10
+ *
11
+ * ## Why this entry point exists
12
+ *
13
+ * `@rebasepro/server` is a single barrel over the whole framework: the boot
14
+ * sequence, the collection loader, the backup routes, the SPA server, the
15
+ * WebSocket layer. Importing one name from it pulls `@hono/node-server`, `ws`,
16
+ * `jsonwebtoken`, Drizzle and a dozen modules that open files. On Node that
17
+ * costs a little start-up time and nothing else, which is why it stood for as
18
+ * long as it did. On a host without Node built-ins it does not resolve at all —
19
+ * so with only that entry point, *no* custom function could ever run anywhere
20
+ * but Node, no matter how portable the function's own code was.
21
+ *
22
+ * That is not a limitation you can lift later. `import { defineFunction } from
23
+ * "@rebasepro/server"` is the line in every function file, every template and
24
+ * every documentation page; changing it afterwards is a breaking change for
25
+ * everyone who has written one. The entry point has to exist before the code
26
+ * that would depend on it does.
27
+ *
28
+ * ## What "portable" means here, precisely
29
+ *
30
+ * Every module reachable from this file:
31
+ *
32
+ * - imports no Node built-in, directly or transitively;
33
+ * - imports no package that needs one (`@hono/node-server`, `ws`,
34
+ * `jsonwebtoken`, `drizzle-orm`, `pg`, …);
35
+ * - touches no host global — `process`, `Buffer`, `__dirname` — at module
36
+ * scope, so the module *evaluates* on a runtime that has none.
37
+ *
38
+ * `portability.test.ts` walks this graph on every run and fails naming the
39
+ * import chain that broke it. The rule is not a convention; it is a test.
40
+ *
41
+ * ## What is deliberately not here
42
+ *
43
+ * - **`rebase.sql()`** — reachable through `rebase`, and Node-only in practice:
44
+ * it runs on the database owner connection over a TCP socket. It is left on
45
+ * the object rather than hidden because there is nothing wrong with using it
46
+ * on a Node deployment; see its docblock, and `runtimeKey()` if a function
47
+ * needs to degrade rather than fail.
48
+ * - **Token verification.** Deciding whether a caller is who they say needs the
49
+ * signing key and belongs to the host; deciding whether *this* caller may
50
+ * call *this* route needs only the resolved identity and belongs here. That
51
+ * is why `requireAuth` below carries no crypto — see `./guards.ts`.
52
+ * - **The loader, the router, the proxy, the timeout middleware.** Host
53
+ * machinery. It lives in `./internal.ts`.
54
+ *
55
+ * @module
56
+ */
57
+ export { defineFunction } from "./define-function.js";
58
+ export type { RebaseFunctionContext } from "./define-function.js";
59
+ /**
60
+ * The app-scoped Rebase client: `dataAsAdmin`, `auth`, `storage`, `email`,
61
+ * `sql`.
62
+ *
63
+ * Re-exported here — the same object the package root exports, not a copy —
64
+ * because it is the one piece of the framework a function reaches for at
65
+ * runtime, and requiring a second import from the Node-only barrel to get it
66
+ * would defeat the entry point.
67
+ *
68
+ * It is safe to hold at module scope, unlike a configuration value, because it
69
+ * is a lazy Proxy: nothing is resolved until a property is read, which happens
70
+ * inside a request. That indirection is also the whole of what a future
71
+ * isolate-based host has to hook — see `_setRebaseResolver` in
72
+ * `../singleton.ts`.
73
+ */
74
+ export { rebase } from "../singleton.js";
75
+ export { getUser, getUserId, getRoles, hasRole, isAdmin, isAuthenticated, getDriver, requireDriver, getApiKey, getRequestId, identityResolved } from "./context.js";
76
+ export type { FunctionUser } from "./context.js";
77
+ export { requireAuth, requireAdmin, requireRole } from "./guards.js";
78
+ export { getEnv, env, requireEnv, runtimeKey, isNodeRuntime, lazyResource } from "./runtime-env.js";
79
+ export { waitUntil } from "./wait-until.js";
80
+ /**
81
+ * The Hono environment a Rebase function runs in: `c.get("user")`,
82
+ * `c.get("driver")`, `c.get("apiKey")` and `c.get("requestId")` are typed
83
+ * through it.
84
+ *
85
+ * `defineFunction` applies it for you. Declare it explicitly only when building
86
+ * the Hono app by hand: `new Hono<HonoEnv>()`.
87
+ */
88
+ export type { HonoEnv, ApiResponse } from "../api/types.js";
89
+ /**
90
+ * Throw this to answer with a specific status.
91
+ *
92
+ * The functions router installs the framework's error handler, so an `ApiError`
93
+ * thrown anywhere inside a handler becomes the status and body it names,
94
+ * whereas any other throw becomes a 500 with its detail withheld.
95
+ */
96
+ export { ApiError } from "../api/errors.js";