@uniformdev/project-map 17.3.1-alpha.194 → 17.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chunk-PFKTXWY5.mjs +1 -0
- package/dist/cli/cli.js +1 -1
- package/dist/cli/cli.mjs +2 -2
- package/dist/index.d.ts +447 -33
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +10 -10
- package/dist/chunk-QOYLUYYN.mjs +0 -1
package/README.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.create;var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var y=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(a,e)=>(typeof require!="undefined"?require:a)[e]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var U=(r,a)=>()=>(r&&(a=r(r=0)),a);var b=(r,a)=>()=>(a||r((a={exports:{}}).exports,a),a.exports),S=(r,a)=>{for(var e in a)n(r,e,{get:a[e],enumerable:!0})},f=(r,a,e,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let p of I(a))!R.call(r,p)&&p!==e&&n(r,p,{get:()=>a[p],enumerable:!(t=m(a,p))||t.enumerable});return r};var C=(r,a,e)=>(e=r!=null?l(N(r)):{},f(a||!r||!r.__esModule?n(e,"default",{value:r,enumerable:!0}):e,r)),v=r=>f(n({},"__esModule",{value:!0}),r);import{ApiClient as g}from"@uniformdev/context/api";var O="/",u=class extends g{constructor(e){super(e);this.getProjectMapDefinitions=async e=>{let t=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(t)};this.getProjectMapDefinition=async e=>{let t=this.createUrl("/api/v1/project-map",{...e,projectMapId:e.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectMap:e.projectMap})})).projectMapId};this.deleteProjectMap=async e=>{let t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectMapId:e.projectMapId}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:e.projectId,projectMapId:e.projectMapId,nodes:e.nodes.map(p=>({...p,node:{...this.cleanProjectMapNode(p.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let t=this.createUrl("/api/v1/project-map-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectMapId:e.projectMapId}),expectNoContent:!0})};this.getSubtree=async e=>{var h;let t={};t.projectId=e.projectId,e.projectMapId?t.projectMapId=e.projectMapId:e.path&&this.validatePath(e.path)?t.path=e.path:e.compositionId&&(t.compositionId=e.compositionId),e.depth&&(t.depth=e.depth.toString()),e.expanded&&(t.expanded="true"),t.tree="true";let p=this.createUrl("/api/v1/project-map-nodes",t),M={...(await this.apiClient(p)).tree},o=[M];for(;o&&o.length>0;){let i=o.pop(),s;(h=i==null?void 0:i.children)==null||h.forEach(c=>{c.parent=j(i),c.previousSibling=j(s),s&&(s.nextSibling=j(c)),s=c,o.push(c)})}return M};this.getNodes=async e=>{let t={};t.projectId=e.projectId,e.projectMapId&&(t.projectMapId=e.projectMapId),e.projectMapId?t.projectMapId=e.projectMapId:e.path&&this.validatePath(e.path)?t.path=e.path:e.compositionId&&(t.compositionId=e.compositionId),e.limit&&(t.limit=e.limit.toString()),e.offset&&(t.offset=e.offset.toString()),e.expanded&&(t.expanded="true");let p=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(p)}}cleanProjectMapNode(e){var t,p,d;return{id:((d=(p=(t=e.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:p.length)!=null?d:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,compositionId:e.compositionId,description:e.description}}validatePath(e){let t=/[*%!&@]/g;if(e==null?void 0:e.match(t))throw"Path cannot contain reserved characters * % ! & @";return!0}},P=class extends u{constructor(a){super({...a,bypassCache:!0})}},j=r=>r?{...r,parent:void 0,children:void 0}:void 0;export{y as a,U as b,b as c,S as d,C as e,v as f,O as g,u as h,P as i};
|
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.fetchProjectMapDefinitions=async p=>{let t=this.createUrl("/api/v1/sitemap",{projectId:p});return await this.apiClient(t)};this.fetchProjectMapDefinition=async p=>{let t=this.createUrl("/api/v1/sitemap",{...p,sitemapId:p.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async p=>{let t=this.createUrl("/api/v1/sitemap");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...p,sitemap:p.projectMap,projectMap:void 0})})).sitemapId};this.deleteProjectMap=async p=>{let t=this.createUrl("/api/v1/sitemap");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,sitemapId:p.projectMapId,projectMapId:void 0}),expectNoContent:!0})};this.upsertProjectMapNodes=async p=>{let t=this.createUrl("/api/v1/sitemap-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:p.projectId,sitemapId: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/sitemap-nodes");(!p.path||this.validatePath(p.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...p,sitemapId:p.projectMapId}),expectNoContent:!0})};this.fetchSubtree=async p=>{var s;let t={};t.projectId=p.projectId,p.projectMapId&&(t.sitemapId=p.projectMapId),p.path&&this.validatePath(p.path)&&(t.path=p.path),p.depth&&(t.depth=p.depth.toString()),t.tree="true";let i=this.createUrl("/api/v1/sitemap-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.fetchNodes=async p=>{let t={};t.projectId=p.projectId,p.projectMapId&&(t.sitemapId=p.projectMapId),p.path&&this.validatePath(p.path)&&(t.path=p.path),p.id&&(t.id=p.id),p.limit&&(t.limit=p.limit.toString()),p.offset&&(t.offset=p.offset.toString());let i=this.createUrl("/api/v1/sitemap-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}).fetchNodes({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",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}).fetchNodes({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.fetchProjectMapDefinitions(a)).sitemaps;for(let i of t){let r=(await e.fetchNodes({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.fetchNodes({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:["smn"],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}).fetchProjectMapDefinition({projectMapId:t,projectId:r});o.sitemaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):w1(o.sitemaps[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}).fetchProjectMapDefinitions(r);w1(s.sitemaps,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.fetchProjectMapDefinitions(a)).sitemaps;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:["smd"],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:["sm"],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,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});
|
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ee,b as Zd,c as H,d as Qd,e as Fp,f as Xd,g as e2,i as re}from"../chunk-
|
|
1
|
+
import{a as ee,b as Zd,c as H,d as Qd,e as Fp,f as Xd,g as e2,i as re}from"../chunk-PFKTXWY5.mjs";var z0=H((Q7,W0)=>{var ka=1e3,qa=ka*60,Ha=qa*60,Sa=Ha*24,Sl=Sa*7,Al=Sa*365.25;W0.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return Cl(e);if(p==="number"&&isFinite(e))return a.long?El(e):Nl(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Cl(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*Al;case"weeks":case"week":case"w":return p*Sl;case"days":case"day":case"d":return p*Sa;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Ha;case"minutes":case"minute":case"mins":case"min":case"m":return p*qa;case"seconds":case"second":case"secs":case"sec":case"s":return p*ka;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function Nl(e){var a=Math.abs(e);return a>=Sa?Math.round(e/Sa)+"d":a>=Ha?Math.round(e/Ha)+"h":a>=qa?Math.round(e/qa)+"m":a>=ka?Math.round(e/ka)+"s":e+"ms"}function El(e){var a=Math.abs(e);return a>=Sa?tt(e,a,Sa,"day"):a>=Ha?tt(e,a,Ha,"hour"):a>=qa?tt(e,a,qa,"minute"):a>=ka?tt(e,a,ka,"second"):e+" ms"}function tt(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var Ni=H((X7,Y0)=>{function Dl(e){p.debug=p,p.default=p,p.coerce=s,p.disable=r,p.enable=i,p.enabled=d,p.humanize=z0(),p.destroy=o,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,v;function g(...h){if(!g.enabled)return;let x=g,S=Number(new Date),F=S-(m||S);x.diff=F,x.prev=m,x.curr=S,m=S,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let M=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(V,T)=>{if(V==="%%")return"%";M++;let G=p.formatters[T];if(typeof G=="function"){let Q=h[M];V=G.call(x,Q),h.splice(M,1),M--}return V}),p.formatArgs.call(x,h),(x.log||p.log).apply(x,h)}return g.namespace=l,g.useColors=p.useColors(),g.color=p.selectColor(l),g.extend=t,g.destroy=p.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,v=p.enabled(l)),v),set:h=>{c=h}}),typeof p.init=="function"&&p.init(g),g}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function s(l){return l instanceof Error?l.stack||l.message:l}function o(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}Y0.exports=Dl});var G0=H((We,it)=>{We.formatArgs=Tl;We.save=Pl;We.load=jl;We.useColors=Ol;We.storage=Fl();We.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();We.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Ol(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Tl(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+it.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}We.log=console.debug||console.log||(()=>{});function Pl(e){try{e?We.storage.setItem("debug",e):We.storage.removeItem("debug")}catch(a){}}function jl(){let e;try{e=We.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function Fl(){try{return localStorage}catch(e){}}it.exports=Ni()(We);var{formatters:Ml}=it.exports;Ml.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var J0=H((em,K0)=>{"use strict";K0.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var X0=H((am,Q0)=>{"use strict";var Il=ee("os"),Z0=ee("tty"),Xe=J0(),{env:Ee}=process,U1;Xe("no-color")||Xe("no-colors")||Xe("color=false")||Xe("color=never")?U1=0:(Xe("color")||Xe("colors")||Xe("color=true")||Xe("color=always"))&&(U1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?U1=1:Ee.FORCE_COLOR==="false"?U1=0:U1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function Ei(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Di(e,a){if(U1===0)return 0;if(Xe("color=16m")||Xe("color=full")||Xe("color=truecolor"))return 3;if(Xe("color=256"))return 2;if(e&&!a&&U1===void 0)return 0;let p=U1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=Il.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ee)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ee)||Ee.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ee)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ee.TEAMCITY_VERSION)?1:0;if(Ee.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ee){let t=parseInt((Ee.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ee.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ee.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ee.TERM)||"COLORTERM"in Ee?1:p}function Vl(e){let a=Di(e,e&&e.isTTY);return Ei(a)}Q0.exports={supportsColor:Vl,stdout:Ei(Di(!0,Z0.isatty(1))),stderr:Ei(Di(!0,Z0.isatty(2)))}});var ar=H((Te,rt)=>{var Ll=ee("tty"),dt=ee("util");Te.init=Hl;Te.log=$l;Te.formatArgs=Rl;Te.save=kl;Te.load=ql;Te.useColors=Bl;Te.destroy=dt.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Te.colors=[6,2,3,4,5,1];try{let e=X0();e&&(e.stderr||e).level>=2&&(Te.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Te.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function Bl(){return"colors"in Te.inspectOpts?Boolean(Te.inspectOpts.colors):Ll.isatty(process.stderr.fd)}function Rl(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
|
|
2
2
|
`).join(`
|
|
3
3
|
`+r),e.push(i+"m+"+rt.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Ul()+a+" "+e[0]}function Ul(){return Te.inspectOpts.hideDate?"":new Date().toISOString()+" "}function $l(...e){return process.stderr.write(dt.format(...e)+`
|
|
4
4
|
`)}function kl(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function ql(){return process.env.DEBUG}function Hl(e){e.inspectOpts={};let a=Object.keys(Te.inspectOpts);for(let p=0;p<a.length;p++)e.inspectOpts[a[p]]=Te.inspectOpts[a[p]]}rt.exports=Ni()(Te);var{formatters:er}=rt.exports;er.o=function(e){return this.inspectOpts.colors=this.useColors,dt.inspect(e,this.inspectOpts).split(`
|
|
@@ -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}).fetchNodes({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",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}).fetchNodes({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.fetchProjectMapDefinitions(a)).sitemaps;for(let i of t){let r=(await e.fetchNodes({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.fetchNodes({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:["smn"],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}).fetchProjectMapDefinition({projectMapId:t,projectId:r});o.sitemaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):g1(o.sitemaps[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}).fetchProjectMapDefinitions(r);g1(s.sitemaps,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.fetchProjectMapDefinitions(a)).sitemaps;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:["smd"],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:["sm"],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,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};
|
|
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/index.d.ts
CHANGED
|
@@ -1,36 +1,450 @@
|
|
|
1
1
|
import { ApiClient } from '@uniformdev/context/api';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file was auto-generated by openapi-typescript.
|
|
5
|
+
* Do not make direct changes to the file.
|
|
6
|
+
*/
|
|
7
|
+
interface paths$1 {
|
|
8
|
+
"/api/v1/project-map-nodes": {
|
|
9
|
+
/** Called to get a list of nodes belonging to a specific path or Id */
|
|
10
|
+
get: {
|
|
11
|
+
parameters: {
|
|
12
|
+
query: {
|
|
13
|
+
/** The project map id that the desired nodes belong */
|
|
14
|
+
projectMapId: string;
|
|
15
|
+
/** The project id that contains the project map tree that this node belongs to */
|
|
16
|
+
projectId: string;
|
|
17
|
+
/** The id of the node to retrieve, cannot have both this parameter and Path */
|
|
18
|
+
id?: string;
|
|
19
|
+
/** The path of the root node to retrieve, cannot have both this parameter and Id */
|
|
20
|
+
path?: string;
|
|
21
|
+
/** Composition id to find associated sitemap nodes for */
|
|
22
|
+
compositionId?: string;
|
|
23
|
+
/** Limit the number or records returned by a number */
|
|
24
|
+
limit?: number;
|
|
25
|
+
/** Number of records to skip before returning nodes */
|
|
26
|
+
offset?: number;
|
|
27
|
+
/** Depth of the tree to fetch */
|
|
28
|
+
depth?: number;
|
|
29
|
+
/** should the data be returned as a json tree object */
|
|
30
|
+
tree?: boolean;
|
|
31
|
+
/** text search filter */
|
|
32
|
+
search?: string;
|
|
33
|
+
/** include expanded helper computed properties, includes isLeaf, parentPath, pathSegment */
|
|
34
|
+
expanded?: boolean;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
responses: {
|
|
38
|
+
/** OK */
|
|
39
|
+
200: {
|
|
40
|
+
content: {
|
|
41
|
+
"application/json": {
|
|
42
|
+
nodes?: components$1["schemas"]["ProjectMapNodeDefinition"][];
|
|
43
|
+
tree?: external$1["v1-project-map-tree.swagger.yml"]["components"]["schemas"]["ProjectMapTreeNodeDefinition"];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
400: external$1["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
48
|
+
401: external$1["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
49
|
+
403: external$1["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
50
|
+
429: external$1["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
51
|
+
500: external$1["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/** Called to insert or update a node or nodes */
|
|
55
|
+
put: {
|
|
56
|
+
responses: {
|
|
57
|
+
/** OK */
|
|
58
|
+
204: never;
|
|
59
|
+
400: external$1["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
60
|
+
401: external$1["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
61
|
+
403: external$1["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
62
|
+
429: external$1["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
63
|
+
500: external$1["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
64
|
+
};
|
|
65
|
+
requestBody: {
|
|
66
|
+
content: {
|
|
67
|
+
"application/json": {
|
|
68
|
+
/** @description An array of projectMap node objects to be updated or inserted */
|
|
69
|
+
nodes: {
|
|
70
|
+
node: components$1["schemas"]["ProjectMapNodeUpdate"];
|
|
71
|
+
/** @description The path of the node directly prior to the location where the current node is desired to go or undefined if there isn't one */
|
|
72
|
+
previousSibling?: string;
|
|
73
|
+
/** @description The path of the node directly after the location where the current node is desired to go or undefined if there isn't one */
|
|
74
|
+
nextSibling?: string;
|
|
75
|
+
}[];
|
|
76
|
+
/**
|
|
77
|
+
* Format: uuid
|
|
78
|
+
* @description The project id of the project that the projectMap belongs to
|
|
79
|
+
*/
|
|
80
|
+
projectId: string;
|
|
81
|
+
/**
|
|
82
|
+
* Format: uuid
|
|
83
|
+
* @description The projectMap id that the changing or inserting nodes belong to
|
|
84
|
+
*/
|
|
85
|
+
projectMapId: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
/** Called to delete a particular projectMap node by id or path */
|
|
91
|
+
delete: {
|
|
92
|
+
responses: {
|
|
93
|
+
/** OK */
|
|
94
|
+
204: never;
|
|
95
|
+
400: external$1["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
96
|
+
401: external$1["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
97
|
+
403: external$1["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
98
|
+
429: external$1["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
99
|
+
500: external$1["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
100
|
+
};
|
|
101
|
+
requestBody: {
|
|
102
|
+
content: {
|
|
103
|
+
"application/json": {
|
|
104
|
+
/**
|
|
105
|
+
* Format: uuid
|
|
106
|
+
* @description Id of the projectMap node to delete
|
|
107
|
+
*/
|
|
108
|
+
nodeId?: string;
|
|
109
|
+
/** @description Path to the projectMap node to delete */
|
|
110
|
+
path: string;
|
|
111
|
+
/**
|
|
112
|
+
* Format: uuid
|
|
113
|
+
* @description Project map id that the node to delete belongs to
|
|
114
|
+
*/
|
|
115
|
+
projectMapId: string;
|
|
116
|
+
/**
|
|
117
|
+
* Format: uuid
|
|
118
|
+
* @description Project id that the project map belongs to
|
|
119
|
+
*/
|
|
120
|
+
projectId: string;
|
|
121
|
+
} | {
|
|
122
|
+
/**
|
|
123
|
+
* Format: uuid
|
|
124
|
+
* @description Id of the projectMap node to delete
|
|
125
|
+
*/
|
|
126
|
+
nodeId: string;
|
|
127
|
+
/** @description Path to the projectMap node to delete */
|
|
128
|
+
path?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Format: uuid
|
|
131
|
+
* @description Project map id that the node to delete belongs to
|
|
132
|
+
*/
|
|
133
|
+
projectMapId: string;
|
|
134
|
+
/**
|
|
135
|
+
* Format: uuid
|
|
136
|
+
* @description Project id that the project map belongs to
|
|
137
|
+
*/
|
|
138
|
+
projectId: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface components$1 {
|
|
146
|
+
schemas: {
|
|
147
|
+
ProjectMapNodeDefinition: {
|
|
148
|
+
/**
|
|
149
|
+
* Format: uuid
|
|
150
|
+
* @description The id of the projectMap entry
|
|
151
|
+
*/
|
|
152
|
+
id: string;
|
|
153
|
+
/** @description Dot delimited path representing the path to the current node */
|
|
154
|
+
path: string;
|
|
155
|
+
/** @description Ordering of the node, higher numbers go after lower numbers. */
|
|
156
|
+
order?: number;
|
|
157
|
+
/** @description Data associated with this projectMap node */
|
|
158
|
+
data?: {
|
|
159
|
+
[key: string]: unknown;
|
|
160
|
+
};
|
|
161
|
+
/** @description The name of the projectMap entry */
|
|
162
|
+
name: string;
|
|
163
|
+
/**
|
|
164
|
+
* @description The type of the projectMap entry
|
|
165
|
+
* @enum {string}
|
|
166
|
+
*/
|
|
167
|
+
type: "composition" | "redirect" | "placeholder";
|
|
168
|
+
/**
|
|
169
|
+
* Format: uuid
|
|
170
|
+
* @description The composition id related to the projectMap entry
|
|
171
|
+
*/
|
|
172
|
+
compositionId?: string;
|
|
173
|
+
/** @description Description of the projectMap node */
|
|
174
|
+
description?: string;
|
|
175
|
+
/** @description Parent path of the current node, only included if requested with the expanded flag */
|
|
176
|
+
parentPath?: string;
|
|
177
|
+
/** @description Last segment of the url, only included if requested with the expanded flag */
|
|
178
|
+
pathSegment?: string;
|
|
179
|
+
/** @description returns true if the node is a leaf node, meaning having no children, only included if requested with the expanded flag */
|
|
180
|
+
isLeaf?: boolean;
|
|
181
|
+
};
|
|
182
|
+
ProjectMapNodeUpdate: {
|
|
183
|
+
/**
|
|
184
|
+
* Format: uuid
|
|
185
|
+
* @description The id of the projectMap entry
|
|
186
|
+
*/
|
|
187
|
+
id?: string;
|
|
188
|
+
/** @description Dot delimited path representing the path to the current node */
|
|
189
|
+
path: string;
|
|
190
|
+
/** @description Ordering of the node, higher numbers go after lower numbers. */
|
|
191
|
+
order?: number;
|
|
192
|
+
/** @description Data associated with this projectMap node */
|
|
193
|
+
data?: {
|
|
194
|
+
[key: string]: unknown;
|
|
195
|
+
};
|
|
196
|
+
/** @description The name of the projectMap entry */
|
|
197
|
+
name: string;
|
|
198
|
+
/**
|
|
199
|
+
* @description The type of the projectMap entry
|
|
200
|
+
* @enum {string}
|
|
201
|
+
*/
|
|
202
|
+
type: "composition" | "redirect" | "placeholder";
|
|
203
|
+
/**
|
|
204
|
+
* Format: uuid
|
|
205
|
+
* @description The composition id related to the projectMap entry
|
|
206
|
+
*/
|
|
207
|
+
compositionId?: string;
|
|
208
|
+
/** @description Description of the projectMap node */
|
|
209
|
+
description?: string;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
interface external$1 {
|
|
214
|
+
"swagger.yml": {
|
|
215
|
+
paths: {};
|
|
216
|
+
components: {
|
|
217
|
+
schemas: {
|
|
218
|
+
Error: {
|
|
219
|
+
/** @description Error message(s) that occurred while processing the request */
|
|
220
|
+
errorMessage?: string[] | string;
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
responses: {
|
|
224
|
+
/** Request input validation failed */
|
|
225
|
+
BadRequestError: {
|
|
226
|
+
content: {
|
|
227
|
+
"application/json": external$1["swagger.yml"]["components"]["schemas"]["Error"];
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
/** API key or token was not valid */
|
|
231
|
+
UnauthorizedError: {
|
|
232
|
+
content: {
|
|
233
|
+
"application/json": external$1["swagger.yml"]["components"]["schemas"]["Error"];
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
/** Permission was denied */
|
|
237
|
+
ForbiddenError: {
|
|
238
|
+
content: {
|
|
239
|
+
"application/json": external$1["swagger.yml"]["components"]["schemas"]["Error"];
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
/** Resource not found */
|
|
243
|
+
NotFoundError: {
|
|
244
|
+
content: {
|
|
245
|
+
"application/json": external$1["swagger.yml"]["components"]["schemas"]["Error"];
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
/** Too many requests in allowed time period */
|
|
249
|
+
RateLimitError: unknown;
|
|
250
|
+
/** Execution error occurred */
|
|
251
|
+
InternalServerError: unknown;
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
operations: {};
|
|
255
|
+
};
|
|
256
|
+
"v1-project-map-tree.swagger.yml": {
|
|
257
|
+
paths: {};
|
|
258
|
+
components: {
|
|
259
|
+
schemas: {
|
|
260
|
+
ProjectMapTreeNodeDefinition: components$1["schemas"]["ProjectMapNodeDefinition"] & {
|
|
261
|
+
/** @description Children of the node */
|
|
262
|
+
children?: external$1["v1-project-map-tree.swagger.yml"]["components"]["schemas"]["ProjectMapTreeNodeDefinition"][];
|
|
263
|
+
} & {
|
|
264
|
+
name: unknown;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
operations: {};
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* This file was auto-generated by openapi-typescript.
|
|
274
|
+
* Do not make direct changes to the file.
|
|
275
|
+
*/
|
|
276
|
+
interface paths {
|
|
277
|
+
"/api/v1/project-map": {
|
|
278
|
+
/** Called to retrieve a list of project maps related to a project or a specific project map by id */
|
|
279
|
+
get: {
|
|
280
|
+
parameters: {
|
|
281
|
+
query: {
|
|
282
|
+
/** The project to fetch project map for */
|
|
283
|
+
projectId: string;
|
|
284
|
+
/** The id of the project map to fetch */
|
|
285
|
+
projectMapId?: string;
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
responses: {
|
|
289
|
+
/** OK */
|
|
290
|
+
200: {
|
|
291
|
+
content: {
|
|
292
|
+
"application/json": {
|
|
293
|
+
projectMaps: components["schemas"]["ProjectMapDefinition"][];
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
298
|
+
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
299
|
+
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
300
|
+
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
301
|
+
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
put: {
|
|
305
|
+
responses: {
|
|
306
|
+
/** OK */
|
|
307
|
+
200: {
|
|
308
|
+
content: {
|
|
309
|
+
"application/json": {
|
|
310
|
+
/**
|
|
311
|
+
* Format: uuid
|
|
312
|
+
* @description Id of the projectMap
|
|
313
|
+
*/
|
|
314
|
+
projectMapId: string;
|
|
315
|
+
};
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
/** OK */
|
|
319
|
+
204: never;
|
|
320
|
+
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
321
|
+
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
322
|
+
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
323
|
+
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
324
|
+
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
325
|
+
};
|
|
326
|
+
requestBody: {
|
|
327
|
+
content: {
|
|
328
|
+
"application/json": {
|
|
329
|
+
/** @description Project map object to insert */
|
|
330
|
+
projectMap: components["schemas"]["ProjectMapDefinition"];
|
|
331
|
+
/**
|
|
332
|
+
* Format: uuid
|
|
333
|
+
* @description Project id to insert the projectMap into
|
|
334
|
+
*/
|
|
335
|
+
projectId: string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
/** Called to delete a projectMap */
|
|
341
|
+
delete: {
|
|
342
|
+
responses: {
|
|
343
|
+
/** OK */
|
|
344
|
+
204: never;
|
|
345
|
+
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
|
346
|
+
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
|
347
|
+
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
|
348
|
+
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
|
349
|
+
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
|
350
|
+
};
|
|
351
|
+
requestBody: {
|
|
352
|
+
content: {
|
|
353
|
+
"application/json": {
|
|
354
|
+
/**
|
|
355
|
+
* Format: uuid
|
|
356
|
+
* @description Id of the project that this projectMap belongs to
|
|
357
|
+
*/
|
|
358
|
+
projectId: string;
|
|
359
|
+
/**
|
|
360
|
+
* Format: uuid
|
|
361
|
+
* @description Id of the projectMap to delete
|
|
362
|
+
*/
|
|
363
|
+
projectMapId: string;
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
interface components {
|
|
371
|
+
schemas: {
|
|
372
|
+
ProjectMapDefinition: {
|
|
373
|
+
/** @description The id of the projectMap node */
|
|
374
|
+
id?: string;
|
|
375
|
+
/** @description The name of the projectMap node */
|
|
376
|
+
name: string;
|
|
377
|
+
/** @description Description of the projectMap node */
|
|
378
|
+
description?: string;
|
|
379
|
+
/** @description The prefix of the url generated by this projectMap */
|
|
380
|
+
baseUrl?: string;
|
|
381
|
+
default?: boolean;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
interface external {
|
|
386
|
+
"swagger.yml": {
|
|
387
|
+
paths: {};
|
|
388
|
+
components: {
|
|
389
|
+
schemas: {
|
|
390
|
+
Error: {
|
|
391
|
+
/** @description Error message(s) that occurred while processing the request */
|
|
392
|
+
errorMessage?: string[] | string;
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
responses: {
|
|
396
|
+
/** Request input validation failed */
|
|
397
|
+
BadRequestError: {
|
|
398
|
+
content: {
|
|
399
|
+
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
/** API key or token was not valid */
|
|
403
|
+
UnauthorizedError: {
|
|
404
|
+
content: {
|
|
405
|
+
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
/** Permission was denied */
|
|
409
|
+
ForbiddenError: {
|
|
410
|
+
content: {
|
|
411
|
+
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
/** Resource not found */
|
|
415
|
+
NotFoundError: {
|
|
416
|
+
content: {
|
|
417
|
+
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
|
418
|
+
};
|
|
419
|
+
};
|
|
420
|
+
/** Too many requests in allowed time period */
|
|
421
|
+
RateLimitError: unknown;
|
|
422
|
+
/** Execution error occurred */
|
|
423
|
+
InternalServerError: unknown;
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
operations: {};
|
|
427
|
+
};
|
|
428
|
+
}
|
|
3
429
|
|
|
4
430
|
declare type ProjectMapNodeWithProjectMapReference = ProjectMapNodeWithId & {
|
|
5
431
|
projectMapId: string;
|
|
6
432
|
};
|
|
7
433
|
|
|
8
|
-
declare type ProjectMapNodeUpsertRequest =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare type
|
|
12
|
-
declare type
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
declare type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
declare type
|
|
19
|
-
declare type
|
|
20
|
-
declare type
|
|
21
|
-
declare type
|
|
22
|
-
projectMapId: string;
|
|
23
|
-
};
|
|
24
|
-
declare type ProjectMapGetResponse = SitemapGetResponse;
|
|
25
|
-
declare type ProjectMapUpsertRequest = Omit<SitemapUpsertRequest, 'sitemap'> & {
|
|
26
|
-
projectMap: SitemapUpsertRequest['sitemap'];
|
|
27
|
-
};
|
|
28
|
-
declare type ProjectMapDeleteRequest = Omit<SitemapDeleteRequest, 'sitemapId'> & {
|
|
29
|
-
projectMapId: string;
|
|
30
|
-
};
|
|
31
|
-
declare type ProjectMapDefinition = SitemapDefinition;
|
|
32
|
-
declare type ProjectMapDefinitionWithId = SitemapDefinitionWithId;
|
|
33
|
-
declare type ProjectMapUpsertResponse = SitemapUpsertResponse;
|
|
434
|
+
declare type ProjectMapNodeUpsertRequest = paths$1['/api/v1/project-map-nodes']['put']['requestBody']['content']['application/json'];
|
|
435
|
+
declare type ProjectMapNodeUpsertRequestNode = ProjectMapNodeUpsertRequest['nodes'][0]['node'];
|
|
436
|
+
declare type ProjectMapNodeDeleteRequest = paths$1['/api/v1/project-map-nodes']['delete']['requestBody']['content']['application/json'];
|
|
437
|
+
declare type ProjectMapNodeGetRequest = paths$1['/api/v1/project-map-nodes']['get']['parameters']['query'];
|
|
438
|
+
declare type ProjectMapNodeGetResponse = paths$1['/api/v1/project-map-nodes']['get']['responses']['200']['content']['application/json'];
|
|
439
|
+
declare type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
|
|
440
|
+
declare type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
|
|
441
|
+
declare type ProjectMapGetRequest = paths['/api/v1/project-map']['get']['parameters']['query'];
|
|
442
|
+
declare type ProjectMapGetResponse = paths['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
|
|
443
|
+
declare type ProjectMapUpsertRequest = paths['/api/v1/project-map']['put']['requestBody']['content']['application/json'];
|
|
444
|
+
declare type ProjectMapDeleteRequest = paths['/api/v1/project-map']['delete']['requestBody']['content']['application/json'];
|
|
445
|
+
declare type ProjectMapDefinition = ProjectMapGetResponse['projectMaps'][0];
|
|
446
|
+
declare type ProjectMapDefinitionWithId = ProjectMapDefinition & Required<Pick<ProjectMapDefinition, 'id'>>;
|
|
447
|
+
declare type ProjectMapUpsertResponse = paths['/api/v1/project-map']['put']['responses']['200']['content']['application/json'];
|
|
34
448
|
declare type NodeType = 'placeholder' | 'composition' | 'redirect';
|
|
35
449
|
declare type ProjectMapDefinitions = {
|
|
36
450
|
projectMaps: ProjectMapDefinitionWithId[];
|
|
@@ -58,8 +472,8 @@ declare type ProjectMapSubtree = ProjectMapNode & {
|
|
|
58
472
|
};
|
|
59
473
|
declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
|
|
60
474
|
constructor(options: ProjectMapClientOptions);
|
|
61
|
-
|
|
62
|
-
|
|
475
|
+
getProjectMapDefinitions: (projectId: string) => Promise<{
|
|
476
|
+
projectMaps: {
|
|
63
477
|
id?: string | undefined;
|
|
64
478
|
name: string;
|
|
65
479
|
description?: string | undefined;
|
|
@@ -67,8 +481,8 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
|
|
|
67
481
|
default?: boolean | undefined;
|
|
68
482
|
}[];
|
|
69
483
|
}>;
|
|
70
|
-
|
|
71
|
-
|
|
484
|
+
getProjectMapDefinition: (options: ProjectMapGetRequest) => Promise<{
|
|
485
|
+
projectMaps: {
|
|
72
486
|
id?: string | undefined;
|
|
73
487
|
name: string;
|
|
74
488
|
description?: string | undefined;
|
|
@@ -80,8 +494,8 @@ declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
|
|
|
80
494
|
deleteProjectMap: (options: ProjectMapDeleteRequest) => Promise<void>;
|
|
81
495
|
upsertProjectMapNodes: (options: ProjectMapNodeUpsertRequest) => Promise<void>;
|
|
82
496
|
deleteProjectMapNode: (options: ProjectMapNodeDeleteRequest) => Promise<void>;
|
|
83
|
-
|
|
84
|
-
|
|
497
|
+
getSubtree: (options: ProjectMapNodeGetRequest) => Promise<ProjectMapSubtree | undefined>;
|
|
498
|
+
getNodes: (options: ProjectMapNodeGetRequest) => Promise<ProjectMapNodeGetResponse>;
|
|
85
499
|
private cleanProjectMapNode;
|
|
86
500
|
private validatePath;
|
|
87
501
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as o,h as r,i as e}from"./chunk-
|
|
1
|
+
import{g as o,h as r,i as e}from"./chunk-PFKTXWY5.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(a,p)=>{for(var e in p)j(a,e,{get:p[e],enumerable:!0})},R=(a,p,e,t)=>{if(p&&typeof p=="object"||typeof p=="function")for(let r of m(p))!I.call(a,r)&&r!==e&&j(a,r,{get:()=>p[r],enumerable:!(t=l(p,r))||t.enumerable});return a};var g=a=>R(j({},"__esModule",{value:!0}),a);var U={};N(U,{ProjectMapClient:()=>n,ROOT_NODE_PATH:()=>y,UncachedProjectMapClient:()=>M});module.exports=g(U);var P=require("@uniformdev/context/api"),y="/",n=class extends P.ApiClient{constructor(e){super(e);this.getProjectMapDefinitions=async e=>{let t=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(t)};this.getProjectMapDefinition=async e=>{let t=this.createUrl("/api/v1/project-map",{...e,projectMapId:e.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectMap:e.projectMap})})).projectMapId};this.deleteProjectMap=async e=>{let t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectMapId:e.projectMapId}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:e.projectId,projectMapId:e.projectMapId,nodes:e.nodes.map(r=>({...r,node:{...this.cleanProjectMapNode(r.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let t=this.createUrl("/api/v1/project-map-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectMapId:e.projectMapId}),expectNoContent:!0})};this.getSubtree=async e=>{var f;let t={};t.projectId=e.projectId,e.projectMapId?t.projectMapId=e.projectMapId:e.path&&this.validatePath(e.path)?t.path=e.path:e.compositionId&&(t.compositionId=e.compositionId),e.depth&&(t.depth=e.depth.toString()),e.expanded&&(t.expanded="true"),t.tree="true";let r=this.createUrl("/api/v1/project-map-nodes",t),h={...(await this.apiClient(r)).tree},o=[h];for(;o&&o.length>0;){let i=o.pop(),s;(f=i==null?void 0:i.children)==null||f.forEach(c=>{c.parent=u(i),c.previousSibling=u(s),s&&(s.nextSibling=u(c)),s=c,o.push(c)})}return h};this.getNodes=async e=>{let t={};t.projectId=e.projectId,e.projectMapId&&(t.projectMapId=e.projectMapId),e.projectMapId?t.projectMapId=e.projectMapId:e.path&&this.validatePath(e.path)?t.path=e.path:e.compositionId&&(t.compositionId=e.compositionId),e.limit&&(t.limit=e.limit.toString()),e.offset&&(t.offset=e.offset.toString()),e.expanded&&(t.expanded="true");let r=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(r)}}cleanProjectMapNode(e){var t,r,d;return{id:((d=(r=(t=e.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:r.length)!=null?d:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,compositionId:e.compositionId,description:e.description}}validatePath(e){let t=/[*%!&@]/g;if(e==null?void 0:e.match(t))throw"Path cannot contain reserved characters * % ! & @";return!0}},M=class extends n{constructor(p){super({...p,bypassCache:!0})}},u=a=>a?{...a,parent:void 0,children:void 0}:void 0;0&&(module.exports={ProjectMapClient,ROOT_NODE_PATH,UncachedProjectMapClient});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as o,h as r,i as e}from"./chunk-
|
|
1
|
+
import{g as o,h as r,i as e}from"./chunk-PFKTXWY5.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/project-map",
|
|
3
|
-
"version": "17.
|
|
4
|
-
"description": "Uniform
|
|
3
|
+
"version": "17.4.0",
|
|
4
|
+
"description": "Uniform Project Map",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.esm.js",
|
|
@@ -32,31 +32,31 @@
|
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "run-s build:ts",
|
|
35
|
+
"build": "run-s update-openapi build:ts",
|
|
36
36
|
"build:ts": "tsup --minify",
|
|
37
|
-
"dev": "run-s dev:ts",
|
|
37
|
+
"dev": "run-s update-openapi dev:ts",
|
|
38
38
|
"dev:ts": "tsup --watch",
|
|
39
39
|
"clean": "rimraf dist",
|
|
40
40
|
"test": "jest --maxWorkers=1 --passWithNoTests",
|
|
41
41
|
"lint": "eslint \"src/**/*.{js,ts,tsx}\"",
|
|
42
|
-
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
42
|
+
"format": "prettier --write \"src/**/*.{js,ts,tsx}\"",
|
|
43
|
+
"update-openapi": "tsx ./scripts/update-openapi.cts"
|
|
43
44
|
},
|
|
44
45
|
"files": [
|
|
45
46
|
"/dist"
|
|
46
47
|
],
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@uniformdev/canvas": "^17.
|
|
49
|
-
"@uniformdev/context": "^17.
|
|
50
|
-
"@uniformdev/sitemap": "^17.3.1-alpha.194+213d546fd",
|
|
49
|
+
"@uniformdev/canvas": "^17.4.0",
|
|
50
|
+
"@uniformdev/context": "^17.4.0",
|
|
51
51
|
"p-limit": "^3.1.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/yargs": "17.0.13",
|
|
55
|
-
"@uniformdev/cli": "^17.
|
|
55
|
+
"@uniformdev/cli": "^17.4.0",
|
|
56
56
|
"yargs": "17.6.0"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "77580d40fbad3c838310f09824d29c067686fa64"
|
|
62
62
|
}
|
package/dist/chunk-QOYLUYYN.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var l=Object.create;var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var b=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(a,e)=>(typeof require!="undefined"?require:a)[e]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var g=(r,a)=>()=>(r&&(a=r(r=0)),a);var I=(r,a)=>()=>(a||r((a={exports:{}}).exports,a),a.exports),S=(r,a)=>{for(var e in a)n(r,e,{get:a[e],enumerable:!0})},M=(r,a,e,t)=>{if(a&&typeof a=="object"||typeof a=="function")for(let i of N(a))!y.call(r,i)&&i!==e&&n(r,i,{get:()=>a[i],enumerable:!(t=m(a,i))||t.enumerable});return r};var C=(r,a,e)=>(e=r!=null?l(R(r)):{},M(a||!r||!r.__esModule?n(e,"default",{value:r,enumerable:!0}):e,r)),v=r=>M(n({},"__esModule",{value:!0}),r);import{ApiClient as U}from"@uniformdev/context/api";var x="/",h=class extends U{constructor(e){super(e);this.fetchProjectMapDefinitions=async e=>{let t=this.createUrl("/api/v1/sitemap",{projectId:e});return await this.apiClient(t)};this.fetchProjectMapDefinition=async e=>{let t=this.createUrl("/api/v1/sitemap",{...e,sitemapId:e.projectMapId});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let t=this.createUrl("/api/v1/sitemap");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,sitemap:e.projectMap,projectMap:void 0})})).sitemapId};this.deleteProjectMap=async e=>{let t=this.createUrl("/api/v1/sitemap");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,sitemapId:e.projectMapId,projectMapId:void 0}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let t=this.createUrl("/api/v1/sitemap-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({projectId:e.projectId,sitemapId:e.projectMapId,nodes:e.nodes.map(i=>({...i,node:{...this.cleanProjectMapNode(i.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let t=this.createUrl("/api/v1/sitemap-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,sitemapId:e.projectMapId}),expectNoContent:!0})};this.fetchSubtree=async e=>{var f;let t={};t.projectId=e.projectId,e.projectMapId&&(t.sitemapId=e.projectMapId),e.path&&this.validatePath(e.path)&&(t.path=e.path),e.depth&&(t.depth=e.depth.toString()),t.tree="true";let i=this.createUrl("/api/v1/sitemap-nodes",t),j={...(await this.apiClient(i)).tree},s=[j];for(;s&&s.length>0;){let c=s.pop(),o;(f=c==null?void 0:c.children)==null||f.forEach(p=>{p.parent=u(c),p.previousSibling=u(o),o&&(o.nextSibling=u(p)),o=p,s.push(p)})}return j};this.fetchNodes=async e=>{let t={};t.projectId=e.projectId,e.projectMapId&&(t.sitemapId=e.projectMapId),e.path&&this.validatePath(e.path)&&(t.path=e.path),e.id&&(t.id=e.id),e.limit&&(t.limit=e.limit.toString()),e.offset&&(t.offset=e.offset.toString());let i=this.createUrl("/api/v1/sitemap-nodes",t);return await this.apiClient(i)}}cleanProjectMapNode(e){var t,i,d;return{id:((d=(i=(t=e.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?d:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,compositionId:e.compositionId,description:e.description}}validatePath(e){let t=/[*%!&@]/g;if(e==null?void 0:e.match(t))throw"path cannot contain reserved characters * % ! & @";return!0}},P=class extends h{constructor(a){super({...a,bypassCache:!0})}},u=r=>r?{...r,parent:void 0,children:void 0}:void 0;export{b as a,g as b,I as c,S as d,C as e,v as f,x as g,h,P as i};
|