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,78 +1,78 @@
|
|
|
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 async_1 = __importDefault(require("async"));
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const get_component_1 = __importDefault(require("./helpers/get-component"));
|
|
9
|
-
const resources_1 = __importDefault(require("../../resources"));
|
|
10
|
-
function components(conf, repository) {
|
|
11
|
-
const getComponent = (0, get_component_1.default)(conf, repository);
|
|
12
|
-
const setHeaders = (results, res) => {
|
|
13
|
-
if (!results || results.length !== 1 || !results[0] || !res.set) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
res.set(results[0].headers);
|
|
17
|
-
};
|
|
18
|
-
return (req, res) => {
|
|
19
|
-
const components = req.body.components;
|
|
20
|
-
const registryErrors = resources_1.default.errors.registry;
|
|
21
|
-
const returnError = function (message) {
|
|
22
|
-
res.status(400).json({
|
|
23
|
-
code: registryErrors.BATCH_ROUTE_BODY_NOT_VALID_CODE,
|
|
24
|
-
error: registryErrors.BATCH_ROUTE_BODY_NOT_VALID(message)
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
if (!components) {
|
|
28
|
-
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_PROPERTY_MISSING);
|
|
29
|
-
}
|
|
30
|
-
else if (!Array.isArray(components)) {
|
|
31
|
-
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_NOT_ARRAY);
|
|
32
|
-
}
|
|
33
|
-
if (!lodash_1.default.isEmpty(components)) {
|
|
34
|
-
const errors = lodash_1.default.compact(
|
|
35
|
-
return !component.name
|
|
36
|
-
? registryErrors.BATCH_ROUTE_COMPONENT_NAME_MISSING(index)
|
|
37
|
-
: '';
|
|
38
|
-
}));
|
|
39
|
-
if (!lodash_1.default.isEmpty(errors)) {
|
|
40
|
-
return returnError(errors.join(', '));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async_1.default.map(components, (component, callback) => {
|
|
44
|
-
getComponent({
|
|
45
|
-
conf: res.conf,
|
|
46
|
-
name: component.name,
|
|
47
|
-
headers: req.headers,
|
|
48
|
-
ip: req.ip,
|
|
49
|
-
omitHref: !!req.body.omitHref,
|
|
50
|
-
parameters: { ...req.body.parameters, ...component.parameters },
|
|
51
|
-
version: component.version
|
|
52
|
-
}, result => callback(null, result));
|
|
53
|
-
},
|
|
54
|
-
// @ts-ignore
|
|
55
|
-
(err, results) => {
|
|
56
|
-
try {
|
|
57
|
-
setHeaders(results, res);
|
|
58
|
-
res.status(200).json(results);
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
// @ts-ignore I think this will never reach (how can setHeaders throw?)
|
|
62
|
-
if (results.code && results.error) {
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
res.status(500).json({ code: results.code, error: results.error });
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
res.status(500).json({
|
|
68
|
-
code: 'RENDER_ERROR',
|
|
69
|
-
error: resources_1.default.errors.registry.RENDER_ERROR(results
|
|
70
|
-
.map(x => `${x.response.name}@${x.response.version}`)
|
|
71
|
-
.join(', '), String(e))
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
exports.default = components;
|
|
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 async_1 = __importDefault(require("async"));
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const get_component_1 = __importDefault(require("./helpers/get-component"));
|
|
9
|
+
const resources_1 = __importDefault(require("../../resources"));
|
|
10
|
+
function components(conf, repository) {
|
|
11
|
+
const getComponent = (0, get_component_1.default)(conf, repository);
|
|
12
|
+
const setHeaders = (results, res) => {
|
|
13
|
+
if (!results || results.length !== 1 || !results[0] || !res.set) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
res.set(results[0].headers);
|
|
17
|
+
};
|
|
18
|
+
return (req, res) => {
|
|
19
|
+
const components = req.body.components;
|
|
20
|
+
const registryErrors = resources_1.default.errors.registry;
|
|
21
|
+
const returnError = function (message) {
|
|
22
|
+
res.status(400).json({
|
|
23
|
+
code: registryErrors.BATCH_ROUTE_BODY_NOT_VALID_CODE,
|
|
24
|
+
error: registryErrors.BATCH_ROUTE_BODY_NOT_VALID(message)
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
if (!components) {
|
|
28
|
+
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_PROPERTY_MISSING);
|
|
29
|
+
}
|
|
30
|
+
else if (!Array.isArray(components)) {
|
|
31
|
+
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_NOT_ARRAY);
|
|
32
|
+
}
|
|
33
|
+
if (!lodash_1.default.isEmpty(components)) {
|
|
34
|
+
const errors = lodash_1.default.compact(components.map((component, index) => {
|
|
35
|
+
return !component.name
|
|
36
|
+
? registryErrors.BATCH_ROUTE_COMPONENT_NAME_MISSING(index)
|
|
37
|
+
: '';
|
|
38
|
+
}));
|
|
39
|
+
if (!lodash_1.default.isEmpty(errors)) {
|
|
40
|
+
return returnError(errors.join(', '));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async_1.default.map(components, (component, callback) => {
|
|
44
|
+
getComponent({
|
|
45
|
+
conf: res.conf,
|
|
46
|
+
name: component.name,
|
|
47
|
+
headers: req.headers,
|
|
48
|
+
ip: req.ip,
|
|
49
|
+
omitHref: !!req.body.omitHref,
|
|
50
|
+
parameters: { ...req.body.parameters, ...component.parameters },
|
|
51
|
+
version: component.version
|
|
52
|
+
}, result => callback(null, result));
|
|
53
|
+
},
|
|
54
|
+
// @ts-ignore
|
|
55
|
+
(err, results) => {
|
|
56
|
+
try {
|
|
57
|
+
setHeaders(results, res);
|
|
58
|
+
res.status(200).json(results);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
// @ts-ignore I think this will never reach (how can setHeaders throw?)
|
|
62
|
+
if (results.code && results.error) {
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
res.status(500).json({ code: results.code, error: results.error });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
res.status(500).json({
|
|
68
|
+
code: 'RENDER_ERROR',
|
|
69
|
+
error: resources_1.default.errors.registry.RENDER_ERROR(results
|
|
70
|
+
.map(x => `${x.response.name}@${x.response.version}`)
|
|
71
|
+
.join(', '), String(e))
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
exports.default = components;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { Config } from '../../types';
|
|
3
|
-
export default function dependencies(conf: Config): (_req: Request, res: Response) => void;
|
|
1
|
+
import { Request, Response } from 'express';
|
|
2
|
+
import { Config } from '../../types';
|
|
3
|
+
export default function dependencies(conf: Config): (_req: Request, res: Response) => void;
|
|
@@ -1,28 +1,28 @@
|
|
|
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 get_available_dependencies_1 = __importDefault(require("./helpers/get-available-dependencies"));
|
|
7
|
-
function dependencies(conf) {
|
|
8
|
-
return function (_req, res) {
|
|
9
|
-
if (res.conf.discovery) {
|
|
10
|
-
const dependencies = (0, get_available_dependencies_1.default)(conf.dependencies).map(({ core, name, version }) => {
|
|
11
|
-
const dep = {
|
|
12
|
-
name,
|
|
13
|
-
core
|
|
14
|
-
};
|
|
15
|
-
if (!core && version) {
|
|
16
|
-
// In the future this could be multiple versions
|
|
17
|
-
dep.versions = [version];
|
|
18
|
-
}
|
|
19
|
-
return dep;
|
|
20
|
-
});
|
|
21
|
-
res.status(200).json(dependencies);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
res.status(401);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
exports.default = dependencies;
|
|
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 get_available_dependencies_1 = __importDefault(require("./helpers/get-available-dependencies"));
|
|
7
|
+
function dependencies(conf) {
|
|
8
|
+
return function (_req, res) {
|
|
9
|
+
if (res.conf.discovery) {
|
|
10
|
+
const dependencies = (0, get_available_dependencies_1.default)(conf.dependencies).map(({ core, name, version }) => {
|
|
11
|
+
const dep = {
|
|
12
|
+
name,
|
|
13
|
+
core
|
|
14
|
+
};
|
|
15
|
+
if (!core && version) {
|
|
16
|
+
// In the future this could be multiple versions
|
|
17
|
+
dep.versions = [version];
|
|
18
|
+
}
|
|
19
|
+
return dep;
|
|
20
|
+
});
|
|
21
|
+
res.status(200).json(dependencies);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
res.status(401);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.default = dependencies;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { OcParameter } from '../../../types';
|
|
2
|
-
export default function applyDefaultValues(requestParameters?: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
1
|
+
import { OcParameter } from '../../../types';
|
|
2
|
+
export default function applyDefaultValues(requestParameters?: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function applyDefaultValues(requestParameters = {}, expectedParameters = {}) {
|
|
4
|
-
const optionalParametersWithDefaults = Object.entries(expectedParameters).filter((params) => !params[1].mandatory && typeof params[1].default !== 'undefined');
|
|
5
|
-
optionalParametersWithDefaults.forEach(([expectedParameterName, expectedParameter]) => {
|
|
6
|
-
const param = requestParameters[expectedParameterName];
|
|
7
|
-
if (param === null || param === undefined) {
|
|
8
|
-
requestParameters[expectedParameterName] = expectedParameter.default;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
return requestParameters;
|
|
12
|
-
}
|
|
13
|
-
exports.default = applyDefaultValues;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function applyDefaultValues(requestParameters = {}, expectedParameters = {}) {
|
|
4
|
+
const optionalParametersWithDefaults = Object.entries(expectedParameters).filter((params) => !params[1].mandatory && typeof params[1].default !== 'undefined');
|
|
5
|
+
optionalParametersWithDefaults.forEach(([expectedParameterName, expectedParameter]) => {
|
|
6
|
+
const param = requestParameters[expectedParameterName];
|
|
7
|
+
if (param === null || param === undefined) {
|
|
8
|
+
requestParameters[expectedParameterName] = expectedParameter.default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
return requestParameters;
|
|
12
|
+
}
|
|
13
|
+
exports.default = applyDefaultValues;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
interface AvailableDependency {
|
|
2
|
-
core: boolean;
|
|
3
|
-
name: string;
|
|
4
|
-
version?: string;
|
|
5
|
-
link: string;
|
|
6
|
-
}
|
|
7
|
-
export default function getAvailableDependencies(dependencies: string[]): AvailableDependency[];
|
|
8
|
-
export {};
|
|
1
|
+
interface AvailableDependency {
|
|
2
|
+
core: boolean;
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
link: string;
|
|
6
|
+
}
|
|
7
|
+
export default function getAvailableDependencies(dependencies: string[]): AvailableDependency[];
|
|
8
|
+
export {};
|
|
@@ -1,24 +1,24 @@
|
|
|
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 lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const require_wrapper_1 = __importDefault(require("../../domain/require-wrapper"));
|
|
9
|
-
function getAvailableDependencies(dependencies) {
|
|
10
|
-
return lodash_1.default.map(dependencies, dependency => {
|
|
11
|
-
var _a;
|
|
12
|
-
const requirer = (0, require_wrapper_1.default)(dependencies);
|
|
13
|
-
const core = lodash_1.default.includes(builtin_modules_1.default, dependency);
|
|
14
|
-
const packageJson = !core
|
|
15
|
-
? requirer(`${dependency}/package.json`)
|
|
16
|
-
: undefined;
|
|
17
|
-
const version = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version;
|
|
18
|
-
const link = core
|
|
19
|
-
? `https://nodejs.org/api/${dependency}.html`
|
|
20
|
-
: (_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.homepage) !== null && _a !== void 0 ? _a : '';
|
|
21
|
-
return { core, name: dependency, version, link };
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.default = getAvailableDependencies;
|
|
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 lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const require_wrapper_1 = __importDefault(require("../../domain/require-wrapper"));
|
|
9
|
+
function getAvailableDependencies(dependencies) {
|
|
10
|
+
return lodash_1.default.map(dependencies, dependency => {
|
|
11
|
+
var _a;
|
|
12
|
+
const requirer = (0, require_wrapper_1.default)(dependencies);
|
|
13
|
+
const core = lodash_1.default.includes(builtin_modules_1.default, dependency);
|
|
14
|
+
const packageJson = !core
|
|
15
|
+
? requirer(`${dependency}/package.json`)
|
|
16
|
+
: undefined;
|
|
17
|
+
const version = packageJson === null || packageJson === void 0 ? void 0 : packageJson.version;
|
|
18
|
+
const link = core
|
|
19
|
+
? `https://nodejs.org/api/${dependency}.html`
|
|
20
|
+
: (_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.homepage) !== null && _a !== void 0 ? _a : '';
|
|
21
|
+
return { core, name: dependency, version, link };
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.default = getAvailableDependencies;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Request, Response } from 'express';
|
|
3
|
-
import { IncomingHttpHeaders } from 'http';
|
|
4
|
-
import { Component, Config } from '../../../types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
} | Component) => void): void;
|
|
20
|
-
export declare function getComponentPreview(conf: Config, req: Request, res: Response, registryError: string | null, callback: ComponentCallback): void;
|
|
21
|
-
export declare function getComponentInfo(conf: Config, req: Request, res: Response, registryError: string | null, callback: ComponentCallback): void;
|
|
22
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { IncomingHttpHeaders } from 'http';
|
|
4
|
+
import { Component, Config } from '../../../types';
|
|
5
|
+
import { GetComponentResult } from './get-component';
|
|
6
|
+
declare type ComponentCallback = (err: {
|
|
7
|
+
registryError: any;
|
|
8
|
+
fallbackError: any;
|
|
9
|
+
} | null, data: Component) => void;
|
|
10
|
+
export declare function getComponent(fallbackRegistryUrl: string, headers: IncomingHttpHeaders, component: {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
parameters: IncomingHttpHeaders;
|
|
14
|
+
}, callback: (result: GetComponentResult) => void): void;
|
|
15
|
+
export declare function getComponentPreview(conf: Config, req: Request, res: Response, registryError: string | null, callback: ComponentCallback): void;
|
|
16
|
+
export declare function getComponentInfo(conf: Config, req: Request, res: Response, registryError: string | null, callback: ComponentCallback): void;
|
|
17
|
+
export {};
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.getComponentInfo = exports.getComponentPreview = exports.getComponent = void 0;
|
|
26
|
-
const minimal_request_1 = __importDefault(require("minimal-request"));
|
|
27
|
-
const url_1 = __importDefault(require("url"));
|
|
28
|
-
const urlBuilder = __importStar(require("../../domain/url-builder"));
|
|
29
|
-
function getComponentFallbackForViewType(buildUrl, conf, req, res, registryError, callback) {
|
|
30
|
-
const path = buildUrl({
|
|
31
|
-
name: req.params['componentName'],
|
|
32
|
-
version: req.params['componentVersion']
|
|
33
|
-
}, conf.fallbackRegistryUrl);
|
|
34
|
-
return (0, minimal_request_1.default)({
|
|
35
|
-
method: 'get',
|
|
36
|
-
url: path,
|
|
37
|
-
headers: {
|
|
38
|
-
...req.headers,
|
|
39
|
-
host: url_1.default.parse(conf.fallbackRegistryUrl).host,
|
|
40
|
-
accept: 'application/json'
|
|
41
|
-
}
|
|
42
|
-
}, (fallbackErr, fallbackResponse) => {
|
|
43
|
-
if (fallbackErr === 304) {
|
|
44
|
-
return res.status(304).send('');
|
|
45
|
-
}
|
|
46
|
-
if (fallbackErr) {
|
|
47
|
-
return callback({
|
|
48
|
-
registryError: registryError,
|
|
49
|
-
fallbackError: fallbackErr
|
|
50
|
-
}, undefined);
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
return callback(null, JSON.parse(fallbackResponse));
|
|
54
|
-
}
|
|
55
|
-
catch (parseError) {
|
|
56
|
-
return callback({
|
|
57
|
-
registryError: registryError,
|
|
58
|
-
fallbackError: `Could not parse fallback response: ${fallbackResponse}`
|
|
59
|
-
}, undefined);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function getComponent(fallbackRegistryUrl, headers, component, callback) {
|
|
64
|
-
return (0, minimal_request_1.default)({
|
|
65
|
-
method: 'post',
|
|
66
|
-
url: fallbackRegistryUrl,
|
|
67
|
-
headers: { ...headers, host: url_1.default.parse(fallbackRegistryUrl).host },
|
|
68
|
-
json: true,
|
|
69
|
-
body: { components: [component] }
|
|
70
|
-
}, (err, res) => {
|
|
71
|
-
if (err || !res || res.length === 0) {
|
|
72
|
-
return callback({
|
|
73
|
-
status: 404,
|
|
74
|
-
response: {
|
|
75
|
-
code: 'NOT_FOUND',
|
|
76
|
-
error: err
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
return callback(res[0]);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.getComponent = getComponent;
|
|
84
|
-
function getComponentPreview(conf, req, res, registryError, callback) {
|
|
85
|
-
getComponentFallbackForViewType(urlBuilder.componentPreview, conf, req, res, registryError, callback);
|
|
86
|
-
}
|
|
87
|
-
exports.getComponentPreview = getComponentPreview;
|
|
88
|
-
function getComponentInfo(conf, req, res, registryError, callback) {
|
|
89
|
-
getComponentFallbackForViewType(urlBuilder.componentInfo, conf, req, res, registryError, callback);
|
|
90
|
-
}
|
|
91
|
-
exports.getComponentInfo = getComponentInfo;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.getComponentInfo = exports.getComponentPreview = exports.getComponent = void 0;
|
|
26
|
+
const minimal_request_1 = __importDefault(require("minimal-request"));
|
|
27
|
+
const url_1 = __importDefault(require("url"));
|
|
28
|
+
const urlBuilder = __importStar(require("../../domain/url-builder"));
|
|
29
|
+
function getComponentFallbackForViewType(buildUrl, conf, req, res, registryError, callback) {
|
|
30
|
+
const path = buildUrl({
|
|
31
|
+
name: req.params['componentName'],
|
|
32
|
+
version: req.params['componentVersion']
|
|
33
|
+
}, conf.fallbackRegistryUrl);
|
|
34
|
+
return (0, minimal_request_1.default)({
|
|
35
|
+
method: 'get',
|
|
36
|
+
url: path,
|
|
37
|
+
headers: {
|
|
38
|
+
...req.headers,
|
|
39
|
+
host: url_1.default.parse(conf.fallbackRegistryUrl).host,
|
|
40
|
+
accept: 'application/json'
|
|
41
|
+
}
|
|
42
|
+
}, (fallbackErr, fallbackResponse) => {
|
|
43
|
+
if (fallbackErr === 304) {
|
|
44
|
+
return res.status(304).send('');
|
|
45
|
+
}
|
|
46
|
+
if (fallbackErr) {
|
|
47
|
+
return callback({
|
|
48
|
+
registryError: registryError,
|
|
49
|
+
fallbackError: fallbackErr
|
|
50
|
+
}, undefined);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
return callback(null, JSON.parse(fallbackResponse));
|
|
54
|
+
}
|
|
55
|
+
catch (parseError) {
|
|
56
|
+
return callback({
|
|
57
|
+
registryError: registryError,
|
|
58
|
+
fallbackError: `Could not parse fallback response: ${fallbackResponse}`
|
|
59
|
+
}, undefined);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function getComponent(fallbackRegistryUrl, headers, component, callback) {
|
|
64
|
+
return (0, minimal_request_1.default)({
|
|
65
|
+
method: 'post',
|
|
66
|
+
url: fallbackRegistryUrl,
|
|
67
|
+
headers: { ...headers, host: url_1.default.parse(fallbackRegistryUrl).host },
|
|
68
|
+
json: true,
|
|
69
|
+
body: { components: [component] }
|
|
70
|
+
}, (err, res) => {
|
|
71
|
+
if (err || !res || res.length === 0) {
|
|
72
|
+
return callback({
|
|
73
|
+
status: 404,
|
|
74
|
+
response: {
|
|
75
|
+
code: 'NOT_FOUND',
|
|
76
|
+
error: err
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return callback(res[0]);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.getComponent = getComponent;
|
|
84
|
+
function getComponentPreview(conf, req, res, registryError, callback) {
|
|
85
|
+
getComponentFallbackForViewType(urlBuilder.componentPreview, conf, req, res, registryError, callback);
|
|
86
|
+
}
|
|
87
|
+
exports.getComponentPreview = getComponentPreview;
|
|
88
|
+
function getComponentInfo(conf, req, res, registryError, callback) {
|
|
89
|
+
getComponentFallbackForViewType(urlBuilder.componentInfo, conf, req, res, registryError, callback);
|
|
90
|
+
}
|
|
91
|
+
exports.getComponentInfo = getComponentInfo;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingHttpHeaders } from 'http';
|
|
3
|
-
interface Options {
|
|
4
|
-
headers: IncomingHttpHeaders;
|
|
5
|
-
name: string;
|
|
6
|
-
parameters: IncomingHttpHeaders;
|
|
7
|
-
version: string;
|
|
8
|
-
}
|
|
9
|
-
interface EventData {
|
|
10
|
-
headers: IncomingHttpHeaders;
|
|
11
|
-
name: string;
|
|
12
|
-
parameters: IncomingHttpHeaders;
|
|
13
|
-
requestVersion: string;
|
|
14
|
-
duration: number;
|
|
15
|
-
}
|
|
16
|
-
export default function getComponentRetrievingInfo(options: Options): {
|
|
17
|
-
extend(obj: unknown): void;
|
|
18
|
-
getData(): EventData;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingHttpHeaders } from 'http';
|
|
3
|
+
interface Options {
|
|
4
|
+
headers: IncomingHttpHeaders;
|
|
5
|
+
name: string;
|
|
6
|
+
parameters: IncomingHttpHeaders;
|
|
7
|
+
version: string;
|
|
8
|
+
}
|
|
9
|
+
interface EventData {
|
|
10
|
+
headers: IncomingHttpHeaders;
|
|
11
|
+
name: string;
|
|
12
|
+
parameters: IncomingHttpHeaders;
|
|
13
|
+
requestVersion: string;
|
|
14
|
+
duration: number;
|
|
15
|
+
}
|
|
16
|
+
export default function getComponentRetrievingInfo(options: Options): {
|
|
17
|
+
extend(obj: unknown): void;
|
|
18
|
+
getData(): EventData;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function getComponentRetrievingInfo(options) {
|
|
4
|
-
const eventData = {
|
|
5
|
-
headers: options.headers,
|
|
6
|
-
name: options.name,
|
|
7
|
-
parameters: options.parameters,
|
|
8
|
-
requestVersion: options.version || '',
|
|
9
|
-
duration: 0
|
|
10
|
-
};
|
|
11
|
-
const start = process.hrtime();
|
|
12
|
-
return {
|
|
13
|
-
extend(obj) {
|
|
14
|
-
Object.assign(eventData, obj);
|
|
15
|
-
},
|
|
16
|
-
getData() {
|
|
17
|
-
const delta = process.hrtime(start);
|
|
18
|
-
const nanosec = delta[0] * 1e9 + delta[1];
|
|
19
|
-
eventData.duration = nanosec / 1e3;
|
|
20
|
-
return eventData;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.default = getComponentRetrievingInfo;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function getComponentRetrievingInfo(options) {
|
|
4
|
+
const eventData = {
|
|
5
|
+
headers: options.headers,
|
|
6
|
+
name: options.name,
|
|
7
|
+
parameters: options.parameters,
|
|
8
|
+
requestVersion: options.version || '',
|
|
9
|
+
duration: 0
|
|
10
|
+
};
|
|
11
|
+
const start = process.hrtime();
|
|
12
|
+
return {
|
|
13
|
+
extend(obj) {
|
|
14
|
+
Object.assign(eventData, obj);
|
|
15
|
+
},
|
|
16
|
+
getData() {
|
|
17
|
+
const delta = process.hrtime(start);
|
|
18
|
+
const nanosec = delta[0] * 1e9 + delta[1];
|
|
19
|
+
eventData.duration = nanosec / 1e3;
|
|
20
|
+
return eventData;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.default = getComponentRetrievingInfo;
|