@things-factory/integration-base 5.0.11 → 6.0.0-alpha.3

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 (95) hide show
  1. package/dist-server/engine/connection-manager.js +1 -2
  2. package/dist-server/engine/connection-manager.js.map +1 -1
  3. package/dist-server/engine/connector/graphql-connector.js +4 -4
  4. package/dist-server/engine/connector/graphql-connector.js.map +1 -1
  5. package/dist-server/engine/connector/http-connector.js +3 -3
  6. package/dist-server/engine/connector/http-connector.js.map +1 -1
  7. package/dist-server/engine/connector/oracle-connector.js +1 -1
  8. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  9. package/dist-server/engine/scenario-engine.js +1 -2
  10. package/dist-server/engine/scenario-engine.js.map +1 -1
  11. package/dist-server/engine/task/local-graphql-mutate.js +3 -2
  12. package/dist-server/engine/task/local-graphql-mutate.js.map +1 -1
  13. package/dist-server/engine/task/local-graphql-query.js +3 -2
  14. package/dist-server/engine/task/local-graphql-query.js.map +1 -1
  15. package/dist-server/engine/task/pick-pending-scenario.js +4 -4
  16. package/dist-server/engine/task/pick-pending-scenario.js.map +1 -1
  17. package/dist-server/engine/task/sub-scenario.js +3 -3
  18. package/dist-server/engine/task/sub-scenario.js.map +1 -1
  19. package/dist-server/engine/task/switch-range-scenario.js +2 -2
  20. package/dist-server/engine/task/switch-range-scenario.js.map +1 -1
  21. package/dist-server/engine/task/switch-scenario.js +2 -2
  22. package/dist-server/engine/task/switch-scenario.js.map +1 -1
  23. package/dist-server/routers/scenario-view-router.js +6 -5
  24. package/dist-server/routers/scenario-view-router.js.map +1 -1
  25. package/dist-server/service/connection/connection-mutation.js +8 -7
  26. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  27. package/dist-server/service/connection/connection-query.js +7 -9
  28. package/dist-server/service/connection/connection-query.js.map +1 -1
  29. package/dist-server/service/connection/connection-subscription.js +4 -6
  30. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  31. package/dist-server/service/connection/connection-type.js +4 -5
  32. package/dist-server/service/connection/connection-type.js.map +1 -1
  33. package/dist-server/service/connector/connector-query.js +4 -4
  34. package/dist-server/service/connector/connector-query.js.map +1 -1
  35. package/dist-server/service/payload-log/payload-log-mutation.js +11 -8
  36. package/dist-server/service/payload-log/payload-log-mutation.js.map +1 -1
  37. package/dist-server/service/payload-log/payload-log-query.js +7 -9
  38. package/dist-server/service/payload-log/payload-log-query.js.map +1 -1
  39. package/dist-server/service/payload-log/payload-log.js +8 -4
  40. package/dist-server/service/payload-log/payload-log.js.map +1 -1
  41. package/dist-server/service/scenario/scenario-mutation.js +13 -8
  42. package/dist-server/service/scenario/scenario-mutation.js.map +1 -1
  43. package/dist-server/service/scenario/scenario-query.js +9 -11
  44. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  45. package/dist-server/service/scenario/scenario-type.js +3 -4
  46. package/dist-server/service/scenario/scenario-type.js.map +1 -1
  47. package/dist-server/service/scenario-flow/scenario-flow.js +1 -2
  48. package/dist-server/service/scenario-flow/scenario-flow.js.map +1 -1
  49. package/dist-server/service/scenario-instance/scenario-instance-mutation.js +4 -5
  50. package/dist-server/service/scenario-instance/scenario-instance-mutation.js.map +1 -1
  51. package/dist-server/service/scenario-instance/scenario-instance-query.js +1 -2
  52. package/dist-server/service/scenario-instance/scenario-instance-query.js.map +1 -1
  53. package/dist-server/service/scenario-instance/scenario-instance-subscription.js +1 -2
  54. package/dist-server/service/scenario-instance/scenario-instance-subscription.js.map +1 -1
  55. package/dist-server/service/scenario-instance/scenario-instance-type.js +3 -3
  56. package/dist-server/service/scenario-instance/scenario-instance-type.js.map +1 -1
  57. package/dist-server/service/scenario-queue/scenario-queue-type.js +1 -2
  58. package/dist-server/service/scenario-queue/scenario-queue-type.js.map +1 -1
  59. package/dist-server/service/step/step-mutation.js +3 -3
  60. package/dist-server/service/step/step-mutation.js.map +1 -1
  61. package/dist-server/service/step/step-query.js +8 -10
  62. package/dist-server/service/step/step-query.js.map +1 -1
  63. package/dist-server/service/step/step-type.js +3 -4
  64. package/dist-server/service/step/step-type.js.map +1 -1
  65. package/dist-server/service/task-type/task-type-query.js +5 -5
  66. package/dist-server/service/task-type/task-type-query.js.map +1 -1
  67. package/dist-server/tsconfig.tsbuildinfo +1 -1
  68. package/package.json +8 -8
  69. package/server/engine/connection-manager.ts +1 -2
  70. package/server/engine/connector/graphql-connector.ts +5 -5
  71. package/server/engine/connector/http-connector.ts +5 -5
  72. package/server/engine/connector/oracle-connector.ts +1 -1
  73. package/server/engine/scenario-engine.ts +2 -2
  74. package/server/engine/task/local-graphql-mutate.ts +3 -2
  75. package/server/engine/task/local-graphql-query.ts +3 -2
  76. package/server/engine/task/pick-pending-scenario.ts +4 -3
  77. package/server/engine/task/sub-scenario.ts +3 -2
  78. package/server/engine/task/switch-range-scenario.ts +1 -2
  79. package/server/engine/task/switch-scenario.ts +1 -2
  80. package/server/routers/scenario-view-router.ts +8 -8
  81. package/server/service/connection/connection-mutation.ts +21 -13
  82. package/server/service/connection/connection-query.ts +8 -9
  83. package/server/service/connection/connection-subscription.ts +5 -4
  84. package/server/service/connector/connector-query.ts +9 -7
  85. package/server/service/payload-log/payload-log-mutation.ts +25 -21
  86. package/server/service/payload-log/payload-log-query.ts +7 -8
  87. package/server/service/payload-log/payload-log.ts +5 -2
  88. package/server/service/scenario/scenario-mutation.ts +26 -20
  89. package/server/service/scenario/scenario-query.ts +11 -12
  90. package/server/service/scenario-instance/scenario-instance-mutation.ts +6 -7
  91. package/server/service/scenario-instance/scenario-instance-query.ts +5 -2
  92. package/server/service/step/step-mutation.ts +5 -5
  93. package/server/service/step/step-query.ts +8 -9
  94. package/server/service/task-type/task-type-query.ts +10 -8
  95. package/db.test.sqlite +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA2C;AAE3C,wEAAmE;AACnE,uDAAgG;A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AwCP;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;0DAKvD;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAS9E;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiBxD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAkB3D;AA9IU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CA+I9B;AA/IY,gDAAkB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { getRepository, In } from 'typeorm'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(@Arg('connection') connection: NewConnection, @Ctx() context: any): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: any\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: any\n ): Promise<Connection[]> {\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 connectionRepo = tx.getRepository(Connection)\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 connectionRepo.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 newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOne(newRecord.id)\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\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 connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(@Arg('names', type => [String]) names: string[], @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain,\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: any): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: domain, name },\n relations: ['domain']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: any) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain, name },\n relations: ['domain']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n}\n"]}
