@formhaus/core 0.13.2 → 0.14.0
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/{check-definition-DuLExofm.d.ts → check-definition-DyiWqhEV.d.ts} +3 -3
- package/dist/chunk-5WADJMJJ.js +2 -0
- package/dist/chunk-5WADJMJJ.js.map +1 -0
- package/dist/chunk-5YPOS62Y.js +3 -0
- package/dist/chunk-5YPOS62Y.js.map +1 -0
- package/dist/chunk-CW5ZWCSD.js +2 -0
- package/dist/chunk-CW5ZWCSD.js.map +1 -0
- package/dist/chunk-QMT7RJ4T.js +3 -0
- package/dist/chunk-QMT7RJ4T.js.map +1 -0
- package/dist/chunk-QVA6DLYS.js +2 -0
- package/dist/chunk-QVA6DLYS.js.map +1 -0
- package/dist/chunk-REIX6ART.js +2 -0
- package/dist/chunk-REIX6ART.js.map +1 -0
- package/dist/chunk-TMO47L42.js +5 -0
- package/dist/chunk-TMO47L42.js.map +1 -0
- package/dist/cloud.d.ts +3 -3
- package/dist/cloud.js +1 -1
- package/dist/{controller-Ds_kbXSU.d.ts → controller-BJVYkMHT.d.ts} +1 -1
- package/dist/default-messages-E-nZe4Tc.d.ts +10 -0
- package/dist/{definition-B4OIy_wH.d.ts → definition-o4Y0OY6y.d.ts} +53 -6
- package/dist/fix.d.ts +38 -0
- package/dist/fix.js +3 -0
- package/dist/fix.js.map +1 -0
- package/dist/i18n.d.ts +4 -3
- package/dist/i18n.js +1 -1
- package/dist/i18n.js.map +1 -1
- package/dist/{runtime-BN2PuKD7.d.ts → index-BNGgMIbC.d.ts} +20 -6
- package/dist/index.d.ts +67 -11
- package/dist/index.js +1 -1
- package/dist/internal.d.ts +27 -7
- package/dist/internal.js +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/issues-Dua58e1J.d.ts +14 -0
- package/dist/server.d.ts +5 -5
- package/dist/server.iife.js +3 -3
- package/dist/server.iife.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/{validate-field-ND_UxoJU.d.ts → validate-field-CRR6GQBA.d.ts} +2 -2
- package/fixtures/submissions/choices.json +6 -26
- package/fixtures/submissions/groups.json +649 -0
- package/fixtures/submissions/messages.json +4 -16
- package/fixtures/submissions/show-conditions.json +2 -7
- package/fixtures/submissions/skip-routes.json +1 -3
- package/fixtures/submissions/skip.json +3 -9
- package/fixtures/submissions/special-types.json +2 -6
- package/package.json +10 -6
- package/schema/form-definition.schema.json +380 -19
- package/schema/form-translation.schema.json +79 -1
- package/style.css +103 -82
- package/dist/chunk-35SAVPYL.js +0 -2
- package/dist/chunk-35SAVPYL.js.map +0 -1
- package/dist/chunk-4UCHIIVE.js +0 -2
- package/dist/chunk-4UCHIIVE.js.map +0 -1
- package/dist/chunk-76YV4J3Q.js +0 -3
- package/dist/chunk-76YV4J3Q.js.map +0 -1
- package/dist/chunk-J5TQSLO3.js +0 -3
- package/dist/chunk-J5TQSLO3.js.map +0 -1
- package/dist/chunk-PBTYUSZR.js +0 -2
- package/dist/chunk-PBTYUSZR.js.map +0 -1
- package/dist/chunk-RN5GQHKN.js +0 -5
- package/dist/chunk-RN5GQHKN.js.map +0 -1
- package/dist/default-messages-yS4QtrYi.d.ts +0 -23
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {f as f$1}from'./chunk-QVA6DLYS.js';import {p,q as q$1,n,r,a,t,e,d,o}from'./chunk-5WADJMJJ.js';var N=class extends Error{constructor(n){super(`Invalid form definition:
|
|
2
|
+
${n.map(t=>t.message).join(`
|
|
3
|
+
`)}`),this.name="FormDefinitionError",this.issues=n;}},ee=e=>e.endsWith("?")?e:`${e}.`;function ne(e){return (n,t,i,o)=>({code:n,severity:e,path:t,message:`${t||"/"}: ${i}.${o?` ${ee(o)}`:""}`,...o&&{hint:ee(o)}})}var f=ne("error"),m=ne("warning");function x(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function nn(e){return e.severity==="error"}function k(e){if(e.length===1)return `Use ${JSON.stringify(e[0])}`;let n=e.slice(0,10).map(t=>JSON.stringify(t)).join(", ");return e.length>10?`Use one of: ${n}, ...`:`Use one of: ${n}`}function Ie(e,n){let t=Array.from({length:n.length+1},(i,o)=>o);for(let i=1;i<=e.length;i++){let o=[i];for(let s=1;s<=n.length;s++)o[s]=Math.min(t[s]+1,o[s-1]+1,t[s-1]+(e[i-1]===n[s-1]?0:1));t=o;}return t[n.length]}function S(e,n){let t=e.toLowerCase();return n.find(i=>i!==e&&Ie(t,i.toLowerCase())<=(i.length>4?2:1))}function q(e,n){let t=S(e,n);return t!==void 0?`Use ${JSON.stringify(t)}`:n.length?k(n):void 0}var te="1.1";function ie({formatVersion:e}){if(e===void 0)return [];let n=typeof e=="string"&&/^[1-9]\d*(\.\d+)?$/.test(e);return n&&parseInt(e,10)<=parseInt(te,10)?[]:[n?f("unsupported-format-version","/formatVersion",`format ${e} is not supported`,"Upgrade @formhaus/core"):f("invalid-type","/formatVersion","must be a version string",`Use "${te}"`)]}var A=a;function Ce({suggest:e},n,t){let i=Object.keys(n).filter(u=>u!=="field"),o=i.filter(u=>!A.includes(u)),s=o.map(u=>f("unknown-operator",`${t}/${x(u)}`,`"${u}" is not a condition operator`,e(u,[...A]))),r=i.length-o.length;if(r!==1&&!(r===0&&o.length)){let u=r?`the condition has ${r} operators`:"the condition has no operator";s.push(f("condition-operator-count",t,u,`Use exactly one of: ${A.join(", ")}`));}return s}function R(e,n,t,i,o){if(e.target(n,i))return [];let s=[...e.h].find(([,u])=>u.has(n));if(s)return [f("group-scope",t,`"${n}" is a field inside the group "${s[0]}"`,"Only fields of the same group can use it")];let r=[...i!==void 0?e.h.get(i)?.keys()??[]:[],...e.S].filter(u=>u!==o);return [f("unknown-field",t,`"${n}" is not a field key`,e.suggest(n,r))]}function xe(e,{condition:n,path:t,owner:i,step:o,key:s,group:r}){let u=e.target(n.field,r);if(!u)return R(e,n.field,`${t}/field`,r,s);if(u.group||o<0||i==="action")return [];let c=i==="step"?"this or a later step":"a later step";if(u.step<o||i!=="step"&&u.step===o)return [];let p=i==="step"?"earlier steps":"this or an earlier step";return [f("forward-reference",`${t}/field`,`"${n.field}" belongs to ${c}`,`${i==="route"?"Route":i==="step"?"Step":"Field"} conditions can use fields of ${p}`)]}function V(e,n){let{condition:t,path:i}=n;return typeof t.field!="string"?[f("missing-property",i,'missing required property "field"',"Add the key of the field to test")]:[...Ce(e,t,i),...xe(e,n)]}function oe(e){return e.conditions.flatMap(n=>V(e,n))}var _=e=>e.split("/fields/").length<=3,De={string:[e=>typeof e=="string","a string"],number:[e=>typeof e=="number"&&Number.isFinite(e),"a number"],boolean:[e=>typeof e=="boolean","true or false"],requirement:[e=>["boolean","string"].includes(typeof e),"true, false or a message string"],scalar:[e=>["string","number","boolean"].includes(typeof e),"a string, number or boolean"],list:[e=>Array.isArray(e)&&e.every(n=>["string","number"].includes(typeof n)),"an array of strings or numbers"]};function D(e,n,t){return Object.entries(n).flatMap(([i,o])=>{let[s,r]=De[o];return e[i]===void 0||s(e[i])?[]:[f("invalid-type",`${t}/${x(i)}`,`"${i}" must be ${r}`)]})}function E(e,n,t,i=f){return i("missing-property",e,`missing required property "${n}"`,t)}function b(e,n$1,t,i,o=false){return e==null&&!o?[]:e===void 0?[E(n$1.slice(0,n$1.lastIndexOf("/")),n$1.slice(n$1.lastIndexOf("/")+1))]:Array.isArray(e)?e.flatMap((s,r)=>n(s)?i(s,`${n$1}/${r}`):[f("invalid-type",`${n$1}/${r}`,`must be ${t}`)]):[f("invalid-type",n$1,"must be an array",o?"Use [] when there is nothing to list":void 0)]}function L(e,n,t){return e[n]===void 0?[E(t,n)]:typeof e[n]=="string"?[]:[f("invalid-type",`${t}/${x(n)}`,`"${n}" must be a string`)]}var W=(e,n)=>D(e,{field:"string",eq:"scalar",neq:"scalar",in:"list",notIn:"list",notEmpty:"boolean",gt:"number",gte:"number",lt:"number",lte:"number"},n);function G(e,n){return [...b(e.show,`${n}/show`,"a condition object",W),...b(e.showAny,`${n}/showAny`,"a condition object",W)]}function P(e,n$1){return n(e)?[...D(e,{label:"string"},n$1),...b(e.disabled,`${n$1}/disabled`,"a condition object",W)]:[]}var Ee=(e,n)=>[...L(e,"value",n),...D(e,{label:"string"},n)],ve={required:"requirement",minLength:"number",maxLength:"number",min:"number",max:"number",pattern:"string",matchField:"string",validator:"string",minLengthMessage:"string",maxLengthMessage:"string",minMessage:"string",maxMessage:"string",patternMessage:"string",matchFieldMessage:"string"};function Fe(e,n$1){return e===void 0?[]:n(e)?D(e,ve,n$1):[f("invalid-type",n$1,"must be an object of validation rules")]}function Me(e,n){return e===void 0||Array.isArray(e)&&e.every(i=>typeof i=="string")?[]:[f("invalid-type",n,"must be an array of field keys")]}var J=(e,n)=>{let t=(e.type==="section"||e.type==="group")&&_(n);return [...L(e,"key",n),...L(e,"type",n),...D(e,{label:"string",placeholder:"string",helperText:"string",title:"string",description:"string",itemLabel:"string",addLabel:"string",removeLabel:"string",defaultItems:"number"},n),...t?b(e.fields,`${n}/fields`,"a field object",J,true):[],...G(e,n),...b(e.options,`${n}/options`,"an option object",Ee),...Fe(e.validation,`${n}/validation`),...Me(e.optionsDependsOn,`${n}/optionsDependsOn`)]},Oe=(e,n)=>[...e.to===void 0?[E(n,"to")]:e.to===null||typeof e.to=="string"?[]:[f("invalid-type",`${n}/to`,'"to" must be a step id or null')],...G(e,n)],Se=(e,n)=>[...L(e,"id",n),...D(e,{title:"string",description:"string"},n),...b(e.fields,`${n}/fields`,"a field object",J,true),...G(e,n),...b(e.routes,`${n}/routes`,"a route object",Oe),...["next","back","skip"].flatMap(t=>P(e[t],`${n}/${t}`))];function re(e){if(!n(e))return [f("invalid-type","","the form definition must be an object")];let n$1=ie(e);return n$1.length?n$1:[...b(e.fields,"/fields","a field object",J),...b(e.steps,"/steps","a step object",Se),...P(e.submit,"/submit"),...P(e.cancel,"/cancel")]}var se='Add "submit": { "label": "Submit" }';function ue(e){return [...L(e,"id",""),...e.submit===void 0?[E("","submit",se)]:n(e.submit)?[]:[f("invalid-type","/submit","must be an action object",se)]]}function v(e,n,t,i,o,s,r){for(let u of i==="action"?["disabled"]:["show","showAny"])(n||{})[u]?.forEach((c,p)=>{e.push({condition:c,path:`${t}/${u}/${p}`,owner:i,step:o,key:s,group:r});});}function ae(e,n,t=()=>{}){let i=e.steps??[],o=[],s=(a,l,d,y,g)=>a.forEach((I,we)=>{let U=`${l}/${we}`;o.push({node:I,path:U,step:d,group:g,parent:y}),(p(I)||q$1(I))&&_(U)&&s(I.fields,`${U}/fields`,d,I,q$1(I)?I:g);});i.length?i.forEach((a,l)=>{s(a.fields,`/steps/${l}/fields`,l);}):s(e.fields??[],"/fields",-1);let r=o.flatMap(({node:a,path:l,step:d,group:y})=>p(a)?[]:[{field:a,path:l,step:d,group:y}]),u=new Map,c=new Map;for(let a of r){let l=a.group?c.get(a.group.key)??new Map:u;a.group&&c.set(a.group.key,l),l.has(a.field.key)||l.set(a.field.key,a);}let p$1=[];for(let{node:a,path:l,step:d,group:y}of o)v(p$1,a,l,"field",d,a.key,y?.key);return i.forEach((a,l)=>{v(p$1,a,`/steps/${l}`,"step",l),(a.routes??[]).forEach((d,y)=>{v(p$1,d,`/steps/${l}/routes/${y}`,"route",l);});for(let d of ["next","back","skip"])v(p$1,a[d],`/steps/${l}/${d}`,"action",l);}),v(p$1,e.submit,"/submit","action",-1),v(p$1,e.cancel,"/cancel","action",-1),{definition:e,nodes:o,entries:r,keys:u,S:[...u.keys()],h:c,conditions:p$1,validators:n,suggest:t,target:(a,l)=>l!==void 0&&c.get(l)?.get(a)||u.get(a)}}function fe(e,n,t,i){let o=e[t],s=e[i];return o===void 0||s===void 0||o<=s?[]:[f("invalid-range",`${n}/validation/${t}`,`${t} (${o}) is greater than ${i} (${s})`,`Lower ${t} or raise ${i}`)]}function Ae(e,n){if(e===void 0)return [];try{return new RegExp(e),[]}catch{return [f("invalid-pattern",`${n}/validation/pattern`,`${JSON.stringify(e)} is not a valid regular expression`,"Fix the pattern or escape special characters with a backslash")]}}function Re(e,{field:n,path:t,group:i}){let o=n.validation??{},s=o.matchField,r=n.type==="group"?n.defaultItems:void 0;return [...fe(o,t,"minLength","maxLength"),...fe(o,t,"min","max"),...Ae(o.pattern,t),...s===void 0?[]:R(e,s,`${t}/validation/matchField`,i?.key),...r!==void 0&&o.maxLength!==void 0&&r>o.maxLength?[f("invalid-range",`${t}/defaultItems`,`defaultItems (${r}) is greater than maxLength (${o.maxLength})`,"Lower defaultItems or raise maxLength")]:[]]}function Le({field:e,path:n}){let t=(e.options??[]).map(i=>i.value);return t.flatMap((i,o)=>t.indexOf(i)<o?[f("duplicate-option-value",`${n}/options/${o}/value`,`"${i}" is already an option value`)]:[])}function ce(e){return e.entries.flatMap(n=>[...Re(e,n),...Le(n)])}var K=({field:e,group:n})=>n?`${n.key}.${e.key}`:e.key;function Ne({definition:e,entries:n,nodes:t$1,target:i}){let o=new Map,s=(r,u,c)=>{let p=t(u).flatMap(a=>{let l=i(a,c);return l?[K(l)]:[]});if(p.length)for(let a of r)o.set(a,[...o.get(a)??[],...p]);};for(let r of n)s([K(r)],r.field,r.group?.key);for(let{node:r,group:u}of t$1)p(r)&&!u&&s(r.fields.map(c=>c.key),r);for(let r$1 of e.steps??[])s(r(r$1.fields).map(u=>u.key),r$1);return o}function je(e){let n=new Map,t=[];for(let i of e.keys()){if(n.has(i))continue;n.set(i,true);let o=[[i,0]];for(;o.length>0;){let s=o[o.length-1],r=e.get(s[0])?.[s[1]++];if(r===void 0)n.set(s[0],false),o.pop();else if(n.get(r)){let u=o.map(([c])=>c);t.push([...u.slice(u.indexOf(r)),r]);}else n.has(r)||(n.set(r,true),o.push([r,0]));}}return t}function le(e){let n=new Map(e.entries.map(t=>[K(t),t.path]));return je(Ne(e)).map(t=>f("condition-cycle",n.get(t[0]),`show conditions form a cycle: ${t.join(" -> ")}`,"Remove one of the conditions in the cycle"))}var pe='Use { "query": "<parameter name>" } for a URL parameter';function Ue(e,{field:n$1,path:t}){let i=n$1.source,o=`${t}/source`,s=f$1;if(typeof i=="string")return s.includes(i)?[]:[f("unknown-source",o,`"${i}" is not a source`,i==="query"?pe:e.suggest(i,s)??k(s))];let r=n(i)&&Object.keys(i).length===1?i.query:void 0;return i===void 0||typeof r=="string"&&r.trim()?[]:[f("invalid-type",o,"must be a source name or a query object",pe)]}function de(e){return e.entries.flatMap(n=>Ue(e,n))}function me({field:e,path:n}){return e.source===void 0||e.type==="hidden"?[]:[m("source-not-applicable",`${n}/source`,'only hidden fields read "source"','Set "type" to "hidden" or remove "source"')]}var j=e=>!!(e.show?.length||e.showAny?.length);function ge(e,n,t){let i=[];for(let o of e[t].routes??[]){let s=o.to===null?null:n.get(o.to);if(s===null&&!j(o))return i;if(!(s==null||s<=t)&&(i.push(s),!j(o)&&!j(e[s])))return i}return t+1<e.length?[...i,t+1]:i}function ye(e){let n=new Map(e.map((t,i)=>[t.id,i]));return e.map((t,i)=>{let o=new Set,s=ge(e,n,i);for(;s.length;){let r=s.pop();o.has(r)||(o.add(r),s.push(...ge(e,n,r)),j(e[r])&&r+1<e.length&&s.push(r+1));}return o})}var Te=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]);function qe({definition:e}){let n=[],t=e.steps??[],i=new Map;return t.forEach((o,s)=>{let r=i.get(o.id);r===void 0?i.set(o.id,s):n.push(f("duplicate-step-id",`/steps/${s}/id`,`step id "${o.id}" is already used by /steps/${r}`,"Give each step a unique id"));}),t.forEach((o,s)=>{(o.routes??[]).forEach((r,u)=>{if(r.to===null)return;let c=i.get(r.to);if(c!==void 0&&c>s)return;let p=t.slice(s+1).map(d=>d.id),a=c===void 0?`"${r.to}" is not a step id`:`"${r.to}" is not a later step`,l=p.length?`${k(p)}, or null to end the form here`:"Use null to end the form here";n.push(f("route-target",`/steps/${s}/routes/${u}/to`,a,l));});}),n}function Ve({definition:e,nodes:n}){let t=[],i=ye(e.steps??[]),o=(u,c)=>u.step!==c.step&&!i[u.step]?.has(c.step),s=n.filter(u=>!u.group),r=s.filter(u=>q$1(u.node));return n.forEach((u,c)=>{let{node:{key:p},path:a,group:l}=u,d=l?n.slice(0,c).find(g=>g.group===l&&g.node.key===p)??s.find(g=>g.node.key===p):s.slice(0,s.indexOf(u)).find(g=>g.node.key===p&&!o(g,u)),y=!l&&r.find(g=>p.startsWith(`${g.node.key}.`));Te.has(p)?t.push(f("reserved-key",`${a}/key`,`"${p}" is a built-in object property name`,"Rename the field key")):d?t.push(f("duplicate-key",`${a}/key`,`key "${p}" is already used by ${d.path}${l?"":" on the same path"}`,l?"Rename the field":"Rename one of the fields, or move them to route branches that never meet")):y&&t.push(f("duplicate-key",`${a}/key`,`key "${p}" starts with the group key "${y.node.key}."`,"Rename the field"));}),t}function We({nodes:e}){return e.flatMap(({node:n,path:t,group:i,parent:o})=>p(n)&&o||i&&["group","file","hidden"].includes(n.type)?[f("invalid-nesting",`${t}/type`,`a ${n.type} cannot be inside a ${o.type}`,"Move it to the fields of the step")]:[])}function he(e){let{definition:n}=e;return [...!!n.fields?.length&&!!n.steps?.length?[f("fields-and-steps","",'the definition has both "fields" and "steps"','Move the top-level fields into a step, or remove "steps"')]:[],...qe(e),...Ve(e),...We(e)]}var $={form:"$schema formatVersion id lang title description messages labels i18n submit cancel fields steps",step:"id title description fields show showAny routes next back skip i18n",field:"key type label placeholder helperText autoAdvance defaultValue source show showAny validation options layout optionsFrom optionsDependsOn accept rows mask inputMode i18n",section:"key type title description show showAny fields i18n",group:"key type label helperText itemLabel addLabel removeLabel defaultItems show showAny validation fields i18n",option:"value label i18n",action:"label variant disabled i18n",route:"to show showAny",validation:"required minLength minLengthMessage maxLength maxLengthMessage min minMessage max maxMessage pattern patternMessage matchField matchFieldMessage validator i18n"},$e="Add a label so screen readers can name the input";function w(e,n,t,i=()=>{}){let o=t.split(" "),s=o.filter(r=>!(r in e));return Object.keys(e).filter(r=>!o.includes(r)).map(r=>{let u=S(r,s),c=u===void 0?i(r):`Did you mean "${u}"?`;return m("unknown-property",`${n}/${x(r)}`,`unknown property "${r}"`,c)})}function F(e,n,t,i){return e[t]===void 0?[E(n,t,i,m)]:[]}function B(e,n$1){return n(e)?[...F(e,n$1,"label"),...w(e,n$1,$.action)]:[]}var Pe=e=>e!=="i18n"&&$.validation.split(" ").includes(e)?`Move "${e}" into "validation": { "${e}": ... }`:void 0;function _e({field:e,path:n$1}){let t=e.type!=="hidden",i=t&&typeof e.label=="string"&&!e.label.trim();return [...F(e,n$1,"label",t?$e:void 0),...i?[m("empty-label",`${n$1}/label`,`the label of "${e.key}" is empty`,$e)]:[],...w(e,n$1,e.type==="group"?$.group:$.field,Pe),...(e.options??[]).flatMap((o,s)=>[...F(o,`${n$1}/options/${s}`,"label"),...w(o,`${n$1}/options/${s}`,$.option)]),...n(e.validation)?w(e.validation,`${n$1}/validation`,$.validation):[]]}function be({definition:e,entries:n,nodes:t}){let{title:i}=e;return [...F(e,"","title","Add a title for host UI and editors"),...i===void 0||typeof i=="string"?[]:[m("invalid-type","/title",'"title" must be a string')],...w(e,"",$.form),...B(e.submit,"/submit"),...B(e.cancel,"/cancel"),...(e.steps??[]).flatMap((o,s)=>{let r=`/steps/${s}`;return [...F(o,r,"title"),...w(o,r,$.step),...(o.routes??[]).flatMap((u,c)=>w(u,`${r}/routes/${c}`,$.route)),...["next","back","skip"].flatMap(u=>B(o[u],`${r}/${u}`))]}),...t.flatMap(({node:o,path:s})=>o.type==="section"?[...F(o,s,"title"),...w(o,s,$.section)]:[]),...n.flatMap(_e)]}var Ge=["in","notIn"],Je=["gt","gte","lt","lte"];function Ke(e$1){return e$1.type==="number"?"number":d.includes(e$1.type)?"boolean":e.includes(e$1.type)&&e$1.type!=="multiselect"&&e$1.type!=="file"?"string":void 0}function Be(e,n,t,i){let o=(a,l)=>[m("condition-value-mismatch",i,a,l)];if(n==="notEmpty")return [];if(Je.includes(n))return e.type!=="multiselect"&&!d.includes(e.type)?[]:o(`"${e.key}" is a ${e.type} field, so "${n}" never matches it`,"Compare a number, text, radio or select field");if(e.type==="multiselect"){let a=n==="neq"||n==="notIn"?"always":"never";return o(`"${e.key}" holds a list of values, so "${n}" ${a} matches it`,"Use notEmpty, or a select or radio field")}let s=Ge.includes(n)&&Array.isArray(t)?t:[t],r=Ke(e),u=r&&s.find(a=>typeof a!==r);if(r&&u!==void 0)return o(`${JSON.stringify(u)} is a ${typeof u}, but "${e.key}" holds a ${r}`,`Use a ${r} value`);let c=r==="string"&&!e.optionsFrom&&e.options?.length?e.options.map(a=>a.value):null,p=c&&s.find(a=>!c.includes(a));return c&&p!==void 0?o(`${JSON.stringify(p)} is not an option of "${e.key}"`,k(c)):[]}function Ye(e,n){let{condition:t,path:i}=n;if(V(e,n).length)return [];let o=A.find(s=>s in t);return Be(e.target(t.field,n.group).field,o,t[o],`${i}/${o}`)}function ze({field:e,path:n}){if(!["select","radio","multiselect"].includes(e.type))return [];if(!Array.isArray(e.options))return e.optionsFrom?[]:[m("missing-options",`${n}/options`,`the ${e.type} field "${e.key}" has no options`,'Add "options" or "optionsFrom"')];let t=e.options.map(s=>s.value),i=e.type==="multiselect"&&Array.isArray(e.defaultValue)?e.defaultValue:[e.defaultValue],o=e.defaultValue===void 0||!t.length||e.optionsFrom?void 0:i.find(s=>!t.includes(s));return o===void 0?[]:[m("default-not-in-options",`${n}/defaultValue`,`${JSON.stringify(o)} is not an option of "${e.key}"`,k(t))]}function He(e){let n=[],t=false;for(let i=0;i<e.length&&e.length<=1e3;i++){let o=e[i];if(t&&"*+{".includes(o))return true;if(t=false,o==="\\")i++;else if(o==="[")for(i++;i<e.length&&e[i]!=="]";i++)e[i]==="\\"&&i++;else o==="("?(n.push(false),e[i+1]==="?"&&i++):o===")"?(t=!!n.pop(),t&&n.length&&(n[n.length-1]=true)):n.length&&"*+?|{".includes(o)&&(n[n.length-1]=true);}return false}function Qe(e$1,{field:n,path:t}){let i=n.validation??{},o$1=(d,y,g)=>m("rule-not-applicable",`${t}/validation/${d}`,y,g),s=n.type==="group",r=s||e.includes(n.type),u=n.type==="number",c=r&&!u?["min","max"].filter(d=>i[d]!==void 0):[],p=r&&["number","checkbox","switch"].includes(n.type)?["minLength","maxLength"].filter(d=>i[d]!==void 0):[],a=[...c.map(d=>o$1(d,`"${d}" applies to number fields only`,`Use ${d}Length to limit ${s?"the number of items":"text length"}`)),...p.map(d=>o$1(d,`"${d}" does not apply to ${n.type} fields`,u?"Use min and max for numbers":`Remove ${d}`))];typeof i.pattern=="string"&&He(i.pattern)&&a.push(m("slow-pattern",`${t}/validation/pattern`,`the pattern of "${n.key}" nests quantifiers and can be very slow`,"Remove the inner or outer quantifier"));let{validators:l}=e$1;return i.validator!==void 0&&l&&!o(l,i.validator)&&a.push(m("unknown-validator",`${t}/validation/validator`,`the validator "${i.validator}" is not registered`,'Pass it in the "validators" option')),a}function Xe(e$1,n){let{field:t,path:i}=n,o=e.includes(t.type)||t.type==="group"?void 0:S(t.type,[...e,"group","section"]);return [...o===void 0?[]:[m("unknown-field-type",`${i}/type`,`"${t.type}" is not a built-in field type`,`Use "${o}", or register a component for "${t.type}"`)],...ze(n),...Qe(e$1,n),...me(n),...(t.optionsDependsOn??[]).flatMap((s,r)=>R(e$1,s,`${i}/optionsDependsOn/${r}`).map(u=>({...u,severity:"warning"})))]}function Ze({definition:e}){let n=e.steps??[];return n.flatMap((t,i)=>{let o=[],s=new Set((t.routes??[]).map(r=>r.to).filter(r=>r!==null));for(let r of s){let u=n.findIndex(a=>a.id===r),c=n[u+1],p=n[u]?.routes?.some(a=>!a.show?.length&&!a.showAny?.length);!c||!s.has(c.id)||p||o.push(m("route-fallthrough",`/steps/${u}`,`branch "${r}" from "${t.id}" continues into the sibling branch "${c.id}"`,`Add an unconditional route on "${r}" to the step where the branches meet`));}return t.skip&&(t.next===false||!n[1])&&o.push(m("skip-unreachable",`/steps/${i}/skip`,`step "${t.id}" has "skip" but no Continue button or later step`,'Remove "skip", or remove "next": false')),o})}function en({definition:e,nodes:n}){let[t,i=0]=String(e.formatVersion??"1.0").split(".").map(Number),o=n.find(({node:s})=>s.type==="section"||s.type==="group");return !o||t!==1||i>=1?[]:[m("outdated-format-version","/formatVersion",`${o.path} is a ${o.node.type}, which needs format 1.1`,'Set "formatVersion": "1.1", so that older versions of @formhaus/core reject the definition instead of skipping the fields inside')]}function ke(e){return [...en(e),...be(e),...e.conditions.flatMap(n=>Ye(e,n)),...e.entries.flatMap(n=>Xe(e,n)),...Ze(e)]}function Y(e,{validators:n,suggest:t,warnings:i}={}){let o=re(e);if(o.length)return o;let s=ae(e,n,t);return [...ue(e),...he(s),...oe(s),...ce(s),...de(s),...le(s),...i?i(s):[]]}function Qn(e){return Y(e)}function Xn(e,n={}){return Y(e,{validators:n.validators,suggest:q,warnings:ke})}function Zn(e,n){let t=Y(e,{suggest:q});if(t.length)throw new N(t);return e}
|
|
4
|
+
export{N as a,f as b,m as c,x as d,nn as e,k as f,S as g,te as h,ae as i,Qn as j,Xn as k,Zn as l};//# sourceMappingURL=chunk-TMO47L42.js.map
|
|
5
|
+
//# sourceMappingURL=chunk-TMO47L42.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/definition-validation/issues.ts","../src/definition-validation/format.ts","../src/definition-validation/conditions.ts","../src/definition-validation/shape.ts","../src/definition-validation/context.ts","../src/definition-validation/fields.ts","../src/definition-validation/graph.ts","../src/definition-validation/sources.ts","../src/definition-validation/paths.ts","../src/definition-validation/structure.ts","../src/definition-validation/properties.ts","../src/definition-validation/warnings.ts","../src/definition-validation/check-definition.ts"],"names":["FormDefinitionError","issues","issue","sentence","text","create","severity","code","path","problem","hint","error","warning","pointer","key","isError","oneOf","values","shown","value","distance","a","b","row","_","index","next","j","closest","candidates","lower","candidate","suggest","match","FORMAT_VERSION","formatIssues","version","valid","OPERATORS","CONDITION_OPERATORS","operatorIssues","condition","keys","unknown","count","missingTarget","context","name","group","inner","scopes","scope","keyList","referenceIssues","owner","step","target","sameStep","allowed","conditionErrors","entry","conditionIssues","nestable","KINDS","item","typed","rules","kind","missing","list","check","required","isEntry","conditions","action","option","RULES","validation","dependencies","field","container","route","shapeIssues","input","format","SUBMIT","metaIssues","collect","source","createContext","definition","validators","steps","nodes","visit","items","parent","node","position","at","isSection","isGroup","entries","rangeIssue","min","max","low","high","patternIssue","pattern","ruleIssues","optionIssues","fieldIssues","nodeId","dependencyGraph","graph","link","owners","known","conditionFields","valueFields","findCycles","visiting","cycles","start","stack","frame","neighbor","graphIssues","paths","cycle","QUERY","sourceIssue","names","SOURCE_NAMES","query","sourceIssues","sourceWarnings","conditional","successors","indexes","from","reachableSteps","seen","queue","RESERVED","stepIssues","first","later","keyIssues","reachable","exclusive","outer","groups","clash","other","prefix","nestingIssues","structureIssues","PROPERTIES","LABEL_HINT","absent","fix","misplaced","fieldWarnings","visible","empty","propertyWarnings","title","LIST_OPERATORS","COMPARISONS","expectedType","BOOLEAN_TYPES","BUILT_IN_TYPES","valueIssue","operator","operand","mismatch","result","operands","expected","wrong","options","conditionWarnings","defaults","slowPattern","closed","char","ruleWarnings","rule","numeric","ranges","sized","hasOwn","routeWarnings","targets","to","sibling","exits","versionWarnings","major","minor","definitionWarnings","warnings","shape","definitionErrors","checkDefinition","parseDefinition","_options","errors"],"mappings":"sGA+CO,IAAMA,EAAN,cAAkC,KAAM,CAG7C,WAAA,CAAYC,CAAAA,CAA2B,CACrC,KAAA,CAAM,CAAA;AAAA,EAA6BA,EAAO,GAAA,CAAKC,CAAAA,EAAUA,CAAAA,CAAM,OAAO,EAAE,IAAA,CAAK;AAAA,CAAI,CAAC,CAAA,CAAE,CAAA,CACpF,IAAA,CAAK,KAAO,qBAAA,CACZ,IAAA,CAAK,MAAA,CAASD,EAChB,CACF,CAAA,CAEME,EAAAA,CAAYC,CAAAA,EAAkBA,EAAK,QAAA,CAAS,GAAG,CAAA,CAAIA,CAAAA,CAAO,CAAA,EAAGA,CAAI,CAAA,CAAA,EAEvE,SAASC,GAAOC,CAAAA,CAAuC,CACrD,OAAO,CAACC,EAA2BC,CAAAA,CAAcC,CAAAA,CAAiBC,CAA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","file":"chunk-TMO47L42.js","sourcesContent":["export type DefinitionIssueCode =\n | 'invalid-type'\n | 'missing-property'\n | 'unknown-property'\n | 'empty-label'\n | 'fields-and-steps'\n | 'duplicate-step-id'\n | 'duplicate-key'\n | 'duplicate-option-value'\n | 'reserved-key'\n | 'route-target'\n | 'unknown-field'\n | 'group-scope'\n | 'invalid-nesting'\n | 'outdated-format-version'\n | 'forward-reference'\n | 'condition-operator-count'\n | 'unknown-operator'\n | 'condition-value-mismatch'\n | 'condition-cycle'\n | 'invalid-pattern'\n | 'slow-pattern'\n | 'invalid-range'\n | 'rule-not-applicable'\n | 'missing-options'\n | 'default-not-in-options'\n | 'unknown-field-type'\n | 'unknown-validator'\n | 'skip-unreachable'\n | 'route-fallthrough'\n | 'unsupported-format-version'\n | 'i18n-unbound-slot'\n | 'unknown-i18n-slot'\n | 'unknown-message-key'\n | 'unknown-label-key'\n | 'i18n-unsafe-identifier'\n | 'unknown-source'\n | 'source-not-applicable';\n\nexport interface DefinitionIssue {\n code: DefinitionIssueCode;\n severity: 'error' | 'warning';\n path: string;\n message: string;\n hint?: string;\n}\n\nexport class FormDefinitionError extends Error {\n readonly issues: DefinitionIssue[];\n\n constructor(issues: DefinitionIssue[]) {\n super(`Invalid form definition:\\n${issues.map((issue) => issue.message).join('\\n')}`);\n this.name = 'FormDefinitionError';\n this.issues = issues;\n }\n}\n\nconst sentence = (text: string) => (text.endsWith('?') ? text : `${text}.`);\n\nfunction create(severity: DefinitionIssue['severity']) {\n return (code: DefinitionIssueCode, path: string, problem: string, hint?: string): DefinitionIssue => ({\n code,\n severity,\n path,\n message: `${path || '/'}: ${problem}.${hint ? ` ${sentence(hint)}` : ''}`,\n ...(hint && { hint: sentence(hint) }),\n });\n}\n\nexport const error = create('error');\nexport const warning = create('warning');\n\nexport function pointer(key: string): string {\n return key.replace(/~/g, '~0').replace(/\\//g, '~1');\n}\n\nexport function isError(issue: DefinitionIssue): boolean {\n return issue.severity === 'error';\n}\n\nexport function oneOf(values: string[]): string {\n if (values.length === 1) return `Use ${JSON.stringify(values[0])}`;\n const shown = values\n .slice(0, 10)\n .map((value) => JSON.stringify(value))\n .join(', ');\n return values.length > 10 ? `Use one of: ${shown}, ...` : `Use one of: ${shown}`;\n}\n\nfunction distance(a: string, b: string): number {\n let row = Array.from({ length: b.length + 1 }, (_, index) => index);\n for (let i = 1; i <= a.length; i++) {\n const next = [i];\n for (let j = 1; j <= b.length; j++) {\n next[j] = Math.min(row[j] + 1, next[j - 1] + 1, row[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));\n }\n row = next;\n }\n return row[b.length];\n}\n\nexport function closest(value: string, candidates: string[]): string | undefined {\n const lower = value.toLowerCase();\n return candidates.find((candidate) => candidate !== value && distance(lower, candidate.toLowerCase()) <= (candidate.length > 4 ? 2 : 1));\n}\n\nexport function suggest(value: string, candidates: string[]): string | undefined {\n const match = closest(value, candidates);\n if (match !== undefined) return `Use ${JSON.stringify(match)}`;\n return candidates.length ? oneOf(candidates) : undefined;\n}\n","import type { DefinitionIssue } from './issues';\nimport { error } from './issues';\n\nexport const FORMAT_VERSION = '1.1';\n\nexport function formatIssues({ formatVersion: version }: Record<string, unknown>): DefinitionIssue[] {\n if (version === undefined) return [];\n const valid = typeof version === 'string' && /^[1-9]\\d*(\\.\\d+)?$/.test(version);\n if (valid && parseInt(version, 10) <= parseInt(FORMAT_VERSION, 10)) return [];\n return [\n valid\n ? error('unsupported-format-version', '/formatVersion', `format ${version} is not supported`, 'Upgrade @formhaus/core')\n : error('invalid-type', '/formatVersion', 'must be a version string', `Use \"${FORMAT_VERSION}\"`),\n ];\n}\n","import { CONDITION_OPERATORS } from '../visibility/evaluate-condition';\nimport type { ShowCondition } from '../types';\nimport type { CheckContext, ConditionEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error, pointer } from './issues';\n\nexport const OPERATORS: readonly string[] = CONDITION_OPERATORS;\n\nfunction operatorIssues({ suggest }: CheckContext, condition: ShowCondition, path: string): DefinitionIssue[] {\n const keys = Object.keys(condition).filter((key) => key !== 'field');\n const unknown = keys.filter((key) => !OPERATORS.includes(key));\n const issues = unknown.map((key) =>\n error('unknown-operator', `${path}/${pointer(key)}`, `\"${key}\" is not a condition operator`, suggest(key, [...OPERATORS])),\n );\n const count = keys.length - unknown.length;\n if (count !== 1 && !(count === 0 && unknown.length)) {\n const problem = count ? `the condition has ${count} operators` : 'the condition has no operator';\n issues.push(error('condition-operator-count', path, problem, `Use exactly one of: ${OPERATORS.join(', ')}`));\n }\n return issues;\n}\n\nexport function missingTarget(context: CheckContext, name: string, path: string, group?: string, key?: string): DefinitionIssue[] {\n if (context.target(name, group)) return [];\n const inner = [...context.scopes].find(([, scope]) => scope.has(name));\n if (inner)\n return [error('group-scope', path, `\"${name}\" is a field inside the group \"${inner[0]}\"`, 'Only fields of the same group can use it')];\n const candidates = [...(group !== undefined ? (context.scopes.get(group)?.keys() ?? []) : []), ...context.keyList].filter(\n (candidate) => candidate !== key,\n );\n return [error('unknown-field', path, `\"${name}\" is not a field key`, context.suggest(name, candidates))];\n}\n\nfunction referenceIssues(context: CheckContext, { condition, path, owner, step, key, group }: ConditionEntry): DefinitionIssue[] {\n const target = context.target(condition.field, group);\n if (!target) return missingTarget(context, condition.field, `${path}/field`, group, key);\n if (target.group || step < 0 || owner === 'action') return [];\n const sameStep = owner === 'step' ? 'this or a later step' : 'a later step';\n if (target.step < step || (owner !== 'step' && target.step === step)) return [];\n const allowed = owner === 'step' ? 'earlier steps' : 'this or an earlier step';\n return [\n error(\n 'forward-reference',\n `${path}/field`,\n `\"${condition.field}\" belongs to ${sameStep}`,\n `${owner === 'route' ? 'Route' : owner === 'step' ? 'Step' : 'Field'} conditions can use fields of ${allowed}`,\n ),\n ];\n}\n\nexport function conditionErrors(context: CheckContext, entry: ConditionEntry): DefinitionIssue[] {\n const { condition, path } = entry;\n if (typeof condition.field !== 'string')\n return [error('missing-property', path, 'missing required property \"field\"', 'Add the key of the field to test')];\n return [...operatorIssues(context, condition, path), ...referenceIssues(context, entry)];\n}\n\nexport function conditionIssues(context: CheckContext): DefinitionIssue[] {\n return context.conditions.flatMap((entry) => conditionErrors(context, entry));\n}\n","import type { DefinitionIssue } from './issues';\nimport { formatIssues } from './format';\nimport { error, pointer } from './issues';\nimport { isEntry } from '../visibility/nodes';\n\nexport { isEntry };\n\nexport const nestable = (path: string) => path.split('/fields/').length <= 3;\n\ntype Entry = Record<string, unknown>;\ntype Check = (value: Entry, path: string) => DefinitionIssue[];\ntype Kind = 'string' | 'number' | 'boolean' | 'requirement' | 'scalar' | 'list';\n\nconst KINDS: Record<Kind, [(value: unknown) => boolean, string]> = {\n string: [(value) => typeof value === 'string', 'a string'],\n number: [(value) => typeof value === 'number' && Number.isFinite(value), 'a number'],\n boolean: [(value) => typeof value === 'boolean', 'true or false'],\n requirement: [(value) => ['boolean', 'string'].includes(typeof value), 'true, false or a message string'],\n scalar: [(value) => ['string', 'number', 'boolean'].includes(typeof value), 'a string, number or boolean'],\n list: [\n (value) => Array.isArray(value) && value.every((item) => ['string', 'number'].includes(typeof item)),\n 'an array of strings or numbers',\n ],\n};\n\nfunction typed(value: Entry, rules: Record<string, Kind>, path: string): DefinitionIssue[] {\n return Object.entries(rules).flatMap(([key, kind]) => {\n const [valid, name] = KINDS[kind];\n return value[key] === undefined || valid(value[key])\n ? []\n : [error('invalid-type', `${path}/${pointer(key)}`, `\"${key}\" must be ${name}`)];\n });\n}\n\nexport function missing(path: string, key: string, hint?: string, create = error): DefinitionIssue {\n return create('missing-property', path, `missing required property \"${key}\"`, hint);\n}\n\nfunction list(value: unknown, path: string, name: string, check: Check, required = false): DefinitionIssue[] {\n if (value == null && !required) return [];\n if (value === undefined) return [missing(path.slice(0, path.lastIndexOf('/')), path.slice(path.lastIndexOf('/') + 1))];\n if (!Array.isArray(value))\n return [error('invalid-type', path, 'must be an array', required ? 'Use [] when there is nothing to list' : undefined)];\n return value.flatMap((item, index) =>\n isEntry(item) ? check(item, `${path}/${index}`) : [error('invalid-type', `${path}/${index}`, `must be ${name}`)],\n );\n}\n\nfunction text(value: Entry, key: string, path: string): DefinitionIssue[] {\n if (value[key] === undefined) return [missing(path, key)];\n return typeof value[key] === 'string' ? [] : [error('invalid-type', `${path}/${pointer(key)}`, `\"${key}\" must be a string`)];\n}\n\nconst condition: Check = (value, path) =>\n typed(\n value,\n {\n field: 'string',\n eq: 'scalar',\n neq: 'scalar',\n in: 'list',\n notIn: 'list',\n notEmpty: 'boolean',\n gt: 'number',\n gte: 'number',\n lt: 'number',\n lte: 'number',\n },\n path,\n );\n\nfunction conditions(value: Entry, path: string): DefinitionIssue[] {\n return [\n ...list(value.show, `${path}/show`, 'a condition object', condition),\n ...list(value.showAny, `${path}/showAny`, 'a condition object', condition),\n ];\n}\n\nfunction action(value: unknown, path: string): DefinitionIssue[] {\n if (!isEntry(value)) return [];\n return [...typed(value, { label: 'string' }, path), ...list(value.disabled, `${path}/disabled`, 'a condition object', condition)];\n}\n\nconst option: Check = (value, path) => [...text(value, 'value', path), ...typed(value, { label: 'string' }, path)];\n\nconst RULES: Record<string, Kind> = {\n required: 'requirement',\n minLength: 'number',\n maxLength: 'number',\n min: 'number',\n max: 'number',\n pattern: 'string',\n matchField: 'string',\n validator: 'string',\n minLengthMessage: 'string',\n maxLengthMessage: 'string',\n minMessage: 'string',\n maxMessage: 'string',\n patternMessage: 'string',\n matchFieldMessage: 'string',\n};\n\nfunction validation(value: unknown, path: string): DefinitionIssue[] {\n if (value === undefined) return [];\n return isEntry(value) ? typed(value, RULES, path) : [error('invalid-type', path, 'must be an object of validation rules')];\n}\n\nfunction dependencies(value: unknown, path: string): DefinitionIssue[] {\n const valid = value === undefined || (Array.isArray(value) && value.every((key) => typeof key === 'string'));\n return valid ? [] : [error('invalid-type', path, 'must be an array of field keys')];\n}\n\nconst field: Check = (value, path) => {\n const container = (value.type === 'section' || value.type === 'group') && nestable(path);\n return [\n ...text(value, 'key', path),\n ...text(value, 'type', path),\n ...typed(\n value,\n {\n label: 'string',\n placeholder: 'string',\n helperText: 'string',\n title: 'string',\n description: 'string',\n itemLabel: 'string',\n addLabel: 'string',\n removeLabel: 'string',\n defaultItems: 'number',\n },\n path,\n ),\n ...(container ? list(value.fields, `${path}/fields`, 'a field object', field, true) : []),\n ...conditions(value, path),\n ...list(value.options, `${path}/options`, 'an option object', option),\n ...validation(value.validation, `${path}/validation`),\n ...dependencies(value.optionsDependsOn, `${path}/optionsDependsOn`),\n ];\n};\n\nconst route: Check = (value, path) => [\n ...(value.to === undefined\n ? [missing(path, 'to')]\n : value.to === null || typeof value.to === 'string'\n ? []\n : [error('invalid-type', `${path}/to`, '\"to\" must be a step id or null')]),\n ...conditions(value, path),\n];\n\nconst step: Check = (value, path) => [\n ...text(value, 'id', path),\n ...typed(value, { title: 'string', description: 'string' }, path),\n ...list(value.fields, `${path}/fields`, 'a field object', field, true),\n ...conditions(value, path),\n ...list(value.routes, `${path}/routes`, 'a route object', route),\n ...['next', 'back', 'skip'].flatMap((name) => action(value[name], `${path}/${name}`)),\n];\n\nexport function shapeIssues(input: unknown): DefinitionIssue[] {\n if (!isEntry(input)) return [error('invalid-type', '', 'the form definition must be an object')];\n const format = formatIssues(input);\n if (format.length) return format;\n return [\n ...list(input.fields, '/fields', 'a field object', field),\n ...list(input.steps, '/steps', 'a step object', step),\n ...action(input.submit, '/submit'),\n ...action(input.cancel, '/cancel'),\n ];\n}\n\nconst SUBMIT = 'Add \"submit\": { \"label\": \"Submit\" }';\n\nexport function metaIssues(input: Entry): DefinitionIssue[] {\n return [\n ...text(input, 'id', ''),\n ...(input.submit === undefined\n ? [missing('', 'submit', SUBMIT)]\n : isEntry(input.submit)\n ? []\n : [error('invalid-type', '/submit', 'must be an action object', SUBMIT)]),\n ];\n}\n","import type { FormAction, FormDefinition, FormField, FormGroup, FormNode, ShowCondition } from '../types';\nimport { isGroup, isSection } from '../visibility/nodes';\nimport { nestable } from './shape';\n\nexport interface FieldEntry {\n field: FormField;\n path: string;\n step: number;\n group?: FormGroup;\n}\n\nexport interface NodeEntry {\n node: FormNode;\n path: string;\n step: number;\n group?: FormGroup;\n parent?: FormNode;\n}\n\nexport interface ConditionEntry {\n condition: ShowCondition;\n path: string;\n owner: 'field' | 'step' | 'route' | 'action';\n step: number;\n key?: string;\n group?: string;\n}\n\nexport interface CheckContext {\n definition: FormDefinition;\n nodes: NodeEntry[];\n entries: FieldEntry[];\n keys: Map<string, FieldEntry>;\n keyList: string[];\n scopes: Map<string, Map<string, FieldEntry>>;\n conditions: ConditionEntry[];\n validators?: Record<string, unknown>;\n suggest: (value: string, candidates: string[]) => string | undefined;\n target: (key: string, group?: string) => FieldEntry | undefined;\n}\n\ntype Owner = { show?: ShowCondition[]; showAny?: ShowCondition[] };\n\nfunction collect(\n target: ConditionEntry[],\n source: Owner | FormAction | false | undefined,\n path: string,\n owner: ConditionEntry['owner'],\n step: number,\n key?: string,\n group?: string,\n): void {\n for (const name of owner === 'action' ? (['disabled'] as const) : (['show', 'showAny'] as const)) {\n ((source || {}) as Record<typeof name, ShowCondition[] | undefined>)[name]?.forEach((condition, index) => {\n target.push({ condition, path: `${path}/${name}/${index}`, owner, step, key, group });\n });\n }\n}\n\nexport function createContext(\n definition: FormDefinition,\n validators?: Record<string, unknown>,\n suggest: CheckContext['suggest'] = () => undefined,\n): CheckContext {\n const steps = definition.steps ?? [];\n const nodes: NodeEntry[] = [];\n const visit = (items: FormNode[], path: string, step: number, parent?: FormNode, group?: FormGroup) =>\n items.forEach((node, position) => {\n const at = `${path}/${position}`;\n nodes.push({ node, path: at, step, group, parent });\n if ((isSection(node) || isGroup(node)) && nestable(at)) visit(node.fields, `${at}/fields`, step, node, isGroup(node) ? node : group);\n });\n if (steps.length) {\n steps.forEach((step, index) => {\n visit(step.fields, `/steps/${index}/fields`, index);\n });\n } else visit(definition.fields ?? [], '/fields', -1);\n const entries: FieldEntry[] = nodes.flatMap(({ node, path, step, group }) =>\n isSection(node) ? [] : [{ field: node, path, step, group }],\n );\n const keys = new Map<string, FieldEntry>();\n const scopes = new Map<string, Map<string, FieldEntry>>();\n for (const entry of entries) {\n const scope = entry.group ? (scopes.get(entry.group.key) ?? new Map<string, FieldEntry>()) : keys;\n if (entry.group) scopes.set(entry.group.key, scope);\n if (!scope.has(entry.field.key)) scope.set(entry.field.key, entry);\n }\n const conditions: ConditionEntry[] = [];\n for (const { node, path, step, group } of nodes) collect(conditions, node, path, 'field', step, node.key, group?.key);\n steps.forEach((step, index) => {\n collect(conditions, step, `/steps/${index}`, 'step', index);\n (step.routes ?? []).forEach((route, position) => {\n collect(conditions, route, `/steps/${index}/routes/${position}`, 'route', index);\n });\n for (const name of ['next', 'back', 'skip'] as const) collect(conditions, step[name], `/steps/${index}/${name}`, 'action', index);\n });\n collect(conditions, definition.submit, '/submit', 'action', -1);\n collect(conditions, definition.cancel, '/cancel', 'action', -1);\n return {\n definition,\n nodes,\n entries,\n keys,\n keyList: [...keys.keys()],\n scopes,\n conditions,\n validators,\n suggest,\n target: (key, group) => (group !== undefined && scopes.get(group)?.get(key)) || keys.get(key),\n };\n}\n","import type { FieldValidation } from '../types';\nimport { missingTarget } from './conditions';\nimport type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error } from './issues';\n\nfunction rangeIssue(rules: FieldValidation, path: string, min: 'min' | 'minLength', max: 'max' | 'maxLength'): DefinitionIssue[] {\n const low = rules[min];\n const high = rules[max];\n if (low === undefined || high === undefined || low <= high) return [];\n return [\n error('invalid-range', `${path}/validation/${min}`, `${min} (${low}) is greater than ${max} (${high})`, `Lower ${min} or raise ${max}`),\n ];\n}\n\nfunction patternIssue(pattern: string | undefined, path: string): DefinitionIssue[] {\n if (pattern === undefined) return [];\n try {\n new RegExp(pattern);\n return [];\n } catch {\n return [\n error(\n 'invalid-pattern',\n `${path}/validation/pattern`,\n `${JSON.stringify(pattern)} is not a valid regular expression`,\n 'Fix the pattern or escape special characters with a backslash',\n ),\n ];\n }\n}\n\nfunction ruleIssues(context: CheckContext, { field, path, group }: FieldEntry): DefinitionIssue[] {\n const rules = field.validation ?? {};\n const match = rules.matchField;\n const items = field.type === 'group' ? (field as { defaultItems?: number }).defaultItems : undefined;\n return [\n ...rangeIssue(rules, path, 'minLength', 'maxLength'),\n ...rangeIssue(rules, path, 'min', 'max'),\n ...patternIssue(rules.pattern, path),\n ...(match === undefined ? [] : missingTarget(context, match, `${path}/validation/matchField`, group?.key)),\n ...(items !== undefined && rules.maxLength !== undefined && items > rules.maxLength\n ? [\n error(\n 'invalid-range',\n `${path}/defaultItems`,\n `defaultItems (${items}) is greater than maxLength (${rules.maxLength})`,\n 'Lower defaultItems or raise maxLength',\n ),\n ]\n : []),\n ];\n}\n\nfunction optionIssues({ field, path }: FieldEntry): DefinitionIssue[] {\n const values = (field.options ?? []).map((option) => option.value);\n return values.flatMap((value, index) =>\n values.indexOf(value) < index\n ? [error('duplicate-option-value', `${path}/options/${index}/value`, `\"${value}\" is already an option value`)]\n : [],\n );\n}\n\nexport function fieldIssues(context: CheckContext): DefinitionIssue[] {\n return context.entries.flatMap((entry) => [...ruleIssues(context, entry), ...optionIssues(entry)]);\n}\n","import type { FormNode } from '../types';\nimport { conditionFields, isSection, valueFields } from '../visibility/nodes';\nimport type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error } from './issues';\n\nconst nodeId = ({ field, group }: FieldEntry) => (group ? `${group.key}.${field.key}` : field.key);\n\nfunction dependencyGraph({ definition, entries, nodes, target }: CheckContext): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const link = (owners: string[], source: FormNode | { show?: { field: string }[]; showAny?: { field: string }[] }, group?: string) => {\n const known = conditionFields(source).flatMap((field) => {\n const entry = target(field, group);\n return entry ? [nodeId(entry)] : [];\n });\n if (known.length) for (const owner of owners) graph.set(owner, [...(graph.get(owner) ?? []), ...known]);\n };\n for (const entry of entries) link([nodeId(entry)], entry.field, entry.group?.key);\n for (const { node, group } of nodes)\n if (isSection(node) && !group)\n link(\n node.fields.map((field) => field.key),\n node,\n );\n for (const step of definition.steps ?? [])\n link(\n valueFields(step.fields).map((field) => field.key),\n step,\n );\n return graph;\n}\n\nfunction findCycles(graph: Map<string, string[]>): string[][] {\n const visiting = new Map<string, boolean>();\n const cycles: string[][] = [];\n for (const start of graph.keys()) {\n if (visiting.has(start)) continue;\n visiting.set(start, true);\n const stack: [string, number][] = [[start, 0]];\n while (stack.length > 0) {\n const frame = stack[stack.length - 1];\n const neighbor = graph.get(frame[0])?.[frame[1]++];\n if (neighbor === undefined) {\n visiting.set(frame[0], false);\n stack.pop();\n } else if (visiting.get(neighbor)) {\n const nodes = stack.map(([node]) => node);\n cycles.push([...nodes.slice(nodes.indexOf(neighbor)), neighbor]);\n } else if (!visiting.has(neighbor)) {\n visiting.set(neighbor, true);\n stack.push([neighbor, 0]);\n }\n }\n }\n return cycles;\n}\n\nexport function graphIssues(context: CheckContext): DefinitionIssue[] {\n const paths = new Map(context.entries.map((entry) => [nodeId(entry), entry.path]));\n return findCycles(dependencyGraph(context)).map((cycle) =>\n error(\n 'condition-cycle',\n paths.get(cycle[0])!,\n `show conditions form a cycle: ${cycle.join(' -> ')}`,\n 'Remove one of the conditions in the cycle',\n ),\n );\n}\n","import { SOURCE_NAMES } from '../sources';\nimport type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error, oneOf, warning } from './issues';\nimport { isEntry } from './shape';\n\nconst QUERY = 'Use { \"query\": \"<parameter name>\" } for a URL parameter';\n\nfunction sourceIssue(context: CheckContext, { field, path }: FieldEntry): DefinitionIssue[] {\n const source: unknown = field.source;\n const at = `${path}/source`;\n const names = SOURCE_NAMES as string[];\n if (typeof source === 'string') {\n return names.includes(source)\n ? []\n : [\n error(\n 'unknown-source',\n at,\n `\"${source}\" is not a source`,\n source === 'query' ? QUERY : (context.suggest(source, names) ?? oneOf(names)),\n ),\n ];\n }\n const query = isEntry(source) && Object.keys(source).length === 1 ? source.query : undefined;\n return source === undefined || (typeof query === 'string' && query.trim())\n ? []\n : [error('invalid-type', at, 'must be a source name or a query object', QUERY)];\n}\n\nexport function sourceIssues(context: CheckContext): DefinitionIssue[] {\n return context.entries.flatMap((entry) => sourceIssue(context, entry));\n}\n\nexport function sourceWarnings({ field, path }: FieldEntry): DefinitionIssue[] {\n return field.source === undefined || field.type === 'hidden'\n ? []\n : [warning('source-not-applicable', `${path}/source`, `only hidden fields read \"source\"`, 'Set \"type\" to \"hidden\" or remove \"source\"')];\n}\n","import type { FormStep, StepRoute } from '../types';\n\nconst conditional = (source: Pick<StepRoute, 'show' | 'showAny'>) => !!(source.show?.length || source.showAny?.length);\n\nfunction successors(steps: FormStep[], indexes: Map<string, number>, from: number): number[] {\n const next: number[] = [];\n for (const route of steps[from].routes ?? []) {\n const target = route.to === null ? null : indexes.get(route.to);\n if (target === null && !conditional(route)) return next;\n if (target === null || target === undefined || target <= from) continue;\n next.push(target);\n if (!conditional(route) && !conditional(steps[target])) return next;\n }\n return from + 1 < steps.length ? [...next, from + 1] : next;\n}\n\nexport function reachableSteps(steps: FormStep[]): Set<number>[] {\n const indexes = new Map(steps.map((step, index) => [step.id, index]));\n return steps.map((_, start) => {\n const seen = new Set<number>();\n const queue = successors(steps, indexes, start);\n while (queue.length) {\n const index = queue.pop()!;\n if (seen.has(index)) continue;\n seen.add(index);\n queue.push(...successors(steps, indexes, index));\n if (conditional(steps[index]) && index + 1 < steps.length) queue.push(index + 1);\n }\n return seen;\n });\n}\n","import { isGroup, isSection } from '../visibility/nodes';\nimport type { CheckContext, NodeEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { error, oneOf } from './issues';\nimport { reachableSteps } from './paths';\n\nconst RESERVED = new Set([...Object.getOwnPropertyNames(Object.prototype), 'prototype']);\n\nfunction stepIssues({ definition }: CheckContext): DefinitionIssue[] {\n const issues: DefinitionIssue[] = [];\n const steps = definition.steps ?? [];\n const seen = new Map<string, number>();\n steps.forEach((step, index) => {\n const first = seen.get(step.id);\n if (first === undefined) seen.set(step.id, index);\n else\n issues.push(\n error(\n 'duplicate-step-id',\n `/steps/${index}/id`,\n `step id \"${step.id}\" is already used by /steps/${first}`,\n 'Give each step a unique id',\n ),\n );\n });\n steps.forEach((step, index) => {\n (step.routes ?? []).forEach((route, position) => {\n if (route.to === null) return;\n const target = seen.get(route.to);\n if (target !== undefined && target > index) return;\n const later = steps.slice(index + 1).map((candidate) => candidate.id);\n const problem = target === undefined ? `\"${route.to}\" is not a step id` : `\"${route.to}\" is not a later step`;\n const hint = later.length ? `${oneOf(later)}, or null to end the form here` : 'Use null to end the form here';\n issues.push(error('route-target', `/steps/${index}/routes/${position}/to`, problem, hint));\n });\n });\n return issues;\n}\n\nfunction keyIssues({ definition, nodes }: CheckContext): DefinitionIssue[] {\n const issues: DefinitionIssue[] = [];\n const reachable = reachableSteps(definition.steps ?? []);\n const exclusive = (a: NodeEntry, b: NodeEntry) => a.step !== b.step && !reachable[a.step]?.has(b.step);\n const outer = nodes.filter((entry) => !entry.group);\n const groups = outer.filter((entry) => isGroup(entry.node));\n nodes.forEach((entry, index) => {\n const {\n node: { key },\n path,\n group,\n } = entry;\n const clash = group\n ? (nodes.slice(0, index).find((other) => other.group === group && other.node.key === key) ??\n outer.find((other) => other.node.key === key))\n : outer.slice(0, outer.indexOf(entry)).find((other) => other.node.key === key && !exclusive(other, entry));\n const prefix = !group && groups.find((other) => key.startsWith(`${other.node.key}.`));\n if (RESERVED.has(key)) {\n issues.push(error('reserved-key', `${path}/key`, `\"${key}\" is a built-in object property name`, 'Rename the field key'));\n } else if (clash) {\n issues.push(\n error(\n 'duplicate-key',\n `${path}/key`,\n `key \"${key}\" is already used by ${clash.path}${group ? '' : ' on the same path'}`,\n group ? 'Rename the field' : 'Rename one of the fields, or move them to route branches that never meet',\n ),\n );\n } else if (prefix) {\n issues.push(\n error('duplicate-key', `${path}/key`, `key \"${key}\" starts with the group key \"${prefix.node.key}.\"`, 'Rename the field'),\n );\n }\n });\n return issues;\n}\n\nfunction nestingIssues({ nodes }: CheckContext): DefinitionIssue[] {\n return nodes.flatMap(({ node, path, group, parent }) =>\n (isSection(node) && parent) || (group && ['group', 'file', 'hidden'].includes(node.type))\n ? [error('invalid-nesting', `${path}/type`, `a ${node.type} cannot be inside a ${parent!.type}`, 'Move it to the fields of the step')]\n : [],\n );\n}\n\nexport function structureIssues(context: CheckContext): DefinitionIssue[] {\n const { definition } = context;\n const both = !!definition.fields?.length && !!definition.steps?.length;\n return [\n ...(both\n ? [\n error(\n 'fields-and-steps',\n '',\n 'the definition has both \"fields\" and \"steps\"',\n 'Move the top-level fields into a step, or remove \"steps\"',\n ),\n ]\n : []),\n ...stepIssues(context),\n ...keyIssues(context),\n ...nestingIssues(context),\n ];\n}\n","import type { CheckContext, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { closest, pointer, warning } from './issues';\nimport { isEntry, missing } from './shape';\n\nexport const PROPERTIES = {\n form: '$schema formatVersion id lang title description messages labels i18n submit cancel fields steps',\n step: 'id title description fields show showAny routes next back skip i18n',\n field:\n 'key type label placeholder helperText autoAdvance defaultValue source show showAny validation options layout optionsFrom optionsDependsOn accept rows mask inputMode i18n',\n section: 'key type title description show showAny fields i18n',\n group: 'key type label helperText itemLabel addLabel removeLabel defaultItems show showAny validation fields i18n',\n option: 'value label i18n',\n action: 'label variant disabled i18n',\n route: 'to show showAny',\n validation:\n 'required minLength minLengthMessage maxLength maxLengthMessage min minMessage max maxMessage pattern patternMessage matchField matchFieldMessage validator i18n',\n};\n\nconst LABEL_HINT = 'Add a label so screen readers can name the input';\n\nfunction unknown(value: object, path: string, list: string, hint: (key: string) => string | undefined = () => undefined) {\n const known = list.split(' ');\n const absent = known.filter((key) => !(key in value));\n return Object.keys(value)\n .filter((key) => !known.includes(key))\n .map((key) => {\n const match = closest(key, absent);\n const fix = match === undefined ? hint(key) : `Did you mean \"${match}\"?`;\n return warning('unknown-property', `${path}/${pointer(key)}`, `unknown property \"${key}\"`, fix);\n });\n}\n\nfunction required(value: object, path: string, key: string, hint?: string): DefinitionIssue[] {\n return (value as Record<string, unknown>)[key] === undefined ? [missing(path, key, hint, warning)] : [];\n}\n\nfunction action(value: unknown, path: string): DefinitionIssue[] {\n return isEntry(value) ? [...required(value, path, 'label'), ...unknown(value, path, PROPERTIES.action)] : [];\n}\n\nconst misplaced = (key: string) =>\n key !== 'i18n' && PROPERTIES.validation.split(' ').includes(key) ? `Move \"${key}\" into \"validation\": { \"${key}\": ... }` : undefined;\n\nfunction fieldWarnings({ field, path }: FieldEntry): DefinitionIssue[] {\n const visible = field.type !== 'hidden';\n const empty = visible && typeof field.label === 'string' && !field.label.trim();\n return [\n ...required(field, path, 'label', visible ? LABEL_HINT : undefined),\n ...(empty ? [warning('empty-label', `${path}/label`, `the label of \"${field.key}\" is empty`, LABEL_HINT)] : []),\n ...unknown(field, path, field.type === 'group' ? PROPERTIES.group : PROPERTIES.field, misplaced),\n ...(field.options ?? []).flatMap((option, index) => [\n ...required(option, `${path}/options/${index}`, 'label'),\n ...unknown(option, `${path}/options/${index}`, PROPERTIES.option),\n ]),\n ...(isEntry(field.validation) ? unknown(field.validation, `${path}/validation`, PROPERTIES.validation) : []),\n ];\n}\n\nexport function propertyWarnings({ definition, entries, nodes }: CheckContext): DefinitionIssue[] {\n const { title } = definition as { title?: unknown };\n return [\n ...required(definition, '', 'title', 'Add a title for host UI and editors'),\n ...(title === undefined || typeof title === 'string' ? [] : [warning('invalid-type', '/title', '\"title\" must be a string')]),\n ...unknown(definition, '', PROPERTIES.form),\n ...action(definition.submit, '/submit'),\n ...action(definition.cancel, '/cancel'),\n ...(definition.steps ?? []).flatMap((step, index) => {\n const path = `/steps/${index}`;\n return [\n ...required(step, path, 'title'),\n ...unknown(step, path, PROPERTIES.step),\n ...(step.routes ?? []).flatMap((route, position) => unknown(route, `${path}/routes/${position}`, PROPERTIES.route)),\n ...(['next', 'back', 'skip'] as const).flatMap((name) => action(step[name], `${path}/${name}`)),\n ];\n }),\n ...nodes.flatMap(({ node, path }) =>\n node.type === 'section' ? [...required(node, path, 'title'), ...unknown(node, path, PROPERTIES.section)] : [],\n ),\n ...entries.flatMap(fieldWarnings),\n ];\n}\n","import type { FormField } from '../types';\nimport { hasOwn } from '../visibility/nodes';\nimport { BOOLEAN_TYPES, BUILT_IN_TYPES } from '../validation/type-checks';\nimport { conditionErrors, missingTarget, OPERATORS } from './conditions';\nimport type { CheckContext, ConditionEntry, FieldEntry } from './context';\nimport type { DefinitionIssue } from './issues';\nimport { closest, oneOf, suggest, warning } from './issues';\nimport { propertyWarnings } from './properties';\nimport { sourceWarnings } from './sources';\n\nconst LIST_OPERATORS = ['in', 'notIn'];\nconst COMPARISONS = ['gt', 'gte', 'lt', 'lte'];\n\nfunction expectedType(field: FormField): string | undefined {\n if (field.type === 'number') return 'number';\n if (BOOLEAN_TYPES.includes(field.type)) return 'boolean';\n return BUILT_IN_TYPES.includes(field.type) && field.type !== 'multiselect' && field.type !== 'file' ? 'string' : undefined;\n}\n\nfunction valueIssue(target: FormField, operator: string, operand: unknown, path: string): DefinitionIssue[] {\n const mismatch = (problem: string, hint: string) => [warning('condition-value-mismatch', path, problem, hint)];\n if (operator === 'notEmpty') return [];\n if (COMPARISONS.includes(operator)) {\n if (target.type !== 'multiselect' && !BOOLEAN_TYPES.includes(target.type)) return [];\n return mismatch(\n `\"${target.key}\" is a ${target.type} field, so \"${operator}\" never matches it`,\n 'Compare a number, text, radio or select field',\n );\n }\n if (target.type === 'multiselect') {\n const result = operator === 'neq' || operator === 'notIn' ? 'always' : 'never';\n return mismatch(\n `\"${target.key}\" holds a list of values, so \"${operator}\" ${result} matches it`,\n 'Use notEmpty, or a select or radio field',\n );\n }\n const operands = LIST_OPERATORS.includes(operator) && Array.isArray(operand) ? operand : [operand];\n const expected = expectedType(target);\n const wrong = expected && operands.find((item) => typeof item !== expected);\n if (expected && wrong !== undefined)\n return mismatch(`${JSON.stringify(wrong)} is a ${typeof wrong}, but \"${target.key}\" holds a ${expected}`, `Use a ${expected} value`);\n const options =\n expected === 'string' && !target.optionsFrom && target.options?.length ? target.options.map((option) => option.value) : null;\n const missing = options && operands.find((item) => !options.includes(item as string));\n return options && missing !== undefined ? mismatch(`${JSON.stringify(missing)} is not an option of \"${target.key}\"`, oneOf(options)) : [];\n}\n\nfunction conditionWarnings(context: CheckContext, entry: ConditionEntry): DefinitionIssue[] {\n const { condition, path } = entry;\n if (conditionErrors(context, entry).length) return [];\n const operator = OPERATORS.find((key) => key in condition)!;\n return valueIssue(\n context.target(condition.field, entry.group)!.field,\n operator,\n condition[operator as keyof typeof condition],\n `${path}/${operator}`,\n );\n}\n\nfunction optionIssues({ field, path }: FieldEntry): DefinitionIssue[] {\n if (!['select', 'radio', 'multiselect'].includes(field.type)) return [];\n if (!Array.isArray(field.options)) {\n return field.optionsFrom\n ? []\n : [\n warning(\n 'missing-options',\n `${path}/options`,\n `the ${field.type} field \"${field.key}\" has no options`,\n 'Add \"options\" or \"optionsFrom\"',\n ),\n ];\n }\n const values = field.options.map((option) => option.value);\n const defaults = field.type === 'multiselect' && Array.isArray(field.defaultValue) ? field.defaultValue : [field.defaultValue];\n const missing =\n field.defaultValue === undefined || !values.length || field.optionsFrom\n ? undefined\n : defaults.find((value) => !values.includes(value as string));\n if (missing === undefined) return [];\n return [\n warning(\n 'default-not-in-options',\n `${path}/defaultValue`,\n `${JSON.stringify(missing)} is not an option of \"${field.key}\"`,\n oneOf(values),\n ),\n ];\n}\n\nfunction slowPattern(pattern: string): boolean {\n const groups: boolean[] = [];\n let closed = false;\n for (let index = 0; index < pattern.length && pattern.length <= 1000; index++) {\n const char = pattern[index];\n if (closed && '*+{'.includes(char)) return true;\n closed = false;\n if (char === '\\\\') index++;\n else if (char === '[') {\n for (index++; index < pattern.length && pattern[index] !== ']'; index++) if (pattern[index] === '\\\\') index++;\n } else if (char === '(') {\n groups.push(false);\n if (pattern[index + 1] === '?') index++;\n } else if (char === ')') {\n closed = !!groups.pop();\n if (closed && groups.length) groups[groups.length - 1] = true;\n } else if (groups.length && '*+?|{'.includes(char)) groups[groups.length - 1] = true;\n }\n return false;\n}\n\nfunction ruleWarnings(context: CheckContext, { field, path }: FieldEntry): DefinitionIssue[] {\n const rules = field.validation ?? {};\n const rule = (name: string, problem: string, hint: string) => warning('rule-not-applicable', `${path}/validation/${name}`, problem, hint);\n const items = field.type === 'group';\n const known = items || BUILT_IN_TYPES.includes(field.type);\n const numeric = field.type === 'number';\n const ranges = known && !numeric ? (['min', 'max'] as const).filter((name) => rules[name] !== undefined) : [];\n const sized =\n known && ['number', 'checkbox', 'switch'].includes(field.type)\n ? (['minLength', 'maxLength'] as const).filter((name) => rules[name] !== undefined)\n : [];\n const issues = [\n ...ranges.map((name) =>\n rule(name, `\"${name}\" applies to number fields only`, `Use ${name}Length to limit ${items ? 'the number of items' : 'text length'}`),\n ),\n ...sized.map((name) =>\n rule(name, `\"${name}\" does not apply to ${field.type} fields`, numeric ? 'Use min and max for numbers' : `Remove ${name}`),\n ),\n ];\n if (typeof rules.pattern === 'string' && slowPattern(rules.pattern)) {\n issues.push(\n warning(\n 'slow-pattern',\n `${path}/validation/pattern`,\n `the pattern of \"${field.key}\" nests quantifiers and can be very slow`,\n 'Remove the inner or outer quantifier',\n ),\n );\n }\n const { validators } = context;\n if (rules.validator !== undefined && validators && !hasOwn(validators, rules.validator)) {\n issues.push(\n warning(\n 'unknown-validator',\n `${path}/validation/validator`,\n `the validator \"${rules.validator}\" is not registered`,\n 'Pass it in the \"validators\" option',\n ),\n );\n }\n return issues;\n}\n\nfunction fieldWarnings(context: CheckContext, entry: FieldEntry): DefinitionIssue[] {\n const { field, path } = entry;\n const match =\n BUILT_IN_TYPES.includes(field.type) || field.type === 'group'\n ? undefined\n : closest(field.type, [...BUILT_IN_TYPES, 'group', 'section']);\n return [\n ...(match === undefined\n ? []\n : [\n warning(\n 'unknown-field-type',\n `${path}/type`,\n `\"${field.type}\" is not a built-in field type`,\n `Use \"${match}\", or register a component for \"${field.type}\"`,\n ),\n ]),\n ...optionIssues(entry),\n ...ruleWarnings(context, entry),\n ...sourceWarnings(entry),\n ...(field.optionsDependsOn ?? []).flatMap((key, index) =>\n missingTarget(context, key, `${path}/optionsDependsOn/${index}`).map((issue) => ({ ...issue, severity: 'warning' as const })),\n ),\n ];\n}\n\nfunction routeWarnings({ definition }: CheckContext): DefinitionIssue[] {\n const steps = definition.steps ?? [];\n return steps.flatMap((step, index) => {\n const issues: DefinitionIssue[] = [];\n const targets = new Set((step.routes ?? []).map((route) => route.to).filter((to) => to !== null));\n for (const target of targets) {\n const position = steps.findIndex((candidate) => candidate.id === target);\n const sibling = steps[position + 1];\n const exits = steps[position]?.routes?.some((route) => !route.show?.length && !route.showAny?.length);\n if (!sibling || !targets.has(sibling.id) || exits) continue;\n issues.push(\n warning(\n 'route-fallthrough',\n `/steps/${position}`,\n `branch \"${target}\" from \"${step.id}\" continues into the sibling branch \"${sibling.id}\"`,\n `Add an unconditional route on \"${target}\" to the step where the branches meet`,\n ),\n );\n }\n if (step.skip && (step.next === false || !steps[1])) {\n issues.push(\n warning(\n 'skip-unreachable',\n `/steps/${index}/skip`,\n `step \"${step.id}\" has \"skip\" but no Continue button or later step`,\n 'Remove \"skip\", or remove \"next\": false',\n ),\n );\n }\n return issues;\n });\n}\n\nfunction versionWarnings({ definition, nodes }: CheckContext): DefinitionIssue[] {\n const [major, minor = 0] = String(definition.formatVersion ?? '1.0')\n .split('.')\n .map(Number);\n const container = nodes.find(({ node }) => node.type === 'section' || node.type === 'group');\n if (!container || major !== 1 || minor >= 1) return [];\n return [\n warning(\n 'outdated-format-version',\n '/formatVersion',\n `${container.path} is a ${container.node.type}, which needs format 1.1`,\n 'Set \"formatVersion\": \"1.1\", so that older versions of @formhaus/core reject the definition instead of skipping the fields inside',\n ),\n ];\n}\n\nexport function definitionWarnings(context: CheckContext): DefinitionIssue[] {\n return [\n ...versionWarnings(context),\n ...propertyWarnings(context),\n ...context.conditions.flatMap((entry) => conditionWarnings(context, entry)),\n ...context.entries.flatMap((entry) => fieldWarnings(context, entry)),\n ...routeWarnings(context),\n ];\n}\n","import type { FormDefinition } from '../types';\nimport { conditionIssues } from './conditions';\nimport { createContext, type CheckContext } from './context';\nimport { fieldIssues } from './fields';\nimport { graphIssues } from './graph';\nimport { FormDefinitionError, suggest, type DefinitionIssue } from './issues';\nimport { metaIssues, shapeIssues } from './shape';\nimport { sourceIssues } from './sources';\nimport { structureIssues } from './structure';\nimport { definitionWarnings } from './warnings';\n\nexport interface CheckDefinitionOptions {\n validators?: Record<string, unknown>;\n}\n\ninterface Checks {\n validators?: Record<string, unknown>;\n suggest?: CheckContext['suggest'];\n warnings?: (context: CheckContext) => DefinitionIssue[];\n}\n\nfunction issues(input: unknown, { validators, suggest, warnings }: Checks = {}): DefinitionIssue[] {\n const shape = shapeIssues(input);\n if (shape.length) return shape;\n const context = createContext(input as FormDefinition, validators, suggest);\n return [\n ...metaIssues(input as Record<string, unknown>),\n ...structureIssues(context),\n ...conditionIssues(context),\n ...fieldIssues(context),\n ...sourceIssues(context),\n ...graphIssues(context),\n ...(warnings ? warnings(context) : []),\n ];\n}\n\nexport function definitionErrors(input: unknown): DefinitionIssue[] {\n return issues(input);\n}\n\nexport function checkDefinition(input: unknown, options: CheckDefinitionOptions = {}): DefinitionIssue[] {\n return issues(input, { validators: options.validators, suggest, warnings: definitionWarnings });\n}\n\nexport function parseDefinition(input: unknown, _options?: CheckDefinitionOptions): FormDefinition {\n const errors = issues(input, { suggest });\n if (errors.length) throw new FormDefinitionError(errors);\n return input as FormDefinition;\n}\n"]}
|
package/dist/cloud.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as CloudAction } from './controller-
|
|
2
|
-
export { a as CloudClientOptions, b as CloudNotice, c as CloudSettings, d as CloudSubmission, e as CloudSubmitterOptions, D as DraftStorage, f as DraftStore, P as PublishedForm, g as createSubmitter, h as fetchDefinition, i as fetchForm, s as sessionDraftStore } from './controller-
|
|
3
|
-
import './definition-
|
|
1
|
+
import { C as CloudAction } from './controller-BJVYkMHT.js';
|
|
2
|
+
export { a as CloudClientOptions, b as CloudNotice, c as CloudSettings, d as CloudSubmission, e as CloudSubmitterOptions, D as DraftStorage, f as DraftStore, P as PublishedForm, g as createSubmitter, h as fetchDefinition, i as fetchForm, s as sessionDraftStore } from './controller-BJVYkMHT.js';
|
|
3
|
+
import './definition-o4Y0OY6y.js';
|
|
4
4
|
|
|
5
5
|
declare class CloudError extends Error {
|
|
6
6
|
readonly status: number;
|
package/dist/cloud.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as CloudError,i as createSubmitter,h as fetchDefinition,g as fetchForm,k as sessionDraftStore}from'./chunk-
|
|
1
|
+
export{d as CloudError,i as createSubmitter,h as fetchDefinition,g as fetchForm,k as sessionDraftStore}from'./chunk-5YPOS62Y.js';import'./chunk-5WADJMJJ.js';//# sourceMappingURL=cloud.js.map
|
|
2
2
|
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { M as MessageCatalog, s as MessageKey, d as FormField } from './definition-o4Y0OY6y.js';
|
|
2
|
+
|
|
3
|
+
type MessageParams = Record<string, unknown>;
|
|
4
|
+
type MessageFn = (key: MessageKey, params: MessageParams, field: FormField) => string | undefined;
|
|
5
|
+
type MessageSource = MessageCatalog | MessageFn;
|
|
6
|
+
declare const DEFAULT_MESSAGES: Readonly<Record<MessageKey, string>>;
|
|
7
|
+
type ValidationRule = 'required' | 'minLength' | 'maxLength' | 'min' | 'max' | 'pattern' | 'matchField';
|
|
8
|
+
declare function getDefaultMessage(rule: ValidationRule | MessageKey, params?: Record<string, unknown>): string;
|
|
9
|
+
|
|
10
|
+
export { DEFAULT_MESSAGES as D, type MessageSource as M, type ValidationRule as V, type MessageFn as a, type MessageParams as b, getDefaultMessage as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
type MessageKey = 'required' | 'minLength' | 'maxLength' | 'minItems' | 'maxItems' | 'min' | 'max' | 'pattern' | 'matchField' | 'email' | 'number' | 'date' | 'datetime' | 'option' | 'options' | 'boolean' | 'string' | 'file' | 'value';
|
|
2
|
-
type LabelKey = 'continue' | 'back' | 'stepOf' | 'errorSummary';
|
|
1
|
+
type MessageKey = 'required' | 'minLength' | 'maxLength' | 'minItems' | 'maxItems' | 'min' | 'max' | 'pattern' | 'matchField' | 'email' | 'number' | 'date' | 'datetime' | 'time' | 'option' | 'options' | 'boolean' | 'string' | 'file' | 'value' | 'hidden';
|
|
2
|
+
type LabelKey = 'continue' | 'back' | 'stepOf' | 'errorSummary' | 'addItem' | 'removeItem' | 'itemLabel' | 'itemAdded' | 'itemRemoved' | 'removeItemNamed' | 'removeItemPrompt' | 'removeItemBody' | 'cancel';
|
|
3
3
|
type MessageCatalog = Partial<Record<MessageKey, string>>;
|
|
4
4
|
type LabelCatalog = Partial<Record<LabelKey, string>>;
|
|
5
5
|
interface FormI18n {
|
|
@@ -17,6 +17,13 @@ interface FieldI18n {
|
|
|
17
17
|
placeholder?: string;
|
|
18
18
|
helperText?: string;
|
|
19
19
|
}
|
|
20
|
+
interface GroupI18n {
|
|
21
|
+
label?: string;
|
|
22
|
+
helperText?: string;
|
|
23
|
+
itemLabel?: string;
|
|
24
|
+
addLabel?: string;
|
|
25
|
+
removeLabel?: string;
|
|
26
|
+
}
|
|
20
27
|
interface LabelI18n {
|
|
21
28
|
label?: string;
|
|
22
29
|
}
|
|
@@ -32,8 +39,12 @@ interface ValidationI18n {
|
|
|
32
39
|
type LabelFn = (key: LabelKey, params: Record<string, unknown>) => string | undefined;
|
|
33
40
|
type LabelSource = LabelCatalog | LabelFn;
|
|
34
41
|
|
|
35
|
-
type DefaultFieldType = 'text' | 'email' | 'phone' | 'number' | 'password' | 'select' | 'autocomplete' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'file' | 'date' | 'datetime' | 'textarea';
|
|
42
|
+
type DefaultFieldType = 'text' | 'email' | 'phone' | 'number' | 'password' | 'select' | 'autocomplete' | 'multiselect' | 'checkbox' | 'radio' | 'switch' | 'file' | 'date' | 'datetime' | 'time' | 'textarea' | 'hidden';
|
|
36
43
|
type FieldType = DefaultFieldType | (string & {});
|
|
44
|
+
type FieldSourceName = 'referrer' | 'page' | 'pageTitle' | 'language' | 'timezone' | 'device' | 'country';
|
|
45
|
+
type FieldSource = FieldSourceName | {
|
|
46
|
+
query: string;
|
|
47
|
+
};
|
|
37
48
|
interface FieldOption {
|
|
38
49
|
value: string;
|
|
39
50
|
label: string;
|
|
@@ -47,6 +58,7 @@ interface FormField {
|
|
|
47
58
|
helperText?: string;
|
|
48
59
|
autoAdvance?: boolean;
|
|
49
60
|
defaultValue?: unknown;
|
|
61
|
+
source?: FieldSource;
|
|
50
62
|
show?: ShowCondition[];
|
|
51
63
|
showAny?: ShowCondition[];
|
|
52
64
|
validation?: FieldValidation;
|
|
@@ -60,6 +72,41 @@ interface FormField {
|
|
|
60
72
|
inputMode?: 'text' | 'numeric' | 'decimal' | 'tel' | 'email' | 'url' | 'search';
|
|
61
73
|
i18n?: FieldI18n;
|
|
62
74
|
}
|
|
75
|
+
interface GroupValidation {
|
|
76
|
+
required?: boolean | string;
|
|
77
|
+
minLength?: number;
|
|
78
|
+
minLengthMessage?: string;
|
|
79
|
+
maxLength?: number;
|
|
80
|
+
maxLengthMessage?: string;
|
|
81
|
+
validator?: string;
|
|
82
|
+
i18n?: Pick<ValidationI18n, 'required' | 'minLength' | 'maxLength'>;
|
|
83
|
+
}
|
|
84
|
+
interface FormGroup {
|
|
85
|
+
key: string;
|
|
86
|
+
type: 'group';
|
|
87
|
+
label: string;
|
|
88
|
+
helperText?: string;
|
|
89
|
+
itemLabel?: string;
|
|
90
|
+
addLabel?: string;
|
|
91
|
+
removeLabel?: string;
|
|
92
|
+
defaultItems?: number;
|
|
93
|
+
show?: ShowCondition[];
|
|
94
|
+
showAny?: ShowCondition[];
|
|
95
|
+
validation?: GroupValidation;
|
|
96
|
+
fields: FormField[];
|
|
97
|
+
i18n?: GroupI18n;
|
|
98
|
+
}
|
|
99
|
+
interface FormSection {
|
|
100
|
+
key: string;
|
|
101
|
+
type: 'section';
|
|
102
|
+
title: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
show?: ShowCondition[];
|
|
105
|
+
showAny?: ShowCondition[];
|
|
106
|
+
fields: (FormField | FormGroup)[];
|
|
107
|
+
i18n?: StepI18n;
|
|
108
|
+
}
|
|
109
|
+
type FormNode = FormField | FormSection | FormGroup;
|
|
63
110
|
interface ShowCondition {
|
|
64
111
|
field: string;
|
|
65
112
|
eq?: string | number | boolean;
|
|
@@ -109,7 +156,7 @@ interface FormDefinition {
|
|
|
109
156
|
i18n?: FormI18n;
|
|
110
157
|
submit: FormAction;
|
|
111
158
|
cancel?: FormAction;
|
|
112
|
-
fields?:
|
|
159
|
+
fields?: FormNode[];
|
|
113
160
|
steps?: FormStep[];
|
|
114
161
|
}
|
|
115
162
|
interface StepRoute {
|
|
@@ -122,7 +169,7 @@ interface FormStep {
|
|
|
122
169
|
id: string;
|
|
123
170
|
title: string;
|
|
124
171
|
description?: string;
|
|
125
|
-
fields:
|
|
172
|
+
fields: FormNode[];
|
|
126
173
|
show?: ShowCondition[];
|
|
127
174
|
showAny?: ShowCondition[];
|
|
128
175
|
next?: FormAction | false;
|
|
@@ -131,4 +178,4 @@ interface FormStep {
|
|
|
131
178
|
i18n?: StepI18n;
|
|
132
179
|
}
|
|
133
180
|
|
|
134
|
-
export type { DefaultFieldType as D,
|
|
181
|
+
export type { DefaultFieldType as D, FormGroup as F, GroupI18n as G, LabelCatalog as L, MessageCatalog as M, ShowCondition as S, ValidationI18n as V, FormSection as a, FormNode as b, FormStep as c, FormField as d, FormAction as e, FieldI18n as f, FieldOption as g, FieldSource as h, FieldSourceName as i, FieldType as j, FieldValidation as k, FormDefinition as l, FormI18n as m, GroupValidation as n, LabelFn as o, LabelI18n as p, LabelKey as q, LabelSource as r, MessageKey as s, StepI18n as t, StepRoute as u };
|
package/dist/fix.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { D as DefinitionIssue } from './issues-Dua58e1J.js';
|
|
2
|
+
|
|
3
|
+
type PatchOperation = {
|
|
4
|
+
op: 'add' | 'replace';
|
|
5
|
+
path: string;
|
|
6
|
+
value: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
op: 'remove';
|
|
9
|
+
path: string;
|
|
10
|
+
} | {
|
|
11
|
+
op: 'move';
|
|
12
|
+
from: string;
|
|
13
|
+
path: string;
|
|
14
|
+
};
|
|
15
|
+
declare function applyFix<T>(definition: T, patch: readonly PatchOperation[]): T;
|
|
16
|
+
|
|
17
|
+
interface DefinitionFix {
|
|
18
|
+
title: string;
|
|
19
|
+
safe: boolean;
|
|
20
|
+
patch: PatchOperation[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface FixableIssue extends DefinitionIssue {
|
|
24
|
+
fixes?: DefinitionFix[];
|
|
25
|
+
}
|
|
26
|
+
interface AppliedFix extends DefinitionFix {
|
|
27
|
+
code: DefinitionIssue['code'];
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
interface FixAllResult<T> {
|
|
31
|
+
definition: T;
|
|
32
|
+
applied: AppliedFix[];
|
|
33
|
+
issues: FixableIssue[];
|
|
34
|
+
}
|
|
35
|
+
declare function suggestFixes(definition: unknown, issues?: readonly DefinitionIssue[]): FixableIssue[];
|
|
36
|
+
declare function fixAll<T>(definition: T, limit?: number): FixAllResult<T>;
|
|
37
|
+
|
|
38
|
+
export { type AppliedFix, type DefinitionFix, type FixAllResult, type FixableIssue, type PatchOperation, applyFix, fixAll, suggestFixes };
|
package/dist/fix.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {k as k$1,g as g$1,h as h$1}from'./chunk-TMO47L42.js';import'./chunk-QVA6DLYS.js';import {a,e}from'./chunk-5WADJMJJ.js';var it=new Set(["__proto__","constructor","prototype"]);function m(t){throw new Error(`Invalid patch: ${t}`)}function A(t){(typeof t!="string"||!t.startsWith("/"))&&m(`${JSON.stringify(t)} is not a JSON pointer to a property`);let n=t.slice(1).split("/").map(r=>r.replace(/~1/g,"/").replace(/~0/g,"~")),e=n.find(r=>it.has(r));return e!==void 0&&m(`"${e}" is not allowed in ${t}`),n}var U=t=>typeof t=="object"&&t!==null;function b(t,n){return Array.isArray(t)?/^(0|[1-9]\d*)$/.test(n)&&Number(n)<t.length:Object.prototype.hasOwnProperty.call(t,n)}function O(t,n){let e=A(n),r=e.pop(),o=t;for(let i of e)(!U(o)||!b(o,i))&&m(`${n} does not exist`),o=o[i];return U(o)||m(`${n} does not exist`),[o,r]}function st(t,n,e){let[r,o]=O(t,n);b(r,o)||m(`${n} does not exist`),r[o]=e;}function z(t,n){let[e,r]=O(t,n);if(b(e,r)||m(`${n} does not exist`),Array.isArray(e))return e.splice(Number(r),1)[0];let o=e[r];return delete e[r],o}function B(t,n,e){let[r,o]=O(t,n);if(!Array.isArray(r)){let a=(o==="id"||o==="key")&&!b(r,o)&&!b(r,"__proto__")?Object.entries(r):[];for(let[f]of a)delete r[f];r[o]=e;for(let[f,l]of a)r[f]=l;return}let i=o==="-"?r.length:/^(0|[1-9]\d*)$/.test(o)?Number(o):-1;(i<0||i>r.length)&&m(`${n} is not a valid array position`),r.splice(i,0,e);}var I=t=>t===void 0?t:JSON.parse(JSON.stringify(t));function S(t,n){Array.isArray(n)||m("the patch must be an array of operations");let e=I(t);for(let r of n){let{op:o,path:i}=r??{};o==="add"?B(e,i,I(r.value)):o==="replace"?st(e,i,I(r.value)):o==="remove"?z(e,i):o==="move"?((typeof i!="string"||typeof r.from!="string")&&m("a move needs path and from pointers"),(i===r.from||i.startsWith(`${r.from}/`))&&m(`${i} is inside ${r.from}`),B(e,i,z(e,r.from))):m(`${JSON.stringify(o)} is not a supported operation`);}return e}function K(t){return t.toLowerCase().normalize("NFKD").replace(/\p{M}/gu,"").replace(/['’]/g,"").replace(/[^a-z0-9]+/g," ").trim().split(" ").filter(Boolean)}function w(t,n,e=""){let r=new Set(n),o=t;for(let i=2;r.has(o);i++)o=`${t}${e}${i}`;return o}var N=(t,n)=>typeof t=="string"&&K(t).join("-")||n;function W(t,n){let e=typeof t=="string"?K(t).map((r,o)=>o?r[0].toUpperCase()+r.slice(1):r).join(""):"";return e?/^\d/.test(e)?`q${e}`:e:n}function D(t){let n=t.replace(/([a-z\d])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return n?n[0].toUpperCase()+n.slice(1):t}var u=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),x=t=>Array.isArray(t)?t:[],h=t=>typeof t=="string"?t:void 0,_=t=>t.filter(n=>typeof n=="string");function p(t,n){if(!n)return t;let e=t;for(let r of A(n))e=u(e)||Array.isArray(e)?e[r]:void 0;return e}var g=t=>t.slice(0,t.lastIndexOf("/")),k=t=>A(t).pop()??"",F=(t,n)=>`${t}/${n.replace(/~/g,"~0").replace(/\//g,"~1")}`;function T(t){return x(t).flatMap(n=>u(n)?[n,...T(n.fields)]:[])}function at(t){return [...T(t.fields),...x(t.steps).flatMap(n=>T(u(n)?n.fields:void 0))]}var E=t=>_(at(t).map(n=>n.key)),C=t=>_(x(t.steps).map(n=>u(n)?n.id:void 0)),R=t=>_(x(t).map(n=>u(n)?n.value:void 0));function Y(t){let n=new Set,e=(r,o)=>{if(Array.isArray(r))for(let i of r)o==="optionsDependsOn"&&typeof i=="string"?n.add(i):(o==="show"||o==="showAny"||o==="disabled")&&u(i)&&typeof i.field=="string"&&n.add(i.field),e(i);else if(u(r)){typeof r.matchField=="string"&&n.add(r.matchField);for(let[i,s]of Object.entries(r))e(s,i);}};return e(t),n}function Z(t,n){let e=[],r=(o,i)=>{if(Array.isArray(o))for(let s of o)(i==="show"||i==="showAny"||i==="disabled")&&u(s)&&s.field===n&&e.push(s.eq,s.neq,...x(s.in),...x(s.notIn)),r(s);else if(u(o))for(let[s,a]of Object.entries(o))r(a,s);};return r(t),e}var G=(t,n)=>t===void 0?void 0:n.exec(t)?.[1],H=t=>G(t.message,/missing required property "([^"]+)"/),P=t=>G(t.hint,/^Did you mean "([^"]+)"\?$/),c=(t,n,...e)=>({title:t,safe:n,patch:e}),d=(t,n)=>({op:"add",path:t,value:n}),y=t=>JSON.stringify(t);function Q(t,n){let e=t.toLowerCase(),r=n.toLowerCase(),o=Array.from({length:e.length+1},(i,s)=>Array.from({length:r.length+1},(a,f)=>s?f?0:s:f));for(let i=1;i<=e.length;i++)for(let s=1;s<=r.length;s++){let a=e[i-1]===r[s-1]?0:1;o[i][s]=Math.min(o[i-1][s]+1,o[i][s-1]+1,o[i-1][s-1]+a),i>1&&s>1&&e[i-1]===r[s-2]&&e[i-2]===r[s-1]&&(o[i][s]=Math.min(o[i][s],o[i-2][s-2]+1));}return o[e.length][r.length]}function ft(t){let n=(e,r)=>x(e).flatMap(o=>!u(o)||o.type==="group"?[]:[...o.type!=="section"&&typeof o.key=="string"?[{key:o.key,step:r}]:[],...n(o.fields,r)]);return [...n(t.fields,-1),...x(t.steps).flatMap((e,r)=>n(u(e)?e.fields:void 0,r))]}function ut(t,n){let e=n.split("/");return e.some((r,o)=>e[o-1]==="fields"&&p(t,e.slice(0,o+1).join("/"))?.type==="group")}function ct(t,n){let e=ft(t),r=/^(.*\/fields\/\d+)\/(show|showAny|validation|optionsDependsOn)\//.exec(n)?.[1],o=r?h(p(t,r)?.key):void 0,i=e.filter(({key:f})=>f!==o),s=Number(/^\/steps\/(\d+)/.exec(n)?.[1]??-1);if(s<0||!/\/(show|showAny)\/\d+\/field$/.test(n))return i.map(({key:f})=>f);let a=r||/\/routes\//.test(n)?s:s-1;return i.filter(f=>f.step<=a).map(({key:f})=>f)}function pt(t,n){let e=Number(/^\/steps\/(\d+)/.exec(n)?.[1]??-1);return x(t.steps).flatMap((r,o)=>o>e&&u(r)&&typeof r.id=="string"?[r.id]:[])}function lt(t,n,e){let r=[...new Set(n)].filter(i=>i!==t&&Q(t,i)<=2),o=r.filter(i=>Q(t,i)<=1);return o.length===1&&r.length===1&&e.includes(o[0])?{match:o[0],safe:true}:{match:g$1(t,e),safe:false}}function M(t,n,e){let r=h(p(t,n.path));if(r===void 0)return [];let o=e==="field"?E(t):dt(t),i=e==="field"?ct(t,n.path):pt(t,n.path),s=e==="field"&&ut(t,n.path),{match:a,safe:f}=lt(r,o,s?o:i);return a===void 0?[]:[c(`Use the ${e} ${y(a)}`,f&&!s,{op:"replace",path:n.path,value:a})]}var dt=t=>x(t.steps).flatMap(n=>u(n)&&typeof n.id=="string"?[n.id]:[]);var X=/^\/steps\/\d+$/,tt=/\/fields\/\d+$/,nt=/\/options\/\d+$/,yt=/^(\/steps\/\d+)?\/(submit|cancel|next|back|skip)$/,gt={submit:"Submit",cancel:"Cancel",next:"Continue",back:"Back",skip:"Skip"};function L(t,n){return c(`Rename "${k(t)}" to "${k(n)}"`,true,{op:"move",from:t,path:n})}function mt(t,n){let e=k(n),r=gt[e],o=e==="next"||e==="back"?t.labels!==void 0||t.lang!==void 0:e==="cancel";return r?[c(`Set the label to ${y(r)}`,!o,d(`${n}/label`,r))]:[]}function xt(t,n,e){let r=H(n),o=n.path,i=p(t,o);if(r===void 0||!u(i))return [];let s=F(o,r),a=e.find(l=>l.code==="unknown-property"&&g(l.path)===o&&P(l)===r);if(a)return [L(a.path,s)];if(r==="submit"&&o==="")return [c('Add a submit button labeled "Submit"',true,d(s,{label:"Submit"}))];if(r==="id"&&(o===""||X.test(o))){let l=w(N(i.title,o?`step-${Number(k(o))+1}`:"my-form"),o?C(t):[],"-");return [c(`Set the id to ${y(l)}`,true,d(s,l))]}if(r==="fields"&&X.test(o))return [c('Add an empty "fields" list',true,d(s,[]))];if(r==="key"&&tt.test(o)){let l=w(W(i.label,"field"),E(t));return [c(`Set the key to ${y(l)}`,true,d(s,l))]}if(r==="value"&&nt.test(o)){let l=w(N(i.label,`option-${Number(k(o))+1}`),R(p(t,g(o))),"-");return [c(`Set the value to ${y(l)}`,true,d(s,l))]}if(r!=="label")return [];if(yt.test(o))return mt(t,o);let f=tt.test(o)?h(i.key):nt.test(o)?h(i.value):void 0;return f?[c(`Set the label to ${y(D(f))}`,true,d(s,D(f)))]:[]}function ht(t,{path:n}){let e=h(p(t,g(n))?.key);return e?[c(`Set the label to ${y(D(e))}`,true,d(n,D(e)))]:[]}function kt(t,n){let e=g(n.path),r=k(n.path),o=P(n);if(o!==void 0)return [L(n.path,F(e,o))];if(!n.hint?.startsWith("Move "))return [];let i=p(t,`${e}/validation`);if(i!==void 0&&(!u(i)||r in i))return [];let s=F(`${e}/validation`,r),a={op:"move",from:n.path,path:s};return [c(`Move "${r}" into "validation"`,false,...i===void 0?[d(`${e}/validation`,{}),a]:[a])]}function wt(t,{path:n}){let e=h(p(t,n));if(e===void 0)return [];let r=w(e,E(t),"_");return [c(`Rename the key to ${y(r)}`,!Y(t).has(e),d(n,r))]}function $t(t,{path:n}){let e=h(p(t,n)),r=g(g(n)),o=p(t,g(r));if(e===void 0||!u(o))return [];let i=w(e,R(p(t,r)),"_"),a=(Array.isArray(o.defaultValue)?o.defaultValue:[o.defaultValue]).includes(e)||typeof o.key=="string"&&Z(t,o.key).includes(e);return [c(`Change the value to ${y(i)}`,!a,d(n,i))]}function bt(t,{path:n}){let e=h(p(t,n));if(e===void 0)return [];let r=w(e,C(t),"-"),o=JSON.stringify(t.steps).includes(`"to":${y(e)}`);return [c(`Rename the step id to ${y(r)}`,!o,d(n,r))]}function Dt(t,n,e,r){let o=h(p(t,n.path)),i=o===void 0?void 0:g$1(o,e);return i===void 0?[]:[c(`Use the ${r} ${y(i)}`,false,{op:"replace",path:n.path,value:i})]}function Ft(t,{path:n}){let e=p(t,g(n)),r=g$1(k(n),[...a]);return r===void 0||!u(e)||r in e?[]:[{...L(n,F(g(n),r)),safe:false}]}function Et(t,{path:n}){let e=p(t,g(n)),r=k(n),o=r==="min"?"max":"maxLength";if(!u(e))return [];let i=g(n);return [c(`Swap ${r} and ${o}`,false,d(`${i}/${r}`,e[o]),d(`${i}/${o}`,e[r]))]}function et(t,n){let e=/^v?(\d+)(\.\d+)*$/i.exec(String(t.formatVersion))?.[1],r=!n&&e!==void 0&&Number(e)===parseInt(h$1,10);return [c(`Set formatVersion to ${y(h$1)}`,r,{op:"replace",path:"/formatVersion",value:h$1})]}function rt(t,n,e$1){switch(n.code){case "missing-property":return xt(t,n,e$1);case "unknown-property":return kt(t,n);case "empty-label":return ht(t,n);case "duplicate-key":return wt(t,n);case "duplicate-option-value":return $t(t,n);case "duplicate-step-id":return bt(t,n);case "unknown-field":return M(t,n,"field");case "route-target":return M(t,n,"step");case "unknown-field-type":return Dt(t,n,e,"type");case "unknown-operator":return Ft(t,n);case "invalid-range":return Et(t,n);case "unsupported-format-version":return et(t,true);case "invalid-type":return n.path==="/formatVersion"?et(t,false):[];default:return []}}function vt(t,n,e){try{return rt(t,n,e)}catch{return []}}function V(t,n){let e=n??k$1(t);return u(t)?e.map(r=>{let o=vt(t,r,e);return o.length?{...r,fixes:o}:{...r}}):e.map(r=>({...r}))}function At(t,n=500){let e=t,r=[],o=new Set;for(let i=0;i<n;i++){let s=V(e).flatMap(({code:a,path:f,fixes:l=[]})=>l.map(ot=>({...ot,code:a,path:f}))).find(a=>a.safe&&!o.has(JSON.stringify(a.patch)));if(!s)break;o.add(JSON.stringify(s.patch));try{e=S(e,s.patch),r.push(s);}catch{}}return {definition:e,applied:r,issues:V(e)}}
|
|
2
|
+
export{S as applyFix,At as fixAll,V as suggestFixes};//# sourceMappingURL=fix.js.map
|
|
3
|
+
//# sourceMappingURL=fix.js.map
|