prostgles-client 4.0.174 → 4.0.177

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 (42) hide show
  1. package/.eslintignore +1 -0
  2. package/.prettierignore +2 -0
  3. package/.prettierrc +4 -0
  4. package/.vscode/settings.json +10 -1
  5. package/dist/Auth.d.ts +2 -2
  6. package/dist/Auth.d.ts.map +1 -1
  7. package/dist/Auth.js +28 -18
  8. package/dist/SyncedTable/SyncedTable.d.ts +12 -12
  9. package/dist/SyncedTable/SyncedTable.d.ts.map +1 -1
  10. package/dist/SyncedTable/SyncedTable.js +92 -78
  11. package/dist/SyncedTable/getMultiSyncSubscription.d.ts.map +1 -1
  12. package/dist/SyncedTable/getMultiSyncSubscription.js +11 -9
  13. package/dist/index.js +1 -1
  14. package/dist/index.no-sync.js +1 -1
  15. package/dist/prostgles.d.ts +24 -0
  16. package/dist/prostgles.d.ts.map +1 -1
  17. package/package.json +3 -2
  18. package/tsconfig.json +1 -3
  19. package/dist/typeTests.d.ts +0 -2
  20. package/dist/typeTests.d.ts.map +0 -1
  21. package/dist/typeTests.js +0 -37
  22. package/lib/Auth.ts +0 -155
  23. package/lib/FunctionQueuer.ts +0 -71
  24. package/lib/SyncedTable/SyncedTable.ts +0 -1078
  25. package/lib/SyncedTable/getMultiSyncSubscription.ts +0 -67
  26. package/lib/SyncedTable/getSingleSyncSubscription.ts +0 -0
  27. package/lib/getDbHandler.ts +0 -152
  28. package/lib/getMethods.ts +0 -30
  29. package/lib/getSqlHandler.ts +0 -174
  30. package/lib/getSubscriptionHandler.ts +0 -211
  31. package/lib/getSyncHandler.ts +0 -201
  32. package/lib/md5.ts +0 -183
  33. package/lib/prostgles-full-cdn.ts +0 -5
  34. package/lib/prostgles-full.ts +0 -8
  35. package/lib/prostgles.ts +0 -351
  36. package/lib/react-hooks.ts +0 -356
  37. package/lib/typeTests.ts +0 -64
  38. package/lib/useProstglesClient.ts +0 -92
  39. package/tests/package-lock.json +0 -71
  40. package/tests/package.json +0 -17
  41. package/tests/test.ts +0 -10
  42. package/tests/tsconfig.json +0 -27
