@squidcloud/client 1.0.189 → 1.0.191

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
@@ -1412,567 +1412,6 @@ __exportStar(__webpack_require__(9862), exports);
1412
1412
  __exportStar(__webpack_require__(7122), exports);
1413
1413
  //# sourceMappingURL=index.js.map
1414
1414
 
1415
- /***/ }),
1416
-
1417
- /***/ 9372:
1418
- /***/ (function(module, exports) {
1419
-
1420
- var global = typeof self !== 'undefined' ? self : this;
1421
- var __self__ = (function () {
1422
- function F() {
1423
- this.fetch = false;
1424
- this.DOMException = global.DOMException
1425
- }
1426
- F.prototype = global;
1427
- return new F();
1428
- })();
1429
- (function(self) {
1430
-
1431
- var irrelevant = (function (exports) {
1432
-
1433
- var support = {
1434
- searchParams: 'URLSearchParams' in self,
1435
- iterable: 'Symbol' in self && 'iterator' in Symbol,
1436
- blob:
1437
- 'FileReader' in self &&
1438
- 'Blob' in self &&
1439
- (function() {
1440
- try {
1441
- new Blob();
1442
- return true
1443
- } catch (e) {
1444
- return false
1445
- }
1446
- })(),
1447
- formData: 'FormData' in self,
1448
- arrayBuffer: 'ArrayBuffer' in self
1449
- };
1450
-
1451
- function isDataView(obj) {
1452
- return obj && DataView.prototype.isPrototypeOf(obj)
1453
- }
1454
-
1455
- if (support.arrayBuffer) {
1456
- var viewClasses = [
1457
- '[object Int8Array]',
1458
- '[object Uint8Array]',
1459
- '[object Uint8ClampedArray]',
1460
- '[object Int16Array]',
1461
- '[object Uint16Array]',
1462
- '[object Int32Array]',
1463
- '[object Uint32Array]',
1464
- '[object Float32Array]',
1465
- '[object Float64Array]'
1466
- ];
1467
-
1468
- var isArrayBufferView =
1469
- ArrayBuffer.isView ||
1470
- function(obj) {
1471
- return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
1472
- };
1473
- }
1474
-
1475
- function normalizeName(name) {
1476
- if (typeof name !== 'string') {
1477
- name = String(name);
1478
- }
1479
- if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
1480
- throw new TypeError('Invalid character in header field name')
1481
- }
1482
- return name.toLowerCase()
1483
- }
1484
-
1485
- function normalizeValue(value) {
1486
- if (typeof value !== 'string') {
1487
- value = String(value);
1488
- }
1489
- return value
1490
- }
1491
-
1492
- // Build a destructive iterator for the value list
1493
- function iteratorFor(items) {
1494
- var iterator = {
1495
- next: function() {
1496
- var value = items.shift();
1497
- return {done: value === undefined, value: value}
1498
- }
1499
- };
1500
-
1501
- if (support.iterable) {
1502
- iterator[Symbol.iterator] = function() {
1503
- return iterator
1504
- };
1505
- }
1506
-
1507
- return iterator
1508
- }
1509
-
1510
- function Headers(headers) {
1511
- this.map = {};
1512
-
1513
- if (headers instanceof Headers) {
1514
- headers.forEach(function(value, name) {
1515
- this.append(name, value);
1516
- }, this);
1517
- } else if (Array.isArray(headers)) {
1518
- headers.forEach(function(header) {
1519
- this.append(header[0], header[1]);
1520
- }, this);
1521
- } else if (headers) {
1522
- Object.getOwnPropertyNames(headers).forEach(function(name) {
1523
- this.append(name, headers[name]);
1524
- }, this);
1525
- }
1526
- }
1527
-
1528
- Headers.prototype.append = function(name, value) {
1529
- name = normalizeName(name);
1530
- value = normalizeValue(value);
1531
- var oldValue = this.map[name];
1532
- this.map[name] = oldValue ? oldValue + ', ' + value : value;
1533
- };
1534
-
1535
- Headers.prototype['delete'] = function(name) {
1536
- delete this.map[normalizeName(name)];
1537
- };
1538
-
1539
- Headers.prototype.get = function(name) {
1540
- name = normalizeName(name);
1541
- return this.has(name) ? this.map[name] : null
1542
- };
1543
-
1544
- Headers.prototype.has = function(name) {
1545
- return this.map.hasOwnProperty(normalizeName(name))
1546
- };
1547
-
1548
- Headers.prototype.set = function(name, value) {
1549
- this.map[normalizeName(name)] = normalizeValue(value);
1550
- };
1551
-
1552
- Headers.prototype.forEach = function(callback, thisArg) {
1553
- for (var name in this.map) {
1554
- if (this.map.hasOwnProperty(name)) {
1555
- callback.call(thisArg, this.map[name], name, this);
1556
- }
1557
- }
1558
- };
1559
-
1560
- Headers.prototype.keys = function() {
1561
- var items = [];
1562
- this.forEach(function(value, name) {
1563
- items.push(name);
1564
- });
1565
- return iteratorFor(items)
1566
- };
1567
-
1568
- Headers.prototype.values = function() {
1569
- var items = [];
1570
- this.forEach(function(value) {
1571
- items.push(value);
1572
- });
1573
- return iteratorFor(items)
1574
- };
1575
-
1576
- Headers.prototype.entries = function() {
1577
- var items = [];
1578
- this.forEach(function(value, name) {
1579
- items.push([name, value]);
1580
- });
1581
- return iteratorFor(items)
1582
- };
1583
-
1584
- if (support.iterable) {
1585
- Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
1586
- }
1587
-
1588
- function consumed(body) {
1589
- if (body.bodyUsed) {
1590
- return Promise.reject(new TypeError('Already read'))
1591
- }
1592
- body.bodyUsed = true;
1593
- }
1594
-
1595
- function fileReaderReady(reader) {
1596
- return new Promise(function(resolve, reject) {
1597
- reader.onload = function() {
1598
- resolve(reader.result);
1599
- };
1600
- reader.onerror = function() {
1601
- reject(reader.error);
1602
- };
1603
- })
1604
- }
1605
-
1606
- function readBlobAsArrayBuffer(blob) {
1607
- var reader = new FileReader();
1608
- var promise = fileReaderReady(reader);
1609
- reader.readAsArrayBuffer(blob);
1610
- return promise
1611
- }
1612
-
1613
- function readBlobAsText(blob) {
1614
- var reader = new FileReader();
1615
- var promise = fileReaderReady(reader);
1616
- reader.readAsText(blob);
1617
- return promise
1618
- }
1619
-
1620
- function readArrayBufferAsText(buf) {
1621
- var view = new Uint8Array(buf);
1622
- var chars = new Array(view.length);
1623
-
1624
- for (var i = 0; i < view.length; i++) {
1625
- chars[i] = String.fromCharCode(view[i]);
1626
- }
1627
- return chars.join('')
1628
- }
1629
-
1630
- function bufferClone(buf) {
1631
- if (buf.slice) {
1632
- return buf.slice(0)
1633
- } else {
1634
- var view = new Uint8Array(buf.byteLength);
1635
- view.set(new Uint8Array(buf));
1636
- return view.buffer
1637
- }
1638
- }
1639
-
1640
- function Body() {
1641
- this.bodyUsed = false;
1642
-
1643
- this._initBody = function(body) {
1644
- this._bodyInit = body;
1645
- if (!body) {
1646
- this._bodyText = '';
1647
- } else if (typeof body === 'string') {
1648
- this._bodyText = body;
1649
- } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
1650
- this._bodyBlob = body;
1651
- } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
1652
- this._bodyFormData = body;
1653
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
1654
- this._bodyText = body.toString();
1655
- } else if (support.arrayBuffer && support.blob && isDataView(body)) {
1656
- this._bodyArrayBuffer = bufferClone(body.buffer);
1657
- // IE 10-11 can't handle a DataView body.
1658
- this._bodyInit = new Blob([this._bodyArrayBuffer]);
1659
- } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
1660
- this._bodyArrayBuffer = bufferClone(body);
1661
- } else {
1662
- this._bodyText = body = Object.prototype.toString.call(body);
1663
- }
1664
-
1665
- if (!this.headers.get('content-type')) {
1666
- if (typeof body === 'string') {
1667
- this.headers.set('content-type', 'text/plain;charset=UTF-8');
1668
- } else if (this._bodyBlob && this._bodyBlob.type) {
1669
- this.headers.set('content-type', this._bodyBlob.type);
1670
- } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
1671
- this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
1672
- }
1673
- }
1674
- };
1675
-
1676
- if (support.blob) {
1677
- this.blob = function() {
1678
- var rejected = consumed(this);
1679
- if (rejected) {
1680
- return rejected
1681
- }
1682
-
1683
- if (this._bodyBlob) {
1684
- return Promise.resolve(this._bodyBlob)
1685
- } else if (this._bodyArrayBuffer) {
1686
- return Promise.resolve(new Blob([this._bodyArrayBuffer]))
1687
- } else if (this._bodyFormData) {
1688
- throw new Error('could not read FormData body as blob')
1689
- } else {
1690
- return Promise.resolve(new Blob([this._bodyText]))
1691
- }
1692
- };
1693
-
1694
- this.arrayBuffer = function() {
1695
- if (this._bodyArrayBuffer) {
1696
- return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
1697
- } else {
1698
- return this.blob().then(readBlobAsArrayBuffer)
1699
- }
1700
- };
1701
- }
1702
-
1703
- this.text = function() {
1704
- var rejected = consumed(this);
1705
- if (rejected) {
1706
- return rejected
1707
- }
1708
-
1709
- if (this._bodyBlob) {
1710
- return readBlobAsText(this._bodyBlob)
1711
- } else if (this._bodyArrayBuffer) {
1712
- return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
1713
- } else if (this._bodyFormData) {
1714
- throw new Error('could not read FormData body as text')
1715
- } else {
1716
- return Promise.resolve(this._bodyText)
1717
- }
1718
- };
1719
-
1720
- if (support.formData) {
1721
- this.formData = function() {
1722
- return this.text().then(decode)
1723
- };
1724
- }
1725
-
1726
- this.json = function() {
1727
- return this.text().then(JSON.parse)
1728
- };
1729
-
1730
- return this
1731
- }
1732
-
1733
- // HTTP methods whose capitalization should be normalized
1734
- var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];
1735
-
1736
- function normalizeMethod(method) {
1737
- var upcased = method.toUpperCase();
1738
- return methods.indexOf(upcased) > -1 ? upcased : method
1739
- }
1740
-
1741
- function Request(input, options) {
1742
- options = options || {};
1743
- var body = options.body;
1744
-
1745
- if (input instanceof Request) {
1746
- if (input.bodyUsed) {
1747
- throw new TypeError('Already read')
1748
- }
1749
- this.url = input.url;
1750
- this.credentials = input.credentials;
1751
- if (!options.headers) {
1752
- this.headers = new Headers(input.headers);
1753
- }
1754
- this.method = input.method;
1755
- this.mode = input.mode;
1756
- this.signal = input.signal;
1757
- if (!body && input._bodyInit != null) {
1758
- body = input._bodyInit;
1759
- input.bodyUsed = true;
1760
- }
1761
- } else {
1762
- this.url = String(input);
1763
- }
1764
-
1765
- this.credentials = options.credentials || this.credentials || 'same-origin';
1766
- if (options.headers || !this.headers) {
1767
- this.headers = new Headers(options.headers);
1768
- }
1769
- this.method = normalizeMethod(options.method || this.method || 'GET');
1770
- this.mode = options.mode || this.mode || null;
1771
- this.signal = options.signal || this.signal;
1772
- this.referrer = null;
1773
-
1774
- if ((this.method === 'GET' || this.method === 'HEAD') && body) {
1775
- throw new TypeError('Body not allowed for GET or HEAD requests')
1776
- }
1777
- this._initBody(body);
1778
- }
1779
-
1780
- Request.prototype.clone = function() {
1781
- return new Request(this, {body: this._bodyInit})
1782
- };
1783
-
1784
- function decode(body) {
1785
- var form = new FormData();
1786
- body
1787
- .trim()
1788
- .split('&')
1789
- .forEach(function(bytes) {
1790
- if (bytes) {
1791
- var split = bytes.split('=');
1792
- var name = split.shift().replace(/\+/g, ' ');
1793
- var value = split.join('=').replace(/\+/g, ' ');
1794
- form.append(decodeURIComponent(name), decodeURIComponent(value));
1795
- }
1796
- });
1797
- return form
1798
- }
1799
-
1800
- function parseHeaders(rawHeaders) {
1801
- var headers = new Headers();
1802
- // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
1803
- // https://tools.ietf.org/html/rfc7230#section-3.2
1804
- var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
1805
- preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
1806
- var parts = line.split(':');
1807
- var key = parts.shift().trim();
1808
- if (key) {
1809
- var value = parts.join(':').trim();
1810
- headers.append(key, value);
1811
- }
1812
- });
1813
- return headers
1814
- }
1815
-
1816
- Body.call(Request.prototype);
1817
-
1818
- function Response(bodyInit, options) {
1819
- if (!options) {
1820
- options = {};
1821
- }
1822
-
1823
- this.type = 'default';
1824
- this.status = options.status === undefined ? 200 : options.status;
1825
- this.ok = this.status >= 200 && this.status < 300;
1826
- this.statusText = 'statusText' in options ? options.statusText : 'OK';
1827
- this.headers = new Headers(options.headers);
1828
- this.url = options.url || '';
1829
- this._initBody(bodyInit);
1830
- }
1831
-
1832
- Body.call(Response.prototype);
1833
-
1834
- Response.prototype.clone = function() {
1835
- return new Response(this._bodyInit, {
1836
- status: this.status,
1837
- statusText: this.statusText,
1838
- headers: new Headers(this.headers),
1839
- url: this.url
1840
- })
1841
- };
1842
-
1843
- Response.error = function() {
1844
- var response = new Response(null, {status: 0, statusText: ''});
1845
- response.type = 'error';
1846
- return response
1847
- };
1848
-
1849
- var redirectStatuses = [301, 302, 303, 307, 308];
1850
-
1851
- Response.redirect = function(url, status) {
1852
- if (redirectStatuses.indexOf(status) === -1) {
1853
- throw new RangeError('Invalid status code')
1854
- }
1855
-
1856
- return new Response(null, {status: status, headers: {location: url}})
1857
- };
1858
-
1859
- exports.DOMException = self.DOMException;
1860
- try {
1861
- new exports.DOMException();
1862
- } catch (err) {
1863
- exports.DOMException = function(message, name) {
1864
- this.message = message;
1865
- this.name = name;
1866
- var error = Error(message);
1867
- this.stack = error.stack;
1868
- };
1869
- exports.DOMException.prototype = Object.create(Error.prototype);
1870
- exports.DOMException.prototype.constructor = exports.DOMException;
1871
- }
1872
-
1873
- function fetch(input, init) {
1874
- return new Promise(function(resolve, reject) {
1875
- var request = new Request(input, init);
1876
-
1877
- if (request.signal && request.signal.aborted) {
1878
- return reject(new exports.DOMException('Aborted', 'AbortError'))
1879
- }
1880
-
1881
- var xhr = new XMLHttpRequest();
1882
-
1883
- function abortXhr() {
1884
- xhr.abort();
1885
- }
1886
-
1887
- xhr.onload = function() {
1888
- var options = {
1889
- status: xhr.status,
1890
- statusText: xhr.statusText,
1891
- headers: parseHeaders(xhr.getAllResponseHeaders() || '')
1892
- };
1893
- options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
1894
- var body = 'response' in xhr ? xhr.response : xhr.responseText;
1895
- resolve(new Response(body, options));
1896
- };
1897
-
1898
- xhr.onerror = function() {
1899
- reject(new TypeError('Network request failed'));
1900
- };
1901
-
1902
- xhr.ontimeout = function() {
1903
- reject(new TypeError('Network request failed'));
1904
- };
1905
-
1906
- xhr.onabort = function() {
1907
- reject(new exports.DOMException('Aborted', 'AbortError'));
1908
- };
1909
-
1910
- xhr.open(request.method, request.url, true);
1911
-
1912
- if (request.credentials === 'include') {
1913
- xhr.withCredentials = true;
1914
- } else if (request.credentials === 'omit') {
1915
- xhr.withCredentials = false;
1916
- }
1917
-
1918
- if ('responseType' in xhr && support.blob) {
1919
- xhr.responseType = 'blob';
1920
- }
1921
-
1922
- request.headers.forEach(function(value, name) {
1923
- xhr.setRequestHeader(name, value);
1924
- });
1925
-
1926
- if (request.signal) {
1927
- request.signal.addEventListener('abort', abortXhr);
1928
-
1929
- xhr.onreadystatechange = function() {
1930
- // DONE (success or failure)
1931
- if (xhr.readyState === 4) {
1932
- request.signal.removeEventListener('abort', abortXhr);
1933
- }
1934
- };
1935
- }
1936
-
1937
- xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
1938
- })
1939
- }
1940
-
1941
- fetch.polyfill = true;
1942
-
1943
- if (!self.fetch) {
1944
- self.fetch = fetch;
1945
- self.Headers = Headers;
1946
- self.Request = Request;
1947
- self.Response = Response;
1948
- }
1949
-
1950
- exports.Headers = Headers;
1951
- exports.Request = Request;
1952
- exports.Response = Response;
1953
- exports.fetch = fetch;
1954
-
1955
- Object.defineProperty(exports, '__esModule', { value: true });
1956
-
1957
- return exports;
1958
-
1959
- })({});
1960
- })(__self__);
1961
- __self__.fetch.ponyfill = true;
1962
- // Remove "polyfill" property added by whatwg-fetch
1963
- delete __self__.fetch.polyfill;
1964
- // Choose between native implementation (global) or custom implementation (__self__)
1965
- // var ctx = global.fetch ? global : __self__;
1966
- var ctx = __self__; // this line disable service worker support temporarily
1967
- exports = ctx.fetch // To enable: import fetch from 'cross-fetch'
1968
- exports["default"] = ctx.fetch // For TypeScript consumers without esModuleInterop.
1969
- exports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'
1970
- exports.Headers = ctx.Headers
1971
- exports.Request = ctx.Request
1972
- exports.Response = ctx.Response
1973
- module.exports = exports
1974
-
1975
-
1976
1415
  /***/ }),
