@opencrvs/toolkit
Advanced tools
Comparing version
@@ -7,5 +7,4 @@ import { ConditionalParameters, JSONSchema } from './conditionals'; | ||
export declare function validate(schema: JSONSchema, data: ConditionalParameters): boolean; | ||
export declare function isFieldHidden(field: FieldConfig, params: ConditionalParameters): boolean; | ||
export declare function isFieldDisabled(field: FieldConfig, params: ConditionalParameters): boolean; | ||
export declare function isFieldHiddenOrDisabled(field: FieldConfig, params: ConditionalParameters): boolean; | ||
export declare function isFieldVisible(field: FieldConfig, form: ActionFormData): boolean; | ||
export declare function isFieldEnabled(field: FieldConfig, form: ActionFormData): boolean; | ||
/** | ||
@@ -12,0 +11,0 @@ * Custom error map for Zod to override the default error messages in intl-formik format. |
@@ -19,4 +19,7 @@ /** | ||
readonly CUSTOM: "CUSTOM"; | ||
readonly REJECT: "REJECT"; | ||
readonly MARKED_AS_DUPLICATE: "MARKED_AS_DUPLICATE"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}; | ||
export type ActionType = (typeof ActionType)[keyof typeof ActionType]; | ||
//# sourceMappingURL=ActionType.d.ts.map |
import { z } from 'zod'; | ||
import { TranslationConfig } from './TranslationConfig'; | ||
export declare const AdvancedSearchConfig: z.ZodObject<{ | ||
id: z.ZodString; | ||
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, { | ||
@@ -31,3 +30,2 @@ id: string; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
title: TranslationConfig; | ||
@@ -41,3 +39,2 @@ fields: { | ||
}, { | ||
id: string; | ||
title: { | ||
@@ -44,0 +41,0 @@ id: string; |
@@ -9,3 +9,3 @@ import { EventConfigInput } from './EventConfigInput'; | ||
actions: ({ | ||
type: "CREATE"; | ||
type: "DECLARE"; | ||
conditionals: ({ | ||
@@ -38,3 +38,3 @@ type: "SHOW"; | ||
} | { | ||
type: "DECLARE"; | ||
type: "VALIDATE"; | ||
conditionals: ({ | ||
@@ -67,3 +67,4 @@ type: "SHOW"; | ||
} | { | ||
type: "VALIDATE"; | ||
type: "REJECT"; | ||
comment: string; | ||
conditionals: ({ | ||
@@ -94,4 +95,65 @@ type: "SHOW"; | ||
}[]; | ||
isDuplicate: boolean; | ||
draft?: boolean | undefined; | ||
} | { | ||
type: "MARKED_AS_DUPLICATE"; | ||
comment: string; | ||
conditionals: ({ | ||
type: "SHOW"; | ||
conditional: import(".").JSONSchema; | ||
} | { | ||
type: "ENABLE"; | ||
conditional: import(".").JSONSchema; | ||
})[]; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
forms: { | ||
active: boolean; | ||
version: { | ||
id: string; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
}; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
pages: { | ||
id: string; | ||
title: import("./TranslationConfig").TranslationConfig; | ||
fields: import("./FieldConfig").Inferred[]; | ||
}[]; | ||
review: { | ||
title: import("./TranslationConfig").TranslationConfig; | ||
fields: import("./FieldConfig").Inferred[]; | ||
}; | ||
}[]; | ||
duplicates: string[]; | ||
draft?: boolean | undefined; | ||
} | { | ||
type: "ARCHIVED"; | ||
comment: string; | ||
conditionals: ({ | ||
type: "SHOW"; | ||
conditional: import(".").JSONSchema; | ||
} | { | ||
type: "ENABLE"; | ||
conditional: import(".").JSONSchema; | ||
})[]; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
forms: { | ||
active: boolean; | ||
version: { | ||
id: string; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
}; | ||
label: import("./TranslationConfig").TranslationConfig; | ||
pages: { | ||
id: string; | ||
title: import("./TranslationConfig").TranslationConfig; | ||
fields: import("./FieldConfig").Inferred[]; | ||
}[]; | ||
review: { | ||
title: import("./TranslationConfig").TranslationConfig; | ||
fields: import("./FieldConfig").Inferred[]; | ||
}; | ||
}[]; | ||
isDuplicate: boolean; | ||
draft?: boolean | undefined; | ||
} | { | ||
type: "REGISTER"; | ||
@@ -319,8 +381,4 @@ conditionals: ({ | ||
id: string; | ||
fields: { | ||
label: import("./TranslationConfig").TranslationConfig; | ||
column: string; | ||
}[]; | ||
filters: { | ||
status: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
status: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
}[]; | ||
@@ -334,3 +392,2 @@ }[]; | ||
advancedSearch: { | ||
id: string; | ||
title: import("./TranslationConfig").TranslationConfig; | ||
@@ -337,0 +394,0 @@ fields: { |
@@ -12,2 +12,4 @@ import { z } from 'zod'; | ||
readonly CERTIFIED: "CERTIFIED"; | ||
readonly REJECTED: "REJECTED"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}>; | ||
@@ -20,2 +22,3 @@ createdAt: z.ZodString; | ||
updatedBy: z.ZodString; | ||
trackingId: z.ZodString; | ||
}, { | ||
@@ -26,3 +29,3 @@ data: z.ZodRecord<z.ZodString, z.ZodAny>; | ||
id: string; | ||
status: "CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
status: "ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
data: Record<string, any>; | ||
@@ -33,2 +36,3 @@ createdAt: string; | ||
assignedTo: string | null; | ||
trackingId: string; | ||
modifiedAt: string; | ||
@@ -39,3 +43,3 @@ updatedBy: string; | ||
id: string; | ||
status: "CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
status: "ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
data: Record<string, any>; | ||
@@ -46,2 +50,3 @@ createdAt: string; | ||
assignedTo: string | null; | ||
trackingId: string; | ||
modifiedAt: string; | ||
@@ -48,0 +53,0 @@ updatedBy: string; |
@@ -13,5 +13,7 @@ import { z } from 'zod'; | ||
readonly CERTIFIED: "CERTIFIED"; | ||
readonly REJECTED: "REJECTED"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}; | ||
export type EventStatus = (typeof EventStatus)[keyof typeof EventStatus]; | ||
export declare const eventStatuses: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
export declare const eventStatuses: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
export declare const EventStatuses: z.ZodNativeEnum<{ | ||
@@ -24,2 +26,4 @@ readonly CREATED: "CREATED"; | ||
readonly CERTIFIED: "CERTIFIED"; | ||
readonly REJECTED: "REJECTED"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}>; | ||
@@ -41,2 +45,4 @@ /** | ||
readonly CERTIFIED: "CERTIFIED"; | ||
readonly REJECTED: "REJECTED"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}>; | ||
@@ -49,6 +55,7 @@ createdAt: z.ZodString; | ||
updatedBy: z.ZodString; | ||
trackingId: z.ZodString; | ||
}, "strip", z.ZodTypeAny, { | ||
type: string; | ||
id: string; | ||
status: "CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
status: "ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
createdAt: string; | ||
@@ -58,2 +65,3 @@ createdBy: string; | ||
assignedTo: string | null; | ||
trackingId: string; | ||
modifiedAt: string; | ||
@@ -64,3 +72,3 @@ updatedBy: string; | ||
id: string; | ||
status: "CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
status: "ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED"; | ||
createdAt: string; | ||
@@ -70,2 +78,3 @@ createdBy: string; | ||
assignedTo: string | null; | ||
trackingId: string; | ||
modifiedAt: string; | ||
@@ -72,0 +81,0 @@ updatedBy: string; |
@@ -161,2 +161,18 @@ import { z } from 'zod'; | ||
zipCode: string; | ||
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; | ||
@@ -163,0 +179,0 @@ export declare const isParagraphFieldType: (field: { |
@@ -9,2 +9,3 @@ export * from './ActionConfig'; | ||
export * from './WorkqueueConfig'; | ||
export * from './Draft'; | ||
export * from './EventMetadata'; | ||
@@ -11,0 +12,0 @@ export * from './EventInput'; |
@@ -1,5 +0,9 @@ | ||
import { DeclareActionInput, RegisterActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput'; | ||
import { ArchivedActionInput, DeclareActionInput, RegisterActionInput, RejectDeclarationActionInput, RequestCorrectionActionInput, ValidateActionInput } from './ActionInput'; | ||
import { ActionType } from './ActionType'; | ||
import { Draft } from './Draft'; | ||
import { EventConfig } from './EventConfig'; | ||
import { EventDocument } from './EventDocument'; | ||
import { EventIndex } from './EventIndex'; | ||
import { EventInput } from './EventInput'; | ||
import { FieldValue } from './FieldValue'; | ||
export declare function generateActionInput(configuration: EventConfig, action: ActionType): import("lodash").Dictionary<string | number | boolean | { | ||
@@ -41,2 +45,87 @@ type: string; | ||
}; | ||
draft: (eventId: string, input?: Partial<Draft>) => { | ||
id: import("../uuid").UUID; | ||
eventId: string; | ||
createdAt: string; | ||
transactionId: import("../uuid").UUID; | ||
action: { | ||
type: "REQUEST_CORRECTION"; | ||
data: { | ||
'applicant.firstname': string; | ||
'applicant.surname': string; | ||
'applicant.dob': string; | ||
'recommender.none': boolean; | ||
}; | ||
metadata: { | ||
'correction.requester.relationship': string; | ||
'correction.request.reason': string; | ||
}; | ||
createdAt: string; | ||
createdBy: string; | ||
createdAtLocation: string; | ||
}; | ||
} & Partial<{ | ||
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 | undefined; | ||
town?: string | undefined; | ||
residentialArea?: string | undefined; | ||
street?: string | undefined; | ||
zipCode?: string | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | 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 | undefined; | ||
town?: string | undefined; | ||
residentialArea?: string | undefined; | ||
street?: string | undefined; | ||
zipCode?: string | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[]> | undefined; | ||
}; | ||
}>; | ||
actions: { | ||
@@ -106,2 +195,69 @@ declare: (eventId: string, input?: Partial<Pick<DeclareActionInput, "transactionId" | "data">>) => { | ||
}; | ||
archive: (eventId: string, input?: Partial<Pick<ArchivedActionInput, "transactionId" | "data">>, isDuplicate?: boolean) => { | ||
type: "ARCHIVED"; | ||
transactionId: string; | ||
data: Record<string, string | number | boolean | { | ||
type: string; | ||
filename: string; | ||
originalFilename: string; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "URBAN"; | ||
number?: string | undefined; | ||
town?: string | undefined; | ||
residentialArea?: string | undefined; | ||
street?: string | undefined; | ||
zipCode?: string | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[]>; | ||
metadata: { | ||
isDuplicate: boolean; | ||
}; | ||
duplicates: never[]; | ||
eventId: string; | ||
}; | ||
reject: (eventId: string, input?: Partial<Pick<RejectDeclarationActionInput, "transactionId" | "data">>) => { | ||
type: "REJECT"; | ||
transactionId: string; | ||
data: Record<string, string | number | boolean | { | ||
type: string; | ||
filename: string; | ||
originalFilename: string; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "URBAN"; | ||
number?: string | undefined; | ||
town?: string | undefined; | ||
residentialArea?: string | undefined; | ||
street?: string | undefined; | ||
zipCode?: string | undefined; | ||
} | { | ||
country: string; | ||
district: string; | ||
province: string; | ||
urbanOrRural: "RURAL"; | ||
village?: string | undefined; | ||
} | { | ||
type: string; | ||
option: string; | ||
filename: string; | ||
originalFilename: string; | ||
}[]>; | ||
duplicates: never[]; | ||
eventId: string; | ||
}; | ||
register: (eventId: string, input?: Partial<Pick<RegisterActionInput, "transactionId" | "data">>) => { | ||
@@ -269,2 +425,8 @@ type: "REGISTER"; | ||
}; | ||
export declare function generateEventDocument({ configuration, actions }: { | ||
configuration: EventConfig; | ||
actions: ActionType[]; | ||
}): EventDocument; | ||
export declare function generateEventDraftDocument(eventId: string, actionType?: ActionType, data?: Record<string, FieldValue>): Draft; | ||
export declare const eventQueryDataGenerator: (overrides?: Partial<EventIndex>) => EventIndex; | ||
//# sourceMappingURL=test.utils.d.ts.map |
@@ -9,2 +9,3 @@ import { TranslationConfig } from './TranslationConfig'; | ||
import { ActionFormData } from './ActionDocument'; | ||
import { FormConfig } from './FormConfig'; | ||
/** | ||
@@ -64,5 +65,23 @@ * @returns All the fields in the event configuration input. | ||
} | undefined; | ||
export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType) => import("./FieldConfig").Inferred[] | undefined; | ||
export declare const findActiveActionFormPages: (configuration: EventConfig, action: ActionType) => { | ||
id: string; | ||
title: TranslationConfig; | ||
fields: import("./FieldConfig").Inferred[]; | ||
}[] | undefined; | ||
export declare const getFormFields: (formConfig: FormConfig) => import("./FieldConfig").Inferred[]; | ||
/** | ||
* Returns only form fields for the action type, if any, excluding review fields. | ||
*/ | ||
export declare const findActiveActionFormFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined; | ||
/** | ||
* Returns all fields for the action type, including review fields, if any. | ||
*/ | ||
export declare const findActiveActionFields: (configuration: EventConfig, action: ActionType) => FieldConfig[] | undefined; | ||
/** | ||
* Returns all fields for the action type, including review fields, or throws | ||
*/ | ||
export declare function getActiveActionFields(configuration: EventConfig, action: ActionType): FieldConfig[]; | ||
export declare function getEventConfiguration(eventConfigurations: EventConfig[], type: string): EventConfig; | ||
export declare function stripHiddenOrDisabledFields(actionType: ActionType, eventConfiguration: EventConfig, data: ActionFormData): import("lodash").Dictionary<string | number | boolean | { | ||
export declare function isOptionalUncheckedCheckbox(field: FieldConfig, form: ActionFormData): boolean; | ||
export declare function stripHiddenFields(fields: FieldConfig[], data: ActionFormData): import("lodash").Dictionary<string | number | boolean | { | ||
type: string; | ||
@@ -69,0 +88,0 @@ filename: string; |
import { z } from 'zod'; | ||
import { TranslationConfig } from './TranslationConfig'; | ||
/** | ||
@@ -8,20 +7,2 @@ * Configuration for workqueue. Workqueues are used to display a list of events. | ||
id: z.ZodString; | ||
fields: z.ZodArray<z.ZodObject<{ | ||
column: z.ZodString; | ||
label: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, "strip", z.ZodTypeAny, TranslationConfig, { | ||
id: string; | ||
description: string; | ||
defaultMessage: string; | ||
}>; | ||
}, "strip", z.ZodTypeAny, { | ||
label: TranslationConfig; | ||
column: string; | ||
}, { | ||
label: { | ||
id: string; | ||
description: string; | ||
defaultMessage: string; | ||
}; | ||
column: string; | ||
}>, "many">; | ||
filters: z.ZodArray<z.ZodObject<{ | ||
@@ -35,29 +16,19 @@ status: z.ZodArray<z.ZodNativeEnum<{ | ||
readonly CERTIFIED: "CERTIFIED"; | ||
readonly REJECTED: "REJECTED"; | ||
readonly ARCHIVED: "ARCHIVED"; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
status: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
status: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
}, { | ||
status: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
status: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
}>, "many">; | ||
}, "strip", z.ZodTypeAny, { | ||
id: string; | ||
fields: { | ||
label: TranslationConfig; | ||
column: string; | ||
}[]; | ||
filters: { | ||
status: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
status: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
}[]; | ||
}, { | ||
id: string; | ||
fields: { | ||
label: { | ||
id: string; | ||
description: string; | ||
defaultMessage: string; | ||
}; | ||
column: string; | ||
}[]; | ||
filters: { | ||
status: ("CERTIFIED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
status: ("ARCHIVED" | "CERTIFIED" | "DECLARED" | "REGISTERED" | "REJECTED" | "VALIDATED" | "CREATED" | "NOTIFIED")[]; | ||
}[]; | ||
@@ -64,0 +35,0 @@ }>; |
@@ -97,15 +97,5 @@ "use strict"; | ||
const: action | ||
}, | ||
draft: { | ||
type: "boolean" | ||
} | ||
}, | ||
required: ["type"], | ||
not: { | ||
properties: { | ||
draft: { | ||
const: true | ||
} | ||
} | ||
} | ||
required: ["type"] | ||
} | ||
@@ -112,0 +102,0 @@ } |
{ | ||
"name": "@opencrvs/toolkit", | ||
"version": "1.7.0-rc.ffe61e3", | ||
"version": "1.8.0-rc.1509100", | ||
"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
1707366
28.29%53
1.92%46822
26.97%