@static-suite/static-suite-data-server 0.0.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 (484) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.json +49 -0
  3. package/.nvmrc +1 -0
  4. package/.prettierrc +10 -0
  5. package/.vscode/launch.json +44 -0
  6. package/LICENSE.txt +339 -0
  7. package/README.md +300 -0
  8. package/__mocks__/clear-module.js +7 -0
  9. package/api-extractor.json +339 -0
  10. package/dist/bin/serve.d.ts +3 -0
  11. package/dist/bin/serve.d.ts.map +1 -0
  12. package/dist/bin/serve.js +105 -0
  13. package/dist/http/README.md +300 -0
  14. package/dist/http/httpServer.d.ts +4 -0
  15. package/dist/http/httpServer.d.ts.map +1 -0
  16. package/dist/http/httpServer.js +24 -0
  17. package/dist/http/public/assets/bulma/bulma-tooltip.min.css +2 -0
  18. package/dist/http/public/assets/bulma/bulma.min.css +1 -0
  19. package/dist/http/public/assets/clipboard/clipboard.min.js +7 -0
  20. package/dist/http/public/assets/simple-datatables/index.js +12 -0
  21. package/dist/http/public/assets/simple-datatables/style.css +173 -0
  22. package/dist/http/routes/cache.d.ts +4 -0
  23. package/dist/http/routes/cache.d.ts.map +1 -0
  24. package/dist/http/routes/cache.js +19 -0
  25. package/dist/http/routes/data.d.ts +4 -0
  26. package/dist/http/routes/data.d.ts.map +1 -0
  27. package/dist/http/routes/data.js +104 -0
  28. package/dist/http/routes/docs.d.ts +3 -0
  29. package/dist/http/routes/docs.d.ts.map +1 -0
  30. package/dist/http/routes/docs.js +14 -0
  31. package/dist/http/routes/dump.d.ts +8 -0
  32. package/dist/http/routes/dump.d.ts.map +1 -0
  33. package/dist/http/routes/dump.js +57 -0
  34. package/dist/http/routes/home.d.ts +3 -0
  35. package/dist/http/routes/home.d.ts.map +1 -0
  36. package/dist/http/routes/home.js +17 -0
  37. package/dist/http/routes/index.d.ts +3 -0
  38. package/dist/http/routes/index.d.ts.map +1 -0
  39. package/dist/http/routes/index.js +33 -0
  40. package/dist/http/routes/query.d.ts +5 -0
  41. package/dist/http/routes/query.d.ts.map +1 -0
  42. package/dist/http/routes/query.js +21 -0
  43. package/dist/http/routes/status.d.ts +9 -0
  44. package/dist/http/routes/status.d.ts.map +1 -0
  45. package/dist/http/routes/status.js +74 -0
  46. package/dist/http/routes/task.d.ts +5 -0
  47. package/dist/http/routes/task.d.ts.map +1 -0
  48. package/dist/http/routes/task.js +22 -0
  49. package/dist/http/views/cacheClear.pug +17 -0
  50. package/dist/http/views/cacheIndex.pug +19 -0
  51. package/dist/http/views/data.pug +68 -0
  52. package/dist/http/views/docs.pug +7 -0
  53. package/dist/http/views/dumpIndex.pug +14 -0
  54. package/dist/http/views/home.pug +15 -0
  55. package/dist/http/views/includes/layout.pug +23 -0
  56. package/dist/http/views/queryIndex.pug +17 -0
  57. package/dist/http/views/statusIndex.pug +14 -0
  58. package/dist/http/views/taskIndex.pug +17 -0
  59. package/dist/lib/config/config.d.ts +26 -0
  60. package/dist/lib/config/config.d.ts.map +1 -0
  61. package/dist/lib/config/config.js +122 -0
  62. package/dist/lib/config/config.types.d.ts +74 -0
  63. package/dist/lib/config/config.types.d.ts.map +1 -0
  64. package/dist/lib/config/config.types.js +2 -0
  65. package/dist/lib/config/error/InvalidRunMode.d.ts +15 -0
  66. package/dist/lib/config/error/InvalidRunMode.d.ts.map +1 -0
  67. package/dist/lib/config/error/InvalidRunMode.js +20 -0
  68. package/dist/lib/config/error/MissingDirectory.d.ts +24 -0
  69. package/dist/lib/config/error/MissingDirectory.d.ts.map +1 -0
  70. package/dist/lib/config/error/MissingDirectory.js +23 -0
  71. package/dist/lib/config/error/MissingRequiredOption.d.ts +19 -0
  72. package/dist/lib/config/error/MissingRequiredOption.d.ts.map +1 -0
  73. package/dist/lib/config/error/MissingRequiredOption.js +21 -0
  74. package/dist/lib/config/error/NonWritableDirectory.d.ts +24 -0
  75. package/dist/lib/config/error/NonWritableDirectory.d.ts.map +1 -0
  76. package/dist/lib/config/error/NonWritableDirectory.js +23 -0
  77. package/dist/lib/config/error/index.d.ts +5 -0
  78. package/dist/lib/config/error/index.d.ts.map +1 -0
  79. package/dist/lib/config/error/index.js +16 -0
  80. package/dist/lib/config/index.d.ts +2 -0
  81. package/dist/lib/config/index.d.ts.map +1 -0
  82. package/dist/lib/config/index.js +13 -0
  83. package/dist/lib/dataServer.d.ts +21 -0
  84. package/dist/lib/dataServer.d.ts.map +1 -0
  85. package/dist/lib/dataServer.js +56 -0
  86. package/dist/lib/dataServer.types.d.ts +84 -0
  87. package/dist/lib/dataServer.types.d.ts.map +1 -0
  88. package/dist/lib/dataServer.types.js +13 -0
  89. package/dist/lib/error/DomainError.d.ts +9 -0
  90. package/dist/lib/error/DomainError.d.ts.map +1 -0
  91. package/dist/lib/error/DomainError.js +20 -0
  92. package/dist/lib/index.d.ts +2 -0
  93. package/dist/lib/index.d.ts.map +1 -0
  94. package/dist/lib/index.js +15 -0
  95. package/dist/lib/query/index.d.ts +3 -0
  96. package/dist/lib/query/index.d.ts.map +1 -0
  97. package/dist/lib/query/index.js +14 -0
  98. package/dist/lib/query/query.types.d.ts +206 -0
  99. package/dist/lib/query/query.types.d.ts.map +1 -0
  100. package/dist/lib/query/query.types.js +21 -0
  101. package/dist/lib/query/queryManager.d.ts +10 -0
  102. package/dist/lib/query/queryManager.d.ts.map +1 -0
  103. package/dist/lib/query/queryManager.js +12 -0
  104. package/dist/lib/query/queryRunner copy.d.ts +3 -0
  105. package/dist/lib/query/queryRunner copy.d.ts.map +1 -0
  106. package/dist/lib/query/queryRunner copy.js +87 -0
  107. package/dist/lib/query/queryRunner.d.ts +3 -0
  108. package/dist/lib/query/queryRunner.d.ts.map +1 -0
  109. package/dist/lib/query/queryRunner.js +96 -0
  110. package/dist/lib/query/queryTagManager.d.ts +3 -0
  111. package/dist/lib/query/queryTagManager.d.ts.map +1 -0
  112. package/dist/lib/query/queryTagManager.js +47 -0
  113. package/dist/lib/store/dataDir/dataDir.types.d.ts +36 -0
  114. package/dist/lib/store/dataDir/dataDir.types.d.ts.map +1 -0
  115. package/dist/lib/store/dataDir/dataDir.types.js +2 -0
  116. package/dist/lib/store/dataDir/dataDirManager.d.ts +3 -0
  117. package/dist/lib/store/dataDir/dataDirManager.d.ts.map +1 -0
  118. package/dist/lib/store/dataDir/dataDirManager.js +97 -0
  119. package/dist/lib/store/dataDir/index.d.ts +2 -0
  120. package/dist/lib/store/dataDir/index.d.ts.map +1 -0
  121. package/dist/lib/store/dataDir/index.js +13 -0
  122. package/dist/lib/store/dependency/dependency.types.d.ts +70 -0
  123. package/dist/lib/store/dependency/dependency.types.d.ts.map +1 -0
  124. package/dist/lib/store/dependency/dependency.types.js +2 -0
  125. package/dist/lib/store/dependency/dependencyFileHelper.d.ts +6 -0
  126. package/dist/lib/store/dependency/dependencyFileHelper.d.ts.map +1 -0
  127. package/dist/lib/store/dependency/dependencyFileHelper.js +46 -0
  128. package/dist/lib/store/dependency/dependencyManager copy.d.ts +6 -0
  129. package/dist/lib/store/dependency/dependencyManager copy.d.ts.map +1 -0
  130. package/dist/lib/store/dependency/dependencyManager copy.js +91 -0
  131. package/dist/lib/store/dependency/dependencyManager.d.ts +6 -0
  132. package/dist/lib/store/dependency/dependencyManager.d.ts.map +1 -0
  133. package/dist/lib/store/dependency/dependencyManager.js +78 -0
  134. package/dist/lib/store/dependency/dependencyManager.types.d.ts +48 -0
  135. package/dist/lib/store/dependency/dependencyManager.types.d.ts.map +1 -0
  136. package/dist/lib/store/dependency/dependencyManager.types.js +2 -0
  137. package/dist/lib/store/dependency/dependencyTagManager.d.ts +6 -0
  138. package/dist/lib/store/dependency/dependencyTagManager.d.ts.map +1 -0
  139. package/dist/lib/store/dependency/dependencyTagManager.js +33 -0
  140. package/dist/lib/store/dependency/dependencyTagger.d.ts +11 -0
  141. package/dist/lib/store/dependency/dependencyTagger.d.ts.map +1 -0
  142. package/dist/lib/store/dependency/dependencyTagger.js +99 -0
  143. package/dist/lib/store/diff/diffManager.d.ts +3 -0
  144. package/dist/lib/store/diff/diffManager.d.ts.map +1 -0
  145. package/dist/lib/store/diff/diffManager.js +114 -0
  146. package/dist/lib/store/diff/diffManager.types.d.ts +50 -0
  147. package/dist/lib/store/diff/diffManager.types.d.ts.map +1 -0
  148. package/dist/lib/store/diff/diffManager.types.js +2 -0
  149. package/dist/lib/store/diff/index.d.ts +2 -0
  150. package/dist/lib/store/diff/index.d.ts.map +1 -0
  151. package/dist/lib/store/diff/index.js +13 -0
  152. package/dist/lib/store/diff/tracker.d.ts +3 -0
  153. package/dist/lib/store/diff/tracker.d.ts.map +1 -0
  154. package/dist/lib/store/diff/tracker.js +82 -0
  155. package/dist/lib/store/diff/tracker.types.d.ts +31 -0
  156. package/dist/lib/store/diff/tracker.types.d.ts.map +1 -0
  157. package/dist/lib/store/diff/tracker.types.js +2 -0
  158. package/dist/lib/store/dump/dumpManager.d.ts +3 -0
  159. package/dist/lib/store/dump/dumpManager.d.ts.map +1 -0
  160. package/dist/lib/store/dump/dumpManager.js +199 -0
  161. package/dist/lib/store/dump/dumpManager.types.d.ts +62 -0
  162. package/dist/lib/store/dump/dumpManager.types.d.ts.map +1 -0
  163. package/dist/lib/store/dump/dumpManager.types.js +2 -0
  164. package/dist/lib/store/dump/index.d.ts +2 -0
  165. package/dist/lib/store/dump/index.d.ts.map +1 -0
  166. package/dist/lib/store/dump/index.js +13 -0
  167. package/dist/lib/store/hook/hook.types.d.ts +205 -0
  168. package/dist/lib/store/hook/hook.types.d.ts.map +1 -0
  169. package/dist/lib/store/hook/hook.types.js +2 -0
  170. package/dist/lib/store/hook/hookManager.d.ts +6 -0
  171. package/dist/lib/store/hook/hookManager.d.ts.map +1 -0
  172. package/dist/lib/store/hook/hookManager.js +168 -0
  173. package/dist/lib/store/hook/index.d.ts +2 -0
  174. package/dist/lib/store/hook/index.d.ts.map +1 -0
  175. package/dist/lib/store/hook/index.js +13 -0
  176. package/dist/lib/store/include/includeIndex.d.ts +6 -0
  177. package/dist/lib/store/include/includeIndex.d.ts.map +1 -0
  178. package/dist/lib/store/include/includeIndex.js +65 -0
  179. package/dist/lib/store/include/includeIndex.types.d.ts +29 -0
  180. package/dist/lib/store/include/includeIndex.types.d.ts.map +1 -0
  181. package/dist/lib/store/include/includeIndex.types.js +2 -0
  182. package/dist/lib/store/include/includeParser.d.ts +3 -0
  183. package/dist/lib/store/include/includeParser.d.ts.map +1 -0
  184. package/dist/lib/store/include/includeParser.js +46 -0
  185. package/dist/lib/store/include/includeParser.types.d.ts +88 -0
  186. package/dist/lib/store/include/includeParser.types.d.ts.map +1 -0
  187. package/dist/lib/store/include/includeParser.types.js +2 -0
  188. package/dist/lib/store/include/index.d.ts +2 -0
  189. package/dist/lib/store/include/index.d.ts.map +1 -0
  190. package/dist/lib/store/include/index.js +13 -0
  191. package/dist/lib/store/include/parsers/configIncludeParser.d.ts +3 -0
  192. package/dist/lib/store/include/parsers/configIncludeParser.d.ts.map +1 -0
  193. package/dist/lib/store/include/parsers/configIncludeParser.js +8 -0
  194. package/dist/lib/store/include/parsers/customIncludeParser.d.ts +3 -0
  195. package/dist/lib/store/include/parsers/customIncludeParser.d.ts.map +1 -0
  196. package/dist/lib/store/include/parsers/customIncludeParser.js +8 -0
  197. package/dist/lib/store/include/parsers/entityIncludeParser.d.ts +3 -0
  198. package/dist/lib/store/include/parsers/entityIncludeParser.d.ts.map +1 -0
  199. package/dist/lib/store/include/parsers/entityIncludeParser.js +13 -0
  200. package/dist/lib/store/include/parsers/index.d.ts +6 -0
  201. package/dist/lib/store/include/parsers/index.d.ts.map +1 -0
  202. package/dist/lib/store/include/parsers/index.js +17 -0
  203. package/dist/lib/store/include/parsers/localeIncludeParser.d.ts +3 -0
  204. package/dist/lib/store/include/parsers/localeIncludeParser.d.ts.map +1 -0
  205. package/dist/lib/store/include/parsers/localeIncludeParser.js +8 -0
  206. package/dist/lib/store/include/parsers/queryIncludeParser.d.ts +11 -0
  207. package/dist/lib/store/include/parsers/queryIncludeParser.d.ts.map +1 -0
  208. package/dist/lib/store/include/parsers/queryIncludeParser.js +45 -0
  209. package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts +3 -0
  210. package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts.map +1 -0
  211. package/dist/lib/store/include/parsers/types/aliasIncludeParser.js +10 -0
  212. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts +8 -0
  213. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts.map +1 -0
  214. package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.js +18 -0
  215. package/dist/lib/store/index.d.ts +2 -0
  216. package/dist/lib/store/index.d.ts.map +1 -0
  217. package/dist/lib/store/index.js +13 -0
  218. package/dist/lib/store/store.d.ts +7 -0
  219. package/dist/lib/store/store.d.ts.map +1 -0
  220. package/dist/lib/store/store.js +89 -0
  221. package/dist/lib/store/store.types.d.ts +231 -0
  222. package/dist/lib/store/store.types.d.ts.map +1 -0
  223. package/dist/lib/store/store.types.js +2 -0
  224. package/dist/lib/store/storeManager.d.ts +3 -0
  225. package/dist/lib/store/storeManager.d.ts.map +1 -0
  226. package/dist/lib/store/storeManager.js +149 -0
  227. package/dist/lib/store/workDir/index.d.ts +2 -0
  228. package/dist/lib/store/workDir/index.d.ts.map +1 -0
  229. package/dist/lib/store/workDir/index.js +13 -0
  230. package/dist/lib/store/workDir/storage/getChangedLinesSince.d.ts +9 -0
  231. package/dist/lib/store/workDir/storage/getChangedLinesSince.d.ts.map +1 -0
  232. package/dist/lib/store/workDir/storage/getChangedLinesSince.js +47 -0
  233. package/dist/lib/store/workDir/storage/getDataFromLogLine.d.ts +10 -0
  234. package/dist/lib/store/workDir/storage/getDataFromLogLine.d.ts.map +1 -0
  235. package/dist/lib/store/workDir/storage/getDataFromLogLine.js +33 -0
  236. package/dist/lib/store/workDir/storage/getLogFile.d.ts +8 -0
  237. package/dist/lib/store/workDir/storage/getLogFile.d.ts.map +1 -0
  238. package/dist/lib/store/workDir/storage/getLogFile.js +11 -0
  239. package/dist/lib/store/workDir/storage/index.d.ts +4 -0
  240. package/dist/lib/store/workDir/storage/index.d.ts.map +1 -0
  241. package/dist/lib/store/workDir/storage/index.js +20 -0
  242. package/dist/lib/store/workDir/workDir.types.d.ts +44 -0
  243. package/dist/lib/store/workDir/workDir.types.d.ts.map +1 -0
  244. package/dist/lib/store/workDir/workDir.types.js +2 -0
  245. package/dist/lib/store/workDir/workDirHelper.d.ts +20 -0
  246. package/dist/lib/store/workDir/workDirHelper.d.ts.map +1 -0
  247. package/dist/lib/store/workDir/workDirHelper.js +52 -0
  248. package/dist/lib/task/index.d.ts +3 -0
  249. package/dist/lib/task/index.d.ts.map +1 -0
  250. package/dist/lib/task/index.js +14 -0
  251. package/dist/lib/task/task.types.d.ts +140 -0
  252. package/dist/lib/task/task.types.d.ts.map +1 -0
  253. package/dist/lib/task/task.types.js +11 -0
  254. package/dist/lib/task/taskManager.d.ts +10 -0
  255. package/dist/lib/task/taskManager.d.ts.map +1 -0
  256. package/dist/lib/task/taskManager.js +12 -0
  257. package/dist/lib/task/taskRunner.d.ts +3 -0
  258. package/dist/lib/task/taskRunner.d.ts.map +1 -0
  259. package/dist/lib/task/taskRunner.js +71 -0
  260. package/dist/lib/tsdoc-metadata.json +11 -0
  261. package/dist/lib/utils/array/arrayUtils.d.ts +2 -0
  262. package/dist/lib/utils/array/arrayUtils.d.ts.map +1 -0
  263. package/dist/lib/utils/array/arrayUtils.js +11 -0
  264. package/dist/lib/utils/cache/cacheBinManager.d.ts +37 -0
  265. package/dist/lib/utils/cache/cacheBinManager.d.ts.map +1 -0
  266. package/dist/lib/utils/cache/cacheBinManager.js +53 -0
  267. package/dist/lib/utils/cache/index.d.ts +2 -0
  268. package/dist/lib/utils/cache/index.d.ts.map +1 -0
  269. package/dist/lib/utils/cache/index.js +13 -0
  270. package/dist/lib/utils/fs/fs.types.d.ts +20 -0
  271. package/dist/lib/utils/fs/fs.types.d.ts.map +1 -0
  272. package/dist/lib/utils/fs/fs.types.js +2 -0
  273. package/dist/lib/utils/fs/fsUtils.d.ts +62 -0
  274. package/dist/lib/utils/fs/fsUtils.d.ts.map +1 -0
  275. package/dist/lib/utils/fs/fsUtils.js +137 -0
  276. package/dist/lib/utils/fs/index.d.ts +2 -0
  277. package/dist/lib/utils/fs/index.d.ts.map +1 -0
  278. package/dist/lib/utils/fs/index.js +13 -0
  279. package/dist/lib/utils/logger/index.d.ts +2 -0
  280. package/dist/lib/utils/logger/index.d.ts.map +1 -0
  281. package/dist/lib/utils/logger/index.js +13 -0
  282. package/dist/lib/utils/logger/logger.d.ts +32 -0
  283. package/dist/lib/utils/logger/logger.d.ts.map +1 -0
  284. package/dist/lib/utils/logger/logger.js +82 -0
  285. package/dist/lib/utils/logger/logger.types.d.ts +37 -0
  286. package/dist/lib/utils/logger/logger.types.d.ts.map +1 -0
  287. package/dist/lib/utils/logger/logger.types.js +15 -0
  288. package/dist/lib/utils/module/dirBasedModuleGroupManager.d.ts +30 -0
  289. package/dist/lib/utils/module/dirBasedModuleGroupManager.d.ts.map +1 -0
  290. package/dist/lib/utils/module/dirBasedModuleGroupManager.js +78 -0
  291. package/dist/lib/utils/module/index.d.ts +3 -0
  292. package/dist/lib/utils/module/index.d.ts.map +1 -0
  293. package/dist/lib/utils/module/index.js +14 -0
  294. package/dist/lib/utils/module/module.types.d.ts +53 -0
  295. package/dist/lib/utils/module/module.types.d.ts.map +1 -0
  296. package/dist/lib/utils/module/module.types.js +2 -0
  297. package/dist/lib/utils/module/moduleManager.d.ts +64 -0
  298. package/dist/lib/utils/module/moduleManager.d.ts.map +1 -0
  299. package/dist/lib/utils/module/moduleManager.js +139 -0
  300. package/dist/lib/utils/object/index.d.ts +2 -0
  301. package/dist/lib/utils/object/index.d.ts.map +1 -0
  302. package/dist/lib/utils/object/index.js +13 -0
  303. package/dist/lib/utils/object/object.types.d.ts +72 -0
  304. package/dist/lib/utils/object/object.types.d.ts.map +1 -0
  305. package/dist/lib/utils/object/object.types.js +2 -0
  306. package/dist/lib/utils/object/objectUtils.d.ts +45 -0
  307. package/dist/lib/utils/object/objectUtils.d.ts.map +1 -0
  308. package/dist/lib/utils/object/objectUtils.js +64 -0
  309. package/dist/lib/utils/string/index.d.ts +2 -0
  310. package/dist/lib/utils/string/index.d.ts.map +1 -0
  311. package/dist/lib/utils/string/index.js +13 -0
  312. package/dist/lib/utils/string/string.types.d.ts +2 -0
  313. package/dist/lib/utils/string/string.types.d.ts.map +1 -0
  314. package/dist/lib/utils/string/string.types.js +2 -0
  315. package/dist/lib/utils/string/stringUtils.d.ts +37 -0
  316. package/dist/lib/utils/string/stringUtils.d.ts.map +1 -0
  317. package/dist/lib/utils/string/stringUtils.js +62 -0
  318. package/dist/lib/watcher/index.d.ts +2 -0
  319. package/dist/lib/watcher/index.d.ts.map +1 -0
  320. package/dist/lib/watcher/index.js +13 -0
  321. package/dist/lib/watcher/watcher.d.ts +17 -0
  322. package/dist/lib/watcher/watcher.d.ts.map +1 -0
  323. package/dist/lib/watcher/watcher.js +65 -0
  324. package/dist/static-suite-data-server.d.ts +392 -0
  325. package/package.json +102 -0
  326. package/scripts/copy-http-files-to-src.js +45 -0
  327. package/src/__tests__/fixtures/data/en/en.json +3 -0
  328. package/src/__tests__/fixtures/data/en/entity/entity.json +3 -0
  329. package/src/__tests__/fixtures/data/en/entity/node/article/article1--card.json +3 -0
  330. package/src/__tests__/fixtures/data/en/entity/node/article/article1--small.json +3 -0
  331. package/src/__tests__/fixtures/data/en/entity/node/article/article1.json +40 -0
  332. package/src/__tests__/fixtures/data/en/entity/node/article/article2--card.json +3 -0
  333. package/src/__tests__/fixtures/data/en/entity/node/article/article2--small.json +3 -0
  334. package/src/__tests__/fixtures/data/en/entity/node/article/article2.json +40 -0
  335. package/src/__tests__/fixtures/data/en/entity/node/article/article3--card.json +3 -0
  336. package/src/__tests__/fixtures/data/en/entity/node/article/article3--small.json +3 -0
  337. package/src/__tests__/fixtures/data/en/entity/node/article/article3.json +7 -0
  338. package/src/__tests__/fixtures/data/en/entity/node/node.json +3 -0
  339. package/src/__tests__/fixtures/data/en/entity/node/page/page1--card.json +3 -0
  340. package/src/__tests__/fixtures/data/en/entity/node/page/page1--small.json +3 -0
  341. package/src/__tests__/fixtures/data/en/entity/node/page/page1.json +3 -0
  342. package/src/__tests__/fixtures/data/en/entity/node/page/page2--card.json +3 -0
  343. package/src/__tests__/fixtures/data/en/entity/node/page/page2--small.json +3 -0
  344. package/src/__tests__/fixtures/data/en/entity/node/page/page2.json +3 -0
  345. package/src/__tests__/fixtures/data/global--block.json +3 -0
  346. package/src/__tests__/fixtures/data/global.json +3 -0
  347. package/src/__tests__/fixtures/hook/main.hook.js +15 -0
  348. package/src/__tests__/fixtures/hook/taxonomy/main.hook.js +15 -0
  349. package/src/__tests__/fixtures/hook/taxonomy/taxo.hook.js +15 -0
  350. package/src/__tests__/fixtures/query/error.query.js +6 -0
  351. package/src/__tests__/fixtures/query/noHandler.query.js +14 -0
  352. package/src/__tests__/fixtures/query/query1.query.js +15 -0
  353. package/src/__tests__/fixtures/query/query2.query.js +14 -0
  354. package/src/__tests__/fixtures/query/wrongNamequery.js +14 -0
  355. package/src/__tests__/fixtures/task/error.task.js +6 -0
  356. package/src/__tests__/fixtures/task/noHandler.task.js +13 -0
  357. package/src/__tests__/fixtures/task/task1.task.js +14 -0
  358. package/src/__tests__/fixtures/task/task2.task.js +13 -0
  359. package/src/__tests__/fixtures/task/wrongNametask.js +13 -0
  360. package/src/bin/serve.ts +107 -0
  361. package/src/http/httpServer.ts +21 -0
  362. package/src/http/routes/cache.ts +17 -0
  363. package/src/http/routes/data.ts +114 -0
  364. package/src/http/routes/docs.ts +9 -0
  365. package/src/http/routes/dump.ts +61 -0
  366. package/src/http/routes/home.ts +16 -0
  367. package/src/http/routes/index.ts +47 -0
  368. package/src/http/routes/query.ts +27 -0
  369. package/src/http/routes/status.ts +89 -0
  370. package/src/http/routes/task.ts +29 -0
  371. package/src/http/views/cacheClear.pug +17 -0
  372. package/src/http/views/cacheIndex.pug +19 -0
  373. package/src/http/views/data.pug +68 -0
  374. package/src/http/views/docs.pug +7 -0
  375. package/src/http/views/dumpIndex.pug +14 -0
  376. package/src/http/views/home.pug +15 -0
  377. package/src/http/views/includes/layout.pug +23 -0
  378. package/src/http/views/queryIndex.pug +17 -0
  379. package/src/http/views/statusIndex.pug +14 -0
  380. package/src/http/views/taskIndex.pug +17 -0
  381. package/src/lib/config/__tests__/config.test.ts +132 -0
  382. package/src/lib/config/config.ts +143 -0
  383. package/src/lib/config/config.types.ts +87 -0
  384. package/src/lib/config/error/InvalidRunMode.ts +17 -0
  385. package/src/lib/config/error/MissingDirectory.ts +30 -0
  386. package/src/lib/config/error/MissingRequiredOption.ts +23 -0
  387. package/src/lib/config/error/NonWritableDirectory.ts +30 -0
  388. package/src/lib/config/error/index.ts +4 -0
  389. package/src/lib/config/index.ts +1 -0
  390. package/src/lib/dataServer.ts +81 -0
  391. package/src/lib/dataServer.types.ts +98 -0
  392. package/src/lib/error/DomainError.ts +18 -0
  393. package/src/lib/index.ts +4 -0
  394. package/src/lib/query/__tests__/queryRunner.test.ts +61 -0
  395. package/src/lib/query/index.ts +2 -0
  396. package/src/lib/query/query.types.ts +231 -0
  397. package/src/lib/query/queryManager.ts +11 -0
  398. package/src/lib/query/queryRunner.ts +110 -0
  399. package/src/lib/query/queryTagManager.ts +53 -0
  400. package/src/lib/store/dataDir/__tests__/dataDirManager.test.ts +15 -0
  401. package/src/lib/store/dataDir/dataDir.types.ts +38 -0
  402. package/src/lib/store/dataDir/dataDirManager.ts +121 -0
  403. package/src/lib/store/dataDir/index.ts +1 -0
  404. package/src/lib/store/dependency/dependency.types.ts +78 -0
  405. package/src/lib/store/dependency/dependencyFileHelper.ts +50 -0
  406. package/src/lib/store/dependency/dependencyManager.ts +82 -0
  407. package/src/lib/store/dependency/dependencyTagger.ts +105 -0
  408. package/src/lib/store/diff/diffManager.ts +122 -0
  409. package/src/lib/store/diff/diffManager.types.ts +51 -0
  410. package/src/lib/store/diff/index.ts +1 -0
  411. package/src/lib/store/dump/dumpManager.ts +235 -0
  412. package/src/lib/store/dump/dumpManager.types.ts +61 -0
  413. package/src/lib/store/dump/index.ts +1 -0
  414. package/src/lib/store/hook/hook.types.ts +232 -0
  415. package/src/lib/store/hook/hookManager.ts +180 -0
  416. package/src/lib/store/hook/index.ts +1 -0
  417. package/src/lib/store/include/__tests__/includeParser.test.ts +80 -0
  418. package/src/lib/store/include/includeParser.ts +54 -0
  419. package/src/lib/store/include/includeParser.types.ts +99 -0
  420. package/src/lib/store/include/index.ts +1 -0
  421. package/src/lib/store/include/parsers/__tests__/entityIncludeParser.test.ts +43 -0
  422. package/src/lib/store/include/parsers/configIncludeParser.ts +8 -0
  423. package/src/lib/store/include/parsers/customIncludeParser.ts +8 -0
  424. package/src/lib/store/include/parsers/entityIncludeParser.ts +15 -0
  425. package/src/lib/store/include/parsers/index.ts +5 -0
  426. package/src/lib/store/include/parsers/localeIncludeParser.ts +8 -0
  427. package/src/lib/store/include/parsers/queryIncludeParser.ts +51 -0
  428. package/src/lib/store/include/parsers/types/__tests__/aliasIncludeParser.test.ts +37 -0
  429. package/src/lib/store/include/parsers/types/__tests__/aliasWithoutTypeIncludeParser.test.ts +43 -0
  430. package/src/lib/store/include/parsers/types/aliasIncludeParser.ts +13 -0
  431. package/src/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.ts +22 -0
  432. package/src/lib/store/index.ts +1 -0
  433. package/src/lib/store/store.ts +105 -0
  434. package/src/lib/store/store.types.ts +251 -0
  435. package/src/lib/store/storeManager.ts +187 -0
  436. package/src/lib/store/workDir/__tests__/workDirHelper.test.ts +25 -0
  437. package/src/lib/store/workDir/index.ts +1 -0
  438. package/src/lib/store/workDir/storage/__tests__/getChangedLinesSince.test.ts +23 -0
  439. package/src/lib/store/workDir/storage/__tests__/getDataFromLogLine.test.ts +21 -0
  440. package/src/lib/store/workDir/storage/getChangedLinesSince.ts +47 -0
  441. package/src/lib/store/workDir/storage/getDataFromLogLine.ts +31 -0
  442. package/src/lib/store/workDir/storage/getLogFile.ts +11 -0
  443. package/src/lib/store/workDir/storage/index.ts +8 -0
  444. package/src/lib/store/workDir/workDir.types.ts +48 -0
  445. package/src/lib/store/workDir/workDirHelper.ts +59 -0
  446. package/src/lib/task/__tests__/taskRunner.test.ts +47 -0
  447. package/src/lib/task/index.ts +2 -0
  448. package/src/lib/task/task.types.ts +151 -0
  449. package/src/lib/task/taskManager.ts +11 -0
  450. package/src/lib/task/taskRunner.ts +79 -0
  451. package/src/lib/utils/array/__tests__/arrayUtils.test.ts +16 -0
  452. package/src/lib/utils/array/arrayUtils.ts +7 -0
  453. package/src/lib/utils/cache/__tests__/cache.test.ts +24 -0
  454. package/src/lib/utils/cache/cacheBinManager.ts +88 -0
  455. package/src/lib/utils/cache/index.ts +1 -0
  456. package/src/lib/utils/fs/__tests__/fixtures/file.json +3 -0
  457. package/src/lib/utils/fs/__tests__/fixtures/file.txt +3 -0
  458. package/src/lib/utils/fs/__tests__/fsUtils.test.ts +93 -0
  459. package/src/lib/utils/fs/fs.types.ts +21 -0
  460. package/src/lib/utils/fs/fsUtils.ts +141 -0
  461. package/src/lib/utils/fs/index.ts +1 -0
  462. package/src/lib/utils/logger/__tests__/logger.test.ts +12 -0
  463. package/src/lib/utils/logger/index.ts +1 -0
  464. package/src/lib/utils/logger/logger.ts +87 -0
  465. package/src/lib/utils/logger/logger.types.ts +41 -0
  466. package/src/lib/utils/module/__mocks__/dummyModule.query.js +4 -0
  467. package/src/lib/utils/module/__mocks__/dummyModule2.query.js +4 -0
  468. package/src/lib/utils/module/__tests__/dirBasedModuleGroupManager.test.ts +34 -0
  469. package/src/lib/utils/module/__tests__/moduleHandler.test.ts +100 -0
  470. package/src/lib/utils/module/dirBasedModuleGroupManager.ts +78 -0
  471. package/src/lib/utils/module/index.ts +2 -0
  472. package/src/lib/utils/module/module.types.ts +57 -0
  473. package/src/lib/utils/module/moduleManager.ts +144 -0
  474. package/src/lib/utils/object/__tests__/objectUtils.test.ts +62 -0
  475. package/src/lib/utils/object/index.ts +1 -0
  476. package/src/lib/utils/object/object.types.ts +74 -0
  477. package/src/lib/utils/object/objectUtils.ts +71 -0
  478. package/src/lib/utils/string/__tests__/stringUtils.test.ts +30 -0
  479. package/src/lib/utils/string/index.ts +1 -0
  480. package/src/lib/utils/string/string.types.ts +1 -0
  481. package/src/lib/utils/string/stringUtils.ts +61 -0
  482. package/src/lib/watcher/index.ts +1 -0
  483. package/src/lib/watcher/watcher.ts +66 -0
  484. package/tsconfig.json +83 -0
