@ak--47/dungeon-master 1.1.0 → 1.2.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 (67) hide show
  1. package/dungeons/technical/ad-spend-schema.json +2 -2
  2. package/dungeons/technical/ad-spend.js +1 -1
  3. package/dungeons/technical/anonymous-users-schema.json +4 -3
  4. package/dungeons/technical/anonymous-users.js +1 -1
  5. package/dungeons/technical/array-of-object-lookup-schema.json +1 -1
  6. package/dungeons/technical/array-of-object-lookup.js +1 -1
  7. package/dungeons/technical/experiments-schema.json +25 -19
  8. package/dungeons/technical/experiments.js +1 -1
  9. package/dungeons/technical/foobar.js +1 -1
  10. package/dungeons/technical/group-analytics-schema.json +92 -0
  11. package/dungeons/technical/group-analytics.js +1 -1
  12. package/dungeons/technical/mirror-strategies-schema.json +4 -4
  13. package/dungeons/technical/mirror-strategies.js +1 -1
  14. package/dungeons/technical/nested-objects.js +1 -1
  15. package/dungeons/technical/retention-cadence.js +1 -2
  16. package/dungeons/technical/sanity-schema.json +22 -22
  17. package/dungeons/technical/sanity.js +1 -0
  18. package/dungeons/technical/scale-test.js +1 -1
  19. package/dungeons/technical/scd-schema.json +230 -33
  20. package/dungeons/technical/scd.js +1 -0
  21. package/dungeons/technical/simple-schema.json +132 -48
  22. package/dungeons/technical/simple.js +1 -1
  23. package/dungeons/technical/simplest-schema.json +168 -79
  24. package/dungeons/technical/simplest.js +1 -1
  25. package/dungeons/technical/text-generation-schema.json +7 -4
  26. package/dungeons/technical/text-generation.js +1 -2
  27. package/dungeons/vertical/community-schema.json +71 -49
  28. package/dungeons/vertical/community.js +8 -2
  29. package/dungeons/vertical/devtools-schema.json +69 -48
  30. package/dungeons/vertical/devtools.js +8 -2
  31. package/dungeons/vertical/ecommerce-schema.json +126 -108
  32. package/dungeons/vertical/ecommerce.js +9 -2
  33. package/dungeons/vertical/education-schema.json +5261 -272
  34. package/dungeons/vertical/education.js +16 -3
  35. package/dungeons/vertical/fintech-schema.json +165 -98
  36. package/dungeons/vertical/fintech.js +16 -3
  37. package/dungeons/vertical/fitness-schema.json +69 -47
  38. package/dungeons/vertical/fitness.js +8 -2
  39. package/dungeons/vertical/food-delivery-schema.json +36237 -187
  40. package/dungeons/vertical/food-delivery.js +16 -3
  41. package/dungeons/vertical/gaming-schema.json +103 -59
  42. package/dungeons/vertical/gaming.js +20 -9
  43. package/dungeons/vertical/healthcare-schema.json +70 -48
  44. package/dungeons/vertical/healthcare.js +8 -2
  45. package/dungeons/vertical/insurance-application-schema.json +66 -47
  46. package/dungeons/vertical/insurance-application.js +8 -2
  47. package/dungeons/vertical/logistics-schema.json +60 -38
  48. package/dungeons/vertical/logistics.js +8 -2
  49. package/dungeons/vertical/marketplace-schema.json +65 -43
  50. package/dungeons/vertical/marketplace.js +8 -2
  51. package/dungeons/vertical/media-schema.json +4085 -123
  52. package/dungeons/vertical/media.js +9 -3
  53. package/dungeons/vertical/rpg-schema.json +1984 -147
  54. package/dungeons/vertical/rpg.js +9 -3
  55. package/dungeons/vertical/sass-schema.json +2622 -147
  56. package/dungeons/vertical/sass.js +16 -3
  57. package/dungeons/vertical/social-schema.json +146 -78
  58. package/dungeons/vertical/social.js +16 -3
  59. package/dungeons/vertical/travel-schema.json +57 -35
  60. package/dungeons/vertical/travel.js +8 -2
  61. package/index.js +1 -1
  62. package/lib/core/context.js +9 -0
  63. package/lib/core/storage.js +2 -0
  64. package/lib/orchestrators/user-loop.js +4 -1
  65. package/package.json +1 -1
  66. package/scripts/extract-dungeon-schema.mjs +64 -18
  67. package/types.d.ts +3 -0
