make-mp-data 2.0.0 → 2.0.2

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.
Files changed (64) hide show
  1. package/dungeons/adspend.js +96 -0
  2. package/dungeons/anon.js +104 -0
  3. package/dungeons/big.js +225 -0
  4. package/dungeons/business.js +345 -0
  5. package/dungeons/complex.js +396 -0
  6. package/dungeons/experiments.js +125 -0
  7. package/dungeons/foobar.js +241 -0
  8. package/dungeons/funnels.js +272 -0
  9. package/dungeons/gaming.js +315 -0
  10. package/dungeons/media.js +7 -7
  11. package/dungeons/mirror.js +129 -0
  12. package/dungeons/sanity.js +113 -0
  13. package/dungeons/scd.js +205 -0
  14. package/dungeons/simple.js +195 -0
  15. package/dungeons/userAgent.js +190 -0
  16. package/entry.js +57 -0
  17. package/index.js +96 -68
  18. package/lib/cli/cli.js +10 -5
  19. package/lib/core/config-validator.js +28 -12
  20. package/lib/core/context.js +147 -130
  21. package/lib/core/storage.js +45 -31
  22. package/lib/data/defaults.js +2 -2
  23. package/lib/generators/adspend.js +1 -2
  24. package/lib/generators/events.js +35 -24
  25. package/lib/generators/funnels.js +1 -2
  26. package/lib/generators/mirror.js +1 -2
  27. package/lib/orchestrators/mixpanel-sender.js +15 -7
  28. package/lib/orchestrators/user-loop.js +21 -10
  29. package/lib/orchestrators/worker-manager.js +5 -2
  30. package/lib/utils/ai.js +36 -63
  31. package/lib/utils/chart.js +5 -0
  32. package/lib/utils/instructions.txt +593 -0
  33. package/lib/utils/utils.js +162 -38
  34. package/package.json +23 -9
  35. package/types.d.ts +376 -376
  36. package/.claude/settings.local.json +0 -20
  37. package/.gcloudignore +0 -18
  38. package/.gitattributes +0 -2
  39. package/.prettierrc +0 -0
  40. package/.vscode/launch.json +0 -80
  41. package/.vscode/settings.json +0 -69
  42. package/.vscode/tasks.json +0 -12
  43. package/dungeons/customers/.gitkeep +0 -0
  44. package/env.yaml +0 -1
  45. package/lib/cloud-function.js +0 -20
  46. package/scratch.mjs +0 -62
  47. package/scripts/dana.mjs +0 -137
  48. package/scripts/deploy.sh +0 -15
  49. package/scripts/jsdoctest.js +0 -5
  50. package/scripts/new-dungeon.sh +0 -98
  51. package/scripts/new-project.mjs +0 -14
  52. package/scripts/run-index.sh +0 -2
  53. package/scripts/update-deps.sh +0 -5
  54. package/tests/benchmark/concurrency.mjs +0 -52
  55. package/tests/cli.test.js +0 -124
  56. package/tests/coverage/.gitkeep +0 -0
  57. package/tests/e2e.test.js +0 -379
  58. package/tests/int.test.js +0 -715
  59. package/tests/testCases.mjs +0 -229
  60. package/tests/testSoup.mjs +0 -28
  61. package/tests/unit.test.js +0 -910
  62. package/tmp/.gitkeep +0 -0
  63. package/tsconfig.json +0 -18
  64. package/vitest.config.js +0 -47
