@rebasepro/server-core 0.1.2 → 0.2.3

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 (75) hide show
  1. package/LICENSE +22 -6
  2. package/dist/common/src/data/query_builder.d.ts +51 -0
  3. package/dist/common/src/index.d.ts +1 -0
  4. package/dist/common/src/util/entities.d.ts +2 -2
  5. package/dist/common/src/util/relations.d.ts +1 -1
  6. package/dist/{index-DXVBFp5V.js → index-BZoAtuqi.js} +6 -2
  7. package/dist/index-BZoAtuqi.js.map +1 -0
  8. package/dist/index.es.js +16038 -15240
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.umd.js +15980 -15178
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/server-core/src/auth/adapter-middleware.d.ts +33 -0
  13. package/dist/server-core/src/auth/admin-routes.d.ts +6 -0
  14. package/dist/server-core/src/auth/auth-overrides.d.ts +139 -0
  15. package/dist/server-core/src/auth/builtin-auth-adapter.d.ts +49 -0
  16. package/dist/server-core/src/auth/crypto-utils.d.ts +16 -0
  17. package/dist/server-core/src/auth/custom-auth-adapter.d.ts +39 -0
  18. package/dist/server-core/src/auth/index.d.ts +7 -0
  19. package/dist/server-core/src/auth/interfaces.d.ts +2 -0
  20. package/dist/server-core/src/auth/middleware.d.ts +18 -0
  21. package/dist/server-core/src/auth/rls-scope.d.ts +31 -0
  22. package/dist/server-core/src/auth/routes.d.ts +7 -1
  23. package/dist/server-core/src/env.d.ts +131 -0
  24. package/dist/server-core/src/index.d.ts +2 -0
  25. package/dist/server-core/src/init.d.ts +62 -3
  26. package/dist/types/src/controllers/auth.d.ts +9 -8
  27. package/dist/types/src/controllers/client.d.ts +3 -0
  28. package/dist/types/src/controllers/data.d.ts +21 -0
  29. package/dist/types/src/types/auth_adapter.d.ts +356 -0
  30. package/dist/types/src/types/collections.d.ts +67 -2
  31. package/dist/types/src/types/database_adapter.d.ts +94 -0
  32. package/dist/types/src/types/entity_actions.d.ts +7 -1
  33. package/dist/types/src/types/entity_callbacks.d.ts +1 -1
  34. package/dist/types/src/types/entity_views.d.ts +36 -1
  35. package/dist/types/src/types/index.d.ts +2 -0
  36. package/dist/types/src/types/plugins.d.ts +1 -1
  37. package/dist/types/src/types/properties.d.ts +24 -5
  38. package/dist/types/src/types/property_config.d.ts +6 -2
  39. package/dist/types/src/types/relations.d.ts +1 -1
  40. package/dist/types/src/types/translations.d.ts +8 -0
  41. package/dist/types/src/users/user.d.ts +5 -0
  42. package/jest.config.cjs +4 -1
  43. package/package.json +27 -27
  44. package/src/api/errors.ts +1 -1
  45. package/src/api/graphql/graphql-schema-generator.ts +7 -0
  46. package/src/api/openapi-generator.ts +13 -1
  47. package/src/api/rest/api-generator-count.test.ts +14 -12
  48. package/src/api/rest/query-parser.ts +2 -20
  49. package/src/auth/adapter-middleware.ts +83 -0
  50. package/src/auth/admin-routes.ts +36 -43
  51. package/src/auth/auth-overrides.ts +172 -0
  52. package/src/auth/builtin-auth-adapter.ts +384 -0
  53. package/src/auth/crypto-utils.ts +31 -0
  54. package/src/auth/custom-auth-adapter.ts +85 -0
  55. package/src/auth/index.ts +10 -0
  56. package/src/auth/interfaces.ts +2 -0
  57. package/src/auth/jwt.ts +3 -1
  58. package/src/auth/middleware.ts +2 -46
  59. package/src/auth/rls-scope.ts +58 -0
  60. package/src/auth/routes.ts +74 -32
  61. package/src/cron/cron-scheduler.test.ts +9 -9
  62. package/src/cron/cron-scheduler.ts +1 -1
  63. package/src/env.ts +224 -0
  64. package/src/index.ts +4 -0
  65. package/src/init.ts +355 -135
  66. package/src/storage/routes.ts +1 -19
  67. package/src/utils/logging.ts +3 -3
  68. package/test/admin-routes.test.ts +10 -4
  69. package/test/auth-routes.test.ts +2 -2
  70. package/test/backend-hooks-admin.test.ts +32 -12
  71. package/test/custom-auth-adapter.test.ts +177 -0
  72. package/test/env.test.ts +138 -0
  73. package/test/query-parser.test.ts +0 -29
  74. package/tsconfig.json +3 -0
  75. package/dist/index-DXVBFp5V.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,22 @@
