Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .eslintrc.cjs

This file was deleted.

10 changes: 10 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { recommendedJavascript } from '@nextcloud/eslint-config'

export default [
...recommendedJavascript,
]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:watch": "vitest",
"lint": "eslint --ext .js src",
"lint:fix": "eslint --ext .js src --fix"
"lint": "eslint src",
"lint:fix": "eslint src --fix"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions src/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

/**
* creates a debug function bound to a context
*
* @param {string} context

Check warning on line 13 in src/debug.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "context" description
* @return {Function}

Check warning on line 14 in src/debug.js

View workflow job for this annotation

GitHub Actions / NPM lint

Prefer a more specific type to `Function`
*/
export function debugFactory(context) {
return (...args) => {
Expand Down
2 changes: 0 additions & 2 deletions src/errors/attachError.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
* @abstract
*/
export default class AttachError extends Error {

/**
*
* @param {object} attach

Check warning on line 18 in src/errors/attachError.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "attach" description
*/
constructor(attach) {
super()

Object.assign(this, attach)
}

}
26 changes: 15 additions & 11 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { debugFactory } from './debug.js'
import { AddressBookHome } from './models/addressBookHome.js'
import { CalendarHome } from './models/calendarHome.js'
import { Principal } from './models/principal.js'
/**
* CDAV Library
*
Expand All @@ -10,11 +14,6 @@
import Request from './request.js'
import * as NS from './utility/namespaceUtility.js'
import * as XMLUtility from './utility/xmlUtility.js'
import { CalendarHome } from './models/calendarHome.js'
import { AddressBookHome } from './models/addressBookHome.js'
import { Principal } from './models/principal.js'

import { debugFactory } from './debug.js'
const debug = debugFactory('index.js')

export { debugFactory as debug, NS as namespaces }
Expand All @@ -23,13 +22,13 @@
*
*/
export default class DavClient {

/**
* @param {object} options

Check warning on line 26 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "options" description
* @param {string} options.rootUrl

Check warning on line 27 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "options.rootUrl" description
* @param {{[name: string]: any}} [options.defaultHeaders] A dictionary of default headers to apply to each request.

Check warning on line 28 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Prefer a more specific type to `any`
* @param {object} factories

Check warning on line 29 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "factories" description
*/
// eslint-disable-next-line no-unused-vars
constructor(options, factories = {}) {
/**
* root URL of DAV Server
Expand Down Expand Up @@ -111,7 +110,8 @@

/**
* initializes the DAVClient
*
* @param {object} options

Check warning on line 114 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "options" description
* @return {Promise<DavClient>}
*/
async connect(options = { enableCalDAV: false, enableCardDAV: false }) {
Expand Down Expand Up @@ -176,7 +176,7 @@
/**
* performs a principal property search based on a principal's displayname
*
* @param {string} name

Check warning on line 179 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "name" description
* @return {Promise<Principal[]>}
*/
async principalPropertySearchByDisplayname(name) {
Expand All @@ -188,7 +188,7 @@
/**
* performs a principal property search based on a principal's displayname OR email address
*
* @param {string} value

Check warning on line 191 in src/index.js

View workflow job for this annotation

GitHub Actions / NPM lint

Missing JSDoc @param "value" description
* @return {Promise<Principal[]>}
*/
async principalPropertySearchByDisplaynameOrEmail(value) {
Expand Down Expand Up @@ -218,8 +218,7 @@
* @return {Promise<[]>}
*/
async principalPropertySearchByAddressAndStory(address, story) {
const [skeleton] = XMLUtility.getRootSkeleton(
[NS.DAV, 'principal-property-search'])
const [skeleton] = XMLUtility.getRootSkeleton([NS.DAV, 'principal-property-search'])

skeleton.children.push({
name: [NS.DAV, 'property-search'],
Expand Down Expand Up @@ -372,6 +371,7 @@

/**
* performs a principal property search
*
* @see https://tools.ietf.org/html/rfc3744#section-9.4
*
* @param {Array} props
Expand Down Expand Up @@ -432,6 +432,7 @@
return new Principal(null, this._request, principalUrl, body)
}).catch((err) => {
// TODO: improve error handling
// eslint-disable-next-line no-console
console.debug(err)
})
}
Expand Down Expand Up @@ -461,6 +462,7 @@
return principals
} catch (err) {
// TODO: improve error handling
// eslint-disable-next-line no-console
console.debug(err)
}
}
Expand Down Expand Up @@ -519,6 +521,7 @@

/**
* Fetches the group-member-set of a principal collection (e.g. a calendar-proxy group).
*
* @see https://tools.ietf.org/html/rfc3744#section-4.3
*
* @param {string} groupUrl Absolute URL of the proxy group principal
Expand All @@ -534,6 +537,7 @@

/**
* Sets the group-member-set of a principal collection (e.g. a calendar-proxy group).
*
* @see https://tools.ietf.org/html/rfc3744#section-4.3
*
* @param {string} groupUrl Absolute URL of the proxy group principal
Expand Down Expand Up @@ -561,6 +565,7 @@

/**
* Fetches the group-membership of a principal (the groups it belongs to).
*
* @see https://tools.ietf.org/html/rfc3744#section-4.4
*
* @param {string} principalUrl Absolute URL of the principal
Expand Down Expand Up @@ -636,7 +641,7 @@
*
* @param {string} ownerPrincipalUrl Absolute URL of the principal who owns the proxy group
* @param {string} delegatePrincipalUrl Absolute or relative URL of the principal to add as delegate
* @param {'write'|'read'} [permission='write'] The proxy group to add the delegate to
* @param {'write'|'read'} [permission] The proxy group to add the delegate to
* @return {Promise<void>}
*/
async addDelegate(ownerPrincipalUrl, delegatePrincipalUrl, permission = 'write') {
Expand All @@ -653,7 +658,7 @@
*
* @param {string} ownerPrincipalUrl Absolute URL of the principal who owns the proxy group
* @param {string} delegatePrincipalUrl Absolute or relative URL of the principal to remove
* @param {'write'|'read'} [permission='write'] The proxy group to remove the delegate from
* @param {'write'|'read'} [permission] The proxy group to remove the delegate from
* @return {Promise<void>}
*/
async removeDelegate(ownerPrincipalUrl, delegatePrincipalUrl, permission = 'write') {
Expand Down Expand Up @@ -797,5 +802,4 @@
const url = this._request.pathname(this.rootUrl) + 'public-calendars/'
this.publicCalendarHome = new CalendarHome(this, this._request, url, {})
}

}
19 changes: 6 additions & 13 deletions src/models/addressBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { davCollectionShareable } from './davCollectionShareable.js'
import { DavCollection } from './davCollection.js'
import { debugFactory } from '../debug.js'
import addressBookPropSet from '../propset/addressBookPropSet.js'
import * as NS from '../utility/namespaceUtility.js'
import * as StringUtility from '../utility/stringUtility.js'
import * as XMLUtility from '../utility/xmlUtility.js'
import addressBookPropSet from '../propset/addressBookPropSet.js'
import { DavCollection } from './davCollection.js'
import { davCollectionShareable } from './davCollectionShareable.js'
import { VCard } from './vcard.js'

import { debugFactory } from '../debug.js'
const debug = debugFactory('AddressBook')

/**
Expand All @@ -33,7 +32,6 @@ const debug = debugFactory('AddressBook')
* @augments DavCollection
*/
export class AddressBook extends davCollectionShareable(DavCollection) {

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -121,9 +119,7 @@ export class AddressBook extends davCollectionShareable(DavCollection) {
async addressbookQuery(filter, prop = null, limit = null, test = 'anyof') {
debug('sending an addressbook-query request')

const [skeleton] = XMLUtility.getRootSkeleton(
[NS.IETF_CARDDAV, 'addressbook-query'],
)
const [skeleton] = XMLUtility.getRootSkeleton([NS.IETF_CARDDAV, 'addressbook-query'])

if (!prop) {
skeleton.children.push({
Expand Down Expand Up @@ -221,9 +217,7 @@ export class AddressBook extends davCollectionShareable(DavCollection) {
* @private
*/
_buildMultiGetBody(hrefs, prop) {
const [skeleton] = XMLUtility.getRootSkeleton(
[NS.IETF_CARDDAV, 'addressbook-multiget'],
)
const [skeleton] = XMLUtility.getRootSkeleton([NS.IETF_CARDDAV, 'addressbook-multiget'])

if (!prop) {
skeleton.children.push({
Expand Down Expand Up @@ -283,5 +277,4 @@ export class AddressBook extends davCollectionShareable(DavCollection) {

return !!addressBookDataProperty.children
}

}
7 changes: 2 additions & 5 deletions src/models/addressBookHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { DavCollection } from './davCollection.js'
import { debugFactory } from '../debug.js'
import * as NS from '../utility/namespaceUtility.js'
import { AddressBook } from './addressBook.js'

import { debugFactory } from '../debug.js'
import { DavCollection } from './davCollection.js'
const debug = debugFactory('AddressBookHome')

/**
Expand All @@ -23,7 +22,6 @@ const debug = debugFactory('AddressBookHome')
* a server to return multiple address book homes though.
*/
export class AddressBookHome extends DavCollection {

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -66,5 +64,4 @@ export class AddressBookHome extends DavCollection {
const name = super._getAvailableNameFromToken(displayname)
return super.createCollection(name, props)
}

}
31 changes: 12 additions & 19 deletions src/models/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { DavCollection } from './davCollection.js'
import { davCollectionPublishable } from './davCollectionPublishable.js'
import { davCollectionShareable } from './davCollectionShareable.js'
import { VObject } from './vobject.js'
import { debugFactory } from '../debug.js'
import calendarPropSet from '../propset/calendarPropSet.js'
import * as NS from '../utility/namespaceUtility.js'
import * as StringUtility from '../utility/stringUtility.js'
import * as XMLUtility from '../utility/xmlUtility.js'

import { debugFactory } from '../debug.js'
import { DavCollection } from './davCollection.js'
import { davCollectionPublishable } from './davCollectionPublishable.js'
import { davCollectionShareable } from './davCollectionShareable.js'
import { VObject } from './vobject.js'
const debug = debugFactory('Calendar')

/**
Expand All @@ -40,7 +39,6 @@ const debug = debugFactory('Calendar')
* @augments DavCollection
*/
export class Calendar extends davCollectionPublishable(davCollectionShareable(DavCollection)) {

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -147,9 +145,7 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da
async calendarQuery(filter, prop = null, timezone = null) {
debug('sending an calendar-query request')

const [skeleton] = XMLUtility.getRootSkeleton(
[NS.IETF_CALDAV, 'calendar-query'],
)
const [skeleton] = XMLUtility.getRootSkeleton([NS.IETF_CALDAV, 'calendar-query'])

if (!prop) {
skeleton.children.push({
Expand Down Expand Up @@ -203,9 +199,7 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da
return []
}

const [skeleton] = XMLUtility.getRootSkeleton(
[NS.IETF_CALDAV, 'calendar-multiget'],
)
const [skeleton] = XMLUtility.getRootSkeleton([NS.IETF_CALDAV, 'calendar-multiget'])

if (!prop) {
skeleton.children.push({
Expand Down Expand Up @@ -242,24 +236,24 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da
* @param {Date} to
* @return {Promise<string>}
*/
// eslint-disable-next-line no-unused-vars
async freeBusyQuery(from, to) {
/* eslint-disable no-tabs */

// debug('sending a free-busy-query request');
//
// const [skeleton] = XMLUtility.getRootSkeleton(
// [NS.IETF_CALDAV, 'free-busy-query'],
// [NS.IETF_CALDAV, 'time-range']
// [NS.IETF_CALDAV, 'free-busy-query'],
// [NS.IETF_CALDAV, 'time-range']
// );
//
// skeleton[0][0].attributes.push(['start', Calendar._getICalendarDateTimeFromDateObject(from)]);
// skeleton[0][0].attributes.push(['end', Calendar._getICalendarDateTimeFromDateObject(to)]);
//
// const headers = {
// 'Depth': '1'
// 'Depth': '1'
// };
// const body = XMLUtility.serialize(skeleton);
// const response = await this._request.report(this.url, headers, body);
/* eslint-enable no-tabs */

// TODO - finish implementation
}
Expand Down Expand Up @@ -336,5 +330,4 @@ export class Calendar extends davCollectionPublishable(davCollectionShareable(Da
'Z',
].join('')
}

}
Loading
Loading