@verdaccio/store 6.0.0-6-next.22 → 6.0.0-6-next.23

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.
Files changed (72) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/build/index.d.ts +5 -4
  3. package/build/index.js +31 -15
  4. package/build/index.js.map +1 -1
  5. package/build/lib/TransFormResults.d.ts +15 -0
  6. package/build/lib/TransFormResults.js +61 -0
  7. package/build/lib/TransFormResults.js.map +1 -0
  8. package/build/lib/search-utils.d.ts +4 -0
  9. package/build/lib/search-utils.js +59 -0
  10. package/build/lib/search-utils.js.map +1 -0
  11. package/build/lib/star-utils.d.ts +14 -0
  12. package/build/{star-utils.js → lib/star-utils.js} +16 -2
  13. package/build/lib/star-utils.js.map +1 -0
  14. package/build/lib/storage-utils.d.ts +82 -0
  15. package/build/{storage-utils.js → lib/storage-utils.js} +166 -60
  16. package/build/lib/storage-utils.js.map +1 -0
  17. package/build/lib/uplink-util.d.ts +10 -0
  18. package/build/lib/uplink-util.js +49 -0
  19. package/build/lib/uplink-util.js.map +1 -0
  20. package/build/lib/versions-utils.d.ts +28 -0
  21. package/build/lib/versions-utils.js +104 -0
  22. package/build/lib/versions-utils.js.map +1 -0
  23. package/build/local-storage.d.ts +3 -165
  24. package/build/local-storage.js +6 -1166
  25. package/build/local-storage.js.map +1 -1
  26. package/build/storage.d.ts +240 -86
  27. package/build/storage.js +1636 -549
  28. package/build/storage.js.map +1 -1
  29. package/build/type.d.ts +37 -19
  30. package/build/type.js.map +1 -1
  31. package/jest.config.js +8 -2
  32. package/package.json +71 -71
  33. package/src/index.ts +5 -4
  34. package/src/lib/TransFormResults.ts +42 -0
  35. package/src/lib/search-utils.ts +50 -0
  36. package/src/{star-utils.ts → lib/star-utils.ts} +16 -5
  37. package/src/lib/storage-utils.ts +356 -0
  38. package/src/lib/uplink-util.ts +41 -0
  39. package/src/lib/versions-utils.ts +87 -0
  40. package/src/local-storage.ts +7 -1217
  41. package/src/storage.ts +1626 -632
  42. package/src/type.ts +41 -21
  43. package/test/fixtures/config/getTarballNext-getupstream.yaml +17 -0
  44. package/test/fixtures/config/syncDoubleUplinksMetadata.yaml +25 -0
  45. package/test/fixtures/config/syncNoUplinksMetadata.yaml +17 -0
  46. package/test/fixtures/config/syncSingleUplinksMetadata.yaml +21 -0
  47. package/test/fixtures/config/updateManifest-1.yaml +16 -0
  48. package/test/fixtures/manifests/foo-npmjs.json +253 -0
  49. package/test/fixtures/manifests/foo-verdaccio.json +253 -0
  50. package/test/fixtures/tarball.tgz +0 -0
  51. package/test/helpers.ts +22 -0
  52. package/test/local-store.__disabled__.ts +553 -0
  53. package/test/search.spec.ts +4 -5
  54. package/test/star.spec.ts +31 -0
  55. package/test/storage-utils.spec.ts +129 -42
  56. package/test/storage.spec.ts +687 -25
  57. package/test/versions.spec.ts +109 -0
  58. package/tsconfig.json +6 -3
  59. package/build/search.d.ts +0 -35
  60. package/build/search.js +0 -198
  61. package/build/search.js.map +0 -1
  62. package/build/star-utils.d.ts +0 -9
  63. package/build/star-utils.js.map +0 -1
  64. package/build/storage-utils.d.ts +0 -39
  65. package/build/storage-utils.js.map +0 -1
  66. package/build/uplink-util.d.ts +0 -7
  67. package/build/uplink-util.js +0 -38
  68. package/build/uplink-util.js.map +0 -1
  69. package/src/search.ts +0 -175
  70. package/src/storage-utils.ts +0 -263
  71. package/src/uplink-util.ts +0 -32
  72. package/test/local-storage.spec.ts +0 -583
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @verdaccio/store
2
2
 
