@squidcloud/local-backend 1.0.65 → 1.0.67

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 (182) hide show
  1. package/dist/common/src/ai-assistant.context.d.ts +13 -13
  2. package/dist/common/src/ai-assistant.context.js +19 -19
  3. package/dist/common/src/ai-assistant.schemas.d.ts +243 -243
  4. package/dist/common/src/ai-assistant.schemas.js +210 -210
  5. package/dist/common/src/ai-assistant.types.d.ts +90 -90
  6. package/dist/common/src/ai-assistant.types.js +11 -11
  7. package/dist/common/src/api-call.context.d.ts +13 -13
  8. package/dist/common/src/api-call.context.js +16 -16
  9. package/dist/common/src/api.types.d.ts +23 -23
  10. package/dist/common/src/api.types.js +2 -2
  11. package/dist/common/src/application.schemas.d.ts +1312 -1312
  12. package/dist/common/src/application.schemas.js +860 -860
  13. package/dist/common/src/application.types.d.ts +186 -186
  14. package/dist/common/src/application.types.js +89 -89
  15. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  16. package/dist/common/src/backend-function.schemas.js +12 -12
  17. package/dist/common/src/backend-function.types.d.ts +6 -6
  18. package/dist/common/src/backend-function.types.js +2 -2
  19. package/dist/common/src/backend-run.types.d.ts +54 -54
  20. package/dist/common/src/backend-run.types.js +96 -96
  21. package/dist/common/src/bundle-api.types.d.ts +63 -63
  22. package/dist/common/src/bundle-api.types.js +2 -2
  23. package/dist/common/src/bundle-data.types.d.ts +59 -59
  24. package/dist/common/src/bundle-data.types.js +2 -2
  25. package/dist/common/src/communication.types.d.ts +18 -18
  26. package/dist/common/src/communication.types.js +40 -40
  27. package/dist/common/src/context.types.d.ts +24 -24
  28. package/dist/common/src/context.types.js +2 -2
  29. package/dist/common/src/distributed-lock.context.d.ts +5 -5
  30. package/dist/common/src/distributed-lock.context.js +10 -10
  31. package/dist/common/src/document.types.d.ts +32 -32
  32. package/dist/common/src/document.types.js +50 -50
  33. package/dist/common/src/graphql.context.d.ts +14 -14
  34. package/dist/common/src/graphql.context.js +12 -12
  35. package/dist/common/src/graphql.types.d.ts +11 -11
  36. package/dist/common/src/graphql.types.js +34 -34
  37. package/dist/common/src/heartbeat.types.d.ts +4 -4
  38. package/dist/common/src/heartbeat.types.js +16 -16
  39. package/dist/common/src/http-status.enum.d.ts +50 -50
  40. package/dist/common/src/http-status.enum.js +54 -54
  41. package/dist/common/src/index.d.ts +55 -55
  42. package/dist/common/src/index.js +71 -71
  43. package/dist/common/src/integrations/ai_assistant.types.d.ts +24 -24
  44. package/dist/common/src/integrations/ai_assistant.types.js +2 -2
  45. package/dist/common/src/integrations/api.types.d.ts +80 -80
  46. package/dist/common/src/integrations/api.types.js +2 -2
  47. package/dist/common/src/integrations/auth.types.d.ts +39 -39
  48. package/dist/common/src/integrations/auth.types.js +2 -2
  49. package/dist/common/src/integrations/database.types.d.ts +231 -231
  50. package/dist/common/src/integrations/database.types.js +2 -2
  51. package/dist/common/src/integrations/index.d.ts +124 -124
  52. package/dist/common/src/integrations/index.js +111 -111
  53. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  54. package/dist/common/src/integrations/observability.types.js +23 -23
  55. package/dist/common/src/logger.types.d.ts +21 -21
  56. package/dist/common/src/logger.types.js +11 -11
  57. package/dist/common/src/metrics.types.d.ts +73 -73
  58. package/dist/common/src/metrics.types.js +11 -11
  59. package/dist/common/src/mutation.context.d.ts +13 -13
  60. package/dist/common/src/mutation.context.js +26 -26
  61. package/dist/common/src/mutation.schemas.d.ts +5 -5
  62. package/dist/common/src/mutation.schemas.js +114 -114
  63. package/dist/common/src/mutation.types.d.ts +63 -63
  64. package/dist/common/src/mutation.types.js +142 -142
  65. package/dist/common/src/named-query.context.d.ts +4 -4
  66. package/dist/common/src/named-query.context.js +9 -9
  67. package/dist/common/src/named-query.schemas.d.ts +3 -3
  68. package/dist/common/src/named-query.schemas.js +13 -13
  69. package/dist/common/src/named-query.types.d.ts +8 -8
  70. package/dist/common/src/named-query.types.js +2 -2
  71. package/dist/common/src/query/base-query-builder.d.ts +37 -37
  72. package/dist/common/src/query/base-query-builder.js +36 -36
  73. package/dist/common/src/query/index.d.ts +4 -4
  74. package/dist/common/src/query/index.js +20 -20
  75. package/dist/common/src/query/pagination.d.ts +42 -42
  76. package/dist/common/src/query/pagination.js +164 -164
  77. package/dist/common/src/query/query-context.d.ts +47 -47
  78. package/dist/common/src/query/query-context.js +159 -159
  79. package/dist/common/src/query/serialized-query.types.d.ts +24 -24
  80. package/dist/common/src/query/serialized-query.types.js +2 -2
  81. package/dist/common/src/query.types.d.ts +86 -86
  82. package/dist/common/src/query.types.js +153 -153
  83. package/dist/common/src/regions.d.ts +21 -21
  84. package/dist/common/src/regions.js +46 -46
  85. package/dist/common/src/schema/schema.types.d.ts +30 -30
  86. package/dist/common/src/schema/schema.types.js +172 -172
  87. package/dist/common/src/secret.schemas.d.ts +6 -6
  88. package/dist/common/src/secret.schemas.js +38 -32
  89. package/dist/common/src/secret.schemas.js.map +1 -1
  90. package/dist/common/src/secret.types.d.ts +49 -49
  91. package/dist/common/src/secret.types.js +5 -5
  92. package/dist/common/src/security.types.d.ts +3 -3
  93. package/dist/common/src/security.types.js +2 -2
  94. package/dist/common/src/socket.schemas.d.ts +3 -3
  95. package/dist/common/src/socket.schemas.js +58 -58
  96. package/dist/common/src/socket.types.d.ts +112 -112
  97. package/dist/common/src/socket.types.js +2 -2
  98. package/dist/common/src/time-units.d.ts +5 -5
  99. package/dist/common/src/time-units.js +8 -8
  100. package/dist/common/src/trigger.types.d.ts +15 -15
  101. package/dist/common/src/trigger.types.js +2 -2
  102. package/dist/common/src/types.d.ts +21 -21
  103. package/dist/common/src/types.js +2 -2
  104. package/dist/common/src/utils/array.d.ts +8 -8
  105. package/dist/common/src/utils/array.js +54 -54
  106. package/dist/common/src/utils/assert.d.ts +8 -8
  107. package/dist/common/src/utils/assert.js +49 -49
  108. package/dist/common/src/utils/error.d.ts +4 -4
  109. package/dist/common/src/utils/error.js +10 -10
  110. package/dist/common/src/utils/global.utils.d.ts +10 -10
  111. package/dist/common/src/utils/global.utils.js +46 -46
  112. package/dist/common/src/utils/http.d.ts +2 -2
  113. package/dist/common/src/utils/http.js +41 -40
  114. package/dist/common/src/utils/http.js.map +1 -1
  115. package/dist/common/src/utils/id.d.ts +2 -2
  116. package/dist/common/src/utils/id.js +21 -21
  117. package/dist/common/src/utils/lock.manager.d.ts +9 -9
  118. package/dist/common/src/utils/lock.manager.js +39 -39
  119. package/dist/common/src/utils/nullish.d.ts +2 -2
  120. package/dist/common/src/utils/nullish.js +11 -11
  121. package/dist/common/src/utils/object.d.ts +5 -5
  122. package/dist/common/src/utils/object.js +75 -75
  123. package/dist/common/src/utils/serialization.d.ts +6 -6
  124. package/dist/common/src/utils/serialization.js +77 -77
  125. package/dist/common/src/utils/transforms.d.ts +18 -18
  126. package/dist/common/src/utils/transforms.js +92 -92
  127. package/dist/common/src/utils/url.d.ts +1 -1
  128. package/dist/common/src/utils/url.js +15 -15
  129. package/dist/common/src/utils/validation.d.ts +17 -17
  130. package/dist/common/src/utils/validation.js +209 -209
  131. package/dist/common/src/webhook-response.d.ts +6 -6
  132. package/dist/common/src/webhook-response.js +2 -2
  133. package/dist/common/src/websocket.impl.d.ts +21 -21
  134. package/dist/common/src/websocket.impl.js +76 -76
  135. package/dist/internal-common/src/async-queue.d.ts +4 -4
  136. package/dist/internal-common/src/async-queue.js +17 -17
  137. package/dist/internal-common/src/code-executor.types.d.ts +13 -13
  138. package/dist/internal-common/src/code-executor.types.js +2 -2
  139. package/dist/internal-common/src/dao.types.d.ts +46 -46
  140. package/dist/internal-common/src/dao.types.js +2 -2
  141. package/dist/internal-common/src/environment/environment.types.d.ts +74 -74
  142. package/dist/internal-common/src/environment/environment.types.js +2 -2
  143. package/dist/internal-common/src/environment/index.d.ts +6 -6
  144. package/dist/internal-common/src/environment/index.js +27 -27
  145. package/dist/internal-common/src/environment/local.environment.d.ts +2 -2
  146. package/dist/internal-common/src/environment/local.environment.js +62 -62
  147. package/dist/internal-common/src/filters/custom-exception.filter.d.ts +6 -6
  148. package/dist/internal-common/src/filters/custom-exception.filter.js +44 -44
  149. package/dist/internal-common/src/index.d.ts +14 -14
  150. package/dist/internal-common/src/index.js +32 -32
  151. package/dist/internal-common/src/interceptors/body.interceptor.d.ts +5 -5
  152. package/dist/internal-common/src/interceptors/body.interceptor.js +24 -24
  153. package/dist/internal-common/src/kafka/kafka.manager.d.ts +22 -22
  154. package/dist/internal-common/src/kafka/kafka.manager.js +129 -129
  155. package/dist/internal-common/src/kafka/kafka.types.d.ts +17 -17
  156. package/dist/internal-common/src/kafka/kafka.types.js +2 -2
  157. package/dist/internal-common/src/kafka-observability-publisher.d.ts +11 -11
  158. package/dist/internal-common/src/kafka-observability-publisher.js +20 -20
  159. package/dist/internal-common/src/local-dev.types.d.ts +35 -35
  160. package/dist/internal-common/src/local-dev.types.js +2 -2
  161. package/dist/internal-common/src/observability-publisher.d.ts +9 -9
  162. package/dist/internal-common/src/observability-publisher.js +58 -58
  163. package/dist/internal-common/src/observability.types.d.ts +17 -17
  164. package/dist/internal-common/src/observability.types.js +2 -2
  165. package/dist/internal-common/src/shutdown.manager.d.ts +20 -20
  166. package/dist/internal-common/src/shutdown.manager.js +75 -75
  167. package/dist/internal-common/src/utils.d.ts +5 -5
  168. package/dist/internal-common/src/utils.js +29 -29
  169. package/dist/local-backend/src/index.d.ts +4 -4
  170. package/dist/local-backend/src/index.js +20 -20
  171. package/dist/local-backend/src/local-backend-socket.service.d.ts +19 -19
  172. package/dist/local-backend/src/local-backend-socket.service.js +110 -110
  173. package/dist/local-backend/src/local-backend.app.d.ts +2 -2
  174. package/dist/local-backend/src/local-backend.app.js +19 -19
  175. package/dist/local-backend/src/local-backend.controller.d.ts +8 -8
  176. package/dist/local-backend/src/local-backend.controller.js +49 -49
  177. package/dist/local-backend/src/local-backend.module.d.ts +8 -8
  178. package/dist/local-backend/src/local-backend.module.js +53 -53
  179. package/dist/local-backend/src/local-backend.service.d.ts +15 -15
  180. package/dist/local-backend/src/local-backend.service.js +165 -165
  181. package/dist/tsconfig.build.tsbuildinfo +1 -1
  182. package/package.json +1 -1
