@fontoxml/fontoxml-development-tools 3.11.0 → 3.12.0-beta.1

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 (196) hide show
  1. package/npm-shrinkwrap.json +3841 -8329
  2. package/package.json +13 -19
  3. package/src/App.js +1 -1
  4. package/src/FdtCommand.js +3 -3
  5. package/src/FdtLicense.js +95 -114
  6. package/src/ModuleRegistrationApi.js +44 -16
  7. package/src/addCoreModulesToApp.js +8 -0
  8. package/src/modules/connectors/index.js +109 -16
  9. package/src/modules/connectors/instanceBuild/Dockerfile.build +1 -1
  10. package/src/modules/connectors/instanceBuild/Dockerfile.run +1 -1
  11. package/src/modules/connectors/instanceDevBuild/docker-compose.yml +2 -2
  12. package/src/modules/content-quality/index.js +101 -20
  13. package/src/modules/content-quality/instanceBuild/Dockerfile +1 -1
  14. package/src/modules/content-quality/instanceDevBuild/docker-compose.yml +1 -1
  15. package/src/modules/core/src/precontroller.help.js +23 -26
  16. package/src/modules/document-history/index.js +101 -20
  17. package/src/modules/document-history/instanceBuild/Dockerfile +1 -1
  18. package/src/modules/document-history/instanceDevBuild/docker-compose.yml +1 -1
  19. package/src/modules/editor/dev-cms/connectors-cms-standard/configureConnectorsCmsStandardDocumentRouter.js +10 -0
  20. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentHistoryGetPostRouteHandler.js +51 -0
  21. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPostRouteHandler.js +65 -76
  22. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPresearchPostRouteHandler.js +10 -7
  23. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentPreviewRouteHandler.js +10 -0
  24. package/src/modules/editor/dev-cms/connectors-cms-standard/configureDocumentRevisionGetPostRouteHandler.js +69 -0
  25. package/src/modules/editor/src/commands/command.convert.editor.controller.js +11 -4
  26. package/src/modules/editor/src/commands/command.convert.package.controller.js +11 -4
  27. package/src/modules/editor/src/getWebpackConfig.js +13 -0
  28. package/src/modules/editor/src/webpackPlugins/CheckDeepImportsResolvePlugin.js +4 -0
  29. package/src/modules/editor-pre-7-7-0/src/api/downloadEditorSDK.js +16 -12
  30. package/src/modules/editor-pre-7-7-0/src/api/executeAndLog.js +3 -2
  31. package/src/modules/editor-pre-7-7-0/src/api/schema/compile.js +16 -22
  32. package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaPackages.js +8 -0
  33. package/src/modules/editor-pre-7-7-0/src/api/schema/getSchemaFontoJson.js +76 -48
  34. package/src/modules/editor-pre-7-7-0/src/command.schema.compile.controller.js +51 -2
  35. package/src/modules/editor-pre-7-7-0/test/api/schema/buildSchemaExperienceConfigurationModel.test.js +70 -79
  36. package/src/modules/editor-pre-7-7-0/test/api/schema/fixtures/invalid-fonto-json/fonto.json +1 -0
  37. package/src/modules/editor-pre-7-7-0/test/api/schema/getSchemaFontoJson.test.js +174 -0
  38. package/src/modules/editor-pre-7-7-0/test/schemaCompileController.test.js +205 -0
  39. package/src/modules/localization/index.js +2 -2
  40. package/src/modules/operations/src/api/getOperations.js +3 -3
  41. package/src/modules/review/index.js +103 -18
  42. package/src/modules/review/instanceBuild/Dockerfile +1 -1
  43. package/src/modules/review/instanceDevBuild/docker-compose.yml +1 -1
  44. package/src/modules/schema/src/api/getSchemaSummaries.js +2 -2
  45. package/src/modules/schema/test/getSchemaSummaries.test.js +14 -10
  46. package/src/modules/schema-compiler/index.js +99 -18
  47. package/src/modules/schema-compiler/instanceBuild/Dockerfile +1 -1
  48. package/src/modules/schema-compiler/instanceDevBuild/docker-compose.yml +1 -1
  49. package/src/modules/shared/index.js +3 -0
  50. package/src/modules/shared/package.json +14 -0
  51. package/src/modules/shared/src/addBackendDockerCommands.js +334 -0
  52. package/src/modules/shared/src/addBackendDownloadSelfContainedCommands.js +78 -0
  53. package/src/modules/shared/src/addBackendVersionsCommands.js +55 -0
  54. package/src/modules/shared/src/controller-templates/command.backend.build.controller.factory.js +273 -0
  55. package/src/modules/shared/src/controller-templates/command.backend.download-self-contained.controller.factory.js +131 -0
  56. package/src/modules/shared/src/controller-templates/command.backend.init.controller.factory.js +88 -0
  57. package/src/modules/shared/src/controller-templates/command.backend.run.controller.factory.js +420 -0
  58. package/src/modules/shared/src/controller-templates/command.backend.upgrade.controller.factory.js +79 -0
  59. package/src/modules/shared/src/controller-templates/command.backend.versions.controller.factory.js +23 -0
  60. package/src/modules/shared/src/controller-templates/docker/BackendManifest.js +42 -0
  61. package/src/modules/shared/src/controller-templates/docker/copyWhitelistedFiles.js +23 -0
  62. package/src/modules/shared/src/controller-templates/docker/dockerCleanup.js +146 -0
  63. package/src/modules/shared/src/controller-templates/docker/tryDockerLogout.js +31 -0
  64. package/src/modules/shared/src/controller-templates/docker/validateBackendInstance.js +48 -0
  65. package/src/modules/shared/src/ensureDockerCommands.js +61 -0
  66. package/src/modules/shared/src/executeAndLog.js +113 -0
  67. package/src/modules/{review/src/utilities/setEntryVisibility.js → shared/src/setFileVisibility.js} +8 -2
  68. package/src/modules/spell-checker/index.js +101 -18
  69. package/src/modules/spell-checker/instanceBuild/Dockerfile +1 -1
  70. package/src/modules/spell-checker/instanceDevBuild/docker-compose.yml +1 -1
  71. package/test/module.shared.test.js +81 -0
  72. package/src/modules/connectors/src/command.build.controller.js +0 -256
  73. package/src/modules/connectors/src/command.build.js +0 -54
  74. package/src/modules/connectors/src/command.download-self-contained.controller.js +0 -110
  75. package/src/modules/connectors/src/command.download-self-contained.js +0 -50
  76. package/src/modules/connectors/src/command.init.controller.js +0 -91
  77. package/src/modules/connectors/src/command.init.js +0 -42
  78. package/src/modules/connectors/src/command.run.controller.js +0 -462
  79. package/src/modules/connectors/src/command.run.js +0 -67
  80. package/src/modules/connectors/src/command.upgrade.controller.js +0 -52
  81. package/src/modules/connectors/src/command.upgrade.js +0 -42
  82. package/src/modules/connectors/src/command.versions.controller.js +0 -14
  83. package/src/modules/connectors/src/command.versions.js +0 -25
  84. package/src/modules/connectors/src/utilities/FontoxmlConnectorsManifest.js +0 -32
  85. package/src/modules/connectors/src/utilities/cleanup.js +0 -70
  86. package/src/modules/connectors/src/utilities/constants.js +0 -42
  87. package/src/modules/connectors/src/utilities/copyWhitelistedFiles.js +0 -22
  88. package/src/modules/connectors/src/utilities/executeAndLog.js +0 -63
  89. package/src/modules/connectors/src/utilities/getVerbosityLevel.js +0 -11
  90. package/src/modules/connectors/src/utilities/getWhitelist.js +0 -16
  91. package/src/modules/connectors/src/utilities/setEntryVisibility.js +0 -22
  92. package/src/modules/connectors/src/utilities/validateInstance.js +0 -29
  93. package/src/modules/content-quality/src/command.build.controller.js +0 -260
  94. package/src/modules/content-quality/src/command.build.js +0 -56
  95. package/src/modules/content-quality/src/command.download-self-contained.controller.js +0 -110
  96. package/src/modules/content-quality/src/command.download-self-contained.js +0 -52
  97. package/src/modules/content-quality/src/command.init.controller.js +0 -91
  98. package/src/modules/content-quality/src/command.init.js +0 -44
  99. package/src/modules/content-quality/src/command.run.controller.js +0 -444
  100. package/src/modules/content-quality/src/command.run.js +0 -64
  101. package/src/modules/content-quality/src/command.upgrade.controller.js +0 -52
  102. package/src/modules/content-quality/src/command.upgrade.js +0 -44
  103. package/src/modules/content-quality/src/command.versions.controller.js +0 -14
  104. package/src/modules/content-quality/src/command.versions.js +0 -25
  105. package/src/modules/content-quality/src/utilities/FontoxmlFcqManifest.js +0 -30
  106. package/src/modules/content-quality/src/utilities/cleanup.js +0 -70
  107. package/src/modules/content-quality/src/utilities/constants.js +0 -44
  108. package/src/modules/content-quality/src/utilities/copyWhitelistedFiles.js +0 -22
  109. package/src/modules/content-quality/src/utilities/executeAndLog.js +0 -63
  110. package/src/modules/content-quality/src/utilities/getVerbosityLevel.js +0 -11
  111. package/src/modules/content-quality/src/utilities/getWhitelist.js +0 -16
  112. package/src/modules/content-quality/src/utilities/setEntryVisibility.js +0 -22
  113. package/src/modules/content-quality/src/utilities/validateInstance.js +0 -29
  114. package/src/modules/document-history/src/command.build.controller.js +0 -260
  115. package/src/modules/document-history/src/command.build.js +0 -56
  116. package/src/modules/document-history/src/command.download-self-contained.controller.js +0 -110
  117. package/src/modules/document-history/src/command.download-self-contained.js +0 -50
  118. package/src/modules/document-history/src/command.init.controller.js +0 -91
  119. package/src/modules/document-history/src/command.init.js +0 -44
  120. package/src/modules/document-history/src/command.run.controller.js +0 -444
  121. package/src/modules/document-history/src/command.run.js +0 -64
  122. package/src/modules/document-history/src/command.upgrade.controller.js +0 -52
  123. package/src/modules/document-history/src/command.upgrade.js +0 -44
  124. package/src/modules/document-history/src/command.versions.controller.js +0 -14
  125. package/src/modules/document-history/src/command.versions.js +0 -25
  126. package/src/modules/document-history/src/utilities/FontoxmlFdhManifest.js +0 -30
  127. package/src/modules/document-history/src/utilities/cleanup.js +0 -70
  128. package/src/modules/document-history/src/utilities/constants.js +0 -44
  129. package/src/modules/document-history/src/utilities/copyWhitelistedFiles.js +0 -22
  130. package/src/modules/document-history/src/utilities/executeAndLog.js +0 -63
  131. package/src/modules/document-history/src/utilities/getVerbosityLevel.js +0 -11
  132. package/src/modules/document-history/src/utilities/getWhitelist.js +0 -16
  133. package/src/modules/document-history/src/utilities/setEntryVisibility.js +0 -22
  134. package/src/modules/document-history/src/utilities/validateInstance.js +0 -29
  135. package/src/modules/review/src/command.build.controller.js +0 -256
  136. package/src/modules/review/src/command.build.js +0 -54
  137. package/src/modules/review/src/command.download-self-contained.controller.js +0 -107
  138. package/src/modules/review/src/command.download-self-contained.js +0 -50
  139. package/src/modules/review/src/command.init.controller.js +0 -89
  140. package/src/modules/review/src/command.init.js +0 -42
  141. package/src/modules/review/src/command.run.controller.js +0 -428
  142. package/src/modules/review/src/command.run.js +0 -60
  143. package/src/modules/review/src/command.upgrade.controller.js +0 -59
  144. package/src/modules/review/src/command.upgrade.js +0 -42
  145. package/src/modules/review/src/command.versions.controller.js +0 -12
  146. package/src/modules/review/src/command.versions.js +0 -25
  147. package/src/modules/review/src/utilities/FontoxmlReviewManifest.js +0 -30
  148. package/src/modules/review/src/utilities/cleanup.js +0 -70
  149. package/src/modules/review/src/utilities/constants.js +0 -42
  150. package/src/modules/review/src/utilities/copyWhitelistedFiles.js +0 -22
  151. package/src/modules/review/src/utilities/executeAndLog.js +0 -63
  152. package/src/modules/review/src/utilities/getVerbosityLevel.js +0 -11
  153. package/src/modules/review/src/utilities/getWhitelist.js +0 -16
  154. package/src/modules/review/src/utilities/validateInstance.js +0 -45
  155. package/src/modules/schema-compiler/src/command.build.controller.js +0 -256
  156. package/src/modules/schema-compiler/src/command.build.js +0 -54
  157. package/src/modules/schema-compiler/src/command.download-self-contained.controller.js +0 -110
  158. package/src/modules/schema-compiler/src/command.download-self-contained.js +0 -50
  159. package/src/modules/schema-compiler/src/command.init.controller.js +0 -91
  160. package/src/modules/schema-compiler/src/command.init.js +0 -42
  161. package/src/modules/schema-compiler/src/command.run.controller.js +0 -430
  162. package/src/modules/schema-compiler/src/command.run.js +0 -60
  163. package/src/modules/schema-compiler/src/command.upgrade.controller.js +0 -64
  164. package/src/modules/schema-compiler/src/command.upgrade.js +0 -42
  165. package/src/modules/schema-compiler/src/command.versions.controller.js +0 -14
  166. package/src/modules/schema-compiler/src/command.versions.js +0 -25
  167. package/src/modules/schema-compiler/src/utilities/FontoxmlSchemaCompilerManifest.js +0 -32
  168. package/src/modules/schema-compiler/src/utilities/cleanup.js +0 -70
  169. package/src/modules/schema-compiler/src/utilities/constants.js +0 -43
  170. package/src/modules/schema-compiler/src/utilities/copyWhitelistedFiles.js +0 -22
  171. package/src/modules/schema-compiler/src/utilities/executeAndLog.js +0 -63
  172. package/src/modules/schema-compiler/src/utilities/getVerbosityLevel.js +0 -11
  173. package/src/modules/schema-compiler/src/utilities/getWhitelist.js +0 -16
  174. package/src/modules/schema-compiler/src/utilities/setEntryVisibility.js +0 -22
  175. package/src/modules/schema-compiler/src/utilities/validateInstance.js +0 -47
  176. package/src/modules/spell-checker/src/command.build.controller.js +0 -257
  177. package/src/modules/spell-checker/src/command.build.js +0 -54
  178. package/src/modules/spell-checker/src/command.download-self-contained.controller.js +0 -110
  179. package/src/modules/spell-checker/src/command.download-self-contained.js +0 -50
  180. package/src/modules/spell-checker/src/command.init.controller.js +0 -91
  181. package/src/modules/spell-checker/src/command.init.js +0 -42
  182. package/src/modules/spell-checker/src/command.run.controller.js +0 -430
  183. package/src/modules/spell-checker/src/command.run.js +0 -62
  184. package/src/modules/spell-checker/src/command.upgrade.controller.js +0 -61
  185. package/src/modules/spell-checker/src/command.upgrade.js +0 -42
  186. package/src/modules/spell-checker/src/command.versions.controller.js +0 -14
  187. package/src/modules/spell-checker/src/command.versions.js +0 -25
  188. package/src/modules/spell-checker/src/utilities/FontoxmlSpellCheckerManifest.js +0 -32
  189. package/src/modules/spell-checker/src/utilities/cleanup.js +0 -70
  190. package/src/modules/spell-checker/src/utilities/constants.js +0 -42
  191. package/src/modules/spell-checker/src/utilities/copyWhitelistedFiles.js +0 -22
  192. package/src/modules/spell-checker/src/utilities/executeAndLog.js +0 -63
  193. package/src/modules/spell-checker/src/utilities/getVerbosityLevel.js +0 -11
  194. package/src/modules/spell-checker/src/utilities/getWhitelist.js +0 -16
  195. package/src/modules/spell-checker/src/utilities/setEntryVisibility.js +0 -22
  196. package/src/modules/spell-checker/src/utilities/validateInstance.js +0 -47
