@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,217 @@
1
+ export interface PackageAccess {
2
+ storage?: string;
3
+ publish?: string[];
4
+ proxy?: string[];
5
+ access?: string[];
6
+ unpublish: string[];
7
+ }
8
+
9
+ export interface PackageList {
10
+ [key: string]: PackageAccess;
11
+ }
12
+
13
+ export interface MergeTags {
14
+ [key: string]: string;
15
+ }
16
+
17
+ export interface DistFile {
18
+ url: string;
19
+ sha: string;
20
+ registry?: string;
21
+ }
22
+
23
+ export interface DistFiles {
24
+ [key: string]: DistFile;
25
+ }
26
+
27
+ export interface Token {
28
+ user: string;
29
+ token: string;
30
+ key: string;
31
+ cidr?: string[];
32
+ readonly: boolean;
33
+ created: number | string;
34
+ updated?: number | string;
35
+ }
36
+
37
+ export interface AttachMents {
38
+ [key: string]: AttachMentsItem;
39
+ }
40
+
41
+ export interface AttachMentsItem {
42
+ content_type?: string;
43
+ data?: string;
44
+ length?: number;
45
+ shasum?: string;
46
+ version?: string;
47
+ }
48
+
49
+ export interface GenericBody {
50
+ [key: string]: string;
51
+ }
52
+
53
+ export interface UpLinkMetadata {
54
+ etag: string;
55
+ fetched: number;
56
+ }
57
+
58
+ export interface UpLinks {
59
+ [key: string]: UpLinkMetadata;
60
+ }
61
+
62
+ export interface Signatures {
63
+ keyid: string;
64
+ sig: string;
65
+ }
66
+
67
+ export interface Dist {
68
+ 'npm-signature'?: string;
69
+ signatures?: Signatures[];
70
+ fileCount?: number;
71
+ integrity?: string;
72
+ shasum: string;
73
+ unpackedSize?: number;
74
+ tarball: string;
75
+ }
76
+
77
+ export interface Author {
78
+ username?: string;
79
+ name: string;
80
+ email?: string;
81
+ url?: string;
82
+ }
83
+
84
+ export interface PackageUsers {
85
+ [key: string]: boolean;
86
+ }
87
+
88
+ export interface Tags {
89
+ [key: string]: Version;
90
+ }
91
+
92
+ export 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
+ export interface Versions {
127
+ [key: string]: Version;
128
+ }
129
+
130
+ /**
131
+ * @deprecated use Manifest instead
132
+ */
133
+ export interface Package {
134
+ _id?: string;
135
+ name: string;
136
+ versions: Versions;
137
+ 'dist-tags': GenericBody;
138
+ time: GenericBody;
139
+ readme?: string;
140
+ users?: PackageUsers;
141
+ _distfiles: DistFiles;
142
+ _attachments: AttachMents;
143
+ _uplinks: UpLinks;
144
+ _rev: string;
145
+ }
146
+
147
+ /**
148
+ * Represents upstream manifest from another registry
149
+ */
150
+ export interface FullRemoteManifest {
151
+ _id?: string;
152
+ _rev?: string;
153
+ name: string;
154
+ description?: string;
155
+ 'dist-tags': GenericBody;
156
+ time: GenericBody;
157
+ versions: Versions;
158
+ maintainers?: Author[];
159
+ /** store the latest readme **/
160
+ readme?: string;
161
+ /** store star assigned to this packages by users */
162
+ users?: PackageUsers;
163
+ // TODO: not clear what access exactly means
164
+ access?: any;
165
+ bugs?: { url: string };
166
+ license?: string;
167
+ homepage?: string;
168
+ repository?: string | { type?: string; url: string; directory?: string };
169
+ keywords?: string[];
170
+ }
171
+
172
+ export interface Manifest extends FullRemoteManifest, PublishManifest {
173
+ // private fields only used by verdaccio
174
+ /**
175
+ * store fast access to the dist url of an specific tarball, instead search version
176
+ * by id, just the tarball id is faster.
177
+ *
178
+ * The _distfiles is created only when a package is being sync from an upstream.
179
+ * also used to fetch tarballs from upstream, the private publish tarballs are not stored in
180
+ * this object because they are not published in the upstream registry.
181
+ */
182
+ _distfiles: DistFiles;
183
+ /**
184
+ * Store access cache metadata, to avoid to fetch the same metadata multiple times.
185
+ *
186
+ * The key represents the uplink id which is composed of a etag and a fetched timestamp.
187
+ *
188
+ * The fetched timestamp is the time when the metadata was fetched, used to avoid to fetch the
189
+ * same metadata until the metadata is older than the last fetch.
190
+ */
191
+ _uplinks: UpLinks;
192
+ /**
193
+ * store the revision of the manifest
194
+ */
195
+ _rev: string;
196
+ }
197
+ export interface PublishManifest {
198
+ /**
199
+ * The `_attachments` object has different usages:
200
+ *
201
+ * - When a package is published, it contains the tarball as an string, this string is used to be
202
+ * converted as a tarball, usually attached to the package but not stored in the database.
203
+ * - If user runs `npm star` the _attachments will be at the manifest body but empty.
204
+ *
205
+ * It has also an internal usage:
206
+ *
207
+ * - Used as a cache for the tarball, quick access to the tarball shasum, etc. Instead
208
+ * iterate versions and find the right one, just using the tarball as a key which is what
209
+ * the package manager sends to the registry.
210
+ *
211
+ * - A `_attachments` object is added every time a private tarball is published, upstream cached tarballs are
212
+ * not being part of this object, only for published private packages.
213
+ *
214
+ * Note: This field is removed when the package is accesed through the web user interface.
215
+ * */
216
+ _attachments: AttachMents;
217
+ }
@@ -0,0 +1,22 @@
1
+ import { Callback, HttpError, RemoteUser } from '../commons';
2
+ import { Config } from '../configuration';
3
+
4
+ export interface AuthPluginPackage {
5
+ packageName: string;
6
+ packageVersion?: string;
7
+ tag?: string;
8
+ }
9
+
10
+ export type AuthError = HttpError & { code: number };
11
+ export type AuthAccessCallback = (error: AuthError | null, access: boolean) => void;
12
+ export type AuthCallback = (error: AuthError | null, groups: string[] | false) => void;
13
+
14
+ // @deprecated use IBasicAuth from @verdaccio/auth
15
+ export interface IBasicAuth<T> {
16
+ config: T & Config;
17
+ aesEncrypt(buf: Buffer): Buffer;
18
+ authenticate(user: string, password: string, cb: Callback): void;
19
+ changePassword(user: string, password: string, newPassword: string, cb: Callback): void;
20
+ allow_access(pkg: AuthPluginPackage, user: RemoteUser, callback: Callback): void;
21
+ add_user(user: string, password: string, cb: Callback): any;
22
+ }
@@ -0,0 +1,15 @@
1
+ import { Config, Logger } from '../configuration';
2
+
3
+ export class Plugin<T> {
4
+ public constructor(config: T, options: PluginOptions<T>) {}
5
+ }
6
+
7
+ export interface IPlugin<T> {
8
+ // TODO: not used on core yet
9
+ version?: string;
10
+ }
11
+
12
+ export interface PluginOptions<T> {
13
+ config: T & Config;
14
+ logger: Logger;
15
+ }
@@ -0,0 +1,6 @@
1
+ import { Manifest } from '../manifest';
2
+ import { IPlugin } from './commons';
3
+
4
+ export interface IPluginStorageFilter<T> extends IPlugin<T> {
5
+ filter_metadata(packageInfo: Manifest): Promise<Manifest>;
6
+ }
@@ -0,0 +1,31 @@
1
+ import { RemoteUser } from '../commons';
2
+ import { AllowAccess } from '../configuration';
3
+ import { PackageAccess } from '../manifest';
4
+ import { AuthAccessCallback, AuthCallback } from './auth';
5
+ import { IPlugin } from './commons';
6
+
7
+ export interface IPluginAuth<T> extends IPlugin<T> {
8
+ /**
9
+ * @param props user from Application component
10
+ */
11
+ authenticate(user: string, password: string, cb: AuthCallback): void;
12
+ adduser?(user: string, password: string, cb: AuthCallback): void;
13
+ changePassword?(user: string, password: string, newPassword: string, cb: AuthCallback): void;
14
+ allow_publish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
15
+ allow_access?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
16
+ allow_unpublish?(user: RemoteUser, pkg: T & PackageAccess, cb: AuthAccessCallback): void;
17
+ allow_publish?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
18
+ allow_access?(user: RemoteUser, pkg: AllowAccess & PackageAccess, cb: AuthAccessCallback): void;
19
+ allow_unpublish?(
20
+ user: RemoteUser,
21
+ pkg: AllowAccess & PackageAccess,
22
+ cb: AuthAccessCallback
23
+ ): void;
24
+ apiJWTmiddleware?(helpers: any): Function;
25
+ }
26
+
27
+ export * from './auth';
28
+ export * from './storage';
29
+ export * from './middleware';
30
+ export * from './commons';
31
+ export * from './filter';
@@ -0,0 +1,8 @@
1
+ import { Config } from '../configuration';
2
+ import { IBasicAuth } from './auth';
3
+ import { IPlugin } from './commons';
4
+
5
+ // TODO: convert to generic storage should come from implementation
6
+ export interface IPluginMiddleware<T, K> extends IPlugin<T> {
7
+ register_middlewares(app: any, auth: IBasicAuth<T>, storage: K): void;
8
+ }
@@ -0,0 +1,95 @@
1
+ import { PassThrough, PipelinePromise, Readable, Stream, Writable } from 'stream';
2
+
3
+ import { Callback, CallbackAction, StringValue } from '../commons';
4
+ import { Config, Logger } from '../configuration';
5
+ import { Manifest, MergeTags, Token, Version } from '../manifest';
6
+ import { IPlugin } from './commons';
7
+
8
+ export type StorageList = string[];
9
+
10
+ export interface LocalStorage {
11
+ list: any;
12
+ secret: string;
13
+ }
14
+
15
+ export interface ILocalStorage {
16
+ add(name: string): void;
17
+ remove(name: string): void;
18
+ get(): StorageList;
19
+ sync(): void;
20
+ }
21
+
22
+ export interface TokenFilter {
23
+ user: string;
24
+ }
25
+
26
+ export interface ITokenActions {
27
+ saveToken(token: Token): Promise<any>;
28
+ deleteToken(user: string, tokenKey: string): Promise<any>;
29
+ readTokens(filter: TokenFilter): Promise<Token[]>;
30
+ }
31
+
32
+ /**
33
+ * This method expect return a Package object
34
+ * eg:
35
+ * {
36
+ * name: string;
37
+ * time: number;
38
+ * ... and other props
39
+ * }
40
+ *
41
+ * The `cb` callback object will be executed if:
42
+ * - it might return object (truly)
43
+ * - it might reutrn null
44
+ */
45
+ export type onSearchPackage = (item: Manifest, cb: CallbackAction) => void;
46
+ // FIXME: error should be export type `VerdaccioError = HttpError & { code: number };`
47
+ // but this type is on @verdaccio/commons-api and cannot be used here yet
48
+ export type onEndSearchPackage = (error?: any) => void;
49
+ export type onValidatePackage = (name: string) => boolean;
50
+
51
+ export type StorageUpdateCallback = (data: Manifest, cb: CallbackAction) => void;
52
+
53
+ export type StorageWriteCallback = (name: string, json: Manifest, callback: Callback) => void;
54
+ export type PackageTransformer = (pkg: Manifest) => Manifest;
55
+ export type ReadPackageCallback = (err: any | null, data?: Manifest) => void;
56
+
57
+ export interface ILocalPackageManager {
58
+ logger: Logger;
59
+ deletePackage(fileName: string): Promise<void>;
60
+ removePackage(): Promise<void>;
61
+ // next packages migration (this list is meant to replace the callback parent functions)
62
+ updatePackage(
63
+ packageName: string,
64
+ handleUpdate: (manifest: Manifest) => Promise<Manifest>
65
+ ): Promise<Manifest>;
66
+ readPackage(name: string): Promise<Manifest>;
67
+ savePackage(pkgName: string, value: Manifest): Promise<void>;
68
+ readTarball(pkgName: string, { signal }): Promise<Readable>;
69
+ createPackage(name: string, manifest: Manifest): Promise<void>;
70
+ writeTarball(tarballName: string, { signal }): Promise<Writable>;
71
+ // verify if tarball exist in the storage
72
+ hasTarball(fileName: string): Promise<boolean>;
73
+ // verify if package exist in the storage
74
+ hasPackage(): Promise<boolean>;
75
+ }
76
+
77
+ export type IPackageStorage = ILocalPackageManager | void;
78
+
79
+ export type IPluginStorage<T> = ILocalData<T>;
80
+ export type IPackageStorageManager = ILocalPackageManager;
81
+
82
+ /**
83
+ * @deprecated use @verdaccio/core pluginUtils instead
84
+ */
85
+ interface ILocalData<T> extends IPlugin<T>, ITokenActions {
86
+ logger: Logger;
87
+ config: T & Config;
88
+ add(name: string): Promise<void>;
89
+ remove(name: string): Promise<void>;
90
+ get(): Promise<any>;
91
+ init(): Promise<void>;
92
+ getSecret(): Promise<string>;
93
+ setSecret(secret: string): Promise<any>;
94
+ getPackageStorage(packageInfo: string): IPackageStorage;
95
+ }
File without changes
package/src/search.ts ADDED
@@ -0,0 +1,28 @@
1
+ export type PublisherMaintainer = {
2
+ username: string;
3
+ email: string;
4
+ };
5
+
6
+ export type SearchPackageBody = {
7
+ name: string;
8
+ scope: string;
9
+ description: string;
10
+ author: string | PublisherMaintainer;
11
+ version: string;
12
+ keywords: string | string[] | undefined;
13
+ date: string;
14
+ links?: {
15
+ npm: string; // only include placeholder for URL eg: {url}/{packageName}
16
+ homepage?: string;
17
+ repository?: string;
18
+ bugs?: string;
19
+ };
20
+ publisher?: any;
21
+ maintainers?: PublisherMaintainer[];
22
+ };
23
+
24
+ export type SearchResultWeb = {
25
+ name: string;
26
+ version: string;
27
+ description: string;
28
+ };
package/src/types.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from './plugins';
2
+ export * from './manifest';
3
+ export * from './search';
4
+ export * from './commons';
5
+ export * from './configuration';
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["src/**/*.test.ts"]
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../../tsconfig.reference.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./build"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["src/**/*.test.ts"]
9
+ }
package/typedoc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["src/types.ts"],
4
+ "sort": ["source-order"]
5
+ }