oc 0.49.26 → 0.49.28
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 +10 -0
- 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 -24
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +41 -41
- package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
- package/dist/cli/domain/get-mocked-plugins.js +88 -88
- 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 +15 -15
- 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 -10
- package/dist/cli/domain/handle-dependencies/index.js +70 -70
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
- package/dist/cli/domain/handle-dependencies/install-compiler.js +58 -58
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +63 -63
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -32
- 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 +44 -44
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +58 -58
- package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
- package/dist/cli/domain/init-template/scaffold.js +34 -34
- package/dist/cli/domain/local.d.ts +21 -21
- package/dist/cli/domain/local.js +86 -86
- 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 +71 -71
- package/dist/cli/domain/registry.d.ts +20 -20
- package/dist/cli/domain/registry.js +143 -143
- 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 -16
- package/dist/cli/facade/clean.js +58 -58
- package/dist/cli/facade/dev.d.ts +146 -114
- package/dist/cli/facade/dev.js +177 -177
- package/dist/cli/facade/init.d.ts +18 -18
- package/dist/cli/facade/init.js +39 -39
- package/dist/cli/facade/mock.d.ts +18 -18
- package/dist/cli/facade/mock.js +12 -12
- package/dist/cli/facade/package.d.ts +19 -19
- package/dist/cli/facade/package.js +49 -49
- package/dist/cli/facade/preview.d.ts +14 -14
- package/dist/cli/facade/preview.js +20 -20
- package/dist/cli/facade/publish.d.ts +24 -24
- package/dist/cli/facade/publish.js +145 -145
- package/dist/cli/facade/registry-add.d.ts +14 -14
- package/dist/cli/facade/registry-add.js +18 -18
- package/dist/cli/facade/registry-ls.d.ts +10 -10
- package/dist/cli/facade/registry-ls.js +27 -27
- package/dist/cli/facade/registry-remove.d.ts +14 -14
- package/dist/cli/facade/registry-remove.js +18 -18
- package/dist/cli/facade/registry.d.ts +5 -5
- package/dist/cli/facade/registry.js +9 -9
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +91 -91
- 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/server.js +1 -1
- package/dist/components/oc-client/_package/src/oc-client.min.js +2 -2
- package/dist/components/oc-client/_package/src/oc-client.min.map +1 -1
- package/dist/components/oc-client/_package/template.js +11 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/components/oc-client/src/oc-client.min.js +2 -2
- package/dist/components/oc-client/src/oc-client.min.map +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 +3 -3
- package/dist/registry/app-start.js +44 -44
- package/dist/registry/domain/authentication.d.ts +7 -7
- package/dist/registry/domain/authentication.js +53 -53
- package/dist/registry/domain/components-cache/components-list.d.ts +8 -8
- package/dist/registry/domain/components-cache/components-list.js +73 -73
- package/dist/registry/domain/components-cache/index.d.ts +7 -7
- package/dist/registry/domain/components-cache/index.js +81 -81
- package/dist/registry/domain/components-details.d.ts +6 -6
- package/dist/registry/domain/components-details.js +63 -63
- package/dist/registry/domain/events-handler.d.ts +48 -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 +30 -30
- 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 -14
- package/dist/registry/domain/nested-renderer.js +59 -59
- package/dist/registry/domain/options-sanitiser.d.ts +6 -6
- package/dist/registry/domain/options-sanitiser.js +113 -113
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -3
- package/dist/registry/domain/plugins-initialiser.js +95 -95
- package/dist/registry/domain/register-templates.d.ts +5 -5
- package/dist/registry/domain/register-templates.js +37 -37
- package/dist/registry/domain/repository.d.ts +26 -26
- package/dist/registry/domain/repository.js +255 -255
- package/dist/registry/domain/require-wrapper.d.ts +2 -2
- package/dist/registry/domain/require-wrapper.js +33 -33
- 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 -10
- package/dist/registry/domain/storage-adapter.js +55 -55
- 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 +117 -117
- 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 +64 -48
- package/dist/registry/index.js +109 -109
- 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 +3 -3
- package/dist/registry/middleware/index.js +48 -48
- 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 +4 -4
- package/dist/registry/router.js +56 -56
- package/dist/registry/routes/component-info.d.ts +4 -4
- package/dist/registry/routes/component-info.js +95 -94
- package/dist/registry/routes/component-preview.d.ts +4 -4
- package/dist/registry/routes/component-preview.js +72 -72
- package/dist/registry/routes/component.d.ts +4 -4
- package/dist/registry/routes/component.js +43 -43
- package/dist/registry/routes/components.d.ts +4 -4
- 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 +23 -23
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -17
- package/dist/registry/routes/helpers/get-component-fallback.js +95 -95
- 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 +34 -34
- package/dist/registry/routes/helpers/get-component.js +445 -435
- 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 +21 -21
- package/dist/registry/routes/index.d.ts +3 -3
- package/dist/registry/routes/index.js +93 -93
- 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 +101 -101
- package/dist/registry/routes/static-redirector.d.ts +3 -3
- package/dist/registry/routes/static-redirector.js +86 -86
- 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 +39 -39
- 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 +3 -3
- 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 +231 -231
- 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 -20
- package/dist/utils/npm-utils.js +74 -74
- package/dist/utils/put.d.ts +2 -2
- package/dist/utils/put.js +29 -29
- 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 +20 -20
|
@@ -1,255 +1,255 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
-
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
33
|
-
const components_cache_1 = __importDefault(require("./components-cache"));
|
|
34
|
-
const components_details_1 = __importDefault(require("./components-details"));
|
|
35
|
-
const register_templates_1 = __importDefault(require("./register-templates"));
|
|
36
|
-
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
37
|
-
const resources_1 = __importDefault(require("../../resources"));
|
|
38
|
-
const validator = __importStar(require("./validators"));
|
|
39
|
-
const storage_adapter_1 = __importDefault(require("./storage-adapter"));
|
|
40
|
-
const versionHandler = __importStar(require("./version-handler"));
|
|
41
|
-
const error_to_string_1 = __importDefault(require("../../utils/error-to-string"));
|
|
42
|
-
const packageInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
|
|
43
|
-
function repository(conf) {
|
|
44
|
-
const cdn = !conf.local &&
|
|
45
|
-
(0, storage_adapter_1.default)(conf.storage.adapter(conf.storage.options));
|
|
46
|
-
const options = !conf.local ? conf.storage.options : null;
|
|
47
|
-
const repositorySource = conf.local
|
|
48
|
-
? 'local repository'
|
|
49
|
-
: cdn.adapterType + ' cdn';
|
|
50
|
-
const componentsCache = (0, components_cache_1.default)(conf, cdn);
|
|
51
|
-
const componentsDetails = (0, components_details_1.default)(conf, cdn);
|
|
52
|
-
const getFilePath = (component, version, filePath) => `${options.componentsDir}/${component}/${version}/${filePath}`;
|
|
53
|
-
const { templatesHash, templatesInfo } = (0, register_templates_1.default)(conf.templates, conf.local);
|
|
54
|
-
const local = {
|
|
55
|
-
getCompiledView(componentName) {
|
|
56
|
-
if (componentName === 'oc-client') {
|
|
57
|
-
return fs_extra_1.default
|
|
58
|
-
.readFileSync(path_1.default.join(__dirname, '../../components/oc-client/_package/template.js'))
|
|
59
|
-
.toString();
|
|
60
|
-
}
|
|
61
|
-
return fs_extra_1.default
|
|
62
|
-
.readFileSync(path_1.default.join(conf.path, `${componentName}/_package/template.js`))
|
|
63
|
-
.toString();
|
|
64
|
-
},
|
|
65
|
-
getComponents() {
|
|
66
|
-
const validComponents = conf.components ||
|
|
67
|
-
fs_extra_1.default.readdirSync(conf.path).filter(file => {
|
|
68
|
-
const isDir = fs_extra_1.default.lstatSync(path_1.default.join(conf.path, file)).isDirectory();
|
|
69
|
-
const isValidComponent = isDir
|
|
70
|
-
? fs_extra_1.default
|
|
71
|
-
.readdirSync(path_1.default.join(conf.path, file))
|
|
72
|
-
.filter(file => file === '_package').length === 1
|
|
73
|
-
: false;
|
|
74
|
-
return isValidComponent;
|
|
75
|
-
});
|
|
76
|
-
validComponents.push('oc-client');
|
|
77
|
-
return validComponents;
|
|
78
|
-
},
|
|
79
|
-
getComponentVersions(componentName) {
|
|
80
|
-
if (componentName === 'oc-client') {
|
|
81
|
-
return Promise.all([
|
|
82
|
-
fs_extra_1.default
|
|
83
|
-
.readJson(path_1.default.join(__dirname, '../../../package.json'))
|
|
84
|
-
.then(x => x.version)
|
|
85
|
-
]);
|
|
86
|
-
}
|
|
87
|
-
if (!local.getComponents().includes(componentName)) {
|
|
88
|
-
return Promise.reject(resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource));
|
|
89
|
-
}
|
|
90
|
-
return Promise.all([
|
|
91
|
-
fs_extra_1.default
|
|
92
|
-
.readJson(path_1.default.join(conf.path, `${componentName}/package.json`))
|
|
93
|
-
.then(x => x.version)
|
|
94
|
-
]);
|
|
95
|
-
},
|
|
96
|
-
getDataProvider(componentName) {
|
|
97
|
-
const ocClientServerPath = '../../components/oc-client/_package/server.js';
|
|
98
|
-
const filePath = componentName === 'oc-client'
|
|
99
|
-
? path_1.default.join(__dirname, ocClientServerPath)
|
|
100
|
-
: path_1.default.join(conf.path, `${componentName}/_package/server.js`);
|
|
101
|
-
return {
|
|
102
|
-
content: fs_extra_1.default.readFileSync(filePath).toString(),
|
|
103
|
-
filePath
|
|
104
|
-
};
|
|
105
|
-
},
|
|
106
|
-
getEnv(componentName) {
|
|
107
|
-
const pkg = fs_extra_1.default.readJsonSync(path_1.default.join(conf.path, `${componentName}/package.json`));
|
|
108
|
-
const filePath = path_1.default.join(conf.path, componentName, pkg.oc.files.env);
|
|
109
|
-
return dotenv_1.default.parse(fs_extra_1.default.readFileSync(filePath).toString());
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
const repository = {
|
|
113
|
-
getCompiledView(componentName, componentVersion) {
|
|
114
|
-
if (conf.local) {
|
|
115
|
-
return Promise.resolve(local.getCompiledView(componentName));
|
|
116
|
-
}
|
|
117
|
-
return cdn.getFile(getFilePath(componentName, componentVersion, 'template.js'));
|
|
118
|
-
},
|
|
119
|
-
async getComponent(componentName, componentVersion) {
|
|
120
|
-
const allVersions = await repository.getComponentVersions(componentName);
|
|
121
|
-
if (allVersions.length === 0) {
|
|
122
|
-
throw resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource);
|
|
123
|
-
}
|
|
124
|
-
const version = versionHandler.getAvailableVersion(componentVersion, allVersions);
|
|
125
|
-
if (!version) {
|
|
126
|
-
throw resources_1.default.errors.registry.COMPONENT_VERSION_NOT_FOUND(componentName, componentVersion || '', repositorySource);
|
|
127
|
-
}
|
|
128
|
-
const component = await repository
|
|
129
|
-
.getComponentInfo(componentName, version)
|
|
130
|
-
.catch(err => {
|
|
131
|
-
throw `component not available: ${(0, error_to_string_1.default)(err)}`;
|
|
132
|
-
});
|
|
133
|
-
return Object.assign(component, { allVersions });
|
|
134
|
-
},
|
|
135
|
-
getComponentInfo(componentName, componentVersion) {
|
|
136
|
-
if (conf.local) {
|
|
137
|
-
let componentInfo;
|
|
138
|
-
if (componentName === 'oc-client') {
|
|
139
|
-
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '../../components/oc-client/_package/package.json'));
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(conf.path, `${componentName}/_package/package.json`));
|
|
143
|
-
}
|
|
144
|
-
if (componentInfo.version === componentVersion) {
|
|
145
|
-
return Promise.resolve(componentInfo);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
// eslint-disable-next-line prefer-promise-reject-errors
|
|
149
|
-
return Promise.reject('version not available');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return cdn.getJson(getFilePath(componentName, componentVersion, 'package.json'), false);
|
|
153
|
-
},
|
|
154
|
-
getComponentPath(componentName, componentVersion) {
|
|
155
|
-
const prefix = conf.local
|
|
156
|
-
? conf.baseUrl
|
|
157
|
-
: `${options['path']}${options.componentsDir}/`;
|
|
158
|
-
return `${prefix}${componentName}/${componentVersion}/`;
|
|
159
|
-
},
|
|
160
|
-
async getComponents() {
|
|
161
|
-
if (conf.local) {
|
|
162
|
-
return local.getComponents();
|
|
163
|
-
}
|
|
164
|
-
const { components } = await componentsCache.get();
|
|
165
|
-
return Object.keys(components);
|
|
166
|
-
},
|
|
167
|
-
getComponentsDetails() {
|
|
168
|
-
if (conf.local) {
|
|
169
|
-
// when in local this won't get called
|
|
170
|
-
return Promise.resolve(null);
|
|
171
|
-
}
|
|
172
|
-
return componentsDetails.get();
|
|
173
|
-
},
|
|
174
|
-
async getComponentVersions(componentName) {
|
|
175
|
-
if (conf.local) {
|
|
176
|
-
return local.getComponentVersions(componentName);
|
|
177
|
-
}
|
|
178
|
-
const res = await componentsCache.get();
|
|
179
|
-
return res.components[componentName] ? res.components[componentName] : [];
|
|
180
|
-
},
|
|
181
|
-
async getDataProvider(componentName, componentVersion) {
|
|
182
|
-
if (conf.local) {
|
|
183
|
-
return local.getDataProvider(componentName);
|
|
184
|
-
}
|
|
185
|
-
const filePath = getFilePath(componentName, componentVersion, 'server.js');
|
|
186
|
-
const content = await cdn.getFile(filePath);
|
|
187
|
-
return { content, filePath };
|
|
188
|
-
},
|
|
189
|
-
async getEnv(componentName, componentVersion) {
|
|
190
|
-
if (conf.local) {
|
|
191
|
-
return local.getEnv(componentName);
|
|
192
|
-
}
|
|
193
|
-
const filePath = getFilePath(componentName, componentVersion, '.env');
|
|
194
|
-
const file = await cdn.getFile(filePath);
|
|
195
|
-
return dotenv_1.default.parse(file);
|
|
196
|
-
},
|
|
197
|
-
getStaticClientPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.js')}`,
|
|
198
|
-
getStaticClientMapPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.map')}`,
|
|
199
|
-
getStaticFilePath: (componentName, componentVersion, filePath) => `${repository.getComponentPath(componentName, componentVersion)}${conf.local ? settings_1.default.registry.localStaticRedirectorPath : ''}${filePath}`,
|
|
200
|
-
getTemplatesInfo: () => templatesInfo,
|
|
201
|
-
getTemplate: (type) => templatesHash[type],
|
|
202
|
-
async init() {
|
|
203
|
-
if (conf.local) {
|
|
204
|
-
// when in local this won't get called
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const componentsList = await componentsCache.load();
|
|
208
|
-
return componentsDetails.refresh(componentsList);
|
|
209
|
-
},
|
|
210
|
-
async publishComponent(pkgDetails, componentName, componentVersion) {
|
|
211
|
-
if (conf.local) {
|
|
212
|
-
throw {
|
|
213
|
-
code: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED_CODE,
|
|
214
|
-
msg: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
if (!validator.validateComponentName(componentName)) {
|
|
218
|
-
throw {
|
|
219
|
-
code: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID_CODE,
|
|
220
|
-
msg: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
if (!validator.validateVersion(componentVersion)) {
|
|
224
|
-
throw {
|
|
225
|
-
code: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID_CODE,
|
|
226
|
-
msg: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID(componentVersion)
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
const validationResult = validator.validatePackageJson(Object.assign(pkgDetails, {
|
|
230
|
-
componentName,
|
|
231
|
-
customValidator: conf.publishValidation
|
|
232
|
-
}));
|
|
233
|
-
if (!validationResult.isValid) {
|
|
234
|
-
throw {
|
|
235
|
-
code: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL_CODE,
|
|
236
|
-
msg: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL(String(validationResult.error))
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
const componentVersions = await repository.getComponentVersions(componentName);
|
|
240
|
-
if (!versionHandler.validateNewVersion(componentVersion, componentVersions)) {
|
|
241
|
-
throw {
|
|
242
|
-
code: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND_CODE,
|
|
243
|
-
msg: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND(componentName, componentVersion, repositorySource)
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
pkgDetails.packageJson.oc.date = (0, oc_get_unix_utc_timestamp_1.default)();
|
|
247
|
-
await fs_extra_1.default.writeJson(path_1.default.join(pkgDetails.outputFolder, 'package.json'), pkgDetails.packageJson);
|
|
248
|
-
await cdn.putDir(pkgDetails.outputFolder, `${options.componentsDir}/${componentName}/${componentVersion}`);
|
|
249
|
-
const componentsList = await componentsCache.refresh();
|
|
250
|
-
return componentsDetails.refresh(componentsList);
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
return repository;
|
|
254
|
-
}
|
|
255
|
-
exports.default = repository;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
+
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
33
|
+
const components_cache_1 = __importDefault(require("./components-cache"));
|
|
34
|
+
const components_details_1 = __importDefault(require("./components-details"));
|
|
35
|
+
const register_templates_1 = __importDefault(require("./register-templates"));
|
|
36
|
+
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
37
|
+
const resources_1 = __importDefault(require("../../resources"));
|
|
38
|
+
const validator = __importStar(require("./validators"));
|
|
39
|
+
const storage_adapter_1 = __importDefault(require("./storage-adapter"));
|
|
40
|
+
const versionHandler = __importStar(require("./version-handler"));
|
|
41
|
+
const error_to_string_1 = __importDefault(require("../../utils/error-to-string"));
|
|
42
|
+
const packageInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
|
|
43
|
+
function repository(conf) {
|
|
44
|
+
const cdn = !conf.local &&
|
|
45
|
+
(0, storage_adapter_1.default)(conf.storage.adapter(conf.storage.options));
|
|
46
|
+
const options = !conf.local ? conf.storage.options : null;
|
|
47
|
+
const repositorySource = conf.local
|
|
48
|
+
? 'local repository'
|
|
49
|
+
: cdn.adapterType + ' cdn';
|
|
50
|
+
const componentsCache = (0, components_cache_1.default)(conf, cdn);
|
|
51
|
+
const componentsDetails = (0, components_details_1.default)(conf, cdn);
|
|
52
|
+
const getFilePath = (component, version, filePath) => `${options.componentsDir}/${component}/${version}/${filePath}`;
|
|
53
|
+
const { templatesHash, templatesInfo } = (0, register_templates_1.default)(conf.templates, conf.local);
|
|
54
|
+
const local = {
|
|
55
|
+
getCompiledView(componentName) {
|
|
56
|
+
if (componentName === 'oc-client') {
|
|
57
|
+
return fs_extra_1.default
|
|
58
|
+
.readFileSync(path_1.default.join(__dirname, '../../components/oc-client/_package/template.js'))
|
|
59
|
+
.toString();
|
|
60
|
+
}
|
|
61
|
+
return fs_extra_1.default
|
|
62
|
+
.readFileSync(path_1.default.join(conf.path, `${componentName}/_package/template.js`))
|
|
63
|
+
.toString();
|
|
64
|
+
},
|
|
65
|
+
getComponents() {
|
|
66
|
+
const validComponents = conf.components ||
|
|
67
|
+
fs_extra_1.default.readdirSync(conf.path).filter(file => {
|
|
68
|
+
const isDir = fs_extra_1.default.lstatSync(path_1.default.join(conf.path, file)).isDirectory();
|
|
69
|
+
const isValidComponent = isDir
|
|
70
|
+
? fs_extra_1.default
|
|
71
|
+
.readdirSync(path_1.default.join(conf.path, file))
|
|
72
|
+
.filter(file => file === '_package').length === 1
|
|
73
|
+
: false;
|
|
74
|
+
return isValidComponent;
|
|
75
|
+
});
|
|
76
|
+
validComponents.push('oc-client');
|
|
77
|
+
return validComponents;
|
|
78
|
+
},
|
|
79
|
+
getComponentVersions(componentName) {
|
|
80
|
+
if (componentName === 'oc-client') {
|
|
81
|
+
return Promise.all([
|
|
82
|
+
fs_extra_1.default
|
|
83
|
+
.readJson(path_1.default.join(__dirname, '../../../package.json'))
|
|
84
|
+
.then(x => x.version)
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
if (!local.getComponents().includes(componentName)) {
|
|
88
|
+
return Promise.reject(resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource));
|
|
89
|
+
}
|
|
90
|
+
return Promise.all([
|
|
91
|
+
fs_extra_1.default
|
|
92
|
+
.readJson(path_1.default.join(conf.path, `${componentName}/package.json`))
|
|
93
|
+
.then(x => x.version)
|
|
94
|
+
]);
|
|
95
|
+
},
|
|
96
|
+
getDataProvider(componentName) {
|
|
97
|
+
const ocClientServerPath = '../../components/oc-client/_package/server.js';
|
|
98
|
+
const filePath = componentName === 'oc-client'
|
|
99
|
+
? path_1.default.join(__dirname, ocClientServerPath)
|
|
100
|
+
: path_1.default.join(conf.path, `${componentName}/_package/server.js`);
|
|
101
|
+
return {
|
|
102
|
+
content: fs_extra_1.default.readFileSync(filePath).toString(),
|
|
103
|
+
filePath
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
getEnv(componentName) {
|
|
107
|
+
const pkg = fs_extra_1.default.readJsonSync(path_1.default.join(conf.path, `${componentName}/package.json`));
|
|
108
|
+
const filePath = path_1.default.join(conf.path, componentName, pkg.oc.files.env);
|
|
109
|
+
return dotenv_1.default.parse(fs_extra_1.default.readFileSync(filePath).toString());
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const repository = {
|
|
113
|
+
getCompiledView(componentName, componentVersion) {
|
|
114
|
+
if (conf.local) {
|
|
115
|
+
return Promise.resolve(local.getCompiledView(componentName));
|
|
116
|
+
}
|
|
117
|
+
return cdn.getFile(getFilePath(componentName, componentVersion, 'template.js'));
|
|
118
|
+
},
|
|
119
|
+
async getComponent(componentName, componentVersion) {
|
|
120
|
+
const allVersions = await repository.getComponentVersions(componentName);
|
|
121
|
+
if (allVersions.length === 0) {
|
|
122
|
+
throw resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource);
|
|
123
|
+
}
|
|
124
|
+
const version = versionHandler.getAvailableVersion(componentVersion, allVersions);
|
|
125
|
+
if (!version) {
|
|
126
|
+
throw resources_1.default.errors.registry.COMPONENT_VERSION_NOT_FOUND(componentName, componentVersion || '', repositorySource);
|
|
127
|
+
}
|
|
128
|
+
const component = await repository
|
|
129
|
+
.getComponentInfo(componentName, version)
|
|
130
|
+
.catch(err => {
|
|
131
|
+
throw `component not available: ${(0, error_to_string_1.default)(err)}`;
|
|
132
|
+
});
|
|
133
|
+
return Object.assign(component, { allVersions });
|
|
134
|
+
},
|
|
135
|
+
getComponentInfo(componentName, componentVersion) {
|
|
136
|
+
if (conf.local) {
|
|
137
|
+
let componentInfo;
|
|
138
|
+
if (componentName === 'oc-client') {
|
|
139
|
+
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '../../components/oc-client/_package/package.json'));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(conf.path, `${componentName}/_package/package.json`));
|
|
143
|
+
}
|
|
144
|
+
if (componentInfo.version === componentVersion) {
|
|
145
|
+
return Promise.resolve(componentInfo);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
149
|
+
return Promise.reject('version not available');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return cdn.getJson(getFilePath(componentName, componentVersion, 'package.json'), false);
|
|
153
|
+
},
|
|
154
|
+
getComponentPath(componentName, componentVersion) {
|
|
155
|
+
const prefix = conf.local
|
|
156
|
+
? conf.baseUrl
|
|
157
|
+
: `${options['path']}${options.componentsDir}/`;
|
|
158
|
+
return `${prefix}${componentName}/${componentVersion}/`;
|
|
159
|
+
},
|
|
160
|
+
async getComponents() {
|
|
161
|
+
if (conf.local) {
|
|
162
|
+
return local.getComponents();
|
|
163
|
+
}
|
|
164
|
+
const { components } = await componentsCache.get();
|
|
165
|
+
return Object.keys(components);
|
|
166
|
+
},
|
|
167
|
+
getComponentsDetails() {
|
|
168
|
+
if (conf.local) {
|
|
169
|
+
// when in local this won't get called
|
|
170
|
+
return Promise.resolve(null);
|
|
171
|
+
}
|
|
172
|
+
return componentsDetails.get();
|
|
173
|
+
},
|
|
174
|
+
async getComponentVersions(componentName) {
|
|
175
|
+
if (conf.local) {
|
|
176
|
+
return local.getComponentVersions(componentName);
|
|
177
|
+
}
|
|
178
|
+
const res = await componentsCache.get();
|
|
179
|
+
return res.components[componentName] ? res.components[componentName] : [];
|
|
180
|
+
},
|
|
181
|
+
async getDataProvider(componentName, componentVersion) {
|
|
182
|
+
if (conf.local) {
|
|
183
|
+
return local.getDataProvider(componentName);
|
|
184
|
+
}
|
|
185
|
+
const filePath = getFilePath(componentName, componentVersion, 'server.js');
|
|
186
|
+
const content = await cdn.getFile(filePath);
|
|
187
|
+
return { content, filePath };
|
|
188
|
+
},
|
|
189
|
+
async getEnv(componentName, componentVersion) {
|
|
190
|
+
if (conf.local) {
|
|
191
|
+
return local.getEnv(componentName);
|
|
192
|
+
}
|
|
193
|
+
const filePath = getFilePath(componentName, componentVersion, '.env');
|
|
194
|
+
const file = await cdn.getFile(filePath);
|
|
195
|
+
return dotenv_1.default.parse(file);
|
|
196
|
+
},
|
|
197
|
+
getStaticClientPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.js')}`,
|
|
198
|
+
getStaticClientMapPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.map')}`,
|
|
199
|
+
getStaticFilePath: (componentName, componentVersion, filePath) => `${repository.getComponentPath(componentName, componentVersion)}${conf.local ? settings_1.default.registry.localStaticRedirectorPath : ''}${filePath}`,
|
|
200
|
+
getTemplatesInfo: () => templatesInfo,
|
|
201
|
+
getTemplate: (type) => templatesHash[type],
|
|
202
|
+
async init() {
|
|
203
|
+
if (conf.local) {
|
|
204
|
+
// when in local this won't get called
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const componentsList = await componentsCache.load();
|
|
208
|
+
return componentsDetails.refresh(componentsList);
|
|
209
|
+
},
|
|
210
|
+
async publishComponent(pkgDetails, componentName, componentVersion) {
|
|
211
|
+
if (conf.local) {
|
|
212
|
+
throw {
|
|
213
|
+
code: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED_CODE,
|
|
214
|
+
msg: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
if (!validator.validateComponentName(componentName)) {
|
|
218
|
+
throw {
|
|
219
|
+
code: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID_CODE,
|
|
220
|
+
msg: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
if (!validator.validateVersion(componentVersion)) {
|
|
224
|
+
throw {
|
|
225
|
+
code: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID_CODE,
|
|
226
|
+
msg: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID(componentVersion)
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
const validationResult = validator.validatePackageJson(Object.assign(pkgDetails, {
|
|
230
|
+
componentName,
|
|
231
|
+
customValidator: conf.publishValidation
|
|
232
|
+
}));
|
|
233
|
+
if (!validationResult.isValid) {
|
|
234
|
+
throw {
|
|
235
|
+
code: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL_CODE,
|
|
236
|
+
msg: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL(String(validationResult.error))
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const componentVersions = await repository.getComponentVersions(componentName);
|
|
240
|
+
if (!versionHandler.validateNewVersion(componentVersion, componentVersions)) {
|
|
241
|
+
throw {
|
|
242
|
+
code: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND_CODE,
|
|
243
|
+
msg: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND(componentName, componentVersion, repositorySource)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
pkgDetails.packageJson.oc.date = (0, oc_get_unix_utc_timestamp_1.default)();
|
|
247
|
+
await fs_extra_1.default.writeJson(path_1.default.join(pkgDetails.outputFolder, 'package.json'), pkgDetails.packageJson);
|
|
248
|
+
await cdn.putDir(pkgDetails.outputFolder, `${options.componentsDir}/${componentName}/${componentVersion}`);
|
|
249
|
+
const componentsList = await componentsCache.refresh();
|
|
250
|
+
return componentsDetails.refresh(componentsList);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
return repository;
|
|
254
|
+
}
|
|
255
|
+
exports.default = repository;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (injectedDependencies: string[]) => <T = unknown>(requirePath: string) => T;
|
|
2
|
-
export default _default;
|
|
1
|
+
declare const _default: (injectedDependencies: string[]) => <T = unknown>(requirePath: string) => T;
|
|
2
|
+
export default _default;
|
|
@@ -1,33 +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 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
|
+
"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>;
|