@verdaccio/types 11.0.0-6-next.10 → 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.
@@ -0,0 +1,5 @@
1
+ import { IBasicAuth } from './auth';
2
+ import { IPlugin } from './commons';
3
+ export interface IPluginMiddleware<T, K> extends IPlugin<T> {
4
+ register_middlewares(app: any, auth: IBasicAuth<T>, storage: K): void;
5
+ }
@@ -0,0 +1,80 @@
1
+ /// <reference types="node" />
2
+ import { Readable, Writable } from 'stream';
3
+ import { Callback, CallbackAction } from '../commons';
4
+ import { Config, Logger } from '../configuration';
5
+ import { Manifest, Token } from '../manifest';
6
+ import { IPlugin } from './commons';
7
+ export declare type StorageList = string[];
8
+ export interface LocalStorage {
9
+ list: any;
10
+ secret: string;
11
+ }
12
+ export interface ILocalStorage {
13
+ add(name: string): void;
14
+ remove(name: string): void;
15
+ get(): StorageList;
16
+ sync(): void;
17
+ }
18
+ export interface TokenFilter {
19
+ user: string;
20
+ }
21
+ export interface ITokenActions {
22
+ saveToken(token: Token): Promise<any>;
23
+ deleteToken(user: string, tokenKey: string): Promise<any>;
24
+ readTokens(filter: TokenFilter): Promise<Token[]>;
25
+ }
26
+ /**
27
+ * This method expect return a Package object
28
+ * eg:
29
+ * {
30
+ * name: string;
31
+ * time: number;
32
+ * ... and other props
33
+ * }
34
+ *
35
+ * The `cb` callback object will be executed if:
36
+ * - it might return object (truly)
37
+ * - it might reutrn null
38
+ */
39
+ export declare type onSearchPackage = (item: Manifest, cb: CallbackAction) => void;
40
+ export declare type onEndSearchPackage = (error?: any) => void;
41
+ export declare type onValidatePackage = (name: string) => boolean;
42
+ export declare type StorageUpdateCallback = (data: Manifest, cb: CallbackAction) => void;
43
+ export declare type StorageWriteCallback = (name: string, json: Manifest, callback: Callback) => void;
44
+ export declare type PackageTransformer = (pkg: Manifest) => Manifest;
45
+ export declare type ReadPackageCallback = (err: any | null, data?: Manifest) => void;
46
+ export interface ILocalPackageManager {
47
+ logger: Logger;
48
+ deletePackage(fileName: string): Promise<void>;
49
+ removePackage(): Promise<void>;
50
+ updatePackage(packageName: string, handleUpdate: (manifest: Manifest) => Promise<Manifest>): Promise<Manifest>;
51
+ readPackage(name: string): Promise<Manifest>;
52
+ savePackage(pkgName: string, value: Manifest): Promise<void>;
53
+ readTarball(pkgName: string, { signal }: {
54
+ signal: any;
55
+ }): Promise<Readable>;
56
+ createPackage(name: string, manifest: Manifest): Promise<void>;
57
+ writeTarball(tarballName: string, { signal }: {
58
+ signal: any;
59
+ }): Promise<Writable>;
60
+ hasTarball(fileName: string): Promise<boolean>;
61
+ hasPackage(): Promise<boolean>;
62
+ }
63
+ export declare type IPackageStorage = ILocalPackageManager | void;
64
+ export declare type IPluginStorage<T> = ILocalData<T>;
65
+ export declare type IPackageStorageManager = ILocalPackageManager;
66
+ /**
67
+ * @deprecated use @verdaccio/core pluginUtils instead
68
+ */
69
+ interface ILocalData<T> extends IPlugin<T>, ITokenActions {
70
+ logger: Logger;
71
+ config: T & Config;
72
+ add(name: string): Promise<void>;
73
+ remove(name: string): Promise<void>;
74
+ get(): Promise<any>;
75
+ init(): Promise<void>;
76
+ getSecret(): Promise<string>;
77
+ setSecret(secret: string): Promise<any>;
78
+ getPackageStorage(packageInfo: string): IPackageStorage;
79
+ }
80
+ export {};
File without changes
@@ -0,0 +1,26 @@
1
+ export declare type PublisherMaintainer = {
2
+ username: string;
3
+ email: string;
4
+ };
5
+ export declare type SearchPackageBody = {
6
+ name: string;
7
+ scope: string;
8
+ description: string;
9
+ author: string | PublisherMaintainer;
10
+ version: string;
11
+ keywords: string | string[] | undefined;
12
+ date: string;
13
+ links?: {
14
+ npm: string;
15
+ homepage?: string;
16
+ repository?: string;
17
+ bugs?: string;
18
+ };
19
+ publisher?: any;
20
+ maintainers?: PublisherMaintainer[];
21
+ };
22
+ export declare type SearchResultWeb = {
23
+ name: string;
24
+ version: string;
25
+ description: string;
26
+ };
@@ -0,0 +1,5 @@
1
+ export * from './plugins';
2
+ export * from './manifest';
3
+ export * from './search';
4
+ export * from './commons';
5
+ export * from './configuration';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/types",
3
- "version": "11.0.0-6-next.10",
3
+ "version": "11.0.0-6-next.13",
4
4
  "description": "verdaccio types definitions",
