@go-avro/avro-js 0.0.2-beta.113 → 0.0.2-beta.114

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.
@@ -17,7 +17,8 @@ export declare class AuthManager {
17
17
  refreshTokens(): Promise<Tokens | null>;
18
18
  setTokens(tokens: Tokens): Promise<void>;
19
19
  setCache(data: Partial<CacheData>): Promise<void>;
20
+ getCache(key?: keyof CacheData): Promise<CacheData | string | null>;
20
21
  clearCache(): Promise<void>;
21
22
  getCompanyId(): Promise<string | null>;
22
- setCompanyId(companyId: string): Promise<void>;
23
+ setCompanyId(companyId: string): Promise<void[]>;
23
24
  }
@@ -121,6 +121,17 @@ export class AuthManager {
121
121
  async setCache(data) {
122
122
  await Promise.all(this.storages.map(s => s.set(data)));
123
123
  }
124
+ async getCache(key) {
125
+ if (!this.storages.length) {
126
+ return null;
127
+ }
128
+ for (const storage of this.storages) {
129
+ const cache = await storage.get(key);
130
+ if (cache)
131
+ return cache;
132
+ }
133
+ return null;
134
+ }
124
135
  async clearCache() {
125
136
  await Promise.all(this.storages.map(s => s.clear()));
126
137
  }
@@ -136,6 +147,6 @@ export class AuthManager {
136
147
  return null;
137
148
  }
138
149
  async setCompanyId(companyId) {
139
- await Promise.all(this.storages.map(s => s.set({ companyId })));
150
+ return Promise.all(this.storages.map(s => s.set({ companyId })));
140
151
  }
141
152
  }
@@ -312,7 +312,8 @@ export declare class AvroQueryClient {
312
312
  }>>;
313
313
  setTokens(tokens: Tokens): Promise<void>;
314
314
  setCache(data: Partial<CacheData>): Promise<void>;
315
- setCompanyId(companyId: string): void;
315
+ getCache(key: keyof CacheData | undefined): Promise<CacheData | string | null>;
316
+ setCompanyId(companyId: string): Promise<void[]>;
316
317
  clearCache(): Promise<void>;
317
318
  isAuthenticated(): boolean;
318
319
  isAuthenticatedAsync(): Promise<boolean>;
@@ -167,9 +167,12 @@ export class AvroQueryClient {
167
167
  setCache(data) {
168
168
  return this.config.authManager.setCache(data);
169
169
  }
170
+ getCache(key) {
171
+ return this.config.authManager.getCache(key);
172
+ }
170
173
  setCompanyId(companyId) {
171
174
  this.companyId = companyId;
172
- this.config.authManager.setCompanyId(companyId);
175
+ return this.config.authManager.setCompanyId(companyId);
173
176
  }
174
177
  clearCache() {
175
178
  return this.config.authManager.clearCache();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.113",
3
+ "version": "0.0.2-beta.114",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",