@directus/extensions-registry 3.0.10 → 3.0.12

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 (3) hide show
  1. package/dist/index.d.ts +227 -215
  2. package/dist/index.js +319 -222
  3. package/package.json +11 -11
package/dist/index.d.ts CHANGED
@@ -1,27 +1,30 @@
1
- import * as stream_web from 'stream/web';
2
- import { ExtensionType } from '@directus/types';
3
- import { z } from 'zod';
1
+ import { z } from "zod";
2
+ import * as stream_web0 from "stream/web";
3
+ import { ExtensionType } from "@directus/types";
4
4
 
5
+ //#region src/modules/account/types/account-options.d.ts
5
6
  interface AccountOptions {
6
- registry?: string;
7
+ registry?: string;
7
8
  }
8
-
9
+ //#endregion
10
+ //#region src/modules/account/schemas/registry-account-response.d.ts
9
11
  declare const RegistryAccountResponse: z.ZodObject<{
10
- data: z.ZodObject<{
11
- id: z.ZodString;
12
- username: z.ZodString;
13
- verified: z.ZodBoolean;
14
- github_username: z.ZodNullable<z.ZodString>;
15
- github_avatar_url: z.ZodNullable<z.ZodString>;
16
- github_name: z.ZodNullable<z.ZodString>;
17
- github_company: z.ZodNullable<z.ZodString>;
18
- github_blog: z.ZodNullable<z.ZodString>;
19
- github_location: z.ZodNullable<z.ZodString>;
20
- github_bio: z.ZodNullable<z.ZodString>;
21
- }, z.core.$strip>;
12
+ data: z.ZodObject<{
13
+ id: z.ZodString;
14
+ username: z.ZodString;
15
+ verified: z.ZodBoolean;
16
+ github_username: z.ZodNullable<z.ZodString>;
17
+ github_avatar_url: z.ZodNullable<z.ZodString>;
18
+ github_name: z.ZodNullable<z.ZodString>;
19
+ github_company: z.ZodNullable<z.ZodString>;
20
+ github_blog: z.ZodNullable<z.ZodString>;
21
+ github_location: z.ZodNullable<z.ZodString>;
22
+ github_bio: z.ZodNullable<z.ZodString>;
23
+ }, z.core.$strip>;
22
24
  }, z.core.$strip>;
23
25
  type RegistryAccountResponse = z.infer<typeof RegistryAccountResponse>;
24
-
26
+ //#endregion
27
+ //#region src/modules/account/account.d.ts
25
28
  /**
26
29
  * Retrieves account information from the extensions registry.
27
30
  *
@@ -61,153 +64,158 @@ type RegistryAccountResponse = z.infer<typeof RegistryAccountResponse>;
61
64
  * ```
62
65
  */
63
66
  declare const account: (id: string, options?: AccountOptions) => Promise<{
64
- data: {
65
- id: string;
66
- username: string;
67
- verified: boolean;
68
- github_username: string | null;
69
- github_avatar_url: string | null;
70
- github_name: string | null;
71
- github_company: string | null;
72
- github_blog: string | null;
73
- github_location: string | null;
74
- github_bio: string | null;
75
- };
67
+ data: {
68
+ id: string;
69
+ username: string;
70
+ verified: boolean;
71
+ github_username: string | null;
72
+ github_avatar_url: string | null;
73
+ github_name: string | null;
74
+ github_company: string | null;
75
+ github_blog: string | null;
76
+ github_location: string | null;
77
+ github_bio: string | null;
78
+ };
76
79
  }>;
77
-
80
+ //#endregion
81
+ //#region src/modules/describe/types/describe-options.d.ts
78
82
  interface DescribeOptions {
79
- registry?: string;
83
+ registry?: string;
80
84
  }
