prostgles-client 4.0.211 → 4.0.213
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 +3 -3
- package/dist/getDbHandler.d.ts.map +1 -1
- package/dist/getDbHandler.js +8 -7
- package/dist/getSubscriptionHandler.d.ts +1 -1
- package/dist/getSubscriptionHandler.d.ts.map +1 -1
- package/dist/getSubscriptionHandler.js +10 -8
- package/dist/index.js +1 -1
- package/dist/index.no-sync.js +1 -1
- package/dist/prostgles.d.ts +24 -8
- package/dist/prostgles.d.ts.map +1 -1
- package/dist/react-hooks.d.ts +4 -4
- package/dist/react-hooks.d.ts.map +1 -1
- package/dist/react-hooks.js +11 -21
- package/package.json +2 -2
package/dist/prostgles.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
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
|
+
import { type Subscription } from "./getSubscriptionHandler";
|
|
4
5
|
import type { Sync, SyncDataItem, SyncOne, SyncOneOptions, SyncOptions, SyncedTable } from "./SyncedTable/SyncedTable";
|
|
5
6
|
import type { Socket } from "socket.io-client";
|
|
6
7
|
export declare const hasWnd: boolean;
|
|
@@ -23,6 +24,12 @@ export type AsyncResult<T> = {
|
|
|
23
24
|
isLoading: boolean;
|
|
24
25
|
error?: any;
|
|
25
26
|
};
|
|
27
|
+
export type HookOptions = {
|
|
28
|
+
/**
|
|
29
|
+
* Used to prevent the hook from fetching data
|
|
30
|
+
*/
|
|
31
|
+
skip?: boolean;
|
|
32
|
+
};
|
|
26
33
|
export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchema | void = void> = ViewHandler<T, S> & {
|
|
27
34
|
/**
|
|
28
35
|
* Retrieves rows matching the filter and keeps them in sync
|
|
@@ -30,7 +37,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
30
37
|
* - any changes to the row using the $update method will be reflected instantly
|
|
31
38
|
* to all sync subscribers that were initiated with the same syncOptions
|
|
32
39
|
*/
|
|
33
|
-
useSync?: (basicFilter: EqualityFilter<T>, syncOptions: SyncOptions) => AsyncResult<SyncDataItem<Required<T>>[] | undefined>;
|
|
40
|
+
useSync?: (basicFilter: EqualityFilter<T>, syncOptions: SyncOptions, hookOptions?: HookOptions) => AsyncResult<SyncDataItem<Required<T>>[] | undefined>;
|
|
34
41
|
sync?: Sync<T>;
|
|
35
42
|
syncOne?: SyncOne<T>;
|
|
36
43
|
/**
|
|
@@ -39,7 +46,7 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
39
46
|
* - any changes to the row using the $update method will be reflected instantly
|
|
40
47
|
* to all sync subscribers that were initiated with the same syncOptions
|
|
41
48
|
*/
|
|
42
|
-
useSyncOne?: (basicFilter: EqualityFilter<T>, syncOptions: SyncOneOptions) => AsyncResult<SyncDataItem<Required<T>> | undefined>;
|
|
49
|
+
useSyncOne?: (basicFilter: EqualityFilter<T>, syncOptions: SyncOneOptions, hookOptions?: HookOptions) => AsyncResult<SyncDataItem<Required<T>> | undefined>;
|
|
43
50
|
/**
|
|
44
51
|
* Used internally to setup sync
|
|
45
52
|
*/
|
|
@@ -49,27 +56,27 @@ export type ViewHandlerClient<T extends AnyObject = AnyObject, S extends DBSchem
|
|
|
49
56
|
/**
|
|
50
57
|
* Retrieves a list of matching records from the view/table and subscribes to changes
|
|
51
58
|
*/
|
|
52
|
-
useSubscribe: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => AsyncResult<SelectReturnType<S, SubParams, T, true> | undefined>;
|
|
59
|
+
useSubscribe: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams, hookOptions?: HookOptions) => AsyncResult<SelectReturnType<S, SubParams, T, true> | undefined>;
|
|
53
60
|
/**
|
|
54
61
|
* Retrieves a matching record from the view/table and subscribes to changes
|
|
55
62
|
*/
|
|
56
|
-
useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams) => AsyncResult<SelectReturnType<S, SubParams, T, false> | undefined>;
|
|
63
|
+
useSubscribeOne: <SubParams extends SubscribeParams<T, S>>(filter?: FullFilter<T, S>, options?: SubParams, hookOptions?: HookOptions) => AsyncResult<SelectReturnType<S, SubParams, T, false> | undefined>;
|
|
57
64
|
/**
|
|
58
65
|
* Retrieves a list of matching records from the view/table
|
|
59
66
|
*/
|
|
60
|
-
useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => AsyncResult<SelectReturnType<S, P, T, true> | undefined>;
|
|
67
|
+
useFind: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P, hookOptions?: HookOptions) => AsyncResult<SelectReturnType<S, P, T, true> | undefined>;
|
|
61
68
|
/**
|
|
62
69
|
* Retrieves first matching record from the view/table
|
|
63
70
|
*/
|
|
64
|
-
useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => AsyncResult<SelectReturnType<S, P, T, false> | undefined>;
|
|
71
|
+
useFindOne: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P, hookOptions?: HookOptions) => AsyncResult<SelectReturnType<S, P, T, false> | undefined>;
|
|
65
72
|
/**
|
|
66
73
|
* Returns the total number of rows matching the filter
|
|
67
74
|
*/
|
|
68
|
-
useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => AsyncResult<number | undefined>;
|
|
75
|
+
useCount: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P, hookOptions?: HookOptions) => AsyncResult<number | undefined>;
|
|
69
76
|
/**
|
|
70
77
|
* Returns result size in bits matching the filter and selectParams
|
|
71
78
|
*/
|
|
72
|
-
useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P) => AsyncResult<string | undefined>;
|
|
79
|
+
useSize: <P extends SelectParams<T, S>>(filter?: FullFilter<T, S>, selectParams?: P, hookOptions?: HookOptions) => AsyncResult<string | undefined>;
|
|
73
80
|
};
|
|
74
81
|
export type TableHandlerClient<T extends AnyObject = AnyObject, S extends DBSchema | void = void> = ViewHandlerClient<T, S> & TableHandler<T, S> & {
|
|
75
82
|
_syncInfo?: any;
|
|
@@ -98,9 +105,18 @@ type SyncDebugEvent = {
|
|
|
98
105
|
data: AnyObject;
|
|
99
106
|
};
|
|
100
107
|
type DebugEvent = {
|
|
108
|
+
type: "subscriptions";
|
|
109
|
+
command: "reAttachAll.start";
|
|
110
|
+
subscriptions: Record<string, Subscription>;
|
|
111
|
+
} | {
|
|
112
|
+
type: "subscriptions";
|
|
113
|
+
command: "reAttachAll.end";
|
|
114
|
+
subscriptions: Record<string, Subscription>;
|
|
115
|
+
} | {
|
|
101
116
|
type: "table";
|
|
102
117
|
command: "unsubscribe";
|
|
103
118
|
tableName: string;
|
|
119
|
+
handlers: AnyFunction[];
|
|
104
120
|
/**
|
|
105
121
|
* If defined then the server will be asked to unsubscribe
|
|
106
122
|
*/
|
package/dist/prostgles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,EAA4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AAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAElD,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,QAAQ,GAAG;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,oBA+H5C"}
|
package/dist/react-hooks.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { type SubscriptionHandler } from "prostgles-types";
|
|
3
|
-
import type { TableHandlerClient } from "./prostgles";
|
|
3
|
+
import type { HookOptions, TableHandlerClient } from "./prostgles";
|
|
4
4
|
type ReactT = typeof import("react");
|
|
5
5
|
export declare const getReact: (throwError?: boolean) => ReactT;
|
|
6
6
|
export declare const getIO: (throwError?: boolean) => typeof import("socket.io-client").io;
|
|
@@ -18,17 +18,17 @@ export declare const useIsMounted: () => () => boolean;
|
|
|
18
18
|
type PromiseFunc = () => Promise<any>;
|
|
19
19
|
type NamedResult = Record<string, PromiseFunc>;
|
|
20
20
|
export declare const usePromise: <F extends PromiseFunc | NamedResult>(f: F, deps?: any[]) => F extends NamedResult ? { [key in keyof F]: Awaited<ReturnType<F[key]>>; } : F extends PromiseFunc ? Awaited<ReturnType<F>> | undefined : undefined;
|
|
21
|
-
export declare const useSubscribe: (subFunc: (filter: any, options: any, onData: any, onError: any) => Promise<SubscriptionHandler>, expectsOne: boolean, filter: any, options: any) => {
|
|
21
|
+
export declare const useSubscribe: (subFunc: (filter: any, options: any, onData: any, onError: any) => Promise<SubscriptionHandler>, expectsOne: boolean, filter: any, options: any, hookOptions?: HookOptions) => {
|
|
22
22
|
data: any;
|
|
23
23
|
error: any;
|
|
24
24
|
isLoading: boolean;
|
|
25
25
|
};
|
|
26
|
-
export declare const useSync: (syncFunc: Required<TableHandlerClient>["sync"] | Required<TableHandlerClient>["syncOne"], basicFilter: Parameters<Required<TableHandlerClient>["sync"]>[0], syncOptions: Parameters<Required<TableHandlerClient>["sync"]>[1]) => {
|
|
26
|
+
export declare const useSync: (syncFunc: Required<TableHandlerClient>["sync"] | Required<TableHandlerClient>["syncOne"], basicFilter: Parameters<Required<TableHandlerClient>["sync"]>[0], syncOptions: Parameters<Required<TableHandlerClient>["sync"]>[1], hookOptions?: HookOptions) => {
|
|
27
27
|
data: any;
|
|
28
28
|
error: any;
|
|
29
29
|
isLoading: boolean;
|
|
30
30
|
};
|
|
31
|
-
export declare const useFetch: (fetchFunc: (...args: any) => Promise<any>, args?: any[]) => {
|
|
31
|
+
export declare const useFetch: (fetchFunc: (...args: any) => Promise<any>, args?: any[], hookOptions?: HookOptions) => {
|
|
32
32
|
data: any;
|
|
33
33
|
error: any;
|
|
34
34
|
isLoading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,iBAAiB,CAAC;AACvF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"react-hooks.d.ts","sourceRoot":"","sources":["../lib/react-hooks.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,mBAAmB,EAA8B,MAAM,iBAAiB,CAAC;AACvF,OAAO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AC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,gBAClD,WAAW;;;;CA4B1B,CAAC;AAEF,eAAO,MAAM,QAAQ,wBACE,GAAG,KAAK,QAAQ,GAAG,CAAC,SACnC,GAAG,EAAE,gBACG,WAAW;;;;CAmB1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,eAA0C,CAAC"}
|
package/dist/react-hooks.js
CHANGED
|
@@ -53,19 +53,6 @@ exports.useEffectDeep = ((callback, deps) => {
|
|
|
53
53
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
54
|
useEffect(callback, deps === null || deps === void 0 ? void 0 : deps.map(exports.useDeepCompareMemoize));
|
|
55
55
|
});
|
|
56
|
-
// class CEffect {
|
|
57
|
-
// private effect: EffectFunc;
|
|
58
|
-
// constructor(effect: EffectFunc) {
|
|
59
|
-
// this.effect = effect;
|
|
60
|
-
// }
|
|
61
|
-
// private cleanupFunc: VoidFunction | void;
|
|
62
|
-
// run = async () => {
|
|
63
|
-
// this.cleanupFunc = await this.effect();
|
|
64
|
-
// }
|
|
65
|
-
// cleanup = async () => {
|
|
66
|
-
// await this.cleanupFunc?.();
|
|
67
|
-
// }
|
|
68
|
-
// }
|
|
69
56
|
/**
|
|
70
57
|
* Debounce with execute first
|
|
71
58
|
* Used to ensure subscriptions are always cleaned up
|
|
@@ -209,12 +196,13 @@ const usePromise = (f, deps = []) => {
|
|
|
209
196
|
return result;
|
|
210
197
|
};
|
|
211
198
|
exports.usePromise = usePromise;
|
|
212
|
-
const useSubscribe = (subFunc, expectsOne, filter, options) => {
|
|
199
|
+
const useSubscribe = (subFunc, expectsOne, filter, options, hookOptions) => {
|
|
200
|
+
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
213
201
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
214
202
|
const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
|
|
215
203
|
const getIsMounted = (0, exports.useIsMounted)();
|
|
216
204
|
(0, exports.useAsyncEffectQueue)(async () => {
|
|
217
|
-
if (!getIsMounted())
|
|
205
|
+
if (!getIsMounted() || skip)
|
|
218
206
|
return;
|
|
219
207
|
setResult(defaultLoadingResult);
|
|
220
208
|
const setError = (newError) => {
|
|
@@ -237,16 +225,17 @@ const useSubscribe = (subFunc, expectsOne, filter, options) => {
|
|
|
237
225
|
catch (error) {
|
|
238
226
|
setError(error);
|
|
239
227
|
}
|
|
240
|
-
}, [subFunc, filter, options]);
|
|
228
|
+
}, [subFunc, filter, options, skip]);
|
|
241
229
|
return { data, error, isLoading };
|
|
242
230
|
};
|
|
243
231
|
exports.useSubscribe = useSubscribe;
|
|
244
|
-
const useSync = (syncFunc, basicFilter, syncOptions) => {
|
|
232
|
+
const useSync = (syncFunc, basicFilter, syncOptions, hookOptions) => {
|
|
233
|
+
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
245
234
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
246
235
|
const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
|
|
247
236
|
const getIsMounted = (0, exports.useIsMounted)();
|
|
248
237
|
(0, exports.useAsyncEffectQueue)(async () => {
|
|
249
|
-
if (!getIsMounted())
|
|
238
|
+
if (!getIsMounted() || skip)
|
|
250
239
|
return;
|
|
251
240
|
const setError = (newError) => {
|
|
252
241
|
if (!getIsMounted())
|
|
@@ -264,16 +253,17 @@ const useSync = (syncFunc, basicFilter, syncOptions) => {
|
|
|
264
253
|
catch (error) {
|
|
265
254
|
setError(error);
|
|
266
255
|
}
|
|
267
|
-
}, [syncFunc, basicFilter, syncOptions]);
|
|
256
|
+
}, [syncFunc, basicFilter, syncOptions, skip]);
|
|
268
257
|
return { data, error, isLoading };
|
|
269
258
|
};
|
|
270
259
|
exports.useSync = useSync;
|
|
271
|
-
const useFetch = (fetchFunc, args = []) => {
|
|
260
|
+
const useFetch = (fetchFunc, args = [], hookOptions) => {
|
|
261
|
+
const { skip } = hookOptions !== null && hookOptions !== void 0 ? hookOptions : {};
|
|
272
262
|
const defaultLoadingResult = { data: undefined, error: undefined, isLoading: true };
|
|
273
263
|
const [{ data, error, isLoading }, setResult] = useState(defaultLoadingResult);
|
|
274
264
|
const getIsMounted = (0, exports.useIsMounted)();
|
|
275
265
|
(0, exports.useAsyncEffectQueue)(async () => {
|
|
276
|
-
if (!getIsMounted())
|
|
266
|
+
if (!getIsMounted() || skip)
|
|
277
267
|
return;
|
|
278
268
|
setResult(defaultLoadingResult);
|
|
279
269
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prostgles-client",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.213",
|
|
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.148"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^14.14.14",
|