@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,210 +1,210 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasOnlyKeys = exports.isRightType = exports.isNotEmpty = exports.validateQueryLimit = exports.validateMutations = exports.validateOpenIdProviderType = exports.validateOpenIdProvider = exports.validateFieldSort = exports.ValidationError = void 0;
4
- const assert_1 = require("./assert");
5
- class ValidationError extends Error {
6
- constructor(error, statusCode, details) {
7
- super(error);
8
- this.statusCode = statusCode;
9
- this.details = details;
10
- }
11
- }
12
- exports.ValidationError = ValidationError;
13
- function validatePathPart(part) {
14
- if (!part || !part.match(/^[a-zA-Z][a-zA-Z0-9!@#$%^&*~_]{0,49}$/)) {
15
- throw new Error('A document id and a collection id can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting' +
16
- 'with a letter, at least one character, and up to 50.');
17
- }
18
- }
19
- function validateCollectionName(collectionName) {
20
- if (typeof collectionName !== 'string' || !collectionName) {
21
- throw new Error('Collection path has to be a non empty string');
22
- }
23
- validatePathPart(collectionName);
24
- }
25
- function validateFieldName(fieldName) {
26
- if (!fieldName || typeof fieldName !== 'string') {
27
- throw new Error('Field name has to be a non-empty string');
28
- }
29
- if (fieldName === '__docId__') {
30
- return;
31
- }
32
- if (!fieldName.match(/^[a-zA-Z_$][a-zA-Z0-9!@#$%^&*~_ ]{0,49}$/)) {
33
- throw new Error('A Field name can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting with a letter, at least one character, and up to 50. Field name: ' +
34
- fieldName);
35
- }
36
- }
37
- function validateQueryCondition(condition) {
38
- if (!condition) {
39
- throw new Error('Condition cannot be empty');
40
- }
41
- if (!condition.operator ||
42
- !['==', '!=', '>', '>=', '<', '<=', 'like', 'not like', 'like_cs', 'not like_cs'].includes(condition.operator)) {
43
- throw new Error('Unsupported operator: ' + condition.operator);
44
- }
45
- validateFieldName(condition.fieldName);
46
- }
47
- function validateFieldSort(fieldSort) {
48
- if (!(fieldSort instanceof Object)) {
49
- throw new Error('Field sort has to be an object');
50
- }
51
- (0, assert_1.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
52
- (0, assert_1.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
53
- validateFieldName(fieldSort.fieldName);
54
- }
55
- exports.validateFieldSort = validateFieldSort;
56
- function validateOpenIdProvider(openIdProvider) {
57
- (0, assert_1.assertTruthy)(openIdProvider, 'INVALID_PROVIDER');
58
- validateOpenIdProviderType(openIdProvider.providerType);
59
- (0, assert_1.assertTruthy)(openIdProvider.providerType, 'INVALID_CLIENT_ID');
60
- (0, assert_1.assertTruthy)(openIdProvider.clientId, 'INVALID_CLIENT_ID');
61
- (0, assert_1.assertTruthy)(openIdProvider.domain, 'INVALID_DOMAIN');
62
- return openIdProvider;
63
- }
64
- exports.validateOpenIdProvider = validateOpenIdProvider;
65
- function validateOpenIdProviderType(providerType) {
66
- const providerArray = ['auth0'];
67
- (0, assert_1.assertTruthy)(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
68
- }
69
- exports.validateOpenIdProviderType = validateOpenIdProviderType;
70
- function validateDeleteMutation(mutation) {
71
- if (!mutation || mutation.type !== 'delete') {
72
- throw new Error('Mutation has to be non empty with type delete.');
73
- }
74
- }
75
- function validateInsertMutation(mutation) {
76
- if (!mutation || mutation.type !== 'insert') {
77
- throw new Error('Mutation has to be non empty with type insert.');
78
- }
79
- if (!mutation.properties || typeof mutation.properties !== 'object') {
80
- throw new Error('The properties in insert mutation need to be a JSON object.');
81
- }
82
- for (const [fieldName] of Object.entries(mutation.properties)) {
83
- validateFieldName(fieldName);
84
- }
85
- }
86
- function validateUpdatePropertyMutation(propertyMutation) {
87
- if (!propertyMutation || propertyMutation.type !== 'update') {
88
- throw new Error('Update value property mutation has to be of type update');
89
- }
90
- if (propertyMutation.value === undefined) {
91
- throw new Error('Value has to exist in an update value property mutation..');
92
- }
93
- }
94
- function validateApplyNumericFnPropertyMutation(propertyMutation) {
95
- if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
96
- throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
97
- }
98
- if (!['increment'].includes(propertyMutation.fn)) {
99
- throw new Error('Invalid fn for apply numeric fn.');
100
- }
101
- if (typeof propertyMutation.value !== 'number') {
102
- throw new Error('The value in an apply numeric fn function has to be numeric.');
103
- }
104
- }
105
- function validateApplyStringFnPropertyMutation(propertyMutation) {
106
- if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
107
- throw new Error('Apply string fn mutation has to be of type applyStringFn');
108
- }
109
- if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
110
- throw new Error('Invalid fn for apply string fn.');
111
- }
112
- if (typeof propertyMutation.value !== 'string') {
113
- throw new Error('The value in an apply string fn function has to be a string.');
114
- }
115
- }
116
- function validatePropertyMutation(propertyMutation) {
117
- if (!propertyMutation || typeof propertyMutation !== 'object') {
118
- throw new Error('Property mutation need to be a JSON object.');
119
- }
120
- if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
121
- throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
122
- }
123
- switch (propertyMutation.type) {
124
- case 'update':
125
- validateUpdatePropertyMutation(propertyMutation);
126
- break;
127
- case 'applyNumericFn':
128
- validateApplyNumericFnPropertyMutation(propertyMutation);
129
- break;
130
- case 'applyStringFn':
131
- validateApplyStringFnPropertyMutation(propertyMutation);
132
- break;
133
- }
134
- }
135
- function validateUpdateMutation(mutation) {
136
- if (!mutation || mutation.type !== 'update') {
137
- throw new Error('Mutation has to be non empty with type update.');
138
- }
139
- if (!mutation.properties || typeof mutation.properties !== 'object') {
140
- throw new Error('The properties in update mutation need to be a JSON object.');
141
- }
142
- const entries = Object.entries(mutation.properties);
143
- for (const [fieldName, propertyMutations] of entries) {
144
- validateFieldName(fieldName);
145
- for (const propertyMutation of propertyMutations) {
146
- validatePropertyMutation(propertyMutation);
147
- }
148
- }
149
- }
150
- function validateMutation(mutation) {
151
- if (!mutation) {
152
- throw new Error('Mutation cannot be empty');
153
- }
154
- if (!['insert', 'delete', 'update'].includes(mutation.type)) {
155
- throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
156
- }
157
- validateCollectionName(mutation.squidDocIdObj.collectionName);
158
- validatePathPart(mutation.squidDocIdObj.docId);
159
- switch (mutation.type) {
160
- case 'delete':
161
- validateDeleteMutation(mutation);
162
- break;
163
- case 'insert':
164
- validateInsertMutation(mutation);
165
- break;
166
- case 'update':
167
- validateUpdateMutation(mutation);
168
- break;
169
- }
170
- }
171
- function validateMutations(mutations) {
172
- if (!mutations || !(mutations instanceof Array) || !mutations.length) {
173
- throw new Error('The list of mutations has to be a non-empty array.');
174
- }
175
- for (const mutation of mutations) {
176
- validateMutation(mutation);
177
- }
178
- }
179
- exports.validateMutations = validateMutations;
180
- function validateQueryLimit(limit) {
181
- (0, assert_1.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
182
- if (limit === -1)
183
- return;
184
- (0, assert_1.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
185
- (0, assert_1.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
186
- (0, assert_1.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
187
- }
188
- exports.validateQueryLimit = validateQueryLimit;
189
- function isNotEmpty(value) {
190
- validateCorrectStringType(value);
191
- return typeof value === 'string' && !!value;
192
- }
193
- exports.isNotEmpty = isNotEmpty;
194
- function validateCorrectStringType(value) {
195
- if (value !== null && value !== undefined && typeof value !== 'string') {
196
- throw new Error(`Unexpected input type ${typeof value}`);
197
- }
198
- }
199
- function isRightType(value, type) {
200
- if (Array.isArray(value)) {
201
- return value.every((element) => typeof element === type);
202
- }
203
- return typeof value === type;
204
- }
205
- exports.isRightType = isRightType;
206
- function hasOnlyKeys(obj, keys) {
207
- return !Array.isArray(obj) && [...Object.keys(obj)].every((key) => keys.includes(key));
208
- }
209
- exports.hasOnlyKeys = hasOnlyKeys;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasOnlyKeys = exports.isRightType = exports.isNotEmpty = exports.validateQueryLimit = exports.validateMutations = exports.validateOpenIdProviderType = exports.validateOpenIdProvider = exports.validateFieldSort = exports.ValidationError = void 0;
4
+ const assert_1 = require("./assert");
5
+ class ValidationError extends Error {
6
+ constructor(error, statusCode, details) {
7
+ super(error);
8
+ this.statusCode = statusCode;
9
+ this.details = details;
10
+ }
11
+ }
12
+ exports.ValidationError = ValidationError;
13
+ function validatePathPart(part) {
14
+ if (!part || !part.match(/^[a-zA-Z][a-zA-Z0-9!@#$%^&*~_]{0,49}$/)) {
15
+ throw new Error('A document id and a collection id can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting' +
16
+ 'with a letter, at least one character, and up to 50.');
17
+ }
18
+ }
19
+ function validateCollectionName(collectionName) {
20
+ if (typeof collectionName !== 'string' || !collectionName) {
21
+ throw new Error('Collection path has to be a non empty string');
22
+ }
23
+ validatePathPart(collectionName);
24
+ }
25
+ function validateFieldName(fieldName) {
26
+ if (!fieldName || typeof fieldName !== 'string') {
27
+ throw new Error('Field name has to be a non-empty string');
28
+ }
29
+ if (fieldName === '__docId__') {
30
+ return;
31
+ }
32
+ if (!fieldName.match(/^[a-zA-Z_$][a-zA-Z0-9!@#$%^&*~_ ]{0,49}$/)) {
33
+ throw new Error('A Field name can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting with a letter, at least one character, and up to 50. Field name: ' +
34
+ fieldName);
35
+ }
36
+ }
37
+ function validateQueryCondition(condition) {
38
+ if (!condition) {
39
+ throw new Error('Condition cannot be empty');
40
+ }
41
+ if (!condition.operator ||
42
+ !['==', '!=', '>', '>=', '<', '<=', 'like', 'not like', 'like_cs', 'not like_cs'].includes(condition.operator)) {
43
+ throw new Error('Unsupported operator: ' + condition.operator);
44
+ }
45
+ validateFieldName(condition.fieldName);
46
+ }
47
+ function validateFieldSort(fieldSort) {
48
+ if (!(fieldSort instanceof Object)) {
49
+ throw new Error('Field sort has to be an object');
50
+ }
51
+ (0, assert_1.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
52
+ (0, assert_1.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
53
+ validateFieldName(fieldSort.fieldName);
54
+ }
55
+ exports.validateFieldSort = validateFieldSort;
56
+ function validateOpenIdProvider(openIdProvider) {
57
+ (0, assert_1.assertTruthy)(openIdProvider, 'INVALID_PROVIDER');
58
+ validateOpenIdProviderType(openIdProvider.providerType);
59
+ (0, assert_1.assertTruthy)(openIdProvider.providerType, 'INVALID_CLIENT_ID');
60
+ (0, assert_1.assertTruthy)(openIdProvider.clientId, 'INVALID_CLIENT_ID');
61
+ (0, assert_1.assertTruthy)(openIdProvider.domain, 'INVALID_DOMAIN');
62
+ return openIdProvider;
63
+ }
64
+ exports.validateOpenIdProvider = validateOpenIdProvider;
65
+ function validateOpenIdProviderType(providerType) {
66
+ const providerArray = ['auth0'];
67
+ (0, assert_1.assertTruthy)(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
68
+ }
69
+ exports.validateOpenIdProviderType = validateOpenIdProviderType;
70
+ function validateDeleteMutation(mutation) {
71
+ if (!mutation || mutation.type !== 'delete') {
72
+ throw new Error('Mutation has to be non empty with type delete.');
73
+ }
74
+ }
75
+ function validateInsertMutation(mutation) {
76
+ if (!mutation || mutation.type !== 'insert') {
77
+ throw new Error('Mutation has to be non empty with type insert.');
78
+ }
79
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
80
+ throw new Error('The properties in insert mutation need to be a JSON object.');
81
+ }
82
+ for (const [fieldName] of Object.entries(mutation.properties)) {
83
+ validateFieldName(fieldName);
84
+ }
85
+ }
86
+ function validateUpdatePropertyMutation(propertyMutation) {
87
+ if (!propertyMutation || propertyMutation.type !== 'update') {
88
+ throw new Error('Update value property mutation has to be of type update');
89
+ }
90
+ if (propertyMutation.value === undefined) {
91
+ throw new Error('Value has to exist in an update value property mutation..');
92
+ }
93
+ }
94
+ function validateApplyNumericFnPropertyMutation(propertyMutation) {
95
+ if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
96
+ throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
97
+ }
98
+ if (!['increment'].includes(propertyMutation.fn)) {
99
+ throw new Error('Invalid fn for apply numeric fn.');
100
+ }
101
+ if (typeof propertyMutation.value !== 'number') {
102
+ throw new Error('The value in an apply numeric fn function has to be numeric.');
103
+ }
104
+ }
105
+ function validateApplyStringFnPropertyMutation(propertyMutation) {
106
+ if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
107
+ throw new Error('Apply string fn mutation has to be of type applyStringFn');
108
+ }
109
+ if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
110
+ throw new Error('Invalid fn for apply string fn.');
111
+ }
112
+ if (typeof propertyMutation.value !== 'string') {
113
+ throw new Error('The value in an apply string fn function has to be a string.');
114
+ }
115
+ }
116
+ function validatePropertyMutation(propertyMutation) {
117
+ if (!propertyMutation || typeof propertyMutation !== 'object') {
118
+ throw new Error('Property mutation need to be a JSON object.');
119
+ }
120
+ if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
121
+ throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
122
+ }
123
+ switch (propertyMutation.type) {
124
+ case 'update':
125
+ validateUpdatePropertyMutation(propertyMutation);
126
+ break;
127
+ case 'applyNumericFn':
128
+ validateApplyNumericFnPropertyMutation(propertyMutation);
129
+ break;
130
+ case 'applyStringFn':
131
+ validateApplyStringFnPropertyMutation(propertyMutation);
132
+ break;
133
+ }
134
+ }
135
+ function validateUpdateMutation(mutation) {
136
+ if (!mutation || mutation.type !== 'update') {
137
+ throw new Error('Mutation has to be non empty with type update.');
138
+ }
139
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
140
+ throw new Error('The properties in update mutation need to be a JSON object.');
141
+ }
142
+ const entries = Object.entries(mutation.properties);
143
+ for (const [fieldName, propertyMutations] of entries) {
144
+ validateFieldName(fieldName);
145
+ for (const propertyMutation of propertyMutations) {
146
+ validatePropertyMutation(propertyMutation);
147
+ }
148
+ }
149
+ }
150
+ function validateMutation(mutation) {
151
+ if (!mutation) {
152
+ throw new Error('Mutation cannot be empty');
153
+ }
154
+ if (!['insert', 'delete', 'update'].includes(mutation.type)) {
155
+ throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
156
+ }
157
+ validateCollectionName(mutation.squidDocIdObj.collectionName);
158
+ validatePathPart(mutation.squidDocIdObj.docId);
159
+ switch (mutation.type) {
160
+ case 'delete':
161
+ validateDeleteMutation(mutation);
162
+ break;
163
+ case 'insert':
164
+ validateInsertMutation(mutation);
165
+ break;
166
+ case 'update':
167
+ validateUpdateMutation(mutation);
168
+ break;
169
+ }
170
+ }
171
+ function validateMutations(mutations) {
172
+ if (!mutations || !(mutations instanceof Array) || !mutations.length) {
173
+ throw new Error('The list of mutations has to be a non-empty array.');
174
+ }
175
+ for (const mutation of mutations) {
176
+ validateMutation(mutation);
177
+ }
178
+ }
179
+ exports.validateMutations = validateMutations;
180
+ function validateQueryLimit(limit) {
181
+ (0, assert_1.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
182
+ if (limit === -1)
183
+ return;
184
+ (0, assert_1.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
185
+ (0, assert_1.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
186
+ (0, assert_1.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
187
+ }
188
+ exports.validateQueryLimit = validateQueryLimit;
189
+ function isNotEmpty(value) {
190
+ validateCorrectStringType(value);
191
+ return typeof value === 'string' && !!value;
192
+ }
193
+ exports.isNotEmpty = isNotEmpty;
194
+ function validateCorrectStringType(value) {
195
+ if (value !== null && value !== undefined && typeof value !== 'string') {
196
+ throw new Error(`Unexpected input type ${typeof value}`);
197
+ }
198
+ }
199
+ function isRightType(value, type) {
200
+ if (Array.isArray(value)) {
201
+ return value.every((element) => typeof element === type);
202
+ }
203
+ return typeof value === type;
204
+ }
205
+ exports.isRightType = isRightType;
206
+ function hasOnlyKeys(obj, keys) {
207
+ return !Array.isArray(obj) && [...Object.keys(obj)].every((key) => keys.includes(key));
208
+ }
209
+ exports.hasOnlyKeys = hasOnlyKeys;
210
210
  //# sourceMappingURL=validation.js.map
@@ -1,6 +1,6 @@
1
- export interface WebhookResponse {
2
- headers: Record<string, any>;
3
- body: any;
4
- statusCode: number;
5
- __isWebhookResponse__: true;
6
- }
1
+ export interface WebhookResponse {
2
+ headers: Record<string, any>;
3
+ body: any;
4
+ statusCode: number;
5
+ __isWebhookResponse__: true;
6
+ }
@@ -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=webhook-response.js.map
@@ -1,21 +1,21 @@
1
- interface Options {
2
- maxAttempts?: number;
3
- protocols?: string[];
4
- onmessage?: (event: any) => void;
5
- onopen?: (event: any) => void;
6
- onclose?: (event: any) => void;
7
- onerror?: (event: any) => void;
8
- onreconnect?: (event: any) => void;
9
- onmaximum?: (event: any) => void;
10
- timeout?: number;
11
- }
12
- export interface WebSocketWrapper {
13
- open: () => void;
14
- reconnect: (e: any) => void;
15
- json: (x: any) => void;
16
- send: (x: string) => void;
17
- close: (x?: number, y?: string) => void;
18
- connected: boolean;
19
- }
20
- export declare function createWebSocketWrapper(url: string, opts?: Options): WebSocketWrapper;
21
- export {};
1
+ interface Options {
2
+ maxAttempts?: number;
3
+ protocols?: string[];
4
+ onmessage?: (event: any) => void;
5
+ onopen?: (event: any) => void;
6
+ onclose?: (event: any) => void;
7
+ onerror?: (event: any) => void;
8
+ onreconnect?: (event: any) => void;
9
+ onmaximum?: (event: any) => void;
10
+ timeout?: number;
11
+ }
12
+ export interface WebSocketWrapper {
13
+ open: () => void;
14
+ reconnect: (e: any) => void;
15
+ json: (x: any) => void;
16
+ send: (x: string) => void;
17
+ close: (x?: number, y?: string) => void;
18
+ connected: boolean;
19
+ }
20
+ export declare function createWebSocketWrapper(url: string, opts?: Options): WebSocketWrapper;
21
+ export {};
@@ -1,77 +1,77 @@
1
- "use strict";
2
- var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.createWebSocketWrapper = void 0;
5
- const global_utils_1 = require("./utils/global.utils");
6
- function noop() {
7
- return;
8
- }
9
- const globalObj = (0, global_utils_1.getGlobal)();
10
- const WebSocketClass = (_a = globalObj['WebSocket']) !== null && _a !== void 0 ? _a : require('ws');
11
- function createWebSocketWrapper(url, opts = {}) {
12
- let ws;
13
- let num = 0;
14
- let timer = 1;
15
- const $ = {
16
- connected: false,
17
- open() {
18
- var _a;
19
- const wsConstructor = (_a = WebSocketClass === null || WebSocketClass === void 0 ? void 0 : WebSocketClass['WebSocket']) !== null && _a !== void 0 ? _a : WebSocketClass;
20
- ws = new wsConstructor(url, opts.protocols || []);
21
- ws.onmessage = opts.onmessage || noop;
22
- ws.onopen = function (e) {
23
- $.connected = true;
24
- (opts.onopen || noop)(e);
25
- num = 0;
26
- };
27
- ws.onclose = function (e) {
28
- $.connected = false;
29
- if (e.code !== 4999) {
30
- global_utils_1.DebugLogger.debug('WebSocket closed. Reconnecting. Close code: ', e.code);
31
- (opts.onclose || noop)(e);
32
- $.reconnect(e);
33
- return;
34
- }
35
- (opts.onclose || noop)(e);
36
- };
37
- ws.onerror = function (e) {
38
- $.connected = false;
39
- if (e && 'ECONNREFUSED' === e.code) {
40
- $.reconnect(e);
41
- }
42
- else {
43
- (opts.onerror || noop)(e);
44
- }
45
- };
46
- },
47
- reconnect(e) {
48
- const maxAttempts = opts.maxAttempts !== undefined ? opts.maxAttempts : Infinity;
49
- if (timer && num++ < maxAttempts) {
50
- timer = setTimeout(function () {
51
- (opts.onreconnect || noop)(e);
52
- global_utils_1.DebugLogger.debug('WebSocket trying to reconnect...');
53
- $.open();
54
- }, opts.timeout || 1000);
55
- }
56
- else {
57
- (opts.onmaximum || noop)(e);
58
- }
59
- },
60
- json(x) {
61
- ws.send(JSON.stringify(x));
62
- },
63
- send(x) {
64
- ws.send(x);
65
- },
66
- close(code = 4999, message) {
67
- $.connected = false;
68
- clearTimeout(timer);
69
- timer = undefined;
70
- ws.close(code, message);
71
- },
72
- };
73
- $.open();
74
- return $;
75
- }
76
- exports.createWebSocketWrapper = createWebSocketWrapper;
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.createWebSocketWrapper = void 0;
5
+ const global_utils_1 = require("./utils/global.utils");
6
+ function noop() {
7
+ return;
8
+ }
9
+ const globalObj = (0, global_utils_1.getGlobal)();
10
+ const WebSocketClass = (_a = globalObj['WebSocket']) !== null && _a !== void 0 ? _a : require('ws');
11
+ function createWebSocketWrapper(url, opts = {}) {
12
+ let ws;
13
+ let num = 0;
14
+ let timer = 1;
15
+ const $ = {
16
+ connected: false,
17
+ open() {
18
+ var _a;
19
+ const wsConstructor = (_a = WebSocketClass === null || WebSocketClass === void 0 ? void 0 : WebSocketClass['WebSocket']) !== null && _a !== void 0 ? _a : WebSocketClass;
20
+ ws = new wsConstructor(url, opts.protocols || []);
21
+ ws.onmessage = opts.onmessage || noop;
22
+ ws.onopen = function (e) {
23
+ $.connected = true;
24
+ (opts.onopen || noop)(e);
25
+ num = 0;
26
+ };
27
+ ws.onclose = function (e) {
28
+ $.connected = false;
29
+ if (e.code !== 4999) {
30
+ global_utils_1.DebugLogger.debug('WebSocket closed. Reconnecting. Close code: ', e.code);
31
+ (opts.onclose || noop)(e);
32
+ $.reconnect(e);
33
+ return;
34
+ }
35
+ (opts.onclose || noop)(e);
36
+ };
37
+ ws.onerror = function (e) {
38
+ $.connected = false;
39
+ if (e && 'ECONNREFUSED' === e.code) {
40
+ $.reconnect(e);
41
+ }
42
+ else {
43
+ (opts.onerror || noop)(e);
44
+ }
45
+ };
46
+ },
47
+ reconnect(e) {
48
+ const maxAttempts = opts.maxAttempts !== undefined ? opts.maxAttempts : Infinity;
49
+ if (timer && num++ < maxAttempts) {
50
+ timer = setTimeout(function () {
51
+ (opts.onreconnect || noop)(e);
52
+ global_utils_1.DebugLogger.debug('WebSocket trying to reconnect...');
53
+ $.open();
54
+ }, opts.timeout || 1000);
55
+ }
56
+ else {
57
+ (opts.onmaximum || noop)(e);
58
+ }
59
+ },
60
+ json(x) {
61
+ ws.send(JSON.stringify(x));
62
+ },
63
+ send(x) {
64
+ ws.send(x);
65
+ },
66
+ close(code = 4999, message) {
67
+ $.connected = false;
68
+ clearTimeout(timer);
69
+ timer = undefined;
70
+ ws.close(code, message);
71
+ },
72
+ };
73
+ $.open();
74
+ return $;
75
+ }
76
+ exports.createWebSocketWrapper = createWebSocketWrapper;
77
77
  //# sourceMappingURL=websocket.impl.js.map
@@ -1,4 +1,4 @@
1
- export declare class AsyncQueue {
2
- promise: Promise<void>;
3
- enqueue(fn: (...args: any[]) => Promise<any>): Promise<any>;
4
- }
1
+ export declare class AsyncQueue {
2
+ promise: Promise<void>;
3
+ enqueue(fn: (...args: any[]) => Promise<any>): Promise<any>;
4
+ }