@arbidocs/sdk 0.4.138 → 0.4.140
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/{browser-B1eZG2h_.d.cts → browser-D3wxXCKl.d.cts} +1146 -3
- package/dist/{browser-B1eZG2h_.d.ts → browser-D3wxXCKl.d.ts} +1146 -3
- package/dist/browser.cjs +646 -8
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +640 -9
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +646 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +640 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/browser.cjs
CHANGED
|
@@ -7717,6 +7717,549 @@ function bytesToBase643(bytes) {
|
|
|
7717
7717
|
return btoa(binary);
|
|
7718
7718
|
}
|
|
7719
7719
|
|
|
7720
|
+
// src/operations/calendar.ts
|
|
7721
|
+
var calendar_exports = {};
|
|
7722
|
+
__export(calendar_exports, {
|
|
7723
|
+
ACCOUNT_VENDOR: () => ACCOUNT_VENDOR,
|
|
7724
|
+
PublicBookingError: () => PublicBookingError,
|
|
7725
|
+
addHolidayCalendar: () => addHolidayCalendar,
|
|
7726
|
+
bookPublicSlot: () => bookPublicSlot,
|
|
7727
|
+
cancelPublicBooking: () => cancelPublicBooking,
|
|
7728
|
+
connectCalDavAccount: () => connectCalDavAccount,
|
|
7729
|
+
connectOAuthAccount: () => connectOAuthAccount,
|
|
7730
|
+
createAppPassword: () => createAppPassword,
|
|
7731
|
+
createCalendar: () => createCalendar,
|
|
7732
|
+
createEvent: () => createEvent,
|
|
7733
|
+
createFeed: () => createFeed,
|
|
7734
|
+
createRoom: () => createRoom,
|
|
7735
|
+
decideCounter: () => decideCounter,
|
|
7736
|
+
deleteBookingPage: () => deleteBookingPage,
|
|
7737
|
+
deleteCalendar: () => deleteCalendar,
|
|
7738
|
+
deleteEvent: () => deleteEvent,
|
|
7739
|
+
disconnectAccount: () => disconnectAccount,
|
|
7740
|
+
ensureCalendarUnlocked: () => ensureCalendarUnlocked,
|
|
7741
|
+
eventIcs: () => eventIcs,
|
|
7742
|
+
exportCalendarIcs: () => exportCalendarIcs,
|
|
7743
|
+
findTime: () => findTime,
|
|
7744
|
+
getCalendarSettings: () => getCalendarSettings,
|
|
7745
|
+
getEvent: () => getEvent,
|
|
7746
|
+
getFreeBusy: () => getFreeBusy,
|
|
7747
|
+
getPublicBookingPage: () => getPublicBookingPage,
|
|
7748
|
+
importCalendarIcs: () => importCalendarIcs,
|
|
7749
|
+
listAccounts: () => listAccounts,
|
|
7750
|
+
listAppPasswords: () => listAppPasswords,
|
|
7751
|
+
listBookingPages: () => listBookingPages,
|
|
7752
|
+
listCalDavProfiles: () => listCalDavProfiles,
|
|
7753
|
+
listCalendars: () => listCalendars,
|
|
7754
|
+
listEvents: () => listEvents,
|
|
7755
|
+
listHolidayCountries: () => listHolidayCountries,
|
|
7756
|
+
listInvitations: () => listInvitations,
|
|
7757
|
+
listOverlays: () => listOverlays,
|
|
7758
|
+
listRooms: () => listRooms,
|
|
7759
|
+
listShares: () => listShares,
|
|
7760
|
+
lookupEventByUid: () => lookupEventByUid,
|
|
7761
|
+
lookupPeopleKeys: () => lookupPeopleKeys,
|
|
7762
|
+
moveEvent: () => moveEvent,
|
|
7763
|
+
publishCalendarToAccount: () => publishCalendarToAccount,
|
|
7764
|
+
putBookingPage: () => putBookingPage,
|
|
7765
|
+
putCalendarSettings: () => putCalendarSettings,
|
|
7766
|
+
refreshCalendar: () => refreshCalendar,
|
|
7767
|
+
respondToEvent: () => respondToEvent,
|
|
7768
|
+
revokeAppPassword: () => revokeAppPassword,
|
|
7769
|
+
shareCalendar: () => shareCalendar,
|
|
7770
|
+
splitAppPasswords: () => splitAppPasswords,
|
|
7771
|
+
subscribeCalendar: () => subscribeCalendar,
|
|
7772
|
+
syncAccount: () => syncAccount,
|
|
7773
|
+
unlockCalendarKeys: () => unlockCalendarKeys,
|
|
7774
|
+
unshareCalendar: () => unshareCalendar,
|
|
7775
|
+
updateAccount: () => updateAccount,
|
|
7776
|
+
updateCalendar: () => updateCalendar,
|
|
7777
|
+
updateEvent: () => updateEvent
|
|
7778
|
+
});
|
|
7779
|
+
var ACCOUNT_VENDOR = {
|
|
7780
|
+
google: "google_calendar",
|
|
7781
|
+
microsoft: "microsoft"
|
|
7782
|
+
};
|
|
7783
|
+
function take(result, what) {
|
|
7784
|
+
if (result.error !== void 0 || !result.response.ok) {
|
|
7785
|
+
const status = result.response.status;
|
|
7786
|
+
throw new ArbiApiError(
|
|
7787
|
+
apiErrorDetail(result.error) ?? `${what} failed (${status})`,
|
|
7788
|
+
result.error,
|
|
7789
|
+
status
|
|
7790
|
+
);
|
|
7791
|
+
}
|
|
7792
|
+
return result.data;
|
|
7793
|
+
}
|
|
7794
|
+
async function unlockCalendarKeys(client$1, keys) {
|
|
7795
|
+
await client.initSodium();
|
|
7796
|
+
const keypair = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey);
|
|
7797
|
+
try {
|
|
7798
|
+
const page = take(await client$1.fetch.GET("/v1/calendar/keys"), "Reading the calendar keys");
|
|
7799
|
+
const sealed = {};
|
|
7800
|
+
for (const [id, wrapped] of Object.entries(page?.keys ?? {})) {
|
|
7801
|
+
const key = client.sealedBoxDecrypt(wrapped, keypair.secretKey);
|
|
7802
|
+
try {
|
|
7803
|
+
sealed[id] = await client.sealKeyForSession(key, keys.serverSessionKey);
|
|
7804
|
+
} finally {
|
|
7805
|
+
key.fill(0);
|
|
7806
|
+
}
|
|
7807
|
+
}
|
|
7808
|
+
if (Object.keys(sealed).length)
|
|
7809
|
+
take(
|
|
7810
|
+
await client$1.fetch.POST("/v1/calendar/session-keys", { body: { keys: sealed } }),
|
|
7811
|
+
"Unlocking the calendar"
|
|
7812
|
+
);
|
|
7813
|
+
} finally {
|
|
7814
|
+
keypair.secretKey.fill(0);
|
|
7815
|
+
}
|
|
7816
|
+
}
|
|
7817
|
+
var unlockStates = /* @__PURE__ */ new WeakMap();
|
|
7818
|
+
function unlockState(keys) {
|
|
7819
|
+
let state = unlockStates.get(keys.serverSessionKey);
|
|
7820
|
+
if (!state) {
|
|
7821
|
+
state = { done: false, running: null, attemptedLocked: /* @__PURE__ */ new Set() };
|
|
7822
|
+
unlockStates.set(keys.serverSessionKey, state);
|
|
7823
|
+
}
|
|
7824
|
+
return state;
|
|
7825
|
+
}
|
|
7826
|
+
async function ensureCalendarUnlocked(client, keys, force = false) {
|
|
7827
|
+
if (!keys) return;
|
|
7828
|
+
const state = unlockState(keys);
|
|
7829
|
+
if (!force && state.done) return;
|
|
7830
|
+
state.running ??= unlockCalendarKeys(client, keys).then(() => {
|
|
7831
|
+
state.done = true;
|
|
7832
|
+
}).finally(() => {
|
|
7833
|
+
state.running = null;
|
|
7834
|
+
});
|
|
7835
|
+
try {
|
|
7836
|
+
await state.running;
|
|
7837
|
+
} catch (err) {
|
|
7838
|
+
console.warn("Calendar keys could not be unlocked", err);
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
var calPath = (calId) => ({ params: { path: { cal_id: calId } } });
|
|
7842
|
+
var evtPath = (evtId) => ({ path: { evt_id: evtId } });
|
|
7843
|
+
async function getCalendarSettings(client) {
|
|
7844
|
+
return take(await client.fetch.GET("/v1/calendar/settings"), "Loading calendar settings");
|
|
7845
|
+
}
|
|
7846
|
+
async function putCalendarSettings(client, body) {
|
|
7847
|
+
return take(
|
|
7848
|
+
await client.fetch.PUT("/v1/calendar/settings", { body }),
|
|
7849
|
+
"Saving calendar settings"
|
|
7850
|
+
);
|
|
7851
|
+
}
|
|
7852
|
+
async function listCalendars(client, keys) {
|
|
7853
|
+
const read = async () => take(await client.fetch.GET("/v1/calendar/calendars"), "Loading calendars");
|
|
7854
|
+
const calendars = await read();
|
|
7855
|
+
if (!keys) return calendars;
|
|
7856
|
+
const state = unlockState(keys);
|
|
7857
|
+
const fresh = calendars.filter((c2) => c2.locked && !state.attemptedLocked.has(c2.id));
|
|
7858
|
+
if (!fresh.length) return calendars;
|
|
7859
|
+
for (const c2 of fresh) state.attemptedLocked.add(c2.id);
|
|
7860
|
+
await ensureCalendarUnlocked(client, keys, true);
|
|
7861
|
+
return read();
|
|
7862
|
+
}
|
|
7863
|
+
async function createCalendar(client, body) {
|
|
7864
|
+
return take(
|
|
7865
|
+
await client.fetch.POST("/v1/calendar/calendars", { body }),
|
|
7866
|
+
"Creating the calendar"
|
|
7867
|
+
);
|
|
7868
|
+
}
|
|
7869
|
+
async function updateCalendar(client, calId, body) {
|
|
7870
|
+
return take(
|
|
7871
|
+
await client.fetch.PATCH("/v1/calendar/calendars/{cal_id}", { ...calPath(calId), body }),
|
|
7872
|
+
"Saving the calendar"
|
|
7873
|
+
);
|
|
7874
|
+
}
|
|
7875
|
+
async function deleteCalendar(client, calId) {
|
|
7876
|
+
take(
|
|
7877
|
+
await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}", calPath(calId)),
|
|
7878
|
+
"Deleting the calendar"
|
|
7879
|
+
);
|
|
7880
|
+
}
|
|
7881
|
+
async function exportCalendarIcs(client, calId) {
|
|
7882
|
+
return take(
|
|
7883
|
+
await client.fetch.GET("/v1/calendar/calendars/{cal_id}/export.ics", {
|
|
7884
|
+
...calPath(calId),
|
|
7885
|
+
parseAs: "blob"
|
|
7886
|
+
}),
|
|
7887
|
+
"Exporting the calendar"
|
|
7888
|
+
);
|
|
7889
|
+
}
|
|
7890
|
+
async function importCalendarIcs(client, ics, calendarId) {
|
|
7891
|
+
return take(
|
|
7892
|
+
await client.fetch.POST("/v1/calendar/import", {
|
|
7893
|
+
body: { ics, calendar_id: calendarId ?? null }
|
|
7894
|
+
}),
|
|
7895
|
+
"Importing"
|
|
7896
|
+
);
|
|
7897
|
+
}
|
|
7898
|
+
async function listEvents(client, { start, end, calendars }) {
|
|
7899
|
+
return take(
|
|
7900
|
+
await client.fetch.GET("/v1/calendar/events", {
|
|
7901
|
+
params: {
|
|
7902
|
+
query: { start, end, calendars: calendars?.length ? calendars.join(",") : void 0 }
|
|
7903
|
+
}
|
|
7904
|
+
}),
|
|
7905
|
+
"Loading events"
|
|
7906
|
+
);
|
|
7907
|
+
}
|
|
7908
|
+
async function getEvent(client, evtId, recurrenceId) {
|
|
7909
|
+
return take(
|
|
7910
|
+
await client.fetch.GET("/v1/calendar/events/{evt_id}", {
|
|
7911
|
+
params: { ...evtPath(evtId), query: { recurrence_id: recurrenceId ?? void 0 } }
|
|
7912
|
+
}),
|
|
7913
|
+
"Loading the event"
|
|
7914
|
+
);
|
|
7915
|
+
}
|
|
7916
|
+
async function createEvent(client, body) {
|
|
7917
|
+
return take(
|
|
7918
|
+
await client.fetch.POST("/v1/calendar/events", { body }),
|
|
7919
|
+
"Saving the event"
|
|
7920
|
+
);
|
|
7921
|
+
}
|
|
7922
|
+
async function updateEvent(client, target, body) {
|
|
7923
|
+
return take(
|
|
7924
|
+
await client.fetch.PATCH("/v1/calendar/events/{evt_id}", {
|
|
7925
|
+
params: {
|
|
7926
|
+
...evtPath(target.id),
|
|
7927
|
+
query: { scope: target.scope, recurrence_id: target.recurrence_id ?? void 0 }
|
|
7928
|
+
},
|
|
7929
|
+
body
|
|
7930
|
+
}),
|
|
7931
|
+
"Saving the event"
|
|
7932
|
+
);
|
|
7933
|
+
}
|
|
7934
|
+
async function deleteEvent(client, target) {
|
|
7935
|
+
take(
|
|
7936
|
+
await client.fetch.DELETE("/v1/calendar/events/{evt_id}", {
|
|
7937
|
+
params: {
|
|
7938
|
+
...evtPath(target.id),
|
|
7939
|
+
query: {
|
|
7940
|
+
scope: target.scope,
|
|
7941
|
+
recurrence_id: target.recurrence_id ?? void 0,
|
|
7942
|
+
notify: target.notify
|
|
7943
|
+
}
|
|
7944
|
+
}
|
|
7945
|
+
}),
|
|
7946
|
+
"Deleting the event"
|
|
7947
|
+
);
|
|
7948
|
+
}
|
|
7949
|
+
async function moveEvent(client, evtId, calendarId) {
|
|
7950
|
+
return take(
|
|
7951
|
+
await client.fetch.POST("/v1/calendar/events/{evt_id}/move", {
|
|
7952
|
+
params: evtPath(evtId),
|
|
7953
|
+
body: { calendar_id: calendarId }
|
|
7954
|
+
}),
|
|
7955
|
+
"Moving the event"
|
|
7956
|
+
);
|
|
7957
|
+
}
|
|
7958
|
+
async function respondToEvent(client, { id, ...body }) {
|
|
7959
|
+
return take(
|
|
7960
|
+
await client.fetch.POST("/v1/calendar/events/{evt_id}/respond", {
|
|
7961
|
+
params: evtPath(id),
|
|
7962
|
+
body: { scope: "all", notify: true, ...body }
|
|
7963
|
+
}),
|
|
7964
|
+
"Sending your response"
|
|
7965
|
+
);
|
|
7966
|
+
}
|
|
7967
|
+
async function eventIcs(client, evtId) {
|
|
7968
|
+
return take(
|
|
7969
|
+
await client.fetch.GET("/v1/calendar/events/{evt_id}/ics", {
|
|
7970
|
+
params: evtPath(evtId),
|
|
7971
|
+
parseAs: "blob"
|
|
7972
|
+
}),
|
|
7973
|
+
"Downloading the event"
|
|
7974
|
+
);
|
|
7975
|
+
}
|
|
7976
|
+
async function lookupEventByUid(client, uid) {
|
|
7977
|
+
try {
|
|
7978
|
+
return take(
|
|
7979
|
+
await client.fetch.GET("/v1/calendar/lookup", { params: { query: { uid } } }),
|
|
7980
|
+
"Looking up the event"
|
|
7981
|
+
);
|
|
7982
|
+
} catch (err) {
|
|
7983
|
+
if (err instanceof ArbiApiError && err.status === 404) return null;
|
|
7984
|
+
throw err;
|
|
7985
|
+
}
|
|
7986
|
+
}
|
|
7987
|
+
async function listOverlays(client, range, layers) {
|
|
7988
|
+
return take(
|
|
7989
|
+
await client.fetch.GET("/v1/calendar/overlays", {
|
|
7990
|
+
params: { query: { start: range.start, end: range.end, layers: layers.join(",") } }
|
|
7991
|
+
}),
|
|
7992
|
+
"Loading the overlays"
|
|
7993
|
+
);
|
|
7994
|
+
}
|
|
7995
|
+
async function listShares(client, calId) {
|
|
7996
|
+
return take(
|
|
7997
|
+
await client.fetch.GET("/v1/calendar/calendars/{cal_id}/shares", calPath(calId)),
|
|
7998
|
+
"Loading the shares"
|
|
7999
|
+
);
|
|
8000
|
+
}
|
|
8001
|
+
async function shareCalendar(client, calId, grantee, role) {
|
|
8002
|
+
return take(
|
|
8003
|
+
await client.fetch.PUT("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
|
|
8004
|
+
params: { path: { cal_id: calId, grantee } },
|
|
8005
|
+
body: { role }
|
|
8006
|
+
}),
|
|
8007
|
+
"Sharing the calendar"
|
|
8008
|
+
);
|
|
8009
|
+
}
|
|
8010
|
+
async function unshareCalendar(client, calId, grantee) {
|
|
8011
|
+
take(
|
|
8012
|
+
await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
|
|
8013
|
+
params: { path: { cal_id: calId, grantee } }
|
|
8014
|
+
}),
|
|
8015
|
+
"Removing the share"
|
|
8016
|
+
);
|
|
8017
|
+
}
|
|
8018
|
+
async function subscribeCalendar(client, body) {
|
|
8019
|
+
return take(
|
|
8020
|
+
await client.fetch.POST("/v1/calendar/subscriptions", {
|
|
8021
|
+
body
|
|
8022
|
+
}),
|
|
8023
|
+
"Subscribing"
|
|
8024
|
+
);
|
|
8025
|
+
}
|
|
8026
|
+
async function refreshCalendar(client, calId) {
|
|
8027
|
+
return take(
|
|
8028
|
+
await client.fetch.POST("/v1/calendar/calendars/{cal_id}/refresh", calPath(calId)),
|
|
8029
|
+
"Refreshing the calendar"
|
|
8030
|
+
);
|
|
8031
|
+
}
|
|
8032
|
+
async function listHolidayCountries(client) {
|
|
8033
|
+
return take(
|
|
8034
|
+
await client.fetch.GET("/v1/calendar/holidays/countries"),
|
|
8035
|
+
"Loading holiday countries"
|
|
8036
|
+
);
|
|
8037
|
+
}
|
|
8038
|
+
async function addHolidayCalendar(client, body) {
|
|
8039
|
+
return take(
|
|
8040
|
+
await client.fetch.POST("/v1/calendar/holidays", {
|
|
8041
|
+
body
|
|
8042
|
+
}),
|
|
8043
|
+
"Adding holidays"
|
|
8044
|
+
);
|
|
8045
|
+
}
|
|
8046
|
+
async function createRoom(client, body) {
|
|
8047
|
+
return take(
|
|
8048
|
+
await client.fetch.POST("/v1/calendar/rooms", { body }),
|
|
8049
|
+
"Adding the room"
|
|
8050
|
+
);
|
|
8051
|
+
}
|
|
8052
|
+
async function listRooms(client, q2 = {}) {
|
|
8053
|
+
return take(
|
|
8054
|
+
await client.fetch.GET("/v1/calendar/rooms", {
|
|
8055
|
+
params: {
|
|
8056
|
+
query: {
|
|
8057
|
+
start: q2.start,
|
|
8058
|
+
end: q2.end,
|
|
8059
|
+
min_capacity: q2.min_capacity || void 0,
|
|
8060
|
+
feature: q2.feature?.length ? q2.feature : void 0,
|
|
8061
|
+
building: q2.building || void 0
|
|
8062
|
+
}
|
|
8063
|
+
}
|
|
8064
|
+
}),
|
|
8065
|
+
"Loading rooms"
|
|
8066
|
+
);
|
|
8067
|
+
}
|
|
8068
|
+
async function getFreeBusy(client, body) {
|
|
8069
|
+
return take(await client.fetch.POST("/v1/calendar/freebusy", { body }), "Loading free/busy");
|
|
8070
|
+
}
|
|
8071
|
+
async function findTime(client, body) {
|
|
8072
|
+
return take(
|
|
8073
|
+
await client.fetch.POST("/v1/calendar/find-time", {
|
|
8074
|
+
body
|
|
8075
|
+
}),
|
|
8076
|
+
"Finding a time"
|
|
8077
|
+
);
|
|
8078
|
+
}
|
|
8079
|
+
async function listInvitations(client) {
|
|
8080
|
+
return take(await client.fetch.GET("/v1/calendar/invitations"), "Loading invitations");
|
|
8081
|
+
}
|
|
8082
|
+
async function decideCounter(client, itpId, accept, comment) {
|
|
8083
|
+
return take(
|
|
8084
|
+
await client.fetch.POST("/v1/calendar/invitations/{itp_id}/decide", {
|
|
8085
|
+
params: { path: { itp_id: itpId } },
|
|
8086
|
+
body: { accept, comment: comment ?? null }
|
|
8087
|
+
}),
|
|
8088
|
+
"Answering the proposal"
|
|
8089
|
+
);
|
|
8090
|
+
}
|
|
8091
|
+
async function lookupPeopleKeys(client, body) {
|
|
8092
|
+
return take(
|
|
8093
|
+
await client.fetch.POST("/v1/calendar/people/keys", {
|
|
8094
|
+
body
|
|
8095
|
+
}),
|
|
8096
|
+
"Looking up people"
|
|
8097
|
+
);
|
|
8098
|
+
}
|
|
8099
|
+
var accPath = (accId) => ({ params: { path: { acc_id: accId } } });
|
|
8100
|
+
async function listAccounts(client) {
|
|
8101
|
+
return take(await client.fetch.GET("/v1/calendar/accounts"), "Loading calendar accounts");
|
|
8102
|
+
}
|
|
8103
|
+
async function listCalDavProfiles(client) {
|
|
8104
|
+
return take(await client.fetch.GET("/v1/calendar/caldav/profiles"), "Loading CalDAV servers");
|
|
8105
|
+
}
|
|
8106
|
+
async function connectOAuthAccount(client, kind, backgroundSync = false) {
|
|
8107
|
+
return take(
|
|
8108
|
+
await client.fetch.POST("/v1/calendar/accounts/{kind}", {
|
|
8109
|
+
params: { path: { kind } },
|
|
8110
|
+
body: { background_sync: backgroundSync }
|
|
8111
|
+
}),
|
|
8112
|
+
"Connecting the account"
|
|
8113
|
+
);
|
|
8114
|
+
}
|
|
8115
|
+
async function connectCalDavAccount(client, body) {
|
|
8116
|
+
return take(
|
|
8117
|
+
await client.fetch.POST("/v1/calendar/accounts", {
|
|
8118
|
+
body: {
|
|
8119
|
+
profile_id: body.profile_id || null,
|
|
8120
|
+
url: body.url?.trim() || null,
|
|
8121
|
+
username: body.username.trim(),
|
|
8122
|
+
password: body.password,
|
|
8123
|
+
background_sync: !!body.background_sync
|
|
8124
|
+
}
|
|
8125
|
+
}),
|
|
8126
|
+
"Connecting the account"
|
|
8127
|
+
);
|
|
8128
|
+
}
|
|
8129
|
+
async function updateAccount(client, accId, backgroundSync) {
|
|
8130
|
+
return take(
|
|
8131
|
+
await client.fetch.PATCH("/v1/calendar/accounts/{acc_id}", {
|
|
8132
|
+
...accPath(accId),
|
|
8133
|
+
body: { background_sync: backgroundSync }
|
|
8134
|
+
}),
|
|
8135
|
+
"Saving the account"
|
|
8136
|
+
);
|
|
8137
|
+
}
|
|
8138
|
+
async function syncAccount(client, accId) {
|
|
8139
|
+
return take(
|
|
8140
|
+
await client.fetch.POST("/v1/calendar/accounts/{acc_id}/sync", accPath(accId)),
|
|
8141
|
+
"Syncing the account"
|
|
8142
|
+
);
|
|
8143
|
+
}
|
|
8144
|
+
async function disconnectAccount(client, accId) {
|
|
8145
|
+
take(
|
|
8146
|
+
await client.fetch.DELETE("/v1/calendar/accounts/{acc_id}", accPath(accId)),
|
|
8147
|
+
"Disconnecting the account"
|
|
8148
|
+
);
|
|
8149
|
+
}
|
|
8150
|
+
async function publishCalendarToAccount(client, accId, calendarId) {
|
|
8151
|
+
return take(
|
|
8152
|
+
await client.fetch.POST("/v1/calendar/accounts/{acc_id}/publish", {
|
|
8153
|
+
params: { path: { acc_id: accId }, query: { calendar_id: calendarId } }
|
|
8154
|
+
}),
|
|
8155
|
+
"Publishing the calendar"
|
|
8156
|
+
);
|
|
8157
|
+
}
|
|
8158
|
+
async function listAppPasswords(client) {
|
|
8159
|
+
return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
|
|
8160
|
+
}
|
|
8161
|
+
async function createAppPassword(client, body) {
|
|
8162
|
+
return take(
|
|
8163
|
+
await client.fetch.POST("/v1/calendar/app-passwords", {
|
|
8164
|
+
body: {
|
|
8165
|
+
label: body.label.trim(),
|
|
8166
|
+
calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
|
|
8167
|
+
}
|
|
8168
|
+
}),
|
|
8169
|
+
"Creating the app password"
|
|
8170
|
+
);
|
|
8171
|
+
}
|
|
8172
|
+
async function createFeed(client, body) {
|
|
8173
|
+
return take(
|
|
8174
|
+
await client.fetch.POST("/v1/calendar/feeds", {
|
|
8175
|
+
body: {
|
|
8176
|
+
calendar_id: body.calendar_id,
|
|
8177
|
+
level: body.level,
|
|
8178
|
+
label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
|
|
8179
|
+
}
|
|
8180
|
+
}),
|
|
8181
|
+
"Creating the feed"
|
|
8182
|
+
);
|
|
8183
|
+
}
|
|
8184
|
+
async function revokeAppPassword(client, apwId) {
|
|
8185
|
+
take(
|
|
8186
|
+
await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
|
|
8187
|
+
params: { path: { apw_id: apwId } }
|
|
8188
|
+
}),
|
|
8189
|
+
"Revoking"
|
|
8190
|
+
);
|
|
8191
|
+
}
|
|
8192
|
+
function splitAppPasswords(rows) {
|
|
8193
|
+
return {
|
|
8194
|
+
devices: rows.filter((r2) => r2.kind === "dav"),
|
|
8195
|
+
feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
|
|
8196
|
+
};
|
|
8197
|
+
}
|
|
8198
|
+
async function listBookingPages(client) {
|
|
8199
|
+
return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
|
|
8200
|
+
}
|
|
8201
|
+
async function putBookingPage(client, body) {
|
|
8202
|
+
return take(
|
|
8203
|
+
await client.fetch.PUT("/v1/calendar/booking-pages/{slug}", {
|
|
8204
|
+
params: { path: { slug: body.slug } },
|
|
8205
|
+
body
|
|
8206
|
+
}),
|
|
8207
|
+
"Saving the booking page"
|
|
8208
|
+
);
|
|
8209
|
+
}
|
|
8210
|
+
async function deleteBookingPage(client, slug) {
|
|
8211
|
+
take(
|
|
8212
|
+
await client.fetch.DELETE("/v1/calendar/booking-pages/{slug}", {
|
|
8213
|
+
params: { path: { slug } }
|
|
8214
|
+
}),
|
|
8215
|
+
"Deleting the booking page"
|
|
8216
|
+
);
|
|
8217
|
+
}
|
|
8218
|
+
var PublicBookingError = class extends Error {
|
|
8219
|
+
constructor(message, status) {
|
|
8220
|
+
super(message);
|
|
8221
|
+
this.status = status;
|
|
8222
|
+
this.name = "PublicBookingError";
|
|
8223
|
+
}
|
|
8224
|
+
status;
|
|
8225
|
+
};
|
|
8226
|
+
async function bookingError(res) {
|
|
8227
|
+
const body = await res.json().catch(() => null);
|
|
8228
|
+
return new PublicBookingError(
|
|
8229
|
+
apiErrorDetail(body) ?? `Request failed (${res.status})`,
|
|
8230
|
+
res.status
|
|
8231
|
+
);
|
|
8232
|
+
}
|
|
8233
|
+
var bookPath = (baseUrl, slug) => `${baseUrl}/v1/calendar/book/${encodeURIComponent(slug)}`;
|
|
8234
|
+
async function getPublicBookingPage(baseUrl, slug, opts = {}, signal) {
|
|
8235
|
+
const q2 = new URLSearchParams();
|
|
8236
|
+
if (opts.duration) q2.set("duration", String(opts.duration));
|
|
8237
|
+
if (opts.start) q2.set("start", opts.start);
|
|
8238
|
+
if (opts.days) q2.set("days", String(opts.days));
|
|
8239
|
+
const qs = q2.toString();
|
|
8240
|
+
const res = await fetch(`${bookPath(baseUrl, slug)}${qs ? `?${qs}` : ""}`, {
|
|
8241
|
+
headers: { Accept: "application/json" },
|
|
8242
|
+
signal
|
|
8243
|
+
});
|
|
8244
|
+
if (!res.ok) throw await bookingError(res);
|
|
8245
|
+
return await res.json();
|
|
8246
|
+
}
|
|
8247
|
+
async function bookPublicSlot(baseUrl, slug, body) {
|
|
8248
|
+
const res = await fetch(bookPath(baseUrl, slug), {
|
|
8249
|
+
method: "POST",
|
|
8250
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
8251
|
+
body: JSON.stringify({ ...body, note: body.note?.trim() || null })
|
|
8252
|
+
});
|
|
8253
|
+
if (!res.ok) throw await bookingError(res);
|
|
8254
|
+
return await res.json();
|
|
8255
|
+
}
|
|
8256
|
+
async function cancelPublicBooking(baseUrl, slug, token) {
|
|
8257
|
+
const res = await fetch(`${bookPath(baseUrl, slug)}/cancel?token=${encodeURIComponent(token)}`, {
|
|
8258
|
+
method: "POST"
|
|
8259
|
+
});
|
|
8260
|
+
if (!res.ok) throw await bookingError(res);
|
|
8261
|
+
}
|
|
8262
|
+
|
|
7720
8263
|
// src/arbi.ts
|
|
7721
8264
|
function tokenExpiresWithin(token, seconds) {
|
|
7722
8265
|
const payload = token?.split(".")[1];
|
|
@@ -8354,11 +8897,13 @@ var Arbi = class {
|
|
|
8354
8897
|
assistantMode
|
|
8355
8898
|
)
|
|
8356
8899
|
};
|
|
8357
|
-
/** Persisted notifications
|
|
8900
|
+
/** Persisted notifications (both the ones you received and the ones you sent), newest first;
|
|
8901
|
+
* new ones also arrive on the normal workspace WebSocket. */
|
|
8358
8902
|
notifications = {
|
|
8359
|
-
list: async (
|
|
8903
|
+
list: async (options = {}) => {
|
|
8904
|
+
const { type, limit = 100, offset } = options;
|
|
8360
8905
|
const { data, error } = await this.requireClient().fetch.GET("/v1/notifications/", {
|
|
8361
|
-
params: { query: { ...type ? { type } : {}, limit:
|
|
8906
|
+
params: { query: { ...type ? { type } : {}, limit, ...offset ? { offset } : {} } }
|
|
8362
8907
|
});
|
|
8363
8908
|
if (error) throw new ArbiError("Could not load notifications");
|
|
8364
8909
|
return data || [];
|
|
@@ -8369,6 +8914,11 @@ var Arbi = class {
|
|
|
8369
8914
|
body: { updates: ids.map((external_id) => ({ external_id, read: true })) }
|
|
8370
8915
|
});
|
|
8371
8916
|
if (error) throw new ArbiError("Could not mark notifications read");
|
|
8917
|
+
},
|
|
8918
|
+
/** Delete notifications for yourself (sender or recipient). */
|
|
8919
|
+
delete: async (ids) => {
|
|
8920
|
+
if (!ids.length) return;
|
|
8921
|
+
await deleteNotifications(this.requireClient(), ids);
|
|
8372
8922
|
}
|
|
8373
8923
|
};
|
|
8374
8924
|
/** Authenticated native Word transport, with normal session recovery. */
|
|
@@ -8526,15 +9076,96 @@ var Arbi = class {
|
|
|
8526
9076
|
generate: (tagIds, docIds) => generateDocTags(this.requireClient(), tagIds, docIds)
|
|
8527
9077
|
};
|
|
8528
9078
|
// ── Contacts ──────────────────────────────────────────────────────────
|
|
9079
|
+
// A card is sealed under its address book's key, which the calendar key bridge carries: without
|
|
9080
|
+
// it the server returns `card: null` and refuses card writes.
|
|
8529
9081
|
contacts = {
|
|
8530
|
-
list: () =>
|
|
9082
|
+
list: () => this.withCalendarKeys((c2) => listContacts(c2)),
|
|
8531
9083
|
invite: (emails) => inviteContacts(this.requireClient(), emails),
|
|
8532
|
-
create: (body) =>
|
|
8533
|
-
update: (contactId, card) =>
|
|
8534
|
-
delete: (contactId) =>
|
|
8535
|
-
search: (q2) =>
|
|
9084
|
+
create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
|
|
9085
|
+
update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
|
|
9086
|
+
delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
|
|
9087
|
+
search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
|
|
8536
9088
|
groupByStatus: groupContactsByStatus
|
|
8537
9089
|
};
|
|
9090
|
+
// ── Calendar ──────────────────────────────────────────────────────────
|
|
9091
|
+
/** The keys the calendar unlock needs; `null` before login (calendars then read as locked). */
|
|
9092
|
+
calendarKeys() {
|
|
9093
|
+
const login = this.loginResult;
|
|
9094
|
+
return login ? { signingPrivateKey: login.signingPrivateKey, serverSessionKey: login.serverSessionKey } : null;
|
|
9095
|
+
}
|
|
9096
|
+
/** Run `op` once this server session holds the calendar keys (unlocked once per session). */
|
|
9097
|
+
async withCalendarKeys(op) {
|
|
9098
|
+
const client = this.requireClient();
|
|
9099
|
+
await ensureCalendarUnlocked(client, this.calendarKeys());
|
|
9100
|
+
return op(client);
|
|
9101
|
+
}
|
|
9102
|
+
/**
|
|
9103
|
+
* The native calendar (`/v1/calendar`). Every content call first bridges the user's calendar
|
|
9104
|
+
* keys to the server session (once per session; see `calendarOps.ensureCalendarUnlocked`).
|
|
9105
|
+
*/
|
|
9106
|
+
calendar = {
|
|
9107
|
+
/** Bridge the calendar keys now; `force` again (keys that arrived since: a share, an invite). */
|
|
9108
|
+
unlock: (force = false) => ensureCalendarUnlocked(this.requireClient(), this.calendarKeys(), force),
|
|
9109
|
+
getSettings: () => this.withCalendarKeys((c2) => getCalendarSettings(c2)),
|
|
9110
|
+
putSettings: (body) => this.withCalendarKeys((c2) => putCalendarSettings(c2, body)),
|
|
9111
|
+
listCalendars: () => this.withCalendarKeys((c2) => listCalendars(c2, this.calendarKeys())),
|
|
9112
|
+
createCalendar: (body) => this.withCalendarKeys((c2) => createCalendar(c2, body)),
|
|
9113
|
+
updateCalendar: (calId, body) => this.withCalendarKeys((c2) => updateCalendar(c2, calId, body)),
|
|
9114
|
+
deleteCalendar: (calId) => this.withCalendarKeys((c2) => deleteCalendar(c2, calId)),
|
|
9115
|
+
exportCalendar: (calId) => this.withCalendarKeys((c2) => exportCalendarIcs(c2, calId)),
|
|
9116
|
+
importIcs: (ics, calendarId) => this.withCalendarKeys((c2) => importCalendarIcs(c2, ics, calendarId)),
|
|
9117
|
+
listEvents: (params) => this.withCalendarKeys((c2) => listEvents(c2, params)),
|
|
9118
|
+
getEvent: (evtId, recurrenceId) => this.withCalendarKeys((c2) => getEvent(c2, evtId, recurrenceId)),
|
|
9119
|
+
createEvent: (body) => this.withCalendarKeys((c2) => createEvent(c2, body)),
|
|
9120
|
+
updateEvent: (target, body) => this.withCalendarKeys((c2) => updateEvent(c2, target, body)),
|
|
9121
|
+
deleteEvent: (target) => this.withCalendarKeys((c2) => deleteEvent(c2, target)),
|
|
9122
|
+
moveEvent: (evtId, calendarId) => this.withCalendarKeys((c2) => moveEvent(c2, evtId, calendarId)),
|
|
9123
|
+
respond: (params) => this.withCalendarKeys((c2) => respondToEvent(c2, params)),
|
|
9124
|
+
eventIcs: (evtId) => this.withCalendarKeys((c2) => eventIcs(c2, evtId)),
|
|
9125
|
+
lookupByUid: (uid) => this.withCalendarKeys((c2) => lookupEventByUid(c2, uid)),
|
|
9126
|
+
/** The open workspace's overlay layers (not sealed: no unlock). */
|
|
9127
|
+
listOverlays: (range, layers) => listOverlays(this.requireClient(), range, layers),
|
|
9128
|
+
listShares: (calId) => this.withCalendarKeys((c2) => listShares(c2, calId)),
|
|
9129
|
+
share: (calId, grantee, role) => this.withCalendarKeys((c2) => shareCalendar(c2, calId, grantee, role)),
|
|
9130
|
+
/** Remove a grantee; the key it rotates is bridged again. */
|
|
9131
|
+
unshare: async (calId, grantee) => {
|
|
9132
|
+
await this.withCalendarKeys((c2) => unshareCalendar(c2, calId, grantee));
|
|
9133
|
+
await this.calendar.unlock(true);
|
|
9134
|
+
},
|
|
9135
|
+
subscribe: (body) => this.withCalendarKeys((c2) => subscribeCalendar(c2, body)),
|
|
9136
|
+
refresh: (calId) => this.withCalendarKeys((c2) => refreshCalendar(c2, calId)),
|
|
9137
|
+
listHolidayCountries: () => this.withCalendarKeys((c2) => listHolidayCountries(c2)),
|
|
9138
|
+
addHolidays: (body) => this.withCalendarKeys((c2) => addHolidayCalendar(c2, body)),
|
|
9139
|
+
createRoom: (body) => this.withCalendarKeys((c2) => createRoom(c2, body)),
|
|
9140
|
+
listRooms: (query) => this.withCalendarKeys((c2) => listRooms(c2, query)),
|
|
9141
|
+
freeBusy: (body) => this.withCalendarKeys((c2) => getFreeBusy(c2, body)),
|
|
9142
|
+
findTime: (body) => this.withCalendarKeys((c2) => findTime(c2, body)),
|
|
9143
|
+
/**
|
|
9144
|
+
* Invitations and proposals waiting for me. A new one arrives with its own key: bridge again
|
|
9145
|
+
* first, or an open tab would not see it until it reloaded.
|
|
9146
|
+
*/
|
|
9147
|
+
listInvitations: async () => {
|
|
9148
|
+
await this.calendar.unlock(true);
|
|
9149
|
+
return listInvitations(this.requireClient());
|
|
9150
|
+
},
|
|
9151
|
+
decideCounter: (itpId, accept, comment) => this.withCalendarKeys((c2) => decideCounter(c2, itpId, accept, comment)),
|
|
9152
|
+
peopleKeys: (body) => this.withCalendarKeys((c2) => lookupPeopleKeys(c2, body)),
|
|
9153
|
+
listAccounts: () => this.withCalendarKeys((c2) => listAccounts(c2)),
|
|
9154
|
+
listCalDavProfiles: () => this.withCalendarKeys((c2) => listCalDavProfiles(c2)),
|
|
9155
|
+
connectOAuthAccount: (kind, backgroundSync = false) => this.withCalendarKeys((c2) => connectOAuthAccount(c2, kind, backgroundSync)),
|
|
9156
|
+
connectCalDavAccount: (body) => this.withCalendarKeys((c2) => connectCalDavAccount(c2, body)),
|
|
9157
|
+
updateAccount: (accId, backgroundSync) => this.withCalendarKeys((c2) => updateAccount(c2, accId, backgroundSync)),
|
|
9158
|
+
syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
|
|
9159
|
+
disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
|
|
9160
|
+
publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
|
|
9161
|
+
listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
|
|
9162
|
+
createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
|
|
9163
|
+
createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
|
|
9164
|
+
revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
|
|
9165
|
+
listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
|
|
9166
|
+
putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
|
|
9167
|
+
deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
|
|
9168
|
+
};
|
|
8538
9169
|
// ── Chats (direct + group) ────────────────────────────────────────────
|
|
8539
9170
|
/**
|
|
8540
9171
|
* Build (and cache) the chat crypto context for the current session: my X25519 keypair
|
|
@@ -8787,23 +9418,28 @@ var Arbi = class {
|
|
|
8787
9418
|
}
|
|
8788
9419
|
};
|
|
8789
9420
|
|
|
9421
|
+
exports.ACCOUNT_VENDOR = ACCOUNT_VENDOR;
|
|
8790
9422
|
exports.Arbi = Arbi;
|
|
8791
9423
|
exports.ArbiApiError = ArbiApiError;
|
|
8792
9424
|
exports.ArbiError = ArbiError;
|
|
8793
9425
|
exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
|
|
8794
9426
|
exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
|
|
8795
9427
|
exports.PlanStepsError = PlanStepsError;
|
|
9428
|
+
exports.PublicBookingError = PublicBookingError;
|
|
8796
9429
|
exports.TAG_KINDS = TAG_KINDS;
|
|
8797
9430
|
exports.WebSocketAuthError = WebSocketAuthError;
|
|
8798
9431
|
exports.account = account_exports;
|
|
8799
9432
|
exports.agentconfig = agentconfig_exports;
|
|
8800
9433
|
exports.assistant = assistant_exports;
|
|
8801
9434
|
exports.authenticatedFetch = authenticatedFetch;
|
|
9435
|
+
exports.bookPublicSlot = bookPublicSlot;
|
|
8802
9436
|
exports.buildCitationChunkData = buildCitationChunkData;
|
|
8803
9437
|
exports.buildFactsContextTool = buildFactsContextTool;
|
|
8804
9438
|
exports.buildRetrievalChunkTool = buildRetrievalChunkTool;
|
|
8805
9439
|
exports.buildRetrievalFullContextTool = buildRetrievalFullContextTool;
|
|
8806
9440
|
exports.buildRetrievalTocTool = buildRetrievalTocTool;
|
|
9441
|
+
exports.calendar = calendar_exports;
|
|
9442
|
+
exports.cancelPublicBooking = cancelPublicBooking;
|
|
8807
9443
|
exports.chats = chats_exports;
|
|
8808
9444
|
exports.connectWebSocket = connectWebSocket;
|
|
8809
9445
|
exports.connectWithReconnect = connectWithReconnect;
|
|
@@ -8825,6 +9461,7 @@ exports.formatItemLabel = formatItemLabel;
|
|
|
8825
9461
|
exports.formatUserName = formatUserName;
|
|
8826
9462
|
exports.formatWorkspaceChoices = formatWorkspaceChoices;
|
|
8827
9463
|
exports.getErrorMessage = getErrorMessage;
|
|
9464
|
+
exports.getPublicBookingPage = getPublicBookingPage;
|
|
8828
9465
|
exports.getRawWorkspaceKey = getRawWorkspaceKey;
|
|
8829
9466
|
exports.health = health_exports;
|
|
8830
9467
|
exports.identityErrorCode = identityErrorCode;
|
|
@@ -8847,6 +9484,7 @@ exports.selectWorkspace = selectWorkspace;
|
|
|
8847
9484
|
exports.selectWorkspaceById = selectWorkspaceById;
|
|
8848
9485
|
exports.sessions = sessions_exports;
|
|
8849
9486
|
exports.settings = settings_exports;
|
|
9487
|
+
exports.splitAppPasswords = splitAppPasswords;
|
|
8850
9488
|
exports.streamSSE = streamSSE;
|
|
8851
9489
|
exports.stripCitationMarkdown = stripCitationMarkdown;
|
|
8852
9490
|
exports.summarizeCitations = summarizeCitations;
|