make-mp-data 1.5.55 → 2.0.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.
Files changed (56) hide show
  1. package/.claude/settings.local.json +20 -0
  2. package/.gcloudignore +2 -1
  3. package/.vscode/launch.json +6 -3
  4. package/.vscode/settings.json +31 -2
  5. package/dungeons/media.js +371 -0
  6. package/index.js +354 -1757
  7. package/{components → lib/cli}/cli.js +21 -6
  8. package/lib/cloud-function.js +20 -0
  9. package/lib/core/config-validator.js +248 -0
  10. package/lib/core/context.js +180 -0
  11. package/lib/core/storage.js +268 -0
  12. package/{components → lib/data}/defaults.js +17 -14
  13. package/lib/generators/adspend.js +133 -0
  14. package/lib/generators/events.js +242 -0
  15. package/lib/generators/funnels.js +330 -0
  16. package/lib/generators/mirror.js +168 -0
  17. package/lib/generators/profiles.js +93 -0
  18. package/lib/generators/scd.js +102 -0
  19. package/lib/orchestrators/mixpanel-sender.js +222 -0
  20. package/lib/orchestrators/user-loop.js +194 -0
  21. package/lib/orchestrators/worker-manager.js +200 -0
  22. package/{components → lib/utils}/ai.js +8 -36
  23. package/{components → lib/utils}/chart.js +9 -9
  24. package/{components → lib/utils}/project.js +4 -4
  25. package/{components → lib/utils}/utils.js +35 -23
  26. package/package.json +19 -12
  27. package/scripts/dana.mjs +137 -0
  28. package/scripts/new-dungeon.sh +7 -6
  29. package/scripts/update-deps.sh +2 -1
  30. package/tests/cli.test.js +28 -25
  31. package/tests/e2e.test.js +38 -36
  32. package/tests/int.test.js +151 -56
  33. package/tests/testSoup.mjs +1 -1
  34. package/tests/unit.test.js +15 -14
  35. package/tsconfig.json +1 -1
  36. package/types.d.ts +76 -18
  37. package/vitest.config.js +47 -0
  38. package/dungeons/adspend.js +0 -96
  39. package/dungeons/anon.js +0 -104
  40. package/dungeons/big.js +0 -224
  41. package/dungeons/business.js +0 -327
  42. package/dungeons/complex.js +0 -396
  43. package/dungeons/foobar.js +0 -241
  44. package/dungeons/funnels.js +0 -220
  45. package/dungeons/gaming-experiments.js +0 -323
  46. package/dungeons/gaming.js +0 -314
  47. package/dungeons/governance.js +0 -288
  48. package/dungeons/mirror.js +0 -129
  49. package/dungeons/sanity.js +0 -118
  50. package/dungeons/scd.js +0 -205
  51. package/dungeons/session-replay.js +0 -175
  52. package/dungeons/simple.js +0 -150
  53. package/dungeons/userAgent.js +0 -190
  54. package/log.json +0 -1067
  55. package/tests/jest.config.js +0 -47
  56. /package/{components → lib/utils}/prompt.txt +0 -0
