make-mp-data 2.0.19 → 2.0.21

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,18 +1,17 @@
1
- declare namespace main {
2
- /**
3
- * most of the time, the value of a property is a primitive
4
- */
5
- type Primitives = string | number | boolean | Date | Record<string, any>;
6
-
7
- /**
8
- * a "validValue" can be a primitive, an array of primitives, or a function that returns a primitive
9
- */
10
- export type ValueValid = Primitives | ValueValid[] | (() => ValueValid);
11
-
12
- /**
13
- * main config object for the entire data generation
14
- */
15
- export interface Dungeon {
1
+ /**
2
+ * most of the time, the value of a property is a primitive
3
+ */
4
+ type Primitives = string | number | boolean | Date | Record<string, any>;
5
+
6
+ /**
7
+ * a "validValue" can be a primitive, an array of primitives, or a function that returns a primitive
8
+ */
9
+ export type ValueValid = Primitives | ValueValid[] | (() => ValueValid);
10
+
11
+ /**
12
+ * main config object for the entire data generation
13
+ */
14
+ export interface Dungeon {
16
15
  // constants
17
16
  token?: string;
18
17
  seed?: string;
@@ -71,34 +70,34 @@ declare namespace main {
71
70
 
72
71
  //probabilities
73
72
  percentUsersBornInDataset?: number;
74
- }
73
+ }
75
74
 
76
- export type SCDProp = {
75
+ export type SCDProp = {
77
76
  type?: string | "user" | "company_id" | "team_id" | "department_id";
78
77
  frequency: "day" | "week" | "month" | "year";
79
78
  values: ValueValid;
80
79
  timing: "fixed" | "fuzzy";
81
80
  max?: number;
82
- };
81
+ };
83
82
 
84
- /**
85
- * the soup is a set of parameters that determine the distribution of events over time
86
- */
87
- type soup = {
83
+ /**
84
+ * the soup is a set of parameters that determine the distribution of events over time
85
+ */
86
+ type soup = {
88
87
  deviation?: number;
89
88
  peaks?: number;
90
89
  mean?: number;
91
- };
90
+ };
92
91
 
93
- /**
94
- * the types of hooks that can be used
95
- */
96
- type hookTypes =
92
+ /**
93
+ * the types of hooks that can be used
94
+ */
95
+ export type hookTypes =
97
96
  | "event"
98
97
  | "user"
99
98
  | "group"
100
99
  | "lookup"
101
- | "scd"
100
+ // | "scd"
102
101
  | "scd-pre"
103
102
  | "mirror"
104
103
  | "funnel-pre"
@@ -109,32 +108,33 @@ declare namespace main {
109
108
  | "everything"
110
109
  | "";
111
110
 
112
- /**
113
- * a hook is a function that can be called before each entity is created, and can be used to modify attributes
114
- */
115
- export type Hook<T> = (record: any, type: hookTypes, meta: any) => T;
111
+ /**
112
+ * a hook is a function that can be called before each entity is created, and can be used to modify attributes
113
+ */
114
+ export type Hook<T> = (record: any, type: hookTypes, meta: any) => T;
116
115
 
117
- export interface hookArrayOptions<T> {
116
+ export interface hookArrayOptions<T> {
118
117
  hook?: Hook<T>;
119
118
  type?: hookTypes;
120
119
  filename?: string;
121
120
  format?: "csv" | "json" | string;
122
121
  concurrency?: number;
122
+ context?: Context;
123
123
  [key: string]: any;
124
- }
124
+ }
125
125
 
126
- /**
127
- * an enriched array is an array that has a hookPush method that can be used to transform-then-push items into the array
128
- */
129
- export interface HookedArray<T> extends Array<T> {
130
- hookPush: (item: T | T[], ...meta) => any;
126
+ /**
127
+ * an enriched array is an array that has a hookPush method that can be used to transform-then-push items into the array
128
+ */
129
+ export interface HookedArray<T> extends Array<T> {
130
+ hookPush: (item: T | T[], ...meta: any[]) => any;
131
131
  flush: () => void;
132
132
  getWriteDir: () => string;
133
133
  getWritePath: () => string;
134
134
  [key: string]: any;
135
- }
135
+ }
136
136
 
137
- export type AllData =
137
+ export type AllData =
138
138
  | HookedArray<EventSchema>
139
139
  | HookedArray<UserProfile>
140
140
  | HookedArray<GroupProfileSchema>
@@ -142,10 +142,10 @@ declare namespace main {
142
142
  | HookedArray<SCDSchema>
143
143
  | any[];
144
144
 
145
- /**
146
- * the storage object is a key-value store that holds arrays of data
147
- */
148
- export interface Storage {
145
+ /**
146
+ * the storage object is a key-value store that holds arrays of data
147
+ */
148
+ export interface Storage {
149
149
  eventData?: HookedArray<EventSchema>;
150
150
  mirrorEventData?: HookedArray<EventSchema>;
151
151
  userProfilesData?: HookedArray<UserProfile>;
@@ -154,24 +154,24 @@ declare namespace main {
154
154
  lookupTableData?: HookedArray<LookupTableSchema>[];
155
155
  scdTableData?: HookedArray<SCDSchema>[];
156
156
  groupEventData?: HookedArray<EventSchema>;
157
- }
157
+ }
158
158
 
159
- /**
160
- * Runtime state for tracking execution metrics and flags
161
- */
162
- export interface RuntimeState {
159
+ /**
160
+ * Runtime state for tracking execution metrics and flags
161
+ */
162
+ export interface RuntimeState {
163
163
  operations: number;
164
164
  eventCount: number;
165
165
  userCount: number;
166
166
  isBatchMode: boolean;
167
167
  verbose: boolean;
168
168
  isCLI: boolean;
169
- }
169
+ }
170
170
 
171
- /**
172
- * Default data factories for generating realistic test data
173
- */
174
- export interface Defaults {
171
+ /**
172
+ * Default data factories for generating realistic test data
173
+ */
174
+ export interface Defaults {
175
175
  locationsUsers: () => any[];
176
176
  locationsEvents: () => any[];
177
177
  iOSDevices: () => any[];
@@ -179,13 +179,13 @@ declare namespace main {
179
179
  desktopDevices: () => any[];
180
180
  browsers: () => any[];
181
181
  campaigns: () => any[];
182
- }
182
+ }
183
183
 
184
- /**
185
- * Context object that replaces global variables with dependency injection
186
- * Contains validated config, storage containers, defaults, and runtime state
187
- */
188
- export interface Context {
184
+ /**
185
+ * Context object that replaces global variables with dependency injection
186
+ * Contains validated config, storage containers, defaults, and runtime state
187
+ */
188
+ export interface Context {
189
189
  config: Dungeon;
190
190
  storage: Storage | null;
191
191
  defaults: Defaults;
@@ -193,6 +193,7 @@ declare namespace main {
193
193
  runtime: RuntimeState;
194
194
  FIXED_NOW: number;
195
195
  FIXED_BEGIN?: number;
196
+ TIME_SHIFT_SECONDS: number;
196
197
 
197
198
  // State update methods
198
199
  incrementOperations(): void;
@@ -212,12 +213,12 @@ declare namespace main {
212
213
  // Time helper methods
213
214
  getTimeShift(): number;
214
215
  getDaysShift(): number;
215
- }
216
+ }
216
217
 
217
- /**
218
- * how we define events and their properties
219
- */
220
- export interface EventConfig {
218
+ /**
219
+ * how we define events and their properties
220
+ */
221
+ export interface EventConfig {
221
222
  event?: string;
222
223
  weight?: number;
223
224
  properties?: Record<string, ValueValid>;
@@ -225,19 +226,19 @@ declare namespace main {
225
226
  isChurnEvent?: boolean;
226
227
  isSessionStartEvent?: boolean;
227
228
  relativeTimeMs?: number;
228
- }
229
+ }
229
230
 
230
- export interface GroupEventConfig extends EventConfig {
231
+ export interface GroupEventConfig extends EventConfig {
231
232
  frequency: number; //how often the event occurs (in days)
232
233
  group_key: string; //the key that the group is based on
233
234
  attribute_to_user: boolean; //if true, the event also goes to a user
234
235
  group_size: number; //the number of users in the group
235
- }
236
+ }
236
237
 
237
- /**
238
- * the generated event data
239
- */
240
- export interface EventSchema {
238
+ /**
239
+ * the generated event data
240
+ */
241
+ export interface EventSchema {
241
242
  event: string;
242
243
  time: string;
243
244
  source: string;
@@ -246,12 +247,20 @@ declare namespace main {
246
247
  session_id?: string;
247
248
  user_id?: string;
248
249
  [key: string]: ValueValid;
249
- }
250
+ }
250
251
 
251
- /**
252
- * how we define funnels and their properties
253
- */
254
- export interface Funnel {
252
+ /**
253
+ * how we define funnels and their properties
254
+ */
255
+ export interface Funnel {
256
+ /**
257
+ * the name of the funnel
258
+ */
259
+ name?: string;
260
+ /**
261
+ * the description of the funnel
262
+ */
263
+ description?: string;
255
264
  /**
256
265
  * the sequence of events that define the funnel
257
266
  */
@@ -274,14 +283,14 @@ declare namespace main {
274
283
  * how the events in the funnel are ordered for each user
275
284
  */
276
285
  order?:
277
- | string
278
- | "sequential"
279
- | "first-fixed"
280
- | "last-fixed"
281
- | "random" //totally shuffled
282
- | "first-and-last-fixed"
283
- | "middle-fixed"
284
- | "interrupted";
286
+ | "sequential"
287
+ | "first-fixed"
288
+ | "last-fixed"
289
+ | "random" //totally shuffled
290
+ | "first-and-last-fixed"
291
+ | "middle-fixed"
292
+ | "interrupted"
293
+ | string;
285
294
 
286
295
  /**
287
296
  * todo: implement this
@@ -302,13 +311,13 @@ declare namespace main {
302
311
  * funnel properties go onto each event in the funnel and are held constant
303
312
  */
304
313
  props?: Record<string, ValueValid>;
305
- }
314
+ }
306
315
 
307
- /**
308
- * mirror props are used to show mutations of event data over time
309
- * there are different strategies for how to mutate the data
310
- */
311
- export interface MirrorProps {
316
+ /**
317
+ * mirror props are used to show mutations of event data over time
318
+ * there are different strategies for how to mutate the data
319
+ */
320
+ export interface MirrorProps {
312
321
  /**
313
322
  * the event that will be mutated in the new version
314
323
  */
@@ -325,18 +334,18 @@ declare namespace main {
325
334
  * optional: for 'fill' mode, daysUnfilled will dictate where the cutoff is in the unfilled data
326
335
  */
327
336
  daysUnfilled?: number;
328
- }
337
+ }
329
338
 
330
- export interface UserProfile {
339
+ export interface UserProfile {
331
340
  name?: string;
332
341
  email?: string;
333
342
  avatar?: string;
334
343
  created: string | undefined;
335
344
  distinct_id: string;
336
345
  [key: string]: ValueValid;
337
- }
346
+ }
338
347
 
339
- export interface Person {
348
+ export interface Person {
340
349
  name: string;
341
350
  email?: string;
342
351
  avatar?: string;
@@ -344,48 +353,48 @@ declare namespace main {
344
353
  anonymousIds: string[];
345
354
  sessionIds: string[];
346
355
  distinct_id?: string;
347
- }
356
+ }
348
357
 
349
- /**
350
- * the generated user data
351
- */
352
- export interface LookupTableSchema {
358
+ /**
359
+ * the generated user data
360
+ */
361
+ export interface LookupTableSchema {
353
362
  key: string;
354
363
  entries: number;
355
364
  attributes: Record<string, ValueValid>;
356
- }
365
+ }
357
366
 
358
- export interface LookupTableData {
367
+ export interface LookupTableData {
359
368
  key: string;
360
369
  data: any[];
361
- }
370
+ }
362
371
 
363
- export interface SCDSchema {
372
+ export interface SCDSchema {
364
373
  distinct_id: string;
365
374
  insertTime: string;
366
375
  startTime: string;
367
376
  [key: string]: ValueValid;
368
- }
377
+ }
369
378
 
370
- export interface GroupProfileSchema {
379
+ export interface GroupProfileSchema {
371
380
  key: string;
372
381
  data: any[];
373
- }
382
+ }
374
383
 
375
- /**
376
- * the end result of importing data into mixpanel
377
- */
378
- export interface ImportResults {
384
+ /**
385
+ * the end result of importing data into mixpanel
386
+ */
387
+ export interface ImportResults {
379
388
  events: ImportResult;
380
389
  users: ImportResult;
381
390
  groups: ImportResult[];
382
- }
383
- type ImportResult = import("mixpanel-import").ImportResults;
391
+ }
392
+ type ImportResult = import("mixpanel-import").ImportResults;
384
393
 
385
- /**
386
- * the end result of the data generation
387
- */
388
- export type Result = {
394
+ /**
395
+ * the end result of the data generation
396
+ */
397
+ export type Result = {
389
398
  eventData: EventSchema[];
390
399
  mirrorEventData: EventSchema[];
391
400
  userProfilesData: any[];
@@ -396,16 +405,15 @@ declare namespace main {
396
405
  importResults?: ImportResults;
397
406
  files?: string[];
398
407
  time?: {
399
- start: number;
400
- end: number;
401
- delta: number;
402
- human: string;
408
+ start: number;
409
+ end: number;
410
+ delta: number;
411
+ human: string;
403
412
  };
404
413
  operations?: number;
405
414
  eventCount?: number;
406
415
  userCount?: number;
407
- };
408
- }
416
+ };
409
417
 
410
418
  /**
411
419
  * Mixpanel Data Generator
@@ -414,6 +422,6 @@ declare namespace main {
414
422
  * import datagenerator from 'make-mp-data';
415
423
  * const data = await datagenerator({...opts});
416
424
  */
417
- declare function main(config: main.Dungeon): Promise<main.Result>;
425
+ declare function main(config: Dungeon): Promise<Result>;
418
426
 
419
- export = main;
427
+ export default main;
@@ -1,20 +0,0 @@
1
- /**
2
- * Cloud Function Entry Point
3
- * Provides a clean interface for Google Cloud Functions deployment
4
- */
5
-
6
- /** @typedef {import('../types').Dungeon} Config */
7
-
8
- import functions from '@google-cloud/functions-framework';
9
- import { handleCloudFunctionEntry } from './orchestrators/worker-manager.js';
10
- import main from '../index.js';
11
-
12
- /**
13
- * Cloud Function HTTP entry point
14
- * Handles distributed data generation across multiple workers
15
- */
16
- functions.http('entry', async (req, res) => {
17
- await handleCloudFunctionEntry(req, res, main);
18
- });
19
-
20
- export { handleCloudFunctionEntry, main };