@bisondesk/core-sdk 1.0.353 → 1.0.354

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 (45) hide show
  1. package/lib/apis/crm.d.ts.map +1 -1
  2. package/lib/apis/crm.js +60 -32
  3. package/lib/apis/crm.js.map +1 -1
  4. package/lib/apis/debtors.d.ts.map +1 -1
  5. package/lib/apis/debtors.js +7 -3
  6. package/lib/apis/debtors.js.map +1 -1
  7. package/lib/apis/internet-vehicles.d.ts.map +1 -1
  8. package/lib/apis/internet-vehicles.js +5 -3
  9. package/lib/apis/internet-vehicles.js.map +1 -1
  10. package/lib/apis/leasing-administration.d.ts.map +1 -1
  11. package/lib/apis/leasing-administration.js +10 -6
  12. package/lib/apis/leasing-administration.js.map +1 -1
  13. package/lib/apis/leasing.d.ts.map +1 -1
  14. package/lib/apis/leasing.js +39 -25
  15. package/lib/apis/leasing.js.map +1 -1
  16. package/lib/apis/tenants.d.ts.map +1 -1
  17. package/lib/apis/tenants.js +15 -10
  18. package/lib/apis/tenants.js.map +1 -1
  19. package/lib/apis/users.d.ts.map +1 -1
  20. package/lib/apis/users.js +9 -7
  21. package/lib/apis/users.js.map +1 -1
  22. package/lib/apis/vehicles.d.ts.map +1 -1
  23. package/lib/apis/vehicles.js +38 -24
  24. package/lib/apis/vehicles.js.map +1 -1
  25. package/lib/constants.d.ts +1 -0
  26. package/lib/constants.d.ts.map +1 -1
  27. package/lib/constants.js +1 -0
  28. package/lib/constants.js.map +1 -1
  29. package/lib/types/vehicles.d.ts +2 -8
  30. package/lib/types/vehicles.d.ts.map +1 -1
  31. package/lib/types/vehicles.js.map +1 -1
  32. package/package.json +2 -2
  33. package/src/apis/crm.ts +128 -130
  34. package/src/apis/debtors.ts +13 -12
  35. package/src/apis/internet-vehicles.ts +5 -3
  36. package/src/apis/leasing-administration.ts +26 -28
  37. package/src/apis/leasing.ts +88 -101
  38. package/src/apis/tenants.ts +31 -38
  39. package/src/apis/users.ts +9 -7
  40. package/src/apis/vehicles.ts +90 -103
  41. package/src/constants.ts +1 -0
  42. package/src/types/vehicles.ts +2 -7
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/tsconfig.deploy.json +0 -5
  45. package/tsconfig.deploy.tsbuildinfo +0 -1