81
-
85
+ //#endregion
86
+ //#region src/modules/describe/schemas/registry-describe-response.d.ts
82
87
  declare const RegistryDescribeResponse: z.ZodObject<{
83
- data: z.ZodObject<{
88
+ data: z.ZodObject<{
89
+ id: z.ZodString;
90
+ name: z.ZodString;
91
+ description: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
92
+ total_downloads: z.ZodNumber;
93
+ downloads: z.ZodUnion<readonly [z.ZodNull, z.ZodArray<z.ZodObject<{
94
+ date: z.ZodString;
95
+ count: z.ZodNumber;
96
+ }, z.core.$strip>>]>;
97
+ verified: z.ZodBoolean;
98
+ readme: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
99
+ type: z.ZodEnum<{
100
+ interface: "interface";
101
+ display: "display";
102
+ layout: "layout";
103
+ module: "module";
104
+ panel: "panel";
105
+ theme: "theme";
106
+ hook: "hook";
107
+ endpoint: "endpoint";
108
+ operation: "operation";
109
+ bundle: "bundle";
110
+ }>;
111
+ license: z.ZodNullable<z.ZodString>;
112
+ versions: z.ZodArray<z.ZodObject<{
113
+ id: z.ZodString;
114
+ version: z.ZodString;
115
+ verified: z.ZodBoolean;
116
+ type: z.ZodEnum<{
117
+ interface: "interface";
118
+ display: "display";
119
+ layout: "layout";
120
+ module: "module";
121
+ panel: "panel";
122
+ theme: "theme";
123
+ hook: "hook";
124
+ endpoint: "endpoint";
125
+ operation: "operation";
126
+ bundle: "bundle";
127
+ }>;
128
+ host_version: z.ZodString;
129
+ publish_date: z.ZodString;
130
+ unpacked_size: z.ZodNumber;
131
+ file_count: z.ZodNumber;
132
+ url_bugs: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
133
+ url_homepage: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
134
+ url_repository: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
135
+ license: z.ZodNullable<z.ZodString>;
136
+ publisher: z.ZodObject<{
84
137
  id: z.ZodString;
85
- name: z.ZodString;
86
- description: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
87
- total_downloads: z.ZodNumber;
88
- downloads: z.ZodUnion<readonly [z.ZodNull, z.ZodArray<z.ZodObject<{
89
- date: z.ZodString;
90
- count: z.ZodNumber;
91
- }, z.core.$strip>>]>;
138
+ username: z.ZodString;
92
139
  verified: z.ZodBoolean;
93
- readme: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
94
- type: z.ZodEnum<{
95
- interface: "interface";
96
- display: "display";
97
- layout: "layout";
98
- module: "module";
99
- panel: "panel";
100
- theme: "theme";
101
- hook: "hook";
102
- endpoint: "endpoint";
103
- operation: "operation";
104
- bundle: "bundle";
105
- }>;
106
- license: z.ZodNullable<z.ZodString>;
107
- versions: z.ZodArray<z.ZodObject<{
108
- id: z.ZodString;
109
- version: z.ZodString;
110
- verified: z.ZodBoolean;
111
- type: z.ZodEnum<{
112
- interface: "interface";
113
- display: "display";
114
- layout: "layout";
115
- module: "module";
116
- panel: "panel";
117
- theme: "theme";
118
- hook: "hook";
119
- endpoint: "endpoint";
120
- operation: "operation";
121
- bundle: "bundle";
122
- }>;
123
- host_version: z.ZodString;
124
- publish_date: z.ZodString;
125
- unpacked_size: z.ZodNumber;
126
- file_count: z.ZodNumber;
127
- url_bugs: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
128
- url_homepage: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
129
- url_repository: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
130
- license: z.ZodNullable<z.ZodString>;
131
- publisher: z.ZodObject<{
132
- id: z.ZodString;
133
- username: z.ZodString;
134
- verified: z.ZodBoolean;
135
- github_name: z.ZodNullable<z.ZodString>;
136
- github_avatar_url: z.ZodNullable<z.ZodString>;
137
- }, z.core.$strip>;
138
- bundled: z.ZodArray<z.ZodObject<{
139
- name: z.ZodString;
140
- type: z.ZodString;
141
- }, z.core.$strip>>;
142
- maintainers: z.ZodNullable<z.ZodArray<z.ZodObject<{
143
- accounts_id: z.ZodObject<{
144
- id: z.ZodString;
145
- username: z.ZodString;
146
- verified: z.ZodBoolean;
147
- github_name: z.ZodNullable<z.ZodString>;
148
- github_avatar_url: z.ZodNullable<z.ZodString>;
149
- }, z.core.$strip>;
150
- }, z.core.$strip>>>;
151
- }, z.core.$strip>>;
152
- }, z.core.$strip>;
140
+ github_name: z.ZodNullable<z.ZodString>;
141
+ github_avatar_url: z.ZodNullable<z.ZodString>;
142
+ }, z.core.$strip>;
143
+ bundled: z.ZodArray<z.ZodObject<{
144
+ name: z.ZodString;
145
+ type: z.ZodString;
146
+ }, z.core.$strip>>;
147
+ maintainers: z.ZodNullable<z.ZodArray<z.ZodObject<{
148
+ accounts_id: z.ZodObject<{
149
+ id: z.ZodString;
150
+ username: z.ZodString;
151
+ verified: z.ZodBoolean;
152
+ github_name: z.ZodNullable<z.ZodString>;
153
+ github_avatar_url: z.ZodNullable<z.ZodString>;
154
+ }, z.core.$strip>;
155
+ }, z.core.$strip>>>;
156
+ }, z.core.$strip>>;
157
+ }, z.core.$strip>;
153
158
  }, z.core.$strip>;
