@ecrvs/opencrvs-toolkit 1.8.1-rc.a7ee8fb
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 +70 -0
- package/build.sh +56 -0
- package/dist/api/index.d.ts +11 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +52 -0
- package/dist/commons/api/router.d.ts +14568 -0
- package/dist/commons/conditionals/conditionals.d.ts +194 -0
- package/dist/commons/conditionals/index.d.ts +2 -0
- package/dist/commons/conditionals/validate.d.ts +129 -0
- package/dist/commons/events/ActionConfig.d.ts +2034 -0
- package/dist/commons/events/ActionDocument.d.ts +14400 -0
- package/dist/commons/events/ActionInput.d.ts +11157 -0
- package/dist/commons/events/ActionType.d.ts +52 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +1175 -0
- package/dist/commons/events/CompositeFieldValue.d.ts +181 -0
- package/dist/commons/events/Conditional.d.ts +55 -0
- package/dist/commons/events/Constants.d.ts +3 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +4494 -0
- package/dist/commons/events/CreatedAtLocation.d.ts +2 -0
- package/dist/commons/events/DeduplicationConfig.d.ts +209 -0
- package/dist/commons/events/Draft.d.ts +814 -0
- package/dist/commons/events/EventConfig.d.ts +2237 -0
- package/dist/commons/events/EventConfigInput.d.ts +10 -0
- package/dist/commons/events/EventDocument.d.ts +8505 -0
- package/dist/commons/events/EventIndex.d.ts +3858 -0
- package/dist/commons/events/EventInput.d.ts +13 -0
- package/dist/commons/events/EventMetadata.d.ts +408 -0
- package/dist/commons/events/FieldConfig.d.ts +7125 -0
- package/dist/commons/events/FieldType.d.ts +46 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +537 -0
- package/dist/commons/events/FieldValue.d.ts +250 -0
- package/dist/commons/events/FileUtils.d.ts +4 -0
- package/dist/commons/events/FormConfig.d.ts +725 -0
- package/dist/commons/events/PageConfig.d.ts +336 -0
- package/dist/commons/events/SummaryConfig.d.ts +170 -0
- package/dist/commons/events/TemplateConfig.d.ts +38 -0
- package/dist/commons/events/TranslationConfig.d.ts +15 -0
- package/dist/commons/events/User.d.ts +45 -0
- package/dist/commons/events/WorkqueueColumnConfig.d.ts +53 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +8997 -0
- package/dist/commons/events/deduplication.d.ts +32 -0
- package/dist/commons/events/defineConfig.d.ts +309 -0
- package/dist/commons/events/event.d.ts +109 -0
- package/dist/commons/events/field.d.ts +151 -0
- package/dist/commons/events/index.d.ts +46 -0
- package/dist/commons/events/locations.d.ts +24 -0
- package/dist/commons/events/scopes.d.ts +55 -0
- package/dist/commons/events/serializer.d.ts +2 -0
- package/dist/commons/events/state/availableActions.d.ts +6 -0
- package/dist/commons/events/state/flags.d.ts +4 -0
- package/dist/commons/events/state/index.d.ts +146 -0
- package/dist/commons/events/state/utils.d.ts +1263 -0
- package/dist/commons/events/test.utils.d.ts +473 -0
- package/dist/commons/events/transactions.d.ts +2 -0
- package/dist/commons/events/utils.d.ts +501 -0
- package/dist/commons/events/workqueueDefaultColumns.d.ts +3 -0
- package/dist/commons/notification/UserNotifications.d.ts +632 -0
- package/dist/commons/notification/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts +2 -0
- package/dist/conditionals/index.d.ts.map +1 -0
- package/dist/conditionals/index.js +491 -0
- package/dist/events/deduplication.d.ts +32 -0
- package/dist/events/deduplication.d.ts.map +1 -0
- package/dist/events/deduplication.js +67 -0
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +8383 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.d.ts.map +1 -0
- package/dist/notification/index.js +5928 -0
- package/dist/scopes/index.d.ts +335 -0
- package/dist/scopes/index.d.ts.map +1 -0
- package/dist/scopes/index.js +379 -0
- package/package.json +40 -0
- package/tsconfig.json +27 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ConfigurableScopeType, Scope } from '../scopes';
|
|
2
|
+
import { DisplayableAction } from './ActionType';
|
|
3
|
+
import { EventIndex } from './EventIndex';
|
|
4
|
+
export declare const ACTION_SCOPE_MAP: {
|
|
5
|
+
READ: "record.read"[];
|
|
6
|
+
CREATE: "record.create"[];
|
|
7
|
+
NOTIFY: "record.notify"[];
|
|
8
|
+
DECLARE: ("record.register" | "record.declare" | "record.declared.validate")[];
|
|
9
|
+
DELETE: "record.declare"[];
|
|
10
|
+
VALIDATE: ("record.register" | "record.declared.validate")[];
|
|
11
|
+
REGISTER: "record.register"[];
|
|
12
|
+
PRINT_CERTIFICATE: "record.registered.print-certified-copies"[];
|
|
13
|
+
REQUEST_CORRECTION: ("record.registered.request-correction" | "record.registered.correct")[];
|
|
14
|
+
REVIEW_CORRECTION_REQUEST: "record.registered.correct"[];
|
|
15
|
+
REJECT_CORRECTION: "record.registered.correct"[];
|
|
16
|
+
APPROVE_CORRECTION: "record.registered.correct"[];
|
|
17
|
+
MARK_AS_DUPLICATE: "record.declared.review-duplicates"[];
|
|
18
|
+
MARK_AS_NOT_DUPLICATE: "record.declared.review-duplicates"[];
|
|
19
|
+
ARCHIVE: "record.declared.archive"[];
|
|
20
|
+
REJECT: "record.declared.reject"[];
|
|
21
|
+
ASSIGN: null;
|
|
22
|
+
UNASSIGN: null;
|
|
23
|
+
DUPLICATE_DETECTED: never[];
|
|
24
|
+
};
|
|
25
|
+
export declare function hasAnyOfScopes(a: Scope[], b: Scope[]): boolean;
|
|
26
|
+
export declare function configurableEventScopeAllowed(scopes: Scope[], allowedConfigurableScopes: ConfigurableScopeType[], eventType: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if a given action is allowed for the provided scopes and event type.
|
|
29
|
+
*
|
|
30
|
+
* This function determines whether the user, with the given set of scopes, is authorized
|
|
31
|
+
* to perform the specified action on an event of the given type. It checks both "plain" scopes
|
|
32
|
+
* (hardcoded, non-configurable) and "configurable" scopes (which may be tied to specific event types).
|
|
33
|
+
*
|
|
34
|
+
* @param {Scope[]} scopes - The list of scopes the user possesses.
|
|
35
|
+
* @param {DisplayableAction} action - The action to check authorization for.
|
|
36
|
+
* @param {string} eventType - The type of event for which the action is being checked.
|
|
37
|
+
* @returns {boolean} True if the action is in scope for the user, otherwise false.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isActionInScope(scopes: Scope[], action: DisplayableAction, eventType: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* A shared utility to check if the user can read a record.
|
|
42
|
+
* This will be removed in 1.10 and implemented by scopes.
|
|
43
|
+
*
|
|
44
|
+
* In order for us to limit the usage of 'record.read' scope, we allow users to view records they have created on system-level.
|
|
45
|
+
*
|
|
46
|
+
* @deprecated - Will be removed in 1.10
|
|
47
|
+
*/
|
|
48
|
+
export declare function canUserReadEvent(event: EventIndex | {
|
|
49
|
+
createdBy: string;
|
|
50
|
+
type: string;
|
|
51
|
+
}, { userId, scopes }: {
|
|
52
|
+
userId: string;
|
|
53
|
+
scopes: string[];
|
|
54
|
+
}): boolean;
|
|
55
|
+
//# sourceMappingURL=scopes.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DisplayableAction } from '../ActionType';
|
|
2
|
+
import { EventIndex } from '../EventIndex';
|
|
3
|
+
import { EventStatus, Flag } from '../EventMetadata';
|
|
4
|
+
export declare function getAvailableActions(status: EventStatus, flags: Flag[]): DisplayableAction[];
|
|
5
|
+
export declare function getAvailableActionsForEvent(event: EventIndex): DisplayableAction[];
|
|
6
|
+
//# sourceMappingURL=availableActions.d.ts.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ActionType } from '../ActionType';
|
|
2
|
+
import { Action, ActionDocument, ActionUpdate, EventState, PotentialDuplicate } from '../ActionDocument';
|
|
3
|
+
import { EventDocument } from '../EventDocument';
|
|
4
|
+
import { EventIndex } from '../EventIndex';
|
|
5
|
+
import { EventStatus } from '../EventMetadata';
|
|
6
|
+
import { Draft } from '../Draft';
|
|
7
|
+
import { EventConfig } from '../EventConfig';
|
|
8
|
+
import { UUID } from '../../uuid';
|
|
9
|
+
import { DocumentPath, FullDocumentPath, FullDocumentUrl } from '../../documents';
|
|
10
|
+
export declare function getStatusFromActions(actions: Array<Action>): "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
|
|
11
|
+
export declare function getAssignedUserFromActions(actions: Array<ActionDocument>): string | null;
|
|
12
|
+
export declare function getAssignedUserSignatureFromActions(actions: Array<ActionDocument>): string | null;
|
|
13
|
+
type NonNullableDeep<T> = T extends [unknown, ...unknown[]] ? {
|
|
14
|
+
[K in keyof T]: NonNullableDeep<NonNullable<T[K]>>;
|
|
15
|
+
} : T extends UUID ? T : T extends FullDocumentPath ? T : T extends DocumentPath ? T : T extends FullDocumentUrl ? T : T extends (infer U)[] ? NonNullableDeep<U>[] : T extends object ? {
|
|
16
|
+
[K in keyof T]: NonNullableDeep<NonNullable<T[K]>>;
|
|
17
|
+
} : NonNullable<T>;
|
|
18
|
+
/**
|
|
19
|
+
* @returns Given arbitrary object, recursively remove all keys with null values
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* deepDropNulls({ a: null, b: { c: null, d: 'foo' } }) // { b: { d: 'foo' } }
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export declare function deepDropNulls<T>(obj: T): NonNullableDeep<T>;
|
|
26
|
+
export declare function isUndeclaredDraft(status: EventStatus): boolean;
|
|
27
|
+
export declare const DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
|
|
28
|
+
export declare function resolveDateOfEvent(eventMetadata: {
|
|
29
|
+
createdAt: string;
|
|
30
|
+
}, declaration: EventState, config: EventConfig): string | undefined;
|
|
31
|
+
export declare function extractPotentialDuplicatesFromActions(actions: Action[]): PotentialDuplicate[];
|
|
32
|
+
/**
|
|
33
|
+
* @returns the current state of the event based on the actions taken.
|
|
34
|
+
* @see EventIndex for the description of the returned object.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCurrentEventState(event: EventDocument, config: EventConfig): EventIndex;
|
|
37
|
+
/**
|
|
38
|
+
* @returns the future state of the event with drafts applied to all fields.
|
|
39
|
+
*
|
|
40
|
+
* NOTE: We treat the draft as a new action that is applied to the event. This means that even the status of the is changed as if draft has been accepted.
|
|
41
|
+
* @see applyDraftToEventIndex to apply the draft to the event without changing the status.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
export declare function dangerouslyGetCurrentEventStateWithDrafts({ event, draft, configuration }: {
|
|
45
|
+
event: EventDocument;
|
|
46
|
+
draft: Draft;
|
|
47
|
+
configuration: EventConfig;
|
|
48
|
+
}): EventIndex;
|
|
49
|
+
export declare function applyDeclarationToEventIndex(eventIndex: EventIndex, declaration: EventState | ActionUpdate, eventConfiguration: EventConfig): EventIndex;
|
|
50
|
+
/**
|
|
51
|
+
* Applies draft to the event index following internal business rules.
|
|
52
|
+
*
|
|
53
|
+
* Ensures only necessary fields are updated based on the draft (declaration, updatedAt, flags).
|
|
54
|
+
* NOTE: When naively applying draft, it leads to incorrect event state, since drafts are 'Accepted' by default.
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
export declare function applyDraftToEventIndex(eventIndex: EventIndex, draft: Draft, eventConfiguration: EventConfig): {
|
|
58
|
+
type: string;
|
|
59
|
+
id: string & import("zod").BRAND<"UUID">;
|
|
60
|
+
status: "ARCHIVED" | "DECLARED" | "REGISTERED" | "VALIDATED" | "CREATED" | "NOTIFIED";
|
|
61
|
+
createdAt: string;
|
|
62
|
+
createdBy: string;
|
|
63
|
+
declaration: Record<string, string | number | boolean | {
|
|
64
|
+
type: string;
|
|
65
|
+
path: string;
|
|
66
|
+
originalFilename: string;
|
|
67
|
+
} | {
|
|
68
|
+
firstname: string;
|
|
69
|
+
surname: string;
|
|
70
|
+
middlename?: string | undefined;
|
|
71
|
+
} | {
|
|
72
|
+
firstname: string;
|
|
73
|
+
surname: string;
|
|
74
|
+
middlename?: string | null | undefined;
|
|
75
|
+
} | Record<string, string> | {
|
|
76
|
+
country: string;
|
|
77
|
+
addressType: "DOMESTIC" | "INTERNATIONAL";
|
|
78
|
+
administrativeArea?: string | undefined;
|
|
79
|
+
streetLevelDetails?: Record<string, string> | undefined;
|
|
80
|
+
} | {
|
|
81
|
+
type: string;
|
|
82
|
+
option: string;
|
|
83
|
+
path: string;
|
|
84
|
+
originalFilename: string;
|
|
85
|
+
}[] | {
|
|
86
|
+
loading: boolean;
|
|
87
|
+
data?: any;
|
|
88
|
+
error?: {
|
|
89
|
+
message: string;
|
|
90
|
+
statusCode: number;
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
} | {
|
|
93
|
+
start: string;
|
|
94
|
+
end: string;
|
|
95
|
+
} | null | undefined>;
|
|
96
|
+
trackingId: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
legalStatuses: {
|
|
99
|
+
DECLARED?: {
|
|
100
|
+
createdAt: string;
|
|
101
|
+
createdBy: string;
|
|
102
|
+
createdByRole: string;
|
|
103
|
+
acceptedAt: string;
|
|
104
|
+
createdByUserType?: "system" | "user" | null | undefined;
|
|
105
|
+
createdBySignature?: string | null | undefined;
|
|
106
|
+
createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
|
107
|
+
} | null | undefined;
|
|
108
|
+
REGISTERED?: {
|
|
109
|
+
createdAt: string;
|
|
110
|
+
createdBy: string;
|
|
111
|
+
createdByRole: string;
|
|
112
|
+
registrationNumber: string;
|
|
113
|
+
acceptedAt: string;
|
|
114
|
+
createdByUserType?: "system" | "user" | null | undefined;
|
|
115
|
+
createdBySignature?: string | null | undefined;
|
|
116
|
+
createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
|
117
|
+
} | null | undefined;
|
|
118
|
+
};
|
|
119
|
+
updatedByUserRole: string;
|
|
120
|
+
potentialDuplicates: {
|
|
121
|
+
id: string & import("zod").BRAND<"UUID">;
|
|
122
|
+
trackingId: string;
|
|
123
|
+
}[];
|
|
124
|
+
flags: string[];
|
|
125
|
+
createdByUserType?: "system" | "user" | null | undefined;
|
|
126
|
+
createdBySignature?: string | null | undefined;
|
|
127
|
+
createdAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
|
128
|
+
assignedTo?: string | null | undefined;
|
|
129
|
+
dateOfEvent?: string | null | undefined;
|
|
130
|
+
updatedAtLocation?: (string & import("zod").BRAND<"UUID">) | null | undefined;
|
|
131
|
+
updatedBy?: string | null | undefined;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Annotation is always specific to the action. when action with annotation is triggered multiple times,
|
|
135
|
+
* previous annotations should have no effect on the new action annotation. (e.g. printing once should not pre-select print form fields)
|
|
136
|
+
*
|
|
137
|
+
* @returns annotation generated from drafts
|
|
138
|
+
*/
|
|
139
|
+
export declare function getAnnotationFromDrafts(drafts: Draft[]): {};
|
|
140
|
+
export declare function getActionAnnotation({ event, actionType, draft }: {
|
|
141
|
+
event: EventDocument;
|
|
142
|
+
actionType: ActionType;
|
|
143
|
+
draft?: Draft;
|
|
144
|
+
}): EventState;
|
|
145
|
+
export {};
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|