package/lib/typeTests.ts DELETED
@@ -1,64 +0,0 @@
1
- import type { AnyObject, FullFilter, TableHandler } from "prostgles-types";
2
- import { type DBHandlerClient, useProstglesClient } from "./prostgles";
3
-
4
- (async () => {
5
- // const schema: DBSchema = {
6
- type GeneratedSchema = {
7
- table1: {
8
- columns: {
9
- col1: string,
10
- },
11
- is_view: false,
12
- select: true,
13
- insert: true,
14
- update: true,
15
- delete: true,
16
- }
17
- };
18
-
19
- const client = useProstglesClient<GeneratedSchema>();
20
- if(client.isLoading || "error" in client) return;
21
- const t1 = client.dbo.table1.useFind({ }, { orderBy: { col1: 1 } });
22
- const dbo: DBHandlerClient<GeneratedSchema> = 1 as any;
23
-
24
-
25
- const client2 = useProstglesClient();
26
- if(client2.isLoading || "error" in client2) return;
27
- client2.dbo.dwada?.find?.();
28
-
29
- const filter: FullFilter<GeneratedSchema["table1"]["columns"], GeneratedSchema> = { };
30
-
31
- const filterCheck = <F extends FullFilter<void, void> | undefined>(f: F) => {};
32
- filterCheck(filter);
33
-
34
- const sub: TableHandler["size"] = dbo.table1.size
35
-
36
- const f = <A extends TableHandler>(a: A) => {};
37
-
38
- // f(dbo.table1)
39
- const ra = <A extends AnyObject>(a: A) => {
40
-
41
- };
42
-
43
- const dbH: DBHandlerClient = 1 as any;
44
-
45
- dbH.dwadwa?.findOne!(
46
- { "name.@@.to_tsquery": ["abc81"] },
47
- { select: {
48
- h: { "$ts_headline_simple": ["name", { plainto_tsquery: "abc81" }] },
49
- hh: { "$ts_headline": ["name", "abc81"] } ,
50
- added: "$date_trunc_2hour",
51
- addedY: { "$date_trunc_5minute": ["added"] }
52
- }});
53
-
54
- dbH.d?.find?.({}, {
55
-
56
- select: { id: 1, name: 1, items3: { name: "$upper" } }
57
- })
58
-
59
- dbH.d?.find!({}, {
60
- select: { connection_id: 1, access_control_user_types: { access_control_id: 1 }, access_control_methods: { access_control_id: 1 } }
61
- })
62
- // const dboBasic: DBHandlerClient = dbo;
63
-
64
- })
@@ -1,92 +0,0 @@
1
-
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Stefan L. All rights reserved.
4
- * Licensed under the MIT License. See LICENSE in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- import {
8
- omitKeys,
9
- type DBSchema,
10
- type DBSchemaTable,
11
- type MethodHandler
12
- } from "prostgles-types";
13
-
14
- import type { ManagerOptions, Socket, SocketOptions } from "socket.io-client";
15
- import type { AuthHandler } from "./Auth";
16
- import { SyncedTable } from "./SyncedTable/SyncedTable";
17
- import { prostgles, type DBHandlerClient, type InitOptions } from "./prostgles";
18
- import { getIO, getReact, useAsyncEffectQueue, useIsMounted } from "./react-hooks";
19
-
20
- type OnReadyParams<DBSchema> = {
21
- dbo: DBHandlerClient<DBSchema>;
22
- methods: MethodHandler | undefined;
23
- tableSchema: DBSchemaTable[] | undefined;
24
- auth: AuthHandler | undefined;
25
- isReconnect: boolean;
26
- socket: Socket;
27
- }
28
- export type UseProstglesClientProps = Omit<InitOptions<DBSchema>, "onReady" | "socket"> & {
29
- socketOptions?: Partial<ManagerOptions & SocketOptions> & { uri?: string; };
30
- skip?: boolean;
31
- };
32
- type ProstglesClientState<PGC> =
33
- | { isLoading: true; error?: undefined; }
34
- | { isLoading: false; error?: undefined; } & PGC
35
- | { isLoading: false; error: Error | string; };
36
-
37
- export const useProstglesClient = <DBSchema>({ skip, socketOptions, ...initOpts }: UseProstglesClientProps = {}): ProstglesClientState<OnReadyParams<DBSchema>> => {
38
- const { useRef, useState } = getReact(true);
39
- const [onReadyArgs, setOnReadyArgs] = useState<ProstglesClientState<OnReadyParams<DBSchema>>>({
40
- isLoading: true
41
- });
42
- const getIsMounted = useIsMounted();
43
-
44
- const socketRef = useRef<Socket>();
45
-
46
- useAsyncEffectQueue(async () => {
47
- if(skip) return undefined;
48
-
49
- socketRef.current?.disconnect();
50
- const io = getIO();
51
- const opts = {
52
- reconnectionDelay: 1000,
53
- reconnection: true,
54
- ...omitKeys(socketOptions ?? {}, ["uri"]),
55
- }
56
- const socket = typeof socketOptions?.uri === "string" ? io(socketOptions.uri, opts) : io(opts);
57
- socketRef.current = socket;
58
- await prostgles<DBSchema>({
59
- socket,
60
- ...initOpts,
61
- onReady: (...args) => {
62
- const [dbo, methods, tableSchema, auth, isReconnect] = args;
63
- const onReadyArgs: OnReadyParams<DBSchema> = {
64
- dbo,
65
- methods,
66
- tableSchema,
67
- auth,
68
- isReconnect,
69
- socket
70
- };
71
- if (!getIsMounted()) {
72
- initOpts.onDebug?.({ type: "onReady.notMounted", data: onReadyArgs as any });
73
- return;
74
- }
75
- initOpts.onDebug?.({ type: "onReady", data: onReadyArgs as any });
76
- setOnReadyArgs({ ...onReadyArgs, isLoading: false });
77
- }
78
- }, SyncedTable)
79
- .catch(err => {
80
- if (!getIsMounted()) return;
81
- const error = err instanceof Error ? err : new Error(err);
82
- setOnReadyArgs({ isLoading: false, error });
83
- });
84
-
85
- return () => {
86
- socket.disconnect();
87
- }
88
-
89
- }, [initOpts, socketOptions, skip]);
90
-
91
- return onReadyArgs;
92
- }
@@ -1,71 +0,0 @@
1
- {
2
- "name": "test",
3
- "version": "1.0.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "test",
9
- "version": "1.0.0",
10
- "license": "ISC",
11
- "dependencies": {
12
- "prostgles-client": "file:.."
13
- },
14
- "devDependencies": {
15
- "@types/node": "^20.10.0"
16
- }
17
- },
18
- "..": {
19
- "name": "prostgles-client",
20
- "version": "4.0.173",
21
- "license": "MIT",
22
- "dependencies": {
23
- "prostgles-types": "^4.0.112"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^14.14.14",
27
- "@types/react": "^18.2.19",
28
- "@typescript-eslint/eslint-plugin": "^8.15.0",
29
- "@typescript-eslint/parser": "^8.15.0",
30
- "eslint": "^8.51.0",
31
- "eslint-plugin-react-hooks": "^4.6.0",
32
- "ts-loader": "^9.5.1",
33
- "tsconfig-paths-webpack-plugin": "^4.0.0",
34
- "typescript": "^5.3.3",
35
- "webpack": "^5.94.0",
36
- "webpack-cli": "^5.1.4"
37
- },
38
- "peerDependencies": {
39
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
40
- "socket.io-client": "^4.8.1"
41
- },
42
- "peerDependenciesMeta": {
43
- "react": {
44
- "optional": true
45
- },
46
- "socket.io-client": {
47
- "optional": true
48
- }
49
- }
50
- },
51
- "node_modules/@types/node": {
52
- "version": "20.10.0",
53
- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.0.tgz",
54
- "integrity": "sha512-D0WfRmU9TQ8I9PFx9Yc+EBHw+vSpIub4IDvQivcp26PtPrdMGAq5SDcpXEo/epqa/DXotVpekHiLNTg3iaKXBQ==",
55
- "dev": true,
56
- "dependencies": {
57
- "undici-types": "~5.26.4"
58
- }
59
- },
60
- "node_modules/prostgles-client": {
61
- "resolved": "..",
62
- "link": true
63
- },
64
- "node_modules/undici-types": {
65
- "version": "5.26.5",
66
- "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
67
- "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
68
- "dev": true
69
- }
70
- }
71
- }
@@ -1,17 +0,0 @@
1
- {
2
- "name": "test",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "npm i && tsc && node --test dist/test.js"
8
- },
9
- "author": "",
10
- "license": "ISC",
11
- "dependencies": {
12
- "prostgles-client": "file:.."
13
- },
14
- "devDependencies": {
15
- "@types/node": "^20.10.0"
16
- }
17
- }
package/tests/test.ts DELETED
@@ -1,10 +0,0 @@
1
- import { strict as assert } from 'assert';
2
- import { SyncedTable } from "prostgles-client";
3
- import { useEffectAsync, useIsMounted, __prglReactInstalled } from "prostgles-client/dist/react-hooks";
4
- import { test } from 'node:test';
5
-
6
- test("exports work", () => {
7
- const exportedTypes = Array.from(new Set([useEffectAsync, useIsMounted, SyncedTable].map(v => typeof v)));
8
- assert.equal(exportedTypes.join(), "function");
9
- assert.equal(typeof __prglReactInstalled(), "boolean");
10
- });
@@ -1,27 +0,0 @@
1
- {
2
- "files": ["test.ts"],
3
- "compilerOptions": {
4
- "baseUrl": ".",
5
- "target": "es2019",
6
- "lib": [
7
- "es6",
8
- "dom",
9
- "es2017",
10
- "es2019"
11
- ],
12
- "strict": true,
13
- "module": "commonjs",
14
- "resolveJsonModule": true,
15
- "rootDir": "./",
16
- "outDir": "dist",
17
- "noImplicitAny": false,
18
- "declaration": true,
19
- "declarationMap": true,
20
- "ignoreDeprecations": "5.0",
21
- "skipLibCheck": true,
22
- "noUncheckedIndexedAccess": false
23
- },
24
- "exclude": [
25
- "node_modules"
26
- ]
27
- }