iamcal 2.1.2 → 3.0.1

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.
Files changed (63) hide show
  1. package/lib/component.d.ts +25 -4
  2. package/lib/component.d.ts.map +1 -1
  3. package/lib/component.js +60 -51
  4. package/lib/components/Calendar.d.ts +0 -20
  5. package/lib/components/Calendar.d.ts.map +1 -1
  6. package/lib/components/Calendar.js +2 -24
  7. package/lib/components/CalendarEvent.d.ts +1 -25
  8. package/lib/components/CalendarEvent.d.ts.map +1 -1
  9. package/lib/components/CalendarEvent.js +4 -29
  10. package/lib/components/TimeZone.d.ts +0 -38
  11. package/lib/components/TimeZone.d.ts.map +1 -1
  12. package/lib/components/TimeZone.js +1 -40
  13. package/lib/components/TimeZoneOffset.d.ts +0 -28
  14. package/lib/components/TimeZoneOffset.d.ts.map +1 -1
  15. package/lib/components/TimeZoneOffset.js +1 -30
  16. package/lib/date.d.ts +2 -10
  17. package/lib/date.d.ts.map +1 -1
  18. package/lib/date.js +15 -20
  19. package/lib/parse.d.ts +9 -16
  20. package/lib/parse.d.ts.map +1 -1
  21. package/lib/parse.js +188 -35
  22. package/lib/patterns.d.ts +28 -0
  23. package/lib/patterns.d.ts.map +1 -1
  24. package/lib/patterns.js +56 -2
  25. package/lib/property/Property.d.ts +344 -0
  26. package/lib/property/Property.d.ts.map +1 -0
  27. package/lib/property/Property.js +508 -0
  28. package/lib/property/escape.d.ts +46 -0
  29. package/lib/property/escape.d.ts.map +1 -0
  30. package/lib/property/escape.js +129 -0
  31. package/lib/property/index.d.ts +7 -0
  32. package/lib/property/index.d.ts.map +1 -0
  33. package/lib/property/index.js +23 -0
  34. package/lib/property/names.d.ts +11 -0
  35. package/lib/property/names.d.ts.map +1 -0
  36. package/lib/property/names.js +62 -0
  37. package/lib/property/parameter.d.ts +10 -0
  38. package/lib/property/parameter.d.ts.map +1 -0
  39. package/lib/property/parameter.js +3 -0
  40. package/lib/{property.d.ts → property/validate.d.ts} +9 -35
  41. package/lib/property/validate.d.ts.map +1 -0
  42. package/lib/property/validate.js +317 -0
  43. package/lib/property/valueType.d.ts +18 -0
  44. package/lib/property/valueType.d.ts.map +1 -0
  45. package/lib/property/valueType.js +82 -0
  46. package/package.json +3 -1
  47. package/src/component.ts +58 -52
  48. package/src/components/Calendar.ts +6 -30
  49. package/src/components/CalendarEvent.ts +7 -33
  50. package/src/components/TimeZone.ts +3 -51
  51. package/src/components/TimeZoneOffset.ts +5 -40
  52. package/src/date.ts +14 -30
  53. package/src/parse.ts +212 -40
  54. package/src/patterns.ts +64 -0
  55. package/src/property/Property.ts +609 -0
  56. package/src/property/escape.ts +132 -0
  57. package/src/property/index.ts +6 -0
  58. package/src/property/names.ts +65 -0
  59. package/src/property/parameter.ts +33 -0
  60. package/src/{property.ts → property/validate.ts} +23 -204
  61. package/src/property/valueType.ts +87 -0
  62. package/lib/property.d.ts.map +0 -1
  63. package/lib/property.js +0 -450
