@things-factory/integration-base 9.0.15 → 9.0.24

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 (61) hide show
  1. package/dist-server/engine/analyzer/analyze-integration.js +2 -2
  2. package/dist-server/engine/analyzer/analyze-integration.js.map +1 -1
  3. package/dist-server/engine/connection-manager.js +6 -4
  4. package/dist-server/engine/connection-manager.js.map +1 -1
  5. package/dist-server/engine/connector/headless-connector.d.ts +8 -0
  6. package/dist-server/engine/connector/headless-connector.js +4 -2
  7. package/dist-server/engine/connector/headless-connector.js.map +1 -1
  8. package/dist-server/engine/connector/mqtt-connector.d.ts +1 -0
  9. package/dist-server/engine/connector/mqtt-connector.js +4 -2
  10. package/dist-server/engine/connector/mqtt-connector.js.map +1 -1
  11. package/dist-server/engine/connector/mssql-connector.d.ts +4 -0
  12. package/dist-server/engine/connector/mssql-connector.js +4 -2
  13. package/dist-server/engine/connector/mssql-connector.js.map +1 -1
  14. package/dist-server/engine/connector/mysql-connector.d.ts +10 -2
  15. package/dist-server/engine/connector/mysql-connector.js +23 -18
  16. package/dist-server/engine/connector/mysql-connector.js.map +1 -1
  17. package/dist-server/engine/connector/operato-connector.d.ts +8 -2
  18. package/dist-server/engine/connector/operato-connector.js +2 -1
  19. package/dist-server/engine/connector/operato-connector.js.map +1 -1
  20. package/dist-server/engine/connector/oracle-connector.d.ts +3 -0
  21. package/dist-server/engine/connector/oracle-connector.js +4 -2
  22. package/dist-server/engine/connector/oracle-connector.js.map +1 -1
  23. package/dist-server/engine/connector/postgresql-connector.d.ts +13 -2
  24. package/dist-server/engine/connector/postgresql-connector.js +14 -6
  25. package/dist-server/engine/connector/postgresql-connector.js.map +1 -1
  26. package/dist-server/engine/connector/pyrun-connector.d.ts +1 -0
  27. package/dist-server/engine/connector/pyrun-connector.js +3 -3
  28. package/dist-server/engine/connector/pyrun-connector.js.map +1 -1
  29. package/dist-server/engine/edge-client.d.ts +1 -1
  30. package/dist-server/engine/edge-client.js.map +1 -1
  31. package/dist-server/service/connection/connection-mutation.d.ts +2 -1
  32. package/dist-server/service/connection/connection-mutation.js +19 -18
  33. package/dist-server/service/connection/connection-mutation.js.map +1 -1
  34. package/dist-server/service/connection/connection-query.d.ts +2 -1
  35. package/dist-server/service/connection/connection-query.js +14 -13
  36. package/dist-server/service/connection/connection-query.js.map +1 -1
  37. package/dist-server/service/connection/connection-subscription.js +5 -4
  38. package/dist-server/service/connection/connection-subscription.js.map +1 -1
  39. package/dist-server/service/connection/connection-type.d.ts +6 -99
  40. package/dist-server/service/connection/connection-type.js +4 -181
  41. package/dist-server/service/connection/connection-type.js.map +1 -1
  42. package/dist-server/service/connection/connection.d.ts +115 -0
  43. package/dist-server/service/connection/connection.js +231 -0
  44. package/dist-server/service/connection/connection.js.map +1 -0
  45. package/dist-server/service/connection/index.d.ts +1 -1
  46. package/dist-server/service/connection/index.js +2 -2
  47. package/dist-server/service/connection/index.js.map +1 -1
  48. package/dist-server/service/connector/connector-query.js +2 -2
  49. package/dist-server/service/connector/connector-query.js.map +1 -1
  50. package/dist-server/service/index.d.ts +1 -0
  51. package/dist-server/service/index.js +1 -0
  52. package/dist-server/service/index.js.map +1 -1
  53. package/dist-server/service/property-spec.d.ts +1 -0
  54. package/dist-server/service/property-spec.js +8 -1
  55. package/dist-server/service/property-spec.js.map +1 -1
  56. package/dist-server/service/scenario/scenario-query.js +3 -3
  57. package/dist-server/service/scenario/scenario-query.js.map +1 -1
  58. package/dist-server/service/task-type/task-type-query.js +2 -2
  59. package/dist-server/service/task-type/task-type-query.js.map +1 -1
  60. package/dist-server/tsconfig.tsbuildinfo +1 -1
  61. package/package.json +10 -10
@@ -6,6 +6,7 @@ const type_graphql_1 = require("type-graphql");
6
6
  const auth_base_1 = require("@things-factory/auth-base");
7
7
  const shell_1 = require("@things-factory/shell");
8
8
  const connection_manager_1 = require("../../engine/connection-manager");
9
+ const connection_1 = require("./connection");
9
10
  const connection_type_1 = require("./connection-type");
