@nullix/zod-mongoose-studio 2.0.0 → 2.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 (45) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/_nuxt/{BkE1sm_1.js → BYb-oWZd.js} +1 -1
  3. package/.output/public/_nuxt/{CCh0PVV0.js → BslsNWeO.js} +1 -1
  4. package/.output/public/_nuxt/{r6LdR7DN.js → ByzCJ9qg.js} +1 -1
  5. package/.output/public/_nuxt/{DJe7Wxdv.js → CEydsZ8-.js} +1 -1
  6. package/.output/public/_nuxt/{koEZfutw.js → CLz6MNQ2.js} +3 -3
  7. package/.output/public/_nuxt/{BC5hGokz.js → CVTJORg5.js} +1 -1
  8. package/.output/public/_nuxt/{CADbZwE5.js → CYpPdUat.js} +1 -1
  9. package/.output/public/_nuxt/{DV2n9B6m.js → CdDk3SWJ.js} +1 -1
  10. package/.output/public/_nuxt/{DVD-jGiv.js → CtvobD-H.js} +1 -1
  11. package/.output/public/_nuxt/{5KLjKHc1.js → DKUkGVFq.js} +1 -1
  12. package/.output/public/_nuxt/{BJwN20Xm.js → DNMZmLbK.js} +1 -1
  13. package/.output/public/_nuxt/{B2UrsJHg.js → Dfsc_W0R.js} +1 -1
  14. package/.output/public/_nuxt/{rEfOp38p.js → DvCFhKNi.js} +1 -1
  15. package/.output/public/_nuxt/EQtuxex4.js +33 -0
  16. package/.output/public/_nuxt/_u12_qo6.js +61 -0
  17. package/.output/public/_nuxt/{CB0WRoVi.js → b184ulLB.js} +1 -1
  18. package/.output/public/_nuxt/builds/latest.json +1 -1
  19. package/.output/public/_nuxt/builds/meta/e94f7b27-aec2-4561-afff-7f7a9eb9f6e9.json +1 -0
  20. package/.output/public/_nuxt/{0J_bLG6U.js → c0F15Q-s.js} +1 -1
  21. package/.output/public/_nuxt/{Cr0GW7rA.js → cVykzrJ8.js} +1 -1
  22. package/.output/public/_nuxt/entry.J_CbC0oY.css +1 -0
  23. package/.output/public/_nuxt/{BMgDPqps.js → qtXB1NaS.js} +1 -1
  24. package/.output/public/_nuxt/{B_sGF2qN.js → s1ajeyOL.js} +1 -1
  25. package/.output/public/_nuxt/{DRBrUaE5.js → yvar5_gl.js} +1 -1
  26. package/.output/server/chunks/build/client.precomputed.mjs +1 -1
  27. package/.output/server/chunks/build/index-B4T6zHp0.mjs +1904 -0
  28. package/.output/server/chunks/build/index-B4T6zHp0.mjs.map +1 -0
  29. package/.output/server/chunks/build/server.mjs +223 -11
  30. package/.output/server/chunks/build/styles.mjs +3 -3
  31. package/.output/server/chunks/nitro/nitro.mjs +651 -336
  32. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  33. package/.output/server/chunks/routes/api/parse.post.mjs +127 -24
  34. package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
  35. package/.output/server/index.mjs +1 -1
  36. package/.output/server/package.json +1 -1
  37. package/app/components/ZodMongooseStudio.vue +135 -46
  38. package/package.json +2 -2
  39. package/server/api/parse.post.ts +6 -0
  40. package/.output/public/_nuxt/BeaJ7I-K.js +0 -33
  41. package/.output/public/_nuxt/Dk9qGA5X.js +0 -59
  42. package/.output/public/_nuxt/builds/meta/dc761332-547d-4953-b51d-b2d453009b48.json +0 -1
  43. package/.output/public/_nuxt/entry.V-_Q9qpd.css +0 -1
  44. package/.output/server/chunks/build/index-Dnrh1ePF.mjs +0 -528
  45. package/.output/server/chunks/build/index-Dnrh1ePF.mjs.map +0 -1
@@ -20,6 +20,21 @@ export default UserSchema;`);
20
20
 
21
21
  const outputDef = ref("// Definition output...");
22
22
  const outputSchema = ref("// Mongoose Schema output...");
23
+ const outputTree = ref("// Mongoose Schema tree output...");
24
+ const outputPaths = ref("// Mongoose Schema paths output...");
25
+ const activeSchemaView = ref<"obj" | "tree" | "paths">("obj");
26
+ const activeSchemaViewOutput = computed(() => {
27
+ switch (activeSchemaView.value) {
28
+ case "obj":
29
+ return outputSchema;
30
+ case "tree":
31
+ return outputTree;
32
+ case "paths":
33
+ return outputPaths;
34
+ }
35
+ });
36
+ const isDefOpen = ref(true);
37
+ const isSchemaOpen = ref(true);
23
38
 
24
39
  const isCompiling = ref(false);
25
40
 
@@ -32,24 +47,25 @@ const handleCompile = async () => {
32
47
  });
33
48
  outputDef.value = `// Result of extractMongooseDef()\nconst definition = ${response.definition};`;