154
159
  type RegistryDescribeResponse = z.infer<typeof RegistryDescribeResponse>;
155
-
160
+ //#endregion
161
+ //#region src/modules/describe/describe.d.ts
156
162
  declare const describe: (id: string, options?: DescribeOptions) => Promise<{
157
- data: {
163
+ data: {
164
+ id: string;
165
+ name: string;
166
+ description: string | null;
167
+ total_downloads: number;
168
+ downloads: {
169
+ date: string;
170
+ count: number;
171
+ }[] | null;
172
+ verified: boolean;
173
+ readme: string | null;
174
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
175
+ license: string | null;
176
+ versions: {
177
+ id: string;
178
+ version: string;
179
+ verified: boolean;
180
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
181
+ host_version: string;
182
+ publish_date: string;
183
+ unpacked_size: number;
184
+ file_count: number;
185
+ url_bugs: string | null;
186
+ url_homepage: string | null;
187
+ url_repository: string | null;
188
+ license: string | null;
189
+ publisher: {
158
190
  id: string;
159
- name: string;
160
- description: string | null;
161
- total_downloads: number;
162
- downloads: {
163
- date: string;
164
- count: number;
165
- }[] | null;
191
+ username: string;
166
192
  verified: boolean;
167
- readme: string | null;
168
- type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
169
- license: string | null;
170
- versions: {
171
- id: string;
172
- version: string;
173
- verified: boolean;
174
- type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
175
- host_version: string;
176
- publish_date: string;
177
- unpacked_size: number;
178
- file_count: number;
179
- url_bugs: string | null;
180
- url_homepage: string | null;
181
- url_repository: string | null;
182
- license: string | null;
183
- publisher: {
184
- id: string;
185
- username: string;
186
- verified: boolean;
187
- github_name: string | null;
188
- github_avatar_url: string | null;
189
- };
190
- bundled: {
191
- name: string;
192
- type: string;
193
- }[];
194
- maintainers: {
195
- accounts_id: {
196
- id: string;
197
- username: string;
198
- verified: boolean;
199
- github_name: string | null;
200
- github_avatar_url: string | null;
201
- };
202
- }[] | null;
203
- }[];
204
- };
193
+ github_name: string | null;
194
+ github_avatar_url: string | null;
195
+ };
196
+ bundled: {
197
+ name: string;
198
+ type: string;
199
+ }[];
200
+ maintainers: {
201
+ accounts_id: {
202
+ id: string;
203
+ username: string;
204
+ verified: boolean;
205
+ github_name: string | null;
206
+ github_avatar_url: string | null;
207
+ };
208
+ }[] | null;
209
+ }[];
210
+ };
205
211
  }>;
206
-
212
+ //#endregion
213
+ //#region src/modules/download/types/download-options.d.ts
207
214
  interface DownloadOptions {
208
- registry?: string;
215
+ registry?: string;
209
216
  }
210
-
217
+ //#endregion
218
+ //#region src/modules/download/download.d.ts
211
219
  /**
212
220
  * Downloads an extension version from the registry as a stream.
213
221
  *
@@ -260,78 +268,82 @@ interface DownloadOptions {
260
268
  * }
261
269
  * ```
262
270
  */
263
- declare const download: (versionId: string, requireSandbox?: boolean, options?: DownloadOptions) => Promise<stream_web.ReadableStream<any> | null>;
264
-
271
+ declare const download: (versionId: string, requireSandbox?: boolean, options?: DownloadOptions) => Promise<stream_web0.ReadableStream<any> | null>;
272
+ //#endregion
273
+ //#region src/modules/list/types/list-options.d.ts
265
274
  interface ListOptions {
266
- registry?: string;
275
+ registry?: string;
267
276
  }
