@verdaccio/core 6.0.0-6-next.2 → 6.0.0-6-next.5

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,53 @@
1
1
  # @verdaccio/core
2
2
 
3
+ ## 6.0.0-6-next.5
4
+
5
+ ### Major Changes
6
+
7
+ - 82cb0f2b: feat!: config.logs throw an error, logging config not longer accept array or logs property
8
+
9
+ ### 💥 Breaking change
10
+
11
+ This is valid
12
+
13
+ ```yaml
14
+ log: { type: stdout, format: pretty, level: http }
15
+ ```
16
+
17
+ This is invalid
18
+
19
+ ```yaml
20
+ logs: { type: stdout, format: pretty, level: http }
21
+ ```
22
+
23
+ or
24
+
25
+ ```yaml
26
+ logs:
27
+ - [{ type: stdout, format: pretty, level: http }]
28
+ ```
29
+
30
+ ### Minor Changes
31
+
32
+ - 5167bb52: feat: ui search support for remote, local and private packages
33
+
34
+ The command `npm search` search globally and return all matches, with this improvement the user interface
35
+ is powered with the same capabilities.
36
+
37
+ The UI also tag where is the origin the package with a tag, also provide the latest version and description of the package.
38
+
39
+ ## 6.0.0-6-next.4
40
+
41
+ ### Minor Changes
42
+
43
+ - 24b9be02: refactor: improve docker image build with strict dependencies and prod build
44
+
45
+ ## 6.0.0-6-next.3
46
+
47
+ ### Minor Changes
48
+
49
+ - 6c1eb021: feat: use warning codes for deprecation warnings
50
+
3
51
  ## 6.0.0-6-next.2
4
52
 
5
53
  ### Major Changes
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LOG_VERDACCIO_BYTES = exports.LOG_VERDACCIO_ERROR = exports.LOG_STATUS_MESSAGE = exports.API_MESSAGE = exports.ERROR_CODE = exports.HTTP_STATUS = exports.HEADERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.CHARACTER_ENCODING = exports.HEADER_TYPE = exports.DEFAULT_USER = exports.USERS = exports.LATEST = exports.DIST_TAGS = exports.TIME_EXPIRATION_7D = exports.TIME_EXPIRATION_24H = exports.DEFAULT_MIN_LIMIT_PASSWORD = void 0;
6
+ exports.USERS = exports.TOKEN_BEARER = exports.TOKEN_BASIC = exports.TIME_EXPIRATION_7D = exports.TIME_EXPIRATION_24H = exports.LOG_VERDACCIO_ERROR = exports.LOG_VERDACCIO_BYTES = exports.LOG_STATUS_MESSAGE = exports.LATEST = exports.HTTP_STATUS = exports.HEADER_TYPE = exports.HEADERS = exports.ERROR_CODE = exports.DIST_TAGS = exports.DEFAULT_USER = exports.DEFAULT_MIN_LIMIT_PASSWORD = exports.CHARACTER_ENCODING = exports.API_MESSAGE = void 0;
7
7
 
8
8
  var _httpStatusCodes = _interopRequireDefault(require("http-status-codes"));
9
9
 
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getConflict = getConflict;
6
+ exports.SUPPORT_ERRORS = exports.APP_ERROR = exports.API_ERROR = void 0;
7
7
  exports.getBadData = getBadData;
8
8
  exports.getBadRequest = getBadRequest;
9
- exports.getInternalError = getInternalError;
10
- exports.getUnauthorized = getUnauthorized;
9
+ exports.getCode = getCode;
10
+ exports.getConflict = getConflict;
11
11
  exports.getForbidden = getForbidden;
12
- exports.getServiceUnavailable = getServiceUnavailable;
12
+ exports.getInternalError = getInternalError;
13
13
  exports.getNotFound = getNotFound;
14
- exports.getCode = getCode;
15
- exports.APP_ERROR = exports.SUPPORT_ERRORS = exports.API_ERROR = void 0;
14
+ exports.getServiceUnavailable = getServiceUnavailable;
15
+ exports.getUnauthorized = getUnauthorized;
16
16
 
17
17
  var _httpErrors = _interopRequireDefault(require("http-errors"));
18
18
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/error-utils.ts"],"names":["API_ERROR","PASSWORD_SHORT","passLength","DEFAULT_MIN_LIMIT_PASSWORD","MUST_BE_LOGGED","PLUGIN_ERROR","CONFIG_BAD_FORMAT","BAD_USERNAME_PASSWORD","NO_PACKAGE","PACKAGE_CANNOT_BE_ADDED","BAD_DATA","NOT_ALLOWED","NOT_ALLOWED_PUBLISH","INTERNAL_SERVER_ERROR","UNKNOWN_ERROR","NOT_PACKAGE_UPLINK","UPLINK_OFFLINE_PUBLISH","UPLINK_OFFLINE","CONTENT_MISMATCH","NOT_FILE_UPLINK","MAX_USERS_REACHED","VERSION_NOT_EXIST","UNSUPORTED_REGISTRY_CALL","FILE_NOT_FOUND","REGISTRATION_DISABLED","UNAUTHORIZED_ACCESS","BAD_STATUS_CODE","PACKAGE_EXIST","BAD_AUTH_HEADER","WEB_DISABLED","DEPRECATED_BASIC_HEADER","BAD_FORMAT_USER_GROUP","RESOURCE_UNAVAILABLE","BAD_PACKAGE_DATA","USERNAME_PASSWORD_REQUIRED","USERNAME_ALREADY_REGISTERED","SUPPORT_ERRORS","PLUGIN_MISSING_INTERFACE","TFA_DISABLED","STORAGE_NOT_IMPLEMENT","PARAMETERS_NOT_VALID","APP_ERROR","CONFIG_NOT_VALID","PROFILE_ERROR","PASSWORD_VALIDATION","getError","code","message","httpError","getConflict","HTTP_STATUS","CONFLICT","getBadData","customMessage","getBadRequest","BAD_REQUEST","getInternalError","INTERNAL_ERROR","getUnauthorized","UNAUTHORIZED","getForbidden","FORBIDDEN","getServiceUnavailable","SERVICE_UNAVAILABLE","getNotFound","NOT_FOUND","getCode","statusCode"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;;;;AAEO,MAAMA,SAAS,GAAG;AACvBC,EAAAA,cAAc,EAAE,CAACC,UAAU,GAAGC,qCAAd,KACb,yEAAD,GACC,GAAED,UAAW,cAHO;AAIvBE,EAAAA,cAAc,EAAE,4CAJO;AAKvBC,EAAAA,YAAY,EAAE,+BALS;AAMvBC,EAAAA,iBAAiB,EAAE,+BANI;AAOvBC,EAAAA,qBAAqB,EAAE,sCAPA;AAQvBC,EAAAA,UAAU,EAAE,2BARW;AASvBC,EAAAA,uBAAuB,EAAE,8BATF;A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B,OAAlC,CAAf;AACD;;AAEM,SAASiB,WAAT,CAAqBX,aAArB,EAA6D;AAClE,SAAOR,QAAQ,CAACK,uBAAYe,SAAb,EAAwBZ,aAAa,IAAIrD,SAAS,CAACQ,UAAnD,CAAf;AACD;;AAEM,SAAS0D,OAAT,CAAiBC,UAAjB,EAAqCd,aAArC,EAA4E;AACjF,SAAOR,QAAQ,CAACsB,UAAD,EAAad,aAAb,CAAf;AACD","sourcesContent":["import createError, { HttpError } from 'http-errors';\nimport { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';\n\nexport const API_ERROR = {\n PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>\n `The provided password is too short. Please pick a password longer than ` +\n `${passLength} characters.`,\n MUST_BE_LOGGED: 'You must be logged in to publish packages.',\n PLUGIN_ERROR: 'bug in the auth plugin system',\n CONFIG_BAD_FORMAT: 'config file must be an object',\n BAD_USERNAME_PASSWORD: 'bad username/password, access denied',\n NO_PACKAGE: 'no such package available',\n PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added',\n BAD_DATA: 'bad data',\n NOT_ALLOWED: 'not allowed to access package',\n NOT_ALLOWED_PUBLISH: 'not allowed to publish package',\n INTERNAL_SERVER_ERROR: 'internal server error',\n UNKNOWN_ERROR: 'unknown error',\n NOT_PACKAGE_UPLINK: 'package does not exist on uplink',\n UPLINK_OFFLINE_PUBLISH: 'one of the uplinks is down, refuse to publish',\n UPLINK_OFFLINE: 'uplink is offline',\n CONTENT_MISMATCH: 'content length mismatch',\n NOT_FILE_UPLINK: \"file doesn't exist on uplink\",\n MAX_USERS_REACHED: 'maximum amount of users reached',\n VERSION_NOT_EXIST: \"this version doesn't exist\",\n UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',\n FILE_NOT_FOUND: 'File not found',\n REGISTRATION_DISABLED: 'user registration disabled',\n UNAUTHORIZED_ACCESS: 'unauthorized access',\n BAD_STATUS_CODE: 'bad status code',\n PACKAGE_EXIST: 'this package is already present',\n BAD_AUTH_HEADER: 'bad authorization header',\n WEB_DISABLED: 'Web interface is disabled in the config file',\n DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead',\n BAD_FORMAT_USER_GROUP: 'user groups is different than an array',\n RESOURCE_UNAVAILABLE: 'resource unavailable',\n BAD_PACKAGE_DATA: 'bad incoming package data',\n USERNAME_PASSWORD_REQUIRED: 'username and password is required',\n USERNAME_ALREADY_REGISTERED: 'username is already registered',\n};\n\nexport const SUPPORT_ERRORS = {\n PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',\n TFA_DISABLED: 'the two-factor authentication is not yet supported',\n STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',\n PARAMETERS_NOT_VALID: 'the parameters are not valid',\n};\n\nexport const APP_ERROR = {\n CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',\n PROFILE_ERROR: 'profile unexpected error',\n PASSWORD_VALIDATION: 'not valid password',\n};\n\nexport type VerdaccioError = HttpError & { code: number };\n\nfunction getError(code: number, message: string): VerdaccioError {\n const httpError = createError(code, message);\n\n httpError.code = code;\n\n return httpError as VerdaccioError;\n}\n\nexport function getConflict(message: string = API_ERROR.PACKAGE_EXIST): VerdaccioError {\n return getError(HTTP_STATUS.CONFLICT, message);\n}\n\nexport function getBadData(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);\n}\n\nexport function getBadRequest(customMessage: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_REQUEST, customMessage);\n}\n\nexport function getInternalError(customMessage?: string): VerdaccioError {\n return customMessage\n ? getError(HTTP_STATUS.INTERNAL_ERROR, customMessage)\n : getError(HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);\n}\n\nexport function getUnauthorized(message = 'no credentials provided'): VerdaccioError {\n return getError(HTTP_STATUS.UNAUTHORIZED, message);\n}\n\nexport function getForbidden(message = \"can't use this filename\"): VerdaccioError {\n return getError(HTTP_STATUS.FORBIDDEN, message);\n}\n\nexport function getServiceUnavailable(\n message: string = API_ERROR.RESOURCE_UNAVAILABLE\n): VerdaccioError {\n return getError(HTTP_STATUS.SERVICE_UNAVAILABLE, message);\n}\n\nexport function getNotFound(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);\n}\n\nexport function getCode(statusCode: number, customMessage: string): VerdaccioError {\n return getError(statusCode, customMessage);\n}\n"],"file":"error-utils.js"}
1
+ {"version":3,"sources":["../src/error-utils.ts"],"names":["API_ERROR","PASSWORD_SHORT","passLength","DEFAULT_MIN_LIMIT_PASSWORD","MUST_BE_LOGGED","PLUGIN_ERROR","CONFIG_BAD_FORMAT","BAD_USERNAME_PASSWORD","NO_PACKAGE","PACKAGE_CANNOT_BE_ADDED","BAD_DATA","NOT_ALLOWED","NOT_ALLOWED_PUBLISH","INTERNAL_SERVER_ERROR","UNKNOWN_ERROR","NOT_PACKAGE_UPLINK","UPLINK_OFFLINE_PUBLISH","UPLINK_OFFLINE","CONTENT_MISMATCH","NOT_FILE_UPLINK","MAX_USERS_REACHED","VERSION_NOT_EXIST","UNSUPORTED_REGISTRY_CALL","FILE_NOT_FOUND","REGISTRATION_DISABLED","UNAUTHORIZED_ACCESS","BAD_STATUS_CODE","PACKAGE_EXIST","BAD_AUTH_HEADER","WEB_DISABLED","DEPRECATED_BASIC_HEADER","BAD_FORMAT_USER_GROUP","RESOURCE_UNAVAILABLE","BAD_PACKAGE_DATA","USERNAME_PASSWORD_REQUIRED","USERNAME_ALREADY_REGISTERED","SUPPORT_ERRORS","PLUGIN_MISSING_INTERFACE","TFA_DISABLED","STORAGE_NOT_IMPLEMENT","PARAMETERS_NOT_VALID","APP_ERROR","CONFIG_NOT_VALID","PROFILE_ERROR","PASSWORD_VALIDATION","getError","code","message","httpError","getConflict","HTTP_STATUS","CONFLICT","getBadData","customMessage","getBadRequest","BAD_REQUEST","getInternalError","INTERNAL_ERROR","getUnauthorized","UNAUTHORIZED","getForbidden","FORBIDDEN","getServiceUnavailable","SERVICE_UNAVAILABLE","getNotFound","NOT_FOUND","getCode","statusCode"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AAEA;;;;AAEO,MAAMA,SAAS,GAAG;AACvBC,EAAAA,cAAc,EAAE,CAACC,UAAU,GAAGC,qCAAd,KACb,yEAAD,GACC,GAAED,UAAW,cAHO;AAIvBE,EAAAA,cAAc,EAAE,4CAJO;AAKvBC,EAAAA,YAAY,EAAE,+BALS;AAMvBC,EAAAA,iBAAiB,EAAE,+BANI;AAOvBC,EAAAA,qBAAqB,EAAE,sCAPA;AAQvBC,EAAAA,UAAU,EAAE,2BARW;AASvBC,EAAAA,uBAAuB,EAAE,8BATF;AAUvBC,EAAAA,QAAQ,EAAE,UAVa;AAWvBC,EAAAA,WAAW,EAAE,+BAXU;AAYvBC,EAAAA,mBAAmB,EAAE,gCAZE;AAavBC,EAAAA,qBAAqB,EAAE,uBAbA;AAcvBC,EAAAA,aAAa,EAAE,eAdQ;AAevBC,EAAAA,kBAAkB,EAAE,kCAfG;AAgBvBC,EAAAA,sBAAsB,EAAE,+CAhBD;AAiBvBC,EAAAA,cAAc,EAAE,mBAjBO;AAkBvBC,EAAAA,gBAAgB,EAAE,yBAlBK;AAmBvBC,EAAAA,eAAe,EAAE,8BAnBM;AAoBvBC,EAAAA,iBAAiB,EAAE,iCApBI;AAqBvBC,EAAAA,iBAAiB,EAAE,4BArBI;AAsBvBC,EAAAA,wBAAwB,EAAE,2BAtBH;AAuBvBC,EAAAA,cAAc,EAAE,gBAvBO;AAwBvBC,EAAAA,qBAAqB,EAAE,4BAxBA;AAyBvBC,EAAAA,mBAAmB,EAAE,qBAzBE;AA0BvBC,EAAAA,eAAe,EAAE,iBA1BM;AA2BvBC,EAAAA,aAAa,EAAE,iCA3BQ;AA4BvBC,EAAAA,eAAe,EAAE,0BA5BM;AA6BvBC,EAAAA,YAAY,E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,QAAQ,CAACK,uBAAYO,cAAb,EAA6BJ,aAA7B,CADQ,GAEhBR,QAAQ,CAACK,uBAAYO,cAAb,EAA6BzD,SAAS,CAACc,aAAvC,CAFZ;AAGD;;AAEM,SAAS4C,eAAT,CAAyBX,OAAO,GAAG,yBAAnC,EAA8E;AACnF,SAAOF,QAAQ,CAACK,uBAAYS,YAAb,EAA2BZ,OAA3B,CAAf;AACD;;AAEM,SAASa,YAAT,CAAsBb,OAAO,GAAG,yBAAhC,EAA2E;AAChF,SAAOF,QAAQ,CAACK,uBAAYW,SAAb,EAAwBd,OAAxB,CAAf;AACD;;AAEM,SAASe,qBAAT,CACLf,OAAe,GAAG/C,SAAS,CAACgC,oBADvB,EAEW;AAChB,SAAOa,QAAQ,CAACK,uBAAYa,mBAAb,EAAkChB,OAAlC,CAAf;AACD;;AAEM,SAASiB,WAAT,CAAqBX,aAArB,EAA6D;AAClE,SAAOR,QAAQ,CAACK,uBAAYe,SAAb,EAAwBZ,aAAa,IAAIrD,SAAS,CAACQ,UAAnD,CAAf;AACD;;AAEM,SAAS0D,OAAT,CAAiBC,UAAjB,EAAqCd,aAArC,EAA4E;AACjF,SAAOR,QAAQ,CAACsB,UAAD,EAAad,aAAb,CAAf;AACD","sourcesContent":["import createError, { HttpError } from 'http-errors';\n\nimport { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';\n\nexport const API_ERROR = {\n PASSWORD_SHORT: (passLength = DEFAULT_MIN_LIMIT_PASSWORD): string =>\n `The provided password is too short. Please pick a password longer than ` +\n `${passLength} characters.`,\n MUST_BE_LOGGED: 'You must be logged in to publish packages.',\n PLUGIN_ERROR: 'bug in the auth plugin system',\n CONFIG_BAD_FORMAT: 'config file must be an object',\n BAD_USERNAME_PASSWORD: 'bad username/password, access denied',\n NO_PACKAGE: 'no such package available',\n PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added',\n BAD_DATA: 'bad data',\n NOT_ALLOWED: 'not allowed to access package',\n NOT_ALLOWED_PUBLISH: 'not allowed to publish package',\n INTERNAL_SERVER_ERROR: 'internal server error',\n UNKNOWN_ERROR: 'unknown error',\n NOT_PACKAGE_UPLINK: 'package does not exist on uplink',\n UPLINK_OFFLINE_PUBLISH: 'one of the uplinks is down, refuse to publish',\n UPLINK_OFFLINE: 'uplink is offline',\n CONTENT_MISMATCH: 'content length mismatch',\n NOT_FILE_UPLINK: \"file doesn't exist on uplink\",\n MAX_USERS_REACHED: 'maximum amount of users reached',\n VERSION_NOT_EXIST: \"this version doesn't exist\",\n UNSUPORTED_REGISTRY_CALL: 'unsupported registry call',\n FILE_NOT_FOUND: 'File not found',\n REGISTRATION_DISABLED: 'user registration disabled',\n UNAUTHORIZED_ACCESS: 'unauthorized access',\n BAD_STATUS_CODE: 'bad status code',\n PACKAGE_EXIST: 'this package is already present',\n BAD_AUTH_HEADER: 'bad authorization header',\n WEB_DISABLED: 'Web interface is disabled in the config file',\n DEPRECATED_BASIC_HEADER: 'basic authentication is deprecated, please use JWT instead',\n BAD_FORMAT_USER_GROUP: 'user groups is different than an array',\n RESOURCE_UNAVAILABLE: 'resource unavailable',\n BAD_PACKAGE_DATA: 'bad incoming package data',\n USERNAME_PASSWORD_REQUIRED: 'username and password is required',\n USERNAME_ALREADY_REGISTERED: 'username is already registered',\n};\n\nexport const SUPPORT_ERRORS = {\n PLUGIN_MISSING_INTERFACE: 'the plugin does not provide implementation of the requested feature',\n TFA_DISABLED: 'the two-factor authentication is not yet supported',\n STORAGE_NOT_IMPLEMENT: 'the storage does not support token saving',\n PARAMETERS_NOT_VALID: 'the parameters are not valid',\n};\n\nexport const APP_ERROR = {\n CONFIG_NOT_VALID: 'CONFIG: it does not look like a valid config file',\n PROFILE_ERROR: 'profile unexpected error',\n PASSWORD_VALIDATION: 'not valid password',\n};\n\nexport type VerdaccioError = HttpError & { code: number };\n\nfunction getError(code: number, message: string): VerdaccioError {\n const httpError = createError(code, message);\n\n httpError.code = code;\n\n return httpError as VerdaccioError;\n}\n\nexport function getConflict(message: string = API_ERROR.PACKAGE_EXIST): VerdaccioError {\n return getError(HTTP_STATUS.CONFLICT, message);\n}\n\nexport function getBadData(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_DATA, customMessage || API_ERROR.BAD_DATA);\n}\n\nexport function getBadRequest(customMessage: string): VerdaccioError {\n return getError(HTTP_STATUS.BAD_REQUEST, customMessage);\n}\n\nexport function getInternalError(customMessage?: string): VerdaccioError {\n return customMessage\n ? getError(HTTP_STATUS.INTERNAL_ERROR, customMessage)\n : getError(HTTP_STATUS.INTERNAL_ERROR, API_ERROR.UNKNOWN_ERROR);\n}\n\nexport function getUnauthorized(message = 'no credentials provided'): VerdaccioError {\n return getError(HTTP_STATUS.UNAUTHORIZED, message);\n}\n\nexport function getForbidden(message = \"can't use this filename\"): VerdaccioError {\n return getError(HTTP_STATUS.FORBIDDEN, message);\n}\n\nexport function getServiceUnavailable(\n message: string = API_ERROR.RESOURCE_UNAVAILABLE\n): VerdaccioError {\n return getError(HTTP_STATUS.SERVICE_UNAVAILABLE, message);\n}\n\nexport function getNotFound(customMessage?: string): VerdaccioError {\n return getError(HTTP_STATUS.NOT_FOUND, customMessage || API_ERROR.NO_PACKAGE);\n}\n\nexport function getCode(statusCode: number, customMessage: string): VerdaccioError {\n return getError(statusCode, customMessage);\n}\n"],"file":"error-utils.js"}
package/build/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
- import * as searchUtils from './search-utils';
2
- import * as streamUtils from './stream-utils';
3
- import * as errorUtils from './error-utils';
4
- import * as validatioUtils from './validation-utils';
5
1
  import * as constants from './constants';
6
- import * as pluginUtils from './plugin-utils';
2
+ import * as errorUtils from './error-utils';
7
3
  import * as fileUtils from './file-utils';
8
4
  import * as pkgUtils from './pkg-utils';
5
+ import * as pluginUtils from './plugin-utils';
6
+ import * as searchUtils from './search-utils';
7
+ import * as streamUtils from './stream-utils';
8
+ import * as validatioUtils from './validation-utils';
9
+ import * as warningUtils from './warning-utils';
9
10
  export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
10
11
  export { TOKEN_BASIC, TOKEN_BEARER, HTTP_STATUS, API_MESSAGE, HEADERS, DIST_TAGS, CHARACTER_ENCODING, HEADER_TYPE, LATEST, DEFAULT_MIN_LIMIT_PASSWORD, DEFAULT_USER, USERS, } from './constants';
11
- export { fileUtils, pkgUtils, searchUtils, streamUtils, errorUtils, validatioUtils, constants, pluginUtils, };
12
+ export { fileUtils, pkgUtils, searchUtils, streamUtils, errorUtils, validatioUtils, constants, pluginUtils, warningUtils, };
package/build/index.js CHANGED
@@ -1,26 +1,18 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/esnext.weak-map.delete-all.js");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- Object.defineProperty(exports, "VerdaccioError", {
9
- enumerable: true,
10
- get: function () {
11
- return errorUtils.VerdaccioError;
12
- }
13
- });
14
6
  Object.defineProperty(exports, "API_ERROR", {
15
7
  enumerable: true,
16
8
  get: function () {
17
9
  return errorUtils.API_ERROR;
18
10
  }
19
11
  });