34
49
  outputSchema.value = `// Result of toMongooseSchema().obj\nconst schemaObj = ${response.schemaObj};`;
50
+ outputTree.value = `// Result of toMongooseSchema().tree\nconst schemaTree = ${response.schemaTree};`;
51
+ outputPaths.value = `// Result of toMongooseSchema().paths\nconst schemaPaths = ${response.schemaPaths};`;
35
52
  } catch (error: any) {
36
53
  const errText = `// Error\n${error.data?.message || error.message}`;
37
54
  outputDef.value = errText;
38
55
  outputSchema.value = errText;
56
+ outputTree.value = errText;
57
+ outputPaths.value = errText;
39
58
  } finally {
40
59
  isCompiling.value = false;
41
60
  }
42
61
  };
43
62
 
44
63
  // Auto-compile with a slight delay as they type
45
- watch(
46
- sourceCode,
47
- () => {
48
- if (isDocsMode.value) return;
49
- clearTimeout(debounceTimer);
50
- debounceTimer = setTimeout(handleCompile, 600);
51
- }
52
- );
64
+ watch(sourceCode, () => {
65
+ if (isDocsMode.value) return;
66
+ clearTimeout(debounceTimer);
67
+ debounceTimer = setTimeout(handleCompile, 600);
68
+ });
53
69
 
54
70
  // Initial compile for Docs Mode
