@squidcloud/client 1.0.127 → 1.0.128

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,411 +1,6 @@
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
-
409
4
  /***/ 8278:
410
5
  /***/ ((__unused_webpack_module, exports) => {
411
6
 
@@ -27441,6 +27036,9 @@ var IntegrationType;
27441
27036
  IntegrationType["azure_sql"] = "azure_sql";
27442
27037
  IntegrationType["azure_postgresql"] = "azure_postgresql";
27443
27038
  IntegrationType["azure_cosmosdb"] = "azure_cosmosdb";
27039
+ IntegrationType["firestore"] = "firestore";
27040
+ IntegrationType["bigquery"] = "bigquery";
27041
+ IntegrationType["cloudsql"] = "cloudsql";
27444
27042
  })(IntegrationType || (IntegrationType = {}));
27445
27043
  var IntegrationSchemaType;
27446
27044
  (function (IntegrationSchemaType) {
@@ -28524,11 +28122,10 @@ var CronExpression;
28524
28122
  /** @internal */
28525
28123
  const ExecuteBackendFunctionRequestSchema = {
28526
28124
  type: 'object',
28527
- required: ['functionName', 'paramsArrayStr', 'clientRequestId'],
28125
+ required: ['functionName', 'paramsArrayStr'],
28528
28126
  properties: {
28529
28127
  functionName: { type: 'string', nullable: false },
28530
28128
  paramsArrayStr: { type: 'string', nullable: false },
28531
- clientRequestId: { type: 'string', nullable: false },
28532
28129
  },
28533
28130
  };
28534
28131
 
@@ -28754,16 +28351,34 @@ function compareOperator(conditionValue, valueInDocument, operator) {
28754
28351
  return !lodash_default().isEqual(conditionValue, valueInDocument);
28755
28352
  }
28756
28353
  // Nulls can only be compared for (in)equality, not other operators.
28757
- if (conditionValue === null || valueInDocument === null)
28758
- return false;
28759
28354
  switch (operator) {
28760
28355
  case '<':
28356
+ if (lodash_default().isNil(conditionValue))
28357
+ return false;
28358
+ if (lodash_default().isNil(valueInDocument))
28359
+ return true;
28761
28360
  return valueInDocument < conditionValue;
28762
28361
  case '<=':
28362
+ if (lodash_default().isNil(valueInDocument)) {
28363
+ return true;
28364
+ }
28365
+ if (lodash_default().isNil(conditionValue)) {
28366
+ return false;
28367
+ }
28763
28368
  return valueInDocument <= conditionValue;
28764
28369
  case '>':
28370
+ if (lodash_default().isNil(valueInDocument))
28371
+ return false;
28372
+ if (lodash_default().isNil(conditionValue))
28373
+ return true;
28765
28374
  return valueInDocument > conditionValue;
28766
28375
  case '>=':
28376
+ if (lodash_default().isNil(conditionValue)) {
28377
+ return true;
28378
+ }
28379
+ if (lodash_default().isNil(valueInDocument)) {
28380
+ return false;
28381
+ }
28767
28382
  return valueInDocument >= conditionValue;
28768
28383
  case 'like':
28769
28384
  return (typeof valueInDocument === 'string' &&
@@ -28791,11 +28406,11 @@ function isStringMatch(str, pattern, caseSensitive) {
28791
28406
  str = str.toLowerCase();
28792
28407
  pattern = pattern.toLowerCase();
28793
28408
  }
28794
- str = str.replace(/\n/g, ' ');
28795
28409
  // Escape special regex characters in the pattern
28796
28410
  const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
28797
28411
  // Replace '%' wildcard with regex equivalent
28798
- const regexPattern = escapedPattern.replace(/%/g, '.*');
28412
+ // Note: this allows for newlines, unlike .*
28413
+ const regexPattern = escapedPattern.replace(/%/g, '[\\s\\S]*');
28799
28414
  // Create regex object and test if string matches
28800
28415
  const regex = new RegExp(`^${regexPattern}$`);
28801
28416
  return regex.test(str);
@@ -29185,8 +28800,8 @@ class BaseQueryBuilder {
29185
28800
 
29186
28801
  ;// CONCATENATED MODULE: external "rxjs"
29187
28802
  const external_rxjs_namespaceObject = require("rxjs");
29188
- // EXTERNAL MODULE: ../common/node_modules/assertic/dist/index.js
29189
- var dist = __webpack_require__(4113);
28803
+ // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
28804
+ var dist = __webpack_require__(8975);
29190
28805
  ;// CONCATENATED MODULE: ../common/src/utils/object.ts
29191
28806
 
29192
28807
 
@@ -29259,6 +28874,7 @@ function replaceKeyInRecord(record, a, b) {
29259
28874
  ;// CONCATENATED MODULE: ../common/src/query/pagination.ts
29260
28875
 
29261
28876
 
28877
+
29262
28878
  class Pagination {
29263
28879
  /** @internal */
29264
28880
  constructor(snapshotEmitter, options = {}) {
@@ -29303,6 +28919,12 @@ class Pagination {
29303
28919
  this.snapshotSubject.next(firstPageSnapshot);
29304
28920
  }
29305
28921
  static compareValues(a, b) {
28922
+ if (lodash_default().isNil(a)) {
28923
+ return lodash_default().isNil(b) ? 0 : -1;
28924
+ }
28925
+ if (lodash_default().isNil(b)) {
28926
+ return 1;
28927
+ }
29306
28928
  if (a > b) {
29307
28929
  return 1;
29308
28930
  }
@@ -29314,7 +28936,7 @@ class Pagination {
29314
28936
  }
29315
28937
  }
29316
28938
  compare(doc1, doc2) {
29317
- if (doc2 === null) {
28939
+ if (lodash_default().isNil(doc2)) {
29318
28940
  return 1;
29319
28941
  }
29320
28942
  for (const so of this.templateSnapshotEmitter.getSortOrders()) {
@@ -30826,13 +30448,13 @@ function getGlobal() {
30826
30448
  }
30827
30449
  /** @internal */
30828
30450
  function isDebugEnabled() {
30829
- const global = getGlobal();
30830
- return global && global['SQUID_DEBUG_ENABLED'];
30451
+ const globalObj = getGlobal();
30452
+ return globalObj && globalObj['SQUID_DEBUG_ENABLED'];
30831
30453
  }
30832
30454
  /** @internal */
30833
30455
  function enableDebugLogs() {
30834
- const global = getGlobal();
30835
- global['SQUID_DEBUG_ENABLED'] = true;
30456
+ const globalObj = getGlobal();
30457
+ globalObj['SQUID_DEBUG_ENABLED'] = true;
30836
30458
  }
30837
30459
  /** @internal */
30838
30460
  class DebugLogger {
@@ -32441,8 +32063,6 @@ class MergedQueryBuilder {
32441
32063
  }
32442
32064
  }
32443
32065
 
32444
- // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
32445
- var assertic_dist = __webpack_require__(8975);
32446
32066
  ;// CONCATENATED MODULE: ./src/document-reference.ts
32447
32067
 
32448
32068
 
@@ -32489,7 +32109,7 @@ class DocumentReference {
32489
32109
  integrationId,
32490
32110
  }, null, 2)}`;
32491
32111
  };
32492
- return (0,assertic_dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError());
32112
+ return (0,dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError());
32493
32113
  }
32494
32114
  /**
32495
32115
  * Returns whether data has been populated for this document reference. Data
@@ -32512,7 +32132,7 @@ class DocumentReference {
32512
32132
  if (this.isTracked() && this.hasData)
32513
32133
  return this.data;
32514
32134
  const results = await this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshot();
32515
- (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32135
+ (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32516
32136
  return results.length ? results[0] : undefined;
32517
32137
  }
32518
32138
  /**
@@ -32528,7 +32148,7 @@ class DocumentReference {
32528
32148
  .dereference()
32529
32149
  .snapshots()
32530
32150
  .pipe((0,external_rxjs_namespaceObject.map)((results) => {
32531
- (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32151
+ (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
32532
32152
  return results.length ? results[0] : undefined;
32533
32153
  }));
32534
32154
  }
@@ -32839,6 +32459,10 @@ class QueryBuilder extends BaseQueryBuilder {
32839
32459
  return this.query.limit;
32840
32460
  }
32841
32461
  limitBy(limit, ...fields) {
32462
+ const sorts = this.query.sortOrder.map((s) => {
32463
+ return s.fieldName;
32464
+ });
32465
+ (0,dist.assertTruthy)(lodash.isEqual(fields.sort(), sorts.slice(0, fields.length).sort()), 'All fields in limitBy must be appear in the first fields in the sortBy list.');
32842
32466
  this.query.limitBy = { limit, fields, reverseSort: false };
32843
32467
  return this;
32844
32468
  }
@@ -32846,7 +32470,7 @@ class QueryBuilder extends BaseQueryBuilder {
32846
32470
  sortBy(fieldName, asc = true) {
32847
32471
  const fieldSort = { asc, fieldName };
32848
32472
  validateFieldSort(fieldSort);
32849
- (0,assertic_dist.assertTruthy)(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
32473
+ (0,dist.assertTruthy)(!this.query.sortOrder.some((so) => so.fieldName === fieldName), `${fieldName} already in the sort list.`);
32850
32474
  this.query.sortOrder.push(fieldSort);
32851
32475
  return this;
32852
32476
  }
@@ -32918,9 +32542,9 @@ class QueryBuilder extends BaseQueryBuilder {
32918
32542
  .processQuery(query, this.collectionName, {}, {}, subscribe, this.forceFetchFromServer)
32919
32543
  .pipe(map_map((docs) => {
32920
32544
  return docs.map((docRecord) => {
32921
- (0,assertic_dist.assertTruthy)(Object.keys(docRecord).length === 1);
32545
+ (0,dist.assertTruthy)(Object.keys(docRecord).length === 1);
32922
32546
  const doc = docRecord[this.collectionName];
32923
- const squidDocId = getSquidDocId((0,assertic_dist.truthy)(doc).__docId__, this.collectionName, this.integrationId);
32547
+ const squidDocId = getSquidDocId((0,dist.truthy)(doc).__docId__, this.collectionName, this.integrationId);
32924
32548
  return this.documentReferenceFactory.create(squidDocId, this.queryBuilderFactory);
32925
32549
  });
32926
32550
  }));
@@ -33491,55 +33115,30 @@ class AiClientFactory {
33491
33115
 
33492
33116
 
33493
33117
 
33494
-
33495
33118
  class ApiManager {
33496
- constructor(clientIdService, rpcManager, socketManager, apiServerUrlOverrideMapping = {}) {
33119
+ constructor(clientIdService, rpcManager, apiServerUrlOverrideMapping = {}) {
33497
33120
  this.clientIdService = clientIdService;
33498
33121
  this.rpcManager = rpcManager;
33499
- this.socketManager = socketManager;
33500
33122
  this.apiServerUrlOverrideMapping = apiServerUrlOverrideMapping;
33501
- this.ongoingApiExecutions = {};
33502
- socketManager
33503
- .observeNotifications()
33504
- .pipe((0,external_rxjs_namespaceObject.filter)((notification) => notification.type === 'api'), map_map((n) => n))
33505
- .subscribe((notification) => {
33506
- this.handleApiResponse(notification.clientRequestId, notification).then();
33507
- });
33508
33123
  }
33509
33124
  callApiAndSubscribe(integrationId, endpointId, request) {
33510
- const clientRequestId = generateId();
33511
- const subject = new external_rxjs_namespaceObject.Subject();
33512
- this.ongoingApiExecutions[clientRequestId] = subject;
33513
33125
  const callApiRequest = {
33514
33126
  integrationId,
33515
33127
  endpointId,
33516
33128
  request,
33517
- clientRequestId,
33518
33129
  serverUrlOverride: this.apiServerUrlOverrideMapping[integrationId],
33519
33130
  };
33520
- this.rpcManager.post('api/call', callApiRequest).catch((e) => {
33521
- console.error('Got error while calling API', integrationId, endpointId, request, e);
33522
- subject.error(e);
33523
- subject.complete();
33524
- });
33525
- return (0,external_rxjs_namespaceObject.race)(subject.pipe((0,external_rxjs_namespaceObject.finalize)(() => {
33526
- delete this.ongoingApiExecutions[clientRequestId];
33527
- }), (0,external_rxjs_namespaceObject.share)()), this.clientIdService.observeClientTooOld().pipe(map_map(() => {
33131
+ return (0,external_rxjs_namespaceObject.race)((0,external_rxjs_namespaceObject.from)(this.rpcManager.post('api/call', callApiRequest)).pipe(map_map((response) => {
33132
+ if (response.success) {
33133
+ return deserializeObj(response.payload);
33134
+ }
33135
+ else {
33136
+ throw new Error(`Got error while calling API (HTTP Status ${response.httpStatus})`);
33137
+ }
33138
+ })), this.clientIdService.observeClientTooOld().pipe(map_map(() => {
33528
33139
  throw new Error('CLIENT_NOT_CONNECTED');
33529
33140
  })));
33530
33141
  }
33531
- async handleApiResponse(clientRequestId, notification) {
33532
- const subject = this.ongoingApiExecutions[clientRequestId];
33533
- if (!subject)
33534
- return;
33535
- if (notification.success) {
33536
- subject.next(deserializeObj(notification.payload));
33537
- }
33538
- else {
33539
- subject.error((0,lodash.pick)(notification, 'httpStatus', 'payload'));
33540
- }
33541
- subject.complete();
33542
- }
33543
33142
  }
33544
33143
 
33545
33144
  ;// CONCATENATED MODULE: ./src/auth.manager.ts
@@ -33591,52 +33190,24 @@ class AuthManager {
33591
33190
 
33592
33191
 
33593
33192
  class BackendFunctionManager {
33594
- constructor(clientIdService, rpcManager, socketManager) {
33193
+ constructor(clientIdService, rpcManager) {
33595
33194
  this.clientIdService = clientIdService;
33596
33195
  this.rpcManager = rpcManager;
33597
- this.socketManager = socketManager;
33598
- this.ongoingFunctionExecutions = {};
33599
- socketManager
33600
- .observeNotifications()
33601
- .pipe((0,external_rxjs_namespaceObject.filter)((notification) => notification.type === 'backendFunction'), map_map((n) => n))
33602
- .subscribe((notification) => {
33603
- this.handleFunctionResponse(notification.clientRequestId, notification.payload);
33604
- });
33605
33196
  }
33606
33197
  executeFunctionAndSubscribe(functionName, ...params) {
33607
- const clientRequestId = generateId();
33608
- const subject = new external_rxjs_namespaceObject.Subject();
33609
- this.ongoingFunctionExecutions[clientRequestId] = subject;
33610
33198
  const request = {
33611
33199
  functionName,
33612
33200
  paramsArrayStr: serialization_serializeObj(params),
33613
- clientRequestId,
33614
33201
  };
33615
- this.rpcManager.post('backend-function/execute', request).catch((e) => {
33616
- console.error('Got error while executing function', functionName, e);
33617
- subject.error(e);
33618
- subject.complete();
33619
- });
33620
- return (0,external_rxjs_namespaceObject.race)(subject.pipe((0,external_rxjs_namespaceObject.finalize)(() => {
33621
- delete this.ongoingFunctionExecutions[clientRequestId];
33622
- }), (0,external_rxjs_namespaceObject.share)()), this.clientIdService.observeClientTooOld().pipe(map_map(() => {
33202
+ return (0,external_rxjs_namespaceObject.race)((0,external_rxjs_namespaceObject.from)(this.rpcManager.post('backend-function/execute', request)).pipe(map_map((response) => {
33203
+ if (!response.success) {
33204
+ throw new Error(response.payload);
33205
+ }
33206
+ return deserializeObj(response.payload);
33207
+ })), this.clientIdService.observeClientTooOld().pipe(map_map(() => {
33623
33208
  throw new Error('CLIENT_NOT_CONNECTED');
33624
33209
  })));
33625
33210
  }
33626
- handleFunctionResponse(clientRequestId, serializedResponse) {
33627
- const subject = this.ongoingFunctionExecutions[clientRequestId];
33628
- if (!subject) {
33629
- return;
33630
- }
33631
- const payload = deserializeObj(serializedResponse);
33632
- if (payload.success) {
33633
- subject.next(payload.response);
33634
- }
33635
- else {
33636
- subject.error(new Error(payload.response));
33637
- subject.complete();
33638
- }
33639
- }
33640
33211
  }
33641
33212
 
33642
33213
  ;// CONCATENATED MODULE: ./src/client-id.service.ts
@@ -33882,7 +33453,7 @@ class DataManager {
33882
33453
  */
33883
33454
  async runInTransaction(fn, transactionId) {
33884
33455
  if (transactionId) {
33885
- (0,assertic_dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33456
+ (0,dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33886
33457
  return fn(transactionId).then(() => Promise.resolve());
33887
33458
  }
33888
33459
  if (this.lockManager.canGetLock(RUN_IN_TRANSACTION_MUTEX)) {
@@ -33963,7 +33534,7 @@ class DataManager {
33963
33534
  /** Same as runInTransaction with the exception that the passed function runs synchronously. */
33964
33535
  async runInTransactionSync(fn, transactionId) {
33965
33536
  if (transactionId) {
33966
- (0,assertic_dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33537
+ (0,dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33967
33538
  fn(transactionId);
33968
33539
  return;
33969
33540
  }
@@ -34275,7 +33846,7 @@ class DataManager {
34275
33846
  }
34276
33847
  removeOutgoingMutation(outgoingMutation) {
34277
33848
  const squidDocId = getSquidDocId(outgoingMutation.mutation.squidDocIdObj);
34278
- const outgoingMutationsForDoc = (0,assertic_dist.truthy)(this.pendingOutgoingMutations.get(squidDocId));
33849
+ const outgoingMutationsForDoc = (0,dist.truthy)(this.pendingOutgoingMutations.get(squidDocId));
34279
33850
  outgoingMutationsForDoc.splice(outgoingMutationsForDoc.indexOf(outgoingMutation), 1);
34280
33851
  if (!outgoingMutationsForDoc.length) {
34281
33852
  this.pendingOutgoingMutations.delete(squidDocId);
@@ -34290,7 +33861,7 @@ class DataManager {
34290
33861
  this.setExpiration(squidDocId, true);
34291
33862
  try {
34292
33863
  const results = await this.queryBuilderFactory.getForDocument(squidDocId).setForceFetchFromServer().snapshot();
34293
- (0,assertic_dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
33864
+ (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
34294
33865
  /** The document does not exist anymore, so we can forget about it */
34295
33866
  if (!results.length) {
34296
33867
  this.forgetDocument(squidDocId);
@@ -34592,7 +34163,7 @@ class DocumentReferenceFactory {
34592
34163
  let reference = this.documents.get(squidDocId);
34593
34164
  if (reference)
34594
34165
  return reference;
34595
- reference = new DocumentReference(squidDocId, (0,assertic_dist.truthy)(this.dataManager, 'dataManager not found'), queryBuilderFactory);
34166
+ reference = new DocumentReference(squidDocId, (0,dist.truthy)(this.dataManager, 'dataManager not found'), queryBuilderFactory);
34596
34167
  const { integrationId, collectionName } = parseSquidDocId(squidDocId);
34597
34168
  this.documents.set(squidDocId, reference);
34598
34169
  const collectionKey = this.getCollectionKey(integrationId, collectionName);
@@ -34632,13 +34203,6 @@ class DocumentReferenceFactory {
34632
34203
 
34633
34204
 
34634
34205
 
34635
- function groupAndSort(sortedDocs, sortFieldNames, sortOrders) {
34636
- const groups = Object.values(lodash_default().groupBy(sortedDocs, (doc) => {
34637
- return serialization_normalizeJsonAsString(sortFieldNames.map((fieldName) => getInPath(doc, fieldName)));
34638
- }));
34639
- const sortFieldIterators = sortFieldNames.map((fieldName) => (group) => getInPath(group[0], fieldName));
34640
- return (0,lodash.orderBy)(groups, sortFieldIterators, sortOrders);
34641
- }
34642
34206
  class DocumentStore {
34643
34207
  constructor() {
34644
34208
  this.squidDocIdToDoc = new Map();
@@ -34669,26 +34233,52 @@ class DocumentStore {
34669
34233
  return doc !== undefined;
34670
34234
  }
34671
34235
  getDocument(squidDocId) {
34672
- return (0,assertic_dist.truthy)(this.getDocumentOrUndefined(squidDocId));
34236
+ return (0,dist.truthy)(this.getDocumentOrUndefined(squidDocId));
34673
34237
  }
34674
34238
  getDocumentOrUndefined(squidDocId) {
34675
34239
  return this.squidDocIdToDoc.get(squidDocId);
34676
34240
  }
34241
+ compareValues(a, b) {
34242
+ if (lodash_default().isNil(a)) {
34243
+ return lodash_default().isNil(b) ? 0 : -1;
34244
+ }
34245
+ if (lodash_default().isNil(b))
34246
+ return 1;
34247
+ if (a === b)
34248
+ return 0;
34249
+ return a > b ? 1 : -1;
34250
+ }
34251
+ compareSquidDocs(a, b, sortFieldNames, sortOrders) {
34252
+ for (const [i, fieldName] of sortFieldNames.entries()) {
34253
+ const compare = this.compareValues(lodash_default().get(a, fieldName), lodash_default().get(b, fieldName));
34254
+ if (compare !== 0) {
34255
+ return sortOrders[i] === 'asc' ? compare : -1 * compare;
34256
+ }
34257
+ }
34258
+ return 0;
34259
+ }
34260
+ group(sortedDocs, sortFieldNames) {
34261
+ return Object.values(lodash_default().groupBy(sortedDocs, (doc) => {
34262
+ return serialization_normalizeJsonAsString(sortFieldNames.map((fieldName) => getInPath(doc, fieldName)));
34263
+ }));
34264
+ }
34677
34265
  sortAndLimitDocs(docIdSet, query) {
34678
34266
  if (docIdSet.size === 0) {
34679
34267
  return [];
34680
34268
  }
34681
- const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(assertic_dist.isNonNullable);
34269
+ const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(dist.isNonNullable);
34682
34270
  const { sortOrder, limitBy } = query;
34683
34271
  const sortFieldNames = sortOrder.map((s) => s.fieldName);
34684
34272
  const sortOrders = sortOrder.map((s) => (s.asc ? 'asc' : 'desc'));
34685
- const sortedDocs = (0,lodash.orderBy)(docs, sortFieldNames, sortOrders);
34273
+ const sortedDocs = docs.sort((a, b) => {
34274
+ return this.compareSquidDocs(a, b, sortFieldNames, sortOrders);
34275
+ });
34686
34276
  const mainLimit = query.limit < 0 ? 2000 : query.limit;
34687
34277
  if (!limitBy) {
34688
34278
  return sortedDocs.slice(0, mainLimit);
34689
34279
  }
34690
34280
  const { limit: internalLimit, fields, reverseSort } = limitBy;
34691
- const sortedGroups = groupAndSort(sortedDocs, fields, sortOrders);
34281
+ const sortedGroups = this.group(sortedDocs, fields);
34692
34282
  let limitedGroups;
34693
34283
  if (reverseSort) {
34694
34284
  limitedGroups = sortedGroups.map((group) => group.slice(-internalLimit));
@@ -48628,7 +48218,7 @@ class QuerySubscriptionManager {
48628
48218
  * Returns the query associated with the given clientRequestId. Throws error if the clientRequestId is not known.
48629
48219
  */
48630
48220
  getQuery(clientRequestId) {
48631
- return (0,assertic_dist.truthy)(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
48221
+ return (0,dist.truthy)(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
48632
48222
  }
48633
48223
  /**
48634
48224
  * A query receives updates from two different sources:
@@ -48733,7 +48323,7 @@ class QuerySubscriptionManager {
48733
48323
  .some(Boolean);
48734
48324
  let rootOngoingQuery = ongoingQuery;
48735
48325
  while (!rootOngoingQuery.allObservables) {
48736
- rootOngoingQuery = (0,assertic_dist.truthy)(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
48326
+ rootOngoingQuery = (0,dist.truthy)(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
48737
48327
  }
48738
48328
  if (observablesUpdated) {
48739
48329
  rootOngoingQueries.add(rootOngoingQuery);
@@ -48760,7 +48350,7 @@ class QuerySubscriptionManager {
48760
48350
  }
48761
48351
  for (const rootOngoingQuery of rootOngoingQueries) {
48762
48352
  const allObservables = this.collectAllObservables(rootOngoingQuery);
48763
- (0,assertic_dist.truthy)(rootOngoingQuery.allObservables).next(allObservables);
48353
+ (0,dist.truthy)(rootOngoingQuery.allObservables).next(allObservables);
48764
48354
  }
48765
48355
  }
48766
48356
  isValidParent(candidateParentQuery) {
@@ -48864,7 +48454,7 @@ class QuerySubscriptionManager {
48864
48454
  this.clientRequestIdToLocalDocuments.delete(clientRequestId);
48865
48455
  const orphanDocument = [];
48866
48456
  for (const doc of docs) {
48867
- const clientRequestIds = (0,assertic_dist.truthy)(this.localDocumentToClientRequestIds.get(doc));
48457
+ const clientRequestIds = (0,dist.truthy)(this.localDocumentToClientRequestIds.get(doc));
48868
48458
  clientRequestIds.delete(clientRequestId);
48869
48459
  if (!clientRequestIds.size) {
48870
48460
  this.localDocumentToClientRequestIds.delete(doc);
@@ -49000,7 +48590,7 @@ class QuerySubscriptionManager {
49000
48590
  const val = doc[joinCondition.right];
49001
48591
  if (!rightAsMap.has(val))
49002
48592
  rightAsMap.set(val, []);
49003
- (0,assertic_dist.truthy)(rightAsMap.get(val)).push(doc);
48593
+ (0,dist.truthy)(rightAsMap.get(val)).push(doc);
49004
48594
  });
49005
48595
  return left.flatMap((leftElement) => {
49006
48596
  var _a;
@@ -49020,7 +48610,7 @@ class QuerySubscriptionManager {
49020
48610
  const result = [];
49021
48611
  const queue = [rootOngoingQuery];
49022
48612
  while (queue.length) {
49023
- const current = (0,assertic_dist.truthy)(queue.shift());
48613
+ const current = (0,dist.truthy)(queue.shift());
49024
48614
  if (current.isEmptyForJoin)
49025
48615
  continue;
49026
48616
  result.push(current);
@@ -49030,7 +48620,7 @@ class QuerySubscriptionManager {
49030
48620
  }
49031
48621
  updateOngoingQueryWithNewDataFromSupportingQuery(supportingQueryResult, supportedOngoingQuery) {
49032
48622
  var _a;
49033
- const joinCondition = (0,assertic_dist.truthy)(supportedOngoingQuery.joinCondition);
48623
+ const joinCondition = (0,dist.truthy)(supportedOngoingQuery.joinCondition);
49034
48624
  const query = supportedOngoingQuery.query;
49035
48625
  if (!supportedOngoingQuery.activated) {
49036
48626
  const newConditions = supportingQueryResult.map((supportingDoc) => {
@@ -49053,7 +48643,7 @@ class QuerySubscriptionManager {
49053
48643
  return true;
49054
48644
  }
49055
48645
  else {
49056
- const supportedQueriesWithSameAlias = (0,assertic_dist.truthy)((_a = supportedOngoingQuery.supportingOngoingQuery) === null || _a === void 0 ? void 0 : _a.supportedQueries).filter((q) => q.alias === supportedOngoingQuery.alias);
48646
+ const supportedQueriesWithSameAlias = (0,dist.truthy)((_a = supportedOngoingQuery.supportingOngoingQuery) === null || _a === void 0 ? void 0 : _a.supportedQueries).filter((q) => q.alias === supportedOngoingQuery.alias);
49057
48647
  const allNeededValues = new Set(supportingQueryResult.map((resultDoc) => { var _a; return (_a = resultDoc[joinCondition.left]) !== null && _a !== void 0 ? _a : null; }));
49058
48648
  for (const supportedQuery of supportedQueriesWithSameAlias) {
49059
48649
  supportedQuery.query.conditions
@@ -49078,7 +48668,7 @@ class QuerySubscriptionManager {
49078
48668
  const ongoingQuery = Object.assign(Object.assign({}, supportedOngoingQuery), { query: newQuery, activated: true, gotInitialResponse: false, dataSubject: new external_rxjs_namespaceObject.BehaviorSubject(null), clientRequestId: generateId(), isEmptyForJoin: false });
49079
48669
  this.registerQueryFinalizer(ongoingQuery);
49080
48670
  this.ongoingQueries.set(ongoingQuery.clientRequestId, ongoingQuery);
49081
- (0,assertic_dist.truthy)(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
48671
+ (0,dist.truthy)(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
49082
48672
  this.sendQueryToServerOrUseParentQuery(ongoingQuery);
49083
48673
  return true;
49084
48674
  }
@@ -49095,7 +48685,7 @@ class QuerySubscriptionManager {
49095
48685
  async completeAllSupportedQueries(rootOngoingQuery) {
49096
48686
  const supportedQueries = [...(rootOngoingQuery.supportedQueries || [])];
49097
48687
  while (supportedQueries.length) {
49098
- const supportedQuery = (0,assertic_dist.truthy)(supportedQueries.shift());
48688
+ const supportedQuery = (0,dist.truthy)(supportedQueries.shift());
49099
48689
  supportedQueries.push(...(supportedQuery.supportedQueries || []));
49100
48690
  await (0,external_rxjs_namespaceObject.firstValueFrom)(supportedQuery.unsubscribeBlockerCount.pipe(filter((count) => count === 0)));
49101
48691
  supportedQuery.dataSubject.complete();
@@ -49581,12 +49171,12 @@ class RpcManager {
49581
49171
  }
49582
49172
  getRateLimiterBucket(path) {
49583
49173
  if (path.startsWith('ai/assistant')) {
49584
- return (0,assertic_dist.truthy)(this.rateLimiters['ai'], 'MISSING_RATE_LIMITER_AI');
49174
+ return (0,dist.truthy)(this.rateLimiters['ai'], 'MISSING_RATE_LIMITER_AI');
49585
49175
  }
49586
49176
  if (path.startsWith('secret/')) {
49587
- return (0,assertic_dist.truthy)(this.rateLimiters['secret'], 'MISSING_RATE_LIMITER_SECRETS');
49177
+ return (0,dist.truthy)(this.rateLimiters['secret'], 'MISSING_RATE_LIMITER_SECRETS');
49588
49178
  }
49589
- return (0,assertic_dist.truthy)(this.rateLimiters['default'], 'MISSING_RATE_LIMITER_DEFAULT');
49179
+ return (0,dist.truthy)(this.rateLimiters['default'], 'MISSING_RATE_LIMITER_DEFAULT');
49590
49180
  }
49591
49181
  }
49592
49182
  class RpcError extends Error {
@@ -49604,9 +49194,9 @@ class SecretClient {
49604
49194
  constructor(rpcManager) {
49605
49195
  this.rpcManager = rpcManager;
49606
49196
  }
49607
- get(key) {
49197
+ async get(key) {
49608
49198
  const request = { key };
49609
- return this.rpcManager.post('/secret/get', request);
49199
+ return (await this.rpcManager.post('/secret/get', request)) || undefined;
49610
49200
  }
49611
49201
  getAll() {
49612
49202
  return this.rpcManager.post('/secret/getAll', {});
@@ -49718,7 +49308,7 @@ class SocketManager {
49718
49308
  this.authManager.waitForReadyState().then(() => {
49719
49309
  (0,external_rxjs_namespaceObject.firstValueFrom)(this.connectionReady.pipe((0,external_rxjs_namespaceObject.filter)(Boolean))).then(() => {
49720
49310
  const authToken = this.authManager.getAuthToken();
49721
- (0,assertic_dist.truthy)(this.socket).send(serialization_serializeObj({ message, authToken }));
49311
+ (0,dist.truthy)(this.socket).send(serialization_serializeObj({ message, authToken }));
49722
49312
  });
49723
49313
  });
49724
49314
  }
@@ -50084,7 +49674,7 @@ class Squid {
50084
49674
  this.querySubscriptionManager.unsubscribe();
50085
49675
  await this.rpcManager.awaitAllSettled();
50086
49676
  };
50087
- (0,assertic_dist.assertTruthy)(options.appId, 'APP_ID_MUST_BE_PROVIDED');
49677
+ (0,dist.assertTruthy)(options.appId, 'APP_ID_MUST_BE_PROVIDED');
50088
49678
  const shouldAddDeveloperId = options.environmentId !== 'prod' && options.squidDeveloperId;
50089
49679
  const appId = appIdWithEnvironmentIdAndDevId(options.appId, options.environmentId, shouldAddDeveloperId ? options.squidDeveloperId : undefined);
50090
49680
  const httpHeaders = getApplicationHttpHeaders(options.region, appId);
@@ -50105,9 +49695,9 @@ class Squid {
50105
49695
  this.collectionReferenceFactory = new CollectionReferenceFactory(this.documentReferenceFactory, this.queryBuilderFactory, this.querySubscriptionManager);
50106
49696
  this.dataManager = new DataManager(this.documentStore, mutationSender, this.socketManager, this.querySubscriptionManager, this.queryBuilderFactory, this.lockManager, this.destructManager, this.documentIdentityService, this.querySender);
50107
49697
  this.documentReferenceFactory.setDataManager(this.dataManager);
50108
- this.backendFunctionManager = new BackendFunctionManager(this.clientIdService, this.rpcManager, this.socketManager);
49698
+ this.backendFunctionManager = new BackendFunctionManager(this.clientIdService, this.rpcManager);
50109
49699
  this.namedQueryManager = new NamedQueryManager(this.rpcManager, this.socketManager);
50110
- this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
49700
+ this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, options.apiServerUrlOverrideMapping);
50111
49701
  this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
50112
49702
  this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
50113
49703
  this.secretClient = new SecretClient(this.rpcManager);
@@ -50143,7 +49733,7 @@ class Squid {
50143
49733
  })();
50144
49734
  }
50145
49735
  validateNotDestructed() {
50146
- (0,assertic_dist.assertTruthy)(!this.destructManager.isDestructing, 'The client was already destructed.');
49736
+ (0,dist.assertTruthy)(!this.destructManager.isDestructing, 'The client was already destructed.');
50147
49737
  }
50148
49738
  }
50149
49739
  Squid.squidInstancesMap = {};
@@ -56,7 +56,10 @@ export declare enum IntegrationType {
56
56
  'xata' = "xata",
57
57
  'azure_sql' = "azure_sql",
58
58
  'azure_postgresql' = "azure_postgresql",
59
- 'azure_cosmosdb' = "azure_cosmosdb"
59
+ 'azure_cosmosdb' = "azure_cosmosdb",
60
+ 'firestore' = "firestore",
61
+ 'bigquery' = "bigquery",
62
+ 'cloudsql' = "cloudsql"
60
63
  }
61
64
  export declare enum IntegrationSchemaType {
62
65
  'data' = "data",
@@ -1,15 +1,11 @@
1
1
  import { ApiEndpointId, IntegrationId } from '@squidcloud/common';
2
2
  import { Observable } from 'rxjs';
3
3
  import { RpcManager } from './rpc.manager';
4
- import { SocketManager } from './socket.manager';
5
4
  import { ClientIdService } from './client-id.service';
6
5
  export declare class ApiManager {
7
6
  private readonly clientIdService;
8
7
  private readonly rpcManager;
9
- private readonly socketManager;
10
8
  private readonly apiServerUrlOverrideMapping;
11
- private readonly ongoingApiExecutions;
12
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager, apiServerUrlOverrideMapping?: Record<IntegrationId, string>);
9
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager, apiServerUrlOverrideMapping?: Record<IntegrationId, string>);
13
10
  callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>): Observable<T>;
14
- private handleApiResponse;
15
11
  }
@@ -1,13 +1,9 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { RpcManager } from './rpc.manager';
3
- import { SocketManager } from './socket.manager';
4
3
  import { ClientIdService } from './client-id.service';
5
4
  export declare class BackendFunctionManager {
6
5
  private readonly clientIdService;
7
6
  private readonly rpcManager;
8
- private readonly socketManager;
9
- private readonly ongoingFunctionExecutions;
10
- constructor(clientIdService: ClientIdService, rpcManager: RpcManager, socketManager: SocketManager);
7
+ constructor(clientIdService: ClientIdService, rpcManager: RpcManager);
11
8
  executeFunctionAndSubscribe<T>(functionName: string, ...params: any[]): Observable<T>;
12
- private handleFunctionResponse;
13
9
  }
@@ -1,10 +1,13 @@
1
- import { Query, SquidDocId, SquidDocument } from '@squidcloud/common';
1
+ import { FieldType, Query, SquidDocId, SquidDocument } from '@squidcloud/common';
2
2
  export declare class DocumentStore {
3
3
  private readonly squidDocIdToDoc;
4
4
  saveDocument(squidDocId: SquidDocId, properties: SquidDocument | undefined): SquidDocument | undefined;
5
5
  hasData(squidDocId: SquidDocId): boolean;
6
6
  getDocument(squidDocId: SquidDocId): SquidDocument;
7
7
  getDocumentOrUndefined(squidDocId: SquidDocId): SquidDocument | undefined;
8
+ compareValues(a: FieldType | undefined, b: FieldType | undefined): number;
9
+ compareSquidDocs(a: SquidDocument, b: SquidDocument, sortFieldNames: string[], sortOrders: ('asc' | 'desc')[]): number;
10
+ group(sortedDocs: SquidDocument[], sortFieldNames: string[]): SquidDocument[][];
8
11
  sortAndLimitDocs(docIdSet: Set<SquidDocId>, query: Query): Array<SquidDocument>;
9
12
  private removeInternalProperties;
10
13
  migrateDocId(squidDocId: SquidDocId, newSquidDocId: SquidDocId): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.127",
3
+ "version": "1.0.128",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",