20
- Object.defineProperty(exports, "SUPPORT_ERRORS", {
12
+ Object.defineProperty(exports, "API_MESSAGE", {
21
13
  enumerable: true,
22
14
  get: function () {
23
- return errorUtils.SUPPORT_ERRORS;
15
+ return constants.API_MESSAGE;
24
16
  }
25
17
  });
26
18
  Object.defineProperty(exports, "APP_ERROR", {
@@ -29,28 +21,28 @@ Object.defineProperty(exports, "APP_ERROR", {
29
21
  return errorUtils.APP_ERROR;
30
22
  }
31
23
  });
32
- Object.defineProperty(exports, "TOKEN_BASIC", {
24
+ Object.defineProperty(exports, "CHARACTER_ENCODING", {
33
25
  enumerable: true,
34
26
  get: function () {
35
- return constants.TOKEN_BASIC;
27
+ return constants.CHARACTER_ENCODING;
36
28
  }
37
29
  });
38
- Object.defineProperty(exports, "TOKEN_BEARER", {
30
+ Object.defineProperty(exports, "DEFAULT_MIN_LIMIT_PASSWORD", {
39
31
  enumerable: true,
40
32
  get: function () {
41
- return constants.TOKEN_BEARER;
33
+ return constants.DEFAULT_MIN_LIMIT_PASSWORD;
42
34
  }
43
35
  });
44
- Object.defineProperty(exports, "HTTP_STATUS", {
36
+ Object.defineProperty(exports, "DEFAULT_USER", {
45
37
  enumerable: true,
46
38
  get: function () {
47
- return constants.HTTP_STATUS;
39
+ return constants.DEFAULT_USER;
48
40
  }
49
41
  });
50
- Object.defineProperty(exports, "API_MESSAGE", {
42
+ Object.defineProperty(exports, "DIST_TAGS", {
51
43
  enumerable: true,
52
44
  get: function () {
53
- return constants.API_MESSAGE;
45
+ return constants.DIST_TAGS;
54
46
  }
55
47
  });
56
48
  Object.defineProperty(exports, "HEADERS", {
@@ -59,40 +51,40 @@ Object.defineProperty(exports, "HEADERS", {
59
51
  return constants.HEADERS;
60
52
  }
61
53
  });
62
- Object.defineProperty(exports, "DIST_TAGS", {
54
+ Object.defineProperty(exports, "HEADER_TYPE", {
63
55
  enumerable: true,
64
56
  get: function () {
65
- return constants.DIST_TAGS;
57
+ return constants.HEADER_TYPE;
66
58
  }
67
59
  });
68
- Object.defineProperty(exports, "CHARACTER_ENCODING", {
60
+ Object.defineProperty(exports, "HTTP_STATUS", {
69
61
  enumerable: true,
70
62
  get: function () {
71
- return constants.CHARACTER_ENCODING;
63
+ return constants.HTTP_STATUS;
72
64
  }
73
65
  });
74
- Object.defineProperty(exports, "HEADER_TYPE", {
66
+ Object.defineProperty(exports, "LATEST", {
75
67
  enumerable: true,
76
68
  get: function () {
77
- return constants.HEADER_TYPE;
69
+ return constants.LATEST;
78
70
  }
79
71
  });
80
- Object.defineProperty(exports, "LATEST", {
72
+ Object.defineProperty(exports, "SUPPORT_ERRORS", {
81
73
  enumerable: true,
82
74
  get: function () {
83
- return constants.LATEST;
75
+ return errorUtils.SUPPORT_ERRORS;
84
76
  }
85
77
  });
86
- Object.defineProperty(exports, "DEFAULT_MIN_LIMIT_PASSWORD", {
78
+ Object.defineProperty(exports, "TOKEN_BASIC", {
87
79
  enumerable: true,
88
80
  get: function () {
89
- return constants.DEFAULT_MIN_LIMIT_PASSWORD;
81
+ return constants.TOKEN_BASIC;
90
82
  }
91
83
  });
92
- Object.defineProperty(exports, "DEFAULT_USER", {
84
+ Object.defineProperty(exports, "TOKEN_BEARER", {
93
85
  enumerable: true,
94
86
  get: function () {
95
- return constants.DEFAULT_USER;
87
+ return constants.TOKEN_BEARER;
96
88
  }
97
89
  });
98
90
  Object.defineProperty(exports, "USERS", {
@@ -101,39 +93,49 @@ Object.defineProperty(exports, "USERS", {
101
93
  return constants.USERS;
102
94
  }
103
95
  });
104
- exports.pkgUtils = exports.fileUtils = exports.pluginUtils = exports.constants = exports.validatioUtils = exports.errorUtils = exports.streamUtils = exports.searchUtils = void 0;
105
-
106
- var searchUtils = _interopRequireWildcard(require("./search-utils"));
107
-
108
- exports.searchUtils = searchUtils;
96
+ Object.defineProperty(exports, "VerdaccioError", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return errorUtils.VerdaccioError;
100
+ }
101
+ });
102
+ exports.warningUtils = exports.validatioUtils = exports.streamUtils = exports.searchUtils = exports.pluginUtils = exports.pkgUtils = exports.fileUtils = exports.errorUtils = exports.constants = void 0;
109
103
 
110
- var streamUtils = _interopRequireWildcard(require("./stream-utils"));
104
+ var constants = _interopRequireWildcard(require("./constants"));
111
105
 
112
- exports.streamUtils = streamUtils;
106
+ exports.constants = constants;
113
107
 
114
108
  var errorUtils = _interopRequireWildcard(require("./error-utils"));
115
109
 
116
110
  exports.errorUtils = errorUtils;
117
111
 
118
- var validatioUtils = _interopRequireWildcard(require("./validation-utils"));
112
+ var fileUtils = _interopRequireWildcard(require("./file-utils"));
119
113
 
120
- exports.validatioUtils = validatioUtils;
114
+ exports.fileUtils = fileUtils;
121
115
 
122
- var constants = _interopRequireWildcard(require("./constants"));
116
+ var pkgUtils = _interopRequireWildcard(require("./pkg-utils"));
123
117
 
124
- exports.constants = constants;
118
+ exports.pkgUtils = pkgUtils;
125
119
 
126
120
  var pluginUtils = _interopRequireWildcard(require("./plugin-utils"));
127
121
 
128
122
  exports.pluginUtils = pluginUtils;
129
123
 
130
- var fileUtils = _interopRequireWildcard(require("./file-utils"));
124
+ var searchUtils = _interopRequireWildcard(require("./search-utils"));
131
125
 
132
- exports.fileUtils = fileUtils;
126
+ exports.searchUtils = searchUtils;
133
127
 
134
- var pkgUtils = _interopRequireWildcard(require("./pkg-utils"));
128
+ var streamUtils = _interopRequireWildcard(require("./stream-utils"));
135
129
 
136
- exports.pkgUtils = pkgUtils;
130
+ exports.streamUtils = streamUtils;
131
+
132
+ var validatioUtils = _interopRequireWildcard(require("./validation-utils"));
133
+
134
+ exports.validatioUtils = validatioUtils;
135
+
136
+ var warningUtils = _interopRequireWildcard(require("./warning-utils"));
137
+
138
+ exports.warningUtils = warningUtils;
137
139
 
138
140
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
139
141
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import * as searchUtils from './search-utils';\nimport * as streamUtils from './stream-utils';\nimport * as errorUtils from './error-utils';\nimport * as validatioUtils from './validation-utils';\nimport * as constants from './constants';\nimport * as pluginUtils from './plugin-utils';\nimport * as fileUtils from './file-utils';\nimport * as pkgUtils from './pkg-utils';\n\nexport { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';\nexport {\n TOKEN_BASIC,\n TOKEN_BEARER,\n HTTP_STATUS,\n API_MESSAGE,\n HEADERS,\n DIST_TAGS,\n CHARACTER_ENCODING,\n HEADER_TYPE,\n LATEST,\n DEFAULT_MIN_LIMIT_PASSWORD,\n DEFAULT_USER,\n USERS,\n} from './constants';\n\nexport {\n fileUtils,\n pkgUtils,\n searchUtils,\n streamUtils,\n errorUtils,\n validatioUtils,\n constants,\n pluginUtils,\n};\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA","sourcesContent":["import * as constants from './constants';\nimport * as errorUtils from './error-utils';\nimport * as fileUtils from './file-utils';\nimport * as pkgUtils from './pkg-utils';\nimport * as pluginUtils from './plugin-utils';\nimport * as searchUtils from './search-utils';\nimport * as streamUtils from './stream-utils';\nimport * as validatioUtils from './validation-utils';\nimport * as warningUtils from './warning-utils';\n\nexport { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';\nexport {\n TOKEN_BASIC,\n TOKEN_BEARER,\n HTTP_STATUS,\n API_MESSAGE,\n HEADERS,\n DIST_TAGS,\n CHARACTER_ENCODING,\n HEADER_TYPE,\n LATEST,\n DEFAULT_MIN_LIMIT_PASSWORD,\n DEFAULT_USER,\n USERS,\n} from './constants';\n\nexport {\n fileUtils,\n pkgUtils,\n searchUtils,\n streamUtils,\n errorUtils,\n validatioUtils,\n constants,\n pluginUtils,\n warningUtils,\n};\n"],"file":"index.js"}
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.semverSort = semverSort;
7
6
  exports.getLatest = getLatest;
8
7
  exports.mergeVersions = mergeVersions;
8
+ exports.semverSort = semverSort;
9
9
 
10
10
  var _semver = _interopRequireDefault(require("semver"));
11
11
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/pkg-utils.ts"],"names":["semverSort","listVersions","filter","x","semver","parse","sort","compareLoose","map","String","getLatest","pkg","Object","keys","versions","length","Error","latest","DIST_TAGS","mergeVersions","local","upstream","i","lte","readme"],"mappings":";;;;;;;;;AACA;;AACA;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,UAAT,CAAoBC,YAApB,EAAsD;AAC3D,SAAOA,YAAY,CAChBC,MADI,CACG,UAAUC,CAAV,EAAsB;AAC5B,QAAI,CAACC,gBAAOC,KAAP,CAAaF,CAAb,EAAgB,IAAhB,CAAL,EAA4B;AAC1B,aAAO,KAAP;AACD;;AACD,WAAO,IAAP;AACD,GANI,EAOJG,IAPI,CAOCF,gBAAOG,YAPR,EAQJC,GARI,CAQAC,MARA,CAAP;AASD;AAED;AACA;AACA;AACA;;;AACO,SAASC,SAAT,CAAmBC,GAAnB,EAAyC;AAAA;;AAC9C,QAAMV,YAAsB,GAAGW,MAAM,CAACC,IAAP,CAAYF,GAAG,CAACG,QAAhB,CAA/B;;AACA,MAAIb,YAAY,CAACc,MAAb,GAAsB,CAA1B,EAA6B;AAC3B,UAAMC,KAAK,CAAC,oCAAD,CAAX;AACD;;AAED,QAAMF,QAAkB,GAAGd,UAAU,CAACC,YAAD,CAArC;AACA,QAAMgB,MAA0B,GAAG,kBAAAN,GAAG,CAACO,oBAAD,CAAH,0DAAgBD,MAAhB,GAAyBN,GAAG,CAACO,oBAAD,CAAH,CAAeD,MAAxC,GAAiDH,QAAQ,CAAC,CAAD,CAA5F;AAEA,SAAOG,MAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,aAAT,CAAuBC,KAAvB,EAAuCC,QAAvC,EAA0D;AAC/D;AACA;AACA,OAAK,MAAMC,CAAX,IAAgBD,QAAQ,CAACP,QAAzB,EAAmC;AACjC,QAAI,OAAOM,KAAK,CAACN,QAAN,CAAeQ,CAAf,CAAP,KAA6B,WAAjC,EAA8C;AAC5CF,MAAAA,KAAK,CAACN,QAAN,CAAeQ,CAAf,IAAoBD,QAAQ,CAACP,QAAT,CAAkBQ,CAAlB,CAApB;AACD;AACF;;AAED,OAAK,MAAMA,CAAX,IAAgBD,QAAQ,CAACH,oBAAD,CAAxB,EAAqC;AACnC,QAAIE,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,MAAwBD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAA5B,EAAoD;AAClD,UAAI,CAACF,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,CAAD,IAAwBlB,gBAAOmB,GAAP,CAAWH,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,CAAX,EAAgCD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAAhC,CAA5B,EAAqF;AACnFF,QAAAA,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,IAAsBD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAAtB;AACD;;AACD,UAAIA,CAAC,KAAK,QAAN,IAAkBF,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,MAAwBD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAA9C,EAAsE;AACpE;AACAF,QAAAA,KAAK,CAACI,MAAN,GAAeH,QAAQ,CAACG,MAAxB;AACD;AACF;AACF;AACF","sourcesContent":["import { Package } from '@verdaccio/types';\nimport semver from 'semver';\nimport { DIST_TAGS } from './constants';\n\n/**\n * Function filters out bad semver versions and sorts the array.\n * @return {Array} sorted Array\n */\nexport function semverSort(listVersions: string[]): string[] {\n return listVersions\n .filter(function (x): boolean {\n if (!semver.parse(x, true)) {\n return false;\n }\n return true;\n })\n .sort(semver.compareLoose)\n .map(String);\n}\n\n/**\n * Get the latest publihsed version of a package.\n * @param package metadata\n **/\nexport function getLatest(pkg: Package): string {\n const listVersions: string[] = Object.keys(pkg.versions);\n if (listVersions.length < 1) {\n throw Error('cannot get lastest version of none');\n }\n\n const versions: string[] = semverSort(listVersions);\n const latest: string | undefined = pkg[DIST_TAGS]?.latest ? pkg[DIST_TAGS].latest : versions[0];\n\n return latest;\n}\n\n/**\n * Function gets a local info and an info from uplinks and tries to merge it\n exported for unit tests only.\n * @param {*} local\n * @param {*} upstream\n * @param {*} config sds\n */\nexport function mergeVersions(local: Package, upstream: Package) {\n // copy new versions to a cache\n // NOTE: if a certain version was updated, we can't refresh it reliably\n for (const i in upstream.versions) {\n if (typeof local.versions[i] === 'undefined') {\n local.versions[i] = upstream.versions[i];\n }\n }\n\n for (const i in upstream[DIST_TAGS]) {\n if (local[DIST_TAGS][i] !== upstream[DIST_TAGS][i]) {\n if (!local[DIST_TAGS][i] || semver.lte(local[DIST_TAGS][i], upstream[DIST_TAGS][i])) {\n local[DIST_TAGS][i] = upstream[DIST_TAGS][i];\n }\n if (i === 'latest' && local[DIST_TAGS][i] === upstream[DIST_TAGS][i]) {\n // if remote has more fresh package, we should borrow its readme\n local.readme = upstream.readme;\n }\n }\n }\n}\n"],"file":"pkg-utils.js"}
1
+ {"version":3,"sources":["../src/pkg-utils.ts"],"names":["semverSort","listVersions","filter","x","semver","parse","sort","compareLoose","map","String","getLatest","pkg","Object","keys","versions","length","Error","latest","DIST_TAGS","mergeVersions","local","upstream","i","lte","readme"],"mappings":";;;;;;;;;AAAA;;AAIA;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,UAAT,CAAoBC,YAApB,EAAsD;AAC3D,SAAOA,YAAY,CAChBC,MADI,CACG,UAAUC,CAAV,EAAsB;AAC5B,QAAI,CAACC,gBAAOC,KAAP,CAAaF,CAAb,EAAgB,IAAhB,CAAL,EAA4B;AAC1B,aAAO,KAAP;AACD;;AACD,WAAO,IAAP;AACD,GANI,EAOJG,IAPI,CAOCF,gBAAOG,YAPR,EAQJC,GARI,CAQAC,MARA,CAAP;AASD;AAED;AACA;A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QAAAA,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,IAAsBD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAAtB;AACD;;AACD,UAAIA,CAAC,KAAK,QAAN,IAAkBF,KAAK,CAACF,oBAAD,CAAL,CAAiBI,CAAjB,MAAwBD,QAAQ,CAACH,oBAAD,CAAR,CAAoBI,CAApB,CAA9C,EAAsE;AACpE;AACAF,QAAAA,KAAK,CAACI,MAAN,GAAeH,QAAQ,CAACG,MAAxB;AACD;AACF;AACF;AACF","sourcesContent":["import semver from 'semver';\n\nimport { Package } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\n/**\n * Function filters out bad semver versions and sorts the array.\n * @return {Array} sorted Array\n */\nexport function semverSort(listVersions: string[]): string[] {\n return listVersions\n .filter(function (x): boolean {\n if (!semver.parse(x, true)) {\n return false;\n }\n return true;\n })\n .sort(semver.compareLoose)\n .map(String);\n}\n\n/**\n * Get the latest publihsed version of a package.\n * @param package metadata\n **/\nexport function getLatest(pkg: Package): string {\n const listVersions: string[] = Object.keys(pkg.versions);\n if (listVersions.length < 1) {\n throw Error('cannot get lastest version of none');\n }\n\n const versions: string[] = semverSort(listVersions);\n const latest: string | undefined = pkg[DIST_TAGS]?.latest ? pkg[DIST_TAGS].latest : versions[0];\n\n return latest;\n}\n\n/**\n * Function gets a local info and an info from uplinks and tries to merge it\n exported for unit tests only.\n * @param {*} local\n * @param {*} upstream\n * @param {*} config sds\n */\nexport function mergeVersions(local: Package, upstream: Package) {\n // copy new versions to a cache\n // NOTE: if a certain version was updated, we can't refresh it reliably\n for (const i in upstream.versions) {\n if (typeof local.versions[i] === 'undefined') {\n local.versions[i] = upstream.versions[i];\n }\n }\n\n for (const i in upstream[DIST_TAGS]) {\n if (local[DIST_TAGS][i] !== upstream[DIST_TAGS][i]) {\n if (!local[DIST_TAGS][i] || semver.lte(local[DIST_TAGS][i], upstream[DIST_TAGS][i])) {\n local[DIST_TAGS][i] = upstream[DIST_TAGS][i];\n }\n if (i === 'latest' && local[DIST_TAGS][i] === upstream[DIST_TAGS][i]) {\n // if remote has more fresh package, we should borrow its readme\n local.readme = upstream.readme;\n }\n }\n }\n}\n"],"file":"pkg-utils.js"}
@@ -14,10 +14,14 @@ export declare type SearchItemPkg = {
14
14
  path?: string;
15
15
  time?: number | Date;
16
16
  };
17
- export declare type SearchItem = {
17
+ declare type PrivatePackage = {
18
+ verdaccioPrivate?: boolean;
19
+ verdaccioPkgCached?: boolean;
20
+ };
21
+ export interface SearchItem extends UnStable, PrivatePackage {
18
22
  package: SearchItemPkg;
19
23
  score: Score;
20
- } & UnStable;
24
+ }
21
25
  export declare type Score = {
22
26
  final: number;
23
27
  detail: SearchMetrics;
@@ -48,11 +52,11 @@ export declare type SearchPackageBody = {
48
52
  publisher?: any;
49
53
  maintainers?: PublisherMaintainer[];
50
54
  };
51
- export declare type SearchPackageItem = {
55
+ export interface SearchPackageItem extends UnStable, PrivatePackage {
52
56
  package: SearchPackageBody;
53
57
  score: Score;
54
58
  searchScore?: number;
55
- } & UnStable;
59
+ }
56
60
  export declare const UNSCOPED = "unscoped";
57
61
  export declare type SearchQuery = {
58
62
  text: string;
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.UNSCOPED = void 0;
7
+ // @deprecated use @verdaccio/types
8
+ // @deprecated use @verdaccio/types
7
9
  const UNSCOPED = 'unscoped';
8
10
  exports.UNSCOPED = UNSCOPED;
9
11
  //# sourceMappingURL=search-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/search-utils.ts"],"names":["UNSCOPED"],"mappings":";;;;;;AA+DO,MAAMA,QAAQ,GAAG,UAAjB","sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\nexport type SearchItem = {\n package: SearchItemPkg;\n score: Score;\n} & UnStable;\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\nexport type SearchResults = {\n objects: SearchItemPkg[];\n total: number;\n time: string;\n};\n\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport type SearchPackageItem = {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n} & UnStable;\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"file":"search-utils.js"}
1
+ {"version":3,"sources":["../src/search-utils.ts"],"names":["UNSCOPED"],"mappings":";;;;;;AA2CA;AAMA;AAyBO,MAAMA,QAAQ,GAAG,UAAjB","sourcesContent":["export type SearchMetrics = {\n quality: number;\n popularity: number;\n maintenance: number;\n};\nexport type UnStable = {\n flags?: {\n // if is false is not be included in search results (majority are stable)\n unstable?: boolean;\n };\n};\nexport type SearchItemPkg = {\n name: string;\n scoped?: string;\n path?: string;\n time?: number | Date;\n};\n\ntype PrivatePackage = {\n // note: prefixed to avoid external conflicts\n\n // the package is published as private\n verdaccioPrivate?: boolean;\n // if the package is not private but is cached\n verdaccioPkgCached?: boolean;\n};\n\nexport interface SearchItem extends UnStable, PrivatePackage {\n package: SearchItemPkg;\n score: Score;\n}\n\nexport type Score = {\n final: number;\n detail: SearchMetrics;\n};\n\nexport type SearchResults = {\n objects: SearchItemPkg[];\n total: number;\n time: string;\n};\n\n// @deprecated use @verdaccio/types\ntype PublisherMaintainer = {\n username: string;\n email: string;\n};\n\n// @deprecated use @verdaccio/types\nexport type SearchPackageBody = {\n name: string;\n scope: string;\n description: string;\n author: string | PublisherMaintainer;\n version: string;\n keywords: string | string[] | undefined;\n date: string;\n links?: {\n npm: string; // only include placeholder for URL eg: {url}/{packageName}\n homepage?: string;\n repository?: string;\n bugs?: string;\n };\n publisher?: any;\n maintainers?: PublisherMaintainer[];\n};\n\nexport interface SearchPackageItem extends UnStable, PrivatePackage {\n package: SearchPackageBody;\n score: Score;\n searchScore?: number;\n}\n\nexport const UNSCOPED = 'unscoped';\n\nexport type SearchQuery = {\n text: string;\n size?: number;\n from?: number;\n} & SearchMetrics;\n"],"file":"search-utils.js"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { PassThrough, TransformOptions, Transform } from 'stream';
2
+ import { PassThrough, Transform, TransformOptions } from 'stream';
3
3
  export interface IReadTarball {
4
4
  abort?: () => void;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/stream-utils.ts"],"names":["ReadTarball","PassThrough","constructor","options","addAbstractMethods","abort","UploadTarball","done","self","name","_called_methods","__defineGetter__","__defineSetter__","fn","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"mappings":";;;;;;;AAAA;;AAWA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAN,SAA0BC,mBAA1B,CAA8D;AAC5D;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAA4B;AAC5C,UAAMA,OAAN,EAD4C,CAE5C;;AACAC,IAAAA,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB;AACD;;AAEMC,EAAAA,KAAK,GAAS,CAAE;;AAXqC;AAc9D;AACA;AACA;AACA;AACA;;;;;AACA,MAAMC,aAAN,SAA4BL,mBAA5B,CAAkE;AAChE;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAAe;AAC/B,UAAMA,OAAN,EAD+B,CAE/B;;AACAC,IAAAA,kBAAkB,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ACG,QAAP,CAAgB,OAAhB,CAAZ;AACA,SAAOD,GAAP;AACD,CARD;AAUA;AACA;AACA;;;;;AACA,MAAME,uBAAuB,GAAG,MAAM;AACpC,SAAO,IAAIC,iBAAJ,CAAc;AACnBC,IAAAA,UAAU,EAAE,IADO;AAEnBC,IAAAA,SAAS,EAAE,CAACX,KAAD,EAAQY,QAAR,EAAkBC,QAAlB,KAA+B;AACxCA,MAAAA,QAAQ,CAAC,IAAD,EAAOC,IAAI,CAACC,SAAL,CAAef,KAAf,CAAP,CAAR;AACD;AAJkB,GAAd,CAAP;AAMD,CAPD","sourcesContent":["import { PassThrough, TransformOptions, Transform } from 'stream';\n\nexport interface IReadTarball {\n abort?: () => void;\n}\n\nexport interface IUploadTarball {\n done?: () => void;\n abort?: () => void;\n}\n\n/**\n * This stream is used to read tarballs from repository.\n * @param {*} options\n * @return {Stream}\n */\nclass ReadTarball extends PassThrough implements IReadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: TransformOptions) {\n super(options);\n // called when data is not needed anymore\n addAbstractMethods(this, 'abort');\n }\n\n public abort(): void {}\n}\n\n/**\n * This stream is used to upload tarballs to a repository.\n * @param {*} options\n * @return {Stream}\n */\nclass UploadTarball extends PassThrough implements IUploadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: any) {\n super(options);\n // called when user closes connection before upload finishes\n addAbstractMethods(this, 'abort');\n\n // called when upload finishes successfully\n addAbstractMethods(this, 'done');\n }\n\n public abort(): void {}\n public done(): void {}\n}\n\n/**\n * This function intercepts abstract calls and replays them allowing.\n * us to attach those functions after we are ready to do so\n * @param {*} self\n * @param {*} name\n */\n// Perhaps someone knows a better way to write this\nfunction addAbstractMethods(self: any, name: any): void {\n self._called_methods = self._called_methods || {};\n\n self.__defineGetter__(name, function () {\n return function (): void {\n self._called_methods[name] = true;\n };\n });\n\n self.__defineSetter__(name, function (fn: any) {\n delete self[name];\n\n self[name] = fn;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (self._called_methods && self._called_methods[name]) {\n delete self._called_methods[name];\n\n self[name]();\n }\n });\n}\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream) => {\n const chunks: Buffer[] = [];\n for await (let chunk of stream) {\n chunks.push(Buffer.from(chunk));\n }\n const buffer = Buffer.concat(chunks);\n const str = buffer.toString('utf-8');\n return str;\n};\n\n/**\n * Transform stream object mode to string\n **/\nconst transformObjectToString = () => {\n return new Transform({\n objectMode: true,\n transform: (chunk, encoding, callback) => {\n callback(null, JSON.stringify(chunk));\n },\n });\n};\n\nexport { ReadTarball, UploadTarball, readableToString, transformObjectToString };\n"],"file":"stream-utils.js"}
1
+ {"version":3,"sources":["../src/stream-utils.ts"],"names":["ReadTarball","PassThrough","constructor","options","addAbstractMethods","abort","UploadTarball","done","self","name","_called_methods","__defineGetter__","__defineSetter__","fn","readableToString","stream","chunks","chunk","push","Buffer","from","buffer","concat","str","toString","transformObjectToString","Transform","objectMode","transform","encoding","callback","JSON","stringify"],"mappings":";;;;;;;AAAA;;AAWA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAN,SAA0BC,mBAA1B,CAA8D;AAC5D;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAA4B;AAC5C,UAAMA,OAAN,EAD4C,CAE5C;;AACAC,IAAAA,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB;AACD;;AAEMC,EAAAA,KAAK,GAAS,CAAE;;AAXqC;AAc9D;AACA;AACA;AACA;AACA;;;;;AACA,MAAMC,aAAN,SAA4BL,mBAA5B,CAAkE;AAChE;AACF;AACA;AACA;AACSC,EAAAA,WAAW,CAACC,OAAD,EAAe;AAC/B,UAAMA,OAAN,EAD+B,CAE/B;;AACAC,IAAAA,kBAAkB,CAAC,IAAD,EAAO,OAAP,CAAlB,CAH+B,CAK/B;;AACAA,IAAAA,kBAAkB,CAAC,IAAD,EAAO,MAAP,CAAlB;AACD;;AAEMC,EAAAA,KAAK,GAA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iBAAJ,CAAc;AACnBC,IAAAA,UAAU,EAAE,IADO;AAEnBC,IAAAA,SAAS,EAAE,CAACX,KAAD,EAAQY,QAAR,EAAkBC,QAAlB,KAA+B;AACxCA,MAAAA,QAAQ,CAAC,IAAD,EAAOC,IAAI,CAACC,SAAL,CAAef,KAAf,CAAP,CAAR;AACD;AAJkB,GAAd,CAAP;AAMD,CAPD","sourcesContent":["import { PassThrough, Transform, TransformOptions } from 'stream';\n\nexport interface IReadTarball {\n abort?: () => void;\n}\n\nexport interface IUploadTarball {\n done?: () => void;\n abort?: () => void;\n}\n\n/**\n * This stream is used to read tarballs from repository.\n * @param {*} options\n * @return {Stream}\n */\nclass ReadTarball extends PassThrough implements IReadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: TransformOptions) {\n super(options);\n // called when data is not needed anymore\n addAbstractMethods(this, 'abort');\n }\n\n public abort(): void {}\n}\n\n/**\n * This stream is used to upload tarballs to a repository.\n * @param {*} options\n * @return {Stream}\n */\nclass UploadTarball extends PassThrough implements IUploadTarball {\n /**\n *\n * @param {Object} options\n */\n public constructor(options: any) {\n super(options);\n // called when user closes connection before upload finishes\n addAbstractMethods(this, 'abort');\n\n // called when upload finishes successfully\n addAbstractMethods(this, 'done');\n }\n\n public abort(): void {}\n public done(): void {}\n}\n\n/**\n * This function intercepts abstract calls and replays them allowing.\n * us to attach those functions after we are ready to do so\n * @param {*} self\n * @param {*} name\n */\n// Perhaps someone knows a better way to write this\nfunction addAbstractMethods(self: any, name: any): void {\n self._called_methods = self._called_methods || {};\n\n self.__defineGetter__(name, function () {\n return function (): void {\n self._called_methods[name] = true;\n };\n });\n\n self.__defineSetter__(name, function (fn: any) {\n delete self[name];\n\n self[name] = fn;\n\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n if (self._called_methods && self._called_methods[name]) {\n delete self._called_methods[name];\n\n self[name]();\n }\n });\n}\n\n/**\n * Converts a buffer stream to a string.\n */\nconst readableToString = async (stream) => {\n const chunks: Buffer[] = [];\n for await (let chunk of stream) {\n chunks.push(Buffer.from(chunk));\n }\n const buffer = Buffer.concat(chunks);\n const str = buffer.toString('utf-8');\n return str;\n};\n\n/**\n * Transform stream object mode to string\n **/\nconst transformObjectToString = () => {\n return new Transform({\n objectMode: true,\n transform: (chunk, encoding, callback) => {\n callback(null, JSON.stringify(chunk));\n },\n });\n};\n\nexport { ReadTarball, UploadTarball, readableToString, transformObjectToString };\n"],"file":"stream-utils.js"}
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.isObject = isObject;
6
7
  exports.isPackageNameScoped = isPackageNameScoped;
8
+ exports.validateMetadata = validateMetadata;
7
9
  exports.validateName = validateName;
8
10
  exports.validatePackage = validatePackage;
9
- exports.validateMetadata = validateMetadata;
10
- exports.isObject = isObject;
11
11
 
12
12
  var _assert = _interopRequireDefault(require("assert"));
13
13
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/validation-utils.ts"],"names":["isPackageNameScoped","name","startsWith","validateName","normalizedName","toLowerCase","isScoped","scopedName","split","match","includes","validatePackage","nameList","length","slice","validateMetadata","object","isObject","assert","strictEqual","DIST_TAGS","obj","prototype","Array","isArray"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;;;AAEO,SAASA,mBAAT,CAA6BC,IAA7B,EAAoD;AACzD,SAAOA,IAAI,CAACC,UAAL,CAAgB,GAAhB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,CAAsBF,IAAtB,EAA6C;AAClD,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAO,KAAP;AACD;;AAED,MAAIG,cAAsB,GAAGH,IAAI,CAACI,WAAL,EAA7B;AAEA,QAAMC,QAAiB,GAAGN,mBAAmB,CAACC,IAAD,CAA7C;AACA,QAAMM,UAAU,GAAGN,IAAI,CAACO,KAAL,CAAW,GAAX,EAAgB,CAAhB,EAAmB,CAAnB,CAAnB;;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,QAAQ,CAACD,MAAM,CAAC,UAAD,CAAP,CAAb,EAAmC;AACjCA,IAAAA,MAAM,CAAC,UAAD,CAAN,GAAqB,EAArB;AACD;;AAED,MAAI,CAACC,QAAQ,CAACD,MAAM,CAAC,MAAD,CAAP,CAAb,EAA+B;AAC7BA,IAAAA,MAAM,CAAC,MAAD,CAAN,GAAiB,EAAjB;AACD;;AAED,SAAOA,MAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,QAAT,CAAkBI,GAAlB,EAAqC;AAC1C,MAAIA,GAAG,KAAK,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAnC,EAAgD;AAC9C,WAAO,KAAP;AACD;;AAED,SACE,CAAC,OAAOA,GAAP,KAAe,QAAf,IAA2B,OAAOA,GAAG,CAACC,SAAX,KAAyB,WAArD,KACAC,KAAK,CAACC,OAAN,CAAcH,GAAd,MAAuB,KAFzB;AAID","sourcesContent":["import assert from 'assert';\nimport { Package } from '@verdaccio/types';\nimport { DIST_TAGS } from './constants';\n\nexport function isPackageNameScoped(name: string): boolean {\n return name.startsWith('@');\n}\n\n/**\n * From normalize-package-data/lib/fixer.js\n * @param {*} name the package name\n * @return {Boolean} whether is valid or not\n */\nexport function validateName(name: string): boolean {\n if (typeof name !== 'string') {\n return false;\n }\n\n let normalizedName: string = name.toLowerCase();\n\n const isScoped: boolean = isPackageNameScoped(name);\n const scopedName = name.split('/', 2)[1];\n\n if (isScoped && typeof scopedName !== 'undefined') {\n normalizedName = scopedName.toLowerCase();\n }\n\n /**\n * Some context about the first regex\n * - npm used to have a different tarball naming system.\n * eg: http://registry.npmjs.com/thirty-two\n * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz\n * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)\n * while nowadays the naming system is based in dashes\n * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz\n *\n * more info here: https://github.com/rlidwka/sinopia/issues/75\n */\n return !(\n !normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) ||\n normalizedName.startsWith('.') || // \".bin\", etc.\n ['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName)\n );\n}\n\n/**\n * Validate a package.\n * @return {Boolean} whether the package is valid or not\n */\nexport function validatePackage(name: string): boolean {\n const nameList = name.split('/', 2);\n if (nameList.length === 1) {\n // normal package\n return validateName(nameList[0]);\n }\n // scoped package\n return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);\n}\n\n/**\n * Validate the package metadata, add additional properties whether are missing within\n * the metadata properties.\n * @param {*} object\n * @param {*} name\n * @return {Object} the object with additional properties as dist-tags ad versions\n */\nexport function validateMetadata(object: Package, name: string): Package {\n assert(isObject(object), 'not a json object');\n assert.strictEqual(object.name, name);\n\n if (!isObject(object[DIST_TAGS])) {\n object[DIST_TAGS] = {};\n }\n\n if (!isObject(object['versions'])) {\n object['versions'] = {};\n }\n\n if (!isObject(object['time'])) {\n object['time'] = {};\n }\n\n return object;\n}\n\n/**\n * Check whether an element is an Object\n * @param {*} obj the element\n * @return {Boolean}\n */\nexport function isObject(obj: any): boolean {\n if (obj === null || typeof obj === 'undefined') {\n return false;\n }\n\n return (\n (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&\n Array.isArray(obj) === false\n );\n}\n"],"file":"validation-utils.js"}
1
+ {"version":3,"sources":["../src/validation-utils.ts"],"names":["isPackageNameScoped","name","startsWith","validateName","normalizedName","toLowerCase","isScoped","scopedName","split","match","includes","validatePackage","nameList","length","slice","validateMetadata","object","isObject","assert","strictEqual","DIST_TAGS","obj","prototype","Array","isArray"],"mappings":";;;;;;;;;;;AAAA;;AAIA;;;;AAEO,SAASA,mBAAT,CAA6BC,IAA7B,EAAoD;AACzD,SAAOA,IAAI,CAACC,UAAL,CAAgB,GAAhB,CAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,YAAT,CAAsBF,IAAtB,EAA6C;AAClD,MAAI,OAAOA,IAAP,K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ACD,MAAD,CAAf,EAAyB,mBAAzB;;AACAE,kBAAOC,WAAP,CAAmBH,MAAM,CAACf,IAA1B,EAAgCA,IAAhC;;AAEA,MAAI,CAACgB,QAAQ,CAACD,MAAM,CAACI,oBAAD,CAAP,CAAb,EAAkC;AAChCJ,IAAAA,MAAM,CAACI,oBAAD,CAAN,GAAoB,EAApB;AACD;;AAED,MAAI,CAACH,QAAQ,CAACD,MAAM,CAAC,UAAD,CAAP,CAAb,EAAmC;AACjCA,IAAAA,MAAM,CAAC,UAAD,CAAN,GAAqB,EAArB;AACD;;AAED,MAAI,CAACC,QAAQ,CAACD,MAAM,CAAC,MAAD,CAAP,CAAb,EAA+B;AAC7BA,IAAAA,MAAM,CAAC,MAAD,CAAN,GAAiB,EAAjB;AACD;;AAED,SAAOA,MAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASC,QAAT,CAAkBI,GAAlB,EAAqC;AAC1C,MAAIA,GAAG,KAAK,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAnC,EAAgD;AAC9C,WAAO,KAAP;AACD;;AAED,SACE,CAAC,OAAOA,GAAP,KAAe,QAAf,IAA2B,OAAOA,GAAG,CAACC,SAAX,KAAyB,WAArD,KACAC,KAAK,CAACC,OAAN,CAAcH,GAAd,MAAuB,KAFzB;AAID","sourcesContent":["import assert from 'assert';\n\nimport { Package } from '@verdaccio/types';\n\nimport { DIST_TAGS } from './constants';\n\nexport function isPackageNameScoped(name: string): boolean {\n return name.startsWith('@');\n}\n\n/**\n * From normalize-package-data/lib/fixer.js\n * @param {*} name the package name\n * @return {Boolean} whether is valid or not\n */\nexport function validateName(name: string): boolean {\n if (typeof name !== 'string') {\n return false;\n }\n\n let normalizedName: string = name.toLowerCase();\n\n const isScoped: boolean = isPackageNameScoped(name);\n const scopedName = name.split('/', 2)[1];\n\n if (isScoped && typeof scopedName !== 'undefined') {\n normalizedName = scopedName.toLowerCase();\n }\n\n /**\n * Some context about the first regex\n * - npm used to have a different tarball naming system.\n * eg: http://registry.npmjs.com/thirty-two\n * https://registry.npmjs.org/thirty-two/-/thirty-two@0.0.1.tgz\n * The file name thirty-two@0.0.1.tgz, the version and the pkg name was separated by an at (@)\n * while nowadays the naming system is based in dashes\n * https://registry.npmjs.org/verdaccio/-/verdaccio-1.4.0.tgz\n *\n * more info here: https://github.com/rlidwka/sinopia/issues/75\n */\n return !(\n !normalizedName.match(/^[-a-zA-Z0-9_.!~*'()@]+$/) ||\n normalizedName.startsWith('.') || // \".bin\", etc.\n ['node_modules', '__proto__', 'favicon.ico'].includes(normalizedName)\n );\n}\n\n/**\n * Validate a package.\n * @return {Boolean} whether the package is valid or not\n */\nexport function validatePackage(name: string): boolean {\n const nameList = name.split('/', 2);\n if (nameList.length === 1) {\n // normal package\n return validateName(nameList[0]);\n }\n // scoped package\n return nameList[0][0] === '@' && validateName(nameList[0].slice(1)) && validateName(nameList[1]);\n}\n\n/**\n * Validate the package metadata, add additional properties whether are missing within\n * the metadata properties.\n * @param {*} object\n * @param {*} name\n * @return {Object} the object with additional properties as dist-tags ad versions\n */\nexport function validateMetadata(object: Package, name: string): Package {\n assert(isObject(object), 'not a json object');\n assert.strictEqual(object.name, name);\n\n if (!isObject(object[DIST_TAGS])) {\n object[DIST_TAGS] = {};\n }\n\n if (!isObject(object['versions'])) {\n object['versions'] = {};\n }\n\n if (!isObject(object['time'])) {\n object['time'] = {};\n }\n\n return object;\n}\n\n/**\n * Check whether an element is an Object\n * @param {*} obj the element\n * @return {Boolean}\n */\nexport function isObject(obj: any): boolean {\n if (obj === null || typeof obj === 'undefined') {\n return false;\n }\n\n return (\n (typeof obj === 'object' || typeof obj.prototype === 'undefined') &&\n Array.isArray(obj) === false\n );\n}\n"],"file":"validation-utils.js"}
@@ -0,0 +1,8 @@
1
+ export declare enum Codes {
2
+ VERWAR001 = "VERWAR001",
3
+ VERWAR002 = "VERWAR002",
4
+ VERWAR003 = "VERWAR003",
5
+ VERWAR004 = "VERWAR004",
6
+ VERDEP003 = "VERDEP003"
7
+ }
8
+ export declare function emit(code: any, a?: string, b?: string, c?: string): void;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Codes = void 0;
7
+ exports.emit = emit;
8
+
9
+ var _processWarning = _interopRequireDefault(require("process-warning"));
10
+
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+
13
+ const warningInstance = (0, _processWarning.default)();
14
+ const verdaccioWarning = 'VerdaccioWarning';
15
+ const verdaccioDeprecation = 'VerdaccioDeprecation';
16
+ let Codes;
17
+ exports.Codes = Codes;
18
+
19
+ (function (Codes) {
20
+ Codes["VERWAR001"] = "VERWAR001";
21
+ Codes["VERWAR002"] = "VERWAR002";
22
+ Codes["VERWAR003"] = "VERWAR003";
23
+ Codes["VERWAR004"] = "VERWAR004";
24
+ Codes["VERDEP003"] = "VERDEP003";
25
+ })(Codes || (exports.Codes = Codes = {}));
26
+
27
+ warningInstance.create(verdaccioWarning, Codes.VERWAR001, `Verdaccio doesn't need superuser privileges. don't run it under root`);
28
+ warningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');
29
+ warningInstance.create(verdaccioWarning, Codes.VERWAR003, 'rotating-file type is not longer supported, consider use [logrotate] instead');
30
+ warningInstance.create(verdaccioWarning, Codes.VERWAR004, `invalid address - %s, we expect a port (e.g. "4873"),
31
+ host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
32
+ https://verdaccio.org/docs/en/configuration#listen-port`);
33
+ warningInstance.create(verdaccioDeprecation, Codes.VERDEP003, 'multiple addresses will be deprecated in the next major, only use one');
34
+
35
+ function emit(code, a, b, c) {
36
+ warningInstance.emit(code, a, b, c);
37
+ }
38
+ //# sourceMappingURL=warning-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/warning-utils.ts"],"names":["warningInstance","verdaccioWarning","verdaccioDeprecation","Codes","create","VERWAR001","VERWAR002","VERWAR003","VERWAR004","VERDEP003","emit","code","a","b","c"],"mappings":";;;;;;;;AAAA;;;;AAEA,MAAMA,eAAe,GAAG,8BAAxB;AACA,MAAMC,gBAAgB,GAAG,kBAAzB;AACA,MAAMC,oBAAoB,GAAG,sBAA7B;IAEYC,K;;;WAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;AAAAA,EAAAA,K;GAAAA,K,qBAAAA,K;;AASZH,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACE,SAFR,EAGG,sEAHH;AAMAL,eAAe,CAACI,MAAhB,CAAuBH,gBAAvB,EAAyCE,KAAK,CAACG,SAA/C,EAA0D,uBAA1D;AAEAN,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACI,SAFR,EAGE,8EAHF;AAMAP,eAAe,CAACI,MAAhB,CACEH,gBADF,EAEEE,KAAK,CAACK,SAFR,EAGG;AACH;AACA,wDALA;AAQAR,eAAe,CAACI,MAAhB,CACEF,oBADF,EAEEC,KAAK,CAACM,SAFR,EAGE,uEAHF;;AAMO,SAASC,IAAT,CAAcC,IAAd,EAAoBC,CAApB,EAAgCC,CAAhC,EAA4CC,CAA5C,EAAwD;AAC7Dd,EAAAA,eAAe,CAACU,IAAhB,CAAqBC,IAArB,EAA2BC,CAA3B,EAA8BC,CAA9B,EAAiCC,CAAjC;AACD","sourcesContent":["import warning from 'process-warning';\n\nconst warningInstance = warning();\nconst verdaccioWarning = 'VerdaccioWarning';\nconst verdaccioDeprecation = 'VerdaccioDeprecation';\n\nexport enum Codes {\n VERWAR001 = 'VERWAR001',\n VERWAR002 = 'VERWAR002',\n VERWAR003 = 'VERWAR003',\n VERWAR004 = 'VERWAR004',\n // deprecation warnings\n VERDEP003 = 'VERDEP003',\n}\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR001,\n `Verdaccio doesn't need superuser privileges. don't run it under root`\n);\n\nwarningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR003,\n 'rotating-file type is not longer supported, consider use [logrotate] instead'\n);\n\nwarningInstance.create(\n verdaccioWarning,\n Codes.VERWAR004,\n `invalid address - %s, we expect a port (e.g. \"4873\"), \nhost:port (e.g. \"localhost:4873\") or full url '(e.g. \"http://localhost:4873/\")\nhttps://verdaccio.org/docs/en/configuration#listen-port`\n);\n\nwarningInstance.create(\n verdaccioDeprecation,\n Codes.VERDEP003,\n 'multiple addresses will be deprecated in the next major, only use one'\n);\n\nexport function emit(code, a?: string, b?: string, c?: string) {\n warningInstance.emit(code, a, b, c);\n}\n"],"file":"warning-utils.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/core",
3
- "version": "6.0.0-6-next.2",
3
+ "version": "6.0.0-6-next.5",
4
4
  "description": "core utilities",
5
5
  "keywords": [
6
6
  "private",
@@ -34,12 +34,14 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "http-errors": "1.8.0",
38
- "http-status-codes": "2.1.4",
39
- "semver": "7.3.5"
37
+ "http-errors": "1.8.1",
38
+ "http-status-codes": "2.2.0",
39
+ "semver": "7.3.5",
40
+ "process-warning": "1.0.0",
41
+ "core-js": "3.20.3"
40
42
  },
41
43
  "devDependencies": {
42
- "@verdaccio/types": "11.0.0-6-next.9"
44
+ "@verdaccio/types": "11.0.0-6-next.11"
43
45
  },
44
46
  "funding": {
45
47
  "type": "opencollective",
@@ -1,4 +1,5 @@
1
1
  import createError, { HttpError } from 'http-errors';
2
+
2
3
  import { DEFAULT_MIN_LIMIT_PASSWORD, HTTP_STATUS } from './constants';
3
4
 
4
5
  export const API_ERROR = {
package/src/index.ts CHANGED
@@ -1,11 +1,12 @@
1
- import * as searchUtils from './search-utils';
2
- import * as streamUtils from './stream-utils';
3
- import * as errorUtils from './error-utils';
4
- import * as validatioUtils from './validation-utils';
5
1
  import * as constants from './constants';
6
- import * as pluginUtils from './plugin-utils';
2
+ import * as errorUtils from './error-utils';
7
3
  import * as fileUtils from './file-utils';
8
4
  import * as pkgUtils from './pkg-utils';
5
+ import * as pluginUtils from './plugin-utils';
6
+ import * as searchUtils from './search-utils';
7
+ import * as streamUtils from './stream-utils';
8
+ import * as validatioUtils from './validation-utils';
9
+ import * as warningUtils from './warning-utils';
9
10
 
10
11
  export { VerdaccioError, API_ERROR, SUPPORT_ERRORS, APP_ERROR } from './error-utils';
11
12
  export {
@@ -32,4 +33,5 @@ export {
32
33
  validatioUtils,
33
34
  constants,
34
35
  pluginUtils,
36
+ warningUtils,
35
37
  };
package/src/pkg-utils.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { Package } from '@verdaccio/types';
2
1
  import semver from 'semver';
2
+
3
+ import { Package } from '@verdaccio/types';
4
+
3
5
  import { DIST_TAGS } from './constants';
4
6
 
5
7
  /**
@@ -1,4 +1,5 @@
1
1
  import { Config, IPackageStorage, Token, TokenFilter } from '@verdaccio/types';
2
+
2
3
  import { searchUtils } from '.';
3
4
 
4
5
  interface IPlugin {
@@ -16,10 +16,19 @@ export type SearchItemPkg = {
16
16
  time?: number | Date;
17
17
  };
18
18
 
19
- export type SearchItem = {
19
+ type PrivatePackage = {
20
+ // note: prefixed to avoid external conflicts
21
+
22
+ // the package is published as private
23
+ verdaccioPrivate?: boolean;
24
+ // if the package is not private but is cached
25
+ verdaccioPkgCached?: boolean;
26
+ };
27
+
28
+ export interface SearchItem extends UnStable, PrivatePackage {
20
29
  package: SearchItemPkg;
21
30
  score: Score;
22
- } & UnStable;
31
+ }
23
32
 
24
33
  export type Score = {
25
34
  final: number;
@@ -32,11 +41,13 @@ export type SearchResults = {
32
41
  time: string;
33
42
  };
34
43
 
44
+ // @deprecated use @verdaccio/types
35
45
  type PublisherMaintainer = {
36
46
  username: string;
37
47
  email: string;
38
48
  };
39
49
 
50
+ // @deprecated use @verdaccio/types
40
51
  export type SearchPackageBody = {
41
52
  name: string;
42
53
  scope: string;
@@ -55,11 +66,11 @@ export type SearchPackageBody = {
55
66
  maintainers?: PublisherMaintainer[];
56
67
  };
57
68
 
58
- export type SearchPackageItem = {
69
+ export interface SearchPackageItem extends UnStable, PrivatePackage {
59
70
  package: SearchPackageBody;
60
71
  score: Score;
61
72
  searchScore?: number;
62
- } & UnStable;
73
+ }
63
74
 
64
75
  export const UNSCOPED = 'unscoped';
65
76
 
@@ -1,4 +1,4 @@
1
- import { PassThrough, TransformOptions, Transform } from 'stream';
1
+ import { PassThrough, Transform, TransformOptions } from 'stream';
2
2
 
3
3
  export interface IReadTarball {
4
4
  abort?: () => void;
@@ -1,5 +1,7 @@
1
1
  import assert from 'assert';
2
+
2
3
  import { Package } from '@verdaccio/types';
4
+
3
5
  import { DIST_TAGS } from './constants';
4
6
 
5
7
  export function isPackageNameScoped(name: string): boolean {
@@ -0,0 +1,46 @@
1
+ import warning from 'process-warning';
2
+
3
+ const warningInstance = warning();
4
+ const verdaccioWarning = 'VerdaccioWarning';
5
+ const verdaccioDeprecation = 'VerdaccioDeprecation';
6
+
7
+ export enum Codes {
8
+ VERWAR001 = 'VERWAR001',
9
+ VERWAR002 = 'VERWAR002',
10
+ VERWAR003 = 'VERWAR003',
11
+ VERWAR004 = 'VERWAR004',
12
+ // deprecation warnings
13
+ VERDEP003 = 'VERDEP003',
14
+ }
15
+
16
+ warningInstance.create(
17
+ verdaccioWarning,
18
+ Codes.VERWAR001,
19
+ `Verdaccio doesn't need superuser privileges. don't run it under root`
20
+ );
21
+
22
+ warningInstance.create(verdaccioWarning, Codes.VERWAR002, 'logger is not defined');
23
+
24
+ warningInstance.create(
25
+ verdaccioWarning,
26
+ Codes.VERWAR003,
27
+ 'rotating-file type is not longer supported, consider use [logrotate] instead'
28
+ );
29
+
30
+ warningInstance.create(
31
+ verdaccioWarning,
32
+ Codes.VERWAR004,
33
+ `invalid address - %s, we expect a port (e.g. "4873"),
34
+ host:port (e.g. "localhost:4873") or full url '(e.g. "http://localhost:4873/")
35
+ https://verdaccio.org/docs/en/configuration#listen-port`
36
+ );
37
+
38
+ warningInstance.create(
39
+ verdaccioDeprecation,
40
+ Codes.VERDEP003,
41
+ 'multiple addresses will be deprecated in the next major, only use one'
42
+ );
43
+
44
+ export function emit(code, a?: string, b?: string, c?: string) {
45
+ warningInstance.emit(code, a, b, c);
46
+ }
@@ -1,17 +1,17 @@
1
1
  import _ from 'lodash';
2
- import { HTTP_STATUS } from '../src/constants';
3
2
 
3
+ import { HTTP_STATUS } from '../src/constants';
4
4
  import {
5
- getNotFound,
5
+ API_ERROR,
6
6
  VerdaccioError,
7
- getConflict,
8
7
  getBadData,
9
- getInternalError,
10
- API_ERROR,
11
- getUnauthorized,
8
+ getCode,
9
+ getConflict,
12
10
  getForbidden,
11
+ getInternalError,
12
+ getNotFound,
13
13
  getServiceUnavailable,
14
- getCode,
14
+ getUnauthorized,
15
15
  } from '../src/error-utils';
16
16
 
17
17
  describe('testing errors', () => {
@@ -1,4 +1,4 @@
1
- import { semverSort, mergeVersions } from '../src/pkg-utils';
1
+ import { mergeVersions, semverSort } from '../src/pkg-utils';
2
2
 
3
3
  describe('Storage._merge_versions versions', () => {
4
4
  test('simple', () => {
@@ -1,5 +1,6 @@
1
1
  import { Stream } from 'stream';
2
- import { readableToString, ReadTarball, UploadTarball } from '../src/stream-utils';
2
+
3
+ import { ReadTarball, UploadTarball, readableToString } from '../src/stream-utils';
3
4
 
4
5
  describe('mystreams', () => {
5
6
  test('should delay events on ReadTarball abort', (cb) => {
@@ -1,4 +1,4 @@
1
- import { validateName, validatePackage, isObject } from '../src/validation-utils';
1
+ import { isObject, validateName, validatePackage } from '../src/validation-utils';
2
2
 
3
3
  describe('validatePackage', () => {
4
4
  test('should validate package names', () => {