@bisondesk/commons-sdk 1.0.21 → 1.0.23-B

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 (61) hide show
  1. package/lib/constants.d.ts +34 -4
  2. package/lib/constants.d.ts.map +1 -1
  3. package/lib/constants.js +94 -8
  4. package/lib/constants.js.map +1 -1
  5. package/lib/dayjs-utils.d.ts +7 -0
  6. package/lib/dayjs-utils.d.ts.map +1 -0
  7. package/lib/dayjs-utils.js +28 -0
  8. package/lib/dayjs-utils.js.map +1 -0
  9. package/lib/discussions.d.ts +43 -0
  10. package/lib/discussions.d.ts.map +1 -0
  11. package/lib/discussions.js +5 -0
  12. package/lib/discussions.js.map +1 -0
  13. package/lib/errors.d.ts +36 -0
  14. package/lib/errors.d.ts.map +1 -0
  15. package/lib/errors.js +67 -0
  16. package/lib/errors.js.map +1 -0
  17. package/lib/exact.d.ts +10 -0
  18. package/lib/exact.d.ts.map +1 -0
  19. package/lib/exact.js +3 -0
  20. package/lib/exact.js.map +1 -0
  21. package/lib/ids.d.ts +2 -1
  22. package/lib/ids.d.ts.map +1 -1
  23. package/lib/ids.js +2 -1
  24. package/lib/ids.js.map +1 -1
  25. package/lib/insurance.d.ts +19 -0
  26. package/lib/insurance.d.ts.map +1 -0
  27. package/lib/insurance.js +3 -0
  28. package/lib/insurance.js.map +1 -0
  29. package/lib/messages.d.ts +56 -0
  30. package/lib/messages.d.ts.map +1 -0
  31. package/lib/messages.js +3 -0
  32. package/lib/messages.js.map +1 -0
  33. package/lib/notifications.d.ts +35 -0
  34. package/lib/notifications.d.ts.map +1 -0
  35. package/lib/notifications.js +9 -0
  36. package/lib/notifications.js.map +1 -0
  37. package/lib/pdf-gen.d.ts +40 -0
  38. package/lib/pdf-gen.d.ts.map +1 -0
  39. package/lib/pdf-gen.js +3 -0
  40. package/lib/pdf-gen.js.map +1 -0
  41. package/lib/storage.d.ts +63 -0
  42. package/lib/storage.d.ts.map +1 -0
  43. package/lib/storage.js +14 -0
  44. package/lib/storage.js.map +1 -0
  45. package/lib/types.d.ts +85 -2
  46. package/lib/types.d.ts.map +1 -1
  47. package/lib/types.js.map +1 -1
  48. package/package.json +6 -3
  49. package/src/constants.ts +97 -7
  50. package/src/dayjs-utils.ts +27 -0
  51. package/src/discussions.ts +50 -0
  52. package/src/errors.ts +79 -0
  53. package/src/exact.ts +9 -0
  54. package/src/ids.ts +1 -0
  55. package/src/insurance.ts +21 -0
  56. package/src/messages.ts +65 -0
  57. package/src/notifications.ts +40 -0
  58. package/src/pdf-gen.ts +43 -0
  59. package/src/storage.ts +83 -0
  60. package/src/types.ts +97 -2
  61. package/tsconfig.tsbuildinfo +1 -2892
