@bisondesk/core-sdk 1.0.331 → 1.0.333
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/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/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/picklists.ts +1 -95
- package/src/types/search.ts +1 -222
- package/src/types/utils.ts +1 -52
- package/tsconfig.deploy.tsbuildinfo +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/lib/types/search.d.ts
CHANGED
|
@@ -1,176 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { MultiLangValue } from '@bisondesk/commons-sdk/types';
|
|
3
|
-
import { FieldTypes, NumberMeta } from './fields.js';
|
|
4
|
-
export declare enum ConditionType {
|
|
5
|
-
and = "AND",
|
|
6
|
-
or = "OR"
|
|
7
|
-
}
|
|
8
|
-
export declare enum ElasticsearchOperator {
|
|
9
|
-
empty = "EMPTY",
|
|
10
|
-
notEmpty = "NOT_EMPTY",
|
|
11
|
-
is = "IS",
|
|
12
|
-
isNot = "IS_NOT",
|
|
13
|
-
greaterThanOrEqual = "GTE",
|
|
14
|
-
greaterThan = "GT",
|
|
15
|
-
lessThanEqual = "LTE",
|
|
16
|
-
lessThan = "LT",
|
|
17
|
-
between = "BETWEEN",
|
|
18
|
-
contains = "CONTAINS",
|
|
19
|
-
notContains = "NOT_CONTAINS",
|
|
20
|
-
startsWith = "STARTS_WITH",
|
|
21
|
-
endsWith = "ENDS_WITH"
|
|
22
|
-
}
|
|
23
|
-
export type Filter<OP = ElasticsearchOperator> = {
|
|
24
|
-
data: string;
|
|
25
|
-
fieldId: string;
|
|
26
|
-
operator: OP;
|
|
27
|
-
};
|
|
28
|
-
export type ComplexFilter<OP = ElasticsearchOperator> = {
|
|
29
|
-
condition: ConditionType;
|
|
30
|
-
filters: Array<Filter<OP> | ComplexFilter<OP>>;
|
|
31
|
-
};
|
|
32
|
-
export type SearchResponse<T = any> = {
|
|
33
|
-
took: number;
|
|
34
|
-
timed_out: boolean;
|
|
35
|
-
_scroll_id?: string;
|
|
36
|
-
_shards: unknown;
|
|
37
|
-
hits: {
|
|
38
|
-
total: {
|
|
39
|
-
value: number;
|
|
40
|
-
relation: 'eq' | 'gte';
|
|
41
|
-
};
|
|
42
|
-
max_score: number;
|
|
43
|
-
hits: Array<{
|
|
44
|
-
_index: string;
|
|
45
|
-
_type: string;
|
|
46
|
-
_id: string;
|
|
47
|
-
_score: number;
|
|
48
|
-
_source?: T;
|
|
49
|
-
_version?: number;
|
|
50
|
-
_explanation?: unknown;
|
|
51
|
-
fields?: any;
|
|
52
|
-
highlight?: any;
|
|
53
|
-
inner_hits?: any;
|
|
54
|
-
matched_queries?: string[];
|
|
55
|
-
sort?: Array<string | number>;
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
aggregations?: {
|
|
59
|
-
[aggName: string]: object;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export declare const FILTER_RANGE_SEPARATOR = "__";
|
|
63
|
-
export declare enum SortOrder {
|
|
64
|
-
asc = "asc",
|
|
65
|
-
desc = "desc"
|
|
66
|
-
}
|
|
67
|
-
export type SortFilter = {
|
|
68
|
-
fieldId: string;
|
|
69
|
-
order: SortOrder;
|
|
70
|
-
};
|
|
71
|
-
export type BaseSearchRequest = {
|
|
72
|
-
fullText?: string;
|
|
73
|
-
limit: number;
|
|
74
|
-
query?: ComplexFilter<ElasticsearchOperator>;
|
|
75
|
-
sortBy?: SortFilter[];
|
|
76
|
-
};
|
|
77
|
-
type InfiniteSearchRequest = {
|
|
78
|
-
infinite: true;
|
|
79
|
-
nextToken?: string;
|
|
80
|
-
};
|
|
81
|
-
type PaginatedSearchRequest = {
|
|
82
|
-
infinite?: false;
|
|
83
|
-
offset?: number;
|
|
84
|
-
};
|
|
85
|
-
export type SearchRequest = {
|
|
86
|
-
fullText?: string;
|
|
87
|
-
limit: number;
|
|
88
|
-
query?: ComplexFilter<ElasticsearchOperator>;
|
|
89
|
-
sortBy?: SortFilter[];
|
|
90
|
-
} & (InfiniteSearchRequest | PaginatedSearchRequest);
|
|
91
|
-
export type GlobalSearchRequest = {
|
|
92
|
-
fullText: string;
|
|
93
|
-
limit: number;
|
|
94
|
-
} & {
|
|
95
|
-
entityIds: BusinessEntityIds[];
|
|
96
|
-
} & (InfiniteSearchRequest | PaginatedSearchRequest);
|
|
97
|
-
export type GlobalSearchResult = {
|
|
98
|
-
businessEntityId: BusinessEntityIds;
|
|
99
|
-
recordId: string;
|
|
100
|
-
title: string;
|
|
101
|
-
description: string;
|
|
102
|
-
tags?: string[];
|
|
103
|
-
};
|
|
104
|
-
export type GlobalSearchByIdRequest = {
|
|
105
|
-
ids: {
|
|
106
|
-
businessEntityId: BusinessEntityIds;
|
|
107
|
-
recordId: string;
|
|
108
|
-
}[];
|
|
109
|
-
};
|
|
110
|
-
export type PublicSearchRequest = {
|
|
111
|
-
limit: number;
|
|
112
|
-
offset?: number;
|
|
113
|
-
query?: ComplexFilter;
|
|
114
|
-
sortBy?: SortFilter[];
|
|
115
|
-
};
|
|
116
|
-
export type AggFilterOperator = ElasticsearchOperator.is | ElasticsearchOperator.greaterThan | ElasticsearchOperator.lessThan | ElasticsearchOperator.greaterThanOrEqual | ElasticsearchOperator.lessThanEqual;
|
|
117
|
-
export declare enum AggregationType {
|
|
118
|
-
term = "TERM",
|
|
119
|
-
range = "RANGE"
|
|
120
|
-
}
|
|
121
|
-
export type TermAggregation = {
|
|
122
|
-
titles: MultiLangValue & {
|
|
123
|
-
[local in (typeof SUPPORTED_LANGUAGES)[number]]: string;
|
|
124
|
-
};
|
|
125
|
-
fieldId: string;
|
|
126
|
-
type: AggregationType.term;
|
|
127
|
-
orderBy?: 'count' | 'field';
|
|
128
|
-
} & ({
|
|
129
|
-
fieldType: FieldTypes.picklist;
|
|
130
|
-
picklistId: string;
|
|
131
|
-
} | {
|
|
132
|
-
fieldType: FieldTypes.number;
|
|
133
|
-
meta?: NumberMeta;
|
|
134
|
-
} | {
|
|
135
|
-
fieldType: Exclude<FieldTypes, FieldTypes.picklist | FieldTypes.number>;
|
|
136
|
-
});
|
|
137
|
-
export type Range = {
|
|
138
|
-
start: number;
|
|
139
|
-
end?: number;
|
|
140
|
-
} | {
|
|
141
|
-
start?: number;
|
|
142
|
-
end: number;
|
|
143
|
-
} | {
|
|
144
|
-
start: number;
|
|
145
|
-
end: number;
|
|
146
|
-
};
|
|
147
|
-
export type RangeAggregation = {
|
|
148
|
-
titles: MultiLangValue & {
|
|
149
|
-
[local in (typeof SUPPORTED_LANGUAGES)[number]]: string;
|
|
150
|
-
};
|
|
151
|
-
fieldId: string;
|
|
152
|
-
type: AggregationType.range;
|
|
153
|
-
step: number;
|
|
154
|
-
ranges: Range[];
|
|
155
|
-
format?: NumberMeta;
|
|
156
|
-
};
|
|
157
|
-
export type Aggregation = TermAggregation | RangeAggregation;
|
|
158
|
-
export type AggregationRequest = {
|
|
159
|
-
fullText?: string;
|
|
160
|
-
filters: ComplexFilter<AggFilterOperator>[];
|
|
161
|
-
};
|
|
162
|
-
export type AggregationResult = {
|
|
163
|
-
value: string;
|
|
164
|
-
count: number;
|
|
165
|
-
from?: number;
|
|
166
|
-
to?: number;
|
|
167
|
-
};
|
|
168
|
-
export type AggregationResultSet = {
|
|
169
|
-
[field: string]: AggregationResult[];
|
|
170
|
-
};
|
|
171
|
-
export type AggregationResponse<M = {}> = {
|
|
172
|
-
results: AggregationResultSet;
|
|
173
|
-
meta: M;
|
|
174
|
-
};
|
|
175
|
-
export {};
|
|
1
|
+
export * from '@bisondesk/commons-sdk/search';
|
|
176
2
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC"}
|
package/lib/types/search.js
CHANGED
|
@@ -1,33 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
(function (ConditionType) {
|
|
3
|
-
ConditionType["and"] = "AND";
|
|
4
|
-
ConditionType["or"] = "OR";
|
|
5
|
-
})(ConditionType || (ConditionType = {}));
|
|
6
|
-
export var ElasticsearchOperator;
|
|
7
|
-
(function (ElasticsearchOperator) {
|
|
8
|
-
ElasticsearchOperator["empty"] = "EMPTY";
|
|
9
|
-
ElasticsearchOperator["notEmpty"] = "NOT_EMPTY";
|
|
10
|
-
ElasticsearchOperator["is"] = "IS";
|
|
11
|
-
ElasticsearchOperator["isNot"] = "IS_NOT";
|
|
12
|
-
ElasticsearchOperator["greaterThanOrEqual"] = "GTE";
|
|
13
|
-
ElasticsearchOperator["greaterThan"] = "GT";
|
|
14
|
-
ElasticsearchOperator["lessThanEqual"] = "LTE";
|
|
15
|
-
ElasticsearchOperator["lessThan"] = "LT";
|
|
16
|
-
ElasticsearchOperator["between"] = "BETWEEN";
|
|
17
|
-
ElasticsearchOperator["contains"] = "CONTAINS";
|
|
18
|
-
ElasticsearchOperator["notContains"] = "NOT_CONTAINS";
|
|
19
|
-
ElasticsearchOperator["startsWith"] = "STARTS_WITH";
|
|
20
|
-
ElasticsearchOperator["endsWith"] = "ENDS_WITH";
|
|
21
|
-
})(ElasticsearchOperator || (ElasticsearchOperator = {}));
|
|
22
|
-
export const FILTER_RANGE_SEPARATOR = '__';
|
|
23
|
-
export var SortOrder;
|
|
24
|
-
(function (SortOrder) {
|
|
25
|
-
SortOrder["asc"] = "asc";
|
|
26
|
-
SortOrder["desc"] = "desc";
|
|
27
|
-
})(SortOrder || (SortOrder = {}));
|
|
28
|
-
export var AggregationType;
|
|
29
|
-
(function (AggregationType) {
|
|
30
|
-
AggregationType["term"] = "TERM";
|
|
31
|
-
AggregationType["range"] = "RANGE";
|
|
32
|
-
})(AggregationType || (AggregationType = {}));
|
|
1
|
+
export * from '@bisondesk/commons-sdk/search';
|
|
33
2
|
//# sourceMappingURL=search.js.map
|
package/lib/types/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"/","sources":["types/search.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC","sourcesContent":["export * from '@bisondesk/commons-sdk/search';\n"]}
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { AdHocPicklistValueDisplay } from './picklists.js';
|
|
3
|
-
export type CountryInfo = {
|
|
4
|
-
code: string;
|
|
5
|
-
name: string;
|
|
6
|
-
labels: {
|
|
7
|
-
city: string;
|
|
8
|
-
state: string;
|
|
9
|
-
postalCode?: string;
|
|
10
|
-
};
|
|
11
|
-
required: {
|
|
12
|
-
city: boolean;
|
|
13
|
-
state: boolean;
|
|
14
|
-
postalCode: boolean;
|
|
15
|
-
};
|
|
16
|
-
dialCode: number;
|
|
17
|
-
currencyCode: string;
|
|
18
|
-
states?: {
|
|
19
|
-
[code: string]: string;
|
|
20
|
-
};
|
|
21
|
-
postalCodeFormat?: string;
|
|
22
|
-
postalCodeEx?: string;
|
|
23
|
-
};
|
|
24
|
-
export type Country = {
|
|
25
|
-
code: string;
|
|
26
|
-
name: string;
|
|
27
|
-
dialCode: number;
|
|
28
|
-
};
|
|
29
|
-
export type ReferenceData = {
|
|
30
|
-
recordTitles: AdHocRecordTitles;
|
|
31
|
-
picklistTitles: AdHocPicklistValueDisplay;
|
|
32
|
-
};
|
|
33
|
-
export type AdHocRecordTitles = {
|
|
34
|
-
[businessEntityId: string]: {
|
|
35
|
-
[recordId: string]: string | MultiLangValue;
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export type DataRecord<T, M = undefined> = {
|
|
39
|
-
record: T;
|
|
40
|
-
meta?: M;
|
|
41
|
-
actions: string[];
|
|
42
|
-
};
|
|
43
|
-
export declare enum PricePercentageMode {
|
|
44
|
-
CURRENCY = "currency",
|
|
45
|
-
PERCENTAGE = "percentage"
|
|
46
|
-
}
|
|
1
|
+
export * from '@bisondesk/commons-sdk/utils';
|
|
47
2
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/types/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"/","sources":["types/utils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"/","sources":["types/utils.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
package/lib/types/utils.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
(function (PricePercentageMode) {
|
|
3
|
-
PricePercentageMode["CURRENCY"] = "currency";
|
|
4
|
-
PricePercentageMode["PERCENTAGE"] = "percentage";
|
|
5
|
-
})(PricePercentageMode || (PricePercentageMode = {}));
|
|
1
|
+
export * from '@bisondesk/commons-sdk/utils';
|
|
6
2
|
//# sourceMappingURL=utils.js.map
|
package/lib/types/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"/","sources":["types/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"/","sources":["types/utils.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC","sourcesContent":["export * from '@bisondesk/commons-sdk/utils';\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/constants';
|
|
2
|
+
import { XError } from '@bisondesk/commons-sdk/errors';
|
|
3
|
+
import { getAdminAuth } from '@bisondesk/commons-sdk/fetch';
|
|
4
|
+
import { PaginatedList } from '@bisondesk/commons-sdk/types';
|
|
5
|
+
import { SearchDebtorInfo } from '../types/leasing-debtors.js';
|
|
6
|
+
import { SearchRequest } from '../types/search.js';
|
|
7
|
+
import { ReferenceData } from '../types/utils.js';
|
|
8
|
+
|
|
9
|
+
export const searchDebtorsInfo = async (
|
|
10
|
+
tenantId: string,
|
|
11
|
+
request: SearchRequest
|
|
12
|
+
): Promise<PaginatedList<SearchDebtorInfo, ReferenceData> | undefined> => {
|
|
13
|
+
const auth = await getAdminAuth();
|
|
14
|
+
const response: Response = await fetch(
|
|
15
|
+
`${process.env.CORE_API_ORIGIN}/api/leasing/debtors/search/results`,
|
|
16
|
+
{
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: auth,
|
|
20
|
+
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
21
|
+
},
|
|
22
|
+
body: JSON.stringify(request),
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
if (response.status === 200) {
|
|
27
|
+
return response.json() as any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const body = await response.text();
|
|
31
|
+
throw new XError('core-sdk.search-debtors-info', {
|
|
32
|
+
tenantId,
|
|
33
|
+
request,
|
|
34
|
+
response: body,
|
|
35
|
+
status: response.status,
|
|
36
|
+
});
|
|
37
|
+
};
|
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';
|