ocean-brain 0.13.0 → 0.13.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/README.md +5 -3
- package/dist/index.js +12 -4
- package/package.json +10 -8
- package/server/client/dist/assets/{Calendar-CaeK7gTz.js → Calendar-DExFS7xq.js} +1 -1
- package/server/client/dist/assets/{Search-DAYHxAml.js → Search-B_BRjOyG.js} +1 -1
- package/server/client/dist/assets/{Tag-CG8b0l1j.js → Tag-2hcR9dd4.js} +1 -1
- package/server/client/dist/assets/{TagNotes-COyaVsdn.js → TagNotes-BE20Ji5s.js} +1 -1
- package/server/client/dist/assets/{Views-BPxlw3vk.js → Views-CQXgnbUQ.js} +1 -1
- package/server/client/dist/assets/{app-BezcjTfd.js → app-4M3jUhmd.js} +2 -2
- package/server/client/dist/assets/{index-CzZFedXj.js → index-CaT-yZJw.js} +1 -1
- package/server/client/dist/assets/{manage-image-detail-9hRTiAsR.js → manage-image-detail-Bu9yymBn.js} +1 -1
- package/server/client/dist/assets/mcp-D8footel.js +5 -0
- package/server/client/dist/assets/{placeholder-CZoqs4S3.js → placeholder-BZ-p6ahW.js} +1 -1
- package/server/client/dist/index.html +1 -1
- package/server/dist/app.js +91 -8
- package/server/dist/features/auth/http/api.js +9 -8
- package/server/dist/features/auth/http/pages.js +27 -28
- package/server/dist/features/auth/service.js +7 -27
- package/server/dist/features/cache/graphql/cache.type-defs.js +1 -1
- package/server/dist/features/image/http/upload.js +2 -2
- package/server/dist/features/mcp-admin/http/handlers.js +9 -9
- package/server/dist/features/note/http/mcp.js +17 -17
- package/server/dist/features/search/http/handlers.js +10 -10
- package/server/dist/features/search/search-manager.js +34 -6
- package/server/dist/features/tag/http/mcp.js +2 -2
- package/server/dist/modules/auth-guard.js +36 -53
- package/server/dist/modules/blocknote.js +16 -9
- package/server/dist/modules/error-handler.js +17 -20
- package/server/dist/modules/mcp-auth.js +50 -56
- package/server/dist/modules/rate-limit.js +23 -23
- package/server/dist/modules/server-events-handler.js +15 -13
- package/server/dist/modules/session-store.js +6 -8
- package/server/dist/paths.js +2 -1
- package/server/dist/routes/api.js +105 -71
- package/server/dist/routes/auth-pages.js +21 -11
- package/server/dist/routes/client.js +60 -72
- package/server/dist/routes/graphql.js +31 -26
- package/server/dist/routes/mcp.js +25 -35
- package/server/dist/server.js +14 -16
- package/server/client/dist/assets/mcp-ugdCKa6H.js +0 -4
- package/server/dist/modules/logger.js +0 -53
- package/server/dist/modules/use-async.js +0 -10
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
npm package README for the public ocean-brain CLI.
|
|
3
3
|
|
|
4
4
|
Keep the product overview in the repository README. This file owns the public
|
|
5
|
-
`serve` and `mcp` command
|
|
5
|
+
`serve` and `mcp` command interfaces, including npx auth and storage behavior.
|
|
6
6
|
-->
|
|
7
7
|
|
|
8
8
|
# ocean-brain CLI
|
|
@@ -69,7 +69,7 @@ For a long-lived installation, replace `ocean-brain` in the commands with an exa
|
|
|
69
69
|
|
|
70
70
|
## `mcp`
|
|
71
71
|
|
|
72
|
-
The `mcp` command starts
|
|
72
|
+
The `mcp` command starts the built-in stdio MCP adapter that forwards tool calls to an existing Ocean Brain instance. It does not start the web app.
|
|
73
73
|
|
|
74
74
|
The MCP tools can search and read notes, query tags and properties, create notes, make targeted Markdown or metadata edits, and move notes to Trash.
|
|
75
75
|
|
|
@@ -87,7 +87,7 @@ First enable MCP access under `Settings > MCP`, issue a token, and save it to a
|
|
|
87
87
|
"--server",
|
|
88
88
|
"http://localhost:6683",
|
|
89
89
|
"--token-file",
|
|
90
|
-
"/absolute/path/to/ocean-brain
|
|
90
|
+
"/absolute/path/to/ocean-brain/mcp-token"
|
|
91
91
|
]
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -104,6 +104,8 @@ Set `--server` to the Ocean Brain URL reachable from the machine running the MCP
|
|
|
104
104
|
| `--token-file <path>` | Read the bearer token from a file; takes precedence over `--token` |
|
|
105
105
|
| `--token <token>` | Direct bearer-token fallback |
|
|
106
106
|
|
|
107
|
+
The built-in adapter expands token-file paths that begin with `~`, `$HOME`, `${HOME}`, `%USERPROFILE%`, or `%HOME%`. This keeps copied JSON configurations portable even when the MCP client does not run arguments through a shell. `Settings > MCP` can generate either macOS/Linux shell commands or Windows PowerShell commands.
|
|
108
|
+
|
|
107
109
|
Prefer `--token-file` so the token is not stored directly in client configuration. Ocean Brain keeps one active MCP token; rotating or revoking it immediately invalidates the previous token. For a long-lived MCP setup, pin an npm package version compatible with the requirement shown in `Settings > MCP`.
|
|
108
110
|
|
|
109
111
|
## Links
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import fs2 from "fs";
|
|
5
|
-
import
|
|
5
|
+
import os2 from "os";
|
|
6
6
|
import path from "path";
|
|
7
7
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
8
8
|
import { Command } from "commander";
|
|
@@ -43,9 +43,17 @@ var resolveServeAuthEnvironment = (options, env) => {
|
|
|
43
43
|
|
|
44
44
|
// src/mcp-auth.ts
|
|
45
45
|
import fs from "fs";
|
|
46
|
-
|
|
46
|
+
import os from "os";
|
|
47
|
+
var expandMcpTokenFilePath = (tokenFilePath, homeDirectory = os.homedir()) => {
|
|
48
|
+
return tokenFilePath.replace(
|
|
49
|
+
/^(?:~|\$HOME|\$\{HOME\}|%USERPROFILE%|%HOME%)(?=$|[\\/])/i,
|
|
50
|
+
homeDirectory
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
var resolveMcpBearerToken = (options, homeDirectory = os.homedir()) => {
|
|
47
54
|
if (options.tokenFile) {
|
|
48
|
-
const
|
|
55
|
+
const tokenFilePath = expandMcpTokenFilePath(options.tokenFile, homeDirectory);
|
|
56
|
+
const token = fs.readFileSync(tokenFilePath, "utf-8").trim();
|
|
49
57
|
return token || void 0;
|
|
50
58
|
}
|
|
51
59
|
return options.token?.trim() || void 0;
|
|
@@ -61,7 +69,7 @@ var program = new Command();
|
|
|
61
69
|
program.name("ocean-brain").description("Self-hosted, open-source note-taking app with bi-directional links").version(pkg.version);
|
|
62
70
|
program.command("serve", { isDefault: true }).description("Start the Ocean Brain server").option("-p, --port <port>", "port to listen on", "6683").option("-H, --host <host>", "host to bind to", "0.0.0.0").option("--allow-insecure-no-auth", "explicitly disable auth protection for local or trusted environments").action(async (opts) => {
|
|
63
71
|
try {
|
|
64
|
-
const defaultRoot = path.resolve(
|
|
72
|
+
const defaultRoot = path.resolve(os2.homedir(), ".ocean-brain");
|
|
65
73
|
const dataDir = process.env.OCEAN_BRAIN_DATA_DIR || path.resolve(defaultRoot, "data");
|
|
66
74
|
const imageDir = process.env.OCEAN_BRAIN_IMAGE_DIR || path.resolve(defaultRoot, "assets/images");
|
|
67
75
|
const dbPath = path.resolve(dataDir, "db.sqlite3");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ocean-brain",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,22 +28,24 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@baejino/auth": "0.1.1",
|
|
30
30
|
"@blocknote/core": "^0.49.0",
|
|
31
|
+
"@fastify/cookie": "^11.1.2",
|
|
32
|
+
"@fastify/csrf-protection": "^8.0.1",
|
|
33
|
+
"@fastify/formbody": "^9.0.0",
|
|
34
|
+
"@fastify/rate-limit": "^11.2.0",
|
|
35
|
+
"@fastify/session": "^11.1.2",
|
|
36
|
+
"@fastify/static": "^10.1.3",
|
|
31
37
|
"@graphql-tools/schema": "^10.0.38",
|
|
32
38
|
"@graphql-tools/utils": "^11.2.2",
|
|
33
39
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
34
40
|
"@prisma/client": "^6.19.3",
|
|
35
41
|
"commander": "^14.0.3",
|
|
36
42
|
"diff": "^9.0.0",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"express-session": "^1.19.0",
|
|
40
|
-
"express-winston": "^4.2.0",
|
|
41
|
-
"graphql-http": "^1.22.4",
|
|
43
|
+
"fastify": "^5.12.1",
|
|
44
|
+
"graphql": "^16.12.0",
|
|
42
45
|
"jsdom": "^25.0.1",
|
|
43
|
-
"
|
|
46
|
+
"mercurius": "^16.10.0",
|
|
44
47
|
"prisma": "^6.19.3",
|
|
45
48
|
"sqlite-vec": "0.1.9",
|
|
46
|
-
"winston": "^3.19.0",
|
|
47
49
|
"zod": "^3.25.76"
|
|
48
50
|
},
|
|
49
51
|
"oceanBrain": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as j}from"./floating-ui.react-dom-BWTnA00G.js";import{T as p,x as H,y as E,M as C,q as S,g as Y,P as Q,h as V}from"./time-PxWila4-.js";import{d as b,s as F,a as $}from"./useNoteMutate-BjvZUmtX.js";import{C as U}from"./url-DKUMNVCI.js";import{C as z,a as P,b as B,c as J,g as G,s as W,d as X}from"./calendar-data-wB0ifXdo.js";import{d as K}from"./app-
|
|
1
|
+
import{j as e,r as j}from"./floating-ui.react-dom-BWTnA00G.js";import{T as p,x as H,y as E,M as C,q as S,g as Y,P as Q,h as V}from"./time-PxWila4-.js";import{d as b,s as F,a as $}from"./useNoteMutate-BjvZUmtX.js";import{C as U}from"./url-DKUMNVCI.js";import{C as z,a as P,b as B,c as J,g as G,s as W,d as X}from"./calendar-data-wB0ifXdo.js";import{d as K}from"./app-4M3jUhmd.js";import{s as Z}from"./FileText.es-DPIwDCEe.js";import{C as ee}from"./Callout-CcYyvHQP.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-hVj6vAYJ.js";import"./Info.es-CYxg-Vku.js";const D=2,te=({year:t,month:a,day:n,isCurrentMonth:r,isSunday:l,isToday:m,isSelected:d,isPast:c,notes:h,reminders:g,onSelect:s})=>{const f=h.slice(0,D).map(y=>({key:`note-${y.id}`,type:"note",title:y.title})),N=g.slice(0,D).map(y=>({key:`reminder-${y.id}`,type:"reminder",title:y.content||y.note?.title||"No title",isCompleted:y.completed})),M=(c?[...f,...N]:[...N,...f]).slice(0,D),R=()=>r?d?"bg-elevated shadow-[inset_0_0_0_1px_var(--border-secondary)] hover:bg-surface":"bg-surface hover:bg-muted":"cursor-default bg-[var(--page-bg)] text-fg-disabled",k=()=>m?"bg-cta font-semibold text-fg-on-filled":r?l?"font-semibold text-fg-weekend":"font-semibold text-fg-secondary":"font-medium text-fg-tertiary";return e.jsx(z,{day:n,dateLabel:b(new Date(t,a-1,n)).format("dddd, MMMM D, YYYY"),cellClassName:R(),dayNumberClassName:k(),isCurrentMonth:r,isToday:m,isSelected:d,noteCount:h.length,reminderCount:g.length,previewItems:M,overflowCount:Math.max(0,h.length+g.length-D),onSelect:s})},ae=te,ne=({note:t,type:a})=>e.jsx(P,{params:{id:t.id},header:e.jsx(Z,{size:12}),title:t.title,meta:b(Number(a==="create"?t.createdAt:t.updatedAt)).format("HH:mm")}),se=({reminder:t})=>e.jsx(P,{params:{id:String(t.note?.id??t.noteId)},header:e.jsx(F,{size:12}),title:t.content||t.note?.title||"No title",titleClassName:t.completed?"line-through":"",meta:b(Number(t.reminderDate)).format("HH:mm")}),re=(t,a)=>t.map(n=>n.type==="note"?e.jsx(ne,{note:n.item,type:a},`note-${n.item.id}`):e.jsx(se,{reminder:n.item},`reminder-${n.item.id}`)),I=(t,a)=>`${t} ${t===1?a:`${a}s`}`,oe="mt-3 flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto overscroll-y-contain pr-2 [scrollbar-color:var(--border-secondary)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-border-secondary [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar]:w-1.5",L=t=>b(new Date(t.year,t.month-1,t.day)).format("dddd, MMMM D"),T=({day:t,type:a,isLoading:n,presentation:r="rail"})=>{const l=j.useMemo(()=>{if(!t)return[];const h=t.notes.map(s=>({type:"note",item:s})),g=t.reminders.map(s=>({type:"reminder",item:s}));return t.isPast?[...h,...g]:[...g,...h]},[t]);if(!t)return e.jsx("section",{"aria-label":"Day details",className:"flex h-full min-h-40 items-center justify-center text-center",children:e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",children:"Select a day to see its activity."})});const m=L(t),d=n?"Loading activity...":[I(t.notes.length,"note"),I(t.reminders.length,"reminder")].join(" · "),c=n?null:e.jsx("div",{className:r==="rail"?oe:"flex flex-col gap-1",children:l.length>0?re(l,a):e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"py-8 text-center",children:"No activity on this day."})});return r==="modal"?e.jsxs("div",{"aria-label":`${m} activity`,children:[e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mb-3",children:d}),c]}):e.jsxs("section",{"aria-label":`${m} details`,className:"flex h-full min-h-0 flex-col",children:[e.jsxs("div",{className:"flex shrink-0 items-start gap-2 border-b border-border-subtle/80 pb-3",children:[e.jsx(K,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-fg-tertiary",size:15}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(p,{as:"h2",variant:"subheading",weight:"semibold",tracking:"tight",children:m}),e.jsx(p,{as:"p",variant:"label",weight:"medium",tone:"secondary",className:"mt-0.5",children:d})]})]}),c]})},ie=["January","February","March","April","May","June","July","August","September","October","November","December"],le=({month:t,year:a,type:n,onPrevMonth:r,onNextMonth:l,onToday:m,onTypeChange:d})=>e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-x-2.5 gap-y-1",children:[e.jsx(p,{as:"h1",variant:"display",weight:"bold",tracking:"tighter",className:"text-2xl leading-none sm:text-[2.15rem]",children:ie[t-1]}),e.jsx(p,{as:"span",variant:"subheading",weight:"medium",tone:"secondary",tracking:"tight",className:"pb-0.5",children:a})]}),e.jsx(p,{as:"p",variant:"meta",weight:"medium",tone:"secondary",className:"hidden sm:block",children:"Track note activity and reminders across the month"})]}),e.jsx("div",{className:"flex lg:justify-end",children:e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:inline-flex sm:w-auto sm:flex-row sm:items-center sm:gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(p,{id:"calendar-note-date-label",as:"span",variant:"label",weight:"medium",tone:"secondary",children:"Note date"}),e.jsxs(H,{value:n,"aria-labelledby":"calendar-note-date-label",onValueChange:h=>d(h),variant:"ghost",size:"sm",children:[e.jsx(E,{value:"create",children:"Created"}),e.jsx(E,{value:"update",children:"Updated"})]})]}),e.jsx("div",{className:"hidden h-5 w-px bg-divider sm:block"}),e.jsx(B,{onPrevMonth:r,onNextMonth:l,onToday:m})]})})]}),_="(min-width: 1280px)",de=({days:t,type:a,isLoading:n,selectedDayKey:r,onSelectedDayChange:l})=>{const[m,d]=j.useState(!1),c=j.useMemo(()=>t.find(s=>s.key===r),[t,r]);j.useEffect(()=>{const s=window.matchMedia(_),f=N=>{N.matches&&d(!1)};return s.addEventListener("change",f),()=>s.removeEventListener("change",f)},[]);const h=s=>{l(s),window.matchMedia(_).matches||d(!0)},g=c?L(c):"Day details";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"min-w-0 xl:grid xl:grid-cols-[minmax(0,1fr)_20rem] 2xl:grid-cols-[minmax(0,1fr)_22rem]",children:[e.jsx(J,{isLoading:n,className:"xl:pr-5",children:t.map(s=>e.jsx(ae,{year:s.year,month:s.month,day:s.day,isCurrentMonth:s.isCurrentMonth,isSunday:s.isSunday,isToday:s.isToday,isSelected:s.key===r,isPast:s.isPast,notes:s.notes,reminders:s.reminders,onSelect:()=>h(s.key)},s.key))}),e.jsx("aside",{className:"relative hidden min-h-0 border-l border-border-subtle xl:block","aria-label":"Selected day",children:e.jsx("div",{className:"absolute inset-y-0 right-0 left-5",children:e.jsx(T,{day:c,type:a,isLoading:n})})})]}),e.jsxs(C,{isOpen:m&&!!c,onClose:()=>d(!1),variant:"inspect",className:"xl:hidden",children:[e.jsx(C.Header,{title:g,onClose:()=>d(!1)}),e.jsxs(C.Body,{children:[e.jsxs(C.Description,{className:"sr-only",children:["View notes and reminders for ",g,"."]}),e.jsx(T,{day:c,type:a,isLoading:n,presentation:"modal"})]})]})]})},ce=`
|
|
2
2
|
query NotesInDateRange($dateRange: DateRangeInput) {
|
|
3
3
|
notesInDateRange(dateRange: $dateRange) {
|
|
4
4
|
id
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{a as L,m as Q}from"./useNoteMutate-BjvZUmtX.js";import{g as q,x as G,y as V,c as X,F as J,B as Y,T as m,q as k,P as W,E as A,Q as Z,D as C,k as ee,h as te,l as w,i as re,s as se,O as ae}from"./time-PxWila4-.js";import{A as ne}from"./AuxiliaryPanelHeader-HAttwVby.js";import{N as P,f as ie,g as oe,T as le}from"./url-DKUMNVCI.js";import{f as ce}from"./Graph-hVj6vAYJ.js";import{s as de}from"./ArrowRight.es-BlNsZQFs.js";import{V as R}from"./ViewChip-BVkZAXyx.js";import"./app-
|
|
1
|
+
import{j as e,r as g}from"./floating-ui.react-dom-BWTnA00G.js";import{a as L,m as Q}from"./useNoteMutate-BjvZUmtX.js";import{g as q,x as G,y as V,c as X,F as J,B as Y,T as m,q as k,P as W,E as A,Q as Z,D as C,k as ee,h as te,l as w,i as re,s as se,O as ae}from"./time-PxWila4-.js";import{A as ne}from"./AuxiliaryPanelHeader-HAttwVby.js";import{N as P,f as ie,g as oe,T as le}from"./url-DKUMNVCI.js";import{f as ce}from"./Graph-hVj6vAYJ.js";import{s as de}from"./ArrowRight.es-BlNsZQFs.js";import{V as R}from"./ViewChip-BVkZAXyx.js";import"./app-4M3jUhmd.js";import{f as me}from"./search-admin-adapter-Daf7e2YQ.js";import{p as he}from"./LinkSimple.es-B-P-7Iem.js";import{s as ue}from"./File.es-CHtXXafR.js";import"./preload-helper-BXl3LOEh.js";const xe=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),O=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=xe(r),n=new RegExp(`(${a})`,"gi"),o=new RegExp(`^${a}$`,"i"),i=t.split(n);return e.jsx("span",{children:i.map((c,d)=>o.test(c)?e.jsx("mark",{children:c},d):e.jsx(g.Fragment,{children:c},d))})},pe={hybrid:"HYBRID",lexical:"LEXICAL",semantic:"SEMANTIC"};function fe({query:t,limit:s=25,offset:r=0,mode:a="hybrid"}){return q(`query FetchSearchNotes($query: String!, $pagination: PaginationInput!, $mode: SearchMode!) {
|
|
2
2
|
searchNotes(query: $query, pagination: $pagination, mode: $mode) {
|
|
3
3
|
totalCount
|
|
4
4
|
semanticAvailable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as T,q as S,P as k,T as f,F as P,x as j,y as g,Q as E,D as R,k as q,E as C,l as x,h as I}from"./time-PxWila4-.js";import{s as A,T as O,a as L,i as F,b as Q,F as v}from"./app-
|
|
1
|
+
import{r as c,j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as T,q as S,P as k,T as f,F as P,x as j,y as g,Q as E,D as R,k as q,E as C,l as x,h as I}from"./time-PxWila4-.js";import{s as A,T as O,a as L,i as F,b as Q,F as v}from"./app-4M3jUhmd.js";import{T as _,e as D}from"./url-DKUMNVCI.js";import{f as M}from"./tag.api-DEUROVKQ.js";import{f as B}from"./Graph-hVj6vAYJ.js";import"./useNoteMutate-BjvZUmtX.js";import"./preload-helper-BXl3LOEh.js";const z=s=>{const{data:d}=T({queryKey:S.tags.list(s.searchParams),async queryFn(){const t=await M({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit,sortBy:s.searchParams.sortBy,sortOrder:s.searchParams.sortOrder});if(t.type==="error")throw t;return t.allTags}});return s.render(d)},G=s=>{const[d,t]=c.useState(!1),r=c.useRef(null),n=c.useRef(!0),u=c.useRef(0),o=c.useCallback(()=>{r.current!==null&&(clearTimeout(r.current),r.current=null)},[]);c.useEffect(()=>(n.current=!0,()=>{n.current=!1,o()}),[o]);const m=c.useCallback(p=>{u.current+=1;const i=u.current;o(),n.current&&t(!0),r.current=setTimeout(()=>{r.current=null,Promise.resolve().then(p).catch(()=>{}).finally(()=>{n.current&&u.current===i&&t(!1)})},s)},[o,s]);return[d,m]},b=I(D);function X(){const s=b.useNavigate(),{page:d,query:t,limit:r,sortBy:n,sortOrder:u}=b.useSearch(),[o,m]=c.useState(t),[,p]=G(350),i=t.trim();c.useEffect(()=>{m(t)},[t]),c.useEffect(()=>{const a=o.trim();a!==i&&p(()=>{s({search:l=>({...l,page:1,query:a})})})},[o,s,i,p]);const y=a=>{s({search:l=>({...l,...a})})},w=()=>{m(""),y({page:1,query:""})};return e.jsxs(k,{title:"Tags",description:"Find tags you added with @ across your notes",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"surface-base flex min-w-0 items-center gap-2 rounded-[16px] px-3.5 py-2.5 lg:w-72",children:[e.jsx(B,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Search"}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsx("input",{"aria-label":"Search tags",placeholder:"Search tags",value:o,onChange:a=>m(a.target.value),className:"h-8 min-w-0 flex-1 bg-transparent text-sm font-medium text-fg-default outline-none placeholder:text-xs placeholder:font-medium placeholder:text-fg-placeholder"}),(o||i)&&e.jsx("button",{type:"button","aria-label":"Clear tag search",className:"focus-ring-soft flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",onClick:w,children:e.jsx(P,{className:"h-3.5 w-3.5",weight:"bold"})})]}),e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Items"}),e.jsx(j,{value:String(r),onValueChange:a=>{const l=Number(a);F(l)&&y({limit:l,page:1})},variant:"ghost",size:"sm",children:O.map(a=>e.jsx(g,{value:String(a),children:a===L?`Default (${a})`:a},a))})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Sort"}),e.jsxs(j,{value:n,onValueChange:a=>y({sortBy:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"referenceCount",children:"Usage"}),e.jsx(g,{value:"name",children:"Name"})]}),e.jsxs(j,{value:u,onValueChange:a=>y({sortOrder:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(g,{value:"desc",children:n==="name"?"Z to A":"Most used"}),e.jsx(g,{value:"asc",children:n==="name"?"A to Z":"Least used"})]})]})]})]}),e.jsx(E,{fallback:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(x,{width:"90px",height:"36px"}),e.jsx(x,{width:"120px",height:"36px"}),e.jsx(x,{width:"80px",height:"36px"}),e.jsx(x,{width:"100px",height:"36px"}),e.jsx(x,{width:"110px",height:"36px"}),e.jsx(x,{width:"70px",height:"36px"})]}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[d,r,i,n,u],children:e.jsx(z,{searchParams:{query:i,offset:(d-1)*r,limit:r,sortBy:n,sortOrder:u},render:({tags:a,totalCount:l})=>e.jsx(v,{fallback:e.jsx(C,{title:i?"No matching tags":"No tags yet",description:i?"Try another tag name":"Add @tags inside notes and they will appear here"}),children:a.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:a.map(h=>e.jsxs(R,{to:_,params:{id:h.id},search:{page:1},className:"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-hover-subtle px-3 py-1.5 text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover hover:text-fg-default",children:[e.jsx(f,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:h.name}),e.jsx(f,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:h.referenceCount})]},h.id))}),e.jsx(v,{fallback:null,children:l&&r<l&&e.jsx(q,{page:d,last:Math.ceil(l/r),onChange:h=>{s({search:N=>({...N,page:h,query:i,limit:r,sortBy:n,sortOrder:u})})}})})]})})})})]})}export{X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,C as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./time-PxWila4-.js";import{F as h,N as k}from"./app-
|
|
1
|
+
import{j as e}from"./floating-ui.react-dom-BWTnA00G.js";import{i as x,C as N,q as j,Q as y,P as c,k as P,E as T,l as o,h as v}from"./time-PxWila4-.js";import{F as h,N as k}from"./app-4M3jUhmd.js";import{T as q}from"./url-DKUMNVCI.js";import"./NotePropertiesPanel-6P7UfRBR.js";import{e as w}from"./useNoteMutate-BjvZUmtX.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-hVj6vAYJ.js";import"./AuxiliaryPanelHeader-HAttwVby.js";import"./LinkSimple.es-B-P-7Iem.js";import"./Plus.es-Dy6onD-Z.js";const R=s=>{const{data:r}=x({queryKey:j.notes.tagList(s.searchParams),async queryFn(){const t=await N({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit});if(t.type==="error")throw t;return t.tagNotes}});return s.render(r)},g=v(q);function B(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=w();return e.jsxs(y,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(o,{width:148,height:24,className:"rounded-full"}),description:e.jsx(o,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"})]})}),errorTitle:"Failed to load tagged notes",errorDescription:"Retry loading notes for this tag",resetKeys:[r,t,i],children:[e.jsx(R,{searchParams:{query:r,offset:(t-1)*i,limit:i},render:({notes:l,totalCount:n})=>{const d=l.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:d??"Tagged Notes",heading:d?n>0?`${d} (${n})`:d:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(T,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:l.map(a=>e.jsx(k,{...a,onPinned:()=>u(a.id,a.pinned),onDelete:()=>m(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(P,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:p=>({...p,page:a})})}})})]})})})}}),f]})}export{B as default};
|