@@ -0,0 +1,40 @@
1
+ import { BusinessEntityIds } from './constants';
2
+ import { AttachmentValue } from './types';
3
+ export declare type TemplateData = {
4
+ [key: string]: unknown;
5
+ };
6
+ export declare type NewPdfTemplateGroup = {
7
+ exampleData?: TemplateData;
8
+ title: string;
9
+ id: string;
10
+ };
11
+ export declare type PdfTemplateGroup = NewPdfTemplateGroup & {
12
+ modifiedAt: string;
13
+ modifiedBy: string;
14
+ };
15
+ declare type BasePdfTemplate = {
16
+ branch: string;
17
+ docx: AttachmentValue;
18
+ groupId: string;
19
+ language: string;
20
+ };
21
+ export declare type PdfTemplate = BasePdfTemplate & {
22
+ id: string;
23
+ modifiedAt: string;
24
+ modifiedBy: string;
25
+ pdf: AttachmentValue;
26
+ };
27
+ export declare type NewPdfTemplate = BasePdfTemplate & {
28
+ id?: string;
29
+ };
30
+ export declare type GeneratePdfEvent = {
31
+ branch: string;
32
+ businessEntityId: BusinessEntityIds;
33
+ data: TemplateData;
34
+ groupId: string;
35
+ language: string;
36
+ outputFilename?: string;
37
+ tenantId: string;
38
+ };
39
+ export {};
40
+ //# sourceMappingURL=pdf-gen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-gen.d.ts","sourceRoot":"","sources":["../src/pdf-gen.ts"],"names":[],"m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js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf-gen.js","sourceRoot":"","sources":["../src/pdf-gen.ts"],"names":[],"mappings":""}
@@ -0,0 +1,63 @@
1
+ import type Joi from 'joi';
2
+ import { Requester } from './types';
3
+ export declare type UploadInfo = {
4
+ id: string;
5
+ uploadUrl: string;
6
+ downloadPath: string;
7
+ method: 'POST' | 'PATCH' | 'PUT';
8
+ headers?: {
9
+ [name: string]: string;
10
+ };
11
+ };
12
+ export declare type VideoDownloadInfo = {
13
+ url: string;
14
+ quality: string;
15
+ size: number;
16
+ };
17
+ export declare type VideoInfo = {
18
+ status: 'SUCCESS' | 'PROCESSING' | 'ERROR';
19
+ downloads: VideoDownloadInfo[];
20
+ id: string;
21
+ };
22
+ export declare enum UploadProviders {
23
+ Vimeo = "vimeo",
24
+ S3 = "s3"
25
+ }
26
+ declare type BaseUploadUrlRequest = {
27
+ contentType: string;
28
+ };
29
+ export declare type VimeoUploadRequest = BaseUploadUrlRequest & {
30
+ size: number;
31
+ name: string;
32
+ };
33
+ export declare type S3UploadRequest = BaseUploadUrlRequest & {
34
+ shared: boolean;
35
+ fileName: string;
36
+ businessEntityId: string;
37
+ };
38
+ export declare type UploadUrlRequest<Provider extends UploadProviders> = Provider extends UploadProviders.Vimeo ? VimeoUploadRequest : Provider extends UploadProviders.S3 ? S3UploadRequest : {};
39
+ export declare type UploadProvider = {
40
+ validationSchema: Joi.ObjectSchema<any>;
41
+ getVideoListInfo: (requester: Requester, videoIds: string[]) => Promise<VideoInfo[]>;
42
+ getUploadInfo(requester: Requester, request: UploadUrlRequest<UploadProviders>): Promise<UploadInfo>;
43
+ };
44
+ export declare type UploadProvidersDefinition = {
45
+ [key in UploadProviders]: UploadProvider;
46
+ };
47
+ export declare enum MediaExportResolution {
48
+ Low = "low",
49
+ High = "high"
50
+ }
51
+ export declare type MediaExportRequest = {
52
+ urls: string[];
53
+ resolution?: MediaExportResolution;
54
+ };
55
+ export declare type MediaExportEvent = {
56
+ s3Keys: string[];
57
+ outputId: string;
58
+ tenantId: string;
59
+ entityId: string;
60
+ resolution: MediaExportResolution;
61
+ };
62
+ export {};
63
+ //# sourceMappingURL=storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;IACjC,OAAO,CAAC,EAAE;QACR,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,OAAO,CAAC;IAC3C,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,EAAE,OAAO;CACV;AAED,aAAK,oBAAoB,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,oBAAY,kBAAkB,GAAG,oBAAoB,GAAG;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,eAAe,GAAG,oBAAoB,GAAG;IAEnD,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,oBAAY,gBAAgB,CAAC,QAAQ,SAAS,eAAe,IAC3D,QAAQ,SAAS,eAAe,CAAC,KAAK,GAClC,kBAAkB,GAClB,QAAQ,SAAS,eAAe,CAAC,EAAE,GACnC,eAAe,GACf,EAAE,CAAC;AAET,oBAAY,cAAc,GAAG;IAC3B,gBAAgB,EAAE,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACxC,gBAAgB,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACrF,aAAa,CACX,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,GACzC,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB,CAAC;AAEF,oBAAY,yBAAyB,GAAG;KACrC,GAAG,IAAI,eAAe,GAAG,cAAc;CACzC,CAAC;AAEF,oBAAY,qBAAqB;IAC/B,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC,CAAC;AAEF,oBAAY,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC"}
package/lib/storage.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MediaExportResolution = exports.UploadProviders = void 0;
4
+ var UploadProviders;
5
+ (function (UploadProviders) {
6
+ UploadProviders["Vimeo"] = "vimeo";
7
+ UploadProviders["S3"] = "s3";
8
+ })(UploadProviders = exports.UploadProviders || (exports.UploadProviders = {}));
9
+ var MediaExportResolution;
10
+ (function (MediaExportResolution) {
11
+ MediaExportResolution["Low"] = "low";
12
+ MediaExportResolution["High"] = "high";
13
+ })(MediaExportResolution = exports.MediaExportResolution || (exports.MediaExportResolution = {}));
14
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":";;;AAyBA,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,kCAAe,CAAA;IACf,4BAAS,CAAA;AACX,CAAC,EAHW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAG1B;AAsCD,IAAY,qBAGX;AAHD,WAAY,qBAAqB;IAC/B,oCAAW,CAAA;IACX,sCAAa,CAAA;AACf,CAAC,EAHW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAGhC"}
package/lib/types.d.ts CHANGED
@@ -1,15 +1,25 @@
1
+ import { AppRoles } from './constants';
1
2
  export declare type PaginatedList<T, M = {}> = {
2
3
  results: T[];
3
4
  totalCount: number;
4
5
  meta: M;
5
6
  };
