@tasenor/common-node 1.9.16
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/.eslintrc.js +4 -0
- package/LICENSE +21 -0
- package/dist/tasenor-common-node/src/cli.d.ts +81 -0
- package/dist/tasenor-common-node/src/cli.js +242 -0
- package/dist/tasenor-common-node/src/cli.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/account.d.ts +12 -0
- package/dist/tasenor-common-node/src/commands/account.js +58 -0
- package/dist/tasenor-common-node/src/commands/account.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/balance.d.ts +11 -0
- package/dist/tasenor-common-node/src/commands/balance.js +117 -0
- package/dist/tasenor-common-node/src/commands/balance.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/db.d.ts +14 -0
- package/dist/tasenor-common-node/src/commands/db.js +69 -0
- package/dist/tasenor-common-node/src/commands/db.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/entry.d.ts +13 -0
- package/dist/tasenor-common-node/src/commands/entry.js +106 -0
- package/dist/tasenor-common-node/src/commands/entry.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/import.d.ts +17 -0
- package/dist/tasenor-common-node/src/commands/import.js +140 -0
- package/dist/tasenor-common-node/src/commands/import.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/importer.d.ts +13 -0
- package/dist/tasenor-common-node/src/commands/importer.js +71 -0
- package/dist/tasenor-common-node/src/commands/importer.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/index.d.ts +191 -0
- package/dist/tasenor-common-node/src/commands/index.js +482 -0
- package/dist/tasenor-common-node/src/commands/index.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/period.d.ts +12 -0
- package/dist/tasenor-common-node/src/commands/period.js +48 -0
- package/dist/tasenor-common-node/src/commands/period.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/plugin.d.ts +15 -0
- package/dist/tasenor-common-node/src/commands/plugin.js +78 -0
- package/dist/tasenor-common-node/src/commands/plugin.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/report.d.ts +11 -0
- package/dist/tasenor-common-node/src/commands/report.js +96 -0
- package/dist/tasenor-common-node/src/commands/report.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/settings.d.ts +10 -0
- package/dist/tasenor-common-node/src/commands/settings.js +64 -0
- package/dist/tasenor-common-node/src/commands/settings.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/stock.d.ts +8 -0
- package/dist/tasenor-common-node/src/commands/stock.js +73 -0
- package/dist/tasenor-common-node/src/commands/stock.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/tag.d.ts +13 -0
- package/dist/tasenor-common-node/src/commands/tag.js +89 -0
- package/dist/tasenor-common-node/src/commands/tag.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/tx.d.ts +12 -0
- package/dist/tasenor-common-node/src/commands/tx.js +81 -0
- package/dist/tasenor-common-node/src/commands/tx.js.map +1 -0
- package/dist/tasenor-common-node/src/commands/user.d.ts +12 -0
- package/dist/tasenor-common-node/src/commands/user.js +52 -0
- package/dist/tasenor-common-node/src/commands/user.js.map +1 -0
- package/dist/tasenor-common-node/src/database/BookkeeperImporter.d.ts +77 -0
- package/dist/tasenor-common-node/src/database/BookkeeperImporter.js +343 -0
- package/dist/tasenor-common-node/src/database/BookkeeperImporter.js.map +1 -0
- package/dist/tasenor-common-node/src/database/DB.d.ts +51 -0
- package/dist/tasenor-common-node/src/database/DB.js +354 -0
- package/dist/tasenor-common-node/src/database/DB.js.map +1 -0
- package/dist/tasenor-common-node/src/database/index.d.ts +7 -0
- package/dist/tasenor-common-node/src/database/index.js +8 -0
- package/dist/tasenor-common-node/src/database/index.js.map +1 -0
- package/dist/tasenor-common-node/src/doccer.d.ts +29 -0
- package/dist/tasenor-common-node/src/doccer.js +30 -0
- package/dist/tasenor-common-node/src/doccer.js.map +1 -0
- package/dist/tasenor-common-node/src/error.d.ts +30 -0
- package/dist/tasenor-common-node/src/error.js +35 -0
- package/dist/tasenor-common-node/src/error.js.map +1 -0
- package/dist/tasenor-common-node/src/export/Exporter.d.ts +69 -0
- package/dist/tasenor-common-node/src/export/Exporter.js +123 -0
- package/dist/tasenor-common-node/src/export/Exporter.js.map +1 -0
- package/dist/tasenor-common-node/src/export/TasenorExporter.d.ts +55 -0
- package/dist/tasenor-common-node/src/export/TasenorExporter.js +135 -0
- package/dist/tasenor-common-node/src/export/TasenorExporter.js.map +1 -0
- package/dist/tasenor-common-node/src/export/TilitinExporter.d.ts +71 -0
- package/dist/tasenor-common-node/src/export/TilitinExporter.js +290 -0
- package/dist/tasenor-common-node/src/export/TilitinExporter.js.map +1 -0
- package/dist/tasenor-common-node/src/export/index.d.ts +8 -0
- package/dist/tasenor-common-node/src/export/index.js +9 -0
- package/dist/tasenor-common-node/src/export/index.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TextFileProcessHandler.d.ts +104 -0
- package/dist/tasenor-common-node/src/import/TextFileProcessHandler.js +354 -0
- package/dist/tasenor-common-node/src/import/TextFileProcessHandler.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TransactionImportConnector.d.ts +38 -0
- package/dist/tasenor-common-node/src/import/TransactionImportConnector.js +27 -0
- package/dist/tasenor-common-node/src/import/TransactionImportConnector.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TransactionImportHandler.d.ts +173 -0
- package/dist/tasenor-common-node/src/import/TransactionImportHandler.js +733 -0
- package/dist/tasenor-common-node/src/import/TransactionImportHandler.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TransactionRules.d.ts +238 -0
- package/dist/tasenor-common-node/src/import/TransactionRules.js +522 -0
- package/dist/tasenor-common-node/src/import/TransactionRules.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TransactionUI.d.ts +181 -0
- package/dist/tasenor-common-node/src/import/TransactionUI.js +482 -0
- package/dist/tasenor-common-node/src/import/TransactionUI.js.map +1 -0
- package/dist/tasenor-common-node/src/import/TransferAnalyzer.d.ts +324 -0
- package/dist/tasenor-common-node/src/import/TransferAnalyzer.js +1379 -0
- package/dist/tasenor-common-node/src/import/TransferAnalyzer.js.map +1 -0
- package/dist/tasenor-common-node/src/import/index.d.ts +11 -0
- package/dist/tasenor-common-node/src/import/index.js +12 -0
- package/dist/tasenor-common-node/src/import/index.js.map +1 -0
- package/dist/tasenor-common-node/src/index.d.ts +12 -0
- package/dist/tasenor-common-node/src/index.js +13 -0
- package/dist/tasenor-common-node/src/index.js.map +1 -0
- package/dist/tasenor-common-node/src/net/crypto.d.ts +33 -0
- package/dist/tasenor-common-node/src/net/crypto.js +63 -0
- package/dist/tasenor-common-node/src/net/crypto.js.map +1 -0
- package/dist/tasenor-common-node/src/net/git.d.ts +49 -0
- package/dist/tasenor-common-node/src/net/git.js +137 -0
- package/dist/tasenor-common-node/src/net/git.js.map +1 -0
- package/dist/tasenor-common-node/src/net/index.d.ts +10 -0
- package/dist/tasenor-common-node/src/net/index.js +11 -0
- package/dist/tasenor-common-node/src/net/index.js.map +1 -0
- package/dist/tasenor-common-node/src/net/middleware.d.ts +61 -0
- package/dist/tasenor-common-node/src/net/middleware.js +220 -0
- package/dist/tasenor-common-node/src/net/middleware.js.map +1 -0
- package/dist/tasenor-common-node/src/net/tokens.d.ts +50 -0
- package/dist/tasenor-common-node/src/net/tokens.js +141 -0
- package/dist/tasenor-common-node/src/net/tokens.js.map +1 -0
- package/dist/tasenor-common-node/src/net/vault.d.ts +67 -0
- package/dist/tasenor-common-node/src/net/vault.js +145 -0
- package/dist/tasenor-common-node/src/net/vault.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/BackendPlugin.d.ts +91 -0
- package/dist/tasenor-common-node/src/plugins/BackendPlugin.js +165 -0
- package/dist/tasenor-common-node/src/plugins/BackendPlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/DataPlugin.d.ts +13 -0
- package/dist/tasenor-common-node/src/plugins/DataPlugin.js +26 -0
- package/dist/tasenor-common-node/src/plugins/DataPlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/ImportPlugin.d.ts +188 -0
- package/dist/tasenor-common-node/src/plugins/ImportPlugin.js +204 -0
- package/dist/tasenor-common-node/src/plugins/ImportPlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/ReportPlugin.d.ts +132 -0
- package/dist/tasenor-common-node/src/plugins/ReportPlugin.js +393 -0
- package/dist/tasenor-common-node/src/plugins/ReportPlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/SchemePlugin.d.ts +34 -0
- package/dist/tasenor-common-node/src/plugins/SchemePlugin.js +47 -0
- package/dist/tasenor-common-node/src/plugins/SchemePlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/ServicePlugin.d.ts +80 -0
- package/dist/tasenor-common-node/src/plugins/ServicePlugin.js +168 -0
- package/dist/tasenor-common-node/src/plugins/ServicePlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/ToolPlugin.d.ts +27 -0
- package/dist/tasenor-common-node/src/plugins/ToolPlugin.js +37 -0
- package/dist/tasenor-common-node/src/plugins/ToolPlugin.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/index.d.ts +13 -0
- package/dist/tasenor-common-node/src/plugins/index.js +14 -0
- package/dist/tasenor-common-node/src/plugins/index.js.map +1 -0
- package/dist/tasenor-common-node/src/plugins/plugins.d.ts +101 -0
- package/dist/tasenor-common-node/src/plugins/plugins.js +292 -0
- package/dist/tasenor-common-node/src/plugins/plugins.js.map +1 -0
- package/dist/tasenor-common-node/src/process/Process.d.ts +108 -0
- package/dist/tasenor-common-node/src/process/Process.js +335 -0
- package/dist/tasenor-common-node/src/process/Process.js.map +1 -0
- package/dist/tasenor-common-node/src/process/ProcessConnector.d.ts +24 -0
- package/dist/tasenor-common-node/src/process/ProcessConnector.js +28 -0
- package/dist/tasenor-common-node/src/process/ProcessConnector.js.map +1 -0
- package/dist/tasenor-common-node/src/process/ProcessFile.d.ts +69 -0
- package/dist/tasenor-common-node/src/process/ProcessFile.js +145 -0
- package/dist/tasenor-common-node/src/process/ProcessFile.js.map +1 -0
- package/dist/tasenor-common-node/src/process/ProcessHandler.d.ts +60 -0
- package/dist/tasenor-common-node/src/process/ProcessHandler.js +73 -0
- package/dist/tasenor-common-node/src/process/ProcessHandler.js.map +1 -0
- package/dist/tasenor-common-node/src/process/ProcessStep.d.ts +52 -0
- package/dist/tasenor-common-node/src/process/ProcessStep.js +78 -0
- package/dist/tasenor-common-node/src/process/ProcessStep.js.map +1 -0
- package/dist/tasenor-common-node/src/process/ProcessingSystem.d.ts +60 -0
- package/dist/tasenor-common-node/src/process/ProcessingSystem.js +182 -0
- package/dist/tasenor-common-node/src/process/ProcessingSystem.js.map +1 -0
- package/dist/tasenor-common-node/src/process/index.d.ts +11 -0
- package/dist/tasenor-common-node/src/process/index.js +12 -0
- package/dist/tasenor-common-node/src/process/index.js.map +1 -0
- package/dist/tasenor-common-node/src/reports/conversions.d.ts +8 -0
- package/dist/tasenor-common-node/src/reports/conversions.js +47 -0
- package/dist/tasenor-common-node/src/reports/conversions.js.map +1 -0
- package/dist/tasenor-common-node/src/reports/index.d.ts +6 -0
- package/dist/tasenor-common-node/src/reports/index.js +7 -0
- package/dist/tasenor-common-node/src/reports/index.js.map +1 -0
- package/dist/tasenor-common-node/src/server/ISPDemoServer.d.ts +43 -0
- package/dist/tasenor-common-node/src/server/ISPDemoServer.js +112 -0
- package/dist/tasenor-common-node/src/server/ISPDemoServer.js.map +1 -0
- package/dist/tasenor-common-node/src/server/api.d.ts +15 -0
- package/dist/tasenor-common-node/src/server/api.js +27 -0
- package/dist/tasenor-common-node/src/server/api.js.map +1 -0
- package/dist/tasenor-common-node/src/server/index.d.ts +7 -0
- package/dist/tasenor-common-node/src/server/index.js +8 -0
- package/dist/tasenor-common-node/src/server/index.js.map +1 -0
- package/dist/tasenor-common-node/src/server/router.d.ts +5 -0
- package/dist/tasenor-common-node/src/server/router.js +37 -0
- package/dist/tasenor-common-node/src/server/router.js.map +1 -0
- package/dist/tasenor-common-node/src/system.d.ts +27 -0
- package/dist/tasenor-common-node/src/system.js +95 -0
- package/dist/tasenor-common-node/src/system.js.map +1 -0
- package/dist/tasenor-common-node/src/testing/ProcessingSystemMock.d.ts +21 -0
- package/dist/tasenor-common-node/src/testing/ProcessingSystemMock.js +33 -0
- package/dist/tasenor-common-node/src/testing/ProcessingSystemMock.js.map +1 -0
- package/dist/tasenor-common-node/src/testing/UnitTestImportConnector.d.ts +24 -0
- package/dist/tasenor-common-node/src/testing/UnitTestImportConnector.js +68 -0
- package/dist/tasenor-common-node/src/testing/UnitTestImportConnector.js.map +1 -0
- package/dist/tasenor-common-node/src/testing/UnitTester.d.ts +64 -0
- package/dist/tasenor-common-node/src/testing/UnitTester.js +199 -0
- package/dist/tasenor-common-node/src/testing/UnitTester.js.map +1 -0
- package/dist/tasenor-common-node/src/testing/index.d.ts +4 -0
- package/dist/tasenor-common-node/src/testing/index.js +5 -0
- package/dist/tasenor-common-node/src/testing/index.js.map +1 -0
- package/dist/tasenor-common-node/src/testing/test-handlers.d.ts +13 -0
- package/dist/tasenor-common-node/src/testing/test-handlers.js +52 -0
- package/dist/tasenor-common-node/src/testing/test-handlers.js.map +1 -0
- package/dist/tasenor-common-node/tests/TransactionRules.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/TransactionRules.spec.js +64 -0
- package/dist/tasenor-common-node/tests/TransactionRules.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-account-address.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-account-address.spec.js +80 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-account-address.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-buying-and-selling.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-buying-and-selling.spec.js +342 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-buying-and-selling.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-loans.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-loans.spec.js +174 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-loans.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-multiple-null-amounts.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-multiple-null-amounts.spec.js +175 -0
- package/dist/tasenor-common-node/tests/TransferAnalyzer-multiple-null-amounts.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/password.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/password.spec.js +8 -0
- package/dist/tasenor-common-node/tests/password.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/tokens.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/tokens.spec.js +49 -0
- package/dist/tasenor-common-node/tests/tokens.spec.js.map +1 -0
- package/dist/tasenor-common-node/tests/vault.spec.d.ts +1 -0
- package/dist/tasenor-common-node/tests/vault.spec.js +19 -0
- package/dist/tasenor-common-node/tests/vault.spec.js.map +1 -0
- package/dist/tasenor-common-plugins/src/CoinbaseImport/backend/CoinbaseHandler.d.ts +11 -0
- package/dist/tasenor-common-plugins/src/CoinbaseImport/backend/CoinbaseHandler.js +30 -0
- package/dist/tasenor-common-plugins/src/CoinbaseImport/backend/CoinbaseHandler.js.map +1 -0
- package/dist/tasenor-common-plugins/src/IncomeAndExpenses/backend/index.d.ts +5 -0
- package/dist/tasenor-common-plugins/src/IncomeAndExpenses/backend/index.js +350 -0
- package/dist/tasenor-common-plugins/src/IncomeAndExpenses/backend/index.js.map +1 -0
- package/dist/tasenor-common-plugins/src/KrakenImport/backend/KrakenHandler.d.ts +23 -0
- package/dist/tasenor-common-plugins/src/KrakenImport/backend/KrakenHandler.js +83 -0
- package/dist/tasenor-common-plugins/src/KrakenImport/backend/KrakenHandler.js.map +1 -0
- package/dist/tasenor-common-plugins/src/LynxImport/backend/LynxHandler.d.ts +28 -0
- package/dist/tasenor-common-plugins/src/LynxImport/backend/LynxHandler.js +340 -0
- package/dist/tasenor-common-plugins/src/LynxImport/backend/LynxHandler.js.map +1 -0
- package/dist/tasenor-common-plugins/src/NordeaImport/backend/NordeaHandler.d.ts +11 -0
- package/dist/tasenor-common-plugins/src/NordeaImport/backend/NordeaHandler.js +39 -0
- package/dist/tasenor-common-plugins/src/NordeaImport/backend/NordeaHandler.js.map +1 -0
- package/dist/tasenor-common-plugins/src/NordnetImport/backend/NordnetHandler.d.ts +17 -0
- package/dist/tasenor-common-plugins/src/NordnetImport/backend/NordnetHandler.js +66 -0
- package/dist/tasenor-common-plugins/src/NordnetImport/backend/NordnetHandler.js.map +1 -0
- package/dist/tasenor-common-plugins/src/TITOImport/backend/TITOHandler.d.ts +13 -0
- package/dist/tasenor-common-plugins/src/TITOImport/backend/TITOHandler.js +241 -0
- package/dist/tasenor-common-plugins/src/TITOImport/backend/TITOHandler.js.map +1 -0
- package/jest.config.js +1 -0
- package/package.json +62 -0
- package/src/cli.ts +267 -0
- package/src/commands/account.ts +69 -0
- package/src/commands/balance.ts +131 -0
- package/src/commands/db.ts +84 -0
- package/src/commands/entry.ts +117 -0
- package/src/commands/import.ts +160 -0
- package/src/commands/importer.ts +84 -0
- package/src/commands/index.ts +534 -0
- package/src/commands/period.ts +59 -0
- package/src/commands/plugin.ts +95 -0
- package/src/commands/report.ts +113 -0
- package/src/commands/settings.ts +75 -0
- package/src/commands/stock.ts +80 -0
- package/src/commands/tag.ts +102 -0
- package/src/commands/tx.ts +93 -0
- package/src/commands/user.ts +65 -0
- package/src/database/BookkeeperImporter.ts +358 -0
- package/src/database/DB.ts +396 -0
- package/src/database/index.ts +7 -0
- package/src/doccer.ts +29 -0
- package/src/error.ts +32 -0
- package/src/export/Exporter.ts +136 -0
- package/src/export/TasenorExporter.ts +144 -0
- package/src/export/TilitinExporter.ts +302 -0
- package/src/export/index.ts +8 -0
- package/src/import/TextFileProcessHandler.ts +384 -0
- package/src/import/TransactionImportConnector.ts +65 -0
- package/src/import/TransactionImportHandler.ts +819 -0
- package/src/import/TransactionRules.ts +570 -0
- package/src/import/TransactionUI.ts +520 -0
- package/src/import/TransferAnalyzer.ts +1450 -0
- package/src/import/index.ts +11 -0
- package/src/index.ts +12 -0
- package/src/net/crypto.ts +69 -0
- package/src/net/git.ts +151 -0
- package/src/net/index.ts +10 -0
- package/src/net/middleware.ts +261 -0
- package/src/net/tokens.ts +140 -0
- package/src/net/vault.ts +161 -0
- package/src/plugins/BackendPlugin.ts +188 -0
- package/src/plugins/DataPlugin.ts +29 -0
- package/src/plugins/ImportPlugin.ts +211 -0
- package/src/plugins/ReportPlugin.ts +443 -0
- package/src/plugins/SchemePlugin.ts +56 -0
- package/src/plugins/ServicePlugin.ts +188 -0
- package/src/plugins/ToolPlugin.ts +44 -0
- package/src/plugins/index.ts +13 -0
- package/src/plugins/plugins.ts +345 -0
- package/src/process/Process.ts +368 -0
- package/src/process/ProcessConnector.ts +45 -0
- package/src/process/ProcessFile.ts +169 -0
- package/src/process/ProcessHandler.ts +94 -0
- package/src/process/ProcessStep.ts +100 -0
- package/src/process/ProcessingSystem.ts +202 -0
- package/src/process/index.ts +11 -0
- package/src/reports/conversions.ts +52 -0
- package/src/reports/index.ts +6 -0
- package/src/server/ISPDemoServer.ts +122 -0
- package/src/server/api.ts +37 -0
- package/src/server/index.ts +7 -0
- package/src/server/router.ts +60 -0
- package/src/system.ts +96 -0
- package/src/testing/ProcessingSystemMock.ts +45 -0
- package/src/testing/UnitTestImportConnector.ts +86 -0
- package/src/testing/UnitTester.ts +231 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/test-handlers.ts +55 -0
- package/tests/TransactionRules.spec.ts +73 -0
- package/tests/TransferAnalyzer-account-address.spec.ts +87 -0
- package/tests/TransferAnalyzer-buying-and-selling.spec.ts +354 -0
- package/tests/TransferAnalyzer-loans.spec.ts +197 -0
- package/tests/TransferAnalyzer-multiple-null-amounts.spec.ts +181 -0
- package/tests/password.spec.ts +8 -0
- package/tests/tokens.spec.ts +52 -0
- package/tests/vault.spec.ts +20 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import chardet from 'chardet';
|
|
2
|
+
import clone from 'clone';
|
|
3
|
+
import { DatabaseError, InvalidFile, NotImplemented } from '../error';
|
|
4
|
+
/**
|
|
5
|
+
* An instance of input data for processing.
|
|
6
|
+
*/
|
|
7
|
+
export class ProcessFile {
|
|
8
|
+
id;
|
|
9
|
+
processId;
|
|
10
|
+
name;
|
|
11
|
+
type;
|
|
12
|
+
encoding;
|
|
13
|
+
data;
|
|
14
|
+
_decoded;
|
|
15
|
+
constructor(obj) {
|
|
16
|
+
this.id = null;
|
|
17
|
+
this.processId = obj.processId || null;
|
|
18
|
+
this.name = obj.name;
|
|
19
|
+
this.type = obj.type;
|
|
20
|
+
this.encoding = obj.encoding;
|
|
21
|
+
this.data = obj.data;
|
|
22
|
+
this._decoded = undefined;
|
|
23
|
+
}
|
|
24
|
+
toString() {
|
|
25
|
+
return `ProcessFile #${this.id} ${this.name}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the loaded process information as JSON object.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
processId: this.processId,
|
|
34
|
+
name: this.name,
|
|
35
|
+
type: this.type,
|
|
36
|
+
encoding: this.encoding,
|
|
37
|
+
data: this.data
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Save the file to the database.
|
|
42
|
+
*/
|
|
43
|
+
async save(db) {
|
|
44
|
+
const out = this.toJSON();
|
|
45
|
+
if (this.encoding === 'json') {
|
|
46
|
+
out.data = JSON.stringify(out.data);
|
|
47
|
+
}
|
|
48
|
+
if (this.id) {
|
|
49
|
+
await db('process_files').update(out).where({ id: this.id });
|
|
50
|
+
return this.id;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
this.id = (await db('process_files').insert(out).returning('id'))[0].id;
|
|
54
|
+
if (this.id)
|
|
55
|
+
return this.id;
|
|
56
|
+
throw new DatabaseError(`Saving process ${JSON.stringify(out)} failed.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Check if the first line of the text file matches to the regular expression.
|
|
61
|
+
* @param re
|
|
62
|
+
*/
|
|
63
|
+
firstLineMatch(re) {
|
|
64
|
+
const str = this.decode();
|
|
65
|
+
const n = str.indexOf('\n');
|
|
66
|
+
const line1 = n < 0 ? str : str.substr(0, n).trim();
|
|
67
|
+
return re.test(line1);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if the second line of the text file matches to the regular expression.
|
|
71
|
+
* @param re
|
|
72
|
+
*/
|
|
73
|
+
secondLineMatch(re) {
|
|
74
|
+
const lines = this.decode().split('\n');
|
|
75
|
+
return lines.length > 1 && re.test(lines[1].trim());
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check if the third line of the text file matches to the regular expression.
|
|
79
|
+
* @param re
|
|
80
|
+
*/
|
|
81
|
+
thirdLineMatch(re) {
|
|
82
|
+
const lines = this.decode().split('\n');
|
|
83
|
+
return lines.length > 2 && re.test(lines[2].trim());
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Check if the file begins with the given string.
|
|
87
|
+
*/
|
|
88
|
+
startsWith(s) {
|
|
89
|
+
let buffer;
|
|
90
|
+
switch (this.encoding) {
|
|
91
|
+
case 'base64':
|
|
92
|
+
buffer = Buffer.from(this.data.substring(0, s.length * 2), 'base64');
|
|
93
|
+
return buffer.toString('ascii').substr(0, s.length) === s;
|
|
94
|
+
default:
|
|
95
|
+
throw new NotImplemented(`Cannot handle encoding ${this.encoding} in startWith().`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Find out if the content is binary or text.
|
|
100
|
+
*
|
|
101
|
+
* The mime type has to start with `text/`.
|
|
102
|
+
*/
|
|
103
|
+
isTextFile() {
|
|
104
|
+
return this.type?.startsWith('text/') || false;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Convert chardet encoding to the supported buffer encoding
|
|
108
|
+
* "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"
|
|
109
|
+
*/
|
|
110
|
+
parseEncoding(encoding) {
|
|
111
|
+
switch (encoding.toUpperCase()) {
|
|
112
|
+
case 'UTF-8':
|
|
113
|
+
return 'utf-8';
|
|
114
|
+
case 'ISO-8859-1':
|
|
115
|
+
return 'latin1';
|
|
116
|
+
case 'UTF-16LE':
|
|
117
|
+
return 'utf16le';
|
|
118
|
+
default:
|
|
119
|
+
throw new InvalidFile(`Not able to map text encoding ${encoding}.`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Try to recognize the file content and decode if it is a recognizable text format.
|
|
124
|
+
*/
|
|
125
|
+
decode() {
|
|
126
|
+
if (this._decoded) {
|
|
127
|
+
return this._decoded;
|
|
128
|
+
}
|
|
129
|
+
if (this.encoding === 'base64') {
|
|
130
|
+
const buffer = Buffer.from(this.data, 'base64');
|
|
131
|
+
const encoding = chardet.detect(buffer);
|
|
132
|
+
if (!encoding) {
|
|
133
|
+
throw new InvalidFile(`Cannot determine encoding for '${this}'.`);
|
|
134
|
+
}
|
|
135
|
+
this._decoded = buffer.toString(this.parseEncoding(encoding));
|
|
136
|
+
return this._decoded;
|
|
137
|
+
}
|
|
138
|
+
if (this.encoding === 'utf-8') {
|
|
139
|
+
this._decoded = clone(this.data);
|
|
140
|
+
return this._decoded || '';
|
|
141
|
+
}
|
|
142
|
+
throw new InvalidFile(`An encoding '${this.encoding}' is not yet supported.`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=ProcessFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessFile.js","sourceRoot":"","sources":["../../../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AED;;OAEG;IACH,MAAM;QACJ,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO,IAAI,CAAC,QAAQ,CAAA;SACrB;QACD,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;YAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACvC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,WAAW,CAAC,kCAAkC,IAAI,IAAI,CAAC,CAAA;aAClE;YACD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAA;YAC7D,OAAO,IAAI,CAAC,QAAQ,CAAA;SACrB;QAED,IAAI,IAAI,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC7B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAChC,OAAO,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAA;SAC3B;QAED,MAAM,IAAI,WAAW,CAAC,gBAAgB,IAAI,CAAC,QAAQ,yBAAyB,CAAC,CAAA;IAC/E,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ProcessFile } from './ProcessFile';
|
|
2
|
+
import { ProcessingSystem } from './ProcessingSystem';
|
|
3
|
+
import { Process } from './Process';
|
|
4
|
+
import { Directions, ImportAction, ImportState, ProcessConfig } from '@dataplug/tasenor-common';
|
|
5
|
+
/**
|
|
6
|
+
* A handler taking care of moving between process states.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ProcessHandler {
|
|
9
|
+
system: ProcessingSystem;
|
|
10
|
+
name: string;
|
|
11
|
+
constructor(name: string);
|
|
12
|
+
/**
|
|
13
|
+
* Attach this handler to the processing system during the registration.
|
|
14
|
+
* @param system
|
|
15
|
+
*/
|
|
16
|
+
connect(system: ProcessingSystem): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check if we are able to handle the given file.
|
|
19
|
+
* @param file
|
|
20
|
+
*/
|
|
21
|
+
canHandle(file: ProcessFile): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if we are able to append the given file to the process.
|
|
24
|
+
* @param file
|
|
25
|
+
*/
|
|
26
|
+
canAppend(file: ProcessFile): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if the state is either successful `true` or failed `false` or not yet complete `undefined`.
|
|
29
|
+
* @param state
|
|
30
|
+
*/
|
|
31
|
+
checkCompletion(state: ImportState): boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Execute an action to the state in order to produce new state. Note that state is cloned and can be modified to be new state.
|
|
34
|
+
* @param action
|
|
35
|
+
* @param state
|
|
36
|
+
* @param files
|
|
37
|
+
*/
|
|
38
|
+
action(process: Process, action: ImportAction, state: ImportState, files: ProcessFile[]): Promise<ImportState>;
|
|
39
|
+
/**
|
|
40
|
+
* Construct intial state from the given data.
|
|
41
|
+
* @param file
|
|
42
|
+
*/
|
|
43
|
+
startingState(files: ProcessFile[]): ImportState;
|
|
44
|
+
/**
|
|
45
|
+
* Figure out possible directions from the given state.
|
|
46
|
+
* @param state
|
|
47
|
+
*/
|
|
48
|
+
getDirections(state: ImportState, config: ProcessConfig): Promise<Directions>;
|
|
49
|
+
/**
|
|
50
|
+
* See if it is possible rollback a process.
|
|
51
|
+
* @param step
|
|
52
|
+
*/
|
|
53
|
+
rollback(process: Process, state: ImportState): Promise<ImportState>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A collection of process handlers.
|
|
57
|
+
*/
|
|
58
|
+
export type ProcessHandlerMap = {
|
|
59
|
+
[key: string]: ProcessHandler;
|
|
60
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { NotImplemented } from '../error';
|
|
2
|
+
/**
|
|
3
|
+
* A handler taking care of moving between process states.
|
|
4
|
+
*/
|
|
5
|
+
export class ProcessHandler {
|
|
6
|
+
system;
|
|
7
|
+
name;
|
|
8
|
+
constructor(name) {
|
|
9
|
+
this.name = name;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Attach this handler to the processing system during the registration.
|
|
13
|
+
* @param system
|
|
14
|
+
*/
|
|
15
|
+
connect(system) {
|
|
16
|
+
this.system = system;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Check if we are able to handle the given file.
|
|
20
|
+
* @param file
|
|
21
|
+
*/
|
|
22
|
+
canHandle(file) {
|
|
23
|
+
throw new NotImplemented(`A handler '${this.name}' cannot check file '${file.name}', since canHandle() is not implemented.`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check if we are able to append the given file to the process.
|
|
27
|
+
* @param file
|
|
28
|
+
*/
|
|
29
|
+
canAppend(file) {
|
|
30
|
+
throw new NotImplemented(`A handler '${this.name}' cannot append file '${file.name}', since canAppend() is not implemented.`);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Check if the state is either successful `true` or failed `false` or not yet complete `undefined`.
|
|
34
|
+
* @param state
|
|
35
|
+
*/
|
|
36
|
+
checkCompletion(state) {
|
|
37
|
+
throw new NotImplemented(`A handler '${this.name}' cannot check state '${JSON.stringify(state)}', since checkCompletion() is not implemented.`);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute an action to the state in order to produce new state. Note that state is cloned and can be modified to be new state.
|
|
41
|
+
* @param action
|
|
42
|
+
* @param state
|
|
43
|
+
* @param files
|
|
44
|
+
*/
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
+
async action(process, action, state, files) {
|
|
47
|
+
throw new NotImplemented(`A handler '${this.name}' for files ${files.map(f => `'${f}''`).join(', ')} does not implement action()`);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Construct intial state from the given data.
|
|
51
|
+
* @param file
|
|
52
|
+
*/
|
|
53
|
+
startingState(files) {
|
|
54
|
+
throw new NotImplemented(`A handler '${this.name}' for file ${files.map(f => `'${f}''`).join(', ')} does not implement startingState()`);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Figure out possible directions from the given state.
|
|
58
|
+
* @param state
|
|
59
|
+
*/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
+
async getDirections(state, config) {
|
|
62
|
+
throw new NotImplemented(`A handler '${this.name}' for state '${JSON.stringify(state)}' does not implement getDirections()`);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* See if it is possible rollback a process.
|
|
66
|
+
* @param step
|
|
67
|
+
*/
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
69
|
+
async rollback(process, state) {
|
|
70
|
+
throw new NotImplemented(`A handler '${this.name}' does not implement rollback()`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=ProcessHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessHandler.js","sourceRoot":"","sources":["../../../../src/process/ProcessHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGzC;;GAEG;AACH,MAAM,OAAO,cAAc;IAEzB,MAAM,CAAkB;IACxB,IAAI,CAAQ;IAEZ,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,OAAO,CAAC,MAAwB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,IAAiB;QACzB,MAAM,IAAI,cAAc,CAAC,cAAc,IAAI,CAAC,IAAI,wBAAwB,IAAI,CAAC,IAAI,0CAA0C,CAAC,CAAA;IAC9H,CAAC;IAED;;;OAGG;IACH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@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Process } from './Process';
|
|
2
|
+
import { KnexDatabase } from '../database';
|
|
3
|
+
import { ID, Directions, ImportAction, ImportState } from '@dataplug/tasenor-common';
|
|
4
|
+
/**
|
|
5
|
+
* A basic information of the processing step.
|
|
6
|
+
*/
|
|
7
|
+
export interface ProcessStepData {
|
|
8
|
+
processId?: ID;
|
|
9
|
+
number: number;
|
|
10
|
+
state: ImportState;
|
|
11
|
+
handler: string;
|
|
12
|
+
action?: ImportAction;
|
|
13
|
+
directions?: Directions;
|
|
14
|
+
started?: Date;
|
|
15
|
+
finished?: Date;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Data of the one step in the process including possible directions and action taken to the next step, if any.
|
|
19
|
+
*/
|
|
20
|
+
export declare class ProcessStep {
|
|
21
|
+
process: Process;
|
|
22
|
+
id: ID;
|
|
23
|
+
processId: ID;
|
|
24
|
+
number: number;
|
|
25
|
+
state: ImportState;
|
|
26
|
+
handler: string;
|
|
27
|
+
started: Date | undefined;
|
|
28
|
+
finished: Date | undefined;
|
|
29
|
+
directions?: Directions;
|
|
30
|
+
action?: ImportAction | undefined;
|
|
31
|
+
constructor(obj: ProcessStepData);
|
|
32
|
+
toString(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get a reference to the database.
|
|
35
|
+
*/
|
|
36
|
+
get db(): KnexDatabase;
|
|
37
|
+
/**
|
|
38
|
+
* Save the process info to the database.
|
|
39
|
+
*/
|
|
40
|
+
save(): Promise<ID>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the loaded process information as JSON object.
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
toJSON(): ProcessStepData;
|
|
46
|
+
/**
|
|
47
|
+
* Set directions and update database.
|
|
48
|
+
* @param db
|
|
49
|
+
* @param directions
|
|
50
|
+
*/
|
|
51
|
+
setDirections(db: KnexDatabase, directions: Directions): Promise<void>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { DatabaseError } from '../error';
|
|
2
|
+
import { Directions } from '@dataplug/tasenor-common';
|
|
3
|
+
/**
|
|
4
|
+
* Data of the one step in the process including possible directions and action taken to the next step, if any.
|
|
5
|
+
*/
|
|
6
|
+
export class ProcessStep {
|
|
7
|
+
process;
|
|
8
|
+
id;
|
|
9
|
+
processId;
|
|
10
|
+
number;
|
|
11
|
+
state;
|
|
12
|
+
handler;
|
|
13
|
+
started;
|
|
14
|
+
finished;
|
|
15
|
+
directions;
|
|
16
|
+
action;
|
|
17
|
+
constructor(obj) {
|
|
18
|
+
this.processId = obj.processId || null;
|
|
19
|
+
this.number = obj.number;
|
|
20
|
+
this.state = obj.state;
|
|
21
|
+
this.handler = obj.handler;
|
|
22
|
+
this.directions = obj.directions ? new Directions(obj.directions) : undefined;
|
|
23
|
+
this.action = obj.action;
|
|
24
|
+
this.started = obj.started;
|
|
25
|
+
this.finished = obj.finished;
|
|
26
|
+
}
|
|
27
|
+
toString() {
|
|
28
|
+
return `ProcessStep ${this.number} of Process #${this.processId}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get a reference to the database.
|
|
32
|
+
*/
|
|
33
|
+
get db() {
|
|
34
|
+
return this.process.db;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Save the process info to the database.
|
|
38
|
+
*/
|
|
39
|
+
async save() {
|
|
40
|
+
if (this.id) {
|
|
41
|
+
await this.db('process_steps').update(this.toJSON()).where({ id: this.id });
|
|
42
|
+
return this.id;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.started = new Date();
|
|
46
|
+
this.id = (await this.db('process_steps').insert(this.toJSON()).returning('id'))[0].id;
|
|
47
|
+
if (this.id)
|
|
48
|
+
return this.id;
|
|
49
|
+
throw new DatabaseError(`Saving process ${JSON.stringify(this.toJSON)} failed.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the loaded process information as JSON object.
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
toJSON() {
|
|
57
|
+
return {
|
|
58
|
+
processId: this.processId,
|
|
59
|
+
number: this.number,
|
|
60
|
+
state: this.state,
|
|
61
|
+
directions: this.directions,
|
|
62
|
+
handler: this.handler,
|
|
63
|
+
action: this.action,
|
|
64
|
+
started: this.started,
|
|
65
|
+
finished: this.finished
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Set directions and update database.
|
|
70
|
+
* @param db
|
|
71
|
+
* @param directions
|
|
72
|
+
*/
|
|
73
|
+
async setDirections(db, directions) {
|
|
74
|
+
this.directions = directions;
|
|
75
|
+
await db('process_steps').update({ directions: directions.toJSON() }).where({ id: this.id });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=ProcessStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessStep.js","sourceRoot":"","sources":["../../../../src/process/ProcessStep.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAM,UAAU,EAA6B,MAAM,0BAA0B,CAAA;AAgBpF;;GAEG;AACH,MAAM,OAAO,WAAW;IAEtB,OAAO,CAAS;IAEhB,EAAE,CAAI;IACN,SAAS,CAAI;IACb,MAAM,CAAQ;IACd,KAAK,CAAa;IAClB,OAAO,CAAQ;IACf,OAAO,CAAkB;IACzB,QAAQ,CAAkB;IAC1B,UAAU,CAAa;IACvB,MAAM,CAA2B;IAEjC,YAAY,GAAoB;QAC9B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,IAAI,IAAI,CAAA;QACtC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,CAAA;QAC1B,IAAI,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;IACH,MAAM;QACJ,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,aAAa,CAAC,EAAgB,EAAE,UAAsB;QAC1D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,MAAM,EAAE,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;IAC9F,CAAC;CACF"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Process } from './Process';
|
|
2
|
+
import { ProcessFileData } from './ProcessFile';
|
|
3
|
+
import { ProcessStep } from './ProcessStep';
|
|
4
|
+
import { ProcessHandler, ProcessHandlerMap } from './ProcessHandler';
|
|
5
|
+
import { ProcessConnector } from './ProcessConnector';
|
|
6
|
+
import { ProcessName, ProcessConfig, ID } from '@dataplug/tasenor-common';
|
|
7
|
+
import { KnexDatabase } from '../database';
|
|
8
|
+
/**
|
|
9
|
+
* An instance of the full processing system.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ProcessingSystem {
|
|
12
|
+
db: KnexDatabase;
|
|
13
|
+
handlers: ProcessHandlerMap;
|
|
14
|
+
connector: ProcessConnector;
|
|
15
|
+
logger: {
|
|
16
|
+
info: (...msg: any[]) => void;
|
|
17
|
+
error: (...msg: any[]) => void;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the system and set the database instance for storing process data.
|
|
21
|
+
* @param db
|
|
22
|
+
*/
|
|
23
|
+
constructor(db: KnexDatabase, connector: ProcessConnector);
|
|
24
|
+
/**
|
|
25
|
+
* Get the translation from the connector.
|
|
26
|
+
* @param language
|
|
27
|
+
* @param text
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
getTranslation(text: string, language: string): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Register new handler class for processing.
|
|
33
|
+
* @param handler
|
|
34
|
+
*/
|
|
35
|
+
register(handler: ProcessHandler): void;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize new process and save it to the database.
|
|
38
|
+
* @param type
|
|
39
|
+
* @param name
|
|
40
|
+
* @param file
|
|
41
|
+
* @returns New process that is already in crashed state, if no handler
|
|
42
|
+
*/
|
|
43
|
+
createProcess(name: ProcessName, files: ProcessFileData[], config: ProcessConfig): Promise<Process>;
|
|
44
|
+
/**
|
|
45
|
+
* Check if we are in the finished state and if not, find the directions forward.
|
|
46
|
+
*/
|
|
47
|
+
checkFinishAndFindDirections(handler: ProcessHandler, step: ProcessStep): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get the named handler or throw an error if not registered.
|
|
50
|
+
* @param name
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
getHandler(name: string): ProcessHandler;
|
|
54
|
+
/**
|
|
55
|
+
* Load the process data from the disk.
|
|
56
|
+
* @param id
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
loadProcess(id: ID): Promise<Process>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Process } from './Process';
|
|
2
|
+
import { ProcessFile } from './ProcessFile';
|
|
3
|
+
import { ProcessStep } from './ProcessStep';
|
|
4
|
+
import { InvalidArgument } from '../error';
|
|
5
|
+
/**
|
|
6
|
+
* An instance of the full processing system.
|
|
7
|
+
*/
|
|
8
|
+
export class ProcessingSystem {
|
|
9
|
+
db;
|
|
10
|
+
handlers = {};
|
|
11
|
+
connector;
|
|
12
|
+
logger;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the system and set the database instance for storing process data.
|
|
15
|
+
* @param db
|
|
16
|
+
*/
|
|
17
|
+
constructor(db, connector) {
|
|
18
|
+
this.db = db;
|
|
19
|
+
this.logger = {
|
|
20
|
+
info: (...msg) => console.log(new Date(), ...msg),
|
|
21
|
+
error: (...msg) => console.error(new Date(), ...msg)
|
|
22
|
+
};
|
|
23
|
+
this.connector = connector;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the translation from the connector.
|
|
27
|
+
* @param language
|
|
28
|
+
* @param text
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
async getTranslation(text, language) {
|
|
32
|
+
return this.connector.getTranslation(text, language);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Register new handler class for processing.
|
|
36
|
+
* @param handler
|
|
37
|
+
*/
|
|
38
|
+
register(handler) {
|
|
39
|
+
if (!handler) {
|
|
40
|
+
throw new InvalidArgument('A handler was undefined.');
|
|
41
|
+
}
|
|
42
|
+
if (!handler.name) {
|
|
43
|
+
throw new InvalidArgument('A handler without name cannot be registered.');
|
|
44
|
+
}
|
|
45
|
+
if (handler.name in this.handlers) {
|
|
46
|
+
throw new InvalidArgument(`The handler '${handler.name}' is already defined.`);
|
|
47
|
+
}
|
|
48
|
+
if (handler.name.length > 32) {
|
|
49
|
+
throw new InvalidArgument(`The handler name '${handler.name}' is too long.`);
|
|
50
|
+
}
|
|
51
|
+
handler.system = this;
|
|
52
|
+
this.handlers[handler.name] = handler;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Initialize new process and save it to the database.
|
|
56
|
+
* @param type
|
|
57
|
+
* @param name
|
|
58
|
+
* @param file
|
|
59
|
+
* @returns New process that is already in crashed state, if no handler
|
|
60
|
+
*/
|
|
61
|
+
async createProcess(name, files, config) {
|
|
62
|
+
// Set up the process.
|
|
63
|
+
const process = new Process(this, name, config);
|
|
64
|
+
await process.save();
|
|
65
|
+
// Check if we have files.
|
|
66
|
+
if (files.length < 1) {
|
|
67
|
+
await process.crashed(new InvalidArgument('No files given to create a process.'));
|
|
68
|
+
return process;
|
|
69
|
+
}
|
|
70
|
+
// Save the first file and attach it to the process.
|
|
71
|
+
const file = files[0];
|
|
72
|
+
const processFile = new ProcessFile(file);
|
|
73
|
+
process.addFile(processFile);
|
|
74
|
+
await processFile.save(this.db);
|
|
75
|
+
// Find the handler.
|
|
76
|
+
let selectedHandler = null;
|
|
77
|
+
for (const handler of Object.values(this.handlers)) {
|
|
78
|
+
try {
|
|
79
|
+
if (handler.canHandle(processFile)) {
|
|
80
|
+
selectedHandler = handler;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
await process.crashed(err);
|
|
86
|
+
return process;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!selectedHandler) {
|
|
90
|
+
await process.crashed(new InvalidArgument(`No handler found for the file ${file.name} of type ${file.type}.`));
|
|
91
|
+
return process;
|
|
92
|
+
}
|
|
93
|
+
// Check if the handler accepts the rest of the files.
|
|
94
|
+
for (let i = 1; i < files.length; i++) {
|
|
95
|
+
const processFile = new ProcessFile(files[i]);
|
|
96
|
+
// await processFile.save(this.db)
|
|
97
|
+
if (!selectedHandler.canAppend(processFile)) {
|
|
98
|
+
await process.crashed(new InvalidArgument(`The file ${files[i].name} of type ${files[i].type} cannot be appended to handler.`));
|
|
99
|
+
return process;
|
|
100
|
+
}
|
|
101
|
+
process.addFile(processFile);
|
|
102
|
+
await processFile.save(this.db);
|
|
103
|
+
}
|
|
104
|
+
// Create initial step using the handler.
|
|
105
|
+
let state;
|
|
106
|
+
try {
|
|
107
|
+
state = selectedHandler.startingState(process.files);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
await process.crashed(err);
|
|
111
|
+
return process;
|
|
112
|
+
}
|
|
113
|
+
const step = new ProcessStep({
|
|
114
|
+
number: 0,
|
|
115
|
+
handler: selectedHandler.name,
|
|
116
|
+
state
|
|
117
|
+
});
|
|
118
|
+
process.addStep(step);
|
|
119
|
+
await step.save();
|
|
120
|
+
process.currentStep = 0;
|
|
121
|
+
await process.save();
|
|
122
|
+
this.logger.info(`Created process ${process}.`);
|
|
123
|
+
// Find directions forward from the initial state.
|
|
124
|
+
await this.checkFinishAndFindDirections(selectedHandler, step);
|
|
125
|
+
return process;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Check if we are in the finished state and if not, find the directions forward.
|
|
129
|
+
*/
|
|
130
|
+
async checkFinishAndFindDirections(handler, step) {
|
|
131
|
+
let result;
|
|
132
|
+
try {
|
|
133
|
+
result = handler.checkCompletion(step.state);
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
return step.process.crashed(err);
|
|
137
|
+
}
|
|
138
|
+
if (result === undefined) {
|
|
139
|
+
let directions;
|
|
140
|
+
try {
|
|
141
|
+
directions = await handler.getDirections(step.state, step.process.config);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return step.process.crashed(err);
|
|
145
|
+
}
|
|
146
|
+
await step.setDirections(this.db, directions);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
// Process is finished.
|
|
150
|
+
step.directions = undefined;
|
|
151
|
+
step.action = undefined;
|
|
152
|
+
step.finished = new Date();
|
|
153
|
+
await step.save();
|
|
154
|
+
step.process.complete = true;
|
|
155
|
+
step.process.successful = result;
|
|
156
|
+
await step.process.save();
|
|
157
|
+
}
|
|
158
|
+
await step.process.updateStatus();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get the named handler or throw an error if not registered.
|
|
162
|
+
* @param name
|
|
163
|
+
* @returns
|
|
164
|
+
*/
|
|
165
|
+
getHandler(name) {
|
|
166
|
+
if (!(name in this.handlers)) {
|
|
167
|
+
throw new InvalidArgument(`There is no handler for '${name}'.`);
|
|
168
|
+
}
|
|
169
|
+
return this.handlers[name];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Load the process data from the disk.
|
|
173
|
+
* @param id
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
async loadProcess(id) {
|
|
177
|
+
const process = new Process(this, null);
|
|
178
|
+
await process.load(id);
|
|
179
|
+
return process;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=ProcessingSystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcessingSystem.js","sourceRoot":"","sources":["../../../../src/process/ProcessingSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAmB,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG1C;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAE3B,EAAE,CAAc;IAChB,QAAQ,GAAsB,EAAE,CAAA;IAChC,SAAS,CAAkB;IAC3B,MAAM,CAGL;IAED;;;OAGG;IACH,YAAY,EAAgB,EAAE,SAA2B;QACvD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,GAAG,CAAC;YACjD,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,GAAG,CAAC;SACrD,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAA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