@things-factory/integration-accounting 5.0.7 → 6.0.0-alpha.0

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 (118) hide show
  1. package/dist-server/controllers/accounting-api/decorators.js +2 -4
  2. package/dist-server/controllers/accounting-api/decorators.js.map +1 -1
  3. package/dist-server/controllers/accounting-api/index.js +55 -63
  4. package/dist-server/controllers/accounting-api/index.js.map +1 -1
  5. package/dist-server/controllers/index.js +2 -15
  6. package/dist-server/controllers/index.js.map +1 -1
  7. package/dist-server/controllers/xero/apis/contact/get-contact.js.map +1 -1
  8. package/dist-server/controllers/xero/apis/contact/get-contacts.js.map +1 -1
  9. package/dist-server/controllers/xero/apis/contact/index.js +3 -16
  10. package/dist-server/controllers/xero/apis/contact/index.js.map +1 -1
  11. package/dist-server/controllers/xero/apis/index.js +5 -18
  12. package/dist-server/controllers/xero/apis/index.js.map +1 -1
  13. package/dist-server/controllers/xero/apis/invoice/create-invoice.js.map +1 -1
  14. package/dist-server/controllers/xero/apis/invoice/get-invoice.js.map +1 -1
  15. package/dist-server/controllers/xero/apis/invoice/get-invoices.js.map +1 -1
  16. package/dist-server/controllers/xero/apis/invoice/index.js +5 -18
  17. package/dist-server/controllers/xero/apis/invoice/index.js.map +1 -1
  18. package/dist-server/controllers/xero/apis/invoice/update-invoice.js.map +1 -1
  19. package/dist-server/controllers/xero/apis/item/create-item.js.map +1 -1
  20. package/dist-server/controllers/xero/apis/item/delete-item.js.map +1 -1
  21. package/dist-server/controllers/xero/apis/item/get-item.js.map +1 -1
  22. package/dist-server/controllers/xero/apis/item/get-items.js.map +1 -1
  23. package/dist-server/controllers/xero/apis/item/index.js +7 -20
  24. package/dist-server/controllers/xero/apis/item/index.js.map +1 -1
  25. package/dist-server/controllers/xero/apis/item/update-item.js.map +1 -1
  26. package/dist-server/controllers/xero/apis/item/update-items.js.map +1 -1
  27. package/dist-server/controllers/xero/apis/purchase-order/get-purchase-orders.js.map +1 -1
  28. package/dist-server/controllers/xero/apis/purchase-order/index.js +2 -15
  29. package/dist-server/controllers/xero/apis/purchase-order/index.js.map +1 -1
  30. package/dist-server/controllers/xero/index.js +3 -28
  31. package/dist-server/controllers/xero/index.js.map +1 -1
  32. package/dist-server/controllers/xero/platform-action.js.map +1 -1
  33. package/dist-server/controllers/xero/xero.js +4 -6
  34. package/dist-server/controllers/xero/xero.js.map +1 -1
  35. package/dist-server/engine/connector/accounting-connector.js.map +1 -1
  36. package/dist-server/engine/connector/index.js.map +1 -1
  37. package/dist-server/engine/index.js.map +1 -1
  38. package/dist-server/engine/task/accounting-api.js +3 -3
  39. package/dist-server/engine/task/accounting-api.js.map +1 -1
  40. package/dist-server/engine/task/index.js.map +1 -1
  41. package/dist-server/entities/account.js +40 -49
  42. package/dist-server/entities/account.js.map +1 -1
  43. package/dist-server/entities/index.js.map +1 -1
  44. package/dist-server/graphql/index.js +3 -25
  45. package/dist-server/graphql/index.js.map +1 -1
  46. package/dist-server/graphql/resolvers/accounting/account.js +4 -4
  47. package/dist-server/graphql/resolvers/accounting/account.js.map +1 -1
  48. package/dist-server/graphql/resolvers/accounting/accounts.js +1 -2
  49. package/dist-server/graphql/resolvers/accounting/accounts.js.map +1 -1
  50. package/dist-server/graphql/resolvers/accounting/create-account.js +4 -3
  51. package/dist-server/graphql/resolvers/accounting/create-account.js.map +1 -1
  52. package/dist-server/graphql/resolvers/accounting/delete-account.js +5 -5
  53. package/dist-server/graphql/resolvers/accounting/delete-account.js.map +1 -1
  54. package/dist-server/graphql/resolvers/accounting/delete-accounts.js +5 -4
  55. package/dist-server/graphql/resolvers/accounting/delete-accounts.js.map +1 -1
  56. package/dist-server/graphql/resolvers/accounting/index.js +2 -24
  57. package/dist-server/graphql/resolvers/accounting/index.js.map +1 -1
  58. package/dist-server/graphql/resolvers/accounting/update-account.js +3 -3
  59. package/dist-server/graphql/resolvers/accounting/update-account.js.map +1 -1
  60. package/dist-server/graphql/resolvers/accounting/update-multiple-accounts.js +3 -3
  61. package/dist-server/graphql/resolvers/accounting/update-multiple-accounts.js.map +1 -1
  62. package/dist-server/graphql/resolvers/accounting/xero/deactivate-xero-account.js +6 -8
  63. package/dist-server/graphql/resolvers/accounting/xero/deactivate-xero-account.js.map +1 -1
  64. package/dist-server/graphql/resolvers/accounting/xero/get-xero-auth-url.js +5 -7
  65. package/dist-server/graphql/resolvers/accounting/xero/get-xero-auth-url.js.map +1 -1
  66. package/dist-server/graphql/resolvers/accounting/xero/index.js.map +1 -1
  67. package/dist-server/graphql/resolvers/accounting/xero/refresh-xero-access-token.js +7 -9
  68. package/dist-server/graphql/resolvers/accounting/xero/refresh-xero-access-token.js.map +1 -1
  69. package/dist-server/graphql/resolvers/accounting-api/accounting-invoice.js.map +1 -1
  70. package/dist-server/graphql/resolvers/accounting-api/accounting-item.js.map +1 -1
  71. package/dist-server/graphql/resolvers/accounting-api/accounting-purchase-order.js.map +1 -1
  72. package/dist-server/graphql/resolvers/accounting-api/index.js.map +1 -1
  73. package/dist-server/graphql/resolvers/index.js +2 -24
  74. package/dist-server/graphql/resolvers/index.js.map +1 -1
  75. package/dist-server/graphql/types/accounting/account-list.js +2 -4
  76. package/dist-server/graphql/types/accounting/account-list.js.map +1 -1
  77. package/dist-server/graphql/types/accounting/account-patch.js +2 -4
  78. package/dist-server/graphql/types/accounting/account-patch.js.map +1 -1
  79. package/dist-server/graphql/types/accounting/account.js +2 -4
  80. package/dist-server/graphql/types/accounting/account.js.map +1 -1
  81. package/dist-server/graphql/types/accounting/index.js.map +1 -1
  82. package/dist-server/graphql/types/accounting/new-account.js +2 -4
  83. package/dist-server/graphql/types/accounting/new-account.js.map +1 -1
  84. package/dist-server/graphql/types/accounting-api/invoice.js +2 -4
  85. package/dist-server/graphql/types/accounting-api/invoice.js.map +1 -1
  86. package/dist-server/graphql/types/accounting-api/item.js +2 -4
  87. package/dist-server/graphql/types/accounting-api/item.js.map +1 -1
  88. package/dist-server/graphql/types/accounting-api/purchase-order.js +2 -4
  89. package/dist-server/graphql/types/accounting-api/purchase-order.js.map +1 -1
  90. package/dist-server/graphql/types/index.js +5 -27
  91. package/dist-server/graphql/types/index.js.map +1 -1
  92. package/dist-server/index.js +5 -18
  93. package/dist-server/index.js.map +1 -1
  94. package/dist-server/migrations/index.js.map +1 -1
  95. package/dist-server/routers/xero-private-router.js +2 -4
  96. package/dist-server/routers/xero-private-router.js.map +1 -1
  97. package/dist-server/routers/xero-router.js +6 -9
  98. package/dist-server/routers/xero-router.js.map +1 -1
  99. package/dist-server/routes.js.map +1 -1
  100. package/dist-server/tsconfig.tsbuildinfo +1 -0
  101. package/package.json +16 -16
  102. package/server/controllers/accounting-api/index.ts +1 -1
  103. package/server/controllers/xero/xero.ts +1 -1
  104. package/server/engine/task/accounting-api.ts +3 -2
  105. package/server/graphql/resolvers/accounting/account.ts +4 -3
  106. package/server/graphql/resolvers/accounting/accounts.ts +2 -4
  107. package/server/graphql/resolvers/accounting/create-account.ts +9 -6
  108. package/server/graphql/resolvers/accounting/delete-account.ts +5 -4
  109. package/server/graphql/resolvers/accounting/delete-accounts.ts +7 -4
  110. package/server/graphql/resolvers/accounting/update-account.ts +4 -3
  111. package/server/graphql/resolvers/accounting/update-multiple-accounts.ts +4 -3
  112. package/server/graphql/resolvers/accounting/xero/deactivate-xero-account.ts +6 -4
  113. package/server/graphql/resolvers/accounting/xero/get-xero-auth-url.ts +6 -4
  114. package/server/graphql/resolvers/accounting/xero/refresh-xero-access-token.ts +7 -5
  115. package/server/graphql/resolvers/accounting-api/accounting-invoice.ts +9 -9
  116. package/server/graphql/resolvers/accounting-api/accounting-item.ts +11 -12
  117. package/server/graphql/resolvers/accounting-api/accounting-purchase-order.ts +1 -1
  118. package/server/routers/xero-router.ts +2 -3
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.Xero = void 0;
7
- const node_fetch_1 = __importDefault(require("node-fetch"));
8
- const typeorm_1 = require("typeorm");
4
+ const tslib_1 = require("tslib");
5
+ const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
+ const shell_1 = require("@things-factory/shell");
9
7
  const utils_1 = require("@things-factory/utils");
