@squidcloud/client 1.0.109 → 1.0.110
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
|
@@ -29606,29 +29606,6 @@ function findMatchingPropertiesForKey(schema, key) {
|
|
|
29606
29606
|
|
|
29607
29607
|
;// CONCATENATED MODULE: ../common/src/secret.schemas.ts
|
|
29608
29608
|
/** @internal */
|
|
29609
|
-
const SetSecretRequestSchema = {
|
|
29610
|
-
type: 'object',
|
|
29611
|
-
required: ['key', 'value'],
|
|
29612
|
-
properties: {
|
|
29613
|
-
key: { type: 'string', pattern: '[a-zA-Z0-9-_+]', nullable: false },
|
|
29614
|
-
value: {
|
|
29615
|
-
anyOf: [
|
|
29616
|
-
{ type: 'string', nullable: false },
|
|
29617
|
-
{ type: 'number', nullable: false },
|
|
29618
|
-
{ type: 'boolean', nullable: false },
|
|
29619
|
-
],
|
|
29620
|
-
},
|
|
29621
|
-
},
|
|
29622
|
-
};
|
|
29623
|
-
/** @internal */
|
|
29624
|
-
const DeleteSecretRequestSchema = {
|
|
29625
|
-
type: 'object',
|
|
29626
|
-
required: ['key'],
|
|
29627
|
-
properties: {
|
|
29628
|
-
key: { type: 'string', pattern: '[a-zA-Z0-9-_]+', nullable: false, isSecret: {} },
|
|
29629
|
-
},
|
|
29630
|
-
};
|
|
29631
|
-
/** @internal */
|
|
29632
29609
|
const DeleteApiKeyRequestSchema = {
|
|
29633
29610
|
type: 'object',
|
|
29634
29611
|
required: ['key'],
|
|
@@ -48549,35 +48526,7 @@ class RpcManager {
|
|
|
48549
48526
|
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.race)(this.socketManager.observeConnectionReady().pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing()));
|
|
48550
48527
|
await this.authManager.waitForReadyState();
|
|
48551
48528
|
}
|
|
48552
|
-
async get(path, params) {
|
|
48553
|
-
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48554
|
-
try {
|
|
48555
|
-
await this.ready();
|
|
48556
|
-
const url = new URL(getApplicationUrl(this.region, this.appId, path));
|
|
48557
|
-
const searchParams = new URLSearchParams(url.search);
|
|
48558
|
-
for (const [key, value] of Object.entries(params || {})) {
|
|
48559
|
-
if (value !== null) {
|
|
48560
|
-
searchParams.set(key, value);
|
|
48561
|
-
}
|
|
48562
|
-
}
|
|
48563
|
-
url.search = searchParams.toString();
|
|
48564
|
-
const response = await external_cross_fetch_default()(url.toString(), {
|
|
48565
|
-
method: 'GET',
|
|
48566
|
-
headers: this.staticHeaders,
|
|
48567
|
-
});
|
|
48568
|
-
return await this.parseResponse(response);
|
|
48569
|
-
}
|
|
48570
|
-
finally {
|
|
48571
|
-
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
|
|
48572
|
-
}
|
|
48573
|
-
}
|
|
48574
48529
|
async post(path, message) {
|
|
48575
|
-
return this.postOrDelete('POST', path, message);
|
|
48576
|
-
}
|
|
48577
|
-
async delete(path, message) {
|
|
48578
|
-
return this.postOrDelete('DELETE', path, message);
|
|
48579
|
-
}
|
|
48580
|
-
async postOrDelete(method, path, message) {
|
|
48581
48530
|
this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
|
|
48582
48531
|
try {
|
|
48583
48532
|
await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
|
|
@@ -48590,7 +48539,7 @@ class RpcManager {
|
|
|
48590
48539
|
DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
|
|
48591
48540
|
const url = getApplicationUrl(this.region, this.appId, path);
|
|
48592
48541
|
const response = await external_cross_fetch_default()(url, {
|
|
48593
|
-
method,
|
|
48542
|
+
method: 'POST',
|
|
48594
48543
|
body: serialization_serializeObj(message),
|
|
48595
48544
|
headers: headers,
|
|
48596
48545
|
});
|
|
@@ -48635,16 +48584,19 @@ class SecretClient {
|
|
|
48635
48584
|
this.rpcManager = rpcManager;
|
|
48636
48585
|
}
|
|
48637
48586
|
get(key) {
|
|
48638
|
-
|
|
48587
|
+
const request = { key };
|
|
48588
|
+
return this.rpcManager.post('/secret/get', request);
|
|
48639
48589
|
}
|
|
48640
48590
|
getAll() {
|
|
48641
|
-
return this.rpcManager.
|
|
48591
|
+
return this.rpcManager.post('/secret/getAll', {});
|
|
48642
48592
|
}
|
|
48643
|
-
upsert(
|
|
48644
|
-
|
|
48593
|
+
upsert(entries) {
|
|
48594
|
+
const request = { entries };
|
|
48595
|
+
return this.rpcManager.post('/secret/upsert', request);
|
|
48645
48596
|
}
|
|
48646
|
-
delete(
|
|
48647
|
-
|
|
48597
|
+
delete(keys) {
|
|
48598
|
+
const request = { keys };
|
|
48599
|
+
return this.rpcManager.post('/secret/delete', request);
|
|
48648
48600
|
}
|
|
48649
48601
|
get apiKeys() {
|
|
48650
48602
|
return new ApiKeysSecretClient(this.rpcManager);
|
|
@@ -48655,16 +48607,19 @@ class ApiKeysSecretClient {
|
|
|
48655
48607
|
this.rpcManager = rpcManager;
|
|
48656
48608
|
}
|
|
48657
48609
|
get(key) {
|
|
48658
|
-
|
|
48610
|
+
const request = { key };
|
|
48611
|
+
return this.rpcManager.post('/secret/api-key/get', request);
|
|
48659
48612
|
}
|
|
48660
48613
|
getAll() {
|
|
48661
|
-
return this.rpcManager.
|
|
48614
|
+
return this.rpcManager.post('/secret/api-key/getAll', {});
|
|
48662
48615
|
}
|
|
48663
48616
|
upsert(key) {
|
|
48664
|
-
|
|
48617
|
+
const request = { key };
|
|
48618
|
+
return this.rpcManager.post('/secret/api-key/upsert', request);
|
|
48665
48619
|
}
|
|
48666
48620
|
delete(key) {
|
|
48667
|
-
|
|
48621
|
+
const request = { key };
|
|
48622
|
+
return this.rpcManager.post('/secret/api-key/delete', request);
|
|
48668
48623
|
}
|
|
48669
48624
|
}
|
|
48670
48625
|
|
|
@@ -4,6 +4,10 @@ export type SecretKey = string;
|
|
|
4
4
|
export type SecretValue = string | number | boolean;
|
|
5
5
|
/** A type alias for an ApiKey. */
|
|
6
6
|
export type ApiKey = string;
|
|
7
|
+
export type SetSecretEntry = {
|
|
8
|
+
key: SecretKey;
|
|
9
|
+
value?: SecretValue;
|
|
10
|
+
};
|
|
7
11
|
export declare const BACKEND_API_KEY = "_BACKEND_API_KEY";
|
|
8
12
|
export declare const APP_API_KEY = "APP_API_KEY";
|
|
9
13
|
export interface SecretEntry<T extends SecretValue = SecretValue> extends SecretMetadata {
|
|
@@ -12,3 +16,7 @@ export interface SecretEntry<T extends SecretValue = SecretValue> extends Secret
|
|
|
12
16
|
export interface ApiKeyEntry extends SecretMetadata {
|
|
13
17
|
value: string;
|
|
14
18
|
}
|
|
19
|
+
export interface SetSecretRequestEntry {
|
|
20
|
+
key: SecretKey;
|
|
21
|
+
value: SecretValue;
|
|
22
|
+
}
|
|
@@ -18,10 +18,7 @@ export declare class RpcManager {
|
|
|
18
18
|
deleteStaticHeader(key: string): void;
|
|
19
19
|
getStaticHeaders(): Record<string, string>;
|
|
20
20
|
private ready;
|
|
21
|
-
get<T>(path: string, params?: Record<string, any>): Promise<T>;
|
|
22
21
|
post<T>(path: string, message: any): Promise<T>;
|
|
23
|
-
delete<T>(path: string, message: any): Promise<T>;
|
|
24
|
-
private postOrDelete;
|
|
25
22
|
private parseResponse;
|
|
26
23
|
}
|
|
27
24
|
export declare class RpcError extends Error {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { SecretEntry, SecretKey,
|
|
1
|
+
import { SecretEntry, SecretKey, SetSecretRequestEntry } from '@squidcloud/common';
|
|
2
2
|
import { RpcManager } from './rpc.manager';
|
|
3
3
|
export declare class SecretClient {
|
|
4
4
|
private readonly rpcManager;
|
|
5
5
|
constructor(rpcManager: RpcManager);
|
|
6
6
|
get(key: SecretKey): Promise<SecretEntry | undefined>;
|
|
7
7
|
getAll(): Promise<Record<SecretKey, SecretEntry>>;
|
|
8
|
-
upsert(
|
|
9
|
-
delete(
|
|
8
|
+
upsert(entries: Array<SetSecretRequestEntry>): Promise<SecretEntry>;
|
|
9
|
+
delete(keys: Array<SecretKey>): Promise<void>;
|
|
10
10
|
get apiKeys(): ApiKeysSecretClient;
|
|
11
11
|
}
|
|
12
12
|
declare class ApiKeysSecretClient {
|