@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,17 @@
1
+ /**
2
+ * Initializes a watcher on any file inside queryDir, hookDir and taskDir.
3
+ *
4
+ * @remarks
5
+ * If runMode is DEV and queryDir, hookDir and/or taskDir are defined by current
6
+ * configuration, a watcher is initialized on them.
7
+ *
8
+ * When something changes inside query directory:
9
+ * 1) Remove all modules inside the query directory, so they are required again.
10
+ * 2) Clear the query cache, since that is not done by the queryManager.
11
+ *
12
+ * When something changes inside hook directory:
13
+ * 1) Remove all modules inside the hook directory, so they are required again.
14
+ * 2) Reload the whole data directory so hooks can be reapplied (this implies clearing the query cache).
15
+ */
16
+ export declare const initWatcher: () => void;
17
+ //# sourceMappingURL=watcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../../src/lib/watcher/watcher.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,QAAO,IAyC9B,CAAC"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initWatcher = void 0;
4
+ const config_1 = require("@lib/config");
5
+ const dataDirManager_1 = require("@lib/store/dataDir/dataDirManager");
6
+ const logger_1 = require("@lib/utils/logger");
7
+ const cache_1 = require("@lib/utils/cache");
8
+ const fs_1 = require("@lib/utils/fs");
9
+ const hook_1 = require("@lib/store/hook");
10
+ const query_1 = require("@lib/query");
11
+ const task_1 = require("@lib/task");
12
+ /**
13
+ * Initializes a watcher on any file inside queryDir, hookDir and taskDir.
14
+ *
15
+ * @remarks
16
+ * If runMode is DEV and queryDir, hookDir and/or taskDir are defined by current
17
+ * configuration, a watcher is initialized on them.
18
+ *
19
+ * When something changes inside query directory:
20
+ * 1) Remove all modules inside the query directory, so they are required again.
21
+ * 2) Clear the query cache, since that is not done by the queryManager.
22
+ *
23
+ * When something changes inside hook directory:
24
+ * 1) Remove all modules inside the hook directory, so they are required again.
25
+ * 2) Reload the whole data directory so hooks can be reapplied (this implies clearing the query cache).
26
+ */
27
+ const initWatcher = () => {
28
+ const paths = [];
29
+ if (config_1.config.queryDir) {
30
+ paths.push(config_1.config.queryDir);
31
+ }
32
+ if (config_1.config.hookDir) {
33
+ paths.push(config_1.config.hookDir);
34
+ }
35
+ if (config_1.config.taskDir) {
36
+ paths.push(config_1.config.taskDir);
37
+ }
38
+ const listener = (filePath) => {
39
+ // Remove all modules inside the query directory.
40
+ if (config_1.config.queryDir && filePath.startsWith(config_1.config.queryDir)) {
41
+ query_1.queryManager.reset();
42
+ // Clear all queries, since they are stale.
43
+ // No need to clear the store subset cache, since no
44
+ // file has been added/updated/deleted.
45
+ cache_1.cache.bin('query').clear();
46
+ }
47
+ // Remove all modules inside the hook directory and reload the whole
48
+ // data directory so hooks can be reapplied.
49
+ if (config_1.config.hookDir && filePath.startsWith(config_1.config.hookDir)) {
50
+ hook_1.hookManager.reset();
51
+ dataDirManager_1.dataDirManager.load();
52
+ logger_1.logger.debug('Re-building store done');
53
+ }
54
+ // Remove all modules inside the task directory.
55
+ if (config_1.config.taskDir && filePath.startsWith(config_1.config.taskDir)) {
56
+ task_1.taskManager.reset();
57
+ }
58
+ };
59
+ (0, fs_1.watch)(paths, {
60
+ add: listener,
61
+ change: listener,
62
+ unlink: listener,
63
+ });
64
+ };
65
+ exports.initWatcher = initWatcher;
@@ -0,0 +1,392 @@
1
+ import { CacheStatus } from '@lib/query/query.types';
2
+ import { LogFile } from '@lib/utils/logger/logger.types';
3
+ import { LogLevel } from '@lib/utils/logger/logger.types';
4
+ import { QueryArgs } from '@lib/query/query.types';
5
+ import { QueryErrorResponse } from '@lib/query/query.types';
6
+ import { QueryModule } from '@lib/query/query.types';
7
+ import { QueryRunner } from '@lib/query/query.types';
8
+ import { QuerySuccessfulResponse } from '@lib/query/query.types';
9
+ import { Store } from '@lib/store/store.types';
10
+
11
+ export { CacheStatus }
12
+
13
+ /**
14
+ * The Data Server instance.
15
+ *
16
+ * @public
17
+ */
18
+ export declare const dataServer: {
19
+ /**
20
+ * Initializes the Data Server.
21
+ *
22
+ * @param options - Configuration options
23
+ *
24
+ * @returns An object with the data store and the queryRunner service.
25
+ */
26
+ init: (options: DataServerInitOptions) => DataServerReturn;
27
+ };
28
+
29
+ /**
30
+ * Init options for Data Server.
31
+ *
32
+ * @public
33
+ */
34
+ export declare type DataServerInitOptions = {
35
+ /**
36
+ * Log level. Optional. @see {@link LogLevel}
37
+ */
38
+ logLevel?: LogLevel;
39
+ /**
40
+ * Path to the log file. Optional. @see {@link LogFile}
41
+ */
42
+ logFile?: LogFile;
43
+ /**
44
+ * Log level for the log file. Optional. @see {@link LogLevel}
45
+ */
46
+ logFileLevel?: LogLevel;
47
+ /**
48
+ * Path to the directory where data is stored.
49
+ */
50
+ dataDir: string;
51
+ /**
52
+ * Path to the directory where work data is stored. Optional.
53
+ */
54
+ workDir?: string;
55
+ /**
56
+ * Path to the directory where queries are stored. Optional.
57
+ */
58
+ queryDir?: string;
59
+ /**
60
+ * Path to the directory where hooks are stored. Optional.
61
+ */
62
+ hookDir?: string;
63
+ /**
64
+ * Path to the directory where tasks are stored. Optional.
65
+ */
66
+ taskDir?: string;
67
+ /**
68
+ * Path to the directory where dumps are stored. Optional.
69
+ */
70
+ dumpDir?: string;
71
+ /**
72
+ * Run mode (dev or prod).
73
+ */
74
+ runMode: RunMode;
75
+ };
76
+
77
+ /**
78
+ * Data returned by Data Server once initialized.
79
+ *
80
+ * @public
81
+ */
82
+ export declare type DataServerReturn = {
83
+ /**
84
+ * The data store.
85
+ */
86
+ store: Store_2;
87
+ /**
88
+ * The query runner, to be able to run queries on demand.
89
+ */
90
+ queryRunner: QueryRunner;
91
+ /**
92
+ * The task runner, to be able to run tasks on demand.
93
+ */
94
+ taskRunner: TaskRunner;
95
+ };
96
+
97
+ export { LogFile }
98
+
99
+ export { LogLevel }
100
+
101
+ export { QueryArgs }
102
+
103
+ export { QueryErrorResponse }
104
+
105
+ export { QueryModule }
106
+
107
+ export { QueryRunner }
108
+
109
+ export { QuerySuccessfulResponse }
110
+
111
+ /**
112
+ * Available run modes: dev or prod.
113
+ *
114
+ * @public
115
+ */
116
+ export declare enum RunMode {
117
+ DEV = "dev",
118
+ PROD = "prod"
119
+ }
120
+
121
+ export { Store }
122
+
123
+ /**
124
+ * The store that holds all data.
125
+ */
126
+ declare type Store_2 = {
127
+ /**
128
+ * Date to tell when was the store last synced.
129
+ *
130
+ * Every time the store is updated, syncDate is set with the last modification
131
+ * date of the data directory, not the date when the store has finished updating.
132
+ *
133
+ * Given this scenario:
134
+ * - Data directory modified at 12:30:00
135
+ * - Syncing the store takes 3 seconds and finishes at 12:30:03
136
+ *
137
+ * ... syncDate will be 12:30:00, not 12:30:03.
138
+ *
139
+ * Doing it the other way round can cause data inconsistencies, because syncing files
140
+ * to the store takes time, it is done sequentially, and in the meanwhile, other
141
+ * modifications can happen:
142
+ * - Store last syncDate is 12:29:00
143
+ * - Data directory is modified at 12:30:00
144
+ * - We ask for modified files after 12:29:00 and got 3 files (1.json, 2.json and 3.json)
145
+ * - File "1.json" is processed and added to the store at 12:30:01
146
+ * - While "2.json" is being processed and added to the store, data directory is modified
147
+ * again at 12:30:02 and "1.json" is changed.
148
+ * - File "3.json" is processed and added to the store at 12:30:03
149
+ *
150
+ * At this moment, there are two options:
151
+ *
152
+ * 1) Setting syncDate to the current date:
153
+ * - Store syncDate is set to 12:30:03
154
+ * - Data directory is modified again at 12:30:10 and only "3.json" is changed
155
+ * - We ask for modified files after 12:30:03 and get only "3.json"
156
+ * - Modification done at 12:30:02 to "1.json" is lost and cannot be recovered unless "1.json" is
157
+ * modified again, or Data Server is restarted
158
+ *
159
+ * 2) Setting syncDate to the last modification date of the data directory:
160
+ * - Store syncDate is set to 12:30:00
161
+ * - Data directory is modified again at 12:30:10 and only "3.json" is changed
162
+ * - We ask for modified files after 12:30:00 and get "1.json" and "3.json"
163
+ * - Modification done at 12:30:02 to "1.json" is properly processed
164
+ */
165
+ syncDate: Date | null;
166
+ /**
167
+ * Map that holds all data for all files.
168
+ *
169
+ * @remarks
170
+ * This map contains files, keyed by their relative filepath. No directory or
171
+ * any other structure is stored here.
172
+ *
173
+ * When executing a query, a common pattern is to create a subset of this
174
+ * map (e.g.- to get all articles of an specific language) and the execute the
175
+ * query against that subset. To do so, see {@link Store#subset}
176
+ *
177
+ * @example
178
+ * ```
179
+ * // Find an specific article.
180
+ * const article = store.data.get('en/entity/node/article/123.json');
181
+ * const article = store.index.url.get('public/pretty/url');
182
+ * const article = store.index.uuid.get('nl').get('ce736c8b-a6ea-43c4-9a6b-ad1fc498017c');
183
+ * const article = store.index.custom.get('taxonomies').get('12234');
184
+ *
185
+ * // Create a subset of all english articles.
186
+ * const results = store.data.subset({ dir: 'en/entity/node/article/', recursive: true });
187
+ * ```
188
+ */
189
+ data: StoreData<string, any>;
190
+ /**
191
+ * A list of deleted files from store, to be able to track them.
192
+ */
193
+ deleted: Set<string>;
194
+ /**
195
+ * An object to hold accessory index data.
196
+ */
197
+ index: {
198
+ /**
199
+ * An index that holds all data for all files, keyed by their URL.
200
+ */
201
+ url: Map<string, any>;
202
+ /**
203
+ * An index that holds all data for all files, keyed by their lang and uuid.
204
+ */
205
+ uuid: Map<string, any>;
206
+ /**
207
+ * An index to hold custom data defined in hooks or queries.
208
+ */
209
+ custom: Map<string, any>;
210
+ };
211
+ };
212
+
213
+ declare interface StoreData<K, V> extends Map<K, V> {
214
+ /**
215
+ * Create a subset with all files in store that match the given arguments.
216
+ *
217
+ * @remarks
218
+ * All subsets are automatically cached, so passing the same arguments
219
+ * will return the same subset from the cache.
220
+ *
221
+ * This is the preferred way of getting a subset of the store files,
222
+ * since is a simple function that most of the times only requires
223
+ * the first argument.
224
+ *
225
+ * @example
226
+ * ```
227
+ * // Get a subset of all nodes with "json" extension.
228
+ * dataServer.store.data.subset({ dir: 'en/entity/node/', variant: null });
229
+ *
230
+ * // Get a subset of all articles in all languages with "json" extension.
231
+ * dataServer.store.data.subset({ dir: '.+/entity/node/article/' });
232
+ *
233
+ * // Get a subset of all articles regardless of their extension.
234
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', ext: null });
235
+ *
236
+ * // Get a subset of all card variants for articles with "json" extension.
237
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', variant: null });
238
+ *
239
+ * // Get a subset of english articles, with "yml" extension, non-recursively.
240
+ * dataServer.store.data.subset({ dir: 'en/entity/node/article/', ext: 'yml', recursive: false });
241
+ * ```
242
+ *
243
+ * @param options - Object with options for creating a store subset.
244
+ *
245
+ * @returns An object with "filenames" and "items".
246
+ */
247
+ subset(options: StoreSubsetOptions): StoreSubset;
248
+ }
249
+
250
+ /**
251
+ * Object holding a subset of items from the store.
252
+ */
253
+ declare type StoreSubset = {
254
+ /**
255
+ * Array of filenames in this subset.
256
+ */
257
+ filenames: Array<string>;
258
+ /**
259
+ * Array of items in this subset.
260
+ */
261
+ items: Array<any>;
262
+ };
263
+
264
+ /**
265
+ * Options for subset() function.
266
+ */
267
+ declare type StoreSubsetOptions = {
268
+ /**
269
+ * Optional base directory to filter files.
270
+ *
271
+ * @remarks
272
+ * It requires a trailing slash, but not a leading slash, e.g.- "en/entity/node/article/"
273
+ */
274
+ dir?: string;
275
+ /**
276
+ * Optional name of a variant file.
277
+ *
278
+ * @remarks
279
+ * Use '_main' to obtain the default variant.
280
+ * Use any other string, e.g.- 'card', to obtain the card variant.
281
+ * Use null to avoid searching for any variant.
282
+ * Defaults to '_main'.
283
+ */
284
+ variant?: string;
285
+ /**
286
+ * Optional file extension, without dots. Defaults to 'json'.
287
+ */
288
+ ext?: string;
289
+ /**
290
+ * Optional flag to search for files recursively. True by default.
291
+ */
292
+ recursive?: boolean;
293
+ };
294
+
295
+ /**
296
+ * An object with task arguments.
297
+ *
298
+ * @public
299
+ */
300
+ declare type TaskArgs = Record<string, any>;
301
+
302
+ /**
303
+ * An error response returned after executing a task.
304
+ *
305
+ * @remarks
306
+ * It takes an string from TaskModule#taskHandler, and wraps them into an
307
+ * structure with metadata. @see {@link TaskModule#default}
308
+ *
309
+ * @public
310
+ */
311
+ declare type TaskErrorResponse = {
312
+ /**
313
+ * Error message from the task, usually coming from a failed validation.
314
+ */
315
+ error: string;
316
+ };
317
+
318
+ /**
319
+ * A service to handle the execution of tasks.
320
+ *
321
+ * @public
322
+ */
323
+ declare type TaskRunner = {
324
+ /**
325
+ * Runs a task and returns its results with metadata.
326
+ *
327
+ * @remarks
328
+ * It checks several validations before a task is run, and then task is executed.
329
+ *
330
+ * It logs an error and throws an exception if any problem occurs during the
331
+ * task execution.
332
+ *
333
+ * @param taskId - Task ID (filename without extension and suffix) of the task
334
+ * to be executed. @see {@link ModuleInfo#id | Definition of a module ID}
335
+ * @param args - Optional object with task arguments.
336
+ *
337
+ * @returns The result of the task as a JSON object with data and metadata keys,
338
+ * or an error response if some validation is not met.
339
+ *
340
+ * @example
341
+ * Here's a result example:
342
+ * ```
343
+ * {
344
+ * data: ['title 1', 'title 2'],
345
+ * metadata: {
346
+ * contentType: 'application/json',
347
+ * execTime: 2,
348
+ * }
349
+ * }
350
+ * ```
351
+
352
+ * @throws
353
+ * Exception thrown if any problem occurs during the task execution.
354
+ */
355
+ run(taskId: string, args: TaskArgs): TaskSuccessfulResponse | TaskErrorResponse;
356
+ };
357
+
358
+ /**
359
+ * A successful response returned after executing a task.
360
+ *
361
+ * @remarks
362
+ * It takes the results from a TaskModule#taskHandler, and wraps them into an
363
+ * structure with metadata. @see {@link TaskModule#default}
364
+ *
365
+ * @public
366
+ */
367
+ declare type TaskSuccessfulResponse = {
368
+ /**
369
+ * Data returned by the task. @see {@link TaskModule#default}
370
+ */
371
+ data: any;
372
+ /**
373
+ * Task metadata
374
+ */
375
+ metadata: {
376
+ /**
377
+ * Content type for the data available in "data"
378
+ *
379
+ * @remarks
380
+ * Even thought this structure is a JSON object, data coming from the
381
+ * task can be anything (XML, a string, etc). It must be specified so any
382
+ * consumer of this data knows what is being returned.
383
+ */
384
+ contentType: string;
385
+ /**
386
+ * Execution time taken by the task, in milliseconds.
387
+ */
388
+ execTimeMs: number;
389
+ };
390
+ };
391
+
392
+ export { }
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@static-suite/static-suite-data-server",
3
+ "version": "0.0.1",
4
+ "description": "A flexible, fast and developer friendly Data Server for Static Suite",
5
+ "main": "./dist/lib/index.js",
6
+ "typings": "./dist/lib/index.d.ts",
7
+ "license": "GPL-2.0+",
8
+ "dependencies": {
9
+ "@creativebulma/bulma-tooltip": "^1.2.0",
10
+ "@microsoft/api-extractor": "^7.18.19",
11
+ "@types/jest": "^27.0.2",
12
+ "@types/tap": "^15.0.5",
13
+ "bulma": "^0.9.3",
14
+ "chokidar": "^3.5.2",
15
+ "clear-module": "^4.1.1",
16
+ "clipboard": "^2.0.8",
17
+ "copyfiles": "^2.4.1",
18
+ "cors": "^2.8.5",
19
+ "decache": "^4.6.0",
20
+ "express": "^4.17.1",
21
+ "fast-glob": "^3.2.7",
22
+ "marked": "^3.0.4",
23
+ "microtime": "^3.0.0",
24
+ "mime-types": "^2.1.33",
25
+ "module-alias": "^2.2.2",
26
+ "nodemon": "^2.0.13",
27
+ "pug": "^3.0.2",
28
+ "simple-datatables": "^3.1.2",
29
+ "tsc-watch": "^4.5.0",
30
+ "typescript": "^4.4.3",
31
+ "winston": "^3.3.3",
32
+ "yargs": "^17.2.1"
33
+ },
34
+ "bin": {
35
+ "static-suite-data-server": "./dist/bin/serve.js"
36
+ },
37
+ "scripts": {
38
+ "dev": "tsc-watch --onSuccess \"yarn lint\"",
39
+ "build": "yarn copy-http-files-to-src && yarn lint && tsc && yarn api-extractor run --local --verbose && yarn post-build && yarn copy-http-files-to-dist",
40
+ "post-build": "yarn rimraf dist/**/*__tests__",
41
+ "serve": "node ./dist/bin/serve.js http --port=57471 --data-dir=./src/__tests__/fixtures/data --work-dir=./src/__tests__/fixtures/work --query-dir=./src/__tests__/fixtures/query --hook-dir=./src/__tests__/fixtures/hook --task-dir=./src/__tests__/fixtures/task --run-mode=dev --log-level=debug",
42
+ "lint": "eslint . --ext .ts",
43
+ "docs": "yarn typedoc --out docs src/lib/",
44
+ "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
45
+ "test": "jest --watch",
46
+ "copy-http-files-to-src": "node ./scripts/copy-http-files-to-src.js",
47
+ "copy-http-files-to-dist": "cp -r ./src/http/public/ ./dist/http/ && cp -r ./src/http/views/ ./dist/http/ && cp README.md ./dist/http/"
48
+ },
49
+ "devDependencies": {
50
+ "@types/cors": "^2.8.12",
51
+ "@types/express": "^4.17.13",
52
+ "@types/marked": "^3.0.2",
53
+ "@types/microtime": "^2.1.0",
54
+ "@types/mime-types": "^2.1.1",
55
+ "@types/module-alias": "^2.0.1",
56
+ "@types/node": "^16.10.2",
57
+ "@types/yargs": "^17.0.3",
58
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
59
+ "@typescript-eslint/parser": "^4.33.0",
60
+ "eslint": "^7.32.0",
61
+ "eslint-config-airbnb-typescript-prettier": "^4.2.0",
62
+ "eslint-import-resolver-typescript": "^2.5.0",
63
+ "eslint-plugin-import": "^2.25.2",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "eslint-plugin-tsdoc": "^0.2.14",
66
+ "husky": "^4.3.7",
67
+ "jest": "^27.3.1",
68
+ "prettier": "^2.4.1",
69
+ "ts-jest": "^27.0.7",
70
+ "typedoc": "^0.22.6",
71
+ "yarn-upgrade-all": "^0.5.4"
72
+ },
73
+ "_moduleAliases": {
74
+ "@bin": "dist/bin",
75
+ "@http": "dist/http",
76
+ "@lib": "dist/lib",
77
+ "@__tests__": "dist/__tests__"
78
+ },
79
+ "jest": {
80
+ "preset": "ts-jest",
81
+ "verbose": true,
82
+ "moduleDirectories": [
83
+ "node_modules",
84
+ "src"
85
+ ],
86
+ "testPathIgnorePatterns": [
87
+ "src/__tests__/fixtures/*",
88
+ "src/__tests__/mocks/*"
89
+ ],
90
+ "moduleNameMapper": {
91
+ "^@bin/(.*)$": "<rootDir>/src/bin/$1",
92
+ "^@http/(.*)$": "<rootDir>/src/http/$1",
93
+ "^@lib/(.*)$": "<rootDir>/src/lib/$1",
94
+ "^@__tests__/(.*)$": "<rootDir>/src/__tests__/$1"
95
+ }
96
+ },
97
+ "husky": {
98
+ "hooks": {
99
+ "pre-commit": "yarn build"
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Script to run after npm install
3
+ *
4
+ * Copy selected files to assets directory
5
+ */
6
+
7
+ const fs = require('fs');
8
+
9
+ // Copy files from Bulma to assets directory
10
+ const bulmaSrcDir = 'node_modules/bulma/css/';
11
+ const bulmaTargetDir = `${process.env.INIT_CWD}/src/http/public/assets/bulma/`;
12
+ fs.mkdirSync(bulmaTargetDir, { recursive: true });
13
+ fs.copyFileSync(
14
+ `${bulmaSrcDir}/bulma.min.css`,
15
+ `${bulmaTargetDir}/bulma.min.css`,
16
+ );
17
+
18
+ // Copy files from Bulma tooltip to assets directory
19
+ const bulmaTooltipSrcDir = 'node_modules/@creativebulma/bulma-tooltip/dist/';
20
+ fs.copyFileSync(
21
+ `${bulmaTooltipSrcDir}/bulma-tooltip.min.css`,
22
+ `${bulmaTargetDir}/bulma-tooltip.min.css`,
23
+ );
24
+
25
+ // Copy files from Clipboard to assets directory
26
+ const clipboardSrcDir = 'node_modules/clipboard/dist/';
27
+ const clipboardTargetDir = `${process.env.INIT_CWD}/src/http/public/assets/clipboard/`;
28
+ fs.mkdirSync(clipboardTargetDir, { recursive: true });
29
+ fs.copyFileSync(
30
+ `${clipboardSrcDir}/clipboard.min.js`,
31
+ `${clipboardTargetDir}/clipboard.min.js`,
32
+ );
33
+
34
+ // Copy files from datatables to assets directory
35
+ const dataTablesSrcDir = 'node_modules/simple-datatables/dist/';
36
+ const dataTablesTargetDir = `${process.env.INIT_CWD}/src/http/public/assets/simple-datatables/`;
37
+ fs.mkdirSync(dataTablesTargetDir, { recursive: true });
38
+ fs.copyFileSync(
39
+ `${dataTablesSrcDir}/umd/simple-datatables.js`,
40
+ `${dataTablesTargetDir}/index.js`,
41
+ );
42
+ fs.copyFileSync(
43
+ `${dataTablesSrcDir}/style.css`,
44
+ `${dataTablesTargetDir}/style.css`,
45
+ );
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "en"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "entity"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "article1--card"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "article1--small"
3
+ }
@@ -0,0 +1,40 @@
1
+ {
2
+ "data": {
3
+ "content": {
4
+ "id": "58724",
5
+ "title": "Title 1",
6
+ "author": {
7
+ "entity": {
8
+ "entityInclude": "en/entity/node/article/article2.json"
9
+ }
10
+ },
11
+ "image": {
12
+ "entity": {
13
+ "entityInclude": "en/entity/node/article/article2.json"
14
+ }
15
+ },
16
+ "queryInclude": "query1?y=33",
17
+ "article2CustomInclude": "en/entity/node/article/article3.json",
18
+ "customInclude": "en/entity/node/article/article3.json",
19
+ "localeInclude": "en/entity/node/article/article3.json",
20
+ "configInclude": "en/entity/node/article/article3.json",
21
+ "thisConfigInclude": "en/entity/node/article/article3.json"
22
+ }
23
+ },
24
+ "metadata": {
25
+ "includes": {
26
+ "static": {
27
+ "data.content.author.entity.entityInclude": "en/entity/node/article/article2.json",
28
+ "data.content.image.entity.entityInclude": "en/entity/node/article/article2.json",
29
+ "data.content.article2CustomInclude": "en/entity/node/article/article3.json",
30
+ "data.content.customInclude": "en/entity/node/article/article3.json",
31
+ "data.content.localeInclude": "en/entity/node/article/article3.json",
32
+ "data.content.configInclude": "en/entity/node/article/article3.json",
33
+ "data.content.thisConfigInclude": "en/entity/node/article/article3.json"
34
+ },
35
+ "dynamic": {
36
+ "data.content.queryInclude": "query1?y=33"
37
+ }
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "name": "article2--card"
3
+ }