@squidcloud/client 1.0.151 → 1.0.153

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
@@ -7041,8 +7041,10 @@ function assertObject(value, objectAssertion, errorContextProvider = undefined,
7041
7041
  assertTruthy(!Array.isArray(value), () => errorWithContext(`is an array.`));
7042
7042
  const assertionEntries = Object.entries(objectAssertion);
7043
7043
  if (constraints.failOnUnknownFields) {
7044
+ const allowedUnknownFieldNames = constraints.allowedUnknownFieldNames || [];
7044
7045
  for (const objectFieldName in value) {
7045
- assertTruthy(assertionEntries.some(([assertionFieldName]) => objectFieldName === assertionFieldName), errorWithContext(`property can't be checked: ${objectFieldName}`));
7046
+ const skipUnknownFieldCheck = allowedUnknownFieldNames.includes(objectFieldName);
7047
+ assertTruthy(skipUnknownFieldCheck || assertionEntries.some(([assertionFieldName]) => objectFieldName === assertionFieldName), errorWithContext(`property can't be checked: ${objectFieldName}`));
7046
7048
  }
7047
7049
  }
7048
7050
  let $o;
@@ -7121,7 +7123,7 @@ exports.callValueAssertion = callValueAssertion;
7121
7123
  "use strict";
7122
7124
 
7123
7125
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7124
- exports.stringAssertion = exports.nullOr = exports.undefinedOr = exports.valueOr = exports.$a = exports.arrayAssertion = exports.objectAssertion = void 0;
7126
+ exports.stringAssertion = exports.nullOr = exports.undefinedOr = exports.valueOr = exports.$u = exports.$a = exports.arrayAssertion = exports.objectAssertion = void 0;
7125
7127
  const Assertion_1 = __webpack_require__(6676);
7126
7128
  const AssertionsLib_1 = __webpack_require__(4356);
7127
7129
  /** A shortcut to build new object type assertion. */
@@ -7159,6 +7161,16 @@ function $a(check, errorMessageProvider) {
7159
7161
  });
7160
7162
  }
7161
7163
  exports.$a = $a;
7164
+ /**
7165
+ * Creates a new value assertion using *check* function.
7166
+ * The assertion accepts the value as valid if 'check(value)' returns true or throws an error otherwise.
7167
+ *
7168
+ * Note: same as `$a` but forces processing of the check function argument as `unknown`.
7169
+ */
7170
+ function $u(check, errorMessageProvider) {
7171
+ return $a(check, errorMessageProvider);
7172
+ }
7173
+ exports.$u = $u;
7162
7174
  /**
7163
7175
  * Creates an assertion that makes comparison by reference with the *expectedValue* before calling *orAssertion*.
7164
7176
  * If comparison with the *expectedValue* succeeds, does not call the *orAssertion*.
@@ -7203,7 +7215,7 @@ exports.stringAssertion = stringAssertion;
7203
7215
  "use strict";
7204
7216
 
7205
7217
  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;
7218
+ exports.assertNonNullable = exports.assertDate = exports.assertEmail = exports.assertHexString = exports.assertUuid = exports.assertBoolean = exports.assertNumber = exports.assertString = exports.formatError = void 0;
7207
7219
  const Assertion_1 = __webpack_require__(6676);
7208
7220
  const ChecksLib_1 = __webpack_require__(9862);
7209
7221
  function formatError(contextProvider, message, value) {
@@ -7244,6 +7256,11 @@ const assertEmail = (value, context = undefined) => {
7244
7256
  (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isEmail)(value), () => formatError(context, 'Invalid email', value));
7245
7257
  };
7246
7258
  exports.assertEmail = assertEmail;
7259
+ /** Asserts that the `value` type is a `Date` object. */
7260
+ const assertDate = (value, context = undefined) => {
7261
+ (0, Assertion_1.assertTruthy)(value instanceof Date, () => formatError(context, 'Invalid Date', value));
7262
+ };
7263
+ exports.assertDate = assertDate;
7247
7264
  function assertNonNullable(value, context) {
7248
7265
  (0, Assertion_1.assertTruthy)((0, ChecksLib_1.isNonNullable)(value), () => formatError(context, `Value is ${value === undefined ? 'undefined' : 'null'}`, value));
7249
7266
  }
@@ -7258,25 +7275,30 @@ exports.assertNonNullable = assertNonNullable;
7258
7275
  "use strict";
7259
7276
 
7260
7277
  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*. */
