@gjsify/pim 0.64.57 → 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.
- package/lib/esm/eds/driver.gjs.js +1 -1
- package/lib/esm/eds/goa.js +1 -0
- package/lib/esm/eds/index.js +1 -1
- package/lib/types/eds/goa.d.ts +11 -0
- package/lib/types/eds/index.d.ts +1 -0
- package/lib/types/goa.spec.d.ts +2 -0
- package/lib/types/types.d.ts +5 -0
- package/package.json +6 -6
- package/po/POTFILES.in +1 -0
|
@@ -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
|
|
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};
|
package/lib/esm/eds/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{edsError as
|
|
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;
|
package/lib/types/eds/index.d.ts
CHANGED
package/lib/types/types.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
67
|
-
"@gjsify/fetch": "0.64.
|
|
68
|
-
"@gjsify/http": "0.64.
|
|
69
|
-
"@gjsify/unit": "0.64.
|
|
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
|
},
|