@marcoappio/marco-config 4.0.4 → 4.0.5
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/appwrite/appwrite.d.ts +365 -36
- package/dist/appwrite/appwrite.d.ts.map +1 -1
- package/dist/appwrite/appwrite.js +78 -32
- package/dist/appwrite/appwrite.test.js +300 -19
- package/package.json +1 -1
|
@@ -14,45 +14,47 @@ const validRows = {
|
|
|
14
14
|
...metadata,
|
|
15
15
|
$tableId: 'accounts',
|
|
16
16
|
colour: '#000000',
|
|
17
|
-
credential:
|
|
17
|
+
credential: null,
|
|
18
18
|
displayName: null,
|
|
19
19
|
initialSyncCompletedAt: null,
|
|
20
20
|
lastErrorCode: null,
|
|
21
21
|
lastSuccessfulSyncAt: null,
|
|
22
|
-
mailboxSyncState:
|
|
22
|
+
mailboxSyncState: null,
|
|
23
23
|
mailProcessedCount: 0,
|
|
24
24
|
mailTotalCount: 0,
|
|
25
|
-
|
|
25
|
+
pollShardAssignmentId: null,
|
|
26
26
|
pollShardId: null,
|
|
27
27
|
primaryAlias: 'alias-1',
|
|
28
|
-
primaryAliasId: 'alias-1',
|
|
29
28
|
primaryEmail: 'marco@example.com',
|
|
30
29
|
profile: 'user-1',
|
|
30
|
+
profileAssignmentKey: 'user-1',
|
|
31
31
|
provider: 'GMAIL',
|
|
32
32
|
state: 'CONNECTED',
|
|
33
|
-
userId: 'user-1',
|
|
34
33
|
},
|
|
35
34
|
aliases: {
|
|
36
35
|
...metadata,
|
|
37
36
|
$tableId: 'aliases',
|
|
38
|
-
|
|
37
|
+
account: 'account-1',
|
|
38
|
+
accountAssignmentKey: 'account-1',
|
|
39
39
|
email: 'marco@example.com',
|
|
40
40
|
isPrimary: true,
|
|
41
41
|
name: 'Marco',
|
|
42
42
|
providerId: 'provider-1',
|
|
43
43
|
signature: '<p>Test signature</p>',
|
|
44
|
-
userId: 'user-1',
|
|
45
44
|
},
|
|
46
45
|
commands: {
|
|
47
46
|
...metadata,
|
|
48
47
|
$tableId: 'commands_v2',
|
|
48
|
+
account: null,
|
|
49
49
|
accountId: null,
|
|
50
50
|
attempts: 0,
|
|
51
51
|
canonicalRevision: null,
|
|
52
|
+
draftId: null,
|
|
52
53
|
errorCode: null,
|
|
53
54
|
kind: 'thread.archive',
|
|
54
55
|
payload: '{"threadId":"thread-1"}',
|
|
55
56
|
payloadHash: 'hash-1',
|
|
57
|
+
profile: 'user-1',
|
|
56
58
|
state: 'ACCEPTED',
|
|
57
59
|
submittedAt: '2026-07-15T00:00:00.000Z',
|
|
58
60
|
userId: 'user-1',
|
|
@@ -64,8 +66,9 @@ const validRows = {
|
|
|
64
66
|
lastContactedAt: '2026-07-15T00:00:00.000Z',
|
|
65
67
|
messageCount: 0,
|
|
66
68
|
normalisedAddress: 'marco@example.com',
|
|
69
|
+
profile: 'user-1',
|
|
70
|
+
profileAssignmentKey: 'user-1',
|
|
67
71
|
searchText: 'marco',
|
|
68
|
-
userId: 'user-1',
|
|
69
72
|
},
|
|
70
73
|
credentials: {
|
|
71
74
|
...metadata,
|
|
@@ -74,25 +77,29 @@ const validRows = {
|
|
|
74
77
|
encryptedPayload: 'encrypted-payload',
|
|
75
78
|
expiresAt: null,
|
|
76
79
|
provider: 'GMAIL',
|
|
80
|
+
refreshLeaseExpiresAt: null,
|
|
81
|
+
refreshLeaseId: null,
|
|
77
82
|
userId: 'user-1',
|
|
78
83
|
},
|
|
79
84
|
drafts: {
|
|
80
85
|
...metadata,
|
|
81
86
|
$tableId: 'drafts',
|
|
82
|
-
|
|
87
|
+
account: 'account-1',
|
|
88
|
+
accountAssignmentKey: 'account-1',
|
|
83
89
|
attachmentMetadata: '[]',
|
|
84
90
|
contentHash: 'hash-1',
|
|
85
91
|
envelope: '{"bcc":[],"cc":[],"subject":null,"to":[]}',
|
|
86
92
|
errorCode: null,
|
|
87
|
-
|
|
93
|
+
executionLeaseExpiresAt: null,
|
|
94
|
+
executionLeaseId: null,
|
|
95
|
+
fromAlias: null,
|
|
88
96
|
html: '<p>Draft</p>',
|
|
89
|
-
|
|
97
|
+
referencedMessage: null,
|
|
90
98
|
revision: 0,
|
|
91
99
|
scheduledAt: null,
|
|
92
100
|
sequence: 0,
|
|
93
101
|
status: 'DRAFT',
|
|
94
102
|
type: 'COMPOSE',
|
|
95
|
-
userId: 'user-1',
|
|
96
103
|
},
|
|
97
104
|
jobs: {
|
|
98
105
|
...metadata,
|
|
@@ -114,21 +121,41 @@ const validRows = {
|
|
|
114
121
|
labels: {
|
|
115
122
|
...metadata,
|
|
116
123
|
$tableId: 'labels',
|
|
117
|
-
|
|
124
|
+
account: 'account-1',
|
|
125
|
+
accountAssignmentKey: 'account-1',
|
|
118
126
|
name: null,
|
|
119
127
|
path: 'Inbox',
|
|
120
128
|
providerId: 'provider-1',
|
|
121
129
|
specialUse: 'INBOX',
|
|
122
130
|
totalCount: 0,
|
|
123
131
|
unreadCount: 0,
|
|
132
|
+
},
|
|
133
|
+
mailboxSyncCandidates: {
|
|
134
|
+
...metadata,
|
|
135
|
+
$tableId: 'mailbox_sync_candidates_v2',
|
|
136
|
+
account: 'account-1',
|
|
137
|
+
accountId: 'account-1',
|
|
138
|
+
generation: 1,
|
|
139
|
+
label: 'label-1',
|
|
140
|
+
labelId: 'label-1',
|
|
141
|
+
lane: 'HEAD',
|
|
142
|
+
mailboxPath: 'INBOX',
|
|
143
|
+
mailboxPriority: 1,
|
|
144
|
+
mailboxSortKey: '0000000001:INBOX',
|
|
145
|
+
providerId: 'provider-message-1',
|
|
146
|
+
receivedAt: '2026-07-15T00:00:00.000Z',
|
|
147
|
+
specialUse: 'INBOX',
|
|
148
|
+
uid: 1,
|
|
149
|
+
uidValidity: 1,
|
|
124
150
|
userId: 'user-1',
|
|
125
151
|
},
|
|
126
152
|
mailboxSyncLanes: {
|
|
127
153
|
...metadata,
|
|
128
154
|
$permissions: [],
|
|
129
155
|
$tableId: 'mailbox_sync_lanes',
|
|
156
|
+
account: 'test-account-id-1',
|
|
130
157
|
accountId: 'test-account-id-1',
|
|
131
|
-
commandId: '
|
|
158
|
+
commandId: 'sync_test-command-id-1',
|
|
132
159
|
cursor: null,
|
|
133
160
|
errorCode: null,
|
|
134
161
|
generation: 1,
|
|
@@ -139,9 +166,12 @@ const validRows = {
|
|
|
139
166
|
mailboxSyncStates: {
|
|
140
167
|
...metadata,
|
|
141
168
|
$tableId: 'mailbox_sync_states',
|
|
169
|
+
accountId: 'account-1',
|
|
142
170
|
errorCode: null,
|
|
143
171
|
lastEventAt: null,
|
|
144
172
|
lastSyncAt: null,
|
|
173
|
+
materialisationLeaseExpiresAt: null,
|
|
174
|
+
materialisationLeaseId: null,
|
|
145
175
|
nextPollAt: null,
|
|
146
176
|
provider: 'GMAIL',
|
|
147
177
|
providerCursor: null,
|
|
@@ -149,6 +179,22 @@ const validRows = {
|
|
|
149
179
|
uidValidity: null,
|
|
150
180
|
userId: 'user-1',
|
|
151
181
|
},
|
|
182
|
+
messageLocations: {
|
|
183
|
+
...metadata,
|
|
184
|
+
$tableId: 'message_locations',
|
|
185
|
+
account: 'account-1',
|
|
186
|
+
accountAssignmentKey: 'account-1',
|
|
187
|
+
flagged: false,
|
|
188
|
+
label: 'label-1',
|
|
189
|
+
labelAssignmentKey: 'label-1',
|
|
190
|
+
message: 'message-1',
|
|
191
|
+
messageAt: '2026-07-15T00:00:00.000Z',
|
|
192
|
+
seen: true,
|
|
193
|
+
thread: 'thread-1',
|
|
194
|
+
threadAssignmentKey: 'thread-1',
|
|
195
|
+
uid: 1,
|
|
196
|
+
uidValidity: 1,
|
|
197
|
+
},
|
|
152
198
|
messages: {
|
|
153
199
|
...metadata,
|
|
154
200
|
$tableId: 'messages',
|
|
@@ -199,6 +245,15 @@ const validRows = {
|
|
|
199
245
|
scheduledExecutionId: null,
|
|
200
246
|
state: 'ACTIVE',
|
|
201
247
|
},
|
|
248
|
+
profileAvatarCleanups: {
|
|
249
|
+
...metadata,
|
|
250
|
+
$permissions: [],
|
|
251
|
+
$tableId: 'profile_avatar_cleanups',
|
|
252
|
+
claimedAt: null,
|
|
253
|
+
claimId: null,
|
|
254
|
+
fileId: 'test-file-id-1',
|
|
255
|
+
profile: 'user-1',
|
|
256
|
+
},
|
|
202
257
|
profiles: {
|
|
203
258
|
...metadata,
|
|
204
259
|
$tableId: 'profiles',
|
|
@@ -212,6 +267,7 @@ const validRows = {
|
|
|
212
267
|
pushNotificationTokens: {
|
|
213
268
|
...metadata,
|
|
214
269
|
$tableId: 'push_notification_tokens',
|
|
270
|
+
profile: 'user-1',
|
|
215
271
|
token: 'ExponentPushToken[token]',
|
|
216
272
|
userId: 'user-1',
|
|
217
273
|
},
|
|
@@ -221,6 +277,7 @@ const validRows = {
|
|
|
221
277
|
aliasIds: ['alias-1'],
|
|
222
278
|
icon: 'mail',
|
|
223
279
|
name: 'Unread',
|
|
280
|
+
profile: 'user-1',
|
|
224
281
|
},
|
|
225
282
|
threadAliases: {
|
|
226
283
|
...metadata,
|
|
@@ -308,12 +365,15 @@ describe('appwrite', () => {
|
|
|
308
365
|
drafts: 'drafts',
|
|
309
366
|
jobs: 'jobs_v2',
|
|
310
367
|
labels: 'labels',
|
|
368
|
+
mailboxSyncCandidates: 'mailbox_sync_candidates_v2',
|
|
311
369
|
mailboxSyncLanes: 'mailbox_sync_lanes',
|
|
312
370
|
mailboxSyncStates: 'mailbox_sync_states',
|
|
371
|
+
messageLocations: 'message_locations',
|
|
313
372
|
messages: 'messages',
|
|
314
373
|
oauthStates: 'oauth_states',
|
|
315
374
|
pollShardCoordinators: 'poll_shard_coordinators',
|
|
316
375
|
pollShards: 'poll_shards',
|
|
376
|
+
profileAvatarCleanups: 'profile_avatar_cleanups',
|
|
317
377
|
profiles: 'profiles',
|
|
318
378
|
pushNotificationTokens: 'push_notification_tokens',
|
|
319
379
|
savedViews: 'saved_views',
|
|
@@ -361,10 +421,10 @@ describe('appwrite', () => {
|
|
|
361
421
|
expect(v.safeParse(appwrite.rowSchemas.savedViews, validRows.savedViews).success).toBe(true);
|
|
362
422
|
expect(v.safeParse(appwrite.rowSchemas.savedViews, { ...validRows.savedViews, aliasEmails: ['marco@example.com'] }).success).toBe(false);
|
|
363
423
|
});
|
|
364
|
-
it('rejects a mailbox sync lane without a command
|
|
424
|
+
it('rejects a mailbox sync lane without a command identifier', () => {
|
|
365
425
|
expect(v.safeParse(appwrite.rowSchemas.mailboxSyncLanes, {
|
|
366
426
|
...validRows.mailboxSyncLanes,
|
|
367
|
-
commandId: '
|
|
427
|
+
commandId: '',
|
|
368
428
|
}).success).toBe(false);
|
|
369
429
|
});
|
|
370
430
|
it('rejects a poll shard with more than ten accounts', () => {
|
|
@@ -401,7 +461,159 @@ describe('appwrite', () => {
|
|
|
401
461
|
});
|
|
402
462
|
}
|
|
403
463
|
const rowTestCases = Object.keys(validRows);
|
|
464
|
+
const metadataKeys = ['$createdAt', '$databaseId', '$id', '$permissions', '$sequence', '$tableId', '$updatedAt'];
|
|
465
|
+
const expectedRowDataKeys = {
|
|
466
|
+
accounts: [
|
|
467
|
+
'colour',
|
|
468
|
+
'credential',
|
|
469
|
+
'displayName',
|
|
470
|
+
'initialSyncCompletedAt',
|
|
471
|
+
'lastErrorCode',
|
|
472
|
+
'lastSuccessfulSyncAt',
|
|
473
|
+
'mailboxSyncState',
|
|
474
|
+
'mailProcessedCount',
|
|
475
|
+
'mailTotalCount',
|
|
476
|
+
'pollShardAssignmentId',
|
|
477
|
+
'pollShardId',
|
|
478
|
+
'primaryAlias',
|
|
479
|
+
'primaryEmail',
|
|
480
|
+
'profile',
|
|
481
|
+
'profileAssignmentKey',
|
|
482
|
+
'provider',
|
|
483
|
+
'state',
|
|
484
|
+
],
|
|
485
|
+
aliases: ['account', 'accountAssignmentKey', 'email', 'isPrimary', 'name', 'providerId', 'signature'],
|
|
486
|
+
commands: ['account', 'accountId', 'attempts', 'canonicalRevision', 'draftId', 'errorCode', 'kind', 'payload', 'payloadHash', 'profile', 'state', 'submittedAt', 'userId'],
|
|
487
|
+
contacts: ['displayName', 'lastContactedAt', 'messageCount', 'normalisedAddress', 'profile', 'profileAssignmentKey', 'searchText'],
|
|
488
|
+
credentials: ['accountId', 'encryptedPayload', 'expiresAt', 'provider', 'refreshLeaseExpiresAt', 'refreshLeaseId', 'userId'],
|
|
489
|
+
drafts: [
|
|
490
|
+
'account',
|
|
491
|
+
'accountAssignmentKey',
|
|
492
|
+
'attachmentMetadata',
|
|
493
|
+
'contentHash',
|
|
494
|
+
'envelope',
|
|
495
|
+
'errorCode',
|
|
496
|
+
'executionLeaseExpiresAt',
|
|
497
|
+
'executionLeaseId',
|
|
498
|
+
'fromAlias',
|
|
499
|
+
'html',
|
|
500
|
+
'referencedMessage',
|
|
501
|
+
'revision',
|
|
502
|
+
'scheduledAt',
|
|
503
|
+
'sequence',
|
|
504
|
+
'status',
|
|
505
|
+
'type',
|
|
506
|
+
],
|
|
507
|
+
jobs: ['accountId', 'attempts', 'commandId', 'dedupeKey', 'errorCode', 'kind', 'leaseExpiresAt', 'leaseId', 'maxAttempts', 'nextRunAt', 'payload', 'state', 'userId'],
|
|
508
|
+
labels: ['account', 'accountAssignmentKey', 'name', 'path', 'providerId', 'specialUse', 'totalCount', 'unreadCount'],
|
|
509
|
+
mailboxSyncCandidates: [
|
|
510
|
+
'account',
|
|
511
|
+
'accountId',
|
|
512
|
+
'generation',
|
|
513
|
+
'label',
|
|
514
|
+
'labelId',
|
|
515
|
+
'lane',
|
|
516
|
+
'mailboxPath',
|
|
517
|
+
'mailboxPriority',
|
|
518
|
+
'mailboxSortKey',
|
|
519
|
+
'providerId',
|
|
520
|
+
'receivedAt',
|
|
521
|
+
'specialUse',
|
|
522
|
+
'uid',
|
|
523
|
+
'uidValidity',
|
|
524
|
+
'userId',
|
|
525
|
+
],
|
|
526
|
+
mailboxSyncLanes: ['account', 'accountId', 'commandId', 'cursor', 'errorCode', 'generation', 'lane', 'state', 'userId'],
|
|
527
|
+
mailboxSyncStates: [
|
|
528
|
+
'accountId',
|
|
529
|
+
'errorCode',
|
|
530
|
+
'lastEventAt',
|
|
531
|
+
'lastSyncAt',
|
|
532
|
+
'materialisationLeaseExpiresAt',
|
|
533
|
+
'materialisationLeaseId',
|
|
534
|
+
'nextPollAt',
|
|
535
|
+
'provider',
|
|
536
|
+
'providerCursor',
|
|
537
|
+
'state',
|
|
538
|
+
'uidValidity',
|
|
539
|
+
'userId',
|
|
540
|
+
],
|
|
541
|
+
messageLocations: [
|
|
542
|
+
'account',
|
|
543
|
+
'accountAssignmentKey',
|
|
544
|
+
'flagged',
|
|
545
|
+
'label',
|
|
546
|
+
'labelAssignmentKey',
|
|
547
|
+
'message',
|
|
548
|
+
'messageAt',
|
|
549
|
+
'seen',
|
|
550
|
+
'thread',
|
|
551
|
+
'threadAssignmentKey',
|
|
552
|
+
'uid',
|
|
553
|
+
'uidValidity',
|
|
554
|
+
],
|
|
555
|
+
messages: [
|
|
556
|
+
'account',
|
|
557
|
+
'accountAssignmentKey',
|
|
558
|
+
'attachmentMetadata',
|
|
559
|
+
'htmlFileId',
|
|
560
|
+
'preview',
|
|
561
|
+
'providerId',
|
|
562
|
+
'rawFileId',
|
|
563
|
+
'receivedAt',
|
|
564
|
+
'recipients',
|
|
565
|
+
'revision',
|
|
566
|
+
'rfcMessageId',
|
|
567
|
+
'sender',
|
|
568
|
+
'senderName',
|
|
569
|
+
'sentAt',
|
|
570
|
+
'size',
|
|
571
|
+
'subject',
|
|
572
|
+
'thread',
|
|
573
|
+
'threadAssignmentKey',
|
|
574
|
+
],
|
|
575
|
+
oauthStates: ['accountId', 'email', 'expiresAt', 'nonceHash', 'operation', 'profile', 'provider', 'returnUri', 'userId'],
|
|
576
|
+
pollShards: ['accountIds', 'errorCode', 'generation', 'lastStartedAt', 'leaseExpiresAt', 'leaseId', 'nextStartAt', 'pollingSnapshot', 'scheduledExecutionId', 'state'],
|
|
577
|
+
profileAvatarCleanups: ['claimedAt', 'claimId', 'fileId', 'profile'],
|
|
578
|
+
profiles: ['avatarFileId', 'deletionRequestedAt', 'email', 'name', 'onboardingState', 'timezone'],
|
|
579
|
+
pushNotificationTokens: ['profile', 'token', 'userId'],
|
|
580
|
+
savedViews: ['aliasIds', 'icon', 'name', 'profile'],
|
|
581
|
+
threadAliases: ['alias', 'aliasAssignmentKey', 'latestMessageAt', 'thread', 'threadAssignmentKey'],
|
|
582
|
+
threadLabels: ['label', 'labelAssignmentKey', 'latestMessageAt', 'locationCount', 'thread', 'threadAssignmentKey'],
|
|
583
|
+
threads: [
|
|
584
|
+
'account',
|
|
585
|
+
'accountAssignmentKey',
|
|
586
|
+
'archived',
|
|
587
|
+
'firstMessageAt',
|
|
588
|
+
'flagged',
|
|
589
|
+
'flaggedLocationCount',
|
|
590
|
+
'hasAttachments',
|
|
591
|
+
'labelIds',
|
|
592
|
+
'latestMessageAt',
|
|
593
|
+
'latestMessageId',
|
|
594
|
+
'messageCount',
|
|
595
|
+
'participants',
|
|
596
|
+
'preview',
|
|
597
|
+
'providerId',
|
|
598
|
+
'revision',
|
|
599
|
+
'searchText',
|
|
600
|
+
'seen',
|
|
601
|
+
'senderEmail',
|
|
602
|
+
'senderName',
|
|
603
|
+
'snoozedUntil',
|
|
604
|
+
'spam',
|
|
605
|
+
'subject',
|
|
606
|
+
'trashed',
|
|
607
|
+
'unseenLocationCount',
|
|
608
|
+
],
|
|
609
|
+
};
|
|
404
610
|
for (const table of rowTestCases) {
|
|
611
|
+
it(`exposes backend-aligned ${table} row keys`, () => {
|
|
612
|
+
const dataKeys = Object.keys(appwrite.rowSchemas[table].entries)
|
|
613
|
+
.filter(key => !metadataKeys.includes(key))
|
|
614
|
+
.sort();
|
|
615
|
+
expect(dataKeys).toEqual([...expectedRowDataKeys[table]].sort());
|
|
616
|
+
});
|
|
405
617
|
it(`accepts the ${table} wire row`, () => {
|
|
406
618
|
expect(v.safeParse(appwrite.rowSchemas[table], validRows[table]).success).toBe(true);
|
|
407
619
|
});
|
|
@@ -410,7 +622,41 @@ describe('appwrite', () => {
|
|
|
410
622
|
expect(v.safeParse(appwrite.rowSchemas[table], rowWithoutId).success).toBe(false);
|
|
411
623
|
});
|
|
412
624
|
}
|
|
413
|
-
it('normalises Appwrite
|
|
625
|
+
it('normalises Appwrite relationship objects to row IDs', () => {
|
|
626
|
+
const account = v.parse(appwrite.rowSchemas.accounts, {
|
|
627
|
+
...validRows.accounts,
|
|
628
|
+
credential: { $id: 'credential-1' },
|
|
629
|
+
mailboxSyncState: { $id: 'mailbox-sync-state-1' },
|
|
630
|
+
primaryAlias: { $id: 'alias-1' },
|
|
631
|
+
profile: { $id: 'user-1' },
|
|
632
|
+
});
|
|
633
|
+
const alias = v.parse(appwrite.rowSchemas.aliases, { ...validRows.aliases, account: { $id: 'account-1' } });
|
|
634
|
+
const command = v.parse(appwrite.rowSchemas.commands, { ...validRows.commands, account: { $id: 'account-1' }, profile: { $id: 'user-1' } });
|
|
635
|
+
const contact = v.parse(appwrite.rowSchemas.contacts, { ...validRows.contacts, profile: { $id: 'user-1' } });
|
|
636
|
+
const draft = v.parse(appwrite.rowSchemas.drafts, {
|
|
637
|
+
...validRows.drafts,
|
|
638
|
+
account: { $id: 'account-1' },
|
|
639
|
+
fromAlias: { $id: 'alias-1' },
|
|
640
|
+
referencedMessage: { $id: 'message-1' },
|
|
641
|
+
});
|
|
642
|
+
const label = v.parse(appwrite.rowSchemas.labels, { ...validRows.labels, account: { $id: 'account-1' } });
|
|
643
|
+
const mailboxSyncCandidate = v.parse(appwrite.rowSchemas.mailboxSyncCandidates, {
|
|
644
|
+
...validRows.mailboxSyncCandidates,
|
|
645
|
+
account: { $id: 'account-1' },
|
|
646
|
+
label: { $id: 'label-1' },
|
|
647
|
+
});
|
|
648
|
+
const mailboxSyncLane = v.parse(appwrite.rowSchemas.mailboxSyncLanes, { ...validRows.mailboxSyncLanes, account: { $id: 'account-1' } });
|
|
649
|
+
const messageLocation = v.parse(appwrite.rowSchemas.messageLocations, {
|
|
650
|
+
...validRows.messageLocations,
|
|
651
|
+
account: { $id: 'account-1' },
|
|
652
|
+
label: { $id: 'label-1' },
|
|
653
|
+
message: { $id: 'message-1' },
|
|
654
|
+
thread: { $id: 'thread-1' },
|
|
655
|
+
});
|
|
656
|
+
const oauthState = v.parse(appwrite.rowSchemas.oauthStates, { ...validRows.oauthStates, profile: { $id: 'user-1' } });
|
|
657
|
+
const profileAvatarCleanup = v.parse(appwrite.rowSchemas.profileAvatarCleanups, { ...validRows.profileAvatarCleanups, profile: { $id: 'user-1' } });
|
|
658
|
+
const pushNotificationToken = v.parse(appwrite.rowSchemas.pushNotificationTokens, { ...validRows.pushNotificationTokens, profile: { $id: 'user-1' } });
|
|
659
|
+
const savedView = v.parse(appwrite.rowSchemas.savedViews, { ...validRows.savedViews, profile: { $id: 'user-1' } });
|
|
414
660
|
const thread = v.parse(appwrite.rowSchemas.threads, { ...validRows.threads, account: { $id: 'account-1' } });
|
|
415
661
|
const message = v.parse(appwrite.rowSchemas.messages, {
|
|
416
662
|
...validRows.messages,
|
|
@@ -427,6 +673,29 @@ describe('appwrite', () => {
|
|
|
427
673
|
label: { $id: 'label-1' },
|
|
428
674
|
thread: { $id: 'thread-1' },
|
|
429
675
|
});
|
|
676
|
+
expect(account.credential).toBe('credential-1');
|
|
677
|
+
expect(account.mailboxSyncState).toBe('mailbox-sync-state-1');
|
|
678
|
+
expect(account.primaryAlias).toBe('alias-1');
|
|
679
|
+
expect(account.profile).toBe('user-1');
|
|
680
|
+
expect(alias.account).toBe('account-1');
|
|
681
|
+
expect(command.account).toBe('account-1');
|
|
682
|
+
expect(command.profile).toBe('user-1');
|
|
683
|
+
expect(contact.profile).toBe('user-1');
|
|
684
|
+
expect(draft.account).toBe('account-1');
|
|
685
|
+
expect(draft.fromAlias).toBe('alias-1');
|
|
686
|
+
expect(draft.referencedMessage).toBe('message-1');
|
|
687
|
+
expect(label.account).toBe('account-1');
|
|
688
|
+
expect(mailboxSyncCandidate.account).toBe('account-1');
|
|
689
|
+
expect(mailboxSyncCandidate.label).toBe('label-1');
|
|
690
|
+
expect(mailboxSyncLane.account).toBe('account-1');
|
|
691
|
+
expect(messageLocation.account).toBe('account-1');
|
|
692
|
+
expect(messageLocation.label).toBe('label-1');
|
|
693
|
+
expect(messageLocation.message).toBe('message-1');
|
|
694
|
+
expect(messageLocation.thread).toBe('thread-1');
|
|
695
|
+
expect(oauthState.profile).toBe('user-1');
|
|
696
|
+
expect(profileAvatarCleanup.profile).toBe('user-1');
|
|
697
|
+
expect(pushNotificationToken.profile).toBe('user-1');
|
|
698
|
+
expect(savedView.profile).toBe('user-1');
|
|
430
699
|
expect(thread.account).toBe('account-1');
|
|
431
700
|
expect(message.account).toBe('account-1');
|
|
432
701
|
expect(message.thread).toBe('thread-1');
|
|
@@ -456,7 +725,19 @@ describe('appwrite', () => {
|
|
|
456
725
|
expect(v.safeParse(schema, row).success).toBe(false);
|
|
457
726
|
});
|
|
458
727
|
}
|
|
459
|
-
const
|
|
728
|
+
const obsoleteRelationshipFieldTestCases = [
|
|
729
|
+
{ field: 'pollShard', row: { ...validRows.accounts, pollShard: null }, schema: appwrite.rowSchemas.accounts, table: 'accounts' },
|
|
730
|
+
{ field: 'primaryAliasId', row: { ...validRows.accounts, primaryAliasId: 'alias-1' }, schema: appwrite.rowSchemas.accounts, table: 'accounts' },
|
|
731
|
+
{ field: 'userId', row: { ...validRows.accounts, userId: 'user-1' }, schema: appwrite.rowSchemas.accounts, table: 'accounts' },
|
|
732
|
+
{ field: 'accountId', row: { ...validRows.aliases, accountId: 'account-1' }, schema: appwrite.rowSchemas.aliases, table: 'aliases' },
|
|
733
|
+
{ field: 'userId', row: { ...validRows.aliases, userId: 'user-1' }, schema: appwrite.rowSchemas.aliases, table: 'aliases' },
|
|
734
|
+
{ field: 'userId', row: { ...validRows.contacts, userId: 'user-1' }, schema: appwrite.rowSchemas.contacts, table: 'contacts' },
|
|
735
|
+
{ field: 'accountId', row: { ...validRows.drafts, accountId: 'account-1' }, schema: appwrite.rowSchemas.drafts, table: 'drafts' },
|
|
736
|
+
{ field: 'fromAliasId', row: { ...validRows.drafts, fromAliasId: 'alias-1' }, schema: appwrite.rowSchemas.drafts, table: 'drafts' },
|
|
737
|
+
{ field: 'referencedMessageId', row: { ...validRows.drafts, referencedMessageId: 'message-1' }, schema: appwrite.rowSchemas.drafts, table: 'drafts' },
|
|
738
|
+
{ field: 'userId', row: { ...validRows.drafts, userId: 'user-1' }, schema: appwrite.rowSchemas.drafts, table: 'drafts' },
|
|
739
|
+
{ field: 'accountId', row: { ...validRows.labels, accountId: 'account-1' }, schema: appwrite.rowSchemas.labels, table: 'labels' },
|
|
740
|
+
{ field: 'userId', row: { ...validRows.labels, userId: 'user-1' }, schema: appwrite.rowSchemas.labels, table: 'labels' },
|
|
460
741
|
{ field: 'accountId', row: { ...validRows.messages, accountId: 'account-1' }, schema: appwrite.rowSchemas.messages, table: 'messages' },
|
|
461
742
|
{ field: 'threadId', row: { ...validRows.messages, threadId: 'thread-1' }, schema: appwrite.rowSchemas.messages, table: 'messages' },
|
|
462
743
|
{ field: 'userId', row: { ...validRows.messages, userId: 'user-1' }, schema: appwrite.rowSchemas.messages, table: 'messages' },
|
|
@@ -471,7 +752,7 @@ describe('appwrite', () => {
|
|
|
471
752
|
{ field: 'threadId', row: { ...validRows.threadLabels, threadId: 'thread-1' }, schema: appwrite.rowSchemas.threadLabels, table: 'threadLabels' },
|
|
472
753
|
{ field: 'userId', row: { ...validRows.threadLabels, userId: 'user-1' }, schema: appwrite.rowSchemas.threadLabels, table: 'threadLabels' },
|
|
473
754
|
];
|
|
474
|
-
for (const { field, row, schema, table } of
|
|
755
|
+
for (const { field, row, schema, table } of obsoleteRelationshipFieldTestCases) {
|
|
475
756
|
it(`rejects obsolete ${field} on ${table}`, () => {
|
|
476
757
|
expect(v.safeParse(schema, row).success).toBe(false);
|
|
477
758
|
});
|