3
+ ## 6.0.0-6-next.23
4
+
5
+ ### Major Changes
6
+
7
+ - 292c0a37: feat!: replace deprecated request dependency by got
8
+
9
+ This is a big refactoring of the core, fetching dependencies, improve code, more tests and better stability. This is essential for the next release, will take some time but would allow modularize more the core.
10
+
11
+ ## Notes
12
+
13
+ - Remove deprecated `request` by other `got`, retry improved, custom Agent ( got does not include it built-in)
14
+ - Remove `async` dependency from storage (used by core) it was linked with proxy somehow safe to remove now
15
+ - Refactor with promises instead callback wherever is possible
16
+ - ~Document the API~
17
+ - Improve testing, integration tests
18
+ - Bugfix
19
+ - Clean up old validations
20
+ - Improve performance
21
+
22
+ ## 💥 Breaking changes
23
+
24
+ - Plugin API methods were callbacks based are returning promises, this will break current storage plugins, check documentation for upgrade.
25
+ - Write Tarball, Read Tarball methods parameters change, a new set of options like `AbortController` signals are being provided to the `addAbortSignal` can be internally used with Streams when a request is aborted. eg: `addAbortSignal(signal, fs.createReadStream(pathName));`
26
+ - `@verdaccio/streams` stream abort support is legacy is being deprecated removed
27
+ - Remove AWS and Google Cloud packages for future refactoring [#2574](https://github.com/verdaccio/verdaccio/pull/2574).
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [292c0a37]
32
+ - Updated dependencies [a3a209b5]
33
+ - Updated dependencies [00d1d2a1]
34
+ - @verdaccio/config@6.0.0-6-next.15
35
+ - @verdaccio/core@6.0.0-6-next.6
36
+ - @verdaccio/tarball@11.0.0-6-next.13
37
+ - @verdaccio/url@11.0.0-6-next.10
38
+ - @verdaccio/hooks@6.0.0-6-next.14
39
+ - @verdaccio/loaders@6.0.0-6-next.13
40
+ - @verdaccio/logger@6.0.0-6-next.12
41
+ - @verdaccio/local-storage@11.0.0-6-next.13
42
+ - @verdaccio/proxy@6.0.0-6-next.21
43
+ - @verdaccio/utils@6.0.0-6-next.12
44
+
3
45
  ## 6.0.0-6-next.22
4
46
 
5
47
  ### Patch Changes
package/build/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './storage';
2
- export * from './storage-utils';
3
- export * from './star-utils';
4
- export * from './search';
1
+ export { Storage } from './storage';
2
+ export * from './lib/storage-utils';
3
+ export * from './lib/search-utils';
4
+ export * from './lib/versions-utils';
5
+ export * from './lib/star-utils';
5
6
  export * from './type';
package/build/index.js CHANGED
@@ -3,55 +3,70 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ Storage: true
8
+ };
9
+ Object.defineProperty(exports, "Storage", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _storage.Storage;
13
+ }
14
+ });
6
15
 
7
16
  var _storage = require("./storage");
8
17
 