1
+ {"version":3,"file":"connection-mutation.js","sourceRoot":"","sources":["../../../server/service/connection/connection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,iDAAqD;AAErD,wEAAmE;AACnE,uDAAgG;AAGhG,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAG7B,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,4BAAU,CAAC,CAAC,IAAI,iCACzC,UAAU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C;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;0DAKvD;AAID;IAFC,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IAE7E,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAUP;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAiBxD;AAGD;IADC,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC;IACnD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8DAkB3D;AApJU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,kBAAkB,CAqJ9B;AArJY,gDAAkB","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionPatch, ConnectionStatus, NewConnection } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionMutation {\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To create new connection' })\n async createConnection(\n @Arg('connection') connection: NewConnection,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Connection).save({\n ...connection,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Connection, { description: 'To modify connection information' })\n async updateConnection(\n @Arg('name') name: string,\n @Arg('patch') patch: ConnectionPatch,\n @Ctx() context: ResolverContext\n ): Promise<Connection> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(Connection)\n const connection = await repository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n return await repository.save({\n ...connection,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [Connection], { description: \"To modify multiple connections' information\" })\n async updateMultipleConnection(\n @Arg('patches', type => [ConnectionPatch]) patches: ConnectionPatch[],\n @Ctx() context: ResolverContext\n ): Promise<Connection[]> {\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 connectionRepo = tx.getRepository(Connection)\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 connectionRepo.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 newRecord = _updateRecords[i]\n const connection = await connectionRepo.findOneBy({ id: newRecord.id })\n\n const result = await connectionRepo.save({\n ...connection,\n ...newRecord,\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 connection' })\n async deleteConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({ domain, name })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple connections' })\n async deleteConnections(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(Connection).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n\n @Mutation(returns => Connection, { description: 'To connect a connection' })\n async connectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n await connection.connect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Mutation(returns => Connection, { description: 'To disconnect a connection' })\n async disconnectConnection(@Arg('name') name: string, @Ctx() context: ResolverContext) {\n const { domain } = context.state\n\n var repository = getRepository(Connection)\n var connection = await repository.findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n await connection.disconnect()\n await repository.save(connection)\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n }\n }\n}\n"]}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.ConnectionQuery = void 0;
5
4
  const tslib_1 = require("tslib");
6
5
  const type_graphql_1 = require("type-graphql");
7
- const typeorm_1 = require("typeorm");
8
6
  const auth_base_1 = require("@things-factory/auth-base");
9
7
  const shell_1 = require("@things-factory/shell");
10
8
  const connection_manager_1 = require("../../engine/connection-manager");
@@ -12,8 +10,8 @@ const connection_type_1 = require("./connection-type");
12
10
  let ConnectionQuery = class ConnectionQuery {
13
11
  async connection(name, context) {
14
12
  const { domain } = context.state;
15
- var connection = await (0, typeorm_1.getRepository)(connection_type_1.Connection).findOne({
16
- where: { domain, name },
13
+ var connection = await (0, shell_1.getRepository)(connection_type_1.Connection).findOne({
14
+ where: { domain: { id: domain.id }, name },
17
15
  relations: ['domain']
18
16
  });
19
17
  return Object.assign(Object.assign({}, connection), { state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
@@ -23,7 +21,7 @@ let ConnectionQuery = class ConnectionQuery {
23
21
  async connections(params, context) {
24
22
  const { domain } = context.state;
25
23
  const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
26
- repository: (0, typeorm_1.getRepository)(connection_type_1.Connection),
24
+ repository: (0, shell_1.getRepository)(connection_type_1.Connection),
27
25
  params,
28
26
  domain,
29
27
  alias: 'connection',
@@ -46,13 +44,13 @@ let ConnectionQuery = class ConnectionQuery {
46
44
  };
47
45
  }
48
46
  async domain(connection) {
49
- return connection.domain || (await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(connection.domainId));
47
+ return connection.domain || (await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: connection.domainId }));
50
48
  }
51
49
  async updater(connection) {
52
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(connection.updaterId);
50
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.updaterId });
53
51
  }
54
52
  async creator(connection) {
55
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(connection.creatorId);
53
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: connection.creatorId });
56
54
  }
57
55
  };