10
11
  /**
11
12
  * @description Provides GraphQL resolvers for the Connection entity.
@@ -13,21 +14,21 @@ const connection_type_1 = require("./connection-type");
13
14
  let ConnectionQuery = class ConnectionQuery {
14
15
  async connection(name, context) {
15
16
  const { domain } = context.state;
16
- var connection = await (0, shell_1.getRepository)(connection_type_1.Connection).findOne({
17
+ var connection = await (0, shell_1.getRepository)(connection_1.Connection).findOne({
17
18
  where: { domain: { id: domain.id }, name },
18
19
  relations: ['domain']
19
20
  });
20
21
  return {
21
22
  ...connection,
22
23
  state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
23
- ? connection_type_1.ConnectionStatus.CONNECTED
24
- : connection_type_1.ConnectionStatus.DISCONNECTED
24
+ ? connection_1.ConnectionStatus.CONNECTED
25
+ : connection_1.ConnectionStatus.DISCONNECTED
25
26
  };
26
27
  }
27
28
  async connections(params, context) {
28
29
  const { domain } = context.state;
29
30
  const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
30
- repository: (0, shell_1.getRepository)(connection_type_1.Connection),
31
+ repository: (0, shell_1.getRepository)(connection_1.Connection),
31
32
  params,
32
33
  domain,
33
34
  alias: 'connection',
@@ -36,8 +37,8 @@ let ConnectionQuery = class ConnectionQuery {
36
37
  const [items, total] = await queryBuilder.leftJoinAndSelect('connection.domain', 'domain').getManyAndCount();
37
38
  items.forEach(connection => {
38
39
  connection['state'] = connection_manager_1.ConnectionManager.getConnectionInstance(connection)
39
- ? connection_type_1.ConnectionStatus.CONNECTED
40
- : connection_type_1.ConnectionStatus.DISCONNECTED;
40
+ ? connection_1.ConnectionStatus.CONNECTED
41
+ : connection_1.ConnectionStatus.DISCONNECTED;
41
42
  });
42
43
  return { items, total };
43
44
  }
@@ -46,7 +47,7 @@ let ConnectionQuery = class ConnectionQuery {
46
47
  const connection = connection_manager_1.ConnectionManager.getConnectionInstanceEntityByName(domain, name);
47
48
  return {
48
49
  ...connection,
49
- state: connection ? connection_type_1.ConnectionStatus.CONNECTED : connection_type_1.ConnectionStatus.DISCONNECTED
50
+ state: connection ? connection_1.ConnectionStatus.CONNECTED : connection_1.ConnectionStatus.DISCONNECTED
50
51
  };
51
52
  }
52
53
  async edge(connection) {
@@ -65,7 +66,7 @@ let ConnectionQuery = class ConnectionQuery {
65
66
  exports.ConnectionQuery = ConnectionQuery;
66
67
  tslib_1.__decorate([
67
68
  (0, type_graphql_1.Directive)('@privilege(category: "connection", privilege: "query", domainOwnerGranted: true, superUserGranted: true)'),
68
- (0, type_graphql_1.Query)(returns => connection_type_1.Connection, {
69
+ (0, type_graphql_1.Query)(returns => connection_1.Connection, {
69
70
  description: 'Fetches a single connection by its name, including its current state.'
70
71
  }),
71
72
  tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
@@ -98,31 +99,31 @@ tslib_1.__decorate([
98
99
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
99
100
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
100
101
  tslib_1.__metadata("design:type", Function),
101
- tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
102
+ tslib_1.__metadata("design:paramtypes", [connection_1.Connection]),
102
103
  tslib_1.__metadata("design:returntype", Promise)
103
104
  ], ConnectionQuery.prototype, "edge", null);
104
105
  tslib_1.__decorate([
105
106
  (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
106
107
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
107
108
  tslib_1.__metadata("design:type", Function),
108
- tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
109
+ tslib_1.__metadata("design:paramtypes", [connection_1.Connection]),
109
110
  tslib_1.__metadata("design:returntype", Promise)
110
111
  ], ConnectionQuery.prototype, "domain", null);
111
112
  tslib_1.__decorate([
112
113
  (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
113
114
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
114
115
  tslib_1.__metadata("design:type", Function),
115
- tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
116
+ tslib_1.__metadata("design:paramtypes", [connection_1.Connection]),
116
117
  tslib_1.__metadata("design:returntype", Promise)
117
118
  ], ConnectionQuery.prototype, "updater", null);
118
119
  tslib_1.__decorate([
119
120
  (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
120
121
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
121
122
  tslib_1.__metadata("design:type", Function),
122
- tslib_1.__metadata("design:paramtypes", [connection_type_1.Connection]),
123
+ tslib_1.__metadata("design:paramtypes", [connection_1.Connection]),
123
124
  tslib_1.__metadata("design:returntype", Promise)
124
125
  ], ConnectionQuery.prototype, "creator", null);
125
126
  exports.ConnectionQuery = ConnectionQuery = tslib_1.__decorate([
126
- (0, type_graphql_1.Resolver)(connection_type_1.Connection)
127
+ (0, type_graphql_1.Resolver)(connection_1.Connection)
127
128
  ], ConnectionQuery);
128
129
  //# sourceMappingURL=connection-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,uDAAiG;AAEjG;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,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;YACL,GAAG,UAAU;YACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,kCAAgB,CAAC,SAAS;g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EAAE;QAChC,WAAW,EAAE,0EAA0E;KACxF,CAAC;IAEC,mBAAA,IAAA,mBAAI,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,CAAA;IACvB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAD2B,iBAAS;;kDAsB3C;AAID;IAFC,IAAA,wBAAS,EAAC,0GAA0G,CAAC;IACrH,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;IAC9F,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAA4B,iCAAe;2DAShG;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAClB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;2CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;6CAI1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,4BAAU;;8CAE3C;0BAnFU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,eAAe,CAoF3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, 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/**\n * @description Provides GraphQL resolvers for the Connection entity.\n */\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, {\n description: 'Fetches a single connection by its name, including its current state.'\n })\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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, {\n description: 'Fetches a paginated list of connections, including their current states.'\n })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): 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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'Fetches the current state of a single connection by its name.' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
