-
Notifications
You must be signed in to change notification settings - Fork 2
/
doc-design.ts
70 lines (61 loc) · 2.02 KB
/
doc-design.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Context data provided to the design function.
*/
export type DesignContext = {
/**
* The username of the user creating the data.
*/
username: string;
}
/**
* Returns a list of design specs that define the desired test data to generate.
* @param context the context data
* @returns a list of design specs
*/
export type DocDesign = (context: DesignContext) => DesignSpec[];
/**
* Design specification for a type of document to generate.
*/
export interface DesignSpec {
/**
* Optional. Useful for debugging and to identify if the upload was successful or failed. Defaults to index in array.
*/
designId?: string;
/**
* Required. The number of documents of this type to generate. This also servers as the batch size of docs to upload.
*/
amount: number;
/**
* The database to upload the generated documents to. Defaults to `medic`.
*/
db?: string;
/**
* Required. Returns the document to generate. If no `_id` value is provided, one will be generated automatically.
* This function is called the number of times defined in the `amount` property.
* @param args.parent the newly created parent document if one exists, otherwise undefined
* @returns the document to generate
*/
getDoc(args: { parent?: Doc }): Doc;
/**
* Defines the children documents that should be created for the current document type. These children will be
* automatically linked to their parent document. For reports, the `contact` field will be populated. If the current
* doc is a `person`, then the `patient_id` and `patient_uuid` fields will be set on the children. Otherwise, the
* `place_id` and `place_uuid` fields will be set on all child reports. For child contacts, the `parent` field will
* be automatically populated.
*/
children?: DesignSpec[];
}
export interface Parent {
_id: string,
parent?: Parent
}
export interface Doc {
_id: string;
type: string;
parent?: Parent;
[key: string]: unknown;
}
export enum DocType {
dataRecord = 'data_record',
person = 'person',
}