@go-avro/avro-js 0.0.2-beta.14 → 0.0.2-beta.140
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.
- package/README.md +1 -0
- package/dist/auth/AuthManager.d.ts +12 -3
- package/dist/auth/AuthManager.js +56 -12
- package/dist/auth/storage.d.ts +8 -8
- package/dist/auth/storage.js +19 -14
- package/dist/client/AvroQueryClientProvider.d.ts +14 -0
- package/dist/client/AvroQueryClientProvider.js +32 -0
- package/dist/client/QueryClient.d.ts +447 -15
- package/dist/client/QueryClient.js +405 -201
- package/dist/client/core/fetch.d.ts +1 -0
- package/dist/client/core/fetch.js +62 -0
- package/dist/client/core/utils.d.ts +1 -0
- package/dist/client/core/utils.js +14 -0
- package/dist/client/core/xhr.d.ts +1 -0
- package/dist/client/core/xhr.js +84 -0
- package/dist/client/hooks/analytics.d.ts +1 -0
- package/dist/client/hooks/analytics.js +26 -0
- package/dist/client/hooks/avro.d.ts +1 -0
- package/dist/client/hooks/avro.js +9 -0
- package/dist/client/hooks/bills.d.ts +1 -0
- package/dist/client/hooks/bills.js +165 -0
- package/dist/client/hooks/chats.d.ts +1 -0
- package/dist/client/hooks/chats.js +37 -0
- package/dist/client/hooks/companies.d.ts +1 -0
- package/dist/client/hooks/companies.js +140 -0
- package/dist/client/hooks/events.d.ts +1 -0
- package/dist/client/hooks/events.js +308 -0
- package/dist/client/hooks/groups.d.ts +1 -0
- package/dist/client/hooks/groups.js +130 -0
- package/dist/client/hooks/jobs.d.ts +1 -0
- package/dist/client/hooks/jobs.js +213 -0
- package/dist/client/hooks/messages.d.ts +1 -0
- package/dist/client/hooks/messages.js +30 -0
- package/dist/client/hooks/months.d.ts +1 -0
- package/dist/client/hooks/months.js +93 -0
- package/dist/client/hooks/plans.d.ts +1 -0
- package/dist/client/hooks/plans.js +8 -0
- package/dist/client/hooks/root.d.ts +1 -0
- package/dist/client/hooks/root.js +8 -0
- package/dist/client/hooks/routes.d.ts +1 -0
- package/dist/client/hooks/routes.js +167 -0
- package/dist/client/hooks/sessions.d.ts +1 -0
- package/dist/client/hooks/sessions.js +175 -0
- package/dist/client/hooks/skills.d.ts +1 -0
- package/dist/client/hooks/skills.js +123 -0
- package/dist/client/hooks/teams.d.ts +1 -0
- package/dist/client/hooks/teams.js +128 -0
- package/dist/client/hooks/users.d.ts +1 -0
- package/dist/client/hooks/users.js +104 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.js +24 -1
- package/dist/types/api.d.ts +138 -34
- package/dist/types/api.js +10 -1
- package/dist/types/auth.d.ts +0 -5
- package/dist/types/cache.d.ts +9 -0
- package/dist/types/cache.js +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
|
+
AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['teams', this.companyId, body.amt ?? 50, body.query ?? "", total ?? "all"],
|
|
6
|
+
queryFn: async () => {
|
|
7
|
+
if (typeof total !== "number") {
|
|
8
|
+
return this.fetchTeams({ ...body, offset: 0 });
|
|
9
|
+
}
|
|
10
|
+
onProgress?.(0);
|
|
11
|
+
const pageCount = body.amt ? Math.ceil(total / body.amt) + 1 : 1;
|
|
12
|
+
let completed = 0;
|
|
13
|
+
const promises = Array.from({ length: pageCount }, (_, i) => this.fetchTeams({
|
|
14
|
+
...body,
|
|
15
|
+
offset: i * (body.amt ?? 1),
|
|
16
|
+
}));
|
|
17
|
+
const trackedPromises = promises.map((promise) => promise.then((result) => {
|
|
18
|
+
completed++;
|
|
19
|
+
const fraction = completed / pageCount;
|
|
20
|
+
onProgress?.(fraction);
|
|
21
|
+
return result;
|
|
22
|
+
}));
|
|
23
|
+
const pages = await Promise.all(trackedPromises);
|
|
24
|
+
const teams = pages.flat();
|
|
25
|
+
return teams;
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
AvroQueryClient.prototype.useCreateTeam = function () {
|
|
30
|
+
const queryClient = this.getQueryClient();
|
|
31
|
+
return useMutation({
|
|
32
|
+
mutationFn: async ({ teamData }) => {
|
|
33
|
+
return this.post(`/company/${this.companyId}/team`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
|
|
34
|
+
},
|
|
35
|
+
onSettled: () => {
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: ['company'] });
|
|
37
|
+
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
AvroQueryClient.prototype.useUpdateTeam = function () {
|
|
42
|
+
const queryClient = this.getQueryClient();
|
|
43
|
+
return useMutation({
|
|
44
|
+
mutationFn: async ({ teamId, teamData }) => {
|
|
45
|
+
return this.put(`/team/${teamId}`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
|
|
46
|
+
},
|
|
47
|
+
onMutate: async ({ teamId, teamData }) => {
|
|
48
|
+
await queryClient.cancelQueries({ queryKey: ['teams'] });
|
|
49
|
+
await queryClient.cancelQueries({ queryKey: ['team', teamId] });
|
|
50
|
+
const previousTeams = queryClient.getQueryData(['teams']);
|
|
51
|
+
const previousTeam = queryClient.getQueryData(['team', teamId]);
|
|
52
|
+
queryClient.setQueryData(['team', teamId], (oldData) => {
|
|
53
|
+
if (!oldData)
|
|
54
|
+
return oldData;
|
|
55
|
+
return { ...oldData, ...teamData };
|
|
56
|
+
});
|
|
57
|
+
queryClient.setQueriesData({ queryKey: ['teams'] }, (oldData) => {
|
|
58
|
+
if (!oldData)
|
|
59
|
+
return oldData;
|
|
60
|
+
if (oldData.pages) {
|
|
61
|
+
const updatedPages = oldData.pages.map((page) => page.map((team) => team.id === teamId ? { ...team, ...teamData } : team));
|
|
62
|
+
return { ...oldData, pages: updatedPages };
|
|
63
|
+
}
|
|
64
|
+
if (Array.isArray(oldData)) {
|
|
65
|
+
return oldData.map((team) => team.id === teamId ? { ...team, ...teamData } : team);
|
|
66
|
+
}
|
|
67
|
+
return oldData;
|
|
68
|
+
});
|
|
69
|
+
return { previousTeams, previousTeam };
|
|
70
|
+
},
|
|
71
|
+
onError: (_err, variables, context) => {
|
|
72
|
+
const { teamId } = variables;
|
|
73
|
+
if (context?.previousTeams) {
|
|
74
|
+
queryClient.setQueryData(['teams'], context.previousTeams);
|
|
75
|
+
}
|
|
76
|
+
if (context?.previousTeam) {
|
|
77
|
+
queryClient.setQueryData(['team', teamId], context.previousTeam);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
onSettled: (_data, _error, variables) => {
|
|
81
|
+
const { teamId } = variables;
|
|
82
|
+
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
83
|
+
queryClient.invalidateQueries({ queryKey: ['team', teamId] });
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
AvroQueryClient.prototype.useDeleteTeam = function () {
|
|
88
|
+
const queryClient = this.getQueryClient();
|
|
89
|
+
return useMutation({
|
|
90
|
+
mutationFn: async ({ teamId, }) => {
|
|
91
|
+
return this.delete(`/team/${teamId}`);
|
|
92
|
+
},
|
|
93
|
+
onMutate: async ({ teamId }) => {
|
|
94
|
+
await queryClient.cancelQueries({ queryKey: ['teams'] });
|
|
95
|
+
await queryClient.cancelQueries({ queryKey: ['team', teamId] });
|
|
96
|
+
const previousRoutes = queryClient.getQueryData(['teams']);
|
|
97
|
+
const previousRoute = queryClient.getQueryData(['team', teamId]);
|
|
98
|
+
queryClient.setQueryData(['team', teamId], undefined);
|
|
99
|
+
queryClient.setQueriesData({ queryKey: ['teams'] }, (oldData) => {
|
|
100
|
+
if (!oldData)
|
|
101
|
+
return oldData;
|
|
102
|
+
if (oldData.pages) {
|
|
103
|
+
const updatedPages = oldData.pages.map((page) => page.filter((team) => team.id !== teamId));
|
|
104
|
+
return { ...oldData, pages: updatedPages };
|
|
105
|
+
}
|
|
106
|
+
if (Array.isArray(oldData)) {
|
|
107
|
+
return oldData.filter((team) => team.id !== teamId);
|
|
108
|
+
}
|
|
109
|
+
return oldData;
|
|
110
|
+
});
|
|
111
|
+
return { previousRoutes, previousRoute };
|
|
112
|
+
},
|
|
113
|
+
onError: (_err, variables, context) => {
|
|
114
|
+
const { teamId } = variables;
|
|
115
|
+
if (context?.previousRoutes) {
|
|
116
|
+
queryClient.setQueryData(['teams'], context.previousRoutes);
|
|
117
|
+
}
|
|
118
|
+
if (context?.previousRoute) {
|
|
119
|
+
queryClient.setQueryData(['team', teamId], context.previousRoute);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
onSettled: (_data, _error, variables) => {
|
|
123
|
+
const { teamId } = variables;
|
|
124
|
+
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
125
|
+
queryClient.invalidateQueries({ queryKey: ['team', teamId] });
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
|
+
AvroQueryClient.prototype.useGetUser = function (userId) {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['user', userId],
|
|
6
|
+
queryFn: () => this.get(`/user/${userId}`),
|
|
7
|
+
enabled: Boolean(userId),
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['user', 'search', searchUsername],
|
|
13
|
+
queryFn: () => {
|
|
14
|
+
if (!searchUsername)
|
|
15
|
+
return Promise.resolve([]);
|
|
16
|
+
return this.get(`/user/search/${searchUsername}`);
|
|
17
|
+
},
|
|
18
|
+
enabled: Boolean(searchUsername),
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
AvroQueryClient.prototype.useGetSelf = function () {
|
|
22
|
+
return useQuery({
|
|
23
|
+
queryKey: ['user'],
|
|
24
|
+
queryFn: () => this.get(`/user`),
|
|
25
|
+
enabled: Boolean(this),
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
AvroQueryClient.prototype.useCreateSelf = function () {
|
|
29
|
+
const queryClient = this.getQueryClient();
|
|
30
|
+
return useMutation({
|
|
31
|
+
mutationFn: async (data) => {
|
|
32
|
+
return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
33
|
+
},
|
|
34
|
+
onSettled: () => {
|
|
35
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
AvroQueryClient.prototype.useUpdateUserCompany = function () {
|
|
40
|
+
const queryClient = this.getQueryClient();
|
|
41
|
+
return useMutation({
|
|
42
|
+
mutationFn: async ({ user_id, data }) => {
|
|
43
|
+
return this.put(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
44
|
+
},
|
|
45
|
+
// Optimistically update the user data and company data in the cache
|
|
46
|
+
onMutate: async (data) => {
|
|
47
|
+
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
48
|
+
await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
|
|
49
|
+
const previousUser = queryClient.getQueryData(['user']);
|
|
50
|
+
const previousCompany = queryClient.getQueryData(['company', this.companyId]);
|
|
51
|
+
if (previousUser) {
|
|
52
|
+
let oldUserCompany = previousUser.companies?.find(c => c.company === this.companyId);
|
|
53
|
+
if (oldUserCompany) {
|
|
54
|
+
oldUserCompany = { ...oldUserCompany, ...data.data };
|
|
55
|
+
const newCompanies = previousUser.companies?.map(c => c.company === this.companyId ? oldUserCompany : c) ?? [];
|
|
56
|
+
queryClient.setQueryData(['user'], { ...previousUser, companies: newCompanies });
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (previousCompany) {
|
|
60
|
+
let oldCompanyUser = previousCompany.users?.find((u) => u.user.id === data.user_id);
|
|
61
|
+
if (oldCompanyUser) {
|
|
62
|
+
oldCompanyUser = { ...oldCompanyUser, ...data.data };
|
|
63
|
+
const newUsers = previousCompany.users?.map((u) => u.user.id === data.user_id ? oldCompanyUser : u) ?? [];
|
|
64
|
+
queryClient.setQueryData(['company', this.companyId], { ...previousCompany, users: newUsers });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { previousUser, previousCompany };
|
|
68
|
+
},
|
|
69
|
+
onError: (err, _, context) => {
|
|
70
|
+
if (context?.previousUser) {
|
|
71
|
+
queryClient.setQueryData(['user'], context.previousUser);
|
|
72
|
+
}
|
|
73
|
+
if (context?.previousCompany) {
|
|
74
|
+
queryClient.setQueryData(['company'], context.previousCompany);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
onSettled: (data, error, variables) => {
|
|
78
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
79
|
+
queryClient.invalidateQueries({ queryKey: ['company', this.companyId] });
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
AvroQueryClient.prototype.useDeleteSelf = function () {
|
|
84
|
+
const queryClient = this.getQueryClient();
|
|
85
|
+
return useMutation({
|
|
86
|
+
mutationFn: async () => {
|
|
87
|
+
return this.delete(`/user`);
|
|
88
|
+
},
|
|
89
|
+
onMutate: async () => {
|
|
90
|
+
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
91
|
+
const previousUser = queryClient.getQueryData(['user']);
|
|
92
|
+
queryClient.removeQueries({ queryKey: ['user'] });
|
|
93
|
+
return { previousUser };
|
|
94
|
+
},
|
|
95
|
+
onError: (err, _, context) => {
|
|
96
|
+
if (context?.previousUser) {
|
|
97
|
+
queryClient.setQueryData(['user'], context.previousUser);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
onSettled: () => {
|
|
101
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
export { AvroQueryClientConfig, AvroQueryClient } from './client/QueryClient';
|
|
2
|
+
export { AvroQueryClientProvider, useAvroQueryClient } from './client/AvroQueryClientProvider';
|
|
2
3
|
export { AuthManager } from './auth/AuthManager';
|
|
3
4
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
5
|
+
import './client/core/xhr';
|
|
6
|
+
import './client/core/fetch';
|
|
7
|
+
import './client/core/utils';
|
|
8
|
+
import './client/hooks/root';
|
|
9
|
+
import './client/hooks/jobs';
|
|
10
|
+
import './client/hooks/routes';
|
|
11
|
+
import './client/hooks/events';
|
|
12
|
+
import './client/hooks/months';
|
|
13
|
+
import './client/hooks/bills';
|
|
14
|
+
import './client/hooks/companies';
|
|
15
|
+
import './client/hooks/users';
|
|
16
|
+
import './client/hooks/sessions';
|
|
17
|
+
import './client/hooks/chats';
|
|
18
|
+
import './client/hooks/messages';
|
|
19
|
+
import './client/hooks/plans';
|
|
20
|
+
import './client/hooks/analytics';
|
|
21
|
+
import './client/hooks/avro';
|
|
22
|
+
import './client/hooks/teams';
|
|
23
|
+
import './client/hooks/groups';
|
|
24
|
+
import './client/hooks/skills';
|
|
4
25
|
export * from './types/api';
|
|
5
|
-
export * from './types/
|
|
26
|
+
export * from './types/auth';
|
|
27
|
+
export * from './types/cache';
|
|
6
28
|
export * from './types/client';
|
|
29
|
+
export * from './types/error';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
export { AvroQueryClient } from './client/QueryClient';
|
|
2
|
+
export { AvroQueryClientProvider, useAvroQueryClient } from './client/AvroQueryClientProvider';
|
|
2
3
|
export { AuthManager } from './auth/AuthManager';
|
|
3
4
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
5
|
+
import './client/core/xhr';
|
|
6
|
+
import './client/core/fetch';
|
|
7
|
+
import './client/core/utils';
|
|
8
|
+
import './client/hooks/root';
|
|
9
|
+
import './client/hooks/jobs';
|
|
10
|
+
import './client/hooks/routes';
|
|
11
|
+
import './client/hooks/events';
|
|
12
|
+
import './client/hooks/months';
|
|
13
|
+
import './client/hooks/bills';
|
|
14
|
+
import './client/hooks/companies';
|
|
15
|
+
import './client/hooks/users';
|
|
16
|
+
import './client/hooks/sessions';
|
|
17
|
+
import './client/hooks/chats';
|
|
18
|
+
import './client/hooks/messages';
|
|
19
|
+
import './client/hooks/plans';
|
|
20
|
+
import './client/hooks/analytics';
|
|
21
|
+
import './client/hooks/avro';
|
|
22
|
+
import './client/hooks/teams';
|
|
23
|
+
import './client/hooks/groups';
|
|
24
|
+
import './client/hooks/skills';
|
|
4
25
|
export * from './types/api';
|
|
5
|
-
export * from './types/
|
|
26
|
+
export * from './types/auth';
|
|
27
|
+
export * from './types/cache';
|
|
6
28
|
export * from './types/client';
|
|
29
|
+
export * from './types/error';
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export interface ApiInfo {
|
|
2
|
+
app_semver: string;
|
|
3
|
+
db_healthy: boolean;
|
|
4
|
+
logged_in_as: string;
|
|
5
|
+
ors_healthy: string;
|
|
6
|
+
pelias_healthy: boolean;
|
|
7
|
+
version: string;
|
|
8
|
+
vroom_healthy: boolean;
|
|
9
|
+
}
|
|
1
10
|
export interface PaymentMethod {
|
|
2
11
|
allow_redisplay: string;
|
|
3
12
|
autopay: boolean;
|
|
@@ -68,12 +77,16 @@ export interface MemberState {
|
|
|
68
77
|
}
|
|
69
78
|
export interface LineItem {
|
|
70
79
|
id: string;
|
|
80
|
+
line_item_type: "CUSTOM" | "ADDITIONAL_CHARGE" | "EVENT" | "SERVICE_MONTH";
|
|
71
81
|
name: string;
|
|
72
82
|
description: string;
|
|
73
83
|
cost: number | null;
|
|
74
84
|
amount: number | null;
|
|
75
85
|
time_created: number;
|
|
76
86
|
}
|
|
87
|
+
export interface CustomLineItem extends LineItem {
|
|
88
|
+
line_item_type: "CUSTOM";
|
|
89
|
+
}
|
|
77
90
|
export interface Reaction {
|
|
78
91
|
id: string;
|
|
79
92
|
message_id: string;
|
|
@@ -147,7 +160,6 @@ export interface Team {
|
|
|
147
160
|
export interface Subscription {
|
|
148
161
|
time_created: number;
|
|
149
162
|
time_updated: string;
|
|
150
|
-
user: User;
|
|
151
163
|
user_company_id: string;
|
|
152
164
|
job_id: string;
|
|
153
165
|
id: string;
|
|
@@ -163,10 +175,14 @@ export interface Plan {
|
|
|
163
175
|
trial_period_days: number;
|
|
164
176
|
time_created: number;
|
|
165
177
|
time_updated: number;
|
|
178
|
+
available_to_new_companies?: boolean;
|
|
179
|
+
available_to?: string[];
|
|
166
180
|
}
|
|
167
181
|
export interface BillPayment {
|
|
168
182
|
id: string;
|
|
169
183
|
amount: number;
|
|
184
|
+
avro_fees: number;
|
|
185
|
+
stripe_fees: number;
|
|
170
186
|
stripe_pi_id: string;
|
|
171
187
|
bill_user_id: string;
|
|
172
188
|
status: "created" | "processing" | "succeeded" | "failed" | "canceled" | "requires_action";
|
|
@@ -193,14 +209,15 @@ export interface User {
|
|
|
193
209
|
companies: UserCompanyAssociation[] | null;
|
|
194
210
|
email: string | null;
|
|
195
211
|
phone_number: string | null;
|
|
196
|
-
time_created:
|
|
197
|
-
time_updated:
|
|
212
|
+
time_created: number;
|
|
213
|
+
time_updated: number | null;
|
|
198
214
|
can_send_emails: boolean | null;
|
|
199
215
|
payment_methods: PaymentMethod[];
|
|
200
216
|
autopay_payment_types: string[];
|
|
201
217
|
autopay: boolean | null;
|
|
202
218
|
chats: Chat[];
|
|
203
219
|
bills: BillUser[];
|
|
220
|
+
is_root: boolean;
|
|
204
221
|
}
|
|
205
222
|
export interface Break {
|
|
206
223
|
id: string;
|
|
@@ -209,20 +226,20 @@ export interface Break {
|
|
|
209
226
|
company_billable: boolean;
|
|
210
227
|
client_billable: boolean;
|
|
211
228
|
}
|
|
212
|
-
export interface ServiceMonth {
|
|
213
|
-
|
|
229
|
+
export interface ServiceMonth extends LineItem {
|
|
230
|
+
line_item_type: "SERVICE_MONTH";
|
|
214
231
|
job_name: string;
|
|
215
232
|
job_id: string | null;
|
|
233
|
+
job_address: string;
|
|
234
|
+
job_labels: string[];
|
|
216
235
|
bill_id: string | null;
|
|
217
|
-
cost: number;
|
|
218
236
|
billed: boolean;
|
|
219
237
|
paid: boolean;
|
|
220
|
-
|
|
221
|
-
time_created: number;
|
|
238
|
+
tasks: string[];
|
|
222
239
|
time_updated: number | null;
|
|
223
240
|
}
|
|
224
241
|
export interface Session {
|
|
225
|
-
|
|
242
|
+
id: string;
|
|
226
243
|
user_id: string;
|
|
227
244
|
company_id: string;
|
|
228
245
|
time_started: number;
|
|
@@ -230,7 +247,7 @@ export interface Session {
|
|
|
230
247
|
break_id: string;
|
|
231
248
|
is_paused: boolean;
|
|
232
249
|
team_id: string;
|
|
233
|
-
|
|
250
|
+
route_id: string;
|
|
234
251
|
breaks: Break[];
|
|
235
252
|
}
|
|
236
253
|
export interface Group {
|
|
@@ -244,6 +261,18 @@ export interface Group {
|
|
|
244
261
|
time_created: number;
|
|
245
262
|
time_updated: number;
|
|
246
263
|
}
|
|
264
|
+
export declare const NotificationLevel: {
|
|
265
|
+
readonly IN_APP: 0;
|
|
266
|
+
readonly EMAIL: 1;
|
|
267
|
+
readonly SMS: 2;
|
|
268
|
+
readonly PUSH: 3;
|
|
269
|
+
};
|
|
270
|
+
export type NotificationLevel = typeof NotificationLevel[keyof typeof NotificationLevel];
|
|
271
|
+
export declare const LoginResponse: {
|
|
272
|
+
readonly SUCCESS: "SUCCESS";
|
|
273
|
+
readonly NEEDS_TOTP: "NEEDS_TOTP";
|
|
274
|
+
};
|
|
275
|
+
export type LoginResponse = typeof LoginResponse[keyof typeof LoginResponse];
|
|
247
276
|
export interface UserCompanyAssociation {
|
|
248
277
|
id: string;
|
|
249
278
|
user: User;
|
|
@@ -252,9 +281,9 @@ export interface UserCompanyAssociation {
|
|
|
252
281
|
effective_permissions: string[];
|
|
253
282
|
time_created: number | null;
|
|
254
283
|
time_updated: number | null;
|
|
255
|
-
notification_setting:
|
|
284
|
+
notification_setting: NotificationLevel[];
|
|
256
285
|
share_email_company_wide: boolean;
|
|
257
|
-
notifications:
|
|
286
|
+
notifications: Notification[];
|
|
258
287
|
groups: string[];
|
|
259
288
|
}
|
|
260
289
|
export interface Email {
|
|
@@ -294,6 +323,7 @@ export interface Bill {
|
|
|
294
323
|
customer_email: string | null;
|
|
295
324
|
manual_emails: string[][];
|
|
296
325
|
users: BillUser[];
|
|
326
|
+
paid: boolean;
|
|
297
327
|
paid_at: number;
|
|
298
328
|
time_created: number;
|
|
299
329
|
time_updated: number;
|
|
@@ -301,7 +331,7 @@ export interface Bill {
|
|
|
301
331
|
intent_created_at: number;
|
|
302
332
|
intent_last_created_at: number;
|
|
303
333
|
payment: BillPayment | null;
|
|
304
|
-
line_items:
|
|
334
|
+
line_items: CustomLineItem[];
|
|
305
335
|
months: string[];
|
|
306
336
|
due_date: number;
|
|
307
337
|
}
|
|
@@ -323,18 +353,13 @@ export interface PlanPayment {
|
|
|
323
353
|
time_updated: number;
|
|
324
354
|
}
|
|
325
355
|
export interface Company {
|
|
326
|
-
events: _Event[];
|
|
327
|
-
months: ServiceMonth[];
|
|
328
356
|
id: string;
|
|
329
|
-
jobs: Job[];
|
|
330
357
|
name: string;
|
|
331
358
|
email: string;
|
|
332
|
-
routes: Route[];
|
|
333
|
-
teams: Team[];
|
|
334
359
|
emails: Email[];
|
|
335
360
|
skills: Skill[];
|
|
336
|
-
time_created:
|
|
337
|
-
time_updated:
|
|
361
|
+
time_created: number;
|
|
362
|
+
time_updated: number | null;
|
|
338
363
|
users: UserCompanyAssociation[];
|
|
339
364
|
use_client_side_customer_start_billing: boolean;
|
|
340
365
|
use_client_side_customer_stop_billing: boolean;
|
|
@@ -353,6 +378,9 @@ export interface Company {
|
|
|
353
378
|
billing_email_id: string;
|
|
354
379
|
num_events: number;
|
|
355
380
|
num_jobs: number;
|
|
381
|
+
num_routes: number;
|
|
382
|
+
num_teams: number;
|
|
383
|
+
num_skills: number;
|
|
356
384
|
bills: Bill[];
|
|
357
385
|
enabled_payment_methods: string[];
|
|
358
386
|
sessions: Session[];
|
|
@@ -416,8 +444,9 @@ export interface Job {
|
|
|
416
444
|
routes: RouteJob[];
|
|
417
445
|
subscribers: Subscription[];
|
|
418
446
|
manual_emails: string[][];
|
|
447
|
+
overdue_time: number;
|
|
419
448
|
last_completed_event: _Event | null;
|
|
420
|
-
|
|
449
|
+
current_event: _Event | null;
|
|
421
450
|
labels: string[];
|
|
422
451
|
owner: string;
|
|
423
452
|
}
|
|
@@ -438,7 +467,8 @@ export interface Task {
|
|
|
438
467
|
created_by: UserCompanyAssociation | null;
|
|
439
468
|
overdueness: number | null;
|
|
440
469
|
overdue_time: number;
|
|
441
|
-
|
|
470
|
+
last_completed_event: _Event | null;
|
|
471
|
+
current_event: _Event | null;
|
|
442
472
|
delay: number;
|
|
443
473
|
skills: string[];
|
|
444
474
|
service: number;
|
|
@@ -450,6 +480,7 @@ export interface Task {
|
|
|
450
480
|
services_prepaid: number;
|
|
451
481
|
months_prepaid: number;
|
|
452
482
|
priority: boolean;
|
|
483
|
+
route_ids: string[];
|
|
453
484
|
}
|
|
454
485
|
export interface TaskWrapper {
|
|
455
486
|
latestEvent: number;
|
|
@@ -471,23 +502,31 @@ export interface taskEndInfo {
|
|
|
471
502
|
internal_notes: string;
|
|
472
503
|
external_notes: string;
|
|
473
504
|
}
|
|
474
|
-
export interface AdditionalCharge {
|
|
505
|
+
export interface AdditionalCharge extends LineItem {
|
|
506
|
+
line_item_type: "ADDITIONAL_CHARGE";
|
|
507
|
+
time_updated: number | null;
|
|
508
|
+
}
|
|
509
|
+
export interface UserEvent {
|
|
475
510
|
id: string;
|
|
476
|
-
|
|
511
|
+
session_id: string;
|
|
512
|
+
event_id: string;
|
|
513
|
+
user_id: string | null;
|
|
514
|
+
team_id: string | null;
|
|
515
|
+
user_name: string | null;
|
|
516
|
+
team_name: string | null;
|
|
517
|
+
time_started: number | null;
|
|
518
|
+
time_ended: number | null;
|
|
519
|
+
time_created: number | null;
|
|
477
520
|
time_updated: number | null;
|
|
478
|
-
name: string;
|
|
479
|
-
amount: number;
|
|
480
521
|
}
|
|
481
|
-
export interface _Event {
|
|
522
|
+
export interface _Event extends LineItem {
|
|
482
523
|
breaks: string[];
|
|
483
|
-
|
|
484
|
-
name: string;
|
|
524
|
+
line_item_type: "EVENT";
|
|
485
525
|
internal_notes: string;
|
|
486
526
|
external_notes: string;
|
|
487
527
|
proofs: string[];
|
|
488
528
|
tasks: string[];
|
|
489
|
-
|
|
490
|
-
time_ended: number;
|
|
529
|
+
time_ended: number | null;
|
|
491
530
|
time_started: number;
|
|
492
531
|
time_updated: number | null;
|
|
493
532
|
job_id: string;
|
|
@@ -496,11 +535,76 @@ export interface _Event {
|
|
|
496
535
|
bill_id: string;
|
|
497
536
|
billed_amount: number;
|
|
498
537
|
additional_charges: AdditionalCharge[];
|
|
499
|
-
|
|
500
|
-
team_id: string;
|
|
501
|
-
cost: number;
|
|
538
|
+
users: UserEvent[];
|
|
502
539
|
billed: boolean;
|
|
503
540
|
paid: boolean;
|
|
504
541
|
autostart: boolean;
|
|
505
542
|
job_labels: string[];
|
|
506
543
|
}
|
|
544
|
+
export interface FinancialInsightData {
|
|
545
|
+
start: number;
|
|
546
|
+
end: number;
|
|
547
|
+
unbilled: {
|
|
548
|
+
events: {
|
|
549
|
+
count: number;
|
|
550
|
+
amount: number;
|
|
551
|
+
};
|
|
552
|
+
service_months: {
|
|
553
|
+
count: number;
|
|
554
|
+
amount: number;
|
|
555
|
+
};
|
|
556
|
+
total: number;
|
|
557
|
+
};
|
|
558
|
+
billed_unbilled: {
|
|
559
|
+
events: {
|
|
560
|
+
count: number;
|
|
561
|
+
amount: number;
|
|
562
|
+
};
|
|
563
|
+
service_months: {
|
|
564
|
+
count: number;
|
|
565
|
+
amount: number;
|
|
566
|
+
};
|
|
567
|
+
total: number;
|
|
568
|
+
};
|
|
569
|
+
paid_unbilled: {
|
|
570
|
+
events: {
|
|
571
|
+
count: number;
|
|
572
|
+
amount: number;
|
|
573
|
+
};
|
|
574
|
+
service_months: {
|
|
575
|
+
count: number;
|
|
576
|
+
amount: number;
|
|
577
|
+
};
|
|
578
|
+
total: number;
|
|
579
|
+
};
|
|
580
|
+
prepaid: {
|
|
581
|
+
events: {
|
|
582
|
+
count: number;
|
|
583
|
+
amount: number;
|
|
584
|
+
};
|
|
585
|
+
service_months: {
|
|
586
|
+
count: number;
|
|
587
|
+
amount: number;
|
|
588
|
+
};
|
|
589
|
+
total: number;
|
|
590
|
+
};
|
|
591
|
+
accounts_receivable: {
|
|
592
|
+
overdue: number;
|
|
593
|
+
not_overdue: number;
|
|
594
|
+
};
|
|
595
|
+
cash: number;
|
|
596
|
+
}
|
|
597
|
+
export interface EventInsightData {
|
|
598
|
+
start: number;
|
|
599
|
+
end: number;
|
|
600
|
+
events_per_job: {
|
|
601
|
+
id: string;
|
|
602
|
+
name: string;
|
|
603
|
+
event_count: number;
|
|
604
|
+
}[];
|
|
605
|
+
events_per_team: {
|
|
606
|
+
team_id: string;
|
|
607
|
+
event_count: number;
|
|
608
|
+
}[];
|
|
609
|
+
total_events: number;
|
|
610
|
+
}
|
package/dist/types/api.js
CHANGED
package/dist/types/auth.d.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Tokens } from "../types/auth";
|
|
2
|
+
export interface CacheData extends Tokens {
|
|
3
|
+
companyId: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Cache {
|
|
6
|
+
get(key?: keyof CacheData): Promise<CacheData | string | null>;
|
|
7
|
+
set(data: Partial<CacheData>): Promise<void>;
|
|
8
|
+
clear(): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|