7
+ export declare type NextList<T, M = {}> = {
8
+ results: T[];
9
+ nextToken?: string;
10
+ meta: M;
11
+ };
12
+ export declare type PaginatedRequest = {
13
+ limit?: number;
14
+ offset?: number;
15
+ };
6
16
  export declare type Requester = {
7
17
  lang: string;
8
- roles: string[];
18
+ roles: AppRoles[];
9
19
  tenantId: string;
10
20
  tenantLang: string;
11
21
  userAgent?: string;
12
- source: string;
22
+ source?: string;
13
23
  userId: string;
14
24
  isApi: boolean;
15
25
  };
@@ -35,4 +45,77 @@ export declare type CognitoInfo = {
35
45
  appClientId: string;
36
46
  region: Region;
37
47
  };
48
+ export declare type SearchPermissions = {
49
+ users: string[];
50
+ roles: AppRoles[];
51
+ };
52
+ export declare type PhoneNumberValue = {
53
+ country: string;
54
+ e164: string;
55
+ international: string;
56
+ national: string;
57
+ };
58
+ export declare type PhoneNumberRawValue = {
59
+ defaultCountry?: string;
60
+ input: string;
61
+ };
62
+ export declare type LocationValue = {
63
+ addressLine1?: string;
64
+ addressLine2?: string;
65
+ city?: string;
66
+ country: string;
67
+ postalCode?: string;
68
+ gps?: {
69
+ lat: number;
70
+ lon: number;
71
+ };
72
+ };
73
+ export declare type LinkValue = {
74
+ text?: string;
75
+ url: string;
76
+ };
77
+ export declare type Document = {
78
+ type: string;
79
+ displayName: string;
80
+ file: AttachmentValue;
81
+ };
82
+ export declare type AttachmentValue = {
83
+ contentType: string;
84
+ fileName: string;
85
+ id: string;
86
+ previewSrc?: string;
87
+ size: number;
88
+ uploadedAt: string;
89
+ uploadedBy: string;
90
+ url: string;
91
+ descriptions?: string | MultiLangValue;
92
+ };
93
+ export declare type VatLayerResponse = {
94
+ vatNumber: string;
95
+ } & ({
96
+ formatValid: false;
97
+ viesValid: false;
98
+ } | {
99
+ formatValid: true;
100
+ viesValid: boolean;
101
+ countryCode: string;
102
+ name: string;
103
+ addressLines: string[];
104
+ });
105
+ export declare type VatValidationResponse = {
106
+ vatNumber: string;
107
+ formatValid?: boolean;
108
+ countryCode?: string;
109
+ } & ({
110
+ viesValid: false;
111
+ } | {
112
+ viesValid: true;
113
+ name?: string;
114
+ normalizedAddress?: LocationValue;
115
+ officialAddress?: string[];
116
+ });
117
+ export declare type VatValidationRequest = {
118
+ defaultCountry?: string;
119
+ input: string;
120
+ };
38
121
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI;IACrC,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,CAAC,CAAC;CACT,CAAC;AAEF,oBAAY,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,U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xB,CACJ,CAAC;AAEF,oBAAY,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,CACA;IAAE,SAAS,EAAE,KAAK,CAAA;CAAE,GACpB;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,aAAa,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B,CACJ,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC"}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuBA,IAAY,MAEX;AAFD,WAAY,MAAM;IAChB,+BAAqB,CAAA;AACvB,CAAC,EAFW,MAAM,GAAN,cAAM,KAAN,cAAM,QAEjB"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAoCA,IAAY,MAEX;AAFD,WAAY,MAAM;IAChB,+BAAqB,CAAA;AACvB,CAAC,EAFW,MAAM,GAAN,cAAM,KAAN,cAAM,QAEjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bisondesk/commons-sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23-B",
4
4
  "scripts": {
5
5
  "build": "npx tsc --build",
6
6
  "clean": "rm -rf lib *.tsbuildinfo",
@@ -8,10 +8,13 @@
8
8
  "integrationtest": "echo \"No test specified\""
9
9
  },
