@opencrvs/toolkit 1.9.12-rc.ba2ea5c → 1.9.12-rc.bce2e6f
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 +14 -753
- package/dist/migrations/v2.0/index.d.ts.map +1 -1
- package/dist/migrations/v2.0/index.js +12 -751
- package/dist/migrations/v2.0/migrate-scopes.d.ts.map +1 -1
- package/dist/migrations/v2.0/migrate-scopes.js +5 -6
- package/opencrvs-toolkit-1.9.12-rc.bce2e6f.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.json +0 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts +0 -3
- package/dist/migrations/v2.0/migrate-workqueue-configs.d.ts.map +0 -1
- package/dist/migrations/v2.0/migrate-workqueue-configs.js +0 -237
- package/dist/migrations/v2.0/remove-demo-scope.d.ts +0 -3
- package/dist/migrations/v2.0/remove-demo-scope.d.ts.map +0 -1
- package/dist/migrations/v2.0/remove-demo-scope.js +0 -75
- package/opencrvs-toolkit-1.9.12-rc.ba2ea5c.tgz +0 -0
package/dist/cli.js
CHANGED
|
@@ -903,8 +903,8 @@ function isBirthConfig(configArg) {
|
|
|
903
903
|
}
|
|
904
904
|
return false;
|
|
905
905
|
}
|
|
906
|
-
function hasElementWithId(
|
|
907
|
-
for (const el of
|
|
906
|
+
function hasElementWithId(array, id) {
|
|
907
|
+
for (const el of array.getElements()) {
|
|
908
908
|
if (!import_ts_morph6.Node.isObjectLiteralExpression(el)) continue;
|
|
909
909
|
const idProp = el.getProperty("id");
|
|
910
910
|
if (!idProp || !import_ts_morph6.Node.isPropertyAssignment(idProp)) continue;
|
|
@@ -1166,15 +1166,15 @@ function processFile7(filePath, project) {
|
|
|
1166
1166
|
const arrayLiterals = sourceFile.getDescendantsOfKind(
|
|
1167
1167
|
import_ts_morph7.SyntaxKind.ArrayLiteralExpression
|
|
1168
1168
|
);
|
|
1169
|
-
for (const
|
|
1169
|
+
for (const array of arrayLiterals) {
|
|
1170
1170
|
const indicesToRemove = [];
|
|
1171
|
-
|
|
1171
|
+
array.getElements().forEach((element, index) => {
|
|
1172
1172
|
if (isPendingCertificationFlag(element)) {
|
|
1173
1173
|
indicesToRemove.push(index);
|
|
1174
1174
|
}
|
|
1175
1175
|
});
|
|
1176
1176
|
for (const index of indicesToRemove.reverse()) {
|
|
1177
|
-
|
|
1177
|
+
array.removeElement(index);
|
|
1178
1178
|
removedCount++;
|
|
1179
1179
|
console.log(
|
|
1180
1180
|
` [${import_path7.default.relative(getCwd(), filePath)}] Removed InherentFlags.PENDING_CERTIFICATION from array`
|
|
@@ -1811,9 +1811,9 @@ function updateRouteHandlers(sourceFiles, group, srcDir, relCwd) {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
return replacedCount;
|
|
1813
1813
|
}
|
|
1814
|
-
function resolveConfigChain(configObj,
|
|
1814
|
+
function resolveConfigChain(configObj, path12) {
|
|
1815
1815
|
let current = configObj;
|
|
1816
|
-
for (const key of
|
|
1816
|
+
for (const key of path12) {
|
|
1817
1817
|
if (!import_ts_morph10.Node.isObjectLiteralExpression(current)) return null;
|
|
1818
1818
|
const prop = current.getProperty(key);
|
|
1819
1819
|
if (!prop || !import_ts_morph10.Node.isPropertyAssignment(prop)) return null;
|
|
@@ -2000,486 +2000,7 @@ Done. Converted ${convertedCount} config file(s), replaced ${totalReplaced} rout
|
|
|
2000
2000
|
// src/migrations/v2.0/migrate-scopes.ts
|
|
2001
2001
|
var import_ts_morph11 = require("ts-morph");
|
|
2002
2002
|
var import_path11 = __toESM(require("path"));
|
|
2003
|
-
|
|
2004
|
-
// ../commons/src/scopes.ts
|
|
2005
|
-
var z3 = __toESM(require("zod/v4"));
|
|
2006
|
-
var qs = __toESM(require("qs"));
|
|
2007
|
-
|
|
2008
|
-
// ../commons/src/uuid.ts
|
|
2009
|
-
var import_uuid = require("uuid");
|
|
2010
|
-
var z = __toESM(require("zod/v4"));
|
|
2011
|
-
var UUID = z.uuid().brand("UUID");
|
|
2012
|
-
|
|
2013
|
-
// ../commons/src/authentication.ts
|
|
2014
|
-
var import_jwt_decode = __toESM(require("jwt-decode"));
|
|
2015
|
-
var z2 = __toESM(require("zod/v4"));
|
|
2016
|
-
var TokenUserType = z2.enum(["user", "system"]);
|
|
2017
|
-
var TokenWithBearer = z2.string().regex(/^Bearer\s/);
|
|
2018
|
-
|
|
2019
|
-
// ../commons/src/scopes.ts
|
|
2020
|
-
var JurisdictionFilter = z3.enum(["administrativeArea", "location", "all"]).describe(
|
|
2021
|
-
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
2022
|
-
);
|
|
2023
|
-
var UserFilter = z3.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
2024
|
-
var RecordScopeTypeV2 = z3.enum([
|
|
2025
|
-
"record.search",
|
|
2026
|
-
"record.create",
|
|
2027
|
-
"record.read",
|
|
2028
|
-
"record.declare",
|
|
2029
|
-
"record.notify",
|
|
2030
|
-
"record.edit",
|
|
2031
|
-
"record.reject",
|
|
2032
|
-
"record.archive",
|
|
2033
|
-
"record.review-duplicates",
|
|
2034
|
-
"record.register",
|
|
2035
|
-
"record.print-certified-copies",
|
|
2036
|
-
"record.request-correction",
|
|
2037
|
-
"record.correct",
|
|
2038
|
-
"record.unassign-others",
|
|
2039
|
-
"record.custom-action"
|
|
2040
|
-
]);
|
|
2041
|
-
var PlainScopeType = z3.enum([
|
|
2042
|
-
// Misc. system scopes
|
|
2043
|
-
"bypassratelimit",
|
|
2044
|
-
"record.reindex",
|
|
2045
|
-
"user.data-seeding",
|
|
2046
|
-
"integration.create",
|
|
2047
|
-
"record.import",
|
|
2048
|
-
"config.update-all",
|
|
2049
|
-
"attachment.upload",
|
|
2050
|
-
"profile.electronic-signature",
|
|
2051
|
-
"user.read-only-my-audit",
|
|
2052
|
-
// Performance dashboard
|
|
2053
|
-
"performance.read",
|
|
2054
|
-
"performance.read-dashboards",
|
|
2055
|
-
"performance.vital-statistics-export",
|
|
2056
|
-
// Scopes used exclusively by countryconfig integration token
|
|
2057
|
-
"record.confirm-registration",
|
|
2058
|
-
"record.reject-registration"
|
|
2059
|
-
]);
|
|
2060
|
-
var scopeByEvent = z3.preprocess(
|
|
2061
|
-
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2062
|
-
z3.array(z3.string()).optional()
|
|
2063
|
-
).describe("Event type, e.g. birth, death");
|
|
2064
|
-
var scopeOptionsPlaceEvent = z3.object({
|
|
2065
|
-
event: scopeByEvent,
|
|
2066
|
-
placeOfEvent: JurisdictionFilter.optional()
|
|
2067
|
-
}).describe("Options applicable to all record scopes.");
|
|
2068
|
-
var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
|
|
2069
|
-
declaredIn: JurisdictionFilter.optional(),
|
|
2070
|
-
declaredBy: UserFilter.optional()
|
|
2071
|
-
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
2072
|
-
var AllRecordScopeOptions = scopeOptionsDeclared.extend({
|
|
2073
|
-
registeredIn: JurisdictionFilter.optional(),
|
|
2074
|
-
registeredBy: UserFilter.optional()
|
|
2075
|
-
}).describe(
|
|
2076
|
-
"Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
|
|
2077
|
-
);
|
|
2078
|
-
var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
2079
|
-
customActionTypes: z3.preprocess(
|
|
2080
|
-
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2081
|
-
z3.array(z3.string()).optional()
|
|
2082
|
-
).describe("Allowed custom action types")
|
|
2083
|
-
});
|
|
2084
|
-
var AccessLevelOptions = z3.object({
|
|
2085
|
-
accessLevel: JurisdictionFilter.optional()
|
|
2086
|
-
});
|
|
2087
|
-
var WorkqueueOrDashboardOptions = z3.object({
|
|
2088
|
-
ids: z3.preprocess(
|
|
2089
|
-
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2090
|
-
z3.array(z3.string())
|
|
2091
|
-
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
2092
|
-
});
|
|
2093
|
-
var AllScopeOptions = z3.object({
|
|
2094
|
-
...AllRecordScopeOptions.shape,
|
|
2095
|
-
...AccessLevelOptions.shape,
|
|
2096
|
-
...WorkqueueOrDashboardOptions.shape
|
|
2097
|
-
});
|
|
2098
|
-
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
2099
|
-
var ResolvedScopeOptionsPlaceEvent = z3.object({
|
|
2100
|
-
event: scopeByEvent,
|
|
2101
|
-
placeOfEvent: UUID.nullish()
|
|
2102
|
-
}).describe(
|
|
2103
|
-
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
2104
|
-
);
|
|
2105
|
-
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
2106
|
-
declaredIn: UUID.nullish(),
|
|
2107
|
-
declaredBy: z3.string().optional()
|
|
2108
|
-
}).describe(
|
|
2109
|
-
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
2110
|
-
);
|
|
2111
|
-
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
2112
|
-
registeredIn: UUID.nullish(),
|
|
2113
|
-
registeredBy: z3.string().optional()
|
|
2114
|
-
}).describe(
|
|
2115
|
-
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
2116
|
-
);
|
|
2117
|
-
var ScopesWithPlaceEventOptions = RecordScopeTypeV2.extract([
|
|
2118
|
-
"record.create",
|
|
2119
|
-
"record.declare",
|
|
2120
|
-
"record.notify"
|
|
2121
|
-
]);
|
|
2122
|
-
var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
|
|
2123
|
-
"record.edit",
|
|
2124
|
-
"record.reject",
|
|
2125
|
-
"record.archive",
|
|
2126
|
-
"record.review-duplicates",
|
|
2127
|
-
"record.register"
|
|
2128
|
-
]);
|
|
2129
|
-
var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
2130
|
-
"record.search",
|
|
2131
|
-
"record.read",
|
|
2132
|
-
"record.request-correction",
|
|
2133
|
-
"record.correct",
|
|
2134
|
-
"record.unassign-others"
|
|
2135
|
-
]);
|
|
2136
|
-
var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
2137
|
-
templates: z3.preprocess(
|
|
2138
|
-
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
2139
|
-
z3.array(z3.string()).optional()
|
|
2140
|
-
).describe(
|
|
2141
|
-
"Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
|
|
2142
|
-
)
|
|
2143
|
-
});
|
|
2144
|
-
var RecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2145
|
-
z3.object({
|
|
2146
|
-
type: ScopesWithPlaceEventOptions,
|
|
2147
|
-
options: scopeOptionsPlaceEvent.optional()
|
|
2148
|
-
}),
|
|
2149
|
-
z3.object({
|
|
2150
|
-
type: ScopesWithDeclaredOptions,
|
|
2151
|
-
options: scopeOptionsDeclared.optional()
|
|
2152
|
-
}),
|
|
2153
|
-
z3.object({
|
|
2154
|
-
type: ScopesWithFullOptions,
|
|
2155
|
-
options: AllRecordScopeOptions.optional()
|
|
2156
|
-
}),
|
|
2157
|
-
z3.object({
|
|
2158
|
-
type: z3.literal("record.custom-action"),
|
|
2159
|
-
options: CustomActionScopeOptions.optional()
|
|
2160
|
-
}),
|
|
2161
|
-
z3.object({
|
|
2162
|
-
type: z3.literal("record.print-certified-copies"),
|
|
2163
|
-
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
2164
|
-
})
|
|
2165
|
-
]).describe(
|
|
2166
|
-
"Scopes used to check user's permission to perform actions on a record."
|
|
2167
|
-
);
|
|
2168
|
-
var ResolvedRecordScopeV2 = z3.discriminatedUnion("type", [
|
|
2169
|
-
z3.object({
|
|
2170
|
-
type: ScopesWithPlaceEventOptions,
|
|
2171
|
-
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
2172
|
-
}),
|
|
2173
|
-
z3.object({
|
|
2174
|
-
type: ScopesWithDeclaredOptions,
|
|
2175
|
-
options: ResolvedScopeOptionsDeclared.optional()
|
|
2176
|
-
}),
|
|
2177
|
-
z3.object({
|
|
2178
|
-
type: ScopesWithFullOptions,
|
|
2179
|
-
options: ResolvedScopeOptionsFull.optional()
|
|
2180
|
-
}),
|
|
2181
|
-
z3.object({
|
|
2182
|
-
type: z3.literal("record.print-certified-copies"),
|
|
2183
|
-
options: ResolvedScopeOptionsFull.extend({
|
|
2184
|
-
templates: z3.array(z3.string()).optional()
|
|
2185
|
-
}).optional()
|
|
2186
|
-
})
|
|
2187
|
-
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
2188
|
-
var SystemScopeType = z3.enum([
|
|
2189
|
-
"organisation.read-locations",
|
|
2190
|
-
"user.read",
|
|
2191
|
-
"user.create",
|
|
2192
|
-
"user.edit"
|
|
2193
|
-
]);
|
|
2194
|
-
var Scope2 = z3.discriminatedUnion("type", [
|
|
2195
|
-
z3.object({ type: PlainScopeType }),
|
|
2196
|
-
...RecordScopeV2.options,
|
|
2197
|
-
z3.object({ type: SystemScopeType, options: AccessLevelOptions.optional() }),
|
|
2198
|
-
z3.object({
|
|
2199
|
-
type: z3.literal("workqueue"),
|
|
2200
|
-
options: WorkqueueOrDashboardOptions
|
|
2201
|
-
}),
|
|
2202
|
-
z3.object({
|
|
2203
|
-
type: z3.literal("dashboard.view"),
|
|
2204
|
-
options: WorkqueueOrDashboardOptions
|
|
2205
|
-
})
|
|
2206
|
-
]);
|
|
2207
|
-
var ScopeType2 = z3.enum([
|
|
2208
|
-
...SystemScopeType.options,
|
|
2209
|
-
...RecordScopeTypeV2.options,
|
|
2210
|
-
...PlainScopeType.options,
|
|
2211
|
-
"workqueue",
|
|
2212
|
-
"dashboard.view"
|
|
2213
|
-
]);
|
|
2214
|
-
var flattenScope = (scope) => ({
|
|
2215
|
-
type: scope.type,
|
|
2216
|
-
..."options" in scope ? scope.options : {}
|
|
2217
|
-
});
|
|
2218
|
-
var unflattenScope = (input) => {
|
|
2219
|
-
const { type, ...options } = input;
|
|
2220
|
-
return { type, options };
|
|
2221
|
-
};
|
|
2222
|
-
var EncodedScope2 = z3.string().brand("EncodedScope");
|
|
2223
|
-
var encodeScope = (scope) => {
|
|
2224
|
-
const flattened = flattenScope(scope);
|
|
2225
|
-
return qs.stringify(flattened, {
|
|
2226
|
-
arrayFormat: "comma",
|
|
2227
|
-
allowDots: true,
|
|
2228
|
-
addQueryPrefix: false,
|
|
2229
|
-
encode: false
|
|
2230
|
-
});
|
|
2231
|
-
};
|
|
2232
|
-
var decodeScope = (query) => {
|
|
2233
|
-
const scope = qs.parse(query, {
|
|
2234
|
-
ignoreQueryPrefix: true,
|
|
2235
|
-
comma: true,
|
|
2236
|
-
allowDots: true
|
|
2237
|
-
});
|
|
2238
|
-
const unflattenedScope = unflattenScope(scope);
|
|
2239
|
-
return Scope2.safeParse(unflattenedScope)?.data;
|
|
2240
|
-
};
|
|
2241
|
-
var DEFAULT_SCOPE_OPTIONS = {
|
|
2242
|
-
placeOfEvent: JurisdictionFilter.enum.all,
|
|
2243
|
-
accessLevel: JurisdictionFilter.enum.all
|
|
2244
|
-
};
|
|
2245
|
-
|
|
2246
|
-
// ../commons/src/scopes.deprecated.do-not-use.ts
|
|
2247
|
-
var z4 = __toESM(require("zod/v4"));
|
|
2248
|
-
var rawConfigurableScopeRegex = /^([a-zA-Z][a-zA-Z0-9.-]*(?:\.[a-zA-Z0-9.-]+)*)\[((?:\w+=[\w.-]+(?:\|[\w.-]+)*)(?:,[\w]+=[\w.-]+(?:\|[\w.-]+)*)*)\]$/;
|
|
2249
|
-
var rawConfigurableScope = z4.string().regex(rawConfigurableScopeRegex);
|
|
2250
|
-
var SearchScope = z4.object({
|
|
2251
|
-
type: z4.literal("search"),
|
|
2252
|
-
options: z4.object({
|
|
2253
|
-
event: z4.array(z4.string()).length(1),
|
|
2254
|
-
access: z4.array(z4.enum(["my-jurisdiction", "all"])).length(1)
|
|
2255
|
-
})
|
|
2256
|
-
});
|
|
2257
|
-
var CreateUserScope = z4.object({
|
|
2258
|
-
type: z4.literal("user.create"),
|
|
2259
|
-
options: z4.object({
|
|
2260
|
-
role: z4.array(z4.string())
|
|
2261
|
-
})
|
|
2262
|
-
});
|
|
2263
|
-
var EditUserScope = z4.object({
|
|
2264
|
-
type: z4.literal("user.edit"),
|
|
2265
|
-
options: z4.object({
|
|
2266
|
-
role: z4.array(z4.string())
|
|
2267
|
-
})
|
|
2268
|
-
});
|
|
2269
|
-
var WorkqueueScope = z4.object({
|
|
2270
|
-
type: z4.literal("workqueue"),
|
|
2271
|
-
options: z4.object({
|
|
2272
|
-
id: z4.array(z4.string())
|
|
2273
|
-
})
|
|
2274
|
-
});
|
|
2275
|
-
var PrintCertifiedCopiesScope = z4.object({
|
|
2276
|
-
type: z4.literal("record.registered.print-certified-copies"),
|
|
2277
|
-
options: z4.object({
|
|
2278
|
-
event: z4.array(z4.string()).describe("Event type, e.g. birth, death"),
|
|
2279
|
-
templates: z4.array(z4.string()).optional().describe(
|
|
2280
|
-
"Template IDs for certified copies. If not provided, all templates will be used."
|
|
2281
|
-
)
|
|
2282
|
-
})
|
|
2283
|
-
});
|
|
2284
|
-
var LegacyRecordScope = z4.object({
|
|
2285
|
-
type: z4.enum([
|
|
2286
|
-
"record.create",
|
|
2287
|
-
"record.read",
|
|
2288
|
-
"record.declare",
|
|
2289
|
-
"record.notify",
|
|
2290
|
-
"record.declared.edit",
|
|
2291
|
-
"record.declared.validate",
|
|
2292
|
-
"record.declared.reject",
|
|
2293
|
-
"record.declared.archive",
|
|
2294
|
-
"record.declared.review-duplicates",
|
|
2295
|
-
"record.register",
|
|
2296
|
-
"record.registered.request-correction",
|
|
2297
|
-
"record.registered.correct",
|
|
2298
|
-
"record.unassign-others"
|
|
2299
|
-
]),
|
|
2300
|
-
options: z4.object({
|
|
2301
|
-
event: z4.array(z4.string()).describe("Event type, e.g. birth, death")
|
|
2302
|
-
})
|
|
2303
|
-
}).describe(
|
|
2304
|
-
"Scopes used to check user's permission to perform actions on a record."
|
|
2305
|
-
);
|
|
2306
|
-
var ConfigurableRawScopes = z4.discriminatedUnion("type", [
|
|
2307
|
-
SearchScope,
|
|
2308
|
-
LegacyRecordScope,
|
|
2309
|
-
PrintCertifiedCopiesScope,
|
|
2310
|
-
CreateUserScope,
|
|
2311
|
-
EditUserScope,
|
|
2312
|
-
WorkqueueScope
|
|
2313
|
-
]);
|
|
2314
|
-
function getScopeOptions(rawOptions) {
|
|
2315
|
-
return rawOptions.split(",").reduce((acc, option) => {
|
|
2316
|
-
const [key, value] = option.split("=");
|
|
2317
|
-
acc[key] = value.split("|");
|
|
2318
|
-
return acc;
|
|
2319
|
-
}, {});
|
|
2320
|
-
}
|
|
2321
|
-
function parseConfigurableScope(scope) {
|
|
2322
|
-
const maybeConfigurableScope = rawConfigurableScope.safeParse(scope);
|
|
2323
|
-
if (!maybeConfigurableScope.success) {
|
|
2324
|
-
return;
|
|
2325
|
-
}
|
|
2326
|
-
const rawScope = maybeConfigurableScope.data;
|
|
2327
|
-
const [, type, rawOptions] = rawScope.match(rawConfigurableScopeRegex) ?? [];
|
|
2328
|
-
const options = getScopeOptions(rawOptions);
|
|
2329
|
-
const parsedScope = {
|
|
2330
|
-
type,
|
|
2331
|
-
options
|
|
2332
|
-
};
|
|
2333
|
-
const result = ConfigurableRawScopes.safeParse(parsedScope);
|
|
2334
|
-
return result.success ? result.data : void 0;
|
|
2335
|
-
}
|
|
2336
|
-
var SCOPES = {
|
|
2337
|
-
BYPASSRATELIMIT: "bypassratelimit",
|
|
2338
|
-
RECORD_REINDEX: "record.reindex",
|
|
2339
|
-
RECORD_IMPORT: "record.import",
|
|
2340
|
-
ATTACHMENT_UPLOAD: "attachment.upload",
|
|
2341
|
-
USER_DATA_SEEDING: "user.data-seeding",
|
|
2342
|
-
INTEGRATION_CREATE: "integration.create",
|
|
2343
|
-
PERFORMANCE_EXPORT_VITAL_STATISTICS: "performance.vital-statistics-export",
|
|
2344
|
-
PROFILE_ELECTRONIC_SIGNATURE: "profile.electronic-signature",
|
|
2345
|
-
PERFORMANCE_READ: "performance.read",
|
|
2346
|
-
PERFORMANCE_READ_DASHBOARDS: "performance.read-dashboards",
|
|
2347
|
-
CONFIG_UPDATE_ALL: "config.update-all",
|
|
2348
|
-
ORGANISATION_READ_LOCATIONS: "organisation.read-locations",
|
|
2349
|
-
ORGANISATION_READ_LOCATIONS_MY_OFFICE: "organisation.read-locations:my-office",
|
|
2350
|
-
ORGANISATION_READ_LOCATIONS_MY_JURISDICTION: "organisation.read-locations:my-jurisdiction",
|
|
2351
|
-
USER_CREATE: "user.create:all",
|
|
2352
|
-
USER_READ: "user.read:all",
|
|
2353
|
-
USER_UPDATE: "user.update:all",
|
|
2354
|
-
USER_READ_MY_OFFICE: "user.read:my-office",
|
|
2355
|
-
USER_READ_MY_JURISDICTION: "user.read:my-jurisdiction",
|
|
2356
|
-
USER_READ_ONLY_MY_AUDIT: "user.read:only-my-audit",
|
|
2357
|
-
USER_CREATE_MY_JURISDICTION: "user.create:my-jurisdiction",
|
|
2358
|
-
USER_UPDATE_MY_JURISDICTION: "user.update:my-jurisdiction"
|
|
2359
|
-
};
|
|
2360
|
-
var literalScopeToV2ScopeMap = {
|
|
2361
|
-
[SCOPES.BYPASSRATELIMIT]: { type: "bypassratelimit" },
|
|
2362
|
-
[SCOPES.RECORD_REINDEX]: { type: "record.reindex" },
|
|
2363
|
-
[SCOPES.RECORD_IMPORT]: { type: "record.import" },
|
|
2364
|
-
[SCOPES.ATTACHMENT_UPLOAD]: { type: "attachment.upload" },
|
|
2365
|
-
[SCOPES.USER_DATA_SEEDING]: { type: "user.data-seeding" },
|
|
2366
|
-
[SCOPES.INTEGRATION_CREATE]: { type: "integration.create" },
|
|
2367
|
-
[SCOPES.PERFORMANCE_EXPORT_VITAL_STATISTICS]: {
|
|
2368
|
-
type: "performance.vital-statistics-export"
|
|
2369
|
-
},
|
|
2370
|
-
[SCOPES.PROFILE_ELECTRONIC_SIGNATURE]: {
|
|
2371
|
-
type: "profile.electronic-signature"
|
|
2372
|
-
},
|
|
2373
|
-
[SCOPES.PERFORMANCE_READ]: { type: "performance.read" },
|
|
2374
|
-
[SCOPES.PERFORMANCE_READ_DASHBOARDS]: { type: "performance.read-dashboards" },
|
|
2375
|
-
[SCOPES.CONFIG_UPDATE_ALL]: { type: "config.update-all" },
|
|
2376
|
-
[SCOPES.ORGANISATION_READ_LOCATIONS]: {
|
|
2377
|
-
type: "organisation.read-locations"
|
|
2378
|
-
},
|
|
2379
|
-
[SCOPES.ORGANISATION_READ_LOCATIONS_MY_OFFICE]: {
|
|
2380
|
-
type: "organisation.read-locations",
|
|
2381
|
-
options: { accessLevel: "location" }
|
|
2382
|
-
},
|
|
2383
|
-
[SCOPES.ORGANISATION_READ_LOCATIONS_MY_JURISDICTION]: {
|
|
2384
|
-
type: "organisation.read-locations",
|
|
2385
|
-
options: { accessLevel: "administrativeArea" }
|
|
2386
|
-
},
|
|
2387
|
-
[SCOPES.USER_CREATE]: { type: "user.create" },
|
|
2388
|
-
[SCOPES.USER_CREATE_MY_JURISDICTION]: {
|
|
2389
|
-
type: "user.create",
|
|
2390
|
-
options: { accessLevel: "administrativeArea" }
|
|
2391
|
-
},
|
|
2392
|
-
[SCOPES.USER_READ]: { type: "user.read" },
|
|
2393
|
-
[SCOPES.USER_READ_MY_OFFICE]: {
|
|
2394
|
-
type: "user.read",
|
|
2395
|
-
options: { accessLevel: "location" }
|
|
2396
|
-
},
|
|
2397
|
-
[SCOPES.USER_READ_MY_JURISDICTION]: {
|
|
2398
|
-
type: "user.read",
|
|
2399
|
-
options: { accessLevel: "administrativeArea" }
|
|
2400
|
-
},
|
|
2401
|
-
[SCOPES.USER_READ_ONLY_MY_AUDIT]: { type: "user.read-only-my-audit" },
|
|
2402
|
-
[SCOPES.USER_UPDATE]: { type: "user.edit" },
|
|
2403
|
-
[SCOPES.USER_UPDATE_MY_JURISDICTION]: {
|
|
2404
|
-
type: "user.edit",
|
|
2405
|
-
options: { accessLevel: "administrativeArea" }
|
|
2406
|
-
}
|
|
2407
|
-
};
|
|
2408
|
-
function parseLiteralScope(scope) {
|
|
2409
|
-
if (scope in literalScopeToV2ScopeMap) {
|
|
2410
|
-
return literalScopeToV2ScopeMap[scope];
|
|
2411
|
-
}
|
|
2412
|
-
return void 0;
|
|
2413
|
-
}
|
|
2414
|
-
var v1ToV2ConfigScopeTypeMap = {
|
|
2415
|
-
search: "record.search",
|
|
2416
|
-
workqueue: "workqueue",
|
|
2417
|
-
"user.create": "user.create",
|
|
2418
|
-
"user.edit": "user.edit",
|
|
2419
|
-
"record.create": "record.create",
|
|
2420
|
-
"record.read": "record.read",
|
|
2421
|
-
"record.declare": "record.declare",
|
|
2422
|
-
"record.notify": "record.notify",
|
|
2423
|
-
"record.register": "record.register",
|
|
2424
|
-
"record.unassign-others": "record.unassign-others",
|
|
2425
|
-
"record.declared.reject": "record.reject",
|
|
2426
|
-
"record.declared.archive": "record.archive",
|
|
2427
|
-
"record.declared.review-duplicates": "record.review-duplicates",
|
|
2428
|
-
"record.registered.print-certified-copies": "record.print-certified-copies",
|
|
2429
|
-
"record.registered.request-correction": "record.request-correction",
|
|
2430
|
-
"record.registered.correct": "record.correct",
|
|
2431
|
-
"record.declared.edit": "record.edit",
|
|
2432
|
-
"record.declared.validate": "record.custom-action"
|
|
2433
|
-
};
|
|
2434
|
-
var legacyScopeToV2Scope = (v1Scope) => {
|
|
2435
|
-
const configurableV1Scope = parseConfigurableScope(v1Scope);
|
|
2436
|
-
const literalV1Scope = parseLiteralScope(v1Scope);
|
|
2437
|
-
if (!configurableV1Scope && !literalV1Scope) {
|
|
2438
|
-
throw new Error(`Invalid V1 scope: ${v1Scope}`);
|
|
2439
|
-
}
|
|
2440
|
-
if (literalV1Scope) {
|
|
2441
|
-
return encodeScope(literalV1Scope);
|
|
2442
|
-
}
|
|
2443
|
-
if (configurableV1Scope) {
|
|
2444
|
-
const type = v1ToV2ConfigScopeTypeMap[configurableV1Scope.type];
|
|
2445
|
-
if (type === void 0) {
|
|
2446
|
-
throw new Error(`Unsupported V1 scope type: ${configurableV1Scope.type}`);
|
|
2447
|
-
}
|
|
2448
|
-
if (configurableV1Scope.type === "workqueue") {
|
|
2449
|
-
return encodeScope({
|
|
2450
|
-
type: "workqueue",
|
|
2451
|
-
options: {
|
|
2452
|
-
ids: configurableV1Scope.options.id || []
|
|
2453
|
-
}
|
|
2454
|
-
});
|
|
2455
|
-
}
|
|
2456
|
-
if (configurableV1Scope.type === "search") {
|
|
2457
|
-
return encodeScope({
|
|
2458
|
-
type,
|
|
2459
|
-
options: {
|
|
2460
|
-
event: configurableV1Scope.options.event || [],
|
|
2461
|
-
placeOfEvent: configurableV1Scope.options.access[0] === "my-jurisdiction" ? "administrativeArea" : "all"
|
|
2462
|
-
}
|
|
2463
|
-
});
|
|
2464
|
-
}
|
|
2465
|
-
if (configurableV1Scope.type === "record.declared.validate") {
|
|
2466
|
-
return encodeScope({
|
|
2467
|
-
type: "record.custom-action",
|
|
2468
|
-
options: {
|
|
2469
|
-
event: configurableV1Scope.options.event,
|
|
2470
|
-
customActionTypes: ["VALIDATE_DECLARATION"]
|
|
2471
|
-
}
|
|
2472
|
-
});
|
|
2473
|
-
}
|
|
2474
|
-
return encodeScope({
|
|
2475
|
-
type,
|
|
2476
|
-
options: configurableV1Scope.options
|
|
2477
|
-
});
|
|
2478
|
-
}
|
|
2479
|
-
throw new Error(`Unsupported V1 scope type: ${v1Scope}`);
|
|
2480
|
-
};
|
|
2481
|
-
|
|
2482
|
-
// src/migrations/v2.0/migrate-scopes.ts
|
|
2003
|
+
var import_commons = require("@opencrvs/commons");
|
|
2483
2004
|
var ROLES_FILE_RELATIVE_PATH = "src/data-seeding/roles/roles.ts";
|
|
2484
2005
|
var SCOPES_PROPERTY_NAME = "scopes";
|
|
2485
2006
|
var TOOLKIT_SCOPES_MODULE = "@opencrvs/toolkit/scopes";
|
|
@@ -2503,7 +2024,7 @@ function resolveLegacyScopeFromElement(element) {
|
|
|
2503
2024
|
}
|
|
2504
2025
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
2505
2026
|
if (scopeKey) {
|
|
2506
|
-
const scopeValue = SCOPES[scopeKey];
|
|
2027
|
+
const scopeValue = import_commons.SCOPES[scopeKey];
|
|
2507
2028
|
return typeof scopeValue === "string" ? scopeValue : null;
|
|
2508
2029
|
}
|
|
2509
2030
|
const expressionType = element.getType();
|
|
@@ -2527,7 +2048,7 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2527
2048
|
const element = elements[index];
|
|
2528
2049
|
if (!import_ts_morph11.Node.isExpression(element)) continue;
|
|
2529
2050
|
const scopeKey = resolveScopeKeyFromElementAccess(element);
|
|
2530
|
-
if (scopeKey && !(scopeKey in SCOPES)) {
|
|
2051
|
+
if (scopeKey && !(scopeKey in import_commons.SCOPES)) {
|
|
2531
2052
|
console.warn(
|
|
2532
2053
|
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Removing unknown scope reference: SCOPES.${scopeKey}`
|
|
2533
2054
|
);
|
|
@@ -2543,8 +2064,8 @@ function migrateScopesArrays(rolesFilePath, project) {
|
|
|
2543
2064
|
continue;
|
|
2544
2065
|
}
|
|
2545
2066
|
try {
|
|
2546
|
-
const migratedScope = legacyScopeToV2Scope(legacyScope);
|
|
2547
|
-
const scope = decodeScope(migratedScope);
|
|
2067
|
+
const migratedScope = (0, import_commons.legacyScopeToV2Scope)(legacyScope);
|
|
2068
|
+
const scope = (0, import_commons.decodeScope)(migratedScope);
|
|
2548
2069
|
if (!scope) {
|
|
2549
2070
|
console.warn(
|
|
2550
2071
|
` [${import_path11.default.relative(getCwd(), rolesFilePath)}] Could not decode migrated scope '${migratedScope}'.`
|
|
@@ -2793,264 +2314,6 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
2793
2314
|
Done. Removed ${totalRemoved} deprecated import(s).`);
|
|
2794
2315
|
}
|
|
2795
2316
|
|
|
2796
|
-
// src/migrations/v2.0/migrate-workqueue-configs.ts
|
|
2797
|
-
var import_ts_morph13 = require("ts-morph");
|
|
2798
|
-
var import_path13 = __toESM(require("path"));
|
|
2799
|
-
var DEFINE_WORKQUEUES_NAME3 = "defineWorkqueues";
|
|
2800
|
-
var ACTIONS_PROPERTY_NAME5 = "actions";
|
|
2801
|
-
var ACTION_PROPERTY_NAME2 = "action";
|
|
2802
|
-
var CONDITIONALS_PROPERTY_NAME = "conditionals";
|
|
2803
|
-
var TYPE_PROPERTY_NAME7 = "type";
|
|
2804
|
-
var SLUG_PROPERTY_NAME = "slug";
|
|
2805
|
-
var SUPPORTED_WORKQUEUE_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
2806
|
-
"READ",
|
|
2807
|
-
"DELETE",
|
|
2808
|
-
"DECLARE",
|
|
2809
|
-
"REGISTER",
|
|
2810
|
-
"EDIT",
|
|
2811
|
-
"REJECT",
|
|
2812
|
-
"MARK_AS_DUPLICATE",
|
|
2813
|
-
"ARCHIVE",
|
|
2814
|
-
"PRINT_CERTIFICATE",
|
|
2815
|
-
"REQUEST_CORRECTION"
|
|
2816
|
-
]);
|
|
2817
|
-
function getWorkqueueLabel(workqueue) {
|
|
2818
|
-
const slugProperty = workqueue.getProperty(SLUG_PROPERTY_NAME);
|
|
2819
|
-
if (!slugProperty || !import_ts_morph13.Node.isPropertyAssignment(slugProperty)) {
|
|
2820
|
-
return "(unknown slug)";
|
|
2821
|
-
}
|
|
2822
|
-
const slugInitializer = slugProperty.getInitializer();
|
|
2823
|
-
if (!slugInitializer || !import_ts_morph13.Node.isStringLiteral(slugInitializer)) {
|
|
2824
|
-
return "(unknown slug)";
|
|
2825
|
-
}
|
|
2826
|
-
return slugInitializer.getLiteralValue();
|
|
2827
|
-
}
|
|
2828
|
-
function getActionTypeName(action) {
|
|
2829
|
-
const typeProperty = action.getProperty(TYPE_PROPERTY_NAME7);
|
|
2830
|
-
if (!typeProperty || !import_ts_morph13.Node.isPropertyAssignment(typeProperty)) {
|
|
2831
|
-
return null;
|
|
2832
|
-
}
|
|
2833
|
-
const typeInitializer = typeProperty.getInitializer();
|
|
2834
|
-
if (!typeInitializer) {
|
|
2835
|
-
return null;
|
|
2836
|
-
}
|
|
2837
|
-
if (import_ts_morph13.Node.isStringLiteral(typeInitializer)) {
|
|
2838
|
-
return typeInitializer.getLiteralValue();
|
|
2839
|
-
}
|
|
2840
|
-
if (import_ts_morph13.Node.isPropertyAccessExpression(typeInitializer)) {
|
|
2841
|
-
return typeInitializer.getName();
|
|
2842
|
-
}
|
|
2843
|
-
return null;
|
|
2844
|
-
}
|
|
2845
|
-
function isUnsupportedActionType(action) {
|
|
2846
|
-
const typeName = getActionTypeName(action);
|
|
2847
|
-
if (!typeName) {
|
|
2848
|
-
return false;
|
|
2849
|
-
}
|
|
2850
|
-
return !SUPPORTED_WORKQUEUE_ACTION_TYPES.has(typeName);
|
|
2851
|
-
}
|
|
2852
|
-
function migrateWorkqueueActions(workqueue, relPath) {
|
|
2853
|
-
const actionsProperty = workqueue.getProperty(ACTIONS_PROPERTY_NAME5);
|
|
2854
|
-
if (!actionsProperty || !import_ts_morph13.Node.isPropertyAssignment(actionsProperty)) {
|
|
2855
|
-
return 0;
|
|
2856
|
-
}
|
|
2857
|
-
const actionsInitializer = actionsProperty.getInitializer();
|
|
2858
|
-
if (!actionsInitializer || !import_ts_morph13.Node.isArrayLiteralExpression(actionsInitializer)) {
|
|
2859
|
-
return 0;
|
|
2860
|
-
}
|
|
2861
|
-
const workqueueLabel = getWorkqueueLabel(workqueue);
|
|
2862
|
-
const existingActionProperty = workqueue.getProperty(ACTION_PROPERTY_NAME2);
|
|
2863
|
-
if (existingActionProperty) {
|
|
2864
|
-
if (import_ts_morph13.Node.isPropertyAssignment(existingActionProperty)) {
|
|
2865
|
-
const existingActionInitializer = existingActionProperty.getInitializer();
|
|
2866
|
-
if (existingActionInitializer && import_ts_morph13.Node.isObjectLiteralExpression(existingActionInitializer)) {
|
|
2867
|
-
const conditionalsProperty2 = existingActionInitializer.getProperty(
|
|
2868
|
-
CONDITIONALS_PROPERTY_NAME
|
|
2869
|
-
);
|
|
2870
|
-
if (conditionalsProperty2) {
|
|
2871
|
-
conditionalsProperty2.remove();
|
|
2872
|
-
console.log(
|
|
2873
|
-
` [${relPath}] Removed deprecated 'conditionals' from 'action' on workqueue '${workqueueLabel}'`
|
|
2874
|
-
);
|
|
2875
|
-
}
|
|
2876
|
-
if (isUnsupportedActionType(existingActionInitializer)) {
|
|
2877
|
-
existingActionProperty.remove();
|
|
2878
|
-
console.log(
|
|
2879
|
-
` [${relPath}] Removed unsupported 'action' type on workqueue '${workqueueLabel}'`
|
|
2880
|
-
);
|
|
2881
|
-
}
|
|
2882
|
-
}
|
|
2883
|
-
}
|
|
2884
|
-
actionsProperty.remove();
|
|
2885
|
-
console.log(
|
|
2886
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' (existing 'action' kept)`
|
|
2887
|
-
);
|
|
2888
|
-
return 1;
|
|
2889
|
-
}
|
|
2890
|
-
const actionCandidates = actionsInitializer.getElements().filter(
|
|
2891
|
-
(element) => import_ts_morph13.Node.isObjectLiteralExpression(element)
|
|
2892
|
-
);
|
|
2893
|
-
if (actionCandidates.length === 0) {
|
|
2894
|
-
actionsProperty.remove();
|
|
2895
|
-
console.log(
|
|
2896
|
-
` [${relPath}] Removed empty 'actions' from workqueue '${workqueueLabel}'`
|
|
2897
|
-
);
|
|
2898
|
-
return 1;
|
|
2899
|
-
}
|
|
2900
|
-
if (actionCandidates.length > 1) {
|
|
2901
|
-
const droppedCount = actionCandidates.length - 1;
|
|
2902
|
-
console.warn(
|
|
2903
|
-
` [${relPath}] Workqueue '${workqueueLabel}' has ${actionCandidates.length} actions; keeping first as 'action' and dropping ${droppedCount} extra action(s)`
|
|
2904
|
-
);
|
|
2905
|
-
}
|
|
2906
|
-
const conditionalsProperty = actionCandidates[0].getProperty(
|
|
2907
|
-
CONDITIONALS_PROPERTY_NAME
|
|
2908
|
-
);
|
|
2909
|
-
if (conditionalsProperty) {
|
|
2910
|
-
conditionalsProperty.remove();
|
|
2911
|
-
console.log(
|
|
2912
|
-
` [${relPath}] Removed deprecated 'conditionals' from migrated 'action' on workqueue '${workqueueLabel}'`
|
|
2913
|
-
);
|
|
2914
|
-
}
|
|
2915
|
-
if (isUnsupportedActionType(actionCandidates[0])) {
|
|
2916
|
-
actionsProperty.remove();
|
|
2917
|
-
console.log(
|
|
2918
|
-
` [${relPath}] Removed deprecated 'actions' from workqueue '${workqueueLabel}' because action type is unsupported`
|
|
2919
|
-
);
|
|
2920
|
-
return 1;
|
|
2921
|
-
}
|
|
2922
|
-
const firstActionText = actionCandidates[0].getText();
|
|
2923
|
-
workqueue.addPropertyAssignment({
|
|
2924
|
-
name: ACTION_PROPERTY_NAME2,
|
|
2925
|
-
initializer: firstActionText
|
|
2926
|
-
});
|
|
2927
|
-
actionsProperty.remove();
|
|
2928
|
-
console.log(
|
|
2929
|
-
` [${relPath}] Replaced 'actions' with 'action' on workqueue '${workqueueLabel}'`
|
|
2930
|
-
);
|
|
2931
|
-
return 1;
|
|
2932
|
-
}
|
|
2933
|
-
function processFile11(filePath, project) {
|
|
2934
|
-
const sourceFile = project.getSourceFile(filePath);
|
|
2935
|
-
if (!sourceFile) return 0;
|
|
2936
|
-
let migratedWorkqueues = 0;
|
|
2937
|
-
const relPath = import_path13.default.relative(getCwd(), filePath);
|
|
2938
|
-
const callExpressions = sourceFile.getDescendantsOfKind(
|
|
2939
|
-
import_ts_morph13.SyntaxKind.CallExpression
|
|
2940
|
-
);
|
|
2941
|
-
for (const call of callExpressions) {
|
|
2942
|
-
const expression = call.getExpression();
|
|
2943
|
-
if (!import_ts_morph13.Node.isIdentifier(expression) || expression.getText() !== DEFINE_WORKQUEUES_NAME3) {
|
|
2944
|
-
continue;
|
|
2945
|
-
}
|
|
2946
|
-
const args2 = call.getArguments();
|
|
2947
|
-
if (args2.length === 0) continue;
|
|
2948
|
-
const workqueuesArg = args2[0];
|
|
2949
|
-
if (!import_ts_morph13.Node.isArrayLiteralExpression(workqueuesArg)) continue;
|
|
2950
|
-
for (const element of workqueuesArg.getElements()) {
|
|
2951
|
-
if (!import_ts_morph13.Node.isObjectLiteralExpression(element)) continue;
|
|
2952
|
-
migratedWorkqueues += migrateWorkqueueActions(element, relPath);
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
return migratedWorkqueues;
|
|
2956
|
-
}
|
|
2957
|
-
async function main13() {
|
|
2958
|
-
const srcDir = import_path13.default.join(getCwd(), "src");
|
|
2959
|
-
console.log(`Scanning for defineWorkqueues calls in: ${srcDir}
|
|
2960
|
-
`);
|
|
2961
|
-
const project = new import_ts_morph13.Project({
|
|
2962
|
-
tsConfigFilePath: import_path13.default.resolve(srcDir, "../tsconfig.json"),
|
|
2963
|
-
skipAddingFilesFromTsConfig: false
|
|
2964
|
-
});
|
|
2965
|
-
const sourceFiles = project.getSourceFiles().filter((sf) => {
|
|
2966
|
-
const fp = sf.getFilePath();
|
|
2967
|
-
return fp.includes("/src/") && !fp.includes("/node_modules/");
|
|
2968
|
-
});
|
|
2969
|
-
console.log(`Found ${sourceFiles.length} source file(s) to analyse.
|
|
2970
|
-
`);
|
|
2971
|
-
let totalMigrated = 0;
|
|
2972
|
-
const modifiedFiles = [];
|
|
2973
|
-
for (const sourceFile of sourceFiles) {
|
|
2974
|
-
const filePath = sourceFile.getFilePath();
|
|
2975
|
-
const migrated = processFile11(filePath, project);
|
|
2976
|
-
if (migrated > 0) {
|
|
2977
|
-
totalMigrated += migrated;
|
|
2978
|
-
modifiedFiles.push(filePath);
|
|
2979
|
-
}
|
|
2980
|
-
}
|
|
2981
|
-
if (modifiedFiles.length === 0) {
|
|
2982
|
-
console.log(
|
|
2983
|
-
"No deprecated workqueue 'actions' arrays found inside defineWorkqueues calls. Nothing to do."
|
|
2984
|
-
);
|
|
2985
|
-
return;
|
|
2986
|
-
}
|
|
2987
|
-
console.log(`
|
|
2988
|
-
Saving ${modifiedFiles.length} modified file(s)...`);
|
|
2989
|
-
for (const filePath of modifiedFiles) {
|
|
2990
|
-
const sourceFile = project.getSourceFileOrThrow(filePath);
|
|
2991
|
-
await sourceFile.save();
|
|
2992
|
-
console.log(` Saved: ${import_path13.default.relative(getCwd(), filePath)}`);
|
|
2993
|
-
}
|
|
2994
|
-
console.log(
|
|
2995
|
-
`
|
|
2996
|
-
Done. Migrated ${totalMigrated} deprecated workqueue 'actions' definition(s) to 'action'.`
|
|
2997
|
-
);
|
|
2998
|
-
}
|
|
2999
|
-
|
|
3000
|
-
// src/migrations/v2.0/remove-demo-scope.ts
|
|
3001
|
-
var import_path14 = __toESM(require("path"));
|
|
3002
|
-
var import_ts_morph14 = require("ts-morph");
|
|
3003
|
-
var ROLES_HANDLER_RELATIVE_PATH = "src/data-seeding/roles/handler.ts";
|
|
3004
|
-
async function main14() {
|
|
3005
|
-
const rolesHandlerPath = import_path14.default.join(getCwd(), ROLES_HANDLER_RELATIVE_PATH);
|
|
3006
|
-
const project = new import_ts_morph14.Project({
|
|
3007
|
-
tsConfigFilePath: import_path14.default.resolve(getCwd(), "tsconfig.json"),
|
|
3008
|
-
skipAddingFilesFromTsConfig: false
|
|
3009
|
-
});
|
|
3010
|
-
const sourceFile = project.getSourceFile(rolesHandlerPath);
|
|
3011
|
-
if (!sourceFile) {
|
|
3012
|
-
console.log(
|
|
3013
|
-
`No roles handler found at '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`
|
|
3014
|
-
);
|
|
3015
|
-
return;
|
|
3016
|
-
}
|
|
3017
|
-
let changed = false;
|
|
3018
|
-
const constantsImport = sourceFile.getImportDeclaration(
|
|
3019
|
-
(decl) => decl.getModuleSpecifierValue() === "@countryconfig/constants"
|
|
3020
|
-
);
|
|
3021
|
-
if (constantsImport) {
|
|
3022
|
-
constantsImport.remove();
|
|
3023
|
-
changed = true;
|
|
3024
|
-
}
|
|
3025
|
-
const rolesHandler = sourceFile.getFunction("rolesHandler");
|
|
3026
|
-
if (!rolesHandler) {
|
|
3027
|
-
console.log(
|
|
3028
|
-
`No rolesHandler export found in '${ROLES_HANDLER_RELATIVE_PATH}'. Nothing to do.`
|
|
3029
|
-
);
|
|
3030
|
-
return;
|
|
3031
|
-
}
|
|
3032
|
-
const secondParam = rolesHandler.getParameters()[1];
|
|
3033
|
-
const secondParamName = secondParam?.getName();
|
|
3034
|
-
const responseToolkitIdentifier = secondParamName || "h";
|
|
3035
|
-
const currentBodyText = rolesHandler.getBodyText();
|
|
3036
|
-
const normalizedCurrent = currentBodyText?.replace(/\s+/g, " ").trim() ?? "";
|
|
3037
|
-
const normalizedDesired = `return ${responseToolkitIdentifier}.response(roles)`;
|
|
3038
|
-
if (normalizedCurrent !== normalizedDesired) {
|
|
3039
|
-
rolesHandler.setBodyText(`return ${responseToolkitIdentifier}.response(roles)`);
|
|
3040
|
-
changed = true;
|
|
3041
|
-
}
|
|
3042
|
-
if (!changed) {
|
|
3043
|
-
console.log(
|
|
3044
|
-
`No changes needed in '${ROLES_HANDLER_RELATIVE_PATH}'.`
|
|
3045
|
-
);
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
3048
|
-
await sourceFile.save();
|
|
3049
|
-
console.log(
|
|
3050
|
-
`Updated '${ROLES_HANDLER_RELATIVE_PATH}' to remove demo scope behavior while preserving file structure.`
|
|
3051
|
-
);
|
|
3052
|
-
}
|
|
3053
|
-
|
|
3054
2317
|
// src/migrations/v2.0/index.ts
|
|
3055
2318
|
var cwd;
|
|
3056
2319
|
function getCwd() {
|
|
@@ -3070,7 +2333,6 @@ async function runUpgrade(ccwd) {
|
|
|
3070
2333
|
);
|
|
3071
2334
|
cwd = process.cwd();
|
|
3072
2335
|
}
|
|
3073
|
-
await main13();
|
|
3074
2336
|
await main();
|
|
3075
2337
|
await main2();
|
|
3076
2338
|
await main3();
|
|
@@ -3083,7 +2345,6 @@ async function runUpgrade(ccwd) {
|
|
|
3083
2345
|
await main10();
|
|
3084
2346
|
await main11();
|
|
3085
2347
|
await main12();
|
|
3086
|
-
await main14();
|
|
3087
2348
|
}
|
|
3088
2349
|
|
|
3089
2350
|
// src/cli.ts
|
|
@@ -3098,7 +2359,7 @@ Commands:
|
|
|
3098
2359
|
|
|
3099
2360
|
Run 'opencrvs <command> --help' for more information on a command.
|
|
3100
2361
|
`.trim();
|
|
3101
|
-
function
|
|
2362
|
+
function main13() {
|
|
3102
2363
|
const command = args[0];
|
|
3103
2364
|
if (!command || command === "--help" || command === "-h") {
|
|
3104
2365
|
console.log(USAGE);
|
|
@@ -3158,4 +2419,4 @@ function handleCheckTranslations() {
|
|
|
3158
2419
|
console.warn("This command is not implemented yet!");
|
|
3159
2420
|
process.exit(1);
|
|
3160
2421
|
}
|
|
3161
|
-
|
|
2422
|
+
main13();
|