@go-avro/avro-js 0.0.36 → 0.0.38

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.
Files changed (59) hide show
  1. package/dist/auth/AuthManager.d.ts +2 -2
  2. package/dist/auth/AuthManager.js +37 -32
  3. package/dist/auth/storage.d.ts +1 -1
  4. package/dist/auth/storage.js +6 -6
  5. package/dist/client/AvroQueryClientProvider.js +1 -1
  6. package/dist/client/QueryClient.d.ts +35 -17
  7. package/dist/client/QueryClient.js +486 -384
  8. package/dist/client/core/fetch.js +16 -11
  9. package/dist/client/core/utils.js +5 -5
  10. package/dist/client/core/xhr.js +28 -23
  11. package/dist/client/hooks/analytics.js +14 -14
  12. package/dist/client/hooks/avro.js +2 -2
  13. package/dist/client/hooks/bills.js +66 -30
  14. package/dist/client/hooks/catalog_items.js +57 -22
  15. package/dist/client/hooks/chats.js +4 -4
  16. package/dist/client/hooks/companies.js +96 -39
  17. package/dist/client/hooks/email.js +1 -1
  18. package/dist/client/hooks/events.js +174 -63
  19. package/dist/client/hooks/groups.js +37 -22
  20. package/dist/client/hooks/jobs.js +69 -18
  21. package/dist/client/hooks/labels.js +36 -21
  22. package/dist/client/hooks/messages.js +9 -6
  23. package/dist/client/hooks/months.js +42 -22
  24. package/dist/client/hooks/plans.js +2 -2
  25. package/dist/client/hooks/prepayments.js +42 -22
  26. package/dist/client/hooks/proposal.js +21 -5
  27. package/dist/client/hooks/root.js +4 -4
  28. package/dist/client/hooks/routes.js +77 -32
  29. package/dist/client/hooks/sessions.js +66 -34
  30. package/dist/client/hooks/skills.js +33 -18
  31. package/dist/client/hooks/teams.js +36 -21
  32. package/dist/client/hooks/timecards.js +6 -0
  33. package/dist/client/hooks/users.js +61 -29
  34. package/dist/client/hooks/waivers.js +41 -19
  35. package/dist/index.d.ts +38 -38
  36. package/dist/index.js +37 -37
  37. package/dist/types/api/Bill.d.ts +1 -1
  38. package/dist/types/api/Bill.js +1 -1
  39. package/dist/types/api/Job.d.ts +1 -1
  40. package/dist/types/api/Job.js +14 -14
  41. package/dist/types/api/LineItem.d.ts +3 -3
  42. package/dist/types/api/LineItem.js +5 -2
  43. package/dist/types/api/PaymentType.d.ts +1 -1
  44. package/dist/types/api/Prepayment.d.ts +1 -1
  45. package/dist/types/api/Route.d.ts +3 -3
  46. package/dist/types/api/Route.js +4 -2
  47. package/dist/types/api/RouteJob.d.ts +1 -1
  48. package/dist/types/api/Task.d.ts +2 -2
  49. package/dist/types/api/Task.js +12 -7
  50. package/dist/types/api/Timecard.d.ts +1 -1
  51. package/dist/types/api/TimecardAction.d.ts +1 -1
  52. package/dist/types/api/UserCompanyAssociation.d.ts +2 -2
  53. package/dist/types/api/UserCompanyAssociation.js +1 -1
  54. package/dist/types/api/_Event.d.ts +1 -1
  55. package/dist/types/api/_Event.js +1 -1
  56. package/dist/types/api.d.ts +1 -1
  57. package/dist/types/auth.d.ts +1 -1
  58. package/dist/types/client.d.ts +1 -1
  59. package/package.json +3 -2
