@joystick.js/node-canary 0.0.0-canary.410 → 0.0.0-canary.411

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.
@@ -1 +1 @@
1
- import p from"./get_value_from_object.js";import v from"./input_validators.js";import $ from"./is_array_path.js";import f from"../../lib/types.js";const y=(t=null,r="",s=!1)=>{if(r&&!f.is_string(r))throw new Error("path must be passed as a string");if(s||!s&&!f.is_object(t))return t;if(r.includes(".$.")){const[o]=r.split(".$.");return p(t,o)}return p(t,r)},j=(t="")=>{if(!t)return"";if(t&&!f.is_string(t))throw new Error("array_path must be a type of string");return t.split(".").pop()},g=({queue:t,rules:r,input:s,path:o,types_only_schema:n})=>{r&&r.type==="object"&&(t=d(t,r.properties,s,o)),r&&r.type==="array"&&f.is_object(r.element)&&(t=d(t,r.element,s,`${o}.$`));const e=$(o)?j(o):o;return console.log({path:o,path_to_value:e,input:s,input_value:y(s,e,n),rules:r}),{path:o,rules:r,input_value:y(s,e,n)}},d=(t=[],r={},s={},o="")=>{const n=!!(r.type&&v.types.includes(r.type));if(!n){const e=Object.entries(r||{});for(let i=0;i<e?.length;i+=1){const[l,c]=e[i];console.log({field:l,rules:c});const a=`${o?`${o}.${l}`:l}`,_=g({queue:t,rules:c,input:s,path:a,types_only_schema:n});t=[...t,_]}}if(n){const e=o,i=g({queue:t,rules:r,input:s,path:field,types_only_schema:n});t=[...t,i]}return t},m=async(t={},r={},s="")=>{const o=[],n=d([],r,t,s);return await Promise.all(n.flatMap(e=>Object.entries(e.rules||{}).flatMap(async([i,l])=>{const c=v.rules[i];if(c&&!e.path.includes(".$.")){const a=await c(l,e.input_value,e.path,m);if(a&&!a.valid)for(let _=0;_<a.errors.length;_+=1){const b=a.errors[_];o.push(b)}}}))),o};var M=m;export{M as default,y as handle_get_input_value};
1
+ import p from"./get_value_from_object.js";import v from"./input_validators.js";import $ from"./is_array_path.js";import f from"../../lib/types.js";const y=(t=null,r="",s=!1)=>{if(r&&!f.is_string(r))throw new Error("path must be passed as a string");if(s||!s&&!f.is_object(t))return t;if(r.includes(".$.")){const[o]=r.split(".$.");return p(t,o)}return p(t,r)},j=(t="")=>{if(!t)return"";if(t&&!f.is_string(t))throw new Error("array_path must be a type of string");return t.split(".").pop()},g=({queue:t,rules:r,input:s,path:o,types_only_schema:n})=>{r&&r.type==="object"&&(t=d(t,r.properties,s,o)),r&&r.type==="array"&&f.is_object(r.element)&&(t=d(t,r.element,s,`${o}.$`));const e=$(o)?j(o):o;return console.log({path:o,path_to_value:e,input:s,input_value:y(s,e,n),rules:r}),{path:o,rules:r,input_value:y(s,e,n)}},d=(t=[],r={},s={},o="")=>{const n=!!(r.type&&v.types.includes(r.type));if(!n){const e=Object.entries(r||{});for(let i=0;i<e?.length;i+=1){const[a,l]=e[i];console.log({field:a,rules:l});const c=`${o?`${o}.${a}`:a}`,_=g({queue:t,rules:l,input:s,path:a,types_only_schema:n});t=[...t,_]}}if(n){const e=o,i=g({queue:t,rules:r,input:s,path:field,types_only_schema:n});t=[...t,i]}return t},m=async(t={},r={},s="")=>{const o=[],n=d([],r,t,s);return await Promise.all(n.flatMap(e=>Object.entries(e.rules||{}).flatMap(async([i,a])=>{const l=v.rules[i];if(l&&!e.path.includes(".$.")){const c=await l(a,e.input_value,e.path,m);if(c&&!c.valid)for(let _=0;_<c.errors.length;_+=1){const b=c.errors[_];o.push(b)}}}))),o};var E=m;export{E as default,y as handle_get_input_value};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.410",
4
+ "version": "0.0.0-canary.411",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -88,7 +88,7 @@ const add_to_validation_queue = (
88
88
  queue,
89
89
  rules,
90
90
  input,
91
- path,
91
+ path: field,
92
92
  types_only_schema,
93
93
  });
94
94