9
- Object.keys(_storage).forEach(function (key) {
18
+ var _storageUtils = require("./lib/storage-utils");
19
+
20
+ Object.keys(_storageUtils).forEach(function (key) {
10
21
  if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _storage[key]) return;
22
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
+ if (key in exports && exports[key] === _storageUtils[key]) return;
12
24
  Object.defineProperty(exports, key, {
13
25
  enumerable: true,
14
26
  get: function () {
15
- return _storage[key];
27
+ return _storageUtils[key];
16
28
  }
17
29
  });
18
30
  });
19
31
 
20
- var _storageUtils = require("./storage-utils");
32
+ var _searchUtils = require("./lib/search-utils");
21
33
 
22
- Object.keys(_storageUtils).forEach(function (key) {
34
+ Object.keys(_searchUtils).forEach(function (key) {
23
35
  if (key === "default" || key === "__esModule") return;
24
- if (key in exports && exports[key] === _storageUtils[key]) return;
36
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
37
+ if (key in exports && exports[key] === _searchUtils[key]) return;
25
38
  Object.defineProperty(exports, key, {
26
39
  enumerable: true,
27
40
  get: function () {
28
- return _storageUtils[key];
41
+ return _searchUtils[key];
29
42
  }
30
43
  });
31
44
  });
32
45
 
33
- var _starUtils = require("./star-utils");
46
+ var _versionsUtils = require("./lib/versions-utils");
34
47
 
35
- Object.keys(_starUtils).forEach(function (key) {
48
+ Object.keys(_versionsUtils).forEach(function (key) {
36
49
  if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _starUtils[key]) return;
50
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
51
+ if (key in exports && exports[key] === _versionsUtils[key]) return;
38
52
  Object.defineProperty(exports, key, {
39
53
  enumerable: true,
40
54
  get: function () {
41
- return _starUtils[key];
55
+ return _versionsUtils[key];
42
56
  }
43
57
  });
44
58
  });
45
59
 
46
- var _search = require("./search");
60
+ var _starUtils = require("./lib/star-utils");
47
61
 
48
- Object.keys(_search).forEach(function (key) {
62
+ Object.keys(_starUtils).forEach(function (key) {
49
63
  if (key === "default" || key === "__esModule") return;
50
- if (key in exports && exports[key] === _search[key]) return;
64
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
65
+ if (key in exports && exports[key] === _starUtils[key]) return;
51
66
  Object.defineProperty(exports, key, {
52
67
  enumerable: true,
53
68
  get: function () {
54
- return _search[key];
69
+ return _starUtils[key];
55
70
  }
56
71
  });
57
72
  });
@@ -60,6 +75,7 @@ var _type = require("./type");
60
75
 
61
76
  Object.keys(_type).forEach(function (key) {
62
77
  if (key === "default" || key === "__esModule") return;
78
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
63
79
  if (key in exports && exports[key] === _type[key]) return;
64
80
  Object.defineProperty(exports, key, {
65
81
  enumerable: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './storage';\nexport * from './storage-utils';\nexport * from './star-utils';\nexport * from './search';\nexport * from './type';\n"],"file":"index.js"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { Storage } from './storage';\nexport * from './lib/storage-utils';\nexport * from './lib/search-utils';\nexport * from './lib/versions-utils';\nexport * from './lib/star-utils';\nexport * from './type';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,15 @@
1
+ /// <reference types="node" />
2
+ import { Transform } from 'stream';
3
+ export declare class TransFormResults extends Transform {
4
+ constructor(options: any);
5
+ /**
6
+ * Transform either array of packages or a single package into a stream of packages.
7
+ * From uplinks the chunks are array but from local packages are objects.
8
+ * @param {string} chunk
9
+ * @param {string} encoding
10
+ * @param {function} done
11
+ * @returns {void}
12
+ * @override
13
+ */
14
+ _transform(chunk: any, _encoding: any, callback: any): any;
15
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TransFormResults = void 0;
7
+
8
+ var _debug = _interopRequireDefault(require("debug"));
9
+
10
+ var _lodash = _interopRequireDefault(require("lodash"));
11
+
12
+ var _stream = require("stream");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const debug = (0, _debug.default)('verdaccio:storage:search:transform');
17
+
18
+ class TransFormResults extends _stream.Transform {
19
+ constructor(options) {
20
+ super(options);
21
+ }
22
+ /**
23
+ * Transform either array of packages or a single package into a stream of packages.
24
+ * From uplinks the chunks are array but from local packages are objects.
25
+ * @param {string} chunk
26
+ * @param {string} encoding
27
+ * @param {function} done
28
+ * @returns {void}
29
+ * @override
30
+ */
31
+
32
+
33
+ _transform(chunk, _encoding, callback) {
34
+ if (_lodash.default.isArray(chunk)) {
35
+ // from remotes we should expect chunks as arrays
36
+ chunk.filter(pkgItem => {
37
+ var _pkgItem$package;
38
+
39
+ debug(`streaming remote pkg name ${pkgItem === null || pkgItem === void 0 ? void 0 : (_pkgItem$package = pkgItem.package) === null || _pkgItem$package === void 0 ? void 0 : _pkgItem$package.name}`);
40
+ return true;
41
+ }).forEach(pkgItem => {
42
+ this.push({ ...pkgItem,
43
+ verdaccioPkgCached: false,
44
+ verdaccioPrivate: false
45
+ });
46
+ });
47
+ return callback();
48
+ } else {
49
+ var _chunk$package;
50
+
51
+ // local we expect objects
52
+ debug(`streaming local pkg name ${chunk === null || chunk === void 0 ? void 0 : (_chunk$package = chunk.package) === null || _chunk$package === void 0 ? void 0 : _chunk$package.name}`);
53
+ this.push(chunk);
54
+ return callback();
55
+ }
56
+ }
57
+
58
+ }
59
+
60
+ exports.TransFormResults = TransFormResults;
61
+ //# sourceMappingURL=TransFormResults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransFormResults.js","names":["debug","buildDebug","TransFormResults","Transform","constructor","options","_transform","chunk","_encoding","callback","_","isArray","filter","pkgItem","package","name","forEach","push","verdaccioPkgCached","verdaccioPrivate"],"sources":["../../src/lib/TransFormResults.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\nimport { Transform } from 'stream';\n\nimport { searchUtils } from '@verdaccio/core';\n\nconst debug = buildDebug('verdaccio:storage:search:transform');\n\nexport class TransFormResults extends Transform {\n public constructor(options) {\n super(options);\n }\n\n /**\n * Transform either array of packages or a single package into a stream of packages.\n * From uplinks the chunks are array but from local packages are objects.\n * @param {string} chunk\n * @param {string} encoding\n * @param {function} done\n * @returns {void}\n * @override\n */\n public _transform(chunk, _encoding, callback) {\n if (_.isArray(chunk)) {\n // from remotes we should expect chunks as arrays\n (chunk as searchUtils.SearchItem[])\n .filter((pkgItem) => {\n debug(`streaming remote pkg name ${pkgItem?.package?.name}`);\n return true;\n })\n .forEach((pkgItem) => {\n this.push({ ...pkgItem, verdaccioPkgCached: false, verdaccioPrivate: false });\n });\n return callback();\n } else {\n // local we expect objects\n debug(`streaming local pkg name ${chunk?.package?.name}`);\n this.push(chunk);\n return callback();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAIA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,oCAAX,CAAd;;AAEO,MAAMC,gBAAN,SAA+BC,iBAA/B,CAAyC;EACvCC,WAAW,CAACC,OAAD,EAAU;IAC1B,MAAMA,OAAN;EACD;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;EACSC,UAAU,CAACC,KAAD,EAAQC,SAAR,EAAmBC,QAAnB,EAA6B;IAC5C,IAAIC,eAAA,CAAEC,OAAF,CAAUJ,KAAV,CAAJ,EAAsB;MACpB;MACCA,KAAD,CACGK,MADH,CACWC,OAAD,IAAa;QAAA;;QACnBb,KAAK,CAAE,6BAA4Ba,OAA7B,aAA6BA,OAA7B,2CAA6BA,OAAO,CAAEC,OAAtC,qDAA6B,iBAAkBC,IAAK,EAArD,CAAL;QACA,OAAO,IAAP;MACD,CAJH,EAKGC,OALH,CAKYH,OAAD,IAAa;QACpB,KAAKI,IAAL,CAAU,EAAE,GAAGJ,OAAL;UAAcK,kBAAkB,EAAE,KAAlC;UAAyCC,gBAAgB,EAAE;QAA3D,CAAV;MACD,CAPH;MAQA,OAAOV,QAAQ,EAAf;IACD,CAXD,MAWO;MAAA;;MACL;MACAT,KAAK,CAAE,4BAA2BO,KAA5B,aAA4BA,KAA5B,yCAA4BA,KAAK,CAAEO,OAAnC,mDAA4B,eAAgBC,IAAK,EAAlD,CAAL;MACA,KAAKE,IAAL,CAAUV,KAAV;MACA,OAAOE,QAAQ,EAAf;IACD;EACF;;AAhC6C"}
@@ -0,0 +1,4 @@
1
+ import { searchUtils } from '@verdaccio/core';
2
+ import { Manifest } from '@verdaccio/types';
3
+ export declare function removeDuplicates(results: searchUtils.SearchPackageItem[]): searchUtils.SearchPackageItem[];
4
+ export declare function mapManifestToSearchPackageBody(pkg: Manifest, searchItem: searchUtils.SearchItem): searchUtils.SearchPackageBody;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mapManifestToSearchPackageBody = mapManifestToSearchPackageBody;
7
+ exports.removeDuplicates = removeDuplicates;
8
+
9
+ var _lodash = require("lodash");
10
+
11
+ var _core = require("@verdaccio/core");
12
+
13
+ function removeDuplicates(results) {
14
+ const pkgNames = [];
15
+ const orderByResults = (0, _lodash.orderBy)(results, ['verdaccioPrivate', 'asc']);
16
+ return orderByResults.filter(pkg => {
17
+ var _pkg$package, _pkg$package2;
18
+
19
+ if (pkgNames.includes(pkg === null || pkg === void 0 ? void 0 : (_pkg$package = pkg.package) === null || _pkg$package === void 0 ? void 0 : _pkg$package.name)) {
20
+ return false;
21
+ }
22
+
23
+ pkgNames.push(pkg === null || pkg === void 0 ? void 0 : (_pkg$package2 = pkg.package) === null || _pkg$package2 === void 0 ? void 0 : _pkg$package2.name);
24
+ return true;
25
+ });
26
+ }
27
+
28
+ function mapManifestToSearchPackageBody(pkg, searchItem) {
29
+ const latest = _core.pkgUtils.getLatest(pkg);
30
+
31
+ const version = pkg.versions[latest];
32
+ const result = {
33
+ name: version.name,
34
+ scope: '',
35
+ description: version.description,
36
+ version: latest,
37
+ keywords: version.keywords,
38
+ date: pkg.time[latest],
39
+ // FIXME: type
40
+ author: version.author,
41
+ // FIXME: not possible fill this out from a private package
42
+ publisher: {},
43
+ // FIXME: type
44
+ maintainers: version.maintainers,
45
+ links: {
46
+ npm: '',
47
+ homepage: version.homepage,
48
+ repository: version.repository,
49
+ bugs: version.bugs
50
+ }
51
+ };
52
+
53
+ if (typeof searchItem.package.scoped === 'string') {
54
+ result.scope = searchItem.package.scoped;
55
+ }
56
+
57
+ return result;
58
+ }
59
+ //# sourceMappingURL=search-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-utils.js","names":["removeDuplicates","results","pkgNames","orderByResults","orderBy","filter","pkg","includes","package","name","push","mapManifestToSearchPackageBody","searchItem","latest","pkgUtils","getLatest","version","versions","result","scope","description","keywords","date","time","author","publisher","maintainers","links","npm","homepage","repository","bugs","scoped"],"sources":["../../src/lib/search-utils.ts"],"sourcesContent":["import { orderBy } from 'lodash';\n\nimport { pkgUtils, searchUtils } from '@verdaccio/core';\nimport { Manifest, Version } from '@verdaccio/types';\n\nexport function removeDuplicates(results: searchUtils.SearchPackageItem[]) {\n const pkgNames: any[] = [];\n const orderByResults = orderBy(results, ['verdaccioPrivate', 'asc']);\n return orderByResults.filter((pkg) => {\n if (pkgNames.includes(pkg?.package?.name)) {\n return false;\n }\n pkgNames.push(pkg?.package?.name);\n return true;\n });\n}\n\nexport function mapManifestToSearchPackageBody(\n pkg: Manifest,\n searchItem: searchUtils.SearchItem\n): searchUtils.SearchPackageBody {\n const latest = pkgUtils.getLatest(pkg);\n const version: Version = pkg.versions[latest];\n const result: searchUtils.SearchPackageBody = {\n name: version.name,\n scope: '',\n description: version.description,\n version: latest,\n keywords: version.keywords,\n date: pkg.time[latest],\n // FIXME: type\n author: version.author as any,\n // FIXME: not possible fill this out from a private package\n publisher: {},\n // FIXME: type\n maintainers: version.maintainers as any,\n links: {\n npm: '',\n homepage: version.homepage,\n repository: version.repository,\n bugs: version.bugs,\n },\n };\n\n if (typeof searchItem.package.scoped === 'string') {\n result.scope = searchItem.package.scoped;\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;AAAA;;AAEA;;AAGO,SAASA,gBAAT,CAA0BC,OAA1B,EAAoE;EACzE,MAAMC,QAAe,GAAG,EAAxB;EACA,MAAMC,cAAc,GAAG,IAAAC,eAAA,EAAQH,OAAR,EAAiB,CAAC,kBAAD,EAAqB,KAArB,CAAjB,CAAvB;EACA,OAAOE,cAAc,CAACE,MAAf,CAAuBC,GAAD,IAAS;IAAA;;IACpC,IAAIJ,QAAQ,CAACK,QAAT,CAAkBD,GAAlB,aAAkBA,GAAlB,uCAAkBA,GAAG,CAAEE,OAAvB,iDAAkB,aAAcC,IAAhC,CAAJ,EAA2C;MACzC,OAAO,KAAP;IACD;;IACDP,QAAQ,CAACQ,IAAT,CAAcJ,GAAd,aAAcA,GAAd,wCAAcA,GAAG,CAAEE,OAAnB,kDAAc,cAAcC,IAA5B;IACA,OAAO,IAAP;EACD,CANM,CAAP;AAOD;;AAEM,SAASE,8BAAT,CACLL,GADK,EAELM,UAFK,EAG0B;EAC/B,MAAMC,MAAM,GAAGC,cAAA,CAASC,SAAT,CAAmBT,GAAnB,CAAf;;EACA,MAAMU,OAAgB,GAAGV,GAAG,CAACW,QAAJ,CAAaJ,MAAb,CAAzB;EACA,MAAMK,MAAqC,GAAG;IAC5CT,IAAI,EAAEO,OAAO,CAACP,IAD8B;IAE5CU,KAAK,EAAE,EAFqC;IAG5CC,WAAW,EAAEJ,OAAO,CAACI,WAHuB;IAI5CJ,OAAO,EAAEH,MAJmC;IAK5CQ,QAAQ,EAAEL,OAAO,CAACK,QAL0B;IAM5CC,IAAI,EAAEhB,GAAG,CAACiB,IAAJ,CAASV,MAAT,CANsC;IAO5C;IACAW,MAAM,EAAER,OAAO,CAACQ,MAR4B;IAS5C;IACAC,SAAS,EAAE,EAViC;IAW5C;IACAC,WAAW,EAAEV,OAAO,CAACU,WAZuB;IAa5CC,KAAK,EAAE;MACLC,GAAG,EAAE,EADA;MAELC,QAAQ,EAAEb,OAAO,CAACa,QAFb;MAGLC,UAAU,EAAEd,OAAO,CAACc,UAHf;MAILC,IAAI,EAAEf,OAAO,CAACe;IAJT;EAbqC,CAA9C;;EAqBA,IAAI,OAAOnB,UAAU,CAACJ,OAAX,CAAmBwB,MAA1B,KAAqC,QAAzC,EAAmD;IACjDd,MAAM,CAACC,KAAP,GAAeP,UAAU,CAACJ,OAAX,CAAmBwB,MAAlC;EACD;;EAED,OAAOd,MAAP;AACD"}
@@ -0,0 +1,14 @@
1
+ import { Manifest } from '@verdaccio/types';
2
+ import { Users } from '../type';
3
+ /**
4
+ * Check whether the package metadta has enough data to be published
5
+ * @param pkg metadata
6
+ */
7
+ /**
8
+ * Check whether the package metadta has enough data to be published
9
+ * @param pkg metadata
10
+ */
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;
14
+ export declare function isStarManifest(manifest: Manifest): boolean;
@@ -5,20 +5,30 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isPublishablePackage = isPublishablePackage;
7
7
  exports.isRelatedToDeprecation = isRelatedToDeprecation;
8
+ exports.isStarManifest = isStarManifest;
8
9
  exports.validateInputs = validateInputs;
9
10
 
10
11
  var _lodash = _interopRequireDefault(require("lodash"));
11
12
 
13
+ var _core = require("@verdaccio/core");
14
+
12
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
16
 
17
+ /**
18
+ * Check whether the package metadta has enough data to be published
19
+ * @param pkg metadata
20
+ */
21
+
14
22
  /**
15
23
  * Check whether the package metadta has enough data to be published
16
24
  * @param pkg metadata
17
25
  */
18
26
  function isPublishablePackage(pkg) {
27
+ // TODO: we can do better, no need get keys
19
28
  const keys = Object.keys(pkg);
20
- return _lodash.default.includes(keys, 'versions');
21
- }
29
+ return keys.includes('versions');
30
+ } // @deprecated don't think this is used anymore (REMOVE)
31
+
22
32
 
23
33
  function isRelatedToDeprecation(pkgInfo) {
24
34
  const {
@@ -47,4 +57,8 @@ function validateInputs(localUsers, username, isStar) {
47
57
 
48
58
  return false;
49
59
  }
60
+
61
+ function isStarManifest(manifest) {
62
+ return isPublishablePackage(manifest) === false && _core.validatioUtils.isObject(manifest.users);
63
+ }
50
64
  //# sourceMappingURL=star-utils.js.map
@@ -0,0 +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"}
@@ -0,0 +1,82 @@
1
+ import { AttachMents, Manifest, Version, Versions } from '@verdaccio/types';
2
+ export declare const STORAGE: {
3
+ PACKAGE_FILE_NAME: string;
4
+ FILE_EXIST_ERROR: string;
5
+ NO_SUCH_FILE_ERROR: string;
6
+ DEFAULT_REVISION: string;
7
+ };
8
+ /**
9
+ * Create a new package in the storage, return a boilerplate package
10
+ * @param name package name
11
+ * @returns {Manifest}
12
+ */
13
+ export declare function generatePackageTemplate(name: string): Manifest;
14
+ /**
15
+ * Normalize package properties, tags, revision id.
16
+ * @param {Object} pkg package reference.
17
+ */
18
+ export declare function normalizePackage(pkg: Manifest): Manifest;
19
+ export declare function generateRevision(rev: string): string;
20
+ export declare function getLatestReadme(pkg: Manifest): string;
21
+ export declare function cleanUpReadme(version: any): Version;
22
+ export declare const WHITELIST: string[];
23
+ export declare function cleanUpLinksRef(result: Manifest, keepUpLinkData?: boolean): Manifest;
24
+ export declare function checkPackageRemote(name: string, isAllowPublishOffline: boolean, syncMetadata: Function): Promise<any>;
25
+ export declare function mergeUplinkTimeIntoLocal(localMetadata: Manifest, remoteMetadata: Manifest): any;
26
+ export declare function mergeUplinkTimeIntoLocalNext(cacheManifest: Manifest, remoteManifest: Manifest): Manifest;
27
+ export declare function updateUpLinkMetadata(uplinkId: any, manifest: Manifest, etag: string): {
28
+ _uplinks: {};
29
+ _distfiles: import("@verdaccio/types").DistFiles;
30
+ _rev: string;
31
+ _id?: string | undefined;
32
+ name: string;
33
+ description?: string | undefined;
34
+ 'dist-tags': import("@verdaccio/types").GenericBody;
35
+ time: import("@verdaccio/types").GenericBody;
36
+ versions: Versions;
37
+ maintainers?: import("@verdaccio/types").Author[] | undefined;
38
+ readme?: string | undefined;
39
+ users?: import("@verdaccio/types").PackageUsers | undefined;
40
+ access?: any;
41
+ bugs?: {
42
+ url: string;
43
+ } | undefined;
44
+ license?: string | undefined;
45
+ homepage?: string | undefined;
46
+ repository?: string | {
47
+ type?: string | undefined;
48
+ url: string;
49
+ directory?: string | undefined;
50
+ } | undefined;
51
+ keywords?: string[] | undefined;
52
+ _attachments: AttachMents;
53
+ };
54
+ export declare function prepareSearchPackage(data: Manifest): any;
55
+ export declare function isDifferentThanOne(versions: Versions | AttachMents): boolean;
56
+ export declare function hasInvalidPublishBody(manifest: Pick<Manifest, '_attachments' | 'versions'>): boolean;
57
+ /**
58
+ * Function gets a local info and an info from uplinks and tries to merge it
59
+ exported for unit tests only.
60
+ * @param {*} local
61
+ * @param {*} remoteManifest
62
+ * @param {*} config configuration file
63
+ */
64
+ export declare function mergeVersions(cacheManifest: Manifest, remoteManifest: Manifest): Manifest;
65
+ /**
66
+ * Normalize dist-tags.
67
+ *
68
+ * There is a legacy behaviour where the dist-tags could be an array, in such
69
+ * case, the array is orderded and the highest version becames the
70
+ * latest.
71
+ *
72
+ * The dist-tag tags must be plain strigs, if the latest is empty (for whatever reason) is
73
+ * normalized to be the highest version available.
74
+ *
75
+ * This function cleans up every invalid version on dist-tags, but does not remove
76
+ * invalid versions from the manifest.
77
+ *
78
+ * @param {*} data
79
+ */
80
+ export declare function normalizeDistTags(manifest: Manifest): Manifest;
81
+ export declare function hasDeprecatedVersions(pkgInfo: Manifest): boolean;
82
+ export declare function isDeprecatedManifest(manifest: Manifest): boolean;