@verdaccio/types 11.0.0-6-next.12 → 11.0.0-6-next.13

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/index.d.ts DELETED
@@ -1,639 +0,0 @@
1
- /// <reference types="node" />
2
- import { PassThrough } from 'stream';
3
-
4
- declare module '@verdaccio/types' {
5
- type StringValue = string | void | null;
6
-
7
- type StorageList = string[];
8
- type Callback = Function;
9
- // FIXME: err should be something flexible enough for any implementation
10
- type CallbackAction = (err: any | null) => void;
11
- interface Author {
12
- username?: string;
13
- name: string;
14
- email?: string;
15
- url?: string;
16
- }
17
-
18
- type PackageManagers = 'pnpm' | 'yarn' | 'npm';
19
-
20
- // FUTURE: WebConf and TemplateUIOptions should be merged .
21
- type CommonWebConf = {
22
- title?: string;
23
- logo?: string;
24
- favicon?: string;
25
- gravatar?: boolean;
26
- sort_packages?: string;
27
- darkMode?: boolean;
28
- url_prefix?: string;
29
- language?: string;
30
- login?: boolean;
31
- scope?: string;
32
- pkgManagers?: PackageManagers[];
33
- };
34
-
35
- /**
36
- * Options are passed to the index.html
37
- */
38
- export type TemplateUIOptions = {
39
- uri?: string;
40
- darkMode?: boolean;
41
- protocol?: string;
42
- host?: string;
43
- // deprecated
44
- basename?: string;
45
- scope?: string;
46
- showInfo?: boolean;
47
- showSettings?: boolean;
48
- showSearch?: boolean;
49
- showFooter?: boolean;
50
- showThemeSwitch?: boolean;
51
- showDownloadTarball?: boolean;
52
- showRaw?: boolean;
53
- base: string;
54
- primaryColor?: string;
55
- version?: string;
56
- logoURI?: string;
57
- flags: FlagsConfig;
58
- } & CommonWebConf;
59
-
60
- /**
61
- * Options on config.yaml for web
62
- */
63
- type WebConf = {
64
- // FIXME: rename to primaryColor and move it to CommonWebConf
65
- primary_color?: string;
66
- enable?: boolean;
67
- scriptsHead?: string[];
68
- scriptsBodyAfter?: string[];
69
- metaScripts?: string[];
70
- bodyBefore?: string[];
71
- bodyAfter?: string[];
72
- } & CommonWebConf;
73
-
74
- interface Dist {
75
- integrity?: string;
76
- shasum: string;
77
- tarball: string;
78
- }
79
-
80
- interface RemoteUser {
81
- real_groups: string[];
82
- groups: string[];
83
- name: string | void;
84
- error?: string;
85
- }
86
-
87
- interface LocalStorage {
88
- list: any;
89
- secret: string;
90
- }
91
-
92
- interface Version {
93
- name: string;
94
- version: string;
95
- devDependencies?: string;
96
- directories?: any;
97
- dist: Dist;
98
- author: string | Author;
99
- main: string;
100
- homemage?: string;
101
- license?: string;
102
- readme: string;
103
- readmeFileName?: string;
104
- readmeFilename?: string;
105
- description: string;
106
- bin?: string;
107
- bugs?: any;
108
- files?: string[];
109
- gitHead?: string;
110
- maintainers?: Author[];
111
- contributors?: Author[];
112
- repository?: string | any;
113
- scripts?: any;
114
- homepage?: string;
115
- etag?: string;
116
- dependencies: any;
117
- keywords?: string | string[];
118
- nodeVersion?: string;
119
- _id: string;
120
- _npmVersion?: string;
121
- _npmUser: Author;
122
- _hasShrinkwrap?: boolean;
123
- deprecated?: string;
124
- }
125
-
126
- interface Logger {
127
- child: (conf: any) => any;
128
- debug: (conf: any, template?: string) => void;
129
- error: (conf: any, template?: string) => void;
130
- http: (conf: any, template?: string) => void;
131
- trace: (conf: any, template?: string) => void;
132
- warn: (conf: any, template?: string) => void;
133
- info: (conf: any, template?: string) => void;
134
- }
135
-
136
- interface Versions {
137
- [key: string]: Version;
138
- }
139
-
140
- interface DistFile {
141
- url: string;
142
- sha: string;
143
- registry?: string;
144
- }
145
-
146
- interface MergeTags {
147
- [key: string]: string;
148
- }
149
-
150
- interface DistFiles {
151
- [key: string]: DistFile;
152
- }
153
-
154
- interface AttachMents {
155
- [key: string]: AttachMentsItem;
156
- }
157
-
158
- interface AttachMentsItem {
159
- content_type?: string;
160
- data?: string;
161
- length?: number;
162
- shasum?: string;
163
- version?: string;
164
- }
165
-
166
- interface GenericBody {
167
- [key: string]: string;
168
- }
169
-
170
- interface UpLinkMetadata {
171
- etag: string;
172
- fetched: number;
173
- }
174
-
175
- interface UpLinks {
176
- [key: string]: UpLinkMetadata;
177
- }
178
-
179
- interface Tags {
180
- [key: string]: Version;
181
- }
182
-
183
- interface Headers {
184
- [key: string]: string;
185
- }
186
-
187
- interface PackageUsers {
188
- [key: string]: boolean;
189
- }
190
-
191
- /**
192
- * @deprecated use Manifest instead
193
- */
194
- interface Package {
195
- _id?: string;
196
- name: string;
197
- versions: Versions;
198
- 'dist-tags': GenericBody;
199
- time: GenericBody;
200
- readme?: string;
201
- users?: PackageUsers;
202
- _distfiles: DistFiles;
203
- _attachments: AttachMents;
204
- _uplinks: UpLinks;
205
- _rev: string;
206
- }
207
-
208
- interface Manifest {
209
- _id?: string;
210
- name: string;
211
- versions: Versions;
212
- 'dist-tags': GenericBody;
213
- time: GenericBody;
214
- readme?: string;
215
- users?: PackageUsers;
216
- _distfiles: DistFiles;
217
- _attachments: AttachMents;
218
- _uplinks: UpLinks;
219
- _rev: string;
220
- }
221
-
222
- interface IUploadTarball extends PassThrough {
223
- abort(): void;
224
- done(): void;
225
- }
226
-
227
- interface IReadTarball extends PassThrough {
228
- abort(): void;
229
- }
230
-
231
- interface UpLinkTokenConf {
232
- type: 'Bearer' | 'Basic';
233
- token?: string;
234
- token_env?: boolean | string;
235
- }
236
-
237
- interface UpLinkConf {
238
- url: string;
239
- ca?: string;
240
- cache?: boolean;
241
- timeout?: string | void;
242
- maxage?: string | void;
243
- max_fails?: number | void;
244
- fail_timeout?: string | void;
245
- headers?: Headers;
246
- auth?: UpLinkTokenConf;
247
- strict_ssl?: boolean | void;
248
- _autogenerated?: boolean;
249
- }
250
-
251
- interface AuthPluginPackage {
252
- packageName: string;
253
- packageVersion?: string;
254
- tag?: string;
255
- }
256
-
257
- interface PackageAccess {
258
- storage?: string;
259
- publish?: string[];
260
- proxy?: string[];
261
- access?: string[];
262
- unpublish: string[];
263
- }
264
-
265
- // info passed to the auth plugin when a package is package is being published
266
- interface AllowAccess {
267
- name: string;
268
- version?: string;
269
- tag?: string;
270
- }
271
-
272
- interface AuthPackageAllow extends PackageAccess, AllowAccess {}
273
-
274
- interface PackageList {
275
- [key: string]: PackageAccess;
276
- }
277
-
278
- interface UpLinksConfList {
279
- [key: string]: UpLinkConf;
280
- }
281
-
282
- type LoggerType = 'stdout' | 'stderr' | 'file';
283
- type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'file';
284
- type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
285
-
286
- interface LoggerConfItem {
287
- type: LoggerType;
288
- format: LoggerFormat;
289
- level: LoggerLevel;
290
- }
291
-
292
- interface PublishOptions {
293
- allow_offline: boolean;
294
- }
295
-
296
- type AuthConf = any | AuthHtpasswd;
297
-
298
- interface AuthHtpasswd {
299
- file: string;
300
- max_users: number;
301
- }
302
-
303
- // FUTURE: rename to Notification
304
- interface Notifications {
305
- method: string;
306
- packagePattern: RegExp;
307
- packagePatternFlags: string;
308
- endpoint: string;
309
- content: string;
310
- headers: Headers;
311
- }
312
-
313
- type Notification = Notifications;
314
-
315
- interface Token {
316
- user: string;
317
- token: string;
318
- key: string;
319
- cidr?: string[];
320
- readonly: boolean;
321
- created: number | string;
322
- updated?: number | string;
323
- }
324
-
325
- interface TokenFilter {
326
- user: string;
327
- }
328
-
329
- type IPackageStorage = ILocalPackageManager | void;
330
- type IPackageStorageManager = ILocalPackageManager;
331
- type IPluginStorage<T> = ILocalData<T>;
332
-
333
- interface AuthHtpasswd {
334
- file: string;
335
- max_users: number;
336
- }
337
-
338
- interface ILocalStorage {
339
- add(name: string): void;
340
- remove(name: string): void;
341
- get(): StorageList;
342
- sync(): void;
343
- }
344
-
345
- interface ListenAddress {
346
- [key: string]: string;
347
- }
348
- interface HttpsConfKeyCert {
349
- key: string;
350
- cert: string;
351
- ca?: string;
352
- }
353
-
354
- interface HttpsConfPfx {
355
- pfx: string;
356
- passphrase?: string;
357
- }
358
-
359
- type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
360
-
361
- interface JWTOptions {
362
- sign: JWTSignOptions;
363
- verify: JWTVerifyOptions;
364
- }
365
-
366
- interface JWTVerifyOptions {
367
- algorithm?: string;
368
- expiresIn?: string;
369
- notBefore?: string | number;
370
- ignoreExpiration?: boolean;
371
- maxAge?: string | number;
372
- clockTimestamp?: number;
373
- }
374
-
375
- interface JWTSignOptions {
376
- algorithm?: string;
377
- expiresIn?: string;
378
- notBefore?: string;
379
- ignoreExpiration?: boolean;
380
- maxAge?: string | number;
381
- clockTimestamp?: number;
382
- }
383
-
384
- interface APITokenOptions {
385
- legacy: boolean;
386
- jwt?: JWTOptions;
387
- }
388
-
389
- interface Security {
390
- web: JWTOptions;
391
- api: APITokenOptions;
392
- }
393
-
394
- export type FlagsConfig = {
395
- searchRemote?: boolean;
396
- changePassword?: boolean;
397
- };
398
-
399
- export type RateLimit = {
400
- windowMs: number;
401
- max: number;
402
- };
403
-
404
- export type ServerSettingsConf = {
405
- // express-rate-limit settings
406
- rateLimit: RateLimit;
407
- keepAliveTimeout?: number;
408
- // force http2 if https is defined
409
- http2?: boolean;
410
- };
411
-
412
- type URLPrefix = {
413
- // if is false, it would be relative by default
414
- absolute: boolean;
415
- // base path
416
- // eg: absolute: true, https://somedomain.com/xxx/
417
- // eg: absolute: false, /xxx/ (default) if url_prefix is an string instead an object
418
- basePath: string;
419
- };
420
-
421
- interface ConfigYaml {
422
- _debug?: boolean;
423
- storage?: string | void;
424
- packages: PackageList;
425
- uplinks: UpLinksConfList;
426
- // FUTURE: log should be mandatory
427
- log?: LoggerConfItem;
428
- web?: WebConf;
429
- auth?: AuthConf;
430
- security: Security;
431
- publish?: PublishOptions;
432
- store?: any;
433
- listen?: ListenAddress;
434
- https?: HttpsConf;
435
- http_proxy?: string;
436
- plugins?: string | void;
437
- https_proxy?: string;
438
- no_proxy?: string;
439
- max_body_size?: string;
440
- notifications?: Notifications;
441
- notify?: Notifications | Notifications[];
442
- middlewares?: any;
443
- filters?: any;
444
- url_prefix?: string;
445
- server?: ServerSettingsConf;
446
- flags?: FlagsConfig;
447
- }
448
-
449
- interface ConfigRuntime extends ConfigYaml {
450
- config_path: string;
451
- }
452
-
453
- interface Config extends ConfigYaml, ConfigRuntime {
454
- user_agent: string;
455
- server_id: string;
456
- secret: string;
457
- // deprecated
458
- checkSecretKey(token: string): string;
459
- getMatchedPackagesSpec(storage: string): PackageAccess | void;
460
- [key: string]: any;
461
- }
462
-
463
- type PublisherMaintainer = {
464
- username: string;
465
- email: string;
466
- };
467
-
468
- type SearchPackageBody = {
469
- name: string;
470
- scope: string;
471
- description: string;
472
- author: string | PublisherMaintainer;
473
- version: string;
474
- keywords: string | string[] | undefined;
475
- date: string;
476
- links?: {
477
- npm: string; // only include placeholder for URL eg: {url}/{packageName}
478
- homepage?: string;
479
- repository?: string;
480
- bugs?: string;
481
- };
482
- publisher?: any;
483
- maintainers?: PublisherMaintainer[];
484
- };
485
-
486
- interface ConfigWithHttps extends Config {
487
- https: HttpsConf;
488
- }
489
-
490
- export interface ITokenActions {
491
- saveToken(token: Token): Promise<any>;
492
- deleteToken(user: string, tokenKey: string): Promise<any>;
493
- readTokens(filter: TokenFilter): Promise<Token[]>;
494
- }
495
-
496
- /**
497
- * @deprecated use @verdaccio/core pluginUtils instead
498
- */
499
- interface ILocalData<T> extends IPlugin<T>, ITokenActions {
500
- logger: Logger;
501
- config: T & Config;
502
- add(name: string): Promise<void>;
503
- remove(name: string): Promise<void>;
504
- get(): Promise<any>;
505
- init(): Promise<void>;
506
- getSecret(): Promise<string>;
507
- setSecret(secret: string): Promise<any>;
508
- getPackageStorage(packageInfo: string): IPackageStorage;
509
- }
510
-
511
- type StorageUpdateCallback = (data: Package, cb: CallbackAction) => void;
512
- type StorageUpdateHandler = (name: string, cb: StorageUpdateCallback) => void;
513
- type StorageWriteCallback = (name: string, json: Package, callback: Callback) => void;
514
- type PackageTransformer = (pkg: Package) => Package;
515
- type ReadPackageCallback = (err: any | null, data?: Package) => void;
516
-
517
- interface ILocalPackageManager {
518
- logger: Logger;
519
- writeTarball(pkgName: string): IUploadTarball;
520
- readTarball(pkgName: string): IReadTarball;
521
- readPackage(fileName: string, callback: ReadPackageCallback): void;
522
- createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
523
- deletePackage(fileName: string): Promise<void>;
524
- removePackage(): Promise<void>;
525
- // @deprecated
526
- updatePackage(
527
- pkgFileName: string,
528
- updateHandler: StorageUpdateCallback,
529
- onWrite: StorageWriteCallback,
530
- transformPackage: PackageTransformer,
531
- onEnd: Callback
532
- ): void;
533
- // @deprecated
534
- savePackage(fileName: string, json: Package, callback: CallbackAction): void;
535
- // next packages migration (this list is meant to replace the callback parent functions)
536
- updatePackageNext(
537
- packageName: string,
538
- handleUpdate: (manifest: Package) => Promise<Package>
539
- ): Promise<Package>;
540
- savePackageNext(name: string, value: Package): Promise<void>;
541
- }
542
-
543
- interface TarballActions {
544
- addTarball(name: string, filename: string): IUploadTarball;
545
- getTarball(name: string, filename: string): IReadTarball;
546
- removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
547
- }
548
-
549
- interface StoragePackageActions extends TarballActions {
550
- addVersion(
551
- name: string,
552
- version: string,
553
- metadata: Version,
554
- tag: StringValue,
555
- callback: Callback
556
- ): void;
557
- mergeTags(name: string, tags: MergeTags, callback: Callback): void;
558
- removePackage(name: string, callback: Callback): void;
559
- changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
560
- }
561
-
562
- // @deprecated use IBasicAuth from @verdaccio/auth
563
- interface IBasicAuth<T> {
564
- config: T & Config;
565
- aesEncrypt(buf: string): string;
566
- authenticate(user: string, password: string, cb: Callback): void;
567
- changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
568
- allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
569
- add_user(user: string, password: string, cb: Callback): any;
570
- }
571
-
572
- export interface Plugin<T> {
573
- new (config: T, options: PluginOptions<T>): T;
574
- }
575
-
576
- interface IPlugin<T> {
577
- version?: string;
578
- // In case a plugin needs to be cleaned up/removed
579
- close?(): void;
580
- }
581
-
582
- interface PluginOptions<T> {
583
- config: T & Config;
584
- logger: Logger;
585
- }
586
-
587
- // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
588
- // instead of AuthError
589
- // but this type is on @verdaccio/core and cannot be used here yet (I don't know why)
590
- interface HttpError extends Error {
591
- status: number;
592
- statusCode: number;
593
- expose: boolean;
594
- headers?: {
595
- [key: string]: string;
596
- };
597
- [key: string]: any;
598
- }
599
-
600
- type AuthError = HttpError & { code: number };
601
- type AuthAccessCallback = (error: AuthError | null, access: boolean) => void;
602
- type AuthCallback = (error: AuthError | null, groups: string[] | false) => void;
603
-
604
- interface IPluginAuth<T> extends IPlugin<T> {
605
- authenticate(user: string, password: string, cb: AuthCallback): void;
606
- adduser?(user: string, password: string, cb: AuthCallback): void;
607
- changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
608
- allow_publish?(user: RemoteUser, pkg: T & AuthPackageAllow, cb: AuthAccessCallback): void;
609
- allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
610
- allow_unpublish?(user: RemoteUser, pkg: T & AuthPackageAllow, cb: AuthAccessCallback): void;
611
- allow_publish?(
612
- user: RemoteUser,
613
- pkg: AllowAccess & PackageAccess,
614
- cb: AuthAccessCallback
615
- ): void;
616
- allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
617
- allow_unpublish?(
618
- user: RemoteUser,
619
- pkg: AllowAccess & PackageAccess,
620
- cb: AuthAccessCallback
621
- ): void;
622
- apiJWTmiddleware?(helpers: any): Function;
623
- }
624
-
625
- // @deprecated use @verdaccio/server
626
- interface IPluginMiddleware<T> extends IPlugin<T> {
627
- register_middlewares(app: any, auth: IBasicAuth<T>, storage: any): void;
628
- }
629
-
630
- interface IPluginStorageFilter<T> extends IPlugin<T> {
631
- filter_metadata(packageInfo: Package): Promise<Package>;
632
- }
633
-
634
- export type SearchResultWeb = {
635
- name: string;
636
- version: string;
637
- description: string;
638
- };
639
- }