@opencrvs/toolkit
Advanced tools
Comparing version
@@ -102,2 +102,8 @@ import { EventDocument } from '../events/EventDocument'; | ||
isValidEnglishName: () => JSONSchema; | ||
/** | ||
* Checks if the field value matches a given regular expression pattern. | ||
* @param pattern - The regular expression pattern to match the field value against. | ||
* @returns A JSONSchema conditional that validates the field value against the pattern. | ||
*/ | ||
matches: (pattern: string) => JSONSchema; | ||
isBetween: (min: number, max: number) => JSONSchema; | ||
@@ -104,0 +110,0 @@ }; |
@@ -22,2 +22,3 @@ /** | ||
readonly ARCHIVE: "ARCHIVE"; | ||
readonly READ: "READ"; | ||
}; | ||
@@ -28,4 +29,4 @@ /** | ||
*/ | ||
export declare const LatentActions: ("REJECT" | "ARCHIVE")[]; | ||
export declare const LatentActions: ("NOTIFY" | "REJECT" | "ARCHIVE")[]; | ||
export type ActionType = (typeof ActionType)[keyof typeof ActionType]; | ||
//# sourceMappingURL=ActionType.d.ts.map |
@@ -30,2 +30,3 @@ import { EventConfigInput } from './EventConfigInput'; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -48,2 +49,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -78,2 +80,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -96,2 +99,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -126,2 +130,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -144,2 +149,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -174,2 +180,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -192,2 +199,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -222,2 +230,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -240,2 +249,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -270,2 +280,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -288,2 +299,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -318,2 +330,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -336,2 +349,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -366,2 +380,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -384,2 +399,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -414,2 +430,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -432,2 +449,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -444,2 +462,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -462,2 +481,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -469,2 +489,3 @@ additionalDetailsForm: ({ | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -487,2 +508,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -512,2 +534,3 @@ draft?: boolean | undefined; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -530,2 +553,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -560,2 +584,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -578,2 +603,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -608,2 +634,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -626,2 +653,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -628,0 +656,0 @@ review: { |
@@ -241,5 +241,7 @@ import { z } from 'zod'; | ||
createdAtLocation: z.ZodString; | ||
status: z.ZodEnum<[import("./ActionDocument").ActionStatus.Requested, import("./ActionDocument").ActionStatus.Accepted, import("./ActionDocument").ActionStatus.Rejected]>; | ||
updatedAt: z.ZodOptional<z.ZodString>; | ||
}, { | ||
type: z.ZodEnum<[ActionType, ...ActionType[]]>; | ||
}>, "id">, "strip", z.ZodTypeAny, { | ||
}>, "id" | "status">, "strip", z.ZodTypeAny, { | ||
type: ActionType; | ||
@@ -325,2 +327,3 @@ data: Record<string, string | number | boolean | { | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}, { | ||
@@ -407,2 +410,3 @@ type: ActionType; | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}>; | ||
@@ -495,2 +499,3 @@ }, "strip", z.ZodTypeAny, { | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
@@ -583,2 +588,3 @@ }, { | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
@@ -585,0 +591,0 @@ }>; |
@@ -9,2 +9,3 @@ import { z } from 'zod'; | ||
id: z.ZodString; | ||
type: z.ZodDefault<z.ZodLiteral<"FORM">>; | ||
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, { | ||
@@ -16,3 +17,3 @@ id: string; | ||
fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">; | ||
type: z.ZodDefault<z.ZodLiteral<"FORM">>; | ||
conditional: z.ZodOptional<z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>>; | ||
}, "strip", z.ZodTypeAny, { | ||
@@ -23,2 +24,3 @@ type: "FORM"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
}, { | ||
@@ -33,2 +35,3 @@ id: string; | ||
type?: "FORM" | undefined; | ||
conditional?: import(".").JSONSchema | undefined; | ||
}>; | ||
@@ -149,2 +152,3 @@ export declare const VerificationPageConfig: z.ZodObject<{ | ||
id: z.ZodString; | ||
type: z.ZodDefault<z.ZodLiteral<"FORM">>; | ||
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, { | ||
@@ -156,3 +160,3 @@ id: string; | ||
fields: z.ZodArray<z.ZodType<import("./FieldConfig").Inferred, any, import("./FieldConfig").InferredInput>, "many">; | ||
type: z.ZodDefault<z.ZodLiteral<"FORM">>; | ||
conditional: z.ZodOptional<z.ZodType<import(".").JSONSchema, z.ZodTypeDef, import(".").JSONSchema>>; | ||
}, { | ||
@@ -289,2 +293,3 @@ type: z.ZodLiteral<"VERIFICATION">; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
}, { | ||
@@ -327,2 +332,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").InferredInput[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
}>; | ||
@@ -390,2 +396,3 @@ export type VerificationPageConfig = z.infer<typeof VerificationPageConfig>; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -408,2 +415,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -437,2 +445,3 @@ review: { | ||
type?: "FORM" | undefined; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -475,2 +484,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").InferredInput[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -477,0 +487,0 @@ review: { |
@@ -34,2 +34,3 @@ export * from './ActionConfig'; | ||
export * from '../conditionals/validate'; | ||
export * from './api'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { ActionDocument } from './ActionDocument'; | ||
import { ActionDocument, ActionUpdate } from './ActionDocument'; | ||
import { ArchiveActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput'; | ||
@@ -167,2 +167,3 @@ import { ActionType } from './ActionType'; | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
@@ -214,2 +215,51 @@ }>; | ||
}; | ||
/** | ||
* Notify allows sending incomplete data. Think it as 'partial declare' for now. | ||
*/ | ||
notify: (eventId: string, input?: { | ||
transactionId?: string; | ||
data?: Partial<ActionUpdate>; | ||
}) => { | ||
type: "NOTIFY"; | ||
transactionId: string; | ||
data: Partial<Record<string, string | number | boolean | { | ||
type: string; | ||
filename: string; | ||
originalFilename: string; | ||
} | { | ||
country: string; | ||
district: string; | ||
addressType: "DOMESTIC"; | ||
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; | ||
addressType: "DOMESTIC"; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | null | undefined; | ||
} | { | ||
country: string; | ||
state: string; | ||
addressType: "INTERNATIONAL"; | ||
district2: string; | ||
cityOrTown?: string | null | undefined; | ||
addressLine1?: string | null | undefined; | ||
addressLine2?: string | null | undefined; | ||
addressLine3?: string | null | undefined; | ||
postcodeOrZip?: string | null | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[] | undefined>>; | ||
eventId: string; | ||
}; | ||
validate: (eventId: string, input?: Partial<Pick<ValidateActionInput, "transactionId" | "data">>) => { | ||
@@ -216,0 +266,0 @@ type: "VALIDATE"; |
@@ -8,4 +8,4 @@ import { TranslationConfig } from './TranslationConfig'; | ||
import { WorkqueueConfig } from './WorkqueueConfig'; | ||
import { EventState } from './ActionDocument'; | ||
import { FormConfig } from './FormConfig'; | ||
import { ActionUpdate, EventState } from './ActionDocument'; | ||
import { FormConfig, FormPageConfig } from './FormConfig'; | ||
import { Draft } from './Draft'; | ||
@@ -49,2 +49,3 @@ import { EventDocument } from './EventDocument'; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -67,2 +68,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -82,2 +84,3 @@ export declare function validateWorkqueueConfig(workqueueConfigs: WorkqueueConfig[]): void; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -100,2 +103,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -112,2 +116,3 @@ review: { | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -130,4 +135,7 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[] | undefined; | ||
export declare const getFormFields: (formConfig: FormConfig) => import("./FieldConfig").Inferred[]; | ||
export declare function isPageVisible(page: FormPageConfig, formValues: ActionUpdate): boolean; | ||
export declare const getVisiblePagesFormFields: (formConfig: FormConfig, formData: ActionUpdate) => import("./FieldConfig").Inferred[]; | ||
/** | ||
@@ -140,3 +148,3 @@ * Returns only form fields for the action type, if any, excluding review fields. | ||
*/ | ||
export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined; | ||
export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType, formData?: ActionUpdate) => FieldConfig[] | undefined; | ||
export declare const getActiveActionFormPages: (configuration: EventConfig, action: ActionType) => ({ | ||
@@ -147,2 +155,3 @@ type: "FORM"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
} | { | ||
@@ -165,2 +174,3 @@ type: "VERIFICATION"; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
})[]; | ||
@@ -296,2 +306,3 @@ /** | ||
}[] | undefined> | undefined; | ||
updatedAt?: string | undefined; | ||
}; | ||
@@ -313,3 +324,21 @@ }[]; | ||
}; | ||
export declare function findActiveActionVerificationPageIds(configuration: EventConfig, action: ActionType): string[]; | ||
export declare function isVerificationPage(page: FormPageConfig): page is { | ||
type: "VERIFICATION"; | ||
id: string; | ||
title: TranslationConfig; | ||
actions: { | ||
verify: { | ||
label: TranslationConfig; | ||
}; | ||
cancel: { | ||
label: TranslationConfig; | ||
confirmation: { | ||
title: TranslationConfig; | ||
body: TranslationConfig; | ||
}; | ||
}; | ||
}; | ||
fields: import("./FieldConfig").Inferred[]; | ||
conditional?: import(".").JSONSchema | undefined; | ||
}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -260,2 +260,23 @@ "use strict"; | ||
}), | ||
/** | ||
* Checks if the field value matches a given regular expression pattern. | ||
* @param pattern - The regular expression pattern to match the field value against. | ||
* @returns A JSONSchema conditional that validates the field value against the pattern. | ||
*/ | ||
matches: (pattern) => defineConditional({ | ||
type: "object", | ||
properties: { | ||
$form: { | ||
type: "object", | ||
properties: { | ||
[fieldId]: { | ||
type: "string", | ||
pattern | ||
} | ||
}, | ||
required: [fieldId] | ||
} | ||
}, | ||
required: ["$form"] | ||
}), | ||
isBetween: (min, max) => defineConditional({ | ||
@@ -262,0 +283,0 @@ type: "object", |
{ | ||
"name": "@opencrvs/toolkit", | ||
"version": "1.8.0-rc.3593db2", | ||
"version": "1.8.0-rc.364b85e", | ||
"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
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
2896608
7.65%72484
6.05%