@squidcloud/client 1.0.126 → 1.0.127

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.
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,411 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
+ /***/ 4113:
5
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
6
+
7
+ "use strict";
8
+
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
24
+ __exportStar(__webpack_require__(3222), exports);
25
+ //# sourceMappingURL=index.js.map
26
+
27
+ /***/ }),
28
+
29
+ /***/ 9471:
30
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
31
+
32
+ "use strict";
33
+
34
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
35
+ exports.callValueAssertion = exports.assertArray = exports.assertObject = exports.getErrorMessage = exports.fail = exports.truthy = exports.assertTruthy = void 0;
36
+ const ChecksLib_1 = __webpack_require__(2389);
37
+ /** Asserts that the *param* value is truthy using '!' operator or throws an Error. */
38
+ function assertTruthy(value, error) {
39
+ if (!value) {
40
+ fail(error);
41
+ }
42
+ }
43
+ exports.assertTruthy = assertTruthy;
44
+ /**
45
+ * Casts the 'value' to a non-nullable type or throws an error.
46
+ * Uses 'assertTruthy' to make the check.
47
+ */
48
+ function truthy(value, error) {
49
+ assertTruthy(value, error);
50
+ return value;
51
+ }
52
+ exports.truthy = truthy;
53
+ function fail(error) {
54
+ const errorMessage = getErrorMessage(error);
55
+ throw new Error(errorMessage || 'Assertion error');
56
+ }
57
+ exports.fail = fail;
58
+ /** Returns validation context as a string. Calls errorProvider() if needed. */
59
+ function getErrorMessage(errorProvider) {
60
+ if (errorProvider === undefined) {
61
+ return '';
62
+ }
63
+ if (typeof errorProvider === 'string') {
64
+ return errorProvider;
65
+ }
66
+ const error = errorProvider();
67
+ if (typeof error === 'string') {
68
+ return error;
69
+ }
70
+ return error.message;
71
+ }
72
+ exports.getErrorMessage = getErrorMessage;
73
+ /**
74
+ * Asserts that the object satisfies the schema using individual field assertions.
75
+ * Throws an error if not.
76
+ * Works only with non-array objects: use 'assertArray' to check arrays.
77
+ */
78
+ function assertObject(value, objectAssertion, errorContextProvider = undefined, constraints = {}) {
79
+ const ctx = () => { return getErrorMessage(errorContextProvider); };
80
+ const errorWithContext = (message) => {
81
+ const context = ctx();
82
+ return context.length === 0 ? message : `${context} ${message}`;
83
+ };
84
+ assertTruthy(typeof value === 'object', () => errorWithContext(`is not an object: ${typeof value}`));
85
+ assertTruthy(value !== undefined, () => errorWithContext(`is not defined`));
86
+ assertTruthy(value !== null, () => errorWithContext(`is null`));
87
+ assertTruthy(!Array.isArray(value), () => errorWithContext(`is an array.`));
88
+ const assertionEntries = Object.entries(objectAssertion);
89
+ if (constraints.failOnUnknownFields) {
90
+ for (const objectFieldName in value) {
91
+ assertTruthy(assertionEntries.some(([assertionFieldName]) => objectFieldName === assertionFieldName), errorWithContext(`property can't be checked: ${objectFieldName}`));
92
+ }
93
+ }
94
+ let $o;
95
+ for (const [fieldKey, fieldAssertion] of assertionEntries) {
96
+ assertTruthy(typeof fieldAssertion === 'function' ||
97
+ (typeof fieldAssertion === 'object' && fieldAssertion !== null), () => `${ctx()}.${fieldKey} assertion is not an object or a function: ${typeof fieldAssertion}`);
98
+ const fieldValue = value[fieldKey];
99
+ const fieldCtx = () => `${ctx()}.${fieldKey}`;
100
+ if (typeof fieldAssertion === 'object') {
101
+ assertTruthy(!Array.isArray(fieldValue), () => `${ctx()}.${fieldCtx()} use arrayAssertion() to create a ValueAssertion for an array`);
102
+ assertObject(fieldValue, fieldAssertion, fieldCtx);
103
+ }
104
+ else {
105
+ assertTruthy(typeof fieldAssertion === 'function', () => `${ctx()}.${fieldCtx()} assertion is not a function`);
106
+ if (fieldKey === '$o') {
107
+ $o = fieldAssertion; // Will be run last.
108
+ }
109
+ else {
110
+ const checkResult = fieldAssertion(fieldValue, fieldCtx);
111
+ assertTruthy(checkResult === undefined, `Assertion function must assert (void) but it returns a value: ${checkResult}. Wrap with $v()?`);
112
+ }
113
+ }
114
+ }
115
+ if ($o) {
116
+ $o(value, errorContextProvider);
117
+ }
118
+ }
119
+ exports.assertObject = assertObject;
120
+ /**
121
+ * Asserts that the *value* is an array and every element in the array satisfy to the *elementAssertion*.
122
+ * Throws error if check fails.
123
+ */
124
+ function assertArray(value, elementAssertion, constraints = {}, errorContextProvider = undefined) {
125
+ var _a, _b;
126
+ const ctx = (mode = 'with-space-separator') => {
127
+ const text = getErrorMessage(errorContextProvider);
128
+ return text ? `${text}${mode === 'with-space-separator' ? ' ' : ''}` : '';
129
+ };
130
+ assertTruthy(Array.isArray(value), () => `${ctx()}value is not an array: ${value}`);
131
+ const minLength = (_a = constraints.minLength) !== null && _a !== void 0 ? _a : 0;
132
+ const maxLength = (_b = constraints.maxLength) !== null && _b !== void 0 ? _b : Infinity;
133
+ assertTruthy(value.length >= minLength, () => `${ctx()}array length < minLength. Array length: ${value.length}, minLength: ${minLength}`);
134
+ assertTruthy(value.length <= maxLength, () => `${ctx()}array length > maxLength. Array length: ${value.length}, maxLength: ${maxLength}`);
135
+ if (constraints.uniqueByIdentity) {
136
+ assertTruthy((0, ChecksLib_1.checkArrayHasUniqueElements)(value, constraints.uniqueByIdentity), () => `${ctx()}array contains non-unique elements`);
137
+ }
138
+ let i = 0;
139
+ const elementErrorProvider = () => `${ctx('no-space-separator')}[${i}]`;
140
+ for (; i < value.length; i++) {
141
+ const element = value[i];
142
+ if (typeof elementAssertion === 'object') {
143
+ assertTruthy(!Array.isArray(element), () => `${elementErrorProvider}: use arrayAssertion() to create a ValueAssertion for an array`);
144
+ assertObject(element, elementAssertion, elementErrorProvider);
145
+ }
146
+ else {
147
+ callValueAssertion(element, elementAssertion, elementErrorProvider);
148
+ }
149
+ }
150
+ }
151
+ exports.assertArray = assertArray;
152
+ /**
153
+ * Calls the assertion.
154
+ * Workaround for TS issue with assertion on genetic arrow function. See https://github.com/microsoft/TypeScript/issues/34523.
155
+ */
156
+ function callValueAssertion(value, valueAssertion, errorContextProvider) {
157
+ valueAssertion(value, errorContextProvider);
158
+ }
159
+ exports.callValueAssertion = callValueAssertion;
160
+ //# sourceMappingURL=Assertion.js.map
161
+
162
+ /***/ }),
163
+
164
+ /***/ 8263:
165
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
166
+
167
+ "use strict";
168
+
169
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
170
+ exports.stringAssertion = exports.nullOr = exports.undefinedOr = exports.valueOr = exports.$a = exports.arrayAssertion = exports.objectAssertion = void 0;
171
+ const Assertion_1 = __webpack_require__(9471);
172
+ const AssertionsLib_1 = __webpack_require__(5412);
173
+ /** A shortcut to build new object type assertion. */
174
+ function objectAssertion(objectTypeAssertion, errorContextProvider = undefined) {
175
+ return o => (0, Assertion_1.assertObject)(o, objectTypeAssertion, errorContextProvider);
176
+ }
177
+ exports.objectAssertion = objectAssertion;
178
+ /**
179
+ * Creates an assertion for array object that checks that array is defined,
180
+ * the array satisfies the *constraints* and every element of the array passes the *elementAssertion* check.
181
+ */
182
+ function arrayAssertion(elementAssertion, constraints = {}) {
183
+ const { minLength, maxLength } = constraints;
184
+ (0, Assertion_1.assertTruthy)((minLength !== null && minLength !== void 0 ? minLength : 0) <= (maxLength !== null && maxLength !== void 0 ? maxLength : Infinity), `minLength must be < maxLength! minLength ${minLength}, maxLength: ${maxLength}`);
185
+ (0, Assertion_1.assertTruthy)((minLength !== null && minLength !== void 0 ? minLength : 0) >= 0, `minLength must be a positive number: ${minLength}`);
186
+ (0, Assertion_1.assertTruthy)((maxLength !== null && maxLength !== void 0 ? maxLength : 0) >= 0, `maxLength must be a positive number: ${maxLength}`);
187
+ return (array, errorContextProvider = undefined) => {
188
+ (0, Assertion_1.assertArray)(array, elementAssertion, constraints, errorContextProvider);
189
+ };
190
+ }
191
+ exports.arrayAssertion = arrayAssertion;
192
+ /**
193
+ * Creates a new value assertion using *check* function.
194
+ * The assertion accepts the value as valid if 'check(value)' returns true or throws an error otherwise.
195
+ */
196
+ function $a(check, errorMessageProvider) {
197
+ (0, Assertion_1.assertTruthy)(typeof check === 'function', `"check" is not a function: ${check}`);
198
+ return (value, errorContextProvider = undefined) => (0, Assertion_1.assertTruthy)(check(value), () => {
199
+ let errorContext = (0, Assertion_1.getErrorMessage)(errorContextProvider) || 'Check is failed';
200
+ if (!errorContext.endsWith(':')) {
201
+ errorContext += ':';
202
+ }
203
+ const errorMessage = (0, Assertion_1.getErrorMessage)(errorMessageProvider);
204
+ return `${errorContext} ${(errorMessage || (typeof value === 'object' ? '[object]' : `'${value}'`))}`;
205
+ });
206
+ }
207
+ exports.$a = $a;
208
+ /**
209
+ * Creates an assertion that makes comparison by reference with the *expectedValue* before calling *orAssertion*.
210
+ * If comparison with the *expectedValue* succeeds, does not call the *orAssertion*.
211
+ */
212
+ function valueOr(expectedValue, orAssertion) {
213
+ return (value, errorContextProvider = undefined) => {
214
+ if (value === expectedValue)
215
+ return;
216
+ if (typeof orAssertion === 'object') {
217
+ (0, Assertion_1.assertObject)(value, orAssertion, errorContextProvider);
218
+ }
219
+ else {
220
+ (0, Assertion_1.callValueAssertion)(value, orAssertion, errorContextProvider);
221
+ }
222
+ };
223
+ }
224
+ exports.valueOr = valueOr;
225
+ /** Creates an assertion that succeeds if the value is *undefined* or calls *orAssertion* if the value is not *undefined*. */
226
+ function undefinedOr(orAssertion) {
227
+ return valueOr(undefined, orAssertion);
228
+ }
229
+ exports.undefinedOr = undefinedOr;
230
+ /** Creates an assertion that succeeds if the value is *null* or calls *orAssertion* if the value is not *undefined*. */
231
+ function nullOr(orAssertion) {
232
+ return valueOr(null, orAssertion);
233
+ }
234
+ exports.nullOr = nullOr;
235
+ const stringAssertion = (constraints) => (value, context = undefined) => {
236
+ var _a, _b;
237
+ (0, AssertionsLib_1.assertString)(value, context);
238
+ (0, Assertion_1.assertTruthy)(value.length >= ((_a = constraints.minLength) !== null && _a !== void 0 ? _a : 0), `${(0, Assertion_1.getErrorMessage)(context)} length is too small: ${value.length} < ${constraints.minLength}`);
239
+ (0, Assertion_1.assertTruthy)(value.length <= ((_b = constraints.maxLength) !== null && _b !== void 0 ? _b : Infinity), `${(0, Assertion_1.getErrorMessage)(context)} length is too large ${value.length} > ${constraints.maxLength}`);
240
+ };
241
+ exports.stringAssertion = stringAssertion;
242
+ //# sourceMappingURL=AssertionFactoriesLib.js.map
243
+
244
+ /***/ }),
245
+
246
+ /***/ 5412:
247
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
248
+
249
+ "use strict";
250
+
251
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
252
+ exports.assertNonNullable = exports.assertEmail = exports.assertHexString = exports.assertUuid = exports.assertBoolean = exports.assertNumber = exports.assertString = exports.formatError = void 0;
253
+ const Assertion_1 = __webpack_require__(9471);
254
+ const ChecksLib_1 = __webpack_require__(2389);
255
+ function formatError(contextProvider, message, value) {
256
+ const context = (0, Assertion_1.getErrorMessage)(contextProvider);
257
+ const renderedValue = value === undefined
258
+ ? '<undefined>'
259
+ : value === null
260
+ ? '<null>'
261
+ : `<${typeof value}:${value}>`;
262
+ return `${context ? `${context}: ` : ''}${message} ${renderedValue}`;
263
+ }
264
+ exports.formatError = formatError;
265
+ /*** Asserts that *value* is a *string*. */
266
+ const assertString = (value, context = undefined) => {
267
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isString)(value), () => formatError(context, 'Not a string', value));
268
+ };
269
+ exports.assertString = assertString;
270
+ const assertNumber = (value, context = undefined) => {
271
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNumber)(value), () => formatError(context, 'Not a number', value));
272
+ };
273
+ exports.assertNumber = assertNumber;
274
+ const assertBoolean = (value, context = undefined) => {
275
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isBoolean)(value), () => formatError(context, 'Not a boolean', value));
276
+ };
277
+ exports.assertBoolean = assertBoolean;
278
+ const assertUuid = (value, context = undefined) => {
279
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isUuid)(value), () => formatError(context, 'Invalid uuid', value));
280
+ };
281
+ exports.assertUuid = assertUuid;
282
+ const assertHexString = (value, context = undefined) => {
283
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isHexString)(value), () => formatError(context, 'Invalid hex string', value));
284
+ };
285
+ exports.assertHexString = assertHexString;
286
+ const assertEmail = (value, context = undefined) => {
287
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isEmail)(value), () => formatError(context, 'Invalid email', value));
288
+ };
289
+ exports.assertEmail = assertEmail;
290
+ function assertNonNullable(value, context = undefined) {
291
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNonNullable)(value), () => formatError(context, `Value is ${value === undefined ? 'undefined' : 'null'}`, value));
292
+ }
293
+ exports.assertNonNullable = assertNonNullable;
294
+ //# sourceMappingURL=AssertionsLib.js.map
295
+
296
+ /***/ }),
297
+
298
+ /***/ 2389:
299
+ /***/ ((__unused_webpack_module, exports) => {
300
+
301
+ "use strict";
302
+
303
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
304
+ exports.isNonNullable = exports.isHexString = exports.isUuid = exports.isEmail = exports.checkArrayHasUniqueElements = exports.isNumber = exports.isString = exports.isBoolean = void 0;
305
+ /** Returns *true* if the value is *boolean*. */
306
+ function isBoolean(value) {
307
+ return typeof value === 'boolean';
308
+ }
309
+ exports.isBoolean = isBoolean;
310
+ /** Returns *true* if the value is *string*. */
311
+ function isString(value) {
312
+ return typeof value === 'string';
313
+ }
314
+ exports.isString = isString;
315
+ /** Returns *true* if the value is *number*. */
316
+ function isNumber(value) {
317
+ return typeof value === 'number';
318
+ }
319
+ exports.isNumber = isNumber;
320
+ /**
321
+ * Checks that array has only unique elements.
322
+ * Uses 'identity' function to perform checks.
323
+ */
324
+ function checkArrayHasUniqueElements(array, identity) {
325
+ if (array.length <= 1) {
326
+ return true;
327
+ }
328
+ const set = new Set();
329
+ for (const e of array) {
330
+ const id = identity(e);
331
+ if (set.has(id)) {
332
+ return false;
333
+ }
334
+ set.add(id);
335
+ }
336
+ return true;
337
+ }
338
+ exports.checkArrayHasUniqueElements = checkArrayHasUniqueElements;
339
+ const EMAIL_REGEX_REGULAR = /^[-!#$%&'*+/\d=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/\d=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z\d])*\.[a-zA-Z](-?[a-zA-Z\d])+$/;
340
+ // eslint-disable-next-line no-misleading-character-class
341
+ const EMAIL_REGEX_INTERNATIONAL = /^(?!\.)((?!.*\.{2})[a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF.!#$%&'*+-/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF\-.\d]+)((\.([a-zA-Z\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]){2,63})+)$/i;
342
+ /** Returns true if *email* is a valid email address. */
343
+ function isEmail(email, constraints = { allowInternationalDomains: false }) {
344
+ if (!isString(email) || email.length === 0 || email.length > 254) {
345
+ return false;
346
+ }
347
+ const regex = constraints.allowInternationalDomains ? EMAIL_REGEX_INTERNATIONAL : EMAIL_REGEX_REGULAR;
348
+ if (!regex.test(email)) {
349
+ return false;
350
+ }
351
+ // Validate each part.
352
+ const parts = email.split('@');
353
+ if (parts[0].length > 64) {
354
+ return false;
355
+ }
356
+ const domainParts = parts[1].split('.');
357
+ return !domainParts.some(part => part.length > 63);
358
+ }
359
+ exports.isEmail = isEmail;
360
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
361
+ /** Returns *true* if *value* is a valid 'uuid' (v1..v5) string. */
362
+ function isUuid(value) {
363
+ return isString(value) && UUID_REGEX.test(value);
364
+ }
365
+ exports.isUuid = isUuid;
366
+ const HEX_STRING_REGEX = /^[0-9a-fA-F]*$/;
367
+ /** Returns *true* if *value* is a string that contains only hexadecimal characters or is empty. */
368
+ function isHexString(value) {
369
+ return isString(value) && HEX_STRING_REGEX.test(value);
370
+ }
371
+ exports.isHexString = isHexString;
372
+ /** Returns true if value is not 'null' and not 'undefined'. */
373
+ function isNonNullable(value) {
374
+ return value !== null && value !== undefined;
375
+ }
376
+ exports.isNonNullable = isNonNullable;
377
+ //# sourceMappingURL=ChecksLib.js.map
378
+
379
+ /***/ }),
380
+
381
+ /***/ 3222:
382
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
383
+
384
+ "use strict";
385
+
386
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
387
+ if (k2 === undefined) k2 = k;
388
+ var desc = Object.getOwnPropertyDescriptor(m, k);
389
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
390
+ desc = { enumerable: true, get: function() { return m[k]; } };
391
+ }
392
+ Object.defineProperty(o, k2, desc);
393
+ }) : (function(o, m, k, k2) {
394
+ if (k2 === undefined) k2 = k;
395
+ o[k2] = m[k];
396
+ }));
397
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
398
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
399
+ };
400
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
401
+ __exportStar(__webpack_require__(9471), exports);
402
+ __exportStar(__webpack_require__(8263), exports);
403
+ __exportStar(__webpack_require__(5412), exports);
404
+ __exportStar(__webpack_require__(2389), exports);
405
+ //# sourceMappingURL=index.js.map
406
+
407
+ /***/ }),
408
+
4
409
  /***/ 8278:
5
410
  /***/ ((__unused_webpack_module, exports) => {
6
411
 
@@ -6948,6 +7353,419 @@ function escapeJsonPtr(str) {
6948
7353
  }
6949
7354
 
6950
7355
 
7356
+ /***/ }),
7357
+
7358
+ /***/ 8975:
7359
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7360
+
7361
+ "use strict";
7362
+
7363
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7364
+ if (k2 === undefined) k2 = k;
7365
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7366
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7367
+ desc = { enumerable: true, get: function() { return m[k]; } };
7368
+ }
7369
+ Object.defineProperty(o, k2, desc);
7370
+ }) : (function(o, m, k, k2) {
7371
+ if (k2 === undefined) k2 = k;
7372
+ o[k2] = m[k];
7373
+ }));
7374
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
7375
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7376
+ };
7377
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7378
+ __exportStar(__webpack_require__(3355), exports);
7379
+ //# sourceMappingURL=index.js.map
7380
+
7381
+ /***/ }),
7382
+
7383
+ /***/ 6676:
7384
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7385
+
7386
+ "use strict";
7387
+
7388
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7389
+ exports.callValueAssertion = exports.assertArray = exports.assertObject = exports.getErrorMessage = exports.getAssertionErrorFromProvider = exports.fail = exports.truthy = exports.assertTruthy = void 0;
7390
+ const ChecksLib_1 = __webpack_require__(9862);
7391
+ /** Asserts that the *param* value is truthy using '!' operator or throws an Error. */
7392
+ function assertTruthy(value, error) {
7393
+ if (!value) {
7394
+ fail(error);
7395
+ }
7396
+ }
7397
+ exports.assertTruthy = assertTruthy;
7398
+ /**
7399
+ * Casts the 'value' to a non-nullable type or throws an error.
7400
+ * Uses 'assertTruthy' to make the check.
7401
+ */
7402
+ function truthy(value, error) {
7403
+ assertTruthy(value, error);
7404
+ return value;
7405
+ }
7406
+ exports.truthy = truthy;
7407
+ function fail(error) {
7408
+ const errorMessage = getAssertionErrorFromProvider(error);
7409
+ if (typeof errorMessage === 'object') {
7410
+ throw errorMessage;
7411
+ }
7412
+ throw new Error(errorMessage || 'Assertion error');
7413
+ }
7414
+ exports.fail = fail;
7415
+ /** Returns validation context as a string. Calls errorProvider() if needed. */
7416
+ function getAssertionErrorFromProvider(errorProvider) {
7417
+ if (errorProvider === undefined) {
7418
+ return '';
7419
+ }
7420
+ if (typeof errorProvider === 'string') {
7421
+ return errorProvider;
7422
+ }
7423
+ return errorProvider();
7424
+ }
7425
+ exports.getAssertionErrorFromProvider = getAssertionErrorFromProvider;
7426
+ /** Returns validation context as a string. Calls errorProvider() if needed. */
7427
+ function getErrorMessage(errorProvider) {
7428
+ const error = getAssertionErrorFromProvider(errorProvider);
7429
+ return typeof error === 'string' ? error : error.message || '<no error message>';
7430
+ }
7431
+ exports.getErrorMessage = getErrorMessage;
7432
+ /**
7433
+ * Asserts that the object satisfies the schema using individual field assertions.
7434
+ * Throws an error if not.
7435
+ * Works only with non-array objects: use 'assertArray' to check arrays.
7436
+ */
7437
+ function assertObject(value, objectAssertion, errorContextProvider = undefined, constraints = {}) {
7438
+ const ctx = () => { return getErrorMessage(errorContextProvider); };
7439
+ const errorWithContext = (message) => {
7440
+ const context = ctx();
7441
+ return context.length === 0 ? message : `${context} ${message}`;
7442
+ };
7443
+ assertTruthy(typeof value === 'object', () => errorWithContext(`is not an object: ${typeof value}`));
7444
+ assertTruthy(value !== undefined, () => errorWithContext(`is not defined`));
7445
+ assertTruthy(value !== null, () => errorWithContext(`is null`));
7446
+ assertTruthy(!Array.isArray(value), () => errorWithContext(`is an array.`));
7447
+ const assertionEntries = Object.entries(objectAssertion);
7448
+ if (constraints.failOnUnknownFields) {
7449
+ for (const objectFieldName in value) {
7450
+ assertTruthy(assertionEntries.some(([assertionFieldName]) => objectFieldName === assertionFieldName), errorWithContext(`property can't be checked: ${objectFieldName}`));
7451
+ }
7452
+ }
7453
+ let $o;
7454
+ for (const [fieldKey, fieldAssertion] of assertionEntries) {
7455
+ assertTruthy(typeof fieldAssertion === 'function' ||
7456
+ (typeof fieldAssertion === 'object' && fieldAssertion !== null), () => `${ctx()}.${fieldKey} assertion is not an object or a function: ${typeof fieldAssertion}`);
7457
+ const fieldValue = value[fieldKey];
7458
+ const fieldCtx = () => `${ctx()}.${fieldKey}`;
7459
+ if (typeof fieldAssertion === 'object') {
7460
+ assertTruthy(!Array.isArray(fieldValue), () => `${ctx()}.${fieldCtx()} use arrayAssertion() to create a ValueAssertion for an array`);
7461
+ assertObject(fieldValue, fieldAssertion, fieldCtx);
7462
+ }
7463
+ else {
7464
+ assertTruthy(typeof fieldAssertion === 'function', () => `${ctx()}.${fieldCtx()} assertion is not a function`);
7465
+ if (fieldKey === '$o') {
7466
+ $o = fieldAssertion; // Will be run last.
7467
+ }
7468
+ else {
7469
+ const checkResult = fieldAssertion(fieldValue, fieldCtx);
7470
+ assertTruthy(checkResult === undefined, `Assertion function must assert (void) but it returns a value: ${checkResult}. Wrap with $v()?`);
7471
+ }
7472
+ }
7473
+ }
7474
+ if ($o) {
7475
+ $o(value, errorContextProvider);
7476
+ }
7477
+ }
7478
+ exports.assertObject = assertObject;
7479
+ /**
7480
+ * Asserts that the *value* is an array and every element in the array satisfy to the *elementAssertion*.
7481
+ * Throws error if check fails.
7482
+ */
7483
+ function assertArray(value, elementAssertion, constraints = {}, errorContextProvider = undefined) {
7484
+ var _a, _b;
7485
+ const ctx = (mode = 'with-space-separator') => {
7486
+ const text = getErrorMessage(errorContextProvider);
7487
+ return text ? `${text}${mode === 'with-space-separator' ? ' ' : ''}` : '';
7488
+ };
7489
+ assertTruthy(Array.isArray(value), () => `${ctx()}value is not an array: ${value}`);
7490
+ const minLength = (_a = constraints.minLength) !== null && _a !== void 0 ? _a : 0;
7491
+ const maxLength = (_b = constraints.maxLength) !== null && _b !== void 0 ? _b : Infinity;
7492
+ assertTruthy(value.length >= minLength, () => `${ctx()}array length < minLength. Array length: ${value.length}, minLength: ${minLength}`);
7493
+ assertTruthy(value.length <= maxLength, () => `${ctx()}array length > maxLength. Array length: ${value.length}, maxLength: ${maxLength}`);
7494
+ if (constraints.uniqueByIdentity) {
7495
+ assertTruthy((0, ChecksLib_1.checkArrayHasUniqueElements)(value, constraints.uniqueByIdentity), () => `${ctx()}array contains non-unique elements`);
7496
+ }
7497
+ let i = 0;
7498
+ const elementErrorProvider = () => `${ctx('no-space-separator')}[${i}]`;
7499
+ for (; i < value.length; i++) {
7500
+ const element = value[i];
7501
+ if (typeof elementAssertion === 'object') {
7502
+ assertTruthy(!Array.isArray(element), () => `${elementErrorProvider}: use arrayAssertion() to create a ValueAssertion for an array`);
7503
+ assertObject(element, elementAssertion, elementErrorProvider);
7504
+ }
7505
+ else {
7506
+ callValueAssertion(element, elementAssertion, elementErrorProvider);
7507
+ }
7508
+ }
7509
+ }
7510
+ exports.assertArray = assertArray;
7511
+ /**
7512
+ * Calls the assertion.
7513
+ * Workaround for TS issue with assertion on genetic arrow function. See https://github.com/microsoft/TypeScript/issues/34523.
7514
+ */
7515
+ function callValueAssertion(value, valueAssertion, errorContextProvider) {
7516
+ valueAssertion(value, errorContextProvider);
7517
+ }
7518
+ exports.callValueAssertion = callValueAssertion;
7519
+ //# sourceMappingURL=Assertion.js.map
7520
+
7521
+ /***/ }),
7522
+
7523
+ /***/ 4810:
7524
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7525
+
7526
+ "use strict";
7527
+
7528
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7529
+ exports.stringAssertion = exports.nullOr = exports.undefinedOr = exports.valueOr = exports.$a = exports.arrayAssertion = exports.objectAssertion = void 0;
7530
+ const Assertion_1 = __webpack_require__(6676);
7531
+ const AssertionsLib_1 = __webpack_require__(4356);
7532
+ /** A shortcut to build new object type assertion. */
7533
+ function objectAssertion(objectTypeAssertion, errorContextProvider = undefined) {
7534
+ return o => (0, Assertion_1.assertObject)(o, objectTypeAssertion, errorContextProvider);
7535
+ }
7536
+ exports.objectAssertion = objectAssertion;
7537
+ /**
7538
+ * Creates an assertion for array object that checks that array is defined,
7539
+ * the array satisfies the *constraints* and every element of the array passes the *elementAssertion* check.
7540
+ */
7541
+ function arrayAssertion(elementAssertion, constraints = {}) {
7542
+ const { minLength, maxLength } = constraints;
7543
+ (0, Assertion_1.assertTruthy)((minLength !== null && minLength !== void 0 ? minLength : 0) <= (maxLength !== null && maxLength !== void 0 ? maxLength : Infinity), `minLength must be < maxLength! minLength ${minLength}, maxLength: ${maxLength}`);
7544
+ (0, Assertion_1.assertTruthy)((minLength !== null && minLength !== void 0 ? minLength : 0) >= 0, `minLength must be a positive number: ${minLength}`);
7545
+ (0, Assertion_1.assertTruthy)((maxLength !== null && maxLength !== void 0 ? maxLength : 0) >= 0, `maxLength must be a positive number: ${maxLength}`);
7546
+ return (array, errorContextProvider = undefined) => {
7547
+ (0, Assertion_1.assertArray)(array, elementAssertion, constraints, errorContextProvider);
7548
+ };
7549
+ }
7550
+ exports.arrayAssertion = arrayAssertion;
7551
+ /**
7552
+ * Creates a new value assertion using *check* function.
7553
+ * The assertion accepts the value as valid if 'check(value)' returns true or throws an error otherwise.
7554
+ */
7555
+ function $a(check, errorMessageProvider) {
7556
+ (0, Assertion_1.assertTruthy)(typeof check === 'function', `"check" is not a function: ${check}`);
7557
+ return (value, errorContextProvider = undefined) => (0, Assertion_1.assertTruthy)(check(value), () => {
7558
+ let errorContext = (0, Assertion_1.getErrorMessage)(errorContextProvider) || 'Check is failed';
7559
+ if (!errorContext.endsWith(':')) {
7560
+ errorContext += ':';
7561
+ }
7562
+ const errorMessage = (0, Assertion_1.getErrorMessage)(errorMessageProvider);
7563
+ return `${errorContext} ${(errorMessage || (typeof value === 'object' ? '[object]' : `'${value}'`))}`;
7564
+ });
7565
+ }
7566
+ exports.$a = $a;
7567
+ /**
7568
+ * Creates an assertion that makes comparison by reference with the *expectedValue* before calling *orAssertion*.
7569
+ * If comparison with the *expectedValue* succeeds, does not call the *orAssertion*.
7570
+ */
7571
+ function valueOr(expectedValue, orAssertion) {
7572
+ return (value, errorContextProvider = undefined) => {
7573
+ if (value === expectedValue)
7574
+ return;
7575
+ if (typeof orAssertion === 'object') {
7576
+ (0, Assertion_1.assertObject)(value, orAssertion, errorContextProvider);
7577
+ }
7578
+ else {
7579
+ (0, Assertion_1.callValueAssertion)(value, orAssertion, errorContextProvider);
7580
+ }
7581
+ };
7582
+ }
7583
+ exports.valueOr = valueOr;
7584
+ /** Creates an assertion that succeeds if the value is *undefined* or calls *orAssertion* if the value is not *undefined*. */
7585
+ function undefinedOr(orAssertion) {
7586
+ return valueOr(undefined, orAssertion);
7587
+ }
7588
+ exports.undefinedOr = undefinedOr;
7589
+ /** Creates an assertion that succeeds if the value is *null* or calls *orAssertion* if the value is not *undefined*. */
7590
+ function nullOr(orAssertion) {
7591
+ return valueOr(null, orAssertion);
7592
+ }
7593
+ exports.nullOr = nullOr;
7594
+ const stringAssertion = (constraints) => (value, context = undefined) => {
7595
+ var _a, _b;
7596
+ (0, AssertionsLib_1.assertString)(value, context);
7597
+ (0, Assertion_1.assertTruthy)(value.length >= ((_a = constraints.minLength) !== null && _a !== void 0 ? _a : 0), `${(0, Assertion_1.getErrorMessage)(context)} length is too small: ${value.length} < ${constraints.minLength}`);
7598
+ (0, Assertion_1.assertTruthy)(value.length <= ((_b = constraints.maxLength) !== null && _b !== void 0 ? _b : Infinity), `${(0, Assertion_1.getErrorMessage)(context)} length is too large ${value.length} > ${constraints.maxLength}`);
7599
+ };
7600
+ exports.stringAssertion = stringAssertion;
7601
+ //# sourceMappingURL=AssertionFactoriesLib.js.map
7602
+
7603
+ /***/ }),
7604
+
7605
+ /***/ 4356:
7606
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7607
+
7608
+ "use strict";
7609
+
7610
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7611
+ exports.assertNonNullable = exports.assertEmail = exports.assertHexString = exports.assertUuid = exports.assertBoolean = exports.assertNumber = exports.assertString = exports.formatError = void 0;
7612
+ const Assertion_1 = __webpack_require__(6676);
7613
+ const ChecksLib_1 = __webpack_require__(9862);
7614
+ function formatError(contextProvider, message, value) {
7615
+ const context = (0, Assertion_1.getAssertionErrorFromProvider)(contextProvider);
7616
+ if (typeof context === 'object') {
7617
+ throw context;
7618
+ }
7619
+ const renderedValue = value === undefined
7620
+ ? '<undefined>'
7621
+ : value === null
7622
+ ? '<null>'
7623
+ : `<${typeof value}:${value}>`;
7624
+ return `${context ? `${context}: ` : ''}${message} ${renderedValue}`;
7625
+ }
7626
+ exports.formatError = formatError;
7627
+ /*** Asserts that *value* is a *string*. */
7628
+ const assertString = (value, context = undefined) => {
7629
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isString)(value), () => formatError(context, 'Not a string', value));
7630
+ };
7631
+ exports.assertString = assertString;
7632
+ const assertNumber = (value, context = undefined) => {
7633
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNumber)(value), () => formatError(context, 'Not a number', value));
7634
+ };
7635
+ exports.assertNumber = assertNumber;
7636
+ const assertBoolean = (value, context = undefined) => {
7637
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isBoolean)(value), () => formatError(context, 'Not a boolean', value));
7638
+ };
7639
+ exports.assertBoolean = assertBoolean;
7640
+ const assertUuid = (value, context = undefined) => {
7641
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isUuid)(value), () => formatError(context, 'Invalid uuid', value));
7642
+ };
7643
+ exports.assertUuid = assertUuid;
7644
+ const assertHexString = (value, context = undefined) => {
7645
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isHexString)(value), () => formatError(context, 'Invalid hex string', value));
7646
+ };
7647
+ exports.assertHexString = assertHexString;
7648
+ const assertEmail = (value, context = undefined) => {
7649
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isEmail)(value), () => formatError(context, 'Invalid email', value));
7650
+ };
7651
+ exports.assertEmail = assertEmail;
7652
+ function assertNonNullable(value, context) {
7653
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNonNullable)(value), () => formatError(context, `Value is ${value === undefined ? 'undefined' : 'null'}`, value));
7654
+ }
7655
+ exports.assertNonNullable = assertNonNullable;
7656
+ //# sourceMappingURL=AssertionsLib.js.map
7657
+
7658
+ /***/ }),
7659
+
7660
+ /***/ 9862:
7661
+ /***/ ((__unused_webpack_module, exports) => {
7662
+
7663
+ "use strict";
7664
+
7665
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7666
+ exports.isNonNullable = exports.isHexString = exports.isUuid = exports.isEmail = exports.checkArrayHasUniqueElements = exports.isNumber = exports.isString = exports.isBoolean = void 0;
7667
+ /** Returns *true* if the value is *boolean*. */
7668
+ function isBoolean(value) {
7669
+ return typeof value === 'boolean';
7670
+ }
7671
+ exports.isBoolean = isBoolean;
7672
+ /** Returns *true* if the value is *string*. */
7673
+ function isString(value) {
7674
+ return typeof value === 'string';
7675
+ }
7676
+ exports.isString = isString;
7677
+ /** Returns *true* if the value is *number*. */
7678
+ function isNumber(value) {
7679
+ return typeof value === 'number';
7680
+ }
7681
+ exports.isNumber = isNumber;
7682
+ /**
7683
+ * Checks that array has only unique elements.
7684
+ * Uses 'identity' function to perform checks.
7685
+ */
7686
+ function checkArrayHasUniqueElements(array, identity) {
7687
+ if (array.length <= 1) {
7688
+ return true;
7689
+ }
7690
+ const set = new Set();
7691
+ for (const e of array) {
7692
+ const id = identity(e);
7693
+ if (set.has(id)) {
7694
+ return false;
7695
+ }
7696
+ set.add(id);
7697
+ }
7698
+ return true;
7699
+ }
7700
+ exports.checkArrayHasUniqueElements = checkArrayHasUniqueElements;
7701
+ const EMAIL_REGEX_REGULAR = /^[-!#$%&'*+/\d=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/\d=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z\d])*\.[a-zA-Z](-?[a-zA-Z\d])+$/;
7702
+ // eslint-disable-next-line no-misleading-character-class
7703
+ const EMAIL_REGEX_INTERNATIONAL = /^(?!\.)((?!.*\.{2})[a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF.!#$%&'*+-/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF\-.\d]+)((\.([a-zA-Z\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]){2,63})+)$/i;
7704
+ /** Returns true if *email* is a valid email address. */
7705
+ function isEmail(email, constraints = { allowInternationalDomains: false }) {
7706
+ if (!isString(email) || email.length === 0 || email.length > 254) {
7707
+ return false;
7708
+ }
7709
+ const regex = constraints.allowInternationalDomains ? EMAIL_REGEX_INTERNATIONAL : EMAIL_REGEX_REGULAR;
7710
+ if (!regex.test(email)) {
7711
+ return false;
7712
+ }
7713
+ // Validate each part.
7714
+ const parts = email.split('@');
7715
+ if (parts[0].length > 64) {
7716
+ return false;
7717
+ }
7718
+ const domainParts = parts[1].split('.');
7719
+ return !domainParts.some(part => part.length > 63);
7720
+ }
7721
+ exports.isEmail = isEmail;
7722
+ const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
7723
+ /** Returns *true* if *value* is a valid 'uuid' (v1..v5) string. */
7724
+ function isUuid(value) {
7725
+ return isString(value) && UUID_REGEX.test(value);
7726
+ }
7727
+ exports.isUuid = isUuid;
7728
+ const HEX_STRING_REGEX = /^[0-9a-fA-F]*$/;
7729
+ /** Returns *true* if *value* is a string that contains only hexadecimal characters or is empty. */
7730
+ function isHexString(value) {
7731
+ return isString(value) && HEX_STRING_REGEX.test(value);
7732
+ }
7733
+ exports.isHexString = isHexString;
7734
+ /** Returns true if value is not 'null' and not 'undefined'. */
7735
+ function isNonNullable(value) {
7736
+ return value !== null && value !== undefined;
7737
+ }
7738
+ exports.isNonNullable = isNonNullable;
7739
+ //# sourceMappingURL=ChecksLib.js.map
7740
+
7741
+ /***/ }),
7742
+
7743
+ /***/ 3355:
7744
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7745
+
7746
+ "use strict";
7747
+
7748
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7749
+ if (k2 === undefined) k2 = k;
7750
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7751
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7752
+ desc = { enumerable: true, get: function() { return m[k]; } };
7753
+ }
7754
+ Object.defineProperty(o, k2, desc);
7755
+ }) : (function(o, m, k, k2) {
7756
+ if (k2 === undefined) k2 = k;
7757
+ o[k2] = m[k];
7758
+ }));
7759
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
7760
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7761
+ };
7762
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7763
+ __exportStar(__webpack_require__(6676), exports);
7764
+ __exportStar(__webpack_require__(4810), exports);
7765
+ __exportStar(__webpack_require__(4356), exports);
7766
+ __exportStar(__webpack_require__(9862), exports);
7767
+ //# sourceMappingURL=index.js.map
7768
+
6951
7769
  /***/ }),
