@uniformdev/project-map 17.7.0 → 17.7.1-alpha.140
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OIOFUJKY.mjs → chunk-IEPGH77W.mjs} +1 -1
- package/dist/cli/cli.js +1 -1
- package/dist/cli/cli.mjs +1 -1
- package/dist/index.d.ts +20 -20
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
var M=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var U=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(o,e)=>(typeof require!="undefined"?require:o)[e]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var b=(r,o)=>()=>(r&&(o=r(r=0)),o);var S=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports),x=(r,o)=>{for(var e in o)d(r,e,{get:o[e],enumerable:!0})},l=(r,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of I(o))!g.call(r,t)&&t!==e&&d(r,t,{get:()=>o[t],enumerable:!(i=m(o,t))||i.enumerable});return r};var C=(r,o,e)=>(e=r!=null?M(N(r)):{},l(o||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),v=r=>l(d({},"__esModule",{value:!0}),r);import{ApiClient as R}from"@uniformdev/context/api";var G="/",u=class extends R{constructor(e){super(e);this.getProjectMapDefinitions=async()=>{let{projectId:e}=this.options,i=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(i)};this.getProjectMapDefinition=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map",{...e,projectId:i});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:i})})).projectMapId};this.deleteProjectMap=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:i}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:i,nodes:e.nodes.map(
|
|
1
|
+
var M=Object.create;var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var U=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(o,e)=>(typeof require!="undefined"?require:o)[e]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+r+'" is not supported')});var b=(r,o)=>()=>(r&&(o=r(r=0)),o);var S=(r,o)=>()=>(o||r((o={exports:{}}).exports,o),o.exports),x=(r,o)=>{for(var e in o)d(r,e,{get:o[e],enumerable:!0})},l=(r,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of I(o))!g.call(r,t)&&t!==e&&d(r,t,{get:()=>o[t],enumerable:!(i=m(o,t))||i.enumerable});return r};var C=(r,o,e)=>(e=r!=null?M(N(r)):{},l(o||!r||!r.__esModule?d(e,"default",{value:r,enumerable:!0}):e,r)),v=r=>l(d({},"__esModule",{value:!0}),r);import{ApiClient as R}from"@uniformdev/context/api";var G="/",u=class extends R{constructor(e){super(e);this.getProjectMapDefinitions=async()=>{let{projectId:e}=this.options,i=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(i)};this.getProjectMapDefinition=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map",{...e,projectId:i});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:i})})).projectMapId};this.deleteProjectMap=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:i}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:i,nodes:e.nodes.map(a=>({...a,node:{...this.cleanProjectMapNode(a.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let{projectId:i}=this.options,t=this.createUrl("/api/v1/project-map-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:i}),expectNoContent:!0})};this.getSubtree=async e=>{var P;let{projectId:i}=this.options,t={projectId:i,projectMapId:e.projectMapId};e.search?t.search=e.search:e.id?t.id=e.id: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 a=this.createUrl("/api/v1/project-map-nodes",t),j={...(await this.apiClient(a)).tree},s=[j];for(;s&&s.length>0;){let p=s.pop(),n;(P=p==null?void 0:p.children)==null||P.forEach(c=>{c.parent=h(p),c.previousSibling=h(n),n&&(n.nextSibling=h(c)),n=c,s.push(c)})}return j};this.getNodes=async e=>{let{projectId:i}=this.options,t={projectId:i};e.projectMapId&&(t.projectMapId=e.projectMapId),e.search?t.search=e.search:e.id?t.id=e.id: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 a=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(a)}}cleanProjectMapNode(e){var i,t,a;return{id:((a=(t=(i=e.id)==null?void 0:i.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:t.length)!=null?a:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,order:e.order,data:e.data,compositionId:e.compositionId,description:e.description}}validatePath(e){let i=/[*%!&@]/g;if(e==null?void 0:e.match(i))throw"Path cannot contain reserved characters * % ! & @";return!0}},f=class extends u{constructor(o){super({...o,bypassCache:!0})}},h=r=>r?{...r,parent:void 0,children:void 0}:void 0;export{U as a,b,S as c,x as d,C as e,v as f,G as g,u as h,f as i};
|
package/dist/cli/cli.js
CHANGED
|
@@ -116,7 +116,7 @@ ${v.join(`
|
|
|
116
116
|
`:""}var x9=_9,S9={dump:x9};function Gd(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 l6=Qn.load,bm=Qn.loadAll,m6=S9.dump;var ym=Gd("safeLoad","load"),_m=Gd("safeLoadAll","loadAll"),xm=Gd("safeDump","dump");var u2=require("path"),K6=l1(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=C9(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(A9(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 A9(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 C9(e){return{newPos:e.newPos,components:e.components.slice(0)}}var Am=new D1;var c6=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,u6=/\S/,f6=new D1;f6.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!u6.test(e)&&!u6.test(a)};f6.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]&&c6.test(a[p])&&c6.test(a[p+2])&&(a[p]+=a[p+2],a.splice(p+1,2),p--);return a};var Zd=new D1;Zd.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 Qd(e,a,p){return Zd.diff(e,a,p)}var N9=new D1;N9.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var E9=new D1;E9.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 D9=Object.prototype.toString,tp=new D1;tp.useLongestToken=!0;tp.tokenize=Zd.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(Kd(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 h6(e,a,p){return tp.diff(e,a,p)}function Kd(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(D9.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]=Kd(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]=Kd(e[s],a,p,t,s);a.pop(),p.pop()}else d=e;return d}var Jd=new D1;Jd.tokenize=function(e){return e.slice()};Jd.join=Jd.removeEmpty=function(e){return e};var Q6=l1(W6(),1);async function Z1({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 G5=Ni(Ei());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 G6.HttpsProxyAgent(e)};return(0,c2.default)(a,t)}return(0,c2.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 Q1(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 X1(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 ea(e){let a=(0,u2.extname)(e);return a===".yaml"||a===".yml"||a===".json"}function o1(e,a,p){let t;if(p&&!a){let i=(0,u2.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=m6(e);break;default:throw new Error(`Unsupported format: ${a}`)}p?(0,z6.writeFileSync)(p,t,"utf8"):console.log(t)}function op(e){let a=(0,Y6.readFileSync)(e,"utf8");return l6(a,{filename:e,json:!0})}async function aa({directory:e,format:a="yaml",selectIdentifier:p,selectDisplayName:t=p,selectFilename:i}){(0,zt.existsSync)(e)||(0,zt.mkdirSync)(e,{recursive:!0});let r=await(0,Yt.readdir)(e,"utf-8"),d=new Set(r.filter(o=>{let l=(0,sp.extname)(o);return l===".json"||l===".yaml"||l===".yml"})),n=o=>(0,sp.join)(e,`${o}.${a}`);async function*s(){for(let o of d){let l=(0,sp.join)(e,o);try{let m=await op(l);yield{id:p(m),displayName:t(m),providerId:l,object:m}}catch(m){throw console.error(G5.default.red(`Failed to read ${l}, data is likely invalid.
|
|
117
117
|
${m==null?void 0:m.message}`)),m}}}return{objects:s(),deleteObject:async o=>{await(0,Yt.unlink)(o)},writeObject:async o=>{i?o1(o.object,a,(0,sp.join)(e,`${i(o.object)}.${a}`)):o1(o.object,a,n(o.id))}}}function J6(e,a){if(!a&&!K6.default.existsSync(e))return{};let p=op(e);if(typeof p!="object")throw new Error(`Package ${e} does not appear valid.`);return p}function Z6(e,a){o1(a,void 0,e)}async function pa({source:e,target:a,compareContents:p=(n,s)=>(0,Q6.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:h6(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:Qd("",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:Qd(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=Ni(Ei());function ta(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 X6=require("@uniformdev/context/api");var h2=class extends X6.ApiClient{constructor(p){super(p);this.getProjectMapDefinitions=async()=>{let{projectId:p}=this.options,t=this.createUrl("/api/v1/project-map",{projectId:p});return await this.apiClient(t)};this.getProjectMapDefinition=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map",{...p,projectId:t});return await this.apiClient(i)};this.upsertProjectMap=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map");return(await this.apiClient(i,{method:"PUT",body:JSON.stringify({...p,projectId:t})})).projectMapId};this.deleteProjectMap=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map");await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...p,projectId:t}),expectNoContent:!0})};this.upsertProjectMapNodes=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...p,projectId:t,nodes:p.nodes.map(r=>({...r,node:{...this.cleanProjectMapNode(r.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map-nodes");(!p.path||this.validatePath(p.path))&&await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...p,projectId:t}),expectNoContent:!0})};this.getSubtree=async p=>{var o;let{projectId:t}=this.options,i={projectId:t,projectMapId:p.projectMapId};p.search?i.search=p.search:p.id?i.id=p.id:p.path&&this.validatePath(p.path)?i.path=p.path:p.compositionId&&(i.compositionId=p.compositionId),p.depth&&(i.depth=p.depth.toString()),p.expanded&&(i.expanded="true"),i.tree="true";let r=this.createUrl("/api/v1/project-map-nodes",i),n={...(await this.apiClient(r)).tree},s=[n];for(;s&&s.length>0;){let l=s.pop(),m;(o=l==null?void 0:l.children)==null||o.forEach(c=>{c.parent=f2(l),c.previousSibling=f2(m),m&&(m.nextSibling=f2(c)),m=c,s.push(c)})}return n};this.getNodes=async p=>{let{projectId:t}=this.options,i={projectId:t};p.projectMapId&&(i.projectMapId=p.projectMapId),p.search?i.search=p.search:p.id?i.id=p.id:p.path&&this.validatePath(p.path)?i.path=p.path:p.compositionId&&(i.compositionId=p.compositionId),p.limit&&(i.limit=p.limit.toString()),p.offset&&(i.offset=p.offset.toString()),p.expanded&&(i.expanded="true");let r=this.createUrl("/api/v1/project-map-nodes",i);return await this.apiClient(r)}}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 h2{constructor(a){super({...a,bypassCache:!0})}},f2=e=>e?{...e,parent:void 0,children:void 0}:void 0;var e4={command:"get <id>",describe:"Fetch a project map",builder:e=>Q1(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,projectId:r}).getProjectMapDefinition({projectMapId:t});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):o1(o.projectMaps[0],i,d)}};var a4={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>Q1(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,projectId:r}).getProjectMapDefinitions();o1(s.projectMaps,t,i)}};function ia(e,a){return J6(e,a)}function Gt(e,a){Z6(e,a)}var P1=e=>e.id,da=e=>`${e.name} (pid: ${e.id})`;function Kt({client:e}){async function*a(){let p=(await e.getProjectMapDefinitions()).projectMaps;for await(let t of p)yield{id:P1(t),displayName:da(t),providerId:P1(t),object:t}}return{objects:a(),deleteObject:async p=>{await e.deleteProjectMap({projectMapId:p})},writeObject:async p=>{await e.upsertProjectMap({projectMap:p.object})}}}var p4={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>re(se(X1(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,projectId:n}),m=Kt({client:l}),c;if(ea(t)){let g=ia(t,!1);c=await Z1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMaps=x,Gt(t,g)}})}else c=await aa({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await pa({source:m,target:c,mode:r,whatIf:d,log:ta({diffMode:s})})}};var t4={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>re(se(X1(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,projectId:d}),l;if(ea(t)){let v=ia(t,!0);l=await Z1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await aa({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=Kt({client:o});await pa({source:l,target:c,mode:i,whatIf:r,log:ta({diffMode:n})})}};var i4={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,projectId:i}).deleteProjectMap({projectMapId:t})}};var d4={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,projectId:i}),n=op(t);await d.upsertProjectMap({projectMap:n})}};var r4={command:"definition <command>",describe:"Commands for ProjectMap Definitions",builder:e=>e.command(p4).command(t4).command(e4).command(i4).command(a4).command(d4).demandCommand(),handler:()=>{Ua.help()}};var n4={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>Q1(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),o=new pe({apiKey:a,apiHost:e,fetch:s,projectId:d});console.log("Debugging params for node get",{projectMapId:i,id:t,projectId:d});let l=await o.getNodes({projectMapId:i,id:t});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):o1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var s4={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>Q1(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,projectId:d}).getNodes({projectMapId:t});o1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var ja=(e,a)=>a+e.projectMapId+e.id+e.path,Jt=e=>`${e.pathSegment}_${e.id}`,ra=e=>`${e.name} (pid: ${e.id})`;function Zt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions()).projectMaps;for(let i of t){let r=(await e.getNodes({projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:ja({...d,projectMapId:i.id},a),displayName:ra(d),providerId:ja({...d,projectMapId:i.id},a),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:i.object.id,projectMapId:i.object.projectMapId})},writeObject:async t=>{let i={...t.object};await e.upsertProjectMapNodes({projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var o4={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>re(se(X1(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 g;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o,projectId:n}),m=Zt({client:l,projectId:n}),c,u=ea(t),v=h=>ja(h,n);if(u){let h=ia(t,!1);c=await Z1({objects:(g=h.projectMapNodes)!=null?g:[],selectIdentifier:v,selectDisplayName:ra,onSyncComplete:async(x,S)=>{h.projectMapNodes=S,Gt(t,h)}})}else c=await aa({directory:t,selectIdentifier:v,selectDisplayName:ra,format:i,selectFilename:Jt});await pa({source:m,target:c,mode:r,whatIf:d,log:ta({diffMode:s})})}};var l4={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>re(se(X1(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 v;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s,projectId:d}),l,m=ea(t),c=g=>ja(g,d);if(m){let g=ia(t,!0);l=await Z1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:c,selectDisplayName:ra})}else l=await aa({directory:t,selectIdentifier:c,selectDisplayName:ra,selectFilename:Jt});let u=Zt({client:o,projectId:d});await pa({source:l,target:u,mode:i,whatIf:r,log:ta({diffMode:n})})}};var m4={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,projectId:r}).deleteProjectMapNode({projectMapId:t,nodeId:i})}};var c4={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,projectId:r}),s=op(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t})}};var u4={command:"node <command>",describe:"Commands for ProjectMap Nodes",builder:e=>e.command(o4).command(l4).command(n4).command(m4).command(s4).command(c4).demandCommand(),handler:()=>{Ua.help()}};var K5={commands:[{command:"project-map <command>",aliases:["prm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(u4).command(r4).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 X6=require("@uniformdev/context/api");var h2=class extends X6.ApiClient{constructor(p){super(p);this.getProjectMapDefinitions=async()=>{let{projectId:p}=this.options,t=this.createUrl("/api/v1/project-map",{projectId:p});return await this.apiClient(t)};this.getProjectMapDefinition=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map",{...p,projectId:t});return await this.apiClient(i)};this.upsertProjectMap=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map");return(await this.apiClient(i,{method:"PUT",body:JSON.stringify({...p,projectId:t})})).projectMapId};this.deleteProjectMap=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map");await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...p,projectId:t}),expectNoContent:!0})};this.upsertProjectMapNodes=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...p,projectId:t,nodes:p.nodes.map(r=>({...r,node:{...this.cleanProjectMapNode(r.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async p=>{let{projectId:t}=this.options,i=this.createUrl("/api/v1/project-map-nodes");(!p.path||this.validatePath(p.path))&&await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...p,projectId:t}),expectNoContent:!0})};this.getSubtree=async p=>{var o;let{projectId:t}=this.options,i={projectId:t,projectMapId:p.projectMapId};p.search?i.search=p.search:p.id?i.id=p.id:p.path&&this.validatePath(p.path)?i.path=p.path:p.compositionId&&(i.compositionId=p.compositionId),p.depth&&(i.depth=p.depth.toString()),p.expanded&&(i.expanded="true"),i.tree="true";let r=this.createUrl("/api/v1/project-map-nodes",i),n={...(await this.apiClient(r)).tree},s=[n];for(;s&&s.length>0;){let l=s.pop(),m;(o=l==null?void 0:l.children)==null||o.forEach(c=>{c.parent=f2(l),c.previousSibling=f2(m),m&&(m.nextSibling=f2(c)),m=c,s.push(c)})}return n};this.getNodes=async p=>{let{projectId:t}=this.options,i={projectId:t};p.projectMapId&&(i.projectMapId=p.projectMapId),p.search?i.search=p.search:p.id?i.id=p.id:p.path&&this.validatePath(p.path)?i.path=p.path:p.compositionId&&(i.compositionId=p.compositionId),p.limit&&(i.limit=p.limit.toString()),p.offset&&(i.offset=p.offset.toString()),p.expanded&&(i.expanded="true");let r=this.createUrl("/api/v1/project-map-nodes",i);return await this.apiClient(r)}}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,order:p.order,data:p.data,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 h2{constructor(a){super({...a,bypassCache:!0})}},f2=e=>e?{...e,parent:void 0,children:void 0}:void 0;var e4={command:"get <id>",describe:"Fetch a project map",builder:e=>Q1(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,projectId:r}).getProjectMapDefinition({projectMapId:t});o.projectMaps.length===0?(console.error("ProjectMap does not exist"),process.exit(1)):o1(o.projectMaps[0],i,d)}};var a4={command:"list",describe:"List of project maps",aliases:["ls"],builder:e=>Q1(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,projectId:r}).getProjectMapDefinitions();o1(s.projectMaps,t,i)}};function ia(e,a){return J6(e,a)}function Gt(e,a){Z6(e,a)}var P1=e=>e.id,da=e=>`${e.name} (pid: ${e.id})`;function Kt({client:e}){async function*a(){let p=(await e.getProjectMapDefinitions()).projectMaps;for await(let t of p)yield{id:P1(t),displayName:da(t),providerId:P1(t),object:t}}return{objects:a(),deleteObject:async p=>{await e.deleteProjectMap({projectMapId:p})},writeObject:async p=>{await e.upsertProjectMap({projectMap:p.object})}}}var p4={command:"pull <directory>",describe:"Pulls all project maps to local files in a directory",builder:e=>re(se(X1(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,projectId:n}),m=Kt({client:l}),c;if(ea(t)){let g=ia(t,!1);c=await Z1({objects:(v=g.projectMaps)!=null?v:[],selectIdentifier:P1,selectDisplayName:da,onSyncComplete:async(h,x)=>{g.projectMaps=x,Gt(t,g)}})}else c=await aa({directory:t,selectIdentifier:P1,selectDisplayName:da,format:i});await pa({source:m,target:c,mode:r,whatIf:d,log:ta({diffMode:s})})}};var t4={command:"push <directory>",describe:"Pushes all project maps from files in a directory or package to Uniform",builder:e=>re(se(X1(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,projectId:d}),l;if(ea(t)){let v=ia(t,!0);l=await Z1({objects:(u=v.projectMaps)!=null?u:[],selectIdentifier:P1,selectDisplayName:da})}else l=await aa({directory:t,selectIdentifier:P1,selectDisplayName:da});let c=Kt({client:o});await pa({source:l,target:c,mode:i,whatIf:r,log:ta({diffMode:n})})}};var i4={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,projectId:i}).deleteProjectMap({projectMapId:t})}};var d4={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,projectId:i}),n=op(t);await d.upsertProjectMap({projectMap:n})}};var r4={command:"definition <command>",describe:"Commands for ProjectMap Definitions",builder:e=>e.command(p4).command(t4).command(e4).command(i4).command(a4).command(d4).demandCommand(),handler:()=>{Ua.help()}};var n4={command:"get <id> <projectMapId>",describe:"Fetch a project map node",builder:e=>Q1(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),o=new pe({apiKey:a,apiHost:e,fetch:s,projectId:d});console.log("Debugging params for node get",{projectMapId:i,id:t,projectId:d});let l=await o.getNodes({projectMapId:i,id:t});((m=l.nodes)==null?void 0:m.length)===0?(console.error("Project map node does not exist"),process.exit(1)):o1({nodes:(c=l.nodes)!=null?c:[],projectMapId:i},r,n)}};var s4={command:"list <projectMapId>",describe:"List project map nodes",aliases:["ls"],builder:e=>Q1(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,projectId:d}).getNodes({projectMapId:t});o1({nodes:(l=o.nodes)!=null?l:[],projectMapId:t},i,r)}};var ja=(e,a)=>a+e.projectMapId+e.id+e.path,Jt=e=>`${e.pathSegment}_${e.id}`,ra=e=>`${e.name} (pid: ${e.id})`;function Zt({client:e,projectId:a}){async function*p(){let t=(await e.getProjectMapDefinitions()).projectMaps;for(let i of t){let r=(await e.getNodes({projectMapId:i.id})).nodes;for await(let d of r!=null?r:[])d&&(yield{id:ja({...d,projectMapId:i.id},a),displayName:ra(d),providerId:ja({...d,projectMapId:i.id},a),object:{...d,projectMapId:i.id}})}}return{objects:p(),deleteObject:async(t,i)=>{await e.deleteProjectMapNode({nodeId:i.object.id,projectMapId:i.object.projectMapId})},writeObject:async t=>{let i={...t.object};await e.upsertProjectMapNodes({projectMapId:t.object.projectMapId,nodes:[{node:i}]})}}}var o4={command:"pull <directory>",describe:"Pulls all project maps nodes to local files in a directory",builder:e=>re(se(X1(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 g;let o=ne(p),l=new pe({apiKey:a,apiHost:e,fetch:o,projectId:n}),m=Zt({client:l,projectId:n}),c,u=ea(t),v=h=>ja(h,n);if(u){let h=ia(t,!1);c=await Z1({objects:(g=h.projectMapNodes)!=null?g:[],selectIdentifier:v,selectDisplayName:ra,onSyncComplete:async(x,S)=>{h.projectMapNodes=S,Gt(t,h)}})}else c=await aa({directory:t,selectIdentifier:v,selectDisplayName:ra,format:i,selectFilename:Jt});await pa({source:m,target:c,mode:r,whatIf:d,log:ta({diffMode:s})})}};var l4={command:"push <directory>",describe:"Pushes all project maps nodes from files in a directory or package to Uniform",builder:e=>re(se(X1(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 v;let s=ne(p),o=new pe({apiKey:a,apiHost:e,fetch:s,projectId:d}),l,m=ea(t),c=g=>ja(g,d);if(m){let g=ia(t,!0);l=await Z1({objects:(v=g.projectMapNodes)!=null?v:[],selectIdentifier:c,selectDisplayName:ra})}else l=await aa({directory:t,selectIdentifier:c,selectDisplayName:ra,selectFilename:Jt});let u=Zt({client:o,projectId:d});await pa({source:l,target:u,mode:i,whatIf:r,log:ta({diffMode:n})})}};var m4={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,projectId:r}).deleteProjectMapNode({projectMapId:t,nodeId:i})}};var c4={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,projectId:r}),s=op(i);await n.upsertProjectMapNodes({nodes:[{node:s}],projectMapId:t})}};var u4={command:"node <command>",describe:"Commands for ProjectMap Nodes",builder:e=>e.command(o4).command(l4).command(n4).command(m4).command(s4).command(c4).demandCommand(),handler:()=>{Ua.help()}};var K5={commands:[{command:"project-map <command>",aliases:["prm"],describe:"Uniform ProjectMap commands",builder:e=>e.command(u4).command(r4).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 p2,c as H,d as t2,e as Fp,f as i2,i as re}from"../chunk-
|
|
1
|
+
import{a as ee,b as p2,c as H,d as t2,e as Fp,f as i2,i as re}from"../chunk-IEPGH77W.mjs";var o0=H((Z7,s0)=>{var Ba=1e3,Ra=Ba*60,Ua=Ra*60,ya=Ua*24,is=ya*7,ds=ya*365.25;s0.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return rs(e);if(p==="number"&&isFinite(e))return a.long?ss(e):ns(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function rs(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*ds;case"weeks":case"week":case"w":return p*is;case"days":case"day":case"d":return p*ya;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Ua;case"minutes":case"minute":case"mins":case"min":case"m":return p*Ra;case"seconds":case"second":case"secs":case"sec":case"s":return p*Ba;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function ns(e){var a=Math.abs(e);return a>=ya?Math.round(e/ya)+"d":a>=Ua?Math.round(e/Ua)+"h":a>=Ra?Math.round(e/Ra)+"m":a>=Ba?Math.round(e/Ba)+"s":e+"ms"}function ss(e){var a=Math.abs(e);return a>=ya?Zp(e,a,ya,"day"):a>=Ua?Zp(e,a,Ua,"hour"):a>=Ra?Zp(e,a,Ra,"minute"):a>=Ba?Zp(e,a,Ba,"second"):e+" ms"}function Zp(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var gi=H((Q7,l0)=>{function os(e){p.debug=p,p.default=p,p.coerce=s,p.disable=r,p.enable=i,p.enabled=d,p.humanize=o0(),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}l0.exports=os});var m0=H((We,Qp)=>{We.formatArgs=ms;We.save=cs;We.load=us;We.useColors=ls;We.storage=fs();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 ls(){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 ms(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Qp.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 cs(e){try{e?We.storage.setItem("debug",e):We.storage.removeItem("debug")}catch(a){}}function us(){let e;try{e=We.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function fs(){try{return localStorage}catch(e){}}Qp.exports=gi()(We);var{formatters:hs}=Qp.exports;hs.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var u0=H((X7,c0)=>{"use strict";c0.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 v0=H((em,h0)=>{"use strict";var vs=ee("os"),f0=ee("tty"),Xe=u0(),{env:Ee}=process,L1;Xe("no-color")||Xe("no-colors")||Xe("color=false")||Xe("color=never")?L1=0:(Xe("color")||Xe("colors")||Xe("color=true")||Xe("color=always"))&&(L1=1);"FORCE_COLOR"in Ee&&(Ee.FORCE_COLOR==="true"?L1=1:Ee.FORCE_COLOR==="false"?L1=0:L1=Ee.FORCE_COLOR.length===0?1:Math.min(parseInt(Ee.FORCE_COLOR,10),3));function wi(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function bi(e,a){if(L1===0)return 0;if(Xe("color=16m")||Xe("color=full")||Xe("color=truecolor"))return 3;if(Xe("color=256"))return 2;if(e&&!a&&L1===void 0)return 0;let p=L1||0;if(Ee.TERM==="dumb")return p;if(process.platform==="win32"){let t=vs.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 gs(e){let a=bi(e,e&&e.isTTY);return wi(a)}h0.exports={supportsColor:gs,stdout:wi(bi(!0,f0.isatty(1))),stderr:wi(bi(!0,f0.isatty(2)))}});var w0=H((Te,et)=>{var ws=ee("tty"),Xp=ee("util");Te.init=Cs;Te.log=xs;Te.formatArgs=ys;Te.save=Ss;Te.load=As;Te.useColors=bs;Te.destroy=Xp.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=v0();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 bs(){return"colors"in Te.inspectOpts?Boolean(Te.inspectOpts.colors):ws.isatty(process.stderr.fd)}function ys(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+"+et.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=_s()+a+" "+e[0]}function _s(){return Te.inspectOpts.hideDate?"":new Date().toISOString()+" "}function xs(...e){return process.stderr.write(Xp.format(...e)+`
|
|
4
4
|
`)}function Ss(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function As(){return process.env.DEBUG}function Cs(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]]}et.exports=gi()(Te);var{formatters:g0}=et.exports;g0.o=function(e){return this.inspectOpts.colors=this.useColors,Xp.inspect(e,this.inspectOpts).split(`
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ApiClient } from '@uniformdev/context/api';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
type ProjectMapNodeWithProjectMapReference = ProjectMapNodeWithId & {
|
|
4
4
|
projectMapId: string;
|
|
5
5
|
};
|
|
6
6
|
|
|
@@ -431,28 +431,28 @@ interface external {
|
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
434
|
+
type ProjectMapNodeUpsertRequest = paths['/api/v1/project-map-nodes']['put']['requestBody']['content']['application/json'];
|
|
435
|
+
type ProjectMapNodeUpsertRequestNode = ProjectMapNodeUpsertRequest['nodes'][0]['node'];
|
|
436
|
+
type ProjectMapNodeDeleteRequest = paths['/api/v1/project-map-nodes']['delete']['requestBody']['content']['application/json'];
|
|
437
|
+
type ProjectMapNodeGetRequest = paths['/api/v1/project-map-nodes']['get']['parameters']['query'];
|
|
438
|
+
type ProjectMapNodeGetResponse = paths['/api/v1/project-map-nodes']['get']['responses']['200']['content']['application/json'];
|
|
439
|
+
type ProjectMapNode = NonNullable<ProjectMapNodeGetResponse['nodes']>[0];
|
|
440
|
+
type ProjectMapNodeWithId = ProjectMapNode & Required<Pick<ProjectMapNode, 'id' | 'name'>>;
|
|
441
|
+
type ProjectMapGetRequest = paths$1['/api/v1/project-map']['get']['parameters']['query'];
|
|
442
|
+
type ProjectMapGetResponse = paths$1['/api/v1/project-map']['get']['responses']['200']['content']['application/json'];
|
|
443
|
+
type ProjectMapUpsertRequest = paths$1['/api/v1/project-map']['put']['requestBody']['content']['application/json'];
|
|
444
|
+
type ProjectMapDeleteRequest = paths$1['/api/v1/project-map']['delete']['requestBody']['content']['application/json'];
|
|
445
|
+
type ProjectMapDefinition = ProjectMapGetResponse['projectMaps'][0];
|
|
446
|
+
type ProjectMapDefinitionWithId = ProjectMapDefinition & Required<Pick<ProjectMapDefinition, 'id'>>;
|
|
447
|
+
type ProjectMapUpsertResponse = paths$1['/api/v1/project-map']['put']['responses']['200']['content']['application/json'];
|
|
448
|
+
type NodeType = 'placeholder' | 'composition' | 'redirect';
|
|
449
|
+
type ProjectMapDefinitions = {
|
|
450
450
|
projectMaps: ProjectMapDefinitionWithId[];
|
|
451
451
|
projectMapNodes: ProjectMapNodeWithProjectMapReference[];
|
|
452
452
|
};
|
|
453
453
|
|
|
454
454
|
declare const ROOT_NODE_PATH = "/";
|
|
455
|
-
|
|
455
|
+
type ProjectMapClientOptions = {
|
|
456
456
|
/** The Uniform API host to use. Internal use. */
|
|
457
457
|
apiHost?: string;
|
|
458
458
|
/** The Uniform API key to use when sending API requests. This or bearer token must be specified. */
|
|
@@ -466,13 +466,13 @@ declare type ProjectMapClientOptions = {
|
|
|
466
466
|
/** Specify whether caching is disabled. */
|
|
467
467
|
bypassCache?: boolean;
|
|
468
468
|
};
|
|
469
|
-
|
|
469
|
+
type ProjectMapSubtree = ProjectMapNode & {
|
|
470
470
|
children?: Array<ProjectMapSubtree> | undefined;
|
|
471
471
|
parent?: ProjectMapSubtree | undefined;
|
|
472
472
|
previousSibling?: ProjectMapSubtree | undefined;
|
|
473
473
|
nextSibling?: ProjectMapSubtree | undefined;
|
|
474
474
|
};
|
|
475
|
-
|
|
475
|
+
type WithoutProjectId<T extends {
|
|
476
476
|
projectId: string;
|
|
477
477
|
}> = Omit<T, 'projectId'>;
|
|
478
478
|
declare class ProjectMapClient extends ApiClient<ProjectMapClientOptions> {
|
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-IEPGH77W.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(o,i)=>{for(var e in i)h(o,e,{get:i[e],enumerable:!0})},g=(o,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of m(i))!I.call(o,t)&&t!==e&&h(o,t,{get:()=>i[t],enumerable:!(r=M(i,t))||r.enumerable});return o};var R=o=>g(h({},"__esModule",{value:!0}),o);var U={};N(U,{ProjectMapClient:()=>d,ROOT_NODE_PATH:()=>y,UncachedProjectMapClient:()=>j});module.exports=R(U);var l=require("@uniformdev/context/api"),y="/",d=class extends l.ApiClient{constructor(e){super(e);this.getProjectMapDefinitions=async()=>{let{projectId:e}=this.options,r=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(r)};this.getProjectMapDefinition=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map",{...e,projectId:r});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:r})})).projectMapId};this.deleteProjectMap=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:r,nodes:e.nodes.map(
|
|
1
|
+
"use strict";var h=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var N=(o,i)=>{for(var e in i)h(o,e,{get:i[e],enumerable:!0})},g=(o,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of m(i))!I.call(o,t)&&t!==e&&h(o,t,{get:()=>i[t],enumerable:!(r=M(i,t))||r.enumerable});return o};var R=o=>g(h({},"__esModule",{value:!0}),o);var U={};N(U,{ProjectMapClient:()=>d,ROOT_NODE_PATH:()=>y,UncachedProjectMapClient:()=>j});module.exports=R(U);var l=require("@uniformdev/context/api"),y="/",d=class extends l.ApiClient{constructor(e){super(e);this.getProjectMapDefinitions=async()=>{let{projectId:e}=this.options,r=this.createUrl("/api/v1/project-map",{projectId:e});return await this.apiClient(r)};this.getProjectMapDefinition=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map",{...e,projectId:r});return await this.apiClient(t)};this.upsertProjectMap=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map");return(await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:r})})).projectMapId};this.deleteProjectMap=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map");await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})};this.upsertProjectMapNodes=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map-nodes");await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:r,nodes:e.nodes.map(a=>({...a,node:{...this.cleanProjectMapNode(a.node)}}))}),expectNoContent:!0})};this.deleteProjectMapNode=async e=>{let{projectId:r}=this.options,t=this.createUrl("/api/v1/project-map-nodes");(!e.path||this.validatePath(e.path))&&await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:r}),expectNoContent:!0})};this.getSubtree=async e=>{var f;let{projectId:r}=this.options,t={projectId:r,projectMapId:e.projectMapId};e.search?t.search=e.search:e.id?t.id=e.id: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 a=this.createUrl("/api/v1/project-map-nodes",t),P={...(await this.apiClient(a)).tree},s=[P];for(;s&&s.length>0;){let p=s.pop(),n;(f=p==null?void 0:p.children)==null||f.forEach(c=>{c.parent=u(p),c.previousSibling=u(n),n&&(n.nextSibling=u(c)),n=c,s.push(c)})}return P};this.getNodes=async e=>{let{projectId:r}=this.options,t={projectId:r};e.projectMapId&&(t.projectMapId=e.projectMapId),e.search?t.search=e.search:e.id?t.id=e.id: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 a=this.createUrl("/api/v1/project-map-nodes",t);return await this.apiClient(a)}}cleanProjectMapNode(e){var r,t,a;return{id:((a=(t=(r=e.id)==null?void 0:r.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:t.length)!=null?a:0)==1?e.id:void 0,path:e.path,name:e.name,type:e.type,order:e.order,data:e.data,compositionId:e.compositionId,description:e.description}}validatePath(e){let r=/[*%!&@]/g;if(e==null?void 0:e.match(r))throw"Path cannot contain reserved characters * % ! & @";return!0}},j=class extends d{constructor(i){super({...i,bypassCache:!0})}},u=o=>o?{...o,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-IEPGH77W.mjs";export{r as ProjectMapClient,o as ROOT_NODE_PATH,e as UncachedProjectMapClient};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/project-map",
|
|
3
|
-
"version": "17.7.
|
|
3
|
+
"version": "17.7.1-alpha.140+80ab6baf9",
|
|
4
4
|
"description": "Uniform Project Map",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"/dist"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@uniformdev/canvas": "^17.7.
|
|
50
|
-
"@uniformdev/context": "^17.7.
|
|
49
|
+
"@uniformdev/canvas": "^17.7.1-alpha.140+80ab6baf9",
|
|
50
|
+
"@uniformdev/context": "^17.7.1-alpha.140+80ab6baf9",
|
|
51
51
|
"p-limit": "^3.1.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/yargs": "17.0.
|
|
55
|
-
"@uniformdev/cli": "^17.7.
|
|
54
|
+
"@types/yargs": "17.0.19",
|
|
55
|
+
"@uniformdev/cli": "^17.7.1-alpha.140+80ab6baf9",
|
|
56
56
|
"yargs": "17.6.2"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "80ab6baf9edea6b520738bd3dff5c6afc882bf77"
|
|
62
62
|
}
|