@things-factory/dataset 10.0.0-beta.94 → 10.0.0-y.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -26,7 +26,7 @@ exports.DataOocSubscription = DataOocSubscription;
|
|
|
26
26
|
tslib_1.__decorate([
|
|
27
27
|
(0, type_graphql_1.Subscription)({
|
|
28
28
|
description: 'Real-time subscription for out-of-control (OOC) events. Users with supervisory roles receive immediate notifications when OOC events occur in their domain.',
|
|
29
|
-
subscribe: ({ args, context, info }) => {
|
|
29
|
+
subscribe: async ({ args, context, info }) => {
|
|
30
30
|
const { domain, user } = context.state;
|
|
31
31
|
const subdomain = domain?.subdomain;
|
|
32
32
|
// Validate domain access
|
|
@@ -34,7 +34,7 @@ tslib_1.__decorate([
|
|
|
34
34
|
throw new Error('domain required');
|
|
35
35
|
}
|
|
36
36
|
// Check user domain access permissions
|
|
37
|
-
if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
|
|
37
|
+
if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {
|
|
38
38
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
|
39
39
|
}
|
|
40
40
|
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('data-ooc'), (0, graphql_yoga_1.filter)(async (payload) => {
|
|
@@ -1 +1 @@
|
|
|
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,+CAAuC;AAGhC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B;;;;OAIG;IAwCH,OAAO,CAAS,OAAwD;QACtE;;;;WAIG;QACH,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC;CACF,CAAA;AArDY,kDAAmB;A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K,EAAE,OAAwD,EAAE,EAAE;gBACxE,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAA;gBAC9C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;gBAE1B,yEAAyE;gBACzE,IAAI,SAAS,KAAK,MAAM,EAAE,SAAS,EAAE,CAAC;oBACpC,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,yEAAyE;gBACzE,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,qBAAO;kDAOjF;8BApDU,mBAAmB;IAD/B,IAAA,uBAAQ,EAAC,qBAAO,CAAC;GACL,mBAAmB,CAqD/B","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.js'\n\n@Resolver(DataOoc)\nexport class DataOocSubscription {\n /**\n * Real-time subscription for out-of-control (OOC) events.\n * This subscription allows users with supervisory roles to receive immediate notifications\n * when new OOC events are created or updated in their domain.\n */\n @Subscription({\n description:\n 'Real-time subscription for out-of-control (OOC) events. Users with supervisory roles receive immediate notifications when OOC events occur in their domain.',\n subscribe: async ({ args, context, info }) => {\n const { domain, user } = context.state\n const subdomain = domain?.subdomain\n\n // Validate domain access\n if (!domain) {\n throw new Error('domain required')\n }\n\n // Check user domain access permissions\n if (!user.domains?.find(d => d.subdomain === subdomain) && !(await 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 // Filter by domain to ensure users only receive events from their domain\n if (subdomain !== domain?.subdomain) {\n return false\n }\n\n // Check if the user has the supervisory role required for this OOC event\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 /**\n * Returns the OOC event data from the subscription payload.\n * This resolver extracts the DataOoc object from the subscription payload\n * and provides it to the client for real-time updates.\n */\n return payload.dataOoc\n }\n}\n"]}
|