@@ -3,10 +3,10 @@ import { RouteJob } from "../../types/api/RouteJob";
3
3
  export class Job {
4
4
  constructor(init) {
5
5
  this.isOverdue = () => {
6
- return this.tasks.some(t => t.isOverdue?.());
6
+ return this.tasks.some((t) => t.isOverdue?.());
7
7
  };
8
8
  this.getOverdueLabel = () => {
9
- const activeTasks = this.tasks.filter(t => t.status === TaskStatus.ACTIVE);
9
+ const activeTasks = this.tasks.filter((t) => t.status === TaskStatus.ACTIVE);
10
10
  if (activeTasks.length === 0) {
11
11
  return "N/A";
12
12
  }
@@ -14,7 +14,7 @@ export class Job {
14
14
  if (!t.overdueness || t.overdueness <= 0) {
15
15
  return mostOverdue;
16
16
  }
17
- if (!mostOverdue || (t.overdueness > (mostOverdue.overdueness ?? 0))) {
17
+ if (!mostOverdue || t.overdueness > (mostOverdue.overdueness ?? 0)) {
18
18
  return t;
19
19
  }
20
20
  return mostOverdue;
@@ -25,44 +25,44 @@ export class Job {
25
25
  if (!this.tasks || this.tasks.length === 0) {
26
26
  return 0;
27
27
  }
28
- const routeJob = this.routes.find(r => r.job_id === this.id);
28
+ const routeJob = this.routes.find((r) => r.job_id === this.id);
29
29
  if (!routeJob) {
30
30
  return 0;
31
31
  }
32
- const contextTasks = this.tasks.filter(t => !t.id || routeJob.tasks.includes(t.id));
32
+ const contextTasks = this.tasks.filter((t) => !t.id || routeJob.tasks.includes(t.id));
33
33
  if (contextTasks.length === 0) {
34
34
  return 0;
35
35
  }
36
- return contextTasks.filter(t => t.isDone?.(route)).length / contextTasks.length;
36
+ return (contextTasks.filter((t) => t.isDone?.(route)).length / contextTasks.length);
37
37
  };
38
38
  this.isDone = (route) => {
39
39
  return this.portionDone(route) === 1;
40
40
  };
41
41
  Object.assign(this, init);
42
42
  if (init?.tasks) {
43
- this.tasks = init.tasks.map(t => new Task(t));
43
+ this.tasks = init.tasks.map((t) => new Task(t));
44
44
  }
45
45
  if (init?.routes) {
46
- this.routes = init.routes.map(r => new RouteJob(r));
46
+ this.routes = init.routes.map((r) => new RouteJob(r));
47
47
  }
48
48
  }
49
49
  getStatus() {
50
- if (this.tasks.some(t => t.status === TaskStatus.ACTIVE)) {
50
+ if (this.tasks.some((t) => t.status === TaskStatus.ACTIVE)) {
51
51
  return TaskStatus.ACTIVE;
52
52
  }
53
- else if (this.tasks.every(t => t.status === TaskStatus.ARCHIVED)) {
53
+ else if (this.tasks.every((t) => t.status === TaskStatus.ARCHIVED)) {
54
54
  return TaskStatus.ARCHIVED;
55
55
  }
56
- else if (this.tasks.some(t => t.status === TaskStatus.PENDING_CUSTOMER)) {
56
+ else if (this.tasks.some((t) => t.status === TaskStatus.PENDING_CUSTOMER)) {
57
57
  return TaskStatus.PENDING_CUSTOMER;
58
58
  }
59
- else if (this.tasks.some(t => t.status === TaskStatus.PENDING_COMPANY)) {
59
+ else if (this.tasks.some((t) => t.status === TaskStatus.PENDING_COMPANY)) {
60
60
  return TaskStatus.PENDING_COMPANY;
61
61
  }
62
- else if (this.tasks.some(t => t.status === TaskStatus.PENDING_PAYMENT)) {
62
+ else if (this.tasks.some((t) => t.status === TaskStatus.PENDING_PAYMENT)) {
63
63
  return TaskStatus.PENDING_PAYMENT;
64
64
  }
65
- else if (this.tasks.some(t => t.status === TaskStatus.PENDING_ACTIVATION)) {
65
+ else if (this.tasks.some((t) => t.status === TaskStatus.PENDING_ACTIVATION)) {
66
66
  return TaskStatus.PENDING_ACTIVATION;
67
67
  }
68
68
  else {
@@ -7,7 +7,7 @@ export declare const LineItemStatus: {
7
7
  readonly PREPAID: "PREPAID";
8
8
  readonly PAID: "PAID";
9
9
  };
10
- export type LineItemStatus = typeof LineItemStatus[keyof typeof LineItemStatus];
10
+ export type LineItemStatus = (typeof LineItemStatus)[keyof typeof LineItemStatus];
11
11
  export declare const LineItemType: {
12
12
  readonly CUSTOM: "CUSTOM";
13
13
  readonly ADDITIONAL_CHARGE: "ADDITIONAL_CHARGE";
@@ -15,8 +15,8 @@ export declare const LineItemType: {
15
15
  readonly SERVICE_MONTH: "SERVICE_MONTH";
16
16
  readonly PREPAYMENT: "PREPAYMENT";
17
17
  };
18
- export type LineItemType = typeof LineItemType[keyof typeof LineItemType];
19
- declare module '../../types/api/LineItem' {
18
+ export type LineItemType = (typeof LineItemType)[keyof typeof LineItemType];
19
+ declare module "../../types/api/LineItem" {
20
20
  interface LineItem {
21
21
  id: string;
22
22
  line_item_type: LineItemType;
@@ -17,10 +17,13 @@ export const LineItemType = {
17
17
  export class LineItem {
18
18
  constructor(init) {
19
19
  this.isPaid = () => {
20
- return this.status === LineItemStatus.PAID || this.status === LineItemStatus.PREPAID || this.status === LineItemStatus.EXTERNALLY_PAID;
20
+ return (this.status === LineItemStatus.PAID ||
21
+ this.status === LineItemStatus.PREPAID ||
22
+ this.status === LineItemStatus.EXTERNALLY_PAID);
21
23
  };
22
24
  this.isBilled = () => {
23
- return this.status === LineItemStatus.BILLED || this.status === LineItemStatus.EXTERNALLY_BILLED;
25
+ return (this.status === LineItemStatus.BILLED ||
26
+ this.status === LineItemStatus.EXTERNALLY_BILLED);
24
27
  };
25
28
  this.isUnbilled = () => {
26
29
  return !this.isBilled() && !this.isPaid();
@@ -1,4 +1,4 @@
1
- export type PaymentType = typeof PaymentType[keyof typeof PaymentType];
1
+ export type PaymentType = (typeof PaymentType)[keyof typeof PaymentType];
2
2
  export declare const PaymentType: {
3
3
  readonly US_BANK_ACCOUNT: "us_bank_account";
4
4
  readonly CARD: "card";
@@ -1,5 +1,5 @@
1
1
  import { LineItem } from "../../types/api/LineItem";
2
- declare module '../../types/api/Prepayment' {
2
+ declare module "../../types/api/Prepayment" {
3
3
  interface Prepayment extends LineItem {
4
4
  id: string;
5
5
  task_id: string | null;
@@ -7,8 +7,8 @@ export declare const FrequencyType: {
7
7
  readonly MONTHLY: "MONTHLY";
8
8
  readonly YEARLY: "YEARLY";
9
9
  };
10
- export type FrequencyType = typeof FrequencyType[keyof typeof FrequencyType];
11
- declare module '../../types/api/Route' {
10
+ export type FrequencyType = (typeof FrequencyType)[keyof typeof FrequencyType];
11
+ declare module "../../types/api/Route" {
12
12
  interface Route {
13
13
  company: string;
14
14
  id: string;
@@ -26,7 +26,7 @@ declare module '../../types/api/Route' {
26
26
  start_longitude: number;
27
27
  end_latitude: number;
28
28
  end_longitude: number;
29
- frequency: typeof FrequencyType[keyof typeof FrequencyType];
29
+ frequency: (typeof FrequencyType)[keyof typeof FrequencyType];
30
30
  }
31
31
  }
32
32
  export declare class Route {
@@ -12,7 +12,9 @@ export class Route {
12
12
  this.getNextOccurrences = (count = 1) => {
13
13
  let next_occurrences = [];
14
14
  for (let i = 0; i < count; i++) {
15
- next_occurrences.push(this.getNextOccurrence(next_occurrences.length > 0 ? next_occurrences[next_occurrences.length - 1] ?? new Date() : new Date()));
15
+ next_occurrences.push(this.getNextOccurrence(next_occurrences.length > 0
16
+ ? (next_occurrences[next_occurrences.length - 1] ?? new Date())
17
+ : new Date()));
16
18
  }
17
19
  return next_occurrences;
18
20
  };
@@ -43,7 +45,7 @@ export class Route {
43
45
  };
44
46
  Object.assign(this, init);
45
47
  if (init?.jobs) {
46
- this.jobs = init.jobs.map(j => new RouteJob(j));
48
+ this.jobs = init.jobs.map((j) => new RouteJob(j));
47
49
  }
48
50
  }
49
51
  }
@@ -1,4 +1,4 @@
1
- declare module '../../types/api/RouteJob' {
1
+ declare module "../../types/api/RouteJob" {
2
2
  interface RouteJob {
3
3
  time_created: number;
4
4
  route_id: string;
@@ -12,8 +12,8 @@ export declare const TaskStatus: {
12
12
  readonly PENDING_PAYMENT: "PENDING_PAYMENT";
13
13
  readonly PENDING_ACTIVATION: "PENDING_ACTIVATION";
14
14
  };
15
- export type TaskStatus = typeof TaskStatus[keyof typeof TaskStatus];
16
- declare module '../../types/api/Task' {
15
+ export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
16
+ declare module "../../types/api/Task" {
17
17
  interface Task {
18
18
  enforce_proof_amount: boolean;
19
19
  events: _Event[];
@@ -6,7 +6,7 @@ export const TaskStatus = {
6
6
  ARCHIVED: "ARCHIVED",
7
7
  DRAFT: "DRAFT",
8
8
  PENDING_PAYMENT: "PENDING_PAYMENT",
9
- PENDING_ACTIVATION: "PENDING_ACTIVATION"
9
+ PENDING_ACTIVATION: "PENDING_ACTIVATION",
10
10
  };
11
11
  export class Task {
12
12
  constructor(init) {
@@ -31,7 +31,9 @@ export class Task {
31
31
  }
32
32
  };
33
33
  this.isOverdue = () => {
34
- return this.status === TaskStatus.ACTIVE && this.overdue_time !== undefined && this.overdue_time > 0;
34
+ return (this.status === TaskStatus.ACTIVE &&
35
+ this.overdue_time !== undefined &&
36
+ this.overdue_time > 0);
35
37
  };
36
38
  this.getOverdueLabel = () => {
37
39
  if (this.overdueness === null || this.status !== TaskStatus.ACTIVE) {
@@ -48,16 +50,19 @@ export class Task {
48
50
  }
49
51
  };
50
52
  this.getNextDue = () => {
51
- if (this.frequency > 0 && (this.status === TaskStatus.ACTIVE)) {
52
- const lastEventTime = this.last_completed_event?.time_ended ?? this.activate_on ?? this.time_created;
53
+ if (this.frequency > 0 && this.status === TaskStatus.ACTIVE) {
54
+ const lastEventTime = this.last_completed_event?.time_ended ??
55
+ this.activate_on ??
56
+ this.time_created;
53
57
  return lastEventTime + this.delay + this.frequency;
54
58
  }
55
59
  return null;
56
60
  };
57
61
  this.computeNextTaskState = (isCustomer, action) => {
58
62
  if (action === "accept") {
59
- if (this.status === TaskStatus.PENDING_CUSTOMER || this.status === TaskStatus.PENDING_COMPANY) {
60
- if (this.prepayments.filter(p => !p.isPaid()).length > 0) {
63
+ if (this.status === TaskStatus.PENDING_CUSTOMER ||
64
+ this.status === TaskStatus.PENDING_COMPANY) {
65
+ if (this.prepayments.filter((p) => !p.isPaid()).length > 0) {
61
66
  return TaskStatus.PENDING_PAYMENT;
62
67
  }
63
68
  if (this.activate_on && this.activate_on * 1000 > Date.now()) {
@@ -108,7 +113,7 @@ export class Task {
108
113
  };
109
114
  Object.assign(this, init);
110
115
  if (init?.prepayments) {
111
- this.prepayments = init.prepayments.map(p => new Prepayment(p));
116
+ this.prepayments = init.prepayments.map((p) => new Prepayment(p));
112
117
  }
113
118
  }
114
119
  }
@@ -5,7 +5,7 @@ export declare const TimecardStatus: {
5
5
  readonly APPROVED: "approved";
6
6
  readonly REJECTED: "rejected";
7
7
  };
8
- export type TimecardStatus = typeof TimecardStatus[keyof typeof TimecardStatus];
8
+ export type TimecardStatus = (typeof TimecardStatus)[keyof typeof TimecardStatus];
9
9
  export interface Timecard {
10
10
  id: string;
11
11
  user_company_id: string;
@@ -6,7 +6,7 @@ export declare const TimecardActionType: {
6
6
  readonly REJECTED: "rejected";
7
7
  readonly EDITED: "edited";
8
8
  };
9
- export type TimecardActionType = typeof TimecardActionType[keyof typeof TimecardActionType];
9
+ export type TimecardActionType = (typeof TimecardActionType)[keyof typeof TimecardActionType];
10
10
  export interface TimecardAction {
11
11
  id: string;
12
12
  action_type: TimecardActionType;
@@ -47,14 +47,14 @@ export declare const Permission: {
47
47
  readonly IS_ROOT: "is_root";
48
48
  readonly IS_CUSTOMER: "is_customer";
49
49
  };
50
- export type Permission = typeof Permission[keyof typeof Permission];
50
+ export type Permission = (typeof Permission)[keyof typeof Permission];
51
51
  export declare const NotificationLevel: {
52
52
  readonly IN_APP: 0;
53
53
  readonly EMAIL: 1;
54
54
  readonly SMS: 2;
55
55
  readonly PUSH: 3;
56
56
  };
57
- export type NotificationLevel = typeof NotificationLevel[keyof typeof NotificationLevel];
57
+ export type NotificationLevel = (typeof NotificationLevel)[keyof typeof NotificationLevel];
58
58
  export interface UserCompanyAssociation {
59
59
  id: string;
60
60
  user: User;
@@ -49,5 +49,5 @@ export const NotificationLevel = {
49
49
  IN_APP: 0,
50
50
  EMAIL: 1,
51
51
  SMS: 2,
52
- PUSH: 3
52
+ PUSH: 3,
53
53
  };
@@ -1,7 +1,7 @@
1
1
  import { LineItem } from "../../types/api/LineItem";
2
2
  import { AdditionalCharge } from "../../types/api/AdditionalCharge";
3
3
  import { UserEvent } from "../../types/api/UserEvent";
4
- declare module '../../types/api/_Event' {
4
+ declare module "../../types/api/_Event" {
5
5
  interface _Event extends LineItem {
6
6
  breaks: string[];
7
7
  line_item_type: "EVENT";
@@ -4,7 +4,7 @@ export class _Event extends LineItem {
4
4
  super(init);
5
5
  this.getCost = () => {
6
6
  const additionalChargesCost = this.additional_charges.reduce((acc, charge) => acc + (charge.cost ?? 0) * (charge.amount ?? 0), 0);
7
- return (this.cost * this.amount) + additionalChargesCost;
7
+ return this.cost * this.amount + additionalChargesCost;
8
8
  };
9
9
  Object.assign(this, init);
10
10
  this.breaks = init?.breaks ?? [];
@@ -43,7 +43,7 @@ export declare const LoginResponse: {
43
43
  readonly SUCCESS: "SUCCESS";
44
44
  readonly NEEDS_TOTP: "NEEDS_TOTP";
45
45
  };
46
- export type LoginResponse = typeof LoginResponse[keyof typeof LoginResponse];
46
+ export type LoginResponse = (typeof LoginResponse)[keyof typeof LoginResponse];
47
47
  export interface ApiInfo {
48
48
  app_semver: string;
49
49
  build_time: string;
@@ -7,4 +7,4 @@ export declare const AuthState: {
7
7
  readonly UNAUTHENTICATED: 2;
8
8
  readonly UNKNOWN: 3;
9
9
  };
10
- export type AuthState = typeof AuthState[keyof typeof AuthState];
10
+ export type AuthState = (typeof AuthState)[keyof typeof AuthState];
@@ -1,4 +1,4 @@
1
- export type RetryStrategy = 'fixed' | 'exponential' | ((attempt: number) => number);
1
+ export type RetryStrategy = "fixed" | "exponential" | ((attempt: number) => number);
2
2
  export interface CancelToken {
3
3
  isCancelled(): boolean;
4
4
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc && tsc-alias",
9
- "lint": "eslint src",
9
+ "lint": "eslint src && prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md,yaml,yml}\" && tsc --noEmit",
10
10
  "test": "jest",
11
11
  "prepublishOnly": "npm run lint && npm run build"
12
12
  },
@@ -40,6 +40,7 @@
40
40
  "eslint-plugin-import": "^2.32.0",
41
41
  "eslint-plugin-jsx-a11y": "^6.10.2",
42
42
  "eslint-plugin-react": "^7.37.5",
43
+ "prettier": "^3.8.3",
43
44
  "tsc-alias": "^1.8.16",
44
45
  "typescript": "^5.8.3",
45
46
  "typescript-eslint": "^8.38.0"