268
-
277
+ //#endregion
278
+ //#region src/modules/list/types/list-query.d.ts
269
279
  interface ListQuery {
270
- type?: ExtensionType;
271
- search?: string;
272
- limit?: number;
273
- offset?: number;
274
- by?: string;
275
- sort?: 'popular' | 'recent' | 'downloads';
276
- sandbox?: boolean;
280
+ type?: ExtensionType;
281
+ search?: string;
282
+ limit?: number;
283
+ offset?: number;
284
+ by?: string;
285
+ sort?: 'popular' | 'recent' | 'downloads';
286
+ sandbox?: boolean;
277
287
  }
278
-
288
+ //#endregion
289
+ //#region src/modules/list/schemas/registry-list-response.d.ts
279
290
  declare const RegistryListResponse: z.ZodObject<{
280
- meta: z.ZodObject<{
281
- filter_count: z.ZodNumber;
291
+ meta: z.ZodObject<{
292
+ filter_count: z.ZodNumber;
293
+ }, z.core.$strip>;
294
+ data: z.ZodArray<z.ZodObject<{
295
+ id: z.ZodString;
296
+ name: z.ZodString;
297
+ description: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
298
+ total_downloads: z.ZodNumber;
299
+ verified: z.ZodBoolean;
300
+ type: z.ZodEnum<{
301
+ interface: "interface";
302
+ display: "display";
303
+ layout: "layout";
304
+ module: "module";
305
+ panel: "panel";
306
+ theme: "theme";
307
+ hook: "hook";
308
+ endpoint: "endpoint";
309
+ operation: "operation";
310
+ bundle: "bundle";
311
+ }>;
312
+ last_updated: z.ZodString;
313
+ host_version: z.ZodString;
314
+ sandbox: z.ZodBoolean;
315
+ license: z.ZodNullable<z.ZodString>;
316
+ publisher: z.ZodObject<{
317
+ username: z.ZodString;
318
+ verified: z.ZodBoolean;
319
+ github_name: z.ZodNullable<z.ZodString>;
282
320
  }, z.core.$strip>;
283
- data: z.ZodArray<z.ZodObject<{
284
- id: z.ZodString;
285
- name: z.ZodString;
286
- description: z.ZodUnion<readonly [z.ZodNull, z.ZodString]>;
287
- total_downloads: z.ZodNumber;
288
- verified: z.ZodBoolean;
289
- type: z.ZodEnum<{
290
- interface: "interface";
291
- display: "display";
292
- layout: "layout";
293
- module: "module";
294
- panel: "panel";
295
- theme: "theme";
296
- hook: "hook";
297
- endpoint: "endpoint";
298
- operation: "operation";
299
- bundle: "bundle";
300
- }>;
301
- last_updated: z.ZodString;
302
- host_version: z.ZodString;
303
- sandbox: z.ZodBoolean;
304
- license: z.ZodNullable<z.ZodString>;
305
- publisher: z.ZodObject<{
306
- username: z.ZodString;
307
- verified: z.ZodBoolean;
308
- github_name: z.ZodNullable<z.ZodString>;
309
- }, z.core.$strip>;
310
- }, z.core.$strip>>;
321
+ }, z.core.$strip>>;
311
322
  }, z.core.$strip>;
312
323
  type RegistryListResponse = z.infer<typeof RegistryListResponse>;
313
-
324
+ //#endregion
325
+ //#region src/modules/list/list.d.ts
314
326
  declare const list: (query: ListQuery, options?: ListOptions) => Promise<{
315
- meta: {
316
- filter_count: number;
327
+ meta: {
328
+ filter_count: number;
329
+ };
330
+ data: {
331
+ id: string;
332
+ name: string;
333
+ description: string | null;
334
+ total_downloads: number;
335
+ verified: boolean;
336
+ type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
337
+ last_updated: string;
338
+ host_version: string;
339
+ sandbox: boolean;
340
+ license: string | null;
341
+ publisher: {
342
+ username: string;
343
+ verified: boolean;
344
+ github_name: string | null;
317
345
  };
318
- data: {
319
- id: string;
320
- name: string;
321
- description: string | null;
322
- total_downloads: number;
323
- verified: boolean;
324
- type: "interface" | "display" | "layout" | "module" | "panel" | "theme" | "hook" | "endpoint" | "operation" | "bundle";
325
- last_updated: string;
326
- host_version: string;
327
- sandbox: boolean;
328
- license: string | null;
329
- publisher: {
330
- username: string;
331
- verified: boolean;
332
- github_name: string | null;
333
- };
334
- }[];
346
+ }[];
335
347
  }>;
336
-
337
- export { type AccountOptions, type DescribeOptions, type DownloadOptions, type ListOptions, type ListQuery, RegistryAccountResponse, RegistryDescribeResponse, RegistryListResponse, account, describe, download, list };
348
+ //#endregion
349
+ export { type AccountOptions, type DescribeOptions, type DownloadOptions, type ListOptions, type ListQuery, type RegistryAccountResponse, type RegistryDescribeResponse, type RegistryListResponse, account, describe, download, list };
package/dist/index.js CHANGED
@@ -1,249 +1,346 @@
1
- // src/modules/account/account.ts
2
- import ky2 from "ky";
3
-
4
- // src/utils/assert-version-compatibility.ts
1
+ import ky from "ky";
5
2
  import { OutOfDateError } from "@directus/errors";
3
+ import { z } from "zod";
4
+ import { EXTENSION_TYPES } from "@directus/constants";
6
5
 
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";
6
+ //#region src/constants.ts
7
+ const DEFAULT_REGISTRY = "https://registry.directus.io";
8
+ const SUPPORTED_VERSION = "2024-01-29";
13
9
 
14
- // src/schemas/registry-version-response.ts
15
- import { z } from "zod";
16
- var RegistryVersionResponse = z.object({
17
- version: z.string()
18
- });
10
+ //#endregion
11
+ //#region src/schemas/registry-version-response.ts
12
+ const RegistryVersionResponse = z.object({ version: z.string() });
19
13
 
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);
14
+ //#endregion
15
+ //#region src/utils/get-api-version.ts
16
+ const _cache = /* @__PURE__ */ new Map();
17
+ const getApiVersion = async (options) => {
18
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
19
+ if (_cache.has(registry)) return _cache.get(registry);
20
+ const response = await ky.get(new URL("/version", registry)).json();
21
+ const { version } = await RegistryVersionResponse.parseAsync(response);
22
+ _cache.set(registry, version);
23
+ setTimeout(() => _cache.delete(registry), 360 * 60 * 1e3);
24
+ return _cache.get(registry);
32
25
  };
33
26
 
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
- }
27
+ //#endregion
28
+ //#region src/utils/assert-version-compatibility.ts
29
+ const assertVersionCompatibility = async (options) => {
30
+ /**
31
+ * The Registry API always targets the latest release of Directus. If the current installation is
32
+ * out of date, the registry operations should fail with an instance out-of-date error.
33
+ */
34
+ if (await getApiVersion(options) !== SUPPORTED_VERSION) throw new OutOfDateError();
40
35
  };
