notemend 0.1.26 → 0.1.27
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/.claude-plugin/plugin.json +1 -1
- package/README.md +27 -9
- package/bin/notemend.mjs +18 -18
- package/bin/step.mjs +2 -0
- package/package.json +1 -1
- package/src/client/index.js +92 -91
- package/src/client/notemend.css +1 -1
- package/src/integration.mjs +1 -1
- package/src/next.mjs +7 -1
- package/src/server/middleware.mjs +7 -1
- package/src/store/cloud.mjs +3 -3
- package/src/store/comments.mjs +3 -3
- package/store.d.ts +13 -2
- package/thread.d.ts +2 -0
package/src/store/cloud.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readFileSync as P,writeFileSync as b,existsSync as I,mkdirSync as
|
|
2
|
-
`),Oe=e=>
|
|
3
|
-
`,{mode:384})}
|
|
1
|
+
import{readFileSync as P,writeFileSync as b,existsSync as I,mkdirSync as A,rmSync as D}from"node:fs";import{homedir as se}from"node:os";import{dirname as H,join as y}from"node:path";import{createStore as oe,add as ae,reply as ce,edit as ie,unsay as ue,patch as le,shotName as v,mediaOf as de,mediaName as L}from"./comments.mjs";const z=process.env.NOTEMEND_APP||"https://app.notemend.com",j={url:process.env.NOTEMEND_SUPABASE_URL||"https://xzhnjldvkirrydbyrdnm.supabase.co",key:process.env.NOTEMEND_SUPABASE_KEY||"sb_publishable_b8h8jTHZ9KtbPvMuroLhqA_-yBqZwd6"},N=y(process.env.NOTEMEND_HOME||y(se(),".config","notemend"),"session.json"),q=e=>y(e,".notemend.json"),he=e=>{try{return JSON.parse(P(q(e),"utf8")).project||null}catch{return null}},Ne=(e,t)=>b(q(e),JSON.stringify({project:t},null,2)+`
|
|
2
|
+
`),Oe=e=>D(q(e),{force:!0}),fe=()=>{try{const e=JSON.parse(P(N,"utf8"));return e.url===j.url?e:null}catch{return null}},me=e=>{A(H(N),{recursive:!0}),b(N,JSON.stringify(e,null,2)+`
|
|
3
|
+
`,{mode:384})},$e=()=>D(N,{force:!0});async function k(e,{method:t="GET",token:l,body:u,headers:i={},raw:d=!1}={}){const m=await fetch(`${j.url}${e}`,{method:t,headers:{apikey:j.key,authorization:`Bearer ${l||j.key}`,...u&&!d?{"content-type":"application/json"}:{},...i},body:d?u:u&&JSON.stringify(u),signal:AbortSignal.timeout(d?12e4:15e3)});if(!m.ok){const h=await m.text();let w=h;try{const _=JSON.parse(h);w=_.msg||_.message||_.error_description||_.error||h}catch{}const O=new Error(`${w} (${m.status})`);throw O.status=m.status,O}return m}const J=e=>{const t={url:j.url,email:e.user.email,user:e.user.id,access_token:e.access_token,refresh_token:e.refresh_token,expires_at:e.expires_at??Math.floor(Date.now()/1e3)+e.expires_in};return me(t),t},xe=e=>k("/auth/v1/otp",{method:"POST",body:{email:e,create_user:!0}}),Ee=async(e,t)=>J(await(await k("/auth/v1/verify",{method:"POST",body:{email:e,token:t,type:"email"}})).json());async function Te(e){const t=await fetch(`${z}/api/cli/device`,{method:"POST"}),l=await t.json().catch(()=>({}));if(!t.ok)throw new Error(l.error||`The cabinet said ${t.status}`);console.log(`Your code: ${l.code}`),e(l.url);const u=Date.now()+l.expires_in*1e3;for(;Date.now()<u;){await new Promise(h=>setTimeout(h,l.interval*1e3));const i=await fetch(`${z}/api/cli/device`,{headers:{authorization:`Bearer ${l.device}`}}).catch(()=>null);if(!i||i.status===202)continue;const d=await i.json().catch(()=>({}));if(!i.ok)throw new Error(d.error||`The cabinet said ${i.status}`);const m=await(await k("/auth/v1/user",{token:d.access_token})).json();return J({user:m,access_token:d.access_token,refresh_token:d.refresh_token,expires_at:Number(d.expires_at)})}throw new Error("No answer from the browser in 10 minutes.")}async function Pe(e,t){const l=await $();if(!l)throw new Error("Sign in first: npx notemend login");return(await(await k("/rest/v1/projects",{method:"POST",token:l.access_token,headers:{prefer:"return=representation"},body:{name:e,...t?{site_url:t}:{}}})).json())[0]}async function $(){const e=fe();if(!e)return null;if(e.expires_at-60>Date.now()/1e3)return e;try{const t=await k("/auth/v1/token?grant_type=refresh_token",{method:"POST",body:{refresh_token:e.refresh_token}});return J(await t.json())}catch(t){if(t.status===400||t.status===401)return null;throw t}}async function Ae(e,t,l){const u=y(H(N),"seen.json");let i={};try{i=JSON.parse(P(u,"utf8"))}catch{}const d=`${e}|${t}|${l}`;if(Date.now()-(i[d]||0)<6*36e5)return;const m=await $();m&&(await k("/rest/v1/rpc/agent_seen",{method:"POST",token:m.access_token,body:{p_agent:e,p_version:t,p_via:l}}),b(u,JSON.stringify({...i,[d]:Date.now()})))}class x extends Error{}const E=new Map;function pe(e,t,l=null){const u=y(e,"feedback","images"),i=n=>`feedback/images/${n}`,d=new WeakMap,m=l?async()=>l:async()=>{const n=await $();if(!n)throw new Error("Not signed in to Notemend \u2014 run `npx notemend login`.");return n},h=async(n,o={})=>k(`/rest/v1/${n}`,{...o,token:(await m()).access_token}),w=async(n,o={})=>k(`/storage/v1/object/shots/${t}/${n}`,{...o,token:(await m()).access_token}),O=`Project ${t} is not there, or you are not in it. Check \`npx notemend link\`.`,_=()=>Object.assign(new Error(O),{status:403,said:"You are not in this project any more \u2014 ask its owner to add you again."}),K="or=(data->>status.neq.done,data->>doneBy.eq.claude)",Y=async({open:n=!1}={})=>{if(!n){const a=await(await h(`stores?project_id=eq.${t}&select=doc,version`)).json();if(!a.length)throw _();const r=a[0].doc;return d.set(r,a[0].version),r}const[o,s]=await Promise.all([h(`stores_meta?project_id=eq.${t}&select=doc,version`).then(a=>a.json()),h(`threads?project_id=eq.${t}&${K}&select=data&order=id`).then(a=>a.json())]);if(!o.length)throw _();const c={...o[0].doc,comments:s.map(a=>a.data)};return d.set(c,o[0].version),c},R=n=>d.get(n)??null,W=async()=>(await(await h(`stores_meta?project_id=eq.${t}&select=version`)).json())[0]?.version??null,Z=async n=>{const o=d.get(n),s=await(await h(`stores?project_id=eq.${t}&version=eq.${o}&select=version`,{method:"PATCH",body:{doc:n},headers:{prefer:"return=representation"}})).json();if(!s.length)throw new x("Someone else wrote first");d.set(n,s[0].version)},G=async n=>(await(await h(`threads?project_id=eq.${t}&id=eq.${Number(n)}&select=data,v`)).json())[0]??null,Q=async(n,o,s,c)=>{const a={};for(const r of new Set([...Object.keys(o),...Object.keys(s)]))JSON.stringify(o[r])!==JSON.stringify(s[r])&&(a[r]=s[r]??null);if(Object.keys(a).length)try{await h("rpc/patch_thread",{method:"POST",body:{p_project:t,p_id:Number(n),p_patch:a,p_version:c}})}catch(r){throw r.status===409||r.status===404?new x(r.message):r}},U=async(n,o,s)=>(await(await h("rpc/react",{method:"POST",body:{p_project:t,p_id:Number(n),p_at:o,p_emoji:s}})).json()).thread,V=async()=>(await(await h(`threads?project_id=eq.${t}&select=route:data->>route`)).json()).map(n=>n.route),X=async()=>({email:(await m()).email}),B=new Map,ee=async(n,o,s,c)=>{const a=n.comments.find(g=>g.id===Number(o)),r=de(s);if(!a||!r)return null;const f=`${a.id}:${c??""}:${s.length}:${s.slice(-48)}`;let p=B.get(f);if(!p||a.images?.includes(i(p))){let g=Date.now();for(;I(y(u,L(a.id,g,r,c)));)g++;p=L(a.id,g,r,c),B.set(f,p)}const S=Buffer.from(r.base64,"base64");return await w(p,{method:"POST",body:S,raw:!0,headers:{"content-type":r.type,"x-upsert":"true"}}),A(u,{recursive:!0}),b(y(u,p),S),(a.images||=[]).push(i(p)),a.updatedAt=new Date().toISOString(),i(p)},te=async(n,o,s)=>{const c=n.comments.find(r=>r.id===Number(o));return!c||v(s)!==s||!s.startsWith(`${c.id}-`)?null:c.images?.includes(i(s))?i(s):await w(s,{method:"HEAD"}).then(()=>!0,()=>!1)?((c.images||=[]).push(i(s)),c.updatedAt=new Date().toISOString(),i(s)):null},M=async n=>{v(n)&&(D(y(u,n),{force:!0}),await w(n,{method:"DELETE"}).catch(()=>{}))};return{cloud:!0,project:t,root:e,imageDir:u,load:Y,versionOf:R,version:W,save:Z,thread:G,patchThread:Q,react:U,routes:V,me:X,attach:ee,adopt:te,detach:async(n,o,s)=>{const c=n.comments.find(f=>f.id===Number(o)),a=v(s),r=a&&c?.images?.find(f=>v(f)===a);return r?(await M(a),c.images=c.images.filter(f=>f!==r),c.updatedAt=new Date().toISOString(),!0):!1},remove:async(n,o)=>{const s=n.comments.find(c=>c.id===Number(o));if(!s)return!1;for(const c of s.images||[])await M(v(c));return n.comments=n.comments.filter(c=>c.id!==Number(o)),!0},fetchImage:async n=>{if(!v(n)||v(n)!==n)return null;const o=y(u,n);if(I(o))return o;const s=await w(n).catch(()=>null);return s?(A(u,{recursive:!0}),b(o,Buffer.from(await s.arrayBuffer())),o):null},people:async()=>{const n=await m(),o=`${t}|${n.email}`,s=E.get(o);if(s&&Date.now()-s.at<6e4)return s.p;const c=r=>h(`rpc/${r}`,{method:"POST",body:{p:t}}).then(f=>f.json()).catch(()=>null),a=Promise.all([h("profiles?select=email,name,nickname,avatar_url,agent_name,agent_avatar_url").then(r=>r.json()),c("project_people"),c("is_staff").then(r=>r??!0),c("project_staff"),c("project_lead"),h(`projects?id=eq.${t}&select=auto_archive_days,team_id`).then(r=>r.json()).then(async([r])=>{const[f]=r?.team_id?await h(`teams?id=eq.${r.team_id}&select=brand_color,brand_logo`).then(p=>p.json()).catch(()=>[]):[];return{autoArchive:r?.auto_archive_days??null,...f&&(f.brand_color||f.brand_logo)?{brand:{color:f.brand_color,logo:f.brand_logo}}:{}}}).catch(()=>({}))]).then(([r,f,p,S,g,ne])=>{if(Array.isArray(f)&&!f.length)throw _();const C=Array.isArray(f)?new Set(f):null,re=C?r.filter(T=>C.has(T.email)):r;return{me:r.find(T=>T.email===n.email)??{email:n.email,name:"",avatar_url:null},team:re,client:p===!1,...Array.isArray(S)?{studio:S}:{},...typeof g=="string"?{lead:g}:{},...ne}});return E.set(o,{at:Date.now(),p:a}),a.catch(()=>{E.get(o)?.p===a&&E.delete(o)}),a},add:ae,reply:ce,edit:ie,unsay:ue,patch:le,token:async()=>(await m()).access_token}}let F=!1;async function De(e){const t=he(e);return t&&await $()?pe(e,t):(t&&!F&&(F=!0,console.warn("[notemend] this site is linked to a Notemend project, but this computer is not signed in \u2014 comments stay in feedback/ until you run `npx notemend login`.")),oe(e))}async function qe(e,t,l){for(let u=0;;u++){const i=await e.thread(t);if(!i)return l({comments:[]});const d=JSON.parse(JSON.stringify(i.data)),m={comments:[i.data]},h=await l(m);try{return await e.patchThread(t,d,m.comments[0],i.v),h}catch(w){if(!(w instanceof x)||u>=4)throw w}}}async function Je(e,t){for(let l=0;;l++){const u=await e.load(),i=await t(u);try{return await e.save(u),i}catch(d){if(!(d instanceof x)||l>=4)throw d}}}export{j as BACKEND,z as CABINET,x as Conflict,pe as cloudStore,Pe as createProject,Te as deviceLogin,Ne as link,he as linkedProject,$e as logout,De as openStore,Je as retry,qe as retryThread,Ae as seen,xe as sendCode,$ as session,Oe as unlink,Ee as verifyCode};
|
package/src/store/comments.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{readFileSync as B,writeFileSync as D,existsSync as y,mkdirSync as A,renameSync as J,rmSync as z,statSync as T}from"node:fs";import{dirname as G,join as g}from"node:path";import{categoryOf as K}from"./categories.mjs";import{BLOCKED as W,DOCS as C,FRAMES as _,docSlug as q,fileExt as H,frameOf as P,toggledReaction as Q}from"./thread.mjs";import{CATEGORIES as ue,categoryOf as
|
|
2
|
-
`),J(l,t)},v=()=>{try{const c=T(t);return`${c.mtimeMs}-${c.size}`}catch{return"0"}};return{root:n,file:t,imageDir:e,archiveDir:o,archiveImageDir:r,load:m,version:v,versionOf:x,save:
|
|
3
|
-
`),c.nextId=j(c),c.comments=u,{moving:a,keeping:u,archiveFile:f,images:d}}}}export{ue as CATEGORIES,
|
|
1
|
+
import{readFileSync as B,writeFileSync as D,existsSync as y,mkdirSync as A,renameSync as J,rmSync as z,statSync as T}from"node:fs";import{dirname as G,join as g}from"node:path";import{categoryOf as K}from"./categories.mjs";import{BLOCKED as W,DOCS as C,FRAMES as _,docSlug as q,fileExt as H,frameOf as P,toggledReaction as Q}from"./thread.mjs";import{CATEGORIES as ue,categoryIcon as fe,categoryOf as le}from"./categories.mjs";import{stateOf as pe,STATE_LABEL as ge}from"./status.mjs";const $=n=>{const t=String(n??"").split(/[/\\]/).pop(),e=/^[\w-][\w.-]*\.([a-z0-9]{1,8})$/i.exec(t);return e&&!W.test(e[1])?t:""},V=n=>{const t=/^data:(image|video|audio)\/(png|jpeg|webp|gif|webm|mp4)(?:;[\w=.-]+)*;base64,(.+)$/s.exec(String(n||""));if(t&&!/^data:[^,]*;ext=/.test(String(n).slice(0,300))){const[,i,s,m]=t;return(i==="image"?!/^(png|jpeg|webp|gif)$/.test(s):i==="video"?s!=="webm":!/^(webm|mp4)$/.test(s))?null:{base64:m,voice:i==="audio",ext:s==="jpeg"?"jpg":s==="mp4"?"m4a":s,type:`${i}/${s}`}}const e=/^data:([\w.+-]+\/[\w.+-]+)((?:;[\w=.-]+)*);base64,(.+)$/s.exec(String(n||""));if(!e)return null;const o=/;ext=([a-z0-9]{1,8})(?:;|$)/i.exec(e[2])?.[1],r=o?H(`x.${o}`):Object.keys(C).find(i=>C[i]===e[1]);return r?{base64:e[3],voice:!1,ext:r,type:r==="pdf"?"application/pdf":"application/octet-stream",slug:q(/;name=([\w.-]+)/.exec(e[2])?.[1])||"file"}:null},L=(n,t,e,o)=>`${e.voice?"voice-":_.includes(o)?`${o}-`:""}${n}-${t}${e.slug?`.${e.slug}`:""}.${e.ext}`,oe=async(n,t,e,o,r)=>{if(typeof o!="string")return null;const i=t.comments.find(m=>m.id===Number(e))?.images?.filter(m=>P(m)===r)??[],s=await n.attach(t,e,o,r);if(s)for(const m of i)await n.detach(t,e,m);return s},j=n=>Math.max(n.nextId||0,n.comments.reduce((t,e)=>Math.max(t,e.id),0)+1);function X(n,{route:t,selector:e,rx:o,ry:r,text:i,label:s,viewport:m,breakpoint:x,browser:I,device:v,tag:k,classes:E,nth:N,category:M,suggest:c,assignee:l,ctx:S,logs:a,host:u,priority:f,shared:d,stage:w,from:h,client:p}){const b={id:j(n),route:t,selector:e,rx:o,ry:r,text:i,tag:k||"",classes:E||[],nth:Number.isInteger(N)?N:null,label:s||"",ctx:S||"",viewport:m||null,breakpoint:x||"desktop",browser:I||"",device:v||"",category:K(M).id,status:"open",note:"",replies:[],doneBy:null,images:[],...c?{suggest:c}:{},...l?{assignee:l}:{},...f?{priority:f}:{},...w?{stage:w}:{},...d?{shared:!0}:{},...p?{client:!0}:{},...Number.isInteger(h?.id)?{from:{id:h.id}}:{},...u?{host:u}:{},...a?.length?{logs:a}:{},createdAt:new Date().toISOString(),updatedAt:null};return n.comments.push(b),n.nextId=b.id+1,b}function Y(n,t,e,o,r,i){const s=n.comments.find(m=>m.id===Number(t));return s?((s.replies||=[]).push({author:e,text:o,at:new Date().toISOString(),...r&&r!=="claude"?{agent:r}:{},...i?{by:i}:{}}),s.updatedAt=new Date().toISOString(),s):null}function Z(n,t,e,o){const r=n.comments.find(s=>s.id===Number(t)),i=e?r?.replies?.find(s=>s.at===e&&s.author==="you"):r;return i?(i.text=o,r.updatedAt=new Date().toISOString(),r):null}function U(n,t,e){const o=n.comments.find(i=>i.id===Number(t)),r=o?.replies?.find(i=>i.at===e&&i.author==="you");return r?(r.text="",r.deleted=!0,delete r.mentions,o.updatedAt=new Date().toISOString(),o):null}function ie(n,t,e,o,r){const i=n.comments.find(x=>x.id===Number(t)),s=e?i?.replies?.find(x=>x.at===e&&!x.deleted):i;if(!s)return null;const m=Q(s.reactions,o,r);return m===null?!1:(m?s.reactions=m:delete s.reactions,i)}function ee(n,t,e){const o=n.comments.find(r=>r.id===Number(t));return o?(Object.assign(o,e,{updatedAt:new Date().toISOString()}),o):null}function ce(n){const t=g(n,"feedback","comments.json"),e=g(n,"feedback","images"),o=g(n,"feedback","archive"),r=g(o,"images"),i=c=>`feedback/images/${c}`,s=new WeakMap,m=()=>{const c=y(t)?JSON.parse(B(t,"utf8")):{comments:[]};return s.set(c,v()),c},x=c=>s.get(c)??v(),I=c=>{A(G(t),{recursive:!0});const l=`${t}.${process.pid}.${Date.now()}.tmp`;D(l,JSON.stringify(c,null,2)+`
|
|
2
|
+
`),J(l,t)},v=()=>{try{const c=T(t);return`${c.mtimeMs}-${c.size}`}catch{return"0"}};return{root:n,file:t,imageDir:e,archiveDir:o,archiveImageDir:r,load:m,version:v,versionOf:x,save:I,attach:(c,l,S,a)=>{const u=c.comments.find(h=>h.id===Number(l)),f=V(S);if(!u||!f)return null;A(e,{recursive:!0});let d=Date.now();for(;y(g(e,L(u.id,d,f,a)));)d++;const w=L(u.id,d,f,a);return D(g(e,w),Buffer.from(f.base64,"base64")),(u.images||=[]).push(i(w)),u.updatedAt=new Date().toISOString(),i(w)},detach:(c,l,S)=>{const a=c.comments.find(d=>d.id===Number(l)),u=$(S),f=u&&a?.images?.find(d=>$(d)===u);return f?(z(g(e,u),{force:!0}),a.images=a.images.filter(d=>d!==f),a.updatedAt=new Date().toISOString(),!0):!1},remove:(c,l)=>{const S=c.comments.find(a=>a.id===Number(l));if(!S)return!1;for(const a of S.images||[])$(a)&&z(g(e,$(a)),{force:!0});return c.comments=c.comments.filter(a=>a.id!==Number(l)),!0},add:X,patch:ee,reply:Y,edit:Z,unsay:U,nextId:j,prune:(c,{dry:l=!1,date:S=new Date().toISOString().slice(0,10)}={})=>{const a=c.comments.filter(p=>p.status==="done"),u=c.comments.filter(p=>p.status!=="done"),f=g(o,`comments-${S}.json`);if(l||!a.length)return{moving:a,keeping:u,archiveFile:f,images:a.flatMap(p=>p.images||[])};A(r,{recursive:!0});const d=[];for(const p of a)p.images=(p.images||[]).map(b=>{const O=$(b);if(!O)return b;const F=g(e,O),R=g(r,O);return y(F)&&J(F,R),d.push(O),`feedback/archive/images/${O}`});const w=y(f)?JSON.parse(B(f,"utf8")).comments||[]:[],h=new Set(w.map(p=>p.id));return D(f,JSON.stringify({comments:[...w,...a.filter(p=>!h.has(p.id))]},null,2)+`
|
|
3
|
+
`),c.nextId=j(c),c.comments=u,{moving:a,keeping:u,archiveFile:f,images:d}}}}export{ue as CATEGORIES,ge as STATE_LABEL,X as add,fe as categoryIcon,le as categoryOf,ce as createStore,Z as edit,oe as fileFrame,L as mediaName,V as mediaOf,j as nextId,ee as patch,ie as react,Y as reply,$ as shotName,pe as stateOf,U as unsay};
|
package/store.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Working } from './thread.js';
|
|
1
|
+
import type { Reactions, Working } from './thread.js';
|
|
2
2
|
|
|
3
3
|
/** One reply in a thread: `author: 'claude'` is any agent, `agent` says which */
|
|
4
4
|
export interface Reply { author: 'you' | 'claude'; text: string; at: string; by?: string; byName?: string; agent?: string; mentions?: string[];
|
|
5
5
|
/** taken back by its writer: kept in place, emptied */
|
|
6
|
-
deleted?: boolean }
|
|
6
|
+
deleted?: boolean; reactions?: Reactions }
|
|
7
7
|
/** A line the page logged before the comment was written (the bar's logs) */
|
|
8
8
|
export interface LogLine { at: string; kind: 'console' | 'error' | 'rejection' | 'network'; text: string }
|
|
9
9
|
|
|
@@ -21,6 +21,13 @@ export interface Comment {
|
|
|
21
21
|
priority?: 'urgent' | 'high' | 'normal' | 'low';
|
|
22
22
|
/** the project's clients see it too */
|
|
23
23
|
shared?: boolean;
|
|
24
|
+
/** written by a client or a guest: the clients' space */
|
|
25
|
+
client?: boolean;
|
|
26
|
+
/** a copy of this thread, in the other space */
|
|
27
|
+
from?: { id: number };
|
|
28
|
+
reactions?: Reactions;
|
|
29
|
+
/** put away by a person */
|
|
30
|
+
archivedAt?: string | null;
|
|
24
31
|
/** a person sent it back: the agent's last word before this is no question */
|
|
25
32
|
reopenedAt?: string; acceptedAt?: string;
|
|
26
33
|
/** who ticked it as fixed, in a team */
|
|
@@ -57,6 +64,8 @@ export function reply(db: Db, id: number | string, author: 'you' | 'claude', tex
|
|
|
57
64
|
export function edit(db: Db, id: number | string, at: string | null, text: string): Comment | null;
|
|
58
65
|
/** Take back one of your replies, found by when it was written */
|
|
59
66
|
export function unsay(db: Db, id: number | string, at: string): Comment | null;
|
|
67
|
+
/** Put `who`'s `emoji` on the comment (`at` null) or a reply, or take it back: null when there is no such message, false past the most kinds */
|
|
68
|
+
export function react(db: Db, id: number | string, at: string | null, emoji: string, who: string): Comment | null | false;
|
|
60
69
|
export function patch(db: Db, id: number | string, changes: Partial<Comment>): Comment | null;
|
|
61
70
|
export type Media = { base64: string; voice: boolean; ext: string; type: string; slug?: string };
|
|
62
71
|
/** What a data: URL files as — a screenshot, a recording, a voice note or a document — else null */
|
|
@@ -73,6 +82,8 @@ export function createStore(root: string): {
|
|
|
73
82
|
save(db: Db): void;
|
|
74
83
|
/** the file's stamp, for ?since= polls: '0' when there is no file yet */
|
|
75
84
|
version(): string;
|
|
85
|
+
/** the stamp the file had when `db` was loaded, else the file's now */
|
|
86
|
+
versionOf(db: Db): string;
|
|
76
87
|
/** file a data: URL screenshot (or webm) under the comment — `kind` makes it a frame; returns its path or null */
|
|
77
88
|
attach(db: Db, id: number | string, dataUrl: string, kind?: 'before' | 'after'): string | null;
|
|
78
89
|
detach(db: Db, id: number | string, name: string): boolean;
|
package/thread.d.ts
CHANGED
|
@@ -35,6 +35,8 @@ export type Working = { agent: string; by?: string | null; at: string; v?: strin
|
|
|
35
35
|
export const WORKING_TTL: number;
|
|
36
36
|
/** The agent working on an open thread now, or null when nobody is or the mark is stale */
|
|
37
37
|
export function workingOn(c: { working?: Working | null; status?: string } | null | undefined, now?: number): Working | null;
|
|
38
|
+
/** Who is on a thread, for its pin: its writer and whoever has it ('' nobody yet); null when resolved or no writer is known. `st` as stateOf gives it */
|
|
39
|
+
export function pinWho(c: Record<string, any>, st: 'open' | 'done' | 'claude', now?: number): { writer: string; taker: string; claude: boolean } | null;
|
|
38
40
|
/** A guest's address: someone let in by link, without an account */
|
|
39
41
|
export function isGuest(email?: string | null): boolean;
|
|
40
42
|
/** A guest's thread the studio has not approved yet: no agent takes it */
|