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,96 @@
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
+ /** @type {import('../types').Dungeon} */
20
+ const config = {
21
+ token: "",
22
+ seed: "foo bar",
23
+ numDays: 365, //how many days worth of data
24
+ numEvents: 10000000, //how many events
25
+ numUsers: 25000, //how many users
26
+ format: 'json', //csv or json
27
+ region: "US",
28
+ hasAnonIds: true, //if true, anonymousIds are created for each user
29
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
30
+ hasAdSpend: true,
31
+ events: [
32
+ {
33
+ event: "foo",
34
+ weight: 10,
35
+ },
36
+ {
37
+ event: "bar",
38
+ weight: 9,
39
+ },
40
+ {
41
+ event: "baz",
42
+ weight: 8,
43
+ },
44
+ {
45
+ event: "qux",
46
+ weight: 7,
47
+ },
48
+ {
49
+ event: "garply",
50
+ weight: 6,
51
+ },
52
+ {
53
+ event: "durtle",
54
+ weight: 5,
55
+ },
56
+ {
57
+ event: "linny",
58
+ weight: 4,
59
+ },
60
+ {
61
+ event: "fonk",
62
+ weight: 3,
63
+ },
64
+ {
65
+ event: "crumn",
66
+ weight: 2,
67
+ },
68
+ {
69
+ event: "yak",
70
+ weight: 1,
71
+ }
72
+ ],
73
+ superProps: {
74
+ color: ["red", "orange", "yellow", "green", "blue", "indigo", "violet"],
75
+ number: integer,
76
+
77
+ },
78
+ userProps: {
79
+ title: chance.profession.bind(chance),
80
+ luckyNumber: weighNumRange(42, 420),
81
+ 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"]
82
+ },
83
+
84
+ scdProps: {},
85
+ mirrorProps: {},
86
+ groupKeys: [],
87
+ groupProps: {},
88
+ lookupTables: [],
89
+ hook: function (record, type, meta) {
90
+ return record;
91
+ }
92
+ };
93
+
94
+
95
+
96
+ export default config;
@@ -0,0 +1,104 @@
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
+
21
+ /** @type {import('../types').Dungeon} */
22
+ const config = {
23
+ token: "",
24
+ seed: "foo bar",
25
+ numDays: 365, //how many days worth of data
26
+ numEvents: 100000, //how many events
27
+ numUsers: 10000, //how many users
28
+ format: 'json', //csv or json
29
+ region: "US",
30
+ hasAnonIds: true, //if true, anonymousIds are created for each user
31
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
32
+ isAnonymous: true,
33
+ hasLocation: true,
34
+ events: [
35
+ {
36
+ event: "foo",
37
+ weight: 10,
38
+ properties: {}
39
+ },
40
+ {
41
+ event: "bar",
42
+ weight: 9,
43
+ properties: {}
44
+ },
45
+ {
46
+ event: "baz",
47
+ weight: 8,
48
+ properties: {}
49
+ },
50
+ {
51
+ event: "qux",
52
+ weight: 7,
53
+ properties: {}
54
+ },
55
+ {
56
+ event: "garply",
57
+ weight: 6,
58
+ properties: {}
59
+ },
60
+ {
61
+ event: "durtle",
62
+ weight: 5,
63
+ properties: {}
64
+ },
65
+ {
66
+ event: "linny",
67
+ weight: 4,
68
+ properties: {}
69
+ },
70
+ {
71
+ event: "fonk",
72
+ weight: 3,
73
+ properties: {}
74
+ },
75
+ {
76
+ event: "crumn",
77
+ weight: 2,
78
+ properties: {}
79
+ },
80
+ {
81
+ event: "yak",
82
+ weight: 1,
83
+ properties: {}
84
+ }
85
+ ],
86
+ superProps: {},
87
+ userProps: {
88
+ title: chance.profession.bind(chance),
89
+ luckyNumber: weighNumRange(42, 420),
90
+ 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"]
91
+ },
92
+ scdProps: {},
93
+ mirrorProps: {},
94
+ groupKeys: [],
95
+ groupProps: {},
96
+ lookupTables: [],
97
+ hook: function (record, type, meta) {
98
+ return record;
99
+ }
100
+ };
101
+
102
+
103
+
104
+ export default config;
@@ -0,0 +1,225 @@
1
+ import Chance from 'chance';
2
+ import dayjs from 'dayjs';
3
+ import utc from 'dayjs/plugin/utc';
4
+ import { uid, comma, makeName } from 'ak-tools';
5
+ import { pickAWinner, weighNumRange, integer, date, choose } from '../lib/utils/utils.js';
6
+
7
+ const seed = "lets go big";
8
+ const chance = new Chance();
9
+ dayjs.extend(utc);
10
+
11
+
12
+ const eventsPerQuarter = 5_000_000_000 // ~5 billion
13
+ const numQuarters = 8; // 24 months
14
+ const parallelism = 5000;
15
+ const totalEvents = Math.floor((eventsPerQuarter * numQuarters) / parallelism);
16
+ const eventPerUser = 500;
17
+ const totalUsers = Math.floor(totalEvents / eventPerUser);
18
+ const totalDays = (numQuarters * 90) + 10;
19
+
20
+ /** @type {import('../types').Dungeon} */
21
+ const config = {
22
+ token: "",
23
+ seed: seed,
24
+ numDays: totalDays,
25
+ numEvents: totalEvents,
26
+ numUsers: totalUsers,
27
+ format: 'json', //csv or json
28
+ region: "US",
29
+ hasAnonIds: false, //if true, anonymousIds are created for each user
30
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
31
+ hasLocation: true,
32
+ hasAndroidDevices: false,
33
+ alsoInferFunnels: false,
34
+ batchSize: 2_000_000,
35
+ hasAvatar: false,
36
+ hasAdSpend: false,
37
+ hasBrowser: false,
38
+ hasCampaigns: false,
39
+ hasDesktopDevices: false,
40
+ hasIOSDevices: false,
41
+ writeToDisk: "gs://dungeon_master_4/big_data",
42
+ funnels: [
43
+ {
44
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
45
+ weight: 1,
46
+ order: "sequential"
47
+ },
48
+ {
49
+ "sequence": ["foo", "bar"],
50
+ weight: 25,
51
+ order: "sequential"
52
+ },
53
+ {
54
+ "sequence": ["foo", "bar", "baz"],
55
+ weight: 20,
56
+ order: "sequential"
57
+ },
58
+ {
59
+ "sequence": ["foo", "bar", "baz", "qux"],
60
+ weight: 15,
61
+ order: "sequential"
62
+ },
63
+ {
64
+ "sequence": ["foo", "bar", "baz", "qux", "garply"],
65
+ weight: 10,
66
+ order: "sequential"
67
+ },
68
+ {
69
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle"],
70
+ weight: 8,
71
+ order: "sequential"
72
+ },
73
+ {
74
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny"],
75
+ weight: 6,
76
+ order: "sequential"
77
+ },
78
+ {
79
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk"],
80
+ weight: 4,
81
+ order: "sequential"
82
+ },
83
+ {
84
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn"],
85
+ weight: 2,
86
+ order: "sequential"
87
+ },
88
+ {
89
+ "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
90
+ weight: 1,
91
+ order: "sequential"
92
+ }
93
+
94
+ ],
95
+ events: [
96
+ { event: "foo" },
97
+ { event: "bar" },
98
+ { event: "baz" },
99
+ { event: "qux" },
100
+ { event: "garply" },
101
+ { event: "durtle" },
102
+ { event: "linny" },
103
+ { event: "fonk" },
104
+ { event: "crumn" },
105
+ { event: "yak" }
106
+ ],
107
+ //? https://docs.mixpanel.com/docs/data-structure/property-reference/data-type
108
+ superProps: {
109
+ "string": pickAWinner(["red", "orange", "yellow", "green", "blue", "indigo", "violet"]),
110
+ "number": integer,
111
+ "boolean": [true, true, false],
112
+ "date": () => date(90),
113
+ "string []": buildStringArray,
114
+ "number []": buildNumberArray,
115
+ "object {}": buildObjectProp,
116
+ "object [{}]": buildObjArrayProp
117
+ },
118
+ userProps: {
119
+ title: chance.profession.bind(chance),
120
+ luckyNumber: weighNumRange(42, 420),
121
+ spiritAnimal: pickAWinner(["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"]),
122
+ isHappyCustomer: pickAWinner([true, true, false]),
123
+ },
124
+ hook: function (record, type, meta) {
125
+
126
+
127
+ // if (type === "event") {
128
+ // debugger;
129
+ // }
130
+
131
+ // if (type === "user") {
132
+
133
+ // }
134
+
135
+ // if (type === "funnel-post") {
136
+
137
+ // }
138
+
139
+ // if (type === "funnel-pre") {
140
+
141
+ // }
142
+
143
+ // if (type === "scd") {
144
+
145
+ // }
146
+
147
+ // if (type === "everything") {
148
+ // debugger;
149
+ // }
150
+
151
+ return record;
152
+ }
153
+ };
154
+
155
+
156
+ function buildObjectProp() {
157
+ return function () {
158
+ return {
159
+ "foo key": choose(pickAWinner(["red", "orange", "yellow", "green", "blue", "indigo", "violet"])()),
160
+ "bar key": integer(1, 100),
161
+ "baz key": choose(pickAWinner([true, true, false])()),
162
+ };
163
+ };
164
+ }
165
+
166
+
167
+ function buildNumberArray() {
168
+ return function () {
169
+ const arr = [];
170
+ const times = integer(1, 10);
171
+ for (let i = 0; i < times; i++) {
172
+ arr.push(integer(1, 100));
173
+ }
174
+ return [arr];
175
+ };
176
+ }
177
+
178
+ function buildStringArray() {
179
+ return function () {
180
+ const arr = [];
181
+ const times = integer(1, 10);
182
+ for (let i = 0; i < times; i++) {
183
+ arr.push(makeName(integer(1, 3), " "));
184
+ }
185
+ return [arr];
186
+ };
187
+ }
188
+
189
+
190
+ function buildObjArrayProp(maxItems = 5) {
191
+
192
+ return function () {
193
+ const categories = ["Device Accessories", "eBooks", "Automotive", "Baby Products", "Beauty", "Books", "Camera & Photo", "Cell Phones & Accessories", "Collectible Coins", "Consumer Electronics", "Entertainment Collectibles", "Fine Art", "Grocery & Gourmet Food", "Health & Personal Care", "Home & Garden", "Independent Design", "Industrial & Scientific", "Accessories", "Major Appliances", "Music", "Musical Instruments", "Office Products", "Outdoors", "Personal Computers", "Pet Supplies", "Software", "Sports", "Sports Collectibles", "Tools & Home Improvement", "Toys & Games", "Video, DVD & Blu-ray", "Video Games", "Watches"];
194
+ const slugs = ['/sale/', '/featured/', '/home/', '/search/', '/wishlist/', '/'];
195
+ const assetExtension = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
196
+ const data = [];
197
+ const numOfItems = integer(1, maxItems);
198
+
199
+ for (var i = 0; i < numOfItems; i++) {
200
+ const category = chance.pickone(categories);
201
+ const slug = chance.pickone(slugs);
202
+ const asset = chance.pickone(assetExtension);
203
+ const price = integer(1, 300);
204
+ const quantity = integer(1, 5);
205
+
206
+ const item = {
207
+ sku: integer(11111, 99999),
208
+ amount: price,
209
+ quantity: quantity,
210
+ total: price * quantity,
211
+ featured: chance.pickone([true, false]),
212
+ category: category,
213
+ urlSlug: slug + category,
214
+ asset: `${category}-${integer(1, 20)}${asset}`
215
+ };
216
+
217
+ data.push(item);
218
+ }
219
+
220
+ return () => [data];
221
+ };
222
+ };
223
+
224
+
225
+ export default config;