58
56
  tslib_1.__decorate([
@@ -68,7 +66,7 @@ tslib_1.__decorate([
68
66
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
69
67
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
70
68
  tslib_1.__metadata("design:type", Function),
71
- tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
69
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
72
70
  tslib_1.__metadata("design:returntype", Promise)
73
71
  ], ConnectionQuery.prototype, "connections", null);
74
72
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;;AAAA,+CAAmF;AACnF,qCAAuC;AAEvC,yDAAgD;AAChD,iDAAwF;AAExF,wEAAmE;AACnE,uDAAiG;AAGjG,IAAa,eAAe,GAA5B,MAAa,eAAe;IAE1B,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAY;QAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,uBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;YACvB,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,kCAAgB,CAAC,YAAY,GACpB,CAAA;IACjB,CAAC;IAGD,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAY;QAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,UAAU,EAAE,IAAA,uBAAa,EAAC,4BAAU,CAAC;YACrC,MAAM;YACN,MAAM;YACN,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC;SACzD,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,E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jEC;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACrD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAcjD;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;iEAAjB,iBAAS,oBAAT,iBAAS;;kDAoB1C;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IACnE,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAAgB,iCAAe;2DASpF;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAE1C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAlEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAmE3B;AAnEY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { getRepository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: any): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(@Args() params: ListParam, @Ctx() context: any): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: any): ConnectionState {\n const { domain } = context.state\n\n var connection = ConnectionManager.getConnectionInstanceByName(domain, name)\n\n return {\n name,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (await getRepository(Domain).findOne(connection.domainId))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOne(connection.updaterId)\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOne(connection.creatorId)\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAAgD;AAChD,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAGjG,IAAa,eAAe,GAA5B,MAAa,eAAe;IAE1B,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,IAAI,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACvD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;YAC1C,SAAS,EAAE,CAAC,QAAQ,CAAC;SACtB,CAAC,CAAA;QAEF,OAAO,gCACF,UAAU,KACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,kCAAgB,CAAC,YAAY,GACpB,CAAA;IACjB,CAAC;IAGD,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAwB;QAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,UAAU,EAAE,IAAA,qBAAa,EAAC,4BAAU,CAAC;YACrC,MAAM;YACN,MAAM;YACN,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,CAAC;SACzD,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC,eAAe,EAAE,CAAA;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AAO,CAAC,EAAE,CAAC,4BAAU,EAAE,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACrD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAcjD;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,gCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAAjB,iBAAS;;kDAoB1C;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IACnE,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAA4B,iCAAe;2DAShG;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAE1C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAlEU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAmE3B;AAnEY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionList, ConnectionState, ConnectionStatus } from './connection-type'\n\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Query(returns => Connection, { description: 'To fetch a connection' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Connection> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name },\n relations: ['domain']\n })\n\n return {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n } as Connection\n }\n\n @Query(returns => ConnectionList, { description: 'To fetch multiple connections' })\n async connections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ConnectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(Connection),\n params,\n domain,\n alias: 'connection',\n searchables: ['name', 'description', 'type', 'endpoint']\n })\n\n const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount()\n\n items.forEach(connection => {\n connection['state'] = ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED\n })\n\n return { items, total }\n }\n\n @Query(returns => ConnectionState, { description: 'To fetch the state of a connection' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n var connection = ConnectionManager.getConnectionInstanceByName(domain, name)\n\n return {\n name,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return connection.domain || (await getRepository(Domain).findOneBy({ id: connection.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOneBy({ id: connection.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return await getRepository(User).findOneBy({ id: connection.creatorId })\n }\n}\n"]}
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.ConnectionSubscription = void 0;
5
4
  const tslib_1 = require("tslib");
5
+ const graphql_subscriptions_1 = require("graphql-subscriptions");
6
6
  const type_graphql_1 = require("type-graphql");
7
- const typeorm_1 = require("typeorm");
8
- const connection_type_1 = require("./connection-type");
9
7
  const shell_1 = require("@things-factory/shell");
10
- const graphql_subscriptions_1 = require("graphql-subscriptions");
11
8
  const connection_manager_1 = require("../../engine/connection-manager");
9
+ const connection_type_1 = require("./connection-type");
12
10
  const debug = require('debug')('things-factory:integration:connection-subscription');
13
11
  let ConnectionSubscription = class ConnectionSubscription {
14
12
  connectionState(payload, name) {
@@ -37,7 +35,7 @@ tslib_1.__decorate([
37
35
  if (name) {
38
36
  where['name'] = name;
39
37
  }
40
- var connections = await (0, typeorm_1.getRepository)(connection_type_1.Connection).find({
38
+ var connections = await (0, shell_1.getRepository)(connection_type_1.Connection).find({
41
39
  where,
42
40
  relations: ['domain']
43
41
  });
@@ -94,7 +92,7 @@ tslib_1.__decorate([
94
92
  tslib_1.__param(1, (0, type_graphql_1.Arg)('level', { nullable: true })),
95
93
  tslib_1.__metadata("design:type", Function),
96
94
  tslib_1.__metadata("design:paramtypes", [Object, String]),
97
- tslib_1.__metadata("design:returntype", typeof (_a = typeof shell_1.Log !== "undefined" && shell_1.Log) === "function" ? _a : Object)
95
+ tslib_1.__metadata("design:returntype", shell_1.Log)
98
96
  ], ConnectionSubscription.prototype, "connectionLog", null);
99
97
  ConnectionSubscription = tslib_1.__decorate([
100
98
  (0, type_graphql_1.Resolver)(connection_type_1.Connection)
@@ -1 +1 @@
1
- {"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;;AAAA,+CAAgE;AAChE,qCAAuC;AACvC,uDAAiF;AACjF,iDAAmD;AACnD,iEAAkD;AACl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CAAC,CAAA;;;gEAAiB,WAAG,oBAAH,WAAG;2DAEjG;AAjGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CAkGlC;AAlGY,wDAAsB","sourcesContent":["import { Resolver, Subscription, Root, Arg } from 'type-graphql'\nimport { getRepository } from 'typeorm'\nimport { Connection, ConnectionState, ConnectionStatus } from './connection-type'\nimport { pubsub, Log } from '@things-factory/shell'\nimport { withFilter } from 'graphql-subscriptions'\nimport { ConnectionManager } from '../../engine/connection-manager'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return withFilter(\n () => pubsub.asyncIterator('connection-state'),\n (payload, variables, context, info) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const { name } = variables\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n }\n )(_, args, context, info)\n }\n })\n connectionState(\n @Root() payload: { connectionState: ConnectionState },\n @Arg('name', { nullable: true }) name: string\n ): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return withFilter(\n () => pubsub.asyncIterator('connection-log'),\n (payload, variables, context, info) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.connectionLog\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n }\n )(_, args, context, info)\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
1
+ {"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,iEAAkD;AAClD,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,uDAAiF;AAEjF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAGpF,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAmDjC,eAAe,CACL,OAA6C,EACpB,IAAY;QAE7C,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAuCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AA/CC;IAlDC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;;YACpC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YACrB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC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,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBACpC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAA;gBAC7D,qCAAqC;gBAErC,0CAA0C;gBAC1C,iBAAiB;gBACjB,IAAI;gBAEJ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE;oBAC7B,OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC;KACF,CAAC;IACa,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAyB,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;4CAAiB,WAAG;2DAEjG;AAjGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CAkGlC;AAlGY,wDAAsB","sourcesContent":["import { withFilter } from 'graphql-subscriptions'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { getRepository, Log, pubsub } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionState, ConnectionStatus } from './connection-type'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { name } = args\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n if (!domain) {\n throw new Error('domain required.')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain']\n })\n\n connections.forEach(connection => {\n pubsub.publish('connection-state', {\n connectionState: {\n ...connection,\n state: ConnectionManager.getConnectionInstance(connection)\n ? ConnectionStatus.CONNECTED\n : ConnectionStatus.DISCONNECTED,\n timestamp: new Date()\n }\n })\n })\n })\n\n return withFilter(\n () => pubsub.asyncIterator('connection-state'),\n (payload, variables, context, info) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n const { name } = variables\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n }\n )(_, args, context, info)\n }\n })\n connectionState(\n @Root() payload: { connectionState: ConnectionState },\n @Arg('name', { nullable: true }) name: string\n ): ConnectionState {\n return payload.connectionState\n }\n\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const { level } = args\n\n const subdomain = domain?.subdomain\n\n debug('subscribe', subdomain)\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return withFilter(\n () => pubsub.asyncIterator('connection-log'),\n (payload, variables, context, info) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.connectionLog\n // const { domain: pdomain } = source\n\n // if (subdomain !== pdomain?.subdomain) {\n // return false\n // }\n\n if (level && level !== plevel) {\n return false\n }\n\n return true\n }\n )(_, args, context, info)\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a, _b, _c, _d;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.ConnectionList = exports.ConnectionPatch = exports.NewConnection = exports.ConnectionState = exports.Connection = exports.ConnectionStatus = void 0;
5
4
  const tslib_1 = require("tslib");
@@ -47,7 +46,7 @@ tslib_1.__decorate([
47
46
  tslib_1.__decorate([
48
47
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
49
48
  (0, type_graphql_1.Field)({ nullable: true }),
50
- tslib_1.__metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
49
+ tslib_1.__metadata("design:type", shell_1.Domain)
51
50
  ], Connection.prototype, "domain", void 0);
52
51
  tslib_1.__decorate([
53
52
  (0, typeorm_1.RelationId)((connection) => connection.domain),
@@ -108,7 +107,7 @@ tslib_1.__decorate([
108
107
  nullable: true
109
108
  }),
110
109
  (0, type_graphql_1.Field)({ nullable: true }),
111
- tslib_1.__metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
110
+ tslib_1.__metadata("design:type", auth_base_1.User)
112
111
  ], Connection.prototype, "creator", void 0);
113
112
  tslib_1.__decorate([
114
113
  (0, typeorm_1.RelationId)((connection) => connection.creator),
@@ -119,7 +118,7 @@ tslib_1.__decorate([
119
118
  nullable: true
120
119
  }),
121
120
  (0, type_graphql_1.Field)({ nullable: true }),
122
- tslib_1.__metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
121
+ tslib_1.__metadata("design:type", auth_base_1.User)
123
122
  ], Connection.prototype, "updater", void 0);
124
123
  tslib_1.__decorate([
125
124
  (0, typeorm_1.RelationId)((connection) => connection.creator),
@@ -135,7 +134,7 @@ let ConnectionState = class ConnectionState {
135
134
  };
136
135
  tslib_1.__decorate([
137
136
  (0, type_graphql_1.Field)({ nullable: true }),
138
- tslib_1.__metadata("design:type", typeof (_d = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _d : Object)
137
+ tslib_1.__metadata("design:type", shell_1.Domain)
139
138
  ], ConnectionState.prototype, "domain", void 0);
140
139
  tslib_1.__decorate([
141
140
  (0, type_graphql_1.Field)({ nullable: true }),
@@ -1 +1 @@
1
- {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;;AAAA,+CAAsF;AACtF,qCASgB;AAEhB,yDA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AAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;AAGf;IADC,IAAA,oBAAK,GAAE;;+CACM;AAvBH,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAwB3B;AAxBY,0CAAe;AA2B5B,IAAa,cAAc,GAA3B,MAAa,cAAc;CAM1B,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;;6CACT;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { logger } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED',\n DISCONNECTED = 'DISCONNECTED'\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'state enumeration of a connection'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType()\nexport class Connection {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain: Domain\n\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column()\n @Field({ nullable: true })\n type: string\n\n @Column()\n @Field({ nullable: true })\n endpoint: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n active: boolean\n\n @Field({ nullable: true })\n state: ConnectionStatus\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n params: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((connection: Connection) => connection.creator)\n updaterId: string\n\n async connect() {\n var connector = ConnectionManager.getConnector(this.type)\n var params = {}\n\n try {\n params = JSON.parse(this.params || '{}')\n } catch (ex) {\n logger.error(`connection '${this.name}' params should be JSON format`, ex)\n }\n\n await connector.connect({\n ...this,\n params\n })\n }\n\n async disconnect() {\n try {\n var connector = ConnectionManager.getConnector(this.type)\n await connector.disconnect(this)\n } finally {\n }\n }\n}\n\n@ObjectType()\nexport class ConnectionState {\n @Field({ nullable: true })\n domain?: Domain\n\n @Field({ 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 type?: string\n\n @Field({ nullable: true })\n state?: ConnectionStatus\n\n @Field({ nullable: true })\n timestamp?: Date\n}\n\n@InputType()\nexport class NewConnection {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class ConnectionPatch {\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 type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field()\n cuFlag: string\n}\n\n@ObjectType()\nexport class ConnectionList {\n @Field(type => [Connection])\n items: Connection[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,qCASgB;AAEhB,yDAAgD;AAChD,6CAA4C;AAC5C,iDAA8C;AAE9C,yCAAgD;AAEhD,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA;AAC/B,CAAC,EAHW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mCAAmC;CACjD,CAAC,CAAA;AAKF,IAAa,UAAU,GAAvB,MAAa,UAAU;IAuErB,KAAK,CAAC,OAAO;QACX,IAAI,SAAS,GAAG,0BAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACzD,IAAI,MAAM,GAAG,EAAE,CAAA;QAEf,IAAI;YACF,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAA;SACzC;QAAC,OAAO,EAAE,EAAE;YACX,YAAM,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,gCAAgC,EAAE,EAAE,CAAC,CAAA;SAC3E;QAED,MAAM,SAAS,CAAC,OAAO,iCAClB,IAAI,KACP,MAAM,IACN,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI;YACF,IAAI,SAAS,GAAG,0BAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACzD,MAAM,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;SACjC;gBAAS;SACT;IACH,CAAC;CACF,CAAA;AA3FC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAA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B;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;AAGf;IADC,IAAA,oBAAK,GAAE;;+CACM;AAvBH,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAwB3B;AAxBY,0CAAe;AA2B5B,IAAa,cAAc,GAA3B,MAAa,cAAc;CAM1B,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;;6CACT;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;AALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B;AANY,wCAAc","sourcesContent":["import { Field, ID, InputType, Int, ObjectType, registerEnumType } from 'type-graphql'\nimport {\n Column,\n CreateDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { logger } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED',\n DISCONNECTED = 'DISCONNECTED'\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'state enumeration of a connection'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType()\nexport class Connection {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Domain)\n @Field({ nullable: true })\n domain: Domain\n\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n @Column()\n @Field()\n name: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n description: string\n\n @Column()\n @Field({ nullable: true })\n type: string\n\n @Column()\n @Field({ nullable: true })\n endpoint: string\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n active: boolean\n\n @Field({ nullable: true })\n state: ConnectionStatus\n\n @Column({\n nullable: true\n })\n @Field({ nullable: true })\n params: string\n\n @CreateDateColumn()\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true })\n updatedAt: Date\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n @ManyToOne(type => User, {\n nullable: true\n })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((connection: Connection) => connection.creator)\n updaterId: string\n\n async connect() {\n var connector = ConnectionManager.getConnector(this.type)\n var params = {}\n\n try {\n params = JSON.parse(this.params || '{}')\n } catch (ex) {\n logger.error(`connection '${this.name}' params should be JSON format`, ex)\n }\n\n await connector.connect({\n ...this,\n params\n })\n }\n\n async disconnect() {\n try {\n var connector = ConnectionManager.getConnector(this.type)\n await connector.disconnect(this)\n } finally {\n }\n }\n}\n\n@ObjectType()\nexport class ConnectionState {\n @Field({ nullable: true })\n domain?: Domain\n\n @Field({ 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 type?: string\n\n @Field({ nullable: true })\n state?: ConnectionStatus\n\n @Field({ nullable: true })\n timestamp?: Date\n}\n\n@InputType()\nexport class NewConnection {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n params?: string\n}\n\n@InputType()\nexport class ConnectionPatch {\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 type?: string\n\n @Field({ nullable: true })\n endpoint?: string\n\n @Field({ nullable: true })\n active?: boolean\n\n @Field({ nullable: true })\n params?: string\n\n @Field()\n cuFlag: string\n}\n\n@ObjectType()\nexport class ConnectionList {\n @Field(type => [Connection])\n items: Connection[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConnectorQuery = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
- const typeorm_1 = require("typeorm");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const connection_manager_1 = require("../../engine/connection-manager");
7
8
  const connection_type_1 = require("../connection/connection-type");
8
9
  const connector_type_1 = require("./connector-type");
9
- const connection_manager_1 = require("../../engine/connection-manager");
10
10
  let ConnectorQuery = class ConnectorQuery {
11
11
  async connection(name, context) {
12
12
  // @ts-ignore
@@ -42,8 +42,8 @@ let ConnectorQuery = class ConnectorQuery {
42
42
  }
43
43
  async connectorByConnection(connectionName, context) {
44
44
  const { domain } = context.state;
45
- var connection = await (0, typeorm_1.getRepository)(connection_type_1.Connection).findOne({
46
- where: { domain, name: connectionName }
45
+ var connection = await (0, shell_1.getRepository)(connection_type_1.Connection).findOne({
46
+ where: { domain: { id: domain.id }, name: connectionName }
47
47
  });
48
48
  return connection && connection_manager_1.ConnectionManager.getConnector(connection.type);
49
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"connector-query.js","sourceRoot":"","sources":["../../../server/service/connector/connector-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwD;AACxD,qCAAuC;AACvC,mEAA0D;AAC1D,qDAA+D;AAC/D,wEAAmE;AAGnE,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEzB,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAY;QAC7D,aAAa;QACb,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,sCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAErG,OAAO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O,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IACvD,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gDAWjD;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;;;gDAsB/E;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;IAE1F,mBAAA,IAAA,kBAAG,EAAC,gBAAgB,CAAC,CAAA;IACrB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DASP;AAnDU,cAAc;IAD1B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,cAAc,CAoD1B;AApDY,wCAAc","sourcesContent":["import { Resolver, Query, Arg, Ctx } from 'type-graphql'\nimport { getRepository } from 'typeorm'\nimport { Connection } from '../connection/connection-type'\nimport { ConnectorType, ConnectorList } from './connector-type'\nimport { ConnectionManager } from '../../engine/connection-manager'\n\n@Resolver(ConnectorType)\nexport class ConnectorQuery {\n @Query(returns => ConnectorType, { description: 'To fetch a connector' })\n async connection(@Arg('name') name: string, @Ctx() context: any): Promise<ConnectorType> {\n // @ts-ignore\n const { description, help, parameterSpec, taskPrefixes } = ConnectionManager.getConnector(name) || {}\n\n return {\n name,\n description,\n help,\n parameterSpec,\n taskPrefixes: taskPrefixes || []\n }\n }\n\n @Query(returns => ConnectorList, { description: 'To fetch multiple connector' })\n async connectors(): Promise<ConnectorList> {\n var connectors = ConnectionManager.getConnectors()\n var items = Object.keys(connectors)\n .map(name => {\n var connector = connectors[name]\n return {\n name,\n description: connector.description,\n help: connector.help,\n parameterSpec: connector.parameterSpec,\n taskPrefixes: connector.taskPrefixes || []\n }\n })\n .sort((x, y) => {\n return x.name < y.name ? -1 : 1\n })\n\n return {\n items,\n total: items.length\n }\n }\n\n @Query(returns => ConnectorType, { description: 'To fetch the connector from a connection' })\n async connectorByConnection(\n @Arg('connectionName') connectionName: string,\n @Ctx() context: any\n ): Promise<ConnectorType> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain, name: connectionName }\n })\n\n return connection && (ConnectionManager.getConnector(connection.type) as any)\n }\n}\n"]}
1
+ {"version":3,"file":"connector-query.js","sourceRoot":"","sources":["../../../server/service/connector/connector-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwD;AAExD,iDAAqD;AAErD,wEAAmE;AACnE,mEAA0D;AAC1D,qDAA+D;AAG/D,IAAa,cAAc,GAA3B,MAAa,cAAc;IAEzB,KAAK,CAAC,UAAU,CAAc,IAAY,EAAS,OAAwB;QACzE,aAAa;QACb,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,sCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;QAErG,OAAO;YACL,IAAI;YACJ,WAAW;YACX,IAAI;YACJ,aAAa;YACb,YAAY,EAAE,YAAY,IAAI,EAAE;SACjC,CAAA;IACH,CAAC;IAGD,KAAK,CAAC,UAAU;QACd,IAAI,UAAU,GAAG,sCAAiB,CAAC,aAAa,EAAE,CAAA;QAClD,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;aAChC,GAAG,CAAC,IAAI,CAAC,EAAE;YACV,IAAI,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YAChC,OAAO;gBACL,IAAI;gBACJ,WAAW,EAAE,SAAS,CAAC,WAAW;gBAClC,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,aAAa,EAAE,SAAS,CAAC,aAAa;gBACtC,YAAY,EAAE,SAAS,CAAC,YAAY,IAAI,EAAE;aAC3C,CAAA;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,CA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AAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,cAAc,CAoD1B;AApDY,wCAAc","sourcesContent":["import { Arg, Ctx, Query, Resolver } from 'type-graphql'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection } from '../connection/connection-type'\nimport { ConnectorList, ConnectorType } from './connector-type'\n\n@Resolver(ConnectorType)\nexport class ConnectorQuery {\n @Query(returns => ConnectorType, { description: 'To fetch a connector' })\n async connection(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<ConnectorType> {\n // @ts-ignore\n const { description, help, parameterSpec, taskPrefixes } = ConnectionManager.getConnector(name) || {}\n\n return {\n name,\n description,\n help,\n parameterSpec,\n taskPrefixes: taskPrefixes || []\n }\n }\n\n @Query(returns => ConnectorList, { description: 'To fetch multiple connector' })\n async connectors(): Promise<ConnectorList> {\n var connectors = ConnectionManager.getConnectors()\n var items = Object.keys(connectors)\n .map(name => {\n var connector = connectors[name]\n return {\n name,\n description: connector.description,\n help: connector.help,\n parameterSpec: connector.parameterSpec,\n taskPrefixes: connector.taskPrefixes || []\n }\n })\n .sort((x, y) => {\n return x.name < y.name ? -1 : 1\n })\n\n return {\n items,\n total: items.length\n }\n }\n\n @Query(returns => ConnectorType, { description: 'To fetch the connector from a connection' })\n async connectorByConnection(\n @Arg('connectionName') connectionName: string,\n @Ctx() context: ResolverContext\n ): Promise<ConnectorType> {\n const { domain } = context.state\n\n var connection = await getRepository(Connection).findOne({\n where: { domain: { id: domain.id }, name: connectionName }\n })\n\n return connection && (ConnectionManager.getConnector(connection.type) as any)\n }\n}\n"]}
@@ -4,9 +4,10 @@ exports.createPayloadLog = exports.PayloadLogMutation = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const typeorm_1 = require("typeorm");
7
+ const env_1 = require("@things-factory/env");
8
+ const shell_1 = require("@things-factory/shell");
7
9
  const payload_log_1 = require("./payload-log");
8
10
  const payload_log_type_1 = require("./payload-log-type");
9
- const env_1 = require("@things-factory/env");
10
11
  let PayloadLogMutation = class PayloadLogMutation {
11
12
  async createPayloadLog(payloadLog, context) {
12
13
  const { domain, user, tx } = context.state;
@@ -16,7 +17,7 @@ let PayloadLogMutation = class PayloadLogMutation {
16
17
  const { domain, user, tx } = context.state;
17
18
  const repository = tx.getRepository(payload_log_1.PayloadLog);
18
19
  const payloadLog = await repository.findOne({
19
- where: { domain, id }
20
+ where: { domain: { id: domain.id }, id }
20
21
  });
21
22
  return await repository.save(Object.assign(Object.assign(Object.assign({}, payloadLog), patch), { updater: user }));
22
23
  }
@@ -36,7 +37,7 @@ let PayloadLogMutation = class PayloadLogMutation {
36
37
  if (_updateRecords.length > 0) {
37
38
  for (let i = 0; i < _updateRecords.length; i++) {
38
39
  const newRecord = _updateRecords[i];
39
- const payloadLog = await payloadLogRepo.findOne(newRecord.id);
40
+ const payloadLog = await payloadLogRepo.findOneBy({ id: newRecord.id });
40
41
  const result = await payloadLogRepo.save(Object.assign(Object.assign(Object.assign({}, payloadLog), newRecord), { updater: user }));
41
42
  results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
42
43
  }
@@ -45,13 +46,13 @@ let PayloadLogMutation = class PayloadLogMutation {
45
46
  }
46
47
  async deletePayloadLog(id, context) {
47
48
  const { domain, tx } = context.state;
48
- await tx.getRepository(payload_log_1.PayloadLog).delete({ domain, id });
49
+ await tx.getRepository(payload_log_1.PayloadLog).delete({ domain: { id: domain.id }, id });
49
50
  return true;
50
51
  }
51
52
  async deletePayloadLogs(ids, context) {
52
53
  const { domain, tx } = context.state;
53
54
  await tx.getRepository(payload_log_1.PayloadLog).delete({
54
- domain,
55
+ domain: { id: domain.id },
55
56
  id: (0, typeorm_1.In)(ids)
56
57
  });
57
58
  return true;
@@ -107,20 +108,22 @@ PayloadLogMutation = tslib_1.__decorate([
107
108
  (0, type_graphql_1.Resolver)(payload_log_1.PayloadLog)
108
109
  ], PayloadLogMutation);
109
110
  exports.PayloadLogMutation = PayloadLogMutation;
110
- async function createPayloadLog(name, endpoint, request, response, context, type = payload_log_1.PayloadType.EGESTION) {
111
+ async function createPayloadLog(name, endpoint, request, response, context, type = payload_log_1.PayloadType.EGESTION, src = null) {
111
112
  try {
112
113
  const { domain, user } = context === null || context === void 0 ? void 0 : context.state;
113
- await (0, typeorm_1.getRepository)(payload_log_1.PayloadLog).save({
114
+ // disabled due to high db server usage
115
+ await (0, shell_1.getRepository)(payload_log_1.PayloadLog).save({
114
116
  name,
115
117
  domain,
116
118
  endpoint,
117
119
  request,
118
120
  response,
119
121
  type,
122
+ src,
120
123
  createdBy: user,
121
124
  updatedBy: user,
122
125
  createdAt: new Date(),
123
- updatedAt: new Date(),
126
+ updatedAt: new Date()
124
127
  });
125
128
  }
126
129
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"payload-log-mutation.js","sourceRoot":"","sources":["../../../server/service/payload-log/payload-log-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA2C;AAC3C,+CAAuD;AACvD,yDAAmE;AACnE,6CAA4C;AAM5C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAG7B,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAY;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,gBAAgB,CACT,EAAU,EACP,KAAsB,EAC7B,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,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kB;IAD9B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,kBAAkB,CAyG9B;AAzGY,gDAAkB;AA4GxB,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,QAAgB,EAChB,OAAe,EACf,QAAgB,EAChB,OAAY,EACZ,OAAoB,yBAAW,CAAC,QAAQ;IAExC,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAmC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA;QAEvE,MAAM,IAAA,uBAAa,EAAC,wBAAU,CAAC,CAAC,IAAI,CAAC;YACnC,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,OAAO;YACP,QAAQ;YACR,IAAI;YACJ,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;KAGH;IAAC,OAAO,KAAK,EAAE;QACd,YAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAA;KAC3C;AACH,CAAC;AA5BD,4CA4BC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { getRepository, In } from 'typeorm'\nimport { PayloadLog, PayloadType } from './payload-log'\nimport { NewPayloadLog, PayloadLogPatch } from './payload-log-type'\nimport { logger } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace } from '@things-factory/biz-base'\n\n@Resolver(PayloadLog)\nexport class PayloadLogMutation {\n @Directive('@transaction')\n @Mutation(returns => PayloadLog, { description: 'To create new PayloadLog' })\n async createPayloadLog(@Arg('payloadLog') payloadLog: NewPayloadLog, @Ctx() context: any): Promise<PayloadLog> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(PayloadLog).save({\n ...payloadLog,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => PayloadLog, { description: 'To modify PayloadLog information' })\n async updatePayloadLog(\n @Arg('id') id: string,\n @Arg('patch') patch: PayloadLogPatch,\n @Ctx() context: any\n ): Promise<PayloadLog> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(PayloadLog)\n const payloadLog = await repository.findOne({\n where: { domain, id }\n })\n\n return await repository.save({\n ...payloadLog,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [PayloadLog], { description: \"To modify multiple PayloadLogs' information\" })\n async updateMultiplePayloadLog(\n @Arg('patches', type => [PayloadLogPatch]) patches: PayloadLogPatch[],\n @Ctx() context: any\n ): Promise<PayloadLog[]> {\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 payloadLogRepo = tx.getRepository(PayloadLog)\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 payloadLogRepo.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 newRecord = _updateRecords[i]\n const payloadLog = await payloadLogRepo.findOne(newRecord.id)\n\n const result = await payloadLogRepo.save({\n ...payloadLog,\n ...newRecord,\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 PayloadLog' })\n async deletePayloadLog(@Arg('id') id: string, @Ctx() context: any): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(PayloadLog).delete({ domain, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple payloadLogs' })\n async deletePayloadLogs(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: any\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(PayloadLog).delete({\n domain,\n id: In(ids)\n })\n\n return true\n }\n}\n\n\nexport async function createPayloadLog(\n name: string,\n endpoint: string,\n request: string,\n response: string,\n context: any,\n type: PayloadType = PayloadType.EGESTION\n): Promise<void> {\n try {\n const { domain, user }: { domain: Domain; user: User } = context?.state\n\n await getRepository(PayloadLog).save({\n name,\n domain,\n endpoint,\n request,\n response,\n type,\n createdBy: user,\n updatedBy: user,\n createdAt: new Date(),\n updatedAt: new Date(),\n })\n\n\n } catch (error) {\n logger.error(`PayloadLog Error: ${error}`)\n }\n}"]}
1
+ {"version":3,"file":"payload-log-mutation.js","sourceRoot":"","sources":["../../../server/service/payload-log/payload-log-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAG5B,6CAA4C;AAC5C,iDAA6D;AAE7D,+CAAuD;AACvD,yDAAmE;AAGnE,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAG7B,KAAK,CAAC,gBAAgB,CACD,UAAyB,EACrC,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,CAAC,IAAI,iCACzC,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,gBAAgB,CACT,EAAU,EACP,KAAsB,EAC7B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,CAAA;QAC/C,MAAM,UAAU,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,M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,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAUP;AA3GU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,kBAAkB,CA4G9B;AA5GY,gDAAkB;AA8GxB,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,QAAgB,EAChB,OAAe,EACf,QAAgB,EAChB,OAAY,EACZ,OAAoB,yBAAW,CAAC,QAAQ,EACxC,MAAc,IAAI;IAElB,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAmC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAA;QAEvE,uCAAuC;QACvC,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC,CAAC,IAAI,CAAC;YACnC,IAAI;YACJ,MAAM;YACN,QAAQ;YACR,OAAO;YACP,QAAQ;YACR,IAAI;YACJ,GAAG;YACH,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAA;KACH;IAAC,OAAO,KAAK,EAAE;QACd,YAAM,CAAC,KAAK,CAAC,qBAAqB,KAAK,EAAE,CAAC,CAAA;KAC3C;AACH,CAAC;AA7BD,4CA6BC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { logger } from '@things-factory/env'\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { PayloadLog, PayloadType } from './payload-log'\nimport { NewPayloadLog, PayloadLogPatch } from './payload-log-type'\n\n@Resolver(PayloadLog)\nexport class PayloadLogMutation {\n @Directive('@transaction')\n @Mutation(returns => PayloadLog, { description: 'To create new PayloadLog' })\n async createPayloadLog(\n @Arg('payloadLog') payloadLog: NewPayloadLog,\n @Ctx() context: ResolverContext\n ): Promise<PayloadLog> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(PayloadLog).save({\n ...payloadLog,\n domain,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => PayloadLog, { description: 'To modify PayloadLog information' })\n async updatePayloadLog(\n @Arg('id') id: string,\n @Arg('patch') patch: PayloadLogPatch,\n @Ctx() context: ResolverContext\n ): Promise<PayloadLog> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(PayloadLog)\n const payloadLog = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n return await repository.save({\n ...payloadLog,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => [PayloadLog], { description: \"To modify multiple PayloadLogs' information\" })\n async updateMultiplePayloadLog(\n @Arg('patches', type => [PayloadLogPatch]) patches: PayloadLogPatch[],\n @Ctx() context: ResolverContext\n ): Promise<PayloadLog[]> {\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 payloadLogRepo = tx.getRepository(PayloadLog)\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 payloadLogRepo.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 newRecord = _updateRecords[i]\n const payloadLog = await payloadLogRepo.findOneBy({ id: newRecord.id })\n\n const result = await payloadLogRepo.save({\n ...payloadLog,\n ...newRecord,\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 PayloadLog' })\n async deletePayloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(PayloadLog).delete({ domain: { id: domain.id }, id })\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple payloadLogs' })\n async deletePayloadLogs(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(PayloadLog).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n return true\n }\n}\n\nexport async function createPayloadLog(\n name: string,\n endpoint: string,\n request: string,\n response: string,\n context: any,\n type: PayloadType = PayloadType.EGESTION,\n src: string = null\n): Promise<void> {\n try {\n const { domain, user }: { domain: Domain; user: User } = context?.state\n\n // disabled due to high db server usage\n await getRepository(PayloadLog).save({\n name,\n domain,\n endpoint,\n request,\n response,\n type,\n src,\n createdBy: user,\n updatedBy: user,\n createdAt: new Date(),\n updatedAt: new Date()\n })\n } catch (error) {\n logger.error(`PayloadLog Error: ${error}`)\n }\n}\n"]}
@@ -1,10 +1,8 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PayloadLogQuery = void 0;
5
4
  const tslib_1 = require("tslib");
6
5
  const type_graphql_1 = require("type-graphql");
7
- const typeorm_1 = require("typeorm");
8
6
  const auth_base_1 = require("@things-factory/auth-base");
9
7
  const shell_1 = require("@things-factory/shell");
10
8
  const payload_log_1 = require("./payload-log");
@@ -12,8 +10,8 @@ const payload_log_type_1 = require("./payload-log-type");
12
10
  let PayloadLogQuery = class PayloadLogQuery {
13
11
  async payloadLog(id, context) {
14
12
  const { domain } = context.state;
15
- return await (0, typeorm_1.getRepository)(payload_log_1.PayloadLog).findOne({
16
- where: { domain, id }
13
+ return await (0, shell_1.getRepository)(payload_log_1.PayloadLog).findOne({
14
+ where: { domain: { id: domain.id }, id }
17
15
  });
18
16
  }
19
17
  async payloadLogs(params, context) {
@@ -21,17 +19,17 @@ let PayloadLogQuery = class PayloadLogQuery {
21
19
  const convertedParams = (0, shell_1.convertListParams)(params, {
22
20
  domain
23
21
  });
24
- const [items, total] = await (0, typeorm_1.getRepository)(payload_log_1.PayloadLog).findAndCount(convertedParams);
22
+ const [items, total] = await (0, shell_1.getRepository)(payload_log_1.PayloadLog).findAndCount(convertedParams);
25
23
  return { items, total };
26
24
  }
27
25
  async domain(payloadLog) {
28
- return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(payloadLog.domainId);
26
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: payloadLog.domainId });
29
27
  }
30
28
  async updater(payloadLog) {
31
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(payloadLog.updaterId);
29
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: payloadLog.updaterId });
32
30
  }
33
31
  async creator(payloadLog) {
34
- return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(payloadLog.creatorId);
32
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: payloadLog.creatorId });
35
33
  }
36
34
  };
37
35
  tslib_1.__decorate([
@@ -47,7 +45,7 @@ tslib_1.__decorate([
47
45
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
48
46
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
49
47
  tslib_1.__metadata("design:type", Function),
50
- tslib_1.__metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
48
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
51
49
  tslib_1.__metadata("design:returntype", Promise)
52
50
  ], PayloadLogQuery.prototype, "payloadLogs", null);
53
51
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"payload-log-query.js","sourceRoot":"","sources":["../../../server/service/payload-log/payload-log-query.ts"],"names":[],"mappings":";;;;;AAAA,+CAAmF;AACnF,qCAAuC;AAEvC,yDAAgD;AAChD,iDAA4E;AAE5E,+CAA0C;AAC1C,yDAAmD;A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E,CAAC;IACrD,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iDAM7C;AAGD;IADC,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAc,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAChE,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;iEAAjB,iBAAS,oBAAT,iBAAS;;kDAS1C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;6CAE1C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAnCU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,eAAe,CAoC3B;AApCY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { getRepository } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { convertListParams, Domain, ListParam } from '@things-factory/shell'\n\nimport { PayloadLog } from './payload-log'\nimport { PayloadLogList } from './payload-log-type'\n\n@Resolver(PayloadLog)\nexport class PayloadLogQuery {\n @Query(returns => PayloadLog, { description: 'To fetch a PayloadLog' })\n async payloadLog(@Arg('id') id: string, @Ctx() context: any): Promise<PayloadLog> {\n const { domain } = context.state\n\n return await getRepository(PayloadLog).findOne({\n where: { domain, id }\n })\n }\n\n @Query(returns => PayloadLogList, { description: 'To fetch multiple PayloadLogs' })\n async payloadLogs(@Args() params: ListParam, @Ctx() context: any): Promise<PayloadLogList> {\n const { domain } = context.state\n\n const convertedParams = convertListParams(params, {\n domain\n })\n const [items, total] = await getRepository(PayloadLog).findAndCount(convertedParams)\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() payloadLog: PayloadLog): Promise<Domain> {\n return await getRepository(Domain).findOne(payloadLog.domainId)\n }\n\n @FieldResolver(type => User)\n async updater(@Root() payloadLog: PayloadLog): Promise<User> {\n return await getRepository(User).findOne(payloadLog.updaterId)\n }\n\n @FieldResolver(type => User)\n async creator(@Root() payloadLog: PayloadLog): Promise<User> {\n return await getRepository(User).findOne(payloadLog.creatorId)\n }\n}\n"]}
1
+ {"version":3,"file":"payload-log-query.js","sourceRoot":"","sources":["../../../server/service/payload-log/payload-log-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AAEnF,yDAAgD;AAChD,iDAA2F;AAE3F,+CAA0C;AAC1C,yDAAmD;AAGnD,IAAa,eAAe,GAA5B,MAAa,eAAe;IAE1B,KAAK,CAAC,UAAU,CAAY,EAAU,EAAS,OAAwB;QACrE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGD,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAwB;QAC1E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,eAAe,GAAG,IAAA,yBAAiB,EAAC,MAAM,EAAE;YAChD,MAAM;SACP,CAAC,CAAA;QACF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,IAAA,qBAAa,EA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CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAnCU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,eAAe,CAoC3B;AApCY,0CAAe","sourcesContent":["import { Arg, Args, Ctx, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { convertListParams, Domain, getRepository, ListParam } from '@things-factory/shell'\n\nimport { PayloadLog } from './payload-log'\nimport { PayloadLogList } from './payload-log-type'\n\n@Resolver(PayloadLog)\nexport class PayloadLogQuery {\n @Query(returns => PayloadLog, { description: 'To fetch a PayloadLog' })\n async payloadLog(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<PayloadLog> {\n const { domain } = context.state\n\n return await getRepository(PayloadLog).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => PayloadLogList, { description: 'To fetch multiple PayloadLogs' })\n async payloadLogs(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<PayloadLogList> {\n const { domain } = context.state\n\n const convertedParams = convertListParams(params, {\n domain\n })\n const [items, total] = await getRepository(PayloadLog).findAndCount(convertedParams)\n\n return { items, total }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() payloadLog: PayloadLog): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: payloadLog.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() payloadLog: PayloadLog): Promise<User> {\n return await getRepository(User).findOneBy({ id: payloadLog.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() payloadLog: PayloadLog): Promise<User> {\n return await getRepository(User).findOneBy({ id: payloadLog.creatorId })\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a, _b, _c;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PayloadLog = exports.PayloadType = void 0;
5
4
  const tslib_1 = require("tslib");
@@ -25,7 +24,7 @@ tslib_1.__decorate([
25
24
  tslib_1.__decorate([
26
25
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
27
26
  (0, type_graphql_1.Field)({ nullable: true }),
28
- tslib_1.__metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
27
+ tslib_1.__metadata("design:type", shell_1.Domain)
29
28
  ], PayloadLog.prototype, "domain", void 0);
30
29
  tslib_1.__decorate([
31
30
  (0, typeorm_1.RelationId)((payloadLog) => payloadLog.domain),
@@ -50,6 +49,11 @@ tslib_1.__decorate([
50
49
  (0, type_graphql_1.Field)(type => String),
51
50
  tslib_1.__metadata("design:type", String)
52
51
  ], PayloadLog.prototype, "type", 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", String)
56
+ ], PayloadLog.prototype, "src", void 0);
53
57
  tslib_1.__decorate([
54
58
  (0, typeorm_1.Column)(),
55
59
  (0, type_graphql_1.Field)(),
@@ -80,7 +84,7 @@ tslib_1.__decorate([
80
84
  nullable: true
81
85
  }),
82
86
  (0, type_graphql_1.Field)({ nullable: true }),
83
- tslib_1.__metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
87
+ tslib_1.__metadata("design:type", auth_base_1.User)
84
88
  ], PayloadLog.prototype, "creator", void 0);
85
89
  tslib_1.__decorate([
86
90
  (0, typeorm_1.RelationId)((payloadLog) => payloadLog.creator),
@@ -91,7 +95,7 @@ tslib_1.__decorate([
91
95
  nullable: true
92
96
  }),
93
97
  (0, type_graphql_1.Field)({ nullable: true }),
94
- tslib_1.__metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
98
+ tslib_1.__metadata("design:type", auth_base_1.User)
95
99
  ], PayloadLog.prototype, "updater", void 0);
96
100
  tslib_1.__decorate([
97
101
  (0, typeorm_1.RelationId)((payloadLog) => payloadLog.creator),