@squidcloud/client 1.0.177 → 1.0.179

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;
@@ -29398,6 +29359,107 @@ function replaceKeyInRecord(record, a, b) {
29398
29359
  function isNil(obj) {
29399
29360
  return obj === undefined || obj === null;
29400
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
+ }
29422
+
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
+ }
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
+ }
29401
29463
 
29402
29464
  ;// CONCATENATED MODULE: ../internal-common/src/public-types/pagination.public-types.ts
29403
29465
 
@@ -29672,6 +29734,7 @@ const ALL_OPERATORS = [
29672
29734
 
29673
29735
  ;// CONCATENATED MODULE: ../internal-common/src/utils/serialization.ts
29674
29736
 
29737
+
29675
29738
  function sortKeys(json) {
29676
29739
  if (Array.isArray(json)) {
29677
29740
  return json.map(o => sortKeys(o));
@@ -29693,16 +29756,19 @@ function serializeObj(obj) {
29693
29756
  if (obj === undefined)
29694
29757
  return null; // TODO: change method signature.
29695
29758
  const objWithReplacedDates = lodash.cloneDeepWith(obj, value => {
29696
- return lodash.isDate(value) ? { $date: value.toISOString() } : undefined;
29759
+ return isDateObject(value) ? { $date: value.toISOString() } : undefined;
29697
29760
  });
29698
29761
  return JSON.stringify(objWithReplacedDates);
29699
29762
  }
29700
29763
  function deserializeObj(str) {
29701
29764
  const deserializedObj = JSON.parse(str);
29702
29765
  return lodash.cloneDeepWith(deserializedObj, value => {
29703
- return lodash.isObject(value) && lodash.has(value, '$date') && Object.keys(value).length === 1
29704
- ? new Date(value['$date'])
29705
- : 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;
29706
29772
  });
29707
29773
  }
29708
29774
  function encodeValueForMapping(value) {
@@ -29744,7 +29810,6 @@ function decodeValueForMapping(encodedString) {
29744
29810
  ;// CONCATENATED MODULE: ../internal-common/src/types/query.types.ts
29745
29811
 
29746
29812
 
29747
-
29748
29813
  /**
29749
29814
  * Example query mapping:
29750
29815
  * Queries:
@@ -29775,10 +29840,10 @@ function compareOperator(conditionValue, valueInDocument, operator) {
29775
29840
  conditionValue = conditionValue instanceof Date ? conditionValue.getTime() : conditionValue !== null && conditionValue !== void 0 ? conditionValue : null;
29776
29841
  valueInDocument = valueInDocument instanceof Date ? valueInDocument.getTime() : valueInDocument !== null && valueInDocument !== void 0 ? valueInDocument : null;
29777
29842
  if (operator === '==') {
29778
- return lodash_default().isEqual(conditionValue, valueInDocument);
29843
+ return isEqual(conditionValue, valueInDocument);
29779
29844
  }
29780
29845
  if (operator === '!=') {
29781
- return !lodash_default().isEqual(conditionValue, valueInDocument);
29846
+ return !isEqual(conditionValue, valueInDocument);
29782
29847
  }
29783
29848
  // Nulls can only be compared for (in)equality, not other operators.
29784
29849
  switch (operator) {
@@ -29938,7 +30003,7 @@ class QueryContext {
29938
30003
  sortedBy(sorts) {
29939
30004
  const mismatch = sorts.find((fieldSort, index) => {
29940
30005
  var _a;
29941
- 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 }));
29942
30007
  });
29943
30008
  return !mismatch;
29944
30009
  }
@@ -30083,7 +30148,7 @@ class QueryContext {
30083
30148
  const { operator, value } = this.parseConditions([testCondition])[0];
30084
30149
  const sortedQueryValue = Array.isArray(queryValue) ? queryValue.sort() : queryValue;
30085
30150
  const sortedValue = Array.isArray(value) ? value.sort() : value;
30086
- return operator === queryOperator && (0,lodash.isEqual)(sortedValue, sortedQueryValue);
30151
+ return operator === queryOperator && isEqual(sortedValue, sortedQueryValue);
30087
30152
  }
30088
30153
  parseConditions(conditions) {
30089
30154
  const parsedConditions = [];
@@ -30171,6 +30236,7 @@ var ClientConnectionState;
30171
30236
 
30172
30237
 
30173
30238
 
30239
+
30174
30240
 
30175
30241
 
30176
30242
  ;// CONCATENATED MODULE: ../internal-common/src/types/document.types.ts
@@ -30754,8 +30820,7 @@ class MergedQueryBuilder {
30754
30820
  for (const { fieldName, asc } of sort) {
30755
30821
  const aVal = getInPath(this.extractData(a), fieldName);
30756
30822
  const bVal = getInPath(this.extractData(b), fieldName);
30757
- const isEqual = compareOperator(aVal, bVal, '==');
30758
- if (isEqual) {
30823
+ if (compareOperator(aVal, bVal, '==')) {
30759
30824
  continue;
30760
30825
  }
30761
30826
  if (compareOperator(bVal, aVal, '<')) {
@@ -33603,7 +33668,7 @@ var ApolloError = /** @class */ (function (_super) {
33603
33668
  //# sourceMappingURL=index.js.map
33604
33669
  ;// CONCATENATED MODULE: ../node_modules/@apollo/client/utilities/common/arrays.js
33605
33670
  // A version of Array.isArray that works better with readonly arrays.
33606
- var arrays_isArray = Array.isArray;
33671
+ var isArray = Array.isArray;
33607
33672
  function isNonEmptyArray(value) {
33608
33673
  return Array.isArray(value) && value.length > 0;
33609
33674
  }
@@ -34917,15 +34982,15 @@ var TYPENAME_FIELD = {
34917
34982
  value: "__typename",
34918
34983
  },
34919
34984
  };
34920
- function isEmpty(op, fragmentMap) {
34985
+ function transform_isEmpty(op, fragmentMap) {
34921
34986
  return (!op ||
34922
34987
  op.selectionSet.selections.every(function (selection) {
34923
34988
  return selection.kind === kinds_Kind.FRAGMENT_SPREAD &&
34924
- isEmpty(fragmentMap[selection.name.value], fragmentMap);
34989
+ transform_isEmpty(fragmentMap[selection.name.value], fragmentMap);
34925
34990
  }));
34926
34991
  }
34927
34992
  function nullIfDocIsEmpty(doc) {
34928
- return (isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))) ?
34993
+ return (transform_isEmpty(getOperationDefinition(doc) || getFragmentDefinition(doc), createFragmentMap(getFragmentDefinitions(doc)))) ?
34929
34994
  null
34930
34995
  : doc;
34931
34996
  }
@@ -34982,7 +35047,7 @@ function removeDirectivesFromDocument(directives, doc) {
34982
35047
  var getInUseByFragmentName = makeInUseGetterFunction("");
34983
35048
  var getInUse = function (ancestors) {
34984
35049
  for (var p = 0, ancestor = void 0; p < ancestors.length && (ancestor = ancestors[p]); ++p) {
34985
- if (arrays_isArray(ancestor))
35050
+ if (isArray(ancestor))
34986
35051
  continue;
34987
35052
  if (ancestor.kind === kinds_Kind.OPERATION_DEFINITION) {
34988
35053
  // If an operation is anonymous, we use the empty string as its key.
@@ -35846,7 +35911,7 @@ function isObjRef(value) {
35846
35911
 
35847
35912
  function shallowCopy(value) {
35848
35913
  if (isNonNullObject(value)) {
35849
- return arrays_isArray(value) ?
35914
+ return isArray(value) ?
35850
35915
  value.slice(0)
35851
35916
  : tslib_es6_assign({ __proto__: Object.getPrototypeOf(value) }, value);
35852
35917
  }
@@ -41040,7 +41105,7 @@ function fieldNameFromStoreName(storeFieldName) {
41040
41105
  }
41041
41106
  function selectionSetMatchesResult(selectionSet, result, variables) {
41042
41107
  if (isNonNullObject(result)) {
41043
- return arrays_isArray(result) ?
41108
+ return isArray(result) ?
41044
41109
  result.every(function (item) {
41045
41110
  return selectionSetMatchesResult(selectionSet, item, variables);
41046
41111
  })
@@ -41062,7 +41127,7 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
41062
41127
  return false;
41063
41128
  }
41064
41129
  function storeValueIsStoreObject(value) {
41065
- return isNonNullObject(value) && !isReference(value) && !arrays_isArray(value);
41130
+ return isNonNullObject(value) && !isReference(value) && !isArray(value);
41066
41131
  }
41067
41132
  function makeProcessedFieldsMerger() {
41068
41133
  return new DeepMerger();
@@ -41940,7 +42005,7 @@ var StoreReader = /** @class */ (function () {
41940
42005
  _a));
41941
42006
  }
41942
42007
  }
41943
- else if (arrays_isArray(fieldValue)) {
42008
+ else if (isArray(fieldValue)) {
41944
42009
  fieldValue = handleMissing(_this.executeSubSelectedArray({
41945
42010
  field: selection,
41946
42011
  array: fieldValue,
@@ -42018,7 +42083,7 @@ var StoreReader = /** @class */ (function () {
42018
42083
  return null;
42019
42084
  }
42020
42085
  // This is a nested array, recurse
42021
- if (arrays_isArray(item)) {
42086
+ if (isArray(item)) {
42022
42087
  return handleMissing(_this.executeSubSelectedArray({
42023
42088
  field: field,
42024
42089
  array: item,
@@ -42218,13 +42283,13 @@ function getSpecifierPaths(spec) {
42218
42283
  var paths_1 = (info.paths = []);
42219
42284
  var currentPath_1 = [];
42220
42285
  spec.forEach(function (s, i) {
42221
- if (arrays_isArray(s)) {
42286
+ if (isArray(s)) {
42222
42287
  getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
42223
42288
  currentPath_1.length = 0;
42224
42289
  }
42225
42290
  else {
42226
42291
  currentPath_1.push(s);
42227
- if (!arrays_isArray(spec[i + 1])) {
42292
+ if (!isArray(spec[i + 1])) {
42228
42293
  paths_1.push(currentPath_1.slice(0));
42229
42294
  currentPath_1.length = 0;
42230
42295
  }
@@ -42250,7 +42315,7 @@ function extractKeyPath(object, path, extract) {
42250
42315
  // possibly unknown) is the honest answer.
42251
42316
  extract = extract || extractKey;
42252
42317
  return normalize(path.reduce(function reducer(obj, key) {
42253
- return arrays_isArray(obj) ?
42318
+ return isArray(obj) ?
42254
42319
  obj.map(function (child) { return reducer(child, key); })
42255
42320
  : obj && extract(obj, key);
42256
42321
  }, object));
@@ -42260,7 +42325,7 @@ function normalize(value) {
42260
42325
  // key fields are scalar, but just in case we get an object or an array, we
42261
42326
  // need to do some normalization of the order of (nested) keys.
42262
42327
  if (isNonNullObject(value)) {
42263
- if (arrays_isArray(value)) {
42328
+ if (isArray(value)) {
42264
42329
  return value.map(normalize);
42265
42330
  }
42266
42331
  return collectSpecifierPaths(Object.keys(value).sort(), function (path) {
@@ -42355,7 +42420,7 @@ var Policies = /** @class */ (function () {
42355
42420
  var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
42356
42421
  while (keyFn) {
42357
42422
  var specifierOrId = keyFn(tslib_es6_assign(tslib_es6_assign({}, object), storeObject), context);
42358
- if (arrays_isArray(specifierOrId)) {
42423
+ if (isArray(specifierOrId)) {
42359
42424
  keyFn = keyFieldsFnFromSpecifier(specifierOrId);
42360
42425
  }
42361
42426
  else {
@@ -42421,7 +42486,7 @@ var Policies = /** @class */ (function () {
42421
42486
  keyFields === false ? nullKeyFieldsFn
42422
42487
  // Pass an array of strings to use those fields to compute a
42423
42488
  // composite ID for objects of this typename.
42424
- : arrays_isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields)
42489
+ : isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields)
42425
42490
  // Pass a function to take full control over identification.
42426
42491
  : typeof keyFields === "function" ? keyFields
42427
42492
  // Leave existing.keyFn unchanged if above cases fail.
@@ -42441,7 +42506,7 @@ var Policies = /** @class */ (function () {
42441
42506
  keyArgs === false ? simpleKeyArgsFn
42442
42507
  // Pass an array of strings to use named arguments to
42443
42508
  // compute a composite identity for the field.
42444
- : arrays_isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs)
42509
+ : isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs)
42445
42510
  // Pass a function to take full control over field identity.
42446
42511
  : typeof keyArgs === "function" ? keyArgs
42447
42512
  // Leave existing.keyFn unchanged if above cases fail.
@@ -42676,7 +42741,7 @@ var Policies = /** @class */ (function () {
42676
42741
  var args = argsFromFieldSpecifier(fieldSpec);
42677
42742
  while (keyFn) {
42678
42743
  var specifierOrString = keyFn(args, context);
42679
- if (arrays_isArray(specifierOrString)) {
42744
+ if (isArray(specifierOrString)) {
42680
42745
  keyFn = keyArgsFnFromSpecifier(specifierOrString);
42681
42746
  }
42682
42747
  else {
@@ -42839,7 +42904,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
42839
42904
  }
42840
42905
  function makeMergeObjectsFunction(store) {
42841
42906
  return function mergeObjects(existing, incoming) {
42842
- if (arrays_isArray(existing) || arrays_isArray(incoming)) {
42907
+ if (isArray(existing) || isArray(incoming)) {
42843
42908
  throw newInvariantError(8);
42844
42909
  }
42845
42910
  // These dynamic checks are necessary because the parameters of a
@@ -43155,7 +43220,7 @@ var StoreWriter = /** @class */ (function () {
43155
43220
  // it's cheaper to store the scalar values directly in the cache.
43156
43221
  return globalThis.__DEV__ !== false ? cloneDeep(value) : value;
43157
43222
  }
43158
- if (arrays_isArray(value)) {
43223
+ if (isArray(value)) {
43159
43224
  return value.map(function (item, i) {
43160
43225
  var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
43161
43226
  maybeRecycleChildMergeTree(mergeTree, i);
@@ -43247,7 +43312,7 @@ var StoreWriter = /** @class */ (function () {
43247
43312
  // Items in the same position in different arrays are not
43248
43313
  // necessarily related to each other, so when incoming is an array
43249
43314
  // we process its elements as if there was no existing data.
43250
- (!arrays_isArray(incoming) &&
43315
+ (!isArray(incoming) &&
43251
43316
  // Likewise, existing must be either a Reference or a StoreObject
43252
43317
  // in order for its fields to be safe to merge with the fields of
43253
43318
  // the incoming object.
@@ -43272,7 +43337,7 @@ var StoreWriter = /** @class */ (function () {
43272
43337
  // to preserve the type of numeric keys.
43273
43338
  var changedFields_1;
43274
43339
  var getValue_1 = function (from, name) {
43275
- return (arrays_isArray(from) ?
43340
+ return (isArray(from) ?
43276
43341
  typeof name === "number" ?
43277
43342
  from[name]
43278
43343
  : void 0
@@ -43298,7 +43363,7 @@ var StoreWriter = /** @class */ (function () {
43298
43363
  });
43299
43364
  if (changedFields_1) {
43300
43365
  // Shallow clone i so we can add changed fields to it.
43301
- 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));
43302
43367
  changedFields_1.forEach(function (value, name) {
43303
43368
  incoming[name] = value;
43304
43369
  });
@@ -43393,7 +43458,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
43393
43458
  var childTypenames = [];
43394
43459
  // Arrays do not have __typename fields, and always need a custom merge
43395
43460
  // function, even if their elements are normalized entities.
43396
- if (!arrays_isArray(existing) && !arrays_isArray(incoming)) {
43461
+ if (!isArray(existing) && !isArray(incoming)) {
43397
43462
  [existing, incoming].forEach(function (child) {
43398
43463
  var typename = store.getFieldValue(child, "__typename");
43399
43464
  if (typeof typename === "string" && !childTypenames.includes(typename)) {
@@ -46993,7 +47058,8 @@ function getApplicationUrl(regionPrefix, appId, path) {
46993
47058
  }
46994
47059
  const url = parsedBaseUrl.toString();
46995
47060
  path = path.startsWith('/') ? path.slice(1) : path;
46996
- return (url.endsWith('/') ? url : url + '/') + path;
47061
+ const urlWithoutTrailingSlash = url.replace(/\/$/g, '');
47062
+ return path.length ? `${urlWithoutTrailingSlash}/${path}` : urlWithoutTrailingSlash;
46997
47063
  }
46998
47064
  function getApplicationHttpHeaders(regionPrefix, appId) {
46999
47065
  const headers = {};
@@ -47547,7 +47613,7 @@ class QueryBuilder extends BaseQueryBuilder {
47547
47613
  const sorts = this.query.sortOrder.map(s => {
47548
47614
  return s.fieldName;
47549
47615
  });
47550
- (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.');
47616
+ (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.');
47551
47617
  this.query.limitBy = { limit, fields, reverseSort: false };
47552
47618
  return this;
47553
47619
  }
@@ -49322,7 +49388,6 @@ var LimitUnderflowState;
49322
49388
  })(LimitUnderflowState || (LimitUnderflowState = {}));
49323
49389
 
49324
49390
  ;// CONCATENATED MODULE: ../internal-common/src/utils/array.ts
49325
-
49326
49391
  /** @internal */
49327
49392
  function binarySearch(arr, key, comparator = (a, b) => (a > b ? 1 : a < b ? -1 : 0), low = 0, high = arr.length - 1) {
49328
49393
  if (high < low)
@@ -49366,7 +49431,7 @@ async function asyncGroupBy(arr, groupNamer) {
49366
49431
  }
49367
49432
  /** @internal */
49368
49433
  const arrayMergeCustomizer = (a, b) => {
49369
- if (isArray(a)) {
49434
+ if (Array.isArray(a)) {
49370
49435
  return a.concat(b);
49371
49436
  }
49372
49437
  else {
@@ -49655,7 +49720,7 @@ class QuerySubscriptionManager {
49655
49720
  }
49656
49721
  this.sendQueryToServerOrUseParentQuery(rootOngoingQuery);
49657
49722
  rootOngoingQuery.allObservables = new external_rxjs_.ReplaySubject(1);
49658
- 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),
49723
+ 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),
49659
49724
  // This handles 'subscribe = false'
49660
49725
  subscribe ? (0,external_rxjs_.tap)() : (0,external_rxjs_.take)(1), (0,external_rxjs_.finalize)(() => {
49661
49726
  var _a;
@@ -50307,25 +50372,90 @@ var external_axios_default = /*#__PURE__*/__webpack_require__.n(external_axios_n
50307
50372
 
50308
50373
 
50309
50374
 
50310
- /** @internal. */
50311
50375
  class RpcError extends Error {
50312
- constructor(statusCode, statusText, headers, url, message) {
50376
+ /** @internal */
50377
+ constructor(statusCode, statusText, url, headers, body, message) {
50313
50378
  super(message || `RPC error ${statusCode} ${statusText} calling ${url}`);
50314
50379
  this.statusCode = statusCode;
50315
50380
  this.statusText = statusText;
50316
- this.headers = headers;
50317
50381
  this.url = url;
50382
+ this.headers = headers;
50383
+ this.body = body;
50318
50384
  }
50319
50385
  }
50320
50386
  /**
50321
50387
  * Runs a post request to the given URL.
50322
50388
  * @internal.
50323
50389
  */
50324
- async function squidHttpPost({ url, headers, files, filesFieldName, message }) {
50325
- const isFetch = !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
50390
+ async function rawSquidHttpPost({ url, headers, files, filesFieldName, message, extractErrorMessage, }) {
50391
+ // Native fetch is used in json request mode or when the corresponding private Squid option is enabled.
50392
+ // This option is enabled in console-local and console-dev modes both in Web & Backend.
50393
+ const isFetch = files.length === 0 || !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
50394
+ let response;
50326
50395
  if (isFetch) {
50327
- const requestOptionHeaders = new Headers(headers);
50328
- const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
50396
+ response = await performFetchRequest(headers, files, filesFieldName, message, url, extractErrorMessage);
50397
+ }
50398
+ else {
50399
+ response = await performAxiosRequest(files, filesFieldName, message, url, headers, extractErrorMessage);
50400
+ }
50401
+ response.body = tryDeserializing(response.body);
50402
+ return response;
50403
+ }
50404
+ async function performFetchRequest(headers, files, filesFieldName, body, url, extractErrorMessage) {
50405
+ const requestOptionHeaders = new Headers(headers);
50406
+ const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
50407
+ if (files.length) {
50408
+ const formData = new FormData();
50409
+ for (const file of files) {
50410
+ const blob = file instanceof Blob ? file : file.blob;
50411
+ const filename = file instanceof Blob ? undefined : file.name;
50412
+ formData.append(filesFieldName, blob, filename);
50413
+ }
50414
+ formData.append('body', serializeObj(body));
50415
+ requestOptions.body = formData;
50416
+ }
50417
+ else {
50418
+ requestOptionHeaders.append('Content-Type', 'application/json');
50419
+ requestOptions.body = serializeObj(body);
50420
+ }
50421
+ const response = await fetch(url, requestOptions);
50422
+ const responseHeaders = {};
50423
+ response.headers.forEach((value, key) => {
50424
+ responseHeaders[key] = value;
50425
+ });
50426
+ if (!response.ok) {
50427
+ const rawBody = await response.text();
50428
+ const parsedBody = tryDeserializing(rawBody);
50429
+ if (!extractErrorMessage) {
50430
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, rawBody);
50431
+ }
50432
+ let message;
50433
+ try {
50434
+ message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
50435
+ }
50436
+ catch (_a) { }
50437
+ if (!message)
50438
+ message = response.statusText;
50439
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, message);
50440
+ }
50441
+ const responseBody = await response.text();
50442
+ DebugLogger.debug(`received response: ${JSON.stringify(responseBody)}`);
50443
+ return {
50444
+ body: responseBody,
50445
+ headers: responseHeaders,
50446
+ status: response.status,
50447
+ statusText: response.statusText,
50448
+ };
50449
+ }
50450
+ function extractAxiosResponseHeaders(response) {
50451
+ return Object.entries(response.headers).reduce((acc, [key, value]) => {
50452
+ acc[key] = value;
50453
+ return acc;
50454
+ }, {});
50455
+ }
50456
+ async function performAxiosRequest(files, filesFieldName, body, url, headers, extractErrorMessage) {
50457
+ let axiosResponse;
50458
+ try {
50329
50459
  if (files.length) {
50330
50460
  const formData = new FormData();
50331
50461
  for (const file of files) {
@@ -50333,73 +50463,54 @@ async function squidHttpPost({ url, headers, files, filesFieldName, message }) {
50333
50463
  const filename = file instanceof Blob ? undefined : file.name;
50334
50464
  formData.append(filesFieldName, blob, filename);
50335
50465
  }
50336
- formData.append('body', serializeObj(message));
50337
- requestOptions.body = formData;
50466
+ formData.append('body', serializeObj(body));
50467
+ // Make the axios call
50468
+ axiosResponse = await external_axios_default().post(url, formData, {
50469
+ headers,
50470
+ responseType: 'text',
50471
+ });
50338
50472
  }
50339
50473
  else {
50340
- requestOptionHeaders.append('Content-Type', 'application/json');
50341
- requestOptions.body = serializeObj(message);
50342
- }
50343
- const response = await fetch(url, requestOptions);
50344
- if (!response.ok) {
50345
- const errorBody = await response.text();
50346
- const errorResponse = tryDeserializing(errorBody);
50347
- const errorResponseMessage = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
50348
- throw new RpcError(response.status, response.statusText, response.headers, url, errorResponseMessage);
50474
+ axiosResponse = await external_axios_default().post(url, serializeObj(body), {
50475
+ headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
50476
+ responseType: 'text',
50477
+ });
50349
50478
  }
50350
- const responseData = await response.text();
50351
- const parsedResponse = tryDeserializing(responseData);
50352
- DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
50353
- return parsedResponse;
50354
50479
  }
50355
- else {
50356
- let axiosResponse;
50357
- try {
50358
- if (files.length) {
50359
- const formData = new FormData();
50360
- for (const file of files) {
50361
- const blob = file instanceof Blob ? file : file.blob;
50362
- const filename = file instanceof Blob ? undefined : file.name;
50363
- formData.append(filesFieldName, blob, filename);
50364
- }
50365
- formData.append('body', serializeObj(message));
50366
- // Make the axios call
50367
- axiosResponse = await external_axios_default().post(url, formData, {
50368
- headers: Object.assign({}, headers),
50369
- responseType: 'text',
50370
- });
50480
+ catch (error) {
50481
+ if ((0,external_axios_namespaceObject.isAxiosError)(error)) {
50482
+ const { response } = error;
50483
+ if (!response)
50484
+ throw error;
50485
+ const responseHeaders = extractAxiosResponseHeaders(response);
50486
+ const rawBody = response.data;
50487
+ const parsedBody = tryDeserializing(rawBody);
50488
+ if (!extractErrorMessage) {
50489
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, rawBody);
50371
50490
  }
50372
- else {
50373
- axiosResponse = await external_axios_default().post(url, serializeObj(message), {
50374
- headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
50375
- responseType: 'text',
50376
- });
50491
+ let message;
50492
+ try {
50493
+ message = typeof parsedBody === 'string' ? parsedBody : parsedBody['message'] || rawBody;
50377
50494
  }
50495
+ catch (_a) { }
50496
+ if (!message)
50497
+ message = response.statusText;
50498
+ throw new RpcError(response.status, response.statusText, url, responseHeaders, parsedBody, message);
50378
50499
  }
50379
- catch (error) {
50380
- if ((0,external_axios_namespaceObject.isAxiosError)(error)) {
50381
- const { response } = error;
50382
- if (!response)
50383
- throw error;
50384
- let message;
50385
- try {
50386
- const errorResponse = tryDeserializing(response.data);
50387
- message = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
50388
- }
50389
- catch (_a) { }
50390
- if (!message)
50391
- message = response.statusText;
50392
- throw new RpcError(response.status, response.statusText, response.headers, url, message);
50393
- }
50394
- else {
50395
- throw error;
50396
- }
50500
+ else {
50501
+ throw error;
50397
50502
  }
50398
- const parsedResponse = tryDeserializing(axiosResponse.data);
50399
- DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
50400
- return parsedResponse;
50401
50503
  }
50504
+ const responseHeaders = extractAxiosResponseHeaders(axiosResponse);
50505
+ DebugLogger.debug(`received response: ${JSON.stringify(axiosResponse.data)}`);
50506
+ return {
50507
+ body: axiosResponse.data,
50508
+ headers: responseHeaders,
50509
+ status: axiosResponse.status,
50510
+ statusText: axiosResponse.statusText,
50511
+ };
50402
50512
  }
50513
+ /** @internal. */
50403
50514
  function tryDeserializing(text) {
50404
50515
  if (!text)
50405
50516
  return undefined;
@@ -50474,6 +50585,10 @@ class RpcManager {
50474
50585
  return this.staticHeaders;
50475
50586
  }
50476
50587
  async post(path, message, files = [], filesFieldName = 'files') {
50588
+ const response = await this.rawPost(path, message, files, filesFieldName);
50589
+ return response.body;
50590
+ }
50591
+ async rawPost(path, message, files = [], filesFieldName = 'files', extractErrorMessage = true) {
50477
50592
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
50478
50593
  try {
50479
50594
  await this.getRateLimiterBucket(path).consume();
@@ -50481,7 +50596,14 @@ class RpcManager {
50481
50596
  const headers = Object.assign(Object.assign({}, this.staticHeaders), authHeaders);
50482
50597
  DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
50483
50598
  const url = getApplicationUrl(this.region, this.appId, path);
50484
- return await squidHttpPost({ url, headers, message, files, filesFieldName });
50599
+ return (await rawSquidHttpPost({
50600
+ url,
50601
+ headers,
50602
+ message,
50603
+ files,
50604
+ filesFieldName,
50605
+ extractErrorMessage,
50606
+ }));
50485
50607
  }
50486
50608
  finally {
50487
50609
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
@@ -51292,8 +51414,7 @@ class QueueManagerImpl {
51292
51414
 
51293
51415
  /** @internal */
51294
51416
  function parseAppId(appId) {
51295
- /** We're splitting also by underscore because of backward compatibility - remove this in a few months */
51296
- const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split(/[_-]/);
51417
+ const [appIdWithoutEnv, environmentId, squidDeveloperId, other] = appId.split('-');
51297
51418
  (0,dist.assertTruthy)(!other, 'Invalid appId: ' + appId);
51298
51419
  return {
51299
51420
  appId: appIdWithoutEnv,
@@ -51327,6 +51448,46 @@ function omitSquidDevId(appId) {
51327
51448
  return appIdWithEnvironmentId(parsedAppId.appId, parsedAppId.environmentId);
51328
51449
  }
51329
51450
 
51451
+ ;// CONCATENATED MODULE: ./src/api-client.ts
51452
+ const DEFAULT_OPTIONS = { headers: {}, queryParams: {}, pathParams: {} };
51453
+ class ApiClient {
51454
+ /** @internal */
51455
+ constructor(rpcManager) {
51456
+ this.rpcManager = rpcManager;
51457
+ }
51458
+ async get(integrationId, endpointId, options) {
51459
+ return this.request(integrationId, endpointId, undefined, options, 'get');
51460
+ }
51461
+ async post(integrationId, endpointId, body, options) {
51462
+ return this.request(integrationId, endpointId, body, options, 'post');
51463
+ }
51464
+ async delete(integrationId, endpointId, body, options) {
51465
+ return this.request(integrationId, endpointId, body, options, 'delete');
51466
+ }
51467
+ async patch(integrationId, endpointId, body, options) {
51468
+ return this.request(integrationId, endpointId, body, options, 'patch');
51469
+ }
51470
+ async put(integrationId, endpointId, body, options) {
51471
+ return this.request(integrationId, endpointId, body, options, 'put');
51472
+ }
51473
+ /**
51474
+ * Performs an HTTP API request to the given integration ID and endpoint ID.
51475
+ * The provided options will be merged with the default options.
51476
+ * In case of error (status code >= 400 or other error), the promise will be rejected with an RpcError.
51477
+ */
51478
+ async request(integrationId, endpointId, body, options, method) {
51479
+ const optionsToSend = Object.assign(Object.assign({}, DEFAULT_OPTIONS), (options || {}));
51480
+ const apiRequest = {
51481
+ integrationId,
51482
+ endpointId,
51483
+ body,
51484
+ options: optionsToSend,
51485
+ overrideMethod: method,
51486
+ };
51487
+ return await this.rpcManager.rawPost('api/callApi', apiRequest, undefined, undefined, false);
51488
+ }
51489
+ }
51490
+
51330
51491
  ;// CONCATENATED MODULE: ./src/squid.ts
51331
51492
 
51332
51493
 
@@ -51358,6 +51519,7 @@ function omitSquidDevId(appId) {
51358
51519
 
51359
51520
 
51360
51521
 
51522
+
51361
51523
 
51362
51524
 
51363
51525
  /**
@@ -51397,6 +51559,7 @@ class Squid {
51397
51559
  this.rpcManager = new RpcManager(options.region, appId, this.destructManager, httpHeaders, this.authManager, this.clientIdService);
51398
51560
  this.aiClientFactory = new AiChatbotClientFactory(this.rpcManager, this.socketManager);
51399
51561
  this.aiClient = new AiClient(this.aiClientFactory, this.rpcManager);
51562
+ this.apiClient = new ApiClient(this.rpcManager);
51400
51563
  this.documentStore = new DocumentStore();
51401
51564
  this.lockManager = new LockManager();
51402
51565
  this.distributedLockManager = new DistributedLockManager(this.socketManager, this.destructManager);
@@ -51559,6 +51722,10 @@ class Squid {
51559
51722
  this._validateNotDestructed();
51560
51723
  return this.aiClient;
51561
51724
  }
51725
+ api() {
51726
+ this._validateNotDestructed();
51727
+ return this.apiClient;
51728
+ }
51562
51729
  get secrets() {
51563
51730
  return this.secretClient;
51564
51731
  }
@@ -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,6 +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;
6
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.177",
3
+ "version": "1.0.179",
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",