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
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const get_available_dependencies_1 = __importDefault(require("./helpers/get-available-dependencies"));
|
|
7
7
|
function dependencies(conf) {
|
|
8
|
-
return function (
|
|
8
|
+
return function (_req, res) {
|
|
9
9
|
if (res.conf.discovery) {
|
|
10
10
|
const dependencies = (0, get_available_dependencies_1.default)(conf.dependencies).map(({ core, name, version }) => {
|
|
11
11
|
const dep = {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { OcParameter } from '../../../types';
|
|
2
|
-
export default function applyDefaultValues(requestParameters?:
|
|
2
|
+
export default function applyDefaultValues(requestParameters?: Record<string, string | number | boolean>, expectedParameters?: Record<string, OcParameter>): Record<string, string | number | boolean>;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { IncomingHttpHeaders } from 'http';
|
|
4
4
|
import { Component, Config } from '../../../types';
|
|
5
|
-
declare type ComponentCallback =
|
|
5
|
+
declare type ComponentCallback = (err: {
|
|
6
6
|
registryError: any;
|
|
7
7
|
fallbackError: any;
|
|
8
|
-
}
|
|
8
|
+
} | null, data: Component) => void;
|
|
9
9
|
export declare function getComponent(fallbackRegistryUrl: string, headers: IncomingHttpHeaders, component: {
|
|
10
10
|
name: string;
|
|
11
11
|
version: string;
|
|
@@ -28,8 +28,8 @@ const url_1 = __importDefault(require("url"));
|
|
|
28
28
|
const urlBuilder = __importStar(require("../../domain/url-builder"));
|
|
29
29
|
function getComponentFallbackForViewType(buildUrl, conf, req, res, registryError, callback) {
|
|
30
30
|
const path = buildUrl({
|
|
31
|
-
name: req.params
|
|
32
|
-
version: req.params
|
|
31
|
+
name: req.params['componentName'],
|
|
32
|
+
version: req.params['componentVersion']
|
|
33
33
|
}, conf.fallbackRegistryUrl);
|
|
34
34
|
return (0, minimal_request_1.default)({
|
|
35
35
|
method: 'get',
|
|
@@ -6,13 +6,13 @@ interface Options {
|
|
|
6
6
|
headers: IncomingHttpHeaders;
|
|
7
7
|
ip: string;
|
|
8
8
|
name: string;
|
|
9
|
-
parameters:
|
|
9
|
+
parameters: Record<string, string>;
|
|
10
10
|
version: string;
|
|
11
11
|
omitHref?: boolean;
|
|
12
12
|
}
|
|
13
13
|
export declare type GetComponentResult = {
|
|
14
14
|
status: number;
|
|
15
|
-
headers?:
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
16
|
response: {
|
|
17
17
|
type?: string;
|
|
18
18
|
code?: string;
|
|
@@ -30,7 +30,7 @@ const oc_empty_response_handler_1 = __importDefault(require("oc-empty-response-h
|
|
|
30
30
|
const vm_1 = __importDefault(require("vm"));
|
|
31
31
|
const lodash_1 = __importDefault(require("lodash"));
|
|
32
32
|
const apply_default_values_1 = __importDefault(require("./apply-default-values"));
|
|
33
|
-
const
|
|
33
|
+
const events_handler_1 = __importDefault(require("../../domain/events-handler"));
|
|
34
34
|
const get_component_retrieving_info_1 = __importDefault(require("./get-component-retrieving-info"));
|
|
35
35
|
const getComponentFallback = __importStar(require("./get-component-fallback"));
|
|
36
36
|
const is_template_legacy_1 = __importDefault(require("../../../utils/is-template-legacy"));
|
|
@@ -64,7 +64,7 @@ function getComponent(conf, repository) {
|
|
|
64
64
|
name: options.name,
|
|
65
65
|
requestVersion: options.version || ''
|
|
66
66
|
});
|
|
67
|
-
|
|
67
|
+
events_handler_1.default.fire('component-retrieved', retrievingInfo.getData());
|
|
68
68
|
return cb(result);
|
|
69
69
|
};
|
|
70
70
|
let componentCallbackDone = false;
|
|
@@ -166,11 +166,11 @@ function getComponent(conf, repository) {
|
|
|
166
166
|
const isValidClientRequest = options.headers['user-agent'] &&
|
|
167
167
|
!!options.headers['user-agent'].match('oc-client-');
|
|
168
168
|
const parseTemplatesHeader = (t) => t.split(';').map(t => t.split(',')[0]);
|
|
169
|
-
const supportedTemplates = options.headers
|
|
170
|
-
? parseTemplatesHeader(options.headers
|
|
169
|
+
const supportedTemplates = options.headers['templates']
|
|
170
|
+
? parseTemplatesHeader(options.headers['templates'])
|
|
171
171
|
: [];
|
|
172
172
|
const isTemplateSupportedByClient = Boolean(isValidClientRequest &&
|
|
173
|
-
options.headers
|
|
173
|
+
options.headers['templates'] &&
|
|
174
174
|
(lodash_1.default.includes(supportedTemplates, component.oc.files.template.type) ||
|
|
175
175
|
lodash_1.default.includes(supportedTemplates, templateType)));
|
|
176
176
|
let renderMode = 'rendered';
|
|
@@ -219,7 +219,7 @@ function getComponent(conf, repository) {
|
|
|
219
219
|
callback({
|
|
220
220
|
status: 200,
|
|
221
221
|
headers: responseHeaders,
|
|
222
|
-
response:
|
|
222
|
+
response: Object.assign(response, {
|
|
223
223
|
data: data,
|
|
224
224
|
template: {
|
|
225
225
|
src: repository.getStaticFilePath(component.name, component.version, 'template.js'),
|
|
@@ -256,7 +256,7 @@ function getComponent(conf, repository) {
|
|
|
256
256
|
callback({
|
|
257
257
|
status: 200,
|
|
258
258
|
headers: responseHeaders,
|
|
259
|
-
response:
|
|
259
|
+
response: Object.assign(response, { html })
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
262
|
};
|
|
@@ -264,7 +264,7 @@ function getComponent(conf, repository) {
|
|
|
264
264
|
returnResult(cached);
|
|
265
265
|
}
|
|
266
266
|
else {
|
|
267
|
-
repository.getCompiledView(component.name, component.version, (
|
|
267
|
+
repository.getCompiledView(component.name, component.version, (_err, templateText) => {
|
|
268
268
|
let ocTemplate;
|
|
269
269
|
try {
|
|
270
270
|
ocTemplate = repository.getTemplate(templateType);
|
|
@@ -384,7 +384,7 @@ function getComponent(conf, repository) {
|
|
|
384
384
|
: {};
|
|
385
385
|
try {
|
|
386
386
|
vm_1.default.runInNewContext(dataProvider.content, context, options);
|
|
387
|
-
const processData = context.module.exports
|
|
387
|
+
const processData = context.module.exports['data'];
|
|
388
388
|
cache.set('file-contents', cacheKey, processData);
|
|
389
389
|
domain.on('error', handleError);
|
|
390
390
|
domain.run(() => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export default function isUrlDiscoverable(url: string, callback:
|
|
1
|
+
export default function isUrlDiscoverable(url: string, callback: (err: null | null, data: {
|
|
2
2
|
isDiscoverable: boolean;
|
|
3
|
-
}
|
|
3
|
+
}) => void): void;
|
|
@@ -8,7 +8,7 @@ function isUrlDiscoverable(url, callback) {
|
|
|
8
8
|
(0, minimal_request_1.default)({
|
|
9
9
|
url,
|
|
10
10
|
headers: { accept: 'text/html' }
|
|
11
|
-
}, (err,
|
|
11
|
+
}, (err, _body, details) => {
|
|
12
12
|
const isHtml = () => details.response.headers['content-type'].indexOf('text/html') >= 0;
|
|
13
13
|
callback(null, { isDiscoverable: !err && isHtml() });
|
|
14
14
|
});
|
|
@@ -25,7 +25,8 @@ function default_1(repository) {
|
|
|
25
25
|
repository.getComponents((err, components) => {
|
|
26
26
|
if (err) {
|
|
27
27
|
res.errorDetails = 'cdn not available';
|
|
28
|
-
|
|
28
|
+
res.status(404).json({ error: res.errorDetails });
|
|
29
|
+
return;
|
|
29
30
|
}
|
|
30
31
|
const baseResponse = {
|
|
31
32
|
href: res.conf.baseUrl,
|
|
@@ -72,7 +73,7 @@ function default_1(repository) {
|
|
|
72
73
|
};
|
|
73
74
|
}),
|
|
74
75
|
componentsHistory: !res.conf.local && (0, get_components_history_1.default)(details),
|
|
75
|
-
q: req.query
|
|
76
|
+
q: req.query['q'] || '',
|
|
76
77
|
stateCounts,
|
|
77
78
|
templates: repository.getTemplatesInfo(),
|
|
78
79
|
title: 'OpenComponents Registry'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
function plugins(conf) {
|
|
4
|
-
return (
|
|
4
|
+
return (_req, res) => {
|
|
5
5
|
if (res.conf.discovery) {
|
|
6
6
|
const plugins = Object.entries(conf.plugins).map(([pluginName, pluginFn]) => ({
|
|
7
7
|
name: pluginName,
|
|
@@ -27,7 +27,7 @@ const index_1 = __importDefault(require("../../resources/index"));
|
|
|
27
27
|
const validator = __importStar(require("../domain/validators"));
|
|
28
28
|
function publish(repository) {
|
|
29
29
|
return function (req, res) {
|
|
30
|
-
if (!req.params
|
|
30
|
+
if (!req.params['componentName'] || !req.params['componentVersion']) {
|
|
31
31
|
res.errorDetails = 'malformed request';
|
|
32
32
|
res.status(409).json({ error: res.errorDetails });
|
|
33
33
|
return;
|
|
@@ -62,11 +62,10 @@ function publish(repository) {
|
|
|
62
62
|
(0, extract_package_1.default)(files, (err, pkgDetails) => {
|
|
63
63
|
if (err) {
|
|
64
64
|
res.errorDetails = `Package is not valid: ${err}`;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.json({ error: 'package is not valid', details: err });
|
|
65
|
+
res.status(500).json({ error: 'package is not valid', details: err });
|
|
66
|
+
return;
|
|
68
67
|
}
|
|
69
|
-
repository.publishComponent(pkgDetails, req.params
|
|
68
|
+
repository.publishComponent(pkgDetails, req.params['componentName'], req.params['componentVersion'], err => {
|
|
70
69
|
if (err) {
|
|
71
70
|
if (err.code === 'not_allowed') {
|
|
72
71
|
res.errorDetails = `Publish not allowed: ${err.msg}`;
|
|
@@ -89,7 +88,7 @@ function publish(repository) {
|
|
|
89
88
|
return res.status(500).json({ error: err.msg });
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
res.status(200).json({ ok: true });
|
|
91
|
+
return res.status(200).json({ ok: true });
|
|
93
92
|
});
|
|
94
93
|
});
|
|
95
94
|
};
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const oc_storage_adapters_utils_1 = require("oc-storage-adapters-utils");
|
|
8
|
+
const oc_storage_adapters_utils_1 = __importDefault(require("oc-storage-adapters-utils"));
|
|
9
9
|
function staticRedirector(repository) {
|
|
10
10
|
return function (req, res) {
|
|
11
11
|
let filePath;
|
|
@@ -27,12 +27,12 @@ function staticRedirector(repository) {
|
|
|
27
27
|
return res.redirect(repository.getStaticClientMapPath());
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
else if (req.params
|
|
30
|
+
else if (req.params['componentName'] === 'oc-client') {
|
|
31
31
|
filePath = path_1.default.join(__dirname, '../../components/oc-client/_package/' + req.params[0]);
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
filePath =
|
|
35
|
-
path_1.default.join(res.conf.path, req.params
|
|
35
|
+
path_1.default.join(res.conf.path, req.params['componentName']) +
|
|
36
36
|
'/_package/' +
|
|
37
37
|
req.params[0];
|
|
38
38
|
}
|
|
@@ -48,7 +48,7 @@ function staticRedirector(repository) {
|
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
const fileStream = fs_extra_1.default.createReadStream(filePath);
|
|
51
|
-
const fileInfo =
|
|
51
|
+
const fileInfo = oc_storage_adapters_utils_1.default.getFileInfo(filePath);
|
|
52
52
|
if (fileInfo.mimeType) {
|
|
53
53
|
res.set('Content-Type', fileInfo.mimeType);
|
|
54
54
|
}
|
|
@@ -55,8 +55,11 @@ function info(vm) {
|
|
|
55
55
|
<div class="field"><p>Accept-Language header:</p></div>
|
|
56
56
|
<input class="w-100" id="lang" type="text" value="*" />
|
|
57
57
|
<h3>
|
|
58
|
-
Preview
|
|
59
|
-
<a class="refresh-preview" href="#refresh">
|
|
58
|
+
Preview (
|
|
59
|
+
<a class="refresh-preview" href="#refresh">Refresh</a>
|
|
60
|
+
|
|
|
61
|
+
<a class="open-preview" href="#open">Open</a>
|
|
62
|
+
)
|
|
60
63
|
</h3>
|
|
61
64
|
<iframe class="preview" src="~preview/${sandBoxDefaultQs}"></iframe>`;
|
|
62
65
|
const scripts = `<script>var thisComponentHref="${href}${component.name}/";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "\nvar oc = oc || {};\noc.cmd = oc.cmd || [];\n\noc.cmd.push(function() {\n $('#versions').change(function() {\n window.location = thisComponentHref + $(this).val() + '/~info';\n });\n\n
|
|
1
|
+
declare const _default: "\nvar oc = oc || {};\noc.cmd = oc.cmd || [];\n\noc.cmd.push(function() {\n $('#versions').change(function() {\n window.location = thisComponentHref + $(this).val() + '/~info';\n });\n\n var refreshPreview = function() {\n var splitted = $('#href')\n .val()\n .split('?'),\n url = splitted[0],\n lang = $('#lang').val();\n\n if (url.slice(-1) !== '/') {\n url += '/';\n }\n\n url = url.replace('http://', '//').replace('https://', '//');\n url += '~preview/?__ocAcceptLanguage=' + lang + '&';\n\n if (splitted.length > 1) {\n url += splitted[1];\n }\n\n $('.preview').attr('src', url);\n\n return false;\n };\n $('.refresh-preview').click(refreshPreview);\n\n $('.open-preview').click(function() {\n refreshPreview();\n var url = $('.preview').attr('src');\n\n window.open(url, '_blank');\n return false;\n });\n\n\n});";
|
|
2
2
|
export default _default;
|
|
@@ -9,7 +9,7 @@ oc.cmd.push(function() {
|
|
|
9
9
|
window.location = thisComponentHref + $(this).val() + '/~info';
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
var refreshPreview = function() {
|
|
13
13
|
var splitted = $('#href')
|
|
14
14
|
.val()
|
|
15
15
|
.split('?'),
|
|
@@ -29,6 +29,17 @@ oc.cmd.push(function() {
|
|
|
29
29
|
|
|
30
30
|
$('.preview').attr('src', url);
|
|
31
31
|
|
|
32
|
+
return false;
|
|
33
|
+
};
|
|
34
|
+
$('.refresh-preview').click(refreshPreview);
|
|
35
|
+
|
|
36
|
+
$('.open-preview').click(function() {
|
|
37
|
+
refreshPreview();
|
|
38
|
+
var url = $('.preview').attr('src');
|
|
39
|
+
|
|
40
|
+
window.open(url, '_blank');
|
|
32
41
|
return false;
|
|
33
42
|
});
|
|
43
|
+
|
|
44
|
+
|
|
34
45
|
});`;
|
|
@@ -110,7 +110,7 @@ declare const _default: {
|
|
|
110
110
|
USING_CREDS: string;
|
|
111
111
|
HELP_HINT: string;
|
|
112
112
|
HOT_RELOADING_DISABLED: string;
|
|
113
|
-
INSTALLING_DEPS: (dependencies: string) => string;
|
|
113
|
+
INSTALLING_DEPS: (dependencies: string, installPath: string) => string;
|
|
114
114
|
LINKING_DEPENDENCIES: (dependencies: string) => string;
|
|
115
115
|
MOCKED_PLUGIN: (name: string, value: string) => string;
|
|
116
116
|
NO_SUCH_COMMAND: (command: string) => string;
|
package/dist/resources/index.js
CHANGED
|
@@ -159,7 +159,7 @@ exports.default = {
|
|
|
159
159
|
USING_CREDS: 'Using specified credentials',
|
|
160
160
|
HELP_HINT: 'Hint: Run -h with any command to show the help',
|
|
161
161
|
HOT_RELOADING_DISABLED: 'OC dev is running with hot reloading disabled so changes will be ignored',
|
|
162
|
-
INSTALLING_DEPS: (dependencies) => `Trying to install missing modules: ${dependencies}
|
|
162
|
+
INSTALLING_DEPS: (dependencies, installPath) => `Trying to install missing modules: ${dependencies} into ${installPath}/node_modules.\nIf you aren't connected to the internet, or npm isn't configured then this step will fail...`,
|
|
163
163
|
LINKING_DEPENDENCIES: (dependencies) => `Trying to link missing modules: ${dependencies}\nThe missing dependencies will be linked to component dependencies`,
|
|
164
164
|
MOCKED_PLUGIN: (name, value) => `Mock for plugin has been registered: ${name} () => ${value}`,
|
|
165
165
|
NO_SUCH_COMMAND: (command) => `No such command '${command}'`,
|
package/dist/types.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export interface ComponentsDetails {
|
|
|
37
37
|
lastEdit: number;
|
|
38
38
|
}
|
|
39
39
|
export interface ComponentsList {
|
|
40
|
-
components:
|
|
40
|
+
components: Record<string, string[]>;
|
|
41
41
|
lastEdit: number;
|
|
42
42
|
}
|
|
43
43
|
export interface OcParameter {
|
|
@@ -104,6 +104,20 @@ export interface VM {
|
|
|
104
104
|
title: string;
|
|
105
105
|
type: 'oc-registry' | 'oc-registry-local';
|
|
106
106
|
}
|
|
107
|
+
export declare type Authentication<T = any> = {
|
|
108
|
+
validate: (config: T) => {
|
|
109
|
+
isValid: boolean;
|
|
110
|
+
message: string;
|
|
111
|
+
};
|
|
112
|
+
middleware: (config: T) => any;
|
|
113
|
+
};
|
|
114
|
+
export declare type PublishAuthConfig = {
|
|
115
|
+
type: 'basic';
|
|
116
|
+
username: string;
|
|
117
|
+
password: string;
|
|
118
|
+
} | ({
|
|
119
|
+
type: string | Authentication;
|
|
120
|
+
} & Record<string, any>);
|
|
107
121
|
export interface Config {
|
|
108
122
|
baseUrl: string;
|
|
109
123
|
baseUrlFunc?: (opts: {
|
|
@@ -118,24 +132,21 @@ export interface Config {
|
|
|
118
132
|
host?: string;
|
|
119
133
|
secure: boolean;
|
|
120
134
|
}) => boolean;
|
|
121
|
-
env:
|
|
135
|
+
env: Record<string, string>;
|
|
122
136
|
executionTimeout?: number;
|
|
123
137
|
fallbackRegistryUrl: string;
|
|
124
138
|
hotReloading: boolean;
|
|
125
139
|
keepAliveTimeout?: number;
|
|
126
140
|
liveReloadPort: number;
|
|
141
|
+
components?: string[];
|
|
127
142
|
local: boolean;
|
|
128
143
|
path: string;
|
|
129
144
|
plugins: Record<string, (...args: unknown[]) => void>;
|
|
130
145
|
pollingInterval: number;
|
|
131
|
-
port: number;
|
|
146
|
+
port: number | string;
|
|
132
147
|
postRequestPayloadSize?: number;
|
|
133
148
|
prefix: string;
|
|
134
|
-
publishAuth?:
|
|
135
|
-
type: string;
|
|
136
|
-
username: string;
|
|
137
|
-
password: string;
|
|
138
|
-
};
|
|
149
|
+
publishAuth?: PublishAuthConfig;
|
|
139
150
|
publishValidation: (data: unknown) => {
|
|
140
151
|
isValid: boolean;
|
|
141
152
|
error?: string;
|
|
@@ -155,7 +166,7 @@ export interface Config {
|
|
|
155
166
|
};
|
|
156
167
|
storage: {
|
|
157
168
|
adapter: any;
|
|
158
|
-
options:
|
|
169
|
+
options: Record<string, any> & {
|
|
159
170
|
componentsDir: string;
|
|
160
171
|
};
|
|
161
172
|
};
|
|
@@ -166,15 +177,15 @@ export interface Config {
|
|
|
166
177
|
}
|
|
167
178
|
export interface Cdn {
|
|
168
179
|
adapterType: string;
|
|
169
|
-
getFile: (filePath: string, cb:
|
|
170
|
-
getJson<T>(filePath: string, force: boolean, cb:
|
|
171
|
-
getJson<T>(filePath: string, cb:
|
|
172
|
-
listSubDirectories: (dir: string, cb:
|
|
180
|
+
getFile: (filePath: string, cb: (err: Error | null, data: string) => void) => void;
|
|
181
|
+
getJson<T>(filePath: string, force: boolean, cb: (err: string | null, data: T) => void): void;
|
|
182
|
+
getJson<T>(filePath: string, cb: (err: string | null, data: T) => void): void;
|
|
183
|
+
listSubDirectories: (dir: string, cb: (err: (Error & {
|
|
173
184
|
code?: string;
|
|
174
|
-
}
|
|
185
|
+
}) | null, data: string[]) => void) => void;
|
|
175
186
|
maxConcurrentRequests: number;
|
|
176
|
-
putDir: (folderPath: string, filePath: string, cb:
|
|
177
|
-
putFileContent: (data: unknown, path: string, isPrivate: boolean, callback:
|
|
187
|
+
putDir: (folderPath: string, filePath: string, cb: (err: Error | null) => void) => void;
|
|
188
|
+
putFileContent: (data: unknown, path: string, isPrivate: boolean, callback: (err: string | null, data: unknown) => void) => void;
|
|
178
189
|
}
|
|
179
190
|
declare type CompiledTemplate = (model: unknown) => string;
|
|
180
191
|
interface CompilerOptions {
|
|
@@ -190,13 +201,13 @@ interface CompilerOptions {
|
|
|
190
201
|
watch: boolean;
|
|
191
202
|
}
|
|
192
203
|
export interface Template {
|
|
193
|
-
compile?: (options: CompilerOptions, cb:
|
|
204
|
+
compile?: (options: CompilerOptions, cb: (err: Error | null) => void) => void;
|
|
194
205
|
getCompiledTemplate: (templateString: string, key: string, context?: Record<string, unknown>) => CompiledTemplate;
|
|
195
206
|
getInfo: () => TemplateInfo;
|
|
196
207
|
render: (options: {
|
|
197
208
|
model: unknown;
|
|
198
209
|
template: CompiledTemplate;
|
|
199
|
-
}, cb:
|
|
210
|
+
}, cb: (err: Error | null, data: string) => void) => void;
|
|
200
211
|
}
|
|
201
212
|
export interface Plugin {
|
|
202
213
|
callback?: (...args: unknown[]) => void;
|
|
@@ -210,32 +221,32 @@ export interface Plugin {
|
|
|
210
221
|
};
|
|
211
222
|
}
|
|
212
223
|
export interface RegistryCli {
|
|
213
|
-
add(registry: string, callback:
|
|
214
|
-
get(callback:
|
|
215
|
-
getApiComponentByHref(href: string, callback:
|
|
216
|
-
getComponentPreviewUrlByUrl(componentHref: string, callback:
|
|
224
|
+
add(registry: string, callback: (err: string | null, data: null) => void): void;
|
|
225
|
+
get(callback: (err: string | null, data: string[]) => void): void;
|
|
226
|
+
getApiComponentByHref(href: string, callback: (err: Error | number | null, data: unknown) => void): void;
|
|
227
|
+
getComponentPreviewUrlByUrl(componentHref: string, callback: (err: Error | number | null, data: string) => void): void;
|
|
217
228
|
putComponent(options: {
|
|
218
229
|
username?: string;
|
|
219
230
|
password?: string;
|
|
220
231
|
route: string;
|
|
221
232
|
path: string;
|
|
222
|
-
}, callback:
|
|
223
|
-
remove(registry: string, callback:
|
|
233
|
+
}, callback: (err: string | null, data: unknown) => void): void;
|
|
234
|
+
remove(registry: string, callback: (err: Error | null) => void): void;
|
|
224
235
|
}
|
|
225
236
|
export interface Local {
|
|
226
237
|
clean: {
|
|
227
|
-
fetchList: (dirPath: string, callback:
|
|
228
|
-
remove: (list: string[], callback:
|
|
238
|
+
fetchList: (dirPath: string, callback: (err: Error | null, data: string[]) => void) => void;
|
|
239
|
+
remove: (list: string[], callback: (err: Error | null, data: string) => void) => void;
|
|
229
240
|
};
|
|
230
241
|
cleanup: (compressedPackagePath: string, cb: (err: NodeJS.ErrnoException) => void) => void;
|
|
231
242
|
compress: (input: string, output: string, cb: (error: Error | string | null) => void) => void;
|
|
232
|
-
getComponentsByDir: (componentsDir: string, callback:
|
|
243
|
+
getComponentsByDir: (componentsDir: string, componentsToRun: (err: Error | null, data: string[]) => void | string[], callback: (err: Error | null, data: string[]) => void) => void;
|
|
233
244
|
init: (options: {
|
|
234
245
|
componentName: string;
|
|
235
246
|
logger: Logger;
|
|
236
247
|
componentPath: string;
|
|
237
248
|
templateType: string;
|
|
238
|
-
}, callback:
|
|
249
|
+
}, callback: (err: string | null, data: string) => void) => void;
|
|
239
250
|
mock: (params: {
|
|
240
251
|
targetType: string;
|
|
241
252
|
targetValue: string;
|
|
@@ -246,31 +257,31 @@ export interface Local {
|
|
|
246
257
|
minify?: boolean;
|
|
247
258
|
verbose?: boolean;
|
|
248
259
|
production?: boolean;
|
|
249
|
-
}, callback:
|
|
260
|
+
}, callback: (err: Error | null, data: Component) => void) => void;
|
|
250
261
|
}
|
|
251
262
|
export interface Repository {
|
|
252
|
-
getCompiledView(componentName: string, componentVersion: string, callback:
|
|
253
|
-
getComponent(componentName: string, componentVersion: string, calllback:
|
|
254
|
-
getComponent(componentName: string, calllback:
|
|
255
|
-
getComponentInfo(componentName: string, componentVersion: string, callback:
|
|
263
|
+
getCompiledView(componentName: string, componentVersion: string, callback: (err: Error | null, data: string) => void): void;
|
|
264
|
+
getComponent(componentName: string, componentVersion: string, calllback: (err: string | null, data: Component) => void): void;
|
|
265
|
+
getComponent(componentName: string, calllback: (err: string | null, data: Component) => void): void;
|
|
266
|
+
getComponentInfo(componentName: string, componentVersion: string, callback: (err: string | null, data: Component) => void): void;
|
|
256
267
|
getComponentPath(componentName: string, componentVersion: string): void;
|
|
257
|
-
getComponents(callback:
|
|
258
|
-
getComponentsDetails(callback:
|
|
259
|
-
getComponentVersions(componentName: string, callback:
|
|
260
|
-
getDataProvider(componentName: string, componentVersion: string, callback:
|
|
268
|
+
getComponents(callback: (err: Error | null, data: string[]) => void): void;
|
|
269
|
+
getComponentsDetails(callback: (err: string | null, data: ComponentsDetails) => void): void;
|
|
270
|
+
getComponentVersions(componentName: string, callback: (err: string | null, data: string[]) => void): void;
|
|
271
|
+
getDataProvider(componentName: string, componentVersion: string, callback: (err: Error | null, data: {
|
|
261
272
|
content: string;
|
|
262
273
|
filePath: string;
|
|
263
|
-
}
|
|
274
|
+
}) => void): void;
|
|
264
275
|
getStaticClientMapPath: () => string;
|
|
265
276
|
getStaticClientPath: () => string;
|
|
266
277
|
getStaticFilePath: (componentName: string, componentVersion: string, filePath: string) => string;
|
|
267
278
|
getTemplate: (type: string) => Template;
|
|
268
279
|
getTemplatesInfo: () => TemplateInfo[];
|
|
269
|
-
init(callback:
|
|
270
|
-
publishComponent(pkgDetails: any, componentName: string, componentVersion: string, callback:
|
|
280
|
+
init(callback: (err: Error | null, data: ComponentsList | string) => void): void;
|
|
281
|
+
publishComponent(pkgDetails: any, componentName: string, componentVersion: string, callback: (err: {
|
|
271
282
|
code: string;
|
|
272
283
|
msg: string;
|
|
273
|
-
}
|
|
284
|
+
} | null, data: ComponentsDetails) => void): void;
|
|
274
285
|
}
|
|
275
286
|
declare global {
|
|
276
287
|
namespace Express {
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export default function cleanRequire(path: string,
|
|
2
|
-
justTry
|
|
3
|
-
resolve
|
|
4
|
-
}):
|
|
1
|
+
export default function cleanRequire(path: string, opts: {
|
|
2
|
+
justTry: true;
|
|
3
|
+
resolve: true;
|
|
4
|
+
}): string | undefined;
|
|
5
|
+
export default function cleanRequire(path: string, opts: {
|
|
6
|
+
justTry?: false;
|
|
7
|
+
resolve: true;
|
|
8
|
+
}): string;
|
|
9
|
+
export default function cleanRequire<T = unknown>(path: string, opts: {
|
|
10
|
+
justTry: true;
|
|
11
|
+
resolve?: false;
|
|
12
|
+
}): T | undefined;
|
|
13
|
+
export default function cleanRequire<T = unknown>(path: string, opts: {
|
|
14
|
+
justTry?: false;
|
|
15
|
+
resolve?: false;
|
|
16
|
+
}): T;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
3
|
+
function padTwoDigits(data) {
|
|
4
|
+
return String(data).padStart(2, '0');
|
|
5
|
+
}
|
|
7
6
|
function dateStringify(date) {
|
|
8
7
|
if (date instanceof Date) {
|
|
9
8
|
return (date.getFullYear() +
|
|
10
9
|
'/' +
|
|
11
|
-
(
|
|
10
|
+
padTwoDigits(date.getMonth() + 1) +
|
|
12
11
|
'/' +
|
|
13
|
-
(
|
|
12
|
+
padTwoDigits(date.getDate()) +
|
|
14
13
|
' ' +
|
|
15
|
-
(
|
|
14
|
+
padTwoDigits(date.getHours()) +
|
|
16
15
|
':' +
|
|
17
|
-
(
|
|
16
|
+
padTwoDigits(date.getMinutes()) +
|
|
18
17
|
':' +
|
|
19
|
-
(
|
|
18
|
+
padTwoDigits(date.getSeconds()));
|
|
20
19
|
}
|
|
21
20
|
return '';
|
|
22
21
|
}
|
|
@@ -8,15 +8,15 @@ export declare const installDependencies: (options: {
|
|
|
8
8
|
installPath: string;
|
|
9
9
|
silent: boolean;
|
|
10
10
|
usePrefix: boolean;
|
|
11
|
-
}, callback:
|
|
11
|
+
}, callback: (err: string | number | null, data: {
|
|
12
12
|
dest: string;
|
|
13
|
-
}
|
|
13
|
+
}) => void) => void;
|
|
14
14
|
export declare const installDependency: (options: {
|
|
15
15
|
dependency: string;
|
|
16
16
|
installPath: string;
|
|
17
17
|
silent?: boolean;
|
|
18
18
|
usePrefix: boolean;
|
|
19
|
-
}, callback:
|
|
19
|
+
}, callback: (err: string | number | null, data: {
|
|
20
20
|
dest: string;
|
|
21
|
-
}
|
|
21
|
+
}) => void) => void;
|
|
22
22
|
export {};
|
package/dist/utils/put.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function put(urlPath: string, files: string | string[], headers: Record<string, string> |
|
|
1
|
+
export default function put(urlPath: string, files: string | string[], headers: Record<string, string> | ((err: Error | string | null, data: any) => void), callback: (err: Error | string | null, data: any) => void): void;
|