MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / createAccount

Function createAccount

lib/models/dav.js:10220–10277  ·  view source on GitHub ↗
(params)

Source from the content-addressed store, hash-verified

10218 return result;
10219};
10220const createAccount = async (params) => {
10221 const { account, headers, loadCollections = false, loadObjects = false, headersToExclude, } = params;
10222 const newAccount = { ...account };
10223 newAccount.rootUrl =
10224 newAccount.rootUrl ||
10225 (await serviceDiscovery({
10226 account,
10227 headers: excludeHeaders(headers, headersToExclude),
10228 }));
10229 newAccount.principalUrl =
10230 newAccount.principalUrl ||
10231 (await fetchPrincipalUrl({
10232 account: newAccount,
10233 headers: excludeHeaders(headers, headersToExclude),
10234 }));
10235 newAccount.homeUrl =
10236 newAccount.homeUrl ||
10237 (await fetchHomeUrl({
10238 account: newAccount,
10239 headers: excludeHeaders(headers, headersToExclude),
10240 }));
10241 // to load objects you must first load collections
10242 if (loadCollections || loadObjects) {
10243 if (account.accountType === 'caldav') {
10244 newAccount.calendars = await fetchCalendars({
10245 headers: excludeHeaders(headers, headersToExclude),
10246 account: newAccount,
10247 });
10248 }
10249 else if (account.accountType === 'carddav') {
10250 newAccount.addressBooks = await fetchAddressBooks({
10251 headers: excludeHeaders(headers, headersToExclude),
10252 account: newAccount,
10253 });
10254 }
10255 }
10256 if (loadObjects) {
10257 if (account.accountType === 'caldav' && newAccount.calendars) {
10258 newAccount.calendars = await Promise.all(newAccount.calendars.map(async (cal) => ({
10259 ...cal,
10260 objects: await fetchCalendarObjects({
10261 calendar: cal,
10262 headers: excludeHeaders(headers, headersToExclude),
10263 }),
10264 })));
10265 }
10266 else if (account.accountType === 'carddav' && newAccount.addressBooks) {
10267 newAccount.addressBooks = await Promise.all(newAccount.addressBooks.map(async (addr) => ({
10268 ...addr,
10269 objects: await fetchVCards({
10270 addressBook: addr,
10271 headers: excludeHeaders(headers, headersToExclude),
10272 }),
10273 })));
10274 }
10275 }
10276 return newAccount;
10277};

Callers 4

createDAVClientFunction · 0.85
createAccount$1Function · 0.85
loginMethod · 0.85
createAccountMethod · 0.85

Calls 8

serviceDiscoveryFunction · 0.85
excludeHeadersFunction · 0.85
fetchPrincipalUrlFunction · 0.85
fetchHomeUrlFunction · 0.85
fetchCalendarsFunction · 0.85
fetchAddressBooksFunction · 0.85
fetchCalendarObjectsFunction · 0.85
fetchVCardsFunction · 0.85

Tested by

no test coverage detected