@verdaccio/types 9.7.2 → 11.0.0-6-next.9

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/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Typescript definitions for verdaccio plugins and internal code
4
4
 
5
5
  # Typescript
6
+
6
7
  For usage with the library, the `tsconfig.json` should looks like this.
7
8
 
8
9
  ```
@@ -44,5 +45,3 @@ import type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';
44
45
  ...
45
46
  }
46
47
  ```
47
-
48
-
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { PassThrough } from 'stream';
1
+ /// <reference types="node" />
2
2
 
3
+ import { PassThrough } from 'stream';
3
4
  declare module '@verdaccio/types' {
4
5
  type StringValue = string | void | null;
5
6
 
@@ -7,13 +8,58 @@ declare module '@verdaccio/types' {
7
8
  type Callback = Function;
8
9
  // FIXME: err should be something flexible enough for any implementation
9
10
  type CallbackAction = (err: any | null) => void;
10
- type CallbackError = (err: NodeJS.ErrnoException) => void;
11
11
  interface Author {
12
+ username?: string;
12
13
  name: string;
13
14
  email?: string;
14
15
  url?: string;
15
16
  }
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
+ base: string;
44
+ primaryColor?: string;
45
+ version?: string;
46
+ logoURI?: string;
47
+ } & CommonWebConf;
48
+
49
+ /**
50
+ * Options on config.yaml for web
51
+ */
52
+ type WebConf = {
53
+ // FIXME: rename to primaryColor and move it to CommonWebConf
54
+ primary_color?: string;
55
+ enable?: boolean;
56
+ scriptsHead?: string[];
57
+ scriptsBodyAfter?: string[];
58
+ metaScripts?: string[];
59
+ bodyBefore?: string[];
60
+ bodyAfter?: string[];
61
+ } & CommonWebConf;
62
+
17
63
  interface Dist {
18
64
  integrity?: string;
19
65
  shasum: string;
@@ -136,7 +182,7 @@ declare module '@verdaccio/types' {
136
182
  name: string;
137
183
  versions: Versions;
138
184
  'dist-tags': GenericBody;
139
- time?: GenericBody;
185
+ time: GenericBody;
140
186
  readme?: string;
141
187
  users?: PackageUsers;
142
188
  _distfiles: DistFiles;
@@ -145,12 +191,12 @@ declare module '@verdaccio/types' {
145
191
  _rev: string;
146
192
  }
147
193
 
148
- class IUploadTarball extends PassThrough {
194
+ interface IUploadTarball extends PassThrough {
149
195
  abort(): void;
150
196
  done(): void;
151
197
  }
152
198
 
153
- class IReadTarball extends PassThrough {
199
+ interface IReadTarball extends PassThrough {
154
200
  abort(): void;
155
201
  }
156
202
 
@@ -185,8 +231,18 @@ declare module '@verdaccio/types' {
185
231
  publish?: string[];
186
232
  proxy?: string[];
187
233
  access?: string[];
234
+ unpublish: string[];
235
+ }
236
+
237
+ // info passed to the auth plugin when a package is package is being published
238
+ interface AllowAccess {
239
+ name: string;
240
+ version?: string;
241
+ tag?: string;
188
242
  }
189
243
 
244
+ interface AuthPackageAllow extends PackageAccess, AllowAccess {}
245
+
190
246
  interface PackageList {
191
247
  [key: string]: PackageAccess;
192
248
  }
@@ -216,6 +272,7 @@ declare module '@verdaccio/types' {
216
272
  max_users: number;
217
273
  }
218
274
 
275
+ // FUTURE: rename to Notification
219
276
  interface Notifications {
220
277
  method: string;
221
278
  packagePattern: RegExp;
@@ -225,25 +282,7 @@ declare module '@verdaccio/types' {
225
282
  headers: Headers;
226
283
  }
227
284
 
228
- interface ConfigFile {
229
- storage: string;
230
- plugins: string;
231
- self_path: string;
232
- packages: PackageList;
233
- uplinks: UpLinksConfList;
234
- logs: LoggerConf[];
235
- web: WebConf;
236
- auth: AuthConf;
237
- publish?: PublishOptions;
238
- url_prefix?: string;
239
- listen?: ListenAddress;
240
- https?: HttpsConf;
241
- http_proxy?: string;
242
- https_proxy?: string;
243
- no_proxy?: string;
244
- max_body_size?: string;
245
- notifications: Notifications;
246
- }
285
+ type Notification = Notifications;
247
286
 
248
287
  interface Token {
249
288
  user: string;
@@ -259,7 +298,6 @@ declare module '@verdaccio/types' {
259
298
  user: string;
260
299
  }
261
300
 
262
- type SyncReturn = Error | void;
263
301
  type IPackageStorage = ILocalPackageManager | void;
264
302
  type IPackageStorageManager = ILocalPackageManager;
265
303
  type IPluginStorage<T> = ILocalData<T>;
@@ -283,16 +321,6 @@ declare module '@verdaccio/types' {
283
321
  interface ListenAddress {
284
322
  [key: string]: string;
285
323
  }
286
-
287
- interface WebConf {
288
- enable?: boolean;
289
- title?: string;
290
- logo?: string;
291
- favicon?: string;
292
- gravatar?: boolean;
293
- sort_packages?: string;
294
- }
295
-
296
324
  interface HttpsConfKeyCert {
297
325
  key: string;
298
326
  cert: string;
@@ -339,32 +367,71 @@ declare module '@verdaccio/types' {
339
367
  api: APITokenOptions;
340
368
  }
341
369
 
342
- interface Config {
343
- user_agent: string;
344
- server_id: any;
370
+ interface ConfigFlags {
371
+ token?: boolean;
372
+ search?: boolean;
373
+ changePassword?: boolean;
374
+ }
375
+ export type RateLimit = {
376
+ windowMs: number;
377
+ max: number;
378
+ };
379
+
380
+ export type ServerSettingsConf = {
381
+ // express-rate-limit settings
382
+ rateLimit: RateLimit;
383
+ keepAliveTimeout?: number;
384
+ // force http2 if https is defined
385
+ http2?: boolean;
386
+ };
387
+
388
+ type URLPrefix = {
389
+ // if is false, it would be relative by default
390
+ absolute: boolean;
391
+ // base path
392
+ // eg: absolute: true, https://somedomain.com/xxx/
393
+ // eg: absolute: false, /xxx/ (default) if url_prefix is an string instead an object
394
+ basePath: string;
395
+ };
396
+
397
+ interface ConfigYaml {
345
398
  _debug?: boolean;
346
399
  storage?: string | void;
347
- plugins?: string | void;
348
- secret: string;
349
- self_path: string;
350
400
  packages: PackageList;
351
401
  uplinks: UpLinksConfList;
402
+ // @deprecated in favor of log
352
403
  logs?: LoggerConf[];
404
+ log?: LoggerConf[];
353
405
  web?: WebConf;
354
406
  auth?: AuthConf;
355
407
  security: Security;
356
408
  publish?: PublishOptions;
357
- url_prefix?: string;
358
409
  store?: any;
359
410
  listen?: ListenAddress;
360
411
  https?: HttpsConf;
361
412
  http_proxy?: string;
413
+ plugins?: string | void;
362
414
  https_proxy?: string;
363
415
  no_proxy?: string;
364
416
  max_body_size?: string;
365
417
  notifications?: Notifications;
418
+ notify?: Notifications | Notifications[];
366
419
  middlewares?: any;
367
420
  filters?: any;
421
+ url_prefix?: string;
422
+ server?: ServerSettingsConf;
423
+ flags?: ConfigFlags;
424
+ }
425
+
426
+ interface ConfigRuntime extends ConfigYaml {
427
+ config_path: string;
428
+ }
429
+
430
+ interface Config extends ConfigYaml, ConfigRuntime {
431
+ user_agent: string;
432
+ server_id: string;
433
+ secret: string;
434
+ // deprecated
368
435
  checkSecretKey(token: string): string;
369
436
  getMatchedPackagesSpec(storage: string): PackageAccess | void;
370
437
  [key: string]: any;
@@ -374,41 +441,25 @@ declare module '@verdaccio/types' {
374
441
  https: HttpsConf;
375
442
  }
376
443
 
377
- interface ITokenActions {
444
+ export interface ITokenActions {
378
445
  saveToken(token: Token): Promise<any>;
379
446
  deleteToken(user: string, tokenKey: string): Promise<any>;
380
447
  readTokens(filter: TokenFilter): Promise<Token[]>;
381
448
  }
382
449
 
383
450
  /**
384
- * This method expect return a Package object
385
- * eg:
386
- * {
387
- * name: string;
388
- * time: number;
389
- * ... and other props
390
- * }
391
- *
392
- * The `cb` callback object will be executed if:
393
- * - it might return object (truly)
394
- * - it might reutrn null
451
+ * @deprecated use @verdaccio/core pluginUtils instead
395
452
  */
396
- type onSearchPackage = (item: Package, cb: CallbackAction) => void;
397
- // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
398
- // but this type is on @verdaccio/commons-api and cannot be used here yet
399
- type onEndSearchPackage = (error?: any) => void;
400
- type onValidatePackage = (name: string) => boolean;
401
-
402
453
  interface ILocalData<T> extends IPlugin<T>, ITokenActions {
403
454
  logger: Logger;
404
455
  config: T & Config;
405
- add(name: string, callback: Callback): void;
406
- remove(name: string, callback: Callback): void;
407
- get(callback: Callback): void;
456
+ add(name: string): Promise<void>;
457
+ remove(name: string): Promise<void>;
458
+ get(): Promise<any>;
459
+ init(): Promise<void>;
408
460
  getSecret(): Promise<string>;
409
461
  setSecret(secret: string): Promise<any>;
410
462
  getPackageStorage(packageInfo: string): IPackageStorage;
411
- search(onPackage: onSearchPackage, onEnd: onEndSearchPackage, validateName: onValidatePackage): void;
412
463
  }
413
464
 
414
465
  type StorageUpdateCallback = (data: Package, cb: CallbackAction) => void;
@@ -423,14 +474,14 @@ declare module '@verdaccio/types' {
423
474
  readTarball(pkgName: string): IReadTarball;
424
475
  readPackage(fileName: string, callback: ReadPackageCallback): void;
425
476
  createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
426
- deletePackage(fileName: string, callback: CallbackAction): void;
427
- removePackage(callback: CallbackAction): void;
477
+ deletePackage(fileName: string): Promise<void>;
478
+ removePackage(): Promise<void>;
428
479
  updatePackage(
429
480
  pkgFileName: string,
430
481
  updateHandler: StorageUpdateCallback,
431
482
  onWrite: StorageWriteCallback,
432
483
  transformPackage: PackageTransformer,
433
- onEnd: CallbackAction
484
+ onEnd: Callback
434
485
  ): void;
435
486
  savePackage(fileName: string, json: Package, callback: CallbackAction): void;
436
487
  }
@@ -442,41 +493,30 @@ declare module '@verdaccio/types' {
442
493
  }
443
494
 
444
495
  interface StoragePackageActions extends TarballActions {
445
- addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
496
+ addVersion(
497
+ name: string,
498
+ version: string,
499
+ metadata: Version,
500
+ tag: StringValue,
501
+ callback: Callback
502
+ ): void;
446
503
  mergeTags(name: string, tags: MergeTags, callback: Callback): void;
447
504
  removePackage(name: string, callback: Callback): void;
448
505
  changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
449
506
  }
450
507
 
451
- interface IStorageManager<T> extends StoragePackageActions {
452
- config: T & Config;
453
- logger: Logger;
454
- init(config: T & Config, filters: any): Promise<any>;
455
- addPackage(name: string, metadata: any, callback: Callback): Promise<any>;
456
- getPackage(options: any): void;
457
- search(startkey: string, options: any): IReadTarball;
458
- getLocalDatabase(callback: Callback): void;
459
- }
460
-
461
- interface IBasicStorage<T> extends StoragePackageActions {
462
- addPackage(name: string, info: Package, callback: Callback): void;
463
- updateVersions(name: string, packageInfo: Package, callback: Callback): void;
464
- getPackageMetadata(name: string, callback: Callback): void;
465
- search(startKey: string, options: any): IReadTarball;
466
- getSecret(config: T & Config): Promise<any>;
467
- }
468
-
508
+ // @deprecated use IBasicAuth from @verdaccio/auth
469
509
  interface IBasicAuth<T> {
470
510
  config: T & Config;
471
- aesEncrypt(buf: Buffer): Buffer;
511
+ aesEncrypt(buf: string): string;
472
512
  authenticate(user: string, password: string, cb: Callback): void;
473
513
  changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
474
514
  allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
475
515
  add_user(user: string, password: string, cb: Callback): any;
476
516
  }
477
517
 
478
- class Plugin<T> {
479
- constructor(config: T, options: PluginOptions<T>);
518
+ export interface Plugin<T> {
519
+ new (config: T, options: PluginOptions<T>): T;
480
520
  }
481
521
 
482
522
  interface IPlugin<T> {
@@ -490,14 +530,9 @@ declare module '@verdaccio/types' {
490
530
  logger: Logger;
491
531
  }
492
532
 
493
- interface AllowAccess {
494
- name: string;
495
- version?: string;
496
- tag?: string;
497
- }
498
-
499
- // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };` instead of AuthError
500
- // but this type is on @verdaccio/commons-api and cannot be used here yet (I don't know why)
533
+ // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
534
+ // instead of AuthError
535
+ // but this type is on @verdaccio/core and cannot be used here yet (I don't know why)
501
536
  interface HttpError extends Error {
502
537
  status: number;
503
538
  statusCode: number;
@@ -516,17 +551,26 @@ declare module '@verdaccio/types' {
516
551
  authenticate(user: string, password: string, cb: AuthCallback): void;
517
552
  adduser?(user: string, password: string, cb: AuthCallback): void;
518
553
  changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
519
- allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
554
+ allow_publish?(user: RemoteUser, pkg: T & AuthPackageAllow, cb: AuthAccessCallback): void;
520
555
  allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
521
- allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
522
- allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
556
+ allow_unpublish?(user: RemoteUser, pkg: T & AuthPackageAllow, cb: AuthAccessCallback): void;
557
+ allow_publish?(
558
+ user: RemoteUser,
559
+ pkg: AllowAccess & PackageAccess,
560
+ cb: AuthAccessCallback
561
+ ): void;
523
562
  allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
524
- allow_unpublish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
563
+ allow_unpublish?(
564
+ user: RemoteUser,
565
+ pkg: AllowAccess & PackageAccess,
566
+ cb: AuthAccessCallback
567
+ ): void;
525
568
  apiJWTmiddleware?(helpers: any): Function;
526
569
  }
527
570
 
571
+ // @deprecated use @verdaccio/server
528
572
  interface IPluginMiddleware<T> extends IPlugin<T> {
529
- register_middlewares(app: any, auth: IBasicAuth<T>, storage: IStorageManager<T>): void;
573
+ register_middlewares(app: any, auth: IBasicAuth<T>, storage: any): void;
530
574
  }
531
575
 
532
576
  interface IPluginStorageFilter<T> extends IPlugin<T> {
package/package.json CHANGED
@@ -1,22 +1,32 @@
1
1
  {
2
2
  "name": "@verdaccio/types",
3
- "version": "9.7.2",
3
+ "version": "11.0.0-6-next.9",
4
4
  "description": "verdaccio types definitions",
5
5
  "keywords": [
6
- "verdaccio",
7
- "typescript",
8
- "types"
6
+ "private",
7
+ "package",
8
+ "repository",
9
+ "registry",
10
+ "enterprise",
11
+ "modules",
12
+ "proxy",
13
+ "server",
14
+ "verdaccio"
9
15
  ],
10
16
  "author": "Juan Picado <juanpicado19@gmail.com>",
11
17
  "license": "MIT",
12
18
  "homepage": "https://verdaccio.org",
19
+ "engines": {
20
+ "node": ">=14",
21
+ "npm": ">=6"
22
+ },
13
23
  "repository": {
14
- "type": "git",
15
- "url": "https://github.com/verdaccio/monorepo",
16
- "directory": "core/types"
24
+ "type": "https",
25
+ "url": "https://github.com/verdaccio/verdaccio",
26
+ "directory": "packages/core/types"
17
27
  },
18
28
  "bugs": {
19
- "url": "https://github.com/verdaccio/monorepo/issues"
29
+ "url": "https://github.com/verdaccio/verdaccio/issues"
20
30
  },
21
31
  "publishConfig": {
22
32
  "access": "public"
@@ -24,13 +34,14 @@
24
34
  "main": "index.d.ts",
25
35
  "types": "index.d.ts",
26
36
  "scripts": {
27
- "lint": "eslint \"**/*.{js,ts}\"",
28
- "lint:stage": "lint-staged",
29
- "test": "tsc --noEmit"
37
+ "test": "exit 0",
38
+ "build": "exit 0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "14.6.0"
30
42
  },
31
43
  "funding": {
32
44
  "type": "opencollective",
33
45
  "url": "https://opencollective.com/verdaccio"
34
- },
35
- "gitHead": "5c7d3c5af1bf28da8ffe61f73dfc6380b5e91679"
46
+ }
36
47
  }
package/tsconfig.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "commonjs",
5
- "noImplicitAny": true,
6
- "noImplicitThis": true,
7
- "strictNullChecks": true,
8
- "strictFunctionTypes": true,
9
- "noEmit": true,
10
- "forceConsistentCasingInFileNames": true
11
- },
12
- "typeRoots": [
13
- "./node_modules/@types",
14
- "./index.d.ts"
15
- ],
16
- "includes": [
17
- "./index.d.ts"
18
- ]
19
- }