@squidcloud/client 1.0.108 → 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'],
@@ -29926,18 +29903,22 @@ class DebugLogger {
29926
29903
  DebugLogger.info(...args);
29927
29904
  }
29928
29905
  static info(...args) {
29929
- console.log(`%c[${new Date().toLocaleTimeString()}] INFO`, 'color:green', ...args);
29906
+ console.log(`%c[${DebugLogger.getTimestampString()}] INFO`, 'color:green', ...args);
29930
29907
  }
29931
29908
  static warn(...args) {
29932
- console.warn(`%c[${new Date().toLocaleTimeString()}] WARN`, 'color:yellow', ...args);
29909
+ console.warn(`%c[${DebugLogger.getTimestampString()}] WARN`, 'color:yellow', ...args);
29933
29910
  }
29934
29911
  static error(...args) {
29935
- console.error(`%c[${new Date().toLocaleTimeString()}] ERROR`, 'color:red', ...args);
29912
+ console.error(`%c[${DebugLogger.getTimestampString()}] ERROR`, 'color:red', ...args);
29936
29913
  }
29937
29914
  static debug(...args) {
29938
29915
  if (!isDebugEnabled())
29939
29916
  return;
29940
- console.log(`%c[${new Date().toLocaleTimeString()}] DEBUG`, 'color:cyan', ...args);
29917
+ console.log(`%c[${DebugLogger.getTimestampString()}] DEBUG`, 'color:cyan', ...args);
29918
+ }
29919
+ static getTimestampString() {
29920
+ const date = new Date();
29921
+ return `${date.toLocaleTimeString()}.${date.getMilliseconds()}`;
29941
29922
  }
29942
29923
  }
29943
29924
 
@@ -47058,6 +47039,13 @@ class MutationSender {
47058
47039
  };
47059
47040
  return await this.rpcManager.post('mutation/mutate', request);
47060
47041
  }
47042
+ catch (e) {
47043
+ DebugLogger.debug('Error while sending mutations', {
47044
+ error: e,
47045
+ mutations: JSON.stringify(reducedMutations, null, 2),
47046
+ });
47047
+ throw e;
47048
+ }
47061
47049
  finally {
47062
47050
  this.lockManager.release(...mutexes);
47063
47051
  }
