@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,99 @@
|
|
|
1
|
+
import { Json } from '@lib/utils/object/object.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Global parser that is able to parse static and dynamic includes.
|
|
5
|
+
*/
|
|
6
|
+
export type IncludeParser = {
|
|
7
|
+
/**
|
|
8
|
+
* Parse all static includes (entity, config, locale and custom).
|
|
9
|
+
*
|
|
10
|
+
* @param relativeFilepath - Relative file path, inside dataDir, to the file to be parsed.
|
|
11
|
+
* @param host - Object that will host a pointer to a target.
|
|
12
|
+
*/
|
|
13
|
+
static(relativeFilepath: string, host: Json): void;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Parse all dynamic includes (queryInclude at this moment)
|
|
17
|
+
*
|
|
18
|
+
* @param host - Object that will host a pointer to a target.
|
|
19
|
+
*/
|
|
20
|
+
dynamic(host: Json): void;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Option to be passed a generic include parser (except entity and query includes).
|
|
25
|
+
*/
|
|
26
|
+
export type GenericIncludeParserOptions = {
|
|
27
|
+
/**
|
|
28
|
+
* Object that will host a pointer to a target.
|
|
29
|
+
*/
|
|
30
|
+
host: Json;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Target that will be referenced from a host.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* It can be any kind of data (object, string, array, int, etc), so we can not
|
|
37
|
+
* assume this is going to be an object.
|
|
38
|
+
*
|
|
39
|
+
* For example, custom includes can point to a string file, or query includes
|
|
40
|
+
* can return an error as a string.
|
|
41
|
+
*
|
|
42
|
+
* The only include that can ensure that its target is an object is entity include.
|
|
43
|
+
*/
|
|
44
|
+
target: unknown;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Array of items to the mount point inside the host object, minus the last item (e.g.- ['data', 'content']).
|
|
48
|
+
*/
|
|
49
|
+
mountPath: string[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Last item of the mount point, that defines the key used to specify the include (e.g.- "configInclude").
|
|
53
|
+
*/
|
|
54
|
+
includeKey: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Option to be passed an entity include parser.
|
|
59
|
+
*/
|
|
60
|
+
export type EntityIncludeParserOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Object that will host a pointer to a target.
|
|
63
|
+
*/
|
|
64
|
+
host: Json;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Entity object that will be referenced from a host.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Since entity includes work only with entity data, we are
|
|
71
|
+
* sure that this is an object.
|
|
72
|
+
*/
|
|
73
|
+
target: Json;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Array of items to the mount point inside the host object, minus the last item (e.g.- ['data', 'content']).
|
|
77
|
+
*/
|
|
78
|
+
mountPath: string[];
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Last item of the mount point, that defines the key used to specify the include (e.g.- "configInclude").
|
|
82
|
+
*/
|
|
83
|
+
includeKey: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Option to be passed a query include parser.
|
|
88
|
+
*/
|
|
89
|
+
export type QueryIncludeParserOptions = {
|
|
90
|
+
/**
|
|
91
|
+
* Object that will host a pointer to a target.
|
|
92
|
+
*/
|
|
93
|
+
host: Json;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Full string of items to the mount point inside the host object.
|
|
97
|
+
*/
|
|
98
|
+
includePath: string;
|
|
99
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './includeParser';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { entityIncludeParser } from '../entityIncludeParser';
|
|
2
|
+
|
|
3
|
+
describe('entityIncludeParser', () => {
|
|
4
|
+
it('mounts data on correct path', () => {
|
|
5
|
+
const host = {
|
|
6
|
+
data: {
|
|
7
|
+
content: {
|
|
8
|
+
entity: {
|
|
9
|
+
entityInclude: 'xxx',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
entityIncludeParser({
|
|
15
|
+
host,
|
|
16
|
+
target: { data: { content: { includedData: 'yyy' } } },
|
|
17
|
+
mountPath: ['data', 'content', 'entity'],
|
|
18
|
+
includeKey: 'entityInclude',
|
|
19
|
+
});
|
|
20
|
+
expect(host.data.content.entity).toStrictEqual({
|
|
21
|
+
includedData: 'yyy',
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('returns undefined when includeData has not data.content structure', () => {
|
|
26
|
+
const host = {
|
|
27
|
+
data: {
|
|
28
|
+
content: {
|
|
29
|
+
entity: {
|
|
30
|
+
entityInclude: 'xxx',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
entityIncludeParser({
|
|
36
|
+
host,
|
|
37
|
+
target: { includedData: 'yyy' },
|
|
38
|
+
mountPath: ['data', 'content', 'entity'],
|
|
39
|
+
includeKey: 'entityInclude',
|
|
40
|
+
});
|
|
41
|
+
expect(host.data.content.entity).toBeUndefined();
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenericIncludeParserOptions } from '../includeParser.types';
|
|
2
|
+
import { aliasIncludeParser } from './types/aliasIncludeParser';
|
|
3
|
+
|
|
4
|
+
export const configIncludeParser = (
|
|
5
|
+
options: GenericIncludeParserOptions,
|
|
6
|
+
): void => {
|
|
7
|
+
aliasIncludeParser(options);
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenericIncludeParserOptions } from '../includeParser.types';
|
|
2
|
+
import { aliasWithoutTypeIncludeParser } from './types/aliasWithoutTypeIncludeParser';
|
|
3
|
+
|
|
4
|
+
export const customIncludeParser = (
|
|
5
|
+
options: GenericIncludeParserOptions,
|
|
6
|
+
): void => {
|
|
7
|
+
aliasWithoutTypeIncludeParser(options, 'custom');
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getObjValue } from '@lib/utils/object';
|
|
2
|
+
import { EntityIncludeParserOptions } from '../includeParser.types';
|
|
3
|
+
|
|
4
|
+
export const entityIncludeParser = ({
|
|
5
|
+
host,
|
|
6
|
+
target,
|
|
7
|
+
mountPath,
|
|
8
|
+
}: EntityIncludeParserOptions): void => {
|
|
9
|
+
// Remove a level from mountPath, to mount entity a level up.
|
|
10
|
+
const includeKey = mountPath.pop();
|
|
11
|
+
if (includeKey) {
|
|
12
|
+
const mountPoint = getObjValue(host, mountPath);
|
|
13
|
+
mountPoint[includeKey] = target?.data?.content;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GenericIncludeParserOptions } from '../includeParser.types';
|
|
2
|
+
import { aliasIncludeParser } from './types/aliasIncludeParser';
|
|
3
|
+
|
|
4
|
+
export const localeIncludeParser = (
|
|
5
|
+
options: GenericIncludeParserOptions,
|
|
6
|
+
): void => {
|
|
7
|
+
aliasIncludeParser(options);
|
|
8
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { config } from '@lib/config';
|
|
2
|
+
import { RunMode } from '@lib/dataServer.types';
|
|
3
|
+
import { queryRunner } from '@lib/query';
|
|
4
|
+
import { isQueryErrorResponse } from '@lib/query/query.types';
|
|
5
|
+
import { getObjValue } from '@lib/utils/object';
|
|
6
|
+
import { QueryIncludeParserOptions } from '../includeParser.types';
|
|
7
|
+
import { aliasWithoutTypeIncludeParser } from './types/aliasWithoutTypeIncludeParser';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parses query includes.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Instead of executing a query and adding its result to a JSON file,
|
|
14
|
+
* create a Proxy so queries are only executed when they are consumed,
|
|
15
|
+
* in a Just-In-Time way.
|
|
16
|
+
*/
|
|
17
|
+
export const queryIncludeParser = ({
|
|
18
|
+
host,
|
|
19
|
+
includePath,
|
|
20
|
+
}: QueryIncludeParserOptions): void => {
|
|
21
|
+
const queryDefinition = getObjValue(host, includePath);
|
|
22
|
+
if (!queryDefinition) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Execute the query when the "data" property is accessed.
|
|
27
|
+
const proxyHandler = {
|
|
28
|
+
get: (target: any, prop: string) => {
|
|
29
|
+
if (prop === 'data') {
|
|
30
|
+
const queryResponse = queryRunner.run(queryDefinition);
|
|
31
|
+
if (isQueryErrorResponse(queryResponse)) {
|
|
32
|
+
return config.runMode === RunMode.DEV
|
|
33
|
+
? `${queryResponse.error} (message visible only in run mode DEV)`
|
|
34
|
+
: null;
|
|
35
|
+
}
|
|
36
|
+
return queryResponse.data;
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const target = new Proxy({ data: null }, proxyHandler);
|
|
42
|
+
|
|
43
|
+
const mountPath = includePath.split('.');
|
|
44
|
+
const includeKey = mountPath.pop();
|
|
45
|
+
if (includeKey) {
|
|
46
|
+
aliasWithoutTypeIncludeParser(
|
|
47
|
+
{ host, target, mountPath, includeKey },
|
|
48
|
+
'query',
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { aliasIncludeParser } from '../aliasIncludeParser';
|
|
2
|
+
|
|
3
|
+
describe('aliasIncludeParser', () => {
|
|
4
|
+
it('mount data on correct paths without alias and deletes original path', () => {
|
|
5
|
+
const fileContent = {
|
|
6
|
+
data: {
|
|
7
|
+
localeInclude: 'xxx',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
aliasIncludeParser({
|
|
11
|
+
host: fileContent,
|
|
12
|
+
target: { includedData: 'yyy' },
|
|
13
|
+
mountPath: ['data'],
|
|
14
|
+
includeKey: 'localeInclude',
|
|
15
|
+
});
|
|
16
|
+
expect(fileContent.data).toStrictEqual({
|
|
17
|
+
locale: { includedData: 'yyy' },
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('mount data on correct paths with alias and deletes original path', () => {
|
|
22
|
+
const fileContent = {
|
|
23
|
+
data: {
|
|
24
|
+
myLocaleInclude: 'xxx',
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
aliasIncludeParser({
|
|
28
|
+
host: fileContent,
|
|
29
|
+
target: { includedData: 'yyy' },
|
|
30
|
+
mountPath: ['data'],
|
|
31
|
+
includeKey: 'myLocaleInclude',
|
|
32
|
+
});
|
|
33
|
+
expect(fileContent.data).toStrictEqual({
|
|
34
|
+
myLocale: { includedData: 'yyy' },
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { aliasWithoutTypeIncludeParser } from '../aliasWithoutTypeIncludeParser';
|
|
2
|
+
|
|
3
|
+
describe('aliasWithoutTypeIncludeParser', () => {
|
|
4
|
+
it('mount data on correct paths without alias and deletes original path', () => {
|
|
5
|
+
const hostObject = {
|
|
6
|
+
data: {
|
|
7
|
+
customInclude: 'xxx',
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
aliasWithoutTypeIncludeParser(
|
|
11
|
+
{
|
|
12
|
+
host: hostObject,
|
|
13
|
+
target: { includedData: 'yyy' },
|
|
14
|
+
mountPath: ['data'],
|
|
15
|
+
includeKey: 'customInclude',
|
|
16
|
+
},
|
|
17
|
+
'custom',
|
|
18
|
+
);
|
|
19
|
+
expect(hostObject.data).toStrictEqual({
|
|
20
|
+
custom: { includedData: 'yyy' },
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('mount data on correct paths with alias and deletes original path', () => {
|
|
25
|
+
const hostObject = {
|
|
26
|
+
data: {
|
|
27
|
+
myCustomInclude: 'xxx',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
aliasWithoutTypeIncludeParser(
|
|
31
|
+
{
|
|
32
|
+
host: hostObject,
|
|
33
|
+
target: { includedData: 'yyy' },
|
|
34
|
+
mountPath: ['data'],
|
|
35
|
+
includeKey: 'myCustomInclude',
|
|
36
|
+
},
|
|
37
|
+
'custom',
|
|
38
|
+
);
|
|
39
|
+
expect(hostObject.data).toStrictEqual({
|
|
40
|
+
my: { includedData: 'yyy' },
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GenericIncludeParserOptions } from '@lib/store/include/includeParser.types';
|
|
2
|
+
import { getObjValue } from '@lib/utils/object';
|
|
3
|
+
|
|
4
|
+
export const aliasIncludeParser = ({
|
|
5
|
+
host,
|
|
6
|
+
target,
|
|
7
|
+
mountPath,
|
|
8
|
+
includeKey,
|
|
9
|
+
}: GenericIncludeParserOptions): void => {
|
|
10
|
+
const mountPoint = getObjValue(host, mountPath);
|
|
11
|
+
mountPoint[includeKey.replace('Include', '')] = target;
|
|
12
|
+
delete mountPoint[includeKey];
|
|
13
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GenericIncludeParserOptions } from '@lib/store/include/includeParser.types';
|
|
2
|
+
import { getObjValue } from '@lib/utils/object';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param options - Object with options as defined in @see {@link IncludeParserOptions}
|
|
6
|
+
* @param type - Type of include (custom, query, etc)
|
|
7
|
+
*/
|
|
8
|
+
export const aliasWithoutTypeIncludeParser = (
|
|
9
|
+
{ host, target, mountPath, includeKey }: GenericIncludeParserOptions,
|
|
10
|
+
type: string,
|
|
11
|
+
): void => {
|
|
12
|
+
const mountPoint = getObjValue(host, mountPath);
|
|
13
|
+
const mountPointKey =
|
|
14
|
+
includeKey.replace('Include', '') === type
|
|
15
|
+
? type
|
|
16
|
+
: includeKey.replace(
|
|
17
|
+
`${type.charAt(0).toUpperCase() + type.slice(1)}Include`,
|
|
18
|
+
'',
|
|
19
|
+
);
|
|
20
|
+
mountPoint[mountPointKey] = target;
|
|
21
|
+
delete mountPoint[includeKey];
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './store';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import microtime from 'microtime';
|
|
2
|
+
import { VARIANT_SEPARATOR } from '@lib/utils/string';
|
|
3
|
+
import { logger } from '@lib/utils/logger';
|
|
4
|
+
import { cache } from '@lib/utils/cache';
|
|
5
|
+
import {
|
|
6
|
+
Store,
|
|
7
|
+
StoreData,
|
|
8
|
+
StoreSubset,
|
|
9
|
+
StoreSubsetOptions,
|
|
10
|
+
} from './store.types';
|
|
11
|
+
|
|
12
|
+
// Instantiate the subset cache so it can be accessed faster.
|
|
13
|
+
const subsetCache = cache.bin<StoreSubset>('store-subset');
|
|
14
|
+
|
|
15
|
+
const initIndex = () => {
|
|
16
|
+
return {
|
|
17
|
+
url: new Map<string, any>(),
|
|
18
|
+
uuid: new Map<string, any>(),
|
|
19
|
+
custom: new Map<string, any>(),
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const initData = () => new Map<string, any>() as StoreData<string, any>;
|
|
24
|
+
export const store: Store = {
|
|
25
|
+
syncDate: null,
|
|
26
|
+
data: initData(),
|
|
27
|
+
deleted: new Set<string>(),
|
|
28
|
+
index: initIndex(),
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
store.data.subset = (options: StoreSubsetOptions): StoreSubset => {
|
|
32
|
+
const startDate = microtime.now();
|
|
33
|
+
|
|
34
|
+
// Merge provided options with default ones.
|
|
35
|
+
const defaultOptions = {
|
|
36
|
+
variant: '_main',
|
|
37
|
+
ext: 'json',
|
|
38
|
+
recursive: 'true',
|
|
39
|
+
};
|
|
40
|
+
const opts = { ...defaultOptions, ...options };
|
|
41
|
+
|
|
42
|
+
let subset: StoreSubset = { filenames: [], items: [] };
|
|
43
|
+
|
|
44
|
+
const dirWithTrimmedSlashes = opts.dir?.replace(/^\//, '').replace(/\/$/, '');
|
|
45
|
+
const dirPart = dirWithTrimmedSlashes ? `${dirWithTrimmedSlashes}/` : '';
|
|
46
|
+
|
|
47
|
+
let variantPart;
|
|
48
|
+
if (opts.variant) {
|
|
49
|
+
const recursiveGroup = opts.recursive ? '.' : '[^/]';
|
|
50
|
+
variantPart =
|
|
51
|
+
opts.variant === '_main'
|
|
52
|
+
? `((?!--)${recursiveGroup})+`
|
|
53
|
+
: `${recursiveGroup}+${VARIANT_SEPARATOR}${opts.variant}`;
|
|
54
|
+
} else {
|
|
55
|
+
variantPart = '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let extensionPart;
|
|
59
|
+
if (opts.recursive) {
|
|
60
|
+
extensionPart = opts.ext ? `.${opts.ext}` : '.+';
|
|
61
|
+
} else {
|
|
62
|
+
extensionPart = opts.ext ? `.${opts.ext}` : '[^/]+';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const pattern = `^${dirPart}${variantPart}${extensionPart}$`;
|
|
66
|
+
logger.debug(`Store subset pattern: ${pattern}`);
|
|
67
|
+
const cachedSubset = subsetCache.get(pattern);
|
|
68
|
+
if (cachedSubset) {
|
|
69
|
+
subset = cachedSubset;
|
|
70
|
+
logger.debug(
|
|
71
|
+
`Store subset obtained from cache in ${
|
|
72
|
+
(microtime.now() - startDate) / 1000
|
|
73
|
+
}ms. ${subset.items.length} items.`,
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
const regex = new RegExp(pattern);
|
|
77
|
+
const mapKeys = Array.from(store.data.keys());
|
|
78
|
+
mapKeys.forEach(k => {
|
|
79
|
+
if (k.match(regex)) {
|
|
80
|
+
subset.filenames.push(k);
|
|
81
|
+
subset.items.push(store.data.get(k));
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
subsetCache.set(pattern, subset);
|
|
85
|
+
logger.debug(
|
|
86
|
+
`Store subset created in ${(microtime.now() - startDate) / 1000} ms. ${
|
|
87
|
+
subset.items.length
|
|
88
|
+
} items.`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return subset;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Resets store and deletes all loaded data.
|
|
97
|
+
*/
|
|
98
|
+
export const resetStore = (): void => {
|
|
99
|
+
store.syncDate = null;
|
|
100
|
+
const previousSubset = store.data.subset;
|
|
101
|
+
store.data = initData();
|
|
102
|
+
store.data.subset = previousSubset;
|
|
103
|
+
store.deleted.clear();
|
|
104
|
+
store.index = initIndex();
|
|
105
|
+
};
|