@@ -22,23 +22,21 @@ export const listLeasingClients = async (
22
22
  opts?: { serviceId: string }
23
23
  ): Promise<string[]> => {
24
24
  const auth = await getAdminAuth();
25
- const response: Response = await fetch(
26
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/clients?offset=${offset}&limit=${limit}`,
27
- {
28
- headers: cleanHeaders({
29
- Authorization: auth,
30
- [TENANT_ID_ADMIN_HEADER]: tenantId,
31
- [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
32
- }),
33
- }
34
- );
25
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/clients?offset=${offset}&limit=${limit}`;
26
+ const response: Response = await fetch(url, {
27
+ headers: cleanHeaders({
28
+ Authorization: auth,
29
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
30
+ [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
31
+ }),
32
+ });
35
33
 
36
34
  if (response.ok) {
37
35
  return response.status === 200 ? (response.json() as any) : undefined;
38
36
  }
39
37
 
40
38
  const body = await response.text();
41
- throw new XError(response.statusText, { tenantId, body, offset, limit });
39
+ throw new XError(response.statusText, { url, tenantId, body, offset, limit });
42
40
  };
43
41
 
44
42
  export const listLeasingContracts = async (
@@ -48,23 +46,21 @@ export const listLeasingContracts = async (
48
46
  opts?: { serviceId: string }
49
47
  ): Promise<LeasingContract[]> => {
50
48
  const auth = await getAdminAuth();
51
- const response: Response = await fetch(
52
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts?offset=${offset}&limit=${limit}`,
53
- {
54
- headers: cleanHeaders({
55
- Authorization: auth,
56
- [TENANT_ID_ADMIN_HEADER]: tenantId,
57
- [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
58
- }),
59
- }
60
- );
49
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts?offset=${offset}&limit=${limit}`;
50
+ const response: Response = await fetch(url, {
51
+ headers: cleanHeaders({
52
+ Authorization: auth,
53
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
54
+ [SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
55
+ }),
56
+ });
61
57
 
62
58
  if (response.ok) {
63
59
  return response.status === 200 ? (response.json() as any) : undefined;
64
60
  }
65
61
 
66
62
  const body = await response.text();
67
- throw new XError(response.statusText, { tenantId, body, offset, limit });
63
+ throw new XError(response.statusText, { url, tenantId, body, offset, limit });
68
64
  };
69
65
 
70
66
  export const getLeasingConditions = async (
@@ -72,22 +68,20 @@ export const getLeasingConditions = async (
72
68
  conditionsId: string
73
69
  ): Promise<LeasingConditions | undefined> => {
74
70
  const auth = await getAdminAuth();
75
- const response: Response = await fetch(
76
- `${process.env.CORE_API_ORIGIN}/api/leasing/conditions/${conditionsId}`,
77
- {
78
- headers: {
79
- Authorization: auth,
80
- [TENANT_ID_ADMIN_HEADER]: tenantId,
81
- },
82
- }
83
- );
71
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/conditions/${conditionsId}`;
72
+ const response: Response = await fetch(url, {
73
+ headers: {
74
+ Authorization: auth,
75
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
76
+ },
77
+ });
84
78
 
85
79
  if (response.ok) {
86
80
  return response.status === 200 ? (response.json() as any) : undefined;
87
81
  }
88
82
 
89
83
  const body = await response.text();
90
- throw new XError(response.statusText, { tenantId, conditionsId, body });
84
+ throw new XError(response.statusText, { url, tenantId, conditionsId, body });
91
85
  };
92
86
 
93
87
  export const createLeasingConditions = async (
@@ -95,8 +89,10 @@ export const createLeasingConditions = async (
95
89
  conditions: NewLeasingConditions
96
90
  ): Promise<LeasingConditions> => {
97
91
  const auth = await getAdminAuth();
98
- const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/leasing/conditions`, {
99
- method: 'POST',
92
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/conditions`;
93
+ const method = 'POST';
94
+ const response: Response = await fetch(url, {
95
+ method,
100
96
  headers: {
101
97
  'Content-Type': 'application/json',
102
98
  Authorization: auth,
@@ -110,7 +106,7 @@ export const createLeasingConditions = async (
110
106
  }
111
107
 
112
108
  const body = await response.text();
113
- throw new XError(response.statusText, { tenantId, conditions, body });
109
+ throw new XError(response.statusText, { method, url, tenantId, conditions, body });
114
110
  };
115
111
 
116
112
  export const getLeasingContractByNumber = async (
@@ -118,22 +114,20 @@ export const getLeasingContractByNumber = async (
118
114
  contractNumber: string
119
115
  ): Promise<LeasingContract | undefined> => {
120
116
  const auth = await getAdminAuth();
121
- const response: Response = await fetch(
122
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/number/${contractNumber}`,
123
- {
124
- headers: {
125
- Authorization: auth,
126
- [TENANT_ID_ADMIN_HEADER]: tenantId,
127
- },
128
- }
129
- );
117
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/number/${contractNumber}`;
118
+ const response: Response = await fetch(url, {
119
+ headers: {
120
+ Authorization: auth,
121
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
122
+ },
123
+ });
130
124
 
131
125
  if (response.ok) {
132
126
  return response.status === 200 ? (response.json() as any) : undefined;
133
127
  }
134
128
 
135
129
  const body = await response.text();
136
- throw new XError(response.statusText, { tenantId, contractNumber, body });
130
+ throw new XError(response.statusText, { url, tenantId, contractNumber, body });
137
131
  };
138
132
 
139
133
  export const getLeasingContract = async (
@@ -141,22 +135,20 @@ export const getLeasingContract = async (
141
135
  contractId: string
142
136
  ): Promise<DataRecord<LeasingContract> | undefined> => {
143
137
  const auth = await getAdminAuth();
144
- const response: Response = await fetch(
145
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}`,
146
- {
147
- headers: {
148
- Authorization: auth,
149
- [TENANT_ID_ADMIN_HEADER]: tenantId,
150
- },
151
- }
152
- );
138
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}`;
139
+ const response: Response = await fetch(url, {
140
+ headers: {
141
+ Authorization: auth,
142
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
143
+ },
144
+ });
153
145
 
154
146
  if (response.ok) {
155
147
  return response.status === 200 ? (response.json() as any) : undefined;
156
148
  }
157
149
 
158
150
  const body = await response.text();
159
- throw new XError(response.statusText, { tenantId, contractId, body });
151
+ throw new XError(response.statusText, { url, tenantId, contractId, body });
160
152
  };
161
153
 
162
154
  export const searchLeasingContracts = async (
@@ -164,25 +156,24 @@ export const searchLeasingContracts = async (
164
156
  request: SearchRequest
165
157
  ): Promise<PaginatedList<SearchLeasingContract, ReferenceData> | undefined> => {
166
158
  const auth = await getAdminAuth();
167
- const response: Response = await fetch(
168
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/search/results`,
169
- {
170
- headers: {
171
- 'Content-Type': 'application/json',
172
- Authorization: auth,
173
- [TENANT_ID_ADMIN_HEADER]: tenantId,
174
- },
175
- method: 'POST',
176
- body: JSON.stringify(request),
177
- }
178
- );
159
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/search/results`;
160
+ const method = 'POST';
161
+ const response: Response = await fetch(url, {
162
+ method,
163
+ headers: {
164
+ 'Content-Type': 'application/json',
165
+ Authorization: auth,
166
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
167
+ },
168
+ body: JSON.stringify(request),
169
+ });
179
170
 
180
171
  if (response.ok) {
181
172
  return response.status === 200 ? (response.json() as any) : undefined;
182
173
  }
183
174
 
184
175
  const body = await response.text();
185
- throw new XError(response.statusText, { tenantId, body });
176
+ throw new XError(response.statusText, { method, url, tenantId, body });
186
177
  };
187
178
 
188
179
  export const findLeasingContracts = async (
@@ -191,22 +182,20 @@ export const findLeasingContracts = async (
191
182
  vehicleId: string
192
183
  ): Promise<LeasingContract[]> => {
193
184
  const auth = await getAdminAuth();
194
- const response: Response = await fetch(
195
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/find?clientId=${clientId}&vehicleId=${vehicleId}`,
196
- {
197
- headers: {
198
- Authorization: auth,
199
- [TENANT_ID_ADMIN_HEADER]: tenantId,
200
- },
201
- }
202
- );
185
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/find?clientId=${clientId}&vehicleId=${vehicleId}`;
186
+ const response: Response = await fetch(url, {
187
+ headers: {
188
+ Authorization: auth,
189
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
190
+ },
191
+ });
203
192
 
204
193
  if (response.status === 200) {
205
194
  return response.json() as any;
206
195
  }
207
196
 
208
197
  const body = await response.text();
209
- throw new XError(response.statusText, { tenantId, clientId, vehicleId, body });
198
+ throw new XError(response.statusText, { url, tenantId, clientId, vehicleId, body });
210
199
  };
211
200
 
212
201
  export const upsertLeasingContract = async (
@@ -214,8 +203,10 @@ export const upsertLeasingContract = async (
214
203
  contract: NewLeasingContract | LeasingContract
215
204
  ): Promise<LeasingContract> => {
216
205
  const auth = await getAdminAuth();
217
- const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/leasing/contracts`, {
218
- method: 'POST',
206
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts`;
207
+ const method = 'POST';
208
+ const response: Response = await fetch(url, {
209
+ method,
219
210
  headers: {
220
211
  'Content-Type': 'application/json',
221
212
  Authorization: auth,
@@ -229,7 +220,7 @@ export const upsertLeasingContract = async (
229
220
  }
230
221
 
231
222
  const body = await response.text();
232
- throw new XError(response.statusText, { tenantId, contract, body });
223
+ throw new XError(response.statusText, { method, url, tenantId, contract, body });
233
224
  };
234
225
 
235
226
  export const getLeasingAmortizations = async (
@@ -237,22 +228,20 @@ export const getLeasingAmortizations = async (
237
228
  contractId: string
238
229
  ): Promise<AmortizationTable | undefined> => {
239
230
  const auth = await getAdminAuth();
240
- const response: Response = await fetch(
241
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}/amortization`,
242
- {
243
- headers: {
244
- Authorization: auth,
245
- [TENANT_ID_ADMIN_HEADER]: tenantId,
246
- },
247
- }
248
- );
231
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}/amortization`;
232
+ const response: Response = await fetch(url, {
233
+ headers: {
234
+ Authorization: auth,
235
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
236
+ },
237
+ });
249
238
 
250
239
  if (response.status === 200) {
251
240
  return response.json() as any;
252
241
  }
253
242
 
254
243
  const body = await response.text();
255
- throw new XError(response.statusText, { tenantId, contractId, body });
244
+ throw new XError(response.statusText, { url, tenantId, contractId, body });
256
245
  };
257
246
 
258
247
  export const listAmortizationDocsByContract = async (
@@ -260,20 +249,18 @@ export const listAmortizationDocsByContract = async (
260
249
  contractId: string
261
250
  ): Promise<AmortizationDocs[]> => {
262
251
  const auth = await getAdminAuth();
263
- const response: Response = await fetch(
264
- `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}/amortization/docs`,
265
- {
266
- headers: {
267
- Authorization: auth,
268
- [TENANT_ID_ADMIN_HEADER]: tenantId,
269
- },
270
- }
271
- );
252
+ const url = `${process.env.CORE_API_ORIGIN}/api/leasing/contracts/${contractId}/amortization/docs`;
253
+ const response: Response = await fetch(url, {
254
+ headers: {
255
+ Authorization: auth,
256
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
257
+ },
258
+ });
272
259
 
273
260
  if (response.status === 200) {
274
261
  return response.json() as any as any;
275
262
  }
276
263
 
277
264
  const body = await response.text();
278
- throw new XError(response.statusText, { tenantId, contractId, body });
265
+ throw new XError(response.statusText, { url, tenantId, contractId, body });
279
266
  };
@@ -5,7 +5,8 @@ import { Tenant, TenantSyncSettings } from '../types/tenants.js';
5
5
 
6
6
  export const listTenants = async (): Promise<Tenant[]> => {
7
7
  const auth = await getAdminAuth();
8
- const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/admin/tenants`, {
8
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants`;
9
+ const response: Response = await fetch(url, {
9
10
  headers: {
10
11
  Authorization: auth,
11
12
  },
@@ -16,85 +17,77 @@ export const listTenants = async (): Promise<Tenant[]> => {
16
17
  }
17
18
 
18
19
  const body = await response.text();
19
- throw new XError(response.statusText, { body });
20
+ throw new XError(response.statusText, { url, body });
20
21
  };
21
22
 
22
23
  export const listTenantsSyncSettings = async (): Promise<TenantSyncSettings[]> => {
23
24
  const auth = await getAdminAuth();
24
- const response: Response = await fetch(
25
- `${process.env.CORE_API_ORIGIN}/admin/tenants/settings/sync`,
26
- {
27
- headers: {
28
- Authorization: auth,
29
- },
30
- }
31
- );
25
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/settings/sync`;
26
+ const response: Response = await fetch(url, {
27
+ headers: {
28
+ Authorization: auth,
29
+ },
30
+ });
32
31
 
33
32
  if (response.ok) {
34
33
  return response.json() as any;
35
34
  }
36
35
 
37
36
  const body = await response.text();
38
- throw new XError(response.statusText, { body });
37
+ throw new XError(response.statusText, { url, body });
39
38
  };
40
39
 
41
40
  export const getTenant = async (tenantId: string): Promise<Tenant | undefined> => {
42
41
  const auth = await getAdminAuth();
43
- const response: Response = await fetch(
44
- `${process.env.CORE_API_ORIGIN}/admin/tenants/${tenantId}`,
45
- {
46
- headers: {
47
- Authorization: auth,
48
- },
49
- }
50
- );
42
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/${tenantId}`;
43
+ const response: Response = await fetch(url, {
44
+ headers: {
45
+ Authorization: auth,
46
+ },
47
+ });
51
48
 
52
49
  if (response.ok) {
53
50
  return response.status === 200 ? (response.json() as any) : undefined;
54
51
  }
55
52
 
56
53
  const body = await response.text();
57
- throw new XError(response.statusText, { body });
54
+ throw new XError(response.statusText, { url, body });
58
55
  };
59
56
 
60
57
  export const getTenantByHyperdmsId = async (
61
58
  hyperdmsTenantId: string
62
59
  ): Promise<Tenant | undefined> => {
63
60
  const auth = await getAdminAuth();
64
- const response: Response = await fetch(
65
- `${process.env.CORE_API_ORIGIN}/admin/tenants/hyperdms/${hyperdmsTenantId}`,
66
- {
67
- headers: {
68
- Authorization: auth,
69
- },
70
- }
71
- );
61
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/hyperdms/${hyperdmsTenantId}`;
62
+ const response: Response = await fetch(url, {
63
+ headers: {
64
+ Authorization: auth,
65
+ },
66
+ });
72
67
 
73
68
  if (response.ok) {
74
69
  return response.status === 200 ? (response.json() as any) : undefined;
75
70
  }
76
71
 
77
72
  const body = await response.text();
78
- throw new XError(response.statusText, { body });
73
+ throw new XError(response.statusText, { url, body });
79
74
  };
80
75
 
81
76
  export const getTenantByHyperportalId = async (
82
77
  hyperportalTenantId: string
83
78
  ): Promise<Tenant | undefined> => {
84
79
  const auth = await getAdminAuth();
85
- const response: Response = await fetch(
86
- `${process.env.CORE_API_ORIGIN}/admin/tenants/hyperportal/${hyperportalTenantId}`,
87
- {
88
- headers: {
89
- Authorization: auth,
90
- },
91
- }
92
- );
80
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/hyperportal/${hyperportalTenantId}`;
81
+ const response: Response = await fetch(url, {
82
+ headers: {
83
+ Authorization: auth,
84
+ },
85
+ });
93
86
 
94
87
  if (response.ok) {
95
88
  return response.status === 200 ? (response.json() as any) : undefined;
96
89
  }
97
90
 
98
91
  const body = await response.text();
99
- throw new XError(response.statusText, { body });
92
+ throw new XError(response.statusText, { url, body });
100
93
  };
package/src/apis/users.ts CHANGED
@@ -7,7 +7,8 @@ import { User } from '../types/users.js';
7
7
 
8
8
  export const getUser = async (tenantId: string, userId: string): Promise<User | undefined> => {
9
9
  const auth = await getAdminAuth();
10
- const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/users/${userId}`, {
10
+ const url = `${process.env.CORE_API_ORIGIN}/api/users/${userId}`;
11
+ const response: Response = await fetch(url, {
11
12
  headers: cleanHeaders({
12
13
  Authorization: auth,
13
14
  [TENANT_ID_ADMIN_HEADER]: tenantId,
@@ -19,7 +20,7 @@ export const getUser = async (tenantId: string, userId: string): Promise<User |
19
20
  }
20
21
 
21
22
  const body = await response.text();
22
- throw new XError(response.statusText, { body, tenantId, userId });
23
+ throw new XError(response.statusText, { url, body, tenantId, userId });
23
24
  };
24
25
 
25
26
  export const listUsers = async (
@@ -27,20 +28,21 @@ export const listUsers = async (
27
28
  opts?: { roles?: AppRoles[]; includeInactive?: boolean }
28
29
  ): Promise<User[]> => {
29
30
  const auth = await getAdminAuth();
31
+ const url = `${process.env.CORE_API_ORIGIN}/api/users`;
30
32
 
31
- const url = new URL(`${process.env.CORE_API_ORIGIN}/api/users`);
33
+ const urlInstance = new URL(url);
32
34
 
33
35
  if (opts?.roles) {
34
36
  for (const role of opts.roles) {
35
- url.searchParams.append('roles', role);
37
+ urlInstance.searchParams.append('roles', role);
36
38
  }
37
39
  }
38
40
 
39
41
  if (opts?.includeInactive) {
40
- url.searchParams.append('includeInactive', opts.includeInactive.toString());
42
+ urlInstance.searchParams.append('includeInactive', opts.includeInactive.toString());
41
43
  }
42
44
 
43
- const response: Response = await fetch(url, {
45
+ const response: Response = await fetch(urlInstance, {
44
46
  headers: cleanHeaders({
45
47
  Authorization: auth,
46
48
  [TENANT_ID_ADMIN_HEADER]: tenantId,
@@ -52,5 +54,5 @@ export const listUsers = async (
52
54
  }
53
55
 
54
56
  const body = await response.text();
55
- throw new XError(response.statusText, { body, tenantId, opts });
57
+ throw new XError(response.statusText, { url, body, tenantId, opts });
56
58
  };