@gjsify/pim 0.64.57-next.363 → 0.64.58

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.
@@ -1 +1 @@
1
- import"../_virtual/_rolldown/runtime.js";import{BackendError as e}from"../errors.js";import{_ as t,fmt as n}from"../i18n.js";import{edsError as r,isBackendFailure as i,unwrapList as a,unwrapResult as o}from"./errors.js";import{cal as s,eds as c}from"./libs.gjs.js";function sexpString(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}async function boundary(e,t){try{return await t()}catch(t){throw i(t)?t:r(e,t)}}function createEdsBackend(){let i=null,l=new Map;async function getRegistry(){if(!i){let e=await c.get();try{i=e.SourceRegistry.new_sync(null)}catch(e){throw r(`EDS source registry`,e)}}return i}async function sources(e){let t=await c.get(),n=await getRegistry();try{return n.list_enabled(e===`event`?t.SOURCE_EXTENSION_CALENDAR:t.SOURCE_EXTENSION_TASK_LIST)}catch(t){throw r(`list ${e===`event`?`calendars`:`task lists`}`,t)}}async function source(r,i){let a=(await sources(r)).find(e=>e.get_uid()===i);if(!a)throw new e(n(t(r===`event`?`no enabled calendar "{uid}"`:`no enabled task list "{uid}"`),{uid:i}));return a}function connect(e,t){let n=`${t}:${e.get_uid()}`,r=l.get(n);return r||(r=s.get().then(({ECal:n})=>new Promise((r,i)=>{let a=t===`event`?n.ClientSourceType.EVENTS:n.ClientSourceType.TASKS;n.Client.connect(e,a,15,null,(e,t)=>{try{let e=n.Client.connect_finish(t);e?r(e):i(Error(`ECal.Client.connect_finish returned null`))}catch(e){i(e)}})})),r.catch(()=>l.delete(n)),l.set(n,r)),r}async function query(e,t){return a(await e.get_object_list_as_comps(t,null)).flatMap(e=>{let t=e.get_icalcomponent()?.as_ical_string();return t?[t]:[]})}return{id:`eds`,listCalendars:e=>boundary(`listCalendars`,async()=>{let t=await getRegistry(),n=e?[e]:[`event`,`reminder`],r=[];for(let e of n)for(let n of await sources(e)){let i=n.get_parent(),a=i?t.ref_source(i):null;r.push({uid:n.get_uid(),name:n.get_display_name(),kind:e,backend:`eds`,account:a?.get_display_name()??null})}return r}),listItems:e=>boundary(`listItems`,async()=>{let{ECal:t}=await s.get(),n=`#t`;e.kind===`event`&&e.from&&e.to&&(n=`(occur-in-time-range? (make-time "${t.isodate_from_time_t(Math.floor(Date.parse(e.from)/1e3))}") (make-time "${t.isodate_from_time_t(Math.floor(Date.parse(e.to)/1e3))}"))`);let i=await sources(e.kind);e.calendarUid&&(i=i.filter(t=>t.get_uid()===e.calendarUid));let a=[],o=0,c=null;for(let t of i){let i;try{i=await connect(t,e.kind),o++}catch(e){c=e;continue}try{for(let e of await query(i,n))a.push({calendarUid:t.get_uid(),ical:e})}catch(e){throw r(`get_object_list_as_comps(${t.get_display_name()})`,e)}}if(o===0&&i.length>0&&c)throw r(`connect calendar`,c);return a}),getItem:(e,t,n)=>boundary(`getItem`,async()=>{let r=await query(await connect(await source(t,e),t),`(uid? ${sexpString(n)})`);return r[0]===void 0?null:{ical:r[0],etag:null}}),createItem:(r,i,a)=>boundary(`createItem`,async()=>{let{ECal:c,ICalGLib:l}=await s.get(),u=await connect(await source(i,r),i);if(u.is_readonly())throw new e(n(t(`"{calendar}" is read-only`),{calendar:r}));let d=l.Component.new_from_string(a),f=o(await u.create_object(d,c.OperationFlags.NONE,null));return typeof f==`string`?f:``}),updateItem:(r,i,a,o)=>boundary(`updateItem`,async()=>{let{ECal:a,ICalGLib:c}=await s.get(),l=await connect(await source(i,r),i);if(l.is_readonly())throw new e(n(t(`"{calendar}" is read-only`),{calendar:r}));let u=c.Component.new_from_string(o);await l.modify_object(u,a.ObjModType.THIS,a.OperationFlags.NONE,null)})}}export{createEdsBackend};
1
+ import"../_virtual/_rolldown/runtime.js";import{BackendError as e}from"../errors.js";import{_ as t,fmt as n}from"../i18n.js";import{goaAccountId as r}from"./goa.js";import{edsError as i,isBackendFailure as a,unwrapList as o,unwrapResult as s}from"./errors.js";import{cal as c,eds as l}from"./libs.gjs.js";function sexpString(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}async function boundary(e,t){try{return await t()}catch(t){throw a(t)?t:i(e,t)}}function createEdsBackend(){let a=null,u=new Map;async function getRegistry(){if(!a){let e=await l.get();try{a=e.SourceRegistry.new_sync(null)}catch(e){throw i(`EDS source registry`,e)}}return a}async function sources(e){let t=await l.get(),n=await getRegistry();try{return n.list_enabled(e===`event`?t.SOURCE_EXTENSION_CALENDAR:t.SOURCE_EXTENSION_TASK_LIST)}catch(t){throw i(`list ${e===`event`?`calendars`:`task lists`}`,t)}}async function source(r,i){let a=(await sources(r)).find(e=>e.get_uid()===i);if(!a)throw new e(n(t(r===`event`?`no enabled calendar "{uid}"`:`no enabled task list "{uid}"`),{uid:i}));return a}function connect(e,t){let n=`${t}:${e.get_uid()}`,r=u.get(n);return r||(r=c.get().then(({ECal:n})=>new Promise((r,i)=>{let a=t===`event`?n.ClientSourceType.EVENTS:n.ClientSourceType.TASKS;n.Client.connect(e,a,15,null,(e,t)=>{try{let e=n.Client.connect_finish(t);e?r(e):i(Error(`ECal.Client.connect_finish returned null`))}catch(e){i(e)}})})),r.catch(()=>u.delete(n)),u.set(n,r)),r}async function query(e,t){return o(await e.get_object_list_as_comps(t,null)).flatMap(e=>{let t=e.get_icalcomponent()?.as_ical_string();return t?[t]:[]})}return{id:`eds`,listCalendars:e=>boundary(`listCalendars`,async()=>{let t=await l.get(),n=await getRegistry(),i=e?[e]:[`event`,`reminder`],a=[];for(let e of i)for(let i of await sources(e)){let o=i.get_parent(),s=o?n.ref_source(o):null,c=r(i,e=>n.ref_source(e),t.SOURCE_EXTENSION_GOA);a.push({uid:i.get_uid(),name:i.get_display_name(),kind:e,backend:`eds`,account:s?.get_display_name()??null,...c?{accountId:c}:{}})}return a}),listItems:e=>boundary(`listItems`,async()=>{let{ECal:t}=await c.get(),n=`#t`;e.kind===`event`&&e.from&&e.to&&(n=`(occur-in-time-range? (make-time "${t.isodate_from_time_t(Math.floor(Date.parse(e.from)/1e3))}") (make-time "${t.isodate_from_time_t(Math.floor(Date.parse(e.to)/1e3))}"))`);let r=await sources(e.kind);e.calendarUid&&(r=r.filter(t=>t.get_uid()===e.calendarUid));let a=[],o=0,s=null;for(let t of r){let r;try{r=await connect(t,e.kind),o++}catch(e){s=e;continue}try{for(let e of await query(r,n))a.push({calendarUid:t.get_uid(),ical:e})}catch(e){throw i(`get_object_list_as_comps(${t.get_display_name()})`,e)}}if(o===0&&r.length>0&&s)throw i(`connect calendar`,s);return a}),getItem:(e,t,n)=>boundary(`getItem`,async()=>{let r=await query(await connect(await source(t,e),t),`(uid? ${sexpString(n)})`);return r[0]===void 0?null:{ical:r[0],etag:null}}),createItem:(r,i,a)=>boundary(`createItem`,async()=>{let{ECal:o,ICalGLib:l}=await c.get(),u=await connect(await source(i,r),i);if(u.is_readonly())throw new e(n(t(`"{calendar}" is read-only`),{calendar:r}));let d=l.Component.new_from_string(a),f=s(await u.create_object(d,o.OperationFlags.NONE,null));return typeof f==`string`?f:``}),updateItem:(r,i,a,o)=>boundary(`updateItem`,async()=>{let{ECal:a,ICalGLib:s}=await c.get(),l=await connect(await source(i,r),i);if(l.is_readonly())throw new e(n(t(`"{calendar}" is read-only`),{calendar:r}));let u=s.Component.new_from_string(o);await l.modify_object(u,a.ObjModType.THIS,a.OperationFlags.NONE,null)})}}export{createEdsBackend};
@@ -0,0 +1 @@
1
+ import"../_virtual/_rolldown/runtime.js";function goaAccountId(e,t,n){let r=e,i=new Set;for(;r;){if(r.has_extension(n))return r.get_extension(n).get_account_id()||null;let e=r.get_parent();if(!e||i.has(e))break;i.add(e),r=t(e)}return null}export{goaAccountId};
@@ -1 +1 @@
1
- import{edsError as e,unwrapList as t,unwrapResult as n}from"./errors.js";import{createEdsBackend as r}from"./driver.gjs.js";export{r as createEdsBackend,e as edsError,t as unwrapList,n as unwrapResult};
1
+ import{goaAccountId as e}from"./goa.js";import{edsError as t,unwrapList as n,unwrapResult as r}from"./errors.js";import{createEdsBackend as i}from"./driver.gjs.js";export{i as createEdsBackend,t as edsError,e as goaAccountId,n as unwrapList,r as unwrapResult};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Which GNOME Online Accounts account an EDS source belongs to. The GOA extension sits on the
3
+ * collection source, not on the calendar, so this walks up the parents until one carries it.
4
+ * Pure over a structural source type so it runs without EDS.
5
+ */
6
+ export interface GoaSourceLike {
7
+ has_extension(name: string): boolean;
8
+ get_extension(name: string): unknown;
9
+ get_parent(): string | null;
10
+ }
11
+ export declare function goaAccountId(source: GoaSourceLike, lookup: (uid: string) => GoaSourceLike | null, goaExtension: string): string | null;
@@ -6,3 +6,4 @@
6
6
  */
