@marcoappio/marco-config 2.0.576 → 2.0.578
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/commands.d.ts +345 -0
- package/dist/appwrite/commands.d.ts.map +1 -0
- package/dist/appwrite/commands.js +237 -0
- package/dist/appwrite/commands.test.d.ts +2 -0
- package/dist/appwrite/commands.test.d.ts.map +1 -0
- package/dist/appwrite/commands.test.js +381 -0
- package/dist/appwrite/functions.d.ts +539 -0
- package/dist/appwrite/functions.d.ts.map +1 -0
- package/dist/appwrite/functions.js +147 -0
- package/dist/appwrite/functions.test.d.ts +2 -0
- package/dist/appwrite/functions.test.d.ts.map +1 -0
- package/dist/appwrite/functions.test.js +154 -0
- package/dist/appwrite/index.d.ts +2 -0
- package/dist/appwrite/index.d.ts.map +1 -1
- package/dist/appwrite/index.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/mutators/mutatorSchemas.d.ts +2 -2
- package/dist/sdk/endpoints/private/mutations/draft/setEnvelope.d.ts +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
import { appwriteCommands } from './commands';
|
|
4
|
+
const commandMetadata = {
|
|
5
|
+
id: '0197f3d4-1b22-7abc-8def-123456789abc',
|
|
6
|
+
submittedAt: '2026-07-15T00:00:00.000Z',
|
|
7
|
+
version: 1,
|
|
8
|
+
};
|
|
9
|
+
const commandFixtures = [
|
|
10
|
+
{
|
|
11
|
+
command: {
|
|
12
|
+
...commandMetadata,
|
|
13
|
+
accountId: null,
|
|
14
|
+
kind: 'profile.settings.set',
|
|
15
|
+
payload: { name: 'Isaac', timezone: 'Europe/London' },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
command: {
|
|
20
|
+
...commandMetadata,
|
|
21
|
+
accountId: 'account_1',
|
|
22
|
+
kind: 'account.settings.set',
|
|
23
|
+
payload: { colour: '#000000', displayName: 'Marco' },
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{ command: { ...commandMetadata, accountId: 'account_1', kind: 'account.delete', payload: {} } },
|
|
27
|
+
{
|
|
28
|
+
command: {
|
|
29
|
+
...commandMetadata,
|
|
30
|
+
accountId: 'account_1',
|
|
31
|
+
kind: 'alias.create',
|
|
32
|
+
payload: { aliasId: 'alias_1', email: 'marco@example.com', name: null, signature: null },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
command: {
|
|
37
|
+
...commandMetadata,
|
|
38
|
+
accountId: 'account_1',
|
|
39
|
+
kind: 'alias.delete',
|
|
40
|
+
payload: { aliasId: 'alias_1' },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
command: {
|
|
45
|
+
...commandMetadata,
|
|
46
|
+
accountId: 'account_1',
|
|
47
|
+
kind: 'alias.name.set',
|
|
48
|
+
payload: { aliasId: 'alias_1', name: 'Marco' },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
command: {
|
|
53
|
+
...commandMetadata,
|
|
54
|
+
accountId: 'account_1',
|
|
55
|
+
kind: 'alias.primary.set',
|
|
56
|
+
payload: { aliasId: 'alias_1' },
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
command: {
|
|
61
|
+
...commandMetadata,
|
|
62
|
+
accountId: 'account_1',
|
|
63
|
+
kind: 'alias.signature.set',
|
|
64
|
+
payload: { aliasId: 'alias_1', signature: 'Regards' },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
command: {
|
|
69
|
+
...commandMetadata,
|
|
70
|
+
accountId: 'account_1',
|
|
71
|
+
kind: 'label.create',
|
|
72
|
+
payload: { labelId: 'label_1', path: 'Projects' },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
command: {
|
|
77
|
+
...commandMetadata,
|
|
78
|
+
accountId: 'account_1',
|
|
79
|
+
kind: 'label.delete',
|
|
80
|
+
payload: { labelId: 'label_1' },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
command: {
|
|
85
|
+
...commandMetadata,
|
|
86
|
+
accountId: 'account_1',
|
|
87
|
+
kind: 'label.rename',
|
|
88
|
+
payload: { labelId: 'label_1', path: 'Projects/Marco' },
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
command: {
|
|
93
|
+
...commandMetadata,
|
|
94
|
+
accountId: 'account_1',
|
|
95
|
+
kind: 'thread.label.add',
|
|
96
|
+
payload: { labelId: 'label_1', threadIds: ['thread_1'] },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
command: {
|
|
101
|
+
...commandMetadata,
|
|
102
|
+
accountId: 'account_1',
|
|
103
|
+
kind: 'thread.label.remove',
|
|
104
|
+
payload: { labelId: 'label_1', threadIds: ['thread_1'] },
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
command: {
|
|
109
|
+
...commandMetadata,
|
|
110
|
+
accountId: 'account_1',
|
|
111
|
+
kind: 'thread.archive.set',
|
|
112
|
+
payload: { archived: true, threadIds: ['thread_1'] },
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
command: {
|
|
117
|
+
...commandMetadata,
|
|
118
|
+
accountId: 'account_1',
|
|
119
|
+
kind: 'thread.flagged.set',
|
|
120
|
+
payload: { flagged: true, threadIds: ['thread_1'] },
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
command: {
|
|
125
|
+
...commandMetadata,
|
|
126
|
+
accountId: 'account_1',
|
|
127
|
+
kind: 'thread.seen.set',
|
|
128
|
+
payload: { seen: true, threadIds: ['thread_1'] },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
command: {
|
|
133
|
+
...commandMetadata,
|
|
134
|
+
accountId: 'account_1',
|
|
135
|
+
kind: 'thread.snooze.set',
|
|
136
|
+
payload: { snoozedUntil: '2026-07-16T00:00:00.000Z', threadIds: ['thread_1'] },
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
command: {
|
|
141
|
+
...commandMetadata,
|
|
142
|
+
accountId: 'account_1',
|
|
143
|
+
kind: 'thread.spam.set',
|
|
144
|
+
payload: { spam: true, threadIds: ['thread_1'] },
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
command: {
|
|
149
|
+
...commandMetadata,
|
|
150
|
+
accountId: 'account_1',
|
|
151
|
+
kind: 'thread.trash.set',
|
|
152
|
+
payload: { threadIds: ['thread_1'], trashed: true },
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
command: {
|
|
157
|
+
...commandMetadata,
|
|
158
|
+
accountId: 'account_1',
|
|
159
|
+
kind: 'thread.delete',
|
|
160
|
+
payload: { threadIds: ['thread_1'] },
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
command: {
|
|
165
|
+
...commandMetadata,
|
|
166
|
+
accountId: 'account_1',
|
|
167
|
+
kind: 'draft.create',
|
|
168
|
+
payload: { draftId: 'draft_1', fromAliasId: null, referencedMessageId: null, type: 'NEW' },
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
command: {
|
|
173
|
+
...commandMetadata,
|
|
174
|
+
accountId: 'account_1',
|
|
175
|
+
kind: 'draft.content.set',
|
|
176
|
+
payload: { draftId: 'draft_1', html: '<p>Hello</p>' },
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
command: {
|
|
181
|
+
...commandMetadata,
|
|
182
|
+
accountId: 'account_1',
|
|
183
|
+
kind: 'draft.envelope.set',
|
|
184
|
+
payload: { bcc: [], cc: [], draftId: 'draft_1', subject: 'Hello', to: ['marco@example.com'] },
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
command: {
|
|
189
|
+
...commandMetadata,
|
|
190
|
+
accountId: 'account_1',
|
|
191
|
+
kind: 'draft.from.set',
|
|
192
|
+
payload: { draftId: 'draft_1', fromAliasId: 'alias_1' },
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
{ command: { ...commandMetadata, accountId: 'account_1', kind: 'draft.delete', payload: { draftId: 'draft_1' } } },
|
|
196
|
+
{
|
|
197
|
+
command: {
|
|
198
|
+
...commandMetadata,
|
|
199
|
+
accountId: 'account_1',
|
|
200
|
+
kind: 'draft.attachment.link',
|
|
201
|
+
payload: {
|
|
202
|
+
draftId: 'draft_1',
|
|
203
|
+
fileId: 'file_1',
|
|
204
|
+
fileName: 'proposal.pdf',
|
|
205
|
+
mimeType: 'application/pdf',
|
|
206
|
+
size: 1,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
command: {
|
|
212
|
+
...commandMetadata,
|
|
213
|
+
accountId: 'account_1',
|
|
214
|
+
kind: 'draft.attachment.delete',
|
|
215
|
+
payload: { draftId: 'draft_1', fileId: 'file_1' },
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
{ command: { ...commandMetadata, accountId: 'account_1', kind: 'draft.send', payload: { draftId: 'draft_1' } } },
|
|
219
|
+
{
|
|
220
|
+
command: {
|
|
221
|
+
...commandMetadata,
|
|
222
|
+
accountId: 'account_1',
|
|
223
|
+
kind: 'draft.send.cancel',
|
|
224
|
+
payload: { draftId: 'draft_1' },
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
command: {
|
|
229
|
+
...commandMetadata,
|
|
230
|
+
accountId: 'account_1',
|
|
231
|
+
kind: 'draft.send.schedule',
|
|
232
|
+
payload: { draftId: 'draft_1', scheduledAt: '2026-07-16T00:00:00.000Z' },
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
describe('appwriteCommands', () => {
|
|
237
|
+
it('publishes the complete version-one command and status manifest', () => {
|
|
238
|
+
expect(appwriteCommands.version).toBe(1);
|
|
239
|
+
expect(appwriteCommands.kinds).toEqual([
|
|
240
|
+
'profile.settings.set',
|
|
241
|
+
'account.settings.set',
|
|
242
|
+
'account.delete',
|
|
243
|
+
'alias.create',
|
|
244
|
+
'alias.delete',
|
|
245
|
+
'alias.name.set',
|
|
246
|
+
'alias.primary.set',
|
|
247
|
+
'alias.signature.set',
|
|
248
|
+
'label.create',
|
|
249
|
+
'label.delete',
|
|
250
|
+
'label.rename',
|
|
251
|
+
'thread.label.add',
|
|
252
|
+
'thread.label.remove',
|
|
253
|
+
'thread.archive.set',
|
|
254
|
+
'thread.flagged.set',
|
|
255
|
+
'thread.seen.set',
|
|
256
|
+
'thread.snooze.set',
|
|
257
|
+
'thread.spam.set',
|
|
258
|
+
'thread.trash.set',
|
|
259
|
+
'thread.delete',
|
|
260
|
+
'draft.create',
|
|
261
|
+
'draft.content.set',
|
|
262
|
+
'draft.envelope.set',
|
|
263
|
+
'draft.from.set',
|
|
264
|
+
'draft.delete',
|
|
265
|
+
'draft.attachment.link',
|
|
266
|
+
'draft.attachment.delete',
|
|
267
|
+
'draft.send',
|
|
268
|
+
'draft.send.cancel',
|
|
269
|
+
'draft.send.schedule',
|
|
270
|
+
]);
|
|
271
|
+
expect(appwriteCommands.states).toEqual(['ACCEPTED', 'RUNNING', 'SUCCEEDED', 'FAILED']);
|
|
272
|
+
expect(appwriteCommands.errorCodes).toEqual([
|
|
273
|
+
'AUTHENTICATION_FAILED',
|
|
274
|
+
'AUTHORIZATION_FAILED',
|
|
275
|
+
'COMMAND_CONFLICT',
|
|
276
|
+
'COMMAND_NOT_FOUND',
|
|
277
|
+
'INVALID_COMMAND',
|
|
278
|
+
'PROVIDER_REJECTED',
|
|
279
|
+
'TRANSIENT_FAILURE',
|
|
280
|
+
'INTERNAL_ERROR',
|
|
281
|
+
]);
|
|
282
|
+
});
|
|
283
|
+
for (const { command } of commandFixtures) {
|
|
284
|
+
it(`accepts ${command.kind}`, () => {
|
|
285
|
+
expect(v.safeParse(appwriteCommands.requestSchema, command).success).toBe(true);
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
const invalidCommands = [
|
|
289
|
+
{
|
|
290
|
+
command: { ...commandFixtures[0].command, payload: commandFixtures[1].command.payload },
|
|
291
|
+
description: 'a command and payload mismatch',
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
command: { ...commandFixtures[0].command, userId: 'another-user' },
|
|
295
|
+
description: 'a caller-provided owner',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
command: { ...commandFixtures[1].command, accountId: null },
|
|
299
|
+
description: 'a null account ID for an account-scoped command',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
command: {
|
|
303
|
+
...commandFixtures[21].command,
|
|
304
|
+
payload: { ...commandFixtures[21].command.payload, credentials: 'secret' },
|
|
305
|
+
},
|
|
306
|
+
description: 'credentials in a payload',
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
command: {
|
|
310
|
+
...commandFixtures[26].command,
|
|
311
|
+
payload: { ...commandFixtures[26].command.payload, token: 'secret' },
|
|
312
|
+
},
|
|
313
|
+
description: 'a token in a payload',
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
command: { ...commandFixtures[0].command, kind: 'saved-view.create' },
|
|
317
|
+
description: 'an excluded action family',
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
command: { ...commandFixtures[0].command, version: 2 },
|
|
321
|
+
description: 'an unknown command version',
|
|
322
|
+
},
|
|
323
|
+
];
|
|
324
|
+
for (const { command, description } of invalidCommands) {
|
|
325
|
+
it(`rejects ${description}`, () => {
|
|
326
|
+
expect(v.safeParse(appwriteCommands.requestSchema, command).success).toBe(false);
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const responseFixtures = [
|
|
330
|
+
{
|
|
331
|
+
expected: true,
|
|
332
|
+
response: {
|
|
333
|
+
canonicalRevision: null,
|
|
334
|
+
error: null,
|
|
335
|
+
id: commandMetadata.id,
|
|
336
|
+
state: 'ACCEPTED',
|
|
337
|
+
},
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
expected: true,
|
|
341
|
+
response: {
|
|
342
|
+
canonicalRevision: null,
|
|
343
|
+
error: null,
|
|
344
|
+
id: commandMetadata.id,
|
|
345
|
+
state: 'RUNNING',
|
|
346
|
+
},
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
expected: true,
|
|
350
|
+
response: {
|
|
351
|
+
canonicalRevision: 3,
|
|
352
|
+
error: null,
|
|
353
|
+
id: commandMetadata.id,
|
|
354
|
+
state: 'SUCCEEDED',
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
expected: true,
|
|
359
|
+
response: {
|
|
360
|
+
canonicalRevision: 3,
|
|
361
|
+
error: { code: 'PROVIDER_REJECTED', retryable: false },
|
|
362
|
+
id: commandMetadata.id,
|
|
363
|
+
state: 'FAILED',
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
expected: false,
|
|
368
|
+
response: {
|
|
369
|
+
canonicalRevision: null,
|
|
370
|
+
error: { code: 'UNSAFE_CODE', retryable: false },
|
|
371
|
+
id: commandMetadata.id,
|
|
372
|
+
state: 'FAILED',
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
];
|
|
376
|
+
for (const { expected, response } of responseFixtures) {
|
|
377
|
+
it(`parses ${response.state} status as ${expected ? 'valid' : 'invalid'}`, () => {
|
|
378
|
+
expect(v.safeParse(appwriteCommands.responseSchema, response).success).toBe(expected);
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
});
|