@arbidocs/sdk 0.4.138 → 0.4.139
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/index.cjs
CHANGED
|
@@ -8313,6 +8313,549 @@ function bytesToBase643(bytes) {
|
|
|
8313
8313
|
return btoa(binary);
|
|
8314
8314
|
}
|
|
8315
8315
|
|
|
8316
|
+
// src/operations/calendar.ts
|
|
8317
|
+
var calendar_exports = {};
|
|
8318
|
+
__export(calendar_exports, {
|
|
8319
|
+
ACCOUNT_VENDOR: () => ACCOUNT_VENDOR,
|
|
8320
|
+
PublicBookingError: () => PublicBookingError,
|
|
8321
|
+
addHolidayCalendar: () => addHolidayCalendar,
|
|
8322
|
+
bookPublicSlot: () => bookPublicSlot,
|
|
8323
|
+
cancelPublicBooking: () => cancelPublicBooking,
|
|
8324
|
+
connectCalDavAccount: () => connectCalDavAccount,
|
|
8325
|
+
connectOAuthAccount: () => connectOAuthAccount,
|
|
8326
|
+
createAppPassword: () => createAppPassword,
|
|
8327
|
+
createCalendar: () => createCalendar,
|
|
8328
|
+
createEvent: () => createEvent,
|
|
8329
|
+
createFeed: () => createFeed,
|
|
8330
|
+
createRoom: () => createRoom,
|
|
8331
|
+
decideCounter: () => decideCounter,
|
|
8332
|
+
deleteBookingPage: () => deleteBookingPage,
|
|
8333
|
+
deleteCalendar: () => deleteCalendar,
|
|
8334
|
+
deleteEvent: () => deleteEvent,
|
|
8335
|
+
disconnectAccount: () => disconnectAccount,
|
|
8336
|
+
ensureCalendarUnlocked: () => ensureCalendarUnlocked,
|
|
8337
|
+
eventIcs: () => eventIcs,
|
|
8338
|
+
exportCalendarIcs: () => exportCalendarIcs,
|
|
8339
|
+
findTime: () => findTime,
|
|
8340
|
+
getCalendarSettings: () => getCalendarSettings,
|
|
8341
|
+
getEvent: () => getEvent,
|
|
8342
|
+
getFreeBusy: () => getFreeBusy,
|
|
8343
|
+
getPublicBookingPage: () => getPublicBookingPage,
|
|
8344
|
+
importCalendarIcs: () => importCalendarIcs,
|
|
8345
|
+
listAccounts: () => listAccounts,
|
|
8346
|
+
listAppPasswords: () => listAppPasswords,
|
|
8347
|
+
listBookingPages: () => listBookingPages,
|
|
8348
|
+
listCalDavProfiles: () => listCalDavProfiles,
|
|
8349
|
+
listCalendars: () => listCalendars,
|
|
8350
|
+
listEvents: () => listEvents,
|
|
8351
|
+
listHolidayCountries: () => listHolidayCountries,
|
|
8352
|
+
listInvitations: () => listInvitations,
|
|
8353
|
+
listOverlays: () => listOverlays,
|
|
8354
|
+
listRooms: () => listRooms,
|
|
8355
|
+
listShares: () => listShares,
|
|
8356
|
+
lookupEventByUid: () => lookupEventByUid,
|
|
8357
|
+
lookupPeopleKeys: () => lookupPeopleKeys,
|
|
8358
|
+
moveEvent: () => moveEvent,
|
|
8359
|
+
publishCalendarToAccount: () => publishCalendarToAccount,
|
|
8360
|
+
putBookingPage: () => putBookingPage,
|
|
8361
|
+
putCalendarSettings: () => putCalendarSettings,
|
|
8362
|
+
refreshCalendar: () => refreshCalendar,
|
|
8363
|
+
respondToEvent: () => respondToEvent,
|
|
8364
|
+
revokeAppPassword: () => revokeAppPassword,
|
|
8365
|
+
shareCalendar: () => shareCalendar,
|
|
8366
|
+
splitAppPasswords: () => splitAppPasswords,
|
|
8367
|
+
subscribeCalendar: () => subscribeCalendar,
|
|
8368
|
+
syncAccount: () => syncAccount,
|
|
8369
|
+
unlockCalendarKeys: () => unlockCalendarKeys,
|
|
8370
|
+
unshareCalendar: () => unshareCalendar,
|
|
8371
|
+
updateAccount: () => updateAccount,
|
|
8372
|
+
updateCalendar: () => updateCalendar,
|
|
8373
|
+
updateEvent: () => updateEvent
|
|
8374
|
+
});
|
|
8375
|
+
var ACCOUNT_VENDOR = {
|
|
8376
|
+
google: "google_calendar",
|
|
8377
|
+
microsoft: "microsoft"
|
|
8378
|
+
};
|
|
8379
|
+
function take(result, what) {
|
|
8380
|
+
if (result.error !== void 0 || !result.response.ok) {
|
|
8381
|
+
const status = result.response.status;
|
|
8382
|
+
throw new ArbiApiError(
|
|
8383
|
+
apiErrorDetail(result.error) ?? `${what} failed (${status})`,
|
|
8384
|
+
result.error,
|
|
8385
|
+
status
|
|
8386
|
+
);
|
|
8387
|
+
}
|
|
8388
|
+
return result.data;
|
|
8389
|
+
}
|
|
8390
|
+
async function unlockCalendarKeys(client$1, keys) {
|
|
8391
|
+
await client.initSodium();
|
|
8392
|
+
const keypair = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey);
|
|
8393
|
+
try {
|
|
8394
|
+
const page = take(await client$1.fetch.GET("/v1/calendar/keys"), "Reading the calendar keys");
|
|
8395
|
+
const sealed = {};
|
|
8396
|
+
for (const [id, wrapped] of Object.entries(page?.keys ?? {})) {
|
|
8397
|
+
const key = client.sealedBoxDecrypt(wrapped, keypair.secretKey);
|
|
8398
|
+
try {
|
|
8399
|
+
sealed[id] = await client.sealKeyForSession(key, keys.serverSessionKey);
|
|
8400
|
+
} finally {
|
|
8401
|
+
key.fill(0);
|
|
8402
|
+
}
|
|
8403
|
+
}
|
|
8404
|
+
if (Object.keys(sealed).length)
|
|
8405
|
+
take(
|
|
8406
|
+
await client$1.fetch.POST("/v1/calendar/session-keys", { body: { keys: sealed } }),
|
|
8407
|
+
"Unlocking the calendar"
|
|
8408
|
+
);
|
|
8409
|
+
} finally {
|
|
8410
|
+
keypair.secretKey.fill(0);
|
|
8411
|
+
}
|
|
8412
|
+
}
|
|
8413
|
+
var unlockStates = /* @__PURE__ */ new WeakMap();
|
|
8414
|
+
function unlockState(keys) {
|
|
8415
|
+
let state = unlockStates.get(keys.serverSessionKey);
|
|
8416
|
+
if (!state) {
|
|
8417
|
+
state = { done: false, running: null, attemptedLocked: /* @__PURE__ */ new Set() };
|
|
8418
|
+
unlockStates.set(keys.serverSessionKey, state);
|
|
8419
|
+
}
|
|
8420
|
+
return state;
|
|
8421
|
+
}
|
|
8422
|
+
async function ensureCalendarUnlocked(client, keys, force = false) {
|
|
8423
|
+
if (!keys) return;
|
|
8424
|
+
const state = unlockState(keys);
|
|
8425
|
+
if (!force && state.done) return;
|
|
8426
|
+
state.running ??= unlockCalendarKeys(client, keys).then(() => {
|
|
8427
|
+
state.done = true;
|
|
8428
|
+
}).finally(() => {
|
|
8429
|
+
state.running = null;
|
|
8430
|
+
});
|
|
8431
|
+
try {
|
|
8432
|
+
await state.running;
|
|
8433
|
+
} catch (err) {
|
|
8434
|
+
console.warn("Calendar keys could not be unlocked", err);
|
|
8435
|
+
}
|
|
8436
|
+
}
|
|
8437
|
+
var calPath = (calId) => ({ params: { path: { cal_id: calId } } });
|
|
8438
|
+
var evtPath = (evtId) => ({ path: { evt_id: evtId } });
|
|
8439
|
+
async function getCalendarSettings(client) {
|
|
8440
|
+
return take(await client.fetch.GET("/v1/calendar/settings"), "Loading calendar settings");
|
|
8441
|
+
}
|
|
8442
|
+
async function putCalendarSettings(client, body) {
|
|
8443
|
+
return take(
|
|
8444
|
+
await client.fetch.PUT("/v1/calendar/settings", { body }),
|
|
8445
|
+
"Saving calendar settings"
|
|
8446
|
+
);
|
|
8447
|
+
}
|
|
8448
|
+
async function listCalendars(client, keys) {
|
|
8449
|
+
const read = async () => take(await client.fetch.GET("/v1/calendar/calendars"), "Loading calendars");
|
|
8450
|
+
const calendars = await read();
|
|
8451
|
+
if (!keys) return calendars;
|
|
8452
|
+
const state = unlockState(keys);
|
|
8453
|
+
const fresh = calendars.filter((c2) => c2.locked && !state.attemptedLocked.has(c2.id));
|
|
8454
|
+
if (!fresh.length) return calendars;
|
|
8455
|
+
for (const c2 of fresh) state.attemptedLocked.add(c2.id);
|
|
8456
|
+
await ensureCalendarUnlocked(client, keys, true);
|
|
8457
|
+
return read();
|
|
8458
|
+
}
|
|
8459
|
+
async function createCalendar(client, body) {
|
|
8460
|
+
return take(
|
|
8461
|
+
await client.fetch.POST("/v1/calendar/calendars", { body }),
|
|
8462
|
+
"Creating the calendar"
|
|
8463
|
+
);
|
|
8464
|
+
}
|
|
8465
|
+
async function updateCalendar(client, calId, body) {
|
|
8466
|
+
return take(
|
|
8467
|
+
await client.fetch.PATCH("/v1/calendar/calendars/{cal_id}", { ...calPath(calId), body }),
|
|
8468
|
+
"Saving the calendar"
|
|
8469
|
+
);
|
|
8470
|
+
}
|
|
8471
|
+
async function deleteCalendar(client, calId) {
|
|
8472
|
+
take(
|
|
8473
|
+
await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}", calPath(calId)),
|
|
8474
|
+
"Deleting the calendar"
|
|
8475
|
+
);
|
|
8476
|
+
}
|
|
8477
|
+
async function exportCalendarIcs(client, calId) {
|
|
8478
|
+
return take(
|
|
8479
|
+
await client.fetch.GET("/v1/calendar/calendars/{cal_id}/export.ics", {
|
|
8480
|
+
...calPath(calId),
|
|
8481
|
+
parseAs: "blob"
|
|
8482
|
+
}),
|
|
8483
|
+
"Exporting the calendar"
|
|
8484
|
+
);
|
|
8485
|
+
}
|
|
8486
|
+
async function importCalendarIcs(client, ics, calendarId) {
|
|
8487
|
+
return take(
|
|
8488
|
+
await client.fetch.POST("/v1/calendar/import", {
|
|
8489
|
+
body: { ics, calendar_id: calendarId ?? null }
|
|
8490
|
+
}),
|
|
8491
|
+
"Importing"
|
|
8492
|
+
);
|
|
8493
|
+
}
|
|
8494
|
+
async function listEvents(client, { start, end, calendars }) {
|
|
8495
|
+
return take(
|
|
8496
|
+
await client.fetch.GET("/v1/calendar/events", {
|
|
8497
|
+
params: {
|
|
8498
|
+
query: { start, end, calendars: calendars?.length ? calendars.join(",") : void 0 }
|
|
8499
|
+
}
|
|
8500
|
+
}),
|
|
8501
|
+
"Loading events"
|
|
8502
|
+
);
|
|
8503
|
+
}
|
|
8504
|
+
async function getEvent(client, evtId, recurrenceId) {
|
|
8505
|
+
return take(
|
|
8506
|
+
await client.fetch.GET("/v1/calendar/events/{evt_id}", {
|
|
8507
|
+
params: { ...evtPath(evtId), query: { recurrence_id: recurrenceId ?? void 0 } }
|
|
8508
|
+
}),
|
|
8509
|
+
"Loading the event"
|
|
8510
|
+
);
|
|
8511
|
+
}
|
|
8512
|
+
async function createEvent(client, body) {
|
|
8513
|
+
return take(
|
|
8514
|
+
await client.fetch.POST("/v1/calendar/events", { body }),
|
|
8515
|
+
"Saving the event"
|
|
8516
|
+
);
|
|
8517
|
+
}
|
|
8518
|
+
async function updateEvent(client, target, body) {
|
|
8519
|
+
return take(
|
|
8520
|
+
await client.fetch.PATCH("/v1/calendar/events/{evt_id}", {
|
|
8521
|
+
params: {
|
|
8522
|
+
...evtPath(target.id),
|
|
8523
|
+
query: { scope: target.scope, recurrence_id: target.recurrence_id ?? void 0 }
|
|
8524
|
+
},
|
|
8525
|
+
body
|
|
8526
|
+
}),
|
|
8527
|
+
"Saving the event"
|
|
8528
|
+
);
|
|
8529
|
+
}
|
|
8530
|
+
async function deleteEvent(client, target) {
|
|
8531
|
+
take(
|
|
8532
|
+
await client.fetch.DELETE("/v1/calendar/events/{evt_id}", {
|
|
8533
|
+
params: {
|
|
8534
|
+
...evtPath(target.id),
|
|
8535
|
+
query: {
|
|
8536
|
+
scope: target.scope,
|
|
8537
|
+
recurrence_id: target.recurrence_id ?? void 0,
|
|
8538
|
+
notify: target.notify
|
|
8539
|
+
}
|
|
8540
|
+
}
|
|
8541
|
+
}),
|
|
8542
|
+
"Deleting the event"
|
|
8543
|
+
);
|
|
8544
|
+
}
|
|
8545
|
+
async function moveEvent(client, evtId, calendarId) {
|
|
8546
|
+
return take(
|
|
8547
|
+
await client.fetch.POST("/v1/calendar/events/{evt_id}/move", {
|
|
8548
|
+
params: evtPath(evtId),
|
|
8549
|
+
body: { calendar_id: calendarId }
|
|
8550
|
+
}),
|
|
8551
|
+
"Moving the event"
|
|
8552
|
+
);
|
|
8553
|
+
}
|
|
8554
|
+
async function respondToEvent(client, { id, ...body }) {
|
|
8555
|
+
return take(
|
|
8556
|
+
await client.fetch.POST("/v1/calendar/events/{evt_id}/respond", {
|
|
8557
|
+
params: evtPath(id),
|
|
8558
|
+
body: { scope: "all", notify: true, ...body }
|
|
8559
|
+
}),
|
|
8560
|
+
"Sending your response"
|
|
8561
|
+
);
|
|
8562
|
+
}
|
|
8563
|
+
async function eventIcs(client, evtId) {
|
|
8564
|
+
return take(
|
|
8565
|
+
await client.fetch.GET("/v1/calendar/events/{evt_id}/ics", {
|
|
8566
|
+
params: evtPath(evtId),
|
|
8567
|
+
parseAs: "blob"
|
|
8568
|
+
}),
|
|
8569
|
+
"Downloading the event"
|
|
8570
|
+
);
|
|
8571
|
+
}
|
|
8572
|
+
async function lookupEventByUid(client, uid) {
|
|
8573
|
+
try {
|
|
8574
|
+
return take(
|
|
8575
|
+
await client.fetch.GET("/v1/calendar/lookup", { params: { query: { uid } } }),
|
|
8576
|
+
"Looking up the event"
|
|
8577
|
+
);
|
|
8578
|
+
} catch (err) {
|
|
8579
|
+
if (err instanceof ArbiApiError && err.status === 404) return null;
|
|
8580
|
+
throw err;
|
|
8581
|
+
}
|
|
8582
|
+
}
|
|
8583
|
+
async function listOverlays(client, range, layers) {
|
|
8584
|
+
return take(
|
|
8585
|
+
await client.fetch.GET("/v1/calendar/overlays", {
|
|
8586
|
+
params: { query: { start: range.start, end: range.end, layers: layers.join(",") } }
|
|
8587
|
+
}),
|
|
8588
|
+
"Loading the overlays"
|
|
8589
|
+
);
|
|
8590
|
+
}
|
|
8591
|
+
async function listShares(client, calId) {
|
|
8592
|
+
return take(
|
|
8593
|
+
await client.fetch.GET("/v1/calendar/calendars/{cal_id}/shares", calPath(calId)),
|
|
8594
|
+
"Loading the shares"
|
|
8595
|
+
);
|
|
8596
|
+
}
|
|
8597
|
+
async function shareCalendar(client, calId, grantee, role) {
|
|
8598
|
+
return take(
|
|
8599
|
+
await client.fetch.PUT("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
|
|
8600
|
+
params: { path: { cal_id: calId, grantee } },
|
|
8601
|
+
body: { role }
|
|
8602
|
+
}),
|
|
8603
|
+
"Sharing the calendar"
|
|
8604
|
+
);
|
|
8605
|
+
}
|
|
8606
|
+
async function unshareCalendar(client, calId, grantee) {
|
|
8607
|
+
take(
|
|
8608
|
+
await client.fetch.DELETE("/v1/calendar/calendars/{cal_id}/shares/{grantee}", {
|
|
8609
|
+
params: { path: { cal_id: calId, grantee } }
|
|
8610
|
+
}),
|
|
8611
|
+
"Removing the share"
|
|
8612
|
+
);
|
|
8613
|
+
}
|
|
8614
|
+
async function subscribeCalendar(client, body) {
|
|
8615
|
+
return take(
|
|
8616
|
+
await client.fetch.POST("/v1/calendar/subscriptions", {
|
|
8617
|
+
body
|
|
8618
|
+
}),
|
|
8619
|
+
"Subscribing"
|
|
8620
|
+
);
|
|
8621
|
+
}
|
|
8622
|
+
async function refreshCalendar(client, calId) {
|
|
8623
|
+
return take(
|
|
8624
|
+
await client.fetch.POST("/v1/calendar/calendars/{cal_id}/refresh", calPath(calId)),
|
|
8625
|
+
"Refreshing the calendar"
|
|
8626
|
+
);
|
|
8627
|
+
}
|
|
8628
|
+
async function listHolidayCountries(client) {
|
|
8629
|
+
return take(
|
|
8630
|
+
await client.fetch.GET("/v1/calendar/holidays/countries"),
|
|
8631
|
+
"Loading holiday countries"
|
|
8632
|
+
);
|
|
8633
|
+
}
|
|
8634
|
+
async function addHolidayCalendar(client, body) {
|
|
8635
|
+
return take(
|
|
8636
|
+
await client.fetch.POST("/v1/calendar/holidays", {
|
|
8637
|
+
body
|
|
8638
|
+
}),
|
|
8639
|
+
"Adding holidays"
|
|
8640
|
+
);
|
|
8641
|
+
}
|
|
8642
|
+
async function createRoom(client, body) {
|
|
8643
|
+
return take(
|
|
8644
|
+
await client.fetch.POST("/v1/calendar/rooms", { body }),
|
|
8645
|
+
"Adding the room"
|
|
8646
|
+
);
|
|
8647
|
+
}
|
|
8648
|
+
async function listRooms(client, q2 = {}) {
|
|
8649
|
+
return take(
|
|
8650
|
+
await client.fetch.GET("/v1/calendar/rooms", {
|
|
8651
|
+
params: {
|
|
8652
|
+
query: {
|
|
8653
|
+
start: q2.start,
|
|
8654
|
+
end: q2.end,
|
|
8655
|
+
min_capacity: q2.min_capacity || void 0,
|
|
8656
|
+
feature: q2.feature?.length ? q2.feature : void 0,
|
|
8657
|
+
building: q2.building || void 0
|
|
8658
|
+
}
|
|
8659
|
+
}
|
|
8660
|
+
}),
|
|
8661
|
+
"Loading rooms"
|
|
8662
|
+
);
|
|
8663
|
+
}
|
|
8664
|
+
async function getFreeBusy(client, body) {
|
|
8665
|
+
return take(await client.fetch.POST("/v1/calendar/freebusy", { body }), "Loading free/busy");
|
|
8666
|
+
}
|
|
8667
|
+
async function findTime(client, body) {
|
|
8668
|
+
return take(
|
|
8669
|
+
await client.fetch.POST("/v1/calendar/find-time", {
|
|
8670
|
+
body
|
|
8671
|
+
}),
|
|
8672
|
+
"Finding a time"
|
|
8673
|
+
);
|
|
8674
|
+
}
|
|
8675
|
+
async function listInvitations(client) {
|
|
8676
|
+
return take(await client.fetch.GET("/v1/calendar/invitations"), "Loading invitations");
|
|
8677
|
+
}
|
|
8678
|
+
async function decideCounter(client, itpId, accept, comment) {
|
|
8679
|
+
return take(
|
|
8680
|
+
await client.fetch.POST("/v1/calendar/invitations/{itp_id}/decide", {
|
|
8681
|
+
params: { path: { itp_id: itpId } },
|
|
8682
|
+
body: { accept, comment: comment ?? null }
|
|
8683
|
+
}),
|
|
8684
|
+
"Answering the proposal"
|
|
8685
|
+
);
|
|
8686
|
+
}
|
|
8687
|
+
async function lookupPeopleKeys(client, body) {
|
|
8688
|
+
return take(
|
|
8689
|
+
await client.fetch.POST("/v1/calendar/people/keys", {
|
|
8690
|
+
body
|
|
8691
|
+
}),
|
|
8692
|
+
"Looking up people"
|
|
8693
|
+
);
|
|
8694
|
+
}
|
|
8695
|
+
var accPath = (accId) => ({ params: { path: { acc_id: accId } } });
|
|
8696
|
+
async function listAccounts(client) {
|
|
8697
|
+
return take(await client.fetch.GET("/v1/calendar/accounts"), "Loading calendar accounts");
|
|
8698
|
+
}
|
|
8699
|
+
async function listCalDavProfiles(client) {
|
|
8700
|
+
return take(await client.fetch.GET("/v1/calendar/caldav/profiles"), "Loading CalDAV servers");
|
|
8701
|
+
}
|
|
8702
|
+
async function connectOAuthAccount(client, kind, backgroundSync = false) {
|
|
8703
|
+
return take(
|
|
8704
|
+
await client.fetch.POST("/v1/calendar/accounts/{kind}", {
|
|
8705
|
+
params: { path: { kind } },
|
|
8706
|
+
body: { background_sync: backgroundSync }
|
|
8707
|
+
}),
|
|
8708
|
+
"Connecting the account"
|
|
8709
|
+
);
|
|
8710
|
+
}
|
|
8711
|
+
async function connectCalDavAccount(client, body) {
|
|
8712
|
+
return take(
|
|
8713
|
+
await client.fetch.POST("/v1/calendar/accounts", {
|
|
8714
|
+
body: {
|
|
8715
|
+
profile_id: body.profile_id || null,
|
|
8716
|
+
url: body.url?.trim() || null,
|
|
8717
|
+
username: body.username.trim(),
|
|
8718
|
+
password: body.password,
|
|
8719
|
+
background_sync: !!body.background_sync
|
|
8720
|
+
}
|
|
8721
|
+
}),
|
|
8722
|
+
"Connecting the account"
|
|
8723
|
+
);
|
|
8724
|
+
}
|
|
8725
|
+
async function updateAccount(client, accId, backgroundSync) {
|
|
8726
|
+
return take(
|
|
8727
|
+
await client.fetch.PATCH("/v1/calendar/accounts/{acc_id}", {
|
|
8728
|
+
...accPath(accId),
|
|
8729
|
+
body: { background_sync: backgroundSync }
|
|
8730
|
+
}),
|
|
8731
|
+
"Saving the account"
|
|
8732
|
+
);
|
|
8733
|
+
}
|
|
8734
|
+
async function syncAccount(client, accId) {
|
|
8735
|
+
return take(
|
|
8736
|
+
await client.fetch.POST("/v1/calendar/accounts/{acc_id}/sync", accPath(accId)),
|
|
8737
|
+
"Syncing the account"
|
|
8738
|
+
);
|
|
8739
|
+
}
|
|
8740
|
+
async function disconnectAccount(client, accId) {
|
|
8741
|
+
take(
|
|
8742
|
+
await client.fetch.DELETE("/v1/calendar/accounts/{acc_id}", accPath(accId)),
|
|
8743
|
+
"Disconnecting the account"
|
|
8744
|
+
);
|
|
8745
|
+
}
|
|
8746
|
+
async function publishCalendarToAccount(client, accId, calendarId) {
|
|
8747
|
+
return take(
|
|
8748
|
+
await client.fetch.POST("/v1/calendar/accounts/{acc_id}/publish", {
|
|
8749
|
+
params: { path: { acc_id: accId }, query: { calendar_id: calendarId } }
|
|
8750
|
+
}),
|
|
8751
|
+
"Publishing the calendar"
|
|
8752
|
+
);
|
|
8753
|
+
}
|
|
8754
|
+
async function listAppPasswords(client) {
|
|
8755
|
+
return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
|
|
8756
|
+
}
|
|
8757
|
+
async function createAppPassword(client, body) {
|
|
8758
|
+
return take(
|
|
8759
|
+
await client.fetch.POST("/v1/calendar/app-passwords", {
|
|
8760
|
+
body: {
|
|
8761
|
+
label: body.label.trim(),
|
|
8762
|
+
calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
|
|
8763
|
+
}
|
|
8764
|
+
}),
|
|
8765
|
+
"Creating the app password"
|
|
8766
|
+
);
|
|
8767
|
+
}
|
|
8768
|
+
async function createFeed(client, body) {
|
|
8769
|
+
return take(
|
|
8770
|
+
await client.fetch.POST("/v1/calendar/feeds", {
|
|
8771
|
+
body: {
|
|
8772
|
+
calendar_id: body.calendar_id,
|
|
8773
|
+
level: body.level,
|
|
8774
|
+
label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
|
|
8775
|
+
}
|
|
8776
|
+
}),
|
|
8777
|
+
"Creating the feed"
|
|
8778
|
+
);
|
|
8779
|
+
}
|
|
8780
|
+
async function revokeAppPassword(client, apwId) {
|
|
8781
|
+
take(
|
|
8782
|
+
await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
|
|
8783
|
+
params: { path: { apw_id: apwId } }
|
|
8784
|
+
}),
|
|
8785
|
+
"Revoking"
|
|
8786
|
+
);
|
|
8787
|
+
}
|
|
8788
|
+
function splitAppPasswords(rows) {
|
|
8789
|
+
return {
|
|
8790
|
+
devices: rows.filter((r2) => r2.kind === "dav"),
|
|
8791
|
+
feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
|
|
8792
|
+
};
|
|
8793
|
+
}
|
|
8794
|
+
async function listBookingPages(client) {
|
|
8795
|
+
return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
|
|
8796
|
+
}
|
|
8797
|
+
async function putBookingPage(client, body) {
|
|
8798
|
+
return take(
|
|
8799
|
+
await client.fetch.PUT("/v1/calendar/booking-pages/{slug}", {
|
|
8800
|
+
params: { path: { slug: body.slug } },
|
|
8801
|
+
body
|
|
8802
|
+
}),
|
|
8803
|
+
"Saving the booking page"
|
|
8804
|
+
);
|
|
8805
|
+
}
|
|
8806
|
+
async function deleteBookingPage(client, slug) {
|
|
8807
|
+
take(
|
|
8808
|
+
await client.fetch.DELETE("/v1/calendar/booking-pages/{slug}", {
|
|
8809
|
+
params: { path: { slug } }
|
|
8810
|
+
}),
|
|
8811
|
+
"Deleting the booking page"
|
|
8812
|
+
);
|
|
8813
|
+
}
|
|
8814
|
+
var PublicBookingError = class extends Error {
|
|
8815
|
+
constructor(message, status) {
|
|
8816
|
+
super(message);
|
|
8817
|
+
this.status = status;
|
|
8818
|
+
this.name = "PublicBookingError";
|
|
8819
|
+
}
|
|
8820
|
+
status;
|
|
8821
|
+
};
|
|
8822
|
+
async function bookingError(res) {
|
|
8823
|
+
const body = await res.json().catch(() => null);
|
|
8824
|
+
return new PublicBookingError(
|
|
8825
|
+
apiErrorDetail(body) ?? `Request failed (${res.status})`,
|
|
8826
|
+
res.status
|
|
8827
|
+
);
|
|
8828
|
+
}
|
|
8829
|
+
var bookPath = (baseUrl, slug) => `${baseUrl}/v1/calendar/book/${encodeURIComponent(slug)}`;
|
|
8830
|
+
async function getPublicBookingPage(baseUrl, slug, opts = {}, signal) {
|
|
8831
|
+
const q2 = new URLSearchParams();
|
|
8832
|
+
if (opts.duration) q2.set("duration", String(opts.duration));
|
|
8833
|
+
if (opts.start) q2.set("start", opts.start);
|
|
8834
|
+
if (opts.days) q2.set("days", String(opts.days));
|
|
8835
|
+
const qs = q2.toString();
|
|
8836
|
+
const res = await fetch(`${bookPath(baseUrl, slug)}${qs ? `?${qs}` : ""}`, {
|
|
8837
|
+
headers: { Accept: "application/json" },
|
|
8838
|
+
signal
|
|
8839
|
+
});
|
|
8840
|
+
if (!res.ok) throw await bookingError(res);
|
|
8841
|
+
return await res.json();
|
|
8842
|
+
}
|
|
8843
|
+
async function bookPublicSlot(baseUrl, slug, body) {
|
|
8844
|
+
const res = await fetch(bookPath(baseUrl, slug), {
|
|
8845
|
+
method: "POST",
|
|
8846
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
8847
|
+
body: JSON.stringify({ ...body, note: body.note?.trim() || null })
|
|
8848
|
+
});
|
|
8849
|
+
if (!res.ok) throw await bookingError(res);
|
|
8850
|
+
return await res.json();
|
|
8851
|
+
}
|
|
8852
|
+
async function cancelPublicBooking(baseUrl, slug, token) {
|
|
8853
|
+
const res = await fetch(`${bookPath(baseUrl, slug)}/cancel?token=${encodeURIComponent(token)}`, {
|
|
8854
|
+
method: "POST"
|
|
8855
|
+
});
|
|
8856
|
+
if (!res.ok) throw await bookingError(res);
|
|
8857
|
+
}
|
|
8858
|
+
|
|
8316
8859
|
// src/arbi.ts
|
|
8317
8860
|
function tokenExpiresWithin(token, seconds) {
|
|
8318
8861
|
const payload = token?.split(".")[1];
|
|
@@ -8950,11 +9493,13 @@ var Arbi = class {
|
|
|
8950
9493
|
assistantMode
|
|
8951
9494
|
)
|
|
8952
9495
|
};
|
|
8953
|
-
/** Persisted notifications
|
|
9496
|
+
/** Persisted notifications (both the ones you received and the ones you sent), newest first;
|
|
9497
|
+
* new ones also arrive on the normal workspace WebSocket. */
|
|
8954
9498
|
notifications = {
|
|
8955
|
-
list: async (
|
|
9499
|
+
list: async (options = {}) => {
|
|
9500
|
+
const { type, limit = 100, offset } = options;
|
|
8956
9501
|
const { data, error } = await this.requireClient().fetch.GET("/v1/notifications/", {
|
|
8957
|
-
params: { query: { ...type ? { type } : {}, limit:
|
|
9502
|
+
params: { query: { ...type ? { type } : {}, limit, ...offset ? { offset } : {} } }
|
|
8958
9503
|
});
|
|
8959
9504
|
if (error) throw new ArbiError("Could not load notifications");
|
|
8960
9505
|
return data || [];
|
|
@@ -8965,6 +9510,11 @@ var Arbi = class {
|
|
|
8965
9510
|
body: { updates: ids.map((external_id) => ({ external_id, read: true })) }
|
|
8966
9511
|
});
|
|
8967
9512
|
if (error) throw new ArbiError("Could not mark notifications read");
|
|
9513
|
+
},
|
|
9514
|
+
/** Delete notifications for yourself (sender or recipient). */
|
|
9515
|
+
delete: async (ids) => {
|
|
9516
|
+
if (!ids.length) return;
|
|
9517
|
+
await deleteNotifications(this.requireClient(), ids);
|
|
8968
9518
|
}
|
|
8969
9519
|
};
|
|
8970
9520
|
/** Authenticated native Word transport, with normal session recovery. */
|
|
@@ -9122,15 +9672,96 @@ var Arbi = class {
|
|
|
9122
9672
|
generate: (tagIds, docIds) => generateDocTags(this.requireClient(), tagIds, docIds)
|
|
9123
9673
|
};
|
|
9124
9674
|
// ── Contacts ──────────────────────────────────────────────────────────
|
|
9675
|
+
// A card is sealed under its address book's key, which the calendar key bridge carries: without
|
|
9676
|
+
// it the server returns `card: null` and refuses card writes.
|
|
9125
9677
|
contacts = {
|
|
9126
|
-
list: () =>
|
|
9678
|
+
list: () => this.withCalendarKeys((c2) => listContacts(c2)),
|
|
9127
9679
|
invite: (emails) => inviteContacts(this.requireClient(), emails),
|
|
9128
|
-
create: (body) =>
|
|
9129
|
-
update: (contactId, card) =>
|
|
9130
|
-
delete: (contactId) =>
|
|
9131
|
-
search: (q2) =>
|
|
9680
|
+
create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
|
|
9681
|
+
update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
|
|
9682
|
+
delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
|
|
9683
|
+
search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
|
|
9132
9684
|
groupByStatus: groupContactsByStatus
|
|
9133
9685
|
};
|
|
9686
|
+
// ── Calendar ──────────────────────────────────────────────────────────
|
|
9687
|
+
/** The keys the calendar unlock needs; `null` before login (calendars then read as locked). */
|
|
9688
|
+
calendarKeys() {
|
|
9689
|
+
const login = this.loginResult;
|
|
9690
|
+
return login ? { signingPrivateKey: login.signingPrivateKey, serverSessionKey: login.serverSessionKey } : null;
|
|
9691
|
+
}
|
|
9692
|
+
/** Run `op` once this server session holds the calendar keys (unlocked once per session). */
|
|
9693
|
+
async withCalendarKeys(op) {
|
|
9694
|
+
const client = this.requireClient();
|
|
9695
|
+
await ensureCalendarUnlocked(client, this.calendarKeys());
|
|
9696
|
+
return op(client);
|
|
9697
|
+
}
|
|
9698
|
+
/**
|
|
9699
|
+
* The native calendar (`/v1/calendar`). Every content call first bridges the user's calendar
|
|
9700
|
+
* keys to the server session (once per session; see `calendarOps.ensureCalendarUnlocked`).
|
|
9701
|
+
*/
|
|
9702
|
+
calendar = {
|
|
9703
|
+
/** Bridge the calendar keys now; `force` again (keys that arrived since: a share, an invite). */
|
|
9704
|
+
unlock: (force = false) => ensureCalendarUnlocked(this.requireClient(), this.calendarKeys(), force),
|
|
9705
|
+
getSettings: () => this.withCalendarKeys((c2) => getCalendarSettings(c2)),
|
|
9706
|
+
putSettings: (body) => this.withCalendarKeys((c2) => putCalendarSettings(c2, body)),
|
|
9707
|
+
listCalendars: () => this.withCalendarKeys((c2) => listCalendars(c2, this.calendarKeys())),
|
|
9708
|
+
createCalendar: (body) => this.withCalendarKeys((c2) => createCalendar(c2, body)),
|
|
9709
|
+
updateCalendar: (calId, body) => this.withCalendarKeys((c2) => updateCalendar(c2, calId, body)),
|
|
9710
|
+
deleteCalendar: (calId) => this.withCalendarKeys((c2) => deleteCalendar(c2, calId)),
|
|
9711
|
+
exportCalendar: (calId) => this.withCalendarKeys((c2) => exportCalendarIcs(c2, calId)),
|
|
9712
|
+
importIcs: (ics, calendarId) => this.withCalendarKeys((c2) => importCalendarIcs(c2, ics, calendarId)),
|
|
9713
|
+
listEvents: (params) => this.withCalendarKeys((c2) => listEvents(c2, params)),
|
|
9714
|
+
getEvent: (evtId, recurrenceId) => this.withCalendarKeys((c2) => getEvent(c2, evtId, recurrenceId)),
|
|
9715
|
+
createEvent: (body) => this.withCalendarKeys((c2) => createEvent(c2, body)),
|
|
9716
|
+
updateEvent: (target, body) => this.withCalendarKeys((c2) => updateEvent(c2, target, body)),
|
|
9717
|
+
deleteEvent: (target) => this.withCalendarKeys((c2) => deleteEvent(c2, target)),
|
|
9718
|
+
moveEvent: (evtId, calendarId) => this.withCalendarKeys((c2) => moveEvent(c2, evtId, calendarId)),
|
|
9719
|
+
respond: (params) => this.withCalendarKeys((c2) => respondToEvent(c2, params)),
|
|
9720
|
+
eventIcs: (evtId) => this.withCalendarKeys((c2) => eventIcs(c2, evtId)),
|
|
9721
|
+
lookupByUid: (uid) => this.withCalendarKeys((c2) => lookupEventByUid(c2, uid)),
|
|
9722
|
+
/** The open workspace's overlay layers (not sealed: no unlock). */
|
|
9723
|
+
listOverlays: (range, layers) => listOverlays(this.requireClient(), range, layers),
|
|
9724
|
+
listShares: (calId) => this.withCalendarKeys((c2) => listShares(c2, calId)),
|
|
9725
|
+
share: (calId, grantee, role) => this.withCalendarKeys((c2) => shareCalendar(c2, calId, grantee, role)),
|
|
9726
|
+
/** Remove a grantee; the key it rotates is bridged again. */
|
|
9727
|
+
unshare: async (calId, grantee) => {
|
|
9728
|
+
await this.withCalendarKeys((c2) => unshareCalendar(c2, calId, grantee));
|
|
9729
|
+
await this.calendar.unlock(true);
|
|
9730
|
+
},
|
|
9731
|
+
subscribe: (body) => this.withCalendarKeys((c2) => subscribeCalendar(c2, body)),
|
|
9732
|
+
refresh: (calId) => this.withCalendarKeys((c2) => refreshCalendar(c2, calId)),
|
|
9733
|
+
listHolidayCountries: () => this.withCalendarKeys((c2) => listHolidayCountries(c2)),
|
|
9734
|
+
addHolidays: (body) => this.withCalendarKeys((c2) => addHolidayCalendar(c2, body)),
|
|
9735
|
+
createRoom: (body) => this.withCalendarKeys((c2) => createRoom(c2, body)),
|
|
9736
|
+
listRooms: (query) => this.withCalendarKeys((c2) => listRooms(c2, query)),
|
|
9737
|
+
freeBusy: (body) => this.withCalendarKeys((c2) => getFreeBusy(c2, body)),
|
|
9738
|
+
findTime: (body) => this.withCalendarKeys((c2) => findTime(c2, body)),
|
|
9739
|
+
/**
|
|
9740
|
+
* Invitations and proposals waiting for me. A new one arrives with its own key: bridge again
|
|
9741
|
+
* first, or an open tab would not see it until it reloaded.
|
|
9742
|
+
*/
|
|
9743
|
+
listInvitations: async () => {
|
|
9744
|
+
await this.calendar.unlock(true);
|
|
9745
|
+
return listInvitations(this.requireClient());
|
|
9746
|
+
},
|
|
9747
|
+
decideCounter: (itpId, accept, comment) => this.withCalendarKeys((c2) => decideCounter(c2, itpId, accept, comment)),
|
|
9748
|
+
peopleKeys: (body) => this.withCalendarKeys((c2) => lookupPeopleKeys(c2, body)),
|
|
9749
|
+
listAccounts: () => this.withCalendarKeys((c2) => listAccounts(c2)),
|
|
9750
|
+
listCalDavProfiles: () => this.withCalendarKeys((c2) => listCalDavProfiles(c2)),
|
|
9751
|
+
connectOAuthAccount: (kind, backgroundSync = false) => this.withCalendarKeys((c2) => connectOAuthAccount(c2, kind, backgroundSync)),
|
|
9752
|
+
connectCalDavAccount: (body) => this.withCalendarKeys((c2) => connectCalDavAccount(c2, body)),
|
|
9753
|
+
updateAccount: (accId, backgroundSync) => this.withCalendarKeys((c2) => updateAccount(c2, accId, backgroundSync)),
|
|
9754
|
+
syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
|
|
9755
|
+
disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
|
|
9756
|
+
publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
|
|
9757
|
+
listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
|
|
9758
|
+
createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
|
|
9759
|
+
createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
|
|
9760
|
+
revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
|
|
9761
|
+
listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
|
|
9762
|
+
putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
|
|
9763
|
+
deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
|
|
9764
|
+
};
|
|
9134
9765
|
// ── Chats (direct + group) ────────────────────────────────────────────
|
|
9135
9766
|
/**
|
|
9136
9767
|
* Build (and cache) the chat crypto context for the current session: my X25519 keypair
|
|
@@ -10456,6 +11087,7 @@ async function startDmListener(options) {
|
|
|
10456
11087
|
};
|
|
10457
11088
|
}
|
|
10458
11089
|
|
|
11090
|
+
exports.ACCOUNT_VENDOR = ACCOUNT_VENDOR;
|
|
10459
11091
|
exports.Arbi = Arbi;
|
|
10460
11092
|
exports.ArbiApiError = ArbiApiError;
|
|
10461
11093
|
exports.ArbiError = ArbiError;
|
|
@@ -10467,6 +11099,7 @@ exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
|
|
|
10467
11099
|
exports.FileConfigStore = FileConfigStore;
|
|
10468
11100
|
exports.OpenClawOrchestrator = OpenClawOrchestrator;
|
|
10469
11101
|
exports.PlanStepsError = PlanStepsError;
|
|
11102
|
+
exports.PublicBookingError = PublicBookingError;
|
|
10470
11103
|
exports.STEP_FIELD_OPTION_TONES = STEP_FIELD_OPTION_TONES;
|
|
10471
11104
|
exports.TAG_KINDS = TAG_KINDS;
|
|
10472
11105
|
exports.WebSocketAuthError = WebSocketAuthError;
|
|
@@ -10475,12 +11108,15 @@ exports.agentconfig = agentconfig_exports;
|
|
|
10475
11108
|
exports.agents = agents_exports;
|
|
10476
11109
|
exports.assistant = assistant_exports;
|
|
10477
11110
|
exports.authenticatedFetch = authenticatedFetch;
|
|
11111
|
+
exports.bookPublicSlot = bookPublicSlot;
|
|
10478
11112
|
exports.buildCitationChunkData = buildCitationChunkData;
|
|
10479
11113
|
exports.buildDocNameMap = buildDocNameMap;
|
|
10480
11114
|
exports.buildFactsContextTool = buildFactsContextTool;
|
|
10481
11115
|
exports.buildRetrievalChunkTool = buildRetrievalChunkTool;
|
|
10482
11116
|
exports.buildRetrievalFullContextTool = buildRetrievalFullContextTool;
|
|
10483
11117
|
exports.buildRetrievalTocTool = buildRetrievalTocTool;
|
|
11118
|
+
exports.calendar = calendar_exports;
|
|
11119
|
+
exports.cancelPublicBooking = cancelPublicBooking;
|
|
10484
11120
|
exports.chats = chats_exports;
|
|
10485
11121
|
exports.connectWebSocket = connectWebSocket;
|
|
10486
11122
|
exports.connectWithReconnect = connectWithReconnect;
|
|
@@ -10511,6 +11147,7 @@ exports.generateEncryptedWorkspaceKey = generateEncryptedWorkspaceKey;
|
|
|
10511
11147
|
exports.generateNewWorkspaceKey = generateNewWorkspaceKey;
|
|
10512
11148
|
exports.getErrorCode = getErrorCode;
|
|
10513
11149
|
exports.getErrorMessage = getErrorMessage;
|
|
11150
|
+
exports.getPublicBookingPage = getPublicBookingPage;
|
|
10514
11151
|
exports.getRawWorkspaceKey = getRawWorkspaceKey;
|
|
10515
11152
|
exports.health = health_exports;
|
|
10516
11153
|
exports.identityErrorCode = identityErrorCode;
|
|
@@ -10538,6 +11175,7 @@ exports.selectWorkspaceById = selectWorkspaceById;
|
|
|
10538
11175
|
exports.sessions = sessions_exports;
|
|
10539
11176
|
exports.settings = settings_exports;
|
|
10540
11177
|
exports.signatureRequests = signature_requests_exports;
|
|
11178
|
+
exports.splitAppPasswords = splitAppPasswords;
|
|
10541
11179
|
exports.startDmListener = startDmListener;
|
|
10542
11180
|
exports.streamSSE = streamSSE;
|
|
10543
11181
|
exports.stripCitationMarkdown = stripCitationMarkdown;
|