41
36
 
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;
37
+ //#endregion
38
+ //#region src/modules/account/lib/construct-url.ts
39
+ /**
40
+ * Constructs a URL for accessing account information in the extensions registry.
41
+ *
42
+ * @param id - The unique identifier of the account to access
43
+ * @param options - Optional configuration object for URL construction
44
+ * @param options.registry - The registry base URL to use (defaults to DEFAULT_REGISTRY if not provided)
45
+ * @returns A URL object pointing to the specified account endpoint
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // Using default registry
50
+ * const url = constructUrl('user123');
51
+ * console.log(url.toString()); // "https://registry.directus.io/accounts/user123"
52
+ *
53
+ * // Using custom registry
54
+ * const customUrl = constructUrl('user456', {
55
+ * registry: 'https://custom-registry.example.com'
56
+ * });
57
+ * console.log(customUrl.toString()); // "https://custom-registry.example.com/accounts/user456"
58
+ * ```
59
+ */
60
+ const constructUrl$3 = (id, options) => {
61
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
62
+ return new URL(`/accounts/${id}`, registry);
47
63
  };
48
64
 
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
+ //#endregion
66
+ //#region src/modules/account/schemas/registry-account-response.ts
67
+ const RegistryAccountResponse = z.object({ data: z.object({
68
+ id: z.string(),
69
+ username: z.string(),
70
+ verified: z.boolean(),
71
+ github_username: z.string().nullable(),
72
+ github_avatar_url: z.string().nullable(),
73
+ github_name: z.string().nullable(),
74
+ github_company: z.string().nullable(),
75
+ github_blog: z.string().nullable(),
76
+ github_location: z.string().nullable(),
77
+ github_bio: z.string().nullable()
78
+ }) });
65
79
 
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);
80
+ //#endregion
81
+ //#region src/modules/account/account.ts
82
+ /**
83
+ * Retrieves account information from the extensions registry.
84
+ *
85
+ * This function fetches detailed account data for a specified user or organization
86
+ * from the Directus extensions registry. It validates API version compatibility
87
+ * and returns structured account information including profile details, published
88
+ * extensions, and other relevant metadata.
89
+ *
90
+ * @param id - The unique identifier of the account to retrieve (username or organization name)
91
+ * @param options - Optional configuration for the request
92
+ * @param options.registry - Custom registry URL to use instead of the default registry
93
+ * @returns Promise that resolves to validated account data from the registry
94
+ *
95
+ * @throws {Error} When API version compatibility check fails
96
+ * @throws {Error} When the account ID is not found in the registry
97
+ * @throws {Error} When network request fails or registry is unreachable
98
+ * @throws {Error} When response data fails validation against the expected schema
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * // Get account information using default registry
103
+ * const accountData = await account('directus');
104
+ * console.log(accountData.name); // Account name
105
+ * console.log(accountData.extensions); // Published extensions
106
+ *
107
+ * // Get account information from custom registry
108
+ * const customAccountData = await account('my-org', {
109
+ * registry: 'https://custom-registry.example.com'
110
+ * });
111
+ *
112
+ * // Handle errors
113
+ * try {
114
+ * const accountData = await account('non-existent-user');
115
+ * } catch (error) {
116
+ * console.error('Failed to fetch account:', error.message);
117
+ * }
118
+ * ```
119
+ */
120
+ const account = async (id, options) => {
121
+ await assertVersionCompatibility(options);
122
+ const url = constructUrl$3(id, options);
123
+ const response = await ky.get(url).json();
124
+ return await RegistryAccountResponse.parseAsync(response);
72
125
  };
