@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.
- package/dist/index.es.js +117 -163
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +121 -166
- package/dist/index.umd.js.map +1 -1
- package/package.json +12 -10
- package/test/usePostgresClientDriver.test.tsx +101 -0
- package/tsconfig.json +2 -0
- package/tsconfig.prod.json +4 -1
- package/vite.config.ts +5 -1
- package/dist/client/src/admin.d.ts +0 -61
- package/dist/client/src/auth.d.ts +0 -178
- package/dist/client/src/collection.d.ts +0 -21
- package/dist/client/src/cron.d.ts +0 -25
- package/dist/client/src/functions.d.ts +0 -49
- package/dist/client/src/index.d.ts +0 -48
- package/dist/client/src/query_builder.d.ts +0 -1
- package/dist/client/src/reviver.d.ts +0 -1
- package/dist/client/src/storage.d.ts +0 -3
- package/dist/client/src/transport.d.ts +0 -33
- package/dist/client/src/websocket.d.ts +0 -105
- package/dist/types/src/controllers/analytics_controller.d.ts +0 -7
- package/dist/types/src/controllers/auth.d.ts +0 -104
- package/dist/types/src/controllers/client.d.ts +0 -168
- package/dist/types/src/controllers/collection_registry.d.ts +0 -46
- package/dist/types/src/controllers/customization_controller.d.ts +0 -60
- package/dist/types/src/controllers/data.d.ts +0 -207
- package/dist/types/src/controllers/data_driver.d.ts +0 -218
- package/dist/types/src/controllers/database_admin.d.ts +0 -11
- package/dist/types/src/controllers/dialogs_controller.d.ts +0 -36
- package/dist/types/src/controllers/effective_role.d.ts +0 -4
- package/dist/types/src/controllers/email.d.ts +0 -36
- package/dist/types/src/controllers/index.d.ts +0 -18
- package/dist/types/src/controllers/local_config_persistence.d.ts +0 -20
- package/dist/types/src/controllers/navigation.d.ts +0 -225
- package/dist/types/src/controllers/registry.d.ts +0 -63
- package/dist/types/src/controllers/side_dialogs_controller.d.ts +0 -67
- package/dist/types/src/controllers/side_entity_controller.d.ts +0 -97
- package/dist/types/src/controllers/snackbar.d.ts +0 -24
- package/dist/types/src/controllers/storage.d.ts +0 -171
- package/dist/types/src/index.d.ts +0 -4
- package/dist/types/src/rebase_context.d.ts +0 -122
- package/dist/types/src/types/auth_adapter.d.ts +0 -301
- package/dist/types/src/types/backend.d.ts +0 -571
- package/dist/types/src/types/backend_hooks.d.ts +0 -172
- package/dist/types/src/types/builders.d.ts +0 -15
- package/dist/types/src/types/chips.d.ts +0 -5
- package/dist/types/src/types/collections.d.ts +0 -961
- package/dist/types/src/types/component_ref.d.ts +0 -47
- package/dist/types/src/types/cron.d.ts +0 -102
- package/dist/types/src/types/data_source.d.ts +0 -64
- package/dist/types/src/types/database_adapter.d.ts +0 -94
- package/dist/types/src/types/entities.d.ts +0 -145
- package/dist/types/src/types/entity_actions.d.ts +0 -104
- package/dist/types/src/types/entity_callbacks.d.ts +0 -173
- package/dist/types/src/types/entity_link_builder.d.ts +0 -7
- package/dist/types/src/types/entity_overrides.d.ts +0 -10
- package/dist/types/src/types/entity_views.d.ts +0 -87
- package/dist/types/src/types/export_import.d.ts +0 -21
- package/dist/types/src/types/formex.d.ts +0 -40
- package/dist/types/src/types/index.d.ts +0 -28
- package/dist/types/src/types/locales.d.ts +0 -4
- package/dist/types/src/types/modify_collections.d.ts +0 -5
- package/dist/types/src/types/plugins.d.ts +0 -282
- package/dist/types/src/types/properties.d.ts +0 -1173
- package/dist/types/src/types/property_config.d.ts +0 -74
- package/dist/types/src/types/relations.d.ts +0 -336
- package/dist/types/src/types/slots.d.ts +0 -262
- package/dist/types/src/types/translations.d.ts +0 -900
- package/dist/types/src/types/user_management_delegate.d.ts +0 -86
- package/dist/types/src/types/websockets.d.ts +0 -78
- package/dist/types/src/users/index.d.ts +0 -1
- package/dist/types/src/users/user.d.ts +0 -50
- /package/dist/{client-postgresql/src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{client-postgresql/src/usePostgresClientDriver.d.ts → usePostgresClientDriver.d.ts} +0 -0
package/dist/index.es.js
CHANGED
|
@@ -1,165 +1,119 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
//#region src/usePostgresClientDriver.ts
|
|
2
3
|
function usePostgresClientDriver(config) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
path: path_4,
|
|
115
|
-
entityId: entityId_1,
|
|
116
|
-
databaseId: databaseId_0
|
|
117
|
-
}, (entity_0) => {
|
|
118
|
-
props_5.onUpdate(entity_0);
|
|
119
|
-
}, props_5.onError);
|
|
120
|
-
},
|
|
121
|
-
isFilterCombinationValid() {
|
|
122
|
-
return true;
|
|
123
|
-
},
|
|
124
|
-
admin: {
|
|
125
|
-
executeSql(sql, options) {
|
|
126
|
-
return client.executeSql(sql, options);
|
|
127
|
-
},
|
|
128
|
-
fetchAvailableDatabases() {
|
|
129
|
-
return client.fetchAvailableDatabases();
|
|
130
|
-
},
|
|
131
|
-
fetchAvailableRoles() {
|
|
132
|
-
return client.fetchAvailableRoles();
|
|
133
|
-
},
|
|
134
|
-
fetchCurrentDatabase() {
|
|
135
|
-
return client.fetchCurrentDatabase();
|
|
136
|
-
},
|
|
137
|
-
fetchUnmappedTables(mappedPaths) {
|
|
138
|
-
return client.fetchUnmappedTables(mappedPaths);
|
|
139
|
-
},
|
|
140
|
-
fetchTableMetadata(tableName) {
|
|
141
|
-
return client.fetchTableMetadata(tableName);
|
|
142
|
-
},
|
|
143
|
-
createBranch(name_0, options_0) {
|
|
144
|
-
return client.createBranch(name_0, options_0);
|
|
145
|
-
},
|
|
146
|
-
deleteBranch(name_1) {
|
|
147
|
-
return client.deleteBranch(name_1);
|
|
148
|
-
},
|
|
149
|
-
listBranches() {
|
|
150
|
-
return client.listBranches();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
$[0] = client;
|
|
155
|
-
$[1] = t1;
|
|
156
|
-
} else {
|
|
157
|
-
t1 = $[1];
|
|
158
|
-
}
|
|
159
|
-
t0 = t1;
|
|
160
|
-
return t0;
|
|
4
|
+
const client = config.wsClient;
|
|
5
|
+
return useMemo(() => {
|
|
6
|
+
if (!client) throw new Error("RebaseWebSocketClient must be provided in config.wsClient");
|
|
7
|
+
return {
|
|
8
|
+
key: "postgres",
|
|
9
|
+
name: "PostgreSQL",
|
|
10
|
+
client,
|
|
11
|
+
async fetchCollection(props) {
|
|
12
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order } = props;
|
|
13
|
+
return client.fetchCollection({
|
|
14
|
+
path,
|
|
15
|
+
filter,
|
|
16
|
+
limit,
|
|
17
|
+
startAfter,
|
|
18
|
+
orderBy,
|
|
19
|
+
searchString,
|
|
20
|
+
order
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
async fetchEntity(props) {
|
|
24
|
+
const { path, entityId, databaseId } = props;
|
|
25
|
+
return client.fetchEntity({
|
|
26
|
+
path,
|
|
27
|
+
entityId,
|
|
28
|
+
databaseId
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
async saveEntity(props) {
|
|
32
|
+
return client.saveEntity({
|
|
33
|
+
path: props.path,
|
|
34
|
+
values: props.values,
|
|
35
|
+
entityId: props.entityId,
|
|
36
|
+
previousValues: props.previousValues,
|
|
37
|
+
status: props.status
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
async deleteEntity(props) {
|
|
41
|
+
const { entity } = props;
|
|
42
|
+
return client.deleteEntity({ entity });
|
|
43
|
+
},
|
|
44
|
+
async checkUniqueField(path, name, value, entityId, collection) {
|
|
45
|
+
return client.checkUniqueField(path, name, value, entityId, collection);
|
|
46
|
+
},
|
|
47
|
+
async countEntities(props) {
|
|
48
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order } = props;
|
|
49
|
+
return client.countEntities({
|
|
50
|
+
path,
|
|
51
|
+
filter,
|
|
52
|
+
limit,
|
|
53
|
+
startAfter,
|
|
54
|
+
orderBy,
|
|
55
|
+
searchString,
|
|
56
|
+
order
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
listenCollection(props) {
|
|
60
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order, onUpdate, onError } = props;
|
|
61
|
+
return client.listenCollection({
|
|
62
|
+
path,
|
|
63
|
+
filter,
|
|
64
|
+
limit,
|
|
65
|
+
startAfter,
|
|
66
|
+
orderBy,
|
|
67
|
+
searchString,
|
|
68
|
+
order
|
|
69
|
+
}, (entities) => props.onUpdate(entities), props.onError);
|
|
70
|
+
},
|
|
71
|
+
listenEntity(props) {
|
|
72
|
+
const { path, entityId, databaseId, onUpdate, onError } = props;
|
|
73
|
+
return client.listenEntity({
|
|
74
|
+
path,
|
|
75
|
+
entityId,
|
|
76
|
+
databaseId
|
|
77
|
+
}, (entity) => {
|
|
78
|
+
props.onUpdate(entity);
|
|
79
|
+
}, props.onError);
|
|
80
|
+
},
|
|
81
|
+
isFilterCombinationValid() {
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
84
|
+
admin: {
|
|
85
|
+
executeSql(sql, options) {
|
|
86
|
+
return client.executeSql(sql, options);
|
|
87
|
+
},
|
|
88
|
+
fetchAvailableDatabases() {
|
|
89
|
+
return client.fetchAvailableDatabases();
|
|
90
|
+
},
|
|
91
|
+
fetchAvailableRoles() {
|
|
92
|
+
return client.fetchAvailableRoles();
|
|
93
|
+
},
|
|
94
|
+
fetchCurrentDatabase() {
|
|
95
|
+
return client.fetchCurrentDatabase();
|
|
96
|
+
},
|
|
97
|
+
fetchUnmappedTables(mappedPaths) {
|
|
98
|
+
return client.fetchUnmappedTables(mappedPaths);
|
|
99
|
+
},
|
|
100
|
+
fetchTableMetadata(tableName) {
|
|
101
|
+
return client.fetchTableMetadata(tableName);
|
|
102
|
+
},
|
|
103
|
+
createBranch(name, options) {
|
|
104
|
+
return client.createBranch(name, options);
|
|
105
|
+
},
|
|
106
|
+
deleteBranch(name) {
|
|
107
|
+
return client.deleteBranch(name);
|
|
108
|
+
},
|
|
109
|
+
listBranches() {
|
|
110
|
+
return client.listBranches();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}, [client]);
|
|
161
115
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
//# sourceMappingURL=index.es.js.map
|
|
116
|
+
//#endregion
|
|
117
|
+
export { usePostgresClientDriver };
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.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"],"
|
|
1
|
+
{"version":3,"file":"index.es.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":";;AAyBA,SAAgB,wBAAwB,QAAsD;CAC1F,MAAM,SAAS,OAAO;CAEtB,OAAO,cAAc;EACjB,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,2DAA2D;EAExF,OAAO;GAEP,KAAK;GAEL,MAAM;GAEN;GAEA,MAAM,gBAA+C,OAAsD;IAEvG,MAAM,EAAE,MAAM,QAAQ,OAAO,YAAY,SAAS,cAAc,UAAU;IAC1E,OAAO,OAAO,gBAAgB;KAAE;KAC5C;KACA;KACA;KACA;KACA;KACA;IAAM,CAAC;GACC;GAEA,MAAM,YAA2C,OAA4D;IACzG,MAAM,EAAE,MAAM,UAAU,eAAe;IACvC,OAAO,OAAO,YAAY;KAAE;KACxC;KACA;IAAW,CAAC;GACJ;GAEA,MAAM,WAA0C,OAA+C;IAC3F,OAAO,OAAO,WAAW;KACrB,MAAM,MAAM;KACZ,QAAQ,MAAM;KACd,UAAU,MAAM;KAChB,gBAAgB,MAAM;KACtB,QAAQ,MAAM;IAClB,CAAC;GACL;GAEA,MAAM,aAA4C,OAA4C;IAC1F,MAAM,EAAE,WAAW;IACnB,OAAO,OAAO,aAAa,EAAE,OAAO,CAAC;GACzC;GAEA,MAAM,iBAAiB,MAAc,MAAc,OAAgB,UAAmB,YAAiD;IACnI,OAAO,OAAO,iBAAiB,MAAM,MAAM,OAAO,UAAU,UAAU;GAC1E;GAEA,MAAM,cAA6C,OAAiD;IAChG,MAAM,EAAE,MAAM,QAAQ,OAAO,YAAY,SAAS,cAAc,UAAU;IAC1E,OAAO,OAAO,cAAc;KAAE;KAC1C;KACA;KACA;KACA;KACA;KACA;IAAM,CAAC;GACC;GAEA,iBAAgD,OAA6C;IACzF,MAAM,EAAE,MAAM,QAAQ,OAAO,YAAY,SAAS,cAAc,OAAO,UAAU,YAAY;IAC7F,OAAO,OAAO,iBACV;KAAE;KAClB;KACA;KACA;KACA;KACA;KACA;IAAM,IACW,aAAuB,MAAM,SAAS,QAAuB,GAC9D,MAAM,OACV;GACJ;GAEA,aAA4C,OAAyC;IACjF,MAAM,EAAE,MAAM,UAAU,YAAY,UAAU,YAAY;IAC1D,OAAO,OAAO,aACV;KAAE;KAClB;KACA;IAAW,IACM,WAA0B;KACvB,MAAM,SAAS,MAA0B;IAC7C,GACA,MAAM,OACV;GACJ;GAEA,2BAAoC;IAChC,OAAO;GACX;GAEA,OAAO;IACH,WAAW,KAAa,SAAoF;KACxG,OAAO,OAAO,WAAW,KAAK,OAAO;IACzC;IACA,0BAA6C;KACzC,OAAO,OAAO,wBAAwB;IAC1C;IACA,sBAAyC;KACrC,OAAO,OAAO,oBAAoB;IACtC;IACA,uBAAoD;KAChD,OAAO,OAAO,qBAAqB;IACvC;IACA,oBAAoB,aAA2C;KAC3D,OAAO,OAAO,oBAAoB,WAAW;IACjD;IACA,mBAAmB,WAAqC;KACpD,OAAO,OAAO,mBAAmB,SAAS;IAC9C;IACA,aAAa,MAAc,SAAoD;KAC3E,OAAO,OAAO,aAAa,MAAM,OAAO;IAC5C;IACA,aAAa,MAA6B;KACtC,OAAO,OAAO,aAAa,IAAI;IACnC;IACA,eAAsC;KAClC,OAAO,OAAO,aAAa;IAC/B;GACJ;EACJ;CACA,GAAG,CAAC,MAAM,CAAC;AAEf"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,168 +1,123 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
|
|
3
|
-
})(this, function(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
props_5.onUpdate(entity_0);
|
|
122
|
-
}, props_5.onError);
|
|
123
|
-
},
|
|
124
|
-
isFilterCombinationValid() {
|
|
125
|
-
return true;
|
|
126
|
-
},
|
|
127
|
-
admin: {
|
|
128
|
-
executeSql(sql, options) {
|
|
129
|
-
return client.executeSql(sql, options);
|
|
130
|
-
},
|
|
131
|
-
fetchAvailableDatabases() {
|
|
132
|
-
return client.fetchAvailableDatabases();
|
|
133
|
-
},
|
|
134
|
-
fetchAvailableRoles() {
|
|
135
|
-
return client.fetchAvailableRoles();
|
|
136
|
-
},
|
|
137
|
-
fetchCurrentDatabase() {
|
|
138
|
-
return client.fetchCurrentDatabase();
|
|
139
|
-
},
|
|
140
|
-
fetchUnmappedTables(mappedPaths) {
|
|
141
|
-
return client.fetchUnmappedTables(mappedPaths);
|
|
142
|
-
},
|
|
143
|
-
fetchTableMetadata(tableName) {
|
|
144
|
-
return client.fetchTableMetadata(tableName);
|
|
145
|
-
},
|
|
146
|
-
createBranch(name_0, options_0) {
|
|
147
|
-
return client.createBranch(name_0, options_0);
|
|
148
|
-
},
|
|
149
|
-
deleteBranch(name_1) {
|
|
150
|
-
return client.deleteBranch(name_1);
|
|
151
|
-
},
|
|
152
|
-
listBranches() {
|
|
153
|
-
return client.listBranches();
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
$[0] = client;
|
|
158
|
-
$[1] = t1;
|
|
159
|
-
} else {
|
|
160
|
-
t1 = $[1];
|
|
161
|
-
}
|
|
162
|
-
t0 = t1;
|
|
163
|
-
return t0;
|
|
164
|
-
}
|
|
165
|
-
exports2.usePostgresClientDriver = usePostgresClientDriver;
|
|
166
|
-
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["Rebase PostgreSQL"] = {}, global.react));
|
|
3
|
+
})(this, function(exports, react) {
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
5
|
+
//#region src/usePostgresClientDriver.ts
|
|
6
|
+
function usePostgresClientDriver(config) {
|
|
7
|
+
const client = config.wsClient;
|
|
8
|
+
return (0, react.useMemo)(() => {
|
|
9
|
+
if (!client) throw new Error("RebaseWebSocketClient must be provided in config.wsClient");
|
|
10
|
+
return {
|
|
11
|
+
key: "postgres",
|
|
12
|
+
name: "PostgreSQL",
|
|
13
|
+
client,
|
|
14
|
+
async fetchCollection(props) {
|
|
15
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order } = props;
|
|
16
|
+
return client.fetchCollection({
|
|
17
|
+
path,
|
|
18
|
+
filter,
|
|
19
|
+
limit,
|
|
20
|
+
startAfter,
|
|
21
|
+
orderBy,
|
|
22
|
+
searchString,
|
|
23
|
+
order
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
async fetchEntity(props) {
|
|
27
|
+
const { path, entityId, databaseId } = props;
|
|
28
|
+
return client.fetchEntity({
|
|
29
|
+
path,
|
|
30
|
+
entityId,
|
|
31
|
+
databaseId
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
async saveEntity(props) {
|
|
35
|
+
return client.saveEntity({
|
|
36
|
+
path: props.path,
|
|
37
|
+
values: props.values,
|
|
38
|
+
entityId: props.entityId,
|
|
39
|
+
previousValues: props.previousValues,
|
|
40
|
+
status: props.status
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
async deleteEntity(props) {
|
|
44
|
+
const { entity } = props;
|
|
45
|
+
return client.deleteEntity({ entity });
|
|
46
|
+
},
|
|
47
|
+
async checkUniqueField(path, name, value, entityId, collection) {
|
|
48
|
+
return client.checkUniqueField(path, name, value, entityId, collection);
|
|
49
|
+
},
|
|
50
|
+
async countEntities(props) {
|
|
51
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order } = props;
|
|
52
|
+
return client.countEntities({
|
|
53
|
+
path,
|
|
54
|
+
filter,
|
|
55
|
+
limit,
|
|
56
|
+
startAfter,
|
|
57
|
+
orderBy,
|
|
58
|
+
searchString,
|
|
59
|
+
order
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
listenCollection(props) {
|
|
63
|
+
const { path, filter, limit, startAfter, orderBy, searchString, order, onUpdate, onError } = props;
|
|
64
|
+
return client.listenCollection({
|
|
65
|
+
path,
|
|
66
|
+
filter,
|
|
67
|
+
limit,
|
|
68
|
+
startAfter,
|
|
69
|
+
orderBy,
|
|
70
|
+
searchString,
|
|
71
|
+
order
|
|
72
|
+
}, (entities) => props.onUpdate(entities), props.onError);
|
|
73
|
+
},
|
|
74
|
+
listenEntity(props) {
|
|
75
|
+
const { path, entityId, databaseId, onUpdate, onError } = props;
|
|
76
|
+
return client.listenEntity({
|
|
77
|
+
path,
|
|
78
|
+
entityId,
|
|
79
|
+
databaseId
|
|
80
|
+
}, (entity) => {
|
|
81
|
+
props.onUpdate(entity);
|
|
82
|
+
}, props.onError);
|
|
83
|
+
},
|
|
84
|
+
isFilterCombinationValid() {
|
|
85
|
+
return true;
|
|
86
|
+
},
|
|
87
|
+
admin: {
|
|
88
|
+
executeSql(sql, options) {
|
|
89
|
+
return client.executeSql(sql, options);
|
|
90
|
+
},
|
|
91
|
+
fetchAvailableDatabases() {
|
|
92
|
+
return client.fetchAvailableDatabases();
|
|
93
|
+
},
|
|
94
|
+
fetchAvailableRoles() {
|
|
95
|
+
return client.fetchAvailableRoles();
|
|
96
|
+
},
|
|
97
|
+
fetchCurrentDatabase() {
|
|
98
|
+
return client.fetchCurrentDatabase();
|
|
99
|
+
},
|
|
100
|
+
fetchUnmappedTables(mappedPaths) {
|
|
101
|
+
return client.fetchUnmappedTables(mappedPaths);
|
|
102
|
+
},
|
|
103
|
+
fetchTableMetadata(tableName) {
|
|
104
|
+
return client.fetchTableMetadata(tableName);
|
|
105
|
+
},
|
|
106
|
+
createBranch(name, options) {
|
|
107
|
+
return client.createBranch(name, options);
|
|
108
|
+
},
|
|
109
|
+
deleteBranch(name) {
|
|
110
|
+
return client.deleteBranch(name);
|
|
111
|
+
},
|
|
112
|
+
listBranches() {
|
|
113
|
+
return client.listBranches();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}, [client]);
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
exports.usePostgresClientDriver = usePostgresClientDriver;
|
|
167
121
|
});
|
|
168
|
-
|
|
122
|
+
|
|
123
|
+
//# sourceMappingURL=index.umd.js.map
|