@squidcloud/client 1.0.175 → 1.0.177
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 +186 -129
- package/dist/internal-common/src/public-types/api-call.public-context.d.ts +17 -1
- package/dist/internal-common/src/public-types/bundle-api.public-types.d.ts +50 -0
- package/dist/internal-common/src/utils/object.d.ts +1 -0
- package/dist/typescript-client/src/ai-assistant-client.d.ts +1 -1
- package/dist/typescript-client/src/ai-chatbot-client.d.ts +2 -2
- package/dist/typescript-client/src/api.manager.d.ts +3 -4
- package/dist/typescript-client/src/rpc.manager.d.ts +0 -8
- package/dist/typescript-client/src/squid-http-client.d.ts +1 -0
- package/dist/typescript-client/src/squid.d.ts +7 -21
- package/package.json +3 -2
package/dist/cjs/index.js
CHANGED
|
@@ -27525,7 +27525,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27525
27525
|
deserializeQuery: () => (/* reexport */ deserializeQuery),
|
|
27526
27526
|
generateId: () => (/* reexport */ generateId),
|
|
27527
27527
|
generateShortId: () => (/* reexport */ generateShortId),
|
|
27528
|
-
isSimpleCondition: () => (/* reexport */ isSimpleCondition)
|
|
27528
|
+
isSimpleCondition: () => (/* reexport */ isSimpleCondition),
|
|
27529
|
+
limiterConfigToOptions: () => (/* reexport */ limiterConfigToOptions)
|
|
27529
27530
|
});
|
|
27530
27531
|
|
|
27531
27532
|
// EXTERNAL MODULE: external "rxjs"
|
|
@@ -28730,7 +28731,7 @@ class AiChatbotContextReference {
|
|
|
28730
28731
|
* Updates an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
|
|
28731
28732
|
* been created for the current context id.
|
|
28732
28733
|
*
|
|
28733
|
-
* @param data An object containing options for
|
|
28734
|
+
* @param data An object containing options for updating the entry.
|
|
28734
28735
|
* @param data.title - The title of the entry.
|
|
28735
28736
|
* @param data.context - The context data.
|
|
28736
28737
|
* @returns A promise that resolves when the context is successfully updated.
|
|
@@ -28803,7 +28804,7 @@ class AiChatbotInstructionReference {
|
|
|
28803
28804
|
* Updates an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
|
|
28804
28805
|
* yet been created for the current instruction id.
|
|
28805
28806
|
*
|
|
28806
|
-
* @param data An object containing options for
|
|
28807
|
+
* @param data An object containing options for updating the entry.
|
|
28807
28808
|
* @param data.instruction - The instruction data.
|
|
28808
28809
|
* @returns A promise that resolves when the instruction is successfully updated.
|
|
28809
28810
|
*/
|
|
@@ -28886,7 +28887,7 @@ class ApiCallContext {
|
|
|
28886
28887
|
this.body = prototype.body;
|
|
28887
28888
|
this.queryParams = prototype.queryParams;
|
|
28888
28889
|
this.pathParams = prototype.pathParams;
|
|
28889
|
-
this.
|
|
28890
|
+
this.options = prototype.options;
|
|
28890
28891
|
}
|
|
28891
28892
|
}
|
|
28892
28893
|
|
|
@@ -29087,6 +29088,51 @@ class BaseQueryBuilder {
|
|
|
29087
29088
|
}
|
|
29088
29089
|
}
|
|
29089
29090
|
|
|
29091
|
+
;// CONCATENATED MODULE: ../internal-common/src/public-types/bundle-api.public-types.ts
|
|
29092
|
+
/**
|
|
29093
|
+
* Convert LimiterConfig to LimiterOptions.
|
|
29094
|
+
*
|
|
29095
|
+
* This decouples the required syntax for the developer from the internal implementation.
|
|
29096
|
+
*
|
|
29097
|
+
* @param config LimiterConfig to convert.
|
|
29098
|
+
*/
|
|
29099
|
+
function limiterConfigToOptions(config) {
|
|
29100
|
+
// Deal with rateLimit if provided.
|
|
29101
|
+
if (config.rateLimit !== undefined) {
|
|
29102
|
+
// Check if rateLimit is of type number and convert to RateLimitOptions.
|
|
29103
|
+
if (typeof config.rateLimit === 'number') {
|
|
29104
|
+
config.rateLimit = [{ value: config.rateLimit, scope: 'global' }];
|
|
29105
|
+
}
|
|
29106
|
+
else if (typeof config.rateLimit === 'object' && !Array.isArray(config.rateLimit)) {
|
|
29107
|
+
config.rateLimit = [config.rateLimit];
|
|
29108
|
+
}
|
|
29109
|
+
// Set defaults if not provided for each item in rateLimit and quotaLimit.
|
|
29110
|
+
config.rateLimit.forEach((options) => {
|
|
29111
|
+
if (options.scope === undefined) {
|
|
29112
|
+
options.scope = 'global';
|
|
29113
|
+
}
|
|
29114
|
+
});
|
|
29115
|
+
}
|
|
29116
|
+
// Same for quotaLimit.
|
|
29117
|
+
if (config.quotaLimit !== undefined) {
|
|
29118
|
+
if (typeof config.quotaLimit === 'number') {
|
|
29119
|
+
config.quotaLimit = [{ value: config.quotaLimit, scope: 'global', renewPeriod: 'monthly' }];
|
|
29120
|
+
}
|
|
29121
|
+
else if (typeof config.quotaLimit === 'object' && !Array.isArray(config.quotaLimit)) {
|
|
29122
|
+
config.quotaLimit = [config.quotaLimit];
|
|
29123
|
+
}
|
|
29124
|
+
config.quotaLimit.forEach((options) => {
|
|
29125
|
+
if (options.scope === undefined) {
|
|
29126
|
+
options.scope = 'global';
|
|
29127
|
+
}
|
|
29128
|
+
if (options.renewPeriod === undefined) {
|
|
29129
|
+
options.renewPeriod = 'monthly';
|
|
29130
|
+
}
|
|
29131
|
+
});
|
|
29132
|
+
}
|
|
29133
|
+
return config;
|
|
29134
|
+
}
|
|
29135
|
+
|
|
29090
29136
|
;// CONCATENATED MODULE: ../internal-common/src/public-types/communication.public-types.ts
|
|
29091
29137
|
const ENVIRONMENT_IDS = ['dev', 'prod'];
|
|
29092
29138
|
// noinspection JSUnusedGtypeslobalSymbols
|
|
@@ -29349,12 +29395,14 @@ function replaceKeyInRecord(record, a, b) {
|
|
|
29349
29395
|
delete record[a];
|
|
29350
29396
|
}
|
|
29351
29397
|
}
|
|
29398
|
+
function isNil(obj) {
|
|
29399
|
+
return obj === undefined || obj === null;
|
|
29400
|
+
}
|
|
29352
29401
|
|
|
29353
29402
|
;// CONCATENATED MODULE: ../internal-common/src/public-types/pagination.public-types.ts
|
|
29354
29403
|
|
|
29355
29404
|
|
|
29356
29405
|
|
|
29357
|
-
|
|
29358
29406
|
class Pagination {
|
|
29359
29407
|
/** @internal */
|
|
29360
29408
|
constructor(snapshotEmitter, options = {}) {
|
|
@@ -29400,10 +29448,10 @@ class Pagination {
|
|
|
29400
29448
|
this.snapshotSubject.next(firstPageSnapshot);
|
|
29401
29449
|
}
|
|
29402
29450
|
static compareValues(a, b) {
|
|
29403
|
-
if (
|
|
29404
|
-
return
|
|
29451
|
+
if (isNil(a)) {
|
|
29452
|
+
return isNil(b) ? 0 : -1;
|
|
29405
29453
|
}
|
|
29406
|
-
if (
|
|
29454
|
+
if (isNil(b)) {
|
|
29407
29455
|
return 1;
|
|
29408
29456
|
}
|
|
29409
29457
|
if (a > b) {
|
|
@@ -29417,7 +29465,7 @@ class Pagination {
|
|
|
29417
29465
|
}
|
|
29418
29466
|
}
|
|
29419
29467
|
compare(doc1, doc2) {
|
|
29420
|
-
if (
|
|
29468
|
+
if (isNil(doc2)) {
|
|
29421
29469
|
return 1;
|
|
29422
29470
|
}
|
|
29423
29471
|
for (const so of this.templateSnapshotEmitter.getSortOrders()) {
|
|
@@ -29696,6 +29744,7 @@ function decodeValueForMapping(encodedString) {
|
|
|
29696
29744
|
;// CONCATENATED MODULE: ../internal-common/src/types/query.types.ts
|
|
29697
29745
|
|
|
29698
29746
|
|
|
29747
|
+
|
|
29699
29748
|
/**
|
|
29700
29749
|
* Example query mapping:
|
|
29701
29750
|
* Queries:
|
|
@@ -29734,30 +29783,30 @@ function compareOperator(conditionValue, valueInDocument, operator) {
|
|
|
29734
29783
|
// Nulls can only be compared for (in)equality, not other operators.
|
|
29735
29784
|
switch (operator) {
|
|
29736
29785
|
case '<':
|
|
29737
|
-
if (
|
|
29786
|
+
if (isNil(conditionValue))
|
|
29738
29787
|
return false;
|
|
29739
|
-
if (
|
|
29788
|
+
if (isNil(valueInDocument))
|
|
29740
29789
|
return true;
|
|
29741
29790
|
return valueInDocument < conditionValue;
|
|
29742
29791
|
case '<=':
|
|
29743
|
-
if (
|
|
29792
|
+
if (isNil(valueInDocument)) {
|
|
29744
29793
|
return true;
|
|
29745
29794
|
}
|
|
29746
|
-
if (
|
|
29795
|
+
if (isNil(conditionValue)) {
|
|
29747
29796
|
return false;
|
|
29748
29797
|
}
|
|
29749
29798
|
return valueInDocument <= conditionValue;
|
|
29750
29799
|
case '>':
|
|
29751
|
-
if (
|
|
29800
|
+
if (isNil(valueInDocument))
|
|
29752
29801
|
return false;
|
|
29753
|
-
if (
|
|
29802
|
+
if (isNil(conditionValue))
|
|
29754
29803
|
return true;
|
|
29755
29804
|
return valueInDocument > conditionValue;
|
|
29756
29805
|
case '>=':
|
|
29757
|
-
if (
|
|
29806
|
+
if (isNil(conditionValue)) {
|
|
29758
29807
|
return true;
|
|
29759
29808
|
}
|
|
29760
|
-
if (
|
|
29809
|
+
if (isNil(valueInDocument)) {
|
|
29761
29810
|
return false;
|
|
29762
29811
|
}
|
|
29763
29812
|
return valueInDocument >= conditionValue;
|
|
@@ -47733,17 +47782,16 @@ class AiChatbotClientFactory {
|
|
|
47733
47782
|
|
|
47734
47783
|
|
|
47735
47784
|
class ApiManager {
|
|
47736
|
-
constructor(clientIdService, rpcManager
|
|
47785
|
+
constructor(clientIdService, rpcManager) {
|
|
47737
47786
|
this.clientIdService = clientIdService;
|
|
47738
47787
|
this.rpcManager = rpcManager;
|
|
47739
|
-
this.apiServerUrlOverrideMapping = apiServerUrlOverrideMapping;
|
|
47740
47788
|
}
|
|
47741
|
-
callApiAndSubscribe(integrationId, endpointId, request) {
|
|
47789
|
+
callApiAndSubscribe(integrationId, endpointId, request, options) {
|
|
47742
47790
|
const callApiRequest = {
|
|
47743
47791
|
integrationId,
|
|
47744
47792
|
endpointId,
|
|
47745
47793
|
request,
|
|
47746
|
-
|
|
47794
|
+
options,
|
|
47747
47795
|
};
|
|
47748
47796
|
return (0,external_rxjs_.race)((0,external_rxjs_.from)(this.rpcManager.post('api/call', callApiRequest)).pipe(map(response => {
|
|
47749
47797
|
const parsedPayload = response.payload ? deserializeObj(response.payload) : undefined;
|
|
@@ -49104,10 +49152,10 @@ class DocumentStore {
|
|
|
49104
49152
|
return this.squidDocIdToDoc.get(squidDocId);
|
|
49105
49153
|
}
|
|
49106
49154
|
compareValues(a, b) {
|
|
49107
|
-
if (
|
|
49108
|
-
return
|
|
49155
|
+
if (isNil(a)) {
|
|
49156
|
+
return isNil(b) ? 0 : -1;
|
|
49109
49157
|
}
|
|
49110
|
-
if (
|
|
49158
|
+
if (isNil(b))
|
|
49111
49159
|
return 1;
|
|
49112
49160
|
if (a === b)
|
|
49113
49161
|
return 0;
|
|
@@ -50254,9 +50302,115 @@ class RateLimiter {
|
|
|
50254
50302
|
;// CONCATENATED MODULE: external "axios"
|
|
50255
50303
|
const external_axios_namespaceObject = require("axios");
|
|
50256
50304
|
var external_axios_default = /*#__PURE__*/__webpack_require__.n(external_axios_namespaceObject);
|
|
50257
|
-
;// CONCATENATED MODULE: ./src/
|
|
50305
|
+
;// CONCATENATED MODULE: ./src/squid-http-client.ts
|
|
50306
|
+
|
|
50307
|
+
|
|
50308
|
+
|
|
50258
50309
|
|
|
50310
|
+
/** @internal. */
|
|
50311
|
+
class RpcError extends Error {
|
|
50312
|
+
constructor(statusCode, statusText, headers, url, message) {
|
|
50313
|
+
super(message || `RPC error ${statusCode} ${statusText} calling ${url}`);
|
|
50314
|
+
this.statusCode = statusCode;
|
|
50315
|
+
this.statusText = statusText;
|
|
50316
|
+
this.headers = headers;
|
|
50317
|
+
this.url = url;
|
|
50318
|
+
}
|
|
50319
|
+
}
|
|
50320
|
+
/**
|
|
50321
|
+
* Runs a post request to the given URL.
|
|
50322
|
+
* @internal.
|
|
50323
|
+
*/
|
|
50324
|
+
async function squidHttpPost({ url, headers, files, filesFieldName, message }) {
|
|
50325
|
+
const isFetch = !!getSquidPrivateOption(SQUID_PRIVATE_OPTION_USE_FETCH_IN_RPC_MANAGER);
|
|
50326
|
+
if (isFetch) {
|
|
50327
|
+
const requestOptionHeaders = new Headers(headers);
|
|
50328
|
+
const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
|
|
50329
|
+
if (files.length) {
|
|
50330
|
+
const formData = new FormData();
|
|
50331
|
+
for (const file of files) {
|
|
50332
|
+
const blob = file instanceof Blob ? file : file.blob;
|
|
50333
|
+
const filename = file instanceof Blob ? undefined : file.name;
|
|
50334
|
+
formData.append(filesFieldName, blob, filename);
|
|
50335
|
+
}
|
|
50336
|
+
formData.append('body', serializeObj(message));
|
|
50337
|
+
requestOptions.body = formData;
|
|
50338
|
+
}
|
|
50339
|
+
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);
|
|
50349
|
+
}
|
|
50350
|
+
const responseData = await response.text();
|
|
50351
|
+
const parsedResponse = tryDeserializing(responseData);
|
|
50352
|
+
DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
|
|
50353
|
+
return parsedResponse;
|
|
50354
|
+
}
|
|
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
|
+
});
|
|
50371
|
+
}
|
|
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
|
+
});
|
|
50377
|
+
}
|
|
50378
|
+
}
|
|
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
|
+
}
|
|
50397
|
+
}
|
|
50398
|
+
const parsedResponse = tryDeserializing(axiosResponse.data);
|
|
50399
|
+
DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
|
|
50400
|
+
return parsedResponse;
|
|
50401
|
+
}
|
|
50402
|
+
}
|
|
50403
|
+
function tryDeserializing(text) {
|
|
50404
|
+
if (!text)
|
|
50405
|
+
return undefined;
|
|
50406
|
+
try {
|
|
50407
|
+
return deserializeObj(text);
|
|
50408
|
+
}
|
|
50409
|
+
catch (_a) { }
|
|
50410
|
+
return text;
|
|
50411
|
+
}
|
|
50259
50412
|
|
|
50413
|
+
;// CONCATENATED MODULE: ./src/rpc.manager.ts
|
|
50260
50414
|
|
|
50261
50415
|
|
|
50262
50416
|
|
|
@@ -50323,105 +50477,16 @@ class RpcManager {
|
|
|
50323
50477
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
50324
50478
|
try {
|
|
50325
50479
|
await this.getRateLimiterBucket(path).consume();
|
|
50326
|
-
let headers = {};
|
|
50327
|
-
if (Object.keys(this.staticHeaders)) {
|
|
50328
|
-
headers = Object.assign(Object.assign({}, headers), this.staticHeaders);
|
|
50329
|
-
}
|
|
50330
50480
|
const authHeaders = await this.getAuthHeaders();
|
|
50331
|
-
headers = Object.assign(Object.assign({},
|
|
50481
|
+
const headers = Object.assign(Object.assign({}, this.staticHeaders), authHeaders);
|
|
50332
50482
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
50333
50483
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
50334
|
-
|
|
50335
|
-
if (isFetch) {
|
|
50336
|
-
const requestOptionHeaders = new Headers(headers);
|
|
50337
|
-
const requestOptions = { method: 'POST', headers: requestOptionHeaders, body: undefined };
|
|
50338
|
-
if (files.length) {
|
|
50339
|
-
const formData = new FormData();
|
|
50340
|
-
files.forEach(file => {
|
|
50341
|
-
const blob = file instanceof Blob ? file : file.blob;
|
|
50342
|
-
const filename = file instanceof Blob ? undefined : file.name;
|
|
50343
|
-
formData.append(filesFieldName, blob, filename);
|
|
50344
|
-
});
|
|
50345
|
-
formData.append('body', serializeObj(message));
|
|
50346
|
-
requestOptions.body = formData;
|
|
50347
|
-
}
|
|
50348
|
-
else {
|
|
50349
|
-
requestOptionHeaders.append('Content-Type', 'application/json');
|
|
50350
|
-
requestOptions.body = serializeObj(message);
|
|
50351
|
-
}
|
|
50352
|
-
const response = await fetch(url, requestOptions);
|
|
50353
|
-
if (!response.ok) {
|
|
50354
|
-
const errorBody = await response.text();
|
|
50355
|
-
const errorResponse = this.tryDeserializing(errorBody);
|
|
50356
|
-
const errorResponseMessage = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
|
|
50357
|
-
throw new RpcError(response.status, response.statusText, response.headers, url, errorResponseMessage);
|
|
50358
|
-
}
|
|
50359
|
-
const responseData = await response.text();
|
|
50360
|
-
const parsedResponse = this.tryDeserializing(responseData);
|
|
50361
|
-
DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
|
|
50362
|
-
return parsedResponse;
|
|
50363
|
-
}
|
|
50364
|
-
else {
|
|
50365
|
-
let axiosResponse;
|
|
50366
|
-
try {
|
|
50367
|
-
if (files.length) {
|
|
50368
|
-
const formData = new FormData();
|
|
50369
|
-
files.forEach(file => {
|
|
50370
|
-
const blob = file instanceof Blob ? file : file.blob;
|
|
50371
|
-
const filename = file instanceof Blob ? undefined : file.name;
|
|
50372
|
-
formData.append(filesFieldName, blob, filename);
|
|
50373
|
-
});
|
|
50374
|
-
formData.append('body', serializeObj(message));
|
|
50375
|
-
// Make the axios call
|
|
50376
|
-
axiosResponse = await external_axios_default().post(url, formData, {
|
|
50377
|
-
headers: Object.assign({}, headers),
|
|
50378
|
-
responseType: 'text',
|
|
50379
|
-
});
|
|
50380
|
-
}
|
|
50381
|
-
else {
|
|
50382
|
-
axiosResponse = await external_axios_default().post(url, serializeObj(message), {
|
|
50383
|
-
headers: Object.assign(Object.assign({}, headers), { 'Content-Type': 'application/json' }),
|
|
50384
|
-
responseType: 'text',
|
|
50385
|
-
});
|
|
50386
|
-
}
|
|
50387
|
-
}
|
|
50388
|
-
catch (error) {
|
|
50389
|
-
if ((0,external_axios_namespaceObject.isAxiosError)(error)) {
|
|
50390
|
-
const { response } = error;
|
|
50391
|
-
if (!response)
|
|
50392
|
-
throw error;
|
|
50393
|
-
let message;
|
|
50394
|
-
try {
|
|
50395
|
-
const errorResponse = this.tryDeserializing(response.data);
|
|
50396
|
-
message = typeof errorResponse === 'string' ? errorResponse : errorResponse['message'];
|
|
50397
|
-
}
|
|
50398
|
-
catch (_a) { }
|
|
50399
|
-
if (!message)
|
|
50400
|
-
message = response.statusText;
|
|
50401
|
-
throw new RpcError(response.status, response.statusText, response.headers, url, message);
|
|
50402
|
-
}
|
|
50403
|
-
else {
|
|
50404
|
-
throw error;
|
|
50405
|
-
}
|
|
50406
|
-
}
|
|
50407
|
-
const parsedResponse = this.tryDeserializing(axiosResponse.data);
|
|
50408
|
-
DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
|
|
50409
|
-
return parsedResponse;
|
|
50410
|
-
}
|
|
50484
|
+
return await squidHttpPost({ url, headers, message, files, filesFieldName });
|
|
50411
50485
|
}
|
|
50412
50486
|
finally {
|
|
50413
50487
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
50414
50488
|
}
|
|
50415
50489
|
}
|
|
50416
|
-
tryDeserializing(text) {
|
|
50417
|
-
if (!text)
|
|
50418
|
-
return undefined;
|
|
50419
|
-
try {
|
|
50420
|
-
return deserializeObj(text);
|
|
50421
|
-
}
|
|
50422
|
-
catch (_a) { }
|
|
50423
|
-
return text;
|
|
50424
|
-
}
|
|
50425
50490
|
getRateLimiterBucket(path) {
|
|
50426
50491
|
if (path.startsWith('ai/chatbot')) {
|
|
50427
50492
|
return (0,dist.truthy)(this.rateLimiters['ai'], 'MISSING_RATE_LIMITER_AI');
|
|
@@ -50432,15 +50497,6 @@ class RpcManager {
|
|
|
50432
50497
|
return (0,dist.truthy)(this.rateLimiters['default'], 'MISSING_RATE_LIMITER_DEFAULT');
|
|
50433
50498
|
}
|
|
50434
50499
|
}
|
|
50435
|
-
class RpcError extends Error {
|
|
50436
|
-
constructor(statusCode, statusText, headers, url, message) {
|
|
50437
|
-
super(message || `RPC error ${statusCode} ${statusText} calling ${url}`);
|
|
50438
|
-
this.statusCode = statusCode;
|
|
50439
|
-
this.statusText = statusText;
|
|
50440
|
-
this.headers = headers;
|
|
50441
|
-
this.url = url;
|
|
50442
|
-
}
|
|
50443
|
-
}
|
|
50444
50500
|
|
|
50445
50501
|
;// CONCATENATED MODULE: ./src/secret.client.ts
|
|
50446
50502
|
class SecretClient {
|
|
@@ -50900,7 +50956,7 @@ class AiAssistantClient {
|
|
|
50900
50956
|
* @param name - The name of the assistant.
|
|
50901
50957
|
* @param instructions - Instructions for the assistant.
|
|
50902
50958
|
* @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
|
|
50903
|
-
* available
|
|
50959
|
+
* available to the assistant.
|
|
50904
50960
|
* @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
|
|
50905
50961
|
* the addFileToAssistant method.
|
|
50906
50962
|
* @returns A promise that resolves to the created assistant's ID.
|
|
@@ -51356,7 +51412,7 @@ class Squid {
|
|
|
51356
51412
|
this.documentReferenceFactory.setDataManager(this.dataManager);
|
|
51357
51413
|
this.backendFunctionManager = new BackendFunctionManager(this.clientIdService, this.rpcManager);
|
|
51358
51414
|
this.nativeQueryManager = new NativeQueryManager(this.rpcManager);
|
|
51359
|
-
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager
|
|
51415
|
+
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager);
|
|
51360
51416
|
this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
|
|
51361
51417
|
this.secretClient = new SecretClient(this.rpcManager);
|
|
51362
51418
|
this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
|
|
@@ -51474,12 +51530,13 @@ class Squid {
|
|
|
51474
51530
|
* @param integrationId The id of the integration that the API is defined with.
|
|
51475
51531
|
* @param endpointId The id of the endpoint in the API integration.
|
|
51476
51532
|
* @param request The request parameters to pass to the API.
|
|
51533
|
+
* @param options optional options for the API call.
|
|
51477
51534
|
* @returns A promise that resolves with the response of the API.
|
|
51478
51535
|
* @typeParam T The type of the response of the API.
|
|
51479
51536
|
*/
|
|
51480
|
-
callApi(integrationId, endpointId, request = {}) {
|
|
51537
|
+
callApi(integrationId, endpointId, request = {}, options) {
|
|
51481
51538
|
this._validateNotDestructed();
|
|
51482
|
-
return (0,external_rxjs_.firstValueFrom)(this.apiManager.callApiAndSubscribe(integrationId, endpointId, request));
|
|
51539
|
+
return (0,external_rxjs_.firstValueFrom)(this.apiManager.callApiAndSubscribe(integrationId, endpointId, request, options || {}));
|
|
51483
51540
|
}
|
|
51484
51541
|
/**
|
|
51485
51542
|
* Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
|
|
@@ -10,5 +10,21 @@ export declare class ApiCallContext {
|
|
|
10
10
|
readonly body: Record<string, any>;
|
|
11
11
|
readonly queryParams: Record<string, string | number | boolean>;
|
|
12
12
|
readonly pathParams: Record<string, string>;
|
|
13
|
-
readonly
|
|
13
|
+
readonly options: ApiOptions;
|
|
14
|
+
}
|
|
15
|
+
/** The options for calling an API. */
|
|
16
|
+
export interface ApiOptions {
|
|
17
|
+
/** If true, the response will be returned as-is without any processing. */
|
|
18
|
+
nativeResponse?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* An optional string to override the default origin of the API (e.g. https://host:port). Useful for
|
|
21
|
+
* scenarios such as testing, development, or accessing the API from different environments.
|
|
22
|
+
*/
|
|
23
|
+
originOverride?: string;
|
|
24
|
+
}
|
|
25
|
+
/** A native API call response. */
|
|
26
|
+
export interface NativeApiCallResponse<T = unknown> {
|
|
27
|
+
body: T;
|
|
28
|
+
headers: ApiHeaders;
|
|
29
|
+
status: number;
|
|
14
30
|
}
|
|
@@ -30,6 +30,56 @@ export interface TriggerRequest<T extends DocumentData = any> {
|
|
|
30
30
|
docAfter?: T;
|
|
31
31
|
}
|
|
32
32
|
export type SchedulerAction = () => void | Promise<void>;
|
|
33
|
+
export type LimitedAction = () => any | Promise<any>;
|
|
34
|
+
export type LimiterScope = 'ip' | 'user' | 'global';
|
|
35
|
+
export type QuotaRenewPeriod = 'hourly' | 'daily' | 'weekly' | 'monthly' | 'quarterly' | 'annually';
|
|
36
|
+
/**
|
|
37
|
+
* Options for rate limiting.
|
|
38
|
+
*
|
|
39
|
+
* @param value Number of executions permitted per second. Note that we
|
|
40
|
+
* permit bursts of up to 3x the specified limit.
|
|
41
|
+
* @param scope What this limit applies to: per user? per IP? global?
|
|
42
|
+
*/
|
|
43
|
+
export interface RateLimitOptions {
|
|
44
|
+
value: number;
|
|
45
|
+
scope?: LimiterScope;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for quota limiting.
|
|
49
|
+
*
|
|
50
|
+
* @param value Number of total executions allowed. Note that this would be
|
|
51
|
+
* reset upon any redeployment of the backend.
|
|
52
|
+
* @param scope What this limit applies to: per user? per IP? global?
|
|
53
|
+
*/
|
|
54
|
+
export interface QuotaLimitOptions {
|
|
55
|
+
value: number;
|
|
56
|
+
scope?: LimiterScope;
|
|
57
|
+
renewPeriod?: QuotaRenewPeriod;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options for rate and quota limiting backend functions.
|
|
61
|
+
*
|
|
62
|
+
* This mirrors the type in Kotlin. It is not the type the developer defines in their code, which is LimiterConfig.
|
|
63
|
+
*
|
|
64
|
+
* @param rateLimit RateLimitOptions configurations. Allows for different limits at different scopes.
|
|
65
|
+
* @param quotaLimit QuotaLimitOptions configurations. Allows for different limits at different scopes.
|
|
66
|
+
*/
|
|
67
|
+
export interface LimiterOptions {
|
|
68
|
+
rateLimit?: RateLimitOptions[];
|
|
69
|
+
quotaLimit?: QuotaLimitOptions[];
|
|
70
|
+
}
|
|
71
|
+
export type LimiterConfig = {
|
|
72
|
+
rateLimit?: number | RateLimitOptions | Array<RateLimitOptions>;
|
|
73
|
+
quotaLimit?: number | QuotaLimitOptions | Array<QuotaLimitOptions>;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Convert LimiterConfig to LimiterOptions.
|
|
77
|
+
*
|
|
78
|
+
* This decouples the required syntax for the developer from the internal implementation.
|
|
79
|
+
*
|
|
80
|
+
* @param config LimiterConfig to convert.
|
|
81
|
+
*/
|
|
82
|
+
export declare function limiterConfigToOptions(config: LimiterConfig): LimiterOptions;
|
|
33
83
|
export type WebhookAction = ((request: WebhookRequest) => any) | (() => any);
|
|
34
84
|
/** The context provided to a webhook function. */
|
|
35
85
|
export interface WebhookRequest<T = any> {
|
|
@@ -3,3 +3,4 @@ export declare function setInPath(obj: object, path: string, value: unknown, del
|
|
|
3
3
|
export declare function deleteInPath(obj: object, path: string, delimiter?: string): void;
|
|
4
4
|
export declare function replaceKeyInMap<K, T>(map: Map<K, T | undefined>, a: K, b: K): void;
|
|
5
5
|
export declare function replaceKeyInRecord<K extends keyof any, T>(record: Record<K, T>, a: K, b: K): void;
|
|
6
|
+
export declare function isNil(obj: unknown): obj is null | undefined;
|
|
@@ -14,7 +14,7 @@ export declare class AiAssistantClient {
|
|
|
14
14
|
* @param name - The name of the assistant.
|
|
15
15
|
* @param instructions - Instructions for the assistant.
|
|
16
16
|
* @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
|
|
17
|
-
* available
|
|
17
|
+
* available to the assistant.
|
|
18
18
|
* @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
|
|
19
19
|
* the addFileToAssistant method.
|
|
20
20
|
* @returns A promise that resolves to the created assistant's ID.
|
|
@@ -113,7 +113,7 @@ declare class AiChatbotContextReference {
|
|
|
113
113
|
* Updates an existing context entry on the chatbot profile. This will result in an error if an entry has not yet
|
|
114
114
|
* been created for the current context id.
|
|
115
115
|
*
|
|
116
|
-
* @param data An object containing options for
|
|
116
|
+
* @param data An object containing options for updating the entry.
|
|
117
117
|
* @param data.title - The title of the entry.
|
|
118
118
|
* @param data.context - The context data.
|
|
119
119
|
* @returns A promise that resolves when the context is successfully updated.
|
|
@@ -150,7 +150,7 @@ declare class AiChatbotInstructionReference {
|
|
|
150
150
|
* Updates an existing instruction entry on the chatbot profile. This will result in an error if an entry has not
|
|
151
151
|
* yet been created for the current instruction id.
|
|
152
152
|
*
|
|
153
|
-
* @param data An object containing options for
|
|
153
|
+
* @param data An object containing options for updating the entry.
|
|
154
154
|
* @param data.instruction - The instruction data.
|
|
155
155
|
* @returns A promise that resolves when the instruction is successfully updated.
|
|
156
156
|
*/
|
|
@@ -1,11 +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, IntegrationId } from './public-types';
|
|
4
|
+
import { ApiEndpointId, ApiOptions, IntegrationId } from './public-types';
|
|
5
5
|
export declare class ApiManager {
|
|
6
6
|
private readonly clientIdService;
|
|
7
7
|
private readonly rpcManager;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>): Observable<T>;
|
|
8
|
+
constructor(clientIdService: ClientIdService, rpcManager: RpcManager);
|
|
9
|
+
callApiAndSubscribe<T>(integrationId: IntegrationId, endpointId: ApiEndpointId, request: Record<string, any>, options: ApiOptions): Observable<T>;
|
|
11
10
|
}
|
|
@@ -18,13 +18,5 @@ export declare class RpcManager {
|
|
|
18
18
|
deleteStaticHeader(key: string): void;
|
|
19
19
|
getStaticHeaders(): Record<string, string>;
|
|
20
20
|
post<T>(path: string, message: unknown, files?: Array<File | BlobAndFilename>, filesFieldName?: string): Promise<T>;
|
|
21
|
-
private tryDeserializing;
|
|
22
21
|
private getRateLimiterBucket;
|
|
23
22
|
}
|
|
24
|
-
export declare class RpcError extends Error {
|
|
25
|
-
readonly statusCode: number;
|
|
26
|
-
readonly statusText: string;
|
|
27
|
-
readonly headers: Headers;
|
|
28
|
-
readonly url: string;
|
|
29
|
-
constructor(statusCode: number, statusText: string, headers: Headers, url: string, message?: string);
|
|
30
|
-
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,7 +5,7 @@ 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, CollectionName, DocumentData, EnvironmentId, IntegrationId, SquidDeveloperId, SquidRegion } from './public-types';
|
|
8
|
+
import { ApiEndpointId, ApiKey, AppId, ApiOptions, CollectionName, DocumentData, EnvironmentId, IntegrationId, NativeApiCallResponse, SquidDeveloperId, SquidRegion } from './public-types';
|
|
9
9
|
import { QueueManager } from './queue.manager';
|
|
10
10
|
/** The different options that can be used to initialize a Squid instance. */
|
|
11
11
|
export interface SquidOptions {
|
|
@@ -48,11 +48,6 @@ export interface SquidOptions {
|
|
|
48
48
|
* The user ID of the developer that runs the environment locally.
|
|
49
49
|
*/
|
|
50
50
|
squidDeveloperId?: SquidDeveloperId;
|
|
51
|
-
/**
|
|
52
|
-
* A list of API endpoints that can be used for overriding the default API endpoints for the different integrations.
|
|
53
|
-
* This is useful for APIs that have multiple base urls hosted in different regions.
|
|
54
|
-
*/
|
|
55
|
-
apiServerUrlOverrideMapping?: Record<IntegrationId, string>;
|
|
56
51
|
}
|
|
57
52
|
/** Authentication data provider for Squid requests. */
|
|
58
53
|
export interface SquidAuthProvider {
|
|
@@ -188,21 +183,12 @@ export declare class Squid {
|
|
|
188
183
|
* @type {Promise<Array<SquidDocument>>}
|
|
189
184
|
*/
|
|
190
185
|
executeNativeRelationalQuery<T = any>(integrationId: IntegrationId, query: string, params?: Record<string, any>): Promise<Array<T>>;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
* {@link https://docs.squid.cloud/docs/integrations/api/httpapi documentation}.
|
|
198
|
-
*
|
|
199
|
-
* @param integrationId The id of the integration that the API is defined with.
|
|
200
|
-
* @param endpointId The id of the endpoint in the API integration.
|
|
201
|
-
* @param request The request parameters to pass to the API.
|
|
202
|
-
* @returns A promise that resolves with the response of the API.
|
|
203
|
-
* @typeParam T The type of the response of the API.
|
|
204
|
-
*/
|
|
205
|
-
callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>): Promise<T>;
|
|
186
|
+
callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: Omit<ApiOptions, 'nativeResponse'> | (ApiOptions & {
|
|
187
|
+
nativeResponse: false;
|
|
188
|
+
})): Promise<T>;
|
|
189
|
+
callApi<T = any>(integrationId: IntegrationId, endpointId: ApiEndpointId, request?: Record<string, any>, options?: ApiOptions & {
|
|
190
|
+
nativeResponse: true;
|
|
191
|
+
}): Promise<NativeApiCallResponse<T>>;
|
|
206
192
|
/**
|
|
207
193
|
* Returns a GraphQL client for the given integration. The GraphQL client can be used to execute GraphQL queries and
|
|
208
194
|
* mutations. For more information about GraphQL in Squid, please refer to the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squidcloud/client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.177",
|
|
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",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"test:cov": "jest --coverage",
|
|
22
22
|
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
|
23
23
|
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
24
|
-
"publish:public": "npm run build && npm publish --access public"
|
|
24
|
+
"publish:public": "npm run build && npm publish --access public",
|
|
25
|
+
"full-bundle-size-report": "cross-env BUILD_FULL_BUNDLE_SIZE_REPORT=1 webpack --mode=production"
|
|
25
26
|
},
|
|
26
27
|
"keywords": [
|
|
27
28
|
"typescript",
|