@bisondesk/commons-sdk 1.0.238 → 1.0.240

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 (39) hide show
  1. package/lib/cjs/constants.js +4 -1
  2. package/lib/cjs/constants.js.map +1 -1
  3. package/lib/cjs/dayjs-utils.js +3 -1
  4. package/lib/cjs/dayjs-utils.js.map +1 -1
  5. package/lib/cjs/location-utils.js +11 -0
  6. package/lib/cjs/location-utils.js.map +1 -0
  7. package/lib/cjs/locations.js +11 -0
  8. package/lib/cjs/locations.js.map +1 -0
  9. package/lib/cjs/types.js.map +1 -1
  10. package/lib/esm/constants.js +3 -0
  11. package/lib/esm/constants.js.map +1 -1
  12. package/lib/esm/dayjs-utils.js +1 -0
  13. package/lib/esm/dayjs-utils.js.map +1 -1
  14. package/lib/esm/location-utils.js +7 -0
  15. package/lib/esm/location-utils.js.map +1 -0
  16. package/lib/esm/locations.js +8 -0
  17. package/lib/esm/locations.js.map +1 -0
  18. package/lib/esm/types.js.map +1 -1
  19. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  20. package/lib/tsconfig.esm.tsbuildinfo +1 -1
  21. package/lib/types/constants.d.ts +4 -1
  22. package/lib/types/constants.d.ts.map +1 -1
  23. package/lib/types/dayjs-utils.d.ts +1 -0
  24. package/lib/types/dayjs-utils.d.ts.map +1 -1
  25. package/lib/types/insurance.d.ts +1 -0
  26. package/lib/types/insurance.d.ts.map +1 -1
  27. package/lib/types/location-utils.d.ts +3 -0
  28. package/lib/types/location-utils.d.ts.map +1 -0
  29. package/lib/types/locations.d.ts +31 -0
  30. package/lib/types/locations.d.ts.map +1 -0
  31. package/lib/types/types.d.ts +11 -11
  32. package/lib/types/types.d.ts.map +1 -1
  33. package/package.json +10 -4
  34. package/src/constants.ts +3 -0
  35. package/src/dayjs-utils.ts +3 -0
  36. package/src/insurance.ts +1 -0
  37. package/src/location-utils.ts +9 -0
  38. package/src/locations.ts +35 -0
  39. package/src/types.ts +13 -12
@@ -0,0 +1,9 @@
1
+ import { LocationValue } from './types';
2
+
3
+ export const getAddressText = (address: LocationValue, joinBy: string = '<br>'): string => {
4
+ const regionLines = [address.postalCode, address.city, address.country.toUpperCase()]
5
+ .filter((n) => !!n)
6
+ .join(', ');
7
+
8
+ return [address.addressLine1, address.addressLine2, regionLines].filter((n) => !!n).join(joinBy);
9
+ };
@@ -0,0 +1,35 @@
1
+ export type GPSCoord = {
2
+ lat: number;
3
+ lon: number;
4
+ };
5
+
6
+ export type LocationValue = {
7
+ addressLine1?: string;
8
+ addressLine2?: string;
9
+ city?: string;
10
+ country: string;
11
+ postalCode?: string;
12
+ gps?: GPSCoord;
13
+ };
14
+
15
+ export type RoutesRequest = {
16
+ origin: LocationValue;
17
+ destination: LocationValue;
18
+ };
19
+
20
+ export enum RouteLabel {
21
+ Unspecified = 'ROUTE_LABEL_UNSPECIFIED',
22
+ Default = 'DEFAULT_ROUTE',
23
+ DefaultAlternate = 'DEFAULT_ROUTE_ALTERNATE',
24
+ FuelEfficient = 'FUEL_EFFICIENT',
25
+ }
26
+
27
+ export type Route = {
28
+ duration: string;
29
+ distanceMeters: number;
30
+ routeLabels: RouteLabel[];
31
+ };
32
+
33
+ export type RoutesResponse = {
34
+ routes: Route[];
35
+ };
package/src/types.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { AppRoles } from './constants';
2
+ import { LocationValue } from './locations';
3
+ export { GPSCoord, LocationValue } from './locations';
2
4
 
3
5
  export type PaginatedList<T, M = {}> = {
4
6
  results: T[];
@@ -6,6 +8,11 @@ export type PaginatedList<T, M = {}> = {
6
8
  meta: M;
7
9
  };
8
10
 
11
+ export type PaginationRequest = {
12
+ limit: number;
13
+ offset: number;
14
+ };
15
+
9
16
  export type NextList<T, M = {}> = {
10
17
  results: T[];
11
18
  nextToken?: string;
@@ -68,18 +75,6 @@ export type PhoneNumberRawValue = {
68
75
  input: string;
69
76
  };
70
77
 
71
- export type LocationValue = {
72
- addressLine1?: string;
73
- addressLine2?: string;
74
- city?: string;
75
- country: string;
76
- postalCode?: string;
77
- gps?: {
78
- lat: number;
79
- lon: number;
80
- };
81
- };
82
-
83
78
  export type LinkValue = {
84
79
  text?: string;
85
80
  url: string;
@@ -132,3 +127,9 @@ export type VatValidationRequest = {
132
127
  defaultCountry?: string;
133
128
  input: string;
134
129
  };
130
+
131
+ export type CurrencyLayerResponse = {
132
+ conversionRate: number;
133
+ targetCurrency: string;
134
+ sourceCurrency: string;
135
+ };