telepact-console 1.0.0-alpha.264 → 1.0.0-alpha.266

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.
@@ -181,7 +181,7 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
181
181
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
182
182
  `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey)if(!t.sep)if(Bd(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=Wd(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Bd(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Hd(t.key)&&!Bd(t.sep,`newline`)){let e=Wd(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken);else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Bd(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Bd(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Bd(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=Wd(Ud(t));Gd(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
183
183
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
184
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Wd(Ud(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Wd(Ud(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function qd(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new zd||null,prettyErrors:t}}function Jd(e,t={}){let{lineCounter:n,prettyErrors:r}=qd(t),i=new Kd(n?.addNewLine),a=new Ed(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Hu(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Wu(e,n)),o.warnings.forEach(Wu(e,n))),o}function Yd(e){return JSON.stringify(e)}function Xd(e,t){let n=e.linePos(t);return{row:n.line,col:n.col}}function Zd(e,t){let n=t?.range?.[0];return typeof n==`number`?Xd(e,n):{row:1,col:1}}function Qd(e,t,n,r){let i=e?.constructor?.name;if(i===`YAMLSeq`){for(let i=0;i<(e?.items?.length??0);i+=1){let a=e?.items?.[i],o=[...t,i];r[Yd(o)]=Zd(n,a),Qd(a,o,n,r)}return}if(i===`YAMLMap`)for(let i of e?.items??[]){let e=i.key?.value;if(typeof e!=`string`)continue;let a=[...t,e];r[Yd(a)]=Zd(n,i.key),Qd(i.value,a,n,r)}}function $d(e){let t=e?.constructor?.name;if(t===`YAMLSeq`){for(let t of e?.items??[])$d(t);return}if(t===`YAMLMap`){let t=new Set;for(let n of e?.items??[]){let e=String(n.key?.value);if(t.has(e))throw Error(`Duplicate YAML key`);t.add(e),$d(n.value)}}}function ef(e,t,n){if((e.errors?.length??0)>0)throw Error(e.errors?.[0]?.message??`YAML parse failed`);let r={};return $d(e.contents),r[Yd([])]=Zd(t,e.contents),Qd(e.contents,[],t,r),e=>r[Yd(e)]??{row:1,col:1}}function tf(e){let t=new zd;return ef(Jd(e,{lineCounter:t,merge:!1,prettyErrors:!1,strict:!0}),t)}function nf(e,t){try{return tf(t)(e)}catch{return{row:1,col:1}}}var rf=Symbol(`telepactDocumentLocators`);function af(e,t){Object.defineProperty(e,rf,{configurable:!0,enumerable:!1,value:{...t},writable:!0})}function of(e){return e[rf]}function sf(e,t){let n=of(e);n!==void 0&&af(t,n)}function cf(e,t,n){let r=of(n)?.[t];return r===void 0?nf(e,n[t]??`[]`):r(e)}function lf(e,t){let n=[];for(let r of e){let e=cf(r.path,r.documentName,t),i={};i.document=r.documentName,i.location=e,i.path=r.path,i.reason={[r.reason]:r.data},n.push(Object.assign({},i))}return n}var uf=class extends Error{schemaParseFailures;schemaParseFailuresPseudoJson;constructor(e,t,n){super(JSON.stringify(lf(e,t),null,2),{cause:n}),this.schemaParseFailures=e,this.schemaParseFailuresPseudoJson=lf(e,t)}};function df(e,t,n,r,i,a){let o=[],s=e.name,c=r[s],l=n[s];for(let u in t){if(!u.startsWith(`fn.`)||u.endsWith(`.->`))continue;let d=t[u+`.->`],f=u,p=a[f],m=new RegExp(p),h=d.tags,g=e.errors.tags;if(m.exec(s))for(let t in g){let a=g[t],u=t;if(u in h){let t=r[f],a=e.errors.tagIndices[u],p=n[f],m=[t,`->`,d.tagIndices[u],u],h=cf(m,p,i);o.push(new sc(l,[c,s,a,u],`PathCollision`,{document:p,path:m,location:h}))}h[u]=a}}if(o.length>0)throw new uf(o,i)}function ff(e,t,n,r,i){let a=[],o=[...t];o.sort((e,t)=>{let i=r[e],a=r[t];return i===a?n[e]-n[t]:i.localeCompare(a)});for(let t=0;t<o.length;t++)for(let s=t+1;s<o.length;s++){let c=o[t],l=o[s],u=n[c],d=n[l],f=r[c],p=r[l],m=e[f],h=e[p],g=m[u],_=h[d],v=g[c],y=_[l];for(let e=0;e<v.length;e++){let t=v[e],n=new Set(Object.keys(t));n.delete(`///`);for(let t=0;t<y.length;t++){let r=y[t],o=new Set(Object.keys(r));if(o.delete(`///`),n.size===o.size&&[...n].every(e=>o.has(e))){let r=n.values().next().value,s=o.values().next().value,m=[u,c,e,r],h=cf(m,f,i);a.push(new sc(p,[d,l,t,s],`PathCollision`,{document:f,path:m,location:h}))}}}}if(a.length>0)throw new uf(a,i)}function pf(e,t){for(let n of e)if(t.startsWith(`info.`)&&n.startsWith(`info.`)||n===t)return n;return null}function mf(e,t,n,r){let i=/^(((fn|errors|headers|info)|((struct|union|_ext)(<[0-2]>)?))\..*)/,a=[],o=Object.keys(t).sort();for(let e of o)i.test(e)&&a.push(e);if(a.length===1)return a[0];throw new uf([new sc(e,[n],`ObjectKeyRegexMatchCountUnexpected`,{regex:i.toString().slice(1,-1),actual:a.length,expected:1,keys:o})],r)}function hf(e){return typeof e==`boolean`?[]:es([],e,_f)}function gf(e,t,n){return t?e:n.randomGenerator.nextBoolean()}var _f=`Boolean`,vf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return hf(e)}generateRandomValue(e,t,n,r){return gf(e,t,r)}getName(){return _f}};function yf(e){return typeof e==`number`&&Number.isInteger(e)?e===0x8000000000000000||e===-0x8000000000000000?[new Qo([],`NumberOutOfRange`,{}),new Qo([],`NumberTruncated`,{})]:[]:es([],e,xf)}function bf(e,t,n){return t?e:n.randomGenerator.nextInt()}var xf=`Integer`,Sf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return yf(e)}generateRandomValue(e,t,n,r){return bf(e,t,r)}getName(){return xf}};function Cf(e){return typeof e==`number`?Number.isInteger(e)&&e===0x8000000000000000||e===-0x8000000000000000?[new Qo([],`NumberOutOfRange`,{}),new Qo([],`NumberTruncated`,{})]:[]:es([],e,Tf)}function wf(e,t,n){return t?e:n.randomGenerator.nextDouble()}var Tf=`Number`,Ef=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Cf(e)}generateRandomValue(e,t,n,r){return wf(e,t,r)}getName(){return Tf}};function Df(e){return typeof e==`string`?[]:es([],e,kf)}function Of(e,t,n){return t?e:n.randomGenerator.nextString()}var kf=`String`,Af=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Df(e)}generateRandomValue(e,t,n,r){return Of(e,t,r)}getName(){return kf}};function jf(e){let t=e.randomGenerator.nextIntWithCeiling(3);return t===0?e.randomGenerator.nextBoolean():t===1?e.randomGenerator.nextInt():e.randomGenerator.nextString()}var Mf=`Any`,Nf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return[]}generateRandomValue(e,t,n,r){return jf(r)}getName(){return Mf}};function Pf(e,t){if(e instanceof Uint8Array)return t.coerceBase64&&Ff(t.path,t.base64Coercions),[];if(typeof e==`string`)try{if(Lo(Ro(e))!==e)throw Error(`Invalid base64`);return t.coerceBase64||Ff(t.path,t.bytesCoercions),[]}catch{return es([],e,`Base64String`)}else return es([],e,Lf)}function Ff(e,t){let n=e[0];e.length>1?(t[n]=t[n]||{},Ff(e.slice(1),t[n])):t[n]=!0}function If(e,t,n){return t?e:n.randomGenerator.nextBytes()}var Lf=`Bytes`,Rf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Pf(e,n)}generateRandomValue(e,t,n,r){return If(e,t,r)}getName(){return Lf}};function zf(e,t,n,r){return[new sc(e,t,`TypeUnexpected`,{actual:{[$o(n)]:{}},expected:{[r]:{}}})]}var Bf=class{fieldName;typeDeclaration;optional;constructor(e,t,n){this.fieldName=e,this.typeDeclaration=t,this.optional=n}};function Vf(e,t,n){if(typeof t==`string`){let r=t,i=`^(.*?)(\\?)?$`,a=new RegExp(i),o=r.match(a);if(!o)throw new uf([new sc(n.documentName,e,`StringRegexMatchFailed`,{regex:i})],n.telepactSchemaDocumentNamesToJson);let s=o[1],c=o[2]!==void 0,l=up(e,s,n);if(l.getTypeParameterCount()!==0)throw new uf([new sc(n.documentName,e,`ArrayLengthUnexpected`,{actual:1,expected:l.getTypeParameterCount()+1})],n.telepactSchemaDocumentNamesToJson);return new Ts(l,c,[])}else if(Array.isArray(t)){let r=t;if(r.length!==1)throw new uf([new sc(n.documentName,e,`ArrayLengthUnexpected`,{actual:r.length,expected:1})],n.telepactSchemaDocumentNamesToJson);let i=r[0],a=[...e,0];return new Ts(new gs,!1,[Vf(a,i,n)])}else if(typeof t==`object`&&t){let r=t,i=Object.keys(r);if(i.length!==1)throw new uf([new sc(n.documentName,e,`ObjectSizeUnexpected`,{actual:i.length,expected:1})],n.telepactSchemaDocumentNamesToJson);let a=i[0],o=r[a];if(a!==`string`){let t=[...e,a];throw new uf([new sc(n.documentName,e,`RequiredObjectKeyMissing`,{key:`string`}),new sc(n.documentName,t,`ObjectKeyDisallowed`,{})],n.telepactSchemaDocumentNamesToJson)}let s=[...e,a];return new Ts(new bs,!1,[Vf(s,o,n)])}else throw new uf(zf(n.documentName,e,t,`StringOrArrayOrObject`),n.telepactSchemaDocumentNamesToJson)}function Hf(e,t,n,r,i){let a=r?`^@[a-z][a-zA-Z0-9_]*$`:`^([a-z][a-zA-Z0-9_]*)(!)?$`,o=new RegExp(a),s=t.match(o);if(!s){let n=[...e,t];throw new uf([new sc(i.documentName,n,`KeyRegexMatchFailed`,{regex:a})],i.telepactSchemaDocumentNamesToJson)}let c=s[0],l=r?!0:!!s[2];return new Bf(c,Vf([...e,c],n,i),l)}function Uf(e,t,n,r){let i=[],a={};for(let o in t){for(let t in a){let n=t.split(`!`)[0],a=o.split(`!`)[0];if(a===n){let t=[...e];i.push(new sc(r.documentName,t,`DuplicateField`,{field:a}))}}try{let i=Hf(e,o,t[o],n,r),s=i.fieldName;a[s]=i}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return a}function Wf(e,t,n,r,i,a){let o=[],s=new Set(Object.keys(t));s.delete(n),s.delete(`///`);for(let e of r)s.delete(e);if(s.size>0)for(let t of s){let n=e.concat(t);o.push(new sc(a.documentName,n,`ObjectKeyDisallowed`,{}))}let c=e.concat(n),l=t[n];if(!Array.isArray(l)){let e=zf(a.documentName,c,l,`Array`);throw o.push(...e),new uf(o,a.telepactSchemaDocumentNamesToJson)}let u=l,d=[],f=-1;for(let e of u){f+=1;let t=c.concat(f);if(typeof e!=`object`||Array.isArray(e)||e==null){let n=zf(a.documentName,t,e,`Object`);o.push(...n);continue}d.push(e)}if(o.length>0)throw new uf(o,a.telepactSchemaDocumentNamesToJson);if(d.length===0)o.push(new sc(a.documentName,c,`EmptyArrayDisallowed`,{}));else for(let e of i){let t=!1;for(let n of d){let r=new Set(Object.keys(n));if(r.delete(`///`),r.has(e)){t=!0;break}}t||o.push(new sc(a.documentName,c,`RequiredObjectKeyMissing`,{key:e}))}let p={},m={};for(let e=0;e<d.length;e++){let t=d[e],r=c.concat(e),i=Object.fromEntries(Object.entries(t));delete i[`///`];let s=Object.keys(i),l=`^([A-Z][a-zA-Z0-9_]*)$`,u=new RegExp(l),f=s.filter(e=>u.test(e));if(f.length!==1){o.push(new sc(a.documentName,r,`ObjectKeyRegexMatchCountUnexpected`,{regex:l,actual:f.length,expected:1,keys:s}));continue}if(Object.keys(i).length!==1){o.push(new sc(a.documentName,r,`ObjectSizeUnexpected`,{expected:1,actual:Object.keys(i).length}));continue}let h=Object.entries(i)[0],g=h[0],_=r.concat(g);if(typeof h[1]!=`object`||Array.isArray(h[1])||h[1]===null||h[1]===void 0){let e=zf(a.documentName,_,h[1],`Object`);o.push(...e);continue}let v=h[1];try{let t=Uf(_,v,!1,a);p[g]=new ds(`${n}.${g}`,t),m[g]=e}catch(e){if(e instanceof uf)o.push(...e.schemaParseFailures);else throw e}}if(o.length>0)throw new uf(o,a.telepactSchemaDocumentNamesToJson);return new cs(n,p,m)}function Gf(e,t){let n={},r=t.tags.Ok_.fields,i=Object.keys(r);i.sort();for(let e of Object.values(r))Kf(e.typeDeclaration,n);let a={};a[`->`]={Ok_:i};let o=Object.keys(n).sort();for(let e of o){if(e.startsWith(`fn.`))continue;let t=n[e];if(t instanceof cs){let n={},r=Object.keys(t.tags).sort();for(let e of r){let r=t.tags[e],i=[],a=Object.keys(r.fields).sort();for(let e of a)i.push(e);i.length>0&&(n[e]=i)}a[e]=n}else if(t instanceof ds){let n=[],r=Object.keys(t.fields).sort();for(let e of r)n.push(e);n.length>0&&(a[e]=n)}}return a}function Kf(e,t){let n=e.type;if(n instanceof cs){t[n.name]=n;for(let e of Object.values(n.tags))for(let n of Object.values(e.fields))Kf(n.typeDeclaration,t)}else if(n instanceof ds){t[n.name]=n;for(let e of Object.values(n.fields))Kf(e.typeDeclaration,t)}else (n instanceof gs||n instanceof bs)&&Kf(e.typeParameters[0],t)}function qf(e,t,n,r){let i=[],a=null;if(!(`->`in t))i.push(new sc(r.documentName,e,`RequiredObjectKeyMissing`,{key:`->`}));else try{a=Wf(e,t,`->`,Object.keys(t),[`Ok_`],r)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);let o=Gf(n,a),s=up([],`_ext.Select_`,r);return s.possibleSelects[n]=o,a}function Jf(e,t,n,r){let i=[],a=`_errors`,o=[...e,a],s=null;if(a in t&&!n.endsWith(`_`))i.push(new sc(r.documentName,o,`ObjectKeyDisallowed`,{}));else{let e=a in t?t[a]:`^errors\\..*$`;if(typeof e!=`string`){let t=zf(r.documentName,o,e,`String`);i.push(...t)}else s=e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return s}function Yf(e,t,n,r,i){let a=[],o=new Set(Object.keys(t));o.delete(n),o.delete(`///`),o.delete(`_ignoreIfDuplicate`);for(let e of r)o.delete(e);if(o.size>0)for(let t of o){let n=[...e,t];a.push(new sc(i.documentName,n,`ObjectKeyDisallowed`,{}))}let s=[...e,n],c=t[n],l=null;if(typeof c!=`object`||Array.isArray(c)||c==null){let e=zf(i.documentName,s,c,`Object`);a.push(...e)}else l=c;if(a.length>0)throw new uf(a,i.telepactSchemaDocumentNamesToJson);return new ds(n,Uf(s,l,!1,i))}function Xf(e,t,n){if(typeof e!=`object`||Array.isArray(e)||e==null)return es([],e,`Object`);let r=t[n.fn];return Zf([],e,r)}function Zf(e,t,n){if(Array.isArray(n)){if(!Array.isArray(t))return es(e,t,`Array`);let r=[];for(let[i,a]of t.entries())n.includes(a)||r.push(new Qo([...e,i],`ArrayElementDisallowed`,{}));return r}else if(typeof n==`object`&&!Array.isArray(n)){if(typeof t!=`object`||Array.isArray(t)||t===null)return es(e,t,`Object`);let r=[];for(let[i,a]of Object.entries(t))if(i in n){let t=Zf([...e,i],a,n[i]);r.push(...t)}else r.push(new Qo([...e,i],`ObjectKeyDisallowed`,{}));return r}return[]}function Qf(e,t){let n=e[t.fnScope];return $f(n,t)}function $f(e,t){if(Array.isArray(e)){let n=[];for(let r of e)t.randomGenerator.nextBoolean()&&n.push(r);return n.sort()}else if(typeof e==`object`&&!Array.isArray(e)){let n={},r=Object.keys(e).sort();for(let i of r){let r=e[i];if(t.randomGenerator.nextBoolean()){let e=$f(r,t);if(typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0)continue;n[i]=e}}return n}else throw Error(`Invalid possibleSelectSection`)}var ep=`Object`,tp=class{possibleSelects={};getTypeParameterCount(){return 0}validate(e,t,n){return Xf(e,this.possibleSelects,n)}generateRandomValue(e,t,n,r){return Qf(this.possibleSelects,r)}getName(){return ep}};function np(e,t,n){if(!(typeof e==`object`&&!Array.isArray(e)))return es([],e,`Object`);let r=e,i=/^fn\..*$/,a=Object.keys(r).sort(),o=a.filter(e=>i.test(e));if(o.length!==1)return[new Qo([],`ObjectKeyRegexMatchCountUnexpected`,{regex:i.toString().slice(1,-1),actual:o.length,expected:1,keys:a})];let s=o[0],c=t[s],l=r[s],u=c,d=s,f=u.tags[d].validate(l,[],n),p=[];for(let e of f){let t=[s,...e.path];p.push(new Qo(t,e.reason,e.data))}return p.filter(e=>e.reason!==`RequiredObjectKeyMissing`)}function rp(e,t){let n=Object.entries(e).filter(([e,t])=>e.startsWith(`fn.`)&&!e.endsWith(`.->`)).filter(([e,t])=>!e.endsWith(`_`)).map(([e,t])=>t);n.sort((e,t)=>e.name.localeCompare(t.name));let r=n[Math.floor(t.randomGenerator.nextIntWithCeiling(n.length))];return os(null,!1,r.tags,t.copy({alwaysIncludeRequiredFields:!1}))}var ip=`_ext.Call_`,ap=class extends fs{types;constructor(e){super(),this.types=e}getTypeParameterCount(){return 0}validate(e,t,n){return np(e,this.types,n)}generateRandomValue(e,t,n,r){return rp(this.types,r)}getName(){return ip}};function op(e,t,n){let r=[];if(!(typeof e==`object`&&!Array.isArray(e)))return es([],e,`Object`);let i=e,a=/^fn\..*$/,o=Object.keys(i).sort(),s=o.filter(e=>a.test(e));if(s.length!==1)return[new Qo([],`ObjectKeyRegexMatchCountUnexpected`,{regex:a.toString().slice(1,-1),actual:s.length,expected:1,keys:o})];let c=s[0],l=i[c],u=t[c],d=t[`${c}.->`],f=c,p=u.tags[f].validate(l,[],n),m=[];for(let e of p){let t=[c,...e.path];m.push(new Qo(t,e.reason,e.data))}let h=m.filter(e=>e.reason!==`RequiredObjectKeyMissing`);if(r.push(...h),!(`->`in i))r.push(new Qo([],`RequiredObjectKeyMissing`,{key:`->`}));else{let e=i[`->`],t=d.validate(e,[],n),a=[];for(let e of t){let t=[`->`,...e.path];a.push(new Qo(t,e.reason,e.data))}let o=a.filter(e=>e.reason!==`RequiredObjectKeyMissing`);r.push(...o)}let g=Object.keys(i).filter(e=>!s.includes(e)&&e!==`->`);for(let e of g)r.push(new Qo([e],`ObjectKeyDisallowed`,{}));return r}function sp(e,t){let n=Object.keys(e).filter(e=>e.startsWith(`fn.`)&&!e.endsWith(`.->`)).filter(e=>!e.endsWith(`_`)).map(e=>e);n.sort((e,t)=>e.localeCompare(t));let r=n[t.randomGenerator.nextIntWithCeiling(n.length)],i=e[r],a=e[r+`.->`],o=i.tags[r].fields,s=a.tags.Ok_.fields,c=as(null,!1,o,t.copy({alwaysIncludeRequiredFields:!1})),l=as(null,!1,s,t.copy({alwaysIncludeRequiredFields:!1}));return{[r]:c,"->":{Ok_:l}}}var cp=`_ext.Stub_`,lp=class extends fs{types;constructor(e){super(),this.types=e}getTypeParameterCount(){return 0}validate(e,t,n){return op(e,this.types,n)}generateRandomValue(e,t,n,r){return sp(this.types,r)}getName(){return cp}};function up(e,t,n){if(n.failedTypes.has(t))throw new uf([],n.telepactSchemaDocumentNamesToJson);let r=n.parsedTypes[t];if(r!==void 0)return r;let i=`^(boolean|integer|number|string|any|bytes)|((fn|(union|struct|_ext))\\.([a-zA-Z_]\\w*))$`,a=new RegExp(i),o=t.match(a);if(!o)throw new uf([new sc(n.documentName,e,`StringRegexMatchFailed`,{regex:i})],n.telepactSchemaDocumentNamesToJson);let s=o[1];if(s)return{boolean:new vf,integer:new Sf,number:new Ef,string:new Af,bytes:new Rf}[s]||new Nf;let c=o[2],l=n.schemaKeysToIndex[c],u=n.schemaKeysToDocumentName[c];if(l===void 0)throw new uf([new sc(n.documentName,e,`TypeUnknown`,{name:c})],n.telepactSchemaDocumentNamesToJson);let d=n.telepactSchemaDocumentNamesToPseudoJson[u][l],f;try{if(c.startsWith(`struct`)){let e=new ds(c,{});f=e,n.parsedTypes[c]=f,e.fields=Yf([l],d,c,[],n.copy({documentName:u})).fields}else if(c.startsWith(`union`)){let e=new cs(c,{},{});f=e,n.parsedTypes[c]=f;let t=Wf([l],d,c,[],[],n.copy({documentName:u}));e.tags=t.tags,e.tagIndices=t.tagIndices}else if(c.startsWith(`fn`)){let e=new cs(c,{},{});f=e,n.parsedTypes[c]=f;let t=Yf([l],d,c,[`->`,`_errors`],n.copy({documentName:u}));e.tags[c]=t,e.tagIndices[c]=0;let r=qf([l],d,c,n.copy({documentName:u}));n.parsedTypes[c+`.->`]=r;let i=Jf([l],d,c,n.copy({documentName:u}));n.fnErrorRegexes[c]=i}else{let e={"_ext.Select_":new tp,"_ext.Call_":new ap(n.parsedTypes),"_ext.Stub_":new lp(n.parsedTypes)}[c];if(!e)throw new uf([new sc(n.documentName,[l],`TypeExtensionImplementationMissing`,{name:c})],n.telepactSchemaDocumentNamesToJson);f=e,n.parsedTypes[c]=f}return f}catch(e){throw e instanceof uf?(n.allParseFailures.push(...e.schemaParseFailures),n.failedTypes.add(c),new uf([],n.telepactSchemaDocumentNamesToJson)):e}}var dp=class{name;errors;constructor(e,t){this.name=e,this.errors=t}};function fp(e,t,n,r){let i=[],a=Object.keys(t).filter(e=>e!==n&&e!==`///`);if(a.length>0)for(let t of a){let n=e.concat(t);i.push(new sc(r.documentName,n,`ObjectKeyDisallowed`,{}))}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return new dp(n,Wf(e,t,n,[],[],r))}var pp=class{name;requestHeaders;responseHeaders;constructor(e,t,n){this.name=e,this.requestHeaders=t,this.responseHeaders=n}};function mp(e,t,n,r){let i=[],a={},o={},s=t[n],c=[...e,n];if(typeof s!=`object`||Array.isArray(s)||s==null){let e=zf(r.documentName,c,s,`Object`);i.push(...e)}else try{let e=Uf(c,s,!0,r);for(let t in e)e[t].optional=!0;Object.assign(a,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}let l=[...e,`->`];`->`in t||i.push(new sc(r.documentName,l,`RequiredObjectKeyMissing`,{key:`->`}));let u=t[`->`];if(typeof u!=`object`||Array.isArray(u)||u==null){let e=zf(r.documentName,c,u,`Object`);i.push(...e)}else try{let e=Uf(l,u,!0,r);for(let t in e)e[t].optional=!0;Object.assign(o,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return new pp(n,a,o)}var hp=class e{documentName;telepactSchemaDocumentNamesToPseudoJson;telepactSchemaDocumentNamesToJson;schemaKeysToDocumentName;schemaKeysToIndex;parsedTypes;fnErrorRegexes;allParseFailures;failedTypes;constructor(e,t,n,r,i,a,o,s,c){this.documentName=e,this.telepactSchemaDocumentNamesToPseudoJson=t,this.telepactSchemaDocumentNamesToJson=n,this.schemaKeysToDocumentName=r,this.schemaKeysToIndex=i,this.parsedTypes=a,this.fnErrorRegexes=o,this.allParseFailures=s,this.failedTypes=c}copy({documentName:t}){return new e(t??this.documentName,this.telepactSchemaDocumentNamesToPseudoJson,this.telepactSchemaDocumentNamesToJson,this.schemaKeysToDocumentName,this.schemaKeysToIndex,this.parsedTypes,this.fnErrorRegexes,this.allParseFailures,this.failedTypes)}};function gp(e,t,n,r,i){let a=[],o=[...t];o.sort((e,t)=>{let i=r[e],a=r[t];return i===a?n[e]-n[t]:i.localeCompare(a)});for(let t=0;t<o.length;t++)for(let s=t+1;s<o.length;s++){let c=o[t],l=o[s],u=n[c],d=n[l],f=r[c],p=r[l],m=e[f],h=e[p],g=m[u],_=h[d],v=g[c],y=_[l],b=Object.keys(v).filter(e=>e in y);for(let e of b){let t=[u,c,e],n=cf(t,f,i);a.push(new sc(p,[d,l,e],`PathCollision`,{document:f,path:t,location:n}))}let x=g[`->`],S=_[`->`],C=Object.keys(x).filter(e=>e in S);for(let e of C){let t=[u,`->`,e],n=cf(t,f,i);a.push(new sc(p,[d,`->`,e],`PathCollision`,{document:f,path:t,location:n}))}}if(a.length>0)throw new uf(a,i)}function _p(e,t){return e.nullable||e.type instanceof gs||e.type instanceof bs?!0:e.type instanceof ds||e.type instanceof cs?t.has(e.type.name):!0}function vp(e,t){return Object.values(e).every(e=>e.optional||_p(e.typeDeclaration,t))}function yp(e,t){return e instanceof ds?vp(e.fields,t):e instanceof cs?Object.values(e.tags).some(e=>vp(e.fields,t)):!0}function bp(e,t,n,r){let i=new Set,a=!0;for(;a;){a=!1;for(let[t,n]of Object.entries(e))i.has(t)||yp(n,i)&&(i.add(t),a=!0)}let o=[];for(let[r,a]of Object.entries(t)){if(r.startsWith(`info.`)||r.startsWith(`headers.`)||r.startsWith(`errors.`))continue;let t=[r];r.startsWith(`fn.`)&&t.push(`${r}.->`);for(let s of t)if(e[s]!==void 0&&!i.has(s)){let e=s.endsWith(`.->`)?[n[r],`->`]:[n[r],r];o.push(new sc(a,e,`RecursiveTypeUnterminated`,{}))}}if(o.length>0)throw new uf(o,r)}function xp(e){let t={},n={},r={},i=[],a={},o=new Set,s={},c={},l=new Set,u=Object.keys(e).sort(),d={};for(let[t,n]of Object.entries(e)){let r;try{r=JSON.parse(n)}catch(n){throw new uf([new sc(t,[],`JsonInvalid`,{})],e,n)}if(!Array.isArray(r))throw new uf(zf(t,[],r,`Array`),e);d[t]=r}for(let r of u){let a=d[r],o=-1;for(let u of a){o+=1;let a=[o];if(typeof u!=`object`||Array.isArray(u)||u==null){let e=zf(r,a,u,`Object`);i.push(...e);continue}let d=u;try{let u=mf(r,d,o,e),f=pf(l,u);if(f!==null){let t=s[f],n=c[f],o=[...a,u],l=cf([t,f],n,e);i.push(new sc(r,o,`PathCollision`,{document:n,location:l,path:[t,f]}));continue}l.add(u),s[u]=o,c[u]=r,(r===`auto_`||r===`auth_`||!r.endsWith(`_`))&&(t[u]=d),n[u]=d}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}}if(i.length>0)throw new uf(i,e);let f=new Set,p=new Set;for(let t of l){if(t.startsWith(`info.`))continue;if(t.startsWith(`headers.`)){f.add(t);continue}else if(t.startsWith(`errors.`)){p.add(t);continue}let n=s[t],l=c[t];try{up([n],t,new hp(l,d,e,c,s,r,a,i,o))}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,e);let m=[];try{for(let t of p){let n=s[t],l=c[t],u=d[l][n];try{let f=fp([n],u,t,new hp(l,d,e,c,s,r,a,i,o));m.push(f)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);try{ff(d,p,s,c,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);for(let t of m)try{df(t,r,c,s,e,a)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}try{bp(r,c,s,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}let h=[];for(let t of f){let n=s[t],l=c[t],u=d[l][n];try{let f=mp([n],u,t,new hp(l,d,e,c,s,r,a,i,o));h.push(f)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,e);try{gp(d,f,s,c,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);let g={},_={};for(let e of h)Object.assign(g,e.requestHeaders),Object.assign(_,e.responseHeaders);let v=(e,t)=>{let n=e.startsWith(`info.`),r=t.startsWith(`info.`);return n&&!r?-1:!n&&r?1:e<t?-1:+(e>t)};return new Op(Object.keys(t).sort(v).map(e=>t[e]),Object.keys(n).sort(v).map(e=>n[e]),r,g,_)}function Sp(e){let t={...e};sf(e,t);let n=ic();Cp(e,`internal_`,n)||(t.internal_=n);let r=oc();for(let n of Object.values(e))if(/"union\.Auth_"\s*:/.test(n)){Cp(e,`auth_`,r)||(t.auth_=r);break}return xp(t)}function Cp(e,t,n){let r=wp({[t]:n});if(r===null)return!1;let i=wp(e);return i===null?!1:Array.from(r).every(e=>i.has(e))}function wp(e){let t=new Set;for(let[n,r]of Object.entries(e)){let i;try{i=JSON.parse(r)}catch{return null}if(!Array.isArray(i))return null;for(let[r,a]of i.entries())if(!(typeof a!=`object`||!a||Array.isArray(a)))try{let i=mf(n,a,r,e);t.add(i)}catch{return null}}return t}function Tp(e){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`YAML values must be JSON-compatible`);return e}if(Array.isArray(e))return e.map(Tp);if(typeof e==`object`){if(Object.getPrototypeOf(e)!==Object.prototype)throw Error(`YAML values must be JSON-compatible`);let t={};for(let[n,r]of Object.entries(e))t[n]=Tp(r);return t}throw Error(`YAML values must be JSON-compatible`)}function Ep(e){let t=new zd,n=Jd(e,{lineCounter:t,merge:!1,prettyErrors:!1,strict:!0});if(n.errors.length>0)throw Error(n.errors[0].message);let r=Tp(n.toJS({mapAsMap:!1}));if(!Array.isArray(r))throw Error(`Telepact YAML root must be a sequence`);return{canonicalJsonText:JSON.stringify(r),locator:ef(n,t)}}function Dp(e,t,n){let r={},i={},a=[],o=t.readdirSync(e).sort().map(t=>n.join(e,t));for(let s of o){let o=n.relative(e,s);if(t.statSync(s).isDirectory()){a.push(new sc(o,[],`DirectoryDisallowed`,{})),r[o]=`[]`;continue}let c=t.readFileSync(s,`utf-8`);if(s.endsWith(`.telepact.json`))r[o]=c;else if(s.endsWith(`.telepact.yaml`))try{let e=Ep(c);r[o]=e.canonicalJsonText,e.locator!==void 0&&(i[o]=e.locator)}catch{r[o]=`[]`,a.push(new sc(o,[],`JsonInvalid`,{}))}else r[o]=c,a.push(new sc(o,[],`FileNamePatternInvalid`,{expected:`*.telepact.json|*.telepact.yaml`}))}if(af(r,i),a.length>0)throw new uf(a,r);return r}var Op=class{original;full;parsed;parsedRequestHeaders;parsedResponseHeaders;constructor(e,t,n,r,i){this.original=e,this.full=t,this.parsed=n,this.parsedRequestHeaders=r,this.parsedResponseHeaders=i}static fromJson(e){return Sp({auto_:e})}static fromFileJsonMap(e){return Sp(e)}static fromDirectory(e,t,n){return Sp(Dp(e,t,n))}},kp=class{functionName;functionArgument;verified;constructor(e,t){this.functionName=e,this.functionArgument=t,this.verified=!1}},Ap=class{whenFunction;whenArgument;thenResult;allowArgumentPartialMatch;count;constructor(e,t,n,r,i){this.whenFunction=e,this.whenArgument=t,this.thenResult=n,this.allowArgumentPartialMatch=r,this.count=i}};function jp(e,t,n,r,i){let a=0;for(let r of i)r.functionName===e&&(n?Ao(r.functionArgument,t)&&(r.verified=!0,a+=1):nc(t,r.functionArgument)&&(r.verified=!0,a+=1));let o=i.map(e=>({[e.functionName]:e.functionArgument})),s=Object.entries(r)[0],c=s[0],l=s[1],u=null;if(c===`Exact`){let e=l.times;a>e?u={TooManyMatchingCalls:{wanted:{Exact:{times:e}},found:a,allCalls:o}}:a<e&&(u={TooFewMatchingCalls:{wanted:{Exact:{times:e}},found:a,allCalls:o}})}else if(c===`AtMost`){let e=l.times;a>e&&(u={TooManyMatchingCalls:{wanted:{AtMost:{times:e}},found:a,allCalls:o}})}else if(c===`AtLeast`){let e=l.times;a<e&&(u={TooFewMatchingCalls:{wanted:{AtLeast:{times:e}},found:a,allCalls:o}})}return u===null?{Ok_:{}}:{ErrorVerificationFailure:{reason:u}}}function Mp(e){let t=e.filter(e=>!e.verified);return t.length>0?{ErrorVerificationFailure:{additionalUnverifiedCalls:t.map(e=>({[e.functionName]:e.functionArgument}))}}:{Ok_:{}}}async function Np(e,t,n,r,i,a,o,s){let c=e.headers[`@gen_`]||!1,l=e.getBodyTarget(),u=e.getBodyPayload();if(l===`fn.createStub_`){let e=u.stub,[n,r]=Object.entries(e).find(([e])=>e.startsWith(`fn.`)),i=e[`->`],a=new Ap(n,r,i,!u[`strictMatch!`]||!1,u[`count!`]||-1);return t.unshift(a),new Ja({},{Ok_:{}})}else if(l===`fn.verify_`){let e=u.call,[t,r]=Object.entries(e).find(([e])=>e.startsWith(`fn.`)),i=u[`count!`]||{AtLeast:{times:1}};return new Ja({},jp(t,r,u[`strictMatch!`]||!1,i,n))}else if(l===`fn.verifyNoMoreInteractions_`)return new Ja({},Mp(n));else if(l===`fn.clearCalls_`)return n.length=0,new Ja({},{Ok_:{}});else if(l===`fn.clearStubs_`)return t.length=0,new Ja({},{Ok_:{}});else if(l===`fn.setRandomSeed_`){let e=u.seed;return r.setSeed(e),new Ja({},{Ok_:{}})}else{n.push(new kp(l,u));let e=i.parsed[l+`.->`];for(let n of t)if(n.count!==0&&n.whenFunction===l){if(n.allowArgumentPartialMatch){if(nc(n.whenArgument,u)){let t=e.generateRandomValue(n.thenResult,!0,[],new Ps(!1,s,!0,l,r));return n.count>0&&--n.count,new Ja({},t)}}else if(Ao(n.whenArgument,u)){let t=e.generateRandomValue(n.thenResult,!0,[],new Ps(!1,s,!0,l,r));return n.count>0&&--n.count,new Ja({},t)}}if(!a&&!c)return new Ja({},{ErrorNoMatchingStub_:{}});if(e)return new Ja({},{Ok_:e.tags.Ok_.generateRandomValue({},!0,[],new Ps(!0,s,!0,l,r))});throw new ko(`Unexpected unknown function: ${l}`)}}var Pp=class{constructor(e,t){this.random=new Ua(t.generatedCollectionLengthMin,t.generatedCollectionLengthMax),this.enableGeneratedDefaultStub=t.enableMessageResponseGeneration,this.enableOptionalFieldGeneration=t.enableOptionalFieldGeneration,this.randomizeOptionalFieldGeneration=t.randomizeOptionalFieldGeneration,this.stubs=[],this.invocations=[];let n=new $s;n.onError=t.onError,n.authRequired=!1,n.middleware=async e=>await this.handle(e),this.server=new Qs(new Op(e.original,e.full,e.parsed,e.parsedRequestHeaders,e.parsedResponseHeaders),new qo({}),n)}random;enableGeneratedDefaultStub;enableOptionalFieldGeneration;randomizeOptionalFieldGeneration;stubs;invocations;server;async process(e){return await this.server.process(e)}handle=async e=>await Np(e,this.stubs,this.invocations,this.random,this.server.telepactSchema,this.enableGeneratedDefaultStub,this.enableOptionalFieldGeneration,this.randomizeOptionalFieldGeneration)},Fp=class{onError=e=>{};enableMessageResponseGeneration=!0;enableOptionalFieldGeneration=!0;randomizeOptionalFieldGeneration=!0;generatedCollectionLengthMin=0;generatedCollectionLengthMax=3},Ip=[{"///":"`_ext.Stub_` is the mock stub object consumed by `fn.createStub_`. It\ncontains exactly one non-internal `fn.*` matcher plus a matching `->`\nresult payload that the mock should return.\n\nSee https://raw.githubusercontent.com/Telepact/telepact/main/doc/extensions.md\nfor full `_ext.Stub_` rules and end-to-end examples.\n","_ext.Stub_":{}},{"///":"`_ext.Call_` is the mock call object used by `fn.verify_` and verification\nfailures. It contains exactly one non-internal `fn.*` key whose value is\nthat function's argument object.\n\nSee https://raw.githubusercontent.com/Telepact/telepact/main/doc/extensions.md\nfor full `_ext.Call_` rules and end-to-end examples.\n","_ext.Call_":{}},{"///":`The number of times a function is allowed to be called.`,"union.CallCountCriteria_":[{Exact:{times:`integer`}},{AtMost:{times:`integer`}},{AtLeast:{times:`integer`}}]},{"///":`Possible causes for a mock verification to fail.`,"union.VerificationFailure_":[{TooFewMatchingCalls:{wanted:`union.CallCountCriteria_`,found:`integer`,allCalls:[`_ext.Call_`]}},{TooManyMatchingCalls:{wanted:`union.CallCountCriteria_`,found:`integer`,allCalls:[`_ext.Call_`]}}]},{"///":`Create a mock stub from an \`_ext.Stub_\`.
184
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=Wd(Ud(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=Wd(Ud(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function qd(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new zd||null,prettyErrors:t}}function Jd(e,t={}){let{lineCounter:n,prettyErrors:r}=qd(t),i=new Kd(n?.addNewLine),a=new Ed(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Hu(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Wu(e,n)),o.warnings.forEach(Wu(e,n))),o}function Yd(e){return JSON.stringify(e)}function Xd(e,t){let n=e.linePos(t);return{row:n.line,col:n.col}}function Zd(e,t){let n=t?.range?.[0];return typeof n==`number`?Xd(e,n):{row:1,col:1}}function Qd(e,t,n,r){let i=e?.constructor?.name;if(i===`YAMLSeq`){for(let i=0;i<(e?.items?.length??0);i+=1){let a=e?.items?.[i],o=[...t,i];r[Yd(o)]=Zd(n,a),Qd(a,o,n,r)}return}if(i===`YAMLMap`)for(let i of e?.items??[]){let e=i.key?.value;if(typeof e!=`string`)continue;let a=[...t,e];r[Yd(a)]=Zd(n,i.key),Qd(i.value,a,n,r)}}function $d(e){let t=e?.constructor?.name;if(t===`YAMLSeq`){for(let t of e?.items??[])$d(t);return}if(t===`YAMLMap`){let t=new Set;for(let n of e?.items??[]){let e=String(n.key?.value);if(t.has(e))throw Error(`Duplicate YAML key`);t.add(e),$d(n.value)}}}function ef(e,t,n){if((e.errors?.length??0)>0)throw Error(e.errors?.[0]?.message??`YAML parse failed`);let r={};return $d(e.contents),r[Yd([])]=Zd(t,e.contents),Qd(e.contents,[],t,r),e=>r[Yd(e)]??{row:1,col:1}}function tf(e){let t=new zd;return ef(Jd(e,{lineCounter:t,merge:!1,prettyErrors:!1,strict:!0}),t)}function nf(e,t){try{return tf(t)(e)}catch{return{row:1,col:1}}}var rf=Symbol(`telepactDocumentLocators`);function af(e,t){Object.defineProperty(e,rf,{configurable:!0,enumerable:!1,value:{...t},writable:!0})}function of(e){return e[rf]}function sf(e,t){let n=of(e);n!==void 0&&af(t,n)}function cf(e,t,n){let r=of(n)?.[t];return r===void 0?nf(e,n[t]??`[]`):r(e)}function lf(e,t){let n=[];for(let r of e){let e=cf(r.path,r.documentName,t),i={};i.document=r.documentName,i.location=e,i.path=r.path,i.reason={[r.reason]:r.data},n.push(Object.assign({},i))}return n}var uf=class extends Error{schemaParseFailures;schemaParseFailuresPseudoJson;constructor(e,t,n){super(JSON.stringify(lf(e,t),null,2),{cause:n}),this.schemaParseFailures=e,this.schemaParseFailuresPseudoJson=lf(e,t)}};function df(e,t,n,r,i,a){let o=[],s=e.name,c=r[s],l=n[s];for(let u in t){if(!u.startsWith(`fn.`)||u.endsWith(`.->`))continue;let d=t[u+`.->`],f=u,p=a[f],m=new RegExp(p),h=d.tags,g=e.errors.tags;if(m.exec(s))for(let t in g){let a=g[t],u=t;if(u in h){let t=r[f],a=e.errors.tagIndices[u],p=n[f],m=[t,`->`,d.tagIndices[u],u],h=cf(m,p,i);o.push(new sc(l,[c,s,a,u],`PathCollision`,{document:p,path:m,location:h}))}h[u]=a}}if(o.length>0)throw new uf(o,i)}function ff(e,t,n,r,i){let a=[],o=[...t];o.sort((e,t)=>{let i=r[e],a=r[t];return i===a?n[e]-n[t]:i.localeCompare(a)});for(let t=0;t<o.length;t++)for(let s=t+1;s<o.length;s++){let c=o[t],l=o[s],u=n[c],d=n[l],f=r[c],p=r[l],m=e[f],h=e[p],g=m[u],_=h[d],v=g[c],y=_[l];for(let e=0;e<v.length;e++){let t=v[e],n=new Set(Object.keys(t));n.delete(`///`);for(let t=0;t<y.length;t++){let r=y[t],o=new Set(Object.keys(r));if(o.delete(`///`),n.size===o.size&&[...n].every(e=>o.has(e))){let r=n.values().next().value,s=o.values().next().value,m=[u,c,e,r],h=cf(m,f,i);a.push(new sc(p,[d,l,t,s],`PathCollision`,{document:f,path:m,location:h}))}}}}if(a.length>0)throw new uf(a,i)}function pf(e,t){for(let n of e)if(t.startsWith(`info.`)&&n.startsWith(`info.`)||n===t)return n;return null}function mf(e,t,n,r){let i=/^(((fn|errors|headers|info)|((struct|union|_ext)(<[0-2]>)?))\..*)/,a=[],o=Object.keys(t).sort();for(let e of o)i.test(e)&&a.push(e);if(a.length===1)return a[0];throw new uf([new sc(e,[n],`ObjectKeyRegexMatchCountUnexpected`,{regex:i.toString().slice(1,-1),actual:a.length,expected:1,keys:o})],r)}function hf(e){return typeof e==`boolean`?[]:es([],e,_f)}function gf(e,t,n){return t?e:n.randomGenerator.nextBoolean()}var _f=`Boolean`,vf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return hf(e)}generateRandomValue(e,t,n,r){return gf(e,t,r)}getName(){return _f}};function yf(e){return typeof e==`number`&&Number.isInteger(e)?e===0x8000000000000000||e===-0x8000000000000000?[new Qo([],`NumberOutOfRange`,{}),new Qo([],`NumberTruncated`,{})]:[]:es([],e,xf)}function bf(e,t,n){return t?e:n.randomGenerator.nextInt()}var xf=`Integer`,Sf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return yf(e)}generateRandomValue(e,t,n,r){return bf(e,t,r)}getName(){return xf}};function Cf(e){return typeof e==`number`?Number.isInteger(e)&&e===0x8000000000000000||e===-0x8000000000000000?[new Qo([],`NumberOutOfRange`,{}),new Qo([],`NumberTruncated`,{})]:[]:es([],e,Tf)}function wf(e,t,n){return t?e:n.randomGenerator.nextDouble()}var Tf=`Number`,Ef=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Cf(e)}generateRandomValue(e,t,n,r){return wf(e,t,r)}getName(){return Tf}};function Df(e){return typeof e==`string`?[]:es([],e,kf)}function Of(e,t,n){return t?e:n.randomGenerator.nextString()}var kf=`String`,Af=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Df(e)}generateRandomValue(e,t,n,r){return Of(e,t,r)}getName(){return kf}};function jf(e){let t=e.randomGenerator.nextIntWithCeiling(3);return t===0?e.randomGenerator.nextBoolean():t===1?e.randomGenerator.nextInt():e.randomGenerator.nextString()}var Mf=`Any`,Nf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return[]}generateRandomValue(e,t,n,r){return jf(r)}getName(){return Mf}};function Pf(e,t){if(e instanceof Uint8Array)return t.coerceBase64&&Ff(t.path,t.base64Coercions),[];if(typeof e==`string`)try{if(Lo(Ro(e))!==e)throw Error(`Invalid base64`);return t.coerceBase64||Ff(t.path,t.bytesCoercions),[]}catch{return es([],e,`Base64String`)}else return es([],e,Lf)}function Ff(e,t){let n=e[0];e.length>1?(t[n]=t[n]||{},Ff(e.slice(1),t[n])):t[n]=!0}function If(e,t,n){return t?e:n.randomGenerator.nextBytes()}var Lf=`Bytes`,Rf=class extends fs{getTypeParameterCount(){return 0}validate(e,t,n){return Pf(e,n)}generateRandomValue(e,t,n,r){return If(e,t,r)}getName(){return Lf}};function zf(e,t,n,r){return[new sc(e,t,`TypeUnexpected`,{actual:{[$o(n)]:{}},expected:{[r]:{}}})]}var Bf=class{fieldName;typeDeclaration;optional;constructor(e,t,n){this.fieldName=e,this.typeDeclaration=t,this.optional=n}};function Vf(e,t,n){if(typeof t==`string`){let r=t,i=`^(.*?)(\\?)?$`,a=new RegExp(i),o=r.match(a);if(!o)throw new uf([new sc(n.documentName,e,`StringRegexMatchFailed`,{regex:i})],n.telepactSchemaDocumentNamesToJson);let s=o[1],c=o[2]!==void 0,l=up(e,s,n);if(l.getTypeParameterCount()!==0)throw new uf([new sc(n.documentName,e,`ArrayLengthUnexpected`,{actual:1,expected:l.getTypeParameterCount()+1})],n.telepactSchemaDocumentNamesToJson);return new Ts(l,c,[])}else if(Array.isArray(t)){let r=t;if(r.length!==1)throw new uf([new sc(n.documentName,e,`ArrayLengthUnexpected`,{actual:r.length,expected:1})],n.telepactSchemaDocumentNamesToJson);let i=r[0],a=[...e,0];return new Ts(new gs,!1,[Vf(a,i,n)])}else if(typeof t==`object`&&t){let r=t,i=Object.keys(r);if(i.length!==1)throw new uf([new sc(n.documentName,e,`ObjectSizeUnexpected`,{actual:i.length,expected:1})],n.telepactSchemaDocumentNamesToJson);let a=i[0],o=r[a];if(a!==`string`){let t=[...e,a];throw new uf([new sc(n.documentName,e,`RequiredObjectKeyMissing`,{key:`string`}),new sc(n.documentName,t,`ObjectKeyDisallowed`,{})],n.telepactSchemaDocumentNamesToJson)}let s=[...e,a];return new Ts(new bs,!1,[Vf(s,o,n)])}else throw new uf(zf(n.documentName,e,t,`StringOrArrayOrObject`),n.telepactSchemaDocumentNamesToJson)}function Hf(e,t,n,r,i){let a=r?`^@[a-z][a-zA-Z0-9_]*$`:`^([a-z][a-zA-Z0-9_]*)(!)?$`,o=new RegExp(a),s=t.match(o);if(!s){let n=[...e,t];throw new uf([new sc(i.documentName,n,`KeyRegexMatchFailed`,{regex:a})],i.telepactSchemaDocumentNamesToJson)}let c=s[0],l=r?!0:!!s[2];return new Bf(c,Vf([...e,c],n,i),l)}function Uf(e,t,n,r){let i=[],a={};for(let o in t){for(let t in a){let n=t.split(`!`)[0],a=o.split(`!`)[0];if(a===n){let t=[...e];i.push(new sc(r.documentName,t,`DuplicateField`,{field:a}))}}try{let i=Hf(e,o,t[o],n,r),s=i.fieldName;a[s]=i}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return a}function Wf(e,t,n,r,i,a){let o=[],s=new Set(Object.keys(t));s.delete(n),s.delete(`///`);for(let e of r)s.delete(e);if(s.size>0)for(let t of s){let n=e.concat(t);o.push(new sc(a.documentName,n,`ObjectKeyDisallowed`,{}))}let c=e.concat(n),l=t[n];if(!Array.isArray(l)){let e=zf(a.documentName,c,l,`Array`);throw o.push(...e),new uf(o,a.telepactSchemaDocumentNamesToJson)}let u=l,d=[],f=-1;for(let e of u){f+=1;let t=c.concat(f);if(typeof e!=`object`||Array.isArray(e)||e==null){let n=zf(a.documentName,t,e,`Object`);o.push(...n);continue}d.push(e)}if(o.length>0)throw new uf(o,a.telepactSchemaDocumentNamesToJson);if(d.length===0)o.push(new sc(a.documentName,c,`EmptyArrayDisallowed`,{}));else for(let e of i){let t=!1;for(let n of d){let r=new Set(Object.keys(n));if(r.delete(`///`),r.has(e)){t=!0;break}}t||o.push(new sc(a.documentName,c,`RequiredObjectKeyMissing`,{key:e}))}let p={},m={};for(let e=0;e<d.length;e++){let t=d[e],r=c.concat(e),i=Object.fromEntries(Object.entries(t));delete i[`///`];let s=Object.keys(i),l=`^([A-Z][a-zA-Z0-9_]*)$`,u=new RegExp(l),f=s.filter(e=>u.test(e));if(f.length!==1){o.push(new sc(a.documentName,r,`ObjectKeyRegexMatchCountUnexpected`,{regex:l,actual:f.length,expected:1,keys:s}));continue}if(Object.keys(i).length!==1){o.push(new sc(a.documentName,r,`ObjectSizeUnexpected`,{expected:1,actual:Object.keys(i).length}));continue}let h=Object.entries(i)[0],g=h[0],_=r.concat(g);if(typeof h[1]!=`object`||Array.isArray(h[1])||h[1]===null||h[1]===void 0){let e=zf(a.documentName,_,h[1],`Object`);o.push(...e);continue}let v=h[1];try{let t=Uf(_,v,!1,a);p[g]=new ds(`${n}.${g}`,t),m[g]=e}catch(e){if(e instanceof uf)o.push(...e.schemaParseFailures);else throw e}}if(o.length>0)throw new uf(o,a.telepactSchemaDocumentNamesToJson);return new cs(n,p,m)}function Gf(e,t){let n={},r=t.tags.Ok_.fields,i=Object.keys(r);i.sort();for(let e of Object.values(r))Kf(e.typeDeclaration,n);let a={};a[`->`]={Ok_:i};let o=Object.keys(n).sort();for(let e of o){if(e.startsWith(`fn.`))continue;let t=n[e];if(t instanceof cs){let n={},r=Object.keys(t.tags).sort();for(let e of r){let r=t.tags[e],i=[],a=Object.keys(r.fields).sort();for(let e of a)i.push(e);i.length>0&&(n[e]=i)}a[e]=n}else if(t instanceof ds){let n=[],r=Object.keys(t.fields).sort();for(let e of r)n.push(e);n.length>0&&(a[e]=n)}}return a}function Kf(e,t){let n=e.type;if(n instanceof cs){if(t[n.name]!==void 0)return;t[n.name]=n;for(let e of Object.values(n.tags))for(let n of Object.values(e.fields))Kf(n.typeDeclaration,t)}else if(n instanceof ds){if(t[n.name]!==void 0)return;t[n.name]=n;for(let e of Object.values(n.fields))Kf(e.typeDeclaration,t)}else (n instanceof gs||n instanceof bs)&&Kf(e.typeParameters[0],t)}function qf(e,t,n,r){let i=[],a=null;if(!(`->`in t))i.push(new sc(r.documentName,e,`RequiredObjectKeyMissing`,{key:`->`}));else try{a=Wf(e,t,`->`,Object.keys(t),[`Ok_`],r)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);let o=Gf(n,a),s=up([],`_ext.Select_`,r);return s.possibleSelects[n]=o,a}function Jf(e,t,n,r){let i=[],a=`_errors`,o=[...e,a],s=null;if(a in t&&!n.endsWith(`_`))i.push(new sc(r.documentName,o,`ObjectKeyDisallowed`,{}));else{let e=a in t?t[a]:`^errors\\..*$`;if(typeof e!=`string`){let t=zf(r.documentName,o,e,`String`);i.push(...t)}else s=e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return s}function Yf(e,t,n,r,i){let a=[],o=new Set(Object.keys(t));o.delete(n),o.delete(`///`),o.delete(`_ignoreIfDuplicate`);for(let e of r)o.delete(e);if(o.size>0)for(let t of o){let n=[...e,t];a.push(new sc(i.documentName,n,`ObjectKeyDisallowed`,{}))}let s=[...e,n],c=t[n],l=null;if(typeof c!=`object`||Array.isArray(c)||c==null){let e=zf(i.documentName,s,c,`Object`);a.push(...e)}else l=c;if(a.length>0)throw new uf(a,i.telepactSchemaDocumentNamesToJson);return new ds(n,Uf(s,l,!1,i))}function Xf(e,t,n){if(typeof e!=`object`||Array.isArray(e)||e==null)return es([],e,`Object`);let r=t[n.fn];return Zf([],e,r)}function Zf(e,t,n){if(Array.isArray(n)){if(!Array.isArray(t))return es(e,t,`Array`);let r=[];for(let[i,a]of t.entries())n.includes(a)||r.push(new Qo([...e,i],`ArrayElementDisallowed`,{}));return r}else if(typeof n==`object`&&!Array.isArray(n)){if(typeof t!=`object`||Array.isArray(t)||t===null)return es(e,t,`Object`);let r=[];for(let[i,a]of Object.entries(t))if(i in n){let t=Zf([...e,i],a,n[i]);r.push(...t)}else r.push(new Qo([...e,i],`ObjectKeyDisallowed`,{}));return r}return[]}function Qf(e,t){let n=e[t.fnScope];return $f(n,t)}function $f(e,t){if(Array.isArray(e)){let n=[];for(let r of e)t.randomGenerator.nextBoolean()&&n.push(r);return n.sort()}else if(typeof e==`object`&&!Array.isArray(e)){let n={},r=Object.keys(e).sort();for(let i of r){let r=e[i];if(t.randomGenerator.nextBoolean()){let e=$f(r,t);if(typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0)continue;n[i]=e}}return n}else throw Error(`Invalid possibleSelectSection`)}var ep=`Object`,tp=class{possibleSelects={};getTypeParameterCount(){return 0}validate(e,t,n){return Xf(e,this.possibleSelects,n)}generateRandomValue(e,t,n,r){return Qf(this.possibleSelects,r)}getName(){return ep}};function np(e,t,n){if(!(typeof e==`object`&&!Array.isArray(e)))return es([],e,`Object`);let r=e,i=/^fn\..*$/,a=Object.keys(r).sort(),o=a.filter(e=>i.test(e));if(o.length!==1)return[new Qo([],`ObjectKeyRegexMatchCountUnexpected`,{regex:i.toString().slice(1,-1),actual:o.length,expected:1,keys:a})];let s=o[0],c=t[s],l=r[s],u=c,d=s,f=u.tags[d].validate(l,[],n),p=[];for(let e of f){let t=[s,...e.path];p.push(new Qo(t,e.reason,e.data))}return p.filter(e=>e.reason!==`RequiredObjectKeyMissing`)}function rp(e,t){let n=Object.entries(e).filter(([e,t])=>e.startsWith(`fn.`)&&!e.endsWith(`.->`)).filter(([e,t])=>!e.endsWith(`_`)).map(([e,t])=>t);n.sort((e,t)=>e.name.localeCompare(t.name));let r=n[Math.floor(t.randomGenerator.nextIntWithCeiling(n.length))];return os(null,!1,r.tags,t.copy({alwaysIncludeRequiredFields:!1}))}var ip=`_ext.Call_`,ap=class extends fs{types;constructor(e){super(),this.types=e}getTypeParameterCount(){return 0}validate(e,t,n){return np(e,this.types,n)}generateRandomValue(e,t,n,r){return rp(this.types,r)}getName(){return ip}};function op(e,t,n){let r=[];if(!(typeof e==`object`&&!Array.isArray(e)))return es([],e,`Object`);let i=e,a=/^fn\..*$/,o=Object.keys(i).sort(),s=o.filter(e=>a.test(e));if(s.length!==1)return[new Qo([],`ObjectKeyRegexMatchCountUnexpected`,{regex:a.toString().slice(1,-1),actual:s.length,expected:1,keys:o})];let c=s[0],l=i[c],u=t[c],d=t[`${c}.->`],f=c,p=u.tags[f].validate(l,[],n),m=[];for(let e of p){let t=[c,...e.path];m.push(new Qo(t,e.reason,e.data))}let h=m.filter(e=>e.reason!==`RequiredObjectKeyMissing`);if(r.push(...h),!(`->`in i))r.push(new Qo([],`RequiredObjectKeyMissing`,{key:`->`}));else{let e=i[`->`],t=d.validate(e,[],n),a=[];for(let e of t){let t=[`->`,...e.path];a.push(new Qo(t,e.reason,e.data))}let o=a.filter(e=>e.reason!==`RequiredObjectKeyMissing`);r.push(...o)}let g=Object.keys(i).filter(e=>!s.includes(e)&&e!==`->`);for(let e of g)r.push(new Qo([e],`ObjectKeyDisallowed`,{}));return r}function sp(e,t){let n=Object.keys(e).filter(e=>e.startsWith(`fn.`)&&!e.endsWith(`.->`)).filter(e=>!e.endsWith(`_`)).map(e=>e);n.sort((e,t)=>e.localeCompare(t));let r=n[t.randomGenerator.nextIntWithCeiling(n.length)],i=e[r],a=e[r+`.->`],o=i.tags[r].fields,s=a.tags.Ok_.fields,c=as(null,!1,o,t.copy({alwaysIncludeRequiredFields:!1})),l=as(null,!1,s,t.copy({alwaysIncludeRequiredFields:!1}));return{[r]:c,"->":{Ok_:l}}}var cp=`_ext.Stub_`,lp=class extends fs{types;constructor(e){super(),this.types=e}getTypeParameterCount(){return 0}validate(e,t,n){return op(e,this.types,n)}generateRandomValue(e,t,n,r){return sp(this.types,r)}getName(){return cp}};function up(e,t,n){if(n.failedTypes.has(t))throw new uf([],n.telepactSchemaDocumentNamesToJson);let r=n.parsedTypes[t];if(r!==void 0)return r;let i=`^(boolean|integer|number|string|any|bytes)|((fn|(union|struct|_ext))\\.([a-zA-Z_]\\w*))$`,a=new RegExp(i),o=t.match(a);if(!o)throw new uf([new sc(n.documentName,e,`StringRegexMatchFailed`,{regex:i})],n.telepactSchemaDocumentNamesToJson);let s=o[1];if(s)return{boolean:new vf,integer:new Sf,number:new Ef,string:new Af,bytes:new Rf}[s]||new Nf;let c=o[2],l=n.schemaKeysToIndex[c],u=n.schemaKeysToDocumentName[c];if(l===void 0)throw new uf([new sc(n.documentName,e,`TypeUnknown`,{name:c})],n.telepactSchemaDocumentNamesToJson);let d=n.telepactSchemaDocumentNamesToPseudoJson[u][l],f;try{if(c.startsWith(`struct`)){let e=new ds(c,{});f=e,n.parsedTypes[c]=f,e.fields=Yf([l],d,c,[],n.copy({documentName:u})).fields}else if(c.startsWith(`union`)){let e=new cs(c,{},{});f=e,n.parsedTypes[c]=f;let t=Wf([l],d,c,[],[],n.copy({documentName:u}));e.tags=t.tags,e.tagIndices=t.tagIndices}else if(c.startsWith(`fn`)){let e=new cs(c,{},{});f=e,n.parsedTypes[c]=f;let t=Yf([l],d,c,[`->`,`_errors`],n.copy({documentName:u}));e.tags[c]=t,e.tagIndices[c]=0;let r=qf([l],d,c,n.copy({documentName:u}));n.parsedTypes[c+`.->`]=r;let i=Jf([l],d,c,n.copy({documentName:u}));n.fnErrorRegexes[c]=i}else{let e={"_ext.Select_":new tp,"_ext.Call_":new ap(n.parsedTypes),"_ext.Stub_":new lp(n.parsedTypes)}[c];if(!e)throw new uf([new sc(n.documentName,[l],`TypeExtensionImplementationMissing`,{name:c})],n.telepactSchemaDocumentNamesToJson);f=e,n.parsedTypes[c]=f}return f}catch(e){throw e instanceof uf?(n.allParseFailures.push(...e.schemaParseFailures),n.failedTypes.add(c),new uf([],n.telepactSchemaDocumentNamesToJson)):e}}var dp=class{name;errors;constructor(e,t){this.name=e,this.errors=t}};function fp(e,t,n,r){let i=[],a=Object.keys(t).filter(e=>e!==n&&e!==`///`);if(a.length>0)for(let t of a){let n=e.concat(t);i.push(new sc(r.documentName,n,`ObjectKeyDisallowed`,{}))}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return new dp(n,Wf(e,t,n,[],[],r))}var pp=class{name;requestHeaders;responseHeaders;constructor(e,t,n){this.name=e,this.requestHeaders=t,this.responseHeaders=n}};function mp(e,t,n,r){let i=[],a={},o={},s=t[n],c=[...e,n];if(typeof s!=`object`||Array.isArray(s)||s==null){let e=zf(r.documentName,c,s,`Object`);i.push(...e)}else try{let e=Uf(c,s,!0,r);for(let t in e)e[t].optional=!0;Object.assign(a,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}let l=[...e,`->`];`->`in t||i.push(new sc(r.documentName,l,`RequiredObjectKeyMissing`,{key:`->`}));let u=t[`->`];if(typeof u!=`object`||Array.isArray(u)||u==null){let e=zf(r.documentName,c,u,`Object`);i.push(...e)}else try{let e=Uf(l,u,!0,r);for(let t in e)e[t].optional=!0;Object.assign(o,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,r.telepactSchemaDocumentNamesToJson);return new pp(n,a,o)}var hp=class e{documentName;telepactSchemaDocumentNamesToPseudoJson;telepactSchemaDocumentNamesToJson;schemaKeysToDocumentName;schemaKeysToIndex;parsedTypes;fnErrorRegexes;allParseFailures;failedTypes;constructor(e,t,n,r,i,a,o,s,c){this.documentName=e,this.telepactSchemaDocumentNamesToPseudoJson=t,this.telepactSchemaDocumentNamesToJson=n,this.schemaKeysToDocumentName=r,this.schemaKeysToIndex=i,this.parsedTypes=a,this.fnErrorRegexes=o,this.allParseFailures=s,this.failedTypes=c}copy({documentName:t}){return new e(t??this.documentName,this.telepactSchemaDocumentNamesToPseudoJson,this.telepactSchemaDocumentNamesToJson,this.schemaKeysToDocumentName,this.schemaKeysToIndex,this.parsedTypes,this.fnErrorRegexes,this.allParseFailures,this.failedTypes)}};function gp(e,t,n,r,i){let a=[],o=[...t];o.sort((e,t)=>{let i=r[e],a=r[t];return i===a?n[e]-n[t]:i.localeCompare(a)});for(let t=0;t<o.length;t++)for(let s=t+1;s<o.length;s++){let c=o[t],l=o[s],u=n[c],d=n[l],f=r[c],p=r[l],m=e[f],h=e[p],g=m[u],_=h[d],v=g[c],y=_[l],b=Object.keys(v).filter(e=>e in y);for(let e of b){let t=[u,c,e],n=cf(t,f,i);a.push(new sc(p,[d,l,e],`PathCollision`,{document:f,path:t,location:n}))}let x=g[`->`],S=_[`->`],C=Object.keys(x).filter(e=>e in S);for(let e of C){let t=[u,`->`,e],n=cf(t,f,i);a.push(new sc(p,[d,`->`,e],`PathCollision`,{document:f,path:t,location:n}))}}if(a.length>0)throw new uf(a,i)}function _p(e,t){return e.nullable||e.type instanceof gs||e.type instanceof bs?!0:e.type instanceof ds||e.type instanceof cs?t.has(e.type.name):!0}function vp(e,t){return Object.values(e).every(e=>e.optional||_p(e.typeDeclaration,t))}function yp(e,t){return e instanceof ds?vp(e.fields,t):e instanceof cs?Object.values(e.tags).some(e=>vp(e.fields,t)):!0}function bp(e,t,n,r){let i=new Set,a=!0;for(;a;){a=!1;for(let[t,n]of Object.entries(e))i.has(t)||yp(n,i)&&(i.add(t),a=!0)}let o=[];for(let[r,a]of Object.entries(t)){if(r.startsWith(`info.`)||r.startsWith(`headers.`)||r.startsWith(`errors.`))continue;let t=[r];r.startsWith(`fn.`)&&t.push(`${r}.->`);for(let s of t)if(e[s]!==void 0&&!i.has(s)){let e=s.endsWith(`.->`)?[n[r],`->`]:[n[r],r];o.push(new sc(a,e,`RecursiveTypeUnterminated`,{}))}}if(o.length>0)throw new uf(o,r)}function xp(e){let t={},n={},r={},i=[],a={},o=new Set,s={},c={},l=new Set,u=Object.keys(e).sort(),d={};for(let[t,n]of Object.entries(e)){let r;try{r=JSON.parse(n)}catch(n){throw new uf([new sc(t,[],`JsonInvalid`,{})],e,n)}if(!Array.isArray(r))throw new uf(zf(t,[],r,`Array`),e);d[t]=r}for(let r of u){let a=d[r],o=-1;for(let u of a){o+=1;let a=[o];if(typeof u!=`object`||Array.isArray(u)||u==null){let e=zf(r,a,u,`Object`);i.push(...e);continue}let d=u;try{let u=mf(r,d,o,e),f=pf(l,u);if(f!==null){let t=s[f],n=c[f],o=[...a,u],l=cf([t,f],n,e);i.push(new sc(r,o,`PathCollision`,{document:n,location:l,path:[t,f]}));continue}l.add(u),s[u]=o,c[u]=r,(r===`auto_`||r===`auth_`||!r.endsWith(`_`))&&(t[u]=d),n[u]=d}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}}if(i.length>0)throw new uf(i,e);let f=new Set,p=new Set;for(let t of l){if(t.startsWith(`info.`))continue;if(t.startsWith(`headers.`)){f.add(t);continue}else if(t.startsWith(`errors.`)){p.add(t);continue}let n=s[t],l=c[t];try{up([n],t,new hp(l,d,e,c,s,r,a,i,o))}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,e);let m=[];try{for(let t of p){let n=s[t],l=c[t],u=d[l][n];try{let f=fp([n],u,t,new hp(l,d,e,c,s,r,a,i,o));m.push(f)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);try{ff(d,p,s,c,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);for(let t of m)try{df(t,r,c,s,e,a)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}try{bp(r,c,s,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}let h=[];for(let t of f){let n=s[t],l=c[t],u=d[l][n];try{let f=mp([n],u,t,new hp(l,d,e,c,s,r,a,i,o));h.push(f)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}}if(i.length>0)throw new uf(i,e);try{gp(d,f,s,c,e)}catch(e){if(e instanceof uf)i.push(...e.schemaParseFailures);else throw e}if(i.length>0)throw new uf(i,e);let g={},_={};for(let e of h)Object.assign(g,e.requestHeaders),Object.assign(_,e.responseHeaders);let v=(e,t)=>{let n=e.startsWith(`info.`),r=t.startsWith(`info.`);return n&&!r?-1:!n&&r?1:e<t?-1:+(e>t)};return new Op(Object.keys(t).sort(v).map(e=>t[e]),Object.keys(n).sort(v).map(e=>n[e]),r,g,_)}function Sp(e){let t={...e};sf(e,t);let n=ic();Cp(e,`internal_`,n)||(t.internal_=n);let r=oc();for(let n of Object.values(e))if(/"union\.Auth_"\s*:/.test(n)){Cp(e,`auth_`,r)||(t.auth_=r);break}return xp(t)}function Cp(e,t,n){let r=wp({[t]:n});if(r===null)return!1;let i=wp(e);return i===null?!1:Array.from(r).every(e=>i.has(e))}function wp(e){let t=new Set;for(let[n,r]of Object.entries(e)){let i;try{i=JSON.parse(r)}catch{return null}if(!Array.isArray(i))return null;for(let[r,a]of i.entries())if(!(typeof a!=`object`||!a||Array.isArray(a)))try{let i=mf(n,a,r,e);t.add(i)}catch{return null}}return t}function Tp(e){if(e===null||typeof e==`string`||typeof e==`boolean`)return e;if(typeof e==`number`){if(!Number.isFinite(e))throw Error(`YAML values must be JSON-compatible`);return e}if(Array.isArray(e))return e.map(Tp);if(typeof e==`object`){if(Object.getPrototypeOf(e)!==Object.prototype)throw Error(`YAML values must be JSON-compatible`);let t={};for(let[n,r]of Object.entries(e))t[n]=Tp(r);return t}throw Error(`YAML values must be JSON-compatible`)}function Ep(e){let t=new zd,n=Jd(e,{lineCounter:t,merge:!1,prettyErrors:!1,strict:!0});if(n.errors.length>0)throw Error(n.errors[0].message);let r=Tp(n.toJS({mapAsMap:!1}));if(!Array.isArray(r))throw Error(`Telepact YAML root must be a sequence`);return{canonicalJsonText:JSON.stringify(r),locator:ef(n,t)}}function Dp(e,t,n){let r={},i={},a=[],o=t.readdirSync(e).sort().map(t=>n.join(e,t));for(let s of o){let o=n.relative(e,s);if(t.statSync(s).isDirectory()){a.push(new sc(o,[],`DirectoryDisallowed`,{})),r[o]=`[]`;continue}let c=t.readFileSync(s,`utf-8`);if(s.endsWith(`.telepact.json`))r[o]=c;else if(s.endsWith(`.telepact.yaml`))try{let e=Ep(c);r[o]=e.canonicalJsonText,e.locator!==void 0&&(i[o]=e.locator)}catch{r[o]=`[]`,a.push(new sc(o,[],`JsonInvalid`,{}))}else r[o]=c,a.push(new sc(o,[],`FileNamePatternInvalid`,{expected:`*.telepact.json|*.telepact.yaml`}))}if(af(r,i),a.length>0)throw new uf(a,r);return r}var Op=class{original;full;parsed;parsedRequestHeaders;parsedResponseHeaders;constructor(e,t,n,r,i){this.original=e,this.full=t,this.parsed=n,this.parsedRequestHeaders=r,this.parsedResponseHeaders=i}static fromJson(e){return Sp({auto_:e})}static fromFileJsonMap(e){return Sp(e)}static fromDirectory(e,t,n){return Sp(Dp(e,t,n))}},kp=class{functionName;functionArgument;verified;constructor(e,t){this.functionName=e,this.functionArgument=t,this.verified=!1}},Ap=class{whenFunction;whenArgument;thenResult;allowArgumentPartialMatch;count;constructor(e,t,n,r,i){this.whenFunction=e,this.whenArgument=t,this.thenResult=n,this.allowArgumentPartialMatch=r,this.count=i}};function jp(e,t,n,r,i){let a=0;for(let r of i)r.functionName===e&&(n?Ao(r.functionArgument,t)&&(r.verified=!0,a+=1):nc(t,r.functionArgument)&&(r.verified=!0,a+=1));let o=i.map(e=>({[e.functionName]:e.functionArgument})),s=Object.entries(r)[0],c=s[0],l=s[1],u=null;if(c===`Exact`){let e=l.times;a>e?u={TooManyMatchingCalls:{wanted:{Exact:{times:e}},found:a,allCalls:o}}:a<e&&(u={TooFewMatchingCalls:{wanted:{Exact:{times:e}},found:a,allCalls:o}})}else if(c===`AtMost`){let e=l.times;a>e&&(u={TooManyMatchingCalls:{wanted:{AtMost:{times:e}},found:a,allCalls:o}})}else if(c===`AtLeast`){let e=l.times;a<e&&(u={TooFewMatchingCalls:{wanted:{AtLeast:{times:e}},found:a,allCalls:o}})}return u===null?{Ok_:{}}:{ErrorVerificationFailure:{reason:u}}}function Mp(e){let t=e.filter(e=>!e.verified);return t.length>0?{ErrorVerificationFailure:{additionalUnverifiedCalls:t.map(e=>({[e.functionName]:e.functionArgument}))}}:{Ok_:{}}}async function Np(e,t,n,r,i,a,o,s){let c=e.headers[`@gen_`]||!1,l=e.getBodyTarget(),u=e.getBodyPayload();if(l===`fn.createStub_`){let e=u.stub,[n,r]=Object.entries(e).find(([e])=>e.startsWith(`fn.`)),i=e[`->`],a=new Ap(n,r,i,!u[`strictMatch!`]||!1,u[`count!`]||-1);return t.unshift(a),new Ja({},{Ok_:{}})}else if(l===`fn.verify_`){let e=u.call,[t,r]=Object.entries(e).find(([e])=>e.startsWith(`fn.`)),i=u[`count!`]||{AtLeast:{times:1}};return new Ja({},jp(t,r,u[`strictMatch!`]||!1,i,n))}else if(l===`fn.verifyNoMoreInteractions_`)return new Ja({},Mp(n));else if(l===`fn.clearCalls_`)return n.length=0,new Ja({},{Ok_:{}});else if(l===`fn.clearStubs_`)return t.length=0,new Ja({},{Ok_:{}});else if(l===`fn.setRandomSeed_`){let e=u.seed;return r.setSeed(e),new Ja({},{Ok_:{}})}else{n.push(new kp(l,u));let e=i.parsed[l+`.->`];for(let n of t)if(n.count!==0&&n.whenFunction===l){if(n.allowArgumentPartialMatch){if(nc(n.whenArgument,u)){let t=e.generateRandomValue(n.thenResult,!0,[],new Ps(!1,s,!0,l,r));return n.count>0&&--n.count,new Ja({},t)}}else if(Ao(n.whenArgument,u)){let t=e.generateRandomValue(n.thenResult,!0,[],new Ps(!1,s,!0,l,r));return n.count>0&&--n.count,new Ja({},t)}}if(!a&&!c)return new Ja({},{ErrorNoMatchingStub_:{}});if(e)return new Ja({},{Ok_:e.tags.Ok_.generateRandomValue({},!0,[],new Ps(!0,s,!0,l,r))});throw new ko(`Unexpected unknown function: ${l}`)}}var Pp=class{constructor(e,t){this.random=new Ua(t.generatedCollectionLengthMin,t.generatedCollectionLengthMax),this.enableGeneratedDefaultStub=t.enableMessageResponseGeneration,this.enableOptionalFieldGeneration=t.enableOptionalFieldGeneration,this.randomizeOptionalFieldGeneration=t.randomizeOptionalFieldGeneration,this.stubs=[],this.invocations=[];let n=new $s;n.onError=t.onError,n.authRequired=!1,n.middleware=async e=>await this.handle(e),this.server=new Qs(new Op(e.original,e.full,e.parsed,e.parsedRequestHeaders,e.parsedResponseHeaders),new qo({}),n)}random;enableGeneratedDefaultStub;enableOptionalFieldGeneration;randomizeOptionalFieldGeneration;stubs;invocations;server;async process(e){return await this.server.process(e)}handle=async e=>await Np(e,this.stubs,this.invocations,this.random,this.server.telepactSchema,this.enableGeneratedDefaultStub,this.enableOptionalFieldGeneration,this.randomizeOptionalFieldGeneration)},Fp=class{onError=e=>{};enableMessageResponseGeneration=!0;enableOptionalFieldGeneration=!0;randomizeOptionalFieldGeneration=!0;generatedCollectionLengthMin=0;generatedCollectionLengthMax=3},Ip=[{"///":"`_ext.Stub_` is the mock stub object consumed by `fn.createStub_`. It\ncontains exactly one non-internal `fn.*` matcher plus a matching `->`\nresult payload that the mock should return.\n\nSee https://raw.githubusercontent.com/Telepact/telepact/main/doc/extensions.md\nfor full `_ext.Stub_` rules and end-to-end examples.\n","_ext.Stub_":{}},{"///":"`_ext.Call_` is the mock call object used by `fn.verify_` and verification\nfailures. It contains exactly one non-internal `fn.*` key whose value is\nthat function's argument object.\n\nSee https://raw.githubusercontent.com/Telepact/telepact/main/doc/extensions.md\nfor full `_ext.Call_` rules and end-to-end examples.\n","_ext.Call_":{}},{"///":`The number of times a function is allowed to be called.`,"union.CallCountCriteria_":[{Exact:{times:`integer`}},{AtMost:{times:`integer`}},{AtLeast:{times:`integer`}}]},{"///":`Possible causes for a mock verification to fail.`,"union.VerificationFailure_":[{TooFewMatchingCalls:{wanted:`union.CallCountCriteria_`,found:`integer`,allCalls:[`_ext.Call_`]}},{TooManyMatchingCalls:{wanted:`union.CallCountCriteria_`,found:`integer`,allCalls:[`_ext.Call_`]}}]},{"///":`Create a mock stub from an \`_ext.Stub_\`.
185
185
 
186
186
  By default the stub matcher is partial, so extra fields on the actual
187
187
  request argument are allowed. Set \`strictMatch!\` to \`true\` to require exact
package/build/index.html CHANGED
@@ -23,7 +23,7 @@
23
23
  <meta name="viewport" content="width=device-width, initial-scale=1" />
24
24
  <script src="./theme-bootstrap.js"></script>
25
25
  <script type="module" src="./override.js"></script>
26
- <script type="module" crossorigin src="./assets/index-70RRDPVc.js"></script>
26
+ <script type="module" crossorigin src="./assets/index-BrBbpyGL.js"></script>
27
27
  <link rel="modulepreload" crossorigin href="./assets/editor.api2-lTxZTfFP.js">
28
28
  <link rel="modulepreload" crossorigin href="./assets/monaco.contribution-CHTVlZuL.js">
29
29
  <link rel="modulepreload" crossorigin href="./assets/workers-BeqnF4UC.js">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telepact-console",
3
- "version": "1.0.0-alpha.264",
3
+ "version": "1.0.0-alpha.266",
4
4
  "description": "A web-based interface for inspecting and testing Telepact APIs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "@tailwindcss/forms": "^0.5.7",
40
40
  "@tailwindcss/typography": "^0.5.19",
41
41
  "@tailwindcss/vite": "^4.2.2",
42
+ "@types/node": "^25.0.3",
42
43
  "@types/react": "^19.0.12",
43
44
  "@types/react-dom": "^19.0.5",
44
- "@types/node": "^25.0.3",
45
45
  "@vitejs/plugin-react": "^6.0.1",
46
46
  "autoprefixer": "^10.4.17",
47
47
  "http-proxy-middleware": "^3.0.3",
@@ -51,7 +51,7 @@
51
51
  "tailwindcss": "^4.1.13",
52
52
  "tslib": "^2.4.1",
53
53
  "typescript": "^5.9.3",
54
- "vite": "^8.0.0"
54
+ "vite": "^8.0.8"
55
55
  },
56
56
  "type": "module",
57
57
  "dependencies": {