@squidcloud/local-backend 1.0.148 → 1.0.151

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 (173) hide show
  1. package/dist/common/src/ai-assistant.types.d.ts +50 -50
  2. package/dist/common/src/ai-assistant.types.js +2 -2
  3. package/dist/common/src/ai-chatbot.context.d.ts +13 -13
  4. package/dist/common/src/ai-chatbot.context.js +19 -19
  5. package/dist/common/src/ai-chatbot.schemas.d.ts +18 -18
  6. package/dist/common/src/ai-chatbot.schemas.js +21 -21
  7. package/dist/common/src/ai-chatbot.types.d.ts +125 -123
  8. package/dist/common/src/ai-chatbot.types.js +18 -18
  9. package/dist/common/src/api-call.context.d.ts +13 -13
  10. package/dist/common/src/api-call.context.js +16 -16
  11. package/dist/common/src/api.types.d.ts +22 -22
  12. package/dist/common/src/api.types.js +2 -2
  13. package/dist/common/src/application.schemas.d.ts +1648 -1648
  14. package/dist/common/src/application.schemas.js +948 -948
  15. package/dist/common/src/application.types.d.ts +193 -193
  16. package/dist/common/src/application.types.js +89 -89
  17. package/dist/common/src/application.types.js.map +1 -1
  18. package/dist/common/src/backend-function.schemas.d.ts +3 -3
  19. package/dist/common/src/backend-function.schemas.js +11 -11
  20. package/dist/common/src/backend-function.types.d.ts +4 -4
  21. package/dist/common/src/backend-function.types.js +2 -2
  22. package/dist/common/src/backend-run.types.d.ts +54 -54
  23. package/dist/common/src/backend-run.types.js +92 -95
  24. package/dist/common/src/backend-run.types.js.map +1 -1
  25. package/dist/common/src/bundle-api.types.d.ts +65 -69
  26. package/dist/common/src/bundle-api.types.js +2 -2
  27. package/dist/common/src/bundle-data.types.d.ts +69 -74
  28. package/dist/common/src/bundle-data.types.js +2 -2
  29. package/dist/common/src/communication.types.d.ts +20 -19
  30. package/dist/common/src/communication.types.js +41 -40
  31. package/dist/common/src/communication.types.js.map +1 -1
  32. package/dist/common/src/context.types.d.ts +24 -24
  33. package/dist/common/src/context.types.js +2 -2
  34. package/dist/common/src/distributed-lock.context.d.ts +4 -4
  35. package/dist/common/src/distributed-lock.context.js +9 -9
  36. package/dist/common/src/document.types.d.ts +32 -32
  37. package/dist/common/src/document.types.js +50 -50
  38. package/dist/common/src/graphql.context.d.ts +14 -14
  39. package/dist/common/src/graphql.context.js +12 -12
  40. package/dist/common/src/graphql.types.d.ts +11 -11
  41. package/dist/common/src/graphql.types.js +34 -34
  42. package/dist/common/src/heartbeat.types.d.ts +4 -4
  43. package/dist/common/src/heartbeat.types.js +16 -16
  44. package/dist/common/src/http-status.enum.d.ts +50 -50
  45. package/dist/common/src/http-status.enum.js +54 -54
  46. package/dist/common/src/http-status.enum.js.map +1 -1
  47. package/dist/common/src/index.d.ts +54 -57
  48. package/dist/common/src/index.js +70 -73
  49. package/dist/common/src/index.js.map +1 -1
  50. package/dist/common/src/integrations/ai_chatbot.types.d.ts +31 -31
  51. package/dist/common/src/integrations/ai_chatbot.types.js +2 -2
  52. package/dist/common/src/integrations/api.types.d.ts +80 -80
  53. package/dist/common/src/integrations/api.types.js +2 -2
  54. package/dist/common/src/integrations/auth.types.d.ts +39 -39
  55. package/dist/common/src/integrations/auth.types.js +2 -2
  56. package/dist/common/src/integrations/database.types.d.ts +274 -274
  57. package/dist/common/src/integrations/database.types.js +2 -2
  58. package/dist/common/src/integrations/index.d.ts +134 -134
  59. package/dist/common/src/integrations/index.js +119 -119
  60. package/dist/common/src/integrations/index.js.map +1 -1
  61. package/dist/common/src/integrations/observability.types.d.ts +23 -23
  62. package/dist/common/src/integrations/observability.types.js +23 -23
  63. package/dist/common/src/logger.types.d.ts +21 -21
  64. package/dist/common/src/logger.types.js +11 -11
  65. package/dist/common/src/logger.types.js.map +1 -1
  66. package/dist/common/src/metrics.types.d.ts +73 -73
  67. package/dist/common/src/metrics.types.js +11 -11
  68. package/dist/common/src/mutation.context.d.ts +13 -13
  69. package/dist/common/src/mutation.context.js +26 -26
  70. package/dist/common/src/mutation.schemas.d.ts +5 -5
  71. package/dist/common/src/mutation.schemas.js +114 -114
  72. package/dist/common/src/mutation.types.d.ts +63 -63
  73. package/dist/common/src/mutation.types.js +142 -142
  74. package/dist/common/src/native-query.context.d.ts +7 -7
  75. package/dist/common/src/native-query.context.js +11 -11
  76. package/dist/common/src/native-query.types.d.ts +16 -16
  77. package/dist/common/src/native-query.types.js +2 -2
  78. package/dist/common/src/query/base-query-builder.d.ts +38 -38
  79. package/dist/common/src/query/base-query-builder.js +39 -39
  80. package/dist/common/src/query/index.d.ts +4 -4
  81. package/dist/common/src/query/index.js +20 -20
  82. package/dist/common/src/query/pagination.d.ts +46 -46
  83. package/dist/common/src/query/pagination.js +211 -211
  84. package/dist/common/src/query/query-context.d.ts +47 -47
  85. package/dist/common/src/query/query-context.js +159 -159
  86. package/dist/common/src/query/serialized-query.types.d.ts +24 -24
  87. package/dist/common/src/query/serialized-query.types.js +2 -2
  88. package/dist/common/src/query.types.d.ts +86 -86
  89. package/dist/common/src/query.types.js +97 -97
  90. package/dist/common/src/regions.d.ts +21 -21
  91. package/dist/common/src/regions.js +46 -46
  92. package/dist/common/src/schema/schema.types.d.ts +30 -30
  93. package/dist/common/src/schema/schema.types.js +173 -173
  94. package/dist/common/src/secret.schemas.d.ts +4 -4
  95. package/dist/common/src/secret.schemas.js +17 -17
  96. package/dist/common/src/secret.types.d.ts +68 -68
  97. package/dist/common/src/secret.types.js +5 -5
  98. package/dist/common/src/security.types.d.ts +3 -3
  99. package/dist/common/src/security.types.js +2 -2
  100. package/dist/common/src/socket.schemas.d.ts +3 -3
  101. package/dist/common/src/socket.schemas.js +57 -57
  102. package/dist/common/src/socket.types.d.ts +126 -126
  103. package/dist/common/src/socket.types.js +9 -9
  104. package/dist/common/src/socket.types.js.map +1 -1
  105. package/dist/common/src/time-units.d.ts +11 -11
  106. package/dist/common/src/time-units.js +14 -14
  107. package/dist/common/src/trigger.types.d.ts +15 -15
  108. package/dist/common/src/trigger.types.js +2 -2
  109. package/dist/common/src/types.d.ts +21 -21
  110. package/dist/common/src/types.js +2 -2
  111. package/dist/common/src/utils/array.d.ts +8 -8
  112. package/dist/common/src/utils/array.js +54 -54
  113. package/dist/common/src/utils/assert.d.ts +3 -3
  114. package/dist/common/src/utils/assert.js +14 -14
  115. package/dist/common/src/utils/error.d.ts +4 -4
  116. package/dist/common/src/utils/error.js +10 -10
  117. package/dist/common/src/utils/global.utils.d.ts +11 -11
  118. package/dist/common/src/utils/global.utils.js +50 -50
  119. package/dist/common/src/utils/http.d.ts +2 -2
  120. package/dist/common/src/utils/http.js +51 -51
  121. package/dist/common/src/utils/id.d.ts +2 -2
  122. package/dist/common/src/utils/id.js +21 -21
  123. package/dist/common/src/utils/lock.manager.d.ts +9 -9
  124. package/dist/common/src/utils/lock.manager.js +39 -39
  125. package/dist/common/src/utils/object.d.ts +5 -5
  126. package/dist/common/src/utils/object.js +75 -75
  127. package/dist/common/src/utils/serialization.d.ts +5 -5
  128. package/dist/common/src/utils/serialization.js +73 -73
  129. package/dist/common/src/utils/transforms.d.ts +18 -18
  130. package/dist/common/src/utils/transforms.js +104 -104
  131. package/dist/common/src/utils/url.d.ts +1 -1
  132. package/dist/common/src/utils/url.js +15 -15
  133. package/dist/common/src/utils/validation.d.ts +17 -17
  134. package/dist/common/src/utils/validation.js +199 -199
  135. package/dist/common/src/webhook-response.d.ts +6 -6
  136. package/dist/common/src/webhook-response.js +2 -2
  137. package/dist/common/src/websocket.impl.d.ts +21 -21
  138. package/dist/common/src/websocket.impl.js +79 -79
  139. package/dist/internal-common/src/code-executor.types.d.ts +13 -13
  140. package/dist/internal-common/src/code-executor.types.js +2 -2
  141. package/dist/internal-common/src/local-dev.types.d.ts +35 -35
  142. package/dist/internal-common/src/local-dev.types.js +2 -2
  143. package/dist/local-backend/package.json +48 -48
  144. package/dist/local-backend/src/index.d.ts +4 -4
  145. package/dist/local-backend/src/index.js +26 -26
  146. package/dist/local-backend/src/local-backend-socket.service.d.ts +18 -18
  147. package/dist/local-backend/src/local-backend-socket.service.js +107 -108
  148. package/dist/local-backend/src/local-backend-socket.service.js.map +1 -1
  149. package/dist/local-backend/src/local-backend.app.d.ts +2 -2
  150. package/dist/local-backend/src/local-backend.app.js +19 -19
  151. package/dist/local-backend/src/local-backend.controller.d.ts +8 -8
  152. package/dist/local-backend/src/local-backend.controller.js +48 -49
  153. package/dist/local-backend/src/local-backend.controller.js.map +1 -1
  154. package/dist/local-backend/src/local-backend.module.d.ts +8 -8
  155. package/dist/local-backend/src/local-backend.module.js +51 -53
  156. package/dist/local-backend/src/local-backend.module.js.map +1 -1
  157. package/dist/local-backend/src/local-backend.service.d.ts +15 -15
  158. package/dist/local-backend/src/local-backend.service.js +173 -176
  159. package/dist/local-backend/src/local-backend.service.js.map +1 -1
  160. package/dist/tsconfig.build.tsbuildinfo +1 -1
  161. package/package.json +1 -1
  162. package/dist/common/src/named-query.context.d.ts +0 -4
  163. package/dist/common/src/named-query.context.js +0 -10
  164. package/dist/common/src/named-query.context.js.map +0 -1
  165. package/dist/common/src/named-query.schemas.d.ts +0 -3
  166. package/dist/common/src/named-query.schemas.js +0 -14
  167. package/dist/common/src/named-query.schemas.js.map +0 -1
  168. package/dist/common/src/named-query.types.d.ts +0 -8
  169. package/dist/common/src/named-query.types.js +0 -3
  170. package/dist/common/src/named-query.types.js.map +0 -1
  171. package/dist/internal-common/src/utils/logger-utils.d.ts +0 -3
  172. package/dist/internal-common/src/utils/logger-utils.js +0 -29
  173. package/dist/internal-common/src/utils/logger-utils.js.map +0 -1
