@marcoappio/marco-config 4.0.9 → 4.0.11

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 (34) hide show
  1. package/dist/appwrite/appwrite.d.ts +1215 -1017
  2. package/dist/appwrite/appwrite.d.ts.map +1 -1
  3. package/dist/appwrite/appwrite.js +11 -375
  4. package/dist/appwrite/appwrite.test.js +75 -1
  5. package/dist/appwrite/commands.d.ts +167 -124
  6. package/dist/appwrite/commands.d.ts.map +1 -1
  7. package/dist/appwrite/commands.js +70 -68
  8. package/dist/appwrite/commands.test.js +30 -17
  9. package/dist/appwrite/functions.d.ts +122 -122
  10. package/dist/appwrite/index.d.ts +2 -2
  11. package/dist/appwrite/index.d.ts.map +1 -1
  12. package/dist/appwrite/index.js +2 -2
  13. package/dist/appwrite/tableContract/identity.d.ts +442 -0
  14. package/dist/appwrite/tableContract/identity.d.ts.map +1 -0
  15. package/dist/appwrite/tableContract/identity.js +158 -0
  16. package/dist/appwrite/tableContract/index.d.ts +2194 -0
  17. package/dist/appwrite/tableContract/index.d.ts.map +1 -0
  18. package/dist/appwrite/tableContract/index.js +77 -0
  19. package/dist/appwrite/tableContract/index.test.d.ts +2 -0
  20. package/dist/appwrite/tableContract/index.test.d.ts.map +1 -0
  21. package/dist/appwrite/tableContract/index.test.js +48 -0
  22. package/dist/appwrite/tableContract/mailbox.d.ts +622 -0
  23. package/dist/appwrite/tableContract/mailbox.d.ts.map +1 -0
  24. package/dist/appwrite/tableContract/mailbox.js +191 -0
  25. package/dist/appwrite/tableContract/operational.d.ts +522 -0
  26. package/dist/appwrite/tableContract/operational.d.ts.map +1 -0
  27. package/dist/appwrite/tableContract/operational.js +191 -0
  28. package/dist/appwrite/tableContract/shared.d.ts +145 -0
  29. package/dist/appwrite/tableContract/shared.d.ts.map +1 -0
  30. package/dist/appwrite/tableContract/shared.js +89 -0
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33.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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDT,CAAA"}
@@ -1,19 +1,11 @@
1
1
  import * as v from 'valibot';
2
2
  import { string } from '../schemas/string';
3
3
  import { MESSAGE_RECIPIENT_TYPES } from '../types';
4
- const identifierSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(255));
5
- export const appwriteRowIdSchema = v.pipe(v.string(), v.minLength(1), v.maxLength(36), v.regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/));
6
- const timestampSchema = v.pipe(v.string(), v.isoTimestamp());
7
- const nonNegativeIntegerSchema = v.pipe(v.number(), v.integer(), v.minValue(0));
8
- const colourSchema = v.pipe(v.string(), v.maxLength(64));
9
- const emailSchema = v.pipe(v.string(), v.email());
10
- const mailboxAddressSchema = string.mailboxAddress();
11
- const mailboxSortKeySchema = v.pipe(v.string(), v.minLength(1), v.maxLength(257));
4
+ import { appwriteDataSchemas, appwriteIds, appwriteRowSchemas as generatedRowSchemas, appwriteRowIdSchema, appwriteTables, mailboxSyncLaneStates, mailboxSyncLanes, mailboxSyncStates, oauthOperations, oauthProviders, oauthReturnUris, oauthReturnUriSchema, pollShardStates, nonNegativeIntegerSchema, identifierSchema, } from './tableContract';
5
+ export { appwriteRowIdSchema, appwriteTableIdSchema, appwriteTableIds } from './tableContract';
6
+ export { appwriteDataSchemas, appwriteRowSchemas, appwriteTableContract, appwriteTables, defineAppwriteTables, } from './tableContract';
7
+ export { accountProviders, accountStates, appwriteRelationshipIdSchema, commandStates, draftStates, draftTypes, jobStates, labelSpecialUses, mailboxSyncLaneStates, mailboxSyncLanes, mailboxSyncProvisionedStates, mailboxSyncStates, oauthOperations, oauthProviders, oauthReturnUris, oauthReturnUriSchema, pollShardStates, } from './tableContract';
12
8
  const jsonObjectTextSchema = v.pipe(v.string(), v.parseJson(), v.check(value => !Array.isArray(value)), v.looseObject({}));
