@go-avro/avro-js 0.0.4-beta.17 → 0.0.4-beta.19

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,7 @@ export declare class AuthManager {
17
17
  refreshTokens(): Promise<Tokens>;
18
18
  setTokens(tokens: Tokens): Promise<void>;
19
19
  setCache(data: Partial<CacheData> | Object): Promise<void>;
20
- getCache(key?: keyof CacheData | string): Promise<CacheData | string | null>;
20
+ getCache(key?: keyof CacheData | string): Promise<CacheData[keyof CacheData] | Object | string | null>;
21
21
  clearCache(): Promise<void>;
22
22
  getCompanyId(): Promise<string | undefined>;
23
23
  setCompanyId(companyId: string): Promise<void[]>;
@@ -488,8 +488,8 @@ export declare class AvroQueryClient {
488
488
  cancelToken?: CancelToken;
489
489
  }>>;
490
490
  setTokens(tokens: Tokens): Promise<void>;
491
- setCache(data: Partial<CacheData>): Promise<void>;
492
- getCache(key?: keyof CacheData | undefined): Promise<CacheData | string | null>;
491
+ setCache(data: Partial<CacheData> | Object): Promise<void>;
492
+ getCache(key?: keyof CacheData | string): Promise<CacheData[keyof CacheData] | Object | string | null>;
493
493
  setCompanyId(companyId: string): Promise<void[]>;
494
494
  getCompanyId(): Promise<string | undefined>;
495
495
  clearCache(): Promise<void>;
@@ -176,7 +176,7 @@ export class AvroQueryClient {
176
176
  setCache(data) {
177
177
  return this.config.authManager.setCache(data);
178
178
  }
179
- getCache(key) {
179
+ async getCache(key) {
180
180
  return this.config.authManager.getCache(key);
181
181
  }
182
182
  setCompanyId(companyId) {
@@ -51,4 +51,6 @@ declare module '../../types/api/Task' {
51
51
  export declare class Task {
52
52
  constructor(init?: Partial<Task>);
53
53
  computeNextTaskState: (isCustomer: boolean, action: "accept" | "modify" | "reject") => TaskStatus;
54
+ getPrepaidEventsRemaining: () => number;
55
+ getPrepaidMonthsRemaining: () => number;
54
56
  }
@@ -35,6 +35,22 @@ export class Task {
35
35
  }
36
36
  return this.status;
37
37
  };
38
+ this.getPrepaidEventsRemaining = () => {
39
+ return this.prepayments.reduce((acc, prepayment) => {
40
+ if (prepayment.isPaid()) {
41
+ return acc + prepayment.amount - prepayment.num_events;
42
+ }
43
+ return acc;
44
+ }, 0);
45
+ };
46
+ this.getPrepaidMonthsRemaining = () => {
47
+ return this.prepayments.reduce((acc, prepayment) => {
48
+ if (prepayment.isPaid()) {
49
+ return acc + prepayment.amount - prepayment.num_service_months;
50
+ }
51
+ return acc;
52
+ }, 0);
53
+ };
38
54
  Object.assign(this, init);
39
55
  if (init?.prepayments) {
40
56
  this.prepayments = init.prepayments.map(p => new Prepayment(p));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.4-beta.17",
3
+ "version": "0.0.4-beta.19",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",