@@ -48300,6 +48288,7 @@ class QuerySubscriptionManager {
48300
48288
  this.rpcManager
48301
48289
  .post('query/query', queryRequest)
48302
48290
  .catch((e) => {
48291
+ DebugLogger.debug('Query error', ongoingQuery.query, e);
48303
48292
  ongoingQuery.dataSubject.error(e);
48304
48293
  ongoingQuery.done = true;
48305
48294
  ongoingQuery.queryRegistered.error('query failed');
@@ -48537,38 +48526,10 @@ class RpcManager {
48537
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()));
48538
48527
  await this.authManager.waitForReadyState();
48539
48528
  }
48540
- async get(path, params) {
48541
- this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48542
- try {
48543
- await this.ready();
48544
- const url = new URL(getApplicationUrl(this.region, this.appId, path));
48545
- const searchParams = new URLSearchParams(url.search);
48546
- for (const [key, value] of Object.entries(params || {})) {
48547
- if (value !== null) {
48548
- searchParams.set(key, value);
48549
- }
48550
- }
48551
- url.search = searchParams.toString();
48552
- const response = await external_cross_fetch_default()(url.toString(), {
48553
- method: 'GET',
48554
- headers: this.staticHeaders,
48555
- });
48556
- return await this.parseResponse(response);
48557
- }
48558
- finally {
48559
- this.onGoingRpcCounter.next(this.onGoingRpcCounter.value - 1);
48560
- }
48561
- }
48562
48529
  async post(path, message) {
48563
- return this.postOrDelete('POST', path, message);
48564
- }
48565
- async delete(path, message) {
48566
- return this.postOrDelete('DELETE', path, message);
48567
- }
48568
- async postOrDelete(method, path, message) {
48569
48530
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48570
48531
  try {
48571
- await this.ready();
48532
+ await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
48572
48533
  let headers = {
48573
48534
  'Content-Type': 'application/json',
48574
48535
  };
@@ -48578,7 +48539,7 @@ class RpcManager {
48578
48539
  DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
48579
48540
  const url = getApplicationUrl(this.region, this.appId, path);
48580
48541
  const response = await external_cross_fetch_default()(url, {
48581
- method,
48542
+ method: 'POST',
48582
48543
  body: serialization_serializeObj(message),
48583
48544
  headers: headers,
48584
48545
  });
@@ -48623,16 +48584,19 @@ class SecretClient {
48623
48584
  this.rpcManager = rpcManager;
48624
48585
  }
48625
48586
  get(key) {
48626
- return this.rpcManager.get('/secret/get', { key });
48587
+ const request = { key };
48588
+ return this.rpcManager.post('/secret/get', request);
48627
48589
  }
48628
48590
  getAll() {
48629
- return this.rpcManager.get('/secret/getAll');
48591
+ return this.rpcManager.post('/secret/getAll', {});
48630
48592
  }
48631
- upsert(key, value) {
48632
- return this.rpcManager.post('/secret/upsert', { key, value });
48593
+ upsert(entries) {
48594
+ const request = { entries };
48595
+ return this.rpcManager.post('/secret/upsert', request);
48633
48596
  }
48634
- delete(key) {
48635
- return this.rpcManager.delete('/secret/delete', { key });
48597
+ delete(keys) {
48598
+ const request = { keys };
48599
+ return this.rpcManager.post('/secret/delete', request);
48636
48600
  }
48637
48601
  get apiKeys() {
48638
48602
  return new ApiKeysSecretClient(this.rpcManager);
@@ -48643,16 +48607,19 @@ class ApiKeysSecretClient {
48643
48607
  this.rpcManager = rpcManager;
48644
48608
  }
48645
48609
  get(key) {
48646
- return this.rpcManager.get('/secret/api-key/get', { key });
48610
+ const request = { key };
48611
+ return this.rpcManager.post('/secret/api-key/get', request);
48647
48612
  }
48648
48613
  getAll() {
48649
- return this.rpcManager.get('/secret/api-key/getAll');
48614
+ return this.rpcManager.post('/secret/api-key/getAll', {});
48650
48615
  }
48651
48616
  upsert(key) {
48652
- return this.rpcManager.post('/secret/api-key/upsert', { key });
48617
+ const request = { key };
48618
+ return this.rpcManager.post('/secret/api-key/upsert', request);
48653
48619
  }
48654
48620
  delete(key) {
48655
- return this.rpcManager.delete('/secret/api-key/delete', { key });
48621
+ const request = { key };
48622
+ return this.rpcManager.post('/secret/api-key/delete', request);
48656
48623
  }
48657
48624
  }
48658
48625
 
@@ -48699,8 +48666,8 @@ class SocketManager {
48699
48666
  return (0,external_rxjs_namespaceObject.race)((0,external_rxjs_namespaceObject.timer)(this.clientTooOldThreshold), this.connectionReady.pipe((0,external_rxjs_namespaceObject.filter)(Boolean)), this.destructManager.observeIsDestructing());
48700
48667
  }))
48701
48668
  .subscribe(() => {
48702
- DebugLogger.debug('Client too old but already connected. Ignoring...');
48703
48669
  if (this.connectionReady.value || this.destructManager.isDestructing) {
48670
+ DebugLogger.debug('Client too old but already connected or the client is destructing. Ignoring...');
48704
48671
  return;
48705
48672
  }
48706
48673
  this.clientIdService.notifyClientTooOld();
@@ -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, SecretValue } from '@squidcloud/common';
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(key: SecretKey, value: SecretValue): Promise<SecretEntry>;
9
- delete(key: SecretKey): Promise<void>;
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.108",
3
+ "version": "1.0.110",
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",