@opencrvs/toolkit 2.0.0-rc.c29d352 → 2.0.0-rc.c3d327f

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.
@@ -306,7 +306,6 @@ __export(events_exports, {
306
306
  getAllUniqueFields: () => getAllUniqueFields,
307
307
  getAnnotationFromDrafts: () => getAnnotationFromDrafts,
308
308
  getAssignedUserFromActions: () => getAssignedUserFromActions,
309
- getAssignedUserSignatureFromActions: () => getAssignedUserSignatureFromActions,
310
309
  getAssignmentStatus: () => getAssignmentStatus,
311
310
  getAvailableActionsForEvent: () => getAvailableActionsForEvent,
312
311
  getAvailableRolesForUserUpdatePayload: () => getAvailableRolesForUserUpdatePayload,
@@ -1765,8 +1764,7 @@ var ActionCreationMetadata = z16.object({
1765
1764
  ),
1766
1765
  createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1767
1766
  acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1768
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation."),
1769
- createdBySignature: z16.string().nullish().describe("Signature of the user who created the action request.")
1767
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1770
1768
  });
1771
1769
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1772
1770
  registrationNumber: z16.string().describe(
@@ -1794,9 +1792,6 @@ var EventMetadata = z16.object({
1794
1792
  createdAtLocation: UUID.nullish().describe(
1795
1793
  "Location of the user who created the event."
1796
1794
  ),
1797
- createdBySignature: DocumentPath.nullish().describe(
1798
- "Signature of the user who created the event."
1799
- ),
1800
1795
  updatedAtLocation: UUID.nullish().describe(
1801
1796
  "Location of the user who last changed the status."
1802
1797
  ),
@@ -3796,6 +3791,9 @@ function precompileActionSchemas(eventConfigurations) {
3796
3791
  function isAgeValue(value) {
3797
3792
  return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
3798
3793
  }
3794
+ function mergeWithBaseFormState(values, context) {
3795
+ return { ...context.baseFormState, ...values };
3796
+ }
3799
3797
  function validate(schema, data) {
3800
3798
  const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
3801
3799
  if ("$form" in data) {
@@ -3834,7 +3832,7 @@ function isOnline() {
3834
3832
  }
3835
3833
  function isConditionMet(conditional, values, context, eventIndex) {
3836
3834
  return validate(conditional, {
3837
- $form: values,
3835
+ $form: mergeWithBaseFormState(values, context),
3838
3836
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3839
3837
  $online: isOnline(),
3840
3838
  $user: context.user,
@@ -3863,7 +3861,7 @@ function isFieldConditionMet(field3, form, conditionalType, context) {
3863
3861
  return true;
3864
3862
  }
3865
3863
  const validConditionals = getConditionalActionsForField(field3, {
3866
- $form: form,
3864
+ $form: mergeWithBaseFormState(form, context),
3867
3865
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
3868
3866
  $online: isOnline(),
3869
3867
  $user: context.user,
@@ -4055,7 +4053,7 @@ function runFieldValidations({
4055
4053
  return [];
4056
4054
  }
4057
4055
  const conditionalParameters = {
4058
- $form: form,
4056
+ $form: mergeWithBaseFormState(form, context),
4059
4057
  $now: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" }),
4060
4058
  /**
4061
4059
  * In real use cases, there can be hundreds of thousands of locations.
@@ -4299,17 +4297,16 @@ function isPageVisible(page, formValues, context) {
4299
4297
  }
4300
4298
  return isConditionMet(page.conditional, formValues, context);
4301
4299
  }
4302
- function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false, declarationContext) {
4300
+ function omitHiddenFields(fields, formValues, validatorContext, includeHiddenFieldsWithNullValues = false) {
4303
4301
  const base = (0, import_lodash.cloneDeep)(formValues);
4304
4302
  function fn(prevVisibilityContext) {
4305
- const visibilityForm = declarationContext ? { ...declarationContext, ...prevVisibilityContext } : prevVisibilityContext;
4306
4303
  const cleaned = (0, import_lodash.omitBy)(base, (value, fieldId) => {
4307
4304
  const fieldConfig = fields.filter((f) => f.id === fieldId);
4308
4305
  if (!fieldConfig.length) {
4309
4306
  return false;
4310
4307
  }
4311
4308
  const isHidden = fieldConfig.every(
4312
- (f) => !isFieldVisible(f, visibilityForm, validatorContext)
4309
+ (f) => !isFieldVisible(f, prevVisibilityContext, validatorContext)
4313
4310
  );
4314
4311
  if (!isHidden) {
4315
4312
  return false;
@@ -4327,7 +4324,7 @@ function omitHiddenPaginatedFields(formConfig, values, validatorContext, include
4327
4324
  const visibleFields = formConfig.pages.filter((p) => isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
4328
4325
  const hiddenFields = formConfig.pages.filter((p) => !isPageVisible(p, values, validatorContext)).flatMap((p) => p.fields);
4329
4326
  const valuesExceptHiddenPage = (0, import_lodash.omitBy)(values, (_2, fieldId) => {
4330
- return hiddenFields.some((f) => f.id === fieldId);
4327
+ return hiddenFields.some((f) => f.id === fieldId) && !visibleFields.some((f) => f.id === fieldId);
4331
4328
  });
4332
4329
  return omitHiddenFields(
4333
4330
  visibleFields,
@@ -4374,13 +4371,10 @@ function getVisibleVerificationPageIds(pages, annotation, context) {
4374
4371
  }
4375
4372
  function omitHiddenAnnotationFields(actionConfig, declaration, annotation, context) {
4376
4373
  const annotationFields = getActionAnnotationFields(actionConfig);
4377
- return omitHiddenFields(
4378
- annotationFields,
4379
- annotation,
4380
- context,
4381
- false,
4382
- declaration
4383
- );
4374
+ return omitHiddenFields(annotationFields, annotation, {
4375
+ ...context,
4376
+ baseFormState: declaration
4377
+ });
4384
4378
  }
4385
4379
  function deepMerge(currentDocument, actionDocument) {
4386
4380
  const currentDocumentClone = (0, import_lodash.cloneDeep)(currentDocument);
@@ -5892,6 +5886,8 @@ var BaseActionInput = z38.object({
5892
5886
  originalActionId: UUID.optional(),
5893
5887
  // should not be part of base action.
5894
5888
  keepAssignment: z38.boolean().optional(),
5889
+ keepAssignmentIfAccepted: z38.boolean().optional(),
5890
+ keepAssignmentIfRejected: z38.boolean().optional(),
5895
5891
  waitFor: z38.boolean().optional(),
5896
5892
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
5897
5893
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
@@ -6146,7 +6142,6 @@ function getDeclarationActionCreationMetadata(actionType, actions) {
6146
6142
  createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
6147
6143
  acceptedAt: acceptAction.createdAt,
6148
6144
  createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
6149
- createdBySignature: requestAction?.createdBySignature ?? acceptAction.createdBySignature,
6150
6145
  registrationNumber
6151
6146
  };
6152
6147
  }
@@ -6360,17 +6355,6 @@ function getAssignedUserFromActions(actions) {
6360
6355
  return user2;
6361
6356
  }, null);
6362
6357
  }
6363
- function getAssignedUserSignatureFromActions(actions) {
6364
- return actions.reduce((signature, action) => {
6365
- if (action.type === ActionType.ASSIGN) {
6366
- return action.createdBySignature || null;
6367
- }
6368
- if (action.type === ActionType.UNASSIGN) {
6369
- return null;
6370
- }
6371
- return signature;
6372
- }, null);
6373
- }
6374
6358
  function deepDropNulls(obj) {
6375
6359
  if (Array.isArray(obj)) {
6376
6360
  return obj.map(deepDropNulls);
@@ -6466,10 +6450,8 @@ function getCurrentEventState(event2, config) {
6466
6450
  createdBy: creationAction.createdBy,
6467
6451
  createdByUserType: creationAction.createdByUserType,
6468
6452
  createdAtLocation: creationAction.createdAtLocation,
6469
- createdBySignature: creationAction.createdBySignature,
6470
6453
  updatedAt: acceptedActionMetadata.createdAt,
6471
6454
  assignedTo: getAssignedUserFromActions(acceptedActions),
6472
- assignedToSignature: getAssignedUserSignatureFromActions(acceptedActions),
6473
6455
  updatedBy: requestActionMetadata.createdBy,
6474
6456
  updatedAtLocation: requestActionMetadata.createdAtLocation,
6475
6457
  declaration,
@@ -9728,7 +9710,6 @@ var eventQueryDataGenerator = (overrides = {}, seed = 1) => {
9728
9710
  createdBy: overrides.createdBy ?? generateUuid(rng),
9729
9711
  createdAtLocation: overrides.createdAtLocation ?? generateUuid(rng),
9730
9712
  updatedAtLocation: overrides.updatedAtLocation ?? generateUuid(rng),
9731
- createdBySignature: overrides.createdBySignature ?? generateRandomSignature(rng),
9732
9713
  updatedAt: overrides.updatedAt ?? (0, import_date_fns4.addDays)(new Date(createdAt), 1).toISOString(),
9733
9714
  assignedTo: overrides.assignedTo ?? null,
9734
9715
  updatedBy: overrides.updatedBy ?? generateUuid(rng),
@@ -1331,8 +1331,7 @@ var ActionCreationMetadata = z16.object({
1331
1331
  ),
1332
1332
  createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1333
1333
  acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1334
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation."),
1335
- createdBySignature: z16.string().nullish().describe("Signature of the user who created the action request.")
1334
+ createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1336
1335
  });
1337
1336
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1338
1337
  registrationNumber: z16.string().describe(
@@ -1360,9 +1359,6 @@ var EventMetadata = z16.object({
1360
1359
  createdAtLocation: UUID.nullish().describe(
1361
1360
  "Location of the user who created the event."
1362
1361
  ),
1363
- createdBySignature: DocumentPath.nullish().describe(
1364
- "Signature of the user who created the event."
1365
- ),
1366
1362
  updatedAtLocation: UUID.nullish().describe(
1367
1363
  "Location of the user who last changed the status."
1368
1364
  ),
@@ -4172,6 +4168,8 @@ var BaseActionInput = z38.object({
4172
4168
  originalActionId: UUID.optional(),
4173
4169
  // should not be part of base action.
4174
4170
  keepAssignment: z38.boolean().optional(),
4171
+ keepAssignmentIfAccepted: z38.boolean().optional(),
4172
+ keepAssignmentIfRejected: z38.boolean().optional(),
4175
4173
  waitFor: z38.boolean().optional(),
4176
4174
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4177
4175
  // @TODO: createdAtLocation should be limited to actions that system users can perform. For normal users, it should not be part of the base action.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.c29d352",
3
+ "version": "2.0.0-rc.c3d327f",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {