@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.
- package/.eslintignore +4 -0
- package/.eslintrc.json +49 -0
- package/.nvmrc +1 -0
- package/.prettierrc +10 -0
- package/.vscode/launch.json +44 -0
- package/LICENSE.txt +339 -0
- package/README.md +300 -0
- package/__mocks__/clear-module.js +7 -0
- package/api-extractor.json +339 -0
- package/dist/bin/serve.d.ts +3 -0
- package/dist/bin/serve.d.ts.map +1 -0
- package/dist/bin/serve.js +105 -0
- package/dist/http/README.md +300 -0
- package/dist/http/httpServer.d.ts +4 -0
- package/dist/http/httpServer.d.ts.map +1 -0
- package/dist/http/httpServer.js +24 -0
- package/dist/http/public/assets/bulma/bulma-tooltip.min.css +2 -0
- package/dist/http/public/assets/bulma/bulma.min.css +1 -0
- package/dist/http/public/assets/clipboard/clipboard.min.js +7 -0
- package/dist/http/public/assets/simple-datatables/index.js +12 -0
- package/dist/http/public/assets/simple-datatables/style.css +173 -0
- package/dist/http/routes/cache.d.ts +4 -0
- package/dist/http/routes/cache.d.ts.map +1 -0
- package/dist/http/routes/cache.js +19 -0
- package/dist/http/routes/data.d.ts +4 -0
- package/dist/http/routes/data.d.ts.map +1 -0
- package/dist/http/routes/data.js +104 -0
- package/dist/http/routes/docs.d.ts +3 -0
- package/dist/http/routes/docs.d.ts.map +1 -0
- package/dist/http/routes/docs.js +14 -0
- package/dist/http/routes/dump.d.ts +8 -0
- package/dist/http/routes/dump.d.ts.map +1 -0
- package/dist/http/routes/dump.js +57 -0
- package/dist/http/routes/home.d.ts +3 -0
- package/dist/http/routes/home.d.ts.map +1 -0
- package/dist/http/routes/home.js +17 -0
- package/dist/http/routes/index.d.ts +3 -0
- package/dist/http/routes/index.d.ts.map +1 -0
- package/dist/http/routes/index.js +33 -0
- package/dist/http/routes/query.d.ts +5 -0
- package/dist/http/routes/query.d.ts.map +1 -0
- package/dist/http/routes/query.js +21 -0
- package/dist/http/routes/status.d.ts +9 -0
- package/dist/http/routes/status.d.ts.map +1 -0
- package/dist/http/routes/status.js +74 -0
- package/dist/http/routes/task.d.ts +5 -0
- package/dist/http/routes/task.d.ts.map +1 -0
- package/dist/http/routes/task.js +22 -0
- package/dist/http/views/cacheClear.pug +17 -0
- package/dist/http/views/cacheIndex.pug +19 -0
- package/dist/http/views/data.pug +68 -0
- package/dist/http/views/docs.pug +7 -0
- package/dist/http/views/dumpIndex.pug +14 -0
- package/dist/http/views/home.pug +15 -0
- package/dist/http/views/includes/layout.pug +23 -0
- package/dist/http/views/queryIndex.pug +17 -0
- package/dist/http/views/statusIndex.pug +14 -0
- package/dist/http/views/taskIndex.pug +17 -0
- package/dist/lib/config/config.d.ts +26 -0
- package/dist/lib/config/config.d.ts.map +1 -0
- package/dist/lib/config/config.js +122 -0
- package/dist/lib/config/config.types.d.ts +74 -0
- package/dist/lib/config/config.types.d.ts.map +1 -0
- package/dist/lib/config/config.types.js +2 -0
- package/dist/lib/config/error/InvalidRunMode.d.ts +15 -0
- package/dist/lib/config/error/InvalidRunMode.d.ts.map +1 -0
- package/dist/lib/config/error/InvalidRunMode.js +20 -0
- package/dist/lib/config/error/MissingDirectory.d.ts +24 -0
- package/dist/lib/config/error/MissingDirectory.d.ts.map +1 -0
- package/dist/lib/config/error/MissingDirectory.js +23 -0
- package/dist/lib/config/error/MissingRequiredOption.d.ts +19 -0
- package/dist/lib/config/error/MissingRequiredOption.d.ts.map +1 -0
- package/dist/lib/config/error/MissingRequiredOption.js +21 -0
- package/dist/lib/config/error/NonWritableDirectory.d.ts +24 -0
- package/dist/lib/config/error/NonWritableDirectory.d.ts.map +1 -0
- package/dist/lib/config/error/NonWritableDirectory.js +23 -0
- package/dist/lib/config/error/index.d.ts +5 -0
- package/dist/lib/config/error/index.d.ts.map +1 -0
- package/dist/lib/config/error/index.js +16 -0
- package/dist/lib/config/index.d.ts +2 -0
- package/dist/lib/config/index.d.ts.map +1 -0
- package/dist/lib/config/index.js +13 -0
- package/dist/lib/dataServer.d.ts +21 -0
- package/dist/lib/dataServer.d.ts.map +1 -0
- package/dist/lib/dataServer.js +56 -0
- package/dist/lib/dataServer.types.d.ts +84 -0
- package/dist/lib/dataServer.types.d.ts.map +1 -0
- package/dist/lib/dataServer.types.js +13 -0
- package/dist/lib/error/DomainError.d.ts +9 -0
- package/dist/lib/error/DomainError.d.ts.map +1 -0
- package/dist/lib/error/DomainError.js +20 -0
- package/dist/lib/index.d.ts +2 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +15 -0
- package/dist/lib/query/index.d.ts +3 -0
- package/dist/lib/query/index.d.ts.map +1 -0
- package/dist/lib/query/index.js +14 -0
- package/dist/lib/query/query.types.d.ts +206 -0
- package/dist/lib/query/query.types.d.ts.map +1 -0
- package/dist/lib/query/query.types.js +21 -0
- package/dist/lib/query/queryManager.d.ts +10 -0
- package/dist/lib/query/queryManager.d.ts.map +1 -0
- package/dist/lib/query/queryManager.js +12 -0
- package/dist/lib/query/queryRunner copy.d.ts +3 -0
- package/dist/lib/query/queryRunner copy.d.ts.map +1 -0
- package/dist/lib/query/queryRunner copy.js +87 -0
- package/dist/lib/query/queryRunner.d.ts +3 -0
- package/dist/lib/query/queryRunner.d.ts.map +1 -0
- package/dist/lib/query/queryRunner.js +96 -0
- package/dist/lib/query/queryTagManager.d.ts +3 -0
- package/dist/lib/query/queryTagManager.d.ts.map +1 -0
- package/dist/lib/query/queryTagManager.js +47 -0
- package/dist/lib/store/dataDir/dataDir.types.d.ts +36 -0
- package/dist/lib/store/dataDir/dataDir.types.d.ts.map +1 -0
- package/dist/lib/store/dataDir/dataDir.types.js +2 -0
- package/dist/lib/store/dataDir/dataDirManager.d.ts +3 -0
- package/dist/lib/store/dataDir/dataDirManager.d.ts.map +1 -0
- package/dist/lib/store/dataDir/dataDirManager.js +97 -0
- package/dist/lib/store/dataDir/index.d.ts +2 -0
- package/dist/lib/store/dataDir/index.d.ts.map +1 -0
- package/dist/lib/store/dataDir/index.js +13 -0
- package/dist/lib/store/dependency/dependency.types.d.ts +70 -0
- package/dist/lib/store/dependency/dependency.types.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependency.types.js +2 -0
- package/dist/lib/store/dependency/dependencyFileHelper.d.ts +6 -0
- package/dist/lib/store/dependency/dependencyFileHelper.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyFileHelper.js +46 -0
- package/dist/lib/store/dependency/dependencyManager copy.d.ts +6 -0
- package/dist/lib/store/dependency/dependencyManager copy.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyManager copy.js +91 -0
- package/dist/lib/store/dependency/dependencyManager.d.ts +6 -0
- package/dist/lib/store/dependency/dependencyManager.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyManager.js +78 -0
- package/dist/lib/store/dependency/dependencyManager.types.d.ts +48 -0
- package/dist/lib/store/dependency/dependencyManager.types.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyManager.types.js +2 -0
- package/dist/lib/store/dependency/dependencyTagManager.d.ts +6 -0
- package/dist/lib/store/dependency/dependencyTagManager.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyTagManager.js +33 -0
- package/dist/lib/store/dependency/dependencyTagger.d.ts +11 -0
- package/dist/lib/store/dependency/dependencyTagger.d.ts.map +1 -0
- package/dist/lib/store/dependency/dependencyTagger.js +99 -0
- package/dist/lib/store/diff/diffManager.d.ts +3 -0
- package/dist/lib/store/diff/diffManager.d.ts.map +1 -0
- package/dist/lib/store/diff/diffManager.js +114 -0
- package/dist/lib/store/diff/diffManager.types.d.ts +50 -0
- package/dist/lib/store/diff/diffManager.types.d.ts.map +1 -0
- package/dist/lib/store/diff/diffManager.types.js +2 -0
- package/dist/lib/store/diff/index.d.ts +2 -0
- package/dist/lib/store/diff/index.d.ts.map +1 -0
- package/dist/lib/store/diff/index.js +13 -0
- package/dist/lib/store/diff/tracker.d.ts +3 -0
- package/dist/lib/store/diff/tracker.d.ts.map +1 -0
- package/dist/lib/store/diff/tracker.js +82 -0
- package/dist/lib/store/diff/tracker.types.d.ts +31 -0
- package/dist/lib/store/diff/tracker.types.d.ts.map +1 -0
- package/dist/lib/store/diff/tracker.types.js +2 -0
- package/dist/lib/store/dump/dumpManager.d.ts +3 -0
- package/dist/lib/store/dump/dumpManager.d.ts.map +1 -0
- package/dist/lib/store/dump/dumpManager.js +199 -0
- package/dist/lib/store/dump/dumpManager.types.d.ts +62 -0
- package/dist/lib/store/dump/dumpManager.types.d.ts.map +1 -0
- package/dist/lib/store/dump/dumpManager.types.js +2 -0
- package/dist/lib/store/dump/index.d.ts +2 -0
- package/dist/lib/store/dump/index.d.ts.map +1 -0
- package/dist/lib/store/dump/index.js +13 -0
- package/dist/lib/store/hook/hook.types.d.ts +205 -0
- package/dist/lib/store/hook/hook.types.d.ts.map +1 -0
- package/dist/lib/store/hook/hook.types.js +2 -0
- package/dist/lib/store/hook/hookManager.d.ts +6 -0
- package/dist/lib/store/hook/hookManager.d.ts.map +1 -0
- package/dist/lib/store/hook/hookManager.js +168 -0
- package/dist/lib/store/hook/index.d.ts +2 -0
- package/dist/lib/store/hook/index.d.ts.map +1 -0
- package/dist/lib/store/hook/index.js +13 -0
- package/dist/lib/store/include/includeIndex.d.ts +6 -0
- package/dist/lib/store/include/includeIndex.d.ts.map +1 -0
- package/dist/lib/store/include/includeIndex.js +65 -0
- package/dist/lib/store/include/includeIndex.types.d.ts +29 -0
- package/dist/lib/store/include/includeIndex.types.d.ts.map +1 -0
- package/dist/lib/store/include/includeIndex.types.js +2 -0
- package/dist/lib/store/include/includeParser.d.ts +3 -0
- package/dist/lib/store/include/includeParser.d.ts.map +1 -0
- package/dist/lib/store/include/includeParser.js +46 -0
- package/dist/lib/store/include/includeParser.types.d.ts +88 -0
- package/dist/lib/store/include/includeParser.types.d.ts.map +1 -0
- package/dist/lib/store/include/includeParser.types.js +2 -0
- package/dist/lib/store/include/index.d.ts +2 -0
- package/dist/lib/store/include/index.d.ts.map +1 -0
- package/dist/lib/store/include/index.js +13 -0
- package/dist/lib/store/include/parsers/configIncludeParser.d.ts +3 -0
- package/dist/lib/store/include/parsers/configIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/configIncludeParser.js +8 -0
- package/dist/lib/store/include/parsers/customIncludeParser.d.ts +3 -0
- package/dist/lib/store/include/parsers/customIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/customIncludeParser.js +8 -0
- package/dist/lib/store/include/parsers/entityIncludeParser.d.ts +3 -0
- package/dist/lib/store/include/parsers/entityIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/entityIncludeParser.js +13 -0
- package/dist/lib/store/include/parsers/index.d.ts +6 -0
- package/dist/lib/store/include/parsers/index.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/index.js +17 -0
- package/dist/lib/store/include/parsers/localeIncludeParser.d.ts +3 -0
- package/dist/lib/store/include/parsers/localeIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/localeIncludeParser.js +8 -0
- package/dist/lib/store/include/parsers/queryIncludeParser.d.ts +11 -0
- package/dist/lib/store/include/parsers/queryIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/queryIncludeParser.js +45 -0
- package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts +3 -0
- package/dist/lib/store/include/parsers/types/aliasIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/types/aliasIncludeParser.js +10 -0
- package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts +8 -0
- package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.d.ts.map +1 -0
- package/dist/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.js +18 -0
- package/dist/lib/store/index.d.ts +2 -0
- package/dist/lib/store/index.d.ts.map +1 -0
- package/dist/lib/store/index.js +13 -0
- package/dist/lib/store/store.d.ts +7 -0
- package/dist/lib/store/store.d.ts.map +1 -0
- package/dist/lib/store/store.js +89 -0
- package/dist/lib/store/store.types.d.ts +231 -0
- package/dist/lib/store/store.types.d.ts.map +1 -0
- package/dist/lib/store/store.types.js +2 -0
- package/dist/lib/store/storeManager.d.ts +3 -0
- package/dist/lib/store/storeManager.d.ts.map +1 -0
- package/dist/lib/store/storeManager.js +149 -0
- package/dist/lib/store/workDir/index.d.ts +2 -0
- package/dist/lib/store/workDir/index.d.ts.map +1 -0
- package/dist/lib/store/workDir/index.js +13 -0
- package/dist/lib/store/workDir/storage/getChangedLinesSince.d.ts +9 -0
- package/dist/lib/store/workDir/storage/getChangedLinesSince.d.ts.map +1 -0
- package/dist/lib/store/workDir/storage/getChangedLinesSince.js +47 -0
- package/dist/lib/store/workDir/storage/getDataFromLogLine.d.ts +10 -0
- package/dist/lib/store/workDir/storage/getDataFromLogLine.d.ts.map +1 -0
- package/dist/lib/store/workDir/storage/getDataFromLogLine.js +33 -0
- package/dist/lib/store/workDir/storage/getLogFile.d.ts +8 -0
- package/dist/lib/store/workDir/storage/getLogFile.d.ts.map +1 -0
- package/dist/lib/store/workDir/storage/getLogFile.js +11 -0
- package/dist/lib/store/workDir/storage/index.d.ts +4 -0
- package/dist/lib/store/workDir/storage/index.d.ts.map +1 -0
- package/dist/lib/store/workDir/storage/index.js +20 -0
- package/dist/lib/store/workDir/workDir.types.d.ts +44 -0
- package/dist/lib/store/workDir/workDir.types.d.ts.map +1 -0
- package/dist/lib/store/workDir/workDir.types.js +2 -0
- package/dist/lib/store/workDir/workDirHelper.d.ts +20 -0
- package/dist/lib/store/workDir/workDirHelper.d.ts.map +1 -0
- package/dist/lib/store/workDir/workDirHelper.js +52 -0
- package/dist/lib/task/index.d.ts +3 -0
- package/dist/lib/task/index.d.ts.map +1 -0
- package/dist/lib/task/index.js +14 -0
- package/dist/lib/task/task.types.d.ts +140 -0
- package/dist/lib/task/task.types.d.ts.map +1 -0
- package/dist/lib/task/task.types.js +11 -0
- package/dist/lib/task/taskManager.d.ts +10 -0
- package/dist/lib/task/taskManager.d.ts.map +1 -0
- package/dist/lib/task/taskManager.js +12 -0
- package/dist/lib/task/taskRunner.d.ts +3 -0
- package/dist/lib/task/taskRunner.d.ts.map +1 -0
- package/dist/lib/task/taskRunner.js +71 -0
- package/dist/lib/tsdoc-metadata.json +11 -0
- package/dist/lib/utils/array/arrayUtils.d.ts +2 -0
- package/dist/lib/utils/array/arrayUtils.d.ts.map +1 -0
- package/dist/lib/utils/array/arrayUtils.js +11 -0
- package/dist/lib/utils/cache/cacheBinManager.d.ts +37 -0
- package/dist/lib/utils/cache/cacheBinManager.d.ts.map +1 -0
- package/dist/lib/utils/cache/cacheBinManager.js +53 -0
- package/dist/lib/utils/cache/index.d.ts +2 -0
- package/dist/lib/utils/cache/index.d.ts.map +1 -0
- package/dist/lib/utils/cache/index.js +13 -0
- package/dist/lib/utils/fs/fs.types.d.ts +20 -0
- package/dist/lib/utils/fs/fs.types.d.ts.map +1 -0
- package/dist/lib/utils/fs/fs.types.js +2 -0
- package/dist/lib/utils/fs/fsUtils.d.ts +62 -0
- package/dist/lib/utils/fs/fsUtils.d.ts.map +1 -0
- package/dist/lib/utils/fs/fsUtils.js +137 -0
- package/dist/lib/utils/fs/index.d.ts +2 -0
- package/dist/lib/utils/fs/index.d.ts.map +1 -0
- package/dist/lib/utils/fs/index.js +13 -0
- package/dist/lib/utils/logger/index.d.ts +2 -0
- package/dist/lib/utils/logger/index.d.ts.map +1 -0
- package/dist/lib/utils/logger/index.js +13 -0
- package/dist/lib/utils/logger/logger.d.ts +32 -0
- package/dist/lib/utils/logger/logger.d.ts.map +1 -0
- package/dist/lib/utils/logger/logger.js +82 -0
- package/dist/lib/utils/logger/logger.types.d.ts +37 -0
- package/dist/lib/utils/logger/logger.types.d.ts.map +1 -0
- package/dist/lib/utils/logger/logger.types.js +15 -0
- package/dist/lib/utils/module/dirBasedModuleGroupManager.d.ts +30 -0
- package/dist/lib/utils/module/dirBasedModuleGroupManager.d.ts.map +1 -0
- package/dist/lib/utils/module/dirBasedModuleGroupManager.js +78 -0
- package/dist/lib/utils/module/index.d.ts +3 -0
- package/dist/lib/utils/module/index.d.ts.map +1 -0
- package/dist/lib/utils/module/index.js +14 -0
- package/dist/lib/utils/module/module.types.d.ts +53 -0
- package/dist/lib/utils/module/module.types.d.ts.map +1 -0
- package/dist/lib/utils/module/module.types.js +2 -0
- package/dist/lib/utils/module/moduleManager.d.ts +64 -0
- package/dist/lib/utils/module/moduleManager.d.ts.map +1 -0
- package/dist/lib/utils/module/moduleManager.js +139 -0
- package/dist/lib/utils/object/index.d.ts +2 -0
- package/dist/lib/utils/object/index.d.ts.map +1 -0
- package/dist/lib/utils/object/index.js +13 -0
- package/dist/lib/utils/object/object.types.d.ts +72 -0
- package/dist/lib/utils/object/object.types.d.ts.map +1 -0
- package/dist/lib/utils/object/object.types.js +2 -0
- package/dist/lib/utils/object/objectUtils.d.ts +45 -0
- package/dist/lib/utils/object/objectUtils.d.ts.map +1 -0
- package/dist/lib/utils/object/objectUtils.js +64 -0
- package/dist/lib/utils/string/index.d.ts +2 -0
- package/dist/lib/utils/string/index.d.ts.map +1 -0
- package/dist/lib/utils/string/index.js +13 -0
- package/dist/lib/utils/string/string.types.d.ts +2 -0
- package/dist/lib/utils/string/string.types.d.ts.map +1 -0
- package/dist/lib/utils/string/string.types.js +2 -0
- package/dist/lib/utils/string/stringUtils.d.ts +37 -0
- package/dist/lib/utils/string/stringUtils.d.ts.map +1 -0
- package/dist/lib/utils/string/stringUtils.js +62 -0
- package/dist/lib/watcher/index.d.ts +2 -0
- package/dist/lib/watcher/index.d.ts.map +1 -0
- package/dist/lib/watcher/index.js +13 -0
- package/dist/lib/watcher/watcher.d.ts +17 -0
- package/dist/lib/watcher/watcher.d.ts.map +1 -0
- package/dist/lib/watcher/watcher.js +65 -0
- package/dist/static-suite-data-server.d.ts +392 -0
- package/package.json +102 -0
- package/scripts/copy-http-files-to-src.js +45 -0
- package/src/__tests__/fixtures/data/en/en.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/entity.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article1--card.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article1--small.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article1.json +40 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article2--card.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article2--small.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article2.json +40 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article3--card.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article3--small.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/article/article3.json +7 -0
- package/src/__tests__/fixtures/data/en/entity/node/node.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page1--card.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page1--small.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page1.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page2--card.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page2--small.json +3 -0
- package/src/__tests__/fixtures/data/en/entity/node/page/page2.json +3 -0
- package/src/__tests__/fixtures/data/global--block.json +3 -0
- package/src/__tests__/fixtures/data/global.json +3 -0
- package/src/__tests__/fixtures/hook/main.hook.js +15 -0
- package/src/__tests__/fixtures/hook/taxonomy/main.hook.js +15 -0
- package/src/__tests__/fixtures/hook/taxonomy/taxo.hook.js +15 -0
- package/src/__tests__/fixtures/query/error.query.js +6 -0
- package/src/__tests__/fixtures/query/noHandler.query.js +14 -0
- package/src/__tests__/fixtures/query/query1.query.js +15 -0
- package/src/__tests__/fixtures/query/query2.query.js +14 -0
- package/src/__tests__/fixtures/query/wrongNamequery.js +14 -0
- package/src/__tests__/fixtures/task/error.task.js +6 -0
- package/src/__tests__/fixtures/task/noHandler.task.js +13 -0
- package/src/__tests__/fixtures/task/task1.task.js +14 -0
- package/src/__tests__/fixtures/task/task2.task.js +13 -0
- package/src/__tests__/fixtures/task/wrongNametask.js +13 -0
- package/src/bin/serve.ts +107 -0
- package/src/http/httpServer.ts +21 -0
- package/src/http/routes/cache.ts +17 -0
- package/src/http/routes/data.ts +114 -0
- package/src/http/routes/docs.ts +9 -0
- package/src/http/routes/dump.ts +61 -0
- package/src/http/routes/home.ts +16 -0
- package/src/http/routes/index.ts +47 -0
- package/src/http/routes/query.ts +27 -0
- package/src/http/routes/status.ts +89 -0
- package/src/http/routes/task.ts +29 -0
- package/src/http/views/cacheClear.pug +17 -0
- package/src/http/views/cacheIndex.pug +19 -0
- package/src/http/views/data.pug +68 -0
- package/src/http/views/docs.pug +7 -0
- package/src/http/views/dumpIndex.pug +14 -0
- package/src/http/views/home.pug +15 -0
- package/src/http/views/includes/layout.pug +23 -0
- package/src/http/views/queryIndex.pug +17 -0
- package/src/http/views/statusIndex.pug +14 -0
- package/src/http/views/taskIndex.pug +17 -0
- package/src/lib/config/__tests__/config.test.ts +132 -0
- package/src/lib/config/config.ts +143 -0
- package/src/lib/config/config.types.ts +87 -0
- package/src/lib/config/error/InvalidRunMode.ts +17 -0
- package/src/lib/config/error/MissingDirectory.ts +30 -0
- package/src/lib/config/error/MissingRequiredOption.ts +23 -0
- package/src/lib/config/error/NonWritableDirectory.ts +30 -0
- package/src/lib/config/error/index.ts +4 -0
- package/src/lib/config/index.ts +1 -0
- package/src/lib/dataServer.ts +81 -0
- package/src/lib/dataServer.types.ts +98 -0
- package/src/lib/error/DomainError.ts +18 -0
- package/src/lib/index.ts +4 -0
- package/src/lib/query/__tests__/queryRunner.test.ts +61 -0
- package/src/lib/query/index.ts +2 -0
- package/src/lib/query/query.types.ts +231 -0
- package/src/lib/query/queryManager.ts +11 -0
- package/src/lib/query/queryRunner.ts +110 -0
- package/src/lib/query/queryTagManager.ts +53 -0
- package/src/lib/store/dataDir/__tests__/dataDirManager.test.ts +15 -0
- package/src/lib/store/dataDir/dataDir.types.ts +38 -0
- package/src/lib/store/dataDir/dataDirManager.ts +121 -0
- package/src/lib/store/dataDir/index.ts +1 -0
- package/src/lib/store/dependency/dependency.types.ts +78 -0
- package/src/lib/store/dependency/dependencyFileHelper.ts +50 -0
- package/src/lib/store/dependency/dependencyManager.ts +82 -0
- package/src/lib/store/dependency/dependencyTagger.ts +105 -0
- package/src/lib/store/diff/diffManager.ts +122 -0
- package/src/lib/store/diff/diffManager.types.ts +51 -0
- package/src/lib/store/diff/index.ts +1 -0
- package/src/lib/store/dump/dumpManager.ts +235 -0
- package/src/lib/store/dump/dumpManager.types.ts +61 -0
- package/src/lib/store/dump/index.ts +1 -0
- package/src/lib/store/hook/hook.types.ts +232 -0
- package/src/lib/store/hook/hookManager.ts +180 -0
- package/src/lib/store/hook/index.ts +1 -0
- package/src/lib/store/include/__tests__/includeParser.test.ts +80 -0
- package/src/lib/store/include/includeParser.ts +54 -0
- package/src/lib/store/include/includeParser.types.ts +99 -0
- package/src/lib/store/include/index.ts +1 -0
- package/src/lib/store/include/parsers/__tests__/entityIncludeParser.test.ts +43 -0
- package/src/lib/store/include/parsers/configIncludeParser.ts +8 -0
- package/src/lib/store/include/parsers/customIncludeParser.ts +8 -0
- package/src/lib/store/include/parsers/entityIncludeParser.ts +15 -0
- package/src/lib/store/include/parsers/index.ts +5 -0
- package/src/lib/store/include/parsers/localeIncludeParser.ts +8 -0
- package/src/lib/store/include/parsers/queryIncludeParser.ts +51 -0
- package/src/lib/store/include/parsers/types/__tests__/aliasIncludeParser.test.ts +37 -0
- package/src/lib/store/include/parsers/types/__tests__/aliasWithoutTypeIncludeParser.test.ts +43 -0
- package/src/lib/store/include/parsers/types/aliasIncludeParser.ts +13 -0
- package/src/lib/store/include/parsers/types/aliasWithoutTypeIncludeParser.ts +22 -0
- package/src/lib/store/index.ts +1 -0
- package/src/lib/store/store.ts +105 -0
- package/src/lib/store/store.types.ts +251 -0
- package/src/lib/store/storeManager.ts +187 -0
- package/src/lib/store/workDir/__tests__/workDirHelper.test.ts +25 -0
- package/src/lib/store/workDir/index.ts +1 -0
- package/src/lib/store/workDir/storage/__tests__/getChangedLinesSince.test.ts +23 -0
- package/src/lib/store/workDir/storage/__tests__/getDataFromLogLine.test.ts +21 -0
- package/src/lib/store/workDir/storage/getChangedLinesSince.ts +47 -0
- package/src/lib/store/workDir/storage/getDataFromLogLine.ts +31 -0
- package/src/lib/store/workDir/storage/getLogFile.ts +11 -0
- package/src/lib/store/workDir/storage/index.ts +8 -0
- package/src/lib/store/workDir/workDir.types.ts +48 -0
- package/src/lib/store/workDir/workDirHelper.ts +59 -0
- package/src/lib/task/__tests__/taskRunner.test.ts +47 -0
- package/src/lib/task/index.ts +2 -0
- package/src/lib/task/task.types.ts +151 -0
- package/src/lib/task/taskManager.ts +11 -0
- package/src/lib/task/taskRunner.ts +79 -0
- package/src/lib/utils/array/__tests__/arrayUtils.test.ts +16 -0
- package/src/lib/utils/array/arrayUtils.ts +7 -0
- package/src/lib/utils/cache/__tests__/cache.test.ts +24 -0
- package/src/lib/utils/cache/cacheBinManager.ts +88 -0
- package/src/lib/utils/cache/index.ts +1 -0
- package/src/lib/utils/fs/__tests__/fixtures/file.json +3 -0
- package/src/lib/utils/fs/__tests__/fixtures/file.txt +3 -0
- package/src/lib/utils/fs/__tests__/fsUtils.test.ts +93 -0
- package/src/lib/utils/fs/fs.types.ts +21 -0
- package/src/lib/utils/fs/fsUtils.ts +141 -0
- package/src/lib/utils/fs/index.ts +1 -0
- package/src/lib/utils/logger/__tests__/logger.test.ts +12 -0
- package/src/lib/utils/logger/index.ts +1 -0
- package/src/lib/utils/logger/logger.ts +87 -0
- package/src/lib/utils/logger/logger.types.ts +41 -0
- package/src/lib/utils/module/__mocks__/dummyModule.query.js +4 -0
- package/src/lib/utils/module/__mocks__/dummyModule2.query.js +4 -0
- package/src/lib/utils/module/__tests__/dirBasedModuleGroupManager.test.ts +34 -0
- package/src/lib/utils/module/__tests__/moduleHandler.test.ts +100 -0
- package/src/lib/utils/module/dirBasedModuleGroupManager.ts +78 -0
- package/src/lib/utils/module/index.ts +2 -0
- package/src/lib/utils/module/module.types.ts +57 -0
- package/src/lib/utils/module/moduleManager.ts +144 -0
- package/src/lib/utils/object/__tests__/objectUtils.test.ts +62 -0
- package/src/lib/utils/object/index.ts +1 -0
- package/src/lib/utils/object/object.types.ts +74 -0
- package/src/lib/utils/object/objectUtils.ts +71 -0
- package/src/lib/utils/string/__tests__/stringUtils.test.ts +30 -0
- package/src/lib/utils/string/index.ts +1 -0
- package/src/lib/utils/string/string.types.ts +1 -0
- package/src/lib/utils/string/stringUtils.ts +61 -0
- package/src/lib/watcher/index.ts +1 -0
- package/src/lib/watcher/watcher.ts +66 -0
- package/tsconfig.json +83 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service that dumps resolved data (with resolved includes) into a dump directory.
|
|
3
|
+
*/
|
|
4
|
+
export type DumpManager = {
|
|
5
|
+
/**
|
|
6
|
+
* Dump resolved data (with resolved includes) into a dump directory.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Raw data stored in Data Server does not resolve its includes until
|
|
10
|
+
* each file is consumed (and therefore stringified). A dump consumes
|
|
11
|
+
* that raw data and stores it in a directory, along its metadata
|
|
12
|
+
* (a list of changed/deleted files), so a later process can store
|
|
13
|
+
* those changes in another service like AWS S3.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Configuration options
|
|
16
|
+
*/
|
|
17
|
+
dump(options?: { incremental: boolean }): Dump;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Reset dump metadata.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Resets dump metadata, removing any dump information older than the passed timestamp.
|
|
24
|
+
*
|
|
25
|
+
* @param timestamp - Timestamp
|
|
26
|
+
*/
|
|
27
|
+
reset(timestamp: number): void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A group of files to by dumped to dump directory.
|
|
32
|
+
*/
|
|
33
|
+
export type Dump = {
|
|
34
|
+
/**
|
|
35
|
+
* Timestamp in milliseconds.
|
|
36
|
+
*/
|
|
37
|
+
since: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A list of updated files, keyed by file path. Its value is an object with two keys,
|
|
41
|
+
* old public URL and new public URL (the value stored at data.content.url.path) before
|
|
42
|
+
* and after updating file in dumpDir.
|
|
43
|
+
*/
|
|
44
|
+
updated: Map<
|
|
45
|
+
string,
|
|
46
|
+
{ oldPublicUrl: string | null; newPublicUrl: string | null }
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A list of deleted files, keyed by file path. Its value is an object with two keys,
|
|
51
|
+
* old public URL and new public URL (the value stored at data.content.url.path) before
|
|
52
|
+
* and after updating file in dumpDir. New public URL is always null, since file is
|
|
53
|
+
* deleted. We keep the same structure for both updated and deleted items.
|
|
54
|
+
*/
|
|
55
|
+
deleted: Map<string, { oldPublicUrl: string | null; newPublicUrl: null }>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional execution time taken by the dump, in milliseconds.
|
|
59
|
+
*/
|
|
60
|
+
execTimeMs?: number;
|
|
61
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dumpManager';
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { ConfigOptions } from '@lib/config/config.types';
|
|
2
|
+
import { Store } from '@lib/store/store.types';
|
|
3
|
+
import { FileType } from '@lib/utils/fs/fs.types';
|
|
4
|
+
import { DependencyTagger } from '../dependency/dependency.types';
|
|
5
|
+
import { Dump } from '../dump/dumpManager.types';
|
|
6
|
+
import { ChangedFiles } from '../workDir/workDir.types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A manager for a group of user-land modules.
|
|
10
|
+
*
|
|
11
|
+
* @typeParam ModuleType - The type of module being managed.
|
|
12
|
+
*/
|
|
13
|
+
export type HookManager = {
|
|
14
|
+
reset(): void;
|
|
15
|
+
|
|
16
|
+
// Events when store is created/loaded for the first time.
|
|
17
|
+
invokeOnStoreLoadStart(): void;
|
|
18
|
+
invokeOnProcessFile(options: FileHookOptions): FileType;
|
|
19
|
+
invokeOnStoreItemAdd(options: FileHookOptions): void;
|
|
20
|
+
invokeOnStoreLoadDone(): void;
|
|
21
|
+
|
|
22
|
+
// Events when store changes, leading to update or remove actions.
|
|
23
|
+
invokeOnStoreChangeStart(changedFiles: ChangedFiles): void;
|
|
24
|
+
invokeOnStoreItemBeforeUpdate(options: FileHookOptions): void;
|
|
25
|
+
invokeOnStoreItemAfterUpdate(options: FileHookOptions): void;
|
|
26
|
+
invokeOnStoreItemDelete(options: FileHookOptions): void;
|
|
27
|
+
invokeOnStoreChangeDone(changedFiles: ChangedFiles): void;
|
|
28
|
+
|
|
29
|
+
// Dump related events
|
|
30
|
+
invokeOnDumpCreate(dump: Dump): Dump;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Options passed to an onModuleLoad hook.
|
|
35
|
+
*/
|
|
36
|
+
export interface OnModuleLoadHookOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Configuration options.
|
|
39
|
+
*/
|
|
40
|
+
config: ConfigOptions;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The data store.
|
|
44
|
+
*/
|
|
45
|
+
store: Store;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Options passed to a hook.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Since hooks are user-land modules, they do not have access to configuration
|
|
53
|
+
* or any other part of the Data Server. All data they need to function must be
|
|
54
|
+
* passed as parameters.
|
|
55
|
+
*/
|
|
56
|
+
export interface BaseHookOptions {
|
|
57
|
+
/**
|
|
58
|
+
* The data store.
|
|
59
|
+
*/
|
|
60
|
+
store: Store;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The dependency tagger service.
|
|
64
|
+
*/
|
|
65
|
+
dependencyTagger: DependencyTagger;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Options passed to a file hook.
|
|
70
|
+
*/
|
|
71
|
+
export interface FileHookOptions {
|
|
72
|
+
/**
|
|
73
|
+
* Relative file path inside the data dir.
|
|
74
|
+
*/
|
|
75
|
+
relativeFilepath: string;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* File contents, an object with "raw" and "json" members.
|
|
79
|
+
*/
|
|
80
|
+
fileContent: FileType;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Full options passed to a hook.
|
|
85
|
+
*/
|
|
86
|
+
export interface FullHookOptions extends BaseHookOptions, FileHookOptions {}
|
|
87
|
+
|
|
88
|
+
export interface ChangedFilesHookOptions extends BaseHookOptions {
|
|
89
|
+
/**
|
|
90
|
+
* A group of changed files in Static Suite's data dir.
|
|
91
|
+
*/
|
|
92
|
+
changedFiles: ChangedFiles;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface OnDumpHookOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Path to the dump directory.
|
|
98
|
+
*/
|
|
99
|
+
dumpDir: string;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The data store.
|
|
103
|
+
*/
|
|
104
|
+
store: Store;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The dump to be processed.
|
|
108
|
+
*/
|
|
109
|
+
dump: Dump;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* A module that defines several hooks.
|
|
114
|
+
*/
|
|
115
|
+
export type HookModule = {
|
|
116
|
+
/**
|
|
117
|
+
* A hook executed when a hook module is loaded or reloaded.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* This hook is aimed at bootstrapping some data structure, or establishing some connection
|
|
121
|
+
* to an external system before other hooks are run.
|
|
122
|
+
*/
|
|
123
|
+
onModuleLoad?(options: OnModuleLoadHookOptions): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* A hook executed before the store starts loading.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* This hook is aimed at bootstrapping some data structure, or establishing some connection
|
|
130
|
+
* to an external system before other hooks are run.
|
|
131
|
+
*
|
|
132
|
+
* @param options - An object with options passed to the hook. @see {@link HookOptions}
|
|
133
|
+
*/
|
|
134
|
+
onStoreLoadStart?(options: BaseHookOptions): void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A hook executed after a file is read from disk, before adding it to the store.
|
|
138
|
+
*
|
|
139
|
+
* @remarks
|
|
140
|
+
* This hook is aimed at altering the contents of the file before it being added to the store.
|
|
141
|
+
*
|
|
142
|
+
* @param options - An object with options passed to the hook. @see {@link FileHookOptions}
|
|
143
|
+
*
|
|
144
|
+
* @returns The file contents, and object with "raw" and "json" members.
|
|
145
|
+
*/
|
|
146
|
+
onProcessFile?(options: FullHookOptions): FileType;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* A hook executed after a file is added into the store.
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* This hook is aimed at adding some information to the store, e.g.- indexing all contents
|
|
153
|
+
* by their taxonomy.
|
|
154
|
+
*
|
|
155
|
+
* @param options - An object with options passed to the hook. @see {@link FileHookOptions}
|
|
156
|
+
*/
|
|
157
|
+
onStoreItemAdd?(options: FullHookOptions): void;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A hook executed after the store finishes loading.
|
|
161
|
+
*
|
|
162
|
+
* @remarks
|
|
163
|
+
* This hook is aimed at adding some final information to the store, e.g.- counting all images, etc
|
|
164
|
+
*
|
|
165
|
+
* @param options - An object with options passed to the hook. @see {@link HookOptions}
|
|
166
|
+
*/
|
|
167
|
+
onStoreLoadDone?(options: BaseHookOptions): void;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* A hook executed before the store starts updating.
|
|
171
|
+
*
|
|
172
|
+
* @remarks
|
|
173
|
+
* This hook is aimed at bootstrapping or updating some data structure
|
|
174
|
+
* before a set of update/delete operations starts.
|
|
175
|
+
*
|
|
176
|
+
* @param options - An object with options passed to the hook. @see {@link HookOptions}
|
|
177
|
+
*/
|
|
178
|
+
onStoreChangeStart?(options: ChangedFilesHookOptions): void;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* A hook executed before a file is updated in the store.
|
|
182
|
+
*
|
|
183
|
+
* @remarks
|
|
184
|
+
* This hook is aimed at adding some information to the store, e.g.- indexing all contents
|
|
185
|
+
* by their taxonomy.
|
|
186
|
+
*
|
|
187
|
+
* @param options - An object with options passed to the hook. @see {@link FileHookOptions}
|
|
188
|
+
*/
|
|
189
|
+
onStoreItemBeforeUpdate?(options: FullHookOptions): void;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* A hook executed after a file is updated in the store.
|
|
193
|
+
*
|
|
194
|
+
* @remarks
|
|
195
|
+
* This hook is aimed at adding some information to the store, e.g.- indexing all contents
|
|
196
|
+
* by their taxonomy.
|
|
197
|
+
*
|
|
198
|
+
* @param options - An object with options passed to the hook. @see {@link FileHookOptions}
|
|
199
|
+
*/
|
|
200
|
+
onStoreItemAfterUpdate?(options: FullHookOptions): void;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* A hook executed after a file is deleted from the store.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* This hook is aimed at reverting the actions taken in storeAdd hook, e.g.- removing a file
|
|
207
|
+
* from a taxonomy index.
|
|
208
|
+
*
|
|
209
|
+
* @param options - An object with options passed to the hook. @see {@link FileHookOptions}
|
|
210
|
+
*/
|
|
211
|
+
onStoreItemDelete?(options: FullHookOptions): void;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* A hook executed after the store ends updating.
|
|
215
|
+
*
|
|
216
|
+
* @remarks
|
|
217
|
+
* This hook is run after a set of update/delete operations finishes.
|
|
218
|
+
*
|
|
219
|
+
* @param options - An object with options passed to the hook. @see {@link HookOptions}
|
|
220
|
+
*/
|
|
221
|
+
onStoreChangeDone?(options: ChangedFilesHookOptions): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* A hook executed after a dump object is created.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* This hook can alter the contents of the dump being saved, and add/remove items.
|
|
228
|
+
*
|
|
229
|
+
* @param options - An object with options passed to the hook. @see {@link OnDumpHookOptions}
|
|
230
|
+
*/
|
|
231
|
+
onDumpCreate?(options: OnDumpHookOptions): Dump;
|
|
232
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { config } from '@lib/config';
|
|
2
|
+
import { store } from '@lib/store';
|
|
3
|
+
import { dependencyTagger } from '@lib/store/dependency/dependencyTagger';
|
|
4
|
+
import { FileType } from '@lib/utils/fs/fs.types';
|
|
5
|
+
import { dirBasedModuleGroupManager } from '@lib/utils/module';
|
|
6
|
+
import { HookManager, HookModule } from './hook.types';
|
|
7
|
+
import { Dump } from '../dump/dumpManager.types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A manager for hooks stored in a user-land directory defined by configuration.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* It extends dirBasedModuleGroupManager, which manages groups of modules based
|
|
14
|
+
* on a directory: @see {@link dirBasedModuleGroupManager}
|
|
15
|
+
*/
|
|
16
|
+
const moduleManager = dirBasedModuleGroupManager<HookModule>('hook');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A specialized hook manager with invoke helpers for all hooks
|
|
20
|
+
*/
|
|
21
|
+
export const hookManager: HookManager = {
|
|
22
|
+
reset() {
|
|
23
|
+
moduleManager.reset();
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
invokeOnStoreLoadStart() {
|
|
27
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
28
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
29
|
+
const hookModule = hookInfo.getModule();
|
|
30
|
+
if (hookModule.onStoreLoadStart) {
|
|
31
|
+
hookModule.onStoreLoadStart({
|
|
32
|
+
store,
|
|
33
|
+
dependencyTagger,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
invokeOnProcessFile({ relativeFilepath, fileContent }) {
|
|
40
|
+
let processedFileContent = fileContent;
|
|
41
|
+
let returnValue: FileType | null = null;
|
|
42
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
43
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
44
|
+
const hookModule = hookInfo.getModule();
|
|
45
|
+
if (hookModule.onProcessFile) {
|
|
46
|
+
returnValue = hookModule.onProcessFile({
|
|
47
|
+
relativeFilepath,
|
|
48
|
+
fileContent: processedFileContent,
|
|
49
|
+
store,
|
|
50
|
+
dependencyTagger,
|
|
51
|
+
});
|
|
52
|
+
if (returnValue) {
|
|
53
|
+
processedFileContent = returnValue;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return processedFileContent;
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
invokeOnStoreItemAdd({ relativeFilepath, fileContent }): void {
|
|
61
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
62
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
63
|
+
const hookModule = hookInfo.getModule();
|
|
64
|
+
if (hookModule.onStoreItemAdd) {
|
|
65
|
+
hookModule.onStoreItemAdd({
|
|
66
|
+
relativeFilepath,
|
|
67
|
+
fileContent,
|
|
68
|
+
store,
|
|
69
|
+
dependencyTagger,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
invokeOnStoreLoadDone() {
|
|
76
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
77
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
78
|
+
const hookModule = hookInfo.getModule();
|
|
79
|
+
if (hookModule.onStoreLoadDone) {
|
|
80
|
+
hookModule.onStoreLoadDone({
|
|
81
|
+
store,
|
|
82
|
+
dependencyTagger,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
invokeOnStoreChangeStart(changedFiles) {
|
|
89
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
90
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
91
|
+
const hookModule = hookInfo.getModule();
|
|
92
|
+
if (hookModule.onStoreChangeStart) {
|
|
93
|
+
hookModule.onStoreChangeStart({
|
|
94
|
+
store,
|
|
95
|
+
dependencyTagger,
|
|
96
|
+
changedFiles,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
invokeOnStoreItemBeforeUpdate({ relativeFilepath, fileContent }) {
|
|
103
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
104
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
105
|
+
const hookModule = hookInfo.getModule();
|
|
106
|
+
if (hookModule.onStoreItemBeforeUpdate) {
|
|
107
|
+
hookModule.onStoreItemBeforeUpdate({
|
|
108
|
+
store,
|
|
109
|
+
dependencyTagger,
|
|
110
|
+
relativeFilepath,
|
|
111
|
+
fileContent,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
invokeOnStoreItemAfterUpdate({ relativeFilepath, fileContent }) {
|
|
118
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
119
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
120
|
+
const hookModule = hookInfo.getModule();
|
|
121
|
+
if (hookModule.onStoreItemAfterUpdate) {
|
|
122
|
+
hookModule.onStoreItemAfterUpdate({
|
|
123
|
+
store,
|
|
124
|
+
dependencyTagger,
|
|
125
|
+
relativeFilepath,
|
|
126
|
+
fileContent,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
invokeOnStoreItemDelete({ relativeFilepath, fileContent }) {
|
|
133
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
134
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
135
|
+
const hookModule = hookInfo.getModule();
|
|
136
|
+
if (hookModule.onStoreItemDelete) {
|
|
137
|
+
hookModule.onStoreItemDelete({
|
|
138
|
+
store,
|
|
139
|
+
dependencyTagger,
|
|
140
|
+
relativeFilepath,
|
|
141
|
+
fileContent,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
invokeOnStoreChangeDone(changedFiles) {
|
|
148
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
149
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
150
|
+
const hookModule = hookInfo.getModule();
|
|
151
|
+
if (hookModule.onStoreChangeDone) {
|
|
152
|
+
hookModule.onStoreChangeDone({
|
|
153
|
+
store,
|
|
154
|
+
dependencyTagger,
|
|
155
|
+
changedFiles,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
invokeOnDumpCreate(dump) {
|
|
162
|
+
let processedDump = dump;
|
|
163
|
+
let returnValue: Dump | null = null;
|
|
164
|
+
const hookModulesInfo = moduleManager.getModuleGroupInfo();
|
|
165
|
+
hookModulesInfo.forEach(hookInfo => {
|
|
166
|
+
const hookModule = hookInfo.getModule();
|
|
167
|
+
if (config.dumpDir && hookModule.onDumpCreate) {
|
|
168
|
+
returnValue = hookModule.onDumpCreate({
|
|
169
|
+
dumpDir: config.dumpDir,
|
|
170
|
+
store,
|
|
171
|
+
dump: processedDump,
|
|
172
|
+
});
|
|
173
|
+
if (returnValue) {
|
|
174
|
+
processedDump = returnValue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return processedDump;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hookManager';
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { config } from '@lib/config';
|
|
4
|
+
import { store } from '@lib/store';
|
|
5
|
+
import { includeParser } from '../includeParser';
|
|
6
|
+
|
|
7
|
+
const staticFileContent = {
|
|
8
|
+
data: {
|
|
9
|
+
content: {
|
|
10
|
+
id: '58724',
|
|
11
|
+
title: 'Title',
|
|
12
|
+
author: {
|
|
13
|
+
entity: {
|
|
14
|
+
entityInclude: 'article2.json',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
image: {
|
|
18
|
+
entity: {
|
|
19
|
+
entityInclude: 'article2.json',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
queryInclude: 'lastPublishedContents',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
metadata: {
|
|
26
|
+
includes: {
|
|
27
|
+
static: {
|
|
28
|
+
'data.content.author.entity.entityInclude': 'article2.json',
|
|
29
|
+
'data.content.image.entity.entityInclude': 'article2.json',
|
|
30
|
+
},
|
|
31
|
+
dynamic: { 'data.content.queryInclude': 'lastPublishedContents' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
store.data.set('article2.json', {
|
|
36
|
+
data: {
|
|
37
|
+
content: {
|
|
38
|
+
id: '58728',
|
|
39
|
+
title: 'Title 2',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('staticIncludeParser', () => {
|
|
45
|
+
it('sets correct value by reference', () => {
|
|
46
|
+
includeParser.static('irrelevantFilePath', staticFileContent);
|
|
47
|
+
expect(staticFileContent.data.content.author.entity).toBe(
|
|
48
|
+
store.data.get('article2.json').data.content,
|
|
49
|
+
);
|
|
50
|
+
store.data.get('article2.json').data.content.title = 'Title 3';
|
|
51
|
+
expect(staticFileContent.data.content.author.entity).toBe(
|
|
52
|
+
store.data.get('article2.json').data.content,
|
|
53
|
+
);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const dynamicFileContent = {
|
|
58
|
+
data: {
|
|
59
|
+
content: {
|
|
60
|
+
queryInclude: 'query2?y=10',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
metadata: {
|
|
64
|
+
includes: {
|
|
65
|
+
dynamic: { 'data.content.queryInclude': 'query2?y=10' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
config.queryDir = fs.realpathSync(path.resolve('src/__tests__/fixtures/query'));
|
|
70
|
+
|
|
71
|
+
describe('queryIncludeParser', () => {
|
|
72
|
+
it('sets correct value', () => {
|
|
73
|
+
includeParser.dynamic(dynamicFileContent);
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
expect(dynamicFileContent.data.content.query.data).toStrictEqual([
|
|
77
|
+
{ id: '1' },
|
|
78
|
+
]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Json } from '@lib/utils/object/object.types';
|
|
2
|
+
import { IncludeParser } from './includeParser.types';
|
|
3
|
+
import {
|
|
4
|
+
configIncludeParser,
|
|
5
|
+
customIncludeParser,
|
|
6
|
+
entityIncludeParser,
|
|
7
|
+
localeIncludeParser,
|
|
8
|
+
queryIncludeParser,
|
|
9
|
+
// queryIncludeParser,
|
|
10
|
+
} from './parsers';
|
|
11
|
+
import { store } from '..';
|
|
12
|
+
|
|
13
|
+
export const includeParser: IncludeParser = {
|
|
14
|
+
static: (relativeFilepath: string, host: Json): void => {
|
|
15
|
+
const staticIncludes = host?.metadata?.includes?.static;
|
|
16
|
+
if (!staticIncludes) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
Object.keys(staticIncludes).forEach((includePath: string) => {
|
|
20
|
+
const mountPath = includePath.split('.');
|
|
21
|
+
const normalizedIncludePath = includePath.toLowerCase();
|
|
22
|
+
const includeKey = mountPath.pop();
|
|
23
|
+
if (includeKey) {
|
|
24
|
+
// All static includes share the same strategy, where the
|
|
25
|
+
// includePath gives access to the final target to be included.
|
|
26
|
+
const targetKey = staticIncludes[includePath];
|
|
27
|
+
const target = store.data.get(targetKey);
|
|
28
|
+
if (normalizedIncludePath.endsWith('configinclude')) {
|
|
29
|
+
configIncludeParser({ host, target, mountPath, includeKey });
|
|
30
|
+
}
|
|
31
|
+
if (normalizedIncludePath.endsWith('entityinclude')) {
|
|
32
|
+
entityIncludeParser({ host, target, mountPath, includeKey });
|
|
33
|
+
}
|
|
34
|
+
if (normalizedIncludePath.endsWith('custominclude')) {
|
|
35
|
+
customIncludeParser({ host, target, mountPath, includeKey });
|
|
36
|
+
}
|
|
37
|
+
if (normalizedIncludePath.endsWith('localeinclude')) {
|
|
38
|
+
localeIncludeParser({ host, target, mountPath, includeKey });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
dynamic: (host: Json): void => {
|
|
45
|
+
const dynamicIncludes = host?.metadata?.includes?.dynamic;
|
|
46
|
+
if (!dynamicIncludes) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
Object.keys(dynamicIncludes).forEach((includePath: string) => {
|
|
50
|
+
// No need to check if it is a query include.
|
|
51
|
+
queryIncludeParser({ host, includePath });
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|