10
10
  "dependencies": {
11
- "nanoid": "3.1.22"
11
+ "nanoid": "3.1.31",
12
+ "dayjs": "1.10.4",
13
+ "dayjs-business-days": "1.0.4"
12
14
  },
13
15
  "devDependencies": {
14
16
  "@types/nanoid": "2.1.0",
15
- "typescript": "4.2.3"
17
+ "typescript": "4.7.4"
16
18
  }
17
19
  }
20
+
package/src/constants.ts CHANGED
@@ -1,16 +1,106 @@
1
1
  //
2
2
  // STATIC ROLES
3
3
  //
4
- export const ADMINS_ROLE = 'admins';
4
+ export enum AppRoles {
5
+ Accountant = 'accountant',
6
+ Admin = 'admins',
7
+ Administrative = 'administrative',
8
+ Commercial = 'commercial',
9
+ Manager = 'manager',
10
+ ParkLogistics = 'park_logistics',
11
+ }
5
12
 
6
13
  //
7
- // CLOUDFORMATION
14
+ // I18N
8
15
  //
9
- export const INFRA_STACK_NAME = 'infra';
10
- export const RDS_MASTER_SECRET_ID_OUTPUT_NAME = 'RDSMasterSecretId';
11
- export const RDS_DEFAULT_SECRET_ID_OUTPUT_NAME = 'RDSSecretId';
16
+ export const SUPPORTED_LANGUAGES = ['en', 'fr', 'nl', 'es'];
12
17
 
13
18
  //
14
- // I18N
19
+ // Headers
20
+ //
21
+ export const TENANT_ID_ADMIN_HEADER = 'tenant-id';
22
+ export const SERVICE_ID_ADMIN_HEADER = 'service-id';
23
+
24
+ //
25
+ // AUTH
26
+ //
27
+ export const NO_TENANT_ID_VALUE = 'notenant';
28
+ export const SYSTEM_USER_ID = 'system';
29
+
30
+ //
31
+ // Business Entity IDs
15
32
  //
