@opencrvs/toolkit
Advanced tools
Comparing version
@@ -101,4 +101,6 @@ import { EventDocument } from '../events/EventDocument'; | ||
inArray: (values: string[]) => JSONSchema; | ||
isValidEnglishName: () => JSONSchema; | ||
isBetween: (min: number, max: number) => JSONSchema; | ||
}; | ||
export {}; | ||
//# sourceMappingURL=conditionals.d.ts.map |
@@ -9,2 +9,29 @@ import { ConditionalParameters, JSONSchema } from './conditionals'; | ||
export declare function isFieldEnabled(field: FieldConfig, form: ActionUpdate | EventState): boolean; | ||
export declare const errorMessages: { | ||
hiddenField: { | ||
id: string; | ||
defaultMessage: string; | ||
description: string; | ||
}; | ||
invalidDate: { | ||
defaultMessage: string; | ||
description: string; | ||
id: string; | ||
}; | ||
invalidEmail: { | ||
defaultMessage: string; | ||
description: string; | ||
id: string; | ||
}; | ||
requiredField: { | ||
defaultMessage: string; | ||
description: string; | ||
id: string; | ||
}; | ||
invalidInput: { | ||
defaultMessage: string; | ||
description: string; | ||
id: string; | ||
}; | ||
}; | ||
/** | ||
@@ -11,0 +38,0 @@ * Custom error map for Zod to override the default error messages in intl-formik format. |
@@ -66,3 +66,2 @@ import { EventConfigInput } from './EventConfigInput'; | ||
type: "REJECT"; | ||
comment: string; | ||
conditionals: ({ | ||
@@ -93,7 +92,5 @@ type: "SHOW"; | ||
}[]; | ||
isDuplicate: boolean; | ||
draft?: boolean | undefined; | ||
} | { | ||
type: "MARKED_AS_DUPLICATE"; | ||
comment: string; | ||
conditionals: ({ | ||
@@ -124,7 +121,5 @@ type: "SHOW"; | ||
}[]; | ||
duplicates: string[]; | ||
draft?: boolean | undefined; | ||
} | { | ||
type: "ARCHIVE"; | ||
comment: string; | ||
conditionals: ({ | ||
@@ -155,3 +150,2 @@ type: "SHOW"; | ||
}[]; | ||
isDuplicate: boolean; | ||
draft?: boolean | undefined; | ||
@@ -158,0 +152,0 @@ } | { |
@@ -261,2 +261,32 @@ import { z } from 'zod'; | ||
} | null; | ||
/** | ||
* Maps complex or nested field types, such as Address fields, to their corresponding empty values. | ||
*/ | ||
export declare function mapFieldTypeToEmptyValue(field: FieldConfig): never[] | { | ||
country: null; | ||
province: null; | ||
district: null; | ||
urbanOrRural: string; | ||
town: null; | ||
residentialArea: null; | ||
street: null; | ||
number: null; | ||
zipCode: null; | ||
filename?: undefined; | ||
originalFilename?: undefined; | ||
type?: undefined; | ||
} | { | ||
filename: string; | ||
originalFilename: string; | ||
type: string; | ||
country?: undefined; | ||
province?: undefined; | ||
district?: undefined; | ||
urbanOrRural?: undefined; | ||
town?: undefined; | ||
residentialArea?: undefined; | ||
street?: undefined; | ||
number?: undefined; | ||
zipCode?: undefined; | ||
} | null; | ||
export declare const isParagraphFieldType: (field: { | ||
@@ -263,0 +293,0 @@ config: FieldConfig; |
@@ -10,2 +10,4 @@ import { TranslationConfig } from './TranslationConfig'; | ||
import { FormConfig } from './FormConfig'; | ||
import { Draft } from './Draft'; | ||
import { EventDocument } from './EventDocument'; | ||
/** | ||
@@ -115,2 +117,80 @@ * @returns All the fields in the event configuration input. | ||
}[]>; | ||
export declare function findActiveDrafts(event: EventDocument, drafts: Draft[]): { | ||
id: string; | ||
createdAt: string; | ||
eventId: string; | ||
transactionId: string; | ||
action: { | ||
type: ActionType; | ||
data: Record<string, string | number | boolean | { | ||
type: string; | ||
filename: string; | ||
originalFilename: string; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "URBAN"; | ||
number?: string | null | undefined; | ||
town?: string | null | undefined; | ||
residentialArea?: string | null | undefined; | ||
street?: string | null | undefined; | ||
zipCode?: string | null | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | null | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[]>; | ||
createdAt: string; | ||
createdBy: string; | ||
createdAtLocation: string; | ||
metadata?: Record<string, string | number | boolean | { | ||
type: string; | ||
filename: string; | ||
originalFilename: string; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "URBAN"; | ||
number?: string | null | undefined; | ||
town?: string | null | undefined; | ||
residentialArea?: string | null | undefined; | ||
street?: string | null | undefined; | ||
zipCode?: string | null | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | null | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[]> | undefined; | ||
}; | ||
}[]; | ||
export declare function createEmptyDraft(eventId: string, draftId: string, actionType: ActionType): { | ||
id: string; | ||
eventId: string; | ||
createdAt: string; | ||
transactionId: import("../uuid").UUID; | ||
action: { | ||
type: ActionType; | ||
data: {}; | ||
metadata: {}; | ||
createdAt: string; | ||
createdBy: string; | ||
createdAtLocation: string; | ||
}; | ||
}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -242,4 +242,38 @@ "use strict"; | ||
required: ["$form"] | ||
}), | ||
isValidEnglishName: () => defineConditional({ | ||
type: "object", | ||
properties: { | ||
$form: { | ||
type: "object", | ||
properties: { | ||
[fieldId]: { | ||
type: "string", | ||
pattern: "^[\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*( [\\p{Script=Latin}0-9'._-]*(\\([\\p{Script=Latin}0-9'._-]+\\))?[\\p{Script=Latin}0-9'._-]*)*$", | ||
description: "Name must contain only letters, numbers, and allowed special characters ('._-). No double spaces." | ||
} | ||
}, | ||
required: [fieldId] | ||
} | ||
}, | ||
required: ["$form"] | ||
}), | ||
isBetween: (min, max) => defineConditional({ | ||
type: "object", | ||
properties: { | ||
$form: { | ||
type: "object", | ||
properties: { | ||
[fieldId]: { | ||
type: "number", | ||
minimum: min, | ||
maximum: max | ||
} | ||
}, | ||
required: [fieldId] | ||
} | ||
}, | ||
required: ["$form"] | ||
}) | ||
}; | ||
} |
{ | ||
"name": "@opencrvs/toolkit", | ||
"version": "1.8.0-rc.3a71f21", | ||
"version": "1.8.0-rc.3c87893", | ||
"description": "OpenCRVS toolkit for building country configurations", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1785422
0.43%56
1.82%47608
0.53%