@go-avro/avro-js 0.0.42 → 0.0.44

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 (83) hide show
  1. package/dist/auth/AuthManager.d.ts +3 -3
  2. package/dist/auth/AuthManager.js +24 -24
  3. package/dist/auth/storage.d.ts +1 -1
  4. package/dist/auth/storage.js +3 -3
  5. package/dist/client/AvroQueryClientProvider.d.ts +4 -4
  6. package/dist/client/AvroQueryClientProvider.js +3 -3
  7. package/dist/client/QueryClient.d.ts +15 -15
  8. package/dist/client/QueryClient.js +239 -259
  9. package/dist/client/core/fetch.js +9 -9
  10. package/dist/client/core/utils.js +4 -4
  11. package/dist/client/core/xhr.js +21 -21
  12. package/dist/client/hooks/analytics.js +12 -12
  13. package/dist/client/hooks/avro.js +4 -4
  14. package/dist/client/hooks/bills.js +36 -39
  15. package/dist/client/hooks/catalog_items.js +25 -31
  16. package/dist/client/hooks/chats.js +6 -6
  17. package/dist/client/hooks/companies.js +45 -57
  18. package/dist/client/hooks/email.d.ts +3 -3
  19. package/dist/client/hooks/email.js +5 -5
  20. package/dist/client/hooks/events.js +71 -81
  21. package/dist/client/hooks/groups.js +25 -31
  22. package/dist/client/hooks/jobs.js +29 -34
  23. package/dist/client/hooks/labels.js +25 -31
  24. package/dist/client/hooks/messages.js +7 -7
  25. package/dist/client/hooks/months.js +21 -21
  26. package/dist/client/hooks/plans.js +4 -4
  27. package/dist/client/hooks/prepayments.js +21 -21
  28. package/dist/client/hooks/proposal.js +11 -11
  29. package/dist/client/hooks/root.js +4 -4
  30. package/dist/client/hooks/routes.js +42 -53
  31. package/dist/client/hooks/sessions.js +33 -45
  32. package/dist/client/hooks/skills.js +22 -28
  33. package/dist/client/hooks/teams.js +26 -32
  34. package/dist/client/hooks/timecards.js +13 -13
  35. package/dist/client/hooks/users.js +39 -42
  36. package/dist/client/hooks/waivers.js +23 -23
  37. package/dist/index.d.ts +38 -38
  38. package/dist/index.js +37 -37
  39. package/dist/types/api/AdditionalCharge.d.ts +2 -2
  40. package/dist/types/api/Avro.d.ts +1 -1
  41. package/dist/types/api/Bill.d.ts +4 -4
  42. package/dist/types/api/Bill.js +4 -4
  43. package/dist/types/api/BillPayment.d.ts +2 -2
  44. package/dist/types/api/BillUser.d.ts +1 -1
  45. package/dist/types/api/CatalogItem.d.ts +1 -1
  46. package/dist/types/api/Chat.d.ts +2 -2
  47. package/dist/types/api/Company.d.ts +12 -12
  48. package/dist/types/api/CustomLineItem.d.ts +2 -2
  49. package/dist/types/api/Email.d.ts +2 -2
  50. package/dist/types/api/EmailNotification.d.ts +2 -2
  51. package/dist/types/api/Group.d.ts +1 -1
  52. package/dist/types/api/Job.d.ts +6 -6
  53. package/dist/types/api/Job.js +12 -12
  54. package/dist/types/api/LineItem.d.ts +1 -1
  55. package/dist/types/api/LineItem.js +12 -12
  56. package/dist/types/api/MemberState.d.ts +1 -1
  57. package/dist/types/api/Message.d.ts +1 -1
  58. package/dist/types/api/PaymentMethod.d.ts +1 -1
  59. package/dist/types/api/PaymentOption.d.ts +1 -1
  60. package/dist/types/api/PaymentType.js +2 -2
  61. package/dist/types/api/PlanPayment.d.ts +1 -1
  62. package/dist/types/api/Prepayment.d.ts +4 -4
  63. package/dist/types/api/Prepayment.js +1 -1
  64. package/dist/types/api/Route.d.ts +2 -2
  65. package/dist/types/api/Route.js +7 -7
  66. package/dist/types/api/RouteJob.d.ts +1 -1
  67. package/dist/types/api/ServiceMonth.d.ts +2 -2
  68. package/dist/types/api/Session.d.ts +2 -2
  69. package/dist/types/api/Task.d.ts +7 -7
  70. package/dist/types/api/Task.js +20 -22
  71. package/dist/types/api/Timecard.d.ts +1 -1
  72. package/dist/types/api/Timecard.js +4 -4
  73. package/dist/types/api/TimecardAction.js +6 -6
  74. package/dist/types/api/User.d.ts +4 -4
  75. package/dist/types/api/UserCompanyAssociation.d.ts +2 -2
  76. package/dist/types/api/UserCompanyAssociation.js +45 -45
  77. package/dist/types/api/_Event.d.ts +5 -5
  78. package/dist/types/api/_Event.js +1 -1
  79. package/dist/types/api.d.ts +44 -44
  80. package/dist/types/api.js +42 -42
  81. package/dist/types/cache.d.ts +1 -1
  82. package/dist/types/client.d.ts +1 -1
  83. package/package.json +2 -1
@@ -1,15 +1,11 @@
1
- import { useMutation, useQuery, useInfiniteQuery, } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
3
- import { Job } from "../../types/api";
1
+ import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { Job } from '../../types/api';
4
4
  AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
5
5
  if (!queryClient) {
6
6
  queryClient = this.getQueryClient();
7
7
  }
8
- return (queryClient.getQueryData([
9
- "jobs",
10
- this.companyId,
11
- this.company?.num_jobs,
12
- ]) ?? []);
8
+ return queryClient.getQueryData(['jobs', this.companyId, this.company?.num_jobs]) ?? [];
13
9
  };
14
10
  AvroQueryClient.prototype.useGetJobs = function (params) {
15
11
  const queryClient = this.getQueryClient();
@@ -17,7 +13,7 @@ AvroQueryClient.prototype.useGetJobs = function (params) {
17
13
  const company_id = params?.companyId ?? this.companyId;
18
14
  const num_jobs = params?.numJobs ?? this.company?.num_jobs ?? 0;
19
15
  return useQuery({
20
- queryKey: ["jobs", company_id, num_jobs],
16
+ queryKey: ['jobs', company_id, num_jobs],
21
17
  queryFn: async () => {
22
18
  params?.onProgress?.(0);
23
19
  const pageCount = amt ? Math.ceil((num_jobs ?? 0) / amt) + 1 : 1;
@@ -40,12 +36,11 @@ AvroQueryClient.prototype.useGetJobs = function (params) {
40
36
  }, job.current_event);
41
37
  job.last_completed_event = job.tasks.reduce((latest, task) => {
42
38
  return task.last_completed_event &&
43
- (!latest ||
44
- task.last_completed_event.time_started > latest.time_started)
39
+ (!latest || task.last_completed_event.time_started > latest.time_started)
45
40
  ? task.last_completed_event
46
41
  : latest;
47
42
  }, job.last_completed_event);
48
- queryClient.setQueryData(["jobs", job.id], job);
43
+ queryClient.setQueryData(['jobs', job.id], job);
49
44
  });
50
45
  return jobs;
51
46
  },
@@ -56,12 +51,12 @@ AvroQueryClient.prototype.useGetInfiniteJobs = function (body, onProgress) {
56
51
  const queryClient = this.getQueryClient();
57
52
  const result = useInfiniteQuery({
58
53
  queryKey: [
59
- "infinite",
60
- "jobs",
54
+ 'infinite',
55
+ 'jobs',
61
56
  this.companyId,
62
57
  body.amt ?? 50,
63
- body.query ?? "",
64
- body.routeId ?? "",
58
+ body.query ?? '',
59
+ body.routeId ?? '',
65
60
  ],
66
61
  initialPageParam: 0,
67
62
  getNextPageParam: (lastPage, allPages) => {
@@ -81,7 +76,7 @@ AvroQueryClient.prototype.useGetInfiniteJobs = function (body, onProgress) {
81
76
  if (result.data) {
82
77
  result.data.pages.forEach((data_page) => {
83
78
  data_page.forEach((job) => {
84
- queryClient.setQueryData(["jobs", job.id], job);
79
+ queryClient.setQueryData(['jobs', job.id], job);
85
80
  });
86
81
  });
87
82
  }
@@ -89,7 +84,7 @@ AvroQueryClient.prototype.useGetInfiniteJobs = function (body, onProgress) {
89
84
  };
90
85
  AvroQueryClient.prototype.useGetJob = function (jobId) {
91
86
  return useQuery({
92
- queryKey: ["jobs", jobId],
87
+ queryKey: ['jobs', jobId],
93
88
  queryFn: async () => {
94
89
  const job = await this.get({
95
90
  path: `/job/${jobId}`,
@@ -106,13 +101,13 @@ AvroQueryClient.prototype.useCreateJob = function () {
106
101
  return this.post({
107
102
  path: `/company/${this.companyId}/job`,
108
103
  data: JSON.stringify(jobData),
109
- headers: { "Content-Type": "application/json" },
104
+ headers: { 'Content-Type': 'application/json' },
110
105
  });
111
106
  },
112
107
  onSuccess: async (result) => {
113
108
  await this._syncEntity(queryClient, {
114
- action: "create",
115
- entityKey: "jobs",
109
+ action: 'create',
110
+ entityKey: 'jobs',
116
111
  id: result.id,
117
112
  fetchPath: `/job/${result.id}`,
118
113
  construct: (d) => new Job(d),
@@ -127,29 +122,29 @@ AvroQueryClient.prototype.useManageJobs = function () {
127
122
  return this.post({
128
123
  path: `/company/${this.companyId}/jobs/manage`,
129
124
  data: JSON.stringify({ jobs }),
130
- headers: { "Content-Type": "application/json" },
125
+ headers: { 'Content-Type': 'application/json' },
131
126
  });
132
127
  },
133
128
  onSuccess: () => {
134
- queryClient.invalidateQueries({ queryKey: ["jobs"] });
135
- queryClient.invalidateQueries({ queryKey: ["infinite", "jobs"] });
129
+ queryClient.invalidateQueries({ queryKey: ['jobs'] });
130
+ queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
136
131
  },
137
132
  });
138
133
  };
139
134
  AvroQueryClient.prototype.useUpdateJob = function () {
140
135
  const queryClient = this.getQueryClient();
141
136
  return useMutation({
142
- mutationFn: ({ jobId, updates, }) => {
137
+ mutationFn: ({ jobId, updates }) => {
143
138
  return this.put({
144
139
  path: `/job/${jobId}`,
145
140
  data: JSON.stringify(updates),
146
- headers: { "Content-Type": "application/json" },
141
+ headers: { 'Content-Type': 'application/json' },
147
142
  });
148
143
  },
149
144
  onSuccess: async (_result, { jobId }) => {
150
145
  await this._syncEntity(queryClient, {
151
- action: "update",
152
- entityKey: "jobs",
146
+ action: 'update',
147
+ entityKey: 'jobs',
153
148
  id: jobId,
154
149
  fetchPath: `/job/${jobId}`,
155
150
  construct: (d) => new Job(d),
@@ -164,12 +159,12 @@ AvroQueryClient.prototype.useDeleteJobs = function () {
164
159
  return this.post({
165
160
  path: `/company/${this.companyId}/jobs/delete`,
166
161
  data: JSON.stringify({ ids }),
167
- headers: { "Content-Type": "application/json" },
162
+ headers: { 'Content-Type': 'application/json' },
168
163
  });
169
164
  },
170
165
  onSuccess: () => {
171
- queryClient.invalidateQueries({ queryKey: ["jobs"] });
172
- queryClient.invalidateQueries({ queryKey: ["infinite", "jobs"] });
166
+ queryClient.invalidateQueries({ queryKey: ['jobs'] });
167
+ queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
173
168
  },
174
169
  });
175
170
  };
@@ -180,14 +175,14 @@ AvroQueryClient.prototype.useDeleteJob = function () {
180
175
  return this.delete({
181
176
  path: `/job/${jobId}`,
182
177
  headers: {
183
- "Content-Type": "application/json",
178
+ 'Content-Type': 'application/json',
184
179
  },
185
180
  });
186
181
  },
187
182
  onSuccess: async (_result, { jobId }) => {
188
183
  await this._syncEntity(queryClient, {
189
- action: "delete",
190
- entityKey: "jobs",
184
+ action: 'delete',
185
+ entityKey: 'jobs',
191
186
  id: jobId,
192
187
  });
193
188
  },
@@ -1,16 +1,10 @@
1
- import { useMutation, useQuery } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
1
+ import { useMutation, useQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
3
  AvroQueryClient.prototype.useGetLabels = function (body, total, onProgress) {
4
4
  return useQuery({
5
- queryKey: [
6
- "labels",
7
- this.companyId,
8
- body.amt ?? 50,
9
- body.query ?? "",
10
- total ?? "all",
11
- ],
5
+ queryKey: ['labels', this.companyId, body.amt ?? 50, body.query ?? '', total ?? 'all'],
12
6
  queryFn: async () => {
13
- if (typeof total !== "number") {
7
+ if (typeof total !== 'number') {
14
8
  return this.fetchLabels({ ...body, offset: 0 });
15
9
  }
16
10
  onProgress?.(0);
@@ -39,11 +33,11 @@ AvroQueryClient.prototype.useCreateLabel = function () {
39
33
  return this.post({
40
34
  path: `/company/${this.companyId}/label`,
41
35
  data: JSON.stringify(labelData),
42
- headers: { "Content-Type": "application/json" },
36
+ headers: { 'Content-Type': 'application/json' },
43
37
  });
44
38
  },
45
39
  onSuccess: () => {
46
- queryClient.invalidateQueries({ queryKey: ["labels"] });
40
+ queryClient.invalidateQueries({ queryKey: ['labels'] });
47
41
  },
48
42
  });
49
43
  };
@@ -54,20 +48,20 @@ AvroQueryClient.prototype.useUpdateLabel = function () {
54
48
  return this.put({
55
49
  path: `/label/${labelId}`,
56
50
  data: JSON.stringify(labelData),
57
- headers: { "Content-Type": "application/json" },
51
+ headers: { 'Content-Type': 'application/json' },
58
52
  });
59
53
  },
60
54
  onMutate: async ({ labelId, labelData }) => {
61
- await queryClient.cancelQueries({ queryKey: ["labels"] });
62
- await queryClient.cancelQueries({ queryKey: ["labels", labelId] });
63
- const previousLabels = queryClient.getQueryData(["labels"]);
64
- const previousLabel = queryClient.getQueryData(["labels", labelId]);
65
- queryClient.setQueryData(["labels", labelId], (oldData) => {
55
+ await queryClient.cancelQueries({ queryKey: ['labels'] });
56
+ await queryClient.cancelQueries({ queryKey: ['labels', labelId] });
57
+ const previousLabels = queryClient.getQueryData(['labels']);
58
+ const previousLabel = queryClient.getQueryData(['labels', labelId]);
59
+ queryClient.setQueryData(['labels', labelId], (oldData) => {
66
60
  if (!oldData)
67
61
  return oldData;
68
62
  return { ...oldData, ...labelData };
69
63
  });
70
- queryClient.setQueriesData({ queryKey: ["labels"] }, (oldData) => {
64
+ queryClient.setQueriesData({ queryKey: ['labels'] }, (oldData) => {
71
65
  if (!oldData)
72
66
  return oldData;
73
67
  if (oldData.pages) {
@@ -82,15 +76,15 @@ AvroQueryClient.prototype.useUpdateLabel = function () {
82
76
  return { previousLabels, previousLabel };
83
77
  },
84
78
  onSuccess: () => {
85
- queryClient.invalidateQueries({ queryKey: ["labels"] });
79
+ queryClient.invalidateQueries({ queryKey: ['labels'] });
86
80
  },
87
81
  onError: (_err, variables, context) => {
88
82
  const { labelId } = variables;
89
83
  if (context?.previousLabels) {
90
- queryClient.setQueryData(["labels"], context.previousLabels);
84
+ queryClient.setQueryData(['labels'], context.previousLabels);
91
85
  }
92
86
  if (context?.previousLabel) {
93
- queryClient.setQueryData(["labels", labelId], context.previousLabel);
87
+ queryClient.setQueryData(['labels', labelId], context.previousLabel);
94
88
  }
95
89
  },
96
90
  });
@@ -102,12 +96,12 @@ AvroQueryClient.prototype.useDeleteLabel = function () {
102
96
  return this.delete({ path: `/label/${labelId}` });
103
97
  },
104
98
  onMutate: async ({ labelId }) => {
105
- await queryClient.cancelQueries({ queryKey: ["labels"] });
106
- await queryClient.cancelQueries({ queryKey: ["labels", labelId] });
107
- const previousLabels = queryClient.getQueryData(["labels"]);
108
- const previousLabel = queryClient.getQueryData(["labels", labelId]);
109
- queryClient.setQueryData(["labels", labelId], undefined);
110
- queryClient.setQueriesData({ queryKey: ["labels"] }, (oldData) => {
99
+ await queryClient.cancelQueries({ queryKey: ['labels'] });
100
+ await queryClient.cancelQueries({ queryKey: ['labels', labelId] });
101
+ const previousLabels = queryClient.getQueryData(['labels']);
102
+ const previousLabel = queryClient.getQueryData(['labels', labelId]);
103
+ queryClient.setQueryData(['labels', labelId], undefined);
104
+ queryClient.setQueriesData({ queryKey: ['labels'] }, (oldData) => {
111
105
  if (!oldData)
112
106
  return oldData;
113
107
  if (oldData.pages) {
@@ -122,15 +116,15 @@ AvroQueryClient.prototype.useDeleteLabel = function () {
122
116
  return { previousLabels, previousLabel };
123
117
  },
124
118
  onSuccess: () => {
125
- queryClient.invalidateQueries({ queryKey: ["labels"] });
119
+ queryClient.invalidateQueries({ queryKey: ['labels'] });
126
120
  },
127
121
  onError: (_err, variables, context) => {
128
122
  const { labelId } = variables;
129
123
  if (context?.previousLabels) {
130
- queryClient.setQueryData(["labels"], context.previousLabels);
124
+ queryClient.setQueryData(['labels'], context.previousLabels);
131
125
  }
132
126
  if (context?.previousLabel) {
133
- queryClient.setQueryData(["labels", labelId], context.previousLabel);
127
+ queryClient.setQueryData(['labels', labelId], context.previousLabel);
134
128
  }
135
129
  },
136
130
  });
@@ -1,15 +1,15 @@
1
- import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
1
+ import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
3
  AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
4
4
  const queryClient = this.getQueryClient();
5
5
  const result = useInfiniteQuery({
6
6
  queryKey: [
7
- "messages",
7
+ 'messages',
8
8
  chatId,
9
9
  body.amt ?? 50,
10
10
  body.known_ids ?? [],
11
11
  body.unknown_ids ?? [],
12
- body.query ?? "",
12
+ body.query ?? '',
13
13
  ],
14
14
  initialPageParam: 0,
15
15
  getNextPageParam: (lastPage, allPages) => {
@@ -25,7 +25,7 @@ AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
25
25
  if (result.data) {
26
26
  result.data.pages.forEach((data_page) => {
27
27
  data_page.forEach((message) => {
28
- queryClient.setQueryData(["message", message.id], message);
28
+ queryClient.setQueryData(['message', message.id], message);
29
29
  });
30
30
  });
31
31
  }
@@ -44,12 +44,12 @@ AvroQueryClient.prototype.useCreateMessage = function (chatId) {
44
44
  id,
45
45
  },
46
46
  }),
47
- headers: { "Content-Type": "application/json" },
47
+ headers: { 'Content-Type': 'application/json' },
48
48
  });
49
49
  return message;
50
50
  },
51
51
  onSuccess: (message) => {
52
- queryClient.setQueryData(["message", message.id], message);
52
+ queryClient.setQueryData(['message', message.id], message);
53
53
  },
54
54
  });
55
55
  };
@@ -1,20 +1,20 @@
1
- import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
3
- import { LineItemStatus } from "../../types/api";
1
+ import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { LineItemStatus } from '../../types/api';
4
4
  AvroQueryClient.prototype.useGetMonths = function (body) {
5
5
  const queryClient = this.getQueryClient();
6
6
  const result = useInfiniteQuery({
7
7
  queryKey: [
8
- "months",
8
+ 'months',
9
9
  this.companyId,
10
10
  body.amt ?? 50,
11
11
  body.known_ids ?? [],
12
12
  body.unknown_ids ?? [],
13
- body.query ?? "",
13
+ body.query ?? '',
14
14
  body.unbilled ?? true,
15
15
  body.billed ?? true,
16
16
  body.paid ?? true,
17
- body.jobId ?? "",
17
+ body.jobId ?? '',
18
18
  body.enabled ?? true,
19
19
  ],
20
20
  initialPageParam: 0,
@@ -29,7 +29,7 @@ AvroQueryClient.prototype.useGetMonths = function (body) {
29
29
  if (result.data) {
30
30
  result.data.pages.forEach((data_page) => {
31
31
  data_page.forEach((month) => {
32
- queryClient.setQueryData(["month", month.id], month);
32
+ queryClient.setQueryData(['month', month.id], month);
33
33
  });
34
34
  });
35
35
  }
@@ -44,41 +44,41 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
44
44
  path: `/company/${this.companyId}/months`,
45
45
  data: JSON.stringify({
46
46
  months: monthIds,
47
- status: action === "billed"
47
+ status: action === 'billed'
48
48
  ? LineItemStatus.EXTERNALLY_BILLED
49
49
  : LineItemStatus.EXTERNALLY_PAID,
50
50
  }),
51
51
  headers: {
52
- "Content-Type": "application/json",
52
+ 'Content-Type': 'application/json',
53
53
  },
54
54
  });
55
55
  },
56
56
  onMutate: async ({ months, action }) => {
57
- await queryClient.cancelQueries({ queryKey: ["months"] });
58
- await queryClient.cancelQueries({ queryKey: ["months"] });
59
- const previousMonths = queryClient.getQueryData(["months"]);
60
- const previousMonthObjs = months.map((month) => queryClient.getQueryData(["month", month.id]));
57
+ await queryClient.cancelQueries({ queryKey: ['months'] });
58
+ await queryClient.cancelQueries({ queryKey: ['months'] });
59
+ const previousMonths = queryClient.getQueryData(['months']);
60
+ const previousMonthObjs = months.map((month) => queryClient.getQueryData(['month', month.id]));
61
61
  const monthIds = months.map((month) => month.id);
62
62
  monthIds.forEach((monthId, idx) => {
63
- queryClient.setQueryData(["month", monthId], (oldData) => {
63
+ queryClient.setQueryData(['month', monthId], (oldData) => {
64
64
  return oldData
65
65
  ? {
66
66
  ...oldData,
67
- status: action === "billed"
67
+ status: action === 'billed'
68
68
  ? LineItemStatus.EXTERNALLY_BILLED
69
69
  : LineItemStatus.EXTERNALLY_PAID,
70
70
  }
71
71
  : oldData;
72
72
  });
73
73
  });
74
- queryClient.setQueriesData({ queryKey: ["months"] }, (oldData) => {
74
+ queryClient.setQueriesData({ queryKey: ['months'] }, (oldData) => {
75
75
  if (!oldData)
76
76
  return oldData;
77
77
  if (oldData.pages) {
78
78
  const updatedPages = oldData.pages.map((page) => page.map((month) => monthIds.includes(month.id)
79
79
  ? {
80
80
  ...month,
81
- status: action === "billed"
81
+ status: action === 'billed'
82
82
  ? LineItemStatus.EXTERNALLY_BILLED
83
83
  : LineItemStatus.EXTERNALLY_PAID,
84
84
  }
@@ -89,7 +89,7 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
89
89
  return oldData.map((month) => monthIds.includes(month.id)
90
90
  ? {
91
91
  ...month,
92
- status: action === "billed"
92
+ status: action === 'billed'
93
93
  ? LineItemStatus.EXTERNALLY_BILLED
94
94
  : LineItemStatus.EXTERNALLY_PAID,
95
95
  }
@@ -100,13 +100,13 @@ AvroQueryClient.prototype.useUpdateMonths = function () {
100
100
  return { previousMonths, previousMonthObjs };
101
101
  },
102
102
  onSuccess: () => {
103
- queryClient.invalidateQueries({ queryKey: ["months"] });
103
+ queryClient.invalidateQueries({ queryKey: ['months'] });
104
104
  },
105
105
  onError: (err, variables, context) => {
106
106
  if (context) {
107
- queryClient.setQueryData(["months"], context.previousMonths);
107
+ queryClient.setQueryData(['months'], context.previousMonths);
108
108
  context.previousMonthObjs.forEach((monthObj) => {
109
- queryClient.setQueryData(["month", monthObj.id], monthObj);
109
+ queryClient.setQueryData(['month', monthObj.id], monthObj);
110
110
  });
111
111
  }
112
112
  },
@@ -1,8 +1,8 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
3
  AvroQueryClient.prototype.useGetPlans = function (code) {
4
4
  return useQuery({
5
- queryKey: ["plans", code],
6
- queryFn: async () => this.get({ path: `/plans${code ? `?code=${code}` : ""}` }),
5
+ queryKey: ['plans', code],
6
+ queryFn: async () => this.get({ path: `/plans${code ? `?code=${code}` : ''}` }),
7
7
  });
8
8
  };
@@ -1,20 +1,20 @@
1
- import { useInfiniteQuery, useMutation } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
3
- import { LineItemStatus } from "../../types/api";
1
+ import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { LineItemStatus } from '../../types/api';
4
4
  AvroQueryClient.prototype.useGetPrepayments = function (body) {
5
5
  const queryClient = this.getQueryClient();
6
6
  const result = useInfiniteQuery({
7
7
  queryKey: [
8
- "prepayments",
8
+ 'prepayments',
9
9
  this.companyId,
10
10
  body.amt ?? 50,
11
11
  body.known_ids ?? [],
12
12
  body.unknown_ids ?? [],
13
- body.query ?? "",
13
+ body.query ?? '',
14
14
  body.unbilled ?? true,
15
15
  body.billed ?? true,
16
16
  body.paid ?? true,
17
- body.taskId ?? "",
17
+ body.taskId ?? '',
18
18
  body.enabled ?? true,
19
19
  ],
20
20
  initialPageParam: 0,
@@ -29,7 +29,7 @@ AvroQueryClient.prototype.useGetPrepayments = function (body) {
29
29
  if (result.data) {
30
30
  result.data.pages.forEach((data_page) => {
31
31
  data_page.forEach((prepayment) => {
32
- queryClient.setQueryData(["prepayment", prepayment.id], prepayment);
32
+ queryClient.setQueryData(['prepayment', prepayment.id], prepayment);
33
33
  });
34
34
  });
35
35
  }
@@ -44,41 +44,41 @@ AvroQueryClient.prototype.useUpdatePrepayments = function () {
44
44
  path: `/company/${this.companyId}/prepayments`,
45
45
  data: JSON.stringify({
46
46
  prepayments: prepaymentIds,
47
- status: action === "billed"
47
+ status: action === 'billed'
48
48
  ? LineItemStatus.EXTERNALLY_BILLED
49
49
  : LineItemStatus.EXTERNALLY_PAID,
50
50
  }),
51
51
  headers: {
52
- "Content-Type": "application/json",
52
+ 'Content-Type': 'application/json',
53
53
  },
54
54
  });
55
55
  },
56
56
  onMutate: async ({ prepayments, action }) => {
57
- await queryClient.cancelQueries({ queryKey: ["prepayments"] });
58
- await queryClient.cancelQueries({ queryKey: ["prepayments"] });
59
- const previousPrepayments = queryClient.getQueryData(["prepayments"]);
60
- const previousPrepaymentObjs = prepayments.map((prepayment) => queryClient.getQueryData(["prepayment", prepayment.id]));
57
+ await queryClient.cancelQueries({ queryKey: ['prepayments'] });
58
+ await queryClient.cancelQueries({ queryKey: ['prepayments'] });
59
+ const previousPrepayments = queryClient.getQueryData(['prepayments']);
60
+ const previousPrepaymentObjs = prepayments.map((prepayment) => queryClient.getQueryData(['prepayment', prepayment.id]));
61
61
  const prepaymentIds = prepayments.map((prepayment) => prepayment.id);
62
62
  prepaymentIds.forEach((prepaymentId, idx) => {
63
- queryClient.setQueryData(["prepayment", prepaymentId], (oldData) => {
63
+ queryClient.setQueryData(['prepayment', prepaymentId], (oldData) => {
64
64
  return oldData
65
65
  ? {
66
66
  ...oldData,
67
- status: action === "billed"
67
+ status: action === 'billed'
68
68
  ? LineItemStatus.EXTERNALLY_BILLED
69
69
  : LineItemStatus.EXTERNALLY_PAID,
70
70
  }
71
71
  : oldData;
72
72
  });
73
73
  });
74
- queryClient.setQueriesData({ queryKey: ["prepayments"] }, (oldData) => {
74
+ queryClient.setQueriesData({ queryKey: ['prepayments'] }, (oldData) => {
75
75
  if (!oldData)
76
76
  return oldData;
77
77
  if (oldData.pages) {
78
78
  const updatedPages = oldData.pages.map((page) => page.map((prepayment) => prepaymentIds.includes(prepayment.id)
79
79
  ? {
80
80
  ...prepayment,
81
- status: action === "billed"
81
+ status: action === 'billed'
82
82
  ? LineItemStatus.EXTERNALLY_BILLED
83
83
  : LineItemStatus.EXTERNALLY_PAID,
84
84
  }
@@ -89,7 +89,7 @@ AvroQueryClient.prototype.useUpdatePrepayments = function () {
89
89
  return oldData.map((prepayment) => prepaymentIds.includes(prepayment.id)
90
90
  ? {
91
91
  ...prepayment,
92
- status: action === "billed"
92
+ status: action === 'billed'
93
93
  ? LineItemStatus.EXTERNALLY_BILLED
94
94
  : LineItemStatus.EXTERNALLY_PAID,
95
95
  }
@@ -100,13 +100,13 @@ AvroQueryClient.prototype.useUpdatePrepayments = function () {
100
100
  return { previousPrepayments, previousPrepaymentObjs };
101
101
  },
102
102
  onSuccess: () => {
103
- queryClient.invalidateQueries({ queryKey: ["prepayments"] });
103
+ queryClient.invalidateQueries({ queryKey: ['prepayments'] });
104
104
  },
105
105
  onError: (err, variables, context) => {
106
106
  if (context) {
107
- queryClient.setQueryData(["prepayments"], context.previousPrepayments);
107
+ queryClient.setQueryData(['prepayments'], context.previousPrepayments);
108
108
  context.previousPrepaymentObjs.forEach((prepaymentObj) => {
109
- queryClient.setQueryData(["prepayment", prepaymentObj.id], prepaymentObj);
109
+ queryClient.setQueryData(['prepayment', prepaymentObj.id], prepaymentObj);
110
110
  });
111
111
  }
112
112
  },
@@ -1,20 +1,20 @@
1
- import { useMutation, useQuery } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
3
- import { Task } from "../../types/api/Task";
1
+ import { useMutation, useQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { Task } from '../../types/api/Task';
4
4
  AvroQueryClient.prototype.useCreateProposal = function () {
5
5
  const queryClient = this.getQueryClient();
6
6
  return useMutation({
7
- mutationFn: async ({ job_id, data, }) => {
7
+ mutationFn: async ({ job_id, data }) => {
8
8
  return this.post({
9
9
  path: `/job/${job_id}/proposal`,
10
10
  data: JSON.stringify(data),
11
- headers: { "Content-Type": "application/json" },
11
+ headers: { 'Content-Type': 'application/json' },
12
12
  });
13
13
  },
14
14
  onSuccess: async (result) => {
15
15
  await this._syncEntity(queryClient, {
16
- action: "create",
17
- entityKey: "proposals",
16
+ action: 'create',
17
+ entityKey: 'proposals',
18
18
  id: result.id,
19
19
  fetchPath: `/proposal/${result.id}`,
20
20
  });
@@ -28,18 +28,18 @@ AvroQueryClient.prototype.useReviewProposal = function (proposal_id) {
28
28
  return this.post({
29
29
  path: `/proposal/${proposal_id}/review`,
30
30
  data: JSON.stringify(data),
31
- headers: { "Content-Type": "application/json" },
31
+ headers: { 'Content-Type': 'application/json' },
32
32
  });
33
33
  },
34
34
  onSuccess: () => {
35
- queryClient.invalidateQueries({ queryKey: ["proposals"] });
36
- queryClient.invalidateQueries({ queryKey: ["jobs"] });
35
+ queryClient.invalidateQueries({ queryKey: ['proposals'] });
36
+ queryClient.invalidateQueries({ queryKey: ['jobs'] });
37
37
  },
38
38
  });
39
39
  };
40
40
  AvroQueryClient.prototype.useGetProposal = function (proposal_id) {
41
41
  return useQuery({
42
- queryKey: ["proposals", proposal_id],
42
+ queryKey: ['proposals', proposal_id],
43
43
  queryFn: async () => {
44
44
  const proposal = await this.get({
45
45
  path: `/proposal/${proposal_id}`,
@@ -1,8 +1,8 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { AvroQueryClient } from "../../client/QueryClient";
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
3
  AvroQueryClient.prototype.useGetRoot = function () {
4
4
  return useQuery({
5
- queryKey: ["health"],
6
- queryFn: () => this.get({ path: "/" }),
5
+ queryKey: ['health'],
6
+ queryFn: () => this.get({ path: '/' }),
7
7
  });
8
8
  };