@@ -0,0 +1,251 @@
1
+ export interface StoreData<K, V> extends Map<K, V> {
2
+ /**
3
+ * Create a subset with all files in store that match the given arguments.
4
+ *
5
+ * @remarks
6
+ * All subsets are automatically cached, so passing the same arguments
7
+ * will return the same subset from the cache.
8
+ *
9
+ * This is the preferred way of getting a subset of the store files,
10
+ * since is a simple function that most of the times only requires
11
+ * the first argument.
12
+ *
13
+ * @example
14
+ * ```
15
+ * // Get a subset of all nodes with "json" extension.
16
+ * dataServer.store.data.subset({ dir: 'en/entity/node/', variant: null });
17
+ *
18
+ * // Get a subset of all articles in all languages with "json" extension.
19
+ * dataServer.store.data.subset({ dir: '.+/entity/node/article/' });
20
+ *
21
+ * // Get a subset of all articles regardless of their extension.
22
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', ext: null });
23
+ *
24
+ * // Get a subset of all card variants for articles with "json" extension.
25
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', variant: null });
26
+ *
27
+ * // Get a subset of english articles, with "yml" extension, non-recursively.
28
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', ext: 'yml', recursive: false });
29
+ * ```
30
+ *
31
+ * @param options - Object with options for creating a store subset.
32
+ *
33
+ * @returns An object with "filenames" and "items".
34
+ */
35
+ subset(options: StoreSubsetOptions): StoreSubset;
36
+ }
37
+
38
+ /**
39
+ * The store that holds all data.
40
+ */
41
+ export type Store = {
42
+ /**
43
+ * Date to tell when was the store last synced.
44
+ *
45
+ * Every time the store is updated, syncDate is set with the last modification
46
+ * date of the data directory, not the date when the store has finished updating.
47
+ *
48
+ * Given this scenario:
49
+ * - Data directory modified at 12:30:00
50
+ * - Syncing the store takes 3 seconds and finishes at 12:30:03
51
+ *
52
+ * ... syncDate will be 12:30:00, not 12:30:03.
53
+ *
54
+ * Doing it the other way round can cause data inconsistencies, because syncing files
55
+ * to the store takes time, it is done sequentially, and in the meanwhile, other
56
+ * modifications can happen:
57
+ * - Store last syncDate is 12:29:00
58
+ * - Data directory is modified at 12:30:00
59
+ * - We ask for modified files after 12:29:00 and got 3 files (1.json, 2.json and 3.json)
60
+ * - File "1.json" is processed and added to the store at 12:30:01
61
+ * - While "2.json" is being processed and added to the store, data directory is modified
62
+ * again at 12:30:02 and "1.json" is changed.
63
+ * - File "3.json" is processed and added to the store at 12:30:03
64
+ *
65
+ * At this moment, there are two options:
66
+ *
67
+ * 1) Setting syncDate to the current date:
68
+ * - Store syncDate is set to 12:30:03
69
+ * - Data directory is modified again at 12:30:10 and only "3.json" is changed
70
+ * - We ask for modified files after 12:30:03 and get only "3.json"
71
+ * - Modification done at 12:30:02 to "1.json" is lost and cannot be recovered unless "1.json" is
72
+ * modified again, or Data Server is restarted
73
+ *
74
+ * 2) Setting syncDate to the last modification date of the data directory:
75
+ * - Store syncDate is set to 12:30:00
76
+ * - Data directory is modified again at 12:30:10 and only "3.json" is changed
77
+ * - We ask for modified files after 12:30:00 and get "1.json" and "3.json"
78
+ * - Modification done at 12:30:02 to "1.json" is properly processed
79
+ */
80
+ syncDate: Date | null;
81
+
82
+ /**
83
+ * Map that holds all data for all files.
84
+ *
85
+ * @remarks
86
+ * This map contains files, keyed by their relative filepath. No directory or
87
+ * any other structure is stored here.
88
+ *
89
+ * When executing a query, a common pattern is to create a subset of this
90
+ * map (e.g.- to get all articles of an specific language) and the execute the
91
+ * query against that subset. To do so, see {@link Store#subset}
92
+ *
93
+ * @example
94
+ * ```
95
+ * // Find an specific article.
96
+ * const article = store.data.get('en/entity/node/article/123.json');
97
+ * const article = store.index.url.get('public/pretty/url');
98
+ * const article = store.index.uuid.get('nl').get('ce736c8b-a6ea-43c4-9a6b-ad1fc498017c');
99
+ * const article = store.index.custom.get('taxonomies').get('12234');
100
+ *
101
+ * // Create a subset of all english articles.
102
+ * const results = store.data.subset({ dir: 'en/entity/node/article/', recursive: true });
103
+ * ```
104
+ */
105
+ data: StoreData<string, any>;
106
+
107
+ /**
108
+ * A list of deleted files from store, to be able to track them.
109
+ */
110
+ deleted: Set<string>;
111
+
112
+ /**
113
+ * An object to hold accessory index data.
114
+ */
115
+ index: {
116
+ /**
117
+ * An index that holds all data for all files, keyed by their URL.
118
+ */
119
+ url: Map<string, any>;
120
+
121
+ /**
122
+ * An index that holds all data for all files, keyed by their lang and uuid.
123
+ */
124
+ uuid: Map<string, any>;
125
+
126
+ /**
127
+ * An index to hold custom data defined in hooks or queries.
128
+ */
129
+ custom: Map<string, any>;
130
+ };
131
+ };
132
+
133
+ /**
134
+ * Options for subset() function.
135
+ */
136
+ export type StoreSubsetOptions = {
137
+ /**
138
+ * Optional base directory to filter files.
139
+ *
140
+ * @remarks
141
+ * It requires a trailing slash, but not a leading slash, e.g.- "en/entity/node/article/"
142
+ */
143
+ dir?: string;
144
+
145
+ /**
146
+ * Optional name of a variant file.
147
+ *
148
+ * @remarks
149
+ * Use '_main' to obtain the default variant.
150
+ * Use any other string, e.g.- 'card', to obtain the card variant.
151
+ * Use null to avoid searching for any variant.
152
+ * Defaults to '_main'.
153
+ */
154
+ variant?: string;
155
+
156
+ /**
157
+ * Optional file extension, without dots. Defaults to 'json'.
158
+ */
159
+ ext?: string;
160
+
161
+ /**
162
+ * Optional flag to search for files recursively. True by default.
163
+ */
164
+ recursive?: boolean;
165
+ };
166
+
167
+ /**
168
+ * Object holding a subset of items from the store.
169
+ */
170
+ export type StoreSubset = {
171
+ /**
172
+ * Array of filenames in this subset.
173
+ */
174
+ filenames: Array<string>;
175
+
176
+ /**
177
+ * Array of items in this subset.
178
+ */
179
+ items: Array<any>;
180
+ };
181
+
182
+ /**
183
+ * The manager that handles the store data.
184
+ */
185
+ export type StoreManager = {
186
+ /**
187
+ * Adds a file to the store, into a Map structure keyed by its relative filepath.
188
+ *
189
+ * @remarks
190
+ * It invokes "process file" and "store add" hooks.
191
+ *
192
+ * @param relativeFilepath - Relative file path, inside dataDir, to the file to be added.
193
+ *
194
+ * @returns The store manager, to allow chaining.
195
+ */
196
+ add(relativeFilepath: string): StoreManager;
197
+
198
+ /**
199
+ * Removes a file from the store.
200
+ *
201
+ * @remarks
202
+ * It removes the file from the map structure.
203
+ * It invokes the "store remove" hook.
204
+ *
205
+ * @param file - Relative path to the file to be removed.
206
+ *
207
+ * @returns The store manager, to allow chaining.
208
+ */
209
+ remove(file: string): StoreManager;
210
+
211
+ /**
212
+ * Updates a file from the store.
213
+ *
214
+ * @remarks
215
+ * It removes the file from the map structure, and adds it again.
216
+ *
217
+ * @param file - Relative path, inside dataDir, to the file to be updated.
218
+ *
219
+ * @returns The store manager, to allow chaining.
220
+ */
221
+ update(file: string): StoreManager;
222
+
223
+ /**
224
+ * Parses all static and dynamic includes (entity, config, locale, custom and query)
225
+ * from data stored in "store.data".
226
+ *
227
+ * @returns The store manager, to allow chaining.
228
+ */
229
+ parseIncludes(): StoreManager;
230
+
231
+ /**
232
+ * Parses all static and dynamic includes (entity, config, locale, custom and query)
233
+ * from one file.
234
+ *
235
+ * @param relativeFilepath - Relative file path, inside dataDir, to the file to be parsed.
236
+ * @param fileContent - The contents of a file.
237
+ *
238
+ * @returns The store manager, to allow chaining.
239
+ */
240
+ parseSingleFileIncludes(
241
+ relativeFilepath: string,
242
+ fileContent: any,
243
+ ): StoreManager;
244
+
245
+ /**
246
+ * Resets store and deletes all loaded data.
247
+ *
248
+ * @returns The store manager, to allow chaining.
249
+ */
250
+ reset(): StoreManager;
251
+ };
@@ -0,0 +1,187 @@
1
+ import { config } from '@lib/config';
2
+ import { getFileContent } from '@lib/utils/fs';
3
+ import { FileType } from '@lib/utils/fs/fs.types';
4
+ import { StoreManager } from './store.types';
5
+ import { hookManager } from './hook';
6
+ import { store, resetStore } from '.';
7
+ import { includeParser } from './include';
8
+ import { dependencyIncludeHelper } from './dependency/dependencyFileHelper';
9
+ import { dependencyTagger } from './dependency/dependencyTagger';
10
+
11
+ /**
12
+ * Sets a file into the store, regardless of being already added or not.
13
+ *
14
+ * @param relativeFilepath - Relative file path, inside dataDir, to the file to be added.
15
+ * @param options - Configuration options.
16
+ *
17
+ * @returns Object with two properties, "raw" and "json".
18
+ */
19
+ const setFileIntoStore = (relativeFilepath: string): FileType => {
20
+ const absoluteFilePath = `${config.dataDir}/${relativeFilepath}`;
21
+ let fileContent = getFileContent(absoluteFilePath);
22
+
23
+ // Invoke "process file" hook.
24
+ fileContent = hookManager.invokeOnProcessFile({
25
+ relativeFilepath,
26
+ fileContent,
27
+ });
28
+
29
+ const dataToStore = fileContent.json || fileContent.raw;
30
+ if (fileContent.json) {
31
+ // Check if the object already exists to make sure we don't break the reference
32
+ const previousData = store.data.get(relativeFilepath);
33
+ if (dataToStore && typeof dataToStore === 'object') {
34
+ if (previousData) {
35
+ // Delete include dependencies.
36
+ dependencyIncludeHelper.deleteIncludeDependencies(
37
+ relativeFilepath,
38
+ dataToStore,
39
+ );
40
+
41
+ // Remove previous data from URL index.
42
+ const url = previousData.data?.content?.url?.path;
43
+ if (url) {
44
+ store.index.url.delete(url);
45
+ }
46
+
47
+ // Remove previous data from UUID index.
48
+ const uuid = previousData.data?.content?.uuid;
49
+ const langcode = previousData.data?.content?.langcode?.value;
50
+ if (uuid && langcode) {
51
+ store.index.uuid.get(langcode)?.delete(uuid);
52
+ }
53
+
54
+ // Delete all referenced object properties
55
+ Object.keys(previousData).forEach(key => {
56
+ delete previousData[key];
57
+ });
58
+ // hydrate new object properties into referenced object
59
+ Object.keys(dataToStore).forEach(key => {
60
+ previousData[key] = dataToStore[key];
61
+ });
62
+ }
63
+
64
+ // Add data to UUID index.
65
+ const uuid = dataToStore.data?.content?.uuid;
66
+ const langcode = dataToStore.data?.content?.langcode?.value;
67
+ if (uuid && langcode) {
68
+ const langcodeMap =
69
+ store.index.uuid.get(langcode) ||
70
+ store.index.uuid.set(langcode, new Map<string, any>()).get(langcode);
71
+ langcodeMap.set(uuid, dataToStore);
72
+ }
73
+
74
+ // Add data to URL index.
75
+ const url = dataToStore.data?.content?.url?.path;
76
+ if (url) {
77
+ store.index.url.set(url, dataToStore);
78
+ }
79
+
80
+ // Add include dependencies.
81
+ dependencyIncludeHelper.setIncludeDependencies(
82
+ relativeFilepath,
83
+ dataToStore,
84
+ );
85
+ }
86
+ }
87
+ store.data.set(relativeFilepath, dataToStore);
88
+
89
+ // Remove this path from store.deleted
90
+ store.deleted.delete(relativeFilepath);
91
+
92
+ return fileContent;
93
+ };
94
+
95
+ export const storeManager: StoreManager = {
96
+ add: (relativeFilepath: string): StoreManager => {
97
+ const fileContent = setFileIntoStore(relativeFilepath);
98
+
99
+ // Invoke "store add" hook.
100
+ hookManager.invokeOnStoreItemAdd({ relativeFilepath, fileContent });
101
+
102
+ return storeManager;
103
+ },
104
+
105
+ update: (relativeFilepath: string): StoreManager => {
106
+ const storedData = store.data.get(relativeFilepath);
107
+ if (storedData) {
108
+ hookManager.invokeOnStoreItemBeforeUpdate({
109
+ relativeFilepath,
110
+ fileContent: storedData,
111
+ });
112
+ }
113
+
114
+ const fileContent = setFileIntoStore(relativeFilepath);
115
+
116
+ // Invalidate this item.
117
+ dependencyTagger.invalidateTags([relativeFilepath]);
118
+
119
+ // Invoke "store update" hook.
120
+ hookManager.invokeOnStoreItemAfterUpdate({
121
+ relativeFilepath,
122
+ fileContent,
123
+ });
124
+
125
+ return storeManager;
126
+ },
127
+
128
+ remove: (relativeFilepath: string): StoreManager => {
129
+ // Get stored data before removing it from store.
130
+ const storedData = store.data.get(relativeFilepath);
131
+
132
+ // Remove data from URL index.
133
+ const url = storedData.data?.content?.url?.path;
134
+ if (url) {
135
+ store.index.url.delete(url);
136
+ }
137
+
138
+ // Remove data from UUID index.
139
+ const uuid = storedData.data?.content?.uuid;
140
+ const langcode = storedData.data?.content?.langcode?.value;
141
+ if (uuid && langcode) {
142
+ store.index.uuid.get(langcode)?.delete(uuid);
143
+ }
144
+
145
+ // Delete file contents from store.
146
+ store.data.delete(relativeFilepath);
147
+
148
+ // Save its path in store.deleted for future reference.
149
+ store.deleted.add(relativeFilepath);
150
+
151
+ // Invalidate this item.
152
+ dependencyTagger.invalidateTags([relativeFilepath]);
153
+
154
+ // Invoke "store remove" hook.
155
+ hookManager.invokeOnStoreItemDelete({
156
+ relativeFilepath,
157
+ fileContent: storedData,
158
+ });
159
+
160
+ return storeManager;
161
+ },
162
+
163
+ parseIncludes: (): StoreManager => {
164
+ // Parses static includes.
165
+ store.data.forEach((fileContent, relativeFilepath) => {
166
+ includeParser.static(relativeFilepath, fileContent);
167
+ });
168
+
169
+ // Parses dynamic includes.
170
+ store.data.forEach(fileContent => {
171
+ includeParser.dynamic(fileContent);
172
+ });
173
+
174
+ return storeManager;
175
+ },
176
+
177
+ parseSingleFileIncludes: (relativeFilepath, fileContent): StoreManager => {
178
+ includeParser.static(relativeFilepath, fileContent);
179
+ includeParser.dynamic(fileContent);
180
+ return storeManager;
181
+ },
182
+
183
+ reset: () => {
184
+ resetStore();
185
+ return storeManager;
186
+ },
187
+ };
@@ -0,0 +1,25 @@
1
+ import path from 'path';
2
+ import fs from 'fs';
3
+ import { config } from '@lib/config';
4
+ import { workDirHelper } from '../workDirHelper';
5
+
6
+ describe('workDirHelper test', () => {
7
+ describe('getChangedFilesSince', () => {
8
+ config.workDir = fs.realpathSync(
9
+ path.resolve('src/__tests__/fixtures/work'),
10
+ );
11
+
12
+ it(`Gets modified and deleted files from static-suite log`, () => {
13
+ expect(
14
+ workDirHelper.getChangedFilesSince(new Date('2021-08-01')),
15
+ ).toEqual({
16
+ deleted: ['es/entity/node/article/10.json'],
17
+ updated: [
18
+ 'en/entity/node/article/10.json',
19
+ 'es/config/static_export.settings.json',
20
+ 'es/entity/node/recipe/9.json',
21
+ ],
22
+ });
23
+ });
24
+ });
25
+ });
@@ -0,0 +1 @@
1
+ export * from './workDirHelper';
@@ -0,0 +1,23 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import { config } from '@lib/config';
4
+ import { getChangedLinesSince } from '../getChangedLinesSince';
5
+
6
+ describe('workDir storage getChangedLinesSince test', () => {
7
+ describe('getChangedLinesSince', () => {
8
+ config.workDir = fs.realpathSync(
9
+ path.resolve('src/__tests__/fixtures/work'),
10
+ );
11
+
12
+ it(`Gets lines of log since given date`, () => {
13
+ expect(getChangedLinesSince(new Date('2021-08-01'))).toEqual([
14
+ '2021-08-16_07-11-55.666963__3504 delete [ID: 10] Prueba y cultiva tus propias hierbas | static-local://es/entity/node/article/10.json',
15
+ '2021-08-16_07-12-45.771095__5959 write [ID: 10] Give it a go and grow your own herbs | static-local://en/entity/node/article/10.json',
16
+ '2021-08-16_07-12-46.771095__5959 delete [ID: 10] Give it a go and grow your own herbs | static-local://en/entity/node/article/10.json',
17
+ '2021-08-16_07-12-47.771095__5959 write [ID: 10] Give it a go and grow your own herbs | static-local://en/entity/node/article/10.json',
18
+ '2021-08-17_08-49-26.273927__5991 write [ID: static_export.settings] static_export.settings | static-local://es/config/static_export.settings.json',
19
+ '2021-08-17_08-50-00.235800__1900 write [ID: 9] Salsa de chile ardiente | static-local://es/entity/node/recipe/9.json',
20
+ ]);
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,21 @@
1
+ import { getDataFromLogLine } from '..';
2
+
3
+ describe('workDir storage getDataFromLogLine test', () => {
4
+ describe('getDataFromLogLine', () => {
5
+ it(`Gets data from line of log`, () => {
6
+ expect(
7
+ getDataFromLogLine(
8
+ '2021-08-16_07-12-45.771095__5959 write [ID: 10] Give it a go and grow your own herbs | static-local://en/entity/node/article/10.json',
9
+ ),
10
+ ).toStrictEqual({
11
+ file: {
12
+ id: '10',
13
+ label: 'Give it a go and grow your own herbs',
14
+ relativePath: 'en/entity/node/article/10.json',
15
+ },
16
+ operation: 'write',
17
+ uniqueId: '2021-08-16_07-12-45.771095__5959',
18
+ });
19
+ });
20
+ });
21
+ });
@@ -0,0 +1,47 @@
1
+ import fs from 'fs';
2
+ import { logger } from '@lib/utils/logger';
3
+ import { getLogFile } from './getLogFile';
4
+
5
+ /**
6
+ * Get changed files since a date.
7
+ *
8
+ * @param sinceDate - Date to search
9
+
10
+ * @returns Array of changed lines
11
+ */
12
+ export const getChangedLinesSince = (sinceDate: Date): string[] => {
13
+ let allLines: string[] = [];
14
+ const logFile = getLogFile();
15
+ if (logFile) {
16
+ try {
17
+ allLines = fs.readFileSync(logFile).toString().split('\n');
18
+ } catch (e) {
19
+ logger.error(
20
+ `Error reading metadata log file located at ${`logFile`}: ${e}`,
21
+ );
22
+ }
23
+ }
24
+
25
+ // todo - Do not use dates and use timestamps in all cases
26
+ // to avoid having to fix offsets.
27
+ const date = new Date();
28
+ const dateOffset = -(date.getTimezoneOffset() * 60 * 1000);
29
+
30
+ const changedLines = allLines.filter(line => {
31
+ const uniqueId = line.substring(0, 32);
32
+ if (!uniqueId) {
33
+ return false;
34
+ }
35
+ const dateString = uniqueId.replace(
36
+ /(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.(\d{3}).*/,
37
+ '$1-$2-$3T$4:$5:$6.$7',
38
+ );
39
+ const uniqueIdDate = Date.parse(dateString) + dateOffset;
40
+ return uniqueIdDate && uniqueIdDate > sinceDate.getTime();
41
+ });
42
+ logger.debug(`Found ${changedLines.length} changed lines`);
43
+ changedLines.forEach(line => {
44
+ logger.debug(`Found changed line: ${line}`);
45
+ });
46
+ return changedLines;
47
+ };
@@ -0,0 +1,31 @@
1
+ import { LogLineData } from '../workDir.types';
2
+
3
+ /**
4
+ * Extract information from Static Suite's log line.
5
+ *
6
+ * @param line - Log line.
7
+ *
8
+ * @returns An object with parsed data, or null if line format is not valid.
9
+ */
10
+ export const getDataFromLogLine = (line: string): LogLineData | null => {
11
+ const matches = line.match(/^(\S+) (\S+) \[ID: ([^\]]+)] (.+)/);
12
+ if (matches) {
13
+ const uniqueId = matches[1];
14
+ const operation = matches[2];
15
+ const fileId = matches[3];
16
+ const [fileLabel, uri] = matches[4].split(' | ');
17
+ const [, uriTarget] = uri.split('://');
18
+ if (operation === 'write' || operation === 'delete') {
19
+ return {
20
+ uniqueId,
21
+ operation,
22
+ file: {
23
+ id: fileId,
24
+ label: fileLabel,
25
+ relativePath: uriTarget,
26
+ },
27
+ };
28
+ }
29
+ }
30
+ return null;
31
+ };
@@ -0,0 +1,11 @@
1
+ import { config } from '@lib/config';
2
+
3
+ /**
4
+ * Gets the absolute path to Static Suite's log file.
5
+ *
6
+ * @returns The absolute path to Static Suite's log file.
7
+ */
8
+ const getLogFile = (): string | null =>
9
+ config.workDir ? `${config.workDir}/lock-executed.log` : null;
10
+
11
+ export { getLogFile };
@@ -0,0 +1,8 @@
1
+ /*
2
+ These functions are separated from workDirHelper, since they are specific
3
+ to the current storage backend (log files saved on disk) and they can change
4
+ in the future.
5
+ */
6
+ export * from './getChangedLinesSince';
7
+ export * from './getDataFromLogLine';
8
+ export * from './getLogFile';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A group of changed files in Static Suite's data dir.
3
+ */
4
+ export type ChangedFiles = {
5
+ /**
6
+ * A list of updated files (both newly added and changed files).
7
+ */
8
+ updated: string[];
9
+ /**
10
+ * A list of deleted files.
11
+ */
12
+ deleted: string[];
13
+ };
14
+
15
+ /**
16
+ * Information from a Static Suite's log line.
17
+ */
18
+ export type LogLineData = {
19
+ /**
20
+ * The unique ID of the write/delete operation from Static Suite.
21
+ */
22
+ uniqueId: string;
23
+
24
+ /**
25
+ * The type of operation executed in the log line.
26
+ */
27
+ operation: 'write' | 'delete';
28
+
29
+ /**
30
+ * Information about the affected file
31
+ */
32
+ file: {
33
+ /**
34
+ * File ID, a string identifying the file in a meaningful way, usually a numeric ID
35
+ */
36
+ id: string;
37
+
38
+ /**
39
+ * A long text identifying the file in a meaningful way, usually the content title.
40
+ */
41
+ label: string;
42
+
43
+ /**
44
+ * Relative file path inside data dir.
45
+ */
46
+ relativePath: string;
47
+ };
48
+ };