@verdaccio/store 6.0.0-6-next.27 → 6.0.0-6-next.29

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,106 @@
1
1
  # @verdaccio/store
2
2
 
3
+ ## 6.0.0-6-next.29
4
+
5
+ ### Minor Changes
6
+
7
+ - ce013d2f: refactor: npm star command support reimplemented
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ce013d2f]
12
+ - @verdaccio/url@11.0.0-6-next.15
13
+ - @verdaccio/tarball@11.0.0-6-next.18
14
+ - @verdaccio/local-storage@11.0.0-6-next.19
15
+ - @verdaccio/core@6.0.0-6-next.49
16
+ - @verdaccio/config@6.0.0-6-next.49
17
+ - @verdaccio/hooks@6.0.0-6-next.19
18
+ - @verdaccio/loaders@6.0.0-6-next.18
19
+ - @verdaccio/logger@6.0.0-6-next.17
20
+ - @verdaccio/proxy@6.0.0-6-next.27
21
+ - @verdaccio/utils@6.0.0-6-next.17
22
+
23
+ ## 6.0.0-6-next.28
24
+
25
+ ### Major Changes
26
+
27
+ - 9fc2e796: feat(plugins): improve plugin loader
28
+
29
+ ### Changes
30
+
31
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
32
+ - Avoid config collisions https://github.com/verdaccio/verdaccio/issues/928
33
+ - https://github.com/verdaccio/verdaccio/issues/1394
34
+ - `config.plugins` plugin path validations
35
+ - Updated algorithm for plugin loader.
36
+ - improved documentation (included dev)
37
+
38
+ ## Features
39
+
40
+ - Add scope plugin support to 6.x https://github.com/verdaccio/verdaccio/pull/3227
41
+ - Custom prefix:
42
+
43
+ ```
44
+ // config.yaml
45
+ server:
46
+ pluginPrefix: mycompany
47
+ middleware:
48
+ audit:
49
+ foo: 1
50
+ ```
51
+
52
+ This configuration will look up for `mycompany-audit` instead `Verdaccio-audit`.
53
+
54
+ ## Breaking Changes
55
+
56
+ ### sinopia plugins
57
+
58
+ - `sinopia` fallback support is removed, but can be restored using `pluginPrefix`
59
+
60
+ ### plugin filter
61
+
62
+ - method rename `filter_metadata`->`filterMetadata`
63
+
64
+ ### Plugin constructor does not merge configs anymore https://github.com/verdaccio/verdaccio/issues/928
65
+
66
+ The plugin receives as first argument `config`, which represents the config of the plugin. Example:
67
+
68
+ ```
69
+ // config.yaml
70
+ auth:
71
+ plugin:
72
+ foo: 1
73
+ bar: 2
74
+
75
+ export class Plugin<T> {
76
+ public constructor(config: T, options: PluginOptions) {
77
+ console.log(config);
78
+ // {foo:1, bar: 2}
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### Minor Changes
84
+
85
+ - 62c24b63: feat: add passwordValidationRegex property
86
+
87
+ ### Patch Changes
88
+
89
+ - 43f32687: fix: abbreviated headers handle quality values
90
+ - Updated dependencies [43f32687]
91
+ - Updated dependencies [9fc2e796]
92
+ - Updated dependencies [62c24b63]
93
+ - @verdaccio/core@6.0.0-6-next.48
94
+ - @verdaccio/config@6.0.0-6-next.48
95
+ - @verdaccio/loaders@6.0.0-6-next.17
96
+ - @verdaccio/local-storage@11.0.0-6-next.18
97
+ - @verdaccio/utils@6.0.0-6-next.16
98
+ - @verdaccio/tarball@11.0.0-6-next.17
99
+ - @verdaccio/url@11.0.0-6-next.14
100
+ - @verdaccio/hooks@6.0.0-6-next.18
101
+ - @verdaccio/logger@6.0.0-6-next.16
102
+ - @verdaccio/proxy@6.0.0-6-next.26
103
+
3
104
  ## 6.0.0-6-next.27
4
105
 
5
106
  ### Patch Changes
@@ -1,14 +1,16 @@
1
- import { Manifest } from '@verdaccio/types';
2
- import { Users } from '../type';
1
+ import { Manifest, PackageUsers } from '@verdaccio/types';
3
2
  /**
4
- * Check whether the package metadta has enough data to be published
3
+ * Check whether the package metadata has enough data to be published
5
4
  * @param pkg metadata
6
5
  */
6
+ export declare function isPublishablePackage(pkg: Manifest): boolean;
7
7
  /**
8
- * Check whether the package metadta has enough data to be published
9
- * @param pkg metadata
8
+ * Verify if the user is actually executing an action, to avoid unnecessary calls
9
+ * to the storage.
10
+ * @param localUsers current state at cache
11
+ * @param username user is executing the action
12
+ * @param userIsAddingStar whether user is removing or adding star
13
+ * @returns boolean
10
14
  */
11
- export declare function isPublishablePackage(pkg: Manifest): boolean;
12
- export declare function isRelatedToDeprecation(pkgInfo: Manifest): boolean;
13
- export declare function validateInputs(localUsers: Users, username: string, isStar: boolean): boolean;
15
+ export declare function isExecutingStarCommand(localUsers: PackageUsers, username: string, userIsAddingStar: boolean): boolean;
14
16
  export declare function isStarManifest(manifest: Manifest): boolean;
@@ -3,59 +3,43 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.isExecutingStarCommand = isExecutingStarCommand;
6
7
  exports.isPublishablePackage = isPublishablePackage;
7
- exports.isRelatedToDeprecation = isRelatedToDeprecation;
8
8
  exports.isStarManifest = isStarManifest;
9
- exports.validateInputs = validateInputs;
10
-
11
- var _lodash = _interopRequireDefault(require("lodash"));
12
9
 
13
10
  var _core = require("@verdaccio/core");
14
11
 
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
12
  /**
18
- * Check whether the package metadta has enough data to be published
19
- * @param pkg metadata
20
- */
21
-
22
- /**
23
- * Check whether the package metadta has enough data to be published
13
+ * Check whether the package metadata has enough data to be published
24
14
  * @param pkg metadata
25
15
  */
26
16
  function isPublishablePackage(pkg) {
27
17
  // TODO: we can do better, no need get keys
28
18
  const keys = Object.keys(pkg);
29
19
  return keys.includes('versions');
30
- } // @deprecated don't think this is used anymore (REMOVE)
31
-
32
-
33
- function isRelatedToDeprecation(pkgInfo) {
34
- const {
35
- versions
36
- } = pkgInfo;
37
-
38
- for (const version in versions) {
39
- if (Object.prototype.hasOwnProperty.call(versions[version], 'deprecated')) {
40
- return true;
41
- }
42
- }
43
-
44
- return false;
45
20
  }
21
+ /**
22
+ * Verify if the user is actually executing an action, to avoid unnecessary calls
23
+ * to the storage.
24
+ * @param localUsers current state at cache
25
+ * @param username user is executing the action
26
+ * @param userIsAddingStar whether user is removing or adding star
27
+ * @returns boolean
28
+ */
29
+
46
30
 
47
- function validateInputs(localUsers, username, isStar) {
48
- const isExistlocalUsers = _lodash.default.isNil(localUsers[username]) === false;
31
+ function isExecutingStarCommand(localUsers, username, userIsAddingStar) {
32
+ const isExist = typeof localUsers[username] !== 'undefined'; // fails if user already exist and us trying to add star.
49
33
 
50
- if (isStar && isExistlocalUsers && localUsers[username]) {
51
- return true;
52
- } else if (!isStar && isExistlocalUsers) {
34
+ if (userIsAddingStar && isExist && localUsers[username]) {
35
+ return false; // if is not adding a start but user exists (removing star)
36
+ } else if (!userIsAddingStar && isExist) {
37
+ return true; // fails if user does not exist and is not adding any star
38
+ } else if (!userIsAddingStar && !isExist) {
53
39
  return false;
54
- } else if (!isStar && !isExistlocalUsers) {
55
- return true;
56
40
  }
57
41
 
58
- return false;
42
+ return true;
59
43
  }
60
44
 
61
45
  function isStarManifest(manifest) {
@@ -1 +1 @@
1
- {"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","isRelatedToDeprecation","pkgInfo","versions","version","prototype","hasOwnProperty","call","validateInputs","localUsers","username","isStar","isExistlocalUsers","_","isNil","isStarManifest","manifest","validatioUtils","isObject","users"],"sources":["../../src/lib/star-utils.ts"],"sourcesContent":["import _ from 'lodash';\n\nimport { validatioUtils } from '@verdaccio/core';\nimport { Manifest } from '@verdaccio/types';\n\nimport { Users } from '../type';\n\n/**\n * Check whether the package metadta has enough data to be published\n * @param pkg metadata\n */\n\n/**\n * Check whether the package metadta has enough data to be published\n * @param pkg metadata\n */\nexport function isPublishablePackage(pkg: Manifest): boolean {\n // TODO: we can do better, no need get keys\n const keys: string[] = Object.keys(pkg);\n\n return keys.includes('versions');\n}\n\n// @deprecated don't think this is used anymore (REMOVE)\nexport function isRelatedToDeprecation(pkgInfo: Manifest): boolean {\n const { versions } = pkgInfo;\n for (const version in versions) {\n if (Object.prototype.hasOwnProperty.call(versions[version], 'deprecated')) {\n return true;\n }\n }\n return false;\n}\n\nexport function validateInputs(localUsers: Users, username: string, isStar: boolean): boolean {\n const isExistlocalUsers = _.isNil(localUsers[username]) === false;\n if (isStar && isExistlocalUsers && localUsers[username]) {\n return true;\n } else if (!isStar && isExistlocalUsers) {\n return false;\n } else if (!isStar && !isExistlocalUsers) {\n return true;\n }\n return false;\n}\n\nexport function isStarManifest(manifest: Manifest): boolean {\n return isPublishablePackage(manifest) === false && validatioUtils.isObject(manifest.users);\n}\n"],"mappings":";;;;;;;;;;AAAA;;AAEA;;;;AAKA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA8BC,GAA9B,EAAsD;EAC3D;EACA,MAAMC,IAAc,GAAGC,MAAM,CAACD,IAAP,CAAYD,GAAZ,CAAvB;EAEA,OAAOC,IAAI,CAACE,QAAL,CAAc,UAAd,CAAP;AACD,C,CAED;;;AACO,SAASC,sBAAT,CAAgCC,OAAhC,EAA4D;EACjE,MAAM;IAAEC;EAAF,IAAeD,OAArB;;EACA,KAAK,MAAME,OAAX,IAAsBD,QAAtB,EAAgC;IAC9B,IAAIJ,MAAM,CAACM,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCJ,QAAQ,CAACC,OAAD,CAA7C,EAAwD,YAAxD,CAAJ,EAA2E;MACzE,OAAO,IAAP;IACD;EACF;;EACD,OAAO,KAAP;AACD;;AAEM,SAASI,cAAT,CAAwBC,UAAxB,EAA2CC,QAA3C,EAA6DC,MAA7D,EAAuF;EAC5F,MAAMC,iBAAiB,GAAGC,eAAA,CAAEC,KAAF,CAAQL,UAAU,CAACC,QAAD,CAAlB,MAAkC,KAA5D;;EACA,IAAIC,MAAM,IAAIC,iBAAV,IAA+BH,UAAU,CAACC,QAAD,CAA7C,EAAyD;IACvD,OAAO,IAAP;EACD,CAFD,MAEO,IAAI,CAACC,MAAD,IAAWC,iBAAf,EAAkC;IACvC,OAAO,KAAP;EACD,CAFM,MAEA,IAAI,CAACD,MAAD,IAAW,CAACC,iBAAhB,EAAmC;IACxC,OAAO,IAAP;EACD;;EACD,OAAO,KAAP;AACD;;AAEM,SAASG,cAAT,CAAwBC,QAAxB,EAAqD;EAC1D,OAAOpB,oBAAoB,CAACoB,QAAD,CAApB,KAAmC,KAAnC,IAA4CC,oBAAA,CAAeC,QAAf,CAAwBF,QAAQ,CAACG,KAAjC,CAAnD;AACD"}
1
+ {"version":3,"file":"star-utils.js","names":["isPublishablePackage","pkg","keys","Object","includes","isExecutingStarCommand","localUsers","username","userIsAddingStar","isExist","isStarManifest","manifest","validatioUtils","isObject","users"],"sources":["../../src/lib/star-utils.ts"],"sourcesContent":["import { validatioUtils } from '@verdaccio/core';\nimport { Manifest, PackageUsers } from '@verdaccio/types';\n\n/**\n * Check whether the package metadata has enough data to be published\n * @param pkg metadata\n */\nexport function isPublishablePackage(pkg: Manifest): boolean {\n // TODO: we can do better, no need get keys\n const keys: string[] = Object.keys(pkg);\n\n return keys.includes('versions');\n}\n\n/**\n * Verify if the user is actually executing an action, to avoid unnecessary calls\n * to the storage.\n * @param localUsers current state at cache\n * @param username user is executing the action\n * @param userIsAddingStar whether user is removing or adding star\n * @returns boolean\n */\nexport function isExecutingStarCommand(\n localUsers: PackageUsers,\n username: string,\n userIsAddingStar: boolean\n): boolean {\n const isExist = typeof localUsers[username] !== 'undefined';\n // fails if user already exist and us trying to add star.\n if (userIsAddingStar && isExist && localUsers[username]) {\n return false;\n // if is not adding a start but user exists (removing star)\n } else if (!userIsAddingStar && isExist) {\n return true;\n // fails if user does not exist and is not adding any star\n } else if (!userIsAddingStar && !isExist) {\n return false;\n }\n return true;\n}\n\nexport function isStarManifest(manifest: Manifest): boolean {\n return isPublishablePackage(manifest) === false && validatioUtils.isObject(manifest.users);\n}\n"],"mappings":";;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACO,SAASA,oBAAT,CAA8BC,GAA9B,EAAsD;EAC3D;EACA,MAAMC,IAAc,GAAGC,MAAM,CAACD,IAAP,CAAYD,GAAZ,CAAvB;EAEA,OAAOC,IAAI,CAACE,QAAL,CAAc,UAAd,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CACLC,UADK,EAELC,QAFK,EAGLC,gBAHK,EAII;EACT,MAAMC,OAAO,GAAG,OAAOH,UAAU,CAACC,QAAD,CAAjB,KAAgC,WAAhD,CADS,CAET;;EACA,IAAIC,gBAAgB,IAAIC,OAApB,IAA+BH,UAAU,CAACC,QAAD,CAA7C,EAAyD;IACvD,OAAO,KAAP,CADuD,CAEvD;EACD,CAHD,MAGO,IAAI,CAACC,gBAAD,IAAqBC,OAAzB,EAAkC;IACvC,OAAO,IAAP,CADuC,CAEvC;EACD,CAHM,MAGA,IAAI,CAACD,gBAAD,IAAqB,CAACC,OAA1B,EAAmC;IACxC,OAAO,KAAP;EACD;;EACD,OAAO,IAAP;AACD;;AAEM,SAASC,cAAT,CAAwBC,QAAxB,EAAqD;EAC1D,OAAOX,oBAAoB,CAACW,QAAD,CAApB,KAAmC,KAAnC,IAA4CC,oBAAA,CAAeC,QAAf,CAAwBF,QAAQ,CAACG,KAAjC,CAAnD;AACD"}
@@ -2,19 +2,19 @@ import { pluginUtils } from '@verdaccio/core';
2
2
  import { Config, Logger } from '@verdaccio/types';
3
3
  export declare const noSuchFile = "ENOENT";
4
4
  export declare const resourceNotAvailable = "EAGAIN";
5
- export declare type IPluginStorage = pluginUtils.IPluginStorage<Config>;
5
+ export declare type PluginStorage = pluginUtils.Storage<Config>;
6
6
  /**
7
7
  * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).
8
8
  */
9
9
  declare class LocalStorage {
10
10
  config: Config;
11
- storagePlugin: IPluginStorage;
11
+ storagePlugin: PluginStorage;
12
12
  logger: Logger;
13
13
  constructor(config: Config, logger: Logger);
14
14
  init(): Promise<void>;
15
- getStoragePlugin(): IPluginStorage;
15
+ getStoragePlugin(): PluginStorage;
16
16
  getSecret(config: Config): Promise<void>;
17
- private _loadStorage;
18
- private _loadStorePlugin;
17
+ private loadStorage;
18
+ private loadStorePlugin;
19
19
  }
20
20
  export { LocalStorage };
@@ -41,7 +41,7 @@ class LocalStorage {
41
41
 
42
42
  async init() {
43
43
  if (this.storagePlugin === null) {
44
- this.storagePlugin = this._loadStorage(this.config, this.logger);
44
+ this.storagePlugin = await this.loadStorage(this.config, this.logger);
45
45
  debug('storage plugin init');
46
46
  await this.storagePlugin.init();
47
47
  debug('storage plugin initialized');
@@ -65,25 +65,32 @@ class LocalStorage {
65
65
  return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));
66
66
  }
67
67
 
68
- _loadStorage(config, logger) {
69
- const Storage = this._loadStorePlugin();
68
+ async loadStorage(config, logger) {
69
+ const Storage = await this.loadStorePlugin();
70
70
 
71
71
  if (_lodash.default.isNil(Storage)) {
72
72
  (0, _assert.default)(this.config.storage, 'CONFIG: storage path not defined');
73
+ debug('no custom storage found, loading default storage @verdaccio/local-storage');
73
74
  return new _localStorage.default(config, logger);
74
75
  }
75
76
 
76
77
  return Storage;
77
78
  }
78
79
 
79
- _loadStorePlugin() {
80
- const plugin_params = {
80
+ async loadStorePlugin() {
81
+ var _this$config, _this$config$serverSe;
82
+
83
+ const plugins = await (0, _loaders.asyncLoadPlugin)(this.config.store, {
81
84
  config: this.config,
82
85
  logger: this.logger
83
- };
84
- const plugins = (0, _loaders.loadPlugin)(this.config, this.config.store, plugin_params, plugin => {
85
- return plugin.getPackageStorage;
86
- });
86
+ }, plugin => {
87
+ return typeof plugin.getPackageStorage !== 'undefined';
88
+ }, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : (_this$config$serverSe = _this$config.serverSettings) === null || _this$config$serverSe === void 0 ? void 0 : _this$config$serverSe.pluginPrefix);
89
+
90
+ if (plugins.length > 1) {
91
+ this.logger.warn('more than one storage plugins has been detected, multiple storage are not supported, one will be selected automatically');
92
+ }
93
+
87
94
  return _lodash.default.head(plugins);
88
95
  }
89
96
 
@@ -1 +1 @@
1
- {"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","_loadStorage","warn","getStoragePlugin","errorUtils","getInternalError","getSecret","secretKey","setSecret","checkSecretKey","Storage","_loadStorePlugin","_","isNil","assert","storage","LocalDatabase","plugin_params","plugins","loadPlugin","store","plugin","getPackageStorage","head"],"sources":["../src/local-storage.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { errorUtils, pluginUtils } from '@verdaccio/core';\nimport { loadPlugin } from '@verdaccio/loaders';\nimport LocalDatabase from '@verdaccio/local-storage';\nimport { Config, Logger } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:storage:local');\n\nexport const noSuchFile = 'ENOENT';\nexport const resourceNotAvailable = 'EAGAIN';\nexport type IPluginStorage = pluginUtils.IPluginStorage<Config>;\n\n/**\n * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).\n */\nclass LocalStorage {\n public config: Config;\n public storagePlugin: IPluginStorage;\n public logger: Logger;\n\n public constructor(config: Config, logger: Logger) {\n debug('local storage created');\n this.logger = logger.child({ sub: 'fs' });\n this.config = config;\n // @ts-expect-error\n this.storagePlugin = null;\n }\n\n public async init() {\n if (this.storagePlugin === null) {\n this.storagePlugin = this._loadStorage(this.config, this.logger);\n debug('storage plugin init');\n await this.storagePlugin.init();\n debug('storage plugin initialized');\n } else {\n this.logger.warn('storage plugin has been already initialized');\n }\n return;\n }\n\n public getStoragePlugin(): IPluginStorage {\n if (this.storagePlugin === null) {\n throw errorUtils.getInternalError('storage plugin is not initialized');\n }\n\n return this.storagePlugin;\n }\n\n public async getSecret(config: Config): Promise<void> {\n const secretKey = await this.storagePlugin.getSecret();\n\n return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));\n }\n\n private _loadStorage(config: Config, logger: Logger): IPluginStorage {\n const Storage = this._loadStorePlugin();\n\n if (_.isNil(Storage)) {\n assert(this.config.storage, 'CONFIG: storage path not defined');\n return new LocalDatabase(config, logger);\n }\n return Storage as IPluginStorage;\n }\n\n private _loadStorePlugin(): IPluginStorage | void {\n const plugin_params = {\n config: this.config,\n logger: this.logger,\n };\n\n const plugins: IPluginStorage[] = loadPlugin<IPluginStorage>(\n this.config,\n this.config.store,\n plugin_params,\n (plugin): IPluginStorage => {\n return plugin.getPackageStorage;\n }\n );\n\n return _.head(plugins);\n }\n}\n\nexport { LocalStorage };\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAGA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,yBAAX,CAAd;AAEO,MAAMC,UAAU,GAAG,QAAnB;;AACA,MAAMC,oBAAoB,GAAG,QAA7B;;;AAGP;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAKVC,WAAW,CAACC,MAAD,EAAiBC,MAAjB,EAAiC;IACjDP,KAAK,CAAC,uBAAD,CAAL;IACA,KAAKO,MAAL,GAAcA,MAAM,CAACC,KAAP,CAAa;MAAEC,GAAG,EAAE;IAAP,CAAb,CAAd;IACA,KAAKH,MAAL,GAAcA,MAAd,CAHiD,CAIjD;;IACA,KAAKI,aAAL,GAAqB,IAArB;EACD;;EAEgB,MAAJC,IAAI,GAAG;IAClB,IAAI,KAAKD,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,KAAKA,aAAL,GAAqB,KAAKE,YAAL,CAAkB,KAAKN,MAAvB,EAA+B,KAAKC,MAApC,CAArB;MACAP,KAAK,CAAC,qBAAD,CAAL;MACA,MAAM,KAAKU,aAAL,CAAmBC,IAAnB,EAAN;MACAX,KAAK,CAAC,4BAAD,CAAL;IACD,CALD,MAKO;MACL,KAAKO,MAAL,CAAYM,IAAZ,CAAiB,6CAAjB;IACD;;IACD;EACD;;EAEMC,gBAAgB,GAAmB;IACxC,IAAI,KAAKJ,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,MAAMK,gBAAA,CAAWC,gBAAX,CAA4B,mCAA5B,CAAN;IACD;;IAED,OAAO,KAAKN,aAAZ;EACD;;EAEqB,MAATO,SAAS,CAACX,MAAD,EAAgC;IACpD,MAAMY,SAAS,GAAG,MAAM,KAAKR,aAAL,CAAmBO,SAAnB,EAAxB;IAEA,OAAO,KAAKP,aAAL,CAAmBS,SAAnB,CAA6Bb,MAAM,CAACc,cAAP,CAAsBF,SAAtB,CAA7B,CAAP;EACD;;EAEON,YAAY,CAACN,MAAD,EAAiBC,MAAjB,EAAiD;IACnE,MAAMc,OAAO,GAAG,KAAKC,gBAAL,EAAhB;;IAEA,IAAIC,eAAA,CAAEC,KAAF,CAAQH,OAAR,CAAJ,EAAsB;MACpB,IAAAI,eAAA,EAAO,KAAKnB,MAAL,CAAYoB,OAAnB,EAA4B,kCAA5B;MACA,OAAO,IAAIC,qBAAJ,CAAkBrB,MAAlB,EAA0BC,MAA1B,CAAP;IACD;;IACD,OAAOc,OAAP;EACD;;EAEOC,gBAAgB,GAA0B;IAChD,MAAMM,aAAa,GAAG;MACpBtB,MAAM,EAAE,KAAKA,MADO;MAEpBC,MAAM,EAAE,KAAKA;IAFO,CAAtB;IAKA,MAAMsB,OAAyB,GAAG,IAAAC,mBAAA,EAChC,KAAKxB,MAD2B,EAEhC,KAAKA,MAAL,CAAYyB,KAFoB,EAGhCH,aAHgC,EAI/BI,MAAD,IAA4B;MAC1B,OAAOA,MAAM,CAACC,iBAAd;IACD,CAN+B,CAAlC;IASA,OAAOV,eAAA,CAAEW,IAAF,CAAOL,OAAP,CAAP;EACD;;AAjEgB"}
1
+ {"version":3,"file":"local-storage.js","names":["debug","buildDebug","noSuchFile","resourceNotAvailable","LocalStorage","constructor","config","logger","child","sub","storagePlugin","init","loadStorage","warn","getStoragePlugin","errorUtils","getInternalError","getSecret","secretKey","setSecret","checkSecretKey","Storage","loadStorePlugin","_","isNil","assert","storage","LocalDatabase","plugins","asyncLoadPlugin","store","plugin","getPackageStorage","serverSettings","pluginPrefix","length","head"],"sources":["../src/local-storage.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport { errorUtils, pluginUtils } from '@verdaccio/core';\nimport { asyncLoadPlugin } from '@verdaccio/loaders';\nimport LocalDatabase from '@verdaccio/local-storage';\nimport { Config, Logger } from '@verdaccio/types';\n\nconst debug = buildDebug('verdaccio:storage:local');\n\nexport const noSuchFile = 'ENOENT';\nexport const resourceNotAvailable = 'EAGAIN';\nexport type PluginStorage = pluginUtils.Storage<Config>;\n\n/**\n * Implements Storage interface (same for storage.js, local-storage.js, up-storage.js).\n */\nclass LocalStorage {\n public config: Config;\n public storagePlugin: PluginStorage;\n public logger: Logger;\n\n public constructor(config: Config, logger: Logger) {\n debug('local storage created');\n this.logger = logger.child({ sub: 'fs' });\n this.config = config;\n // @ts-expect-error\n this.storagePlugin = null;\n }\n\n public async init() {\n if (this.storagePlugin === null) {\n this.storagePlugin = await this.loadStorage(this.config, this.logger);\n debug('storage plugin init');\n await this.storagePlugin.init();\n debug('storage plugin initialized');\n } else {\n this.logger.warn('storage plugin has been already initialized');\n }\n return;\n }\n\n public getStoragePlugin(): PluginStorage {\n if (this.storagePlugin === null) {\n throw errorUtils.getInternalError('storage plugin is not initialized');\n }\n\n return this.storagePlugin;\n }\n\n public async getSecret(config: Config): Promise<void> {\n const secretKey = await this.storagePlugin.getSecret();\n\n return this.storagePlugin.setSecret(config.checkSecretKey(secretKey));\n }\n\n private async loadStorage(config: Config, logger: Logger): Promise<PluginStorage> {\n const Storage = await this.loadStorePlugin();\n if (_.isNil(Storage)) {\n assert(this.config.storage, 'CONFIG: storage path not defined');\n debug('no custom storage found, loading default storage @verdaccio/local-storage');\n return new LocalDatabase(config, logger);\n }\n return Storage as PluginStorage;\n }\n\n private async loadStorePlugin(): Promise<PluginStorage | undefined> {\n const plugins: PluginStorage[] = await asyncLoadPlugin<pluginUtils.Storage<unknown>>(\n this.config.store,\n {\n config: this.config,\n logger: this.logger,\n },\n (plugin) => {\n return typeof plugin.getPackageStorage !== 'undefined';\n },\n this.config?.serverSettings?.pluginPrefix\n );\n\n if (plugins.length > 1) {\n this.logger.warn(\n 'more than one storage plugins has been detected, multiple storage are not supported, one will be selected automatically'\n );\n }\n\n return _.head(plugins);\n }\n}\n\nexport { LocalStorage };\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;AAGA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,yBAAX,CAAd;AAEO,MAAMC,UAAU,GAAG,QAAnB;;AACA,MAAMC,oBAAoB,GAAG,QAA7B;;;AAGP;AACA;AACA;AACA,MAAMC,YAAN,CAAmB;EAKVC,WAAW,CAACC,MAAD,EAAiBC,MAAjB,EAAiC;IACjDP,KAAK,CAAC,uBAAD,CAAL;IACA,KAAKO,MAAL,GAAcA,MAAM,CAACC,KAAP,CAAa;MAAEC,GAAG,EAAE;IAAP,CAAb,CAAd;IACA,KAAKH,MAAL,GAAcA,MAAd,CAHiD,CAIjD;;IACA,KAAKI,aAAL,GAAqB,IAArB;EACD;;EAEgB,MAAJC,IAAI,GAAG;IAClB,IAAI,KAAKD,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,KAAKA,aAAL,GAAqB,MAAM,KAAKE,WAAL,CAAiB,KAAKN,MAAtB,EAA8B,KAAKC,MAAnC,CAA3B;MACAP,KAAK,CAAC,qBAAD,CAAL;MACA,MAAM,KAAKU,aAAL,CAAmBC,IAAnB,EAAN;MACAX,KAAK,CAAC,4BAAD,CAAL;IACD,CALD,MAKO;MACL,KAAKO,MAAL,CAAYM,IAAZ,CAAiB,6CAAjB;IACD;;IACD;EACD;;EAEMC,gBAAgB,GAAkB;IACvC,IAAI,KAAKJ,aAAL,KAAuB,IAA3B,EAAiC;MAC/B,MAAMK,gBAAA,CAAWC,gBAAX,CAA4B,mCAA5B,CAAN;IACD;;IAED,OAAO,KAAKN,aAAZ;EACD;;EAEqB,MAATO,SAAS,CAACX,MAAD,EAAgC;IACpD,MAAMY,SAAS,GAAG,MAAM,KAAKR,aAAL,CAAmBO,SAAnB,EAAxB;IAEA,OAAO,KAAKP,aAAL,CAAmBS,SAAnB,CAA6Bb,MAAM,CAACc,cAAP,CAAsBF,SAAtB,CAA7B,CAAP;EACD;;EAEwB,MAAXN,WAAW,CAACN,MAAD,EAAiBC,MAAjB,EAAyD;IAChF,MAAMc,OAAO,GAAG,MAAM,KAAKC,eAAL,EAAtB;;IACA,IAAIC,eAAA,CAAEC,KAAF,CAAQH,OAAR,CAAJ,EAAsB;MACpB,IAAAI,eAAA,EAAO,KAAKnB,MAAL,CAAYoB,OAAnB,EAA4B,kCAA5B;MACA1B,KAAK,CAAC,2EAAD,CAAL;MACA,OAAO,IAAI2B,qBAAJ,CAAkBrB,MAAlB,EAA0BC,MAA1B,CAAP;IACD;;IACD,OAAOc,OAAP;EACD;;EAE4B,MAAfC,eAAe,GAAuC;IAAA;;IAClE,MAAMM,OAAwB,GAAG,MAAM,IAAAC,wBAAA,EACrC,KAAKvB,MAAL,CAAYwB,KADyB,EAErC;MACExB,MAAM,EAAE,KAAKA,MADf;MAEEC,MAAM,EAAE,KAAKA;IAFf,CAFqC,EAMpCwB,MAAD,IAAY;MACV,OAAO,OAAOA,MAAM,CAACC,iBAAd,KAAoC,WAA3C;IACD,CARoC,kBASrC,KAAK1B,MATgC,0EASrC,aAAa2B,cATwB,0DASrC,sBAA6BC,YATQ,CAAvC;;IAYA,IAAIN,OAAO,CAACO,MAAR,GAAiB,CAArB,EAAwB;MACtB,KAAK5B,MAAL,CAAYM,IAAZ,CACE,yHADF;IAGD;;IAED,OAAOU,eAAA,CAAEa,IAAF,CAAOR,OAAP,CAAP;EACD;;AArEgB"}
@@ -1,18 +1,19 @@
1
1
  /// <reference types="node" />
2
2
  import { PassThrough, Readable } from 'stream';
3
- import { searchUtils } from '@verdaccio/core';
3
+ import { pluginUtils, searchUtils } from '@verdaccio/core';
4
4
  import { ISyncUplinksOptions, ProxySearchParams } from '@verdaccio/proxy';
5
5
  import { AbbreviatedManifest, Config, Logger, Manifest, MergeTags, StringValue, Token, TokenFilter, Version } from '@verdaccio/types';
6
6
  import { UpdateManifestOptions } from '.';
7
7
  import { ProxyInstanceList } from './lib/uplink-util';
8
8
  import { LocalStorage } from './local-storage';
9
- import { IGetPackageOptionsNext, IPluginFilters } from './type';
9
+ import { IGetPackageOptionsNext, StarManifestBody } from './type';
10
+ export declare type Filters = pluginUtils.ManifestFilter<Config>[];
10
11
  export declare const noSuchFile = "ENOENT";
11
12
  export declare const resourceNotAvailable = "EAGAIN";
12
13
  export declare const PROTO_NAME = "__proto__";
13
14
  declare class Storage {
14
15
  localStorage: LocalStorage;
15
- filters: IPluginFilters;
16
+ filters: Filters | null;
16
17
  readonly config: Config;
17
18
  readonly logger: Logger;
18
19
  readonly uplinks: ProxyInstanceList;
@@ -23,7 +24,7 @@ declare class Storage {
23
24
  Function changes a package info from local storage and all uplinks with write access./
24
25
  Used storages: local (write)
25
26
  */
26
- changePackageNext(name: string, metadata: Manifest, revision: string): Promise<void>;
27
+ changePackage(name: string, metadata: Manifest, revision: string): Promise<void>;
27
28
  removePackage(name: string, revision: any): Promise<void>;
28
29
  /**
29
30
  Remove a tarball from a system
@@ -67,10 +68,10 @@ declare class Storage {
67
68
  /**
68
69
  * Initialize the storage asynchronously.
69
70
  * @param config Config
70
- * @param filters IPluginFilters
71
+ * @param filters Filters
71
72
  * @returns Storage instance
72
73
  */
73
- init(config: Config, filters?: IPluginFilters): Promise<void>;
74
+ init(config: Config): Promise<void>;
74
75
  /**
75
76
  * Consume the upstream and pipe it to a transformable stream.
76
77
  */
@@ -114,8 +115,7 @@ declare class Storage {
114
115
  */
115
116
  mergeTagsNext(name: string, tags: MergeTags): Promise<Manifest>;
116
117
  private getUpLinkForDistFile;
117
- updateLocalMetadata(pkgName: string): Promise<void>;
118
- updateManifest(manifest: Manifest, options: UpdateManifestOptions): Promise<void>;
118
+ updateManifest(manifest: Manifest | StarManifestBody, options: UpdateManifestOptions): Promise<string | undefined>;
119
119
  private deprecate;
120
120
  private star;
121
121
  /**
@@ -183,14 +183,14 @@ declare class Storage {
183
183
  */
184
184
  private checkPackageRemote;
185
185
  private setDefaultRevision;
186
- private writePackageNext;
186
+ private writePackage;
187
187
  /**
188
188
  * @param {*} name package name
189
189
  * @param {*} updateHandler function(package, cb) - update function
190
190
  * @param {*} callback callback that gets invoked after it's all updated
191
191
  * @return {Function}
192
192
  */
193
- private updatePackageNext;
193
+ private updatePackage;
194
194
  /**
195
195
  *
196
196
  * @protected