@oddington/cli 0.1.89 → 0.1.90
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/os.js +19 -16
- package/package.json +1 -1
package/dist/os.js
CHANGED
|
@@ -144,7 +144,7 @@ ${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.pus
|
|
|
144
144
|
`)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
|
|
145
145
|
`,Z)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(D){let Z=D.items[D.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,Z.value){let $="end"in Z.value?Z.value.end:void 0;if((Array.isArray($)?$[$.length-1]:void 0)?.type==="comment")$?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)D.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else{if(this.atIndentedComment(Z.start,D.indent)){let Q=D.items[D.items.length-2]?.value?.end;if(Array.isArray(Q)){vZ(Q,Z.start),Q.push(this.sourceToken),D.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=D.indent){let $=!this.onKeyLine&&this.indent===D.indent,Q=$&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",J=[];if(Q&&Z.sep&&!Z.value){let X=[];for(let W=0;W<Z.sep.length;++W){let G=Z.sep[W];switch(G.type){case"newline":X.push(W);break;case"space":break;case"comment":if(G.indent>D.indent)X.length=0;break;default:X.length=0}}if(X.length>=2)J=Z.sep.splice(X[1])}switch(this.type){case"anchor":case"tag":if(Q||Z.value)J.push(this.sourceToken),D.items.push({start:J}),this.onKeyLine=!0;else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"explicit-key-ind":if(!Z.sep&&!Z.explicitKey)Z.start.push(this.sourceToken),Z.explicitKey=!0;else if(Q||Z.value)J.push(this.sourceToken),D.items.push({start:J,explicitKey:!0});else 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(Z.explicitKey)if(!Z.sep)if(b3(Z.start,"newline"))Object.assign(Z,{key:null,sep:[this.sourceToken]});else{let X=G5(Z.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]})}else if(Z.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(b3(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:J,key:null,sep:[this.sourceToken]}]});else if(H_(Z.key)&&!b3(Z.sep,"newline")){let X=G5(Z.start),W=Z.key,G=Z.sep;G.push(this.sourceToken),delete Z.key,delete Z.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:W,sep:G}]})}else if(J.length>0)Z.sep=Z.sep.concat(J,this.sourceToken);else Z.sep.push(this.sourceToken);else if(!Z.sep)Object.assign(Z,{key:null,sep:[this.sourceToken]});else if(Z.value||Q)D.items.push({start:J,key:null,sep:[this.sourceToken]});else if(b3(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else Z.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let X=this.flowScalar(this.type);if(Q||Z.value)D.items.push({start:J,key:X,sep:[]}),this.onKeyLine=!0;else if(Z.sep)this.stack.push(X);else Object.assign(Z,{key:X,sep:[]}),this.onKeyLine=!0;return}default:{let X=this.startBlockValue(D);if(X){if(X.type==="block-seq"){if(!Z.explicitKey&&Z.sep&&!b3(Z.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 if($)D.items.push({start:J});this.stack.push(X);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(D){let Z=D.items[D.items.length-1];switch(this.type){case"newline":if(Z.value){let $="end"in Z.value?Z.value.end:void 0;if((Array.isArray($)?$[$.length-1]:void 0)?.type==="comment")$?.push(this.sourceToken);else D.items.push({start:[this.sourceToken]})}else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)D.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(Z.start,D.indent)){let Q=D.items[D.items.length-2]?.value?.end;if(Array.isArray(Q)){vZ(Q,Z.start),Q.push(this.sourceToken),D.items.pop();return}}Z.start.push(this.sourceToken)}return;case"anchor":case"tag":if(Z.value||this.indent<=D.indent)break;Z.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==D.indent)break;if(Z.value||b3(Z.start,"seq-item-ind"))D.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return}if(this.indent>D.indent){let $=this.startBlockValue(D);if($){this.stack.push($);return}}yield*this.pop(),yield*this.step()}*flowCollection(D){let Z=D.items[D.items.length-1];if(this.type==="flow-error-end"){let $;do yield*this.pop(),$=this.peek(1);while($?.type==="flow-collection")}else if(D.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!Z||Z.sep)D.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return;case"map-value-ind":if(!Z||Z.value)D.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Object.assign(Z,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!Z||Z.value)D.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Q=this.flowScalar(this.type);if(!Z||Z.value)D.items.push({start:[],key:Q,sep:[]});else if(Z.sep)this.stack.push(Q);else Object.assign(Z,{key:Q,sep:[]});return}case"flow-map-end":case"flow-seq-end":D.end.push(this.sourceToken);return}let $=this.startBlockValue(D);if($)this.stack.push($);else yield*this.pop(),yield*this.step()}else{let $=this.peek(2);if($.type==="block-map"&&(this.type==="map-value-ind"&&$.indent===D.indent||this.type==="newline"&&!$.items[$.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&$.type!=="flow-collection"){let Q=mZ($),J=G5(Q);B_(D);let X=D.end.splice(1,D.end.length);X.push(this.sourceToken);let W={type:"block-map",offset:D.offset,indent:D.indent,items:[{start:J,key:D,sep:X}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=W}else yield*this.lineEnd(D)}}flowScalar(D){if(this.onNewLine){let Z=this.source.indexOf(`
|
|
146
146
|
`)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
|
|
147
|
-
`,Z)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){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 Z=mZ(D),$=G5(Z);return $.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=mZ(D),$=G5(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return D.every(($)=>$.type==="newline"||$.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){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;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}eh.Parser=K_});var L_=a((Ym)=>{var z_=vG(),$m=P4(),S4=T4(),Zm=oW(),Qm=mD(),Jm=oG(),V_=rG();function U_(D){let Z=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||Z&&new Jm.LineCounter||null,prettyErrors:Z}}function Xm(D,Z={}){let{lineCounter:$,prettyErrors:Q}=U_(Z),J=new V_.Parser($?.addNewLine),X=new z_.Composer(Z),W=Array.from(X.compose(J.parse(D)));if(Q&&$)for(let G of W)G.errors.forEach(S4.prettifyError(D,$)),G.warnings.forEach(S4.prettifyError(D,$));if(W.length>0)return W;return Object.assign([],{empty:!0},X.streamInfo())}function F_(D,Z={}){let{lineCounter:$,prettyErrors:Q}=U_(Z),J=new V_.Parser($?.addNewLine),X=new z_.Composer(Z),W=null;for(let G of X.compose(J.parse(D),!0,D.length))if(!W)W=G;else if(W.options.logLevel!=="silent"){W.errors.push(new S4.YAMLParseError(G.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Q&&$)W.errors.forEach(S4.prettifyError(D,$)),W.warnings.forEach(S4.prettifyError(D,$));return W}function Wm(D,Z,$){let Q=void 0;if(typeof Z==="function")Q=Z;else if($===void 0&&Z&&typeof Z==="object")$=Z;let J=F_(D,$);if(!J)return null;if(J.warnings.forEach((X)=>Zm.warn(J.options.logLevel,X)),J.errors.length>0)if(J.options.logLevel!=="silent")throw J.errors[0];else J.errors=[];return J.toJS(Object.assign({reviver:Q},$))}function Gm(D,Z,$){let Q=null;if(typeof Z==="function"||Array.isArray(Z))Q=Z;else if($===void 0&&Z)$=Z;if(typeof $==="string")$=$.length;if(typeof $==="number"){let J=Math.round($);$=J<1?void 0:J>8?{indent:8}:{indent:J}}if(D===void 0){let{keepUndefined:J}=$??Z??{};if(!J)return}if(Qm.isDocument(D)&&!Q)return D.toString($);return new $m.Document(D,Q,$).toString($)}Ym.parse=Wm;Ym.parseAllDocuments=Xm;Ym.parseDocument=F_;Ym.stringify=Gm});var Vm,Um,Fm,tG,Lm,k3,Nm,_m,Mm,Cm,v2D,Om,Pm,Tm,uZ,N_,jm,eG,qm,Am,Im,Sm,Rm,DY,Em,wm,E1,Y5,xm,y3,w1,bm,km,ym,gm,fm,hm,mm,vm,um,R4,dm,$Y,pm;var ZY=N0(()=>{Vm=vG(),Um=P4(),Fm=jG(),tG=T4(),Lm=Y4(),k3=mD(),Nm=R3(),_m=C2(),Mm=w3(),Cm=x3(),v2D=fZ(),Om=aG(),Pm=oG(),Tm=rG(),uZ=L_(),N_=W4();jm=Vm.Composer,eG=Um.Document,qm=Fm.Schema,Am=tG.YAMLError,Im=tG.YAMLParseError,Sm=tG.YAMLWarning,Rm=Lm.Alias,DY=k3.isAlias,Em=k3.isCollection,wm=k3.isDocument,E1=k3.isMap,Y5=k3.isNode,xm=k3.isPair,y3=k3.isScalar,w1=k3.isSeq,bm=Nm.Pair,km=_m.Scalar,ym=Mm.YAMLMap,gm=Cm.YAMLSeq,fm=Om.Lexer,hm=Pm.LineCounter,mm=Tm.Parser,vm=uZ.parse,um=uZ.parseAllDocuments,R4=uZ.parseDocument,dm=uZ.stringify,$Y=N_.visit,pm=N_.visitAsync});function x1(D){return{type:D.kind,many:D.many,nullable:D.nullable,...D.kind==="number"&&D.precision!==void 0?{decimalPlaces:D.precision}:{},...D.kind==="date"&&D.format?{format:D.format}:{}}}function Z2(D){throw new e(D)}function __(D){if(/[\u0000\uD800-\uDFFF]/u.test(D))Z2("Record text must contain Unicode scalar values excluding U+0000")}function XY(D){if(!D||typeof D!=="object"||Array.isArray(D))Z2("Expected a field mapping");return D}function QY(D,Z,$){if(Object.keys(D).some((Q)=>!Z.includes(Q))||$.some((Q)=>!Object.hasOwn(D,Q)))Z2("Unsupported or missing schema/record fields")}function JY(D,Z,$,Q=!1){if(Z>8)Z2("Invalid field definitions");let J={...XY(D)};if(["enum_list","links","list"].includes(String(J.kind))&&J.many!==void 0&&J.many!==!0)Z2("Conflicting cardinality");if(Object.hasOwn(J,"inline")){if(J.kind!=="list"||typeof J.inline!=="boolean"||Object.hasOwn(J,"style"))Z2("Unsupported or conflicting inline style");if(J.inline)J.style="inline";delete J.inline}switch(J.kind){case"bool":J.kind="boolean";break;case"constant":J.kind="const";break;case"enum_list":J.kind="enum",J.many=!0;break;case"links":J.kind="link",J.many=!0;break;case"month":if(J.format!==void 0&&J.format!=="month")Z2("Conflicting date format");J.kind="date",J.format="month";break;case"list":{if(Object.hasOwn(J,"items")&&Object.hasOwn(J,"fields"))Z2("Conflicting list definitions");let B=Object.hasOwn(J,"items")?J.items:J.fields;if(J.kind=B===void 0?"string":"object",J.many=!0,Object.hasOwn(J,"items"))delete J.items;if(B!==void 0)J.fields=B;break}case"map":if(Object.hasOwn(J,"keys")||Object.hasOwn(J,"values")){if(Object.hasOwn(J,"key")||Object.hasOwn(J,"value")||J.keys!=="YYYY-MM"||J.values!=="number")Z2("Unsupported or conflicting map definitions");J.key={kind:"date",format:"month"},J.value={kind:"number",...Object.hasOwn(J,"precision")?{precision:J.precision}:{}},delete J.keys,delete J.values,delete J.precision}break}if(J.nullable!==void 0&&typeof J.nullable!=="boolean")Z2("Invalid nullability");if(J.many!==void 0&&typeof J.many!=="boolean")Z2("Invalid cardinality");if(["description","term"].some((B)=>J[B]!==void 0&&typeof J[B]!=="string"))Z2("Invalid field documentation");let W={nullable:J.nullable===!0,many:J.many===!0,...$&&J.nullable===!0?{optional:!0}:{},...typeof J.description==="string"?{description:J.description}:{},...typeof J.term==="string"?{term:J.term}:{},...J.style==="inline"?{style:"inline"}:{}};if(J.style!==void 0&&(J.style!=="inline"||!W.many))Z2("Unsupported storage style");let G=["kind","nullable","many","style","description","term",...Q?["name"]:[]],Y=(B=[])=>QY(J,[...G,...B],["kind",...B]);switch(J.kind){case"string":case"integer":case"boolean":case"datetime":return Y(),{...W,kind:J.kind};case"number":if(QY(J,[...G,"precision"],["kind"]),J.precision!==void 0&&(!Number.isInteger(J.precision)||Number(J.precision)<0||Number(J.precision)>6))Z2("Unsupported decimal precision");return{...W,kind:"number",...J.precision!==void 0?{precision:J.precision}:{}};case"date":if(QY(J,[...G,"format"],["kind"]),J.format!==void 0&&J.format!=="month")Z2("Unsupported date format");return{...W,kind:"date",...J.format==="month"?{format:"month"}:{}};case"const":if(Y(["value"]),W.many||!["string","number","boolean"].includes(typeof J.value)||typeof J.value==="number"&&!Number.isFinite(J.value))Z2("Invalid constant");return{...W,kind:"const",value:J.value};case"enum":case"link":{let B=J.kind==="enum"?"values":"to";Y([B]);let K=J.kind==="link"&&typeof J.to==="string"?[J.to]:J[B];if(!Array.isArray(K)||!K.length||K.length>1e5||new Set(K).size!==K.length||K.some((H)=>typeof H!=="string"||!H||J.kind==="link"&&!M_.test(H)))Z2("Invalid enum/link definition");return J.kind==="enum"?{...W,kind:"enum",values:K}:{...W,kind:"link",to:K}}case"object":return Y(["fields"]),{...W,kind:"object",fields:dZ(J.fields,Z+1,$)};case"map":{Y(["key","value"]);let B=JY(J.key,Z+1,$),K=JY(J.value,Z+1,$);if(!["string","integer","date","enum"].includes(B.kind)||B.nullable||B.many)Z2("Unsupported map key definition");return{...W,kind:"map",key:B,value:K}}default:return Z2("Unsupported field kind")}}function dZ(D,Z=0,$=!1){if(Z>8||!Array.isArray(D)||!D.length||D.length>256)Z2("Invalid field definitions");let Q=new Set;return D.map((J)=>{let X=XY(J);if(typeof X.name!=="string"||!M_.test(X.name)||["constructor","prototype"].includes(X.name)||Q.has(X.name))Z2("Invalid or duplicate field name");return Q.add(X.name),{name:X.name,...JY(X,Z,$,!0)}})}function P2(D,Z,$,Q=!1){let J=XY(D);for(let[X,W]of Object.entries(J))if(__(X),typeof W==="string")__(W);for(let X of Object.keys(J))if(!Z.some((W)=>W.name===X))throw new O2("unknown",X);for(let X of Z)if(!X.optional&&!Object.hasOwn(J,X.name))throw new O2("missing",X.name,x1(X));for(let X of Z){let W=J[X.name];if(!Object.hasOwn(J,X.name)&&X.optional)continue;if(W===null&&X.nullable)continue;if(X.many){if(!Array.isArray(W)||W.length>1e5||["enum","link"].includes(X.kind)&&new Set(W).size!==W.length)throw new O2("invalid",X.name,x1(X));try{for(let Y of W)P2({[X.name]:Y},[{...X,many:!1,nullable:!1}],$,Q)}catch(Y){if(Y instanceof O2&&Y.field===X.name)Y.expected=x1(X);throw Y}continue}let G=!1;switch(X.kind){case"const":G=W===X.value;break;case"string":G=typeof W==="string";break;case"integer":G=Number.isSafeInteger(W);break;case"number":{if(G=typeof W==="number"&&Number.isFinite(W),G&&X.precision!==void 0){let Y=W*10**X.precision;G=Number.isSafeInteger(Math.round(Y))&&Math.abs(Y-Math.round(Y))<=Math.min(0.0000001,Number.EPSILON*Math.max(1,Math.abs(Y))*4)}break}case"boolean":G=typeof W==="boolean";break;case"datetime":G=typeof W==="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(W)&&Number.isFinite(Date.parse(W))&&new Date(W).toISOString()===W;break;case"date":{let Y=typeof W==="string"&&X.format==="month"?`${W}-01`:W;G=typeof W==="string"&&(X.format==="month"?/^\d{4}-\d{2}$/.test(W):/^\d{4}-\d{2}-\d{2}$/.test(W))&&typeof Y==="string"&&Number.isFinite(Date.parse(Y))&&new Date(Y).toISOString().slice(0,10)===Y;break}case"enum":G=typeof W==="string"&&X.values.includes(W);break;case"link":{let Y=(Q?s8:a6)(W);G=!!Y&&(!$||X.to.includes($(Y.ref,X.to)??""));break}case"object":if(!W||typeof W!=="object"||Array.isArray(W))break;P2(W,X.fields,$,Q),G=!0;break;case"map":{if(!W||typeof W!=="object"||Array.isArray(W))break;let Y=Object.entries(W);if(Y.length>1e5)Z2("Record map is too large");for(let[B,K]of Y){if(["<<","__proto__","constructor","prototype"].includes(B))Z2("Unsupported record map key");let H=X.key.kind==="integer"?Number(B):B;if(X.key.kind==="integer"&&String(H)!==B)Z2("Invalid integer map key");P2({key:H},[{...X.key,name:"key"}],$,Q),P2({value:K},[{...X.value,name:"value"}],$,Q)}G=!0;break}}if(!G)throw new O2("invalid",X.name,x1(X))}}var e,O2,M_;var E4=N0(()=>{o6();W3();e=class e extends Error{path;constructor(D,Z){super(D);this.path=Z;this.name="RecordValidationError"}};O2=class O2 extends e{problem;field;expected;detail;constructor(D,Z,$){super(`${D} record field: ${Z}`);this.problem=D;this.field=Z;this.expected=$}atRecord(D,Z,$=!1){let Q=$&&this.problem==="unknown"&&this.field==="media_type"?"source_schema":this.problem;return this.message=B6(D,this.field,Q,Z,this.expected)??B6(D,this.field,this.problem)??this.message,this.detail=lJ(D,this.field,Q,Z,this.expected)??lJ(D,this.field,this.problem,void 0,this.expected),Object.assign(this,z8({code:"invalid_change",message:this.message,detail:this.detail})),this}};M_=/^[a-zA-Z][a-zA-Z0-9_-]*$/});function T_(D){let Z=[],$=WY(D).replace(/<([^>]+)>/g,(Q,J)=>{return Z.push(J),J==="year"?"(\\d{4})":J==="month"?"(0[1-9]|1[0-2])":`(${cm})`});return{names:Z,pattern:new RegExp(`^${$}$`)}}function a8(D){return!!D&&!D.many&&!D.nullable&&!["object","map","link"].includes(D.kind)}function bD(D){throw new e(D)}function lm(D){if(/[\u0000\uD800-\uDFFF]/u.test(D))bD("Record text must contain Unicode scalar values excluding U+0000")}function j_(D){if(!D||typeof D!=="object"||Array.isArray(D))bD("Expected a field mapping");return D}function O_(D,Z,$){if(Object.keys(D).some((Q)=>!Z.includes(Q))||$.some((Q)=>!Object.hasOwn(D,Q)))bD("Unsupported or missing schema/record fields")}function q_(D){let Z=R4(D,{version:"1.2",uniqueKeys:!0});if(Z.errors.length||Z.warnings.length)bD("Invalid or unsupported YAML");$Y(Z,($,Q)=>{if(DY(Q)||Y5(Q)&&(Q.tag||("anchor"in Q)&&Q.anchor))bD("YAML tags, anchors and aliases are unsupported");if(y3(Q)&&typeof Q.value==="string")lm(Q.value);if(E1(Q)){if(Q.items.length>1e5)bD("YAML mapping is too large");let J=new Set;for(let X of Q.items){let W=X.key?.value;if(!(typeof W==="string"||typeof W==="number"&&Number.isSafeInteger(W))||["<<","__proto__","constructor","prototype"].includes(String(W))||J.has(String(W)))bD("Unsupported or duplicate YAML mapping key");J.add(String(W))}}if(w1(Q)&&Q.items.length>1e5)bD("YAML list is too large")});try{return z0(Z.toJS({maxAliasCount:0}))}catch{return bD("YAML must contain finite JSON values")}}function GY(D,Z){let $=j_(q_(D));if(Object.hasOwn($,"folder")||Object.hasOwn($,"filename")){if(O_($,["type","folder","filename","reference","description","fields"],["type","folder","filename","fields"]),typeof $.type!=="string"||!C_.test($.type)||typeof $.folder!=="string"||typeof $.filename!=="string"||$.description!==void 0&&typeof $.description!=="string")bD("Unsupported native schema");let{folder:W,filename:G}=$,Y=[...G.matchAll(/<([^>]+)>/g)].map((_)=>_[1]);if(!/^[a-zA-Z0-9_-]+(?:\/(?:[a-zA-Z0-9_-]+|<[a-zA-Z][a-zA-Z0-9_-]*>))*$/.test(W)||!/^(?:[a-zA-Z0-9_-]+|<[a-zA-Z][a-zA-Z0-9_-]*>)+$/.test(G)||!Y.length)bD("Unsupported native naming pattern");let B=W.split("/"),K=B.findIndex((_)=>_.startsWith("<")),H=B.slice(0,K<0?B.length:K).join("/");if(K>=0&&B.slice(K).some((_)=>!_.startsWith("<")))bD("Literal folders after placeholders are unsupported");if(Z!==void 0&&Z!==H&&!Z.endsWith(`/${H}`))bD("Native schema folder does not match its collection");let z=[...W.matchAll(/<([^>]+)>/g),...G.matchAll(/<([^>]+)>/g)].map((_)=>_[1]);if(new Set(z).size!==z.length)bD("Repeated naming placeholder");let V=dZ($.fields,0,!0);for(let _ of z){let M=V.find((O)=>O.name===_);if(M&&!a8(M)&&M.kind!=="link")bD("Naming placeholders require non-null scalar identity fields");if(M&&a8(M)&&M.kind==="const"&&!pZ.test(String(M.value)))bD("Naming constant is not a safe identity field")}let L=[...W.matchAll(/<([^>]+)>/g)].map((_)=>_[1]),N=$.reference??`${H}/${G}`,U=typeof N==="string"?[...N.matchAll(/<([^>]+)>/g)].map((_)=>_[1]):[];if(typeof N!=="string"||!D2(N.replace(/<[^>]+>/g,"example"))||U.some((_)=>!z.includes(_)||L.includes(_)&&_!=="entity"&&!a8(V.find((M)=>M.name===_)))||new Set(U).size!==U.length||Y.some((_)=>!U.includes(_)))bD("Unsupported native reference pattern");let F=V.find((_)=>_.name==="type");if(!F||F.kind!=="const"||F.value!==$.type||F.nullable)bD("Schema requires matching constant type");return{type:$.type,path:G,ref:N,fields:V,naming:{folder:W,filename:G,collection:H},...typeof $.description==="string"?{description:$.description}:{}}}if(O_($,["type","path","ref","fields"],["type","path","ref","fields"]),typeof $.type!=="string"||!C_.test($.type)||typeof $.path!=="string"||!["{id}.md","**/{id}.md"].includes($.path)||typeof $.ref!=="string"||!$.ref.endsWith("/{id}")||!D2($.ref.replace("{id}","example")))bD("Unsupported record type, path or reference pattern");let Q=dZ($.fields),J=Q.find((W)=>W.name==="id"),X=Q.find((W)=>W.name==="type");if(!J||J.kind!=="string"||J.many||J.nullable||!X||X.kind!=="const"||X.value!==$.type||X.nullable)bD("Schema requires string id and matching constant type");return{type:$.type,path:$.path,ref:$.ref,fields:Q}}function cZ(D,Z,$){let Q=Z.split("/");if(Q.some((_)=>!_||_==="."||_===".."||!/^[a-zA-Z0-9_.-]+$/.test(_)))bD("Record path does not match its schema");if(!D.naming){let _=Q.at(-1),M=_?.endsWith(".md")?_.slice(0,-3):void 0;if(!M||!pZ.test(M)||D.path==="{id}.md"&&Q.length!==1)bD("Record path does not match its schema");if($&&(typeof $.id!=="string"||$.id!==M))bD("Invalid stable record identity");return D.ref.replace("{id}",M)}let J=D.naming.folder.slice(D.naming.collection.length+1),{names:X,pattern:W}=T_(J),G=W.exec(Q.slice(0,-1).join("/"));if(!G)bD("Record path does not match its schema");let Y=Object.fromEntries(X.map((_,M)=>[_,G[M+1]])),B=Q.at(-1),K=B?.endsWith(".md")?B.slice(0,-3):void 0;if(!K)bD("Record path does not match its schema");let H=[...D.naming.filename.matchAll(/<([^>]+)>/g)].map((_)=>_[1]),z=(_)=>_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),V=[],L="",N=0;for(let _ of D.naming.filename.matchAll(/<([^>]+)>/g)){L+=z(D.naming.filename.slice(N,_.index));let M=_[1],O=D.fields.find((j)=>j.name===M);if($&&O&&a8(O)){if(P2({[M]:$[M]},[O]),!pZ.test(String($[M])))bD("Invalid filename identity field");Y[M]=String($[M]),L+=z(Y[M])}else V.push(M),L+="([a-zA-Z0-9][a-zA-Z0-9_-]*)";N=_.index+_[0].length}L+=z(D.naming.filename.slice(N));let U=new RegExp(`^${L}$`).exec(K);if(!U)bD("Record identity fields do not match its filename");for(let[_,M]of V.entries())Y[M]=U[_+1];if(!$&&H.length>1){if(D.ref===`${D.naming.collection}/${D.naming.filename}`)return`${D.naming.collection}/${K}`;return}for(let _ of X){let M=D.fields.find((O)=>O.name===_);if($&&M&&a8(M)){if(P2({[_]:$[_]},[M]),String($[_])!==Y[_])bD("Record identity field does not match its folder")}}let F=D.ref.replace(/<([^>]+)>/g,(_,M)=>Y[M]);if(!D2(F))bD("Invalid stable record identity");return F}function A_(D,Z){let $=P_.get(D);if(!$){if(!D.naming)$=(Q)=>{let J=Q.split("/"),X=J.at(-1),W=X?.endsWith(".md")?X.slice(0,-3):void 0;if(J.some((G)=>!G||G==="."||G===".."||!/^[a-zA-Z0-9_.-]+$/.test(G))||!W||!pZ.test(W)||D.path==="{id}.md"&&J.length!==1)bD("Record path does not match its schema");return D.ref.replace("{id}",W)};else{let Q=D.naming.folder.slice(D.naming.collection.length+1),{names:J,pattern:X}=T_(Q),W=[],G="",Y=0;for(let H of D.naming.filename.matchAll(/<([^>]+)>/g))G+=WY(D.naming.filename.slice(Y,H.index)),W.push(H[1]),G+="([a-zA-Z0-9][a-zA-Z0-9_-]*)",Y=H.index+H[0].length;G+=WY(D.naming.filename.slice(Y));let B=new RegExp(`^${G}$`),K=W.length<=1||D.ref===`${D.naming.collection}/${D.naming.filename}`;$=(H)=>{let z=H.split("/");if(z.some((M)=>!M||M==="."||M===".."||!/^[a-zA-Z0-9_.-]+$/.test(M)))bD("Record path does not match its schema");let V=X.exec(z.slice(0,-1).join("/"));if(!V)bD("Record path does not match its schema");let L=Object.fromEntries(J.map((M,O)=>[M,V[O+1]])),N=z.at(-1),U=N?.endsWith(".md")?N.slice(0,-3):void 0,F=U?B.exec(U):void 0;if(!F)bD("Record identity fields do not match its filename");for(let[M,O]of W.entries())L[O]=F[M+1];if(!K)return;let _=D.ref.replace(/<([^>]+)>/g,(M,O)=>L[O]);if(!D2(_))bD("Invalid stable record identity");return _}}P_.set(D,$)}return $(Z)}function b1(D,Z,$){let Q=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(D);if(!Q)bD("Record requires YAML front matter");let J=j_(q_(Q[1]));if(J.type!==Z.type)bD("Record type does not match its schema");let X=cZ(Z,$,J);if(!X)bD("Record path requires its record fields");return{ref:X,fields:J,body:Q[2]}}function g3(D,Z){let $=new Set,Q=(J,X)=>{if(J===null||J===void 0)return;if(X.many){if(Array.isArray(J))for(let W of J)Q(W,{...X,many:!1})}else if(X.kind==="link"){let W=a6(J);if(W)$.add(W.ref)}else if(typeof J==="object"&&!Array.isArray(J)){if(X.kind==="object")for(let W of X.fields)Q(J[W.name],W);if(X.kind==="map")for(let W of Object.values(J))Q(W,X.value)}};for(let J of Z)Q(D[J.name],J);return[...$]}var cm="[a-zA-Z0-9][a-zA-Z0-9_-]*",WY=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C_,pZ,P_;var m0=N0(()=>{o6();ZY();l0();E4();E4();C_=/^[a-zA-Z][a-zA-Z0-9_-]*$/,pZ=/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;P_=new WeakMap});import{createHash as sm}from"node:crypto";function a2(D){return`record-v1:${sm("sha256").update(D).digest("hex")}`}var w4=()=>{};import{posix as B5}from"node:path";async function lZ(D,Z,$,Q={}){if(!tB($)||!$.length)throw new e("Managed data roots required");let J=(M)=>$.some((O)=>O==="."||M===O||M.startsWith(`${O}/`)),X=D.filter((M)=>J(M.path)),W=(M)=>M.split("/").some((O)=>["routines",".git"].includes(O)),G=new Map,Y=new Map;for(let M of X){if(W(M.path))continue;if(M.path.split("/").some((O)=>!/^[a-zA-Z0-9_.-]+$/.test(O)||[".",".."].includes(O)))throw new e("Unsupported data path");if(M.mode!=="100644")throw new e("Symlinks, submodules and executable data are unsupported")}let B=X.filter((M)=>!W(M.path)&&B5.basename(M.path)==="_schema.yaml"),K=Array(B.length),H=0,z=async()=>{while(!0){let M=H++,O=B[M];if(!O)return;try{K[M]=GY(I_.decode(await Z(O.oid)),B5.dirname(O.path))}catch(j){YY(j,O.path)}}};await Promise.all(Array.from({length:Math.min(Q.readConcurrency??1,B.length)},z));for(let[M,O]of B.entries())G.set(B5.dirname(O.path),K[M]),Y.set(O.path,O.oid);if(!G.size)throw new e("No collection schemas in managed data roots");let V=new Map,L=[],N=new Map,U=async(M)=>{let O=N.get(M.entry.path);if(O)return O;let j=await Z(M.entry.oid),q;Q.observeRecordParse?.(M.entry.path);try{q=b1(I_.decode(j),M.schema,M.relativePath)}catch(C){return YY(C,M.entry.path)}let R={bytes:j,record:q};return N.set(M.entry.path,R),R};for(let M of X){if(W(M.path)||!M.path.endsWith(".md"))continue;let O=B5.dirname(M.path);while(!G.has(O)&&O!==".")O=B5.dirname(O);let j=G.get(O);if(!j)throw new e("Markdown record has no collection schema");let q=B5.relative(O,M.path),R=A_(j,q),C={entry:M,schema:j,collectionPath:O,relativePath:q};if(!R){L.push(C);continue}if(V.has(R))throw new e("Duplicate stable record reference");V.set(R,C)}for(let M of L){let{record:O}=await U(M);if(V.has(O.ref))throw new e("Duplicate stable record reference");V.set(O.ref,M)}let F=new Map([...V].map(([M,O])=>[M,O.schema.type])),_=new Map([...V].map(([M,O])=>[M,O.entry.path]));return{async snapshot(M,O,j,q=!1,R={}){let C=new Map,T=M;if(q)T=[...V.keys()];if(O!==void 0){if(!G.has(O))throw new e("Collection schema unavailable");T=[...V].filter(([,m])=>m.collectionPath===O).map(([m])=>m)}let w=Array(T.length),y=0,E=async()=>{while(!0){let m=y++,h=T[m];if(h===void 0)return;let f=V.get(h);if(!f){if(R.allowMissing)continue;throw new e("Record is missing or outside the named repository")}let{bytes:c,record:d}=await U(f);if(d.ref!==h)throw new e("Record identity changed during capture");w[m]={...d,schema:f.schema,bytes:c,path:f.entry.path,collectionPath:f.collectionPath,version:a2(c)}}},k=Math.min(R.readConcurrency??1,T.length);await Promise.all(Array.from({length:k},E));for(let m=0;m<T.length;m++){let h=w[m];if(h)C.set(T[m],h)}if(R.validateFields!==!1)for(let m of C.values())try{P2(m.fields,m.schema.fields,(h)=>V.get(h)?.schema.type)}catch(h){YY(h,m.path)}let b=[];if(j?.size)for(let[m,h]of V){if(j.has(m))continue;let{record:f}=await U(h);for(let c of g3(f.fields,h.schema.fields))if(j.has(c))b.push({from:m,to:c})}return{records:C,schemas:G,schemaVersions:Y,incomingReferences:b,types:F,paths:_}}}}var I_,YY=(D,Z)=>{if(D instanceof e)throw new e(D.message,D.path??Z);throw D};var BY=N0(()=>{Y0();m0();w4();I_=new TextDecoder("utf-8",{fatal:!0})});c0();import{createHash as Bj,randomBytes as kK}from"node:crypto";import{execFile as Hj}from"node:child_process";import{createServer as Kj}from"node:http";import{createInterface as zj}from"node:readline/promises";var a5=(D,Z=[])=>D.name==="up"||Z.includes("vim")&&D.name==="k"||Z.includes("emacs")&&D.ctrl&&D.name==="p",M7=(D,Z=[])=>D.name==="down"||Z.includes("vim")&&D.name==="j"||Z.includes("emacs")&&D.ctrl&&D.name==="n";var QJ=(D)=>D.name==="backspace";var JJ=(D)=>"1234567890".includes(D.name),XJ=(D)=>D.name==="enter"||D.name==="return";class WJ extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class GJ extends Error{name="CancelPromptError";message="Prompt was canceled"}class C7 extends Error{name="ExitPromptError"}class YJ extends Error{name="HookError"}class o5 extends Error{name="ValidationError"}import{AsyncResource as gP}from"node:async_hooks";import{AsyncLocalStorage as bP,AsyncResource as kP}from"node:async_hooks";var eB=new bP;function yP(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function DH(D,Z){let $=yP(D);return eB.run($,()=>{function Q(J){$.handleChange=()=>{$.index=0,J()},$.handleChange()}return Z(Q)})}function n3(){let D=eB.getStore();if(!D)throw new YJ("[Inquirer] Hook functions can only be called from within a prompt");return D}function BJ(){return n3().rl}function HJ(D){let Z=(...$)=>{let Q=n3(),J=!1,X=Q.handleChange;Q.handleChange=()=>{J=!0};let W=D(...$);if(J)X();return Q.handleChange=X,W};return kP.bind(Z)}function e1(D){let Z=n3(),{index:$}=Z,Q={get(){return Z.hooks[$]},set(X){Z.hooks[$]=X},initialized:$ in Z.hooks},J=D(Q);return Z.index++,J}function $H(){n3().handleChange()}var i3={queue(D){let Z=n3(),{index:$}=Z;Z.hooksEffect.push(()=>{Z.hooksCleanup[$]?.();let Q=D(BJ());if(Q!=null&&typeof Q!=="function")throw new o5("useEffect return value must be a cleanup function or nothing.");Z.hooksCleanup[$]=Q})},run(){let D=n3();HJ(()=>{D.hooksEffect.forEach((Z)=>{Z()}),D.hooksEffect.length=0})()},clearAll(){let D=n3();D.hooksCleanup.forEach((Z)=>{Z?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function y8(D){return e1((Z)=>{let $=gP.bind(function J(X){if(Z.get()!==X)Z.set(X),$H()});if(Z.initialized)return[Z.get(),$];let Q=typeof D==="function"?D():D;return Z.set(Q),[Q,$]})}function a3(D,Z){e1(($)=>{let Q=$.get();if(!Array.isArray(Q)||Z.some((X,W)=>!Object.is(X,Q[W])))i3.queue(D);$.set(Z)})}var I0=H8(O7(),1);import K8 from"node:process";function mP(){if(K8.platform!=="win32")return K8.env.TERM!=="linux";return Boolean(K8.env.WT_SESSION)||Boolean(K8.env.TERMINUS_SUBLIME)||K8.env.ConEmuTask==="{cmd::Cmder}"||K8.env.TERM_PROGRAM==="Terminus-Sublime"||K8.env.TERM_PROGRAM==="vscode"||K8.env.TERM==="xterm-256color"||K8.env.TERM==="alacritty"||K8.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var QH={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},JH={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},vP={tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},uP={...QH,...JH},dP={...QH,...vP},pP=mP(),cP=pP?uP:dP,D6=cP,Ps=Object.entries(JH);var XH={prefix:{idle:I0.default.blue("?"),done:I0.default.green(D6.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>I0.default.yellow(D))},style:{answer:I0.default.cyan,message:I0.default.bold,error:(D)=>I0.default.red(`> ${D}`),defaultAnswer:(D)=>I0.default.dim(`(${D})`),help:I0.default.dim,highlight:I0.default.cyan,key:(D)=>I0.default.cyan(I0.default.bold(`<${D}>`))}};function WH(D){if(typeof D!=="object"||D===null)return!1;let Z=D;while(Object.getPrototypeOf(Z)!==null)Z=Object.getPrototypeOf(Z);return Object.getPrototypeOf(D)===Z}function GH(...D){let Z={};for(let $ of D)for(let[Q,J]of Object.entries($)){let X=Z[Q];Z[Q]=WH(X)&&WH(J)?GH(X,J):J}return Z}function r5(...D){let Z=[XH,...D.filter(($)=>$!=null)];return GH(...Z)}function KJ({status:D="idle",theme:Z}){let[$,Q]=y8(!1),[J,X]=y8(0),{prefix:W,spinner:G}=r5(Z);if(a3(()=>{if(D==="loading"){let B,K=-1,H=setTimeout(()=>{Q(!0),B=setInterval(()=>{K=K+1,X(K%G.frames.length)},G.interval)},300);return()=>{clearTimeout(H),clearInterval(B)}}else Q(!1)},[D]),$)return G.frames[J];return typeof W==="string"?W:W[D==="loading"?"idle":D]??W.idle}function t5(D,Z){return e1(($)=>{let Q=$.get();if(!Q||Q.dependencies.length!==Z.length||Q.dependencies.some((J,X)=>J!==Z[X])){let J=D();return $.set({value:J,dependencies:Z}),J}return Q.value})}function o3(D){return y8({current:D})[0]}function zJ(D){let Z=o3(D);Z.current=D,a3(($)=>{let Q=!1,J=HJ((X,W)=>{if(Q)return;Z.current(W,$)});return $.input.on("keypress",J),()=>{Q=!0,$.input.removeListener("keypress",J)}},[])}var gH=H8(BH(),1),fH=H8(yH(),1);function $9(D,Z){return D.split(`
|
|
147
|
+
`,Z)+1}return{type:D,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(D){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 Z=mZ(D),$=G5(Z);return $.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=mZ(D),$=G5(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(D,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return D.every(($)=>$.type==="newline"||$.type==="space")}*documentEnd(D){if(this.type!=="doc-mode"){if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd(D){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;case"space":case"comment":default:if(D.end)D.end.push(this.sourceToken);else D.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}eh.Parser=K_});var L_=a((Ym)=>{var z_=vG(),$m=P4(),S4=T4(),Zm=oW(),Qm=mD(),Jm=oG(),V_=rG();function U_(D){let Z=D.prettyErrors!==!1;return{lineCounter:D.lineCounter||Z&&new Jm.LineCounter||null,prettyErrors:Z}}function Xm(D,Z={}){let{lineCounter:$,prettyErrors:Q}=U_(Z),J=new V_.Parser($?.addNewLine),X=new z_.Composer(Z),W=Array.from(X.compose(J.parse(D)));if(Q&&$)for(let G of W)G.errors.forEach(S4.prettifyError(D,$)),G.warnings.forEach(S4.prettifyError(D,$));if(W.length>0)return W;return Object.assign([],{empty:!0},X.streamInfo())}function F_(D,Z={}){let{lineCounter:$,prettyErrors:Q}=U_(Z),J=new V_.Parser($?.addNewLine),X=new z_.Composer(Z),W=null;for(let G of X.compose(J.parse(D),!0,D.length))if(!W)W=G;else if(W.options.logLevel!=="silent"){W.errors.push(new S4.YAMLParseError(G.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(Q&&$)W.errors.forEach(S4.prettifyError(D,$)),W.warnings.forEach(S4.prettifyError(D,$));return W}function Wm(D,Z,$){let Q=void 0;if(typeof Z==="function")Q=Z;else if($===void 0&&Z&&typeof Z==="object")$=Z;let J=F_(D,$);if(!J)return null;if(J.warnings.forEach((X)=>Zm.warn(J.options.logLevel,X)),J.errors.length>0)if(J.options.logLevel!=="silent")throw J.errors[0];else J.errors=[];return J.toJS(Object.assign({reviver:Q},$))}function Gm(D,Z,$){let Q=null;if(typeof Z==="function"||Array.isArray(Z))Q=Z;else if($===void 0&&Z)$=Z;if(typeof $==="string")$=$.length;if(typeof $==="number"){let J=Math.round($);$=J<1?void 0:J>8?{indent:8}:{indent:J}}if(D===void 0){let{keepUndefined:J}=$??Z??{};if(!J)return}if(Qm.isDocument(D)&&!Q)return D.toString($);return new $m.Document(D,Q,$).toString($)}Ym.parse=Wm;Ym.parseAllDocuments=Xm;Ym.parseDocument=F_;Ym.stringify=Gm});var Vm,Um,Fm,tG,Lm,k3,Nm,_m,Mm,Cm,v2D,Om,Pm,Tm,uZ,N_,jm,eG,qm,Am,Im,Sm,Rm,DY,Em,wm,E1,Y5,xm,y3,w1,bm,km,ym,gm,fm,hm,mm,vm,um,R4,dm,$Y,pm;var ZY=N0(()=>{Vm=vG(),Um=P4(),Fm=jG(),tG=T4(),Lm=Y4(),k3=mD(),Nm=R3(),_m=C2(),Mm=w3(),Cm=x3(),v2D=fZ(),Om=aG(),Pm=oG(),Tm=rG(),uZ=L_(),N_=W4();jm=Vm.Composer,eG=Um.Document,qm=Fm.Schema,Am=tG.YAMLError,Im=tG.YAMLParseError,Sm=tG.YAMLWarning,Rm=Lm.Alias,DY=k3.isAlias,Em=k3.isCollection,wm=k3.isDocument,E1=k3.isMap,Y5=k3.isNode,xm=k3.isPair,y3=k3.isScalar,w1=k3.isSeq,bm=Nm.Pair,km=_m.Scalar,ym=Mm.YAMLMap,gm=Cm.YAMLSeq,fm=Om.Lexer,hm=Pm.LineCounter,mm=Tm.Parser,vm=uZ.parse,um=uZ.parseAllDocuments,R4=uZ.parseDocument,dm=uZ.stringify,$Y=N_.visit,pm=N_.visitAsync});function x1(D){return{type:D.kind,many:D.many,nullable:D.nullable,...D.kind==="number"&&D.precision!==void 0?{decimalPlaces:D.precision}:{},...D.kind==="date"&&D.format?{format:D.format}:{}}}function Z2(D){throw new e(D)}function __(D){if(/[\u0000\uD800-\uDFFF]/u.test(D))Z2("Record text must contain Unicode scalar values excluding U+0000")}function XY(D){if(!D||typeof D!=="object"||Array.isArray(D))Z2("Expected a field mapping");return D}function QY(D,Z,$){if(Object.keys(D).some((Q)=>!Z.includes(Q))||$.some((Q)=>!Object.hasOwn(D,Q)))Z2("Unsupported or missing schema/record fields")}function JY(D,Z,$,Q=!1){if(Z>8)Z2("Invalid field definitions");let J={...XY(D)};if(["enum_list","links","list"].includes(String(J.kind))&&J.many!==void 0&&J.many!==!0)Z2("Conflicting cardinality");if(Object.hasOwn(J,"inline")){if(J.kind!=="list"||typeof J.inline!=="boolean"||Object.hasOwn(J,"style"))Z2("Unsupported or conflicting inline style");if(J.inline)J.style="inline";delete J.inline}switch(J.kind){case"bool":J.kind="boolean";break;case"constant":J.kind="const";break;case"enum_list":J.kind="enum",J.many=!0;break;case"links":J.kind="link",J.many=!0;break;case"month":if(J.format!==void 0&&J.format!=="month")Z2("Conflicting date format");J.kind="date",J.format="month";break;case"list":{if(Object.hasOwn(J,"items")&&Object.hasOwn(J,"fields"))Z2("Conflicting list definitions");let B=Object.hasOwn(J,"items")?J.items:J.fields;if(J.kind=B===void 0?"string":"object",J.many=!0,Object.hasOwn(J,"items"))delete J.items;if(B!==void 0)J.fields=B;break}case"map":if(Object.hasOwn(J,"keys")||Object.hasOwn(J,"values")){if(Object.hasOwn(J,"key")||Object.hasOwn(J,"value")||J.keys!=="YYYY-MM"||J.values!=="number")Z2("Unsupported or conflicting map definitions");J.key={kind:"date",format:"month"},J.value={kind:"number",...Object.hasOwn(J,"precision")?{precision:J.precision}:{}},delete J.keys,delete J.values,delete J.precision}break}if(J.nullable!==void 0&&typeof J.nullable!=="boolean")Z2("Invalid nullability");if(J.many!==void 0&&typeof J.many!=="boolean")Z2("Invalid cardinality");if(["description","term"].some((B)=>J[B]!==void 0&&typeof J[B]!=="string"))Z2("Invalid field documentation");let W={nullable:J.nullable===!0,many:J.many===!0,...$&&J.nullable===!0?{optional:!0}:{},...typeof J.description==="string"?{description:J.description}:{},...typeof J.term==="string"?{term:J.term}:{},...J.style==="inline"?{style:"inline"}:{}};if(J.style!==void 0&&(J.style!=="inline"||!W.many))Z2("Unsupported storage style");let G=["kind","nullable","many","style","description","term",...Q?["name"]:[]],Y=(B=[])=>QY(J,[...G,...B],["kind",...B]);switch(J.kind){case"string":case"integer":case"boolean":case"datetime":return Y(),{...W,kind:J.kind};case"number":if(QY(J,[...G,"precision"],["kind"]),J.precision!==void 0&&(!Number.isInteger(J.precision)||Number(J.precision)<0||Number(J.precision)>6))Z2("Unsupported decimal precision");return{...W,kind:"number",...J.precision!==void 0?{precision:J.precision}:{}};case"date":if(QY(J,[...G,"format"],["kind"]),J.format!==void 0&&J.format!=="month")Z2("Unsupported date format");return{...W,kind:"date",...J.format==="month"?{format:"month"}:{}};case"const":if(Y(["value"]),W.many||!["string","number","boolean"].includes(typeof J.value)||typeof J.value==="number"&&!Number.isFinite(J.value))Z2("Invalid constant");return{...W,kind:"const",value:J.value};case"enum":case"link":{let B=J.kind==="enum"?"values":"to";Y([B]);let K=J.kind==="link"&&typeof J.to==="string"?[J.to]:J[B];if(!Array.isArray(K)||!K.length||K.length>1e5||new Set(K).size!==K.length||K.some((H)=>typeof H!=="string"||!H||J.kind==="link"&&!M_.test(H)))Z2("Invalid enum/link definition");return J.kind==="enum"?{...W,kind:"enum",values:K}:{...W,kind:"link",to:K}}case"object":return Y(["fields"]),{...W,kind:"object",fields:dZ(J.fields,Z+1,$)};case"map":{Y(["key","value"]);let B=JY(J.key,Z+1,$),K=JY(J.value,Z+1,$);if(!["string","integer","date","enum"].includes(B.kind)||B.nullable||B.many)Z2("Unsupported map key definition");return{...W,kind:"map",key:B,value:K}}default:return Z2("Unsupported field kind")}}function dZ(D,Z=0,$=!1){if(Z>8||!Array.isArray(D)||!D.length||D.length>256)Z2("Invalid field definitions");let Q=new Set;return D.map((J)=>{let X=XY(J);if(typeof X.name!=="string"||!M_.test(X.name)||["constructor","prototype"].includes(X.name)||Q.has(X.name))Z2("Invalid or duplicate field name");return Q.add(X.name),{name:X.name,...JY(X,Z,$,!0)}})}function P2(D,Z,$,Q=!1){let J=XY(D);for(let[X,W]of Object.entries(J))if(__(X),typeof W==="string")__(W);for(let X of Object.keys(J))if(!Z.some((W)=>W.name===X))throw new O2("unknown",X);for(let X of Z)if(!X.optional&&!Object.hasOwn(J,X.name))throw new O2("missing",X.name,x1(X));for(let X of Z){let W=J[X.name];if(!Object.hasOwn(J,X.name)&&X.optional)continue;if(W===null&&X.nullable)continue;if(X.many){if(!Array.isArray(W)||W.length>1e5||["enum","link"].includes(X.kind)&&new Set(W).size!==W.length)throw new O2("invalid",X.name,x1(X));try{for(let Y of W)P2({[X.name]:Y},[{...X,many:!1,nullable:!1}],$,Q)}catch(Y){if(Y instanceof O2&&Y.field===X.name)Y.expected=x1(X);throw Y}continue}let G=!1;switch(X.kind){case"const":G=W===X.value;break;case"string":G=typeof W==="string";break;case"integer":G=Number.isSafeInteger(W);break;case"number":{if(G=typeof W==="number"&&Number.isFinite(W),G&&X.precision!==void 0){let Y=W*10**X.precision;G=Number.isSafeInteger(Math.round(Y))&&Math.abs(Y-Math.round(Y))<=Math.min(0.0000001,Number.EPSILON*Math.max(1,Math.abs(Y))*4)}break}case"boolean":G=typeof W==="boolean";break;case"datetime":G=typeof W==="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(W)&&Number.isFinite(Date.parse(W))&&new Date(W).toISOString()===W;break;case"date":{let Y=typeof W==="string"&&X.format==="month"?`${W}-01`:W;G=typeof W==="string"&&(X.format==="month"?/^\d{4}-\d{2}$/.test(W):/^\d{4}-\d{2}-\d{2}$/.test(W))&&typeof Y==="string"&&Number.isFinite(Date.parse(Y))&&new Date(Y).toISOString().slice(0,10)===Y;break}case"enum":G=typeof W==="string"&&X.values.includes(W);break;case"link":{let Y=(Q?s8:a6)(W);G=!!Y&&(!$||X.to.includes($(Y.ref,X.to)??""));break}case"object":if(!W||typeof W!=="object"||Array.isArray(W))break;P2(W,X.fields,$,Q),G=!0;break;case"map":{if(!W||typeof W!=="object"||Array.isArray(W))break;let Y=Object.entries(W);if(Y.length>1e5)Z2("Record map is too large");for(let[B,K]of Y){if(["<<","__proto__","constructor","prototype"].includes(B))Z2("Unsupported record map key");let H=X.key.kind==="integer"?Number(B):B;if(X.key.kind==="integer"&&String(H)!==B)Z2("Invalid integer map key");P2({key:H},[{...X.key,name:"key"}],$,Q),P2({value:K},[{...X.value,name:"value"}],$,Q)}G=!0;break}}if(!G)throw new O2("invalid",X.name,x1(X))}}var e,O2,M_;var E4=N0(()=>{o6();W3();e=class e extends Error{path;constructor(D,Z){super(D);this.path=Z;this.name="RecordValidationError"}};O2=class O2 extends e{problem;field;expected;detail;constructor(D,Z,$){super(`${D} record field: ${Z}`);this.problem=D;this.field=Z;this.expected=$}atRecord(D,Z,$=!1){let Q=$&&this.problem==="unknown"&&this.field==="media_type"?"source_schema":this.problem;return this.message=B6(D,this.field,Q,Z,this.expected)??B6(D,this.field,this.problem)??this.message,this.detail=lJ(D,this.field,Q,Z,this.expected)??lJ(D,this.field,this.problem,void 0,this.expected),Object.assign(this,z8({code:"invalid_change",message:this.message,detail:this.detail})),this}};M_=/^[a-zA-Z][a-zA-Z0-9_-]*$/});function T_(D){let Z=[],$=WY(D).replace(/<([^>]+)>/g,(Q,J)=>{return Z.push(J),J==="year"?"(\\d{4})":J==="month"?"(0[1-9]|1[0-2])":`(${cm})`});return{names:Z,pattern:new RegExp(`^${$}$`)}}function a8(D){return!!D&&!D.many&&!D.nullable&&!["object","map","link"].includes(D.kind)}function bD(D){throw new e(D)}function lm(D){if(/[\u0000\uD800-\uDFFF]/u.test(D))bD("Record text must contain Unicode scalar values excluding U+0000")}function j_(D){if(!D||typeof D!=="object"||Array.isArray(D))bD("Expected a field mapping");return D}function O_(D,Z,$){if(Object.keys(D).some((Q)=>!Z.includes(Q))||$.some((Q)=>!Object.hasOwn(D,Q)))bD("Unsupported or missing schema/record fields")}function q_(D){let Z=R4(D,{version:"1.2",uniqueKeys:!0});if(Z.errors.length||Z.warnings.length)bD("Invalid or unsupported YAML");$Y(Z,($,Q)=>{if(DY(Q)||Y5(Q)&&(Q.tag||("anchor"in Q)&&Q.anchor))bD("YAML tags, anchors and aliases are unsupported");if(y3(Q)&&typeof Q.value==="string")lm(Q.value);if(E1(Q)){if(Q.items.length>1e5)bD("YAML mapping is too large");let J=new Set;for(let X of Q.items){let W=X.key?.value;if(!(typeof W==="string"||typeof W==="number"&&Number.isSafeInteger(W))||["<<","__proto__","constructor","prototype"].includes(String(W))||J.has(String(W)))bD("Unsupported or duplicate YAML mapping key");J.add(String(W))}}if(w1(Q)&&Q.items.length>1e5)bD("YAML list is too large")});try{return z0(Z.toJS({maxAliasCount:0}))}catch{return bD("YAML must contain finite JSON values")}}function GY(D,Z){let $=j_(q_(D));if(Object.hasOwn($,"folder")||Object.hasOwn($,"filename")){if(O_($,["type","folder","filename","reference","description","fields"],["type","folder","filename","fields"]),typeof $.type!=="string"||!C_.test($.type)||typeof $.folder!=="string"||typeof $.filename!=="string"||$.description!==void 0&&typeof $.description!=="string")bD("Unsupported native schema");let{folder:W,filename:G}=$,Y=[...G.matchAll(/<([^>]+)>/g)].map((_)=>_[1]);if(!/^[a-zA-Z0-9_-]+(?:\/(?:[a-zA-Z0-9_-]+|<[a-zA-Z][a-zA-Z0-9_-]*>))*$/.test(W)||!/^(?:[a-zA-Z0-9_-]+|<[a-zA-Z][a-zA-Z0-9_-]*>)+$/.test(G)||!Y.length)bD("Unsupported native naming pattern");let B=W.split("/"),K=B.findIndex((_)=>_.startsWith("<")),H=B.slice(0,K<0?B.length:K).join("/");if(K>=0&&B.slice(K).some((_)=>!_.startsWith("<")))bD("Literal folders after placeholders are unsupported");if(Z!==void 0&&Z!==H&&!Z.endsWith(`/${H}`))bD("Native schema folder does not match its collection");let z=[...W.matchAll(/<([^>]+)>/g),...G.matchAll(/<([^>]+)>/g)].map((_)=>_[1]);if(new Set(z).size!==z.length)bD("Repeated naming placeholder");let V=dZ($.fields,0,!0);for(let _ of z){let M=V.find((O)=>O.name===_);if(M&&!a8(M)&&M.kind!=="link")bD("Naming placeholders require non-null scalar identity fields");if(M&&a8(M)&&M.kind==="const"&&!pZ.test(String(M.value)))bD("Naming constant is not a safe identity field")}let L=[...W.matchAll(/<([^>]+)>/g)].map((_)=>_[1]),N=$.reference??`${H}/${G}`,U=typeof N==="string"?[...N.matchAll(/<([^>]+)>/g)].map((_)=>_[1]):[];if(typeof N!=="string"||!D2(N.replace(/<[^>]+>/g,"example"))||U.some((_)=>!z.includes(_)||L.includes(_)&&_!=="entity"&&!a8(V.find((M)=>M.name===_)))||new Set(U).size!==U.length||Y.some((_)=>!U.includes(_)))bD("Unsupported native reference pattern");let F=V.find((_)=>_.name==="type");if(!F||F.kind!=="const"||F.value!==$.type||F.nullable)bD("Schema requires matching constant type");return{type:$.type,path:G,ref:N,fields:V,naming:{folder:W,filename:G,collection:H},...typeof $.description==="string"?{description:$.description}:{}}}if(O_($,["type","path","ref","fields"],["type","path","ref","fields"]),typeof $.type!=="string"||!C_.test($.type)||typeof $.path!=="string"||!["{id}.md","**/{id}.md"].includes($.path)||typeof $.ref!=="string"||!$.ref.endsWith("/{id}")||!D2($.ref.replace("{id}","example")))bD("Unsupported record type, path or reference pattern");let Q=dZ($.fields),J=Q.find((W)=>W.name==="id"),X=Q.find((W)=>W.name==="type");if(!J||J.kind!=="string"||J.many||J.nullable||!X||X.kind!=="const"||X.value!==$.type||X.nullable)bD("Schema requires string id and matching constant type");return{type:$.type,path:$.path,ref:$.ref,fields:Q}}function cZ(D,Z,$){let Q=Z.split("/");if(Q.some((_)=>!_||_==="."||_===".."||!/^[a-zA-Z0-9_.-]+$/.test(_)))bD("Record path does not match its schema");if(!D.naming){let _=Q.at(-1),M=_?.endsWith(".md")?_.slice(0,-3):void 0;if(!M||!pZ.test(M)||D.path==="{id}.md"&&Q.length!==1)bD("Record path does not match its schema");if($&&(typeof $.id!=="string"||$.id!==M))bD("Invalid stable record identity");return D.ref.replace("{id}",M)}let J=D.naming.folder.slice(D.naming.collection.length+1),{names:X,pattern:W}=T_(J),G=W.exec(Q.slice(0,-1).join("/"));if(!G)bD("Record path does not match its schema");let Y=Object.fromEntries(X.map((_,M)=>[_,G[M+1]])),B=Q.at(-1),K=B?.endsWith(".md")?B.slice(0,-3):void 0;if(!K)bD("Record path does not match its schema");let H=[...D.naming.filename.matchAll(/<([^>]+)>/g)].map((_)=>_[1]),z=(_)=>_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),V=[],L="",N=0;for(let _ of D.naming.filename.matchAll(/<([^>]+)>/g)){L+=z(D.naming.filename.slice(N,_.index));let M=_[1],O=D.fields.find((j)=>j.name===M);if($&&O&&a8(O)){if(P2({[M]:$[M]},[O]),!pZ.test(String($[M])))bD("Invalid filename identity field");Y[M]=String($[M]),L+=z(Y[M])}else V.push(M),L+="([a-zA-Z0-9][a-zA-Z0-9_-]*)";N=_.index+_[0].length}L+=z(D.naming.filename.slice(N));let U=new RegExp(`^${L}$`).exec(K);if(!U)bD("Record identity fields do not match its filename");for(let[_,M]of V.entries())Y[M]=U[_+1];if(!$&&H.length>1){if(D.ref===`${D.naming.collection}/${D.naming.filename}`)return`${D.naming.collection}/${K}`;return}for(let _ of X){let M=D.fields.find((O)=>O.name===_);if($&&M&&a8(M)){if(P2({[_]:$[_]},[M]),String($[_])!==Y[_])bD("Record identity field does not match its folder")}}let F=D.ref.replace(/<([^>]+)>/g,(_,M)=>Y[M]);if(!D2(F))bD("Invalid stable record identity");return F}function A_(D,Z){let $=P_.get(D);if(!$){if(!D.naming)$=(Q)=>{let J=Q.split("/"),X=J.at(-1),W=X?.endsWith(".md")?X.slice(0,-3):void 0;if(J.some((G)=>!G||G==="."||G===".."||!/^[a-zA-Z0-9_.-]+$/.test(G))||!W||!pZ.test(W)||D.path==="{id}.md"&&J.length!==1)bD("Record path does not match its schema");return D.ref.replace("{id}",W)};else{let Q=D.naming.folder.slice(D.naming.collection.length+1),{names:J,pattern:X}=T_(Q),W=[],G="",Y=0;for(let H of D.naming.filename.matchAll(/<([^>]+)>/g))G+=WY(D.naming.filename.slice(Y,H.index)),W.push(H[1]),G+="([a-zA-Z0-9][a-zA-Z0-9_-]*)",Y=H.index+H[0].length;G+=WY(D.naming.filename.slice(Y));let B=new RegExp(`^${G}$`),K=W.length<=1||D.ref===`${D.naming.collection}/${D.naming.filename}`;$=(H)=>{let z=H.split("/");if(z.some((M)=>!M||M==="."||M===".."||!/^[a-zA-Z0-9_.-]+$/.test(M)))bD("Record path does not match its schema");let V=X.exec(z.slice(0,-1).join("/"));if(!V)bD("Record path does not match its schema");let L=Object.fromEntries(J.map((M,O)=>[M,V[O+1]])),N=z.at(-1),U=N?.endsWith(".md")?N.slice(0,-3):void 0,F=U?B.exec(U):void 0;if(!F)bD("Record identity fields do not match its filename");for(let[M,O]of W.entries())L[O]=F[M+1];if(!K)return;let _=D.ref.replace(/<([^>]+)>/g,(M,O)=>L[O]);if(!D2(_))bD("Invalid stable record identity");return _}}P_.set(D,$)}return $(Z)}function b1(D,Z,$){let Q=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(D);if(!Q)bD("Record requires YAML front matter");let J=j_(q_(Q[1]));if(J.type!==Z.type)bD("Record type does not match its schema");let X=cZ(Z,$,J);if(!X)bD("Record path requires its record fields");return{ref:X,fields:J,body:Q[2]}}function g3(D,Z){let $=new Set,Q=(J,X)=>{if(J===null||J===void 0)return;if(X.many){if(Array.isArray(J))for(let W of J)Q(W,{...X,many:!1})}else if(X.kind==="link"){let W=a6(J);if(W)$.add(W.ref)}else if(typeof J==="object"&&!Array.isArray(J)){if(X.kind==="object")for(let W of X.fields)Q(J[W.name],W);if(X.kind==="map")for(let W of Object.values(J))Q(W,X.value)}};for(let J of Z)Q(D[J.name],J);return[...$]}var cm="[a-zA-Z0-9][a-zA-Z0-9_-]*",WY=(D)=>D.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),C_,pZ,P_;var m0=N0(()=>{o6();ZY();l0();E4();E4();C_=/^[a-zA-Z][a-zA-Z0-9_-]*$/,pZ=/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;P_=new WeakMap});import{createHash as sm}from"node:crypto";function a2(D){return`record-v1:${sm("sha256").update(D).digest("hex")}`}var w4=()=>{};import{posix as B5}from"node:path";async function lZ(D,Z,$,Q={}){if(!tB($)||!$.length)throw new e("Managed data roots required");let J=(M)=>$.some((O)=>O==="."||M===O||M.startsWith(`${O}/`)),X=D.filter((M)=>J(M.path)),W=(M)=>M.split("/").some((O)=>["routines",".git"].includes(O)),G=new Map,Y=new Map;for(let M of X){if(W(M.path))continue;if(M.path.split("/").some((O)=>!/^[a-zA-Z0-9_.-]+$/.test(O)||[".",".."].includes(O)))throw new e("Unsupported data path");if(M.mode!=="100644")throw new e("Symlinks, submodules and executable data are unsupported")}let B=X.filter((M)=>!W(M.path)&&B5.basename(M.path)==="_schema.yaml"),K=Array(B.length),H=0,z=async()=>{while(!0){let M=H++,O=B[M];if(!O)return;try{K[M]=GY(I_.decode(await Z(O.oid)),B5.dirname(O.path))}catch(j){YY(j,O.path)}}};await Promise.all(Array.from({length:Math.min(Q.readConcurrency??1,B.length)},z));for(let[M,O]of B.entries())G.set(B5.dirname(O.path),K[M]),Y.set(O.path,O.oid);if(!G.size)throw new e("No collection schemas in managed data roots");let V=new Map,L=[],N=new Map,U=async(M)=>{let O=N.get(M.entry.path);if(O)return O;let j=await Z(M.entry.oid),q;Q.observeRecordParse?.(M.entry.path);try{q=b1(I_.decode(j),M.schema,M.relativePath)}catch(C){return YY(C,M.entry.path)}let R={bytes:j,record:q};return N.set(M.entry.path,R),R};for(let M of X){if(W(M.path)||!M.path.endsWith(".md"))continue;let O=B5.dirname(M.path);while(!G.has(O)&&O!==".")O=B5.dirname(O);let j=G.get(O);if(!j)throw new e("Markdown record has no collection schema");let q=B5.relative(O,M.path),R=A_(j,q),C={entry:M,schema:j,collectionPath:O,relativePath:q};if(!R){L.push(C);continue}if(V.has(R))throw new e("Duplicate stable record reference");V.set(R,C)}for(let M of L){let{record:O}=await U(M);if(V.has(O.ref))throw new e("Duplicate stable record reference");V.set(O.ref,M)}let F=new Map([...V].map(([M,O])=>[M,O.schema.type])),_=new Map([...V].map(([M,O])=>[M,O.entry.path]));return{async snapshot(M,O,j,q=!1,R={}){let C=new Map,T=M;if(q)T=[...V.keys()];if(O!==void 0){if(!G.has(O))throw new e("Collection schema unavailable");T=[...V].filter(([,m])=>m.collectionPath===O).map(([m])=>m)}let w=Array(T.length),y=0,E=async()=>{while(!0){let m=y++,h=T[m];if(h===void 0)return;let f=V.get(h);if(!f){if(R.allowMissing)continue;throw new e("Record is missing or outside the named repository")}let{bytes:c,record:d}=await U(f);if(d.ref!==h)throw new e("Record identity changed during capture");w[m]={...d,schema:f.schema,bytes:c,path:f.entry.path,collectionPath:f.collectionPath,version:a2(c)}}},k=Math.min(R.readConcurrency??1,T.length);await Promise.all(Array.from({length:k},E));for(let m=0;m<T.length;m++){let h=w[m];if(h)C.set(T[m],h)}if(R.validateFields!==!1)for(let m of C.values())try{P2(m.fields,m.schema.fields,(h,f)=>V.get(h)?.schema.type??(R.allowMissingLinkTargets?f[0]:void 0))}catch(h){YY(h,m.path)}let b=[];if(j?.size)for(let[m,h]of V){if(j.has(m))continue;let{record:f}=await U(h);for(let c of g3(f.fields,h.schema.fields))if(j.has(c))b.push({from:m,to:c})}return{records:C,schemas:G,schemaVersions:Y,incomingReferences:b,types:F,paths:_}}}}var I_,YY=(D,Z)=>{if(D instanceof e)throw new e(D.message,D.path??Z);throw D};var BY=N0(()=>{Y0();m0();w4();I_=new TextDecoder("utf-8",{fatal:!0})});c0();import{createHash as Bj,randomBytes as kK}from"node:crypto";import{execFile as Hj}from"node:child_process";import{createServer as Kj}from"node:http";import{createInterface as zj}from"node:readline/promises";var a5=(D,Z=[])=>D.name==="up"||Z.includes("vim")&&D.name==="k"||Z.includes("emacs")&&D.ctrl&&D.name==="p",M7=(D,Z=[])=>D.name==="down"||Z.includes("vim")&&D.name==="j"||Z.includes("emacs")&&D.ctrl&&D.name==="n";var QJ=(D)=>D.name==="backspace";var JJ=(D)=>"1234567890".includes(D.name),XJ=(D)=>D.name==="enter"||D.name==="return";class WJ extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(D){super();this.cause=D?.cause}}class GJ extends Error{name="CancelPromptError";message="Prompt was canceled"}class C7 extends Error{name="ExitPromptError"}class YJ extends Error{name="HookError"}class o5 extends Error{name="ValidationError"}import{AsyncResource as gP}from"node:async_hooks";import{AsyncLocalStorage as bP,AsyncResource as kP}from"node:async_hooks";var eB=new bP;function yP(D){return{rl:D,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function DH(D,Z){let $=yP(D);return eB.run($,()=>{function Q(J){$.handleChange=()=>{$.index=0,J()},$.handleChange()}return Z(Q)})}function n3(){let D=eB.getStore();if(!D)throw new YJ("[Inquirer] Hook functions can only be called from within a prompt");return D}function BJ(){return n3().rl}function HJ(D){let Z=(...$)=>{let Q=n3(),J=!1,X=Q.handleChange;Q.handleChange=()=>{J=!0};let W=D(...$);if(J)X();return Q.handleChange=X,W};return kP.bind(Z)}function e1(D){let Z=n3(),{index:$}=Z,Q={get(){return Z.hooks[$]},set(X){Z.hooks[$]=X},initialized:$ in Z.hooks},J=D(Q);return Z.index++,J}function $H(){n3().handleChange()}var i3={queue(D){let Z=n3(),{index:$}=Z;Z.hooksEffect.push(()=>{Z.hooksCleanup[$]?.();let Q=D(BJ());if(Q!=null&&typeof Q!=="function")throw new o5("useEffect return value must be a cleanup function or nothing.");Z.hooksCleanup[$]=Q})},run(){let D=n3();HJ(()=>{D.hooksEffect.forEach((Z)=>{Z()}),D.hooksEffect.length=0})()},clearAll(){let D=n3();D.hooksCleanup.forEach((Z)=>{Z?.()}),D.hooksEffect.length=0,D.hooksCleanup.length=0}};function y8(D){return e1((Z)=>{let $=gP.bind(function J(X){if(Z.get()!==X)Z.set(X),$H()});if(Z.initialized)return[Z.get(),$];let Q=typeof D==="function"?D():D;return Z.set(Q),[Q,$]})}function a3(D,Z){e1(($)=>{let Q=$.get();if(!Array.isArray(Q)||Z.some((X,W)=>!Object.is(X,Q[W])))i3.queue(D);$.set(Z)})}var I0=H8(O7(),1);import K8 from"node:process";function mP(){if(K8.platform!=="win32")return K8.env.TERM!=="linux";return Boolean(K8.env.WT_SESSION)||Boolean(K8.env.TERMINUS_SUBLIME)||K8.env.ConEmuTask==="{cmd::Cmder}"||K8.env.TERM_PROGRAM==="Terminus-Sublime"||K8.env.TERM_PROGRAM==="vscode"||K8.env.TERM==="xterm-256color"||K8.env.TERM==="alacritty"||K8.env.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var QH={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"█",squareDarkShade:"▓",squareMediumShade:"▒",squareLightShade:"░",squareTop:"▀",squareBottom:"▄",squareLeft:"▌",squareRight:"▐",squareCenter:"■",bullet:"●",dot:"․",ellipsis:"…",pointerSmall:"›",triangleUp:"▲",triangleUpSmall:"▴",triangleDown:"▼",triangleDownSmall:"▾",triangleLeftSmall:"◂",triangleRightSmall:"▸",home:"⌂",heart:"♥",musicNote:"♪",musicNoteBeamed:"♫",arrowUp:"↑",arrowDown:"↓",arrowLeft:"←",arrowRight:"→",arrowLeftRight:"↔",arrowUpDown:"↕",almostEqual:"≈",notEqual:"≠",lessOrEqual:"≤",greaterOrEqual:"≥",identical:"≡",infinity:"∞",subscriptZero:"₀",subscriptOne:"₁",subscriptTwo:"₂",subscriptThree:"₃",subscriptFour:"₄",subscriptFive:"₅",subscriptSix:"₆",subscriptSeven:"₇",subscriptEight:"₈",subscriptNine:"₉",oneHalf:"½",oneThird:"⅓",oneQuarter:"¼",oneFifth:"⅕",oneSixth:"⅙",oneEighth:"⅛",twoThirds:"⅔",twoFifths:"⅖",threeQuarters:"¾",threeFifths:"⅗",threeEighths:"⅜",fourFifths:"⅘",fiveSixths:"⅚",fiveEighths:"⅝",sevenEighths:"⅞",line:"─",lineBold:"━",lineDouble:"═",lineDashed0:"┄",lineDashed1:"┅",lineDashed2:"┈",lineDashed3:"┉",lineDashed4:"╌",lineDashed5:"╍",lineDashed6:"╴",lineDashed7:"╶",lineDashed8:"╸",lineDashed9:"╺",lineDashed10:"╼",lineDashed11:"╾",lineDashed12:"−",lineDashed13:"–",lineDashed14:"‐",lineDashed15:"⁃",lineVertical:"│",lineVerticalBold:"┃",lineVerticalDouble:"║",lineVerticalDashed0:"┆",lineVerticalDashed1:"┇",lineVerticalDashed2:"┊",lineVerticalDashed3:"┋",lineVerticalDashed4:"╎",lineVerticalDashed5:"╏",lineVerticalDashed6:"╵",lineVerticalDashed7:"╷",lineVerticalDashed8:"╹",lineVerticalDashed9:"╻",lineVerticalDashed10:"╽",lineVerticalDashed11:"╿",lineDownLeft:"┐",lineDownLeftArc:"╮",lineDownBoldLeftBold:"┓",lineDownBoldLeft:"┒",lineDownLeftBold:"┑",lineDownDoubleLeftDouble:"╗",lineDownDoubleLeft:"╖",lineDownLeftDouble:"╕",lineDownRight:"┌",lineDownRightArc:"╭",lineDownBoldRightBold:"┏",lineDownBoldRight:"┎",lineDownRightBold:"┍",lineDownDoubleRightDouble:"╔",lineDownDoubleRight:"╓",lineDownRightDouble:"╒",lineUpLeft:"┘",lineUpLeftArc:"╯",lineUpBoldLeftBold:"┛",lineUpBoldLeft:"┚",lineUpLeftBold:"┙",lineUpDoubleLeftDouble:"╝",lineUpDoubleLeft:"╜",lineUpLeftDouble:"╛",lineUpRight:"└",lineUpRightArc:"╰",lineUpBoldRightBold:"┗",lineUpBoldRight:"┖",lineUpRightBold:"┕",lineUpDoubleRightDouble:"╚",lineUpDoubleRight:"╙",lineUpRightDouble:"╘",lineUpDownLeft:"┤",lineUpBoldDownBoldLeftBold:"┫",lineUpBoldDownBoldLeft:"┨",lineUpDownLeftBold:"┥",lineUpBoldDownLeftBold:"┩",lineUpDownBoldLeftBold:"┪",lineUpDownBoldLeft:"┧",lineUpBoldDownLeft:"┦",lineUpDoubleDownDoubleLeftDouble:"╣",lineUpDoubleDownDoubleLeft:"╢",lineUpDownLeftDouble:"╡",lineUpDownRight:"├",lineUpBoldDownBoldRightBold:"┣",lineUpBoldDownBoldRight:"┠",lineUpDownRightBold:"┝",lineUpBoldDownRightBold:"┡",lineUpDownBoldRightBold:"┢",lineUpDownBoldRight:"┟",lineUpBoldDownRight:"┞",lineUpDoubleDownDoubleRightDouble:"╠",lineUpDoubleDownDoubleRight:"╟",lineUpDownRightDouble:"╞",lineDownLeftRight:"┬",lineDownBoldLeftBoldRightBold:"┳",lineDownLeftBoldRightBold:"┯",lineDownBoldLeftRight:"┰",lineDownBoldLeftBoldRight:"┱",lineDownBoldLeftRightBold:"┲",lineDownLeftRightBold:"┮",lineDownLeftBoldRight:"┭",lineDownDoubleLeftDoubleRightDouble:"╦",lineDownDoubleLeftRight:"╥",lineDownLeftDoubleRightDouble:"╤",lineUpLeftRight:"┴",lineUpBoldLeftBoldRightBold:"┻",lineUpLeftBoldRightBold:"┷",lineUpBoldLeftRight:"┸",lineUpBoldLeftBoldRight:"┹",lineUpBoldLeftRightBold:"┺",lineUpLeftRightBold:"┶",lineUpLeftBoldRight:"┵",lineUpDoubleLeftDoubleRightDouble:"╩",lineUpDoubleLeftRight:"╨",lineUpLeftDoubleRightDouble:"╧",lineUpDownLeftRight:"┼",lineUpBoldDownBoldLeftBoldRightBold:"╋",lineUpDownBoldLeftBoldRightBold:"╈",lineUpBoldDownLeftBoldRightBold:"╇",lineUpBoldDownBoldLeftRightBold:"╊",lineUpBoldDownBoldLeftBoldRight:"╉",lineUpBoldDownLeftRight:"╀",lineUpDownBoldLeftRight:"╁",lineUpDownLeftBoldRight:"┽",lineUpDownLeftRightBold:"┾",lineUpBoldDownBoldLeftRight:"╂",lineUpDownLeftBoldRightBold:"┿",lineUpBoldDownLeftBoldRight:"╃",lineUpBoldDownLeftRightBold:"╄",lineUpDownBoldLeftBoldRight:"╅",lineUpDownBoldLeftRightBold:"╆",lineUpDoubleDownDoubleLeftDoubleRightDouble:"╬",lineUpDoubleDownDoubleLeftRight:"╫",lineUpDownLeftDoubleRightDouble:"╪",lineCross:"╳",lineBackslash:"╲",lineSlash:"╱"},JH={tick:"✔",info:"ℹ",warning:"⚠",cross:"✘",squareSmall:"◻",squareSmallFilled:"◼",circle:"◯",circleFilled:"◉",circleDotted:"◌",circleDouble:"◎",circleCircle:"ⓞ",circleCross:"ⓧ",circlePipe:"Ⓘ",radioOn:"◉",radioOff:"◯",checkboxOn:"☒",checkboxOff:"☐",checkboxCircleOn:"ⓧ",checkboxCircleOff:"Ⓘ",pointer:"❯",triangleUpOutline:"△",triangleLeft:"◀",triangleRight:"▶",lozenge:"◆",lozengeOutline:"◇",hamburger:"☰",smiley:"㋡",mustache:"෴",star:"★",play:"▶",nodejs:"⬢",oneSeventh:"⅐",oneNinth:"⅑",oneTenth:"⅒"},vP={tick:"√",info:"i",warning:"‼",cross:"×",squareSmall:"□",squareSmallFilled:"■",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(○)",circleCross:"(×)",circlePipe:"(│)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[×]",checkboxOff:"[ ]",checkboxCircleOn:"(×)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"∆",triangleLeft:"◄",triangleRight:"►",lozenge:"♦",lozengeOutline:"◊",hamburger:"≡",smiley:"☺",mustache:"┌─┐",star:"✶",play:"►",nodejs:"♦",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},uP={...QH,...JH},dP={...QH,...vP},pP=mP(),cP=pP?uP:dP,D6=cP,Ps=Object.entries(JH);var XH={prefix:{idle:I0.default.blue("?"),done:I0.default.green(D6.tick)},spinner:{interval:80,frames:["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"].map((D)=>I0.default.yellow(D))},style:{answer:I0.default.cyan,message:I0.default.bold,error:(D)=>I0.default.red(`> ${D}`),defaultAnswer:(D)=>I0.default.dim(`(${D})`),help:I0.default.dim,highlight:I0.default.cyan,key:(D)=>I0.default.cyan(I0.default.bold(`<${D}>`))}};function WH(D){if(typeof D!=="object"||D===null)return!1;let Z=D;while(Object.getPrototypeOf(Z)!==null)Z=Object.getPrototypeOf(Z);return Object.getPrototypeOf(D)===Z}function GH(...D){let Z={};for(let $ of D)for(let[Q,J]of Object.entries($)){let X=Z[Q];Z[Q]=WH(X)&&WH(J)?GH(X,J):J}return Z}function r5(...D){let Z=[XH,...D.filter(($)=>$!=null)];return GH(...Z)}function KJ({status:D="idle",theme:Z}){let[$,Q]=y8(!1),[J,X]=y8(0),{prefix:W,spinner:G}=r5(Z);if(a3(()=>{if(D==="loading"){let B,K=-1,H=setTimeout(()=>{Q(!0),B=setInterval(()=>{K=K+1,X(K%G.frames.length)},G.interval)},300);return()=>{clearTimeout(H),clearInterval(B)}}else Q(!1)},[D]),$)return G.frames[J];return typeof W==="string"?W:W[D==="loading"?"idle":D]??W.idle}function t5(D,Z){return e1(($)=>{let Q=$.get();if(!Q||Q.dependencies.length!==Z.length||Q.dependencies.some((J,X)=>J!==Z[X])){let J=D();return $.set({value:J,dependencies:Z}),J}return Q.value})}function o3(D){return y8({current:D})[0]}function zJ(D){let Z=o3(D);Z.current=D,a3(($)=>{let Q=!1,J=HJ((X,W)=>{if(Q)return;Z.current(W,$)});return $.input.on("keypress",J),()=>{Q=!0,$.input.removeListener("keypress",J)}},[])}var gH=H8(BH(),1),fH=H8(yH(),1);function $9(D,Z){return D.split(`
|
|
148
148
|
`).flatMap(($)=>fH.default($,Z,{trim:!1,hard:!0}).split(`
|
|
149
149
|
`).map((Q)=>Q.trimEnd())).join(`
|
|
150
150
|
`)}function j7(){return gH.default({defaultWidth:80,output:BJ().output})}function zT({active:D,renderedItems:Z,pageSize:$,loop:Q}){let J=o3({lastPointer:D,lastActive:void 0}),{lastPointer:X,lastActive:W}=J.current,G=Math.floor($/2),Y=Z.reduce((H,z)=>H+z.length,0),B=Z.slice(0,D).reduce((H,z)=>H+z.length,0),K=B;if(Y>$)if(Q){if(K=X,W!=null&&W<D&&D-W<$)K=Math.min(G,Math.abs(D-W)===1?Math.min(X+(Z[W]?.length??0),Math.max(B,X)):X+D-W)}else{let H=Z.slice(D).reduce((z,V)=>z+V.length,0);K=H<$-G?$-H:Math.min(B,G)}return J.current.lastPointer=K,J.current.lastActive=D,K}function OJ({items:D,active:Z,renderItem:$,pageSize:Q,loop:J=!0}){let X=j7(),W=(F)=>(F%D.length+D.length)%D.length,G=D.map((F,_)=>{if(F==null)return[];return $9($({item:F,index:_,isActive:_===Z}),X).split(`
|
|
@@ -227,7 +227,7 @@ To try again, run:
|
|
|
227
227
|
Try again before pushing your data.`}let J;try{let W=await(Z.request??((G,Y)=>$2(G,Y,{...Z,store:Q})))(`/workspaces/${D}/repositories`,{signal:AbortSignal.timeout(30000)});if(!W.ok)throw Error();J=F9(await W.json())}catch{return`We couldn’t load this data repository’s settings.
|
|
228
228
|
Try again before pushing your data.`}try{let X=Q.read();if(X?.activeWorkspace?.slug!==D)return;Q.write({...X,activeWorkspace:{...X.activeWorkspace,repositories:J}})}catch{return`We couldn’t save your workspace settings.
|
|
229
229
|
Try again before pushing your data.`}}async function mK(D,Z,$="os login"){if(!D.length)throw new OD("denied","Your OS account has no current workspace access. No new selection was stored.");if(D.length===1)return{...D[0]};if(!Z&&!process.stdin.isTTY)throw Error(`Choose your active workspace by running ${$} in an interactive terminal.`);if(!Z&&process.stderr.isTTY&&process.env.TERM!=="dumb")try{return await eH(D)}catch(X){if(X instanceof Error&&X.name==="ExitPromptError")throw Error("Workspace selection cancelled. No new selection was stored.");throw X}let Q=Z?void 0:zj({input:process.stdin,output:process.stderr}),J=["Choose your active workspace:",...D.map((X,W)=>` ${W+1}. ${X.name} (${X.slug})`),"Workspace number: "].join(`
|
|
230
|
-
`);try{let X=Z??((W)=>Q.question(W));while(!0){let W=(await X(J)).trim(),G=/^[1-9][0-9]*$/.test(W)?D[Number(W)-1]:void 0;if(G)return{...G}}}finally{Q?.close()}}async function M0(D={}){let Z=D.fetch??fetch,$=D.origin??B0,Q=D.store??o2(),J=await s0($,Z),X=await V8(J,Q,Z,void 0,D.refreshSession),W=await _9(J,X.accessToken,Z);if(!X.activeWorkspace)return W;return{...W,activeWorkspace:WX(X,W)}}function WX(D,Z){let $=_6(D),Q=Z.workspaces.find((J)=>J.slug===$.slug);if(!Q)throw new OD("denied",`You no longer have access to the active workspace ${$.slug}. Run os login to choose a workspace.`);return{...Q}}function _6(D,Z){let $=D.activeWorkspace;if(!J3($))throw new UD("This OS login has no active workspace. Run os login to choose one.");if(Z!==void 0&&Z!==$.slug)throw new UD(`The active workspace is ${$.slug}. Run os login to choose another workspace.`);return{...$}}async function U8(D={}){let Z=D.store??o2(),$=(Y,B)=>(D.fetch??fetch)(Y,{...B,...D.signal?{signal:D.signal}:{},redirect:"error",credentials:"omit"}),Q=await s0(B0,$),J=await V8(Q,Z,$),X=await _9(Q,J.accessToken,$),W=WX(J,X);return{workspace:W,member:X,request:async(Y,B={})=>{let K=/^\/workspaces\/([^/]+)\//.exec(Y)?.[1];if(K)_6(J,K);return N9(Y,G(B),{...D,store:Z},{config:Q,session:J})},filesRequest:(Y,B={})=>J1(W.slug,Y,G(B),{...D,store:Z}),inboxRequest:(Y,B={})=>p7(W.slug,Y,G(B),{...D,store:Z})};function G(Y){return{...Y,signal:D.signal&&Y.signal?AbortSignal.any([D.signal,Y.signal]):D.signal??Y.signal}}}async function p7(D,Z,$={},Q={}){let J=`https://${D}.oddington.ai`,X=new URL(Z,J),W=new Headers($.headers),G=!1;if(Z==="/api/inbox"&&typeof $.body==="string")try{let{operation:V}=L6(JSON.parse($.body));G=V==="items.list"||V==="items.read"}catch{}if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(D)||D.length>63||["auth","www","api","os"].includes(D)||X.origin!==J||X.username||X.password||X.search||X.hash||!(G||/^\/api\/inbox\/(check|publish|resolve|files)$/.test(Z))||$.method!=="POST"||W.has("authorization")||W.has("x-os-run")||W.has("x-os-workspace")||W.has("transfer-encoding"))throw Error("Invalid Inbox endpoint");let Y=Q.fetch??fetch,B=async(V,L)=>{let N=await Y(V,{...L,redirect:"error",credentials:"omit",signal:$.signal??AbortSignal.timeout(30000)});if(N.redirected||N.status>=300&&N.status<400)throw Error("OS redirected an Inbox request");return N},K=await s0(B0,B),H=await V8(K,Q.store??o2(),B);_6(H,D);let z=W;return z.set("authorization",`Bearer ${H.accessToken}`),B(X,{...$,headers:z,redirect:"error",cache:"no-store"})}async function J1(D,Z,$={},Q={}){let J=new URL(Z,`https://${D}.oddington.ai`),X=$.method??"GET",W=/^\/api\/files\/([^/]+)(?:\/(upload\/(check|reconcile)))?$/.exec(J.pathname),G=W?.[1],Y=new Headers($.headers),B=/^\/api\/files\/([^/]+)\/enrichments$/.exec(J.pathname),K=X==="POST"&&Y.get("content-type")==="application/json"&&(J.pathname==="/api/files"||B&&uD.test(B[1]));if(K){if(typeof $.body!=="string"||Buffer.byteLength($.body)>65536||Y.has("transfer-encoding"))throw new p("invalid_input",400);try{JSON.parse($.body)}catch{throw new p("invalid_input",400)}}let H=X==="POST"&&B&&uD.test(B[1])&&!K;if(H){let C=()=>new p("invalid_input",400,!1,{reason:"invalid_enrichment_request"}),T=Y.get("x-os-enrichment");if(Y.get("content-type")!=="application/octet-stream"||Y.has("transfer-encoding")||!($.body instanceof Uint8Array||$.body instanceof ArrayBuffer)||!T||T.length>4096)throw C();let w;try{w=D1(JSON.parse(decodeURIComponent(T)),16777216)}catch(y){if(y instanceof p)throw y;throw C()}if(w.size!==$.body.byteLength)throw new p("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:w.size,receivedBytes:$.body.byteLength})}let z=/^\/api\/files\/([0-9a-f-]{36})\/(?:content|enrichments\/([^/]+)\/content)$/.exec(J.pathname),V=X==="GET"&&z&&uD.test(z[1]);if(V&&z?.[2])try{V=f8(decodeURIComponent(z[2]))}catch{V=!1}let L=X==="POST"&&J.pathname==="/api/files"&&!K,N=X==="GET"&&J.pathname==="/api/files/preflight";if(N){let C=Y.get("x-os-file");if(!C||C.length>16384||$.body!==void 0&&$.body!==null)throw new p("invalid_input",400);try{let T=JSON.parse(decodeURIComponent(C));if(!T||typeof T!=="object"||Array.isArray(T)||Object.keys(T).sort().join(",")!=="metadata,sha256"||typeof T.sha256!=="string"||!/^[0-9a-f]{64}$/.test(T.sha256)||H0(T.metadata,j2).storage!=="remote")throw new p("invalid_input",400)}catch(T){if(T instanceof p)throw T;throw new p("invalid_input",400)}}let U=X==="POST"&&/^\/api\/files\/multipart\/(start|part|complete|acknowledge|abort)$/.exec(J.pathname);if(L||U){let C=new Headers($.headers),T=U?U[1]:void 0,w=L||T==="part";if(C.get("content-type")!==(w?"application/octet-stream":"application/json")||C.has("transfer-encoding")||(w?!($.body instanceof Uint8Array||$.body instanceof ArrayBuffer):typeof $.body!=="string")||!w&&Buffer.byteLength($.body)>131072||T&&T!=="start"&&!C.get("x-os-transfer")||T==="part"&&(!/^[1-9][0-9]*$/.test(C.get("x-os-part")??"")||$.body.byteLength>8388608))throw new p("invalid_input",400);try{if(L||T==="start"){let y=C.get("x-os-file");if(L&&(!y||y.length>16384))throw new p("invalid_input",400);let E=H0(JSON.parse(L?decodeURIComponent(y):$.body),L?16777216:j2);if(E.storage!=="remote"||L&&E.size!==$.body.byteLength)throw new p("invalid_input",400)}else if(!w)JSON.parse($.body)}catch(y){if(y instanceof p)throw y;throw new p("invalid_input",400)}}let F=/^\/api\/files\/([0-9a-f-]{36})\/upload\/multipart\/(start|part|complete|abort|enrichments\/[^/]+)$/.exec(J.pathname),_=X==="POST"&&F&&uD.test(F[1]);if(_){let C=new Headers($.headers),T=F[2]==="part"||F[2].startsWith("enrichments/");if(C.get("content-type")!==(T?"application/octet-stream":"application/json")||(T?!($.body instanceof ArrayBuffer):typeof $.body!=="string")||F[2]!=="start"&&!C.get("x-os-transfer")||F[2]==="part"&&!/^[1-9][0-9]*$/.test(C.get("x-os-part")??""))throw new p("invalid_input",400)}let M=X==="POST"&&J.pathname==="/api/data";if((Z.startsWith("/")?Z:Z.slice(J.origin.length))!==J.pathname||!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(D)||D.length>63||["auth","www","api","os"].includes(D)||J.origin!==`https://${D}.oddington.ai`||J.username||J.password||J.search||J.hash||!(X==="GET"&&J.pathname==="/api/files/context"||G&&uD.test(G)&&(X==="GET"&&!W?.[2]||X==="DELETE"&&!W?.[2]||X==="POST"&&!!W?.[2])||M||_||L||N||U||K||H||V)||!M&&!_&&!L&&!N&&!U&&!K&&!H&&$.body!==void 0&&$.body!==null)throw new p("invalid_input",400);let O=Q.fetch??fetch,j=async(C,T)=>{let w=await O(C,{...T,redirect:"error",credentials:"omit",signal:$.signal??AbortSignal.timeout(30000)});if(w.redirected||w.status>=300&&w.status<400)throw new p("unavailable",503,!0);return w},R=(Q.authentication?await Q.authentication(j):void 0)?.session??await V8(await s0(G6(),j),Q.store??o2(),j);return _6(R,D),Y.delete("x-os-run"),Y.set("authorization",`Bearer ${R.accessToken}`),Y.set("x-os-workspace",D),j(J,{...$,headers:Y,redirect:"error",cache:"no-store"})}class t2 extends Error{}class Q1 extends t2{}class C6 extends Error{constructor(){super("Could not reach the OS API.")}}async function $2(D,Z={},$={}){return N9(D,Z,$)}async function N9(D,Z,$,Q){let W=/^\/workspaces\/([^/]+)\/repositories\/([^/]+)\/context$/.exec(D),G=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/(deployment-context|deployments)(?:/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})(?:/(diagnostics|source)(?:/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}))?)?)?$").exec(D),Y=G&&(G[1]==="deployment-context"?!G[2]&&(Z.method??"GET")==="POST":G[3]==="source"?(Z.method??"GET")==="PUT":G[2]?(Z.method??"GET")==="GET"&&Z.body==null:(Z.method??"GET")==="POST"),B=!1;try{B=!!W&&D===k7(W[1],decodeURIComponent(W[2]))}catch{}let K=new Headers(Z.headers);if(K.has("x-os-workspace"))throw new Q1("Invalid authenticated OS API endpoint");let H=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/connections\/use$/.test(D),z=D==="/api/cli/data/schema",V=/^\/workspaces\/[a-z0-9][a-z0-9-]*\/repositories$/.test(D),L=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/(?:snapshots|repositories\/([^/]+)\/snapshots\/([^/]+)(\/refresh)?)$/.exec(D),N=!!L&&(!L[1]||X2(L[1])&&X2(L[2])),U=!1;if(N){let n=Z.method??"GET";if(U=!L[1]?n==="GET"&&Z.body==null:L[3]?n==="POST"&&Z.body==null:["GET","DELETE"].includes(n)&&Z.body==null,L[1]&&!L[3]&&n==="PUT")try{let o=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=65536?JSON.parse(Z.body):void 0,A=o?.collections;U=["collections","bodies,collections"].includes(Object.keys(o).sort().join(","))&&(A==="@all"||Array.isArray(A)&&A.length>0&&new Set(A).size===A.length&&A.every((S)=>typeof S==="string"&&S.split("/").every((I)=>/^[a-zA-Z0-9_.-]+$/.test(I)&&![".","..",".git","routines"].includes(I))))&&(o.bodies===void 0||Array.isArray(o.bodies)&&new Set(o.bodies).size===o.bodies.length&&o.bodies.every((S)=>typeof S==="string"&&S.split("/").every((I)=>/^[a-zA-Z0-9_.-]+$/.test(I)&&![".","..",".git","routines"].includes(I))&&(A==="@all"||A.includes(S))))&&K.get("content-type")==="application/json"}catch{}}let F=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/repositories\/[a-z][a-z0-9-]{0,62}\/index$/.test(D),_=!1;if(V)try{let n=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=4096?JSON.parse(Z.body):void 0;K9(n),_=!0}catch{}let M=V&&(Z.method??"GET")==="GET"&&Z.body==null,O=!1;if(z)try{let n=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=8192?JSON.parse(Z.body):void 0;if(n&&Object.keys(n).sort().join(",")==="branch,remote,repository"&&eD(n.repository))O=y7({remote:n.remote,branch:n.branch}).remote===n.remote}catch{}let j=new RegExp("^/api/cli/local-routines/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/preparation(?:\\?repository=[a-z][a-z0-9-]{0,62})?$").test(D),q=new RegExp("^/api/cli/local-routines/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/renew$").test(D),C=j||q||new RegExp("^/api/cli/local-routines/[a-z0-9][a-z0-9-]{0,62}/(?:resolve|admit|check)$").test(D),T=j?(Z.method??"GET")==="GET"&&Z.body==null:q?Z.method==="POST"&&Z.body==null:Z.method==="POST",w=/^\/api\/cli\/remote-routines\/[a-z0-9][a-z0-9-]{0,62}\/runs$/.test(D),y=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/runs$").test(D),E=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/describe$").test(D),k=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?:/steps/[a-z0-9][a-z0-9-]{0,62})?$").test(D),b=w||y||E||!!k,m=w?Z.method==="POST":E?(Z.method??"GET")==="GET"&&Z.body==null:y?Z.method==="POST"||(Z.method??"GET")==="GET"&&Z.body==null:(Z.method??"GET")==="GET"&&Z.body==null;if(K.has("x-os-run")&&!j&&!q||H&&(Z.method!=="POST"||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding"))||G&&(!Y||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||G[3]==="diagnostics"&&G[4]||G[3]==="source"&&!G[4]&&Z.body!=null)||b&&(!m||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||!y&&!w&&K.has("content-length")&&K.get("content-length")!=="0")||C&&(!T||K.has("x-os-workspace")||K.has("transfer-encoding")||K.has("x-os-run")&&!j&&!q||(j||q)&&!/^[0-9a-f]{64}$/.test(K.get("x-os-run")??"")||(j||q)&&K.has("content-length")&&K.get("content-length")!=="0")||z&&(!O||Z.method!=="POST"||K.has("x-os-run")||K.has("x-os-workspace")||K.has("authorization")||K.has("transfer-encoding"))||V&&(!M&&(!_||Z.method!=="POST")||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding"))||N&&(!U||K.has("content-encoding")||K.has("content-length")||K.has("authorization")||K.has("x-os-run")||K.has("transfer-encoding"))||F&&(Z.method!=="POST"||Z.body!==void 0&&Z.body!==null||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||K.has("content-length"))||!N&&!F&&!V&&!z&&!H&&!G&&!b&&!C&&!B&&!new RegExp("^/workspaces/[a-z0-9][a-z0-9-]*/(?:files/storage|connections(?:\\?usable=true|/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?:/test|/grants/(?:user|runtime)/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|/repository-targets(?:/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})?)?|/dropbox/authorizations(?:/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/complete)?)?)$").test(D)||B&&((Z.method??"GET")!=="GET"||Z.body!==void 0&&Z.body!==null||K.has("x-os-run")||K.has("transfer-encoding")||K.has("content-length")&&K.get("content-length")!=="0"))throw new Q1("Invalid authenticated OS API endpoint");let h=new URL(D,e3);if(h.pathname+h.search!==D)throw new Q1("Invalid authenticated OS API endpoint");let f=$.fetch??fetch,c=async(n,o)=>{let A;try{Z.signal?.throwIfAborted(),A=await f(n,{...o,redirect:"error",...Z.signal?{signal:Z.signal}:{}}),Z.signal?.throwIfAborted()}catch(S){if(Z.signal?.aborted)throw S;throw new C6}if(A.redirected||A.status>=300&&A.status<400)throw new t2("OS redirected an OS API request");return A};Z.signal?.throwIfAborted();let d=typeof Q==="function"?await Q(c):Q,i=d?.session;if(!i){let n=$.store??o2();if(C){let o=n.read();if(!o)throw new UD;i=o.expiresAt>Date.now()+60000?o:await V8(d?.config??await s0($.origin??B0,c,!0),n,c,o)}else{let o=d?.config??await s0($.origin??B0,c,!0);i=await V8(o,n,c)}}let v=/^\/workspaces\/([^/]+)\/(?:snapshots|files\/storage|connections|repositories\/[^/]+\/(?:index|snapshots\/[^/]+)|(?:routines\/[^/]+\/)?runs|routines\/[^/]+\/describe)(?:[/?]|$)/.exec(D)?.[1];if(v)_6(i,v);Z.signal?.throwIfAborted();let l=new Headers(Z.headers);if(C||w)l.set("x-os-workspace",_6(i).slug);return l.set("authorization",`Bearer ${i.accessToken}`),c(h,{...Z,headers:l,credentials:"omit"})}function vK(D){let Z=D.store??o2(),$,Q,J,X=(W,G)=>J??=(async()=>{if($??=await s0(B0,W,!0),G.throwIfAborted(),!Q){let B=Z.read();if(!B)throw new UD;Q={...B}}let Y=Q;return Q=await V8($,{read(){throw Error("Unexpected command session acquisition")},delete(){throw Error("Unexpected command session deletion")},write(B){G.throwIfAborted();let K=Z.read();if(!K||K.accessToken!==Y.accessToken||K.refreshToken!==Y.refreshToken||K.expiresAt!==Y.expiresAt||K.tokenType!==Y.tokenType||K.activeWorkspace?.slug!==Y.activeWorkspace?.slug)throw new OD("denied");G.throwIfAborted(),Z.write(B)}},W,Y),G.throwIfAborted(),{config:$,session:Q}})().finally(()=>{J=void 0});return{request(W,G={}){let Y=G.signal?AbortSignal.any([D.signal,G.signal]):D.signal;return N9(W,{...G,signal:Y},D,(B)=>X(B,Y))},filesRequest(W,G,Y={}){let B=Y.signal?AbortSignal.any([D.signal,Y.signal]):D.signal;return J1(W,G,{...Y,signal:B},{store:Z,fetch:D.fetch,authentication:(K)=>X(K,B)})}}}async function GX(D){let Z=async(G,Y)=>{D.signal.throwIfAborted();let B=await D.fetch(G,{...Y,redirect:"error",signal:D.signal});if(D.signal.throwIfAborted(),B.redirected||B.status>=300&&B.status<400)throw new t2("OS redirected a launch request");return B},$=await s0(D.origin,Z,!0),Q=D.store.read();if(!Q)throw new UD;let J={...Q},X=await V8($,{read(){throw Error("Unexpected launch session read")},write(){},delete(){throw Error("Unexpected launch session deletion")}},Z,J,D.refreshSession),W=!1;return{session:{...X},identity:async(G)=>{let Y=await _9($,X.accessToken,G);return{...Y,activeWorkspace:WX(X,Y)}},request:(G,Y={})=>N9(G,Y,D,{config:$,session:X}),finish(){if(W)return;W=!0;let G=D.store.read();if(!G||G.accessToken!==J.accessToken||G.refreshToken!==J.refreshToken||G.expiresAt!==J.expiresAt||G.tokenType!==J.tokenType||G.activeWorkspace?.slug!==J.activeWorkspace?.slug)throw new OD("denied");if(X!==J)D.store.write(X)}}}async function uK(D={}){let Z=D.fetch??fetch,$=D.origin??B0,Q=D.store??o2(),J;try{J=Q.read()}catch{return Q.delete(),!1}if(!J)return Q.delete(),!1;try{let X=await s0($,Z),W=await V8(X,Q,Z,J);if(!(await Z(X.sessionEndpoint,{method:"DELETE",redirect:"error",headers:{authorization:`Bearer ${W.accessToken}`}})).ok)throw Error("Could not revoke the OS login")}finally{Q.delete()}return!0}async function s0(D,Z,$=!1){let Q=await Z(`${D}/api/cli/oauth-configuration`,{redirect:"error"});if(Q.redirected||Q.status>=300&&Q.status<400)throw Error("OS redirected CLI login configuration");let J=await Q.json().catch(()=>{return});if(!Q.ok)throw Error(BX(J,"OS login is unavailable"));try{return _j(J,D)}catch(X){if($)throw new t2("OS returned invalid CLI login configuration");throw X}}async function Mj(D,Z,$,Q){let J=await Q(D.tokenEndpoint,{method:"POST",redirect:"error",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:D.clientId,code:Z,code_verifier:$,redirect_uri:D.redirectUri})}),X=await J.json().catch(()=>{return});if(!J.ok)throw Error(BX(X,"OS login failed"));return yK(X)}async function V8(D,Z,$,Q,J=!1){let X=Q??Z.read();if(!X)throw new UD;if(!J&&X.expiresAt>Date.now()+60000)return X;let W=await $(D.tokenEndpoint,{method:"POST",redirect:"error",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",client_id:D.clientId,refresh_token:X.refreshToken})}),G=await W.json().catch(()=>{return});if([400,401,403].includes(W.status)&&M6(G)?.error==="invalid_grant")throw new UD;if(!W.ok)throw new OD([400,401,403].includes(W.status)?"denied":"unavailable",BX(G,"OS could not verify your account. Try again later."));let Y={...yK(G,X.refreshToken),...X.activeWorkspace?{activeWorkspace:{...X.activeWorkspace}}:{}};if(!Q){let B=Z.read();if(!B||B.accessToken!==X.accessToken||B.refreshToken!==X.refreshToken||B.expiresAt!==X.expiresAt||B.tokenType!==X.tokenType||B.activeWorkspace?.slug!==X.activeWorkspace?.slug)throw new OD("denied")}return Z.write(Y),Y}class OD extends Error{kind;constructor(D,Z="OS account unavailable"){super(Z);this.kind=D}}class UD extends OD{constructor(D=q2){super("denied",D)}}async function _9(D,Z,$){let Q=await $(D.sessionEndpoint,{redirect:"error",headers:{authorization:`Bearer ${Z}`}});if(Q.status===401)throw new UD;if(!Q.ok)throw new OD([401,403].includes(Q.status)?"denied":Q.status===409?"invalid":"unavailable");let J=await Q.text(),X;try{X=JSON.parse(J)}catch{throw new OD("invalid")}let W=M6(X);if(!W||typeof W.id!=="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(W.id)||typeof W.email!=="string"||!Array.isArray(W.workspaces))throw new OD("invalid");if(W.name!==void 0&&typeof W.name!=="string")throw new OD("invalid");let G=W.workspaces.map((Y)=>{let B=M6(Y);if(!J3(B))throw new OD("invalid");return{slug:B.slug,name:B.name}});return{id:W.id.toLowerCase(),email:W.email,...W.name?{name:W.name}:{},workspaces:G}}function Cj(D,Z){let $=new URL(D),Q;return{result:new Promise((X,W)=>{let G=setTimeout(()=>{Q?.close(),W(Error("Timed out waiting for authorization. Run os login to try again."))},Vj);Q=Kj((Y,B)=>{let K=new URL(Y.url??"/",$);if(K.pathname!==$.pathname){B.writeHead(404).end("Not found");return}if(K.searchParams.get("state")!==Z){B.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),B.end("OS login received an invalid authorization state");return}try{let H=Nj(K,Z);B.writeHead(200,{"content-type":"text/html; charset=utf-8"}),B.end(bK("authorized")),clearTimeout(G),Q?.close(),X(H)}catch(H){let z=K.searchParams.get("error")==="access_denied";B.writeHead(z?200:400,{"content-type":"text/html; charset=utf-8"}),B.end(bK(z?"cancelled":"error")),clearTimeout(G),Q?.close(),W(H)}}),Q.on("error",(Y)=>{clearTimeout(G),W(Error(`Could not start the OS login callback: ${Y.message}`))}),Q.listen(Number($.port),$.hostname)})}}function bK(D){let Z=D==="authorized"?{title:"Authorization received",message:"You can close this tab and go back to your terminal.",symbol:"✓",success:!0}:D==="cancelled"?{title:"OS CLI was not authorized",message:"No new login was stored on this computer. You can close this tab.",symbol:"×",success:!1}:{title:"Unable to authorize the OS CLI",message:"Run os login again in your terminal.",symbol:"×",success:!1};return`<!doctype html>
|
|
230
|
+
`);try{let X=Z??((W)=>Q.question(W));while(!0){let W=(await X(J)).trim(),G=/^[1-9][0-9]*$/.test(W)?D[Number(W)-1]:void 0;if(G)return{...G}}}finally{Q?.close()}}async function M0(D={}){let Z=D.fetch??fetch,$=D.origin??B0,Q=D.store??o2(),J=await s0($,Z),X=await V8(J,Q,Z,void 0,D.refreshSession),W=await _9(J,X.accessToken,Z);if(!X.activeWorkspace)return W;return{...W,activeWorkspace:WX(X,W)}}function WX(D,Z){let $=_6(D),Q=Z.workspaces.find((J)=>J.slug===$.slug);if(!Q)throw new OD("denied",`You no longer have access to the active workspace ${$.slug}. Run os login to choose a workspace.`);return{...Q}}function _6(D,Z){let $=D.activeWorkspace;if(!J3($))throw new UD("This OS login has no active workspace. Run os login to choose one.");if(Z!==void 0&&Z!==$.slug)throw new UD(`The active workspace is ${$.slug}. Run os login to choose another workspace.`);return{...$}}async function U8(D={}){let Z=D.store??o2(),$=(Y,B)=>(D.fetch??fetch)(Y,{...B,...D.signal?{signal:D.signal}:{},redirect:"error",credentials:"omit"}),Q=await s0(B0,$),J=await V8(Q,Z,$),X=await _9(Q,J.accessToken,$),W=WX(J,X);return{workspace:W,member:X,request:async(Y,B={})=>{let K=/^\/workspaces\/([^/]+)\//.exec(Y)?.[1];if(K)_6(J,K);return N9(Y,G(B),{...D,store:Z},{config:Q,session:J})},filesRequest:(Y,B={})=>J1(W.slug,Y,G(B),{...D,store:Z}),inboxRequest:(Y,B={})=>p7(W.slug,Y,G(B),{...D,store:Z})};function G(Y){return{...Y,signal:D.signal&&Y.signal?AbortSignal.any([D.signal,Y.signal]):D.signal??Y.signal}}}async function p7(D,Z,$={},Q={}){let J=`https://${D}.oddington.ai`,X=new URL(Z,J),W=new Headers($.headers),G=!1;if(Z==="/api/inbox"&&typeof $.body==="string")try{let{operation:V}=L6(JSON.parse($.body));G=V==="items.list"||V==="items.read"}catch{}if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(D)||D.length>63||["auth","www","api","os"].includes(D)||X.origin!==J||X.username||X.password||X.search||X.hash||!(G||/^\/api\/inbox\/(check|publish|resolve|files)$/.test(Z))||$.method!=="POST"||W.has("authorization")||W.has("x-os-run")||W.has("x-os-workspace")||W.has("transfer-encoding"))throw Error("Invalid Inbox endpoint");let Y=Q.fetch??fetch,B=async(V,L)=>{let N=await Y(V,{...L,redirect:"error",credentials:"omit",signal:$.signal??AbortSignal.timeout(30000)});if(N.redirected||N.status>=300&&N.status<400)throw Error("OS redirected an Inbox request");return N},K=await s0(B0,B),H=await V8(K,Q.store??o2(),B);_6(H,D);let z=W;return z.set("authorization",`Bearer ${H.accessToken}`),B(X,{...$,headers:z,redirect:"error",cache:"no-store"})}async function J1(D,Z,$={},Q={}){let J=new URL(Z,`https://${D}.oddington.ai`),X=$.method??"GET",W=/^\/api\/files\/([^/]+)(?:\/(upload\/(check|reconcile)))?$/.exec(J.pathname),G=W?.[1],Y=new Headers($.headers),B=/^\/api\/files\/([^/]+)\/enrichments$/.exec(J.pathname),K=X==="POST"&&Y.get("content-type")==="application/json"&&(J.pathname==="/api/files"||B&&uD.test(B[1]));if(K){if(typeof $.body!=="string"||Buffer.byteLength($.body)>65536||Y.has("transfer-encoding"))throw new p("invalid_input",400);try{JSON.parse($.body)}catch{throw new p("invalid_input",400)}}let H=X==="POST"&&B&&uD.test(B[1])&&!K;if(H){let C=()=>new p("invalid_input",400,!1,{reason:"invalid_enrichment_request"}),T=Y.get("x-os-enrichment");if(Y.get("content-type")!=="application/octet-stream"||Y.has("transfer-encoding")||!($.body instanceof Uint8Array||$.body instanceof ArrayBuffer)||!T||T.length>4096)throw C();let w;try{w=D1(JSON.parse(decodeURIComponent(T)),16777216)}catch(y){if(y instanceof p)throw y;throw C()}if(w.size!==$.body.byteLength)throw new p("invalid_input",400,!1,{reason:"size_mismatch",expectedBytes:w.size,receivedBytes:$.body.byteLength})}let z=/^\/api\/files\/([0-9a-f-]{36})\/(?:content|enrichments\/([^/]+)\/content)$/.exec(J.pathname),V=X==="GET"&&z&&uD.test(z[1]);if(V&&z?.[2])try{V=f8(decodeURIComponent(z[2]))}catch{V=!1}let L=X==="POST"&&J.pathname==="/api/files"&&!K,N=X==="GET"&&J.pathname==="/api/files/preflight";if(N){let C=Y.get("x-os-file");if(!C||C.length>16384||$.body!==void 0&&$.body!==null)throw new p("invalid_input",400);try{let T=JSON.parse(decodeURIComponent(C));if(!T||typeof T!=="object"||Array.isArray(T)||Object.keys(T).sort().join(",")!=="metadata,sha256"||typeof T.sha256!=="string"||!/^[0-9a-f]{64}$/.test(T.sha256)||H0(T.metadata,j2).storage!=="remote")throw new p("invalid_input",400)}catch(T){if(T instanceof p)throw T;throw new p("invalid_input",400)}}let U=X==="POST"&&/^\/api\/files\/multipart\/(start|part|complete|acknowledge|abort)$/.exec(J.pathname);if(L||U){let C=new Headers($.headers),T=U?U[1]:void 0,w=L||T==="part";if(C.get("content-type")!==(w?"application/octet-stream":"application/json")||C.has("transfer-encoding")||(w?!($.body instanceof Uint8Array||$.body instanceof ArrayBuffer):typeof $.body!=="string")||!w&&Buffer.byteLength($.body)>131072||T&&T!=="start"&&!C.get("x-os-transfer")||T==="part"&&(!/^[1-9][0-9]*$/.test(C.get("x-os-part")??"")||$.body.byteLength>8388608))throw new p("invalid_input",400);try{if(L||T==="start"){let y=C.get("x-os-file");if(L&&(!y||y.length>16384))throw new p("invalid_input",400);let E=H0(JSON.parse(L?decodeURIComponent(y):$.body),L?16777216:j2);if(E.storage!=="remote"||L&&E.size!==$.body.byteLength)throw new p("invalid_input",400)}else if(!w)JSON.parse($.body)}catch(y){if(y instanceof p)throw y;throw new p("invalid_input",400)}}let F=/^\/api\/files\/([0-9a-f-]{36})\/upload\/multipart\/(start|part|complete|abort|enrichments\/[^/]+)$/.exec(J.pathname),_=X==="POST"&&F&&uD.test(F[1]);if(_){let C=new Headers($.headers),T=F[2]==="part"||F[2].startsWith("enrichments/");if(C.get("content-type")!==(T?"application/octet-stream":"application/json")||(T?!($.body instanceof ArrayBuffer):typeof $.body!=="string")||F[2]!=="start"&&!C.get("x-os-transfer")||F[2]==="part"&&!/^[1-9][0-9]*$/.test(C.get("x-os-part")??""))throw new p("invalid_input",400)}let M=X==="POST"&&J.pathname==="/api/data";if((Z.startsWith("/")?Z:Z.slice(J.origin.length))!==J.pathname||!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(D)||D.length>63||["auth","www","api","os"].includes(D)||J.origin!==`https://${D}.oddington.ai`||J.username||J.password||J.search||J.hash||!(X==="GET"&&J.pathname==="/api/files/context"||G&&uD.test(G)&&(X==="GET"&&!W?.[2]||X==="DELETE"&&!W?.[2]||X==="POST"&&!!W?.[2])||M||_||L||N||U||K||H||V)||!M&&!_&&!L&&!N&&!U&&!K&&!H&&$.body!==void 0&&$.body!==null)throw new p("invalid_input",400);let O=Q.fetch??fetch,j=async(C,T)=>{let w=await O(C,{...T,redirect:"error",credentials:"omit",signal:$.signal??AbortSignal.timeout(30000)});if(w.redirected||w.status>=300&&w.status<400)throw new p("unavailable",503,!0);return w},R=(Q.authentication?await Q.authentication(j):void 0)?.session??await V8(await s0(G6(),j),Q.store??o2(),j);return _6(R,D),Y.delete("x-os-run"),Y.set("authorization",`Bearer ${R.accessToken}`),Y.set("x-os-workspace",D),j(J,{...$,headers:Y,redirect:"error",cache:"no-store"})}class t2 extends Error{}class Q1 extends t2{}class C6 extends Error{constructor(){super("Could not reach the OS API.")}}async function $2(D,Z={},$={}){return N9(D,Z,$)}async function N9(D,Z,$,Q){let W=/^\/workspaces\/([^/]+)\/repositories\/([^/]+)\/context$/.exec(D),G=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/(deployment-context|deployments)(?:/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})(?:/(diagnostics|source)(?:/([0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}))?)?)?$").exec(D),Y=G&&(G[1]==="deployment-context"?!G[2]&&(Z.method??"GET")==="POST":G[3]==="source"?(Z.method??"GET")==="PUT":G[2]?(Z.method??"GET")==="GET"&&Z.body==null:(Z.method??"GET")==="POST"),B=!1;try{B=!!W&&D===k7(W[1],decodeURIComponent(W[2]))}catch{}let K=new Headers(Z.headers);if(K.has("x-os-workspace"))throw new Q1("Invalid authenticated OS API endpoint");let H=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/connections\/use$/.test(D),z=D==="/api/cli/data/schema",V=/^\/workspaces\/[a-z0-9][a-z0-9-]*\/repositories$/.test(D),L=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/(?:snapshots|repositories\/([^/]+)\/snapshots\/([^/]+)(\/refresh)?)$/.exec(D),N=!!L&&(!L[1]||X2(L[1])&&X2(L[2])),U=!1;if(N){let n=Z.method??"GET";if(U=!L[1]?n==="GET"&&Z.body==null:L[3]?n==="POST"&&Z.body==null:["GET","DELETE"].includes(n)&&Z.body==null,L[1]&&!L[3]&&(n==="PUT"||n==="PATCH"))try{let o=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=65536?JSON.parse(Z.body):void 0,A=o?.collections;U=["collections","bodies,collections"].includes(Object.keys(o).sort().join(","))&&(A==="@all"||Array.isArray(A)&&A.length>0&&new Set(A).size===A.length&&A.every((S)=>typeof S==="string"&&S.split("/").every((I)=>/^[a-zA-Z0-9_.-]+$/.test(I)&&![".","..",".git","routines"].includes(I))))&&(o.bodies===void 0||Array.isArray(o.bodies)&&new Set(o.bodies).size===o.bodies.length&&o.bodies.every((S)=>typeof S==="string"&&S.split("/").every((I)=>/^[a-zA-Z0-9_.-]+$/.test(I)&&![".","..",".git","routines"].includes(I))&&(A==="@all"||A.includes(S))))&&K.get("content-type")==="application/json"}catch{}}let F=/^\/workspaces\/[a-z0-9][a-z0-9-]{0,62}\/repositories\/[a-z][a-z0-9-]{0,62}\/index$/.test(D),_=!1;if(V)try{let n=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=4096?JSON.parse(Z.body):void 0;K9(n),_=!0}catch{}let M=V&&(Z.method??"GET")==="GET"&&Z.body==null,O=!1;if(z)try{let n=typeof Z.body==="string"&&Buffer.byteLength(Z.body)<=8192?JSON.parse(Z.body):void 0;if(n&&Object.keys(n).sort().join(",")==="branch,remote,repository"&&eD(n.repository))O=y7({remote:n.remote,branch:n.branch}).remote===n.remote}catch{}let j=new RegExp("^/api/cli/local-routines/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/preparation(?:\\?repository=[a-z][a-z0-9-]{0,62})?$").test(D),q=new RegExp("^/api/cli/local-routines/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/renew$").test(D),C=j||q||new RegExp("^/api/cli/local-routines/[a-z0-9][a-z0-9-]{0,62}/(?:resolve|admit|check)$").test(D),T=j?(Z.method??"GET")==="GET"&&Z.body==null:q?Z.method==="POST"&&Z.body==null:Z.method==="POST",w=/^\/api\/cli\/remote-routines\/[a-z0-9][a-z0-9-]{0,62}\/runs$/.test(D),y=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/runs$").test(D),E=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/routines/[a-z0-9][a-z0-9-]{0,62}/describe$").test(D),k=new RegExp("^/workspaces/[a-z0-9][a-z0-9-]{0,62}/runs/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?:/steps/[a-z0-9][a-z0-9-]{0,62})?$").test(D),b=w||y||E||!!k,m=w?Z.method==="POST":E?(Z.method??"GET")==="GET"&&Z.body==null:y?Z.method==="POST"||(Z.method??"GET")==="GET"&&Z.body==null:(Z.method??"GET")==="GET"&&Z.body==null;if(K.has("x-os-run")&&!j&&!q||H&&(Z.method!=="POST"||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding"))||G&&(!Y||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||G[3]==="diagnostics"&&G[4]||G[3]==="source"&&!G[4]&&Z.body!=null)||b&&(!m||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||!y&&!w&&K.has("content-length")&&K.get("content-length")!=="0")||C&&(!T||K.has("x-os-workspace")||K.has("transfer-encoding")||K.has("x-os-run")&&!j&&!q||(j||q)&&!/^[0-9a-f]{64}$/.test(K.get("x-os-run")??"")||(j||q)&&K.has("content-length")&&K.get("content-length")!=="0")||z&&(!O||Z.method!=="POST"||K.has("x-os-run")||K.has("x-os-workspace")||K.has("authorization")||K.has("transfer-encoding"))||V&&(!M&&(!_||Z.method!=="POST")||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding"))||N&&(!U||K.has("content-encoding")||K.has("content-length")||K.has("authorization")||K.has("x-os-run")||K.has("transfer-encoding"))||F&&(Z.method!=="POST"||Z.body!==void 0&&Z.body!==null||K.has("authorization")||K.has("x-os-run")||K.has("x-os-workspace")||K.has("transfer-encoding")||K.has("content-length"))||!N&&!F&&!V&&!z&&!H&&!G&&!b&&!C&&!B&&!new RegExp("^/workspaces/[a-z0-9][a-z0-9-]*/(?:files/storage|connections(?:\\?usable=true|/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?:/test|/grants/(?:user|runtime)/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|/repository-targets(?:/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})?)?|/dropbox/authorizations(?:/[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/complete)?)?)$").test(D)||B&&((Z.method??"GET")!=="GET"||Z.body!==void 0&&Z.body!==null||K.has("x-os-run")||K.has("transfer-encoding")||K.has("content-length")&&K.get("content-length")!=="0"))throw new Q1("Invalid authenticated OS API endpoint");let h=new URL(D,e3);if(h.pathname+h.search!==D)throw new Q1("Invalid authenticated OS API endpoint");let f=$.fetch??fetch,c=async(n,o)=>{let A;try{Z.signal?.throwIfAborted(),A=await f(n,{...o,redirect:"error",...Z.signal?{signal:Z.signal}:{}}),Z.signal?.throwIfAborted()}catch(S){if(Z.signal?.aborted)throw S;throw new C6}if(A.redirected||A.status>=300&&A.status<400)throw new t2("OS redirected an OS API request");return A};Z.signal?.throwIfAborted();let d=typeof Q==="function"?await Q(c):Q,i=d?.session;if(!i){let n=$.store??o2();if(C){let o=n.read();if(!o)throw new UD;i=o.expiresAt>Date.now()+60000?o:await V8(d?.config??await s0($.origin??B0,c,!0),n,c,o)}else{let o=d?.config??await s0($.origin??B0,c,!0);i=await V8(o,n,c)}}let v=/^\/workspaces\/([^/]+)\/(?:snapshots|files\/storage|connections|repositories\/[^/]+\/(?:index|snapshots\/[^/]+)|(?:routines\/[^/]+\/)?runs|routines\/[^/]+\/describe)(?:[/?]|$)/.exec(D)?.[1];if(v)_6(i,v);Z.signal?.throwIfAborted();let l=new Headers(Z.headers);if(C||w)l.set("x-os-workspace",_6(i).slug);return l.set("authorization",`Bearer ${i.accessToken}`),c(h,{...Z,headers:l,credentials:"omit"})}function vK(D){let Z=D.store??o2(),$,Q,J,X=(W,G)=>J??=(async()=>{if($??=await s0(B0,W,!0),G.throwIfAborted(),!Q){let B=Z.read();if(!B)throw new UD;Q={...B}}let Y=Q;return Q=await V8($,{read(){throw Error("Unexpected command session acquisition")},delete(){throw Error("Unexpected command session deletion")},write(B){G.throwIfAborted();let K=Z.read();if(!K||K.accessToken!==Y.accessToken||K.refreshToken!==Y.refreshToken||K.expiresAt!==Y.expiresAt||K.tokenType!==Y.tokenType||K.activeWorkspace?.slug!==Y.activeWorkspace?.slug)throw new OD("denied");G.throwIfAborted(),Z.write(B)}},W,Y),G.throwIfAborted(),{config:$,session:Q}})().finally(()=>{J=void 0});return{request(W,G={}){let Y=G.signal?AbortSignal.any([D.signal,G.signal]):D.signal;return N9(W,{...G,signal:Y},D,(B)=>X(B,Y))},filesRequest(W,G,Y={}){let B=Y.signal?AbortSignal.any([D.signal,Y.signal]):D.signal;return J1(W,G,{...Y,signal:B},{store:Z,fetch:D.fetch,authentication:(K)=>X(K,B)})}}}async function GX(D){let Z=async(G,Y)=>{D.signal.throwIfAborted();let B=await D.fetch(G,{...Y,redirect:"error",signal:D.signal});if(D.signal.throwIfAborted(),B.redirected||B.status>=300&&B.status<400)throw new t2("OS redirected a launch request");return B},$=await s0(D.origin,Z,!0),Q=D.store.read();if(!Q)throw new UD;let J={...Q},X=await V8($,{read(){throw Error("Unexpected launch session read")},write(){},delete(){throw Error("Unexpected launch session deletion")}},Z,J,D.refreshSession),W=!1;return{session:{...X},identity:async(G)=>{let Y=await _9($,X.accessToken,G);return{...Y,activeWorkspace:WX(X,Y)}},request:(G,Y={})=>N9(G,Y,D,{config:$,session:X}),finish(){if(W)return;W=!0;let G=D.store.read();if(!G||G.accessToken!==J.accessToken||G.refreshToken!==J.refreshToken||G.expiresAt!==J.expiresAt||G.tokenType!==J.tokenType||G.activeWorkspace?.slug!==J.activeWorkspace?.slug)throw new OD("denied");if(X!==J)D.store.write(X)}}}async function uK(D={}){let Z=D.fetch??fetch,$=D.origin??B0,Q=D.store??o2(),J;try{J=Q.read()}catch{return Q.delete(),!1}if(!J)return Q.delete(),!1;try{let X=await s0($,Z),W=await V8(X,Q,Z,J);if(!(await Z(X.sessionEndpoint,{method:"DELETE",redirect:"error",headers:{authorization:`Bearer ${W.accessToken}`}})).ok)throw Error("Could not revoke the OS login")}finally{Q.delete()}return!0}async function s0(D,Z,$=!1){let Q=await Z(`${D}/api/cli/oauth-configuration`,{redirect:"error"});if(Q.redirected||Q.status>=300&&Q.status<400)throw Error("OS redirected CLI login configuration");let J=await Q.json().catch(()=>{return});if(!Q.ok)throw Error(BX(J,"OS login is unavailable"));try{return _j(J,D)}catch(X){if($)throw new t2("OS returned invalid CLI login configuration");throw X}}async function Mj(D,Z,$,Q){let J=await Q(D.tokenEndpoint,{method:"POST",redirect:"error",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",client_id:D.clientId,code:Z,code_verifier:$,redirect_uri:D.redirectUri})}),X=await J.json().catch(()=>{return});if(!J.ok)throw Error(BX(X,"OS login failed"));return yK(X)}async function V8(D,Z,$,Q,J=!1){let X=Q??Z.read();if(!X)throw new UD;if(!J&&X.expiresAt>Date.now()+60000)return X;let W=await $(D.tokenEndpoint,{method:"POST",redirect:"error",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"refresh_token",client_id:D.clientId,refresh_token:X.refreshToken})}),G=await W.json().catch(()=>{return});if([400,401,403].includes(W.status)&&M6(G)?.error==="invalid_grant")throw new UD;if(!W.ok)throw new OD([400,401,403].includes(W.status)?"denied":"unavailable",BX(G,"OS could not verify your account. Try again later."));let Y={...yK(G,X.refreshToken),...X.activeWorkspace?{activeWorkspace:{...X.activeWorkspace}}:{}};if(!Q){let B=Z.read();if(!B||B.accessToken!==X.accessToken||B.refreshToken!==X.refreshToken||B.expiresAt!==X.expiresAt||B.tokenType!==X.tokenType||B.activeWorkspace?.slug!==X.activeWorkspace?.slug)throw new OD("denied")}return Z.write(Y),Y}class OD extends Error{kind;constructor(D,Z="OS account unavailable"){super(Z);this.kind=D}}class UD extends OD{constructor(D=q2){super("denied",D)}}async function _9(D,Z,$){let Q=await $(D.sessionEndpoint,{redirect:"error",headers:{authorization:`Bearer ${Z}`}});if(Q.status===401)throw new UD;if(!Q.ok)throw new OD([401,403].includes(Q.status)?"denied":Q.status===409?"invalid":"unavailable");let J=await Q.text(),X;try{X=JSON.parse(J)}catch{throw new OD("invalid")}let W=M6(X);if(!W||typeof W.id!=="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(W.id)||typeof W.email!=="string"||!Array.isArray(W.workspaces))throw new OD("invalid");if(W.name!==void 0&&typeof W.name!=="string")throw new OD("invalid");let G=W.workspaces.map((Y)=>{let B=M6(Y);if(!J3(B))throw new OD("invalid");return{slug:B.slug,name:B.name}});return{id:W.id.toLowerCase(),email:W.email,...W.name?{name:W.name}:{},workspaces:G}}function Cj(D,Z){let $=new URL(D),Q;return{result:new Promise((X,W)=>{let G=setTimeout(()=>{Q?.close(),W(Error("Timed out waiting for authorization. Run os login to try again."))},Vj);Q=Kj((Y,B)=>{let K=new URL(Y.url??"/",$);if(K.pathname!==$.pathname){B.writeHead(404).end("Not found");return}if(K.searchParams.get("state")!==Z){B.writeHead(400,{"content-type":"text/plain; charset=utf-8"}),B.end("OS login received an invalid authorization state");return}try{let H=Nj(K,Z);B.writeHead(200,{"content-type":"text/html; charset=utf-8"}),B.end(bK("authorized")),clearTimeout(G),Q?.close(),X(H)}catch(H){let z=K.searchParams.get("error")==="access_denied";B.writeHead(z?200:400,{"content-type":"text/html; charset=utf-8"}),B.end(bK(z?"cancelled":"error")),clearTimeout(G),Q?.close(),W(H)}}),Q.on("error",(Y)=>{clearTimeout(G),W(Error(`Could not start the OS login callback: ${Y.message}`))}),Q.listen(Number($.port),$.hostname)})}}function bK(D){let Z=D==="authorized"?{title:"Authorization received",message:"You can close this tab and go back to your terminal.",symbol:"✓",success:!0}:D==="cancelled"?{title:"OS CLI was not authorized",message:"No new login was stored on this computer. You can close this tab.",symbol:"×",success:!1}:{title:"Unable to authorize the OS CLI",message:"Run os login again in your terminal.",symbol:"×",success:!1};return`<!doctype html>
|
|
231
231
|
<html lang="en">
|
|
232
232
|
<head>
|
|
233
233
|
<meta charset="utf-8">
|
|
@@ -1803,7 +1803,7 @@ Run this command from the repository or any folder inside it.`);throw Error(xB)}
|
|
|
1803
1803
|
|
|
1804
1804
|
${X}
|
|
1805
1805
|
|
|
1806
|
-
Save your edits separately, then restore the generated file before running this command again.`)}let Y=await iO(Q),B=Z.local?await sO(Q,D):void 0;G[D]=B?.snapshot??await Ml(D,$,Z);let K=await iO(Q);if(K.length!==Y.length||Y.some((H)=>!K.some((z)=>z.path===H.path&&z.before===H.before)))throw Error(`Project files changed during schema generation: ${Q}. Retry after reviewing them.`);return await B?.assertUnchanged(),await _l(Q,[...Y,{path:X,before:W?.text,after:$P(G),mode:W?.mode??420}],Z.replace??rO),{repository:D,source:Z.local?"local":"published",generated:X,projects:Y.filter((H)=>H.before!==H.after).map((H)=>H.path)}}finally{await IB(J,{recursive:!0,force:!0})}}async function ZP(D){if(D.length===0||D.includes("--help")||D.includes("-h")){console.log(D[0]==="schema"?Ul:Vl);return}if(D[0]==="schema"&&(D.length===1||D.length===2&&D[1]==="--local"))throw Error(Fl);let Z=D.includes("--local"),$=D.filter((J)=>J!=="--local");if($.length!==2||$[0]!=="schema"||D.length!==(Z?3:2))throw Error(iQ);let Q=await Cl($[1],{local:Z});console.log(`Schema ${Q.repository}: ${Q.generated} (from ${Q.source} schemas)`);for(let J of Q.projects)console.log(`Integrated ${J}`)}c0();var mB="Usage: os data snapshots <create|list|get|refresh|delete>",Ol=`Manage Data snapshots.
|
|
1806
|
+
Save your edits separately, then restore the generated file before running this command again.`)}let Y=await iO(Q),B=Z.local?await sO(Q,D):void 0;G[D]=B?.snapshot??await Ml(D,$,Z);let K=await iO(Q);if(K.length!==Y.length||Y.some((H)=>!K.some((z)=>z.path===H.path&&z.before===H.before)))throw Error(`Project files changed during schema generation: ${Q}. Retry after reviewing them.`);return await B?.assertUnchanged(),await _l(Q,[...Y,{path:X,before:W?.text,after:$P(G),mode:W?.mode??420}],Z.replace??rO),{repository:D,source:Z.local?"local":"published",generated:X,projects:Y.filter((H)=>H.before!==H.after).map((H)=>H.path)}}finally{await IB(J,{recursive:!0,force:!0})}}async function ZP(D){if(D.length===0||D.includes("--help")||D.includes("-h")){console.log(D[0]==="schema"?Ul:Vl);return}if(D[0]==="schema"&&(D.length===1||D.length===2&&D[1]==="--local"))throw Error(Fl);let Z=D.includes("--local"),$=D.filter((J)=>J!=="--local");if($.length!==2||$[0]!=="schema"||D.length!==(Z?3:2))throw Error(iQ);let Q=await Cl($[1],{local:Z});console.log(`Schema ${Q.repository}: ${Q.generated} (from ${Q.source} schemas)`);for(let J of Q.projects)console.log(`Integrated ${J}`)}c0();var mB="Usage: os data snapshots <create|update|list|get|refresh|delete>",Ol=`Manage Data snapshots.
|
|
1807
1807
|
|
|
1808
1808
|
A Data snapshot lets an app download complete Records from selected
|
|
1809
1809
|
collections. OS builds it from the latest published version of a Data
|
|
@@ -1814,39 +1814,42 @@ Usage:
|
|
|
1814
1814
|
|
|
1815
1815
|
Commands:
|
|
1816
1816
|
create Create a snapshot and build it for the first time
|
|
1817
|
+
update Replace a snapshot's definition and rebuild it
|
|
1817
1818
|
list List snapshots in the active workspace
|
|
1818
1819
|
get Show a snapshot's definition and current version
|
|
1819
1820
|
refresh Rebuild a snapshot from the latest published Records
|
|
1820
1821
|
delete Delete a snapshot
|
|
1821
1822
|
|
|
1822
|
-
Run \`os data snapshots <command> --help\` for command details.`,aQ=["create","list","get","refresh","delete"],fB=(D)=>`os data snapshots ${D}${D==="list"?"":" <name> --repository <repository>"}${D==="create"?" --collections <names|@all> [--bodies <names>]":""}`;function Pl(D){let $=[{create:"Create a snapshot and build it from the latest published Records.",list:"List snapshots in the active workspace.",get:"Show a snapshot's definition and current version.",refresh:"Rebuild a snapshot from the latest published Records.",delete:"Delete a snapshot and its downloadable artifact."}[D],`Usage:
|
|
1823
|
+
Run \`os data snapshots <command> --help\` for command details.`,aQ=["create","update","list","get","refresh","delete"],fB=(D)=>`os data snapshots ${D}${D==="list"?"":" <name> --repository <repository>"}${D==="create"||D==="update"?" --collections <names|@all> [--bodies <names>]":""}`;function Pl(D){let $=[{create:"Create a snapshot and build it from the latest published Records.",update:"Replace a snapshot's complete collection and body selection.",list:"List snapshots in the active workspace.",get:"Show a snapshot's definition and current version.",refresh:"Rebuild a snapshot from the latest published Records.",delete:"Delete a snapshot and its downloadable artifact."}[D],`Usage:
|
|
1823
1824
|
${fB(D)}`];if(D!=="list")$.push(`Required inputs:
|
|
1824
1825
|
<name>
|
|
1825
1826
|
The snapshot's name.
|
|
1826
1827
|
--repository
|
|
1827
|
-
The Data repository's name in your active workspace.${D==="create"?`
|
|
1828
|
+
The Data repository's name in your active workspace.${D==="create"||D==="update"?`
|
|
1828
1829
|
--collections
|
|
1829
1830
|
Collection names separated by commas, or @all for every collection that exists now.
|
|
1830
|
-
Pass this option once.
|
|
1831
|
-
${fB(D).replace("<name>","buchhaltung").replace("<repository>","general").replace("<names|@all>","transactions,invoices").replace(" [--bodies <names>]"," --bodies invoices")}`),D==="create")$.push(`Optional inputs:
|
|
1831
|
+
Pass this option once. Include every collection you want in the snapshot.`:""}`);if($.push(`Example:
|
|
1832
|
+
${fB(D).replace("<name>","buchhaltung").replace("<repository>","general").replace("<names|@all>","transactions,invoices").replace(" [--bodies <names>]"," --bodies invoices")}`),D==="create"||D==="update")$.push(`Optional inputs:
|
|
1832
1833
|
--bodies
|
|
1833
1834
|
Collection names separated by commas whose Markdown bodies to include.
|
|
1834
1835
|
These names must be selected by --collections. Omit for structured Records only.`,`To include every collection that exists now:
|
|
1835
|
-
os data snapshots
|
|
1836
|
+
os data snapshots ${D} buchhaltung --repository general --collections @all`,D==="update"?`The command waits for the replacement. The previous snapshot stays readable
|
|
1837
|
+
while OS builds it. A failed update keeps its previous definition and contents.
|
|
1838
|
+
Omitting --bodies removes all bodies.`:"The command waits until the snapshot is ready to read.");if(D==="refresh")$.push("The command waits for the new snapshot. A failed refresh keeps the previous version.");return $.join(`
|
|
1836
1839
|
|
|
1837
|
-
`)}function Tl(D,Z){return`
|
|
1840
|
+
`)}function Tl(D,Z,$){return`This command needs a complete collection selection.
|
|
1838
1841
|
|
|
1839
|
-
Pass
|
|
1840
|
-
os data snapshots
|
|
1842
|
+
Pass all collection names separated by commas:
|
|
1843
|
+
os data snapshots ${D} ${Z} --repository ${$} --collections "<collections>"
|
|
1841
1844
|
|
|
1842
1845
|
To include every collection that exists now, use @all:
|
|
1843
|
-
os data snapshots
|
|
1846
|
+
os data snapshots ${D} ${Z} --repository ${$} --collections @all
|
|
1844
1847
|
|
|
1845
1848
|
For more details, run:
|
|
1846
|
-
os data snapshots
|
|
1849
|
+
os data snapshots ${D} --help`}function hB(D,Z="create"){if(D==="@all")return D;let $=D.split(",");if(new Set($).size!==$.length||$.some((Q)=>!Q.split("/").every((J)=>/^[a-zA-Z0-9_.-]+$/.test(J)&&![".","..",".git","routines"].includes(J))))throw Error(`Choose collection names separated by commas, or use @all on its own.
|
|
1847
1850
|
|
|
1848
1851
|
For more details, run:
|
|
1849
|
-
os data snapshots
|
|
1852
|
+
os data snapshots ${Z} --help`);return $}function QP(D){if(!D||!["collections,id,name,refreshedAt,repository,version","bodies,collections,id,name,refreshedAt,repository,version"].includes(Object.keys(D).sort().join(",")))throw Error("OS returned an invalid snapshot response.");let Z=D,$={...Z,bodies:Z.bodies===void 0?[]:Z.bodies};if(typeof $.id!=="string"||!/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test($.id)||!X2($.name)||!X2($.repository)||!Array.isArray($.collections)||!$.collections.length||$.collections.some((Q)=>typeof Q!=="string")||new Set($.collections).size!==$.collections.length||!Array.isArray($.bodies)||new Set($.bodies).size!==$.bodies.length||$.bodies.some((Q)=>!$.collections.includes(Q))||typeof $.version!=="string"||!/^current-[0-9a-f]{40}$/.test($.version)||typeof $.refreshedAt!=="string"||!Number.isFinite(Date.parse($.refreshedAt)))throw Error("OS returned an invalid snapshot response.");for(let Q of $.collections){let J=hB(Q);if(J==="@all"||J.length!==1)throw Error("OS returned an invalid snapshot response.")}return $}var jl=(D)=>`Snapshot: ${D.name}
|
|
1850
1853
|
Repository: ${D.repository}
|
|
1851
1854
|
Collections: ${D.collections.join(", ")}
|
|
1852
1855
|
Bodies: ${D.bodies.length?D.bodies.join(", "):"none"}
|
|
@@ -1856,7 +1859,7 @@ Refreshed: ${D.refreshedAt}`;function vB(D){let Z=D[0];if(!D.length||D.includes(
|
|
|
1856
1859
|
${aQ.includes(Z)?`Usage: ${fB(Z)}`:mB}
|
|
1857
1860
|
|
|
1858
1861
|
For more details, run:
|
|
1859
|
-
os data snapshots${aQ.includes(Z)?` ${Z}`:""} --help`);if(!aQ.includes(Z))throw $();let Q=Z==="list"?void 0:D[1],J,X,W,G=new Set;for(let Y=Z==="list"?1:2;Y<D.length;Y+=2){let B=D[Y],K=D[Y+1];if(Z==="list"||!["--repository",...Z==="create"?["--collections","--bodies"]:[]].includes(B)||G.has(B)||!K||K.startsWith("-"))throw $();if(G.add(B),B==="--repository")J=K;else if(B==="--collections")X=hB(K);else{let H=hB(K);if(H==="@all")throw $();W=H}}if(Z!=="list"&&(!X2(Q)||!X2(J)))throw $();if(Z==="create"&&!X)throw Error(Tl(Q,J));if(W&&X!=="@all"&&W.some((Y)=>!X?.includes(Y)))throw $();return{command:Z,name:Q,repository:J,collections:X,bodies:W}}async function JP(D,Z={}){let $=Z.print??console.log,Q=vB(D);if(!Q){let L=D[0];$(aQ.includes(L)?Pl(L):Ol);return}let{command:J,name:X,repository:W,collections:G,bodies:Y}=Q,B=await(Z.context??U8)(),K=`/workspaces/${B.workspace.slug}/${J==="list"?"snapshots":`repositories/${W}/snapshots/${X}${J==="refresh"?"/refresh":""}`}`,H=await B.request(K,J==="create"?{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({collections:G,...Y?{bodies:Y}:{}})}:{method:J==="refresh"?"POST":J==="delete"?"DELETE":"GET"}),z=await H.json().catch(()=>null);if(!H.ok){let L={unauthenticated:"Sign in with os login.",access_denied:"You do not have access to this snapshot in the active workspace.",not_found:"The snapshot was not found.",already_exists:"That snapshot already exists. Choose another name or get the existing snapshot.",snapshot_busy:"Another operation is working on this snapshot. Try again after it finishes.",invalid_query:"Check the snapshot name, repository and collections."}[z?.error?.code];throw Error(`Could not ${J} ${J==="list"?"snapshots":"the snapshot"}. ${L??"Try the same command again."}`)}if(J==="delete"){if(!z||Object.keys(z).join(",")!=="id"||typeof z.id!=="string")throw Error("OS returned an invalid snapshot response.");$(`Deleted snapshot ${X} from repository ${W}.`);return}let V=J==="list"?Array.isArray(z)?z.map(QP):void 0:[QP(z)];if(!V||J!=="list"&&(V[0].name!==X||V[0].repository!==W))throw Error("OS returned an invalid snapshot response.");$(V.length?V.map(jl).join(`
|
|
1862
|
+
os data snapshots${aQ.includes(Z)?` ${Z}`:""} --help`);if(!aQ.includes(Z))throw $();let Q=Z==="list"?void 0:D[1],J,X,W,G=new Set;for(let Y=Z==="list"?1:2;Y<D.length;Y+=2){let B=D[Y],K=D[Y+1];if(Z==="list"||!["--repository",...Z==="create"||Z==="update"?["--collections","--bodies"]:[]].includes(B)||G.has(B)||!K||K.startsWith("-"))throw $();if(G.add(B),B==="--repository")J=K;else if(B==="--collections")X=hB(K,Z);else{let H=hB(K,Z);if(H==="@all")throw $();W=H}}if(Z!=="list"&&(!X2(Q)||!X2(J)))throw $();if((Z==="create"||Z==="update")&&!X)throw Error(Tl(Z,Q,J));if(W&&X!=="@all"&&W.some((Y)=>!X?.includes(Y)))throw $();return{command:Z,name:Q,repository:J,collections:X,bodies:W}}async function JP(D,Z={}){let $=Z.print??console.log,Q=vB(D);if(!Q){let L=D[0];$(aQ.includes(L)?Pl(L):Ol);return}let{command:J,name:X,repository:W,collections:G,bodies:Y}=Q,B=await(Z.context??U8)(),K=`/workspaces/${B.workspace.slug}/${J==="list"?"snapshots":`repositories/${W}/snapshots/${X}${J==="refresh"?"/refresh":""}`}`,H=await B.request(K,J==="create"||J==="update"?{method:J==="update"?"PATCH":"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({collections:G,...Y?{bodies:Y}:{}})}:{method:J==="refresh"?"POST":J==="delete"?"DELETE":"GET"}),z=await H.json().catch(()=>null);if(!H.ok){let L={unauthenticated:"Sign in with os login.",access_denied:"You do not have access to this snapshot in the active workspace.",not_found:"The snapshot was not found.",already_exists:"That snapshot already exists. Choose another name or get the existing snapshot.",snapshot_busy:"Another operation is working on this snapshot. Try again after it finishes.",invalid_query:"Check the snapshot name, repository and collections."}[z?.error?.code];throw Error(`Could not ${J} ${J==="list"?"snapshots":"the snapshot"}. ${L??"Try the same command again."}`)}if(J==="delete"){if(!z||Object.keys(z).join(",")!=="id"||typeof z.id!=="string")throw Error("OS returned an invalid snapshot response.");$(`Deleted snapshot ${X} from repository ${W}.`);return}let V=J==="list"?Array.isArray(z)?z.map(QP):void 0:[QP(z)];if(!V||J!=="list"&&(V[0].name!==X||V[0].repository!==W))throw Error("OS returned an invalid snapshot response.");$(V.length?V.map(jl).join(`
|
|
1860
1863
|
|
|
1861
1864
|
`):"No snapshots in the active workspace.")}var oQ="Usage: os repository add <name> --workspace <workspace> --git-repository <name>",ql=`Add a Data repository to your workspace.
|
|
1862
1865
|
|
|
@@ -1885,7 +1888,7 @@ Commands:
|
|
|
1885
1888
|
${oQ}
|
|
1886
1889
|
|
|
1887
1890
|
For more details, run:
|
|
1888
|
-
os repository add --help`);if(D[0]!=="add")throw X();$=D[1];let W=new Set;for(let z=2;z<D.length;z+=2){let V=D[z],L=D[z+1];if(!["--workspace","--git-repository"].includes(V)||W.has(V)||!L||L.startsWith("-"))throw X();if(W.add(V),V==="--workspace")Q=L;else J=L}let G;try{if(G=K9({name:$,gitRepository:J}),!Q||!/^[a-z0-9][a-z0-9-]*$/.test(Q))throw X()}catch{throw X()}let Y=await $2(`/workspaces/${Q}/repositories`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(G)},Z),B=await Y.json().catch(()=>null);if(!Y.ok)throw Error(typeof B?.error==="string"?B.error:"Could not add the Data repository. Run the same command again.");let K=MK(B);if(K.repository.name!==G.name||K.repository.gitRepository!==G.gitRepository)throw Error("Invalid repository setup response");console.log(JSON.stringify(K,null,2));let H=await L9(Q,Z);if(H)console.error(H)}var rQ={name:"@oddington/cli",version:"0.1.
|
|
1891
|
+
os repository add --help`);if(D[0]!=="add")throw X();$=D[1];let W=new Set;for(let z=2;z<D.length;z+=2){let V=D[z],L=D[z+1];if(!["--workspace","--git-repository"].includes(V)||W.has(V)||!L||L.startsWith("-"))throw X();if(W.add(V),V==="--workspace")Q=L;else J=L}let G;try{if(G=K9({name:$,gitRepository:J}),!Q||!/^[a-z0-9][a-z0-9-]*$/.test(Q))throw X()}catch{throw X()}let Y=await $2(`/workspaces/${Q}/repositories`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(G)},Z),B=await Y.json().catch(()=>null);if(!Y.ok)throw Error(typeof B?.error==="string"?B.error:"Could not add the Data repository. Run the same command again.");let K=MK(B);if(K.repository.name!==G.name||K.repository.gitRepository!==G.gitRepository)throw Error("Invalid repository setup response");console.log(JSON.stringify(K,null,2));let H=await L9(Q,Z);if(H)console.error(H)}var rQ={name:"@oddington/cli",version:"0.1.90",description:"OS command-line client",license:"SEE LICENSE IN LICENSE",type:"module",bin:{os:"dist/os.js"},files:["dist","LICENSE","README.md"],engines:{node:">=22.12.0"},publishConfig:{access:"public"},scripts:{build:"bun run --filter @oddington/sdk build && bun run scripts/build.ts",check:"tsc --noEmit",prepack:"bun run scripts/prepack.ts","verify:package":"bun run scripts/verify-package.ts"},devDependencies:{"@babel/parser":"8.0.7","@inquirer/select":"4.4.2","@inquirer/testing":"2.1.53","@types/node":"26.6.1","@types/semver":"^7.7.1",semver:"^7.7.3",typescript:"7.0.2"},dependencies:{"@oddington/sdk":"^0.1.53"},exports:{}};var WP=`Usage:
|
|
1889
1892
|
os --version
|
|
1890
1893
|
os login
|
|
1891
1894
|
os whoami
|