forked from Zimbra/zm-api-js-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entities.ts
665 lines (559 loc) · 13.4 KB
/
entities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
import { Entity } from '.';
/**
* This file provides the schema necessary to normalize/denormalize the json response we get from the zimbra-apis
* into more human-readable field names and vice-versa for sending data from our codebase to the zimbra apis.
*
* It is only necessary to specify fields that you want renamed. Fields that you do not want renamed will be kept and be unmodified
*/
const MimePart = new Entity({
cd: 'contentDisposition',
ci: 'contentId',
ct: 'contentType',
s: 'size',
part: 'part',
mid: 'messageId',
content: 'content'
});
const CalendarItemAlarmTriggerRelative = new Entity({
w: 'weeks',
d: 'days',
h: 'hours',
m: 'minutes',
s: 'seconds',
related: 'relatedTo',
neg: 'negative'
});
const CalendarItemAlarmTrigger = new Entity({
rel: ['relative', CalendarItemAlarmTriggerRelative]
});
const IntervalRule = new Entity({
ival: 'intervalCount'
});
const NumOfOccurences = new Entity({
num: 'number'
});
const UntilDate = new Entity({
d: 'date'
});
const ByMonthDayRule = new Entity({
modaylist: 'dayList'
});
const ByMonthRule = new Entity({
molist: 'monthList'
});
const SimpleRepeatingRule = new Entity({
freq: 'frequency',
interval: ['interval', IntervalRule],
count: ['count', NumOfOccurences],
until: ['until', UntilDate],
bymonthday: ['bymonthday', ByMonthDayRule],
bymonth: ['bymonth', ByMonthRule]
});
const AddRecurrenceInfo = new Entity({
rule: ['rule', SimpleRepeatingRule]
});
const RecurrenceInfo = new Entity({
add: ['add', AddRecurrenceInfo]
});
const CalendarItemAlarmAttendees = new Entity({
a: 'email'
});
const CalendarItemAlarm = new Entity({
trigger: CalendarItemAlarmTrigger,
at: ['attendees', CalendarItemAlarmAttendees]
});
const CalendarItemDateTime = new Entity({
d: 'date',
tz: 'timezone',
tzoDue: 'timezoneDue',
u: 'utc'
});
const CalendarItemAttendees = new Entity({
ptst: 'participationStatus',
a: 'address',
d: 'name',
cutype: 'calendarUserType'
});
const CalendarItemReply = new Entity({
ptst: 'participationStatus',
at: 'attendee'
});
const CalendarItemOrganizer = new Entity({
a: 'address',
d: 'name'
});
const commonFieldForMessageAndDocuments = {
d: 'date',
f: 'flags',
l: 'folderId',
md: 'changeDate',
ms: 'modifiedSequence',
rev: 'revision',
s: 'size',
sf: 'sortField',
t: 'tags',
tn: 'tagNames'
};
const commonMessageFields = {
...commonFieldForMessageAndDocuments,
cid: 'conversationId',
fr: 'excerpt'
};
const commonInviteFields = {
compNum: 'componentNum',
calItemId: 'calendarItemId',
fb: 'freeBusy',
fba: 'freeBusyActual',
fr: 'excerpt',
isOrg: 'isOrganizer',
invId: 'inviteId',
loc: 'location',
or: ['organizer', CalendarItemOrganizer],
ridZ: 'utcRecurrenceId'
};
const InviteComponent = new Entity({
...commonMessageFields,
...commonInviteFields,
alarm: ['alarms', CalendarItemAlarm],
at: ['attendees', CalendarItemAttendees],
completed: 'completedDateTime',
desc: 'description',
descHtml: 'htmlDescription',
e: ['end', CalendarItemDateTime],
ex: 'isException',
recur: ['recurrence', RecurrenceInfo],
s: ['start', CalendarItemDateTime],
exceptId: ['exceptId', CalendarItemDateTime],
seq: 'sequence'
});
const InviteReplies = new Entity({
reply: ['reply', CalendarItemReply]
});
const CalTZInfo = new Entity({
stdoff: 'timezoneStdOffset',
dayoff: 'timezoneDaylightOffset'
});
const Invitation = new Entity({
seq: 'sequenceNumber',
compNum: 'componentNum',
recurId: 'recurrenceId',
tz: ['tz', CalTZInfo],
comp: ['components', InviteComponent],
replies: ['replies', InviteReplies],
mp: ['mimeParts', MimePart]
});
const InviteInfo = new Entity({
comp: ['components', InviteComponent],
replies: ['replies', InviteReplies],
mp: ['mimeParts', MimePart]
});
const MailItemEmailAddress = new Entity({
a: 'address',
p: 'name',
d: 'displayName',
t: 'type'
});
const ExistingAttachmentsInfo = new Entity({
mid: 'messageId',
part: 'part'
});
const AttachmentsInfo = new Entity({
aid: 'attachmentId',
doc: 'documents',
mp: ['existingAttachments', ExistingAttachmentsInfo]
});
MimePart.addMapping({
mp: ['mimeParts', MimePart],
attach: ['attachments', AttachmentsInfo]
});
const commonMailItemFields = {
...commonMessageFields,
e: ['emailAddresses', MailItemEmailAddress],
inv: ['invitations', InviteInfo],
mp: ['mimeParts', MimePart],
shr: 'share',
su: 'subject',
origid: 'origId',
attach: ['attachments', AttachmentsInfo],
rt: 'replyType'
};
const SendMessageFields = new Entity({
...commonMailItemFields,
id: 'id',
aid: 'attachmentId',
irt: 'inReplyTo',
rt: 'replyType',
did: 'draftId',
idnt: 'entityId'
});
export const SendMessageInfo = new Entity({
m: ['message', SendMessageFields]
});
export const MessageInfo = new Entity({
...commonMailItemFields
});
export const AppointmentInfo = new Entity({
inv: ['invitations', Invitation]
});
export const Conversation = new Entity({
...commonMailItemFields,
n: 'numMessages',
m: ['messages', MessageInfo],
u: 'unread'
});
export const SearchConversation = new Entity({
...commonMailItemFields,
n: 'numMessages',
m: ['messagesMetaData', MessageInfo],
u: 'unread'
});
export const CalendarItemCreateModifyRequest = new Entity({
rev: 'revision',
comp: 'componentNum',
m: ['message', MessageInfo],
apptId: 'appointmentId',
calItemId: 'calendarItemId',
invId: 'inviteId'
});
export const CounterAppointmentInfo = new Entity({
rev: 'revision',
comp: 'componentNum',
m: ['message', MessageInfo],
invId: 'inviteId'
});
export const InstanceDate = new Entity({
d: 'date',
tz: 'timezone'
});
export const CalendarItemDeleteRequest = new Entity({
inst: ['instanceDate', InstanceDate],
id: 'inviteId',
comp: 'componentNum',
s: 'start',
m: ['message', MessageInfo]
});
const NewMountpointSpec = new Entity({
rid: 'sharedItemId',
zid: 'ownerZimbraId',
f: 'flags',
l: 'parentFolderId'
});
export const CreateMountpointRequest = new Entity({
link: NewMountpointSpec
});
const commonAccessControlEntities = {
d: 'address',
gt: 'granteeType',
zid: 'zimbraId',
pw: 'password'
};
const ACLGrant = new Entity({
...commonAccessControlEntities,
perm: 'permissions'
});
const ACL = new Entity({
grant: ACLGrant
});
const ShareNotificationAddress = new Entity({
a: 'address',
t: 'type',
p: 'personalName'
});
const Instance = new Entity({
...commonMessageFields,
...commonInviteFields,
otherAtt: 'otherAttendees',
s: 'start',
ptst: 'participationStatus',
dur: 'duration',
ex: 'isException'
});
const Alarm = new Entity({
compNum: 'componentNum',
invId: 'inviteId',
loc: 'location'
});
export const CalendarItemHitInfo = new Entity({
...commonMessageFields,
...commonInviteFields,
recur: 'isRecurring',
ptst: 'participationStatus',
dur: 'duration',
tzo: 'timezoneOffset',
otherAtt: 'otherAttendees',
inst: ['instances', Instance],
inv: ['invitations', Invitation],
alarmData: ['alarmData', Alarm],
sf: 'sortField'
});
export const Hit = new Entity({
sf: 'sortField'
});
const Folder = new Entity({
u: 'unread',
l: 'parentFolderId',
f: 'flags',
n: 'nonFolderItemCount',
s: 'nonFolderItemCountTotal',
rev: 'revision',
acl: ACL,
perm: 'permissions',
rid: 'sharedItemId',
zid: 'ownerZimbraId'
});
Folder.addMapping({
folder: ['folders', Folder],
link: ['linkedFolders', Folder]
});
export { Folder };
const ForwardMessageInput = new Entity({
e: ['emailAddresses', MailItemEmailAddress],
mp: ['mimeParts', MimePart],
su: 'subject'
});
export const ForwardAppointmentInfo = new Entity({
m: ['message', ForwardMessageInput],
exceptId: ['exceptId', InstanceDate]
});
export const ForwardAppointmentInviteInfo = new Entity({
m: ['message', ForwardMessageInput]
});
export const FreeBusyInstance = new Entity({
s: 'start',
e: 'end'
});
export const FreeBusy = new Entity({
t: ['tentative', FreeBusyInstance],
f: ['free', FreeBusyInstance],
b: ['busy', FreeBusyInstance],
u: ['unavailable', FreeBusyInstance],
n: ['nodata', FreeBusyInstance]
});
export const ActionOptions = new Entity({
l: 'folderId',
tcon: 'constraints',
tn: 'tagNames',
f: 'flags',
zid: 'zimbraId',
grant: ACLGrant
});
export const AutoComplete = new Entity({
t: 'type'
});
export const AutoCompleteMatch = new Entity({
l: 'folderId'
});
export const AutoCompleteResponse = new Entity({
match: AutoCompleteMatch
});
export const ShareNotification = new Entity({
e: ['address', ShareNotificationAddress]
});
export const ExternalCalendar = new Entity({
name: 'accountName',
l: 'folderId'
});
const ImageFields = new Entity({
ct: 'contentType',
s: 'size'
});
const ContactAttributes = new Entity({
image: ImageFields
});
const contactFields = {
d: 'date',
l: 'folderId',
rev: 'revision',
sf: 'sortField',
t: 'tags',
tn: 'tagNames',
_attrs: ['attributes', ContactAttributes]
};
const contactListMembers = new Entity({
cn: ['contacts', new Entity({ ...contactFields })]
});
export const ClientInfoResponse = new Entity({
_attrs: 'attributes'
});
export const Contact = new Entity({
...contactFields,
m: ['members', contactListMembers]
});
export const AutoCompleteGALResponse = new Entity({
cn: ['contacts', Contact]
});
export const Appointment = new Entity({
alarm: 'alarm',
inst: ['instances', Instance]
});
export const Document = new Entity({
...commonFieldForMessageAndDocuments,
luuid: 'folderUuid',
mdver: 'metadataVersion',
meta: 'metaData',
descEnabled: 'descriptionEnabled',
ver: 'version', //same item may have different versions (i.e same names) will need to implement ListDocumentRevisionsRequest
leb: 'lastEditedAccount',
cr: 'revisonCreator',
cd: 'revisedCreationDate',
loid: 'lockOwnerId',
ct: 'contentType'
});
export const MessagePartInputForDocuments = new Entity({
id: 'messageId',
part: 'attachmentPart'
});
export const SaveDocument = new Entity({
l: 'folderId',
name: 'name',
ver: 'version', //same item may have different versions (i.e same names) will need to implement ListDocumentRevisionsRequest
ct: 'contentType',
descEnabled: 'descriptionEnabled',
m: ['messageData', MessagePartInputForDocuments]
});
export const SearchResponse = new Entity({
m: ['messages', MessageInfo],
c: ['conversations', SearchConversation],
cn: ['contacts', Contact],
appt: ['appointments', CalendarItemHitInfo],
doc: ['documents', Document],
hit: Hit
});
export const GetAppointmentResponse = new Entity({
appt: ['appointment', AppointmentInfo]
});
const RedirectAction = new Entity({
a: 'address'
});
const NotifyAction = new Entity({
a: 'address',
su: 'subject'
});
const FilterAction = new Entity({
actionKeep: 'keep',
actionDiscard: 'discard',
actionFileInto: 'fileInto',
actionFlag: 'flag',
actionTag: 'tag',
actionRedirect: ['redirect', RedirectAction],
actionReply: 'reply',
actionNotify: ['notify', NotifyAction],
actionStop: 'stop'
});
const DateCondition = new Entity({
d: 'date'
});
const ImportanceCondition = new Entity({
imp: 'importance'
});
const SizeCondition = new Entity({
s: 'size'
});
const FilterCondition = new Entity({
condition: 'allOrAny',
addressBookTest: 'addressBook',
addressTest: 'address',
attachmentTest: 'attachment',
bodyTest: 'body',
bulkTest: 'bulk',
contactRankingTest: 'contactRanking',
conversationTest: 'conversation',
dateTest: ['date', DateCondition],
facebookTest: 'facebook',
flaggedTest: 'flag',
headerExistsTest: 'headerExists',
headerTest: 'header',
importanceTest: ['importance', ImportanceCondition],
inviteTest: 'invite',
linkedinTest: 'linkedin',
listTest: 'list',
meTest: 'me',
mimeHeaderTest: 'mimeHeader',
sizeTest: ['size', SizeCondition],
twitterTest: 'twitter',
communityRequestsTest: 'communityRequests',
communityContentTest: 'communityContent',
communityConnectionsTest: 'communityConnections'
});
export const Filter = new Entity({
filterActions: ['actions', FilterAction],
filterTests: ['conditions', FilterCondition]
});
export const InviteReply = new Entity({
compNum: 'componentNum',
m: ['message', MessageInfo],
rt: 'replyType',
exceptId: ['exceptId', InstanceDate]
});
const Signature = new Entity({
cid: 'contentId'
});
export const CreateSignatureRequest = new Entity({
signature: Signature
});
const GetFolderSpec = new Entity({
l: 'parentFolderId'
});
export const GetFolderRequest = new Entity({
tr: 'traverseMountpoints',
folder: GetFolderSpec
});
const ContactInputAttributes = new Entity({
n: 'name',
_content: 'content'
});
export const ContactInputRequest = new Entity({
l: 'folderId',
tn: 'tagNames',
a: ['attributes', ContactInputAttributes],
m: 'memberOps'
});
const contentInfo = new Entity({
_content: 'content'
});
const AddMsgAttributes = new Entity({
content: ['content', contentInfo],
d: 'date',
f: 'flags',
l: 'folderId',
t: 'tags',
tn: 'tagNames'
});
export const AddMsgInfo = new Entity({
m: ['message', AddMsgAttributes]
});
const OnlyEmailAddress = new Entity({
addr: 'emailAddress'
});
const Target = new Entity({
d: 'displayName',
email: ['email', OnlyEmailAddress]
});
const Targets = new Entity({
target: ['target', Target]
});
export const DiscoverRightsResponse = new Entity({
targets: ['targets', Targets]
});
export const AccountACEInfo = new Entity({
...commonAccessControlEntities,
chkgt: 'checkGrantee'
});
export const AccountRights = new Entity({
ace: ['access', AccountACEInfo]
});
export const SaveDocuments = new Entity({
doc: ['document', SaveDocument]
});
export const GetRightsRequest = new Entity({
ace: 'access'
});
export const CreateAppSpecificPasswordResponse = new Entity({
pw: 'password'
});
export const Tag = new Entity({
u: 'unread'
});
export const Mailbox = new Entity({
s: 'used'
});