73
126
 
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;
127
+ //#endregion
128
+ //#region src/modules/describe/lib/construct-url.ts
129
+ const constructUrl$2 = (id, options) => {
130
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
131
+ return new URL(`/extensions/${id}`, registry);
82
132
  };
83
133
 
84
- // src/modules/describe/schemas/registry-describe-response.ts
85
- import { EXTENSION_TYPES } from "@directus/constants";
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
- });
134
+ //#endregion
135
+ //#region src/modules/describe/schemas/registry-describe-response.ts
136
+ const RegistryDescribeResponse = z.object({ data: z.object({
137
+ id: z.string(),
138
+ name: z.string(),
139
+ description: z.union([z.null(), z.string()]),
140
+ total_downloads: z.number(),
141
+ downloads: z.union([z.null(), z.array(z.object({
142
+ date: z.string(),
143
+ count: z.number()
144
+ }))]),
145
+ verified: z.boolean(),
146
+ readme: z.union([z.null(), z.string()]),
147
+ type: z.enum(EXTENSION_TYPES),
148
+ license: z.string().nullable(),
149
+ versions: z.array(z.object({
150
+ id: z.string(),
151
+ version: z.string(),
152
+ verified: z.boolean(),
153
+ type: z.enum(EXTENSION_TYPES),
154
+ host_version: z.string(),
155
+ publish_date: z.string(),
156
+ unpacked_size: z.number(),
157
+ file_count: z.number(),
158
+ url_bugs: z.union([z.null(), z.string()]),
159
+ url_homepage: z.union([z.null(), z.string()]),
160
+ url_repository: z.union([z.null(), z.string()]),
161
+ license: z.string().nullable(),
162
+ publisher: z.object({
163
+ id: z.string(),
164
+ username: z.string(),
165
+ verified: z.boolean(),
166
+ github_name: z.string().nullable(),
167
+ github_avatar_url: z.string().nullable()
168
+ }),
169
+ bundled: z.array(z.object({
170
+ name: z.string(),
171
+ type: z.string()
172
+ })),
173
+ maintainers: z.array(z.object({ accounts_id: z.object({
174
+ id: z.string(),
175
+ username: z.string(),
176
+ verified: z.boolean(),
177
+ github_name: z.string().nullable(),
178
+ github_avatar_url: z.string().nullable()
179
+ }) })).nullable()
180
+ }))
181
+ }) });
148
182
 
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);
183
+ //#endregion
184
+ //#region src/modules/describe/describe.ts
185
+ const describe = async (id, options) => {
186
+ await assertVersionCompatibility(options);
187
+ const url = constructUrl$2(id, options);
188
+ const response = await ky.get(url).json();
189
+ return await RegistryDescribeResponse.parseAsync(response);
155
190
  };
