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.
Files changed (193) hide show
  1. package/.github/workflows/node.js.yml +1 -1
  2. package/CHANGELOG.md +25 -0
  3. package/dist/cli/commands.d.ts +8 -0
  4. package/dist/cli/commands.js +8 -0
  5. package/dist/cli/domain/clean.d.ts +2 -2
  6. package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
  7. package/dist/cli/domain/get-components-by-dir.js +10 -1
  8. package/dist/cli/domain/get-mocked-plugins.js +1 -1
  9. package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +1 -1
  10. package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +3 -2
  11. package/dist/cli/domain/handle-dependencies/index.d.ts +2 -2
  12. package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +2 -1
  13. package/dist/cli/domain/handle-dependencies/install-compiler.js +1 -1
  14. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +1 -1
  15. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +6 -3
  16. package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +1 -1
  17. package/dist/cli/domain/handle-dependencies/require-template.d.ts +1 -1
  18. package/dist/cli/domain/init-template/index.d.ts +2 -2
  19. package/dist/cli/domain/init-template/install-template.d.ts +2 -2
  20. package/dist/cli/domain/init-template/scaffold.d.ts +2 -2
  21. package/dist/cli/domain/mock.js +1 -1
  22. package/dist/cli/domain/package-components.d.ts +1 -1
  23. package/dist/cli/domain/registry.js +2 -2
  24. package/dist/cli/facade/dev.d.ts +2 -1
  25. package/dist/cli/facade/dev.js +8 -8
  26. package/dist/cli/facade/init.d.ts +1 -1
  27. package/dist/cli/facade/package.d.ts +1 -1
  28. package/dist/cli/facade/preview.d.ts +1 -1
  29. package/dist/cli/facade/publish.d.ts +1 -0
  30. package/dist/cli/facade/publish.js +10 -5
  31. package/dist/cli/facade/registry-add.d.ts +1 -1
  32. package/dist/cli/facade/registry-ls.d.ts +1 -1
  33. package/dist/cli/facade/registry-ls.js +1 -1
  34. package/dist/cli/facade/registry-remove.d.ts +1 -1
  35. package/dist/cli/facade/registry.d.ts +1 -1
  36. package/dist/cli/facade/registry.js +1 -1
  37. package/dist/cli/logger.d.ts +4 -4
  38. package/dist/cli/logger.js +5 -5
  39. package/dist/cli/programmatic-api.d.ts +2 -0
  40. package/dist/components/oc-client/_package/package.json +1 -1
  41. package/dist/components/oc-client/_package/server.js +1 -1
  42. package/dist/components/oc-client/_package/src/oc-client.min.js +2 -2
  43. package/dist/components/oc-client/_package/src/oc-client.min.map +1 -1
  44. package/dist/components/oc-client/_package/template.js +1 -1
  45. package/dist/components/oc-client/package.json +1 -1
  46. package/dist/components/oc-client/src/oc-client.min.js +2 -2
  47. package/dist/components/oc-client/src/oc-client.min.map +1 -1
  48. package/dist/registry/app-start.d.ts +1 -1
  49. package/dist/registry/app-start.js +1 -1
  50. package/dist/registry/domain/authentication.d.ts +2 -3
  51. package/dist/registry/domain/authentication.js +4 -4
  52. package/dist/registry/domain/components-cache/components-list.d.ts +4 -4
  53. package/dist/registry/domain/components-cache/index.d.ts +3 -3
  54. package/dist/registry/domain/components-cache/index.js +4 -23
  55. package/dist/registry/domain/components-details.d.ts +2 -2
  56. package/dist/registry/domain/components-details.js +6 -21
  57. package/dist/registry/domain/events-handler.d.ts +39 -5
  58. package/dist/registry/domain/events-handler.js +29 -31
  59. package/dist/registry/domain/extract-package.d.ts +2 -2
  60. package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +1 -1
  61. package/dist/registry/domain/nested-renderer.d.ts +3 -3
  62. package/dist/registry/domain/options-sanitiser.js +15 -15
  63. package/dist/registry/domain/plugins-initialiser.d.ts +1 -1
  64. package/dist/registry/domain/plugins-initialiser.js +3 -3
  65. package/dist/registry/domain/register-templates.d.ts +1 -1
  66. package/dist/registry/domain/repository.js +18 -17
  67. package/dist/registry/domain/sanitiser.d.ts +1 -1
  68. package/dist/registry/domain/url-builder.d.ts +2 -2
  69. package/dist/registry/domain/validators/component-parameters.d.ts +3 -3
  70. package/dist/registry/domain/validators/registry-configuration.js +4 -4
  71. package/dist/registry/index.d.ts +33 -4
  72. package/dist/registry/index.js +10 -6
  73. package/dist/registry/middleware/cors.d.ts +1 -1
  74. package/dist/registry/middleware/cors.js +1 -1
  75. package/dist/registry/middleware/file-uploads.js +1 -1
  76. package/dist/registry/middleware/index.js +1 -1
  77. package/dist/registry/middleware/request-handler.js +2 -21
  78. package/dist/registry/router.js +1 -1
  79. package/dist/registry/routes/component-info.js +5 -4
  80. package/dist/registry/routes/component-preview.js +5 -4
  81. package/dist/registry/routes/component.js +2 -2
  82. package/dist/registry/routes/components.js +6 -6
  83. package/dist/registry/routes/dependencies.d.ts +1 -1
  84. package/dist/registry/routes/dependencies.js +1 -1
  85. package/dist/registry/routes/helpers/apply-default-values.d.ts +1 -1
  86. package/dist/registry/routes/helpers/get-component-fallback.d.ts +2 -2
  87. package/dist/registry/routes/helpers/get-component-fallback.js +2 -2
  88. package/dist/registry/routes/helpers/get-component.d.ts +2 -2
  89. package/dist/registry/routes/helpers/get-component.js +9 -9
  90. package/dist/registry/routes/helpers/is-url-discoverable.d.ts +2 -2
  91. package/dist/registry/routes/helpers/is-url-discoverable.js +1 -1
  92. package/dist/registry/routes/index.js +3 -2
  93. package/dist/registry/routes/plugins.d.ts +1 -1
  94. package/dist/registry/routes/plugins.js +1 -1
  95. package/dist/registry/routes/publish.js +5 -6
  96. package/dist/registry/routes/static-redirector.js +4 -4
  97. package/dist/registry/views/info.js +5 -2
  98. package/dist/registry/views/static/info.d.ts +1 -1
  99. package/dist/registry/views/static/info.js +12 -1
  100. package/dist/resources/index.d.ts +1 -1
  101. package/dist/resources/index.js +1 -1
  102. package/dist/types.d.ts +52 -41
  103. package/dist/utils/clean-require.d.ts +16 -4
  104. package/dist/utils/date-stringify.js +8 -9
  105. package/dist/utils/npm-utils.d.ts +4 -4
  106. package/dist/utils/put.d.ts +1 -1
  107. package/logintervals.md +1 -1
  108. package/package.json +34 -35
  109. package/src/cli/commands.ts +10 -0
  110. package/src/cli/domain/clean.ts +12 -4
  111. package/src/cli/domain/get-components-by-dir.ts +21 -1
  112. package/src/cli/domain/get-mocked-plugins.ts +4 -4
  113. package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +1 -1
  114. package/src/cli/domain/handle-dependencies/get-compiler.ts +4 -3
  115. package/src/cli/domain/handle-dependencies/index.ts +21 -17
  116. package/src/cli/domain/handle-dependencies/install-compiler.ts +5 -4
  117. package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +7 -4
  118. package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +1 -1
  119. package/src/cli/domain/handle-dependencies/require-template.ts +1 -1
  120. package/src/cli/domain/init-template/index.ts +1 -1
  121. package/src/cli/domain/init-template/install-template.ts +1 -1
  122. package/src/cli/domain/init-template/scaffold.ts +1 -1
  123. package/src/cli/domain/mock.ts +1 -1
  124. package/src/cli/domain/package-components.ts +4 -1
  125. package/src/cli/domain/registry.ts +8 -8
  126. package/src/cli/facade/dev.ts +100 -97
  127. package/src/cli/facade/init.ts +1 -1
  128. package/src/cli/facade/package.ts +1 -1
  129. package/src/cli/facade/preview.ts +1 -1
  130. package/src/cli/facade/publish.ts +25 -10
  131. package/src/cli/facade/registry-add.ts +4 -1
  132. package/src/cli/facade/registry-ls.ts +4 -1
  133. package/src/cli/facade/registry-remove.ts +4 -1
  134. package/src/cli/facade/registry.ts +1 -1
  135. package/src/cli/index.ts +1 -1
  136. package/src/cli/logger.ts +10 -10
  137. package/src/components/oc-client/_package/package.json +1 -1
  138. package/src/components/oc-client/_package/server.js +1 -1
  139. package/src/components/oc-client/_package/src/oc-client.min.js +2 -2
  140. package/src/components/oc-client/_package/src/oc-client.min.map +1 -1
  141. package/src/components/oc-client/_package/template.js +1 -1
  142. package/src/components/oc-client/package.json +1 -1
  143. package/src/components/oc-client/src/oc-client.min.js +2 -2
  144. package/src/components/oc-client/src/oc-client.min.map +1 -1
  145. package/src/globals.d.ts +6 -12
  146. package/src/registry/app-start.ts +2 -2
  147. package/src/registry/domain/authentication.ts +6 -18
  148. package/src/registry/domain/components-cache/components-list.ts +11 -7
  149. package/src/registry/domain/components-cache/index.ts +5 -5
  150. package/src/registry/domain/components-details.ts +14 -8
  151. package/src/registry/domain/events-handler.ts +73 -27
  152. package/src/registry/domain/extract-package.ts +7 -4
  153. package/src/registry/domain/get-package-json-from-temp-dir.ts +1 -1
  154. package/src/registry/domain/nested-renderer.ts +3 -3
  155. package/src/registry/domain/options-sanitiser.ts +15 -15
  156. package/src/registry/domain/plugins-initialiser.ts +8 -5
  157. package/src/registry/domain/register-templates.ts +2 -2
  158. package/src/registry/domain/repository.ts +50 -40
  159. package/src/registry/domain/sanitiser.ts +4 -4
  160. package/src/registry/domain/url-builder.ts +2 -2
  161. package/src/registry/domain/validators/component-parameters.ts +4 -4
  162. package/src/registry/domain/validators/registry-configuration.ts +4 -4
  163. package/src/registry/index.ts +20 -10
  164. package/src/registry/middleware/cors.ts +1 -1
  165. package/src/registry/middleware/file-uploads.ts +1 -1
  166. package/src/registry/middleware/index.ts +1 -1
  167. package/src/registry/middleware/request-handler.ts +6 -21
  168. package/src/registry/router.ts +1 -1
  169. package/src/registry/routes/component-info.ts +7 -6
  170. package/src/registry/routes/component-preview.ts +6 -5
  171. package/src/registry/routes/component.ts +2 -2
  172. package/src/registry/routes/components.ts +7 -7
  173. package/src/registry/routes/dependencies.ts +1 -1
  174. package/src/registry/routes/helpers/apply-default-values.ts +3 -3
  175. package/src/registry/routes/helpers/get-component-fallback.ts +7 -7
  176. package/src/registry/routes/helpers/get-component.ts +16 -13
  177. package/src/registry/routes/helpers/is-url-discoverable.ts +2 -2
  178. package/src/registry/routes/index.ts +3 -2
  179. package/src/registry/routes/plugins.ts +1 -1
  180. package/src/registry/routes/publish.ts +6 -7
  181. package/src/registry/routes/static-redirector.ts +4 -4
  182. package/src/registry/views/info.ts +5 -2
  183. package/src/registry/views/static/info.ts +12 -1
  184. package/src/resources/index.ts +2 -2
  185. package/src/types.ts +85 -41
  186. package/src/utils/clean-require.ts +17 -1
  187. package/src/utils/date-stringify.ts +8 -6
  188. package/src/utils/npm-utils.ts +2 -2
  189. package/src/utils/put.ts +4 -2
  190. package/tsconfig.json +3 -3
  191. package/dist/utils/pad-zero.d.ts +0 -1
  192. package/dist/utils/pad-zero.js +0 -6
  193. 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 (req, res) {
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?: Dictionary<string | number | boolean>, expectedParameters?: Dictionary<OcParameter>): Dictionary<string | number | boolean>;
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 = Callback<Component, {
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.componentName,
32
- version: req.params.componentVersion
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: Dictionary<string>;
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?: Dictionary<string>;
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 eventsHandler = __importStar(require("../../domain/events-handler"));
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
- eventsHandler.fire('component-retrieved', retrievingInfo.getData());
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.templates
170
- ? parseTemplatesHeader(options.headers.templates)
169
+ const supportedTemplates = options.headers['templates']
170
+ ? parseTemplatesHeader(options.headers['templates'])
171
171
  : [];
172
172
  const isTemplateSupportedByClient = Boolean(isValidClientRequest &&
173
- options.headers.templates &&
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: lodash_1.default.extend(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: lodash_1.default.extend(response, { html })
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, (err, templateText) => {
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.data;
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: Callback<{
1
+ export default function isUrlDiscoverable(url: string, callback: (err: null | null, data: {
2
2
  isDiscoverable: boolean;
3
- }, null>): void;
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, body, details) => {
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
- return res.status(404).json({ error: res.errorDetails });
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.q || '',
76
+ q: req.query['q'] || '',
76
77
  stateCounts,
77
78
  templates: repository.getTemplatesInfo(),
78
79
  title: 'OpenComponents Registry'
@@ -1,3 +1,3 @@
1
1
  import { Request, Response } from 'express';
2
2
  import { Config } from '../../types';
3
- export default function plugins(conf: Config): (req: Request, res: Response) => void;
3
+ export default function plugins(conf: Config): (_req: Request, res: Response) => void;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  function plugins(conf) {
4
- return (req, res) => {
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.componentName || !req.params.componentVersion) {
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
- return res
66
- .status(500)
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.componentName, req.params.componentVersion, err => {
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.componentName === 'oc-client') {
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.componentName) +
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 = (0, oc_storage_adapters_utils_1.getFileInfo)(filePath);
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">(Refresh)</a>
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 $('.refresh-preview').click(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});";
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
- $('.refresh-preview').click(function() {
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;
@@ -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}\nIf you aren't connected to the internet, or npm isn't configured then this step will fail...`,
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: Dictionary<string[]>;
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: Dictionary<string>;
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: Dictionary<any> & {
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: Callback<string>) => void;
170
- getJson<T>(filePath: string, force: boolean, cb: Callback<T, string>): void;
171
- getJson<T>(filePath: string, cb: Callback<T, string>): void;
172
- listSubDirectories: (dir: string, cb: Callback<string[], Error & {
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
- }>) => void;
185
+ }) | null, data: string[]) => void) => void;
175
186
  maxConcurrentRequests: number;
176
- putDir: (folderPath: string, filePath: string, cb: Callback) => void;
177
- putFileContent: (data: unknown, path: string, isPrivate: boolean, callback: Callback<unknown, string>) => void;
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: Callback) => void;
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: Callback<string>) => void;
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: Callback<null, string>): void;
214
- get(callback: Callback<string[], string>): void;
215
- getApiComponentByHref(href: string, callback: Callback<unknown, Error | number>): void;
216
- getComponentPreviewUrlByUrl(componentHref: string, callback: Callback<string, Error | number>): void;
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: Callback<unknown, string>): void;
223
- remove(registry: string, callback: Callback): void;
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: Callback<string[]>) => void;
228
- remove: (list: string[], callback: Callback<string>) => void;
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: Callback<string[]>) => void;
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: Callback<string, string>) => void;
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: Callback<Component>) => void;
260
+ }, callback: (err: Error | null, data: Component) => void) => void;
250
261
  }
251
262
  export interface Repository {
252
- getCompiledView(componentName: string, componentVersion: string, callback: Callback<string>): void;
253
- getComponent(componentName: string, componentVersion: string, calllback: Callback<Component, string>): void;
254
- getComponent(componentName: string, calllback: Callback<Component, string>): void;
255
- getComponentInfo(componentName: string, componentVersion: string, callback: Callback<Component, string>): void;
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: Callback<string[]>): void;
258
- getComponentsDetails(callback: Callback<ComponentsDetails, string>): void;
259
- getComponentVersions(componentName: string, callback: Callback<string[], string>): void;
260
- getDataProvider(componentName: string, componentVersion: string, callback: 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
- }>): void;
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: Callback<ComponentsList | string>): void;
270
- publishComponent(pkgDetails: any, componentName: string, componentVersion: string, callback: Callback<ComponentsDetails, {
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
- }>): void;
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, { justTry, resolve }: {
2
- justTry?: boolean;
3
- resolve?: boolean;
4
- }): any;
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
- const pad_zero_1 = __importDefault(require("./pad-zero"));
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
- (0, pad_zero_1.default)(2, date.getMonth() + 1) +
10
+ padTwoDigits(date.getMonth() + 1) +
12
11
  '/' +
13
- (0, pad_zero_1.default)(2, date.getDate()) +
12
+ padTwoDigits(date.getDate()) +
14
13
  ' ' +
15
- (0, pad_zero_1.default)(2, date.getHours()) +
14
+ padTwoDigits(date.getHours()) +
16
15
  ':' +
17
- (0, pad_zero_1.default)(2, date.getMinutes()) +
16
+ padTwoDigits(date.getMinutes()) +
18
17
  ':' +
19
- (0, pad_zero_1.default)(2, date.getSeconds()));
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: Callback<{
11
+ }, callback: (err: string | number | null, data: {
12
12
  dest: string;
13
- }, string | number>) => void;
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: Callback<{
19
+ }, callback: (err: string | number | null, data: {
20
20
  dest: string;
21
- }, string | number>) => void;
21
+ }) => void) => void;
22
22
  export {};
@@ -1 +1 @@
1
- export default function put(urlPath: string, files: string | string[], headers: Record<string, string> | Callback<any, Error | string>, callback: Callback<any, Error | string>): void;
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;