@bisondesk/commons-sdk 1.0.331 → 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.
@@ -0,0 +1,221 @@
1
+ import { BusinessEntityIds, SUPPORTED_LANGUAGES } from './constants.js';
2
+ import { FieldTypes, NumberMeta } from './fields.js';
3
+ import { MultiLangValue } from './types.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 declare enum ElasticsearchGeoOperator {
29
+ boundingBox = "geo_bounding_box",
30
+ distance = "geo_distance",
31
+ polygon = "geo_polygon"
32
+ }
33
+ type ElasticSearchCoordinates = {
34
+ lat: number;
35
+ lon: number;
36
+ } | [lat: number, lon: number] | string;
37
+ type BoundingBoxCoordinates = {
38
+ top_left: ElasticSearchCoordinates;
39
+ bottom_right: ElasticSearchCoordinates;
40
+ };
41
+ type BoundingBoxWKT = {
42
+ wkt: `BBOX (${number}, ${number}, ${number}, ${number})`;
43
+ };
44
+ type BoundingBoxVertices = {
45
+ top: number;
46
+ left: number;
47
+ bottom: number;
48
+ right: number;
49
+ };
50
+ type GeoDistanceUnit = 'mi' | 'yd' | 'ft' | 'in' | 'km' | 'm' | 'cm' | 'mm' | 'nmi';
51
+ type GeoBoundingBoxFilter = {
52
+ operator: ElasticsearchGeoOperator.boundingBox;
53
+ data: BoundingBoxCoordinates | BoundingBoxWKT | BoundingBoxVertices;
54
+ };
55
+ type GeoDistanceFilter = {
56
+ operator: ElasticsearchGeoOperator.distance;
57
+ data: {
58
+ distance: `${number}${GeoDistanceUnit}`;
59
+ coords: ElasticSearchCoordinates;
60
+ };
61
+ };
62
+ type GeoPolygonFilter = {
63
+ operator: ElasticsearchGeoOperator.polygon;
64
+ data: {
65
+ points: ElasticSearchCoordinates[];
66
+ };
67
+ };
68
+ export type GeoFilter = {
69
+ fieldId: string;
70
+ } & (GeoBoundingBoxFilter | GeoDistanceFilter | GeoPolygonFilter);
71
+ export type ComplexFilter<OP = ElasticsearchOperator> = {
72
+ condition: ConditionType;
73
+ filters: Array<Filter<OP> | ComplexFilter<OP>>;
74
+ };
75
+ export type SearchResponse<T = any> = {
76
+ took: number;
77
+ timed_out: boolean;
78
+ _scroll_id?: string;
79
+ _shards: unknown;
80
+ hits: {
81
+ total: {
82
+ value: number;
83
+ relation: 'eq' | 'gte';
84
+ };
85
+ max_score: number;
86
+ hits: Array<{
87
+ _index: string;
88
+ _type: string;
89
+ _id: string;
90
+ _score: number;
91
+ _source?: T;
92
+ _version?: number;
93
+ _explanation?: unknown;
94
+ fields?: any;
95
+ highlight?: any;
96
+ inner_hits?: any;
97
+ matched_queries?: string[];
98
+ sort?: Array<string | number>;
99
+ }>;
100
+ };
101
+ aggregations?: {
102
+ [aggName: string]: object;
103
+ };
104
+ };
105
+ export declare const FILTER_RANGE_SEPARATOR = "__";
106
+ export declare enum SortOrder {
107
+ asc = "asc",
108
+ desc = "desc"
109
+ }
110
+ export type SortFilter = {
111
+ fieldId: string;
112
+ order: SortOrder;
113
+ };
114
+ export type BaseSearchRequest = {
115
+ fullText?: string;
116
+ limit: number;
117
+ query?: ComplexFilter<ElasticsearchOperator>;
118
+ sortBy?: SortFilter[];
119
+ };
120
+ type InfiniteSearchRequest = {
121
+ infinite: true;
122
+ nextToken?: string;
123
+ };
124
+ type PaginatedSearchRequest = {
125
+ infinite?: false;
126
+ offset?: number;
127
+ };
128
+ export type SearchRequest = {
129
+ fullText?: string;
130
+ limit: number;
131
+ query?: ComplexFilter<ElasticsearchOperator>;
132
+ geoFilters?: GeoFilter[];
133
+ sortBy?: SortFilter[];
134
+ } & (InfiniteSearchRequest | PaginatedSearchRequest);
135
+ export type GlobalSearchRequest = {
136
+ fullText: string;
137
+ limit: number;
138
+ } & {
139
+ entityIds: BusinessEntityIds[];
140
+ } & (InfiniteSearchRequest | PaginatedSearchRequest);
141
+ export type GlobalSearchResult = {
142
+ businessEntityId: BusinessEntityIds;
143
+ recordId: string;
144
+ title: string;
145
+ description: string;
146
+ tags?: string[];
147
+ };
148
+ export type GlobalSearchByIdRequest = {
149
+ ids: {
150
+ businessEntityId: BusinessEntityIds;
151
+ recordId: string;
152
+ }[];
153
+ };
154
+ export type PublicSearchRequest = {
155
+ limit: number;
156
+ offset?: number;
157
+ query?: ComplexFilter;
158
+ sortBy?: SortFilter[];
159
+ };
160
+ export type AggFilterOperator = ElasticsearchOperator.is | ElasticsearchOperator.greaterThan | ElasticsearchOperator.lessThan | ElasticsearchOperator.greaterThanOrEqual | ElasticsearchOperator.lessThanEqual;
161
+ export declare enum AggregationType {
162
+ term = "TERM",
163
+ range = "RANGE"
164
+ }
165
+ export type TermAggregation = {
166
+ titles: MultiLangValue & {
167
+ [local in (typeof SUPPORTED_LANGUAGES)[number]]: string;
168
+ };
169
+ fieldId: string;
170
+ type: AggregationType.term;
171
+ orderBy?: 'count' | 'field';
172
+ } & ({
173
+ fieldType: FieldTypes.picklist;
174
+ picklistId: string;
175
+ } | {
176
+ fieldType: FieldTypes.number;
177
+ meta?: NumberMeta;
178
+ } | {
179
+ fieldType: Exclude<FieldTypes, FieldTypes.picklist | FieldTypes.number>;
180
+ });
181
+ export type Range = {
182
+ start: number;
183
+ end?: number;
184
+ } | {
185
+ start?: number;
186
+ end: number;
187
+ } | {
188
+ start: number;
189
+ end: number;
190
+ };
191
+ export type RangeAggregation = {
192
+ titles: MultiLangValue & {
193
+ [local in (typeof SUPPORTED_LANGUAGES)[number]]: string;
194
+ };
195
+ fieldId: string;
196
+ type: AggregationType.range;
197
+ step: number;
198
+ ranges: Range[];
199
+ format?: NumberMeta;
200
+ };
201
+ export type Aggregation = TermAggregation | RangeAggregation;
202
+ export type AggregationRequest = {
203
+ fullText?: string;
204
+ filters: ComplexFilter<AggFilterOperator>[];
205
+ geoFilters?: GeoFilter[];
206
+ };
207
+ export type AggregationResult = {
208
+ value: string;
209
+ count: number;
210
+ from?: number;
211
+ to?: number;
212
+ };
213
+ export type AggregationResultSet = {
214
+ [field: string]: AggregationResult[];
215
+ };
216
+ export type AggregationResponse<M = {}> = {
217
+ results: AggregationResultSet;
218
+ meta: M;
219
+ };
220
+ export {};
221
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"/","sources":["search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,EAAE,OAAO;CACV;AAED,oBAAY,qBAAqB;IAE/B,KAAK,UAAU;IACf,QAAQ,cAAc;IACtB,EAAE,OAAO;IACT,KAAK,WAAW;IAEhB,kBAAkB,QAAQ;IAC1B,WAAW,OAAO;IAClB,aAAa,QAAQ;IACrB,QAAQ,OAAO;IACf,OAAO,YAAY;IAEnB,QAAQ,aAAa;IACrB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;CACvB;AAED,MAAM,MAAM,MAAM,CAAC,EAAE,GAAG,qBAAqB,IAAI;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,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AI;IACxC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,IAAI,EAAE,CAAC,CAAC;CACT,CAAC"}
package/lib/search.js ADDED
@@ -0,0 +1,39 @@
1
+ export var ConditionType;
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 var ElasticsearchGeoOperator;
23
+ (function (ElasticsearchGeoOperator) {
24
+ ElasticsearchGeoOperator["boundingBox"] = "geo_bounding_box";
25
+ ElasticsearchGeoOperator["distance"] = "geo_distance";
26
+ ElasticsearchGeoOperator["polygon"] = "geo_polygon";
27
+ })(ElasticsearchGeoOperator || (ElasticsearchGeoOperator = {}));
28
+ export const FILTER_RANGE_SEPARATOR = '__';
29
+ export var SortOrder;
30
+ (function (SortOrder) {
31
+ SortOrder["asc"] = "asc";
32
+ SortOrder["desc"] = "desc";
33
+ })(SortOrder || (SortOrder = {}));
34
+ export var AggregationType;
35
+ (function (AggregationType) {
36
+ AggregationType["term"] = "TERM";
37
+ AggregationType["range"] = "RANGE";
38
+ })(AggregationType || (AggregationType = {}));
39
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"/","sources":["search.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,0BAAS,CAAA;AACX,CAAC,EAHW,aAAa,KAAb,aAAa,QAGxB;AAED,MAAM,CAAN,IAAY,qBAiBX;AAjBD,WAAY,qBAAqB;IAE/B,wCAAe,CAAA;IACf,+CAAsB,CAAA;IACtB,kCAAS,CAAA;IACT,yCAAgB,CAAA;IAEhB,mDAA0B,CAAA;IAC1B,2CAAkB,CAAA;IAClB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,4CAAmB,CAAA;IAEnB,8CAAqB,CAAA;IACrB,qDAA4B,CAAA;IAC5B,mDAA0B,CAAA;IAC1B,+CAAsB,CAAA;AACxB,CAAC,EAjBW,qBAAqB,KAArB,qBAAqB,QAiBhC;AAQD,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAClC,4DAAgC,CAAA;IAChC,qDAAyB,CAAA;IACzB,mDAAuB,CAAA;AACzB,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC;AA4FD,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,wBAAW,CAAA;IACX,0BAAa,CAAA;AACf,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAwED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B","sourcesContent":["import { BusinessEntityIds, SUPPORTED_LANGUAGES } from './constants.js';\nimport { FieldTypes, NumberMeta } from './fields.js';\nimport { MultiLangValue } from './types.js';\n\nexport enum ConditionType {\n and = 'AND',\n or = 'OR',\n}\n\nexport enum ElasticsearchOperator {\n // all properties\n empty = 'EMPTY',\n notEmpty = 'NOT_EMPTY',\n is = 'IS',\n isNot = 'IS_NOT',\n // number, date properties\n greaterThanOrEqual = 'GTE',\n greaterThan = 'GT',\n lessThanEqual = 'LTE',\n lessThan = 'LT',\n between = 'BETWEEN',\n // string properties\n contains = 'CONTAINS',\n notContains = 'NOT_CONTAINS',\n startsWith = 'STARTS_WITH',\n endsWith = 'ENDS_WITH',\n}\n\nexport type Filter<OP = ElasticsearchOperator> = {\n data: string;\n fieldId: string;\n operator: OP;\n};\n\nexport enum ElasticsearchGeoOperator {\n boundingBox = 'geo_bounding_box',\n distance = 'geo_distance',\n polygon = 'geo_polygon',\n}\n\ntype ElasticSearchCoordinates =\n | {\n lat: number;\n lon: number;\n }\n | [lat: number, lon: number]\n | string;\n\ntype BoundingBoxCoordinates = {\n top_left: ElasticSearchCoordinates;\n bottom_right: ElasticSearchCoordinates;\n};\n\ntype BoundingBoxWKT = {\n wkt: `BBOX (${number}, ${number}, ${number}, ${number})`;\n};\n\ntype BoundingBoxVertices = {\n top: number;\n left: number;\n bottom: number;\n right: number;\n};\n\ntype GeoDistanceUnit = 'mi' | 'yd' | 'ft' | 'in' | 'km' | 'm' | 'cm' | 'mm' | 'nmi';\n\ntype GeoBoundingBoxFilter = {\n operator: ElasticsearchGeoOperator.boundingBox;\n data: BoundingBoxCoordinates | BoundingBoxWKT | BoundingBoxVertices;\n};\n\ntype GeoDistanceFilter = {\n operator: ElasticsearchGeoOperator.distance;\n data: {\n distance: `${number}${GeoDistanceUnit}`;\n coords: ElasticSearchCoordinates;\n };\n};\n\ntype GeoPolygonFilter = {\n operator: ElasticsearchGeoOperator.polygon;\n data: {\n points: ElasticSearchCoordinates[];\n };\n};\n\nexport type GeoFilter = { fieldId: string } & (\n | GeoBoundingBoxFilter\n | GeoDistanceFilter\n | GeoPolygonFilter\n);\n\nexport type ComplexFilter<OP = ElasticsearchOperator> = {\n condition: ConditionType;\n filters: Array<Filter<OP> | ComplexFilter<OP>>;\n};\n\nexport type SearchResponse<T = any> = {\n took: number;\n timed_out: boolean;\n _scroll_id?: string;\n _shards: unknown;\n hits: {\n total: {\n value: number;\n relation: 'eq' | 'gte';\n };\n max_score: number;\n hits: Array<{\n _index: string;\n _type: string;\n _id: string;\n _score: number;\n _source?: T;\n _version?: number;\n _explanation?: unknown;\n fields?: any;\n highlight?: any;\n inner_hits?: any;\n matched_queries?: string[];\n sort?: Array<string | number>;\n }>;\n };\n aggregations?: { [aggName: string]: object };\n};\n\n///////////////////////////////////////////////////////\n// Search\n///////////////////////////////////////////////////////\n\nexport const FILTER_RANGE_SEPARATOR = '__';\n\nexport enum SortOrder {\n asc = 'asc',\n desc = 'desc',\n}\n\nexport type SortFilter = {\n fieldId: string;\n order: SortOrder;\n};\n\nexport type BaseSearchRequest = {\n fullText?: string;\n limit: number;\n query?: ComplexFilter<ElasticsearchOperator>;\n sortBy?: SortFilter[];\n};\n\ntype InfiniteSearchRequest = {\n infinite: true;\n nextToken?: string;\n};\n\ntype PaginatedSearchRequest = {\n infinite?: false;\n offset?: number;\n};\n\nexport type SearchRequest = {\n fullText?: string;\n limit: number;\n query?: ComplexFilter<ElasticsearchOperator>;\n geoFilters?: GeoFilter[];\n sortBy?: SortFilter[];\n} & (InfiniteSearchRequest | PaginatedSearchRequest);\n\nexport type GlobalSearchRequest = {\n fullText: string;\n limit: number;\n} & {\n entityIds: BusinessEntityIds[];\n} & (InfiniteSearchRequest | PaginatedSearchRequest);\n\nexport type GlobalSearchResult = {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n title: string;\n description: string;\n tags?: string[];\n};\n\nexport type GlobalSearchByIdRequest = {\n ids: {\n businessEntityId: BusinessEntityIds;\n recordId: string;\n }[];\n};\n\nexport type PublicSearchRequest = {\n limit: number;\n offset?: number;\n query?: ComplexFilter;\n sortBy?: SortFilter[];\n};\n\n///////////////////////////////////////////////////////\n// Aggregations\n///////////////////////////////////////////////////////\n\nexport type AggFilterOperator =\n | ElasticsearchOperator.is\n | ElasticsearchOperator.greaterThan\n | ElasticsearchOperator.lessThan\n | ElasticsearchOperator.greaterThanOrEqual\n | ElasticsearchOperator.lessThanEqual;\n\nexport enum AggregationType {\n term = 'TERM',\n range = 'RANGE',\n}\n\nexport type TermAggregation = {\n titles: MultiLangValue & { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string };\n fieldId: string;\n type: AggregationType.term;\n\n orderBy?: 'count' | 'field';\n} & (\n | {\n fieldType: FieldTypes.picklist;\n picklistId: string;\n }\n | {\n fieldType: FieldTypes.number;\n meta?: NumberMeta;\n }\n | {\n fieldType: Exclude<FieldTypes, FieldTypes.picklist | FieldTypes.number>;\n }\n);\n\nexport type Range =\n | {\n start: number;\n end?: number;\n }\n | {\n start?: number;\n end: number;\n }\n | {\n start: number;\n end: number;\n };\n\nexport type RangeAggregation = {\n titles: MultiLangValue & { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string };\n fieldId: string;\n type: AggregationType.range;\n step: number;\n ranges: Range[];\n format?: NumberMeta;\n};\n\nexport type Aggregation = TermAggregation | RangeAggregation;\n\nexport type AggregationRequest = {\n fullText?: string;\n filters: ComplexFilter<AggFilterOperator>[];\n geoFilters?: GeoFilter[];\n};\n\nexport type AggregationResult = {\n value: string;\n count: number;\n from?: number;\n to?: number;\n};\n\nexport type AggregationResultSet = {\n [field: string]: AggregationResult[];\n};\n\nexport type AggregationResponse<M = {}> = {\n results: AggregationResultSet;\n meta: M;\n};\n"]}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ import { AdHocPicklistValueDisplay } from './picklists.js';
2
+ import { MultiLangValue } from './types.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
+ }
47
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"/","sources":["utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE;QACR,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;QACf,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QACP,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,CAAC;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,EAAE,iBAAiB,CAAC;IAChC,cAAc,EAAE,yBAAyB,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,gBAAgB,EAAE,MAAM,GAAG;QAC1B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAAC;KAC7C,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,IAAI;IACzC,MAAM,EAAE,CAAC,CAAC;IACV,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,oBAAY,mBAAmB;IAC7B,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC1B"}
package/lib/utils.js ADDED
@@ -0,0 +1,6 @@
1
+ export var PricePercentageMode;
2
+ (function (PricePercentageMode) {
3
+ PricePercentageMode["CURRENCY"] = "currency";
4
+ PricePercentageMode["PERCENTAGE"] = "percentage";
5
+ })(PricePercentageMode || (PricePercentageMode = {}));
6
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"/","sources":["utils.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,4CAAqB,CAAA;IACrB,gDAAyB,CAAA;AAC3B,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B","sourcesContent":["import { AdHocPicklistValueDisplay } from './picklists.js';\nimport { MultiLangValue } from './types.js';\n\nexport type CountryInfo = {\n code: string; // code is ISO 3166-1 alpha-2\n name: string;\n labels: {\n city: string;\n state: string;\n postalCode?: string;\n };\n required: {\n city: boolean;\n state: boolean;\n postalCode: boolean;\n };\n dialCode: number;\n currencyCode: string;\n states?: {\n [code: string]: string; // code is ISO 3166-2\n };\n postalCodeFormat?: string;\n postalCodeEx?: string;\n};\n\nexport type Country = {\n code: string;\n name: string;\n dialCode: number;\n};\n\nexport type ReferenceData = {\n recordTitles: AdHocRecordTitles;\n picklistTitles: AdHocPicklistValueDisplay;\n};\n\nexport type AdHocRecordTitles = {\n [businessEntityId: string]: {\n [recordId: string]: string | MultiLangValue;\n };\n};\n\nexport type DataRecord<T, M = undefined> = {\n record: T;\n meta?: M; // typically ReferenceData\n actions: string[];\n};\n\nexport enum PricePercentageMode {\n CURRENCY = 'currency',\n PERCENTAGE = 'percentage',\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/commons-sdk",
3
- "version": "1.0.331",
3
+ "version": "1.0.332",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx tsc --build tsconfig.deploy.json",
@@ -0,0 +1,105 @@
1
+ import fetch, { Response } from 'node-fetch';
2
+ import { XError } from '../errors.js';
3
+ import { cleanHeaders, getAdminAuth } from '../fetch.js';
4
+ import {
5
+ AdHocPicklistRequest,
6
+ AdHocPicklistValueDisplay,
7
+ PicklistOptionsRequest,
8
+ PicklistValue,
9
+ PicklistValueRequest,
10
+ PicklistValueUpdateRequest,
11
+ } from '../picklists.js';
12
+ import { Option } from '../types.js';
13
+
14
+ export const getMultiplePicklistValues = async (
15
+ request: AdHocPicklistRequest
16
+ ): Promise<AdHocPicklistValueDisplay> => {
17
+ const auth = await getAdminAuth();
18
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {
19
+ method: 'POST',
20
+ headers: {
21
+ Authorization: auth,
22
+ 'Content-Type': 'application/json',
23
+ },
24
+ body: JSON.stringify(request),
25
+ });
26
+
27
+ if (response.ok) {
28
+ return response.json() as any;
29
+ }
30
+
31
+ const body = await response.text();
32
+ throw new XError(response.statusText, { body });
33
+ };
34
+
35
+ export const getPicklistOptions = async (req: PicklistOptionsRequest): Promise<Option[]> => {
36
+ const auth = await getAdminAuth();
37
+
38
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/options`, {
39
+ method: 'POST',
40
+ headers: cleanHeaders({
41
+ Authorization: auth,
42
+ 'Content-Type': 'application/json',
43
+ }),
44
+ body: JSON.stringify(req),
45
+ });
46
+
47
+ if (response.ok) {
48
+ return response.json() as any;
49
+ }
50
+
51
+ const body = await response.text();
52
+ throw new XError(response.statusText, { body, req });
53
+ };
54
+
55
+ export const upsertPicklistValue = async (
56
+ request: PicklistValueUpdateRequest
57
+ ): Promise<PicklistValue> => {
58
+ const auth = await getAdminAuth();
59
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/value`, {
60
+ method: 'POST',
61
+ headers: {
62
+ Authorization: auth,
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ body: JSON.stringify(request),
66
+ });
67
+
68
+ if (response.ok) {
69
+ return response.json() as any;
70
+ }
71
+
72
+ const body = await response.text();
73
+ throw new XError(response.statusText, { body });
74
+ };
75
+
76
+ export const getAdhocPicklistDisplayValue = async (
77
+ requests: PicklistValueRequest[],
78
+ preferredLang: string,
79
+ tenantLang: string
80
+ ): Promise<AdHocPicklistValueDisplay> => {
81
+ const auth = await getAdminAuth();
82
+
83
+ const req: AdHocPicklistRequest = {
84
+ preferredLang,
85
+ requests,
86
+ tenantLang,
87
+ };
88
+
89
+ const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/picklists/bulk/read`, {
90
+ method: 'POST',
91
+ headers: cleanHeaders({
92
+ Authorization: auth,
93
+ 'Content-Type': 'application/json',
94
+ }),
95
+ body: JSON.stringify(req),
96
+ });
97
+
98
+ if (response.ok) {
99
+ return response.json() as any;
100
+ }
101
+
102
+ const body = await response.text();
103
+
104
+ throw new XError(response.statusText, { body, req });
105
+ };
package/src/constants.ts CHANGED
@@ -70,6 +70,7 @@ export enum BusinessEntityIds {
70
70
  VehiclesPriceLists = 'vehicles_price_lists',
71
71
  Debtors = 'debtors',
72
72
  DocumentDrafts = 'document_drafts',
73
+ TrackAndTraceDevices = 'track_and_trace_devices',
73
74
  }
74
75
 
75
76
  //
@@ -0,0 +1,44 @@
1
+ //
2
+ // These definitions are sent to the UI
3
+
4
+ import { SUPPORTED_LANGUAGES } from './constants.js';
5
+ import { FieldTypeInfo } from './fields.js';
6
+ import { Aggregation } from './search.js';
7
+
8
+ //
9
+ export type PublicSearchDefinition = {
10
+ fields: { [fieldId: string]: SearchField };
11
+ aggs: Aggregation[];
12
+ };
13
+
14
+ //
15
+ // These definitions are for internal consumption
16
+ //
17
+ export type SearchDefinition = {
18
+ fields: { [fieldId: string]: SearchField };
19
+ };
20
+
21
+ export type SearchField = {
22
+ id: string;
23
+ titles: { [lang: string]: string } & (
24
+ | { [local in (typeof SUPPORTED_LANGUAGES)[number]]: string }
25
+ | { key: string }
26
+ );
27
+ } & FieldTypeInfo;
28
+
29
+ export type EsDefinitionField = {
30
+ esMapping: unknown;
31
+ sortKey?: string;
32
+ };
33
+
34
+ export type EsDefinition = {
35
+ name: string;
36
+ nestedEsPaths: string[];
37
+ fields: {
38
+ [fieldId: string]: EsDefinitionField;
39
+ };
40
+ };
41
+
42
+ export type EsFullTextSearchDefinition = ((lang: string) => string)[];
43
+
44
+ export type EsAggregationsDefinition = Aggregation[];
package/src/exact.ts CHANGED
@@ -14,18 +14,3 @@ export type ExactClientAccount = {
14
14
  exactTld: string;
15
15
  authenticated: boolean;
16
16
  };
17
-
18
- // TODO remove once exact-sdk is correctly published
19
- export type GlAccount = {
20
- id: string;
21
- code: number;
22
- description: string;
23
- };
24
-
25
- export type Journal = {
26
- code: string;
27
- type: string;
28
- glAccountCode: string;
29
- glAccountDescription: string;
30
- description: string;
31
- };
package/src/fields.ts ADDED
@@ -0,0 +1,123 @@
1
+ export enum FieldTypes {
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 };