prostgles-server 3.0.44 → 3.0.46

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 (50) hide show
  1. package/README.md +20 -21
  2. package/dist/DboBuilder/QueryBuilder/Functions.d.ts +64 -0
  3. package/dist/DboBuilder/QueryBuilder/Functions.d.ts.map +1 -0
  4. package/dist/DboBuilder/QueryBuilder/Functions.js +940 -0
  5. package/dist/DboBuilder/QueryBuilder/Functions.js.map +1 -0
  6. package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts +1 -62
  7. package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -1
  8. package/dist/DboBuilder/QueryBuilder/QueryBuilder.js +6 -896
  9. package/dist/DboBuilder/QueryBuilder/QueryBuilder.js.map +1 -1
  10. package/dist/DboBuilder/TableHandler.d.ts.map +1 -1
  11. package/dist/DboBuilder/TableHandler.js +5 -6
  12. package/dist/DboBuilder/TableHandler.js.map +1 -1
  13. package/dist/DboBuilder/ViewHandler.d.ts.map +1 -1
  14. package/dist/DboBuilder/ViewHandler.js +4 -3
  15. package/dist/DboBuilder/ViewHandler.js.map +1 -1
  16. package/dist/DboBuilder/parseUpdateRules.d.ts.map +1 -1
  17. package/dist/DboBuilder/parseUpdateRules.js +5 -1
  18. package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
  19. package/dist/DboBuilder.d.ts +1 -1
  20. package/dist/DboBuilder.d.ts.map +1 -1
  21. package/dist/DboBuilder.js.map +1 -1
  22. package/dist/PubSubManager.d.ts.map +1 -1
  23. package/dist/PubSubManager.js +1 -13
  24. package/dist/PubSubManager.js.map +1 -1
  25. package/lib/DboBuilder/QueryBuilder/Functions.d.ts +64 -0
  26. package/lib/DboBuilder/QueryBuilder/Functions.d.ts.map +1 -0
  27. package/lib/DboBuilder/QueryBuilder/Functions.js +939 -0
  28. package/lib/DboBuilder/QueryBuilder/Functions.ts +1071 -0
  29. package/lib/DboBuilder/QueryBuilder/QueryBuilder.d.ts +1 -62
  30. package/lib/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -1
  31. package/lib/DboBuilder/QueryBuilder/QueryBuilder.js +6 -896
  32. package/lib/DboBuilder/QueryBuilder/QueryBuilder.ts +1 -1025
  33. package/lib/DboBuilder/TableHandler.d.ts.map +1 -1
  34. package/lib/DboBuilder/TableHandler.js +5 -6
  35. package/lib/DboBuilder/TableHandler.ts +7 -8
  36. package/lib/DboBuilder/ViewHandler.d.ts.map +1 -1
  37. package/lib/DboBuilder/ViewHandler.js +4 -3
  38. package/lib/DboBuilder/ViewHandler.ts +2 -1
  39. package/lib/DboBuilder/parseUpdateRules.d.ts.map +1 -1
  40. package/lib/DboBuilder/parseUpdateRules.js +5 -1
  41. package/lib/DboBuilder/parseUpdateRules.ts +8 -1
  42. package/lib/DboBuilder.d.ts +1 -1
  43. package/lib/DboBuilder.d.ts.map +1 -1
  44. package/lib/DboBuilder.ts +5 -9
  45. package/lib/PubSubManager.d.ts.map +1 -1
  46. package/lib/PubSubManager.js +1 -13
  47. package/lib/PubSubManager.ts +1 -13
  48. package/package.json +1 -1
  49. package/tests/client/PID.txt +1 -1
  50. package/tests/server/package-lock.json +1 -1
package/README.md CHANGED
@@ -14,8 +14,8 @@
14
14
 
15
15
  * CRUD operations
16
16
  * Subscriptions to data changes
17
- * Policies and Rules for client data access
18
- * Client-Server data replication
17
+ * Fine grained access control
18
+ * Optimistic data replication
19
19
  * Generated TypeScript Definition for Database schema
20
20
 
21
21
  ## Installation