156
191
 
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;
192
+ //#endregion
193
+ //#region src/modules/download/lib/construct-url.ts
194
+ /**
195
+ * Constructs a download URL for an extension version from the registry.
196
+ *
197
+ * This function creates a properly formatted URL for downloading a specific
198
+ * extension version from the Directus extensions registry. It supports both
199
+ * production downloads and sandbox mode downloads for testing purposes.
200
+ *
201
+ * @param versionId - The unique identifier of the extension version to download
202
+ * @param requireSandbox - Whether to enable sandbox mode for the download (defaults to false)
203
+ * @param options - Optional configuration for the download request
204
+ * @param options.registry - Custom registry URL to use instead of the default registry
205
+ * @returns A URL object pointing to the download endpoint for the specified version
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * // Download from default registry
210
+ * const downloadUrl = constructUrl('extension-v1.0.0');
211
+ * console.log(downloadUrl.href); // 'https://registry.directus.io/download/extension-v1.0.0'
212
+ *
213
+ * // Download with sandbox mode enabled
214
+ * const sandboxUrl = constructUrl('extension-v1.0.0', true);
215
+ * console.log(sandboxUrl.href); // 'https://registry.directus.io/download/extension-v1.0.0?sandbox=true'
216
+ *
217
+ * // Download from custom registry
218
+ * const customUrl = constructUrl('extension-v1.0.0', false, {
219
+ * registry: 'https://custom-registry.example.com'
220
+ * });
221
+ * console.log(customUrl.href); // 'https://custom-registry.example.com/download/extension-v1.0.0'
222
+ *
223
+ * // Combine custom registry with sandbox mode
224
+ * const customSandboxUrl = constructUrl('extension-v1.0.0', true, {
225
+ * registry: 'https://custom-registry.example.com'
226
+ * });
227
+ * console.log(customSandboxUrl.href);
228
+ * // 'https://custom-registry.example.com/download/extension-v1.0.0?sandbox=true'
229
+ * ```
230
+ */
231
+ const constructUrl$1 = (versionId, requireSandbox = false, options) => {
232
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
233
+ const url = new URL(`/download/${versionId}`, registry);
234
+ if (requireSandbox) url.searchParams.set("sandbox", "true");
235
+ return url;
168
236
  };
169
237
 
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;
238
+ //#endregion
239
+ //#region src/modules/download/download.ts
240
+ /**
241
+ * Downloads an extension version from the registry as a stream.
242
+ *
243
+ * This function retrieves the binary content of a specific extension version
244
+ * from the Directus extensions registry. It validates API version compatibility
245
+ * and returns a ReadableStream that can be used to process the downloaded content,
246
+ * such as saving to disk or streaming to a client.
247
+ *
248
+ * @param versionId - The unique identifier of the extension version to download
249
+ * @param requireSandbox - Whether to enable sandbox mode for the download (defaults to false)
250
+ * @param options - Optional configuration for the download request
251
+ * @param options.registry - Custom registry URL to use instead of the default registry
252
+ * @returns Promise that resolves to a ReadableStream containing the extension's binary content
253
+ *
254
+ * @throws {Error} When API version compatibility check fails
255
+ * @throws {Error} When the version ID is not found in the registry
256
+ * @throws {Error} When network request fails or registry is unreachable
257
+ * @throws {Error} When the response status indicates an error (4xx, 5xx)
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * // Download extension from default registry
262
+ * const stream = await download('my-extension-v1.0.0');
263
+ *
264
+ * // Save to file system
265
+ * import { createWriteStream } from 'fs';
266
+ * import { pipeline } from 'stream/promises';
267
+ *
268
+ * const fileStream = createWriteStream('./extension.zip');
269
+ * await pipeline(Readable.fromWeb(stream), fileStream);
270
+ *
271
+ * // Download with sandbox mode enabled
272
+ * const sandboxStream = await download('my-extension-v1.0.0', true);
273
+ *
274
+ * // Download from custom registry
275
+ * const customStream = await download('my-extension-v1.0.0', false, {
276
+ * registry: 'https://custom-registry.example.com'
277
+ * });
278
+ *
279
+ * // Download with both sandbox and custom registry
280
+ * const customSandboxStream = await download('my-extension-v1.0.0', true, {
281
+ * registry: 'https://custom-registry.example.com'
282
+ * });
283
+ *
284
+ * // Handle errors
285
+ * try {
286
+ * const stream = await download('non-existent-version');
287
+ * } catch (error) {
288
+ * console.error('Download failed:', error.message);
289
+ * }
290
+ * ```
291
+ */
292
+ const download = async (versionId, requireSandbox = false, options) => {
293
+ await assertVersionCompatibility(options);
294
+ const url = constructUrl$1(versionId, requireSandbox, options);
295
+ return (await ky.get(url)).body;
176
296
  };