@@ -1,25 +1,19 @@
1
1
  import path from 'path';
2
- import xml2js from 'xml2js';
2
+ import { parseXmlDocument } from 'slimdom';
3
3
 
4
- const parseString = xml2js.parseString;
4
+ function createFileNameForNewDocument(content) {
5
+ let rootElementName = null;
5
6
 
6
- function createIdForNewDocument(content, callback) {
7
- parseString(content, function (error, result) {
8
- let rootElementName;
9
- if (!error) {
10
- const rootElements = Object.keys(result);
11
- if (rootElements.length) {
12
- rootElementName = rootElements[0];
13
- }
14
- }
15
-
16
- const timestamp = new Date();
17
- const fileName = `${timestamp.getTime()}${
18
- rootElementName ? `-${rootElementName}` : ''
19
- }.xml`;
7
+ try {
8
+ const document = parseXmlDocument(content);
9
+ rootElementName = document.documentElement.localName;
10
+ } catch (_err) {
11
+ // do nothing
12
+ }
20
13
 
21
- callback(null, fileName);
22
- });
14
+ return `${new Date().getTime()}${
15
+ rootElementName ? `-${rootElementName}` : ''
16
+ }.xml`;
23
17
  }
24
18
 
25
19
  function configureDocumentPostRouteHandler(config) {
@@ -31,68 +25,63 @@ function configureDocumentPostRouteHandler(config) {
31
25
  }
32
26
 
33
27
  const content = req.body.content;
34
- createIdForNewDocument(content, function (_error, fileName) {
35
- const context = req.body.context;
36
- const currentSession = req.getFontoSession(
37
- context.editSessionToken
38
- );
39
- const documentId = path
40
- .join(folderId, fileName)
41
- .replace(/\\/g, '/');
42
- const metadata = req.body.metadata;
43
- const documentContext = {
44
- isLockAcquired: true,
45
- };
46
- documentContext.documentMetadata = metadata;
28
+ const fileName = createFileNameForNewDocument(content);
29
+ const context = req.body.context;
30
+ const currentSession = req.getFontoSession(context.editSessionToken);
31
+ const documentId = path.join(folderId, fileName).replace(/\\/g, '/');
32
+ const metadata = req.body.metadata;
33
+ const documentContext = {
34
+ isLockAcquired: true,
35
+ };
36
+ documentContext.documentMetadata = metadata;
47
37
 
48
- req.cms.createNew(
49
- documentId,
50
- content,
51
- currentSession,
52
- (error, documentId) => {
53
- if (error) {
54
- res.status(400).send(error);
55
- return;
56
- }
38
+ req.cms.createNew(
39
+ documentId,
40
+ content,
41
+ currentSession,
42
+ (error, documentId) => {
43
+ if (error) {
44
+ res.status(400).send(error);
45
+ return;
46
+ }
57
47
 
58
- req.cms.getLatestRevisionId(
59
- documentId,
60
- currentSession.editSessionToken,
61
- (error, revisionId) => {
62
- if (error) {
63
- res.status(500).send(error);
64
- return;
65
- }
48
+ req.cms.getLatestRevisionId(
49
+ documentId,
50
+ currentSession.editSessionToken,
51
+ (error, revisionId) => {
52
+ if (error) {
53
+ res.status(500).send(error);
54
+ return;
55
+ }
66
56
 
67
- const documentLoadLock = {
68
- ...config.documentLoadLock,
69
- ...config.documentLoadLockOverrides[documentId],
70
- };
57
+ const documentLoadLock = {
58
+ ...config.documentLoadLock,
59
+ ...config.documentLoadLockOverrides[documentId],
60
+ };
71
61
 
72
- res.status(201)
73
- .set(
74
- 'content-type',
75
- 'application/json; charset=utf-8'
76
- )
77
- .json({
78
- documentId,
79
- revisionId,
80
- content,
81
- documentContext,
82
- metadata,
83
- lock: {
84
- isLockAcquired:
85
- documentLoadLock.isLockAcquired,
86
- isLockAvailable:
87
- documentLoadLock.isLockAvailable,
88
- reason: documentLoadLock.lockReason,
89
- },
90
- });
91
- }
92
- );
93
- }
94
- );
95
- });
62
+ res.status(201)
63
+ .set(
64
+ 'content-type',
65
+ 'application/json; charset=utf-8'
66
+ )
67
+ .json({
68
+ documentId,
69
+ revisionId,
70
+ content,
71
+ documentContext,
72
+ metadata,
73
+ lock: {
74
+ isLockAcquired:
75
+ documentLoadLock.isLockAcquired,
76
+ isLockAvailable:
77
+ documentLoadLock.isLockAvailable,
78
+ reason: documentLoadLock.lockReason,
79
+ },
80
+ });
81
+ }
82
+ );
83
+ }
84
+ );
96
85
  };
97
86
  }