55
71
  if (isDocsMode.value) {
@@ -58,9 +74,16 @@ if (isDocsMode.value) {
58
74
  </script>
59
75
 
60
76
  <template>
61
- <div class="h-screen flex flex-col bg-gray-50 dark:bg-gray-950">
77
+ <div
78
+ class="flex flex-col bg-gray-50 dark:bg-gray-950 overflow-hidden relative"
79
+ :class="[
80
+ isDocsMode
81
+ ? 'h-[calc(100vh-var(--ui-header-height,64px))] sticky top-[var(--ui-header-height,64px)]'
82
+ : 'h-screen',
83
+ ]"
84
+ >
62
85
  <header
63
- class="bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 py-3 px-4 flex justify-between items-center shrink-0"
86
+ class="bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 py-3 px-4 flex justify-between items-center shrink-0 z-20"
64
87
  >
65
88
  <div class="flex items-center gap-4">
66
89
  <h1 class="text-xl font-bold text-primary">
@@ -87,50 +110,116 @@ if (isDocsMode.value) {
87
110
  </div>
88
111
  </header>
89
112
 
90
- <div
91
- class="flex-1 grid grid-cols-2 gap-px bg-gray-200 dark:bg-gray-800 min-h-0"
113
+ <UDashboardGroup
114
+ class="flex-1 min-h-0 !relative !inset-auto"
115
+ storage-key="studio-layout"
92
116
  >
93
117
  <!-- Left: Editor -->
94
- <div class="bg-white dark:bg-gray-950 h-full relative">
95
- <ClientOnly>
96
- <StudioEditor v-model="sourceCode" />
97
- </ClientOnly>
98
- </div>
118
+ <UDashboardPanel id="editor" collapsible resizable :min-size="20">
119
+ <div class="h-full relative bg-white dark:bg-gray-950">
120
+ <ClientOnly>
121
+ <StudioEditor v-model="sourceCode" />
122
+ </ClientOnly>
123
+ </div>
124
+ </UDashboardPanel>
99
125
 
100
126
  <!-- Right: Split Outputs -->
101
- <div class="flex flex-col h-full gap-px bg-gray-200 dark:bg-gray-800">
127
+ <UDashboardPanel
128
+ id="outputs"
129
+ resizable
130
+ :min-size="20"
131
+ class="flex flex-col h-full bg-gray-200 dark:bg-gray-800 overflow-hidden"
132
+ >
102
133
  <!-- Top Right: Definition -->
103
- <div
104
- class="flex-1 bg-white dark:bg-gray-950 relative flex flex-col min-h-0"
134
+ <UCollapsible
135
+ v-model:open="isDefOpen"
136
+ :class="[isDefOpen ? 'flex-1' : 'flex-none']"
137
+ :ui="{ content: 'flex-1 flex flex-col min-h-0' }"
138
+ class="bg-white dark:bg-gray-950 flex flex-col min-h-0"
105
139
  >
106
- <div
107
- class="px-3 py-1 bg-gray-100 dark:bg-gray-900 text-xs font-semibold text-gray-600 dark:text-gray-400 border-b border-gray-200 dark:border-gray-800 z-10"
108
- >
109
- extractMongooseDef()
110
- </div>
111
- <div class="flex-1 relative">
112
- <ClientOnly>
113
- <StudioOutput :model-value="outputDef" />
114
- </ClientOnly>
115
- </div>
116
- </div>
140
+ <template #default="{ open }">
141
+ <div
142
+ class="px-3 py-1 bg-gray-100 dark:bg-gray-900 text-xs font-semibold text-gray-600 dark:text-gray-400 border-b border-gray-200 dark:border-gray-800 z-10 flex justify-between items-center cursor-pointer select-none"
143
+ >
144
+ <span>extractMongooseDef()</span>
145
+ <UIcon
146
+ :name="
147
+ open
148
+ ? 'i-heroicons-chevron-down'
149
+ : 'i-heroicons-chevron-right'
150
+ "
151
+ />
152
+ </div>
153
+ </template>
154
+ <template #content>
155
+ <div class="flex-1 relative">
156
+ <ClientOnly>
157
+ <StudioOutput :model-value="outputDef" />
158
+ </ClientOnly>
159
+ </div>
160
+ </template>
161
+ </UCollapsible>
117
162
 
118
163
  <!-- Bottom Right: Schema -->
119
- <div
120
- class="flex-1 bg-white dark:bg-gray-950 relative flex flex-col min-h-0"
164
+ <UCollapsible
165
+ v-model:open="isSchemaOpen"
166
+ :class="[isSchemaOpen ? 'flex-1' : 'flex-none']"
167
+ :ui="{ content: 'flex-1 flex flex-col min-h-0' }"
168
+ class="bg-white dark:bg-gray-950 flex flex-col min-h-0"
121
169
  >
122
- <div
123
- class="px-3 py-1 bg-gray-100 dark:bg-gray-900 text-xs font-semibold text-gray-600 dark:text-gray-400 border-b border-gray-200 dark:border-gray-800 z-10"
124
- >
125
- toMongooseSchema()
126
- </div>
127
- <div class="flex-1 relative">
128
- <ClientOnly>
129
- <StudioOutput :model-value="outputSchema" />
130
- </ClientOnly>
131
- </div>
132
- </div>
133
- </div>
134
- </div>
170
+ <template #default="{ open }">
171
+ <div
172
+ class="px-3 py-1 bg-gray-100 dark:bg-gray-900 text-xs font-semibold text-gray-600 dark:text-gray-400 border-b border-gray-200 dark:border-gray-800 z-10 flex justify-between items-center cursor-pointer select-none"
173
+ >
174
+ <div class="flex items-center gap-2">
175
+ <span>toMongooseSchema()</span>
176
+ <div class="flex gap-1" @click.stop>
177
+ <UButton
178
+ size="xs"
179
+ variant="ghost"
180
+ :color="activeSchemaView === 'obj' ? 'primary' : 'neutral'"
181
+ @click="activeSchemaView = 'obj'"
182
+ >
183
+ .obj
184
+ </UButton>
185
+ <UButton
186
+ size="xs"
187
+ variant="ghost"
188
+ :color="activeSchemaView === 'tree' ? 'primary' : 'neutral'"
189
+ @click="activeSchemaView = 'tree'"
190
+ >
191
+ .tree
192
+ </UButton>
193
+ <UButton
194
+ size="xs"
195
+ variant="ghost"
196
+ :color="
197
+ activeSchemaView === 'paths' ? 'primary' : 'neutral'
198
+ "
199
+ @click="activeSchemaView = 'paths'"
200
+ >
201
+ .paths
202
+ </UButton>
203
+ </div>
204
+ </div>
205
+ <UIcon
206
+ :name="
207
+ open
208
+ ? 'i-heroicons-chevron-down'
209
+ : 'i-heroicons-chevron-right'
210
+ "
211
+ />
212
+ </div>
213
+ </template>
214
+ <template #content>
215
+ <div class="flex-1 relative">
216
+ <ClientOnly>
217
+ <StudioOutput :model-value="activeSchemaViewOutput.value" />
218
+ </ClientOnly>
219
+ </div>
220
+ </template>
221
+ </UCollapsible>
222
+ </UDashboardPanel>
223
+ </UDashboardGroup>
135
224
  </div>
136
225
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nullix/zod-mongoose-studio",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Monaco-powered TypeScript playground for @nullix/zod-mongoose",
5
5
  "main": "./nuxt.config.ts",
6
6
  "bin": {
@@ -44,7 +44,7 @@
44
44
  "mongoose": "9.6.3",
45
45
  "open": "11.0.0",
46
46
  "zod": "4.3.6",
47
- "@nullix/zod-mongoose": "2.0.0"
47
+ "@nullix/zod-mongoose": "2.2.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@nuxt/ui": "4.6.0",
@@ -135,10 +135,16 @@ export default defineEventHandler(async (event) => {
135
135
  const formattedDef = formatValue(extractedDef);
136
136
  // schemaObj is a Mongoose Schema instance, we only care about its .obj for display
137
137
  const formattedSchema = formatValue(mongooseSchema.obj);
138
+ // @ts-ignore
139
+ const formattedTree = formatValue(mongooseSchema.tree);
140
+ // @ts-ignore
141
+ const formattedPaths = formatValue(mongooseSchema.paths);
138
142
 
139
143
  return {
140
144
  definition: util.inspect(formattedDef, formatOpts),
141
145
  schemaObj: util.inspect(formattedSchema, formatOpts),
146
+ schemaTree: util.inspect(formattedTree, formatOpts),
147
+ schemaPaths: util.inspect(formattedPaths, formatOpts),
142
148
  };
143
149
  } catch (err: any) {
144
150
  throw createError({