@@ -0,0 +1,315 @@
1
+
2
+ import dayjs from "dayjs";
3
+ import utc from "dayjs/plugin/utc.js";
4
+ import "dotenv/config";
5
+ import * as u from "../lib/utils/utils.js";
6
+ import * as v from "ak-tools";
7
+
8
+ const SEED = "my-seed";
9
+ dayjs.extend(utc);
10
+ const chance = u.initChance(SEED);
11
+ const num_users = 25_000;
12
+ const days = 180;
13
+
14
+ /** @typedef {import("../types.js").Dungeon} Config */
15
+
16
+ /** @type {Config} */
17
+ const config = {
18
+ token: "17f327eeb2217278f5b2c42a54aafe96",
19
+ seed: "sdgsdfgdfgkfj dfgkjh",
20
+ numDays: days,
21
+ numEvents: num_users * 90,
22
+ numUsers: num_users,
23
+ hasAnonIds: false,
24
+ hasSessionIds: false,
25
+ format: "json",
26
+ alsoInferFunnels: true,
27
+ hasLocation: true,
28
+ hasAndroidDevices: true,
29
+ hasIOSDevices: true,
30
+ hasDesktopDevices: true,
31
+ hasBrowser: false,
32
+ hasCampaigns: true,
33
+ isAnonymous: false,
34
+ hasAdSpend: false,
35
+ percentUsersBornInDataset: 35,
36
+
37
+ hasAvatar: true,
38
+ makeChart: false,
39
+
40
+ batchSize: 1_500_000,
41
+ concurrency: 1,
42
+ writeToDisk: false,
43
+ funnels: [
44
+ {
45
+ "sequence": ["app install", "character creation", "join party"],
46
+ "isFirstFunnel": true,
47
+ "conversionRate": 0.8,
48
+ "timeToConvert": .25,
49
+ },
50
+ {
51
+ "sequence": ["start quest", "gameplay summary", "complete quest"],
52
+ conversionRate: 0.99,
53
+ timeToConvert: 1,
54
+ props: {
55
+ "quest type": u.pickAWinner([
56
+ "Rescue",
57
+ "Retrieve",
58
+ "Explore",
59
+ "Destroy",
60
+ "Investigate",
61
+ ]),
62
+ "quest difficulty": u.pickAWinner([
63
+ "Easy",
64
+ "Medium",
65
+ "Hard",
66
+ "Legendary",
67
+ ]),
68
+ "quest location": u.pickAWinner([
69
+ "Forest",
70
+ "Dungeon",
71
+ "Mountain",
72
+ "City",
73
+ "Desert",
74
+ ])
75
+ }
76
+ },
77
+ ],
78
+ events: [
79
+ { event: "app install", weight: 10, isFirstEvent: true },
80
+ {
81
+ event: "character creation",
82
+ weight: 2,
83
+ properties: {
84
+ mode: u.pickAWinner(["fast", "slow", "template"]),
85
+ },
86
+ },
87
+ {
88
+ event: "join party",
89
+ weight: 8,
90
+ properties: {
91
+ "party size": u.weighNumRange(1, 6),
92
+ "party leader": u.pickAWinner([
93
+ "Bard",
94
+ "Cleric",
95
+ "Fighter",
96
+ "Rogue",
97
+ "Wizard",
98
+ "Paladin",
99
+ "Ranger",
100
+ "Sorcerer",
101
+ "Warlock",
102
+ ]),
103
+ },
104
+ },
105
+ {
106
+ event: "start quest",
107
+ weight: 12,
108
+ properties: {},
109
+ },
110
+ {
111
+ event: "complete quest",
112
+ weight: 12,
113
+ properties: {},
114
+ },
115
+ {
116
+ "event": "gameplay summary",
117
+ "weight": 14,
118
+ "properties": {
119
+ "# enemies defeated": u.weighNumRange(0, 100),
120
+ "# respawns": u.weighNumRange(0, 10, 5),
121
+ "# attacks": u.weighNumRange(0, 100, 6, 12),
122
+ "# gold found": u.weighNumRange(0, 1000),
123
+ }
124
+ },
125
+ {
126
+ "event": "in-game purchase",
127
+ "weight": 2,
128
+ "properties": {
129
+ "purchase type": u.pickAWinner([
130
+ "Gold",
131
+ "Gems",
132
+ "Items: Weapons",
133
+ "Items: Armor",
134
+ "Items: Potions",
135
+ "Items: Scrolls",
136
+ "Boosts",
137
+ "Currency",
138
+ ]),
139
+ "purchase amount": u.weighNumRange(1, 50, 1, 20),
140
+ }
141
+ },
142
+ {
143
+ event: "fight boss",
144
+ weight: 3,
145
+ properties: {
146
+ "boss type": u.pickAWinner([
147
+ "Dragon",
148
+ "Demon",
149
+ "Lich",
150
+ "Vampire",
151
+ "Beholder",
152
+ ]),
153
+ "boss level": u.weighNumRange(10, 20),
154
+ "boss difficulty": u.pickAWinner([
155
+ "Hard",
156
+ "Legendary",
157
+ "Impossible",
158
+ ]),
159
+ "fight duration (mins)": u.weighNumRange(1, 60),
160
+
161
+ },
162
+ },
163
+ {
164
+ event: "level up",
165
+ weight: 1,
166
+ properties: {
167
+ "new abilities": u.pickAWinner([
168
+ "Attack",
169
+ "Spell",
170
+ "Feat",
171
+ "Skill",
172
+ ]),
173
+ },
174
+ },
175
+ {
176
+ event: "generic event (common)",
177
+ weight: 5,
178
+ properties: {
179
+ generic_prop: u.pickAWinner(["foo", "bar", "baz", "qux"]),
180
+ }
181
+ },
182
+ {
183
+ event: "generic event (uncommon)",
184
+ weight: 3,
185
+ properties: {
186
+ generic_prop: u.pickAWinner(["foo", "bar", "baz", "qux"]),
187
+ }
188
+ },
189
+ ],
190
+ superProps: {
191
+ platform: u.pickAWinner([
192
+ "Mobile",
193
+ "Xbox",
194
+ "Playstation",
195
+ "Switch",
196
+ "Web"
197
+ ]),
198
+ "game mode": u.pickAWinner([
199
+ "Single Player",
200
+ "Multiplayer",
201
+ ], 1),
202
+ language: u.pickAWinner([
203
+ "English",
204
+ "Spanish",
205
+ "French",
206
+ "German",
207
+ "Japanese",
208
+ "Korean",
209
+ "Chinese",
210
+ ], 0),
211
+
212
+ },
213
+ scdProps: {
214
+ // "subscription MRR" : {
215
+ // "frequency": "week",
216
+ // "type": "number",
217
+ // values: u.weighNumRange(0, 250, 1, 200),
218
+ // timing: "fixed",
219
+ // max: 250,
220
+ // }
221
+ },
222
+ userProps: {
223
+ experiment: u.pickAWinner([
224
+ "fast leveling",
225
+ "tension economy",
226
+ "free trial",
227
+ ]),
228
+ variant: ["A", "B", "C", "Control"],
229
+
230
+ race: u.pickAWinner([
231
+ "Human",
232
+ "Elf",
233
+ "Dwarf",
234
+ "Halfling",
235
+ "Dragonborn",
236
+ "Gnome",
237
+ "Half-Elf",
238
+ "Half-Orc",
239
+ "Tiefling",
240
+ ]),
241
+ class: u.pickAWinner([
242
+ "Barbarian",
243
+ "Bard",
244
+ "Cleric",
245
+ "Druid",
246
+ "Fighter",
247
+ "Monk",
248
+ "Paladin",
249
+ "Ranger",
250
+ "Rogue",
251
+ "Sorcerer",
252
+ "Warlock",
253
+ "Wizard",
254
+ ]),
255
+ alignment: u.pickAWinner([
256
+ "Lawful Good",
257
+ "Neutral Good",
258
+ "Chaotic Good",
259
+ "Lawful Neutral",
260
+ "True Neutral",
261
+ "Chaotic Neutral",
262
+ "Lawful Evil",
263
+ "Neutral Evil",
264
+ "Chaotic Evil",
265
+ ]),
266
+ level: u.weighNumRange(1, 20),
267
+ background: u.pickAWinner([
268
+ "Acolyte",
269
+ "Charlatan",
270
+ "Criminal",
271
+ "Entertainer",
272
+ "Folk Hero",
273
+ "Guild Artisan",
274
+ "Hermit",
275
+ "Noble",
276
+ "Outlander",
277
+ "Sage",
278
+ "Sailor",
279
+ "Soldier",
280
+ "Urchin",
281
+ ]),
282
+ "subscription MRR": u.weighNumRange(0, 250, 1, 200)
283
+ },
284
+ hook: function (record, type, meta) {
285
+ // const NOW = dayjs();
286
+
287
+ if (type === "event") {
288
+ // const EVENT_TIME = dayjs(record.time);
289
+ }
290
+
291
+ if (type === "user") {
292
+
293
+ }
294
+
295
+ if (type === "funnel-post") {
296
+
297
+ }
298
+
299
+ if (type === "funnel-pre") {
300
+
301
+ }
302
+
303
+ if (type === "scd") {
304
+
305
+ }
306
+
307
+ if (type === "everything") {
308
+
309
+ }
310
+
311
+ return record;
312
+ }
313
+ };
314
+
315
+ export default config;
package/dungeons/media.js CHANGED
@@ -1,16 +1,16 @@
1
1
 