98
87
 
@@ -1,7 +1,7 @@
1
- import evaluateXPathToBoolean from 'fontoxpath';
2
- import { slimdom, sync } from 'slimdom-sax-parser';
1
+ import fontoxpath from 'fontoxpath';
2
+ import { Node, parseXmlDocument } from 'slimdom';
3
3
 
4
- const { TEXT_NODE, ELEMENT_NODE } = slimdom.Node;
4
+ const { TEXT_NODE, ELEMENT_NODE } = Node;
5
5
 
6
6
  const DEFAULT_FIND_AND_REPLACE_PRESEARCH_CONFIG = {
7
7
  blockElementXPathTest:
@@ -23,7 +23,8 @@ function getSearchableTextForDom(findAndReplacePresearchConfig, dom) {
23
23
 
24
24
  if (
25
25
  node.nodeType !== ELEMENT_NODE ||
26
- evaluateXPathToBoolean(
26
+ // eslint-disable-next-line import/no-named-as-default-member
27
+ fontoxpath.evaluateXPathToBoolean(
27
28
  findAndReplacePresearchConfig.removedElementXPathTest,
28
29
  node
29
30
  )
@@ -34,7 +35,8 @@ function getSearchableTextForDom(findAndReplacePresearchConfig, dom) {
34
35
  }
35
36
 
36
37
  if (
37
- evaluateXPathToBoolean(
38
+ // eslint-disable-next-line import/no-named-as-default-member
39
+ fontoxpath.evaluateXPathToBoolean(
38
40
  findAndReplacePresearchConfig.outOfOrderElementXPathTest,
39
41
  node
40
42
  )
@@ -47,7 +49,8 @@ function getSearchableTextForDom(findAndReplacePresearchConfig, dom) {
47
49
  }
48
50
 
49
51
  if (
50
- evaluateXPathToBoolean(
52
+ // eslint-disable-next-line import/no-named-as-default-member
53
+ fontoxpath.evaluateXPathToBoolean(
51
54
  findAndReplacePresearchConfig.blockElementXPathTest,
52
55
  node
53
56
  )
@@ -95,7 +98,7 @@ function getResultForDocumentId(
95
98
  try {
96
99
  const searchableText = getSearchableTextForDom(
97
100
  findAndReplacePresearchConfig,
98
- sync(content)
101
+ parseXmlDocument(content)
99
102
  );
100
103
  if (!searchableText.match(new RegExp(searchTerm, 'gi'))) {
101
104
  resolve(null);
@@ -1,7 +1,17 @@
1
1
  import PDFDocument from 'pdfkit';
2
2
 
3
+ let warningForDeprecationWasLogged = false;
4
+
3
5
  export default function configureDocumentPreviewRouteHandler(_config) {
4
6
  return (req, res) => {
7
+ // Log Deprecation Warning
8
+ if (!warningForDeprecationWasLogged) {
9
+ console.warn(
10
+ '/n [fontoxml-publication-preview add-on] This API is deprecated and it will be removed in 8.4.0. Please refer to https://documentation.fontoxml.com/latest/upcoming-removals-8-4-167dd6e00dd4 to get more information.'
11
+ );
12
+ warningForDeprecationWasLogged = true;
13
+ }
14
+
5
15
  const pdf = new PDFDocument();
6
16
  pdf.pipe(res);
7
17
 
@@ -0,0 +1,69 @@
1
+ export default function configureDocumentRevisionGetPostRouteHandler() {
2
+ return (req, res) => {
3
+ const documentsRevisions = req.body.documentsRevisions;
4
+ const correlationIdRepository = req.repositories.correlationId;
5
+
6
+ // Because these requests do not originate from the editor, but from another server, we
7
+ // have no edit session token. We do, however, have an correlationId which we may resolve
8
+ // to the editSessionToken used by the corresponding call to the proxy
9
+ const editSessionToken =
10
+ correlationIdRepository.getEditSessionTokenForRequest(req);
11
+
12
+ const documentPromises = documentsRevisions.map((documentRevisions) => {
13
+ const documentId = documentRevisions.documentId;
14
+
15
+ const documentExists = req.cms.existsSync(documentId);
16
+ if (!documentExists) {
17
+ return {
18
+ documentId,
19
+ status: 404,
20
+ };
21
+ }
22
+
23
+ const revisionPromises = documentRevisions.revisionIds.map(
24
+ (revisionId) => {
25
+ return new Promise((resolve, _) => {
26
+ req.cms.loadRevision(
27
+ documentId,
28
+ revisionId,
29
+ editSessionToken,
30
+ (error, content) => {
31
+ const revisionResponse = {
32
+ revisionId,
33
+ };
34
+
35
+ if (error) {
36
+ revisionResponse.status = 404;
37
+ } else {
38
+ revisionResponse.status = 200;
39
+ revisionResponse.revision = {
40
+ content,
41
+ };
42
+ }
43
+ resolve(revisionResponse);
44
+ }
45
+ );
46
+ });
47
+ }
48
+ );
49
+
50
+ return Promise.all(revisionPromises).then((revisions) => {
51
+ return {
52
+ documentId,
53
+ status: 200,
54
+ revisions,
55
+ };
56
+ });
57
+ });
58
+
59
+ Promise.all(documentPromises).then((results) => {
60
+ const response = {
61
+ results,
62
+ };
63
+
64
+ res.status(200)
65
+ .set('content-type', 'application/json; charset=utf-8')
66
+ .json(response);
67
+ });
68
+ };
69
+ }
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs-extra';
2
+ import inquirer from 'inquirer';
2
3
  import path from 'path';
3
4
  import { performance } from 'perf_hooks';
4
- import Confirm from 'prompt-confirm';
5
5
 
6
6
  import convertEditorWithOutput from './api/convertEditorWithOutput.js';
7
7
 
@@ -28,9 +28,16 @@ export default async function editorConvertEditorCommand(req, res) {
28
28
 
29
29
  if (
30
30
  !doNotOverwrite &&
31
- !(await new Confirm(
32
- 'The conversion will overwrite all files in the working directory, are you sure you want to continue?'
33
- ).run())
31
+ !(await inquirer
32
+ .prompt([
33
+ {
34
+ type: 'confirm',
35
+ name: 'confirm',
36
+ message:
37
+ 'The conversion will overwrite all files in the working directory, are you sure you want to continue?',
38
+ },
39
+ ])
40
+ .then((answers) => !!answers.confirm))
34
41
  ) {
35
42
  res.break();
36
43
  res.notice('Aborted');
@@ -1,9 +1,9 @@
1
1
  import fastGlob from 'fast-glob';
2
2
  import fs from 'fs-extra';
3
+ import inquirer from 'inquirer';
3
4
  import pMap from 'p-map';
4
5
  import path from 'path';
5
6
  import { performance } from 'perf_hooks';
6
- import Confirm from 'prompt-confirm';
7
7
 
8
8
  import outputWarningsByFilename from '../helpers/outputWarningsByFilename.js';
9
9
  import prettifyJsFile from '../helpers/prettifyJsFile.js';
@@ -39,9 +39,16 @@ export default async function editorConvertPackageCommand(req, res) {
39
39
 
40
40
  if (
41
41
  !doNotOverwrite &&
42
- !(await new Confirm(
43
- 'The conversion will overwrite all files in the working directory, are you sure you want to continue?'
44
- ).run())
42
+ !(await inquirer
43
+ .prompt([
44
+ {
45
+ type: 'confirm',
46
+ name: 'confirm',
47
+ message:
48
+ 'The conversion will overwrite all files in the working directory, are you sure you want to continue?',
49
+ },
50
+ ])
51
+ .then((answers) => !!answers.confirm))
45
52
  ) {
46
53
  res.break();
47
54
  res.notice('Aborted');
@@ -56,6 +56,15 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
56
56
  srcFolder: picomatch.makeRe(`${paths.srcFolder}**/*`),
57
57
  testAssets: picomatch.makeRe(`${paths.testAssetsFolder}**/*`),
58
58
 
59
+ // Fds imports
60
+ // TODO: Remove backward compatibility, this is for pre 7.16.0 editors.
61
+ platformVendorsFdsImport: picomatch.makeRe(
62
+ `${paths.platformFolder}fontoxml-vendors/src/fds/*`
63
+ ),
64
+ platformLinkedVendorsFdsImport: picomatch.makeRe(
65
+ `${paths.platformLinkedFolder}fontoxml-vendors/src/fds/*`
66
+ ),
67
+
59
68
  // Deep imports
60
69
  platformDeepImport: picomatch.makeRe(
61
70
  `${paths.platformFolder}*/src/*/**/*`
@@ -383,6 +392,10 @@ export default function getWebpackConfig(appConfig, appManifest, options) {
383
392
  regExps.platformDeepImport,
384
393
  regExps.platformLinkedDeepImport,
385
394
  ],
395
+ importPathExcludeRegExps: [
396
+ regExps.platformVendorsFdsImport,
397
+ regExps.platformLinkedVendorsFdsImport,
398
+ ],
386
399
  fdtOutputPlugin,
387
400
  }),
388
401
  ].filter(Boolean),
@@ -84,6 +84,10 @@ export default class CheckDeepImportsResolvePlugin {
84
84
  // Does the import target an undesired path?
85
85
  this.options.importPathRegExps.some((regExp) =>
86
86
  regExp.test(request.path)
87
+ ) &&
88
+ // But does not match an excluded regexp.
89
+ !this.options.importPathExcludeRegExps.some((regExp) =>
90
+ regExp.test(request.path)
87
91
  )
88
92
  ) {
89
93
  // Make the absolute paths easier to read.
@@ -1,4 +1,4 @@
1
- import requestPromise from 'request-promise-native';
1
+ import fetch from 'node-fetch';
2
2
 
3
3
  /**
4
4
  * Download a zipped Fonto Editor SDK.
@@ -44,16 +44,19 @@ export default function downloadEditorSDK(sdkVersion, req, res) {
44
44
  .then((productData) => {
45
45
  const downloadUri =
46
46
  productData.products['editor'].selfContained.uri;
47
- return requestPromise
48
- .get(downloadUri, {
49
- resolveWithFullResponse: true,
50
- simple: false,
51
- encoding: null,
52
- })
53
- .then((response) => {
54
- switch (response.statusCode) {
47
+ return fetch(downloadUri, { method: 'GET' }).then(
48
+ async (response) => {
49
+ switch (response.status) {
55
50
  case 200:
56
- return response.body;
51
+ try {
52
+ return Buffer.from(
53
+ await response.arrayBuffer()
54
+ );
55
+ } catch (_err) {
56
+ throw new Error(
57
+ `Invalid response data from the Fonto Editor SDK server.`
58
+ );
59
+ }
57
60
  case 401:
58
61
  case 403:
59
62
  throw new Error(
@@ -65,9 +68,10 @@ export default function downloadEditorSDK(sdkVersion, req, res) {
65
68
  );
66
69
  default:
67
70
  throw new Error(
68
- `Invalid response from the Fonto Editor SDK server (${response.statusCode}).`
71
+ `Invalid response from the Fonto Editor SDK server (${response.status}).`
69
72
  );
70
73
  }
71
- });
74
+ }
75
+ );
72
76
  });
73
77
  }
@@ -1,6 +1,6 @@
1
+ import { supportsColor } from 'chalk';
1
2
  import cp from 'child_process';
2
3
  import os from 'os';
3
- import supportsColor from 'supports-color';
4
4
 
5
5
  export default (
6
6
  res,
@@ -14,7 +14,8 @@ export default (
14
14
  return new Promise((resolve, reject) => {
15
15
  const errors = [];
16
16
  const env = { ...process.env };
17
- if (supportsColor.stdout) {
17
+
18
+ if (supportsColor) {
18
19
  env.FORCE_COLOR = true;
19
20
  }
20
21
 
@@ -1,5 +1,4 @@
1
- import requestPromise from 'request-promise-native';
2
- import url from 'url';
1
+ import fetch, { File, FormData } from 'node-fetch';
3
2
 
4
3
  /**
5
4
  * Compile a schema zip archive using the schema compile service.
@@ -12,34 +11,29 @@ import url from 'url';
12
11
  export default async (baseUrl, compressedSchema) => {
13
12
  let response;
14
13
  try {
15
- response = await requestPromise.post(
16
- url.resolve(baseUrl, '/api/compile'),
17
- {
18
- formData: {
19
- data: {
20
- options: {
21
- contentType: 'application/zip',
22
- filename: 'schema.zip',
23
- },
24
- value: compressedSchema,
25
- },
26
- },
27
- resolveWithFullResponse: true,
28
- simple: false,
29
- }
14
+ const form = new FormData();
15
+ form.set(
16
+ 'schema',
17
+ new File([compressedSchema], 'schema.zip', {
18
+ type: 'application/zip',
19
+ }),
20
+ 'schema.zip'
30
21
  );
22
+
23
+ const compileUrl = new URL('/api/compile', baseUrl);
24
+ response = await fetch(compileUrl.href, { method: 'POST', body: form });
31
25
  } catch (_error) {
32
26
  throw new Error('Could not connect to the schema compile service.');
33
27
  }
34
28
 
35
- switch (response.statusCode) {
29
+ switch (response.status) {
36
30
  case 200:
37
31
  case 400:
38
32
  try {
39
- return JSON.parse(response.body);
40
- } catch (_error) {
33
+ return await response.json();
34
+ } catch (_err) {
41
35
  throw new Error(
42
- 'Invalid response data from the schema compile service.'
36
+ `Invalid response data from the schema compile service.`
43
37
  );
44
38
  }
45
39
  case 401:
@@ -49,7 +43,7 @@ export default async (baseUrl, compressedSchema) => {
49
43
  );
50
44
  default:
51
45
  throw new Error(
52
- `Invalid response from the schema compile service (${response.statusCode}).`
46
+ `Invalid response from the schema compile service (${response.status}).`
53
47
  );
54
48
  }
55
49
  };
@@ -90,6 +90,14 @@ async function createPackageSchemaLocationsJsFile(
90
90
  ]);
91
91
 
92
92
  await writeAstProgramToFile(schemaLocationsFilePath, schemaLocationsJsAst);
93
+
94
+ await fs.remove(
95
+ path.join(
96
+ packageDirectoryPath,
97
+ 'src',
98
+ useTypeScript ? 'SCHEMA_LOCATIONS.js' : 'SCHEMA_LOCATIONS.ts'
99
+ )
100
+ );
93
101
  }
94
102
 
95
103
  /**
@@ -2,6 +2,80 @@ import fs from 'fs-extra';
2
2
  import os from 'os';
3
3
  import path from 'path';
4
4
 
5
+ /**
6
+ * Validate the schema fonto.json file contents.
7
+ *
8
+ * @param {string} fontoJson The schema fonto.json contents.
9
+ *
10
+ * @throws If the schema fonto Json is invalid.
11
+ */
12
+ export function validateSchemaFontoJson(fontoJson) {
13
+ if (!fontoJson.rootSchemas) {
14
+ throw new Error('Missing "rootSchemas" property in fonto.json.');
15
+ }
16
+
17
+ if (
18
+ typeof fontoJson.rootSchemas !== 'object' ||
19
+ Array.isArray(fontoJson.rootSchemas)
20
+ ) {
21
+ throw new Error(
22
+ 'The "rootSchemas" property is not an object in fonto.json.'
23
+ );
24
+ }
25
+
26
+ const xsdPaths = Object.keys(fontoJson.rootSchemas);
27
+ const requireLocations = xsdPaths.length > 1;
28
+ xsdPaths.forEach((xsdPath) => {
29
+ const schemaPackage = fontoJson.rootSchemas[xsdPath];
30
+
31
+ if (typeof schemaPackage !== 'object' || Array.isArray(schemaPackage)) {
32
+ throw new Error(
33
+ `Root schema "${xsdPath}" is not an object in fonto.json.`
34
+ );
35
+ }
36
+
37
+ if (!schemaPackage.packageName) {
38
+ throw new Error(
39
+ `Root schema "${xsdPath}" does not have a valid "packageName" property in fonto.json.`
40
+ );
41
+ }
42
+
43
+ // If there are multiple root schemas, the location property is required.
44
+ if (
45
+ requireLocations &&
46
+ (!schemaPackage.locations || !schemaPackage.locations.length)
47
+ ) {
48
+ const error = new Error(
49
+ !schemaPackage.locations
50
+ ? `Root schema "${xsdPath}" is missing the "locations" property, which is required when having multipe root schemas in fonto.json.`
51
+ : `Root schema "${xsdPath}" has an empty "locations" property, which is not allowed when having multipe root schemas in fonto.json.`
52
+ );
53
+
54
+ const solution = [
55
+ 'Make sure to set locations for each schema in fonto.json when having multipe root schemas.',
56
+ 'See: https://documentation.fontoxml.com/latest/schema-experiences-7d818ffb9db5',
57
+ ];
58
+
59
+ error.solution = solution.join(os.EOL);
60
+ throw error;
61
+ }
62
+
63
+ // Validate the locations property, if there is any.
64
+ if (
65
+ schemaPackage.locations &&
66
+ (!Array.isArray(schemaPackage.locations) ||
67
+ schemaPackage.locations.some(
68
+ (schemaLocation) =>
69
+ typeof schemaLocation !== 'string' || !schemaLocation
70
+ ))
71
+ ) {
72
+ throw new Error(
73
+ `Root schema "${xsdPath}" has an invalid "locations" property in fonto.json.`
74
+ );
75
+ }
76
+ });
77
+ }
78
+
5
79
  /**
6
80
  * Get the schema fonto.json file contents.
7
81
  *
@@ -10,7 +84,7 @@ import path from 'path';
10
84
  * @return {Promise<Object>} Returns the contents of fonto.json.
11
85
  *
12
86
  * @async
13
- * @throws If the required directory or files do not exist.
87
+ * @throws If the required directory or files do not exist or the schema fonto json is invalid.
14
88
  */
15
89
  export default async function getSchemaFontoJson(inputPath) {
16
90
  if (!inputPath) {
@@ -38,53 +112,7 @@ export default async function getSchemaFontoJson(inputPath) {
38
112
  throw new Error('The required fonto.json could not be parsed.');
39
113
  }
40
114
 
41
- if (!fontoJson.rootSchemas) {
42
- throw new Error('Missing rootSchemas property in fonto.json.');
43
- }
44
-
45
- const xsdPaths = Object.keys(fontoJson.rootSchemas);
46
- xsdPaths.forEach((xsdPath) => {
47
- const schemaPackage = fontoJson.rootSchemas[xsdPath];
48
- if (!schemaPackage.packageName) {
49
- throw new Error(
50
- `Root schema "${xsdPath}" has no package name in fonto.json.`
51
- );
52
- }
53
-
54
- if (
55
- schemaPackage.locations &&
56
- (!Array.isArray(schemaPackage.locations) ||
57
- schemaPackage.locations.some(
58
- (schemaLocation) => typeof schemaLocation !== 'string'
59
- ))
60
- ) {
61
- throw new Error(
62
- `Root schema "${xsdPath}" has invalid locations in fonto.json.`
63
- );
64
- }
65
-
66
- // In case of referencing multiple schemas, verify that each has valid locations.
67
- if (
68
- xsdPaths.length > 1 &&
69
- (!schemaPackage.locations ||
70
- !schemaPackage.locations.length ||
71
- schemaPackage.locations.some(
72
- (schemaLocation) => !schemaLocation
73
- ))
74
- ) {
75
- const error = new Error(
76
- 'One or more schemas in fonto.json do not have valid locations associated.'
77
- );
78
-
79
- const solution = [
80
- 'Make sure to set locations for each schema in fonto.json.',
81
- 'See: https://documentation.fontoxml.com/latest/schema-experiences-7d818ffb9db5',
82
- ];
83
-
84
- error.solution = solution.join(os.EOL);
85
- throw error;
86
- }
87
- });
115
+ validateSchemaFontoJson(fontoJson);
88
116
 
89
117
  return fontoJson;
90
118
  }