@stacksjs/calendar-api 0.64.6 → 0.66.0
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/generators/google.d.ts +2 -0
- package/dist/generators/ics.d.ts +2 -0
- package/dist/generators/weboutlook.d.ts +2 -0
- package/dist/generators/yahoo.d.ts +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +216 -2
- package/dist/index.js.map +199 -8
- package/dist/types.d.ts +43 -0
- package/package.json +8 -13
- package/src/generators/google.ts +7 -3
- package/src/generators/ics.ts +8 -4
- package/src/generators/weboutlook.ts +7 -3
- package/src/generators/yahoo.ts +7 -3
- package/src/index.ts +1 -4
- package/src/types.ts +1 -1
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Ref } from "vue";
|
|
2
|
+
export interface CalendarStore {
|
|
3
|
+
day: number;
|
|
4
|
+
month: Ref<number>;
|
|
5
|
+
year: Ref<number>;
|
|
6
|
+
currentMonthYear: Ref<string>;
|
|
7
|
+
currentMonthDayYear: Ref<string>;
|
|
8
|
+
datesOfThePastMonth: Ref<number[]>;
|
|
9
|
+
datesOfTheMonth: Ref<number[]>;
|
|
10
|
+
datesOfNextMonth: Ref<number[]>;
|
|
11
|
+
currentWeekView: Ref<number[]>;
|
|
12
|
+
currentWeekViewToday: Ref<number[]>;
|
|
13
|
+
}
|
|
14
|
+
export interface Time {
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Events {
|
|
19
|
+
date: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
month: number;
|
|
23
|
+
day: number;
|
|
24
|
+
year: number;
|
|
25
|
+
time: Time;
|
|
26
|
+
}
|
|
27
|
+
export interface WeekDates {
|
|
28
|
+
month: number;
|
|
29
|
+
date: number;
|
|
30
|
+
}
|
|
31
|
+
export interface TimeTableStyle {
|
|
32
|
+
time: string;
|
|
33
|
+
gridRow: string;
|
|
34
|
+
}
|
|
35
|
+
export interface CalendarLink {
|
|
36
|
+
from: Date;
|
|
37
|
+
to: Date;
|
|
38
|
+
allDay: boolean;
|
|
39
|
+
address: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
timezone: string;
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/calendar-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.66.0",
|
|
5
5
|
"description": "Easily interact with calendar APIs.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
|
+
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"funding": "https://github.com/sponsors/chrisbbreuer",
|
|
9
10
|
"homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/calendar#readme",
|
|
@@ -34,23 +35,17 @@
|
|
|
34
35
|
},
|
|
35
36
|
"module": "dist/index.js",
|
|
36
37
|
"types": "dist/index.d.ts",
|
|
37
|
-
"
|
|
38
|
-
"Chris Breuer <chris@stacksjs.org>"
|
|
39
|
-
],
|
|
40
|
-
"files": [
|
|
41
|
-
"README.md",
|
|
42
|
-
"dist",
|
|
43
|
-
"src"
|
|
44
|
-
],
|
|
38
|
+
"files": ["README.md", "dist", "src"],
|
|
45
39
|
"scripts": {
|
|
46
|
-
"build": "bun
|
|
47
|
-
"typecheck": "bun
|
|
40
|
+
"build": "bun build.ts",
|
|
41
|
+
"typecheck": "bun tsc --noEmit",
|
|
48
42
|
"prepublishOnly": "bun run build"
|
|
49
43
|
},
|
|
50
44
|
"dependencies": {
|
|
51
|
-
"@stacksjs/
|
|
45
|
+
"@stacksjs/browser": "0.65.1",
|
|
46
|
+
"@stacksjs/security": "0.65.1"
|
|
52
47
|
},
|
|
53
48
|
"devDependencies": {
|
|
54
|
-
"@stacksjs/development": "
|
|
49
|
+
"@stacksjs/development": "0.65.1"
|
|
55
50
|
}
|
|
56
51
|
}
|
package/src/generators/google.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CalendarLink } from '../types'
|
|
2
|
+
import { useDateFormat } from '@stacksjs/browser'
|
|
2
3
|
|
|
3
4
|
const dateFormat = 'YYYYMMDD'
|
|
4
5
|
const timeFormat = 'YYYYMMDDThhmmss'
|
|
@@ -15,12 +16,15 @@ export function generateGoogle(link: CalendarLink): string {
|
|
|
15
16
|
useDateFormat(utcEndDateTime, dateTimeFormat).value
|
|
16
17
|
}`
|
|
17
18
|
|
|
18
|
-
if (link.timezone)
|
|
19
|
+
if (link.timezone)
|
|
20
|
+
url = `${url}&ctz=${link.timezone}`
|
|
19
21
|
|
|
20
22
|
url = `${url}&text=${encodeURIComponent(link.title)}`
|
|
21
23
|
|
|
22
|
-
if (link.description)
|
|
23
|
-
|
|
24
|
+
if (link.description)
|
|
25
|
+
url = `${url}&details=${encodeURIComponent(link.description)}`
|
|
26
|
+
if (link.address)
|
|
27
|
+
url = `${url}&location=${encodeURIComponent(link.address)}`
|
|
24
28
|
|
|
25
29
|
return url
|
|
26
30
|
}
|
package/src/generators/ics.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import md5 from 'crypto-js/md5'
|
|
2
1
|
import type { CalendarLink } from '../types'
|
|
2
|
+
import { useDateFormat, useMax } from '@stacksjs/browser'
|
|
3
|
+
import md5 from 'crypto-js/md5'
|
|
3
4
|
|
|
4
5
|
export function generateIcs(link: CalendarLink): string {
|
|
5
6
|
const dateFormat = 'YYYYMMDD'
|
|
@@ -25,14 +26,17 @@ export function generateIcs(link: CalendarLink): string {
|
|
|
25
26
|
url.push(`DTSTAMP;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
|
|
26
27
|
url.push(`DTSTART:${useDateFormat(link.from, dateTimeFormat).value}`)
|
|
27
28
|
url.push(`DURATION:P${useMax(1, dateDiffInDays(link.from, link.to)).value}D`)
|
|
28
|
-
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
29
31
|
url.push(`DTSTAMP;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
|
|
30
32
|
url.push(`DTSTART;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
|
|
31
33
|
url.push(`DTEND;TZID=${useDateFormat(link.to, dateTimeFormat).value}`)
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
if (link.description)
|
|
35
|
-
|
|
36
|
+
if (link.description)
|
|
37
|
+
url.push(`X-ALT-DESC;FMTTYPE=text/html:${link.description}`)
|
|
38
|
+
if (link.address)
|
|
39
|
+
url.push(`LOCATION:${link.address}`)
|
|
36
40
|
|
|
37
41
|
url.push('END:VEVENT')
|
|
38
42
|
url.push('END:VCALENDAR')
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CalendarLink } from '../types'
|
|
2
|
+
import { useDateFormat } from '@stacksjs/browser'
|
|
2
3
|
|
|
3
4
|
export function generateOutlook(link: CalendarLink): string {
|
|
4
5
|
const dateFormat = 'YYYY-MM-DD'
|
|
@@ -19,12 +20,15 @@ export function generateOutlook(link: CalendarLink): string {
|
|
|
19
20
|
? `${url}&enddt=${useDateFormat(utcEndDateTime, dateTimeFormat).value}`
|
|
20
21
|
: `${url}&enddt=${useDateFormat(utcEndDateTime, dateTimeFormat).value}Z`
|
|
21
22
|
|
|
22
|
-
if (link.allDay)
|
|
23
|
+
if (link.allDay)
|
|
24
|
+
url = `${url}&allday=true`
|
|
23
25
|
|
|
24
26
|
url = `${url}&subject=${encodeURIComponent(link.title)}`
|
|
25
27
|
|
|
26
|
-
if (link.description)
|
|
27
|
-
|
|
28
|
+
if (link.description)
|
|
29
|
+
url = `${url}&body=${encodeURIComponent(link.description)}`
|
|
30
|
+
if (link.address)
|
|
31
|
+
url = `${url}&location=${encodeURIComponent(link.address)}`
|
|
28
32
|
|
|
29
33
|
return url
|
|
30
34
|
}
|
package/src/generators/yahoo.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CalendarLink } from '../types'
|
|
2
|
+
import { useDateFormat } from '@stacksjs/browser'
|
|
2
3
|
|
|
3
4
|
export function generateYahoo(link: CalendarLink): string {
|
|
4
5
|
const dateFormat = 'YYYYMMDD'
|
|
@@ -13,15 +14,18 @@ export function generateYahoo(link: CalendarLink): string {
|
|
|
13
14
|
url = `${url}&ST=${useDateFormat(link.from, dateTimeFormat).value}`
|
|
14
15
|
url = `${url}&DUR=allday`
|
|
15
16
|
url = `${url}&ET=${useDateFormat(link.to, dateTimeFormat).value}`
|
|
16
|
-
}
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
17
19
|
url = `${url}&ST=${useDateFormat(utcStartDateTime, dateTimeFormat).value}Z`
|
|
18
20
|
url = `${url}&ET=${useDateFormat(utcEndDateTime, dateTimeFormat).value}Z`
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
url = `${url}&TITLE=${encodeURIComponent(link.title)}`
|
|
22
24
|
|
|
23
|
-
if (link.description)
|
|
24
|
-
|
|
25
|
+
if (link.description)
|
|
26
|
+
url = `${url}&DESC=${encodeURIComponent(link.description)}`
|
|
27
|
+
if (link.address)
|
|
28
|
+
url = `${url}&in_loc=${encodeURIComponent(link.address)}`
|
|
25
29
|
|
|
26
30
|
return url
|
|
27
31
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
|
+
import type { CalendarLink } from './types'
|
|
1
2
|
import { generateGoogle } from './generators/google'
|
|
2
3
|
import { generateIcs } from './generators/ics'
|
|
3
4
|
import { generateOutlook } from './generators/weboutlook'
|
|
4
5
|
import { generateYahoo } from './generators/yahoo'
|
|
5
|
-
import type { CalendarLink } from './types'
|
|
6
6
|
|
|
7
7
|
export function exportCalendarGoogle(link: CalendarLink): string {
|
|
8
8
|
return generateGoogle(link)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
// functions that mutate state and trigger updates
|
|
12
11
|
export function exportCalendarIcs(link: CalendarLink): string {
|
|
13
12
|
return generateIcs(link)
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
// functions that mutate state and trigger updates
|
|
17
15
|
export function exportCalendarOutlook(link: CalendarLink): string {
|
|
18
16
|
return generateOutlook(link)
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
// functions that mutate state and trigger updates
|
|
22
19
|
export function exportCalendarYahoo(link: CalendarLink): string {
|
|
23
20
|
return generateYahoo(link)
|
|
24
21
|
}
|