silgi 0.2.1 → 0.2.3
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/dist/chunks/generate.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { r as relativeWithDot } from '../shared/silgi.C0NIj2vN.mjs';
|
|
|
9
9
|
import { defu } from 'defu';
|
|
10
10
|
import { withTrailingSlash } from 'ufo';
|
|
11
11
|
import { resolvePath, resolve as resolve$1 } from 'mlly';
|
|
12
|
-
import { i as getDirectory, r as resolveSilgiModule, j as resolvePath$1, k as generateUris, m as generateSilgiStorageBaseType } from '../shared/silgi.
|
|
12
|
+
import { i as getDirectory, r as resolveSilgiModule, j as resolvePath$1, k as generateUris, m as generateSilgiStorageBaseType } from '../shared/silgi.BxA0HYd5.mjs';
|
|
13
13
|
import { readdir } from 'node:fs/promises';
|
|
14
14
|
import { consola } from 'consola';
|
|
15
15
|
import { globby } from 'globby';
|
package/dist/cli/index.mjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -2,8 +2,8 @@ import { createConsola } from 'consola';
|
|
|
2
2
|
import defu, { defu as defu$1 } from 'defu';
|
|
3
3
|
import { createHooks } from 'hookable';
|
|
4
4
|
import { applyDefaults } from 'untyped';
|
|
5
|
-
import { u as useSilgi, l as loadSilgiModuleInstance, p as parseURI, S as SilgiError, a as useStorage, n as normalizeResult, b as SilgiErrorCode, g as generateStorageKey, s as scanAction, c as createStorage, d as silgiCtx, t as tryUseSilgi } from './shared/silgi.
|
|
6
|
-
export { e as createResolver, f as useHook, h as useShared } from './shared/silgi.
|
|
5
|
+
import { u as useSilgi, l as loadSilgiModuleInstance, p as parseURI, S as SilgiError, a as useStorage, n as normalizeResult, b as SilgiErrorCode, g as generateStorageKey, s as scanAction, c as createStorage, d as silgiCtx, t as tryUseSilgi } from './shared/silgi.BxA0HYd5.mjs';
|
|
6
|
+
export { e as createResolver, f as useHook, h as useShared } from './shared/silgi.BxA0HYd5.mjs';
|
|
7
7
|
import satisfies from 'semver/functions/satisfies.js';
|
|
8
8
|
import { S as SilgiConfigSchema } from './shared/silgi.C0NIj2vN.mjs';
|
|
9
9
|
export { r as relativeWithDot } from './shared/silgi.C0NIj2vN.mjs';
|
|
@@ -280,6 +280,9 @@ class SilgiHelper {
|
|
|
280
280
|
...query,
|
|
281
281
|
...body
|
|
282
282
|
});
|
|
283
|
+
if (data.success) {
|
|
284
|
+
return data.data;
|
|
285
|
+
}
|
|
283
286
|
return {
|
|
284
287
|
path: event.path,
|
|
285
288
|
method: event.method,
|
|
@@ -150,25 +150,35 @@ const plugins = {
|
|
|
150
150
|
} catch {
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
|
-
}
|
|
153
|
+
},
|
|
154
|
+
internalKeys: ["_def", "shape"]
|
|
155
|
+
// Zod-specific internal keys
|
|
154
156
|
},
|
|
155
157
|
yup: {
|
|
156
158
|
name: "yup",
|
|
157
159
|
isSchemaType: (obj) => obj?._type !== undefined,
|
|
158
160
|
getRouterParams: (routerObj) => {
|
|
159
161
|
return routerObj?.fields ? Object.keys(routerObj.fields) : null;
|
|
160
|
-
}
|
|
162
|
+
},
|
|
163
|
+
internalKeys: ["_type", "fields"]
|
|
164
|
+
// Yup-specific internal keys
|
|
161
165
|
}
|
|
162
166
|
};
|
|
163
167
|
class SchemaValidatorRegistry {
|
|
168
|
+
currentValidator = null;
|
|
164
169
|
validators = [];
|
|
165
170
|
constructor(validationLibrary = "zod") {
|
|
166
171
|
this.setValidationLibrary(validationLibrary);
|
|
167
172
|
}
|
|
173
|
+
isInternalKey(key) {
|
|
174
|
+
if (!this.currentValidator) return false;
|
|
175
|
+
return this.currentValidator.internalKeys.includes(key);
|
|
176
|
+
}
|
|
168
177
|
setValidationLibrary(library) {
|
|
169
178
|
this.validators = [];
|
|
170
179
|
const plugin = plugins[library];
|
|
171
180
|
if (plugin) {
|
|
181
|
+
this.currentValidator = plugin;
|
|
172
182
|
this.register(plugin);
|
|
173
183
|
}
|
|
174
184
|
}
|
|
@@ -190,26 +200,23 @@ function traverseObject(silgi, obj, currentPath = []) {
|
|
|
190
200
|
schemaRegistry.setValidationLibrary(silgi.options.validationLibrary || "zod");
|
|
191
201
|
const uriMap = /* @__PURE__ */ new Map();
|
|
192
202
|
function traverse(node, path = []) {
|
|
193
|
-
if (node
|
|
203
|
+
if (!node || typeof node !== "object")
|
|
204
|
+
return;
|
|
205
|
+
if (path.length === 4) {
|
|
194
206
|
const basePath = path.join("/");
|
|
207
|
+
let paramString = "";
|
|
195
208
|
if (node.router) {
|
|
196
209
|
const params = schemaRegistry.getParams(node.router);
|
|
197
210
|
if (params?.length) {
|
|
198
|
-
|
|
199
|
-
uriMap.set(basePath, paramString);
|
|
200
|
-
} else {
|
|
201
|
-
uriMap.set(basePath, "");
|
|
211
|
+
paramString = params.map((p) => `:${p}`).join("/");
|
|
202
212
|
}
|
|
203
|
-
} else {
|
|
204
|
-
uriMap.set(basePath, "");
|
|
205
213
|
}
|
|
214
|
+
uriMap.set(basePath, paramString);
|
|
206
215
|
return;
|
|
207
216
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
traverse(node[key], [...path, key]);
|
|
212
|
-
}
|
|
217
|
+
for (const key in node) {
|
|
218
|
+
if (!schemaRegistry.isInternalKey(key)) {
|
|
219
|
+
traverse(node[key], [...path, key]);
|
|
213
220
|
}
|
|
214
221
|
}
|
|
215
222
|
}
|