@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
|
|
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