@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,44 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
import { KnexDatabase } from '../database'
|
|
3
|
+
import { BackendPlugin } from './BackendPlugin'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A generic tool.
|
|
7
|
+
*/
|
|
8
|
+
export class ToolPlugin extends BackendPlugin {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handler for GET request.
|
|
12
|
+
*/
|
|
13
|
+
async GET(db: KnexDatabase, query): Promise<unknown> {
|
|
14
|
+
return undefined
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Handler for DELETE request.
|
|
19
|
+
*/
|
|
20
|
+
async DELETE(db: KnexDatabase, query): Promise<unknown> {
|
|
21
|
+
return undefined
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Handler for POST request.
|
|
26
|
+
*/
|
|
27
|
+
async POST(db: KnexDatabase, data): Promise<unknown> {
|
|
28
|
+
return undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Handler for PUT request.
|
|
33
|
+
*/
|
|
34
|
+
async PUT(db: KnexDatabase, data): Promise<unknown> {
|
|
35
|
+
return undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Handler for PATCH request.
|
|
40
|
+
*/
|
|
41
|
+
async PATCH(db: KnexDatabase, data): Promise<unknown> {
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin base classes for backend and utility functions.
|
|
3
|
+
*
|
|
4
|
+
* @module tasenor-common-node/src/plugins
|
|
5
|
+
*/
|
|
6
|
+
export * from './BackendPlugin'
|
|
7
|
+
export * from './DataPlugin'
|
|
8
|
+
export * from './ImportPlugin'
|
|
9
|
+
export * from './ReportPlugin'
|
|
10
|
+
export * from './SchemePlugin'
|
|
11
|
+
export * from './ServicePlugin'
|
|
12
|
+
export * from './ToolPlugin'
|
|
13
|
+
export * from './plugins'
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import glob from 'fast-glob'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import { TasenorPlugin, PluginCatalog, FilePath, net, Url, note, log } from '@dataplug/tasenor-common'
|
|
5
|
+
import { create } from 'ts-opaque'
|
|
6
|
+
import { vault } from '../net'
|
|
7
|
+
|
|
8
|
+
const PLUGIN_FIELDS = ['code', 'title', 'version', 'icon', 'releaseDate', 'use', 'type', 'description']
|
|
9
|
+
|
|
10
|
+
interface PluginConfig {
|
|
11
|
+
PLUGIN_PATH?: string
|
|
12
|
+
}
|
|
13
|
+
type ConfigVariable = keyof PluginConfig
|
|
14
|
+
|
|
15
|
+
// Internal configuration for the module.
|
|
16
|
+
const config: PluginConfig = {
|
|
17
|
+
PLUGIN_PATH: undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface PluginState {
|
|
21
|
+
installed: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Get the configuration variable or throw an error.
|
|
26
|
+
* @param variable Name of the variable.
|
|
27
|
+
*/
|
|
28
|
+
function getConfig(variable: ConfigVariable): string {
|
|
29
|
+
const value = config[variable]
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
throw new Error(`Configuration variable ${variable} is required but it is not set.`)
|
|
32
|
+
}
|
|
33
|
+
return value
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Set the configuration variable. When setting the root for plugins other directories are set automatically.
|
|
38
|
+
* @param variable Name of the variable.
|
|
39
|
+
* @param value Value of the variable.
|
|
40
|
+
*/
|
|
41
|
+
function setConfig(variable: ConfigVariable, value: string): void {
|
|
42
|
+
if (variable in config) {
|
|
43
|
+
config[variable] = value
|
|
44
|
+
} else {
|
|
45
|
+
throw new Error(`No such configuration variable as ${variable}.`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Sort list of plugins according to the code.
|
|
51
|
+
* @param plugins A list of plugins.
|
|
52
|
+
* @returns New sorted list.
|
|
53
|
+
*/
|
|
54
|
+
function sortPlugins(plugins: TasenorPlugin[]): TasenorPlugin[] {
|
|
55
|
+
return plugins.sort((a, b) => a.code < b.code ? -1 : (a.code > b.code ? 1 : 0))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Compare two plugin lists if they are essentially the same.
|
|
60
|
+
* @param listA
|
|
61
|
+
* @param listB
|
|
62
|
+
* @returns True if code, versions and path match.
|
|
63
|
+
*/
|
|
64
|
+
function samePlugins(listA: TasenorPlugin[], listB: TasenorPlugin[]): boolean {
|
|
65
|
+
if (listA.length !== listB.length) {
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
68
|
+
listA = sortPlugins(listA)
|
|
69
|
+
listB = sortPlugins(listB)
|
|
70
|
+
for (let i = 0; i < listA.length; i++) {
|
|
71
|
+
if (listA[i].id !== listB[i].id ||
|
|
72
|
+
listA[i].code !== listB[i].code ||
|
|
73
|
+
listA[i].installedVersion !== listB[i].installedVersion ||
|
|
74
|
+
listA[i].path !== listB[i].path
|
|
75
|
+
) {
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Read in the current `index.json` file.
|
|
84
|
+
*/
|
|
85
|
+
function loadPluginIndex(): PluginCatalog {
|
|
86
|
+
const indexPath = path.join(getConfig('PLUGIN_PATH'), 'index.json')
|
|
87
|
+
note(`Loading plugin index from '${indexPath}'.`)
|
|
88
|
+
if (fs.existsSync(indexPath)) {
|
|
89
|
+
return JSON.parse(fs.readFileSync(indexPath).toString('utf-8'))
|
|
90
|
+
}
|
|
91
|
+
return []
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Store plugin index.
|
|
96
|
+
* @param plugins
|
|
97
|
+
*/
|
|
98
|
+
function savePluginIndex(plugins) {
|
|
99
|
+
plugins = sortPlugins(plugins)
|
|
100
|
+
const indexPath = path.join(getConfig('PLUGIN_PATH'), 'index.json')
|
|
101
|
+
note(`Saving plugin index to '${indexPath}'.`)
|
|
102
|
+
fs.writeFileSync(indexPath, JSON.stringify(plugins, null, 2) + '\n')
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Update one plugin in the index.
|
|
107
|
+
*/
|
|
108
|
+
function updatePluginIndex(plugin: TasenorPlugin, plugins: TasenorPlugin[] | undefined = undefined) {
|
|
109
|
+
const old = findPluginFromIndex(plugin.code, plugins)
|
|
110
|
+
if (!old) {
|
|
111
|
+
throw new Error(`Cannot update non-existing plugin ${plugin.code}.`)
|
|
112
|
+
}
|
|
113
|
+
Object.assign(old, plugin)
|
|
114
|
+
savePluginIndex(plugins)
|
|
115
|
+
|
|
116
|
+
return plugins
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Find the named plugin from the current `index.json` file or from the list if given..
|
|
121
|
+
* @param {String} code
|
|
122
|
+
* @returns Data or null if not found.
|
|
123
|
+
*/
|
|
124
|
+
function findPluginFromIndex(code: string, plugins: TasenorPlugin[] | undefined = undefined): TasenorPlugin | null {
|
|
125
|
+
const index = plugins || loadPluginIndex()
|
|
126
|
+
const plugin = index.find(plugin => plugin.code === code)
|
|
127
|
+
return plugin || null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get the current plugin list maintained by some master API.
|
|
132
|
+
* @returns The latest list.
|
|
133
|
+
*/
|
|
134
|
+
async function fetchOfficialPluginList(): Promise<TasenorPlugin[]> {
|
|
135
|
+
const url = vault.get('TASENOR_API_URL', '')
|
|
136
|
+
if (url) {
|
|
137
|
+
const plugins = await net.GET(`${url}/plugins` as Url)
|
|
138
|
+
if (plugins.success) {
|
|
139
|
+
return plugins.data as unknown as TasenorPlugin[]
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return []
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Scan all plugins from the plugin directory based on index files found.
|
|
147
|
+
*/
|
|
148
|
+
function scanPlugins(): TasenorPlugin[] {
|
|
149
|
+
const rootPath = path.resolve(getConfig('PLUGIN_PATH'))
|
|
150
|
+
log(`Scanning plugins from ${rootPath}.`)
|
|
151
|
+
let uiFiles: FilePath[] = []
|
|
152
|
+
let backendFiles: FilePath[] = []
|
|
153
|
+
|
|
154
|
+
// Scan each dir resolving symlinks first.
|
|
155
|
+
const dirs = glob.sync(path.join(rootPath, '**', 'package.json'))
|
|
156
|
+
|
|
157
|
+
dirs.map(dir => path.dirname(fs.realpathSync(dir))).forEach(dir => {
|
|
158
|
+
uiFiles = uiFiles.concat(
|
|
159
|
+
glob.sync(path.join(dir, '**', 'ui', 'index.tsx')).map(
|
|
160
|
+
p => p.substring(0, p.length - 'ui/index.tsx'.length) as FilePath
|
|
161
|
+
)
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
backendFiles = backendFiles.concat(
|
|
165
|
+
glob.sync(path.join(dir, '**', 'backend', 'index.ts')).map(
|
|
166
|
+
p => p.substring(0, p.length - 'backend/index.ts'.length) as FilePath
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
const pluginSet = new Set<FilePath>(uiFiles.concat(backendFiles))
|
|
172
|
+
|
|
173
|
+
return [...pluginSet].map(scanPlugin)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Read data from the plugin's index file(s) found from the given path.
|
|
178
|
+
*/
|
|
179
|
+
function scanPlugin(pluginPath: FilePath): TasenorPlugin {
|
|
180
|
+
const uiPath: FilePath = path.join(pluginPath, 'ui', 'index.tsx') as FilePath
|
|
181
|
+
const ui = fs.existsSync(uiPath) ? readUIPlugin(uiPath) : null
|
|
182
|
+
const backendPath: FilePath = path.join(pluginPath, 'backend', 'index.ts') as FilePath
|
|
183
|
+
const backend = fs.existsSync(backendPath) ? readBackendPlugin(backendPath) : null
|
|
184
|
+
if (ui && backend) {
|
|
185
|
+
for (const field of PLUGIN_FIELDS) {
|
|
186
|
+
if (ui[field] !== backend[field]) {
|
|
187
|
+
throw new Error(`A field '${field}' have contradicting values ${JSON.stringify(ui[field])} and ${JSON.stringify(backend[field])} for index files '${uiPath}' and '${backendPath}'.`)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (ui === null && backend === null) {
|
|
192
|
+
throw new Error(`Cannot find any plugins in '${pluginPath}'.`)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return ui || backend as TasenorPlugin
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Read UI plugin data from the given index file.
|
|
200
|
+
*/
|
|
201
|
+
function readUIPlugin(indexPath: FilePath): TasenorPlugin {
|
|
202
|
+
const regex = new RegExp(`^\\s*static\\s+(${PLUGIN_FIELDS.join('|')})\\s*=\\s*(?:'([^']*)'|"([^"]*)")`)
|
|
203
|
+
|
|
204
|
+
const data: TasenorPlugin = {
|
|
205
|
+
code: create('Unknown'),
|
|
206
|
+
title: 'Unknown Development Plugin',
|
|
207
|
+
icon: 'HelpOutline',
|
|
208
|
+
path: path.dirname(path.dirname(indexPath)),
|
|
209
|
+
version: create('0'),
|
|
210
|
+
releaseDate: null,
|
|
211
|
+
use: 'unknown',
|
|
212
|
+
type: 'unknown',
|
|
213
|
+
description: 'No description'
|
|
214
|
+
}
|
|
215
|
+
const code = fs.readFileSync(indexPath).toString('utf-8').split('\n')
|
|
216
|
+
for (const line of code) {
|
|
217
|
+
const match = regex.exec(line)
|
|
218
|
+
if (match) {
|
|
219
|
+
data[match[1]] = match[2]
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return data
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function readBackendPlugin(indexPath: FilePath): TasenorPlugin {
|
|
227
|
+
const regex = new RegExp(`^\\s*this\\.(${PLUGIN_FIELDS.join('|')})\\s*=\\s*(?:'([^']*)'|"([^"]*)")`)
|
|
228
|
+
|
|
229
|
+
const data: TasenorPlugin = {
|
|
230
|
+
code: create('Unknown'),
|
|
231
|
+
title: 'Unknown Development Plugin',
|
|
232
|
+
icon: 'HelpOutline',
|
|
233
|
+
path: path.dirname(path.dirname(indexPath)),
|
|
234
|
+
version: create('0'),
|
|
235
|
+
releaseDate: null,
|
|
236
|
+
use: 'unknown',
|
|
237
|
+
type: 'unknown',
|
|
238
|
+
description: 'No description'
|
|
239
|
+
}
|
|
240
|
+
const code = fs.readFileSync(indexPath).toString('utf-8').split('\n')
|
|
241
|
+
for (const line of code) {
|
|
242
|
+
const match = regex.exec(line)
|
|
243
|
+
if (match) {
|
|
244
|
+
data[match[1]] = match[2]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return data
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Read the local plugin state.
|
|
253
|
+
*/
|
|
254
|
+
function loadPluginState(plugin: TasenorPlugin): PluginState {
|
|
255
|
+
const stateFile = plugin.path && path.join(plugin.path, '.state')
|
|
256
|
+
if (stateFile && fs.existsSync(stateFile)) {
|
|
257
|
+
return JSON.parse(fs.readFileSync(stateFile).toString('utf-8'))
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
installed: false
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Save local plugin state.
|
|
266
|
+
*/
|
|
267
|
+
function savePluginState(plugin: TasenorPlugin, state: PluginState): void {
|
|
268
|
+
const stateFile = path.join(plugin.path, '.state')
|
|
269
|
+
fs.writeFileSync(stateFile, JSON.stringify(state, null, 2) + '\n')
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Check if plugin is marked as installed.
|
|
274
|
+
*/
|
|
275
|
+
function isInstalled(plugin: TasenorPlugin): boolean {
|
|
276
|
+
return loadPluginState(plugin).installed
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Combine official and installed plugins to the same list and save if changed.
|
|
281
|
+
*/
|
|
282
|
+
async function updatePluginList() {
|
|
283
|
+
let current: TasenorPlugin[] = []
|
|
284
|
+
|
|
285
|
+
// Get the official list if any.
|
|
286
|
+
for (const plugin of await fetchOfficialPluginList()) {
|
|
287
|
+
current[plugin.code] = plugin
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Collect and add local plugins.
|
|
291
|
+
let localId = -1
|
|
292
|
+
|
|
293
|
+
for (const plugin of await scanPlugins()) {
|
|
294
|
+
if (!current[plugin.code]) {
|
|
295
|
+
current[plugin.code] = plugin
|
|
296
|
+
current[plugin.code].id = localId--
|
|
297
|
+
}
|
|
298
|
+
current[plugin.code].path = plugin.path
|
|
299
|
+
current[plugin.code].version = plugin.version
|
|
300
|
+
current[plugin.code].availableVersion = plugin.version
|
|
301
|
+
if (isInstalled(plugin)) {
|
|
302
|
+
current[plugin.code].installedVersion = plugin.version
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// Avoid dev server unnecessary restart.
|
|
307
|
+
const old = loadPluginIndex()
|
|
308
|
+
current = Object.values(current)
|
|
309
|
+
if (!samePlugins(old, current)) {
|
|
310
|
+
savePluginIndex(current)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return current
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Convert full path from UI or backend index file to relative path inside the plugin.
|
|
318
|
+
*/
|
|
319
|
+
function pluginLocalPath(indexFilePath: FilePath): string | undefined {
|
|
320
|
+
const match = /\/[^/]+\/(ui|backend)\/index.tsx?$/.exec(indexFilePath)
|
|
321
|
+
if (match) {
|
|
322
|
+
return match[0].substring(1)
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Collection of file system and API related plugin handling functions for fetching, building and scanning.
|
|
328
|
+
*/
|
|
329
|
+
export const plugins = {
|
|
330
|
+
findPluginFromIndex,
|
|
331
|
+
fetchOfficialPluginList,
|
|
332
|
+
getConfig,
|
|
333
|
+
isInstalled,
|
|
334
|
+
loadPluginIndex,
|
|
335
|
+
loadPluginState,
|
|
336
|
+
pluginLocalPath,
|
|
337
|
+
samePlugins,
|
|
338
|
+
savePluginIndex,
|
|
339
|
+
savePluginState,
|
|
340
|
+
scanPlugins,
|
|
341
|
+
setConfig,
|
|
342
|
+
sortPlugins,
|
|
343
|
+
updatePluginIndex,
|
|
344
|
+
updatePluginList
|
|
345
|
+
}
|