@@ -80,31 +80,30 @@ prostgles({
80
80
 
81
81
  ./public/index.html
82
82
  ```html
83
-
84
-
83
+
85
84
  <!DOCTYPE html>
86
85
  <html>
87
- <head>
88
- <title> Prostgles </title>
86
+ <head>
87
+ <title> Prostgles </title>
88
+
89
+ <meta name="viewport" content="width=device-width, initial-scale=1">
90
+ <script src="https://unpkg.com/socket.io-client@latest/dist/socket.io.min.js" type="text/javascript"></script>
91
+ <script src="https://unpkg.com/prostgles-client@latest/dist/index.js" type="text/javascript"></script>
92
+ </head>
93
+ <body>
89
94
 
90
- <meta name="viewport" content="width=device-width, initial-scale=1">
91
- <script src="https://unpkg.com/socket.io-client@latest/dist/socket.io.min.js" type="text/javascript"></script>
92
- <script src="https://unpkg.com/prostgles-client@latest/dist/index.js" type="text/javascript"></script>
93
- </head>
94
- <body>
95
+ <script>
95
96
 
96
- <script>
97
+ prostgles({
98
+ socket: io(),
99
+ onReady: async (dbo, dbsMethods, schemaTables, auth) => {
97
100
 
98
- prostgles({
99
- socket: io(),
100
- onReady: async ({ db }) => {
101
+ }
102
+ });
101
103
 
102
- }
103
- });
104
-
105
- </script>
106
-
107
- </body>
104
+ </script>
105
+
106
+ </body>
108
107
  </html>
109
108
  ```
110
109
 
@@ -0,0 +1,64 @@
1
+ import { ColumnInfo, PG_COLUMN_UDT_DATA_TYPE } from "prostgles-types";
2
+ export declare const parseFunction: (funcData: {
3
+ func: string | FunctionSpec;
4
+ args: any[];
5
+ functions: FunctionSpec[];
6
+ allowedFields: string[];
7
+ }) => FunctionSpec;
8
+ declare type GetQueryArgs = {
9
+ allColumns: ColumnInfo[];
10
+ allowedFields: string[];
11
+ args: any[];
12
+ tableAlias?: string;
13
+ ctidField?: string;
14
+ };
15
+ export declare type FieldSpec = {
16
+ name: string;
17
+ type: "column" | "computed";
18
+ /**
19
+ * allowedFields passed for multicol functions (e.g.: $rowhash)
20
+ */
21
+ getQuery: (params: Omit<GetQueryArgs, "args">) => string;
22
+ };
23
+ export declare type FunctionSpec = {
24
+ name: string;
25
+ description?: string;
26
+ /**
27
+ * If true then it can be used in filters and is expected to return boolean
28
+ */
29
+ canBeUsedForFilter?: boolean;
30
+ /**
31
+ * If true then the first argument is expected to be a column name
32
+ */
33
+ singleColArg: boolean;
34
+ /**
35
+ * If true then this func can be used within where clause
36
+ */
37
+ /**
38
+ * Number of arguments expected
39
+ */
40
+ numArgs: number;
41
+ /**
42
+ * If provided then the number of column names provided to the function (from getFields()) must not be less than this
43
+ * By default every function is checked against numArgs
44
+ */
45
+ minCols?: number;
46
+ type: "function" | "aggregation" | "computed";
47
+ /**
48
+ * getFields: string[] -> used to validate user supplied field names. It will be fired before querying to validate against allowed columns
49
+ * if not field names are used from arguments then return an empty array
50
+ */
51
+ getFields: (args: any[]) => "*" | string[];
52
+ /**
53
+ * allowedFields passed for multicol functions (e.g.: $rowhash)
54
+ */
55
+ getQuery: (params: GetQueryArgs) => string;
56
+ returnType?: PG_COLUMN_UDT_DATA_TYPE;
57
+ };
58
+ /**
59
+ * Each function expects a column at the very least
60
+ */
61
+ export declare const FUNCTIONS: FunctionSpec[];
62
+ export declare const COMPUTED_FIELDS: FieldSpec[];
63
+ export {};
64
+ //# sourceMappingURL=Functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Functions.d.ts","sourceRoot":"","sources":["../../../lib/DboBuilder/QueryBuilder/Functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,UAAU,EAAW,uBAAuB,EAAuC,MAAM,iBAAiB,CAAC;AAK5H,eAAO,MAAM,aAAa,aAAc;IAAE,IAAI,EAAE,MAAM,GAAG,YAAY,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAC;IAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAC;CAAE,KAAG,YA0C5I,CAAA;AAGD,aAAK,YAAY,GAAG;IAClB,UAAU,EAAE,UAAU,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC5B;;OAEG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,YA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