@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,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cache = void 0;
4
+ const data = new Map();
5
+ /**
6
+ * Initializes a cache bin.
7
+ *
8
+ * @remarks
9
+ * If a cache bin already exists, it clears it, creating a new one.
10
+ * If the cache bin doesn't exist, it simply creates it.
11
+ *
12
+ * @param binId - The id of the bin.
13
+ * @returns The initialized cache bin.
14
+ *
15
+ */
16
+ const initBin = (binId) => {
17
+ data.set(binId, new Map());
18
+ return data.get(binId);
19
+ };
20
+ /**
21
+ * Cache system based on specialized bins.
22
+ *
23
+ * All cache items belong to a specific bin ("file", "query", etc),
24
+ * which is a kind of "folder" or "directory" where data belonging
25
+ * to the same context/domain is stored altogether.
26
+ */
27
+ exports.cache = {
28
+ bin: (binId) => {
29
+ return data.get(binId) || initBin(binId);
30
+ },
31
+ /**
32
+ * Returns a boolean indicating whether a cache bin
33
+ * with the specified key exists or not.
34
+ *
35
+ * @param binId - The id of the bin.
36
+ * @returns True if the cache bin exists, false otherwise.
37
+ */
38
+ has: binId => data.has(binId),
39
+ /**
40
+ * Gets an array of keys of all available cache bins.
41
+ *
42
+ * @returns An array of cache bin keys.
43
+ */
44
+ keys: () => Array.from(data.keys()),
45
+ /**
46
+ * Gets an array of keys of all available cache bins.
47
+ *
48
+ * @returns An array of cache bin keys.
49
+ */
50
+ clear: () => {
51
+ data.clear();
52
+ },
53
+ };
@@ -0,0 +1,2 @@
1
+ export * from './cacheBinManager';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,13 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./cacheBinManager"), exports);
@@ -0,0 +1,20 @@
1
+ import { Json } from '@lib/utils/object/object.types';
2
+ /**
3
+ * An object that represents a file's contents.
4
+ *
5
+ * @remarks
6
+ * Object with two properties, "raw" and "json", which contain
7
+ * the raw and json version of the file. If file is not a JSON, the "json"
8
+ * property is null. If file is not found, both properties are null.
9
+ */
10
+ export declare type FileType = {
11
+ /**
12
+ * The raw contents of the file, as a string. Null if file is not found.
13
+ */
14
+ raw: string | null;
15
+ /**
16
+ * The file contents parsed as JSON, if file is a JSON file. Null if not a JSON file.
17
+ */
18
+ json: Json | null;
19
+ };
20
+ //# sourceMappingURL=fs.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/fs/fs.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAEtD;;;;;;;GAOG;AACH,oBAAY,QAAQ,GAAG;IACrB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnB;;OAEG;IACH,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACnB,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,62 @@
1
+ import { Options as fastGlobOptions } from 'fast-glob';
2
+ import { FileType } from './fs.types';
3
+ /**
4
+ * Tells whether a path is JSON or not.
5
+ *
6
+ * @remarks
7
+ * A fast checker that avoids reading the contents of a file, or doing
8
+ * some other complex operation to determine if a file contains JSON data.
9
+ *
10
+ * @internal
11
+ */
12
+ export declare const isJsonFile: (filepath: string) => boolean;
13
+ /**
14
+ * Reads a file and logs an error on failure.
15
+ *
16
+ * @param filePath - A path to a file.
17
+ *
18
+ * @returns The file contents as a string if file is found, or null otherwise.
19
+ */
20
+ export declare const readFile: (filePath: string) => string | null;
21
+ /**
22
+ * Gets raw and JSON parsed content from a file.
23
+ *
24
+ * @param filepath - A path to a file.
25
+ *
26
+ * @returns Object with two properties, "raw" and "json", which contain
27
+ * the raw and json version of the file. If file is not a JSON, the "json"
28
+ * property is null. If file is not found, both properties are null.
29
+ */
30
+ export declare const getFileContent: (filepath: string) => FileType;
31
+ /**
32
+ * Finds all files inside a directory
33
+ *
34
+ * @param dir - Absolute path to the directory to be scanned
35
+ * @param glob - Optional glob to filter results (default all files recursive '**\/*')
36
+ * @param options - Options for the fast-glob package.
37
+ * See https://www.npmjs.com/package/fast-glob for reference .
38
+ *
39
+ * @returns Array of file paths found inside directory
40
+ */
41
+ export declare const findFilesInDir: (dir: string, glob?: string, options?: fastGlobOptions) => string[];
42
+ /**
43
+ * Gets a file's modification date and logs an error on failure.
44
+ *
45
+ * @param filePath - Path to the file
46
+ *
47
+ * @returns The file's modification date as a Date object, or null on error
48
+ */
49
+ export declare const getModificationDate: (filePath: string) => Date | null;
50
+ /**
51
+ * Watches for changes on a set of paths and attach listener to them
52
+ *
53
+ * @remarks
54
+ * It handles three different events: add, change and unlink
55
+ *
56
+ * @param paths - An array of paths to be watched
57
+ * @param listeners - An object with three optional event keys (add, change and unlink)
58
+ * and a listener function as value. That function will be executed once any of
59
+ * the event keys is dispatched.
60
+ */
61
+ export declare const watch: (paths: string[], listeners: Record<"add" | "change" | "unlink", (filePath: string) => void>) => void;
62
+ //# sourceMappingURL=fsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsUtils.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/fs/fsUtils.ts"],"names":[],"mappings":"AACA,OAAW,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,WAAW,CAAC;AAI3D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,aAAc,MAAM,KAAG,OACd,CAAC;AAEjC;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,aAAc,MAAM,KAAG,MAAM,GAAG,IAWpD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,aAAc,MAAM,KAAG,QAUjD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,QACpB,MAAM,2BAEF,eAAe,KACvB,MAAM,EAQR,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,aAAc,MAAM,KAAG,IAAI,GAAG,IAQ7D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,UACT,MAAM,EAAE,4DAC2C,MAAM,KAAK,IAAI,MACxE,IAyBF,CAAC"}
@@ -0,0 +1,137 @@
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.watch = exports.getModificationDate = exports.findFilesInDir = exports.getFileContent = exports.readFile = exports.isJsonFile = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const fast_glob_1 = __importDefault(require("fast-glob"));
9
+ const chokidar_1 = __importDefault(require("chokidar"));
10
+ const logger_1 = require("@lib/utils/logger");
11
+ const string_1 = require("@lib/utils/string");
12
+ /**
13
+ * Tells whether a path is JSON or not.
14
+ *
15
+ * @remarks
16
+ * A fast checker that avoids reading the contents of a file, or doing
17
+ * some other complex operation to determine if a file contains JSON data.
18
+ *
19
+ * @internal
20
+ */
21
+ const isJsonFile = (filepath) => filepath.slice(-5) === '.json';
22
+ exports.isJsonFile = isJsonFile;
23
+ /**
24
+ * Reads a file and logs an error on failure.
25
+ *
26
+ * @param filePath - A path to a file.
27
+ *
28
+ * @returns The file contents as a string if file is found, or null otherwise.
29
+ */
30
+ const readFile = (filePath) => {
31
+ let content = null;
32
+ try {
33
+ content = fs_1.default.readFileSync(filePath, { encoding: 'utf8', flag: 'r' });
34
+ }
35
+ catch (error) {
36
+ // When an error is thrown, content is undefined, so ensure
37
+ // it is converted to null.
38
+ content = null;
39
+ logger_1.logger.error(`Error reading file "${filePath}": ${error}`);
40
+ }
41
+ return content;
42
+ };
43
+ exports.readFile = readFile;
44
+ /**
45
+ * Gets raw and JSON parsed content from a file.
46
+ *
47
+ * @param filepath - A path to a file.
48
+ *
49
+ * @returns Object with two properties, "raw" and "json", which contain
50
+ * the raw and json version of the file. If file is not a JSON, the "json"
51
+ * property is null. If file is not found, both properties are null.
52
+ */
53
+ const getFileContent = (filepath) => {
54
+ const raw = (0, exports.readFile)(filepath);
55
+ let json = null;
56
+ if (raw && (0, exports.isJsonFile)(filepath)) {
57
+ json = (0, string_1.parseJsonString)(raw);
58
+ if (!json) {
59
+ logger_1.logger.error(`Error getting JSON from file "${filepath}"`);
60
+ }
61
+ }
62
+ return { raw, json };
63
+ };
64
+ exports.getFileContent = getFileContent;
65
+ /**
66
+ * Finds all files inside a directory
67
+ *
68
+ * @param dir - Absolute path to the directory to be scanned
69
+ * @param glob - Optional glob to filter results (default all files recursive '**\/*')
70
+ * @param options - Options for the fast-glob package.
71
+ * See https://www.npmjs.com/package/fast-glob for reference .
72
+ *
73
+ * @returns Array of file paths found inside directory
74
+ */
75
+ const findFilesInDir = (dir, glob = '**/*', options = { absolute: false }) => {
76
+ const startDate = Date.now();
77
+ const files = fast_glob_1.default.sync([glob], { cwd: dir, ...options });
78
+ const endDate = Date.now();
79
+ logger_1.logger.debug(`${files.length} files found inside ${dir} in ${endDate - startDate}ms.`);
80
+ return files;
81
+ };
82
+ exports.findFilesInDir = findFilesInDir;
83
+ /**
84
+ * Gets a file's modification date and logs an error on failure.
85
+ *
86
+ * @param filePath - Path to the file
87
+ *
88
+ * @returns The file's modification date as a Date object, or null on error
89
+ */
90
+ const getModificationDate = (filePath) => {
91
+ let modificationDate = null;
92
+ try {
93
+ modificationDate = new Date(fs_1.default.statSync(filePath).mtime);
94
+ }
95
+ catch (e) {
96
+ logger_1.logger.error(`Error getting modification date for ${`path`}: ${e}`);
97
+ }
98
+ return modificationDate;
99
+ };
100
+ exports.getModificationDate = getModificationDate;
101
+ /**
102
+ * Watches for changes on a set of paths and attach listener to them
103
+ *
104
+ * @remarks
105
+ * It handles three different events: add, change and unlink
106
+ *
107
+ * @param paths - An array of paths to be watched
108
+ * @param listeners - An object with three optional event keys (add, change and unlink)
109
+ * and a listener function as value. That function will be executed once any of
110
+ * the event keys is dispatched.
111
+ */
112
+ const watch = (paths, listeners) => {
113
+ if (paths.length > 0) {
114
+ const watcher = chokidar_1.default.watch(paths, {
115
+ ignored: /(^|[/\\])\../,
116
+ persistent: true,
117
+ });
118
+ // Add event listeners.
119
+ watcher.on('ready', () => {
120
+ logger_1.logger.debug(`Watcher listening for changes on ${paths.join(',')}`);
121
+ watcher
122
+ .on('add', filePath => {
123
+ logger_1.logger.debug(`File ${filePath} added`);
124
+ listeners.add(filePath);
125
+ })
126
+ .on('change', filePath => {
127
+ logger_1.logger.debug(`File ${filePath} changed`);
128
+ listeners.change(filePath);
129
+ })
130
+ .on('unlink', filePath => {
131
+ logger_1.logger.debug(`File ${filePath} removed`);
132
+ listeners.unlink(filePath);
133
+ });
134
+ });
135
+ }
136
+ };
137
+ exports.watch = watch;
@@ -0,0 +1,2 @@
1
+ export * from './fsUtils';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/fs/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,13 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./fsUtils"), exports);
@@ -0,0 +1,2 @@
1
+ export * from './logger';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,13 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./logger"), exports);
@@ -0,0 +1,32 @@
1
+ import winston from 'winston';
2
+ import { LogLevel, LogFile } from './logger.types';
3
+ /**
4
+ * The winston logger
5
+ */
6
+ export declare const logger: winston.Logger;
7
+ /**
8
+ * Configures a logger instance
9
+ *
10
+ * @remarks
11
+ * The logger can log its messages to two different transports:
12
+ *
13
+ * 1) The stdout (from the terminal/console which started this process)
14
+ * 2) A log file located on the filesystem
15
+ *
16
+ * Since stdout is a volatile transport that cannot be reviewed at a
17
+ * later point in time, it is recommended to use the log file when
18
+ * running the Data Server on production environments.
19
+ *
20
+ * If a log file is defined, but its path is no writable, it should:
21
+ * 1) Log an error (which would be logged to the stdout)
22
+ * 2) Throw an error
23
+ *
24
+ * @param level - Log level, defaults to "warn"
25
+ * @param logFile - Configuration data for the log file. An object
26
+ * containing two properties: path and level
27
+ *
28
+ * @throws
29
+ * An exception if a log file is defined, but its path is no writable
30
+ */
31
+ export declare const configureLogger: (level?: LogLevel, logFile?: LogFile | undefined) => void;
32
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/logger/logger.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAiBnD;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,OAAO,CAAC,MAU3B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,WACnB,QAAQ,oCAEd,IAwBF,CAAC"}
@@ -0,0 +1,82 @@
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.configureLogger = exports.logger = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const winston_1 = __importDefault(require("winston"));
10
+ const logger_types_1 = require("./logger.types");
11
+ /**
12
+ * Defines a custom log format that prints a timestamp, a level and a message
13
+ */
14
+ const customFormat = winston_1.default.format.printf(({ level, message, timestamp }) => `${timestamp} [${level}]: ${message}`);
15
+ /**
16
+ * The combined log format, that makes use of the custom log format
17
+ */
18
+ const combinedFormat = winston_1.default.format.combine(winston_1.default.format.timestamp(), customFormat);
19
+ /**
20
+ * The winston logger
21
+ */
22
+ exports.logger = winston_1.default.createLogger({
23
+ levels: winston_1.default.config.npm.levels,
24
+ level: 'info',
25
+ format: winston_1.default.format.json(),
26
+ transports: [
27
+ // Write all logs with level `info` and below to console
28
+ new winston_1.default.transports.Console({
29
+ format: combinedFormat,
30
+ }),
31
+ ],
32
+ });
33
+ /**
34
+ * Configures a logger instance
35
+ *
36
+ * @remarks
37
+ * The logger can log its messages to two different transports:
38
+ *
39
+ * 1) The stdout (from the terminal/console which started this process)
40
+ * 2) A log file located on the filesystem
41
+ *
42
+ * Since stdout is a volatile transport that cannot be reviewed at a
43
+ * later point in time, it is recommended to use the log file when
44
+ * running the Data Server on production environments.
45
+ *
46
+ * If a log file is defined, but its path is no writable, it should:
47
+ * 1) Log an error (which would be logged to the stdout)
48
+ * 2) Throw an error
49
+ *
50
+ * @param level - Log level, defaults to "warn"
51
+ * @param logFile - Configuration data for the log file. An object
52
+ * containing two properties: path and level
53
+ *
54
+ * @throws
55
+ * An exception if a log file is defined, but its path is no writable
56
+ */
57
+ const configureLogger = (level = logger_types_1.LogLevel.WARN, logFile) => {
58
+ if (level) {
59
+ exports.logger.level = level;
60
+ }
61
+ if (logFile && logFile.path) {
62
+ const logFileAbsolute = fs_1.default.realpathSync(path_1.default.resolve(logFile.path));
63
+ // Check if file dirname is writable.
64
+ try {
65
+ fs_1.default.accessSync(path_1.default.dirname(logFileAbsolute), fs_1.default.constants.W_OK);
66
+ }
67
+ catch (e) {
68
+ // Log error and rethrow.
69
+ exports.logger.error(`Log file "${logFileAbsolute}" is not writable: ${e}`);
70
+ throw e;
71
+ }
72
+ // Create and add the file transport to the logger
73
+ const fileTransport = new winston_1.default.transports.File({
74
+ filename: path_1.default.basename(logFileAbsolute),
75
+ dirname: path_1.default.dirname(logFileAbsolute),
76
+ format: combinedFormat,
77
+ level: logFile.level,
78
+ });
79
+ exports.logger.add(fileTransport);
80
+ }
81
+ };
82
+ exports.configureLogger = configureLogger;
@@ -0,0 +1,37 @@
1
+ import winston from 'winston';
2
+ /**
3
+ * The logger service.
4
+ *
5
+ * @remarks
6
+ * A logger currently based on the "winston" package.
7
+ */
8
+ export declare type Logger = winston.Logger;
9
+ /**
10
+ * Log levels: error, warn, info and debug.
11
+ *
12
+ * @public
13
+ */
14
+ export declare enum LogLevel {
15
+ ERROR = "error",
16
+ WARN = "warn",
17
+ INFO = "info",
18
+ DEBUG = "debug"
19
+ }
20
+ /**
21
+ * A helper to get LogLevel type as strings. @see {@link LogLevel}.
22
+ */
23
+ export declare type LogLevelStrings = keyof typeof LogLevel;
24
+ /**
25
+ * A log file definition.
26
+ */
27
+ export declare type LogFile = {
28
+ /**
29
+ * Path to the log file.
30
+ */
31
+ path: string;
32
+ /**
33
+ * Log level for the log file.
34
+ */
35
+ level: LogLevel;
36
+ };
37
+ //# sourceMappingURL=logger.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.types.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/logger/logger.types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B;;;;;GAKG;AACH,oBAAY,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;AAEpC;;;;GAIG;AACH,oBAAY,QAAQ;IAClB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,oBAAY,eAAe,GAAG,MAAM,OAAO,QAAQ,CAAC;AAEpD;;GAEG;AACH,oBAAY,OAAO,GAAG;IACpB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,QAAQ,CAAC;CACjB,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogLevel = void 0;
4
+ /**
5
+ * Log levels: error, warn, info and debug.
6
+ *
7
+ * @public
8
+ */
9
+ var LogLevel;
10
+ (function (LogLevel) {
11
+ LogLevel["ERROR"] = "error";
12
+ LogLevel["WARN"] = "warn";
13
+ LogLevel["INFO"] = "info";
14
+ LogLevel["DEBUG"] = "debug";
15
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
@@ -0,0 +1,30 @@
1
+ import { ModuleGroupManager } from './module.types';
2
+ /**
3
+ * A manager of module groups based on a directory.
4
+ *
5
+ * A module group is a set of user-land modules that are stored inside
6
+ * a directory. The contents of that directory are unknown, and it can contain
7
+ * modules and other non-module files required by those modules.
8
+ *
9
+ * Modules are distinguished from other files because they contain a key as a suffix,
10
+ * at the end of their name, following this pattern: [MODULE_ID].[KEY].js
11
+ *
12
+ * For example:
13
+ *
14
+ * - lastContents.query.js
15
+ * - listByTermId.query.js
16
+ * - taxonomy.hook.js
17
+ * - media.hook.js
18
+ *
19
+ * This manager provided a set of common functionalities for those kind of
20
+ * directories.
21
+ *
22
+ * @param key - Key to distinguish modules from other files. This key is
23
+ * also used to derive the name of the configuration option that defines
24
+ * the path to the directory where the module group is stored, following this
25
+ * pattern: `${key}Dir`
26
+ * @returns A module group manager with a set of common functionalities
27
+ * for those kind of directories.
28
+ */
29
+ export declare const dirBasedModuleGroupManager: <ModuleType>(key: 'hook' | 'query' | 'task') => ModuleGroupManager<ModuleType>;
30
+ //# sourceMappingURL=dirBasedModuleGroupManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dirBasedModuleGroupManager.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/module/dirBasedModuleGroupManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAc,MAAM,gBAAgB,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,0BAA0B,oBAEhC,MAAM,GAAG,OAAO,GAAG,MAAM,mCAyC/B,CAAC"}
@@ -0,0 +1,78 @@
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.dirBasedModuleGroupManager = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const config_1 = require("@lib/config");
9
+ const fs_1 = require("@lib/utils/fs");
10
+ const cache_1 = require("@lib/utils/cache");
11
+ const moduleManager_1 = require("./moduleManager");
12
+ /**
13
+ * A manager of module groups based on a directory.
14
+ *
15
+ * A module group is a set of user-land modules that are stored inside
16
+ * a directory. The contents of that directory are unknown, and it can contain
17
+ * modules and other non-module files required by those modules.
18
+ *
19
+ * Modules are distinguished from other files because they contain a key as a suffix,
20
+ * at the end of their name, following this pattern: [MODULE_ID].[KEY].js
21
+ *
22
+ * For example:
23
+ *
24
+ * - lastContents.query.js
25
+ * - listByTermId.query.js
26
+ * - taxonomy.hook.js
27
+ * - media.hook.js
28
+ *
29
+ * This manager provided a set of common functionalities for those kind of
30
+ * directories.
31
+ *
32
+ * @param key - Key to distinguish modules from other files. This key is
33
+ * also used to derive the name of the configuration option that defines
34
+ * the path to the directory where the module group is stored, following this
35
+ * pattern: `${key}Dir`
36
+ * @returns A module group manager with a set of common functionalities
37
+ * for those kind of directories.
38
+ */
39
+ const dirBasedModuleGroupManager = (
40
+ // Key needs to be explicitly defined to make TypeScript happy.
41
+ key) => {
42
+ /**
43
+ * Cache bin used by this module group
44
+ */
45
+ const moduleGroupInfo = cache_1.cache.bin(`${key}-modules`);
46
+ const moduleGroupManager = {
47
+ getModuleGroupInfo: () => {
48
+ // Use config here, because outside this function, the config object is not
49
+ // already defined.
50
+ const dir = config_1.config[`${key}Dir`];
51
+ // Scan directory only if moduleGroupInfo is empty.
52
+ if (dir && moduleGroupInfo.size === 0) {
53
+ // For each detected module, get all its information.
54
+ (0, fs_1.findFilesInDir)(dir, `**/*.${key}.js`).forEach(filepath => {
55
+ const replace = `.${key}.js$`;
56
+ const moduleId = filepath.replace(new RegExp(replace), '');
57
+ const absolutePath = path_1.default.join(dir, filepath);
58
+ moduleGroupInfo.set(moduleId, {
59
+ id: moduleId,
60
+ absolutePath,
61
+ relativePath: filepath,
62
+ getModule: () => moduleManager_1.moduleManager.get(absolutePath),
63
+ });
64
+ });
65
+ }
66
+ return moduleGroupInfo;
67
+ },
68
+ reset: () => {
69
+ // Use config here, because outside this function, the config object is not
70
+ // already defined.
71
+ const dir = config_1.config[`${key}Dir`];
72
+ moduleManager_1.moduleManager.removeAll(new RegExp(`^${dir}`));
73
+ moduleGroupInfo.clear();
74
+ },
75
+ };
76
+ return moduleGroupManager;
77
+ };
78
+ exports.dirBasedModuleGroupManager = dirBasedModuleGroupManager;
@@ -0,0 +1,3 @@
1
+ export * from './moduleManager';
2
+ export * from './dirBasedModuleGroupManager';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/utils/module/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC"}