@opencrvs/toolkit 1.9.12-rc.f66bece → 1.9.12-rc.f687751
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/dist/cli.js +1350 -142
- package/dist/commons/api/router.d.ts +175 -163
- package/dist/commons/events/AuditLog.d.ts +2 -0
- package/dist/commons/notification/UserNotifications.d.ts +15 -0
- package/dist/events/index.js +13 -2
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/add-birth-certificate-issuance-flag.js +3 -4
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +3 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +1 -0
- package/dist/migrations/v2.0/add-resend-invite-notification.js +345 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +19 -0
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +17 -13
- package/dist/migrations/v2.0/convert-config-files-to-ts.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +4 -5
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +4 -5
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +77 -0
- package/dist/migrations/v2.0/index.d.ts +8 -4
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +1318 -139
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.d.ts.map +1 -1
- package/dist/migrations/v2.0/make-built-in-validate-actions-custom.js +5 -6
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +3 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -0
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +221 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +3 -0
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +1 -0
- package/dist/migrations/v2.0/migrate-application-config-url.js +342 -0
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +6 -7
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-validated-workqueue-status-to-flag.js +3 -4
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +3 -4
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +3 -4
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +2 -3
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +3 -4
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +3 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +163 -0
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +1 -2
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +3 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-old-statistics-service.js +356 -0
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +3 -4
- package/dist/migrations/v2.0/remove-review-from-register-action.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-review-from-register-action.js +3 -4
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +3 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +1 -0
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +186 -0
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +3 -4
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +3 -4
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +1 -2
- package/dist/migrations/v2.0/update-package-json.d.ts +3 -0
- package/dist/migrations/v2.0/update-package-json.d.ts.map +1 -0
- package/dist/migrations/v2.0/update-package-json.js +105 -0
- package/dist/notification/index.js +6 -0
- package/opencrvs-toolkit-1.9.12-rc.f687751.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-1.9.12-rc.f66bece.tgz +0 -0
|
@@ -60,6 +60,7 @@ export declare const UserAuditRecordInput: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
60
60
|
"user.password_changed": "user.password_changed";
|
|
61
61
|
"user.password_reset": "user.password_reset";
|
|
62
62
|
"user.password_reset_by_admin": "user.password_reset_by_admin";
|
|
63
|
+
"user.resend_invite": "user.resend_invite";
|
|
63
64
|
"user.username_reminder": "user.username_reminder";
|
|
64
65
|
"user.username_reminder_by_admin": "user.username_reminder_by_admin";
|
|
65
66
|
}>;
|
|
@@ -340,6 +341,7 @@ export declare const AuditLogEntrySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
340
341
|
"user.password_changed": "user.password_changed";
|
|
341
342
|
"user.password_reset": "user.password_reset";
|
|
342
343
|
"user.password_reset_by_admin": "user.password_reset_by_admin";
|
|
344
|
+
"user.resend_invite": "user.resend_invite";
|
|
343
345
|
"user.username_reminder": "user.username_reminder";
|
|
344
346
|
"user.username_reminder_by_admin": "user.username_reminder_by_admin";
|
|
345
347
|
}>;
|
|
@@ -5,6 +5,7 @@ export declare const TriggerEvent: {
|
|
|
5
5
|
readonly USERNAME_REMINDER: "username-reminder";
|
|
6
6
|
readonly RESET_PASSWORD: "reset-password";
|
|
7
7
|
readonly RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin";
|
|
8
|
+
readonly RESEND_INVITE: "resend-invite";
|
|
8
9
|
readonly TWO_FA: "2fa";
|
|
9
10
|
readonly ALL_USER_NOTIFICATION: "all-user-notification";
|
|
10
11
|
readonly CHANGE_PHONE_NUMBER: "change-phone-number";
|
|
@@ -112,6 +113,20 @@ export declare const TriggerPayload: {
|
|
|
112
113
|
role: z.ZodString;
|
|
113
114
|
}, z.core.$strip>;
|
|
114
115
|
}, z.core.$strip>;
|
|
116
|
+
readonly "resend-invite": z.ZodObject<{
|
|
117
|
+
recipient: z.ZodObject<{
|
|
118
|
+
name: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
firstname: z.ZodString;
|
|
120
|
+
surname: z.ZodString;
|
|
121
|
+
middlename: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
mobile: z.ZodOptional<z.ZodString>;
|
|
124
|
+
email: z.ZodOptional<z.ZodString>;
|
|
125
|
+
bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
username: z.ZodString;
|
|
128
|
+
temporaryPassword: z.ZodString;
|
|
129
|
+
}, z.core.$strip>;
|
|
115
130
|
readonly "2fa": z.ZodObject<{
|
|
116
131
|
recipient: z.ZodObject<{
|
|
117
132
|
name: z.ZodOptional<z.ZodObject<{
|
package/dist/events/index.js
CHANGED
|
@@ -938,6 +938,7 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
|
|
|
938
938
|
"user.password_changed",
|
|
939
939
|
"user.password_reset",
|
|
940
940
|
"user.password_reset_by_admin",
|
|
941
|
+
"user.resend_invite",
|
|
941
942
|
"user.username_reminder",
|
|
942
943
|
"user.username_reminder_by_admin"
|
|
943
944
|
]),
|
|
@@ -4574,7 +4575,16 @@ function aggregateActionDeclarations(event2) {
|
|
|
4574
4575
|
if (!requestAction) {
|
|
4575
4576
|
return declaration;
|
|
4576
4577
|
}
|
|
4577
|
-
|
|
4578
|
+
const declarationWithApprovedCorrection = getCompleteActionDeclaration(
|
|
4579
|
+
declaration,
|
|
4580
|
+
event2,
|
|
4581
|
+
requestAction
|
|
4582
|
+
);
|
|
4583
|
+
return getCompleteActionDeclaration(
|
|
4584
|
+
declarationWithApprovedCorrection,
|
|
4585
|
+
event2,
|
|
4586
|
+
action
|
|
4587
|
+
);
|
|
4578
4588
|
}
|
|
4579
4589
|
return getCompleteActionDeclaration(declaration, event2, action);
|
|
4580
4590
|
}, {});
|
|
@@ -10013,7 +10023,8 @@ function userDeserializer(serializedUserField, user2) {
|
|
|
10013
10023
|
`Deserializer for ${serializedUserField.$userField} is not implemented yet`
|
|
10014
10024
|
);
|
|
10015
10025
|
}
|
|
10016
|
-
|
|
10026
|
+
const value = user2[serializedUserField.$userField];
|
|
10027
|
+
return typeof value === "string" ? value : void 0;
|
|
10017
10028
|
}
|
|
10018
10029
|
function isDefined(value) {
|
|
10019
10030
|
return value !== void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-birth-certificate-issuance-flag.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-birth-certificate-issuance-flag.ts"],"names":[],"mappings":"AA2aA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -48,7 +48,6 @@ exports.main = main;
|
|
|
48
48
|
*/
|
|
49
49
|
const ts_morph_1 = require("ts-morph");
|
|
50
50
|
const path_1 = __importDefault(require("path"));
|
|
51
|
-
const _1 = require(".");
|
|
52
51
|
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
53
52
|
const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
|
|
54
53
|
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
@@ -318,7 +317,7 @@ function processFile(filePath, project) {
|
|
|
318
317
|
if (!sourceFile)
|
|
319
318
|
return 0;
|
|
320
319
|
let totalChanges = 0;
|
|
321
|
-
const relPath = path_1.default.relative(
|
|
320
|
+
const relPath = path_1.default.relative(process.cwd(), filePath);
|
|
322
321
|
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
323
322
|
for (const call of callExpressions) {
|
|
324
323
|
const expression = call.getExpression();
|
|
@@ -369,7 +368,7 @@ function processFile(filePath, project) {
|
|
|
369
368
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
370
369
|
function main() {
|
|
371
370
|
return __awaiter(this, void 0, void 0, function* () {
|
|
372
|
-
const srcDir = path_1.default.join(
|
|
371
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
373
372
|
console.log(`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
|
|
374
373
|
const project = new ts_morph_1.Project({
|
|
375
374
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -398,7 +397,7 @@ function main() {
|
|
|
398
397
|
for (const filePath of modifiedFiles) {
|
|
399
398
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
400
399
|
yield sourceFile.save();
|
|
401
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
400
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
402
401
|
}
|
|
403
402
|
console.log(`\nDone. Applied ${totalChanges} change(s) across ${modifiedFiles.length} file(s).`);
|
|
404
403
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add-resend-invite-notification.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/add-resend-invite-notification.ts"],"names":[],"mappings":"AAmSA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA2FnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.main = main;
|
|
26
|
+
/**
|
|
27
|
+
* Codemod: Add `TriggerEvent.RESEND_INVITE` wiring to the country config
|
|
28
|
+
* (email schemas, templates, `/triggers/user/resend-invite` route,
|
|
29
|
+
* SMS keys, CSV copy, HTML template).
|
|
30
|
+
*
|
|
31
|
+
* Idempotent: safe to run multiple times; skips edits when markers are
|
|
32
|
+
* already present.
|
|
33
|
+
*/
|
|
34
|
+
const fs_1 = require("fs");
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const EMAIL_TEMPLATES_INDEX = 'src/api/notification/email-templates/index.ts';
|
|
37
|
+
const NOTIFICATION_HANDLER = 'src/api/notification/handler.ts';
|
|
38
|
+
const USER_NOTIFICATION_ROUTES = 'src/config/routes/userNotificationRoutes.ts';
|
|
39
|
+
const SMS_SERVICE = 'src/api/notification/sms-service.ts';
|
|
40
|
+
const NOTIFICATION_CSV = 'src/translations/notification.csv';
|
|
41
|
+
const RESEND_INVITE_HTML = 'src/api/notification/email-templates/other/resend-invite.html';
|
|
42
|
+
const TRIGGER_VARIABLE_ANCHOR_BEFORE = ` [TriggerEvent.CHANGE_PHONE_NUMBER]: z.object({
|
|
43
|
+
firstname: z.string(),
|
|
44
|
+
code: z.string()
|
|
45
|
+
})
|
|
46
|
+
} as const`;
|
|
47
|
+
const TRIGGER_VARIABLE_ANCHOR_AFTER = ` [TriggerEvent.CHANGE_PHONE_NUMBER]: z.object({
|
|
48
|
+
firstname: z.string(),
|
|
49
|
+
code: z.string()
|
|
50
|
+
}),
|
|
51
|
+
[TriggerEvent.RESEND_INVITE]: z.object({
|
|
52
|
+
firstname: z.string(),
|
|
53
|
+
username: z.string(),
|
|
54
|
+
temporaryPassword: z.string(),
|
|
55
|
+
completeSetupUrl: z.string(),
|
|
56
|
+
loginURL: z.string()
|
|
57
|
+
})
|
|
58
|
+
} as const`;
|
|
59
|
+
const TEMPLATES_ANCHOR_BEFORE = ` [TriggerEvent.USER_CREATED]: {
|
|
60
|
+
type: 'onboarding-invite',
|
|
61
|
+
subject: 'Welcome to OpenCRVS!',
|
|
62
|
+
template:
|
|
63
|
+
readOtherTemplate<TriggerVariable['user-created']>('onboarding-invite')
|
|
64
|
+
},
|
|
65
|
+
[TriggerEvent.TWO_FA]: {`;
|
|
66
|
+
const TEMPLATES_ANCHOR_AFTER = ` [TriggerEvent.USER_CREATED]: {
|
|
67
|
+
type: 'onboarding-invite',
|
|
68
|
+
subject: 'Welcome to OpenCRVS!',
|
|
69
|
+
template:
|
|
70
|
+
readOtherTemplate<TriggerVariable['user-created']>('onboarding-invite')
|
|
71
|
+
},
|
|
72
|
+
[TriggerEvent.RESEND_INVITE]: {
|
|
73
|
+
type: 'resend-invite',
|
|
74
|
+
subject: 'Your OpenCRVS account invitation',
|
|
75
|
+
template:
|
|
76
|
+
readOtherTemplate<TriggerVariable['resend-invite']>('resend-invite')
|
|
77
|
+
},
|
|
78
|
+
[TriggerEvent.TWO_FA]: {`;
|
|
79
|
+
const HANDLER_ANCHOR_BEFORE = ` case TriggerEvent.USER_CREATED:
|
|
80
|
+
return {
|
|
81
|
+
firstname,
|
|
82
|
+
username: payload.username,
|
|
83
|
+
temporaryPassword: payload.temporaryPassword,
|
|
84
|
+
completeSetupUrl: LOGIN_URL,
|
|
85
|
+
loginURL: LOGIN_URL
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
case TriggerEvent.USER_UPDATED:`;
|
|
89
|
+
const HANDLER_ANCHOR_AFTER = ` case TriggerEvent.USER_CREATED:
|
|
90
|
+
return {
|
|
91
|
+
firstname,
|
|
92
|
+
username: payload.username,
|
|
93
|
+
temporaryPassword: payload.temporaryPassword,
|
|
94
|
+
completeSetupUrl: LOGIN_URL,
|
|
95
|
+
loginURL: LOGIN_URL
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case TriggerEvent.RESEND_INVITE:
|
|
99
|
+
return {
|
|
100
|
+
firstname,
|
|
101
|
+
username: payload.username,
|
|
102
|
+
temporaryPassword: payload.temporaryPassword,
|
|
103
|
+
completeSetupUrl: LOGIN_URL,
|
|
104
|
+
loginURL: LOGIN_URL
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
case TriggerEvent.USER_UPDATED:`;
|
|
108
|
+
const ROUTES_ANCHOR_BEFORE = ` {
|
|
109
|
+
method: 'POST',
|
|
110
|
+
path: '/triggers/user/user-created',
|
|
111
|
+
handler: makeNotificationHandler('user-created'),
|
|
112
|
+
options: {
|
|
113
|
+
auth: false,
|
|
114
|
+
tags: ['api'],
|
|
115
|
+
description: 'Handles notification for user creation'
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
method: 'POST',
|
|
120
|
+
path: '/triggers/user/user-updated',`;
|
|
121
|
+
const ROUTES_ANCHOR_AFTER = ` {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
path: '/triggers/user/user-created',
|
|
124
|
+
handler: makeNotificationHandler('user-created'),
|
|
125
|
+
options: {
|
|
126
|
+
auth: false,
|
|
127
|
+
tags: ['api'],
|
|
128
|
+
description: 'Handles notification for user creation'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
method: 'POST',
|
|
133
|
+
path: '/triggers/user/resend-invite',
|
|
134
|
+
handler: makeNotificationHandler('resend-invite'),
|
|
135
|
+
options: {
|
|
136
|
+
auth: false,
|
|
137
|
+
tags: ['api'],
|
|
138
|
+
description: 'Handles notification for resent user invite'
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
method: 'POST',
|
|
143
|
+
path: '/triggers/user/user-updated',`;
|
|
144
|
+
const SMS_OTHER_BEFORE = ` userCredentialsNotification: 'userCredentialsNotification',
|
|
145
|
+
retieveUserNameNotification:`;
|
|
146
|
+
const SMS_OTHER_AFTER = ` userCredentialsNotification: 'userCredentialsNotification',
|
|
147
|
+
resendInviteNotification: 'resendInviteNotification',
|
|
148
|
+
retieveUserNameNotification:`;
|
|
149
|
+
const SMS_TRIGGER_BEFORE = ` ['user-created']: 'userCredentialsNotification',
|
|
150
|
+
['user-updated']: 'updateUserNameNotification',`;
|
|
151
|
+
const SMS_TRIGGER_AFTER = ` ['user-created']: 'userCredentialsNotification',
|
|
152
|
+
['resend-invite']: 'resendInviteNotification',
|
|
153
|
+
['user-updated']: 'updateUserNameNotification',`;
|
|
154
|
+
const RESEND_INVITE_HTML_CONTENT = `<!doctype html>
|
|
155
|
+
<html>
|
|
156
|
+
<head>
|
|
157
|
+
<link
|
|
158
|
+
href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;700&display=swap"
|
|
159
|
+
rel="stylesheet"
|
|
160
|
+
/>
|
|
161
|
+
<style type="text/css">
|
|
162
|
+
body {
|
|
163
|
+
font-family: 'Noto Sans', sans-serif;
|
|
164
|
+
color: #222;
|
|
165
|
+
padding: 16px 24px;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
h1 {
|
|
169
|
+
font-size: 21px;
|
|
170
|
+
margin-top: 32px;
|
|
171
|
+
margin-bottom: 36px;
|
|
172
|
+
font-weight: 700;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
p {
|
|
176
|
+
font-weight: 400;
|
|
177
|
+
font-size: 16px;
|
|
178
|
+
line-height: 1.8;
|
|
179
|
+
margin-bottom: 24px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
i {
|
|
183
|
+
color: #666;
|
|
184
|
+
font-weight: 400;
|
|
185
|
+
font-size: 16px;
|
|
186
|
+
}
|
|
187
|
+
</style>
|
|
188
|
+
</head>
|
|
189
|
+
|
|
190
|
+
<body>
|
|
191
|
+
<img
|
|
192
|
+
src="{{countryLogo}}"
|
|
193
|
+
alt="country_logo"
|
|
194
|
+
style="max-height: 88px; max-width: 100%"
|
|
195
|
+
/>
|
|
196
|
+
<h1>Your {{applicationName}} account invitation</h1>
|
|
197
|
+
<p>Hello {{firstname}},</p>
|
|
198
|
+
<p>Your account invitation has been resent. Please use the following credentials to access your account:</p>
|
|
199
|
+
<p>
|
|
200
|
+
Username: <strong>{{username}}</strong><br />
|
|
201
|
+
Password: <strong>{{temporaryPassword}}</strong>
|
|
202
|
+
</p>
|
|
203
|
+
<p>
|
|
204
|
+
Please click the link below to complete your account setup and start using
|
|
205
|
+
{{applicationName}}.
|
|
206
|
+
</p>
|
|
207
|
+
|
|
208
|
+
<div style="margin-top: 32px; margin-bottom: 32px">
|
|
209
|
+
<a href="{{loginURL}}">Complete setup</a>
|
|
210
|
+
</div>
|
|
211
|
+
<br />
|
|
212
|
+
<p>
|
|
213
|
+
Best regards, <br />
|
|
214
|
+
{{applicationName}} Team
|
|
215
|
+
</p>
|
|
216
|
+
</body>
|
|
217
|
+
</html>
|
|
218
|
+
`;
|
|
219
|
+
const CSV_ROW = "resendInviteNotification,The SMS message that is sent when a user invitation is resent,Your OpenCRVS account invitation was resent. Please login with your username: {{username}} and temporary password: {{temporaryPassword}},Votre invitation de compte OpenCRVS a été renvoyée. Veuillez vous connecter avec votre nom d'utilisateur : {{username}} et votre mot de passe temporaire : {{temporaryPassword}}.\n";
|
|
220
|
+
function replaceExactlyOnceOrSkip(fileLabel, contents, before, after, anchorName) {
|
|
221
|
+
const n = contents.split(before).length - 1;
|
|
222
|
+
if (n === 0) {
|
|
223
|
+
// eslint-disable-next-line no-console
|
|
224
|
+
console.log(` [${fileLabel}] ${anchorName}: anchor not found — skipping (unexpected file shape).`);
|
|
225
|
+
return { contents, changed: false };
|
|
226
|
+
}
|
|
227
|
+
if (n > 1) {
|
|
228
|
+
// eslint-disable-next-line no-console
|
|
229
|
+
console.warn(` [${fileLabel}] ${anchorName}: ambiguous anchor (${n} matches) — skipping.`);
|
|
230
|
+
return { contents, changed: false };
|
|
231
|
+
}
|
|
232
|
+
const next = contents.replace(before, after);
|
|
233
|
+
return { contents: next, changed: true };
|
|
234
|
+
}
|
|
235
|
+
function patchEmailTemplatesIndex() {
|
|
236
|
+
const full = path_1.default.join(process.cwd(), EMAIL_TEMPLATES_INDEX);
|
|
237
|
+
if (!(0, fs_1.existsSync)(full)) {
|
|
238
|
+
// eslint-disable-next-line no-console
|
|
239
|
+
console.log(` '${EMAIL_TEMPLATES_INDEX}' missing — skipping.`);
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
let text = (0, fs_1.readFileSync)(full, 'utf8');
|
|
243
|
+
let changed = false;
|
|
244
|
+
if (!text.includes('[TriggerEvent.RESEND_INVITE]: z.object')) {
|
|
245
|
+
const r = replaceExactlyOnceOrSkip(EMAIL_TEMPLATES_INDEX, text, TRIGGER_VARIABLE_ANCHOR_BEFORE, TRIGGER_VARIABLE_ANCHOR_AFTER, 'TriggerVariable');
|
|
246
|
+
text = r.contents;
|
|
247
|
+
if (r.changed)
|
|
248
|
+
changed = true;
|
|
249
|
+
}
|
|
250
|
+
if (!text.includes("readOtherTemplate<TriggerVariable['resend-invite']>")) {
|
|
251
|
+
const r = replaceExactlyOnceOrSkip(EMAIL_TEMPLATES_INDEX, text, TEMPLATES_ANCHOR_BEFORE, TEMPLATES_ANCHOR_AFTER, '`templates`');
|
|
252
|
+
text = r.contents;
|
|
253
|
+
if (r.changed)
|
|
254
|
+
changed = true;
|
|
255
|
+
}
|
|
256
|
+
if (changed) {
|
|
257
|
+
(0, fs_1.writeFileSync)(full, text);
|
|
258
|
+
}
|
|
259
|
+
return changed;
|
|
260
|
+
}
|
|
261
|
+
function main() {
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
// eslint-disable-next-line no-console
|
|
264
|
+
console.log('Adding RESEND_INVITE notification wiring…');
|
|
265
|
+
const touched = [];
|
|
266
|
+
if (patchEmailTemplatesIndex())
|
|
267
|
+
touched.push(EMAIL_TEMPLATES_INDEX);
|
|
268
|
+
/* handler */
|
|
269
|
+
const handlerPath = path_1.default.join(process.cwd(), NOTIFICATION_HANDLER);
|
|
270
|
+
if ((0, fs_1.existsSync)(handlerPath)) {
|
|
271
|
+
let t = (0, fs_1.readFileSync)(handlerPath, 'utf8');
|
|
272
|
+
if (!t.includes('TriggerEvent.RESEND_INVITE') &&
|
|
273
|
+
t.includes(HANDLER_ANCHOR_BEFORE)) {
|
|
274
|
+
const count = t.split(HANDLER_ANCHOR_BEFORE).length - 1;
|
|
275
|
+
if (count === 1) {
|
|
276
|
+
t = t.replace(HANDLER_ANCHOR_BEFORE, HANDLER_ANCHOR_AFTER);
|
|
277
|
+
(0, fs_1.writeFileSync)(handlerPath, t);
|
|
278
|
+
touched.push(NOTIFICATION_HANDLER);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/* routes */
|
|
283
|
+
const routesPath = path_1.default.join(process.cwd(), USER_NOTIFICATION_ROUTES);
|
|
284
|
+
if ((0, fs_1.existsSync)(routesPath)) {
|
|
285
|
+
let t = (0, fs_1.readFileSync)(routesPath, 'utf8');
|
|
286
|
+
if (!t.includes(`/triggers/user/resend-invite`) && t.includes(ROUTES_ANCHOR_BEFORE)) {
|
|
287
|
+
const count = t.split(ROUTES_ANCHOR_BEFORE).length - 1;
|
|
288
|
+
if (count === 1) {
|
|
289
|
+
t = t.replace(ROUTES_ANCHOR_BEFORE, ROUTES_ANCHOR_AFTER);
|
|
290
|
+
(0, fs_1.writeFileSync)(routesPath, t);
|
|
291
|
+
touched.push(USER_NOTIFICATION_ROUTES);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/* sms-service */
|
|
296
|
+
const smsPath = path_1.default.join(process.cwd(), SMS_SERVICE);
|
|
297
|
+
if ((0, fs_1.existsSync)(smsPath)) {
|
|
298
|
+
let t = (0, fs_1.readFileSync)(smsPath, 'utf8');
|
|
299
|
+
let smsChanged = false;
|
|
300
|
+
if (!t.includes(`resendInviteNotification`)) {
|
|
301
|
+
const n = t.split(SMS_OTHER_BEFORE).length - 1;
|
|
302
|
+
if (n === 1) {
|
|
303
|
+
t = t.replace(SMS_OTHER_BEFORE, SMS_OTHER_AFTER);
|
|
304
|
+
smsChanged = true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (!t.includes(`['resend-invite']`)) {
|
|
308
|
+
const n = t.split(SMS_TRIGGER_BEFORE).length - 1;
|
|
309
|
+
if (n === 1) {
|
|
310
|
+
t = t.replace(SMS_TRIGGER_BEFORE, SMS_TRIGGER_AFTER);
|
|
311
|
+
smsChanged = true;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
if (smsChanged) {
|
|
315
|
+
(0, fs_1.writeFileSync)(smsPath, t);
|
|
316
|
+
touched.push(SMS_SERVICE);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
/* csv */
|
|
320
|
+
const csvPath = path_1.default.join(process.cwd(), NOTIFICATION_CSV);
|
|
321
|
+
if ((0, fs_1.existsSync)(csvPath)) {
|
|
322
|
+
let t = (0, fs_1.readFileSync)(csvPath, 'utf8');
|
|
323
|
+
if (!/^resendInviteNotification,/m.test(t)) {
|
|
324
|
+
if (!t.endsWith('\n'))
|
|
325
|
+
t += '\n';
|
|
326
|
+
(0, fs_1.writeFileSync)(csvPath, t + CSV_ROW);
|
|
327
|
+
touched.push(NOTIFICATION_CSV);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/* html */
|
|
331
|
+
const htmlPath = path_1.default.join(process.cwd(), RESEND_INVITE_HTML);
|
|
332
|
+
(0, fs_1.mkdirSync)(path_1.default.dirname(htmlPath), { recursive: true });
|
|
333
|
+
if (!(0, fs_1.existsSync)(htmlPath)) {
|
|
334
|
+
(0, fs_1.writeFileSync)(htmlPath, RESEND_INVITE_HTML_CONTENT);
|
|
335
|
+
touched.push(RESEND_INVITE_HTML);
|
|
336
|
+
}
|
|
337
|
+
if (touched.length === 0) {
|
|
338
|
+
// eslint-disable-next-line no-console
|
|
339
|
+
console.log(' Nothing to update (already present or anchors not found).');
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
// eslint-disable-next-line no-console
|
|
343
|
+
console.log(` Updated:\n${touched.map((f) => ` - ${f}`).join('\n')}`);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
|
|
2
|
+
export declare const UPSTREAM_BRANCH = "develop";
|
|
3
|
+
/**
|
|
4
|
+
* Runs a git command in the country config working directory.
|
|
5
|
+
*
|
|
6
|
+
* By default stderr is inherited so the user sees progress output from
|
|
7
|
+
* long-running commands (e.g. `git fetch`). Pass `silent: true` to suppress
|
|
8
|
+
* both stdout and stderr when you only care about the exit code.
|
|
9
|
+
*/
|
|
10
|
+
export declare function runGit(args: string[], { silent }?: {
|
|
11
|
+
silent?: boolean;
|
|
12
|
+
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* Runs a git command and returns true on success, false on failure.
|
|
15
|
+
* Stderr/stdout are suppressed — use only when the exit code is the only
|
|
16
|
+
* signal you care about.
|
|
17
|
+
*/
|
|
18
|
+
export declare function tryGit(args: string[]): boolean;
|
|
19
|
+
export declare function assertIsGitRepo(): void;
|
|
1
20
|
declare function main(): Promise<void>;
|
|
2
21
|
export { main };
|
|
3
22
|
//# sourceMappingURL=checkout-upstream-files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAG1D,eAAO,MAAM,eAAe,YAAY,CAAA;AAcxC;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -19,6 +19,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.UPSTREAM_BRANCH = exports.UPSTREAM_URL = void 0;
|
|
23
|
+
exports.runGit = runGit;
|
|
24
|
+
exports.tryGit = tryGit;
|
|
25
|
+
exports.assertIsGitRepo = assertIsGitRepo;
|
|
22
26
|
exports.main = main;
|
|
23
27
|
/**
|
|
24
28
|
* Codemod: Replace selected files with their upstream v2.0 versions from
|
|
@@ -54,16 +58,16 @@ exports.main = main;
|
|
|
54
58
|
* - Requires the country config working directory to be a git repo.
|
|
55
59
|
*/
|
|
56
60
|
const child_process_1 = require("child_process");
|
|
57
|
-
|
|
58
|
-
const UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
|
|
61
|
+
exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
|
|
59
62
|
// @TODO: This needs to be changed to 'release-v2.0.0' once the branch is created
|
|
60
|
-
|
|
63
|
+
exports.UPSTREAM_BRANCH = 'develop';
|
|
61
64
|
// Remote name used only for the duration of this codemod. Prefixed to avoid
|
|
62
65
|
// clashing with remotes the user may have (origin, upstream, etc.).
|
|
63
66
|
const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
|
|
64
67
|
const FILES_TO_CHECKOUT = [
|
|
65
|
-
'
|
|
66
|
-
'
|
|
68
|
+
'src/analytics/analytics.ts',
|
|
69
|
+
'Dockerfile',
|
|
70
|
+
'Dockerfile.assets'
|
|
67
71
|
];
|
|
68
72
|
// ─── Git helpers ─────────────────────────────────────────────────────────────
|
|
69
73
|
/**
|
|
@@ -75,7 +79,7 @@ const FILES_TO_CHECKOUT = [
|
|
|
75
79
|
*/
|
|
76
80
|
function runGit(args, { silent = false } = {}) {
|
|
77
81
|
return (0, child_process_1.execFileSync)('git', args, {
|
|
78
|
-
cwd:
|
|
82
|
+
cwd: process.cwd(),
|
|
79
83
|
encoding: 'utf8',
|
|
80
84
|
stdio: silent ? ['ignore', 'pipe', 'pipe'] : ['ignore', 'pipe', 'inherit']
|
|
81
85
|
});
|
|
@@ -96,22 +100,22 @@ function tryGit(args) {
|
|
|
96
100
|
}
|
|
97
101
|
function assertIsGitRepo() {
|
|
98
102
|
if (!tryGit(['rev-parse', '--is-inside-work-tree'])) {
|
|
99
|
-
throw new Error(
|
|
103
|
+
throw new Error(`${process.cwd()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`);
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
103
107
|
function main() {
|
|
104
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
-
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...\n`);
|
|
109
|
+
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${exports.UPSTREAM_URL}@${exports.UPSTREAM_BRANCH}...\n`);
|
|
106
110
|
assertIsGitRepo();
|
|
107
111
|
// Best-effort cleanup of a stale temp remote from a previous aborted run.
|
|
108
112
|
tryGit(['remote', 'remove', TEMP_REMOTE]);
|
|
109
113
|
try {
|
|
110
|
-
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${UPSTREAM_URL}`);
|
|
111
|
-
runGit(['remote', 'add', TEMP_REMOTE, UPSTREAM_URL], { silent: true });
|
|
112
|
-
console.log(` Fetching ${TEMP_REMOTE}/${UPSTREAM_BRANCH} (depth 1)...`);
|
|
113
|
-
runGit(['fetch', '--depth=1', TEMP_REMOTE, UPSTREAM_BRANCH]);
|
|
114
|
-
const ref = `${TEMP_REMOTE}/${UPSTREAM_BRANCH}`;
|
|
114
|
+
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${exports.UPSTREAM_URL}`);
|
|
115
|
+
runGit(['remote', 'add', TEMP_REMOTE, exports.UPSTREAM_URL], { silent: true });
|
|
116
|
+
console.log(` Fetching ${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH} (depth 1)...`);
|
|
117
|
+
runGit(['fetch', '--depth=1', TEMP_REMOTE, exports.UPSTREAM_BRANCH]);
|
|
118
|
+
const ref = `${TEMP_REMOTE}/${exports.UPSTREAM_BRANCH}`;
|
|
115
119
|
const missing = [];
|
|
116
120
|
let checkedOut = 0;
|
|
117
121
|
for (const file of FILES_TO_CHECKOUT) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-config-files-to-ts.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-config-files-to-ts.ts"],"names":[],"mappings":"AAuuBA,wBAAsB,IAAI,kBAyPzB"}
|
|
@@ -87,7 +87,6 @@ exports.main = main;
|
|
|
87
87
|
const fs = __importStar(require("fs"));
|
|
88
88
|
const ts_morph_1 = require("ts-morph");
|
|
89
89
|
const path_1 = __importDefault(require("path"));
|
|
90
|
-
const _1 = require(".");
|
|
91
90
|
// ─── Schema-valid keys per config type ───────────────────────────────────────
|
|
92
91
|
const CLIENT_VALID_KEYS = new Set([
|
|
93
92
|
'COUNTRY',
|
|
@@ -634,8 +633,8 @@ function ensureJoinImport(sf) {
|
|
|
634
633
|
function main() {
|
|
635
634
|
return __awaiter(this, void 0, void 0, function* () {
|
|
636
635
|
var _a;
|
|
637
|
-
const srcDir = path_1.default.join(
|
|
638
|
-
const relCwd = (fp) => path_1.default.relative(
|
|
636
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
637
|
+
const relCwd = (fp) => path_1.default.relative(process.cwd(), fp);
|
|
639
638
|
// ── Phase 1: Convert JS config files to TypeScript ────────────────────────
|
|
640
639
|
console.log('Phase 1: Converting JS config files to TypeScript...\n');
|
|
641
640
|
let convertedCount = 0;
|
|
@@ -741,7 +740,7 @@ function main() {
|
|
|
741
740
|
if (/\bjoin\s*\(/.test(adjustedValue)) {
|
|
742
741
|
ensureJoinImport(sf);
|
|
743
742
|
}
|
|
744
|
-
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(
|
|
743
|
+
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
|
|
745
744
|
filesToSaveAfterInlining.add(sf);
|
|
746
745
|
madeReplacement = true;
|
|
747
746
|
break; // restart — tree has changed
|
|
@@ -752,7 +751,7 @@ function main() {
|
|
|
752
751
|
// Persist files that received inline replacements
|
|
753
752
|
for (const sf of Array.from(filesToSaveAfterInlining)) {
|
|
754
753
|
yield sf.save();
|
|
755
|
-
console.log(` Saved (inlined): ${path_1.default.relative(
|
|
754
|
+
console.log(` Saved (inlined): ${path_1.default.relative(process.cwd(), sf.getFilePath())}`);
|
|
756
755
|
}
|
|
757
756
|
// Remove in reverse order to avoid index shifting
|
|
758
757
|
for (const prop of [...propsToRemove].reverse()) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convert-paragraph-to-heading.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/convert-paragraph-to-heading.ts"],"names":[],"mappings":"AAsJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -42,7 +42,6 @@ exports.main = main;
|
|
|
42
42
|
*/
|
|
43
43
|
const ts_morph_1 = require("ts-morph");
|
|
44
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
-
const _1 = require(".");
|
|
46
45
|
const FIELD_TYPE_ENUM_NAME = 'FieldType';
|
|
47
46
|
const PARAGRAPH_MEMBER_NAME = 'PARAGRAPH';
|
|
48
47
|
const HEADING_MEMBER_NAME = 'HEADING';
|
|
@@ -112,18 +111,18 @@ function processFile(filePath, project) {
|
|
|
112
111
|
const result = transformParagraphField(obj);
|
|
113
112
|
if (result === 'converted-to-heading') {
|
|
114
113
|
changedCount++;
|
|
115
|
-
console.log(` [${path_1.default.relative(
|
|
114
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
|
|
116
115
|
}
|
|
117
116
|
else if (result === 'removed-font-variant') {
|
|
118
117
|
changedCount++;
|
|
119
|
-
console.log(` [${path_1.default.relative(
|
|
118
|
+
console.log(` [${path_1.default.relative(process.cwd(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
return changedCount;
|
|
123
122
|
}
|
|
124
123
|
function main() {
|
|
125
124
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const srcDir = path_1.default.join(
|
|
125
|
+
const srcDir = path_1.default.join(process.cwd(), 'src');
|
|
127
126
|
console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}\n`);
|
|
128
127
|
const project = new ts_morph_1.Project({
|
|
129
128
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -152,7 +151,7 @@ function main() {
|
|
|
152
151
|
for (const filePath of modifiedFiles) {
|
|
153
152
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
154
153
|
yield sourceFile.save();
|
|
155
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
154
|
+
console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
|
|
156
155
|
}
|
|
157
156
|
console.log(`\nDone. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
|
|
158
157
|
});
|