Skip to content

Commit 0526d4a

Browse files
committed
v2.0.3
1 parent f366a05 commit 0526d4a

27 files changed

+7812
-4170
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
CREDENTIAL_DAVICAL_USERNAME=""
2+
CREDENTIAL_DAVICAL_PASSWORD=""
3+
CREDENTIAL_DAVICAL_SERVER_URL=""
14
CREDENTIAL_ZOHO_USERNAME=""
25
CREDENTIAL_ZOHO_PASSWORD=""
36
CREDENTIAL_ZOHO_SERVER_URL=""

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"consts",
1515
"copyfiles",
1616
"ctag",
17+
"DAVICAL",
1718
"DAVV",
1819
"displayname",
1920
"docusuarus",

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## v2.0.3
2+
3+
**improvements**
4+
5+
- added support for davical
6+
- fixed a bug related to expand #116
7+
- updated deps
8+
19
## v2.0.2
210

311
**improvements**

dist/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tsdav",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser",
55
"keywords": [
66
"dav",
@@ -54,36 +54,36 @@
5454
"xml-js": "1.6.11"
5555
},
5656
"devDependencies": {
57-
"@rollup/plugin-commonjs": "21.0.3",
57+
"@rollup/plugin-commonjs": "22.0.1",
5858
"@rollup/plugin-node-resolve": "13.1.3",
59-
"@rollup/plugin-typescript": "8.3.1",
59+
"@rollup/plugin-typescript": "8.3.3",
6060
"@types/base-64": "1.0.0",
6161
"@types/debug": "4.1.7",
62-
"@types/jest": "27.4.1",
63-
"@types/node": "17.0.23",
64-
"@typescript-eslint/eslint-plugin": "5.16.0",
65-
"@typescript-eslint/parser": "5.16.0",
62+
"@types/jest": "28.1.4",
63+
"@types/node": "18.0.0",
64+
"@typescript-eslint/eslint-plugin": "5.30.3",
65+
"@typescript-eslint/parser": "5.18.0",
6666
"copyfiles": "2.4.1",
6767
"cross-env": "7.0.3",
68-
"dotenv": "16.0.0",
69-
"eslint": "8.12.0",
68+
"dotenv": "16.0.1",
69+
"eslint": "8.19.0",
7070
"eslint-config-airbnb": "19.0.4",
71-
"eslint-config-airbnb-typescript": "16.1.4",
71+
"eslint-config-airbnb-typescript": "17.0.0",
7272
"eslint-config-prettier": "8.5.0",
7373
"eslint-module-utils": "2.7.3",
74-
"eslint-plugin-import": "2.25.4",
75-
"eslint-plugin-prettier": "4.0.0",
76-
"jest": "27.5.1",
77-
"prettier": "2.6.1",
74+
"eslint-plugin-import": "2.26.0",
75+
"eslint-plugin-prettier": "4.2.1",
76+
"jest": "28.1.2",
77+
"prettier": "2.7.1",
7878
"rimraf": "3.0.2",
79-
"rollup": "2.70.1",
80-
"rollup-plugin-dts": "4.2.0",
79+
"rollup": "2.75.7",
80+
"rollup-plugin-dts": "4.2.2",
8181
"rollup-plugin-node-builtins": "2.1.2",
82-
"rollup-plugin-polyfill-node": "0.8.0",
82+
"rollup-plugin-polyfill-node": "0.9.0",
8383
"rollup-plugin-terser": "7.0.2",
84-
"sort-package-json": "1.55.0",
85-
"ts-jest": "27.1.4",
86-
"typescript": "4.6.3"
84+
"sort-package-json": "1.57.0",
85+
"ts-jest": "28.0.5",
86+
"typescript": "4.7.4"
8787
},
8888
"engines": {
8989
"node": ">=10"

dist/tsdav.cjs.js

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ function hasFields(obj, fields) {
321321
}
322322
return inObj(obj);
323323
}
324-
const findMissingFieldNames = (obj, fields) => fields.reduce((prev, curr) => (obj[curr] ? prev : `${prev.length ? `${prev},` : ''}${curr}`), '');
324+
const findMissingFieldNames = (obj, fields) => fields.reduce((prev, curr) => (obj[curr] ? prev : `${prev.length ? `${prev},` : ''}${curr.toString()}`), '');
325325