5
5
  "keywords": [
6
6
  "private",
@@ -31,18 +31,28 @@
31
31
  "publishConfig": {
32
32
  "access": "public"
33
33
  },
34
- "main": "index.d.ts",
35
- "types": "index.d.ts",
36
- "scripts": {
37
- "test": "exit 0",
38
- "build": "exit 0"
39
- },
34
+ "main": "build/types.d.ts",
35
+ "types": "build/types.d.ts",
40
36
  "devDependencies": {
41
- "@types/node": "14.6.0",
42
- "tsd": "0.18.0"
37
+ "@types/node": "16.11.47",
38
+ "typedoc": "beta",
39
+ "typedoc-plugin-missing-exports": "1.0.0"
40
+ },
41
+ "typedoc": {
42
+ "entryPoint": "./src/types.ts",
43
+ "readmeFile": "./README.md",
44
+ "displayName": "@verdaccio/types"
43
45
  },
44
46
  "funding": {
45
47
  "type": "opencollective",
46
48
  "url": "https://opencollective.com/verdaccio"
47
- }
48
- }
49
+ },
50
+ "scripts": {
51
+ "clean": "rimraf ./build",
52
+ "test": "pnpm type-check",
53
+ "build:docs": "typedoc --options ./typedoc.json --excludeExternals --tsconfig tsconfig.build.json",
54
+ "type-check": "tsc --noEmit -p tsconfig.build.json",
55
+ "build": "tsc --emitDeclarationOnly -p tsconfig.build.json"
56
+ },
57
+ "readme": "# @verdaccio/types\n\nTypeScript definitions for Verdaccio plugins and internal code.\n\n### Usage\n\n```ts\nimport type {ILocalData, LocalStorage, Logger, Config} from '@verdaccio/types';\n\nclass LocalData implements ILocalData {\n path: string;\n logger: Logger;\n data: LocalStorage;\n config: Config;\n locked: boolean;\n ...\n}\n```\n\n### Run docs\n\nGenerate the package types documentation at `./docs` folder.\n\n```bash\n pnpm build:docs\n```\n"
58
+ }
package/src/commons.ts ADDED
@@ -0,0 +1,37 @@
1
+ // @deprecated add proper type fot the callback
2
+ export type Callback = Function;
3
+ // FIXME: err should be something flexible enough for any implementation
4
+ export type CallbackAction = (err: any | null) => void;
5
+ // eslint-disable-next-line no-undef
6
+ export type CallbackError = (err: NodeJS.ErrnoException) => void;
7
+
8
+ export interface RemoteUser {
9
+ real_groups: string[];
10
+ groups: string[];
11
+ name: string | void;
12
+ error?: string;
13
+ }
14
+
15
+ export type StringValue = string | void | null;
16
+
17
+ // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
18
+ // instead of AuthError
19
+ // but this type is on @verdaccio/core and cannot be used here yet (I don't know why)
20
+ export interface HttpError extends Error {
21
+ status: number;
22
+ statusCode: number;
23
+ expose: boolean;
24
+ headers?: {
25
+ [key: string]: string;
26
+ };
27
+ [key: string]: any;
28
+ }
29
+
30
+ export type URLPrefix = {
31
+ // if is false, it would be relative by default
32
+ absolute: boolean;
33
+ // base path
34
+ // eg: absolute: true, https://somedomain.com/xxx/
35
+ // eg: absolute: false, /xxx/ (default) if url_prefix is an string instead an object
36
+ basePath: string;
37
+ };
@@ -0,0 +1,296 @@
1
+ import { PackageAccess, PackageList } from './manifest';
2
+
3
+ export type TypeToken = 'Bearer' | 'Basic';
4
+
5
+ export interface Logger {
6
+ child: (conf: any) => any;
7
+ debug: (conf: any, template?: string) => void;
8
+ error: (conf: any, template?: string) => void;
9
+ http: (conf: any, template?: string) => void;
10
+ trace: (conf: any, template?: string) => void;
11
+ warn: (conf: any, template?: string) => void;
12
+ info: (conf: any, template?: string) => void;
13
+ }
14
+
15
+ export type LoggerType = 'stdout' | 'file';
16
+ export type LoggerFormat = 'pretty' | 'pretty-timestamped' | 'json';
17
+ export type LoggerLevel = 'http' | 'fatal' | 'warn' | 'info' | 'debug' | 'trace';
18
+
19
+ export type LoggerConfigItem = {
20
+ type?: LoggerType;
21
+ /**
22
+ * The format
23
+ */
24
+ format?: LoggerFormat;
25
+ path?: string;
26
+ level?: string;
27
+ colors?: boolean;
28
+ async?: boolean;
29
+ };
30
+
31
+ export interface ConfigWithHttps extends Config {
32
+ https: HttpsConf;
33
+ }
34
+
35
+ export interface PackageAccessYaml {
36
+ storage?: string;
37
+ publish?: string;
38
+ proxy?: string;
39
+ access?: string;
40
+ unpublish?: string;
41
+ }
42
+
43
+ export interface LoggerConfItem {
44
+ type: LoggerType;
45
+ format: LoggerFormat;
46
+ level: LoggerLevel;
47
+ }
48
+
49
+ export interface Headers {
50
+ [key: string]: string;
51
+ }
52
+
53
+ export interface UpLinkTokenConf {
54
+ type: TypeToken;
55
+ token?: string;
56
+ token_env?: boolean | string;
57
+ }
58
+
59
+ export interface UpLinkConf {
60
+ url: string;
61
+ ca?: string;
62
+ cache?: boolean;
63
+ timeout?: string | void;
64
+ maxage?: string | void;
65
+ max_fails?: number | void;
66
+ fail_timeout?: string | void;
67
+ headers?: Headers;
68
+ auth?: UpLinkTokenConf;
69
+ strict_ssl?: boolean | void;
70
+ _autogenerated?: boolean;
71
+ }
72
+
73
+ export type RateLimit = {
74
+ windowMs?: number;
75
+ max?: number;
76
+ };
77
+
78
+ // export interface WebConf {
79
+ // enable?: boolean;
80
+ // title?: string;
81
+ // logo?: string;
82
+ // favicon?: string;
83
+ // gravatar?: boolean;
84
+ // sort_packages?: string;
85
+ // rateLimit?: RateLimit;
86
+ // }
87
+
88
+ export type FlagsConfig = {
89
+ searchRemote?: boolean;
90
+ changePassword?: boolean;
91
+ };
92
+
93
+ export type PackageManagers = 'pnpm' | 'yarn' | 'npm';
94
+
95
+ // FUTURE: WebConf and TemplateUIOptions should be merged .
96
+ export type CommonWebConf = {
97
+ title?: string;
98
+ logo?: string;
99
+ favicon?: string;
100
+ gravatar?: boolean;
101
+ sort_packages?: string;
102
+ darkMode?: boolean;
103
+ url_prefix?: string;
104
+ language?: string;
105
+ login?: boolean;
106
+ scope?: string;
107
+ pkgManagers?: PackageManagers[];
108
+ };
109
+
110
+ /**
111
+ * Options are passed to the index.html
112
+ */
113
+ export type TemplateUIOptions = {
114
+ uri?: string;
115
+ darkMode?: boolean;
116
+ protocol?: string;
117
+ host?: string;
118
+ // deprecated
119
+ basename?: string;
120
+ scope?: string;
121
+ showInfo?: boolean;
122
+ showSettings?: boolean;
123
+ showSearch?: boolean;
124
+ showFooter?: boolean;
125
+ showThemeSwitch?: boolean;
126
+ showDownloadTarball?: boolean;
127
+ showRaw?: boolean;
128
+ base: string;
129
+ primaryColor?: string;
130
+ version?: string;
131
+ logoURI?: string;
132
+ flags: FlagsConfig;
133
+ } & CommonWebConf;
134
+
135
+ /**
136
+ * Options on config.yaml for web
137
+ */
138
+ export type WebConf = {
139
+ // FIXME: rename to primaryColor and move it to CommonWebConf
140
+ primary_color?: string;
141
+ enable?: boolean;
142
+ scriptsHead?: string[];
143
+ scriptsBodyAfter?: string[];
144
+ metaScripts?: string[];
145
+ bodyBefore?: string[];
146
+ bodyAfter?: string[];
147
+ } & CommonWebConf;
148
+
149
+ export interface UpLinksConfList {
150
+ [key: string]: UpLinkConf;
151
+ }
152
+
153
+ export interface AuthHtpasswd {
154
+ file: string;
155
+ max_users: number;
156
+ }
157
+
158
+ export type AuthConf = any | AuthHtpasswd;
159
+
160
+ export interface JWTOptions {
161
+ sign: JWTSignOptions;
162
+ verify: JWTVerifyOptions;
163
+ }
164
+
165
+ export interface JWTSignOptions {
166
+ algorithm?: string;
167
+ expiresIn?: string;
168
+ notBefore?: string;
169
+ ignoreExpiration?: boolean;
170
+ maxAge?: string | number;
171
+ clockTimestamp?: number;
172
+ }
173
+
174
+ export interface JWTVerifyOptions {
175
+ algorithm?: string;
176
+ expiresIn?: string;
177
+ notBefore?: string | number;
178
+ ignoreExpiration?: boolean;
179
+ maxAge?: string | number;
180
+ clockTimestamp?: number;
181
+ }
182
+
183
+ export interface APITokenOptions {
184
+ legacy: boolean;
185
+ jwt?: JWTOptions;
186
+ }
187
+
188
+ export interface Security {
189
+ web: JWTOptions;
190
+ api: APITokenOptions;
191
+ }
192
+
193
+ export interface PublishOptions {
194
+ allow_offline: boolean;
195
+ }
196
+
197
+ export interface ListenAddress {
198
+ [key: string]: string;
199
+ }
200
+
201
+ export interface HttpsConfKeyCert {
202
+ key: string;
203
+ cert: string;
204
+ ca?: string;
205
+ }
206
+
207
+ export interface HttpsConfPfx {
208
+ pfx: string;
209
+ passphrase?: string;
210
+ }
211
+
212
+ export type HttpsConf = HttpsConfKeyCert | HttpsConfPfx;
213
+
214
+ export interface Notifications {
215
+ method: string;
216
+ packagePattern: RegExp;
217
+ packagePatternFlags: string;
218
+ endpoint: string;
219
+ content: string;
220
+ headers: Headers;
221
+ }
222
+
223
+ export type Notification = Notifications;
224
+
225
+ export type ServerSettingsConf = {
226
+ // express-rate-limit settings
227
+ rateLimit: RateLimit;
228
+ keepAliveTimeout?: number;
229
+ };
230
+
231
+ /**
232
+ * YAML configuration file available options.
233
+ */
234
+ export interface ConfigYaml {
235
+ _debug?: boolean;
236
+ storage?: string | void;
237
+ packages: PackageList;
238
+ uplinks: UpLinksConfList;
239
+ log?: LoggerConfItem;
240
+ web?: WebConf;
241
+ auth?: AuthConf;
242
+ security: Security;
243
+ publish?: PublishOptions;
244
+ store?: any;
245
+ listen?: ListenAddress;
246
+ https?: HttpsConf;
247
+ http_proxy?: string;
248
+ plugins?: string | void;
249
+ https_proxy?: string;
250
+ no_proxy?: string;
251
+ max_body_size?: string;
252
+ notifications?: Notifications;
253
+ notify?: Notifications | Notifications[];
254
+ middlewares?: any;
255
+ filters?: any;
256
+ url_prefix?: string;
257
+ server?: ServerSettingsConf;
258
+ flags?: FlagsConfig;
259
+ // internal objects, added by internal yaml to JS config parser
260
+ // @deprecated use configPath instead
261
+ config_path?: string;
262
+ // save the configuration file path
263
+ configPath?: string;
264
+ }
265
+
266
+ /**
267
+ * Configuration object with additonal methods for configuration, includes yaml and internal medatada.
268
+ * @interface Config
269
+ * @extends {ConfigYaml}
270
+ */
271
+ export interface Config extends Omit<ConfigYaml, 'packages' | 'security' | 'configPath'> {
272
+ user_agent: string;
273
+ server_id: string;
274
+ secret: string;
275
+ // save the configuration file path, it's fails without thi configPath
276
+ configPath: string;
277
+ // packages from yaml file looks different from packages inside the config file
278
+ packages: PackageList;
279
+ // security object defaults is added by the config file but optional in the yaml file
280
+ security: Security;
281
+ // @deprecated (pending adding the replacement)
282
+ checkSecretKey(token: string): string;
283
+ getMatchedPackagesSpec(storage: string): PackageAccess | void;
284
+ // TODO: verify how to handle this in the future
285
+ [key: string]: any;
286
+ }
287
+
288
+ export interface AllowAccess {
289
+ name: string;
290
+ version?: string;
291
+ tag?: string;
292
+ }
293
+
294
+ // info passed to the auth plugin when a package is package is being published
295
+
296
+ export interface AuthPackageAllow extends PackageAccess, AllowAccess {}