7
7
  export { createEdsBackend } from './driver.gjs.js';
8
8
  export { edsError, unwrapList, unwrapResult } from './errors.js';
9
+ export { goaAccountId, type GoaSourceLike } from './goa.js';
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -13,6 +13,11 @@ export interface CalendarInfo {
13
13
  backend: string;
14
14
  /** Display name of the collection/account it belongs to, when the backend knows one. */
15
15
  account: string | null;
16
+ /**
17
+ * The system online account (GNOME Online Accounts) the calendar comes from, so an app can
18
+ * scope to one account. Absent when the backend has no such link.
19
+ */
20
+ accountId?: string;
16
21
  /** The collection refuses writes (a subscribed or shared-read-only list). Absent: unknown, assume writable. */
17
22
  readOnly?: boolean;
18
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/pim",
3
- "version": "0.64.57-next.363",
3
+ "version": "0.64.58",
4
4
  "description": "Calendars and tasks behind one port: the CalendarBackend interface moves iCalendar text, drivers move it to CalDAV (plain fetch, every runtime) or Evolution Data Server (typelibs loaded on first use).",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -56,17 +56,17 @@
56
56
  "@girs/ecal-2.0": "5.4.0",
57
57
  "@girs/edataserver-1.2": "5.4.0",
58
58
  "@girs/icalglib-3.0": "5.4.0",
59
- "@gjsify/dav": "0.64.57-next.363"
59
+ "@gjsify/dav": "0.64.58"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@girs/gio-2.0": "5.4.0",
63
63
  "@girs/gjs": "5.4.0",
64
64
  "@girs/glib-2.0": "5.4.0",
65
65
  "@girs/gobject-2.0": "5.4.0",
66
- "@gjsify/cli": "0.64.57-next.363",
67
- "@gjsify/fetch": "0.64.57-next.363",
68
- "@gjsify/http": "0.64.57-next.363",
69
- "@gjsify/unit": "0.64.57-next.363",
66
+ "@gjsify/cli": "0.64.58",
67
+ "@gjsify/fetch": "0.64.58",
68
+ "@gjsify/http": "0.64.58",
69
+ "@gjsify/unit": "0.64.58",
70
70
  "@types/node": "^25.9.2",
71
71
  "typescript": "^6.0.3"
72
72
  },
@@ -104,6 +104,5 @@
104
104
  "darwin": "The CalDAV driver is plain fetch and works; the EDS driver answers BackendUnavailableError because Evolution Data Server is not there.",
105
105
  "win32": "The CalDAV driver is plain fetch and works; the EDS driver answers BackendUnavailableError because Evolution Data Server is not there."
106
106
  }
107
- },
108
- "gitHead": "75905af1599250ab9a443fe4b079c4cd7fbc0bad"
107
+ }
109
108
  }
package/po/POTFILES.in CHANGED
@@ -5,6 +5,7 @@ src/caldav/errors.ts
5
5
  src/caldav/index.ts
6
6
  src/eds/driver.gjs.ts
7
7
  src/eds/errors.ts
8
+ src/eds/goa.ts
8
9
  src/eds/index.ts
9
10
  src/eds/libs.gjs.ts
10
11
  src/errors.ts