@@ -1,200 +1,200 @@
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 assertic_1 = require("assertic");
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 validateFieldSort(fieldSort) {
38
- if (!(fieldSort instanceof Object)) {
39
- throw new Error('Field sort has to be an object');
40
- }
41
- (0, assertic_1.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
42
- (0, assertic_1.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
43
- validateFieldName(fieldSort.fieldName);
44
- }
45
- exports.validateFieldSort = validateFieldSort;
46
- function validateOpenIdProvider(openIdProvider) {
47
- (0, assertic_1.assertTruthy)(openIdProvider, 'INVALID_PROVIDER');
48
- validateOpenIdProviderType(openIdProvider.providerType);
49
- (0, assertic_1.assertTruthy)(openIdProvider.providerType, 'INVALID_CLIENT_ID');
50
- (0, assertic_1.assertTruthy)(openIdProvider.clientId, 'INVALID_CLIENT_ID');
51
- (0, assertic_1.assertTruthy)(openIdProvider.domain, 'INVALID_DOMAIN');
52
- return openIdProvider;
53
- }
54
- exports.validateOpenIdProvider = validateOpenIdProvider;
55
- function validateOpenIdProviderType(providerType) {
56
- const providerArray = ['auth0'];
57
- (0, assertic_1.assertTruthy)(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
58
- }
59
- exports.validateOpenIdProviderType = validateOpenIdProviderType;
60
- function validateDeleteMutation(mutation) {
61
- if (!mutation || mutation.type !== 'delete') {
62
- throw new Error('Mutation has to be non empty with type delete.');
63
- }
64
- }
65
- function validateInsertMutation(mutation) {
66
- if (!mutation || mutation.type !== 'insert') {
67
- throw new Error('Mutation has to be non empty with type insert.');
68
- }
69
- if (!mutation.properties || typeof mutation.properties !== 'object') {
70
- throw new Error('The properties in insert mutation need to be a JSON object.');
71
- }
72
- for (const [fieldName] of Object.entries(mutation.properties)) {
73
- validateFieldName(fieldName);
74
- }
75
- }
76
- function validateUpdatePropertyMutation(propertyMutation) {
77
- if (!propertyMutation || propertyMutation.type !== 'update') {
78
- throw new Error('Update value property mutation has to be of type update');
79
- }
80
- if (propertyMutation.value === undefined) {
81
- throw new Error('Value has to exist in an update value property mutation..');
82
- }
83
- }
84
- function validateApplyNumericFnPropertyMutation(propertyMutation) {
85
- if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
86
- throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
87
- }
88
- if (!['increment'].includes(propertyMutation.fn)) {
89
- throw new Error('Invalid fn for apply numeric fn.');
90
- }
91
- if (typeof propertyMutation.value !== 'number') {
92
- throw new Error('The value in an apply numeric fn function has to be numeric.');
93
- }
94
- }
95
- function validateApplyStringFnPropertyMutation(propertyMutation) {
96
- if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
97
- throw new Error('Apply string fn mutation has to be of type applyStringFn');
98
- }
99
- if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
100
- throw new Error('Invalid fn for apply string fn.');
101
- }
102
- if (typeof propertyMutation.value !== 'string') {
103
- throw new Error('The value in an apply string fn function has to be a string.');
104
- }
105
- }
106
- function validatePropertyMutation(propertyMutation) {
107
- if (!propertyMutation || typeof propertyMutation !== 'object') {
108
- throw new Error('Property mutation need to be a JSON object.');
109
- }
110
- if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
111
- throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
112
- }
113
- switch (propertyMutation.type) {
114
- case 'update':
115
- validateUpdatePropertyMutation(propertyMutation);
116
- break;
117
- case 'applyNumericFn':
118
- validateApplyNumericFnPropertyMutation(propertyMutation);
119
- break;
120
- case 'applyStringFn':
121
- validateApplyStringFnPropertyMutation(propertyMutation);
122
- break;
123
- }
124
- }
125
- function validateUpdateMutation(mutation) {
126
- if (!mutation || mutation.type !== 'update') {
127
- throw new Error('Mutation has to be non empty with type update.');
128
- }
129
- if (!mutation.properties || typeof mutation.properties !== 'object') {
130
- throw new Error('The properties in update mutation need to be a JSON object.');
131
- }
132
- const entries = Object.entries(mutation.properties);
133
- for (const [fieldName, propertyMutations] of entries) {
134
- validateFieldName(fieldName);
135
- for (const propertyMutation of propertyMutations) {
136
- validatePropertyMutation(propertyMutation);
137
- }
138
- }
139
- }
140
- function validateMutation(mutation) {
141
- if (!mutation) {
142
- throw new Error('Mutation cannot be empty');
143
- }
144
- if (!['insert', 'delete', 'update'].includes(mutation.type)) {
145
- throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
146
- }
147
- validateCollectionName(mutation.squidDocIdObj.collectionName);
148
- validatePathPart(mutation.squidDocIdObj.docId);
149
- switch (mutation.type) {
150
- case 'delete':
151
- validateDeleteMutation(mutation);
152
- break;
153
- case 'insert':
154
- validateInsertMutation(mutation);
155
- break;
156
- case 'update':
157
- validateUpdateMutation(mutation);
158
- break;
159
- }
160
- }
161
- function validateMutations(mutations) {
162
- if (!mutations || !(mutations instanceof Array) || !mutations.length) {
163
- throw new Error('The list of mutations has to be a non-empty array.');
164
- }
165
- for (const mutation of mutations) {
166
- validateMutation(mutation);
167
- }
168
- }
169
- exports.validateMutations = validateMutations;
170
- function validateQueryLimit(limit) {
171
- (0, assertic_1.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
172
- if (limit === -1)
173
- return;
174
- (0, assertic_1.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
175
- (0, assertic_1.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
176
- (0, assertic_1.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
177
- }
178
- exports.validateQueryLimit = validateQueryLimit;
179
- function isNotEmpty(value) {
180
- validateCorrectStringType(value);
181
- return typeof value === 'string' && !!value;
182
- }
183
- exports.isNotEmpty = isNotEmpty;
184
- function validateCorrectStringType(value) {
185
- if (value !== null && value !== undefined && typeof value !== 'string') {
186
- throw new Error(`Unexpected input type ${typeof value}`);
187
- }
188
- }
189
- function isRightType(value, type) {
190
- if (Array.isArray(value)) {
191
- return value.every(element => typeof element === type);
192
- }
193
- return typeof value === type;
194
- }
195
- exports.isRightType = isRightType;
196
- function hasOnlyKeys(obj, keys) {
197
- return !Array.isArray(obj) && [...Object.keys(obj)].every(key => keys.includes(key));
198
- }
199
- 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 assertic_1 = require("assertic");
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 validateFieldSort(fieldSort) {
38
+ if (!(fieldSort instanceof Object)) {
39
+ throw new Error('Field sort has to be an object');
40
+ }
41
+ (0, assertic_1.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
42
+ (0, assertic_1.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
43
+ validateFieldName(fieldSort.fieldName);
44
+ }
45
+ exports.validateFieldSort = validateFieldSort;
46
+ function validateOpenIdProvider(openIdProvider) {
47
+ (0, assertic_1.assertTruthy)(openIdProvider, 'INVALID_PROVIDER');
48
+ validateOpenIdProviderType(openIdProvider.providerType);
49
+ (0, assertic_1.assertTruthy)(openIdProvider.providerType, 'INVALID_CLIENT_ID');
50
+ (0, assertic_1.assertTruthy)(openIdProvider.clientId, 'INVALID_CLIENT_ID');
51
+ (0, assertic_1.assertTruthy)(openIdProvider.domain, 'INVALID_DOMAIN');
52
+ return openIdProvider;
53
+ }
54
+ exports.validateOpenIdProvider = validateOpenIdProvider;
55
+ function validateOpenIdProviderType(providerType) {
56
+ const providerArray = ['auth0'];
57
+ (0, assertic_1.assertTruthy)(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
58
+ }
59
+ exports.validateOpenIdProviderType = validateOpenIdProviderType;
60
+ function validateDeleteMutation(mutation) {
61
+ if (!mutation || mutation.type !== 'delete') {
62
+ throw new Error('Mutation has to be non empty with type delete.');
63
+ }
64
+ }
65
+ function validateInsertMutation(mutation) {
66
+ if (!mutation || mutation.type !== 'insert') {
67
+ throw new Error('Mutation has to be non empty with type insert.');
68
+ }
69
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
70
+ throw new Error('The properties in insert mutation need to be a JSON object.');
71
+ }
72
+ for (const [fieldName] of Object.entries(mutation.properties)) {
73
+ validateFieldName(fieldName);
74
+ }
75
+ }
76
+ function validateUpdatePropertyMutation(propertyMutation) {
77
+ if (!propertyMutation || propertyMutation.type !== 'update') {
78
+ throw new Error('Update value property mutation has to be of type update');
79
+ }
80
+ if (propertyMutation.value === undefined) {
81
+ throw new Error('Value has to exist in an update value property mutation..');
82
+ }
83
+ }
84
+ function validateApplyNumericFnPropertyMutation(propertyMutation) {
85
+ if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
86
+ throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
87
+ }
88
+ if (!['increment'].includes(propertyMutation.fn)) {
89
+ throw new Error('Invalid fn for apply numeric fn.');
90
+ }
91
+ if (typeof propertyMutation.value !== 'number') {
92
+ throw new Error('The value in an apply numeric fn function has to be numeric.');
93
+ }
94
+ }
95
+ function validateApplyStringFnPropertyMutation(propertyMutation) {
96
+ if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
97
+ throw new Error('Apply string fn mutation has to be of type applyStringFn');
98
+ }
99
+ if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
100
+ throw new Error('Invalid fn for apply string fn.');
101
+ }
102
+ if (typeof propertyMutation.value !== 'string') {
103
+ throw new Error('The value in an apply string fn function has to be a string.');
104
+ }
105
+ }
106
+ function validatePropertyMutation(propertyMutation) {
107
+ if (!propertyMutation || typeof propertyMutation !== 'object') {
108
+ throw new Error('Property mutation need to be a JSON object.');
109
+ }
110
+ if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
111
+ throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
112
+ }
113
+ switch (propertyMutation.type) {
114
+ case 'update':
115
+ validateUpdatePropertyMutation(propertyMutation);
116
+ break;
117
+ case 'applyNumericFn':
118
+ validateApplyNumericFnPropertyMutation(propertyMutation);
119
+ break;
120
+ case 'applyStringFn':
121
+ validateApplyStringFnPropertyMutation(propertyMutation);
122
+ break;
123
+ }
124
+ }
125
+ function validateUpdateMutation(mutation) {
126
+ if (!mutation || mutation.type !== 'update') {
127
+ throw new Error('Mutation has to be non empty with type update.');
128
+ }
129
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
130
+ throw new Error('The properties in update mutation need to be a JSON object.');
131
+ }
132
+ const entries = Object.entries(mutation.properties);
133
+ for (const [fieldName, propertyMutations] of entries) {
134
+ validateFieldName(fieldName);
135
+ for (const propertyMutation of propertyMutations) {
136
+ validatePropertyMutation(propertyMutation);
137
+ }
138
+ }
139
+ }
140
+ function validateMutation(mutation) {
141
+ if (!mutation) {
142
+ throw new Error('Mutation cannot be empty');
143
+ }
144
+ if (!['insert', 'delete', 'update'].includes(mutation.type)) {
145
+ throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
146
+ }
147
+ validateCollectionName(mutation.squidDocIdObj.collectionName);
148
+ validatePathPart(mutation.squidDocIdObj.docId);
149
+ switch (mutation.type) {
150
+ case 'delete':
151
+ validateDeleteMutation(mutation);
152
+ break;
153
+ case 'insert':
154
+ validateInsertMutation(mutation);
155
+ break;
156
+ case 'update':
157
+ validateUpdateMutation(mutation);
158
+ break;
159
+ }
160
+ }
161
+ function validateMutations(mutations) {
162
+ if (!mutations || !(mutations instanceof Array) || !mutations.length) {
163
+ throw new Error('The list of mutations has to be a non-empty array.');
164
+ }
165
+ for (const mutation of mutations) {
166
+ validateMutation(mutation);
167
+ }
168
+ }
169
+ exports.validateMutations = validateMutations;
170
+ function validateQueryLimit(limit) {
171
+ (0, assertic_1.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
172
+ if (limit === -1)
173
+ return;
174
+ (0, assertic_1.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
175
+ (0, assertic_1.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
176
+ (0, assertic_1.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
177
+ }
178
+ exports.validateQueryLimit = validateQueryLimit;
179
+ function isNotEmpty(value) {
180
+ validateCorrectStringType(value);
181
+ return typeof value === 'string' && !!value;
182
+ }
183
+ exports.isNotEmpty = isNotEmpty;
184
+ function validateCorrectStringType(value) {
185
+ if (value !== null && value !== undefined && typeof value !== 'string') {
186
+ throw new Error(`Unexpected input type ${typeof value}`);
187
+ }
188
+ }
189
+ function isRightType(value, type) {
190
+ if (Array.isArray(value)) {
191
+ return value.every(element => typeof element === type);
192
+ }
193
+ return typeof value === type;
194
+ }
195
+ exports.isRightType = isRightType;
196
+ function hasOnlyKeys(obj, keys) {
197
+ return !Array.isArray(obj) && [...Object.keys(obj)].every(key => keys.includes(key));
198
+ }
199
+ exports.hasOnlyKeys = hasOnlyKeys;
200
200
  //# 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,80 +1,80 @@
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 && e.code !== 4001) {
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
- try {
68
- $.connected = false;
69
- clearTimeout(timer);
70
- timer = undefined;
71
- ws.close(code, message);
72
- }
73
- catch (e) { }
74
- },
75
- };
76
- $.open();
77
- return $;
78
- }
79
- 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 && e.code !== 4001) {
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
+ try {
68
+ $.connected = false;
69
+ clearTimeout(timer);
70
+ timer = undefined;
71
+ ws.close(code, message);
72
+ }
73
+ catch (e) { }
74
+ },
75
+ };
76
+ $.open();
77
+ return $;
78
+ }
79
+ exports.createWebSocketWrapper = createWebSocketWrapper;
80
80
  //# sourceMappingURL=websocket.impl.js.map
