notu 0.2.0 → 0.2.2

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.
@@ -0,0 +1,5 @@
1
+ (function(w,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(w=typeof globalThis<"u"?globalThis:w||self,E(w.notu={}))})(this,function(w){"use strict";var pn=Object.defineProperty;var mn=(w,E,N)=>E in w?pn(w,E,{enumerable:!0,configurable:!0,writable:!0,value:N}):w[E]=N;var h=(w,E,N)=>(mn(w,typeof E!="symbol"?E+"":E,N),N);class E{constructor(){h(this,"state","NEW")}new(){return this.state="NEW",this}clean(){return this.state="CLEAN",this}dirty(){return this.state="DIRTY",this}delete(){return this.state="DELETED",this}get isNew(){return this.state=="NEW"}get isClean(){return this.state=="CLEAN"}get isDirty(){return this.state=="DIRTY"}get isDeleted(){return this.state=="DELETED"}validate(n=!1){return!0}}class N extends E{constructor(){super(...arguments);h(this,"id",0);h(this,"_name","");h(this,"_type","TEXT");h(this,"_spaceId",0);h(this,"_space",null)}get name(){return this._name}set name(t){t!==this._name&&(this._name=t,this.isClean&&this.dirty())}get type(){return this._type}set type(t){if(!this.isNew)throw Error("Cannot change an attribute's type once it has been created.");this._type=t}get isText(){return this.type=="TEXT"}get isNumber(){return this.type=="NUMBER"}get isBoolean(){return this.type=="BOOLEAN"}get isDate(){return this.type=="DATE"}asText(){return this.type="TEXT",this}asNumber(){return this.type="NUMBER",this}asBoolean(){return this.type="BOOLEAN",this}asDate(){return this.type="DATE",this}get spaceId(){return this._spaceId}set spaceId(t){var s;t!==this._spaceId&&(this._spaceId=t,t!==((s=this.space)==null?void 0:s.id)&&(this._space=null),this.isClean&&this.dirty())}get space(){return this._space}set space(t){this._space=t,this.spaceId=(t==null?void 0:t.id)??0}duplicate(){const t=new N;return t.id=this.id,t.name=this.name,t.type=this.type,t.space=this.space,t}validate(t=!1){let s=null;if(this.spaceId<=0?s="Note spaceId must be greater than zero.":!this.isNew&&this.id<=0&&(s="Attr id must be greater than zero if in non-new state."),t&&s!=null)throw Error(s);return s==null}get defaultValue(){switch(this.type){case"TEXT":return"";case"NUMBER":return 0;case"BOOLEAN":return!1;case"DATE":return new Date}}}class Kt{constructor(n){h(this,"_client",null);h(this,"_spaces",[]);if(!n)throw Error("Client must be set on Environment constructor");this._client=n}get client(){return this._client}get spaces(){return this._spaces}async loadSpaces(){return this._spaces=await this.client.getSpaces(),this.spaces}async saveSpace(n){return await this.client.saveSpace(n)}async getNotes(n,t){return await this.client.getNotes(n,t)}async getNoteCount(n,t){return await this.client.getNoteCount(n,t)}async saveNote(n){return(await this.client.saveNotes([n]))[0]}async saveNotes(n){return await this.client.saveNotes(n)}async customJob(n,t){return await this.client.customJob(n,t)}}function pt(e,n){return function(){return e.apply(n,arguments)}}const{toString:Xt}=Object.prototype,{getPrototypeOf:Q}=Object,k=(e=>n=>{const t=Xt.call(n);return e[t]||(e[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),R=e=>(e=e.toLowerCase(),n=>k(n)===e),j=e=>n=>typeof n===e,{isArray:P}=Array,B=j("undefined");function Gt(e){return e!==null&&!B(e)&&e.constructor!==null&&!B(e.constructor)&&S(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const mt=R("ArrayBuffer");function Qt(e){let n;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?n=ArrayBuffer.isView(e):n=e&&e.buffer&&mt(e.buffer),n}const Yt=j("string"),S=j("function"),gt=j("number"),z=e=>e!==null&&typeof e=="object",Zt=e=>e===!0||e===!1,H=e=>{if(k(e)!=="object")return!1;const n=Q(e);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},vt=R("Date"),te=R("File"),ee=R("Blob"),ne=R("FileList"),se=e=>z(e)&&S(e.pipe),re=e=>{let n;return e&&(typeof FormData=="function"&&e instanceof FormData||S(e.append)&&((n=k(e))==="formdata"||n==="object"&&S(e.toString)&&e.toString()==="[object FormData]"))},ie=R("URLSearchParams"),oe=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function F(e,n,{allOwnKeys:t=!1}={}){if(e===null||typeof e>"u")return;let s,r;if(typeof e!="object"&&(e=[e]),P(e))for(s=0,r=e.length;s<r;s++)n.call(null,e[s],s,e);else{const i=t?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let c;for(s=0;s<o;s++)c=i[s],n.call(null,e[c],c,e)}}function wt(e,n){n=n.toLowerCase();const t=Object.keys(e);let s=t.length,r;for(;s-- >0;)if(r=t[s],n===r.toLowerCase())return r;return null}const yt=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Et=e=>!B(e)&&e!==yt;function Y(){const{caseless:e}=Et(this)&&this||{},n={},t=(s,r)=>{const i=e&&wt(n,r)||r;H(n[i])&&H(s)?n[i]=Y(n[i],s):H(s)?n[i]=Y({},s):P(s)?n[i]=s.slice():n[i]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&F(arguments[s],t);return n}const ae=(e,n,t,{allOwnKeys:s}={})=>(F(n,(r,i)=>{t&&S(r)?e[i]=pt(r,t):e[i]=r},{allOwnKeys:s}),e),ce=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ue=(e,n,t,s)=>{e.prototype=Object.create(n.prototype,s),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:n.prototype}),t&&Object.assign(e.prototype,t)},le=(e,n,t,s)=>{let r,i,o;const c={};if(n=n||{},e==null)return n;do{for(r=Object.getOwnPropertyNames(e),i=r.length;i-- >0;)o=r[i],(!s||s(o,e,n))&&!c[o]&&(n[o]=e[o],c[o]=!0);e=t!==!1&&Q(e)}while(e&&(!t||t(e,n))&&e!==Object.prototype);return n},de=(e,n,t)=>{e=String(e),(t===void 0||t>e.length)&&(t=e.length),t-=n.length;const s=e.indexOf(n,t);return s!==-1&&s===t},he=e=>{if(!e)return null;if(P(e))return e;let n=e.length;if(!gt(n))return null;const t=new Array(n);for(;n-- >0;)t[n]=e[n];return t},fe=(e=>n=>e&&n instanceof e)(typeof Uint8Array<"u"&&Q(Uint8Array)),pe=(e,n)=>{const s=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=s.next())&&!r.done;){const i=r.value;n.call(e,i[0],i[1])}},me=(e,n)=>{let t;const s=[];for(;(t=e.exec(n))!==null;)s.push(t);return s},ge=R("HTMLFormElement"),we=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),bt=(({hasOwnProperty:e})=>(n,t)=>e.call(n,t))(Object.prototype),ye=R("RegExp"),_t=(e,n)=>{const t=Object.getOwnPropertyDescriptors(e),s={};F(t,(r,i)=>{let o;(o=n(r,i,e))!==!1&&(s[i]=o||r)}),Object.defineProperties(e,s)},Ee=e=>{_t(e,(n,t)=>{if(S(e)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=e[t];if(S(s)){if(n.enumerable=!1,"writable"in n){n.writable=!1;return}n.set||(n.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},be=(e,n)=>{const t={},s=r=>{r.forEach(i=>{t[i]=!0})};return P(e)?s(e):s(String(e).split(n)),t},_e=()=>{},Te=(e,n)=>(e=+e,Number.isFinite(e)?e:n),Z="abcdefghijklmnopqrstuvwxyz",Tt="0123456789",St={DIGIT:Tt,ALPHA:Z,ALPHA_DIGIT:Z+Z.toUpperCase()+Tt},Se=(e=16,n=St.ALPHA_DIGIT)=>{let t="";const{length:s}=n;for(;e--;)t+=n[Math.random()*s|0];return t};function Re(e){return!!(e&&S(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const Oe=e=>{const n=new Array(10),t=(s,r)=>{if(z(s)){if(n.indexOf(s)>=0)return;if(!("toJSON"in s)){n[r]=s;const i=P(s)?[]:{};return F(s,(o,c)=>{const d=t(o,r+1);!B(d)&&(i[c]=d)}),n[r]=void 0,i}}return s};return t(e,0)},Ae=R("AsyncFunction"),a={isArray:P,isArrayBuffer:mt,isBuffer:Gt,isFormData:re,isArrayBufferView:Qt,isString:Yt,isNumber:gt,isBoolean:Zt,isObject:z,isPlainObject:H,isUndefined:B,isDate:vt,isFile:te,isBlob:ee,isRegExp:ye,isFunction:S,isStream:se,isURLSearchParams:ie,isTypedArray:fe,isFileList:ne,forEach:F,merge:Y,extend:ae,trim:oe,stripBOM:ce,inherits:ue,toFlatObject:le,kindOf:k,kindOfTest:R,endsWith:de,toArray:he,forEachEntry:pe,matchAll:me,isHTMLForm:ge,hasOwnProperty:bt,hasOwnProp:bt,reduceDescriptors:_t,freezeMethods:Ee,toObjectSet:be,toCamelCase:we,noop:_e,toFiniteNumber:Te,findKey:wt,global:yt,isContextDefined:Et,ALPHABET:St,generateString:Se,isSpecCompliantForm:Re,toJSONObject:Oe,isAsyncFn:Ae,isThenable:e=>e&&(z(e)||S(e))&&S(e.then)&&S(e.catch)};function g(e,n,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",n&&(this.code=n),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r)}a.inherits(g,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Rt=g.prototype,Ot={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Ot[e]={value:e}}),Object.defineProperties(g,Ot),Object.defineProperty(Rt,"isAxiosError",{value:!0}),g.from=(e,n,t,s,r,i)=>{const o=Object.create(Rt);return a.toFlatObject(e,o,function(d){return d!==Error.prototype},c=>c!=="isAxiosError"),g.call(o,e.message,n,t,s,r),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};const Ne=null;function v(e){return a.isPlainObject(e)||a.isArray(e)}function At(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Nt(e,n,t){return e?e.concat(n).map(function(r,i){return r=At(r),!t&&i?"["+r+"]":r}).join(t?".":""):n}function xe(e){return a.isArray(e)&&!e.some(v)}const Ie=a.toFlatObject(a,{},null,function(n){return/^is[A-Z]/.test(n)});function M(e,n,t){if(!a.isObject(e))throw new TypeError("target must be an object");n=n||new FormData,t=a.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,T){return!a.isUndefined(T[m])});const s=t.metaTokens,r=t.visitor||u,i=t.dots,o=t.indexes,d=(t.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(n);if(!a.isFunction(r))throw new TypeError("visitor must be a function");function f(l){if(l===null)return"";if(a.isDate(l))return l.toISOString();if(!d&&a.isBlob(l))throw new g("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(l)||a.isTypedArray(l)?d&&typeof Blob=="function"?new Blob([l]):Buffer.from(l):l}function u(l,m,T){let I=l;if(l&&!T&&typeof l=="object"){if(a.endsWith(m,"{}"))m=s?m:m.slice(0,-2),l=JSON.stringify(l);else if(a.isArray(l)&&xe(l)||(a.isFileList(l)||a.endsWith(m,"[]"))&&(I=a.toArray(l)))return m=At(m),I.forEach(function(G,fn){!(a.isUndefined(G)||G===null)&&n.append(o===!0?Nt([m],fn,i):o===null?m:m+"[]",f(G))}),!1}return v(l)?!0:(n.append(Nt(T,m,i),f(l)),!1)}const p=[],b=Object.assign(Ie,{defaultVisitor:u,convertValue:f,isVisitable:v});function _(l,m){if(!a.isUndefined(l)){if(p.indexOf(l)!==-1)throw Error("Circular reference detected in "+m.join("."));p.push(l),a.forEach(l,function(I,A){(!(a.isUndefined(I)||I===null)&&r.call(n,I,a.isString(A)?A.trim():A,m,b))===!0&&_(I,m?m.concat(A):[A])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return _(e),n}function xt(e){const n={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(s){return n[s]})}function tt(e,n){this._pairs=[],e&&M(e,this,n)}const It=tt.prototype;It.append=function(n,t){this._pairs.push([n,t])},It.toString=function(n){const t=n?function(s){return n.call(this,s,xt)}:xt;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function Ce(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Ct(e,n,t){if(!n)return e;const s=t&&t.encode||Ce,r=t&&t.serialize;let i;if(r?i=r(n,t):i=a.isURLSearchParams(n)?n.toString():new tt(n,t).toString(s),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Pe{constructor(){this.handlers=[]}use(n,t,s){return this.handlers.push({fulfilled:n,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(n){this.handlers[n]&&(this.handlers[n]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(n){a.forEach(this.handlers,function(s){s!==null&&n(s)})}}const Pt=Pe,Dt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},De=typeof URLSearchParams<"u"?URLSearchParams:tt,Be=typeof FormData<"u"?FormData:null,Fe=typeof Blob<"u"?Blob:null,Le=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Ue=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),O={isBrowser:!0,classes:{URLSearchParams:De,FormData:Be,Blob:Fe},isStandardBrowserEnv:Le,isStandardBrowserWebWorkerEnv:Ue,protocols:["http","https","file","blob","url","data"]};function ke(e,n){return M(e,new O.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,i){return O.isNode&&a.isBuffer(t)?(this.append(s,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},n))}function je(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(n=>n[0]==="[]"?"":n[1]||n[0])}function ze(e){const n={},t=Object.keys(e);let s;const r=t.length;let i;for(s=0;s<r;s++)i=t[s],n[i]=e[i];return n}function Bt(e){function n(t,s,r,i){let o=t[i++];const c=Number.isFinite(+o),d=i>=t.length;return o=!o&&a.isArray(r)?r.length:o,d?(a.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!c):((!r[o]||!a.isObject(r[o]))&&(r[o]=[]),n(t,s,r[o],i)&&a.isArray(r[o])&&(r[o]=ze(r[o])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const t={};return a.forEachEntry(e,(s,r)=>{n(je(s),r,t,0)}),t}return null}function He(e,n,t){if(a.isString(e))try{return(n||JSON.parse)(e),a.trim(e)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(e)}const et={transitional:Dt,adapter:["xhr","http"],transformRequest:[function(n,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,i=a.isObject(n);if(i&&a.isHTMLForm(n)&&(n=new FormData(n)),a.isFormData(n))return r&&r?JSON.stringify(Bt(n)):n;if(a.isArrayBuffer(n)||a.isBuffer(n)||a.isStream(n)||a.isFile(n)||a.isBlob(n))return n;if(a.isArrayBufferView(n))return n.buffer;if(a.isURLSearchParams(n))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),n.toString();let c;if(i){if(s.indexOf("application/x-www-form-urlencoded")>-1)return ke(n,this.formSerializer).toString();if((c=a.isFileList(n))||s.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return M(c?{"files[]":n}:n,d&&new d,this.formSerializer)}}return i||r?(t.setContentType("application/json",!1),He(n)):n}],transformResponse:[function(n){const t=this.transitional||et.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(n&&a.isString(n)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(n)}catch(c){if(o)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,this.response):c}}return n}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:O.classes.FormData,Blob:O.classes.Blob},validateStatus:function(n){return n>=200&&n<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{et.headers[e]={}});const nt=et,Me=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Je=e=>{const n={};let t,s,r;return e&&e.split(`
2
+ `).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||n[t]&&Me[t])&&(t==="set-cookie"?n[t]?n[t].push(s):n[t]=[s]:n[t]=n[t]?n[t]+", "+s:s)}),n},Ft=Symbol("internals");function L(e){return e&&String(e).trim().toLowerCase()}function J(e){return e===!1||e==null?e:a.isArray(e)?e.map(J):String(e)}function qe(e){const n=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(e);)n[s[1]]=s[2];return n}const $e=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function st(e,n,t,s,r){if(a.isFunction(s))return s.call(this,n,t);if(r&&(n=t),!!a.isString(n)){if(a.isString(s))return n.indexOf(s)!==-1;if(a.isRegExp(s))return s.test(n)}}function Ve(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(n,t,s)=>t.toUpperCase()+s)}function We(e,n){const t=a.toCamelCase(" "+n);["get","set","has"].forEach(s=>{Object.defineProperty(e,s+t,{value:function(r,i,o){return this[s].call(this,n,r,i,o)},configurable:!0})})}class q{constructor(n){n&&this.set(n)}set(n,t,s){const r=this;function i(c,d,f){const u=L(d);if(!u)throw new Error("header name must be a non-empty string");const p=a.findKey(r,u);(!p||r[p]===void 0||f===!0||f===void 0&&r[p]!==!1)&&(r[p||d]=J(c))}const o=(c,d)=>a.forEach(c,(f,u)=>i(f,u,d));return a.isPlainObject(n)||n instanceof this.constructor?o(n,t):a.isString(n)&&(n=n.trim())&&!$e(n)?o(Je(n),t):n!=null&&i(t,n,s),this}get(n,t){if(n=L(n),n){const s=a.findKey(this,n);if(s){const r=this[s];if(!t)return r;if(t===!0)return qe(r);if(a.isFunction(t))return t.call(this,r,s);if(a.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(n,t){if(n=L(n),n){const s=a.findKey(this,n);return!!(s&&this[s]!==void 0&&(!t||st(this,this[s],s,t)))}return!1}delete(n,t){const s=this;let r=!1;function i(o){if(o=L(o),o){const c=a.findKey(s,o);c&&(!t||st(s,s[c],c,t))&&(delete s[c],r=!0)}}return a.isArray(n)?n.forEach(i):i(n),r}clear(n){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const i=t[s];(!n||st(this,this[i],i,n,!0))&&(delete this[i],r=!0)}return r}normalize(n){const t=this,s={};return a.forEach(this,(r,i)=>{const o=a.findKey(s,i);if(o){t[o]=J(r),delete t[i];return}const c=n?Ve(i):String(i).trim();c!==i&&delete t[i],t[c]=J(r),s[c]=!0}),this}concat(...n){return this.constructor.concat(this,...n)}toJSON(n){const t=Object.create(null);return a.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=n&&a.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([n,t])=>n+": "+t).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(n){return n instanceof this?n:new this(n)}static concat(n,...t){const s=new this(n);return t.forEach(r=>s.set(r)),s}static accessor(n){const s=(this[Ft]=this[Ft]={accessors:{}}).accessors,r=this.prototype;function i(o){const c=L(o);s[c]||(We(r,o),s[c]=!0)}return a.isArray(n)?n.forEach(i):i(n),this}}q.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(q.prototype,({value:e},n)=>{let t=n[0].toUpperCase()+n.slice(1);return{get:()=>e,set(s){this[t]=s}}}),a.freezeMethods(q);const x=q;function rt(e,n){const t=this||nt,s=n||t,r=x.from(s.headers);let i=s.data;return a.forEach(e,function(c){i=c.call(t,i,r.normalize(),n?n.status:void 0)}),r.normalize(),i}function Lt(e){return!!(e&&e.__CANCEL__)}function U(e,n,t){g.call(this,e??"canceled",g.ERR_CANCELED,n,t),this.name="CanceledError"}a.inherits(U,g,{__CANCEL__:!0});function Ke(e,n,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?e(t):n(new g("Request failed with status code "+t.status,[g.ERR_BAD_REQUEST,g.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const Xe=O.isStandardBrowserEnv?function(){return{write:function(t,s,r,i,o,c){const d=[];d.push(t+"="+encodeURIComponent(s)),a.isNumber(r)&&d.push("expires="+new Date(r).toGMTString()),a.isString(i)&&d.push("path="+i),a.isString(o)&&d.push("domain="+o),c===!0&&d.push("secure"),document.cookie=d.join("; ")},read:function(t){const s=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return s?decodeURIComponent(s[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Ge(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Qe(e,n){return n?e.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):e}function Ut(e,n){return e&&!Ge(n)?Qe(e,n):n}const Ye=O.isStandardBrowserEnv?function(){const n=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let s;function r(i){let o=i;return n&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return s=r(window.location.href),function(o){const c=a.isString(o)?r(o):o;return c.protocol===s.protocol&&c.host===s.host}}():function(){return function(){return!0}}();function Ze(e){const n=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return n&&n[1]||""}function ve(e,n){e=e||10;const t=new Array(e),s=new Array(e);let r=0,i=0,o;return n=n!==void 0?n:1e3,function(d){const f=Date.now(),u=s[i];o||(o=f),t[r]=d,s[r]=f;let p=i,b=0;for(;p!==r;)b+=t[p++],p=p%e;if(r=(r+1)%e,r===i&&(i=(i+1)%e),f-o<n)return;const _=u&&f-u;return _?Math.round(b*1e3/_):void 0}}function kt(e,n){let t=0;const s=ve(50,250);return r=>{const i=r.loaded,o=r.lengthComputable?r.total:void 0,c=i-t,d=s(c),f=i<=o;t=i;const u={loaded:i,total:o,progress:o?i/o:void 0,bytes:c,rate:d||void 0,estimated:d&&o&&f?(o-i)/d:void 0,event:r};u[n?"download":"upload"]=!0,e(u)}}const it={http:Ne,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(t,s){let r=e.data;const i=x.from(e.headers).normalize(),o=e.responseType;let c;function d(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}let f;a.isFormData(r)&&(O.isStandardBrowserEnv||O.isStandardBrowserWebWorkerEnv?i.setContentType(!1):i.getContentType(/^\s*multipart\/form-data/)?a.isString(f=i.getContentType())&&i.setContentType(f.replace(/^\s*(multipart\/form-data);+/,"$1")):i.setContentType("multipart/form-data"));let u=new XMLHttpRequest;if(e.auth){const l=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(l+":"+m))}const p=Ut(e.baseURL,e.url);u.open(e.method.toUpperCase(),Ct(p,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function b(){if(!u)return;const l=x.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),T={data:!o||o==="text"||o==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:l,config:e,request:u};Ke(function(A){t(A),d()},function(A){s(A),d()},T),u=null}if("onloadend"in u?u.onloadend=b:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(b)},u.onabort=function(){u&&(s(new g("Request aborted",g.ECONNABORTED,e,u)),u=null)},u.onerror=function(){s(new g("Network Error",g.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){let m=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const T=e.transitional||Dt;e.timeoutErrorMessage&&(m=e.timeoutErrorMessage),s(new g(m,T.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,e,u)),u=null},O.isStandardBrowserEnv){const l=(e.withCredentials||Ye(p))&&e.xsrfCookieName&&Xe.read(e.xsrfCookieName);l&&i.set(e.xsrfHeaderName,l)}r===void 0&&i.setContentType(null),"setRequestHeader"in u&&a.forEach(i.toJSON(),function(m,T){u.setRequestHeader(T,m)}),a.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),o&&o!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",kt(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",kt(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=l=>{u&&(s(!l||l.type?new U(null,e,u):l),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const _=Ze(p);if(_&&O.protocols.indexOf(_)===-1){s(new g("Unsupported protocol "+_+":",g.ERR_BAD_REQUEST,e));return}u.send(r||null)})}};a.forEach(it,(e,n)=>{if(e){try{Object.defineProperty(e,"name",{value:n})}catch{}Object.defineProperty(e,"adapterName",{value:n})}});const jt=e=>`- ${e}`,tn=e=>a.isFunction(e)||e===null||e===!1,zt={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:n}=e;let t,s;const r={};for(let i=0;i<n;i++){t=e[i];let o;if(s=t,!tn(t)&&(s=it[(o=String(t)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${o}'`);if(s)break;r[o||"#"+i]=s}if(!s){const i=Object.entries(r).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=n?i.length>1?`since :
4
+ `+i.map(jt).join(`
5
+ `):" "+jt(i[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s},adapters:it};function ot(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new U(null,e)}function Ht(e){return ot(e),e.headers=x.from(e.headers),e.data=rt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),zt.getAdapter(e.adapter||nt.adapter)(e).then(function(s){return ot(e),s.data=rt.call(e,e.transformResponse,s),s.headers=x.from(s.headers),s},function(s){return Lt(s)||(ot(e),s&&s.response&&(s.response.data=rt.call(e,e.transformResponse,s.response),s.response.headers=x.from(s.response.headers))),Promise.reject(s)})}const Mt=e=>e instanceof x?e.toJSON():e;function D(e,n){n=n||{};const t={};function s(f,u,p){return a.isPlainObject(f)&&a.isPlainObject(u)?a.merge.call({caseless:p},f,u):a.isPlainObject(u)?a.merge({},u):a.isArray(u)?u.slice():u}function r(f,u,p){if(a.isUndefined(u)){if(!a.isUndefined(f))return s(void 0,f,p)}else return s(f,u,p)}function i(f,u){if(!a.isUndefined(u))return s(void 0,u)}function o(f,u){if(a.isUndefined(u)){if(!a.isUndefined(f))return s(void 0,f)}else return s(void 0,u)}function c(f,u,p){if(p in n)return s(f,u);if(p in e)return s(void 0,f)}const d={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(f,u)=>r(Mt(f),Mt(u),!0)};return a.forEach(Object.keys(Object.assign({},e,n)),function(u){const p=d[u]||r,b=p(e[u],n[u],u);a.isUndefined(b)&&p!==c||(t[u]=b)}),t}const Jt="1.5.1",at={};["object","boolean","number","function","string","symbol"].forEach((e,n)=>{at[e]=function(s){return typeof s===e||"a"+(n<1?"n ":" ")+e}});const qt={};at.transitional=function(n,t,s){function r(i,o){return"[Axios v"+Jt+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return(i,o,c)=>{if(n===!1)throw new g(r(o," has been removed"+(t?" in "+t:"")),g.ERR_DEPRECATED);return t&&!qt[o]&&(qt[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),n?n(i,o,c):!0}};function en(e,n,t){if(typeof e!="object")throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const s=Object.keys(e);let r=s.length;for(;r-- >0;){const i=s[r],o=n[i];if(o){const c=e[i],d=c===void 0||o(c,i,e);if(d!==!0)throw new g("option "+i+" must be "+d,g.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new g("Unknown option "+i,g.ERR_BAD_OPTION)}}const ct={assertOptions:en,validators:at},C=ct.validators;class ${constructor(n){this.defaults=n,this.interceptors={request:new Pt,response:new Pt}}request(n,t){typeof n=="string"?(t=t||{},t.url=n):t=n||{},t=D(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:i}=t;s!==void 0&&ct.assertOptions(s,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),r!=null&&(a.isFunction(r)?t.paramsSerializer={serialize:r}:ct.assertOptions(r,{encode:C.function,serialize:C.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[t.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],l=>{delete i[l]}),t.headers=x.concat(o,i);const c=[];let d=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(d=d&&m.synchronous,c.unshift(m.fulfilled,m.rejected))});const f=[];this.interceptors.response.forEach(function(m){f.push(m.fulfilled,m.rejected)});let u,p=0,b;if(!d){const l=[Ht.bind(this),void 0];for(l.unshift.apply(l,c),l.push.apply(l,f),b=l.length,u=Promise.resolve(t);p<b;)u=u.then(l[p++],l[p++]);return u}b=c.length;let _=t;for(p=0;p<b;){const l=c[p++],m=c[p++];try{_=l(_)}catch(T){m.call(this,T);break}}try{u=Ht.call(this,_)}catch(l){return Promise.reject(l)}for(p=0,b=f.length;p<b;)u=u.then(f[p++],f[p++]);return u}getUri(n){n=D(this.defaults,n);const t=Ut(n.baseURL,n.url);return Ct(t,n.params,n.paramsSerializer)}}a.forEach(["delete","get","head","options"],function(n){$.prototype[n]=function(t,s){return this.request(D(s||{},{method:n,url:t,data:(s||{}).data}))}}),a.forEach(["post","put","patch"],function(n){function t(s){return function(i,o,c){return this.request(D(c||{},{method:n,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}$.prototype[n]=t(),$.prototype[n+"Form"]=t(!0)});const V=$;class ut{constructor(n){if(typeof n!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const s=this;this.promise.then(r=>{if(!s._listeners)return;let i=s._listeners.length;for(;i-- >0;)s._listeners[i](r);s._listeners=null}),this.promise.then=r=>{let i;const o=new Promise(c=>{s.subscribe(c),i=c}).then(r);return o.cancel=function(){s.unsubscribe(i)},o},n(function(i,o,c){s.reason||(s.reason=new U(i,o,c),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(n){if(this.reason){n(this.reason);return}this._listeners?this._listeners.push(n):this._listeners=[n]}unsubscribe(n){if(!this._listeners)return;const t=this._listeners.indexOf(n);t!==-1&&this._listeners.splice(t,1)}static source(){let n;return{token:new ut(function(r){n=r}),cancel:n}}}const nn=ut;function sn(e){return function(t){return e.apply(null,t)}}function rn(e){return a.isObject(e)&&e.isAxiosError===!0}const lt={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(lt).forEach(([e,n])=>{lt[n]=e});const on=lt;function $t(e){const n=new V(e),t=pt(V.prototype.request,n);return a.extend(t,V.prototype,n,{allOwnKeys:!0}),a.extend(t,n,null,{allOwnKeys:!0}),t.create=function(r){return $t(D(e,r))},t}const y=$t(nt);y.Axios=V,y.CanceledError=U,y.CancelToken=nn,y.isCancel=Lt,y.VERSION=Jt,y.toFormData=M,y.AxiosError=g,y.Cancel=y.CanceledError,y.all=function(n){return Promise.all(n)},y.spread=sn,y.isAxiosError=rn,y.mergeConfig=D,y.AxiosHeaders=x,y.formToJSON=e=>Bt(a.isHTMLForm(e)?new FormData(e):e),y.getAdapter=zt.getAdapter,y.HttpStatusCode=on,y.default=y;const an=y;class cn{constructor(n,t=null){h(this,"_url",null);h(this,"_token",null);h(this,"_httpRequester");if(!n)throw Error("Endpoint URL must be passed in to NotuClient constructor");this._url=n,this._httpRequester=t??an}get url(){return this._url}get token(){return this._token}set token(n){this._token=n}async login(n,t){try{const s=await this._httpRequester({method:"post",url:(this.url+"/login").replace("//","/"),data:{username:n,password:t}});return this._token=s.data,{success:!0,error:null,token:s.data}}catch(s){if(s.response.status==401)return{success:!1,error:"Invalid username & password.",token:null};throw s}}async getSpaces(){return(await this._httpRequester({method:"get",url:(this.url+"/spaces").replace("//","/"),headers:{Authorization:"Bearer "+this.token}})).data}async saveSpace(n){return(await this._httpRequester({method:"post",url:(this.url+"/spaces").replace("//","/"),data:n,headers:{Authorization:"Bearer "+this.token}})).data}async getNotes(n,t){return(await this._httpRequester({method:"get",url:(this.url+"/notes").replace("//","/"),data:{query:n,spaceId:t},headers:{Authorization:"Bearer "+this.token}})).data}async getNoteCount(n,t){return(await this._httpRequester({method:"get",url:(this.url+"/notes").replace("//","/"),data:{query:n,spaceId:t},headers:{Authorization:"Bearer "+this.token}})).data}async saveNotes(n){return(await this._httpRequester({method:"post",url:(this.url+"/notes").replace("//","/"),data:{notes:n},headers:{Authorization:"Bearer "+this.token}})).data}async customJob(n,t){return(await this._httpRequester({method:"post",url:(this.url+"customjob").replace("//","/"),data:{name:n,data:t},headers:{Authorization:"Bearer "+this.token}})).data}}class W extends E{constructor(){super(...arguments);h(this,"_noteId",0);h(this,"_note",null);h(this,"_attrId",0);h(this,"_attr",null);h(this,"_value",null);h(this,"_tagId",null);h(this,"_tag",null)}get noteId(){return this._noteId}set noteId(t){var s;t!==this._noteId&&(this._noteId=t,t!==((s=this.note)==null?void 0:s.id)&&(this._note=null),this.isClean&&this.dirty())}get note(){return this._note}set note(t){this._note=t,this.noteId=(t==null?void 0:t.id)??0}get attrId(){return this._attrId}set attrId(t){var s;t!==this._attrId&&(this._attrId=t,t!==((s=this.attr)==null?void 0:s.id)&&(this._attr=null),this.isClean&&this.dirty())}get attr(){return this._attr}set attr(t){const s=this._attr;this._attr=t,t?(!s||t.type!=s.type)&&(this.value=t.defaultValue):this.value=null,this.attrId=(t==null?void 0:t.id)??0}get value(){return this._value}set value(t){t!=this._value&&(this._value=t,this.isClean&&this.dirty())}get tagId(){return this._tagId}set tagId(t){var s;t!==this._tagId&&(this._tagId=t,t!==((s=this.tag)==null?void 0:s.id)&&(this._tag=null),this.isClean&&this.dirty())}get tag(){return this._tag}set tag(t){this._tag=t,this.tagId=(t==null?void 0:t.id)??null}duplicate(){const t=new W;return t.noteId=this.noteId,t.note=this.note,t.attrId=this.attrId,t.attr=this.attr,t.tagId=this.tagId,t.tag=this.tag,t.value=this.value,t}validate(t=!1){let s=null;if(this.noteId<=0&&!this.isNew?s="NoteAttr noteId must be greater than zero":this.attrId<=0&&(s="NoteAttr attrId must be greater than zero"),t&&s!=null)throw Error(s);return s==null}}class K extends E{constructor(){super(...arguments);h(this,"_noteId",0);h(this,"_note",null);h(this,"_tagId",0);h(this,"_tag",null)}get noteId(){return this._noteId}set noteId(t){var s;t!==this._noteId&&(this._noteId=t,t!==((s=this.note)==null?void 0:s.id)&&(this._note=null),this.isClean&&this.dirty())}get note(){return this._note}set note(t){this._note=t,this.noteId=(t==null?void 0:t.id)??0}get tagId(){return this._tagId}set tagId(t){var s;t!==this._tagId&&(this._tagId=t,t!==((s=this.tag)==null?void 0:s.id)&&(this._tag=null),this.isClean&&this.dirty())}get tag(){return this._tag}set tag(t){this._tag=t,this.tagId=(t==null?void 0:t.id)??0}get attrs(){return this.note.attrs.filter(t=>t.tagId==this.tagId)}addAttr(t){if(!this.note)throw new Error("Cannot call addAttr on NoteTag where note property has not been set");const s=this.note.addAttr(t);return s.tag=this.tag,s}duplicate(){const t=new K;return t.noteId=this.noteId,t.tagId=this.tagId,t}validate(t=!1){let s=null;if(this.noteId<=0&&!this.isNew?s="NoteTag noteId must be greater than zero":this.tagId<=0?s="NoteTag tagId must be greater than zero":this.noteId==this.tagId&&(s="NoteTag cannot link a note to its own tag"),t&&s!=null)throw Error(s);return s==null}}class X extends E{constructor(t=""){super();h(this,"_id",0);h(this,"_name","");h(this,"_color",null);this._name=t}get id(){return this._id}set id(t){t!==this._id&&(this._id=t,this.isClean&&this.dirty())}get name(){return this._name}set name(t){t!==this._name&&(this._name=t,this.isClean&&this.dirty())}get color(){return this._color}set color(t){t!==this._color&&(this._color=t,this.isClean&&this.dirty())}duplicate(){const t=new X;return t.id=this.id,t.name=this.name,t.state=this.state,t}validate(t=!1){let s=null;if(!this.isNew&&this.id<=0?s="Tag id must be greater than zero if in non-new state.":!this.name||!/^[a-zA-Z][a-zA-Z0-9 ]*[a-zA-Z0-9]?$/.test(this.name)?s="Tag name is invalid, must only contain letters, numbers, and spaces, starting with a letter":this.color&&!/^#?[A-z0-9]{6}$/.test(this.color)&&(s="Tag color is invalid, must be a 6 character hexadecimal."),t&&s!=null)throw Error(s);return s==null}}class dt extends E{constructor(){super(...arguments);h(this,"id",0);h(this,"_date",new Date);h(this,"_text","");h(this,"_archived",!1);h(this,"_spaceId",0);h(this,"_space",null);h(this,"_ownTag",null);h(this,"_tags",[]);h(this,"_attrs",[])}get date(){return this._date}set date(t){t!==this._date&&(this._date=t,this.isClean&&this.dirty())}get text(){return this._text}set text(t){t!==this._text&&(this._text=t,this.isClean&&this.dirty())}get archived(){return this._archived}set archived(t){t!==this._archived&&(this._archived=t,this.isClean&&this.dirty())}get spaceId(){return this._spaceId}set spaceId(t){var s;t!==this._spaceId&&(this._spaceId=t,t!==((s=this.space)==null?void 0:s.id)&&(this._space=null),this.isClean&&this.dirty())}get space(){return this._space}set space(t){this._space=t,this.spaceId=(t==null?void 0:t.id)??0}get ownTag(){return this._ownTag}setOwnTag(t){if(typeof t=="string")this.ownTag==null&&(this._ownTag=new X),this.ownTag.name=t,this.ownTag.id=this.id;else{if(this.ownTag)throw new Error("Note has already had its tag set. If you would like to change the tag name, call setTag with just a string specifying the new tag name.");if(t.id!=0&&t.id!=this.id)throw new Error("Attempted to set tag to note with non-matching ID. Added tag id must either match the note id, which indicates that the tag has already been added to the note. Otherwise the tag id must be zero, indicating that the tag still needs to be added.");this._ownTag=t}return this}removeOwnTag(){this.ownTag&&(this.ownTag.isNew?this._ownTag=null:this.ownTag.delete())}get tags(){return this._tags}addTag(t){if(t.isDeleted)throw Error("Cannot add a tag marked as deleted to a note");if(t.isNew)throw Error("Cannot add a tag that hasn't yet been saved to a note");if(t.id==this.id)throw Error("Note cannot add its own tag as a linked tag");let s=this.tags.find(r=>r.tagId==t.id);return s?(s.isDeleted&&s.dirty(),s):(s=new K,s.note=this,s.tag=t,this._tags.push(s),s)}removeTag(t){const s=this.tags.find(r=>r.tagId==t.id);return s?(s.isNew?this._tags=this._tags.filter(r=>r!==s):s.delete(),this):this}get attrs(){return this._attrs}addAttr(t){if(t.isDeleted)throw Error("Cannot add an attribute marked as deleted to a note");if(t.isNew)throw Error("Cannot add an attribute that hasn't yet been saved to a note");let s=this.attrs.find(r=>r.attrId==t.id);return s?(s.isDeleted&&s.dirty(),s):(s=new W,s.note=this,s.attr=t,this._attrs.push(s),s)}removeAttr(t){const s=this.attrs.find(r=>r.attrId==t.id);return s?(s.isNew?this._attrs=this._attrs.filter(r=>r!==s):s.delete(),this):this}duplicate(){const t=new dt;return t.id=this.id,t.date=this.date,t.text=this.text,t.archived=this.archived,t.space=this.space,t.state=this.state,t}validate(t=!1){let s=null;if(this.spaceId<=0?s="Note spaceId must be greater than zero.":!this.isNew&&this.id<=0&&(s="Note id must be greater than zero if in non-new state."),t&&s!=null)throw Error(s);if(this.ownTag&&!this.ownTag.validate(t))return!1;for(const r of this.tags)if(!r.validate(t))return!1;for(const r of this.attrs)if(!r.validate(t))return!1;return s==null}}class Vt{constructor(){h(this,"where",null);h(this,"order",null);h(this,"tags",[]);h(this,"attrs",[])}}class un{constructor(){h(this,"space",null);h(this,"name",null);h(this,"searchDepth",0);h(this,"strictSearchDepth",!0);h(this,"includeOwner",!1)}}class ln{constructor(){h(this,"space",null);h(this,"name",null);h(this,"exists",!1);h(this,"tagNameFilters",null)}}function dn(e){const n=hn(e);return n.where=ht(n.where,n),n.order=ht(n.order,n),n.where=Wt(n.where,n),n.order=Wt(n.order,n),n}function hn(e){e=" "+e+" ";const n=new Vt,t=e.toUpperCase().indexOf(" ORDER BY ");return t<0?n.where=e.trim():(n.where=e.substring(0,t).trim(),n.order=e.substring(t+10).trim()),n.where==""&&(n.where=null),n}function ht(e,n){const t=[/(#+\??~?|~)([\w\d]+\.)?([\w\d]+)/,/(#+\??~?|~)\[([\w\d\s]+\.)?([\w\d\s]+)\]/];for(const s of t)for(;;){const r=s.exec(e);if(!r)break;const i=r[1],o=new un;o.space=r[2]?r[2].substring(0,r[2].length-1):null,o.name=r[3],o.includeOwner=i.includes("~"),o.searchDepth=(i.match(/#/g)||[]).length,o.strictSearchDepth=!i.includes("?");const c=r[0],d=e.indexOf(c),f=d+c.length;e=e.substring(0,d)+`{tag${n.tags.length}}`+e.substring(f),n.tags.push(o)}return e}function Wt(e,n){const t=[/@([\w\d]+\.(?!Exists\(|On\())?([\w\d]+)/,/@\[([\w\d\s]+\.)?([\w\d\s]+)\]/];for(const s of t)for(;;){const r=s.exec(e);if(!r)break;const i=new ln;i.space=r[1]?r[1].substring(0,r[1].length-1):null,i.name=r[2];const o=e.indexOf(r[0]);let c=o+r[0].length;if(e.substring(c,c+9)==".Exists()"&&(i.exists=!0,c+=9),e.substring(c,c+4)==".On("){let d=c+4;if(c=e.indexOf(")",d),c<0)throw Error("Unclosed bracket detected");let f=e.substring(d,c).split("|");const u=new Vt;for(let p of f)p.startsWith("~")||(p="~"+p),ht(p,u);i.tagNameFilters=u.tags,c++}e=e.substring(0,o)+`{attr${n.attrs.length}}`+e.substring(c),n.attrs.push(i)}return e}class ft extends E{constructor(t=""){super();h(this,"id",0);h(this,"_name","");this._name=t}get name(){return this._name}set name(t){t!==this._name&&(this._name=t,this.isClean&&this.dirty())}duplicate(){const t=new ft;return t.id=this.id,t.name=this.name,t.state=this.state,t}validate(t=!1){let s=null;if(!this.isNew&&this.id<=0&&(s="Space id must be greater than zero if in non-new state."),t&&s!=null)throw Error(s);return s==null}}w.Attr=N,w.Environment=Kt,w.HttpClient=cn,w.Note=dt,w.NoteAttr=W,w.NoteTag=K,w.Space=ft,w.Tag=X,w.parseQuery=dn,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "notu",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
+ "main": "dist/notu.js",
6
+ "unpkg": "dist/notu.js",
7
+ "files": [
8
+ "/dist"
9
+ ],
5
10
  "repository": {
6
11
  "type": "git",
7
12
  "url": "https://github.com/jamescoyle1989/notu.git"
@@ -1,76 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import Environment from './Environment';
3
- import { NotuClient, NotuLoginResult } from './services/HttpClient';
4
- import Space from './models/Space';
5
- import { Note } from '.';
6
-
7
-
8
- class TestClient implements NotuClient {
9
- login(username: string, password: string): Promise<NotuLoginResult> {
10
- return Promise.resolve({ success: true, error: null, token: 'qwer.asdf.zxcv' });
11
- }
12
-
13
- getSpaces(): Promise<Array<Space>> {
14
- const output = [
15
- new Space('Space 1'),
16
- new Space('Space 2')
17
- ];
18
- output[0].id = 1;
19
- output[1].id = 2;
20
- for (const space of output)
21
- space.clean();
22
- return Promise.resolve(output);
23
- }
24
-
25
- saveSpace(space: Space): Promise<Space> {
26
- return Promise.resolve(space.duplicate());
27
- }
28
-
29
- getNotes(query: string, spaceId: number): Promise<Array<Note>> {
30
- const output = [
31
- new Note(),
32
- new Note(),
33
- new Note()
34
- ];
35
- for (let i = 0; i < output.length; i++) {
36
- output[i].text = 'Note ' + (i+1);
37
- output[i].id = i+1;
38
- output[i].spaceId = (i % 2) + 1;
39
- output[i].clean();
40
- }
41
- return Promise.resolve(output);
42
- }
43
-
44
- getNoteCount(query: string, spaceId: number): Promise<number> {
45
- return Promise.resolve(3);
46
- }
47
-
48
- saveNotes(notes: Array<Note>): Promise<Array<Note>> {
49
- return Promise.resolve(notes.map(n => n.duplicate()));
50
- }
51
-
52
- customJob(name: string, data: any): Promise<any> {
53
- return Promise.resolve({ test: 123 });
54
- }
55
- }
56
-
57
-
58
- test('constructor takes client parameter', () => {
59
- const client = new TestClient();
60
- const env = new Environment(client);
61
-
62
- expect(env.client).toBe(client);
63
- });
64
-
65
- test('constructor throws error if client not set', () => {
66
- expect(() => new Environment(null)).toThrowError();
67
- });
68
-
69
-
70
- test('loadSpaces stores the list of spaces on the environment', async () => {
71
- const env = new Environment(new TestClient());
72
-
73
- await env.loadSpaces();
74
-
75
- expect(env.spaces.length).toBe(2);
76
- });
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- import { Note } from '.';
4
- import Space from './models/Space';
5
- import { NotuClient } from './services/HttpClient';
6
-
7
-
8
- export default class Environment {
9
-
10
- private _client: NotuClient = null;
11
- get client(): NotuClient { return this._client; }
12
-
13
- private _spaces: Array<Space> = [];
14
- get spaces(): Array<Space> { return this._spaces; }
15
-
16
- constructor(client: NotuClient) {
17
- if (!client)
18
- throw Error('Client must be set on Environment constructor');
19
- this._client = client;
20
- }
21
-
22
- async loadSpaces(): Promise<Array<Space>> {
23
- this._spaces = await this.client.getSpaces();
24
- return this.spaces;
25
- }
26
-
27
- async saveSpace(space: Space): Promise<Space> {
28
- return await this.client.saveSpace(space);
29
- }
30
-
31
- async getNotes(query: string, spaceId: number): Promise<Array<Note>> {
32
- return await this.client.getNotes(query, spaceId);
33
- }
34
-
35
- async getNoteCount(query: string, spaceId: number): Promise<number> {
36
- return await this.client.getNoteCount(query, spaceId);
37
- }
38
-
39
- async saveNote(note: Note): Promise<Note> {
40
- return (await this.client.saveNotes([note]))[0];
41
- }
42
-
43
- async saveNotes(notes: Array<Note>): Promise<Array<Note>> {
44
- return await this.client.saveNotes(notes);
45
- }
46
-
47
- async customJob(name: string, data: any): Promise<any> {
48
- return await this.client.customJob(name, data);
49
- }
50
-
51
- }
package/src/index.ts DELETED
@@ -1,21 +0,0 @@
1
- import Attr from './models/Attr';
2
- import Environment from './Environment';
3
- import HttpClient from './services/HttpClient';
4
- import Note from './models/Note';
5
- import NoteAttr from './models/NoteAttr';
6
- import NoteTag from './models/NoteTag';
7
- import parseQuery from './services/QueryParser';
8
- import Space from './models/Space';
9
- import Tag from './models/Tag';
10
-
11
- export {
12
- Attr,
13
- Environment,
14
- HttpClient,
15
- Note,
16
- NoteAttr,
17
- NoteTag,
18
- parseQuery,
19
- Space,
20
- Tag
21
- };
@@ -1,214 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import Attr from './Attr';
3
- import Space from './Space';
4
-
5
-
6
- test('Gets initiated as new', () => {
7
- const attr = new Attr();
8
- expect(attr.isNew).toBe(true);
9
- });
10
-
11
-
12
- test('Set name marks attr as dirty if currently clean', () => {
13
- const attr = new Attr().clean();
14
- attr.name = 'asdf';
15
- expect(attr.isDirty).toBe(true);
16
- });
17
-
18
- test('Set name doesnt change attr state if new', () => {
19
- const attr = new Attr().new();
20
- attr.name = 'asdf';
21
- expect(attr.isNew).toBe(true);
22
- });
23
-
24
- test('Set name doesnt change attr state if value not different', () => {
25
- const attr = new Attr().clean();
26
- attr.name = '';
27
- expect(attr.isClean).toBe(true);
28
- });
29
-
30
-
31
- test('Set type is allowed if attr is new', () => {
32
- const attr = new Attr().new();
33
- attr.type = 'BOOLEAN';
34
- expect(attr.type).toBe('BOOLEAN');
35
- });
36
-
37
- test('Set type is not allowed if attr is not new', () => {
38
- const attr = new Attr().clean();
39
- expect(() => attr.type = 'BOOLEAN').toThrowError();
40
- });
41
-
42
- test('isText returns true if type is text', () => {
43
- const attr = new Attr();
44
- attr.type = 'TEXT';
45
- expect(attr.isText).toBe(true);
46
- attr.type = 'NUMBER';
47
- expect(attr.isText).toBe(false);
48
- });
49
-
50
- test('isNumber returns true if type is number', () => {
51
- const attr = new Attr();
52
- attr.type = 'TEXT';
53
- expect(attr.isNumber).toBe(false);
54
- attr.type = 'NUMBER';
55
- expect(attr.isNumber).toBe(true);
56
- });
57
-
58
- test('isBoolean returns true if type is boolean', () => {
59
- const attr = new Attr();
60
- attr.type = 'TEXT';
61
- expect(attr.isBoolean).toBe(false);
62
- attr.type = 'BOOLEAN';
63
- expect(attr.isBoolean).toBe(true);
64
- });
65
-
66
- test('isDate returns true if type is date', () => {
67
- const attr = new Attr();
68
- attr.type = 'TEXT';
69
- expect(attr.isDate).toBe(false);
70
- attr.type = 'DATE';
71
- expect(attr.isDate).toBe(true);
72
- });
73
-
74
- test('asText sets type', () => {
75
- const attr = new Attr().asText();
76
- expect(attr.type).toBe('TEXT');
77
- });
78
-
79
- test('asNumber sets type', () => {
80
- const attr = new Attr().asNumber();
81
- expect(attr.type).toBe('NUMBER');
82
- });
83
-
84
- test('asBoolean sets type', () => {
85
- const attr = new Attr().asBoolean();
86
- expect(attr.type).toBe('BOOLEAN');
87
- });
88
-
89
- test('asDate sets type', () => {
90
- const attr = new Attr().asDate();
91
- expect(attr.type).toBe('DATE');
92
- });
93
-
94
-
95
- test('Set spaceId marks attr as dirty if currently clean', () => {
96
- const attr = new Attr().clean();
97
- attr.spaceId = 123;
98
- expect(attr.isDirty).toBe(true);
99
- });
100
-
101
- test('Set spaceId doesnt change attr state if new', () => {
102
- const attr = new Attr().new();
103
- attr.spaceId = 123;
104
- expect(attr.isNew).toBe(true);
105
- });
106
-
107
- test('Set spaceId doesnt change attr state if value not different', () => {
108
- const attr = new Attr().clean();
109
- attr.spaceId = attr.spaceId;
110
- expect(attr.isClean).toBe(true);
111
- });
112
-
113
- test('Setting space with id different than current spaceId updates state', () => {
114
- const attr = new Attr();
115
- attr.spaceId = 57;
116
- attr.clean();
117
- const space = new Space('hello');
118
- space.id = 60;
119
-
120
- attr.space = space;
121
-
122
- expect(attr.spaceId).toBe(60);
123
- expect(attr.isDirty).toBe(true);
124
- });
125
-
126
- test('Setting space with id same as current spaceId preserves state', () => {
127
- const attr = new Attr();
128
- attr.spaceId = 80;
129
- attr.clean();
130
- const space = new Space('hello');
131
- space.id = 80;
132
-
133
- attr.space = space;
134
-
135
- expect(attr.spaceId).toBe(80);
136
- expect(attr.isClean).toBe(true);
137
- });
138
-
139
- test('Setting spaceId to new value removes space object', () => {
140
- const attr = new Attr();
141
- const space = new Space('hello');
142
- space.id = 80;
143
- attr.space = space;
144
-
145
- attr.spaceId = 81;
146
-
147
- expect(attr.space).toBeNull();
148
- });
149
-
150
- test('Setting spaceId to same as current space id preserves it', () => {
151
- const attr = new Attr();
152
- const space = new Space('hello');
153
- space.id = 80;
154
- attr.space = space;
155
-
156
- attr.spaceId = 80;
157
-
158
- expect(attr.space.name).toBe('hello');
159
- });
160
-
161
-
162
- test('Can duplicate itself', () => {
163
- const attr = new Attr();
164
- const space = new Space('hello');
165
- space.id = 123;
166
- attr.space = space;
167
- const copy = attr.duplicate();
168
- expect(copy.id).toBe(attr.id);
169
- expect(copy.name).toBe(attr.name);
170
- expect(copy.type).toBe(attr.type);
171
- expect(copy.space).toBe(attr.space);
172
- expect(copy.spaceId).toBe(attr.spaceId);
173
- });
174
-
175
-
176
- test('validate fails if spaceId is 0', () => {
177
- const model = new Attr();
178
- model.spaceId = 0;
179
- expect(model.validate()).toBe(false);
180
- });
181
-
182
- test('validate fails if not new and id <= 0', () => {
183
- const model = new Attr().clean();
184
- model.id = 0;
185
- model.spaceId = 123;
186
- expect(model.validate()).toBe(false);
187
- });
188
-
189
- test('validate throws error if arg set to true', () => {
190
- const model = new Attr();
191
- model.spaceId = 0;
192
- expect(() => model.validate(true)).toThrowError();
193
- });
194
-
195
-
196
- test('defaultValue returns correct value for text', () => {
197
- const model = new Attr().asText();
198
- expect(model.defaultValue).toBe('');
199
- });
200
-
201
- test('defaultValue returns correct value for number', () => {
202
- const model = new Attr().asNumber();
203
- expect(model.defaultValue).toBe(0);
204
- });
205
-
206
- test('defaultValue returns correct value for boolean', () => {
207
- const model = new Attr().asBoolean();
208
- expect(model.defaultValue).toBe(false);
209
- });
210
-
211
- test('defaultValue returns correct value for date', () => {
212
- const model = new Attr().asDate();
213
- expect(model.defaultValue.getSeconds()).toBe(new Date().getSeconds());
214
- });
@@ -1,125 +0,0 @@
1
- 'use strict';
2
-
3
- import ModelWithState from './ModelWithState';
4
- import Space from './Space';
5
-
6
-
7
- const ATTR_TYPE = {
8
- TEXT: 'TEXT',
9
- NUMBER: 'NUMBER',
10
- BOOLEAN: 'BOOLEAN',
11
- DATE: 'DATE'
12
- };
13
-
14
- export type AttrType = keyof typeof ATTR_TYPE;
15
-
16
-
17
- export default class Attr extends ModelWithState<Attr> {
18
- id: number = 0;
19
-
20
-
21
- private _name: string = '';
22
- get name(): string { return this._name; }
23
- set name(value: string) {
24
- if (value !== this._name) {
25
- this._name = value;
26
- if (this.isClean)
27
- this.dirty();
28
- }
29
- }
30
-
31
- private _type: AttrType = 'TEXT';
32
- get type(): AttrType { return this._type; }
33
- set type(value: AttrType) {
34
- if (!this.isNew)
35
- throw Error('Cannot change an attribute\'s type once it has been created.');
36
- this._type = value;
37
- }
38
-
39
- get isText(): boolean { return this.type == 'TEXT'; }
40
-
41
- get isNumber(): boolean { return this.type == 'NUMBER'; }
42
-
43
- get isBoolean(): boolean { return this.type == 'BOOLEAN'; }
44
-
45
- get isDate(): boolean { return this.type == 'DATE'; }
46
-
47
- asText(): Attr {
48
- this.type = 'TEXT';
49
- return this;
50
- }
51
-
52
- asNumber(): Attr {
53
- this.type = 'NUMBER';
54
- return this;
55
- }
56
-
57
- asBoolean(): Attr {
58
- this.type = 'BOOLEAN';
59
- return this;
60
- }
61
-
62
- asDate(): Attr {
63
- this.type = 'DATE';
64
- return this;
65
- }
66
-
67
-
68
- private _spaceId: number = 0;
69
- get spaceId(): number { return this._spaceId; }
70
- set spaceId(value: number) {
71
- if (value !== this._spaceId) {
72
- this._spaceId = value;
73
- if (value !== this.space?.id ?? 0)
74
- this._space = null;
75
- if (this.isClean)
76
- this.dirty();
77
- }
78
- }
79
-
80
- private _space: Space = null;
81
- get space(): Space { return this._space; }
82
- set space(value: Space) {
83
- this._space = value;
84
- this.spaceId = value?.id ?? 0;
85
- }
86
-
87
-
88
- duplicate(): Attr {
89
- const output = new Attr();
90
- output.id = this.id;
91
- output.name = this.name;
92
- output.type = this.type;
93
- output.space = this.space;
94
- return output;
95
- }
96
-
97
-
98
- validate(throwError: boolean = false): boolean {
99
- let output = null;
100
-
101
- if (this.spaceId <= 0)
102
- output = 'Note spaceId must be greater than zero.';
103
- else if (!this.isNew && this.id <= 0)
104
- output = 'Attr id must be greater than zero if in non-new state.';
105
-
106
- if (throwError && output != null)
107
- throw Error(output);
108
-
109
- return output == null;
110
- }
111
-
112
-
113
- get defaultValue(): any {
114
- switch (this.type) {
115
- case 'TEXT':
116
- return '';
117
- case 'NUMBER':
118
- return 0;
119
- case 'BOOLEAN':
120
- return false;
121
- case 'DATE':
122
- return new Date();
123
- }
124
- }
125
- }