make-mp-data 1.3.3 → 1.4.0
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/.vscode/launch.json +11 -3
- package/.vscode/settings.json +12 -2
- package/README.md +2 -2
- package/chart.js +180 -0
- package/cli.js +30 -17
- package/index.js +459 -287
- package/package.json +59 -49
- package/{models → schemas}/complex.js +39 -19
- package/schemas/foobar.js +110 -0
- package/schemas/funnels.js +222 -0
- package/{models → schemas}/simple.js +10 -10
- package/scratch.mjs +20 -0
- package/testCases.mjs +229 -0
- package/testSoup.mjs +27 -0
- package/tests/e2e.test.js +27 -20
- package/tests/jest.config.js +30 -0
- package/tests/unit.test.js +360 -19
- package/tmp/.gitkeep +0 -0
- package/tsconfig.json +18 -0
- package/types.d.ts +186 -113
- package/utils.js +634 -124
- package/timesoup.js +0 -92
- /package/{models → schemas}/deepNest.js +0 -0
package/types.d.ts
CHANGED
|
@@ -1,114 +1,187 @@
|
|
|
1
1
|
declare namespace main {
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
2
|
+
type Primitives = string | number | boolean | Date | Record<string, any>;
|
|
3
|
+
|
|
4
|
+
// Recursive type to handle functions returning functions that eventually return Primitives or arrays of Primitives
|
|
5
|
+
export type ValueValid = Primitives | ValueValid[] | (() => ValueValid);
|
|
6
|
+
|
|
7
|
+
// MAIN CONFIGURATION OBJECT
|
|
8
|
+
export interface Config {
|
|
9
|
+
token?: string;
|
|
10
|
+
seed?: string;
|
|
11
|
+
numDays?: number;
|
|
12
|
+
epochStart?: number;
|
|
13
|
+
epochEnd?: number;
|
|
14
|
+
numEvents?: number;
|
|
15
|
+
numUsers?: number;
|
|
16
|
+
format?: "csv" | "json";
|
|
17
|
+
region?: "US" | "EU";
|
|
18
|
+
chance?: any;
|
|
19
|
+
events?: EventConfig[]; //can also be a array of strings
|
|
20
|
+
superProps?: Record<string, ValueValid>;
|
|
21
|
+
funnels?: Funnel[];
|
|
22
|
+
userProps?: Record<string, ValueValid>;
|
|
23
|
+
scdProps?: Record<string, ValueValid>;
|
|
24
|
+
mirrorProps?: Record<string, MirrorProps>;
|
|
25
|
+
groupKeys?: [string, number][] | [string, number, string[]][]; // [key, numGroups, [events]]
|
|
26
|
+
groupProps?: Record<string, Record<string, ValueValid>>;
|
|
27
|
+
lookupTables?: LookupTable[];
|
|
28
|
+
writeToDisk?: boolean;
|
|
29
|
+
simulationName?: string;
|
|
30
|
+
verbose?: boolean;
|
|
31
|
+
anonIds?: boolean;
|
|
32
|
+
sessionIds?: boolean;
|
|
33
|
+
makeChart?: boolean | string;
|
|
34
|
+
soup?: soup;
|
|
35
|
+
hook?: Hook<any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type soup = {
|
|
39
|
+
deviation?: number;
|
|
40
|
+
peaks?: number;
|
|
41
|
+
mean?: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
type hookTypes =
|
|
45
|
+
| "event"
|
|
46
|
+
| "user"
|
|
47
|
+
| "group"
|
|
48
|
+
| "lookup"
|
|
49
|
+
| "scd"
|
|
50
|
+
| "mirror"
|
|
51
|
+
| "funnel-pre"
|
|
52
|
+
| "funnel-post"
|
|
53
|
+
| "";
|
|
54
|
+
export type Hook<T> = (record: any, type: hookTypes, meta: any) => T;
|
|
55
|
+
|
|
56
|
+
export interface EnrichArrayOptions<T> {
|
|
57
|
+
hook?: Hook<T>;
|
|
58
|
+
type?: hookTypes;
|
|
59
|
+
[key: string]: any;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface EnrichedArray<T> extends Array<T> {
|
|
63
|
+
hookPush: (item: T) => number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface EventConfig {
|
|
67
|
+
event?: string;
|
|
68
|
+
weight?: number;
|
|
69
|
+
properties?: Record<string, ValueValid>;
|
|
70
|
+
isFirstEvent?: boolean;
|
|
71
|
+
relativeTimeMs?: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface EventSpec {
|
|
75
|
+
event: string;
|
|
76
|
+
time: string;
|
|
77
|
+
insert_id: string;
|
|
78
|
+
device_id?: string;
|
|
79
|
+
session_id?: string;
|
|
80
|
+
user_id?: string;
|
|
81
|
+
[key: string]: ValueValid;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface Funnel {
|
|
85
|
+
sequence: string[];
|
|
86
|
+
weight?: number;
|
|
87
|
+
isFirstFunnel?: boolean;
|
|
88
|
+
order?:
|
|
89
|
+
| "sequential"
|
|
90
|
+
| "first-fixed"
|
|
91
|
+
| "last-fixed"
|
|
92
|
+
| "random"
|
|
93
|
+
| "first-and-last-fixed"
|
|
94
|
+
| "middle-fixed";
|
|
95
|
+
conversionRate?: number;
|
|
96
|
+
timeToConvert?: number;
|
|
97
|
+
props?: Record<string, ValueValid>;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface MirrorProps {
|
|
101
|
+
events: string[] | "*";
|
|
102
|
+
values: ValueValid[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface LookupTable {
|
|
106
|
+
key: string;
|
|
107
|
+
entries: number;
|
|
108
|
+
attributes: Record<string, ValueValid>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface SCDTableRow {
|
|
112
|
+
distinct_id: string;
|
|
113
|
+
insertTime: string;
|
|
114
|
+
startTime: string;
|
|
115
|
+
[key: string]: ValueValid;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export type Result = {
|
|
119
|
+
eventData: EventData[];
|
|
120
|
+
userProfilesData: any[];
|
|
121
|
+
scdTableData: any[];
|
|
122
|
+
groupProfilesData: GroupProfilesData[];
|
|
123
|
+
lookupTableData: LookupTableData[];
|
|
124
|
+
importResults?: ImportResults;
|
|
125
|
+
files?: string[];
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export interface EventData {
|
|
129
|
+
event: string;
|
|
130
|
+
source: string;
|
|
131
|
+
time: string;
|
|
132
|
+
device_id?: string;
|
|
133
|
+
session_id?: string;
|
|
134
|
+
user_id?: string;
|
|
135
|
+
[key: string]: any;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface GroupProfilesData {
|
|
139
|
+
key: string;
|
|
140
|
+
data: any[];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface LookupTableData {
|
|
144
|
+
key: string;
|
|
145
|
+
data: any[];
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface ImportResults {
|
|
149
|
+
events: ImportResult;
|
|
150
|
+
users: ImportResult;
|
|
151
|
+
groups: ImportResult[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface ImportResult {
|
|
155
|
+
success: number;
|
|
156
|
+
bytes: number;
|
|
157
|
+
}
|
|
158
|
+
export interface Person {
|
|
159
|
+
name: string;
|
|
160
|
+
email: string;
|
|
161
|
+
avatar: string;
|
|
162
|
+
created: string | undefined;
|
|
163
|
+
anonymousIds: string[];
|
|
164
|
+
sessionIds: string[];
|
|
165
|
+
distinct_id?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface UserProfile {
|
|
169
|
+
name?: string;
|
|
170
|
+
email?: string;
|
|
171
|
+
avatar?: string;
|
|
172
|
+
created: string | undefined;
|
|
173
|
+
distinct_id: string;
|
|
174
|
+
[key: string]: ValueValid;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Mixpanel Data Generator
|
|
180
|
+
* model events, users, groups, and lookup tables (and SCD props!)
|
|
181
|
+
* @example
|
|
182
|
+
* const gen = require('make-mp-data')
|
|
183
|
+
* const dta = gen({writeToDisk: false})
|
|
184
|
+
*/
|
|
185
|
+
declare function main(config: main.Config): Promise<main.Result>;
|
|
186
|
+
|
|
187
|
+
export = main;
|