1
+ {"version":3,"file":"connection-query.js","sourceRoot":"","sources":["../../../server/service/connection/connection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAE9F,yDAA2D;AAC3D,iDAAuG;AAEvG,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmE;AAEnE;;GAEG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IAKpB,AAAN,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,uBAAU,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;YACL,GAAG,UAAU;YACb,KAAK,EAAE,sCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC;gBACxD,CAAC,CAAC,6BAAgB,CAAC,SAAS;gBAC5B,CAAC,CAAC,6BAAgB,CAAC,YAAY;SACpB,CAAA;IACjB,CAAC;IAMK,AAAN,KAAK,CAAC,WAAW,CACU,MAAiB,EACnC,OAAwB;QAE/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B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAD2B,iBAAS;;kDAsB3C;AAID;IAFC,IAAA,wBAAS,EAAC,0GAA0G,CAAC;IACrH,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAe,EAAE,EAAE,WAAW,EAAE,+DAA+D,EAAE,CAAC;IAC9F,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IAAgB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;4CAA4B,iCAAe;2DAShG;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAClB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;2CAExC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;6CAI1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,uBAAU;;8CAE3C;0BAnFU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,eAAe,CAoF3B","sourcesContent":["import { Arg, Args, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\n\nimport { Appliance, User } from '@things-factory/auth-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine/connection-manager'\nimport { Connection, ConnectionStatus } from './connection'\nimport { ConnectionList, ConnectionState } from './connection-type'\n\n/**\n * @description Provides GraphQL resolvers for the Connection entity.\n */\n@Resolver(Connection)\nexport class ConnectionQuery {\n @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => Connection, {\n description: 'Fetches a single connection by its name, including its current state.'\n })\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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionList, {\n description: 'Fetches a paginated list of connections, including their current states.'\n })\n async connections(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): 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 @Directive('@privilege(category: \"connection\", privilege: \"query\", domainOwnerGranted: true, superUserGranted: true)')\n @Query(returns => ConnectionState, { description: 'Fetches the current state of a single connection by its name.' })\n fetchConnectionState(@Arg('name') name: string, @Ctx() context: ResolverContext): ConnectionState {\n const { domain } = context.state\n\n const connection = ConnectionManager.getConnectionInstanceEntityByName(domain, name)\n\n return {\n ...connection,\n state: connection ? ConnectionStatus.CONNECTED : ConnectionStatus.DISCONNECTED\n }\n }\n\n @FieldResolver(type => Domain)\n async edge(@Root() connection: Connection) {\n return connection.edgeId && (await getRepository(Appliance).findOneBy({ id: connection.edgeId }))\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() connection: Connection) {\n return (\n connection.domain || (connection.domainId && (await getRepository(Domain).findOneBy({ id: connection.domainId })))\n )\n }\n\n @FieldResolver(type => User)\n async updater(@Root() connection: Connection): Promise<User> {\n return connection.updaterId && (await getRepository(User).findOneBy({ id: connection.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() connection: Connection): Promise<User> {\n return connection.creatorId && (await getRepository(User).findOneBy({ id: connection.creatorId }))\n }\n}\n"]}
@@ -6,6 +6,7 @@ const graphql_yoga_1 = require("graphql-yoga");
6
6
  const type_graphql_1 = require("type-graphql");
7
7
  const shell_1 = require("@things-factory/shell");
8
8
  const connection_manager_1 = require("../../engine/connection-manager");
9
+ const connection_1 = require("./connection");
9
10
  const connection_type_1 = require("./connection-type");
10
11
  const debug = require('debug')('things-factory:integration:connection-subscription');
11
12
  let ConnectionSubscription = class ConnectionSubscription {
@@ -36,7 +37,7 @@ tslib_1.__decorate([
36
37
  if (name) {
37
38
  where['name'] = name;
38
39
  }
39
- var connections = await (0, shell_1.getRepository)(connection_type_1.Connection).find({
40
+ var connections = await (0, shell_1.getRepository)(connection_1.Connection).find({
40
41
  where,
41
42
  relations: ['domain', 'edge']
42
43
  });
@@ -45,8 +46,8 @@ tslib_1.__decorate([
45
46
  connectionState: {
46
47
  ...connection,
47
48
  state: connection_manager_1.ConnectionManager.getConnectionInstance(connection)
48
- ? connection_type_1.ConnectionStatus.CONNECTED
49
- : connection_type_1.ConnectionStatus.DISCONNECTED,
49
+ ? connection_1.ConnectionStatus.CONNECTED
50
+ : connection_1.ConnectionStatus.DISCONNECTED,
50
51
  timestamp: new Date()
51
52
  }
52
53
  });
@@ -99,6 +100,6 @@ tslib_1.__decorate([
99
100
  tslib_1.__metadata("design:returntype", shell_1.Log)
100
101
  ], ConnectionSubscription.prototype, "connectionLog", null);
101
102
  exports.ConnectionSubscription = ConnectionSubscription = tslib_1.__decorate([
102
- (0, type_graphql_1.Resolver)(connection_type_1.Connection)
103
+ (0, type_graphql_1.Resolver)(connection_1.Connection)
103
104
  ], ConnectionSubscription);
104
105
  //# sourceMappingURL=connection-subscription.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection-subscription.js","sourceRoot":"","sources":["../../../server/service/connection/connection-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,uDAAiF;AAEjF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAmDjC,eAAe,CACL,OAA6C,EACpB,IAAY;QAE7C,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAwCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AAnGY,wDAAsB;AAmDjC;IAlDC,IAAA,2BAAY,EAAC;QACZ,WAAW,EAAE,iDAAiD;QAC9D,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YACrC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;YACrB,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,CAAA;YAEnC,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;YACrC,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;gBACn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AK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBAC9B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,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;iCAlGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,4BAAU,CAAC;GACR,sBAAsB,CAmGlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\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 description: 'Subscribes to the state changes of connections.',\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) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain: { id: domain.id } }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain', 'edge']\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 pipe(\n pubsub.subscribe('connection-state'),\n filter(async (payload: { connectionState: ConnectionState }) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n })\n )\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 description: 'Subscribes to log messages from connections.',\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) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('connection-log'),\n filter(async (payload: { log: Log }) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.log\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 )\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,+CAA2C;AAC3C,+CAAgE;AAEhE,iDAAkE;AAElE,wEAAmE;AACnE,6CAA2D;AAC3D,uDAAmD;AAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAmDjC,eAAe,CACL,OAA6C,EACpB,IAAY;QAE7C,OAAO,OAAO,CAAC,eAAe,CAAA;IAChC,CAAC;IAwCD,aAAa,CAAS,OAAqB,EAAoC,KAAa;QAC1F,OAAO,OAAO,CAAC,GAAG,CAAA;IACpB,CAAC;CACF,CAAA;AAnGY,wDAAsB;AAmDjC;IAlDC,IAAA,2BAAY,EAAC;QACZ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AAC,CAAA;YACpC,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;gBACnG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;YACjF,CAAC;YAED,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAClC,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAqB,EAAE,EAAE;gBACrC,gCAAgC;gBAChC,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAA;gBACnD,qCAAqC;gBAErC,0CAA0C;gBAC1C,iBAAiB;gBACjB,IAAI;gBAEJ,IAAI,KAAK,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;oBAC9B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,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;iCAlGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,sBAAsB,CAmGlC","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\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, ConnectionStatus } from './connection'\nimport { ConnectionState } from './connection-type'\n\nconst debug = require('debug')('things-factory:integration:connection-subscription')\n\n@Resolver(Connection)\nexport class ConnectionSubscription {\n @Subscription({\n description: 'Subscribes to the state changes of connections.',\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) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n process.nextTick(async () => {\n var where = { domain: { id: domain.id } }\n if (name) {\n where['name'] = name\n }\n\n var connections = await getRepository(Connection).find({\n where,\n relations: ['domain', 'edge']\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 pipe(\n pubsub.subscribe('connection-state'),\n filter(async (payload: { connectionState: ConnectionState }) => {\n const { domain: pdomain, name: pname } = payload.connectionState\n\n return (!name || name === pname) && subdomain === pdomain?.subdomain\n })\n )\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 description: 'Subscribes to log messages from connections.',\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) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('connection-log'),\n filter(async (payload: { log: Log }) => {\n // TODO support domain filtering\n const { /* source, */ level: plevel } = payload.log\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 )\n }\n })\n connectionLog(@Root() payload: { log: Log }, @Arg('level', { nullable: true }) level: string): Log {\n return payload.log\n }\n}\n"]}
@@ -1,109 +1,16 @@
1
- import { User, Appliance } from '@things-factory/auth-base';
1
+ import { Appliance } from '@things-factory/auth-base';
2
2
  import { Domain } from '@things-factory/shell';
3
- export declare enum ConnectionStatus {
4
- CONNECTED = "CONNECTED",// Represents an active, established connection.
5
- DISCONNECTED = "DISCONNECTED"
6
- }
7
- export declare class Connection {
8
- /**
9
- * Unique identifier for the connection, generated in UUID format.
10
- */
11
- readonly id: string;
12
- /**
13
- * Many-to-One relationship with the Domain entity.
14
- */
15
- domain: Domain;
16
- /**
17
- * Stores the ID of the associated Domain.
18
- */
19
- domainId: string;
20
- /**
21
- * The name of the connection.
22
- */
23
- name: string;
24
- /**
25
- * Optional description for the connection.
26
- */
27
- description: string;
28
- /**
29
- * The type of the connection.
30
- */
31
- type: string;
32
- /**
33
- * Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.
34
- */
35
- edge: Appliance;
36
- /**
37
- * Stores the ID of the Appliance who delegate the connection.
38
- */
39
- edgeId: string;
40
- /**
41
- * The endpoint for the connection.
42
- */
43
- endpoint: string;
44
- /**
45
- * Indicates the active status of the connection.
46
- */
47
- active: boolean;
48
- /**
49
- * The status of the connection, using the ConnectionStatus type.
50
- */
51
- state: ConnectionStatus;
52
- /**
53
- * Additional parameters for the connection, stored as a JSON string.
54
- *
55
- * [Caution]
56
- * 이 컬럼타입은 postgres 데이터베이스에서는 varchar 타입을 유지한다.
57
- * 이는 데이터베이스 타입을 변경하면 기존 데이터가 손실될 수 있기 때문이다.
58
- * 'simple-json' 타입으로 변경 전에 postgres 데이타베이스에 이미 varchar 타입으로 사용한 사례가 많기 때문이다.
59
- */
60
- params: {
61
- [key: string]: any;
62
- };
63
- /**
64
- * The date and time when the connection was created.
65
- */
66
- createdAt: Date;
67
- /**
68
- * The date and time when the connection was last updated.
69
- */
70
- updatedAt: Date;
71
- /**
72
- * Many-to-One relationship with the User entity who created the connection. Optional field.
73
- */
74
- creator: User;
75
- /**
76
- * Stores the ID of the User who created the connection.
77
- */
78
- creatorId: string;
79
- /**
80
- * Many-to-One relationship with the User entity who last updated the connection.
81
- * Optional field.
82
- */
83
- updater: User;
84
- /**
85
- * Stores the ID of the User who last updated the connection.
86
- *
87
- */
88
- updaterId: string;
89
- /**
90
- * Asynchronous method to establish the connection.
91
- *
92
- */
93
- connect(): Promise<void>;
94
- /**
95
- * @brief Asynchronous method to disconnect the connection.
96
- *
97
- */
98
- disconnect(): Promise<void>;
99
- }
3
+ import { Connection } from './connection';
4
+ import { ConnectionStatus } from './connection';
100
5
  /**
101
6
  * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로
102
7
  * 추후, 타입 일치를 통해서 제거할 예정임.
103
8
  *
104
9
  */
105
10
  export interface InputConnection extends Connection {
106
- params: any;
11
+ params: {
12
+ [key: string]: any;
13
+ };
107
14
  }
108
15
  export declare class ConnectionState {
109
16
  domain?: Domain;
@@ -1,189 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionList = exports.ConnectionPatch = exports.NewConnection = exports.ConnectionState = exports.Connection = exports.ConnectionStatus = void 0;
3
+ exports.ConnectionList = exports.ConnectionPatch = exports.NewConnection = exports.ConnectionState = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
- const typeorm_1 = require("typeorm");
7
6
  const auth_base_1 = require("@things-factory/auth-base");
8
- const env_1 = require("@things-factory/env");
9
7
  const shell_1 = require("@things-factory/shell");
10
- const engine_1 = require("../../engine");
11
- const proxy_connector_1 = require("../../engine/connector/proxy-connector");
12
- const ORMCONFIG = env_1.config.get('ormconfig', {});
13
- const DATABASE_TYPE = ORMCONFIG.type;
14
- var ConnectionStatus;
15
- (function (ConnectionStatus) {
16
- ConnectionStatus["CONNECTED"] = "CONNECTED";
17
- ConnectionStatus["DISCONNECTED"] = "DISCONNECTED"; // Represents a terminated or inactive connection.
18
- })(ConnectionStatus || (exports.ConnectionStatus = ConnectionStatus = {}));
19
- (0, type_graphql_1.registerEnumType)(ConnectionStatus, {
20
- name: 'ConnectionStatus',
21
- description: 'Enumeration of possible states for a connection.'
22
- });
23
- let Connection = class Connection {
24
- /**
25
- * Asynchronous method to establish the connection.
26
- *
27
- */
28
- async connect() {
29
- const { type, edge } = this;
30
- const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
31
- await connector.connect({
32
- ...this,
33
- params: this.params || {}
34
- });
35
- }
36
- /**
37
- * @brief Asynchronous method to disconnect the connection.
38
- *
39
- */
40
- async disconnect() {
41
- try {
42
- const { type, edge } = this;
43
- const connector = edge ? proxy_connector_1.ProxyConnector.instance : engine_1.ConnectionManager.getConnector(type);
44
- await connector.disconnect(this);
45
- }
46
- finally {
47
- }
48
- }
49
- };
50
- exports.Connection = Connection;
51
- tslib_1.__decorate([
52
- (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
53
- (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the connection.' }),
54
- tslib_1.__metadata("design:type", String)
55
- ], Connection.prototype, "id", void 0);
56
- tslib_1.__decorate([
57
- (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
58
- (0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true, description: 'The domain to which this connection belongs.' }),
59
- tslib_1.__metadata("design:type", shell_1.Domain
60
- /**
61
- * Stores the ID of the associated Domain.
62
- */
63
- )
64
- ], Connection.prototype, "domain", void 0);
65
- tslib_1.__decorate([
66
- (0, typeorm_1.RelationId)((connection) => connection.domain),
67
- tslib_1.__metadata("design:type", String)
68
- ], Connection.prototype, "domainId", void 0);
69
- tslib_1.__decorate([
70
- (0, typeorm_1.Column)(),
71
- (0, type_graphql_1.Field)({ description: 'The name of the connection.' }),
72
- tslib_1.__metadata("design:type", String)
73
- ], Connection.prototype, "name", void 0);
74
- tslib_1.__decorate([
75
- (0, typeorm_1.Column)({
76
- nullable: true
77
- }),
78
- (0, type_graphql_1.Field)({ nullable: true, description: 'A detailed description of the connection.' }),
79
- tslib_1.__metadata("design:type", String)
80
- ], Connection.prototype, "description", void 0);
81
- tslib_1.__decorate([
82
- (0, typeorm_1.Column)(),
83
- (0, type_graphql_1.Field)({ nullable: true, description: 'The type of the connection (e.g., tcp, http, mqtt).' }),
84
- tslib_1.__metadata("design:type", String)
85
- ], Connection.prototype, "type", void 0);
86
- tslib_1.__decorate([
87
- (0, typeorm_1.ManyToOne)(type => auth_base_1.Appliance, { nullable: true }),
88
- (0, type_graphql_1.Field)({ nullable: true, description: 'The edge appliance that delegates this connection, if any.' }),
89
- tslib_1.__metadata("design:type", auth_base_1.Appliance
90
- /**
91
- * Stores the ID of the Appliance who delegate the connection.
92
- */
93
- )
94
- ], Connection.prototype, "edge", void 0);
95
- tslib_1.__decorate([
96
- (0, typeorm_1.RelationId)((connection) => connection.edge),
97
- tslib_1.__metadata("design:type", String)
98
- ], Connection.prototype, "edgeId", void 0);
99
- tslib_1.__decorate([
100
- (0, typeorm_1.Column)(),
101
- (0, type_graphql_1.Field)({ nullable: true, description: 'The endpoint URL or address for the connection.' }),
102
- tslib_1.__metadata("design:type", String)
103
- ], Connection.prototype, "endpoint", void 0);
104
- tslib_1.__decorate([
105
- (0, typeorm_1.Column)({ nullable: true }),
106
- (0, type_graphql_1.Field)({
107
- nullable: true,
108
- description: 'Indicates whether the connection is currently active and should be maintained.'
109
- }),
110
- tslib_1.__metadata("design:type", Boolean)
111
- ], Connection.prototype, "active", void 0);
112
- tslib_1.__decorate([
113
- (0, type_graphql_1.Field)({ nullable: true, description: 'The current status of the connection (e.g., CONNECTED, DISCONNECTED).' }),
114
- tslib_1.__metadata("design:type", String)
115
- ], Connection.prototype, "state", void 0);
116
- tslib_1.__decorate([
117
- (0, typeorm_1.Column)({
118
- type: DATABASE_TYPE == 'postgres' ? 'varchar' : 'simple-json',
119
- nullable: true,
120
- transformer: DATABASE_TYPE == 'postgres'
121
- ? {
122
- to: (value) => JSON.stringify(value),
123
- from: (value) => {
124
- try {
125
- return JSON.parse(value);
126
- }
127
- catch (error) {
128
- return null;
129
- }
130
- }
131
- }
132
- : undefined
133
- }),
134
- (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true, description: 'A key-value map of parameters for the connection.' }),
135
- tslib_1.__metadata("design:type", Object)
136
- ], Connection.prototype, "params", void 0);
137
- tslib_1.__decorate([
138
- (0, typeorm_1.CreateDateColumn)(),
139
- (0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the connection was created.' }),
140
- tslib_1.__metadata("design:type", Date
141
- /**
142
- * The date and time when the connection was last updated.
143
- */
144
- )
145
- ], Connection.prototype, "createdAt", void 0);
146
- tslib_1.__decorate([
147
- (0, typeorm_1.UpdateDateColumn)(),
148
- (0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the connection was last updated.' }),
149
- tslib_1.__metadata("design:type", Date
150
- /**
151
- * Many-to-One relationship with the User entity who created the connection. Optional field.
152
- */
153
- )
154
- ], Connection.prototype, "updatedAt", void 0);
155
- tslib_1.__decorate([
156
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
157
- (0, type_graphql_1.Field)({ nullable: true, description: 'The user who created the connection.' }),
158
- tslib_1.__metadata("design:type", auth_base_1.User
159
- /**
160
- * Stores the ID of the User who created the connection.
161
- */
162
- )
163
- ], Connection.prototype, "creator", void 0);
164
- tslib_1.__decorate([
165
- (0, typeorm_1.RelationId)((connection) => connection.creator),
166
- tslib_1.__metadata("design:type", String)
167
- ], Connection.prototype, "creatorId", void 0);
168
- tslib_1.__decorate([
169
- (0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
170
- (0, type_graphql_1.Field)({ nullable: true, description: 'The user who last updated the connection.' }),
171
- tslib_1.__metadata("design:type", auth_base_1.User
172
- /**
173
- * Stores the ID of the User who last updated the connection.
174
- *
175
- */
176
- )
177
- ], Connection.prototype, "updater", void 0);
178
- tslib_1.__decorate([
179
- (0, typeorm_1.RelationId)((connection) => connection.updater),
180
- tslib_1.__metadata("design:type", String)
181
- ], Connection.prototype, "updaterId", void 0);
182
- exports.Connection = Connection = tslib_1.__decorate([
183
- (0, typeorm_1.Entity)(),
184
- (0, typeorm_1.Index)('ix_connection_0', (connection) => [connection.domain, connection.name], { unique: true }),
185
- (0, type_graphql_1.ObjectType)({ description: 'Represents a configured connection to an external system or service.' })
186
- ], Connection);
8
+ const connection_1 = require("./connection");
9
+ const connection_2 = require("./connection");
187
10
  let ConnectionState = class ConnectionState {
188
11
  };
189
12
  exports.ConnectionState = ConnectionState;
@@ -301,7 +124,7 @@ let ConnectionList = class ConnectionList {
301
124
  };
302
125
  exports.ConnectionList = ConnectionList;
303
126
  tslib_1.__decorate([
304
- (0, type_graphql_1.Field)(type => [Connection], { description: 'The list of connection items.' }),
127
+ (0, type_graphql_1.Field)(type => [connection_1.Connection], { description: 'The list of connection items.' }),
305
128
  tslib_1.__metadata("design:type", Array)
306
129
  ], ConnectionList.prototype, "items", void 0);
307
130
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAsF;AACtF,qCASgB;AAEhB,yDAA2D;AAC3D,6CAA4C;AAC5C,iDAAuE;AAEvE,yCAAgD;AAChD,4EAAuE;AAEvE,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,2CAAuB,CAAA;IACvB,iDAA6B,CAAA,CAAC,kDAAkD;AAClF,CAAC,EAHW,gBAAgB,gCAAhB,gBAAgB,QAG3B;AAED,IAAA,+BAAgB,EAAC,gBAAgB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,EAAE,iFAAiF;KAC/F,CAAC;;+CACa;0BA7BJ,eAAe;IAD3B,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,uDAAuD,EAAE,CAAC;GACvE,eAAe,CA8B3B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;6CAC3D;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3D;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","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, Appliance } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\nimport { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { ConnectionManager } from '../../engine'\nimport { ProxyConnector } from '../../engine/connector/proxy-connector'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum ConnectionStatus {\n CONNECTED = 'CONNECTED', // Represents an active, established connection.\n DISCONNECTED = 'DISCONNECTED' // Represents a terminated or inactive connection.\n}\n\nregisterEnumType(ConnectionStatus, {\n name: 'ConnectionStatus',\n description: 'Enumeration of possible states for a connection.'\n})\n\n@Entity()\n@Index('ix_connection_0', (connection: Connection) => [connection.domain, connection.name], { unique: true })\n@ObjectType({ description: 'Represents a configured connection to an external system or service.' })\nexport class Connection {\n /**\n * Unique identifier for the connection, generated in UUID format.\n */\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the connection.' })\n readonly id: string\n\n /**\n * Many-to-One relationship with the Domain entity.\n */\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain to which this connection belongs.' })\n domain: Domain\n\n /**\n * Stores the ID of the associated Domain.\n */\n @RelationId((connection: Connection) => connection.domain)\n domainId: string\n\n /**\n * The name of the connection.\n */\n @Column()\n @Field({ description: 'The name of the connection.' })\n name: string\n\n /**\n * Optional description for the connection.\n */\n @Column({\n nullable: true\n })\n @Field({ nullable: true, description: 'A detailed description of the connection.' })\n description: string\n\n /**\n * The type of the connection.\n */\n @Column()\n @Field({ nullable: true, description: 'The type of the connection (e.g., tcp, http, mqtt).' })\n type: string\n\n /**\n * Many-to-One relationship with the Appliance entity which delegate the connection. Optional field.\n */\n @ManyToOne(type => Appliance, { nullable: true })\n @Field({ nullable: true, description: 'The edge appliance that delegates this connection, if any.' })\n edge: Appliance\n\n /**\n * Stores the ID of the Appliance who delegate the connection.\n */\n @RelationId((connection: Connection) => connection.edge)\n edgeId: string\n\n /**\n * The endpoint for the connection.\n */\n @Column()\n @Field({ nullable: true, description: 'The endpoint URL or address for the connection.' })\n endpoint: string\n\n /**\n * Indicates the active status of the connection.\n */\n @Column({ nullable: true })\n @Field({\n nullable: true,\n description: 'Indicates whether the connection is currently active and should be maintained.'\n })\n active: boolean\n\n /**\n * The status of the connection, using the ConnectionStatus type.\n */\n @Field({ nullable: true, description: 'The current status of the connection (e.g., CONNECTED, DISCONNECTED).' })\n state: ConnectionStatus\n\n /**\n * Additional parameters for the connection, stored as a JSON string.\n *\n * [Caution]\n * 이 컬럼타입은 postgres 데이터베이스에서는 varchar 타입을 유지한다.\n * 이는 데이터베이스 타입을 변경하면 기존 데이터가 손실될 수 있기 때문이다.\n * 'simple-json' 타입으로 변경 전에 postgres 데이타베이스에 이미 varchar 타입으로 사용한 사례가 많기 때문이다.\n */\n @Column({\n type: DATABASE_TYPE == 'postgres' ? 'varchar' : 'simple-json',\n nullable: true,\n transformer:\n DATABASE_TYPE == 'postgres'\n ? {\n to: (value: any) => JSON.stringify(value),\n from: (value: string) => {\n try {\n return JSON.parse(value)\n } catch (error) {\n return null\n }\n }\n }\n : undefined\n })\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the connection.' })\n params: { [key: string]: any }\n\n /**\n * The date and time when the connection was created.\n */\n @CreateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the connection was created.' })\n createdAt: Date\n\n /**\n * The date and time when the connection was last updated.\n */\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'The timestamp when the connection was last updated.' })\n updatedAt: Date\n\n /**\n * Many-to-One relationship with the User entity who created the connection. Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who created the connection.' })\n creator: User\n\n /**\n * Stores the ID of the User who created the connection.\n */\n @RelationId((connection: Connection) => connection.creator)\n creatorId: string\n\n /**\n * Many-to-One relationship with the User entity who last updated the connection.\n * Optional field.\n */\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who last updated the connection.' })\n updater: User\n\n /**\n * Stores the ID of the User who last updated the connection.\n *\n */\n @RelationId((connection: Connection) => connection.updater)\n updaterId: string\n\n /**\n * Asynchronous method to establish the connection.\n *\n */\n async connect() {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n\n await connector.connect({\n ...this,\n params: this.params || {}\n })\n }\n\n /**\n * @brief Asynchronous method to disconnect the connection.\n *\n */\n async disconnect() {\n try {\n const { type, edge } = this\n const connector = edge ? ProxyConnector.instance : ConnectionManager.getConnector(type)\n await connector.disconnect(this)\n } finally {\n }\n }\n}\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: any\n}\n\n@ObjectType({ description: 'Represents the state of a connection at a point in time.' })\nexport class ConnectionState {\n @Field(type => Domain, { description: 'The domain of the connection.' })\n domain?: Domain\n\n @Field({ nullable: true, description: 'The unique identifier of the connection.' })\n id?: string\n\n @Field({ nullable: true, description: 'The name of the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The description of the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the connection.' })\n type?: string\n\n @Field(type => Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The current status of the connection.' })\n state?: ConnectionStatus\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n timestamp?: Date\n}\n\n@InputType({ description: 'Input for creating a new connection.' })\nexport class NewConnection {\n @Field({ description: 'The name for the new connection.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The endpoint URL or address for the new connection.' })\n endpoint?: string\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' })\n params?: { [key: string]: any }\n}\n\n@InputType({ description: 'Input for updating (patching) an existing connection.' })\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the connection to update.' })\n id: string\n\n @Field({ nullable: true, description: 'The new name for the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the connection.' })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The new endpoint for the connection.' })\n endpoint?: string\n\n @Field({ nullable: true, description: 'The new active status for the connection.' })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'The new parameters for the connection.' })\n params?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the connection is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of connections.' })\nexport class ConnectionList {\n @Field(type => [Connection], { description: 'The list of connection items.' })\n items: Connection[]\n\n @Field(type => Int, { description: 'The total number of connections.' })\n total: number\n}\n"]}
1
+ {"version":3,"file":"connection-type.js","sourceRoot":"","sources":["../../../server/service/connection/connection-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAqD;AACrD,iDAAuE;AAEvE,6CAAyC;AACzC,6CAA+C;AAYxC,IAAM,eAAe,GAArB,MAAM,eAAe;CAwB3B,CAAA;AAxBY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC/D,cAAM;+CAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;;2CACxE;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;;oDACzD;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;;6CACzD;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,oDAAoD,EAAE,CAAC;sCACzG,qBAAS;6CAAA;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EA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EAAE,+BAA+B,EAAE,CAAC;;6CAC3D;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3D;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { Appliance } from '@things-factory/auth-base'\nimport { Domain, ObjectRef, ScalarObject } from '@things-factory/shell'\n\nimport { Connection } from './connection'\nimport { ConnectionStatus } from './connection'\n\n/**\n * Connection의 params의 원 타입과 사용 시에 타입 불일치로 인해 임시적으로 생성한 타입으로\n * 추후, 타입 일치를 통해서 제거할 예정임.\n *\n */\nexport interface InputConnection extends Connection {\n params: { [key: string]: any }\n}\n\n@ObjectType({ description: 'Represents the state of a connection at a point in time.' })\nexport class ConnectionState {\n @Field(type => Domain, { description: 'The domain of the connection.' })\n domain?: Domain\n\n @Field({ nullable: true, description: 'The unique identifier of the connection.' })\n id?: string\n\n @Field({ nullable: true, description: 'The name of the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The description of the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the connection.' })\n type?: string\n\n @Field(type => Appliance, { nullable: true, description: 'The edge appliance associated with the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The current status of the connection.' })\n state?: ConnectionStatus\n\n @Field({ nullable: true, description: 'The timestamp when this state was recorded.' })\n timestamp?: Date\n}\n\n@InputType({ description: 'Input for creating a new connection.' })\nexport class NewConnection {\n @Field({ description: 'The name for the new connection.' })\n name: string\n\n @Field({ nullable: true, description: 'A detailed description for the new connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The type of the new connection (e.g., tcp, http, mqtt).' })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'Reference to the edge appliance for the new connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The endpoint URL or address for the new connection.' })\n endpoint?: string\n\n @Field(type => ScalarObject, { nullable: true, description: 'A key-value map of parameters for the new connection.' })\n params?: { [key: string]: any }\n}\n\n@InputType({ description: 'Input for updating (patching) an existing connection.' })\nexport class ConnectionPatch {\n @Field(type => ID, { nullable: true, description: 'The unique identifier of the connection to update.' })\n id: string\n\n @Field({ nullable: true, description: 'The new name for the connection.' })\n name?: string\n\n @Field({ nullable: true, description: 'The new description for the connection.' })\n description?: string\n\n @Field({ nullable: true, description: 'The new type for the connection.' })\n type?: string\n\n @Field(type => ObjectRef, { nullable: true, description: 'The new edge appliance for the connection.' })\n edge?: Appliance\n\n @Field({ nullable: true, description: 'The new endpoint for the connection.' })\n endpoint?: string\n\n @Field({ nullable: true, description: 'The new active status for the connection.' })\n active?: boolean\n\n @Field(type => ScalarObject, { nullable: true, description: 'The new parameters for the connection.' })\n params?: { [key: string]: any }\n\n @Field({\n nullable: true,\n description: 'A flag indicating whether the connection is being created, updated, or deleted.'\n })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of connections.' })\nexport class ConnectionList {\n @Field(type => [Connection], { description: 'The list of connection items.' })\n items: Connection[]\n\n @Field(type => Int, { description: 'The total number of connections.' })\n total: number\n}\n"]}