@squidcloud/client 1.0.176 → 1.0.178

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
@@ -28880,13 +28880,11 @@ const AI_MODEL_NAMES = [
28880
28880
  class ApiCallContext {
28881
28881
  /** @internal */
28882
28882
  constructor(prototype) {
28883
+ this.integrationId = prototype.integrationId;
28883
28884
  this.endpointId = prototype.endpointId;
28884
28885
  this.url = prototype.url;
28885
28886
  this.method = prototype.method;
28886
- this.headers = prototype.headers;
28887
28887
  this.body = prototype.body;
28888
- this.queryParams = prototype.queryParams;
28889
- this.pathParams = prototype.pathParams;
28890
28888
  this.options = prototype.options;
28891
28889
  }
28892
28890
  }
@@ -29285,46 +29283,6 @@ var IntegrationSchemaType;
29285
29283
  // EXTERNAL MODULE: ../node_modules/lodash/lodash.js
29286
29284
  var lodash = __webpack_require__(8784);
29287
29285
  var lodash_default = /*#__PURE__*/__webpack_require__.n(lodash);
29288
- ;// CONCATENATED MODULE: ../internal-common/src/public-types/mutation.public-context.ts
29289
-
29290
- /** The mutation context that will be provided to the security function. */
29291
- class MutationContext {
29292
- /**
29293
- * @internal
29294
- */
29295
- constructor(mutation, beforeAndAfterDocs, serverTimeStamp) {
29296
- this.mutation = mutation;
29297
- this.beforeAndAfterDocs = beforeAndAfterDocs;
29298
- this.serverTimeStamp = serverTimeStamp;
29299
- }
29300
- getMutationType() {
29301
- return this.mutation.type;
29302
- }
29303
- get before() {
29304
- return this.beforeAndAfterDocs.before;
29305
- }
29306
- get after() {
29307
- return this.beforeAndAfterDocs.after;
29308
- }
29309
- /** Returns true if the mutation affects the provided path. */
29310
- affectsPath(path) {
29311
- const before = this.before ? lodash.get(this.before, path) : undefined;
29312
- const after = this.after ? lodash.get(this.after, path) : undefined;
29313
- return !lodash.isEqual(before, after);
29314
- }
29315
- }
29316
-
29317
- ;// CONCATENATED MODULE: ../internal-common/src/public-types/native-query.public-context.ts
29318
- /** The context provided to the secure native query function. */
29319
- class NativeQueryContext {
29320
- /** @internal */
29321
- constructor(query, params, clientId) {
29322
- this.query = query;
29323
- this.params = params;
29324
- this.clientId = clientId;
29325
- }
29326
- }
29327
-
29328
29286
  // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
29329
29287
  var dist = __webpack_require__(8975);
29330
29288
  ;// CONCATENATED MODULE: ../internal-common/src/utils/object.ts
@@ -29347,7 +29305,10 @@ function getInPath(obj, path, delimiter = '.') {
29347
29305
  function isJsObject(obj) {
29348
29306
  if (typeof obj !== 'object')
29349
29307
  return false;
29350
- return Reflect.getPrototypeOf(obj) === Object.prototype;
29308
+ return obj !== null && Reflect.getPrototypeOf(obj) === Object.prototype;
29309
+ }
29310
+ function isDateObject(value) {
29311
+ return Object.prototype.toString.call(value) === '[object Date]';
29351
29312
  }
29352
29313
  function setInPath(obj, path, value, delimiter = '.') {
29353
29314
  var _a;
@@ -29395,9 +29356,112 @@ function replaceKeyInRecord(record, a, b) {
29395
29356
  delete record[a];
29396
29357
  }
29397
29358
  }
29359
+ function isNil(obj) {
29360
+ return obj === undefined || obj === null;
29361
+ }
29362
+ function isEqual(a, b) {
29363
+ if (a === b)
29364
+ return true;
29365
+ if (a === null || b === null)
29366
+ return false;
29367
+ const type = typeof a;
29368
+ if (type !== typeof b)
29369
+ return false;
29370
+ if (type !== 'object')
29371
+ return a === b;
29372
+ if (a instanceof Date && b instanceof Date) {
29373
+ return a.getTime() === b.getTime();
29374
+ }
29375
+ const keysA = Object.keys(a);
29376
+ const keysB = Object.keys(b);
29377
+ if (keysA.length !== keysB.length)
29378
+ return false;
29379
+ for (const key of keysA) {
29380
+ if (!keysB.includes(key) || !isEqual(a[key], b[key]))
29381
+ return false;
29382
+ }
29383
+ return true;
29384
+ }
29385
+ function isEmpty(a) {
29386
+ if (a === null || a === undefined) {
29387
+ return true;
29388
+ }
29389
+ if (typeof a === 'function') {
29390
+ return Object.keys(a).length === 0;
29391
+ }
29392
+ if (ArrayBuffer.isView(a) && !(a instanceof DataView)) {
29393
+ return a.byteLength === 0;
29394
+ }
29395
+ if (typeof a !== 'object' && !Array.isArray(a) && typeof a !== 'string') {
29396
+ return true;
29397
+ }
29398
+ if (Array.isArray(a) || typeof a === 'string' || (typeof a === 'object' && 'length' in a)) {
29399
+ return a.length === 0;
29400
+ }
29401
+ if (a instanceof Map || a instanceof Set) {
29402
+ return a.size === 0;
29403
+ }
29404
+ if (typeof a === 'object' && a.constructor === Object) {
29405
+ return Object.keys(a).length === 0;
29406
+ }
29407
+ return false;
29408
+ }
29409
+ function omit(object, ...paths) {
29410
+ if (object === null || object === undefined) {
29411
+ return {};
29412
+ }
29413
+ const result = {};
29414
+ const omitKeys = new Set(paths);
29415
+ Object.keys(object).forEach(key => {
29416
+ if (!omitKeys.has(key)) {
29417
+ result[key] = object[key];
29418
+ }
29419
+ });
29420
+ return result;
29421
+ }
29398
29422
 
29399
- ;// CONCATENATED MODULE: ../internal-common/src/public-types/pagination.public-types.ts
29423
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/mutation.public-context.ts
29424
+
29425
+
29426
+ /** The mutation context that will be provided to the security function. */
29427
+ class MutationContext {
29428
+ /**
29429
+ * @internal
29430
+ */
29431
+ constructor(mutation, beforeAndAfterDocs, serverTimeStamp) {
29432
+ this.mutation = mutation;
29433
+ this.beforeAndAfterDocs = beforeAndAfterDocs;
29434
+ this.serverTimeStamp = serverTimeStamp;
29435
+ }
29436
+ getMutationType() {
29437
+ return this.mutation.type;
29438
+ }
29439
+ get before() {
29440
+ return this.beforeAndAfterDocs.before;
29441
+ }
29442
+ get after() {
29443
+ return this.beforeAndAfterDocs.after;
29444
+ }
29445
+ /** Returns true if the mutation affects the provided path. */
29446
+ affectsPath(path) {
29447
+ const before = this.before ? lodash.get(this.before, path) : undefined;
29448
+ const after = this.after ? lodash.get(this.after, path) : undefined;
29449
+ return !isEqual(before, after);
29450
+ }
29451
+ }
29400
29452
 
29453
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/native-query.public-context.ts
29454
+ /** The context provided to the secure native query function. */
29455
+ class NativeQueryContext {
29456
+ /** @internal */
29457
+ constructor(query, params, clientId) {
29458
+ this.query = query;
29459
+ this.params = params;
29460
+ this.clientId = clientId;
29461
+ }
29462
+ }
29463
+
29464
+ ;// CONCATENATED MODULE: ../internal-common/src/public-types/pagination.public-types.ts
29401
29465
 
29402
29466
 
29403
29467
 
@@ -29446,10 +29510,10 @@ class Pagination {
29446
29510
  this.snapshotSubject.next(firstPageSnapshot);
29447
29511
  }
29448
29512
  static compareValues(a, b) {
29449
- if (lodash_default().isNil(a)) {
29450
- return lodash_default().isNil(b) ? 0 : -1;
29513
+ if (isNil(a)) {
29514
+ return isNil(b) ? 0 : -1;
29451
29515
  }
29452
- if (lodash_default().isNil(b)) {
29516
+ if (isNil(b)) {
29453
29517
  return 1;
29454
29518
  }
29455
29519
  if (a > b) {
@@ -29463,7 +29527,7 @@ class Pagination {
29463
29527
  }
29464
29528
  }
29465
29529
  compare(doc1, doc2) {
29466
- if (lodash_default().isNil(doc2)) {
29530
+ if (isNil(doc2)) {
29467
29531
  return 1;
29468
29532
  }
29469
29533
  for (const so of this.templateSnapshotEmitter.getSortOrders()) {
@@ -29670,6 +29734,7 @@ const ALL_OPERATORS = [
29670
29734
 
29671
29735
  ;// CONCATENATED MODULE: ../internal-common/src/utils/serialization.ts
29672
29736
 
29737
+
29673
29738
  function sortKeys(json) {
29674
29739
  if (Array.isArray(json)) {
29675
29740
  return json.map(o => sortKeys(o));
@@ -29691,16 +29756,19 @@ function serializeObj(obj) {
29691
29756
  if (obj === undefined)
29692
29757
  return null; // TODO: change method signature.
29693
29758
  const objWithReplacedDates = lodash.cloneDeepWith(obj, value => {
29694
- return lodash.isDate(value) ? { $date: value.toISOString() } : undefined;
29759
+ return isDateObject(value) ? { $date: value.toISOString() } : undefined;
29695
29760
  });
29696
29761
  return JSON.stringify(objWithReplacedDates);
29697
29762
  }
29698
29763
  function deserializeObj(str) {
29699
29764
  const deserializedObj = JSON.parse(str);
29700
29765
  return lodash.cloneDeepWith(deserializedObj, value => {
29701
- return lodash.isObject(value) && lodash.has(value, '$date') && Object.keys(value).length === 1
29702
- ? new Date(value['$date'])
29703
- : undefined;
29766
+ if (value === null || typeof value !== 'object') {
29767
+ return undefined;
29768
+ }
29769
+ const record = value;
29770
+ const date = record['$date'];
29771
+ return date && Object.keys(record).length === 1 ? new Date(date) : undefined;
29704
29772
  });
29705
29773
  }
29706
29774
  function encodeValueForMapping(value) {
@@ -29772,38 +29840,38 @@ function compareOperator(conditionValue, valueInDocument, operator) {
29772
29840
  conditionValue = conditionValue instanceof Date ? conditionValue.getTime() : conditionValue !== null && conditionValue !== void 0 ? conditionValue : null;
29773
29841
  valueInDocument = valueInDocument instanceof Date ? valueInDocument.getTime() : valueInDocument !== null && valueInDocument !== void 0 ? valueInDocument : null;
29774
29842
  if (operator === '==') {
29775
- return lodash_default().isEqual(conditionValue, valueInDocument);
29843
+ return isEqual(conditionValue, valueInDocument);
29776
29844
  }
29777
29845
  if (operator === '!=') {
29778
- return !lodash_default().isEqual(conditionValue, valueInDocument);
29846
+ return !isEqual(conditionValue, valueInDocument);
29779
29847
  }
29780
29848
  // Nulls can only be compared for (in)equality, not other operators.
29781
29849
  switch (operator) {
29782
29850
  case '<':
29783
- if (lodash_default().isNil(conditionValue))
29851
+ if (isNil(conditionValue))
29784
29852
  return false;
29785
- if (lodash_default().isNil(valueInDocument))
29853
+ if (isNil(valueInDocument))
29786
29854
  return true;
29787
29855
  return valueInDocument < conditionValue;
29788
29856
  case '<=':
29789
- if (lodash_default().isNil(valueInDocument)) {
29857
+ if (isNil(valueInDocument)) {
29790
29858
  return true;
29791
29859
  }
29792
- if (lodash_default().isNil(conditionValue)) {
29860
+ if (isNil(conditionValue)) {
29793
29861
  return false;
29794
29862
  }
29795
29863
  return valueInDocument <= conditionValue;
29796
29864
  case '>':
29797
- if (lodash_default().isNil(valueInDocument))
29865
+ if (isNil(valueInDocument))
29798
29866
  return false;
29799
- if (lodash_default().isNil(conditionValue))
29867
+ if (isNil(conditionValue))
29800
29868
  return true;
29801
29869
  return valueInDocument > conditionValue;
29802
29870
  case '>=':
29803
- if (lodash_default().isNil(conditionValue)) {
29871
+ if (isNil(conditionValue)) {
29804
29872
  return true;
29805
29873
  }
29806
- if (lodash_default().isNil(valueInDocument)) {
29874
+ if (isNil(valueInDocument)) {
29807
29875
  return false;
29808
29876
  }
29809
29877
  return valueInDocument >= conditionValue;
@@ -29935,7 +30003,7 @@ class QueryContext {
29935
30003
  sortedBy(sorts) {
29936
30004
  const mismatch = sorts.find((fieldSort, index) => {
29937
30005
  var _a;
29938
- return !(0,lodash.isEqual)(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
30006
+ return !isEqual(this.query.sortOrder[index], Object.assign(Object.assign({}, fieldSort), { asc: (_a = fieldSort.asc) !== null && _a !== void 0 ? _a : true }));
29939
30007
  });
29940
30008
  return !mismatch;
29941
30009
  }
@@ -30080,7 +30148,7 @@ class QueryContext {
30080
30148
  const { operator, value } = this.parseConditions([testCondition])[0];
30081
30149
  const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
30082
30150
  const sortedValue = Array.isArray(value) ? value.sort() : value;
30083
- return operator === queryOperator && (0,lodash.isEqual)(sortedValue, sortedQueryValue);
30151
+ return operator === queryOperator && isEqual(sortedValue, sortedQueryValue);
30084
30152
  }
30085
30153
  parseConditions(conditions) {
30086
30154
  const parsedConditions = [];
@@ -30168,6 +30236,7 @@ var ClientConnectionState;
30168
30236
 
30169
30237
 
30170
30238
 
30239
+
30171
30240
 
30172
30241
 
30173
30242
  ;// CONCATENATED MODULE: ../internal-common/src/types/document.types.ts
@@ -30751,8 +30820,7 @@ class MergedQueryBuilder {
30751
30820
  for (const { fieldName, asc } of sort) {
30752
30821
  const aVal = getInPath(this.extractData(a), fieldName);
30753
30822
  const bVal = getInPath(this.extractData(b), fieldName);
30754
- const isEqual = compareOperator(aVal, bVal, '==');
30755
- if (isEqual) {
30823
+ if (compareOperator(aVal, bVal, '==')) {
30756
30824
  continue;
30757
30825
  }
30758
30826
  if (compareOperator(bVal, aVal, '<')) {
@@ -33600,7 +33668,7 @@ var ApolloError = /** @class */ (function (_super) {
33600
33668
  //# sourceMappingURL=index.js.map
33601
33669
  ;// CONCATENATED MODULE: ../node_modules/@apollo/client/utilities/common/arrays.js
33602
33670
  // A version of Array.isArray that works better with readonly arrays.
33603
- var arrays_isArray = Array.isArray;
33671
+ var isArray = Array.isArray;
33604
33672
  function isNonEmptyArray(value) {
33605
33673
  return Array.isArray(value) && value.length > 0;
33606
33674
  }
@@ -34914,15 +34982,15 @@ var TYPENAME_FIELD = {
34914
34982
  value: "__typename",
34915
34983
  },
34916
34984
  };
34917
- function isEmpty(op, fragmentMap) {
34985
+ function transform_isEmpty(op, fragmentMap) {
34918
34986
  return (!op ||
34919
34987
  op.selectionSet.selections.every(function (selection) {
34920
34988
  return selection.kind === kinds_Kind.FRAGMENT_SPREAD &&
34921
- isEmpty(fragmentMap[selection.name.value], fragmentMap);
34989
+ transform_isEmpty(fragmentMap[selection.name.value], fragmentMap);
34922
34990
  }));
34923
34991
  }
34924
34992
  function nullIfDocIsEmpty(doc) {
34925
- return (isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))) ?
34993
+ return (transform_isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))) ?
34926
34994
  null
34927
34995
  : doc;
34928
34996
  }
@@ -34979,7 +35047,7 @@ function removeDirectivesFromDocument(directives, doc) {
34979
35047
  var getInUseByFragmentName = makeInUseGetterFunction("");
34980
35048
  var getInUse = function (ancestors) {
34981
35049
  for (var p = 0, ancestor = void 0; p < ancestors.length && (ancestor = ancestors[p]); ++p) {
34982
- if (arrays_isArray(ancestor))
35050
+ if (isArray(ancestor))
34983
35051
  continue;
34984
35052
  if (ancestor.kind === kinds_Kind.OPERATION_DEFINITION) {
34985
35053
  // If an operation is anonymous, we use the empty string as its key.
@@ -35843,7 +35911,7 @@ function isObjRef(value) {
35843
35911
 
35844
35912
  function shallowCopy(value) {
35845
35913
  if (isNonNullObject(value)) {
35846
- return arrays_isArray(value) ?
35914
+ return isArray(value) ?
35847
35915
  value.slice(0)
35848
35916
  : tslib_es6_assign({ __proto__: Object.getPrototypeOf(value) }, value);
35849
35917
  }
@@ -41037,7 +41105,7 @@ function fieldNameFromStoreName(storeFieldName) {
41037
41105
  }
41038
41106
  function selectionSetMatchesResult(selectionSet, result, variables) {
41039
41107
  if (isNonNullObject(result)) {
41040
- return arrays_isArray(result) ?
41108
+ return isArray(result) ?
41041
41109
  result.every(function (item) {
41042
41110
  return selectionSetMatchesResult(selectionSet, item, variables);
41043
41111
  })
@@ -41059,7 +41127,7 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
41059
41127
  return false;
41060
41128
  }
41061
41129
  function storeValueIsStoreObject(value) {
41062
- return isNonNullObject(value) && !isReference(value) && !arrays_isArray(value);
41130
+ return isNonNullObject(value) && !isReference(value) && !isArray(value);
41063
41131
  }
41064
41132
  function makeProcessedFieldsMerger() {
41065
41133
  return new DeepMerger();
@@ -41937,7 +42005,7 @@ var StoreReader = /** @class */ (function () {
41937
42005
  _a));
41938
42006
  }
41939
42007
  }
41940
- else if (arrays_isArray(fieldValue)) {
42008
+ else if (isArray(fieldValue)) {
41941
42009
  fieldValue = handleMissing(_this.executeSubSelectedArray({
41942
42010
  field: selection,
41943
42011
  array: fieldValue,
@@ -42015,7 +42083,7 @@ var StoreReader = /** @class */ (function () {
42015
42083
  return null;
42016
42084
  }
42017
42085
  // This is a nested array, recurse
42018
- if (arrays_isArray(item)) {
42086
+ if (isArray(item)) {
42019
42087
  return handleMissing(_this.executeSubSelectedArray({
42020
42088
  field: field,
42021
42089
  array: item,
@@ -42215,13 +42283,13 @@ function getSpecifierPaths(spec) {
42215
42283
  var paths_1 = (info.paths = []);
42216
42284
  var currentPath_1 = [];
42217
42285
  spec.forEach(function (s, i) {
42218
- if (arrays_isArray(s)) {
42286
+ if (isArray(s)) {
42219
42287
  getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
42220
42288
  currentPath_1.length = 0;
42221
42289
  }
42222
42290
  else {
42223
42291
  currentPath_1.push(s);
42224
- if (!arrays_isArray(spec[i + 1])) {
42292
+ if (!isArray(spec[i + 1])) {
42225
42293
  paths_1.push(currentPath_1.slice(0));
42226
42294
  currentPath_1.length = 0;
42227
42295
  }
@@ -42247,7 +42315,7 @@ function extractKeyPath(object, path, extract) {
42247
42315
  // possibly unknown) is the honest answer.
42248
42316
  extract = extract || extractKey;
42249
42317
  return normalize(path.reduce(function reducer(obj, key) {
42250
- return arrays_isArray(obj) ?
42318
+ return isArray(obj) ?
42251
42319
  obj.map(function (child) { return reducer(child, key); })
42252
42320
  : obj && extract(obj, key);
42253
42321
  }, object));
@@ -42257,7 +42325,7 @@ function normalize(value) {
42257
42325
  // key fields are scalar, but just in case we get an object or an array, we
42258
42326
  // need to do some normalization of the order of (nested) keys.
42259
42327
  if (isNonNullObject(value)) {
42260
- if (arrays_isArray(value)) {
42328
+ if (isArray(value)) {
42261
42329
  return value.map(normalize);
42262
42330
  }
42263
42331
  return collectSpecifierPaths(Object.keys(value).sort(), function (path) {
@@ -42352,7 +42420,7 @@ var Policies = /** @class */ (function () {
42352
42420
  var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
42353
42421
  while (keyFn) {
42354
42422
  var specifierOrId = keyFn(tslib_es6_assign(tslib_es6_assign({}, object), storeObject), context);
42355
- if (arrays_isArray(specifierOrId)) {
42423
+ if (isArray(specifierOrId)) {
42356
42424
  keyFn = keyFieldsFnFromSpecifier(specifierOrId);
42357
42425
  }
42358
42426
  else {
@@ -42418,7 +42486,7 @@ var Policies = /** @class */ (function () {
42418
42486
  keyFields === false ? nullKeyFieldsFn
42419
42487
  // Pass an array of strings to use those fields to compute a
42420
42488
  // composite ID for objects of this typename.
42421
- : arrays_isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields)
42489
+ : isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields)
42422
42490
  // Pass a function to take full control over identification.
42423
42491
  : typeof keyFields === "function" ? keyFields
42424
42492
  // Leave existing.keyFn unchanged if above cases fail.
@@ -42438,7 +42506,7 @@ var Policies = /** @class */ (function () {
42438
42506
  keyArgs === false ? simpleKeyArgsFn
42439
42507
  // Pass an array of strings to use named arguments to
42440
42508
  // compute a composite identity for the field.
42441
- : arrays_isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs)
42509
+ : isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs)
42442
42510
  // Pass a function to take full control over field identity.
42443
42511
  : typeof keyArgs === "function" ? keyArgs
42444
42512
  // Leave existing.keyFn unchanged if above cases fail.
@@ -42673,7 +42741,7 @@ var Policies = /** @class */ (function () {
42673
42741
  var args = argsFromFieldSpecifier(fieldSpec);
42674
42742
  while (keyFn) {
42675
42743
  var specifierOrString = keyFn(args, context);
42676
- if (arrays_isArray(specifierOrString)) {
42744
+ if (isArray(specifierOrString)) {
42677
42745
  keyFn = keyArgsFnFromSpecifier(specifierOrString);
42678
42746
  }
42679
42747
  else {
@@ -42836,7 +42904,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
42836
42904
  }
42837
42905
  function makeMergeObjectsFunction(store) {
42838
42906
  return function mergeObjects(existing, incoming) {
42839
- if (arrays_isArray(existing) || arrays_isArray(incoming)) {
42907
+ if (isArray(existing) || isArray(incoming)) {
42840
42908
  throw newInvariantError(8);
42841
42909
  }
42842
42910
  // These dynamic checks are necessary because the parameters of a
@@ -43152,7 +43220,7 @@ var StoreWriter = /** @class */ (function () {
43152
43220
  // it's cheaper to store the scalar values directly in the cache.
43153
43221
  return globalThis.__DEV__ !== false ? cloneDeep(value) : value;
43154
43222
  }
43155
- if (arrays_isArray(value)) {
43223
+ if (isArray(value)) {
43156
43224
  return value.map(function (item, i) {
43157
43225
  var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
43158
43226
  maybeRecycleChildMergeTree(mergeTree, i);
@@ -43244,7 +43312,7 @@ var StoreWriter = /** @class */ (function () {
43244
43312
  // Items in the same position in different arrays are not
43245
43313
  // necessarily related to each other, so when incoming is an array
43246
43314
  // we process its elements as if there was no existing data.
43247
- (!arrays_isArray(incoming) &&
43315
+ (!isArray(incoming) &&
43248
43316
  // Likewise, existing must be either a Reference or a StoreObject
43249
43317
  // in order for its fields to be safe to merge with the fields of
43250
43318
  // the incoming object.
@@ -43269,7 +43337,7 @@ var StoreWriter = /** @class */ (function () {
43269
43337
  // to preserve the type of numeric keys.
43270
43338
  var changedFields_1;
43271
43339
  var getValue_1 = function (from, name) {
43272
- return (arrays_isArray(from) ?
43340
+ return (isArray(from) ?
43273
43341
  typeof name === "number" ?
43274
43342
  from[name]
43275
43343
  : void 0
@@ -43295,7 +43363,7 @@ var StoreWriter = /** @class */ (function () {
43295
43363
  });
43296
43364
  if (changedFields_1) {
43297
43365
  // Shallow clone i so we can add changed fields to it.
43298
- incoming = (arrays_isArray(i_1) ? i_1.slice(0) : tslib_es6_assign({}, i_1));
43366
+ incoming = (isArray(i_1) ? i_1.slice(0) : tslib_es6_assign({}, i_1));
43299
43367
  changedFields_1.forEach(function (value, name) {
43300
43368
  incoming[name] = value;
43301
43369
  });
@@ -43390,7 +43458,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
43390
43458
  var childTypenames = [];
43391
43459
  // Arrays do not have __typename fields, and always need a custom merge
43392
43460
  // function, even if their elements are normalized entities.
43393
- if (!arrays_isArray(existing) && !arrays_isArray(incoming)) {
43461
+ if (!isArray(existing) && !isArray(incoming)) {
43394
43462
  [existing, incoming].forEach(function (child) {
43395
43463
  var typename = store.getFieldValue(child, "__typename");
43396
43464
  if (typeof typename === "string" && !childTypenames.includes(typename)) {
@@ -47544,7 +47612,7 @@ class QueryBuilder extends BaseQueryBuilder {
47544
47612
  const sorts = this.query.sortOrder.map(s => {
47545
47613
  return s.fieldName;
47546
47614
  });
47547
- (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.');
47615
+ (0,dist.assertTruthy)(isEqual(fields.sort(), sorts.slice(0, fields.length).sort()), 'All fields in limitBy must be appear in the first fields in the sortBy list.');
47548
47616
  this.query.limitBy = { limit, fields, reverseSort: false };
47549
47617
  return this;
47550
47618
  }
@@ -49149,10 +49217,10 @@ class DocumentStore {
49149
49217
  return this.squidDocIdToDoc.get(squidDocId);
49150
49218
  }
49151
49219
  compareValues(a, b) {
49152
- if (lodash_default().isNil(a)) {
49153
- return lodash_default().isNil(b) ? 0 : -1;
49220
+ if (isNil(a)) {
49221
+ return isNil(b) ? 0 : -1;
49154
49222
  }
49155
- if (lodash_default().isNil(b))
49223
+ if (isNil(b))
49156
49224
  return 1;
49157
49225
  if (a === b)
49158
49226
  return 0;
@@ -49319,7 +49387,6 @@ var LimitUnderflowState;
49319
49387
  })(LimitUnderflowState || (LimitUnderflowState = {}));
49320
49388
 
49321
49389
  ;// CONCATENATED MODULE: ../internal-common/src/utils/array.ts
49322
-
49323
49390
  /** @internal */
49324
49391
  function binarySearch(arr, key, comparator = (a, b) => (a > b ? 1 : a < b ? -1 : 0), low = 0, high = arr.length - 1) {
49325
49392
  if (high < low)
@@ -49363,7 +49430,7 @@ async function asyncGroupBy(arr, groupNamer) {
49363
49430
  }
49364
49431
  /** @internal */
49365
49432
  const arrayMergeCustomizer = (a, b) => {
49366
- if (isArray(a)) {
49433
+ if (Array.isArray(a)) {
49367
49434
  return a.concat(b);
49368
49435
  }
49369
49436
  else {
@@ -49652,7 +49719,7 @@ class QuerySubscriptionManager {
49652
49719
  }
49653
49720
  this.sendQueryToServerOrUseParentQuery(rootOngoingQuery);
49654
49721
  rootOngoingQuery.allObservables = new external_rxjs_.ReplaySubject(1);
49655
- const result = rootOngoingQuery.allObservables.pipe((0,external_rxjs_.switchMap)(allObservables => (0,external_rxjs_.combineLatest)(allObservables).pipe(map(allResults => this.joinResults(allResults, joinConditions, rootOngoingQuery)))), filter(() => this.allOngoingQueriesGotInitialResult(rootOngoingQuery)), (0,external_rxjs_.startWith)(undefined), (0,external_rxjs_.pairwise)(), filter(([before, after]) => !lodash.isEqual(before, after)), map(([, after]) => after),
49722
+ const result = rootOngoingQuery.allObservables.pipe((0,external_rxjs_.switchMap)(allObservables => (0,external_rxjs_.combineLatest)(allObservables).pipe(map(allResults => this.joinResults(allResults, joinConditions, rootOngoingQuery)))), filter(() => this.allOngoingQueriesGotInitialResult(rootOngoingQuery)), (0,external_rxjs_.startWith)(undefined), (0,external_rxjs_.pairwise)(), filter(([before, after]) => !isEqual(before, after)), map(([, after]) => after),
49656
49723
  // This handles 'subscribe = false'
49657
49724
  subscribe ? (0,external_rxjs_.tap)() : (0,external_rxjs_.take)(1), (0,external_rxjs_.finalize)(() => {
49658
49725
  var _a;
@@ -50304,25 +50371,90 @@ var external_axios_default = /*#__PURE__*/__webpack_require__.n(external_axios_n
50304
50371
 
50305
50372
 
50306
50373
 
50307
- /** @internal. */
50308
50374
  class RpcError extends Error {
50309
- constructor(statusCode, statusText, headers, url, message) {
50375
+ /** @internal */
50376
+ constructor(statusCode, statusText, url, headers, body, message) {
50310
50377
  super(message || `RPC error ${statusCode} ${statusText} calling ${url}`);
50311
50378
  this.statusCode = statusCode;
50312
50379
  this.statusText = statusText;
50313
- this.headers = headers;
50314
50380
  this.url = url;
50381
+ this.headers = headers;
50382
+ this.body = body;
50315
50383
  }
50316
50384
  }
50317
50385
  /**
50318
50386
  * Runs a post request to the given URL.
50319
50387
  * @internal.
50320
50388
  */
50321
- async function squidHttpPost({ url, headers, files, filesFieldName, message }) {
50322
- const isFetch = !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
50389
+ async function rawSquidHttpPost({ url, headers, files, filesFieldName, message, extractErrorMessage, }) {
50390
+ // Native fetch is used in json request mode or when the corresponding private Squid option is enabled.
50391
+ // This option is enabled in console-local and console-dev modes both in Web & Backend.
50392
+ const isFetch = files.length === 0 || !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
50393
+ let response;
50323
50394
  if (isFetch) {
50324
- const requestOptionHeaders = new Headers(headers);
50325
- const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
50395
+ response = await performFetchRequest(headers, files, filesFieldName, message, url, extractErrorMessage);
50396
+ }
50397
+ else {
50398
+ response = await performAxiosRequest(files, filesFieldName, message, url, headers, extractErrorMessage);
50399
+ }
50400
+ response.body = tryDeserializing(response.body);
50401
+ return response;
50402
+ }
50403
+ async function performFetchRequest(headers, files, filesFieldName, body, url, extractErrorMessage) {
50404
+ const requestOptionHeaders = new Headers(headers);
50405
+ const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
50406
+ if (files.length) {
50407
+ const formData = new FormData();
50408
+ for (const file of files) {
50409
+ const blob = file instanceof Blob ? file : file.blob;
50410
+ const filename = file instanceof Blob ? undefined : file.name;
50411
+ formData.append(filesFieldName, blob, filename);
50412
+ }
50413
+ formData.append('body', serializeObj(body));
50414
+ requestOptions.body = formData;
50415
+ }
50416
+ else {
50417
+ requestOptionHeaders.append('Content-Type', 'application/json');
50418
+ requestOptions.body = serializeObj(body);
50419
+ }
50420
+ const response = await fetch(url, requestOptions);
50421
+ const responseHeaders = {};
50422
+ response.headers.forEach((value, key) => {
50423
+ responseHeaders[key] = value;
50424
+ });
50425
+ if (!response.ok) {
50426
+ const rawBody = await response.text();
50427
+ const parsedBody = tryDeserializing(rawBody);
50428
+ if (!extractErrorMessage) {
50429
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, rawBody);
50430
+ }
50431
+ let message;
50432
+ try {
50433
+ message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
50434
+ }
50435
+ catch (_a) { }
50436
+ if (!message)
50437
+ message = response.statusText;
50438
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, message);
50439
+ }
50440
+ const responseBody = await response.text();
50441
+ DebugLogger.debug(`received response: ${JSON.stringify(responseBody)}`);
50442
+ return {
50443
+ body: responseBody,
50444
+ headers: responseHeaders,
50445
+ status: response.status,
50446
+ statusText: response.statusText,
50447
+ };
50448
+ }
50449
+ function extractAxiosResponseHeaders(response) {
50450
+ return Object.entries(response.headers).reduce((acc, [key, value]) => {
50451
+ acc[key] = value;
50452
+ return acc;
50453
+ }, {});
50454
+ }
50455
+ async function performAxiosRequest(files, filesFieldName, body, url, headers, extractErrorMessage) {
50456
+ let axiosResponse;
50457
+ try {
50326
50458
  if (files.length) {
50327
50459
  const formData = new FormData();
50328
50460
  for (const file of files) {
@@ -50330,72 +50462,52 @@ async function squidHttpPost({ url, headers, files, filesFieldName, message }) {
50330
50462
  const filename = file instanceof Blob ? undefined : file.name;
50331
50463
  formData.append(filesFieldName, blob, filename);
50332
50464
  }
50333
- formData.append('body', serializeObj(message));
50334
- requestOptions.body = formData;
50465
+ formData.append('body', serializeObj(body));
50466
+ // Make the axios call
50467
+ axiosResponse = await external_axios_default().post(url, formData, {
50468
+ headers,
50469
+ responseType: 'text',
50470
+ });
50335
50471
  }
50336
50472
  else {
50337
- requestOptionHeaders.append('Content-Type', 'application/json');
50338
- requestOptions.body = serializeObj(message);
50339
- }
50340
- const response = await fetch(url, requestOptions);
50341
- if (!response.ok) {
50342
- const errorBody = await response.text();
50343
- const errorResponse = tryDeserializing(errorBody);
50344
- const errorResponseMessage = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
50345
- throw new RpcError(response.status, response.statusText, response.headers, url, errorResponseMessage);
50473
+ axiosResponse = await external_axios_default().post(url, serializeObj(body), {
50474
+ headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
50475
+ responseType: 'text',
50476
+ });
50346
50477
  }
50347
- const responseData = await response.text();
50348
- const parsedResponse = tryDeserializing(responseData);
50349
- DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
50350
- return parsedResponse;
50351
50478
  }
50352
- else {
50353
- let axiosResponse;
50354
- try {
50355
- if (files.length) {
50356
- const formData = new FormData();
50357
- for (const file of files) {
50358
- const blob = file instanceof Blob ? file : file.blob;
50359
- const filename = file instanceof Blob ? undefined : file.name;
50360
- formData.append(filesFieldName, blob, filename);
50361
- }
50362
- formData.append('body', serializeObj(message));
50363
- // Make the axios call
50364
- axiosResponse = await external_axios_default().post(url, formData, {
50365
- headers: Object.assign({}, headers),
50366
- responseType: 'text',
50367
- });
50479
+ catch (error) {
50480
+ if ((0,external_axios_namespaceObject.isAxiosError)(error)) {
50481
+ const { response } = error;
50482
+ if (!response)
50483
+ throw error;
50484
+ const responseHeaders = extractAxiosResponseHeaders(response);
50485
+ const rawBody = response.data;
50486
+ const parsedBody = tryDeserializing(rawBody);
50487
+ if (!extractErrorMessage) {
50488
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, rawBody);
50368
50489
  }
50369
- else {
50370
- axiosResponse = await external_axios_default().post(url, serializeObj(message), {
50371
- headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
50372
- responseType: 'text',
50373
- });
50490
+ let message;
50491
+ try {
50492
+ message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
50374
50493
  }
50494
+ catch (_a) { }
50495
+ if (!message)
50496
+ message = response.statusText;
50497
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, message);
50375
50498
  }
50376
- catch (error) {
50377
- if ((0,external_axios_namespaceObject.isAxiosError)(error)) {
50378
- const { response } = error;
50379
- if (!response)
50380
- throw error;
50381
- let message;
50382
- try {
50383
- const errorResponse = tryDeserializing(response.data);
50384
- message = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
50385
- }
50386
- catch (_a) { }
50387
- if (!message)
50388
- message = response.statusText;
50389
- throw new RpcError(response.status, response.statusText, response.headers, url, message);
50390
- }
50391
- else {
50392
- throw error;
50393
- }
50499
+ else {
50500
+ throw error;
50394
50501
  }
50395
- const parsedResponse = tryDeserializing(axiosResponse.data);
50396
- DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
50397
- return parsedResponse;
50398
50502
  }
50503
+ const responseHeaders = extractAxiosResponseHeaders(axiosResponse);
50504
+ DebugLogger.debug(`received response: ${JSON.stringify(axiosResponse.data)}`);
50505
+ return {
50506
+ body: axiosResponse.data,
50507
+ headers: responseHeaders,
50508
+ status: axiosResponse.status,
50509
+ statusText: axiosResponse.statusText,
50510
+ };
50399
50511
  }
50400
50512
  function tryDeserializing(text) {
50401
50513
  if (!text)
@@ -50471,6 +50583,10 @@ class RpcManager {
50471
50583
  return this.staticHeaders;
50472
50584
  }
50473
50585
  async post(path, message, files = [], filesFieldName = 'files') {
50586
+ const response = await this.rawPost(path, message, files, filesFieldName);
50587
+ return response.body;
50588
+ }
50589
+ async rawPost(path, message, files = [], filesFieldName = 'files', extractErrorMessage = true) {
50474
50590
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
50475
50591
  try {
50476
50592
  await this.getRateLimiterBucket(path).consume();
@@ -50478,7 +50594,14 @@ class RpcManager {
50478
50594
  const headers = Object.assign(Object.assign({}, this.staticHeaders), authHeaders);
50479
50595
  DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
50480
50596
  const url = getApplicationUrl(this.region, this.appId, path);
50481
- return await squidHttpPost({ url, headers, message, files, filesFieldName });
50597
+ return (await rawSquidHttpPost({
50598
+ url,
50599
+ headers,
50600
+ message,
50601
+ files,
50602
+ filesFieldName,
50603
+ extractErrorMessage,
50604
+ }));
50482
50605
  }
50483
50606
  finally {
50484
50607
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
@@ -51289,8 +51412,7 @@ class QueueManagerImpl {
51289
51412
 
51290
51413
  /** @internal */
51291
51414
  function parseAppId(appId) {
51292
- /** We're splitting also by underscore because of backward compatibility - remove this in a few months */
51293
- const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split(/[_-]/);
51415
+ const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split('-');
51294
51416
  (0,dist.assertTruthy)(!other, 'Invalid appId: ' + appId);
51295
51417
  return {
51296
51418
  appId: appIdWithoutEnv,
@@ -51324,6 +51446,46 @@ function omitSquidDevId(appId) {
51324
51446
  return appIdWithEnvironmentId(parsedAppId.appId, parsedAppId.environmentId);
51325
51447
  }
51326
51448
 
51449
+ ;// CONCATENATED MODULE: ./src/api-client.ts
51450
+ const DEFAULT_OPTIONS = { headers: {}, queryParams: {}, pathParams: {} };
51451
+ class ApiClient {
51452
+ /** @internal */
51453
+ constructor(rpcManager) {
51454
+ this.rpcManager = rpcManager;
51455
+ }
51456
+ async get(integrationId, endpointId, options) {
51457
+ return this.request(integrationId, endpointId, undefined, options, 'get');
51458
+ }
51459
+ async post(integrationId, endpointId, body, options) {
51460
+ return this.request(integrationId, endpointId, body, options, 'post');
51461
+ }
51462
+ async delete(integrationId, endpointId, body, options) {
51463
+ return this.request(integrationId, endpointId, body, options, 'delete');
51464
+ }
51465
+ async patch(integrationId, endpointId, body, options) {
51466
+ return this.request(integrationId, endpointId, body, options, 'patch');
51467
+ }
51468
+ async put(integrationId, endpointId, body, options) {
51469
+ return this.request(integrationId, endpointId, body, options, 'put');
51470
+ }
51471
+ /**
51472
+ * Performs an HTTP API request to the given integration ID and endpoint ID.
51473
+ * The provided options will be merged with the default options.
51474
+ * In case of error (status code >= 400 or other error), the promise will be rejected with an RpcError.
51475
+ */
51476
+ async request(integrationId, endpointId, body, options, method) {
51477
+ const optionsToSend = Object.assign(Object.assign({}, DEFAULT_OPTIONS), (options || {}));
51478
+ const apiRequest = {
51479
+ integrationId,
51480
+ endpointId,
51481
+ body,
51482
+ options: optionsToSend,
51483
+ overrideMethod: method,
51484
+ };
51485
+ return await this.rpcManager.rawPost('api/callApi', apiRequest, undefined, undefined, false);
51486
+ }
51487
+ }
51488
+
51327
51489
  ;// CONCATENATED MODULE: ./src/squid.ts
51328
51490
 
51329
51491
 
@@ -51355,6 +51517,7 @@ function omitSquidDevId(appId) {
51355
51517
 
51356
51518
 
51357
51519
 
51520
+
51358
51521
 
51359
51522
 
51360
51523
  /**
@@ -51394,6 +51557,7 @@ class Squid {
51394
51557
  this.rpcManager = new RpcManager(options.region, appId, this.destructManager, httpHeaders, this.authManager, this.clientIdService);
51395
51558
  this.aiClientFactory = new AiChatbotClientFactory(this.rpcManager, this.socketManager);
51396
51559
  this.aiClient = new AiClient(this.aiClientFactory, this.rpcManager);
51560
+ this.apiClient = new ApiClient(this.rpcManager);
51397
51561
  this.documentStore = new DocumentStore();
51398
51562
  this.lockManager = new LockManager();
51399
51563
  this.distributedLockManager = new DistributedLockManager(this.socketManager, this.destructManager);
@@ -51556,6 +51720,10 @@ class Squid {
51556
51720
  this._validateNotDestructed();
51557
51721
  return this.aiClient;
51558
51722
  }
51723
+ api() {
51724
+ this._validateNotDestructed();
51725
+ return this.apiClient;
51726
+ }
51559
51727
  get secrets() {
51560
51728
  return this.secretClient;
51561
51729
  }
@@ -4,12 +4,19 @@ 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';
6
6
  export type OpenAiResponseFormat = 'text' | 'json_object';
7
+ /** The options for the AI chatbot chat method. */
7
8
  export interface AiChatbotChatOptions {
9
+ /** The maximum number of tokens to use when making the request to the AI model. Default to the max tokens the model can accept */
8
10
  maxTokens?: number;
11
+ /** A unique chat ID, if the same chat ID is used again and history is not disabled, it will continue the conversation */
9
12
  chatId?: string;
13
+ /** Whether to disable history for the chat. Default to false */
10
14
  disableHistory?: boolean;
15
+ /** Whether to include references from the source context in the response. Default to false */
11
16
  includeReference?: boolean;
17
+ /** The format of the response from the AI model. Note that not all models support JSON format. Default to 'text' */
12
18
  responseFormat?: OpenAiResponseFormat;
19
+ /** Whether to response in a "smooth typing" way, beneficial when the chat result is displayed in a UI. Default to true */
13
20
  smoothTyping?: boolean;
14
21
  }
15
22
  export type AiChatbotMutationType = 'insert' | 'update' | 'delete';
@@ -1,19 +1,23 @@
1
1
  import { ApiEndpointId, HttpMethod } from './integrations/api.public-types';
2
+ import { IntegrationId } from './communication.public-types';
2
3
  /** The headers of an API call. */
3
- export type ApiHeaders = Record<string, string | number | boolean>;
4
+ export type ApiHeaders = Record<string, string>;
4
5
  /** The context of an API call. */
5
6
  export declare class ApiCallContext {
7
+ readonly integrationId: IntegrationId;
6
8
  readonly endpointId: ApiEndpointId;
7
9
  readonly url: string;
8
10
  readonly method: HttpMethod;
9
- readonly headers: ApiHeaders;
10
- readonly body: Record<string, any>;
11
- readonly queryParams: Record<string, string | number | boolean>;
12
- readonly pathParams: Record<string, string>;
11
+ readonly body: unknown;
13
12
  readonly options: ApiOptions;
14
13
  }
15
- /** The options for calling an API. */
16
14
  export interface ApiOptions {
15
+ headers?: ApiHeaders;
16
+ queryParams?: Record<string, string>;
17
+ pathParams?: Record<string, string>;
18
+ }
19
+ /** The options for calling an API. */
20
+ export interface CallApiOptions {
17
21
  /** If true, the response will be returned as-is without any processing. */
18
22
  nativeResponse?: boolean;
19
23
  /**
@@ -22,6 +26,13 @@ export interface ApiOptions {
22
26
  */
23
27
  originOverride?: string;
24
28
  }
29
+ export interface CallApiRequest {
30
+ integrationId: IntegrationId;
31
+ endpointId: ApiEndpointId;
32
+ body?: any;
33
+ overrideMethod?: HttpMethod;
34
+ options: ApiOptions;
35
+ }
25
36
  /** A native API call response. */
26
37
  export interface NativeApiCallResponse<T = unknown> {
27
38
  body: T;
@@ -6,3 +6,10 @@ export type TopicActionType = 'read' | 'write' | 'all';
6
6
  export type AiChatbotActionType = 'chat' | 'mutate' | 'all';
7
7
  export type AiFunctionParamType = 'string' | 'number' | 'boolean' | 'date';
8
8
  export type FunctionName = string;
9
+ export interface AiFunctionParam {
10
+ name: string;
11
+ description: string;
12
+ type: AiFunctionParamType;
13
+ required: boolean;
14
+ }
15
+ export type TopicName = string;
@@ -0,0 +1,5 @@
1
+ export interface OpenApiResponse {
2
+ headers: Record<string, any>;
3
+ body: any;
4
+ statusCode: number;
5
+ }
@@ -1,6 +1,5 @@
1
1
  import { CollectionName, DocumentData, FieldName } from './document.public-types';
2
2
  import { Paths } from './typescript.public-types';
3
- import { ClientRequestId } from './communication.public-types';
4
3
  /**
5
4
  * An alias for a join result. This is used to disambiguate fields in the result.
6
5
  */
@@ -57,9 +56,4 @@ export interface Query<Doc extends DocumentData = any> {
57
56
  reverseSort: boolean;
58
57
  };
59
58
  }
60
- export interface QueryRegisterRequest {
61
- clientRequestId: ClientRequestId;
62
- query: Query;
63
- parentClientRequestId: ClientRequestId;
64
- }
65
59
  export {};
@@ -1,5 +1,10 @@
1
1
  export declare function getInPath(obj: Readonly<any> | undefined, path: string, delimiter?: string): any;
2
+ export declare function isDateObject(value: unknown): value is Date;
2
3
  export declare function setInPath(obj: object, path: string, value: unknown, delimiter?: string): void;
3
4
  export declare function deleteInPath(obj: object, path: string, delimiter?: string): void;
4
5
  export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
5
6
  export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
7
+ export declare function isNil(obj: unknown): obj is null | undefined;
8
+ export declare function isEqual(a: unknown, b: unknown): boolean;
9
+ export declare function isEmpty(a: unknown): boolean;
10
+ export declare function omit<T extends object, K extends (string | number | symbol)[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
@@ -0,0 +1,18 @@
1
+ import { IntegrationId } from '../../internal-common/src/public-types/communication.public-types';
2
+ import { ApiEndpointId, HttpMethod } from '../../internal-common/src/public-types/integrations/api.public-types';
3
+ import { ApiOptions } from '../../internal-common/src/public-types/api-call.public-context';
4
+ import { HttpResponse } from './squid-http-client';
5
+ export declare class ApiClient {
6
+ private readonly rpcManager;
7
+ get<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, options?: ApiOptions): Promise<HttpResponse<T>>;
8
+ post<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: unknown, options?: ApiOptions): Promise<HttpResponse<T>>;
9
+ delete<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: unknown, options?: ApiOptions): Promise<HttpResponse<T>>;
10
+ patch<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: unknown, options?: ApiOptions): Promise<HttpResponse<T>>;
11
+ put<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: unknown, options?: ApiOptions): Promise<HttpResponse<T>>;
12
+ /**
13
+ * Performs an HTTP API request to the given integration ID and endpoint ID.
14
+ * The provided options will be merged with the default options.
15
+ * In case of error (status code >= 400 or other error), the promise will be rejected with an RpcError.
16
+ */
17
+ request<T = unknown>(integrationId: IntegrationId, endpointId: ApiEndpointId, body?: unknown, options?: ApiOptions, method?: HttpMethod): Promise<HttpResponse<T>>;
18
+ }
@@ -1,10 +1,10 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { RpcManager } from './rpc.manager';
3
3
  import { ClientIdService } from './client-id.service';
4
- import { ApiEndpointId, ApiOptions, IntegrationId } from './public-types';
4
+ import { ApiEndpointId, CallApiOptions, IntegrationId } from './public-types';
5
5
  export declare class ApiManager {
6
6
  private readonly clientIdService;
7
7
  private readonly rpcManager;
8
8
  constructor(clientIdService: ClientIdService, rpcManager: RpcManager);
9
- callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>, options: ApiOptions): Observable<T>;
9
+ callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>, options: CallApiOptions): Observable<T>;
10
10
  }
@@ -20,6 +20,7 @@ export * from '../../internal-common/src/public-types/mutation.public-context';
20
20
  export * from '../../internal-common/src/public-types/mutation.public-types';
21
21
  export * from '../../internal-common/src/public-types/native-query.public-context';
22
22
  export * from '../../internal-common/src/public-types/native-query.public-types';
23
+ export * from '../../internal-common/src/public-types/openapi.public-types';
23
24
  export * from '../../internal-common/src/public-types/pagination.public-types';
24
25
  export * from '../../internal-common/src/public-types/query.public-context';
25
26
  export * from '../../internal-common/src/public-types/query.public-types';
@@ -3,6 +3,7 @@ import { ClientIdService } from './client-id.service';
3
3
  import { DestructManager } from './destruct.manager';
4
4
  import { BlobAndFilename } from './types';
5
5
  import { SquidRegion } from './public-types';
6
+ import { HttpResponse } from './squid-http-client';
6
7
  export declare class RpcManager {
7
8
  private readonly region;
8
9
  private readonly appId;
@@ -18,5 +19,6 @@ export declare class RpcManager {
18
19
  deleteStaticHeader(key: string): void;
19
20
  getStaticHeaders(): Record<string, string>;
20
21
  post<T>(path: string, message: unknown, files?: Array<File | BlobAndFilename>, filesFieldName?: string): Promise<T>;
22
+ rawPost<T = unknown>(path: string, message: unknown, files?: Array<File | BlobAndFilename>, filesFieldName?: string, extractErrorMessage?: boolean): Promise<HttpResponse<T>>;
21
23
  private getRateLimiterBucket;
22
24
  }
@@ -1 +1,23 @@
1
- export {};
1
+ import { BlobAndFilename } from './types';
2
+ export declare class RpcError extends Error {
3
+ readonly statusCode: number;
4
+ readonly statusText: string;
5
+ readonly url: string;
6
+ readonly headers: Record<string, string>;
7
+ readonly body?: unknown;
8
+ }
9
+ export interface HttpPostInput {
10
+ url: string;
11
+ headers: Record<string, string>;
12
+ message: unknown;
13
+ files: Array<File | BlobAndFilename>;
14
+ filesFieldName: string;
15
+ extractErrorMessage: boolean;
16
+ }
17
+ /** A response object with type T for the body. */
18
+ export interface HttpResponse<T = unknown> {
19
+ status: number;
20
+ statusText: string;
21
+ headers: Record<string, string>;
22
+ body: T;
23
+ }
@@ -5,8 +5,9 @@ import { GraphQLClient } from './graphql-client';
5
5
  import { SecretClient } from './secret.client';
6
6
  import { TransactionId } from './types';
7
7
  import { AiClient } from './ai.types';
8
- import { ApiEndpointId, ApiKey, AppId, ApiOptions, CollectionName, DocumentData, EnvironmentId, IntegrationId, NativeApiCallResponse, SquidDeveloperId, SquidRegion } from './public-types';
8
+ import { ApiEndpointId, ApiKey, CallApiOptions, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, NativeApiCallResponse, SquidDeveloperId, SquidRegion } from './public-types';
9
9
  import { QueueManager } from './queue.manager';
10
+ import { ApiClient } from './api-client';
10
11
  /** The different options that can be used to initialize a Squid instance. */
11
12
  export interface SquidOptions {
12
13
  /**
@@ -98,6 +99,7 @@ export declare class Squid {
98
99
  private readonly querySender;
99
100
  private static readonly squidInstancesMap;
100
101
  private readonly aiClient;
102
+ private readonly apiClient;
101
103
  private readonly queueManagerFactory;
102
104
  /**
103
105
  * Creates a new instance of Squid with the given options.
@@ -183,10 +185,10 @@ export declare class Squid {
183
185
  * @type {Promise<Array<SquidDocument>>}
184
186
  */
185
187
  executeNativeRelationalQuery<T = any>(integrationId: IntegrationId, query: string, params?: Record<string, any>): Promise<Array<T>>;
186
- callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: Omit<ApiOptions, 'nativeResponse'> | (ApiOptions & {
188
+ callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: Omit<CallApiOptions, 'nativeResponse'> | (CallApiOptions & {
187
189
  nativeResponse: false;
188
190
  })): Promise<T>;
189
- callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: ApiOptions & {
191
+ callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: CallApiOptions & {
190
192
  nativeResponse: true;
191
193
  }): Promise<NativeApiCallResponse<T>>;
192
194
  /**
@@ -204,6 +206,7 @@ export declare class Squid {
204
206
  * @returns A set of AI specific clients.
205
207
  */
206
208
  ai(): AiClient;
209
+ api(): ApiClient;
207
210
  get secrets(): SecretClient;
208
211
  /**
209
212
  * Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.176",
3
+ "version": "1.0.178",
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",