1 |
|
2 | import { PassThrough } from 'stream';
|
3 | import { Callback, CallbackAction, StringValue } from '../commons';
|
4 | import { Config, Logger } from '../configuration';
|
5 | import { MergeTags, Package, Token, Version } from '../manifest';
|
6 | import { IPlugin } from './commons';
|
7 | export declare class IUploadTarball extends PassThrough {
|
8 | abort(): void;
|
9 | done(): void;
|
10 | }
|
11 | export declare class IReadTarball extends PassThrough {
|
12 | abort(): void;
|
13 | }
|
14 | export declare type StorageList = string[];
|
15 | export interface LocalStorage {
|
16 | list: any;
|
17 | secret: string;
|
18 | }
|
19 | export interface ILocalStorage {
|
20 | add(name: string): void;
|
21 | remove(name: string): void;
|
22 | get(): StorageList;
|
23 | sync(): void;
|
24 | }
|
25 | interface TarballActions {
|
26 | addTarball(name: string, filename: string): IUploadTarball;
|
27 | getTarball(name: string, filename: string): IReadTarball;
|
28 | removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
|
29 | }
|
30 | interface StoragePackageActions extends TarballActions {
|
31 | addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
|
32 | mergeTags(name: string, tags: MergeTags, callback: Callback): void;
|
33 | removePackage(name: string, callback: Callback): void;
|
34 | changePackage(name: string, metadata: Package, revision: string, callback: Callback): void;
|
35 | }
|
36 | export interface IStorageManager<T> extends StoragePackageActions {
|
37 | config: T & Config;
|
38 | logger: Logger;
|
39 | init(config: T & Config, filters: any): Promise<any>;
|
40 | addPackage(name: string, metadata: any, callback: Callback): Promise<any>;
|
41 | getPackage(options: any): void;
|
42 | search(startkey: string, options: any): IReadTarball;
|
43 | getLocalDatabase(callback: Callback): void;
|
44 | }
|
45 | export interface IBasicStorage<T> extends StoragePackageActions {
|
46 | addPackage(name: string, info: Package, callback: Callback): void;
|
47 | updateVersions(name: string, packageInfo: Package, callback: Callback): void;
|
48 | getPackageMetadata(name: string, callback: Callback): void;
|
49 | search(startKey: string, options: any): IReadTarball;
|
50 | getSecret(config: T & Config): Promise<any>;
|
51 | }
|
52 | export interface TokenFilter {
|
53 | user: string;
|
54 | }
|
55 | export interface ITokenActions {
|
56 | saveToken(token: Token): Promise<any>;
|
57 | deleteToken(user: string, tokenKey: string): Promise<any>;
|
58 | readTokens(filter: TokenFilter): Promise<Token[]>;
|
59 | }
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | export declare type onSearchPackage = (item: Package, cb: CallbackAction) => void;
|
74 | export declare type onEndSearchPackage = (error?: any) => void;
|
75 | export declare type onValidatePackage = (name: string) => boolean;
|
76 | export declare type StorageUpdateCallback = (data: Package, cb: CallbackAction) => void;
|
77 | export declare type StorageWriteCallback = (name: string, json: Package, callback: Callback) => void;
|
78 | export declare type PackageTransformer = (pkg: Package) => Package;
|
79 | export declare type ReadPackageCallback = (err: any | null, data?: Package) => void;
|
80 | export interface ILocalPackageManager {
|
81 | logger: Logger;
|
82 | writeTarball(pkgName: string): IUploadTarball;
|
83 | readTarball(pkgName: string): IReadTarball;
|
84 | readPackage(fileName: string, callback: ReadPackageCallback): void;
|
85 | createPackage(pkgName: string, value: Package, cb: CallbackAction): void;
|
86 | deletePackage(fileName: string, callback: CallbackAction): void;
|
87 | removePackage(callback: CallbackAction): void;
|
88 | updatePackage(pkgFileName: string, updateHandler: StorageUpdateCallback, onWrite: StorageWriteCallback, transformPackage: PackageTransformer, onEnd: CallbackAction): void;
|
89 | savePackage(fileName: string, json: Package, callback: CallbackAction): void;
|
90 | }
|
91 | export declare type IPackageStorage = ILocalPackageManager | void;
|
92 | export declare type IPluginStorage<T> = ILocalData<T>;
|
93 | export declare type IPackageStorageManager = ILocalPackageManager;
|
94 | export interface ILocalData<T> extends IPlugin<T>, ITokenActions {
|
95 | logger: Logger;
|
96 | config: T & Config;
|
97 | add(name: string, callback: Callback): void;
|
98 | remove(name: string, callback: Callback): void;
|
99 | get(callback: Callback): void;
|
100 | getSecret(): Promise<string>;
|
101 | setSecret(secret: string): Promise<any>;
|
102 | getPackageStorage(packageInfo: string): IPackageStorage;
|
103 | search(onPackage: onSearchPackage, onEnd: onEndSearchPackage, validateName: onValidatePackage): void;
|
104 | }
|
105 | export {};
|