@rebasepro/client-postgresql 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 (74) hide show
  1. package/dist/index.es.js +117 -163
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +121 -166
  4. package/dist/index.umd.js.map +1 -1
  5. package/package.json +12 -10
  6. package/test/usePostgresClientDriver.test.tsx +101 -0
  7. package/tsconfig.json +2 -0
  8. package/tsconfig.prod.json +4 -1
  9. package/vite.config.ts +5 -1
  10. package/dist/client/src/admin.d.ts +0 -61
  11. package/dist/client/src/auth.d.ts +0 -178
  12. package/dist/client/src/collection.d.ts +0 -21
  13. package/dist/client/src/cron.d.ts +0 -25
  14. package/dist/client/src/functions.d.ts +0 -49
  15. package/dist/client/src/index.d.ts +0 -48
  16. package/dist/client/src/query_builder.d.ts +0 -1
  17. package/dist/client/src/reviver.d.ts +0 -1
  18. package/dist/client/src/storage.d.ts +0 -3
  19. package/dist/client/src/transport.d.ts +0 -33
  20. package/dist/client/src/websocket.d.ts +0 -105
  21. package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
  22. package/dist/types/src/controllers/auth.d.ts +0 -104
  23. package/dist/types/src/controllers/client.d.ts +0 -168
  24. package/dist/types/src/controllers/collection_registry.d.ts +0 -46
  25. package/dist/types/src/controllers/customization_controller.d.ts +0 -60
  26. package/dist/types/src/controllers/data.d.ts +0 -207
  27. package/dist/types/src/controllers/data_driver.d.ts +0 -218
  28. package/dist/types/src/controllers/database_admin.d.ts +0 -11
  29. package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
  30. package/dist/types/src/controllers/effective_role.d.ts +0 -4
  31. package/dist/types/src/controllers/email.d.ts +0 -36
  32. package/dist/types/src/controllers/index.d.ts +0 -18
  33. package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
  34. package/dist/types/src/controllers/navigation.d.ts +0 -225
  35. package/dist/types/src/controllers/registry.d.ts +0 -63
  36. package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
  37. package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
  38. package/dist/types/src/controllers/snackbar.d.ts +0 -24
  39. package/dist/types/src/controllers/storage.d.ts +0 -171
  40. package/dist/types/src/index.d.ts +0 -4
  41. package/dist/types/src/rebase_context.d.ts +0 -122
  42. package/dist/types/src/types/auth_adapter.d.ts +0 -301
  43. package/dist/types/src/types/backend.d.ts +0 -571
  44. package/dist/types/src/types/backend_hooks.d.ts +0 -172
  45. package/dist/types/src/types/builders.d.ts +0 -15
  46. package/dist/types/src/types/chips.d.ts +0 -5
  47. package/dist/types/src/types/collections.d.ts +0 -961
  48. package/dist/types/src/types/component_ref.d.ts +0 -47
  49. package/dist/types/src/types/cron.d.ts +0 -102
  50. package/dist/types/src/types/data_source.d.ts +0 -64
  51. package/dist/types/src/types/database_adapter.d.ts +0 -94
  52. package/dist/types/src/types/entities.d.ts +0 -145
  53. package/dist/types/src/types/entity_actions.d.ts +0 -104
  54. package/dist/types/src/types/entity_callbacks.d.ts +0 -173
  55. package/dist/types/src/types/entity_link_builder.d.ts +0 -7
  56. package/dist/types/src/types/entity_overrides.d.ts +0 -10
  57. package/dist/types/src/types/entity_views.d.ts +0 -87
  58. package/dist/types/src/types/export_import.d.ts +0 -21
  59. package/dist/types/src/types/formex.d.ts +0 -40
  60. package/dist/types/src/types/index.d.ts +0 -28
  61. package/dist/types/src/types/locales.d.ts +0 -4
  62. package/dist/types/src/types/modify_collections.d.ts +0 -5
  63. package/dist/types/src/types/plugins.d.ts +0 -282
  64. package/dist/types/src/types/properties.d.ts +0 -1173
  65. package/dist/types/src/types/property_config.d.ts +0 -74
  66. package/dist/types/src/types/relations.d.ts +0 -336
  67. package/dist/types/src/types/slots.d.ts +0 -262
  68. package/dist/types/src/types/translations.d.ts +0 -900
  69. package/dist/types/src/types/user_management_delegate.d.ts +0 -86
  70. package/dist/types/src/types/websockets.d.ts +0 -78
  71. package/dist/types/src/users/index.d.ts +0 -1
  72. package/dist/types/src/users/user.d.ts +0 -50
  73. /package/dist/{client-postgresql/src/index.d.ts → index.d.ts} +0 -0
  74. /package/dist/{client-postgresql/src/usePostgresClientDriver.d.ts → usePostgresClientDriver.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/usePostgresClientDriver.ts"],"sourcesContent":["import { useMemo, useEffect } from \"react\";\nimport {\n DataDriver,\n DeleteEntityProps,\n Entity,\n EntityCollection,\n EntityReference, EntityRelation,\n FetchCollectionProps,\n FetchEntityProps,\n ListenCollectionProps,\n ListenEntityProps,\n SaveEntityProps,\n BranchInfo\n} from \"@rebasepro/types\";\nimport { RebaseWebSocketClient } from \"@rebasepro/client\";\n\nexport interface PostgresDataDriverConfig {\n wsClient?: RebaseWebSocketClient;\n}\n\nexport interface PostgresDataDriver extends DataDriver {\n client?: RebaseWebSocketClient;\n}\n\n\nexport function usePostgresClientDriver(config: PostgresDataDriverConfig): PostgresDataDriver {\n const client = config.wsClient;\n\n return useMemo(() => {\n if (!client) throw new Error(\"RebaseWebSocketClient must be provided in config.wsClient\");\n\n return {\n\n key: \"postgres\",\n\n name: \"PostgreSQL\",\n\n client,\n\n async fetchCollection<M extends Record<string, any>>(props: FetchCollectionProps<M>): Promise<Entity<M>[]> {\n // Pick only the fields the client needs, ignoring extra fields from the CMS layer\n const { path, filter, limit, startAfter, orderBy, searchString, order } = props;\n return client.fetchCollection({ path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder }) as Promise<Entity<M>[]>;\n },\n\n async fetchEntity<M extends Record<string, any>>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined> {\n const { path, entityId, databaseId } = props;\n return client.fetchEntity({ path,\nentityId,\ndatabaseId }) as Promise<Entity<M> | undefined>;\n },\n\n async saveEntity<M extends Record<string, any>>(props: SaveEntityProps<M>): Promise<Entity<M>> {\n return client.saveEntity({\n path: props.path,\n values: props.values,\n entityId: props.entityId,\n previousValues: props.previousValues,\n status: props.status\n }) as Promise<Entity<M>>;\n },\n\n async deleteEntity<M extends Record<string, any>>(props: DeleteEntityProps<M>): Promise<void> {\n const { entity } = props;\n return client.deleteEntity({ entity });\n },\n\n async checkUniqueField(path: string, name: string, value: unknown, entityId?: string, collection?: EntityCollection): Promise<boolean> {\n return client.checkUniqueField(path, name, value, entityId, collection);\n },\n\n async countEntities<M extends Record<string, any>>(props: FetchCollectionProps<M>): Promise<number> {\n const { path, filter, limit, startAfter, orderBy, searchString, order } = props;\n return client.countEntities({ path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder });\n },\n\n listenCollection<M extends Record<string, any>>(props: ListenCollectionProps<M>): () => void {\n const { path, filter, limit, startAfter, orderBy, searchString, order, onUpdate, onError } = props;\n return client.listenCollection(\n { path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder },\n (entities: Entity[]) => props.onUpdate(entities as Entity<M>[]),\n props.onError\n );\n },\n\n listenEntity<M extends Record<string, any>>(props: ListenEntityProps<M>): () => void {\n const { path, entityId, databaseId, onUpdate, onError } = props;\n return client.listenEntity(\n { path,\nentityId,\ndatabaseId },\n (entity: Entity | null) => {\n props.onUpdate(entity as Entity<M> | null);\n },\n props.onError\n );\n },\n\n isFilterCombinationValid(): boolean {\n return true; // PostgreSQL supports complex filter combinations\n },\n\n admin: {\n executeSql(sql: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]> {\n return client.executeSql(sql, options);\n },\n fetchAvailableDatabases(): Promise<string[]> {\n return client.fetchAvailableDatabases();\n },\n fetchAvailableRoles(): Promise<string[]> {\n return client.fetchAvailableRoles();\n },\n fetchCurrentDatabase(): Promise<string | undefined> {\n return client.fetchCurrentDatabase();\n },\n fetchUnmappedTables(mappedPaths?: string[]): Promise<string[]> {\n return client.fetchUnmappedTables(mappedPaths);\n },\n fetchTableMetadata(tableName: string): Promise<unknown> {\n return client.fetchTableMetadata(tableName);\n },\n createBranch(name: string, options?: { source?: string }): Promise<BranchInfo> {\n return client.createBranch(name, options);\n },\n deleteBranch(name: string): Promise<void> {\n return client.deleteBranch(name);\n },\n listBranches(): Promise<BranchInfo[]> {\n return client.listBranches();\n }\n }\n } as PostgresDataDriver;\n }, [client]);\n\n}\n"],"names":["usePostgresClientDriver","config","$","_c","client","wsClient","t0","Error","t1","key","name","fetchCollection","props","path","filter","limit","startAfter","orderBy","searchString","order","fetchEntity","props_0","path_0","entityId","databaseId","saveEntity","props_1","values","previousValues","status","deleteEntity","props_2","entity","checkUniqueField","path_1","value","entityId_0","collection","countEntities","props_3","path_2","filter_0","limit_0","startAfter_0","orderBy_0","searchString_0","order_0","listenCollection","props_4","path_3","filter_1","limit_1","startAfter_1","orderBy_1","searchString_1","order_1","entities","onUpdate","onError","listenEntity","props_5","path_4","entityId_1","databaseId_0","entity_0","isFilterCombinationValid","admin","executeSql","sql","options","fetchAvailableDatabases","fetchAvailableRoles","fetchCurrentDatabase","fetchUnmappedTables","mappedPaths","fetchTableMetadata","tableName","createBranch","name_0","options_0","deleteBranch","name_1","listBranches"],"mappings":";;;;AAyBO,WAAAA,wBAAAC,QAAA;AAAA,UAAAC,IAAAC,qBAAAA,EAAA,CAAA;AACH,UAAAC,SAAeH,OAAMI;AAAU,QAAAC;AAAA,QAAA,CAGtBF,QAAM;AAAA,YAAA,IAAAG,MAAkB,2DAA2D;AAAA,IAAA;AAAA,QAAAC;AAAA,QAAAN,SAAAE,QAAA;AAEjFI,WAAA;AAAA,QAAAC,KAEF;AAAA,QAAUC,MAET;AAAA,QAAYN;AAAAA,QAAA,MAAAO,gBAAAC,OAAA;AAMd,gBAAA;AAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,UAAAA,IAA0EP;AAAM,iBACzER,OAAMO,gBAAA;AAAA,YAAAE;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC;AAAAA,YAAAC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G5BpE,OAAMoE,qBAAAA;AAAAA,UAAuB;AAAA,UAAAC,oBAAAC,aAAA;AAAA,mBAG7BtE,OAAMqE,oBAAqBC,WAAW;AAAA,UAAC;AAAA,UAAAC,mBAAAC,WAAA;AAAA,mBAGvCxE,OAAMuE,mBAAoBC,SAAS;AAAA,UAAC;AAAA,UAAAC,aAAAC,QAAAC,WAAA;AAAA,mBAGpC3E,OAAMyE,aAAcnE,QAAM2D,SAAO;AAAA,UAAC;AAAA,UAAAW,aAAAC,QAAA;AAAA,mBAGlC7E,OAAM4E,aAActE,MAAI;AAAA,UAAC;AAAA,UAAAwE,eAAA;AAAA,mBAGzB9E,OAAM8E,aAAAA;AAAAA,UAAe;AAAA,QAAA;AAAA,MAAA;AAGvChF,aAAAE;AAAAF,aAAAM;AAAAA,IAAA,OAAA;AAAAA,WAAAN,EAAA,CAAA;AAAA,IAAA;AAtHGI,SAAOE;AAsHa,WAzHjBF;AAAAA,EA0HK;;;;"}