16
- export const SUPPORTED_LANGUAGES = ['en', 'fr', 'nl'];
33
+ export enum BusinessEntityIds {
34
+ BecrisDeclarations = 'becris_declarations',
35
+ Contacts = 'contacts',
36
+ Emails = 'emails',
37
+ FinanceDocuments = 'finance_documents',
38
+ InternetVehicles = 'internet-vehicles',
39
+ Leads = 'leads',
40
+ LeasingContracts = 'leasing_contracts',
41
+ LeasingUploadAutomation = 'leasing_upload_automation',
42
+ Opportunities = 'opportunities',
43
+ Organizations = 'organizations',
44
+ PdfTemplates = 'pdf_templates',
45
+ Users = 'users',
46
+ Vehicles = 'vehicles',
47
+ VehiclesPriceLists = 'vehicles_price_lists',
48
+ }
49
+
50
+ //
51
+ // PDF Templates IDs
52
+ //
53
+ export const LEASING_QUOTE_TEMPLATE_GROUP_ID = 'leasing_quote_template';
54
+ export const LEASING_QUOTE_PROFORMA_TEMPLATE_GROUP_ID = 'leasing_quote_proforma_template';
55
+ export const LEASING_CONTRACT_AMORTIZATION_TEMPLATE_GROUP_ID =
56
+ 'leasing_contract_amortization_template';
57
+ export const LEASING_CONTRACT_TC_TEMPLATE_GROUP_ID = 'leasing_contract_tc_template';
58
+
59
+ //
60
+ // VAT Prefixes for EU Countries and Great Britain & Northern Ireland
61
+ //
62
+ export const EU_VAT_COUNTRY_CODES = [
63
+ 'at',
64
+ 'be',
65
+ 'bg',
66
+ 'hr',
67
+ 'cy',
68
+ 'cz',
69
+ 'dk',
70
+ 'ee',
71
+ 'fi',
72
+ 'fr',
73
+ 'de',
74
+ 'el',
75
+ 'hu',
76
+ 'ie',
77
+ 'it',
78
+ 'lv',
79
+ 'lt',
80
+ 'lu',
81
+ 'mt',
82
+ 'nl',
83
+ 'pl',
84
+ 'pt',
85
+ 'ro',
86
+ 'sk',
87
+ 'si',
88
+ 'es',
89
+ 'se',
90
+ 'xi', // Northern Ireland
91
+ ];
92
+
93
+ export const HEXON_LANG_CODES: [string, ...string[]] = [
94
+ 'en',
95
+ 'nl',
96
+ 'de',
97
+ 'fr',
98
+ 'es',
99
+ 'pt',
100
+ 'it',
101
+ 'pl',
102
+ 'ru',
103
+ 'ro',
104
+ 'el',
105
+ 'bg',
106
+ ];
@@ -0,0 +1,27 @@
1
+ import dayjs, { Dayjs } from 'dayjs';
2
+ import dayjsBusinessDays from 'dayjs-business-days';
3
+ import customParseFormat from 'dayjs/plugin/customParseFormat';
4
+ import IsoWeek from 'dayjs/plugin/isoWeek';
5
+ import timezone from 'dayjs/plugin/timezone';
6
+ import dayjsUtc from 'dayjs/plugin/utc';
7
+
8
+ dayjs.extend(dayjsBusinessDays);
9
+ dayjs.extend(IsoWeek);
10
+ dayjs.extend(customParseFormat);
11
+ dayjs.extend(dayjsUtc);
12
+ dayjs.extend(timezone);
13
+
14
+ // Exists only to make Typescript happy, otherwise the build would fail with
15
+ // "Property 'tz' does not exist on type 'Dayjs'"
16
+ export const tz = dayjs.tz;
17
+
18
+ export const utc = dayjs.utc;
19
+
20
+ export const isSameOrAfter = (value: Dayjs, reference: Dayjs): boolean =>
21
+ value.isAfter(reference) || value.isSame(reference);
22
+
23
+ export const isBetween = (value: Dayjs, startInclusive: Dayjs, endExclusive: Dayjs): boolean =>
24
+ isSameOrAfter(value, startInclusive) && value.isBefore(endExclusive);
25
+
26
+ export const businessDaysAdd = (value: Dayjs, days: number): Dayjs =>
27
+ (value as any).businessDaysAdd(days);
@@ -0,0 +1,50 @@
1
+ import { BusinessEntityIds } from './constants';
2
+
3
+ export type Discussion = {
4
+ businessEntityId: BusinessEntityIds;
5
+ createdAt: string;
6
+ followers: string[];
7
+ id: string;
8
+ recordId: string;
9
+ title?: string;
10
+ };
11
+
12
+ export type DiscussionData = {
13
+ discussion: Discussion;
14
+ messages: Message[];
15
+ };
16
+
17
+ export type NewDiscussion = {
18
+ businessEntityId: BusinessEntityIds;
19
+ content: MessageContent;
20
+ recordId: string;
21
+ title?: string;
22
+ followers: string[];
23
+ };
24
+
25
+ export type Message = {
26
+ author: string;
27
+ content?: MessageContent; // optional if the content is deleted
28
+ createdAt: string;
29
+ deletedAt?: string;
30
+ id: string;
31
+ };
32
+
33
+ export type MessageContent = {
34
+ value: string;
35
+ mentions: string[];
36
+ };
37
+
38
+ export const MESSAGE_NOTIFICATION_ORIGIN = 'message';
39
+
40
+ export type MessageNotificationData = {
41
+ snippet: string;
42
+ id: string;
43
+ mention?: boolean;
44
+ };
45
+
46
+ export type NewDiscussionEvent = {
47
+ discussion: NewDiscussion;
48
+ tenantId: string;
49
+ author: string;
50
+ };
package/src/errors.ts ADDED
@@ -0,0 +1,79 @@
1
+ import { ValidationError, ValidationErrorItem } from 'joi';
2
+
3
+ export class XError extends Error {
4
+ errorCtx: any;
5
+
6
+ constructor(message?: string, errorCtx?: any) {
7
+ super(message);
8
+ this.name = 'XError';
9
+ this.errorCtx = errorCtx;
10
+ }
11
+ }
12
+
13
+ export class WrappedError extends Error {
14
+ errorCtx: any;
15
+
16
+ constructor(err: Error, errorCtx?: any) {
17
+ super(err.message);
18
+ this.name = err.name;
19
+ this.stack = err.stack;
20
+ this.errorCtx = errorCtx;
21
+ }
22
+ }
23
+
24
+ export class AsyncStopError extends Error {
25
+ constructor(message?: string) {
26
+ super(message);
27
+ this.name = 'AsyncStopError';
28
+ }
29
+ }
30
+
31
+ export class ForbiddenError extends Error {
32
+ constructor(message?: string) {
33
+ super(message);
34
+ this.name = 'ForbiddenError';
35
+ }
36
+ }
37
+
38
+ export class EntryAlreadyExistsError extends Error {
39
+ constructor(message?: string) {
40
+ super(message);
41
+ this.name = 'EntryAlreadyExistsError';
42
+ }
43
+ }
44
+
45
+ type FieldValidationError = {
46
+ message: string;
47
+ path: Array<string | number>;
48
+ type: string;
49
+ };
50
+ export class InvalidArgumentsError extends Error {
51
+ validationErrors?: { errors: FieldValidationError[] };
52
+ isValidation = true;
53
+ errorCtx: any;
54
+
55
+ constructor(message?: string, errors?: ValidationError, errorCtx?: any) {
56
+ super(message);
57
+ this.name = 'InvalidArgumentsError';
58
+ this.errorCtx = errorCtx;
59
+
60
+ if (errors != null) {
61
+ this.validationErrors = {
62
+ errors: errors.details.map(
63
+ ({ path, type, message }: ValidationErrorItem): FieldValidationError => ({
64
+ message,
65
+ path,
66
+ type: type === 'custom' ? message : type,
67
+ })
68
+ ),
69
+ };
70
+ }
71
+ }
72
+ }
73
+
74
+ export class UnauthorizedError extends Error {
75
+ constructor(message?: string) {
76
+ super(message);
77
+ this.name = 'UnauthorizedError';
78
+ }
79
+ }
package/src/exact.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type ExactClientAccount = {
2
+ branchId: string;
3
+ division: number;
4
+ clientId: string;
5
+ lastAuthenticatedAt?: string;
6
+ expiresAt?: string;
7
+ exactTld: string;
8
+ authenticated: boolean;
9
+ };
package/src/ids.ts CHANGED
@@ -5,6 +5,7 @@ export enum Alphabet {
5
5
  Alphanumeric = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz',
6
6
  Lowercase = 'abcdefghijklmnopqrstuvwxyz',
7
7
  LowerAlphanumeric = '0123456789abcdefghijklmnopqrstuvwxyz',
8
+ ReferenceCode = '123456789ABCDEFGHJKMNPQRSTUVWXYZ',
8
9
  }
