oc 0.49.6 → 0.49.9

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 (305) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +2 -15
  3. package/dist/cli/commands.d.ts +163 -163
  4. package/dist/cli/commands.js +162 -162
  5. package/dist/cli/domain/clean.d.ts +2 -2
  6. package/dist/cli/domain/clean.js +24 -27
  7. package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
  8. package/dist/cli/domain/get-components-by-dir.js +41 -48
  9. package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
  10. package/dist/cli/domain/get-mocked-plugins.js +89 -87
  11. package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +6 -6
  12. package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +16 -17
  13. package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +10 -10
  14. package/dist/cli/domain/handle-dependencies/get-compiler.js +28 -28
  15. package/dist/cli/domain/handle-dependencies/get-missing-dependencies.d.ts +1 -1
  16. package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +18 -18
  17. package/dist/cli/domain/handle-dependencies/index.d.ts +10 -9
  18. package/dist/cli/domain/handle-dependencies/index.js +70 -64
  19. package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
  20. package/dist/cli/domain/handle-dependencies/install-compiler.js +54 -47
  21. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
  22. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -55
  23. package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
  24. package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -36
  25. package/dist/cli/domain/handle-dependencies/require-template.d.ts +17 -17
  26. package/dist/cli/domain/handle-dependencies/require-template.js +34 -34
  27. package/dist/cli/domain/init-template/index.d.ts +10 -10
  28. package/dist/cli/domain/init-template/index.js +40 -42
  29. package/dist/cli/domain/init-template/install-template.d.ts +11 -11
  30. package/dist/cli/domain/init-template/install-template.js +54 -53
  31. package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
  32. package/dist/cli/domain/init-template/scaffold.js +30 -30
  33. package/dist/cli/domain/local.d.ts +2 -2
  34. package/dist/cli/domain/local.js +82 -81
  35. package/dist/cli/domain/mock.d.ts +5 -5
  36. package/dist/cli/domain/mock.js +33 -33
  37. package/dist/cli/domain/package-components.d.ts +9 -9
  38. package/dist/cli/domain/package-components.js +67 -70
  39. package/dist/cli/domain/registry.d.ts +6 -6
  40. package/dist/cli/domain/registry.js +136 -149
  41. package/dist/cli/domain/url-parser.d.ts +14 -14
  42. package/dist/cli/domain/url-parser.js +31 -31
  43. package/dist/cli/domain/watch.d.ts +1 -1
  44. package/dist/cli/domain/watch.js +29 -29
  45. package/dist/cli/facade/clean.d.ts +16 -10
  46. package/dist/cli/facade/clean.js +58 -48
  47. package/dist/cli/facade/dev.d.ts +114 -21
  48. package/dist/cli/facade/dev.js +176 -190
  49. package/dist/cli/facade/init.d.ts +18 -11
  50. package/dist/cli/facade/init.js +39 -37
  51. package/dist/cli/facade/mock.d.ts +18 -11
  52. package/dist/cli/facade/mock.js +12 -13
  53. package/dist/cli/facade/package.d.ts +18 -11
  54. package/dist/cli/facade/package.js +49 -51
  55. package/dist/cli/facade/preview.d.ts +14 -9
  56. package/dist/cli/facade/preview.js +20 -18
  57. package/dist/cli/facade/publish.d.ts +23 -14
  58. package/dist/cli/facade/publish.js +145 -165
  59. package/dist/cli/facade/registry-add.d.ts +14 -9
  60. package/dist/cli/facade/registry-add.js +18 -17
  61. package/dist/cli/facade/registry-ls.d.ts +10 -7
  62. package/dist/cli/facade/registry-ls.js +27 -25
  63. package/dist/cli/facade/registry-remove.d.ts +14 -9
  64. package/dist/cli/facade/registry-remove.js +18 -17
  65. package/dist/cli/facade/registry.d.ts +5 -2
  66. package/dist/cli/facade/registry.js +9 -6
  67. package/dist/cli/index.d.ts +1 -1
  68. package/dist/cli/index.js +91 -93
  69. package/dist/cli/logger.d.ts +8 -8
  70. package/dist/cli/logger.js +19 -19
  71. package/dist/cli/programmatic-api.d.ts +84 -84
  72. package/dist/cli/programmatic-api.js +66 -66
  73. package/dist/cli/validate-command.d.ts +2 -2
  74. package/dist/cli/validate-command.js +18 -18
  75. package/dist/components/oc-client/_package/package.json +1 -1
  76. package/dist/components/oc-client/package.json +1 -1
  77. package/dist/index.d.ts +3 -3
  78. package/dist/index.js +12 -12
  79. package/dist/oc-cli.d.ts +2 -2
  80. package/dist/oc-cli.js +3 -3
  81. package/dist/registry/app-start.d.ts +2 -2
  82. package/dist/registry/app-start.js +44 -44
  83. package/dist/registry/domain/authentication.d.ts +7 -8
  84. package/dist/registry/domain/authentication.js +53 -50
  85. package/dist/registry/domain/components-cache/components-list.d.ts +8 -7
  86. package/dist/registry/domain/components-cache/components-list.js +50 -64
  87. package/dist/registry/domain/components-cache/index.d.ts +7 -6
  88. package/dist/registry/domain/components-cache/index.js +76 -79
  89. package/dist/registry/domain/components-details.d.ts +6 -5
  90. package/dist/registry/domain/components-details.js +64 -75
  91. package/dist/registry/domain/events-handler.d.ts +40 -40
  92. package/dist/registry/domain/events-handler.js +37 -37
  93. package/dist/registry/domain/extract-package.d.ts +8 -8
  94. package/dist/registry/domain/extract-package.js +26 -29
  95. package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +2 -2
  96. package/dist/registry/domain/get-package-json-from-temp-dir.js +11 -11
  97. package/dist/registry/domain/nested-renderer.d.ts +14 -13
  98. package/dist/registry/domain/nested-renderer.js +59 -95
  99. package/dist/registry/domain/options-sanitiser.d.ts +6 -6
  100. package/dist/registry/domain/options-sanitiser.js +106 -104
  101. package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
  102. package/dist/registry/domain/plugins-initialiser.js +95 -99
  103. package/dist/registry/domain/register-templates.d.ts +5 -5
  104. package/dist/registry/domain/register-templates.js +30 -30
  105. package/dist/registry/domain/repository.d.ts +2 -2
  106. package/dist/registry/domain/repository.js +237 -259
  107. package/dist/registry/domain/require-wrapper.d.ts +2 -2
  108. package/dist/registry/domain/require-wrapper.js +33 -34
  109. package/dist/registry/domain/sanitiser.d.ts +2 -2
  110. package/dist/registry/domain/sanitiser.js +52 -52
  111. package/dist/registry/domain/storage-adapter.d.ts +10 -0
  112. package/dist/registry/domain/storage-adapter.js +55 -0
  113. package/dist/registry/domain/url-builder.d.ts +10 -10
  114. package/dist/registry/domain/url-builder.js +60 -60
  115. package/dist/registry/domain/validators/component-parameters.d.ts +11 -11
  116. package/dist/registry/domain/validators/component-parameters.js +79 -79
  117. package/dist/registry/domain/validators/index.d.ts +16 -16
  118. package/dist/registry/domain/validators/index.js +29 -29
  119. package/dist/registry/domain/validators/node-version.d.ts +15 -15
  120. package/dist/registry/domain/validators/node-version.js +40 -40
  121. package/dist/registry/domain/validators/oc-cli-version.d.ts +15 -15
  122. package/dist/registry/domain/validators/oc-cli-version.js +34 -34
  123. package/dist/registry/domain/validators/package-json-validator.d.ts +13 -13
  124. package/dist/registry/domain/validators/package-json-validator.js +23 -23
  125. package/dist/registry/domain/validators/plugins-requirements.d.ts +9 -9
  126. package/dist/registry/domain/validators/plugins-requirements.js +22 -22
  127. package/dist/registry/domain/validators/registry-configuration.d.ts +9 -9
  128. package/dist/registry/domain/validators/registry-configuration.js +113 -113
  129. package/dist/registry/domain/validators/uploaded-package.d.ts +14 -14
  130. package/dist/registry/domain/validators/uploaded-package.js +25 -25
  131. package/dist/registry/domain/version-handler.d.ts +2 -2
  132. package/dist/registry/domain/version-handler.js +22 -22
  133. package/dist/registry/index.d.ts +48 -48
  134. package/dist/registry/index.js +107 -120
  135. package/dist/registry/middleware/base-url-handler.d.ts +2 -2
  136. package/dist/registry/middleware/base-url-handler.js +12 -12
  137. package/dist/registry/middleware/cors.d.ts +2 -2
  138. package/dist/registry/middleware/cors.js +11 -11
  139. package/dist/registry/middleware/discovery-handler.d.ts +2 -2
  140. package/dist/registry/middleware/discovery-handler.js +15 -15
  141. package/dist/registry/middleware/file-uploads.d.ts +2 -2
  142. package/dist/registry/middleware/file-uploads.js +23 -23
  143. package/dist/registry/middleware/index.d.ts +7 -3
  144. package/dist/registry/middleware/index.js +51 -47
  145. package/dist/registry/middleware/request-handler.d.ts +2 -2
  146. package/dist/registry/middleware/request-handler.js +30 -30
  147. package/dist/registry/router.d.ts +3 -3
  148. package/dist/registry/router.js +56 -58
  149. package/dist/registry/routes/component-info.d.ts +3 -3
  150. package/dist/registry/routes/component-info.js +90 -89
  151. package/dist/registry/routes/component-preview.d.ts +3 -3
  152. package/dist/registry/routes/component-preview.js +68 -67
  153. package/dist/registry/routes/component.d.ts +3 -3
  154. package/dist/registry/routes/component.js +43 -43
  155. package/dist/registry/routes/components.d.ts +3 -3
  156. package/dist/registry/routes/components.js +78 -78
  157. package/dist/registry/routes/dependencies.d.ts +3 -3
  158. package/dist/registry/routes/dependencies.js +28 -28
  159. package/dist/registry/routes/helpers/apply-default-values.d.ts +2 -2
  160. package/dist/registry/routes/helpers/apply-default-values.js +13 -13
  161. package/dist/registry/routes/helpers/get-available-dependencies.d.ts +8 -8
  162. package/dist/registry/routes/helpers/get-available-dependencies.js +24 -24
  163. package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -22
  164. package/dist/registry/routes/helpers/get-component-fallback.js +91 -91
  165. package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +20 -20
  166. package/dist/registry/routes/helpers/get-component-retrieving-info.js +24 -24
  167. package/dist/registry/routes/helpers/get-component.d.ts +33 -33
  168. package/dist/registry/routes/helpers/get-component.js +406 -405
  169. package/dist/registry/routes/helpers/get-components-history.d.ts +8 -8
  170. package/dist/registry/routes/helpers/get-components-history.js +28 -28
  171. package/dist/registry/routes/helpers/is-url-discoverable.d.ts +3 -3
  172. package/dist/registry/routes/helpers/is-url-discoverable.js +22 -16
  173. package/dist/registry/routes/index.d.ts +3 -3
  174. package/dist/registry/routes/index.js +93 -92
  175. package/dist/registry/routes/plugins.d.ts +3 -3
  176. package/dist/registry/routes/plugins.js +17 -17
  177. package/dist/registry/routes/publish.d.ts +3 -3
  178. package/dist/registry/routes/publish.js +97 -96
  179. package/dist/registry/routes/static-redirector.d.ts +3 -3
  180. package/dist/registry/routes/static-redirector.js +63 -63
  181. package/dist/registry/views/index.d.ts +2 -2
  182. package/dist/registry/views/index.js +39 -39
  183. package/dist/registry/views/info.d.ts +16 -16
  184. package/dist/registry/views/info.js +44 -41
  185. package/dist/registry/views/partials/component-author.d.ts +8 -8
  186. package/dist/registry/views/partials/component-author.js +20 -20
  187. package/dist/registry/views/partials/component-parameters.d.ts +5 -5
  188. package/dist/registry/views/partials/component-parameters.js +24 -24
  189. package/dist/registry/views/partials/component-state.d.ts +5 -5
  190. package/dist/registry/views/partials/component-state.js +6 -6
  191. package/dist/registry/views/partials/component-versions.d.ts +5 -5
  192. package/dist/registry/views/partials/component-versions.js +9 -9
  193. package/dist/registry/views/partials/components-dependencies.d.ts +2 -2
  194. package/dist/registry/views/partials/components-dependencies.js +12 -12
  195. package/dist/registry/views/partials/components-history.d.ts +2 -2
  196. package/dist/registry/views/partials/components-history.js +10 -10
  197. package/dist/registry/views/partials/components-list.d.ts +2 -2
  198. package/dist/registry/views/partials/components-list.js +26 -26
  199. package/dist/registry/views/partials/components-plugins.d.ts +2 -2
  200. package/dist/registry/views/partials/components-plugins.js +8 -8
  201. package/dist/registry/views/partials/components-templates.d.ts +2 -2
  202. package/dist/registry/views/partials/components-templates.js +14 -14
  203. package/dist/registry/views/partials/layout.d.ts +8 -8
  204. package/dist/registry/views/partials/layout.js +11 -11
  205. package/dist/registry/views/partials/property.d.ts +2 -2
  206. package/dist/registry/views/partials/property.js +11 -11
  207. package/dist/registry/views/partials/selected-checkbox.d.ts +4 -4
  208. package/dist/registry/views/partials/selected-checkbox.js +7 -7
  209. package/dist/registry/views/preview.d.ts +8 -8
  210. package/dist/registry/views/preview.js +9 -9
  211. package/dist/registry/views/static/index.d.ts +2 -2
  212. package/dist/registry/views/static/index.js +3 -3
  213. package/dist/registry/views/static/info.d.ts +2 -2
  214. package/dist/registry/views/static/info.js +15 -4
  215. package/dist/registry/views/static/style.d.ts +2 -2
  216. package/dist/registry/views/static/style.js +3 -3
  217. package/dist/resources/index.d.ts +134 -134
  218. package/dist/resources/index.js +145 -145
  219. package/dist/resources/settings.d.ts +17 -17
  220. package/dist/resources/settings.js +18 -18
  221. package/dist/types.d.ts +287 -285
  222. package/dist/types.js +2 -2
  223. package/dist/utils/clean-require.d.ts +16 -16
  224. package/dist/utils/clean-require.js +18 -18
  225. package/dist/utils/date-stringify.d.ts +1 -1
  226. package/dist/utils/date-stringify.js +22 -22
  227. package/dist/utils/error-to-string.d.ts +1 -1
  228. package/dist/utils/error-to-string.js +15 -15
  229. package/dist/utils/is-template-legacy.d.ts +3 -3
  230. package/dist/utils/is-template-legacy.js +6 -6
  231. package/dist/utils/is-template-valid.d.ts +4 -4
  232. package/dist/utils/is-template-valid.js +12 -12
  233. package/dist/utils/module-exists.d.ts +1 -1
  234. package/dist/utils/module-exists.js +15 -15
  235. package/dist/utils/npm-utils.d.ts +20 -22
  236. package/dist/utils/npm-utils.js +74 -63
  237. package/dist/utils/put.d.ts +2 -1
  238. package/dist/utils/put.js +29 -48
  239. package/dist/utils/strip-version.d.ts +1 -1
  240. package/dist/utils/strip-version.js +11 -11
  241. package/logintervals.md +1 -1
  242. package/package.json +6 -1
  243. package/src/cli/domain/clean.ts +10 -20
  244. package/src/cli/domain/get-components-by-dir.ts +12 -26
  245. package/src/cli/domain/get-mocked-plugins.ts +32 -26
  246. package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +8 -12
  247. package/src/cli/domain/handle-dependencies/get-compiler.ts +8 -11
  248. package/src/cli/domain/handle-dependencies/index.ts +55 -109
  249. package/src/cli/domain/handle-dependencies/install-compiler.ts +22 -15
  250. package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +19 -13
  251. package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +8 -16
  252. package/src/cli/domain/init-template/index.ts +13 -20
  253. package/src/cli/domain/init-template/install-template.ts +11 -12
  254. package/src/cli/domain/init-template/scaffold.ts +9 -12
  255. package/src/cli/domain/local.ts +19 -22
  256. package/src/cli/domain/mock.ts +32 -36
  257. package/src/cli/domain/package-components.ts +14 -25
  258. package/src/cli/domain/registry.ts +80 -116
  259. package/src/cli/domain/watch.ts +1 -1
  260. package/src/cli/facade/clean.ts +37 -37
  261. package/src/cli/facade/dev.ts +159 -182
  262. package/src/cli/facade/init.ts +36 -38
  263. package/src/cli/facade/mock.ts +11 -10
  264. package/src/cli/facade/package.ts +44 -49
  265. package/src/cli/facade/preview.ts +20 -18
  266. package/src/cli/facade/publish.ts +134 -172
  267. package/src/cli/facade/registry-add.ts +16 -15
  268. package/src/cli/facade/registry-ls.ts +27 -22
  269. package/src/cli/facade/registry-remove.ts +16 -15
  270. package/src/cli/facade/registry.ts +7 -5
  271. package/src/cli/index.ts +3 -5
  272. package/src/components/oc-client/_package/package.json +1 -1
  273. package/src/components/oc-client/package.json +1 -1
  274. package/src/globals.d.ts +38 -0
  275. package/src/oc-cli.js +0 -0
  276. package/src/registry/app-start.ts +27 -31
  277. package/src/registry/domain/authentication.ts +5 -13
  278. package/src/registry/domain/components-cache/components-list.ts +45 -67
  279. package/src/registry/domain/components-cache/index.ts +55 -60
  280. package/src/registry/domain/components-details.ts +49 -75
  281. package/src/registry/domain/extract-package.ts +19 -27
  282. package/src/registry/domain/get-package-json-from-temp-dir.ts +3 -4
  283. package/src/registry/domain/nested-renderer.ts +64 -122
  284. package/src/registry/domain/options-sanitiser.ts +6 -3
  285. package/src/registry/domain/plugins-initialiser.ts +45 -49
  286. package/src/registry/domain/repository.ts +129 -235
  287. package/src/registry/domain/require-wrapper.ts +1 -2
  288. package/src/registry/domain/storage-adapter.ts +85 -0
  289. package/src/registry/index.ts +48 -79
  290. package/src/registry/middleware/index.ts +10 -2
  291. package/src/registry/router.ts +2 -10
  292. package/src/registry/routes/component-info.ts +4 -3
  293. package/src/registry/routes/component-preview.ts +3 -2
  294. package/src/registry/routes/components.ts +1 -1
  295. package/src/registry/routes/helpers/get-component-fallback.ts +3 -9
  296. package/src/registry/routes/helpers/get-component.ts +11 -9
  297. package/src/registry/routes/helpers/is-url-discoverable.ts +14 -15
  298. package/src/registry/routes/index.ts +18 -13
  299. package/src/registry/routes/publish.ts +31 -34
  300. package/src/registry/views/info.ts +5 -2
  301. package/src/registry/views/static/info.ts +12 -1
  302. package/src/resources/settings.ts +1 -1
  303. package/src/types.ts +80 -141
  304. package/src/utils/npm-utils.ts +38 -37
  305. package/src/utils/put.ts +15 -37
