@things-factory/dataset 5.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +21 -0
  3. package/client/bootstrap.js +3 -0
  4. package/client/index.js +0 -0
  5. package/client/pages/data-item-list.js +280 -0
  6. package/client/pages/data-sample.js +272 -0
  7. package/client/pages/data-set-importer.js +103 -0
  8. package/client/pages/data-set.js +418 -0
  9. package/client/route.js +11 -0
  10. package/dist-server/controllers/index.js +1 -0
  11. package/dist-server/controllers/index.js.map +1 -0
  12. package/dist-server/index.js +21 -0
  13. package/dist-server/index.js.map +1 -0
  14. package/dist-server/middlewares/index.js +8 -0
  15. package/dist-server/middlewares/index.js.map +1 -0
  16. package/dist-server/migrations/index.js +12 -0
  17. package/dist-server/migrations/index.js.map +1 -0
  18. package/dist-server/routes.js +25 -0
  19. package/dist-server/routes.js.map +1 -0
  20. package/dist-server/service/data-item/data-item-mutation.js +69 -0
  21. package/dist-server/service/data-item/data-item-mutation.js.map +1 -0
  22. package/dist-server/service/data-item/data-item-query.js +100 -0
  23. package/dist-server/service/data-item/data-item-query.js.map +1 -0
  24. package/dist-server/service/data-item/data-item-type.js +80 -0
  25. package/dist-server/service/data-item/data-item-type.js.map +1 -0
  26. package/dist-server/service/data-item/data-item.js +136 -0
  27. package/dist-server/service/data-item/data-item.js.map +1 -0
  28. package/dist-server/service/data-item/index.js +9 -0
  29. package/dist-server/service/data-item/index.js.map +1 -0
  30. package/dist-server/service/data-sample/data-sample-mutation.js +142 -0
  31. package/dist-server/service/data-sample/data-sample-mutation.js.map +1 -0
  32. package/dist-server/service/data-sample/data-sample-query.js +100 -0
  33. package/dist-server/service/data-sample/data-sample-query.js.map +1 -0
  34. package/dist-server/service/data-sample/data-sample-type.js +82 -0
  35. package/dist-server/service/data-sample/data-sample-type.js.map +1 -0
  36. package/dist-server/service/data-sample/data-sample.js +105 -0
  37. package/dist-server/service/data-sample/data-sample.js.map +1 -0
  38. package/dist-server/service/data-sample/index.js +9 -0
  39. package/dist-server/service/data-sample/index.js.map +1 -0
  40. package/dist-server/service/data-set/data-set-mutation.js +216 -0
  41. package/dist-server/service/data-set/data-set-mutation.js.map +1 -0
  42. package/dist-server/service/data-set/data-set-query.js +102 -0
  43. package/dist-server/service/data-set/data-set-query.js.map +1 -0
  44. package/dist-server/service/data-set/data-set-type.js +89 -0
  45. package/dist-server/service/data-set/data-set-type.js.map +1 -0
  46. package/dist-server/service/data-set/data-set.js +117 -0
  47. package/dist-server/service/data-set/data-set.js.map +1 -0
  48. package/dist-server/service/data-set/index.js +9 -0
  49. package/dist-server/service/data-set/index.js.map +1 -0
  50. package/dist-server/service/index.js +40 -0
  51. package/dist-server/service/index.js.map +1 -0
  52. package/package.json +38 -0
  53. package/server/controllers/index.ts +0 -0
  54. package/server/index.ts +5 -0
  55. package/server/middlewares/index.ts +3 -0
  56. package/server/migrations/index.ts +9 -0
  57. package/server/routes.ts +28 -0
  58. package/server/service/data-item/data-item-mutation.ts +56 -0
  59. package/server/service/data-item/data-item-query.ts +53 -0
  60. package/server/service/data-item/data-item-type.ts +50 -0
  61. package/server/service/data-item/data-item.ts +113 -0
  62. package/server/service/data-item/index.ts +6 -0
  63. package/server/service/data-sample/data-sample-mutation.ts +137 -0
  64. package/server/service/data-sample/data-sample-query.ts +53 -0
  65. package/server/service/data-sample/data-sample-type.ts +50 -0
  66. package/server/service/data-sample/data-sample.ts +84 -0
  67. package/server/service/data-sample/index.ts +6 -0
  68. package/server/service/data-set/data-set-mutation.ts +209 -0
  69. package/server/service/data-set/data-set-query.ts +55 -0
  70. package/server/service/data-set/data-set-type.ts +54 -0
  71. package/server/service/data-set/data-set.ts +96 -0
  72. package/server/service/data-set/index.ts +6 -0
  73. package/server/service/index.ts +25 -0
  74. package/things-factory.config.js +17 -0
  75. package/translations/en.json +8 -0
  76. package/translations/ko.json +8 -0
  77. package/translations/ms.json +8 -0
  78. package/translations/zh.json +8 -0
  79. package/tsconfig.json +9 -0
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.DataItemQuery = void 0;
17
+ const type_graphql_1 = require("type-graphql");
18
+ const typeorm_1 = require("typeorm");
19
+ const auth_base_1 = require("@things-factory/auth-base");
20
+ const shell_1 = require("@things-factory/shell");
21
+ const data_set_1 = require("../data-set/data-set");
22
+ const data_item_1 = require("./data-item");
23
+ const data_item_type_1 = require("./data-item-type");
24
+ let DataItemQuery = class DataItemQuery {
25
+ async dataItem(id, context) {
26
+ const { domain } = context.state;
27
+ return await (0, typeorm_1.getRepository)(data_item_1.DataItem).findOne({
28
+ where: { domain, id }
29
+ });
30
+ }
31
+ async dataItems(params, context) {
32
+ const { domain } = context.state;
33
+ const convertedParams = (0, shell_1.convertListParams)(params, domain.id);
34
+ const [items, total] = await (0, typeorm_1.getRepository)(data_item_1.DataItem).findAndCount(convertedParams);
35
+ return { items, total };
36
+ }
37
+ async dataSet(dataItem) {
38
+ return await (0, typeorm_1.getRepository)(data_set_1.DataSet).findOne(dataItem.dataSetId);
39
+ }
40
+ async domain(dataItem) {
41
+ return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(dataItem.domainId);
42
+ }
43
+ async updater(dataItem) {
44
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(dataItem.updaterId);
45
+ }
46
+ async creator(dataItem) {
47
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(dataItem.creatorId);
48
+ }
49
+ };
50
+ __decorate([
51
+ (0, type_graphql_1.Directive)('@privilege(category: "data-set", privilege: "query", domainOwnerGranted: true)'),
52
+ (0, type_graphql_1.Query)(returns => data_item_1.DataItem, { description: 'To fetch a DataItem' }),
53
+ __param(0, (0, type_graphql_1.Arg)('id')),
54
+ __param(1, (0, type_graphql_1.Ctx)()),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [String, Object]),
57
+ __metadata("design:returntype", Promise)
58
+ ], DataItemQuery.prototype, "dataItem", null);
59
+ __decorate([
60
+ (0, type_graphql_1.Directive)('@privilege(category: "data-set", privilege: "query", domainOwnerGranted: true)'),
61
+ (0, type_graphql_1.Query)(returns => data_item_type_1.DataItemList, { description: 'To fetch multiple DataItems' }),
62
+ __param(0, (0, type_graphql_1.Args)()),
63
+ __param(1, (0, type_graphql_1.Ctx)()),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
66
+ __metadata("design:returntype", Promise)
67
+ ], DataItemQuery.prototype, "dataItems", null);
68
+ __decorate([
69
+ (0, type_graphql_1.FieldResolver)(type => data_set_1.DataSet),
70
+ __param(0, (0, type_graphql_1.Root)()),
71
+ __metadata("design:type", Function),
72
+ __metadata("design:paramtypes", [data_item_1.DataItem]),
73
+ __metadata("design:returntype", Promise)
74
+ ], DataItemQuery.prototype, "dataSet", null);
75
+ __decorate([
76
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
77
+ __param(0, (0, type_graphql_1.Root)()),
78
+ __metadata("design:type", Function),
79
+ __metadata("design:paramtypes", [data_item_1.DataItem]),
80
+ __metadata("design:returntype", Promise)
81
+ ], DataItemQuery.prototype, "domain", null);
82
+ __decorate([
83
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
84
+ __param(0, (0, type_graphql_1.Root)()),
85
+ __metadata("design:type", Function),
86
+ __metadata("design:paramtypes", [data_item_1.DataItem]),
87
+ __metadata("design:returntype", Promise)
88
+ ], DataItemQuery.prototype, "updater", null);
89
+ __decorate([
90
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
91
+ __param(0, (0, type_graphql_1.Root)()),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [data_item_1.DataItem]),
94
+ __metadata("design:returntype", Promise)
95
+ ], DataItemQuery.prototype, "creator", null);
96
+ DataItemQuery = __decorate([
97
+ (0, type_graphql_1.Resolver)(data_item_1.DataItem)
98
+ ], DataItemQuery);
99
+ exports.DataItemQuery = DataItemQuery;
100
+ //# sourceMappingURL=data-item-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-item-query.js","sourceRoot":"","sources":["../../../server/service/data-item/data-item-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA8F;AAC9F,qCAAuC;AAEvC,yDAAgD;AAChD,iDAA4E;AAE5E,mDAA8C;AAC9C,2CAAsC;AACtC,qDAA+C;AAG/C,IAAa,aAAa,GAA1B,MAAa,aAAa;IAGxB,KAAK,CAAC,QAAQ,CAAY,EAAU,EAAS,OAAY;QACvD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,uBAAa,EAAC,oBAAQ,CAAC,CAAC,OAAO,CAAC;YAC3C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,SAAS,CAAS,MAAiB,EAAS,OAAY;QAC5D,MAAM,EAAE,MA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BAAK,EAAC,OAAO,CAAC,EAAE,CAAC,6BAAY,EAAE,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IAC9D,WAAA,IAAA,mBAAI,GAAE,CAAA;IAAqB,WAAA,IAAA,kBAAG,GAAE,CAAA;;yDAAjB,iBAAS,oBAAT,iBAAS;;8CAOxC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAO,CAAC;IAChB,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAW,oBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAW,oBAAQ;;2CAEtC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAW,oBAAQ;;4CAEvC;AAGD;IADC,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,WAAA,IAAA,mBAAI,GAAE,CAAA;;qCAAW,oBAAQ;;4CAEvC;AAxCU,aAAa;IADzB,IAAA,uBAAQ,EAAC,oBAAQ,CAAC;GACN,aAAa,CAyCzB;AAzCY,sCAAa"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DataItemList = exports.DataItemPatch = void 0;
13
+ const type_graphql_1 = require("type-graphql");
14
+ const shell_1 = require("@things-factory/shell");
15
+ const data_item_1 = require("./data-item");
16
+ let DataItemPatch = class DataItemPatch {
17
+ };
18
+ __decorate([
19
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
20
+ __metadata("design:type", String)
21
+ ], DataItemPatch.prototype, "id", void 0);
22
+ __decorate([
23
+ (0, type_graphql_1.Field)({ nullable: true }),
24
+ __metadata("design:type", String)
25
+ ], DataItemPatch.prototype, "dataSetId", void 0);
26
+ __decorate([
27
+ (0, type_graphql_1.Field)({ nullable: true }),
28
+ __metadata("design:type", String)
29
+ ], DataItemPatch.prototype, "name", void 0);
30
+ __decorate([
31
+ (0, type_graphql_1.Field)({ nullable: true }),
32
+ __metadata("design:type", String)
33
+ ], DataItemPatch.prototype, "description", void 0);
34
+ __decorate([
35
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
36
+ __metadata("design:type", Number)
37
+ ], DataItemPatch.prototype, "sequence", void 0);
38
+ __decorate([
39
+ (0, type_graphql_1.Field)(type => data_item_1.DataItemType, { nullable: true }),
40
+ __metadata("design:type", String)
41
+ ], DataItemPatch.prototype, "type", void 0);
42
+ __decorate([
43
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
44
+ __metadata("design:type", Number)
45
+ ], DataItemPatch.prototype, "quota", void 0);
46
+ __decorate([
47
+ (0, type_graphql_1.Field)({ nullable: true }),
48
+ __metadata("design:type", String)
49
+ ], DataItemPatch.prototype, "options", void 0);
50
+ __decorate([
51
+ (0, type_graphql_1.Field)({ nullable: true }),
52
+ __metadata("design:type", Boolean)
53
+ ], DataItemPatch.prototype, "active", void 0);
54
+ __decorate([
55
+ (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
56
+ __metadata("design:type", Object)
57
+ ], DataItemPatch.prototype, "spec", void 0);
58
+ __decorate([
59
+ (0, type_graphql_1.Field)({ nullable: true }),
60
+ __metadata("design:type", String)
61
+ ], DataItemPatch.prototype, "cuFlag", void 0);
62
+ DataItemPatch = __decorate([
63
+ (0, type_graphql_1.InputType)()
64
+ ], DataItemPatch);
65
+ exports.DataItemPatch = DataItemPatch;
66
+ let DataItemList = class DataItemList {
67
+ };
68
+ __decorate([
69
+ (0, type_graphql_1.Field)(type => [data_item_1.DataItem]),
70
+ __metadata("design:type", Array)
71
+ ], DataItemList.prototype, "items", void 0);
72
+ __decorate([
73
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
74
+ __metadata("design:type", Number)
75
+ ], DataItemList.prototype, "total", void 0);
76
+ DataItemList = __decorate([
77
+ (0, type_graphql_1.ObjectType)()
78
+ ], DataItemList);
79
+ exports.DataItemList = DataItemList;
80
+ //# sourceMappingURL=data-item-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-item-type.js","sourceRoot":"","sources":["../../../server/service/data-item/data-item-type.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAoE;AAEpE,iDAAoD;AAEpD,2CAAoD;AAGpD,IAAa,aAAa,GAA1B,MAAa,aAAa;CAiCzB,CAAA;AA/BC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAC3B;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACR;AAGlB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACb;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACN;AAGpB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACtB;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,wBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAC7B;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACzB;AAGd;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,oBAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACnC;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACX;AAhCJ,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CAiCzB;AAjCY,sCAAa;AAoC1B,IAAa,YAAY,GAAzB,MAAa,YAAY;CAMxB,CAAA;AAJC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,oBAAQ,CAAC,CAAC;;2CACT;AAGjB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;2CACN;AALF,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CAMxB;AANY,oCAAY"}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var _a, _b, _c;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.DataItem = exports.DataItemType = void 0;
14
+ const type_graphql_1 = require("type-graphql");
15
+ const typeorm_1 = require("typeorm");
16
+ const auth_base_1 = require("@things-factory/auth-base");
17
+ const shell_1 = require("@things-factory/shell");
18
+ const data_set_1 = require("../data-set/data-set");
19
+ var DataItemType;
20
+ (function (DataItemType) {
21
+ DataItemType["number"] = "number";
22
+ DataItemType["text"] = "text";
23
+ DataItemType["boolean"] = "boolean";
24
+ DataItemType["select"] = "select";
25
+ })(DataItemType = exports.DataItemType || (exports.DataItemType = {}));
26
+ (0, type_graphql_1.registerEnumType)(DataItemType, {
27
+ name: 'DataItemType',
28
+ description: 'state enumeration of a data-item'
29
+ });
30
+ let DataItem = class DataItem {
31
+ };
32
+ __decorate([
33
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
34
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID),
35
+ __metadata("design:type", String)
36
+ ], DataItem.prototype, "id", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
39
+ (0, type_graphql_1.Field)({ nullable: true }),
40
+ __metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
41
+ ], DataItem.prototype, "domain", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.RelationId)((dataItem) => dataItem.domain),
44
+ __metadata("design:type", String)
45
+ ], DataItem.prototype, "domainId", void 0);
46
+ __decorate([
47
+ (0, typeorm_1.Column)(),
48
+ (0, type_graphql_1.Field)(),
49
+ __metadata("design:type", String)
50
+ ], DataItem.prototype, "name", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({
53
+ nullable: true
54
+ }),
55
+ (0, type_graphql_1.Field)({ nullable: true }),
56
+ __metadata("design:type", String)
57
+ ], DataItem.prototype, "description", void 0);
58
+ __decorate([
59
+ (0, typeorm_1.ManyToOne)(type => data_set_1.DataSet, dataSet => dataSet.dataItems, { onDelete: 'CASCADE' }),
60
+ (0, type_graphql_1.Field)(type => data_set_1.DataSet, { nullable: true }),
61
+ __metadata("design:type", data_set_1.DataSet)
62
+ ], DataItem.prototype, "dataSet", void 0);
63
+ __decorate([
64
+ (0, typeorm_1.RelationId)((dataItem) => dataItem.dataSet),
65
+ __metadata("design:type", String)
66
+ ], DataItem.prototype, "dataSetId", void 0);
67
+ __decorate([
68
+ (0, typeorm_1.Column)(),
69
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
70
+ __metadata("design:type", Number)
71
+ ], DataItem.prototype, "sequence", void 0);
72
+ __decorate([
73
+ (0, typeorm_1.Column)({
74
+ nullable: true
75
+ }),
76
+ (0, type_graphql_1.Field)({ nullable: true }),
77
+ __metadata("design:type", Boolean)
78
+ ], DataItem.prototype, "active", void 0);
79
+ __decorate([
80
+ (0, typeorm_1.Column)({
81
+ nullable: true
82
+ }),
83
+ (0, type_graphql_1.Field)({ nullable: true }),
84
+ __metadata("design:type", String)
85
+ ], DataItem.prototype, "type", void 0);
86
+ __decorate([
87
+ (0, typeorm_1.Column)({
88
+ nullable: true
89
+ }),
90
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
91
+ __metadata("design:type", Number)
92
+ ], DataItem.prototype, "quota", void 0);
93
+ __decorate([
94
+ (0, typeorm_1.Column)('simple-json', { nullable: true }),
95
+ (0, type_graphql_1.Field)(type => shell_1.ScalarObject, { nullable: true }),
96
+ __metadata("design:type", Object)
97
+ ], DataItem.prototype, "spec", void 0);
98
+ __decorate([
99
+ (0, typeorm_1.CreateDateColumn)(),
100
+ (0, type_graphql_1.Field)({ nullable: true }),
101
+ __metadata("design:type", Date)
102
+ ], DataItem.prototype, "createdAt", void 0);
103
+ __decorate([
104
+ (0, typeorm_1.UpdateDateColumn)(),
105
+ (0, type_graphql_1.Field)({ nullable: true }),
106
+ __metadata("design:type", Date)
107
+ ], DataItem.prototype, "updatedAt", void 0);
108
+ __decorate([
109
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
110
+ nullable: true
111
+ }),
112
+ (0, type_graphql_1.Field)({ nullable: true }),
113
+ __metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
114
+ ], DataItem.prototype, "creator", void 0);
115
+ __decorate([
116
+ (0, typeorm_1.RelationId)((dataItem) => dataItem.creator),
117
+ __metadata("design:type", String)
118
+ ], DataItem.prototype, "creatorId", void 0);
119
+ __decorate([
120
+ (0, typeorm_1.ManyToOne)(type => auth_base_1.User, {
121
+ nullable: true
122
+ }),
123
+ (0, type_graphql_1.Field)({ nullable: true }),
124
+ __metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
125
+ ], DataItem.prototype, "updater", void 0);
126
+ __decorate([
127
+ (0, typeorm_1.RelationId)((dataItem) => dataItem.creator),
128
+ __metadata("design:type", String)
129
+ ], DataItem.prototype, "updaterId", void 0);
130
+ DataItem = __decorate([
131
+ (0, typeorm_1.Entity)(),
132
+ (0, typeorm_1.Index)('ix_data_item_0', (dataItem) => [dataItem.domain, dataItem.dataSet, dataItem.name], { unique: true }),
133
+ (0, type_graphql_1.ObjectType)({ description: 'Entity for DataItem' })
134
+ ], DataItem);
135
+ exports.DataItem = DataItem;
136
+ //# sourceMappingURL=data-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-item.js","sourceRoot":"","sources":["../../../server/service/data-item/data-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA2E;AAC3E,qCASgB;AAEhB,yDAAgD;AAChD,iDAA4D;AAE5D,mDA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ChB,gBAAI,oBAAJ,gBAAI;yCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;2CACnC;AAMlB;IAJC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE;QACvB,QAAQ,EAAE,IAAI;KACf,CAAC;IACD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;yCAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;;2CACnC;AA/EP,QAAQ;IAHpB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,gBAAgB,EAAE,CAAC,QAAkB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACrH,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,CAAC;GACtC,QAAQ,CAgFpB;AAhFY,4BAAQ"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.entities = void 0;
4
+ const data_item_1 = require("./data-item");
5
+ const data_item_query_1 = require("./data-item-query");
6
+ const data_item_mutation_1 = require("./data-item-mutation");
7
+ exports.entities = [data_item_1.DataItem];
8
+ exports.resolvers = [data_item_query_1.DataItemQuery, data_item_mutation_1.DataItemMutation];
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/data-item/index.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AACtC,uDAAiD;AACjD,6DAAuD;AAE1C,QAAA,QAAQ,GAAG,CAAC,oBAAQ,CAAC,CAAA;AACrB,QAAA,SAAS,GAAG,CAAC,+BAAa,EAAE,qCAAgB,CAAC,CAAA"}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DataSampleMutation = void 0;
16
+ const type_graphql_1 = require("type-graphql");
17
+ const typeorm_1 = require("typeorm");
18
+ const data_item_1 = require("../data-item/data-item");
19
+ const data_set_1 = require("../data-set/data-set");
20
+ const data_sample_1 = require("./data-sample");
21
+ const data_sample_type_1 = require("./data-sample-type");
22
+ let DataSampleMutation = class DataSampleMutation {
23
+ async createDataSample(dataSample, context) {
24
+ const { domain, user, tx } = context.state;
25
+ const dataSet = await tx.getRepository(data_set_1.DataSet).findOne({ id: dataSample.dataSetId });
26
+ const dataItems = await tx.getRepository(data_item_1.DataItem).find({
27
+ select: {
28
+ domain,
29
+ dataSetId: dataSample.dataSetId
30
+ },
31
+ order: {
32
+ sequence: 'DESC'
33
+ }
34
+ });
35
+ var spec = {};
36
+ dataItems.sortforEach(dataItem => {
37
+ spec[dataItem.name] = dataItem.spec;
38
+ });
39
+ return await tx.getRepository(data_sample_1.DataSample).save(Object.assign(Object.assign({ name: dataSet.name, description: dataSet.description }, dataSample), { domain,
40
+ spec, creator: user, updater: user }));
41
+ }
42
+ async updateDataSample(id, patch, context) {
43
+ const { domain, user, tx } = context.state;
44
+ const repository = tx.getRepository(data_sample_1.DataSample);
45
+ const dataSample = await repository.findOne({
46
+ where: { domain, id }
47
+ });
48
+ return await repository.save(Object.assign(Object.assign(Object.assign({}, dataSample), patch), { updater: user }));
49
+ }
50
+ async updateMultipleDataSample(patches, context) {
51
+ const { domain, user, tx } = context.state;
52
+ let results = [];
53
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
54
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
55
+ const dataSampleRepo = tx.getRepository(data_sample_1.DataSample);
56
+ if (_createRecords.length > 0) {
57
+ for (let i = 0; i < _createRecords.length; i++) {
58
+ const newRecord = _createRecords[i];
59
+ const result = await dataSampleRepo.save(Object.assign(Object.assign({}, newRecord), { domain, creator: user, updater: user }));
60
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
61
+ }
62
+ }
63
+ if (_updateRecords.length > 0) {
64
+ for (let i = 0; i < _updateRecords.length; i++) {
65
+ const newRecord = _updateRecords[i];
66
+ const dataSample = await dataSampleRepo.findOne(newRecord.id);
67
+ const result = await dataSampleRepo.save(Object.assign(Object.assign(Object.assign({}, dataSample), newRecord), { updater: user }));
68
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
69
+ }
70
+ }
71
+ return results;
72
+ }
73
+ async deleteDataSample(id, context) {
74
+ const { domain, tx } = context.state;
75
+ await tx.getRepository(data_sample_1.DataSample).delete({ domain, id });
76
+ return true;
77
+ }
78
+ async deleteDataSamples(ids, context) {
79
+ const { domain, tx } = context.state;
80
+ await tx.getRepository(data_sample_1.DataSample).delete({
81
+ domain,
82
+ id: (0, typeorm_1.In)(ids)
83
+ });
84
+ return true;
85
+ }
86
+ };
87
+ __decorate([
88
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)'),
89
+ (0, type_graphql_1.Directive)('@transaction'),
90
+ (0, type_graphql_1.Mutation)(returns => data_sample_1.DataSample, { description: 'To create new data sample' }),
91
+ __param(0, (0, type_graphql_1.Arg)('dataSample')),
92
+ __param(1, (0, type_graphql_1.Ctx)()),
93
+ __metadata("design:type", Function),
94
+ __metadata("design:paramtypes", [data_sample_type_1.NewDataSample, Object]),
95
+ __metadata("design:returntype", Promise)
96
+ ], DataSampleMutation.prototype, "createDataSample", null);
97
+ __decorate([
98
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)'),
99
+ (0, type_graphql_1.Directive)('@transaction'),
100
+ (0, type_graphql_1.Mutation)(returns => data_sample_1.DataSample, { description: 'To modify data sample information' }),
101
+ __param(0, (0, type_graphql_1.Arg)('id')),
102
+ __param(1, (0, type_graphql_1.Arg)('patch')),
103
+ __param(2, (0, type_graphql_1.Ctx)()),
104
+ __metadata("design:type", Function),
105
+ __metadata("design:paramtypes", [String, data_sample_type_1.DataSamplePatch, Object]),
106
+ __metadata("design:returntype", Promise)
107
+ ], DataSampleMutation.prototype, "updateDataSample", null);
108
+ __decorate([
109
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)'),
110
+ (0, type_graphql_1.Directive)('@transaction'),
111
+ (0, type_graphql_1.Mutation)(returns => [data_sample_1.DataSample], { description: "To modify multiple data samples' information" }),
112
+ __param(0, (0, type_graphql_1.Arg)('patches', type => [data_sample_type_1.DataSamplePatch])),
113
+ __param(1, (0, type_graphql_1.Ctx)()),
114
+ __metadata("design:type", Function),
115
+ __metadata("design:paramtypes", [Array, Object]),
116
+ __metadata("design:returntype", Promise)
117
+ ], DataSampleMutation.prototype, "updateMultipleDataSample", null);
118
+ __decorate([
119
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)'),
120
+ (0, type_graphql_1.Directive)('@transaction'),
121
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete a data sample' }),
122
+ __param(0, (0, type_graphql_1.Arg)('id')),
123
+ __param(1, (0, type_graphql_1.Ctx)()),
124
+ __metadata("design:type", Function),
125
+ __metadata("design:paramtypes", [String, Object]),
126
+ __metadata("design:returntype", Promise)
127
+ ], DataSampleMutation.prototype, "deleteDataSample", null);
128
+ __decorate([
129
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "mutation", domainOwnerGranted: true)'),
130
+ (0, type_graphql_1.Directive)('@transaction'),
131
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple data samples' }),
132
+ __param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
133
+ __param(1, (0, type_graphql_1.Ctx)()),
134
+ __metadata("design:type", Function),
135
+ __metadata("design:paramtypes", [Array, Object]),
136
+ __metadata("design:returntype", Promise)
137
+ ], DataSampleMutation.prototype, "deleteDataSamples", null);
138
+ DataSampleMutation = __decorate([
139
+ (0, type_graphql_1.Resolver)(data_sample_1.DataSample)
140
+ ], DataSampleMutation);
141
+ exports.DataSampleMutation = DataSampleMutation;
142
+ //# sourceMappingURL=data-sample-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-sample-mutation.js","sourceRoot":"","sources":["../../../server/service/data-sample/data-sample-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,sDAAiD;AACjD,mDAA8C;AAC9C,+CAA0C;AAC1C,yDAAmE;AAGnE,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;IAI7B,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAY;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,kBAAO,CAAC,CAAC,O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
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var _a;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.DataSampleQuery = void 0;
17
+ const type_graphql_1 = require("type-graphql");
18
+ const typeorm_1 = require("typeorm");
19
+ const auth_base_1 = require("@things-factory/auth-base");
20
+ const shell_1 = require("@things-factory/shell");
21
+ const data_set_1 = require("../data-set/data-set");
22
+ const data_sample_1 = require("./data-sample");
23
+ const data_sample_type_1 = require("./data-sample-type");
24
+ let DataSampleQuery = class DataSampleQuery {
25
+ async dataSample(id, context) {
26
+ const { domain } = context.state;
27
+ return await (0, typeorm_1.getRepository)(data_sample_1.DataSample).findOne({
28
+ where: { domain, id }
29
+ });
30
+ }
31
+ async dataSamples(params, context) {
32
+ const { domain } = context.state;
33
+ const convertedParams = (0, shell_1.convertListParams)(params, domain.id);
34
+ const [items, total] = await (0, typeorm_1.getRepository)(data_sample_1.DataSample).findAndCount(convertedParams);
35
+ return { items, total };
36
+ }
37
+ async dataSet(dataSample) {
38
+ return await (0, typeorm_1.getRepository)(data_set_1.DataSet).findOne(dataSample.dataSetId);
39
+ }
40
+ async domain(dataSample) {
41
+ return await (0, typeorm_1.getRepository)(shell_1.Domain).findOne(dataSample.domainId);
42
+ }
43
+ async updater(dataSample) {
44
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(dataSample.updaterId);
45
+ }
46
+ async creator(dataSample) {
47
+ return await (0, typeorm_1.getRepository)(auth_base_1.User).findOne(dataSample.creatorId);
48
+ }
49
+ };
50
+ __decorate([
51
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "query", domainOwnerGranted: true)'),
52
+ (0, type_graphql_1.Query)(returns => data_sample_1.DataSample, { description: 'To fetch a data sample' }),
53
+ __param(0, (0, type_graphql_1.Arg)('id')),
54
+ __param(1, (0, type_graphql_1.Ctx)()),
55
+ __metadata("design:type", Function),
56
+ __metadata("design:paramtypes", [String, Object]),
57
+ __metadata("design:returntype", Promise)
58
+ ], DataSampleQuery.prototype, "dataSample", null);
59
+ __decorate([
60
+ (0, type_graphql_1.Directive)('@privilege(category: "data-sample", privilege: "query", domainOwnerGranted: true)'),
61
+ (0, type_graphql_1.Query)(returns => data_sample_type_1.DataSampleList, { description: 'To fetch multiple data samples' }),
62
+ __param(0, (0, type_graphql_1.Args)()),
63
+ __param(1, (0, type_graphql_1.Ctx)()),
64
+ __metadata("design:type", Function),
65
+ __metadata("design:paramtypes", [typeof (_a = typeof shell_1.ListParam !== "undefined" && shell_1.ListParam) === "function" ? _a : Object, Object]),
66
+ __metadata("design:returntype", Promise)
67
+ ], DataSampleQuery.prototype, "dataSamples", null);
68
+ __decorate([
69
+ (0, type_graphql_1.FieldResolver)(type => data_set_1.DataSet),
70
+ __param(0, (0, type_graphql_1.Root)()),
71
+ __metadata("design:type", Function),
72
+ __metadata("design:paramtypes", [data_sample_1.DataSample]),
73
+ __metadata("design:returntype", Promise)
74
+ ], DataSampleQuery.prototype, "dataSet", null);
75
+ __decorate([
76
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
77
+ __param(0, (0, type_graphql_1.Root)()),
78
+ __metadata("design:type", Function),
79
+ __metadata("design:paramtypes", [data_sample_1.DataSample]),
80
+ __metadata("design:returntype", Promise)
81
+ ], DataSampleQuery.prototype, "domain", null);
82
+ __decorate([
83
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
84
+ __param(0, (0, type_graphql_1.Root)()),
85
+ __metadata("design:type", Function),
86
+ __metadata("design:paramtypes", [data_sample_1.DataSample]),
87
+ __metadata("design:returntype", Promise)
88
+ ], DataSampleQuery.prototype, "updater", null);
89
+ __decorate([
90
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
91
+ __param(0, (0, type_graphql_1.Root)()),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [data_sample_1.DataSample]),
94
+ __metadata("design:returntype", Promise)
95
+ ], DataSampleQuery.prototype, "creator", null);
96
+ DataSampleQuery = __decorate([
97
+ (0, type_graphql_1.Resolver)(data_sample_1.DataSample)
98
+ ], DataSampleQuery);
99
+ exports.DataSampleQuery = DataSampleQuery;
100
+ //# sourceMappingURL=data-sample-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-sample-query.js","sourceRoot":"","sources":["../../../server/service/data-sample/data-sample-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA8F;AAC9F,qCAAuC;AAEvC,yDAAgD;AAChD,iDAA4E;AAE5E,mDAA8C;AAC9C,+CAA0C;AAC1C,yDAAmD;AAGnD,IAAa,eAAe,GAA5B,MAAa,eAAe;IAG1B,KAAK,CAAC,UAAU,CAAY,EAAU,EAAS,OAAY;QACzD,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,uBAAa,EAAC,wBAAU,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;IACJ,CAAC;IAID,KAAK,CAAC,WAAW,CAAS,MAAiB,EAAS,OAAY;QAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KA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