@verdaccio/store 6.0.0-6-next.13 → 6.0.0-6-next.17

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,113 @@
1
1
  # @verdaccio/store
2
2
 
3
+ ## 6.0.0-6-next.17
4
+
5
+ ### Major Changes
6
+
7
+ - a828271d: refactor: download manifest endpoint and integrate fastify
8
+
9
+ Much simpler API for fetching a package
10
+
11
+ ```
12
+ const manifest = await storage.getPackageNext({
13
+ name,
14
+ uplinksLook: true,
15
+ req,
16
+ version: queryVersion,
17
+ requestOptions,
18
+ });
19
+ ```
20
+
21
+ > not perfect, the `req` still is being passed to the proxy (this has to be refactored at proxy package) and then removed from here, in proxy we pass the request instance to the `request` library.
22
+
23
+ ### Details
24
+
25
+ - `async/await` sugar for getPackage()
26
+ - Improve and reuse code between current implementation and new fastify endpoint (add scaffolding for request manifest)
27
+ - Improve performance
28
+ - Add new tests
29
+
30
+ ### Breaking changes
31
+
32
+ All storage plugins will stop to work since the storage uses `getPackageNext` method which is Promise based, I won't replace this now because will force me to update all plugins, I'll follow up in another PR. Currently will throw http 500
33
+
34
+ ### Minor Changes
35
+
36
+ - b13a3fef: refactor: improve versions and dist-tag filters
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [a828271d]
41
+ - Updated dependencies [24b9be02]
42
+ - Updated dependencies [e75c0a3b]
43
+ - Updated dependencies [b13a3fef]
44
+ - @verdaccio/tarball@11.0.0-6-next.11
45
+ - @verdaccio/local-storage@11.0.0-6-next.11
46
+ - @verdaccio/utils@6.0.0-6-next.10
47
+ - @verdaccio/core@6.0.0-6-next.4
48
+ - @verdaccio/logger@6.0.0-6-next.8
49
+ - @verdaccio/proxy@6.0.0-6-next.16
50
+ - @verdaccio/config@6.0.0-6-next.12
51
+ - @verdaccio/loaders@6.0.0-6-next.8
52
+ - @verdaccio/streams@11.0.0-6-next.5
53
+
54
+ ## 6.0.0-6-next.16
55
+
56
+ ### Minor Changes
57
+
58
+ - f86c31ed: feat: migrate web sidebar endpoint to fastify
59
+
60
+ reuse utils methods between packages
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [f86c31ed]
65
+ - @verdaccio/utils@6.0.0-6-next.9
66
+ - @verdaccio/config@6.0.0-6-next.11
67
+ - @verdaccio/local-storage@11.0.0-6-next.10
68
+ - @verdaccio/proxy@6.0.0-6-next.15
69
+ - @verdaccio/loaders@6.0.0-6-next.7
70
+
71
+ ## 6.0.0-6-next.15
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [6c1eb021]
76
+ - @verdaccio/core@6.0.0-6-next.3
77
+ - @verdaccio/logger@6.0.0-6-next.7
78
+ - @verdaccio/config@6.0.0-6-next.10
79
+ - @verdaccio/loaders@6.0.0-6-next.7
80
+ - @verdaccio/local-storage@11.0.0-6-next.10
81
+ - @verdaccio/proxy@6.0.0-6-next.14
82
+ - @verdaccio/utils@6.0.0-6-next.8
83
+
84
+ ## 6.0.0-6-next.14
85
+
86
+ ### Major Changes
87
+
88
+ - 794af76c: Remove Node 12 support
89
+
90
+ - We need move to the new `undici` and does not support Node.js 12
91
+
92
+ ### Minor Changes
93
+
94
+ - b702ea36: abort search request support for proxy
95
+ - 154b2ecd: refactor: remove @verdaccio/commons-api in favor @verdaccio/core and remove duplications
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [794af76c]
100
+ - Updated dependencies [b702ea36]
101
+ - Updated dependencies [154b2ecd]
102
+ - @verdaccio/config@6.0.0-6-next.9
103
+ - @verdaccio/core@6.0.0-6-next.2
104
+ - @verdaccio/streams@11.0.0-6-next.5
105
+ - @verdaccio/loaders@6.0.0-6-next.6
106
+ - @verdaccio/logger@6.0.0-6-next.6
107
+ - @verdaccio/utils@6.0.0-6-next.7
108
+ - @verdaccio/proxy@6.0.0-6-next.13
109
+ - @verdaccio/local-storage@11.0.0-6-next.9
110
+
3
111
  ## 6.0.0-6-next.13
