@uniformdev/project-map 17.7.1-alpha.140 → 17.7.1-alpha.167

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/index.esm.js CHANGED
@@ -1 +1,10 @@
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};
1
+ import {
2
+ ProjectMapClient,
3
+ ROOT_NODE_PATH,
4
+ UncachedProjectMapClient
5
+ } from "./chunk-VEO6RNDL.mjs";
6
+ export {
7
+ ProjectMapClient,
8
+ ROOT_NODE_PATH,
9
+ UncachedProjectMapClient
10
+ };
package/dist/index.js CHANGED
@@ -1 +1,209 @@
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});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ ProjectMapClient: () => ProjectMapClient,
24
+ ROOT_NODE_PATH: () => ROOT_NODE_PATH,
25
+ UncachedProjectMapClient: () => UncachedProjectMapClient
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/projectMapClient.ts
30
+ var import_api = require("@uniformdev/context/api");
31
+ var ROOT_NODE_PATH = "/";
32
+ var ProjectMapClient = class extends import_api.ApiClient {
33
+ constructor(options) {
34
+ super(options);
35
+ this.getProjectMapDefinitions = async () => {
36
+ const { projectId } = this.options;
37
+ const fetchUri = this.createUrl("/api/v1/project-map", { projectId });
38
+ return await this.apiClient(fetchUri);
39
+ };
40
+ this.getProjectMapDefinition = async (options) => {
41
+ const { projectId } = this.options;
42
+ const fetchUri = this.createUrl("/api/v1/project-map", {
43
+ ...options,
44
+ projectId
45
+ });
46
+ return await this.apiClient(fetchUri);
47
+ };
48
+ this.upsertProjectMap = async (options) => {
49
+ const { projectId } = this.options;
50
+ const fetchUri = this.createUrl("/api/v1/project-map");
51
+ const result = await this.apiClient(fetchUri, {
52
+ method: "PUT",
53
+ body: JSON.stringify({ ...options, projectId })
54
+ });
55
+ return result.projectMapId;
56
+ };
57
+ this.deleteProjectMap = async (options) => {
58
+ const { projectId } = this.options;
59
+ const fetchUri = this.createUrl("/api/v1/project-map");
60
+ await this.apiClient(fetchUri, {
61
+ method: "DELETE",
62
+ body: JSON.stringify({ ...options, projectId }),
63
+ expectNoContent: true
64
+ });
65
+ };
66
+ this.upsertProjectMapNodes = async (options) => {
67
+ const { projectId } = this.options;
68
+ const fetchUri = this.createUrl("/api/v1/project-map-nodes");
69
+ await this.apiClient(fetchUri, {
70
+ method: "PUT",
71
+ body: JSON.stringify({
72
+ ...options,
73
+ projectId,
74
+ nodes: options.nodes.map((n) => {
75
+ return {
76
+ ...n,
77
+ node: { ...this.cleanProjectMapNode(n.node) }
78
+ };
79
+ })
80
+ }),
81
+ expectNoContent: true
82
+ });
83
+ };
84
+ this.deleteProjectMapNode = async (options) => {
85
+ const { projectId } = this.options;
86
+ const fetchUri = this.createUrl("/api/v1/project-map-nodes");
87
+ if (!options.path || this.validatePath(options.path)) {
88
+ await this.apiClient(fetchUri, {
89
+ method: "DELETE",
90
+ body: JSON.stringify({
91
+ ...options,
92
+ projectId
93
+ }),
94
+ expectNoContent: true
95
+ });
96
+ }
97
+ };
98
+ this.getSubtree = async (options) => {
99
+ var _a;
100
+ const { projectId } = this.options;
101
+ const fetchOptions = {
102
+ projectId,
103
+ projectMapId: options.projectMapId
104
+ };
105
+ if (options.search) {
106
+ fetchOptions["search"] = options.search;
107
+ } else if (options.id) {
108
+ fetchOptions["id"] = options.id;
109
+ } else if (options.path && this.validatePath(options.path)) {
110
+ fetchOptions["path"] = options.path;
111
+ } else if (options.compositionId) {
112
+ fetchOptions["compositionId"] = options.compositionId;
113
+ }
114
+ if (options.depth) {
115
+ fetchOptions["depth"] = options.depth.toString();
116
+ }
117
+ if (options.expanded) {
118
+ fetchOptions["expanded"] = "true";
119
+ }
120
+ fetchOptions["tree"] = "true";
121
+ const fetchUri = this.createUrl("/api/v1/project-map-nodes", fetchOptions);
122
+ const result = await this.apiClient(fetchUri);
123
+ const root = {
124
+ ...result.tree
125
+ };
126
+ const nodes = [root];
127
+ while (nodes && nodes.length > 0) {
128
+ const currentNode = nodes.pop();
129
+ let lastChild = void 0;
130
+ (_a = currentNode == null ? void 0 : currentNode.children) == null ? void 0 : _a.forEach((child) => {
131
+ child.parent = cutReferences(currentNode);
132
+ child.previousSibling = cutReferences(lastChild);
133
+ if (lastChild) {
134
+ lastChild.nextSibling = cutReferences(child);
135
+ }
136
+ lastChild = child;
137
+ nodes.push(child);
138
+ });
139
+ }
140
+ return root;
141
+ };
142
+ this.getNodes = async (options) => {
143
+ const { projectId } = this.options;
144
+ const fetchOptions = {
145
+ projectId
146
+ };
147
+ if (options.projectMapId) {
148
+ fetchOptions["projectMapId"] = options.projectMapId;
149
+ }
150
+ if (options.search) {
151
+ fetchOptions["search"] = options.search;
152
+ } else if (options.id) {
153
+ fetchOptions["id"] = options.id;
154
+ } else if (options.path && this.validatePath(options.path)) {
155
+ fetchOptions["path"] = options.path;
156
+ } else if (options.compositionId) {
157
+ fetchOptions["compositionId"] = options.compositionId;
158
+ }
159
+ if (options.limit) {
160
+ fetchOptions["limit"] = options.limit.toString();
161
+ }
162
+ if (options.offset) {
163
+ fetchOptions["offset"] = options.offset.toString();
164
+ }
165
+ if (options.expanded) {
166
+ fetchOptions["expanded"] = "true";
167
+ }
168
+ const fetchUri = this.createUrl("/api/v1/project-map-nodes", fetchOptions);
169
+ return await this.apiClient(fetchUri);
170
+ };
171
+ }
172
+ cleanProjectMapNode(node) {
173
+ var _a, _b, _c;
174
+ return {
175
+ id: ((_c = (_b = (_a = node.id) == null ? void 0 : _a.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 : _b.length) != null ? _c : 0) == 1 ? node.id : void 0,
176
+ path: node.path,
177
+ name: node.name,
178
+ type: node.type,
179
+ order: node.order,
180
+ data: node.data,
181
+ compositionId: node.compositionId,
182
+ description: node.description
183
+ };
184
+ }
185
+ validatePath(path) {
186
+ const regex = /[*%!&@]/g;
187
+ const match = path == null ? void 0 : path.match(regex);
188
+ if (match) {
189
+ throw "Path cannot contain reserved characters * % ! & @";
190
+ }
191
+ return true;
192
+ }
193
+ };
194
+ var UncachedProjectMapClient = class extends ProjectMapClient {
195
+ constructor(options) {
196
+ super({ ...options, bypassCache: true });
197
+ }
198
+ };
199
+ var cutReferences = (node) => node ? {
200
+ ...node,
201
+ parent: void 0,
202
+ children: void 0
203
+ } : void 0;
204
+ // Annotate the CommonJS export names for ESM import in node:
205
+ 0 && (module.exports = {
206
+ ProjectMapClient,
207
+ ROOT_NODE_PATH,
208
+ UncachedProjectMapClient
209
+ });
package/dist/index.mjs CHANGED
@@ -1 +1,10 @@
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};
1
+ import {
2
+ ProjectMapClient,
3
+ ROOT_NODE_PATH,
4
+ UncachedProjectMapClient
5
+ } from "./chunk-VEO6RNDL.mjs";
6
+ export {
7
+ ProjectMapClient,
8
+ ROOT_NODE_PATH,
9
+ UncachedProjectMapClient
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/project-map",
3
- "version": "17.7.1-alpha.140+80ab6baf9",
3
+ "version": "17.7.1-alpha.167+a358adea9",
4
4
  "description": "Uniform Project Map",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "sideEffects": false,
34
34
  "scripts": {
35
35
  "build": "run-s update-openapi build:ts",
36
- "build:ts": "tsup --minify",
36
+ "build:ts": "tsup",
37
37
  "dev": "run-s update-openapi dev:ts",
38
38
  "dev:ts": "tsup --watch",
39
39
  "clean": "rimraf dist",
@@ -46,17 +46,17 @@
46
46
  "/dist"
47
47
  ],
48
48
  "dependencies": {
49
- "@uniformdev/canvas": "^17.7.1-alpha.140+80ab6baf9",
50
- "@uniformdev/context": "^17.7.1-alpha.140+80ab6baf9",
49
+ "@uniformdev/canvas": "^17.7.1-alpha.167+a358adea9",
50
+ "@uniformdev/context": "^17.7.1-alpha.167+a358adea9",
51
51
  "p-limit": "^3.1.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/yargs": "17.0.19",
55
- "@uniformdev/cli": "^17.7.1-alpha.140+80ab6baf9",
55
+ "@uniformdev/cli": "^17.7.1-alpha.167+a358adea9",
56
56
  "yargs": "17.6.2"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "80ab6baf9edea6b520738bd3dff5c6afc882bf77"
61
+ "gitHead": "a358adea91b24a877e577be784d56b794c4cfab8"
62
62
  }
@@ -1 +0,0 @@
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};