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