prostgles-client 4.0.178 → 4.0.180
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/getDbHandler.d.ts +1 -1
- package/dist/getDbHandler.d.ts.map +1 -1
- package/dist/getDbHandler.js +70 -21
- package/dist/prostgles.d.ts +45 -7
- package/dist/prostgles.d.ts.map +1 -1
- package/dist/prostgles.js +6 -5
- package/package.json +2 -2
package/dist/getDbHandler.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type Args = {
|
|
|
12
12
|
syncHandler: ReturnType<typeof getSyncHandler>;
|
|
13
13
|
subscriptionHandler: ReturnType<typeof getSubscriptionHandler>;
|
|
14
14
|
};
|
|
15
|
-
export declare const getDBO: ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler, socket, joinTables }: Args) => {
|
|
15
|
+
export declare const getDBO: ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler, socket, joinTables, }: Args) => {
|
|
16
16
|
dbo: Partial<DBHandlerClient>;
|
|
17
17
|
};
|
|
18
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDbHandler.d.ts","sourceRoot":"","sources":["../lib/getDbHandler.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getDbHandler.d.ts","sourceRoot":"","sources":["../lib/getDbHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EAIjB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,WAAW,EAGhB,KAAK,eAAe,EAIrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAQ,WAAW,EAAwB,MAAM,2BAA2B,CAAC;AACzF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAEvE,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IACvC,WAAW,EAAE,OAAO,WAAW,GAAG,SAAS,CAAC;IAC5C,WAAW,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;IAC/C,mBAAmB,EAAE,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC;CAChE,CAAC;AAIF,eAAO,MAAM,MAAM,4FAQhB,IAAI;;CAuNN,CAAC"}
|
package/dist/getDbHandler.js
CHANGED
|
@@ -4,32 +4,40 @@ exports.getDBO = void 0;
|
|
|
4
4
|
const prostgles_types_1 = require("prostgles-types");
|
|
5
5
|
const prostgles_1 = require("./prostgles");
|
|
6
6
|
const preffix = prostgles_types_1.CHANNELS._preffix;
|
|
7
|
-
const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler, socket, joinTables }) => {
|
|
7
|
+
const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler, socket, joinTables, }) => {
|
|
8
8
|
const dbo = JSON.parse(JSON.stringify(schema));
|
|
9
9
|
/* Building DBO object */
|
|
10
10
|
const checkSubscriptionArgs = (basicFilter, options, onChange, onError) => {
|
|
11
|
-
if (basicFilter !== undefined && !(0, prostgles_types_1.isObject)(basicFilter)
|
|
11
|
+
if ((basicFilter !== undefined && !(0, prostgles_types_1.isObject)(basicFilter)) ||
|
|
12
|
+
(options !== undefined && !(0, prostgles_types_1.isObject)(options)) ||
|
|
13
|
+
!(typeof onChange === "function") ||
|
|
14
|
+
(onError !== undefined && typeof onError !== "function")) {
|
|
12
15
|
throw "Expecting: ( basicFilter<object>, options<object>, onChange<function> , onError?<function>) but got something else";
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
18
|
const sub_commands = ["subscribe", "subscribeOne"];
|
|
16
|
-
(0, prostgles_types_1.getKeys)(dbo).forEach(tableName => {
|
|
19
|
+
(0, prostgles_types_1.getKeys)(dbo).forEach((tableName) => {
|
|
17
20
|
const all_commands = Object.keys(dbo[tableName]);
|
|
18
21
|
const dboTable = dbo[tableName];
|
|
19
22
|
all_commands
|
|
20
23
|
.sort((a, b) => sub_commands.includes(a) - sub_commands.includes(b))
|
|
21
|
-
.forEach(command => {
|
|
24
|
+
.forEach((command) => {
|
|
22
25
|
if (command === "sync") {
|
|
23
26
|
dboTable._syncInfo = { ...dboTable[command] };
|
|
24
27
|
if (syncedTable) {
|
|
25
28
|
dboTable.getSync = async (filter, params = {}) => {
|
|
26
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
29
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
30
|
+
type: "table",
|
|
31
|
+
command: "getSync",
|
|
32
|
+
tableName,
|
|
33
|
+
data: { filter, params },
|
|
34
|
+
}));
|
|
27
35
|
return syncedTable.create({
|
|
28
36
|
name: tableName,
|
|
29
37
|
onDebug: onDebug,
|
|
30
38
|
filter,
|
|
31
39
|
db: dbo,
|
|
32
|
-
...params
|
|
40
|
+
...params,
|
|
33
41
|
});
|
|
34
42
|
};
|
|
35
43
|
const upsertSyncTable = async (basicFilter = {}, options = {}, onError) => {
|
|
@@ -41,19 +49,29 @@ const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler
|
|
|
41
49
|
name: tableName,
|
|
42
50
|
filter: basicFilter,
|
|
43
51
|
db: dbo,
|
|
44
|
-
onError
|
|
52
|
+
onError,
|
|
45
53
|
});
|
|
46
54
|
}
|
|
47
55
|
return syncHandler.syncedTables[syncName];
|
|
48
56
|
};
|
|
49
57
|
const sync = async (basicFilter, options = { handlesOnData: true, select: "*" }, onChange, onError) => {
|
|
50
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
58
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
59
|
+
type: "table",
|
|
60
|
+
command: "sync",
|
|
61
|
+
tableName,
|
|
62
|
+
data: { basicFilter, options },
|
|
63
|
+
}));
|
|
51
64
|
checkSubscriptionArgs(basicFilter, options, onChange, onError);
|
|
52
65
|
const s = await upsertSyncTable(basicFilter, options, onError);
|
|
53
66
|
return await s.sync(onChange, options.handlesOnData);
|
|
54
67
|
};
|
|
55
68
|
const syncOne = async (basicFilter, options = { handlesOnData: true }, onChange, onError) => {
|
|
56
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
69
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
70
|
+
type: "table",
|
|
71
|
+
command: "syncOne",
|
|
72
|
+
tableName,
|
|
73
|
+
data: { basicFilter, options },
|
|
74
|
+
}));
|
|
57
75
|
checkSubscriptionArgs(basicFilter, options, onChange, onError);
|
|
58
76
|
const s = await upsertSyncTable(basicFilter, options, onError);
|
|
59
77
|
return await s.syncOne(basicFilter, onChange, options.handlesOnData);
|
|
@@ -62,17 +80,28 @@ const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler
|
|
|
62
80
|
dboTable.syncOne = syncOne;
|
|
63
81
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
64
82
|
dboTable.useSync = (basicFilter, options) => (0, prostgles_1.useSync)(sync, basicFilter, options);
|
|
83
|
+
dboTable.useSyncOne = (basicFilter, options) =>
|
|
65
84
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
66
|
-
|
|
85
|
+
(0, prostgles_1.useSync)(syncOne, basicFilter, options);
|
|
67
86
|
}
|
|
68
87
|
dboTable._sync = async function (param1, param2, syncHandles) {
|
|
69
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
88
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
89
|
+
type: "table",
|
|
90
|
+
command: "_sync",
|
|
91
|
+
tableName,
|
|
92
|
+
data: { param1, param2, syncHandles },
|
|
93
|
+
}));
|
|
70
94
|
return syncHandler.addSync({ tableName, command, param1, param2 }, syncHandles);
|
|
71
95
|
};
|
|
72
96
|
}
|
|
73
97
|
else if (sub_commands.includes(command)) {
|
|
74
98
|
const subFunc = async function (param1 = {}, param2 = {}, onChange, onError) {
|
|
75
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
99
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
100
|
+
type: "table",
|
|
101
|
+
command: command,
|
|
102
|
+
tableName,
|
|
103
|
+
data: { param1, param2, onChange, onError },
|
|
104
|
+
}));
|
|
76
105
|
checkSubscriptionArgs(param1, param2, onChange, onError);
|
|
77
106
|
return subscriptionHandler.addSub(dbo, { tableName, command, param1, param2 }, onChange, onError);
|
|
78
107
|
};
|
|
@@ -81,23 +110,38 @@ const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler
|
|
|
81
110
|
/**
|
|
82
111
|
* React hooks
|
|
83
112
|
*/
|
|
84
|
-
const handlerName = command === "subscribe" ? "useSubscribe"
|
|
113
|
+
const handlerName = command === "subscribe" ? "useSubscribe"
|
|
114
|
+
: command === "subscribeOne" ? "useSubscribeOne"
|
|
115
|
+
: undefined;
|
|
85
116
|
if (handlerName) {
|
|
117
|
+
dboTable[handlerName] = (filter, options) =>
|
|
86
118
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
87
|
-
|
|
119
|
+
(0, prostgles_1.useSubscribe)(subFunc, command === SUBONE, filter, options);
|
|
88
120
|
}
|
|
89
121
|
if (command === SUBONE || !sub_commands.includes(SUBONE)) {
|
|
90
122
|
dboTable[SUBONE] = async function (param1, param2, onChange, onError) {
|
|
91
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
123
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
124
|
+
type: "table",
|
|
125
|
+
command: "getSync",
|
|
126
|
+
tableName,
|
|
127
|
+
data: { param1, param2, onChange, onError },
|
|
128
|
+
}));
|
|
92
129
|
checkSubscriptionArgs(param1, param2, onChange, onError);
|
|
93
|
-
const onChangeOne = (rows) => {
|
|
130
|
+
const onChangeOne = (rows) => {
|
|
131
|
+
onChange(rows[0]);
|
|
132
|
+
};
|
|
94
133
|
return subscriptionHandler.addSub(dbo, { tableName, command, param1, param2 }, onChangeOne, onError);
|
|
95
134
|
};
|
|
96
135
|
}
|
|
97
136
|
}
|
|
98
137
|
else {
|
|
99
138
|
const method = async function (param1, param2, param3) {
|
|
100
|
-
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
139
|
+
await (onDebug === null || onDebug === void 0 ? void 0 : onDebug({
|
|
140
|
+
type: "table",
|
|
141
|
+
command: command,
|
|
142
|
+
tableName,
|
|
143
|
+
data: { param1, param2, param3 },
|
|
144
|
+
}));
|
|
101
145
|
return new Promise((resolve, reject) => {
|
|
102
146
|
socket.emit(preffix, { tableName, command, param1, param2, param3 },
|
|
103
147
|
/* Get col definition and re-cast data types?! */
|
|
@@ -110,17 +154,22 @@ const getDBO = ({ schema, onDebug, syncedTable, syncHandler, subscriptionHandler
|
|
|
110
154
|
});
|
|
111
155
|
};
|
|
112
156
|
dboTable[command] = method;
|
|
113
|
-
const methodName = command === "findOne" ? "useFindOne"
|
|
157
|
+
const methodName = command === "findOne" ? "useFindOne"
|
|
158
|
+
: command === "find" ? "useFind"
|
|
159
|
+
: command === "count" ? "useCount"
|
|
160
|
+
: command === "size" ? "useSize"
|
|
161
|
+
: undefined;
|
|
114
162
|
if (methodName) {
|
|
163
|
+
dboTable[methodName] = (param1, param2, param3) =>
|
|
115
164
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
116
|
-
|
|
165
|
+
(0, prostgles_1.useFetch)(method, [param1, param2, param3]);
|
|
117
166
|
}
|
|
118
167
|
if (["find", "findOne"].includes(command)) {
|
|
119
168
|
dboTable.getJoinedTables = function () {
|
|
120
169
|
return joinTables
|
|
121
|
-
.filter(tb => Array.isArray(tb) && tb.includes(tableName))
|
|
170
|
+
.filter((tb) => Array.isArray(tb) && tb.includes(tableName))
|
|
122
171
|
.flat()
|
|
123
|
-
.filter(t => t !== tableName);
|
|
172
|
+
.filter((t) => t !== tableName);
|
|
124
173
|
};
|
|
125
174
|
}
|
|
126
175
|
}
|
package/dist/prostgles.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { AnyObject, ClientSchema, ClientSyncHandles, DBSchema, DBSchemaTable, DbJoinMaker, EqualityFilter, FullFilter,
|
|
1
|
+
import type { AnyObject, ClientSchema, ClientSyncHandles, DBSchema, DBSchemaTable, DbJoinMaker, EqualityFilter, FullFilter, SelectReturnType, MethodHandler, SQLHandler, SQLResult, SelectParams, SubscribeParams, TableHandler, ViewHandler } from "prostgles-types";
|
|
2
2
|
import { asName } from "prostgles-types";
|
|
3
3
|
import { type AuthHandler } from "./Auth";
|
|
4
4
|
import type { Sync, SyncDataItem, SyncOne, SyncOneOptions, SyncOptions, SyncedTable } from "./SyncedTable/SyncedTable";
|
|
5
|
+
import type { Socket } from "socket.io-client";
|
|
5
6
|
export declare const hasWnd: boolean;
|
|
6
7
|
export declare const debug: any;
|
|
7
8
|
export * from "./react-hooks";
|
|
@@ -40,7 +41,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
40
41
|
* Retrieves a list of matching records from the view/table and subscribes to changes
|
|
41
42
|
*/
|
|
42
43
|
useSubscribe: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
|
|
43
|
-
data:
|
|
44
|
+
data: SelectReturnType<S, SubParams, T, true> | undefined;
|
|
44
45
|
error?: any;
|
|
45
46
|
isLoading: boolean;
|
|
46
47
|
};
|
|
@@ -48,7 +49,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
48
49
|
* Retrieves a matching record from the view/table and subscribes to changes
|
|
49
50
|
*/
|
|
50
51
|
useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => {
|
|
51
|
-
data:
|
|
52
|
+
data: SelectReturnType<S, SubParams, T, false> | undefined;
|
|
52
53
|
error?: any;
|
|
53
54
|
isLoading: boolean;
|
|
54
55
|
};
|
|
@@ -56,7 +57,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
56
57
|
* Retrieves a list of matching records from the view/table
|
|
57
58
|
*/
|
|
58
59
|
useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
|
|
59
|
-
data: undefined |
|
|
60
|
+
data: undefined | SelectReturnType<S, P, T, true>;
|
|
60
61
|
isLoading: boolean;
|
|
61
62
|
error?: any;
|
|
62
63
|
};
|
|
@@ -64,7 +65,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
64
65
|
* Retrieves first matching record from the view/table
|
|
65
66
|
*/
|
|
66
67
|
useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => {
|
|
67
|
-
data: undefined |
|
|
68
|
+
data: undefined | SelectReturnType<S, P, T, false>;
|
|
68
69
|
isLoading: boolean;
|
|
69
70
|
error?: any;
|
|
70
71
|
};
|
|
@@ -145,7 +146,10 @@ type DebugEvent = {
|
|
|
145
146
|
state: "connected" | "disconnected" | "reconnected" | undefined;
|
|
146
147
|
};
|
|
147
148
|
export type InitOptions<DBSchema = void> = {
|
|
148
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Socket.io client instance
|
|
151
|
+
*/
|
|
152
|
+
socket: Socket;
|
|
149
153
|
/**
|
|
150
154
|
* Execute this when requesting user reload (due to session expiring authGuard)
|
|
151
155
|
* Otherwise window will reload
|
|
@@ -155,14 +159,48 @@ export type InitOptions<DBSchema = void> = {
|
|
|
155
159
|
* true by default
|
|
156
160
|
*/
|
|
157
161
|
onSchemaChange?: false | (() => void);
|
|
158
|
-
onReady: (dbo: DBHandlerClient<DBSchema>, methods: MethodHandler | undefined, tableSchema: DBSchemaTable[] | undefined, auth: AuthHandler, isReconnect: boolean) => any;
|
|
159
162
|
/**
|
|
163
|
+
* Callback called when:
|
|
164
|
+
* - the client connects for the first time
|
|
165
|
+
* - the schema changes
|
|
166
|
+
* - the client reconnects
|
|
167
|
+
* - server requests a reload
|
|
168
|
+
*/
|
|
169
|
+
onReady: OnReadyCallback<DBSchema>;
|
|
170
|
+
/**
|
|
171
|
+
* Custom handler in case of websocket re-connection.
|
|
160
172
|
* If not provided will fire onReady
|
|
161
173
|
*/
|
|
162
174
|
onReconnect?: (socket: any, error?: any) => any;
|
|
175
|
+
/**
|
|
176
|
+
* On disconnect handler.
|
|
177
|
+
* It is recommended to use this callback instead of socket.on("disconnect")
|
|
178
|
+
*/
|
|
163
179
|
onDisconnect?: () => any;
|
|
180
|
+
/**
|
|
181
|
+
* Awaited debug callback.
|
|
182
|
+
* Allows greater granularity during debugging.
|
|
183
|
+
*/
|
|
164
184
|
onDebug?: (event: DebugEvent) => any;
|
|
165
185
|
};
|
|
186
|
+
type OnReadyCallback<DBSchema = void> = (
|
|
187
|
+
/**
|
|
188
|
+
* The database handler object.
|
|
189
|
+
* Only allowed tables and table methods are defined
|
|
190
|
+
*/
|
|
191
|
+
dbo: DBHandlerClient<DBSchema>,
|
|
192
|
+
/**
|
|
193
|
+
* Custom server-side TS methods
|
|
194
|
+
*/
|
|
195
|
+
methods: MethodHandler | undefined,
|
|
196
|
+
/**
|
|
197
|
+
* Table schema together with column permission details the client has access to
|
|
198
|
+
*/
|
|
199
|
+
tableSchema: DBSchemaTable[] | undefined,
|
|
200
|
+
/**
|
|
201
|
+
* Handlers for authentication that are configured on the server through the "auth" options
|
|
202
|
+
*/
|
|
203
|
+
auth: AuthHandler, isReconnect: boolean) => void | Promise<void>;
|
|
166
204
|
export type AnyFunction = (...args: any[]) => any;
|
|
167
205
|
export type CoreParams = {
|
|
168
206
|
tableName: string;
|
package/dist/prostgles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prostgles.d.ts","sourceRoot":"","sources":["../lib/prostgles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,QAAQ,EACR,aAAa,EACb,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,SAAS,EACT,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAY,MAAM,EAAmB,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,KAAK,WAAW,EAAa,MAAM,QAAQ,CAAC;AAMrD,OAAO,KAAK,EACV,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,cAAc,EACd,WAAW,EACX,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C,eAAO,MAAM,MAAM,SAAgC,CAAC;AACpD,eAAO,MAAM,KAAK,EAAE,GAInB,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAE5C,MAAM,MAAM,iBAAiB,CAC3B,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,SAAS,QAAQ,GAAG,IAAI,GAAG,IAAI,IAC9B,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IACtB,eAAe,EAAE,MAAM,MAAM,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAEf;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AG;IACrB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAOF,wBAAgB,SAAS,CAAC,QAAQ,EAChC,QAAQ,EAAE,WAAW,CAAC,QAAQ,CAAC,EAC/B,WAAW,EAAE,OAAO,WAAW,GAAG,SAAS,oBA0I5C"}
|
package/dist/prostgles.js
CHANGED
|
@@ -39,7 +39,7 @@ exports.debug = debug;
|
|
|
39
39
|
__exportStar(require("./react-hooks"), exports);
|
|
40
40
|
__exportStar(require("./useProstglesClient"), exports);
|
|
41
41
|
function prostgles(initOpts, syncedTable) {
|
|
42
|
-
const { socket, onReady, onDisconnect, onReconnect, onSchemaChange = true, onReload, onDebug } = initOpts;
|
|
42
|
+
const { socket, onReady, onDisconnect, onReconnect, onSchemaChange = true, onReload, onDebug, } = initOpts;
|
|
43
43
|
let schemaAge;
|
|
44
44
|
(0, exports.debug)("prostgles", { initOpts });
|
|
45
45
|
if (onSchemaChange) {
|
|
@@ -57,7 +57,7 @@ function prostgles(initOpts, syncedTable) {
|
|
|
57
57
|
let state;
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
59
59
|
socket.removeAllListeners(prostgles_types_1.CHANNELS.CONNECTION);
|
|
60
|
-
socket.on(prostgles_types_1.CHANNELS.CONNECTION, error => {
|
|
60
|
+
socket.on(prostgles_types_1.CHANNELS.CONNECTION, (error) => {
|
|
61
61
|
reject(error);
|
|
62
62
|
return "ok";
|
|
63
63
|
});
|
|
@@ -83,8 +83,9 @@ function prostgles(initOpts, syncedTable) {
|
|
|
83
83
|
/** Only destroy existing syncs if schema changed */
|
|
84
84
|
const schemaDidNotChange = (schemaAge === null || schemaAge === void 0 ? void 0 : schemaAge.clientSchema) && (0, react_hooks_1.isEqual)(schemaAge.clientSchema, clientSchema);
|
|
85
85
|
if (!schemaDidNotChange) {
|
|
86
|
-
syncHandler
|
|
87
|
-
.
|
|
86
|
+
syncHandler
|
|
87
|
+
.destroySyncs()
|
|
88
|
+
.catch((error) => console.error("Error while destroying syncs", error));
|
|
88
89
|
}
|
|
89
90
|
if (err) {
|
|
90
91
|
console.error("Error on schema change:", err);
|
|
@@ -121,7 +122,7 @@ function prostgles(initOpts, syncedTable) {
|
|
|
121
122
|
}
|
|
122
123
|
subscriptionHandler.reAttachAll();
|
|
123
124
|
syncHandler.reAttachAll();
|
|
124
|
-
joinTables.flat().map(table => {
|
|
125
|
+
joinTables.flat().map((table) => {
|
|
125
126
|
var _a, _b, _c, _d;
|
|
126
127
|
(_a = dbo.innerJoin) !== null && _a !== void 0 ? _a : (dbo.innerJoin = {});
|
|
127
128
|
(_b = dbo.leftJoin) !== null && _b !== void 0 ? _b : (dbo.leftJoin = {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-client",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.180",
|
|
4
4
|
"description": "Reactive client for Postgres",
|
|
5
5
|
"main": "dist/prostgles-full.js",
|
|
6
6
|
"types": "dist/prostgles-full.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"pushpublish": "npm version patch --git-tag-version false && git push && npm publish"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"prostgles-types": "^4.0.
|
|
31
|
+
"prostgles-types": "^4.0.122"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^14.14.14",
|