@bisondesk/core-sdk 1.0.343 → 1.0.345
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/lib/apis/opportunities.d.ts +0 -1
- package/lib/apis/opportunities.d.ts.map +1 -1
- package/lib/apis/opportunities.js +0 -9
- package/lib/apis/opportunities.js.map +1 -1
- package/lib/apis/users.d.ts +5 -0
- package/lib/apis/users.d.ts.map +1 -1
- package/lib/apis/users.js +24 -0
- package/lib/apis/users.js.map +1 -1
- package/lib/types/crm.d.ts +10 -2
- package/lib/types/crm.d.ts.map +1 -1
- package/lib/types/crm.js.map +1 -1
- package/lib/types/leasing-search.d.ts +0 -8
- package/lib/types/leasing-search.d.ts.map +1 -1
- package/lib/types/leasing-search.js.map +1 -1
- package/lib/types/leasing.d.ts +10 -1
- package/lib/types/leasing.d.ts.map +1 -1
- package/lib/types/leasing.js.map +1 -1
- package/lib/types/vehicles.d.ts +0 -5
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js +0 -4
- package/lib/types/vehicles.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/opportunities.ts +0 -16
- package/src/apis/users.ts +35 -1
- package/src/types/crm.ts +11 -2
- package/src/types/leasing-search.ts +0 -9
- package/src/types/leasing.ts +11 -1
- package/src/types/vehicles.ts +0 -6
- package/tsconfig.deploy.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/apis/users.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
1
|
+
import { AppRoles, TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
2
2
|
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
3
3
|
import { cleanHeaders, getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
4
4
|
import fetch, { Response } from 'node-fetch';
|
|
5
|
+
import { URL } from 'url';
|
|
5
6
|
import { User } from '../types/users.js';
|
|
6
7
|
|
|
7
8
|
export const getUser = async (tenantId: string, userId: string): Promise<User | undefined> => {
|
|
@@ -20,3 +21,36 @@ export const getUser = async (tenantId: string, userId: string): Promise<User |
|
|
|
20
21
|
const body = await response.text();
|
|
21
22
|
throw new XError(response.statusText, { body, tenantId, userId });
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export const listUsers = async (
|
|
26
|
+
tenantId: string,
|
|
27
|
+
opts?: { roles?: AppRoles[]; includeInactive?: boolean }
|
|
28
|
+
): Promise<User[]> => {
|
|
29
|
+
const auth = await getAdminAuth();
|
|
30
|
+
|
|
31
|
+
const url = new URL(`${process.env.CORE_API_ORIGIN}/api/users`);
|
|
32
|
+
|
|
33
|
+
if (opts?.roles) {
|
|
34
|
+
for (const role of opts.roles) {
|
|
35
|
+
url.searchParams.append('roles', role);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (opts?.includeInactive) {
|
|
40
|
+
url.searchParams.append('includeInactive', opts.includeInactive.toString());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const response: Response = await fetch(url, {
|
|
44
|
+
headers: cleanHeaders({
|
|
45
|
+
Authorization: auth,
|
|
46
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
47
|
+
}),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (response.ok) {
|
|
51
|
+
return response.status === 200 ? (response.json() as any) : undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const body = await response.text();
|
|
55
|
+
throw new XError(response.statusText, { body, tenantId, opts });
|
|
56
|
+
};
|
package/src/types/crm.ts
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
SearchPermissions,
|
|
7
7
|
} from '@bisondesk/commons-sdk/types';
|
|
8
8
|
import { PublicSearchDefinition } from './definitions.js';
|
|
9
|
-
import { LeasingContract } from './leasing.js';
|
|
10
9
|
import { ReferenceData } from './utils.js';
|
|
11
10
|
|
|
12
11
|
export type CrmEvent = CrmOrganizationEvent | CrmContactEvent;
|
|
@@ -79,9 +78,19 @@ export type OrganizationDebtInfo = {
|
|
|
79
78
|
unpaidAmount: string;
|
|
80
79
|
};
|
|
81
80
|
|
|
81
|
+
export type OrgLeasingContract = {
|
|
82
|
+
id: string;
|
|
83
|
+
contractNumber?: string;
|
|
84
|
+
vehicle: {
|
|
85
|
+
id: string;
|
|
86
|
+
stockNumber: string;
|
|
87
|
+
administrativeNumber?: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
82
91
|
export type SearchOrganization = {
|
|
83
92
|
org: Organization;
|
|
84
|
-
contract:
|
|
93
|
+
contract: OrgLeasingContract[]; // important for the logic regarding leasing overdue reminders
|
|
85
94
|
};
|
|
86
95
|
|
|
87
96
|
export type PotentialDuplicatesReferenceData = ReferenceData & { blockIgnore?: boolean };
|
|
@@ -17,7 +17,6 @@ export type SearchLeasingContract = {
|
|
|
17
17
|
contract: LeasingContract;
|
|
18
18
|
org: Organization;
|
|
19
19
|
contact?: Contact;
|
|
20
|
-
debt: LeasingContractDebtInfo;
|
|
21
20
|
vehicle: Vehicle;
|
|
22
21
|
custom: {
|
|
23
22
|
active: boolean;
|
|
@@ -25,14 +24,6 @@ export type SearchLeasingContract = {
|
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
export type LeasingContractDebtInfo = {
|
|
29
|
-
overdueSince?: string;
|
|
30
|
-
overdueInvoices: number;
|
|
31
|
-
overdueAmount: string;
|
|
32
|
-
unpaidInvoices: number;
|
|
33
|
-
unpaidAmount: string;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
27
|
export type InputSearchLeasingContract = SearchLeasingContract & {
|
|
37
28
|
permissions: SearchPermissions;
|
|
38
29
|
};
|
package/src/types/leasing.ts
CHANGED
|
@@ -7,6 +7,14 @@ export enum LeasingContractActions {
|
|
|
7
7
|
CREATE_FINANCE_DOCUMENT = 'create_finance_document',
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export type LeasingContractDebtInfo = {
|
|
11
|
+
overdueSince?: string;
|
|
12
|
+
overdueInvoices: number;
|
|
13
|
+
overdueAmount: string;
|
|
14
|
+
unpaidInvoices: number;
|
|
15
|
+
unpaidAmount: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
export type LeasingContractEvent = {
|
|
11
19
|
id: string;
|
|
12
20
|
action: 'create' | 'update' | 'delete';
|
|
@@ -113,11 +121,13 @@ type BaseLeasingContract<T = LeasingContractHyperportal | LeasingContractBisonde
|
|
|
113
121
|
export type LeasingContract<T = LeasingContractHyperportal | LeasingContractBisondesk> =
|
|
114
122
|
BaseLeasingContract<T> & {
|
|
115
123
|
readonly expectedEndDate: string;
|
|
124
|
+
readonly debt: LeasingContractDebtInfo;
|
|
116
125
|
};
|
|
117
126
|
|
|
118
127
|
export type NewLeasingContract<T = LeasingContractHyperportal | LeasingContractBisondesk> =
|
|
119
128
|
BaseLeasingContract<T> & {
|
|
120
|
-
readonly expectedEndDate?: undefined;
|
|
129
|
+
readonly expectedEndDate?: string | undefined;
|
|
130
|
+
readonly debt?: LeasingContractDebtInfo | undefined;
|
|
121
131
|
};
|
|
122
132
|
|
|
123
133
|
export type NextLeasingRentRowRequest = {
|
package/src/types/vehicles.ts
CHANGED
|
@@ -471,18 +471,12 @@ export type VehicleAxle = {
|
|
|
471
471
|
tyreSize?: string;
|
|
472
472
|
};
|
|
473
473
|
|
|
474
|
-
export enum MarketingChannel {
|
|
475
|
-
TELEGRAM = 'telegram',
|
|
476
|
-
}
|
|
477
|
-
|
|
478
474
|
export type VehicleMarketing = {
|
|
479
475
|
titles: MultiLangValue;
|
|
480
476
|
remarks?: MultiLangValue;
|
|
481
477
|
marketingPlatforms: string[];
|
|
482
|
-
channels?: MarketingChannel[];
|
|
483
478
|
videos: AttachmentValue[];
|
|
484
479
|
overrides?: {
|
|
485
|
-
channels?: boolean;
|
|
486
480
|
marketingPlatforms?: boolean;
|
|
487
481
|
remarks?: boolean;
|
|
488
482
|
titles?: boolean;
|