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
@@ -10,10 +10,13 @@ export default function extractPackage(
10
10
  | {
11
11
  [fieldname: string]: Express.Multer.File[];
12
12
  },
13
- callback: Callback<{
14
- outputFolder: string;
15
- packageJson: PackageJson;
16
- }>
13
+ callback: (
14
+ err: Error | null,
15
+ data: {
16
+ outputFolder: string;
17
+ packageJson: PackageJson;
18
+ }
19
+ ) => void
17
20
  ): void {
18
21
  const packageFile: Express.Multer.File = (files as any)[0];
19
22
  const packagePath = path.resolve(packageFile.path);
@@ -4,7 +4,7 @@ import { PackageJson } from 'type-fest';
4
4
 
5
5
  export default function getPackageJsonFromTempDir(
6
6
  tempDirPath: string,
7
- callback: Callback<PackageJson>
7
+ callback: (err: Error | null, data: PackageJson) => void
8
8
  ): void {
9
9
  return fs.readJson(path.join(tempDirPath, 'package.json'), callback);
10
10
  }
@@ -5,12 +5,12 @@ import settings from '../../resources/settings';
5
5
  import strings from '../../resources';
6
6
  import { Config } from '../../types';
7
7
 
8
- type Cb = Callback<string, string>;
8
+ type Cb = (err: string | null, data: string) => void;
9
9
  type Options = {
10
10
  version?: string;
11
11
  name?: string;
12
- headers?: Dictionary<string>;
13
- parameters?: Dictionary<string>;
12
+ headers?: Record<string, string>;
13
+ parameters?: Record<string, string>;
14
14
  };
15
15
  type Params = {
16
16
  components: Options[];
@@ -13,7 +13,7 @@ export default function optionsSanitiser(input: Input): Config {
13
13
  const options = _.clone(input);
14
14
 
15
15
  if (!options.publishAuth) {
16
- (options as Config).beforePublish = (req, res, next) => next();
16
+ (options as Config).beforePublish = (_req, _res, next) => next();
17
17
  } else {
18
18
  (options as Config).beforePublish = auth.middleware(options.publishAuth);
19
19
  }
@@ -37,28 +37,28 @@ export default function optionsSanitiser(input: Input): Config {
37
37
  options.tempDir = settings.registry.defaultTempPath;
38
38
  }
39
39
 
40
- if (!_.isBoolean(options.hotReloading)) {
40
+ if (typeof options.hotReloading !== 'boolean') {
41
41
  options.hotReloading = !!options.local;
42
42
  }
43
43
 
44
- if (_.isUndefined(options.verbosity)) {
44
+ if (!options.verbosity) {
45
45
  options.verbosity = 0;
46
46
  }
47
47
 
48
- if (_.isUndefined(options.discovery)) {
48
+ if (typeof options.discovery === 'undefined') {
49
49
  options.discovery = true;
50
50
  }
51
51
 
52
- if (_.isUndefined(options.pollingInterval)) {
52
+ if (typeof options.pollingInterval === 'undefined') {
53
53
  options.pollingInterval = 5;
54
54
  }
55
55
 
56
- if (_.isUndefined(options.templates)) {
56
+ if (!options.templates) {
57
57
  options.templates = [];
58
58
  }
59
59
 
60
60
  if (
61
- !_.isUndefined(options.fallbackRegistryUrl) &&
61
+ typeof options.fallbackRegistryUrl !== 'undefined' &&
62
62
  _.last(options.fallbackRegistryUrl) !== '/'
63
63
  ) {
64
64
  options.fallbackRegistryUrl += '/';
@@ -68,7 +68,7 @@ export default function optionsSanitiser(input: Input): Config {
68
68
  options.customHeadersToSkipOnWeakVersion || []
69
69
  ).map(s => s.toLowerCase());
70
70
 
71
- options.port = Number(process.env.PORT || options.port);
71
+ options.port = options.port || process.env['PORT'] || 3000;
72
72
  options.timeout = options.timeout || 1000 * 60 * 2;
73
73
  options.keepAliveTimeout =
74
74
  options.keepAliveTimeout || DEFAULT_NODE_KEEPALIVE_MS;
@@ -85,22 +85,22 @@ export default function optionsSanitiser(input: Input): Config {
85
85
  }
86
86
 
87
87
  if (options.refreshInterval && options.storage) {
88
- options.storage.options.refreshInterval = options.refreshInterval;
88
+ options.storage.options['refreshInterval'] = options.refreshInterval;
89
89
  }
90
90
 
91
91
  if (options.verbosity && options.storage) {
92
- options.storage.options.verbosity = options.verbosity;
92
+ options.storage.options['verbosity'] = options.verbosity;
93
93
  }
94
94
 
95
95
  if (
96
96
  options.storage &&
97
97
  options.storage.options &&
98
- options.storage.options.path
98
+ options.storage.options['path']
99
99
  ) {
100
- options.storage.options.path =
101
- options.storage.options.path.indexOf('http') === 0
102
- ? options.storage.options.path
103
- : `https:${options.storage.options.path}`;
100
+ options.storage.options['path'] =
101
+ options.storage.options['path'].indexOf('http') === 0
102
+ ? options.storage.options['path']
103
+ : `https:${options.storage.options['path']}`;
104
104
  }
105
105
 
106
106
  if (!options.env) {
@@ -12,9 +12,9 @@ function validatePlugins(plugins: unknown[]): asserts plugins is Plugin[] {
12
12
  c++;
13
13
  if (
14
14
  !_.isObject((plugin as Plugin).register) ||
15
- !_.isFunction((plugin as Plugin).register.register) ||
16
- !_.isFunction((plugin as Plugin).register.execute) ||
17
- !_.isString((plugin as Plugin).name)
15
+ typeof (plugin as Plugin).register.register !== 'function' ||
16
+ typeof (plugin as Plugin).register.execute !== 'function' ||
17
+ typeof (plugin as Plugin).name !== 'string'
18
18
  ) {
19
19
  throw new Error(
20
20
  strings.errors.registry.PLUGIN_NOT_VALID(
@@ -55,9 +55,12 @@ const defer = function (plugin: Plugin, cb: (err?: Error) => void) {
55
55
 
56
56
  export function init(
57
57
  pluginsToRegister: unknown[],
58
- callback: Callback<Dictionary<(...args: unknown[]) => void>, unknown>
58
+ callback: (
59
+ err: unknown,
60
+ data: Record<string, (...args: unknown[]) => void>
61
+ ) => void
59
62
  ): void {
60
- const registered: Dictionary<(...args: unknown[]) => void> = {};
63
+ const registered: Record<string, (...args: unknown[]) => void> = {};
61
64
 
62
65
  try {
63
66
  validatePlugins(pluginsToRegister);
@@ -5,7 +5,7 @@ import { Template, TemplateInfo } from '../../types';
5
5
  import _ from 'lodash';
6
6
 
7
7
  export default function registerTemplates(extraTemplates: Template[]): {
8
- templatesHash: Dictionary<Template>;
8
+ templatesHash: Record<string, Template>;
9
9
  templatesInfo: TemplateInfo[];
10
10
  } {
11
11
  const coreTemplates: Template[] = [
@@ -18,7 +18,7 @@ export default function registerTemplates(extraTemplates: Template[]): {
18
18
  const type = template.getInfo().type;
19
19
  hash[type] = template;
20
20
  return hash;
21
- }, {} as Dictionary<Template>);
21
+ }, {} as Record<string, Template>);
22
22
 
23
23
  const templatesInfo = templates.map(template => {
24
24
  return template.getInfo();
@@ -58,23 +58,25 @@ export default function repository(conf: Config): Repository {
58
58
  .toString();
59
59
  },
60
60
  getComponents(): string[] {
61
- const validComponents = fs.readdirSync(conf.path).filter(file => {
62
- const isDir = fs.lstatSync(path.join(conf.path, file)).isDirectory();
63
- const isValidComponent = isDir
64
- ? fs
65
- .readdirSync(path.join(conf.path, file))
66
- .filter(file => file === '_package').length === 1
67
- : false;
68
-
69
- return isValidComponent;
70
- });
61
+ const validComponents =
62
+ conf.components ||
63
+ fs.readdirSync(conf.path).filter(file => {
64
+ const isDir = fs.lstatSync(path.join(conf.path, file)).isDirectory();
65
+ const isValidComponent = isDir
66
+ ? fs
67
+ .readdirSync(path.join(conf.path, file))
68
+ .filter(file => file === '_package').length === 1
69
+ : false;
70
+
71
+ return isValidComponent;
72
+ });
71
73
 
72
74
  validComponents.push('oc-client');
73
75
  return validComponents;
74
76
  },
75
77
  getComponentVersions(
76
78
  componentName: string,
77
- callback: Callback<string[], string>
79
+ callback: (err: string | null, data: string[]) => void
78
80
  ) {
79
81
  if (componentName === 'oc-client') {
80
82
  return callback(null, [
@@ -116,7 +118,7 @@ export default function repository(conf: Config): Repository {
116
118
  getCompiledView(
117
119
  componentName: string,
118
120
  componentVersion: string,
119
- callback: Callback<string>
121
+ callback: (err: Error | null, data: string) => void
120
122
  ) {
121
123
  if (conf.local) {
122
124
  return callback(null, local.getCompiledView(componentName));
@@ -129,19 +131,19 @@ export default function repository(conf: Config): Repository {
129
131
  },
130
132
  getComponent(
131
133
  componentName: string,
132
- componentVersionOrCallback: string | Callback<Component, string>,
133
- callbackMaybe?: Callback<Component, string>
134
+ componentVersionOrCallback:
135
+ | string
136
+ | ((err: string | null, data: Component) => void),
137
+ callbackMaybe?: (err: string | null, data: Component) => void
134
138
  ) {
135
- const componentVersion: string | undefined = _.isFunction(
136
- componentVersionOrCallback
137
- )
138
- ? undefined
139
- : (componentVersionOrCallback as any);
140
- const callback: Callback<Component, string> = _.isFunction(
141
- componentVersionOrCallback
142
- )
143
- ? (componentVersionOrCallback as any)
144
- : callbackMaybe!;
139
+ const componentVersion: string | undefined =
140
+ typeof componentVersionOrCallback === 'function'
141
+ ? undefined
142
+ : (componentVersionOrCallback as any);
143
+ const callback: (err: string | null, data: Component) => void =
144
+ typeof componentVersionOrCallback === 'function'
145
+ ? (componentVersionOrCallback as any)
146
+ : callbackMaybe!;
145
147
 
146
148
  repository.getComponentVersions(componentName, (err, allVersions) => {
147
149
  if (err) {
@@ -184,7 +186,7 @@ export default function repository(conf: Config): Repository {
184
186
  null as any
185
187
  );
186
188
  }
187
- callback(null, _.extend(component, { allVersions }));
189
+ callback(null, Object.assign(component, { allVersions }));
188
190
  }
189
191
  );
190
192
  });
@@ -192,7 +194,7 @@ export default function repository(conf: Config): Repository {
192
194
  getComponentInfo(
193
195
  componentName: string,
194
196
  componentVersion: string,
195
- callback: Callback<Component, string>
197
+ callback: (err: string | null, data: Component) => void
196
198
  ) {
197
199
  if (conf.local) {
198
200
  let componentInfo;
@@ -225,10 +227,10 @@ export default function repository(conf: Config): Repository {
225
227
  getComponentPath(componentName: string, componentVersion: string) {
226
228
  const prefix = conf.local
227
229
  ? conf.baseUrl
228
- : `${options!.path}${options!.componentsDir}/`;
230
+ : `${options!['path']}${options!.componentsDir}/`;
229
231
  return `${prefix}${componentName}/${componentVersion}/`;
230
232
  },
231
- getComponents(callback: Callback<string[]>) {
233
+ getComponents(callback: (err: Error | null, data: string[]) => void) {
232
234
  if (conf.local) {
233
235
  return callback(null, local.getComponents());
234
236
  }
@@ -237,7 +239,9 @@ export default function repository(conf: Config): Repository {
237
239
  callback(err, res ? Object.keys(res.components) : (null as any))
238
240
  );
239
241
  },
240
- getComponentsDetails(callback: Callback<ComponentsDetails, string>) {
242
+ getComponentsDetails(
243
+ callback: (err: string | null, data: ComponentsDetails) => void
244
+ ) {
241
245
  if (conf.local) {
242
246
  return (callback as any)();
243
247
  }
@@ -246,7 +250,7 @@ export default function repository(conf: Config): Repository {
246
250
  },
247
251
  getComponentVersions(
248
252
  componentName: string,
249
- callback: Callback<string[], string>
253
+ callback: (err: string | null, data: string[]) => void
250
254
  ) {
251
255
  if (conf.local) {
252
256
  return local.getComponentVersions(componentName, callback);
@@ -264,10 +268,13 @@ export default function repository(conf: Config): Repository {
264
268
  getDataProvider(
265
269
  componentName: string,
266
270
  componentVersion: string,
267
- callback: Callback<{
268
- content: string;
269
- filePath: string;
270
- }>
271
+ callback: (
272
+ err: Error | null,
273
+ data: {
274
+ content: string;
275
+ filePath: string;
276
+ }
277
+ ) => void
271
278
  ) {
272
279
  if (conf.local) {
273
280
  return callback(null, local.getDataProvider(componentName));
@@ -284,14 +291,14 @@ export default function repository(conf: Config): Repository {
284
291
  );
285
292
  },
286
293
  getStaticClientPath: () =>
287
- `${options!.path}${getFilePath(
294
+ `${options!['path']}${getFilePath(
288
295
  'oc-client',
289
296
  packageInfo.version,
290
297
  'src/oc-client.min.js'
291
298
  )}`,
292
299
 
293
300
  getStaticClientMapPath: () =>
294
- `${options!.path}${getFilePath(
301
+ `${options!['path']}${getFilePath(
295
302
  'oc-client',
296
303
  packageInfo.version,
297
304
  'src/oc-client.min.map'
@@ -309,7 +316,7 @@ export default function repository(conf: Config): Repository {
309
316
  getTemplatesInfo: () => templatesInfo,
310
317
  getTemplate: (type: string) => templatesHash[type],
311
318
 
312
- init(callback: Callback<ComponentsList | string>) {
319
+ init(callback: (err: Error | null, data: ComponentsList | string) => void) {
313
320
  if (conf.local) {
314
321
  return callback(null, 'ok');
315
322
  }
@@ -327,7 +334,10 @@ export default function repository(conf: Config): Repository {
327
334
  pkgDetails: any,
328
335
  componentName: string,
329
336
  componentVersion: string,
330
- callback: Callback<ComponentsDetails, { code: string; msg: string }>
337
+ callback: (
338
+ err: { code: string; msg: string } | null,
339
+ data: ComponentsDetails
340
+ ) => void
331
341
  ) {
332
342
  if (conf.local) {
333
343
  return callback(
@@ -362,7 +372,7 @@ export default function repository(conf: Config): Repository {
362
372
  }
363
373
 
364
374
  const validationResult = validator.validatePackageJson(
365
- _.extend(pkgDetails, {
375
+ Object.assign(pkgDetails, {
366
376
  componentName,
367
377
  customValidator: conf.publishValidation
368
378
  })
@@ -382,7 +392,7 @@ export default function repository(conf: Config): Repository {
382
392
 
383
393
  repository.getComponentVersions(
384
394
  componentName,
385
- (err, componentVersions) => {
395
+ (_err, componentVersions) => {
386
396
  if (
387
397
  !versionHandler.validateNewVersion(
388
398
  componentVersion,
@@ -34,10 +34,10 @@ const sanitise = {
34
34
  const toRemove = ['__ocAcceptLanguage'];
35
35
 
36
36
  export function sanitiseComponentParameters(
37
- requestParameters: Dictionary<string | number | boolean>,
38
- expectedParameters: Dictionary<OcParameter>
39
- ): Dictionary<string | number | boolean> {
40
- const result: Dictionary<string | number | boolean> = {};
37
+ requestParameters: Record<string, string | number | boolean>,
38
+ expectedParameters: Record<string, OcParameter>
39
+ ): Record<string, string | number | boolean> {
40
+ const result: Record<string, string | number | boolean> = {};
41
41
 
42
42
  for (const [requestParameterName, requestParameter] of Object.entries(
43
43
  requestParameters
@@ -4,7 +4,7 @@ import url from 'url';
4
4
  type Component = {
5
5
  name: string;
6
6
  version?: string;
7
- parameters?: Dictionary<string>;
7
+ parameters?: Record<string, string>;
8
8
  };
9
9
 
10
10
  function componentForType(
@@ -61,7 +61,7 @@ export function componentPreview(
61
61
 
62
62
  return href;
63
63
  }
64
- export function queryString(parameters: Dictionary<string> = {}): string {
64
+ export function queryString(parameters: Record<string, string> = {}): string {
65
65
  let qs = '';
66
66
 
67
67
  if (Object.keys(parameters).length > 0) {
@@ -21,15 +21,15 @@ const validateParameter = function (
21
21
  interface ValidationResult {
22
22
  isValid: boolean;
23
23
  errors: {
24
- mandatory?: Dictionary<string>;
25
- types?: Dictionary<string>;
24
+ mandatory?: Record<string, string>;
25
+ types?: Record<string, string>;
26
26
  message?: string;
27
27
  };
28
28
  }
29
29
 
30
30
  export default function componentParameters(
31
- requestParameters: Dictionary<string | number | boolean>,
32
- expectedParameters: Dictionary<OcParameter> = {}
31
+ requestParameters: Record<string, string | number | boolean>,
32
+ expectedParameters: Record<string, OcParameter> = {}
33
33
  ): ValidationResult {
34
34
  const result: ValidationResult = { isValid: true, errors: {} };
35
35
  const mandatoryParameters: string[] = [];
@@ -105,10 +105,10 @@ export default function registryConfiguration(
105
105
  const cdn = conf.storage.adapter(conf.storage.options);
106
106
  if (cdn.adapterType === 's3') {
107
107
  if (
108
- !conf.storage.options.bucket ||
109
- !conf.storage.options.region ||
110
- (conf.storage.options.key && !conf.storage.options.secret) ||
111
- (!conf.storage.options.key && conf.storage.options.secret)
108
+ !conf.storage.options['bucket'] ||
109
+ !conf.storage.options['region'] ||
110
+ (conf.storage.options['key'] && !conf.storage.options['secret']) ||
111
+ (!conf.storage.options['key'] && conf.storage.options['secret'])
112
112
  ) {
113
113
  return returnError(
114
114
  strings.errors.registry.CONFIGURATION_STORAGE_NOT_VALID(
@@ -5,7 +5,7 @@ import http from 'http';
5
5
  import _ from 'lodash';
6
6
 
7
7
  import appStart from './app-start';
8
- import * as eventsHandler from './domain/events-handler';
8
+ import eventsHandler from './domain/events-handler';
9
9
  import * as middleware from './middleware';
10
10
  import * as pluginsInitialiser from './domain/plugins-initialiser';
11
11
  import Repository from './domain/repository';
@@ -46,7 +46,10 @@ export default function registry(inputOptions: Input) {
46
46
  };
47
47
 
48
48
  const start = (
49
- callback: Callback<{ app: express.Express; server: http.Server }>
49
+ callback: (
50
+ err: Error | null,
51
+ data: { app: express.Express; server: http.Server }
52
+ ) => void
50
53
  ) => {
51
54
  // eslint-disable-next-line no-console
52
55
  const ok = (msg: string) => console.log(colors.green(msg));
@@ -56,12 +59,16 @@ export default function registry(inputOptions: Input) {
56
59
  router.create(app, options, repository);
57
60
  async.waterfall(
58
61
  [
59
- (cb: Callback<Dictionary<(...args: unknown[]) => unknown>, unknown>) =>
60
- pluginsInitialiser.init(plugins, cb),
62
+ (
63
+ cb: (
64
+ err: unknown,
65
+ data: Record<string, (...args: unknown[]) => unknown>
66
+ ) => void
67
+ ) => pluginsInitialiser.init(plugins, cb),
61
68
 
62
69
  (
63
- plugins: Dictionary<(...args: unknown[]) => void>,
64
- cb: Callback<ComponentsList | string>
70
+ plugins: Record<string, (...args: unknown[]) => void>,
71
+ cb: (err: Error | null, data: ComponentsList | string) => void
65
72
  ) => {
66
73
  options.plugins = plugins;
67
74
  repository.init(cb);
@@ -69,7 +76,7 @@ export default function registry(inputOptions: Input) {
69
76
 
70
77
  (
71
78
  componentsInfo: ComponentsList,
72
- cb: Callback<ComponentsList, string>
79
+ cb: (err: string | null, data: ComponentsList) => void
73
80
  ) => {
74
81
  appStart(repository, options, (err: any) =>
75
82
  cb(err ? err.msg : null, componentsInfo)
@@ -117,9 +124,12 @@ export default function registry(inputOptions: Input) {
117
124
  callback(null, { app, server });
118
125
  });
119
126
 
120
- server.on('error', message => {
121
- eventsHandler.fire('error', { code: 'EXPRESS_ERROR', message });
122
- callback(message, undefined as any);
127
+ server.on('error', error => {
128
+ eventsHandler.fire('error', {
129
+ code: 'EXPRESS_ERROR',
130
+ message: error?.message ?? String(error)
131
+ });
132
+ callback(error, undefined as any);
123
133
  });
124
134
  }
125
135
  );
@@ -1,7 +1,7 @@
1
1
  import { NextFunction, Request, Response } from 'express';
2
2
 
3
3
  export default function cors(
4
- req: Request,
4
+ _req: Request,
5
5
  res: Response,
6
6
  next: NextFunction
7
7
  ): void {
@@ -19,7 +19,7 @@ export default function fileUpload(
19
19
  },
20
20
  storage: multer.diskStorage({
21
21
  destination: res.conf.tempDir,
22
- filename: (req, file, cb) =>
22
+ filename: (_req, file, cb) =>
23
23
  cb(null, `${normaliseFileName(file.originalname)}-${Date.now()}.tar.gz`)
24
24
  })
25
25
  });
@@ -20,7 +20,7 @@ export const bind = (app: Express, options: Config): Express => {
20
20
  app.set('port', options.port);
21
21
  app.set('json spaces', 0);
22
22
 
23
- app.use((req, res, next) => {
23
+ app.use((_req, res, next) => {
24
24
  res.conf = options;
25
25
  next();
26
26
  });
@@ -1,26 +1,11 @@
1
1
  import { Request, RequestHandler, Response } from 'express';
2
- import { IncomingHttpHeaders } from 'http';
3
2
  import responseTime from 'response-time';
4
3
 
5
- import * as eventsHandler from '../domain/events-handler';
6
-
7
- interface ResponseTimeData {
8
- body: any;
9
- duration: number;
10
- headers: IncomingHttpHeaders;
11
- method: string;
12
- path: string;
13
- relativeUrl: string;
14
- query: Record<string, any>;
15
- url: string;
16
- statusCode: number;
17
- errorDetails?: string;
18
- errorCode?: string;
19
- }
4
+ import eventsHandler, { RequestData } from '../domain/events-handler';
20
5
 
21
6
  export default function requestHandler(): RequestHandler {
22
7
  return responseTime((req: Request, res: Response, time) => {
23
- const data: ResponseTimeData = {
8
+ const data: RequestData = {
24
9
  body: req.body,
25
10
  duration: parseInt(String(time * 1000)),
26
11
  headers: req.headers,
@@ -32,12 +17,12 @@ export default function requestHandler(): RequestHandler {
32
17
  statusCode: res.statusCode
33
18
  };
34
19
 
35
- if ((res as any).errorDetails) {
36
- data.errorDetails = (res as any).errorDetails;
20
+ if (res.errorDetails) {
21
+ data.errorDetails = res.errorDetails;
37
22
  }
38
23
 
39
- if ((res as any).errorCode) {
40
- data.errorCode = (res as any).errorCode;
24
+ if (res.errorCode) {
25
+ data.errorCode = res.errorCode;
41
26
  }
42
27
 
43
28
  eventsHandler.fire('request', data);
@@ -31,7 +31,7 @@ export function create(
31
31
  const prefix = conf.prefix;
32
32
 
33
33
  if (prefix !== '/') {
34
- app.get('/', (req, res) => res.redirect(prefix));
34
+ app.get('/', (_req, res) => res.redirect(prefix));
35
35
  app.get(prefix.substr(0, prefix.length - 1), routes.index);
36
36
  }
37
37
 
@@ -43,10 +43,11 @@ function componentInfo(
43
43
  req: Request,
44
44
  res: Response,
45
45
  component: Component
46
- ) {
46
+ ): void {
47
47
  if (err) {
48
48
  res.errorDetails = (err as any).registryError || err;
49
- return res.status(404).json(err);
49
+ res.status(404).json(err);
50
+ return;
50
51
  }
51
52
 
52
53
  const isHtmlRequest =
@@ -63,7 +64,7 @@ function componentInfo(
63
64
  typeof component.repository === 'string' ? component.repository : null
64
65
  );
65
66
 
66
- isUrlDiscoverable(href, (err, result) => {
67
+ isUrlDiscoverable(href, (_err, result) => {
67
68
  if (!result.isDiscoverable) {
68
69
  href = `//${req.headers.host}${res.conf.prefix}`;
69
70
  }
@@ -83,7 +84,7 @@ function componentInfo(
83
84
  } else {
84
85
  res.status(200).json(
85
86
  Object.assign(component, {
86
- requestVersion: req.params.componentVersion || ''
87
+ requestVersion: req.params['componentVersion'] || ''
87
88
  })
88
89
  );
89
90
  }
@@ -95,8 +96,8 @@ export default function componentInfoRoute(
95
96
  ) {
96
97
  return function (req: Request, res: Response): void {
97
98
  repository.getComponent(
98
- req.params.componentName,
99
- req.params.componentVersion,
99
+ req.params['componentName'],
100
+ req.params['componentVersion'],
100
101
  (registryError, component) => {
101
102
  if (registryError && conf.fallbackRegistryUrl) {
102
103
  return getComponentFallback.getComponentInfo(