@rebasepro/server-core 0.5.0 → 0.6.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 (279) hide show
  1. package/dist/{server-core/src/api → api}/errors.d.ts +5 -2
  2. package/dist/{server-core/src/api → api}/rest/api-generator.d.ts +8 -2
  3. package/dist/{server-core/src/api → api}/types.d.ts +2 -0
  4. package/dist/auth/admin-user-ops.d.ts +79 -0
  5. package/dist/{server-core/src/auth → auth}/api-keys/index.d.ts +2 -2
  6. package/dist/{server-core/src/auth → auth}/auth-hooks.d.ts +37 -9
  7. package/dist/{server-core/src/auth → auth}/builtin-auth-adapter.d.ts +4 -4
  8. package/dist/{server-core/src/auth → auth}/index.d.ts +5 -2
  9. package/dist/auth/mfa-routes.d.ts +6 -0
  10. package/dist/auth/reset-password-admin.d.ts +29 -0
  11. package/dist/auth/session-routes.d.ts +25 -0
  12. package/dist/backend-CIxN4FVm.js +15 -0
  13. package/dist/backend-CIxN4FVm.js.map +1 -0
  14. package/dist/chunk-Dze3rakg.js +42 -0
  15. package/dist/{server-core/src/cron → cron}/cron-scheduler.d.ts +1 -1
  16. package/dist/dist-CZKP-Xz4.js +832 -0
  17. package/dist/dist-CZKP-Xz4.js.map +1 -0
  18. package/dist/env.d.ts +102 -0
  19. package/dist/from-VbwD7xRf.js +3849 -0
  20. package/dist/from-VbwD7xRf.js.map +1 -0
  21. package/dist/{server-core/src/index.d.ts → index.d.ts} +1 -0
  22. package/dist/index.es.js +60872 -50462
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/index.umd.js +73156 -51298
  25. package/dist/index.umd.js.map +1 -1
  26. package/dist/init/docs.d.ts +4 -0
  27. package/dist/init/health.d.ts +2 -0
  28. package/dist/init/middlewares.d.ts +10 -0
  29. package/dist/init/shutdown.d.ts +11 -0
  30. package/dist/init/storage.d.ts +5 -0
  31. package/dist/{server-core/src/init.d.ts → init.d.ts} +4 -4
  32. package/dist/jwt-DHcQRGC3.js +4168 -0
  33. package/dist/jwt-DHcQRGC3.js.map +1 -0
  34. package/dist/logger-BYU66ENZ.js +94 -0
  35. package/dist/logger-BYU66ENZ.js.map +1 -0
  36. package/dist/ms-BeBSuOXN.js +125 -0
  37. package/dist/ms-BeBSuOXN.js.map +1 -0
  38. package/dist/multipart-parser-CedBDOeC.js +299 -0
  39. package/dist/multipart-parser-CedBDOeC.js.map +1 -0
  40. package/dist/src-COaj0G3P.js +1182 -0
  41. package/dist/src-COaj0G3P.js.map +1 -0
  42. package/dist/{server-core/src/storage → storage}/image-transform.d.ts +3 -1
  43. package/dist/utils/request-id.d.ts +4 -0
  44. package/package.json +29 -29
  45. package/src/api/collections_for_test/callbacks_test_collection.ts +7 -6
  46. package/src/api/errors.ts +75 -19
  47. package/src/api/graphql/graphql-schema-generator.ts +15 -10
  48. package/src/api/logs-routes.ts +5 -2
  49. package/src/api/rest/api-generator-count.test.ts +21 -10
  50. package/src/api/rest/api-generator.ts +102 -26
  51. package/src/api/rest/query-parser.ts +18 -12
  52. package/src/api/server.ts +12 -1
  53. package/src/api/types.ts +2 -0
  54. package/src/auth/adapter-middleware.ts +17 -10
  55. package/src/auth/admin-user-ops.ts +236 -0
  56. package/src/auth/api-keys/api-key-middleware.ts +15 -9
  57. package/src/auth/api-keys/api-key-permission-guard.ts +1 -1
  58. package/src/auth/api-keys/api-key-routes.ts +3 -3
  59. package/src/auth/api-keys/api-key-store.ts +14 -8
  60. package/src/auth/api-keys/index.ts +2 -2
  61. package/src/auth/apple-oauth.ts +4 -3
  62. package/src/auth/auth-hooks.ts +50 -10
  63. package/src/auth/bitbucket-oauth.ts +5 -4
  64. package/src/auth/builtin-auth-adapter.ts +60 -39
  65. package/src/auth/custom-auth-adapter.ts +4 -5
  66. package/src/auth/discord-oauth.ts +5 -4
  67. package/src/auth/facebook-oauth.ts +5 -4
  68. package/src/auth/github-oauth.ts +6 -5
  69. package/src/auth/gitlab-oauth.ts +5 -4
  70. package/src/auth/google-oauth.ts +2 -1
  71. package/src/auth/index.ts +6 -2
  72. package/src/auth/jwt.ts +5 -4
  73. package/src/auth/linkedin-oauth.ts +4 -3
  74. package/src/auth/mfa-routes.ts +299 -0
  75. package/src/auth/mfa.ts +2 -1
  76. package/src/auth/microsoft-oauth.ts +5 -4
  77. package/src/auth/middleware.ts +5 -4
  78. package/src/auth/rate-limiter.ts +1 -1
  79. package/src/auth/reset-password-admin.ts +144 -0
  80. package/src/auth/rls-scope.ts +1 -1
  81. package/src/auth/routes.ts +52 -596
  82. package/src/auth/session-routes.ts +341 -0
  83. package/src/auth/slack-oauth.ts +6 -5
  84. package/src/auth/spotify-oauth.ts +5 -4
  85. package/src/auth/twitter-oauth.ts +4 -3
  86. package/src/collections/loader.ts +5 -4
  87. package/src/cron/cron-scheduler.test.ts +23 -11
  88. package/src/cron/cron-scheduler.ts +14 -8
  89. package/src/cron/cron-store.ts +1 -1
  90. package/src/email/smtp-email-service.ts +3 -2
  91. package/src/env.ts +11 -10
  92. package/src/index.ts +1 -0
  93. package/src/init/docs.ts +47 -0
  94. package/src/init/health.ts +37 -0
  95. package/src/init/middlewares.ts +61 -0
  96. package/src/init/shutdown.ts +56 -0
  97. package/src/init/storage.ts +57 -0
  98. package/src/init.ts +85 -279
  99. package/src/serve-spa.ts +12 -5
  100. package/src/services/driver-registry.ts +4 -3
  101. package/src/storage/S3StorageController.ts +1 -2
  102. package/src/storage/image-transform.ts +25 -10
  103. package/src/storage/routes.ts +34 -11
  104. package/src/storage/storage-registry.ts +4 -3
  105. package/src/storage/tus-handler.ts +12 -12
  106. package/src/utils/request-id.ts +40 -0
  107. package/src/utils/request-logger.ts +6 -0
  108. package/test/api-generator.test.ts +90 -2
  109. package/test/api-key-permission-guard.test.ts +24 -12
  110. package/test/auth-routes.test.ts +5 -3
  111. package/test/backend-hooks-data.test.ts +99 -30
  112. package/test/custom-auth-adapter.test.ts +16 -15
  113. package/test/email-templates.test.ts +10 -5
  114. package/test/env.test.ts +10 -10
  115. package/test/function-loader.test.ts +7 -4
  116. package/test/graphql-schema-generator.test.ts +554 -0
  117. package/test/jwt-security.test.ts +1 -1
  118. package/test/query-parser.test.ts +0 -1
  119. package/test/reset-password-admin.test.ts +113 -0
  120. package/test/singleton.test.ts +5 -5
  121. package/test/smtp-email-service.test.ts +21 -21
  122. package/test/webhook-service.test.ts +22 -11
  123. package/tsconfig.json +2 -0
  124. package/tsconfig.prod.json +3 -0
  125. package/vite.config.ts +10 -5
  126. package/dist/common/src/collections/CollectionRegistry.d.ts +0 -56
  127. package/dist/common/src/collections/default-collections.d.ts +0 -9
  128. package/dist/common/src/collections/index.d.ts +0 -2
  129. package/dist/common/src/data/buildRebaseData.d.ts +0 -14
  130. package/dist/common/src/data/query_builder.d.ts +0 -55
  131. package/dist/common/src/index.d.ts +0 -4
  132. package/dist/common/src/util/builders.d.ts +0 -57
  133. package/dist/common/src/util/callbacks.d.ts +0 -6
  134. package/dist/common/src/util/collections.d.ts +0 -11
  135. package/dist/common/src/util/common.d.ts +0 -2
  136. package/dist/common/src/util/conditions.d.ts +0 -26
  137. package/dist/common/src/util/entities.d.ts +0 -58
  138. package/dist/common/src/util/enums.d.ts +0 -3
  139. package/dist/common/src/util/index.d.ts +0 -16
  140. package/dist/common/src/util/navigation_from_path.d.ts +0 -34
  141. package/dist/common/src/util/navigation_utils.d.ts +0 -20
  142. package/dist/common/src/util/parent_references_from_path.d.ts +0 -6
  143. package/dist/common/src/util/paths.d.ts +0 -14
  144. package/dist/common/src/util/permissions.d.ts +0 -14
  145. package/dist/common/src/util/references.d.ts +0 -2
  146. package/dist/common/src/util/relations.d.ts +0 -22
  147. package/dist/common/src/util/resolutions.d.ts +0 -72
  148. package/dist/common/src/util/storage.d.ts +0 -24
  149. package/dist/index-Cr1D21av.js +0 -49
  150. package/dist/index-Cr1D21av.js.map +0 -1
  151. package/dist/server-core/src/auth/admin-routes.d.ts +0 -27
  152. package/dist/server-core/src/env.d.ts +0 -137
  153. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  154. package/dist/types/src/controllers/auth.d.ts +0 -104
  155. package/dist/types/src/controllers/client.d.ts +0 -168
  156. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  157. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  158. package/dist/types/src/controllers/data.d.ts +0 -207
  159. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  160. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  161. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  162. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  163. package/dist/types/src/controllers/email.d.ts +0 -36
  164. package/dist/types/src/controllers/index.d.ts +0 -18
  165. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  166. package/dist/types/src/controllers/navigation.d.ts +0 -225
  167. package/dist/types/src/controllers/registry.d.ts +0 -63
  168. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  169. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  170. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  171. package/dist/types/src/controllers/storage.d.ts +0 -171
  172. package/dist/types/src/index.d.ts +0 -4
  173. package/dist/types/src/rebase_context.d.ts +0 -122
  174. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  175. package/dist/types/src/types/backend.d.ts +0 -571
  176. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  177. package/dist/types/src/types/builders.d.ts +0 -15
  178. package/dist/types/src/types/chips.d.ts +0 -5
  179. package/dist/types/src/types/collections.d.ts +0 -961
  180. package/dist/types/src/types/component_ref.d.ts +0 -47
  181. package/dist/types/src/types/cron.d.ts +0 -102
  182. package/dist/types/src/types/data_source.d.ts +0 -64
  183. package/dist/types/src/types/database_adapter.d.ts +0 -94
  184. package/dist/types/src/types/entities.d.ts +0 -145
  185. package/dist/types/src/types/entity_actions.d.ts +0 -104
  186. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  187. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  188. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  189. package/dist/types/src/types/entity_views.d.ts +0 -87
  190. package/dist/types/src/types/export_import.d.ts +0 -21
  191. package/dist/types/src/types/formex.d.ts +0 -40
  192. package/dist/types/src/types/index.d.ts +0 -28
  193. package/dist/types/src/types/locales.d.ts +0 -4
  194. package/dist/types/src/types/modify_collections.d.ts +0 -5
  195. package/dist/types/src/types/plugins.d.ts +0 -282
  196. package/dist/types/src/types/properties.d.ts +0 -1173
  197. package/dist/types/src/types/property_config.d.ts +0 -74
  198. package/dist/types/src/types/relations.d.ts +0 -336
  199. package/dist/types/src/types/slots.d.ts +0 -262
  200. package/dist/types/src/types/translations.d.ts +0 -900
  201. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  202. package/dist/types/src/types/websockets.d.ts +0 -78
  203. package/dist/types/src/users/index.d.ts +0 -1
  204. package/dist/types/src/users/user.d.ts +0 -50
  205. package/src/auth/admin-routes.ts +0 -534
  206. package/test/admin-routes.test.ts +0 -544
  207. package/test/backend-hooks-admin.test.ts +0 -388
  208. /package/dist/{server-core/src/api → api}/ast-schema-editor.d.ts +0 -0
  209. /package/dist/{server-core/src/api → api}/collections_for_test/callbacks_test_collection.d.ts +0 -0
  210. /package/dist/{server-core/src/api → api}/graphql/graphql-schema-generator.d.ts +0 -0
  211. /package/dist/{server-core/src/api → api}/graphql/index.d.ts +0 -0
  212. /package/dist/{server-core/src/api → api}/index.d.ts +0 -0
  213. /package/dist/{server-core/src/api → api}/logs-routes.d.ts +0 -0
  214. /package/dist/{server-core/src/api → api}/openapi-generator.d.ts +0 -0
  215. /package/dist/{server-core/src/api → api}/rest/index.d.ts +0 -0
  216. /package/dist/{server-core/src/api → api}/rest/query-parser.d.ts +0 -0
  217. /package/dist/{server-core/src/api → api}/schema-editor-routes.d.ts +0 -0
  218. /package/dist/{server-core/src/api → api}/server.d.ts +0 -0
  219. /package/dist/{server-core/src/auth → auth}/adapter-middleware.d.ts +0 -0
  220. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-middleware.d.ts +0 -0
  221. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-permission-guard.d.ts +0 -0
  222. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-routes.d.ts +0 -0
  223. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-store.d.ts +0 -0
  224. /package/dist/{server-core/src/auth → auth}/api-keys/api-key-types.d.ts +0 -0
  225. /package/dist/{server-core/src/auth → auth}/apple-oauth.d.ts +0 -0
  226. /package/dist/{server-core/src/auth → auth}/bitbucket-oauth.d.ts +0 -0
  227. /package/dist/{server-core/src/auth → auth}/crypto-utils.d.ts +0 -0
  228. /package/dist/{server-core/src/auth → auth}/custom-auth-adapter.d.ts +0 -0
  229. /package/dist/{server-core/src/auth → auth}/discord-oauth.d.ts +0 -0
  230. /package/dist/{server-core/src/auth → auth}/facebook-oauth.d.ts +0 -0
  231. /package/dist/{server-core/src/auth → auth}/github-oauth.d.ts +0 -0
  232. /package/dist/{server-core/src/auth → auth}/gitlab-oauth.d.ts +0 -0
  233. /package/dist/{server-core/src/auth → auth}/google-oauth.d.ts +0 -0
  234. /package/dist/{server-core/src/auth → auth}/interfaces.d.ts +0 -0
  235. /package/dist/{server-core/src/auth → auth}/jwt.d.ts +0 -0
  236. /package/dist/{server-core/src/auth → auth}/linkedin-oauth.d.ts +0 -0
  237. /package/dist/{server-core/src/auth → auth}/mfa.d.ts +0 -0
  238. /package/dist/{server-core/src/auth → auth}/microsoft-oauth.d.ts +0 -0
  239. /package/dist/{server-core/src/auth → auth}/middleware.d.ts +0 -0
  240. /package/dist/{server-core/src/auth → auth}/password.d.ts +0 -0
  241. /package/dist/{server-core/src/auth → auth}/rate-limiter.d.ts +0 -0
  242. /package/dist/{server-core/src/auth → auth}/rls-scope.d.ts +0 -0
  243. /package/dist/{server-core/src/auth → auth}/routes.d.ts +0 -0
  244. /package/dist/{server-core/src/auth → auth}/slack-oauth.d.ts +0 -0
  245. /package/dist/{server-core/src/auth → auth}/spotify-oauth.d.ts +0 -0
  246. /package/dist/{server-core/src/auth → auth}/twitter-oauth.d.ts +0 -0
  247. /package/dist/{server-core/src/collections → collections}/BackendCollectionRegistry.d.ts +0 -0
  248. /package/dist/{server-core/src/collections → collections}/loader.d.ts +0 -0
  249. /package/dist/{server-core/src/cron → cron}/cron-loader.d.ts +0 -0
  250. /package/dist/{server-core/src/cron → cron}/cron-routes.d.ts +0 -0
  251. /package/dist/{server-core/src/cron → cron}/cron-store.d.ts +0 -0
  252. /package/dist/{server-core/src/cron → cron}/index.d.ts +0 -0
  253. /package/dist/{server-core/src/db → db}/interfaces.d.ts +0 -0
  254. /package/dist/{server-core/src/email → email}/index.d.ts +0 -0
  255. /package/dist/{server-core/src/email → email}/smtp-email-service.d.ts +0 -0
  256. /package/dist/{server-core/src/email → email}/templates.d.ts +0 -0
  257. /package/dist/{server-core/src/email → email}/types.d.ts +0 -0
  258. /package/dist/{server-core/src/functions → functions}/function-loader.d.ts +0 -0
  259. /package/dist/{server-core/src/functions → functions}/function-routes.d.ts +0 -0
  260. /package/dist/{server-core/src/functions → functions}/index.d.ts +0 -0
  261. /package/dist/{server-core/src/history → history}/history-routes.d.ts +0 -0
  262. /package/dist/{server-core/src/history → history}/index.d.ts +0 -0
  263. /package/dist/{server-core/src/serve-spa.d.ts → serve-spa.d.ts} +0 -0
  264. /package/dist/{server-core/src/services → services}/driver-registry.d.ts +0 -0
  265. /package/dist/{server-core/src/services → services}/webhook-service.d.ts +0 -0
  266. /package/dist/{server-core/src/singleton.d.ts → singleton.d.ts} +0 -0
  267. /package/dist/{server-core/src/storage → storage}/LocalStorageController.d.ts +0 -0
  268. /package/dist/{server-core/src/storage → storage}/S3StorageController.d.ts +0 -0
  269. /package/dist/{server-core/src/storage → storage}/index.d.ts +0 -0
  270. /package/dist/{server-core/src/storage → storage}/routes.d.ts +0 -0
  271. /package/dist/{server-core/src/storage → storage}/storage-registry.d.ts +0 -0
  272. /package/dist/{server-core/src/storage → storage}/tus-handler.d.ts +0 -0
  273. /package/dist/{server-core/src/storage → storage}/types.d.ts +0 -0
  274. /package/dist/{server-core/src/types → types}/index.d.ts +0 -0
  275. /package/dist/{server-core/src/utils → utils}/dev-port.d.ts +0 -0
  276. /package/dist/{server-core/src/utils → utils}/logger.d.ts +0 -0
  277. /package/dist/{server-core/src/utils → utils}/logging.d.ts +0 -0
  278. /package/dist/{server-core/src/utils → utils}/request-logger.d.ts +0 -0
  279. /package/dist/{server-core/src/utils → utils}/sql.d.ts +0 -0
