@go-avro/avro-js 0.0.2-beta.113 → 0.0.2-beta.115
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
|
}
|
package/dist/auth/AuthManager.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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>;
|
|
@@ -145,6 +145,7 @@ export class AvroQueryClient {
|
|
|
145
145
|
}
|
|
146
146
|
throw new StandardError(401, 'Invalid Google login response');
|
|
147
147
|
}
|
|
148
|
+
this._isAuthenticated = true;
|
|
148
149
|
this.socket.auth = { token: resp.access_token };
|
|
149
150
|
if (!this.socket.connected) {
|
|
150
151
|
this.socket.connect();
|
|
@@ -167,9 +168,12 @@ export class AvroQueryClient {
|
|
|
167
168
|
setCache(data) {
|
|
168
169
|
return this.config.authManager.setCache(data);
|
|
169
170
|
}
|
|
171
|
+
getCache(key) {
|
|
172
|
+
return this.config.authManager.getCache(key);
|
|
173
|
+
}
|
|
170
174
|
setCompanyId(companyId) {
|
|
171
175
|
this.companyId = companyId;
|
|
172
|
-
this.config.authManager.setCompanyId(companyId);
|
|
176
|
+
return this.config.authManager.setCompanyId(companyId);
|
|
173
177
|
}
|
|
174
178
|
clearCache() {
|
|
175
179
|
return this.config.authManager.clearCache();
|
|
@@ -217,7 +221,7 @@ export class AvroQueryClient {
|
|
|
217
221
|
})
|
|
218
222
|
.catch(err => {
|
|
219
223
|
console.error('Failed to fetch jobs:', err);
|
|
220
|
-
throw new StandardError(500,
|
|
224
|
+
throw new StandardError(500, `Failed to fetch jobs: ${err.message ?? err}`);
|
|
221
225
|
});
|
|
222
226
|
}
|
|
223
227
|
fetchChats(body = {}, cancelToken, headers = {}) {
|