@squidcloud/client 1.0.126 → 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
@@ -6948,6 +6948,419 @@ function escapeJsonPtr(str) {
6948
6948
  }
6949
6949
 
6950
6950
 
6951
+ /***/ }),
6952
+
6953
+ /***/ 8975:
6954
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
6955
+
6956
+ "use strict";
6957
+
6958
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6959
+ if (k2 === undefined) k2 = k;
6960
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6961
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6962
+ desc = { enumerable: true, get: function() { return m[k]; } };
6963
+ }
6964
+ Object.defineProperty(o, k2, desc);
6965
+ }) : (function(o, m, k, k2) {
6966
+ if (k2 === undefined) k2 = k;
6967
+ o[k2] = m[k];
6968
+ }));
6969
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
6970
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6971
+ };
6972
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6973
+ __exportStar(__webpack_require__(3355), exports);
6974
+ //# sourceMappingURL=index.js.map
6975
+
6976
+ /***/ }),
6977
+
6978
+ /***/ 6676:
6979
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6980
+
6981
+ "use strict";
6982
+
6983
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
6984
+ exports.callValueAssertion = exports.assertArray = exports.assertObject = exports.getErrorMessage = exports.getAssertionErrorFromProvider = exports.fail = exports.truthy = exports.assertTruthy = void 0;
6985
+ const ChecksLib_1 = __webpack_require__(9862);
6986
+ /** Asserts that the *param* value is truthy using '!' operator or throws an Error. */
6987
+ function assertTruthy(value, error) {
6988
+ if (!value) {
6989
+ fail(error);
6990
+ }
6991
+ }
6992
+ exports.assertTruthy = assertTruthy;
6993
+ /**
6994
+ * Casts the 'value' to a non-nullable type or throws an error.
6995
+ * Uses 'assertTruthy' to make the check.
6996
+ */
6997
+ function truthy(value, error) {
6998
+ assertTruthy(value, error);
6999
+ return value;
7000
+ }
7001
+ exports.truthy = truthy;
7002
+ function fail(error) {
7003
+ const errorMessage = getAssertionErrorFromProvider(error);
7004
+ if (typeof errorMessage === 'object') {
7005
+ throw errorMessage;
7006
+ }
7007
+ throw new Error(errorMessage || 'Assertion error');
7008
+ }
7009
+ exports.fail = fail;
7010
+ /** Returns validation context as a string. Calls errorProvider() if needed. */
7011
+ function getAssertionErrorFromProvider(errorProvider) {
7012
+ if (errorProvider === undefined) {
7013
+ return '';
7014
+ }
7015
+ if (typeof errorProvider === 'string') {
7016
+ return errorProvider;
7017
+ }
7018
+ return errorProvider();
7019
+ }
7020
+ exports.getAssertionErrorFromProvider = getAssertionErrorFromProvider;
7021
+ /** Returns validation context as a string. Calls errorProvider() if needed. */
7022
+ function getErrorMessage(errorProvider) {
7023
+ const error = getAssertionErrorFromProvider(errorProvider);
7024
+ return typeof error === 'string' ? error : error.message || '<no error message>';
7025
+ }
7026
+ exports.getErrorMessage = getErrorMessage;
7027
+ /**
7028
+ * Asserts that the object satisfies the schema using individual field assertions.
7029
+ * Throws an error if not.
7030
+ * Works only with non-array objects: use 'assertArray' to check arrays.
7031
+ */
7032
+ function assertObject(value, objectAssertion, errorContextProvider = undefined, constraints = {}) {
7033
+ const ctx = () => { return getErrorMessage(errorContextProvider); };
7034
+ const errorWithContext = (message) => {
7035
+ const context = ctx();
7036
+ return context.length === 0 ? message : `${context} ${message}`;
7037
+ };
7038
+ assertTruthy(typeof value === 'object', () => errorWithContext(`is not an object: ${typeof value}`));
7039
+ assertTruthy(value !== undefined, () => errorWithContext(`is not defined`));
7040
+ assertTruthy(value !== null, () => errorWithContext(`is null`));
7041
+ assertTruthy(!Array.isArray(value), () => errorWithContext(`is an array.`));
7042
+ const assertionEntries = Object.entries(objectAssertion);
7043
+ if (constraints.failOnUnknownFields) {
7044
+ for (const objectFieldName in value) {
7045
+ assertTruthy(assertionEntries.some(([assertionFieldName]) => objectFieldName === assertionFieldName), errorWithContext(`property can't be checked: ${objectFieldName}`));
7046
+ }
7047
+ }
7048
+ let $o;
7049
+ for (const [fieldKey, fieldAssertion] of assertionEntries) {
7050
+ assertTruthy(typeof fieldAssertion === 'function' ||
7051
+ (typeof fieldAssertion === 'object' && fieldAssertion !== null), () => `${ctx()}.${fieldKey} assertion is not an object or a function: ${typeof fieldAssertion}`);
7052
+ const fieldValue = value[fieldKey];
7053
+ const fieldCtx = () => `${ctx()}.${fieldKey}`;
7054
+ if (typeof fieldAssertion === 'object') {
7055
+ assertTruthy(!Array.isArray(fieldValue), () => `${ctx()}.${fieldCtx()} use arrayAssertion() to create a ValueAssertion for an array`);
7056
+ assertObject(fieldValue, fieldAssertion, fieldCtx);
7057
+ }
7058
+ else {
7059
+ assertTruthy(typeof fieldAssertion === 'function', () => `${ctx()}.${fieldCtx()} assertion is not a function`);
7060
+ if (fieldKey === '$o') {
7061
+ $o = fieldAssertion; // Will be run last.
7062
+ }
7063
+ else {
7064
+ const checkResult = fieldAssertion(fieldValue, fieldCtx);
7065
+ assertTruthy(checkResult === undefined, `Assertion function must assert (void) but it returns a value: ${checkResult}. Wrap with $v()?`);
7066
+ }
7067
+ }
7068
+ }
7069
+ if ($o) {
7070
+ $o(value, errorContextProvider);
7071
+ }
7072
+ }
7073
+ exports.assertObject = assertObject;
7074
+ /**
7075
+ * Asserts that the *value* is an array and every element in the array satisfy to the *elementAssertion*.
7076
+ * Throws error if check fails.
7077
+ */
7078
+ function assertArray(value, elementAssertion, constraints = {}, errorContextProvider = undefined) {
7079
+ var _a, _b;
7080
+ const ctx = (mode = 'with-space-separator') => {
7081
+ const text = getErrorMessage(errorContextProvider);
7082
+ return text ? `${text}${mode === 'with-space-separator' ? ' ' : ''}` : '';
7083
+ };
7084
+ assertTruthy(Array.isArray(value), () => `${ctx()}value is not an array: ${value}`);
7085
+ const minLength = (_a = constraints.minLength) !== null && _a !== void 0 ? _a : 0;
7086
+ const maxLength = (_b = constraints.maxLength) !== null && _b !== void 0 ? _b : Infinity;
7087
+ assertTruthy(value.length >= minLength, () => `${ctx()}array length < minLength. Array length: ${value.length}, minLength: ${minLength}`);
7088
+ assertTruthy(value.length <= maxLength, () => `${ctx()}array length > maxLength. Array length: ${value.length}, maxLength: ${maxLength}`);
7089
+ if (constraints.uniqueByIdentity) {
7090
+ assertTruthy((0, ChecksLib_1.checkArrayHasUniqueElements)(value, constraints.uniqueByIdentity), () => `${ctx()}array contains non-unique elements`);
7091
+ }
7092
+ let i = 0;
7093
+ const elementErrorProvider = () => `${ctx('no-space-separator')}[${i}]`;
7094
+ for (; i < value.length; i++) {
7095
+ const element = value[i];
7096
+ if (typeof elementAssertion === 'object') {
7097
+ assertTruthy(!Array.isArray(element), () => `${elementErrorProvider}: use arrayAssertion() to create a ValueAssertion for an array`);
7098
+ assertObject(element, elementAssertion, elementErrorProvider);
7099
+ }
7100
+ else {
7101
+ callValueAssertion(element, elementAssertion, elementErrorProvider);
7102
+ }
7103
+ }
7104
+ }
7105
+ exports.assertArray = assertArray;
7106
+ /**
7107
+ * Calls the assertion.
7108
+ * Workaround for TS issue with assertion on genetic arrow function. See https://github.com/microsoft/TypeScript/issues/34523.
7109
+ */
7110
+ function callValueAssertion(value, valueAssertion, errorContextProvider) {
7111
+ valueAssertion(value, errorContextProvider);
7112
+ }
7113
+ exports.callValueAssertion = callValueAssertion;
7114
+ //# sourceMappingURL=Assertion.js.map
7115
+
7116
+ /***/ }),
7117
+
7118
+ /***/ 4810:
7119
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7120
+
7121
+ "use strict";
7122
+
7123
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7124
+ exports.stringAssertion = exports.nullOr = exports.undefinedOr = exports.valueOr = exports.$a = exports.arrayAssertion = exports.objectAssertion = void 0;
7125
+ const Assertion_1 = __webpack_require__(6676);
7126
+ const AssertionsLib_1 = __webpack_require__(4356);
7127
+ /** A shortcut to build new object type assertion. */
7128
+ function objectAssertion(objectTypeAssertion, errorContextProvider = undefined) {
7129
+ return o => (0, Assertion_1.assertObject)(o, objectTypeAssertion, errorContextProvider);
7130
+ }
7131
+ exports.objectAssertion = objectAssertion;
7132
+ /**
7133
+ * Creates an assertion for array object that checks that array is defined,
7134
+ * the array satisfies the *constraints* and every element of the array passes the *elementAssertion* check.
7135
+ */
7136
+ function arrayAssertion(elementAssertion, constraints = {}) {
7137
+ const { minLength, maxLength } = constraints;
7138
+ (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}`);
7139
+ (0, Assertion_1.assertTruthy)((minLength !== null && minLength !== void 0 ? minLength : 0) >= 0, `minLength must be a positive number: ${minLength}`);
7140
+ (0, Assertion_1.assertTruthy)((maxLength !== null && maxLength !== void 0 ? maxLength : 0) >= 0, `maxLength must be a positive number: ${maxLength}`);
7141
+ return (array, errorContextProvider = undefined) => {
7142
+ (0, Assertion_1.assertArray)(array, elementAssertion, constraints, errorContextProvider);
7143
+ };
7144
+ }
7145
+ exports.arrayAssertion = arrayAssertion;
7146
+ /**
7147
+ * Creates a new value assertion using *check* function.
7148
+ * The assertion accepts the value as valid if 'check(value)' returns true or throws an error otherwise.
7149
+ */
7150
+ function $a(check, errorMessageProvider) {
7151
+ (0, Assertion_1.assertTruthy)(typeof check === 'function', `"check" is not a function: ${check}`);
7152
+ return (value, errorContextProvider = undefined) => (0, Assertion_1.assertTruthy)(check(value), () => {
7153
+ let errorContext = (0, Assertion_1.getErrorMessage)(errorContextProvider) || 'Check is failed';
7154
+ if (!errorContext.endsWith(':')) {
7155
+ errorContext += ':';
7156
+ }
7157
+ const errorMessage = (0, Assertion_1.getErrorMessage)(errorMessageProvider);
7158
+ return `${errorContext} ${(errorMessage || (typeof value === 'object' ? '[object]' : `'${value}'`))}`;
7159
+ });
7160
+ }
7161
+ exports.$a = $a;
7162
+ /**
7163
+ * Creates an assertion that makes comparison by reference with the *expectedValue* before calling *orAssertion*.
7164
+ * If comparison with the *expectedValue* succeeds, does not call the *orAssertion*.
7165
+ */
7166
+ function valueOr(expectedValue, orAssertion) {
7167
+ return (value, errorContextProvider = undefined) => {
7168
+ if (value === expectedValue)
7169
+ return;
7170
+ if (typeof orAssertion === 'object') {
7171
+ (0, Assertion_1.assertObject)(value, orAssertion, errorContextProvider);
7172
+ }
7173
+ else {
7174
+ (0, Assertion_1.callValueAssertion)(value, orAssertion, errorContextProvider);
7175
+ }
7176
+ };
7177
+ }
7178
+ exports.valueOr = valueOr;
7179
+ /** Creates an assertion that succeeds if the value is *undefined* or calls *orAssertion* if the value is not *undefined*. */
7180
+ function undefinedOr(orAssertion) {
7181
+ return valueOr(undefined, orAssertion);
7182
+ }
7183
+ exports.undefinedOr = undefinedOr;
7184
+ /** Creates an assertion that succeeds if the value is *null* or calls *orAssertion* if the value is not *undefined*. */
7185
+ function nullOr(orAssertion) {
7186
+ return valueOr(null, orAssertion);
7187
+ }
7188
+ exports.nullOr = nullOr;
7189
+ const stringAssertion = (constraints) => (value, context = undefined) => {
7190
+ var _a, _b;
7191
+ (0, AssertionsLib_1.assertString)(value, context);
7192
+ (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}`);
7193
+ (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}`);
7194
+ };
7195
+ exports.stringAssertion = stringAssertion;
7196
+ //# sourceMappingURL=AssertionFactoriesLib.js.map
7197
+
7198
+ /***/ }),
7199
+
7200
+ /***/ 4356:
7201
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7202
+
7203
+ "use strict";
7204
+
7205
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7206
+ exports.assertNonNullable = exports.assertEmail = exports.assertHexString = exports.assertUuid = exports.assertBoolean = exports.assertNumber = exports.assertString = exports.formatError = void 0;
7207
+ const Assertion_1 = __webpack_require__(6676);
7208
+ const ChecksLib_1 = __webpack_require__(9862);
7209
+ function formatError(contextProvider, message, value) {
7210
+ const context = (0, Assertion_1.getAssertionErrorFromProvider)(contextProvider);
7211
+ if (typeof context === 'object') {
7212
+ throw context;
7213
+ }
7214
+ const renderedValue = value === undefined
7215
+ ? '<undefined>'
7216
+ : value === null
7217
+ ? '<null>'
7218
+ : `<${typeof value}:${value}>`;
7219
+ return `${context ? `${context}: ` : ''}${message} ${renderedValue}`;
7220
+ }
7221
+ exports.formatError = formatError;
7222
+ /*** Asserts that *value* is a *string*. */
7223
+ const assertString = (value, context = undefined) => {
7224
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isString)(value), () => formatError(context, 'Not a string', value));
7225
+ };
7226
+ exports.assertString = assertString;
7227
+ const assertNumber = (value, context = undefined) => {
7228
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNumber)(value), () => formatError(context, 'Not a number', value));
7229
+ };
7230
+ exports.assertNumber = assertNumber;
7231
+ const assertBoolean = (value, context = undefined) => {
7232
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isBoolean)(value), () => formatError(context, 'Not a boolean', value));
7233
+ };
7234
+ exports.assertBoolean = assertBoolean;
7235
+ const assertUuid = (value, context = undefined) => {
7236
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isUuid)(value), () => formatError(context, 'Invalid uuid', value));
7237
+ };
7238
+ exports.assertUuid = assertUuid;
7239
+ const assertHexString = (value, context = undefined) => {
7240
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isHexString)(value), () => formatError(context, 'Invalid hex string', value));
7241
+ };
7242
+ exports.assertHexString = assertHexString;
7243
+ const assertEmail = (value, context = undefined) => {
7244
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isEmail)(value), () => formatError(context, 'Invalid email', value));
7245
+ };
7246
+ exports.assertEmail = assertEmail;
7247
+ function assertNonNullable(value, context) {
7248
+ (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNonNullable)(value), () => formatError(context, `Value is ${value === undefined ? 'undefined' : 'null'}`, value));
7249
+ }
7250
+ exports.assertNonNullable = assertNonNullable;
7251
+ //# sourceMappingURL=AssertionsLib.js.map
7252
+
7253
+ /***/ }),
7254
+
7255
+ /***/ 9862:
7256
+ /***/ ((__unused_webpack_module, exports) => {
7257
+
7258
+ "use strict";
7259
+
7260
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7261
+ exports.isNonNullable = exports.isHexString = exports.isUuid = exports.isEmail = exports.checkArrayHasUniqueElements = exports.isNumber = exports.isString = exports.isBoolean = void 0;
7262
+ /** Returns *true* if the value is *boolean*. */
7263
+ function isBoolean(value) {
7264
+ return typeof value === 'boolean';
7265
+ }
7266
+ exports.isBoolean = isBoolean;
7267
+ /** Returns *true* if the value is *string*. */
7268
+ function isString(value) {
7269
+ return typeof value === 'string';
7270
+ }
7271
+ exports.isString = isString;
7272
+ /** Returns *true* if the value is *number*. */
7273
+ function isNumber(value) {
7274
+ return typeof value === 'number';
7275
+ }
7276
+ exports.isNumber = isNumber;
7277
+ /**
7278
+ * Checks that array has only unique elements.
7279
+ * Uses 'identity' function to perform checks.
7280
+ */
7281
+ function checkArrayHasUniqueElements(array, identity) {
7282
+ if (array.length <= 1) {
7283
+ return true;
7284
+ }
7285
+ const set = new Set();
7286
+ for (const e of array) {
7287
+ const id = identity(e);
7288
+ if (set.has(id)) {
7289
+ return false;
7290
+ }
7291
+ set.add(id);
7292
+ }
7293
+ return true;
7294
+ }
7295
+ exports.checkArrayHasUniqueElements = checkArrayHasUniqueElements;
7296
+ 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])+$/;
7297
+ // eslint-disable-next-line no-misleading-character-class
7298
+ 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;
7299
+ /** Returns true if *email* is a valid email address. */
7300
+ function isEmail(email, constraints = { allowInternationalDomains: false }) {
7301
+ if (!isString(email) || email.length === 0 || email.length > 254) {
7302
+ return false;
7303
+ }
7304
+ const regex = constraints.allowInternationalDomains ? EMAIL_REGEX_INTERNATIONAL : EMAIL_REGEX_REGULAR;
7305
+ if (!regex.test(email)) {
7306
+ return false;
7307
+ }
7308
+ // Validate each part.
7309
+ const parts = email.split('@');
7310
+ if (parts[0].length > 64) {
7311
+ return false;
7312
+ }
7313
+ const domainParts = parts[1].split('.');
7314
+ return !domainParts.some(part => part.length > 63);
7315
+ }
7316
+ exports.isEmail = isEmail;
7317
+ 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;
7318
+ /** Returns *true* if *value* is a valid 'uuid' (v1..v5) string. */
7319
+ function isUuid(value) {
7320
+ return isString(value) && UUID_REGEX.test(value);
7321
+ }
7322
+ exports.isUuid = isUuid;
7323
+ const HEX_STRING_REGEX = /^[0-9a-fA-F]*$/;
7324
+ /** Returns *true* if *value* is a string that contains only hexadecimal characters or is empty. */
7325
+ function isHexString(value) {
7326
+ return isString(value) && HEX_STRING_REGEX.test(value);
7327
+ }
7328
+ exports.isHexString = isHexString;
7329
+ /** Returns true if value is not 'null' and not 'undefined'. */
7330
+ function isNonNullable(value) {
7331
+ return value !== null && value !== undefined;
7332
+ }
7333
+ exports.isNonNullable = isNonNullable;
7334
+ //# sourceMappingURL=ChecksLib.js.map
7335
+
7336
+ /***/ }),
7337
+
7338
+ /***/ 3355:
7339
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
7340
+
7341
+ "use strict";
7342
+
7343
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7344
+ if (k2 === undefined) k2 = k;
7345
+ var desc = Object.getOwnPropertyDescriptor(m, k);
7346
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7347
+ desc = { enumerable: true, get: function() { return m[k]; } };
7348
+ }
7349
+ Object.defineProperty(o, k2, desc);
7350
+ }) : (function(o, m, k, k2) {
7351
+ if (k2 === undefined) k2 = k;
7352
+ o[k2] = m[k];
7353
+ }));
7354
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
7355
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
7356
+ };
7357
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7358
+ __exportStar(__webpack_require__(6676), exports);
7359
+ __exportStar(__webpack_require__(4810), exports);
7360
+ __exportStar(__webpack_require__(4356), exports);
7361
+ __exportStar(__webpack_require__(9862), exports);
7362
+ //# sourceMappingURL=index.js.map
7363
+
6951
7364
  /***/ }),
6952
7365
 
6953
7366
  /***/ 2091:
@@ -26308,14 +26721,15 @@ __webpack_require__.r(__webpack_exports__);
26308
26721
 
26309
26722
  // EXPORTS
26310
26723
  __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)
26724
+ AiAssistantProfileReference: () => (/* reexport */ AiAssistantProfileReference),
26725
+ Changes: () => (/* reexport */ Changes),
26726
+ CollectionReference: () => (/* reexport */ CollectionReference),
26727
+ DocumentReference: () => (/* reexport */ DocumentReference),
26728
+ GraphQLClient: () => (/* reexport */ GraphQLClient),
26729
+ JoinQueryBuilder: () => (/* reexport */ JoinQueryBuilder),
26730
+ QueryBuilder: () => (/* reexport */ QueryBuilder),
26731
+ Squid: () => (/* reexport */ Squid),
26732
+ deserializeQuery: () => (/* reexport */ deserializeQuery)
26319
26733
  });
26320
26734
 
26321
26735
  ;// CONCATENATED MODULE: ../common/src/ai-assistant.schemas.ts
@@ -26622,6 +27036,9 @@ var IntegrationType;
26622
27036
  IntegrationType["azure_sql"] = "azure_sql";
26623
27037
  IntegrationType["azure_postgresql"] = "azure_postgresql";
26624
27038
  IntegrationType["azure_cosmosdb"] = "azure_cosmosdb";
27039
+ IntegrationType["firestore"] = "firestore";
27040
+ IntegrationType["bigquery"] = "bigquery";
27041
+ IntegrationType["cloudsql"] = "cloudsql";
26625
27042
  })(IntegrationType || (IntegrationType = {}));
26626
27043
  var IntegrationSchemaType;
26627
27044
  (function (IntegrationSchemaType) {
@@ -26820,9 +27237,8 @@ const GraphQLConnectionOptionsSchema = {
26820
27237
  const OpenApiDiscoveryOptionsSchema = {
26821
27238
  type: 'object',
26822
27239
  nullable: false,
26823
- required: ['openApiSpecUrl'],
26824
27240
  properties: {
26825
- openApiSpecUrl: { type: 'string', nullable: false },
27241
+ openApiSpecUrl: { type: 'string', nullable: true },
26826
27242
  },
26827
27243
  };
26828
27244
  /** Generated using openai */
@@ -27581,7 +27997,6 @@ const DiscoverOpenApiSchemaRequestSchema = {
27581
27997
  properties: {
27582
27998
  discoveryOptions: {
27583
27999
  type: 'object',
27584
- required: ['openApiSpecUrl'],
27585
28000
  properties: {
27586
28001
  openApiSpecUrl: {
27587
28002
  type: 'string',
@@ -27707,11 +28122,10 @@ var CronExpression;
27707
28122
  /** @internal */
27708
28123
  const ExecuteBackendFunctionRequestSchema = {
27709
28124
  type: 'object',
27710
- required: ['functionName', 'paramsArrayStr', 'clientRequestId'],
28125
+ required: ['functionName', 'paramsArrayStr'],
27711
28126
  properties: {
27712
28127
  functionName: { type: 'string', nullable: false },
27713
28128
  paramsArrayStr: { type: 'string', nullable: false },
27714
- clientRequestId: { type: 'string', nullable: false },
27715
28129
  },
27716
28130
  };
27717
28131
 
@@ -27937,16 +28351,34 @@ function compareOperator(conditionValue, valueInDocument, operator) {
27937
28351
  return !lodash_default().isEqual(conditionValue, valueInDocument);
27938
28352
  }
27939
28353
  // Nulls can only be compared for (in)equality, not other operators.
27940
- if (conditionValue === null || valueInDocument === null)
27941
- return false;
27942
28354
  switch (operator) {
27943
28355
  case '<':
28356
+ if (lodash_default().isNil(conditionValue))
28357
+ return false;
28358
+ if (lodash_default().isNil(valueInDocument))
28359
+ return true;
27944
28360
  return valueInDocument < conditionValue;
27945
28361
  case '<=':
28362
+ if (lodash_default().isNil(valueInDocument)) {
28363
+ return true;
28364
+ }
28365
+ if (lodash_default().isNil(conditionValue)) {
28366
+ return false;
28367
+ }
27946
28368
  return valueInDocument <= conditionValue;
27947
28369
  case '>':
28370
+ if (lodash_default().isNil(valueInDocument))
28371
+ return false;
28372
+ if (lodash_default().isNil(conditionValue))
28373
+ return true;
27948
28374
  return valueInDocument > conditionValue;
27949
28375
  case '>=':
28376
+ if (lodash_default().isNil(conditionValue)) {
28377
+ return true;
28378
+ }
28379
+ if (lodash_default().isNil(valueInDocument)) {
28380
+ return false;
28381
+ }
27950
28382
  return valueInDocument >= conditionValue;
27951
28383
  case 'like':
27952
28384
  return (typeof valueInDocument === 'string' &&
@@ -27974,11 +28406,11 @@ function isStringMatch(str, pattern, caseSensitive) {
27974
28406
  str = str.toLowerCase();
27975
28407
  pattern = pattern.toLowerCase();
27976
28408
  }
27977
- str = str.replace(/\n/g, ' ');
27978
28409
  // Escape special regex characters in the pattern
27979
28410
  const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
27980
28411
  // Replace '%' wildcard with regex equivalent
27981
- const regexPattern = escapedPattern.replace(/%/g, '.*');
28412
+ // Note: this allows for newlines, unlike .*
28413
+ const regexPattern = escapedPattern.replace(/%/g, '[\\s\\S]*');
27982
28414
  // Create regex object and test if string matches
27983
28415
  const regex = new RegExp(`^${regexPattern}$`);
27984
28416
  return regex.test(str);
@@ -28368,319 +28800,8 @@ class BaseQueryBuilder {
28368
28800
 
28369
28801
  ;// CONCATENATED MODULE: external "rxjs"
28370
28802
  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
-
28803
+ // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
28804
+ var dist = __webpack_require__(8975);
28684
28805
  ;// CONCATENATED MODULE: ../common/src/utils/object.ts
28685
28806
 
28686
28807
 
@@ -28689,7 +28810,7 @@ function getInPath(obj, path, delimiter = '.') {
28689
28810
  let value = undefined;
28690
28811
  let currentObj = obj;
28691
28812
  while (currentObj && splitPath.length) {
28692
- const key = assert_truthy(splitPath.shift());
28813
+ const key = (0,dist.truthy)(splitPath.shift());
28693
28814
  if (!(currentObj instanceof Object) || !(key in currentObj)) {
28694
28815
  return undefined;
28695
28816
  }
@@ -28708,7 +28829,7 @@ function setInPath(obj, path, value, delimiter = '.') {
28708
28829
  const splitPath = path.split(delimiter);
28709
28830
  let currentObj = obj;
28710
28831
  while (splitPath.length) {
28711
- const key = assert_truthy(splitPath.shift());
28832
+ const key = (0,dist.truthy)(splitPath.shift());
28712
28833
  if (splitPath.length) {
28713
28834
  const newCurrentObj = isJsObject(currentObj[key]) ? (_a = lodash.clone(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
28714
28835
  currentObj[key] = newCurrentObj;
@@ -28724,7 +28845,7 @@ function deleteInPath(obj, path, delimiter = '.') {
28724
28845
  const splitPath = path.split(delimiter);
28725
28846
  let currentObj = obj;
28726
28847
  while (splitPath.length) {
28727
- const key = assert_truthy(splitPath.shift());
28848
+ const key = (0,dist.truthy)(splitPath.shift());
28728
28849
  if (splitPath.length) {
28729
28850
  const newCurrentObj = isJsObject(currentObj[key]) ? (_a = lodash.clone(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
28730
28851
  currentObj[key] = newCurrentObj;
@@ -28753,6 +28874,7 @@ function replaceKeyInRecord(record, a, b) {
28753
28874
  ;// CONCATENATED MODULE: ../common/src/query/pagination.ts
28754
28875
 
28755
28876
 
28877
+
28756
28878
  class Pagination {
28757
28879
  /** @internal */
28758
28880
  constructor(snapshotEmitter, options = {}) {
@@ -28797,6 +28919,12 @@ class Pagination {
28797
28919
  this.snapshotSubject.next(firstPageSnapshot);
28798
28920
  }
28799
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
+ }
28800
28928
  if (a > b) {
28801
28929
  return 1;
28802
28930
  }
@@ -28808,7 +28936,7 @@ class Pagination {
28808
28936
  }
28809
28937
  }
28810
28938
  compare(doc1, doc2) {
28811
- if (doc2 === null) {
28939
+ if (lodash_default().isNil(doc2)) {
28812
28940
  return 1;
28813
28941
  }
28814
28942
  for (const so of this.templateSnapshotEmitter.getSortOrders()) {
@@ -29090,13 +29218,18 @@ function isWebhookResponse(response) {
29090
29218
  }
29091
29219
 
29092
29220
  ;// CONCATENATED MODULE: ../common/src/communication.types.ts
29221
+ /**
29222
+ * The appId is the unique identifier of an application.
29223
+ * It is the combination of the application id (as shown in the console), environment id (dev, prod) and the
29224
+ * developer id (if exists). For example - "fdgfd90ds-dev-1234567890abcdef"
29225
+ */
29093
29226
 
29094
29227
  const allEnvironmentIds = (/* unused pure expression or super */ null && (['prod', 'dev']));
29095
29228
  /** @internal */
29096
29229
  function parseAppId(appId) {
29097
29230
  /** We're splitting also by underscore because of backward compatibility - remove this in a few months */
29098
29231
  const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split(/[_-]/);
29099
- assert_assertTruthy(!other, 'Invalid appId: ' + appId);
29232
+ (0,dist.assertTruthy)(!other, 'Invalid appId: ' + appId);
29100
29233
  return {
29101
29234
  appId: appIdWithoutEnv,
29102
29235
  environmentId: (environmentId !== null && environmentId !== void 0 ? environmentId : 'prod'),
@@ -29178,7 +29311,7 @@ function hasDocumentDiff(beforeDoc, afterDoc) {
29178
29311
  switch (diff.kind) {
29179
29312
  case 'N':
29180
29313
  // If a new property has been added, and it's defined, the document is changed.
29181
- return isNotNullish(diff.rhs);
29314
+ return isNonNullable(diff.rhs);
29182
29315
  case 'E':
29183
29316
  case 'D':
29184
29317
  case 'A':
@@ -29223,6 +29356,59 @@ const EmptyIntrospection = {
29223
29356
  },
29224
29357
  };
29225
29358
 
29359
+ ;// CONCATENATED MODULE: ../common/src/http-status.enum.ts
29360
+ var http_status_enum_HttpStatus;
29361
+ (function (HttpStatus) {
29362
+ HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
29363
+ HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
29364
+ HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
29365
+ HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
29366
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
29367
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
29368
+ HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
29369
+ HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
29370
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
29371
+ HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
29372
+ HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
29373
+ HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
29374
+ HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
29375
+ HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
29376
+ HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
29377
+ HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
29378
+ HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
29379
+ HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
29380
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
29381
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
29382
+ HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
29383
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
29384
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
29385
+ HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
29386
+ HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
29387
+ HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
29388
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
29389
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
29390
+ HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
29391
+ HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
29392
+ HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
29393
+ HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
29394
+ HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
29395
+ HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
29396
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
29397
+ HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
29398
+ HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
29399
+ HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
29400
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
29401
+ HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
29402
+ HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
29403
+ HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
29404
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
29405
+ HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
29406
+ HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
29407
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
29408
+ HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
29409
+ HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
29410
+ })(http_status_enum_HttpStatus || (http_status_enum_HttpStatus = {}));
29411
+
29226
29412
  ;// CONCATENATED MODULE: ../common/src/logger.types.ts
29227
29413
  var LogLevel;
29228
29414
  (function (LogLevel) {
@@ -29426,7 +29612,7 @@ function mergeMutations(mutationA, mutationB) {
29426
29612
  // At this point mutationB.type has to be 'update'
29427
29613
  if (mutationA.type === 'delete')
29428
29614
  throw new Error('Cannot delete and then update');
29429
- assert_assertTruthy(mutationB.type === 'update', 'Invalid mutation type');
29615
+ (0,dist.assertTruthy)(mutationB.type === 'update', 'Invalid mutation type');
29430
29616
  if (mutationA.type === 'update')
29431
29617
  return mergeUpdateMutations(mutationA, mutationB);
29432
29618
  const result = lodash.cloneDeep(mutationA);
@@ -29545,7 +29731,7 @@ function getSquidSupportedCloudMap() {
29545
29731
  id: 'aws',
29546
29732
  name: 'Amazon Web Services',
29547
29733
  icon: 'aws_icon',
29548
- regions: [squidSupportedRegionMap['us-east-1.aws']].filter(isNotNullish),
29734
+ regions: [squidSupportedRegionMap['us-east-1.aws']].filter(isNonNullable),
29549
29735
  },
29550
29736
  gcp: {
29551
29737
  id: 'gcp',
@@ -29579,8 +29765,225 @@ function convertFromSquidRegion(regionAndCloud) {
29579
29765
  var ajv = __webpack_require__(6236);
29580
29766
  var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv);
29581
29767
  // EXTERNAL MODULE: ../node_modules/ajv-formats/dist/index.js
29582
- var dist = __webpack_require__(8414);
29583
- var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
29768
+ var ajv_formats_dist = __webpack_require__(8414);
29769
+ var ajv_formats_dist_default = /*#__PURE__*/__webpack_require__.n(ajv_formats_dist);
29770
+ ;// CONCATENATED MODULE: ../common/src/utils/validation.ts
29771
+ /**
29772
+ * This file contains general validators for the different objects being received from the client. The parameters are
29773
+ * usually of type 'any' to make sure there are no assumptions that the object has the correct type.
29774
+ * Also, this file should avoid importing from other files that are not for validation to avoid circular deps.
29775
+ */
29776
+
29777
+ class validation_ValidationError extends (/* unused pure expression or super */ null && (Error)) {
29778
+ constructor(error, statusCode, details) {
29779
+ super(error);
29780
+ this.statusCode = statusCode;
29781
+ this.details = details;
29782
+ }
29783
+ }
29784
+ function validatePathPart(part) {
29785
+ if (!part || !part.match(/^[a-zA-Z][a-zA-Z0-9!@#$%^&*~_]{0,49}$/)) {
29786
+ throw new Error('A document id and a collection id can contain only a-z, A-Z, 0-9,!@#$%^&*~_, starting' +
29787
+ 'with a letter, at least one character, and up to 50.');
29788
+ }
29789
+ }
29790
+ function validateCollectionName(collectionName) {
29791
+ if (typeof collectionName !== 'string' || !collectionName) {
29792
+ throw new Error('Collection path has to be a non empty string');
29793
+ }
29794
+ validatePathPart(collectionName);
29795
+ }
29796
+ function validateFieldName(fieldName) {
29797
+ if (!fieldName || typeof fieldName !== 'string') {
29798
+ throw new Error('Field name has to be a non-empty string');
29799
+ }
29800
+ if (fieldName === '__docId__') {
29801
+ // __docId__ is the only valid fieldName that can start with '_'
29802
+ return;
29803
+ }
29804
+ if (!fieldName.match(/^[a-zA-Z_$][a-zA-Z0-9!@#$%^&*~_ ]{0,49}$/)) {
29805
+ 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: ' +
29806
+ fieldName);
29807
+ }
29808
+ }
29809
+ // TODO: remove if not used
29810
+ function validateQueryCondition(condition) {
29811
+ if (!condition) {
29812
+ throw new Error('Condition cannot be empty');
29813
+ }
29814
+ if (!condition.operator ||
29815
+ !['==', '!=', '>', '>=', '<', '<=', 'like', 'not like', 'like_cs', 'not like_cs'].includes(condition.operator)) {
29816
+ throw new Error('Unsupported operator: ' + condition.operator);
29817
+ }
29818
+ validateFieldName(condition.fieldName);
29819
+ // TODO - figure out how to validate the value
29820
+ }
29821
+ function validateFieldSort(fieldSort) {
29822
+ if (!(fieldSort instanceof Object)) {
29823
+ throw new Error('Field sort has to be an object');
29824
+ }
29825
+ (0,dist.assertTruthy)(hasOnlyKeys(fieldSort, ['fieldName', 'asc']), 'Field sort should only contain a fieldName and asc');
29826
+ (0,dist.assertTruthy)(isRightType(fieldSort.asc, 'boolean'), 'Asc needs to be boolean');
29827
+ validateFieldName(fieldSort.fieldName);
29828
+ }
29829
+ function validateOpenIdProvider(openIdProvider) {
29830
+ assertTruthy(openIdProvider, 'INVALID_PROVIDER');
29831
+ validateOpenIdProviderType(openIdProvider.providerType);
29832
+ assertTruthy(openIdProvider.providerType, 'INVALID_CLIENT_ID');
29833
+ assertTruthy(openIdProvider.clientId, 'INVALID_CLIENT_ID');
29834
+ assertTruthy(openIdProvider.domain, 'INVALID_DOMAIN');
29835
+ return openIdProvider;
29836
+ }
29837
+ function validateOpenIdProviderType(providerType) {
29838
+ const providerArray = ['auth0'];
29839
+ assertTruthy(providerArray.includes(providerType), 'INVALID_OPEN_ID_PROVIDER_TYPE');
29840
+ }
29841
+ function validateDeleteMutation(mutation) {
29842
+ if (!mutation || mutation.type !== 'delete') {
29843
+ throw new Error('Mutation has to be non empty with type delete.');
29844
+ }
29845
+ // Not much to validate for delete.
29846
+ }
29847
+ function validateInsertMutation(mutation) {
29848
+ if (!mutation || mutation.type !== 'insert') {
29849
+ throw new Error('Mutation has to be non empty with type insert.');
29850
+ }
29851
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
29852
+ throw new Error('The properties in insert mutation need to be a JSON object.');
29853
+ }
29854
+ for (const [fieldName] of Object.entries(mutation.properties)) {
29855
+ validateFieldName(fieldName);
29856
+ // TODO - figure out how to validate the value
29857
+ }
29858
+ }
29859
+ function validateUpdatePropertyMutation(propertyMutation) {
29860
+ if (!propertyMutation || propertyMutation.type !== 'update') {
29861
+ throw new Error('Update value property mutation has to be of type update');
29862
+ }
29863
+ if (propertyMutation.value === undefined) {
29864
+ throw new Error('Value has to exist in an update value property mutation..');
29865
+ }
29866
+ }
29867
+ function validateApplyNumericFnPropertyMutation(propertyMutation) {
29868
+ if (!propertyMutation || propertyMutation.type !== 'applyNumericFn') {
29869
+ throw new Error('Apply numeric fn mutation has to be of type applyNumericFn');
29870
+ }
29871
+ if (!['increment'].includes(propertyMutation.fn)) {
29872
+ throw new Error('Invalid fn for apply numeric fn.');
29873
+ }
29874
+ if (typeof propertyMutation.value !== 'number') {
29875
+ throw new Error('The value in an apply numeric fn function has to be numeric.');
29876
+ }
29877
+ }
29878
+ function validateApplyStringFnPropertyMutation(propertyMutation) {
29879
+ if (!propertyMutation || propertyMutation.type !== 'applyStringFn') {
29880
+ throw new Error('Apply string fn mutation has to be of type applyStringFn');
29881
+ }
29882
+ if (!['trim', 'extendString'].includes(propertyMutation.fn)) {
29883
+ throw new Error('Invalid fn for apply string fn.');
29884
+ }
29885
+ if (typeof propertyMutation.value !== 'string') {
29886
+ throw new Error('The value in an apply string fn function has to be a string.');
29887
+ }
29888
+ }
29889
+ function validatePropertyMutation(propertyMutation) {
29890
+ if (!propertyMutation || typeof propertyMutation !== 'object') {
29891
+ throw new Error('Property mutation need to be a JSON object.');
29892
+ }
29893
+ if (!['update', 'applyNumericFn', 'applyStringFn'].includes(propertyMutation.type)) {
29894
+ throw new Error(`Property mutation can be of type 'update', 'applyNumericFn', 'applyStringFn'`);
29895
+ }
29896
+ switch (propertyMutation.type) {
29897
+ case 'update':
29898
+ validateUpdatePropertyMutation(propertyMutation);
29899
+ break;
29900
+ case 'applyNumericFn':
29901
+ validateApplyNumericFnPropertyMutation(propertyMutation);
29902
+ break;
29903
+ case 'applyStringFn':
29904
+ validateApplyStringFnPropertyMutation(propertyMutation);
29905
+ break;
29906
+ }
29907
+ }
29908
+ function validateUpdateMutation(mutation) {
29909
+ if (!mutation || mutation.type !== 'update') {
29910
+ throw new Error('Mutation has to be non empty with type update.');
29911
+ }
29912
+ if (!mutation.properties || typeof mutation.properties !== 'object') {
29913
+ throw new Error('The properties in update mutation need to be a JSON object.');
29914
+ }
29915
+ const entries = Object.entries(mutation.properties);
29916
+ for (const [fieldName, propertyMutations] of entries) {
29917
+ validateFieldName(fieldName);
29918
+ for (const propertyMutation of propertyMutations) {
29919
+ validatePropertyMutation(propertyMutation);
29920
+ }
29921
+ }
29922
+ }
29923
+ function validateMutation(mutation) {
29924
+ if (!mutation) {
29925
+ throw new Error('Mutation cannot be empty');
29926
+ }
29927
+ if (!['insert', 'delete', 'update'].includes(mutation.type)) {
29928
+ throw new Error(`Mutation type has to be one of 'insert', 'delete', or 'update'`);
29929
+ }
29930
+ validateCollectionName(mutation.squidDocIdObj.collectionName);
29931
+ validatePathPart(mutation.squidDocIdObj.docId);
29932
+ switch (mutation.type) {
29933
+ case 'delete':
29934
+ validateDeleteMutation(mutation);
29935
+ break;
29936
+ case 'insert':
29937
+ validateInsertMutation(mutation);
29938
+ break;
29939
+ case 'update':
29940
+ validateUpdateMutation(mutation);
29941
+ break;
29942
+ }
29943
+ }
29944
+ function validateMutations(mutations) {
29945
+ if (!mutations || !(mutations instanceof Array) || !mutations.length) {
29946
+ throw new Error('The list of mutations has to be a non-empty array.');
29947
+ }
29948
+ for (const mutation of mutations) {
29949
+ validateMutation(mutation);
29950
+ }
29951
+ }
29952
+ function validateQueryLimit(limit) {
29953
+ (0,dist.assertTruthy)(isRightType(limit, 'number'), 'Limit needs to be a number');
29954
+ if (limit === -1)
29955
+ return;
29956
+ (0,dist.assertTruthy)(limit > 0, 'query limit has to be greater than 0');
29957
+ (0,dist.assertTruthy)(Math.floor(limit) === limit, 'query limit has to be an integer');
29958
+ (0,dist.assertTruthy)(limit <= 20000, 'Limit can be maximum 20000');
29959
+ }
29960
+ /** Returns true if the value is not an empty string (undefined/null are considered empty). */
29961
+ function isNotEmpty(value) {
29962
+ validateCorrectStringType(value);
29963
+ return typeof value === 'string' && !!value;
29964
+ }
29965
+ /**
29966
+ * TODO: deprecated: this method is used in both validate...() and is...() methods.
29967
+ * The validate...() must throw an error, while is...() must not.
29968
+ */
29969
+ function validateCorrectStringType(value) {
29970
+ if (value !== null && value !== undefined && typeof value !== 'string') {
29971
+ throw new Error(`Unexpected input type ${typeof value}`);
29972
+ }
29973
+ }
29974
+ /** Returns true if 'typeof' of the 'value' is 'type' or 'type[]'. */
29975
+ function isRightType(value, type) {
29976
+ // TODO: the method is ambiguous when the value is an empty array and will return 'true' for any type.
29977
+ if (Array.isArray(value)) {
29978
+ return value.every((element) => typeof element === type);
29979
+ }
29980
+ return typeof value === type;
29981
+ }
29982
+ /** Returns true if 'obj' has only keys listed in the 'keys'. Object can't be an array. */
29983
+ function hasOnlyKeys(obj, keys) {
29984
+ return !Array.isArray(obj) && [...Object.keys(obj)].every((key) => keys.includes(key));
29985
+ }
29986
+
29584
29987
  ;// CONCATENATED MODULE: ../common/src/schema/schema.types.ts
29585
29988
 
29586
29989
 
@@ -29589,7 +29992,7 @@ var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
29589
29992
 
29590
29993
 
29591
29994
  const schema_types_ajv = new (ajv_default())({ allErrors: true, allowUnionTypes: false, useDefaults: false });
29592
- dist_default()(schema_types_ajv);
29995
+ ajv_formats_dist_default()(schema_types_ajv);
29593
29996
  schema_types_ajv.addKeyword({
29594
29997
  keyword: 'isDate',
29595
29998
  type: 'object',
@@ -29728,7 +30131,8 @@ function getMatchingProperties(path, schema) {
29728
30131
  result.parentsMatch.push(schema);
29729
30132
  const pathToUse = [...path];
29730
30133
  while (pathToUse.length) {
29731
- const key = notNullish(pathToUse.shift());
30134
+ const key = pathToUse.shift();
30135
+ assertTruthy(key !== undefined);
29732
30136
  const matchingPropertiesForKey = findMatchingPropertiesForKey(schema, key);
29733
30137
  for (const property of matchingPropertiesForKey) {
29734
30138
  const subMatchingProperties = getMatchingProperties(pathToUse, property);
@@ -29903,12 +30307,17 @@ const arrayMergeCustomizer = (a, b) => {
29903
30307
  }
29904
30308
  };
29905
30309
 
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
- }
30310
+ ;// CONCATENATED MODULE: ../common/src/utils/assert.ts
30311
+
30312
+
30313
+
30314
+ /** @internal */
30315
+ function assertValidateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
30316
+ assertTruthy(value, () => new ValidationError(message, statusCode, details));
30317
+ }
30318
+ /** @internal */
30319
+ function validateTruthy(value, message, statusCode = HttpStatus.BAD_REQUEST, details) {
30320
+ return truthy(value, () => new ValidationError(message, statusCode, details));
29912
30321
  }
29913
30322
 
29914
30323
  ;// CONCATENATED MODULE: ../common/src/utils/http.ts
@@ -29992,7 +30401,7 @@ class LockManager {
29992
30401
  }
29993
30402
  release(...mutexes) {
29994
30403
  for (const mutex of mutexes) {
29995
- const isLockedSubject = assert_truthy(this.locks[mutex]);
30404
+ const isLockedSubject = (0,dist.truthy)(this.locks[mutex]);
29996
30405
  isLockedSubject.next(false);
29997
30406
  isLockedSubject.complete();
29998
30407
  delete this.locks[mutex];
@@ -30002,21 +30411,13 @@ class LockManager {
30002
30411
  return !mutexes.some((mutex) => { var _a; return (_a = this.locks[mutex]) === null || _a === void 0 ? void 0 : _a.value; });
30003
30412
  }
30004
30413
  lockSync(...mutexes) {
30005
- assert_assertTruthy(this.canGetLock(...mutexes), 'Cannot acquire lock sync');
30414
+ (0,dist.assertTruthy)(this.canGetLock(...mutexes), 'Cannot acquire lock sync');
30006
30415
  for (const mutex of mutexes) {
30007
30416
  this.locks[mutex] = new external_rxjs_namespaceObject.BehaviorSubject(true);
30008
30417
  }
30009
30418
  }
30010
30419
  }
30011
30420
 
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
30421
  ;// CONCATENATED MODULE: ../common/src/heartbeat.types.ts
30021
30422
 
30022
30423
  async function checkAllHeartbeatProviders(heartbeatProviders) {
@@ -30047,13 +30448,13 @@ function getGlobal() {
30047
30448
  }
30048
30449
  /** @internal */
30049
30450
  function isDebugEnabled() {
30050
- const global = getGlobal();
30051
- return global && global['SQUID_DEBUG_ENABLED'];
30451
+ const globalObj = getGlobal();
30452
+ return globalObj && globalObj['SQUID_DEBUG_ENABLED'];
30052
30453
  }
30053
30454
  /** @internal */
30054
30455
  function enableDebugLogs() {
30055
- const global = getGlobal();
30056
- global['SQUID_DEBUG_ENABLED'] = true;
30456
+ const globalObj = getGlobal();
30457
+ globalObj['SQUID_DEBUG_ENABLED'] = true;
30057
30458
  }
30058
30459
  /** @internal */
30059
30460
  class DebugLogger {
@@ -30207,7 +30608,6 @@ function createWebSocketWrapper(url, opts = {}) {
30207
30608
 
30208
30609
 
30209
30610
 
30210
-
30211
30611
 
30212
30612
 
30213
30613
 
@@ -31667,6 +32067,7 @@ class MergedQueryBuilder {
31667
32067
 
31668
32068
 
31669
32069
 
32070
+
31670
32071
  /**
31671
32072
  * Holds a reference to a document. A document reference is a reference to a specific record in a collection. You can
31672
32073
  * 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 +32109,7 @@ class DocumentReference {
31708
32109
  integrationId,
31709
32110
  }, null, 2)}`;