@@ -1,16 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Extracts an abbreviated schema from a JavaScript dungeon file.
4
+ * Extracts a complete schema from a JavaScript dungeon file.
5
5
  *
6
- * Output contains only the event/property relationships, superProps, userProps,
7
- * and funnels no hooks, no config flags, no functions.
6
+ * Output contains everything about the dungeon EXCEPT:
7
+ * - hook function (runtime logic, not schema)
8
+ * - credentials (token, serviceAccount, serviceSecret, projectId)
9
+ * - execution params (seed, format, gzip, verbose, concurrency, batchSize, writeToDisk, region)
8
10
  *
9
11
  * Property values are simplified:
10
12
  * - Plain arrays → deduplicated
11
13
  * - weighNumRange(min,max) arrays → { "$range": [min, max] }
12
14
  * - Functions (pickAWinner, weighChoices, etc.) → sampled and deduplicated
13
- * - High-cardinality / complex values → omitted
15
+ * - High-cardinality / complex values → type hint
14
16
  *
15
17
  * Usage:
16
18
  * node scripts/extract-dungeon-schema.mjs <input.js> [output.json]
@@ -61,12 +63,16 @@ async function processOne(inputFile, outputFile) {
61
63
 
62
64
  const schema = {};
63
65
 
64
- // Events
66
+ // ── Events ──────────────────────────────────────────────────────
65
67
  if (config.events?.length) {
66
68
  schema.events = config.events.map(evt => {
67
69
  const entry = { event: evt.event };
68
70
  if (evt.weight && evt.weight !== 1) entry.weight = evt.weight;
69
71
  if (evt.isFirstEvent) entry.isFirstEvent = true;
72
+ if (evt.isChurnEvent) entry.isChurnEvent = true;
73
+ if (evt.returnLikelihood !== undefined) entry.returnLikelihood = evt.returnLikelihood;
74
+ if (evt.isStrictEvent) entry.isStrictEvent = true;
75
+ if (evt.isSessionStartEvent) entry.isSessionStartEvent = true;
70
76
  if (evt.properties && Object.keys(evt.properties).length) {
71
77
  const props = extractProps(evt.properties);
72
78
  if (Object.keys(props).length) entry.properties = props;
@@ -75,22 +81,11 @@ async function processOne(inputFile, outputFile) {
75
81
  });
76
82
  }
77
83
 
78
- // Super props
79
- if (config.superProps && Object.keys(config.superProps).length) {
80
- const sp = extractProps(config.superProps);
81
- if (Object.keys(sp).length) schema.superProps = sp;
82
- }
83
-
84
- // User props
85
- if (config.userProps && Object.keys(config.userProps).length) {
86
- const up = extractProps(config.userProps);
87
- if (Object.keys(up).length) schema.userProps = up;
88
- }
89
-
90
- // Funnels
84
+ // ── Funnels ─────────────────────────────────────────────────────
91
85
  if (config.funnels?.length) {
92
86
  schema.funnels = config.funnels.map(f => {
93
87
  const entry = { sequence: f.sequence };
88
+ if (f.name) entry.name = f.name;
94
89
  if (f.isFirstFunnel) entry.isFirstFunnel = true;
95
90
  if (f.conversionRate !== undefined) entry.conversionRate = f.conversionRate;
96
91
  if (f.timeToConvert !== undefined) entry.timeToConvert = f.timeToConvert;
@@ -98,6 +93,8 @@ async function processOne(inputFile, outputFile) {
98
93
  if (f.weight && f.weight !== 1) entry.weight = f.weight;
99
94
  if (f.requireRepeats) entry.requireRepeats = true;
100
95
  if (f.experiment) entry.experiment = true;
96
+ if (f.bindPropsIndex !== undefined) entry.bindPropsIndex = f.bindPropsIndex;
97
+ if (f.conditions) entry.conditions = f.conditions;
101
98
  if (f.props && Object.keys(f.props).length) {
102
99
  const fp = extractProps(f.props);
103
100
  if (Object.keys(fp).length) entry.props = fp;
@@ -106,6 +103,55 @@ async function processOne(inputFile, outputFile) {
106
103
  });
107
104
  }
108
105
 
106
+ // ── Super props ─────────────────────────────────────────────────
107
+ if (config.superProps && Object.keys(config.superProps).length) {
108
+ const sp = extractProps(config.superProps);
109
+ if (Object.keys(sp).length) schema.superProps = sp;
110
+ }
111
+
112
+ // ── User props ──────────────────────────────────────────────────
113
+ if (config.userProps && Object.keys(config.userProps).length) {
114
+ const up = extractProps(config.userProps);
115
+ if (Object.keys(up).length) schema.userProps = up;
116
+ }
117
+
118
+ // ── Group keys ──────────────────────────────────────────────────
119
+ if (config.groupKeys?.length) {
120
+ schema.groupKeys = config.groupKeys.map(gk => {
121
+ if (Array.isArray(gk)) {
122
+ const entry = { key: gk[0], count: gk[1] };
123
+ if (gk[2]) entry.affectsEvents = gk[2];
124
+ return entry;
125
+ }
126
+ return gk;
127
+ });
128
+ }
129
+
130
+ // ── Group props ─────────────────────────────────────────────────
131
+ if (config.groupProps && Object.keys(config.groupProps).length) {
132
+ schema.groupProps = {};
133
+ for (const [groupKey, props] of Object.entries(config.groupProps)) {
134
+ schema.groupProps[groupKey] = extractProps(props);
135
+ }
136
+ }
137
+
138
+ // ── SCD props ───────────────────────────────────────────────────
139
+ if (config.scdProps && Object.keys(config.scdProps).length) {
140
+ schema.scdProps = {};
141
+ for (const [key, scd] of Object.entries(config.scdProps)) {
142
+ const entry = {};
143
+ entry.type = scd.type || "user";
144
+ if (scd.frequency) entry.frequency = scd.frequency;
145
+ if (scd.timing) entry.timing = scd.timing;
146
+ if (scd.max !== undefined) entry.max = scd.max;
147
+ if (scd.values) {
148
+ const simplified = simplifyValue(scd.values);
149
+ if (simplified) entry.values = simplified;
150
+ }
151
+ schema.scdProps[key] = entry;
152
+ }
153
+ }
154
+
109
155
  writeFileSync(outputPath, JSON.stringify(schema, null, 2) + '\n', 'utf-8');
110
156
  console.log(` ✅ ${baseName}-schema.json`);
111
157
  }
package/types.d.ts CHANGED
@@ -266,6 +266,7 @@ export interface Storage {
266
266
  export interface RuntimeState {
267
267
  operations: number;
268
268
  eventCount: number;
269
+ storedEventCount: number;
269
270
  userCount: number;
270
271
  isBatchMode: boolean;
271
272
  verbose: boolean;
@@ -305,11 +306,13 @@ export interface Context {
305
306
  incrementOperations(): void;
306
307
  incrementEvents(): void;
307
308
  incrementUsers(): void;
309
+ incrementStoredEvents(count?: number): void;
308
310
  setStorage(storage: Storage): void;
309
311
 
310
312
  // State getter methods
311
313
  getOperations(): number;
312
314
  getEventCount(): number;
315
+ getStoredEventCount(): number;
313
316
  getUserCount(): number;
314
317
  incrementUserCount(): void;
315
318
  incrementEventCount(): void;