ocean-brain 0.5.0 → 0.6.1
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/mcp.js +660 -31
- package/package.json +2 -1
- package/server/client/dist/assets/{Calendar-BU9XgX2N.js → Calendar-BJHLksEZ.js} +1 -1
- package/server/client/dist/assets/{Callout-C6tVCxOT.js → Callout-wFx9oCas.js} +1 -1
- package/server/client/dist/assets/Graph-9piERaNR.js +1 -0
- package/server/client/dist/assets/{Image-DxWhlIDG.js → Image-DK0lnaK2.js} +1 -1
- package/server/client/dist/assets/{Image.es-BjGK7y6Y.js → Image.es-Be7par_j.js} +1 -1
- package/server/client/dist/assets/Note-CC9ybxXL.js +21 -0
- package/server/client/dist/assets/{Plus.es-EcmtS_uw.js → Plus.es-BKm7uDYu.js} +1 -1
- package/server/client/dist/assets/Reminders-DRxA8v98.js +1 -0
- package/server/client/dist/assets/Search-BunSQrqv.js +1 -0
- package/server/client/dist/assets/{SurfaceCard-CO0oVxeL.js → SurfaceCard-FhlC8VSR.js} +1 -1
- package/server/client/dist/assets/Tag-z_crJ5JP.js +1 -0
- package/server/client/dist/assets/TagNotes-D7wIJ4jy.js +1 -0
- package/server/client/dist/assets/{Trash.es-DmwfSy3l.js → Trash.es-ByMVwx0d.js} +1 -1
- package/server/client/dist/assets/ViewNotes-Duo9XmcJ.js +1 -0
- package/server/client/dist/assets/Views-D4Z_O9Kd.js +1 -0
- package/server/client/dist/assets/{image.api-DeF9ck7g.js → image.api-B5Qi-Txv.js} +1 -1
- package/server/client/dist/assets/{index-BZUGWdOU.css → index-Cd81UxEh.css} +1 -1
- package/server/client/dist/assets/index-cHJQCo8V.js +1 -0
- package/server/client/dist/assets/index-nYj7BL3a.js +327 -0
- package/server/client/dist/assets/manage-image-detail-DcZggB1M.js +1 -0
- package/server/client/dist/assets/manage-image-glbtBibn.js +1 -0
- package/server/client/dist/assets/{mcp-Bh743HBz.js → mcp-BBUpQdS9.js} +1 -1
- package/server/client/dist/assets/{note-core-Z6kqulGB.js → note-core-DMZcZ4yV.js} +53 -53
- package/server/client/dist/assets/{note-vendor-i1M2FSI2.js → note-vendor-uuJO2MTD.js} +1 -1
- package/server/client/dist/assets/{placeholder-XQqo1Fvr.js → placeholder-B_qb_qkc.js} +5 -5
- package/server/client/dist/assets/properties-CiyQv6Tb.js +1 -0
- package/server/client/dist/assets/trash-CQnj4Rmv.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-D21PurIS.js → useReminderMutate-CSKliBcc.js} +1 -1
- package/server/client/dist/assets/view-dashboard-B5fKgvk_.js +99 -0
- package/server/client/dist/index.html +4 -4
- package/server/dist/features/note/graphql/note.field.resolver.js +2 -0
- package/server/dist/features/note/graphql/note.field.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js +119 -0
- package/server/dist/features/note/graphql/note.mutation.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.query.resolver.js +14 -0
- package/server/dist/features/note/graphql/note.query.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.type-defs.js +100 -0
- package/server/dist/features/note/graphql/note.type-defs.js.map +1 -1
- package/server/dist/features/note/http/mcp.js +394 -1
- package/server/dist/features/note/http/mcp.js.map +1 -1
- package/server/dist/features/note/services/markdown-intent-write.js +495 -0
- package/server/dist/features/note/services/markdown-intent-write.js.map +1 -0
- package/server/dist/features/note/services/markdown-patch.js +601 -0
- package/server/dist/features/note/services/markdown-patch.js.map +1 -0
- package/server/dist/features/note/services/properties.js +874 -0
- package/server/dist/features/note/services/properties.js.map +1 -0
- package/server/dist/features/note/services/snapshot.js +94 -12
- package/server/dist/features/note/services/snapshot.js.map +1 -1
- package/server/dist/features/note/services/trash.js +70 -2
- package/server/dist/features/note/services/trash.js.map +1 -1
- package/server/dist/features/note/services/write.js +21 -7
- package/server/dist/features/note/services/write.js.map +1 -1
- package/server/dist/features/view/graphql/view.query.resolver.js +31 -1
- package/server/dist/features/view/graphql/view.query.resolver.js.map +1 -1
- package/server/dist/features/view/graphql/view.type-defs.js +57 -1
- package/server/dist/features/view/graphql/view.type-defs.js.map +1 -1
- package/server/dist/features/view/services/workspace.js +367 -43
- package/server/dist/features/view/services/workspace.js.map +1 -1
- package/server/dist/modules/blocknote.js +367 -7
- package/server/dist/modules/blocknote.js.map +1 -1
- package/server/dist/routes/mcp.js +21 -1
- package/server/dist/routes/mcp.js.map +1 -1
- package/server/prisma/migrations/20260527073000_0017_note_properties/migration.sql +105 -0
- package/server/prisma/migrations/20260531073000_0018_view_query/migration.sql +3 -0
- package/server/prisma/schema.prisma +226 -130
- package/server/client/dist/assets/Graph-Dond2hGK.js +0 -1
- package/server/client/dist/assets/Note-Cr6GtXUM.js +0 -21
- package/server/client/dist/assets/Reminders-BlLLT_x0.js +0 -1
- package/server/client/dist/assets/Search-CrZ0ap8x.js +0 -1
- package/server/client/dist/assets/Tag-vws5AfNW.js +0 -1
- package/server/client/dist/assets/TagNotes-Fmf1Kgim.js +0 -1
- package/server/client/dist/assets/ViewNotes-BALN7IfH.js +0 -1
- package/server/client/dist/assets/Views-Ccc_Ml5U.js +0 -1
- package/server/client/dist/assets/index-BSVE2cGd.js +0 -1
- package/server/client/dist/assets/index-BvKBTjQq.js +0 -246
- package/server/client/dist/assets/manage-image-IoTXaMBP.js +0 -1
- package/server/client/dist/assets/manage-image-detail-BRTXwOsh.js +0 -1
- package/server/client/dist/assets/trash-hiJIg6-c.js +0 -1
- package/server/client/dist/assets/view-dashboard-BuaZ4MvI.js +0 -90
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Tc,g as Vy,a as x,R as Rc,N as Ve}from"./graph-vendor-CUxe67Lr.js";import{a as kC,f as VC,P as BC,b as $C,y as UC,g as GC,c as bm,D as Rd,d as ZC,M as PC,m as qC,e as YC,H as XC,N as IC,i as QC,h as FC,L as KC,A as JC,B as WC,_ as Eo,j as ht,k as kt,l as Ys,n as Wa,p as e4,o as Hl,q as Ke,r as Mc,S as ei,T as t4,s as Oc,t as Qn,I as xm,u as Pv,C as n4,v as o4,w as By,x as $y,z as Uy,E as l4,F as r4,R as ti,G as a4,J as i4,K as s4,O as c4,Q as Gy,U as u4,V as f4,W as qv,X as d4,Y as m4,Z as p4,$ as h4,a0 as g4,a1 as we,a2 as Sm}from"./note-core-Z6kqulGB.js";var Md={exports:{}},qa={};var Yv;function v4(){if(Yv)return qa;Yv=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,s,c){var u=null;if(c!==void 0&&(u=""+c),s.key!==void 0&&(u=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:t,type:a,key:u,ref:s!==void 0?s:null,props:c}}return qa.Fragment=o,qa.jsx=r,qa.jsxs=r,qa}var Xv;function y4(){return Xv||(Xv=1,Md.exports=v4()),Md.exports}var y=y4(),Od={exports:{}},Ya={},jd={exports:{}},_d={};var Iv;function b4(){return Iv||(Iv=1,(function(t){function o(z,L){var _=z.length;z.push(L);e:for(;0<_;){var Z=_-1>>>1,I=z[Z];if(0<s(I,L))z[Z]=L,z[_]=I,_=Z;else break e}}function r(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var L=z[0],_=z.pop();if(_!==L){z[0]=_;e:for(var Z=0,I=z.length,ae=I>>>1;Z<ae;){var ne=2*(Z+1)-1,re=z[ne],ve=ne+1,se=z[ve];if(0>s(re,_))ve<I&&0>s(se,re)?(z[Z]=se,z[ve]=_,Z=ve):(z[Z]=re,z[ne]=_,Z=ne);else if(ve<I&&0>s(se,_))z[Z]=se,z[ve]=_,Z=ve;else break e}}return L}function s(z,L){var _=z.sortIndex-L.sortIndex;return _!==0?_:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();t.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,v=null,b=3,C=!1,E=!1,w=!1,T=!1,M=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(z){for(var L=r(h);L!==null;){if(L.callback===null)a(h);else if(L.startTime<=z)a(h),L.sortIndex=L.expirationTime,o(m,L);else break;L=r(h)}}function D(z){if(w=!1,N(z),!E)if(r(m)!==null)E=!0,V||(V=!0,le());else{var L=r(h);L!==null&&W(D,L.startTime-z)}}var V=!1,$=-1,X=5,F=-1;function q(){return T?!0:!(t.unstable_now()-F<X)}function te(){if(T=!1,V){var z=t.unstable_now();F=z;var L=!0;try{e:{E=!1,w&&(w=!1,O($),$=-1),C=!0;var _=b;try{t:{for(N(z),v=r(m);v!==null&&!(v.expirationTime>z&&q());){var Z=v.callback;if(typeof Z=="function"){v.callback=null,b=v.priorityLevel;var I=Z(v.expirationTime<=z);if(z=t.unstable_now(),typeof I=="function"){v.callback=I,N(z),L=!0;break t}v===r(m)&&a(m),N(z)}else a(m);v=r(m)}if(v!==null)L=!0;else{var ae=r(h);ae!==null&&W(D,ae.startTime-z),L=!1}}break e}finally{v=null,b=_,C=!1}L=void 0}}finally{L?le():V=!1}}}var le;if(typeof j=="function")le=function(){j(te)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,H=ee.port2;ee.port1.onmessage=te,le=function(){H.postMessage(null)}}else le=function(){M(te,0)};function W(z,L){$=M(function(){z(t.unstable_now())},L)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(z){switch(b){case 1:case 2:case 3:var L=3;break;default:L=b}var _=b;b=L;try{return z()}finally{b=_}},t.unstable_requestPaint=function(){T=!0},t.unstable_runWithPriority=function(z,L){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var _=b;b=z;try{return L()}finally{b=_}},t.unstable_scheduleCallback=function(z,L,_){var Z=t.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?Z+_:Z):_=Z,z){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=_+I,z={id:g++,callback:L,priorityLevel:z,startTime:_,expirationTime:I,sortIndex:-1},_>Z?(z.sortIndex=_,o(h,z),r(m)===null&&z===r(h)&&(w?(O($),$=-1):w=!0,W(D,_-Z))):(z.sortIndex=I,o(m,z),E||C||(E=!0,V||(V=!0,le()))),z},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(z){var L=b;return function(){var _=b;b=L;try{return z.apply(this,arguments)}finally{b=_}}}})(_d)),_d}var Qv;function x4(){return Qv||(Qv=1,jd.exports=b4()),jd.exports}var Nd={exports:{}},Et={};var Fv;function S4(){if(Fv)return Et;Fv=1;var t=Tc();function o(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},s=Symbol.for("react.portal");function c(m,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:v==null?null:""+v,children:m,containerInfo:h,implementation:g}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Et.createPortal=function(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(o(299));return c(m,h,null,g)},Et.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Et.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Et.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Et.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,C=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:C}):g==="script"&&a.d.X(m,{crossOrigin:v,integrity:b,fetchPriority:C,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Et.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Et.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Et.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Et.requestFormReset=function(m){a.d.r(m)},Et.unstable_batchedUpdates=function(m,h){return m(h)},Et.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Et.useFormStatus=function(){return u.H.useHostTransitionStatus()},Et.version="19.2.4",Et}var Kv;function Zy(){if(Kv)return Nd.exports;Kv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(o){console.error(o)}}return t(),Nd.exports=S4(),Nd.exports}var Jv;function C4(){if(Jv)return Ya;Jv=1;var t=x4(),o=Tc(),r=Zy();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function u(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function f(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(c(e)!==e)throw Error(a(188))}function h(e){var n=e.alternate;if(!n){if(n=c(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,i=n;;){var d=l.return;if(d===null)break;var p=d.alternate;if(p===null){if(i=d.return,i!==null){l=i;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===l)return m(d),e;if(p===i)return m(d),n;p=p.sibling}throw Error(a(188))}if(l.return!==i.return)l=d,i=p;else{for(var S=!1,R=d.child;R;){if(R===l){S=!0,l=d,i=p;break}if(R===i){S=!0,i=d,l=p;break}R=R.sibling}if(!S){for(R=p.child;R;){if(R===l){S=!0,l=p,i=d;break}if(R===i){S=!0,i=p,l=d;break}R=R.sibling}if(!S)throw Error(a(189))}}if(l.alternate!==i)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function g(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=g(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),j=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function le(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var ee=Symbol.for("react.client.reference");function H(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case M:return"Profiler";case T:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case j:return e.displayName||"Context";case O:return(e._context.displayName||"Context")+".Consumer";case N:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $:return n=e.displayName||null,n!==null?n:H(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return H(e(n))}catch{}}return null}var W=Array.isArray,z=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_={pending:!1,data:null,method:null,action:null},Z=[],I=-1;function ae(e){return{current:e}}function ne(e){0>I||(e.current=Z[I],Z[I]=null,I--)}function re(e,n){I++,Z[I]=e.current,e.current=n}var ve=ae(null),se=ae(null),be=ae(null),Le=ae(null);function Ee(e,n){switch(re(be,n),re(se,e),re(ve,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?mv(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=mv(n),e=pv(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ne(ve),re(ve,e)}function ye(){ne(ve),ne(se),ne(be)}function Je(e){e.memoizedState!==null&&re(Le,e);var n=ve.current,l=pv(n,e.type);n!==l&&(re(se,e),re(ve,l))}function nt(e){se.current===e&&(ne(ve),ne(se)),Le.current===e&&(ne(Le),Ua._currentValue=_)}var We,Ae;function tt(e){if(We===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);We=n&&n[1]||"",Ae=-1<l.stack.indexOf(`
|
|
1
|
+
import{r as Tc,g as Vy,a as x,R as Rc,N as Ve}from"./graph-vendor-CUxe67Lr.js";import{a as kC,f as VC,P as BC,b as $C,y as UC,g as GC,c as bm,D as Rd,d as ZC,M as PC,m as qC,e as YC,H as XC,N as IC,i as QC,h as FC,L as KC,A as JC,B as WC,_ as Eo,j as ht,k as kt,l as Ys,n as Wa,p as e4,o as Hl,q as Ke,r as Mc,S as ei,T as t4,s as Oc,t as Qn,I as xm,u as Pv,C as n4,v as o4,w as By,x as $y,z as Uy,E as l4,F as r4,R as ti,G as a4,J as i4,K as s4,O as c4,Q as Gy,U as u4,V as f4,W as qv,X as d4,Y as m4,Z as p4,$ as h4,a0 as g4,a1 as we,a2 as Sm}from"./note-core-DMZcZ4yV.js";var Md={exports:{}},qa={};var Yv;function v4(){if(Yv)return qa;Yv=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(a,s,c){var u=null;if(c!==void 0&&(u=""+c),s.key!==void 0&&(u=""+s.key),"key"in s){c={};for(var f in s)f!=="key"&&(c[f]=s[f])}else c=s;return s=c.ref,{$$typeof:t,type:a,key:u,ref:s!==void 0?s:null,props:c}}return qa.Fragment=o,qa.jsx=r,qa.jsxs=r,qa}var Xv;function y4(){return Xv||(Xv=1,Md.exports=v4()),Md.exports}var y=y4(),Od={exports:{}},Ya={},jd={exports:{}},_d={};var Iv;function b4(){return Iv||(Iv=1,(function(t){function o(z,L){var _=z.length;z.push(L);e:for(;0<_;){var Z=_-1>>>1,I=z[Z];if(0<s(I,L))z[Z]=L,z[_]=I,_=Z;else break e}}function r(z){return z.length===0?null:z[0]}function a(z){if(z.length===0)return null;var L=z[0],_=z.pop();if(_!==L){z[0]=_;e:for(var Z=0,I=z.length,ae=I>>>1;Z<ae;){var ne=2*(Z+1)-1,re=z[ne],ve=ne+1,se=z[ve];if(0>s(re,_))ve<I&&0>s(se,re)?(z[Z]=se,z[ve]=_,Z=ve):(z[Z]=re,z[ne]=_,Z=ne);else if(ve<I&&0>s(se,_))z[Z]=se,z[ve]=_,Z=ve;else break e}}return L}function s(z,L){var _=z.sortIndex-L.sortIndex;return _!==0?_:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;t.unstable_now=function(){return c.now()}}else{var u=Date,f=u.now();t.unstable_now=function(){return u.now()-f}}var m=[],h=[],g=1,v=null,b=3,C=!1,E=!1,w=!1,T=!1,M=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function N(z){for(var L=r(h);L!==null;){if(L.callback===null)a(h);else if(L.startTime<=z)a(h),L.sortIndex=L.expirationTime,o(m,L);else break;L=r(h)}}function D(z){if(w=!1,N(z),!E)if(r(m)!==null)E=!0,V||(V=!0,le());else{var L=r(h);L!==null&&W(D,L.startTime-z)}}var V=!1,$=-1,X=5,F=-1;function q(){return T?!0:!(t.unstable_now()-F<X)}function te(){if(T=!1,V){var z=t.unstable_now();F=z;var L=!0;try{e:{E=!1,w&&(w=!1,O($),$=-1),C=!0;var _=b;try{t:{for(N(z),v=r(m);v!==null&&!(v.expirationTime>z&&q());){var Z=v.callback;if(typeof Z=="function"){v.callback=null,b=v.priorityLevel;var I=Z(v.expirationTime<=z);if(z=t.unstable_now(),typeof I=="function"){v.callback=I,N(z),L=!0;break t}v===r(m)&&a(m),N(z)}else a(m);v=r(m)}if(v!==null)L=!0;else{var ae=r(h);ae!==null&&W(D,ae.startTime-z),L=!1}}break e}finally{v=null,b=_,C=!1}L=void 0}}finally{L?le():V=!1}}}var le;if(typeof j=="function")le=function(){j(te)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,H=ee.port2;ee.port1.onmessage=te,le=function(){H.postMessage(null)}}else le=function(){M(te,0)};function W(z,L){$=M(function(){z(t.unstable_now())},L)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):X=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(z){switch(b){case 1:case 2:case 3:var L=3;break;default:L=b}var _=b;b=L;try{return z()}finally{b=_}},t.unstable_requestPaint=function(){T=!0},t.unstable_runWithPriority=function(z,L){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var _=b;b=z;try{return L()}finally{b=_}},t.unstable_scheduleCallback=function(z,L,_){var Z=t.unstable_now();switch(typeof _=="object"&&_!==null?(_=_.delay,_=typeof _=="number"&&0<_?Z+_:Z):_=Z,z){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=_+I,z={id:g++,callback:L,priorityLevel:z,startTime:_,expirationTime:I,sortIndex:-1},_>Z?(z.sortIndex=_,o(h,z),r(m)===null&&z===r(h)&&(w?(O($),$=-1):w=!0,W(D,_-Z))):(z.sortIndex=I,o(m,z),E||C||(E=!0,V||(V=!0,le()))),z},t.unstable_shouldYield=q,t.unstable_wrapCallback=function(z){var L=b;return function(){var _=b;b=L;try{return z.apply(this,arguments)}finally{b=_}}}})(_d)),_d}var Qv;function x4(){return Qv||(Qv=1,jd.exports=b4()),jd.exports}var Nd={exports:{}},Et={};var Fv;function S4(){if(Fv)return Et;Fv=1;var t=Tc();function o(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)h+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function r(){}var a={d:{f:r,r:function(){throw Error(o(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},s=Symbol.for("react.portal");function c(m,h,g){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:v==null?null:""+v,children:m,containerInfo:h,implementation:g}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function f(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,Et.createPortal=function(m,h){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(o(299));return c(m,h,null,g)},Et.flushSync=function(m){var h=u.T,g=a.p;try{if(u.T=null,a.p=2,m)return m()}finally{u.T=h,a.p=g,a.d.f()}},Et.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,a.d.C(m,h))},Et.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},Et.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin),b=typeof h.integrity=="string"?h.integrity:void 0,C=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;g==="style"?a.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:C}):g==="script"&&a.d.X(m,{crossOrigin:v,integrity:b,fetchPriority:C,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},Et.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var g=f(h.as,h.crossOrigin);a.d.M(m,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&a.d.M(m)},Et.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var g=h.as,v=f(g,h.crossOrigin);a.d.L(m,g,{crossOrigin:v,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},Et.preloadModule=function(m,h){if(typeof m=="string")if(h){var g=f(h.as,h.crossOrigin);a.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else a.d.m(m)},Et.requestFormReset=function(m){a.d.r(m)},Et.unstable_batchedUpdates=function(m,h){return m(h)},Et.useFormState=function(m,h,g){return u.H.useFormState(m,h,g)},Et.useFormStatus=function(){return u.H.useHostTransitionStatus()},Et.version="19.2.4",Et}var Kv;function Zy(){if(Kv)return Nd.exports;Kv=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(o){console.error(o)}}return t(),Nd.exports=S4(),Nd.exports}var Jv;function C4(){if(Jv)return Ya;Jv=1;var t=x4(),o=Tc(),r=Zy();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function u(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function f(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function m(e){if(c(e)!==e)throw Error(a(188))}function h(e){var n=e.alternate;if(!n){if(n=c(e),n===null)throw Error(a(188));return n!==e?null:e}for(var l=e,i=n;;){var d=l.return;if(d===null)break;var p=d.alternate;if(p===null){if(i=d.return,i!==null){l=i;continue}break}if(d.child===p.child){for(p=d.child;p;){if(p===l)return m(d),e;if(p===i)return m(d),n;p=p.sibling}throw Error(a(188))}if(l.return!==i.return)l=d,i=p;else{for(var S=!1,R=d.child;R;){if(R===l){S=!0,l=d,i=p;break}if(R===i){S=!0,i=d,l=p;break}R=R.sibling}if(!S){for(R=p.child;R;){if(R===l){S=!0,l=p,i=d;break}if(R===i){S=!0,i=p,l=d;break}R=R.sibling}if(!S)throw Error(a(189))}}if(l.alternate!==i)throw Error(a(190))}if(l.tag!==3)throw Error(a(188));return l.stateNode.current===l?e:n}function g(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=g(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),j=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),q=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function le(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var ee=Symbol.for("react.client.reference");function H(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case M:return"Profiler";case T:return"StrictMode";case D:return"Suspense";case V:return"SuspenseList";case F:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case j:return e.displayName||"Context";case O:return(e._context.displayName||"Context")+".Consumer";case N:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $:return n=e.displayName||null,n!==null?n:H(e.type)||"Memo";case X:n=e._payload,e=e._init;try{return H(e(n))}catch{}}return null}var W=Array.isArray,z=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_={pending:!1,data:null,method:null,action:null},Z=[],I=-1;function ae(e){return{current:e}}function ne(e){0>I||(e.current=Z[I],Z[I]=null,I--)}function re(e,n){I++,Z[I]=e.current,e.current=n}var ve=ae(null),se=ae(null),be=ae(null),Le=ae(null);function Ee(e,n){switch(re(be,n),re(se,e),re(ve,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?mv(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=mv(n),e=pv(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}ne(ve),re(ve,e)}function ye(){ne(ve),ne(se),ne(be)}function Je(e){e.memoizedState!==null&&re(Le,e);var n=ve.current,l=pv(n,e.type);n!==l&&(re(se,e),re(ve,l))}function nt(e){se.current===e&&(ne(ve),ne(se)),Le.current===e&&(ne(Le),Ua._currentValue=_)}var We,Ae;function tt(e){if(We===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);We=n&&n[1]||"",Ae=-1<l.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
3
|
`+We+e+Ae}var nn=!1;function An(e,n){if(!e||nn)return"";nn=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(Y){var P=Y}Reflect.construct(e,[],J)}else{try{J.call()}catch(Y){P=Y}e.call(J.prototype)}}else{try{throw Error()}catch(Y){P=Y}(J=e())&&typeof J.catch=="function"&&J.catch(function(){})}}catch(Y){if(Y&&P&&typeof Y.stack=="string")return[Y.stack,P.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=i.DetermineComponentFrameRoot(),S=p[0],R=p[1];if(S&&R){var A=S.split(`
|
|
4
4
|
`),G=R.split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{p as J,h as P,w as V,q as v,b4 as W,u as ee,ah as M,P as ae,T as s,al as te,b5 as j,b6 as N,B as C,a8 as se,M as m,l as b,I as w,r as le,ac as ne,a1 as re,i as $,j as ce,aP as ie,X as oe}from"./index-nYj7BL3a.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-FhlC8VSR.js";import{n as de}from"./Plus.es-BKm7uDYu.js";import"./note-core-DMZcZ4yV.js";const me=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216.49,168.49a12,12,0,0,1-17,0L128,97,56.49,168.49a12,12,0,0,1-17-17l80-80a12,12,0,0,1,17,0l80,80A12,12,0,0,1,216.49,168.49Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M208,160H48l80-80Z",opacity:"0.2"}),a.createElement("path",{d:"M213.66,154.34l-80-80a8,8,0,0,0-11.32,0l-80,80A8,8,0,0,0,48,168H208a8,8,0,0,0,5.66-13.66ZM67.31,152,128,91.31,188.69,152Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M215.39,163.06A8,8,0,0,1,208,168H48a8,8,0,0,1-5.66-13.66l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,215.39,163.06Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M212.24,164.24a6,6,0,0,1-8.48,0L128,88.49,52.24,164.24a6,6,0,0,1-8.48-8.48l80-80a6,6,0,0,1,8.48,0l80,80A6,6,0,0,1,212.24,164.24Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M210.83,162.83a4,4,0,0,1-5.66,0L128,85.66,50.83,162.83a4,4,0,0,1-5.66-5.66l80-80a4,4,0,0,1,5.66,0l80,80A4,4,0,0,1,210.83,162.83Z"}))]]),O=a.forwardRef((l,c)=>a.createElement(J,{ref:c,...l,weights:me}));O.displayName="CaretUpIcon";const he=O,k=["id","name","template","replacement","createdAt","updatedAt"],ue=new Set(k),pe=`query FetchPlaceholders(
|
|
2
2
|
$searchFilter: SearchFilterInput,
|
|
3
3
|
$pagination: PaginationInput
|
|
4
4
|
) {
|
|
@@ -10,9 +10,9 @@ import{j as e}from"./note-vendor-i1M2FSI2.js";import{p as Y,h as E,w as J,q as v
|
|
|
10
10
|
placeholders {
|
|
11
11
|
__PLACEHOLDER_FIELDS__ }
|
|
12
12
|
}
|
|
13
|
-
}`,xe=l=>{const c=l&&l.length>0?l.filter(r=>ue.has(r)):
|
|
13
|
+
}`,xe=l=>{const c=l&&l.length>0?l.filter(r=>ue.has(r)):k;return Array.from(new Set(c)).map(r=>" "+r).join(`
|
|
14
14
|
`)+`
|
|
15
|
-
`},ge=async({limit:l=25,offset:c=0,query:h="",fields:r}={})=>{const g=xe(r),i=pe.replace("__PLACEHOLDER_FIELDS__",g);return
|
|
15
|
+
`},ge=async({limit:l=25,offset:c=0,query:h="",fields:r}={})=>{const g=xe(r),i=pe.replace("__PLACEHOLDER_FIELDS__",g);return P(i,{searchFilter:{query:h},pagination:{limit:l,offset:c}})},ye=l=>P(`mutation CreatePlaceholder(
|
|
16
16
|
$name: String!,
|
|
17
17
|
$template: String!,
|
|
18
18
|
$replacement: String!
|
|
@@ -29,6 +29,6 @@ __PLACEHOLDER_FIELDS__ }
|
|
|
29
29
|
createdAt
|
|
30
30
|
updatedAt
|
|
31
31
|
}
|
|
32
|
-
}`,l),fe=l=>
|
|
32
|
+
}`,l),fe=l=>P(`mutation DeletePlaceholder($id: ID!) {
|
|
33
33
|
deletePlaceholder(id: $id)
|
|
34
|
-
}`,{id:l}),I=ce(ie),
|
|
34
|
+
}`,{id:l}),I=ce(ie),Ee=()=>{const l=oe(),c=V(),h=I.useNavigate(),{page:r}=I.useSearch(),[g,i]=a.useState(!1),[y,H]=a.useState(!0),[n,u]=a.useState({name:"",template:"",replacement:""}),o=25,T=v.placeholders.list({limit:o,offset:(r-1)*o}),[E]=a.useState(W),{data:d,isLoading:p}=ee({queryKey:T,queryFn:async()=>{const t=await ge({offset:(r-1)*o,limit:o});if(t.type==="error")throw t;return t.allPlaceholders}}),F=M({mutationFn:ye,onSuccess:async()=>{l("Placeholder added successfully"),i(!1),u({name:"",template:"",replacement:""}),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),q=M({mutationFn:fe,onSuccess:async()=>{l("Placeholder deleted successfully"),await c.invalidateQueries({queryKey:v.placeholders.listAll(),exact:!1})}}),B=E.length,x=d?.totalCount??0,Z=d?.placeholders??[],f="font-medium text-fg-tertiary",L="leading-[1.2]",A="break-all leading-[1.2]",S="leading-[1.2]",_="flex flex-col gap-px",R="space-y-px",Q="focus-ring-soft inline-flex items-center gap-2 rounded-[12px] border border-transparent px-2.5 py-1.5 text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",K="relative",U="absolute right-2 top-2",X="focus-ring-soft surface-base group flex flex-col items-center justify-center gap-0.5 px-4 py-4 text-center text-fg-secondary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",G="inline-flex h-[34px] w-[34px] items-center justify-center rounded-full border border-border-subtle bg-surface text-current transition-colors group-hover:border-border-secondary/70",z=x>0?`Placeholders (${x})`:void 0;return e.jsxs(ae,{title:"Placeholders",variant:"default",heading:p?e.jsx($,{width:244,height:24,className:"rounded-full"}):z,description:p?e.jsx($,{width:260,height:16,className:"rounded-full"}):"Create tokens that get replaced with values when you clone a note",children:[e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("section",{className:"space-y-3 border-b border-border-subtle/80 pb-5",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"System placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Built-in tokens for date and time that are always available when cloning notes"})]}),e.jsxs("button",{type:"button",onClick:()=>H(!y),className:Q,children:[e.jsxs(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:[B," items"]}),y?e.jsx(he,{className:"h-4 w-4"}):e.jsx(te,{className:"h-4 w-4"})]})]}),y&&e.jsx("div",{className:"grid-auto-cards grid gap-5",children:E.map(t=>e.jsx(D,{children:e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:L,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Current value: ",t.replacement]})]})]})},t.name))})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"Custom placeholders"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"Custom tokens you define once and reuse whenever you clone a note"})]}),!p&&e.jsx(s,{as:"span",variant:"meta",weight:"medium",tone:"secondary",children:x===1?"1 item":`${x} items`})]}),!p&&e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[Z.map(t=>e.jsxs(D,{className:K,children:[e.jsx(C,{variant:"ghost",size:"icon-sm",className:U,onClick:()=>q.mutate(t.id.toString()),children:e.jsx(se,{className:"h-4 w-4"})}),e.jsxs("div",{className:_,children:[e.jsx(s,{as:"div",variant:"body",weight:"medium",className:`min-w-0 pr-8 ${L}`,children:t.name}),e.jsxs("div",{className:R,children:[e.jsxs(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:A,children:[j,t.template,N]}),e.jsxs(s,{as:"div",variant:"label",weight:"medium",tone:"tertiary",className:S,children:["Replaces with: ",t.replacement]})]})]})]},t.id)),e.jsxs("button",{type:"button",onClick:()=>i(!0),className:X,children:[e.jsx("span",{className:G,children:e.jsx(de,{className:"h-4.5 w-4.5"})}),e.jsx(s,{as:"div",variant:"meta",weight:"medium",tone:"secondary",className:"text-current",children:"New custom"})]})]})]})]}),e.jsxs(m,{isOpen:g,onClose:()=>i(!1),variant:"form",children:[e.jsx(m.Header,{title:"Add Placeholder",onClose:()=>i(!1)}),e.jsxs(m.Body,{children:[e.jsx(m.Description,{className:"mb-4",children:"Create a token that swaps in a value when you clone a note"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"name",className:f,children:"Name"}),e.jsx(w,{id:"name",type:"text",value:n.name,onChange:t=>u({...n,name:t.target.value}),placeholder:"Description of this placeholder"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"A readable label so you can find this placeholder later"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"template",className:f,children:"Placeholder"}),e.jsx(w,{id:"template",type:"text",value:n.template,onChange:t=>u({...n,template:t.target.value}),placeholder:"note_app"}),e.jsxs(s,{as:"p",variant:"meta",tone:"secondary",children:["Use it in a note as ",j,"your_placeholder",N]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"replacement",className:f,children:"Replacement"}),e.jsx(w,{id:"replacement",type:"text",value:n.replacement,onChange:t=>u({...n,replacement:t.target.value}),placeholder:"Ocean Brain"}),e.jsx(s,{as:"p",variant:"meta",tone:"secondary",children:"This value is inserted when the placeholder is replaced during cloning"})]})]})]}),e.jsx(m.Footer,{children:e.jsxs(le,{children:[e.jsx(C,{variant:"ghost",onClick:()=>i(!1),children:"Cancel"}),e.jsx(C,{variant:"primary",isLoading:F.isPending,onClick:()=>{if(!n.name||!n.template||!n.replacement){l("All fields are required");return}F.mutate({name:n.name,template:n.template,replacement:n.replacement})},children:"Add"})]})})]}),e.jsx(ne,{fallback:null,children:d?.totalCount&&o<d.totalCount&&e.jsx(re,{page:r,last:Math.ceil(d.totalCount/o),onChange:t=>{h({search:Y=>({...Y,page:t})})}})})]})};export{Ee as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{w as oe,u as de,F as ce,q as x,ah as M,b1 as ue,b2 as me,b3 as pe,P as he,T as s,B as o,M as d,I as v,S as xe,e as be,r as q,X as ve,j as ye,aI as ge}from"./index-nYj7BL3a.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-DMZcZ4yV.js";const fe=ye(ge),W=[{value:"text",label:"Text",description:"Short status or label values."},{value:"url",label:"URL",description:"External sources, issues, docs, or references."},{value:"number",label:"Number",description:"Priority, score, or count values."},{value:"date",label:"Date",description:"Due dates and milestones."},{value:"boolean",label:"Boolean",description:"True or false flags."},{value:"select",label:"Select",description:"Choose one option from a controlled list."}],je=l=>!l.id&&!l.label.trim()&&!l.value.trim(),Ne=l=>(l.value.trim()||l.label.trim()).toLowerCase().replace(/\s+/g,"-"),Ce=l=>/^[a-z0-9][a-z0-9_-]*$/.test(l),X=l=>l.filter(r=>r.id||r.label.trim()).map((r,F)=>({...r.id?{id:r.id}:{},label:r.label.trim(),value:r.value.trim()||r.label.trim(),color:r.color??null,order:r.order??F}));function Ee(){const l=ve(),r=oe(),F=fe.useSearch(),Z=Number(F.page??1),R=50,V=Math.max(0,Z-1)*R,[O,I]=p.useState(""),[Q,A]=p.useState(""),[y,$]=p.useState("text"),[D,j]=p.useState([{label:"",value:""}]),[u,N]=p.useState(null),[i,H]=p.useState(null),[k,L]=p.useState(""),[E,g]=p.useState([{label:"",value:""}]),[ee,C]=p.useState(!1),S=()=>{I(""),A(""),$("text"),j([{label:"",value:""}])},ae=a=>{H(a),L(a.name),g(a.options.length>0?a.options.map(t=>({id:t.id,label:t.label,value:t.value,color:t.color,order:t.order})):[{label:"",value:""}])},T=()=>{H(null),L(""),g([{label:"",value:""}])},_=de({queryKey:x.notes.propertyKeys({limit:R,offset:V}),queryFn:async()=>{const a=await ce({limit:R,offset:V});if(a.type==="error")throw a;return a.notePropertyKeys}}),w=M({mutationFn:async()=>ue({key:O,name:Q||O,valueType:y,...y==="select"?{options:D.map((a,t)=>({label:a.label.trim(),value:a.value.trim()||a.label.trim(),order:t})).filter(a=>a.label)}:{}}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to create property.");return}S(),C(!1),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),l("Property created.")},onError:()=>{l("Failed to create property.")}}),h=M({mutationFn:async()=>{if(!i)throw new Error("Property to edit is missing.");return me({key:i.key,name:k||i.key,...i.valueType==="select"?{options:X(E)}:{}})},onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to update property.");return}T(),r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),l("Property updated.")},onError:()=>{l("Failed to update property.")}}),f=M({mutationFn:async({propertyKey:a,confirmImpact:t})=>pe({key:a.key,confirmImpact:t}),onSuccess:a=>{if(a.type==="error"){l(a.errors[0]?.message??"Failed to delete property.");return}r.invalidateQueries({queryKey:x.notes.propertyKeysAll(),exact:!1}),r.invalidateQueries({queryKey:x.notes.all(),exact:!1}),r.invalidateQueries({queryKey:x.views.all(),exact:!1}),N(null),l(a.deleteNotePropertyKey.affectedNoteCount>0?`Property deleted from ${a.deleteNotePropertyKey.affectedNoteCount} note(s).`:"Property deleted.")},onError:()=>{l("Failed to delete property.")}}),P=_.data?.keys??[],se=y!=="select"||D.some(a=>a.label.trim()),z=i?.valueType==="select"?E.filter(a=>!je(a)):[],B=z.map(Ne),K=B.find((a,t)=>B.indexOf(a)!==t),U=B.find(a=>!Ce(a)),J=z.some(a=>!!a.id&&!a.label.trim()),Y=z.some(a=>!a.id&&!a.label.trim()),te=!i||i.valueType!=="select"||z.length>0&&!J&&!Y&&!K&&!U,le=!!i&&k.trim()!==i?.name,re=i?.valueType==="select"&&JSON.stringify(X(E))!==JSON.stringify(i.options.map(a=>({id:a.id,label:a.label,value:a.value,color:a.color??null,order:a.order}))),ie=le||!!re,G=J?"Existing option labels cannot be empty.":Y?"New options need a label.":K?`Option value “${K}” is duplicated.`:U?"Option values must use letters, numbers, dashes, or underscores.":"",ne=()=>{u&&f.mutate({propertyKey:u,confirmImpact:u.noteCount>0})};return e.jsxs(he,{title:"Properties",description:"Define shared note fields before using them in notes and future views.",headerRight:e.jsx(o,{type:"button",size:"md",variant:"primary",className:"w-full sm:w-auto",onClick:()=>C(!0),children:"New property"}),children:[e.jsxs("section",{className:"flex flex-col gap-3","aria-labelledby":"shared-properties-heading",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(s,{id:"shared-properties-heading",as:"h2",variant:"label",weight:"medium",className:"text-fg-tertiary",children:"Shared fields"}),!_.isLoading&&P.length>0&&e.jsxs(s,{as:"span",variant:"meta",tone:"tertiary",children:[P.length," field",P.length===1?"":"s"]})]}),_.isLoading?e.jsx(s,{as:"p",variant:"body",tone:"tertiary",className:"surface-base px-4 py-3.5",children:"Loading properties..."}):P.length===0?e.jsxs("div",{className:"surface-base border-dashed p-6 text-center",children:[e.jsx(s,{as:"p",variant:"body",weight:"medium",children:"No shared properties yet."}),e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create one here, then attach it from the note screen."})]}):e.jsx("div",{className:"flex flex-col gap-3",children:P.map(a=>e.jsxs("article",{className:"surface-base grid gap-3 px-4 py-3.5 md:grid-cols-[minmax(0,1fr)_120px_120px_auto] md:items-center",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"h3",variant:"body",weight:"semibold",className:"truncate",children:a.name}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"font-mono",children:a.key}),a.options.length>0&&e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[a.options.slice(0,6).map(t=>e.jsx("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-secondary",children:t.label},t.id)),a.options.length>6&&e.jsxs("span",{className:"rounded-full border border-border-subtle bg-subtle px-2 py-0.5 text-xs font-medium text-fg-tertiary",children:["+",a.options.length-6]})]})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Type"}),e.jsx(s,{as:"span",variant:"label",tone:"secondary",className:"capitalize",children:a.valueType})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block md:hidden",children:"Used in"}),e.jsxs(s,{as:"span",variant:"label",tone:"tertiary",children:[a.noteCount," note",a.noteCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-self-start md:justify-self-end",children:[e.jsx(o,{type:"button",size:"sm",variant:"subtle",disabled:h.isPending||f.isPending,onClick:()=>ae(a),children:"Edit"}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",disabled:f.isPending||h.isPending,onClick:()=>N(a),children:"Delete"})]})]},a.key))})]}),e.jsxs(d,{isOpen:ee,onClose:()=>{w.isPending||(C(!1),S())},variant:"form",children:[e.jsx(d.Header,{title:"New property",onClose:()=>{C(!1),S()}}),e.jsx(d.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Create a shared field that notes can use for values and future views."}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Key"}),e.jsx(v,{size:"md",placeholder:"status",value:O,onChange:a=>I(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Name"}),e.jsx(v,{size:"md",placeholder:"Status",value:Q,onChange:a=>A(a.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Type"}),e.jsx(xe,{value:y,onValueChange:a=>$(a),children:W.map(a=>e.jsx(be,{value:a.value,children:a.label},a.value))})]}),y==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>j(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:D.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:"value",value:a.value,onChange:c=>j(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>j(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},t))})]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",children:W.find(a=>a.value===y)?.description})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:w.isPending,onClick:()=>{C(!1),S()},children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!O.trim()||!se||w.isPending,isLoading:w.isPending,onClick:()=>w.mutate(),children:"Create property"})]})})]}),e.jsxs(d,{isOpen:!!i,onClose:()=>{h.isPending||T()},variant:"form",children:[e.jsx(d.Header,{title:"Edit property",onClose:()=>{h.isPending||T()}}),e.jsx(d.Body,{children:i&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"Rename the display label or add select options. Key, type, and existing option values stay fixed so notes and views remain stable."}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Key"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"font-mono",children:i.key})]}),e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 px-3 py-2",children:[e.jsx(s,{as:"span",variant:"micro",tone:"tertiary",className:"block",children:"Type"}),e.jsx(s,{as:"span",variant:"label",weight:"medium",className:"capitalize",children:i.valueType})]})]}),e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx(s,{as:"span",variant:"label",weight:"medium",children:"Display name"}),e.jsx(v,{size:"md",placeholder:"Workflow state",value:k,onChange:a=>L(a.target.value)})]}),i.valueType==="select"&&e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle/50 p-3",children:[e.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx(s,{as:"span",variant:"label",weight:"semibold",children:"Options"}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-0.5",children:"Existing option values are locked. Removing existing options needs an impact-aware delete flow."})]}),e.jsx(o,{type:"button",size:"sm",variant:"subtle",onClick:()=>g(a=>[...a,{label:"",value:""}]),children:"Add option"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map((a,t)=>e.jsxs("div",{className:"grid gap-2 sm:grid-cols-[1fr_1fr_auto]",children:[e.jsx(v,{size:"sm",placeholder:"Label",value:a.label,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,label:c.target.value}:n))}),e.jsx(v,{size:"sm",placeholder:a.id?"Locked value":"value",value:a.value,disabled:!!a.id,onChange:c=>g(m=>m.map((n,b)=>b===t?{...n,value:c.target.value}:n))}),a.id?e.jsx(s,{as:"span",variant:"meta",tone:"tertiary",className:"flex h-8 items-center px-3",children:"Locked"}):e.jsx(o,{type:"button",size:"sm",variant:"soft-danger",onClick:()=>g(c=>c.filter((m,n)=>n!==t)),children:"Remove"})]},a.id??`new-${t}`))}),G&&e.jsx(s,{as:"p",variant:"micro",tone:"error",className:"mt-2",children:G})]})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:h.isPending,onClick:T,children:"Cancel"}),e.jsx(o,{type:"button",variant:"primary",size:"sm",disabled:!k.trim()||!ie||!te||h.isPending,isLoading:h.isPending,onClick:()=>h.mutate(),children:"Save changes"})]})})]}),e.jsxs(d,{isOpen:!!u,onClose:()=>{f.isPending||N(null)},variant:"confirm",children:[e.jsx(d.Header,{title:"Delete property",onClose:()=>N(null)}),e.jsx(d.Body,{children:u&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs(s,{as:"p",variant:"body",weight:"medium",children:["Delete “",u.name,"”?"]}),u.noteCount>0?e.jsxs("div",{className:"rounded-[14px] border border-border-subtle bg-subtle p-3",children:[e.jsxs(s,{as:"p",variant:"label",tone:"secondary",children:["This property is used by ",u.noteCount," note",u.noteCount===1?"":"s","."]}),e.jsx(s,{as:"p",variant:"micro",tone:"tertiary",className:"mt-1 leading-5",children:"Deleting it removes this value from those notes. Future views using this property will need configuration."})]}):e.jsx(s,{as:"p",variant:"label",tone:"tertiary",children:"This property is not used by any note yet."})]})}),e.jsx(d.Footer,{children:e.jsxs(q,{children:[e.jsx(o,{type:"button",variant:"ghost",size:"sm",disabled:f.isPending,onClick:()=>N(null),children:"Cancel"}),e.jsx(o,{type:"button",variant:"danger",size:"sm",isLoading:f.isPending,onClick:ne,children:"Delete"})]})})]})]})}export{Ee as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./note-vendor-uuJO2MTD.js";import{a0 as M,j as Q,aw as F,w as L,v as _,a6 as I,aT as K,q as i,ah as E,aU as B,N as O,aV as W,P as N,G,T as d,ax as H,B as j,a1 as U,aW as V,i as l,X as Y,d as $,ak as z,u as X,aX as Z,M as y}from"./index-nYj7BL3a.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-FhlC8VSR.js";import"./note-core-DMZcZ4yV.js";const m=25,v=Q(F),S=30,R=`Deleted notes stay here for ${S} days before permanent removal`,g={title:"Permanently delete note?",description:"This note is referenced by the notes below. If you permanently delete it, those links will stay broken. Other notes will not be edited automatically.",confirmLabel:"Delete now",confirmVariant:"danger"},P=a=>$(a).format("YYYY-MM-DD HH:mm"),J=({note:a,onClose:o})=>{const s=a?.id??"",c=a?.title||"Untitled note",r=X({queryKey:i.notes.trashDetail(s),enabled:!!a,queryFn:async()=>{const h=await Z(s);if(h.type==="error")throw h;if(!h.trashedNote)throw new Error("Trashed note not found");return h.trashedNote}}),f=r.data?.contentAsMarkdown.trim()??"";return e.jsxs(y,{isOpen:!!a,onClose:o,variant:"inspect",children:[e.jsx(y.Header,{title:c,onClose:o}),e.jsx(y.Body,{children:e.jsxs("div",{className:"flex flex-col gap-3",children:[a&&e.jsxs(d,{as:"p",variant:"meta",tone:"secondary",children:["Deleted ",P(a.deletedAt)]}),r.isLoading&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",children:"Loading deleted note content..."}),r.isError&&e.jsx(d,{as:"p",variant:"meta",tone:"error",children:"Failed to load deleted note content."}),!r.isLoading&&!r.isError&&f&&e.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:f}),!r.isLoading&&!r.isError&&!f&&e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this deleted note."})]})}),e.jsx(y.Footer,{children:e.jsx(j,{variant:"ghost",size:"sm",onClick:o,children:"Close"})})]})},ee=()=>e.jsx(N,{title:"Trash",variant:"default",heading:e.jsx(l,{width:118,height:24,className:"rounded-full"}),description:e.jsx(l,{width:352,height:16,className:"rounded-full"}),children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:3},(a,o)=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsx(l,{width:"40%",height:18,className:"rounded-full"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:168,height:14,className:"rounded-full"}),e.jsx(l,{width:176,height:14,className:"rounded-full"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(l,{width:56,height:24,className:"rounded-full"}),e.jsx(l,{width:72,height:24,className:"rounded-full"})]})]}),e.jsx(l,{width:92,height:32,className:"rounded-[12px]"})]})},o))})}),te=()=>{const{page:a}=v.useSearch(),o=v.useNavigate(),s=L(),c=Y(),r=_(),[f,h]=k.useState(null),[x,b]=k.useState(null),{data:u}=I({queryKey:i.notes.trash({limit:m,offset:(a-1)*m}),queryFn:async()=>{const t=await K({limit:m,offset:(a-1)*m});if(t.type==="error")throw t;return t.trashedNotes}}),w=E({mutationFn:B,onSuccess:async t=>{if(t.type==="error")throw t;await Promise.all([s.invalidateQueries({queryKey:i.notes.all(),exact:!1}),s.invalidateQueries({queryKey:i.tags.all(),exact:!1}),s.invalidateQueries({queryKey:i.reminders.all(),exact:!1}),s.invalidateQueries({queryKey:i.images.all(),exact:!1}),s.invalidateQueries({queryKey:i.calendar.all(),exact:!1})]),c("The note has been restored."),o({to:O,params:{id:t.restoreTrashedNote.id}})},onError:()=>{c("Failed to restore the note.")}}),p=E({mutationFn:W,onSuccess:async t=>{if(t.type==="error")throw t;await s.invalidateQueries({queryKey:i.notes.trashAll(),exact:!1}),c("The note has been permanently deleted.")},onError:()=>{c("Failed to permanently delete the note.")}}),D=()=>{if(!x)return;const{id:t}=x;b(null),p.mutate(t)},q=async t=>{const n=await z(t);if(n.type==="error"){c("Failed to check linked notes before permanently deleting this note.");return}if(s.setQueryData(i.notes.backReferences(t),n.backReferences),n.backReferences.length>0){b({id:t,backReferences:n.backReferences});return}await r("Permanently delete this note? This cannot be undone.")&&p.mutate(t)},T=u.totalCount>0?`Trash (${u.totalCount})`:void 0,A=u.notes.find(t=>t.id===f)??null;return u.notes.length===0?e.jsx(N,{title:"Trash",variant:"default",heading:T,description:R,children:e.jsx(G,{title:"Trash is empty",description:`Delete a note and you can restore it here for ${S} days before permanent removal`})}):e.jsxs(N,{title:"Trash",variant:"default",heading:T,description:R,children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid gap-3",children:u.notes.map(t=>e.jsx(C,{padding:"compact",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-1.5",children:[e.jsx(d,{as:"h2",variant:"body",weight:"medium",className:"min-w-0 flex-1 break-words leading-[1.25]",children:t.title||"Untitled note"}),t.pinned&&e.jsx("span",{title:"Pinned",className:"inline-flex h-5 w-5 shrink-0 items-center justify-center text-fg-tertiary",children:e.jsx(H,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1",children:e.jsxs(d,{as:"div",variant:"meta",weight:"medium",tone:"secondary",children:["Deleted ",P(t.deletedAt)]})}),t.tagNames.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.tagNames.map(n=>e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"rounded-full border border-border-subtle bg-hover-subtle px-2 py-0.5",children:n},`${t.id}-${n}`))}),t.contentPreview&&e.jsx("div",{className:"mt-3 rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:e.jsx(d,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-3 whitespace-pre-wrap break-words",children:t.contentPreview})})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[e.jsx(j,{variant:"subtle",size:"sm",onClick:()=>h(t.id),children:"View content"}),e.jsx(j,{variant:"subtle",size:"sm",isLoading:w.isPending&&w.variables===t.id,onClick:()=>w.mutate(t.id),children:"Restore"}),e.jsx(j,{variant:"soft-danger",size:"sm",isLoading:p.isPending&&p.variables===t.id,onClick:()=>q(t.id),children:"Delete now"})]})]})},t.id))}),u.totalCount>m&&e.jsx(U,{page:a,last:Math.ceil(u.totalCount/m),onChange:t=>{o({search:n=>({...n,page:t})})}})]}),e.jsx(J,{note:A,onClose:()=>h(null)}),e.jsx(V,{isOpen:!!x,title:g.title,description:g.description,references:x?.backReferences??[],confirmLabel:g.confirmLabel,confirmVariant:g.confirmVariant,onClose:()=>b(null),onConfirm:D})]})},oe=()=>{const{page:a}=v.useSearch();return e.jsx(M,{fallback:e.jsx(ee,{}),errorTitle:"Failed to load trash",errorDescription:"Retry loading deleted notes",resetKeys:[a],children:e.jsx(te,{})})};export{oe as default};
|
package/server/client/dist/assets/{useReminderMutate-D21PurIS.js → useReminderMutate-CSKliBcc.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as y}from"./note-vendor-
|
|
1
|
+
import{j as y}from"./note-vendor-uuJO2MTD.js";import{h as u,a6 as f,q as n,w as R,X as $}from"./index-nYj7BL3a.js";import{a as l}from"./graph-vendor-CUxe67Lr.js";const g=(e={})=>({limit:e.limit??10,offset:e.offset??0}),D=async(e,t)=>u(`
|
|
2
2
|
query FetchNoteReminders($noteId: ID!, $pagination: PaginationInput) {
|
|
3
3
|
noteReminders(noteId: $noteId, pagination: $pagination) {
|
|
4
4
|
totalCount
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import{h as n}from"./index-nYj7BL3a.js";const d=`
|
|
2
|
+
id
|
|
3
|
+
tabId
|
|
4
|
+
title
|
|
5
|
+
displayType
|
|
6
|
+
tagNames
|
|
7
|
+
mode
|
|
8
|
+
propertyFilters {
|
|
9
|
+
key
|
|
10
|
+
name
|
|
11
|
+
valueType
|
|
12
|
+
operator
|
|
13
|
+
value
|
|
14
|
+
}
|
|
15
|
+
sortBy
|
|
16
|
+
sortOrder
|
|
17
|
+
limit
|
|
18
|
+
order
|
|
19
|
+
`;function V(){return n(`query FetchViewWorkspace {
|
|
20
|
+
viewWorkspace {
|
|
21
|
+
activeTabId
|
|
22
|
+
tabs {
|
|
23
|
+
id
|
|
24
|
+
title
|
|
25
|
+
order
|
|
26
|
+
sections {
|
|
27
|
+
${d}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}`)}function I(e){return n(`query FetchViewSection($id: ID!) {
|
|
32
|
+
viewSection(id: $id) {
|
|
33
|
+
${d}
|
|
34
|
+
}
|
|
35
|
+
}`,{id:e})}function w(e,{limit:t=25,offset:i=0}={}){return n(`query FetchViewSectionNotes($id: ID!, $pagination: PaginationInput) {
|
|
36
|
+
viewSectionNotes(id: $id, pagination: $pagination) {
|
|
37
|
+
totalCount
|
|
38
|
+
notes {
|
|
39
|
+
id
|
|
40
|
+
title
|
|
41
|
+
pinned
|
|
42
|
+
tags {
|
|
43
|
+
id
|
|
44
|
+
name
|
|
45
|
+
}
|
|
46
|
+
createdAt
|
|
47
|
+
updatedAt
|
|
48
|
+
properties {
|
|
49
|
+
key
|
|
50
|
+
name
|
|
51
|
+
value
|
|
52
|
+
valueType
|
|
53
|
+
option { id label value color order }
|
|
54
|
+
createdAt
|
|
55
|
+
updatedAt
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}`,{id:e,pagination:{limit:t,offset:i}})}function $(e){return n(`mutation CreateViewTab($title: String!) {
|
|
60
|
+
createViewTab(title: $title) {
|
|
61
|
+
id
|
|
62
|
+
}
|
|
63
|
+
}`,{title:e})}function m(e,t){return n(`mutation UpdateViewTab($id: ID!, $title: String!) {
|
|
64
|
+
updateViewTab(id: $id, title: $title) {
|
|
65
|
+
id
|
|
66
|
+
}
|
|
67
|
+
}`,{id:e,title:t})}function f(e){return n(`mutation DeleteViewTab($id: ID!) {
|
|
68
|
+
deleteViewTab(id: $id)
|
|
69
|
+
}`,{id:e})}function T(e){return n(`mutation SetActiveViewTab($id: ID!) {
|
|
70
|
+
setActiveViewTab(id: $id) {
|
|
71
|
+
activeTabId
|
|
72
|
+
tabs {
|
|
73
|
+
id
|
|
74
|
+
title
|
|
75
|
+
order
|
|
76
|
+
sections {
|
|
77
|
+
${d}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}`,{id:e})}function S(e){return n(`mutation ReorderViewTabs($tabIds: [ID!]!) {
|
|
82
|
+
reorderViewTabs(tabIds: $tabIds) {
|
|
83
|
+
id
|
|
84
|
+
}
|
|
85
|
+
}`,{tabIds:e})}function g(e,t){return n(`mutation CreateViewSection($tabId: ID!, $input: ViewSectionInput!) {
|
|
86
|
+
createViewSection(tabId: $tabId, input: $input) {
|
|
87
|
+
id
|
|
88
|
+
}
|
|
89
|
+
}`,{tabId:e,input:t})}function v(e,t){return n(`mutation UpdateViewSection($id: ID!, $input: ViewSectionInput!) {
|
|
90
|
+
updateViewSection(id: $id, input: $input) {
|
|
91
|
+
id
|
|
92
|
+
}
|
|
93
|
+
}`,{id:e,input:t})}function y(e){return n(`mutation DeleteViewSection($id: ID!) {
|
|
94
|
+
deleteViewSection(id: $id)
|
|
95
|
+
}`,{id:e})}function h(e,t){return n(`mutation ReorderViewSections($tabId: ID!, $sectionIds: [ID!]!) {
|
|
96
|
+
reorderViewSections(tabId: $tabId, sectionIds: $sectionIds) {
|
|
97
|
+
id
|
|
98
|
+
}
|
|
99
|
+
}`,{tabId:e,sectionIds:t})}const D={activeTabId:null,tabs:[]},l=e=>{const t=e.trim();return t?t.startsWith("@")?t:t.startsWith("#")?`@${t.slice(1)}`:`@${t}`:""},c=(e,t,i)=>{if(t===i)return e;const r=e.findIndex(s=>s.id===t),a=e.findIndex(s=>s.id===i);if(r<0||a<0)return e;const o=[...e],[u]=o.splice(r,1);return o.splice(a,0,u),o},A=e=>{const t=e.flatMap(i=>typeof i=="string"?i.split(","):[]);return Array.from(new Set(t.map(l).filter(Boolean)))},W=e=>e.tabs.length===0?null:e.activeTabId?e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[0]??null:e.tabs[0]??null,x=(e,t)=>e.tabs.some(i=>i.id===t)?{...e,activeTabId:t}:e,N=(e,t,i)=>({...e,tabs:c(e.tabs,t,i)}),E=(e,t,i,r)=>({...e,tabs:e.tabs.map(a=>a.id===t?{...a,sections:c(a.sections,i,r)}:a)}),F=e=>e==="or"?"Matches any selected tag":"Matches all selected tags",M=e=>e==="or"?"OR":"AND",b=e=>{switch(e){case"before":return"before";case"after":return"after";case"exists":return"is set";case"notExists":return"is empty";default:return"is"}},q=e=>{const t=b(e.operator);return e.operator==="exists"||e.operator==="notExists"?`${e.name} ${t}`:`${e.name} ${t} ${e.value??""}`.trim()},C=e=>({page:1,sectionId:e.id});export{D as E,q as a,C as b,b as c,F as d,V as e,w as f,M as g,W as h,T as i,S as j,E as k,h as l,$ as m,A as n,f as o,g as p,v as q,N as r,x as s,y as t,m as u,I as v};
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
<link rel="icon" type="image/png" href="/icon.png" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Ocean Brain</title>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<script type="module" crossorigin src="/assets/index-nYj7BL3a.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/graph-vendor-CUxe67Lr.js">
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/note-core-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/note-vendor-
|
|
13
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/note-core-DMZcZ4yV.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/note-vendor-uuJO2MTD.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Cd81UxEh.css">
|
|
14
14
|
</head>
|
|
15
15
|
|
|
16
16
|
<body>
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { listNoteProperties } from "../../../features/note/services/properties.js";
|
|
1
2
|
import { renderNoteSnapshotContentAsMarkdown } from "../../../features/note/services/snapshot.js";
|
|
2
3
|
import models from "../../../models.js";
|
|
3
4
|
const noteFieldResolvers = {
|
|
4
5
|
tags: async (note) => models.tag.findMany({ where: { notes: { some: { id: note.id } } } }),
|
|
6
|
+
properties: async (note) => listNoteProperties(note.id),
|
|
5
7
|
contentAsMarkdown: async (note) => {
|
|
6
8
|
const { blocksToMarkdown } = await import("../../../modules/blocknote.js");
|
|
7
9
|
return blocksToMarkdown(note.content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/note/graphql/note.field.resolver.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\nimport { renderNoteSnapshotContentAsMarkdown } from '~/features/note/services/snapshot.js';\nimport type { Note } from '~/models.js';\nimport models from '~/models.js';\n\ntype NoteFieldResolvers = NonNullable<IResolvers['Note']>;\ntype NoteSnapshotFieldResolvers = NonNullable<IResolvers['NoteSnapshot']>;\n\ninterface NoteSnapshotSource {\n contentAsMarkdown?: string;\n payload?: string;\n}\n\nexport const noteFieldResolvers: NoteFieldResolvers = {\n tags: async (note: Note) => models.tag.findMany({ where: { notes: { some: { id: note.id } } } }),\n contentAsMarkdown: async (note: Note) => {\n const { blocksToMarkdown } = await import('~/modules/blocknote.js');\n return blocksToMarkdown(note.content);\n },\n};\n\nexport const noteSnapshotFieldResolvers: NoteSnapshotFieldResolvers = {\n contentAsMarkdown: async (snapshot: NoteSnapshotSource) => {\n if (typeof snapshot.contentAsMarkdown === 'string') {\n return snapshot.contentAsMarkdown;\n }\n\n if (typeof snapshot.payload === 'string') {\n return renderNoteSnapshotContentAsMarkdown(snapshot.payload);\n }\n\n return '';\n },\n};\n"],"mappings":"AACA,SAAS,2CAA2C;AAEpD,OAAO,YAAY;AAUZ,MAAM,qBAAyC;AAAA,EAClD,MAAM,OAAO,SAAe,OAAO,IAAI,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;AAAA,EAC/F,mBAAmB,OAAO,SAAe;AACrC,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,wBAAwB;AAClE,WAAO,iBAAiB,KAAK,OAAO;AAAA,EACxC;AACJ;AAEO,MAAM,6BAAyD;AAAA,EAClE,mBAAmB,OAAO,aAAiC;AACvD,QAAI,OAAO,SAAS,sBAAsB,UAAU;AAChD,aAAO,SAAS;AAAA,IACpB;AAEA,QAAI,OAAO,SAAS,YAAY,UAAU;AACtC,aAAO,oCAAoC,SAAS,OAAO;AAAA,IAC/D;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/note/graphql/note.field.resolver.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\nimport { listNoteProperties } from '~/features/note/services/properties.js';\nimport { renderNoteSnapshotContentAsMarkdown } from '~/features/note/services/snapshot.js';\nimport type { Note } from '~/models.js';\nimport models from '~/models.js';\n\ntype NoteFieldResolvers = NonNullable<IResolvers['Note']>;\ntype NoteSnapshotFieldResolvers = NonNullable<IResolvers['NoteSnapshot']>;\n\ninterface NoteSnapshotSource {\n contentAsMarkdown?: string;\n payload?: string;\n}\n\nexport const noteFieldResolvers: NoteFieldResolvers = {\n tags: async (note: Note) => models.tag.findMany({ where: { notes: { some: { id: note.id } } } }),\n properties: async (note: Note) => listNoteProperties(note.id),\n contentAsMarkdown: async (note: Note) => {\n const { blocksToMarkdown } = await import('~/modules/blocknote.js');\n return blocksToMarkdown(note.content);\n },\n};\n\nexport const noteSnapshotFieldResolvers: NoteSnapshotFieldResolvers = {\n contentAsMarkdown: async (snapshot: NoteSnapshotSource) => {\n if (typeof snapshot.contentAsMarkdown === 'string') {\n return snapshot.contentAsMarkdown;\n }\n\n if (typeof snapshot.payload === 'string') {\n return renderNoteSnapshotContentAsMarkdown(snapshot.payload);\n }\n\n return '';\n },\n};\n"],"mappings":"AACA,SAAS,0BAA0B;AACnC,SAAS,2CAA2C;AAEpD,OAAO,YAAY;AAUZ,MAAM,qBAAyC;AAAA,EAClD,MAAM,OAAO,SAAe,OAAO,IAAI,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,KAAK,GAAG,EAAE,EAAE,EAAE,CAAC;AAAA,EAC/F,YAAY,OAAO,SAAe,mBAAmB,KAAK,EAAE;AAAA,EAC5D,mBAAmB,OAAO,SAAe;AACrC,UAAM,EAAE,iBAAiB,IAAI,MAAM,OAAO,wBAAwB;AAClE,WAAO,iBAAiB,KAAK,OAAO;AAAA,EACxC;AACJ;AAEO,MAAM,6BAAyD;AAAA,EAClE,mBAAmB,OAAO,aAAiC;AACvD,QAAI,OAAO,SAAS,sBAAsB,UAAU;AAChD,aAAO,SAAS;AAAA,IACpB;AAEA,QAAI,OAAO,SAAS,YAAY,UAAU;AACtC,aAAO,oCAAoC,SAAS,OAAO;AAAA,IAC/D;AAEA,WAAO;AAAA,EACX;AACJ;","names":[]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { GraphQLError } from "graphql";
|
|
2
2
|
import { extractBlocksByType, parseNoteContent } from "../../../features/note/services/content-blocks.js";
|
|
3
|
+
import {
|
|
4
|
+
createNotePropertyDefinition,
|
|
5
|
+
deleteNotePropertyDefinition,
|
|
6
|
+
InvalidNotePropertyInputError,
|
|
7
|
+
NotePropertyDeleteConfirmationRequiredError,
|
|
8
|
+
updateNotePropertiesWithVersionGuard,
|
|
9
|
+
updateNotePropertyDefinition
|
|
10
|
+
} from "../../../features/note/services/properties.js";
|
|
3
11
|
import { buildNoteSearchProjection } from "../../../features/note/services/search.js";
|
|
4
12
|
import { createSnapshotMetaFromUserAgent, restoreNoteSnapshot } from "../../../features/note/services/snapshot.js";
|
|
5
13
|
import { purgeTrashedNoteById, restoreTrashedNoteById, trashNoteById } from "../../../features/note/services/trash.js";
|
|
@@ -157,6 +165,117 @@ const noteMutationResolvers = {
|
|
|
157
165
|
}
|
|
158
166
|
return true;
|
|
159
167
|
},
|
|
168
|
+
createNotePropertyKey: async (_, { input }) => {
|
|
169
|
+
try {
|
|
170
|
+
return await createNotePropertyDefinition(input);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
if (error instanceof InvalidNotePropertyInputError) {
|
|
173
|
+
throw new GraphQLError(error.message, {
|
|
174
|
+
extensions: {
|
|
175
|
+
code: "INVALID_NOTE_PROPERTY_INPUT"
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
updateNotePropertyKey: async (_, { key, input }) => {
|
|
183
|
+
try {
|
|
184
|
+
const result = await updateNotePropertyDefinition({ key, input });
|
|
185
|
+
if (!result) {
|
|
186
|
+
throw "NOT FOUND";
|
|
187
|
+
}
|
|
188
|
+
return result;
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof InvalidNotePropertyInputError) {
|
|
191
|
+
throw new GraphQLError(error.message, {
|
|
192
|
+
extensions: {
|
|
193
|
+
code: "INVALID_NOTE_PROPERTY_INPUT"
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
throw error;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
deleteNotePropertyKey: async (_, { key, confirmImpact }) => {
|
|
201
|
+
try {
|
|
202
|
+
const result = await deleteNotePropertyDefinition({ key, confirmImpact });
|
|
203
|
+
if (!result) {
|
|
204
|
+
throw "NOT FOUND";
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (error instanceof InvalidNotePropertyInputError) {
|
|
209
|
+
throw new GraphQLError(error.message, {
|
|
210
|
+
extensions: {
|
|
211
|
+
code: "INVALID_NOTE_PROPERTY_INPUT"
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (error instanceof NotePropertyDeleteConfirmationRequiredError) {
|
|
216
|
+
throw new GraphQLError(error.message, {
|
|
217
|
+
extensions: {
|
|
218
|
+
code: error.code,
|
|
219
|
+
affectedNoteCount: error.affectedNoteCount
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
updateNoteProperties: async (_, {
|
|
227
|
+
id,
|
|
228
|
+
patch,
|
|
229
|
+
editSessionId,
|
|
230
|
+
expectedUpdatedAt,
|
|
231
|
+
force
|
|
232
|
+
}) => {
|
|
233
|
+
try {
|
|
234
|
+
const note = await updateNotePropertiesWithVersionGuard({
|
|
235
|
+
id: Number(id),
|
|
236
|
+
patch,
|
|
237
|
+
...editSessionId ? { editSessionId } : {},
|
|
238
|
+
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
239
|
+
...force ? { force: true } : {}
|
|
240
|
+
});
|
|
241
|
+
if (!note) {
|
|
242
|
+
throw "NOT FOUND";
|
|
243
|
+
}
|
|
244
|
+
return note;
|
|
245
|
+
} catch (error) {
|
|
246
|
+
if (error instanceof InvalidNotePropertyInputError) {
|
|
247
|
+
throw new GraphQLError(error.message, {
|
|
248
|
+
extensions: {
|
|
249
|
+
code: "INVALID_NOTE_PROPERTY_INPUT"
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
if (isNoteVersionConflictError(error)) {
|
|
254
|
+
throw new GraphQLError(error.message, {
|
|
255
|
+
extensions: {
|
|
256
|
+
code: error.code,
|
|
257
|
+
currentUpdatedAt: error.currentUpdatedAt,
|
|
258
|
+
expectedUpdatedAt: error.expectedUpdatedAt
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
if (isInvalidNoteVersionError(error)) {
|
|
263
|
+
throw new GraphQLError(error.message, {
|
|
264
|
+
extensions: {
|
|
265
|
+
code: error.code
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
if (isMissingNoteVersionError(error)) {
|
|
270
|
+
throw new GraphQLError(error.message, {
|
|
271
|
+
extensions: {
|
|
272
|
+
code: error.code
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
},
|
|
160
279
|
pinNote: (_, { id, pinned }) => models.note.update({
|
|
161
280
|
where: { id: Number(id) },
|
|
162
281
|
data: { pinned: Boolean(pinned) }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/note/graphql/note.mutation.resolver.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\nimport type { Request } from 'express';\nimport { GraphQLError } from 'graphql';\nimport { extractBlocksByType, parseNoteContent } from '~/features/note/services/content-blocks.js';\nimport { buildNoteSearchProjection } from '~/features/note/services/search.js';\nimport { createSnapshotMetaFromUserAgent, restoreNoteSnapshot } from '~/features/note/services/snapshot.js';\nimport { purgeTrashedNoteById, restoreTrashedNoteById, trashNoteById } from '~/features/note/services/trash.js';\nimport { updateNoteWithVersionGuard } from '~/features/note/services/write.js';\nimport {\n isInvalidNoteVersionError,\n isMissingNoteVersionError,\n isNoteVersionConflictError,\n} from '~/features/note/services/write-conflict.js';\nimport models from '~/models.js';\nimport type { NoteInput } from '~/types/index.js';\n\nconst PLACEHOLDER_PREFIX = '{%';\nconst PLACEHOLDER_SUFFIX = '%}';\n\nconst replacePlaceholders = async (content: string) => {\n const placeholders = content.matchAll(new RegExp(`${PLACEHOLDER_PREFIX}([^}]+)${PLACEHOLDER_SUFFIX}`, 'g'));\n const resolvedPlaceholders = await models.placeholder.findMany({\n select: {\n template: true,\n replacement: true,\n },\n where: { template: { in: Array.from(new Set(Array.from(placeholders, (match) => match[1]))) } },\n });\n\n let replacedContent = content;\n\n for (const placeholder of resolvedPlaceholders) {\n replacedContent = replacedContent.replace(\n new RegExp(`${PLACEHOLDER_PREFIX}${placeholder.template}${PLACEHOLDER_SUFFIX}`, 'g'),\n placeholder.replacement,\n );\n }\n\n return replacedContent;\n};\n\nconst getRequestUserAgent = (req?: Request) => {\n const userAgentHeader = req?.headers['user-agent'];\n return Array.isArray(userAgentHeader) ? userAgentHeader[0] : userAgentHeader;\n};\n\nconst toTagConnections = (blocks: Array<{ props?: { id?: string | number } }>) => {\n return blocks\n .map((block) => block.props?.id)\n .filter((id) => id !== undefined && id !== null && String(id).trim() !== '')\n .map((id) => Number(id))\n .filter(Number.isFinite)\n .map((id) => ({ id }));\n};\n\nconst parseRequiredNoteContent = (content: string) => {\n const parsedContent = parseNoteContent(content);\n\n if (!parsedContent) {\n throw new GraphQLError('Note content must be valid BlockNote JSON.', {\n extensions: {\n code: 'INVALID_NOTE_CONTENT',\n },\n });\n }\n\n return parsedContent;\n};\n\ntype NoteMutationResolvers = NonNullable<IResolvers['Mutation']>;\ntype CreateNoteInput = Required<Pick<NoteInput, 'title' | 'content'>> & Pick<NoteInput, 'layout'>;\n\nexport const noteMutationResolvers: NoteMutationResolvers = {\n createNote: async (_, { note }: { note: CreateNoteInput }) => {\n const replacedTitle = await replacePlaceholders(note.title);\n const replacedContent = await replacePlaceholders(note.content);\n const parsedContent = replacedContent ? parseRequiredNoteContent(replacedContent) : null;\n const blocks = parsedContent ? extractBlocksByType<{ id: string }>('tag', parsedContent) : [];\n const createdNote = await models.note.create({\n data: {\n title: replacedTitle,\n content: replacedContent,\n ...buildNoteSearchProjection({\n title: replacedTitle,\n content: replacedContent,\n }),\n ...(note.layout && { layout: note.layout }),\n },\n });\n\n if (!replacedContent) {\n return createdNote;\n }\n\n return models.note.update({\n where: { id: createdNote.id },\n data: { tags: { set: toTagConnections(blocks) } },\n });\n },\n updateNote: async (\n _,\n {\n id,\n note,\n editSessionId,\n expectedUpdatedAt,\n force,\n }: {\n id: number;\n note: NoteInput;\n editSessionId?: string;\n expectedUpdatedAt?: string;\n force?: boolean;\n },\n context: {\n req?: Request;\n },\n ) => {\n const parsedContent = note.content ? parseRequiredNoteContent(note.content) : null;\n const blocks = parsedContent ? extractBlocksByType<{ id: string }>('tag', parsedContent) : [];\n try {\n const updatedNote = await updateNoteWithVersionGuard({\n id: Number(id),\n data: {\n ...(note.title !== undefined ? { title: note.title } : {}),\n ...(note.content !== undefined ? { content: note.content } : {}),\n ...(note.layout !== undefined ? { layout: note.layout } : {}),\n ...(note.content !== undefined ? { tagIds: toTagConnections(blocks).map((tag) => tag.id) } : {}),\n },\n ...(editSessionId ? { editSessionId } : {}),\n ...(expectedUpdatedAt ? { expectedUpdatedAt } : {}),\n ...(force ? { force: true } : {}),\n snapshotMeta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req)),\n });\n\n if (!updatedNote) {\n throw 'NOT FOUND';\n }\n\n return updatedNote;\n } catch (error) {\n if (isNoteVersionConflictError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n currentUpdatedAt: error.currentUpdatedAt,\n expectedUpdatedAt: error.expectedUpdatedAt,\n },\n });\n }\n\n if (isInvalidNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n if (isMissingNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n throw error;\n }\n },\n deleteNote: async (_, { id }: { id: string }) => {\n const trashedNote = await trashNoteById(Number(id));\n\n if (!trashedNote) {\n throw 'NOT FOUND';\n }\n\n return true;\n },\n restoreNoteSnapshot: async (\n _,\n { id }: { id: string },\n context: {\n req?: Request;\n },\n ) => {\n const note = await restoreNoteSnapshot(Number(id), {\n meta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req)),\n });\n\n if (!note) {\n throw 'NOT FOUND';\n }\n\n return note;\n },\n restoreTrashedNote: async (_, { id }: { id: string }) => {\n const note = await restoreTrashedNoteById(Number(id));\n\n if (!note) {\n throw 'NOT FOUND';\n }\n\n return note;\n },\n purgeTrashedNote: async (_, { id }: { id: string }) => {\n const purgedNote = await purgeTrashedNoteById(Number(id));\n\n if (!purgedNote) {\n throw 'NOT FOUND';\n }\n\n return true;\n },\n pinNote: (_, { id, pinned }: { id: string; pinned: boolean }) =>\n models.note.update({\n where: { id: Number(id) },\n data: { pinned: Boolean(pinned) },\n }),\n reorderNotes: async (_, { notes }: { notes: Array<{ id: string; order: number }> }) => {\n const updatePromises = notes.map(({ id, order }) =>\n models.note.update({\n where: { id: Number(id) },\n data: { order },\n }),\n );\n\n return Promise.all(updatePromises);\n },\n};\n"],"mappings":"AAEA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,wBAAwB;AACtD,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC,2BAA2B;AACrE,SAAS,sBAAsB,wBAAwB,qBAAqB;AAC5E,SAAS,kCAAkC;AAC3C;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,OAAO,YAAY;AAGnB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE3B,MAAM,sBAAsB,OAAO,YAAoB;AACnD,QAAM,eA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AACD,UAAM,OAAO,MAAM,oBAAoB,OAAO,EAAE,GAAG;AAAA,MAC/C,MAAM,gCAAgC,oBAAoB,QAAQ,GAAG,CAAC;AAAA,IAC1E,CAAC;AAED,QAAI,CAAC,MAAM;AACP,YAAM;AAAA,IACV;AAEA,WAAO;AAAA,EACX;AAAA,EACA,oBAAoB,OAAO,GAAG,EAAE,GAAG,MAAsB;AACrD,UAAM,OAAO,MAAM,uBAAuB,OAAO,EAAE,CAAC;AAEpD,QAAI,CAAC,MAAM;AACP,YAAM;AAAA,IACV;AAEA,WAAO;AAAA,EACX;AAAA,EACA,kBAAkB,OAAO,GAAG,EAAE,GAAG,MAAsB;AACnD,UAAM,aAAa,MAAM,qBAAqB,OAAO,EAAE,CAAC;AAExD,QAAI,CAAC,YAAY;AACb,YAAM;AAAA,IACV;AAEA,WAAO;AAAA,EACX;AAAA,EACA,SAAS,CAAC,GAAG,EAAE,IAAI,OAAO,MACtB,OAAO,KAAK,OAAO;AAAA,IACf,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;AAAA,IACxB,MAAM,EAAE,QAAQ,QAAQ,MAAM,EAAE;AAAA,EACpC,CAAC;AAAA,EACL,cAAc,OAAO,GAAG,EAAE,MAAM,MAAuD;AACnF,UAAM,iBAAiB,MAAM;AAAA,MAAI,CAAC,EAAE,IAAI,MAAM,MAC1C,OAAO,KAAK,OAAO;AAAA,QACf,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;AAAA,QACxB,MAAM,EAAE,MAAM;AAAA,MAClB,CAAC;AAAA,IACL;AAEA,WAAO,QAAQ,IAAI,cAAc;AAAA,EACrC;AACJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/features/note/graphql/note.mutation.resolver.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\nimport type { Request } from 'express';\nimport { GraphQLError } from 'graphql';\nimport { extractBlocksByType, parseNoteContent } from '~/features/note/services/content-blocks.js';\nimport {\n createNotePropertyDefinition,\n deleteNotePropertyDefinition,\n InvalidNotePropertyInputError,\n type NotePropertiesPatchInput,\n type NotePropertyDefinitionInput,\n type NotePropertyDefinitionUpdateInput,\n NotePropertyDeleteConfirmationRequiredError,\n updateNotePropertiesWithVersionGuard,\n updateNotePropertyDefinition,\n} from '~/features/note/services/properties.js';\nimport { buildNoteSearchProjection } from '~/features/note/services/search.js';\nimport { createSnapshotMetaFromUserAgent, restoreNoteSnapshot } from '~/features/note/services/snapshot.js';\nimport { purgeTrashedNoteById, restoreTrashedNoteById, trashNoteById } from '~/features/note/services/trash.js';\nimport { updateNoteWithVersionGuard } from '~/features/note/services/write.js';\nimport {\n isInvalidNoteVersionError,\n isMissingNoteVersionError,\n isNoteVersionConflictError,\n} from '~/features/note/services/write-conflict.js';\nimport models from '~/models.js';\nimport type { NoteInput } from '~/types/index.js';\n\nconst PLACEHOLDER_PREFIX = '{%';\nconst PLACEHOLDER_SUFFIX = '%}';\n\nconst replacePlaceholders = async (content: string) => {\n const placeholders = content.matchAll(new RegExp(`${PLACEHOLDER_PREFIX}([^}]+)${PLACEHOLDER_SUFFIX}`, 'g'));\n const resolvedPlaceholders = await models.placeholder.findMany({\n select: {\n template: true,\n replacement: true,\n },\n where: { template: { in: Array.from(new Set(Array.from(placeholders, (match) => match[1]))) } },\n });\n\n let replacedContent = content;\n\n for (const placeholder of resolvedPlaceholders) {\n replacedContent = replacedContent.replace(\n new RegExp(`${PLACEHOLDER_PREFIX}${placeholder.template}${PLACEHOLDER_SUFFIX}`, 'g'),\n placeholder.replacement,\n );\n }\n\n return replacedContent;\n};\n\nconst getRequestUserAgent = (req?: Request) => {\n const userAgentHeader = req?.headers['user-agent'];\n return Array.isArray(userAgentHeader) ? userAgentHeader[0] : userAgentHeader;\n};\n\nconst toTagConnections = (blocks: Array<{ props?: { id?: string | number } }>) => {\n return blocks\n .map((block) => block.props?.id)\n .filter((id) => id !== undefined && id !== null && String(id).trim() !== '')\n .map((id) => Number(id))\n .filter(Number.isFinite)\n .map((id) => ({ id }));\n};\n\nconst parseRequiredNoteContent = (content: string) => {\n const parsedContent = parseNoteContent(content);\n\n if (!parsedContent) {\n throw new GraphQLError('Note content must be valid BlockNote JSON.', {\n extensions: {\n code: 'INVALID_NOTE_CONTENT',\n },\n });\n }\n\n return parsedContent;\n};\n\ntype NoteMutationResolvers = NonNullable<IResolvers['Mutation']>;\ntype CreateNoteInput = Required<Pick<NoteInput, 'title' | 'content'>> & Pick<NoteInput, 'layout'>;\n\nexport const noteMutationResolvers: NoteMutationResolvers = {\n createNote: async (_, { note }: { note: CreateNoteInput }) => {\n const replacedTitle = await replacePlaceholders(note.title);\n const replacedContent = await replacePlaceholders(note.content);\n const parsedContent = replacedContent ? parseRequiredNoteContent(replacedContent) : null;\n const blocks = parsedContent ? extractBlocksByType<{ id: string }>('tag', parsedContent) : [];\n const createdNote = await models.note.create({\n data: {\n title: replacedTitle,\n content: replacedContent,\n ...buildNoteSearchProjection({\n title: replacedTitle,\n content: replacedContent,\n }),\n ...(note.layout && { layout: note.layout }),\n },\n });\n\n if (!replacedContent) {\n return createdNote;\n }\n\n return models.note.update({\n where: { id: createdNote.id },\n data: { tags: { set: toTagConnections(blocks) } },\n });\n },\n updateNote: async (\n _,\n {\n id,\n note,\n editSessionId,\n expectedUpdatedAt,\n force,\n }: {\n id: number;\n note: NoteInput;\n editSessionId?: string;\n expectedUpdatedAt?: string;\n force?: boolean;\n },\n context: {\n req?: Request;\n },\n ) => {\n const parsedContent = note.content ? parseRequiredNoteContent(note.content) : null;\n const blocks = parsedContent ? extractBlocksByType<{ id: string }>('tag', parsedContent) : [];\n try {\n const updatedNote = await updateNoteWithVersionGuard({\n id: Number(id),\n data: {\n ...(note.title !== undefined ? { title: note.title } : {}),\n ...(note.content !== undefined ? { content: note.content } : {}),\n ...(note.layout !== undefined ? { layout: note.layout } : {}),\n ...(note.content !== undefined ? { tagIds: toTagConnections(blocks).map((tag) => tag.id) } : {}),\n },\n ...(editSessionId ? { editSessionId } : {}),\n ...(expectedUpdatedAt ? { expectedUpdatedAt } : {}),\n ...(force ? { force: true } : {}),\n snapshotMeta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req)),\n });\n\n if (!updatedNote) {\n throw 'NOT FOUND';\n }\n\n return updatedNote;\n } catch (error) {\n if (isNoteVersionConflictError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n currentUpdatedAt: error.currentUpdatedAt,\n expectedUpdatedAt: error.expectedUpdatedAt,\n },\n });\n }\n\n if (isInvalidNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n if (isMissingNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n throw error;\n }\n },\n deleteNote: async (_, { id }: { id: string }) => {\n const trashedNote = await trashNoteById(Number(id));\n\n if (!trashedNote) {\n throw 'NOT FOUND';\n }\n\n return true;\n },\n restoreNoteSnapshot: async (\n _,\n { id }: { id: string },\n context: {\n req?: Request;\n },\n ) => {\n const note = await restoreNoteSnapshot(Number(id), {\n meta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req)),\n });\n\n if (!note) {\n throw 'NOT FOUND';\n }\n\n return note;\n },\n restoreTrashedNote: async (_, { id }: { id: string }) => {\n const note = await restoreTrashedNoteById(Number(id));\n\n if (!note) {\n throw 'NOT FOUND';\n }\n\n return note;\n },\n purgeTrashedNote: async (_, { id }: { id: string }) => {\n const purgedNote = await purgeTrashedNoteById(Number(id));\n\n if (!purgedNote) {\n throw 'NOT FOUND';\n }\n\n return true;\n },\n createNotePropertyKey: async (_, { input }: { input: NotePropertyDefinitionInput }) => {\n try {\n return await createNotePropertyDefinition(input);\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: 'INVALID_NOTE_PROPERTY_INPUT',\n },\n });\n }\n\n throw error;\n }\n },\n updateNotePropertyKey: async (_, { key, input }: { key: string; input: NotePropertyDefinitionUpdateInput }) => {\n try {\n const result = await updateNotePropertyDefinition({ key, input });\n\n if (!result) {\n throw 'NOT FOUND';\n }\n\n return result;\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: 'INVALID_NOTE_PROPERTY_INPUT',\n },\n });\n }\n\n throw error;\n }\n },\n deleteNotePropertyKey: async (_, { key, confirmImpact }: { key: string; confirmImpact?: boolean }) => {\n try {\n const result = await deleteNotePropertyDefinition({ key, confirmImpact });\n\n if (!result) {\n throw 'NOT FOUND';\n }\n\n return result;\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: 'INVALID_NOTE_PROPERTY_INPUT',\n },\n });\n }\n\n if (error instanceof NotePropertyDeleteConfirmationRequiredError) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n affectedNoteCount: error.affectedNoteCount,\n },\n });\n }\n\n throw error;\n }\n },\n updateNoteProperties: async (\n _,\n {\n id,\n patch,\n editSessionId,\n expectedUpdatedAt,\n force,\n }: {\n id: string;\n patch: NotePropertiesPatchInput;\n editSessionId?: string;\n expectedUpdatedAt?: string;\n force?: boolean;\n },\n ) => {\n try {\n const note = await updateNotePropertiesWithVersionGuard({\n id: Number(id),\n patch,\n ...(editSessionId ? { editSessionId } : {}),\n ...(expectedUpdatedAt ? { expectedUpdatedAt } : {}),\n ...(force ? { force: true } : {}),\n });\n\n if (!note) {\n throw 'NOT FOUND';\n }\n\n return note;\n } catch (error) {\n if (error instanceof InvalidNotePropertyInputError) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: 'INVALID_NOTE_PROPERTY_INPUT',\n },\n });\n }\n\n if (isNoteVersionConflictError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n currentUpdatedAt: error.currentUpdatedAt,\n expectedUpdatedAt: error.expectedUpdatedAt,\n },\n });\n }\n\n if (isInvalidNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n if (isMissingNoteVersionError(error)) {\n throw new GraphQLError(error.message, {\n extensions: {\n code: error.code,\n },\n });\n }\n\n throw error;\n }\n },\n pinNote: (_, { id, pinned }: { id: string; pinned: boolean }) =>\n models.note.update({\n where: { id: Number(id) },\n data: { pinned: Boolean(pinned) },\n }),\n reorderNotes: async (_, { notes }: { notes: Array<{ id: string; order: number }> }) => {\n const updatePromises = notes.map(({ id, order }) =>\n models.note.update({\n where: { id: Number(id) },\n data: { order },\n }),\n );\n\n return Promise.all(updatePromises);\n },\n};\n"],"mappings":"AAEA,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,wBAAwB;AACtD;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iCAAiC;AAC1C,SAAS,iCAAiC,2BAA2B;AACrE,SAAS,sBAAsB,wBAAwB,qBAAqB;AAC5E,SAAS,kCAAkC;AAC3C;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,OAAO,YAAY;AAGnB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAE3B,MAAM,sBAAsB,OAAO,YAAoB;AACnD,QAAM,eAAe,QAAQ,SAAS,IAAI,OAAO,GAAG,kBAAkB,UAAU,kBAAkB,IAAI,GAAG,CAAC;AAC1G,QAAM,uBAAuB,MAAM,OAAO,YAAY,SAAS;AAAA,IAC3D,QAAQ;AAAA,MACJ,UAAU;AAAA,MACV,aAAa;AAAA,IACjB;AAAA,IACA,OAAO,EAAE,UAAU,EAAE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,cAAc,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;AAAA,EAClG,CAAC;AAED,MAAI,kBAAkB;AAEtB,aAAW,eAAe,sBAAsB;AAC5C,sBAAkB,gBAAgB;AAAA,MAC9B,IAAI,OAAO,GAAG,kBA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AE,IAAI,OAAO,MACtB,OAAO,KAAK,OAAO;AAAA,IACf,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;AAAA,IACxB,MAAM,EAAE,QAAQ,QAAQ,MAAM,EAAE;AAAA,EACpC,CAAC;AAAA,EACL,cAAc,OAAO,GAAG,EAAE,MAAM,MAAuD;AACnF,UAAM,iBAAiB,MAAM;AAAA,MAAI,CAAC,EAAE,IAAI,MAAM,MAC1C,OAAO,KAAK,OAAO;AAAA,QACf,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE;AAAA,QACxB,MAAM,EAAE,MAAM;AAAA,MAClB,CAAC;AAAA,IACL;AAEA,WAAO,QAAQ,IAAI,cAAc;AAAA,EACrC;AACJ;","names":[]}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
normalizeReferenceId,
|
|
7
7
|
syncReferenceTitlesInContent
|
|
8
8
|
} from "../../../features/note/services/content-blocks.js";
|
|
9
|
+
import { listNotePropertyKeys } from "../../../features/note/services/properties.js";
|
|
9
10
|
import {
|
|
10
11
|
buildNoteSearchProjection,
|
|
11
12
|
filterNotesBySearchQuery,
|
|
@@ -358,6 +359,19 @@ const noteQueryResolvers = {
|
|
|
358
359
|
noteSnapshot: async (_, { id }) => {
|
|
359
360
|
return getNoteSnapshot(Number(id));
|
|
360
361
|
},
|
|
362
|
+
notePropertyKeys: async (_, {
|
|
363
|
+
query,
|
|
364
|
+
pagination = {
|
|
365
|
+
limit: 50,
|
|
366
|
+
offset: 0
|
|
367
|
+
}
|
|
368
|
+
}) => {
|
|
369
|
+
return listNotePropertyKeys({
|
|
370
|
+
query,
|
|
371
|
+
limit: Number(pagination.limit),
|
|
372
|
+
offset: Number(pagination.offset)
|
|
373
|
+
});
|
|
374
|
+
},
|
|
361
375
|
trashedNote: async (_, { id }) => {
|
|
362
376
|
return getTrashedNoteById(Number(id));
|
|
363
377
|
},
|