@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.
- package/dungeons/technical/ad-spend-schema.json +2 -2
- package/dungeons/technical/ad-spend.js +1 -1
- package/dungeons/technical/anonymous-users-schema.json +4 -3
- package/dungeons/technical/anonymous-users.js +1 -1
- package/dungeons/technical/array-of-object-lookup-schema.json +1 -1
- package/dungeons/technical/array-of-object-lookup.js +1 -1
- package/dungeons/technical/experiments-schema.json +25 -19
- package/dungeons/technical/experiments.js +1 -1
- package/dungeons/technical/foobar.js +1 -1
- package/dungeons/technical/group-analytics-schema.json +92 -0
- package/dungeons/technical/group-analytics.js +1 -1
- package/dungeons/technical/mirror-strategies-schema.json +4 -4
- package/dungeons/technical/mirror-strategies.js +1 -1
- package/dungeons/technical/nested-objects.js +1 -1
- package/dungeons/technical/retention-cadence.js +1 -2
- package/dungeons/technical/sanity-schema.json +22 -22
- package/dungeons/technical/sanity.js +1 -0
- package/dungeons/technical/scale-test.js +1 -1
- package/dungeons/technical/scd-schema.json +230 -33
- package/dungeons/technical/scd.js +1 -0
- package/dungeons/technical/simple-schema.json +132 -48
- package/dungeons/technical/simple.js +1 -1
- package/dungeons/technical/simplest-schema.json +168 -79
- package/dungeons/technical/simplest.js +1 -1
- package/dungeons/technical/text-generation-schema.json +7 -4
- package/dungeons/technical/text-generation.js +1 -2
- package/dungeons/vertical/community-schema.json +71 -49
- package/dungeons/vertical/community.js +8 -2
- package/dungeons/vertical/devtools-schema.json +69 -48
- package/dungeons/vertical/devtools.js +8 -2
- package/dungeons/vertical/ecommerce-schema.json +126 -108
- package/dungeons/vertical/ecommerce.js +9 -2
- package/dungeons/vertical/education-schema.json +5261 -272
- package/dungeons/vertical/education.js +16 -3
- package/dungeons/vertical/fintech-schema.json +165 -98
- package/dungeons/vertical/fintech.js +16 -3
- package/dungeons/vertical/fitness-schema.json +69 -47
- package/dungeons/vertical/fitness.js +8 -2
- package/dungeons/vertical/food-delivery-schema.json +36237 -187
- package/dungeons/vertical/food-delivery.js +16 -3
- package/dungeons/vertical/gaming-schema.json +103 -59
- package/dungeons/vertical/gaming.js +20 -9
- package/dungeons/vertical/healthcare-schema.json +70 -48
- package/dungeons/vertical/healthcare.js +8 -2
- package/dungeons/vertical/insurance-application-schema.json +66 -47
- package/dungeons/vertical/insurance-application.js +8 -2
- package/dungeons/vertical/logistics-schema.json +60 -38
- package/dungeons/vertical/logistics.js +8 -2
- package/dungeons/vertical/marketplace-schema.json +65 -43
- package/dungeons/vertical/marketplace.js +8 -2
- package/dungeons/vertical/media-schema.json +4085 -123
- package/dungeons/vertical/media.js +9 -3
- package/dungeons/vertical/rpg-schema.json +1984 -147
- package/dungeons/vertical/rpg.js +9 -3
- package/dungeons/vertical/sass-schema.json +2622 -147
- package/dungeons/vertical/sass.js +16 -3
- package/dungeons/vertical/social-schema.json +146 -78
- package/dungeons/vertical/social.js +16 -3
- package/dungeons/vertical/travel-schema.json +57 -35
- package/dungeons/vertical/travel.js +8 -2
- package/index.js +1 -1
- package/lib/core/context.js +9 -0
- package/lib/core/storage.js +2 -0
- package/lib/orchestrators/user-loop.js +4 -1
- package/package.json +1 -1
- package/scripts/extract-dungeon-schema.mjs +64 -18
- package/types.d.ts +3 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Extracts
|
|
4
|
+
* Extracts a complete schema from a JavaScript dungeon file.
|
|
5
5
|
*
|
|
6
|
-
* Output contains
|
|
7
|
-
*
|
|
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 →
|
|
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
|
-
//
|
|
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;
|