@things-factory/dataset 6.2.87 → 7.0.0-alpha.1

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.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DataOocSubscription = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const graphql_subscriptions_1 = require("graphql-subscriptions");
5
+ const graphql_yoga_1 = require("graphql-yoga");
6
6
  const type_graphql_1 = require("type-graphql");
7
7
  const auth_base_1 = require("@things-factory/auth-base");
8
8
  const shell_1 = require("@things-factory/shell");
@@ -14,7 +14,7 @@ let DataOocSubscription = class DataOocSubscription {
14
14
  };
15
15
  tslib_1.__decorate([
16
16
  (0, type_graphql_1.Subscription)({
17
- subscribe: (_, args, context, info) => {
17
+ subscribe: ({ args, context, info }) => {
18
18
  var _a;
19
19
  const { domain, user } = context.state;
20
20
  const subdomain = domain === null || domain === void 0 ? void 0 : domain.subdomain;
@@ -24,7 +24,7 @@ tslib_1.__decorate([
24
24
  if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
25
25
  throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
26
26
  }
27
- return (0, graphql_subscriptions_1.withFilter)(() => shell_1.pubsub.asyncIterator('data-ooc'), async (payload, variables, context, info) => {
27
+ return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('data-ooc'), (0, graphql_yoga_1.filter)(async (payload) => {
28
28
  const { dataOoc, supervisoryRoleId } = payload;
29
29
  const { domain } = dataOoc;
30
30
  if (subdomain !== (domain === null || domain === void 0 ? void 0 : domain.subdomain)) {
@@ -36,7 +36,7 @@ tslib_1.__decorate([
36
36
  relations: ['roles']
37
37
  });
38
38
  return !!userWithRoles.roles.find(role => role.id === supervisoryRoleId);
39
- })(_, args, context, info);
39
+ }));
40
40
  }
41
41
  }),
42
42
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -1 +1 @@
1
- {"version":3,"file":"data-ooc-subscription.js","sourceRoot":"","sources":["../../../server/service/data-ooc/data-ooc-subscription.ts"],"names":[],"mappings":";;;;AAAA,iEAAkD;AAClD,+CAA2D;AAE3D,yDAAgD;AAChD,iDAA6D;AAE7D,yCAAoC;AAG7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAmC9B,OAAO,CAAS,OAAwD;QACtE,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC;CACF,CAAA;AArCC;IAAC,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,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;aACnC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAClG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aAChF;YAED,OAAO,IAAA,kCAAU,EACf,GAAG,EAAE,CAAC,cAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EACtC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBAC1C,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAA;gBAC9C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;gBAE1B,IAAI,SAAS,MAAK,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA,EAAE;oBACnC,OAAO,KAAK,CAAA;iBACb;gBAED,kCAAkC;gBAClC,MAAM,aAAa,GAAS,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;oBAC5D,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;oBACtB,SAAS,EAAE,CAAC,OAAO,CAAC;iBACrB,CAAC,CAAA;gBAEF,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,iBAAiB,CAAC,CAAA;YAC1E,CAAC,CACF,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,CAAA;QAC3B,CAAC;KACF,CAAC;IACO,mBAAA,IAAA,mBAAI,GAAE,CAAA;;;4CAA4D,kBAAO;kDAEjF;AArCU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,kBAAO,CAAC;GACL,mBAAmB,CAsC/B;AAtCY,kDAAmB","sourcesContent":["import { withFilter } from 'graphql-subscriptions'\nimport { Resolver, Root, Subscription } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { getRepository, pubsub } from '@things-factory/shell'\n\nimport { DataOoc } from './data-ooc'\n\n@Resolver(DataOoc)\nexport class DataOocSubscription {\n @Subscription({\n subscribe: (_, args, context, info) => {\n const { domain, user } = context.state\n const subdomain = domain?.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 withFilter(\n () => pubsub.asyncIterator('data-ooc'),\n async (payload, variables, context, info) => {\n const { dataOoc, supervisoryRoleId } = payload\n const { domain } = dataOoc\n\n if (subdomain !== domain?.subdomain) {\n return false\n }\n\n // check if the user has that role\n const userWithRoles: User = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n\n return !!userWithRoles.roles.find(role => role.id === supervisoryRoleId)\n }\n )(_, args, context, info)\n }\n })\n dataOoc(@Root() payload: { dataOoc: DataOoc; supervisoryRoleId: string }): DataOoc {\n return payload.dataOoc\n }\n}\n"]}
1
+ {"version":3,"file":"data-ooc-subscription.js","sourceRoot":"","sources":["../../../server/service/data-ooc/data-ooc-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAA2D;AAE3D,yDAAgD;AAChD,iDAA6D;AAE7D,yCAAoC;AAG7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAmC9B,OAAO,CAAS,OAAwD;QACtE,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC;CACF,CAAA;AArCC;IAAC,IAAA,2BAAY,EAAC;QACZ,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,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;aACnC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAClG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aAChF;YAED,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,UAAU,CAAC,EAC5B,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAwD,EAAE,EAAE;gBACxE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAA;gBAC9C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;gBAE1B,IAAI,SAAS,MAAK,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA,EAAE;oBACnC,OAAO,KAAK,CAAA;iBACb;gBAED,kCAAkC;gBAClC,MAAM,aAAa,GAAS,MAAM,IAAA,qBAAa,EAAC,gBAAI,CAAC,CAAC,OAAO,CAAC;oBAC5D,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE;oBACtB,SAAS,EAAE,CAAC,OAAO,CAAC;iBACrB,CAAC,CAAA;gBAEF,OAAO,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,iBAAiB,CAAC,CAAA;YAC1E,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACO,mBAAA,IAAA,mBAAI,GAAE,CAAA;;;4CAA4D,kBAAO;kDAEjF;AArCU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,kBAAO,CAAC;GACL,mBAAmB,CAsC/B;AAtCY,kDAAmB","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Resolver, Root, Subscription } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { getRepository, pubsub } from '@things-factory/shell'\n\nimport { DataOoc } from './data-ooc'\n\n@Resolver(DataOoc)\nexport class DataOocSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const subdomain = domain?.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('data-ooc'),\n filter(async (payload: { dataOoc: DataOoc; supervisoryRoleId: string }) => {\n const { dataOoc, supervisoryRoleId } = payload\n const { domain } = dataOoc\n\n if (subdomain !== domain?.subdomain) {\n return false\n }\n\n // check if the user has that role\n const userWithRoles: User = await getRepository(User).findOne({\n where: { id: user.id },\n relations: ['roles']\n })\n\n return !!userWithRoles.roles.find(role => role.id === supervisoryRoleId)\n })\n )\n }\n })\n dataOoc(@Root() payload: { dataOoc: DataOoc; supervisoryRoleId: string }): DataOoc {\n return payload.dataOoc\n }\n}\n"]}