Skip to content

Commit eab219e

Browse files
mlucoolsergiohgz
authored andcommitted
feat: support for an IPluginStorageFilter (#58)
feat: support for an IPluginStorageFilter @mlucool
1 parent 50f5531 commit eab219e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

core/types/index.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ type StringValue = string | void | null;
339339
max_body_size?: string;
340340
notifications?: Notifications;
341341
middlewares?: any;
342+
storage_filters?: any;
342343
checkSecretKey(token: string): string;
343344
getMatchedPackagesSpec(storage: string): PackageAccess | void;
344345
[key: string]: any;
@@ -388,7 +389,7 @@ type StringValue = string | void | null;
388389
interface IStorageManager<T> extends StoragePackageActions {
389390
config: T & Config;
390391
logger: Logger;
391-
init(config: T & Config): Promise<any>;
392+
init(config: T & Config, filters: any): Promise<any>;
392393
addPackage(name: string, metadata: any, callback: Callback): Promise<any>;
393394
getPackage(options: any): void;
394395
search(startkey: string, options: any): IReadTarball;
@@ -418,6 +419,8 @@ type StringValue = string | void | null;
418419

419420
interface IPlugin<T> {
420421
version?: string;
422+
// In case a plugin needs to be cleaned up/removed
423+
close?(): void;
421424
}
422425

423426
type PluginOptions<T> = {
@@ -437,4 +440,8 @@ type StringValue = string | void | null;
437440
interface IPluginMiddleware<T> extends IPlugin<T> {
438441
register_middlewares(app: any, auth: IBasicAuth<T>, storage: IStorageManager<T>): void;
439442
}
443+
444+
interface IPluginStorageFilter<T> extends IPlugin<T> {
445+
filter_metadata(packageInfo: Package, cb: Callback): void;
446+
}
440447
}

core/types/src/flow/types.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* @flow */
22

3+
import {Callback, IBasicAuth, IPlugin, IStorageManager, Package} from '@verdaccio/types';
4+
35
declare type verdaccio$StringValue = string | void | null;
46

57
declare type verdaccio$Callback = Function;
@@ -330,6 +332,7 @@ declare interface verdaccio$Config {
330332
max_body_size?: string;
331333
notifications?: verdaccio$Notifications;
332334
middlewares?: any;
335+
storage_filters?: any;
333336
checkSecretKey(token: string): string;
334337
getMatchedPackagesSpec(storage: string): verdaccio$PackageAccess | void;
335338
[key: string]: any;
@@ -380,7 +383,7 @@ declare interface verdaccio$StoragePackageActions extends verdaccio$TarballActio
380383
declare interface verdaccio$IStorageManager extends verdaccio$StoragePackageActions {
381384
config: $Subtype<verdaccio$Config>;
382385
logger: verdaccio$Logger;
383-
init(config: $Subtype<verdaccio$Config>): Promise<any>;
386+
init(config: $Subtype<verdaccio$Config>, filters: any): Promise<any>;
384387
addPackage(name: string, metadata: any, callback: verdaccio$Callback): Promise<any>;
385388
getPackage(options: any): void;
386389
search(startkey: string, options: any): verdaccio$IReadTarball;
@@ -406,6 +409,7 @@ declare interface verdaccio$IBasicAuth {
406409

407410
declare interface verdaccio$IPlugin {
408411
version?: string;
412+
close(): void;
409413
}
410414

411415
declare type verdaccio$PluginOptions = {
@@ -426,6 +430,10 @@ declare interface verdaccio$IPluginMiddleware extends verdaccio$IPlugin {
426430
register_middlewares(app: any, auth: verdaccio$IBasicAuth, storage: verdaccio$IStorageManager): void;
427431
}
428432

433+
declare interface verdaccio$IPluginStorageFilter extends verdaccio$IPlugin {
434+
filter_metadata(packageInfo: verdaccio$Package, cb: verdaccio$Callback): void;
435+
}
436+
429437
declare module "@verdaccio/local-storage" {
430438
declare export type ILocalData = verdaccio$ILocalData;
431439
declare export type IPluginStorage = verdaccio$ILocalData;
@@ -470,6 +478,7 @@ declare module "@verdaccio/types" {
470478
declare export type IBasicAuth = verdaccio$IBasicAuth;
471479
declare export type IPluginAuth = verdaccio$IPluginAuth;
472480
declare export type IPluginMiddleware = verdaccio$IPluginMiddleware;
481+
declare export type IPluginStorageFilter = verdaccio$IPluginStorageFilter;
473482
declare export type PluginOptions = verdaccio$PluginOptions;
474483
declare export type Stdout = stream$Writable | tty$WriteStream;
475484
declare export type Stdin = stream$Readable | tty$ReadStream;

0 commit comments

Comments
 (0)