@@ -1,13 +1,13 @@
1
- import { Auth, ExecuteFunctionAnnotationType, RunConfiguration, RunContext, RunSecrets, ServiceFunctionName } from '@squidcloud/common';
2
- export type SingleExecuteFunctionRequest = {
3
- functionName: ServiceFunctionName;
4
- params: Array<any>;
5
- };
6
- export interface BatchRunConfigurationRequest {
7
- configuration: RunConfiguration;
8
- context: RunContext;
9
- auth: Auth | undefined;
10
- requests: Array<SingleExecuteFunctionRequest>;
11
- secrets?: RunSecrets;
12
- executeFunctionAnnotationType: ExecuteFunctionAnnotationType;
13
- }
1
+ import { Auth, ExecuteFunctionAnnotationType, RunConfiguration, RunContext, RunSecrets, ServiceFunctionName } from '@squidcloud/common';
2
+ export type SingleExecuteFunctionRequest = {
3
+ functionName: ServiceFunctionName;
4
+ params: Array<any>;
5
+ };
6
+ export interface BatchRunConfigurationRequest {
7
+ configuration: RunConfiguration;
8
+ context: RunContext;
9
+ auth: Auth | undefined;
10
+ requests: Array<SingleExecuteFunctionRequest>;
11
+ secrets?: RunSecrets;
12
+ executeFunctionAnnotationType: ExecuteFunctionAnnotationType;
13
+ }
@@ -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=code-executor.types.js.map