oc 0.50.56 → 0.50.57-beta.0
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/.turbo/turbo-build.log +16 -18
- package/.turbo/turbo-lint.log +2 -2
- package/.turbo/turbo-test-silent.log +28 -46
- package/.turbo/turbo-test.log +17 -19
- package/CHANGELOG.md +6 -0
- package/dist/components/oc-client/_package/package.json +1 -38
- package/dist/index.d.ts +1 -0
- package/dist/registry/domain/extract-package.d.ts +3 -2
- package/dist/registry/domain/http-server/express-adapter.d.ts +2 -0
- package/dist/registry/domain/http-server/express-adapter.js +196 -0
- package/dist/registry/domain/http-server/types.d.ts +99 -0
- package/dist/registry/domain/http-server/types.js +2 -0
- package/dist/registry/domain/options-sanitiser.js +13 -0
- package/dist/registry/domain/server-adapter.d.ts +4 -0
- package/dist/registry/domain/server-adapter.js +20 -0
- package/dist/registry/domain/validators/uploaded-package.d.ts +5 -4
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +14 -16
- package/dist/registry/middleware/base-url-handler.d.ts +3 -2
- package/dist/registry/middleware/base-url-handler.js +3 -4
- package/dist/registry/middleware/compression.d.ts +2 -2
- package/dist/registry/middleware/compression.js +1 -1
- package/dist/registry/middleware/cors.d.ts +3 -2
- package/dist/registry/middleware/cors.js +7 -8
- package/dist/registry/middleware/discovery-handler.d.ts +3 -2
- package/dist/registry/middleware/discovery-handler.js +3 -4
- package/dist/registry/middleware/index.d.ts +2 -2
- package/dist/registry/middleware/index.js +39 -36
- package/dist/registry/router.d.ts +2 -2
- package/dist/registry/router.js +33 -27
- package/dist/registry/routes/component-info.d.ts +2 -2
- package/dist/registry/routes/component-info.js +1 -1
- package/dist/registry/routes/component-preview.d.ts +2 -2
- package/dist/registry/routes/component.d.ts +2 -2
- package/dist/registry/routes/component.js +3 -5
- package/dist/registry/routes/components.d.ts +2 -2
- package/dist/registry/routes/components.js +3 -1
- package/dist/registry/routes/dependencies.d.ts +2 -2
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +3 -3
- package/dist/registry/routes/helpers/get-component.d.ts +1 -1
- package/dist/registry/routes/history.d.ts +2 -2
- package/dist/registry/routes/history.js +1 -1
- package/dist/registry/routes/index.d.ts +2 -2
- package/dist/registry/routes/plugins.d.ts +2 -2
- package/dist/registry/routes/publish.d.ts +2 -2
- package/dist/registry/routes/static-redirector.d.ts +3 -2
- package/dist/registry/routes/static-redirector.js +8 -12
- package/dist/registry/routes/validate.d.ts +2 -2
- package/dist/types.d.ts +8 -0
- package/package.json +6 -6
- package/dist/registry/middleware/file-uploads.d.ts +0 -2
- package/dist/registry/middleware/file-uploads.js +0 -23
- package/dist/registry/middleware/request-handler.d.ts +0 -2
- package/dist/registry/middleware/request-handler.js +0 -30
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import type { UploadedFile } from '../http-server/types';
|
|
1
2
|
type ValidationResponse = {
|
|
2
3
|
isValid: true;
|
|
3
|
-
files:
|
|
4
|
-
[fieldname: string]:
|
|
4
|
+
files: UploadedFile[] | {
|
|
5
|
+
[fieldname: string]: UploadedFile[];
|
|
5
6
|
};
|
|
6
7
|
} | {
|
|
7
8
|
isValid: false;
|
|
8
9
|
message: string;
|
|
9
10
|
};
|
|
10
|
-
export default function uploadedPackage(input?:
|
|
11
|
-
[fieldname: string]:
|
|
11
|
+
export default function uploadedPackage(input?: UploadedFile[] | {
|
|
12
|
+
[fieldname: string]: UploadedFile[];
|
|
12
13
|
}): ValidationResponse;
|
|
13
14
|
export {};
|
package/dist/registry/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import http from 'node:http';
|
|
2
|
-
import express from 'express';
|
|
1
|
+
import type http from 'node:http';
|
|
2
|
+
import type express from 'express';
|
|
3
3
|
import type { Plugin } from '../types';
|
|
4
4
|
import { RegistryOptions } from './domain/options-sanitiser';
|
|
5
5
|
export { RegistryOptions };
|
package/dist/registry/index.js
CHANGED
|
@@ -37,14 +37,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.default = registry;
|
|
40
|
-
const node_http_1 = __importDefault(require("node:http"));
|
|
41
40
|
const safe_1 = __importDefault(require("colors/safe"));
|
|
42
|
-
const express_1 = __importDefault(require("express"));
|
|
43
41
|
const app_start_1 = __importDefault(require("./app-start"));
|
|
44
42
|
const events_handler_1 = __importDefault(require("./domain/events-handler"));
|
|
45
43
|
const options_sanitiser_1 = __importDefault(require("./domain/options-sanitiser"));
|
|
46
44
|
const pluginsInitialiser = __importStar(require("./domain/plugins-initialiser"));
|
|
47
45
|
const repository_1 = __importDefault(require("./domain/repository"));
|
|
46
|
+
const server_adapter_1 = __importDefault(require("./domain/server-adapter"));
|
|
48
47
|
const validator = __importStar(require("./domain/validators"));
|
|
49
48
|
const middleware = __importStar(require("./middleware"));
|
|
50
49
|
const router_1 = require("./router");
|
|
@@ -55,13 +54,13 @@ function registry(inputOptions) {
|
|
|
55
54
|
}
|
|
56
55
|
const options = (0, options_sanitiser_1.default)(inputOptions);
|
|
57
56
|
const plugins = [];
|
|
58
|
-
const
|
|
59
|
-
|
|
57
|
+
const adapter = middleware.bind((0, server_adapter_1.default)(options.server.adapter, options.server.options), options);
|
|
58
|
+
const app = adapter.native();
|
|
60
59
|
const repository = (0, repository_1.default)(options);
|
|
61
60
|
const close = (callback) => {
|
|
62
61
|
const closeMetadataStore = () => Promise.resolve(repository.close?.()).catch(() => undefined);
|
|
63
|
-
if (
|
|
64
|
-
|
|
62
|
+
if (adapter.isListening()) {
|
|
63
|
+
adapter.close((err) => {
|
|
65
64
|
void closeMetadataStore().finally(() => callback(err));
|
|
66
65
|
});
|
|
67
66
|
return;
|
|
@@ -75,30 +74,29 @@ function registry(inputOptions) {
|
|
|
75
74
|
const ok = (msg) => console.log(safe_1.default.green(msg));
|
|
76
75
|
try {
|
|
77
76
|
options.plugins = await pluginsInitialiser.init(plugins);
|
|
78
|
-
(0, router_1.create)(
|
|
77
|
+
(0, router_1.create)(adapter, options, repository);
|
|
79
78
|
const componentsInfo = await repository.init();
|
|
80
79
|
await (0, app_start_1.default)(repository, options);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
server.listen(options.port, (err) => {
|
|
80
|
+
adapter.listen({
|
|
81
|
+
port: options.port,
|
|
82
|
+
timeout: options.timeout,
|
|
83
|
+
keepAliveTimeout: options.keepAliveTimeout
|
|
84
|
+
}, (err) => {
|
|
87
85
|
if (err) {
|
|
88
86
|
return callback(err);
|
|
89
87
|
}
|
|
90
88
|
events_handler_1.default.fire('start', {});
|
|
91
89
|
if (options.verbosity) {
|
|
92
|
-
ok(`Registry started at port http://localhost:${
|
|
90
|
+
ok(`Registry started at port http://localhost:${options.port}${options.prefix}`);
|
|
93
91
|
if (componentsInfo) {
|
|
94
92
|
const componentsNumber = Object.keys(componentsInfo.components).length;
|
|
95
93
|
const componentsReleases = Object.values(componentsInfo.components).reduce((acc, component) => acc + Object.keys(component).length, 0);
|
|
96
94
|
ok(`Registry serving ${componentsNumber} components for a total of ${componentsReleases} releases.`);
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
|
-
callback(null, { app, server });
|
|
97
|
+
callback(null, { app, server: adapter.httpServer() });
|
|
100
98
|
});
|
|
101
|
-
|
|
99
|
+
adapter.onServerError((error) => {
|
|
102
100
|
events_handler_1.default.fire('error', {
|
|
103
101
|
code: 'EXPRESS_ERROR',
|
|
104
102
|
message: error?.message ?? String(error)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
|
+
declare const baseUrlHandler: OcHandler;
|
|
3
|
+
export default baseUrlHandler;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
function baseUrlHandler(req, res, next) {
|
|
3
|
+
const baseUrlHandler = (req, res) => {
|
|
5
4
|
if (res.conf.baseUrlFunc) {
|
|
6
5
|
res.conf.baseUrl = res.conf.baseUrlFunc({
|
|
7
6
|
host: req.headers.host,
|
|
8
7
|
secure: req.secure
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
};
|
|
11
|
+
exports.default = baseUrlHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OcRequest, OcResponse } from '../domain/http-server/types';
|
|
2
2
|
export default function compress(data: {
|
|
3
3
|
uncompressed: string;
|
|
4
4
|
brotli: Buffer;
|
|
5
5
|
gzip: Buffer;
|
|
6
|
-
}, req:
|
|
6
|
+
}, req: OcRequest, res: OcResponse): void;
|
|
@@ -9,7 +9,7 @@ function compress(data, req, res) {
|
|
|
9
9
|
res.send(data.uncompressed);
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
res.
|
|
12
|
+
res.set('Content-Encoding', encoding);
|
|
13
13
|
const compressed = encoding === 'br' ? data.brotli : data.gzip;
|
|
14
14
|
res.send(compressed);
|
|
15
15
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
|
+
declare const cors: OcHandler;
|
|
3
|
+
export default cors;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
function cors(_req, res, next) {
|
|
3
|
+
const cors = (_req, res) => {
|
|
5
4
|
res.removeHeader('X-Powered-By');
|
|
6
|
-
res.
|
|
7
|
-
res.
|
|
8
|
-
res.
|
|
9
|
-
res.
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
res.set('Access-Control-Allow-Credentials', 'true');
|
|
6
|
+
res.set('Access-Control-Allow-Origin', '*');
|
|
7
|
+
res.set('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, traceparent');
|
|
8
|
+
res.set('Access-Control-Allow-Methods', 'GET, OPTIONS, PUT, POST');
|
|
9
|
+
};
|
|
10
|
+
exports.default = cors;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
|
+
declare const discoveryHandler: OcHandler;
|
|
3
|
+
export default discoveryHandler;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
function discoveryHandler(req, res, next) {
|
|
3
|
+
const discoveryHandler = (req, res) => {
|
|
5
4
|
res.conf.discoveryFunc =
|
|
6
5
|
res.conf.discoveryFunc ||
|
|
7
6
|
(typeof res.conf.discovery === 'function' ? res.conf.discovery : undefined);
|
|
@@ -11,5 +10,5 @@ function discoveryHandler(req, res, next) {
|
|
|
11
10
|
secure: req.secure
|
|
12
11
|
});
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
};
|
|
14
|
+
exports.default = discoveryHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type Express } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
3
|
-
|
|
2
|
+
import type { HttpServerAdapter } from '../domain/http-server/types';
|
|
3
|
+
export declare const bind: (adapter: HttpServerAdapter, options: Config) => HttpServerAdapter;
|
|
@@ -4,54 +4,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.bind = void 0;
|
|
7
|
-
const
|
|
8
|
-
const errorhandler_1 = __importDefault(require("errorhandler"));
|
|
9
|
-
const express_1 = __importDefault(require("express"));
|
|
10
|
-
const morgan_1 = __importDefault(require("morgan"));
|
|
7
|
+
const events_handler_1 = __importDefault(require("../domain/events-handler"));
|
|
11
8
|
const base_url_handler_1 = __importDefault(require("./base-url-handler"));
|
|
12
9
|
const cors_1 = __importDefault(require("./cors"));
|
|
13
10
|
const discovery_handler_1 = __importDefault(require("./discovery-handler"));
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
inflate: true
|
|
18
|
-
};
|
|
19
|
-
const bodyParserUrlEncodedArgument = {
|
|
20
|
-
extended: true
|
|
21
|
-
};
|
|
22
|
-
const bind = (app, options) => {
|
|
23
|
-
app.set('port', options.port);
|
|
24
|
-
app.set('json spaces', 0);
|
|
25
|
-
app.set('etag', 'strong');
|
|
26
|
-
app.use((_req, res, next) => {
|
|
11
|
+
const normaliseFileName = (x) => x.replace('.tar.gz', '').replace(/\W+/g, '-').toLowerCase();
|
|
12
|
+
const bind = (adapter, options) => {
|
|
13
|
+
adapter.use((_req, res) => {
|
|
27
14
|
res.conf = options;
|
|
28
|
-
next();
|
|
29
15
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
16
|
+
adapter.enableRequestTiming((req, res, time) => {
|
|
17
|
+
const data = {
|
|
18
|
+
body: req.body,
|
|
19
|
+
duration: time,
|
|
20
|
+
headers: req.headers,
|
|
21
|
+
method: req.method,
|
|
22
|
+
path: req.path,
|
|
23
|
+
relativeUrl: req.originalUrl,
|
|
24
|
+
query: req.query,
|
|
25
|
+
url: req.protocol + '://' + req.get('host') + req.originalUrl,
|
|
26
|
+
statusCode: res.statusCode
|
|
27
|
+
};
|
|
28
|
+
if (res.errorDetails) {
|
|
29
|
+
data.errorDetails = res.errorDetails;
|
|
30
|
+
}
|
|
31
|
+
if (res.errorCode) {
|
|
32
|
+
data.errorCode = res.errorCode;
|
|
33
|
+
}
|
|
34
|
+
events_handler_1.default.fire('request', data);
|
|
35
|
+
});
|
|
36
|
+
adapter.enableCookies();
|
|
37
|
+
adapter.enableBodyParser({ limit: options.postRequestPayloadSize });
|
|
38
|
+
adapter.use(cors_1.default);
|
|
39
|
+
if (!options.local) {
|
|
40
|
+
adapter.enableFileUploads({
|
|
41
|
+
tempDir: options.tempDir,
|
|
42
|
+
filename: (originalName) => `${normaliseFileName(originalName)}-${Date.now()}.tar.gz`
|
|
43
|
+
});
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
app.use(cors_1.default);
|
|
41
|
-
app.use(file_uploads_1.default);
|
|
42
|
-
app.use(base_url_handler_1.default);
|
|
43
|
-
app.use(discovery_handler_1.default);
|
|
45
|
+
adapter.use(base_url_handler_1.default);
|
|
46
|
+
adapter.use(discovery_handler_1.default);
|
|
44
47
|
if (options.verbosity) {
|
|
45
|
-
|
|
48
|
+
adapter.enableLogging({
|
|
46
49
|
skip: (req, res) => {
|
|
47
50
|
// Hide logging development console calls
|
|
48
|
-
return req.url.startsWith(`${res.conf
|
|
51
|
+
return req.url.startsWith(`${res.conf?.prefix ?? ''}~actions/$$__oc__server___console__$$`);
|
|
49
52
|
}
|
|
50
|
-
})
|
|
53
|
+
});
|
|
51
54
|
}
|
|
52
55
|
if (options.local) {
|
|
53
|
-
|
|
56
|
+
adapter.enableErrorHandler();
|
|
54
57
|
}
|
|
55
|
-
return
|
|
58
|
+
return adapter;
|
|
56
59
|
};
|
|
57
60
|
exports.bind = bind;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Express } from 'express';
|
|
2
1
|
import type { Repository } from '../registry/domain/repository';
|
|
3
2
|
import type { Config } from '../types';
|
|
4
|
-
|
|
3
|
+
import type { HttpServerAdapter } from './domain/http-server/types';
|
|
4
|
+
export declare function create(adapter: HttpServerAdapter, conf: Config, repository: Repository): void;
|
package/dist/registry/router.js
CHANGED
|
@@ -16,7 +16,8 @@ const plugins_1 = __importDefault(require("./routes/plugins"));
|
|
|
16
16
|
const publish_1 = __importDefault(require("./routes/publish"));
|
|
17
17
|
const static_redirector_1 = __importDefault(require("./routes/static-redirector"));
|
|
18
18
|
const validate_1 = __importDefault(require("./routes/validate"));
|
|
19
|
-
function create(
|
|
19
|
+
function create(adapter, conf, repository) {
|
|
20
|
+
const route = (method, path, id, ...handlers) => adapter.route(method, path, id, handlers);
|
|
20
21
|
const routes = {
|
|
21
22
|
component: (0, component_1.default)(conf, repository),
|
|
22
23
|
components: (0, components_1.default)(conf, repository),
|
|
@@ -24,7 +25,12 @@ function create(app, conf, repository) {
|
|
|
24
25
|
componentPreview: (0, component_preview_1.default)(conf, repository),
|
|
25
26
|
index: (0, routes_1.default)(repository),
|
|
26
27
|
publish: (0, publish_1.default)(repository),
|
|
27
|
-
staticRedirector:
|
|
28
|
+
staticRedirector: {
|
|
29
|
+
client: (0, static_redirector_1.default)(repository, 'client'),
|
|
30
|
+
devClient: (0, static_redirector_1.default)(repository, 'dev-client'),
|
|
31
|
+
clientMap: (0, static_redirector_1.default)(repository, 'client-map'),
|
|
32
|
+
localStatic: (0, static_redirector_1.default)(repository, 'local-static')
|
|
33
|
+
},
|
|
28
34
|
plugins: (0, plugins_1.default)(conf),
|
|
29
35
|
dependencies: (0, dependencies_1.default)(conf),
|
|
30
36
|
history: (0, history_1.default)(repository),
|
|
@@ -33,42 +39,42 @@ function create(app, conf, repository) {
|
|
|
33
39
|
const prefix = conf.prefix;
|
|
34
40
|
const definedBaseRoute = conf.routes?.find((route) => route.route === '/');
|
|
35
41
|
if (prefix !== '/' && !definedBaseRoute) {
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
route('get', '/', 'root-redirect', (_req, res) => res.redirect(prefix));
|
|
43
|
+
route('get', prefix.substring(0, prefix.length - 1), 'prefix-index', routes.index);
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
route('get', `${prefix}oc-client/client.js`, 'client', routes.staticRedirector.client);
|
|
46
|
+
route('get', `${prefix}oc-client/client.dev.js`, 'dev-client', routes.staticRedirector.devClient);
|
|
47
|
+
route('get', `${prefix}oc-client/oc-client.min.map`, 'client-map', routes.staticRedirector.clientMap);
|
|
48
|
+
route('get', `${prefix}~registry/plugins`, 'plugins', routes.plugins);
|
|
49
|
+
route('get', `${prefix}~registry/dependencies`, 'dependencies', routes.dependencies);
|
|
50
|
+
route('get', `${prefix}~registry/history`, 'history', routes.history);
|
|
45
51
|
if (conf.discovery.validate) {
|
|
46
|
-
|
|
52
|
+
route('post', `${prefix}~registry/validate`, 'validate', routes.validate);
|
|
47
53
|
}
|
|
48
54
|
if (conf.local) {
|
|
49
|
-
|
|
55
|
+
route('get', `${prefix}:componentName/:componentVersion/${settings_1.default.registry.localStaticRedirectorPath}*splat`, 'local-static', routes.staticRedirector.localStatic);
|
|
50
56
|
}
|
|
51
57
|
else {
|
|
52
|
-
|
|
58
|
+
route('put', `${prefix}:componentName/:componentVersion`, 'publish', adapter.fromConnect(conf.beforePublish), routes.publish);
|
|
53
59
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
route('get', prefix, 'index', routes.index);
|
|
61
|
+
route('post', prefix, 'components', routes.components);
|
|
62
|
+
route('get', `${prefix}:componentName/:componentVersion${settings_1.default.registry.componentInfoPath}`, 'component-version-info', routes.componentInfo);
|
|
63
|
+
route('get', `${prefix}:componentName${settings_1.default.registry.componentInfoPath}`, 'component-info', routes.componentInfo);
|
|
64
|
+
route('get', `${prefix}:componentName/:componentVersion${settings_1.default.registry.componentPreviewPath}`, 'component-version-preview', routes.componentPreview);
|
|
65
|
+
route('get', `${prefix}:componentName${settings_1.default.registry.componentPreviewPath}`, 'component-preview', routes.componentPreview);
|
|
66
|
+
route('get', `${prefix}:componentName/:componentVersion`, 'component-version', routes.component);
|
|
67
|
+
route('get', `${prefix}:componentName`, 'component', routes.component);
|
|
68
|
+
route('post', `${prefix}~actions/:action/:componentName/:componentVersion`, 'component-version-action', routes.component);
|
|
69
|
+
route('post', `${prefix}~actions/:action/:componentName`, 'component-action', routes.component);
|
|
64
70
|
if (conf.routes) {
|
|
65
|
-
for (const
|
|
71
|
+
for (const routeConfig of conf.routes) {
|
|
66
72
|
// Ensure handler is a function (should be converted by options-sanitiser)
|
|
67
|
-
if (typeof
|
|
68
|
-
|
|
73
|
+
if (typeof routeConfig.handler === 'function') {
|
|
74
|
+
route(routeConfig.method.toLowerCase(), routeConfig.route, routeConfig.route, adapter.fromConnect(routeConfig.handler));
|
|
69
75
|
}
|
|
70
76
|
else {
|
|
71
|
-
console.warn(`Warning: Route handler for "${
|
|
77
|
+
console.warn(`Warning: Route handler for "${routeConfig.route}" is not a function. Skipping route.`);
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
3
|
import type { Repository } from '../domain/repository';
|
|
4
|
-
export default function componentInfoRoute(conf: Config, repository: Repository):
|
|
4
|
+
export default function componentInfoRoute(conf: Config, repository: Repository): OcHandler;
|
|
@@ -84,7 +84,7 @@ function componentInfo(err, req, res, component, componentDetail) {
|
|
|
84
84
|
href = `//${req.headers.host}${res.conf.prefix}`;
|
|
85
85
|
}
|
|
86
86
|
// Get theme from cookie or default to dark
|
|
87
|
-
const theme = req.cookies?.['oc-theme']
|
|
87
|
+
const theme = req.cookies?.['oc-theme'] === 'light' ? 'light' : 'dark';
|
|
88
88
|
res.send((0, info_1.default)({
|
|
89
89
|
component,
|
|
90
90
|
componentDetail,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
3
|
import type { Repository } from '../domain/repository';
|
|
4
|
-
export default function componentPreviewRoute(conf: Config, repository: Repository):
|
|
4
|
+
export default function componentPreviewRoute(conf: Config, repository: Repository): OcHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestHandler } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
3
|
import type { Repository } from '../domain/repository';
|
|
4
|
-
export default function component(conf: Config, repository: Repository):
|
|
4
|
+
export default function component(conf: Config, repository: Repository): OcHandler;
|
|
@@ -70,7 +70,7 @@ function component(conf, repository) {
|
|
|
70
70
|
res.errorDetails = result.response.error;
|
|
71
71
|
}
|
|
72
72
|
try {
|
|
73
|
-
if (Object.keys(result.headers
|
|
73
|
+
if (result.headers && Object.keys(result.headers).length) {
|
|
74
74
|
res.set(result.headers);
|
|
75
75
|
}
|
|
76
76
|
if (Array.isArray(result.cookies) && result.cookies.length > 0) {
|
|
@@ -89,10 +89,8 @@ function component(conf, repository) {
|
|
|
89
89
|
nodeStream.on('error', (err) => {
|
|
90
90
|
res.status(500).end(String(err));
|
|
91
91
|
});
|
|
92
|
-
res.
|
|
93
|
-
|
|
94
|
-
res.end();
|
|
95
|
-
});
|
|
92
|
+
res.set('Content-Type', 'x-text/stream');
|
|
93
|
+
res.stream(nodeStream);
|
|
96
94
|
}
|
|
97
95
|
else {
|
|
98
96
|
res.status(result.status).json(result.response);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestHandler } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
3
|
import type { Repository } from '../domain/repository';
|
|
4
|
-
export default function components(conf: Config, repository: Repository):
|
|
4
|
+
export default function components(conf: Config, repository: Repository): OcHandler;
|
|
@@ -13,7 +13,9 @@ function components(conf, repository) {
|
|
|
13
13
|
if (results?.length !== 1 || !results[0] || !res.set) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
if (results[0].headers) {
|
|
17
|
+
res.set(results[0].headers);
|
|
18
|
+
}
|
|
17
19
|
};
|
|
18
20
|
const setCookies = (results, res) => {
|
|
19
21
|
if (results?.length !== 1 || !results[0] || !res.cookie) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
3
|
-
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
|
+
export default function dependencies(conf: Config): OcHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import type { Request, Response } from 'express';
|
|
3
2
|
import type { Component, Config } from '../../../types';
|
|
3
|
+
import type { OcRequest, OcResponse } from '../../domain/http-server/types';
|
|
4
4
|
import type { GetComponentResult } from './get-component';
|
|
5
5
|
type ComponentCallback = (err: {
|
|
6
6
|
registryError: any;
|
|
@@ -11,6 +11,6 @@ export declare function getComponent(fallbackRegistryUrl: string, headers: Incom
|
|
|
11
11
|
version: string;
|
|
12
12
|
parameters: IncomingHttpHeaders;
|
|
13
13
|
}, callback: (result: GetComponentResult) => void): void;
|
|
14
|
-
export declare function getComponentPreview(conf: Config, req:
|
|
15
|
-
export declare function getComponentInfo(conf: Config, req:
|
|
14
|
+
export declare function getComponentPreview(conf: Config, req: OcRequest, res: OcResponse, registryError: string | null, callback: ComponentCallback): void;
|
|
15
|
+
export declare function getComponentInfo(conf: Config, req: OcRequest, res: OcResponse, registryError: string | null, callback: ComponentCallback): void;
|
|
16
16
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
2
|
-
import type { CookieOptions } from 'express';
|
|
3
2
|
import type { Config } from '../../../types';
|
|
3
|
+
import type { CookieOptions } from '../../domain/http-server/types';
|
|
4
4
|
import type { Repository } from '../../domain/repository';
|
|
5
5
|
export interface RendererOptions {
|
|
6
6
|
action?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
2
|
import type { Repository } from '../domain/repository';
|
|
3
|
-
export default function history(repository: Repository):
|
|
3
|
+
export default function history(repository: Repository): OcHandler;
|
|
@@ -11,7 +11,7 @@ function history(repository) {
|
|
|
11
11
|
if (res.conf.discovery.ui && !res.conf.local) {
|
|
12
12
|
const details = await repository.getComponentsDetails();
|
|
13
13
|
const componentsHistory = (0, get_components_history_1.default)(details);
|
|
14
|
-
res.
|
|
14
|
+
res.set('Cache-Control', 'public, max-age=600');
|
|
15
15
|
res.status(200).json({ componentsHistory });
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
2
|
import type { Repository } from '../domain/repository';
|
|
3
|
-
export default function (repository: Repository):
|
|
3
|
+
export default function (repository: Repository): OcHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request, Response } from 'express';
|
|
2
1
|
import type { Config } from '../../types';
|
|
3
|
-
|
|
2
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
3
|
+
export default function plugins(conf: Config): OcHandler;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
2
|
import type { Repository } from '../domain/repository';
|
|
3
|
-
export default function publish(repository: Repository):
|
|
3
|
+
export default function publish(repository: Repository): OcHandler;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OcHandler } from '../domain/http-server/types';
|
|
2
2
|
import type { Repository } from '../domain/repository';
|
|
3
|
-
export
|
|
3
|
+
export type StaticRedirectorRouteId = 'client' | 'dev-client' | 'client-map' | 'local-static';
|
|
4
|
+
export default function staticRedirector(repository: Repository, routeId: StaticRedirectorRouteId): OcHandler;
|