6952
7770
 
6953
7771
  /***/ 2091:
@@ -26308,14 +27126,15 @@ __webpack_require__.r(__webpack_exports__);
26308
27126
 
26309
27127
  // EXPORTS
26310
27128
  __webpack_require__.d(__webpack_exports__, {
26311
- "Changes": () => (/* reexport */ Changes),
26312
- "CollectionReference": () => (/* reexport */ CollectionReference),
26313
- "DocumentReference": () => (/* reexport */ DocumentReference),
26314
- "GraphQLClient": () => (/* reexport */ GraphQLClient),
26315
- "JoinQueryBuilder": () => (/* reexport */ JoinQueryBuilder),
26316
- "QueryBuilder": () => (/* reexport */ QueryBuilder),
26317
- "Squid": () => (/* reexport */ Squid),
26318
- "deserializeQuery": () => (/* reexport */ deserializeQuery)
27129
+ AiAssistantProfileReference: () => (/* reexport */ AiAssistantProfileReference),
27130
+ Changes: () => (/* reexport */ Changes),
27131
+ CollectionReference: () => (/* reexport */ CollectionReference),
27132
+ DocumentReference: () => (/* reexport */ DocumentReference),
27133
+ GraphQLClient: () => (/* reexport */ GraphQLClient),
27134
+ JoinQueryBuilder: () => (/* reexport */ JoinQueryBuilder),
27135
+ QueryBuilder: () => (/* reexport */ QueryBuilder),
27136
+ Squid: () => (/* reexport */ Squid),
27137
+ deserializeQuery: () => (/* reexport */ deserializeQuery)
26319
27138
  });
