@things-factory/accounting 6.0.46

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 (227) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +31 -0
  3. package/assets/images/book-activity.jpg +0 -0
  4. package/assets/images/expense-activity.jpg +0 -0
  5. package/assets/images/hatiolab-logo.png +0 -0
  6. package/client/activities/activity-book-edit.ts +88 -0
  7. package/client/activities/activity-book-view.ts +88 -0
  8. package/client/activities/activity-expense-edit.ts +88 -0
  9. package/client/activities/activity-expense-view.ts +88 -0
  10. package/client/bootstrap.ts +1 -0
  11. package/client/index.ts +0 -0
  12. package/client/pages/account/account-importer.ts +97 -0
  13. package/client/pages/account/account-list-page.ts +348 -0
  14. package/client/pages/accounting-category/accounting-category-importer.ts +97 -0
  15. package/client/pages/accounting-category/accounting-category-list-page.ts +348 -0
  16. package/client/pages/financial-statement/financial-statement-importer.ts +97 -0
  17. package/client/pages/financial-statement/financial-statement-list-page.ts +348 -0
  18. package/client/pages/income-statement/income-statement-importer.ts +97 -0
  19. package/client/pages/income-statement/income-statement-list-page.ts +348 -0
  20. package/client/pages/ledger/ledger-importer.ts +97 -0
  21. package/client/pages/ledger/ledger-list-page.ts +332 -0
  22. package/client/pages/main.ts +24 -0
  23. package/client/pages/transaction/transaction-importer.ts +97 -0
  24. package/client/pages/transaction/transaction-list-page.ts +348 -0
  25. package/client/route.ts +27 -0
  26. package/client/tsconfig.json +11 -0
  27. package/dist-client/activities/activity-book-edit.d.ts +14 -0
  28. package/dist-client/activities/activity-book-edit.js +85 -0
  29. package/dist-client/activities/activity-book-edit.js.map +1 -0
  30. package/dist-client/activities/activity-book-view.d.ts +14 -0
  31. package/dist-client/activities/activity-book-view.js +85 -0
  32. package/dist-client/activities/activity-book-view.js.map +1 -0
  33. package/dist-client/activities/activity-expense-edit.d.ts +14 -0
  34. package/dist-client/activities/activity-expense-edit.js +85 -0
  35. package/dist-client/activities/activity-expense-edit.js.map +1 -0
  36. package/dist-client/activities/activity-expense-view.d.ts +14 -0
  37. package/dist-client/activities/activity-expense-view.js +85 -0
  38. package/dist-client/activities/activity-expense-view.js.map +1 -0
  39. package/dist-client/bootstrap.d.ts +1 -0
  40. package/dist-client/bootstrap.js +2 -0
  41. package/dist-client/bootstrap.js.map +1 -0
  42. package/dist-client/index.d.ts +0 -0
  43. package/dist-client/index.js +2 -0
  44. package/dist-client/index.js.map +1 -0
  45. package/dist-client/pages/account/account-importer.d.ts +22 -0
  46. package/dist-client/pages/account/account-importer.js +100 -0
  47. package/dist-client/pages/account/account-importer.js.map +1 -0
  48. package/dist-client/pages/account/account-list-page.d.ts +62 -0
  49. package/dist-client/pages/account/account-list-page.js +326 -0
  50. package/dist-client/pages/account/account-list-page.js.map +1 -0
  51. package/dist-client/pages/accounting-category/accounting-category-importer.d.ts +22 -0
  52. package/dist-client/pages/accounting-category/accounting-category-importer.js +100 -0
  53. package/dist-client/pages/accounting-category/accounting-category-importer.js.map +1 -0
  54. package/dist-client/pages/accounting-category/accounting-category-list-page.d.ts +62 -0
  55. package/dist-client/pages/accounting-category/accounting-category-list-page.js +326 -0
  56. package/dist-client/pages/accounting-category/accounting-category-list-page.js.map +1 -0
  57. package/dist-client/pages/financial-statement/financial-statement-importer.d.ts +22 -0
  58. package/dist-client/pages/financial-statement/financial-statement-importer.js +100 -0
  59. package/dist-client/pages/financial-statement/financial-statement-importer.js.map +1 -0
  60. package/dist-client/pages/financial-statement/financial-statement-list-page.d.ts +62 -0
  61. package/dist-client/pages/financial-statement/financial-statement-list-page.js +326 -0
  62. package/dist-client/pages/financial-statement/financial-statement-list-page.js.map +1 -0
  63. package/dist-client/pages/income-statement/income-statement-importer.d.ts +22 -0
  64. package/dist-client/pages/income-statement/income-statement-importer.js +100 -0
  65. package/dist-client/pages/income-statement/income-statement-importer.js.map +1 -0
  66. package/dist-client/pages/income-statement/income-statement-list-page.d.ts +62 -0
  67. package/dist-client/pages/income-statement/income-statement-list-page.js +326 -0
  68. package/dist-client/pages/income-statement/income-statement-list-page.js.map +1 -0
  69. package/dist-client/pages/ledger/ledger-importer.d.ts +22 -0
  70. package/dist-client/pages/ledger/ledger-importer.js +100 -0
  71. package/dist-client/pages/ledger/ledger-importer.js.map +1 -0
  72. package/dist-client/pages/ledger/ledger-list-page.d.ts +62 -0
  73. package/dist-client/pages/ledger/ledger-list-page.js +317 -0
  74. package/dist-client/pages/ledger/ledger-list-page.js.map +1 -0
  75. package/dist-client/pages/main.d.ts +1 -0
  76. package/dist-client/pages/main.js +27 -0
  77. package/dist-client/pages/main.js.map +1 -0
  78. package/dist-client/pages/transaction/transaction-importer.d.ts +22 -0
  79. package/dist-client/pages/transaction/transaction-importer.js +100 -0
  80. package/dist-client/pages/transaction/transaction-importer.js.map +1 -0
  81. package/dist-client/pages/transaction/transaction-list-page.d.ts +62 -0
  82. package/dist-client/pages/transaction/transaction-list-page.js +326 -0
  83. package/dist-client/pages/transaction/transaction-list-page.js.map +1 -0
  84. package/dist-client/route.d.ts +1 -0
  85. package/dist-client/route.js +23 -0
  86. package/dist-client/route.js.map +1 -0
  87. package/dist-client/tsconfig.tsbuildinfo +1 -0
  88. package/dist-server/activities/activity-book.js +150 -0
  89. package/dist-server/activities/activity-book.js.map +1 -0
  90. package/dist-server/activities/activity-expense.js +150 -0
  91. package/dist-server/activities/activity-expense.js.map +1 -0
  92. package/dist-server/activities/index.js +19 -0
  93. package/dist-server/activities/index.js.map +1 -0
  94. package/dist-server/controllers/index.js +1 -0
  95. package/dist-server/controllers/index.js.map +1 -0
  96. package/dist-server/index.js +7 -0
  97. package/dist-server/index.js.map +1 -0
  98. package/dist-server/middlewares/index.js +8 -0
  99. package/dist-server/middlewares/index.js.map +1 -0
  100. package/dist-server/migrations/index.js +12 -0
  101. package/dist-server/migrations/index.js.map +1 -0
  102. package/dist-server/routes.js +25 -0
  103. package/dist-server/routes.js.map +1 -0
  104. package/dist-server/service/account/account-history.js +113 -0
  105. package/dist-server/service/account/account-history.js.map +1 -0
  106. package/dist-server/service/account/account-mutation.js +130 -0
  107. package/dist-server/service/account/account-mutation.js.map +1 -0
  108. package/dist-server/service/account/account-query.js +79 -0
  109. package/dist-server/service/account/account-query.js.map +1 -0
  110. package/dist-server/service/account/account-type.js +65 -0
  111. package/dist-server/service/account/account-type.js.map +1 -0
  112. package/dist-server/service/account/account.js +102 -0
  113. package/dist-server/service/account/account.js.map +1 -0
  114. package/dist-server/service/account/event-subscriber.js +21 -0
  115. package/dist-server/service/account/event-subscriber.js.map +1 -0
  116. package/dist-server/service/account/index.js +12 -0
  117. package/dist-server/service/account/index.js.map +1 -0
  118. package/dist-server/service/accounting-category/accounting-category-mutation.js +132 -0
  119. package/dist-server/service/accounting-category/accounting-category-mutation.js.map +1 -0
  120. package/dist-server/service/accounting-category/accounting-category-query.js +79 -0
  121. package/dist-server/service/accounting-category/accounting-category-query.js.map +1 -0
  122. package/dist-server/service/accounting-category/accounting-category-type.js +65 -0
  123. package/dist-server/service/accounting-category/accounting-category-type.js.map +1 -0
  124. package/dist-server/service/accounting-category/accounting-category.js +89 -0
  125. package/dist-server/service/accounting-category/accounting-category.js.map +1 -0
  126. package/dist-server/service/accounting-category/index.js +10 -0
  127. package/dist-server/service/accounting-category/index.js.map +1 -0
  128. package/dist-server/service/financial-statement/event-subscriber.js +21 -0
  129. package/dist-server/service/financial-statement/event-subscriber.js.map +1 -0
  130. package/dist-server/service/financial-statement/financial-statement-history.js +126 -0
  131. package/dist-server/service/financial-statement/financial-statement-history.js.map +1 -0
  132. package/dist-server/service/financial-statement/financial-statement-mutation.js +132 -0
  133. package/dist-server/service/financial-statement/financial-statement-mutation.js.map +1 -0
  134. package/dist-server/service/financial-statement/financial-statement-query.js +79 -0
  135. package/dist-server/service/financial-statement/financial-statement-query.js.map +1 -0
  136. package/dist-server/service/financial-statement/financial-statement-type.js +77 -0
  137. package/dist-server/service/financial-statement/financial-statement-type.js.map +1 -0
  138. package/dist-server/service/financial-statement/financial-statement.js +111 -0
  139. package/dist-server/service/financial-statement/financial-statement.js.map +1 -0
  140. package/dist-server/service/financial-statement/index.js +12 -0
  141. package/dist-server/service/financial-statement/index.js.map +1 -0
  142. package/dist-server/service/income-statement/event-subscriber.js +21 -0
  143. package/dist-server/service/income-statement/event-subscriber.js.map +1 -0
  144. package/dist-server/service/income-statement/income-statement-history.js +126 -0
  145. package/dist-server/service/income-statement/income-statement-history.js.map +1 -0
  146. package/dist-server/service/income-statement/income-statement-mutation.js +132 -0
  147. package/dist-server/service/income-statement/income-statement-mutation.js.map +1 -0
  148. package/dist-server/service/income-statement/income-statement-query.js +79 -0
  149. package/dist-server/service/income-statement/income-statement-query.js.map +1 -0
  150. package/dist-server/service/income-statement/income-statement-type.js +77 -0
  151. package/dist-server/service/income-statement/income-statement-type.js.map +1 -0
  152. package/dist-server/service/income-statement/income-statement.js +117 -0
  153. package/dist-server/service/income-statement/income-statement.js.map +1 -0
  154. package/dist-server/service/income-statement/index.js +12 -0
  155. package/dist-server/service/income-statement/index.js.map +1 -0
  156. package/dist-server/service/index.js +43 -0
  157. package/dist-server/service/index.js.map +1 -0
  158. package/dist-server/service/transaction/event-subscriber.js +21 -0
  159. package/dist-server/service/transaction/event-subscriber.js.map +1 -0
  160. package/dist-server/service/transaction/index.js +12 -0
  161. package/dist-server/service/transaction/index.js.map +1 -0
  162. package/dist-server/service/transaction/transaction-history.js +123 -0
  163. package/dist-server/service/transaction/transaction-history.js.map +1 -0
  164. package/dist-server/service/transaction/transaction-mutation.js +130 -0
  165. package/dist-server/service/transaction/transaction-mutation.js.map +1 -0
  166. package/dist-server/service/transaction/transaction-query.js +79 -0
  167. package/dist-server/service/transaction/transaction-query.js.map +1 -0
  168. package/dist-server/service/transaction/transaction-type.js +73 -0
  169. package/dist-server/service/transaction/transaction-type.js.map +1 -0
  170. package/dist-server/service/transaction/transaction.js +130 -0
  171. package/dist-server/service/transaction/transaction.js.map +1 -0
  172. package/dist-server/tsconfig.tsbuildinfo +1 -0
  173. package/helps/accounting/account.md +160 -0
  174. package/helps/accounting/accounting-category.md +160 -0
  175. package/helps/accounting/financial-accounting.md +53 -0
  176. package/helps/accounting/financial-statement.md +160 -0
  177. package/helps/accounting/income-statement.md +160 -0
  178. package/helps/accounting/transaction.md +160 -0
  179. package/package.json +36 -0
  180. package/server/activities/activity-book.ts +149 -0
  181. package/server/activities/activity-expense.ts +149 -0
  182. package/server/activities/index.ts +19 -0
  183. package/server/controllers/index.ts +0 -0
  184. package/server/index.ts +4 -0
  185. package/server/middlewares/index.ts +3 -0
  186. package/server/migrations/index.ts +9 -0
  187. package/server/routes.ts +28 -0
  188. package/server/service/account/account-history.ts +103 -0
  189. package/server/service/account/account-mutation.ts +137 -0
  190. package/server/service/account/account-query.ts +49 -0
  191. package/server/service/account/account-type.ts +44 -0
  192. package/server/service/account/account.ts +86 -0
  193. package/server/service/account/event-subscriber.ts +17 -0
  194. package/server/service/account/index.ts +9 -0
  195. package/server/service/accounting-category/accounting-category-mutation.ts +145 -0
  196. package/server/service/accounting-category/accounting-category-query.ts +51 -0
  197. package/server/service/accounting-category/accounting-category-type.ts +42 -0
  198. package/server/service/accounting-category/accounting-category.ts +80 -0
  199. package/server/service/accounting-category/index.ts +7 -0
  200. package/server/service/financial-statement/event-subscriber.ts +17 -0
  201. package/server/service/financial-statement/financial-statement-history.ts +114 -0
  202. package/server/service/financial-statement/financial-statement-mutation.ts +145 -0
  203. package/server/service/financial-statement/financial-statement-query.ts +51 -0
  204. package/server/service/financial-statement/financial-statement-type.ts +51 -0
  205. package/server/service/financial-statement/financial-statement.ts +100 -0
  206. package/server/service/financial-statement/index.ts +9 -0
  207. package/server/service/income-statement/event-subscriber.ts +17 -0
  208. package/server/service/income-statement/income-statement-history.ts +114 -0
  209. package/server/service/income-statement/income-statement-mutation.ts +145 -0
  210. package/server/service/income-statement/income-statement-query.ts +48 -0
  211. package/server/service/income-statement/income-statement-type.ts +51 -0
  212. package/server/service/income-statement/income-statement.ts +105 -0
  213. package/server/service/income-statement/index.ts +9 -0
  214. package/server/service/index.ts +62 -0
  215. package/server/service/transaction/event-subscriber.ts +17 -0
  216. package/server/service/transaction/index.ts +9 -0
  217. package/server/service/transaction/transaction-history.ts +111 -0
  218. package/server/service/transaction/transaction-mutation.ts +143 -0
  219. package/server/service/transaction/transaction-query.ts +48 -0
  220. package/server/service/transaction/transaction-type.ts +48 -0
  221. package/server/service/transaction/transaction.ts +115 -0
  222. package/server/tsconfig.json +10 -0
  223. package/things-factory.config.js +16 -0
  224. package/translations/en.json +1 -0
  225. package/translations/ko.json +1 -0
  226. package/translations/ms.json +1 -0
  227. package/translations/zh.json +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/activities/index.ts"],"names":[],"mappings":";;AAAA,uDAAgE;AAEhE,+BAA+B;AAC/B,yDAAoD;AACpD,mDAEC;AAAA;IACD,wBAAwB;IACrB,kCAAe;IACf,4BAAY;CACd,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,gCAAqB,CAAC,uBAAuB,CAAC,QAAQ,CAAC,CAAA;AACzD,CAAC,CAAC,CAAA;AAEF;;;;EAIE","sourcesContent":["import { ActivityInstallations } from '@things-factory/worklist'\n\n/* IMPORT ACTIVITY TEMPLATES */\nimport { ActivityExpense } from './activity-expense'\nimport { ActivityBook } from './activity-book'\n\n;[\n/* ACTIVITY TEMPLATES */\n\t ActivityExpense,\n\t ActivityBook,\n].forEach(template => {\n ActivityInstallations.installActivityTemplate(template)\n})\n\n/* \nAdd the following line to server/index.ts so that activities can be registered when loading a module.\n--\nimport './activities'\n*/\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./migrations"), exports);