@@ -1,160 +1,160 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryContext = void 0;
4
- const _ = require("lodash");
5
- const lodash_1 = require("lodash");
6
- const query_types_1 = require("../query.types");
7
- const CompareTable = {
8
- 'in:in': (a, b) => a.every((c) => b.includes(c)),
9
- 'in:not in': (a, b) => a.every((c) => !b.includes(c)),
10
- 'not in:not in': (a, b) => b.every((c) => a.includes(c)),
11
- '>:not in': (a, b) => b.every((c) => a >= c),
12
- '>=:not in': (a, b) => b.every((c) => a > c),
13
- '<:not in': (a, b) => b.every((c) => a <= c),
14
- '<=:not in': (a, b) => b.every((c) => a < c),
15
- '>:>': (a, b) => a >= b,
16
- '>=:>': (a, b) => a > b,
17
- 'in:>': (a, b) => a.every((c) => c > b),
18
- '>:>=': (a, b) => a >= b,
19
- '>=:>=': (a, b) => a >= b,
20
- 'in:>=': (a, b) => a.every((c) => c >= b),
21
- '<:<': (a, b) => a <= b,
22
- '<=:<': (a, b) => a < b,
23
- 'in:<': (a, b) => a.every((c) => c < b),
24
- '<:<=': (a, b) => a <= b,
25
- '<=:<=': (a, b) => a <= b,
26
- 'in:<=': (a, b) => a.every((c) => c <= b),
27
- };
28
- class QueryContext {
29
- constructor(query) {
30
- this.query = query;
31
- this.query = query;
32
- this.parsedConditions = this.parseConditions(this.query.conditions.filter(query_types_1.isSimpleCondition));
33
- }
34
- get integrationId() {
35
- return this.query.integrationId;
36
- }
37
- get collectionName() {
38
- return this.query.collectionName;
39
- }
40
- get limit() {
41
- return this.query.limit;
42
- }
43
- sortedBy(sorts) {
44
- const mismatch = sorts.find((fieldSort, index) => {
45
- var _a;
46
- return !(0, lodash_1.isEqual)(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
47
- });
48
- return !mismatch;
49
- }
50
- sortedByExact(sorts) {
51
- if (sorts.length !== this.query.sortOrder.length)
52
- return false;
53
- return this.sortedBy(sorts);
54
- }
55
- isSubqueryOf(fieldName, operator, value) {
56
- return this.isSubqueryOfCondition({
57
- fieldName,
58
- operator,
59
- value,
60
- });
61
- }
62
- isSubqueryOfCondition(condition) {
63
- const conditions = this.parsedConditions.filter((c) => c.fieldName === condition.fieldName);
64
- return !!conditions.find((c) => this.evaluateSubset(c, condition));
65
- }
66
- isSubqueryOfConditions(conditions) {
67
- const parsedConditions = this.parseConditions(conditions);
68
- return parsedConditions.every((c) => this.isSubqueryOfCondition(c));
69
- }
70
- isSubqueryOfQuery(query) {
71
- if (query.collectionName !== this.collectionName || query.integrationId !== this.integrationId)
72
- return false;
73
- const simpleConditions = query.conditions.filter(query_types_1.isSimpleCondition);
74
- const subsetOfConditions = this.isSubqueryOfConditions(simpleConditions);
75
- const subsetOfOrder = this.sortedBy(query.sortOrder);
76
- const withinLimit = query.limit === -1 || (this.limit > -1 && this.limit < query.limit);
77
- return subsetOfConditions && subsetOfOrder && withinLimit;
78
- }
79
- getConditionsFor(...fieldNames) {
80
- return this.parsedConditions.filter((cond) => fieldNames.includes(cond.fieldName));
81
- }
82
- getConditionsForField(fieldName) {
83
- return this.parsedConditions.filter((cond) => cond.fieldName === fieldName);
84
- }
85
- documentMatchesQuery(doc) {
86
- for (const contextCondition of this.parsedConditions) {
87
- const fieldNameOrPath = contextCondition.fieldName;
88
- const operator = contextCondition.operator;
89
- const valueInDoc = _.get(doc, fieldNameOrPath);
90
- if (operator === 'in') {
91
- if (contextCondition.value.includes(valueInDoc)) {
92
- continue;
93
- }
94
- return false;
95
- }
96
- else if (operator === 'not in') {
97
- if (contextCondition.value.includes(valueInDoc)) {
98
- return false;
99
- }
100
- continue;
101
- }
102
- if (!(0, query_types_1.compareOperator)(contextCondition.value, valueInDoc, operator)) {
103
- return false;
104
- }
105
- }
106
- return true;
107
- }
108
- evaluateSubset(queryCondition, testCondition) {
109
- const { operator: queryOperator, value: queryValue } = queryCondition;
110
- const { operator, value } = this.parseConditions([testCondition])[0];
111
- const compareFunction = CompareTable[`${queryOperator}:${operator}`];
112
- if (!compareFunction)
113
- return false;
114
- return compareFunction(queryValue, value);
115
- }
116
- evaluateIncludes(queryCondition, testCondition) {
117
- const { operator: queryOperator, value: queryValue } = queryCondition;
118
- const { operator, value } = this.parseConditions([testCondition])[0];
119
- const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
120
- const sortedValue = Array.isArray(value) ? value.sort() : value;
121
- return operator === queryOperator && (0, lodash_1.isEqual)(sortedValue, sortedQueryValue);
122
- }
123
- parseConditions(conditions) {
124
- const parsedConditions = [];
125
- const inMap = new Map();
126
- const notInMap = new Map();
127
- conditions.forEach((c) => {
128
- switch (c.operator) {
129
- case '==':
130
- case 'in':
131
- inMap.set(c.fieldName, (inMap.get(c.fieldName) || []).concat(c.value));
132
- break;
133
- case '!=':
134
- case 'not in':
135
- notInMap.set(c.fieldName, (notInMap.get(c.fieldName) || []).concat(c.value));
136
- break;
137
- default:
138
- parsedConditions.push(c);
139
- break;
140
- }
141
- });
142
- inMap.forEach((value, fieldName) => {
143
- parsedConditions.push({
144
- fieldName: fieldName,
145
- operator: 'in',
146
- value: value,
147
- });
148
- });
149
- notInMap.forEach((value, fieldName) => {
150
- parsedConditions.push({
151
- fieldName: fieldName,
152
- operator: 'not in',
153
- value: value,
154
- });
155
- });
156
- return parsedConditions;
157
- }
158
- }
159
- exports.QueryContext = QueryContext;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryContext = void 0;
4
+ const _ = require("lodash");
5
+ const lodash_1 = require("lodash");
6
+ const query_types_1 = require("../query.types");
7
+ const CompareTable = {
8
+ 'in:in': (a, b) => a.every((c) => b.includes(c)),
9
+ 'in:not in': (a, b) => a.every((c) => !b.includes(c)),
10
+ 'not in:not in': (a, b) => b.every((c) => a.includes(c)),
11
+ '>:not in': (a, b) => b.every((c) => a >= c),
12
+ '>=:not in': (a, b) => b.every((c) => a > c),
13
+ '<:not in': (a, b) => b.every((c) => a <= c),
14
+ '<=:not in': (a, b) => b.every((c) => a < c),
15
+ '>:>': (a, b) => a >= b,
16
+ '>=:>': (a, b) => a > b,
17
+ 'in:>': (a, b) => a.every((c) => c > b),
18
+ '>:>=': (a, b) => a >= b,
19
+ '>=:>=': (a, b) => a >= b,
20
+ 'in:>=': (a, b) => a.every((c) => c >= b),
21
+ '<:<': (a, b) => a <= b,
22
+ '<=:<': (a, b) => a < b,
23
+ 'in:<': (a, b) => a.every((c) => c < b),
24
+ '<:<=': (a, b) => a <= b,
25
+ '<=:<=': (a, b) => a <= b,
26
+ 'in:<=': (a, b) => a.every((c) => c <= b),
27
+ };
28
+ class QueryContext {
29
+ constructor(query) {
30
+ this.query = query;
31
+ this.query = query;
32
+ this.parsedConditions = this.parseConditions(this.query.conditions.filter(query_types_1.isSimpleCondition));
33
+ }
34
+ get integrationId() {
35
+ return this.query.integrationId;
36
+ }
37
+ get collectionName() {
38
+ return this.query.collectionName;
39
+ }
40
+ get limit() {
41
+ return this.query.limit;
42
+ }
43
+ sortedBy(sorts) {
44
+ const mismatch = sorts.find((fieldSort, index) => {
45
+ var _a;
46
+ return !(0, lodash_1.isEqual)(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
47
+ });
48
+ return !mismatch;
49
+ }
50
+ sortedByExact(sorts) {
51
+ if (sorts.length !== this.query.sortOrder.length)
52
+ return false;
53
+ return this.sortedBy(sorts);
54
+ }
55
+ isSubqueryOf(fieldName, operator, value) {
56
+ return this.isSubqueryOfCondition({
57
+ fieldName,
58
+ operator,
59
+ value,
60
+ });
61
+ }
62
+ isSubqueryOfCondition(condition) {
63
+ const conditions = this.parsedConditions.filter((c) => c.fieldName === condition.fieldName);
64
+ return !!conditions.find((c) => this.evaluateSubset(c, condition));
65
+ }
66
+ isSubqueryOfConditions(conditions) {
67
+ const parsedConditions = this.parseConditions(conditions);
68
+ return parsedConditions.every((c) => this.isSubqueryOfCondition(c));
69
+ }
70
+ isSubqueryOfQuery(query) {
71
+ if (query.collectionName !== this.collectionName || query.integrationId !== this.integrationId)
72
+ return false;
73
+ const simpleConditions = query.conditions.filter(query_types_1.isSimpleCondition);
74
+ const subsetOfConditions = this.isSubqueryOfConditions(simpleConditions);
75
+ const subsetOfOrder = this.sortedBy(query.sortOrder);
76
+ const withinLimit = query.limit === -1 || (this.limit > -1 && this.limit < query.limit);
77
+ return subsetOfConditions && subsetOfOrder && withinLimit;
78
+ }
79
+ getConditionsFor(...fieldNames) {
80
+ return this.parsedConditions.filter((cond) => fieldNames.includes(cond.fieldName));
81
+ }
82
+ getConditionsForField(fieldName) {
83
+ return this.parsedConditions.filter((cond) => cond.fieldName === fieldName);
84
+ }
85
+ documentMatchesQuery(doc) {
86
+ for (const contextCondition of this.parsedConditions) {
87
+ const fieldNameOrPath = contextCondition.fieldName;
88
+ const operator = contextCondition.operator;
89
+ const valueInDoc = _.get(doc, fieldNameOrPath);
90
+ if (operator === 'in') {
91
+ if (contextCondition.value.includes(valueInDoc)) {
92
+ continue;
93
+ }
94
+ return false;
95
+ }
96
+ else if (operator === 'not in') {
97
+ if (contextCondition.value.includes(valueInDoc)) {
98
+ return false;
99
+ }
100
+ continue;
101
+ }
102
+ if (!(0, query_types_1.compareOperator)(contextCondition.value, valueInDoc, operator)) {
103
+ return false;
104
+ }
105
+ }
106
+ return true;
107
+ }
108
+ evaluateSubset(queryCondition, testCondition) {
109
+ const { operator: queryOperator, value: queryValue } = queryCondition;
110
+ const { operator, value } = this.parseConditions([testCondition])[0];
111
+ const compareFunction = CompareTable[`${queryOperator}:${operator}`];
112
+ if (!compareFunction)
113
+ return false;
114
+ return compareFunction(queryValue, value);
115
+ }
116
+ evaluateIncludes(queryCondition, testCondition) {
117
+ const { operator: queryOperator, value: queryValue } = queryCondition;
118
+ const { operator, value } = this.parseConditions([testCondition])[0];
119
+ const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
120
+ const sortedValue = Array.isArray(value) ? value.sort() : value;
121
+ return operator === queryOperator && (0, lodash_1.isEqual)(sortedValue, sortedQueryValue);
122
+ }
123
+ parseConditions(conditions) {
124
+ const parsedConditions = [];
125
+ const inMap = new Map();
126
+ const notInMap = new Map();
127
+ conditions.forEach((c) => {
128
+ switch (c.operator) {
129
+ case '==':
130
+ case 'in':
131
+ inMap.set(c.fieldName, (inMap.get(c.fieldName) || []).concat(c.value));
132
+ break;
133
+ case '!=':
134
+ case 'not in':
135
+ notInMap.set(c.fieldName, (notInMap.get(c.fieldName) || []).concat(c.value));
136
+ break;
137
+ default:
138
+ parsedConditions.push(c);
139
+ break;
140
+ }
141
+ });
142
+ inMap.forEach((value, fieldName) => {
143
+ parsedConditions.push({
144
+ fieldName: fieldName,
145
+ operator: 'in',
146
+ value: value,
147
+ });
148
+ });
149
+ notInMap.forEach((value, fieldName) => {
150
+ parsedConditions.push({
151
+ fieldName: fieldName,
152
+ operator: 'not in',
153
+ value: value,
154
+ });
155
+ });
156
+ return parsedConditions;
157
+ }
158
+ }
159
+ exports.QueryContext = QueryContext;
160
160
  //# sourceMappingURL=query-context.js.map
@@ -1,24 +1,24 @@
1
- import { DocumentData } from '../document.types';
2
- import { Query, Alias, JoinCondition } from '../query.types';
3
- export type SerializedSimpleQuery = {
4
- type: 'simple';
5
- query: Query;
6
- dereference: boolean;
7
- };
8
- export type SerializedJoinQuery = {
9
- type: 'join';
10
- grouped: boolean;
11
- dereference: boolean;
12
- root: {
13
- alias: Alias;
14
- query: Query;
15
- };
16
- leftToRight: Record<Alias, Alias[]>;
17
- joins: Record<Alias, Query<DocumentData>>;
18
- joinConditions: Record<Alias, JoinCondition>;
19
- };
20
- export type SerializedMergedQuery = {
21
- type: 'merged';
22
- queries: Array<SerializedQuery>;
23
- };
24
- export type SerializedQuery = SerializedSimpleQuery | SerializedJoinQuery | SerializedMergedQuery;
1
+ import { DocumentData } from '../document.types';
2
+ import { Query, Alias, JoinCondition } from '../query.types';
3
+ export type SerializedSimpleQuery = {
4
+ type: 'simple';
5
+ query: Query;
6
+ dereference: boolean;
7
+ };
8
+ export type SerializedJoinQuery = {
9
+ type: 'join';
10
+ grouped: boolean;
11
+ dereference: boolean;
12
+ root: {
13
+ alias: Alias;
14
+ query: Query;
15
+ };
16
+ leftToRight: Record<Alias, Alias[]>;
17
+ joins: Record<Alias, Query<DocumentData>>;
18
+ joinConditions: Record<Alias, JoinCondition>;
19
+ };
20
+ export type SerializedMergedQuery = {
21
+ type: 'merged';
22
+ queries: Array<SerializedQuery>;
23
+ };
24
+ export type SerializedQuery = SerializedSimpleQuery | SerializedJoinQuery | SerializedMergedQuery;
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=serialized-query.types.js.map
@@ -1,86 +1,86 @@
1
- import { TriggerId } from './application.types';
2
- import { AppId, ClientId, ClientRequestId } from './communication.types';
3
- import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from './document.types';
4
- import { Paths } from './types';
5
- export type Alias = string;
6
- export interface JoinCondition {
7
- leftAlias: Alias;
8
- left: FieldName;
9
- right: FieldName;
10
- isInner: boolean;
11
- }
12
- export type Condition<Doc extends DocumentData = any> = SimpleCondition<Doc> | CompositeCondition<Doc>;
13
- export type Conditions<Doc extends DocumentData = any> = Array<Condition<Doc>>;
14
- export interface SimpleCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>, MyOperator = Operator> {
15
- fieldName: F;
16
- operator: MyOperator;
17
- value: any;
18
- }
19
- export interface CompositeCondition<Doc extends DocumentData = any> {
20
- fields: Array<SimpleCondition<Doc, Paths<Doc>, CompositeConditionOperator>>;
21
- }
22
- export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
23
- type CompositeConditionOperator = '>=' | '<=' | '>' | '<';
24
- export type Operator = '==' | '!=' | CompositeConditionOperator | 'like' | 'not like' | 'like_cs' | 'not like_cs';
25
- export interface FieldSort<Doc> {
26
- fieldName: FieldName<Doc>;
27
- asc: boolean;
28
- }
29
- interface RegularQueryKey {
30
- queryType: 'query';
31
- clientId: string;
32
- clientRequestId: string;
33
- }
34
- interface TriggerKey {
35
- queryType: 'trigger';
36
- triggerId: TriggerId;
37
- }
38
- export type QueryKey = RegularQueryKey | TriggerKey;
39
- export interface Query<Doc extends DocumentData = any> {
40
- collectionName: CollectionName;
41
- integrationId: string;
42
- conditions: Conditions<Doc>;
43
- sortOrder: Array<FieldSort<Doc>>;
44
- limit: number;
45
- limitBy?: {
46
- limit: number;
47
- fields: Array<FieldName<Doc>>;
48
- reverseSort: boolean;
49
- };
50
- }
51
- export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
52
- export interface QueryRequest {
53
- clientRequestId: ClientRequestId;
54
- query: Query;
55
- subscribe: boolean;
56
- }
57
- export interface QueryUnsubscribeRequest {
58
- clientRequestId: ClientRequestId;
59
- }
60
- export interface QueryRegisterRequest {
61
- clientRequestId: ClientRequestId;
62
- query: Query;
63
- parentClientRequestId: ClientRequestId;
64
- }
65
- interface QueryMetadata {
66
- condCount: number;
67
- }
68
- export declare function encodeCondition(condition: Condition<any>): EncodedCondition;
69
- export type EncodedCondition = string;
70
- export type QueryMapping<QueryReferenceType extends string> = {
71
- unconditional: Array<QueryReferenceType>;
72
- conditional: Record<EncodedCondition, Array<QueryReferenceType>>;
73
- queriesMetadata: Record<QueryReferenceType, QueryMetadata>;
74
- };
75
- export declare abstract class QueryMappingManager<T> {
76
- abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
77
- abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
78
- abstract removeLocalDevAppData(appId: AppId): Promise<void>;
79
- }
80
- export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
81
- export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
82
- export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
83
- clientId: string;
84
- clientRequestId: string;
85
- };
86
- export {};
1
+ import { TriggerId } from './application.types';
2
+ import { AppId, ClientId, ClientRequestId } from './communication.types';
3
+ import { CollectionName, DocumentData, FieldName, PrimitiveFieldType } from './document.types';
4
+ import { Paths } from './types';
5
+ export type Alias = string;
6
+ export interface JoinCondition {
7
+ leftAlias: Alias;
8
+ left: FieldName;
9
+ right: FieldName;
10
+ isInner: boolean;
11
+ }
12
+ export type Condition<Doc extends DocumentData = any> = SimpleCondition<Doc> | CompositeCondition<Doc>;
13
+ export type Conditions<Doc extends DocumentData = any> = Array<Condition<Doc>>;
14
+ export interface SimpleCondition<Doc extends DocumentData = any, F extends Paths<Doc> = Paths<Doc>, MyOperator = Operator> {
15
+ fieldName: F;
16
+ operator: MyOperator;
17
+ value: any;
18
+ }
19
+ export interface CompositeCondition<Doc extends DocumentData = any> {
20
+ fields: Array<SimpleCondition<Doc, Paths<Doc>, CompositeConditionOperator>>;
21
+ }
22
+ export declare function isSimpleCondition(condition: Condition): condition is SimpleCondition;
23
+ type CompositeConditionOperator = '>=' | '<=' | '>' | '<';
24
+ export type Operator = '==' | '!=' | CompositeConditionOperator | 'like' | 'not like' | 'like_cs' | 'not like_cs';
25
+ export interface FieldSort<Doc> {
26
+ fieldName: FieldName<Doc>;
27
+ asc: boolean;
28
+ }
29
+ interface RegularQueryKey {
30
+ queryType: 'query';
31
+ clientId: string;
32
+ clientRequestId: string;
33
+ }
34
+ interface TriggerKey {
35
+ queryType: 'trigger';
36
+ triggerId: TriggerId;
37
+ }
38
+ export type QueryKey = RegularQueryKey | TriggerKey;
39
+ export interface Query<Doc extends DocumentData = any> {
40
+ collectionName: CollectionName;
41
+ integrationId: string;
42
+ conditions: Conditions<Doc>;
43
+ sortOrder: Array<FieldSort<Doc>>;
44
+ limit: number;
45
+ limitBy?: {
46
+ limit: number;
47
+ fields: Array<FieldName<Doc>>;
48
+ reverseSort: boolean;
49
+ };
50
+ }
51
+ export type QuerySubscriptionId = `${ClientId}_${ClientRequestId}`;
52
+ export interface QueryRequest {
53
+ clientRequestId: ClientRequestId;
54
+ query: Query;
55
+ subscribe: boolean;
56
+ }
57
+ export interface QueryUnsubscribeRequest {
58
+ clientRequestId: ClientRequestId;
59
+ }
60
+ export interface QueryRegisterRequest {
61
+ clientRequestId: ClientRequestId;
62
+ query: Query;
63
+ parentClientRequestId: ClientRequestId;
64
+ }
65
+ interface QueryMetadata {
66
+ condCount: number;
67
+ }
68
+ export declare function encodeCondition(condition: Condition<any>): EncodedCondition;
69
+ export type EncodedCondition = string;
70
+ export type QueryMapping<QueryReferenceType extends string> = {
71
+ unconditional: Array<QueryReferenceType>;
72
+ conditional: Record<EncodedCondition, Array<QueryReferenceType>>;
73
+ queriesMetadata: Record<QueryReferenceType, QueryMetadata>;
74
+ };
75
+ export declare abstract class QueryMappingManager<T> {
76
+ abstract addQuery(appId: AppId, query: Query, key: T): Promise<void>;
77
+ abstract removeQuery(appId: AppId, key: T): Promise<Query | undefined>;
78
+ abstract removeLocalDevAppData(appId: AppId): Promise<void>;
79
+ }
80
+ export declare function compareOperator(conditionValue: PrimitiveFieldType, valueInDocument: PrimitiveFieldType, operator: Operator): boolean;
81
+ export declare function getQuerySubscriptionId(clientId: string, clientRequestId: string): QuerySubscriptionId;
82
+ export declare function parseQuerySubscriptionId(querySubscriptionId: QuerySubscriptionId): {
83
+ clientId: string;
84
+ clientRequestId: string;
85
+ };
86
+ export {};