@@ -1,95 +1,59 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const async_1 = __importDefault(require("async"));
7
- const lodash_1 = __importDefault(require("lodash"));
8
- const settings_1 = __importDefault(require("../../resources/settings"));
9
- const resources_1 = __importDefault(require("../../resources"));
10
- const sanitise = {
11
- componentParams(component, options, callback) {
12
- return {
13
- ...sanitise.options(options, callback),
14
- componentName: component
15
- };
16
- },
17
- componentsParams(components, options, callback) {
18
- return {
19
- ...sanitise.options(options, callback),
20
- components: components
21
- };
22
- },
23
- headers(h = {}) {
24
- return {
25
- ...h,
26
- accept: settings_1.default.registry.acceptRenderedHeader
27
- };
28
- },
29
- options(options, callback) {
30
- const cb = !callback && typeof options === 'function' ? options : callback;
31
- const opts = typeof options === 'function' ? {} : options;
32
- return { callback: cb, options: opts };
33
- }
34
- };
35
- const validate = {
36
- callback(c) {
37
- if (!c || typeof c !== 'function') {
38
- throw new Error(resources_1.default.errors.registry.NESTED_RENDERER_CALLBACK_IS_NOT_VALID);
39
- }
40
- },
41
- componentParams(params) {
42
- if (!params.componentName) {
43
- throw new Error(resources_1.default.errors.registry.NESTED_RENDERER_COMPONENT_NAME_IS_NOT_VALID);
44
- }
45
- validate.callback(params.callback);
46
- },
47
- componentsParams(params) {
48
- if (lodash_1.default.isEmpty(params.components)) {
49
- throw new Error(resources_1.default.errors.registry.NESTED_RENDERER_COMPONENTS_IS_NOT_VALID);
50
- }
51
- validate.callback(params.callback);
52
- }
53
- };
54
- function nestedRenderer(renderer, conf) {
55
- return {
56
- renderComponent(componentName, renderOptions, callback) {
57
- const p = sanitise.componentParams(componentName, renderOptions, callback);
58
- validate.componentParams(p);
59
- return renderer({
60
- conf: conf,
61
- headers: sanitise.headers(p.options.headers),
62
- name: componentName,
63
- parameters: p.options.parameters || {},
64
- version: p.options.version || ''
65
- }, (result) => {
66
- if (result.response.error) {
67
- return p.callback(result.response.error, undefined);
68
- }
69
- else {
70
- return p.callback(null, result.response.html);
71
- }
72
- });
73
- },
74
- renderComponents(components, renderOptions, callback) {
75
- const p = sanitise.componentsParams(components, renderOptions, callback);
76
- validate.componentsParams(p);
77
- async_1.default.map(p.components, (component, cb) => {
78
- renderer({
79
- conf: conf,
80
- headers: sanitise.headers(p.options.headers),
81
- name: component.name,
82
- parameters: {
83
- ...p.options.parameters,
84
- ...component.parameters
85
- },
86
- version: component.version || ''
87
- }, (result) => {
88
- const error = result.response.error;
89
- cb(null, error ? new Error(error) : result.response.html);
90
- });
91
- }, p.callback);
92
- }
93
- };
94
- }
95
- exports.default = nestedRenderer;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const settings_1 = __importDefault(require("../../resources/settings"));
7
+ const resources_1 = __importDefault(require("../../resources"));
8
+ function nestedRenderer(rendererWithCallback, conf) {
9
+ const renderer = (options) => new Promise((res, rej) => {
10
+ rendererWithCallback(options, result => {
11
+ if (result.response.error) {
12
+ rej(result.response.error);
13
+ }
14
+ else {
15
+ res(result.response.html);
16
+ }
17
+ });
18
+ });
19
+ return {
20
+ renderComponent(componentName, options = {}) {
21
+ if (!componentName) {
22
+ throw new Error(resources_1.default.errors.registry.NESTED_RENDERER_COMPONENT_NAME_IS_NOT_VALID);
23
+ }
24
+ return renderer({
25
+ conf: conf,
26
+ ip: options.ip || '',
27
+ headers: {
28
+ ...options.headers,
29
+ accept: settings_1.default.registry.acceptRenderedHeader
30
+ },
31
+ name: componentName,
32
+ parameters: options.parameters || {},
33
+ version: options.version || ''
34
+ });
35
+ },
36
+ renderComponents(components, options = {}) {
37
+ if (!components || !components.length) {
38
+ throw new Error(resources_1.default.errors.registry.NESTED_RENDERER_COMPONENTS_IS_NOT_VALID);
39
+ }
40
+ return Promise.all(components.map(component => {
41
+ return renderer({
42
+ conf: conf,
43
+ headers: {
44
+ ...options.headers,
45
+ accept: settings_1.default.registry.acceptRenderedHeader
46
+ },
47
+ ip: component.ip || '',
48
+ name: component.name,
49
+ parameters: {
50
+ ...options.parameters,
51
+ ...component.parameters
52
+ },
53
+ version: component.version || ''
54
+ }).catch(err => new Error(err));
55
+ }));
56
+ }
57
+ };
58
+ }
59
+ exports.default = nestedRenderer;
@@ -1,6 +1,6 @@
1
- import { Config } from '../../types';
2
- interface Input extends Partial<Omit<Config, 'beforePublish'>> {
3
- baseUrl: string;
4
- }
5
- export default function optionsSanitiser(input: Input): Config;
6
- export {};
1
+ import { Config } from '../../types';
2
+ interface Input extends Partial<Omit<Config, 'beforePublish'>> {
3
+ baseUrl: string;
4
+ }
5
+ export default function optionsSanitiser(input: Input): Config;
6
+ export {};
@@ -1,104 +1,106 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const lodash_1 = __importDefault(require("lodash"));
26
- const settings_1 = __importDefault(require("../../resources/settings"));
27
- const auth = __importStar(require("./authentication"));
28
- const DEFAULT_NODE_KEEPALIVE_MS = 5000;
29
- function optionsSanitiser(input) {
30
- const options = lodash_1.default.clone(input);
31
- if (!options.publishAuth) {
32
- options.beforePublish = (_req, _res, next) => next();
33
- }
34
- else {
35
- options.beforePublish = auth.middleware(options.publishAuth);
36
- }
37
- if (!options.publishValidation) {
38
- options.publishValidation = () => ({
39
- isValid: true
40
- });
41
- }
42
- if (!options.prefix) {
43
- options.prefix = '/';
44
- }
45
- const hasTrailingPrefix = new RegExp(options.prefix + '$');
46
- if (!options.baseUrl.match(hasTrailingPrefix)) {
47
- options.baseUrl = options.baseUrl.replace(/\/$/, '') + options.prefix;
48
- }
49
- if (!options.tempDir) {
50
- options.tempDir = settings_1.default.registry.defaultTempPath;
51
- }
52
- if (typeof options.hotReloading !== 'boolean') {
53
- options.hotReloading = !!options.local;
54
- }
55
- if (!options.verbosity) {
56
- options.verbosity = 0;
57
- }
58
- if (typeof options.discovery === 'undefined') {
59
- options.discovery = true;
60
- }
61
- if (typeof options.pollingInterval === 'undefined') {
62
- options.pollingInterval = 5;
63
- }
64
- if (!options.templates) {
65
- options.templates = [];
66
- }
67
- if (typeof options.fallbackRegistryUrl !== 'undefined' &&
68
- lodash_1.default.last(options.fallbackRegistryUrl) !== '/') {
69
- options.fallbackRegistryUrl += '/';
70
- }
71
- options.customHeadersToSkipOnWeakVersion = (options.customHeadersToSkipOnWeakVersion || []).map(s => s.toLowerCase());
72
- options.port = options.port || process.env['PORT'] || 3000;
73
- options.timeout = options.timeout || 1000 * 60 * 2;
74
- options.keepAliveTimeout =
75
- options.keepAliveTimeout || DEFAULT_NODE_KEEPALIVE_MS;
76
- if (options.s3) {
77
- options.storage = {
78
- adapter: require('oc-s3-storage-adapter'),
79
- options: options.s3
80
- };
81
- }
82
- if (options.storage && !options.storage.adapter) {
83
- options.storage.adapter = require('oc-s3-storage-adapter');
84
- }
85
- if (options.refreshInterval && options.storage) {
86
- options.storage.options['refreshInterval'] = options.refreshInterval;
87
- }
88
- if (options.verbosity && options.storage) {
89
- options.storage.options['verbosity'] = options.verbosity;
90
- }
91
- if (options.storage &&
92
- options.storage.options &&
93
- options.storage.options['path']) {
94
- options.storage.options['path'] =
95
- options.storage.options['path'].indexOf('http') === 0
96
- ? options.storage.options['path']
97
- : `https:${options.storage.options['path']}`;
98
- }
99
- if (!options.env) {
100
- options.env = {};
101
- }
102
- return options;
103
- }
104
- exports.default = optionsSanitiser;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const settings_1 = __importDefault(require("../../resources/settings"));
26
+ const auth = __importStar(require("./authentication"));
27
+ const DEFAULT_NODE_KEEPALIVE_MS = 5000;
28
+ function optionsSanitiser(input) {
29
+ const options = { ...input };
30
+ if (!options.publishAuth) {
31
+ options.beforePublish = (_req, _res, next) => next();
32
+ }
33
+ else {
34
+ options.beforePublish = auth.middleware(options.publishAuth);
35
+ }
36
+ if (!options.publishValidation) {
37
+ options.publishValidation = () => ({
38
+ isValid: true
39
+ });
40
+ }
41
+ if (!options.prefix) {
42
+ options.prefix = '/';
43
+ }
44
+ const hasTrailingPrefix = new RegExp(options.prefix + '$');
45
+ if (!options.baseUrl.match(hasTrailingPrefix)) {
46
+ options.baseUrl = options.baseUrl.replace(/\/$/, '') + options.prefix;
47
+ }
48
+ if (!options.tempDir) {
49
+ options.tempDir = settings_1.default.registry.defaultTempPath;
50
+ }
51
+ if (typeof options.hotReloading !== 'boolean') {
52
+ options.hotReloading = !!options.local;
53
+ }
54
+ if (!options.verbosity) {
55
+ options.verbosity = 0;
56
+ }
57
+ if (typeof options.discovery === 'undefined') {
58
+ options.discovery = true;
59
+ }
60
+ if (typeof options.pollingInterval === 'undefined') {
61
+ options.pollingInterval = 5;
62
+ }
63
+ if (!options.templates) {
64
+ options.templates = [];
65
+ }
66
+ if (!options.dependencies) {
67
+ options.dependencies = [];
68
+ }
69
+ if (typeof options.fallbackRegistryUrl !== 'undefined' &&
70
+ !options.fallbackRegistryUrl.endsWith('/')) {
71
+ options.fallbackRegistryUrl += '/';
72
+ }
73
+ options.customHeadersToSkipOnWeakVersion = (options.customHeadersToSkipOnWeakVersion || []).map(s => s.toLowerCase());
74
+ options.port = options.port || process.env['PORT'] || 3000;
75
+ options.timeout = options.timeout || 1000 * 60 * 2;
76
+ options.keepAliveTimeout =
77
+ options.keepAliveTimeout || DEFAULT_NODE_KEEPALIVE_MS;
78
+ if (options.s3) {
79
+ options.storage = {
80
+ adapter: require('oc-s3-storage-adapter'),
81
+ options: options.s3
82
+ };
83
+ }
84
+ if (options.storage && !options.storage.adapter) {
85
+ options.storage.adapter = require('oc-s3-storage-adapter');
86
+ }
87
+ if (options.refreshInterval && options.storage) {
88
+ options.storage.options['refreshInterval'] = options.refreshInterval;
89
+ }
90
+ if (options.verbosity && options.storage) {
91
+ options.storage.options['verbosity'] = options.verbosity;
92
+ }
93
+ if (options.storage &&
94
+ options.storage.options &&
95
+ options.storage.options['path']) {
96
+ options.storage.options['path'] =
97
+ options.storage.options['path'].indexOf('http') === 0
98
+ ? options.storage.options['path']
99
+ : `https:${options.storage.options['path']}`;
100
+ }
101
+ if (!options.env) {
102
+ options.env = {};
103
+ }
104
+ return options;
105
+ }
106
+ exports.default = optionsSanitiser;
@@ -1 +1,3 @@
1
- export declare function init(pluginsToRegister: unknown[], callback: (err: unknown, data: Record<string, (...args: unknown[]) => void>) => void): void;
1
+ declare type PluginFunctions = Record<string, (...args: unknown[]) => void>;
2
+ export declare function init(pluginsToRegister: unknown[]): Promise<PluginFunctions>;
3
+ export {};
@@ -1,99 +1,95 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.init = void 0;
7
- const async_1 = __importDefault(require("async"));
8
- const lodash_1 = __importDefault(require("lodash"));
9
- const dependency_graph_1 = require("dependency-graph");
10
- const resources_1 = __importDefault(require("../../resources"));
11
- function validatePlugins(plugins) {
12
- let c = 0;
13
- plugins.forEach(plugin => {
14
- c++;
15
- if (!lodash_1.default.isObject(plugin.register) ||
16
- typeof plugin.register.register !== 'function' ||
17
- typeof plugin.register.execute !== 'function' ||
18
- typeof plugin.name !== 'string') {
19
- throw new Error(resources_1.default.errors.registry.PLUGIN_NOT_VALID(plugin.name || String(c)));
20
- }
21
- });
22
- }
23
- function checkDependencies(plugins) {
24
- const graph = new dependency_graph_1.DepGraph();
25
- plugins.forEach(p => graph.addNode(p.name));
26
- plugins.forEach(p => {
27
- if (!p.register.dependencies) {
28
- return;
29
- }
30
- p.register.dependencies.forEach(d => {
31
- try {
32
- graph.addDependency(p.name, d);
33
- }
34
- catch (err) {
35
- throw new Error(`unknown plugin dependency: ${d}`);
36
- }
37
- });
38
- });
39
- return graph.overallOrder();
40
- }
41
- let deferredLoads = [];
42
- const defer = function (plugin, cb) {
43
- deferredLoads.push(plugin);
44
- return cb();
45
- };
46
- function init(pluginsToRegister, callback) {
47
- const registered = {};
48
- try {
49
- validatePlugins(pluginsToRegister);
50
- checkDependencies(pluginsToRegister);
51
- }
52
- catch (err) {
53
- return callback(err, undefined);
54
- }
55
- const dependenciesRegistered = (dependencies) => {
56
- if (dependencies.length === 0) {
57
- return true;
58
- }
59
- let present = true;
60
- dependencies.forEach(d => {
61
- if (!registered[d]) {
62
- present = false;
63
- }
64
- });
65
- return present;
66
- };
67
- const loadPlugin = (plugin, cb) => {
68
- const done = lodash_1.default.once(cb);
69
- if (registered[plugin.name]) {
70
- return done();
71
- }
72
- if (!plugin.register.dependencies) {
73
- plugin.register.dependencies = [];
74
- }
75
- if (!dependenciesRegistered(plugin.register.dependencies)) {
76
- return defer(plugin, done);
77
- }
78
- const dependencies = lodash_1.default.pick(registered, plugin.register.dependencies);
79
- plugin.register.register(plugin.options || {}, dependencies, (err) => {
80
- const pluginCallback = plugin.callback || lodash_1.default.noop;
81
- pluginCallback(err);
82
- // Overriding toString so implementation details of plugins do not
83
- // leak to OC consumers
84
- plugin.register.execute.toString = () => plugin.description || '';
85
- registered[plugin.name] = plugin.register.execute;
86
- done(err);
87
- });
88
- };
89
- const terminator = function (err) {
90
- if (deferredLoads.length > 0) {
91
- const deferredPlugins = lodash_1.default.clone(deferredLoads);
92
- deferredLoads = [];
93
- return async_1.default.mapSeries(deferredPlugins, loadPlugin, terminator);
94
- }
95
- callback(err, registered);
96
- };
97
- async_1.default.mapSeries(pluginsToRegister, loadPlugin, terminator);
98
- }
99
- exports.init = init;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
7
+ const p_limit_1 = __importDefault(require("p-limit"));
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const dependency_graph_1 = require("dependency-graph");
10
+ const util_1 = require("util");
11
+ const resources_1 = __importDefault(require("../../resources"));
12
+ function validatePlugins(plugins) {
13
+ for (let idx = 0; idx < plugins.length; idx++) {
14
+ const plugin = plugins[idx];
15
+ if (!lodash_1.default.isObject(plugin.register) ||
16
+ typeof plugin.register.register !== 'function' ||
17
+ typeof plugin.register.execute !== 'function' ||
18
+ typeof plugin.name !== 'string') {
19
+ throw new Error(resources_1.default.errors.registry.PLUGIN_NOT_VALID(plugin.name || String(idx + 1)));
20
+ }
21
+ }
22
+ }
23
+ function checkDependencies(plugins) {
24
+ const graph = new dependency_graph_1.DepGraph();
25
+ plugins.forEach(p => graph.addNode(p.name));
26
+ plugins.forEach(p => {
27
+ if (!p.register.dependencies) {
28
+ return;
29
+ }
30
+ p.register.dependencies.forEach(d => {
31
+ try {
32
+ graph.addDependency(p.name, d);
33
+ }
34
+ catch (err) {
35
+ throw new Error(`unknown plugin dependency: ${d}`);
36
+ }
37
+ });
38
+ });
39
+ return graph.overallOrder();
40
+ }
41
+ let deferredLoads = [];
42
+ async function init(pluginsToRegister) {
43
+ const registered = {};
44
+ validatePlugins(pluginsToRegister);
45
+ checkDependencies(pluginsToRegister);
46
+ const dependenciesRegistered = (dependencies) => {
47
+ if (dependencies.length === 0) {
48
+ return true;
49
+ }
50
+ let present = true;
51
+ dependencies.forEach(d => {
52
+ if (!registered[d]) {
53
+ present = false;
54
+ }
55
+ });
56
+ return present;
57
+ };
58
+ const loadPlugin = async (plugin) => {
59
+ if (registered[plugin.name]) {
60
+ return;
61
+ }
62
+ if (!plugin.register.dependencies) {
63
+ plugin.register.dependencies = [];
64
+ }
65
+ if (!dependenciesRegistered(plugin.register.dependencies)) {
66
+ deferredLoads.push(plugin);
67
+ return;
68
+ }
69
+ const dependencies = lodash_1.default.pick(registered, plugin.register.dependencies);
70
+ const register = (0, util_1.promisify)(plugin.register.register);
71
+ const pluginCallback = plugin.callback || lodash_1.default.noop;
72
+ await register(plugin.options || {}, dependencies).catch(err => {
73
+ pluginCallback(err);
74
+ throw err;
75
+ });
76
+ // Overriding toString so implementation details of plugins do not
77
+ // leak to OC consumers
78
+ plugin.register.execute.toString = () => plugin.description || '';
79
+ registered[plugin.name] = plugin.register.execute;
80
+ pluginCallback();
81
+ };
82
+ const terminator = async () => {
83
+ if (deferredLoads.length > 0) {
84
+ const deferredPlugins = lodash_1.default.clone(deferredLoads);
85
+ deferredLoads = [];
86
+ await Promise.all(deferredPlugins.map(plugin => onSeries(() => loadPlugin(plugin))));
87
+ return terminator();
88
+ }
89
+ return registered;
90
+ };
91
+ const onSeries = (0, p_limit_1.default)(1);
92
+ await Promise.all(pluginsToRegister.map(plugin => onSeries(() => loadPlugin(plugin))));
93
+ return terminator();
94
+ }
95
+ exports.init = init;
@@ -1,5 +1,5 @@
1
- import { Template, TemplateInfo } from '../../types';
2
- export default function registerTemplates(extraTemplates: Template[]): {
3
- templatesHash: Record<string, Template>;
4
- templatesInfo: TemplateInfo[];
5
- };
1
+ import { Template, TemplateInfo } from '../../types';
2
+ export default function registerTemplates(extraTemplates: Template[]): {
3
+ templatesHash: Record<string, Template>;
4
+ templatesInfo: TemplateInfo[];
5
+ };