@things-factory/shell 10.0.0-beta.89 → 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.
@@ -9,14 +9,15 @@ const data_types_js_1 = require("./data-types.js");
9
9
  /* 이 Resolver는 @things-factory/integration-base 에서 Overide 된다. (state-register를 사용하기 위해서) */
10
10
  let DataResolver = class DataResolver {
11
11
  data(payload, tag) {
12
- return payload.data;
12
+ // 전달 시점에 발행 타임스탬프(ts)를 무조건 스탬프 (클라이언트 데이터 지연 모니터링용).
13
+ return { ...payload.data, ts: Date.now() };
13
14
  }
14
15
  };
15
16
  exports.DataResolver = DataResolver;
16
17
  tslib_1.__decorate([
17
18
  (0, type_graphql_1.Subscription)({
18
19
  description: 'Subscribes to real-time data updates for a specific tag within the current domain. Only users belonging to the domain or superusers are allowed to subscribe.',
19
- subscribe: ({ args, context, info }) => {
20
+ subscribe: async ({ args, context, info }) => {
20
21
  const { domain, user } = context.state;
21
22
  const { tag } = args;
22
23
  const subdomain = domain?.subdomain;
@@ -24,7 +25,7 @@ tslib_1.__decorate([
24
25
  throw new Error('domain and tag required');
25
26
  }
26
27
  //@ts-ignore
27
- if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {
28
+ if (!user.domains?.find(d => d.subdomain === subdomain) && !(await process.superUserGranted(domain, user))) {
28
29
  throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
29
30
  }
30
31
  return (0, graphql_yoga_1.pipe)(pubsub_js_1.pubsub.subscribe('data'), (0, graphql_yoga_1.filter)((payload) => {
@@ -1 +1 @@
1
- {"version":3,"file":"data-resolver.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,+CAAwC;AACxC,mDAAsC;AAEtC,4FAA4F;AAErF,IAAM,YAAY,GAAlB,MAAM,YAAY;IA2BvB,IAAI,CACM,OAAuB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C,KAAK,EAAE,EAAE,WAAW,EAAE,uEAAuE,EAAE,CAAC,CAAA;;;4CACpG,oBAAI;wCAEN;uBAhCU,YAAY;IADxB,IAAA,uBAAQ,GAAE;GACE,YAAY,CAiCxB","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { pubsub } from '../../pubsub.js'\nimport { Data } from './data-types.js'\n\n/* 이 Resolver는 @things-factory/integration-base 에서 Overide 된다. (state-register를 사용하기 위해서) */\n@Resolver()\nexport class DataResolver {\n @Subscription({\n description:\n 'Subscribes to real-time data updates for a specific tag within the current domain. Only users belonging to the domain or superusers are allowed to subscribe.',\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { tag } = args\n const subdomain = domain?.subdomain\n\n if (!domain || !tag) {\n throw new Error('domain and tag required')\n }\n\n //@ts-ignore\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'),\n filter((payload: { data: Data }) => {\n const { domain: pdomain, tag: ptag, data } = payload.data\n return tag === ptag && subdomain === pdomain?.subdomain\n })\n )\n }\n })\n data(\n @Root() payload: { data: Data },\n @Arg('tag', { description: 'The tag used to filter and identify the data stream for subscription.' }) tag: string\n ): Data {\n return payload.data\n }\n}\n"]}
1
+ {"version":3,"file":"data-resolver.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAAgE;AAEhE,+CAAwC;AACxC,mDAAsC;AAEtC,4FAA4F;AAErF,IAAM,YAAY,GAAlB,MAAM,YAAY;IA2BvB,IAAI,CACM,OAAuB,EACuE,GAAW;QAEjH,qDAAqD;QACrD,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;IAC5C,C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,uEAAuE,EAAE,CAAC,CAAA;;;4CACpG,oBAAI;wCAGN;uBAjCU,YAAY;IADxB,IAAA,uBAAQ,GAAE;GACE,YAAY,CAkCxB","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, Root, Subscription } from 'type-graphql'\n\nimport { pubsub } from '../../pubsub.js'\nimport { Data } from './data-types.js'\n\n/* 이 Resolver는 @things-factory/integration-base 에서 Overide 된다. (state-register를 사용하기 위해서) */\n@Resolver()\nexport class DataResolver {\n @Subscription({\n description:\n 'Subscribes to real-time data updates for a specific tag within the current domain. Only users belonging to the domain or superusers are allowed to subscribe.',\n subscribe: async ({ args, context, info }) => {\n const { domain, user } = context.state\n const { tag } = args\n const subdomain = domain?.subdomain\n\n if (!domain || !tag) {\n throw new Error('domain and tag required')\n }\n\n //@ts-ignore\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'),\n filter((payload: { data: Data }) => {\n const { domain: pdomain, tag: ptag, data } = payload.data\n return tag === ptag && subdomain === pdomain?.subdomain\n })\n )\n }\n })\n data(\n @Root() payload: { data: Data },\n @Arg('tag', { description: 'The tag used to filter and identify the data stream for subscription.' }) tag: string\n ): Data {\n // 전달 시점에 발행 타임스탬프(ts)를 무조건 스탬프 (클라이언트 데이터 지연 모니터링용).\n return { ...payload.data, ts: Date.now() }\n }\n}\n"]}
@@ -3,4 +3,5 @@ export declare class Data {
3
3
  domain?: Domain;
4
4
  tag: string;
5
5
  data?: Object;
6
+ ts?: number;
6
7
  }
@@ -23,6 +23,13 @@ tslib_1.__decorate([
23
23
  }),
24
24
  tslib_1.__metadata("design:type", Object)
25
25
  ], Data.prototype, "data", void 0);
26
+ tslib_1.__decorate([
27
+ (0, type_graphql_1.Field)(type => type_graphql_1.Float, {
28
+ nullable: true,
29
+ description: 'Server publish timestamp in epoch milliseconds, stamped at delivery. Used by clients to monitor data delivery lag.'
30
+ }),
31
+ tslib_1.__metadata("design:type", Number)
32
+ ], Data.prototype, "ts", void 0);
26
33
  exports.Data = Data = tslib_1.__decorate([
27
34
  (0, type_graphql_1.ObjectType)({
28
35
  description: 'Represents a data payload delivered via subscription, including its domain, tag, and content.'
@@ -1 +1 @@
1
- {"version":3,"file":"data-types.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAEhD,uEAA+D;AAC/D,mDAA4C;AAKrC,IAAM,IAAI,GAAV,MAAM,IAAI;CAYhB,CAAA;AAZY,oBAAI;AAEf;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;sCACvF,kBAAM;oCAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2EAA2E,EAAE,CAAC;;iCACzF;AAMX;IAJC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAY,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,wDAAwD;KACtE,CAAC;sCACK,MAAM;kCAAA;eAXF,IAAI;IAHhB,IAAA,yBAAU,EAAC;QACV,WAAW,EAAE,+FAA+F;KAC7G,CAAC;GACW,IAAI,CAYhB","sourcesContent":["import { Field, ObjectType } from 'type-graphql'\n\nimport { ScalarObject } from '../common-types/scalar-object.js'\nimport { Domain } from '../domain/domain.js'\n\n@ObjectType({\n description: 'Represents a data payload delivered via subscription, including its domain, tag, and content.'\n})\nexport class Data {\n @Field(type => Domain, { nullable: true, description: 'The domain where the data originated.' })\n domain?: Domain\n\n @Field({ description: 'The tag name attached to the data, used for filtering and identification.' })\n tag: string\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'The actual data content delivered by the subscription.'\n })\n data?: Object\n}\n"]}
1
+ {"version":3,"file":"data-types.js","sourceRoot":"","sources":["../../../server/service/subscription-data/data-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAuD;AAEvD,uEAA+D;AAC/D,mDAA4C;AAKrC,IAAM,IAAI,GAAV,MAAM,IAAI;CAkBhB,CAAA;AAlBY,oBAAI;AAEf;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;sCACvF,kBAAM;oCAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,2EAA2E,EAAE,CAAC;;iCACzF;AAMX;IAJC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,+BAAY,EAAE;QAC3B,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,wDAAwD;KACtE,CAAC;sCACK,MAAM;kCAAA;AAMb;IAJC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAK,EAAE;QACpB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,oHAAoH;KAClI,CAAC;;gCACS;eAjBA,IAAI;IAHhB,IAAA,yBAAU,EAAC;QACV,WAAW,EAAE,+FAA+F;KAC7G,CAAC;GACW,IAAI,CAkBhB","sourcesContent":["import { Field, Float, ObjectType } from 'type-graphql'\n\nimport { ScalarObject } from '../common-types/scalar-object.js'\nimport { Domain } from '../domain/domain.js'\n\n@ObjectType({\n description: 'Represents a data payload delivered via subscription, including its domain, tag, and content.'\n})\nexport class Data {\n @Field(type => Domain, { nullable: true, description: 'The domain where the data originated.' })\n domain?: Domain\n\n @Field({ description: 'The tag name attached to the data, used for filtering and identification.' })\n tag: string\n\n @Field(type => ScalarObject, {\n nullable: true,\n description: 'The actual data content delivered by the subscription.'\n })\n data?: Object\n\n @Field(type => Float, {\n nullable: true,\n description: 'Server publish timestamp in epoch milliseconds, stamped at delivery. Used by clients to monitor data delivery lag.'\n })\n ts?: number\n}\n"]}