5
+ tslib_1.__exportStar(require("./middlewares"), exports);
6
+ require("./routes");
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,wDAA6B;AAE7B,oBAAiB","sourcesContent":["export * from './migrations'\nexport * from './middlewares'\n\nimport './routes'\n"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initMiddlewares = void 0;
4
+ function initMiddlewares(app) {
5
+ /* can add middlewares into app */
6
+ }
7
+ exports.initMiddlewares = initMiddlewares;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAG;IACjC,kCAAkC;AACpC,CAAC;AAFD,0CAEC","sourcesContent":["export function initMiddlewares(app) {\n /* can add middlewares into app */\n}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrations = void 0;
4
+ const glob = require('glob');
5
+ const path = require('path');
6
+ exports.migrations = [];
7
+ glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
+ if (file.indexOf('index.js') !== -1)
9
+ return;
10
+ exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
+ });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA","sourcesContent":["const glob = require('glob')\nconst path = require('path')\n\nexport var migrations = []\n\nglob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function(file) {\n if (file.indexOf('index.js') !== -1) return\n migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])\n})\n"]}
@@ -0,0 +1,25 @@
1
+ const debug = require('debug')('things-factory:accounting:routes');
2
+ process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
3
+ /*
4
+ * can add global public routes to application (auth not required, tenancy not required)
5
+ *
6
+ * ex) routes.get('/path', async(context, next) => {})
7
+ * ex) routes.post('/path', async(context, next) => {})
8
+ */
9
+ });
10
+ process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
11
+ /*
12
+ * can add global private routes to application (auth required, tenancy not required)
13
+ */
14
+ });
15
+ process.on('bootstrap-module-domain-public-route', (app, domainPublicRouter) => {
16
+ /*
17
+ * can add domain public routes to application (auth not required, tenancy required)
18
+ */
19
+ });
20
+ process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
21
+ /*
22
+ * can add domain private routes to application (auth required, tenancy required)
23
+ */
24
+ });
25
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,kCAAkC,CAAC,CAAA;AAElE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA","sourcesContent":["const debug = require('debug')('things-factory:accounting:routes')\n\nprocess.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {\n /*\n * can add global public routes to application (auth not required, tenancy not required)\n *\n * ex) routes.get('/path', async(context, next) => {})\n * ex) routes.post('/path', async(context, next) => {})\n */\n})\n\nprocess.on('bootstrap-module-global-private-route' as any, (app, globalPrivateRouter) => {\n /*\n * can add global private routes to application (auth required, tenancy not required)\n */\n})\n\nprocess.on('bootstrap-module-domain-public-route' as any, (app, domainPublicRouter) => {\n /*\n * can add domain public routes to application (auth not required, tenancy required)\n */\n})\n\nprocess.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {\n /*\n * can add domain private routes to application (auth required, tenancy required)\n */\n})\n"]}
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountHistory = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const typeorm_history_1 = require("@operato/typeorm-history");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const env_1 = require("@things-factory/env");
10
+ const shell_1 = require("@things-factory/shell");
11
+ const ORMCONFIG = env_1.config.get('ormconfig', {});
12
+ const DATABASE_TYPE = ORMCONFIG.type;
13
+ let AccountHistory = class AccountHistory {
14
+ constructor() {
15
+ this.version = 1;
16
+ }
17
+ };
18
+ tslib_1.__decorate([
19
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
20
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], AccountHistory.prototype, "id", void 0);
23
+ tslib_1.__decorate([
24
+ (0, typeorm_1.Column)({ nullable: true, default: 1 }),
25
+ (0, type_graphql_1.Field)({ nullable: true }),
26
+ tslib_1.__metadata("design:type", Number)
27
+ ], AccountHistory.prototype, "version", void 0);
28
+ tslib_1.__decorate([
29
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
30
+ (0, type_graphql_1.Field)({ nullable: true }),
31
+ tslib_1.__metadata("design:type", shell_1.Domain)
32
+ ], AccountHistory.prototype, "domain", void 0);
33
+ tslib_1.__decorate([
34
+ (0, typeorm_1.RelationId)((account) => account.domain),
35
+ tslib_1.__metadata("design:type", String)
36
+ ], AccountHistory.prototype, "domainId", void 0);
37
+ tslib_1.__decorate([
38
+ (0, typeorm_1.Column)({ nullable: true }),
39
+ (0, type_graphql_1.Field)({ nullable: true }),
40
+ tslib_1.__metadata("design:type", String)
41
+ ], AccountHistory.prototype, "controlNumber", void 0);
42
+ tslib_1.__decorate([
43
+ (0, typeorm_1.Column)({ nullable: true }),
44
+ (0, type_graphql_1.Field)({ nullable: true }),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], AccountHistory.prototype, "name", void 0);
47
+ tslib_1.__decorate([
48
+ (0, typeorm_1.Column)({ nullable: true }),
49
+ (0, type_graphql_1.Field)({ nullable: true }),
50
+ tslib_1.__metadata("design:type", String)
51
+ ], AccountHistory.prototype, "description", void 0);
52
+ tslib_1.__decorate([
53
+ (0, typeorm_1.Column)({ nullable: true }),
54
+ (0, type_graphql_1.Field)({ nullable: true }),
55
+ tslib_1.__metadata("design:type", Boolean)
56
+ ], AccountHistory.prototype, "active", void 0);
57
+ tslib_1.__decorate([
58
+ (0, typeorm_1.Column)({ nullable: true }),
59
+ (0, type_graphql_1.Field)({ nullable: true }),
60
+ tslib_1.__metadata("design:type", Date)
61
+ ], AccountHistory.prototype, "createdAt", void 0);
62
+ tslib_1.__decorate([
63
+ (0, typeorm_1.Column)({ nullable: true }),
64
+ (0, type_graphql_1.Field)({ nullable: true }),
65
+ tslib_1.__metadata("design:type", Date)
66
+ ], AccountHistory.prototype, "updatedAt", void 0);
67
+ tslib_1.__decorate([
68
+ (0, typeorm_1.Column)({ nullable: true }),
69
+ (0, type_graphql_1.Field)({ nullable: true }),
70
+ tslib_1.__metadata("design:type", Date)
71
+ ], AccountHistory.prototype, "deletedAt", void 0);
72
+ tslib_1.__decorate([
73
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
74
+ (0, type_graphql_1.Field)({ nullable: true }),
75
+ tslib_1.__metadata("design:type", auth_base_1.User)
76
+ ], AccountHistory.prototype, "creator", void 0);
77
+ tslib_1.__decorate([
78
+ (0, typeorm_1.RelationId)((account) => account.creator),
79
+ tslib_1.__metadata("design:type", String)
80
+ ], AccountHistory.prototype, "creatorId", void 0);
81
+ tslib_1.__decorate([
82
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
83
+ (0, type_graphql_1.Field)({ nullable: true }),
84
+ tslib_1.__metadata("design:type", auth_base_1.User)
85
+ ], AccountHistory.prototype, "updater", void 0);
86
+ tslib_1.__decorate([
87
+ (0, typeorm_1.RelationId)((account) => account.updater),
88
+ tslib_1.__metadata("design:type", String)
89
+ ], AccountHistory.prototype, "updaterId", void 0);
90
+ tslib_1.__decorate([
91
+ (0, typeorm_history_1.HistoryOriginalIdColumn)(),
92
+ tslib_1.__metadata("design:type", String)
93
+ ], AccountHistory.prototype, "originalId", void 0);
94
+ tslib_1.__decorate([
95
+ (0, typeorm_history_1.HistoryActionColumn)({
96
+ nullable: false,
97
+ type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
98
+ ? 'enum'
99
+ : DATABASE_TYPE == 'oracle'
100
+ ? 'varchar2'
101
+ : 'smallint',
102
+ enum: typeorm_history_1.HistoryActionType
103
+ }),
104
+ tslib_1.__metadata("design:type", String)
105
+ ], AccountHistory.prototype, "action", void 0);
106
+ AccountHistory = tslib_1.__decorate([
107
+ (0, typeorm_1.Entity)(),
108
+ (0, typeorm_1.Index)('ix_account_history_0', (accountHistory) => [accountHistory.originalId, accountHistory.version], { unique: true }),
109
+ (0, typeorm_1.Index)('ix_account_history_1', (accountHistory) => [accountHistory.domain, accountHistory.originalId, accountHistory.version], { unique: true }),
110
+ (0, type_graphql_1.ObjectType)({ description: 'History Entity of Account' })
111
+ ], AccountHistory);
112
+ exports.AccountHistory = AccountHistory;
113
+ //# sourceMappingURL=account-history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-history.js","sourceRoot":"","sources":["../../../server/service/account/account-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAA8F;AAE9F,8DAKiC;AACjC,yDAAsD;AACtD,6CAA4C;AAC5C,iDAA8C;AAI9C,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAc7B,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QAOL,YAAO,GAAY,CAAC,CAAA;IAiEtB,CAAC;CAAA,CAAA;AAvEC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;0CACC;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,C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EAAE,CACjB;IACA,IAAA,eAAK,EACJ,sBAAsB,EACtB,CAAC,cAA8B,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,EAC9G,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;GAC5C,cAAc,CAwE1B;AAxEY,wCAAc","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport {\n HistoryActionColumn,\n HistoryActionType,\n HistoryEntityInterface,\n HistoryOriginalIdColumn\n} from '@operato/typeorm-history'\nimport { Role, User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { Account } from './account'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index(\n 'ix_account_history_0',\n (accountHistory: AccountHistory) => [accountHistory.originalId, accountHistory.version],\n { unique: true }\n)\n@Index(\n 'ix_account_history_1',\n (accountHistory: AccountHistory) => [accountHistory.domain, accountHistory.originalId, accountHistory.version],\n { unique: true }\n)\n@ObjectType({ description: 'History Entity of Account' })\nexport class AccountHistory implements HistoryEntityInterface<Account> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: true, default: 1 })\n @Field({ nullable: true })\n version?: number = 1\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain?: Domain\n\n @RelationId((account: Account) => account.domain)\n domainId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n controlNumber?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n name?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n description?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n active?: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n updatedAt?: Date\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator?: User\n\n @RelationId((account: Account) => account.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater?: User\n\n @RelationId((account: Account) => account.updater)\n updaterId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: HistoryActionType\n })\n public action!: HistoryActionType\n}\n"]}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const attachment_base_1 = require("@things-factory/attachment-base");
8
+ const account_1 = require("./account");
9
+ const account_type_1 = require("./account-type");
10
+ let AccountMutation = class AccountMutation {
11
+ async createAccount(account, context) {
12
+ const { domain, user, tx } = context.state;
13
+ const result = await tx.getRepository(account_1.Account).save(Object.assign(Object.assign({}, account), { domain, creator: user, updater: user }));
14
+ return result;
15
+ }
16
+ async updateAccount(id, patch, context) {
17
+ const { domain, user, tx } = context.state;
18
+ const repository = tx.getRepository(account_1.Account);
19
+ const account = await repository.findOne({
20
+ where: { domain: { id: domain.id }, id }
21
+ });
22
+ const result = await repository.save(Object.assign(Object.assign(Object.assign({}, account), patch), { updater: user }));
23
+ return result;
24
+ }
25
+ async updateMultipleAccount(patches, context) {
26
+ const { domain, user, tx } = context.state;
27
+ let results = [];
28
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
29
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
30
+ const accountRepo = tx.getRepository(account_1.Account);
31
+ if (_createRecords.length > 0) {
32
+ for (let i = 0; i < _createRecords.length; i++) {
33
+ const newRecord = _createRecords[i];
34
+ const result = await accountRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
35
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
36
+ }
37
+ }
38
+ if (_updateRecords.length > 0) {
39
+ for (let i = 0; i < _updateRecords.length; i++) {
40
+ const updateRecord = _updateRecords[i];
41
+ const account = await accountRepo.findOneBy({ id: updateRecord.id });
42
+ const result = await accountRepo.save(Object.assign(Object.assign(Object.assign({}, account), updateRecord), { updater: user }));
43
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
44
+ }
45
+ }
46
+ return results;
47
+ }
48
+ async deleteAccount(id, context) {
49
+ const { domain, tx } = context.state;
50
+ await tx.getRepository(account_1.Account).delete({ domain: { id: domain.id }, id });
51
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
52
+ return true;
53
+ }
54
+ async deleteAccounts(ids, context) {
55
+ const { domain, tx } = context.state;
56
+ await tx.getRepository(account_1.Account).delete({
57
+ domain: { id: domain.id },
58
+ id: (0, typeorm_1.In)(ids)
59
+ });
60
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
61
+ return true;
62
+ }
63
+ async importAccounts(accounts, context) {
64
+ const { domain, tx } = context.state;
65
+ await Promise.all(accounts.map(async (account) => {
66
+ const createdAccount = await tx.getRepository(account_1.Account).save(Object.assign({ domain }, account));
67
+ }));
68
+ return true;
69
+ }
70
+ };
71
+ tslib_1.__decorate([
72
+ (0, type_graphql_1.Directive)('@transaction'),
73
+ (0, type_graphql_1.Mutation)(returns => account_1.Account, { description: 'To create new Account' }),
74
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('account')),
75
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
76
+ tslib_1.__metadata("design:type", Function),
77
+ tslib_1.__metadata("design:paramtypes", [account_type_1.NewAccount, Object]),
78
+ tslib_1.__metadata("design:returntype", Promise)
79
+ ], AccountMutation.prototype, "createAccount", null);
80
+ tslib_1.__decorate([
81
+ (0, type_graphql_1.Directive)('@transaction'),
82
+ (0, type_graphql_1.Mutation)(returns => account_1.Account, { description: 'To modify Account information' }),
83
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
84
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
85
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
86
+ tslib_1.__metadata("design:type", Function),
87
+ tslib_1.__metadata("design:paramtypes", [String, account_type_1.AccountPatch, Object]),
88
+ tslib_1.__metadata("design:returntype", Promise)
89
+ ], AccountMutation.prototype, "updateAccount", null);
90
+ tslib_1.__decorate([
91
+ (0, type_graphql_1.Directive)('@transaction'),
92
+ (0, type_graphql_1.Mutation)(returns => [account_1.Account], { description: "To modify multiple Accounts' information" }),
93
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [account_type_1.AccountPatch])),
94
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
95
+ tslib_1.__metadata("design:type", Function),
96
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
97
+ tslib_1.__metadata("design:returntype", Promise)
98
+ ], AccountMutation.prototype, "updateMultipleAccount", null);
99
+ tslib_1.__decorate([
100
+ (0, type_graphql_1.Directive)('@transaction'),
101
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete Account' }),
102
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
103
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
104
+ tslib_1.__metadata("design:type", Function),
105
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
106
+ tslib_1.__metadata("design:returntype", Promise)
107
+ ], AccountMutation.prototype, "deleteAccount", null);
108
+ tslib_1.__decorate([
109
+ (0, type_graphql_1.Directive)('@transaction'),
110
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Accounts' }),
111
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
112
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
113
+ tslib_1.__metadata("design:type", Function),
114
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
115
+ tslib_1.__metadata("design:returntype", Promise)
116
+ ], AccountMutation.prototype, "deleteAccounts", null);
117
+ tslib_1.__decorate([
118
+ (0, type_graphql_1.Directive)('@transaction'),
119
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To import multiple Accounts' }),
120
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('accounts', type => [account_type_1.AccountPatch])),
121
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
122
+ tslib_1.__metadata("design:type", Function),
123
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
124
+ tslib_1.__metadata("design:returntype", Promise)
125
+ ], AccountMutation.prototype, "importAccounts", null);
126
+ AccountMutation = tslib_1.__decorate([
127
+ (0, type_graphql_1.Resolver)(account_1.Account)
128
+ ], AccountMutation);
129
+ exports.AccountMutation = AccountMutation;
130
+ //# sourceMappingURL=account-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-mutation.js","sourceRoot":"","sources":["../../../server/service/account/account-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,uCAAmC;AACnC,iDAAyD;AAGlD,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,iBAAO,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;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAE1E,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,2BAAY,CAAC,CAAC,CAAA;IACvC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;qDAWP;AA9HU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CA+H3B;AA/HY,0CAAe","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { Account } from './account'\nimport { NewAccount, AccountPatch } from './account-type'\n\n@Resolver(Account)\nexport class AccountMutation {\n @Directive('@transaction')\n @Mutation(returns => Account, { description: 'To create new Account' })\n async createAccount(@Arg('account') account: NewAccount, @Ctx() context: ResolverContext): Promise<Account> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(Account).save({\n ...account,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Account, { description: 'To modify Account information' })\n async updateAccount(\n @Arg('id') id: string,\n @Arg('patch') patch: AccountPatch,\n @Ctx() context: ResolverContext\n ): Promise<Account> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Account)\n const account = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...account,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Account], { description: \"To modify multiple Accounts' information\" })\n async updateMultipleAccount(\n @Arg('patches', type => [AccountPatch]) patches: AccountPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Account[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const accountRepo = tx.getRepository(Account)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await accountRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const account = await accountRepo.findOneBy({ id: updateRecord.id })\n\n const result = await accountRepo.save({\n ...account,\n ...updateRecord,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Account' })\n async deleteAccount(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Account).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Accounts' })\n async deleteAccounts(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Account).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple Accounts' })\n async importAccounts(\n @Arg('accounts', type => [AccountPatch]) accounts: AccountPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n accounts.map(async (account: AccountPatch) => {\n const createdAccount: Account = await tx.getRepository(Account).save({ domain, ...account })\n })\n )\n\n return true\n }\n}\n"]}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountQuery = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const auth_base_1 = require("@things-factory/auth-base");
8
+ const account_1 = require("./account");
9
+ const account_type_1 = require("./account-type");
10
+ let AccountQuery = class AccountQuery {
11
+ async account(id, context) {
12
+ const { domain } = context.state;
13
+ return await (0, shell_1.getRepository)(account_1.Account).findOne({
14
+ where: { domain: { id: domain.id }, id }
15
+ });
16
+ }
17
+ async accounts(params, context) {
18
+ const { domain } = context.state;
19
+ const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
20
+ domain,
21
+ params,
22
+ repository: await (0, shell_1.getRepository)(account_1.Account),
23
+ searchables: ['name', 'description']
24
+ });
25
+ const [items, total] = await queryBuilder.getManyAndCount();
26
+ return { items, total };
27
+ }
28
+ async domain(account) {
29
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: account.domainId });
30
+ }
31
+ async updater(account) {
32
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: account.updaterId });
33
+ }
34
+ async creator(account) {
35
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: account.creatorId });
36
+ }
37
+ };
38
+ tslib_1.__decorate([
39
+ (0, type_graphql_1.Query)(returns => account_1.Account, { nullable: true, description: 'To fetch a Account' }),
40
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
41
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
42
+ tslib_1.__metadata("design:type", Function),
43
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
44
+ tslib_1.__metadata("design:returntype", Promise)
45
+ ], AccountQuery.prototype, "account", null);
46
+ tslib_1.__decorate([
47
+ (0, type_graphql_1.Query)(returns => account_type_1.AccountList, { description: 'To fetch multiple Accounts' }),
48
+ tslib_1.__param(0, (0, type_graphql_1.Args)()),
49
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
50
+ tslib_1.__metadata("design:type", Function),
51
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
52
+ tslib_1.__metadata("design:returntype", Promise)
53
+ ], AccountQuery.prototype, "accounts", null);
54
+ tslib_1.__decorate([
55
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
56
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
57
+ tslib_1.__metadata("design:type", Function),
58
+ tslib_1.__metadata("design:paramtypes", [account_1.Account]),
59
+ tslib_1.__metadata("design:returntype", Promise)
60
+ ], AccountQuery.prototype, "domain", null);
61
+ tslib_1.__decorate([
62
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
63
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
64
+ tslib_1.__metadata("design:type", Function),
65
+ tslib_1.__metadata("design:paramtypes", [account_1.Account]),
66
+ tslib_1.__metadata("design:returntype", Promise)
67
+ ], AccountQuery.prototype, "updater", null);
68
+ tslib_1.__decorate([
69
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
70
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
71
+ tslib_1.__metadata("design:type", Function),
72
+ tslib_1.__metadata("design:paramtypes", [account_1.Account]),
73
+ tslib_1.__metadata("design:returntype", Promise)
74
+ ], AccountQuery.prototype, "creator", null);
75
+ AccountQuery = tslib_1.__decorate([
76
+ (0, type_graphql_1.Resolver)(account_1.Account)
77
+ ], AccountQuery);
78
+ exports.AccountQuery = AccountQuery;
79
+ //# sourceMappingURL=account-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-query.js","sourceRoot":"","sources":["../../../server/service/account/account-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,iDAAuG;AACvG,yDAAgD;AAChD,uCAAmC;AACnC,iDAA4C;AAGrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEjB,AAAN,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK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C,OAAO,CAAC,EAAE,CAAC,iBAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACnE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2CAM1C;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,0BAAW,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IAC7D,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;4CAavC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAvCU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CAwCxB;AAxCY,oCAAY","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Account } from './account'\nimport { AccountList } from './account-type'\n\n@Resolver(Account)\nexport class AccountQuery {\n @Query(returns => Account!, { nullable: true, description: 'To fetch a Account' })\n async account(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Account> {\n const { domain } = context.state\n\n return await getRepository(Account).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => AccountList, { description: 'To fetch multiple Accounts' })\n async accounts(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<AccountList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(Account),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() account: Account): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: account.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() account: Account): Promise<User> {\n return await getRepository(User).findOneBy({ id: account.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() account: Account): Promise<User> {\n return await getRepository(User).findOneBy({ id: account.creatorId })\n }\n}\n"]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountList = exports.AccountPatch = exports.NewAccount = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const account_1 = require("./account");
7
+ let NewAccount = class NewAccount {
8
+ };
9
+ tslib_1.__decorate([
10
+ (0, type_graphql_1.Field)(),
11
+ tslib_1.__metadata("design:type", String)
12
+ ], NewAccount.prototype, "name", void 0);
13
+ tslib_1.__decorate([
14
+ (0, type_graphql_1.Field)({ nullable: true }),
15
+ tslib_1.__metadata("design:type", String)
16
+ ], NewAccount.prototype, "description", void 0);
17
+ tslib_1.__decorate([
18
+ (0, type_graphql_1.Field)({ nullable: true }),
19
+ tslib_1.__metadata("design:type", Boolean)
20
+ ], NewAccount.prototype, "active", void 0);
21
+ NewAccount = tslib_1.__decorate([
22
+ (0, type_graphql_1.InputType)()
23
+ ], NewAccount);
24
+ exports.NewAccount = NewAccount;
25
+ let AccountPatch = class AccountPatch {
26
+ };
27
+ tslib_1.__decorate([
28
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], AccountPatch.prototype, "id", void 0);
31
+ tslib_1.__decorate([
32
+ (0, type_graphql_1.Field)({ nullable: true }),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], AccountPatch.prototype, "name", void 0);
35
+ tslib_1.__decorate([
36
+ (0, type_graphql_1.Field)({ nullable: true }),
37
+ tslib_1.__metadata("design:type", String)
38
+ ], AccountPatch.prototype, "description", void 0);
39
+ tslib_1.__decorate([
40
+ (0, type_graphql_1.Field)({ nullable: true }),
41
+ tslib_1.__metadata("design:type", Boolean)
42
+ ], AccountPatch.prototype, "active", void 0);
43
+ tslib_1.__decorate([
44
+ (0, type_graphql_1.Field)({ nullable: true }),
45
+ tslib_1.__metadata("design:type", String)
46
+ ], AccountPatch.prototype, "cuFlag", void 0);
47
+ AccountPatch = tslib_1.__decorate([
48
+ (0, type_graphql_1.InputType)()
49
+ ], AccountPatch);
50
+ exports.AccountPatch = AccountPatch;
51
+ let AccountList = class AccountList {
52
+ };
53
+ tslib_1.__decorate([
54
+ (0, type_graphql_1.Field)(type => [account_1.Account]),
55
+ tslib_1.__metadata("design:type", Array)
56
+ ], AccountList.prototype, "items", void 0);
57
+ tslib_1.__decorate([
58
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
59
+ tslib_1.__metadata("design:type", Number)
60
+ ], AccountList.prototype, "total", void 0);
61
+ AccountList = tslib_1.__decorate([
62
+ (0, type_graphql_1.ObjectType)()
63
+ ], AccountList);
64
+ exports.AccountList = AccountList;
65
+ //# sourceMappingURL=account-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-type.js","sourceRoot":"","sources":["../../../server/service/account/account-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AAItF,uCAAmC;AAG5B,IAAM,UAAU,GAAhB,MAAM,UAAU;CAStB,CAAA;AARC;IAAC,IAAA,oBAAK,GAAE;;wCACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACV;AARL,UAAU;IADtB,IAAA,wBAAS,GAAE;GACC,UAAU,CAStB;AATY,gCAAU;AAYhB,IAAM,YAAY,GAAlB,MAAM,YAAY;CAexB,CAAA;AAdC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;wCAC3B;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACb;AAEb;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACV;AAEhB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACX;AAdJ,YAAY;IADxB,IAAA,wBAAS,GAAE;GACC,YAAY,CAexB;AAfY,oCAAY;AAkBlB,IAAM,WAAW,GAAjB,MAAM,WAAW;CAMvB,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,iBAAO,CAAC,CAAC;;0CACT;AAEhB;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;0CACN;AALF,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAMvB;AANY,kCAAW","sourcesContent":["import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'\n\nimport { ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Account } from './account'\n\n@InputType()\nexport class NewAccount {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n active?: boolean\n}\n\n@InputType()\nexport class AccountPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class AccountList {\n @Field(type => [Account])\n items: Account[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Account = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typeorm_1 = require("typeorm");
6
+ const type_graphql_1 = require("type-graphql");
7
+ const shell_1 = require("@things-factory/shell");
8
+ const auth_base_1 = require("@things-factory/auth-base");
9
+ const accounting_category_1 = require("../accounting-category/accounting-category");
10
+ let Account = class Account {
11
+ constructor() {
12
+ this.version = 1;
13
+ }
14
+ };
15
+ tslib_1.__decorate([
16
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
17
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
18
+ tslib_1.__metadata("design:type", String)
19
+ ], Account.prototype, "id", void 0);
20
+ tslib_1.__decorate([
21
+ (0, typeorm_1.VersionColumn)(),
22
+ (0, type_graphql_1.Field)({ nullable: true }),
23
+ tslib_1.__metadata("design:type", Number)
24
+ ], Account.prototype, "version", void 0);
25
+ tslib_1.__decorate([
26
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
27
+ (0, type_graphql_1.Field)({ nullable: true }),
28
+ tslib_1.__metadata("design:type", shell_1.Domain)
29
+ ], Account.prototype, "domain", void 0);
30
+ tslib_1.__decorate([
31
+ (0, typeorm_1.RelationId)((account) => account.domain),
32
+ tslib_1.__metadata("design:type", String)
33
+ ], Account.prototype, "domainId", void 0);
34
+ tslib_1.__decorate([
35
+ (0, typeorm_1.Column)(),
36
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Account control number' }),
37
+ tslib_1.__metadata("design:type", String)
38
+ ], Account.prototype, "controlNumber", void 0);
39
+ tslib_1.__decorate([
40
+ (0, typeorm_1.Column)(),
41
+ (0, type_graphql_1.Field)({ nullable: true, description: 'Account name' }),
42
+ tslib_1.__metadata("design:type", String)
43
+ ], Account.prototype, "name", void 0);
44
+ tslib_1.__decorate([
45
+ (0, typeorm_1.Column)({ nullable: true }),
46
+ (0, type_graphql_1.Field)({ nullable: true }),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], Account.prototype, "description", void 0);
49
+ tslib_1.__decorate([
50
+ (0, typeorm_1.Column)({ nullable: true }),
51
+ (0, type_graphql_1.Field)({ nullable: true }),
52
+ tslib_1.__metadata("design:type", Boolean)
53
+ ], Account.prototype, "active", void 0);
54
+ tslib_1.__decorate([
55
+ (0, typeorm_1.Column)({ nullable: true }),
56
+ (0, type_graphql_1.Field)(type => accounting_category_1.AccountingCategory, { nullable: true }),
57
+ tslib_1.__metadata("design:type", accounting_category_1.AccountingCategory)
58
+ ], Account.prototype, "category", void 0);
59
+ tslib_1.__decorate([
60
+ (0, typeorm_1.RelationId)((account) => account.category),
61
+ tslib_1.__metadata("design:type", String)
62
+ ], Account.prototype, "categoryId", void 0);
63
+ tslib_1.__decorate([
64
+ (0, typeorm_1.CreateDateColumn)(),
65
+ (0, type_graphql_1.Field)({ nullable: true }),
66
+ tslib_1.__metadata("design:type", Date)
67
+ ], Account.prototype, "createdAt", void 0);
68
+ tslib_1.__decorate([
69
+ (0, typeorm_1.UpdateDateColumn)(),
70
+ (0, type_graphql_1.Field)({ nullable: true }),
71
+ tslib_1.__metadata("design:type", Date)
72
+ ], Account.prototype, "updatedAt", void 0);
73
+ tslib_1.__decorate([
74
+ (0, typeorm_1.DeleteDateColumn)(),
75
+ (0, type_graphql_1.Field)({ nullable: true }),
76
+ tslib_1.__metadata("design:type", Date)
77
+ ], Account.prototype, "deletedAt", void 0);
78
+ tslib_1.__decorate([
79
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
80
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
81
+ tslib_1.__metadata("design:type", auth_base_1.User)
82
+ ], Account.prototype, "creator", void 0);
83
+ tslib_1.__decorate([
84
+ (0, typeorm_1.RelationId)((account) => account.creator),
85
+ tslib_1.__metadata("design:type", String)
86
+ ], Account.prototype, "creatorId", void 0);
87
+ tslib_1.__decorate([
88
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
89
+ (0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
90
+ tslib_1.__metadata("design:type", auth_base_1.User)
91
+ ], Account.prototype, "updater", void 0);
92
+ tslib_1.__decorate([
93
+ (0, typeorm_1.RelationId)((account) => account.updater),
94
+ tslib_1.__metadata("design:type", String)
95
+ ], Account.prototype, "updaterId", void 0);
96
+ Account = tslib_1.__decorate([
97
+ (0, typeorm_1.Entity)(),
98
+ (0, typeorm_1.Index)('ix_account_0', (account) => [account.domain, account.name, account.deletedAt], { unique: true }),
99
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for Account' })
100
+ ], Account);
101
+ exports.Account = Account;
102
+ //# sourceMappingURL=account.js.map