@opencrvs/mosip 1.7.0-alpha.14 → 1.7.0-alpha.16
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/build/events.d.ts +16 -0
- package/build/events.js +42 -5
- package/build/forms.d.ts +4 -2
- package/build/forms.js +4 -3
- package/package.json +1 -1
- package/src/events.ts +50 -4
- package/src/forms.ts +4 -3
package/build/events.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type * as Hapi from "@hapi/hapi";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces event registration handler in country config
|
|
4
|
+
*/
|
|
2
5
|
export declare const mosipRegistrationHandler: ({ url }: {
|
|
3
6
|
url: string;
|
|
4
7
|
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
8
|
+
/**
|
|
9
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
10
|
+
*/
|
|
11
|
+
export declare const mosipRegistrationForReviewHandler: ({ url }: {
|
|
12
|
+
url: string;
|
|
13
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
|
14
|
+
/**
|
|
15
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
16
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
17
|
+
*/
|
|
18
|
+
export declare const mosipRegistrationForApprovalHandler: ({ url }: {
|
|
19
|
+
url: string;
|
|
20
|
+
}) => (request: Hapi.Request, h: Hapi.ResponseToolkit) => Promise<Hapi.ResponseObject>;
|
package/build/events.js
CHANGED
|
@@ -3,19 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.mosipRegistrationHandler = void 0;
|
|
6
|
+
exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler = exports.mosipRegistrationHandler = void 0;
|
|
7
7
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
/**
|
|
9
|
+
* Replaces event registration handler in country config
|
|
10
|
+
*/
|
|
8
11
|
const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
9
|
-
const
|
|
10
|
-
const response = await (0, node_fetch_1.default)(
|
|
12
|
+
const MOSIP_API_REGISTRATION_EVENT_URL = new URL("./events/registration", url);
|
|
13
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
11
14
|
method: "POST",
|
|
12
15
|
body: JSON.stringify(request.payload),
|
|
13
|
-
headers:
|
|
16
|
+
headers: {
|
|
17
|
+
...request.headers,
|
|
18
|
+
"content-type": "application/json",
|
|
19
|
+
},
|
|
14
20
|
});
|
|
15
21
|
if (!response.ok) {
|
|
16
22
|
return h
|
|
17
23
|
.response({
|
|
18
|
-
error: "OpenCRVS-MOSIP
|
|
24
|
+
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
19
25
|
response: await response.text(),
|
|
20
26
|
})
|
|
21
27
|
.code(500);
|
|
@@ -23,3 +29,34 @@ const mosipRegistrationHandler = ({ url }) => (async (request, h) => {
|
|
|
23
29
|
return h.response({ success: true }).code(200);
|
|
24
30
|
});
|
|
25
31
|
exports.mosipRegistrationHandler = mosipRegistrationHandler;
|
|
32
|
+
/**
|
|
33
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
34
|
+
*/
|
|
35
|
+
const mosipRegistrationForReviewHandler = ({ url }) => (async (request, h) => {
|
|
36
|
+
// Corresponds to `packages/mosip-api` /events/review -route
|
|
37
|
+
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
38
|
+
console.info(request.headers);
|
|
39
|
+
const response = await (0, node_fetch_1.default)(MOSIP_API_REVIEW_EVENT_URL, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
body: JSON.stringify(request.payload),
|
|
42
|
+
headers: {
|
|
43
|
+
...request.headers,
|
|
44
|
+
"content-type": "application/json",
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
return h
|
|
49
|
+
.response({
|
|
50
|
+
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
51
|
+
response: await response.text(),
|
|
52
|
+
})
|
|
53
|
+
.code(500);
|
|
54
|
+
}
|
|
55
|
+
return h.response({ success: true }).code(200);
|
|
56
|
+
});
|
|
57
|
+
exports.mosipRegistrationForReviewHandler = mosipRegistrationForReviewHandler;
|
|
58
|
+
/**
|
|
59
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
60
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
61
|
+
*/
|
|
62
|
+
exports.mosipRegistrationForApprovalHandler = exports.mosipRegistrationForReviewHandler;
|
package/build/forms.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ export declare const qr: ({ validation, }: {
|
|
|
129
129
|
errorMessage: MessageDescriptor;
|
|
130
130
|
};
|
|
131
131
|
};
|
|
132
|
-
export declare const verified: (event: string, sectionId: string) => {
|
|
132
|
+
export declare const verified: (event: string, sectionId: string, mapping: any) => {
|
|
133
133
|
name: string;
|
|
134
134
|
fieldId: string;
|
|
135
135
|
customQuestionMappingId: string;
|
|
@@ -144,6 +144,7 @@ export declare const verified: (event: string, sectionId: string) => {
|
|
|
144
144
|
expression: string;
|
|
145
145
|
};
|
|
146
146
|
validator: never[];
|
|
147
|
+
mapping: any;
|
|
147
148
|
};
|
|
148
149
|
export declare const idVerificationBanner: (event: string, sectionId: string, status: "pending" | "verified" | "failed") => {
|
|
149
150
|
name: string;
|
|
@@ -163,7 +164,7 @@ export declare const idVerificationBanner: (event: string, sectionId: string, st
|
|
|
163
164
|
expression: string;
|
|
164
165
|
}[];
|
|
165
166
|
};
|
|
166
|
-
export declare const idVerificationFields: (event: string, sectionId: string) => ({
|
|
167
|
+
export declare const idVerificationFields: (event: string, sectionId: string, mapping: any) => ({
|
|
167
168
|
name: string;
|
|
168
169
|
fieldId: string;
|
|
169
170
|
customQuestionMappingId: string;
|
|
@@ -178,6 +179,7 @@ export declare const idVerificationFields: (event: string, sectionId: string) =>
|
|
|
178
179
|
expression: string;
|
|
179
180
|
};
|
|
180
181
|
validator: never[];
|
|
182
|
+
mapping: any;
|
|
181
183
|
} | {
|
|
182
184
|
name: string;
|
|
183
185
|
type: string;
|
package/build/forms.js
CHANGED
|
@@ -142,7 +142,7 @@ const qr = ({ validation, }) => ({
|
|
|
142
142
|
validation,
|
|
143
143
|
});
|
|
144
144
|
exports.qr = qr;
|
|
145
|
-
const verified = (event, sectionId) => {
|
|
145
|
+
const verified = (event, sectionId, mapping) => {
|
|
146
146
|
const fieldName = "verified";
|
|
147
147
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
148
148
|
return {
|
|
@@ -160,6 +160,7 @@ const verified = (event, sectionId) => {
|
|
|
160
160
|
expression: 'Boolean($form?.idReader)? "pending":""',
|
|
161
161
|
},
|
|
162
162
|
validator: [],
|
|
163
|
+
mapping
|
|
163
164
|
};
|
|
164
165
|
};
|
|
165
166
|
exports.verified = verified;
|
|
@@ -191,9 +192,9 @@ const idVerificationBanner = (event, sectionId, status) => {
|
|
|
191
192
|
};
|
|
192
193
|
};
|
|
193
194
|
exports.idVerificationBanner = idVerificationBanner;
|
|
194
|
-
const idVerificationFields = (event, sectionId) => {
|
|
195
|
+
const idVerificationFields = (event, sectionId, mapping) => {
|
|
195
196
|
return [
|
|
196
|
-
(0, exports.verified)(event, sectionId),
|
|
197
|
+
(0, exports.verified)(event, sectionId, mapping),
|
|
197
198
|
(0, exports.idVerificationBanner)(event, sectionId, "pending"),
|
|
198
199
|
(0, exports.idVerificationBanner)(event, sectionId, "verified"),
|
|
199
200
|
(0, exports.idVerificationBanner)(event, sectionId, "failed"),
|
package/package.json
CHANGED
package/src/events.ts
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
import type * as Hapi from "@hapi/hapi";
|
|
2
2
|
import fetch from "node-fetch";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Replaces event registration handler in country config
|
|
6
|
+
*/
|
|
4
7
|
export const mosipRegistrationHandler = ({ url }: { url: string }) =>
|
|
5
8
|
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
6
|
-
const
|
|
9
|
+
const MOSIP_API_REGISTRATION_EVENT_URL = new URL(
|
|
10
|
+
"./events/registration",
|
|
11
|
+
url,
|
|
12
|
+
);
|
|
7
13
|
|
|
8
|
-
const response = await fetch(
|
|
14
|
+
const response = await fetch(MOSIP_API_REGISTRATION_EVENT_URL, {
|
|
9
15
|
method: "POST",
|
|
10
16
|
body: JSON.stringify(request.payload),
|
|
11
|
-
headers:
|
|
17
|
+
headers: {
|
|
18
|
+
...request.headers,
|
|
19
|
+
"content-type": "application/json",
|
|
20
|
+
},
|
|
12
21
|
});
|
|
13
22
|
|
|
14
23
|
if (!response.ok) {
|
|
15
24
|
return h
|
|
16
25
|
.response({
|
|
17
|
-
error: "OpenCRVS-MOSIP
|
|
26
|
+
error: "OpenCRVS-MOSIP event registration route did not return a 200",
|
|
18
27
|
response: await response.text(),
|
|
19
28
|
})
|
|
20
29
|
.code(500);
|
|
@@ -22,3 +31,40 @@ export const mosipRegistrationHandler = ({ url }: { url: string }) =>
|
|
|
22
31
|
|
|
23
32
|
return h.response({ success: true }).code(200);
|
|
24
33
|
}) satisfies Hapi.ServerRoute["handler"];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Replaces `/events/{event}/actions/sent-notification-for-review` handler in country config
|
|
37
|
+
*/
|
|
38
|
+
export const mosipRegistrationForReviewHandler = ({ url }: { url: string }) =>
|
|
39
|
+
(async (request: Hapi.Request, h: Hapi.ResponseToolkit) => {
|
|
40
|
+
// Corresponds to `packages/mosip-api` /events/review -route
|
|
41
|
+
const MOSIP_API_REVIEW_EVENT_URL = new URL("./events/review", url);
|
|
42
|
+
|
|
43
|
+
console.info(request.headers);
|
|
44
|
+
|
|
45
|
+
const response = await fetch(MOSIP_API_REVIEW_EVENT_URL, {
|
|
46
|
+
method: "POST",
|
|
47
|
+
body: JSON.stringify(request.payload),
|
|
48
|
+
headers: {
|
|
49
|
+
...request.headers,
|
|
50
|
+
"content-type": "application/json",
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
return h
|
|
56
|
+
.response({
|
|
57
|
+
error: "OpenCRVS-MOSIP event review route did not return a 200",
|
|
58
|
+
response: await response.text(),
|
|
59
|
+
})
|
|
60
|
+
.code(500);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return h.response({ success: true }).code(200);
|
|
64
|
+
}) satisfies Hapi.ServerRoute["handler"];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Replaces `/events/{event}/actions/sent-for-approval` handler in country config
|
|
68
|
+
* Currently the same as `/events/{event}/actions/sent-notification-for-review`
|
|
69
|
+
*/
|
|
70
|
+
export const mosipRegistrationForApprovalHandler = mosipRegistrationForReviewHandler
|
package/src/forms.ts
CHANGED
|
@@ -184,7 +184,7 @@ export const qr = ({
|
|
|
184
184
|
validation,
|
|
185
185
|
});
|
|
186
186
|
|
|
187
|
-
export const verified = (event: string, sectionId: string) => {
|
|
187
|
+
export const verified = (event: string, sectionId: string, mapping: any) => {
|
|
188
188
|
const fieldName = "verified";
|
|
189
189
|
const fieldId = `${event}.${sectionId}.${sectionId}-view-group.${fieldName}`;
|
|
190
190
|
return {
|
|
@@ -202,6 +202,7 @@ export const verified = (event: string, sectionId: string) => {
|
|
|
202
202
|
expression: 'Boolean($form?.idReader)? "pending":""',
|
|
203
203
|
},
|
|
204
204
|
validator: [],
|
|
205
|
+
mapping
|
|
205
206
|
};
|
|
206
207
|
};
|
|
207
208
|
|
|
@@ -238,9 +239,9 @@ export const idVerificationBanner = (
|
|
|
238
239
|
};
|
|
239
240
|
};
|
|
240
241
|
|
|
241
|
-
export const idVerificationFields = (event: string, sectionId: string) => {
|
|
242
|
+
export const idVerificationFields = (event: string, sectionId: string, mapping: any) => {
|
|
242
243
|
return [
|
|
243
|
-
verified(event, sectionId),
|
|
244
|
+
verified(event, sectionId, mapping),
|
|
244
245
|
idVerificationBanner(event, sectionId, "pending"),
|
|
245
246
|
idVerificationBanner(event, sectionId, "verified"),
|
|
246
247
|
idVerificationBanner(event, sectionId, "failed"),
|