@@ -0,0 +1,132 @@
1
+ import { ord } from '../patterns'
2
+
3
+ /**
4
+ * Escape special characters in a TEXT property value.
5
+ *
6
+ * Note: This method converts both CRLF and LF to '\n'.
7
+ * @param value The property value to escape.
8
+ * @returns The escaped property value.
9
+ * @see {@link unescapeTextPropertyValue}
10
+ */
11
+ export function escapeTextPropertyValue(value: string): string {
12
+ return value.replace(/(?=[,;\\])/g, '\\').replace(/\r?\n/g, '\\n')
13
+ }
14
+
15
+ /**
16
+ * Unescape special characters in a TEXT property value.
17
+ * @param value The property value to unescape.
18
+ * @returns The unescaped property value.
19
+ * @throws If the value contains a bad escaped character, i.e., a character that should not be escaped after a backslash.
20
+ * @see {@link unescapeTextPropertyValue}
21
+ */
22
+ export function unescapeTextPropertyValue(value: string): string {
23
+ /** List that will contain the characters of the unescaped string. */
24
+ const chars: number[] = []
25
+
26
+ // Character codes for special characters
27
+ const backslash = ord('\\')
28
+ const newline = ord('\n')
29
+ const lowercaseN = ord('n')
30
+ const uppercaseN = ord('N')
31
+ const comma = ord(',')
32
+ const semicolon = ord(';')
33
+
34
+ let previousCharWasBackslash = false
35
+ for (let i = 0; i < value.length; i++) {
36
+ const char = value.charCodeAt(i)
37
+
38
+ if (previousCharWasBackslash) {
39
+ // Previous character was a backslash, so this character is the second character in an escape sequence
40
+ if (char === lowercaseN || char === uppercaseN) {
41
+ chars.push(newline)
42
+ } else if (
43
+ char === comma ||
44
+ char === semicolon ||
45
+ char === backslash
46
+ ) {
47
+ chars.push(char)
48
+ } else {
49
+ const position = i - 1
50
+ throw new SyntaxError(
51
+ `Bad escaped character '\\${String.fromCharCode(char)}' at position ${position}`
52
+ )
53
+ }
54
+ // End the escape sequence
55
+ previousCharWasBackslash = false
56
+ } else if (char === backslash) {
57
+ // Start of an escape sequence
58
+ previousCharWasBackslash = true
59
+ } else {
60
+ chars.push(char)
61
+ }
62
+ }
63
+
64
+ return String.fromCharCode(...chars)
65
+ }
66
+
67
+ /**
68
+ * Escape a property parameter value.
69
+ * @param param The parameter value to escape.
70
+ * @returns The escaped parameter value.
71
+ * @throws If the parameter value contains a DQUOTE (") character.
72
+ * @see {@link unescapePropertyParameterValue}
73
+ */
74
+ export function escapePropertyParameterValue(param: string): string {
75
+ // Property parameter values MUST NOT contain the DQUOTE character. The
76
+ // DQUOTE character is used as a delimiter for parameter values that
77
+ // contain restricted characters or URI text.
78
+ if (param.includes('"')) {
79
+ throw new Error('Parameter value must not contain DQUOTE (").')
80
+ }
81
+
82
+ // Property parameter values that contain the COLON, SEMICOLON, or COMMA
83
+ // character separators MUST be specified as quoted-string text values.
84
+ if (/[:;,]/.test(param)) {
85
+ return `"${param}"`
86
+ }
87
+ return param
88
+ }
89
+
90
+ /**
91
+ * Unescape a property parameter value.
92
+ * @param param The parameter value to unescape.
93
+ * @returns The unescaped parameter value.
94
+ * @see {@link escapePropertyParameterValue}
95
+ */
96
+ export function unescapePropertyParameterValue(param: string): string {
97
+ if (param.startsWith('"') && param.endsWith('"')) {
98
+ return param.slice(1, -1)
99
+ }
100
+ return param
101
+ }
102
+
103
+ // Max line length as defined by RFC 5545 3.1.
104
+ export const MAX_LINE_LENGTH = 75
105
+
106
+ /**
107
+ * Fold a single line as specified in RFC 5545 3.1.
108
+ * @param line The line to fold.
109
+ * @returns The folded line.
110
+ */
111
+ export function foldLine(line: string): string {
112
+ if (line.length < MAX_LINE_LENGTH) return line
113
+
114
+ const lines = [line.substring(0, MAX_LINE_LENGTH)]
115
+ const matches = line
116
+ .substring(MAX_LINE_LENGTH)
117
+ .matchAll(new RegExp(`.{${MAX_LINE_LENGTH - 2}}`, 'g'))
118
+ for (const match of matches) {
119
+ lines.push(match[0])
120
+ }
121
+
122
+ return lines.join('\r\n ')
123
+ }
124
+
125
+ /**
126
+ * Unfold a single line as specified in RFC 5545 3.1.
127
+ * @param lines The lines to unfold.
128
+ * @returns The unfolded line.
129
+ */
130
+ export function unfoldLine(lines: string): string {
131
+ return lines.replace(/\r\n /g, '')
132
+ }
@@ -0,0 +1,6 @@
1
+ export * from './escape'
2
+ export * from './names'
3
+ export * from './parameter'
4
+ export * from './Property'
5
+ export * from './validate'
6
+ export * from './valueType'
@@ -0,0 +1,65 @@
1
+ export const knownPropertyNames = [
2
+ 'CALSCALE',
3
+ 'METHOD',
4
+ 'PRODID',
5
+ 'VERSION',
6
+ 'ATTACH',
7
+ 'CATEGORIES',
8
+ 'CLASS',
9
+ 'COMMENT',
10
+ 'DESCRIPTION',
11
+ 'GEO',
12
+ 'LOCATION',
13
+ 'PERCENT-COMPLETE',
14
+ 'PRIORITY',
15
+ 'RESOURCES',
16
+ 'STATUS',
17
+ 'SUMMARY',
18
+ 'COMPLETED',
19
+ 'DTEND',
20
+ 'DUE',
21
+ 'DTSTART',
22
+ 'DURATION',
23
+ 'FREEBUSY',
24
+ 'TRANSP',
25
+ 'TZID',
26
+ 'TZNAME',
27
+ 'TZOFFSETFROM',
28
+ 'TZOFFSETTO',
29
+ 'TZURL',
30
+ 'ATTENDEE',
31
+ 'CONTACT',
32
+ 'ORGANIZER',
33
+ 'RECURRENCE-ID',
34
+ 'RELATED-TO',
35
+ 'URL',
36
+ 'UID',
37
+ 'EXDATE',
38
+ 'RDATE',
39
+ 'RRULE',
40
+ 'ACTION',
41
+ 'REPEAT',
42
+ 'TRIGGER',
43
+ 'CREATED',
44
+ 'DTSTAMP',
45
+ 'LAST-MODIFIED',
46
+ 'SEQUENCE',
47
+ 'REQUEST-STATUS',
48
+ ] as const
49
+ export type KnownPropertyName = (typeof knownPropertyNames)[number]
50
+ export type AllowedPropertyName =
51
+ | KnownPropertyName
52
+ | (`X-${string}` & {})
53
+ | (string & {})
54
+
55
+ /**
56
+ * Check if a property name is known. A property name is known if it is present
57
+ * in {@link knownPropertyNames}.
58
+ * @param name The property name to check.
59
+ * @returns If the name is a known property name.
60
+ */
61
+ export function isKnownPropertyName(
62
+ name: AllowedPropertyName
63
+ ): name is KnownPropertyName {
64
+ return knownPropertyNames.includes(name as KnownPropertyName)
65
+ }
@@ -0,0 +1,33 @@
1
+ export type CalendarUserType =
2
+ | 'INDIVIDUAL'
3
+ | 'GROUP'
4
+ | 'RESOURCE'
5
+ | 'ROOM'
6
+ | 'UNKNOWN'
7
+ | (string & {})
8
+ export type Encoding = '8BIT' | 'BASE64'
9
+ export type FreeBusyTimeType =
10
+ | 'FREE'
11
+ | 'BUSY'
12
+ | 'BUSY-UNAVAILABLE'
13
+ | 'BUSY-TENTATIVE'
14
+ | (string & {})
15
+ export type ParticipationStatus =
16
+ | 'NEEDS-ACTION'
17
+ | 'ACCEPTED'
18
+ | 'DECLINED'
19
+ | 'TENTATIVE'
20
+ | 'DELEGATED'
21
+ | 'COMPLETED'
22
+ | 'IN-PROCESS'
23
+ | (string & {})
24
+ export type RecurrenceIdentifierRange = 'THISANDFUTURE'
25
+ export type AlarmTriggerRelationship = 'START' | 'END'
26
+ export type RelationshipType = 'PARENT' | 'CHILD' | 'SIBLING' | (string & {})
27
+ export type ParticipationRole =
28
+ | 'CHAIR'
29
+ | 'REQ-PARTICIPANT'
30
+ | 'OPT-PARTICIPANT'
31
+ | 'NON-PARTICIPANT'
32
+ | (string & {})
33
+ export type RsvpExpectation = 'TRUE' | 'FALSE'
@@ -1,185 +1,9 @@
1
- import { parseDateString, parseDateTimeString } from './date'
2
- import * as patterns from './patterns'
3
- import { matchesWholeString } from './patterns'
4
-
5
- export interface Property {
6
- name: string
7
- params: string[]
8
- value: string
9
- }
10
-
11
- export const knownPropertyNames = [
12
- 'CALSCALE',
13
- 'METHOD',
14
- 'PRODID',
15
- 'VERSION',
16
- 'ATTACH',
17
- 'CATEGORIES',
18
- 'CLASS',
19
- 'COMMENT',
20
- 'DESCRIPTION',
21
- 'GEO',
22
- 'LOCATION',
23
- 'PERCENT-COMPLETE',
24
- 'PRIORITY',
25
- 'RESOURCES',
26
- 'STATUS',
27
- 'SUMMARY',
28
- 'COMPLETED',
29
- 'DTEND',
30
- 'DUE',
31
- 'DTSTART',
32
- 'DURATION',
33
- 'FREEBUSY',
34
- 'TRANSP',
35
- 'TZID',
36
- 'TZNAME',
37
- 'TZOFFSETFROM',
38
- 'TZOFFSETTO',
39
- 'TZURL',
40
- 'ATTENDEE',
41
- 'CONTACT',
42
- 'ORGANIZER',
43
- 'RECURRENCE-ID',
44
- 'RELATED-TO',
45
- 'URL',
46
- 'UID',
47
- 'EXDATE',
48
- 'RDATE',
49
- 'RRULE',
50
- 'ACTION',
51
- 'REPEAT',
52
- 'TRIGGER',
53
- 'CREATED',
54
- 'DTSTAMP',
55
- 'LAST-MODIFIED',
56
- 'SEQUENCE',
57
- 'REQUEST-STATUS',
58
- ] as const
59
- export type KnownPropertyName = (typeof knownPropertyNames)[number]
60
- export type AllowedPropertyName =
61
- | KnownPropertyName
62
- | (`X-${string}` & {})
63
- | (string & {})
64
-
65
- export const knownValueTypes = [
66
- 'BINARY',
67
- 'BOOLEAN',
68
- 'CAL-ADDRESS',
69
- 'DATE',
70
- 'DATE-TIME',
71
- 'DURATION',
72
- 'FLOAT',
73
- 'INTEGER',
74
- 'PERIOD',
75
- 'RECUR',
76
- 'TEXT',
77
- 'TIME',
78
- 'URI',
79
- 'UTC-OFFSET',
80
- ] as const
81
- export type KnownValueType = (typeof knownValueTypes)[number]
82
- export type AllowedValueType = KnownValueType | (string & {})
83
-
84
- /**
85
- * The value types that each property supports as defined by the iCalendar
86
- * specification. The first in the list is the default type.
87
- */
88
- export const supportedValueTypes: {
89
- [name in KnownPropertyName]: KnownValueType[]
90
- } = {
91
- CALSCALE: ['TEXT'],
92
- METHOD: ['TEXT'],
93
- PRODID: ['TEXT'],
94
- VERSION: ['TEXT'],
95
- ATTACH: ['URI', 'BINARY'],
96
- CATEGORIES: ['TEXT'],
97
- CLASS: ['TEXT'],
98
- COMMENT: ['TEXT'],
99
- DESCRIPTION: ['TEXT'],
100
- GEO: ['FLOAT'],
101
- LOCATION: ['TEXT'],
102
- 'PERCENT-COMPLETE': ['INTEGER'],
103
- PRIORITY: ['INTEGER'],
104
- RESOURCES: ['TEXT'],
105
- STATUS: ['TEXT'],
106
- SUMMARY: ['TEXT'],
107
- COMPLETED: ['DATE-TIME'],
108
- DTEND: ['DATE-TIME', 'DATE'],
109
- DUE: ['DATE-TIME', 'DATE'],
110
- DTSTART: ['DATE-TIME', 'DATE'],
111
- DURATION: ['DURATION'],
112
- FREEBUSY: ['PERIOD'],
113
- TRANSP: ['TEXT'],
114
- TZID: ['TEXT'],
115
- TZNAME: ['TEXT'],
116
- TZOFFSETFROM: ['UTC-OFFSET'],
117
- TZOFFSETTO: ['UTC-OFFSET'],
118
- TZURL: ['URI'],
119
- ATTENDEE: ['CAL-ADDRESS'],
120
- CONTACT: ['TEXT'],
121
- ORGANIZER: ['CAL-ADDRESS'],
122
- 'RECURRENCE-ID': ['DATE-TIME', 'DATE'],
123
- 'RELATED-TO': ['TEXT'],
124
- URL: ['URI'],
125
- UID: ['TEXT'],
126
- EXDATE: ['DATE-TIME', 'DATE'],
127
- RDATE: ['DATE-TIME', 'DATE', 'PERIOD'],
128
- RRULE: ['RECUR'],
129
- ACTION: ['TEXT'],
130
- REPEAT: ['INTEGER'],
131
- TRIGGER: ['DURATION', 'DATE-TIME'],
132
- CREATED: ['DATE-TIME'],
133
- DTSTAMP: ['DATE-TIME'],
134
- 'LAST-MODIFIED': ['DATE-TIME'],
135
- SEQUENCE: ['INTEGER'],
136
- 'REQUEST-STATUS': ['TEXT'],
137
- }
138
-
139
- /**
140
- * Get the value type of a property, as defined by the VALUE parameter.
141
- * @param property The property to get the value type of.
142
- * @returns The value type if present, else `undefined`.
143
- * @throws If the parameter value is misformed.
144
- */
145
- export function getPropertyValueType(
146
- property: Property
147
- ): AllowedValueType | undefined
148
-
149
- /**
150
- * Get the value type of a property, as defined by the VALUE parameter.
151
- * @param property The property to get the value type of.
152
- * @param defaultValue The default value to return if the property VALUE parameter is not present.
153
- * @returns The value type if present, else `defaultValue` or `undefined`.
154
- * @throws If the parameter value is misformed.
155
- */
156
- export function getPropertyValueType(
157
- property: Property,
158
- defaultValue: AllowedValueType
159
- ): AllowedValueType
160
- export function getPropertyValueType(
161
- property: Property,
162
- defaultValue: AllowedValueType | undefined
163
- ): AllowedValueType | undefined
164
- export function getPropertyValueType(
165
- property: Property,
166
- defaultValue?: AllowedValueType | undefined
167
- ): AllowedValueType | undefined {
168
- const found = property.params.find(param => /^VALUE=.+$/i.test(param))
169
- if (!found) return defaultValue
170
-
171
- if (!patterns.matchesWholeString(patterns.paramValue, found)) {
172
- throw new Error('Parameter value is misformed')
173
- }
174
-
175
- // Return as uppercase if known value
176
- const value = found?.split('=')[1]
177
- if ((knownValueTypes as readonly string[]).includes(value.toUpperCase())) {
178
- return value.toUpperCase()
179
- }
180
-
181
- return value
182
- }
1
+ import { parseDateString, parseDateTimeString } from '../date'
2
+ import * as patterns from '../patterns'
3
+ import { matchesWholeString } from '../patterns'
4
+ import type { Property } from './Property'
5
+ import { isKnownPropertyName, type KnownPropertyName } from './names'
6
+ import { type AllowedValueType, supportedValueTypes } from './valueType'
183
7
 
