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/types.d.ts CHANGED
@@ -1,114 +1,187 @@
1
1
  declare namespace main {
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
- type ValueValid =
6
- | Primitives
7
- | ValueValid[]
8
- | (() => ValueValid);
9
-
10
- // MAIN CONFIGURATION OBJECT
11
- export interface Config {
12
- token?: string;
13
- seed?: string;
14
- numDays?: number;
15
- numEvents?: number;
16
- numUsers?: number;
17
- format?: "csv" | "json";
18
- region?: string;
19
- events?: EventConfig[];
20
- superProps?: Record<string, ValueValid>;
21
- userProps?: Record<string, ValueValid>;
22
- scdProps?: Record<string, ValueValid>;
23
- mirrorProps?: Record<string, MirrorProps>;
24
- groupKeys?: [string, number][];
25
- groupProps?: Record<string, Record<string, ValueValid>>;
26
- lookupTables?: LookupTable[];
27
- writeToDisk?: boolean;
28
- simulationName?: string;
29
- verbose?: boolean;
30
- anonIds?: boolean;
31
- sessionIds?: boolean;
32
- hook?: Hook;
33
- }
34
-
35
- export type Hook = (record: any, type: string, meta: any) => any;
36
-
37
- export interface EventConfig {
38
- event?: string;
39
- weight?: number;
40
- properties?: Record<string, ValueValid>;
41
- isFirstEvent?: boolean;
42
- }
43
-
44
- export interface MirrorProps {
45
- events: string[] | "*";
46
- values: ValueValid[];
47
- }
48
-
49
- export interface LookupTable {
50
- key: string;
51
- entries: number;
52
- attributes: Record<string, ValueValid>;
53
- }
54
-
55
- export interface SCDTable {
56
- distinct_id: string;
57
- insertTime: string;
58
- startTime: string;
59
- [key: string]: ValueValid;
60
- }
61
-
62
- export type Result = {
63
- eventData: EventData[];
64
- userProfilesData: any[];
65
- scdTableData: any[];
66
- groupProfilesData: GroupProfilesData[];
67
- lookupTableData: LookupTableData[];
68
- import?: ImportResults;
69
- files?: string[];
70
- };
71
-
72
- export interface EventData {
73
- event: string;
74
- $source: string;
75
- time: string;
76
- $device_id?: string;
77
- $session_id?: string;
78
- $user_id?: string;
79
- [key: string]: any;
80
- }
81
-
82
- export interface GroupProfilesData {
83
- key: string;
84
- data: any[];
85
- }
86
-
87
- export interface LookupTableData {
88
- key: string;
89
- data: any[];
90
- }
91
-
92
- export interface ImportResults {
93
- events: ImportResult;
94
- users: ImportResult;
95
- groups: ImportResult[];
96
- }
97
-
98
- export interface ImportResult {
99
- success: number;
100
- bytes: number;
101
- }
102
- }
103
-
104
- /**
105
- * Mixpanel Data Generator
106
- * model events, users, groups, and lookup tables (and SCD props!)
107
- * @example
108
- * const gen = require('make-mp-data')
109
- * const dta = gen({writeToDisk: false})
110
- */
111
- declare function main(config: main.Config): Promise<main.Result>;
112
-
113
- export = main;
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;