@@ -0,0 +1,47 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ const isDebugMode = process.env.NODE_OPTIONS?.includes('--inspect') || process.env.NODE_OPTIONS?.includes('--inspect-brk');
4
+
5
+ export default defineConfig({
6
+ test: {
7
+ // Global test settings
8
+ globals: true,
9
+ environment: 'node',
10
+
11
+ // Test file patterns
12
+ include: ['tests/**/*.test.js'],
13
+
14
+ // Coverage settings
15
+ coverage: {
16
+ provider: 'v8',
17
+ reporter: ['text', 'json', 'html'],
18
+ reportsDirectory: './coverage'
19
+ },
20
+
21
+ // Test execution settings
22
+ testTimeout: 60000, // one min
23
+ hookTimeout: 30000,
24
+ teardownTimeout: 10000,
25
+
26
+ // Thread pool settings
27
+ pool: 'threads',
28
+ poolOptions: {
29
+ threads: {
30
+ maxThreads: 4,
31
+ minThreads: 1
32
+ }
33
+ },
34
+
35
+ // Reporter settings
36
+ reporters: isDebugMode ? 'verbose' : 'default',
37
+
38
+ // Don't watch in CI/test environments
39
+ watch: false,
40
+
41
+ // Allow mixed concurrent/sequential execution
42
+ // CLI tests use describe.sequential() due to execSync collisions
43
+ sequence: {
44
+ concurrent: true
45
+ }
46
+ }
47
+ });
@@ -1,96 +0,0 @@
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
- const Chance = require('chance');
12
- const chance = new Chance();
13
- const dayjs = require("dayjs");
14
- const utc = require("dayjs/plugin/utc");
15
- dayjs.extend(utc);
16
- const { uid, comma } = require('ak-tools');
17
- const { pickAWinner, weighNumRange, date, integer } = require('../components/utils');
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
- module.exports = config;
package/dungeons/anon.js DELETED
@@ -1,104 +0,0 @@
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
- const Chance = require('chance');
12
- const chance = new Chance();
13
- const dayjs = require("dayjs");
14
- const utc = require("dayjs/plugin/utc");
15
- dayjs.extend(utc);
16
- const { uid, comma } = require('ak-tools');
17
- const { pickAWinner, weighNumRange, date, integer } = require('../components/utils');
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
- module.exports = config;
package/dungeons/big.js DELETED
@@ -1,224 +0,0 @@
1
- const seed = "lets go big";
2
- const Chance = require('chance');
3
- const chance = new Chance();
4
- const dayjs = require("dayjs");
5
- const utc = require("dayjs/plugin/utc");
6
- dayjs.extend(utc);
7
- const { uid, comma, makeName } = require('ak-tools');
8
- const { pickAWinner, weighNumRange, integer, date, choose } = require('../components/utils');
9
-
10
-
11
- const eventsPerQuarter = 5_000_000_000 // ~5 billion
12
- const numQuarters = 8; // 24 months
13
- const parallelism = 5000;
14
- const totalEvents = Math.floor((eventsPerQuarter * numQuarters) / parallelism);
15
- const eventPerUser = 500;
16
- const totalUsers = Math.floor(totalEvents / eventPerUser);
17
- const totalDays = (numQuarters * 90) + 10;
18
-
19
- /** @type {import('../types').Dungeon} */
20
- const config = {
21
- token: "",
22
- seed: seed,
23
- numDays: totalDays,
24
- numEvents: totalEvents,
25
- numUsers: totalUsers,
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
- hasLocation: true,
31
- hasAndroidDevices: false,
32
- alsoInferFunnels: false,
33
- batchSize: 2_000_000,
34
- hasAvatar: false,
35
- hasAdSpend: false,
36
- hasBrowser: false,
37
- hasCampaigns: false,
38
- hasDesktopDevices: false,
39
- hasIOSDevices: false,
40
- writeToDisk: "gs://dungeon_master_4/big_data",
41
- funnels: [
42
- {
43
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
44
- weight: 1,
45
- order: "sequential"
46
- },
47
- {
48
- "sequence": ["foo", "bar"],
49
- weight: 25,
50
- order: "sequential"
51
- },
52
- {
53
- "sequence": ["foo", "bar", "baz"],
54
- weight: 20,
55
- order: "sequential"
56
- },
57
- {
58
- "sequence": ["foo", "bar", "baz", "qux"],
59
- weight: 15,
60
- order: "sequential"
61
- },
62
- {
63
- "sequence": ["foo", "bar", "baz", "qux", "garply"],
64
- weight: 10,
65
- order: "sequential"
66
- },
67
- {
68
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle"],
69
- weight: 8,
70
- order: "sequential"
71
- },
72
- {
73
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny"],
74
- weight: 6,
75
- order: "sequential"
76
- },
77
- {
78
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk"],
79
- weight: 4,
80
- order: "sequential"
81
- },
82
- {
83
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn"],
84
- weight: 2,
85
- order: "sequential"
86
- },
87
- {
88
- "sequence": ["foo", "bar", "baz", "qux", "garply", "durtle", "linny", "fonk", "crumn", "yak"],
89
- weight: 1,
90
- order: "sequential"
91
- }
92
-
93
- ],
94
- events: [
95
- { event: "foo" },
96
- { event: "bar" },
97
- { event: "baz" },
98
- { event: "qux" },
99
- { event: "garply" },
100
- { event: "durtle" },
101
- { event: "linny" },
102
- { event: "fonk" },
103
- { event: "crumn" },
104
- { event: "yak" }
105
- ],
106
- //? https://docs.mixpanel.com/docs/data-structure/property-reference/data-type
107
- superProps: {
108
- "string": pickAWinner(["red", "orange", "yellow", "green", "blue", "indigo", "violet"]),
109
- "number": integer,
110
- "boolean": [true, true, false],
111
- "date": () => date(90),
112
- "string []": buildStringArray,
113
- "number []": buildNumberArray,
114
- "object {}": buildObjectProp,
115
- "object [{}]": buildObjArrayProp
116
- },
117
- userProps: {
118
- title: chance.profession.bind(chance),
119
- luckyNumber: weighNumRange(42, 420),
120
- 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"]),
121
- isHappyCustomer: pickAWinner([true, true, false]),
122
- },
123
- hook: function (record, type, meta) {
124
-
125
-
126
- // if (type === "event") {
127
- // debugger;
128
- // }
129
-
130
- // if (type === "user") {
131
-
132
- // }
133
-
134
- // if (type === "funnel-post") {
135
-
136
- // }
137
-
138
- // if (type === "funnel-pre") {
139
-
140
- // }
141
-
142
- // if (type === "scd") {
143
-
144
- // }
145
-
146
- // if (type === "everything") {
147
- // debugger;
148
- // }
149
-
150
- return record;
151
- }
152
- };
153
-
154
-
155
- function buildObjectProp() {
156
- return function () {
157
- return {
158
- "foo key": choose(pickAWinner(["red", "orange", "yellow", "green", "blue", "indigo", "violet"])()),
159
- "bar key": integer(1, 100),
160
- "baz key": choose(pickAWinner([true, true, false])()),
161
- };
162
- };
163
- }
164
-
165
-
166
- function buildNumberArray() {
167
- return function () {
168
- const arr = [];
169
- const times = integer(1, 10);
170
- for (let i = 0; i < times; i++) {
171
- arr.push(integer(1, 100));
172
- }
173
- return [arr];
174
- };
175
- }
176
-
177
- function buildStringArray() {
178
- return function () {
179
- const arr = [];
180
- const times = integer(1, 10);
181
- for (let i = 0; i < times; i++) {
182
- arr.push(makeName(integer(1, 3), " "));
183
- }
184
- return [arr];
185
- };
186
- }
187
-
188
-
189
- function buildObjArrayProp(maxItems = 5) {
190
-
191
- return function () {
192
- 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"];
193
- const slugs = ['/sale/', '/featured/', '/home/', '/search/', '/wishlist/', '/'];
194
- const assetExtension = ['.png', '.jpg', '.jpeg', '.heic', '.mp4', '.mov', '.avi'];
195
- const data = [];
196
- const numOfItems = integer(1, maxItems);
197
-
198
- for (var i = 0; i < numOfItems; i++) {
199
- const category = chance.pickone(categories);
200
- const slug = chance.pickone(slugs);
201
- const asset = chance.pickone(assetExtension);
202
- const price = integer(1, 300);
203
- const quantity = integer(1, 5);
204
-
205
- const item = {
206
- sku: integer(11111, 99999),
207
- amount: price,
208
- quantity: quantity,
209
- total: price * quantity,
210
- featured: chance.pickone([true, false]),
211
- category: category,
212
- urlSlug: slug + category,
213
- asset: `${category}-${integer(1, 20)}${asset}`
214
- };
215
-
216
- data.push(item);
217
- }
218
-
219
- return () => [data];
220
- };
221
- };
222
-
223
-
224
- module.exports = config;