silgi 0.2.0 → 0.2.2

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.
@@ -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.BLxo8kmF.mjs';
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';
@@ -3,7 +3,7 @@ import consola from 'consola';
3
3
 
4
4
  const name = "silgi";
5
5
  const type = "module";
6
- const version = "0.2.0";
6
+ const version = "0.2.2";
7
7
  const packageManager = "pnpm@9.15.1";
8
8
  const sideEffects = false;
9
9
  const exports = {
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.BLxo8kmF.mjs';
6
- export { e as createResolver, f as useHook, h as useShared } from './shared/silgi.BLxo8kmF.mjs';
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';
@@ -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 && typeof node === "object" && node.input && node.output) {
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
- const paramString = params.map((p) => `:${p}`).join("/");
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
- if (node && typeof node === "object") {
209
- for (const key in node) {
210
- if (!["router", "input", "output", "_def", "shape"].includes(key)) {
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "sideEffects": false,
6
6
  "exports": {
7
7
  ".": {