@nullix/zod-mongoose-studio 2.1.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.
- package/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{WZ0WK9cR.js → BYb-oWZd.js} +1 -1
- package/.output/public/_nuxt/{BV6uALfO.js → BslsNWeO.js} +1 -1
- package/.output/public/_nuxt/{B_782F4p.js → ByzCJ9qg.js} +1 -1
- package/.output/public/_nuxt/{DeCqoVOS.js → CEydsZ8-.js} +1 -1
- package/.output/public/_nuxt/{BoHhCIKW.js → CLz6MNQ2.js} +3 -3
- package/.output/public/_nuxt/{BSqjh6Vk.js → CVTJORg5.js} +1 -1
- package/.output/public/_nuxt/{kBtP64Rx.js → CYpPdUat.js} +1 -1
- package/.output/public/_nuxt/{Db19R32y.js → CdDk3SWJ.js} +1 -1
- package/.output/public/_nuxt/{CvnpbYw0.js → CtvobD-H.js} +1 -1
- package/.output/public/_nuxt/{Y39o1QEi.js → DKUkGVFq.js} +1 -1
- package/.output/public/_nuxt/{BS4yU4O0.js → DNMZmLbK.js} +1 -1
- package/.output/public/_nuxt/{B4zoPYF-.js → Dfsc_W0R.js} +1 -1
- package/.output/public/_nuxt/{BEI71c6K.js → DvCFhKNi.js} +1 -1
- package/.output/public/_nuxt/EQtuxex4.js +33 -0
- package/.output/public/_nuxt/_u12_qo6.js +61 -0
- package/.output/public/_nuxt/{B8qGaxNm.js → b184ulLB.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/e94f7b27-aec2-4561-afff-7f7a9eb9f6e9.json +1 -0
- package/.output/public/_nuxt/{Db4IAypj.js → c0F15Q-s.js} +1 -1
- package/.output/public/_nuxt/{CP9Z7-_9.js → cVykzrJ8.js} +1 -1
- package/.output/public/_nuxt/entry.J_CbC0oY.css +1 -0
- package/.output/public/_nuxt/error-404.64pZEiDn.css +1 -0
- package/.output/public/_nuxt/error-500.DHOpI0Ir.css +1 -0
- package/.output/public/_nuxt/{D8_n84hl.js → qtXB1NaS.js} +1 -1
- package/.output/public/_nuxt/{CqNsQbt9.js → s1ajeyOL.js} +1 -1
- package/.output/public/_nuxt/{dBZQW7JD.js → yvar5_gl.js} +1 -1
- package/.output/server/chunks/_/error-500.mjs.map +1 -1
- package/.output/server/chunks/build/client.precomputed.mjs +1 -1
- package/.output/server/chunks/build/{error-404-8tbBXju4.mjs → error-404-BN-7rNE4.mjs} +4 -4
- package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +8 -0
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +1 -0
- package/.output/server/chunks/build/{error-500-DxFsom1i.mjs → error-500-DhIQ-2yt.mjs} +4 -4
- package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +1 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +8 -0
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +1 -0
- package/.output/server/chunks/build/index-B4T6zHp0.mjs +1904 -0
- package/.output/server/chunks/build/index-B4T6zHp0.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +231 -19
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/nitro/nitro.mjs +660 -345
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/parse.post.mjs +73 -13
- package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/index.mjs +1 -1
- package/.output/server/package.json +1 -1
- package/app/components/ZodMongooseStudio.vue +135 -46
- package/package.json +2 -2
- package/server/api/parse.post.ts +6 -0
- package/.output/public/_nuxt/BWajNATZ.js +0 -59
- package/.output/public/_nuxt/NAqlztEN.js +0 -33
- package/.output/public/_nuxt/builds/meta/8b851c04-1848-472a-b5cd-0727aaaf90f4.json +0 -1
- package/.output/public/_nuxt/entry.V-_Q9qpd.css +0 -1
- package/.output/public/_nuxt/error-404.CTWLHxjC.css +0 -1
- package/.output/public/_nuxt/error-500.UBfk8-QP.css +0 -1
- package/.output/server/chunks/build/error-404-8tbBXju4.mjs.map +0 -1
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs +0 -8
- package/.output/server/chunks/build/error-404-styles.BeWfK6Py.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-DxFsom1i.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs +0 -8
- package/.output/server/chunks/build/error-500-styles.CPUUvoY-.mjs.map +0 -1
- package/.output/server/chunks/build/index-BB-Clavm.mjs +0 -528
- package/.output/server/chunks/build/index-BB-Clavm.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
|
-
|
|
47
|
-
()
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
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
|
-
<
|
|
91
|
-
class="flex-1
|
|
113
|
+
<UDashboardGroup
|
|
114
|
+
class="flex-1 min-h-0 !relative !inset-auto"
|
|
115
|
+
storage-key="studio-layout"
|
|
92
116
|
>
|
|
93
117
|
<!-- Left: Editor -->
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
<
|
|
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
|
-
<
|
|
104
|
-
|
|
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
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
<
|
|
120
|
-
|
|
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
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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.
|
|
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.
|
|
47
|
+
"@nullix/zod-mongoose": "2.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@nuxt/ui": "4.6.0",
|
package/server/api/parse.post.ts
CHANGED
|
@@ -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({
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./BoHhCIKW.js","./NAqlztEN.js","./entry.V-_Q9qpd.css","./editor.CdBKkuhR.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{f as N,g as j,h as B,i as R,j as P,o as c,k as m,w as f,r as S,l as i,m as q,n as z,p as L,q as U,s as h,c as _,t as F,P as G,v as H,x as C,y as T,z as O,A as V,B as w,C as Z,D as p,E as D,a as l,d as M,b,F as K,G as J,H as Q,_ as W}from"./NAqlztEN.js";const X={slots:{base:"font-medium inline-flex items-center",label:"truncate",leadingIcon:"shrink-0",leadingAvatar:"shrink-0",leadingAvatarSize:"",trailingIcon:"shrink-0"},variants:{fieldGroup:{horizontal:"not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]",vertical:"not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]"},color:{primary:"",secondary:"",success:"",info:"",warning:"",error:"",neutral:""},variant:{solid:"",outline:"",soft:"",subtle:""},size:{xs:{base:"text-[8px]/3 px-1 py-0.5 gap-1 rounded-sm",leadingIcon:"size-3",leadingAvatarSize:"3xs",trailingIcon:"size-3"},sm:{base:"text-[10px]/3 px-1.5 py-1 gap-1 rounded-sm",leadingIcon:"size-3",leadingAvatarSize:"3xs",trailingIcon:"size-3"},md:{base:"text-xs px-2 py-1 gap-1 rounded-md",leadingIcon:"size-4",leadingAvatarSize:"3xs",trailingIcon:"size-4"},lg:{base:"text-sm px-2 py-1 gap-1.5 rounded-md",leadingIcon:"size-5",leadingAvatarSize:"2xs",trailingIcon:"size-5"},xl:{base:"text-base px-2.5 py-1 gap-1.5 rounded-md",leadingIcon:"size-6",leadingAvatarSize:"2xs",trailingIcon:"size-6"}},square:{true:""}},compoundVariants:[{color:"primary",variant:"solid",class:"bg-primary text-inverted"},{color:"secondary",variant:"solid",class:"bg-secondary text-inverted"},{color:"success",variant:"solid",class:"bg-success text-inverted"},{color:"info",variant:"solid",class:"bg-info text-inverted"},{color:"warning",variant:"solid",class:"bg-warning text-inverted"},{color:"error",variant:"solid",class:"bg-error text-inverted"},{color:"primary",variant:"outline",class:"text-primary ring ring-inset ring-primary/50"},{color:"secondary",variant:"outline",class:"text-secondary ring ring-inset ring-secondary/50"},{color:"success",variant:"outline",class:"text-success ring ring-inset ring-success/50"},{color:"info",variant:"outline",class:"text-info ring ring-inset ring-info/50"},{color:"warning",variant:"outline",class:"text-warning ring ring-inset ring-warning/50"},{color:"error",variant:"outline",class:"text-error ring ring-inset ring-error/50"},{color:"primary",variant:"soft",class:"bg-primary/10 text-primary"},{color:"secondary",variant:"soft",class:"bg-secondary/10 text-secondary"},{color:"success",variant:"soft",class:"bg-success/10 text-success"},{color:"info",variant:"soft",class:"bg-info/10 text-info"},{color:"warning",variant:"soft",class:"bg-warning/10 text-warning"},{color:"error",variant:"soft",class:"bg-error/10 text-error"},{color:"primary",variant:"subtle",class:"bg-primary/10 text-primary ring ring-inset ring-primary/25"},{color:"secondary",variant:"subtle",class:"bg-secondary/10 text-secondary ring ring-inset ring-secondary/25"},{color:"success",variant:"subtle",class:"bg-success/10 text-success ring ring-inset ring-success/25"},{color:"info",variant:"subtle",class:"bg-info/10 text-info ring ring-inset ring-info/25"},{color:"warning",variant:"subtle",class:"bg-warning/10 text-warning ring ring-inset ring-warning/25"},{color:"error",variant:"subtle",class:"bg-error/10 text-error ring ring-inset ring-error/25"},{color:"neutral",variant:"solid",class:"text-inverted bg-inverted"},{color:"neutral",variant:"outline",class:"ring ring-inset ring-accented text-default bg-default"},{color:"neutral",variant:"soft",class:"text-default bg-elevated"},{color:"neutral",variant:"subtle",class:"ring ring-inset ring-accented text-default bg-elevated"},{size:"xs",square:!0,class:"p-0.5"},{size:"sm",square:!0,class:"p-1"},{size:"md",square:!0,class:"p-1"},{size:"lg",square:!0,class:"p-1"},{size:"xl",square:!0,class:"p-1"}],defaultVariants:{color:"primary",variant:"solid",size:"md"}},Y={__name:"UBadge",props:{as:{type:null,required:!1,default:"span"},label:{type:[String,Number],required:!1},color:{type:null,required:!1},variant:{type:null,required:!1},size:{type:null,required:!1},square:{type:Boolean,required:!1},class:{type:null,required:!1},ui:{type:Object,required:!1},icon:{type:null,required:!1},avatar:{type:Object,required:!1},leading:{type:Boolean,required:!1},leadingIcon:{type:null,required:!1},trailing:{type:Boolean,required:!1},trailingIcon:{type:null,required:!1}},setup(s){const t=s,r=N(),d=j(),o=B("badge",t),{orientation:a,size:n}=R(t),{isLeading:g,isTrailing:y,leadingIconName:v,trailingIconName:u}=P(t),e=H(()=>C({extend:C(X),...d.ui?.badge||{}})({color:t.color,variant:t.variant,size:n.value||t.size,square:t.square||!r.default&&!t.label,fieldGroup:a.value}));return(x,I)=>(c(),m(i(G),{as:s.as,"data-slot":"base",class:z(e.value.base({class:[i(o)?.base,t.class]}))},{default:f(()=>[S(x.$slots,"leading",{ui:e.value},()=>[i(g)&&i(v)?(c(),m(q,{key:0,name:i(v),"data-slot":"leadingIcon",class:z(e.value.leadingIcon({class:i(o)?.leadingIcon}))},null,8,["name","class"])):s.avatar?(c(),m(L,U({key:1,size:i(o)?.leadingAvatarSize||e.value.leadingAvatarSize()},s.avatar,{"data-slot":"leadingAvatar",class:e.value.leadingAvatar({class:i(o)?.leadingAvatar})}),null,16,["size","class"])):h("",!0)]),S(x.$slots,"default",{ui:e.value},()=>[s.label!==void 0&&s.label!==null?(c(),_("span",{key:0,"data-slot":"label",class:z(e.value.label({class:i(o)?.label}))},F(s.label),3)):h("",!0)]),S(x.$slots,"trailing",{ui:e.value},()=>[i(y)&&i(u)?(c(),m(q,{key:0,name:i(u),"data-slot":"trailingIcon",class:z(e.value.trailingIcon({class:i(o)?.trailingIcon}))},null,8,["name","class"])):h("",!0)])]),_:3},8,["as","class"]))}},ee=T({__name:"StudioEditor",props:{modelValue:{}},emits:["update:modelValue"],setup(s,{emit:t}){const r=s,d=t,o=p(null),a=D(null);return O(async()=>{if(!o.value)return;const n=await V(()=>import("./BoHhCIKW.js").then(g=>g.b),__vite__mapDeps([0,1,2,3]),import.meta.url);n.typescript.typescriptDefaults.setCompilerOptions({target:n.typescript.ScriptTarget.ESNext,allowNonTsExtensions:!0,moduleResolution:n.typescript.ModuleResolutionKind.NodeJs,module:n.typescript.ModuleKind.ESNext,noEmit:!0}),n.typescript.typescriptDefaults.addExtraLib(`
|
|
3
|
-
declare module 'zod/v4' {
|
|
4
|
-
export const z: any;
|
|
5
|
-
export type ZodTypeAny = any;
|
|
6
|
-
export type ZodObject<T> = any;
|
|
7
|
-
export type ZodString = any;
|
|
8
|
-
export type ZodNumber = any;
|
|
9
|
-
}
|
|
10
|
-
`,"file:///node_modules/@types/zod-v4/index.d.ts"),n.typescript.typescriptDefaults.addExtraLib(`
|
|
11
|
-
declare module '@nullix/zod-mongoose' {
|
|
12
|
-
import { z } from 'zod/v4';
|
|
13
|
-
import mongoose, { SchemaOptions } from 'mongoose';
|
|
14
|
-
import * as hookable from 'hookable';
|
|
15
|
-
|
|
16
|
-
interface MongooseMeta extends Record<string, any> {
|
|
17
|
-
explicitId?: boolean;
|
|
18
|
-
}
|
|
19
|
-
declare const mongooseRegistry: z.core.$ZodRegistry<MongooseMeta, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
20
|
-
declare function withMongoose<T extends z.ZodTypeAny>(schema: T, meta: MongooseMeta): T;
|
|
21
|
-
|
|
22
|
-
type ToMongooseType<T extends z.ZodTypeAny> = any; // Simplified for Monaco perf
|
|
23
|
-
|
|
24
|
-
export declare function extractMongooseDef<T extends z.ZodTypeAny>(schema: T, visited?: Map<z.ZodTypeAny, any>, isField?: boolean): ToMongooseType<T> & Record<string, any>;
|
|
25
|
-
|
|
26
|
-
interface ToMongooseSchemaOptions extends SchemaOptions {
|
|
27
|
-
plugins?: Array<(schema: mongoose.Schema, options?: any) => void>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export declare function toMongooseSchema<T extends z.ZodTypeAny>(schema: T, options?: ToMongooseSchemaOptions): mongoose.Schema<z.infer<T>>;
|
|
31
|
-
|
|
32
|
-
export declare const zObjectId: (options?: MongooseMeta) => any;
|
|
33
|
-
export declare const zBuffer: (options?: MongooseMeta) => any;
|
|
34
|
-
export declare const zPopulated: <T extends z.ZodTypeAny>(ref: string, schema: T, options?: MongooseMeta) => any;
|
|
35
|
-
export declare const genTimestampsSchema: <CrAt = "createdAt", UpAt = "updatedAt">(createdAtField?: any, updatedAtField?: any) => any;
|
|
36
|
-
|
|
37
|
-
export type PopulatedSchema<T, K extends keyof T> = any;
|
|
38
|
-
export declare const bufferMongooseGetter: (value: unknown) => any;
|
|
39
|
-
export declare const getMongoose: () => any;
|
|
40
|
-
export declare const setFrontendMode: (enabled: boolean) => void;
|
|
41
|
-
export declare const getFrontendMode: () => boolean;
|
|
42
|
-
|
|
43
|
-
export type MongooseZodHooks = any;
|
|
44
|
-
export declare const hooks: any;
|
|
45
|
-
export declare function callHookSync<Name extends keyof MongooseZodHooks>(name: Name, ...args: Parameters<MongooseZodHooks[Name]>): void;
|
|
46
|
-
}
|
|
47
|
-
`,"file:///node_modules/@nullix/zod-mongoose/index.d.ts"),a.value=n.editor.create(o.value,{value:r.modelValue,language:"typescript",theme:"vs-dark",minimap:{enabled:!1},automaticLayout:!0,fontSize:14,padding:{top:16}}),a.value.onDidChangeModelContent(()=>{d("update:modelValue",a.value?.getValue()||"")})}),w(()=>r.modelValue,n=>{a.value&&a.value.getValue()!==n&&a.value.setValue(n)}),Z(()=>{a.value&&a.value.dispose()}),(n,g)=>(c(),_("div",{ref_key:"editorContainer",ref:o,class:"w-full h-full"},null,512))}}),oe=Object.assign(ee,{__name:"StudioEditor"}),te=T({__name:"StudioOutput",props:{modelValue:{}},setup(s){const t=s,r=p(null),d=D(null);return O(async()=>{if(!r.value)return;const o=await V(()=>import("./BoHhCIKW.js").then(a=>a.b),__vite__mapDeps([0,1,2,3]),import.meta.url);d.value=o.editor.create(r.value,{value:t.modelValue,language:"typescript",theme:"vs-dark",minimap:{enabled:!1},automaticLayout:!0,readOnly:!0,fontSize:14,padding:{top:16}})}),w(()=>t.modelValue,o=>{d.value&&d.value.setValue(o)}),Z(()=>{d.value&&d.value.dispose()}),(o,a)=>(c(),_("div",{ref_key:"outputContainer",ref:r,class:"w-full h-full"},null,512))}}),ae=Object.assign(te,{__name:"StudioOutput"}),ne={class:"h-screen flex flex-col bg-gray-50 dark:bg-gray-950"},se={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"},re={class:"flex items-center gap-4"},ie={class:"flex items-center gap-2"},le={key:1,class:"text-sm text-gray-500"},ce={class:"flex-1 grid grid-cols-2 gap-px bg-gray-200 dark:bg-gray-800 min-h-0"},de={class:"bg-white dark:bg-gray-950 h-full relative"},ue={class:"flex flex-col h-full gap-px bg-gray-200 dark:bg-gray-800"},ge={class:"flex-1 bg-white dark:bg-gray-950 relative flex flex-col min-h-0"},pe={class:"flex-1 relative"},me={class:"flex-1 bg-white dark:bg-gray-950 relative flex flex-col min-h-0"},fe={class:"flex-1 relative"},ye=T({__name:"ZodMongooseStudio",setup(s){let t;const r=J(),d=p(r.public.isLocalMode),o=p(r.public.isDocsMode),a=p(`import { z } from 'zod/v4';
|
|
48
|
-
import { extractMongooseDef, toMongooseSchema } from '@nullix/zod-mongoose';
|
|
49
|
-
|
|
50
|
-
const UserSchema = z.object({
|
|
51
|
-
name: z.string(),
|
|
52
|
-
age: z.number().optional()
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// Export your schema so the Studio can transform it
|
|
56
|
-
export default UserSchema;`),n=p("// Definition output..."),g=p("// Mongoose Schema output..."),y=p(!1),v=async()=>{y.value=!0;try{const u=await $fetch("/api/parse",{method:"POST",body:{sourceCode:a.value}});n.value=`// Result of extractMongooseDef()
|
|
57
|
-
const definition = ${u.definition};`,g.value=`// Result of toMongooseSchema().obj
|
|
58
|
-
const schemaObj = ${u.schemaObj};`}catch(u){const e=`// Error
|
|
59
|
-
${u.data?.message||u.message}`;n.value=e,g.value=e}finally{y.value=!1}};return w(a,()=>{o.value||(clearTimeout(t),t=setTimeout(v,600))}),o.value&&v(),(u,e)=>{const x=Y,I=Q,E=oe,k=K,A=ae;return c(),_("div",ne,[l("header",se,[l("div",re,[e[3]||(e[3]=l("h1",{class:"text-xl font-bold text-primary"}," @nullix/zod-mongoose Studio ",-1)),d.value?(c(),m(x,{key:0,color:"success",variant:"soft"},{default:f(()=>[...e[1]||(e[1]=[M("Local Mode",-1)])]),_:1})):(c(),m(x,{key:1,color:"info",variant:"soft"},{default:f(()=>[...e[2]||(e[2]=[M("Docs Mode",-1)])]),_:1}))]),l("div",ie,[o.value?(c(),m(I,{key:0,icon:"i-heroicons-play-solid",color:"primary",loading:y.value,onClick:v},{default:f(()=>[...e[4]||(e[4]=[M(" Run ",-1)])]),_:1},8,["loading"])):y.value?(c(),_("span",le,"Transforming...")):h("",!0)])]),l("div",ce,[l("div",de,[b(k,null,{default:f(()=>[b(E,{modelValue:a.value,"onUpdate:modelValue":e[0]||(e[0]=$=>a.value=$)},null,8,["modelValue"])]),_:1})]),l("div",ue,[l("div",ge,[e[5]||(e[5]=l("div",{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"}," extractMongooseDef() ",-1)),l("div",pe,[b(k,null,{default:f(()=>[b(A,{"model-value":n.value},null,8,["model-value"])]),_:1})])]),l("div",me,[e[6]||(e[6]=l("div",{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"}," toMongooseSchema() ",-1)),l("div",fe,[b(k,null,{default:f(()=>[b(A,{"model-value":g.value},null,8,["model-value"])]),_:1})])])])])])}}}),ve=Object.assign(ye,{__name:"ZodMongooseStudio"}),xe={};function be(s,t){const r=ve;return c(),m(r)}const ze=W(xe,[["render",be]]);export{ze as default};
|