26320
27139
 
26321
27140
  ;// CONCATENATED MODULE: ../common/src/ai-assistant.schemas.ts
@@ -26820,9 +27639,8 @@ const GraphQLConnectionOptionsSchema = {
26820
27639
  const OpenApiDiscoveryOptionsSchema = {
26821
27640
  type: 'object',
26822
27641
  nullable: false,
26823
- required: ['openApiSpecUrl'],
26824
27642
  properties: {
26825
- openApiSpecUrl: { type: 'string', nullable: false },
27643
+ openApiSpecUrl: { type: 'string', nullable: true },
26826
27644
  },
26827
27645
  };
26828
27646
  /** Generated using openai */
@@ -27581,7 +28399,6 @@ const DiscoverOpenApiSchemaRequestSchema = {
27581
28399
  properties: {
27582
28400
  discoveryOptions: {
27583
28401
  type: 'object',
27584
- required: ['openApiSpecUrl'],
27585
28402
  properties: {
27586
28403
  openApiSpecUrl: {
27587
28404
  type: 'string',
@@ -28368,319 +29185,8 @@ class BaseQueryBuilder {
28368
29185
 
28369
29186
  ;// CONCATENATED MODULE: external "rxjs"
28370
29187
  const external_rxjs_namespaceObject = require("rxjs");
28371
- ;// CONCATENATED MODULE: ../common/src/http-status.enum.ts
28372
- var http_status_enum_HttpStatus;
28373
- (function (HttpStatus) {
28374
- HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
28375
- HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
28376
- HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
28377
- HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
28378
- HttpStatus[HttpStatus["OK"] = 200] = "OK";
28379
- HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
28380
- HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
28381
- HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
28382
- HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
28383
- HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
28384
- HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
28385
- HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
28386
- HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
28387
- HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
28388
- HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
28389
- HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
28390
- HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
28391
- HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
28392
- HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
28393
- HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
28394
- HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
28395
- HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
28396
- HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
28397
- HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
28398
- HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
28399
- HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
28400
- HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
28401
- HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
28402
- HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
28403
- HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
28404
- HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
28405
- HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
28406
- HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
28407
- HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
28408
- HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
28409
- HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
28410
- HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
28411
- HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
28412
- HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
28413
- HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
28414
- HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
28415
- HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
28416
- HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
28417
- HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
28418
- HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
28419
- HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
28420
- HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
28421
- HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
28422
- })(http_status_enum_HttpStatus || (http_status_enum_HttpStatus = {}));
28423
-
28424
- ;// CONCATENATED MODULE: ../common/src/utils/validation.ts
28425
-
28426
- class validation_ValidationError extends Error {
28427
- constructor(error, statusCode, details) {
28428
- super(error);
28429
- this.statusCode = statusCode;
28430
- this.details = details;
28431
- }
28432
- }
28433
- function validatePathPart(part) {
28434
- if (!part || !part.match(/^[a-zA-Z][a-zA-Z0-9!@#$%^&*~_]{0,49}$/)) {
28435
- throw new Error('A document id and a collection id can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting' +
28436
- 'with a letter, at least one character, and up to 50.');
28437
- }
28438
- }
28439
- function validateCollectionName(collectionName) {
28440
- if (typeof collectionName !== 'string' || !collectionName) {
28441
- throw new Error('Collection path has to be a non empty string');
28442
- }
28443
- validatePathPart(collectionName);
28444
- }
28445
- function validateFieldName(fieldName) {
28446
- if (!fieldName || typeof fieldName !== 'string') {
28447
- throw new Error('Field name has to be a non-empty string');
28448
- }
28449
- if (fieldName === '__docId__') {
28450
- // __docId__ is the only valid fieldName that can start with '_'
28451
- return;
28452
- }
28453
- if (!fieldName.match(/^[a-zA-Z_$][a-zA-Z0-9!@#$%^&*~_ ]{0,49}$/)) {
28454
- 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: ' +
28455
- fieldName);
28456
- }
28457
- }
28458
- // TODO: remove if not used
28459
- function validateQueryCondition(condition) {
28460
- if (!condition) {
28461
- throw new Error('Condition cannot be empty');
28462
- }
28463
- if (!condition.operator ||
28464
- !['==', '!=', '>', '>=', '<', '<=', 'like', 'not like', 'like_cs', 'not like_cs'].includes(condition.operator)) {
28465
- throw new Error('Unsupported operator: ' + condition.operator);
28466
- }
28467
- validateFieldName(condition.fieldName);
28468
- // TODO - figure out how to validate the value
28469
- }
28470
- function validateFieldSort(fieldSort) {
28471
- if (!(fieldSort instanceof Object)) {
28472
- throw new Error('Field sort has to be an object');
28473
- }
28474
- assert_assertTruthy(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
28475
- assert_assertTruthy(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
28476
- validateFieldName(fieldSort.fieldName);
28477
- }
28478
- function validateOpenIdProvider(openIdProvider) {
28479
- assertTruthy(openIdProvider, 'INVALID_PROVIDER');
28480
- validateOpenIdProviderType(openIdProvider.providerType);
28481
- assertTruthy(openIdProvider.providerType, 'INVALID_CLIENT_ID');
28482
- assertTruthy(openIdProvider.clientId, 'INVALID_CLIENT_ID');
28483
- assertTruthy(openIdProvider.domain, 'INVALID_DOMAIN');
28484
- return openIdProvider;
28485
- }
28486
- function validateOpenIdProviderType(providerType) {
28487
- const providerArray = ['auth0'];
28488
- assertTruthy(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
28489
- }
28490
- function validateDeleteMutation(mutation) {
28491
- if (!mutation || mutation.type !== 'delete') {
28492
- throw new Error('Mutation has to be non empty with type delete.');
28493
- }
28494
- // Not much to validate for delete.
28495
- }
28496
- function validateInsertMutation(mutation) {
28497
- if (!mutation || mutation.type !== 'insert') {
28498
- throw new Error('Mutation has to be non empty with type insert.');
28499
- }
28500
- if (!mutation.properties || typeof mutation.properties !== 'object') {
28501
- throw new Error('The properties in insert mutation need to be a JSON object.');
28502
- }
28503
- for (const [fieldName] of Object.entries(mutation.properties)) {
28504
- validateFieldName(fieldName);
28505
- // TODO - figure out how to validate the value
28506
- }
28507
- }
28508
- function validateUpdatePropertyMutation(propertyMutation) {
28509
- if (!propertyMutation || propertyMutation.type !== 'update') {
28510
- throw new Error('Update value property mutation has to be of type update');
28511
- }
28512
- if (propertyMutation.value === undefined) {
28513
- throw new Error('Value has to exist in an update value property mutation..');
28514
- }
28515
- }
28516
- function validateApplyNumericFnPropertyMutation(propertyMutation) {
28517
- if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
28518
- throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
28519
- }
28520
- if (!['increment'].includes(propertyMutation.fn)) {
28521
- throw new Error('Invalid fn for apply numeric fn.');
28522
- }
28523
- if (typeof propertyMutation.value !== 'number') {
28524
- throw new Error('The value in an apply numeric fn function has to be numeric.');
28525
- }
28526
- }
28527
- function validateApplyStringFnPropertyMutation(propertyMutation) {
28528
- if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
28529
- throw new Error('Apply string fn mutation has to be of type applyStringFn');
28530
- }
28531
- if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
28532
- throw new Error('Invalid fn for apply string fn.');
28533
- }
28534
- if (typeof propertyMutation.value !== 'string') {
28535
- throw new Error('The value in an apply string fn function has to be a string.');
28536
- }
28537
- }
28538
- function validatePropertyMutation(propertyMutation) {
28539
- if (!propertyMutation || typeof propertyMutation !== 'object') {
28540
- throw new Error('Property mutation need to be a JSON object.');
28541
- }
28542
- if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
28543
- throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
28544
- }
28545
- switch (propertyMutation.type) {
28546
- case 'update':
28547
- validateUpdatePropertyMutation(propertyMutation);
28548
- break;
28549
- case 'applyNumericFn':
28550
- validateApplyNumericFnPropertyMutation(propertyMutation);
28551
- break;
28552
- case 'applyStringFn':
28553
- validateApplyStringFnPropertyMutation(propertyMutation);
28554
- break;
28555
- }
28556
- }
28557
- function validateUpdateMutation(mutation) {
28558
- if (!mutation || mutation.type !== 'update') {
28559
- throw new Error('Mutation has to be non empty with type update.');
28560
- }
28561
- if (!mutation.properties || typeof mutation.properties !== 'object') {
28562
- throw new Error('The properties in update mutation need to be a JSON object.');
28563
- }
28564
- const entries = Object.entries(mutation.properties);
28565
- for (const [fieldName, propertyMutations] of entries) {
28566
- validateFieldName(fieldName);
28567
- for (const propertyMutation of propertyMutations) {
28568
- validatePropertyMutation(propertyMutation);
28569
- }
28570
- }
28571
- }
28572
- function validateMutation(mutation) {
28573
- if (!mutation) {
28574
- throw new Error('Mutation cannot be empty');
28575
- }
28576
- if (!['insert', 'delete', 'update'].includes(mutation.type)) {
28577
- throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
28578
- }
28579
- validateCollectionName(mutation.squidDocIdObj.collectionName);
28580
- validatePathPart(mutation.squidDocIdObj.docId);
28581
- switch (mutation.type) {
28582
- case 'delete':
28583
- validateDeleteMutation(mutation);
28584
- break;
28585
- case 'insert':
28586
- validateInsertMutation(mutation);
28587
- break;
28588
- case 'update':
28589
- validateUpdateMutation(mutation);
28590
- break;
28591
- }
28592
- }
28593
- function validateMutations(mutations) {
28594
- if (!mutations || !(mutations instanceof Array) || !mutations.length) {
28595
- throw new Error('The list of mutations has to be a non-empty array.');
28596
- }
28597
- for (const mutation of mutations) {
28598
- validateMutation(mutation);
28599
- }
28600
- }
28601
- function validateQueryLimit(limit) {
28602
- assert_assertTruthy(isRightType(limit, 'number'), 'Limit needs to be a number');
28603
- if (limit === -1)
28604
- return;
28605
- assert_assertTruthy(limit > 0, 'query limit has to be greater than 0');
28606
- assert_assertTruthy(Math.floor(limit) === limit, 'query limit has to be an integer');
28607
- assert_assertTruthy(limit <= 20000, 'Limit can be maximum 20000');
28608
- }
28609
- /** Returns true if the value is not an empty string (undefined/null are considered empty). */
28610
- function isNotEmpty(value) {
28611
- validateCorrectStringType(value);
28612
- return typeof value === 'string' && !!value;
28613
- }
28614
- /**
28615
- * TODO: deprecated: this method is used in both validate...() and is...() methods.
28616
- * The validate...() must throw an error, while is...() must not.
28617
- */
28618
- function validateCorrectStringType(value) {
28619
- if (value !== null && value !== undefined && typeof value !== 'string') {
28620
- throw new Error(`Unexpected input type ${typeof value}`);
28621
- }
28622
- }
28623
- /** Returns true if 'typeof' of the 'value' is 'type' or 'type[]'. */
28624
- function isRightType(value, type) {
28625
- // TODO: the method is ambiguous when the value is an empty array and will return 'true' for any type.
28626
- if (Array.isArray(value)) {
28627
- return value.every((element) => typeof element === type);
28628
- }
28629
- return typeof value === type;
28630
- }
28631
- /** Returns true if 'obj' has only keys listed in the 'keys'. Object can't be an array. */
28632
- function hasOnlyKeys(obj, keys) {
28633
- return !Array.isArray(obj) && [...Object.keys(obj)].every((key) => keys.includes(key));
28634
- }
28635
-
28636
- ;// CONCATENATED MODULE: ../common/src/utils/assert.ts
28637
-
28638
-
28639
-
28640
- /** @internal */
28641
- function assert_assertTruthy(value, error) {
28642
- if (value) {
28643
- return;
28644
- }
28645
- const messageOrObject = typeof error === 'function' ? error() : error;
28646
- if (messageOrObject instanceof Error) {
28647
- throw messageOrObject;
28648
- }
28649
- else {
28650
- throw new Error(messageOrObject !== null && messageOrObject !== void 0 ? messageOrObject : 'Assertion error');
28651
- }
28652
- }
28653
- /** @internal */
28654
- function assertNotNullish(value, error) {
28655
- if (isNotNullish(value))
28656
- return;
28657
- const messageOrObject = typeof error === 'function' ? error() : error;
28658
- if (messageOrObject instanceof Error) {
28659
- throw messageOrObject;
28660
- }
28661
- else {
28662
- throw new Error(messageOrObject !== null && messageOrObject !== void 0 ? messageOrObject : 'Assertion error');
28663
- }
28664
- }
28665
- /** @internal */
28666
- function assertValidateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
28667
- assert_assertTruthy(value, () => new ValidationError(message, statusCode, details));
28668
- }
28669
- /** @internal */
28670
- function assert_truthy(value, error) {
28671
- assert_assertTruthy(value, error);
28672
- return value;
28673
- }
28674
- /** @internal */
28675
- function assert_notNullish(value, error) {
28676
- assertNotNullish(value, error);
28677
- return value;
28678
- }
28679
- /** @internal */
28680
- function validateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
28681
- return assert_truthy(value, () => new ValidationError(message, statusCode, details));
28682
- }
28683
-
29188
+ // EXTERNAL MODULE: ../common/node_modules/assertic/dist/index.js
29189
+ var dist = __webpack_require__(4113);
28684
29190
  ;// CONCATENATED MODULE: ../common/src/utils/object.ts
28685
29191
 
28686
29192
 
@@ -28689,7 +29195,7 @@ function getInPath(obj, path, delimiter = '.') {
28689
29195
  let value = undefined;
28690
29196
  let currentObj = obj;
28691
29197
  while (currentObj && splitPath.length) {
28692
- const key = assert_truthy(splitPath.shift());
29198
+ const key = (0,dist.truthy)(splitPath.shift());
28693
29199
  if (!(currentObj instanceof Object) || !(key in currentObj)) {
28694
29200
  return undefined;
28695
29201
  }
@@ -28708,7 +29214,7 @@ function setInPath(obj, path, value, delimiter = '.') {
28708
29214
  const splitPath = path.split(delimiter);
28709
29215
  let currentObj = obj;
28710
29216
  while (splitPath.length) {
28711
- const key = assert_truthy(splitPath.shift());
29217
+ const key = (0,dist.truthy)(splitPath.shift());
28712
29218
  if (splitPath.length) {
28713
29219
  const newCurrentObj = isJsObject(currentObj[key]) ? (_a = lodash.clone(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
28714
29220
  currentObj[key] = newCurrentObj;
@@ -28724,7 +29230,7 @@ function deleteInPath(obj, path, delimiter = '.') {
28724
29230
  const splitPath = path.split(delimiter);
28725
29231
  let currentObj = obj;
28726
29232
  while (splitPath.length) {
28727
- const key = assert_truthy(splitPath.shift());
29233
+ const key = (0,dist.truthy)(splitPath.shift());
28728
29234
  if (splitPath.length) {
28729
29235
  const newCurrentObj = isJsObject(currentObj[key]) ? (_a = lodash.clone(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
28730
29236
  currentObj[key] = newCurrentObj;
@@ -29090,13 +29596,18 @@ function isWebhookResponse(response) {
29090
29596
  }
29091
29597
 
29092
29598
  ;// CONCATENATED MODULE: ../common/src/communication.types.ts
29599
+ /**
29600
+ * The appId is the unique identifier of an application.
29601
+ * It is the combination of the application id (as shown in the console), environment id (dev, prod) and the
29602
+ * developer id (if exists). For example - "fdgfd90ds-dev-1234567890abcdef"
29603
+ */
29093
29604
 
29094
29605
  const allEnvironmentIds = (/* unused pure expression or super */ null && (['prod', 'dev']));
29095
29606
  /** @internal */
29096
29607
  function parseAppId(appId) {
29097
29608
  /** We're splitting also by underscore because of backward compatibility - remove this in a few months */
29098
29609
  const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split(/[_-]/);
29099
- assert_assertTruthy(!other, 'Invalid appId: ' + appId);
29610
+ (0,dist.assertTruthy)(!other, 'Invalid appId: ' + appId);
29100
29611
  return {
29101
29612
  appId: appIdWithoutEnv,
29102
29613
  environmentId: (environmentId !== null && environmentId !== void 0 ? environmentId : 'prod'),
@@ -29178,7 +29689,7 @@ function hasDocumentDiff(beforeDoc, afterDoc) {
29178
29689
  switch (diff.kind) {
29179
29690
  case 'N':
29180
29691
  // If a new property has been added, and it's defined, the document is changed.
29181
- return isNotNullish(diff.rhs);
29692
+ return isNonNullable(diff.rhs);
29182
29693
  case 'E':
29183
29694
  case 'D':
29184
29695
  case 'A':
@@ -29223,6 +29734,59 @@ const EmptyIntrospection = {
29223
29734
  },
29224
29735
  };
29225
29736
 
29737
+ ;// CONCATENATED MODULE: ../common/src/http-status.enum.ts
29738
+ var http_status_enum_HttpStatus;
29739
+ (function (HttpStatus) {
29740
+ HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
29741
+ HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
29742
+ HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
29743
+ HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
29744
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
29745
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
29746
+ HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
29747
+ HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
29748
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
29749
+ HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
29750
+ HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
29751
+ HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
29752
+ HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
29753
+ HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
29754
+ HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
29755
+ HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
29756
+ HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
29757
+ HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
29758
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
29759
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
29760
+ HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
29761
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
29762
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
29763
+ HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
29764
+ HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
29765
+ HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
29766
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
29767
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
29768
+ HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
29769
+ HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
29770
+ HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
29771
+ HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
29772
+ HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
29773
+ HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
29774
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
29775
+ HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
29776
+ HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
29777
+ HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
29778
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
29779
+ HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
29780
+ HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
29781
+ HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
29782
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
29783
+ HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
29784
+ HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
29785
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
29786
+ HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
29787
+ HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
29788
+ })(http_status_enum_HttpStatus || (http_status_enum_HttpStatus = {}));
29789
+
29226
29790
  ;// CONCATENATED MODULE: ../common/src/logger.types.ts
29227
29791
  var LogLevel;
29228
29792
  (function (LogLevel) {
@@ -29426,7 +29990,7 @@ function mergeMutations(mutationA, mutationB) {
29426
29990
  // At this point mutationB.type has to be 'update'
29427
29991
  if (mutationA.type === 'delete')
29428
29992
  throw new Error('Cannot delete and then update');
29429
- assert_assertTruthy(mutationB.type === 'update', 'Invalid mutation type');
29993
+ (0,dist.assertTruthy)(mutationB.type === 'update', 'Invalid mutation type');
29430
29994
  if (mutationA.type === 'update')
29431
29995
  return mergeUpdateMutations(mutationA, mutationB);
29432
29996
  const result = lodash.cloneDeep(mutationA);
@@ -29545,7 +30109,7 @@ function getSquidSupportedCloudMap() {
29545
30109
  id: 'aws',
29546
30110
  name: 'Amazon Web Services',
29547
30111
  icon: 'aws_icon',
29548
- regions: [squidSupportedRegionMap['us-east-1.aws']].filter(isNotNullish),
30112
+ regions: [squidSupportedRegionMap['us-east-1.aws']].filter(isNonNullable),
29549
30113
  },
29550
30114
  gcp: {
29551
30115
  id: 'gcp',
@@ -29579,8 +30143,225 @@ function convertFromSquidRegion(regionAndCloud) {
29579
30143
  var ajv = __webpack_require__(6236);
29580
30144
  var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv);
29581
30145
  // EXTERNAL MODULE: ../node_modules/ajv-formats/dist/index.js
29582
- var dist = __webpack_require__(8414);
29583
- var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
30146
+ var ajv_formats_dist = __webpack_require__(8414);
30147
+ var ajv_formats_dist_default = /*#__PURE__*/__webpack_require__.n(ajv_formats_dist);
30148
+ ;// CONCATENATED MODULE: ../common/src/utils/validation.ts
30149
+ /**
30150
+ * This file contains general validators for the different objects being received from the client. The parameters are
30151
+ * usually of type 'any' to make sure there are no assumptions that the object has the correct type.
30152
+ * Also, this file should avoid importing from other files that are not for validation to avoid circular deps.
30153
+ */
30154
+
30155
+ class validation_ValidationError extends (/* unused pure expression or super */ null && (Error)) {
30156
+ constructor(error, statusCode, details) {
30157
+ super(error);
30158
+ this.statusCode = statusCode;
30159
+ this.details = details;
30160
+ }
30161
+ }
30162
+ function validatePathPart(part) {
30163
+ if (!part || !part.match(/^[a-zA-Z][a-zA-Z0-9!@#$%^&*~_]{0,49}$/)) {
30164
+ throw new Error('A document id and a collection id can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting' +
30165
+ 'with a letter, at least one character, and up to 50.');
30166
+ }
30167
+ }
30168
+ function validateCollectionName(collectionName) {
30169
+ if (typeof collectionName !== 'string' || !collectionName) {
30170
+ throw new Error('Collection path has to be a non empty string');
30171
+ }
30172
+ validatePathPart(collectionName);
30173
+ }
30174
+ function validateFieldName(fieldName) {
30175
+ if (!fieldName || typeof fieldName !== 'string') {
30176
+ throw new Error('Field name has to be a non-empty string');
30177
+ }
30178
+ if (fieldName === '__docId__') {
30179
+ // __docId__ is the only valid fieldName that can start with '_'
30180
+ return;
30181
+ }
30182
+ if (!fieldName.match(/^[a-zA-Z_$][a-zA-Z0-9!@#$%^&*~_ ]{0,49}$/)) {
30183
+ 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: ' +
30184
+ fieldName);
30185
+ }
30186
+ }
30187
+ // TODO: remove if not used
30188
+ function validateQueryCondition(condition) {
30189
+ if (!condition) {
30190
+ throw new Error('Condition cannot be empty');
30191
+ }
30192
+ if (!condition.operator ||
30193
+ !['==', '!=', '>', '>=', '<', '<=', 'like', 'not like', 'like_cs', 'not like_cs'].includes(condition.operator)) {
30194
+ throw new Error('Unsupported operator: ' + condition.operator);
30195
+ }
30196
+ validateFieldName(condition.fieldName);
30197
+ // TODO - figure out how to validate the value
30198
+ }
30199
+ function validateFieldSort(fieldSort) {
30200
+ if (!(fieldSort instanceof Object)) {
30201
+ throw new Error('Field sort has to be an object');
30202
+ }
30203
+ (0,dist.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
30204
+ (0,dist.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
30205
+ validateFieldName(fieldSort.fieldName);
30206
+ }
30207
+ function validateOpenIdProvider(openIdProvider) {
30208
+ assertTruthy(openIdProvider, 'INVALID_PROVIDER');
30209
+ validateOpenIdProviderType(openIdProvider.providerType);
30210
+ assertTruthy(openIdProvider.providerType, 'INVALID_CLIENT_ID');
30211
+ assertTruthy(openIdProvider.clientId, 'INVALID_CLIENT_ID');
30212
+ assertTruthy(openIdProvider.domain, 'INVALID_DOMAIN');
30213
+ return openIdProvider;
30214
+ }
30215
+ function validateOpenIdProviderType(providerType) {
30216
+ const providerArray = ['auth0'];
30217
+ assertTruthy(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
30218
+ }
30219
+ function validateDeleteMutation(mutation) {
30220
+ if (!mutation || mutation.type !== 'delete') {
30221
+ throw new Error('Mutation has to be non empty with type delete.');
30222
+ }
30223
+ // Not much to validate for delete.
30224
+ }
30225
+ function validateInsertMutation(mutation) {
30226
+ if (!mutation || mutation.type !== 'insert') {
30227
+ throw new Error('Mutation has to be non empty with type insert.');
30228
+ }
30229
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
30230
+ throw new Error('The properties in insert mutation need to be a JSON object.');
30231
+ }
30232
+ for (const [fieldName] of Object.entries(mutation.properties)) {
30233
+ validateFieldName(fieldName);
30234
+ // TODO - figure out how to validate the value
30235
+ }
30236
+ }
30237
+ function validateUpdatePropertyMutation(propertyMutation) {
30238
+ if (!propertyMutation || propertyMutation.type !== 'update') {
30239
+ throw new Error('Update value property mutation has to be of type update');
30240
+ }
30241
+ if (propertyMutation.value === undefined) {
30242
+ throw new Error('Value has to exist in an update value property mutation..');
30243
+ }
30244
+ }
30245
+ function validateApplyNumericFnPropertyMutation(propertyMutation) {
30246
+ if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
30247
+ throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
30248
+ }
30249
+ if (!['increment'].includes(propertyMutation.fn)) {
30250
+ throw new Error('Invalid fn for apply numeric fn.');
30251
+ }
30252
+ if (typeof propertyMutation.value !== 'number') {
30253
+ throw new Error('The value in an apply numeric fn function has to be numeric.');
30254
+ }
30255
+ }
30256
+ function validateApplyStringFnPropertyMutation(propertyMutation) {
30257
+ if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
30258
+ throw new Error('Apply string fn mutation has to be of type applyStringFn');
30259
+ }
30260
+ if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
30261
+ throw new Error('Invalid fn for apply string fn.');
30262
+ }
30263
+ if (typeof propertyMutation.value !== 'string') {
30264
+ throw new Error('The value in an apply string fn function has to be a string.');
30265
+ }
30266
+ }
30267
+ function validatePropertyMutation(propertyMutation) {
30268
+ if (!propertyMutation || typeof propertyMutation !== 'object') {
30269
+ throw new Error('Property mutation need to be a JSON object.');
30270
+ }
30271
+ if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
30272
+ throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
30273
+ }
30274
+ switch (propertyMutation.type) {
30275
+ case 'update':
30276
+ validateUpdatePropertyMutation(propertyMutation);
30277
+ break;
30278
+ case 'applyNumericFn':
30279
+ validateApplyNumericFnPropertyMutation(propertyMutation);
30280
+ break;
30281
+ case 'applyStringFn':
30282
+ validateApplyStringFnPropertyMutation(propertyMutation);
30283
+ break;
30284
+ }
30285
+ }
30286
+ function validateUpdateMutation(mutation) {
30287
+ if (!mutation || mutation.type !== 'update') {
30288
+ throw new Error('Mutation has to be non empty with type update.');
30289
+ }
30290
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
30291
+ throw new Error('The properties in update mutation need to be a JSON object.');
30292
+ }
30293
+ const entries = Object.entries(mutation.properties);
30294
+ for (const [fieldName, propertyMutations] of entries) {
30295
+ validateFieldName(fieldName);
30296
+ for (const propertyMutation of propertyMutations) {
30297
+ validatePropertyMutation(propertyMutation);
30298
+ }
30299
+ }
30300
+ }
30301
+ function validateMutation(mutation) {
30302
+ if (!mutation) {
30303
+ throw new Error('Mutation cannot be empty');
30304
+ }
30305
+ if (!['insert', 'delete', 'update'].includes(mutation.type)) {
30306
+ throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
30307
+ }
30308
+ validateCollectionName(mutation.squidDocIdObj.collectionName);
30309
+ validatePathPart(mutation.squidDocIdObj.docId);
30310
+ switch (mutation.type) {
30311
+ case 'delete':
30312
+ validateDeleteMutation(mutation);
30313
+ break;
30314
+ case 'insert':
30315
+ validateInsertMutation(mutation);
30316
+ break;
30317
+ case 'update':
30318
+ validateUpdateMutation(mutation);
30319
+ break;
30320
+ }
30321
+ }
30322
+ function validateMutations(mutations) {
30323
+ if (!mutations || !(mutations instanceof Array) || !mutations.length) {
30324
+ throw new Error('The list of mutations has to be a non-empty array.');
30325
+ }
30326
+ for (const mutation of mutations) {
30327
+ validateMutation(mutation);
30328
+ }
30329
+ }
30330
+ function validateQueryLimit(limit) {
30331
+ (0,dist.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
30332
+ if (limit === -1)
30333
+ return;
30334
+ (0,dist.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
30335
+ (0,dist.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
30336
+ (0,dist.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
30337
+ }
30338
+ /** Returns true if the value is not an empty string (undefined/null are considered empty). */
30339
+ function isNotEmpty(value) {
30340
+ validateCorrectStringType(value);
30341
+ return typeof value === 'string' && !!value;
30342
+ }
30343
+ /**
30344
+ * TODO: deprecated: this method is used in both validate...() and is...() methods.
30345
+ * The validate...() must throw an error, while is...() must not.
30346
+ */
30347
+ function validateCorrectStringType(value) {
30348
+ if (value !== null && value !== undefined && typeof value !== 'string') {
30349
+ throw new Error(`Unexpected input type ${typeof value}`);
30350
+ }
30351
+ }
30352
+ /** Returns true if 'typeof' of the 'value' is 'type' or 'type[]'. */
30353
+ function isRightType(value, type) {
30354
+ // TODO: the method is ambiguous when the value is an empty array and will return 'true' for any type.
30355
+ if (Array.isArray(value)) {
30356
+ return value.every((element) => typeof element === type);
30357
+ }
30358
+ return typeof value === type;
30359
+ }
30360
+ /** Returns true if 'obj' has only keys listed in the 'keys'. Object can't be an array. */
30361
+ function hasOnlyKeys(obj, keys) {
30362
+ return !Array.isArray(obj) && [...Object.keys(obj)].every((key) => keys.includes(key));
30363
+ }
30364
+
29584
30365
  ;// CONCATENATED MODULE: ../common/src/schema/schema.types.ts
29585
30366
 
29586
30367
 
@@ -29589,7 +30370,7 @@ var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
29589
30370
 
29590
30371
 
29591
30372
  const schema_types_ajv = new (ajv_default())({ allErrors: true, allowUnionTypes: false, useDefaults: false });
29592
- dist_default()(schema_types_ajv);
30373
+ ajv_formats_dist_default()(schema_types_ajv);
29593
30374
  schema_types_ajv.addKeyword({
29594
30375
  keyword: 'isDate',
29595
30376
  type: 'object',
@@ -29728,7 +30509,8 @@ function getMatchingProperties(path, schema) {
29728
30509
  result.parentsMatch.push(schema);
29729
30510
  const pathToUse = [...path];
29730
30511
  while (pathToUse.length) {
29731
- const key = notNullish(pathToUse.shift());
30512
+ const key = pathToUse.shift();
30513
+ assertTruthy(key !== undefined);
29732
30514
  const matchingPropertiesForKey = findMatchingPropertiesForKey(schema, key);
29733
30515
  for (const property of matchingPropertiesForKey) {
29734
30516
  const subMatchingProperties = getMatchingProperties(pathToUse, property);
@@ -29903,12 +30685,17 @@ const arrayMergeCustomizer = (a, b) => {
29903
30685
  }
29904
30686
  };
29905
30687
 
29906
- ;// CONCATENATED MODULE: ../common/src/utils/error.ts
29907
- class CodeExecutionError extends Error {
29908
- constructor(error, details) {
29909
- super(error);
29910
- this.details = details;
29911
- }
30688
+ ;// CONCATENATED MODULE: ../common/src/utils/assert.ts
30689
+
30690
+
30691
+
30692
+ /** @internal */
30693
+ function assertValidateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
30694
+ assertTruthy(value, () => new ValidationError(message, statusCode, details));
30695
+ }
30696
+ /** @internal */
30697
+ function validateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
30698
+ return truthy(value, () => new ValidationError(message, statusCode, details));
29912
30699
  }
29913
30700
 
29914
30701
  ;// CONCATENATED MODULE: ../common/src/utils/http.ts
@@ -29992,7 +30779,7 @@ class LockManager {
29992
30779
  }
29993
30780
  release(...mutexes) {
29994
30781
  for (const mutex of mutexes) {
29995
- const isLockedSubject = assert_truthy(this.locks[mutex]);
30782
+ const isLockedSubject = (0,dist.truthy)(this.locks[mutex]);
29996
30783
  isLockedSubject.next(false);
29997
30784
  isLockedSubject.complete();
29998
30785
  delete this.locks[mutex];
@@ -30002,21 +30789,13 @@ class LockManager {
30002
30789
  return !mutexes.some((mutex) => { var _a; return (_a = this.locks[mutex]) === null || _a === void 0 ? void 0 : _a.value; });
30003
30790
  }
30004
30791
  lockSync(...mutexes) {
30005
- assert_assertTruthy(this.canGetLock(...mutexes), 'Cannot acquire lock sync');
30792
+ (0,dist.assertTruthy)(this.canGetLock(...mutexes), 'Cannot acquire lock sync');
30006
30793
  for (const mutex of mutexes) {
30007
30794
  this.locks[mutex] = new external_rxjs_namespaceObject.BehaviorSubject(true);
30008
30795
  }
30009
30796
  }
30010
30797
  }
30011
30798
 
30012
- ;// CONCATENATED MODULE: ../common/src/utils/nullish.ts
30013
- function nullish_isNotNullish(t) {
30014
- return t !== null && t !== undefined;
30015
- }
30016
- function isString(t) {
30017
- return typeof t === 'string';
30018
- }
30019
-
30020
30799
  ;// CONCATENATED MODULE: ../common/src/heartbeat.types.ts
30021
30800
 
30022
30801
  async function checkAllHeartbeatProviders(heartbeatProviders) {
@@ -30207,7 +30986,6 @@ function createWebSocketWrapper(url, opts = {}) {
30207
30986
 
30208
30987
 
30209
30988
 
30210
-
30211
30989
 
30212
30990
 
30213
30991
 
@@ -31663,10 +32441,13 @@ class MergedQueryBuilder {
31663
32441
  }
31664
32442
  }
31665
32443
 
32444
+ // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
32445
+ var assertic_dist = __webpack_require__(8975);
31666
32446
  ;// CONCATENATED MODULE: ./src/document-reference.ts
31667
32447
 
31668
32448
 
31669
32449
 
32450
+
31670
32451
  /**
31671
32452
  * Holds a reference to a document. A document reference is a reference to a specific record in a collection. You can
31672
32453
  * use it to read or write data to the document. A document can refer to a row in a table in a relational database or a
@@ -31708,7 +32489,7 @@ class DocumentReference {
31708
32489
  integrationId,
31709
32490
  }, null, 2)}`;
31710
32491
  };
31711
- return assert_truthy(this.dataManager.getProperties(this.squidDocId), getError());
32492
+ return (0,assertic_dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError());
31712
32493
  }
31713
32494
  /**
31714
32495
  * Returns whether data has been populated for this document reference. Data
@@ -31731,7 +32512,7 @@ class DocumentReference {
31731
32512
  if (this.isTracked() && this.hasData)
31732
32513
  return this.data;
31733
32514
  const results = await this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshot();
31734
- assert_truthy(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32515
+ (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
31735
32516
  return results.length ? results[0] : undefined;
31736
32517
  }
31737
32518
  /**
@@ -31747,7 +32528,7 @@ class DocumentReference {
31747
32528
  .dereference()
31748
32529
  .snapshots()
31749
32530
  .pipe((0,external_rxjs_namespaceObject.map)((results) => {
31750
- assert_truthy(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32531
+ (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
31751
32532
  return results.length ? results[0] : undefined;
31752
32533
  }));
31753
32534
  }
@@ -31930,6 +32711,7 @@ class DocumentReference {
31930
32711
 
31931
32712
 
31932
32713
 
32714
+
31933
32715
  /** @internal */
31934
32716
  class QueryBuilderFactory {
31935
32717
  constructor(querySubscriptionManager, localQueryManager, documentReferenceFactory, documentIdentityService) {
@@ -32064,7 +32846,7 @@ class QueryBuilder extends BaseQueryBuilder {
32064
32846
  sortBy(fieldName, asc = true) {
32065
32847
  const fieldSort = { asc, fieldName };
32066
32848
  validateFieldSort(fieldSort);
32067
- assert_assertTruthy(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
32849
+ (0,assertic_dist.assertTruthy)(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
32068
32850
  this.query.sortOrder.push(fieldSort);
32069
32851
  return this;
32070
32852
  }
@@ -32136,9 +32918,9 @@ class QueryBuilder extends BaseQueryBuilder {
32136
32918
  .processQuery(query, this.collectionName, {}, {}, subscribe, this.forceFetchFromServer)
32137
32919
  .pipe(map_map((docs) => {
32138
32920
  return docs.map((docRecord) => {
32139
- assert_assertTruthy(Object.keys(docRecord).length === 1);
32921
+ (0,assertic_dist.assertTruthy)(Object.keys(docRecord).length === 1);
32140
32922
  const doc = docRecord[this.collectionName];
32141
- const squidDocId = getSquidDocId(assert_truthy(doc).__docId__, this.collectionName, this.integrationId);
32923
+ const squidDocId = getSquidDocId((0,assertic_dist.truthy)(doc).__docId__, this.collectionName, this.integrationId);
32142
32924
  return this.documentReferenceFactory.create(squidDocId, this.queryBuilderFactory);
32143
32925
  });
32144
32926
  }));
@@ -32975,6 +33757,7 @@ var promise_pool_dist = __webpack_require__(3910);
32975
33757
 
32976
33758
 
32977
33759
 
33760
+
32978
33761
  /** Two transactions cannot run in parallel - this mutex is used for blocking a second transaction. */
32979
33762
  const RUN_IN_TRANSACTION_MUTEX = 'dataManager_runInTransaction';
32980
33763
  class DataManager {
@@ -33099,7 +33882,7 @@ class DataManager {
33099
33882
  */
33100
33883
  async runInTransaction(fn, transactionId) {
33101
33884
  if (transactionId) {
33102
- assert_assertTruthy(transactionId === this.currentTransactionId, 'Transaction already ended.');
33885
+ (0,assertic_dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33103
33886
  return fn(transactionId).then(() => Promise.resolve());
33104
33887
  }
33105
33888
  if (this.lockManager.canGetLock(RUN_IN_TRANSACTION_MUTEX)) {
@@ -33180,7 +33963,7 @@ class DataManager {
33180
33963
  /** Same as runInTransaction with the exception that the passed function runs synchronously. */
33181
33964
  async runInTransactionSync(fn, transactionId) {
33182
33965
  if (transactionId) {
33183
- assert_assertTruthy(transactionId === this.currentTransactionId, 'Transaction already ended.');
33966
+ (0,assertic_dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33184
33967
  fn(transactionId);
33185
33968
  return;
33186
33969
  }
@@ -33426,7 +34209,7 @@ class DataManager {
33426
34209
  async sendAllUnsentOutgoingMutations(promiseResolver) {
33427
34210
  const outgoingMutationsByIntegrationId = this.groupOutgoingMutationsByIntegrationId();
33428
34211
  try {
33429
- await promise_pool_dist.PromisePool["for"](outgoingMutationsByIntegrationId)
34212
+ await promise_pool_dist.PromisePool.for(outgoingMutationsByIntegrationId)
33430
34213
  .withConcurrency(outgoingMutationsByIntegrationId.length || 1)
33431
34214
  .handleError((e) => {
33432
34215
  throw e;
@@ -33492,7 +34275,7 @@ class DataManager {
33492
34275
  }
33493
34276
  removeOutgoingMutation(outgoingMutation) {
33494
34277
  const squidDocId = getSquidDocId(outgoingMutation.mutation.squidDocIdObj);
33495
- const outgoingMutationsForDoc = assert_truthy(this.pendingOutgoingMutations.get(squidDocId));
34278
+ const outgoingMutationsForDoc = (0,assertic_dist.truthy)(this.pendingOutgoingMutations.get(squidDocId));
33496
34279
  outgoingMutationsForDoc.splice(outgoingMutationsForDoc.indexOf(outgoingMutation), 1);
33497
34280
  if (!outgoingMutationsForDoc.length) {
33498
34281
  this.pendingOutgoingMutations.delete(squidDocId);
@@ -33507,7 +34290,7 @@ class DataManager {
33507
34290
  this.setExpiration(squidDocId, true);
33508
34291
  try {
33509
34292
  const results = await this.queryBuilderFactory.getForDocument(squidDocId).setForceFetchFromServer().snapshot();
33510
- assert_truthy(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
34293
+ (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
33511
34294
  /** The document does not exist anymore, so we can forget about it */
33512
34295
  if (!results.length) {
33513
34296
  this.forgetDocument(squidDocId);
@@ -33795,6 +34578,7 @@ class DocumentIdentityService {
33795
34578
  ;// CONCATENATED MODULE: ./src/document-reference.factory.ts
33796
34579
 
33797
34580
 
34581
+
33798
34582
  class DocumentReferenceFactory {
33799
34583
  constructor(documentIdentityService) {
33800
34584
  this.documentIdentityService = documentIdentityService;
@@ -33808,7 +34592,7 @@ class DocumentReferenceFactory {
33808
34592
  let reference = this.documents.get(squidDocId);
33809
34593
  if (reference)
33810
34594
  return reference;
33811
- reference = new DocumentReference(squidDocId, assert_truthy(this.dataManager, 'dataManager not found'), queryBuilderFactory);
34595
+ reference = new DocumentReference(squidDocId, (0,assertic_dist.truthy)(this.dataManager, 'dataManager not found'), queryBuilderFactory);
33812
34596
  const { integrationId, collectionName } = parseSquidDocId(squidDocId);
33813
34597
  this.documents.set(squidDocId, reference);
33814
34598
  const collectionKey = this.getCollectionKey(integrationId, collectionName);
@@ -33847,15 +34631,12 @@ class DocumentReferenceFactory {
33847
34631
  ;// CONCATENATED MODULE: ./src/document-store.ts
33848
34632
 
33849
34633
 
34634
+
33850
34635
  function groupAndSort(sortedDocs, sortFieldNames, sortOrders) {
33851
34636
  const groups = Object.values(lodash_default().groupBy(sortedDocs, (doc) => {
33852
34637
  return serialization_normalizeJsonAsString(sortFieldNames.map((fieldName) => getInPath(doc, fieldName)));
33853
34638
  }));
33854
- const sortFieldIterators = sortFieldNames.map((fieldName) => {
33855
- return (group) => {
33856
- getInPath(group[0], fieldName);
33857
- };
33858
- });
34639
+ const sortFieldIterators = sortFieldNames.map((fieldName) => (group) => getInPath(group[0], fieldName));
33859
34640
  return (0,lodash.orderBy)(groups, sortFieldIterators, sortOrders);
33860
34641
  }
33861
34642
  class DocumentStore {
@@ -33888,7 +34669,7 @@ class DocumentStore {
33888
34669
  return doc !== undefined;
33889
34670
  }
33890
34671
  getDocument(squidDocId) {
33891
- return assert_truthy(this.getDocumentOrUndefined(squidDocId));
34672
+ return (0,assertic_dist.truthy)(this.getDocumentOrUndefined(squidDocId));
33892
34673
  }
33893
34674
  getDocumentOrUndefined(squidDocId) {
33894
34675
  return this.squidDocIdToDoc.get(squidDocId);
@@ -33897,7 +34678,7 @@ class DocumentStore {
33897
34678
  if (docIdSet.size === 0) {
33898
34679
  return [];
33899
34680
  }
33900
- const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(nullish_isNotNullish);
34681
+ const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(assertic_dist.isNonNullable);
33901
34682
  const { sortOrder, limitBy } = query;
33902
34683
  const sortFieldNames = sortOrder.map((s) => s.fieldName);
33903
34684
  const sortOrders = sortOrder.map((s) => (s.asc ? 'asc' : 'desc'));
@@ -47787,6 +48568,7 @@ var LimitUnderflowState;
47787
48568
 
47788
48569
 
47789
48570
 
48571
+
47790
48572
  // See limitUnderflowState below.
47791
48573
  // Exported only for tests
47792
48574
  const FETCH_BEYOND_LIMIT = 100;
@@ -47846,7 +48628,7 @@ class QuerySubscriptionManager {
47846
48628
  * Returns the query associated with the given clientRequestId. Throws error if the clientRequestId is not known.
47847
48629
  */
47848
48630
  getQuery(clientRequestId) {
47849
- return assert_truthy(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
48631
+ return (0,assertic_dist.truthy)(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
47850
48632
  }
47851
48633
  /**
47852
48634
  * A query receives updates from two different sources:
@@ -47951,7 +48733,7 @@ class QuerySubscriptionManager {
47951
48733
  .some(Boolean);
47952
48734
  let rootOngoingQuery = ongoingQuery;
47953
48735
  while (!rootOngoingQuery.allObservables) {
47954
- rootOngoingQuery = assert_truthy(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
48736
+ rootOngoingQuery = (0,assertic_dist.truthy)(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
47955
48737
  }
47956
48738
  if (observablesUpdated) {
47957
48739
  rootOngoingQueries.add(rootOngoingQuery);
@@ -47978,7 +48760,7 @@ class QuerySubscriptionManager {
47978
48760
  }
47979
48761
  for (const rootOngoingQuery of rootOngoingQueries) {
47980
48762
  const allObservables = this.collectAllObservables(rootOngoingQuery);
47981
- assert_truthy(rootOngoingQuery.allObservables).next(allObservables);
48763
+ (0,assertic_dist.truthy)(rootOngoingQuery.allObservables).next(allObservables);
47982
48764
  }
47983
48765
  }
47984
48766
  isValidParent(candidateParentQuery) {
@@ -48082,7 +48864,7 @@ class QuerySubscriptionManager {
48082
48864
  this.clientRequestIdToLocalDocuments.delete(clientRequestId);
48083
48865
  const orphanDocument = [];
48084
48866
  for (const doc of docs) {
48085
- const clientRequestIds = assert_truthy(this.localDocumentToClientRequestIds.get(doc));
48867
+ const clientRequestIds = (0,assertic_dist.truthy)(this.localDocumentToClientRequestIds.get(doc));
48086
48868
  clientRequestIds.delete(clientRequestId);
48087
48869
  if (!clientRequestIds.size) {
48088
48870
  this.localDocumentToClientRequestIds.delete(doc);
@@ -48146,7 +48928,7 @@ class QuerySubscriptionManager {
48146
48928
  done: false,
48147
48929
  isInFlight: false,
48148
48930
  forceFetchFromServer: false,
48149
- limitUnderflowState: LimitUnderflowState.UNKNOWN,
48931
+ limitUnderflowState: subscribe ? LimitUnderflowState.UNKNOWN : LimitUnderflowState.DISABLED,
48150
48932
  };
48151
48933
  this.registerQueryFinalizer(result);
48152
48934
  this.ongoingQueries.set(clientRequestId, result);
@@ -48218,7 +49000,7 @@ class QuerySubscriptionManager {
48218
49000
  const val = doc[joinCondition.right];
48219
49001
  if (!rightAsMap.has(val))
48220
49002
  rightAsMap.set(val, []);
48221
- assert_truthy(rightAsMap.get(val)).push(doc);
49003
+ (0,assertic_dist.truthy)(rightAsMap.get(val)).push(doc);
48222
49004
  });
48223
49005
  return left.flatMap((leftElement) => {
48224
49006
  var _a;
@@ -48238,7 +49020,7 @@ class QuerySubscriptionManager {
48238
49020
  const result = [];
48239
49021
  const queue = [rootOngoingQuery];
48240
49022
  while (queue.length) {
48241
- const current = assert_truthy(queue.shift());
49023
+ const current = (0,assertic_dist.truthy)(queue.shift());
48242
49024
  if (current.isEmptyForJoin)
48243
49025
  continue;
48244
49026
  result.push(current);
@@ -48248,7 +49030,7 @@ class QuerySubscriptionManager {
48248
49030
  }
48249
49031
  updateOngoingQueryWithNewDataFromSupportingQuery(supportingQueryResult, supportedOngoingQuery) {
48250
49032
  var _a;
48251
- const joinCondition = assert_truthy(supportedOngoingQuery.joinCondition);
49033
+ const joinCondition = (0,assertic_dist.truthy)(supportedOngoingQuery.joinCondition);
48252
49034
  const query = supportedOngoingQuery.query;
48253
49035
  if (!supportedOngoingQuery.activated) {
48254
49036
  const newConditions = supportingQueryResult.map((supportingDoc) => {
@@ -48271,7 +49053,7 @@ class QuerySubscriptionManager {
48271
49053
  return true;
48272
49054
  }
48273
49055
  else {
48274
- const supportedQueriesWithSameAlias = assert_truthy((_a = supportedOngoingQuery.supportingOngoingQuery) === null || _a === void 0 ? void 0 : _a.supportedQueries).filter((q) => q.alias === supportedOngoingQuery.alias);
49056
+ const supportedQueriesWithSameAlias = (0,assertic_dist.truthy)((_a = supportedOngoingQuery.supportingOngoingQuery) === null || _a === void 0 ? void 0 : _a.supportedQueries).filter((q) => q.alias === supportedOngoingQuery.alias);
48275
49057
  const allNeededValues = new Set(supportingQueryResult.map((resultDoc) => { var _a; return (_a = resultDoc[joinCondition.left]) !== null && _a !== void 0 ? _a : null; }));
48276
49058
  for (const supportedQuery of supportedQueriesWithSameAlias) {
48277
49059
  supportedQuery.query.conditions
@@ -48296,7 +49078,7 @@ class QuerySubscriptionManager {
48296
49078
  const ongoingQuery = Object.assign(Object.assign({}, supportedOngoingQuery), { query: newQuery, activated: true, gotInitialResponse: false, dataSubject: new external_rxjs_namespaceObject.BehaviorSubject(null), clientRequestId: generateId(), isEmptyForJoin: false });
48297
49079
  this.registerQueryFinalizer(ongoingQuery);
48298
49080
  this.ongoingQueries.set(ongoingQuery.clientRequestId, ongoingQuery);
48299
- assert_truthy(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
49081
+ (0,assertic_dist.truthy)(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
48300
49082
  this.sendQueryToServerOrUseParentQuery(ongoingQuery);
48301
49083
  return true;
48302
49084
  }
@@ -48313,7 +49095,7 @@ class QuerySubscriptionManager {
48313
49095
  async completeAllSupportedQueries(rootOngoingQuery) {
48314
49096
  const supportedQueries = [...(rootOngoingQuery.supportedQueries || [])];
48315
49097
  while (supportedQueries.length) {
48316
- const supportedQuery = assert_truthy(supportedQueries.shift());
49098
+ const supportedQuery = (0,assertic_dist.truthy)(supportedQueries.shift());
48317
49099
  supportedQueries.push(...(supportedQuery.supportedQueries || []));
48318
49100
  await (0,external_rxjs_namespaceObject.firstValueFrom)(supportedQuery.unsubscribeBlockerCount.pipe(filter((count) => count === 0)));
48319
49101
  supportedQuery.dataSubject.complete();
@@ -48430,7 +49212,7 @@ class QuerySubscriptionManager {
48430
49212
  */
48431
49213
  sendQueryToServer(ongoingQuery) {
48432
49214
  const oldLimit = ongoingQuery.query.limit;
48433
- const newLimit = oldLimit > 0 ? oldLimit + FETCH_BEYOND_LIMIT : oldLimit;
49215
+ const newLimit = oldLimit > 0 && ongoingQuery.subscribe ? oldLimit + FETCH_BEYOND_LIMIT : oldLimit;
48434
49216
  const queryRequest = {
48435
49217
  query: Object.assign(Object.assign({}, ongoingQuery.query), { limit: newLimit }),
48436
49218
  clientRequestId: ongoingQuery.clientRequestId,
@@ -48615,10 +49397,65 @@ class ClientQueryMappingManager {
48615
49397
  }
48616
49398
  }
48617
49399
 
49400
+ ;// CONCATENATED MODULE: ./src/rate-limiter.ts
49401
+
49402
+ class RateLimiter {
49403
+ /**
49404
+ * Creates a new rate limiter. It limits the number of requests using two parameters:
49405
+ * - capacity: the maximum number of tokens (actions) that can be stored at any given time
49406
+ * - seconds: the number of seconds it takes to refill the bucket to its maximum capacity
49407
+ *
49408
+ * We then can calculate the refillRatePerMs: the number of tokens (actions) that are added to the bucket every
49409
+ * millisecond
49410
+ *
49411
+ * Example:
49412
+ * Say we want to allow maximum 60 requests in a period of 5 seconds. We can create a rate limiter with:
49413
+ * - capacity: 60
49414
+ * - seconds: 5
49415
+ * And we will get refillRatePerMs: 60 / (5 * 1000) = 0.012
49416
+ *
49417
+ * To use:
49418
+ * const rateLimiter = new RateLimiter(60, 5);
49419
+ * await rateLimiter.consume();
49420
+ *
49421
+ * @param capacity
49422
+ * @param refillRatePerMs
49423
+ */
49424
+ constructor(capacity, seconds) {
49425
+ this.capacity = capacity;
49426
+ this.seconds = seconds;
49427
+ this.tokens = capacity;
49428
+ this.refillRatePerMs = capacity / (seconds * 1000);
49429
+ this.lastRefillTimestamp = Date.now();
49430
+ }
49431
+ async consume() {
49432
+ if (this.attemptConsume())
49433
+ return;
49434
+ await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.interval)(10).pipe((0,external_rxjs_namespaceObject.filter)(() => this.attemptConsume()), (0,external_rxjs_namespaceObject.first)()));
49435
+ }
49436
+ attemptConsume() {
49437
+ this.refill();
49438
+ if (this.tokens >= 1) {
49439
+ this.tokens -= 1;
49440
+ return true;
49441
+ }
49442
+ return false;
49443
+ }
49444
+ refill() {
49445
+ const now = Date.now();
49446
+ const elapsedTime = now - this.lastRefillTimestamp;
49447
+ const tokensToAdd = elapsedTime * this.refillRatePerMs;
49448
+ this.tokens = Math.min(this.tokens + tokensToAdd, this.capacity);
49449
+ this.lastRefillTimestamp = now;
49450
+ }
49451
+ }
49452
+
48618
49453
  ;// CONCATENATED MODULE: ./src/rpc.manager.ts
48619
49454
 
48620
49455
 
48621
49456
 
49457
+
49458
+
48622
49459
  class RpcManager {
48623
49460
  constructor(region, appId, destructManager, headers = {}, authManager, clientIdService) {
48624
49461
  this.region = region;
@@ -48657,6 +49494,12 @@ class RpcManager {
48657
49494
  destructManager.onDestruct(async () => {
48658
49495
  await this.awaitAllSettled();
48659
49496
  });
49497
+ const rateLimiterMultiplier = apiKey ? 5 : 1;
49498
+ this.rateLimiters = {
49499
+ default: new RateLimiter(60 * rateLimiterMultiplier, 5),
49500
+ ai: new RateLimiter(20 * rateLimiterMultiplier, 5),
49501
+ secret: new RateLimiter(20 * rateLimiterMultiplier, 5),
49502
+ };
48660
49503
  }
48661
49504
  async awaitAllSettled() {
48662
49505
  await (0,external_rxjs_namespaceObject.firstValueFrom)(this.onGoingRpcCounter.pipe((0,external_rxjs_namespaceObject.filter)((value) => value === 0)));
@@ -48676,6 +49519,7 @@ class RpcManager {
48676
49519
  async post(path, message, files = []) {
48677
49520
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48678
49521
  try {
49522
+ await this.getRateLimiterBucket(path).consume();
48679
49523
  await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
48680
49524
  let headers = {};
48681
49525
  if (Object.keys(this.staticHeaders)) {
@@ -48735,6 +49579,15 @@ class RpcManager {
48735
49579
  }
48736
49580
  return (json || text);
48737
49581
  }
49582
+ getRateLimiterBucket(path) {
49583
+ if (path.startsWith('ai/assistant')) {
49584
+ return (0,assertic_dist.truthy)(this.rateLimiters['ai'], 'MISSING_RATE_LIMITER_AI');
49585
+ }
49586
+ if (path.startsWith('secret/')) {
49587
+ return (0,assertic_dist.truthy)(this.rateLimiters['secret'], 'MISSING_RATE_LIMITER_SECRETS');
49588
+ }
49589
+ return (0,assertic_dist.truthy)(this.rateLimiters['default'], 'MISSING_RATE_LIMITER_DEFAULT');
49590
+ }
48738
49591
  }
48739
49592
  class RpcError extends Error {
48740
49593
  constructor(statusCode, statusText, headers, url, message) {
@@ -48759,8 +49612,7 @@ class SecretClient {
48759
49612
  return this.rpcManager.post('/secret/getAll', {});
48760
49613
  }
48761
49614
  upsert(key, value) {
48762
- const request = { entries: [{ key, value }] };
48763
- return this.rpcManager.post('/secret/upsert', request);
49615
+ return this.upsertMany([{ key, value }]).then((entries) => entries[0]);
48764
49616
  }
48765
49617
  upsertMany(entries) {
48766
49618
  const request = { entries };
@@ -48811,6 +49663,7 @@ const NOOP_FN = (fn) => {
48811
49663
 
48812
49664
 
48813
49665
 
49666
+
48814
49667
  class SocketManager {
48815
49668
  constructor(clientIdService, region, appId, messageNotificationWrapper = NOOP_FN, destructManager, authManager) {
48816
49669
  this.clientIdService = clientIdService;
@@ -48865,7 +49718,7 @@ class SocketManager {
48865
49718
  this.authManager.waitForReadyState().then(() => {
48866
49719
  (0,external_rxjs_namespaceObject.firstValueFrom)(this.connectionReady.pipe((0,external_rxjs_namespaceObject.filter)(Boolean))).then(() => {
48867
49720
  const authToken = this.authManager.getAuthToken();
48868
- assert_truthy(this.socket).send(serialization_serializeObj({ message, authToken }));
49721
+ (0,assertic_dist.truthy)(this.socket).send(serialization_serializeObj({ message, authToken }));
48869
49722
  });
48870
49723
  });
48871
49724
  }
@@ -48979,6 +49832,11 @@ class QuerySender {
48979
49832
  clearTimeout(this.pendingQueryBatchTimeout);
48980
49833
  this.pendingQueryBatchTimeout = undefined;
48981
49834
  }
49835
+ // A batch should not have more than 10 queries
49836
+ if (this.pendingQueryRequests.length >= 10) {
49837
+ void this.processQueryBatch();
49838
+ return responsePromise;
49839
+ }
48982
49840
  this.pendingQueryBatchTimeout = setTimeout(() => {
48983
49841
  this.safeToSendQueriesToServer.pipe(filter(Boolean), (0,external_rxjs_namespaceObject.take)(1)).subscribe(() => {
48984
49842
  this.processQueryBatch();
@@ -49048,6 +49906,7 @@ class QuerySender {
49048
49906
 
49049
49907
 
49050
49908
 
49909
+
49051
49910
 
49052
49911
 
49053
49912
  /**
@@ -49225,7 +50084,7 @@ class Squid {
49225
50084
  this.querySubscriptionManager.unsubscribe();
49226
50085
  await this.rpcManager.awaitAllSettled();
49227
50086
  };
49228
- assert_assertTruthy(options.appId, 'APP_ID_MUST_BE_PROVIDED');
50087
+ (0,assertic_dist.assertTruthy)(options.appId, 'APP_ID_MUST_BE_PROVIDED');
49229
50088
  const shouldAddDeveloperId = options.environmentId !== 'prod' && options.squidDeveloperId;
49230
50089
  const appId = appIdWithEnvironmentIdAndDevId(options.appId, options.environmentId, shouldAddDeveloperId ? options.squidDeveloperId : undefined);
49231
50090
  const httpHeaders = getApplicationHttpHeaders(options.region, appId);
@@ -49284,7 +50143,7 @@ class Squid {
49284
50143
  })();
49285
50144
  }
49286
50145
  validateNotDestructed() {
49287
- assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
50146
+ (0,assertic_dist.assertTruthy)(!this.destructManager.isDestructing, 'The client was already destructed.');
49288
50147
  }
49289
50148
  }
49290
50149
  Squid.squidInstancesMap = {};
@@ -49297,6 +50156,7 @@ Squid.squidInstancesMap = {};
49297
50156
 
49298
50157
 
49299
50158
 
50159
+
49300
50160
 
49301
50161
  })();
49302
50162