@rebasepro/server-postgresql 0.2.1 → 0.2.4

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 (57) hide show
  1. package/dist/common/src/collections/default-collections.d.ts +12 -0
  2. package/dist/common/src/collections/index.d.ts +1 -0
  3. package/dist/common/src/data/query_builder.d.ts +51 -0
  4. package/dist/common/src/index.d.ts +1 -0
  5. package/dist/common/src/util/permissions.d.ts +1 -0
  6. package/dist/index.es.js +1202 -369
  7. package/dist/index.es.js.map +1 -1
  8. package/dist/index.umd.js +1200 -367
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/server-postgresql/src/PostgresBackendDriver.d.ts +1 -1
  11. package/dist/server-postgresql/src/PostgresBootstrapper.d.ts +1 -0
  12. package/dist/server-postgresql/src/auth/services.d.ts +43 -1
  13. package/dist/server-postgresql/src/connection.d.ts +25 -0
  14. package/dist/server-postgresql/src/schema/auth-schema.d.ts +2382 -35
  15. package/dist/server-postgresql/src/services/EntityFetchService.d.ts +4 -0
  16. package/dist/server-postgresql/src/services/entityService.d.ts +2 -0
  17. package/dist/server-postgresql/src/services/realtimeService.d.ts +20 -0
  18. package/dist/server-postgresql/src/utils/drizzle-conditions.d.ts +18 -0
  19. package/dist/types/src/controllers/auth.d.ts +2 -24
  20. package/dist/types/src/controllers/client.d.ts +0 -3
  21. package/dist/types/src/controllers/collection_registry.d.ts +1 -1
  22. package/dist/types/src/controllers/data.d.ts +21 -0
  23. package/dist/types/src/controllers/data_driver.d.ts +18 -0
  24. package/dist/types/src/controllers/registry.d.ts +5 -4
  25. package/dist/types/src/rebase_context.d.ts +1 -1
  26. package/dist/types/src/types/auth_adapter.d.ts +2 -4
  27. package/dist/types/src/types/collections.d.ts +0 -4
  28. package/dist/types/src/types/component_ref.d.ts +1 -1
  29. package/dist/types/src/types/cron.d.ts +1 -1
  30. package/dist/types/src/types/entity_views.d.ts +1 -0
  31. package/dist/types/src/types/export_import.d.ts +1 -1
  32. package/dist/types/src/types/formex.d.ts +2 -2
  33. package/dist/types/src/types/properties.d.ts +2 -2
  34. package/dist/types/src/types/translations.d.ts +28 -12
  35. package/dist/types/src/types/user_management_delegate.d.ts +6 -4
  36. package/dist/types/src/users/roles.d.ts +0 -8
  37. package/package.json +7 -6
  38. package/src/PostgresBackendDriver.ts +13 -7
  39. package/src/PostgresBootstrapper.ts +27 -8
  40. package/src/auth/ensure-tables.ts +79 -17
  41. package/src/auth/services.ts +292 -23
  42. package/src/cli.ts +5 -0
  43. package/src/connection.ts +77 -0
  44. package/src/data-transformer.ts +2 -2
  45. package/src/schema/auth-schema.ts +80 -14
  46. package/src/schema/default-collections.ts +1 -0
  47. package/src/schema/doctor.ts +82 -41
  48. package/src/schema/generate-drizzle-schema.ts +6 -6
  49. package/src/services/EntityFetchService.ts +69 -10
  50. package/src/services/entityService.ts +2 -0
  51. package/src/services/realtimeService.ts +214 -2
  52. package/src/utils/drizzle-conditions.ts +74 -2
  53. package/src/websocket.ts +10 -2
  54. package/test/auth-services.test.ts +15 -28
  55. package/test/drizzle-conditions.test.ts +168 -0
  56. package/test/postgresDataDriver.test.ts +130 -1
  57. package/vite.config.ts +1 -1
@@ -0,0 +1,12 @@
1
+ import { PostgresCollection } from "@rebasepro/types";
2
+ /**
3
+ * Default users collection definition.
4
+ *
5
+ * Shared between the admin UI (for navigation/display) and the backend
6
+ * (for schema generation). Both consumers prepend this to the developer's
7
+ * collections array and rely on generic slug-based deduplication
8
+ * (Map keyed by slug, last-write-wins) so that developer-defined
9
+ * collections with the same slug override this default — no hardcoded
10
+ * string checks required.
11
+ */
12
+ export declare const defaultUsersCollection: PostgresCollection;
@@ -1 +1,2 @@
1
1
  export * from "./CollectionRegistry";
2
+ export * from "./default-collections";
@@ -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";
@@ -1,4 +1,5 @@
1
1
  import { AuthController, Entity, EntityCollection, User } from "@rebasepro/types";
2
+ export declare function checkOperation<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, entity: Entity<M> | null, targetOperation: "select" | "insert" | "update" | "delete"): boolean;
2
3
  export declare function canReadCollection<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>): boolean;
3
4
  export declare function canEditEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;
4
5
  export declare function canCreateEntity<M extends Record<string, unknown>, USER extends User>(collection: EntityCollection<M>, authController: AuthController<USER>, path: string, entity: Entity<M> | null): boolean;