@@ -1,34 +0,0 @@
1
- import { EntityCollection } from "@rebasepro/types";
2
- type EntityCustomView<M extends Record<string, unknown> = Record<string, unknown>> = {
3
- key: string;
4
- [key: string]: unknown;
5
- };
6
- export type NavigationViewInternal<M extends Record<string, unknown> = Record<string, unknown>> = NavigationViewEntityInternal<M> | NavigationViewCollectionInternal<M> | NavigationViewEntityCustomInternal<M>;
7
- export interface NavigationViewEntityInternal<M extends Record<string, unknown>> {
8
- type: "entity";
9
- entityId: string | number;
10
- slug: string;
11
- path: string;
12
- parentCollection: EntityCollection<M>;
13
- }
14
- export interface NavigationViewCollectionInternal<M extends Record<string, unknown>> {
15
- type: "collection";
16
- id: string;
17
- slug: string;
18
- path: string;
19
- collection: EntityCollection<M>;
20
- }
21
- export interface NavigationViewEntityCustomInternal<M extends Record<string, unknown>> {
22
- type: "custom_view";
23
- slug: string;
24
- path: string;
25
- entityId: string | number;
26
- view: EntityCustomView<M>;
27
- }
28
- export declare function getNavigationEntriesFromPath(props: {
29
- path: string;
30
- collections: EntityCollection[] | undefined;
31
- currentFullPath?: string;
32
- contextEntityViews?: EntityCustomView[];
33
- }): NavigationViewInternal[];
34
- export {};
@@ -1,20 +0,0 @@
1
- import { EntityCollection } from "@rebasepro/types";
2
- export declare function removeInitialAndTrailingSlashes(s: string): string;
3
- export declare function removeInitialSlash(s: string): string;
4
- export declare function removeTrailingSlash(s: string): string;
5
- export declare function addInitialSlash(s: string): string;
6
- export declare function getLastSegment(path: string): string;
7
- export declare function resolveCollectionPathIds(path: string, allCollections: EntityCollection[]): string;
8
- /**
9
- * Find the corresponding view at any depth for a given path.
10
- * Note that path or segments of the paths can be collection aliases.
11
- * @param slugOrPath
12
- * @param collections
13
- */
14
- export declare function getCollectionBySlugWithin(slugOrPath: string, collections: EntityCollection[]): EntityCollection | undefined;
15
- /**
16
- * Get the subcollection combinations from a path:
17
- * "sites/es/locales" => ["sites/es/locales", "sites"]
18
- * @param subpaths
19
- */
20
- export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
@@ -1,6 +0,0 @@
1
- import { EntityCollection, EntityReference } from "@rebasepro/types";
2
- export declare function getParentReferencesFromPath(props: {
3
- path: string;
4
- collections: EntityCollection[] | undefined;
5
- currentFullPath?: string;
6
- }): EntityReference[];
@@ -1,14 +0,0 @@
1
- export declare const COLLECTION_PATH_SEPARATOR = "::";
2
- /**
3
- * Remove the entity ids from a given path
4
- * `products/B44RG6APH/locales` => `products::locales`
5
- * @param path
6
- */
7
- export declare function stripCollectionPath(path: string): string;
8
- export declare function segmentsToStrippedPath(paths: string[]): string;
9
- /**
10
- * Extract the collection path routes
11
- * `products/B44RG6APH/locales` => [`products`, `locales`]
12
- * @param path
13
- */
14
- export declare function fullPathToCollectionSegments(path: string): string[];
@@ -1,14 +0,0 @@
1
- import { Entity, EntityCollection, User } from "@rebasepro/types";
2
- /**
3
- * Minimal auth context for permission checking.
4
- * Only requires the user object — avoids forcing callers to construct
5
- * a full AuthController just to check permissions.
6
- */
7
- export interface AuthContext<USER extends User = User> {
8
- user: USER | null;
9
- }
10
- export declare function checkOperation<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, entity: Entity<M> | null, targetOperation: "select" | "insert" | "update" | "delete"): boolean;
11
- export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>): boolean;
12
- export declare function canEditEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
13
- export declare function canCreateEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
14
- export declare function canDeleteEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authContext: AuthContext<USER>, path: string, entity: Entity<M> | null): boolean;
@@ -1,2 +0,0 @@
1
- import { EntityCollection } from "@rebasepro/types";
2
- export declare function getEntityImagePreviewPropertyKey<M extends Record<string, unknown>>(collection: EntityCollection<M>): string | undefined;
@@ -1,22 +0,0 @@
1
- import { EntityCollection, Property, Relation } from "@rebasepro/types";
2
- export declare function sanitizeRelation(relation: Partial<Relation>, sourceCollection: EntityCollection, resolveCollection?: (slugOrTable: string) => EntityCollection | undefined): Relation;
3
- export declare function resolveCollectionRelations(collection: EntityCollection): Record<string, Relation>;
4
- export declare function resolvePropertyRelation({ propertyKey, property, sourceCollection }: {
5
- propertyKey: string;
6
- property: Property;
7
- sourceCollection: EntityCollection;
8
- }): Relation | undefined;
9
- export declare function getTableName(collection: EntityCollection): string;
10
- export declare function getTableVarName(tableName: string): string;
11
- export declare function getEnumVarName(tableName: string, propName: string): string;
12
- export declare function getColumnName(fullColumn: string): string;
13
- /**
14
- * Look up a relation by key with forgiving normalization.
15
- *
16
- * `resolveCollectionRelations` stores each relation under a single canonical
17
- * key (no aliases). This helper tries the given key as-is, then falls back to
18
- * slug form (underscores → hyphens) and snake_case form (hyphens → underscores)
19
- * so that callers that receive a key from external input (URL path segments,
20
- * user-provided config, etc.) can still find the right entry.
21
- */
22
- export declare function findRelation(resolvedRelations: Record<string, Relation>, key: string): Relation | undefined;
@@ -1,72 +0,0 @@
1
- import { ArrayProperty, AuthController, EntityCollection, EnumValueConfig, EnumValues, NumberProperty, Properties, Property, Relation, RelationProperty, StringProperty } from "@rebasepro/types";
2
- type PropertyConfig = {
3
- property: unknown;
4
- [key: string]: unknown;
5
- };
6
- /**
7
- * Resolve property builders, enums and arrays.
8
- */
9
- export type ResolvePropertyProps<M extends Record<string, unknown> = Record<string, unknown>> = {
10
- property: Property;
11
- propertyKey?: string;
12
- values?: Partial<M>;
13
- previousValues?: Partial<M>;
14
- path?: string;
15
- entityId?: string | number;
16
- index?: number;
17
- propertyConfigs?: Record<string, PropertyConfig>;
18
- ignoreMissingFields?: boolean;
19
- authController: AuthController;
20
- };
21
- export declare function resolveProperty<M extends Record<string, unknown> = Record<string, unknown>>(props: ResolvePropertyProps<M>): Property | null;
22
- export declare function resolveRelationProperty(property: RelationProperty, relations: Relation[], propertyKey?: string): RelationProperty;
23
- /**
24
- * Resolve enum aliases for a string or number property
25
- * @param property
26
- */
27
- export declare function resolvePropertyEnum(property: StringProperty | NumberProperty): StringProperty | NumberProperty;
28
- /**
29
- * Resolve enums and arrays for properties
30
- * @param properties
31
- * @param value
32
- */
33
- export declare function resolveProperties<M extends Record<string, unknown>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
34
- propertyKey?: string;
35
- properties: Properties;
36
- values?: Partial<M>;
37
- previousValues?: Partial<M>;
38
- path?: string;
39
- entityId?: string | number;
40
- index?: number;
41
- propertyConfigs?: Record<string, PropertyConfig>;
42
- ignoreMissingFields?: boolean;
43
- authController: AuthController;
44
- }): Properties;
45
- export declare function resolveArrayProperties<M>({ propertyKey, property, ignoreMissingFields, ...props }: {
46
- propertyKey?: string;
47
- property: ArrayProperty;
48
- values?: Partial<M>;
49
- previousValues?: Partial<M>;
50
- path?: string;
51
- entityId?: string | number;
52
- index?: number;
53
- propertyConfigs?: Record<string, PropertyConfig>;
54
- ignoreMissingFields?: boolean;
55
- authController: AuthController;
56
- }): Property[];
57
- export declare function getArrayResolvedProperties({ propertyKey, propertyValue, property, ...props }: {
58
- propertyValue: unknown;
59
- propertyKey?: string;
60
- property: ArrayProperty;
61
- ignoreMissingFields: boolean;
62
- values?: object;
63
- previousValues?: object;
64
- path?: string;
65
- entityId?: string | number;
66
- index?: number;
67
- propertyConfigs?: Record<string, PropertyConfig>;
68
- authController: AuthController;
69
- }): Property[];
70
- export declare function resolveEnumValues(input: EnumValues): EnumValueConfig[] | undefined;
71
- export declare function getSubcollections<M extends Record<string, unknown> = Record<string, unknown>>(collection: EntityCollection<M>): EntityCollection<Record<string, unknown>>[];
72
- export {};
@@ -1,24 +0,0 @@
1
- import { ArrayProperty, EntityValues, StorageConfig, StringProperty, UploadedFileContext } from "@rebasepro/types";
2
- interface ResolveFilenameStringParams<M extends Record<string, unknown>> {
3
- input: string | ((context: UploadedFileContext) => (Promise<string> | string));
4
- storage: StorageConfig;
5
- values: EntityValues<M>;
6
- entityId?: string | number;
7
- path?: string;
8
- property: StringProperty | ArrayProperty;
9
- file: File;
10
- propertyKey: string;
11
- }
12
- export declare function resolveStorageFilenameString<M extends Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
13
- interface ResolveStoragePathStringParams<M extends Record<string, unknown>> {
14
- input: string | ((context: UploadedFileContext) => string);
15
- storage: StorageConfig;
16
- values: EntityValues<M>;
17
- entityId?: string | number;
18
- path?: string;
19
- property: StringProperty | ArrayProperty;
20
- file: File;
21
- propertyKey: string;
22
- }
23
- export declare function resolveStoragePathString<M extends Record<string, unknown>>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveStoragePathStringParams<M>): string;
24
- export {};
@@ -1,49 +0,0 @@
1
- import { createGoogleProvider, createLinkedinProvider, createGitHubProvider, createMicrosoftProvider, createAppleProvider, createFacebookProvider, createTwitterProvider, createDiscordProvider, createGitLabProvider, createBitbucketProvider, createSlackProvider, createSpotifyProvider } from "./index.es.js";
2
- import { apiKeyKeyGenerator, configureJwt, createAdapterAuthMiddleware, createAdminRoutes, createApiKeyRateLimiter, createApiKeyRoutes, createApiKeyStore, createAuthMiddleware, createAuthRoutes, createBuiltinAuthAdapter, createCustomAuthAdapter, createRateLimiter, defaultAuthLimiter, extractUserFromToken, generateAccessToken, generateRefreshToken, getAccessTokenExpiry, getRefreshTokenExpiry, hashPassword, hashRefreshToken, httpMethodToOperation, isApiKeyToken, isOperationAllowed, optionalAuth, requireAdmin, requireAuth, resolveAuthHooks, strictAuthLimiter, validateApiKey, validatePasswordStrength, verifyAccessToken, verifyPassword } from "./index.es.js";
3
- export {
4
- apiKeyKeyGenerator,
5
- configureJwt,
6
- createAdapterAuthMiddleware,
7
- createAdminRoutes,
8
- createApiKeyRateLimiter,
9
- createApiKeyRoutes,
10
- createApiKeyStore,
11
- createAppleProvider,
12
- createAuthMiddleware,
13
- createAuthRoutes,
14
- createBitbucketProvider,
15
- createBuiltinAuthAdapter,
16
- createCustomAuthAdapter,
17
- createDiscordProvider,
18
- createFacebookProvider,
19
- createGitHubProvider,
20
- createGitLabProvider,
21
- createGoogleProvider,
22
- createLinkedinProvider,
23
- createMicrosoftProvider,
24
- createRateLimiter,
25
- createSlackProvider,
26
- createSpotifyProvider,
27
- createTwitterProvider,
28
- defaultAuthLimiter,
29
- extractUserFromToken,
30
- generateAccessToken,
31
- generateRefreshToken,
32
- getAccessTokenExpiry,
33
- getRefreshTokenExpiry,
34
- hashPassword,
35
- hashRefreshToken,
36
- httpMethodToOperation,
37
- isApiKeyToken,
38
- isOperationAllowed,
39
- optionalAuth,
40
- requireAdmin,
41
- requireAuth,
42
- resolveAuthHooks,
43
- strictAuthLimiter,
44
- validateApiKey,
45
- validatePasswordStrength,
46
- verifyAccessToken,
47
- verifyPassword
48
- };
49
- //# sourceMappingURL=index-Cr1D21av.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Cr1D21av.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
@@ -1,27 +0,0 @@
1
- import { Hono } from "hono";
2
- import type { AuthHooks } from "./auth-hooks";
3
- import { AuthModuleConfig } from "./routes";
4
- import type { BackendHooks } from "@rebasepro/types";
5
- interface AdminRouteOptions extends AuthModuleConfig {
6
- serviceKey?: string;
7
- /**
8
- * Callback to persistently mark bootstrap as completed.
9
- * Invoked after the first admin user is promoted via POST /admin/bootstrap.
10
- */
11
- setBootstrapCompleted?: () => Promise<void>;
12
- /**
13
- * Backend-level hooks for intercepting admin data.
14
- */
15
- hooks?: BackendHooks;
16
- /**
17
- * Auth hooks for customizing password hashing, credential
18
- * verification, lifecycle hooks, etc.
19
- */
20
- authHooks?: AuthHooks;
21
- }
22
- import { HonoEnv } from "../api/types";
23
- /**
24
- * Create admin routes for user and role management
25
- */
26
- export declare function createAdminRoutes(config: AdminRouteOptions): Hono<HonoEnv>;
27
- export {};
@@ -1,137 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * The full set of environment variables recognized by a Rebase backend.
4
- */
5
- declare const rebaseEnvSchema: z.ZodObject<{
6
- NODE_ENV: z.ZodDefault<z.ZodEnum<["development", "production", "test"]>>;
7
- PORT: z.ZodEffects<z.ZodDefault<z.ZodString>, number, string | undefined>;
8
- DATABASE_URL: z.ZodString;
9
- ADMIN_CONNECTION_STRING: z.ZodOptional<z.ZodString>;
10
- JWT_SECRET: z.ZodString;
11
- JWT_ACCESS_EXPIRES_IN: z.ZodDefault<z.ZodString>;
12
- JWT_REFRESH_EXPIRES_IN: z.ZodDefault<z.ZodString>;
13
- GOOGLE_CLIENT_ID: z.ZodOptional<z.ZodString>;
14
- GOOGLE_CLIENT_SECRET: z.ZodOptional<z.ZodString>;
15
- REBASE_SERVICE_KEY: z.ZodOptional<z.ZodString>;
16
- ALLOW_REGISTRATION: z.ZodEffects<z.ZodDefault<z.ZodEnum<["true", "false", ""]>>, boolean, "" | "true" | "false" | undefined>;
17
- ALLOW_LOCALHOST_IN_PRODUCTION: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false", ""]>>, boolean, "" | "true" | "false" | undefined>;
18
- CORS_ORIGINS: z.ZodOptional<z.ZodString>;
19
- FRONTEND_URL: z.ZodOptional<z.ZodString>;
20
- DB_POOL_MAX: z.ZodEffects<z.ZodDefault<z.ZodString>, number, string | undefined>;
21
- DB_POOL_IDLE_TIMEOUT: z.ZodEffects<z.ZodDefault<z.ZodString>, number, string | undefined>;
22
- DB_POOL_CONNECT_TIMEOUT: z.ZodEffects<z.ZodDefault<z.ZodString>, number, string | undefined>;
23
- DATABASE_DIRECT_URL: z.ZodOptional<z.ZodString>;
24
- DATABASE_READ_URL: z.ZodOptional<z.ZodString>;
25
- FORCE_LOCAL_STORAGE: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false", ""]>>, boolean, "" | "true" | "false" | undefined>;
26
- STORAGE_TYPE: z.ZodDefault<z.ZodEnum<["local", "s3"]>>;
27
- STORAGE_PATH: z.ZodOptional<z.ZodString>;
28
- S3_BUCKET: z.ZodOptional<z.ZodString>;
29
- S3_REGION: z.ZodOptional<z.ZodString>;
30
- S3_ACCESS_KEY_ID: z.ZodOptional<z.ZodString>;
31
- S3_SECRET_ACCESS_KEY: z.ZodOptional<z.ZodString>;
32
- S3_ENDPOINT: z.ZodOptional<z.ZodString>;
33
- S3_FORCE_PATH_STYLE: z.ZodEffects<z.ZodOptional<z.ZodEnum<["true", "false", ""]>>, boolean, "" | "true" | "false" | undefined>;
34
- }, "strip", z.ZodTypeAny, {
35
- NODE_ENV: "development" | "production" | "test";
36
- PORT: number;
37
- DATABASE_URL: string;
38
- JWT_SECRET: string;
39
- JWT_ACCESS_EXPIRES_IN: string;
40
- JWT_REFRESH_EXPIRES_IN: string;
41
- ALLOW_REGISTRATION: boolean;
42
- ALLOW_LOCALHOST_IN_PRODUCTION: boolean;
43
- DB_POOL_MAX: number;
44
- DB_POOL_IDLE_TIMEOUT: number;
45
- DB_POOL_CONNECT_TIMEOUT: number;
46
- FORCE_LOCAL_STORAGE: boolean;
47
- STORAGE_TYPE: "local" | "s3";
48
- S3_FORCE_PATH_STYLE: boolean;
49
- ADMIN_CONNECTION_STRING?: string | undefined;
50
- GOOGLE_CLIENT_ID?: string | undefined;
51
- GOOGLE_CLIENT_SECRET?: string | undefined;
52
- REBASE_SERVICE_KEY?: string | undefined;
53
- CORS_ORIGINS?: string | undefined;
54
- FRONTEND_URL?: string | undefined;
55
- DATABASE_DIRECT_URL?: string | undefined;
56
- DATABASE_READ_URL?: string | undefined;
57
- STORAGE_PATH?: string | undefined;
58
- S3_BUCKET?: string | undefined;
59
- S3_REGION?: string | undefined;
60
- S3_ACCESS_KEY_ID?: string | undefined;
61
- S3_SECRET_ACCESS_KEY?: string | undefined;
62
- S3_ENDPOINT?: string | undefined;
63
- }, {
64
- DATABASE_URL: string;
65
- JWT_SECRET: string;
66
- NODE_ENV?: "development" | "production" | "test" | undefined;
67
- PORT?: string | undefined;
68
- ADMIN_CONNECTION_STRING?: string | undefined;
69
- JWT_ACCESS_EXPIRES_IN?: string | undefined;
70
- JWT_REFRESH_EXPIRES_IN?: string | undefined;
71
- GOOGLE_CLIENT_ID?: string | undefined;
72
- GOOGLE_CLIENT_SECRET?: string | undefined;
73
- REBASE_SERVICE_KEY?: string | undefined;
74
- ALLOW_REGISTRATION?: "" | "true" | "false" | undefined;
75
- ALLOW_LOCALHOST_IN_PRODUCTION?: "" | "true" | "false" | undefined;
76
- CORS_ORIGINS?: string | undefined;
77
- FRONTEND_URL?: string | undefined;
78
- DB_POOL_MAX?: string | undefined;
79
- DB_POOL_IDLE_TIMEOUT?: string | undefined;
80
- DB_POOL_CONNECT_TIMEOUT?: string | undefined;
81
- DATABASE_DIRECT_URL?: string | undefined;
82
- DATABASE_READ_URL?: string | undefined;
83
- FORCE_LOCAL_STORAGE?: "" | "true" | "false" | undefined;
84
- STORAGE_TYPE?: "local" | "s3" | undefined;
85
- STORAGE_PATH?: string | undefined;
86
- S3_BUCKET?: string | undefined;
87
- S3_REGION?: string | undefined;
88
- S3_ACCESS_KEY_ID?: string | undefined;
89
- S3_SECRET_ACCESS_KEY?: string | undefined;
90
- S3_ENDPOINT?: string | undefined;
91
- S3_FORCE_PATH_STYLE?: "" | "true" | "false" | undefined;
92
- }>;
93
- /** Inferred type of the validated environment. */
94
- export type RebaseEnv = z.infer<typeof rebaseEnvSchema>;
95
- /**
96
- * Load and validate the Rebase environment configuration from `process.env`.
97
- *
98
- * Call this **after** your `.env` file has been loaded (via `dotenv`, `--env-file`,
99
- * container injection, etc.). This function does not load `.env` files itself —
100
- * that is a deployment concern, not a framework concern.
101
- *
102
- * Behavior:
103
- * - Auto-generates ephemeral `JWT_SECRET` and `REBASE_SERVICE_KEY` in
104
- * non-production mode so developers can start without manual setup.
105
- * - Blocks auto-generated secrets in production.
106
- * - Returns a fully typed, validated env object.
107
- *
108
- * Use `extend` to add your own typed env variables on top of the base Rebase schema:
109
- *
110
- * @example
111
- * ```ts
112
- * import dotenv from "dotenv";
113
- * import { z } from "zod";
114
- * import { loadEnv } from "@rebasepro/server-core";
115
- *
116
- * dotenv.config({ path: "../../.env" });
117
- *
118
- * // Basic — just Rebase env vars:
119
- * export const env = loadEnv();
120
- *
121
- * // Extended — add your own typed vars:
122
- * export const env = loadEnv({
123
- * extend: z.object({
124
- * SMTP_HOST: z.string().optional(),
125
- * SMTP_PORT: z.string().default("587").transform(Number),
126
- * STRIPE_SECRET_KEY: z.string(),
127
- * })
128
- * });
129
- * // env.SMTP_HOST → string | undefined (fully typed)
130
- * // env.STRIPE_SECRET_KEY → string (validated, required)
131
- * ```
132
- */
133
- export declare function loadEnv(): RebaseEnv;
134
- export declare function loadEnv<E extends z.AnyZodObject>(options: {
135
- extend: E;
136
- }): RebaseEnv & z.infer<E>;
137
- export {};
@@ -1,7 +0,0 @@
1
- export type AnalyticsController = {
2
- /**
3
- * Callback used to get analytics events from the CMS
4
- */
5
- onAnalyticsEvent?: (event: AnalyticsEvent, data?: object) => void;
6
- };
7
- export type AnalyticsEvent = "entity_click" | "entity_click_from_reference" | "reference_selection_clear" | "reference_selection_toggle" | "reference_selected_single" | "reference_selection_new_entity" | "edit_entity_clicked" | "entity_edited" | "new_entity_click" | "new_entity_saved" | "copy_entity_click" | "entity_copied" | "single_delete_dialog_open" | "multiple_delete_dialog_open" | "single_entity_deleted" | "multiple_entities_deleted" | "drawer_navigate_to_home" | "drawer_navigate_to_collection" | "drawer_navigate_to_view" | "home_navigate_to_collection" | "home_favorite_navigate_to_collection" | "home_navigate_to_view" | "home_navigate_to_admin_view" | "home_favorite_navigate_to_view" | "home_move_card" | "home_move_group" | "home_drop_new_group" | "collection_inline_editing" | "view_mode_changed" | "kanban_card_moved" | "kanban_column_reorder" | "kanban_property_changed" | "kanban_new_entity_in_column" | "kanban_backfill_order" | "card_view_entity_click" | "unmapped_event";
@@ -1,104 +0,0 @@
1
- import type { User } from "../users";
2
- /**
3
- * Capabilities advertised by an auth provider.
4
- * UI components use this to show/hide features dynamically
5
- * (e.g. password reset, registration, session management).
6
- * @group Hooks and utilities
7
- */
8
- export interface AuthCapabilities {
9
- emailPasswordLogin?: boolean;
10
- googleLogin?: boolean;
11
- registration?: boolean;
12
- passwordReset?: boolean;
13
- sessionManagement?: boolean;
14
- profileUpdate?: boolean;
15
- emailVerification?: boolean;
16
- /** List of enabled OAuth provider IDs (e.g. ["google", "github", "discord"]) */
17
- enabledProviders?: string[];
18
- }
19
- /**
20
- * Controller for retrieving the logged user or performing auth related operations.
21
- * Note that if you are implementing your AuthController, you probably will want
22
- * to do it as the result of a hook.
23
- * @group Hooks and utilities
24
- */
25
- export type AuthController<USER extends User = User, ExtraData = unknown> = {
26
- /**
27
- * The user currently logged in
28
- * The values can be: the user object, null if they skipped login
29
- */
30
- user: USER | null;
31
- /**
32
- * Initial loading flag. It is used not to display the login screen
33
- * when the app first loads, and it has not been checked whether the user
34
- * is logged in or not.
35
- */
36
- initialLoading?: boolean;
37
- /**
38
- * Loading flag. It is used to display a loading screen when the user is
39
- * logging in or out.
40
- */
41
- authLoading: boolean;
42
- /**
43
- * Sign out
44
- */
45
- signOut: () => Promise<void>;
46
- /**
47
- * Error initializing the authentication
48
- */
49
- authError?: unknown;
50
- /**
51
- * Error dispatched by the auth provider
52
- */
53
- authProviderError?: unknown;
54
- /**
55
- * You can use this method to retrieve the auth token for the current user.
56
- */
57
- getAuthToken: () => Promise<string>;
58
- /**
59
- * Has the user skipped the login process
60
- */
61
- loginSkipped: boolean;
62
- extra: ExtraData;
63
- setExtra: (extra: ExtraData) => void;
64
- setUser?(user: USER | null): void;
65
- setUserRoles?(roles: string[]): void;
66
- /**
67
- * Capabilities advertised by the auth provider.
68
- * UI components use this to feature-detect what the backend supports.
69
- */
70
- capabilities?: AuthCapabilities;
71
- };
72
- /**
73
- * Extended auth controller with common optional auth methods.
74
- * Backend implementations (Rebase backend, Firebase, Supabase, etc.)
75
- * extend this with their own backend-specific extras.
76
- * @group Hooks and utilities
77
- */
78
- export interface AuthControllerExtended<USER extends User = User, ExtraData = unknown> extends AuthController<USER, ExtraData> {
79
- /** Login with email and password */
80
- emailPasswordLogin?(email: string, password: string): Promise<void>;
81
- /** Login with Google — accepts an ID token, access token, or authorization code payload */
82
- googleLogin?: (payload: {
83
- idToken: string;
84
- } | {
85
- accessToken: string;
86
- } | {
87
- code: string;
88
- redirectUri: string;
89
- }) => Promise<void>;
90
- /** Generic OAuth login — works with any provider. Posts payload to /auth/{providerId}. */
91
- oauthLogin?: (providerId: string, payload: Record<string, unknown>) => Promise<void>;
92
- /** Register a new user */
93
- register?(email: string, password: string, displayName?: string): Promise<void>;
94
- /** Skip login (for anonymous access if enabled) */
95
- skipLogin?(): void;
96
- /** Request password reset email */
97
- forgotPassword?(email: string): Promise<void>;
98
- /** Reset password using a token */
99
- resetPassword?(token: string, password: string): Promise<void>;
100
- /** Change password for the authenticated user */
101
- changePassword?(oldPassword: string, newPassword: string): Promise<void>;
102
- /** Update user profile */
103
- updateProfile?(displayName?: string, photoURL?: string): Promise<USER>;
104
- }