@opencrvs/toolkit 2.1.0-rc.9e444d5 → 2.1.0-rc.a434ca3
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/README.md +1 -0
- package/create-countryconfig/index.js +59 -24
- package/dist/application-config/index.js +227 -196
- package/dist/cli.js +174 -58
- package/dist/commons/api/router.d.ts +193 -20
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/conditionals/validate.d.ts +11 -4
- package/dist/commons/events/ActionDocument.d.ts +1 -7
- package/dist/commons/events/ActionStatus.d.ts +14 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/AuditLog.d.ts +110 -0
- package/dist/commons/events/EventConfig.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +3 -26
- package/dist/commons/events/FieldConfig.d.ts +65 -53
- package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
- package/dist/commons/events/FieldValue.d.ts +2 -2
- package/dist/commons/events/Flag.d.ts +42 -0
- package/dist/commons/events/PlainDate.d.ts +8 -0
- package/dist/commons/events/SummaryConfig.d.ts +249 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
- package/dist/commons/events/event.d.ts +12 -0
- package/dist/commons/events/locations.d.ts +99 -16
- package/dist/commons/events/mocks.test.utils.d.ts +30 -0
- package/dist/conditionals/index.js +302 -55
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.d.ts.map +1 -1
- package/dist/environment/index.js +10 -0
- package/dist/environment/logger.d.ts +12 -3
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/paths.d.ts +7 -0
- package/dist/environment/paths.d.ts.map +1 -0
- package/dist/environment/paths.js +72 -0
- package/dist/environment/setup-environment.js +2 -1
- package/dist/environment/templates.d.ts.map +1 -1
- package/dist/environment/templates.js +2 -1
- package/dist/environment/update-workflows.d.ts.map +1 -1
- package/dist/environment/update-workflows.js +17 -5
- package/dist/environment/upgrade.d.ts +2 -0
- package/dist/environment/upgrade.d.ts.map +1 -0
- package/dist/environment/upgrade.js +82 -0
- package/dist/environment/users.js +11 -13
- package/dist/events/index.js +3493 -3250
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
- package/dist/notification/index.js +1806 -1050
- package/dist/scopes/index.d.ts +248 -25
- package/dist/scopes/index.js +303 -55
- package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
- package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
- package/opencrvs-toolkit-2.1.0-rc.a434ca3.tgz +0 -0
- package/package.json +5 -5
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.1.0-rc.9e444d5.tgz +0 -0
|
@@ -47,7 +47,7 @@ __export(conditionals_exports, {
|
|
|
47
47
|
user: () => user
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(conditionals_exports);
|
|
50
|
-
var
|
|
50
|
+
var z12 = __toESM(require("zod/v4"));
|
|
51
51
|
|
|
52
52
|
// ../commons/src/conditionals/conditionals.ts
|
|
53
53
|
var objectHash = __toESM(require("object-hash"));
|
|
@@ -124,7 +124,7 @@ function todayDateTimeValueSerializer() {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
// ../commons/src/scopes.ts
|
|
127
|
-
var
|
|
127
|
+
var z10 = __toESM(require("zod/v4"));
|
|
128
128
|
var qs = __toESM(require("qs"));
|
|
129
129
|
|
|
130
130
|
// ../commons/src/uuid.ts
|
|
@@ -138,12 +138,257 @@ var z5 = __toESM(require("zod/v4"));
|
|
|
138
138
|
var TokenUserType = z5.enum(["user", "system"]);
|
|
139
139
|
var TokenWithBearer = z5.string().regex(/^Bearer\s/);
|
|
140
140
|
|
|
141
|
+
// ../commons/src/events/ActionType.ts
|
|
142
|
+
var z6 = __toESM(require("zod/v4"));
|
|
143
|
+
var ActionType = {
|
|
144
|
+
// Pre-declaration actions
|
|
145
|
+
DELETE: "DELETE",
|
|
146
|
+
CREATE: "CREATE",
|
|
147
|
+
NOTIFY: "NOTIFY",
|
|
148
|
+
// Declaration actions
|
|
149
|
+
DECLARE: "DECLARE",
|
|
150
|
+
REGISTER: "REGISTER",
|
|
151
|
+
EDIT: "EDIT",
|
|
152
|
+
// Declaration system actions. Non-configurable.
|
|
153
|
+
DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
|
|
154
|
+
REJECT: "REJECT",
|
|
155
|
+
// REJECT_DECLARATION
|
|
156
|
+
MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
|
|
157
|
+
MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
|
|
158
|
+
ARCHIVE: "ARCHIVE",
|
|
159
|
+
UNARCHIVE: "UNARCHIVE",
|
|
160
|
+
// Record actions
|
|
161
|
+
PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
|
|
162
|
+
REQUEST_CORRECTION: "REQUEST_CORRECTION",
|
|
163
|
+
REJECT_CORRECTION: "REJECT_CORRECTION",
|
|
164
|
+
APPROVE_CORRECTION: "APPROVE_CORRECTION",
|
|
165
|
+
// General actions
|
|
166
|
+
READ: "READ",
|
|
167
|
+
ASSIGN: "ASSIGN",
|
|
168
|
+
UNASSIGN: "UNASSIGN",
|
|
169
|
+
// Custom action
|
|
170
|
+
CUSTOM: "CUSTOM"
|
|
171
|
+
};
|
|
172
|
+
var ConfirmableActions = [
|
|
173
|
+
ActionType.NOTIFY,
|
|
174
|
+
ActionType.DECLARE,
|
|
175
|
+
ActionType.EDIT,
|
|
176
|
+
ActionType.REGISTER,
|
|
177
|
+
ActionType.REJECT,
|
|
178
|
+
ActionType.ARCHIVE,
|
|
179
|
+
ActionType.UNARCHIVE,
|
|
180
|
+
ActionType.PRINT_CERTIFICATE,
|
|
181
|
+
ActionType.REQUEST_CORRECTION,
|
|
182
|
+
ActionType.APPROVE_CORRECTION,
|
|
183
|
+
ActionType.REJECT_CORRECTION,
|
|
184
|
+
ActionType.CUSTOM
|
|
185
|
+
];
|
|
186
|
+
var ActionTypes = z6.enum([
|
|
187
|
+
"DELETE",
|
|
188
|
+
"CREATE",
|
|
189
|
+
"NOTIFY",
|
|
190
|
+
"DECLARE",
|
|
191
|
+
"EDIT",
|
|
192
|
+
"REGISTER",
|
|
193
|
+
"DUPLICATE_DETECTED",
|
|
194
|
+
"REJECT",
|
|
195
|
+
"MARK_AS_DUPLICATE",
|
|
196
|
+
"MARK_AS_NOT_DUPLICATE",
|
|
197
|
+
"ARCHIVE",
|
|
198
|
+
"UNARCHIVE",
|
|
199
|
+
"PRINT_CERTIFICATE",
|
|
200
|
+
"REQUEST_CORRECTION",
|
|
201
|
+
"REJECT_CORRECTION",
|
|
202
|
+
"APPROVE_CORRECTION",
|
|
203
|
+
"READ",
|
|
204
|
+
"ASSIGN",
|
|
205
|
+
"UNASSIGN",
|
|
206
|
+
"CUSTOM"
|
|
207
|
+
]);
|
|
208
|
+
var declarationActionValues = [
|
|
209
|
+
ActionTypes.enum.DECLARE,
|
|
210
|
+
ActionTypes.enum.EDIT,
|
|
211
|
+
ActionTypes.enum.REGISTER,
|
|
212
|
+
ActionTypes.enum.NOTIFY,
|
|
213
|
+
ActionTypes.enum.DUPLICATE_DETECTED
|
|
214
|
+
];
|
|
215
|
+
var DeclarationActions = ActionTypes.extract(declarationActionValues);
|
|
216
|
+
var declarationUpdateActionValues = [
|
|
217
|
+
...declarationActionValues,
|
|
218
|
+
ActionTypes.enum.REQUEST_CORRECTION
|
|
219
|
+
];
|
|
220
|
+
var DeclarationUpdateActions = ActionTypes.extract(
|
|
221
|
+
declarationUpdateActionValues
|
|
222
|
+
);
|
|
223
|
+
var annotationActions = ActionTypes.exclude(declarationActionValues);
|
|
224
|
+
var writeActions = ActionTypes.exclude([
|
|
225
|
+
ActionType.CREATE,
|
|
226
|
+
ActionType.READ,
|
|
227
|
+
ActionType.ASSIGN,
|
|
228
|
+
ActionType.UNASSIGN
|
|
229
|
+
]);
|
|
230
|
+
var WorkqueueActionType = ActionTypes.extract([
|
|
231
|
+
ActionType.READ,
|
|
232
|
+
ActionType.DELETE,
|
|
233
|
+
ActionType.DECLARE,
|
|
234
|
+
ActionType.REGISTER,
|
|
235
|
+
ActionType.EDIT,
|
|
236
|
+
ActionType.REJECT,
|
|
237
|
+
ActionType.MARK_AS_DUPLICATE,
|
|
238
|
+
ActionType.ARCHIVE,
|
|
239
|
+
ActionType.UNARCHIVE,
|
|
240
|
+
ActionType.PRINT_CERTIFICATE,
|
|
241
|
+
ActionType.REQUEST_CORRECTION
|
|
242
|
+
]);
|
|
243
|
+
var META_ACTIONS = [
|
|
244
|
+
ActionType.ASSIGN,
|
|
245
|
+
ActionType.UNASSIGN,
|
|
246
|
+
ActionType.READ
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
// ../commons/src/events/ActionStatus.ts
|
|
250
|
+
var ActionStatus = {
|
|
251
|
+
Requested: "Requested",
|
|
252
|
+
Accepted: "Accepted",
|
|
253
|
+
Rejected: "Rejected"
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// ../commons/src/events/Flag.ts
|
|
257
|
+
var z9 = __toESM(require("zod/v4"));
|
|
258
|
+
|
|
259
|
+
// ../commons/src/events/TranslationConfig.ts
|
|
260
|
+
var z7 = __toESM(require("zod/v4"));
|
|
261
|
+
var TranslationConfig = z7.object({
|
|
262
|
+
id: z7.string().describe(
|
|
263
|
+
"The identifier of the translation referred in translation CSV files"
|
|
264
|
+
),
|
|
265
|
+
defaultMessage: z7.string().describe("Default translation message"),
|
|
266
|
+
description: z7.string().describe(
|
|
267
|
+
"Describe the translation for a translator to be able to identify it."
|
|
268
|
+
)
|
|
269
|
+
}).meta({
|
|
270
|
+
description: "Translation configuration",
|
|
271
|
+
id: "TranslationConfig"
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// ../commons/src/events/Conditional.ts
|
|
275
|
+
var z8 = __toESM(require("zod/v4"));
|
|
276
|
+
var Conditional = z8.any().describe("JSONSchema").meta({
|
|
277
|
+
description: "JSON schema conditional configuration",
|
|
278
|
+
id: "Conditional"
|
|
279
|
+
});
|
|
280
|
+
var ConditionalType = {
|
|
281
|
+
SHOW: "SHOW",
|
|
282
|
+
ENABLE: "ENABLE",
|
|
283
|
+
DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
|
|
284
|
+
};
|
|
285
|
+
var ShowConditional = z8.object({
|
|
286
|
+
type: z8.literal(ConditionalType.SHOW),
|
|
287
|
+
conditional: Conditional
|
|
288
|
+
}).describe(
|
|
289
|
+
"If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
|
|
290
|
+
);
|
|
291
|
+
var EnableConditional = z8.object({
|
|
292
|
+
type: z8.literal(ConditionalType.ENABLE),
|
|
293
|
+
conditional: Conditional
|
|
294
|
+
}).describe(
|
|
295
|
+
"If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
|
|
296
|
+
);
|
|
297
|
+
var ActionConditional = z8.discriminatedUnion("type", [
|
|
298
|
+
// Action can be shown / hidden
|
|
299
|
+
ShowConditional,
|
|
300
|
+
// Action can be shown to the user in the list but as disabled
|
|
301
|
+
EnableConditional
|
|
302
|
+
]).meta({
|
|
303
|
+
id: "ActionConditional",
|
|
304
|
+
description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
|
|
305
|
+
});
|
|
306
|
+
var DisplayOnReviewConditional = z8.object({
|
|
307
|
+
type: z8.literal(ConditionalType.DISPLAY_ON_REVIEW),
|
|
308
|
+
conditional: Conditional
|
|
309
|
+
}).describe(
|
|
310
|
+
"If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
|
|
311
|
+
);
|
|
312
|
+
var FieldConditional = z8.discriminatedUnion("type", [
|
|
313
|
+
// Field input can be shown / hidden
|
|
314
|
+
ShowConditional,
|
|
315
|
+
// Field input can be shown to the user but as disabled
|
|
316
|
+
EnableConditional,
|
|
317
|
+
// Field output can be shown / hidden on the review page
|
|
318
|
+
DisplayOnReviewConditional
|
|
319
|
+
]).meta({
|
|
320
|
+
id: "FieldConditional",
|
|
321
|
+
description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
// ../commons/src/events/Flag.ts
|
|
325
|
+
var InherentFlags = {
|
|
326
|
+
INCOMPLETE: "incomplete",
|
|
327
|
+
REJECTED: "rejected",
|
|
328
|
+
CORRECTION_REQUESTED: "correction-requested",
|
|
329
|
+
POTENTIAL_DUPLICATE: "potential-duplicate",
|
|
330
|
+
/**
|
|
331
|
+
* This flag is set by the Edit-action and removed after the declaration or registration.
|
|
332
|
+
* A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
|
|
333
|
+
*
|
|
334
|
+
* We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
|
|
335
|
+
*/
|
|
336
|
+
EDIT_IN_PROGRESS: "edit-in-progress"
|
|
337
|
+
};
|
|
338
|
+
var actionFlagPattern;
|
|
339
|
+
function getActionFlagPattern() {
|
|
340
|
+
actionFlagPattern ??= new RegExp(
|
|
341
|
+
`^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
|
|
342
|
+
ActionStatus
|
|
343
|
+
).join("|").toLowerCase()})$`
|
|
344
|
+
);
|
|
345
|
+
return actionFlagPattern;
|
|
346
|
+
}
|
|
347
|
+
var ActionFlag = z9.string().refine((value) => getActionFlagPattern().test(value), {
|
|
348
|
+
message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
|
|
349
|
+
});
|
|
350
|
+
var CustomFlag = z9.string().refine((val) => !Object.values(InherentFlags).includes(val), {
|
|
351
|
+
message: `Custom flag cannot be one of the inherent flags: ${Object.values(
|
|
352
|
+
InherentFlags
|
|
353
|
+
).join(", ")}`
|
|
354
|
+
}).refine((val) => !ActionFlag.safeParse(val).success, {
|
|
355
|
+
message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
|
|
356
|
+
}).describe("Custom flag identifier defined by the country config.");
|
|
357
|
+
var Flag = ActionFlag.or(z9.enum(InherentFlags)).or(CustomFlag);
|
|
358
|
+
var ContainsFlags = z9.object({
|
|
359
|
+
anyOf: z9.array(Flag).optional(),
|
|
360
|
+
noneOf: z9.array(Flag).optional(),
|
|
361
|
+
allOf: z9.array(Flag).optional()
|
|
362
|
+
}).meta({
|
|
363
|
+
id: "ContainsFlags"
|
|
364
|
+
});
|
|
365
|
+
var FlagConfig = z9.object({
|
|
366
|
+
id: CustomFlag,
|
|
367
|
+
requiresAction: z9.boolean().describe(
|
|
368
|
+
"Indicates if this flag expects an action to be performed to be cleared."
|
|
369
|
+
),
|
|
370
|
+
label: TranslationConfig.describe("Human readable label of the flag.")
|
|
371
|
+
}).meta({
|
|
372
|
+
id: "FlagConfig",
|
|
373
|
+
description: "Configuration for a custom flag that can be added to or removed from records by event actions."
|
|
374
|
+
});
|
|
375
|
+
var ActionFlagConfig = z9.object({
|
|
376
|
+
id: Flag,
|
|
377
|
+
operation: z9.enum(["add", "remove"]).describe("Operation to perform on the flag."),
|
|
378
|
+
conditional: Conditional.optional().describe(
|
|
379
|
+
"When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
|
|
380
|
+
)
|
|
381
|
+
}).meta({
|
|
382
|
+
id: "ActionFlagConfig",
|
|
383
|
+
description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
|
|
384
|
+
});
|
|
385
|
+
|
|
141
386
|
// ../commons/src/scopes.ts
|
|
142
|
-
var JurisdictionFilter =
|
|
387
|
+
var JurisdictionFilter = z10.enum(["administrativeArea", "location", "all"]).describe(
|
|
143
388
|
"Filters based on user jurisdiction relative to their office location in hierarchy."
|
|
144
389
|
);
|
|
145
|
-
var UserFilter =
|
|
146
|
-
var RecordScopeTypeV2 =
|
|
390
|
+
var UserFilter = z10.enum(["user"]).describe("Filters based on the user. Limits to self.");
|
|
391
|
+
var RecordScopeTypeV2 = z10.enum([
|
|
147
392
|
"record.search",
|
|
148
393
|
"record.create",
|
|
149
394
|
"record.read",
|
|
@@ -161,7 +406,7 @@ var RecordScopeTypeV2 = z6.enum([
|
|
|
161
406
|
"record.unassign-others",
|
|
162
407
|
"record.custom-action"
|
|
163
408
|
]);
|
|
164
|
-
var PlainScopeType =
|
|
409
|
+
var PlainScopeType = z10.enum([
|
|
165
410
|
// Misc. system scopes
|
|
166
411
|
"bypassratelimit",
|
|
167
412
|
"record.reindex",
|
|
@@ -181,15 +426,15 @@ var PlainScopeType = z6.enum([
|
|
|
181
426
|
"record.confirm-registration",
|
|
182
427
|
"record.reject-registration"
|
|
183
428
|
]);
|
|
184
|
-
var scopeByEvent =
|
|
429
|
+
var scopeByEvent = z10.preprocess(
|
|
185
430
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
186
|
-
|
|
431
|
+
z10.array(z10.string()).optional()
|
|
187
432
|
).describe("Event type, e.g. birth, death");
|
|
188
|
-
var userRole =
|
|
433
|
+
var userRole = z10.preprocess(
|
|
189
434
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
190
|
-
|
|
435
|
+
z10.array(z10.string()).optional()
|
|
191
436
|
).describe("User role, e.g. admin, field agent");
|
|
192
|
-
var scopeOptionsPlaceEvent =
|
|
437
|
+
var scopeOptionsPlaceEvent = z10.object({
|
|
193
438
|
event: scopeByEvent,
|
|
194
439
|
placeOfEvent: JurisdictionFilter.optional()
|
|
195
440
|
}).describe("Options applicable to all record scopes.");
|
|
@@ -201,36 +446,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
|
|
|
201
446
|
}).describe("Options applicable to actions that may take place after DECLARE");
|
|
202
447
|
var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
|
|
203
448
|
registeredIn: JurisdictionFilter.optional(),
|
|
204
|
-
registeredBy: UserFilter.optional()
|
|
449
|
+
registeredBy: UserFilter.optional(),
|
|
450
|
+
flags: ContainsFlags.optional()
|
|
205
451
|
}).describe(
|
|
206
452
|
"Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
|
|
207
453
|
);
|
|
208
454
|
var CustomActionScopeOptions = AllRecordScopeOptions.extend({
|
|
209
|
-
customActionTypes:
|
|
455
|
+
customActionTypes: z10.preprocess(
|
|
210
456
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
211
|
-
|
|
457
|
+
z10.array(z10.string()).optional()
|
|
212
458
|
).describe("Allowed custom action types")
|
|
213
459
|
});
|
|
214
|
-
var AccessLevelOptions =
|
|
460
|
+
var AccessLevelOptions = z10.object({
|
|
215
461
|
accessLevel: JurisdictionFilter.optional()
|
|
216
462
|
});
|
|
217
463
|
var AllUserScopeOptions = AccessLevelOptions.extend({
|
|
218
464
|
role: userRole.optional()
|
|
219
465
|
});
|
|
220
|
-
var WorkqueueOrDashboardOptions =
|
|
221
|
-
ids:
|
|
466
|
+
var WorkqueueOrDashboardOptions = z10.object({
|
|
467
|
+
ids: z10.preprocess(
|
|
222
468
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
223
|
-
|
|
469
|
+
z10.array(z10.string())
|
|
224
470
|
).describe("Must contain a list of workqueue or dashboard ids.")
|
|
225
471
|
});
|
|
226
|
-
var AllScopeOptions =
|
|
472
|
+
var AllScopeOptions = z10.object({
|
|
227
473
|
...AllRecordScopeOptions.shape,
|
|
228
474
|
...AccessLevelOptions.shape,
|
|
229
475
|
...AllUserScopeOptions.shape,
|
|
230
476
|
...WorkqueueOrDashboardOptions.shape
|
|
231
477
|
});
|
|
232
478
|
var ScopeOptionKey = AllScopeOptions.keyof();
|
|
233
|
-
var ResolvedScopeOptionsPlaceEvent =
|
|
479
|
+
var ResolvedScopeOptionsPlaceEvent = z10.object({
|
|
234
480
|
event: scopeByEvent,
|
|
235
481
|
placeOfEvent: UUID.nullish()
|
|
236
482
|
}).describe(
|
|
@@ -238,15 +484,16 @@ var ResolvedScopeOptionsPlaceEvent = z6.object({
|
|
|
238
484
|
);
|
|
239
485
|
var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
|
|
240
486
|
notifiedIn: UUID.nullish(),
|
|
241
|
-
notifiedBy:
|
|
487
|
+
notifiedBy: z10.string().optional(),
|
|
242
488
|
declaredIn: UUID.nullish(),
|
|
243
|
-
declaredBy:
|
|
489
|
+
declaredBy: z10.string().optional()
|
|
244
490
|
}).describe(
|
|
245
491
|
"Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
|
|
246
492
|
);
|
|
247
493
|
var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
|
|
248
494
|
registeredIn: UUID.nullish(),
|
|
249
|
-
registeredBy:
|
|
495
|
+
registeredBy: z10.string().optional(),
|
|
496
|
+
flags: ContainsFlags.optional()
|
|
250
497
|
}).describe(
|
|
251
498
|
"Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
|
|
252
499
|
);
|
|
@@ -271,38 +518,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
|
|
|
271
518
|
"record.unassign-others"
|
|
272
519
|
]);
|
|
273
520
|
var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
|
|
274
|
-
templates:
|
|
521
|
+
templates: z10.preprocess(
|
|
275
522
|
(val) => val === void 0 ? void 0 : [val].flat(),
|
|
276
|
-
|
|
523
|
+
z10.array(z10.string()).optional()
|
|
277
524
|
).describe(
|
|
278
525
|
"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."
|
|
279
526
|
)
|
|
280
527
|
});
|
|
281
|
-
var RecordScopeV2 =
|
|
282
|
-
|
|
528
|
+
var RecordScopeV2 = z10.discriminatedUnion("type", [
|
|
529
|
+
z10.object({
|
|
283
530
|
type: ScopesWithPlaceEventOptions,
|
|
284
531
|
options: scopeOptionsPlaceEvent.optional()
|
|
285
532
|
}),
|
|
286
|
-
|
|
533
|
+
z10.object({
|
|
287
534
|
type: ScopesWithDeclaredOptions,
|
|
288
535
|
options: scopeOptionsDeclaredOrNotified.optional()
|
|
289
536
|
}),
|
|
290
|
-
|
|
537
|
+
z10.object({
|
|
291
538
|
type: ScopesWithFullOptions,
|
|
292
539
|
options: AllRecordScopeOptions.optional()
|
|
293
540
|
}),
|
|
294
|
-
|
|
295
|
-
type:
|
|
541
|
+
z10.object({
|
|
542
|
+
type: z10.literal("record.custom-action"),
|
|
296
543
|
options: CustomActionScopeOptions.optional()
|
|
297
544
|
}),
|
|
298
|
-
|
|
299
|
-
type:
|
|
545
|
+
z10.object({
|
|
546
|
+
type: z10.literal("record.print-certified-copies"),
|
|
300
547
|
options: ScopeOptionsPrintCertifiedCopies.optional()
|
|
301
548
|
})
|
|
302
549
|
]).describe(
|
|
303
550
|
"Scopes used to check user's permission to perform actions on a record."
|
|
304
551
|
);
|
|
305
|
-
var SystemScopeType =
|
|
552
|
+
var SystemScopeType = z10.enum([
|
|
306
553
|
"organisation.read-locations",
|
|
307
554
|
"user.read",
|
|
308
555
|
"user.create",
|
|
@@ -316,61 +563,61 @@ var UserScopeType = SystemScopeType.extract([
|
|
|
316
563
|
"user.search"
|
|
317
564
|
]);
|
|
318
565
|
var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
|
|
319
|
-
var UserScopeV2 =
|
|
320
|
-
|
|
566
|
+
var UserScopeV2 = z10.discriminatedUnion("type", [
|
|
567
|
+
z10.object({
|
|
321
568
|
type: ScopesWithRoleOption,
|
|
322
569
|
options: AllUserScopeOptions.optional()
|
|
323
570
|
}),
|
|
324
|
-
|
|
571
|
+
z10.object({
|
|
325
572
|
type: UserScopeType.extract(["user.read", "user.search"]),
|
|
326
573
|
options: AccessLevelOptions.optional()
|
|
327
574
|
})
|
|
328
575
|
]);
|
|
329
|
-
var ResolvedRecordScopeV2 =
|
|
330
|
-
|
|
576
|
+
var ResolvedRecordScopeV2 = z10.discriminatedUnion("type", [
|
|
577
|
+
z10.object({
|
|
331
578
|
type: ScopesWithPlaceEventOptions,
|
|
332
579
|
options: ResolvedScopeOptionsPlaceEvent.optional()
|
|
333
580
|
}),
|
|
334
|
-
|
|
581
|
+
z10.object({
|
|
335
582
|
type: ScopesWithDeclaredOptions,
|
|
336
583
|
options: ResolvedScopeOptionsDeclared.optional()
|
|
337
584
|
}),
|
|
338
|
-
|
|
585
|
+
z10.object({
|
|
339
586
|
type: ScopesWithFullOptions,
|
|
340
587
|
options: ResolvedScopeOptionsFull.optional()
|
|
341
588
|
}),
|
|
342
|
-
|
|
343
|
-
type:
|
|
589
|
+
z10.object({
|
|
590
|
+
type: z10.literal("record.print-certified-copies"),
|
|
344
591
|
options: ResolvedScopeOptionsFull.extend({
|
|
345
|
-
templates:
|
|
592
|
+
templates: z10.array(z10.string()).optional()
|
|
346
593
|
}).optional()
|
|
347
594
|
})
|
|
348
595
|
]).describe("Resolved scope with location/user IDs instead of filters.");
|
|
349
|
-
var Scope2 =
|
|
350
|
-
|
|
596
|
+
var Scope2 = z10.discriminatedUnion("type", [
|
|
597
|
+
z10.object({ type: PlainScopeType }),
|
|
351
598
|
...RecordScopeV2.options,
|
|
352
599
|
...UserScopeV2.options,
|
|
353
|
-
|
|
354
|
-
type:
|
|
600
|
+
z10.object({
|
|
601
|
+
type: z10.literal("organisation.read-locations"),
|
|
355
602
|
options: AccessLevelOptions.optional()
|
|
356
603
|
}),
|
|
357
|
-
|
|
358
|
-
type:
|
|
604
|
+
z10.object({
|
|
605
|
+
type: z10.literal("workqueue"),
|
|
359
606
|
options: WorkqueueOrDashboardOptions
|
|
360
607
|
}),
|
|
361
|
-
|
|
362
|
-
type:
|
|
608
|
+
z10.object({
|
|
609
|
+
type: z10.literal("dashboard.view"),
|
|
363
610
|
options: WorkqueueOrDashboardOptions
|
|
364
611
|
})
|
|
365
612
|
]);
|
|
366
|
-
var ScopeType2 =
|
|
613
|
+
var ScopeType2 = z10.enum([
|
|
367
614
|
...SystemScopeType.options,
|
|
368
615
|
...RecordScopeTypeV2.options,
|
|
369
616
|
...PlainScopeType.options,
|
|
370
617
|
"workqueue",
|
|
371
618
|
"dashboard.view"
|
|
372
619
|
]);
|
|
373
|
-
var EncodedScope2 =
|
|
620
|
+
var EncodedScope2 = z10.string().brand("EncodedScope");
|
|
374
621
|
var DEFAULT_SCOPE_OPTIONS = {
|
|
375
622
|
placeOfEvent: JurisdictionFilter.enum.all,
|
|
376
623
|
accessLevel: JurisdictionFilter.enum.all,
|
|
@@ -1065,4 +1312,4 @@ function createFieldConditionals(fieldId) {
|
|
|
1065
1312
|
}
|
|
1066
1313
|
|
|
1067
1314
|
// src/conditionals/index.ts
|
|
1068
|
-
|
|
1315
|
+
z12.globalRegistry.clear();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare function runEnvironmentInit(): Promise<void>;
|
|
2
|
+
export declare function runEnvironmentUpgrade(): Promise<void>;
|
|
2
3
|
export declare function runEnvironmentUpdateWorkflows(): Promise<void>;
|
|
3
4
|
export declare function runEnvironmentUsers(): Promise<void>;
|
|
4
5
|
export declare function runEnvironmentSwarmToK8s(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/environment/index.ts"],"names":[],"mappings":"AAyCA,wBAAsB,kBAAkB,kBAIvC;AAED,wBAAsB,qBAAqB,kBAI1C;AAED,wBAAsB,6BAA6B,kBAIlD;AAED,wBAAsB,mBAAmB,kBAIxC;AAED,wBAAsB,wBAAwB,kBAG7C"}
|
|
@@ -20,11 +20,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.runEnvironmentInit = runEnvironmentInit;
|
|
23
|
+
exports.runEnvironmentUpgrade = runEnvironmentUpgrade;
|
|
23
24
|
exports.runEnvironmentUpdateWorkflows = runEnvironmentUpdateWorkflows;
|
|
24
25
|
exports.runEnvironmentUsers = runEnvironmentUsers;
|
|
25
26
|
exports.runEnvironmentSwarmToK8s = runEnvironmentSwarmToK8s;
|
|
26
27
|
const fs_1 = require("fs");
|
|
27
28
|
const path_1 = require("path");
|
|
29
|
+
const paths_1 = require("./paths");
|
|
28
30
|
const REQUIRED_REPOSITORY_DIRECTORIES = [
|
|
29
31
|
'.github/workflows',
|
|
30
32
|
'environments',
|
|
@@ -46,9 +48,17 @@ function validateRepositoryStructure(repositoryRoot = process.cwd()) {
|
|
|
46
48
|
function runEnvironmentInit() {
|
|
47
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
50
|
validateRepositoryStructure();
|
|
51
|
+
(0, paths_1.assertNoOldInventoryLayout)();
|
|
49
52
|
yield import('./setup-environment.js');
|
|
50
53
|
});
|
|
51
54
|
}
|
|
55
|
+
function runEnvironmentUpgrade() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
validateRepositoryStructure();
|
|
58
|
+
const { upgradeEnvironmentLayout } = yield import('./upgrade.js');
|
|
59
|
+
yield upgradeEnvironmentLayout();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
52
62
|
function runEnvironmentUpdateWorkflows() {
|
|
53
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
64
|
validateRepositoryStructure();
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
export declare const log:
|
|
2
|
-
|
|
1
|
+
export declare const log: {
|
|
2
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
3
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
4
|
+
};
|
|
5
|
+
export declare const warn: {
|
|
6
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
7
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
8
|
+
};
|
|
3
9
|
export declare const success: (...args: any[]) => void;
|
|
4
|
-
export declare const info:
|
|
10
|
+
export declare const info: {
|
|
11
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
12
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
13
|
+
};
|
|
5
14
|
export declare const error: (...args: any[]) => void;
|
|
6
15
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/environment/logger.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,GAAG;;;CAAc,CAAA;AAC9B,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,OAAO,YAAa,GAAG,EAAE,SACI,CAAA;AAC1C,eAAO,MAAM,IAAI;;;CAAe,CAAA;AAChC,eAAO,MAAM,KAAK,YAAa,GAAG,EAAE,SAA2C,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const OLD_INVENTORY_DIR: string;
|
|
2
|
+
export declare const INVENTORY_FILE_NAME = "inventory.yml";
|
|
3
|
+
export declare function getEnvironmentInventoryPath(environment: string): string;
|
|
4
|
+
export declare function findOldInventoryFiles(): string[];
|
|
5
|
+
export declare function getEnvironmentNameFromOldInventoryPath(filePath: string): string;
|
|
6
|
+
export declare function assertNoOldInventoryLayout(): void;
|
|
7
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/environment/paths.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,iBAAiB,QAI7B,CAAA;AAED,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,UAE9D;AAED,wBAAgB,qBAAqB,aAEpC;AAED,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,UAEtE;AAED,wBAAgB,0BAA0B,SAWzC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
6
|
+
*
|
|
7
|
+
* OpenCRVS is also distributed under the terms of the Civil Registration
|
|
8
|
+
* & Healthcare Disclaimer located at http://opencrvs.org/license.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.INVENTORY_FILE_NAME = exports.OLD_INVENTORY_DIR = void 0;
|
|
47
|
+
exports.getEnvironmentInventoryPath = getEnvironmentInventoryPath;
|
|
48
|
+
exports.findOldInventoryFiles = findOldInventoryFiles;
|
|
49
|
+
exports.getEnvironmentNameFromOldInventoryPath = getEnvironmentNameFromOldInventoryPath;
|
|
50
|
+
exports.assertNoOldInventoryLayout = assertNoOldInventoryLayout;
|
|
51
|
+
const path_1 = require("path");
|
|
52
|
+
const glob = __importStar(require("glob"));
|
|
53
|
+
exports.OLD_INVENTORY_DIR = (0, path_1.join)('infrastructure', 'server-setup', 'inventory');
|
|
54
|
+
exports.INVENTORY_FILE_NAME = 'inventory.yml';
|
|
55
|
+
function getEnvironmentInventoryPath(environment) {
|
|
56
|
+
return (0, path_1.join)('environments', environment, exports.INVENTORY_FILE_NAME);
|
|
57
|
+
}
|
|
58
|
+
function findOldInventoryFiles() {
|
|
59
|
+
return glob.sync((0, path_1.join)(exports.OLD_INVENTORY_DIR, '*.yml')).sort();
|
|
60
|
+
}
|
|
61
|
+
function getEnvironmentNameFromOldInventoryPath(filePath) {
|
|
62
|
+
return (0, path_1.basename)(filePath, '.yml');
|
|
63
|
+
}
|
|
64
|
+
function assertNoOldInventoryLayout() {
|
|
65
|
+
if (findOldInventoryFiles().length === 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
throw new Error([
|
|
69
|
+
`Old inventory layout detected at ${exports.OLD_INVENTORY_DIR}.`,
|
|
70
|
+
'Please run `yarn environment:upgrade` before running `yarn environment:init`.'
|
|
71
|
+
].join(' '));
|
|
72
|
+
}
|