cogsbox-shape 0.5.217 → 0.5.218

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.
@@ -117,31 +117,6 @@ function addValidationIssues(params, issues) {
117
117
  params.addZodErrors(issues);
118
118
  notifyValidationPaths(params.stateKey, issues.map((issue) => issue.path));
119
119
  }
120
- function setValidationIssues(stateKey, issues) {
121
- if (issues.length === 0)
122
- return;
123
- const store = getGlobalStore.getState();
124
- for (const issue of issues) {
125
- const currentMeta = store.getShadowMetadata(stateKey, issue.path) || {};
126
- store.setShadowMetadata(stateKey, issue.path, {
127
- ...currentMeta,
128
- validation: {
129
- status: "INVALID",
130
- errors: [
131
- {
132
- source: "client",
133
- message: issue.message,
134
- severity: "error",
135
- code: issue.code,
136
- },
137
- ],
138
- lastValidated: Date.now(),
139
- validatedValue: store.getShadowValue(stateKey, issue.path),
140
- },
141
- });
142
- }
143
- notifyValidationPaths(stateKey, issues.map((issue) => issue.path));
144
- }
145
120
  function issueMatchesSelectedKeys(issue, parentPath, selectedKeys) {
146
121
  const issuePath = issue.path.map(String);
147
122
  if (issuePath.length <= parentPath.length)
@@ -285,20 +260,10 @@ export function validateShapeKeys(box, params) {
285
260
  const clientSchema = entry?.validators?.client ?? entry?.schemas.client;
286
261
  if (!entry || !clientSchema)
287
262
  return { success: true, results: [] };
288
- const store = getGlobalStore.getState();
289
- const rootState = params.getState?.() ?? store.getShadowValue(params.stateKey, []);
263
+ const rootState = params.getState?.() ?? getGlobalStore.getState().getShadowValue(params.stateKey, []);
290
264
  const result = clientSchema.safeParse(rootState);
291
265
  const selectedKeys = params.keys ? new Set(params.keys) : null;
292
- const targetPaths = params.keys?.map((key) => [...params.path, key]) ??
293
- (result.success
294
- ? []
295
- : mapZodIssues(result.error.issues).map((issue) => issue.path));
296
266
  if (result.success) {
297
- clearValidationPaths({
298
- stateKey: params.stateKey,
299
- getState: () => rootState,
300
- addZodErrors: () => { },
301
- }, targetPaths);
302
267
  return {
303
268
  success: true,
304
269
  results: params.keys?.map((key) => ({
@@ -313,14 +278,6 @@ export function validateShapeKeys(box, params) {
313
278
  ? result.error.issues.filter((issue) => issueMatchesSelectedKeys(issue, params.path, selectedKeys))
314
279
  : result.error.issues;
315
280
  const mapped = mapZodIssues(issues);
316
- const activeKeys = new Set(mapped.map((issue) => pathKey(issue.path)));
317
- const stalePaths = targetPaths.filter((targetPath) => !activeKeys.has(pathKey(targetPath)));
318
- clearValidationPaths({
319
- stateKey: params.stateKey,
320
- getState: () => rootState,
321
- addZodErrors: () => { },
322
- }, stalePaths);
323
- setValidationIssues(params.stateKey, mapped);
324
281
  return {
325
282
  success: mapped.length === 0,
326
283
  results: params.keys?.map((key) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cogsbox-shape",
3
- "version": "0.5.217",
3
+ "version": "0.5.218",
4
4
  "description": "A TypeScript library for creating type-safe database schemas with Zod validation, SQL type definitions, and automatic client/server transformations. Unifies client, server, and database types through a single schema definition, with built-in support for relationships and serialization.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",