7278
+ exports.isNonNullable = exports.isHexString = exports.isUuid = exports.isEmail = exports.checkArraysHasEqualElementsByComparator = exports.checkArraysHaveEqualElements = exports.checkArrayHasUniqueElements = exports.isDate = exports.isNumber = exports.isString = exports.isBoolean = void 0;
7279
+ /** Returns `true` if the value is `boolean`. */
7263
7280
  function isBoolean(value) {
7264
7281
  return typeof value === 'boolean';
7265
7282
  }
7266
7283
  exports.isBoolean = isBoolean;
7267
- /** Returns *true* if the value is *string*. */
7284
+ /** Returns `true` if the value is `string`. */
7268
7285
  function isString(value) {
7269
7286
  return typeof value === 'string';
7270
7287
  }
7271
7288
  exports.isString = isString;
7272
- /** Returns *true* if the value is *number*. */
7289
+ /** Returns `true` if the value is `number`. */
7273
7290
  function isNumber(value) {
7274
7291
  return typeof value === 'number';
7275
7292
  }
7276
7293
  exports.isNumber = isNumber;
7294
+ /** Returns `true` if the value is `Date` object. */
7295
+ function isDate(value) {
7296
+ return value instanceof Date;
7297
+ }
7298
+ exports.isDate = isDate;
7277
7299
  /**
7278
7300
  * Checks that array has only unique elements.
7279
- * Uses 'identity' function to perform checks.
7301
+ * Uses `identity` function to perform checks.
7280
7302
  */