31710
32111
  };
31711
- return assert_truthy(this.dataManager.getProperties(this.squidDocId), getError());
32112
+ return (0,dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError());
31712
32113
  }
31713
32114
  /**
31714
32115
  * Returns whether data has been populated for this document reference. Data
@@ -31731,7 +32132,7 @@ class DocumentReference {
31731
32132
  if (this.isTracked() && this.hasData)
31732
32133
  return this.data;
31733
32134
  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);
32135
+ (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + this.squidDocId);
31735
32136
  return results.length ? results[0] : undefined;
31736
32137
  }
31737
32138
  /**
@@ -31747,7 +32148,7 @@ class DocumentReference {
31747
32148
  .dereference()
31748
32149
  .snapshots()
31749
32150
  .pipe((0,external_rxjs_namespaceObject.map)((results) => {
31750
- assert_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);
31751
32152
  return results.length ? results[0] : undefined;
31752
32153
  }));
31753
32154
  }
@@ -31930,6 +32331,7 @@ class DocumentReference {
31930
32331
 
31931
32332
 
31932
32333
 
32334
+
31933
32335
  /** @internal */
31934
32336
  class QueryBuilderFactory {
31935
32337
  constructor(querySubscriptionManager, localQueryManager, documentReferenceFactory, documentIdentityService) {
@@ -32057,6 +32459,10 @@ class QueryBuilder extends BaseQueryBuilder {
32057
32459
  return this.query.limit;
32058
32460
  }
32059
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.');
32060
32466
  this.query.limitBy = { limit, fields, reverseSort: false };
32061
32467
  return this;
32062
32468
  }
@@ -32064,7 +32470,7 @@ class QueryBuilder extends BaseQueryBuilder {
32064
32470
  sortBy(fieldName, asc = true) {
32065
32471
  const fieldSort = { asc, fieldName };
32066
32472
  validateFieldSort(fieldSort);
32067
- assert_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.`);
32068
32474
  this.query.sortOrder.push(fieldSort);
32069
32475
  return this;
32070
32476
  }
@@ -32136,9 +32542,9 @@ class QueryBuilder extends BaseQueryBuilder {
32136
32542
  .processQuery(query, this.collectionName, {}, {}, subscribe, this.forceFetchFromServer)
32137
32543
  .pipe(map_map((docs) => {
32138
32544
  return docs.map((docRecord) => {
32139
- assert_assertTruthy(Object.keys(docRecord).length === 1);
32545
+ (0,dist.assertTruthy)(Object.keys(docRecord).length === 1);
32140
32546
  const doc = docRecord[this.collectionName];
32141
- const squidDocId = getSquidDocId(assert_truthy(doc).__docId__, this.collectionName, this.integrationId);
32547
+ const squidDocId = getSquidDocId((0,dist.truthy)(doc).__docId__, this.collectionName, this.integrationId);
32142
32548
  return this.documentReferenceFactory.create(squidDocId, this.queryBuilderFactory);
32143
32549
  });
32144
32550
  }));
@@ -32709,55 +33115,30 @@ class AiClientFactory {
32709
33115
 
32710
33116
 
32711
33117
 
32712
-
32713
33118
  class ApiManager {
32714
- constructor(clientIdService, rpcManager, socketManager, apiServerUrlOverrideMapping = {}) {
33119
+ constructor(clientIdService, rpcManager, apiServerUrlOverrideMapping = {}) {
32715
33120
  this.clientIdService = clientIdService;
32716
33121
  this.rpcManager = rpcManager;
32717
- this.socketManager = socketManager;
32718
33122
  this.apiServerUrlOverrideMapping = apiServerUrlOverrideMapping;
32719
- this.ongoingApiExecutions = {};
32720
- socketManager
32721
- .observeNotifications()
32722
- .pipe((0,external_rxjs_namespaceObject.filter)((notification) => notification.type === 'api'), map_map((n) => n))
32723
- .subscribe((notification) => {
32724
- this.handleApiResponse(notification.clientRequestId, notification).then();
32725
- });
32726
33123
  }
32727
33124
  callApiAndSubscribe(integrationId, endpointId, request) {
32728
- const clientRequestId = generateId();
32729
- const subject = new external_rxjs_namespaceObject.Subject();
32730
- this.ongoingApiExecutions[clientRequestId] = subject;
32731
33125
  const callApiRequest = {
32732
33126
  integrationId,
32733
33127
  endpointId,
32734
33128
  request,
32735
- clientRequestId,
32736
33129
  serverUrlOverride: this.apiServerUrlOverrideMapping[integrationId],
32737
33130
  };
32738
- this.rpcManager.post('api/call', callApiRequest).catch((e) => {
32739
- console.error('Got error while calling API', integrationId, endpointId, request, e);
32740
- subject.error(e);
32741
- subject.complete();
32742
- });
32743
- return (0,external_rxjs_namespaceObject.race)(subject.pipe((0,external_rxjs_namespaceObject.finalize)(() => {
32744
- delete this.ongoingApiExecutions[clientRequestId];
32745
- }), (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(() => {
32746
33139
  throw new Error('CLIENT_NOT_CONNECTED');
32747
33140
  })));
32748
33141
  }
32749
- async handleApiResponse(clientRequestId, notification) {
32750
- const subject = this.ongoingApiExecutions[clientRequestId];
32751
- if (!subject)
32752
- return;
32753
- if (notification.success) {
32754
- subject.next(deserializeObj(notification.payload));
32755
- }
32756
- else {
32757
- subject.error((0,lodash.pick)(notification, 'httpStatus', 'payload'));
32758
- }
32759
- subject.complete();
32760
- }
32761
33142
  }
32762
33143
 
32763
33144
  ;// CONCATENATED MODULE: ./src/auth.manager.ts
@@ -32809,52 +33190,24 @@ class AuthManager {
32809
33190
 
32810
33191
 
32811
33192
  class BackendFunctionManager {
32812
- constructor(clientIdService, rpcManager, socketManager) {
33193
+ constructor(clientIdService, rpcManager) {
32813
33194
  this.clientIdService = clientIdService;
32814
33195
  this.rpcManager = rpcManager;
32815
- this.socketManager = socketManager;
32816
- this.ongoingFunctionExecutions = {};
32817
- socketManager
32818
- .observeNotifications()
32819
- .pipe((0,external_rxjs_namespaceObject.filter)((notification) => notification.type === 'backendFunction'), map_map((n) => n))
32820
- .subscribe((notification) => {
32821
- this.handleFunctionResponse(notification.clientRequestId, notification.payload);
32822
- });
32823
33196
  }
32824
33197
  executeFunctionAndSubscribe(functionName, ...params) {
32825
- const clientRequestId = generateId();
32826
- const subject = new external_rxjs_namespaceObject.Subject();
32827
- this.ongoingFunctionExecutions[clientRequestId] = subject;
32828
33198
  const request = {
32829
33199
  functionName,
32830
33200
  paramsArrayStr: serialization_serializeObj(params),
32831
- clientRequestId,
32832
33201
  };
32833
- this.rpcManager.post('backend-function/execute', request).catch((e) => {
32834
- console.error('Got error while executing function', functionName, e);
32835
- subject.error(e);
32836
- subject.complete();
32837
- });
32838
- return (0,external_rxjs_namespaceObject.race)(subject.pipe((0,external_rxjs_namespaceObject.finalize)(() => {
32839
- delete this.ongoingFunctionExecutions[clientRequestId];
32840
- }), (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(() => {
32841
33208
  throw new Error('CLIENT_NOT_CONNECTED');
32842
33209
  })));
32843
33210
  }
32844
- handleFunctionResponse(clientRequestId, serializedResponse) {
32845
- const subject = this.ongoingFunctionExecutions[clientRequestId];
32846
- if (!subject) {
32847
- return;
32848
- }
32849
- const payload = deserializeObj(serializedResponse);
32850
- if (payload.success) {
32851
- subject.next(payload.response);
32852
- }
32853
- else {
32854
- subject.error(new Error(payload.response));
32855
- subject.complete();
32856
- }
32857
- }
32858
33211
  }
32859
33212
 
32860
33213
  ;// CONCATENATED MODULE: ./src/client-id.service.ts
@@ -32975,6 +33328,7 @@ var promise_pool_dist = __webpack_require__(3910);
32975
33328
 
32976
33329
 
32977
33330
 
33331
+
32978
33332
  /** Two transactions cannot run in parallel - this mutex is used for blocking a second transaction. */
32979
33333
  const RUN_IN_TRANSACTION_MUTEX = 'dataManager_runInTransaction';
32980
33334
  class DataManager {
@@ -33099,7 +33453,7 @@ class DataManager {
33099
33453
  */
33100
33454
  async runInTransaction(fn, transactionId) {
33101
33455
  if (transactionId) {
33102
- assert_assertTruthy(transactionId === this.currentTransactionId, 'Transaction already ended.');
33456
+ (0,dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33103
33457
  return fn(transactionId).then(() => Promise.resolve());
33104
33458
  }
33105
33459
  if (this.lockManager.canGetLock(RUN_IN_TRANSACTION_MUTEX)) {
@@ -33180,7 +33534,7 @@ class DataManager {
33180
33534
  /** Same as runInTransaction with the exception that the passed function runs synchronously. */
33181
33535
  async runInTransactionSync(fn, transactionId) {
33182
33536
  if (transactionId) {
33183
- assert_assertTruthy(transactionId === this.currentTransactionId, 'Transaction already ended.');
33537
+ (0,dist.assertTruthy)(transactionId === this.currentTransactionId, 'Transaction already ended.');
33184
33538
  fn(transactionId);
33185
33539
  return;
33186
33540
  }
@@ -33426,7 +33780,7 @@ class DataManager {
33426
33780
  async sendAllUnsentOutgoingMutations(promiseResolver) {
33427
33781
  const outgoingMutationsByIntegrationId = this.groupOutgoingMutationsByIntegrationId();
33428
33782
  try {
33429
- await promise_pool_dist.PromisePool["for"](outgoingMutationsByIntegrationId)
33783
+ await promise_pool_dist.PromisePool.for(outgoingMutationsByIntegrationId)
33430
33784
  .withConcurrency(outgoingMutationsByIntegrationId.length || 1)
33431
33785
  .handleError((e) => {
33432
33786
  throw e;
@@ -33492,7 +33846,7 @@ class DataManager {
33492
33846
  }
33493
33847
  removeOutgoingMutation(outgoingMutation) {
33494
33848
  const squidDocId = getSquidDocId(outgoingMutation.mutation.squidDocIdObj);
33495
- const outgoingMutationsForDoc = assert_truthy(this.pendingOutgoingMutations.get(squidDocId));
33849
+ const outgoingMutationsForDoc = (0,dist.truthy)(this.pendingOutgoingMutations.get(squidDocId));
33496
33850
  outgoingMutationsForDoc.splice(outgoingMutationsForDoc.indexOf(outgoingMutation), 1);
33497
33851
  if (!outgoingMutationsForDoc.length) {
33498
33852
  this.pendingOutgoingMutations.delete(squidDocId);
@@ -33507,7 +33861,7 @@ class DataManager {
33507
33861
  this.setExpiration(squidDocId, true);
33508
33862
  try {
33509
33863
  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);
33864
+ (0,dist.truthy)(results.length <= 1, 'Got more than one doc for the same id:' + squidDocId);
33511
33865
  /** The document does not exist anymore, so we can forget about it */
33512
33866
  if (!results.length) {
33513
33867
  this.forgetDocument(squidDocId);
@@ -33795,6 +34149,7 @@ class DocumentIdentityService {
33795
34149
  ;// CONCATENATED MODULE: ./src/document-reference.factory.ts
33796
34150
 
33797
34151
 
34152
+
33798
34153
  class DocumentReferenceFactory {
33799
34154
  constructor(documentIdentityService) {
33800
34155
  this.documentIdentityService = documentIdentityService;
@@ -33808,7 +34163,7 @@ class DocumentReferenceFactory {
33808
34163
  let reference = this.documents.get(squidDocId);
33809
34164
  if (reference)
33810
34165
  return reference;
33811
- reference = new DocumentReference(squidDocId, assert_truthy(this.dataManager, 'dataManager not found'), queryBuilderFactory);
34166
+ reference = new DocumentReference(squidDocId, (0,dist.truthy)(this.dataManager, 'dataManager not found'), queryBuilderFactory);
33812
34167
  const { integrationId, collectionName } = parseSquidDocId(squidDocId);
33813
34168
  this.documents.set(squidDocId, reference);
33814
34169
  const collectionKey = this.getCollectionKey(integrationId, collectionName);
@@ -33847,17 +34202,7 @@ class DocumentReferenceFactory {
33847
34202
  ;// CONCATENATED MODULE: ./src/document-store.ts
33848
34203
 
33849
34204
 
33850
- function groupAndSort(sortedDocs, sortFieldNames, sortOrders) {
33851
- const groups = Object.values(lodash_default().groupBy(sortedDocs, (doc) => {
33852
- return serialization_normalizeJsonAsString(sortFieldNames.map((fieldName) => getInPath(doc, fieldName)));
33853
- }));
33854
- const sortFieldIterators = sortFieldNames.map((fieldName) => {
33855
- return (group) => {
33856
- getInPath(group[0], fieldName);
33857
- };
33858
- });
33859
- return (0,lodash.orderBy)(groups, sortFieldIterators, sortOrders);
33860
- }
34205
+
33861
34206
  class DocumentStore {
33862
34207
  constructor() {
33863
34208
  this.squidDocIdToDoc = new Map();
@@ -33888,26 +34233,52 @@ class DocumentStore {
33888
34233
  return doc !== undefined;
33889
34234
  }
33890
34235
  getDocument(squidDocId) {
33891
- return assert_truthy(this.getDocumentOrUndefined(squidDocId));
34236
+ return (0,dist.truthy)(this.getDocumentOrUndefined(squidDocId));
33892
34237
  }
33893
34238
  getDocumentOrUndefined(squidDocId) {
33894
34239
  return this.squidDocIdToDoc.get(squidDocId);
33895
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
+ }
33896
34265
  sortAndLimitDocs(docIdSet, query) {
33897
34266
  if (docIdSet.size === 0) {
33898
34267
  return [];
33899
34268
  }
33900
- const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(nullish_isNotNullish);
34269
+ const docs = [...docIdSet].map((id) => this.squidDocIdToDoc.get(id)).filter(dist.isNonNullable);
33901
34270
  const { sortOrder, limitBy } = query;
33902
34271
  const sortFieldNames = sortOrder.map((s) => s.fieldName);
33903
34272
  const sortOrders = sortOrder.map((s) => (s.asc ? 'asc' : 'desc'));
33904
- const sortedDocs = (0,lodash.orderBy)(docs, sortFieldNames, sortOrders);
34273
+ const sortedDocs = docs.sort((a, b) => {
34274
+ return this.compareSquidDocs(a, b, sortFieldNames, sortOrders);
34275
+ });
33905
34276
  const mainLimit = query.limit < 0 ? 2000 : query.limit;
33906
34277
  if (!limitBy) {
33907
34278
  return sortedDocs.slice(0, mainLimit);
33908
34279
  }
33909
34280
  const { limit: internalLimit, fields, reverseSort } = limitBy;
33910
- const sortedGroups = groupAndSort(sortedDocs, fields, sortOrders);
34281
+ const sortedGroups = this.group(sortedDocs, fields);
33911
34282
  let limitedGroups;
33912
34283
  if (reverseSort) {
33913
34284
  limitedGroups = sortedGroups.map((group) => group.slice(-internalLimit));
@@ -47787,6 +48158,7 @@ var LimitUnderflowState;
47787
48158
 
47788
48159
 
47789
48160
 
48161
+
47790
48162
  // See limitUnderflowState below.
47791
48163
  // Exported only for tests
47792
48164
  const FETCH_BEYOND_LIMIT = 100;
@@ -47846,7 +48218,7 @@ class QuerySubscriptionManager {
47846
48218
  * Returns the query associated with the given clientRequestId. Throws error if the clientRequestId is not known.
47847
48219
  */
47848
48220
  getQuery(clientRequestId) {
47849
- return assert_truthy(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
48221
+ return (0,dist.truthy)(this.ongoingQueries.get(clientRequestId), 'UNKNOWN_QUERY').query;
47850
48222
  }
47851
48223
  /**
47852
48224
  * A query receives updates from two different sources:
@@ -47951,7 +48323,7 @@ class QuerySubscriptionManager {
47951
48323
  .some(Boolean);
47952
48324
  let rootOngoingQuery = ongoingQuery;
47953
48325
  while (!rootOngoingQuery.allObservables) {
47954
- rootOngoingQuery = assert_truthy(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
48326
+ rootOngoingQuery = (0,dist.truthy)(rootOngoingQuery === null || rootOngoingQuery === void 0 ? void 0 : rootOngoingQuery.supportingOngoingQuery);
47955
48327
  }
47956
48328
  if (observablesUpdated) {
47957
48329
  rootOngoingQueries.add(rootOngoingQuery);
@@ -47978,7 +48350,7 @@ class QuerySubscriptionManager {
47978
48350
  }
47979
48351
  for (const rootOngoingQuery of rootOngoingQueries) {
47980
48352
  const allObservables = this.collectAllObservables(rootOngoingQuery);
47981
- assert_truthy(rootOngoingQuery.allObservables).next(allObservables);
48353
+ (0,dist.truthy)(rootOngoingQuery.allObservables).next(allObservables);
47982
48354
  }
47983
48355
  }
47984
48356
  isValidParent(candidateParentQuery) {
@@ -48082,7 +48454,7 @@ class QuerySubscriptionManager {
48082
48454
  this.clientRequestIdToLocalDocuments.delete(clientRequestId);
48083
48455
  const orphanDocument = [];
48084
48456
  for (const doc of docs) {
48085
- const clientRequestIds = assert_truthy(this.localDocumentToClientRequestIds.get(doc));
48457
+ const clientRequestIds = (0,dist.truthy)(this.localDocumentToClientRequestIds.get(doc));
48086
48458
  clientRequestIds.delete(clientRequestId);
48087
48459
  if (!clientRequestIds.size) {
48088
48460
  this.localDocumentToClientRequestIds.delete(doc);
@@ -48146,7 +48518,7 @@ class QuerySubscriptionManager {
48146
48518
  done: false,
48147
48519
  isInFlight: false,
48148
48520
  forceFetchFromServer: false,
48149
- limitUnderflowState: LimitUnderflowState.UNKNOWN,
48521
+ limitUnderflowState: subscribe ? LimitUnderflowState.UNKNOWN : LimitUnderflowState.DISABLED,
48150
48522
  };
48151
48523
  this.registerQueryFinalizer(result);
48152
48524
  this.ongoingQueries.set(clientRequestId, result);
@@ -48218,7 +48590,7 @@ class QuerySubscriptionManager {
48218
48590
  const val = doc[joinCondition.right];
48219
48591
  if (!rightAsMap.has(val))
48220
48592
  rightAsMap.set(val, []);
48221
- assert_truthy(rightAsMap.get(val)).push(doc);
48593
+ (0,dist.truthy)(rightAsMap.get(val)).push(doc);
48222
48594
  });
48223
48595
  return left.flatMap((leftElement) => {
48224
48596
  var _a;
@@ -48238,7 +48610,7 @@ class QuerySubscriptionManager {
48238
48610
  const result = [];
48239
48611
  const queue = [rootOngoingQuery];
48240
48612
  while (queue.length) {
48241
- const current = assert_truthy(queue.shift());
48613
+ const current = (0,dist.truthy)(queue.shift());
48242
48614
  if (current.isEmptyForJoin)
48243
48615
  continue;
48244
48616
  result.push(current);
@@ -48248,7 +48620,7 @@ class QuerySubscriptionManager {
48248
48620
  }
48249
48621
  updateOngoingQueryWithNewDataFromSupportingQuery(supportingQueryResult, supportedOngoingQuery) {
48250
48622
  var _a;
48251
- const joinCondition = assert_truthy(supportedOngoingQuery.joinCondition);
48623
+ const joinCondition = (0,dist.truthy)(supportedOngoingQuery.joinCondition);
48252
48624
  const query = supportedOngoingQuery.query;
48253
48625
  if (!supportedOngoingQuery.activated) {
48254
48626
  const newConditions = supportingQueryResult.map((supportingDoc) => {
@@ -48271,7 +48643,7 @@ class QuerySubscriptionManager {
48271
48643
  return true;
48272
48644
  }
48273
48645
  else {
48274
- const supportedQueriesWithSameAlias = assert_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);
48275
48647
  const allNeededValues = new Set(supportingQueryResult.map((resultDoc) => { var _a; return (_a = resultDoc[joinCondition.left]) !== null && _a !== void 0 ? _a : null; }));
48276
48648
  for (const supportedQuery of supportedQueriesWithSameAlias) {
48277
48649
  supportedQuery.query.conditions
@@ -48296,7 +48668,7 @@ class QuerySubscriptionManager {
48296
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 });
48297
48669
  this.registerQueryFinalizer(ongoingQuery);
48298
48670
  this.ongoingQueries.set(ongoingQuery.clientRequestId, ongoingQuery);
48299
- assert_truthy(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
48671
+ (0,dist.truthy)(supportedOngoingQuery.supportingOngoingQuery).supportedQueries.push(ongoingQuery);
48300
48672
  this.sendQueryToServerOrUseParentQuery(ongoingQuery);
48301
48673
  return true;
48302
48674
  }
@@ -48313,7 +48685,7 @@ class QuerySubscriptionManager {
48313
48685
  async completeAllSupportedQueries(rootOngoingQuery) {
48314
48686
  const supportedQueries = [...(rootOngoingQuery.supportedQueries || [])];
48315
48687
  while (supportedQueries.length) {
48316
- const supportedQuery = assert_truthy(supportedQueries.shift());
48688
+ const supportedQuery = (0,dist.truthy)(supportedQueries.shift());
48317
48689
  supportedQueries.push(...(supportedQuery.supportedQueries || []));
48318
48690
  await (0,external_rxjs_namespaceObject.firstValueFrom)(supportedQuery.unsubscribeBlockerCount.pipe(filter((count) => count === 0)));
48319
48691
  supportedQuery.dataSubject.complete();
@@ -48430,7 +48802,7 @@ class QuerySubscriptionManager {
48430
48802
  */
48431
48803
  sendQueryToServer(ongoingQuery) {
48432
48804
  const oldLimit = ongoingQuery.query.limit;
48433
- const newLimit = oldLimit > 0 ? oldLimit + FETCH_BEYOND_LIMIT : oldLimit;
48805
+ const newLimit = oldLimit > 0 && ongoingQuery.subscribe ? oldLimit + FETCH_BEYOND_LIMIT : oldLimit;
48434
48806
  const queryRequest = {
48435
48807
  query: Object.assign(Object.assign({}, ongoingQuery.query), { limit: newLimit }),
48436
48808
  clientRequestId: ongoingQuery.clientRequestId,
@@ -48615,10 +48987,65 @@ class ClientQueryMappingManager {
48615
48987
  }
48616
48988
  }
48617
48989
 
48990
+ ;// CONCATENATED MODULE: ./src/rate-limiter.ts
48991
+
48992
+ class RateLimiter {
48993
+ /**
48994
+ * Creates a new rate limiter. It limits the number of requests using two parameters:
48995
+ * - capacity: the maximum number of tokens (actions) that can be stored at any given time
48996
+ * - seconds: the number of seconds it takes to refill the bucket to its maximum capacity
48997
+ *
48998
+ * We then can calculate the refillRatePerMs: the number of tokens (actions) that are added to the bucket every
48999
+ * millisecond
49000
+ *
49001
+ * Example:
49002
+ * Say we want to allow maximum 60 requests in a period of 5 seconds. We can create a rate limiter with:
49003
+ * - capacity: 60
49004
+ * - seconds: 5
49005
+ * And we will get refillRatePerMs: 60 / (5 * 1000) = 0.012
49006
+ *
49007
+ * To use:
49008
+ * const rateLimiter = new RateLimiter(60, 5);
49009
+ * await rateLimiter.consume();
49010
+ *
49011
+ * @param capacity
49012
+ * @param refillRatePerMs
49013
+ */
49014
+ constructor(capacity, seconds) {
49015
+ this.capacity = capacity;
49016
+ this.seconds = seconds;
49017
+ this.tokens = capacity;
49018
+ this.refillRatePerMs = capacity / (seconds * 1000);
49019
+ this.lastRefillTimestamp = Date.now();
49020
+ }
49021
+ async consume() {
49022
+ if (this.attemptConsume())
49023
+ return;
49024
+ 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)()));
49025
+ }
49026
+ attemptConsume() {
49027
+ this.refill();
49028
+ if (this.tokens >= 1) {
49029
+ this.tokens -= 1;
49030
+ return true;
49031
+ }
49032
+ return false;
49033
+ }
49034
+ refill() {
49035
+ const now = Date.now();
49036
+ const elapsedTime = now - this.lastRefillTimestamp;
49037
+ const tokensToAdd = elapsedTime * this.refillRatePerMs;
49038
+ this.tokens = Math.min(this.tokens + tokensToAdd, this.capacity);
49039
+ this.lastRefillTimestamp = now;
49040
+ }
49041
+ }
49042
+
48618
49043
  ;// CONCATENATED MODULE: ./src/rpc.manager.ts
48619
49044
 
48620
49045
 
48621
49046
 
49047
+
49048
+
48622
49049
  class RpcManager {
48623
49050
  constructor(region, appId, destructManager, headers = {}, authManager, clientIdService) {
48624
49051
  this.region = region;
@@ -48657,6 +49084,12 @@ class RpcManager {
48657
49084
  destructManager.onDestruct(async () => {
48658
49085
  await this.awaitAllSettled();
48659
49086
  });
49087
+ const rateLimiterMultiplier = apiKey ? 5 : 1;
49088
+ this.rateLimiters = {
49089
+ default: new RateLimiter(60 * rateLimiterMultiplier, 5),
49090
+ ai: new RateLimiter(20 * rateLimiterMultiplier, 5),
49091
+ secret: new RateLimiter(20 * rateLimiterMultiplier, 5),
49092
+ };
48660
49093
  }
48661
49094
  async awaitAllSettled() {
48662
49095
  await (0,external_rxjs_namespaceObject.firstValueFrom)(this.onGoingRpcCounter.pipe((0,external_rxjs_namespaceObject.filter)((value) => value === 0)));
@@ -48676,6 +49109,7 @@ class RpcManager {
48676
49109
  async post(path, message, files = []) {
48677
49110
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48678
49111
  try {
49112
+ await this.getRateLimiterBucket(path).consume();
48679
49113
  await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
48680
49114
  let headers = {};
48681
49115
  if (Object.keys(this.staticHeaders)) {
@@ -48735,6 +49169,15 @@ class RpcManager {
48735
49169
  }
48736
49170
  return (json || text);
48737
49171
  }
49172
+ getRateLimiterBucket(path) {
49173
+ if (path.startsWith('ai/assistant')) {
49174
+ return (0,dist.truthy)(this.rateLimiters['ai'], 'MISSING_RATE_LIMITER_AI');
49175
+ }
49176
+ if (path.startsWith('secret/')) {
49177
+ return (0,dist.truthy)(this.rateLimiters['secret'], 'MISSING_RATE_LIMITER_SECRETS');
49178
+ }
49179
+ return (0,dist.truthy)(this.rateLimiters['default'], 'MISSING_RATE_LIMITER_DEFAULT');
49180
+ }
48738
49181
  }
48739
49182
  class RpcError extends Error {
48740
49183
  constructor(statusCode, statusText, headers, url, message) {
@@ -48751,16 +49194,15 @@ class SecretClient {
48751
49194
  constructor(rpcManager) {
48752
49195
  this.rpcManager = rpcManager;
48753
49196
  }
48754
- get(key) {
49197
+ async get(key) {
48755
49198
  const request = { key };
48756
- return this.rpcManager.post('/secret/get', request);
49199
+ return (await this.rpcManager.post('/secret/get', request)) || undefined;
48757
49200
  }
48758
49201
  getAll() {
48759
49202
  return this.rpcManager.post('/secret/getAll', {});
48760
49203
  }
48761
49204
  upsert(key, value) {
48762
- const request = { entries: [{ key, value }] };
48763
- return this.rpcManager.post('/secret/upsert', request);
49205
+ return this.upsertMany([{ key, value }]).then((entries) => entries[0]);
48764
49206
  }
48765
49207
  upsertMany(entries) {
48766
49208
  const request = { entries };
@@ -48811,6 +49253,7 @@ const NOOP_FN = (fn) => {
48811
49253
 
48812
49254
 
48813
49255
 
49256
+
48814
49257
  class SocketManager {
48815
49258
  constructor(clientIdService, region, appId, messageNotificationWrapper = NOOP_FN, destructManager, authManager) {
48816
49259
  this.clientIdService = clientIdService;
@@ -48865,7 +49308,7 @@ class SocketManager {
48865
49308
  this.authManager.waitForReadyState().then(() => {
48866
49309
  (0,external_rxjs_namespaceObject.firstValueFrom)(this.connectionReady.pipe((0,external_rxjs_namespaceObject.filter)(Boolean))).then(() => {
48867
49310
  const authToken = this.authManager.getAuthToken();
48868
- assert_truthy(this.socket).send(serialization_serializeObj({ message, authToken }));
49311
+ (0,dist.truthy)(this.socket).send(serialization_serializeObj({ message, authToken }));
48869
49312
  });
48870
49313
  });
48871
49314
  }
@@ -48979,6 +49422,11 @@ class QuerySender {
48979
49422
  clearTimeout(this.pendingQueryBatchTimeout);
48980
49423
  this.pendingQueryBatchTimeout = undefined;
48981
49424
  }
49425
+ // A batch should not have more than 10 queries
49426
+ if (this.pendingQueryRequests.length >= 10) {
49427
+ void this.processQueryBatch();
49428
+ return responsePromise;
49429
+ }
48982
49430
  this.pendingQueryBatchTimeout = setTimeout(() => {
48983
49431
  this.safeToSendQueriesToServer.pipe(filter(Boolean), (0,external_rxjs_namespaceObject.take)(1)).subscribe(() => {
48984
49432
  this.processQueryBatch();
@@ -49048,6 +49496,7 @@ class QuerySender {
49048
49496
 
49049
49497
 
49050
49498
 
49499
+
49051
49500
 
49052
49501
 
49053
49502
  /**
@@ -49225,7 +49674,7 @@ class Squid {
49225
49674
  this.querySubscriptionManager.unsubscribe();
49226
49675
  await this.rpcManager.awaitAllSettled();
49227
49676
  };
49228
- assert_assertTruthy(options.appId, 'APP_ID_MUST_BE_PROVIDED');
49677
+ (0,dist.assertTruthy)(options.appId, 'APP_ID_MUST_BE_PROVIDED');
49229
49678
  const shouldAddDeveloperId = options.environmentId !== 'prod' && options.squidDeveloperId;
49230
49679
  const appId = appIdWithEnvironmentIdAndDevId(options.appId, options.environmentId, shouldAddDeveloperId ? options.squidDeveloperId : undefined);
49231
49680
  const httpHeaders = getApplicationHttpHeaders(options.region, appId);
@@ -49246,9 +49695,9 @@ class Squid {
49246
49695
  this.collectionReferenceFactory = new CollectionReferenceFactory(this.documentReferenceFactory, this.queryBuilderFactory, this.querySubscriptionManager);
49247
49696
  this.dataManager = new DataManager(this.documentStore, mutationSender, this.socketManager, this.querySubscriptionManager, this.queryBuilderFactory, this.lockManager, this.destructManager, this.documentIdentityService, this.querySender);
49248
49697
  this.documentReferenceFactory.setDataManager(this.dataManager);
49249
- this.backendFunctionManager = new BackendFunctionManager(this.clientIdService, this.rpcManager, this.socketManager);
49698
+ this.backendFunctionManager = new BackendFunctionManager(this.clientIdService, this.rpcManager);
49250
49699
  this.namedQueryManager = new NamedQueryManager(this.rpcManager, this.socketManager);
49251
- this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
49700
+ this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, options.apiServerUrlOverrideMapping);
49252
49701
  this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
49253
49702
  this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
49254
49703
  this.secretClient = new SecretClient(this.rpcManager);
@@ -49284,7 +49733,7 @@ class Squid {
49284
49733
  })();
49285
49734
  }
49286
49735
  validateNotDestructed() {
49287
- assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
49736
+ (0,dist.assertTruthy)(!this.destructManager.isDestructing, 'The client was already destructed.');
49288
49737
  }
49289
49738
  }
49290
49739
  Squid.squidInstancesMap = {};
@@ -49297,6 +49746,7 @@ Squid.squidInstancesMap = {};
49297
49746
 
49298
49747
 
49299
49748
 
49749
+
49300
49750
 
49301
49751
  })();
49302
49752