@things-factory/integration-base 9.0.25 → 9.0.26

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.
@@ -56,7 +56,7 @@ tslib_1.__decorate([
56
56
  });
57
57
  return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('connection-state'), (0, graphql_yoga_1.filter)(async (payload) => {
58
58
  const { domain: pdomain, name: pname } = payload.connectionState;
59
- return (!name || name === pname) && subdomain === pdomain?.subdomain;
59
+ return (!name || name === pname) && (subdomain === pdomain?.subdomain || pdomain?.id === domain.parentId);
60
60
  }));
61
61
  }
62
62
  }),
@@ -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,6CAA2D;AAC3D,uDAAmD;AAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AAG7E,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAoDjC,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;AApGY,wDAAsB;AAoDjC;IAnDC,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,C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AA6B,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;iCAnGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,sBAAsB,CAoGlC","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 domain /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */,\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;AAE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C,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;iCAnGU,sBAAsB;IADlC,IAAA,uBAAQ,EAAC,uBAAU,CAAC;GACR,sBAAsB,CAoGlC","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 domain /* 상속 및 on-demand 연결에서 connection.domain 과 다를 수 있음 */,\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 || pdomain?.id === domain.parentId)\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"]}