184
8
  /** Represents an error which occurs while validating a calendar property. */
185
9
  export class PropertyValidationError extends Error {
@@ -431,6 +255,18 @@ export function validateValue(value: string, type: AllowedValueType) {
431
255
  }
432
256
  }
433
257
 
258
+ /**
259
+ * Validate if a value is a valid content type.
260
+ * @param value The value to validate.
261
+ * @throws {PropertyValidationError} If the validation fails.
262
+ */
263
+ export function validateContentType(value: string) {
264
+ if (!matchesWholeString(patterns.contentType, value))
265
+ throw new PropertyValidationError(
266
+ `${value} does not match pattern for content type`
267
+ )
268
+ }
269
+
434
270
  /* eslint-disable jsdoc/require-description-complete-sentence --
435
271
  * Does not allow line to end with ':'.
436
272
  **/
@@ -452,32 +288,15 @@ export function validateValue(value: string, type: AllowedValueType) {
452
288
  export function validateProperty(property: Property) {
453
289
  // Get supported and default types
454
290
  let supportedTypes: AllowedValueType[] | undefined = undefined
455
- let defaultType: AllowedValueType | undefined = undefined
456
-
457
- if (knownPropertyNames.includes(property.name as KnownPropertyName)) {
458
- const name = property.name as KnownPropertyName
291
+ if (isKnownPropertyName(property.name)) {
292
+ const name: KnownPropertyName = property.name
459
293
  supportedTypes = supportedValueTypes[name]
460
- defaultType = supportedTypes[0]
461
294
  }
462
295
 
463
- // Find value type
464
- const valueType = getPropertyValueType(property, defaultType)
465
-
466
- // If value type is unknown, validate as TEXT
467
- if (valueType === undefined) {
468
- try {
469
- validateText(property.value)
470
- } catch (e) {
471
- throw e instanceof PropertyValidationError
472
- ? new PropertyValidationError(
473
- `Unknown property ${property.name} is not valid text`
474
- )
475
- : e
476
- }
477
- return
478
- }
296
+ // Get value type
297
+ const valueType = property.getValueType()
479
298
 
480
- // Check if type is unsupported
299
+ // Check if value type is unsupported by the property
481
300
  if (supportedTypes !== undefined && !supportedTypes.includes(valueType)) {
482
301
  throw new PropertyValidationError(
483
302
  supportedTypes.length === 1
@@ -0,0 +1,87 @@
1
+ import type { AllowedPropertyName, KnownPropertyName } from './names'
2
+
3
+ export const knownValueTypes = [
4
+ 'BINARY',
5
+ 'BOOLEAN',
6
+ 'CAL-ADDRESS',
7
+ 'DATE',
8
+ 'DATE-TIME',
9
+ 'DURATION',
10
+ 'FLOAT',
11
+ 'INTEGER',
12
+ 'PERIOD',
13
+ 'RECUR',
14
+ 'TEXT',
15
+ 'TIME',
16
+ 'URI',
17
+ 'UTC-OFFSET',
18
+ ] as const
19
+ export type KnownValueType = (typeof knownValueTypes)[number]
20
+ export type AllowedValueType = KnownValueType | (string & {})
21
+
22
+ /**
23
+ * The value types that each known property supports as defined by the iCalendar
24
+ * specification. The first in the list is the default type.
25
+ */
26
+ export const supportedValueTypes: {
27
+ [name in KnownPropertyName]: KnownValueType[]
28
+ } = {
29
+ CALSCALE: ['TEXT'],
30
+ METHOD: ['TEXT'],
31
+ PRODID: ['TEXT'],
32
+ VERSION: ['TEXT'],
33
+ ATTACH: ['URI', 'BINARY'],
34
+ CATEGORIES: ['TEXT'],
35
+ CLASS: ['TEXT'],
36
+ COMMENT: ['TEXT'],
37
+ DESCRIPTION: ['TEXT'],
38
+ GEO: ['FLOAT'],
39
+ LOCATION: ['TEXT'],
40
+ 'PERCENT-COMPLETE': ['INTEGER'],
41
+ PRIORITY: ['INTEGER'],
42
+ RESOURCES: ['TEXT'],
43
+ STATUS: ['TEXT'],
44
+ SUMMARY: ['TEXT'],
45
+ COMPLETED: ['DATE-TIME'],
46
+ DTEND: ['DATE-TIME', 'DATE'],
47
+ DUE: ['DATE-TIME', 'DATE'],
48
+ DTSTART: ['DATE-TIME', 'DATE'],
49
+ DURATION: ['DURATION'],
50
+ FREEBUSY: ['PERIOD'],
51
+ TRANSP: ['TEXT'],
52
+ TZID: ['TEXT'],
53
+ TZNAME: ['TEXT'],
54
+ TZOFFSETFROM: ['UTC-OFFSET'],
55
+ TZOFFSETTO: ['UTC-OFFSET'],
56
+ TZURL: ['URI'],
57
+ ATTENDEE: ['CAL-ADDRESS'],
58
+ CONTACT: ['TEXT'],
59
+ ORGANIZER: ['CAL-ADDRESS'],
60
+ 'RECURRENCE-ID': ['DATE-TIME', 'DATE'],
61
+ 'RELATED-TO': ['TEXT'],
62
+ URL: ['URI'],
63
+ UID: ['TEXT'],
64
+ EXDATE: ['DATE-TIME', 'DATE'],
65
+ RDATE: ['DATE-TIME', 'DATE', 'PERIOD'],
66
+ RRULE: ['RECUR'],
67
+ ACTION: ['TEXT'],
68
+ REPEAT: ['INTEGER'],
69
+ TRIGGER: ['DURATION', 'DATE-TIME'],
70
+ CREATED: ['DATE-TIME'],
71
+ DTSTAMP: ['DATE-TIME'],
72
+ 'LAST-MODIFIED': ['DATE-TIME'],
73
+ SEQUENCE: ['INTEGER'],
74
+ 'REQUEST-STATUS': ['TEXT'],
75
+ }
76
+
77
+ /**
78
+ * Get the default value type of a property based on its name.
79
+ * @param name The name of the property.
80
+ * @returns The default value type of the property, or `TEXT` if the property is unknown.
81
+ */
82
+ export function getDefaultValueType(name: AllowedPropertyName): KnownValueType {
83
+ const defaultType = supportedValueTypes[
84
+ name.toUpperCase() as KnownPropertyName
85
+ ]?.[0] as KnownValueType | undefined
86
+ return defaultType ?? 'TEXT'
87
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../src/property.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,kBAAkB,0hBA+CrB,CAAA;AACV,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAA;AACnE,MAAM,MAAM,mBAAmB,GACzB,iBAAiB,GACjB,CAAC,KAAK,MAAM,EAAE,GAAG,EAAE,CAAC,GACpB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEnB,eAAO,MAAM,eAAe,4JAelB,CAAA;AACV,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC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