ocean-brain 0.4.2 → 0.6.0
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-DI0PhQTq.js → Calendar-BytW4PeT.js} +1 -1
- package/server/client/dist/assets/Callout-9sJgGNRb.js +1 -0
- package/server/client/dist/assets/Graph-o5u-NzrA.js +1 -0
- package/server/client/dist/assets/{Image-DlJ4MDo3.js → Image-DxWhlIDG.js} +1 -1
- package/server/client/dist/assets/{Image.es-COwqkQuh.js → Image.es-B0LL3pb7.js} +1 -1
- package/server/client/dist/assets/Note-CYoYzZNu.js +21 -0
- package/server/client/dist/assets/{Plus.es-KeV96R_e.js → Plus.es-DpxzgRtY.js} +1 -1
- package/server/client/dist/assets/Reminders-DAepTZg1.js +1 -0
- package/server/client/dist/assets/Search-6KH7An44.js +1 -0
- package/server/client/dist/assets/{SurfaceCard-CHjcCuqZ.js → SurfaceCard-EMs50xSF.js} +1 -1
- package/server/client/dist/assets/Tag-C89j8x56.js +1 -0
- package/server/client/dist/assets/TagNotes-BTbu-f6v.js +1 -0
- package/server/client/dist/assets/{Trash.es-BqRTZPrI.js → Trash.es-C5x35NKF.js} +1 -1
- package/server/client/dist/assets/ViewNotes-DPEuki3y.js +1 -0
- package/server/client/dist/assets/Views-BGkuNhVd.js +1 -0
- package/server/client/dist/assets/{image.api-CMdQbCyN.js → image.api-DRhRQ0Gf.js} +1 -1
- package/server/client/dist/assets/{index-D2gRB1ig.css → index-Cd81UxEh.css} +1 -1
- package/server/client/dist/assets/index-DYlYUrjH.js +327 -0
- package/server/client/dist/assets/index-DswSFFMb.js +1 -0
- package/server/client/dist/assets/manage-image-C6sHhWnI.js +1 -0
- package/server/client/dist/assets/manage-image-detail-CJkfybR9.js +1 -0
- package/server/client/dist/assets/{mcp-DqGLZv90.js → mcp-piouFDNm.js} +1 -1
- package/server/client/dist/assets/note-core-Z6kqulGB.js +180 -0
- package/server/client/dist/assets/note-vendor-i1M2FSI2.js +54 -0
- package/server/client/dist/assets/{placeholder-BXLtvdtN.js → placeholder-DGz3CHej.js} +4 -4
- package/server/client/dist/assets/properties-CM4khczg.js +1 -0
- package/server/client/dist/assets/trash-C2lItz-b.js +1 -0
- package/server/client/dist/assets/{useReminderMutate-v1EXqM90.js → useReminderMutate-DHjDDHKg.js} +1 -1
- package/server/client/dist/assets/view-dashboard-C17WsdL7.js +99 -0
- package/server/client/dist/index.html +4 -4
- package/server/dist/features/note/graphql/note.field.resolver.js +16 -1
- package/server/dist/features/note/graphql/note.field.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.mutation.resolver.js +192 -36
- package/server/dist/features/note/graphql/note.mutation.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.query.resolver.js +88 -76
- package/server/dist/features/note/graphql/note.query.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.resolver.js +3 -2
- package/server/dist/features/note/graphql/note.resolver.js.map +1 -1
- package/server/dist/features/note/graphql/note.type-defs.js +104 -1
- 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/cleanup.js +4 -3
- package/server/dist/features/note/services/cleanup.js.map +1 -1
- package/server/dist/features/note/services/content-blocks.js +113 -0
- package/server/dist/features/note/services/content-blocks.js.map +1 -0
- package/server/dist/features/note/services/markdown-intent-write.js +478 -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/search.js +10 -29
- package/server/dist/features/note/services/search.js.map +1 -1
- package/server/dist/features/note/services/snapshot.js +260 -18
- 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-conflict.js +87 -0
- package/server/dist/features/note/services/write-conflict.js.map +1 -0
- package/server/dist/features/note/services/write.js +121 -0
- package/server/dist/features/note/services/write.js.map +1 -0
- 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-tree.js +41 -0
- package/server/dist/modules/blocknote-tree.js.map +1 -0
- package/server/dist/modules/blocknote.js +47 -2
- package/server/dist/modules/blocknote.js.map +1 -1
- package/server/dist/modules/error-handler.js +7 -4
- package/server/dist/modules/error-handler.js.map +1 -1
- package/server/dist/modules/recovery-retention.js +2 -2
- package/server/dist/modules/recovery-retention.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/Callout-BAqbXI0L.js +0 -1
- package/server/client/dist/assets/Graph-Dhuog4tc.js +0 -1
- package/server/client/dist/assets/Note-ChUWU3Su.js +0 -21
- package/server/client/dist/assets/Reminders-D7MCTNxb.js +0 -1
- package/server/client/dist/assets/Search-B-fwTr5y.js +0 -1
- package/server/client/dist/assets/Tag-BbV2z-Db.js +0 -1
- package/server/client/dist/assets/TagNotes-2HKF09Jm.js +0 -1
- package/server/client/dist/assets/ViewNotes-TfM3Uzbp.js +0 -1
- package/server/client/dist/assets/Views-CUwtnfa8.js +0 -1
- package/server/client/dist/assets/index-B4l2UvuC.js +0 -232
- package/server/client/dist/assets/index-zhxZjg7V.js +0 -1
- package/server/client/dist/assets/manage-image-DdXb5Bkj.js +0 -1
- package/server/client/dist/assets/manage-image-detail-CrrXCQIX.js +0 -1
- package/server/client/dist/assets/note-core-GgFcksAF.js +0 -178
- package/server/client/dist/assets/note-vendor-B0t5F04o.js +0 -54
- package/server/client/dist/assets/trash-3eUAjFRh.js +0 -1
- package/server/client/dist/assets/view-dashboard-T6gmohr-.js +0 -90
- package/server/dist/features/note/graphql/note.graphql.shared.js +0 -23
- package/server/dist/features/note/graphql/note.graphql.shared.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./note-vendor-
|
|
1
|
+
import{j as e}from"./note-vendor-i1M2FSI2.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-DYlYUrjH.js";import{a}from"./graph-vendor-CUxe67Lr.js";import{S as D}from"./SurfaceCard-EMs50xSF.js";import{n as de}from"./Plus.es-DpxzgRtY.js";import"./note-core-Z6kqulGB.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
|
) {
|
|
@@ -12,7 +12,7 @@ __PLACEHOLDER_FIELDS__ }
|
|
|
12
12
|
}
|
|
13
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-i1M2FSI2.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-DYlYUrjH.js";import{a as p}from"./graph-vendor-CUxe67Lr.js";import"./note-core-Z6kqulGB.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-i1M2FSI2.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-DYlYUrjH.js";import{a as k}from"./graph-vendor-CUxe67Lr.js";import{S as C}from"./SurfaceCard-EMs50xSF.js";import"./note-core-Z6kqulGB.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-v1EXqM90.js → useReminderMutate-DHjDDHKg.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as y}from"./note-vendor-
|
|
1
|
+
import{j as y}from"./note-vendor-i1M2FSI2.js";import{h as u,a6 as f,q as n,w as R,X as $}from"./index-DYlYUrjH.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-DYlYUrjH.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-DYlYUrjH.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-Z6kqulGB.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/note-vendor-i1M2FSI2.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-Cd81UxEh.css">
|
|
14
14
|
</head>
|
|
15
15
|
|
|
16
16
|
<body>
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
+
import { listNoteProperties } from "../../../features/note/services/properties.js";
|
|
2
|
+
import { renderNoteSnapshotContentAsMarkdown } from "../../../features/note/services/snapshot.js";
|
|
1
3
|
import models from "../../../models.js";
|
|
2
4
|
const noteFieldResolvers = {
|
|
3
5
|
tags: async (note) => models.tag.findMany({ where: { notes: { some: { id: note.id } } } }),
|
|
6
|
+
properties: async (note) => listNoteProperties(note.id),
|
|
4
7
|
contentAsMarkdown: async (note) => {
|
|
5
8
|
const { blocksToMarkdown } = await import("../../../modules/blocknote.js");
|
|
6
9
|
return blocksToMarkdown(note.content);
|
|
7
10
|
}
|
|
8
11
|
};
|
|
12
|
+
const noteSnapshotFieldResolvers = {
|
|
13
|
+
contentAsMarkdown: async (snapshot) => {
|
|
14
|
+
if (typeof snapshot.contentAsMarkdown === "string") {
|
|
15
|
+
return snapshot.contentAsMarkdown;
|
|
16
|
+
}
|
|
17
|
+
if (typeof snapshot.payload === "string") {
|
|
18
|
+
return renderNoteSnapshotContentAsMarkdown(snapshot.payload);
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
9
23
|
export {
|
|
10
|
-
noteFieldResolvers
|
|
24
|
+
noteFieldResolvers,
|
|
25
|
+
noteSnapshotFieldResolvers
|
|
11
26
|
};
|
|
12
27
|
//# sourceMappingURL=note.field.resolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/features/note/graphql/note.field.resolver.ts"],"sourcesContent":["import type { IResolvers } from '@graphql-tools/utils';\nimport type { Note } from '~/models.js';\nimport models from '~/models.js';\n\ntype NoteFieldResolvers = NonNullable<IResolvers['Note']>;\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"],"mappings":"
|
|
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,12 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphQLError } from "graphql";
|
|
2
|
+
import { extractBlocksByType, parseNoteContent } from "../../../features/note/services/content-blocks.js";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
createNotePropertyDefinition,
|
|
5
|
+
deleteNotePropertyDefinition,
|
|
6
|
+
InvalidNotePropertyInputError,
|
|
7
|
+
NotePropertyDeleteConfirmationRequiredError,
|
|
8
|
+
updateNotePropertiesWithVersionGuard,
|
|
9
|
+
updateNotePropertyDefinition
|
|
10
|
+
} from "../../../features/note/services/properties.js";
|
|
11
|
+
import { buildNoteSearchProjection } from "../../../features/note/services/search.js";
|
|
12
|
+
import { createSnapshotMetaFromUserAgent, restoreNoteSnapshot } from "../../../features/note/services/snapshot.js";
|
|
7
13
|
import { purgeTrashedNoteById, restoreTrashedNoteById, trashNoteById } from "../../../features/note/services/trash.js";
|
|
14
|
+
import { updateNoteWithVersionGuard } from "../../../features/note/services/write.js";
|
|
15
|
+
import {
|
|
16
|
+
isInvalidNoteVersionError,
|
|
17
|
+
isMissingNoteVersionError,
|
|
18
|
+
isNoteVersionConflictError
|
|
19
|
+
} from "../../../features/note/services/write-conflict.js";
|
|
8
20
|
import models from "../../../models.js";
|
|
9
|
-
import { extractBlocksByType } from "./note.graphql.shared.js";
|
|
10
21
|
const PLACEHOLDER_PREFIX = "{%";
|
|
11
22
|
const PLACEHOLDER_SUFFIX = "%}";
|
|
12
23
|
const replacePlaceholders = async (content) => {
|
|
@@ -31,10 +42,26 @@ const getRequestUserAgent = (req) => {
|
|
|
31
42
|
const userAgentHeader = req?.headers["user-agent"];
|
|
32
43
|
return Array.isArray(userAgentHeader) ? userAgentHeader[0] : userAgentHeader;
|
|
33
44
|
};
|
|
45
|
+
const toTagConnections = (blocks) => {
|
|
46
|
+
return blocks.map((block) => block.props?.id).filter((id) => id !== void 0 && id !== null && String(id).trim() !== "").map((id) => Number(id)).filter(Number.isFinite).map((id) => ({ id }));
|
|
47
|
+
};
|
|
48
|
+
const parseRequiredNoteContent = (content) => {
|
|
49
|
+
const parsedContent = parseNoteContent(content);
|
|
50
|
+
if (!parsedContent) {
|
|
51
|
+
throw new GraphQLError("Note content must be valid BlockNote JSON.", {
|
|
52
|
+
extensions: {
|
|
53
|
+
code: "INVALID_NOTE_CONTENT"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return parsedContent;
|
|
58
|
+
};
|
|
34
59
|
const noteMutationResolvers = {
|
|
35
60
|
createNote: async (_, { note }) => {
|
|
36
61
|
const replacedTitle = await replacePlaceholders(note.title);
|
|
37
62
|
const replacedContent = await replacePlaceholders(note.content);
|
|
63
|
+
const parsedContent = replacedContent ? parseRequiredNoteContent(replacedContent) : null;
|
|
64
|
+
const blocks = parsedContent ? extractBlocksByType("tag", parsedContent) : [];
|
|
38
65
|
const createdNote = await models.note.create({
|
|
39
66
|
data: {
|
|
40
67
|
title: replacedTitle,
|
|
@@ -49,46 +76,64 @@ const noteMutationResolvers = {
|
|
|
49
76
|
if (!replacedContent) {
|
|
50
77
|
return createdNote;
|
|
51
78
|
}
|
|
52
|
-
const blocks = extractBlocksByType("tag", JSON.parse(replacedContent));
|
|
53
79
|
return models.note.update({
|
|
54
80
|
where: { id: createdNote.id },
|
|
55
|
-
data: { tags: { set: blocks
|
|
81
|
+
data: { tags: { set: toTagConnections(blocks) } }
|
|
56
82
|
});
|
|
57
83
|
},
|
|
58
84
|
updateNote: async (_, {
|
|
59
85
|
id,
|
|
60
86
|
note,
|
|
61
|
-
editSessionId
|
|
87
|
+
editSessionId,
|
|
88
|
+
expectedUpdatedAt,
|
|
89
|
+
force
|
|
62
90
|
}, context) => {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
const parsedContent = note.content ? parseRequiredNoteContent(note.content) : null;
|
|
92
|
+
const blocks = parsedContent ? extractBlocksByType("tag", parsedContent) : [];
|
|
93
|
+
try {
|
|
94
|
+
const updatedNote = await updateNoteWithVersionGuard({
|
|
95
|
+
id: Number(id),
|
|
96
|
+
data: {
|
|
97
|
+
...note.title !== void 0 ? { title: note.title } : {},
|
|
98
|
+
...note.content !== void 0 ? { content: note.content } : {},
|
|
99
|
+
...note.layout !== void 0 ? { layout: note.layout } : {},
|
|
100
|
+
...note.content !== void 0 ? { tagIds: toTagConnections(blocks).map((tag) => tag.id) } : {}
|
|
101
|
+
},
|
|
102
|
+
...editSessionId ? { editSessionId } : {},
|
|
103
|
+
...expectedUpdatedAt ? { expectedUpdatedAt } : {},
|
|
104
|
+
...force ? { force: true } : {},
|
|
105
|
+
snapshotMeta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req))
|
|
106
|
+
});
|
|
107
|
+
if (!updatedNote) {
|
|
108
|
+
throw "NOT FOUND";
|
|
68
109
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const nextTitle = note.title ?? existingNote.title;
|
|
80
|
-
const nextContent = note.content ?? existingNote.content;
|
|
81
|
-
return models.note.update({
|
|
82
|
-
where: { id: Number(id) },
|
|
83
|
-
data: {
|
|
84
|
-
...note,
|
|
85
|
-
...buildNoteSearchProjection({
|
|
86
|
-
title: nextTitle,
|
|
87
|
-
content: nextContent
|
|
88
|
-
}),
|
|
89
|
-
...note.content ? { tags: { set: blocks.map((block) => ({ id: Number(block.props.id) })) } } : {}
|
|
110
|
+
return updatedNote;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (isNoteVersionConflictError(error)) {
|
|
113
|
+
throw new GraphQLError(error.message, {
|
|
114
|
+
extensions: {
|
|
115
|
+
code: error.code,
|
|
116
|
+
currentUpdatedAt: error.currentUpdatedAt,
|
|
117
|
+
expectedUpdatedAt: error.expectedUpdatedAt
|
|
118
|
+
}
|
|
119
|
+
});
|
|
90
120
|
}
|
|
91
|
-
|
|
121
|
+
if (isInvalidNoteVersionError(error)) {
|
|
122
|
+
throw new GraphQLError(error.message, {
|
|
123
|
+
extensions: {
|
|
124
|
+
code: error.code
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (isMissingNoteVersionError(error)) {
|
|
129
|
+
throw new GraphQLError(error.message, {
|
|
130
|
+
extensions: {
|
|
131
|
+
code: error.code
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
92
137
|
},
|
|
93
138
|
deleteNote: async (_, { id }) => {
|
|
94
139
|
const trashedNote = await trashNoteById(Number(id));
|
|
@@ -120,6 +165,117 @@ const noteMutationResolvers = {
|
|
|
120
165
|
}
|
|
121
166
|
return true;
|
|
122
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
|
+
},
|
|
123
279
|
pinNote: (_, { id, pinned }) => models.note.update({
|
|
124
280
|
where: { id: Number(id) },
|
|
125
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 { buildNoteSearchProjection } from '~/features/note/services/search.js';\nimport {\n captureNoteBaseline,\n createSnapshotMetaFromUserAgent,\n restoreNoteSnapshot,\n} from '~/features/note/services/snapshot.js';\nimport { purgeTrashedNoteById, restoreTrashedNoteById, trashNoteById } from '~/features/note/services/trash.js';\nimport models from '~/models.js';\nimport type { NoteInput } from '~/types/index.js';\nimport { extractBlocksByType } from './note.graphql.shared.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\ntype NoteMutationResolvers = NonNullable<IResolvers['Mutation']>;\n\nexport const noteMutationResolvers: NoteMutationResolvers = {\n createNote: async (_, { note }: { note: NoteInput }) => {\n const replacedTitle = await replacePlaceholders(note.title);\n const replacedContent = await replacePlaceholders(note.content);\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 const blocks = extractBlocksByType<{ id: string }>('tag', JSON.parse(replacedContent));\n\n return models.note.update({\n where: { id: createdNote.id },\n data: { tags: { set: blocks.map((block) => ({ id: Number(block.props.id) })) } },\n });\n },\n updateNote: async (\n _,\n {\n id,\n note,\n editSessionId,\n }: {\n id: number;\n note: NoteInput;\n editSessionId?: string;\n },\n context: {\n req?: Request;\n },\n ) => {\n const existingNote = await models.note.findUnique({\n where: { id: Number(id) },\n select: {\n title: true,\n content: true,\n },\n });\n\n if (!existingNote) {\n throw 'NOT FOUND';\n }\n\n const blocks = note.content ? extractBlocksByType<{ id: string }>('tag', JSON.parse(note.content)) : [];\n\n await captureNoteBaseline({\n noteId: Number(id),\n ...(editSessionId ? { editSessionId } : {}),\n meta: createSnapshotMetaFromUserAgent(getRequestUserAgent(context.req)),\n });\n\n const nextTitle = note.title ?? existingNote.title;\n const nextContent = note.content ?? existingNote.content;\n\n return models.note.update({\n where: { id: Number(id) },\n data: {\n ...note,\n ...buildNoteSearchProjection({\n title: nextTitle,\n content: nextContent,\n }),\n ...(note.content ? { tags: { set: blocks.map((block) => ({ id: Number(block.props.id) })) } } : {}),\n },\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,iCAAiC;AAC1C;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,sBAAsB,wBAAwB,qBAAqB;AAC5E,OAAO,YAAY;AAEnB,SAAS,2BAA2B;AAEpC,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,kBAAkB,GAAG,YAAY,QAAQ,G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AAM,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,kBAAkB,GAAG,YAAY,QAAQ,GAAG,kBAAkB,IAAI,GAAG;AAAA,MACnF,YAAY;AAAA,IAChB;AAAA,EACJ;AAEA,SAAO;AACX;AAEA,MAAM,sBAAsB,CAAC,QAAkB;AAC3C,QAAM,kBAAkB,KAAK,QAAQ,YAAY;AACjD,SAAO,MAAM,QAAQ,eAAe,IAAI,gBAAgB,CAAC,IAAI;AACjE;A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