@opencrvs/toolkit 2.0.0-rc.e6ee324 → 2.0.0-rc.e711b76
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/create-countryconfig/index.js +50 -20
- package/create-countryconfig/package.json +12 -2
- package/dist/application-config/index.js +283 -120
- package/dist/cli.js +406 -131
- package/dist/commons/api/router.d.ts +3367 -217
- package/dist/commons/application-config/index.d.ts +1 -0
- package/dist/commons/conditionals/conditionals.d.ts +357 -7
- package/dist/commons/conditionals/validate.d.ts +52 -2
- package/dist/commons/events/ActionConfig.d.ts +28 -2
- package/dist/commons/events/ActionDocument.d.ts +6 -0
- package/dist/commons/events/ActionInput.d.ts +114 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
- package/dist/commons/events/Draft.d.ts +4 -2
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventDocument.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +25 -3
- package/dist/commons/events/EventMetadata.d.ts +26 -7
- package/dist/commons/events/FieldConfig.d.ts +388 -50
- package/dist/commons/events/FieldType.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
- package/dist/commons/events/FieldValue.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +189 -150
- package/dist/commons/events/field.d.ts +53 -1
- package/dist/commons/events/index.d.ts +2 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/flags.d.ts +16 -0
- package/dist/commons/events/state/index.d.ts +8 -4
- package/dist/commons/events/state/utils.d.ts +21 -289
- package/dist/commons/events/utils.d.ts +13 -2
- package/dist/conditionals/index.js +60 -2
- package/dist/events/index.js +1110 -285
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +1 -2
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts +9 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.d.ts.map +1 -1
- package/dist/migrations/v2.0/delete-infrastructure-directory.js +66 -20
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts +3 -0
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.d.ts.map +1 -0
- package/dist/migrations/v2.0/fix-accept-requested-registration-function-type.js +110 -0
- package/dist/migrations/v2.0/index.d.ts +5 -3
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +404 -129
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts +11 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.d.ts.map +1 -1
- package/dist/migrations/v2.0/merge-infrastructure-directory.js +17 -16
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +54 -30
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +140 -59
- package/dist/notification/index.js +911 -156
- package/dist/scopes/index.d.ts +92 -6
- package/dist/scopes/index.js +17 -4
- package/opencrvs-toolkit-2.0.0-rc.e711b76.tgz +0 -0
- package/package.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.e6ee324.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -1883,9 +1883,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
return replacedCount;
|
|
1885
1885
|
}
|
|
1886
|
-
function resolveConfigChain(configObj,
|
|
1886
|
+
function resolveConfigChain(configObj, path24) {
|
|
1887
1887
|
let current = configObj;
|
|
1888
|
-
for (const key of
|
|
1888
|
+
for (const key of path24) {
|
|
1889
1889
|
if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
|
|
1890
1890
|
const prop = current.getProperty(key);
|
|
1891
1891
|
if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
|
|
@@ -2120,6 +2120,10 @@ Done. Converted ${convertedCount} config file(s), replaced ${totalReplaced} rout
|
|
|
2120
2120
|
var import_ts_morph11 = require("ts-morph");
|
|
2121
2121
|
var import_path11 = __toESM(require("path"));
|
|
2122
2122
|
|
|
2123
|
+
// ../commons/src/scopes.deprecated.do-not-use.ts
|
|
2124
|
+
var z4 = __toESM(require("zod/v4"));
|
|
2125
|
+
var import_lodash = require("lodash");
|
|
2126
|
+
|
|
2123
2127
|
// ../commons/src/scopes.ts
|
|
2124
2128
|
var z3 = __toESM(require("zod/v4"));
|
|
2125
2129
|
var qs = __toESM(require("qs"));
|
|
@@ -2189,6 +2193,8 @@ var scopeOptionsPlaceEvent = z3.object({
|
|
|
2189
2193
|
placeOfEvent: JurisdictionFilter.optional()
|
|
2190
2194
|
}).describe("Options applicable to all record scopes.");
|
|
2191
2195
|
var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
|
|
2196
|
+
notifiedIn: JurisdictionFilter.optional(),
|
|
2197
|
+
notifiedBy: UserFilter.optional(),
|
|
2192
2198
|
declaredIn: JurisdictionFilter.optional(),
|
|
2193
2199
|
declaredBy: UserFilter.optional()
|
|
2194
2200
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
@@ -2230,6 +2236,8 @@ var ResolvedScopeOptionsPlaceEvent = z3.object({
|
|
|
2230
2236
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
2231
2237
|
);
|
|
2232
2238
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
2239
|
+
notifiedIn: UUID.nullish(),
|
|
2240
|
+
notifiedBy: z3.string().optional(),
|
|
2233
2241
|
declaredIn: UUID.nullish(),
|
|
2234
2242
|
declaredBy: z3.string().optional()
|
|
2235
2243
|
}).describe(
|
|
@@ -2378,22 +2386,30 @@ var encodeScope = (scope) => {
|
|
|
2378
2386
|
encode: false
|
|
2379
2387
|
});
|
|
2380
2388
|
};
|
|
2381
|
-
var
|
|
2382
|
-
|
|
2389
|
+
var decodedScopeCache = /* @__PURE__ */ new Map();
|
|
2390
|
+
var decodeScope = (encodedScope) => {
|
|
2391
|
+
if (decodedScopeCache.has(encodedScope)) {
|
|
2392
|
+
return decodedScopeCache.get(encodedScope);
|
|
2393
|
+
}
|
|
2394
|
+
const scope = qs.parse(encodedScope, {
|
|
2383
2395
|
ignoreQueryPrefix: true,
|
|
2384
2396
|
comma: true,
|
|
2385
2397
|
allowDots: true
|
|
2386
2398
|
});
|
|
2387
2399
|
const unflattenedScope = unflattenScope(scope);
|
|
2388
|
-
|
|
2400
|
+
const result = Scope2.safeParse(unflattenedScope)?.data;
|
|
2401
|
+
decodedScopeCache.set(encodedScope, result);
|
|
2402
|
+
return result;
|
|
2389
2403
|
};
|
|
2390
2404
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
2391
2405
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
2392
|
-
accessLevel: JurisdictionFilter.enum.all
|
|
2406
|
+
accessLevel: JurisdictionFilter.enum.all,
|
|
2407
|
+
notifiedIn: JurisdictionFilter.enum.all,
|
|
2408
|
+
declaredIn: JurisdictionFilter.enum.all,
|
|
2409
|
+
registeredIn: JurisdictionFilter.enum.all
|
|
2393
2410
|
};
|
|
2394
2411
|
|
|
2395
2412
|
// ../commons/src/scopes.deprecated.do-not-use.ts
|
|
2396
|
-
var z4 = __toESM(require("zod/v4"));
|
|
2397
2413
|
var rawConfigurableScopeRegex = /^([a-zA-Z][a-zA-Z0-9.-]*(?:\.[a-zA-Z0-9.-]+)*)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
|
2398
2414
|
var rawConfigurableScope = z4.string().regex(rawConfigurableScopeRegex);
|
|
2399
2415
|
var SearchScope = z4.object({
|
|
@@ -2627,6 +2643,74 @@ var legacyScopeToV2Scope = (v1Scope) => {
|
|
|
2627
2643
|
}
|
|
2628
2644
|
throw new Error(`Unsupported V1 scope type: ${v1Scope}`);
|
|
2629
2645
|
};
|
|
2646
|
+
var MERGEABLE_USER_SCOPE_TYPES = ["user.create", "user.edit"];
|
|
2647
|
+
function isMergeableUserScopeType(type) {
|
|
2648
|
+
return MERGEABLE_USER_SCOPE_TYPES.includes(type);
|
|
2649
|
+
}
|
|
2650
|
+
function decodeLegacyScope(legacy) {
|
|
2651
|
+
const encoded = legacyScopeToV2Scope(legacy);
|
|
2652
|
+
const scope = decodeScope(encoded);
|
|
2653
|
+
if (!scope) {
|
|
2654
|
+
throw new Error(
|
|
2655
|
+
`Could not decode migrated scope from legacy '${legacy}' (encoded: '${encoded}').`
|
|
2656
|
+
);
|
|
2657
|
+
}
|
|
2658
|
+
return { legacy, scope };
|
|
2659
|
+
}
|
|
2660
|
+
function groupByType(entries) {
|
|
2661
|
+
return entries.reduce(
|
|
2662
|
+
(groups, entry) => ({
|
|
2663
|
+
...groups,
|
|
2664
|
+
[entry.scope.type]: [...groups[entry.scope.type] ?? [], entry]
|
|
2665
|
+
}),
|
|
2666
|
+
{}
|
|
2667
|
+
);
|
|
2668
|
+
}
|
|
2669
|
+
function deduplicateEntries(entries) {
|
|
2670
|
+
return entries.filter(
|
|
2671
|
+
(entry, index) => entries.findIndex((e) => (0, import_lodash.isEqual)(e.scope, entry.scope)) === index
|
|
2672
|
+
);
|
|
2673
|
+
}
|
|
2674
|
+
function mergeEntries(type, entries) {
|
|
2675
|
+
const optionsList = entries.map(
|
|
2676
|
+
(e) => "options" in e.scope && e.scope.options ? e.scope.options : {}
|
|
2677
|
+
);
|
|
2678
|
+
const allKeys = optionsList.flatMap(
|
|
2679
|
+
(opts) => Object.keys(opts).filter((k) => opts[k] !== void 0)
|
|
2680
|
+
);
|
|
2681
|
+
const conflictKey = allKeys.find((key, i) => allKeys.indexOf(key) !== i);
|
|
2682
|
+
if (conflictKey) {
|
|
2683
|
+
const conflicting = entries.filter(
|
|
2684
|
+
(e) => conflictKey in ("options" in e.scope && e.scope.options || {})
|
|
2685
|
+
).map((e) => JSON.stringify(e.legacy));
|
|
2686
|
+
throw new Error(
|
|
2687
|
+
`Cannot auto-merge two '${type}' scopes that both define '${conflictKey}'. Conflicting legacy scopes: [${conflicting.join(", ")}]. Resolve manually in roles.ts and re-run.`
|
|
2688
|
+
);
|
|
2689
|
+
}
|
|
2690
|
+
const mergedOptions = Object.assign({}, ...optionsList);
|
|
2691
|
+
const merged = Object.keys(mergedOptions).length > 0 ? { type, options: mergedOptions } : { type };
|
|
2692
|
+
const parsed = Scope2.safeParse(merged);
|
|
2693
|
+
if (!parsed.success) {
|
|
2694
|
+
throw new Error(
|
|
2695
|
+
`Merged '${type}' scope failed schema validation: ${parsed.error.message}. Legacy scopes: [${entries.map((e) => JSON.stringify(e.legacy)).join(", ")}].`
|
|
2696
|
+
);
|
|
2697
|
+
}
|
|
2698
|
+
return parsed.data;
|
|
2699
|
+
}
|
|
2700
|
+
function migrateLegacyScopesArrayToV2Scopes(legacyScopes) {
|
|
2701
|
+
const groups = groupByType(legacyScopes.map(decodeLegacyScope));
|
|
2702
|
+
return Object.entries(groups).flatMap(([type, entries]) => {
|
|
2703
|
+
const deduped = deduplicateEntries(entries);
|
|
2704
|
+
if (deduped.length <= 1) return deduped.map((e) => e.scope);
|
|
2705
|
+
if (!isMergeableUserScopeType(type)) {
|
|
2706
|
+
console.warn(
|
|
2707
|
+
`Multiple non-mergeable '${type}' scopes detected after dedup \u2014 kept all as-is. Legacy scopes: [${deduped.map((e) => JSON.stringify(e.legacy)).join(", ")}]. Review whether the duplication is intentional.`
|
|
2708
|
+
);
|
|
2709
|
+
return deduped.map((e) => e.scope);
|
|
2710
|
+
}
|
|
2711
|
+
return [mergeEntries(type, deduped)];
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2630
2714
|
|
|
2631
2715
|
// src/migrations/v2.0/migrate-scopes.ts
|
|
2632
2716
|
var ROLES_FILE_RELATIVE_PATH = "src/data-seeding/roles/roles.ts";
|
|
@@ -2664,57 +2748,65 @@ function resolveLegacyScopeFromElement(element) {
|
|
|
2664
2748
|
}
|
|
2665
2749
|
function migrateScopesArrays(rolesFilePath, project) {
|
|
2666
2750
|
const sourceFile = project.getSourceFile(rolesFilePath);
|
|
2667
|
-
if (!sourceFile)
|
|
2751
|
+
if (!sourceFile) {
|
|
2752
|
+
return { migratedCount: 0, removedCount: 0, mergedCount: 0 };
|
|
2753
|
+
}
|
|
2668
2754
|
let migratedCount = 0;
|
|
2669
2755
|
let removedCount = 0;
|
|
2756
|
+
let mergedCount = 0;
|
|
2670
2757
|
const scopesProperties = sourceFile.getDescendantsOfKind(import_ts_morph11.SyntaxKind.PropertyAssignment).filter((prop) => prop.getName() === SCOPES_PROPERTY_NAME);
|
|
2758
|
+
const relPath = import_path11.default.relative(process.cwd(), rolesFilePath);
|
|
2671
2759
|
for (const scopesProp of scopesProperties) {
|
|
2672
2760
|
const initializer = scopesProp.getInitializer();
|
|
2673
2761
|
if (!initializer || !import_ts_morph11.Node.isArrayLiteralExpression(initializer)) continue;
|
|
2674
|
-
const
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2762
|
+
const rawTexts = [];
|
|
2763
|
+
const legacyStrings = [];
|
|
2764
|
+
let anyChange = false;
|
|
2765
|
+
for (const element of initializer.getElements()) {
|
|
2678
2766
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
2679
2767
|
if (scopeKey && !(scopeKey in SCOPES)) {
|
|
2680
2768
|
console.warn(
|
|
2681
|
-
` [${
|
|
2769
|
+
` [${relPath}] Removing unknown scope reference: SCOPES.${scopeKey}`
|
|
2682
2770
|
);
|
|
2683
|
-
initializer.removeElement(index);
|
|
2684
2771
|
removedCount++;
|
|
2772
|
+
anyChange = true;
|
|
2685
2773
|
continue;
|
|
2686
2774
|
}
|
|
2687
2775
|
const legacyScope = resolveLegacyScopeFromElement(element);
|
|
2688
2776
|
if (!legacyScope) {
|
|
2689
2777
|
console.warn(
|
|
2690
|
-
` [${
|
|
2778
|
+
` [${relPath}] Preserving non-literal scope expression verbatim: ${element.getText()}`
|
|
2691
2779
|
);
|
|
2780
|
+
rawTexts.push(element.getText());
|
|
2692
2781
|
continue;
|
|
2693
2782
|
}
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
const scope = decodeScope(migratedScope);
|
|
2697
|
-
if (!scope) {
|
|
2698
|
-
console.warn(
|
|
2699
|
-
` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
|
|
2700
|
-
);
|
|
2701
|
-
continue;
|
|
2702
|
-
}
|
|
2703
|
-
element.replaceWithText(JSON.stringify(scope));
|
|
2704
|
-
migratedCount++;
|
|
2705
|
-
} catch (error) {
|
|
2706
|
-
console.warn(
|
|
2707
|
-
` [${import_path11.default.relative(process.cwd(), rolesFilePath)}] Could not migrate scope '${legacyScope}': ${error}`
|
|
2708
|
-
);
|
|
2709
|
-
}
|
|
2783
|
+
legacyStrings.push(legacyScope);
|
|
2784
|
+
anyChange = true;
|
|
2710
2785
|
}
|
|
2786
|
+
if (!anyChange) continue;
|
|
2787
|
+
let mergedScopes;
|
|
2788
|
+
try {
|
|
2789
|
+
mergedScopes = migrateLegacyScopesArrayToV2Scopes(legacyStrings);
|
|
2790
|
+
} catch (error) {
|
|
2791
|
+
throw new Error(
|
|
2792
|
+
`[${relPath}] Failed to migrate scopes for role: ${error instanceof Error ? error.message : String(error)}`,
|
|
2793
|
+
{ cause: error }
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
migratedCount += legacyStrings.length;
|
|
2797
|
+
mergedCount += legacyStrings.length - mergedScopes.length;
|
|
2798
|
+
const outputElements = [
|
|
2799
|
+
...rawTexts,
|
|
2800
|
+
...mergedScopes.map((s) => JSON.stringify(s))
|
|
2801
|
+
];
|
|
2802
|
+
scopesProp.setInitializer(`[${outputElements.join(", ")}]`);
|
|
2711
2803
|
}
|
|
2712
2804
|
if (removedCount > 0) {
|
|
2713
2805
|
console.log(
|
|
2714
|
-
` Removed ${removedCount} unknown SCOPES reference(s) from '${
|
|
2806
|
+
` Removed ${removedCount} unknown SCOPES reference(s) from '${relPath}'.`
|
|
2715
2807
|
);
|
|
2716
2808
|
}
|
|
2717
|
-
return { migratedCount, removedCount };
|
|
2809
|
+
return { migratedCount, removedCount, mergedCount };
|
|
2718
2810
|
}
|
|
2719
2811
|
function ensureScopesHelpersImport(rolesFilePath, project) {
|
|
2720
2812
|
const sourceFile = project.getSourceFile(rolesFilePath);
|
|
@@ -2849,7 +2941,7 @@ async function main11() {
|
|
|
2849
2941
|
return;
|
|
2850
2942
|
}
|
|
2851
2943
|
const importChanged = ensureScopesHelpersImport(rolesFilePath, project);
|
|
2852
|
-
const { migratedCount, removedCount } = migrateScopesArrays(
|
|
2944
|
+
const { migratedCount, removedCount, mergedCount } = migrateScopesArrays(
|
|
2853
2945
|
rolesFilePath,
|
|
2854
2946
|
project
|
|
2855
2947
|
);
|
|
@@ -2868,7 +2960,7 @@ async function main11() {
|
|
|
2868
2960
|
}
|
|
2869
2961
|
await sourceFile.save();
|
|
2870
2962
|
console.log(
|
|
2871
|
-
`Done. Migrated ${migratedCount} legacy scope(s), removed ${removedCount} unknown SCOPES reference(s), wrapped ${wrappedScopesCount} scope array(s) with defineScopes()${wrappedRoles ? ", wrapped roles with defineRoles()" : ""}${removedRoleType ? ", and removed Role type definition" : ""}${importChanged ? ". Updated toolkit/scopes imports." : "."}`
|
|
2963
|
+
`Done. Migrated ${migratedCount} legacy scope(s), merged ${mergedCount} AND-paired scope(s) into single v2 objects (privilege-escalation fix, see issue #12489), removed ${removedCount} unknown SCOPES reference(s), wrapped ${wrappedScopesCount} scope array(s) with defineScopes()${wrappedRoles ? ", wrapped roles with defineRoles()" : ""}${removedRoleType ? ", and removed Role type definition" : ""}${importChanged ? ". Updated toolkit/scopes imports." : "."}`
|
|
2872
2964
|
);
|
|
2873
2965
|
}
|
|
2874
2966
|
|
|
@@ -3674,6 +3766,10 @@ var ACTION_PROPERTY_NAME2 = "action";
|
|
|
3674
3766
|
var CONDITIONALS_PROPERTY_NAME = "conditionals";
|
|
3675
3767
|
var TYPE_PROPERTY_NAME7 = "type";
|
|
3676
3768
|
var SLUG_PROPERTY_NAME = "slug";
|
|
3769
|
+
var READ_ACTION_TYPE = "READ";
|
|
3770
|
+
var ACTION_TYPE_IMPORT_NAME = "ActionType";
|
|
3771
|
+
var TOOLKIT_EVENTS_MODULE2 = "@opencrvs/toolkit/events";
|
|
3772
|
+
var READ_ACTION_FALLBACK_INITIALIZER = `{ type: ${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE} }`;
|
|
3677
3773
|
var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
3678
3774
|
"READ",
|
|
3679
3775
|
"DELETE",
|
|
@@ -3721,91 +3817,137 @@ function isUnsupportedActionType(action) {
|
|
|
3721
3817
|
}
|
|
3722
3818
|
return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
|
|
3723
3819
|
}
|
|
3724
|
-
function
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3820
|
+
function ensureValidAction(workqueue, relPath) {
|
|
3821
|
+
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
3822
|
+
const actionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
3823
|
+
if (actionProperty && import_ts_morph17.Node.isPropertyAssignment(actionProperty)) {
|
|
3824
|
+
const initializer = actionProperty.getInitializer();
|
|
3825
|
+
if (initializer && import_ts_morph17.Node.isObjectLiteralExpression(initializer)) {
|
|
3826
|
+
if (!isUnsupportedActionType(initializer)) {
|
|
3827
|
+
return { changed: false, usedReadFallback: false };
|
|
3828
|
+
}
|
|
3829
|
+
actionProperty.set({
|
|
3830
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3831
|
+
initializer: READ_ACTION_FALLBACK_INITIALIZER
|
|
3832
|
+
});
|
|
3833
|
+
console.log(
|
|
3834
|
+
` [${relPath}] Replaced unsupported 'action' type with '${ACTION_TYPE_IMPORT_NAME}.${READ_ACTION_TYPE}' on workqueue '${workqueueLabel}'`
|
|
3835
|
+
);
|
|
3836
|
+
return { changed: true, usedReadFallback: true };
|
|
3837
|
+
}
|
|
3732
3838
|
}
|
|
3839
|
+
workqueue.addPropertyAssignment({
|
|
3840
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3841
|
+
initializer: READ_ACTION_FALLBACK_INITIALIZER
|
|
3842
|
+
});
|
|
3843
|
+
console.log(
|
|
3844
|
+
` [${relPath}] Added default 'action: ${READ_ACTION_FALLBACK_INITIALIZER}' to workqueue '${workqueueLabel}'`
|
|
3845
|
+
);
|
|
3846
|
+
return { changed: true, usedReadFallback: true };
|
|
3847
|
+
}
|
|
3848
|
+
function migrateWorkqueueActions(workqueue, relPath) {
|
|
3733
3849
|
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
3734
|
-
const
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3850
|
+
const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
|
|
3851
|
+
let actionsArrayMigrated = false;
|
|
3852
|
+
if (actionsProperty && import_ts_morph17.Node.isPropertyAssignment(actionsProperty)) {
|
|
3853
|
+
const actionsInitializer = actionsProperty.getInitializer();
|
|
3854
|
+
if (actionsInitializer && import_ts_morph17.Node.isArrayLiteralExpression(actionsInitializer)) {
|
|
3855
|
+
const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
3856
|
+
if (existingActionProperty) {
|
|
3857
|
+
if (import_ts_morph17.Node.isPropertyAssignment(existingActionProperty)) {
|
|
3858
|
+
const existingActionInitializer = existingActionProperty.getInitializer();
|
|
3859
|
+
if (existingActionInitializer && import_ts_morph17.Node.isObjectLiteralExpression(existingActionInitializer)) {
|
|
3860
|
+
const conditionalsProperty = existingActionInitializer.getProperty(
|
|
3861
|
+
CONDITIONALS_PROPERTY_NAME
|
|
3862
|
+
);
|
|
3863
|
+
if (conditionalsProperty) {
|
|
3864
|
+
conditionalsProperty.remove();
|
|
3865
|
+
console.log(
|
|
3866
|
+
` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
|
|
3867
|
+
);
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
}
|
|
3871
|
+
actionsProperty.remove();
|
|
3872
|
+
console.log(
|
|
3873
|
+
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
|
|
3874
|
+
);
|
|
3875
|
+
actionsArrayMigrated = true;
|
|
3876
|
+
} else {
|
|
3877
|
+
const actionCandidates = actionsInitializer.getElements().filter(
|
|
3878
|
+
(element) => import_ts_morph17.Node.isObjectLiteralExpression(element)
|
|
3741
3879
|
);
|
|
3742
|
-
if (
|
|
3743
|
-
|
|
3880
|
+
if (actionCandidates.length === 0) {
|
|
3881
|
+
actionsProperty.remove();
|
|
3744
3882
|
console.log(
|
|
3745
|
-
` [${relPath}] Removed
|
|
3883
|
+
` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
|
|
3746
3884
|
);
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3885
|
+
actionsArrayMigrated = true;
|
|
3886
|
+
} else {
|
|
3887
|
+
if (actionCandidates.length > 1) {
|
|
3888
|
+
const droppedCount = actionCandidates.length - 1;
|
|
3889
|
+
console.warn(
|
|
3890
|
+
` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
|
|
3891
|
+
);
|
|
3892
|
+
}
|
|
3893
|
+
const conditionalsProperty = actionCandidates[0].getProperty(
|
|
3894
|
+
CONDITIONALS_PROPERTY_NAME
|
|
3752
3895
|
);
|
|
3896
|
+
if (conditionalsProperty) {
|
|
3897
|
+
conditionalsProperty.remove();
|
|
3898
|
+
console.log(
|
|
3899
|
+
` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
|
|
3900
|
+
);
|
|
3901
|
+
}
|
|
3902
|
+
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
3903
|
+
actionsProperty.remove();
|
|
3904
|
+
console.log(
|
|
3905
|
+
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
|
|
3906
|
+
);
|
|
3907
|
+
actionsArrayMigrated = true;
|
|
3908
|
+
} else {
|
|
3909
|
+
const firstActionText = actionCandidates[0].getText();
|
|
3910
|
+
workqueue.addPropertyAssignment({
|
|
3911
|
+
name: ACTION_PROPERTY_NAME2,
|
|
3912
|
+
initializer: firstActionText
|
|
3913
|
+
});
|
|
3914
|
+
actionsProperty.remove();
|
|
3915
|
+
console.log(
|
|
3916
|
+
` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
|
|
3917
|
+
);
|
|
3918
|
+
actionsArrayMigrated = true;
|
|
3919
|
+
}
|
|
3753
3920
|
}
|
|
3754
3921
|
}
|
|
3755
3922
|
}
|
|
3756
|
-
actionsProperty.remove();
|
|
3757
|
-
console.log(
|
|
3758
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
|
|
3759
|
-
);
|
|
3760
|
-
return 1;
|
|
3761
3923
|
}
|
|
3762
|
-
const
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
}
|
|
3772
|
-
if (actionCandidates.length > 1) {
|
|
3773
|
-
const droppedCount = actionCandidates.length - 1;
|
|
3774
|
-
console.warn(
|
|
3775
|
-
` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
|
|
3776
|
-
);
|
|
3777
|
-
}
|
|
3778
|
-
const conditionalsProperty = actionCandidates[0].getProperty(
|
|
3779
|
-
CONDITIONALS_PROPERTY_NAME
|
|
3924
|
+
const fallback = ensureValidAction(workqueue, relPath);
|
|
3925
|
+
return {
|
|
3926
|
+
changed: actionsArrayMigrated || fallback.changed,
|
|
3927
|
+
usedReadFallback: fallback.usedReadFallback
|
|
3928
|
+
};
|
|
3929
|
+
}
|
|
3930
|
+
function ensureActionTypeImport(sourceFile) {
|
|
3931
|
+
const existingImport = sourceFile.getImportDeclaration(
|
|
3932
|
+
(decl) => decl.getModuleSpecifierValue() === TOOLKIT_EVENTS_MODULE2
|
|
3780
3933
|
);
|
|
3781
|
-
if (
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
3788
|
-
actionsProperty.remove();
|
|
3789
|
-
console.log(
|
|
3790
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
|
|
3791
|
-
);
|
|
3792
|
-
return 1;
|
|
3934
|
+
if (existingImport) {
|
|
3935
|
+
const alreadyImported = existingImport.getNamedImports().some((ni) => ni.getName() === ACTION_TYPE_IMPORT_NAME);
|
|
3936
|
+
if (!alreadyImported) {
|
|
3937
|
+
existingImport.addNamedImport(ACTION_TYPE_IMPORT_NAME);
|
|
3938
|
+
}
|
|
3939
|
+
return;
|
|
3793
3940
|
}
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
initializer: firstActionText
|
|
3941
|
+
sourceFile.addImportDeclaration({
|
|
3942
|
+
moduleSpecifier: TOOLKIT_EVENTS_MODULE2,
|
|
3943
|
+
namedImports: [ACTION_TYPE_IMPORT_NAME]
|
|
3798
3944
|
});
|
|
3799
|
-
actionsProperty.remove();
|
|
3800
|
-
console.log(
|
|
3801
|
-
` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
|
|
3802
|
-
);
|
|
3803
|
-
return 1;
|
|
3804
3945
|
}
|
|
3805
3946
|
function processFile13(filePath, project) {
|
|
3806
3947
|
const sourceFile = project.getSourceFile(filePath);
|
|
3807
3948
|
if (!sourceFile) return 0;
|
|
3808
3949
|
let migratedWorkqueues = 0;
|
|
3950
|
+
let needsActionTypeImport = false;
|
|
3809
3951
|
const relPath = import_path18.default.relative(process.cwd(), filePath);
|
|
3810
3952
|
const callExpressions = sourceFile.getDescendantsOfKind(
|
|
3811
3953
|
import_ts_morph17.SyntaxKind.CallExpression
|
|
@@ -3821,9 +3963,14 @@ function processFile13(filePath, project) {
|
|
|
3821
3963
|
if (!import_ts_morph17.Node.isArrayLiteralExpression(workqueuesArg)) continue;
|
|
3822
3964
|
for (const element of workqueuesArg.getElements()) {
|
|
3823
3965
|
if (!import_ts_morph17.Node.isObjectLiteralExpression(element)) continue;
|
|
3824
|
-
|
|
3966
|
+
const result = migrateWorkqueueActions(element, relPath);
|
|
3967
|
+
if (result.changed) migratedWorkqueues++;
|
|
3968
|
+
if (result.usedReadFallback) needsActionTypeImport = true;
|
|
3825
3969
|
}
|
|
3826
3970
|
}
|
|
3971
|
+
if (needsActionTypeImport) {
|
|
3972
|
+
ensureActionTypeImport(sourceFile);
|
|
3973
|
+
}
|
|
3827
3974
|
return migratedWorkqueues;
|
|
3828
3975
|
}
|
|
3829
3976
|
async function main18() {
|
|
@@ -4158,7 +4305,7 @@ Saved ${handlerRelPath}.`);
|
|
|
4158
4305
|
// src/migrations/v2.0/checkout-upstream-files.ts
|
|
4159
4306
|
var import_child_process = require("child_process");
|
|
4160
4307
|
var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
|
|
4161
|
-
var UPSTREAM_BRANCH = "
|
|
4308
|
+
var UPSTREAM_BRANCH = "release/2.0.0";
|
|
4162
4309
|
var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
|
|
4163
4310
|
var FILES_TO_CHECKOUT = [
|
|
4164
4311
|
"src/analytics/analytics.ts",
|
|
@@ -4697,9 +4844,9 @@ var import_path24 = require("path");
|
|
|
4697
4844
|
var TEMP_REMOTE2 = "opencrvs-upgrade-v19-v20-codemod-merge-infra";
|
|
4698
4845
|
var INFRASTRUCTURE_DIR = "infrastructure";
|
|
4699
4846
|
var BASE_BRANCH = "release-v1.9";
|
|
4700
|
-
function gitShowBytes(ref,
|
|
4847
|
+
function gitShowBytes(ref, path24) {
|
|
4701
4848
|
try {
|
|
4702
|
-
const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${
|
|
4849
|
+
const buf = (0, import_child_process2.execFileSync)("git", ["show", `${ref}:${path24}`], {
|
|
4703
4850
|
cwd: process.cwd(),
|
|
4704
4851
|
stdio: ["ignore", "pipe", "pipe"]
|
|
4705
4852
|
});
|
|
@@ -4708,9 +4855,13 @@ function gitShowBytes(ref, path23) {
|
|
|
4708
4855
|
return null;
|
|
4709
4856
|
}
|
|
4710
4857
|
}
|
|
4711
|
-
async function main25(
|
|
4858
|
+
async function main25({
|
|
4859
|
+
subdirs = []
|
|
4860
|
+
} = {}) {
|
|
4861
|
+
const pathspecs = subdirs.length > 0 ? subdirs.map((s) => `${INFRASTRUCTURE_DIR}/${s}/`) : [`${INFRASTRUCTURE_DIR}/`];
|
|
4862
|
+
const scopeLabel = pathspecs.map((p) => `'${p}'`).join(", ");
|
|
4712
4863
|
console.log(
|
|
4713
|
-
`Merging
|
|
4864
|
+
`Merging ${scopeLabel} from ${UPSTREAM_URL}@${UPSTREAM_BRANCH} (base: ${BASE_BRANCH})...
|
|
4714
4865
|
`
|
|
4715
4866
|
);
|
|
4716
4867
|
assertIsGitRepo();
|
|
@@ -4725,20 +4876,12 @@ async function main25() {
|
|
|
4725
4876
|
const ref = `${TEMP_REMOTE2}/${UPSTREAM_BRANCH}`;
|
|
4726
4877
|
const baseRef = `${TEMP_REMOTE2}/${BASE_BRANCH}`;
|
|
4727
4878
|
const upstreamFiles = runGit(
|
|
4728
|
-
[
|
|
4729
|
-
"ls-tree",
|
|
4730
|
-
"-r",
|
|
4731
|
-
"--name-only",
|
|
4732
|
-
"-z",
|
|
4733
|
-
ref,
|
|
4734
|
-
"--",
|
|
4735
|
-
`${INFRASTRUCTURE_DIR}/`
|
|
4736
|
-
],
|
|
4879
|
+
["ls-tree", "-r", "--name-only", "-z", ref, "--", ...pathspecs],
|
|
4737
4880
|
{ silent: true }
|
|
4738
4881
|
).split("\0").filter(Boolean);
|
|
4739
4882
|
if (upstreamFiles.length === 0) {
|
|
4740
4883
|
console.log(
|
|
4741
|
-
` No files found under
|
|
4884
|
+
` No files found under ${scopeLabel} on ${ref}. Nothing to merge.`
|
|
4742
4885
|
);
|
|
4743
4886
|
return;
|
|
4744
4887
|
}
|
|
@@ -4813,7 +4956,9 @@ async function main25() {
|
|
|
4813
4956
|
var import_fs6 = require("fs");
|
|
4814
4957
|
var import_path25 = require("path");
|
|
4815
4958
|
var INFRASTRUCTURE_DIR2 = "infrastructure";
|
|
4816
|
-
async function main26(
|
|
4959
|
+
async function main26({
|
|
4960
|
+
keep = []
|
|
4961
|
+
} = {}) {
|
|
4817
4962
|
const fullPath = (0, import_path25.join)(process.cwd(), INFRASTRUCTURE_DIR2);
|
|
4818
4963
|
if (!(0, import_fs6.existsSync)(fullPath)) {
|
|
4819
4964
|
console.log(
|
|
@@ -4821,24 +4966,152 @@ async function main26() {
|
|
|
4821
4966
|
);
|
|
4822
4967
|
return;
|
|
4823
4968
|
}
|
|
4824
|
-
console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
|
|
4825
|
-
`);
|
|
4826
4969
|
assertIsGitRepo();
|
|
4827
|
-
|
|
4828
|
-
|
|
4970
|
+
if (keep.length === 0) {
|
|
4971
|
+
console.log(`Deleting '${INFRASTRUCTURE_DIR2}/'...
|
|
4972
|
+
`);
|
|
4973
|
+
runGit(["rm", "-rf", "--ignore-unmatch", "--", `${INFRASTRUCTURE_DIR2}/`], {
|
|
4974
|
+
silent: true
|
|
4975
|
+
});
|
|
4976
|
+
console.log(
|
|
4977
|
+
` Staged deletion of tracked files under '${INFRASTRUCTURE_DIR2}/'.`
|
|
4978
|
+
);
|
|
4979
|
+
if ((0, import_fs6.existsSync)(fullPath)) {
|
|
4980
|
+
(0, import_fs6.rmSync)(fullPath, { recursive: true, force: true });
|
|
4981
|
+
console.log(
|
|
4982
|
+
` Removed remaining untracked files under '${INFRASTRUCTURE_DIR2}/'.`
|
|
4983
|
+
);
|
|
4984
|
+
}
|
|
4985
|
+
console.log(
|
|
4986
|
+
`
|
|
4987
|
+
Done. Review the staged deletion with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
|
|
4988
|
+
);
|
|
4989
|
+
return;
|
|
4990
|
+
}
|
|
4991
|
+
const keepSet = new Set(keep);
|
|
4992
|
+
console.log(
|
|
4993
|
+
`Deleting contents of '${INFRASTRUCTURE_DIR2}/' except: ${[...keepSet].map((name) => `'${name}'`).join(", ")}
|
|
4994
|
+
`
|
|
4995
|
+
);
|
|
4996
|
+
const topLevelEntries = (0, import_fs6.readdirSync)(fullPath, { withFileTypes: true });
|
|
4997
|
+
let deleted = 0;
|
|
4998
|
+
for (const entry of topLevelEntries) {
|
|
4999
|
+
if (keepSet.has(entry.name)) {
|
|
5000
|
+
console.log(` Keeping '${INFRASTRUCTURE_DIR2}/${entry.name}'.`);
|
|
5001
|
+
continue;
|
|
5002
|
+
}
|
|
5003
|
+
const relPath = `${INFRASTRUCTURE_DIR2}/${entry.name}${entry.isDirectory() ? "/" : ""}`;
|
|
5004
|
+
runGit(["rm", "-rf", "--ignore-unmatch", "--", relPath], { silent: true });
|
|
5005
|
+
const fullEntryPath = (0, import_path25.join)(fullPath, entry.name);
|
|
5006
|
+
if ((0, import_fs6.existsSync)(fullEntryPath)) {
|
|
5007
|
+
(0, import_fs6.rmSync)(fullEntryPath, { recursive: true, force: true });
|
|
5008
|
+
}
|
|
5009
|
+
console.log(` Deleted '${relPath}'.`);
|
|
5010
|
+
deleted++;
|
|
5011
|
+
}
|
|
5012
|
+
const presentNames = new Set(topLevelEntries.map((e) => e.name));
|
|
5013
|
+
const missingKeeps = [...keepSet].filter((name) => !presentNames.has(name));
|
|
5014
|
+
if (missingKeeps.length > 0) {
|
|
5015
|
+
console.warn(
|
|
5016
|
+
` [warn] Requested to keep ${missingKeeps.map((n) => `'${n}'`).join(", ")} but they don't exist under '${INFRASTRUCTURE_DIR2}/'.`
|
|
5017
|
+
);
|
|
5018
|
+
}
|
|
5019
|
+
console.log(
|
|
5020
|
+
`
|
|
5021
|
+
Done. Deleted ${deleted} top-level entr${deleted === 1 ? "y" : "ies"}. Review the staged deletions with: git diff --cached -- '${INFRASTRUCTURE_DIR2}/'`
|
|
5022
|
+
);
|
|
5023
|
+
}
|
|
5024
|
+
|
|
5025
|
+
// src/migrations/v2.0/fix-accept-requested-registration-function-type.ts
|
|
5026
|
+
var import_ts_morph22 = require("ts-morph");
|
|
5027
|
+
var import_path26 = __toESM(require("path"));
|
|
5028
|
+
var TARGET_FUNCTION_NAME = "acceptRequestedRegistration";
|
|
5029
|
+
var ACTION_PARAMETER_NAME = "action";
|
|
5030
|
+
var OLD_TYPE = "ActionInput";
|
|
5031
|
+
var NEW_TYPE = "Extract<ActionInput, { type?: 'REGISTER' }>";
|
|
5032
|
+
function isAcceptRequestedRegistrationParameter(parameter) {
|
|
5033
|
+
const functionDeclaration = parameter.getFirstAncestorByKind(
|
|
5034
|
+
import_ts_morph22.SyntaxKind.FunctionDeclaration
|
|
5035
|
+
);
|
|
5036
|
+
if (functionDeclaration?.getName() === TARGET_FUNCTION_NAME) {
|
|
5037
|
+
return true;
|
|
5038
|
+
}
|
|
5039
|
+
const arrowFunction = parameter.getFirstAncestorByKind(
|
|
5040
|
+
import_ts_morph22.SyntaxKind.ArrowFunction
|
|
5041
|
+
);
|
|
5042
|
+
const variableDeclaration = arrowFunction?.getFirstAncestorByKind(
|
|
5043
|
+
import_ts_morph22.SyntaxKind.VariableDeclaration
|
|
5044
|
+
);
|
|
5045
|
+
return variableDeclaration?.getName() === TARGET_FUNCTION_NAME;
|
|
5046
|
+
}
|
|
5047
|
+
function processFile14(filePath, project) {
|
|
5048
|
+
const sourceFile = project.getSourceFile(filePath);
|
|
5049
|
+
if (!sourceFile) return 0;
|
|
5050
|
+
let updatedCount = 0;
|
|
5051
|
+
for (const parameter of sourceFile.getDescendantsOfKind(
|
|
5052
|
+
import_ts_morph22.SyntaxKind.Parameter
|
|
5053
|
+
)) {
|
|
5054
|
+
if (parameter.getName() !== ACTION_PARAMETER_NAME) {
|
|
5055
|
+
continue;
|
|
5056
|
+
}
|
|
5057
|
+
if (!isAcceptRequestedRegistrationParameter(parameter)) {
|
|
5058
|
+
continue;
|
|
5059
|
+
}
|
|
5060
|
+
const typeNode = parameter.getTypeNode();
|
|
5061
|
+
if (!typeNode || typeNode.getText() !== OLD_TYPE) {
|
|
5062
|
+
continue;
|
|
5063
|
+
}
|
|
5064
|
+
parameter.setType(NEW_TYPE);
|
|
5065
|
+
updatedCount++;
|
|
5066
|
+
console.log(
|
|
5067
|
+
` [${import_path26.default.relative(process.cwd(), filePath)}] Updated '${ACTION_PARAMETER_NAME}' in ${TARGET_FUNCTION_NAME} to ${NEW_TYPE}`
|
|
5068
|
+
);
|
|
5069
|
+
}
|
|
5070
|
+
return updatedCount;
|
|
5071
|
+
}
|
|
5072
|
+
async function main27() {
|
|
5073
|
+
const srcDir = import_path26.default.join(process.cwd(), "src");
|
|
5074
|
+
console.log(`Scanning for ${TARGET_FUNCTION_NAME} in: ${srcDir}
|
|
5075
|
+
`);
|
|
5076
|
+
const project = new import_ts_morph22.Project({
|
|
5077
|
+
tsConfigFilePath: import_path26.default.resolve(srcDir, "../tsconfig.json"),
|
|
5078
|
+
skipAddingFilesFromTsConfig: false
|
|
5079
|
+
});
|
|
5080
|
+
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
5081
|
+
const filePath = sf.getFilePath();
|
|
5082
|
+
return filePath.includes("/src/") && !filePath.includes("/node_modules/");
|
|
4829
5083
|
});
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
5084
|
+
let totalUpdated = 0;
|
|
5085
|
+
const modifiedFiles = [];
|
|
5086
|
+
for (const sourceFile of sourceFiles) {
|
|
5087
|
+
const filePath = sourceFile.getFilePath();
|
|
5088
|
+
const updated = processFile14(filePath, project);
|
|
5089
|
+
if (updated > 0) {
|
|
5090
|
+
totalUpdated += updated;
|
|
5091
|
+
modifiedFiles.push(filePath);
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
if (modifiedFiles.length === 0) {
|
|
5095
|
+
console.log(
|
|
5096
|
+
`No '${ACTION_PARAMETER_NAME}: ${OLD_TYPE}' parameter in ${TARGET_FUNCTION_NAME} found. Nothing to do.`
|
|
5097
|
+
);
|
|
5098
|
+
return;
|
|
5099
|
+
}
|
|
5100
|
+
console.log(`
|
|
5101
|
+
Saving ${modifiedFiles.length} modified file(s)...`);
|
|
5102
|
+
for (const filePath of modifiedFiles) {
|
|
5103
|
+
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
5104
|
+
await sourceFile.save();
|
|
5105
|
+
console.log(` Saved: ${import_path26.default.relative(process.cwd(), filePath)}`);
|
|
4834
5106
|
}
|
|
4835
5107
|
console.log(
|
|
4836
5108
|
`
|
|
4837
|
-
|
|
5109
|
+
Done. Updated ${totalUpdated} parameter type annotation(s) in ${TARGET_FUNCTION_NAME}.`
|
|
4838
5110
|
);
|
|
4839
5111
|
}
|
|
4840
5112
|
|
|
4841
5113
|
// src/migrations/v2.0/index.ts
|
|
5114
|
+
var NON_SWARM_INFRA_SUBDIRS = ["postgres", "metabase"];
|
|
4842
5115
|
async function runUpgrade(dockerSwarm) {
|
|
4843
5116
|
await main18();
|
|
4844
5117
|
await main();
|
|
@@ -4863,11 +5136,13 @@ async function runUpgrade(dockerSwarm) {
|
|
|
4863
5136
|
await main22();
|
|
4864
5137
|
await main23();
|
|
4865
5138
|
await main24();
|
|
5139
|
+
await main27();
|
|
4866
5140
|
await main17();
|
|
4867
5141
|
if (dockerSwarm) {
|
|
4868
5142
|
await main25();
|
|
4869
5143
|
} else {
|
|
4870
|
-
await main26();
|
|
5144
|
+
await main26({ keep: NON_SWARM_INFRA_SUBDIRS });
|
|
5145
|
+
await main25({ subdirs: NON_SWARM_INFRA_SUBDIRS });
|
|
4871
5146
|
}
|
|
4872
5147
|
}
|
|
4873
5148
|
|
|
@@ -4896,7 +5171,7 @@ Options:
|
|
|
4896
5171
|
'infrastructure/' directory is deleted (default).
|
|
4897
5172
|
-h, --help Show this message.
|
|
4898
5173
|
`.trim();
|
|
4899
|
-
function
|
|
5174
|
+
function main28() {
|
|
4900
5175
|
const command = args[0];
|
|
4901
5176
|
if (!command || command === "--help" || command === "-h") {
|
|
4902
5177
|
console.log(USAGE);
|
|
@@ -4971,4 +5246,4 @@ function handleCheckTranslations() {
|
|
|
4971
5246
|
console.warn("This command is not implemented yet!");
|
|
4972
5247
|
process.exit(1);
|
|
4973
5248
|
}
|
|
4974
|
-
|
|
5249
|
+
main28();
|