@uniformdev/project-map 17.4.0 → 17.4.1-alpha.34

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/cli/cli.js CHANGED
@@ -116,7 +116,7 @@ ${v.join(`
116
116
  `:""}var Nl=Cl,El={dump:Nl};function Vi(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var rr=G0.load,O7=G0.loadAll,nr=El.dump;var T7=Vi("safeLoad","load"),P7=Vi("safeLoadAll","loadAll"),j7=Vi("safeDump","dump");var $6=require("fs"),o2=require("path"),k6=require("fs"),q6=o1(Dr(),1),s2=o1(r6(),1),H6=o1(require("fs"),1);function D1(){}D1.prototype={diff:function(a,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.callback;typeof t=="function"&&(i=t,t={}),this.options=t;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),p=this.castInput(p),a=this.removeEmpty(this.tokenize(a)),p=this.removeEmpty(this.tokenize(p));var n=p.length,s=a.length,o=1,l=n+s;t.maxEditLength&&(l=Math.min(l,t.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],p,a,0);if(m[0].newPos+1>=n&&c+1>=s)return d([{value:this.join(p),count:p.length}]);function u(){for(var g=-1*o;g<=o;g+=2){var h=void 0,x=m[g-1],S=m[g+1],M=(S?S.newPos:0)-g;x&&(m[g-1]=void 0);var F=x&&x.newPos+1<n,k=S&&0<=M&&M<s;if(!F&&!k){m[g]=void 0;continue}if(!F||k&&x.newPos<S.newPos?(h=_9(S),r.pushComponent(h.components,void 0,!0)):(h=x,h.newPos++,r.pushComponent(h.components,!0,void 0)),M=r.extractCommon(h,p,a,g),h.newPos+1>=n&&M+1>=s)return d(y9(r,h.components,p,a,r.useLongestToken));m[g]=h}o++}if(i)(function g(){setTimeout(function(){if(o>l)return i();u()||g()},0)})();else for(;o<=l;){var v=u();if(v)return v}},pushComponent:function(a,p,t){var i=a[a.length-1];i&&i.added===p&&i.removed===t?a[a.length-1]={count:i.count+1,added:p,removed:t}:a.push({count:1,added:p,removed:t})},extractCommon:function(a,p,t,i){for(var r=p.length,d=t.length,n=a.newPos,s=n-i,o=0;n+1<r&&s+1<d&&this.equals(p[n+1],t[s+1]);)n++,s++,o++;return o&&a.components.push({count:o}),a.newPos=n,s},equals:function(a,p){return this.options.comparator?this.options.comparator(a,p):a===p||this.options.ignoreCase&&a.toLowerCase()===p.toLowerCase()},removeEmpty:function(a){for(var p=[],t=0;t<a.length;t++)a[t]&&p.push(a[t]);return p},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function y9(e,a,p,t,i){for(var r=0,d=a.length,n=0,s=0;r<d;r++){var o=a[r];if(o.removed){if(o.value=e.join(t.slice(s,s+o.count)),s+=o.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!o.added&&i){var l=p.slice(n,n+o.count);l=l.map(function(u,v){var g=t[s+v];return g.length>u.length?g:u}),o.value=e.join(l)}else o.value=e.join(p.slice(n,n+o.count));n+=o.count,o.added||(s+=o.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function _9(e){return{newPos:e.newPos,components:e.components.slice(0)}}var ym=new D1;var n6=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,s6=/\S/,o6=new D1;o6.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!s6.test(e)&&!s6.test(a)};o6.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),p=0;p<a.length-1;p++)!a[p+1]&&a[p+2]&&n6.test(a[p])&&n6.test(a[p+2])&&(a[p]+=a[p+2],a.splice(p+1,2),p--);return a};var Yd=new D1;Yd.tokenize=function(e){var a=[],p=e.split(/(\n|\r\n)/);p[p.length-1]||p.pop();for(var t=0;t<p.length;t++){var i=p[t];t%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function Gd(e,a,p){return Yd.diff(e,a,p)}var x9=new D1;x9.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var S9=new D1;S9.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function It(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?It=function(a){return typeof a}:It=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},It(e)}var A9=Object.prototype.toString,tp=new D1;tp.useLongestToken=!0;tp.tokenize=Yd.tokenize;tp.castInput=function(e){var a=this.options,p=a.undefinedReplacement,t=a.stringifyReplacer,i=t===void 0?function(r,d){return typeof d=="undefined"?p:d}:t;return typeof e=="string"?e:JSON.stringify(Wd(e,null,null,i),i," ")};tp.equals=function(e,a){return D1.prototype.equals.call(tp,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function l6(e,a,p){return tp.diff(e,a,p)}function Wd(e,a,p,t,i){a=a||[],p=p||[],t&&(e=t(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return p[r];var d;if(A9.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),p.push(d),r=0;r<e.length;r+=1)d[r]=Wd(e[r],a,p,t,i);return a.pop(),p.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),It(e)==="object"&&e!==null){a.push(e),d={},p.push(d);var n=[],s;for(s in e)e.hasOwnProperty(s)&&n.push(s);for(n.sort(),r=0;r<n.length;r+=1)s=n[r],d[s]=Wd(e[s],a,p,t,s);a.pop(),p.pop()}else d=e;return d}var zd=new D1;zd.tokenize=function(e){return e.slice()};zd.join=zd.removeEmpty=function(e){return e};var Y6=o1(U6(),1);async function Q1({objects:e,selectIdentifier:a,selectDisplayName:p=a,onSyncComplete:t}){let i=e.reduce((n,s)=>{let o=a(s);if(n[o])throw new Error(`Identifier ${o} was not unique.`);return n[o]={id:o,object:s,providerId:o,displayName:p(s)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,s)=>n[0].localeCompare(s[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let s=a(n.object);i[s]=n},extractCurrent:d,onSyncComplete:t?n=>t(n,d()):void 0}}var H5=xi(Si());function re(e){var a,p;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(p=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?p:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function ne(e){return e&&console.log(`\u{1F991} Using proxy ${e}`),(a,p)=>{if(e){let t={...p,agent:new q6.HttpsProxyAgent(e)};return(0,s2.default)(a,t)}return(0,s2.default)(a,p)}}function se(e){var a,p,t;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(t=(p=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?p:process.env.UPM_CLI_PROJECT_ID)!=null?t:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function X1(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function ea(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function aa(e){let a=(0,o2.extname)(e);return a===".yaml"||a===".yml"||a===".json"}function w1(e,a,p){let t;if(p&&!a){let i=(0,o2.extname)(p);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":t=JSON.stringify(e,null,2);break;case"yaml":t=nr(e);break;default:throw new Error(`Unsupported format: ${a}`)}p?(0,$6.writeFileSync)(p,t,"utf8"):console.log(t)}function sp(e){let a=(0,k6.readFileSync)(e,"utf8");return rr(a,{filename:e,json:!0})}async function pa({directory:e,format:a="yaml",selectIdentifier:p,selectDisplayName:t=p}){(0,zt.existsSync)(e)||(0,zt.mkdirSync)(e,{recursive:!0});let i=await(0,Yt.readdir)(e,"utf-8"),r=new Set(i.filter(s=>{let o=(0,Vp.extname)(s);return o===".json"||o===".yaml"||o===".yml"})),d=s=>(0,Vp.join)(e,`${s}.${a}`);async function*n(){for(let s of r){let o=(0,Vp.join)(e,s);try{let l=await sp(o);yield{id:p(l),displayName:t(l),providerId:o,object:l}}catch(l){throw console.error(H5.default.red(`Failed to read ${o}, data is likely invalid.
117
117
  ${l==null?void 0:l.message}`)),l}}}return{objects:n(),deleteObject:async s=>{await(0,Yt.unlink)(s)},writeObject:async s=>{w1(s.object,a,d(s.id))}}}function W6(e,a){if(!a&&!H6.default.existsSync(e))return{};let p=sp(e);if(typeof p!="object")throw new Error(`Package ${e} does not appear valid.`);return p}function z6(e,a){w1(a,void 0,e)}async function ta({source:e,target:a,compareContents:p=(n,s)=>(0,Y6.default)(n.object,s.object,(o,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:t,allowEmptySource:i=!1,whatIf:r=!1,log:d=()=>{}}){var n,s;let o=new Map;for await(let c of a.objects)o.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,v=o.get(u);if(v){if(!p(c,v)&&(t==="createOrUpdate"||t==="mirror")){let g=async(h,x)=>{var S;if(!r)try{await a.writeObject(h,x)}catch(M){throw new Wt(M,h)}d({action:"update",id:u,providerId:h.providerId,displayName:(S=h.displayName)!=null?S:h.providerId,whatIf:r,diff:l6(x.object,h.object)})};l.push(g(c,v))}o.delete(u)}else{let g=async(h,x)=>{var S;if(!r)try{await a.writeObject(h)}catch(M){throw new Wt(M,h)}d({action:"create",id:x,providerId:x,displayName:(S=h.displayName)!=null?S:h.providerId,whatIf:r,diff:Gd("",JSON.stringify(h.object,null,2))})};l.push(g(c,u))}}if(await Promise.all(l),t==="mirror"){if(!m&&!i)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];o.forEach(async u=>{let v=async g=>{var h;if(!r)try{await a.deleteObject(g.providerId,g)}catch(x){throw new Wt(x,g)}d({action:"delete",id:g.id,providerId:g.providerId,displayName:(h=g.displayName)!=null?h:g.providerId,whatIf:r,diff:Gd(JSON.stringify(g.object,null,2),"")})};c.push(v(u))}),await Promise.all(c)}await Promise.all([(n=e.onSyncComplete)==null?void 0:n.call(e,!1),(s=a.onSyncComplete)==null?void 0:s.call(a,!0)])}var Wt=class extends Error{constructor(e,a){var p;super(`Error syncing ${(p=a.displayName)!=null?p:a.providerId} (${a.providerId})
118
118
  ${e}`),this.stack=void 0,Object.setPrototypeOf(this,Wt.prototype)}},np=xi(Si());function ia(e){let{diffMode:a="off",indent:p,prefix:t}=e!=null?e:{};return function({action:i,displayName:r,whatIf:d,diff:n}){let s="";switch(i){case"create":s=np.default.green("[A]");break;case"update":s=np.default.white("[U]");break;case"delete":s=np.default.yellow("[D]");break}let o="";(a==="on"||a==="update"&&i==="update")&&(o=`
119
- `+n.map(l=>l.added?np.default.green(l.value):l.removed?np.default.red(l.value):l.value).join("")),console.log(`${p!=null?p:""}${d?np.default.gray("[WHATIF]"):""}${s}${t!=null?t:""} ${r}${o}`)}}var G6=require("@uniformdev/context/api"),K6="/",m2=class extends G6.ApiClient{constructor(p){super(p);this.getProjectMapDefinitions=async p=>{let t=this.createUrl("/api/v1/project-map",{projectId:p});return await this.apiClient(t)};this.getProjectMapDefinition=async p=>{let t=this.createUrl("/api/v1/project-map",{...p,projectMapId:p.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async p=>{let t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...p,projectMap:p.projectMap})})).projectMapId};this.deleteProjectMap=async p=>{let t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,projectMapId:p.projectMapId}),expectNoContent:!0})};this.upsertProjectMapNodes=async p=>{let t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:p.projectId,projectMapId:p.projectMapId,nodes:p.nodes.map(i=>({...i,node:{...this.cleanProjectMapNode(i.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async p=>{let t=this.createUrl("/api/v1/project-map-nodes");(!p.path||this.validatePath(p.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,projectMapId:p.projectMapId}),expectNoContent:!0})};this.getSubtree=async p=>{var s;let t={};t.projectId=p.projectId,p.projectMapId?t.projectMapId=p.projectMapId:p.path&&this.validatePath(p.path)?t.path=p.path:p.compositionId&&(t.compositionId=p.compositionId),p.depth&&(t.depth=p.depth.toString()),p.expanded&&(t.expanded="true"),t.tree="true";let i=this.createUrl("/api/v1/project-map-nodes",t),d={...(await this.apiClient(i)).tree},n=[d];for(;n&&n.length>0;){let o=n.pop(),l;(s=o==null?void 0:o.children)==null||s.forEach(m=>{m.parent=l2(o),m.previousSibling=l2(l),l&&(l.nextSibling=l2(m)),l=m,n.push(m)})}return d};this.getNodes=async p=>{let t={};t.projectId=p.projectId,p.projectMapId&&(t.projectMapId=p.projectMapId),p.projectMapId?t.projectMapId=p.projectMapId:p.path&&this.validatePath(p.path)?t.path=p.path:p.compositionId&&(t.compositionId=p.compositionId),p.limit&&(t.limit=p.limit.toString()),p.offset&&(t.offset=p.offset.toString()),p.expanded&&(t.expanded="true");let i=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(i)}}cleanProjectMapNode(p){var t,i,r;return{id:((r=(i=(t=p.id)==null?void 0:t.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i))==null?void 0:i.length)!=null?r:0)==1?p.id:void 0,path:p.path,name:p.name,type:p.type,compositionId:p.compositionId,description:p.description}}validatePath(p){let t=/[*%!&@]/g;if(p==null?void 0:p.match(t))throw"Path cannot contain reserved characters * % ! & @";return!0}},pe=class extends m2{constructor(a){super({...a,bypassCache:!0})}},l2=e=>e?{...e,parent:void 0,children:void 0}:void 0;var J6={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>X1(re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to fetch"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,projectMapId:i,format:r,project:d,filename:n})=>{var m,c;let s=ne(p),l=await new pe({apiKey:a,apiHost:e,fetch:s}).getNodes({projectMapId:i,id:t,projectId:d});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):w1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var Z6={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>X1(re(se(e.positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,format:i,filename:r,project:d})=>{var l;let n=ne(p),o=await new pe({apiKey:a,apiHost:e,fetch:n}).getNodes({projectMapId:t,projectId:d});w1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var P1=e=>e.id,da=e=>`${e.name} (pid: ${e.id})`;function ra(e,a){return W6(e,a)}function Gt(e,a){z6(e,a)}function Kt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for(let i of t){let r=(await e.getNodes({projectId:a,projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:P1(d),displayName:da(d),providerId:P1(d),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:t,projectMapId:i.object.projectMapId,projectId:a})},writeObject:async t=>{var r;let i={...t.object};if(i.path===K6){let d=(r=(await e.getNodes({projectId:a,projectMapId:i.projectMapId,path:i.path})).nodes)==null?void 0:r[0];d&&(i.id=d.id)}await e.upsertProjectMapNodes({projectId:a,projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var Q6={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o}),m=Kt({client:l,projectId:n}),c;if(aa(t)){let g=ra(t,!1);c=await Q1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMapNodes=x,Gt(t,g)}})}else c=await pa({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await ta({source:m,target:c,mode:r,whatIf:d,log:ia({diffMode:s})})}};var X6={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s}),l;if(aa(t)){let v=ra(t,!0);l=await Q1({objects:(u=v.projectMapNodes)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await pa({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=Kt({client:o,projectId:d});await ta({source:l,target:c,mode:i,whatIf:r,log:ia({diffMode:n})})}};var e4={command:"remove <id> <projectMapId>",aliases:["delete","rm"],describe:"Delete a project map node",builder:e=>re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to delete"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to delete from"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,id:i,project:r})=>{let d=ne(p);await new pe({apiKey:a,apiHost:e,fetch:d}).deleteProjectMapNode({projectMapId:t,nodeId:i,projectId:r})}};var a4={command:"update <filename> <projectMapId>",aliases:["put"],describe:"Insert or update a project map node",builder:e=>re(se(e.positional("filename",{demandOption:!0,describe:"ProjectMap node file with nodes data"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to put into"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,filename:i,project:r})=>{let d=ne(p),n=new pe({apiKey:a,apiHost:e,fetch:d}),s=sp(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t,projectId:r})}};var p4={command:"project-map-node <command>",aliases:["pmn"],describe:"Commands for ProjectMap Nodes",builder:e=>e.command(Q6).command(X6).command(J6).command(e4).command(Z6).command(a4).demandCommand(),handler:()=>{Ua.help()}};var t4={command:"get <id>",describe:"Fetch a project map",builder:e=>X1(re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap UUID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,project:r,filename:d})=>{let n=ne(p),o=await new pe({apiKey:a,apiHost:e,fetch:n}).getProjectMapDefinition({projectMapId:t,projectId:r});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):w1(o.projectMaps[0],i,d)}};var i4={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>X1(re(se(e))),handler:async({apiHost:e,apiKey:a,proxy:p,format:t,filename:i,project:r})=>{let d=ne(p),s=await new pe({apiKey:a,apiHost:e,fetch:d}).getProjectMapDefinitions(r);w1(s.projectMaps,t,i)}};var j1=e=>e.id,na=e=>`${e.name} (pid: ${e.id})`;function Jt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for await(let i of t)yield{id:j1(i),displayName:na(i),providerId:j1(i),object:i}}return{objects:p(),deleteObject:async t=>{await e.deleteProjectMap({projectMapId:t,projectId:a})},writeObject:async t=>{await e.upsertProjectMap({projectMap:t.object,projectId:a})}}}var d4={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o}),m=Jt({client:l,projectId:n}),c;if(aa(t)){let g=ra(t,!1);c=await Q1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:j1,selectDisplayName:na,onSyncComplete:async(h,x)=>{g.projectMaps=x,Gt(t,g)}})}else c=await pa({directory:t,selectIdentifier:j1,selectDisplayName:na,format:i});await ta({source:m,target:c,mode:r,whatIf:d,log:ia({diffMode:s})})}};var r4={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s}),l;if(aa(t)){let v=ra(t,!0);l=await Q1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:j1,selectDisplayName:na})}else l=await pa({directory:t,selectIdentifier:j1,selectDisplayName:na});let c=Jt({client:o,projectId:d});await ta({source:l,target:c,mode:i,whatIf:r,log:ia({diffMode:n})})}};var n4={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a project map",builder:e=>re(se(e.positional("id",{demandOption:!0,describe:" UUID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=ne(p);await new pe({apiKey:a,apiHost:e,fetch:r}).deleteProjectMap({projectMapId:t,projectId:i})}};var s4={command:"update <filename>",aliases:["put"],describe:"Insert or update a project map",builder:e=>re(se(e.positional("filename",{demandOption:!0,describe:"Project map file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i})=>{let r=ne(p),d=new pe({apiKey:a,apiHost:e,fetch:r}),n=sp(t);await d.upsertProjectMap({projectMap:n,projectId:i})}};var o4={command:"project-map-definition <command>",aliases:["pmd"],describe:"Commands for ProjectMap Definitions",builder:e=>e.command(d4).command(r4).command(t4).command(n4).command(i4).command(s4).demandCommand(),handler:()=>{Ua.help()}};var W5={commands:[{command:"project-map <command>",aliases:["pm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(p4).command(o4).demandCommand(),handler:()=>{Ua.showHelp()}}]};0&&(module.exports={uniformCLI});
119
+ `+n.map(l=>l.added?np.default.green(l.value):l.removed?np.default.red(l.value):l.value).join("")),console.log(`${p!=null?p:""}${d?np.default.gray("[WHATIF]"):""}${s}${t!=null?t:""} ${r}${o}`)}}var G6=require("@uniformdev/context/api"),K6="/",m2=class extends G6.ApiClient{constructor(p){super(p);this.getProjectMapDefinitions=async p=>{let t=this.createUrl("/api/v1/project-map",{projectId:p});return await this.apiClient(t)};this.getProjectMapDefinition=async p=>{let t=this.createUrl("/api/v1/project-map",{...p,projectMapId:p.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async p=>{let t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...p,projectMap:p.projectMap})})).projectMapId};this.deleteProjectMap=async p=>{let t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,projectMapId:p.projectMapId}),expectNoContent:!0})};this.upsertProjectMapNodes=async p=>{let t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:p.projectId,projectMapId:p.projectMapId,nodes:p.nodes.map(i=>({...i,node:{...this.cleanProjectMapNode(i.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async p=>{let t=this.createUrl("/api/v1/project-map-nodes");(!p.path||this.validatePath(p.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,projectMapId:p.projectMapId}),expectNoContent:!0})};this.getSubtree=async p=>{var s;let t={};t.projectId=p.projectId,p.projectMapId?t.projectMapId=p.projectMapId:p.path&&this.validatePath(p.path)?t.path=p.path:p.compositionId&&(t.compositionId=p.compositionId),p.depth&&(t.depth=p.depth.toString()),p.expanded&&(t.expanded="true"),t.tree="true";let i=this.createUrl("/api/v1/project-map-nodes",t),d={...(await this.apiClient(i)).tree},n=[d];for(;n&&n.length>0;){let o=n.pop(),l;(s=o==null?void 0:o.children)==null||s.forEach(m=>{m.parent=l2(o),m.previousSibling=l2(l),l&&(l.nextSibling=l2(m)),l=m,n.push(m)})}return d};this.getNodes=async p=>{let t={};t.projectId=p.projectId,p.projectMapId&&(t.projectMapId=p.projectMapId),p.projectMapId?t.projectMapId=p.projectMapId:p.path&&this.validatePath(p.path)?t.path=p.path:p.compositionId&&(t.compositionId=p.compositionId),p.limit&&(t.limit=p.limit.toString()),p.offset&&(t.offset=p.offset.toString()),p.expanded&&(t.expanded="true");let i=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(i)}}cleanProjectMapNode(p){var t,i,r;return{id:((r=(i=(t=p.id)==null?void 0:t.match(/^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i))==null?void 0:i.length)!=null?r:0)==1?p.id:void 0,path:p.path,name:p.name,type:p.type,compositionId:p.compositionId,description:p.description}}validatePath(p){let t=/[*%!&@]/g;if(p==null?void 0:p.match(t))throw"Path cannot contain reserved characters * % ! & @";return!0}},pe=class extends m2{constructor(a){super({...a,bypassCache:!0})}},l2=e=>e?{...e,parent:void 0,children:void 0}:void 0;var J6={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>X1(re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to fetch"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,projectMapId:i,format:r,project:d,filename:n})=>{var m,c;let s=ne(p),l=await new pe({apiKey:a,apiHost:e,fetch:s}).getNodes({projectMapId:i,id:t,projectId:d});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):w1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var Z6={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>X1(re(se(e.positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,format:i,filename:r,project:d})=>{var l;let n=ne(p),o=await new pe({apiKey:a,apiHost:e,fetch:n}).getNodes({projectMapId:t,projectId:d});w1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var P1=e=>e.id+e.projectMapId,da=e=>`${e.name} (pid: ${e.id})`;function ra(e,a){return W6(e,a)}function Gt(e,a){z6(e,a)}function Kt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for(let i of t){let r=(await e.getNodes({projectId:a,projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:P1({...d,projectMapId:i.id}),displayName:da(d),providerId:P1({...d,projectMapId:i.id}),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:t,projectMapId:i.object.projectMapId,projectId:a})},writeObject:async t=>{var r;let i={...t.object};if(i.path===K6){let d=(r=(await e.getNodes({projectId:a,projectMapId:i.projectMapId,path:i.path})).nodes)==null?void 0:r[0];d&&(i.id=d.id)}await e.upsertProjectMapNodes({projectId:a,projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var Q6={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o}),m=Kt({client:l,projectId:n}),c;if(aa(t)){let g=ra(t,!1);c=await Q1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMapNodes=x,Gt(t,g)}})}else c=await pa({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await ta({source:m,target:c,mode:r,whatIf:d,log:ia({diffMode:s})})}};var X6={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s}),l;if(aa(t)){let v=ra(t,!0);l=await Q1({objects:(u=v.projectMapNodes)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await pa({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=Kt({client:o,projectId:d});await ta({source:l,target:c,mode:i,whatIf:r,log:ia({diffMode:n})})}};var e4={command:"remove <id> <projectMapId>",aliases:["delete","rm"],describe:"Delete a project map node",builder:e=>re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to delete"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to delete from"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,id:i,project:r})=>{let d=ne(p);await new pe({apiKey:a,apiHost:e,fetch:d}).deleteProjectMapNode({projectMapId:t,nodeId:i,projectId:r})}};var a4={command:"update <filename> <projectMapId>",aliases:["put"],describe:"Insert or update a project map node",builder:e=>re(se(e.positional("filename",{demandOption:!0,describe:"ProjectMap node file with nodes data"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to put into"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,filename:i,project:r})=>{let d=ne(p),n=new pe({apiKey:a,apiHost:e,fetch:d}),s=sp(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t,projectId:r})}};var p4={command:"project-map-node <command>",aliases:["pmn"],describe:"Commands for ProjectMap Nodes",builder:e=>e.command(Q6).command(X6).command(J6).command(e4).command(Z6).command(a4).demandCommand(),handler:()=>{Ua.help()}};var t4={command:"get <id>",describe:"Fetch a project map",builder:e=>X1(re(se(e.positional("id",{demandOption:!0,describe:"ProjectMap UUID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,project:r,filename:d})=>{let n=ne(p),o=await new pe({apiKey:a,apiHost:e,fetch:n}).getProjectMapDefinition({projectMapId:t,projectId:r});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):w1(o.projectMaps[0],i,d)}};var i4={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>X1(re(se(e))),handler:async({apiHost:e,apiKey:a,proxy:p,format:t,filename:i,project:r})=>{let d=ne(p),s=await new pe({apiKey:a,apiHost:e,fetch:d}).getProjectMapDefinitions(r);w1(s.projectMaps,t,i)}};var j1=e=>e.id,na=e=>`${e.name} (pid: ${e.id})`;function Jt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for await(let i of t)yield{id:j1(i),displayName:na(i),providerId:j1(i),object:i}}return{objects:p(),deleteObject:async t=>{await e.deleteProjectMap({projectMapId:t,projectId:a})},writeObject:async t=>{await e.upsertProjectMap({projectMap:t.object,projectId:a})}}}var d4={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o}),m=Jt({client:l,projectId:n}),c;if(aa(t)){let g=ra(t,!1);c=await Q1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:j1,selectDisplayName:na,onSyncComplete:async(h,x)=>{g.projectMaps=x,Gt(t,g)}})}else c=await pa({directory:t,selectIdentifier:j1,selectDisplayName:na,format:i});await ta({source:m,target:c,mode:r,whatIf:d,log:ia({diffMode:s})})}};var r4={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>re(se(ea(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s}),l;if(aa(t)){let v=ra(t,!0);l=await Q1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:j1,selectDisplayName:na})}else l=await pa({directory:t,selectIdentifier:j1,selectDisplayName:na});let c=Jt({client:o,projectId:d});await ta({source:l,target:c,mode:i,whatIf:r,log:ia({diffMode:n})})}};var n4={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a project map",builder:e=>re(se(e.positional("id",{demandOption:!0,describe:" UUID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=ne(p);await new pe({apiKey:a,apiHost:e,fetch:r}).deleteProjectMap({projectMapId:t,projectId:i})}};var s4={command:"update <filename>",aliases:["put"],describe:"Insert or update a project map",builder:e=>re(se(e.positional("filename",{demandOption:!0,describe:"Project map file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i})=>{let r=ne(p),d=new pe({apiKey:a,apiHost:e,fetch:r}),n=sp(t);await d.upsertProjectMap({projectMap:n,projectId:i})}};var o4={command:"project-map-definition <command>",aliases:["pmd"],describe:"Commands for ProjectMap Definitions",builder:e=>e.command(d4).command(r4).command(t4).command(n4).command(i4).command(s4).demandCommand(),handler:()=>{Ua.help()}};var W5={commands:[{command:"project-map <command>",aliases:["pm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(p4).command(o4).demandCommand(),handler:()=>{Ua.showHelp()}}]};0&&(module.exports={uniformCLI});
120
120
  /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
121
121
  /**
122
122
  * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
package/dist/cli/cli.mjs CHANGED
@@ -116,7 +116,7 @@ ${v.join(`
116
116
  `:""}var _l=yl,xl={dump:_l};function Ci(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var q0=P0.load,Y7=P0.loadAll,H0=xl.dump;var G7=Ci("safeLoad","load"),K7=Ci("safeLoadAll","loadAll"),J7=Ci("safeDump","dump");var N6=Fp(mr(),1),Jd=Fp(qn(),1);import{writeFileSync as z5}from"fs";import{extname as C6}from"path";import{readFileSync as Y5}from"fs";import G5 from"fs";function E1(){}E1.prototype={diff:function(a,p){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=t.callback;typeof t=="function"&&(i=t,t={}),this.options=t;var r=this;function d(g){return i?(setTimeout(function(){i(void 0,g)},0),!0):g}a=this.castInput(a),p=this.castInput(p),a=this.removeEmpty(this.tokenize(a)),p=this.removeEmpty(this.tokenize(p));var n=p.length,s=a.length,o=1,l=n+s;t.maxEditLength&&(l=Math.min(l,t.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],p,a,0);if(m[0].newPos+1>=n&&c+1>=s)return d([{value:this.join(p),count:p.length}]);function u(){for(var g=-1*o;g<=o;g+=2){var h=void 0,x=m[g-1],S=m[g+1],F=(S?S.newPos:0)-g;x&&(m[g-1]=void 0);var M=x&&x.newPos+1<n,k=S&&0<=F&&F<s;if(!M&&!k){m[g]=void 0;continue}if(!M||k&&x.newPos<S.newPos?(h=g9(S),r.pushComponent(h.components,void 0,!0)):(h=x,h.newPos++,r.pushComponent(h.components,!0,void 0)),F=r.extractCommon(h,p,a,g),h.newPos+1>=n&&F+1>=s)return d(v9(r,h.components,p,a,r.useLongestToken));m[g]=h}o++}if(i)(function g(){setTimeout(function(){if(o>l)return i();u()||g()},0)})();else for(;o<=l;){var v=u();if(v)return v}},pushComponent:function(a,p,t){var i=a[a.length-1];i&&i.added===p&&i.removed===t?a[a.length-1]={count:i.count+1,added:p,removed:t}:a.push({count:1,added:p,removed:t})},extractCommon:function(a,p,t,i){for(var r=p.length,d=t.length,n=a.newPos,s=n-i,o=0;n+1<r&&s+1<d&&this.equals(p[n+1],t[s+1]);)n++,s++,o++;return o&&a.components.push({count:o}),a.newPos=n,s},equals:function(a,p){return this.options.comparator?this.options.comparator(a,p):a===p||this.options.ignoreCase&&a.toLowerCase()===p.toLowerCase()},removeEmpty:function(a){for(var p=[],t=0;t<a.length;t++)a[t]&&p.push(a[t]);return p},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function v9(e,a,p,t,i){for(var r=0,d=a.length,n=0,s=0;r<d;r++){var o=a[r];if(o.removed){if(o.value=e.join(t.slice(s,s+o.count)),s+=o.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!o.added&&i){var l=p.slice(n,n+o.count);l=l.map(function(u,v){var g=t[s+v];return g.length>u.length?g:u}),o.value=e.join(l)}else o.value=e.join(p.slice(n,n+o.count));n+=o.count,o.added||(s+=o.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function g9(e){return{newPos:e.newPos,components:e.components.slice(0)}}var qm=new E1;var Hn=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,Wn=/\S/,zn=new E1;zn.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!Wn.test(e)&&!Wn.test(a)};zn.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),p=0;p<a.length-1;p++)!a[p+1]&&a[p+2]&&Hn.test(a[p])&&Hn.test(a[p+2])&&(a[p]+=a[p+2],a.splice(p+1,2),p--);return a};var Id=new E1;Id.tokenize=function(e){var a=[],p=e.split(/(\n|\r\n)/);p[p.length-1]||p.pop();for(var t=0;t<p.length;t++){var i=p[t];t%2&&!this.options.newlineIsToken?a[a.length-1]+=i:(this.options.ignoreWhitespace&&(i=i.trim()),a.push(i))}return a};function Vd(e,a,p){return Id.diff(e,a,p)}var w9=new E1;w9.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var b9=new E1;b9.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function Dt(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Dt=function(a){return typeof a}:Dt=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},Dt(e)}var y9=Object.prototype.toString,ep=new E1;ep.useLongestToken=!0;ep.tokenize=Id.tokenize;ep.castInput=function(e){var a=this.options,p=a.undefinedReplacement,t=a.stringifyReplacer,i=t===void 0?function(r,d){return typeof d=="undefined"?p:d}:t;return typeof e=="string"?e:JSON.stringify(Fd(e,null,null,i),i," ")};ep.equals=function(e,a){return E1.prototype.equals.call(ep,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function Yn(e,a,p){return ep.diff(e,a,p)}function Fd(e,a,p,t,i){a=a||[],p=p||[],t&&(e=t(i,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return p[r];var d;if(y9.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),p.push(d),r=0;r<e.length;r+=1)d[r]=Fd(e[r],a,p,t,i);return a.pop(),p.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),Dt(e)==="object"&&e!==null){a.push(e),d={},p.push(d);var n=[],s;for(s in e)e.hasOwnProperty(s)&&n.push(s);for(n.sort(),r=0;r<n.length;r+=1)s=n[r],d[s]=Fd(e[s],a,p,t,s);a.pop(),p.pop()}else d=e;return d}var Md=new E1;Md.tokenize=function(e){return e.slice()};Md.join=Md.removeEmpty=function(e){return e};var O6=Fp(S6(),1);async function J1({objects:e,selectIdentifier:a,selectDisplayName:p=a,onSyncComplete:t}){let i=e.reduce((n,s)=>{let o=a(s);if(n[o])throw new Error(`Identifier ${o} was not unique.`);return n[o]={id:o,object:s,providerId:o,displayName:p(s)},n},{});async function*r(){for(let n of Object.values(i))yield n}function d(){return Object.entries(i).sort((n,s)=>n[0].localeCompare(s[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete i[n]},writeObject:async n=>{let s=a(n.object);i[s]=n},extractCurrent:d,onSyncComplete:t?n=>t(n,d()):void 0}}var U5=mi(ci());function ne(e){var a,p;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(p=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?p:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function se(e){return e&&console.log(`\u{1F991} Using proxy ${e}`),(a,p)=>{if(e){let t={...p,agent:new N6.HttpsProxyAgent(e)};return(0,Jd.default)(a,t)}return(0,Jd.default)(a,p)}}function oe(e){var a,p,t;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(t=(p=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?p:process.env.UPM_CLI_PROJECT_ID)!=null?t:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function Z1(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function Q1(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function X1(e){let a=C6(e);return a===".yaml"||a===".yml"||a===".json"}function g1(e,a,p){let t;if(p&&!a){let i=C6(p);i===".yaml"||i===".yml"?a="yaml":i===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":t=JSON.stringify(e,null,2);break;case"yaml":t=H0(e);break;default:throw new Error(`Unsupported format: ${a}`)}p?z5(p,t,"utf8"):console.log(t)}function dp(e){let a=Y5(e,"utf8");return q0(a,{filename:e,json:!0})}async function ea({directory:e,format:a="yaml",selectIdentifier:p,selectDisplayName:t=p}){$5(e)||k5(e,{recursive:!0});let i=await q5(e,"utf-8"),r=new Set(i.filter(s=>{let o=W5(s);return o===".json"||o===".yaml"||o===".yml"})),d=s=>A6(e,`${s}.${a}`);async function*n(){for(let s of r){let o=A6(e,s);try{let l=await dp(o);yield{id:p(l),displayName:t(l),providerId:o,object:l}}catch(l){throw console.error(U5.default.red(`Failed to read ${o}, data is likely invalid.
117
117
  ${l==null?void 0:l.message}`)),l}}}return{objects:n(),deleteObject:async s=>{await H5(s)},writeObject:async s=>{g1(s.object,a,d(s.id))}}}function E6(e,a){if(!a&&!G5.existsSync(e))return{};let p=dp(e);if(typeof p!="object")throw new Error(`Package ${e} does not appear valid.`);return p}function D6(e,a){g1(a,void 0,e)}async function aa({source:e,target:a,compareContents:p=(n,s)=>(0,O6.default)(n.object,s.object,(o,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:t,allowEmptySource:i=!1,whatIf:r=!1,log:d=()=>{}}){var n,s;let o=new Map;for await(let c of a.objects)o.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,v=o.get(u);if(v){if(!p(c,v)&&(t==="createOrUpdate"||t==="mirror")){let g=async(h,x)=>{var S;if(!r)try{await a.writeObject(h,x)}catch(F){throw new Bt(F,h)}d({action:"update",id:u,providerId:h.providerId,displayName:(S=h.displayName)!=null?S:h.providerId,whatIf:r,diff:Yn(x.object,h.object)})};l.push(g(c,v))}o.delete(u)}else{let g=async(h,x)=>{var S;if(!r)try{await a.writeObject(h)}catch(F){throw new Bt(F,h)}d({action:"create",id:x,providerId:x,displayName:(S=h.displayName)!=null?S:h.providerId,whatIf:r,diff:Vd("",JSON.stringify(h.object,null,2))})};l.push(g(c,u))}}if(await Promise.all(l),t==="mirror"){if(!m&&!i)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];o.forEach(async u=>{let v=async g=>{var h;if(!r)try{await a.deleteObject(g.providerId,g)}catch(x){throw new Bt(x,g)}d({action:"delete",id:g.id,providerId:g.providerId,displayName:(h=g.displayName)!=null?h:g.providerId,whatIf:r,diff:Vd(JSON.stringify(g.object,null,2),"")})};c.push(v(u))}),await Promise.all(c)}await Promise.all([(n=e.onSyncComplete)==null?void 0:n.call(e,!1),(s=a.onSyncComplete)==null?void 0:s.call(a,!0)])}var Bt=class extends Error{constructor(e,a){var p;super(`Error syncing ${(p=a.displayName)!=null?p:a.providerId} (${a.providerId})
118
118
  ${e}`),this.stack=void 0,Object.setPrototypeOf(this,Bt.prototype)}},ip=mi(ci());function pa(e){let{diffMode:a="off",indent:p,prefix:t}=e!=null?e:{};return function({action:i,displayName:r,whatIf:d,diff:n}){let s="";switch(i){case"create":s=ip.default.green("[A]");break;case"update":s=ip.default.white("[U]");break;case"delete":s=ip.default.yellow("[D]");break}let o="";(a==="on"||a==="update"&&i==="update")&&(o=`
119
- `+n.map(l=>l.added?ip.default.green(l.value):l.removed?ip.default.red(l.value):l.value).join("")),console.log(`${p!=null?p:""}${d?ip.default.gray("[WHATIF]"):""}${s}${t!=null?t:""} ${r}${o}`)}}var T6={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>Z1(ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to fetch"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,projectMapId:i,format:r,project:d,filename:n})=>{var m,c;let s=se(p),l=await new re({apiKey:a,apiHost:e,fetch:s}).getNodes({projectMapId:i,id:t,projectId:d});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):g1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var P6={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>Z1(ne(oe(e.positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,format:i,filename:r,project:d})=>{var l;let n=se(p),o=await new re({apiKey:a,apiHost:e,fetch:n}).getNodes({projectMapId:t,projectId:d});g1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var T1=e=>e.id,ta=e=>`${e.name} (pid: ${e.id})`;function ia(e,a){return E6(e,a)}function Rt(e,a){D6(e,a)}function Ut({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for(let i of t){let r=(await e.getNodes({projectId:a,projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:T1(d),displayName:ta(d),providerId:T1(d),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:t,projectMapId:i.object.projectMapId,projectId:a})},writeObject:async t=>{var r;let i={...t.object};if(i.path===e2){let d=(r=(await e.getNodes({projectId:a,projectMapId:i.projectMapId,path:i.path})).nodes)==null?void 0:r[0];d&&(i.id=d.id)}await e.upsertProjectMapNodes({projectId:a,projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var j6={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=se(p),l=new re({apiKey:a,apiHost:e,fetch:o}),m=Ut({client:l,projectId:n}),c;if(X1(t)){let g=ia(t,!1);c=await J1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:T1,selectDisplayName:ta,onSyncComplete:async(h,x)=>{g.projectMapNodes=x,Rt(t,g)}})}else c=await ea({directory:t,selectIdentifier:T1,selectDisplayName:ta,format:i});await aa({source:m,target:c,mode:r,whatIf:d,log:pa({diffMode:s})})}};var F6={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=se(p),o=new re({apiKey:a,apiHost:e,fetch:s}),l;if(X1(t)){let v=ia(t,!0);l=await J1({objects:(u=v.projectMapNodes)!=null?u:[],selectIdentifier:T1,selectDisplayName:ta})}else l=await ea({directory:t,selectIdentifier:T1,selectDisplayName:ta});let c=Ut({client:o,projectId:d});await aa({source:l,target:c,mode:i,whatIf:r,log:pa({diffMode:n})})}};var M6={command:"remove <id> <projectMapId>",aliases:["delete","rm"],describe:"Delete a project map node",builder:e=>ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to delete"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to delete from"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,id:i,project:r})=>{let d=se(p);await new re({apiKey:a,apiHost:e,fetch:d}).deleteProjectMapNode({projectMapId:t,nodeId:i,projectId:r})}};var I6={command:"update <filename> <projectMapId>",aliases:["put"],describe:"Insert or update a project map node",builder:e=>ne(oe(e.positional("filename",{demandOption:!0,describe:"ProjectMap node file with nodes data"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to put into"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,filename:i,project:r})=>{let d=se(p),n=new re({apiKey:a,apiHost:e,fetch:d}),s=dp(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t,projectId:r})}};var V6={command:"project-map-node <command>",aliases:["pmn"],describe:"Commands for ProjectMap Nodes",builder:e=>e.command(j6).command(F6).command(T6).command(M6).command(P6).command(I6).demandCommand(),handler:()=>{La.help()}};var L6={command:"get <id>",describe:"Fetch a project map",builder:e=>Z1(ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap UUID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,project:r,filename:d})=>{let n=se(p),o=await new re({apiKey:a,apiHost:e,fetch:n}).getProjectMapDefinition({projectMapId:t,projectId:r});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):g1(o.projectMaps[0],i,d)}};var B6={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>Z1(ne(oe(e))),handler:async({apiHost:e,apiKey:a,proxy:p,format:t,filename:i,project:r})=>{let d=se(p),s=await new re({apiKey:a,apiHost:e,fetch:d}).getProjectMapDefinitions(r);g1(s.projectMaps,t,i)}};var P1=e=>e.id,da=e=>`${e.name} (pid: ${e.id})`;function $t({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for await(let i of t)yield{id:P1(i),displayName:da(i),providerId:P1(i),object:i}}return{objects:p(),deleteObject:async t=>{await e.deleteProjectMap({projectMapId:t,projectId:a})},writeObject:async t=>{await e.upsertProjectMap({projectMap:t.object,projectId:a})}}}var R6={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=se(p),l=new re({apiKey:a,apiHost:e,fetch:o}),m=$t({client:l,projectId:n}),c;if(X1(t)){let g=ia(t,!1);c=await J1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMaps=x,Rt(t,g)}})}else c=await ea({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await aa({source:m,target:c,mode:r,whatIf:d,log:pa({diffMode:s})})}};var U6={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=se(p),o=new re({apiKey:a,apiHost:e,fetch:s}),l;if(X1(t)){let v=ia(t,!0);l=await J1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await ea({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=$t({client:o,projectId:d});await aa({source:l,target:c,mode:i,whatIf:r,log:pa({diffMode:n})})}};var $6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a project map",builder:e=>ne(oe(e.positional("id",{demandOption:!0,describe:" UUID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=se(p);await new re({apiKey:a,apiHost:e,fetch:r}).deleteProjectMap({projectMapId:t,projectId:i})}};var k6={command:"update <filename>",aliases:["put"],describe:"Insert or update a project map",builder:e=>ne(oe(e.positional("filename",{demandOption:!0,describe:"Project map file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i})=>{let r=se(p),d=new re({apiKey:a,apiHost:e,fetch:r}),n=dp(t);await d.upsertProjectMap({projectMap:n,projectId:i})}};var q6={command:"project-map-definition <command>",aliases:["pmd"],describe:"Commands for ProjectMap Definitions",builder:e=>e.command(R6).command(U6).command(L6).command($6).command(B6).command(k6).demandCommand(),handler:()=>{La.help()}};var ff={commands:[{command:"project-map <command>",aliases:["pm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(V6).command(q6).demandCommand(),handler:()=>{La.showHelp()}}]};export{ff as uniformCLI};
119
+ `+n.map(l=>l.added?ip.default.green(l.value):l.removed?ip.default.red(l.value):l.value).join("")),console.log(`${p!=null?p:""}${d?ip.default.gray("[WHATIF]"):""}${s}${t!=null?t:""} ${r}${o}`)}}var T6={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>Z1(ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to fetch"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,projectMapId:i,format:r,project:d,filename:n})=>{var m,c;let s=se(p),l=await new re({apiKey:a,apiHost:e,fetch:s}).getNodes({projectMapId:i,id:t,projectId:d});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):g1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var P6={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>Z1(ne(oe(e.positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to fetch from"})))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,format:i,filename:r,project:d})=>{var l;let n=se(p),o=await new re({apiKey:a,apiHost:e,fetch:n}).getNodes({projectMapId:t,projectId:d});g1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var T1=e=>e.id+e.projectMapId,ta=e=>`${e.name} (pid: ${e.id})`;function ia(e,a){return E6(e,a)}function Rt(e,a){D6(e,a)}function Ut({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for(let i of t){let r=(await e.getNodes({projectId:a,projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:T1({...d,projectMapId:i.id}),displayName:ta(d),providerId:T1({...d,projectMapId:i.id}),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:t,projectMapId:i.object.projectMapId,projectId:a})},writeObject:async t=>{var r;let i={...t.object};if(i.path===e2){let d=(r=(await e.getNodes({projectId:a,projectMapId:i.projectMapId,path:i.path})).nodes)==null?void 0:r[0];d&&(i.id=d.id)}await e.upsertProjectMapNodes({projectId:a,projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var j6={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=se(p),l=new re({apiKey:a,apiHost:e,fetch:o}),m=Ut({client:l,projectId:n}),c;if(X1(t)){let g=ia(t,!1);c=await J1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:T1,selectDisplayName:ta,onSyncComplete:async(h,x)=>{g.projectMapNodes=x,Rt(t,g)}})}else c=await ea({directory:t,selectIdentifier:T1,selectDisplayName:ta,format:i});await aa({source:m,target:c,mode:r,whatIf:d,log:pa({diffMode:s})})}};var F6={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=se(p),o=new re({apiKey:a,apiHost:e,fetch:s}),l;if(X1(t)){let v=ia(t,!0);l=await J1({objects:(u=v.projectMapNodes)!=null?u:[],selectIdentifier:T1,selectDisplayName:ta})}else l=await ea({directory:t,selectIdentifier:T1,selectDisplayName:ta});let c=Ut({client:o,projectId:d});await aa({source:l,target:c,mode:i,whatIf:r,log:pa({diffMode:n})})}};var M6={command:"remove <id> <projectMapId>",aliases:["delete","rm"],describe:"Delete a project map node",builder:e=>ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap Node UUID to delete"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to delete from"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,id:i,project:r})=>{let d=se(p);await new re({apiKey:a,apiHost:e,fetch:d}).deleteProjectMapNode({projectMapId:t,nodeId:i,projectId:r})}};var I6={command:"update <filename> <projectMapId>",aliases:["put"],describe:"Insert or update a project map node",builder:e=>ne(oe(e.positional("filename",{demandOption:!0,describe:"ProjectMap node file with nodes data"}).positional("projectMapId",{demandOption:!0,describe:"ProjectMap UUID to put into"}))),handler:async({apiHost:e,apiKey:a,proxy:p,projectMapId:t,filename:i,project:r})=>{let d=se(p),n=new re({apiKey:a,apiHost:e,fetch:d}),s=dp(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t,projectId:r})}};var V6={command:"project-map-node <command>",aliases:["pmn"],describe:"Commands for ProjectMap Nodes",builder:e=>e.command(j6).command(F6).command(T6).command(M6).command(P6).command(I6).demandCommand(),handler:()=>{La.help()}};var L6={command:"get <id>",describe:"Fetch a project map",builder:e=>Z1(ne(oe(e.positional("id",{demandOption:!0,describe:"ProjectMap UUID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,format:i,project:r,filename:d})=>{let n=se(p),o=await new re({apiKey:a,apiHost:e,fetch:n}).getProjectMapDefinition({projectMapId:t,projectId:r});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):g1(o.projectMaps[0],i,d)}};var B6={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>Z1(ne(oe(e))),handler:async({apiHost:e,apiKey:a,proxy:p,format:t,filename:i,project:r})=>{let d=se(p),s=await new re({apiKey:a,apiHost:e,fetch:d}).getProjectMapDefinitions(r);g1(s.projectMaps,t,i)}};var P1=e=>e.id,da=e=>`${e.name} (pid: ${e.id})`;function $t({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions(a)).projectMaps;for await(let i of t)yield{id:P1(i),displayName:da(i),providerId:P1(i),object:i}}return{objects:p(),deleteObject:async t=>{await e.deleteProjectMap({projectMapId:t,projectId:a})},writeObject:async t=>{await e.upsertProjectMap({projectMap:t.object,projectId:a})}}}var R6={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to save project maps to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,format:i,mode:r,whatIf:d,project:n,diff:s})=>{var v;let o=se(p),l=new re({apiKey:a,apiHost:e,fetch:o}),m=$t({client:l,projectId:n}),c;if(X1(t)){let g=ia(t,!1);c=await J1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMaps=x,Rt(t,g)}})}else c=await ea({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await aa({source:m,target:c,mode:r,whatIf:d,log:pa({diffMode:s})})}};var U6={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>ne(oe(Q1(e.positional("directory",{describe:"Directory to read project maps from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:p,directory:t,mode:i,whatIf:r,project:d,diff:n})=>{var u;let s=se(p),o=new re({apiKey:a,apiHost:e,fetch:s}),l;if(X1(t)){let v=ia(t,!0);l=await J1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await ea({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=$t({client:o,projectId:d});await aa({source:l,target:c,mode:i,whatIf:r,log:pa({diffMode:n})})}};var $6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a project map",builder:e=>ne(oe(e.positional("id",{demandOption:!0,describe:" UUID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:p,id:t,project:i})=>{let r=se(p);await new re({apiKey:a,apiHost:e,fetch:r}).deleteProjectMap({projectMapId:t,projectId:i})}};var k6={command:"update <filename>",aliases:["put"],describe:"Insert or update a project map",builder:e=>ne(oe(e.positional("filename",{demandOption:!0,describe:"Project map file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:p,filename:t,project:i})=>{let r=se(p),d=new re({apiKey:a,apiHost:e,fetch:r}),n=dp(t);await d.upsertProjectMap({projectMap:n,projectId:i})}};var q6={command:"project-map-definition <command>",aliases:["pmd"],describe:"Commands for ProjectMap Definitions",builder:e=>e.command(R6).command(U6).command(L6).command($6).command(B6).command(k6).demandCommand(),handler:()=>{La.help()}};var ff={commands:[{command:"project-map <command>",aliases:["pm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(V6).command(q6).demandCommand(),handler:()=>{La.showHelp()}}]};export{ff as uniformCLI};
120
120
  /*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
121
121
  /**
122
122
  * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "17.4.0",
3
+ "version": "17.4.1-alpha.34+d7b9aa4ba",
4
4
  "description": "Uniform Project Map",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -46,17 +46,17 @@
46
46
  "/dist"
47
47
  ],
48
48
  "dependencies": {
49
- "@uniformdev/canvas": "^17.4.0",
50
- "@uniformdev/context": "^17.4.0",
49
+ "@uniformdev/canvas": "^17.4.1-alpha.34+d7b9aa4ba",
50
+ "@uniformdev/context": "^17.4.1-alpha.34+d7b9aa4ba",
51
51
  "p-limit": "^3.1.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/yargs": "17.0.13",
55
- "@uniformdev/cli": "^17.4.0",
55
+ "@uniformdev/cli": "^17.4.1-alpha.34+d7b9aa4ba",
56
56
  "yargs": "17.6.0"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "77580d40fbad3c838310f09824d29c067686fa64"
61
+ "gitHead": "d7b9aa4ba467282780318d3b3eafa5f38ca886da"
62
62
  }