9
10
 
10
11
  // The ID can contain only alphabets and numbers and underscore.
@@ -0,0 +1,21 @@
1
+ export type InsuranceEntry = {
2
+ checkedAt: string;
3
+ insured: boolean;
4
+ };
5
+
6
+ export type InsuranceCheckEvent = {
7
+ contractId: string;
8
+ tenantId: string;
9
+ vin: string;
10
+ };
11
+
12
+ export type InsuranceCheckResponseEvent = InsuranceCheckEvent & {
13
+ insurance: InsuranceEntry;
14
+ };
15
+
16
+ export type InsuranceHistoryRequest = {
17
+ contractId: string;
18
+ tenantId: string;
19
+ limit?: number;
20
+ nextToken?: string;
21
+ };
@@ -0,0 +1,65 @@
1
+ import { AttachmentValue } from './types';
2
+
3
+ export type EmailAddress = {
4
+ name?: string;
5
+ email: string;
6
+ };
7
+
8
+ export type EmailDestination = EmailAddress & {
9
+ organizationId?: string;
10
+ contactId?: string;
11
+ addressType: 'TO' | 'CC' | 'BCC';
12
+ };
13
+
14
+ export type EmailContent = {
15
+ subject: string;
16
+ body: {
17
+ text?: string;
18
+ html?: string;
19
+ };
20
+ };
21
+
22
+ export type EmailMessage = {
23
+ id: string;
24
+ sentAt: string;
25
+ sentBy: string;
26
+ content?: AttachmentValue;
27
+ subject: string;
28
+ source: EmailAddress;
29
+ replyTo?: EmailAddress;
30
+ destinations: EmailDestination[];
31
+ };
32
+
33
+ export type EmailMessageEvent = {
34
+ tenantId: string;
35
+ message: EmailMessage;
36
+ };
37
+
38
+ export type TemplatedEmailRequest = {
39
+ data: Record<string, unknown>;
40
+ destinations: EmailDestination[];
41
+ replyTo?: EmailAddress;
42
+ source: EmailAddress;
43
+ subject: string;
44
+ template: string;
45
+ };
46
+
47
+ export type EmailRequest = {
48
+ references?: string[] | string;
49
+ /* messageId of the email to reply to */
50
+ inReplyTo?: string;
51
+ destinations: EmailDestination[];
52
+ replyTo?: EmailAddress;
53
+ source: EmailAddress;
54
+ subject: string;
55
+ attachments?: AttachmentValue[];
56
+ body:
57
+ | {
58
+ text?: string;
59
+ html: string;
60
+ }
61
+ | {
62
+ html?: string;
63
+ text: string;
64
+ };
65
+ };