@overmap-ai/common 0.0.1-more-code-dump.3 → 0.0.1-more-code-dump.4
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.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/utils/models/index.d.ts +1 -0
- package/dist/utils/models/users.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),t=function(e){return e[e.GUEST=0]=`GUEST`,e[e.BASIC=2]=`BASIC`,e[e.ADMIN=4]=`ADMIN`,e}({}),n=function(e){return e[e.PLANNED=0]=`PLANNED`,e[e.ACTIVE=1]=`ACTIVE`,e[e.MAINTENANCE=2]=`MAINTENANCE`,e[e.INACTIVE=3]=`INACTIVE`,e[e.RETIRED=4]=`RETIRED`,e[e.DISPOSED=5]=`DISPOSED`,e}({}),r=function(e){return e.STATUS=`status`,e.PRIORITY=`priority`,e.DESCRIPTION=`description`,e.TITLE=`title`,e.ASSIGNED_TO=`assigned_to`,e.DUE_DATE=`due_date`,e}({}),i=function(e){return e[e.BACKLOG=0]=`BACKLOG`,e[e.PLANNED=1]=`PLANNED`,e[e.IN_PROGRESS=2]=`IN_PROGRESS`,e[e.COMPLETED=3]=`COMPLETED`,e[e.CANCELLED=4]=`CANCELLED`,e}({}),a=function(e){return e[e.LOWEST=0]=`LOWEST`,e[e.LOW=2]=`LOW`,e[e.MEDIUM=4]=`MEDIUM`,e[e.HIGH=6]=`HIGH`,e[e.HIGHEST=8]=`HIGHEST`,e}({}),o=function(e){return e[e.ADD_ASSIGNEE=0]=`ADD_ASSIGNEE`,e[e.REMOVE_ASSIGNEE=2]=`REMOVE_ASSIGNEE`,e[e.ADD_REVIEWER=4]=`ADD_REVIEWER`,e[e.REMOVE_REVIEWER=6]=`REMOVE_REVIEWER`,e}({}),s=function(e){return e[e.APPROVED=0]=`APPROVED`,e[e.REJECTED=2]=`REJECTED`,e[e.CHANGES_REQUESTED=4]=`CHANGES_REQUESTED`,e}({}),c=function(e){return e[e.USER_REGISTRATION=0]=`USER_REGISTRATION`,e[e.APPLICATION_INVITE=2]=`APPLICATION_INVITE`,e[e.PROJECT_INVITE=4]=`PROJECT_INVITE`,e[e.ORGANIZATION_INVITE=6]=`ORGANIZATION_INVITE`,e[e.ADD_EMAIL_DOMAIN=8]=`ADD_EMAIL_DOMAIN`,e[e.RESET_PASSWORD=10]=`RESET_PASSWORD`,e}({}),l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).slice(1));function u(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+`-`+l[e[t+4]]+l[e[t+5]]+`-`+l[e[t+6]]+l[e[t+7]]+`-`+l[e[t+8]]+l[e[t+9]]+`-`+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}var d,f=new Uint8Array(16);function p(){if(!d){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);d=crypto.getRandomValues.bind(crypto)}return d(f)}var m={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function h(e,t,n){if(m.randomUUID&&!t&&!e)return m.randomUUID();e||={};let r=e.random??e.rng?.()??p();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return u(r)}function g(e){return{...e,uuid:h()}}function ee(e){let t={};for(let n of e)t[n.uuid]=n;return t}function _(e){return e.map(({uuid:e})=>e)}function v(e,t){return e.localeCompare(t)}function y(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1);return n.slice(0,n.lastIndexOf(` `))+`…`}function b(e,t){return t===1?e:e+`s`}function te(e){let t=e.trim().split(/[\s-_]+/).filter(e=>e.length>0);if(t.length===0)return``;if(t.length===1){let e=t[0];if(e.length<=3)return e.toUpperCase();let n=e.replace(/[aeiouAEIOU]/g,``);return n.length>=2?n.slice(0,3).toUpperCase():e.slice(0,3).toUpperCase()}return t.length===2?(t[0][0]+t[1].slice(0,2)).toUpperCase():t.slice(0,3).map(e=>e[0]).join(``).toUpperCase()}function x(e,t){return e.toLowerCase().includes(t.toLowerCase())}function ne(e,t=``,n=255){let r=e.replace(/[^a-z0-9_\-.]/gi,`_`).replace(/_{2,}/g,`_`);if(!t){let n=e.split(`.`);n.length>1&&(t=n[n.length-1])}t&&!t.startsWith(`.`)&&(t=`.`+t);let i=t?t.length:0;return r.length+i>n&&(r=r.slice(0,n-i)+(t||``)),r}function S(e,t){let n=[],r=0,i=e.length;for(;r<i;)n.push(e.slice(r,r+=t));return n}var C=Object.freeze([]),w=Object.freeze({}),T=Object.freeze(new Set),E=Object.freeze(new Map),D=`Unlabelled asset`,O=[n.PLANNED,n.ACTIVE,n.MAINTENANCE,n.INACTIVE,n.RETIRED,n.DISPOSED],k=`Untitled issue`,A=[a.LOWEST,a.LOW,a.MEDIUM,a.HIGH,a.HIGHEST],j=[i.BACKLOG,i.PLANNED,i.IN_PROGRESS,i.COMPLETED,i.CANCELLED],M=[t.GUEST,t.BASIC,t.ADMIN],N=`Untitled document`,P=`Unknown user`,F=`An unexpected error occurred. Please try again later.`,I=`(Pending)`,L=1,R=7,z=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,B=(e,t)=>x(e.label||`Unlabelled asset`,t)||x(e.index?.toString()??`(Pending)`,t),V=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,re=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,H=(e,t)=>x(e.title||`Untitled issue`,t)||x(e.index?.toString()??`(Pending)`,t);function U(e,t){return v(e.uuid,t.uuid)}var W=(e,t)=>e.submitted_at===t.submitted_at?0:e.submitted_at<t.submitted_at?-1:1,G=(e,t)=>e.name.localeCompare(t.name),K=(e,t)=>x(e.name,t),q=(e,t)=>`${e.abbr}-${t.index??`(Pending)`}`;function J(e,t){if(!t)throw Error(`Missing required 'options' parameter.`);let{id:n,parentId:r,childIds:i,valueResolver:a,valueKey:o=`value`,parentKey:s=`parent`,childrenKey:c=`children`,depthKey:l=!1,validateTree:u=!1,validateReferences:d=!1,includeEmptyChildrenArray:f=!1}=t;if(!n)throw Error(`Option 'id' is required.`);if(!r&&!i)throw Error(`Either 'parentId' or 'childIds' must be provided.`);if(r&&i)throw Error(`'parentId' and 'childIds' cannot be used together.`);let p=[],m=new Map;if(r){let t=new Map;for(let i of e){let e=typeof n==`function`?n(i):i[n];if(m.has(e))throw Error(`Duplicate identifier '${e}'.`);let l=o===!1?{...a?a(i):i}:{[o]:a?a(i):i};o===!1&&(s!==!1&&delete l[s],delete l[c]),f&&(l[c]=[]),m.set(e,l);let u=typeof r==`function`?r(i):i[r],d=m.get(u);if(d)d[c]||=[],d[c].push(l),s!==!1&&(l[s]=d);else{let e=t.get(u);e?e.push(l):t.set(u,[l])}let p=t.get(e);if(p){if(l[c]=p,s!==!1)for(let e of p)e[s]=l;t.delete(e)}}for(let[e,n]of t.entries()){if(d&&e!=null)throw Error(`Referential integrity violation: parentId '${e}' does not match any item in the input.`);for(let e of n)p.push(e)}}else if(i){let t=new Map,r=new Map;for(let l of e){let e=typeof n==`function`?n(l):l[n];if(m.has(e))throw Error(`Duplicate identifier '${e}'.`);let u=o===!1?{...a?a(l):l}:{[o]:a?a(l):l};o===!1&&(s!==!1&&delete u[s],delete u[c]),f&&(u[c]=[]),m.set(e,u);let d=typeof i==`function`?i(l):l[i];if(d!=null){if(typeof d[Symbol.iterator]!=`function`)throw Error(`Item '${e}' has invalid children: expected an iterable value.`);u[c]=[];for(let e of d){let n=m.get(e);if(n){if(u[c].push(n),s!==!1){if(n[s]&&n[s]!==u)throw Error(`Node '${e}' already has a different parent, refusing to overwrite.`);n[s]=u}r.delete(e)}else{if(t.has(e))throw Error(`Multiple parents reference the same unresolved child '${e}'.`);t.set(e,{parentNode:u,childIndex:u[c].length}),u[c].push(null)}}u[c].length===0&&delete u[c]}let p=t.get(e);if(p){let{parentNode:n,childIndex:r}=p;if(n[c][r]=u,s!==!1){if(u[s]&&u[s]!==n)throw Error(`Node '${e}' already has a different parent, refusing to overwrite.`);u[s]=n}t.delete(e)}else r.set(e,u)}if(t.size>0){if(d){let e=t.keys().next().value;throw Error(`Referential integrity violation: child reference '${e}' does not match any item in the input.`)}let e=Array.from(t.values());for(let t=e.length-1;t>=0;t--){let{parentNode:n,childIndex:r}=e[t];n[c].splice(r,1),n[c].length===0&&delete n[c]}}for(let e of r.values())p.push(e)}let h=typeof l==`string`||typeof l==`symbol`||typeof l==`number`;if(u||h){if(p.length===0&&m.size>0)throw Error(`Tree validation failed: detected a cycle.`);let e=[...p].map(e=>({node:e,depth:0})),t=new Set,n=0,r=m.size;for(;e.length>0&&n++<=r;){let{node:n,depth:r}=e.pop();if(t.has(n))throw Error(`Tree validation failed: a node reachable via multiple paths.`);if(t.add(n),h&&(n[l]=r),n[c])for(let t of n[c])e.push({node:t,depth:r+1})}if(m.size!==t.size)throw Error(`Tree validation failed: detected a cycle.`)}return{roots:p,nodes:m}}var Y=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTraversalStrategy=e.TreeNode=void 0,e.TreeNode=class{constructor(e,t,n){this.children=[],this.strategy=this.depthFirstSearch,this.model=e,this.index=t,n&&(this.strategy=n)}addChild(e){e&&this.children.push(e)}removeChild(e){e&&(this.children=this.children.filter(t=>t!==e))}moveChild(e,t){e&&t&&(this.removeChild(e),t.addChild(e))}findChild(e,t){let n;n=typeof e==`function`?e:n=>n.model[e]===t;for(let e of this.children){if(n(e))return e;if(e.children){let t=e.findChild(n);if(t)return t}}return null}getPath(e){let t=[],n=r=>{if(!r)return!1;if(t.push(r),r===e)return!0;for(let e of r.children)if(n(e))return!0;return t.pop(),!1};return n(this),t.length>0?t:null}getReversePath(e){let t=this.getPath(e);return t?t.reverse():null}getParent(e){if(!e)return null;for(let t of this.children){if(t.children.includes(e))return t;let n=t.getParent(e);if(n)return n}return null}findChildren(e,t){let n;return n=typeof e==`function`?e:n=>n.model[e]===t,this.children.filter(n)}deleteChildren(e,t){let n;n=typeof e==`function`?e:n=>n.model[e]===t,this.children=this.children.filter(e=>!n(e))}insertChild(e,t,n){if(!e||!this.children)return;let r=typeof t==`function`?this.children.findIndex(t):this.children.findIndex(e=>e.model[t]===n);r===-1?this.children.push(e):this.children.splice(r,0,e)}depthFirstSearch(e,t=`in-order`){let n=[],r=e=>{t.includes(`pre-order`)&&n.push(e);for(let t of e.children)r(t);(t.includes(`in-order`)||t.includes(`post-order`))&&n.push(e)};return r(e),t===`reverse-pre-order`||t===`reverse-post-order`||t===`reverse-in-order`?n.reverse():n}breadthFirstOrder(e){let t=[],n=[e];for(;n.length>0;){let e=n.shift();t.push(e),n.push(...e.children)}return t}};function t(e){return e.depthFirstSearch(e)}e.defaultTraversalStrategy=t})),X=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tree=void 0;var t=Y();e.Tree=class{constructor(e,n){this.strategy=t.defaultTraversalStrategy,this.root=e?this.parse(e):null,n&&(this.strategy=n)}parse(e){if(!e)return null;let n=new t.TreeNode(e,0);return e.children&&this.parseChildren(n,e.children),n}parseChildren(e,n){n&&n.forEach((n,r)=>{let i=new t.TreeNode(n,r+1);e.addChild(i),n.children&&this.parseChildren(i,n.children)})}all(){return this.root?this.strategy(this.root):null}remove(e){let t=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},n=(e,r)=>{t(e.children,r),e.children.forEach(e=>n(e,r))};this.root&&(this.root===e?this.root=null:n(this.root,e))}find(e,t){return this.root?this.root.findChild(e,t):null}move(e,t){e.getParent(this.root)?.removeChild(e),t.addChild(e)}getPath(e){return this.root?this.root.getPath(e):null}getReversePath(e){return this.root?this.root.getReversePath(e):null}walk(e){var t;(t=this.root)==null||t.depthFirstSearch(this.root).forEach(e)}insertChild(e,t,n){let r;r=typeof t==`function`?t:e=>e.model[t]===n;let i=this.root?this.strategy(this.root):[];for(let t of i)if(r(t)){t.addChild(e);return}}}})),Z=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTraversalStrategy=e.TreeNode=e.Tree=void 0;var t=X();Object.defineProperty(e,"Tree",{enumerable:!0,get:function(){return t.Tree}});var n=Y();Object.defineProperty(e,"TreeNode",{enumerable:!0,get:function(){return n.TreeNode}}),Object.defineProperty(e,"defaultTraversalStrategy",{enumerable:!0,get:function(){return n.defaultTraversalStrategy}})}))(),Q=e=>J(e,{id:e=>e.uuid,parentId:e=>e.parent_document,includeEmptyChildrenArray:!0,valueKey:!1}),ie=e=>{let{roots:t}=Q(e);return t.map(e=>new Z.Tree(e))},ae=(e,t)=>{let{nodes:n}=Q(t),r=n.get(e);if(!r)throw Error(`Node with uuid ${e} does not exist in document tree.`);return new Z.Tree(r)},oe=e=>e.length===0?C:e,se=e=>Object.keys(e).length===0?w:e,ce=e=>e.size===0?T:e,le=e=>e.size===0?w:e;function $(e){return e instanceof Error&&e.name===`AbortError`}var ue=class{[Symbol.toStringTag]=`Promise`;_promise;_resolve;_reject;_state=`pending`;get state(){return this._state}constructor(){this._resolve=null,this._reject=null,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw Error(`No resolve callback`);this._resolve(e),this._state=`fulfilled`}reject(e){if(!this._reject)throw e;this._reject(e),this._state=`rejected`}finally(e){throw Error("`finally` not implemented")}},de=class e extends Promise{_uuid;constructor(e,t){super(e),this._uuid=t}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(t,n){return new e((e,n)=>{Promise.resolve(t).then(e).catch(n)},n)}then(e,t){let n=super.then(e,t);return n.uuid=this.uuid,n}catch(e){let t=super.catch(e);return t.uuid=this.uuid,t}finally(e){let t=super.finally(e);return t.uuid=this.uuid,t}};exports.ABBREVIATION_MAX_LENGTH=R,exports.ABBREVIATION_MIN_LENGTH=L,exports.ASSET_STATUS_TYPES=O,exports.AssetStatusType=n,exports.DeferredPromise=ue,exports.EMPTY_ARRAY=C,exports.EMPTY_MAP=E,exports.EMPTY_OBJECT=w,exports.EMPTY_SET=T,exports.ERROR_MSG_UNEXPECTED=F,exports.INDEX_FALLBACK=I,exports.ISSUE_PRIORITY_TYPES=A,exports.ISSUE_STATUS_TYPES=j,exports.IssuePriorityType=a,exports.IssueStatusType=i,exports.IssueUpdateChange=r,exports.NON_EXISTING_USER_NAME=P,exports.ORGANIZATION_ACCESS_LEVELS=M,exports.OrganizationAccessLevel=t,exports.ProcedureStepEventType=o,exports.ProcedureStepFieldValuesReviewType=s,exports.UNLABELLED_ASSET_LABEL=D,exports.UNTITLED_DOCUMENT_TITLE=N,exports.UNTITLED_ISSUE_TITLE=k,exports.UUIDPromise=de,exports.VerificationCodeType=c,exports.assetFilterCallback=B,exports.assetTypeStatusSortFn=z,exports.chunkArray=S,exports.computeModelIndex=q,exports.fallbackToEmptyArray=oe,exports.fallbackToEmptyMap=le,exports.fallbackToEmptyObject=se,exports.fallbackToEmptySet=ce,exports.generateAbbreviation=te,exports.getDocumentSubTree=ae,exports.getDocumentTrees=ie,exports.includesLowercase=x,exports.isAbortError=$,exports.issueFilterCallback=H,exports.issueTypePrioritySortFn=re,exports.issueTypeStatusSortFn=V,exports.nameModelFilterFn=K,exports.nameModelSortFn=G,exports.pluralize=b,exports.submittedAtModelSortFn=W,exports.toFileNameSafeString=ne,exports.toUuidArray=_,exports.toUuidIdRecord=ee,exports.truncate=y,exports.uuidModelSortFn=U,exports.uuidObj=g,exports.uuidSortFn=v;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),t=function(e){return e[e.GUEST=0]=`GUEST`,e[e.BASIC=2]=`BASIC`,e[e.ADMIN=4]=`ADMIN`,e}({}),n=function(e){return e[e.PLANNED=0]=`PLANNED`,e[e.ACTIVE=1]=`ACTIVE`,e[e.MAINTENANCE=2]=`MAINTENANCE`,e[e.INACTIVE=3]=`INACTIVE`,e[e.RETIRED=4]=`RETIRED`,e[e.DISPOSED=5]=`DISPOSED`,e}({}),r=function(e){return e.STATUS=`status`,e.PRIORITY=`priority`,e.DESCRIPTION=`description`,e.TITLE=`title`,e.ASSIGNED_TO=`assigned_to`,e.DUE_DATE=`due_date`,e}({}),i=function(e){return e[e.BACKLOG=0]=`BACKLOG`,e[e.PLANNED=1]=`PLANNED`,e[e.IN_PROGRESS=2]=`IN_PROGRESS`,e[e.COMPLETED=3]=`COMPLETED`,e[e.CANCELLED=4]=`CANCELLED`,e}({}),a=function(e){return e[e.LOWEST=0]=`LOWEST`,e[e.LOW=2]=`LOW`,e[e.MEDIUM=4]=`MEDIUM`,e[e.HIGH=6]=`HIGH`,e[e.HIGHEST=8]=`HIGHEST`,e}({}),o=function(e){return e[e.ADD_ASSIGNEE=0]=`ADD_ASSIGNEE`,e[e.REMOVE_ASSIGNEE=2]=`REMOVE_ASSIGNEE`,e[e.ADD_REVIEWER=4]=`ADD_REVIEWER`,e[e.REMOVE_REVIEWER=6]=`REMOVE_REVIEWER`,e}({}),s=function(e){return e[e.APPROVED=0]=`APPROVED`,e[e.REJECTED=2]=`REJECTED`,e[e.CHANGES_REQUESTED=4]=`CHANGES_REQUESTED`,e}({}),c=function(e){return e[e.USER_REGISTRATION=0]=`USER_REGISTRATION`,e[e.APPLICATION_INVITE=2]=`APPLICATION_INVITE`,e[e.PROJECT_INVITE=4]=`PROJECT_INVITE`,e[e.ORGANIZATION_INVITE=6]=`ORGANIZATION_INVITE`,e[e.ADD_EMAIL_DOMAIN=8]=`ADD_EMAIL_DOMAIN`,e[e.RESET_PASSWORD=10]=`RESET_PASSWORD`,e}({}),l=[];for(let e=0;e<256;++e)l.push((e+256).toString(16).slice(1));function u(e,t=0){return(l[e[t+0]]+l[e[t+1]]+l[e[t+2]]+l[e[t+3]]+`-`+l[e[t+4]]+l[e[t+5]]+`-`+l[e[t+6]]+l[e[t+7]]+`-`+l[e[t+8]]+l[e[t+9]]+`-`+l[e[t+10]]+l[e[t+11]]+l[e[t+12]]+l[e[t+13]]+l[e[t+14]]+l[e[t+15]]).toLowerCase()}var d,f=new Uint8Array(16);function p(){if(!d){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);d=crypto.getRandomValues.bind(crypto)}return d(f)}var m={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function h(e,t,n){if(m.randomUUID&&!t&&!e)return m.randomUUID();e||={};let r=e.random??e.rng?.()??p();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return u(r)}function g(e){return{...e,uuid:h()}}function ee(e){let t={};for(let n of e)t[n.uuid]=n;return t}function _(e){return e.map(({uuid:e})=>e)}function v(e,t){return e.localeCompare(t)}function y(e,t){if(e.length<=t)return e;let n=e.slice(0,t-1);return n.slice(0,n.lastIndexOf(` `))+`…`}function b(e,t){return t===1?e:e+`s`}function te(e){let t=e.trim().split(/[\s-_]+/).filter(e=>e.length>0);if(t.length===0)return``;if(t.length===1){let e=t[0];if(e.length<=3)return e.toUpperCase();let n=e.replace(/[aeiouAEIOU]/g,``);return n.length>=2?n.slice(0,3).toUpperCase():e.slice(0,3).toUpperCase()}return t.length===2?(t[0][0]+t[1].slice(0,2)).toUpperCase():t.slice(0,3).map(e=>e[0]).join(``).toUpperCase()}function x(e,t){return e.toLowerCase().includes(t.toLowerCase())}function ne(e,t=``,n=255){let r=e.replace(/[^a-z0-9_\-.]/gi,`_`).replace(/_{2,}/g,`_`);if(!t){let n=e.split(`.`);n.length>1&&(t=n[n.length-1])}t&&!t.startsWith(`.`)&&(t=`.`+t);let i=t?t.length:0;return r.length+i>n&&(r=r.slice(0,n-i)+(t||``)),r}function S(e,t){let n=[],r=0,i=e.length;for(;r<i;)n.push(e.slice(r,r+=t));return n}var C=Object.freeze([]),w=Object.freeze({}),T=Object.freeze(new Set),E=Object.freeze(new Map),D=`Unlabelled asset`,O=[n.PLANNED,n.ACTIVE,n.MAINTENANCE,n.INACTIVE,n.RETIRED,n.DISPOSED],k=`Untitled issue`,A=[a.LOWEST,a.LOW,a.MEDIUM,a.HIGH,a.HIGHEST],j=[i.BACKLOG,i.PLANNED,i.IN_PROGRESS,i.COMPLETED,i.CANCELLED],M=[t.GUEST,t.BASIC,t.ADMIN],N=`Untitled document`,P=`Unknown user`,F=`An unexpected error occurred. Please try again later.`,I=`(Pending)`,L=1,R=7,z=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,B=(e,t)=>x(e.label||`Unlabelled asset`,t)||x(e.index?.toString()??`(Pending)`,t),V=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,re=(e,t)=>e.type===t.type?e.order-t.order:e.type-t.type,H=(e,t)=>x(e.title||`Untitled issue`,t)||x(e.index?.toString()??`(Pending)`,t);function U(e,t){return v(e.uuid,t.uuid)}var W=(e,t)=>e.submitted_at===t.submitted_at?0:e.submitted_at<t.submitted_at?-1:1,G=(e,t)=>e.name.localeCompare(t.name),K=(e,t)=>x(e.name,t),q=(e,t)=>`${e.abbr}-${t.index??`(Pending)`}`;function J(e,t){if(!t)throw Error(`Missing required 'options' parameter.`);let{id:n,parentId:r,childIds:i,valueResolver:a,valueKey:o=`value`,parentKey:s=`parent`,childrenKey:c=`children`,depthKey:l=!1,validateTree:u=!1,validateReferences:d=!1,includeEmptyChildrenArray:f=!1}=t;if(!n)throw Error(`Option 'id' is required.`);if(!r&&!i)throw Error(`Either 'parentId' or 'childIds' must be provided.`);if(r&&i)throw Error(`'parentId' and 'childIds' cannot be used together.`);let p=[],m=new Map;if(r){let t=new Map;for(let i of e){let e=typeof n==`function`?n(i):i[n];if(m.has(e))throw Error(`Duplicate identifier '${e}'.`);let l=o===!1?{...a?a(i):i}:{[o]:a?a(i):i};o===!1&&(s!==!1&&delete l[s],delete l[c]),f&&(l[c]=[]),m.set(e,l);let u=typeof r==`function`?r(i):i[r],d=m.get(u);if(d)d[c]||=[],d[c].push(l),s!==!1&&(l[s]=d);else{let e=t.get(u);e?e.push(l):t.set(u,[l])}let p=t.get(e);if(p){if(l[c]=p,s!==!1)for(let e of p)e[s]=l;t.delete(e)}}for(let[e,n]of t.entries()){if(d&&e!=null)throw Error(`Referential integrity violation: parentId '${e}' does not match any item in the input.`);for(let e of n)p.push(e)}}else if(i){let t=new Map,r=new Map;for(let l of e){let e=typeof n==`function`?n(l):l[n];if(m.has(e))throw Error(`Duplicate identifier '${e}'.`);let u=o===!1?{...a?a(l):l}:{[o]:a?a(l):l};o===!1&&(s!==!1&&delete u[s],delete u[c]),f&&(u[c]=[]),m.set(e,u);let d=typeof i==`function`?i(l):l[i];if(d!=null){if(typeof d[Symbol.iterator]!=`function`)throw Error(`Item '${e}' has invalid children: expected an iterable value.`);u[c]=[];for(let e of d){let n=m.get(e);if(n){if(u[c].push(n),s!==!1){if(n[s]&&n[s]!==u)throw Error(`Node '${e}' already has a different parent, refusing to overwrite.`);n[s]=u}r.delete(e)}else{if(t.has(e))throw Error(`Multiple parents reference the same unresolved child '${e}'.`);t.set(e,{parentNode:u,childIndex:u[c].length}),u[c].push(null)}}u[c].length===0&&delete u[c]}let p=t.get(e);if(p){let{parentNode:n,childIndex:r}=p;if(n[c][r]=u,s!==!1){if(u[s]&&u[s]!==n)throw Error(`Node '${e}' already has a different parent, refusing to overwrite.`);u[s]=n}t.delete(e)}else r.set(e,u)}if(t.size>0){if(d){let e=t.keys().next().value;throw Error(`Referential integrity violation: child reference '${e}' does not match any item in the input.`)}let e=Array.from(t.values());for(let t=e.length-1;t>=0;t--){let{parentNode:n,childIndex:r}=e[t];n[c].splice(r,1),n[c].length===0&&delete n[c]}}for(let e of r.values())p.push(e)}let h=typeof l==`string`||typeof l==`symbol`||typeof l==`number`;if(u||h){if(p.length===0&&m.size>0)throw Error(`Tree validation failed: detected a cycle.`);let e=[...p].map(e=>({node:e,depth:0})),t=new Set,n=0,r=m.size;for(;e.length>0&&n++<=r;){let{node:n,depth:r}=e.pop();if(t.has(n))throw Error(`Tree validation failed: a node reachable via multiple paths.`);if(t.add(n),h&&(n[l]=r),n[c])for(let t of n[c])e.push({node:t,depth:r+1})}if(m.size!==t.size)throw Error(`Tree validation failed: detected a cycle.`)}return{roots:p,nodes:m}}var Y=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTraversalStrategy=e.TreeNode=void 0,e.TreeNode=class{constructor(e,t,n){this.children=[],this.strategy=this.depthFirstSearch,this.model=e,this.index=t,n&&(this.strategy=n)}addChild(e){e&&this.children.push(e)}removeChild(e){e&&(this.children=this.children.filter(t=>t!==e))}moveChild(e,t){e&&t&&(this.removeChild(e),t.addChild(e))}findChild(e,t){let n;n=typeof e==`function`?e:n=>n.model[e]===t;for(let e of this.children){if(n(e))return e;if(e.children){let t=e.findChild(n);if(t)return t}}return null}getPath(e){let t=[],n=r=>{if(!r)return!1;if(t.push(r),r===e)return!0;for(let e of r.children)if(n(e))return!0;return t.pop(),!1};return n(this),t.length>0?t:null}getReversePath(e){let t=this.getPath(e);return t?t.reverse():null}getParent(e){if(!e)return null;for(let t of this.children){if(t.children.includes(e))return t;let n=t.getParent(e);if(n)return n}return null}findChildren(e,t){let n;return n=typeof e==`function`?e:n=>n.model[e]===t,this.children.filter(n)}deleteChildren(e,t){let n;n=typeof e==`function`?e:n=>n.model[e]===t,this.children=this.children.filter(e=>!n(e))}insertChild(e,t,n){if(!e||!this.children)return;let r=typeof t==`function`?this.children.findIndex(t):this.children.findIndex(e=>e.model[t]===n);r===-1?this.children.push(e):this.children.splice(r,0,e)}depthFirstSearch(e,t=`in-order`){let n=[],r=e=>{t.includes(`pre-order`)&&n.push(e);for(let t of e.children)r(t);(t.includes(`in-order`)||t.includes(`post-order`))&&n.push(e)};return r(e),t===`reverse-pre-order`||t===`reverse-post-order`||t===`reverse-in-order`?n.reverse():n}breadthFirstOrder(e){let t=[],n=[e];for(;n.length>0;){let e=n.shift();t.push(e),n.push(...e.children)}return t}};function t(e){return e.depthFirstSearch(e)}e.defaultTraversalStrategy=t})),X=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tree=void 0;var t=Y();e.Tree=class{constructor(e,n){this.strategy=t.defaultTraversalStrategy,this.root=e?this.parse(e):null,n&&(this.strategy=n)}parse(e){if(!e)return null;let n=new t.TreeNode(e,0);return e.children&&this.parseChildren(n,e.children),n}parseChildren(e,n){n&&n.forEach((n,r)=>{let i=new t.TreeNode(n,r+1);e.addChild(i),n.children&&this.parseChildren(i,n.children)})}all(){return this.root?this.strategy(this.root):null}remove(e){let t=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},n=(e,r)=>{t(e.children,r),e.children.forEach(e=>n(e,r))};this.root&&(this.root===e?this.root=null:n(this.root,e))}find(e,t){return this.root?this.root.findChild(e,t):null}move(e,t){e.getParent(this.root)?.removeChild(e),t.addChild(e)}getPath(e){return this.root?this.root.getPath(e):null}getReversePath(e){return this.root?this.root.getReversePath(e):null}walk(e){var t;(t=this.root)==null||t.depthFirstSearch(this.root).forEach(e)}insertChild(e,t,n){let r;r=typeof t==`function`?t:e=>e.model[t]===n;let i=this.root?this.strategy(this.root):[];for(let t of i)if(r(t)){t.addChild(e);return}}}})),Z=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defaultTraversalStrategy=e.TreeNode=e.Tree=void 0;var t=X();Object.defineProperty(e,"Tree",{enumerable:!0,get:function(){return t.Tree}});var n=Y();Object.defineProperty(e,"TreeNode",{enumerable:!0,get:function(){return n.TreeNode}}),Object.defineProperty(e,"defaultTraversalStrategy",{enumerable:!0,get:function(){return n.defaultTraversalStrategy}})}))(),Q=e=>J(e,{id:e=>e.uuid,parentId:e=>e.parent_document,includeEmptyChildrenArray:!0,valueKey:!1}),ie=e=>{let{roots:t}=Q(e);return t.map(e=>new Z.Tree(e))},ae=(e,t)=>{let{nodes:n}=Q(t),r=n.get(e);if(!r)throw Error(`Node with uuid ${e} does not exist in document tree.`);return new Z.Tree(r)},oe=(e,t)=>e.email.localeCompare(t.email),se=e=>e.length===0?C:e,ce=e=>Object.keys(e).length===0?w:e,le=e=>e.size===0?T:e,$=e=>e.size===0?w:e;function ue(e){return e instanceof Error&&e.name===`AbortError`}var de=class{[Symbol.toStringTag]=`Promise`;_promise;_resolve;_reject;_state=`pending`;get state(){return this._state}constructor(){this._resolve=null,this._reject=null,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}then(e,t){return this._promise.then(e,t)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw Error(`No resolve callback`);this._resolve(e),this._state=`fulfilled`}reject(e){if(!this._reject)throw e;this._reject(e),this._state=`rejected`}finally(e){throw Error("`finally` not implemented")}},fe=class e extends Promise{_uuid;constructor(e,t){super(e),this._uuid=t}get uuid(){return this._uuid}set uuid(e){this._uuid=e}static from(t,n){return new e((e,n)=>{Promise.resolve(t).then(e).catch(n)},n)}then(e,t){let n=super.then(e,t);return n.uuid=this.uuid,n}catch(e){let t=super.catch(e);return t.uuid=this.uuid,t}finally(e){let t=super.finally(e);return t.uuid=this.uuid,t}};exports.ABBREVIATION_MAX_LENGTH=R,exports.ABBREVIATION_MIN_LENGTH=L,exports.ASSET_STATUS_TYPES=O,exports.AssetStatusType=n,exports.DeferredPromise=de,exports.EMPTY_ARRAY=C,exports.EMPTY_MAP=E,exports.EMPTY_OBJECT=w,exports.EMPTY_SET=T,exports.ERROR_MSG_UNEXPECTED=F,exports.INDEX_FALLBACK=I,exports.ISSUE_PRIORITY_TYPES=A,exports.ISSUE_STATUS_TYPES=j,exports.IssuePriorityType=a,exports.IssueStatusType=i,exports.IssueUpdateChange=r,exports.NON_EXISTING_USER_NAME=P,exports.ORGANIZATION_ACCESS_LEVELS=M,exports.OrganizationAccessLevel=t,exports.ProcedureStepEventType=o,exports.ProcedureStepFieldValuesReviewType=s,exports.UNLABELLED_ASSET_LABEL=D,exports.UNTITLED_DOCUMENT_TITLE=N,exports.UNTITLED_ISSUE_TITLE=k,exports.UUIDPromise=fe,exports.VerificationCodeType=c,exports.assetFilterCallback=B,exports.assetTypeStatusSortFn=z,exports.chunkArray=S,exports.computeModelIndex=q,exports.fallbackToEmptyArray=se,exports.fallbackToEmptyMap=$,exports.fallbackToEmptyObject=ce,exports.fallbackToEmptySet=le,exports.generateAbbreviation=te,exports.getDocumentSubTree=ae,exports.getDocumentTrees=ie,exports.includesLowercase=x,exports.isAbortError=ue,exports.issueFilterCallback=H,exports.issueTypePrioritySortFn=re,exports.issueTypeStatusSortFn=V,exports.nameModelFilterFn=K,exports.nameModelSortFn=G,exports.pluralize=b,exports.submittedAtModelSortFn=W,exports.toFileNameSafeString=ne,exports.toUuidArray=_,exports.toUuidIdRecord=ee,exports.truncate=y,exports.userSortFn=oe,exports.uuidModelSortFn=U,exports.uuidObj=g,exports.uuidSortFn=v;
|
package/dist/index.js
CHANGED
|
@@ -416,15 +416,15 @@ var Y = /* @__PURE__ */ e(((e) => {
|
|
|
416
416
|
let { nodes: n } = Q(t), r = n.get(e);
|
|
417
417
|
if (!r) throw Error(`Node with uuid ${e} does not exist in document tree.`);
|
|
418
418
|
return new Z.Tree(r);
|
|
419
|
-
}, oe = (e) => e.length === 0 ? C : e,
|
|
419
|
+
}, oe = (e, t) => e.email.localeCompare(t.email), se = (e) => e.length === 0 ? C : e, ce = (e) => Object.keys(e).length === 0 ? w : e, le = (e) => e.size === 0 ? T : e, $ = (e) => e.size === 0 ? w : e;
|
|
420
420
|
//#endregion
|
|
421
421
|
//#region src/utils/errors.ts
|
|
422
|
-
function
|
|
422
|
+
function ue(e) {
|
|
423
423
|
return e instanceof Error && e.name === "AbortError";
|
|
424
424
|
}
|
|
425
425
|
//#endregion
|
|
426
426
|
//#region src/classes/DeferredPromise.ts
|
|
427
|
-
var
|
|
427
|
+
var de = class {
|
|
428
428
|
[Symbol.toStringTag] = "Promise";
|
|
429
429
|
_promise;
|
|
430
430
|
_resolve;
|
|
@@ -455,7 +455,7 @@ var ue = class {
|
|
|
455
455
|
finally(e) {
|
|
456
456
|
throw Error("`finally` not implemented");
|
|
457
457
|
}
|
|
458
|
-
},
|
|
458
|
+
}, fe = class e extends Promise {
|
|
459
459
|
_uuid;
|
|
460
460
|
constructor(e, t) {
|
|
461
461
|
super(e), this._uuid = t;
|
|
@@ -485,4 +485,4 @@ var ue = class {
|
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
//#endregion
|
|
488
|
-
export { R as ABBREVIATION_MAX_LENGTH, L as ABBREVIATION_MIN_LENGTH, O as ASSET_STATUS_TYPES, n as AssetStatusType,
|
|
488
|
+
export { R as ABBREVIATION_MAX_LENGTH, L as ABBREVIATION_MIN_LENGTH, O as ASSET_STATUS_TYPES, n as AssetStatusType, de as DeferredPromise, C as EMPTY_ARRAY, E as EMPTY_MAP, w as EMPTY_OBJECT, T as EMPTY_SET, F as ERROR_MSG_UNEXPECTED, I as INDEX_FALLBACK, A as ISSUE_PRIORITY_TYPES, j as ISSUE_STATUS_TYPES, a as IssuePriorityType, i as IssueStatusType, r as IssueUpdateChange, P as NON_EXISTING_USER_NAME, M as ORGANIZATION_ACCESS_LEVELS, t as OrganizationAccessLevel, o as ProcedureStepEventType, s as ProcedureStepFieldValuesReviewType, D as UNLABELLED_ASSET_LABEL, N as UNTITLED_DOCUMENT_TITLE, k as UNTITLED_ISSUE_TITLE, fe as UUIDPromise, c as VerificationCodeType, B as assetFilterCallback, z as assetTypeStatusSortFn, S as chunkArray, q as computeModelIndex, se as fallbackToEmptyArray, $ as fallbackToEmptyMap, ce as fallbackToEmptyObject, le as fallbackToEmptySet, te as generateAbbreviation, ae as getDocumentSubTree, ie as getDocumentTrees, x as includesLowercase, ue as isAbortError, H as issueFilterCallback, re as issueTypePrioritySortFn, V as issueTypeStatusSortFn, K as nameModelFilterFn, G as nameModelSortFn, b as pluralize, W as submittedAtModelSortFn, ne as toFileNameSafeString, _ as toUuidArray, ee as toUuidIdRecord, y as truncate, oe as userSortFn, U as uuidModelSortFn, g as uuidObj, v as uuidSortFn };
|