13
- const appwriteRelationshipIdSchema = v.union([
14
- identifierSchema,
15
- v.pipe(v.object({ $id: identifierSchema }), v.transform(relationship => relationship.$id)),
16
- ]);
17
9
  const draftAttachmentSchema = v.strictObject({
18
10
  fileId: appwriteRowIdSchema,
19
11
  fileName: v.pipe(v.string(), v.minLength(1), v.maxLength(255)),
@@ -22,10 +14,10 @@ const draftAttachmentSchema = v.strictObject({
22
14
  });
23
15
  const draftAttachmentsSchema = v.pipe(v.string(), v.parseJson(), v.array(draftAttachmentSchema));
24
16
  const draftEnvelopeSchema = v.pipe(v.string(), v.parseJson(), v.strictObject({
25
- bcc: v.array(mailboxAddressSchema),
26
- cc: v.array(mailboxAddressSchema),
17
+ bcc: v.array(string.mailboxAddress()),
18
+ cc: v.array(string.mailboxAddress()),
27
19
  subject: v.nullable(v.string()),
28
- to: v.array(mailboxAddressSchema),
20
+ to: v.array(string.mailboxAddress()),
29
21
  }));
30
22
  const messageAttachmentSchema = v.looseObject({
31
23
  fileId: v.optional(v.nullable(appwriteRowIdSchema)),
@@ -37,26 +29,11 @@ const messageAttachmentSchema = v.looseObject({
37
29
  });
38
30
  const messageAttachmentsSchema = v.pipe(v.string(), v.parseJson(), v.array(messageAttachmentSchema));
39
31
  const messageRecipientSchema = v.strictObject({
40
- emailAddress: mailboxAddressSchema,
32
+ emailAddress: string.mailboxAddress(),
41
33
  name: v.nullable(identifierSchema),
42
34
  type: v.picklist(MESSAGE_RECIPIENT_TYPES),
43
35
  });
44
36
  const messageRecipientsSchema = v.pipe(v.string(), v.parseJson(), v.array(messageRecipientSchema));
45
- const accountProviders = ['GMAIL', 'OUTLOOK', 'IMAP'];
46
- const accountStates = ['AWAITING_CONNECTION', 'CONNECTED', 'ERROR', 'DISCONNECTED'];
47
- const commandStates = ['ACCEPTED', 'RUNNING', 'SUCCEEDED', 'FAILED'];
48
- const draftStates = ['DRAFT', 'SCHEDULED', 'SENDING', 'SENT', 'FAILED', 'CANCELLED'];
49
- const draftTypes = ['COMPOSE', 'REPLY', 'FORWARD'];
50
- const jobStates = ['PENDING', 'RUNNING', 'SUCCEEDED', 'FAILED', 'CANCELLED'];
51
- const labelSpecialUses = ['ALL', 'ARCHIVE', 'DRAFTS', 'INBOX', 'JUNK', 'SENT', 'STARRED', 'TRASH'];
52
- const mailboxSyncLanes = ['HEAD', 'BACKFILL'];
53
- const mailboxSyncLaneStates = ['PENDING', 'RUNNING', 'COMPLETED', 'FAILED'];
54
- const mailboxSyncStates = ['INITIAL', 'SYNCING', 'CURRENT', 'ERROR'];
55
- const oauthOperations = ['CONNECT', 'REPLACE'];
56
- const oauthProviders = ['GMAIL', 'OUTLOOK'];
57
- const oauthReturnUris = ['https://app.marcoapp.io/onboarding/loading'];
58
- const oauthReturnUriSchema = v.picklist(oauthReturnUris);
59
- const pollShardStates = ['ACTIVE', 'STOPPED', 'FAILED'];
60
37
  const appwriteEnvironments = ['development', 'production', 'staging'];
61
38
  const appwriteDeployments = {
62
39
  development: {
@@ -87,350 +64,8 @@ const appwriteDeployments = {
87
64
  projectId: 'marco',
88
65
  },
89
66
  };
90
- const appwriteIds = {
91
- bucket: 'marco-files',
92
- database: 'marco',
93
- functions: {
94
- api: 'marco-api',
95
- worker: 'marco-worker',
96
- },
97
- tables: {
98
- accounts: 'accounts',
99
- aliases: 'aliases',
100
- commands: 'commands_v2',
101
- contacts: 'contacts',
102
- credentials: 'credentials',
103
- drafts: 'drafts',
104
- jobs: 'jobs_v2',
105
- labels: 'labels',
106
- mailboxSyncCandidates: 'mailbox_sync_candidates_v2',
107
- mailboxSyncLanes: 'mailbox_sync_lanes',
108
- mailboxSyncStates: 'mailbox_sync_states',
109
- messageLocations: 'message_locations',
110
- messages: 'messages',
111
- oauthStates: 'oauth_states',
112
- pollShardCoordinators: 'poll_shard_coordinators',
113
- pollShards: 'poll_shards',
114
- profileAvatarCleanups: 'profile_avatar_cleanups',
115
- profiles: 'profiles',
116
- pushNotificationTokens: 'push_notification_tokens',
117
- savedViews: 'saved_views',
118
- threadAliases: 'thread_aliases',
119
- threadLabels: 'thread_labels',
120
- threads: 'threads',
121
- },
122
- };
123
- const wireMetadata = (tableId) => ({
124
- $createdAt: timestampSchema,
125
- $databaseId: v.literal(appwriteIds.database),
126
- $id: appwriteRowIdSchema,
127
- $permissions: v.array(v.string()),
128
- $sequence: identifierSchema,
129
- $tableId: v.literal(tableId),
130
- $updatedAt: timestampSchema,
131
- });
132
- const rowSchemas = {
133
- accounts: v.strictObject({
134
- ...wireMetadata(appwriteIds.tables.accounts),
135
- colour: colourSchema,
136
- credential: v.nullable(appwriteRelationshipIdSchema),
137
- displayName: v.nullable(identifierSchema),
138
- initialSyncCompletedAt: v.nullable(timestampSchema),
139
- lastErrorCode: v.nullable(identifierSchema),
140
- lastSuccessfulSyncAt: v.nullable(timestampSchema),
141
- mailboxSyncState: v.nullable(appwriteRelationshipIdSchema),
142
- mailProcessedCount: nonNegativeIntegerSchema,
143
- mailTotalCount: nonNegativeIntegerSchema,
144
- pollShardAssignmentId: v.nullable(identifierSchema),
145
- pollShardId: v.nullable(identifierSchema),
146
- primaryAlias: v.nullable(appwriteRelationshipIdSchema),
147
- primaryEmail: emailSchema,
148
- profile: appwriteRelationshipIdSchema,
149
- profileAssignmentKey: identifierSchema,
150
- provider: v.picklist(accountProviders),
151
- state: v.picklist(accountStates),
152
- }),
153
- aliases: v.strictObject({
154
- ...wireMetadata(appwriteIds.tables.aliases),
155
- account: appwriteRelationshipIdSchema,
156
- accountAssignmentKey: identifierSchema,
157
- email: emailSchema,
158
- isPrimary: v.boolean(),
159
- name: v.nullable(identifierSchema),
160
- providerId: identifierSchema,
161
- signature: v.nullable(v.string()),
162
- }),
163
- commands: v.strictObject({
164
- ...wireMetadata(appwriteIds.tables.commands),
165
- account: v.nullable(appwriteRelationshipIdSchema),
166
- accountId: v.nullable(identifierSchema),
167
- attempts: nonNegativeIntegerSchema,
168
- canonicalRevision: v.nullable(nonNegativeIntegerSchema),
169
- draftId: v.nullable(identifierSchema),
170
- errorCode: v.nullable(identifierSchema),
171
- kind: identifierSchema,
172
- payload: v.string(),
173
- payloadHash: identifierSchema,
174
- profile: appwriteRelationshipIdSchema,
175
- state: v.picklist(commandStates),
176
- submittedAt: timestampSchema,
177
- userId: identifierSchema,
178
- }),
179
- contacts: v.strictObject({
180
- ...wireMetadata(appwriteIds.tables.contacts),
181
- displayName: v.nullable(identifierSchema),
182
- lastContactedAt: v.nullable(timestampSchema),
183
- messageCount: nonNegativeIntegerSchema,
184
- normalisedAddress: mailboxAddressSchema,
185
- profile: appwriteRelationshipIdSchema,
186
- profileAssignmentKey: identifierSchema,
187
- searchText: v.string(),
188
- }),
189
- credentials: v.strictObject({
190
- ...wireMetadata(appwriteIds.tables.credentials),
191
- accountId: identifierSchema,
192
- encryptedPayload: v.string(),
193
- expiresAt: v.nullable(timestampSchema),
194
- provider: v.picklist(accountProviders),
195
- refreshLeaseExpiresAt: v.nullable(timestampSchema),
196
- refreshLeaseId: v.nullable(identifierSchema),
197
- userId: identifierSchema,
198
- }),
199
- drafts: v.strictObject({
200
- ...wireMetadata(appwriteIds.tables.drafts),
201
- account: appwriteRelationshipIdSchema,
202
- accountAssignmentKey: identifierSchema,
203
- attachmentMetadata: v.string(),
204
- contentHash: identifierSchema,
205
- envelope: v.string(),
206
- errorCode: v.nullable(identifierSchema),
207
- executionLeaseExpiresAt: v.nullable(timestampSchema),
208
- executionLeaseId: v.nullable(identifierSchema),
209
- fromAlias: v.nullable(appwriteRelationshipIdSchema),
210
- html: v.string(),
211
- referencedMessage: v.nullable(appwriteRelationshipIdSchema),
212
- revision: nonNegativeIntegerSchema,
213
- scheduledAt: v.nullable(timestampSchema),
214
- sequence: nonNegativeIntegerSchema,
215
- status: v.picklist(draftStates),
216
- type: v.picklist(draftTypes),
217
- }),
218
- jobs: v.strictObject({
219
- ...wireMetadata(appwriteIds.tables.jobs),
220
- accountId: v.nullable(identifierSchema),
221
- attempts: nonNegativeIntegerSchema,
222
- commandId: identifierSchema,
223
- dedupeKey: identifierSchema,
224
- errorCode: v.nullable(identifierSchema),
225
- kind: identifierSchema,
226
- leaseExpiresAt: v.nullable(timestampSchema),
227
- leaseId: v.nullable(identifierSchema),
228
- maxAttempts: nonNegativeIntegerSchema,
229
- nextRunAt: timestampSchema,
230
- payload: v.string(),
231
- state: v.picklist(jobStates),
232
- userId: identifierSchema,
233
- }),
234
- labels: v.strictObject({
235
- ...wireMetadata(appwriteIds.tables.labels),
236
- account: appwriteRelationshipIdSchema,
237
- accountAssignmentKey: identifierSchema,
238
- name: v.nullable(identifierSchema),
239
- path: identifierSchema,
240
- providerId: identifierSchema,
241
- specialUse: v.nullable(v.picklist(labelSpecialUses)),
242
- totalCount: nonNegativeIntegerSchema,
243
- unreadCount: nonNegativeIntegerSchema,
244
- }),
245
- mailboxSyncCandidates: v.strictObject({
246
- ...wireMetadata(appwriteIds.tables.mailboxSyncCandidates),
247
- account: appwriteRelationshipIdSchema,
248
- accountId: identifierSchema,
249
- generation: nonNegativeIntegerSchema,
250
- label: appwriteRelationshipIdSchema,
251
- labelId: identifierSchema,
252
- lane: v.picklist(mailboxSyncLanes),
253
- mailboxPath: identifierSchema,
254
- mailboxPriority: nonNegativeIntegerSchema,
255
- mailboxSortKey: mailboxSortKeySchema,
256
- providerId: identifierSchema,
257
- receivedAt: timestampSchema,
258
- specialUse: v.nullable(v.picklist(labelSpecialUses)),
259
- uid: nonNegativeIntegerSchema,
260
- uidValidity: nonNegativeIntegerSchema,
261
- userId: identifierSchema,
262
- }),
263
- mailboxSyncLanes: v.strictObject({
264
- ...wireMetadata(appwriteIds.tables.mailboxSyncLanes),
265
- $permissions: v.pipe(v.array(v.string()), v.length(0)),
266
- account: appwriteRelationshipIdSchema,
267
- accountId: identifierSchema,
268
- commandId: identifierSchema,
269
- cursor: v.nullable(v.string()),
270
- errorCode: v.nullable(identifierSchema),
271
- generation: nonNegativeIntegerSchema,
272
- lane: v.picklist(mailboxSyncLanes),
273
- state: v.picklist(mailboxSyncLaneStates),
274
- userId: identifierSchema,
275
- }),
276
- mailboxSyncStates: v.strictObject({
277
- ...wireMetadata(appwriteIds.tables.mailboxSyncStates),
278
- accountId: identifierSchema,
279
- errorCode: v.nullable(identifierSchema),
280
- lastEventAt: v.nullable(timestampSchema),
281
- lastSyncAt: v.nullable(timestampSchema),
282
- materialisationLeaseExpiresAt: v.nullable(timestampSchema),
283
- materialisationLeaseId: v.nullable(identifierSchema),
284
- nextPollAt: v.nullable(timestampSchema),
285
- provider: v.picklist(accountProviders),
286
- providerCursor: v.nullable(v.string()),
287
- state: v.picklist(mailboxSyncStates),
288
- uidValidity: v.nullable(v.string()),
289
- userId: identifierSchema,
290
- }),
291
- messageLocations: v.strictObject({
292
- ...wireMetadata(appwriteIds.tables.messageLocations),
293
- account: appwriteRelationshipIdSchema,
294
- accountAssignmentKey: identifierSchema,
295
- flagged: v.boolean(),
296
- label: appwriteRelationshipIdSchema,
297
- labelAssignmentKey: identifierSchema,
298
- message: appwriteRelationshipIdSchema,
299
- messageAt: timestampSchema,
300
- seen: v.boolean(),
301
- thread: appwriteRelationshipIdSchema,
302
- threadAssignmentKey: identifierSchema,
303
- uid: nonNegativeIntegerSchema,
304
- uidValidity: nonNegativeIntegerSchema,
305
- }),
306
- messages: v.strictObject({
307
- ...wireMetadata(appwriteIds.tables.messages),
308
- account: appwriteRelationshipIdSchema,
309
- accountAssignmentKey: identifierSchema,
310
- attachmentMetadata: v.string(),
311
- htmlFileId: v.nullable(identifierSchema),
312
- preview: v.nullable(v.string()),
313
- providerId: identifierSchema,
314
- rawFileId: v.nullable(identifierSchema),
315
- receivedAt: v.nullable(timestampSchema),
316
- recipients: v.nullable(v.string()),
317
- revision: nonNegativeIntegerSchema,
318
- rfcMessageId: v.nullable(identifierSchema),
319
- sender: v.nullable(v.string()),
320
- senderName: v.nullable(v.string()),
321
- sentAt: timestampSchema,
322
- size: nonNegativeIntegerSchema,
323
- subject: v.nullable(v.string()),
324
- thread: appwriteRelationshipIdSchema,
325
- threadAssignmentKey: identifierSchema,
326
- }),
327
- oauthStates: v.strictObject({
328
- ...wireMetadata(appwriteIds.tables.oauthStates),
329
- accountId: identifierSchema,
330
- email: emailSchema,
331
- expiresAt: timestampSchema,
332
- nonceHash: identifierSchema,
333
- operation: v.picklist(oauthOperations),
334
- profile: appwriteRelationshipIdSchema,
335
- provider: v.picklist(oauthProviders),
336
- returnUri: oauthReturnUriSchema,
337
- userId: identifierSchema,
338
- }),
339
- pollShardCoordinators: v.strictObject({
340
- ...wireMetadata(appwriteIds.tables.pollShardCoordinators),
341
- $permissions: v.pipe(v.array(v.string()), v.length(0)),
342
- accountCursor: v.nullable(identifierSchema),
343
- }),
344
- pollShards: v.strictObject({
345
- ...wireMetadata(appwriteIds.tables.pollShards),
346
- $permissions: v.pipe(v.array(v.string()), v.length(0)),
347
- accountIds: v.pipe(v.array(identifierSchema), v.maxLength(10)),
348
- errorCode: v.nullable(identifierSchema),
349
- generation: nonNegativeIntegerSchema,
350
- lastStartedAt: v.nullable(timestampSchema),
351
- leaseExpiresAt: v.nullable(timestampSchema),
352
- leaseId: v.nullable(identifierSchema),
353
- nextStartAt: timestampSchema,
354
- pollingSnapshot: v.string(),
355
- scheduledExecutionId: v.nullable(identifierSchema),
356
- state: v.picklist(pollShardStates),
357
- }),
358
- profileAvatarCleanups: v.strictObject({
359
- ...wireMetadata(appwriteIds.tables.profileAvatarCleanups),
360
- $permissions: v.pipe(v.array(v.string()), v.length(0)),
361
- claimedAt: v.nullable(timestampSchema),
362
- claimId: v.nullable(identifierSchema),
363
- fileId: identifierSchema,
364
- profile: appwriteRelationshipIdSchema,
365
- }),
366
- profiles: v.strictObject({
367
- ...wireMetadata(appwriteIds.tables.profiles),
368
- avatarFileId: v.nullable(appwriteRowIdSchema),
369
- deletionRequestedAt: v.nullable(timestampSchema),
370
- email: emailSchema,
371
- name: v.nullable(identifierSchema),
372
- onboardingState: v.nullable(identifierSchema),
373
- timezone: v.nullable(identifierSchema),
374
- }),
375
- pushNotificationTokens: v.strictObject({
376
- ...wireMetadata(appwriteIds.tables.pushNotificationTokens),
377
- profile: appwriteRelationshipIdSchema,
378
- token: identifierSchema,
379
- userId: identifierSchema,
380
- }),
381
- savedViews: v.strictObject({
382
- ...wireMetadata(appwriteIds.tables.savedViews),
383
- aliasIds: v.array(identifierSchema),
384
- icon: v.nullable(identifierSchema),
385
- name: identifierSchema,
386
- profile: appwriteRelationshipIdSchema,
387
- }),
388
- threadAliases: v.strictObject({
389
- ...wireMetadata(appwriteIds.tables.threadAliases),
390
- alias: appwriteRelationshipIdSchema,
391
- aliasAssignmentKey: identifierSchema,
392
- latestMessageAt: timestampSchema,
393
- thread: appwriteRelationshipIdSchema,
394
- threadAssignmentKey: identifierSchema,
395
- }),
396
- threadLabels: v.strictObject({
397
- ...wireMetadata(appwriteIds.tables.threadLabels),
398
- label: appwriteRelationshipIdSchema,
399
- labelAssignmentKey: identifierSchema,
400
- latestMessageAt: timestampSchema,
401
- locationCount: nonNegativeIntegerSchema,
402
- thread: appwriteRelationshipIdSchema,
403
- threadAssignmentKey: identifierSchema,
404
- }),
405
- threads: v.strictObject({
406
- ...wireMetadata(appwriteIds.tables.threads),
407
- account: appwriteRelationshipIdSchema,
408
- accountAssignmentKey: identifierSchema,
409
- archived: v.boolean(),
410
- firstMessageAt: v.nullable(timestampSchema),
411
- flagged: v.boolean(),
412
- flaggedLocationCount: nonNegativeIntegerSchema,
413
- hasAttachments: v.boolean(),
414
- labelIds: v.array(identifierSchema),
415
- latestMessageAt: timestampSchema,
416
- latestMessageId: identifierSchema,
417
- messageCount: nonNegativeIntegerSchema,
418
- participants: v.nullable(v.string()),
419
- preview: v.nullable(v.string()),
420
- providerId: identifierSchema,
421
- revision: nonNegativeIntegerSchema,
422
- searchText: v.nullable(v.string()),
423
- seen: v.boolean(),
424
- senderEmail: v.nullable(mailboxAddressSchema),
425
- senderName: v.nullable(identifierSchema),
426
- snoozedUntil: v.nullable(timestampSchema),
427
- spam: v.boolean(),
428
- subject: v.nullable(v.string()),
429
- trashed: v.boolean(),
430
- unseenLocationCount: nonNegativeIntegerSchema,
431
- }),
432
- };
433
67
  export const appwrite = {
68
+ dataSchemas: appwriteDataSchemas,
434
69
  decodedSchemas: {
435
70
  commandPayload: jsonObjectTextSchema,
436
71
  draftAttachments: draftAttachmentsSchema,
@@ -445,5 +80,6 @@ export const appwrite = {
445
80
  mailboxSync: { lanes: mailboxSyncLanes, laneStates: mailboxSyncLaneStates, states: mailboxSyncStates },
446
81
  oauth: { operations: oauthOperations, providers: oauthProviders, returnUris: oauthReturnUris, returnUriSchema: oauthReturnUriSchema },
447
82
  polling: { shardStates: pollShardStates },
448
- rowSchemas,
83
+ rowSchemas: generatedRowSchemas,
84
+ tables: appwriteTables,
449
85
  };
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'bun:test';
2
2
  import * as v from 'valibot';
3
- import { appwrite } from './appwrite';
3
+ import { appwrite, appwriteTableIds } from './appwrite';
4
4
  const metadata = {
5
5
  $createdAt: '2026-07-15T00:00:00.000Z',
6
6
  $databaseId: 'marco',
@@ -230,6 +230,12 @@ const validRows = {
230
230
  returnUri: 'https://app.marcoapp.io/onboarding/loading',
231
231
  userId: 'user-1',
232
232
  },
233
+ pollShardCoordinators: {
234
+ ...metadata,
235
+ $permissions: [],
236
+ $tableId: 'poll_shard_coordinators',
237
+ accountCursor: null,
238
+ },
233
239
  pollShards: {
234
240
  ...metadata,
235
241
  $permissions: [],
@@ -383,6 +389,73 @@ describe('appwrite', () => {
383
389
  },
384
390
  });
385
391
  });
392
+ it('generates every table definition and schema from the shared contract', () => {
393
+ expect(Object.keys(appwrite.tables).sort()).toEqual(Object.keys(appwrite.ids.tables).sort());
394
+ const tableKeys = Object.keys(appwrite.ids.tables);
395
+ for (const tableKey of tableKeys) {
396
+ const tableId = appwrite.ids.tables[tableKey];
397
+ const table = appwrite.tables[tableKey];
398
+ const dataSchema = appwrite.dataSchemas[tableKey];
399
+ const rowSchema = appwrite.rowSchemas[tableKey];
400
+ const dataKeys = Object.keys(dataSchema.entries);
401
+ expect(table.id).toBe(tableId);
402
+ expect(Object.keys(rowSchema.entries)).toEqual(['$createdAt', '$databaseId', '$id', '$permissions', '$sequence', '$tableId', '$updatedAt', ...dataKeys]);
403
+ expect(dataKeys.sort()).toEqual([...table.columns.map(column => column.key), ...(table.relationships ?? []).map(relationship => relationship.key)].sort());
404
+ }
405
+ });
406
+ it('publishes every physical table ID exactly once', () => {
407
+ expect([...appwriteTableIds]).toEqual(Object.values(appwrite.ids.tables));
408
+ expect(new Set(appwriteTableIds).size).toBe(appwriteTableIds.length);
409
+ });
410
+ it('publishes the explicit physical message-location contract', () => {
411
+ expect(appwrite.tables.messageLocations.columns).toEqual([
412
+ { key: 'accountAssignmentKey', required: true, size: 36, type: 'string' },
413
+ { key: 'flagged', required: true, type: 'boolean' },
414
+ { key: 'labelAssignmentKey', required: true, size: 36, type: 'string' },
415
+ { key: 'messageAt', required: true, type: 'datetime' },
416
+ { key: 'seen', required: true, type: 'boolean' },
417
+ { key: 'threadAssignmentKey', required: true, size: 36, type: 'string' },
418
+ { key: 'uid', required: false, type: 'bigint' },
419
+ { key: 'uidValidity', required: false, type: 'bigint' },
420
+ ]);
421
+ expect(appwrite.tables.messageLocations.relationships).toEqual([
422
+ { key: 'account', onDelete: 'cascade', relatedTableId: appwrite.ids.tables.accounts, type: 'manyToOne' },
423
+ { key: 'label', onDelete: 'cascade', relatedTableId: appwrite.ids.tables.labels, type: 'manyToOne' },
424
+ { key: 'message', onDelete: 'cascade', relatedTableId: appwrite.ids.tables.messages, type: 'manyToOne' },
425
+ { key: 'thread', onDelete: 'cascade', relatedTableId: appwrite.ids.tables.threads, type: 'manyToOne' },
426
+ ]);
427
+ });
428
+ it('enforces nullable positive message-location coordinates as a pair', () => {
429
+ const messageLocations = appwrite.dataSchemas.messageLocations;
430
+ for (const coordinates of [
431
+ { uid: null, uidValidity: null },
432
+ { uid: 1, uidValidity: 1 },
433
+ ]) {
434
+ expect(v.safeParse(messageLocations, { ...validRows.messageLocations, ...coordinates }).success).toBe(true);
435
+ }
436
+ for (const coordinates of [
437
+ { uid: null, uidValidity: 1 },
438
+ { uid: 1, uidValidity: null },
439
+ { uid: 0, uidValidity: 1 },
440
+ { uid: 1, uidValidity: 0 },
441
+ ]) {
442
+ expect(v.safeParse(messageLocations, { ...validRows.messageLocations, ...coordinates }).success).toBe(false);
443
+ }
444
+ });
445
+ it('rejects zero mailbox-sync candidate coordinates', () => {
446
+ expect(v.safeParse(appwrite.dataSchemas.mailboxSyncCandidates.entries.uid, 0).success).toBe(false);
447
+ expect(v.safeParse(appwrite.dataSchemas.mailboxSyncCandidates.entries.uidValidity, 0).success).toBe(false);
448
+ });
449
+ it('pins every generated wire row to its table ID', () => {
450
+ const tableKeys = Object.keys(appwrite.ids.tables);
451
+ for (const tableKey of tableKeys) {
452
+ const wrongTableId = tableKey === 'accounts' ? appwrite.ids.tables.aliases : appwrite.ids.tables.accounts;
453
+ const rowSchema = appwrite.rowSchemas[tableKey];
454
+ const row = validRows[tableKey];
455
+ expect(v.safeParse(rowSchema, row).success).toBe(true);
456
+ expect(v.safeParse(rowSchema, { ...row, $tableId: wrongTableId }).success).toBe(false);
457
+ }
458
+ });
386
459
  it('exports the shared OAuth state contract', () => {
387
460
  expect(appwrite.oauth).toMatchObject({
388
461
  operations: ['CONNECT', 'REPLACE'],
@@ -573,6 +646,7 @@ describe('appwrite', () => {
573
646
  'threadAssignmentKey',
574
647
  ],
575
648
  oauthStates: ['accountId', 'email', 'expiresAt', 'nonceHash', 'operation', 'profile', 'provider', 'returnUri', 'userId'],
649
+ pollShardCoordinators: ['accountCursor'],
576
650
  pollShards: ['accountIds', 'errorCode', 'generation', 'lastStartedAt', 'leaseExpiresAt', 'leaseId', 'nextStartAt', 'pollingSnapshot', 'scheduledExecutionId', 'state'],
577
651
  profileAvatarCleanups: ['claimedAt', 'claimId', 'fileId', 'profile'],
578
652
  profiles: ['avatarFileId', 'deletionRequestedAt', 'email', 'name', 'onboardingState', 'timezone'],