7281
7303
  function checkArrayHasUniqueElements(array, identity) {
7282
7304
  if (array.length <= 1) {
@@ -7293,6 +7315,38 @@ function checkArrayHasUniqueElements(array, identity) {
7293
7315
  return true;
7294
7316
  }
7295
7317
  exports.checkArrayHasUniqueElements = checkArrayHasUniqueElements;
7318
+ /**
7319
+ * Checks if two arrays have equal elements.
7320
+ * Compares elements with by reference.
7321
+ * See `checkArraysHasEqualElementsByComparator` if you need to use a custom comparator.
7322
+ */
7323
+ function checkArraysHaveEqualElements(array1, array2) {
7324
+ return checkArraysHasEqualElementsByComparator(array1, array2, (e1, e2) => e1 === e2);
7325
+ }
7326
+ exports.checkArraysHaveEqualElements = checkArraysHaveEqualElements;
7327
+ /**
7328
+ * Checks that two arrays have equal elements.
7329
+ * Returns `true` if all elements and their indexes are equal or false otherwise.
7330
+ * Uses `comparator` to compare the elements.
7331
+ */
7332
+ function checkArraysHasEqualElementsByComparator(array1, array2, comparator) {
7333
+ if (array1 === array2) {
7334
+ return true;
7335
+ }
7336
+ if (!array1 || !array2) {
7337
+ return false;
7338
+ }
7339
+ if (array1.length !== array2.length) {
7340
+ return false;
7341
+ }
7342
+ for (let i = 0; i < array1.length; i++) {
7343
+ if (!comparator(array1[i], array2[i])) {
7344
+ return false;
7345
+ }
7346
+ }
7347
+ return true;
7348
+ }
7349
+ exports.checkArraysHasEqualElementsByComparator = checkArraysHasEqualElementsByComparator;
7296
7350
  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
7351
  // eslint-disable-next-line no-misleading-character-class
7298
7352
  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;
@@ -35514,7 +35568,13 @@ const AiChatbotChatRequestSchema = {
35514
35568
 
35515
35569
  ;// CONCATENATED MODULE: ../common/src/ai-chatbot.types.ts
35516
35570
  /** The supported AI model names. */
35517
- const AI_MODEL_NAMES = (/* unused pure expression or super */ null && (['gpt-3.5-turbo', 'gpt-4', 'claude-2', 'gpt-4-1106-preview']));
35571
+ const AI_MODEL_NAMES = (/* unused pure expression or super */ null && ([
35572
+ 'gpt-3.5-turbo',
35573
+ 'gpt-3.5-turbo-1106',
35574
+ 'gpt-4',
35575
+ 'claude-2',
35576
+ 'gpt-4-1106-preview',
35577
+ ]));
35518
35578
  /** @internal */
35519
35579
  const AiModelData = {
35520
35580
  'gpt-4': {
@@ -35523,6 +35583,9 @@ const AiModelData = {
35523
35583
  'gpt-3.5-turbo': {
35524
35584
  tokens: 4096,
35525
35585
  },
35586
+ 'gpt-3.5-turbo-1106': {
35587
+ tokens: 16385,
35588
+ },
35526
35589
  'claude-2': {
35527
35590
  tokens: 100000,
35528
35591
  },
@@ -36760,9 +36823,9 @@ function sortKeys(json) {
36760
36823
  return result;
36761
36824
  }
36762
36825
  function serialization_normalizeJsonAsString(json) {
36763
- return serialization_serializeObj(sortKeys(json));
36826
+ return serializeObj(sortKeys(json));
36764
36827
  }
36765
- function serialization_serializeObj(obj) {
36828
+ function serializeObj(obj) {
36766
36829
  if (obj === undefined)
36767
36830
  return null; // TODO: change method signature.
36768
36831
  const objWithReplacedDates = lodash.cloneDeepWith(obj, value => {
@@ -36781,7 +36844,7 @@ function deserializeObj(str) {
36781
36844
  function encodeValueForMapping(value) {
36782
36845
  if (value === undefined)
36783
36846
  throw new Error('INVALID_ENCODE_VALUE');
36784
- const serializedValue = serialization_serializeObj(value);
36847
+ const serializedValue = serializeObj(value);
36785
36848
  if (typeof Buffer !== 'undefined') {
36786
36849
  // Node.js
36787
36850
  return Buffer.from(serializedValue, 'utf8').toString('base64');
@@ -37380,6 +37443,7 @@ function replaceKeyInRecord(record, a, b) {
37380
37443
 
37381
37444
 
37382
37445
 
37446
+
37383
37447
  class Pagination {
37384
37448
  /** @internal */
37385
37449
  constructor(snapshotEmitter, options = {}) {
@@ -37410,6 +37474,7 @@ class Pagination {
37410
37474
  */
37411
37475
  this.navigatingToLastPage = false;
37412
37476
  this.lastElement = null;
37477
+ (0,dist.assertTruthy)(snapshotEmitter.getSortOrders().length > 0, 'Unable to paginate results. Please specify a sort order.');
37413
37478
  this.snapshotSubject.pipe((0,external_rxjs_.switchAll)()).subscribe(data => this.dataReceived(data));
37414
37479
  this.templateSnapshotEmitter = snapshotEmitter.clone();
37415
37480
  this.options = Object.assign({ pageSize: 100, subscribe: true }, options);
@@ -37645,7 +37710,6 @@ class Pagination {
37645
37710
 
37646
37711
 
37647
37712
 
37648
-
37649
37713
  /** @internal */
37650
37714
  const ExecuteFunctionSecureAnnotations = (/* unused pure expression or super */ null && ([
37651
37715
  'secureDistributedLock',
@@ -37702,7 +37766,7 @@ function transformResponse(functionResponse, executeFunctionAnnotationType) {
37702
37766
  'content-type': isStringOrNullBody ? 'text/plain' : 'application/json',
37703
37767
  'cache-control': 'no-cache',
37704
37768
  };
37705
- const body = isStringOrNullBody ? functionResponse || '' : serializeObj(functionResponse);
37769
+ const body = isStringOrNullBody ? functionResponse || '' : JSON.stringify(functionResponse);
37706
37770
  // noinspection UnnecessaryLocalVariableJS
37707
37771
  const webhookResponse = {
37708
37772
  headers,
@@ -37711,6 +37775,26 @@ function transformResponse(functionResponse, executeFunctionAnnotationType) {
37711
37775
  };
37712
37776
  return webhookResponse;
37713
37777
  }
37778
+ if (executeFunctionAnnotationType === 'openapi') {
37779
+ if (isOpenApiResponse(functionResponse)) {
37780
+ delete functionResponse['__isOpenApiResponse__'];
37781
+ return functionResponse;
37782
+ }
37783
+ functionResponse = functionResponse !== null && functionResponse !== void 0 ? functionResponse : null;
37784
+ const isStringOrNullBody = functionResponse === null || typeof functionResponse === 'string';
37785
+ const headers = {
37786
+ 'content-type': isStringOrNullBody ? 'text/plain' : 'application/json',
37787
+ 'cache-control': 'no-cache',
37788
+ };
37789
+ const body = isStringOrNullBody ? functionResponse || '' : JSON.stringify(functionResponse);
37790
+ // noinspection UnnecessaryLocalVariableJS
37791
+ const openApiResponse = {
37792
+ headers,
37793
+ body,
37794
+ statusCode: functionResponse === null ? 204 : 200,
37795
+ };
37796
+ return openApiResponse;
37797
+ }
37714
37798
  return functionResponse;
37715
37799
  }
37716
37800
  function convertToRunSecrets(appSecrets) {
@@ -37726,6 +37810,9 @@ function convertToRunSecrets(appSecrets) {
37726
37810
  function isWebhookResponse(response) {
37727
37811
  return response && response.__isWebhookResponse__;
37728
37812
  }
37813
+ function isOpenApiResponse(response) {
37814
+ return response && response.__isOpenApiResponse__;
37815
+ }
37729
37816
 
37730
37817
  ;// CONCATENATED MODULE: ../common/src/communication.types.ts
37731
37818
  /**
@@ -38830,6 +38917,8 @@ const kotlinControllers = [
38830
38917
  'quota',
38831
38918
  'named-query',
38832
38919
  'native-query',
38920
+ 'application-kotlin',
38921
+ 'openapi',
38833
38922
  ];
38834
38923
  function getApplicationUrl(regionPrefix, appId, path) {
38835
38924
  const baseUrl = 'https://squid.cloud';
@@ -39120,6 +39209,8 @@ function createWebSocketWrapper(url, opts = {}) {
39120
39209
 
39121
39210
 
39122
39211
 
39212
+
39213
+
39123
39214
 
39124
39215
 
39125
39216
 
@@ -40188,7 +40279,7 @@ class JoinQueryBuilder extends BaseQueryBuilder {
40188
40279
  return this;
40189
40280
  }
40190
40281
  extractData(data) {
40191
- return data[this.rootAlias].data;
40282
+ return data[this.rootAlias].dataRef;
40192
40283
  }
40193
40284
  serialize() {
40194
40285
  return {
@@ -40415,10 +40506,10 @@ class GroupedJoin {
40415
40506
  * value is the document/document reference
40416
40507
  */
40417
40508
  if (Object.keys(this.joinQueryBuilder.leftToRight).length > 1) {
40418
- return data[this.joinQueryBuilder.rootAlias].data;
40509
+ return data[this.joinQueryBuilder.rootAlias].dataRef;
40419
40510
  }
40420
40511
  else {
40421
- return data.data;
40512
+ return data.dataRef;
40422
40513
  }
40423
40514
  }
40424
40515
  serialize() {
@@ -40690,6 +40781,16 @@ class DocumentReference {
40690
40781
  * @throws Error if the document does not exist.
40691
40782
  */
40692
40783
  get data() {
40784
+ return lodash.cloneDeep(this.dataRef);
40785
+ }
40786
+ /**
40787
+ * Returns a read-only internal copy of the document data. This works similar to `this.data`, except it does not
40788
+ * perform a defensive copy. The caller may not modify this object, on penalty of unexpected behavior.
40789
+ *
40790
+ * @returns The document data.
40791
+ * @throws Error if the document does not exist.
40792
+ */
40793
+ get dataRef() {
40693
40794
  const getError = () => {
40694
40795
  const { collectionName, integrationId, docId } = parseSquidDocId(this.squidDocId);
40695
40796
  return `No data found for document reference: ${JSON.stringify({
@@ -40698,7 +40799,7 @@ class DocumentReference {
40698
40799
  integrationId,
40699
40800
  }, null, 2)}`;
40700
40801
  };
40701
- return (0,dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError());
40802
+ return (0,dist.truthy)(this.dataManager.getProperties(this.squidDocId), getError);
40702
40803
  }
40703
40804
  /**
40704
40805
  * Returns whether data has been populated for this document reference. Data
@@ -41164,7 +41265,7 @@ class QueryBuilder extends BaseQueryBuilder {
41164
41265
  else {
41165
41266
  for (const docAfter of data) {
41166
41267
  const squidDocId = docAfter.squidDocId;
41167
- const docAfterData = docAfter.data;
41268
+ const docAfterData = docAfter.dataRef;
41168
41269
  if (beforeDocSet.has(docAfterData)) {
41169
41270
  delete beforeDocMap[squidDocId];
41170
41271
  beforeDocSet.delete(docAfterData);
@@ -41187,7 +41288,7 @@ class QueryBuilder extends BaseQueryBuilder {
41187
41288
  beforeDocMap = {};
41188
41289
  beforeDocSet = new Set();
41189
41290
  for (const afterDoc of data) {
41190
- const afterDocData = afterDoc.data;
41291
+ const afterDocData = afterDoc.dataRef;
41191
41292
  beforeDocMap[afterDoc.squidDocId] = afterDocData;
41192
41293
  beforeDocSet.add(afterDocData);
41193
41294
  }
@@ -41217,6 +41318,9 @@ class QueryBuilder extends BaseQueryBuilder {
41217
41318
  return res;
41218
41319
  }
41219
41320
  addCompositeCondition(conditions) {
41321
+ if (!conditions.length) {
41322
+ return this;
41323
+ }
41220
41324
  this.query.conditions.push({ fields: conditions });
41221
41325
  return this;
41222
41326
  }
@@ -41237,7 +41341,7 @@ class QueryBuilder extends BaseQueryBuilder {
41237
41341
  };
41238
41342
  }
41239
41343
  extractData(data) {
41240
- return data.data;
41344
+ return data.dataRef;
41241
41345
  }
41242
41346
  paginate(options) {
41243
41347
  return new Pagination(this, options);
@@ -41790,7 +41894,7 @@ class BackendFunctionManager {
41790
41894
  executeFunctionAndSubscribe(functionName, ...params) {
41791
41895
  const request = {
41792
41896
  functionName,
41793
- paramsArrayStr: serialization_serializeObj(params),
41897
+ paramsArrayStr: serializeObj(params),
41794
41898
  };
41795
41899
  return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post('backend-function/execute', request)).pipe(map_map(response => {
41796
41900
  if (!response.success) {
@@ -57274,7 +57378,7 @@ class RpcManager {
57274
57378
  const filename = file instanceof Blob ? undefined : file.name;
57275
57379
  formData.append(filesFieldName, blob, filename);
57276
57380
  });
57277
- formData.append('body', serialization_serializeObj(message));
57381
+ formData.append('body', serializeObj(message));
57278
57382
  // Make the axios call
57279
57383
  axiosResponse = await external_axios_default().post(url, formData, {
57280
57384
  headers: Object.assign({}, headers),
@@ -57282,7 +57386,7 @@ class RpcManager {
57282
57386
  });
57283
57387
  }
57284
57388
  else {
57285
- axiosResponse = await external_axios_default().post(url, serialization_serializeObj(message), {
57389
+ axiosResponse = await external_axios_default().post(url, serializeObj(message), {
57286
57390
  headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
57287
57391
  responseType: 'text',
57288
57392
  });
@@ -57495,7 +57599,7 @@ class SocketManager {
57495
57599
  }
57496
57600
  try {
57497
57601
  (0,dist.assertTruthy)(this.socket, 'Socket is undefined in sendMessageAsync');
57498
- this.socket.send(serialization_serializeObj({ message, authToken }));
57602
+ this.socket.send(serializeObj({ message, authToken }));
57499
57603
  }
57500
57604
  catch (e) {
57501
57605
  if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
@@ -57514,7 +57618,7 @@ class SocketManager {
57514
57618
  if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected))
57515
57619
  return;
57516
57620
  const message = { type: 'kill' };
57517
- this.socket.send(serialization_serializeObj({ message }));
57621
+ this.socket.send(serializeObj({ message }));
57518
57622
  }
57519
57623
  connect() {
57520
57624
  var _a;
@@ -57650,6 +57754,14 @@ class QuerySender {
57650
57754
  }
57651
57755
  async processQueryBatch() {
57652
57756
  const queryRequestAndSubjects = this.pendingQueryRequests.splice(0);
57757
+ /**
57758
+ * There is a race condition where the batch timeout is triggered but the safeToSendQueriesToServer is not yet
57759
+ * true. In this case this function will be invoked again once the safeToSendQueriesToServer is true within the
57760
+ * setTimeout handler, and it may cause the queryRequestAndSubjects to be empty. In this case we do not want to send
57761
+ * an empty batch.
57762
+ */
57763
+ if (!queryRequestAndSubjects.length)
57764
+ return;
57653
57765
  const pendingQueryRequests = queryRequestAndSubjects.map(({ queryRequest }) => queryRequest);
57654
57766
  const responseSubjects = queryRequestAndSubjects.map(({ responseSubject }) => responseSubject);
57655
57767
  this.inflightQueriesCount.next(this.inflightQueriesCount.value + pendingQueryRequests.length);
@@ -1,5 +1,5 @@
1
1
  /** The supported AI model names. */
2
- export declare const AI_MODEL_NAMES: readonly ["gpt-3.5-turbo", "gpt-4", "claude-2", "gpt-4-1106-preview"];
2
+ export declare const AI_MODEL_NAMES: readonly ["gpt-3.5-turbo", "gpt-3.5-turbo-1106", "gpt-4", "claude-2", "gpt-4-1106-preview"];
3
3
  export type AiModelName = (typeof AI_MODEL_NAMES)[number];
4
4
  /** The possible sources for the LLM provider API key. */
5
5
  export type ApiKeySource = 'user' | 'system';
@@ -104,6 +104,11 @@ export interface CreateEnvironmentRequest {
104
104
  sourceAppId: AppId;
105
105
  environmentId: EnvironmentId;
106
106
  }
107
+ export interface UpdateApplicationCodeRequest {
108
+ appId: AppId;
109
+ openApiSpecStr?: string;
110
+ openApiControllersStr?: string;
111
+ }
107
112
  interface BaseUpsertIntegrationRequest<T extends IntegrationTypeWithConfig, C extends IntegrationConfig> {
108
113
  id: IntegrationId;
109
114
  type: T;
@@ -30,8 +30,8 @@ export interface TriggerRequest<T extends DocumentData = any> {
30
30
  export type SchedulerAction = () => void | Promise<void>;
31
31
  export type WebhookAction = ((request: WebhookRequest) => any) | (() => any);
32
32
  /** The context provided to a webhook function. */
33
- export interface WebhookRequest {
34
- body: any;
33
+ export interface WebhookRequest<T = any> {
34
+ body: T;
35
35
  rawBody?: string;
36
36
  queryParams: Record<string, string>;
37
37
  headers: Record<string, string>;
@@ -2,4 +2,8 @@
2
2
  export type DatabaseActionType = 'read' | 'write' | 'update' | 'insert' | 'delete' | 'all';
3
3
  /** The different types of actions that can be performed on an AI chatbot. */
4
4
  export type AiChatbotActionType = 'chat' | 'mutate' | 'all';
5
+ export interface LocalBackendData {
6
+ applicationBundleData: ApplicationBundleData;
7
+ openApiSpecStr?: string;
8
+ }
5
9
  export type AiFunctionParamType = 'string' | 'number' | 'boolean' | 'date';
@@ -14,6 +14,7 @@ export * from './communication.types';
14
14
  export * from './context.types';
15
15
  export * from './distributed-lock.context';
16
16
  export * from './document.types';
17
+ export * from './openapi.types';
17
18
  export * from './graphql.context';
18
19
  export * from './graphql.types';
19
20
  export * from './http-status.enum';
@@ -49,6 +50,7 @@ export * from './utils/transforms';
49
50
  export * from './utils/url';
50
51
  export * from './utils/validation';
51
52
  export * from './webhook-response';
53
+ export * from './openapi-response';
52
54
  export * from './heartbeat.types';
53
55
  export * from './utils/global.utils';
54
56
  export * from './websocket.impl';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -11,6 +11,8 @@ export interface ExecuteAiQueryResponse {
11
11
  answer: string;
12
12
  explanation?: string;
13
13
  executedQuery?: string;
14
+ queryMarkdownType?: string;
15
+ success: boolean;
14
16
  }
15
17
  /**
16
18
  * AiClient class serves as a facade for interacting with different AI services.
@@ -24,6 +24,14 @@ export declare class DocumentReference<T extends DocumentData = any> {
24
24
  * @throws Error if the document does not exist.
25
25
  */
26
26
  get data(): T;
27
+ /**
28
+ * Returns a read-only internal copy of the document data. This works similar to `this.data`, except it does not
29
+ * perform a defensive copy. The caller may not modify this object, on penalty of unexpected behavior.
30
+ *
31
+ * @returns The document data.
32
+ * @throws Error if the document does not exist.
33
+ */
34
+ get dataRef(): T;
27
35
  /**
28
36
  * Returns whether data has been populated for this document reference. Data
29
37
  * will not present if a document has not been queried, does not exist, or
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.151",
3
+ "version": "1.0.153",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "license": "ISC",
34
34
  "dependencies": {
35
35
  "@apollo/client": "^3.7.4",
36
- "@squidcloud/common": "1.0.151",
36
+ "@squidcloud/common": "1.0.153",
37
37
  "@supercharge/promise-pool": "^2.3.2",
38
38
  "axios": "^1.6.2",
39
39
  "cross-fetch": "^3.1.5",