@bisondesk/core-sdk 1.0.330 → 1.0.332
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/debtors.d.ts +6 -0
- package/lib/apis/debtors.d.ts.map +1 -0
- package/lib/apis/debtors.js +25 -0
- package/lib/apis/debtors.js.map +1 -0
- package/lib/apis/leasing.d.ts +5 -1
- package/lib/apis/leasing.d.ts.map +1 -1
- package/lib/apis/leasing.js +17 -0
- package/lib/apis/leasing.js.map +1 -1
- package/lib/apis/picklists.d.ts +1 -5
- package/lib/apis/picklists.d.ts.map +1 -1
- package/lib/apis/picklists.js +1 -51
- package/lib/apis/picklists.js.map +1 -1
- package/lib/types/definitions.d.ts +1 -37
- package/lib/types/definitions.d.ts.map +1 -1
- package/lib/types/definitions.js +1 -1
- package/lib/types/definitions.js.map +1 -1
- package/lib/types/fields.d.ts +1 -82
- package/lib/types/fields.d.ts.map +1 -1
- package/lib/types/fields.js +1 -25
- package/lib/types/fields.js.map +1 -1
- package/lib/types/opportunities.d.ts +1 -0
- package/lib/types/opportunities.d.ts.map +1 -1
- package/lib/types/opportunities.js.map +1 -1
- package/lib/types/picklists.d.ts +1 -82
- package/lib/types/picklists.d.ts.map +1 -1
- package/lib/types/picklists.js +1 -1
- package/lib/types/picklists.js.map +1 -1
- package/lib/types/search.d.ts +1 -175
- package/lib/types/search.d.ts.map +1 -1
- package/lib/types/search.js +1 -32
- package/lib/types/search.js.map +1 -1
- package/lib/types/utils.d.ts +1 -46
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +1 -5
- package/lib/types/utils.js.map +1 -1
- package/lib/utils/search.d.ts.map +1 -1
- package/lib/utils/search.js.map +1 -1
- package/package.json +1 -1
- package/src/apis/debtors.ts +37 -0
- package/src/apis/leasing.ts +30 -1
- package/src/apis/picklists.ts +1 -73
- package/src/types/definitions.ts +1 -43
- package/src/types/fields.ts +1 -123
- package/src/types/opportunities.ts +1 -0
- package/src/types/picklists.ts +1 -95
- package/src/types/search.ts +1 -222
- package/src/types/utils.ts +1 -52
- package/src/utils/search.ts +2 -0
- package/tsconfig.deploy.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/apis/leasing.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { SERVICE_ID_ADMIN_HEADER, 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
|
+
import { PaginatedList } from '@bisondesk/commons-sdk/types';
|
|
4
5
|
import fetch, { Response } from 'node-fetch';
|
|
6
|
+
import { SearchLeasingContract } from '../types/leasing-search.js';
|
|
5
7
|
import {
|
|
6
8
|
AmortizationDocs,
|
|
7
9
|
AmortizationTable,
|
|
@@ -10,7 +12,8 @@ import {
|
|
|
10
12
|
NewLeasingConditions,
|
|
11
13
|
NewLeasingContract,
|
|
12
14
|
} from '../types/leasing.js';
|
|
13
|
-
import {
|
|
15
|
+
import { SearchRequest } from '../types/search.js';
|
|
16
|
+
import { DataRecord, ReferenceData } from '../types/utils.js';
|
|
14
17
|
|
|
15
18
|
export const listLeasingClients = async (
|
|
16
19
|
tenantId: string,
|
|
@@ -156,6 +159,32 @@ export const getLeasingContract = async (
|
|
|
156
159
|
throw new XError(response.statusText, { tenantId, contractId, body });
|
|
157
160
|
};
|
|
158
161
|
|
|
162
|
+
export const searchLeasingContracts = async (
|
|
163
|
+
tenantId: string,
|
|
164
|
+
request: SearchRequest
|
|
165
|
+
): Promise<PaginatedList<SearchLeasingContract, ReferenceData> | undefined> => {
|
|
166
|
+
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
|
+
);
|
|
179
|
+
|
|
180
|
+
if (response.ok) {
|
|
181
|
+
return response.status === 200 ? (response.json() as any) : undefined;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const body = await response.text();
|
|
185
|
+
throw new XError(response.statusText, { tenantId, body });
|
|
186
|
+
};
|
|
187
|
+
|
|
159
188
|
export const findLeasingContracts = async (
|
|
160
189
|
tenantId: string,
|
|
161
190
|
clientId: string,
|
package/src/apis/picklists.ts
CHANGED
|
@@ -1,73 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { cleanHeaders, getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
3
|
-
import { Option } from '@bisondesk/commons-sdk/types';
|
|
4
|
-
import fetch, { Response } from 'node-fetch';
|
|
5
|
-
import {
|
|
6
|
-
AdHocPicklistRequest,
|
|
7
|
-
AdHocPicklistValueDisplay,
|
|
8
|
-
PicklistOptionsRequest,
|
|
9
|
-
PicklistValue,
|
|
10
|
-
PicklistValueUpdateRequest,
|
|
11
|
-
} from '../types/picklists.js';
|
|
12
|
-
|
|
13
|
-
export const getMultiplePicklistValues = async (
|
|
14
|
-
request: AdHocPicklistRequest
|
|
15
|
-
): Promise<AdHocPicklistValueDisplay> => {
|
|
16
|
-
const auth = await getAdminAuth();
|
|
17
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {
|
|
18
|
-
method: 'POST',
|
|
19
|
-
headers: {
|
|
20
|
-
Authorization: auth,
|
|
21
|
-
'Content-Type': 'application/json',
|
|
22
|
-
},
|
|
23
|
-
body: JSON.stringify(request),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (response.ok) {
|
|
27
|
-
return response.json() as any;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const body = await response.text();
|
|
31
|
-
throw new XError(response.statusText, { body });
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export const getPicklistOptions = async (req: PicklistOptionsRequest): Promise<Option[]> => {
|
|
35
|
-
const auth = await getAdminAuth();
|
|
36
|
-
|
|
37
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/options`, {
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: cleanHeaders({
|
|
40
|
-
Authorization: auth,
|
|
41
|
-
'Content-Type': 'application/json',
|
|
42
|
-
}),
|
|
43
|
-
body: JSON.stringify(req),
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (response.ok) {
|
|
47
|
-
return response.json() as any;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const body = await response.text();
|
|
51
|
-
throw new XError(response.statusText, { body, req });
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export const upsertPicklistValue = async (
|
|
55
|
-
request: PicklistValueUpdateRequest
|
|
56
|
-
): Promise<PicklistValue> => {
|
|
57
|
-
const auth = await getAdminAuth();
|
|
58
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/value`, {
|
|
59
|
-
method: 'POST',
|
|
60
|
-
headers: {
|
|
61
|
-
Authorization: auth,
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
},
|
|
64
|
-
body: JSON.stringify(request),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
if (response.ok) {
|
|
68
|
-
return response.json() as any;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const body = await response.text();
|
|
72
|
-
throw new XError(response.statusText, { body });
|
|
73
|
-
};
|
|
1
|
+
export * from '@bisondesk/commons-sdk/apis/picklists';
|
package/src/types/definitions.ts
CHANGED
|
@@ -1,43 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { FieldTypeInfo } from './fields.js';
|
|
3
|
-
import { Aggregation } from './search.js';
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
// These definitions are sent to the UI
|
|
7
|
-
//
|
|
8
|
-
export type PublicSearchDefinition = {
|
|
9
|
-
fields: { [fieldId: string]: SearchField };
|
|
10
|
-
aggs: Aggregation[];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
// These definitions are for internal consumption
|
|
15
|
-
//
|
|
16
|
-
export type SearchDefinition = {
|
|
17
|
-
fields: { [fieldId: string]: SearchField };
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type SearchField = {
|
|
21
|
-
id: string;
|
|
22
|
-
titles: { [lang: string]: string } & (
|
|
23
|
-
| { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string }
|
|
24
|
-
| { key: string }
|
|
25
|
-
);
|
|
26
|
-
} & FieldTypeInfo;
|
|
27
|
-
|
|
28
|
-
export type EsDefinitionField = {
|
|
29
|
-
esMapping: unknown;
|
|
30
|
-
sortKey?: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type EsDefinition = {
|
|
34
|
-
name: string;
|
|
35
|
-
nestedEsPaths: string[];
|
|
36
|
-
fields: {
|
|
37
|
-
[fieldId: string]: EsDefinitionField;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type EsFullTextSearchDefinition = ((lang: string) => string)[];
|
|
42
|
-
|
|
43
|
-
export type EsAggregationsDefinition = Aggregation[];
|
|
1
|
+
export * from '@bisondesk/commons-sdk/definitions';
|
package/src/types/fields.ts
CHANGED
|
@@ -1,123 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
attachment = 'attachment',
|
|
3
|
-
checkbox = 'checkbox',
|
|
4
|
-
collaborator = 'collaborator',
|
|
5
|
-
date = 'date',
|
|
6
|
-
email = 'email',
|
|
7
|
-
image = 'image',
|
|
8
|
-
link = 'link',
|
|
9
|
-
location = 'location',
|
|
10
|
-
multilang = 'multilang',
|
|
11
|
-
multiline = 'multiline',
|
|
12
|
-
number = 'number',
|
|
13
|
-
phoneNumber = 'phoneNumber',
|
|
14
|
-
picklist = 'picklist',
|
|
15
|
-
rating = 'rating',
|
|
16
|
-
text = 'text',
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
// Field values
|
|
21
|
-
//
|
|
22
|
-
export enum DateGranularity {
|
|
23
|
-
year = 'year',
|
|
24
|
-
yearMonth = 'yearMonth',
|
|
25
|
-
yearMonthDay = 'yearMonthDay',
|
|
26
|
-
yearMonthDayTime = 'yearMonthDayTime',
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
// Field metas
|
|
31
|
-
//
|
|
32
|
-
type BaseMeta = {};
|
|
33
|
-
|
|
34
|
-
type NumberUnit =
|
|
35
|
-
| 'acre'
|
|
36
|
-
| 'bit'
|
|
37
|
-
| 'byte'
|
|
38
|
-
| 'celsius'
|
|
39
|
-
| 'centimeter'
|
|
40
|
-
| 'day'
|
|
41
|
-
| 'degree'
|
|
42
|
-
| 'fahrenheit'
|
|
43
|
-
| 'fluid-ounce'
|
|
44
|
-
| 'foot'
|
|
45
|
-
| 'gallon'
|
|
46
|
-
| 'gigabit'
|
|
47
|
-
| 'gigabyte'
|
|
48
|
-
| 'gram'
|
|
49
|
-
| 'hectare'
|
|
50
|
-
| 'hour'
|
|
51
|
-
| 'inch'
|
|
52
|
-
| 'kilobit'
|
|
53
|
-
| 'kilobyte'
|
|
54
|
-
| 'kilogram'
|
|
55
|
-
| 'kilometer'
|
|
56
|
-
| 'liter'
|
|
57
|
-
| 'megabit'
|
|
58
|
-
| 'megabyte'
|
|
59
|
-
| 'meter'
|
|
60
|
-
| 'mile'
|
|
61
|
-
| 'mile-scandinavian'
|
|
62
|
-
| 'milliliter'
|
|
63
|
-
| 'millimeter'
|
|
64
|
-
| 'millisecond'
|
|
65
|
-
| 'minute'
|
|
66
|
-
| 'month'
|
|
67
|
-
| 'ounce'
|
|
68
|
-
| 'percent'
|
|
69
|
-
| 'petabyte'
|
|
70
|
-
| 'pound'
|
|
71
|
-
| 'second'
|
|
72
|
-
| 'stone'
|
|
73
|
-
| 'terabit'
|
|
74
|
-
| 'terabyte'
|
|
75
|
-
| 'week'
|
|
76
|
-
| 'yard'
|
|
77
|
-
| 'year';
|
|
78
|
-
|
|
79
|
-
type BaseNumberMeta = {
|
|
80
|
-
minimumFractionDigits?: number;
|
|
81
|
-
maximumFractionDigits?: number;
|
|
82
|
-
useGrouping?: boolean;
|
|
83
|
-
} & (
|
|
84
|
-
| {
|
|
85
|
-
style: 'unit';
|
|
86
|
-
unit: NumberUnit;
|
|
87
|
-
}
|
|
88
|
-
| {
|
|
89
|
-
style?: 'currency' | 'decimal' | 'percent';
|
|
90
|
-
unit?: NumberUnit;
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
export type NumberMeta = BaseMeta & BaseNumberMeta;
|
|
95
|
-
|
|
96
|
-
export type DateMeta = BaseMeta & {
|
|
97
|
-
granularity: DateGranularity;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export type RatingMeta = BaseMeta & {
|
|
101
|
-
max: number;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export type PicklistMeta = BaseMeta & {
|
|
105
|
-
picklistId: string;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export type FieldTypeInfo =
|
|
109
|
-
| { type: FieldTypes.attachment }
|
|
110
|
-
| { type: FieldTypes.checkbox }
|
|
111
|
-
| { type: FieldTypes.date; meta: DateMeta }
|
|
112
|
-
| { type: FieldTypes.email }
|
|
113
|
-
| { type: FieldTypes.image }
|
|
114
|
-
| { type: FieldTypes.link }
|
|
115
|
-
| { type: FieldTypes.location }
|
|
116
|
-
| { type: FieldTypes.multilang }
|
|
117
|
-
| { type: FieldTypes.multiline }
|
|
118
|
-
| { type: FieldTypes.number; meta: NumberMeta }
|
|
119
|
-
| { type: FieldTypes.phoneNumber }
|
|
120
|
-
| { type: FieldTypes.picklist; meta: PicklistMeta }
|
|
121
|
-
| { type: FieldTypes.rating; meta: RatingMeta }
|
|
122
|
-
| { type: FieldTypes.text }
|
|
123
|
-
| { type: FieldTypes.collaborator };
|
|
1
|
+
export * from '@bisondesk/commons-sdk/fields';
|
package/src/types/picklists.ts
CHANGED
|
@@ -1,95 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type PicklistValueUpdateRequest = {
|
|
4
|
-
picklistId: string;
|
|
5
|
-
value: PicklistValue | NewPicklistValue;
|
|
6
|
-
tenantId?: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type NewPicklistValue<T = Record<string, string>> = {
|
|
10
|
-
color?: string;
|
|
11
|
-
sortPriority?: number;
|
|
12
|
-
titles: MultiLangValue;
|
|
13
|
-
dependency?: PicklistValueDependency;
|
|
14
|
-
meta?: T;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type PicklistValue<T = any> = NewPicklistValue<T> & {
|
|
18
|
-
id: string;
|
|
19
|
-
system?: boolean;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type PicklistValueListRequest = {
|
|
23
|
-
picklistId: string;
|
|
24
|
-
limit: number;
|
|
25
|
-
offset: number;
|
|
26
|
-
dependencies?: PicklistValueDependency[];
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type PicklistValueRequest = {
|
|
30
|
-
picklistId: string;
|
|
31
|
-
valueId: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type AdHocPicklistValues<T = any> = {
|
|
35
|
-
[picklistId: string]: {
|
|
36
|
-
[valueId: string]: PicklistValue<T>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type AdHocPicklistRequest = {
|
|
41
|
-
requests: PicklistValueRequest[];
|
|
42
|
-
preferredLang: string;
|
|
43
|
-
tenantLang: string;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type AdHocPicklistValueDisplay = {
|
|
47
|
-
[picklistId: string]: {
|
|
48
|
-
[valueId: string]: {
|
|
49
|
-
color?: string;
|
|
50
|
-
title: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export type PicklistOptionsRequest = {
|
|
56
|
-
picklistId: string;
|
|
57
|
-
dependencies?: PicklistValueDependency[];
|
|
58
|
-
lang: string;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export type PicklistUpsertValueRequest = {
|
|
62
|
-
tenantId?: string;
|
|
63
|
-
picklistId: string;
|
|
64
|
-
value: PicklistValue | NewPicklistValue;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type QuickAddPicklistValue = {
|
|
68
|
-
sortPriority?: number;
|
|
69
|
-
titles: MultiLangValue;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export type NewPicklist = {
|
|
73
|
-
id?: undefined;
|
|
74
|
-
titles: MultiLangValue;
|
|
75
|
-
values: QuickAddPicklistValue[];
|
|
76
|
-
customSort?: boolean;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export type BasePicklist = {
|
|
80
|
-
customSort?: boolean;
|
|
81
|
-
id: string;
|
|
82
|
-
system?: boolean;
|
|
83
|
-
titles: MultiLangValue;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export type PicklistInfo = BasePicklist & {
|
|
87
|
-
count: number;
|
|
88
|
-
modifiedAt: string;
|
|
89
|
-
};
|
|
90
|
-
export type PicklistValueDependency = {
|
|
91
|
-
picklistId: string;
|
|
92
|
-
values: string[];
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type PicklistCollection = (BasePicklist & { data: PicklistValue[] })[];
|
|
1
|
+
export * from '@bisondesk/commons-sdk/picklists';
|
package/src/types/search.ts
CHANGED
|
@@ -1,222 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// Generic stuff
|
|
3
|
-
///////////////////////////////////////////////////////
|
|
4
|
-
|
|
5
|
-
import { BusinessEntityIds, SUPPORTED_LANGUAGES } from '@bisondesk/commons-sdk/constants';
|
|
6
|
-
import { MultiLangValue } from '@bisondesk/commons-sdk/types';
|
|
7
|
-
import { FieldTypes, NumberMeta } from './fields.js';
|
|
8
|
-
|
|
9
|
-
export enum ConditionType {
|
|
10
|
-
and = 'AND',
|
|
11
|
-
or = 'OR',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export enum ElasticsearchOperator {
|
|
15
|
-
// all properties
|
|
16
|
-
empty = 'EMPTY',
|
|
17
|
-
notEmpty = 'NOT_EMPTY',
|
|
18
|
-
is = 'IS',
|
|
19
|
-
isNot = 'IS_NOT',
|
|
20
|
-
// number, date properties
|
|
21
|
-
greaterThanOrEqual = 'GTE',
|
|
22
|
-
greaterThan = 'GT',
|
|
23
|
-
lessThanEqual = 'LTE',
|
|
24
|
-
lessThan = 'LT',
|
|
25
|
-
between = 'BETWEEN',
|
|
26
|
-
// string properties
|
|
27
|
-
contains = 'CONTAINS',
|
|
28
|
-
notContains = 'NOT_CONTAINS',
|
|
29
|
-
startsWith = 'STARTS_WITH',
|
|
30
|
-
endsWith = 'ENDS_WITH',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type Filter<OP = ElasticsearchOperator> = {
|
|
34
|
-
data: string;
|
|
35
|
-
fieldId: string;
|
|
36
|
-
operator: OP;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type ComplexFilter<OP = ElasticsearchOperator> = {
|
|
40
|
-
condition: ConditionType;
|
|
41
|
-
filters: Array<Filter<OP> | ComplexFilter<OP>>;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type SearchResponse<T = any> = {
|
|
45
|
-
took: number;
|
|
46
|
-
timed_out: boolean;
|
|
47
|
-
_scroll_id?: string;
|
|
48
|
-
_shards: unknown;
|
|
49
|
-
hits: {
|
|
50
|
-
total: {
|
|
51
|
-
value: number;
|
|
52
|
-
relation: 'eq' | 'gte';
|
|
53
|
-
};
|
|
54
|
-
max_score: number;
|
|
55
|
-
hits: Array<{
|
|
56
|
-
_index: string;
|
|
57
|
-
_type: string;
|
|
58
|
-
_id: string;
|
|
59
|
-
_score: number;
|
|
60
|
-
_source?: T;
|
|
61
|
-
_version?: number;
|
|
62
|
-
_explanation?: unknown;
|
|
63
|
-
fields?: any;
|
|
64
|
-
highlight?: any;
|
|
65
|
-
inner_hits?: any;
|
|
66
|
-
matched_queries?: string[];
|
|
67
|
-
sort?: Array<string | number>;
|
|
68
|
-
}>;
|
|
69
|
-
};
|
|
70
|
-
aggregations?: { [aggName: string]: object };
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
///////////////////////////////////////////////////////
|
|
74
|
-
// Search
|
|
75
|
-
///////////////////////////////////////////////////////
|
|
76
|
-
|
|
77
|
-
export const FILTER_RANGE_SEPARATOR = '__';
|
|
78
|
-
|
|
79
|
-
export enum SortOrder {
|
|
80
|
-
asc = 'asc',
|
|
81
|
-
desc = 'desc',
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type SortFilter = {
|
|
85
|
-
fieldId: string;
|
|
86
|
-
order: SortOrder;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type BaseSearchRequest = {
|
|
90
|
-
fullText?: string;
|
|
91
|
-
limit: number;
|
|
92
|
-
query?: ComplexFilter<ElasticsearchOperator>;
|
|
93
|
-
sortBy?: SortFilter[];
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
type InfiniteSearchRequest = {
|
|
97
|
-
infinite: true;
|
|
98
|
-
nextToken?: string;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type PaginatedSearchRequest = {
|
|
102
|
-
infinite?: false;
|
|
103
|
-
offset?: number;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export type SearchRequest = {
|
|
107
|
-
fullText?: string;
|
|
108
|
-
limit: number;
|
|
109
|
-
query?: ComplexFilter<ElasticsearchOperator>;
|
|
110
|
-
sortBy?: SortFilter[];
|
|
111
|
-
} & (InfiniteSearchRequest | PaginatedSearchRequest);
|
|
112
|
-
|
|
113
|
-
export type GlobalSearchRequest = {
|
|
114
|
-
fullText: string;
|
|
115
|
-
limit: number;
|
|
116
|
-
} & {
|
|
117
|
-
entityIds: BusinessEntityIds[];
|
|
118
|
-
} & (InfiniteSearchRequest | PaginatedSearchRequest);
|
|
119
|
-
|
|
120
|
-
export type GlobalSearchResult = {
|
|
121
|
-
businessEntityId: BusinessEntityIds;
|
|
122
|
-
recordId: string;
|
|
123
|
-
title: string;
|
|
124
|
-
description: string;
|
|
125
|
-
tags?: string[];
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export type GlobalSearchByIdRequest = {
|
|
129
|
-
ids: {
|
|
130
|
-
businessEntityId: BusinessEntityIds;
|
|
131
|
-
recordId: string;
|
|
132
|
-
}[];
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export type PublicSearchRequest = {
|
|
136
|
-
limit: number;
|
|
137
|
-
offset?: number;
|
|
138
|
-
query?: ComplexFilter;
|
|
139
|
-
sortBy?: SortFilter[];
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
///////////////////////////////////////////////////////
|
|
143
|
-
// Aggregations
|
|
144
|
-
///////////////////////////////////////////////////////
|
|
145
|
-
|
|
146
|
-
export type AggFilterOperator =
|
|
147
|
-
| ElasticsearchOperator.is
|
|
148
|
-
| ElasticsearchOperator.greaterThan
|
|
149
|
-
| ElasticsearchOperator.lessThan
|
|
150
|
-
| ElasticsearchOperator.greaterThanOrEqual
|
|
151
|
-
| ElasticsearchOperator.lessThanEqual;
|
|
152
|
-
|
|
153
|
-
export enum AggregationType {
|
|
154
|
-
term = 'TERM',
|
|
155
|
-
range = 'RANGE',
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export type TermAggregation = {
|
|
159
|
-
titles: MultiLangValue & { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string };
|
|
160
|
-
fieldId: string;
|
|
161
|
-
type: AggregationType.term;
|
|
162
|
-
|
|
163
|
-
orderBy?: 'count' | 'field';
|
|
164
|
-
} & (
|
|
165
|
-
| {
|
|
166
|
-
fieldType: FieldTypes.picklist;
|
|
167
|
-
picklistId: string;
|
|
168
|
-
}
|
|
169
|
-
| {
|
|
170
|
-
fieldType: FieldTypes.number;
|
|
171
|
-
meta?: NumberMeta;
|
|
172
|
-
}
|
|
173
|
-
| {
|
|
174
|
-
fieldType: Exclude<FieldTypes, FieldTypes.picklist | FieldTypes.number>;
|
|
175
|
-
}
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
export type Range =
|
|
179
|
-
| {
|
|
180
|
-
start: number;
|
|
181
|
-
end?: number;
|
|
182
|
-
}
|
|
183
|
-
| {
|
|
184
|
-
start?: number;
|
|
185
|
-
end: number;
|
|
186
|
-
}
|
|
187
|
-
| {
|
|
188
|
-
start: number;
|
|
189
|
-
end: number;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export type RangeAggregation = {
|
|
193
|
-
titles: MultiLangValue & { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string };
|
|
194
|
-
fieldId: string;
|
|
195
|
-
type: AggregationType.range;
|
|
196
|
-
step: number;
|
|
197
|
-
ranges: Range[];
|
|
198
|
-
format?: NumberMeta;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export type Aggregation = TermAggregation | RangeAggregation;
|
|
202
|
-
|
|
203
|
-
export type AggregationRequest = {
|
|
204
|
-
fullText?: string;
|
|
205
|
-
filters: ComplexFilter<AggFilterOperator>[];
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export type AggregationResult = {
|
|
209
|
-
value: string;
|
|
210
|
-
count: number;
|
|
211
|
-
from?: number;
|
|
212
|
-
to?: number;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
export type AggregationResultSet = {
|
|
216
|
-
[field: string]: AggregationResult[];
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export type AggregationResponse<M = {}> = {
|
|
220
|
-
results: AggregationResultSet;
|
|
221
|
-
meta: M;
|
|
222
|
-
};
|
|
1
|
+
export * from '@bisondesk/commons-sdk/search';
|
package/src/types/utils.ts
CHANGED
|
@@ -1,52 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { AdHocPicklistValueDisplay } from './picklists.js';
|
|
3
|
-
|
|
4
|
-
export type CountryInfo = {
|
|
5
|
-
code: string; // code is ISO 3166-1 alpha-2
|
|
6
|
-
name: string;
|
|
7
|
-
labels: {
|
|
8
|
-
city: string;
|
|
9
|
-
state: string;
|
|
10
|
-
postalCode?: string;
|
|
11
|
-
};
|
|
12
|
-
required: {
|
|
13
|
-
city: boolean;
|
|
14
|
-
state: boolean;
|
|
15
|
-
postalCode: boolean;
|
|
16
|
-
};
|
|
17
|
-
dialCode: number;
|
|
18
|
-
currencyCode: string;
|
|
19
|
-
states?: {
|
|
20
|
-
[code: string]: string; // code is ISO 3166-2
|
|
21
|
-
};
|
|
22
|
-
postalCodeFormat?: string;
|
|
23
|
-
postalCodeEx?: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type Country = {
|
|
27
|
-
code: string;
|
|
28
|
-
name: string;
|
|
29
|
-
dialCode: number;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ReferenceData = {
|
|
33
|
-
recordTitles: AdHocRecordTitles;
|
|
34
|
-
picklistTitles: AdHocPicklistValueDisplay;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type AdHocRecordTitles = {
|
|
38
|
-
[businessEntityId: string]: {
|
|
39
|
-
[recordId: string]: string | MultiLangValue;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type DataRecord<T, M = undefined> = {
|
|
44
|
-
record: T;
|
|
45
|
-
meta?: M; // typically ReferenceData
|
|
46
|
-
actions: string[];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export enum PricePercentageMode {
|
|
50
|
-
CURRENCY = 'currency',
|
|
51
|
-
PERCENTAGE = 'percentage',
|
|
52
|
-
}
|
|
1
|
+
export * from '@bisondesk/commons-sdk/utils';
|
package/src/utils/search.ts
CHANGED
|
@@ -54,6 +54,8 @@ export const mappings: {
|
|
|
54
54
|
getMainEntity: (entity: SearchVehicle) => entity.vehicle,
|
|
55
55
|
getTitle: (vehicle: Vehicle) => vehicle.internal.description.title,
|
|
56
56
|
getTags: (vehicle: Vehicle) => [
|
|
57
|
+
// the order of the tags here is relevant for exact integration
|
|
58
|
+
// see: packages/exact/src/service/purchase.ts
|
|
57
59
|
vehicle.external.identification?.stockNumber,
|
|
58
60
|
vehicle.internal.identification?.administrativeNumber,
|
|
59
61
|
vehicle.external.identification?.vin,
|