10
8
  const account_1 = require("../../entities/account");
11
9
  const ENDPOINT = 'https://api.xero.com/api.xro/2.0';
@@ -149,7 +147,7 @@ class Xero {
149
147
  tokenType,
150
148
  expiresIn: new Date(exp * 1000)
151
149
  };
152
- const repository = (0, typeorm_1.getRepository)(account_1.Account);
150
+ const repository = (0, shell_1.getRepository)(account_1.Account);
153
151
  return await repository.save(Object.assign(Object.assign({}, account), patch));
154
152
  }
155
153
  }
@@ -1 +1 @@
1
- {"version":3,"file":"xero.js","sourceRoot":"","sources":["../../../server/controllers/xero/xero.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAC9B,qCAAuC;AAEvC,iDAAgD;AAEhD,oDAAgD;AAEhD,MAAM,QAAQ,GAAG,kCAAkC,CAAA;AACnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4CAA4C,CAAC,CAAA;AAU5E,MAAa,IAAI;IAGf,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED,YAAY,CAAC,KAAK;QAChB,MAAM,MAAM,GAAG,qGAAqG,CAAA;QACpH,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAErD,OAAO,kFAAkF,MAAM,UAAU,MAAM,iBAAiB,WAAW,UAAU,KAAK,EAAE,CAAA;IAC9J,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,IAAS;QAC/B,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE7C,MAAM,EAAE,GAAG,MAAM,CAAC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AAE,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;SAChC,CAAA;QAED,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAA;QAEzC,OAAO,MAAM,UAAU,CAAC,IAAI,iCACvB,OAAO,GACP,KAAK,EACR,CAAA;IACJ,CAAC;CACF;AApMD,oBAoMC","sourcesContent":["import fetch from 'node-fetch'\n\nimport { getRepository } from '@things-factory/shell'\nimport { parseJwt } from '@things-factory/utils'\n\nimport { Account } from '../../entities/account'\n\nconst ENDPOINT = 'https://api.xero.com/api.xro/2.0'\nconst debug = require('debug')('things-factory:integration-accounting:xero')\n\nexport type XeroConfig = {\n apiKey: string\n apiSecret: string\n accessToken?: string\n tenantId?: string\n callback?: string\n}\n\nexport class Xero {\n private config: XeroConfig\n\n constructor(config: XeroConfig) {\n this.config = {\n ...config\n }\n }\n\n buildAuthURL(nonce) {\n const scopes = 'offline_access openid profile email accounting.transactions accounting.settings accounting.contacts'\n const { apiKey, callback: redirectUrl } = this.config\n\n return `https://login.xero.com/identity/connect/authorize?response_type=code&client_id=${apiKey}&scope=${scopes}&redirect_uri=${redirectUrl}&state=${nonce}`\n }\n\n async get(path: string, data: any) {\n const { accessToken, tenantId } = this.config\n\n const qs = Object.entries(data)\n .map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)\n .join('&')\n\n const endpoint = `${ENDPOINT}${path}${qs ? '?' + qs : ''}`\n debug('endpoint', endpoint)\n\n const response = await fetch(endpoint, {\n method: 'get',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'xero-tenant-id': tenantId\n }\n })\n\n if (!response.ok) {\n throw response\n }\n\n let result = await response.json()\n debug('response result', result)\n result = this.convertStatusCode(result)\n\n return result\n }\n\n async post(path: string, data: any = {}) {\n const { accessToken, tenantId } = this.config\n\n debug('data', data)\n\n const jsondata = JSON.stringify(data)\n\n const endpoint = `${ENDPOINT}${path}`\n debug('endpoint', endpoint)\n\n const response = await fetch(endpoint, {\n method: 'post',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'xero-tenant-id': tenantId\n },\n body: jsondata\n })\n\n if (!response.ok) {\n throw response\n }\n\n let result = await response.json()\n debug('response result', result)\n result = this.convertStatusCode(result)\n\n return result\n }\n\n async put(path: string, data: any = {}) {\n const { accessToken, tenantId } = this.config\n\n debug('data', data)\n\n const jsondata = JSON.stringify(data)\n\n const endpoint = `${ENDPOINT}${path}`\n debug('endpoint', endpoint)\n\n const response = await fetch(endpoint, {\n method: 'put',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'xero-tenant-id': tenantId\n },\n body: jsondata\n })\n\n if (!response.ok) {\n throw response\n }\n\n let result = await response.json()\n debug('response result', result)\n result = this.convertStatusCode(result)\n\n return result\n }\n\n async delete(path: string, data: any = {}) {\n const { accessToken, tenantId } = this.config\n\n debug('data', data)\n\n const jsondata = JSON.stringify(data)\n\n const endpoint = `${ENDPOINT}${path}`\n debug('endpoint', endpoint)\n\n const response = await fetch(endpoint, {\n method: 'delete',\n headers: {\n accept: 'application/json',\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n 'xero-tenant-id': tenantId\n },\n body: jsondata\n })\n\n if (!response.ok) {\n throw response\n }\n\n let result = await response.json()\n debug('response result', result)\n result = this.convertStatusCode(result)\n\n return result\n }\n\n private convertStatusCode(result: Record<string, any>): Record<string, any> {\n result.ok = result.Status.toLowerCase() === 'ok'\n return result\n }\n\n public static async refreshAccessToken(apiKey, apiSecret, account) {\n const refreshRequestData = {\n grant_type: 'refresh_token',\n refresh_token: account.refreshToken\n }\n\n const refreshResponse = await fetch(`https://identity.xero.com/connect/token`, {\n method: 'post',\n headers: {\n Authorization: `Basic ${Buffer.from(apiKey + ':' + apiSecret).toString('base64')}`,\n 'Content-Type': 'application/x-www-form-urlencoded'\n },\n body: Object.entries(refreshRequestData)\n .map(([key, value]) => encodeURIComponent(key) + '=' + encodeURIComponent(value))\n .join('&')\n })\n\n if (!refreshResponse.ok) {\n throw new Error(`get account information failed: ${await refreshResponse.text()}`)\n }\n\n const body = await refreshResponse.json()\n const {\n access_token /* token used to call the API */,\n id_token /* token containing user identity details (only returned if OpenID Connect scopes are requested) */,\n expires_in /* amount of seconds until the access token expires */,\n token_type: tokenType /* must be Bearer */,\n refresh_token\n /* token used to refresh the access token once it has expired (only returned if the offline_access scope is requested).\n */\n } = body\n\n const { exp } = parseJwt(access_token)\n\n var patch = {\n accessToken: access_token,\n refreshToken: refresh_token,\n tokenType,\n expiresIn: new Date(exp * 1000)\n }\n\n const repository = getRepository(Account)\n\n return await repository.save({\n ...account,\n ...patch\n })\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/accounting-connector.ts"],"names":[],"mappings":";;;AAAA,uEAA+E;AAE/E,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAU;QACtB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAA;QAE7C,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,oBAAO,UAAU,EAAG,CAAA;QAEtE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CAAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;CACF;AA5BD,kDA4BC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA"}
1
+ {"version":3,"file":"accounting-connector.js","sourceRoot":"","sources":["../../../server/engine/connector/accounting-connector.ts"],"names":[],"mappings":";;;AAAA,uEAA+E;AAE/E,MAAa,mBAAmB;IAC9B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;IAC7E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,UAAU;QACtB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAA;QAE7C,oCAAiB,CAAC,qBAAqB,CAAC,UAAU,oBAAO,UAAU,EAAG,CAAA;QAEtE,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,IAAI,IAAI,UAAU,CAAC,QAAQ,gBAAgB,CAAC,CAAA;IAC/G,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAU;QACzB,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,aAAa;QACf,OAAO,EAAE,CAAA;IACX,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,YAAY,CAAC,CAAA;IACvB,CAAC;CACF;AA5BD,kDA4BC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,IAAI,mBAAmB,EAAE,CAAC,CAAA","sourcesContent":["import { ConnectionManager, Connector } from '@things-factory/integration-base'\n\nexport class AccountingConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('accounting-connector connections are ready')\n }\n\n async connect(connection) {\n const { domain, name, endpoint } = connection\n\n ConnectionManager.addConnectionInstance(connection, { ...connection })\n\n ConnectionManager.logger.info(`accounting-connector connection(${name}:${connection.endpoint}) is connected`)\n }\n\n async disconnect(connection) {\n ConnectionManager.removeConnectionInstance(connection)\n\n ConnectionManager.logger.info(`accounting-connector connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return []\n }\n\n get taskPrefixes() {\n return ['accounting']\n }\n}\n\nConnectionManager.registerConnector('accounting-connector', new AccountingConnector())\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/connector/index.ts"],"names":[],"mappings":";;AAAA,kCAA+B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/connector/index.ts"],"names":[],"mappings":";;AAAA,kCAA+B","sourcesContent":["import './accounting-connector'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,uBAAoB;AACpB,kBAAe"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,uBAAoB;AACpB,kBAAe","sourcesContent":["import './connector'\nimport './task'\n"]}
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const integration_base_1 = require("@things-factory/integration-base");
4
+ const shell_1 = require("@things-factory/shell");
4
5
  const utils_1 = require("@things-factory/utils");
5
- const typeorm_1 = require("typeorm");
6
- const entities_1 = require("../../entities");
7
6
  const accounting_api_1 = require("../../controllers/accounting-api");
7
+ const entities_1 = require("../../entities");
8
8
  async function AccountingAPI(step, { logger, data, domain }) {
9
9
  var { connection, params: { account: name, api, accessor } } = step;
10
10
  var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection) || {};
@@ -14,7 +14,7 @@ async function AccountingAPI(step, { logger, data, domain }) {
14
14
  if (!api) {
15
15
  throw new Error(`no api defined`);
16
16
  }
17
- const repository = (0, typeorm_1.getRepository)(entities_1.Account);
17
+ const repository = (0, shell_1.getRepository)(entities_1.Account);
18
18
  const account = await repository.findOne({
19
19
  where: { domain: domain.id, name }
20
20
  });
@@ -1 +1 @@
1
- {"version":3,"file":"accounting-api.js","sourceRoot":"","sources":["../../../server/engine/task/accounting-api.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,iDAA8C;AAC9C,qCAAuC;AACvC,6CAAwC;AACxC,qEAAuE;AAEvE,KAAK,UAAU,aAAa,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IACzD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EACzC,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,EAAE,CAAA;IACpF,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,IAAI,CAAC,GAAG,EAAE;QACR,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAA;KAClC;IAED,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAA;IACzC,MAAM,OAAO,GAAY,MAAM,UAAU,CAAC,OAAO,CAAC;QAChD,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE;KACnC,CAAC,CAAA;IAEF,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;KACtC;IAED,IAAI,MAAM,GAAG,MAAM,8BAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;IAE5E,OAAO;QACL,IAAI,EAAE,MAAM;KACb,CAAA;AACH,CAAC;AAED,aAAa,CAAC,aAAa,GAAG;IAC5B;QACE,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE;YACR,SAAS,EAAE,UAAU;YACrB,QAAQ,EAAE,MAAM;SACjB;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,KAAK;QACZ,QAAQ,EAAE;YACR,OAAO,EAAE,CAAC,EAAE,EAAE,uBAAuB,CAAC;SACvC;KACF;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA"}
1
+ {"version":3,"file":"accounting-api.js","sourceRoot":"","sources":["../../../server/engine/task/accounting-api.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAClF,iDAAqD;AACrD,iDAA8C;AAE9C,qEAAuE;AACvE,6CAAwC;AAExC,KAAK,UAAU,aAAa,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IACzD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,EACzC,GA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U;KAClB;CACF,CAAA;AAED,+BAAY,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { getRepository } from '@things-factory/shell'\nimport { access } from '@things-factory/utils'\n\nimport { AccountingAPI as API } from '../../controllers/accounting-api'\nimport { Account } from '../../entities'\n\nasync function AccountingAPI(step, { logger, data, domain }) {\n var {\n connection,\n params: { account: name, api, accessor }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection) || {}\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n if (!api) {\n throw new Error(`no api defined`)\n }\n\n const repository = getRepository(Account)\n const account: Account = await repository.findOne({\n where: { domain: domain.id, name }\n })\n\n if (!account) {\n throw new Error(`no account defined`)\n }\n\n var result = await API[api](account, accessor ? access(accessor, data) : {})\n\n return {\n data: result\n }\n}\n\nAccountingAPI.parameterSpec = [\n {\n type: 'entity-selector',\n name: 'account',\n label: 'account',\n property: {\n queryName: 'accounts',\n valueKey: 'name'\n }\n },\n {\n type: 'select',\n name: 'api',\n label: 'api',\n property: {\n options: ['', 'getAccountingInvoices']\n }\n },\n {\n type: 'string',\n name: 'accessor',\n label: 'accessor'\n }\n]\n\nTaskRegistry.registerTaskHandler('accounting-api', AccountingAPI)\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,4BAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,4BAAyB","sourcesContent":["import './accounting-api'\n"]}
@@ -1,120 +1,111 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var _a, _b, _c;
12
2
  Object.defineProperty(exports, "__esModule", { value: true });
13
3
  exports.Account = void 0;
4
+ const tslib_1 = require("tslib");
14
5
  const auth_base_1 = require("@things-factory/auth-base");
15
6
  const shell_1 = require("@things-factory/shell");
16
7
  const typeorm_1 = require("typeorm");
17
8
  let Account = class Account {
18
9
  };
19
- __decorate([
10
+ tslib_1.__decorate([
20
11
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
21
- __metadata("design:type", String)
12
+ tslib_1.__metadata("design:type", String)
22
13
  ], Account.prototype, "id", void 0);
23
- __decorate([
14
+ tslib_1.__decorate([
24
15
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
25
- __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
16
+ tslib_1.__metadata("design:type", shell_1.Domain)
26
17
  ], Account.prototype, "domain", void 0);
27
- __decorate([
18
+ tslib_1.__decorate([
28
19
  (0, typeorm_1.Column)(),
29
- __metadata("design:type", String)
20
+ tslib_1.__metadata("design:type", String)
30
21
  ], Account.prototype, "platform", void 0);
31
- __decorate([
22
+ tslib_1.__decorate([
32
23
  (0, typeorm_1.Column)({
33
24
  nullable: true
34
25
  }),
35
- __metadata("design:type", String)
26
+ tslib_1.__metadata("design:type", String)
36
27
  ], Account.prototype, "accountId", void 0);
37
- __decorate([
28
+ tslib_1.__decorate([
38
29
  (0, typeorm_1.Column)(),
39
- __metadata("design:type", String)
30
+ tslib_1.__metadata("design:type", String)
40
31
  ], Account.prototype, "countryCode", void 0);
41
- __decorate([
32
+ tslib_1.__decorate([
42
33
  (0, typeorm_1.Column)({
43
34
  nullable: true
44
35
  }),
45
- __metadata("design:type", String)
36
+ tslib_1.__metadata("design:type", String)
46
37
  ], Account.prototype, "status", void 0);
47
- __decorate([
38
+ tslib_1.__decorate([
48
39
  (0, typeorm_1.Column)(),
49
- __metadata("design:type", String)
40
+ tslib_1.__metadata("design:type", String)
50
41
  ], Account.prototype, "name", void 0);
51
- __decorate([
42
+ tslib_1.__decorate([
52
43
  (0, typeorm_1.Column)({
53
44
  nullable: true
54
45
  }),
55
- __metadata("design:type", String)
46
+ tslib_1.__metadata("design:type", String)
56
47
  ], Account.prototype, "accessInfo", void 0);
57
- __decorate([
48
+ tslib_1.__decorate([
58
49
  (0, typeorm_1.Column)({
59
50
  nullable: true
60
51
  }),
61
- __metadata("design:type", String)
52
+ tslib_1.__metadata("design:type", String)
62
53
  ], Account.prototype, "accessToken", void 0);
63
- __decorate([
54
+ tslib_1.__decorate([
64
55
  (0, typeorm_1.Column)({ default: false, nullable: true }),
65
- __metadata("design:type", Boolean)
56
+ tslib_1.__metadata("design:type", Boolean)
66
57
  ], Account.prototype, "trackedInventory", void 0);
67
- __decorate([
58
+ tslib_1.__decorate([
68
59
  (0, typeorm_1.Column)({
69
60
  nullable: true
70
61
  }),
71
- __metadata("design:type", String)
62
+ tslib_1.__metadata("design:type", String)
72
63
  ], Account.prototype, "refreshToken", void 0);
73
- __decorate([
64
+ tslib_1.__decorate([
74
65
  (0, typeorm_1.Column)({
75
66
  nullable: true
76
67
  }),
77
- __metadata("design:type", Date)
68
+ tslib_1.__metadata("design:type", Date)
78
69
  ], Account.prototype, "expiresIn", void 0);
79
- __decorate([
70
+ tslib_1.__decorate([
80
71
  (0, typeorm_1.Column)({
81
72
  nullable: true
82
73
  }),
83
- __metadata("design:type", String)
74
+ tslib_1.__metadata("design:type", String)
84
75
  ], Account.prototype, "tokenType", void 0);
85
- __decorate([
76
+ tslib_1.__decorate([
86
77
  (0, typeorm_1.Column)({
87
78
  nullable: true
88
79
  }),
89
- __metadata("design:type", String)
80
+ tslib_1.__metadata("design:type", String)
90
81
  ], Account.prototype, "accountInfo", void 0);
91
- __decorate([
82
+ tslib_1.__decorate([
92
83
  (0, typeorm_1.Column)({
93
84
  nullable: true
94
85
  }),
95
- __metadata("design:type", String)
86
+ tslib_1.__metadata("design:type", String)
96
87
  ], Account.prototype, "description", void 0);
97
- __decorate([
88
+ tslib_1.__decorate([
98
89
  (0, typeorm_1.CreateDateColumn)(),
99
- __metadata("design:type", Date)
90
+ tslib_1.__metadata("design:type", Date)
100
91
  ], Account.prototype, "createdAt", void 0);
101
- __decorate([
92
+ tslib_1.__decorate([
102
93
  (0, typeorm_1.UpdateDateColumn)(),
103
- __metadata("design:type", Date)
94
+ tslib_1.__metadata("design:type", Date)
104
95
  ], Account.prototype, "updatedAt", void 0);
105
- __decorate([
96
+ tslib_1.__decorate([
106
97
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
107
98
  nullable: true
108
99
  }),
109
- __metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
100
+ tslib_1.__metadata("design:type", auth_base_1.User)
110
101
  ], Account.prototype, "creator", void 0);
111
- __decorate([
102
+ tslib_1.__decorate([
112
103
  (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
113
104
  nullable: true
114
105
  }),
115
- __metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
106
+ tslib_1.__metadata("design:type", auth_base_1.User)
116
107
  ], Account.prototype, "updater", void 0);
117
- Account = __decorate([
108
+ Account = tslib_1.__decorate([
118
109
  (0, typeorm_1.Entity)(),
119
110
  (0, typeorm_1.Index)('ix_account_0', (account) => [account.domain, account.name], { unique: true })
120
111
  ], Account);
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../server/entities/account.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,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,EAAE,IAAI;KACf,CAAC;;4CACiB;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACzB,OAAO;iDAAA;AAKzB;IAHC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;6CACkB;AAKpB;IAHC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;sCACS,IAAI;0CAAA;AAKf;IAHC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;0CACe;AAKjB;IAHC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;4CACiB;AAKnB;IAHC,IAAA,gBAAM,EAAC;QACN,QAAQ,EAAE,IAAI;KACf,CAAC;;4CACiB;AAGnB;IADC,IAAA,0BAAgB,GAAE;sCACR,IAAI;0CAAA;AAGf;IADC,IAAA,0BAAgB,GAAE;sCACR,IAAI;0CAAA;AAKf;IAHC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;sCACO,gBAAI;wCAAA;AAKb;IAHC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;sCACO,gBAAI;wCAAA;AA9EF,OAAO;IAFnB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,cAAc,EAAE,CAAC,OAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACjF,OAAO,CA+EnB;AA/EY,0BAAO","sourcesContent":["import { User } from '@things-factory/auth-base'\nimport { Domain } from '@things-factory/shell'\nimport { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'\n\n@Entity()\n@Index('ix_account_0', (account: Account) => [account.domain, account.name], { unique: true })\nexport class Account {\n @PrimaryGeneratedColumn('uuid')\n id: string\n\n @ManyToOne(type => Domain)\n domain: Domain\n\n @Column()\n platform: string\n\n @Column({\n nullable: true\n })\n accountId: string\n\n @Column()\n countryCode: string\n\n @Column({\n nullable: true\n })\n status: string\n\n @Column()\n name: string\n\n @Column({\n nullable: true\n })\n accessInfo: string\n\n @Column({\n nullable: true\n })\n accessToken: string\n\n @Column({ default: false, nullable: true })\n trackedInventory: Boolean\n\n @Column({\n nullable: true\n })\n refreshToken: string\n\n @Column({\n nullable: true\n })\n expiresIn: Date\n\n @Column({\n nullable: true\n })\n tokenType: string\n\n @Column({\n nullable: true\n })\n accountInfo: string\n\n @Column({\n nullable: true\n })\n description: string\n\n @CreateDateColumn()\n createdAt: Date\n\n @UpdateDateColumn()\n updatedAt: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n creator: User\n\n @ManyToOne(type => User, {\n nullable: true\n })\n updater: User\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAI1B,wFAJA,iBAAO,OAIA;AAFH,QAAA,QAAQ,GAAG,CAAC,iBAAO,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/entities/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAI1B,wFAJA,iBAAO,OAIA;AAFH,QAAA,QAAQ,GAAG,CAAC,iBAAO,CAAC,CAAA","sourcesContent":["import { Account } from './account'\n\nexport const entities = [Account]\n\nexport { Account }\n"]}
@@ -1,31 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.schema = void 0;
27
- const typeDefs = __importStar(require("./types"));
28
- const resolvers = __importStar(require("./resolvers"));
4
+ const tslib_1 = require("tslib");
5
+ const typeDefs = tslib_1.__importStar(require("./types"));
6
+ const resolvers = tslib_1.__importStar(require("./resolvers"));
29
7
  exports.schema = {
30
8
  typeDefs,
31
9
  resolvers
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/graphql/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAmC;AACnC,uDAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,QAAQ;IACR,SAAS;CACV,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/graphql/index.ts"],"names":[],"mappings":";;;;AAAA,0DAAmC;AACnC,+DAAwC;AAE3B,QAAA,MAAM,GAAG;IACpB,QAAQ;IACR,SAAS;CACV,CAAA","sourcesContent":["import * as typeDefs from './types'\nimport * as resolvers from './resolvers'\n\nexport const schema = {\n typeDefs,\n resolvers\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.accountResolver = void 0;
4
- const typeorm_1 = require("typeorm");
4
+ const shell_1 = require("@things-factory/shell");
5
5
  const entities_1 = require("../../../entities");
6
6
  exports.accountResolver = {
7
7
  async account(_, { id }, context) {
8
- const repository = (0, typeorm_1.getRepository)(entities_1.Account);
9
- return await (0, typeorm_1.getRepository)(entities_1.Account).findOne({
10
- where: { domain: context.state.domain, id },
8
+ const repository = (0, shell_1.getRepository)(entities_1.Account);
9
+ return await (0, shell_1.getRepository)(entities_1.Account).findOne({
10
+ where: { domain: { id: context.state.domain.id }, id },
11
11
  relations: ['domain', 'creator', 'updater']
12
12
  });
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/account.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAA2C;AAE9B,QAAA,eAAe,GAAG;IAC7B,KAAK,CAAC,OAAO,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAY;QACxC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAA;QAEzC,OAAO,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE;YAC3C,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/account.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AAErD,gDAA2C;AAE9B,QAAA,eAAe,GAAG;IAC7B,KAAK,CAAC,OAAO,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAwB;QACpD,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAA;QAEzC,OAAO,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YACtD,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;SAC5C,CAAC,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\n\nimport { Account } from '../../../entities'\n\nexport const accountResolver = {\n async account(_: any, { id }, context: ResolverContext) {\n const repository = getRepository(Account)\n\n return await getRepository(Account).findOne({\n where: { domain: { id: context.state.domain.id }, id },\n relations: ['domain', 'creator', 'updater']\n })\n }\n}\n"]}
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.accountsResolver = void 0;
4
- const typeorm_1 = require("typeorm");
5
4
  const shell_1 = require("@things-factory/shell");
6
5
  const entities_1 = require("../../../entities");
7
6
  exports.accountsResolver = {
8
7
  async accounts(_, params, context) {
9
8
  const { domain } = context.state;
10
9
  const convertedParams = (0, shell_1.convertListParams)(params, { domain });
11
- const [items, total] = await (0, typeorm_1.getRepository)(entities_1.Account).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'creator', 'updater'] }));
10
+ const [items, total] = await (0, shell_1.getRepository)(entities_1.Account).findAndCount(Object.assign(Object.assign({}, convertedParams), { relations: ['domain', 'creator', 'updater'] }));
12
11
  return { items, total };
13
12
  }
14
13
  };
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/accounts.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,iDAAoE;AAEpE,gDAA2C;AAE9B,QAAA,gBAAgB,GAAG;IAC9B,KAAK,CAAC,QAAQ,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAY;QACpD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,YAAY,iCAC3D,eAAe,KAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,IAC3C,CAAA;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/accounts.ts"],"names":[],"mappings":";;;AAAA,iDAAmF;AAEnF,gDAA2C;AAE9B,QAAA,gBAAgB,GAAG;IAC9B,KAAK,CAAC,QAAQ,CAAC,CAAM,EAAE,MAAiB,EAAE,OAAwB;QAChE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QAC7D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,YAAY,iCAC3D,eAAe,KAClB,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,IAC3C,CAAA;QACF,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;CACF,CAAA","sourcesContent":["import { convertListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { Account } from '../../../entities'\n\nexport const accountsResolver = {\n async accounts(_: any, params: ListParam, context: ResolverContext) {\n const { domain } = context.state\n const convertedParams = convertListParams(params, { domain })\n const [items, total] = await getRepository(Account).findAndCount({\n ...convertedParams,\n relations: ['domain', 'creator', 'updater']\n })\n return { items, total }\n }\n}\n"]}
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createAccount = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const entities_1 = require("../../../entities");
4
+ const shell_1 = require("@things-factory/shell");
6
5
  const controllers_1 = require("../../../controllers");
6
+ const entities_1 = require("../../../entities");
7
7
  exports.createAccount = {
8
8
  async createAccount(_, { account }, context) {
9
- return await (0, typeorm_1.getRepository)(entities_1.Account).save(Object.assign(Object.assign({ status: controllers_1.ACCOUNTING_STATUS.INACTIVE }, account), { domain: context.state.domain, creator: context.state.user, updater: context.state.user }));
9
+ const { domain, user } = context.state;
10
+ return await (0, shell_1.getRepository)(entities_1.Account).save(Object.assign(Object.assign({ status: controllers_1.ACCOUNTING_STATUS.INACTIVE }, account), { domain, creator: user, updater: user }));
10
11
  }
11
12
  };
12
13
  //# sourceMappingURL=create-account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/create-account.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAA2C;AAC3C,sDAAwD;AAE3C,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAY;QACnD,OAAO,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,+BACtC,MAAM,EAAE,+BAAiB,CAAC,QAAQ,IAC/B,OAAO,KACV,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAC5B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAC3B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"create-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/create-account.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AAErD,sDAAwD;AACxD,gDAA2C;AAE9B,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAwB;QAC/D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,OAAO,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,+BACtC,MAAM,EAAE,+BAAiB,CAAC,QAAQ,IAC/B,OAAO,KACV,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\n\nimport { ACCOUNTING_STATUS } from '../../../controllers'\nimport { Account } from '../../../entities'\n\nexport const createAccount = {\n async createAccount(_: any, { account }, context: ResolverContext) {\n const { domain, user } = context.state\n\n return await getRepository(Account).save({\n status: ACCOUNTING_STATUS.INACTIVE,\n ...account,\n domain,\n creator: user,\n updater: user\n })\n }\n}\n"]}
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteAccount = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const entities_1 = require("../../../entities");
4
+ const shell_1 = require("@things-factory/shell");
6
5
  const controllers_1 = require("../../../controllers");
6
+ const entities_1 = require("../../../entities");
7
7
  exports.deleteAccount = {
8
8
  async deleteAccount(_, { id }, context) {
9
- const foundAccount = await (0, typeorm_1.getRepository)(entities_1.Account).findOne({
10
- where: { domain: context.state.domain, id }
9
+ const foundAccount = await (0, shell_1.getRepository)(entities_1.Account).findOne({
10
+ where: { domain: { id: context.state.domain.id }, id }
11
11
  });
12
- await (0, typeorm_1.getRepository)(entities_1.Account).save(Object.assign(Object.assign({}, foundAccount), { status: controllers_1.ACCOUNTING_STATUS.TERMINATED, updater: context.state.user }));
12
+ await (0, shell_1.getRepository)(entities_1.Account).save(Object.assign(Object.assign({}, foundAccount), { status: controllers_1.ACCOUNTING_STATUS.TERMINATED, updater: context.state.user }));
13
13
  return true;
14
14
  }
15
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"delete-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/delete-account.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAA2C;AAC3C,sDAAwD;AAE3C,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAY;QAC9C,MAAM,YAAY,GAAY,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC;YACjE,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE;SAC5C,CAAC,CAAA;QAEF,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,iCAC5B,YAAY,KACf,MAAM,EAAE,+BAAiB,CAAC,UAAU,EACpC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"delete-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/delete-account.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AAErD,sDAAwD;AACxD,gDAA2C;AAE9B,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAwB;QAC1D,MAAM,YAAY,GAAY,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,OAAO,CAAC;YACjE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACvD,CAAC,CAAA;QAEF,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,iCAC5B,YAAY,KACf,MAAM,EAAE,+BAAiB,CAAC,UAAU,EACpC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\n\nimport { ACCOUNTING_STATUS } from '../../../controllers'\nimport { Account } from '../../../entities'\n\nexport const deleteAccount = {\n async deleteAccount(_: any, { id }, context: ResolverContext) {\n const foundAccount: Account = await getRepository(Account).findOne({\n where: { domain: { id: context.state.domain.id }, id }\n })\n\n await getRepository(Account).save({\n ...foundAccount,\n status: ACCOUNTING_STATUS.TERMINATED,\n updater: context.state.user\n })\n\n return true\n }\n}\n"]}
@@ -2,17 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteAccounts = void 0;
4
4
  const typeorm_1 = require("typeorm");
5
- const entities_1 = require("../../../entities");
5
+ const shell_1 = require("@things-factory/shell");
6
6
  const controllers_1 = require("../../../controllers");
7
+ const entities_1 = require("../../../entities");
7
8
  exports.deleteAccounts = {
8
9
  async deleteAccounts(_, { ids }, context) {
9
- let foundAccounts = await (0, typeorm_1.getRepository)(entities_1.Account).find({
10
- where: { domain: context.state.domain, id: (0, typeorm_1.In)(ids) }
10
+ let foundAccounts = await (0, shell_1.getRepository)(entities_1.Account).find({
11
+ where: { domain: { id: context.state.domain.id }, id: (0, typeorm_1.In)(ids) }
11
12
  });
12
13
  const updatedAccount = foundAccounts.map((account) => {
13
14
  return Object.assign(Object.assign({}, account), { status: controllers_1.ACCOUNTING_STATUS.TERMINATED, updater: context.state.user });
14
15
  });
15
- await (0, typeorm_1.getRepository)(entities_1.Account).save(updatedAccount);
16
+ await (0, shell_1.getRepository)(entities_1.Account).save(updatedAccount);
16
17
  return true;
17
18
  }
18
19
  };
@@ -1 +1 @@
1
- {"version":3,"file":"delete-accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/delete-accounts.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAC3C,gDAA2C;AAC3C,sDAAwD;AAE3C,QAAA,cAAc,GAAG;IAC5B,KAAK,CAAC,cAAc,CAAC,CAAM,EAAE,EAAE,GAAG,EAAE,EAAE,OAAY;QAChD,IAAI,aAAa,GAAc,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC;YAC/D,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE;SACrD,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,OAAgB,EAAE,EAAE;YAC5D,uCACK,OAAO,KACV,MAAM,EAAE,+BAAiB,CAAC,UAAU,EACpC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC5B;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACjD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"delete-accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/delete-accounts.ts"],"names":[],"mappings":";;;AAAA,qCAA4B;AAE5B,iDAAqD;AAErD,sDAAwD;AACxD,gDAA2C;AAE9B,QAAA,cAAc,GAAG;IAC5B,KAAK,CAAC,cAAc,CAAC,CAAM,EAAE,EAAE,GAAG,EAAE,EAAE,OAAwB;QAC5D,IAAI,aAAa,GAAc,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC;YAC/D,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC,EAAE;SAChE,CAAC,CAAA;QAEF,MAAM,cAAc,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,OAAgB,EAAE,EAAE;YAC5D,uCACK,OAAO,KACV,MAAM,EAAE,+BAAiB,CAAC,UAAU,EACpC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC5B;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACjD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA","sourcesContent":["import { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ACCOUNTING_STATUS } from '../../../controllers'\nimport { Account } from '../../../entities'\n\nexport const deleteAccounts = {\n async deleteAccounts(_: any, { ids }, context: ResolverContext) {\n let foundAccounts: Account[] = await getRepository(Account).find({\n where: { domain: { id: context.state.domain.id }, id: In(ids) }\n })\n\n const updatedAccount = foundAccounts.map((account: Account) => {\n return {\n ...account,\n status: ACCOUNTING_STATUS.TERMINATED,\n updater: context.state.user\n }\n })\n\n await getRepository(Account).save(updatedAccount)\n return true\n }\n}\n"]}
@@ -1,29 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.Mutation = exports.Query = void 0;
4
+ const tslib_1 = require("tslib");
27
5
  const account_1 = require("./account");
28
6
  const accounts_1 = require("./accounts");
29
7
  const update_multiple_accounts_1 = require("./update-multiple-accounts");
@@ -31,7 +9,7 @@ const update_account_1 = require("./update-account");
31
9
  const create_account_1 = require("./create-account");
32
10
  const delete_account_1 = require("./delete-account");
33
11
  const delete_accounts_1 = require("./delete-accounts");
34
- const Xero = __importStar(require("./xero"));
12
+ const Xero = tslib_1.__importStar(require("./xero"));
35
13
  exports.Query = Object.assign(Object.assign(Object.assign({}, accounts_1.accountsResolver), account_1.accountResolver), Xero.Query);
36
14
  exports.Mutation = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, update_account_1.updateAccount), update_multiple_accounts_1.updateMultipleAccount), create_account_1.createAccount), delete_account_1.deleteAccount), delete_accounts_1.deleteAccounts), Xero.Mutation);
37
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAA2C;AAC3C,yCAA6C;AAE7C,yEAAkE;AAClE,qDAAgD;AAChD,qDAAgD;AAChD,qDAAgD;AAChD,uDAAkD;AAElD,6CAA8B;AAEjB,QAAA,KAAK,iDACb,2BAAgB,GAChB,yBAAe,GACf,IAAI,CAAC,KAAK,EACd;AAEY,QAAA,QAAQ,2FAChB,8BAAa,GACb,gDAAqB,GACrB,8BAAa,GACb,8BAAa,GACb,gCAAc,GACd,IAAI,CAAC,QAAQ,EACjB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/index.ts"],"names":[],"mappings":";;;;AAAA,uCAA2C;AAC3C,yCAA6C;AAE7C,yEAAkE;AAClE,qDAAgD;AAChD,qDAAgD;AAChD,qDAAgD;AAChD,uDAAkD;AAElD,qDAA8B;AAEjB,QAAA,KAAK,iDACb,2BAAgB,GAChB,yBAAe,GACf,IAAI,CAAC,KAAK,EACd;AAEY,QAAA,QAAQ,2FAChB,8BAAa,GACb,gDAAqB,GACrB,8BAAa,GACb,8BAAa,GACb,gCAAc,GACd,IAAI,CAAC,QAAQ,EACjB","sourcesContent":["import { accountResolver } from './account'\nimport { accountsResolver } from './accounts'\n\nimport { updateMultipleAccount } from './update-multiple-accounts'\nimport { updateAccount } from './update-account'\nimport { createAccount } from './create-account'\nimport { deleteAccount } from './delete-account'\nimport { deleteAccounts } from './delete-accounts'\n\nimport * as Xero from './xero'\n\nexport const Query = {\n ...accountsResolver,\n ...accountResolver,\n ...Xero.Query\n}\n\nexport const Mutation = {\n ...updateAccount,\n ...updateMultipleAccount,\n ...createAccount,\n ...deleteAccount,\n ...deleteAccounts,\n ...Xero.Mutation\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateAccount = void 0;
4
- const typeorm_1 = require("typeorm");
4
+ const shell_1 = require("@things-factory/shell");
5
5
  const entities_1 = require("../../../entities");
6
6
  exports.updateAccount = {
7
7
  async updateAccount(_, { name, patch }, context) {
8
- const repository = (0, typeorm_1.getRepository)(entities_1.Account);
8
+ const repository = (0, shell_1.getRepository)(entities_1.Account);
9
9
  const account = await repository.findOne({
10
- where: { domain: context.state.domain, name }
10
+ where: { domain: { id: context.state.domain.id }, name }
11
11
  });
12
12
  return await repository.save(Object.assign(Object.assign(Object.assign({}, account), patch), { updater: context.state.user }));
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"update-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/update-account.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAA2C;AAE9B,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAY;QACvD,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,kBAAO,CAAC,CAAA;QACzC,MAAM,OAAO,GAAQ,MAAM,UAAU,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE;SAC9C,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,OAAO,GACP,KAAK,KACR,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"update-account.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/update-account.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AAErD,gDAA2C;AAE9B,QAAA,aAAa,GAAG;IAC3B,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAwB;QACnE,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAA;QACzC,MAAM,OAAO,GAAQ,MAAM,UAAU,CAAC,OAAO,CAAC;YAC5C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;SACzD,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,OAAO,GACP,KAAK,KACR,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\n\nimport { Account } from '../../../entities'\n\nexport const updateAccount = {\n async updateAccount(_: any, { name, patch }, context: ResolverContext) {\n const repository = getRepository(Account)\n const account: any = await repository.findOne({\n where: { domain: { id: context.state.domain.id }, name }\n })\n\n return await repository.save({\n ...account,\n ...patch,\n updater: context.state.user\n })\n }\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.updateMultipleAccount = void 0;
4
- const typeorm_1 = require("typeorm");
4
+ const shell_1 = require("@things-factory/shell");
5
5
  const entities_1 = require("../../../entities");
6
6
  exports.updateMultipleAccount = {
7
7
  async updateMultipleAccount(_, { patches }, context) {
8
8
  let results = [];
9
9
  const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
10
10
  const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
11
- const accountRepo = (0, typeorm_1.getRepository)(entities_1.Account);
11
+ const accountRepo = (0, shell_1.getRepository)(entities_1.Account);
12
12
  if (_createRecords.length > 0) {
13
13
  for (let i = 0; i < _createRecords.length; i++) {
14
14
  const newRecord = _createRecords[i];
@@ -19,7 +19,7 @@ exports.updateMultipleAccount = {
19
19
  if (_updateRecords.length > 0) {
20
20
  for (let i = 0; i < _updateRecords.length; i++) {
21
21
  const newRecord = _updateRecords[i];
22
- const account = await accountRepo.findOne(newRecord.id);
22
+ const account = await accountRepo.findOneBy({ id: newRecord.id });
23
23
  const result = await accountRepo.save(Object.assign(Object.assign(Object.assign({}, account), newRecord), { updater: context.state.user }));
24
24
  results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"update-multiple-accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/update-multiple-accounts.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAA2C;AAE9B,QAAA,qBAAqB,GAAG;IACnC,KAAK,CAAC,qBAAqB,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,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+CAChC,OAAO,GACP,SAAS,KACZ,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;gBAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;aACzC;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"update-multiple-accounts.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/accounting/update-multiple-accounts.ts"],"names":[],"mappings":";;;AAAA,iDAAqD;AAErD,gDAA2C;AAE9B,QAAA,qBAAqB,GAAG;IACnC,KAAK,CAAC,qBAAqB,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAwB;QACvE,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QACzF,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;QACzF,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAC,kBAAO,CAAC,CAAA;QAE1C,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;gBAEnC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,iCAChC,SAAS,KACZ,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAC5B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,EAC3B,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;gBAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;aACzC;SACF;QAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;gBACnC,MAAM,OAAO,GAAY,MAAM,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAA;gBAE1E,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,+CAChC,OAAO,GACP,SAAS,KACZ,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,IAAI,IAC3B,CAAA;gBAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;aACzC;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF,CAAA","sourcesContent":["import { getRepository } from '@things-factory/shell'\n\nimport { Account } from '../../../entities'\n\nexport const updateMultipleAccount = {\n async updateMultipleAccount(_: any, { patches }, context: ResolverContext) {\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 = 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: context.state.domain,\n creator: context.state.user,\n updater: context.state.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 newRecord = _updateRecords[i]\n const account: Account = await accountRepo.findOneBy({ id: newRecord.id })\n\n const result = await accountRepo.save({\n ...account,\n ...newRecord,\n updater: context.state.user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n}\n"]}