177
297
 
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;
298
+ //#endregion
299
+ //#region src/modules/list/lib/construct-url.ts
300
+ const constructUrl = (query, options) => {
301
+ const registry = options?.registry ?? DEFAULT_REGISTRY;
302
+ const url = new URL("/extensions", registry);
303
+ if (query.search) url.searchParams.set("search", query.search);
304
+ if (query.type) url.searchParams.set("type", query.type);
305
+ if (query.limit) url.searchParams.set("limit", String(query.limit));
306
+ if (query.offset) url.searchParams.set("offset", String(query.offset));
307
+ if (query.by) url.searchParams.set("by", query.by);
308
+ if (query.sort) url.searchParams.set("sort", query.sort);
309
+ if (query.sandbox) url.searchParams.set("sandbox", "true");
310
+ return url;
207
311
  };
208
312
 
209
- // src/modules/list/schemas/registry-list-response.ts
210
- import { EXTENSION_TYPES as EXTENSION_TYPES2 } from "@directus/constants";
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
- )
313
+ //#endregion
314
+ //#region src/modules/list/schemas/registry-list-response.ts
315
+ const RegistryListResponse = z.object({
316
+ meta: z.object({ filter_count: z.number() }),
317
+ data: z.array(z.object({
318
+ id: z.string(),
319
+ name: z.string(),
320
+ description: z.union([z.null(), z.string()]),
321
+ total_downloads: z.number(),
322
+ verified: z.boolean(),
323
+ type: z.enum(EXTENSION_TYPES),
324
+ last_updated: z.string(),
325
+ host_version: z.string(),
326
+ sandbox: z.boolean(),
327
+ license: z.string().nullable(),
328
+ publisher: z.object({
329
+ username: z.string(),
330
+ verified: z.boolean(),
331
+ github_name: z.string().nullable()
332
+ })
333
+ }))
235
334
  });
236
335
 
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
336
+ //#endregion
337
+ //#region src/modules/list/list.ts
338
+ const list = async (query, options) => {
339
+ await assertVersionCompatibility(options);
340
+ const url = constructUrl(query, options);
341
+ const response = await ky.get(url).json();
342
+ return await RegistryListResponse.parseAsync(response);
249
343
  };
344
+
345
+ //#endregion
346
+ export { account, describe, download, list };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@directus/extensions-registry",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "Abstraction for exploring Directus extensions on a package registry",
5
5
  "homepage": "https://directus.io",
6
6
  "repository": {
@@ -21,23 +21,23 @@
21
21
  "dist"
22
22
  ],
23
23
  "dependencies": {
24
- "ky": "1.8.2",
25
- "zod": "4.0.14",
26
- "@directus/constants": "13.0.2",
27
- "@directus/errors": "2.0.3",
28
- "@directus/extensions": "3.0.10"
24
+ "ky": "1.13.0",
25
+ "zod": "4.1.12",
26
+ "@directus/errors": "2.0.5",
27
+ "@directus/constants": "14.0.0",
28
+ "@directus/extensions": "3.0.12"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@directus/tsconfig": "3.0.0",
32
32
  "@vitest/coverage-v8": "3.2.4",
33
- "tsup": "8.5.0",
34
- "typescript": "5.8.3",
33
+ "tsdown": "0.15.11",
34
+ "typescript": "5.9.3",
35
35
  "vitest": "3.2.4",
36
- "@directus/types": "13.2.2"
36
+ "@directus/types": "13.3.0"
37
37
  },
38
38
  "scripts": {
39
- "build": "tsup src/index.ts --format=esm --dts",
40
- "dev": "tsup src/index.ts --format=esm --dts --watch",
39
+ "build": "tsdown src/index.ts --dts",
40
+ "dev": "tsdown src/index.ts --dts --watch",
41
41
  "test": "vitest run",
42
42
  "test:coverage": "vitest run --coverage"
43
43
  }