2
2
  const SEED = "my-seed";
3
- const dayjs = require("dayjs");
4
- const utc = require("dayjs/plugin/utc");
3
+ import dayjs from 'dayjs';
4
+ import utc from 'dayjs/plugin/utc';
5
5
  dayjs.extend(utc);
6
- require("dotenv").config();
7
- const u = require("../components/utils");
8
- const v = require("ak-tools");
6
+ import 'dotenv/config';
7
+ import * as u from '../lib/utils/utils.js';
8
+ import * as v from 'ak-tools';
9
9
  const chance = u.initChance(SEED);
10
10
  const num_users = 10_000;
11
11
  const days = 125;
12
12
 
13
- /** @typedef {import("../types").Dungeon} Config */
13
+ /** @typedef {import("../types.js").Dungeon} Config */
14
14
 
15
15
  function genIds(numIds = 1000) {
16
16
  const ids = [];
@@ -368,4 +368,4 @@ const config = {
368
368
  }
369
369
  };
370
370
 
371
- module.exports = config;
371
+ export default config;
@@ -0,0 +1,129 @@
1
+ /**
2
+ * This is the default configuration file for the data generator in SIMPLE mode
3
+ * notice how the config object is structured, and see it's type definition in ./types.d.ts
4
+ * feel free to modify this file to customize the data you generate
5
+ * see helper functions in utils.js for more ways to generate data
6
+ */
7
+
8
+
9
+
10
+
11
+ import Chance from 'chance';
12
+ const chance = new Chance();
13
+ import dayjs from "dayjs";
14
+ import utc from "dayjs/plugin/utc.js";
15
+ dayjs.extend(utc);
16
+ import { uid, comma } from 'ak-tools';
17
+ import { pickAWinner, weighNumRange, date, integer } from '../lib/utils/utils.js';
18
+
19
+
20
+ /** @type {import('../types').Dungeon} */
21
+ const config = {
22
+ token: "",
23
+ seed: "mirror me",
24
+ numDays: 30, //how many days worth of data
25
+ numEvents: 10000, //how many events
26
+ numUsers: 1000, //how many users
27
+ format: 'json', //csv or json
28
+ region: "US",
29
+ hasAnonIds: true, //if true, anonymousIds are created for each user
30
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
31
+
32
+ events: [
33
+ {
34
+ event: "foo",
35
+ weight: 10,
36
+ properties: {}
37
+ },
38
+ {
39
+ event: "bar",
40
+ weight: 9,
41
+ properties: {}
42
+ },
43
+ {
44
+ event: "baz",
45
+ weight: 8,
46
+ properties: {}
47
+ },
48
+ {
49
+ event: "qux",
50
+ weight: 7,
51
+ properties: {}
52
+ },
53
+ {
54
+ event: "garply",
55
+ weight: 6,
56
+ properties: {}
57
+ },
58
+ {
59
+ event: "durtle",
60
+ weight: 5,
61
+ properties: {}
62
+ },
63
+ {
64
+ event: "linny",
65
+ weight: 4,
66
+ properties: {}
67
+ },
68
+ {
69
+ event: "fonk",
70
+ weight: 3,
71
+ properties: {}
72
+ },
73
+ {
74
+ event: "crumn",
75
+ weight: 2,
76
+ properties: {}
77
+ },
78
+ {
79
+ event: "yak",
80
+ weight: 1,
81
+ properties: {}
82
+ }
83
+ ],
84
+ superProps: {
85
+ color: ["red", "orange", "yellow", "green", "blue", "indigo", "violet"],
86
+ deleteMe: ["hello", "world", "i", "should", "be", "deleted"],
87
+ updateMe: weighNumRange(1, 10)
88
+ },
89
+ userProps: {
90
+ title: chance.profession.bind(chance),
91
+ luckyNumber: weighNumRange(42, 420),
92
+ spiritAnimal: ["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"]
93
+ },
94
+
95
+ scdProps: {},
96
+ mirrorProps: {
97
+ "newlyCreated": {
98
+ events: "*",
99
+ strategy: "create",
100
+ values: ["fickle", "buckle", "tickle", "mackle"]
101
+
102
+ },
103
+ "deleteMe": {
104
+ events: "*",
105
+ strategy: "delete",
106
+ values: ["ignored"]
107
+ },
108
+ "fillMe": {
109
+ events: "*",
110
+ strategy: "fill",
111
+ values: ["deal", "with", "it"]
112
+ },
113
+ "updateMe": {
114
+ events: "*",
115
+ strategy: "update",
116
+ values: weighNumRange(11, 20)
117
+ },
118
+ },
119
+ groupKeys: [],
120
+ groupProps: {},
121
+ lookupTables: [],
122
+ hook: function (record, type, meta) {
123
+ return record;
124
+ }
125
+ };
126
+
127
+
128
+
129
+ export default config;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * This is the default configuration file for the data generator in SIMPLE mode
3
+ * notice how the config object is structured, and see it's type definition in ./types.d.ts
4
+ * feel free to modify this file to customize the data you generate
5
+ * see helper functions in utils.js for more ways to generate data
6
+ */
7
+
8
+
9
+
10
+
11
+ import Chance from 'chance';
12
+ const chance = new Chance();
13
+ import dayjs from 'dayjs';
14
+ import utc from 'dayjs/plugin/utc.js';
15
+ dayjs.extend(utc);
16
+ import { weighNumRange, integer } from '../lib/utils/utils.js';
17
+
18
+
19
+ /** @type {import('../types.js').Dungeon} */
20
+ const config = {
21
+ token: "",
22
+ seed: "foo bar",
23
+ numDays: 90, //how many days worth of data
24
+ numEvents: 50_000, //how many events
25
+ numUsers: 500, //how many users
26
+ format: 'json', //csv or json
27
+ region: "US",
28
+ hasAnonIds: false, //if true, anonymousIds are created for each user
29
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
30
+ alsoInferFunnels: true, //if true, infer funnels from events
31
+ makeChart: true,
32
+ writeToDisk: true,
33
+ concurrency: 25,
34
+ funnels: [
35
+ {
36
+ sequence: ["qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
37
+ },
38
+ {
39
+ sequence: ["foo", "bar", "baz"],
40
+ isFirstFunnel: true,
41
+ }
42
+ ],
43
+ events: [
44
+ {
45
+ event: "foo",
46
+ weight: 10,
47
+ properties: {}
48
+ },
49
+ {
50
+ event: "bar",
51
+ weight: 9,
52
+ isFirstEvent: true,
53
+ properties: {}
54
+ },
55
+ {
56
+ event: "baz",
57
+ weight: 8,
58
+ properties: {}
59
+ },
60
+ {
61
+ event: "qux",
62
+ weight: 7,
63
+ properties: {}
64
+ },
65
+ {
66
+ event: "garply",
67
+ weight: 6,
68
+ properties: {}
69
+ },
70
+ {
71
+ event: "durtle",
72
+ weight: 5,
73
+ properties: {}
74
+ },
75
+ {
76
+ event: "linny",
77
+ weight: 4,
78
+ properties: {}
79
+ },
80
+ {
81
+ event: "fonk",
82
+ weight: 3,
83
+ properties: {}
84
+ },
85
+ {
86
+ event: "crumn",
87
+ weight: 2,
88
+ properties: {}
89
+ },
90
+ {
91
+ event: "yak",
92
+ weight: 1,
93
+ properties: {}
94
+ }
95
+ ],
96
+ superProps: {
97
+ color: ["red", "orange", "yellow", "green", "blue", "indigo", "violet"],
98
+ number: integer,
99
+
100
+ },
101
+ userProps: {
102
+ title: chance.profession.bind(chance),
103
+ luckyNumber: weighNumRange(42, 420),
104
+ spiritAnimal: ["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"]
105
+ },
106
+ hook: function (record, type, meta) {
107
+ return record;
108
+ }
109
+ };
110
+
111
+
112
+
113
+ export default config;