oc 0.49.6 → 0.49.9
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 +26 -0
- package/README.md +2 -15
- package/dist/cli/commands.d.ts +163 -163
- package/dist/cli/commands.js +162 -162
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/clean.js +24 -27
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +41 -48
- package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
- package/dist/cli/domain/get-mocked-plugins.js +89 -87
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +16 -17
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +10 -10
- package/dist/cli/domain/handle-dependencies/get-compiler.js +28 -28
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +18 -18
- package/dist/cli/domain/handle-dependencies/index.d.ts +10 -9
- package/dist/cli/domain/handle-dependencies/index.js +70 -64
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
- package/dist/cli/domain/handle-dependencies/install-compiler.js +54 -47
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -55
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -36
- package/dist/cli/domain/handle-dependencies/require-template.d.ts +17 -17
- package/dist/cli/domain/handle-dependencies/require-template.js +34 -34
- package/dist/cli/domain/init-template/index.d.ts +10 -10
- package/dist/cli/domain/init-template/index.js +40 -42
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +54 -53
- package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
- package/dist/cli/domain/init-template/scaffold.js +30 -30
- package/dist/cli/domain/local.d.ts +2 -2
- package/dist/cli/domain/local.js +82 -81
- package/dist/cli/domain/mock.d.ts +5 -5
- package/dist/cli/domain/mock.js +33 -33
- package/dist/cli/domain/package-components.d.ts +9 -9
- package/dist/cli/domain/package-components.js +67 -70
- package/dist/cli/domain/registry.d.ts +6 -6
- package/dist/cli/domain/registry.js +136 -149
- package/dist/cli/domain/url-parser.d.ts +14 -14
- package/dist/cli/domain/url-parser.js +31 -31
- package/dist/cli/domain/watch.d.ts +1 -1
- package/dist/cli/domain/watch.js +29 -29
- package/dist/cli/facade/clean.d.ts +16 -10
- package/dist/cli/facade/clean.js +58 -48
- package/dist/cli/facade/dev.d.ts +114 -21
- package/dist/cli/facade/dev.js +176 -190
- package/dist/cli/facade/init.d.ts +18 -11
- package/dist/cli/facade/init.js +39 -37
- package/dist/cli/facade/mock.d.ts +18 -11
- package/dist/cli/facade/mock.js +12 -13
- package/dist/cli/facade/package.d.ts +18 -11
- package/dist/cli/facade/package.js +49 -51
- package/dist/cli/facade/preview.d.ts +14 -9
- package/dist/cli/facade/preview.js +20 -18
- package/dist/cli/facade/publish.d.ts +23 -14
- package/dist/cli/facade/publish.js +145 -165
- package/dist/cli/facade/registry-add.d.ts +14 -9
- package/dist/cli/facade/registry-add.js +18 -17
- package/dist/cli/facade/registry-ls.d.ts +10 -7
- package/dist/cli/facade/registry-ls.js +27 -25
- package/dist/cli/facade/registry-remove.d.ts +14 -9
- package/dist/cli/facade/registry-remove.js +18 -17
- package/dist/cli/facade/registry.d.ts +5 -2
- package/dist/cli/facade/registry.js +9 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +91 -93
- package/dist/cli/logger.d.ts +8 -8
- package/dist/cli/logger.js +19 -19
- package/dist/cli/programmatic-api.d.ts +84 -84
- package/dist/cli/programmatic-api.js +66 -66
- package/dist/cli/validate-command.d.ts +2 -2
- package/dist/cli/validate-command.js +18 -18
- package/dist/components/oc-client/_package/package.json +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/dist/oc-cli.d.ts +2 -2
- package/dist/oc-cli.js +3 -3
- package/dist/registry/app-start.d.ts +2 -2
- package/dist/registry/app-start.js +44 -44
- package/dist/registry/domain/authentication.d.ts +7 -8
- package/dist/registry/domain/authentication.js +53 -50
- package/dist/registry/domain/components-cache/components-list.d.ts +8 -7
- package/dist/registry/domain/components-cache/components-list.js +50 -64
- package/dist/registry/domain/components-cache/index.d.ts +7 -6
- package/dist/registry/domain/components-cache/index.js +76 -79
- package/dist/registry/domain/components-details.d.ts +6 -5
- package/dist/registry/domain/components-details.js +64 -75
- package/dist/registry/domain/events-handler.d.ts +40 -40
- package/dist/registry/domain/events-handler.js +37 -37
- package/dist/registry/domain/extract-package.d.ts +8 -8
- package/dist/registry/domain/extract-package.js +26 -29
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +2 -2
- package/dist/registry/domain/get-package-json-from-temp-dir.js +11 -11
- package/dist/registry/domain/nested-renderer.d.ts +14 -13
- package/dist/registry/domain/nested-renderer.js +59 -95
- package/dist/registry/domain/options-sanitiser.d.ts +6 -6
- package/dist/registry/domain/options-sanitiser.js +106 -104
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
- package/dist/registry/domain/plugins-initialiser.js +95 -99
- package/dist/registry/domain/register-templates.d.ts +5 -5
- package/dist/registry/domain/register-templates.js +30 -30
- package/dist/registry/domain/repository.d.ts +2 -2
- package/dist/registry/domain/repository.js +237 -259
- package/dist/registry/domain/require-wrapper.d.ts +2 -2
- package/dist/registry/domain/require-wrapper.js +33 -34
- package/dist/registry/domain/sanitiser.d.ts +2 -2
- package/dist/registry/domain/sanitiser.js +52 -52
- package/dist/registry/domain/storage-adapter.d.ts +10 -0
- package/dist/registry/domain/storage-adapter.js +55 -0
- package/dist/registry/domain/url-builder.d.ts +10 -10
- package/dist/registry/domain/url-builder.js +60 -60
- package/dist/registry/domain/validators/component-parameters.d.ts +11 -11
- package/dist/registry/domain/validators/component-parameters.js +79 -79
- package/dist/registry/domain/validators/index.d.ts +16 -16
- package/dist/registry/domain/validators/index.js +29 -29
- package/dist/registry/domain/validators/node-version.d.ts +15 -15
- package/dist/registry/domain/validators/node-version.js +40 -40
- package/dist/registry/domain/validators/oc-cli-version.d.ts +15 -15
- package/dist/registry/domain/validators/oc-cli-version.js +34 -34
- package/dist/registry/domain/validators/package-json-validator.d.ts +13 -13
- package/dist/registry/domain/validators/package-json-validator.js +23 -23
- package/dist/registry/domain/validators/plugins-requirements.d.ts +9 -9
- package/dist/registry/domain/validators/plugins-requirements.js +22 -22
- package/dist/registry/domain/validators/registry-configuration.d.ts +9 -9
- package/dist/registry/domain/validators/registry-configuration.js +113 -113
- package/dist/registry/domain/validators/uploaded-package.d.ts +14 -14
- package/dist/registry/domain/validators/uploaded-package.js +25 -25
- package/dist/registry/domain/version-handler.d.ts +2 -2
- package/dist/registry/domain/version-handler.js +22 -22
- package/dist/registry/index.d.ts +48 -48
- package/dist/registry/index.js +107 -120
- package/dist/registry/middleware/base-url-handler.d.ts +2 -2
- package/dist/registry/middleware/base-url-handler.js +12 -12
- package/dist/registry/middleware/cors.d.ts +2 -2
- package/dist/registry/middleware/cors.js +11 -11
- package/dist/registry/middleware/discovery-handler.d.ts +2 -2
- package/dist/registry/middleware/discovery-handler.js +15 -15
- package/dist/registry/middleware/file-uploads.d.ts +2 -2
- package/dist/registry/middleware/file-uploads.js +23 -23
- package/dist/registry/middleware/index.d.ts +7 -3
- package/dist/registry/middleware/index.js +51 -47
- package/dist/registry/middleware/request-handler.d.ts +2 -2
- package/dist/registry/middleware/request-handler.js +30 -30
- package/dist/registry/router.d.ts +3 -3
- package/dist/registry/router.js +56 -58
- package/dist/registry/routes/component-info.d.ts +3 -3
- package/dist/registry/routes/component-info.js +90 -89
- package/dist/registry/routes/component-preview.d.ts +3 -3
- package/dist/registry/routes/component-preview.js +68 -67
- package/dist/registry/routes/component.d.ts +3 -3
- package/dist/registry/routes/component.js +43 -43
- package/dist/registry/routes/components.d.ts +3 -3
- package/dist/registry/routes/components.js +78 -78
- package/dist/registry/routes/dependencies.d.ts +3 -3
- package/dist/registry/routes/dependencies.js +28 -28
- package/dist/registry/routes/helpers/apply-default-values.d.ts +2 -2
- package/dist/registry/routes/helpers/apply-default-values.js +13 -13
- package/dist/registry/routes/helpers/get-available-dependencies.d.ts +8 -8
- package/dist/registry/routes/helpers/get-available-dependencies.js +24 -24
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -22
- package/dist/registry/routes/helpers/get-component-fallback.js +91 -91
- package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +20 -20
- package/dist/registry/routes/helpers/get-component-retrieving-info.js +24 -24
- package/dist/registry/routes/helpers/get-component.d.ts +33 -33
- package/dist/registry/routes/helpers/get-component.js +406 -405
- package/dist/registry/routes/helpers/get-components-history.d.ts +8 -8
- package/dist/registry/routes/helpers/get-components-history.js +28 -28
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +3 -3
- package/dist/registry/routes/helpers/is-url-discoverable.js +22 -16
- package/dist/registry/routes/index.d.ts +3 -3
- package/dist/registry/routes/index.js +93 -92
- package/dist/registry/routes/plugins.d.ts +3 -3
- package/dist/registry/routes/plugins.js +17 -17
- package/dist/registry/routes/publish.d.ts +3 -3
- package/dist/registry/routes/publish.js +97 -96
- package/dist/registry/routes/static-redirector.d.ts +3 -3
- package/dist/registry/routes/static-redirector.js +63 -63
- package/dist/registry/views/index.d.ts +2 -2
- package/dist/registry/views/index.js +39 -39
- package/dist/registry/views/info.d.ts +16 -16
- package/dist/registry/views/info.js +44 -41
- package/dist/registry/views/partials/component-author.d.ts +8 -8
- package/dist/registry/views/partials/component-author.js +20 -20
- package/dist/registry/views/partials/component-parameters.d.ts +5 -5
- package/dist/registry/views/partials/component-parameters.js +24 -24
- package/dist/registry/views/partials/component-state.d.ts +5 -5
- package/dist/registry/views/partials/component-state.js +6 -6
- package/dist/registry/views/partials/component-versions.d.ts +5 -5
- package/dist/registry/views/partials/component-versions.js +9 -9
- package/dist/registry/views/partials/components-dependencies.d.ts +2 -2
- package/dist/registry/views/partials/components-dependencies.js +12 -12
- package/dist/registry/views/partials/components-history.d.ts +2 -2
- package/dist/registry/views/partials/components-history.js +10 -10
- package/dist/registry/views/partials/components-list.d.ts +2 -2
- package/dist/registry/views/partials/components-list.js +26 -26
- package/dist/registry/views/partials/components-plugins.d.ts +2 -2
- package/dist/registry/views/partials/components-plugins.js +8 -8
- package/dist/registry/views/partials/components-templates.d.ts +2 -2
- package/dist/registry/views/partials/components-templates.js +14 -14
- package/dist/registry/views/partials/layout.d.ts +8 -8
- package/dist/registry/views/partials/layout.js +11 -11
- package/dist/registry/views/partials/property.d.ts +2 -2
- package/dist/registry/views/partials/property.js +11 -11
- package/dist/registry/views/partials/selected-checkbox.d.ts +4 -4
- package/dist/registry/views/partials/selected-checkbox.js +7 -7
- package/dist/registry/views/preview.d.ts +8 -8
- package/dist/registry/views/preview.js +9 -9
- package/dist/registry/views/static/index.d.ts +2 -2
- package/dist/registry/views/static/index.js +3 -3
- package/dist/registry/views/static/info.d.ts +2 -2
- package/dist/registry/views/static/info.js +15 -4
- package/dist/registry/views/static/style.d.ts +2 -2
- package/dist/registry/views/static/style.js +3 -3
- package/dist/resources/index.d.ts +134 -134
- package/dist/resources/index.js +145 -145
- package/dist/resources/settings.d.ts +17 -17
- package/dist/resources/settings.js +18 -18
- package/dist/types.d.ts +287 -285
- package/dist/types.js +2 -2
- package/dist/utils/clean-require.d.ts +16 -16
- package/dist/utils/clean-require.js +18 -18
- package/dist/utils/date-stringify.d.ts +1 -1
- package/dist/utils/date-stringify.js +22 -22
- package/dist/utils/error-to-string.d.ts +1 -1
- package/dist/utils/error-to-string.js +15 -15
- package/dist/utils/is-template-legacy.d.ts +3 -3
- package/dist/utils/is-template-legacy.js +6 -6
- package/dist/utils/is-template-valid.d.ts +4 -4
- package/dist/utils/is-template-valid.js +12 -12
- package/dist/utils/module-exists.d.ts +1 -1
- package/dist/utils/module-exists.js +15 -15
- package/dist/utils/npm-utils.d.ts +20 -22
- package/dist/utils/npm-utils.js +74 -63
- package/dist/utils/put.d.ts +2 -1
- package/dist/utils/put.js +29 -48
- package/dist/utils/strip-version.d.ts +1 -1
- package/dist/utils/strip-version.js +11 -11
- package/logintervals.md +1 -1
- package/package.json +6 -1
- package/src/cli/domain/clean.ts +10 -20
- package/src/cli/domain/get-components-by-dir.ts +12 -26
- package/src/cli/domain/get-mocked-plugins.ts +32 -26
- package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +8 -12
- package/src/cli/domain/handle-dependencies/get-compiler.ts +8 -11
- package/src/cli/domain/handle-dependencies/index.ts +55 -109
- package/src/cli/domain/handle-dependencies/install-compiler.ts +22 -15
- package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +19 -13
- package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +8 -16
- package/src/cli/domain/init-template/index.ts +13 -20
- package/src/cli/domain/init-template/install-template.ts +11 -12
- package/src/cli/domain/init-template/scaffold.ts +9 -12
- package/src/cli/domain/local.ts +19 -22
- package/src/cli/domain/mock.ts +32 -36
- package/src/cli/domain/package-components.ts +14 -25
- package/src/cli/domain/registry.ts +80 -116
- package/src/cli/domain/watch.ts +1 -1
- package/src/cli/facade/clean.ts +37 -37
- package/src/cli/facade/dev.ts +159 -182
- package/src/cli/facade/init.ts +36 -38
- package/src/cli/facade/mock.ts +11 -10
- package/src/cli/facade/package.ts +44 -49
- package/src/cli/facade/preview.ts +20 -18
- package/src/cli/facade/publish.ts +134 -172
- package/src/cli/facade/registry-add.ts +16 -15
- package/src/cli/facade/registry-ls.ts +27 -22
- package/src/cli/facade/registry-remove.ts +16 -15
- package/src/cli/facade/registry.ts +7 -5
- package/src/cli/index.ts +3 -5
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/globals.d.ts +38 -0
- package/src/oc-cli.js +0 -0
- package/src/registry/app-start.ts +27 -31
- package/src/registry/domain/authentication.ts +5 -13
- package/src/registry/domain/components-cache/components-list.ts +45 -67
- package/src/registry/domain/components-cache/index.ts +55 -60
- package/src/registry/domain/components-details.ts +49 -75
- package/src/registry/domain/extract-package.ts +19 -27
- package/src/registry/domain/get-package-json-from-temp-dir.ts +3 -4
- package/src/registry/domain/nested-renderer.ts +64 -122
- package/src/registry/domain/options-sanitiser.ts +6 -3
- package/src/registry/domain/plugins-initialiser.ts +45 -49
- package/src/registry/domain/repository.ts +129 -235
- package/src/registry/domain/require-wrapper.ts +1 -2
- package/src/registry/domain/storage-adapter.ts +85 -0
- package/src/registry/index.ts +48 -79
- package/src/registry/middleware/index.ts +10 -2
- package/src/registry/router.ts +2 -10
- package/src/registry/routes/component-info.ts +4 -3
- package/src/registry/routes/component-preview.ts +3 -2
- package/src/registry/routes/components.ts +1 -1
- package/src/registry/routes/helpers/get-component-fallback.ts +3 -9
- package/src/registry/routes/helpers/get-component.ts +11 -9
- package/src/registry/routes/helpers/is-url-discoverable.ts +14 -15
- package/src/registry/routes/index.ts +18 -13
- package/src/registry/routes/publish.ts +31 -34
- package/src/registry/views/info.ts +5 -2
- package/src/registry/views/static/info.ts +12 -1
- package/src/resources/settings.ts +1 -1
- package/src/types.ts +80 -141
- package/src/utils/npm-utils.ts +38 -37
- package/src/utils/put.ts +15 -37
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const builtin_modules_1 = __importDefault(require("builtin-modules"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const require_package_name_1 = __importDefault(require("require-package-name"));
|
|
9
|
-
const try_require_1 = __importDefault(require("try-require"));
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const builtin_modules_1 = __importDefault(require("builtin-modules"));
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const require_package_name_1 = __importDefault(require("require-package-name"));
|
|
9
|
+
const try_require_1 = __importDefault(require("try-require"));
|
|
10
|
+
const resources_1 = __importDefault(require("../../resources"));
|
|
11
|
+
const isCoreDependency = (x) => builtin_modules_1.default.includes(x);
|
|
12
|
+
const requireCoreDependency = (x) => (isCoreDependency(x) && (0, try_require_1.default)(x)) || undefined;
|
|
13
|
+
const requireDependency = (requirePath) => {
|
|
14
|
+
const nodeModulesPath = path_1.default.resolve('.', 'node_modules');
|
|
15
|
+
const modulePath = path_1.default.resolve(nodeModulesPath, requirePath);
|
|
16
|
+
return (0, try_require_1.default)(modulePath);
|
|
17
|
+
};
|
|
18
|
+
const throwError = (requirePath) => {
|
|
19
|
+
throw {
|
|
20
|
+
code: resources_1.default.errors.registry.DEPENDENCY_NOT_FOUND_CODE,
|
|
21
|
+
missing: [requirePath]
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
exports.default = (injectedDependencies) => (requirePath) => {
|
|
25
|
+
const moduleName = (0, require_package_name_1.default)(requirePath);
|
|
26
|
+
const isAllowed = injectedDependencies.includes(moduleName);
|
|
27
|
+
if (!isAllowed) {
|
|
28
|
+
return throwError(requirePath);
|
|
29
|
+
}
|
|
30
|
+
return (requireDependency(requirePath) ||
|
|
31
|
+
requireCoreDependency(requirePath) ||
|
|
32
|
+
throwError(requirePath));
|
|
33
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OcParameter } from '../../types';
|
|
2
|
-
export declare function sanitiseComponentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
1
|
+
import { OcParameter } from '../../types';
|
|
2
|
+
export declare function sanitiseComponentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sanitiseComponentParameters = void 0;
|
|
4
|
-
const sanitise = {
|
|
5
|
-
booleanParameter(variable) {
|
|
6
|
-
if (typeof variable === 'string') {
|
|
7
|
-
if (variable === 'true') {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
else if (variable === 'false') {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return variable;
|
|
15
|
-
},
|
|
16
|
-
numberParameter(variable) {
|
|
17
|
-
return Number(variable);
|
|
18
|
-
},
|
|
19
|
-
stringParameter(variable) {
|
|
20
|
-
return variable == null ? '' : variable;
|
|
21
|
-
},
|
|
22
|
-
parameter(variable, type) {
|
|
23
|
-
if (type === 'boolean') {
|
|
24
|
-
return sanitise.booleanParameter(variable);
|
|
25
|
-
}
|
|
26
|
-
else if (type === 'number') {
|
|
27
|
-
return sanitise.numberParameter(variable);
|
|
28
|
-
}
|
|
29
|
-
else if (type === 'string') {
|
|
30
|
-
return sanitise.stringParameter(variable);
|
|
31
|
-
}
|
|
32
|
-
return variable;
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const toRemove = ['__ocAcceptLanguage'];
|
|
36
|
-
function sanitiseComponentParameters(requestParameters, expectedParameters) {
|
|
37
|
-
const result = {};
|
|
38
|
-
for (const [requestParameterName, requestParameter] of Object.entries(requestParameters)) {
|
|
39
|
-
if (typeof expectedParameters === 'object' &&
|
|
40
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
41
|
-
expectedParameters.hasOwnProperty(requestParameterName)) {
|
|
42
|
-
const expectedType = expectedParameters[requestParameterName].type;
|
|
43
|
-
const sanitised = sanitise.parameter(requestParameter, expectedType);
|
|
44
|
-
result[requestParameterName] = sanitised;
|
|
45
|
-
}
|
|
46
|
-
else if (!toRemove.includes(requestParameterName)) {
|
|
47
|
-
result[requestParameterName] = requestParameter;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
exports.sanitiseComponentParameters = sanitiseComponentParameters;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitiseComponentParameters = void 0;
|
|
4
|
+
const sanitise = {
|
|
5
|
+
booleanParameter(variable) {
|
|
6
|
+
if (typeof variable === 'string') {
|
|
7
|
+
if (variable === 'true') {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
else if (variable === 'false') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return variable;
|
|
15
|
+
},
|
|
16
|
+
numberParameter(variable) {
|
|
17
|
+
return Number(variable);
|
|
18
|
+
},
|
|
19
|
+
stringParameter(variable) {
|
|
20
|
+
return variable == null ? '' : variable;
|
|
21
|
+
},
|
|
22
|
+
parameter(variable, type) {
|
|
23
|
+
if (type === 'boolean') {
|
|
24
|
+
return sanitise.booleanParameter(variable);
|
|
25
|
+
}
|
|
26
|
+
else if (type === 'number') {
|
|
27
|
+
return sanitise.numberParameter(variable);
|
|
28
|
+
}
|
|
29
|
+
else if (type === 'string') {
|
|
30
|
+
return sanitise.stringParameter(variable);
|
|
31
|
+
}
|
|
32
|
+
return variable;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const toRemove = ['__ocAcceptLanguage'];
|
|
36
|
+
function sanitiseComponentParameters(requestParameters, expectedParameters) {
|
|
37
|
+
const result = {};
|
|
38
|
+
for (const [requestParameterName, requestParameter] of Object.entries(requestParameters)) {
|
|
39
|
+
if (typeof expectedParameters === 'object' &&
|
|
40
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
41
|
+
expectedParameters.hasOwnProperty(requestParameterName)) {
|
|
42
|
+
const expectedType = expectedParameters[requestParameterName].type;
|
|
43
|
+
const sanitised = sanitise.parameter(requestParameter, expectedType);
|
|
44
|
+
result[requestParameterName] = sanitised;
|
|
45
|
+
}
|
|
46
|
+
else if (!toRemove.includes(requestParameterName)) {
|
|
47
|
+
result[requestParameterName] = requestParameter;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
exports.sanitiseComponentParameters = sanitiseComponentParameters;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
2
|
+
declare type RemovePromiseOverload<T> = T extends {
|
|
3
|
+
(...args: infer B): void;
|
|
4
|
+
(...args: any[]): Promise<any>;
|
|
5
|
+
} ? (...args: B) => void : T;
|
|
6
|
+
declare type LegacyStorageAdapter = {
|
|
7
|
+
[P in keyof StorageAdapter]: RemovePromiseOverload<StorageAdapter[P]>;
|
|
8
|
+
};
|
|
9
|
+
export default function getPromiseBasedAdapter(adapter: StorageAdapter | LegacyStorageAdapter): StorageAdapter;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const universalify_1 = require("universalify");
|
|
4
|
+
const officialAdapters = {
|
|
5
|
+
s3: { name: 'oc-s3-storage-adapter', firstPromiseBasedVersion: '1.2.0' },
|
|
6
|
+
gs: { name: 'oc-gs-storage-adapter', firstPromiseBasedVersion: '1.1.0' },
|
|
7
|
+
'azure-blob-storage': {
|
|
8
|
+
name: 'oc-azure-storage-adapter',
|
|
9
|
+
firstPromiseBasedVersion: '0.1.0'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
function isOfficialAdapter(adapter) {
|
|
13
|
+
return Object.keys(officialAdapters).includes(adapter.adapterType);
|
|
14
|
+
}
|
|
15
|
+
function isPromiseBased(tryFunction) {
|
|
16
|
+
try {
|
|
17
|
+
tryFunction().catch(() => {
|
|
18
|
+
// To not throw unhandled promise exceptions
|
|
19
|
+
});
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function isLegacyAdapter(adapter) {
|
|
27
|
+
return !isPromiseBased(() => adapter.getFile(''));
|
|
28
|
+
}
|
|
29
|
+
function convertLegacyAdapter(adapter) {
|
|
30
|
+
return {
|
|
31
|
+
getFile: (0, universalify_1.fromCallback)(adapter.getFile),
|
|
32
|
+
getJson: (0, universalify_1.fromCallback)(adapter.getJson),
|
|
33
|
+
listSubDirectories: (0, universalify_1.fromCallback)(adapter.listSubDirectories),
|
|
34
|
+
putDir: (0, universalify_1.fromCallback)(adapter.putDir),
|
|
35
|
+
putFile: (0, universalify_1.fromCallback)(adapter.putFile),
|
|
36
|
+
putFileContent: (0, universalify_1.fromCallback)(adapter.putFileContent),
|
|
37
|
+
getUrl: adapter.getUrl,
|
|
38
|
+
maxConcurrentRequests: adapter.maxConcurrentRequests,
|
|
39
|
+
adapterType: adapter.adapterType
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function getPromiseBasedAdapter(adapter) {
|
|
43
|
+
if (isLegacyAdapter(adapter)) {
|
|
44
|
+
if (isOfficialAdapter(adapter)) {
|
|
45
|
+
const pkg = officialAdapters[adapter.adapterType];
|
|
46
|
+
process.emitWarning(`Adapters now should work with promises. Consider upgrading your package ${pkg.name} to at least version ${pkg.firstPromiseBasedVersion}`, 'DeprecationWarning');
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
process.emitWarning('Your adapter is using the old interface of working with callbacks. Consider upgrading it to work with promises, as the previous one will be deprecated.', 'DeprecationWarning');
|
|
50
|
+
}
|
|
51
|
+
return convertLegacyAdapter(adapter);
|
|
52
|
+
}
|
|
53
|
+
return adapter;
|
|
54
|
+
}
|
|
55
|
+
exports.default = getPromiseBasedAdapter;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
declare type Component = {
|
|
2
|
-
name: string;
|
|
3
|
-
version?: string;
|
|
4
|
-
parameters?: Record<string, string>;
|
|
5
|
-
};
|
|
6
|
-
export declare function component(component: Component | string, baseUrl: string): string;
|
|
7
|
-
export declare function componentInfo(component: Component, baseUrl: string): string;
|
|
8
|
-
export declare function componentPreview(component: Component, baseUrl: string): string;
|
|
9
|
-
export declare function queryString(parameters?: Record<string, string>): string;
|
|
10
|
-
export {};
|
|
1
|
+
declare type Component = {
|
|
2
|
+
name: string;
|
|
3
|
+
version?: string;
|
|
4
|
+
parameters?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
export declare function component(component: Component | string, baseUrl: string): string;
|
|
7
|
+
export declare function componentInfo(component: Component, baseUrl: string): string;
|
|
8
|
+
export declare function componentPreview(component: Component, baseUrl: string): string;
|
|
9
|
+
export declare function queryString(parameters?: Record<string, string>): string;
|
|
10
|
+
export {};
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.queryString = exports.componentPreview = exports.componentInfo = exports.component = void 0;
|
|
7
|
-
const querystring_1 = __importDefault(require("querystring"));
|
|
8
|
-
const url_1 = __importDefault(require("url"));
|
|
9
|
-
function componentForType(component, baseUrl, type) {
|
|
10
|
-
if (typeof component === 'string') {
|
|
11
|
-
component = { name: component };
|
|
12
|
-
}
|
|
13
|
-
let href = url_1.default.resolve(baseUrl, component.name) + '/';
|
|
14
|
-
if (component.version) {
|
|
15
|
-
href += component.version + '/';
|
|
16
|
-
}
|
|
17
|
-
href += '~' + type;
|
|
18
|
-
return href;
|
|
19
|
-
}
|
|
20
|
-
function component(component, baseUrl) {
|
|
21
|
-
if (typeof component === 'string') {
|
|
22
|
-
component = { name: component };
|
|
23
|
-
}
|
|
24
|
-
let componentUrl = url_1.default.resolve(baseUrl, component.name);
|
|
25
|
-
if (component.version) {
|
|
26
|
-
componentUrl += '/' + component.version;
|
|
27
|
-
}
|
|
28
|
-
componentUrl += queryString(component.parameters);
|
|
29
|
-
return componentUrl;
|
|
30
|
-
}
|
|
31
|
-
exports.component = component;
|
|
32
|
-
function componentInfo(component, baseUrl) {
|
|
33
|
-
return componentForType(component, baseUrl, 'info');
|
|
34
|
-
}
|
|
35
|
-
exports.componentInfo = componentInfo;
|
|
36
|
-
function componentPreview(component, baseUrl) {
|
|
37
|
-
let href = componentForType(component, baseUrl, 'preview');
|
|
38
|
-
if (!!component.parameters && Object.keys(component.parameters).length) {
|
|
39
|
-
href += '/?' + querystring_1.default.stringify(component.parameters);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
href += '/';
|
|
43
|
-
}
|
|
44
|
-
return href;
|
|
45
|
-
}
|
|
46
|
-
exports.componentPreview = componentPreview;
|
|
47
|
-
function queryString(parameters = {}) {
|
|
48
|
-
let qs = '';
|
|
49
|
-
if (Object.keys(parameters).length > 0) {
|
|
50
|
-
qs += '?';
|
|
51
|
-
for (const [key, parameter] of Object.entries(parameters)) {
|
|
52
|
-
qs += key + '=' + encodeURIComponent(parameter) + '&';
|
|
53
|
-
}
|
|
54
|
-
if (Object.keys(parameters).length > 0) {
|
|
55
|
-
qs = qs.slice(0, -1);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return qs;
|
|
59
|
-
}
|
|
60
|
-
exports.queryString = queryString;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.queryString = exports.componentPreview = exports.componentInfo = exports.component = void 0;
|
|
7
|
+
const querystring_1 = __importDefault(require("querystring"));
|
|
8
|
+
const url_1 = __importDefault(require("url"));
|
|
9
|
+
function componentForType(component, baseUrl, type) {
|
|
10
|
+
if (typeof component === 'string') {
|
|
11
|
+
component = { name: component };
|
|
12
|
+
}
|
|
13
|
+
let href = url_1.default.resolve(baseUrl, component.name) + '/';
|
|
14
|
+
if (component.version) {
|
|
15
|
+
href += component.version + '/';
|
|
16
|
+
}
|
|
17
|
+
href += '~' + type;
|
|
18
|
+
return href;
|
|
19
|
+
}
|
|
20
|
+
function component(component, baseUrl) {
|
|
21
|
+
if (typeof component === 'string') {
|
|
22
|
+
component = { name: component };
|
|
23
|
+
}
|
|
24
|
+
let componentUrl = url_1.default.resolve(baseUrl, component.name);
|
|
25
|
+
if (component.version) {
|
|
26
|
+
componentUrl += '/' + component.version;
|
|
27
|
+
}
|
|
28
|
+
componentUrl += queryString(component.parameters);
|
|
29
|
+
return componentUrl;
|
|
30
|
+
}
|
|
31
|
+
exports.component = component;
|
|
32
|
+
function componentInfo(component, baseUrl) {
|
|
33
|
+
return componentForType(component, baseUrl, 'info');
|
|
34
|
+
}
|
|
35
|
+
exports.componentInfo = componentInfo;
|
|
36
|
+
function componentPreview(component, baseUrl) {
|
|
37
|
+
let href = componentForType(component, baseUrl, 'preview');
|
|
38
|
+
if (!!component.parameters && Object.keys(component.parameters).length) {
|
|
39
|
+
href += '/?' + querystring_1.default.stringify(component.parameters);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
href += '/';
|
|
43
|
+
}
|
|
44
|
+
return href;
|
|
45
|
+
}
|
|
46
|
+
exports.componentPreview = componentPreview;
|
|
47
|
+
function queryString(parameters = {}) {
|
|
48
|
+
let qs = '';
|
|
49
|
+
if (Object.keys(parameters).length > 0) {
|
|
50
|
+
qs += '?';
|
|
51
|
+
for (const [key, parameter] of Object.entries(parameters)) {
|
|
52
|
+
qs += key + '=' + encodeURIComponent(parameter) + '&';
|
|
53
|
+
}
|
|
54
|
+
if (Object.keys(parameters).length > 0) {
|
|
55
|
+
qs = qs.slice(0, -1);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return qs;
|
|
59
|
+
}
|
|
60
|
+
exports.queryString = queryString;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { OcParameter } from '../../../types';
|
|
2
|
-
interface ValidationResult {
|
|
3
|
-
isValid: boolean;
|
|
4
|
-
errors: {
|
|
5
|
-
mandatory?: Record<string, string>;
|
|
6
|
-
types?: Record<string, string>;
|
|
7
|
-
message?: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export default function componentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): ValidationResult;
|
|
11
|
-
export {};
|
|
1
|
+
import { OcParameter } from '../../../types';
|
|
2
|
+
interface ValidationResult {
|
|
3
|
+
isValid: boolean;
|
|
4
|
+
errors: {
|
|
5
|
+
mandatory?: Record<string, string>;
|
|
6
|
+
types?: Record<string, string>;
|
|
7
|
+
message?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export default function componentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): ValidationResult;
|
|
11
|
+
export {};
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const resources_1 = __importDefault(require("../../../resources"));
|
|
7
|
-
const validateParameter = function (parameter, expectedType) {
|
|
8
|
-
const expected = expectedType.toLowerCase();
|
|
9
|
-
if (expected === 'boolean') {
|
|
10
|
-
return typeof parameter === 'boolean';
|
|
11
|
-
}
|
|
12
|
-
else if (expected === 'number') {
|
|
13
|
-
return typeof parameter === 'number';
|
|
14
|
-
}
|
|
15
|
-
else if (expected === 'string') {
|
|
16
|
-
return typeof parameter === 'string';
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
};
|
|
20
|
-
function componentParameters(requestParameters, expectedParameters = {}) {
|
|
21
|
-
const result = { isValid: true, errors: {} };
|
|
22
|
-
const mandatoryParameters = [];
|
|
23
|
-
for (const [expectedParameterName, expectedParameter] of Object.entries(expectedParameters)) {
|
|
24
|
-
if (expectedParameter.mandatory) {
|
|
25
|
-
mandatoryParameters.push(expectedParameterName);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
for (const mandatoryParameterName of mandatoryParameters) {
|
|
29
|
-
if (typeof requestParameters === 'object' &&
|
|
30
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
31
|
-
!requestParameters.hasOwnProperty(mandatoryParameterName)) {
|
|
32
|
-
if (!result.errors.mandatory) {
|
|
33
|
-
result.errors.mandatory = {};
|
|
34
|
-
result.isValid = false;
|
|
35
|
-
}
|
|
36
|
-
result.errors.mandatory[mandatoryParameterName] =
|
|
37
|
-
resources_1.default.errors.registry.MANDATORY_PARAMETER_MISSING_CODE;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
for (const [requestParameterName, requestParameter] of Object.entries(requestParameters)) {
|
|
41
|
-
if (typeof expectedParameters === 'object' &&
|
|
42
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
43
|
-
expectedParameters.hasOwnProperty(requestParameterName)) {
|
|
44
|
-
const expectedType = expectedParameters[requestParameterName].type;
|
|
45
|
-
if (!validateParameter(requestParameter, expectedType)) {
|
|
46
|
-
if (!result.errors.types) {
|
|
47
|
-
result.errors.types = {};
|
|
48
|
-
result.isValid = false;
|
|
49
|
-
}
|
|
50
|
-
result.errors.types[requestParameterName] =
|
|
51
|
-
resources_1.default.errors.registry.PARAMETER_WRONG_FORMAT_CODE;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
result.errors.message = (function () {
|
|
56
|
-
let errorString = '';
|
|
57
|
-
if (Object.keys(result.errors.mandatory || {}).length > 0) {
|
|
58
|
-
const missingParams = Object.keys(result.errors.mandatory || {})
|
|
59
|
-
.map(mandatoryParameterName => mandatoryParameterName + ', ')
|
|
60
|
-
.join('')
|
|
61
|
-
.slice(0, -2);
|
|
62
|
-
errorString +=
|
|
63
|
-
resources_1.default.errors.registry.MANDATORY_PARAMETER_MISSING(missingParams);
|
|
64
|
-
}
|
|
65
|
-
if (Object.keys(result.errors.types || {}).length > 0) {
|
|
66
|
-
if (errorString.length > 0) {
|
|
67
|
-
errorString += '; ';
|
|
68
|
-
}
|
|
69
|
-
const badParams = Object.keys(result.errors.types || {})
|
|
70
|
-
.map(parameterName => parameterName + ', ')
|
|
71
|
-
.join('')
|
|
72
|
-
.slice(0, -2);
|
|
73
|
-
errorString += resources_1.default.errors.registry.PARAMETER_WRONG_FORMAT(badParams);
|
|
74
|
-
}
|
|
75
|
-
return errorString;
|
|
76
|
-
})();
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
exports.default = componentParameters;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const resources_1 = __importDefault(require("../../../resources"));
|
|
7
|
+
const validateParameter = function (parameter, expectedType) {
|
|
8
|
+
const expected = expectedType.toLowerCase();
|
|
9
|
+
if (expected === 'boolean') {
|
|
10
|
+
return typeof parameter === 'boolean';
|
|
11
|
+
}
|
|
12
|
+
else if (expected === 'number') {
|
|
13
|
+
return typeof parameter === 'number';
|
|
14
|
+
}
|
|
15
|
+
else if (expected === 'string') {
|
|
16
|
+
return typeof parameter === 'string';
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
function componentParameters(requestParameters, expectedParameters = {}) {
|
|
21
|
+
const result = { isValid: true, errors: {} };
|
|
22
|
+
const mandatoryParameters = [];
|
|
23
|
+
for (const [expectedParameterName, expectedParameter] of Object.entries(expectedParameters)) {
|
|
24
|
+
if (expectedParameter.mandatory) {
|
|
25
|
+
mandatoryParameters.push(expectedParameterName);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const mandatoryParameterName of mandatoryParameters) {
|
|
29
|
+
if (typeof requestParameters === 'object' &&
|
|
30
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
31
|
+
!requestParameters.hasOwnProperty(mandatoryParameterName)) {
|
|
32
|
+
if (!result.errors.mandatory) {
|
|
33
|
+
result.errors.mandatory = {};
|
|
34
|
+
result.isValid = false;
|
|
35
|
+
}
|
|
36
|
+
result.errors.mandatory[mandatoryParameterName] =
|
|
37
|
+
resources_1.default.errors.registry.MANDATORY_PARAMETER_MISSING_CODE;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const [requestParameterName, requestParameter] of Object.entries(requestParameters)) {
|
|
41
|
+
if (typeof expectedParameters === 'object' &&
|
|
42
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
43
|
+
expectedParameters.hasOwnProperty(requestParameterName)) {
|
|
44
|
+
const expectedType = expectedParameters[requestParameterName].type;
|
|
45
|
+
if (!validateParameter(requestParameter, expectedType)) {
|
|
46
|
+
if (!result.errors.types) {
|
|
47
|
+
result.errors.types = {};
|
|
48
|
+
result.isValid = false;
|
|
49
|
+
}
|
|
50
|
+
result.errors.types[requestParameterName] =
|
|
51
|
+
resources_1.default.errors.registry.PARAMETER_WRONG_FORMAT_CODE;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
result.errors.message = (function () {
|
|
56
|
+
let errorString = '';
|
|
57
|
+
if (Object.keys(result.errors.mandatory || {}).length > 0) {
|
|
58
|
+
const missingParams = Object.keys(result.errors.mandatory || {})
|
|
59
|
+
.map(mandatoryParameterName => mandatoryParameterName + ', ')
|
|
60
|
+
.join('')
|
|
61
|
+
.slice(0, -2);
|
|
62
|
+
errorString +=
|
|
63
|
+
resources_1.default.errors.registry.MANDATORY_PARAMETER_MISSING(missingParams);
|
|
64
|
+
}
|
|
65
|
+
if (Object.keys(result.errors.types || {}).length > 0) {
|
|
66
|
+
if (errorString.length > 0) {
|
|
67
|
+
errorString += '; ';
|
|
68
|
+
}
|
|
69
|
+
const badParams = Object.keys(result.errors.types || {})
|
|
70
|
+
.map(parameterName => parameterName + ', ')
|
|
71
|
+
.join('')
|
|
72
|
+
.slice(0, -2);
|
|
73
|
+
errorString += resources_1.default.errors.registry.PARAMETER_WRONG_FORMAT(badParams);
|
|
74
|
+
}
|
|
75
|
+
return errorString;
|
|
76
|
+
})();
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
exports.default = componentParameters;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import ocCliVersionValidator from './oc-cli-version';
|
|
2
|
-
import componentParametersValidator from './component-parameters';
|
|
3
|
-
import packageJsonValidator from './package-json-validator';
|
|
4
|
-
import pluginsRequirementsValidator from './plugins-requirements';
|
|
5
|
-
import registryConfigurationValidator from './registry-configuration';
|
|
6
|
-
import uploadedPackageValidator from './uploaded-package';
|
|
7
|
-
import nodeVersionValidator from './node-version';
|
|
8
|
-
export declare function validateComponentName(componentName: string): boolean;
|
|
9
|
-
export declare const validateComponentParameters: typeof componentParametersValidator;
|
|
10
|
-
export declare const validateNodeVersion: typeof nodeVersionValidator;
|
|
11
|
-
export declare const validateOcCliVersion: typeof ocCliVersionValidator;
|
|
12
|
-
export declare const validatePackage: typeof uploadedPackageValidator;
|
|
13
|
-
export declare const validatePackageJson: typeof packageJsonValidator;
|
|
14
|
-
export declare const validatePluginsRequirements: typeof pluginsRequirementsValidator;
|
|
15
|
-
export declare const validateRegistryConfiguration: typeof registryConfigurationValidator;
|
|
16
|
-
export declare function validateVersion(version: string): boolean;
|
|
1
|
+
import ocCliVersionValidator from './oc-cli-version';
|
|
2
|
+
import componentParametersValidator from './component-parameters';
|
|
3
|
+
import packageJsonValidator from './package-json-validator';
|
|
4
|
+
import pluginsRequirementsValidator from './plugins-requirements';
|
|
5
|
+
import registryConfigurationValidator from './registry-configuration';
|
|
6
|
+
import uploadedPackageValidator from './uploaded-package';
|
|
7
|
+
import nodeVersionValidator from './node-version';
|
|
8
|
+
export declare function validateComponentName(componentName: string): boolean;
|
|
9
|
+
export declare const validateComponentParameters: typeof componentParametersValidator;
|
|
10
|
+
export declare const validateNodeVersion: typeof nodeVersionValidator;
|
|
11
|
+
export declare const validateOcCliVersion: typeof ocCliVersionValidator;
|
|
12
|
+
export declare const validatePackage: typeof uploadedPackageValidator;
|
|
13
|
+
export declare const validatePackageJson: typeof packageJsonValidator;
|
|
14
|
+
export declare const validatePluginsRequirements: typeof pluginsRequirementsValidator;
|
|
15
|
+
export declare const validateRegistryConfiguration: typeof registryConfigurationValidator;
|
|
16
|
+
export declare function validateVersion(version: string): boolean;
|