1
+ {"version":3,"file":"index.umd.js","names":[],"sources":["../src/usePostgresClientDriver.ts"],"sourcesContent":["import { useMemo, useEffect } from \"react\";\nimport {\n DataDriver,\n DeleteEntityProps,\n Entity,\n EntityCollection,\n EntityReference, EntityRelation,\n FetchCollectionProps,\n FetchEntityProps,\n ListenCollectionProps,\n ListenEntityProps,\n SaveEntityProps,\n BranchInfo\n} from \"@rebasepro/types\";\nimport { RebaseWebSocketClient } from \"@rebasepro/client\";\n\nexport interface PostgresDataDriverConfig {\n wsClient?: RebaseWebSocketClient;\n}\n\nexport interface PostgresDataDriver extends DataDriver {\n client?: RebaseWebSocketClient;\n}\n\n\nexport function usePostgresClientDriver(config: PostgresDataDriverConfig): PostgresDataDriver {\n const client = config.wsClient;\n\n return useMemo(() => {\n if (!client) throw new Error(\"RebaseWebSocketClient must be provided in config.wsClient\");\n\n return {\n\n key: \"postgres\",\n\n name: \"PostgreSQL\",\n\n client,\n\n async fetchCollection<M extends Record<string, any>>(props: FetchCollectionProps<M>): Promise<Entity<M>[]> {\n // Pick only the fields the client needs, ignoring extra fields from the CMS layer\n const { path, filter, limit, startAfter, orderBy, searchString, order } = props;\n return client.fetchCollection({ path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder }) as Promise<Entity<M>[]>;\n },\n\n async fetchEntity<M extends Record<string, any>>(props: FetchEntityProps<M>): Promise<Entity<M> | undefined> {\n const { path, entityId, databaseId } = props;\n return client.fetchEntity({ path,\nentityId,\ndatabaseId }) as Promise<Entity<M> | undefined>;\n },\n\n async saveEntity<M extends Record<string, any>>(props: SaveEntityProps<M>): Promise<Entity<M>> {\n return client.saveEntity({\n path: props.path,\n values: props.values,\n entityId: props.entityId,\n previousValues: props.previousValues,\n status: props.status\n }) as Promise<Entity<M>>;\n },\n\n async deleteEntity<M extends Record<string, any>>(props: DeleteEntityProps<M>): Promise<void> {\n const { entity } = props;\n return client.deleteEntity({ entity });\n },\n\n async checkUniqueField(path: string, name: string, value: unknown, entityId?: string, collection?: EntityCollection): Promise<boolean> {\n return client.checkUniqueField(path, name, value, entityId, collection);\n },\n\n async countEntities<M extends Record<string, any>>(props: FetchCollectionProps<M>): Promise<number> {\n const { path, filter, limit, startAfter, orderBy, searchString, order } = props;\n return client.countEntities({ path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder });\n },\n\n listenCollection<M extends Record<string, any>>(props: ListenCollectionProps<M>): () => void {\n const { path, filter, limit, startAfter, orderBy, searchString, order, onUpdate, onError } = props;\n return client.listenCollection(\n { path,\nfilter,\nlimit,\nstartAfter,\norderBy,\nsearchString,\norder },\n (entities: Entity[]) => props.onUpdate(entities as Entity<M>[]),\n props.onError\n );\n },\n\n listenEntity<M extends Record<string, any>>(props: ListenEntityProps<M>): () => void {\n const { path, entityId, databaseId, onUpdate, onError } = props;\n return client.listenEntity(\n { path,\nentityId,\ndatabaseId },\n (entity: Entity | null) => {\n props.onUpdate(entity as Entity<M> | null);\n },\n props.onError\n );\n },\n\n isFilterCombinationValid(): boolean {\n return true; // PostgreSQL supports complex filter combinations\n },\n\n admin: {\n executeSql(sql: string, options?: { database?: string; role?: string }): Promise<Record<string, unknown>[]> {\n return client.executeSql(sql, options);\n },\n fetchAvailableDatabases(): Promise<string[]> {\n return client.fetchAvailableDatabases();\n },\n fetchAvailableRoles(): Promise<string[]> {\n return client.fetchAvailableRoles();\n },\n fetchCurrentDatabase(): Promise<string | undefined> {\n return client.fetchCurrentDatabase();\n },\n fetchUnmappedTables(mappedPaths?: string[]): Promise<string[]> {\n return client.fetchUnmappedTables(mappedPaths);\n },\n fetchTableMetadata(tableName: string): Promise<unknown> {\n return client.fetchTableMetadata(tableName);\n },\n createBranch(name: string, options?: { source?: string }): Promise<BranchInfo> {\n return client.createBranch(name, options);\n },\n deleteBranch(name: string): Promise<void> {\n return client.deleteBranch(name);\n },\n listBranches(): Promise<BranchInfo[]> {\n return client.listBranches();\n }\n }\n } as PostgresDataDriver;\n }, [client]);\n\n}\n"],"mappings":";;;;;CAyBA,SAAgB,wBAAwB,QAAsD;EAC1F,MAAM,SAAS,OAAO;EAEtB,QAAA,GAAA,MAAA,eAAqB;GACjB,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,2DAA2D;GAExF,OAAO;IAEP,KAAK;IAEL,MAAM;IAEN;IAEA,MAAM,gBAA+C,OAAsD;KAEvG,MAAM,EAAE,MAAM,QAAQ,OAAO,YAAY,SAAS,cAAc,UAAU;KAC1E,OAAO,OAAO,gBAAgB;MAAE;MAC5C;MACA;MACA;MACA;MACA;MACA;KAAM,CAAC;IACC;IAEA,MAAM,YAA2C,OAA4D;KACzG,MAAM,EAAE,MAAM,UAAU,eAAe;KACvC,OAAO,OAAO,YAAY;MAAE;MACxC;MACA;KAAW,CAAC;IACJ;IAEA,MAAM,WAA0C,OAA+C;KAC3F,OAAO,OAAO,WAAW;MACrB,MAAM,MAAM;MACZ,QAAQ,MAAM;MACd,UAAU,MAAM;MAChB,gBAAgB,MAAM;MACtB,QAAQ,MAAM;KA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5C;KACA,aAAa,MAA6B;MACtC,OAAO,OAAO,aAAa,IAAI;KACnC;KACA,eAAsC;MAClC,OAAO,OAAO,aAAa;KAC/B;IACJ;GACJ;EACA,GAAG,CAAC,MAAM,CAAC;CAEf"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/client-postgresql",
3
3
  "type": "module",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "description": "PostgreSQL data source client for Rebase",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/rebaseco"
@@ -32,6 +32,7 @@
32
32
  "transform": {
33
33
  "^.+\\.tsx?$": "ts-jest"
34
34
  },
35
+ "testEnvironment": "jsdom",
35
36
  "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
36
37
  "moduleFileExtensions": [
37
38
  "ts",
@@ -57,22 +58,23 @@
57
58
  "./package.json": "./package.json"
58
59
  },
59
60
  "dependencies": {
60
- "@rebasepro/client": "0.5.0",
61
- "@rebasepro/types": "0.5.0"
61
+ "@rebasepro/client": "0.6.1",
62
+ "@rebasepro/types": "0.6.1"
62
63
  },
63
64
  "peerDependencies": {
64
65
  "react": ">=19.0.0",
65
66
  "react-dom": ">=19.0.0"
66
67
  },
67
68
  "devDependencies": {
68
- "@types/jest": "^29.5.14",
69
- "@types/react": "^19.2.15",
69
+ "@types/jest": "^30.0.0",
70
+ "@types/react": "^19.2.17",
70
71
  "@types/react-dom": "^19.2.3",
71
- "@vitejs/plugin-react": "^4.7.0",
72
- "jest": "^29.7.0",
73
- "ts-jest": "^29.4.10",
74
- "typescript": "^5.9.3",
75
- "vite": "^5.4.21"
72
+ "@vitejs/plugin-react": "^6.0.2",
73
+ "jest": "^30.4.2",
74
+ "jest-environment-jsdom": "^30.4.1",
75
+ "ts-jest": "^29.4.11",
76
+ "typescript": "^6.0.3",
77
+ "vite": "^8.0.16"
76
78
  },
77
79
  "gitHead": "d935eefa5aa8d1009a2398cfac2c1e4ee9aeb6b6",
78
80
  "publishConfig": {
@@ -0,0 +1,101 @@
1
+ import React from "react";
2
+ import { renderHook } from "@testing-library/react";
3
+ import { usePostgresClientDriver } from "../src/usePostgresClientDriver";
4
+
5
+ describe("usePostgresClientDriver hook", () => {
6
+ let mockWsClient: any;
7
+
8
+ beforeEach(() => {
9
+ mockWsClient = {
10
+ fetchCollection: jest.fn().mockResolvedValue([{ id: "1",
11
+ name: "Entity 1" }]),
12
+ fetchEntity: jest.fn().mockResolvedValue({ id: "1",
13
+ name: "Entity 1" }),
14
+ saveEntity: jest.fn().mockResolvedValue({ id: "1",
15
+ name: "Saved Entity" }),
16
+ deleteEntity: jest.fn().mockResolvedValue(undefined),
17
+ checkUniqueField: jest.fn().mockResolvedValue(true),
18
+ countEntities: jest.fn().mockResolvedValue(42),
19
+ listenCollection: jest.fn(() => jest.fn()),
20
+ listenEntity: jest.fn(() => jest.fn()),
21
+ executeSql: jest.fn().mockResolvedValue([]),
22
+ fetchAvailableDatabases: jest.fn().mockResolvedValue(["db1"]),
23
+ fetchAvailableRoles: jest.fn().mockResolvedValue(["role1"]),
24
+ fetchCurrentDatabase: jest.fn().mockResolvedValue("db1"),
25
+ fetchUnmappedTables: jest.fn().mockResolvedValue([]),
26
+ fetchTableMetadata: jest.fn().mockResolvedValue({}),
27
+ createBranch: jest.fn().mockResolvedValue({ name: "branch1" }),
28
+ deleteBranch: jest.fn().mockResolvedValue(undefined),
29
+ listBranches: jest.fn().mockResolvedValue([])
30
+ };
31
+ });
32
+
33
+ it("throws error if wsClient is not provided", () => {
34
+ expect(() => {
35
+ renderHook(() => usePostgresClientDriver({} as any));
36
+ }).toThrow("RebaseWebSocketClient must be provided in config.wsClient");
37
+ });
38
+
39
+ it("returns active database driver object", () => {
40
+ const { result } = renderHook(() => usePostgresClientDriver({ wsClient: mockWsClient }));
41
+
42
+ expect(result.current.key).toBe("postgres");
43
+ expect(result.current.name).toBe("PostgreSQL");
44
+ expect(result.current.client).toBe(mockWsClient);
45
+ });
46
+
47
+ it("correctly routes fetchCollection, fetchEntity, saveEntity, deleteEntity", async () => {
48
+ const { result } = renderHook(() => usePostgresClientDriver({ wsClient: mockWsClient }));
49
+ const driver = result.current;
50
+
51
+ // fetchCollection
52
+ const list = await driver.fetchCollection({ path: "posts" });
53
+ expect(mockWsClient.fetchCollection).toHaveBeenCalledWith({ path: "posts" });
54
+ expect(list).toEqual([{ id: "1",
55
+ name: "Entity 1" }]);
56
+
57
+ // fetchEntity
58
+ const item = await driver.fetchEntity({ path: "posts",
59
+ entityId: "1" });
60
+ expect(mockWsClient.fetchEntity).toHaveBeenCalledWith({ path: "posts",
61
+ entityId: "1" });
62
+ expect(item).toEqual({ id: "1",
63
+ name: "Entity 1" });
64
+
65
+ // saveEntity
66
+ const saved = await driver.saveEntity({ path: "posts",
67
+ values: { name: "Test" } });
68
+ expect(mockWsClient.saveEntity).toHaveBeenCalledWith({
69
+ path: "posts",
70
+ values: { name: "Test" },
71
+ entityId: undefined,
72
+ previousValues: undefined,
73
+ status: undefined
74
+ });
75
+ expect(saved).toEqual({ id: "1",
76
+ name: "Saved Entity" });
77
+
78
+ // deleteEntity
79
+ await driver.deleteEntity({ entity: { id: "1",
80
+ name: "Test" } });
81
+ expect(mockWsClient.deleteEntity).toHaveBeenCalledWith({ entity: { id: "1",
82
+ name: "Test" } });
83
+ });
84
+
85
+ it("correctly routes admin database branching operations", async () => {
86
+ const { result } = renderHook(() => usePostgresClientDriver({ wsClient: mockWsClient }));
87
+ const driver = result.current;
88
+
89
+ // createBranch
90
+ await driver.admin.createBranch("branch_test");
91
+ expect(mockWsClient.createBranch).toHaveBeenCalledWith("branch_test", undefined);
92
+
93
+ // deleteBranch
94
+ await driver.admin.deleteBranch("branch_test");
95
+ expect(mockWsClient.deleteBranch).toHaveBeenCalledWith("branch_test");
96
+
97
+ // listBranches
98
+ await driver.admin.listBranches();
99
+ expect(mockWsClient.listBranches).toHaveBeenCalled();
100
+ });
101
+ });
package/tsconfig.json CHANGED
@@ -1,5 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
+ "rootDir": ".",
4
+ "ignoreDeprecations": "6.0",
3
5
  "outDir": "dist",
4
6
  "module": "ESNEXT",
5
7
  "target": "ESNEXT",
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "extends": "./tsconfig.json",
3
3
  "compilerOptions": {
4
+ "ignoreDeprecations": "6.0",
5
+ "rootDir": "./src",
4
6
  "noEmit": false,
5
7
  "declaration": true,
6
8
  "emitDeclarationOnly": true,
7
- "declarationDir": "dist"
9
+ "declarationDir": "dist",
10
+ "paths": {}
8
11
  },
9
12
  "include": [
10
13
  "src/**/*"
package/vite.config.ts CHANGED
@@ -1,4 +1,3 @@
1
- // @ts-ignore
2
1
  import path from "path";
3
2
 
4
3
  import { defineConfig } from "vite";
@@ -29,6 +28,11 @@ export default defineConfig(() => ({
29
28
  sourcemap: true,
30
29
  rollupOptions: {
31
30
  external: isExternal,
31
+ onwarn(warning, warn) {
32
+ if (warning.code === "MISSING_GLOBAL_NAME") return;
33
+ if (warning.code === "INEFFECTIVE_DYNAMIC_IMPORT") return;
34
+ warn(warning);
35
+ },
32
36
  output: {
33
37
  globals: {
34
38
  "json-logic-js": "jsonLogic",
@@ -1,61 +0,0 @@
1
- import type { Transport } from "./transport";
2
- export interface AdminUser {
3
- uid: string;
4
- email: string;
5
- displayName: string | null;
6
- photoURL: string | null;
7
- provider: string;
8
- roles: string[];
9
- createdAt: string;
10
- updatedAt: string;
11
- }
12
- export interface CreateAdminOptions {
13
- adminPath?: string;
14
- }
15
- export declare function createAdmin(transport: Transport, options?: CreateAdminOptions): {
16
- listUsers: () => Promise<{
17
- users: AdminUser[];
18
- }>;
19
- listUsersPaginated: (options?: {
20
- search?: string;
21
- limit?: number;
22
- offset?: number;
23
- orderBy?: string;
24
- orderDir?: "asc" | "desc";
25
- }) => Promise<{
26
- users: AdminUser[];
27
- total: number;
28
- limit: number;
29
- offset: number;
30
- }>;
31
- getUser: (userId: string) => Promise<{
32
- user: AdminUser;
33
- }>;
34
- createUser: (data: {
35
- email: string;
36
- displayName?: string;
37
- password?: string;
38
- roles?: string[];
39
- }) => Promise<{
40
- user: AdminUser;
41
- }>;
42
- updateUser: (userId: string, data: {
43
- email?: string;
44
- displayName?: string;
45
- password?: string;
46
- roles?: string[];
47
- }) => Promise<{
48
- user: AdminUser;
49
- }>;
50
- deleteUser: (userId: string) => Promise<{
51
- success: boolean;
52
- }>;
53
- bootstrap: () => Promise<{
54
- success: boolean;
55
- message: string;
56
- user: {
57
- uid: string;
58
- roles: string[];
59
- };
60
- }>;
61
- };
@@ -1,178 +0,0 @@
1
- import { Transport } from "./transport";
2
- export interface RebaseUser {
3
- uid: string;
4
- email: string | null;
5
- displayName: string | null;
6
- photoURL: string | null;
7
- emailVerified?: boolean;
8
- roles?: string[];
9
- providerId: string;
10
- isAnonymous: boolean;
11
- }
12
- export interface RebaseTokens {
13
- accessToken: string;
14
- refreshToken: string;
15
- accessTokenExpiresAt: number;
16
- }
17
- export interface RebaseSession {
18
- accessToken: string;
19
- refreshToken: string;
20
- expiresAt: number;
21
- user: RebaseUser;
22
- }
23
- export type AuthChangeEvent = "SIGNED_IN" | "SIGNED_OUT" | "TOKEN_REFRESHED" | "USER_UPDATED";
24
- export interface AuthConfig {
25
- needsSetup: boolean;
26
- registrationEnabled: boolean;
27
- emailServiceEnabled?: boolean;
28
- passwordReset?: boolean;
29
- emailVerification?: boolean;
30
- enabledProviders: string[];
31
- }
32
- export interface AuthStorage {
33
- getItem: (key: string) => string | null;
34
- setItem: (key: string, value: string) => void;
35
- removeItem: (key: string) => void;
36
- }
37
- export declare function createMemoryStorage(): AuthStorage;
38
- export interface CreateAuthOptions {
39
- storage?: AuthStorage;
40
- authPath?: string;
41
- autoRefresh?: boolean;
42
- persistSession?: boolean;
43
- }
44
- export declare function createAuth(transport: Transport, options?: CreateAuthOptions): {
45
- signInWithEmail: (email: string, password: string) => Promise<{
46
- user: RebaseUser;
47
- accessToken: string;
48
- refreshToken: string;
49
- }>;
50
- signUp: (email: string, password: string, displayName?: string) => Promise<{
51
- user: RebaseUser;
52
- accessToken: string;
53
- refreshToken: string;
54
- }>;
55
- signInWithGoogle: (payload: {
56
- idToken: string;
57
- } | {
58
- accessToken: string;
59
- } | {
60
- code: string;
61
- redirectUri: string;
62
- }) => Promise<{
63
- user: RebaseUser;
64
- accessToken: string;
65
- refreshToken: string;
66
- }>;
67
- signInWithLinkedin: (code: string, redirectUri: string) => Promise<{
68
- user: RebaseUser;
69
- accessToken: string;
70
- refreshToken: string;
71
- }>;
72
- signInWithOAuth: (providerId: string, payload: Record<string, unknown>) => Promise<{
73
- user: RebaseUser;
74
- accessToken: string;
75
- refreshToken: string;
76
- }>;
77
- signInWithGitHub: (code: string, redirectUri: string) => Promise<{
78
- user: RebaseUser;
79
- accessToken: string;
80
- refreshToken: string;
81
- }>;
82
- signInWithMicrosoft: (code: string, redirectUri: string) => Promise<{
83
- user: RebaseUser;
84
- accessToken: string;
85
- refreshToken: string;
86
- }>;
87
- signInWithApple: (code: string, redirectUri: string, user?: {
88
- name?: {
89
- firstName?: string;
90
- lastName?: string;
91
- };
92
- email?: string;
93
- }) => Promise<{
94
- user: RebaseUser;
95
- accessToken: string;
96
- refreshToken: string;
97
- }>;
98
- signInWithFacebook: (code: string, redirectUri: string) => Promise<{
99
- user: RebaseUser;
100
- accessToken: string;
101
- refreshToken: string;
102
- }>;
103
- signInWithTwitter: (code: string, redirectUri: string, codeVerifier: string) => Promise<{
104
- user: RebaseUser;
105
- accessToken: string;
106
- refreshToken: string;
107
- }>;
108
- signInWithDiscord: (code: string, redirectUri: string) => Promise<{
109
- user: RebaseUser;
110
- accessToken: string;
111
- refreshToken: string;
112
- }>;
113
- signInWithGitLab: (code: string, redirectUri: string) => Promise<{
114
- user: RebaseUser;
115
- accessToken: string;
116
- refreshToken: string;
117
- }>;
118
- signInWithBitbucket: (code: string, redirectUri: string) => Promise<{
119
- user: RebaseUser;
120
- accessToken: string;
121
- refreshToken: string;
122
- }>;
123
- signInWithSlack: (code: string, redirectUri: string) => Promise<{
124
- user: RebaseUser;
125
- accessToken: string;
126
- refreshToken: string;
127
- }>;
128
- signInWithSpotify: (code: string, redirectUri: string) => Promise<{
129
- user: RebaseUser;
130
- accessToken: string;
131
- refreshToken: string;
132
- }>;
133
- signOut: () => Promise<void>;
134
- refreshSession: () => Promise<RebaseSession>;
135
- getUser: () => Promise<RebaseUser>;
136
- updateUser: (updates: {
137
- displayName?: string;
138
- photoURL?: string;
139
- }) => Promise<RebaseUser>;
140
- resetPasswordForEmail: (email: string) => Promise<{
141
- success: boolean;
142
- message: string;
143
- }>;
144
- resetPassword: (token: string, password: string) => Promise<{
145
- success: boolean;
146
- message: string;
147
- }>;
148
- changePassword: (oldPassword: string, newPassword: string) => Promise<{
149
- success: boolean;
150
- message: string;
151
- }>;
152
- sendVerificationEmail: () => Promise<{
153
- success: boolean;
154
- message: string;
155
- }>;
156
- verifyEmail: (token: string) => Promise<{
157
- success: boolean;
158
- message: string;
159
- }>;
160
- getSessions: () => Promise<Record<string, unknown>[]>;
161
- revokeSession: (sessionId: string) => Promise<{
162
- success: boolean;
163
- }>;
164
- revokeAllSessions: () => Promise<{
165
- success: boolean;
166
- }>;
167
- getAuthConfig: () => Promise<AuthConfig>;
168
- getSession: () => RebaseSession | null;
169
- onAuthStateChange: (callback: (event: AuthChangeEvent, session: RebaseSession | null) => void) => () => boolean;
170
- };
171
- export interface CookieStorageOptions {
172
- path?: string;
173
- domain?: string;
174
- secure?: boolean;
175
- sameSite?: "Lax" | "Strict" | "None";
176
- maxAge?: number;
177
- }
178
- export declare function createCookieStorage(options?: CookieStorageOptions): AuthStorage;
@@ -1,21 +0,0 @@
1
- import { FindParams, Transport } from "./transport";
2
- import { RebaseWebSocketClient } from "./websocket";
3
- import { CollectionAccessor, FilterOperator, LogicalCondition, WhereValue } from "@rebasepro/types";
4
- import { QueryBuilder } from "./query_builder";
5
- /**
6
- * CollectionClient extends `CollectionAccessor` from `@rebasepro/types` so that
7
- * `client.data` can be passed directly to the core Rebase component.
8
- *
9
- * Additionally it exposes fluent query builder methods like `.where()`, `.orderBy()`.
10
- */
11
- export interface CollectionClient<M extends Record<string, unknown> = Record<string, unknown>> extends CollectionAccessor<M> {
12
- where<K extends keyof M & string>(column: K, operator: FilterOperator, value: WhereValue<M[K]>): QueryBuilder<M>;
13
- where(logicalCondition: LogicalCondition): QueryBuilder<M>;
14
- orderBy(column: keyof M & string, ascending?: "asc" | "desc"): QueryBuilder<M>;
15
- limit(count: number): QueryBuilder<M>;
16
- offset(count: number): QueryBuilder<M>;
17
- search(searchString: string): QueryBuilder<M>;
18
- include(...relations: string[]): QueryBuilder<M>;
19
- count(params?: FindParams): Promise<number>;
20
- }
21
- export declare function createCollectionClient<M extends Record<string, unknown> = Record<string, unknown>>(transport: Transport, slug: string, ws?: RebaseWebSocketClient): CollectionClient<M>;
@@ -1,25 +0,0 @@
1
- import { Transport } from "./transport";
2
- import type { CronJobStatus, CronJobLogEntry } from "@rebasepro/types";
3
- export interface CreateCronOptions {
4
- cronPath?: string;
5
- }
6
- export declare function createCron(transport: Transport, options?: CreateCronOptions): {
7
- listJobs: () => Promise<{
8
- jobs: CronJobStatus[];
9
- }>;
10
- getJob: (jobId: string) => Promise<{
11
- job: CronJobStatus;
12
- }>;
13
- triggerJob: (jobId: string) => Promise<{
14
- log: CronJobLogEntry;
15
- job: CronJobStatus;
16
- }>;
17
- getJobLogs: (jobId: string, options?: {
18
- limit?: number;
19
- }) => Promise<{
20
- logs: CronJobLogEntry[];
21
- }>;
22
- toggleJob: (jobId: string, enabled: boolean) => Promise<{
23
- job: CronJobStatus;
24
- }>;
25
- };
@@ -1,49 +0,0 @@
1
- import type { Transport } from "./transport";
2
- /**
3
- * Client interface for invoking custom backend functions.
4
- *
5
- * Custom functions are Hono route files auto-mounted by the Rebase backend
6
- * at `/api/functions/{name}`. The `FunctionsClient` wraps the shared
7
- * transport so callers never need to manually construct URLs or inject
8
- * auth tokens.
9
- *
10
- * @example
11
- * ```ts
12
- * const result = await client.functions.invoke<{ job: Job }>('extract-job', {
13
- * url: 'https://example.com/posting',
14
- * html: htmlContent,
15
- * });
16
- * ```
17
- */
18
- export interface FunctionsClient {
19
- /**
20
- * Invoke a custom backend function by name.
21
- *
22
- * @typeParam T - Expected shape of the response payload.
23
- * @param name - Function name (the filename without extension, e.g. `"extract-job"`).
24
- * @param payload - Optional JSON-serialisable body sent as `POST`.
25
- * @param options - Optional overrides (HTTP method, sub-path, extra headers).
26
- * @returns The parsed JSON response from the function.
27
- */
28
- invoke<T = unknown>(name: string, payload?: unknown, options?: FunctionInvokeOptions): Promise<T>;
29
- }
30
- export interface FunctionInvokeOptions {
31
- /** HTTP method — defaults to `"POST"`. */
32
- method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
33
- /** Sub-path appended after the function name, e.g. `"status/123"`. */
34
- path?: string;
35
- /** Extra headers merged into the request (auth is still injected automatically). */
36
- headers?: Record<string, string>;
37
- }
38
- /**
39
- * Create a `FunctionsClient` backed by the given transport.
40
- *
41
- * The transport already handles:
42
- * - Base URL resolution
43
- * - JWT injection via `Authorization: Bearer`
44
- * - 401 retry / `onUnauthorized` flow
45
- * - Consistent error throwing via `RebaseApiError`
46
- *
47
- * @internal
48
- */
49
- export declare function createFunctionsClient(transport: Transport): FunctionsClient;
@@ -1,48 +0,0 @@
1
- import { RebaseClientConfig } from "./transport";
2
- import { createAuth, CreateAuthOptions } from "./auth";
3
- import { createAdmin, CreateAdminOptions } from "./admin";
4
- import { createCron, CreateCronOptions } from "./cron";
5
- import { CollectionClient } from "./collection";
6
- import type { FunctionsClient } from "./functions";
7
- export * from "./transport";
8
- export * from "./auth";
9
- export * from "./admin";
10
- export * from "./cron";
11
- export * from "./collection";
12
- export * from "./query_builder";
13
- export * from "./websocket";
14
- export * from "./storage";
15
- export * from "./reviver";
16
- export * from "./functions";
17
- export interface CreateRebaseClientOptions extends RebaseClientConfig {
18
- auth?: CreateAuthOptions;
19
- admin?: CreateAdminOptions;
20
- cron?: CreateCronOptions;
21
- }
22
- import { RebaseWebSocketClient } from "./websocket";
23
- import { RebaseClient as BaseRebaseClient, RebaseData, StorageSource } from "@rebasepro/types";
24
- export type { Entity, FindResponse } from "@rebasepro/types";
25
- type KebabToCamelCase<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamelCase<U>>}` : S;
26
- export type RebaseClient<DB = Record<string, unknown>> = Omit<BaseRebaseClient<DB>, "data"> & {
27
- setToken: (token: string | null) => void;
28
- setAuthTokenGetter: (getter: () => Promise<string | null>) => void;
29
- setOnUnauthorized: (handler: () => Promise<boolean>) => void;
30
- resolveToken: () => Promise<string | null>;
31
- auth: ReturnType<typeof createAuth>;
32
- admin: ReturnType<typeof createAdmin>;
33
- cron: ReturnType<typeof createCron>;
34
- functions: FunctionsClient;
35
- ws?: RebaseWebSocketClient;
36
- storage?: StorageSource;
37
- call: <T = unknown>(endpoint: string, payload?: unknown) => Promise<T>;
38
- data: {
39
- collection<S extends string>(slug: S): CollectionClient<KebabToCamelCase<S> extends keyof DB ? (DB[KebabToCamelCase<S>] extends {
40
- Row: infer R extends Record<string, unknown>;
41
- } ? R : Record<string, unknown>) : Record<string, unknown>>;
42
- } & {
43
- [K in keyof DB]: CollectionClient<DB[K] extends {
44
- Row: infer R extends Record<string, unknown>;
45
- } ? R : Record<string, unknown>>;
46
- } & RebaseData;
47
- };
48
- export declare function createRebaseClient<DB = Record<string, unknown>>(options: CreateRebaseClientOptions): RebaseClient<DB>;
@@ -1 +0,0 @@
1
- export { QueryBuilder, or, and, cond } from "@rebasepro/common";
@@ -1 +0,0 @@
1
- export declare function rebaseReviver(_key: string, value: unknown): unknown;
@@ -1,3 +0,0 @@
1
- import { StorageSource } from "@rebasepro/types";
2
- import { Transport } from "./transport";
3
- export declare function createStorage(transport: Transport): StorageSource;