verdaccio 6.7.3 → 6.8.0

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.
@@ -11,95 +11,160 @@ declare class Storage {
11
11
  uplinks: Record<string, ProxyStorage>;
12
12
  filters: IPluginFilters | undefined;
13
13
  constructor(config: Config);
14
+ /**
15
+ * Initialize the storage: load the storage plugin (or the default
16
+ * local storage) and the filter plugins. Safe to call once; subsequent
17
+ * calls only reload missing filters.
18
+ * @param {Config} config verdaccio configuration
19
+ * @param {IPluginFilters} filters preloaded filter plugins; when omitted they are loaded from the configuration
20
+ */
14
21
  init(config: Config, filters?: IPluginFilters): Promise<void>;
22
+ /**
23
+ * Resolve the storage backend: a configured storage plugin when available,
24
+ * otherwise the default `@verdaccio/local-storage` on the configured path.
25
+ * @return {Promise<StoragePlugin>} the storage plugin instance
26
+ */
15
27
  private loadStorage;
28
+ /**
29
+ * Load the storage plugins declared under `store` in the configuration.
30
+ * Only one storage is supported: with several plugins configured the
31
+ * first loaded one wins and a warning is logged.
32
+ * @return {Promise<StoragePluginLegacy<Config> | undefined>} the selected plugin, or undefined when none is configured
33
+ */
16
34
  private loadStorePlugin;
17
35
  /**
18
- * Add a {name} package to a system
19
- Function checks if package with the same name is available from uplinks.
20
- If it isn't, we create package locally
21
- Used storages: local (write) && uplinks
36
+ * Add a package to the system (publish flow).
37
+ * Verifies the package does not exist locally nor on any uplink before
38
+ * creating it locally; uplinks being offline rejects the publish unless
39
+ * `publish.allow_offline` is enabled.
40
+ * Used storages: local (write) && uplinks
41
+ * @param {String} name package name
42
+ * @param {Object} metadata package manifest to publish
43
+ * @param {Function} callback invoked with an error when the publish is rejected
22
44
  */
23
45
  addPackage(name: string, metadata: any, callback: any): Promise<void>;
46
+ /**
47
+ * Whether `publish.allow_offline` is enabled in the configuration.
48
+ * @return {Boolean} true when publishing with unreachable uplinks is allowed
49
+ */
24
50
  private _isAllowPublishOffline;
51
+ /**
52
+ * Read the npm tokens matching the filter from the token storage.
53
+ * Used storages: local (read)
54
+ */
25
55
  readTokens(filter: TokenFilter): Promise<Token[]>;
56
+ /**
57
+ * Save an npm token to the token storage.
58
+ * Used storages: local (write)
59
+ */
26
60
  saveToken(token: Token): Promise<void>;
61
+ /**
62
+ * Delete an npm token from the token storage.
63
+ * Used storages: local (write)
64
+ */
27
65
  deleteToken(user: string, tokenKey: string): Promise<any>;
28
66
  /**
29
- * Add a new version of package {name} to a system
30
- Used storages: local (write)
67
+ * Add a new version of a package to the system.
68
+ * Used storages: local (write)
69
+ * @param {String} name package name
70
+ * @param {String} version version id, eg. 1.0.0
71
+ * @param {Version} metadata version metadata
72
+ * @param {String} tag dist-tag pointing to the version
73
+ * @param {Function} callback
31
74
  */
32
75
  addVersion(name: string, version: string, metadata: Version, tag: StringValue, callback: Callback): void;
33
76
  /**
34
- * Tags a package version with a provided tag
35
- Used storages: local (write)
77
+ * Tag package versions with the provided dist-tags.
78
+ * Used storages: local (write)
79
+ * @param {String} name package name
80
+ * @param {MergeTags} tagHash dist-tag to version mapping to merge
81
+ * @param {Function} callback
36
82
  */
37
83
  mergeTags(name: string, tagHash: MergeTags, callback: Callback): void;
38
84
  /**
39
- * Change an existing package (i.e. unpublish one version)
40
- Function changes a package info from local storage and all uplinks with write access./
41
- Used storages: local (write)
85
+ * Change an existing package (eg. unpublish one version).
86
+ * Used storages: local (write)
87
+ * @param {String} name package name
88
+ * @param {Manifest} metadata updated package manifest
89
+ * @param {String} revision expected revision of the stored manifest
90
+ * @param {Function} callback
42
91
  */
43
92
  changePackage(name: string, metadata: Manifest, revision: string, callback: Callback): void;
44
93
  /**
45
- * Remove a package from a system
46
- Function removes a package from local storage
47
- Used storages: local (write)
94
+ * Remove a package from the local storage and the search indexer.
95
+ * Used storages: local (write)
96
+ * @param {String} name package name
97
+ * @param {Function} callback
48
98
  */
49
99
  removePackage(name: string, callback: Callback): void;
50
100
  /**
51
- Remove a tarball from a system
52
- Function removes a tarball from local storage.
53
- Tarball in question should not be linked to in any existing
54
- versions, i.e. package version should be unpublished first.
55
- Used storage: local (write)
101
+ * Remove a tarball from the local storage. The tarball must not be
102
+ * linked by any existing version, ie. the version should be
103
+ * unpublished first.
104
+ * Used storages: local (write)
105
+ * @param {String} name package name
106
+ * @param {String} filename tarball file name
107
+ * @param {String} revision expected revision of the stored manifest
108
+ * @param {Function} callback
56
109
  */
57
110
  removeTarball(name: string, filename: string, revision: string, callback: Callback): void;
58
111
  /**
59
- * Upload a tarball for {name} package
60
- Function is synchronous and returns a WritableStream
61
- Used storages: local (write)
112
+ * Upload a tarball (publish flow). Synchronous, returns a writable
113
+ * stream the tarball body is piped into.
114
+ * Used storages: local (write)
115
+ * @param {String} name package name
116
+ * @param {String} filename tarball file name
117
+ * @return {Stream} writable upload stream
62
118
  */
63
119
  addTarball(name: string, filename: string): import("@verdaccio/streams").UploadTarball;
120
+ /**
121
+ * Whether a tarball exists in the local storage, without reading it
122
+ * (the stream is aborted as soon as it opens).
123
+ * Used storages: local (read)
124
+ * @param {String} name package name
125
+ * @param {String} filename tarball file name
126
+ * @return {Promise<Boolean>} true when the tarball is stored locally
127
+ */
64
128
  hasLocalTarball(name: string, filename: string): Promise<boolean>;
65
129
  /**
66
- Get a tarball from a storage for {name} package
67
- Function is synchronous and returns a ReadableStream
68
- Function tries to read tarball locally, if it fails then it reads package
69
- information in order to figure out where we can get this tarball from
70
- Used storages: local || uplink (just one)
130
+ * Get a tarball. Synchronous, returns a readable stream.
131
+ * The tarball is read locally first; on a local miss the distfile record
132
+ * is resolved from the package metadata (see lookupDistFile), syncing the
133
+ * uplinks when the local metadata does not know the file, and the tarball
134
+ * is then fetched from the uplink that serves the distfile url.
135
+ * Used storages: local || uplink (just one)
136
+ * @param {String} name package name
137
+ * @param {String} filename tarball file name
138
+ * @return {Stream} readable tarball stream
71
139
  */
72
140
  getTarball(name: string, filename: string): ReadTarball;
73
141
  /**
74
- Retrieve a package metadata for {name} package
75
- Function invokes localStorage.getPackage and uplink.get_package for every
76
- uplink with proxy_access rights against {name} and combines results
77
- into one json object
78
- Used storages: local && uplink (proxy_access)
79
-
80
- * @param {object} options
81
- * @property {string} options.name Package Name
82
- * @property {object} options.req Express `req` object
83
- * @property {boolean} options.keepUpLinkData keep up link info in package meta, last update, etc.
84
- * @property {function} options.callback Callback for receive data
142
+ * Retrieve the package metadata: the local manifest merged with the
143
+ * manifest of every uplink with proxy access to the package.
144
+ * Used storages: local && uplink (proxy_access)
145
+ * @param {Object} options
146
+ * @property {String} options.name package name
147
+ * @property {Object} options.req Express `req` object
148
+ * @property {Boolean} options.keepUpLinkData keep the uplink info (last update, etc.) in the package metadata
149
+ * @property {Boolean} options.abbreviated serve the abbreviated manifest (npm install)
150
+ * @property {Function} options.callback invoked with the merged manifest and any uplink errors
85
151
  */
86
152
  getPackage(options: any): void;
87
153
  /**
88
- Retrieve remote and local packages more recent than {startkey}
89
- Function streams all packages from all uplinks first, and then
90
- local packages.
91
- Note that local packages could override registry ones just because
92
- they appear in JSON last. That's a trade-off we make to avoid
93
- memory issues.
94
- Used storages: local && uplink (proxy_access)
95
- * @param {*} startkey
96
- * @param {*} options
97
- * @return {Stream}
154
+ * Retrieve remote and local packages more recent than the start key.
155
+ * All uplinks are streamed first, then the local packages; local
156
+ * packages can override registry ones just because they appear in the
157
+ * JSON last — a trade-off made to avoid memory issues.
158
+ * Used storages: local && uplink (proxy_access)
159
+ * @param {String} startkey timestamp to search from
160
+ * @param {Object} options request options; `local=1` in the query skips the uplinks
161
+ * @return {Stream} object stream of search results
98
162
  */
99
163
  search(startkey: string, options: any): any;
100
164
  /**
101
- * Retrieve only private local packages
102
- * @param {*} callback
165
+ * Retrieve only private local packages, as the latest version of each.
166
+ * Used storages: local (read)
167
+ * @param {Function} callback invoked with the list of latest versions
103
168
  */
104
169
  getLocalDatabase(callback: Callback): void;
105
170
  /**
@@ -107,9 +172,13 @@ declare class Storage {
107
172
  */
108
173
  private _collectLocalPackages;
109
174
  /**
110
- * Function fetches package metadata from uplinks and synchronizes it with local data
111
- if package is available locally, it MUST be provided in pkginfo
112
- returns callback(err, result, uplink_errors)
175
+ * Fetch the package metadata from every uplink with proxy access and
176
+ * synchronize it with the local data; filter plugins are applied to the
177
+ * merged result.
178
+ * @param {String} name package name
179
+ * @param {Manifest} packageInfo local manifest; MUST be provided when the package exists locally
180
+ * @param {ISyncUplinks} options uplink request options
181
+ * @param {Function} callback invoked with (err, mergedManifest, uplinkErrors)
113
182
  */
114
183
  _syncUplinksMetadata(name: string, packageInfo: Manifest, options: ISyncUplinks, callback: Callback): void;
115
184
  /**
@@ -126,10 +195,11 @@ declare class Storage {
126
195
  */
127
196
  private _isTarballAllowedByFilters;
128
197
  /**
129
- * Set a hidden value for each version.
130
- * @param {Array} versions list of version
131
- * @param {String} upLink uplink name
132
- * @private
198
+ * Tag each version with the uplink it was fetched from, under a hidden
199
+ * (symbol) key. The local storage uses the tag to record the registry
200
+ * on the distfile records it creates.
201
+ * @param {Versions} versions versions fetched from the uplink
202
+ * @param {ProxyStorage} upLink uplink the versions were fetched from
133
203
  */
134
204
  _updateVersionsHiddenUpLink(versions: Versions, upLink: ProxyStorage): void;
135
205
  }