4
112
 
5
113
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { PassThrough } from 'stream';
3
- import { searchUtils, pluginUtils } from '@verdaccio/core';
4
- import { Token, TokenFilter, Package, Config, IUploadTarball, IReadTarball, MergeTags, Version, Callback, Logger, CallbackAction, StringValue } from '@verdaccio/types';
3
+ import { pluginUtils, searchUtils } from '@verdaccio/core';
4
+ import { Callback, CallbackAction, Config, IReadTarball, IUploadTarball, Logger, MergeTags, Package, StringValue, Token, TokenFilter, Version } from '@verdaccio/types';
5
5
  export declare type IPluginStorage = pluginUtils.IPluginStorage<Config>;
6
6
  export declare function normalizeSearchPackage(pkg: Package, searchItem: searchUtils.SearchItem): searchUtils.SearchPackageBody;
7
7
  export declare const PROTO_NAME = "__proto__";
@@ -88,11 +88,13 @@ declare class LocalStorage {
88
88
  * @return {ReadTarball}
89
89
  */
90
90
  private _streamSuccessReadTarBall;
91
+ getPackageMetadataNext(name: string): Promise<Package>;
91
92
  /**
92
93
  * Retrieve a package by name.
93
94
  * @param {*} name
94
95
  * @param {*} callback
95
96
  * @return {Function}
97
+ * @deprecated
96
98
  */
97
99
  getPackageMetadata(name: string, callback?: Callback): void;
98
100
  search(searchStream: PassThrough, query: searchUtils.SearchQuery): Promise<void>;
@@ -106,8 +108,10 @@ declare class LocalStorage {
106
108
  * Read a json file from storage.
107
109
  * @param {Object} storage
108
110
  * @param {Function} callback
111
+ * @deprecated
109
112
  */
110
113
  private _readPackage;
114
+ private _readPackageNext;
111
115
  /**
112
116
  * Retrieve either a previous created local package or a boilerplate.
113
117
  * @param {*} pkgName
@@ -3,35 +3,31 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.PROTO_NAME = exports.LocalStorage = void 0;
6
7
  exports.normalizeSearchPackage = normalizeSearchPackage;
7
- exports.LocalStorage = exports.PROTO_NAME = void 0;
8
8
 
9
9
  var _assert = _interopRequireDefault(require("assert"));
10
10
 
11
- var _url = _interopRequireDefault(require("url"));
11
+ var _debug = _interopRequireDefault(require("debug"));
12
12
 
13
13
  var _lodash = _interopRequireDefault(require("lodash"));
14
14
 
15
- var _debug = _interopRequireDefault(require("debug"));
16
-
17
- var _utils = require("@verdaccio/utils");
15
+ var _url = _interopRequireDefault(require("url"));
18
16
 
19
17
  var _core = require("@verdaccio/core");
20
18
 
21
- var _commonsApi = require("@verdaccio/commons-api");
22
-
23
19
  var _loaders = require("@verdaccio/loaders");
24
20
 
25
21
  var _localStorage = _interopRequireDefault(require("@verdaccio/local-storage"));
26
22
 
27
23
  var _streams = require("@verdaccio/streams");
28
24
 
25
+ var _utils = require("@verdaccio/utils");
26
+
29
27
  var _storageUtils = require("./storage-utils");
30
28
 
31
29
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
32
30
 
33
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
34
-
35
31
  const debug = (0, _debug.default)('verdaccio:storage:local');
36
32
 
37
33
  function normalizeSearchPackage(pkg, searchItem) {
@@ -75,12 +71,6 @@ exports.PROTO_NAME = PROTO_NAME;
75
71
 
76
72
  class LocalStorage {
77
73
  constructor(config, logger) {
78
- _defineProperty(this, "config", void 0);
79
-
80
- _defineProperty(this, "storagePlugin", void 0);
81
-
82
- _defineProperty(this, "logger", void 0);
83
-
84
74
  debug('local storage created');
85
75
  this.logger = logger.child({
86
76
  sub: 'fs'
@@ -110,13 +100,13 @@ class LocalStorage {
110
100
 
111
101
  if (_lodash.default.isNil(storage)) {
112
102
  debug(`storage is missing for %o package cannot be added`, name);
113
- return callback(_utils.ErrorCode.getNotFound('this package cannot be added'));
103
+ return callback(_core.errorUtils.getNotFound('this package cannot be added'));
114
104
  }
115
105
 
116
106
  storage.createPackage(name, (0, _storageUtils.generatePackageTemplate)(name), err => {
117
- if (_lodash.default.isNull(err) === false && (err.code === _storageUtils.STORAGE.FILE_EXIST_ERROR || err.code === _commonsApi.HTTP_STATUS.CONFLICT)) {
107
+ if (_lodash.default.isNull(err) === false && (err.code === _storageUtils.STORAGE.FILE_EXIST_ERROR || err.code === _core.HTTP_STATUS.CONFLICT)) {
118
108
  debug(`error on creating a package for %o with error %o`, name, err.message);
119
- return callback(_utils.ErrorCode.getConflict());
109
+ return callback(_core.errorUtils.getConflict());
120
110
  }
121
111
 
122
112
  const latest = (0, _utils.getLatestVersion)(pkg);
@@ -141,15 +131,15 @@ class LocalStorage {
141
131
  const storage = this._getLocalStorage(name);
142
132
 
143
133
  if (_lodash.default.isNil(storage)) {
144
- throw _utils.ErrorCode.getNotFound();
134
+ throw _core.errorUtils.getNotFound();
145
135
  }
146
136
 
147
137
  return new Promise((resolve, reject) => {
148
138
  storage.readPackage(name, async (err, data) => {
149
139
  if (_lodash.default.isNil(err) === false) {
150
- if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _commonsApi.HTTP_STATUS.NOT_FOUND) {
140
+ if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
151
141
  debug(`error on not found %o with error %o`, name, err.message);
152
- return reject(_utils.ErrorCode.getNotFound());
142
+ return reject(_core.errorUtils.getNotFound());
153
143
  }
154
144
 
155
145
  return reject(err);
@@ -179,7 +169,7 @@ class LocalStorage {
179
169
  this.logger.error({
180
170
  err
181
171
  }, 'removed package has failed @{err.message}');
182
- throw _utils.ErrorCode.getBadData(err.message);
172
+ throw _core.errorUtils.getBadData(err.message);
183
173
  }
184
174
  });
185
175
  });
@@ -219,7 +209,7 @@ class LocalStorage {
219
209
 
220
210
  version = (0, _storageUtils.cleanUpReadme)(version);
221
211
  debug('clean up readme for %o', versionId);
222
- version.contributors = (0, _storageUtils.normalizeContributors)(version.contributors);
212
+ version.contributors = (0, _utils.normalizeContributors)(version.contributors);
223
213
  change = true;
224
214
  packageLocalJson.versions[versionId] = version;
225
215
 
@@ -245,10 +235,10 @@ class LocalStorage {
245
235
 
246
236
  debug('update dist-tags');
247
237
 
248
- for (const tag in packageInfo[_commonsApi.DIST_TAGS]) {
249
- if (!packageLocalJson[_commonsApi.DIST_TAGS][tag] || packageLocalJson[_commonsApi.DIST_TAGS][tag] !== packageInfo[_commonsApi.DIST_TAGS][tag]) {
238
+ for (const tag in packageInfo[_core.DIST_TAGS]) {
239
+ if (!packageLocalJson[_core.DIST_TAGS][tag] || packageLocalJson[_core.DIST_TAGS][tag] !== packageInfo[_core.DIST_TAGS][tag]) {
250
240
  change = true;
251
- packageLocalJson[_commonsApi.DIST_TAGS][tag] = packageInfo[_commonsApi.DIST_TAGS][tag];
241
+ packageLocalJson[_core.DIST_TAGS][tag] = packageInfo[_core.DIST_TAGS][tag];
252
242
  }
253
243
  }
254
244
 
@@ -301,13 +291,13 @@ class LocalStorage {
301
291
  debug('%s` readme mutated', name); // TODO: lodash remove
302
292
 
303
293
  metadata = (0, _storageUtils.cleanUpReadme)(metadata);
304
- metadata.contributors = (0, _storageUtils.normalizeContributors)(metadata.contributors);
294
+ metadata.contributors = (0, _utils.normalizeContributors)(metadata.contributors);
305
295
  debug('%s` contributors normalized', name);
306
296
  const hasVersion = data.versions[version] != null;
307
297
 
308
298
  if (hasVersion) {
309
299
  debug('%s version %s already exists', name, version);
310
- return cb(_utils.ErrorCode.getConflict());
300
+ return cb(_core.errorUtils.getConflict());
311
301
  } // if uploaded tarball has a different shasum, it's very likely that we
312
302
  // have some kind of error
313
303
 
@@ -319,7 +309,7 @@ class LocalStorage {
319
309
  if (_lodash.default.isNil(data._attachments[tarball].shasum) === false && _lodash.default.isNil(metadata.dist.shasum) === false) {
320
310
  if (data._attachments[tarball].shasum != metadata.dist.shasum) {
321
311
  const errorMessage = `shasum error, ` + `${data._attachments[tarball].shasum} != ${metadata.dist.shasum}`;
322
- return cb(_utils.ErrorCode.getBadRequest(errorMessage));
312
+ return cb(_core.errorUtils.getBadRequest(errorMessage));
323
313
  }
324
314
  }
325
315
 
@@ -348,7 +338,7 @@ class LocalStorage {
348
338
  await this.storagePlugin.add(name);
349
339
  cb();
350
340
  } catch (err) {
351
- cb(_utils.ErrorCode.getBadData(err.message));
341
+ cb(_core.errorUtils.getBadData(err.message));
352
342
  }
353
343
  }, callback);
354
344
  }
@@ -368,12 +358,12 @@ class LocalStorage {
368
358
  for (const tag in tags) {
369
359
  // this handle dist-tag rm command
370
360
  if (_lodash.default.isNull(tags[tag])) {
371
- delete data[_commonsApi.DIST_TAGS][tag];
361
+ delete data[_core.DIST_TAGS][tag];
372
362
  continue;
373
363
  }
374
364
 
375
365
  if (_lodash.default.isNil(data.versions[tags[tag]])) {
376
- return cb(_utils.ErrorCode.getNotFound(_commonsApi.API_ERROR.VERSION_NOT_EXIST));
366
+ return cb(_core.errorUtils.getNotFound(_core.API_ERROR.VERSION_NOT_EXIST));
377
367
  }
378
368
 
379
369
  const version = tags[tag];
@@ -397,9 +387,9 @@ class LocalStorage {
397
387
  changePackage(name, incomingPkg, revision, callback) {
398
388
  debug(`change package tags for %o revision %s`, name, revision);
399
389
 
400
- if (!_core.validatioUtils.isObject(incomingPkg.versions) || !_core.validatioUtils.isObject(incomingPkg[_commonsApi.DIST_TAGS])) {
390
+ if (!_core.validatioUtils.isObject(incomingPkg.versions) || !_core.validatioUtils.isObject(incomingPkg[_core.DIST_TAGS])) {
401
391
  debug(`change package bad data for %o`, name);
402
- return callback(_utils.ErrorCode.getBadData());
392
+ return callback(_core.errorUtils.getBadData());
403
393
  }
404
394
 
405
395
  debug(`change package udapting package for %o`, name);
@@ -445,8 +435,8 @@ class LocalStorage {
445
435
  }
446
436
  }
447
437
 
448
- localData[_commonsApi.USERS] = incomingPkg[_commonsApi.USERS];
449
- localData[_commonsApi.DIST_TAGS] = incomingPkg[_commonsApi.DIST_TAGS];
438
+ localData[_core.USERS] = incomingPkg[_core.USERS];
439
+ localData[_core.DIST_TAGS] = incomingPkg[_core.DIST_TAGS];
450
440
  cb(null);
451
441
  }, function (err) {
452
442
  if (err) {
@@ -475,7 +465,7 @@ class LocalStorage {
475
465
  delete data._attachments[filename];
476
466
  cb(null);
477
467
  } else {
478
- cb(_utils.ErrorCode.getNotFound('no such file available'));
468
+ cb(_core.errorUtils.getNotFound('no such file available'));
479
469
  }
480
470
  }, err => {
481
471
  if (err) {
@@ -499,7 +489,7 @@ class LocalStorage {
499
489
  return callback(null);
500
490
  });
501
491
  } else {
502
- callback(_utils.ErrorCode.getInternalError());
492
+ callback(_core.errorUtils.getInternalError());
503
493
  }
504
494
  });
505
495
  }
@@ -537,7 +527,7 @@ class LocalStorage {
537
527
 
538
528
  if (name === PROTO_NAME) {
539
529
  process.nextTick(() => {
540
- uploadStream.emit('error', _utils.ErrorCode.getForbidden());
530
+ uploadStream.emit('error', _core.errorUtils.getForbidden());
541
531
  });
542
532
  return uploadStream;
543
533
  } // FIXME: this condition will never met, storage is always defined
@@ -553,10 +543,10 @@ class LocalStorage {
553
543
  const writeStream = storage.writeTarball(filename);
554
544
  writeStream.on('error', err => {
555
545
  // @ts-ignore
556
- if (err.code === _storageUtils.STORAGE.FILE_EXIST_ERROR || err.code === _commonsApi.HTTP_STATUS.CONFLICT) {
557
- uploadStream.emit('error', _utils.ErrorCode.getConflict());
546
+ if (err.code === _storageUtils.STORAGE.FILE_EXIST_ERROR || err.code === _core.HTTP_STATUS.CONFLICT) {
547
+ uploadStream.emit('error', _core.errorUtils.getConflict());
558
548
  uploadStream.abort(); // @ts-ignore
559
- } else if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _commonsApi.HTTP_STATUS.NOT_FOUND) {
549
+ } else if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
560
550
  // check if package exists to throw an appropriate message
561
551
  this.getPackageMetadata(name, function (_err) {
562
552
  if (_err) {
@@ -597,7 +587,7 @@ class LocalStorage {
597
587
 
598
588
  uploadStream.done = function () {
599
589
  if (!length) {
600
- uploadStream.emit('error', _utils.ErrorCode.getBadData('refusing to accept zero-length file'));
590
+ uploadStream.emit('error', _core.errorUtils.getBadData('refusing to accept zero-length file'));
601
591
  writeStream.abort();
602
592
  } else {
603
593
  writeStream.done();
@@ -636,7 +626,7 @@ class LocalStorage {
636
626
  _createFailureStreamResponse() {
637
627
  const stream = new _streams.ReadTarball({});
638
628
  process.nextTick(() => {
639
- stream.emit('error', _utils.ErrorCode.getNotFound('no such file available'));
629
+ stream.emit('error', _core.errorUtils.getNotFound('no such file available'));
640
630
  });
641
631
  return stream;
642
632
  }
@@ -652,7 +642,7 @@ class LocalStorage {
652
642
  _streamSuccessReadTarBall(storage, filename) {
653
643
  const stream = new _streams.ReadTarball({});
654
644
  const readTarballStream = storage.readTarball(filename);
655
- const e404 = _utils.ErrorCode.getNotFound;
645
+ const e404 = _core.errorUtils.getNotFound;
656
646
 
657
647
  stream.abort = function () {
658
648
  if (_lodash.default.isNil(readTarballStream) === false) {
@@ -662,7 +652,7 @@ class LocalStorage {
662
652
 
663
653
  readTarballStream.on('error', function (err) {
664
654
  // @ts-ignore
665
- if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _commonsApi.HTTP_STATUS.NOT_FOUND) {
655
+ if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
666
656
  stream.emit('error', e404('no such file available'));
667
657
  } else {
668
658
  stream.emit('error', err);
@@ -678,11 +668,26 @@ class LocalStorage {
678
668
  });
679
669
  return stream;
680
670
  }
671
+
672
+ async getPackageMetadataNext(name) {
673
+ const storage = this._getLocalStorage(name);
674
+
675
+ debug('get package metadata for %o', name);
676
+
677
+ if (typeof storage === 'undefined') {
678
+ // TODO: this might be a better an error to throw
679
+ // if storage is not there cannot be 404.
680
+ throw _core.errorUtils.getNotFound();
681
+ }
682
+
683
+ return await this._readPackageNext(name, storage);
684
+ }
681
685
  /**
682
686
  * Retrieve a package by name.
683
687
  * @param {*} name
684
688
  * @param {*} callback
685
689
  * @return {Function}
690
+ * @deprecated
686
691
  */
687
692
 
688
693
 
@@ -692,7 +697,7 @@ class LocalStorage {
692
697
  debug('get package metadata for %o', name);
693
698
 
694
699
  if (typeof storage === 'undefined') {
695
- return callback(_utils.ErrorCode.getNotFound());
700
+ return callback(_core.errorUtils.getNotFound());
696
701
  }
697
702
 
698
703
  this._readPackage(name, storage, callback);
@@ -778,15 +783,16 @@ class LocalStorage {
778
783
  * Read a json file from storage.
779
784
  * @param {Object} storage
780
785
  * @param {Function} callback
786
+ * @deprecated
781
787
  */
782
788
 
783
789
 
784
790
  _readPackage(name, storage, callback) {
785
791
  storage.readPackage(name, (err, result) => {
786
792
  if (err) {
787
- if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _commonsApi.HTTP_STATUS.NOT_FOUND) {
793
+ if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
788
794
  debug('package %s not found', name);
789
- return callback(_utils.ErrorCode.getNotFound());
795
+ return callback(_core.errorUtils.getNotFound());
790
796
  }
791
797
 
792
798
  return callback(this._internalError(err, _storageUtils.STORAGE.PACKAGE_FILE_NAME, 'error reading'));
@@ -795,6 +801,24 @@ class LocalStorage {
795
801
  callback(err, (0, _storageUtils.normalizePackage)(result));
796
802
  });
797
803
  }
804
+
805
+ async _readPackageNext(name, storage) {
806
+ try {
807
+ const result = await storage.readPackageNext(name);
808
+ return (0, _storageUtils.normalizePackage)(result);
809
+ } catch (err) {
810
+ if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
811
+ debug('package %s not found', name);
812
+ throw _core.errorUtils.getNotFound();
813
+ }
814
+
815
+ this.logger.error({
816
+ err: err,
817
+ file: _storageUtils.STORAGE.PACKAGE_FILE_NAME
818
+ }, `error reading @{file}: @{!err.message}`);
819
+ throw _core.errorUtils.getInternalError();
820
+ }
821
+ }
798
822
  /**
799
823
  * Retrieve either a previous created local package or a boilerplate.
800
824
  * @param {*} pkgName
@@ -815,7 +839,7 @@ class LocalStorage {
815
839
  storage.readPackage(pkgName, (err, data) => {
816
840
  // TODO: race condition
817
841
  if (_lodash.default.isNil(err) === false) {
818
- if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _commonsApi.HTTP_STATUS.NOT_FOUND) {
842
+ if (err.code === _storageUtils.STORAGE.NO_SUCH_FILE_ERROR || err.code === _core.HTTP_STATUS.NOT_FOUND) {
819
843
  data = (0, _storageUtils.generatePackageTemplate)(pkgName);
820
844
  } else {
821
845
  return callback(this._internalError(err, _storageUtils.STORAGE.PACKAGE_FILE_NAME, 'error reading'));
@@ -843,7 +867,7 @@ class LocalStorage {
843
867
  err: err,
844
868
  file: file
845
869
  }, `${message} @{file}: @{!err.message}`);
846
- return _utils.ErrorCode.getInternalError();
870
+ return _core.errorUtils.getInternalError();
847
871
  }
848
872
  /**
849
873
  * @param {*} name package name
@@ -857,7 +881,7 @@ class LocalStorage {
857
881
  const storage = this._getLocalStorage(name);
858
882
 
859
883
  if (!storage) {
860
- return callback(_utils.ErrorCode.getNotFound());
884
+ return callback(_core.errorUtils.getNotFound());
861
885
  }
862
886
 
863
887
  storage.updatePackage(name, updateHandler, this._writePackage.bind(this), _storageUtils.normalizePackage, callback);
@@ -965,7 +989,7 @@ class LocalStorage {
965
989
 
966
990
  saveToken(token) {
967
991
  if (_lodash.default.isFunction(this.storagePlugin.saveToken) === false) {
968
- return Promise.reject(_utils.ErrorCode.getCode(_commonsApi.HTTP_STATUS.SERVICE_UNAVAILABLE, _commonsApi.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
992
+ return Promise.reject(_core.errorUtils.getCode(_core.HTTP_STATUS.SERVICE_UNAVAILABLE, _core.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
969
993
  }
970
994
 
971
995
  return this.storagePlugin.saveToken(token);
@@ -973,7 +997,7 @@ class LocalStorage {
973
997
 
974
998
  deleteToken(user, tokenKey) {
975
999
  if (_lodash.default.isFunction(this.storagePlugin.deleteToken) === false) {
976
- return Promise.reject(_utils.ErrorCode.getCode(_commonsApi.HTTP_STATUS.SERVICE_UNAVAILABLE, _commonsApi.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
1000
+ return Promise.reject(_core.errorUtils.getCode(_core.HTTP_STATUS.SERVICE_UNAVAILABLE, _core.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
977
1001
  }
978
1002
 
979
1003
  return this.storagePlugin.deleteToken(user, tokenKey);
@@ -981,7 +1005,7 @@ class LocalStorage {
981
1005
 
982
1006
  readTokens(filter) {
983
1007
  if (_lodash.default.isFunction(this.storagePlugin.readTokens) === false) {
984
- return Promise.reject(_utils.ErrorCode.getCode(_commonsApi.HTTP_STATUS.SERVICE_UNAVAILABLE, _commonsApi.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
1008
+ return Promise.reject(_core.errorUtils.getCode(_core.HTTP_STATUS.SERVICE_UNAVAILABLE, _core.SUPPORT_ERRORS.PLUGIN_MISSING_INTERFACE));
985
1009
  }
986
1010
 
987
1011
  return this.storagePlugin.readTokens(filter);