(params)
| 9586 | }); |
| 9587 | }; |
| 9588 | const fetchAddressBooks = async (params) => { |
| 9589 | const { account, headers, props: customProps, headersToExclude } = params !== null && params !== void 0 ? params : {}; |
| 9590 | const requiredFields = ['homeUrl', 'rootUrl']; |
| 9591 | if (!account || !hasFields(account, requiredFields)) { |
| 9592 | if (!account) { |
| 9593 | throw new Error('no account for fetchAddressBooks'); |
| 9594 | } |
| 9595 | throw new Error(`account must have ${findMissingFieldNames(account, requiredFields)} before fetchAddressBooks`); |
| 9596 | } |
| 9597 | const res = await propfind({ |
| 9598 | url: account.homeUrl, |
| 9599 | props: customProps !== null && customProps !== void 0 ? customProps : { |
| 9600 | [`${DAVNamespaceShort.DAV}:displayname`]: {}, |
| 9601 | [`${DAVNamespaceShort.CALENDAR_SERVER}:getctag`]: {}, |
| 9602 | [`${DAVNamespaceShort.DAV}:resourcetype`]: {}, |
| 9603 | [`${DAVNamespaceShort.DAV}:sync-token`]: {}, |
| 9604 | }, |
| 9605 | depth: '1', |
| 9606 | headers: excludeHeaders(headers, headersToExclude), |
| 9607 | }); |
| 9608 | return Promise.all(res |
| 9609 | .filter((r) => { var _a, _b; return Object.keys((_b = (_a = r.props) === null || _a === void 0 ? void 0 : _a.resourcetype) !== null && _b !== void 0 ? _b : {}).includes('addressbook'); }) |
| 9610 | .map((rs) => { |
| 9611 | var _a, _b, _c, _d, _e, _f, _g, _h, _j; |
| 9612 | const displayName = (_c = (_b = (_a = rs.props) === null || _a === void 0 ? void 0 : _a.displayname) === null || _b === void 0 ? void 0 : _b._cdata) !== null && _c !== void 0 ? _c : (_d = rs.props) === null || _d === void 0 ? void 0 : _d.displayname; |
| 9613 | debug$3(`Found address book named ${typeof displayName === 'string' ? displayName : ''}, |
| 9614 | props: ${JSON.stringify(rs.props)}`); |
| 9615 | return { |
| 9616 | url: new URL((_e = rs.href) !== null && _e !== void 0 ? _e : '', (_f = account.rootUrl) !== null && _f !== void 0 ? _f : '').href, |
| 9617 | ctag: (_g = rs.props) === null || _g === void 0 ? void 0 : _g.getctag, |
| 9618 | displayName: typeof displayName === 'string' ? displayName : '', |
| 9619 | resourcetype: Object.keys((_h = rs.props) === null || _h === void 0 ? void 0 : _h.resourcetype), |
| 9620 | syncToken: (_j = rs.props) === null || _j === void 0 ? void 0 : _j.syncToken, |
| 9621 | }; |
| 9622 | }) |
| 9623 | .map(async (addr) => ({ |
| 9624 | ...addr, |
| 9625 | reports: await supportedReportSet({ collection: addr, headers }), |
| 9626 | }))); |
| 9627 | }; |
| 9628 | const fetchVCards = async (params) => { |
| 9629 | const { addressBook, headers, objectUrls, headersToExclude, urlFilter = (url) => url, useMultiGet = true, } = params; |
| 9630 | debug$3(`Fetching vcards from ${addressBook === null || addressBook === void 0 ? void 0 : addressBook.url}`); |
no test coverage detected