@directus/extensions-registry 1.0.0

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.
@@ -0,0 +1,657 @@
1
+ import { ExtensionType } from '@directus/extensions';
2
+ import { z } from 'zod';
3
+
4
+ interface AccountOptions {
5
+ registry?: string;
6
+ }
7
+
8
+ declare const RegistryAccountResponse: z.ZodObject<{
9
+ data: z.ZodObject<{
10
+ id: z.ZodString;
11
+ username: z.ZodString;
12
+ verified: z.ZodBoolean;
13
+ github_username: z.ZodNullable<z.ZodString>;
14
+ github_avatar_url: z.ZodNullable<z.ZodString>;
15
+ github_name: z.ZodNullable<z.ZodString>;
16
+ github_company: z.ZodNullable<z.ZodString>;
17
+ github_blog: z.ZodNullable<z.ZodString>;
18
+ github_location: z.ZodNullable<z.ZodString>;
19
+ github_bio: z.ZodNullable<z.ZodString>;
20
+ }, "strip", z.ZodTypeAny, {
21
+ id: string;
22
+ username: string;
23
+ verified: boolean;
24
+ github_username: string | null;
25
+ github_avatar_url: string | null;
26
+ github_name: string | null;
27
+ github_company: string | null;
28
+ github_blog: string | null;
29
+ github_location: string | null;
30
+ github_bio: string | null;
31
+ }, {
32
+ id: string;
33
+ username: string;
34
+ verified: boolean;
35
+ github_username: string | null;
36
+ github_avatar_url: string | null;
37
+ github_name: string | null;
38
+ github_company: string | null;
39
+ github_blog: string | null;
40
+ github_location: string | null;
41
+ github_bio: string | null;
42
+ }>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ data: {
45
+ id: string;
46
+ username: string;
47
+ verified: boolean;
48
+ github_username: string | null;
49
+ github_avatar_url: string | null;
50
+ github_name: string | null;
51
+ github_company: string | null;
52
+ github_blog: string | null;
53
+ github_location: string | null;
54
+ github_bio: string | null;
55
+ };
56
+ }, {
57
+ data: {
58
+ id: string;
59
+ username: string;
60
+ verified: boolean;
61
+ github_username: string | null;
62
+ github_avatar_url: string | null;
63
+ github_name: string | null;
64
+ github_company: string | null;
65
+ github_blog: string | null;
66
+ github_location: string | null;
67
+ github_bio: string | null;
68
+ };
69
+ }>;
70
+ type RegistryAccountResponse = z.infer<typeof RegistryAccountResponse>;
71
+
72
+ declare const account: (id: string, options?: AccountOptions) => Promise<{
73
+ data: {
74
+ id: string;
75
+ username: string;
76
+ verified: boolean;
77
+ github_username: string | null;
78
+ github_avatar_url: string | null;
79
+ github_name: string | null;
80
+ github_company: string | null;
81
+ github_blog: string | null;
82
+ github_location: string | null;
83
+ github_bio: string | null;
84
+ };
85
+ }>;
86
+
87
+ interface DescribeOptions {
88
+ registry?: string;
89
+ }
90
+
91
+ declare const RegistryDescribeResponse: z.ZodObject<{
92
+ data: z.ZodObject<{
93
+ id: z.ZodString;
94
+ name: z.ZodString;
95
+ description: z.ZodUnion<[z.ZodNull, z.ZodString]>;
96
+ total_downloads: z.ZodNumber;
97
+ downloads: z.ZodUnion<[z.ZodNull, z.ZodArray<z.ZodObject<{
98
+ date: z.ZodString;
99
+ count: z.ZodNumber;
100
+ }, "strip", z.ZodTypeAny, {
101
+ date: string;
102
+ count: number;
103
+ }, {
104
+ date: string;
105
+ count: number;
106
+ }>, "many">]>;
107
+ verified: z.ZodBoolean;
108
+ readme: z.ZodUnion<[z.ZodNull, z.ZodString]>;
109
+ type: z.ZodEnum<["interface", "display", "layout", "module", "panel", "theme", "hook", "endpoint", "operation", "bundle"]>;
110
+ license: z.ZodNullable<z.ZodString>;
111
+ versions: z.ZodArray<z.ZodObject<{
112
+ id: z.ZodString;
113
+ version: z.ZodString;
114
+ verified: z.ZodBoolean;
115
+ type: z.ZodEnum<["interface", "display", "layout", "module", "panel", "theme", "hook", "endpoint", "operation", "bundle"]>;
116
+ host_version: z.ZodString;
117
+ publish_date: z.ZodString;
118
+ unpacked_size: z.ZodNumber;
119
+ file_count: z.ZodNumber;
120
+ url_bugs: z.ZodUnion<[z.ZodNull, z.ZodString]>;
121
+ url_homepage: z.ZodUnion<[z.ZodNull, z.ZodString]>;
122
+ url_repository: z.ZodUnion<[z.ZodNull, z.ZodString]>;
123
+ license: z.ZodNullable<z.ZodString>;
124
+ publisher: z.ZodObject<{
125
+ id: z.ZodString;
126
+ username: z.ZodString;
127
+ verified: z.ZodBoolean;
128
+ github_name: z.ZodNullable<z.ZodString>;
129
+ github_avatar_url: z.ZodNullable<z.ZodString>;
130
+ }, "strip", z.ZodTypeAny, {
131
+ id: string;
132
+ username: string;
133
+ verified: boolean;
134
+ github_avatar_url: string | null;
135
+ github_name: string | null;
136
+ }, {
137
+ id: string;
138
+ username: string;
139
+ verified: boolean;
140
+ github_avatar_url: string | null;
141
+ github_name: string | null;
142
+ }>;
143
+ bundled: z.ZodArray<z.ZodObject<{
144
+ name: z.ZodString;
145
+ type: z.ZodString;
146
+ }, "strip", z.ZodTypeAny, {
147
+ type: string;
148
+ name: string;
149
+ }, {
150
+ type: string;
151
+ name: string;
152
+ }>, "many">;
153
+ maintainers: z.ZodNullable<z.ZodArray<z.ZodObject<{
154
+ accounts_id: z.ZodObject<{
155
+ id: z.ZodString;
156
+ username: z.ZodString;
157
+ verified: z.ZodBoolean;
158
+ github_name: z.ZodNullable<z.ZodString>;
159
+ github_avatar_url: z.ZodNullable<z.ZodString>;
160
+ }, "strip", z.ZodTypeAny, {
161
+ id: string;
162
+ username: string;
163
+ verified: boolean;
164
+ github_avatar_url: string | null;
165
+ github_name: string | null;
166
+ }, {
167
+ id: string;
168
+ username: string;
169
+ verified: boolean;
170
+ github_avatar_url: string | null;
171
+ github_name: string | null;
172
+ }>;
173
+ }, "strip", z.ZodTypeAny, {
174
+ accounts_id: {
175
+ id: string;
176
+ username: string;
177
+ verified: boolean;
178
+ github_avatar_url: string | null;
179
+ github_name: string | null;
180
+ };
181
+ }, {
182
+ accounts_id: {
183
+ id: string;
184
+ username: string;
185
+ verified: boolean;
186
+ github_avatar_url: string | null;
187
+ github_name: string | null;
188
+ };
189
+ }>, "many">>;
190
+ }, "strip", z.ZodTypeAny, {
191
+ version: string;
192
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
193
+ id: string;
194
+ verified: boolean;
195
+ license: string | null;
196
+ host_version: string;
197
+ publish_date: string;
198
+ unpacked_size: number;
199
+ file_count: number;
200
+ url_bugs: string | null;
201
+ url_homepage: string | null;
202
+ url_repository: string | null;
203
+ publisher: {
204
+ id: string;
205
+ username: string;
206
+ verified: boolean;
207
+ github_avatar_url: string | null;
208
+ github_name: string | null;
209
+ };
210
+ bundled: {
211
+ type: string;
212
+ name: string;
213
+ }[];
214
+ maintainers: {
215
+ accounts_id: {
216
+ id: string;
217
+ username: string;
218
+ verified: boolean;
219
+ github_avatar_url: string | null;
220
+ github_name: string | null;
221
+ };
222
+ }[] | null;
223
+ }, {
224
+ version: string;
225
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
226
+ id: string;
227
+ verified: boolean;
228
+ license: string | null;
229
+ host_version: string;
230
+ publish_date: string;
231
+ unpacked_size: number;
232
+ file_count: number;
233
+ url_bugs: string | null;
234
+ url_homepage: string | null;
235
+ url_repository: string | null;
236
+ publisher: {
237
+ id: string;
238
+ username: string;
239
+ verified: boolean;
240
+ github_avatar_url: string | null;
241
+ github_name: string | null;
242
+ };
243
+ bundled: {
244
+ type: string;
245
+ name: string;
246
+ }[];
247
+ maintainers: {
248
+ accounts_id: {
249
+ id: string;
250
+ username: string;
251
+ verified: boolean;
252
+ github_avatar_url: string | null;
253
+ github_name: string | null;
254
+ };
255
+ }[] | null;
256
+ }>, "many">;
257
+ }, "strip", z.ZodTypeAny, {
258
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
259
+ id: string;
260
+ verified: boolean;
261
+ name: string;
262
+ description: string | null;
263
+ total_downloads: number;
264
+ downloads: {
265
+ date: string;
266
+ count: number;
267
+ }[] | null;
268
+ readme: string | null;
269
+ license: string | null;
270
+ versions: {
271
+ version: string;
272
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
273
+ id: string;
274
+ verified: boolean;
275
+ license: string | null;
276
+ host_version: string;
277
+ publish_date: string;
278
+ unpacked_size: number;
279
+ file_count: number;
280
+ url_bugs: string | null;
281
+ url_homepage: string | null;
282
+ url_repository: string | null;
283
+ publisher: {
284
+ id: string;
285
+ username: string;
286
+ verified: boolean;
287
+ github_avatar_url: string | null;
288
+ github_name: string | null;
289
+ };
290
+ bundled: {
291
+ type: string;
292
+ name: string;
293
+ }[];
294
+ maintainers: {
295
+ accounts_id: {
296
+ id: string;
297
+ username: string;
298
+ verified: boolean;
299
+ github_avatar_url: string | null;
300
+ github_name: string | null;
301
+ };
302
+ }[] | null;
303
+ }[];
304
+ }, {
305
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
306
+ id: string;
307
+ verified: boolean;
308
+ name: string;
309
+ description: string | null;
310
+ total_downloads: number;
311
+ downloads: {
312
+ date: string;
313
+ count: number;
314
+ }[] | null;
315
+ readme: string | null;
316
+ license: string | null;
317
+ versions: {
318
+ version: string;
319
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
320
+ id: string;
321
+ verified: boolean;
322
+ license: string | null;
323
+ host_version: string;
324
+ publish_date: string;
325
+ unpacked_size: number;
326
+ file_count: number;
327
+ url_bugs: string | null;
328
+ url_homepage: string | null;
329
+ url_repository: string | null;
330
+ publisher: {
331
+ id: string;
332
+ username: string;
333
+ verified: boolean;
334
+ github_avatar_url: string | null;
335
+ github_name: string | null;
336
+ };
337
+ bundled: {
338
+ type: string;
339
+ name: string;
340
+ }[];
341
+ maintainers: {
342
+ accounts_id: {
343
+ id: string;
344
+ username: string;
345
+ verified: boolean;
346
+ github_avatar_url: string | null;
347
+ github_name: string | null;
348
+ };
349
+ }[] | null;
350
+ }[];
351
+ }>;
352
+ }, "strip", z.ZodTypeAny, {
353
+ data: {
354
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
355
+ id: string;
356
+ verified: boolean;
357
+ name: string;
358
+ description: string | null;
359
+ total_downloads: number;
360
+ downloads: {
361
+ date: string;
362
+ count: number;
363
+ }[] | null;
364
+ readme: string | null;
365
+ license: string | null;
366
+ versions: {
367
+ version: string;
368
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
369
+ id: string;
370
+ verified: boolean;
371
+ license: string | null;
372
+ host_version: string;
373
+ publish_date: string;
374
+ unpacked_size: number;
375
+ file_count: number;
376
+ url_bugs: string | null;
377
+ url_homepage: string | null;
378
+ url_repository: string | null;
379
+ publisher: {
380
+ id: string;
381
+ username: string;
382
+ verified: boolean;
383
+ github_avatar_url: string | null;
384
+ github_name: string | null;
385
+ };
386
+ bundled: {
387
+ type: string;
388
+ name: string;
389
+ }[];
390
+ maintainers: {
391
+ accounts_id: {
392
+ id: string;
393
+ username: string;
394
+ verified: boolean;
395
+ github_avatar_url: string | null;
396
+ github_name: string | null;
397
+ };
398
+ }[] | null;
399
+ }[];
400
+ };
401
+ }, {
402
+ data: {
403
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
404
+ id: string;
405
+ verified: boolean;
406
+ name: string;
407
+ description: string | null;
408
+ total_downloads: number;
409
+ downloads: {
410
+ date: string;
411
+ count: number;
412
+ }[] | null;
413
+ readme: string | null;
414
+ license: string | null;
415
+ versions: {
416
+ version: string;
417
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
418
+ id: string;
419
+ verified: boolean;
420
+ license: string | null;
421
+ host_version: string;
422
+ publish_date: string;
423
+ unpacked_size: number;
424
+ file_count: number;
425
+ url_bugs: string | null;
426
+ url_homepage: string | null;
427
+ url_repository: string | null;
428
+ publisher: {
429
+ id: string;
430
+ username: string;
431
+ verified: boolean;
432
+ github_avatar_url: string | null;
433
+ github_name: string | null;
434
+ };
435
+ bundled: {
436
+ type: string;
437
+ name: string;
438
+ }[];
439
+ maintainers: {
440
+ accounts_id: {
441
+ id: string;
442
+ username: string;
443
+ verified: boolean;
444
+ github_avatar_url: string | null;
445
+ github_name: string | null;
446
+ };
447
+ }[] | null;
448
+ }[];
449
+ };
450
+ }>;
451
+ type RegistryDescribeResponse = z.infer<typeof RegistryDescribeResponse>;
452
+
453
+ declare const describe: (id: string, options?: DescribeOptions) => Promise<{
454
+ data: {
455
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
456
+ id: string;
457
+ verified: boolean;
458
+ name: string;
459
+ description: string | null;
460
+ total_downloads: number;
461
+ downloads: {
462
+ date: string;
463
+ count: number;
464
+ }[] | null;
465
+ readme: string | null;
466
+ license: string | null;
467
+ versions: {
468
+ version: string;
469
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
470
+ id: string;
471
+ verified: boolean;
472
+ license: string | null;
473
+ host_version: string;
474
+ publish_date: string;
475
+ unpacked_size: number;
476
+ file_count: number;
477
+ url_bugs: string | null;
478
+ url_homepage: string | null;
479
+ url_repository: string | null;
480
+ publisher: {
481
+ id: string;
482
+ username: string;
483
+ verified: boolean;
484
+ github_avatar_url: string | null;
485
+ github_name: string | null;
486
+ };
487
+ bundled: {
488
+ type: string;
489
+ name: string;
490
+ }[];
491
+ maintainers: {
492
+ accounts_id: {
493
+ id: string;
494
+ username: string;
495
+ verified: boolean;
496
+ github_avatar_url: string | null;
497
+ github_name: string | null;
498
+ };
499
+ }[] | null;
500
+ }[];
501
+ };
502
+ }>;
503
+
504
+ interface DownloadOptions {
505
+ registry?: string;
506
+ }
507
+
508
+ declare const download: (versionId: string, requireSandbox?: boolean, options?: DownloadOptions) => Promise<ReadableStream<Uint8Array> | null>;
509
+
510
+ interface ListOptions {
511
+ registry?: string;
512
+ }
513
+
514
+ interface ListQuery {
515
+ type?: ExtensionType;
516
+ search?: string;
517
+ limit?: number;
518
+ offset?: number;
519
+ by?: string;
520
+ sort?: 'popular' | 'recent' | 'downloads';
521
+ sandbox?: boolean;
522
+ }
523
+
524
+ declare const RegistryListResponse: z.ZodObject<{
525
+ meta: z.ZodObject<{
526
+ filter_count: z.ZodNumber;
527
+ }, "strip", z.ZodTypeAny, {
528
+ filter_count: number;
529
+ }, {
530
+ filter_count: number;
531
+ }>;
532
+ data: z.ZodArray<z.ZodObject<{
533
+ id: z.ZodString;
534
+ name: z.ZodString;
535
+ description: z.ZodUnion<[z.ZodNull, z.ZodString]>;
536
+ total_downloads: z.ZodNumber;
537
+ verified: z.ZodBoolean;
538
+ type: z.ZodEnum<["interface", "display", "layout", "module", "panel", "theme", "hook", "endpoint", "operation", "bundle"]>;
539
+ last_updated: z.ZodString;
540
+ host_version: z.ZodString;
541
+ sandbox: z.ZodBoolean;
542
+ license: z.ZodNullable<z.ZodString>;
543
+ publisher: z.ZodObject<{
544
+ username: z.ZodString;
545
+ verified: z.ZodBoolean;
546
+ github_name: z.ZodNullable<z.ZodString>;
547
+ }, "strip", z.ZodTypeAny, {
548
+ username: string;
549
+ verified: boolean;
550
+ github_name: string | null;
551
+ }, {
552
+ username: string;
553
+ verified: boolean;
554
+ github_name: string | null;
555
+ }>;
556
+ }, "strip", z.ZodTypeAny, {
557
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
558
+ id: string;
559
+ verified: boolean;
560
+ name: string;
561
+ description: string | null;
562
+ total_downloads: number;
563
+ license: string | null;
564
+ host_version: string;
565
+ publisher: {
566
+ username: string;
567
+ verified: boolean;
568
+ github_name: string | null;
569
+ };
570
+ sandbox: boolean;
571
+ last_updated: string;
572
+ }, {
573
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
574
+ id: string;
575
+ verified: boolean;
576
+ name: string;
577
+ description: string | null;
578
+ total_downloads: number;
579
+ license: string | null;
580
+ host_version: string;
581
+ publisher: {
582
+ username: string;
583
+ verified: boolean;
584
+ github_name: string | null;
585
+ };
586
+ sandbox: boolean;
587
+ last_updated: string;
588
+ }>, "many">;
589
+ }, "strip", z.ZodTypeAny, {
590
+ data: {
591
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
592
+ id: string;
593
+ verified: boolean;
594
+ name: string;
595
+ description: string | null;
596
+ total_downloads: number;
597
+ license: string | null;
598
+ host_version: string;
599
+ publisher: {
600
+ username: string;
601
+ verified: boolean;
602
+ github_name: string | null;
603
+ };
604
+ sandbox: boolean;
605
+ last_updated: string;
606
+ }[];
607
+ meta: {
608
+ filter_count: number;
609
+ };
610
+ }, {
611
+ data: {
612
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
613
+ id: string;
614
+ verified: boolean;
615
+ name: string;
616
+ description: string | null;
617
+ total_downloads: number;
618
+ license: string | null;
619
+ host_version: string;
620
+ publisher: {
621
+ username: string;
622
+ verified: boolean;
623
+ github_name: string | null;
624
+ };
625
+ sandbox: boolean;
626
+ last_updated: string;
627
+ }[];
628
+ meta: {
629
+ filter_count: number;
630
+ };
631
+ }>;
632
+ type RegistryListResponse = z.infer<typeof RegistryListResponse>;
633
+
634
+ declare const list: (query: ListQuery, options?: ListOptions) => Promise<{
635
+ data: {
636
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
637
+ id: string;
638
+ verified: boolean;
639
+ name: string;
640
+ description: string | null;
641
+ total_downloads: number;
642
+ license: string | null;
643
+ host_version: string;
644
+ publisher: {
645
+ username: string;
646
+ verified: boolean;
647
+ github_name: string | null;
648
+ };
649
+ sandbox: boolean;
650
+ last_updated: string;
651
+ }[];
652
+ meta: {
653
+ filter_count: number;
654
+ };
655
+ }>;
656
+
657
+ export { type AccountOptions, type DescribeOptions, type DownloadOptions, type ListOptions, type ListQuery, RegistryAccountResponse, RegistryDescribeResponse, RegistryListResponse, account, describe, download, list };
package/dist/index.js ADDED
@@ -0,0 +1,249 @@
1
+ // src/modules/account/account.ts
2
+ import ky2 from "ky";
3
+
4
+ // src/utils/assert-version-compatibility.ts
5
+ import { OutOfDateError } from "@directus/errors";
6
+
7
+ // src/constants.ts
8
+ var DEFAULT_REGISTRY = "https://registry.directus.io";
9
+ var SUPPORTED_VERSION = "2024-01-29";
10
+
11
+ // src/utils/get-api-version.ts
12
+ import ky from "ky";
13
+
14
+ // src/schemas/registry-version-response.ts
15
+ import { z } from "zod";
16
+ var RegistryVersionResponse = z.object({
17
+ version: z.string()
18
+ });
19
+
20
+ // src/utils/get-api-version.ts
21
+ var _cache = /* @__PURE__ */ new Map();
22
+ var getApiVersion = async (options) => {
23
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
24
+ if (_cache.has(registry)) {
25
+ return _cache.get(registry);
26
+ }
27
+ const response = await ky.get(new URL("/version", registry)).json();
28
+ const { version } = await RegistryVersionResponse.parseAsync(response);
29
+ _cache.set(registry, version);
30
+ setTimeout(() => _cache.delete(registry), 6 * 60 * 60 * 1e3);
31
+ return _cache.get(registry);
32
+ };
33
+
34
+ // src/utils/assert-version-compatibility.ts
35
+ var assertVersionCompatibility = async (options) => {
36
+ const version = await getApiVersion(options);
37
+ if (version !== SUPPORTED_VERSION) {
38
+ throw new OutOfDateError();
39
+ }
40
+ };
41
+
42
+ // src/modules/account/lib/construct-url.ts
43
+ var constructUrl = (id, options) => {
44
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
45
+ const url = new URL(`/accounts/${id}`, registry);
46
+ return url;
47
+ };
48
+
49
+ // src/modules/account/schemas/registry-account-response.ts
50
+ import { z as z2 } from "zod";
51
+ var RegistryAccountResponse = z2.object({
52
+ data: z2.object({
53
+ id: z2.string(),
54
+ username: z2.string(),
55
+ verified: z2.boolean(),
56
+ github_username: z2.string().nullable(),
57
+ github_avatar_url: z2.string().nullable(),
58
+ github_name: z2.string().nullable(),
59
+ github_company: z2.string().nullable(),
60
+ github_blog: z2.string().nullable(),
61
+ github_location: z2.string().nullable(),
62
+ github_bio: z2.string().nullable()
63
+ })
64
+ });
65
+
66
+ // src/modules/account/account.ts
67
+ var account = async (id, options) => {
68
+ await assertVersionCompatibility(options);
69
+ const url = constructUrl(id, options);
70
+ const response = await ky2.get(url).json();
71
+ return await RegistryAccountResponse.parseAsync(response);
72
+ };
73
+
74
+ // src/modules/describe/describe.ts
75
+ import ky3 from "ky";
76
+
77
+ // src/modules/describe/lib/construct-url.ts
78
+ var constructUrl2 = (id, options) => {
79
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
80
+ const url = new URL(`/extensions/${id}`, registry);
81
+ return url;
82
+ };
83
+
84
+ // src/modules/describe/schemas/registry-describe-response.ts
85
+ import { EXTENSION_TYPES } from "@directus/extensions";
86
+ import { z as z3 } from "zod";
87
+ var RegistryDescribeResponse = z3.object({
88
+ data: z3.object({
89
+ id: z3.string(),
90
+ name: z3.string(),
91
+ description: z3.union([z3.null(), z3.string()]),
92
+ total_downloads: z3.number(),
93
+ downloads: z3.union([
94
+ z3.null(),
95
+ z3.array(
96
+ z3.object({
97
+ date: z3.string(),
98
+ count: z3.number()
99
+ })
100
+ )
101
+ ]),
102
+ verified: z3.boolean(),
103
+ readme: z3.union([z3.null(), z3.string()]),
104
+ type: z3.enum(EXTENSION_TYPES),
105
+ license: z3.string().nullable(),
106
+ versions: z3.array(
107
+ z3.object({
108
+ id: z3.string(),
109
+ version: z3.string(),
110
+ verified: z3.boolean(),
111
+ type: z3.enum(EXTENSION_TYPES),
112
+ host_version: z3.string(),
113
+ publish_date: z3.string(),
114
+ unpacked_size: z3.number(),
115
+ file_count: z3.number(),
116
+ url_bugs: z3.union([z3.null(), z3.string()]),
117
+ url_homepage: z3.union([z3.null(), z3.string()]),
118
+ url_repository: z3.union([z3.null(), z3.string()]),
119
+ license: z3.string().nullable(),
120
+ publisher: z3.object({
121
+ id: z3.string(),
122
+ username: z3.string(),
123
+ verified: z3.boolean(),
124
+ github_name: z3.string().nullable(),
125
+ github_avatar_url: z3.string().nullable()
126
+ }),
127
+ bundled: z3.array(
128
+ z3.object({
129
+ name: z3.string(),
130
+ type: z3.string()
131
+ })
132
+ ),
133
+ maintainers: z3.array(
134
+ z3.object({
135
+ accounts_id: z3.object({
136
+ id: z3.string(),
137
+ username: z3.string(),
138
+ verified: z3.boolean(),
139
+ github_name: z3.string().nullable(),
140
+ github_avatar_url: z3.string().nullable()
141
+ })
142
+ })
143
+ ).nullable()
144
+ })
145
+ )
146
+ })
147
+ });
148
+
149
+ // src/modules/describe/describe.ts
150
+ var describe = async (id, options) => {
151
+ await assertVersionCompatibility(options);
152
+ const url = constructUrl2(id, options);
153
+ const response = await ky3.get(url).json();
154
+ return await RegistryDescribeResponse.parseAsync(response);
155
+ };
156
+
157
+ // src/modules/download/download.ts
158
+ import ky4 from "ky";
159
+
160
+ // src/modules/download/lib/construct-url.ts
161
+ var constructUrl3 = (versionId, requireSandbox = false, options) => {
162
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
163
+ const url = new URL(`/download/${versionId}`, registry);
164
+ if (requireSandbox) {
165
+ url.searchParams.set("sandbox", "true");
166
+ }
167
+ return url;
168
+ };
169
+
170
+ // src/modules/download/download.ts
171
+ var download = async (versionId, requireSandbox = false, options) => {
172
+ await assertVersionCompatibility(options);
173
+ const url = constructUrl3(versionId, requireSandbox, options);
174
+ const response = await ky4.get(url);
175
+ return response.body;
176
+ };
177
+
178
+ // src/modules/list/list.ts
179
+ import ky5 from "ky";
180
+
181
+ // src/modules/list/lib/construct-url.ts
182
+ var constructUrl4 = (query, options) => {
183
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
184
+ const url = new URL("/extensions", registry);
185
+ if (query.search) {
186
+ url.searchParams.set("search", query.search);
187
+ }
188
+ if (query.type) {
189
+ url.searchParams.set("type", query.type);
190
+ }
191
+ if (query.limit) {
192
+ url.searchParams.set("limit", String(query.limit));
193
+ }
194
+ if (query.offset) {
195
+ url.searchParams.set("offset", String(query.offset));
196
+ }
197
+ if (query.by) {
198
+ url.searchParams.set("by", query.by);
199
+ }
200
+ if (query.sort) {
201
+ url.searchParams.set("sort", query.sort);
202
+ }
203
+ if (query.sandbox) {
204
+ url.searchParams.set("sandbox", "true");
205
+ }
206
+ return url;
207
+ };
208
+
209
+ // src/modules/list/schemas/registry-list-response.ts
210
+ import { EXTENSION_TYPES as EXTENSION_TYPES2 } from "@directus/extensions";
211
+ import { z as z4 } from "zod";
212
+ var RegistryListResponse = z4.object({
213
+ meta: z4.object({
214
+ filter_count: z4.number()
215
+ }),
216
+ data: z4.array(
217
+ z4.object({
218
+ id: z4.string(),
219
+ name: z4.string(),
220
+ description: z4.union([z4.null(), z4.string()]),
221
+ total_downloads: z4.number(),
222
+ verified: z4.boolean(),
223
+ type: z4.enum(EXTENSION_TYPES2),
224
+ last_updated: z4.string(),
225
+ host_version: z4.string(),
226
+ sandbox: z4.boolean(),
227
+ license: z4.string().nullable(),
228
+ publisher: z4.object({
229
+ username: z4.string(),
230
+ verified: z4.boolean(),
231
+ github_name: z4.string().nullable()
232
+ })
233
+ })
234
+ )
235
+ });
236
+
237
+ // src/modules/list/list.ts
238
+ var list = async (query, options) => {
239
+ await assertVersionCompatibility(options);
240
+ const url = constructUrl4(query, options);
241
+ const response = await ky5.get(url).json();
242
+ return await RegistryListResponse.parseAsync(response);
243
+ };
244
+ export {
245
+ account,
246
+ describe,
247
+ download,
248
+ list
249
+ };
package/license ADDED
@@ -0,0 +1,16 @@
1
+ MIT License
2
+
3
+ Copyright 2023 Monospace, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6
+ documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
7
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8
+ persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11
+ Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@directus/extensions-registry",
3
+ "version": "1.0.0",
4
+ "description": "Abstraction for exploring Directus extensions on a package registry",
5
+ "homepage": "https://directus.io",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/directus/directus.git",
9
+ "directory": "packages/extensions-registry"
10
+ },
11
+ "funding": "https://github.com/directus/directus?sponsor=1",
12
+ "license": "MIT",
13
+ "author": "Rijk van Zanten <rijkvanzanten@me.com>",
14
+ "type": "module",
15
+ "exports": {
16
+ ".": "./dist/index.js",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "main": "dist/index.js",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "ky": "1.2.2",
25
+ "lodash-es": "4.17.21",
26
+ "validate-npm-package-name": "5.0.0",
27
+ "zod": "3.22.4",
28
+ "@directus/errors": "0.2.4",
29
+ "@directus/extensions": "1.0.0",
30
+ "@directus/utils": "11.0.6"
31
+ },
32
+ "devDependencies": {
33
+ "@types/lodash-es": "4.17.12",
34
+ "@types/validate-npm-package-name": "4.0.2",
35
+ "@vitest/coverage-v8": "1.3.1",
36
+ "tsup": "8.0.1",
37
+ "typescript": "5.3.3",
38
+ "vitest": "1.1.1",
39
+ "@directus/tsconfig": "1.0.1"
40
+ },
41
+ "scripts": {
42
+ "build": "tsup src/index.ts --format=esm --dts",
43
+ "dev": "tsup src/index.ts --format=esm --dts --watch",
44
+ "test": "vitest --watch=false"
45
+ }
46
+ }
package/readme.md ADDED
@@ -0,0 +1,3 @@
1
+ # @directus/extensions-registry
2
+
3
+ Abstraction for exploring Directus extensions on a package registry.