1977
1416
 
1978
1417
  /***/ 8784:
@@ -27757,6 +27196,7 @@ __webpack_require__.d(__webpack_exports__, {
27757
27196
  SecretClient: () => (/* reexport */ SecretClient),
27758
27197
  SocketManager: () => (/* reexport */ SocketManager),
27759
27198
  Squid: () => (/* reexport */ Squid),
27199
+ StorageClient: () => (/* reexport */ StorageClient),
27760
27200
  allEnvironmentIds: () => (/* reexport */ allEnvironmentIds),
27761
27201
  deserializeQuery: () => (/* reexport */ deserializeQuery),
27762
27202
  generateId: () => (/* reexport */ generateId),
@@ -29337,7 +28777,6 @@ class ApiClient {
29337
28777
 
29338
28778
  // EXTERNAL MODULE: ../node_modules/lodash/lodash.js
29339
28779
  var lodash = __webpack_require__(8784);
29340
- var lodash_default = /*#__PURE__*/__webpack_require__.n(lodash);
29341
28780
  // EXTERNAL MODULE: ../node_modules/assertic/dist/index.js
29342
28781
  var dist = __webpack_require__(8975);
29343
28782
  // EXTERNAL MODULE: ../node_modules/rfdc/index.js
@@ -29346,7 +28785,6 @@ var rfdc_default = /*#__PURE__*/__webpack_require__.n(rfdc);
29346
28785
  ;// CONCATENATED MODULE: ../internal-common/src/utils/object.ts
29347
28786
 
29348
28787
 
29349
-
29350
28788
  const SPLIT_REGEX_FOR_GET_IN_PATH = /[.\[\]]/;
29351
28789
  /** Returns a value by the `path`. Works with array indexes, like a.b[0]. */
29352
28790
  function getInPath(obj, path) {
@@ -29384,7 +28822,7 @@ function setInPath(obj, path, value, delimiter = '.') {
29384
28822
  const key = (0,dist.truthy)(splitPath.shift());
29385
28823
  if (splitPath.length) {
29386
28824
  const fieldValue = currentObj[key];
29387
- const newCurrentObj = isJsObject(fieldValue) ? (_a = lodash.clone(fieldValue)) !== null && _a !== void 0 ? _a : {} : {};
28825
+ const newCurrentObj = isJsObject(fieldValue) ? (_a = cloneShallow(fieldValue)) !== null && _a !== void 0 ? _a : {} : {};
29388
28826
  currentObj[key] = newCurrentObj;
29389
28827
  currentObj = newCurrentObj;
29390
28828
  }
@@ -29400,7 +28838,7 @@ function deleteInPath(obj, path, delimiter = '.') {
29400
28838
  while (splitPath.length) {
29401
28839
  const key = (0,dist.truthy)(splitPath.shift());
29402
28840
  if (splitPath.length) {
29403
- const newCurrentObj = isJsObject(currentObj[key]) ? (_a = lodash.clone(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
28841
+ const newCurrentObj = isJsObject(currentObj[key]) ? (_a = cloneShallow(currentObj[key])) !== null && _a !== void 0 ? _a : {} : {};
29404
28842
  currentObj[key] = newCurrentObj;
29405
28843
  currentObj = newCurrentObj;
29406
28844
  }
@@ -29473,17 +28911,19 @@ function isEmpty(a) {
29473
28911
  }
29474
28912
  return false;
29475
28913
  }
29476
- function omit(object, ...paths) {
28914
+ function omit(object, ...fieldsToRemove) {
29477
28915
  if (object === null || object === undefined) {
29478
28916
  return {};
29479
28917
  }
29480
- const result = {};
29481
- const omitKeys = new Set(paths);
29482
- Object.keys(object).forEach(key => {
29483
- if (!omitKeys.has(key)) {
29484
- result[key] = object[key];
28918
+ if (fieldsToRemove.length === 0) {
28919
+ return object;
28920
+ }
28921
+ const result = Object.assign({}, object);
28922
+ for (const fieldToRemove of fieldsToRemove) {
28923
+ if (result.hasOwnProperty(fieldToRemove)) {
28924
+ delete result[fieldToRemove];
29485
28925
  }
29486
- });
28926
+ }
29487
28927
  return result;
29488
28928
  }
29489
28929
  /** Creates a deep copy of the object. Copies all Date, Map, Set fields. */
@@ -29493,19 +28933,85 @@ function cloneDeep(value) {
29493
28933
  // and it cases some tests to fail.
29494
28934
  return rfdc_default()()(value);
29495
28935
  }
28936
+ /** Creates a shallow clone of the object. */
28937
+ function cloneShallow(value) {
28938
+ if (typeof value !== 'object' || value === null)
28939
+ return value;
28940
+ if (value instanceof Date)
28941
+ return new Date(value);
28942
+ if (Array.isArray(value))
28943
+ return [...value];
28944
+ if (value instanceof Map)
28945
+ return new Map(Array.from(value));
28946
+ if (value instanceof Set)
28947
+ return new Set(Array.from(value));
28948
+ return Object.assign({}, value);
28949
+ }
29496
28950
  /** Compares 2 values. 'null' and 'undefined' values are considered equal and are less than any other values. */
29497
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
29498
- function compareValues(a, b) {
29499
- if (a === b || (isNil(a) && isNil(b))) {
28951
+ function compareValues(v1, v2) {
28952
+ if (v1 === v2 || (isNil(v1) && isNil(v2))) {
29500
28953
  return 0;
29501
28954
  }
29502
- else if (isNil(a)) {
28955
+ else if (isNil(v1)) {
29503
28956
  return -1;
29504
28957
  }
29505
- else if (isNil(b)) {
28958
+ else if (isNil(v2)) {
29506
28959
  return 1;
29507
28960
  }
29508
- return a < b ? -1 : a > b ? 1 : 0;
28961
+ const v1Type = typeof v1;
28962
+ const v2Type = typeof v2;
28963
+ if (v1Type !== v2Type) {
28964
+ return v1Type < v2Type ? -1 : 1;
28965
+ }
28966
+ if (typeof v1 === 'number') {
28967
+ (0,dist.assertTruthy)(typeof v2 === 'number');
28968
+ if (isNaN(v1) && isNaN(v2))
28969
+ return 0; // Consider NaNs as equal.
28970
+ if (isNaN(v1))
28971
+ return -1; // NaN is considered less than any number.
28972
+ if (isNaN(v2))
28973
+ return 1; // Any number is considered greater than NaN.
28974
+ return v1 < v2 ? -1 : 1;
28975
+ }
28976
+ if (typeof v1 === 'boolean') {
28977
+ (0,dist.assertTruthy)(typeof v2 === 'boolean');
28978
+ return v1 < v2 ? -1 : 1;
28979
+ }
28980
+ if (typeof v1 === 'bigint') {
28981
+ (0,dist.assertTruthy)(typeof v2 === 'bigint');
28982
+ return v1 < v2 ? -1 : 1;
28983
+ }
28984
+ if (typeof v1 === 'string') {
28985
+ (0,dist.assertTruthy)(typeof v2 === 'string');
28986
+ return v1.localeCompare(v2);
28987
+ }
28988
+ if (v1 instanceof Date && v2 instanceof Date) {
28989
+ return Math.sign(v1.getTime() - v2.getTime());
28990
+ }
28991
+ return 0; // Fallback if types are not comparable.
28992
+ }
28993
+ /** Returns a new object with all top-level object fields re-mapped using `valueMapperFn`. */
28994
+ function mapValues(obj, valueMapperFn) {
28995
+ const result = {};
28996
+ const keys = Object.keys(obj);
28997
+ for (const key of keys) {
28998
+ const value = obj[key];
28999
+ result[key] = valueMapperFn(value, key, obj);
29000
+ }
29001
+ return result;
29002
+ }
29003
+ /** Groups elements of the array by key. See _.groupBy for details. */
29004
+ function groupBy(array, getKey) {
29005
+ return array.reduce((result, item) => {
29006
+ const key = getKey(item);
29007
+ if (!result[key]) {
29008
+ result[key] = [item];
29009
+ }
29010
+ else {
29011
+ result[key].push(item);
29012
+ }
29013
+ return result;
29014
+ }, {});
29509
29015
  }
29510
29016
 
29511
29017
  ;// CONCATENATED MODULE: ../internal-common/src/utils/serialization.ts
@@ -29593,14 +29099,14 @@ class ApiManager {
29593
29099
  this.clientIdService = clientIdService;
29594
29100
  this.rpcManager = rpcManager;
29595
29101
  }
29596
- callApiAndSubscribe(integrationId, endpointId, request, options) {
29102
+ callApiAndSubscribe(integrationId, endpointId, request, options, file) {
29597
29103
  const callApiRequest = {
29598
29104
  integrationId,
29599
29105
  endpointId,
29600
29106
  request,
29601
29107
  options,
29602
29108
  };
29603
- return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post('api/call', callApiRequest)).pipe(map(response => {
29109
+ return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post('api/call', callApiRequest, file ? [file] : undefined, file ? 'file' : undefined)).pipe(map(response => {
29604
29110
  const parsedPayload = response.payload ? deserializeObj(response.payload) : undefined;
29605
29111
  if (response.success) {
29606
29112
  return parsedPayload;
@@ -29672,13 +29178,23 @@ class BackendFunctionManager {
29672
29178
  this.rpcManager = rpcManager;
29673
29179
  }
29674
29180
  executeFunctionAndSubscribe(functionName, ...params) {
29181
+ const fileArr = [];
29182
+ const paramArr = [];
29183
+ params.forEach(param => {
29184
+ if (typeof File !== 'undefined' && param instanceof File) {
29185
+ fileArr.push(param);
29186
+ }
29187
+ else {
29188
+ paramArr.push(param);
29189
+ }
29190
+ });
29675
29191
  const request = {
29676
29192
  functionName,
29677
- paramsArrayStr: serializeObj(params),
29193
+ paramsArrayStr: serializeObj(paramArr),
29678
29194
  };
29679
29195
  // Append '?functionName' suffix to every POST request for visibility in the browser's 'Network' tab.
29680
29196
  const postUrl = `backend-function/execute?${encodeURIComponent(functionName)}`;
29681
- return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post(postUrl, request)).pipe(map(response => {
29197
+ return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post(postUrl, request, fileArr.length > 0 ? fileArr : [])).pipe(map(response => {
29682
29198
  if (!response.success) {
29683
29199
  throw new Error(response.payload);
29684
29200
  }
@@ -30086,6 +29602,8 @@ var IntegrationType;
30086
29602
  IntegrationType["kafka"] = "kafka";
30087
29603
  IntegrationType["confluent"] = "confluent";
30088
29604
  IntegrationType["built_in_queue"] = "built_in_queue";
29605
+ IntegrationType["s3"] = "s3";
29606
+ IntegrationType["built_in_s3"] = "built_in_s3";
30089
29607
  // Coming Soon
30090
29608
  IntegrationType["algolia"] = "algolia";
30091
29609
  IntegrationType["elastic_observability"] = "elastic_observability";
@@ -30269,15 +29787,54 @@ function isStringMatch(str, pattern, caseSensitive) {
30269
29787
  str = str.toLowerCase();
30270
29788
  pattern = pattern.toLowerCase();
30271
29789
  }
30272
- // Escape special regex characters in the pattern
30273
- const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
30274
- // Replace '%' wildcard with regex equivalent
30275
- // Note: this allows for newlines, unlike .*
30276
- const regexPattern = escapedPattern.replace(/%/g, '[\\s\\S]*');
29790
+ const regexPattern = replaceSpecialCharacters(pattern);
30277
29791
  // Create regex object and test if string matches
30278
29792
  const regex = new RegExp(`^${regexPattern}$`);
30279
29793
  return regex.test(str);
30280
29794
  }
29795
+ /**
29796
+ * Generates the regex pattern, handling special characters as follows:
29797
+ * - `_` is replaced with a `.`
29798
+ * - `%` is replaced with `[\s\S]*`.
29799
+ * - The above characters can be escaped with \, eg. `\_` is replaced with `_` and `\%` with `%`.
29800
+ * - All special characters in regex (-, /, \, ^, $, *, +, ?, ., (, ), |, [, ], {, }) get escaped with \
29801
+ *
29802
+ * Exported for testing purposes.
29803
+ * */
29804
+ function replaceSpecialCharacters(input) {
29805
+ let result = '';
29806
+ for (let i = 0; i < input.length; ++i) {
29807
+ if (input[i] === '\\') {
29808
+ if (i + 1 < input.length && ['%', '_'].includes(input[i + 1])) {
29809
+ result += input[i + 1];
29810
+ i++;
29811
+ }
29812
+ else if (i + 1 < input.length && input[i + 1] === '\\') {
29813
+ result += '\\\\';
29814
+ i++;
29815
+ }
29816
+ else {
29817
+ result += '\\';
29818
+ }
29819
+ }
29820
+ else if (input[i] === '%') {
29821
+ // Replace '%' wildcard with regex equivalent. Note: this allows for newlines, unlike .*
29822
+ result += '[\\s\\S]*';
29823
+ }
29824
+ else if (input[i] === '_') {
29825
+ result += '[\\s\\S]';
29826
+ }
29827
+ else {
29828
+ // Escape special regex characters in the pattern
29829
+ // '\' is checked above and needs to be manually escaped by the user
29830
+ if ('/-\\^$*+?.()[]{}|'.includes(input[i])) {
29831
+ result += '\\';
29832
+ }
29833
+ result += input[i];
29834
+ }
29835
+ }
29836
+ return result;
29837
+ }
30281
29838
  /**
30282
29839
  * Returns a unique identifier for the query which includes both the client id and the client request id.
30283
29840
  * @internal
@@ -30602,6 +30159,7 @@ var ClientConnectionState;
30602
30159
 
30603
30160
 
30604
30161
 
30162
+
30605
30163
 
30606
30164
 
30607
30165
  ;// CONCATENATED MODULE: ../internal-common/src/utils/assert.ts
@@ -31108,7 +30666,6 @@ class Pagination {
31108
30666
 
31109
30667
 
31110
30668
 
31111
-
31112
30669
  /** @internal */
31113
30670
  class QueryBuilderFactory {
31114
30671
  constructor(querySubscriptionManager, localQueryManager, documentReferenceFactory, documentIdentityService) {
@@ -31218,24 +30775,32 @@ class BaseQueryBuilder {
31218
30775
  * A shortcut for where(fieldName, 'like', pattern).
31219
30776
  *
31220
30777
  * @param fieldName The name of the field to query.
31221
- * @param pattern The pattern to compare against. '%' is the only allowed wildcard
30778
+ * @param pattern The pattern to compare against. '%' matches 0 or more wildcard characters. '_' matches exactly one wildcard character. '\' can be used to escape '%', '_'. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid.
31222
30779
  * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
31223
30780
  * @returns The query builder.
31224
30781
  */
31225
30782
  like(fieldName, pattern, caseSensitive) {
30783
+ this.throwIfInvalidLikePattern(pattern);
31226
30784
  return this.where(fieldName, caseSensitive ? 'like_cs' : 'like', pattern);
31227
30785
  }
31228
30786
  /**
31229
30787
  * A shortcut for where(fieldName, 'not like', pattern).
31230
30788
  *
31231
30789
  * @param fieldName The name of the field to query.
31232
- * @param pattern The pattern to compare against. '%' is the only allowed wildcard
30790
+ * @param pattern The pattern to compare against. '%' matches 0 or more wildcard characters. '_' matches exactly one wildcard character. '\' can be used to escape '%', '_'. or another '\'. Note that any '\' that is not followed by '%', '_', or '\' is invalid.
31233
30791
  * @param caseSensitive Whether to use case-sensitive comparison. Defaults to true.
31234
30792
  * @returns The query builder.
31235
30793
  */
31236
30794
  notLike(fieldName, pattern, caseSensitive) {
30795
+ this.throwIfInvalidLikePattern(pattern);
31237
30796
  return this.where(fieldName, caseSensitive ? 'not like_cs' : 'not like', pattern);
31238
30797
  }
30798
+ throwIfInvalidLikePattern(pattern) {
30799
+ const invalidBackslash = /\\(?![%_\\])/;
30800
+ if (invalidBackslash.test(pattern)) {
30801
+ throw new Error(`Invalid pattern. Cannot have any \\ which are not followed by _, % or \\`);
30802
+ }
30803
+ }
31239
30804
  }
31240
30805
  /** @internal */
31241
30806
  class DereferenceEmitter {
@@ -31368,15 +30933,16 @@ class QueryBuilder extends BaseQueryBuilder {
31368
30933
  mergeConditions() {
31369
30934
  const simpleConditions = this.query.conditions.filter(isSimpleCondition);
31370
30935
  const result = [];
31371
- const groupByFieldName = lodash.groupBy(simpleConditions || [], condition => condition.fieldName);
30936
+ const groupByFieldName = groupBy(simpleConditions || [], condition => condition.fieldName);
31372
30937
  for (const fieldNameGroup of Object.values(groupByFieldName)) {
31373
- const groupByOperator = lodash.groupBy(fieldNameGroup, operator => operator.operator);
30938
+ const groupByOperator = groupBy(fieldNameGroup, operator => operator.operator);
31374
30939
  for (const [operator, operatorGroup] of Object.entries(groupByOperator)) {
31375
30940
  if (operator === '==' || operator === '!=') {
31376
30941
  result.push(...operatorGroup);
31377
30942
  continue;
31378
30943
  }
31379
- const sorted = lodash.sortBy(operatorGroup, o => o.value);
30944
+ const sorted = [...operatorGroup];
30945
+ sorted.sort((o1, o2) => compareValues(o1.value, o2.value));
31380
30946
  if (operator === '>' || operator === '>=') {
31381
30947
  result.push(sorted[sorted.length - 1]);
31382
30948
  }
@@ -31567,7 +31133,6 @@ class Changes {
31567
31133
 
31568
31134
 
31569
31135
 
31570
-
31571
31136
  /**
31572
31137
  * A query builder that can participate in a join.
31573
31138
  * To learn more about join queries, see the
@@ -31735,13 +31300,9 @@ class DereferencedJoin {
31735
31300
  }
31736
31301
  /** @inheritDoc */
31737
31302
  snapshots(subscribe) {
31738
- return this.joinQueryBuilder.snapshots(subscribe).pipe(map(docs => {
31739
- return docs.map(doc => {
31740
- return lodash.mapValues(doc, doc1 => {
31741
- return doc1 === null || doc1 === void 0 ? void 0 : doc1.data;
31742
- });
31743
- });
31744
- }));
31303
+ return this.joinQueryBuilder
31304
+ .snapshots(subscribe)
31305
+ .pipe(map(docs => docs.map(doc => mapValues(doc, fieldDoc => fieldDoc === null || fieldDoc === void 0 ? void 0 : fieldDoc.data))));
31745
31306
  }
31746
31307
  /**
31747
31308
  * @inheritDoc
@@ -31879,7 +31440,7 @@ class GroupedJoin {
31879
31440
  return new DereferencedGroupedJoin(this);
31880
31441
  }
31881
31442
  groupData(input, rootAlias) {
31882
- const oneLevelGroup = lodash.groupBy(input, inputRow => { var _a; return (_a = inputRow[rootAlias]) === null || _a === void 0 ? void 0 : _a.squidDocId; });
31443
+ const oneLevelGroup = groupBy(input, inputRow => { var _a; return (_a = inputRow[rootAlias]) === null || _a === void 0 ? void 0 : _a.squidDocId; });
31883
31444
  return Object.values(oneLevelGroup)
31884
31445
  .filter(value => {
31885
31446
  return value[0][rootAlias] !== undefined;
@@ -32236,7 +31797,6 @@ var promise_pool_dist = __webpack_require__(3910);
32236
31797
 
32237
31798
 
32238
31799
 
32239
-
32240
31800
  function applyStringFn(initialValue, propertyMutation) {
32241
31801
  switch (propertyMutation.fn) {
32242
31802
  case 'trim':
@@ -32268,7 +31828,7 @@ function applyPropertyMutation(property, propertyMutation) {
32268
31828
  case 'applyStringFn':
32269
31829
  return applyStringFn(property, propertyMutation);
32270
31830
  case 'update':
32271
- return typeof propertyMutation.value === 'object' ? lodash.cloneDeep(propertyMutation.value) : propertyMutation.value;
31831
+ return typeof propertyMutation.value === 'object' ? cloneDeep(propertyMutation.value) : propertyMutation.value;
32272
31832
  case 'removeProperty':
32273
31833
  return undefined;
32274
31834
  default:
@@ -32351,18 +31911,6 @@ function applyUpdateMutation(doc, updateMutation) {
32351
31911
  }
32352
31912
  return result;
32353
31913
  }
32354
- /** @internal */
32355
- function convertInsertToUpdate(insertMutation) {
32356
- const result = {
32357
- type: 'update',
32358
- squidDocIdObj: insertMutation.squidDocIdObj,
32359
- properties: {},
32360
- };
32361
- for (const [key, value] of Object.entries(insertMutation.properties)) {
32362
- result.properties[key] = [{ type: 'update', value }];
32363
- }
32364
- return result;
32365
- }
32366
31914
  /**
32367
31915
  * Reduces the list of mutations such that each document will have a single mutation. If for example there are multiple
32368
31916
  * updates to the same document, those will be merged and a single update will be returned.
@@ -33172,6 +32720,9 @@ class DistributedLockManager {
33172
32720
  },
33173
32721
  };
33174
32722
  })), this.acquireLockMessagesFromServer.pipe((0,external_rxjs_.filter)(message => message.payload.clientRequestId === clientRequestId))));
32723
+ if (this.destructManager.isDestructing) {
32724
+ throw new Error('Destructing');
32725
+ }
33175
32726
  if (!result.payload.lockId) {
33176
32727
  throw new Error(`Failed to acquire lock: ${result.payload.error}`);
33177
32728
  }
@@ -33587,7 +33138,6 @@ class DocumentReferenceFactory {
33587
33138
 
33588
33139
 
33589
33140
 
33590
-
33591
33141
  class DocumentStore {
33592
33142
  constructor() {
33593
33143
  this.squidDocIdToDoc = new Map();
@@ -33635,9 +33185,7 @@ class DocumentStore {
33635
33185
  return 0;
33636
33186
  }
33637
33187
  group(sortedDocs, sortFieldNames) {
33638
- return Object.values(lodash_default().groupBy(sortedDocs, doc => {
33639
- return normalizeJsonAsString(sortFieldNames.map(fieldName => getInPath(doc, fieldName)));
33640
- }));
33188
+ return Object.values(groupBy(sortedDocs, doc => normalizeJsonAsString(sortFieldNames.map(fieldName => getInPath(doc, fieldName)))));
33641
33189
  }
33642
33190
  sortAndLimitDocs(docIdSet, query) {
33643
33191
  if (docIdSet.size === 0) {
@@ -49553,9 +49101,6 @@ var extras = {
49553
49101
  gql["default"] = gql;
49554
49102
  /* harmony default export */ const graphql_tag_lib = ((/* unused pure expression or super */ null && (gql)));
49555
49103
  //# sourceMappingURL=index.js.map
49556
- // EXTERNAL MODULE: ../node_modules/cross-fetch/dist/browser-ponyfill.js
49557
- var browser_ponyfill = __webpack_require__(9372);
49558
- var browser_ponyfill_default = /*#__PURE__*/__webpack_require__.n(browser_ponyfill);
49559
49104
  ;// CONCATENATED MODULE: ../internal-common/src/utils/http.ts
49560
49105
  const kotlinControllers = [
49561
49106
  'query',
@@ -49573,6 +49118,7 @@ const kotlinControllers = [
49573
49118
  'queue',
49574
49119
  'mutation',
49575
49120
  'application',
49121
+ 'storage',
49576
49122
  ];
49577
49123
  function getApplicationUrl(regionPrefix, appId, path) {
49578
49124
  const baseUrl = 'https://squid.cloud';
@@ -49611,47 +49157,9 @@ function isIOS(regionPrefix) {
49611
49157
  return /ios$/.test(regionPrefix);
49612
49158
  }
49613
49159
 
49614
- ;// CONCATENATED MODULE: ../internal-common/src/utils/squid-private-options.ts
49615
-
49616
- function squid_private_options_getGlobal() {
49617
- if (typeof window !== 'undefined') {
49618
- return window;
49619
- }
49620
- else if (typeof __webpack_require__.g !== 'undefined') {
49621
- return __webpack_require__.g;
49622
- }
49623
- else if (typeof self !== 'undefined') {
49624
- return self;
49625
- }
49626
- (0,dist.fail)('Failed to get global context');
49627
- }
49628
- function getSquidPrivateOptions() {
49629
- const globalScope = squid_private_options_getGlobal();
49630
- let privateOptions = globalScope['__squidPrivateOptions'];
49631
- if (!privateOptions) {
49632
- privateOptions = {};
49633
- globalScope['__squidPrivateOptions'] = privateOptions;
49634
- }
49635
- return privateOptions;
49636
- }
49637
- function setSquidPrivateOption(optionName, value) {
49638
- getSquidPrivateOptions()[optionName] = value;
49639
- }
49640
- function getSquidPrivateOption(optionName) {
49641
- return getSquidPrivateOptions()[optionName];
49642
- }
49643
- /**
49644
- * When set to 'true' (boolean), the Graphql client in Squid uses new 'fetch' based
49645
- * HTTP client instead of cross-fetch library.
49646
- * The option will be removed after the migration is tested and all issues are fixed.
49647
- */
49648
- const SQUID_PRIVATE_OPTION_USE_FETCH_IN_GRAPHQL_CLIENT = 'useFetchInGraphqlClient';
49649
-
49650
49160
  ;// CONCATENATED MODULE: ./src/graphql-client.ts
49651
49161
 
49652
49162
 
49653
-
49654
-
49655
49163
  /** A GraphQL client that can be used to query and mutate data. */
49656
49164
  class GraphQLClient {
49657
49165
  /** @internal */
@@ -49660,13 +49168,10 @@ class GraphQLClient {
49660
49168
  this.region = region;
49661
49169
  this.appId = appId;
49662
49170
  const url = getApplicationUrl(this.region, this.appId, `${integrationId}/graphql`);
49663
- const forceFetch = Date.now() > 0; // TODO: remove this after testing with GA.
49664
- const fetchImpl = getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_GRAPHQL_CLIENT) || forceFetch ? fetch : (browser_ponyfill_default());
49665
49171
  this.client = new ApolloClient({
49666
49172
  link: new HttpLink({
49667
49173
  uri: url,
49668
49174
  headers: this.rpcManager.getStaticHeaders(),
49669
- fetch: fetchImpl,
49670
49175
  }),
49671
49176
  cache: new InMemoryCache(),
49672
49177
  });
@@ -51193,7 +50698,7 @@ async function performFetchRequest({ headers, files, filesFieldName, message: bo
51193
50698
  };
51194
50699
  }
51195
50700
  catch (e) {
51196
- console.error(`Unable to perform fetch request to url: ${url}`, e);
50701
+ DebugLogger.debug(`Unable to perform fetch request to url: ${url}`, e);
51197
50702
  throw e;
51198
50703
  }
51199
50704
  }
@@ -51495,11 +51000,13 @@ class SocketManager {
51495
51000
  }))
51496
51001
  .subscribe(() => {
51497
51002
  if (this.connectionReady.value) {
51498
- DebugLogger.debug(`Client reconnected before becoming too old. Ignoring... ${this.clientIdService.getClientId()}`);
51003
+ DebugLogger.debug(this.clientIdService.getClientId(), `Client reconnected before becoming too old. Ignoring...`);
51499
51004
  return;
51500
51005
  }
51501
- DebugLogger.debug(`Client disconnected for a long period - refreshing ${this.clientIdService.getClientId()}`);
51502
- this.refreshClient();
51006
+ if (!this.destructManager.isDestructing) {
51007
+ DebugLogger.debug(this.clientIdService.getClientId(), `Client disconnected for a long period - refreshing`);
51008
+ this.refreshClient();
51009
+ }
51503
51010
  });
51504
51011
  this.observeConnectionReady()
51505
51012
  .pipe((0,external_rxjs_.filter)(Boolean))
@@ -51511,22 +51018,22 @@ class SocketManager {
51511
51018
  }
51512
51019
  refreshClient() {
51513
51020
  if (this.destructManager.isDestructing) {
51514
- DebugLogger.debug(`Client too old but is destructed. Ignoring... ${this.clientIdService.getClientId()}`);
51021
+ DebugLogger.debug(this.clientIdService.getClientId(), `Client too old but is destructed. Ignoring...`);
51515
51022
  return;
51516
51023
  }
51517
51024
  else if (this.clientIdService.isClientTooOld()) {
51518
- DebugLogger.debug(`Client is already marked as too old. Ignoring... ${this.clientIdService.getClientId()}`);
51025
+ DebugLogger.debug(this.clientIdService.getClientId(), `Client is already marked as too old. Ignoring...`);
51519
51026
  return;
51520
51027
  }
51521
- DebugLogger.debug(`Notifying client too old ${this.clientIdService.getClientId()}`);
51028
+ DebugLogger.debug(this.clientIdService.getClientId(), `Notifying client too old`);
51522
51029
  this.clientIdService.notifyClientTooOld();
51523
- DebugLogger.debug('Client too old. Reconnecting...');
51030
+ DebugLogger.debug(this.clientIdService.getClientId(), 'Client too old. Reconnecting...');
51524
51031
  this.connect();
51525
51032
  }
51526
51033
  tick() {
51527
51034
  const diff = Math.abs(Date.now() - this.lastTick.getTime());
51528
51035
  if (diff > this.clientTooOldThreshold) {
51529
- DebugLogger.debug('Tick: Client not responding for a long time. Refreshing...', this.clientIdService.getClientId());
51036
+ DebugLogger.debug(this.clientIdService.getClientId(), 'Tick: Client not responding for a long time. Refreshing...');
51530
51037
  this.refreshClient();
51531
51038
  }
51532
51039
  this.lastTick = new Date();
@@ -51551,7 +51058,9 @@ class SocketManager {
51551
51058
  }
51552
51059
  try {
51553
51060
  (0,dist.assertTruthy)(this.socket, 'Socket is undefined in sendMessageAsync');
51554
- this.socket.send(serializeObj({ message, authToken }));
51061
+ const serializedMessage = serializeObj({ message, authToken });
51062
+ DebugLogger.debug(this.clientIdService.getClientId(), 'Sending message to socket: ', serializedMessage);
51063
+ this.socket.send(serializedMessage);
51555
51064
  }
51556
51065
  catch (e) {
51557
51066
  if (!((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connected)) {
@@ -51582,18 +51091,18 @@ class SocketManager {
51582
51091
  .replace('https', 'wss')
51583
51092
  .replace('http', 'ws');
51584
51093
  const clientId = this.clientIdService.getClientId();
51585
- DebugLogger.debug('Connecting to socket at:', endpoint, 'clientId:', clientId);
51094
+ DebugLogger.debug(this.clientIdService.getClientId(), 'Connecting to socket at:', endpoint);
51586
51095
  const socketUri = `${endpoint}?clientId=${clientId}`;
51587
51096
  this.socket = createWebSocketWrapper(socketUri, {
51588
51097
  timeout: 5000, // 5 seconds
51589
51098
  onmessage: (e) => this.onMessage(e.data),
51590
51099
  onopen: () => {
51591
- DebugLogger.debug(`Connection to socket established. Endpoint: ${endpoint} ${this.clientIdService.getClientId()}`);
51100
+ DebugLogger.debug(this.clientIdService.getClientId(), `Connection to socket established. Endpoint: ${endpoint}`);
51592
51101
  },
51593
51102
  onreconnect: () => {
51594
- DebugLogger.debug(`WebSocket reconnect event triggered ${clientId}`);
51103
+ DebugLogger.debug(clientId, `WebSocket reconnect event triggered`);
51595
51104
  if (this.clientIdService.getClientId() !== clientId) {
51596
- DebugLogger.debug(`WebSocket reconnect event triggered - ignored because the client id changed. Old: ${clientId}, new: ${this.clientIdService.getClientId()}`);
51105
+ DebugLogger.debug(clientId, `WebSocket reconnect event triggered - ignored because the client id changed. Old: ${this.clientIdService.getClientId()}`);
51597
51106
  return;
51598
51107
  }
51599
51108
  if (this.connectionReady.value) {
@@ -51601,9 +51110,9 @@ class SocketManager {
51601
51110
  }
51602
51111
  },
51603
51112
  onclose: () => {
51604
- DebugLogger.debug(`WebSocket onclose event triggered ${clientId}`);
51113
+ DebugLogger.debug(clientId, `WebSocket onclose event triggered`);
51605
51114
  if (this.clientIdService.getClientId() !== clientId) {
51606
- DebugLogger.debug(`WebSocket onclose event triggered - ignored because the client id changed. Old: ${clientId}, new: ${this.clientIdService.getClientId()}`);
51115
+ DebugLogger.debug(clientId, `WebSocket onclose event triggered - ignored because the client id changed. new: ${this.clientIdService.getClientId()}`);
51607
51116
  return;
51608
51117
  }
51609
51118
  if (this.connectionReady.value) {
@@ -51624,7 +51133,7 @@ class SocketManager {
51624
51133
  }
51625
51134
  onMessage(messagesStr) {
51626
51135
  if (messagesStr === 'connectionReady') {
51627
- DebugLogger.debug(`Got socket message: connectionReady ${this.clientIdService.getClientId()}`);
51136
+ DebugLogger.debug(this.clientIdService.getClientId(), `Got socket message: connectionReady`);
51628
51137
  this.onConnectionReady();
51629
51138
  return;
51630
51139
  }
@@ -51635,7 +51144,7 @@ class SocketManager {
51635
51144
  continue;
51636
51145
  }
51637
51146
  this.seenMessageIds.add(message.messageId);
51638
- DebugLogger.debug(new Date(), `Got socket message: (${this.clientIdService.getClientId()})`, JSON.stringify(message, null, 2));
51147
+ DebugLogger.debug(this.clientIdService.getClientId(), new Date(), `Got socket message`, JSON.stringify(message, null, 2));
51639
51148
  this.messageNotificationWrapper(() => {
51640
51149
  this.webSocketObserver.next(message);
51641
51150
  });
@@ -51717,6 +51226,55 @@ function omitSquidDevId(appId) {
51717
51226
  return appIdWithEnvironmentId(parsedAppId.appId, parsedAppId.environmentId);
51718
51227
  }
51719
51228
 
51229
+ ;// CONCATENATED MODULE: ./src/storage-client.ts
51230
+ class StorageClient {
51231
+ /** @internal */
51232
+ constructor(integrationId = 'built_in_storage', rpcManager) {
51233
+ this.integrationId = integrationId;
51234
+ this.rpcManager = rpcManager;
51235
+ }
51236
+ async uploadFile(pathInBucket, file, expirationInSeconds) {
51237
+ const request = {
51238
+ integrationId: this.integrationId,
51239
+ pathInBucket,
51240
+ expirationInSeconds,
51241
+ };
51242
+ await this.rpcManager.post('storage/uploadFile', request, [file]);
51243
+ }
51244
+ async getFileMetadata(pathInBucket) {
51245
+ const request = {
51246
+ integrationId: this.integrationId,
51247
+ pathInBucket,
51248
+ };
51249
+ return await this.rpcManager.post('storage/getFileMetadata', request);
51250
+ }
51251
+ async getDownloadUrl(pathInBucket, urlExpirationInSeconds) {
51252
+ const request = {
51253
+ integrationId: this.integrationId,
51254
+ pathInBucket,
51255
+ urlExpirationInSeconds,
51256
+ };
51257
+ return await this.rpcManager.post('storage/getDownloadUrl', request);
51258
+ }
51259
+ async listDirectoryContents(pathInBucket) {
51260
+ const request = {
51261
+ integrationId: this.integrationId,
51262
+ pathInBucket,
51263
+ };
51264
+ return await this.rpcManager.post('storage/listDirectoryContents', request);
51265
+ }
51266
+ async deleteFile(pathInBucket) {
51267
+ await this.deleteFiles([pathInBucket]);
51268
+ }
51269
+ async deleteFiles(pathsInBucket) {
51270
+ const request = {
51271
+ integrationId: this.integrationId,
51272
+ pathsInBucket,
51273
+ };
51274
+ await this.rpcManager.post('storage/deleteFiles', request);
51275
+ }
51276
+ }
51277
+
51720
51278
  ;// CONCATENATED MODULE: ./src/squid.ts
51721
51279
 
51722
51280
 
@@ -51749,6 +51307,7 @@ function omitSquidDevId(appId) {
51749
51307
 
51750
51308
 
51751
51309
 
51310
+
51752
51311
 
51753
51312
 
51754
51313
  /**
@@ -51923,12 +51482,13 @@ class Squid {
51923
51482
  * @param endpointId The id of the endpoint in the API integration.
51924
51483
  * @param request The request parameters to pass to the API.
51925
51484
  * @param options optional options for the API call.
51485
+ * @param file optional file to pass in as part of the API
51926
51486
  * @returns A promise that resolves with the response of the API.
51927
51487
  * @typeParam T The type of the response of the API.
51928
51488
  */
51929
- callApi(integrationId, endpointId, request = {}, options) {
51489
+ callApi(integrationId, endpointId, request = {}, options, file) {
51930
51490
  this._validateNotDestructed();
51931
- return (0,external_rxjs_.firstValueFrom)(this.apiManager.callApiAndSubscribe(integrationId, endpointId, request, options || {}));
51491
+ return (0,external_rxjs_.firstValueFrom)(this.apiManager.callApiAndSubscribe(integrationId, endpointId, request, options || {}, file));
51932
51492
  }
51933
51493
  /**
51934
51494
  * Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
@@ -51955,6 +51515,10 @@ class Squid {
51955
51515
  this._validateNotDestructed();
51956
51516
  return this.apiClient;
51957
51517
  }
51518
+ storage(integrationId = 'built_in_storage') {
51519
+ this._validateNotDestructed();
51520
+ return new StorageClient(integrationId, this.rpcManager);
51521
+ }
51958
51522
  get secrets() {
51959
51523
  return this.secretClient;
51960
51524
  }
@@ -51969,6 +51533,23 @@ class Squid {
51969
51533
  this._validateNotDestructed();
51970
51534
  return this.distributedLockManager.lock(mutex);
51971
51535
  }
51536
+ /**
51537
+ * Executes the given callback while holding a lock for the given mutex. The lock will be released when the callback
51538
+ * finishes.
51539
+ * @param mutex A string that uniquely identifies the lock.
51540
+ * @param fn The callback to execute while holding the lock.
51541
+ * @returns A promise that resolves with the result of the callback. The promise will reject if failed
51542
+ * to acquire the lock.
51543
+ */
51544
+ async withLock(mutex, fn) {
51545
+ const lock = await this.acquireLock(mutex);
51546
+ try {
51547
+ return await fn(lock);
51548
+ }
51549
+ finally {
51550
+ void lock.release();
51551
+ }
51552
+ }
51972
51553
  /**
51973
51554
  * Returns a queue manager for the given topic name and integration id. Using the queue manager you can consume and
51974
51555
  * produce messages
@@ -52050,6 +51631,7 @@ Squid.squidInstancesMap = {};
52050
51631
 
52051
51632
 
52052
51633
 
51634
+
52053
51635
 
52054
51636
 
52055
51637
  })();