@nullix/zod-mongoose-studio 3.2.0 → 3.3.1
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/_fonts/57NSSoFy1VLVs2gqly8Ls9awBnZMFyXGrefpmqvdqmc-zJfbBtpgM4cDmcXBsqZNW79_kFnlpPd62b48glgdydA.woff2 +0 -0
- package/.output/public/_fonts/8VR2wSMN-3U4NbWAVYXlkRV6hA0jFBXP-0RtL3X7fko-x2gYI4qfmkRdxyQQUPaBZdZdgl1TeVrquF_TxHeM4lM.woff2 +0 -0
- package/.output/public/_fonts/GsKUclqeNLJ96g5AU593ug6yanivOiwjW_7zESNPChw-jHA4tBeM1bjF7LATGUpfBuSTyomIFrWBTzjF7txVYfg.woff2 +0 -0
- package/.output/public/_fonts/Ld1FnTo3yTIwDyGfTQ5-Fws9AWsCbKfMvgxduXr7JcY-W25bL8NF1fjpLRSOgJb7RoZPHqGQNwMTM7S9tHVoxx8.woff2 +0 -0
- package/.output/public/_fonts/NdzqRASp2bovDUhQT1IRE_EMqKJ2KYQdTCfFcBvL8yw-KhwZiS86o3fErOe5GGMExHUemmI_dBfaEFxjISZrBd0.woff2 +0 -0
- package/.output/public/_fonts/iTkrULNFJJkTvihIg1Vqi5IODRH_9btXCioVF5l98I8-AndUyau2HR2felA_ra8V2mutQgschhasE5FD1dXGJX8.woff2 +0 -0
- package/.output/public/_nuxt/{qQyvCkbV.js → 5Tu2WUJz.js} +1 -1
- package/.output/public/_nuxt/B0N6xv5E.js +1 -0
- package/.output/public/_nuxt/{DjPT-NCE.js → B0cUlOSM.js} +1 -1
- package/.output/public/_nuxt/B9paGgN0.js +33 -0
- package/.output/public/_nuxt/{IxYCG8hB.js → BCIlnd0g.js} +1 -1
- package/.output/public/_nuxt/{ikxafTHA.js → BNDnV2op.js} +180 -184
- package/.output/public/_nuxt/{Ce-T_1aD.js → BO4hqv6q.js} +1 -1
- package/.output/public/_nuxt/{Bd32GOUy.js → BOsJJ_ZU.js} +1 -1
- package/.output/public/_nuxt/{BzhSDy30.js → C2BHp-MG.js} +1 -1
- package/.output/public/_nuxt/{Cs8GXJCB.js → CKULsFUz.js} +1 -1
- package/.output/public/_nuxt/CMH9iX_E.js +6 -0
- package/.output/public/_nuxt/{tzj4nvDE.js → CzbCpNnc.js} +2 -2
- package/.output/public/_nuxt/{CC3n3Aga.js → D87QMS6j.js} +1 -1
- package/.output/public/_nuxt/DA0pQuyP.js +27 -0
- package/.output/public/_nuxt/{B7P0wQ35.js → DcJ7oPvZ.js} +1 -1
- package/.output/public/_nuxt/{Ick_23I4.js → Dce9SnGa.js} +1 -1
- package/.output/public/_nuxt/{CAd-qHfI.js → DpKrXpkK.js} +1 -1
- package/.output/public/_nuxt/DsnIpnT9.js +1 -0
- package/.output/public/_nuxt/{CNZorjDf.js → I3Ucam2s.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/51f1351c-0667-4235-9ddc-16582a51ce03.json +1 -0
- package/.output/public/_nuxt/{entry.J_CbC0oY.css → entry.B-vs1tRH.css} +1 -1
- package/.output/public/_nuxt/error-404.CTSXlFYa.css +1 -0
- package/.output/public/_nuxt/error-500.DqEfQnVZ.css +1 -0
- package/.output/public/_nuxt/{nDZOJ7rN.js → o-NCh2rp.js} +2 -2
- package/.output/public/_nuxt/{qwxNOyg7.js → sKEJiAHO.js} +1 -1
- package/.output/public/_nuxt/{81vqh61j.js → tqQNlhT9.js} +1 -1
- package/.output/public/_nuxt/ypRHVLFO.js +1 -0
- 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-BN-7rNE4.mjs → error-404-KRkA0DPI.mjs} +10 -4
- package/.output/server/chunks/build/error-404-KRkA0DPI.mjs.map +1 -0
- package/.output/server/chunks/build/error-404-styles.I0NYw-Bn.mjs +8 -0
- package/.output/server/chunks/build/error-404-styles.I0NYw-Bn.mjs.map +1 -0
- package/.output/server/chunks/build/{error-500-DhIQ-2yt.mjs → error-500-DIIFf55p.mjs} +10 -4
- package/.output/server/chunks/build/error-500-DIIFf55p.mjs.map +1 -0
- package/.output/server/chunks/build/error-500-styles.D1cs9hQy.mjs +8 -0
- package/.output/server/chunks/build/error-500-styles.D1cs9hQy.mjs.map +1 -0
- package/.output/server/chunks/build/index-CB1N4gax.mjs +557 -0
- package/.output/server/chunks/build/index-CB1N4gax.mjs.map +1 -0
- package/.output/server/chunks/build/server.mjs +326 -248
- package/.output/server/chunks/build/server.mjs.map +1 -1
- package/.output/server/chunks/build/styles.mjs +4 -4
- package/.output/server/chunks/nitro/nitro.mjs +2302 -835
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/editor-types.get.mjs +44 -0
- package/.output/server/chunks/routes/api/editor-types.get.mjs.map +1 -0
- package/.output/server/chunks/routes/api/parse.post.mjs +26 -1316
- package/.output/server/chunks/routes/api/parse.post.mjs.map +1 -1
- package/.output/server/chunks/routes/api/resolve.get.mjs +6 -0
- package/.output/server/chunks/routes/api/resolve.get.mjs.map +1 -1
- package/.output/server/chunks/routes/api/studio/run.post.mjs +35 -0
- package/.output/server/chunks/routes/api/studio/run.post.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +1 -1
- package/.output/server/chunks/routes/renderer.mjs.map +1 -1
- package/.output/server/index.mjs +7 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/acorn/dist/acorn.mjs +6266 -0
- package/.output/server/node_modules/acorn/package.json +50 -0
- package/.output/server/node_modules/ip-address/dist/common.js +112 -4
- package/.output/server/node_modules/ip-address/dist/ipv4.js +322 -87
- package/.output/server/node_modules/ip-address/dist/ipv6.js +654 -199
- package/.output/server/node_modules/ip-address/dist/v4/constants.js +45 -2
- package/.output/server/node_modules/ip-address/dist/v6/constants.js +55 -3
- package/.output/server/node_modules/ip-address/dist/v6/helpers.js +12 -3
- package/.output/server/node_modules/ip-address/package.json +49 -37
- package/.output/server/node_modules/ufo/dist/index.mjs +2 -2
- package/.output/server/node_modules/ufo/package.json +9 -9
- package/.output/server/package.json +4 -3
- package/README.md +62 -19
- package/app/assets/css/main.css +1 -0
- package/app/assets/css/studio.css +131 -0
- package/app/components/StudioConversion.vue +41 -0
- package/app/components/StudioDataPanel.vue +21 -0
- package/app/components/StudioEditor.vue +78 -102
- package/app/components/StudioExpandButton.vue +11 -0
- package/app/components/StudioOutput.vue +7 -1
- package/app/components/StudioSourcePanel.vue +16 -0
- package/app/components/StudioValidation.vue +47 -0
- package/app/components/ZodMongooseStudio.vue +216 -198
- package/app/composables/useStudioRunner.ts +142 -0
- package/app/pages/index.vue +1 -1
- package/app/plugins/monaco.client.ts +2 -0
- package/bin/index.mjs +5 -0
- package/nuxt.config.ts +4 -3
- package/package.json +4 -2
- package/server/api/editor-types.get.ts +28 -0
- package/server/api/parse.post.ts +17 -175
- package/server/api/studio/run.post.ts +17 -0
- package/server/middleware/security.ts +29 -7
- package/server/utils/example-data.ts +80 -0
- package/server/utils/parse-request.ts +28 -0
- package/server/utils/runner-client.ts +40 -0
- package/server/utils/studio-execution.ts +176 -0
- package/.output/public/_nuxt/BD40YYqZ.js +0 -33
- package/.output/public/_nuxt/BlQmLjV4.js +0 -1
- package/.output/public/_nuxt/CJ4Cv9fY.js +0 -61
- package/.output/public/_nuxt/builds/meta/34871c14-b0f4-4898-9ff0-debaff743355.json +0 -1
- package/.output/public/_nuxt/error-404.64pZEiDn.css +0 -1
- package/.output/public/_nuxt/error-500.DHOpI0Ir.css +0 -1
- package/.output/public/_nuxt/rH_O4qXT.js +0 -1
- package/.output/server/chunks/build/error-404-BN-7rNE4.mjs.map +0 -1
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs +0 -8
- package/.output/server/chunks/build/error-404-styles.Byx46oLR.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-DhIQ-2yt.mjs.map +0 -1
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs +0 -8
- package/.output/server/chunks/build/error-500-styles.BL3UT0Wa.mjs.map +0 -1
- package/.output/server/chunks/build/index-B4T6zHp0.mjs +0 -1904
- package/.output/server/chunks/build/index-B4T6zHp0.mjs.map +0 -1
- package/.output/server/node_modules/zod/index.js +0 -4
- /package/.output/public/_nuxt/{editor.CdBKkuhR.css → monaco.CdBKkuhR.css} +0 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import { _ as _export_sfc, c as useRuntimeConfig, b as __nuxt_component_0$3 } from './server.mjs';
|
|
2
|
+
import { mergeProps, defineComponent, ref, shallowRef, unref, isRef, withCtx, createVNode, watch, nextTick, useModel, mergeModels, computed, useSSRContext } from 'vue';
|
|
3
|
+
import { ssrRenderComponent, ssrRenderAttrs, ssrInterpolate, ssrIncludeBooleanAttr, ssrRenderClass, ssrRenderAttr, ssrRenderList, ssrRenderSlot } from 'vue/server-renderer';
|
|
4
|
+
import '../nitro/nitro.mjs';
|
|
5
|
+
import 'node:http';
|
|
6
|
+
import 'node:vm';
|
|
7
|
+
import 'esbuild';
|
|
8
|
+
import 'node:util';
|
|
9
|
+
import 'acorn';
|
|
10
|
+
import 'zod/v4';
|
|
11
|
+
import 'mongoose';
|
|
12
|
+
import 'node:https';
|
|
13
|
+
import 'node:events';
|
|
14
|
+
import 'node:buffer';
|
|
15
|
+
import 'node:fs';
|
|
16
|
+
import 'node:path';
|
|
17
|
+
import 'node:crypto';
|
|
18
|
+
import 'node:url';
|
|
19
|
+
import '@iconify/utils';
|
|
20
|
+
import 'consola';
|
|
21
|
+
import 'tailwindcss/colors';
|
|
22
|
+
import 'perfect-debounce';
|
|
23
|
+
import '../routes/renderer.mjs';
|
|
24
|
+
import 'vue-bundle-renderer/runtime';
|
|
25
|
+
import 'unhead/server';
|
|
26
|
+
import 'devalue';
|
|
27
|
+
import 'unhead/utils';
|
|
28
|
+
|
|
29
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
30
|
+
__name: "StudioSourcePanel",
|
|
31
|
+
__ssrInlineRender: true,
|
|
32
|
+
props: {
|
|
33
|
+
"modelValue": { required: true },
|
|
34
|
+
"modelModifiers": {}
|
|
35
|
+
},
|
|
36
|
+
emits: ["update:modelValue"],
|
|
37
|
+
setup(__props) {
|
|
38
|
+
useModel(__props, "modelValue");
|
|
39
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
40
|
+
const _component_ClientOnly = __nuxt_component_0$3;
|
|
41
|
+
_push(`<section${ssrRenderAttrs(mergeProps({
|
|
42
|
+
class: "studio-card studio-schema",
|
|
43
|
+
"aria-labelledby": "schema-title"
|
|
44
|
+
}, _attrs))}><div class="studio-card-head"><div class="studio-card-heading"><div><p class="studio-eyebrow">TypeScript</p><h2 id="schema-title">Schema</h2></div></div>`);
|
|
45
|
+
ssrRenderSlot(_ctx.$slots, "actions", {}, null, _push, _parent);
|
|
46
|
+
_push(`</div><div class="studio-editor-surface">`);
|
|
47
|
+
_push(ssrRenderComponent(_component_ClientOnly, null, {}, _parent));
|
|
48
|
+
_push(`</div><div class="studio-card-foot">Use <code>z</code> and zod-mongoose helpers directly. You can define multiple schemas.</div></section>`);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
const _sfc_setup$6 = _sfc_main$6.setup;
|
|
53
|
+
_sfc_main$6.setup = (props, ctx) => {
|
|
54
|
+
const ssrContext = useSSRContext();
|
|
55
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/StudioSourcePanel.vue");
|
|
56
|
+
return _sfc_setup$6 ? _sfc_setup$6(props, ctx) : void 0;
|
|
57
|
+
};
|
|
58
|
+
const __nuxt_component_0$1 = Object.assign(_sfc_main$6, { __name: "StudioSourcePanel" });
|
|
59
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
60
|
+
__name: "StudioExpandButton",
|
|
61
|
+
__ssrInlineRender: true,
|
|
62
|
+
props: {
|
|
63
|
+
expanded: { type: Boolean },
|
|
64
|
+
label: {}
|
|
65
|
+
},
|
|
66
|
+
emits: ["toggle"],
|
|
67
|
+
setup(__props, { emit: __emit }) {
|
|
68
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
69
|
+
_push(`<button${ssrRenderAttrs(mergeProps({
|
|
70
|
+
type: "button",
|
|
71
|
+
class: "studio-expand-button",
|
|
72
|
+
"aria-label": __props.expanded ? `Restore ${__props.label}` : `Expand ${__props.label}`,
|
|
73
|
+
title: __props.expanded ? "Restore panel" : "Expand panel"
|
|
74
|
+
}, _attrs))}>`);
|
|
75
|
+
if (__props.expanded) {
|
|
76
|
+
_push(`<svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M7 2v5H2m16 6h-5v5M2 7l5-5m6 16 5-5"></path></svg>`);
|
|
77
|
+
} else {
|
|
78
|
+
_push(`<svg viewBox="0 0 20 20" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.6" aria-hidden="true"><path d="M2 7V2h5m6 16h5v-5M2 2l5 5m6 6 5 5"></path></svg>`);
|
|
79
|
+
}
|
|
80
|
+
_push(`</button>`);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const _sfc_setup$5 = _sfc_main$5.setup;
|
|
85
|
+
_sfc_main$5.setup = (props, ctx) => {
|
|
86
|
+
const ssrContext = useSSRContext();
|
|
87
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/StudioExpandButton.vue");
|
|
88
|
+
return _sfc_setup$5 ? _sfc_setup$5(props, ctx) : void 0;
|
|
89
|
+
};
|
|
90
|
+
const __nuxt_component_1 = Object.assign(_sfc_main$5, { __name: "StudioExpandButton" });
|
|
91
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
92
|
+
__name: "StudioDataPanel",
|
|
93
|
+
__ssrInlineRender: true,
|
|
94
|
+
props: /* @__PURE__ */ mergeModels({
|
|
95
|
+
isRunning: { type: Boolean },
|
|
96
|
+
canRun: { type: Boolean }
|
|
97
|
+
}, {
|
|
98
|
+
"modelValue": { required: true },
|
|
99
|
+
"modelModifiers": {}
|
|
100
|
+
}),
|
|
101
|
+
emits: /* @__PURE__ */ mergeModels(["loadExample"], ["update:modelValue"]),
|
|
102
|
+
setup(__props, { emit: __emit }) {
|
|
103
|
+
useModel(__props, "modelValue");
|
|
104
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
105
|
+
const _component_ClientOnly = __nuxt_component_0$3;
|
|
106
|
+
_push(`<section${ssrRenderAttrs(mergeProps({
|
|
107
|
+
class: "studio-card studio-data",
|
|
108
|
+
"aria-labelledby": "data-title"
|
|
109
|
+
}, _attrs))}><div class="studio-card-head"><div class="studio-card-heading"><div><p class="studio-eyebrow">JSON</p><h2 id="data-title">Input data</h2></div></div><div class="studio-card-actions"><button type="button" class="studio-example-button"${ssrIncludeBooleanAttr(__props.isRunning || !__props.canRun) ? " disabled" : ""}>Load example</button>`);
|
|
110
|
+
ssrRenderSlot(_ctx.$slots, "actions", {}, null, _push, _parent);
|
|
111
|
+
_push(`</div></div><div class="studio-editor-surface">`);
|
|
112
|
+
_push(ssrRenderComponent(_component_ClientOnly, null, {}, _parent));
|
|
113
|
+
_push(`</div><div class="studio-card-foot">Enter a JSON value, then run to see what Zod returns.</div></section>`);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const _sfc_setup$4 = _sfc_main$4.setup;
|
|
118
|
+
_sfc_main$4.setup = (props, ctx) => {
|
|
119
|
+
const ssrContext = useSSRContext();
|
|
120
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/StudioDataPanel.vue");
|
|
121
|
+
return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
|
|
122
|
+
};
|
|
123
|
+
const __nuxt_component_2 = Object.assign(_sfc_main$4, { __name: "StudioDataPanel" });
|
|
124
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
125
|
+
__name: "StudioValidation",
|
|
126
|
+
__ssrInlineRender: true,
|
|
127
|
+
props: {
|
|
128
|
+
result: {},
|
|
129
|
+
stale: { type: Boolean }
|
|
130
|
+
},
|
|
131
|
+
setup(__props) {
|
|
132
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
133
|
+
_push(`<section${ssrRenderAttrs(mergeProps({
|
|
134
|
+
class: "studio-card studio-validation",
|
|
135
|
+
"aria-labelledby": "validation-title"
|
|
136
|
+
}, _attrs))}><div class="studio-card-head"><div class="studio-card-heading"><div><p class="studio-eyebrow">Zod</p><h2 id="validation-title">Validation</h2></div></div><div class="studio-card-actions">`);
|
|
137
|
+
if (__props.stale) {
|
|
138
|
+
_push(`<span class="studio-status studio-status-stale">Edited</span>`);
|
|
139
|
+
} else if (__props.result.status === "valid") {
|
|
140
|
+
_push(`<span class="studio-status studio-status-valid">Valid</span>`);
|
|
141
|
+
} else if (__props.result.status === "invalid" || __props.result.status === "json-error" || __props.result.status === "parse-error") {
|
|
142
|
+
_push(`<span class="studio-status studio-status-invalid">Invalid</span>`);
|
|
143
|
+
} else {
|
|
144
|
+
_push(`<span class="studio-status">Ready</span>`);
|
|
145
|
+
}
|
|
146
|
+
ssrRenderSlot(_ctx.$slots, "actions", {}, null, _push, _parent);
|
|
147
|
+
_push(`</div></div><div class="studio-validation-body">`);
|
|
148
|
+
if (__props.result.status === "valid") {
|
|
149
|
+
_push(`<div class="studio-result-intro"><span class="studio-result-icon studio-result-icon-valid">✓</span><div><strong>Parsed successfully</strong><p>Defaults, transforms and stripped fields appear below.</p></div></div>`);
|
|
150
|
+
} else if (__props.result.status === "invalid") {
|
|
151
|
+
_push(`<div class="studio-result-intro"><span class="studio-result-icon studio-result-icon-invalid">!</span><div><strong>${ssrInterpolate(__props.result.issues?.length)} validation issue${ssrInterpolate(__props.result.issues?.length === 1 ? "" : "s")}</strong><p>Update the JSON input and run again.</p></div></div>`);
|
|
152
|
+
} else {
|
|
153
|
+
_push(`<div class="studio-result-intro"><span class="studio-result-icon">{ }</span><div><strong>${ssrInterpolate(__props.result.status === "json-error" ? "JSON could not be read" : __props.result.status === "parse-error" ? "Validation could not run" : "Ready to validate")}</strong><p>${ssrInterpolate(__props.result.message)}</p></div></div>`);
|
|
154
|
+
}
|
|
155
|
+
if (__props.result.status === "valid") {
|
|
156
|
+
_push(`<pre class="studio-parsed" aria-label="Parsed data">${ssrInterpolate(__props.result.parsed)}</pre>`);
|
|
157
|
+
} else if (__props.result.status === "invalid") {
|
|
158
|
+
_push(`<ul class="studio-issues"><!--[-->`);
|
|
159
|
+
ssrRenderList(__props.result.issues, (issue, index2) => {
|
|
160
|
+
_push(`<li><code>${ssrInterpolate(issue.path)}</code><span>${ssrInterpolate(issue.message)}</span></li>`);
|
|
161
|
+
});
|
|
162
|
+
_push(`<!--]--></ul>`);
|
|
163
|
+
} else {
|
|
164
|
+
_push(`<!---->`);
|
|
165
|
+
}
|
|
166
|
+
_push(`</div></section>`);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const _sfc_setup$3 = _sfc_main$3.setup;
|
|
171
|
+
_sfc_main$3.setup = (props, ctx) => {
|
|
172
|
+
const ssrContext = useSSRContext();
|
|
173
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/StudioValidation.vue");
|
|
174
|
+
return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
|
|
175
|
+
};
|
|
176
|
+
const __nuxt_component_3 = Object.assign(_sfc_main$3, { __name: "StudioValidation" });
|
|
177
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
178
|
+
__name: "StudioConversion",
|
|
179
|
+
__ssrInlineRender: true,
|
|
180
|
+
props: {
|
|
181
|
+
result: {}
|
|
182
|
+
},
|
|
183
|
+
setup(__props) {
|
|
184
|
+
const props = __props;
|
|
185
|
+
const active = shallowRef("definition");
|
|
186
|
+
const views = [
|
|
187
|
+
{ key: "definition", label: "Definition" },
|
|
188
|
+
{ key: "obj", label: ".obj" },
|
|
189
|
+
{ key: "tree", label: ".tree" },
|
|
190
|
+
{ key: "paths", label: ".paths" }
|
|
191
|
+
];
|
|
192
|
+
computed(() => {
|
|
193
|
+
if (props.result.error) return `// Conversion error
|
|
194
|
+
${props.result.error}`;
|
|
195
|
+
switch (active.value) {
|
|
196
|
+
case "definition":
|
|
197
|
+
return props.result.definition || "// Run a schema to see its Mongoose definition.";
|
|
198
|
+
case "obj":
|
|
199
|
+
return props.result.schemaObj || "// No schema object yet.";
|
|
200
|
+
case "tree":
|
|
201
|
+
return props.result.schemaTree || "// No schema tree yet.";
|
|
202
|
+
case "paths":
|
|
203
|
+
return props.result.schemaPaths || "// No schema paths yet.";
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
207
|
+
const _component_ClientOnly = __nuxt_component_0$3;
|
|
208
|
+
_push(`<section${ssrRenderAttrs(mergeProps({
|
|
209
|
+
class: "studio-card studio-conversion",
|
|
210
|
+
"aria-labelledby": "conversion-title"
|
|
211
|
+
}, _attrs))}><div class="studio-card-head"><div class="studio-card-heading"><div><p class="studio-eyebrow">Mongoose</p><h2 id="conversion-title">Schema output</h2></div></div>`);
|
|
212
|
+
ssrRenderSlot(_ctx.$slots, "actions", {}, null, _push, _parent);
|
|
213
|
+
_push(`</div><div class="studio-tabs" role="tablist" aria-label="Mongoose output view"><!--[-->`);
|
|
214
|
+
ssrRenderList(views, (view) => {
|
|
215
|
+
_push(`<button type="button" role="tab"${ssrRenderAttr("aria-selected", active.value === view.key)} class="${ssrRenderClass({ "is-active": active.value === view.key })}">${ssrInterpolate(view.label)}</button>`);
|
|
216
|
+
});
|
|
217
|
+
_push(`<!--]--></div><div class="studio-conversion-output" role="tabpanel">`);
|
|
218
|
+
_push(ssrRenderComponent(_component_ClientOnly, null, {}, _parent));
|
|
219
|
+
_push(`</div></section>`);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
const _sfc_setup$2 = _sfc_main$2.setup;
|
|
224
|
+
_sfc_main$2.setup = (props, ctx) => {
|
|
225
|
+
const ssrContext = useSSRContext();
|
|
226
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/StudioConversion.vue");
|
|
227
|
+
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
|
|
228
|
+
};
|
|
229
|
+
const __nuxt_component_4 = Object.assign(_sfc_main$2, { __name: "StudioConversion" });
|
|
230
|
+
function useStudioRunner() {
|
|
231
|
+
const config = useRuntimeConfig();
|
|
232
|
+
const sourceCode = shallowRef(`// z and every @nullix/zod-mongoose helper are ready to use.
|
|
233
|
+
const UserSchema = z.object({
|
|
234
|
+
name: z.string().trim().min(2),
|
|
235
|
+
email: z.email(),
|
|
236
|
+
age: z.number().int().min(18).optional(),
|
|
237
|
+
role: z.enum(['reader', 'admin']).default('reader'),
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
const PostSchema = z.object({
|
|
241
|
+
title: z.string().min(1),
|
|
242
|
+
published: z.boolean().default(false),
|
|
243
|
+
});`);
|
|
244
|
+
const inputData = shallowRef(`{
|
|
245
|
+
"name": " Ada Lovelace ",
|
|
246
|
+
"email": "ada@example.com",
|
|
247
|
+
"age": 28
|
|
248
|
+
}`);
|
|
249
|
+
const schemaNames = shallowRef([]);
|
|
250
|
+
const selectedSchema = shallowRef("");
|
|
251
|
+
const validation = shallowRef({ status: "empty", message: "Run the studio to see parsed data." });
|
|
252
|
+
const conversion = shallowRef({});
|
|
253
|
+
const isRunning = shallowRef(false);
|
|
254
|
+
const isDirty = shallowRef(false);
|
|
255
|
+
const hasRun = shallowRef(false);
|
|
256
|
+
const error = shallowRef("");
|
|
257
|
+
const exampleError = shallowRef("");
|
|
258
|
+
let debounceTimer;
|
|
259
|
+
let runId = 0;
|
|
260
|
+
async function run(action = "run") {
|
|
261
|
+
if (!config.public.isExecutionEnabled) return;
|
|
262
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
263
|
+
const currentRun = ++runId;
|
|
264
|
+
const submittedSource = sourceCode.value;
|
|
265
|
+
const submittedInput = inputData.value;
|
|
266
|
+
isRunning.value = true;
|
|
267
|
+
error.value = "";
|
|
268
|
+
exampleError.value = "";
|
|
269
|
+
try {
|
|
270
|
+
const response = await $fetch(config.public.isDocsMode ? "/api/studio/run" : "/api/parse", {
|
|
271
|
+
method: "POST",
|
|
272
|
+
body: {
|
|
273
|
+
sourceCode: submittedSource,
|
|
274
|
+
inputData: submittedInput,
|
|
275
|
+
selectedSchema: selectedSchema.value || void 0,
|
|
276
|
+
action
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
if (currentRun !== runId) return;
|
|
280
|
+
schemaNames.value = response.schemaNames;
|
|
281
|
+
hasRun.value = true;
|
|
282
|
+
selectedSchema.value = response.selectedSchema;
|
|
283
|
+
validation.value = response.validation;
|
|
284
|
+
conversion.value = response.conversion;
|
|
285
|
+
exampleError.value = response.exampleError || "";
|
|
286
|
+
if (response.example && sourceCode.value === submittedSource && inputData.value === submittedInput) inputData.value = response.example;
|
|
287
|
+
isDirty.value = sourceCode.value !== submittedSource || inputData.value !== submittedInput && inputData.value !== response.example;
|
|
288
|
+
} catch (caught) {
|
|
289
|
+
if (currentRun !== runId) return;
|
|
290
|
+
error.value = caught.data?.message || caught.message || "The studio could not run this schema.";
|
|
291
|
+
validation.value = { status: "empty", message: "Run the studio to see parsed data." };
|
|
292
|
+
conversion.value = {};
|
|
293
|
+
} finally {
|
|
294
|
+
if (currentRun === runId) isRunning.value = false;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function selectSchema(name) {
|
|
298
|
+
selectedSchema.value = name;
|
|
299
|
+
isDirty.value = true;
|
|
300
|
+
if (config.public.isExecutionEnabled) void run();
|
|
301
|
+
}
|
|
302
|
+
function saveSession() {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
watch(sourceCode, () => {
|
|
306
|
+
isDirty.value = true;
|
|
307
|
+
if (!config.public.isDocsMode) {
|
|
308
|
+
if (debounceTimer) clearTimeout(debounceTimer);
|
|
309
|
+
debounceTimer = setTimeout(() => void run(), 650);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
watch(inputData, () => {
|
|
313
|
+
isDirty.value = true;
|
|
314
|
+
}, { flush: "sync" });
|
|
315
|
+
watch([sourceCode, inputData, selectedSchema], saveSession, { flush: "sync" });
|
|
316
|
+
return {
|
|
317
|
+
sourceCode,
|
|
318
|
+
inputData,
|
|
319
|
+
schemaNames,
|
|
320
|
+
selectedSchema,
|
|
321
|
+
validation,
|
|
322
|
+
conversion,
|
|
323
|
+
isRunning,
|
|
324
|
+
isDirty,
|
|
325
|
+
hasRun,
|
|
326
|
+
error,
|
|
327
|
+
exampleError,
|
|
328
|
+
run,
|
|
329
|
+
selectSchema
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
333
|
+
__name: "ZodMongooseStudio",
|
|
334
|
+
__ssrInlineRender: true,
|
|
335
|
+
setup(__props) {
|
|
336
|
+
const config = useRuntimeConfig();
|
|
337
|
+
const root = ref(null);
|
|
338
|
+
const mobileView = shallowRef(
|
|
339
|
+
"schema"
|
|
340
|
+
);
|
|
341
|
+
const expandedPanel = shallowRef(null);
|
|
342
|
+
let transitioning = false;
|
|
343
|
+
const mobileViews = [
|
|
344
|
+
{ key: "schema", label: "Schema" },
|
|
345
|
+
{ key: "data", label: "Data" },
|
|
346
|
+
{ key: "result", label: "Result" },
|
|
347
|
+
{ key: "mongoose", label: "Mongoose" }
|
|
348
|
+
];
|
|
349
|
+
const {
|
|
350
|
+
sourceCode,
|
|
351
|
+
inputData,
|
|
352
|
+
schemaNames,
|
|
353
|
+
selectedSchema,
|
|
354
|
+
validation,
|
|
355
|
+
conversion,
|
|
356
|
+
isRunning,
|
|
357
|
+
isDirty,
|
|
358
|
+
hasRun,
|
|
359
|
+
error,
|
|
360
|
+
exampleError,
|
|
361
|
+
run
|
|
362
|
+
} = useStudioRunner();
|
|
363
|
+
function togglePanel(panel) {
|
|
364
|
+
if (transitioning) return;
|
|
365
|
+
const card = root.value?.querySelector(`.studio-${panel}`);
|
|
366
|
+
const change = () => {
|
|
367
|
+
expandedPanel.value = expandedPanel.value === panel ? null : panel;
|
|
368
|
+
};
|
|
369
|
+
if (card && "startViewTransition" in void 0) {
|
|
370
|
+
transitioning = true;
|
|
371
|
+
card.style.viewTransitionName = "studio-expanded-panel";
|
|
372
|
+
const transition = (void 0).startViewTransition(() => {
|
|
373
|
+
change();
|
|
374
|
+
return nextTick();
|
|
375
|
+
});
|
|
376
|
+
void transition.finished.finally(() => {
|
|
377
|
+
card.style.viewTransitionName = "";
|
|
378
|
+
transitioning = false;
|
|
379
|
+
});
|
|
380
|
+
} else change();
|
|
381
|
+
}
|
|
382
|
+
return (_ctx, _push, _parent, _attrs) => {
|
|
383
|
+
const _component_StudioSourcePanel = __nuxt_component_0$1;
|
|
384
|
+
const _component_StudioExpandButton = __nuxt_component_1;
|
|
385
|
+
const _component_StudioDataPanel = __nuxt_component_2;
|
|
386
|
+
const _component_StudioValidation = __nuxt_component_3;
|
|
387
|
+
const _component_StudioConversion = __nuxt_component_4;
|
|
388
|
+
_push(`<div${ssrRenderAttrs(mergeProps({
|
|
389
|
+
ref_key: "root",
|
|
390
|
+
ref: root,
|
|
391
|
+
class: ["studio-shell", {
|
|
392
|
+
"studio-shell-docs": unref(config).public.isDocsMode,
|
|
393
|
+
"is-focused": expandedPanel.value
|
|
394
|
+
}]
|
|
395
|
+
}, _attrs))}><header class="studio-header"><div class="studio-brand"><div><p class="studio-eyebrow">@nullix/zod-mongoose</p><h1>Studio</h1></div></div><div class="studio-header-actions"><span class="studio-mode">${ssrInterpolate(unref(config).public.isDocsMode ? "Playground" : "Local mode")}</span><span class="studio-shortcut" aria-hidden="true">⌘ / Ctrl + S or R</span><button type="button" class="studio-run"${ssrIncludeBooleanAttr(unref(isRunning) || !unref(config).public.isExecutionEnabled) ? " disabled" : ""}>${ssrInterpolate(unref(isRunning) ? "Running…" : "Run")}</button></div></header><div class="studio-subbar"><div class="studio-subbar-copy"><span class="${ssrRenderClass([{ "is-busy": unref(isRunning), error: unref(error) }, "studio-pulse"])}"></span><span>${ssrInterpolate(unref(isRunning) ? "Working through your schema…" : unref(error) ? "Run failed" : !unref(hasRun) ? "Waiting for first run" : unref(isDirty) ? "Changes ready to run" : "Schema and data in sync")}</span></div><label class="studio-schema-picker"><span>ACTIVE SCHEMA</span><select${ssrRenderAttr("value", unref(selectedSchema))}${ssrIncludeBooleanAttr(unref(schemaNames).length < 2) ? " disabled" : ""} aria-label="Active schema">`);
|
|
396
|
+
if (!unref(schemaNames).length) {
|
|
397
|
+
_push(`<option value=""> Run to find schemas </option>`);
|
|
398
|
+
} else {
|
|
399
|
+
_push(`<!---->`);
|
|
400
|
+
}
|
|
401
|
+
_push(`<!--[-->`);
|
|
402
|
+
ssrRenderList(unref(schemaNames), (name) => {
|
|
403
|
+
_push(`<option${ssrRenderAttr("value", name)}>${ssrInterpolate(name)}</option>`);
|
|
404
|
+
});
|
|
405
|
+
_push(`<!--]--></select></label></div><nav class="studio-mobile-nav" aria-label="Studio sections"><!--[-->`);
|
|
406
|
+
ssrRenderList(mobileViews, (view) => {
|
|
407
|
+
_push(`<button type="button" class="${ssrRenderClass({ "is-active": mobileView.value === view.key })}">${ssrInterpolate(view.label)}</button>`);
|
|
408
|
+
});
|
|
409
|
+
_push(`<!--]--></nav>`);
|
|
410
|
+
if (unref(error)) {
|
|
411
|
+
_push(`<div class="studio-error-banner" role="alert"><strong>Run failed</strong><span>${ssrInterpolate(unref(error))}</span></div>`);
|
|
412
|
+
} else {
|
|
413
|
+
_push(`<!---->`);
|
|
414
|
+
}
|
|
415
|
+
if (unref(exampleError)) {
|
|
416
|
+
_push(`<div class="studio-error-banner studio-example-banner" role="status"><strong>Example unavailable</strong><span>${ssrInterpolate(unref(exampleError))}</span></div>`);
|
|
417
|
+
} else {
|
|
418
|
+
_push(`<!---->`);
|
|
419
|
+
}
|
|
420
|
+
_push(`<main class="studio-workspace"><div class="studio-column studio-input-column">`);
|
|
421
|
+
_push(ssrRenderComponent(_component_StudioSourcePanel, {
|
|
422
|
+
modelValue: unref(sourceCode),
|
|
423
|
+
"onUpdate:modelValue": ($event) => isRef(sourceCode) ? sourceCode.value = $event : null,
|
|
424
|
+
class: {
|
|
425
|
+
"is-mobile-active": mobileView.value === "schema",
|
|
426
|
+
"is-expanded": expandedPanel.value === "schema"
|
|
427
|
+
}
|
|
428
|
+
}, {
|
|
429
|
+
actions: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
430
|
+
if (_push2) {
|
|
431
|
+
_push2(ssrRenderComponent(_component_StudioExpandButton, {
|
|
432
|
+
label: "schema editor",
|
|
433
|
+
expanded: expandedPanel.value === "schema",
|
|
434
|
+
onToggle: ($event) => togglePanel("schema")
|
|
435
|
+
}, null, _parent2, _scopeId));
|
|
436
|
+
} else {
|
|
437
|
+
return [
|
|
438
|
+
createVNode(_component_StudioExpandButton, {
|
|
439
|
+
label: "schema editor",
|
|
440
|
+
expanded: expandedPanel.value === "schema",
|
|
441
|
+
onToggle: ($event) => togglePanel("schema")
|
|
442
|
+
}, null, 8, ["expanded", "onToggle"])
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
}),
|
|
446
|
+
_: 1
|
|
447
|
+
}, _parent));
|
|
448
|
+
_push(ssrRenderComponent(_component_StudioDataPanel, {
|
|
449
|
+
modelValue: unref(inputData),
|
|
450
|
+
"onUpdate:modelValue": ($event) => isRef(inputData) ? inputData.value = $event : null,
|
|
451
|
+
"is-running": unref(isRunning),
|
|
452
|
+
"can-run": unref(config).public.isExecutionEnabled,
|
|
453
|
+
class: {
|
|
454
|
+
"is-mobile-active": mobileView.value === "data",
|
|
455
|
+
"is-expanded": expandedPanel.value === "data"
|
|
456
|
+
},
|
|
457
|
+
onLoadExample: ($event) => unref(run)("example")
|
|
458
|
+
}, {
|
|
459
|
+
actions: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
460
|
+
if (_push2) {
|
|
461
|
+
_push2(ssrRenderComponent(_component_StudioExpandButton, {
|
|
462
|
+
label: "data editor",
|
|
463
|
+
expanded: expandedPanel.value === "data",
|
|
464
|
+
onToggle: ($event) => togglePanel("data")
|
|
465
|
+
}, null, _parent2, _scopeId));
|
|
466
|
+
} else {
|
|
467
|
+
return [
|
|
468
|
+
createVNode(_component_StudioExpandButton, {
|
|
469
|
+
label: "data editor",
|
|
470
|
+
expanded: expandedPanel.value === "data",
|
|
471
|
+
onToggle: ($event) => togglePanel("data")
|
|
472
|
+
}, null, 8, ["expanded", "onToggle"])
|
|
473
|
+
];
|
|
474
|
+
}
|
|
475
|
+
}),
|
|
476
|
+
_: 1
|
|
477
|
+
}, _parent));
|
|
478
|
+
_push(`</div><div class="studio-column studio-output-column">`);
|
|
479
|
+
_push(ssrRenderComponent(_component_StudioValidation, {
|
|
480
|
+
class: ["studio-result", {
|
|
481
|
+
"is-mobile-active": mobileView.value === "result",
|
|
482
|
+
"is-expanded": expandedPanel.value === "result"
|
|
483
|
+
}],
|
|
484
|
+
result: unref(validation),
|
|
485
|
+
stale: unref(isDirty)
|
|
486
|
+
}, {
|
|
487
|
+
actions: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
488
|
+
if (_push2) {
|
|
489
|
+
_push2(ssrRenderComponent(_component_StudioExpandButton, {
|
|
490
|
+
label: "validation result",
|
|
491
|
+
expanded: expandedPanel.value === "result",
|
|
492
|
+
onToggle: ($event) => togglePanel("result")
|
|
493
|
+
}, null, _parent2, _scopeId));
|
|
494
|
+
} else {
|
|
495
|
+
return [
|
|
496
|
+
createVNode(_component_StudioExpandButton, {
|
|
497
|
+
label: "validation result",
|
|
498
|
+
expanded: expandedPanel.value === "result",
|
|
499
|
+
onToggle: ($event) => togglePanel("result")
|
|
500
|
+
}, null, 8, ["expanded", "onToggle"])
|
|
501
|
+
];
|
|
502
|
+
}
|
|
503
|
+
}),
|
|
504
|
+
_: 1
|
|
505
|
+
}, _parent));
|
|
506
|
+
_push(ssrRenderComponent(_component_StudioConversion, {
|
|
507
|
+
class: ["studio-mongoose", {
|
|
508
|
+
"is-mobile-active": mobileView.value === "mongoose",
|
|
509
|
+
"is-expanded": expandedPanel.value === "mongoose"
|
|
510
|
+
}],
|
|
511
|
+
result: unref(conversion)
|
|
512
|
+
}, {
|
|
513
|
+
actions: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
514
|
+
if (_push2) {
|
|
515
|
+
_push2(ssrRenderComponent(_component_StudioExpandButton, {
|
|
516
|
+
label: "Mongoose output",
|
|
517
|
+
expanded: expandedPanel.value === "mongoose",
|
|
518
|
+
onToggle: ($event) => togglePanel("mongoose")
|
|
519
|
+
}, null, _parent2, _scopeId));
|
|
520
|
+
} else {
|
|
521
|
+
return [
|
|
522
|
+
createVNode(_component_StudioExpandButton, {
|
|
523
|
+
label: "Mongoose output",
|
|
524
|
+
expanded: expandedPanel.value === "mongoose",
|
|
525
|
+
onToggle: ($event) => togglePanel("mongoose")
|
|
526
|
+
}, null, 8, ["expanded", "onToggle"])
|
|
527
|
+
];
|
|
528
|
+
}
|
|
529
|
+
}),
|
|
530
|
+
_: 1
|
|
531
|
+
}, _parent));
|
|
532
|
+
_push(`</div></main></div>`);
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
const _sfc_setup$1 = _sfc_main$1.setup;
|
|
537
|
+
_sfc_main$1.setup = (props, ctx) => {
|
|
538
|
+
const ssrContext = useSSRContext();
|
|
539
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/ZodMongooseStudio.vue");
|
|
540
|
+
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
|
|
541
|
+
};
|
|
542
|
+
const __nuxt_component_0 = Object.assign(_sfc_main$1, { __name: "ZodMongooseStudio" });
|
|
543
|
+
const _sfc_main = {};
|
|
544
|
+
function _sfc_ssrRender(_ctx, _push, _parent, _attrs) {
|
|
545
|
+
const _component_ZodMongooseStudio = __nuxt_component_0;
|
|
546
|
+
_push(ssrRenderComponent(_component_ZodMongooseStudio, mergeProps({ class: "studio-standalone" }, _attrs), null, _parent));
|
|
547
|
+
}
|
|
548
|
+
const _sfc_setup = _sfc_main.setup;
|
|
549
|
+
_sfc_main.setup = (props, ctx) => {
|
|
550
|
+
const ssrContext = useSSRContext();
|
|
551
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/index.vue");
|
|
552
|
+
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
553
|
+
};
|
|
554
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
|
|
555
|
+
|
|
556
|
+
export { index as default };
|
|
557
|
+
//# sourceMappingURL=index-CB1N4gax.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CB1N4gax.mjs","sources":["../../../../node_modules/.cache/nuxt/.nuxt/dist/server/_nuxt/index-CB1N4gax.js"],"names":["__nuxt_component_0$2"],"mappings":"","x_google_ignoreList":[0]}
|