@tasenor/common-node 1.9.32 → 1.9.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/dist/migrations/01_init.js +60 -0
  2. package/dist/src/cli.d.ts +81 -0
  3. package/dist/src/cli.js +242 -0
  4. package/dist/src/cli.js.map +1 -0
  5. package/dist/src/commands/account.d.ts +12 -0
  6. package/dist/src/commands/account.js +58 -0
  7. package/dist/src/commands/account.js.map +1 -0
  8. package/dist/src/commands/balance.d.ts +11 -0
  9. package/dist/src/commands/balance.js +117 -0
  10. package/dist/src/commands/balance.js.map +1 -0
  11. package/dist/src/commands/db.d.ts +14 -0
  12. package/dist/src/commands/db.js +69 -0
  13. package/dist/src/commands/db.js.map +1 -0
  14. package/dist/src/commands/entry.d.ts +13 -0
  15. package/dist/src/commands/entry.js +106 -0
  16. package/dist/src/commands/entry.js.map +1 -0
  17. package/dist/src/commands/import.d.ts +17 -0
  18. package/dist/src/commands/import.js +140 -0
  19. package/dist/src/commands/import.js.map +1 -0
  20. package/dist/src/commands/importer.d.ts +13 -0
  21. package/dist/src/commands/importer.js +71 -0
  22. package/dist/src/commands/importer.js.map +1 -0
  23. package/dist/src/commands/index.d.ts +191 -0
  24. package/dist/src/commands/index.js +482 -0
  25. package/dist/src/commands/index.js.map +1 -0
  26. package/dist/src/commands/period.d.ts +12 -0
  27. package/dist/src/commands/period.js +48 -0
  28. package/dist/src/commands/period.js.map +1 -0
  29. package/dist/src/commands/plugin.d.ts +15 -0
  30. package/dist/src/commands/plugin.js +78 -0
  31. package/dist/src/commands/plugin.js.map +1 -0
  32. package/dist/src/commands/report.d.ts +11 -0
  33. package/dist/src/commands/report.js +96 -0
  34. package/dist/src/commands/report.js.map +1 -0
  35. package/dist/src/commands/settings.d.ts +10 -0
  36. package/dist/src/commands/settings.js +64 -0
  37. package/dist/src/commands/settings.js.map +1 -0
  38. package/dist/src/commands/stock.d.ts +8 -0
  39. package/dist/src/commands/stock.js +73 -0
  40. package/dist/src/commands/stock.js.map +1 -0
  41. package/dist/src/commands/tag.d.ts +13 -0
  42. package/dist/src/commands/tag.js +89 -0
  43. package/dist/src/commands/tag.js.map +1 -0
  44. package/dist/src/commands/tx.d.ts +12 -0
  45. package/dist/src/commands/tx.js +81 -0
  46. package/dist/src/commands/tx.js.map +1 -0
  47. package/dist/src/commands/user.d.ts +12 -0
  48. package/dist/src/commands/user.js +52 -0
  49. package/dist/src/commands/user.js.map +1 -0
  50. package/dist/src/database/BookkeeperImporter.d.ts +77 -0
  51. package/dist/src/database/BookkeeperImporter.js +343 -0
  52. package/dist/src/database/BookkeeperImporter.js.map +1 -0
  53. package/dist/src/database/DB.d.ts +51 -0
  54. package/dist/src/database/DB.js +354 -0
  55. package/dist/src/database/DB.js.map +1 -0
  56. package/dist/src/database/index.d.ts +7 -0
  57. package/dist/src/database/index.js +8 -0
  58. package/dist/src/database/index.js.map +1 -0
  59. package/dist/src/doccer.d.ts +29 -0
  60. package/dist/src/doccer.js +30 -0
  61. package/dist/src/doccer.js.map +1 -0
  62. package/dist/src/error.d.ts +30 -0
  63. package/dist/src/error.js +35 -0
  64. package/dist/src/error.js.map +1 -0
  65. package/dist/src/export/Exporter.d.ts +69 -0
  66. package/dist/src/export/Exporter.js +123 -0
  67. package/dist/src/export/Exporter.js.map +1 -0
  68. package/dist/src/export/TasenorExporter.d.ts +55 -0
  69. package/dist/src/export/TasenorExporter.js +135 -0
  70. package/dist/src/export/TasenorExporter.js.map +1 -0
  71. package/dist/src/export/TilitinExporter.d.ts +71 -0
  72. package/dist/src/export/TilitinExporter.js +290 -0
  73. package/dist/src/export/TilitinExporter.js.map +1 -0
  74. package/dist/src/export/index.d.ts +8 -0
  75. package/dist/src/export/index.js +9 -0
  76. package/dist/src/export/index.js.map +1 -0
  77. package/dist/src/import/TextFileProcessHandler.d.ts +104 -0
  78. package/dist/src/import/TextFileProcessHandler.js +354 -0
  79. package/dist/src/import/TextFileProcessHandler.js.map +1 -0
  80. package/dist/src/import/TransactionImportConnector.d.ts +38 -0
  81. package/dist/src/import/TransactionImportConnector.js +27 -0
  82. package/dist/src/import/TransactionImportConnector.js.map +1 -0
  83. package/dist/src/import/TransactionImportHandler.d.ts +174 -0
  84. package/dist/src/import/TransactionImportHandler.js +736 -0
  85. package/dist/src/import/TransactionImportHandler.js.map +1 -0
  86. package/dist/src/import/TransactionRules.d.ts +238 -0
  87. package/dist/src/import/TransactionRules.js +522 -0
  88. package/dist/src/import/TransactionRules.js.map +1 -0
  89. package/dist/src/import/TransactionUI.d.ts +181 -0
  90. package/dist/src/import/TransactionUI.js +482 -0
  91. package/dist/src/import/TransactionUI.js.map +1 -0
  92. package/dist/src/import/TransferAnalyzer.d.ts +324 -0
  93. package/dist/src/import/TransferAnalyzer.js +1379 -0
  94. package/dist/src/import/TransferAnalyzer.js.map +1 -0
  95. package/dist/src/import/index.d.ts +11 -0
  96. package/dist/src/import/index.js +12 -0
  97. package/dist/src/import/index.js.map +1 -0
  98. package/dist/src/index.d.ts +11 -0
  99. package/dist/src/index.js +12 -0
  100. package/dist/src/index.js.map +1 -0
  101. package/dist/src/net/crypto.d.ts +33 -0
  102. package/dist/src/net/crypto.js +63 -0
  103. package/dist/src/net/crypto.js.map +1 -0
  104. package/dist/src/net/git.d.ts +49 -0
  105. package/dist/src/net/git.js +137 -0
  106. package/dist/src/net/git.js.map +1 -0
  107. package/dist/src/net/index.d.ts +10 -0
  108. package/dist/src/net/index.js +11 -0
  109. package/dist/src/net/index.js.map +1 -0
  110. package/dist/src/net/middleware.d.ts +61 -0
  111. package/dist/src/net/middleware.js +220 -0
  112. package/dist/src/net/middleware.js.map +1 -0
  113. package/dist/src/net/tokens.d.ts +50 -0
  114. package/dist/src/net/tokens.js +141 -0
  115. package/dist/src/net/tokens.js.map +1 -0
  116. package/dist/src/net/vault.d.ts +67 -0
  117. package/dist/src/net/vault.js +145 -0
  118. package/dist/src/net/vault.js.map +1 -0
  119. package/dist/src/plugins/BackendPlugin.d.ts +91 -0
  120. package/dist/src/plugins/BackendPlugin.js +165 -0
  121. package/dist/src/plugins/BackendPlugin.js.map +1 -0
  122. package/dist/src/plugins/DataPlugin.d.ts +13 -0
  123. package/dist/src/plugins/DataPlugin.js +26 -0
  124. package/dist/src/plugins/DataPlugin.js.map +1 -0
  125. package/dist/src/plugins/ImportPlugin.d.ts +188 -0
  126. package/dist/src/plugins/ImportPlugin.js +204 -0
  127. package/dist/src/plugins/ImportPlugin.js.map +1 -0
  128. package/dist/src/plugins/ReportPlugin.d.ts +132 -0
  129. package/dist/src/plugins/ReportPlugin.js +393 -0
  130. package/dist/src/plugins/ReportPlugin.js.map +1 -0
  131. package/dist/src/plugins/SchemePlugin.d.ts +34 -0
  132. package/dist/src/plugins/SchemePlugin.js +47 -0
  133. package/dist/src/plugins/SchemePlugin.js.map +1 -0
  134. package/dist/src/plugins/ServicePlugin.d.ts +80 -0
  135. package/dist/src/plugins/ServicePlugin.js +168 -0
  136. package/dist/src/plugins/ServicePlugin.js.map +1 -0
  137. package/dist/src/plugins/ToolPlugin.d.ts +27 -0
  138. package/dist/src/plugins/ToolPlugin.js +37 -0
  139. package/dist/src/plugins/ToolPlugin.js.map +1 -0
  140. package/dist/src/plugins/index.d.ts +13 -0
  141. package/dist/src/plugins/index.js +14 -0
  142. package/dist/src/plugins/index.js.map +1 -0
  143. package/dist/src/plugins/plugins.d.ts +101 -0
  144. package/dist/src/plugins/plugins.js +292 -0
  145. package/dist/src/plugins/plugins.js.map +1 -0
  146. package/dist/src/process/Process.d.ts +108 -0
  147. package/dist/src/process/Process.js +335 -0
  148. package/dist/src/process/Process.js.map +1 -0
  149. package/dist/src/process/ProcessConnector.d.ts +24 -0
  150. package/dist/src/process/ProcessConnector.js +28 -0
  151. package/dist/src/process/ProcessConnector.js.map +1 -0
  152. package/dist/src/process/ProcessFile.d.ts +69 -0
  153. package/dist/src/process/ProcessFile.js +145 -0
  154. package/dist/src/process/ProcessFile.js.map +1 -0
  155. package/dist/src/process/ProcessHandler.d.ts +60 -0
  156. package/dist/src/process/ProcessHandler.js +73 -0
  157. package/dist/src/process/ProcessHandler.js.map +1 -0
  158. package/dist/src/process/ProcessStep.d.ts +52 -0
  159. package/dist/src/process/ProcessStep.js +78 -0
  160. package/dist/src/process/ProcessStep.js.map +1 -0
  161. package/dist/src/process/ProcessingSystem.d.ts +60 -0
  162. package/dist/src/process/ProcessingSystem.js +182 -0
  163. package/dist/src/process/ProcessingSystem.js.map +1 -0
  164. package/dist/src/process/index.d.ts +11 -0
  165. package/dist/src/process/index.js +12 -0
  166. package/dist/src/process/index.js.map +1 -0
  167. package/dist/src/reports/conversions.d.ts +8 -0
  168. package/dist/src/reports/conversions.js +47 -0
  169. package/dist/src/reports/conversions.js.map +1 -0
  170. package/dist/src/reports/index.d.ts +6 -0
  171. package/dist/src/reports/index.js +7 -0
  172. package/dist/src/reports/index.js.map +1 -0
  173. package/dist/src/server/ISPDemoServer.d.ts +43 -0
  174. package/dist/src/server/ISPDemoServer.js +112 -0
  175. package/dist/src/server/ISPDemoServer.js.map +1 -0
  176. package/dist/src/server/api.d.ts +15 -0
  177. package/dist/src/server/api.js +27 -0
  178. package/dist/src/server/api.js.map +1 -0
  179. package/dist/src/server/index.d.ts +7 -0
  180. package/dist/src/server/index.js +8 -0
  181. package/dist/src/server/index.js.map +1 -0
  182. package/dist/src/server/router.d.ts +5 -0
  183. package/dist/src/server/router.js +37 -0
  184. package/dist/src/server/router.js.map +1 -0
  185. package/dist/src/system.d.ts +27 -0
  186. package/dist/src/system.js +95 -0
  187. package/dist/src/system.js.map +1 -0
  188. package/dist/tests/TransactionRules.spec.d.ts +1 -0
  189. package/dist/tests/TransactionRules.spec.js +64 -0
  190. package/dist/tests/TransactionRules.spec.js.map +1 -0
  191. package/dist/tests/password.spec.d.ts +1 -0
  192. package/dist/tests/password.spec.js +8 -0
  193. package/dist/tests/password.spec.js.map +1 -0
  194. package/dist/tests/tokens.spec.d.ts +1 -0
  195. package/dist/tests/tokens.spec.js +49 -0
  196. package/dist/tests/tokens.spec.js.map +1 -0
  197. package/dist/tests/vault.spec.d.ts +1 -0
  198. package/dist/tests/vault.spec.js +19 -0
  199. package/dist/tests/vault.spec.js.map +1 -0
  200. package/package.json +3 -3
  201. package/src/import/TransactionImportHandler.ts +5 -1
  202. package/src/index.ts +0 -1
  203. package/src/testing/ProcessingSystemMock.ts +0 -45
  204. package/src/testing/UnitTestImportConnector.ts +0 -86
  205. package/src/testing/UnitTester.ts +0 -231
  206. package/src/testing/index.ts +0 -4
  207. package/src/testing/test-handlers.ts +0 -47
  208. package/tests/TransferAnalyzer-account-address.spec.ts +0 -87
  209. package/tests/TransferAnalyzer-buying-and-selling.spec.ts +0 -354
  210. package/tests/TransferAnalyzer-loans.spec.ts +0 -197
  211. package/tests/TransferAnalyzer-multiple-null-amounts.spec.ts +0 -181
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../src/plugins/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAA0C,GAAG,EAAO,IAAI,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAC7F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,CAAA;AAOvG,yCAAyC;AACzC,MAAM,MAAM,GAAiB;IAC3B,WAAW,EAAE,SAAS;CACvB,CAAA;AAMD;;;GAGG;AACH,SAAS,SAAS,CAAC,QAAwB;IACzC,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC9B,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,108 @@
1
+ import { ProcessFile } from './ProcessFile';
2
+ import { ProcessingSystem } from './ProcessingSystem';
3
+ import { ProcessStep } from './ProcessStep';
4
+ import { ProcessName, ProcessConfig, ProcessStatus, ID, ImportAction, ImportState } from '@tasenor/common';
5
+ import { KnexDatabase } from '../database';
6
+ /**
7
+ * Overall description of the process.
8
+ */
9
+ export interface ProcessInfo {
10
+ name: ProcessName;
11
+ config: ProcessConfig;
12
+ complete: boolean;
13
+ successful: boolean | undefined;
14
+ currentStep: number | undefined;
15
+ status: ProcessStatus;
16
+ error?: string;
17
+ }
18
+ /**
19
+ * A complete description of the process state and steps taken.
20
+ */
21
+ export declare class Process {
22
+ system: ProcessingSystem;
23
+ id: ID;
24
+ name: ProcessName;
25
+ config: ProcessConfig;
26
+ complete: boolean;
27
+ successful: boolean | undefined;
28
+ currentStep: number | undefined;
29
+ status: ProcessStatus;
30
+ files: ProcessFile[];
31
+ steps: ProcessStep[];
32
+ error: string | undefined;
33
+ constructor(system: ProcessingSystem, name: ProcessName | null, config?: ProcessConfig);
34
+ toString(): string;
35
+ /**
36
+ * Get the loaded process information as JSON object.
37
+ * @returns
38
+ */
39
+ toJSON(): ProcessInfo;
40
+ /**
41
+ * Append a file to this process and link its ID.
42
+ * @param file
43
+ */
44
+ addFile(file: ProcessFile): void;
45
+ /**
46
+ * Append a step to this process and link its ID.
47
+ * @param step
48
+ */
49
+ addStep(step: ProcessStep): Promise<void>;
50
+ /**
51
+ * Load the current step if not yet loaded and return it.
52
+ */
53
+ getCurrentStep(): Promise<ProcessStep>;
54
+ /**
55
+ * Mark the current state as completed and create new additional step with the new state.
56
+ * @param state
57
+ */
58
+ proceedToState(action: ImportAction, state: ImportState): Promise<void>;
59
+ /**
60
+ * Get a reference to the database.
61
+ */
62
+ get db(): KnexDatabase;
63
+ /**
64
+ * Save the process info to the database.
65
+ */
66
+ save(): Promise<ID>;
67
+ /**
68
+ * Load the process data and its files. Note that current step is not yet loaded here, but when using getCurrentStep().
69
+ * @param id
70
+ */
71
+ load(id: ID): Promise<void>;
72
+ /**
73
+ * Load the step with the given number from the database.
74
+ * @param number
75
+ * @returns
76
+ */
77
+ loadStep(number: number): Promise<ProcessStep>;
78
+ /**
79
+ * Check if the process can be run.
80
+ */
81
+ canRun(): boolean;
82
+ /**
83
+ * Execute process as long as it is completed, failed or requires additional input.
84
+ */
85
+ run(): Promise<void>;
86
+ /**
87
+ * Record the error and mark the process as finished with an error.
88
+ * @param err
89
+ */
90
+ crashed(err: Error): Promise<void>;
91
+ /**
92
+ * Resolve the status of the process and update it to the database.
93
+ */
94
+ updateStatus(): Promise<void>;
95
+ /**
96
+ * Get the state of the current step of the process.
97
+ */
98
+ get state(): ImportState;
99
+ /**
100
+ * Handle external input coming in.
101
+ * @param action
102
+ */
103
+ input(action: ImportAction): Promise<void>;
104
+ /**
105
+ * Roll back the process.
106
+ */
107
+ rollback(): Promise<boolean>;
108
+ }
@@ -0,0 +1,335 @@
1
+ import clone from 'clone';
2
+ import { BadState, DatabaseError, InvalidArgument, isAskUI } from '../error';
3
+ import { ProcessFile } from './ProcessFile';
4
+ import { ProcessStep } from './ProcessStep';
5
+ import { Directions } from '@tasenor/common';
6
+ /**
7
+ * A complete description of the process state and steps taken.
8
+ */
9
+ export class Process {
10
+ system;
11
+ id;
12
+ name;
13
+ config;
14
+ complete;
15
+ successful;
16
+ currentStep;
17
+ status;
18
+ files;
19
+ steps;
20
+ error;
21
+ constructor(system, name, config = {}) {
22
+ this.system = system;
23
+ this.id = null;
24
+ this.config = config;
25
+ this.name = name || '[no name]';
26
+ this.complete = false;
27
+ this.successful = undefined;
28
+ this.files = [];
29
+ this.steps = [];
30
+ this.currentStep = undefined;
31
+ this.status = 'INCOMPLETE';
32
+ }
33
+ toString() {
34
+ return `Process #${this.id} ${this.name}`;
35
+ }
36
+ /**
37
+ * Get the loaded process information as JSON object.
38
+ * @returns
39
+ */
40
+ toJSON() {
41
+ return {
42
+ name: this.name,
43
+ config: this.config,
44
+ complete: this.complete,
45
+ successful: this.successful,
46
+ currentStep: this.currentStep,
47
+ status: this.status,
48
+ error: this.error
49
+ };
50
+ }
51
+ /**
52
+ * Append a file to this process and link its ID.
53
+ * @param file
54
+ */
55
+ addFile(file) {
56
+ file.processId = this.id;
57
+ this.files.push(file);
58
+ }
59
+ /**
60
+ * Append a step to this process and link its ID.
61
+ * @param step
62
+ */
63
+ async addStep(step) {
64
+ step.processId = this.id;
65
+ step.process = this;
66
+ this.steps.push(step);
67
+ }
68
+ /**
69
+ * Load the current step if not yet loaded and return it.
70
+ */
71
+ async getCurrentStep() {
72
+ if (this.currentStep === null || this.currentStep === undefined) {
73
+ throw new BadState(`Process #${this.id} ${this.name} has invalid current step.`);
74
+ }
75
+ if (this.steps[this.currentStep]) {
76
+ return this.steps[this.currentStep];
77
+ }
78
+ return this.loadStep(this.currentStep);
79
+ }
80
+ /**
81
+ * Mark the current state as completed and create new additional step with the new state.
82
+ * @param state
83
+ */
84
+ async proceedToState(action, state) {
85
+ const current = await this.getCurrentStep();
86
+ const handler = this.system.getHandler(current.handler);
87
+ current.action = action;
88
+ current.finished = new Date();
89
+ current.save();
90
+ const nextStep = new ProcessStep({
91
+ number: current.number + 1,
92
+ state,
93
+ handler: handler.name
94
+ });
95
+ this.addStep(nextStep);
96
+ this.currentStep = (this.currentStep || 0) + 1;
97
+ this.system.logger.info(`Proceeding ${this} to new step ${this.currentStep}.`);
98
+ this.save();
99
+ await nextStep.save();
100
+ await this.system.checkFinishAndFindDirections(handler, nextStep);
101
+ }
102
+ /**
103
+ * Get a reference to the database.
104
+ */
105
+ get db() {
106
+ return this.system.db;
107
+ }
108
+ /**
109
+ * Save the process info to the database.
110
+ */
111
+ async save() {
112
+ if (this.id) {
113
+ await this.db('processes').update(this.toJSON()).where({ id: this.id });
114
+ return this.id;
115
+ }
116
+ else {
117
+ this.id = (await this.db('processes').insert(this.toJSON()).returning('id'))[0].id;
118
+ if (this.id)
119
+ return this.id;
120
+ throw new DatabaseError(`Saving process ${JSON.stringify(this.toJSON)} failed.`);
121
+ }
122
+ }
123
+ /**
124
+ * Load the process data and its files. Note that current step is not yet loaded here, but when using getCurrentStep().
125
+ * @param id
126
+ */
127
+ async load(id) {
128
+ // Load basic info.
129
+ const data = await this.db('processes').select('*').where({ id }).first();
130
+ if (!data) {
131
+ throw new InvalidArgument(`Cannot find process #${id}`);
132
+ }
133
+ Object.assign(this, data);
134
+ this.id = id;
135
+ // Load files.
136
+ this.files = (await this.db('process_files').select('*').where({ processId: this.id })).map(fileData => {
137
+ const file = new ProcessFile(fileData);
138
+ file.id = fileData.id;
139
+ return file;
140
+ });
141
+ // Load current step.
142
+ await this.getCurrentStep();
143
+ }
144
+ /**
145
+ * Load the step with the given number from the database.
146
+ * @param number
147
+ * @returns
148
+ */
149
+ async loadStep(number) {
150
+ if (!this.id) {
151
+ throw new BadState(`Cannot load steps, if the process have no ID ${JSON.stringify(this.toJSON())}.`);
152
+ }
153
+ if (this.currentStep === undefined) {
154
+ throw new BadState(`Cannot load any steps, since process have no current step ${JSON.stringify(this.toJSON())}.`);
155
+ }
156
+ const data = await this.db('process_steps').where({ processId: this.id, number }).first();
157
+ if (!data) {
158
+ throw new BadState(`Cannot find step ${this.currentStep} for process ${JSON.stringify(this.toJSON())}.`);
159
+ }
160
+ this.steps[this.currentStep] = new ProcessStep(data);
161
+ this.steps[this.currentStep].id = data.id;
162
+ this.steps[this.currentStep].process = this;
163
+ return this.steps[this.currentStep];
164
+ }
165
+ /**
166
+ * Check if the process can be run.
167
+ */
168
+ canRun() {
169
+ return !this.complete && (this.status === 'INCOMPLETE' || this.status === 'WAITING');
170
+ }
171
+ /**
172
+ * Execute process as long as it is completed, failed or requires additional input.
173
+ */
174
+ async run() {
175
+ let step;
176
+ let MAX_RUNS = 100;
177
+ while (true) {
178
+ MAX_RUNS--;
179
+ if (MAX_RUNS < 0) {
180
+ this.system.logger.error(`Maximum number of executions reached for the process ${this}.`);
181
+ break;
182
+ }
183
+ step = await this.getCurrentStep();
184
+ if (!step.directions) {
185
+ this.system.logger.info(`No new directions for the process ${this}.`);
186
+ break;
187
+ }
188
+ if (!step.directions.isImmediate()) {
189
+ this.system.logger.info(`Waiting for more input for the process ${this}.`);
190
+ await this.updateStatus();
191
+ break;
192
+ }
193
+ const handler = this.system.getHandler(step.handler);
194
+ const state = clone(step.state);
195
+ const action = clone(step.directions.action);
196
+ try {
197
+ if (action) {
198
+ const nextState = await handler.action(this, action, state, this.files);
199
+ await this.proceedToState(action, nextState);
200
+ }
201
+ else {
202
+ throw new BadState(`Process step ${step} has no action.`);
203
+ }
204
+ }
205
+ catch (err) {
206
+ return await this.crashed(err);
207
+ }
208
+ }
209
+ }
210
+ /**
211
+ * Record the error and mark the process as finished with an error.
212
+ * @param err
213
+ */
214
+ async crashed(err) {
215
+ if (isAskUI(err)) {
216
+ // Postpone the action we tried. Instead, create query for UI to add more configuration for later retry.
217
+ const directions = new Directions({
218
+ type: 'ui',
219
+ element: err.element
220
+ });
221
+ const step = await this.getCurrentStep();
222
+ step.directions = directions;
223
+ await step.save();
224
+ await this.updateStatus();
225
+ return;
226
+ }
227
+ this.system.logger.error(`Processing of ${this} failed:`, err);
228
+ if (this.currentStep !== undefined && this.currentStep !== null) {
229
+ const step = await this.loadStep(this.currentStep);
230
+ step.finished = new Date();
231
+ await step.save();
232
+ }
233
+ this.error = err.stack ? err.stack : `${err.name}: ${err.message}`;
234
+ await this.save();
235
+ await this.updateStatus();
236
+ }
237
+ /**
238
+ * Resolve the status of the process and update it to the database.
239
+ */
240
+ async updateStatus() {
241
+ let status = 'INCOMPLETE';
242
+ if (this.error) {
243
+ status = 'CRASHED';
244
+ }
245
+ else {
246
+ if (this.currentStep === null || this.currentStep === undefined) {
247
+ throw new BadState(`Cannot check status when there is no current step loaded for ${this}`);
248
+ }
249
+ const step = this.steps[this.currentStep];
250
+ if (step.finished) {
251
+ if (this.successful === true)
252
+ status = 'SUCCEEDED';
253
+ if (this.successful === false)
254
+ status = 'FAILED';
255
+ }
256
+ if (step.directions) {
257
+ status = step.directions.isImmediate() ? 'INCOMPLETE' : 'WAITING';
258
+ }
259
+ }
260
+ if (this.status !== status) {
261
+ this.system.logger.info(`Process ${this} is now ${status}`);
262
+ }
263
+ this.status = status;
264
+ await this.db('processes').update({ status }).where({ id: this.id });
265
+ let directions, state;
266
+ switch (status) {
267
+ case 'SUCCEEDED':
268
+ await this.system.connector.success(this.state);
269
+ break;
270
+ case 'CRASHED':
271
+ await this.system.connector.fail(this.error);
272
+ break;
273
+ case 'FAILED':
274
+ await this.system.connector.fail(this.state);
275
+ break;
276
+ default:
277
+ directions = this.currentStep ? this.steps[this.currentStep].directions : null;
278
+ state = this.currentStep ? this.steps[this.currentStep].state : null;
279
+ await this.system.connector.waiting(state, directions);
280
+ }
281
+ }
282
+ /**
283
+ * Get the state of the current step of the process.
284
+ */
285
+ get state() {
286
+ if (this.currentStep === null || this.currentStep === undefined) {
287
+ throw new BadState(`Cannot check state when there is no current step loaded for ${this}`);
288
+ }
289
+ const step = this.steps[this.currentStep];
290
+ return step.state;
291
+ }
292
+ /**
293
+ * Handle external input coming in.
294
+ * @param action
295
+ */
296
+ async input(action) {
297
+ this.system.logger.info(`Handling input ${JSON.stringify(action)} on process ${this}.`);
298
+ const step = await this.getCurrentStep();
299
+ const handler = this.system.getHandler(step.handler);
300
+ let nextState;
301
+ try {
302
+ nextState = await handler.action(this, action, clone(step.state), this.files);
303
+ }
304
+ catch (err) {
305
+ return this.crashed(err);
306
+ }
307
+ await this.proceedToState(action, nextState);
308
+ }
309
+ /**
310
+ * Roll back the process.
311
+ */
312
+ async rollback() {
313
+ if (this.currentStep === null || this.currentStep === undefined) {
314
+ throw new BadState('Cannot rollback when there is no current step.');
315
+ }
316
+ if (this.currentStep < 1) {
317
+ throw new BadState('Cannot rollback when there is only initial step in the process.');
318
+ }
319
+ const step = await this.getCurrentStep();
320
+ this.system.logger.info(`Attempt of rolling back '${step}' from '${this}'.`);
321
+ const handler = this.system.getHandler(step.handler);
322
+ await handler.rollback(this, this.state);
323
+ const current = await this.getCurrentStep();
324
+ current.action = { rollback: true };
325
+ current.finished = new Date();
326
+ current.save();
327
+ this.system.logger.info(`Proceeding ${this} to new step ${this.currentStep}.`);
328
+ this.save();
329
+ this.status = 'ROLLEDBACK';
330
+ await this.db('processes').update({ status: this.status }).where({ id: this.id });
331
+ this.system.logger.info(`Roll back of '${this}' successful.`);
332
+ return true;
333
+ }
334
+ }
335
+ //# sourceMappingURL=Process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Process.js","sourceRoot":"","sources":["../../../src/process/Process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,UAAU,EAA4F,MAAM,iBAAiB,CAAA;AAgBtI;;GAEG;AACH,MAAM,OAAO,OAAO;IAElB,MAAM,CAAkB;IAExB,EAAE,CAAI;IACN,IAAI,CAAa;IACjB,MAAM,CAAe;IACrB,QAAQ,CAAS;IACjB,UAAU,CAAqB;IAC/B,WAAW,CAAoB;IAC/B,MAAM,CAAe;IACrB,KAAK,CAAe;IACpB,KAAK,CAAe;IACpB,KAAK,CAAoB;IAEzB,YAAY,MAAwB,EAAE,IAAwB,EAAE,SAAwB,EAAE;QACxF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,WAAW,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAA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OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QACxC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QAC3C,OAAO,CAAC,MAAM,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAA;QACnC,OAAO,CAAC,QAAQ,GAAG,IAAI,IAAI,EAAE,CAAA;QAC7B,OAAO,CAAC,IAAI,EAAE,CAAA;QAEd,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,IAAI,gBAAgB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;QAC9E,IAAI,CAAC,IAAI,EAAE,CAAA;QAEX,IAAI,CAAC,MAAM,GAAG,YAAY,CAAA;QAC1B,MAAM,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QACjF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,IAAI,eAAe,CAAC,CAAA;QAE7D,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import { ID } from '@tasenor/common';
2
+ /**
3
+ * A connector interface for querying information, applying results and running various hooks.
4
+ */
5
+ export interface ProcessConnector {
6
+ initialize(server: unknown): Promise<void>;
7
+ getTranslation(text: string, language: string): Promise<string>;
8
+ resultExists(processId: ID, args: unknown): Promise<boolean>;
9
+ applyResult(processId: ID, args: unknown): Promise<Record<string, unknown>>;
10
+ rollback(processId: ID): Promise<boolean>;
11
+ success(state: unknown): Promise<void>;
12
+ waiting(state: unknown, directions: any): Promise<void>;
13
+ fail(state: unknown): Promise<void>;
14
+ }
15
+ export declare const defaultConnector: {
16
+ initialize(): Promise<void>;
17
+ resultExists(processId: ID, args: unknown): Promise<boolean>;
18
+ applyResult(): Promise<Record<string, unknown>>;
19
+ success(): Promise<void>;
20
+ waiting(): Promise<void>;
21
+ fail(): Promise<void>;
22
+ getTranslation(text: string): Promise<string>;
23
+ rollback(processId: ID): Promise<boolean>;
24
+ };
@@ -0,0 +1,28 @@
1
+ export const defaultConnector = {
2
+ async initialize() {
3
+ console.log(new Date(), 'Connector initialized.');
4
+ },
5
+ async resultExists(processId, args) {
6
+ return false;
7
+ },
8
+ async applyResult() {
9
+ console.log(new Date(), 'Result received.');
10
+ return {};
11
+ },
12
+ async success() {
13
+ console.log(new Date(), 'Process completed.');
14
+ },
15
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
16
+ async waiting() {
17
+ },
18
+ async fail() {
19
+ console.error(new Date(), 'Process failed.');
20
+ },
21
+ async getTranslation(text) {
22
+ return text;
23
+ },
24
+ async rollback(processId) {
25
+ return true;
26
+ }
27
+ };
28
+ //# sourceMappingURL=ProcessConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessConnector.js","sourceRoot":"","sources":["../../../src/process/ProcessConnector.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,KAAK,CAAC,UAAU;QACd,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,wBAAwB,CAAC,CAAA;IACnD,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,SAAa,EAAE,IAAa;QAC7C,OAAO,KAAK,CAAA;IACd,CAAC;IACD,KAAK,CAAC,WAAW;QACf,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,kBAAkB,CAAC,CAAA;QAC3C,OAAO,EAAE,CAAA;IACX,CAAC;IACD,KAAK,CAAC,OAAO;QACX,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,oBAAoB,CAAC,CAAA;IAC/C,CAAC;IACD,gEAAgE;IAChE,KAAK,CAAC,OAAO;IACb,CAAC;IACD,KAAK,CAAC,IAAI;QACR,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,iBAAiB,CAAC,CAAA;IAC9C,CAAC;IACD,KAAK,CAAC,cAAc,CAAC,IAAY;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,KAAK,CAAC,QAAQ,CAAC,SAAa;QAC1B,OAAO,IAAI,CAAA;IACb,CAAC;CAEF,CAAA"}
@@ -0,0 +1,69 @@
1
+ import { ID, FileEncoding } from '@tasenor/common';
2
+ import { KnexDatabase } from '../database';
3
+ /**
4
+ * A data structure containing input data for the process.
5
+ */
6
+ export interface ProcessFileData {
7
+ processId?: ID;
8
+ name: string;
9
+ type?: string;
10
+ encoding: FileEncoding;
11
+ data: string;
12
+ }
13
+ /**
14
+ * An instance of input data for processing.
15
+ */
16
+ export declare class ProcessFile {
17
+ id: ID;
18
+ processId: ID;
19
+ name: string;
20
+ type?: string;
21
+ encoding: FileEncoding;
22
+ data: string;
23
+ _decoded?: string;
24
+ constructor(obj: ProcessFileData);
25
+ toString(): string;
26
+ /**
27
+ * Get the loaded process information as JSON object.
28
+ * @returns
29
+ */
30
+ toJSON(): ProcessFileData;
31
+ /**
32
+ * Save the file to the database.
33
+ */
34
+ save(db: KnexDatabase): Promise<ID>;
35
+ /**
36
+ * Check if the first line of the text file matches to the regular expression.
37
+ * @param re
38
+ */
39
+ firstLineMatch(re: RegExp): boolean;
40
+ /**
41
+ * Check if the second line of the text file matches to the regular expression.
42
+ * @param re
43
+ */
44
+ secondLineMatch(re: RegExp): boolean;
45
+ /**
46
+ * Check if the third line of the text file matches to the regular expression.
47
+ * @param re
48
+ */
49
+ thirdLineMatch(re: RegExp): boolean;
50
+ /**
51
+ * Check if the file begins with the given string.
52
+ */
53
+ startsWith(s: string): boolean;
54
+ /**
55
+ * Find out if the content is binary or text.
56
+ *
57
+ * The mime type has to start with `text/`.
58
+ */
59
+ isTextFile(): boolean;
60
+ /**
61
+ * Convert chardet encoding to the supported buffer encoding
62
+ * "ascii" | "utf8" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex"
63
+ */
64
+ parseEncoding(encoding: string): 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex';
65
+ /**
66
+ * Try to recognize the file content and decode if it is a recognizable text format.
67
+ */
68
+ decode(): string;
69
+ }