@squidcloud/client 1.0.109 → 1.0.111

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'],
@@ -31959,6 +31936,7 @@ class QueryBuilder extends BaseQueryBuilder {
31959
31936
  }
31960
31937
  return [...this.query.conditions.filter((c) => !isSimpleCondition(c)), ...result];
31961
31938
  }
31939
+ // noinspection JSUnusedGlobalSymbols
31962
31940
  getSortOrder() {
31963
31941
  return this.query.sortOrder;
31964
31942
  }
@@ -31986,9 +31964,15 @@ class QueryBuilder extends BaseQueryBuilder {
31986
31964
  * @inheritDoc
31987
31965
  */
31988
31966
  snapshots(subscribe = true) {
31967
+ const query = this.build();
31989
31968
  return this.querySubscriptionManager
31990
- .processQuery(this.build(), this.collectionName, {}, {}, subscribe, this.forceFetchFromServer)
31991
- .pipe(map_map((docs) => {
31969
+ .processQuery(query, this.collectionName, {}, {}, subscribe, this.forceFetchFromServer)
31970
+ .pipe((0,external_rxjs_namespaceObject.timeout)(10000), (0,external_rxjs_namespaceObject.catchError)((err) => {
31971
+ if (err.name === 'TimeoutError') {
31972
+ return (0,external_rxjs_namespaceObject.throwError)(() => Error(`Error while waiting for query response, collection: ${this.collectionName}, query: ${JSON.stringify(query)}, error: ${err}`));
31973
+ }
31974
+ return (0,external_rxjs_namespaceObject.throwError)(() => err);
31975
+ }), map_map((docs) => {
31992
31976
  return docs.map((docRecord) => {
31993
31977
  assert_assertTruthy(Object.keys(docRecord).length === 1);
31994
31978
  const doc = docRecord[this.collectionName];
@@ -32103,6 +32087,7 @@ class QueryBuilder extends BaseQueryBuilder {
32103
32087
  }
32104
32088
  /** Describes the changes to a query result. */
32105
32089
  class Changes {
32090
+ // noinspection JSUnusedGlobalSymbols
32106
32091
  constructor(
32107
32092
  /** The newly inserted documents to the query result */
32108
32093
  inserts,
@@ -48549,35 +48534,7 @@ class RpcManager {
48549
48534
  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
48535
  await this.authManager.waitForReadyState();
48551
48536
  }
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
48537
  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
48538
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48582
48539
  try {
48583
48540
  await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
@@ -48590,7 +48547,7 @@ class RpcManager {
48590
48547
  DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
48591
48548
  const url = getApplicationUrl(this.region, this.appId, path);
48592
48549
  const response = await external_cross_fetch_default()(url, {
48593
- method,
48550
+ method: 'POST',
48594
48551
  body: serialization_serializeObj(message),
48595
48552
  headers: headers,
48596
48553
  });
@@ -48635,16 +48592,27 @@ class SecretClient {
48635
48592
  this.rpcManager = rpcManager;
48636
48593
  }
48637
48594
  get(key) {
48638
- return this.rpcManager.get('/secret/get', { key });
48595
+ const request = { key };
48596
+ return this.rpcManager.post('/secret/get', request);
48639
48597
  }
48640
48598
  getAll() {
48641
- return this.rpcManager.get('/secret/getAll');
48599
+ return this.rpcManager.post('/secret/getAll', {});
48642
48600
  }
48643
48601
  upsert(key, value) {
48644
- return this.rpcManager.post('/secret/upsert', { key, value });
48602
+ const request = { entries: [{ key, value }] };
48603
+ return this.rpcManager.post('/secret/upsert', request);
48604
+ }
48605
+ upsertMany(entries) {
48606
+ const request = { entries };
48607
+ return this.rpcManager.post('/secret/upsert', request);
48645
48608
  }
48646
48609
  delete(key) {
48647
- return this.rpcManager.delete('/secret/delete', { key });
48610
+ const request = { keys: [key] };
48611
+ return this.rpcManager.post('/secret/delete', request);
48612
+ }
48613
+ deleteMany(keys) {
48614
+ const request = { keys };
48615
+ return this.rpcManager.post('/secret/delete', request);
48648
48616
  }
48649
48617
  get apiKeys() {
48650
48618
  return new ApiKeysSecretClient(this.rpcManager);
@@ -48655,16 +48623,19 @@ class ApiKeysSecretClient {
48655
48623
  this.rpcManager = rpcManager;
48656
48624
  }
48657
48625
  get(key) {
48658
- return this.rpcManager.get('/secret/api-key/get', { key });
48626
+ const request = { key };
48627
+ return this.rpcManager.post('/secret/api-key/get', request);
48659
48628
  }
48660
48629
  getAll() {
48661
- return this.rpcManager.get('/secret/api-key/getAll');
48630
+ return this.rpcManager.post('/secret/api-key/getAll', {});
48662
48631
  }
48663
48632
  upsert(key) {
48664
- return this.rpcManager.post('/secret/api-key/upsert', { key });
48633
+ const request = { key };
48634
+ return this.rpcManager.post('/secret/api-key/upsert', request);
48665
48635
  }
48666
48636
  delete(key) {
48667
- return this.rpcManager.delete('/secret/api-key/delete', { key });
48637
+ const request = { key };
48638
+ return this.rpcManager.post('/secret/api-key/delete', request);
48668
48639
  }
48669
48640
  }
48670
48641
 
@@ -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,4 +1,4 @@
1
- import { SecretEntry, SecretKey, SecretValue } from '@squidcloud/common';
1
+ import { SecretEntry, SecretKey, SecretValue, SetSecretRequestEntry } from '@squidcloud/common';
2
2
  import { RpcManager } from './rpc.manager';
3
3
  export declare class SecretClient {
4
4
  private readonly rpcManager;
@@ -6,7 +6,9 @@ export declare class SecretClient {
6
6
  get(key: SecretKey): Promise<SecretEntry | undefined>;
7
7
  getAll(): Promise<Record<SecretKey, SecretEntry>>;
8
8
  upsert(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
9
+ upsertMany(entries: Array<SetSecretRequestEntry>): Promise<SecretEntry>;
9
10
  delete(key: SecretKey): Promise<void>;
11
+ deleteMany(keys: Array<SecretKey>): Promise<void>;
10
12
  get apiKeys(): ApiKeysSecretClient;
11
13
  }
12
14
  declare class ApiKeysSecretClient {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.109",
3
+ "version": "1.0.111",
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",