@lysaab/lysa-pep 0.5.0 → 0.7.0

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/Exports.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- export { BusinessRelation, EntityType, MilitaryRank, PepContext, PepContextProps, PepContextProvider, PepState, PepStatus, PepType, Relation, Role } from "./pages/PepContext";
1
+ export * from "./pages/PepContext";
2
+ export * from './model/PepModel';
3
+ export * from './model/PepTexts';
2
4
  export { PepIsPepPage } from './pages/PepIsPepPage';
3
5
  export { PepRelationPage } from './pages/PepRelationPage';
4
6
  export { PepRolePage } from './pages/PepRolePage';
package/lib/Exports.js CHANGED
@@ -1,4 +1,6 @@
1
- export { BusinessRelation, EntityType, MilitaryRank, PepContext, PepContextProvider, PepStatus, PepType, Relation, Role } from "./pages/PepContext";
1
+ export * from "./pages/PepContext";
2
+ export * from './model/PepModel';
3
+ export * from './model/PepTexts';
2
4
  export { PepIsPepPage } from './pages/PepIsPepPage';
3
5
  export { PepRelationPage } from './pages/PepRelationPage';
4
6
  export { PepRolePage } from './pages/PepRolePage';
@@ -0,0 +1,7 @@
1
+ import { PepState } from "../pages/PepContext";
2
+ export interface PepRequest extends Omit<PepState, "isSweden" | "isOngoing" | "ended" | "birthdayOfPEP"> {
3
+ ended?: string;
4
+ birthdayOfPEP?: string;
5
+ }
6
+ export declare function stateToRequest(pepData: PepState): PepRequest;
7
+ export declare function requestToState({ ended, birthdayOfPEP, ...serverData }: PepRequest): PepState;
@@ -0,0 +1,40 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { PepType, EntityType, PepStatus } from "../pages/PepContext";
13
+ import { DateTime } from "luxon";
14
+ export function stateToRequest(pepData) {
15
+ const data = Object.assign({}, pepData);
16
+ delete data.isSweden;
17
+ delete data.isOngoing;
18
+ delete data.ownerName;
19
+ if (data.legalEntityType === EntityType.PERSON) {
20
+ delete data.tin;
21
+ }
22
+ return Object.assign(Object.assign({}, data), { country: data.type !== PepType.NOT_PEP ? data.country || "SE" : undefined, ended: data.ended
23
+ ? DateTime.fromJSDate(data.ended).toFormat("yyyy-MM")
24
+ : undefined, birthdayOfPEP: data.birthdayOfPEP
25
+ ? DateTime.fromJSDate(data.birthdayOfPEP).toFormat("yyyy-MM-dd")
26
+ : undefined });
27
+ }
28
+ export function requestToState(_a) {
29
+ var { ended, birthdayOfPEP } = _a, serverData = __rest(_a, ["ended", "birthdayOfPEP"]);
30
+ const state = Object.assign({}, serverData);
31
+ if (ended) {
32
+ state.ended = DateTime.fromFormat(ended, "yyyy-MM").toJSDate();
33
+ }
34
+ if (birthdayOfPEP) {
35
+ state.birthdayOfPEP = DateTime.fromFormat(birthdayOfPEP, "yyyy-MM").toJSDate();
36
+ }
37
+ state.isSweden = state.country === "SE" ? "sweden" : "other";
38
+ state.isOngoing = state.ended ? PepStatus.ENDED : PepStatus.ONGOING;
39
+ return state;
40
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lysaab/lysa-pep",
3
3
  "author": "Lysa AB",
4
- "version": "0.5.0",
4
+ "version": "0.7.0",
5
5
  "main": "./lib/Exports.js",
6
6
  "dependencies": {
7
7
  "@lysaab/ui-2": "^8.7.0",
package/src/Exports.ts CHANGED
@@ -1,16 +1,6 @@
1
- export {
2
- BusinessRelation,
3
- EntityType,
4
- MilitaryRank,
5
- PepContext,
6
- PepContextProps,
7
- PepContextProvider,
8
- PepState,
9
- PepStatus,
10
- PepType,
11
- Relation,
12
- Role
13
- } from "./pages/PepContext";
1
+ export * from "./pages/PepContext";
2
+ export * from './model/PepModel';
3
+ export * from './model/PepTexts';
14
4
 
15
5
  export { PepIsPepPage } from './pages/PepIsPepPage';
16
6
  export { PepRelationPage } from './pages/PepRelationPage';
@@ -1,4 +1,4 @@
1
- import { PepState, PepType, EntityType } from "../pages/PepContext";
1
+ import { PepState, PepType, EntityType, PepStatus } from "../pages/PepContext";
2
2
  import { DateTime } from "luxon";
3
3
 
4
4
  export interface PepRequest
@@ -11,12 +11,12 @@ export interface PepRequest
11
11
  *
12
12
  * Do some minor preprocessing before we are ready to sen everything to the server
13
13
  */
14
- export function formatServerRequest(pepData: PepState): PepRequest {
14
+ export function stateToRequest(pepData: PepState): PepRequest {
15
15
  const data = { ...pepData };
16
16
  delete data.isSweden;
17
17
  delete data.isOngoing;
18
18
  delete data.ownerName;
19
- if(data.legalEntityType === EntityType.PERSON) {
19
+ if (data.legalEntityType === EntityType.PERSON) {
20
20
  delete data.tin;
21
21
  }
22
22
  return {
@@ -30,3 +30,23 @@ export function formatServerRequest(pepData: PepState): PepRequest {
30
30
  : undefined
31
31
  };
32
32
  }
33
+
34
+ export function requestToState({
35
+ ended,
36
+ birthdayOfPEP,
37
+ ...serverData
38
+ }: PepRequest): PepState {
39
+ const state: PepState = { ...serverData };
40
+ if (ended) {
41
+ state.ended = DateTime.fromFormat(ended, "yyyy-MM").toJSDate();
42
+ }
43
+ if (birthdayOfPEP) {
44
+ state.birthdayOfPEP = DateTime.fromFormat(
45
+ birthdayOfPEP,
46
+ "yyyy-MM"
47
+ ).toJSDate();
48
+ }
49
+ state.isSweden = state.country === "SE" ? "sweden" : "other";
50
+ state.isOngoing = state.ended ? PepStatus.ENDED : PepStatus.ONGOING;
51
+ return state;
52
+ }