326326
const debug$4 = getLogger__default["default"]('tsdav:collection');
327327
const collectionQuery = (params) => __awaiter(void 0, void 0, void 0, function* () {
@@ -878,7 +878,22 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
878878
(yield calendarQuery({
879879
url: calendar.url,
880880
props: {
881-
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
881+
[`${exports.DAVNamespaceShort.DAV}:getetag`]: Object.assign({}, (expand && timeRange
882+
? {
883+
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
884+
_attributes: {
885+
start: `${new Date(timeRange.start)
886+
.toISOString()
887+
.slice(0, 19)
888+
.replace(/[-:.]/g, '')}Z`,
889+
end: `${new Date(timeRange.end)
890+
.toISOString()
891+
.slice(0, 19)
892+
.replace(/[-:.]/g, '')}Z`,
893+
},
894+
},
895+
}
896+
: {})),
882897
},
883898
filters,
884899
depth: '1',
@@ -887,33 +902,63 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
887902
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
888903
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))) // filter out non ics calendar objects since apple calendar might have those
889904
.map((url) => new URL(url).pathname); // obtain pathname of the url
890-
const calendarObjectResults = calendarObjectUrls.length > 0
891-
? yield calendarMultiGet({
892-
url: calendar.url,
893-
props: {
894-
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
895-
[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
896-
? {
897-
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
898-
_attributes: {
899-
start: `${new Date(timeRange.start)
900-
.toISOString()
901-
.slice(0, 19)
902-
.replace(/[-:.]/g, '')}Z`,
903-
end: `${new Date(timeRange.end)
904-
.toISOString()
905-
.slice(0, 19)
906-
.replace(/[-:.]/g, '')}Z`,
905+
let calendarObjectResults = [];
906+
if (calendarObjectUrls.length > 0) {
907+
if (expand) {
908+
calendarObjectResults = yield calendarQuery({
909+
url: calendar.url,
910+
props: {
911+
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
912+
[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
913+
? {
914+
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
915+
_attributes: {
916+
start: `${new Date(timeRange.start)
917+
.toISOString()
918+
.slice(0, 19)
919+
.replace(/[-:.]/g, '')}Z`,
920+
end: `${new Date(timeRange.end)
921+
.toISOString()
922+
.slice(0, 19)
923+
.replace(/[-:.]/g, '')}Z`,
924+
},
907925
},
908-
},
909-
}
910-
: {})),
911-
},
912-
objectUrls: calendarObjectUrls,
913-
depth: '1',
914-
headers,
915-
})
916-
: [];
926+
}
927+
: {})),
928+
},
929+
filters,
930+
depth: '1',
931+
headers,
932+
});
933+
}
934+
else {
935+
calendarObjectResults = yield calendarMultiGet({
936+
url: calendar.url,
937+
props: {
938+
[`${exports.DAVNamespaceShort.DAV}:getetag`]: {},
939+
[`${exports.DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
940+
? {
941+
[`${exports.DAVNamespaceShort.CALDAV}:expand`]: {
942+
_attributes: {
943+
start: `${new Date(timeRange.start)
944+
.toISOString()
945+
.slice(0, 19)
946+
.replace(/[-:.]/g, '')}Z`,
947+
end: `${new Date(timeRange.end)
948+
.toISOString()
949+
.slice(0, 19)
950+
.replace(/[-:.]/g, '')}Z`,
951+
},
952+
},
953+
}
954+
: {})),
955+
},
956+
objectUrls: calendarObjectUrls,
957+
depth: '1',
958+
headers,
959+
});
960+
}
961+
}
917962
return calendarObjectResults.map((res) => {
918963
var _a, _b, _c, _d, _e, _f;
919964
return ({

dist/tsdav.d.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ declare const addressBookMultiGet: (params: {
183183
headers?: Record<string, string>;
184184
}) => Promise<DAVResponse[]>;
185185
declare const fetchAddressBooks: (params?: {
186-
account?: DAVAccount | undefined;
187-
props?: ElementCompact | undefined;
188-
headers?: Record<string, string> | undefined;
189-
} | undefined) => Promise<DAVAddressBook[]>;
186+
account?: DAVAccount;
187+
props?: ElementCompact;
188+
headers?: Record<string, string>;
189+
}) => Promise<DAVAddressBook[]>;
190190
declare const fetchVCards: (params: {
191191
addressBook: DAVAddressBook;
192192
headers?: Record<string, string> | undefined;
@@ -232,10 +232,10 @@ declare const makeCalendar: (params: {
232232
headers?: Record<string, string>;
233233
}) => Promise<DAVResponse[]>;
234234
declare const fetchCalendars: (params?: {
235-
account?: DAVAccount | undefined;
236-
props?: ElementCompact | undefined;
237-
headers?: Record<string, string> | undefined;
238-
} | undefined) => Promise<DAVCalendar[]>;
235+
account?: DAVAccount;
236+
props?: ElementCompact;
237+
headers?: Record<string, string>;
238+
}) => Promise<DAVCalendar[]>;
239239
declare const fetchCalendarObjects: (params: {
240240
calendar: DAVCalendar;
241241
objectUrls?: string[] | undefined;
@@ -588,8 +588,8 @@ declare const getOauthHeaders: (credentials: DAVCredentials) => Promise<{
588588
};
589589
}>;
590590

591-
declare const urlEquals: (urlA?: string | undefined, urlB?: string | undefined) => boolean;
592-
declare const urlContains: (urlA?: string | undefined, urlB?: string | undefined) => boolean;
591+
declare const urlEquals: (urlA?: string, urlB?: string) => boolean;
592+
declare const urlContains: (urlA?: string, urlB?: string) => boolean;
593593
declare const getDAVAttribute: (nsArr: DAVNamespace[]) => {
594594
[key: string]: DAVNamespace;
595595
};

dist/tsdav.esm.js

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ function hasFields(obj, fields) {
312312
}
313313
return inObj(obj);
314314
}
315-
const findMissingFieldNames = (obj, fields) => fields.reduce((prev, curr) => (obj[curr] ? prev : `${prev.length ? `${prev},` : ''}${curr}`), '');
315+
const findMissingFieldNames = (obj, fields) => fields.reduce((prev, curr) => (obj[curr] ? prev : `${prev.length ? `${prev},` : ''}${curr.toString()}`), '');
316316

317317
const debug$4 = getLogger('tsdav:collection');
318318
const collectionQuery = (params) => __awaiter(void 0, void 0, void 0, function* () {
@@ -869,7 +869,22 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
869869
(yield calendarQuery({
870870
url: calendar.url,
871871
props: {
872-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
872+
[`${DAVNamespaceShort.DAV}:getetag`]: Object.assign({}, (expand && timeRange
873+
? {
874+
[`${DAVNamespaceShort.CALDAV}:expand`]: {
875+
_attributes: {
876+
start: `${new Date(timeRange.start)
877+
.toISOString()
878+
.slice(0, 19)
879+
.replace(/[-:.]/g, '')}Z`,
880+
end: `${new Date(timeRange.end)
881+
.toISOString()
882+
.slice(0, 19)
883+
.replace(/[-:.]/g, '')}Z`,
884+
},
885+
},
886+
}
887+
: {})),
873888
},
874889
filters,
875890
depth: '1',
@@ -878,33 +893,63 @@ const fetchCalendarObjects = (params) => __awaiter(void 0, void 0, void 0, funct
878893
.map((url) => (url.startsWith('http') || !url ? url : new URL(url, calendar.url).href)) // patch up to full url if url is not full
879894
.filter(urlFilter !== null && urlFilter !== void 0 ? urlFilter : ((url) => Boolean(url === null || url === void 0 ? void 0 : url.includes('.ics')))) // filter out non ics calendar objects since apple calendar might have those
880895
.map((url) => new URL(url).pathname); // obtain pathname of the url
881-
const calendarObjectResults = calendarObjectUrls.length > 0
882-
? yield calendarMultiGet({
883-
url: calendar.url,
884-
props: {
885-
[`${DAVNamespaceShort.DAV}:getetag`]: {},
886-
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
887-
? {
888-
[`${DAVNamespaceShort.CALDAV}:expand`]: {
889-
_attributes: {
890-
start: `${new Date(timeRange.start)
891-
.toISOString()
892-
.slice(0, 19)
893-
.replace(/[-:.]/g, '')}Z`,
894-
end: `${new Date(timeRange.end)
895-
.toISOString()
896-
.slice(0, 19)
897-
.replace(/[-:.]/g, '')}Z`,
896+
let calendarObjectResults = [];
897+
if (calendarObjectUrls.length > 0) {
898+
if (expand) {
899+
calendarObjectResults = yield calendarQuery({
900+
url: calendar.url,
901+
props: {
902+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
903+
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
904+
? {
905+
[`${DAVNamespaceShort.CALDAV}:expand`]: {
906+
_attributes: {
907+
start: `${new Date(timeRange.start)
908+
.toISOString()
909+
.slice(0, 19)
910+
.replace(/[-:.]/g, '')}Z`,
911+
end: `${new Date(timeRange.end)
912+
.toISOString()
913+
.slice(0, 19)
914+
.replace(/[-:.]/g, '')}Z`,
915+
},
898916
},
899-
},
900-
}
901-
: {})),
902-
},
903-
objectUrls: calendarObjectUrls,
904-
depth: '1',
905-
headers,
906-
})
907-
: [];
917+
}
918+
: {})),
919+
},
920+
filters,
921+
depth: '1',
922+
headers,
923+
});
924+
}
925+
else {
926+
calendarObjectResults = yield calendarMultiGet({
927+
url: calendar.url,
928+
props: {
929+
[`${DAVNamespaceShort.DAV}:getetag`]: {},
930+
[`${DAVNamespaceShort.CALDAV}:calendar-data`]: Object.assign({}, (expand && timeRange
931+
? {
932+
[`${DAVNamespaceShort.CALDAV}:expand`]: {
933+
_attributes: {
934+
start: `${new Date(timeRange.start)
935+
.toISOString()
936+
.slice(0, 19)
937+
.replace(/[-:.]/g, '')}Z`,
938+
end: `${new Date(timeRange.end)
939+
.toISOString()
940+
.slice(0, 19)
941+
.replace(/[-:.]/g, '')}Z`,
942+
},
943+
},
944+
}
945+
: {})),
946+
},
947+
objectUrls: calendarObjectUrls,
948+
depth: '1',
949+
headers,
950+
});
951+
}
952+
}
908953
return calendarObjectResults.map((res) => {
909954
var _a, _b, _c, _d, _e, _f;
910955
return ({

0 commit comments

Comments
 (0)