1
- Source code in this repository is variously licensed under the Business Source
2
- License 1.1 (BSL), Apache version 2.0 and the MIT license. A copy of each
3
- license can be found in each one of the packages under the folder packages
4
- under a file called License. Source code in a given file is licensed under the
5
- BSL and the copyright belongs to Rebase Authors unless otherwise noted at the
6
- beginning of the file.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rebase
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,51 @@
1
+ import { FindResponse, CollectionAccessor, QueryBuilderInterface, FilterOperator } from "@rebasepro/types";
2
+ export declare class QueryBuilder<M extends Record<string, unknown> = Record<string, unknown>> implements QueryBuilderInterface<M> {
3
+ private collection;
4
+ private params;
5
+ constructor(collection: CollectionAccessor<M>);
6
+ /**
7
+ * Add a filter condition to your query.
8
+ * @example
9
+ * client.collection('users').where('age', '>=', 18).find()
10
+ */
11
+ where(column: keyof M & string, operator: FilterOperator, value: unknown): this;
12
+ /**
13
+ * Order the results by a specific column.
14
+ * @example
15
+ * client.collection('users').orderBy('createdAt', 'desc').find()
16
+ */
17
+ orderBy(column: keyof M & string, ascending?: "asc" | "desc"): this;
18
+ /**
19
+ * Limit the number of results returned.
20
+ */
21
+ limit(count: number): this;
22
+ /**
23
+ * Skip the first N results.
24
+ */
25
+ offset(count: number): this;
26
+ /**
27
+ * Set a free-text search string if supported by the backend.
28
+ */
29
+ search(searchString: string): this;
30
+ /**
31
+ * Include related entities in the response.
32
+ * Relations will be populated with full entity data instead of just IDs.
33
+ *
34
+ * @param relations - Relation names to include, or "*" for all.
35
+ * @example
36
+ * // Include specific relations
37
+ * client.data.posts.include("tags", "author").find()
38
+ *
39
+ * // Include all relations
40
+ * client.data.posts.include("*").find()
41
+ */
42
+ include(...relations: string[]): this;
43
+ /**
44
+ * Execute the find query and return the results.
45
+ */
46
+ find(): Promise<FindResponse<M>>;
47
+ /**
48
+ * Listen to realtime updates matching this query.
49
+ */
50
+ listen(onUpdate: (data: FindResponse<M>) => void, onError?: (error: Error) => void): () => void;
51
+ }
@@ -1,3 +1,4 @@
1
1
  export * from "./util";
2
2
  export * from "./collections";
3
3
  export * from "./data/buildRebaseData";
4
+ export * from "./data/query_builder";
@@ -3,8 +3,8 @@ export declare function isReadOnly(property: Property): boolean;
3
3
  export declare function isHidden(property: Property): boolean;
4
4
  export declare function isPropertyBuilder(property?: Property): boolean;
5
5
  export declare function getDefaultValuesFor<M extends Record<string, unknown>>(properties: Properties): Partial<EntityValues<M>>;
6
- export declare function getDefaultValueFor(property?: Property): {} | null | undefined;
7
- export declare function getDefaultValueFortype(type: DataType): {} | null;
6
+ export declare function getDefaultValueFor(property?: Property): unknown;
7
+ export declare function getDefaultValueFortype(type: DataType): unknown;
8
8
  /**
9
9
  * Update the automatic values in an entity before save
10
10
  * @group Driver
@@ -1,5 +1,5 @@
1
1
  import { EntityCollection, Property, Relation } from "@rebasepro/types";
2
- export declare function sanitizeRelation(relation: Partial<Relation>, sourceCollection: EntityCollection): Relation;
2
+ export declare function sanitizeRelation(relation: Partial<Relation>, sourceCollection: EntityCollection, resolveCollection?: (slugOrTable: string) => EntityCollection | undefined): Relation;
3
3
  export declare function resolveCollectionRelations(collection: EntityCollection): Record<string, Relation>;
4
4
  export declare function resolvePropertyRelation({ propertyKey, property, sourceCollection }: {
5
5
  propertyKey: string;
@@ -1,12 +1,15 @@
1
1
  import { createGoogleProvider, createLinkedinProvider, createGitHubProvider, createMicrosoftProvider, createAppleProvider, createFacebookProvider, createTwitterProvider, createDiscordProvider, createGitLabProvider, createBitbucketProvider, createSlackProvider, createSpotifyProvider } from "./index.es.js";
2
- import { configureJwt, createAdminRoutes, createAuthMiddleware, createAuthRoutes, createRateLimiter, defaultAuthLimiter, extractUserFromToken, generateAccessToken, generateRefreshToken, getAccessTokenExpiry, getRefreshTokenExpiry, hashPassword, hashRefreshToken, optionalAuth, requireAdmin, requireAuth, strictAuthLimiter, validatePasswordStrength, verifyAccessToken, verifyPassword } from "./index.es.js";
2
+ import { configureJwt, createAdapterAuthMiddleware, createAdminRoutes, createAuthMiddleware, createAuthRoutes, createBuiltinAuthAdapter, createCustomAuthAdapter, createRateLimiter, defaultAuthLimiter, extractUserFromToken, generateAccessToken, generateRefreshToken, getAccessTokenExpiry, getRefreshTokenExpiry, hashPassword, hashRefreshToken, optionalAuth, requireAdmin, requireAuth, resolveAuthOverrides, strictAuthLimiter, validatePasswordStrength, verifyAccessToken, verifyPassword } from "./index.es.js";
3
3
  export {
4
4
  configureJwt,
5
+ createAdapterAuthMiddleware,
5
6
  createAdminRoutes,
6
7
  createAppleProvider,
7
8
  createAuthMiddleware,
8
9
  createAuthRoutes,
9
10
  createBitbucketProvider,
11
+ createBuiltinAuthAdapter,
12
+ createCustomAuthAdapter,
10
13
  createDiscordProvider,
11
14
  createFacebookProvider,
12
15
  createGitHubProvider,
@@ -29,9 +32,10 @@ export {
29
32
  optionalAuth,
30
33
  requireAdmin,
31
34
  requireAuth,
35
+ resolveAuthOverrides,
32
36
  strictAuthLimiter,
33
37
  validatePasswordStrength,
34
38
  verifyAccessToken,
35
39
  verifyPassword
36
40
  };
37
- //# sourceMappingURL=index-DXVBFp5V.js.map
41
+ //# sourceMappingURL=index-BZoAtuqi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BZoAtuqi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}