@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,144 @@
1
+ /* eslint-disable global-require */
2
+ /* eslint-disable import/no-dynamic-require */
3
+ import clearModule from 'clear-module';
4
+ import { logger } from '@lib/utils/logger';
5
+ import { config } from '@lib/config';
6
+ import { store } from '@lib/store';
7
+
8
+ /**
9
+ * Internal module cache.
10
+ *
11
+ * @remarks
12
+ * It does not use the shared cache util since this cache must to be
13
+ * managed only by this module, and should not be accessible nor
14
+ * managed from the outside.
15
+ */
16
+ const internalModuleCache: Record<string, any> = {};
17
+
18
+ /**
19
+ * Internal resolve cache.
20
+ *
21
+ * @remarks
22
+ * It does not use the shared cache util since this cache must be
23
+ * managed only by this module, and should not be accessible nor
24
+ * managed from the outside.
25
+ */
26
+ const internalResolveCache: Record<string, any> = {};
27
+
28
+ /**
29
+ * Resolves a path to a module
30
+ *
31
+ * @param modulePath - A path to a module
32
+ * @returns The resolved path, or the given unresolved path if module cannot be found
33
+ */
34
+ const resolve = (modulePath: string): string => {
35
+ let resolvedModulePath = internalResolveCache[modulePath];
36
+ if (!resolvedModulePath) {
37
+ try {
38
+ resolvedModulePath = require.resolve(modulePath);
39
+ } catch (e) {
40
+ resolvedModulePath = modulePath;
41
+ }
42
+ internalResolveCache[modulePath] = resolvedModulePath;
43
+ }
44
+ return resolvedModulePath;
45
+ };
46
+
47
+ /**
48
+ * Module system that manages the caching of modules.
49
+ *
50
+ * @remarks
51
+ * Modules are cached by Node.js when they are required. This module handler
52
+ * is able to remove them from Node.js cache and reload them from scratch.
53
+ *
54
+ * This manager is aimed at handling "user-land" modules, i.e.- modules managed
55
+ * by users and not part of the Data Server core. Those "user-land" modules are
56
+ * queries and hooks, so trying to manage other kind of module will throw and error.
57
+ */
58
+ export const moduleManager = {
59
+ /**
60
+ * Loads a module from scratch
61
+ *
62
+ * @remarks
63
+ * Removes a module from Node.js cache, and loads it from scratch.
64
+ * If the module is not valid or not found, it logs an error and throws
65
+ * an exception.
66
+ *
67
+ * @param modulePath - Path to the module to be loaded
68
+ * @typeParam Type - Type of the module to be loaded
69
+ *
70
+ * @returns - The requested module
71
+ *
72
+ * @throws
73
+ * An exception if the module is not valid or it cannot be loaded.
74
+ */
75
+ load: <Type>(modulePath: string): Type => {
76
+ const resolvedModulePath = resolve(modulePath);
77
+ moduleManager.remove(resolvedModulePath, { useLogger: false });
78
+ try {
79
+ internalModuleCache[resolvedModulePath] = require(resolvedModulePath);
80
+ } catch (e) {
81
+ logger.error(`Module "${resolvedModulePath}" not found.`);
82
+ throw e;
83
+ }
84
+ if (internalModuleCache[resolvedModulePath].onModuleLoad) {
85
+ internalModuleCache[resolvedModulePath].onModuleLoad({ config, store });
86
+ }
87
+ logger.debug(`Module ${resolvedModulePath} successfully loaded.`);
88
+ return internalModuleCache[resolvedModulePath];
89
+ },
90
+
91
+ /**
92
+ * Removes a single module from Node.js cache
93
+ *
94
+ * @param modulePath - Path to the module to be removed
95
+ * @param options - Object of options:
96
+ * useLogger: Flag to use logger or not. Useful to avoid
97
+ * "remove" log lines when this function is called from
98
+ * other functions.
99
+ */
100
+ remove: (modulePath: string, options = { useLogger: true }): void => {
101
+ const resolvedModulePath = resolve(modulePath);
102
+ clearModule(resolvedModulePath);
103
+ delete internalModuleCache[resolvedModulePath];
104
+ if (options.useLogger) {
105
+ logger.debug(`Module ${resolvedModulePath} successfully removed.`);
106
+ }
107
+ },
108
+
109
+ /**
110
+ * Removes several modules from Node.js cache at once
111
+ *
112
+ * @param regex - Regular expression to be tested again cached modules path
113
+ */
114
+ removeAll: (regex: RegExp): void => {
115
+ const modulePathsToBeRemoved = Object.keys(require.cache).filter(
116
+ modulePath => regex.test(modulePath),
117
+ );
118
+ modulePathsToBeRemoved.forEach(modulePath =>
119
+ moduleManager.remove(modulePath),
120
+ );
121
+ },
122
+
123
+ /**
124
+ * Gets a module from cache or loads it from scratch
125
+ *
126
+ * @remarks
127
+ * If module is not found, logs an error and throws an exception.
128
+ *
129
+ * @param modulePath - Path to the module to be loaded
130
+ * @typeParam Type - Type of the module to be loaded
131
+ *
132
+ * @returns - The requested module
133
+ *
134
+ * @throws
135
+ * An exception if the module cannot be loaded.
136
+ */
137
+ get: <Type>(modulePath: string): Type => {
138
+ const resolvedModulePath = resolve(modulePath);
139
+ return (
140
+ internalModuleCache[resolvedModulePath] ||
141
+ moduleManager.load(resolvedModulePath)
142
+ );
143
+ },
144
+ };
@@ -0,0 +1,62 @@
1
+ import { getObjValue } from '..';
2
+ import { isEmptyObject, hasKey, deepClone, jsonify } from '../objectUtils';
3
+
4
+ describe('Object utils test', () => {
5
+ describe('isEmptyObject', () => {
6
+ it('returns true for an empty object', () => {
7
+ expect(isEmptyObject({})).toBe(true);
8
+ });
9
+ it('returns false for a non empty object', () => {
10
+ expect(isEmptyObject({ x: 1 })).toBe(false);
11
+ });
12
+ });
13
+
14
+ describe('hasKey', () => {
15
+ it('returns true if an object has a given key', () => {
16
+ expect(hasKey({ x: 1 }, 'x')).toBe(true);
17
+ });
18
+ it('returns false if an object does not have a given key', () => {
19
+ expect(hasKey({ x: 1 }, 'y')).toBe(false);
20
+ });
21
+ });
22
+
23
+ describe('deepClone', () => {
24
+ it('returns an object equal to the given one, without references to nested objects', () => {
25
+ const anObject = { x: 1, y: {} };
26
+ const anotherObject = { z: 34 };
27
+ anObject.y = anotherObject;
28
+ const clonedObject = deepClone(anObject);
29
+ expect(clonedObject).toStrictEqual(anObject);
30
+ anotherObject.z = 22;
31
+ expect(clonedObject).not.toStrictEqual(anObject);
32
+ });
33
+ });
34
+ describe('getObjectValue', () => {
35
+ const testObject = { x: { y: { z: 'value' } } };
36
+ it('gets object value with default separator', () => {
37
+ expect(getObjValue(testObject, 'x.y.z')).toBe('value');
38
+ });
39
+ it('gets object value with custom separator', () => {
40
+ expect(getObjValue(testObject, 'x/y/z', '/')).toBe('value');
41
+ });
42
+ it('gets object value with array separator', () => {
43
+ expect(getObjValue(testObject, ['x', 'y', 'z'])).toBe('value');
44
+ });
45
+ it('gets undefined when path does not exist', () => {
46
+ expect(getObjValue(testObject, 'x.z.z')).toBeUndefined();
47
+ });
48
+ });
49
+
50
+ describe('jsonify', () => {
51
+ const testObject = {
52
+ x: new Set([1, 2]),
53
+ y: new Map([['mapKey', 'mapValue']]),
54
+ };
55
+ it('jsonify object containing Set and Map', () => {
56
+ expect(jsonify(testObject)).toEqual({
57
+ x: [1, 2],
58
+ y: { mapKey: 'mapValue' },
59
+ });
60
+ });
61
+ });
62
+ });
@@ -0,0 +1 @@
1
+ export * from './objectUtils';
@@ -0,0 +1,74 @@
1
+ export type ObjectType = Record<string, unknown>;
2
+
3
+ /**
4
+ * Structure where a content's data and metadata os hold.
5
+ *
6
+ * @remarks
7
+ * This type describes any JSON object, which can contain any data, but
8
+ * it is usually structured this way:
9
+ *
10
+ * @example
11
+ * ```
12
+ * {
13
+ * "data": {
14
+ * "content": {
15
+ * ...,
16
+ * }
17
+ * }
18
+ * "metadata": {
19
+ * "includes": [
20
+ * "data.content.author.entity.entityInclude",
21
+ * "data.content.image.entity.entityInclude",
22
+ * "data.content.queryInclude"
23
+ * ]
24
+ * }
25
+ * }
26
+ * ```
27
+ */
28
+ export type Json = {
29
+ [key: string]: any;
30
+
31
+ /**
32
+ * Optional structure for a content's data.
33
+ */
34
+ data?: {
35
+ [key: string]: any;
36
+ /**
37
+ * Optional object that holds the fields of a Drupal content.
38
+ */
39
+ content?: Record<string, any>;
40
+ };
41
+
42
+ /**
43
+ * Optional structure for metadata includes.
44
+ */
45
+ metadata?: {
46
+ [key: string]: any;
47
+ /**
48
+ * Optional array for metadata includes.
49
+ *
50
+ * @remarks
51
+ * Every include path is stored in this array, so they can be
52
+ * easily accessed.
53
+ *
54
+ * @example
55
+ * ```
56
+ * "metadata": {
57
+ * "includes": [
58
+ * "static": [
59
+ * "data.content.author.entity.entityInclude",
60
+ * "data.content.image.entity.entityInclude",
61
+ * ]
62
+ * "dynamic": [
63
+ * "data.content.queryInclude"
64
+ * ]
65
+ * ]
66
+ * }
67
+ * ```
68
+ */
69
+ includes?: {
70
+ static?: Record<string, string>;
71
+ dynamic?: Record<string, string>;
72
+ };
73
+ };
74
+ };
@@ -0,0 +1,71 @@
1
+ import { ObjectType } from './object.types';
2
+
3
+ /**
4
+ * Checks if an object is empty (i.e.- contains zero keys)
5
+ *
6
+ * @param object - An object
7
+ *
8
+ * @returns True if the object contains zero keys, false otherwise.
9
+ */
10
+ export const isEmptyObject = (object: ObjectType): boolean =>
11
+ Object.keys(object).length === 0;
12
+
13
+ /**
14
+ * Checks if an object contains a key
15
+ *
16
+ * @param object - An object
17
+ * @param key - The name of a key
18
+ *
19
+ * @returns True if the object has the given key, false otherwise.
20
+ */
21
+ export const hasKey = <O>(object: O, key: PropertyKey): key is keyof O => {
22
+ return key in object;
23
+ };
24
+
25
+ /**
26
+ * Clones an object and all its nested objects
27
+ *
28
+ * @param object - An object to be cloned
29
+ *
30
+ * @returns An identical object without references to nested objects
31
+ */
32
+ export const deepClone = (object: ObjectType): ObjectType =>
33
+ JSON.parse(JSON.stringify(object));
34
+
35
+ /**
36
+ * Gets object property by property path
37
+ *
38
+ * @param object - An object
39
+ * @param path - A string or array of strings
40
+ * @param separator - Optional separator if path is a string. '.' by default.
41
+ *
42
+ * @returns Value of the path or undefined
43
+ */
44
+ export const getObjValue = (
45
+ object: ObjectType,
46
+ path: string | string[],
47
+ separator?: string,
48
+ ): any | undefined => {
49
+ const pathArray = Array.isArray(path) ? path : path.split(separator || '.');
50
+ return pathArray.reduce(
51
+ (previous: any, current: any) => previous?.[current],
52
+ object,
53
+ );
54
+ };
55
+
56
+ /**
57
+ * Converts a JavaScript value containing Set and Map, to a JSON object.
58
+ *
59
+ * @param value - A JavaScript value to be converted.
60
+ *
61
+ * @returns A JSON object
62
+ */
63
+ export const jsonify = <T>(value: T): T => {
64
+ return JSON.parse(
65
+ JSON.stringify(value, (k, v) => {
66
+ if (v instanceof Set) return [...v];
67
+ if (v instanceof Map) return Object.fromEntries(v);
68
+ return v;
69
+ }),
70
+ );
71
+ };
@@ -0,0 +1,30 @@
1
+ import { logger } from '@lib/utils/logger';
2
+ import { parseJsonString, parseURLSearchParams } from '../stringUtils';
3
+
4
+ describe('String utils test', () => {
5
+ describe('parseJsonString', () => {
6
+ logger.error = jest.fn();
7
+ it('parses a well-formed JSON string without logging any error', () => {
8
+ expect(parseJsonString('{"key": "value"}')).not.toBeNull();
9
+ expect(logger.error).not.toHaveBeenCalled();
10
+ });
11
+ it('logs an error when parsing a malformed JSON string', () => {
12
+ expect(parseJsonString('malformed-json-string')).toBeNull();
13
+ expect(logger.error).toHaveBeenCalled();
14
+ });
15
+ });
16
+
17
+ describe('parseURLSearchParams', () => {
18
+ it('parses a query string with non repeated keys and returns an object', () => {
19
+ const parsedQuery = parseURLSearchParams('arg1=a&arg2=b');
20
+ const expectedValue = { arg1: 'a', arg2: 'b' };
21
+ expect(parsedQuery).toStrictEqual(expectedValue);
22
+ });
23
+
24
+ it('parses a query string with repeated keys and returns an object', () => {
25
+ const parsedQuery = parseURLSearchParams('arg1=a&arg2=b&arg1=c');
26
+ const expectedValue = { arg1: ['a', 'c'], arg2: 'b' };
27
+ expect(parsedQuery).toEqual(expectedValue);
28
+ });
29
+ });
30
+ });
@@ -0,0 +1 @@
1
+ export * from './stringUtils';
@@ -0,0 +1 @@
1
+ export type URLSearchParamsObject = Record<string, string | string[] | null>;
@@ -0,0 +1,61 @@
1
+ import { logger } from '@lib/utils/logger';
2
+ import { URLSearchParamsObject } from './string.types';
3
+
4
+ /**
5
+ * Separator for variant data files saved to storage.
6
+ *
7
+ * @remarks
8
+ * Refers to the separator that is used by variant data files when they are
9
+ * saved. If a "master" data file name is "12345.json", and its variant keys
10
+ * are "card" and "search", its resulting variant file names are:
11
+ * - 12345--card.json
12
+ * - 12345--search.json
13
+ * @see ExporterPluginInterface::VARIANT_SEPARATOR in https://www.drupal.org/project/static_suite
14
+ *
15
+ * @sealed
16
+ * Not intended to be over ride.
17
+ */
18
+ export const VARIANT_SEPARATOR = '--';
19
+
20
+ /**
21
+ * Parses a JSON string and logs an error on failure.
22
+ *
23
+ * @param jsonString - The string to be parsed.
24
+ *
25
+ * @returns A JSON object or null on error.
26
+ */
27
+ export const parseJsonString = (jsonString: string): any => {
28
+ let json = null;
29
+ try {
30
+ json = JSON.parse(jsonString);
31
+ } catch (error) {
32
+ logger.error(`Error parsing JSON data "${jsonString}": ${error}`);
33
+ }
34
+ return json;
35
+ };
36
+
37
+ /**
38
+ * Parses a raw URL search (aka "query string") into an object.
39
+ *
40
+ * @remarks
41
+ * Turns a string like "arg1=a&arg2=b" into an object like
42
+ * \{ arg1: 'a', arg2: 'b'\}
43
+ *
44
+ * @param queryString - A raw URL search string
45
+ *
46
+ * @returns An object where its keys are the query arguments.
47
+ */
48
+ export const parseURLSearchParams = (
49
+ queryString: string,
50
+ ): URLSearchParamsObject => {
51
+ const params = new URLSearchParams(queryString);
52
+ const obj: URLSearchParamsObject = {};
53
+ Array.from(params.keys()).forEach(key => {
54
+ if (params.getAll(key).length > 1) {
55
+ obj[key] = params.getAll(key);
56
+ } else {
57
+ obj[key] = params.get(key);
58
+ }
59
+ });
60
+ return obj;
61
+ };
@@ -0,0 +1 @@
1
+ export * from './watcher';
@@ -0,0 +1,66 @@
1
+ import { config } from '@lib/config';
2
+ import { dataDirManager } from '@lib/store/dataDir/dataDirManager';
3
+ import { logger } from '@lib/utils/logger';
4
+ import { cache } from '@lib/utils/cache';
5
+ import { watch } from '@lib/utils/fs';
6
+ import { hookManager } from '@lib/store/hook';
7
+ import { queryManager } from '@lib/query';
8
+ import { taskManager } from '@lib/task';
9
+
10
+ /**
11
+ * Initializes a watcher on any file inside queryDir, hookDir and taskDir.
12
+ *
13
+ * @remarks
14
+ * If runMode is DEV and queryDir, hookDir and/or taskDir are defined by current
15
+ * configuration, a watcher is initialized on them.
16
+ *
17
+ * When something changes inside query directory:
18
+ * 1) Remove all modules inside the query directory, so they are required again.
19
+ * 2) Clear the query cache, since that is not done by the queryManager.
20
+ *
21
+ * When something changes inside hook directory:
22
+ * 1) Remove all modules inside the hook directory, so they are required again.
23
+ * 2) Reload the whole data directory so hooks can be reapplied (this implies clearing the query cache).
24
+ */
25
+ export const initWatcher = (): void => {
26
+ const paths: string[] = [];
27
+ if (config.queryDir) {
28
+ paths.push(config.queryDir);
29
+ }
30
+ if (config.hookDir) {
31
+ paths.push(config.hookDir);
32
+ }
33
+ if (config.taskDir) {
34
+ paths.push(config.taskDir);
35
+ }
36
+
37
+ const listener = (filePath: string) => {
38
+ // Remove all modules inside the query directory.
39
+ if (config.queryDir && filePath.startsWith(config.queryDir)) {
40
+ queryManager.reset();
41
+ // Clear all queries, since they are stale.
42
+ // No need to clear the store subset cache, since no
43
+ // file has been added/updated/deleted.
44
+ cache.bin('query').clear();
45
+ }
46
+
47
+ // Remove all modules inside the hook directory and reload the whole
48
+ // data directory so hooks can be reapplied.
49
+ if (config.hookDir && filePath.startsWith(config.hookDir)) {
50
+ hookManager.reset();
51
+ dataDirManager.load();
52
+ logger.debug('Re-building store done');
53
+ }
54
+
55
+ // Remove all modules inside the task directory.
56
+ if (config.taskDir && filePath.startsWith(config.taskDir)) {
57
+ taskManager.reset();
58
+ }
59
+ };
60
+
61
+ watch(paths, {
62
+ add: listener,
63
+ change: listener,
64
+ unlink: listener,
65
+ });
66
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Basic Options */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ "target": "ES2020" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */,
8
+ "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
9
+ "lib": [
10
+ "ES2020",
11
+ "dom",
12
+ "dom.iterable"
13
+ ] /* Specify library files to be included in the compilation. */,
14
+ // "allowJs": true, /* Allow javascript files to be compiled. */
15
+ // "checkJs": true, /* Report errors in .js files. */
16
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
17
+ "declaration": true /* Generates corresponding '.d.ts' file. */,
18
+ "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
19
+ // "sourceMap": true, /* Generates corresponding '.map' file. */
20
+ // "outFile": "./", /* Concatenate and emit output to single file. */
21
+ "outDir": "./dist" /* Redirect output structure to the directory. */,
22
+ "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
23
+ // "composite": true, /* Enable project compilation */
24
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
25
+ // "removeComments": true, /* Do not emit comments to output. */
26
+ // "noEmit": true, /* Do not emit outputs. */
27
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
28
+ "downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
29
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
30
+
31
+ /* Strict Type-Checking Options */
32
+ "strict": true /* Enable all strict type-checking options. */,
33
+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
34
+ // "strictNullChecks": true, /* Enable strict null checks. */
35
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
36
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
37
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
38
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
39
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
40
+
41
+ /* Additional Checks */
42
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
43
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
44
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
45
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
46
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
47
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
48
+ // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
49
+
50
+ /* Module Resolution Options */
51
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
52
+ "baseUrl": "./src" /* Base directory to resolve non-absolute module names. */,
53
+ "paths": {
54
+ "@bin/*": ["bin/*"],
55
+ "@http/*": ["http/*"],
56
+ "@lib/*": ["lib/*"],
57
+ "@__tests__/*": ["__tests__/*"]
58
+ } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
59
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
60
+ // "typeRoots": [], /* List of folders to include type definitions from. */
61
+ // "types": [], /* Type declaration files to be included in compilation. */
62
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
63
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
64
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
65
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
66
+
67
+ /* Source Map Options */
68
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
69
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
70
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
71
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
72
+
73
+ /* Experimental Options */
74
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
75
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
76
+
77
+ /* Advanced Options */
78
+ "skipLibCheck": true /* Skip type checking of declaration files. */,
79
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
80
+ },
81
+ "include": ["src"]
82
+ // "exclude": ["mocks", "**/__tests__/*", "**/*.test.ts"]
83
+ }