@opencrvs/toolkit 2.0.0-rc.b63fd2e → 2.0.0-rc.bee2b7b
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/application-config/index.js +36 -7
- package/dist/cli.js +178 -1390
- package/dist/commons/events/locations.d.ts +17 -1
- package/dist/conditionals/index.js +36 -7
- package/dist/events/index.js +74 -7
- 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 +4 -3
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +0 -19
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +13 -17
- 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 +5 -4
- package/dist/migrations/v2.0/convert-paragraph-to-heading.d.ts.map +1 -1
- package/dist/migrations/v2.0/convert-paragraph-to-heading.js +5 -4
- package/dist/migrations/v2.0/create-events-index.d.ts.map +1 -1
- package/dist/migrations/v2.0/create-events-index.js +2 -1
- package/dist/migrations/v2.0/index.d.ts +4 -8
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +175 -1358
- 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 +6 -5
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +7 -6
- 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 +4 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +4 -3
- package/dist/migrations/v2.0/remove-delete-actions.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-delete-actions.js +4 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +3 -2
- package/dist/migrations/v2.0/remove-deprecated-imports.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-deprecated-imports.js +4 -3
- package/dist/migrations/v2.0/remove-hearth-migrations.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-hearth-migrations.js +2 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.d.ts.map +1 -1
- package/dist/migrations/v2.0/remove-pending-certification-flag.js +4 -3
- 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 +4 -3
- package/dist/migrations/v2.0/rename-api-paths.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-api-paths.js +4 -3
- package/dist/migrations/v2.0/rename-location-parent-id.d.ts.map +1 -1
- package/dist/migrations/v2.0/rename-location-parent-id.js +4 -3
- package/dist/migrations/v2.0/simplify-analytics-precalculations.d.ts.map +1 -1
- package/dist/migrations/v2.0/simplify-analytics-precalculations.js +2 -1
- package/dist/notification/index.js +36 -7
- package/dist/scopes/index.d.ts +80 -10
- package/dist/scopes/index.js +42 -8
- package/opencrvs-toolkit-2.0.0-rc.bee2b7b.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts +0 -3
- package/dist/migrations/v2.0/add-resend-invite-notification.d.ts.map +0 -1
- package/dist/migrations/v2.0/add-resend-invite-notification.js +0 -373
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +0 -3
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +0 -77
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +0 -3
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +0 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +0 -221
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-application-config-url.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-application-config-url.js +0 -342
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts +0 -3
- package/dist/migrations/v2.0/remove-fhir-url-helpers.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-fhir-url-helpers.js +0 -163
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts +0 -3
- package/dist/migrations/v2.0/remove-old-statistics-service.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-old-statistics-service.js +0 -356
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts +0 -3
- package/dist/migrations/v2.0/remove-unused-environment-variables.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-unused-environment-variables.js +0 -186
- package/dist/migrations/v2.0/update-package-json.d.ts +0 -3
- package/dist/migrations/v2.0/update-package-json.d.ts.map +0 -1
- package/dist/migrations/v2.0/update-package-json.js +0 -105
- package/opencrvs-toolkit-2.0.0-rc.b63fd2e.tgz +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { UUID } from '../uuid';
|
|
1
2
|
import * as z from 'zod/v4';
|
|
2
3
|
import { EventIndex } from './EventIndex';
|
|
3
4
|
import { ActionCreationMetadata, RegistrationCreationMetadata } from './EventMetadata';
|
|
4
|
-
import { RecordScopeV2 } from '../scopes';
|
|
5
|
+
import { RecordScopeV2, UserScopeV2 } from '../scopes';
|
|
5
6
|
import { SystemContext, UserContext } from '../users/User';
|
|
6
7
|
/** @deprecated Moving on, location types are arbitrary and defined by the country config. */
|
|
7
8
|
export declare const LocationTypeV1: z.ZodEnum<{
|
|
@@ -51,6 +52,21 @@ export type EventIndexWithAdministrativeHierarchy = Omit<ToArrayFields<EventInde
|
|
|
51
52
|
*
|
|
52
53
|
*/
|
|
53
54
|
export declare function canAccessEventWithScope(event: Partial<EventIndexWithAdministrativeHierarchy>, scope: RecordScopeV2, user: UserContext | SystemContext, customActionType?: string): boolean;
|
|
55
|
+
export type UserWithResolvedHierarchy = {
|
|
56
|
+
role: string;
|
|
57
|
+
administrativeHierarchy: UUID[];
|
|
58
|
+
primaryOfficeId: UUID;
|
|
59
|
+
};
|
|
60
|
+
export declare function canAccessUserWithScope({ userToAccess, scope, user }: {
|
|
61
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
62
|
+
scope: UserScopeV2;
|
|
63
|
+
user: UserContext | SystemContext;
|
|
64
|
+
}): boolean;
|
|
65
|
+
export declare function canAccessOtherUserWithScopes({ scopes, userToAccess, user }: {
|
|
66
|
+
scopes: UserScopeV2[];
|
|
67
|
+
userToAccess: UserWithResolvedHierarchy;
|
|
68
|
+
user: UserContext | SystemContext;
|
|
69
|
+
}): boolean;
|
|
54
70
|
/**
|
|
55
71
|
* Given indexed event and list of resolved scopes, determine if any of the scopes allow access to the event.
|
|
56
72
|
*
|
|
@@ -182,6 +182,10 @@ var scopeByEvent = z6.preprocess(
|
|
|
182
182
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
183
183
|
z6.array(z6.string()).optional()
|
|
184
184
|
).describe("Event type, e.g. birth, death");
|
|
185
|
+
var userRole = z6.preprocess(
|
|
186
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
187
|
+
z6.array(z6.string()).optional()
|
|
188
|
+
).describe("User role, e.g. admin, field agent");
|
|
185
189
|
var scopeOptionsPlaceEvent = z6.object({
|
|
186
190
|
event: scopeByEvent,
|
|
187
191
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -286,6 +290,33 @@ var RecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
286
290
|
]).describe(
|
|
287
291
|
"Scopes used to check user's permission to perform actions on a record."
|
|
288
292
|
);
|
|
293
|
+
var SystemScopeType = z6.enum([
|
|
294
|
+
"organisation.read-locations",
|
|
295
|
+
"user.read",
|
|
296
|
+
"user.create",
|
|
297
|
+
"user.edit"
|
|
298
|
+
]);
|
|
299
|
+
var UserScopeType = SystemScopeType.extract([
|
|
300
|
+
"user.read",
|
|
301
|
+
"user.create",
|
|
302
|
+
"user.edit"
|
|
303
|
+
]);
|
|
304
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
305
|
+
var UserScopeV2 = z6.discriminatedUnion("type", [
|
|
306
|
+
z6.object({
|
|
307
|
+
type: ScopesWithRoleOption,
|
|
308
|
+
options: z6.object({
|
|
309
|
+
accessLevel: JurisdictionFilter.optional(),
|
|
310
|
+
role: userRole.optional()
|
|
311
|
+
}).optional()
|
|
312
|
+
}),
|
|
313
|
+
z6.object({
|
|
314
|
+
type: UserScopeType.extract(["user.read"]),
|
|
315
|
+
options: z6.object({
|
|
316
|
+
accessLevel: JurisdictionFilter.optional()
|
|
317
|
+
}).optional()
|
|
318
|
+
})
|
|
319
|
+
]);
|
|
289
320
|
var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
290
321
|
z6.object({
|
|
291
322
|
type: ScopesWithPlaceEventOptions,
|
|
@@ -306,16 +337,14 @@ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
|
|
|
306
337
|
}).optional()
|
|
307
338
|
})
|
|
308
339
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
309
|
-
var SystemScopeType = z6.enum([
|
|
310
|
-
"organisation.read-locations",
|
|
311
|
-
"user.read",
|
|
312
|
-
"user.create",
|
|
313
|
-
"user.edit"
|
|
314
|
-
]);
|
|
315
340
|
var Scope2 = z6.discriminatedUnion("type", [
|
|
316
341
|
z6.object({ type: PlainScopeType }),
|
|
317
342
|
...RecordScopeV2.options,
|
|
318
|
-
|
|
343
|
+
...UserScopeV2.options,
|
|
344
|
+
z6.object({
|
|
345
|
+
type: z6.literal("organisation.read-locations"),
|
|
346
|
+
options: AccessLevelOptions.optional()
|
|
347
|
+
}),
|
|
319
348
|
z6.object({
|
|
320
349
|
type: z6.literal("workqueue"),
|
|
321
350
|
options: WorkqueueOrDashboardOptions
|
package/dist/events/index.js
CHANGED
|
@@ -243,6 +243,8 @@ __export(events_exports, {
|
|
|
243
243
|
areConditionsMet: () => areConditionsMet,
|
|
244
244
|
buildFormState: () => buildFormState,
|
|
245
245
|
canAccessEventWithScope: () => canAccessEventWithScope,
|
|
246
|
+
canAccessOtherUserWithScopes: () => canAccessOtherUserWithScopes,
|
|
247
|
+
canAccessUserWithScope: () => canAccessUserWithScope,
|
|
246
248
|
compositeFieldTypes: () => compositeFieldTypes,
|
|
247
249
|
createEmptyDraft: () => createEmptyDraft,
|
|
248
250
|
createFieldConditionals: () => createFieldConditionals,
|
|
@@ -489,6 +491,10 @@ var scopeByEvent = z2.preprocess(
|
|
|
489
491
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
490
492
|
z2.array(z2.string()).optional()
|
|
491
493
|
).describe("Event type, e.g. birth, death");
|
|
494
|
+
var userRole = z2.preprocess(
|
|
495
|
+
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
496
|
+
z2.array(z2.string()).optional()
|
|
497
|
+
).describe("User role, e.g. admin, field agent");
|
|
492
498
|
var scopeOptionsPlaceEvent = z2.object({
|
|
493
499
|
event: scopeByEvent,
|
|
494
500
|
placeOfEvent: JurisdictionFilter.optional()
|
|
@@ -593,6 +599,36 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
593
599
|
]).describe(
|
|
594
600
|
"Scopes used to check user's permission to perform actions on a record."
|
|
595
601
|
);
|
|
602
|
+
var SystemScopeType = z2.enum([
|
|
603
|
+
"organisation.read-locations",
|
|
604
|
+
"user.read",
|
|
605
|
+
"user.create",
|
|
606
|
+
"user.edit"
|
|
607
|
+
]);
|
|
608
|
+
var UserScopeType = SystemScopeType.extract([
|
|
609
|
+
"user.read",
|
|
610
|
+
"user.create",
|
|
611
|
+
"user.edit"
|
|
612
|
+
]);
|
|
613
|
+
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
614
|
+
var UserScopeV2 = z2.discriminatedUnion("type", [
|
|
615
|
+
z2.object({
|
|
616
|
+
type: ScopesWithRoleOption,
|
|
617
|
+
options: z2.object({
|
|
618
|
+
accessLevel: JurisdictionFilter.optional(),
|
|
619
|
+
role: userRole.optional()
|
|
620
|
+
}).optional()
|
|
621
|
+
}),
|
|
622
|
+
z2.object({
|
|
623
|
+
type: UserScopeType.extract(["user.read"]),
|
|
624
|
+
options: z2.object({
|
|
625
|
+
accessLevel: JurisdictionFilter.optional()
|
|
626
|
+
}).optional()
|
|
627
|
+
})
|
|
628
|
+
]);
|
|
629
|
+
function scopeUsesRoleOptions(scope) {
|
|
630
|
+
return ScopesWithRoleOption?.options.some((opt) => opt === scope.type);
|
|
631
|
+
}
|
|
596
632
|
function scopeUsesDeclaredOptions(scope) {
|
|
597
633
|
return !ScopesWithPlaceEventOptions.options.some((opt) => opt === scope.type);
|
|
598
634
|
}
|
|
@@ -625,16 +661,14 @@ var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
|
|
|
625
661
|
}).optional()
|
|
626
662
|
})
|
|
627
663
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
628
|
-
var SystemScopeType = z2.enum([
|
|
629
|
-
"organisation.read-locations",
|
|
630
|
-
"user.read",
|
|
631
|
-
"user.create",
|
|
632
|
-
"user.edit"
|
|
633
|
-
]);
|
|
634
664
|
var Scope = z2.discriminatedUnion("type", [
|
|
635
665
|
z2.object({ type: PlainScopeType }),
|
|
636
666
|
...RecordScopeV2.options,
|
|
637
|
-
|
|
667
|
+
...UserScopeV2.options,
|
|
668
|
+
z2.object({
|
|
669
|
+
type: z2.literal("organisation.read-locations"),
|
|
670
|
+
options: AccessLevelOptions.optional()
|
|
671
|
+
}),
|
|
638
672
|
z2.object({
|
|
639
673
|
type: z2.literal("workqueue"),
|
|
640
674
|
options: WorkqueueOrDashboardOptions
|
|
@@ -9930,6 +9964,39 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
|
|
|
9930
9964
|
}
|
|
9931
9965
|
return true;
|
|
9932
9966
|
}
|
|
9967
|
+
function canAccessUserWithScope({
|
|
9968
|
+
userToAccess,
|
|
9969
|
+
scope,
|
|
9970
|
+
user: user2
|
|
9971
|
+
}) {
|
|
9972
|
+
const opts = scope.options;
|
|
9973
|
+
const hasSameOffice = user2.primaryOfficeId === userToAccess.primaryOfficeId;
|
|
9974
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.location && !hasSameOffice) {
|
|
9975
|
+
return false;
|
|
9976
|
+
}
|
|
9977
|
+
const hasAdministrativeAreaInHierarchy = userToAccess.administrativeHierarchy.some(
|
|
9978
|
+
(id) => user2.administrativeAreaId === id
|
|
9979
|
+
) || user2.administrativeAreaId === null;
|
|
9980
|
+
if (opts?.accessLevel === JurisdictionFilter.enum.administrativeArea && !hasAdministrativeAreaInHierarchy) {
|
|
9981
|
+
return false;
|
|
9982
|
+
}
|
|
9983
|
+
if (scopeUsesRoleOptions(scope)) {
|
|
9984
|
+
const { options } = scope;
|
|
9985
|
+
if (options?.role && !options.role.includes(userToAccess.role)) {
|
|
9986
|
+
return false;
|
|
9987
|
+
}
|
|
9988
|
+
}
|
|
9989
|
+
return true;
|
|
9990
|
+
}
|
|
9991
|
+
function canAccessOtherUserWithScopes({
|
|
9992
|
+
scopes,
|
|
9993
|
+
userToAccess,
|
|
9994
|
+
user: user2
|
|
9995
|
+
}) {
|
|
9996
|
+
return scopes.some(
|
|
9997
|
+
(scope) => canAccessUserWithScope({ userToAccess, scope, user: user2 })
|
|
9998
|
+
);
|
|
9999
|
+
}
|
|
9933
10000
|
function userCanAccessEventWithScopes(event2, scopes, user2, customActionType) {
|
|
9934
10001
|
return scopes.some(
|
|
9935
10002
|
(scope) => canAccessEventWithScope(event2, scope, user2, customActionType)
|
|
@@ -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":"AA6aA,iBAAe,IAAI,kBAiDlB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -48,6 +48,7 @@ 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(".");
|
|
51
52
|
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
52
53
|
const DEFINE_WORKQUEUES_NAME = 'defineWorkqueues';
|
|
53
54
|
const ACTIONS_PROPERTY_NAME = 'actions';
|
|
@@ -317,7 +318,7 @@ function processFile(filePath, project) {
|
|
|
317
318
|
if (!sourceFile)
|
|
318
319
|
return 0;
|
|
319
320
|
let totalChanges = 0;
|
|
320
|
-
const relPath = path_1.default.relative(
|
|
321
|
+
const relPath = path_1.default.relative((0, _1.getCwd)(), filePath);
|
|
321
322
|
const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
|
|
322
323
|
for (const call of callExpressions) {
|
|
323
324
|
const expression = call.getExpression();
|
|
@@ -368,7 +369,7 @@ function processFile(filePath, project) {
|
|
|
368
369
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
369
370
|
function main() {
|
|
370
371
|
return __awaiter(this, void 0, void 0, function* () {
|
|
371
|
-
const srcDir = path_1.default.join(
|
|
372
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
372
373
|
console.log(`Scanning for birth defineConfig and PRINT_CERTIFICATE workqueues in: ${srcDir}\n`);
|
|
373
374
|
const project = new ts_morph_1.Project({
|
|
374
375
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -397,7 +398,7 @@ function main() {
|
|
|
397
398
|
for (const filePath of modifiedFiles) {
|
|
398
399
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
399
400
|
yield sourceFile.save();
|
|
400
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
401
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
401
402
|
}
|
|
402
403
|
console.log(`\nDone. Applied ${totalChanges} change(s) across ${modifiedFiles.length} file(s).`);
|
|
403
404
|
});
|
|
@@ -1,22 +1,3 @@
|
|
|
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;
|
|
20
1
|
declare function main(): Promise<void>;
|
|
21
2
|
export { main };
|
|
22
3
|
//# 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":"AA0GA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -19,10 +19,6 @@ 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;
|
|
26
22
|
exports.main = main;
|
|
27
23
|
/**
|
|
28
24
|
* Codemod: Replace selected files with their upstream v2.0 versions from
|
|
@@ -58,16 +54,16 @@ exports.main = main;
|
|
|
58
54
|
* - Requires the country config working directory to be a git repo.
|
|
59
55
|
*/
|
|
60
56
|
const child_process_1 = require("child_process");
|
|
61
|
-
|
|
57
|
+
const _1 = require(".");
|
|
58
|
+
const UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
|
|
62
59
|
// @TODO: This needs to be changed to 'release-v2.0.0' once the branch is created
|
|
63
|
-
|
|
60
|
+
const UPSTREAM_BRANCH = 'develop';
|
|
64
61
|
// Remote name used only for the duration of this codemod. Prefixed to avoid
|
|
65
62
|
// clashing with remotes the user may have (origin, upstream, etc.).
|
|
66
63
|
const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
|
|
67
64
|
const FILES_TO_CHECKOUT = [
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'Dockerfile.assets'
|
|
65
|
+
'infrastructure/postgres/setup-analytics.sh',
|
|
66
|
+
'src/analytics/analytics.ts'
|
|
71
67
|
];
|
|
72
68
|
// ─── Git helpers ─────────────────────────────────────────────────────────────
|
|
73
69
|
/**
|
|
@@ -79,7 +75,7 @@ const FILES_TO_CHECKOUT = [
|
|
|
79
75
|
*/
|
|
80
76
|
function runGit(args, { silent = false } = {}) {
|
|
81
77
|
return (0, child_process_1.execFileSync)('git', args, {
|
|
82
|
-
cwd:
|
|
78
|
+
cwd: (0, _1.getCwd)(),
|
|
83
79
|
encoding: 'utf8',
|
|
84
80
|
stdio: silent ? ['ignore', 'pipe', 'pipe'] : ['ignore', 'pipe', 'inherit']
|
|
85
81
|
});
|
|
@@ -100,22 +96,22 @@ function tryGit(args) {
|
|
|
100
96
|
}
|
|
101
97
|
function assertIsGitRepo() {
|
|
102
98
|
if (!tryGit(['rev-parse', '--is-inside-work-tree'])) {
|
|
103
|
-
throw new Error(
|
|
99
|
+
throw new Error(`checkout-upstream-files: ${(0, _1.getCwd)()} is not a git repository. Initialise git (or run the upgrade inside a git checkout) before re-running.`);
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
107
103
|
function main() {
|
|
108
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${
|
|
105
|
+
console.log(`Checking out ${FILES_TO_CHECKOUT.length} file(s) from ${UPSTREAM_URL}@${UPSTREAM_BRANCH}...\n`);
|
|
110
106
|
assertIsGitRepo();
|
|
111
107
|
// Best-effort cleanup of a stale temp remote from a previous aborted run.
|
|
112
108
|
tryGit(['remote', 'remove', TEMP_REMOTE]);
|
|
113
109
|
try {
|
|
114
|
-
console.log(` Adding temporary remote '${TEMP_REMOTE}' → ${
|
|
115
|
-
runGit(['remote', 'add', TEMP_REMOTE,
|
|
116
|
-
console.log(` Fetching ${TEMP_REMOTE}/${
|
|
117
|
-
runGit(['fetch', '--depth=1', TEMP_REMOTE,
|
|
118
|
-
const ref = `${TEMP_REMOTE}/${
|
|
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}`;
|
|
119
115
|
const missing = [];
|
|
120
116
|
let checkedOut = 0;
|
|
121
117
|
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":"AAyuBA,wBAAsB,IAAI,kBAyPzB"}
|
|
@@ -87,6 +87,7 @@ 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(".");
|
|
90
91
|
// ─── Schema-valid keys per config type ───────────────────────────────────────
|
|
91
92
|
const CLIENT_VALID_KEYS = new Set([
|
|
92
93
|
'COUNTRY',
|
|
@@ -633,8 +634,8 @@ function ensureJoinImport(sf) {
|
|
|
633
634
|
function main() {
|
|
634
635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
635
636
|
var _a;
|
|
636
|
-
const srcDir = path_1.default.join(
|
|
637
|
-
const relCwd = (fp) => path_1.default.relative(
|
|
637
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
638
|
+
const relCwd = (fp) => path_1.default.relative((0, _1.getCwd)(), fp);
|
|
638
639
|
// ── Phase 1: Convert JS config files to TypeScript ────────────────────────
|
|
639
640
|
console.log('Phase 1: Converting JS config files to TypeScript...\n');
|
|
640
641
|
let convertedCount = 0;
|
|
@@ -740,7 +741,7 @@ function main() {
|
|
|
740
741
|
if (/\bjoin\s*\(/.test(adjustedValue)) {
|
|
741
742
|
ensureJoinImport(sf);
|
|
742
743
|
}
|
|
743
|
-
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative(
|
|
744
|
+
console.log(` Inlined applicationConfig.${accessPath.join('.')} → ${adjustedValue} in ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
|
|
744
745
|
filesToSaveAfterInlining.add(sf);
|
|
745
746
|
madeReplacement = true;
|
|
746
747
|
break; // restart — tree has changed
|
|
@@ -751,7 +752,7 @@ function main() {
|
|
|
751
752
|
// Persist files that received inline replacements
|
|
752
753
|
for (const sf of Array.from(filesToSaveAfterInlining)) {
|
|
753
754
|
yield sf.save();
|
|
754
|
-
console.log(` Saved (inlined): ${path_1.default.relative(
|
|
755
|
+
console.log(` Saved (inlined): ${path_1.default.relative((0, _1.getCwd)(), sf.getFilePath())}`);
|
|
755
756
|
}
|
|
756
757
|
// Remove in reverse order to avoid index shifting
|
|
757
758
|
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":"AAwJA,iBAAe,IAAI,kBA6ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -42,6 +42,7 @@ 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(".");
|
|
45
46
|
const FIELD_TYPE_ENUM_NAME = 'FieldType';
|
|
46
47
|
const PARAGRAPH_MEMBER_NAME = 'PARAGRAPH';
|
|
47
48
|
const HEADING_MEMBER_NAME = 'HEADING';
|
|
@@ -111,18 +112,18 @@ function processFile(filePath, project) {
|
|
|
111
112
|
const result = transformParagraphField(obj);
|
|
112
113
|
if (result === 'converted-to-heading') {
|
|
113
114
|
changedCount++;
|
|
114
|
-
console.log(` [${path_1.default.relative(
|
|
115
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Converted PARAGRAPH with heading fontVariant to HEADING`);
|
|
115
116
|
}
|
|
116
117
|
else if (result === 'removed-font-variant') {
|
|
117
118
|
changedCount++;
|
|
118
|
-
console.log(` [${path_1.default.relative(
|
|
119
|
+
console.log(` [${path_1.default.relative((0, _1.getCwd)(), filePath)}] Removed non-heading fontVariant from PARAGRAPH`);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
return changedCount;
|
|
122
123
|
}
|
|
123
124
|
function main() {
|
|
124
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
const srcDir = path_1.default.join(
|
|
126
|
+
const srcDir = path_1.default.join((0, _1.getCwd)(), 'src');
|
|
126
127
|
console.log(`Scanning for FieldType.PARAGRAPH fields in: ${srcDir}\n`);
|
|
127
128
|
const project = new ts_morph_1.Project({
|
|
128
129
|
tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
|
|
@@ -151,7 +152,7 @@ function main() {
|
|
|
151
152
|
for (const filePath of modifiedFiles) {
|
|
152
153
|
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
153
154
|
yield sourceFile.save();
|
|
154
|
-
console.log(` Saved: ${path_1.default.relative(
|
|
155
|
+
console.log(` Saved: ${path_1.default.relative((0, _1.getCwd)(), filePath)}`);
|
|
155
156
|
}
|
|
156
157
|
console.log(`\nDone. Processed ${totalChanged} FieldType.PARAGRAPH field(s).`);
|
|
157
158
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-events-index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/create-events-index.ts"],"names":[],"mappings":"AAqTA,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAmEnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -63,6 +63,7 @@ exports.main = main;
|
|
|
63
63
|
const ts_morph_1 = require("ts-morph");
|
|
64
64
|
const fs_1 = __importDefault(require("fs"));
|
|
65
65
|
const path_1 = __importDefault(require("path"));
|
|
66
|
+
const _1 = require(".");
|
|
66
67
|
const DEFINE_CONFIG_NAME = 'defineConfig';
|
|
67
68
|
const HANDLER_FUNCTION_NAMES = new Set([
|
|
68
69
|
'getCustomEventsHandler',
|
|
@@ -273,7 +274,7 @@ function modifyHandler(sourceFile, exportNames) {
|
|
|
273
274
|
// ─── Entry point ─────────────────────────────────────────────────────────────
|
|
274
275
|
function main() {
|
|
275
276
|
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
-
const cwd =
|
|
277
|
+
const cwd = (0, _1.getCwd)();
|
|
277
278
|
const srcDir = path_1.default.join(cwd, 'src');
|
|
278
279
|
console.log(`Scanning for defineConfig event exports in: ${srcDir}\n`);
|
|
279
280
|
const project = new ts_morph_1.Project({
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
+
export declare function getCwd(): string;
|
|
1
2
|
/**
|
|
2
|
-
* Run the upgrade process for
|
|
3
|
-
* directory.
|
|
4
|
-
*
|
|
5
|
-
* @param dockerSwarm - When true, the local `infrastructure/` directory is
|
|
6
|
-
* merged with upstream changes (Docker Swarm deployments still need it).
|
|
7
|
-
* When false (the default), `infrastructure/` is deleted entirely, since
|
|
8
|
-
* non-Swarm deployments no longer ship it.
|
|
3
|
+
* Run the upgrade process for a given country config directory.
|
|
4
|
+
* @param ccwd - The country config working directory.
|
|
9
5
|
*/
|
|
10
|
-
export declare function runUpgrade(
|
|
6
|
+
export declare function runUpgrade(ccwd: string | undefined): Promise<void>;
|
|
11
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/index.ts"],"names":[],"mappings":"AA+BA,wBAAgB,MAAM,WAMrB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,iBA8BxD"}
|