@marcoappio/marco-config 4.0.14 → 4.0.15
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 +4957 -267
- package/dist/appwrite/commands.d.ts.map +1 -1
- package/dist/appwrite/commands.js +72 -111
- package/dist/appwrite/commands.test.js +36 -1
- package/dist/appwrite/functions.d.ts +2427 -226
- package/dist/appwrite/functions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/appwrite/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAc5B,eAAO,MAAM,cAAc;8BACC,MAAM,KAAG,MAAM;CAC1C,CAAA;AAED,QAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/appwrite/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAc5B,eAAO,MAAM,cAAc;8BACC,MAAM,KAAG,MAAM;CAC1C,CAAA;AAED,KAAK,wBAAwB,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,OAAO,GAAG,eAAe,GAAG,iBAAiB,GAAG,QAAQ,CAAA;AAqH5H,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAa,CAAC,CAAA;AACzF,MAAM,MAAM,sBAAsB,CAAC,KAAK,SAAS,mBAAmB,IAAI,OAAO,CAAC,sBAAsB,EAAE;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC,SAAS,CAAC,CAAA;AACnI,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,gBAAgB,CAAC,cAAc,CAAC,CAAA;AAC3F,MAAM,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAA"}
|
|
@@ -11,74 +11,6 @@ const avatarSha256Schema = v.pipe(v.string(), v.regex(/^[a-f0-9]{64}$/));
|
|
|
11
11
|
export const appwriteAvatar = {
|
|
12
12
|
createFileId: (commandId) => v.parse(commandIdSchema, commandId),
|
|
13
13
|
};
|
|
14
|
-
const commandKinds = {
|
|
15
|
-
accountDelete: 'account.delete',
|
|
16
|
-
accountSettingsSet: 'account.settings.set',
|
|
17
|
-
aliasCreate: 'alias.create',
|
|
18
|
-
aliasDelete: 'alias.delete',
|
|
19
|
-
aliasNameSet: 'alias.name.set',
|
|
20
|
-
aliasPrimarySet: 'alias.primary.set',
|
|
21
|
-
aliasSignatureSet: 'alias.signature.set',
|
|
22
|
-
draftAttachmentDelete: 'draft.attachment.delete',
|
|
23
|
-
draftAttachmentLink: 'draft.attachment.link',
|
|
24
|
-
draftContentSet: 'draft.content.set',
|
|
25
|
-
draftCreate: 'draft.create',
|
|
26
|
-
draftDelete: 'draft.delete',
|
|
27
|
-
draftEnvelopeSet: 'draft.envelope.set',
|
|
28
|
-
draftFromSet: 'draft.from.set',
|
|
29
|
-
draftSend: 'draft.send',
|
|
30
|
-
draftSendCancel: 'draft.send.cancel',
|
|
31
|
-
draftSendSchedule: 'draft.send.schedule',
|
|
32
|
-
labelCreate: 'label.create',
|
|
33
|
-
labelDelete: 'label.delete',
|
|
34
|
-
labelRename: 'label.rename',
|
|
35
|
-
profileAvatarSet: 'profile.avatar.set',
|
|
36
|
-
profileSettingsSet: 'profile.settings.set',
|
|
37
|
-
threadArchiveSet: 'thread.archive.set',
|
|
38
|
-
threadDelete: 'thread.delete',
|
|
39
|
-
threadFlaggedSet: 'thread.flagged.set',
|
|
40
|
-
threadLabelAdd: 'thread.label.add',
|
|
41
|
-
threadLabelRemove: 'thread.label.remove',
|
|
42
|
-
threadSeenSet: 'thread.seen.set',
|
|
43
|
-
threadSnoozeSet: 'thread.snooze.set',
|
|
44
|
-
threadSpamSet: 'thread.spam.set',
|
|
45
|
-
threadTrashSet: 'thread.trash.set',
|
|
46
|
-
};
|
|
47
|
-
export const appwriteCommandGroups = {
|
|
48
|
-
account: [
|
|
49
|
-
commandKinds.accountDelete,
|
|
50
|
-
commandKinds.accountSettingsSet,
|
|
51
|
-
commandKinds.aliasCreate,
|
|
52
|
-
commandKinds.aliasDelete,
|
|
53
|
-
commandKinds.aliasNameSet,
|
|
54
|
-
commandKinds.aliasPrimarySet,
|
|
55
|
-
commandKinds.aliasSignatureSet,
|
|
56
|
-
],
|
|
57
|
-
draft: [
|
|
58
|
-
commandKinds.draftAttachmentDelete,
|
|
59
|
-
commandKinds.draftAttachmentLink,
|
|
60
|
-
commandKinds.draftContentSet,
|
|
61
|
-
commandKinds.draftCreate,
|
|
62
|
-
commandKinds.draftDelete,
|
|
63
|
-
commandKinds.draftEnvelopeSet,
|
|
64
|
-
commandKinds.draftFromSet,
|
|
65
|
-
],
|
|
66
|
-
draftSend: [commandKinds.draftSend, commandKinds.draftSendCancel, commandKinds.draftSendSchedule],
|
|
67
|
-
label: [commandKinds.labelCreate, commandKinds.labelDelete, commandKinds.labelRename],
|
|
68
|
-
profileAvatar: [commandKinds.profileAvatarSet],
|
|
69
|
-
profileSettings: [commandKinds.profileSettingsSet],
|
|
70
|
-
thread: [
|
|
71
|
-
commandKinds.threadArchiveSet,
|
|
72
|
-
commandKinds.threadDelete,
|
|
73
|
-
commandKinds.threadFlaggedSet,
|
|
74
|
-
commandKinds.threadLabelAdd,
|
|
75
|
-
commandKinds.threadLabelRemove,
|
|
76
|
-
commandKinds.threadSeenSet,
|
|
77
|
-
commandKinds.threadSnoozeSet,
|
|
78
|
-
commandKinds.threadSpamSet,
|
|
79
|
-
commandKinds.threadTrashSet,
|
|
80
|
-
],
|
|
81
|
-
};
|
|
82
14
|
const commandErrorCodes = [
|
|
83
15
|
'AUTHENTICATION_FAILED',
|
|
84
16
|
'AUTHORIZATION_FAILED',
|
|
@@ -90,6 +22,10 @@ const commandErrorCodes = [
|
|
|
90
22
|
'INTERNAL_ERROR',
|
|
91
23
|
];
|
|
92
24
|
const accountIdSchema = id.accountId.required();
|
|
25
|
+
const commandAccountIdSchemas = {
|
|
26
|
+
NULLABLE: v.nullable(accountIdSchema),
|
|
27
|
+
REQUIRED: accountIdSchema,
|
|
28
|
+
};
|
|
93
29
|
const createCommandRequestSchema = (kind, payload, accountId) => v.strictObject({
|
|
94
30
|
accountId,
|
|
95
31
|
id: commandIdSchema,
|
|
@@ -98,7 +34,6 @@ const createCommandRequestSchema = (kind, payload, accountId) => v.strictObject(
|
|
|
98
34
|
submittedAt: isoTimestampSchema,
|
|
99
35
|
version: v.literal(1),
|
|
100
36
|
});
|
|
101
|
-
const createAccountCommandRequestSchema = (kind, payload) => createCommandRequestSchema(kind, payload, accountIdSchema);
|
|
102
37
|
const profileSettingsSetPayloadSchema = v.strictObject({
|
|
103
38
|
name: v.optional(v.nullable(string.required())),
|
|
104
39
|
timezone: v.optional(v.nullable(string.required())),
|
|
@@ -171,66 +106,92 @@ const draftAttachmentDeletePayloadSchema = v.strictObject({
|
|
|
171
106
|
const draftSendPayloadSchema = v.strictObject({ draftId: id.draftId.required() });
|
|
172
107
|
const draftSendCancelPayloadSchema = v.strictObject({ draftId: id.draftId.required() });
|
|
173
108
|
const draftSendSchedulePayloadSchema = v.strictObject({ draftId: id.draftId.required(), scheduledAt: canonicalTimestampSchema });
|
|
174
|
-
const
|
|
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
|
-
|
|
109
|
+
const defineCommand = (kind, accountScope, payloadSchema) => ({
|
|
110
|
+
...createCommandRequestSchema(kind, payloadSchema, commandAccountIdSchemas[accountScope]),
|
|
111
|
+
accountScope,
|
|
112
|
+
commandKind: kind,
|
|
113
|
+
payloadSchema,
|
|
114
|
+
});
|
|
115
|
+
const commandDefinitions = {
|
|
116
|
+
account: [
|
|
117
|
+
defineCommand('account.delete', 'REQUIRED', accountDeletePayloadSchema),
|
|
118
|
+
defineCommand('account.settings.set', 'REQUIRED', accountSettingsSetPayloadSchema),
|
|
119
|
+
defineCommand('alias.create', 'REQUIRED', aliasCreatePayloadSchema),
|
|
120
|
+
defineCommand('alias.delete', 'REQUIRED', aliasDeletePayloadSchema),
|
|
121
|
+
defineCommand('alias.name.set', 'REQUIRED', aliasNameSetPayloadSchema),
|
|
122
|
+
defineCommand('alias.primary.set', 'REQUIRED', aliasPrimarySetPayloadSchema),
|
|
123
|
+
defineCommand('alias.signature.set', 'REQUIRED', aliasSignatureSetPayloadSchema),
|
|
124
|
+
],
|
|
125
|
+
draft: [
|
|
126
|
+
defineCommand('draft.attachment.delete', 'REQUIRED', draftAttachmentDeletePayloadSchema),
|
|
127
|
+
defineCommand('draft.attachment.link', 'REQUIRED', draftAttachmentLinkPayloadSchema),
|
|
128
|
+
defineCommand('draft.content.set', 'REQUIRED', draftContentSetPayloadSchema),
|
|
129
|
+
defineCommand('draft.create', 'REQUIRED', draftCreatePayloadSchema),
|
|
130
|
+
defineCommand('draft.delete', 'REQUIRED', draftDeletePayloadSchema),
|
|
131
|
+
defineCommand('draft.envelope.set', 'REQUIRED', draftEnvelopeSetPayloadSchema),
|
|
132
|
+
defineCommand('draft.from.set', 'REQUIRED', draftFromSetPayloadSchema),
|
|
133
|
+
],
|
|
134
|
+
draftSend: [
|
|
135
|
+
defineCommand('draft.send', 'REQUIRED', draftSendPayloadSchema),
|
|
136
|
+
defineCommand('draft.send.cancel', 'REQUIRED', draftSendCancelPayloadSchema),
|
|
137
|
+
defineCommand('draft.send.schedule', 'REQUIRED', draftSendSchedulePayloadSchema),
|
|
138
|
+
],
|
|
139
|
+
label: [
|
|
140
|
+
defineCommand('label.create', 'REQUIRED', labelCreatePayloadSchema),
|
|
141
|
+
defineCommand('label.delete', 'REQUIRED', labelDeletePayloadSchema),
|
|
142
|
+
defineCommand('label.rename', 'REQUIRED', labelRenamePayloadSchema),
|
|
143
|
+
],
|
|
144
|
+
profileAvatar: [defineCommand('profile.avatar.set', 'NULLABLE', profileAvatarSetPayloadSchema)],
|
|
145
|
+
profileSettings: [defineCommand('profile.settings.set', 'NULLABLE', profileSettingsSetPayloadSchema)],
|
|
146
|
+
thread: [
|
|
147
|
+
defineCommand('thread.archive.set', 'REQUIRED', threadArchiveSetPayloadSchema),
|
|
148
|
+
defineCommand('thread.delete', 'REQUIRED', threadDeletePayloadSchema),
|
|
149
|
+
defineCommand('thread.flagged.set', 'REQUIRED', threadFlaggedSetPayloadSchema),
|
|
150
|
+
defineCommand('thread.label.add', 'REQUIRED', threadLabelAddPayloadSchema),
|
|
151
|
+
defineCommand('thread.label.remove', 'REQUIRED', threadLabelRemovePayloadSchema),
|
|
152
|
+
defineCommand('thread.seen.set', 'REQUIRED', threadSeenSetPayloadSchema),
|
|
153
|
+
defineCommand('thread.snooze.set', 'REQUIRED', threadSnoozeSetPayloadSchema),
|
|
154
|
+
defineCommand('thread.spam.set', 'REQUIRED', threadSpamSetPayloadSchema),
|
|
155
|
+
defineCommand('thread.trash.set', 'REQUIRED', threadTrashSetPayloadSchema),
|
|
156
|
+
],
|
|
157
|
+
};
|
|
158
|
+
export const appwriteCommandGroups = {
|
|
159
|
+
account: Object.freeze(commandDefinitions.account.map(({ commandKind }) => commandKind)),
|
|
160
|
+
draft: Object.freeze(commandDefinitions.draft.map(({ commandKind }) => commandKind)),
|
|
161
|
+
draftSend: Object.freeze(commandDefinitions.draftSend.map(({ commandKind }) => commandKind)),
|
|
162
|
+
label: Object.freeze(commandDefinitions.label.map(({ commandKind }) => commandKind)),
|
|
163
|
+
profileAvatar: Object.freeze(commandDefinitions.profileAvatar.map(({ commandKind }) => commandKind)),
|
|
164
|
+
profileSettings: Object.freeze(commandDefinitions.profileSettings.map(({ commandKind }) => commandKind)),
|
|
165
|
+
thread: Object.freeze(commandDefinitions.thread.map(({ commandKind }) => commandKind)),
|
|
206
166
|
};
|
|
167
|
+
const commandRequestSchemas = Object.values(commandDefinitions).flat();
|
|
207
168
|
const commandErrorSchema = v.strictObject({
|
|
208
169
|
code: v.picklist(commandErrorCodes),
|
|
209
170
|
retryable: v.boolean(),
|
|
210
171
|
});
|
|
172
|
+
const commandResponseEntries = {
|
|
173
|
+
canonicalRevision: v.nullable(nonNegativeIntegerSchema),
|
|
174
|
+
id: commandIdSchema,
|
|
175
|
+
};
|
|
211
176
|
const commandResponseSchemas = [
|
|
212
177
|
v.strictObject({
|
|
213
|
-
|
|
178
|
+
...commandResponseEntries,
|
|
214
179
|
error: v.null_(),
|
|
215
|
-
id: commandIdSchema,
|
|
216
180
|
state: v.literal('ACCEPTED'),
|
|
217
181
|
}),
|
|
218
182
|
v.strictObject({
|
|
219
|
-
|
|
183
|
+
...commandResponseEntries,
|
|
220
184
|
error: v.null_(),
|
|
221
|
-
id: commandIdSchema,
|
|
222
185
|
state: v.literal('RUNNING'),
|
|
223
186
|
}),
|
|
224
187
|
v.strictObject({
|
|
225
|
-
|
|
188
|
+
...commandResponseEntries,
|
|
226
189
|
error: v.null_(),
|
|
227
|
-
id: commandIdSchema,
|
|
228
190
|
state: v.literal('SUCCEEDED'),
|
|
229
191
|
}),
|
|
230
192
|
v.strictObject({
|
|
231
|
-
|
|
193
|
+
...commandResponseEntries,
|
|
232
194
|
error: commandErrorSchema,
|
|
233
|
-
id: commandIdSchema,
|
|
234
195
|
state: v.literal('FAILED'),
|
|
235
196
|
}),
|
|
236
197
|
];
|
|
@@ -238,8 +199,8 @@ export const appwriteCommands = {
|
|
|
238
199
|
errorCodes: commandErrorCodes,
|
|
239
200
|
errorSchema: commandErrorSchema,
|
|
240
201
|
idSchema: commandIdSchema,
|
|
241
|
-
kinds: Object.values(appwriteCommandGroups).flat(),
|
|
242
|
-
requestSchema: v.variant('kind',
|
|
202
|
+
kinds: Object.freeze(Object.values(appwriteCommandGroups).flat()),
|
|
203
|
+
requestSchema: v.variant('kind', commandRequestSchemas),
|
|
243
204
|
responseSchema: v.variant('state', commandResponseSchemas),
|
|
244
205
|
states: commandStates,
|
|
245
206
|
threadCommandBatchSize: appwriteThreadCommandBatchSize,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
1
|
+
import { describe, expect, expectTypeOf, it } from 'bun:test';
|
|
2
2
|
import * as v from 'valibot';
|
|
3
3
|
import { appwriteCommandGroups as rootCommandGroups } from '../index';
|
|
4
4
|
import { appwriteAvatar, appwriteCommandGroups, appwriteCommands } from './commands';
|
|
@@ -296,13 +296,48 @@ describe('appwriteCommands', () => {
|
|
|
296
296
|
const groupedKinds = Object.values(appwriteCommandGroups).flat();
|
|
297
297
|
const fixtureKinds = commandFixtures.map(({ command }) => command.kind);
|
|
298
298
|
expect(Object.keys(appwriteCommandGroups)).toEqual(['account', 'draft', 'draftSend', 'label', 'profileAvatar', 'profileSettings', 'thread']);
|
|
299
|
+
expect(appwriteCommandGroups).toEqual({
|
|
300
|
+
account: ['account.delete', 'account.settings.set', 'alias.create', 'alias.delete', 'alias.name.set', 'alias.primary.set', 'alias.signature.set'],
|
|
301
|
+
draft: ['draft.attachment.delete', 'draft.attachment.link', 'draft.content.set', 'draft.create', 'draft.delete', 'draft.envelope.set', 'draft.from.set'],
|
|
302
|
+
draftSend: ['draft.send', 'draft.send.cancel', 'draft.send.schedule'],
|
|
303
|
+
label: ['label.create', 'label.delete', 'label.rename'],
|
|
304
|
+
profileAvatar: ['profile.avatar.set'],
|
|
305
|
+
profileSettings: ['profile.settings.set'],
|
|
306
|
+
thread: [
|
|
307
|
+
'thread.archive.set',
|
|
308
|
+
'thread.delete',
|
|
309
|
+
'thread.flagged.set',
|
|
310
|
+
'thread.label.add',
|
|
311
|
+
'thread.label.remove',
|
|
312
|
+
'thread.seen.set',
|
|
313
|
+
'thread.snooze.set',
|
|
314
|
+
'thread.spam.set',
|
|
315
|
+
'thread.trash.set',
|
|
316
|
+
],
|
|
317
|
+
});
|
|
299
318
|
expect(groupedKinds).toHaveLength(31);
|
|
300
319
|
expect(new Set(groupedKinds).size).toBe(31);
|
|
301
320
|
expect(groupedKinds).toEqual([...appwriteCommands.kinds]);
|
|
321
|
+
expect(Object.values(appwriteCommandGroups).every(Object.isFrozen)).toBe(true);
|
|
322
|
+
expect(Object.isFrozen(appwriteCommands.kinds)).toBe(true);
|
|
302
323
|
expect(Array.from(new Set(fixtureKinds)).sort()).toEqual(Array.from(new Set(appwriteCommands.kinds)).sort());
|
|
303
324
|
expect(appwriteIndexCommandGroups).toBe(appwriteCommandGroups);
|
|
304
325
|
expect(rootCommandGroups).toBe(appwriteCommandGroups);
|
|
305
326
|
});
|
|
327
|
+
it('preserves group-specific command and payload inference', () => {
|
|
328
|
+
expectTypeOf().toEqualTypeOf();
|
|
329
|
+
expectTypeOf().toEqualTypeOf();
|
|
330
|
+
expectTypeOf().toEqualTypeOf();
|
|
331
|
+
expectTypeOf().toEqualTypeOf();
|
|
332
|
+
expectTypeOf().toEqualTypeOf();
|
|
333
|
+
});
|
|
334
|
+
it('enforces each command account scope', () => {
|
|
335
|
+
const nullableKinds = new Set([...appwriteCommandGroups.profileAvatar, ...appwriteCommandGroups.profileSettings]);
|
|
336
|
+
for (const { command } of commandFixtures) {
|
|
337
|
+
expect(v.safeParse(appwriteCommands.requestSchema, { ...command, accountId: 'account_1' }).success).toBe(true);
|
|
338
|
+
expect(v.safeParse(appwriteCommands.requestSchema, { ...command, accountId: null }).success).toBe(nullableKinds.has(command.kind));
|
|
339
|
+
}
|
|
340
|
+
});
|
|
306
341
|
it('derives a command-scoped avatar file ID within Appwrite limits', () => {
|
|
307
342
|
expect(appwriteAvatar.createFileId(commandMetadata.id)).toBe(commandMetadata.id);
|
|
308
343
|
expect(appwriteAvatar.createFileId('0197f3d4-1b22-7abc-8def-123456789abd')).not.toBe(appwriteAvatar.createFileId(commandMetadata.id));
|