oc 0.49.3 → 0.49.7
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/.github/workflows/node.js.yml +1 -1
- package/CHANGELOG.md +25 -0
- package/dist/cli/commands.d.ts +8 -0
- package/dist/cli/commands.js +8 -0
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +10 -1
- package/dist/cli/domain/get-mocked-plugins.js +1 -1
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +3 -2
- package/dist/cli/domain/handle-dependencies/index.d.ts +2 -2
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +2 -1
- package/dist/cli/domain/handle-dependencies/install-compiler.js +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +6 -3
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/require-template.d.ts +1 -1
- package/dist/cli/domain/init-template/index.d.ts +2 -2
- package/dist/cli/domain/init-template/install-template.d.ts +2 -2
- package/dist/cli/domain/init-template/scaffold.d.ts +2 -2
- package/dist/cli/domain/mock.js +1 -1
- package/dist/cli/domain/package-components.d.ts +1 -1
- package/dist/cli/domain/registry.js +2 -2
- package/dist/cli/facade/dev.d.ts +2 -1
- package/dist/cli/facade/dev.js +8 -8
- package/dist/cli/facade/init.d.ts +1 -1
- package/dist/cli/facade/package.d.ts +1 -1
- package/dist/cli/facade/preview.d.ts +1 -1
- package/dist/cli/facade/publish.d.ts +1 -0
- package/dist/cli/facade/publish.js +10 -5
- package/dist/cli/facade/registry-add.d.ts +1 -1
- package/dist/cli/facade/registry-ls.d.ts +1 -1
- package/dist/cli/facade/registry-ls.js +1 -1
- package/dist/cli/facade/registry-remove.d.ts +1 -1
- package/dist/cli/facade/registry.d.ts +1 -1
- package/dist/cli/facade/registry.js +1 -1
- package/dist/cli/logger.d.ts +4 -4
- package/dist/cli/logger.js +5 -5
- package/dist/cli/programmatic-api.d.ts +2 -0
- 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 +1 -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/registry/app-start.d.ts +1 -1
- package/dist/registry/app-start.js +1 -1
- package/dist/registry/domain/authentication.d.ts +2 -3
- package/dist/registry/domain/authentication.js +4 -4
- package/dist/registry/domain/components-cache/components-list.d.ts +4 -4
- package/dist/registry/domain/components-cache/index.d.ts +3 -3
- package/dist/registry/domain/components-cache/index.js +4 -23
- package/dist/registry/domain/components-details.d.ts +2 -2
- package/dist/registry/domain/components-details.js +6 -21
- package/dist/registry/domain/events-handler.d.ts +39 -5
- package/dist/registry/domain/events-handler.js +29 -31
- package/dist/registry/domain/extract-package.d.ts +2 -2
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +1 -1
- package/dist/registry/domain/nested-renderer.d.ts +3 -3
- package/dist/registry/domain/options-sanitiser.js +15 -15
- package/dist/registry/domain/plugins-initialiser.d.ts +1 -1
- package/dist/registry/domain/plugins-initialiser.js +3 -3
- package/dist/registry/domain/register-templates.d.ts +1 -1
- package/dist/registry/domain/repository.js +18 -17
- package/dist/registry/domain/sanitiser.d.ts +1 -1
- package/dist/registry/domain/url-builder.d.ts +2 -2
- package/dist/registry/domain/validators/component-parameters.d.ts +3 -3
- package/dist/registry/domain/validators/registry-configuration.js +4 -4
- package/dist/registry/index.d.ts +33 -4
- package/dist/registry/index.js +10 -6
- package/dist/registry/middleware/cors.d.ts +1 -1
- package/dist/registry/middleware/cors.js +1 -1
- package/dist/registry/middleware/file-uploads.js +1 -1
- package/dist/registry/middleware/index.js +1 -1
- package/dist/registry/middleware/request-handler.js +2 -21
- package/dist/registry/router.js +1 -1
- package/dist/registry/routes/component-info.js +5 -4
- package/dist/registry/routes/component-preview.js +5 -4
- package/dist/registry/routes/component.js +2 -2
- package/dist/registry/routes/components.js +6 -6
- package/dist/registry/routes/dependencies.d.ts +1 -1
- package/dist/registry/routes/dependencies.js +1 -1
- package/dist/registry/routes/helpers/apply-default-values.d.ts +1 -1
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +2 -2
- package/dist/registry/routes/helpers/get-component-fallback.js +2 -2
- package/dist/registry/routes/helpers/get-component.d.ts +2 -2
- package/dist/registry/routes/helpers/get-component.js +9 -9
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +2 -2
- package/dist/registry/routes/helpers/is-url-discoverable.js +1 -1
- package/dist/registry/routes/index.js +3 -2
- package/dist/registry/routes/plugins.d.ts +1 -1
- package/dist/registry/routes/plugins.js +1 -1
- package/dist/registry/routes/publish.js +5 -6
- package/dist/registry/routes/static-redirector.js +4 -4
- package/dist/registry/views/info.js +5 -2
- package/dist/registry/views/static/info.d.ts +1 -1
- package/dist/registry/views/static/info.js +12 -1
- package/dist/resources/index.d.ts +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/types.d.ts +52 -41
- package/dist/utils/clean-require.d.ts +16 -4
- package/dist/utils/date-stringify.js +8 -9
- package/dist/utils/npm-utils.d.ts +4 -4
- package/dist/utils/put.d.ts +1 -1
- package/logintervals.md +1 -1
- package/package.json +34 -35
- package/src/cli/commands.ts +10 -0
- package/src/cli/domain/clean.ts +12 -4
- package/src/cli/domain/get-components-by-dir.ts +21 -1
- package/src/cli/domain/get-mocked-plugins.ts +4 -4
- package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +1 -1
- package/src/cli/domain/handle-dependencies/get-compiler.ts +4 -3
- package/src/cli/domain/handle-dependencies/index.ts +21 -17
- package/src/cli/domain/handle-dependencies/install-compiler.ts +5 -4
- package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +7 -4
- package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +1 -1
- package/src/cli/domain/handle-dependencies/require-template.ts +1 -1
- package/src/cli/domain/init-template/index.ts +1 -1
- package/src/cli/domain/init-template/install-template.ts +1 -1
- package/src/cli/domain/init-template/scaffold.ts +1 -1
- package/src/cli/domain/mock.ts +1 -1
- package/src/cli/domain/package-components.ts +4 -1
- package/src/cli/domain/registry.ts +8 -8
- package/src/cli/facade/dev.ts +100 -97
- package/src/cli/facade/init.ts +1 -1
- package/src/cli/facade/package.ts +1 -1
- package/src/cli/facade/preview.ts +1 -1
- package/src/cli/facade/publish.ts +25 -10
- package/src/cli/facade/registry-add.ts +4 -1
- package/src/cli/facade/registry-ls.ts +4 -1
- package/src/cli/facade/registry-remove.ts +4 -1
- package/src/cli/facade/registry.ts +1 -1
- package/src/cli/index.ts +1 -1
- package/src/cli/logger.ts +10 -10
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/_package/server.js +1 -1
- package/src/components/oc-client/_package/src/oc-client.min.js +2 -2
- package/src/components/oc-client/_package/src/oc-client.min.map +1 -1
- package/src/components/oc-client/_package/template.js +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/components/oc-client/src/oc-client.min.js +2 -2
- package/src/components/oc-client/src/oc-client.min.map +1 -1
- package/src/globals.d.ts +6 -12
- package/src/registry/app-start.ts +2 -2
- package/src/registry/domain/authentication.ts +6 -18
- package/src/registry/domain/components-cache/components-list.ts +11 -7
- package/src/registry/domain/components-cache/index.ts +5 -5
- package/src/registry/domain/components-details.ts +14 -8
- package/src/registry/domain/events-handler.ts +73 -27
- package/src/registry/domain/extract-package.ts +7 -4
- package/src/registry/domain/get-package-json-from-temp-dir.ts +1 -1
- package/src/registry/domain/nested-renderer.ts +3 -3
- package/src/registry/domain/options-sanitiser.ts +15 -15
- package/src/registry/domain/plugins-initialiser.ts +8 -5
- package/src/registry/domain/register-templates.ts +2 -2
- package/src/registry/domain/repository.ts +50 -40
- package/src/registry/domain/sanitiser.ts +4 -4
- package/src/registry/domain/url-builder.ts +2 -2
- package/src/registry/domain/validators/component-parameters.ts +4 -4
- package/src/registry/domain/validators/registry-configuration.ts +4 -4
- package/src/registry/index.ts +20 -10
- package/src/registry/middleware/cors.ts +1 -1
- package/src/registry/middleware/file-uploads.ts +1 -1
- package/src/registry/middleware/index.ts +1 -1
- package/src/registry/middleware/request-handler.ts +6 -21
- package/src/registry/router.ts +1 -1
- package/src/registry/routes/component-info.ts +7 -6
- package/src/registry/routes/component-preview.ts +6 -5
- package/src/registry/routes/component.ts +2 -2
- package/src/registry/routes/components.ts +7 -7
- package/src/registry/routes/dependencies.ts +1 -1
- package/src/registry/routes/helpers/apply-default-values.ts +3 -3
- package/src/registry/routes/helpers/get-component-fallback.ts +7 -7
- package/src/registry/routes/helpers/get-component.ts +16 -13
- package/src/registry/routes/helpers/is-url-discoverable.ts +2 -2
- package/src/registry/routes/index.ts +3 -2
- package/src/registry/routes/plugins.ts +1 -1
- package/src/registry/routes/publish.ts +6 -7
- package/src/registry/routes/static-redirector.ts +4 -4
- package/src/registry/views/info.ts +5 -2
- package/src/registry/views/static/info.ts +12 -1
- package/src/resources/index.ts +2 -2
- package/src/types.ts +85 -41
- package/src/utils/clean-require.ts +17 -1
- package/src/utils/date-stringify.ts +8 -6
- package/src/utils/npm-utils.ts +2 -2
- package/src/utils/put.ts +4 -2
- package/tsconfig.json +3 -3
- package/dist/utils/pad-zero.d.ts +0 -1
- package/dist/utils/pad-zero.js +0 -6
- package/src/utils/pad-zero.ts +0 -3
|
@@ -3,37 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.reset = exports.off = exports.on = exports.fire = void 0;
|
|
7
6
|
const resources_1 = __importDefault(require("../../resources"));
|
|
8
7
|
let subscriptions = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
subscriptions[eventName]
|
|
12
|
-
callback
|
|
13
|
-
|
|
8
|
+
const eventsHandler = {
|
|
9
|
+
fire(eventName, eventData) {
|
|
10
|
+
if (subscriptions[eventName]) {
|
|
11
|
+
subscriptions[eventName].forEach(callback => {
|
|
12
|
+
callback(eventData);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
on(eventName, callback) {
|
|
17
|
+
if (typeof callback !== 'function') {
|
|
18
|
+
throw resources_1.default.errors.registry.CONFIGURATION_ONREQUEST_MUST_BE_FUNCTION;
|
|
19
|
+
}
|
|
20
|
+
if (!subscriptions[eventName]) {
|
|
21
|
+
subscriptions[eventName] = [];
|
|
22
|
+
}
|
|
23
|
+
subscriptions[eventName].push(callback);
|
|
24
|
+
},
|
|
25
|
+
off(eventName, callback) {
|
|
26
|
+
if (typeof callback !== 'function') {
|
|
27
|
+
throw resources_1.default.errors.registry.CONFIGURATION_OFFREQUEST_MUST_BE_FUNCTION;
|
|
28
|
+
}
|
|
29
|
+
if (subscriptions[eventName]) {
|
|
30
|
+
subscriptions[eventName] = subscriptions[eventName].filter(sub => sub !== callback);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
reset() {
|
|
34
|
+
subscriptions = {};
|
|
14
35
|
}
|
|
15
|
-
}
|
|
16
|
-
exports.
|
|
17
|
-
function on(eventName, callback) {
|
|
18
|
-
if (typeof callback !== 'function') {
|
|
19
|
-
throw resources_1.default.errors.registry.CONFIGURATION_ONREQUEST_MUST_BE_FUNCTION;
|
|
20
|
-
}
|
|
21
|
-
if (!subscriptions[eventName]) {
|
|
22
|
-
subscriptions[eventName] = [];
|
|
23
|
-
}
|
|
24
|
-
subscriptions[eventName].push(callback);
|
|
25
|
-
}
|
|
26
|
-
exports.on = on;
|
|
27
|
-
function off(eventName, callback) {
|
|
28
|
-
if (typeof callback !== 'function') {
|
|
29
|
-
throw resources_1.default.errors.registry.CONFIGURATION_OFFREQUEST_MUST_BE_FUNCTION;
|
|
30
|
-
}
|
|
31
|
-
if (subscriptions[eventName]) {
|
|
32
|
-
subscriptions[eventName] = subscriptions[eventName].filter(sub => sub !== callback);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.off = off;
|
|
36
|
-
function reset() {
|
|
37
|
-
subscriptions = {};
|
|
38
|
-
}
|
|
39
|
-
exports.reset = reset;
|
|
36
|
+
};
|
|
37
|
+
exports.default = eventsHandler;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { PackageJson } from 'type-fest';
|
|
3
3
|
export default function extractPackage(files: Express.Multer.File[] | {
|
|
4
4
|
[fieldname: string]: Express.Multer.File[];
|
|
5
|
-
}, callback:
|
|
5
|
+
}, callback: (err: Error | null, data: {
|
|
6
6
|
outputFolder: string;
|
|
7
7
|
packageJson: PackageJson;
|
|
8
|
-
}
|
|
8
|
+
}) => void): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { PackageJson } from 'type-fest';
|
|
2
|
-
export default function getPackageJsonFromTempDir(tempDirPath: string, callback:
|
|
2
|
+
export default function getPackageJsonFromTempDir(tempDirPath: string, callback: (err: Error | null, data: PackageJson) => void): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Config } from '../../types';
|
|
2
|
-
declare type Cb =
|
|
2
|
+
declare type Cb = (err: string | null, data: string) => void;
|
|
3
3
|
declare type Options = {
|
|
4
4
|
version?: string;
|
|
5
5
|
name?: string;
|
|
6
|
-
headers?:
|
|
7
|
-
parameters?:
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
parameters?: Record<string, string>;
|
|
8
8
|
};
|
|
9
9
|
export default function nestedRenderer(renderer: any, conf: Config): {
|
|
10
10
|
renderComponent(componentName: string, renderOptions: Options | Cb, callback?: Cb | undefined): any;
|
|
@@ -29,7 +29,7 @@ const DEFAULT_NODE_KEEPALIVE_MS = 5000;
|
|
|
29
29
|
function optionsSanitiser(input) {
|
|
30
30
|
const options = lodash_1.default.clone(input);
|
|
31
31
|
if (!options.publishAuth) {
|
|
32
|
-
options.beforePublish = (
|
|
32
|
+
options.beforePublish = (_req, _res, next) => next();
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
35
|
options.beforePublish = auth.middleware(options.publishAuth);
|
|
@@ -49,27 +49,27 @@ function optionsSanitiser(input) {
|
|
|
49
49
|
if (!options.tempDir) {
|
|
50
50
|
options.tempDir = settings_1.default.registry.defaultTempPath;
|
|
51
51
|
}
|
|
52
|
-
if (
|
|
52
|
+
if (typeof options.hotReloading !== 'boolean') {
|
|
53
53
|
options.hotReloading = !!options.local;
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
55
|
+
if (!options.verbosity) {
|
|
56
56
|
options.verbosity = 0;
|
|
57
57
|
}
|
|
58
|
-
if (
|
|
58
|
+
if (typeof options.discovery === 'undefined') {
|
|
59
59
|
options.discovery = true;
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
61
|
+
if (typeof options.pollingInterval === 'undefined') {
|
|
62
62
|
options.pollingInterval = 5;
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
64
|
+
if (!options.templates) {
|
|
65
65
|
options.templates = [];
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
67
|
+
if (typeof options.fallbackRegistryUrl !== 'undefined' &&
|
|
68
68
|
lodash_1.default.last(options.fallbackRegistryUrl) !== '/') {
|
|
69
69
|
options.fallbackRegistryUrl += '/';
|
|
70
70
|
}
|
|
71
71
|
options.customHeadersToSkipOnWeakVersion = (options.customHeadersToSkipOnWeakVersion || []).map(s => s.toLowerCase());
|
|
72
|
-
options.port =
|
|
72
|
+
options.port = options.port || process.env['PORT'] || 3000;
|
|
73
73
|
options.timeout = options.timeout || 1000 * 60 * 2;
|
|
74
74
|
options.keepAliveTimeout =
|
|
75
75
|
options.keepAliveTimeout || DEFAULT_NODE_KEEPALIVE_MS;
|
|
@@ -83,18 +83,18 @@ function optionsSanitiser(input) {
|
|
|
83
83
|
options.storage.adapter = require('oc-s3-storage-adapter');
|
|
84
84
|
}
|
|
85
85
|
if (options.refreshInterval && options.storage) {
|
|
86
|
-
options.storage.options
|
|
86
|
+
options.storage.options['refreshInterval'] = options.refreshInterval;
|
|
87
87
|
}
|
|
88
88
|
if (options.verbosity && options.storage) {
|
|
89
|
-
options.storage.options
|
|
89
|
+
options.storage.options['verbosity'] = options.verbosity;
|
|
90
90
|
}
|
|
91
91
|
if (options.storage &&
|
|
92
92
|
options.storage.options &&
|
|
93
|
-
options.storage.options
|
|
94
|
-
options.storage.options
|
|
95
|
-
options.storage.options
|
|
96
|
-
? options.storage.options
|
|
97
|
-
: `https:${options.storage.options
|
|
93
|
+
options.storage.options['path']) {
|
|
94
|
+
options.storage.options['path'] =
|
|
95
|
+
options.storage.options['path'].indexOf('http') === 0
|
|
96
|
+
? options.storage.options['path']
|
|
97
|
+
: `https:${options.storage.options['path']}`;
|
|
98
98
|
}
|
|
99
99
|
if (!options.env) {
|
|
100
100
|
options.env = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function init(pluginsToRegister: unknown[], callback:
|
|
1
|
+
export declare function init(pluginsToRegister: unknown[], callback: (err: unknown, data: Record<string, (...args: unknown[]) => void>) => void): void;
|
|
@@ -13,9 +13,9 @@ function validatePlugins(plugins) {
|
|
|
13
13
|
plugins.forEach(plugin => {
|
|
14
14
|
c++;
|
|
15
15
|
if (!lodash_1.default.isObject(plugin.register) ||
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
typeof plugin.register.register !== 'function' ||
|
|
17
|
+
typeof plugin.register.execute !== 'function' ||
|
|
18
|
+
typeof plugin.name !== 'string') {
|
|
19
19
|
throw new Error(resources_1.default.errors.registry.PLUGIN_NOT_VALID(plugin.name || String(c)));
|
|
20
20
|
}
|
|
21
21
|
});
|
|
@@ -57,15 +57,16 @@ function repository(conf) {
|
|
|
57
57
|
.toString();
|
|
58
58
|
},
|
|
59
59
|
getComponents() {
|
|
60
|
-
const validComponents =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const validComponents = conf.components ||
|
|
61
|
+
fs_extra_1.default.readdirSync(conf.path).filter(file => {
|
|
62
|
+
const isDir = fs_extra_1.default.lstatSync(path_1.default.join(conf.path, file)).isDirectory();
|
|
63
|
+
const isValidComponent = isDir
|
|
64
|
+
? fs_extra_1.default
|
|
65
|
+
.readdirSync(path_1.default.join(conf.path, file))
|
|
66
|
+
.filter(file => file === '_package').length === 1
|
|
67
|
+
: false;
|
|
68
|
+
return isValidComponent;
|
|
69
|
+
});
|
|
69
70
|
validComponents.push('oc-client');
|
|
70
71
|
return validComponents;
|
|
71
72
|
},
|
|
@@ -102,10 +103,10 @@ function repository(conf) {
|
|
|
102
103
|
cdn.getFile(getFilePath(componentName, componentVersion, 'template.js'), callback);
|
|
103
104
|
},
|
|
104
105
|
getComponent(componentName, componentVersionOrCallback, callbackMaybe) {
|
|
105
|
-
const componentVersion =
|
|
106
|
+
const componentVersion = typeof componentVersionOrCallback === 'function'
|
|
106
107
|
? undefined
|
|
107
108
|
: componentVersionOrCallback;
|
|
108
|
-
const callback =
|
|
109
|
+
const callback = typeof componentVersionOrCallback === 'function'
|
|
109
110
|
? componentVersionOrCallback
|
|
110
111
|
: callbackMaybe;
|
|
111
112
|
repository.getComponentVersions(componentName, (err, allVersions) => {
|
|
@@ -123,7 +124,7 @@ function repository(conf) {
|
|
|
123
124
|
if (err) {
|
|
124
125
|
return callback(`component not available: ${(0, error_to_string_1.default)(err)}`, null);
|
|
125
126
|
}
|
|
126
|
-
callback(null,
|
|
127
|
+
callback(null, Object.assign(component, { allVersions }));
|
|
127
128
|
});
|
|
128
129
|
});
|
|
129
130
|
},
|
|
@@ -148,7 +149,7 @@ function repository(conf) {
|
|
|
148
149
|
getComponentPath(componentName, componentVersion) {
|
|
149
150
|
const prefix = conf.local
|
|
150
151
|
? conf.baseUrl
|
|
151
|
-
: `${options
|
|
152
|
+
: `${options['path']}${options.componentsDir}/`;
|
|
152
153
|
return `${prefix}${componentName}/${componentVersion}/`;
|
|
153
154
|
},
|
|
154
155
|
getComponents(callback) {
|
|
@@ -180,8 +181,8 @@ function repository(conf) {
|
|
|
180
181
|
const filePath = getFilePath(componentName, componentVersion, 'server.js');
|
|
181
182
|
cdn.getFile(filePath, (err, content) => callback(err, content ? { content, filePath } : null));
|
|
182
183
|
},
|
|
183
|
-
getStaticClientPath: () => `${options
|
|
184
|
-
getStaticClientMapPath: () => `${options
|
|
184
|
+
getStaticClientPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.js')}`,
|
|
185
|
+
getStaticClientMapPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.map')}`,
|
|
185
186
|
getStaticFilePath: (componentName, componentVersion, filePath) => `${repository.getComponentPath(componentName, componentVersion)}${conf.local ? settings_1.default.registry.localStaticRedirectorPath : ''}${filePath}`,
|
|
186
187
|
getTemplatesInfo: () => templatesInfo,
|
|
187
188
|
getTemplate: (type) => templatesHash[type],
|
|
@@ -215,7 +216,7 @@ function repository(conf) {
|
|
|
215
216
|
msg: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID(componentVersion)
|
|
216
217
|
}, undefined);
|
|
217
218
|
}
|
|
218
|
-
const validationResult = validator.validatePackageJson(
|
|
219
|
+
const validationResult = validator.validatePackageJson(Object.assign(pkgDetails, {
|
|
219
220
|
componentName,
|
|
220
221
|
customValidator: conf.publishValidation
|
|
221
222
|
}));
|
|
@@ -225,7 +226,7 @@ function repository(conf) {
|
|
|
225
226
|
msg: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL(String(validationResult.error))
|
|
226
227
|
}, undefined);
|
|
227
228
|
}
|
|
228
|
-
repository.getComponentVersions(componentName, (
|
|
229
|
+
repository.getComponentVersions(componentName, (_err, componentVersions) => {
|
|
229
230
|
if (!versionHandler.validateNewVersion(componentVersion, componentVersions)) {
|
|
230
231
|
return callback({
|
|
231
232
|
code: resources_1.default.errors.registry
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OcParameter } from '../../types';
|
|
2
|
-
export declare function sanitiseComponentParameters(requestParameters:
|
|
2
|
+
export declare function sanitiseComponentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare type Component = {
|
|
2
2
|
name: string;
|
|
3
3
|
version?: string;
|
|
4
|
-
parameters?:
|
|
4
|
+
parameters?: Record<string, string>;
|
|
5
5
|
};
|
|
6
6
|
export declare function component(component: Component | string, baseUrl: string): string;
|
|
7
7
|
export declare function componentInfo(component: Component, baseUrl: string): string;
|
|
8
8
|
export declare function componentPreview(component: Component, baseUrl: string): string;
|
|
9
|
-
export declare function queryString(parameters?:
|
|
9
|
+
export declare function queryString(parameters?: Record<string, string>): string;
|
|
10
10
|
export {};
|
|
@@ -2,10 +2,10 @@ import { OcParameter } from '../../../types';
|
|
|
2
2
|
interface ValidationResult {
|
|
3
3
|
isValid: boolean;
|
|
4
4
|
errors: {
|
|
5
|
-
mandatory?:
|
|
6
|
-
types?:
|
|
5
|
+
mandatory?: Record<string, string>;
|
|
6
|
+
types?: Record<string, string>;
|
|
7
7
|
message?: string;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export default function componentParameters(requestParameters:
|
|
10
|
+
export default function componentParameters(requestParameters: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): ValidationResult;
|
|
11
11
|
export {};
|
|
@@ -89,10 +89,10 @@ function registryConfiguration(conf) {
|
|
|
89
89
|
}
|
|
90
90
|
const cdn = conf.storage.adapter(conf.storage.options);
|
|
91
91
|
if (cdn.adapterType === 's3') {
|
|
92
|
-
if (!conf.storage.options
|
|
93
|
-
!conf.storage.options
|
|
94
|
-
(conf.storage.options
|
|
95
|
-
(!conf.storage.options
|
|
92
|
+
if (!conf.storage.options['bucket'] ||
|
|
93
|
+
!conf.storage.options['region'] ||
|
|
94
|
+
(conf.storage.options['key'] && !conf.storage.options['secret']) ||
|
|
95
|
+
(!conf.storage.options['key'] && conf.storage.options['secret'])) {
|
|
96
96
|
return returnError(resources_1.default.errors.registry.CONFIGURATION_STORAGE_NOT_VALID(cdn.adapterType.toUpperCase()));
|
|
97
97
|
}
|
|
98
98
|
}
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import http from 'http';
|
|
4
|
-
import * as eventsHandler from './domain/events-handler';
|
|
5
4
|
import { Config, Plugin } from '../types';
|
|
6
5
|
interface Input extends Partial<Omit<Config, 'beforePublish'>> {
|
|
7
6
|
baseUrl: string;
|
|
8
7
|
}
|
|
9
8
|
export default function registry(inputOptions: Input): {
|
|
10
9
|
close: (callback: (err?: Error | undefined | string) => void) => void | http.Server;
|
|
11
|
-
on:
|
|
10
|
+
on: <T extends keyof {
|
|
11
|
+
error: {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
start: unknown;
|
|
16
|
+
'cache-poll': number;
|
|
17
|
+
request: import("./domain/events-handler").RequestData;
|
|
18
|
+
'component-retrieved': {
|
|
19
|
+
headers: http.IncomingHttpHeaders;
|
|
20
|
+
name: string;
|
|
21
|
+
parameters: http.IncomingHttpHeaders;
|
|
22
|
+
requestVersion: string;
|
|
23
|
+
duration: number;
|
|
24
|
+
};
|
|
25
|
+
}>(eventName: T, listener: (data: {
|
|
26
|
+
error: {
|
|
27
|
+
code: string;
|
|
28
|
+
message: string;
|
|
29
|
+
};
|
|
30
|
+
start: unknown;
|
|
31
|
+
'cache-poll': number;
|
|
32
|
+
request: import("./domain/events-handler").RequestData;
|
|
33
|
+
'component-retrieved': {
|
|
34
|
+
headers: http.IncomingHttpHeaders;
|
|
35
|
+
name: string;
|
|
36
|
+
parameters: http.IncomingHttpHeaders;
|
|
37
|
+
requestVersion: string;
|
|
38
|
+
duration: number;
|
|
39
|
+
};
|
|
40
|
+
}[T]) => void) => void;
|
|
12
41
|
register: (plugin: Omit<Plugin, 'callback'>, callback?: ((...args: any[]) => void) | undefined) => void;
|
|
13
|
-
start: (callback:
|
|
42
|
+
start: (callback: (err: Error | null, data: {
|
|
14
43
|
app: express.Express;
|
|
15
44
|
server: http.Server;
|
|
16
|
-
}
|
|
45
|
+
}) => void) => void;
|
|
17
46
|
app: express.Express;
|
|
18
47
|
};
|
|
19
48
|
export {};
|
package/dist/registry/index.js
CHANGED
|
@@ -28,7 +28,7 @@ const express_1 = __importDefault(require("express"));
|
|
|
28
28
|
const http_1 = __importDefault(require("http"));
|
|
29
29
|
const lodash_1 = __importDefault(require("lodash"));
|
|
30
30
|
const app_start_1 = __importDefault(require("./app-start"));
|
|
31
|
-
const
|
|
31
|
+
const events_handler_1 = __importDefault(require("./domain/events-handler"));
|
|
32
32
|
const middleware = __importStar(require("./middleware"));
|
|
33
33
|
const pluginsInitialiser = __importStar(require("./domain/plugins-initialiser"));
|
|
34
34
|
const repository_1 = __importDefault(require("./domain/repository"));
|
|
@@ -84,7 +84,7 @@ function registry(inputOptions) {
|
|
|
84
84
|
if (err) {
|
|
85
85
|
return callback(err, undefined);
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
events_handler_1.default.fire('start', {});
|
|
88
88
|
if (options.verbosity) {
|
|
89
89
|
ok(`Registry started at port ${app.get('port')}`);
|
|
90
90
|
if (lodash_1.default.isObject(componentsInfo)) {
|
|
@@ -99,15 +99,19 @@ function registry(inputOptions) {
|
|
|
99
99
|
}
|
|
100
100
|
callback(null, { app, server });
|
|
101
101
|
});
|
|
102
|
-
server.on('error',
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
server.on('error', error => {
|
|
103
|
+
var _a;
|
|
104
|
+
events_handler_1.default.fire('error', {
|
|
105
|
+
code: 'EXPRESS_ERROR',
|
|
106
|
+
message: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : String(error)
|
|
107
|
+
});
|
|
108
|
+
callback(error, undefined);
|
|
105
109
|
});
|
|
106
110
|
});
|
|
107
111
|
};
|
|
108
112
|
return {
|
|
109
113
|
close,
|
|
110
|
-
on:
|
|
114
|
+
on: events_handler_1.default.on,
|
|
111
115
|
register,
|
|
112
116
|
start,
|
|
113
117
|
app
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
export default function cors(
|
|
2
|
+
export default function cors(_req: Request, res: Response, next: NextFunction): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function cors(
|
|
3
|
+
function cors(_req, res, next) {
|
|
4
4
|
res.removeHeader('X-Powered-By');
|
|
5
5
|
res.header('Access-Control-Allow-Credentials', 'true');
|
|
6
6
|
res.header('Access-Control-Allow-Origin', '*');
|
|
@@ -15,7 +15,7 @@ function fileUpload(req, res, next) {
|
|
|
15
15
|
},
|
|
16
16
|
storage: multer_1.default.diskStorage({
|
|
17
17
|
destination: res.conf.tempDir,
|
|
18
|
-
filename: (
|
|
18
|
+
filename: (_req, file, cb) => cb(null, `${normaliseFileName(file.originalname)}-${Date.now()}.tar.gz`)
|
|
19
19
|
})
|
|
20
20
|
});
|
|
21
21
|
return upload.any()(req, res, next);
|
|
@@ -1,29 +1,10 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
6
|
const response_time_1 = __importDefault(require("response-time"));
|
|
26
|
-
const
|
|
7
|
+
const events_handler_1 = __importDefault(require("../domain/events-handler"));
|
|
27
8
|
function requestHandler() {
|
|
28
9
|
return (0, response_time_1.default)((req, res, time) => {
|
|
29
10
|
const data = {
|
|
@@ -43,7 +24,7 @@ function requestHandler() {
|
|
|
43
24
|
if (res.errorCode) {
|
|
44
25
|
data.errorCode = res.errorCode;
|
|
45
26
|
}
|
|
46
|
-
|
|
27
|
+
events_handler_1.default.fire('request', data);
|
|
47
28
|
});
|
|
48
29
|
}
|
|
49
30
|
exports.default = requestHandler;
|
package/dist/registry/router.js
CHANGED
|
@@ -28,7 +28,7 @@ function create(app, conf, repository) {
|
|
|
28
28
|
};
|
|
29
29
|
const prefix = conf.prefix;
|
|
30
30
|
if (prefix !== '/') {
|
|
31
|
-
app.get('/', (
|
|
31
|
+
app.get('/', (_req, res) => res.redirect(prefix));
|
|
32
32
|
app.get(prefix.substr(0, prefix.length - 1), routes.index);
|
|
33
33
|
}
|
|
34
34
|
app.get(`${prefix}oc-client/client.js`, routes.staticRedirector);
|
|
@@ -46,7 +46,8 @@ function getParsedAuthor(component) {
|
|
|
46
46
|
function componentInfo(err, req, res, component) {
|
|
47
47
|
if (err) {
|
|
48
48
|
res.errorDetails = err.registryError || err;
|
|
49
|
-
|
|
49
|
+
res.status(404).json(err);
|
|
50
|
+
return;
|
|
50
51
|
}
|
|
51
52
|
const isHtmlRequest = !!req.headers.accept && req.headers.accept.indexOf('text/html') >= 0;
|
|
52
53
|
if (isHtmlRequest && !!res.conf.discovery) {
|
|
@@ -54,7 +55,7 @@ function componentInfo(err, req, res, component) {
|
|
|
54
55
|
const parsedAuthor = getParsedAuthor(component);
|
|
55
56
|
let href = res.conf.baseUrl;
|
|
56
57
|
const repositoryUrl = lodash_1.default.get(component, 'repository.url', typeof component.repository === 'string' ? component.repository : null);
|
|
57
|
-
(0, is_url_discoverable_1.default)(href, (
|
|
58
|
+
(0, is_url_discoverable_1.default)(href, (_err, result) => {
|
|
58
59
|
if (!result.isDiscoverable) {
|
|
59
60
|
href = `//${req.headers.host}${res.conf.prefix}`;
|
|
60
61
|
}
|
|
@@ -71,13 +72,13 @@ function componentInfo(err, req, res, component) {
|
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
74
|
res.status(200).json(Object.assign(component, {
|
|
74
|
-
requestVersion: req.params
|
|
75
|
+
requestVersion: req.params['componentVersion'] || ''
|
|
75
76
|
}));
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
function componentInfoRoute(conf, repository) {
|
|
79
80
|
return function (req, res) {
|
|
80
|
-
repository.getComponent(req.params
|
|
81
|
+
repository.getComponent(req.params['componentName'], req.params['componentVersion'], (registryError, component) => {
|
|
81
82
|
if (registryError && conf.fallbackRegistryUrl) {
|
|
82
83
|
return getComponentFallback.getComponentInfo(conf, req, res, registryError, (fallbackError, fallbackComponent) => componentInfo(fallbackError, req, res, fallbackComponent));
|
|
83
84
|
}
|
|
@@ -29,7 +29,8 @@ function componentPreview(err, req, res, component, templates) {
|
|
|
29
29
|
if (err) {
|
|
30
30
|
res.errorDetails = err.registryError || err;
|
|
31
31
|
res.errorCode = 'NOT_FOUND';
|
|
32
|
-
|
|
32
|
+
res.status(404).json(err);
|
|
33
|
+
return;
|
|
33
34
|
}
|
|
34
35
|
let liveReload = '';
|
|
35
36
|
if (res.conf.liveReloadPort) {
|
|
@@ -37,7 +38,7 @@ function componentPreview(err, req, res, component, templates) {
|
|
|
37
38
|
}
|
|
38
39
|
const isHtmlRequest = !!req.headers.accept && req.headers.accept.indexOf('text/html') >= 0;
|
|
39
40
|
if (isHtmlRequest && !!res.conf.discovery) {
|
|
40
|
-
|
|
41
|
+
res.send((0, preview_1.default)({
|
|
41
42
|
component,
|
|
42
43
|
href: res.conf.baseUrl,
|
|
43
44
|
liveReload,
|
|
@@ -47,13 +48,13 @@ function componentPreview(err, req, res, component, templates) {
|
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
50
|
res.status(200).json(Object.assign(component, {
|
|
50
|
-
requestVersion: req.params
|
|
51
|
+
requestVersion: req.params['componentVersion'] || ''
|
|
51
52
|
}));
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
function componentPreviewRoute(conf, repository) {
|
|
55
56
|
return (req, res) => {
|
|
56
|
-
repository.getComponent(req.params
|
|
57
|
+
repository.getComponent(req.params['componentName'], req.params['componentVersion'], (registryError, component) => {
|
|
57
58
|
if (registryError && conf.fallbackRegistryUrl) {
|
|
58
59
|
return getComponentFallback.getComponentPreview(conf, req, res, registryError, (fallbackError, fallbackComponent) => {
|
|
59
60
|
componentPreview(fallbackError, req, res, fallbackComponent, repository.getTemplatesInfo());
|
|
@@ -14,9 +14,9 @@ function component(conf, repository) {
|
|
|
14
14
|
conf: res.conf,
|
|
15
15
|
headers: req.headers,
|
|
16
16
|
ip: req.ip,
|
|
17
|
-
name: req.params
|
|
17
|
+
name: req.params['componentName'],
|
|
18
18
|
parameters: req.query,
|
|
19
|
-
version: req.params
|
|
19
|
+
version: req.params['componentVersion']
|
|
20
20
|
}, result => {
|
|
21
21
|
if (result.response.error) {
|
|
22
22
|
if (lodash_1.default.isError(result.response.error)) {
|
|
@@ -19,7 +19,7 @@ function components(conf, repository) {
|
|
|
19
19
|
const components = req.body.components;
|
|
20
20
|
const registryErrors = resources_1.default.errors.registry;
|
|
21
21
|
const returnError = function (message) {
|
|
22
|
-
|
|
22
|
+
res.status(400).json({
|
|
23
23
|
code: registryErrors.BATCH_ROUTE_BODY_NOT_VALID_CODE,
|
|
24
24
|
error: registryErrors.BATCH_ROUTE_BODY_NOT_VALID(message)
|
|
25
25
|
});
|
|
@@ -27,14 +27,14 @@ function components(conf, repository) {
|
|
|
27
27
|
if (!components) {
|
|
28
28
|
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_PROPERTY_MISSING);
|
|
29
29
|
}
|
|
30
|
-
else if (!
|
|
30
|
+
else if (!Array.isArray(components)) {
|
|
31
31
|
return returnError(registryErrors.BATCH_ROUTE_COMPONENTS_NOT_ARRAY);
|
|
32
32
|
}
|
|
33
33
|
if (!lodash_1.default.isEmpty(components)) {
|
|
34
34
|
const errors = lodash_1.default.compact(lodash_1.default.map(components, (component, index) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
return !component.name
|
|
36
|
+
? registryErrors.BATCH_ROUTE_COMPONENT_NAME_MISSING(index)
|
|
37
|
+
: '';
|
|
38
38
|
}));
|
|
39
39
|
if (!lodash_1.default.isEmpty(errors)) {
|
|
40
40
|
return returnError(errors.join(', '));
|
|
@@ -47,7 +47,7 @@ function components(conf, repository) {
|
|
|
47
47
|
headers: req.headers,
|
|
48
48
|
ip: req.ip,
|
|
49
49
|
omitHref: !!req.body.omitHref,
|
|
50
|
-
parameters:
|
|
50
|
+
parameters: { ...req.body.parameters, ...component.parameters },
|
|
51
51
|
version: component.version
|
|
52
52
|
}, result => callback(null, result));
|
|
53
53
|
},
|