@squidcloud/client 1.0.105 → 1.0.106
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 +112 -25
- package/dist/common/src/secret.types.d.ts +6 -0
- package/dist/esm/index.js +112 -25
- package/dist/typescript-client/src/rpc.manager.d.ts +5 -0
- package/dist/typescript-client/src/secret.client.d.ts +20 -0
- package/dist/typescript-client/src/squid.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -29604,16 +29604,22 @@ function findMatchingPropertiesForKey(schema, key) {
|
|
|
29604
29604
|
|
|
29605
29605
|
;// CONCATENATED MODULE: ../common/src/secret.schemas.ts
|
|
29606
29606
|
/** @internal */
|
|
29607
|
-
const
|
|
29607
|
+
const SetSecretRequestSchema = {
|
|
29608
29608
|
type: 'object',
|
|
29609
29609
|
required: ['key', 'value'],
|
|
29610
29610
|
properties: {
|
|
29611
29611
|
key: { type: 'string', pattern: '[a-zA-Z0-9-_+]', nullable: false },
|
|
29612
|
-
value: {
|
|
29612
|
+
value: {
|
|
29613
|
+
anyOf: [
|
|
29614
|
+
{ type: 'string', nullable: false },
|
|
29615
|
+
{ type: 'number', nullable: false },
|
|
29616
|
+
{ type: 'boolean', nullable: false },
|
|
29617
|
+
],
|
|
29618
|
+
},
|
|
29613
29619
|
},
|
|
29614
29620
|
};
|
|
29615
29621
|
/** @internal */
|
|
29616
|
-
const
|
|
29622
|
+
const DeleteSecretRequestSchema = {
|
|
29617
29623
|
type: 'object',
|
|
29618
29624
|
required: ['key'],
|
|
29619
29625
|
properties: {
|
|
@@ -29786,6 +29792,7 @@ function getApplicationUrl(regionPrefix, appId, path) {
|
|
|
29786
29792
|
}
|
|
29787
29793
|
}
|
|
29788
29794
|
const url = parsedBaseUrl.toString();
|
|
29795
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
29789
29796
|
return (url.endsWith('/') ? url : url + '/') + path;
|
|
29790
29797
|
}
|
|
29791
29798
|
function getApplicationHttpHeaders(regionPrefix, appId) {
|
|
@@ -32690,7 +32697,7 @@ class ClientIdService {
|
|
|
32690
32697
|
return this.clientIdSubject;
|
|
32691
32698
|
}
|
|
32692
32699
|
observeClientTooOld() {
|
|
32693
|
-
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)((
|
|
32700
|
+
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)(() => undefined));
|
|
32694
32701
|
}
|
|
32695
32702
|
/** there was a long-term disconnection of the socket */
|
|
32696
32703
|
notifyClientTooOld() {
|
|
@@ -48494,12 +48501,43 @@ class RpcManager {
|
|
|
48494
48501
|
getStaticHeaders() {
|
|
48495
48502
|
return this.staticHeaders;
|
|
48496
48503
|
}
|
|
48504
|
+
async ready() {
|
|
48505
|
+
// Waiting for socket connection to be established before sending an RPC request
|
|
48506
|
+
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48507
|
+
await this.authManager.waitForReadyState();
|
|
48508
|
+
}
|
|
48509
|
+
async get(path, params) {
|
|
48510
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48511
|
+
try {
|
|
48512
|
+
await this.ready();
|
|
48513
|
+
const url = new URL(getApplicationUrl(this.region, this.appId, path));
|
|
48514
|
+
const searchParams = new URLSearchParams(url.search);
|
|
48515
|
+
for (const [key, value] of Object.entries(params || {})) {
|
|
48516
|
+
if (value !== null) {
|
|
48517
|
+
searchParams.set(key, value);
|
|
48518
|
+
}
|
|
48519
|
+
}
|
|
48520
|
+
url.search = searchParams.toString();
|
|
48521
|
+
const response = await external_cross_fetch_default()(url.toString(), {
|
|
48522
|
+
method: 'GET',
|
|
48523
|
+
headers: this.staticHeaders,
|
|
48524
|
+
});
|
|
48525
|
+
return await this.parseResponse(response);
|
|
48526
|
+
}
|
|
48527
|
+
finally {
|
|
48528
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48529
|
+
}
|
|
48530
|
+
}
|
|
48497
48531
|
async post(path, message) {
|
|
48532
|
+
return this.postOrDelete('POST', path, message);
|
|
48533
|
+
}
|
|
48534
|
+
async delete(path, message) {
|
|
48535
|
+
return this.postOrDelete('DELETE', path, message);
|
|
48536
|
+
}
|
|
48537
|
+
async postOrDelete(method, path, message) {
|
|
48498
48538
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48499
48539
|
try {
|
|
48500
|
-
|
|
48501
|
-
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48502
|
-
await this.authManager.waitForReadyState();
|
|
48540
|
+
await this.ready();
|
|
48503
48541
|
let headers = {
|
|
48504
48542
|
'Content-Type': 'application/json',
|
|
48505
48543
|
};
|
|
@@ -48509,31 +48547,34 @@ class RpcManager {
|
|
|
48509
48547
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
48510
48548
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
48511
48549
|
const response = await external_cross_fetch_default()(url, {
|
|
48512
|
-
method
|
|
48550
|
+
method,
|
|
48513
48551
|
body: serialization_serializeObj(message),
|
|
48514
48552
|
headers: headers,
|
|
48515
48553
|
});
|
|
48516
|
-
|
|
48517
|
-
let json;
|
|
48518
|
-
try {
|
|
48519
|
-
text = await response.text();
|
|
48520
|
-
try {
|
|
48521
|
-
json = JSON.parse(text);
|
|
48522
|
-
}
|
|
48523
|
-
catch (_a) { }
|
|
48524
|
-
}
|
|
48525
|
-
catch (_b) {
|
|
48526
|
-
text = 'Cannot read body';
|
|
48527
|
-
}
|
|
48528
|
-
if (!response.ok) {
|
|
48529
|
-
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48530
|
-
}
|
|
48531
|
-
return (json || text);
|
|
48554
|
+
return await this.parseResponse(response);
|
|
48532
48555
|
}
|
|
48533
48556
|
finally {
|
|
48534
48557
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48535
48558
|
}
|
|
48536
48559
|
}
|
|
48560
|
+
async parseResponse(response) {
|
|
48561
|
+
let text;
|
|
48562
|
+
let json;
|
|
48563
|
+
try {
|
|
48564
|
+
text = await response.text();
|
|
48565
|
+
try {
|
|
48566
|
+
json = JSON.parse(text);
|
|
48567
|
+
}
|
|
48568
|
+
catch (_a) { }
|
|
48569
|
+
}
|
|
48570
|
+
catch (_b) {
|
|
48571
|
+
text = 'Cannot read body';
|
|
48572
|
+
}
|
|
48573
|
+
if (!response.ok) {
|
|
48574
|
+
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48575
|
+
}
|
|
48576
|
+
return (json || text);
|
|
48577
|
+
}
|
|
48537
48578
|
}
|
|
48538
48579
|
class RpcError extends Error {
|
|
48539
48580
|
constructor(statusCode, statusText, headers, url, message) {
|
|
@@ -48545,6 +48586,45 @@ class RpcError extends Error {
|
|
|
48545
48586
|
}
|
|
48546
48587
|
}
|
|
48547
48588
|
|
|
48589
|
+
;// CONCATENATED MODULE: ./src/secret.client.ts
|
|
48590
|
+
class SecretClient {
|
|
48591
|
+
constructor(rpcManager) {
|
|
48592
|
+
this.rpcManager = rpcManager;
|
|
48593
|
+
}
|
|
48594
|
+
get(key) {
|
|
48595
|
+
return this.rpcManager.get('/secret/get', { key });
|
|
48596
|
+
}
|
|
48597
|
+
getAll() {
|
|
48598
|
+
return this.rpcManager.get('/secret/getAll');
|
|
48599
|
+
}
|
|
48600
|
+
upsert(key, value) {
|
|
48601
|
+
return this.rpcManager.post('/secret/upsert', { key, value });
|
|
48602
|
+
}
|
|
48603
|
+
delete(key) {
|
|
48604
|
+
return this.rpcManager.delete('/secret/delete', { key });
|
|
48605
|
+
}
|
|
48606
|
+
get apiKeys() {
|
|
48607
|
+
return new ApiKeysSecretClient(this.rpcManager);
|
|
48608
|
+
}
|
|
48609
|
+
}
|
|
48610
|
+
class ApiKeysSecretClient {
|
|
48611
|
+
constructor(rpcManager) {
|
|
48612
|
+
this.rpcManager = rpcManager;
|
|
48613
|
+
}
|
|
48614
|
+
get(key) {
|
|
48615
|
+
return this.rpcManager.get('/secret/api-key/get', { key });
|
|
48616
|
+
}
|
|
48617
|
+
getAll() {
|
|
48618
|
+
return this.rpcManager.get('/secret/api-key/getAll');
|
|
48619
|
+
}
|
|
48620
|
+
upsert(key) {
|
|
48621
|
+
return this.rpcManager.post('/secret/api-key/upsert', { key });
|
|
48622
|
+
}
|
|
48623
|
+
delete(key) {
|
|
48624
|
+
return this.rpcManager.delete('/secret/api-key/delete', { key });
|
|
48625
|
+
}
|
|
48626
|
+
}
|
|
48627
|
+
|
|
48548
48628
|
;// CONCATENATED MODULE: ./src/types.ts
|
|
48549
48629
|
/**
|
|
48550
48630
|
* @internal
|
|
@@ -48577,7 +48657,7 @@ class SocketManager {
|
|
|
48577
48657
|
* This value means we wait for 5 minutes before considering the client to be too old.
|
|
48578
48658
|
* Note: we make this a function so that we can easily override it in tests.
|
|
48579
48659
|
*/
|
|
48580
|
-
this.clientTooOldThreshold =
|
|
48660
|
+
this.clientTooOldThreshold = 30000;
|
|
48581
48661
|
this.destructManager.onDestruct(async () => {
|
|
48582
48662
|
await this.destruct();
|
|
48583
48663
|
});
|
|
@@ -48718,6 +48798,7 @@ class SocketManager {
|
|
|
48718
48798
|
|
|
48719
48799
|
|
|
48720
48800
|
|
|
48801
|
+
|
|
48721
48802
|
|
|
48722
48803
|
|
|
48723
48804
|
/**
|
|
@@ -48920,6 +49001,7 @@ class Squid {
|
|
|
48920
49001
|
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
|
|
48921
49002
|
this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
|
|
48922
49003
|
this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
|
|
49004
|
+
this.secretClient = new SecretClient(this.rpcManager);
|
|
48923
49005
|
this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
|
|
48924
49006
|
}
|
|
48925
49007
|
/**
|
|
@@ -48946,6 +49028,11 @@ class Squid {
|
|
|
48946
49028
|
static getInstances() {
|
|
48947
49029
|
return Object.values(Squid.squidInstancesMap);
|
|
48948
49030
|
}
|
|
49031
|
+
get secrets() {
|
|
49032
|
+
return (() => {
|
|
49033
|
+
return this.secretClient;
|
|
49034
|
+
})();
|
|
49035
|
+
}
|
|
48949
49036
|
validateNotDestructed() {
|
|
48950
49037
|
assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
|
|
48951
49038
|
}
|
|
@@ -6,3 +6,9 @@ export type SecretValue = string | number | boolean;
|
|
|
6
6
|
export type ApiKey = string;
|
|
7
7
|
export declare const BACKEND_API_KEY = "_BACKEND_API_KEY";
|
|
8
8
|
export declare const APP_API_KEY = "APP_API_KEY";
|
|
9
|
+
export interface SecretEntry<T extends SecretValue = SecretValue> extends SecretMetadata {
|
|
10
|
+
value: T;
|
|
11
|
+
}
|
|
12
|
+
export interface ApiKeyEntry extends SecretMetadata {
|
|
13
|
+
value: string;
|
|
14
|
+
}
|
package/dist/esm/index.js
CHANGED
|
@@ -29519,16 +29519,22 @@ function findMatchingPropertiesForKey(schema, key) {
|
|
|
29519
29519
|
|
|
29520
29520
|
;// CONCATENATED MODULE: ../common/src/secret.schemas.ts
|
|
29521
29521
|
/** @internal */
|
|
29522
|
-
const
|
|
29522
|
+
const SetSecretRequestSchema = {
|
|
29523
29523
|
type: 'object',
|
|
29524
29524
|
required: ['key', 'value'],
|
|
29525
29525
|
properties: {
|
|
29526
29526
|
key: { type: 'string', pattern: '[a-zA-Z0-9-_+]', nullable: false },
|
|
29527
|
-
value: {
|
|
29527
|
+
value: {
|
|
29528
|
+
anyOf: [
|
|
29529
|
+
{ type: 'string', nullable: false },
|
|
29530
|
+
{ type: 'number', nullable: false },
|
|
29531
|
+
{ type: 'boolean', nullable: false },
|
|
29532
|
+
],
|
|
29533
|
+
},
|
|
29528
29534
|
},
|
|
29529
29535
|
};
|
|
29530
29536
|
/** @internal */
|
|
29531
|
-
const
|
|
29537
|
+
const DeleteSecretRequestSchema = {
|
|
29532
29538
|
type: 'object',
|
|
29533
29539
|
required: ['key'],
|
|
29534
29540
|
properties: {
|
|
@@ -29701,6 +29707,7 @@ function getApplicationUrl(regionPrefix, appId, path) {
|
|
|
29701
29707
|
}
|
|
29702
29708
|
}
|
|
29703
29709
|
const url = parsedBaseUrl.toString();
|
|
29710
|
+
path = path.startsWith('/') ? path.slice(1) : path;
|
|
29704
29711
|
return (url.endsWith('/') ? url : url + '/') + path;
|
|
29705
29712
|
}
|
|
29706
29713
|
function getApplicationHttpHeaders(regionPrefix, appId) {
|
|
@@ -32605,7 +32612,7 @@ class ClientIdService {
|
|
|
32605
32612
|
return this.clientIdSubject;
|
|
32606
32613
|
}
|
|
32607
32614
|
observeClientTooOld() {
|
|
32608
|
-
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)((
|
|
32615
|
+
return this.clientTooOldSubject.pipe((0,external_rxjs_namespaceObject.filter)((v) => v), (0,external_rxjs_namespaceObject.map)(() => undefined));
|
|
32609
32616
|
}
|
|
32610
32617
|
/** there was a long-term disconnection of the socket */
|
|
32611
32618
|
notifyClientTooOld() {
|
|
@@ -48410,12 +48417,43 @@ class RpcManager {
|
|
|
48410
48417
|
getStaticHeaders() {
|
|
48411
48418
|
return this.staticHeaders;
|
|
48412
48419
|
}
|
|
48420
|
+
async ready() {
|
|
48421
|
+
// Waiting for socket connection to be established before sending an RPC request
|
|
48422
|
+
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48423
|
+
await this.authManager.waitForReadyState();
|
|
48424
|
+
}
|
|
48425
|
+
async get(path, params) {
|
|
48426
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48427
|
+
try {
|
|
48428
|
+
await this.ready();
|
|
48429
|
+
const url = new URL(getApplicationUrl(this.region, this.appId, path));
|
|
48430
|
+
const searchParams = new URLSearchParams(url.search);
|
|
48431
|
+
for (const [key, value] of Object.entries(params || {})) {
|
|
48432
|
+
if (value !== null) {
|
|
48433
|
+
searchParams.set(key, value);
|
|
48434
|
+
}
|
|
48435
|
+
}
|
|
48436
|
+
url.search = searchParams.toString();
|
|
48437
|
+
const response = await (0,external_cross_fetch_namespaceObject["default"])(url.toString(), {
|
|
48438
|
+
method: 'GET',
|
|
48439
|
+
headers: this.staticHeaders,
|
|
48440
|
+
});
|
|
48441
|
+
return await this.parseResponse(response);
|
|
48442
|
+
}
|
|
48443
|
+
finally {
|
|
48444
|
+
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48445
|
+
}
|
|
48446
|
+
}
|
|
48413
48447
|
async post(path, message) {
|
|
48448
|
+
return this.postOrDelete('POST', path, message);
|
|
48449
|
+
}
|
|
48450
|
+
async delete(path, message) {
|
|
48451
|
+
return this.postOrDelete('DELETE', path, message);
|
|
48452
|
+
}
|
|
48453
|
+
async postOrDelete(method, path, message) {
|
|
48414
48454
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48415
48455
|
try {
|
|
48416
|
-
|
|
48417
|
-
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48418
|
-
await this.authManager.waitForReadyState();
|
|
48456
|
+
await this.ready();
|
|
48419
48457
|
let headers = {
|
|
48420
48458
|
'Content-Type': 'application/json',
|
|
48421
48459
|
};
|
|
@@ -48425,31 +48463,34 @@ class RpcManager {
|
|
|
48425
48463
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
48426
48464
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
48427
48465
|
const response = await (0,external_cross_fetch_namespaceObject["default"])(url, {
|
|
48428
|
-
method
|
|
48466
|
+
method,
|
|
48429
48467
|
body: serialization_serializeObj(message),
|
|
48430
48468
|
headers: headers,
|
|
48431
48469
|
});
|
|
48432
|
-
|
|
48433
|
-
let json;
|
|
48434
|
-
try {
|
|
48435
|
-
text = await response.text();
|
|
48436
|
-
try {
|
|
48437
|
-
json = JSON.parse(text);
|
|
48438
|
-
}
|
|
48439
|
-
catch (_a) { }
|
|
48440
|
-
}
|
|
48441
|
-
catch (_b) {
|
|
48442
|
-
text = 'Cannot read body';
|
|
48443
|
-
}
|
|
48444
|
-
if (!response.ok) {
|
|
48445
|
-
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48446
|
-
}
|
|
48447
|
-
return (json || text);
|
|
48470
|
+
return await this.parseResponse(response);
|
|
48448
48471
|
}
|
|
48449
48472
|
finally {
|
|
48450
48473
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48451
48474
|
}
|
|
48452
48475
|
}
|
|
48476
|
+
async parseResponse(response) {
|
|
48477
|
+
let text;
|
|
48478
|
+
let json;
|
|
48479
|
+
try {
|
|
48480
|
+
text = await response.text();
|
|
48481
|
+
try {
|
|
48482
|
+
json = JSON.parse(text);
|
|
48483
|
+
}
|
|
48484
|
+
catch (_a) { }
|
|
48485
|
+
}
|
|
48486
|
+
catch (_b) {
|
|
48487
|
+
text = 'Cannot read body';
|
|
48488
|
+
}
|
|
48489
|
+
if (!response.ok) {
|
|
48490
|
+
throw new RpcError(response.status, response.statusText, response.headers, response.url, json === null || json === void 0 ? void 0 : json['message']);
|
|
48491
|
+
}
|
|
48492
|
+
return (json || text);
|
|
48493
|
+
}
|
|
48453
48494
|
}
|
|
48454
48495
|
class RpcError extends Error {
|
|
48455
48496
|
constructor(statusCode, statusText, headers, url, message) {
|
|
@@ -48461,6 +48502,45 @@ class RpcError extends Error {
|
|
|
48461
48502
|
}
|
|
48462
48503
|
}
|
|
48463
48504
|
|
|
48505
|
+
;// CONCATENATED MODULE: ./src/secret.client.ts
|
|
48506
|
+
class SecretClient {
|
|
48507
|
+
constructor(rpcManager) {
|
|
48508
|
+
this.rpcManager = rpcManager;
|
|
48509
|
+
}
|
|
48510
|
+
get(key) {
|
|
48511
|
+
return this.rpcManager.get('/secret/get', { key });
|
|
48512
|
+
}
|
|
48513
|
+
getAll() {
|
|
48514
|
+
return this.rpcManager.get('/secret/getAll');
|
|
48515
|
+
}
|
|
48516
|
+
upsert(key, value) {
|
|
48517
|
+
return this.rpcManager.post('/secret/upsert', { key, value });
|
|
48518
|
+
}
|
|
48519
|
+
delete(key) {
|
|
48520
|
+
return this.rpcManager.delete('/secret/delete', { key });
|
|
48521
|
+
}
|
|
48522
|
+
get apiKeys() {
|
|
48523
|
+
return new ApiKeysSecretClient(this.rpcManager);
|
|
48524
|
+
}
|
|
48525
|
+
}
|
|
48526
|
+
class ApiKeysSecretClient {
|
|
48527
|
+
constructor(rpcManager) {
|
|
48528
|
+
this.rpcManager = rpcManager;
|
|
48529
|
+
}
|
|
48530
|
+
get(key) {
|
|
48531
|
+
return this.rpcManager.get('/secret/api-key/get', { key });
|
|
48532
|
+
}
|
|
48533
|
+
getAll() {
|
|
48534
|
+
return this.rpcManager.get('/secret/api-key/getAll');
|
|
48535
|
+
}
|
|
48536
|
+
upsert(key) {
|
|
48537
|
+
return this.rpcManager.post('/secret/api-key/upsert', { key });
|
|
48538
|
+
}
|
|
48539
|
+
delete(key) {
|
|
48540
|
+
return this.rpcManager.delete('/secret/api-key/delete', { key });
|
|
48541
|
+
}
|
|
48542
|
+
}
|
|
48543
|
+
|
|
48464
48544
|
;// CONCATENATED MODULE: ./src/types.ts
|
|
48465
48545
|
/**
|
|
48466
48546
|
* @internal
|
|
@@ -48493,7 +48573,7 @@ class SocketManager {
|
|
|
48493
48573
|
* This value means we wait for 5 minutes before considering the client to be too old.
|
|
48494
48574
|
* Note: we make this a function so that we can easily override it in tests.
|
|
48495
48575
|
*/
|
|
48496
|
-
this.clientTooOldThreshold =
|
|
48576
|
+
this.clientTooOldThreshold = 30000;
|
|
48497
48577
|
this.destructManager.onDestruct(async () => {
|
|
48498
48578
|
await this.destruct();
|
|
48499
48579
|
});
|
|
@@ -48634,6 +48714,7 @@ class SocketManager {
|
|
|
48634
48714
|
|
|
48635
48715
|
|
|
48636
48716
|
|
|
48717
|
+
|
|
48637
48718
|
|
|
48638
48719
|
|
|
48639
48720
|
/**
|
|
@@ -48836,6 +48917,7 @@ class Squid {
|
|
|
48836
48917
|
this.apiManager = new ApiManager(this.clientIdService, this.rpcManager, this.socketManager, options.apiServerUrlOverrideMapping);
|
|
48837
48918
|
this.graphqlClientFactory = new GraphQLClientFactory(this.rpcManager, options.region, appId);
|
|
48838
48919
|
this.aiClientFactory = new AiClientFactory(this.rpcManager, this.socketManager);
|
|
48920
|
+
this.secretClient = new SecretClient(this.rpcManager);
|
|
48839
48921
|
this._connectionDetails = new ConnectionDetails(this.clientIdService, this.socketManager);
|
|
48840
48922
|
}
|
|
48841
48923
|
/**
|
|
@@ -48862,6 +48944,11 @@ class Squid {
|
|
|
48862
48944
|
static getInstances() {
|
|
48863
48945
|
return Object.values(Squid.squidInstancesMap);
|
|
48864
48946
|
}
|
|
48947
|
+
get secrets() {
|
|
48948
|
+
return (() => {
|
|
48949
|
+
return this.secretClient;
|
|
48950
|
+
})();
|
|
48951
|
+
}
|
|
48865
48952
|
validateNotDestructed() {
|
|
48866
48953
|
assert_assertTruthy(!this.destructManager.isDestructing, 'The client was already destructed.');
|
|
48867
48954
|
}
|
|
@@ -17,7 +17,12 @@ export declare class RpcManager {
|
|
|
17
17
|
setStaticHeader(key: string, value: string): void;
|
|
18
18
|
deleteStaticHeader(key: string): void;
|
|
19
19
|
getStaticHeaders(): Record<string, string>;
|
|
20
|
+
private ready;
|
|
21
|
+
get<T>(path: string, params?: Record<string, any>): Promise<T>;
|
|
20
22
|
post<T>(path: string, message: any): Promise<T>;
|
|
23
|
+
delete<T>(path: string, message: any): Promise<T>;
|
|
24
|
+
private postOrDelete;
|
|
25
|
+
private parseResponse;
|
|
21
26
|
}
|
|
22
27
|
export declare class RpcError extends Error {
|
|
23
28
|
readonly statusCode: number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SecretEntry, SecretKey, SecretValue } from '@squidcloud/common';
|
|
2
|
+
import { RpcManager } from './rpc.manager';
|
|
3
|
+
export declare class SecretClient {
|
|
4
|
+
private readonly rpcManager;
|
|
5
|
+
constructor(rpcManager: RpcManager);
|
|
6
|
+
get(key: SecretKey): Promise<SecretEntry | undefined>;
|
|
7
|
+
getAll(): Promise<Record<SecretKey, SecretEntry>>;
|
|
8
|
+
upsert(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
|
|
9
|
+
delete(key: SecretKey): Promise<void>;
|
|
10
|
+
get apiKeys(): ApiKeysSecretClient;
|
|
11
|
+
}
|
|
12
|
+
declare class ApiKeysSecretClient {
|
|
13
|
+
private readonly rpcManager;
|
|
14
|
+
constructor(rpcManager: RpcManager);
|
|
15
|
+
get(key: SecretKey): Promise<SecretEntry | undefined>;
|
|
16
|
+
getAll(): Promise<Record<SecretKey, SecretEntry>>;
|
|
17
|
+
upsert(key: SecretKey): Promise<SecretEntry>;
|
|
18
|
+
delete(key: SecretKey): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -5,6 +5,7 @@ import { CollectionReference } from './collection-reference';
|
|
|
5
5
|
import { ConnectionDetails } from './connection-details';
|
|
6
6
|
import { DistributedLock } from './distributed-lock.manager';
|
|
7
7
|
import { GraphQLClient } from './graphql-client';
|
|
8
|
+
import { SecretClient } from './secret.client';
|
|
8
9
|
import { TransactionId } from './types';
|
|
9
10
|
/** The different options that can be used to initialize a Squid instance. */
|
|
10
11
|
export interface SquidOptions {
|
|
@@ -71,6 +72,7 @@ export declare class Squid {
|
|
|
71
72
|
private readonly clientIdService;
|
|
72
73
|
private readonly aiClientFactory;
|
|
73
74
|
private readonly _connectionDetails;
|
|
75
|
+
private readonly secretClient;
|
|
74
76
|
private static readonly squidInstancesMap;
|
|
75
77
|
/**
|
|
76
78
|
* Creates a new instance of Squid with the given options.
|
|
@@ -195,6 +197,7 @@ export declare class Squid {
|
|
|
195
197
|
*/
|
|
196
198
|
assistant: (integrationId: IntegrationId) => AiAssistantClient;
|
|
197
199
|
};
|
|
200
|
+
get secrets(): SecretClient;
|
|
198
201
|
/**
|
|
199
202
|
* Returns a distributed lock for the given mutex. The lock can be used to synchronize access to a shared resource.
|
|
200
203
|
* The lock will be released when the release method on the returned object is invoked or whenever the connection
|