@things-factory/reference-app 4.3.671 → 4.3.673

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.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./service"), exports);
18
+ __exportStar(require("./migrations"), exports);
19
+ __exportStar(require("./middlewares"), exports);
20
+ require("./routes");
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,+CAA4B;AAC5B,gDAA6B;AAE7B,oBAAiB"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initMiddlewares = void 0;
4
+ function initMiddlewares(app) {
5
+ /* can add middlewares into app */
6
+ }
7
+ exports.initMiddlewares = initMiddlewares;
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAC,GAAG;IACjC,kCAAkC;AACpC,CAAC;AAFD,0CAEC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrations = void 0;
4
+ const glob = require('glob');
5
+ const path = require('path');
6
+ exports.migrations = [];
7
+ glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
+ if (file.indexOf('index.js') !== -1)
9
+ return;
10
+ exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
+ });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ const debug = require('debug')('things-factory:reference-app:routes');
2
+ process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
3
+ /*
4
+ * can add global public routes to application (auth not required, tenancy not required)
5
+ *
6
+ * ex) routes.get('/path', async(context, next) => {})
7
+ * ex) routes.post('/path', async(context, next) => {})
8
+ */
9
+ });
10
+ process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
11
+ /*
12
+ * can add global private routes to application (auth required, tenancy not required)
13
+ */
14
+ });
15
+ process.on('bootstrap-module-domain-public-route', (app, domainPublicRouter) => {
16
+ /*
17
+ * can add domain public routes to application (auth not required, tenancy required)
18
+ */
19
+ });
20
+ process.on('bootstrap-module-domain-private-route', (app, domainPrivateRouter) => {
21
+ /*
22
+ * can add domain private routes to application (auth required, tenancy required)
23
+ */
24
+ });
25
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qCAAqC,CAAC,CAAA;AAErE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;;;;OAKG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF;;OAEG;AACL,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF;;OAEG;AACL,CAAC,CAAC,CAAA"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /* EXPORT ENTITY TYPES */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.schema = exports.entities = void 0;
5
+ /* IMPORT ENTITIES AND RESOLVERS */
6
+ const reference_1 = require("./reference");
7
+ exports.entities = [
8
+ /* ENTITIES */
9
+ ...reference_1.entities
10
+ ];
11
+ exports.schema = {
12
+ resolverClasses: [
13
+ /* RESOLVER CLASSES */
14
+ ...reference_1.resolvers
15
+ ]
16
+ };
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";AAAA,yBAAyB;;;AAEzB,mCAAmC;AACnC,2CAA4F;AAE/E,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,oBAAiB;CACrB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,qBAAkB;KACtB;CACF,CAAA"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvers = exports.entities = void 0;
4
+ const reference_mutation_1 = require("./reference-mutation");
5
+ const reference_query_1 = require("./reference-query");
6
+ exports.entities = [];
7
+ exports.resolvers = [reference_mutation_1.ReferenceMutation, reference_query_1.ReferenceQuery];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/reference/index.ts"],"names":[],"mappings":";;;AAAA,6DAAwD;AACxD,uDAAkD;AAErC,QAAA,QAAQ,GAAG,EAAE,CAAA;AACb,QAAA,SAAS,GAAG,CAAC,sCAAiB,EAAE,gCAAc,CAAC,CAAA"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.extractInfos = void 0;
7
+ const node_fetch_1 = __importDefault(require("node-fetch"));
8
+ const env_1 = require("@things-factory/env");
9
+ const utils_1 = require("@things-factory/utils");
10
+ const appSyncConfig = env_1.config.get('awsAppSync');
11
+ async function extractInfos(images) {
12
+ const extraction = {
13
+ success_count: true,
14
+ failure_count: true,
15
+ result: {
16
+ boundaries: true,
17
+ texts: true
18
+ }
19
+ };
20
+ const query = utils_1.gqlBuilder.jsonToGraphQLQuery({
21
+ mutation: {
22
+ extractInfos: {
23
+ __args: {
24
+ images
25
+ },
26
+ ocr: extraction,
27
+ barcode: extraction
28
+ }
29
+ }
30
+ });
31
+ const body = JSON.stringify({ query });
32
+ const response = await (0, node_fetch_1.default)(appSyncConfig['apiUrl'], {
33
+ method: 'POST',
34
+ headers: {
35
+ 'Content-Type': 'application/graphql',
36
+ 'x-api-key': appSyncConfig['apiKey']
37
+ },
38
+ body
39
+ });
40
+ const jsonRes = await response.json();
41
+ return jsonRes;
42
+ }
43
+ exports.extractInfos = extractInfos;
44
+ // @deprecated
45
+ function getRequestBody(images) {
46
+ // @things-factory/utils gqlBuilder.buildArgs 와 유사
47
+ const imageArgs = images.map(obj => {
48
+ const args = [];
49
+ for (let key in obj) {
50
+ args.push(`${key}: \"${obj[key]}\"`);
51
+ }
52
+ return '{' + args.join(',') + '}';
53
+ });
54
+ // console.log(gqlBuilder.buildArgs(images))
55
+ // console.log(imageArgs)
56
+ const body = JSON.stringify({
57
+ query: `mutation {
58
+ upload(images: ${imageArgs}) {
59
+ success_count
60
+ failure_count
61
+ results {
62
+ boundaries
63
+ texts
64
+ }
65
+ }
66
+ }`
67
+ });
68
+ return body;
69
+ }
70
+ //# sourceMappingURL=lambda-call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lambda-call.js","sourceRoot":"","sources":["../../../server/service/reference/lambda-call.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,6CAA4C;AAC5C,iDAAkD;AAElD,MAAM,aAAa,GAAG,YAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAEvC,KAAK,UAAU,YAAY,CAAC,MAAM;IACvC,MAAM,UAAU,GAAG;QACjB,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE;YACN,UAAU,EAAE,I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CAAC"}
@@ -0,0 +1,73 @@
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.ReferenceMutation = void 0;
16
+ const type_graphql_1 = require("type-graphql");
17
+ const graphql_upload_1 = require("graphql-upload");
18
+ const shell_1 = require("@things-factory/shell");
19
+ const utils_1 = require("@things-factory/utils");
20
+ const attachment_base_1 = require("@things-factory/attachment-base");
21
+ let ReferenceMutation = class ReferenceMutation {
22
+ async referenceUpload(_, files, context) {
23
+ const { domain, user, tx } = context.state;
24
+ const all = Promise.all(files);
25
+ if ((files === null || files === void 0 ? void 0 : files.length) > 0) {
26
+ const attachments = files.map(attachment => {
27
+ return {
28
+ file: attachment,
29
+ refBy: 100,
30
+ category: 'Reference'
31
+ };
32
+ });
33
+ await (0, attachment_base_1.createAttachments)(_, { attachments }, context);
34
+ }
35
+ return 'success';
36
+ }
37
+ async referencePendingJob(_, tag, context) {
38
+ const { domain } = context.state;
39
+ for (var i = 0; i <= 100; i++) {
40
+ await (0, utils_1.sleep)(100);
41
+ (0, shell_1.publishProgress)({
42
+ domain,
43
+ tag,
44
+ progress: i,
45
+ message: `${i * 10} / 1000`
46
+ });
47
+ }
48
+ return 'success';
49
+ }
50
+ };
51
+ __decorate([
52
+ (0, type_graphql_1.Mutation)(returns => String, { description: 'To reference of file upload' }),
53
+ __param(0, (0, type_graphql_1.Root)()),
54
+ __param(1, (0, type_graphql_1.Arg)('files', () => [graphql_upload_1.GraphQLUpload])),
55
+ __param(2, (0, type_graphql_1.Ctx)()),
56
+ __metadata("design:type", Function),
57
+ __metadata("design:paramtypes", [Object, Array, Object]),
58
+ __metadata("design:returntype", Promise)
59
+ ], ReferenceMutation.prototype, "referenceUpload", null);
60
+ __decorate([
61
+ (0, type_graphql_1.Mutation)(returns => String, { description: 'To reference of pending job progress' }),
62
+ __param(0, (0, type_graphql_1.Root)()),
63
+ __param(1, (0, type_graphql_1.Arg)('tag')),
64
+ __param(2, (0, type_graphql_1.Ctx)()),
65
+ __metadata("design:type", Function),
66
+ __metadata("design:paramtypes", [Object, String, Object]),
67
+ __metadata("design:returntype", Promise)
68
+ ], ReferenceMutation.prototype, "referencePendingJob", null);
69
+ ReferenceMutation = __decorate([
70
+ (0, type_graphql_1.Resolver)()
71
+ ], ReferenceMutation);
72
+ exports.ReferenceMutation = ReferenceMutation;
73
+ //# sourceMappingURL=reference-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-mutation.js","sourceRoot":"","sources":["../../../server/service/reference/reference-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAA4E;AAC5E,mDAA0D;AAC1D,iDAAuD;AACvD,iDAA6C;AAC7C,qEAA+E;AAGxE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAEtB,AAAN,KAAK,CAAC,eAAe,CACX,CAAC,EAET,KAAmB,EACZ,OAAY;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAE9B,IAAI,CAAA,KAAK,aAAL,K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AAA,mBAAI,GAAE,CAAA;IAAK,WAAA,IAAA,kBAAG,EAAC,KAAK,CAAC,CAAA;IAAe,WAAA,IAAA,kBAAG,GAAE,CAAA;;;;4DAenE;AAzCU,iBAAiB;IAD7B,IAAA,uBAAQ,GAAE;GACE,iBAAiB,CA0C7B;AA1CY,8CAAiB"}
@@ -0,0 +1,95 @@
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.ReferenceQuery = void 0;
16
+ const graphql_upload_1 = require("graphql-upload");
17
+ const type_graphql_1 = require("type-graphql");
18
+ const attachment_base_1 = require("@things-factory/attachment-base");
19
+ const shell_1 = require("@things-factory/shell");
20
+ const utils_1 = require("@things-factory/utils");
21
+ const lambda_call_1 = require("./lambda-call");
22
+ const debug = require('debug')('things-factory:reference-app');
23
+ let ReferenceQuery = class ReferenceQuery {
24
+ async ocrRequest(_, images, context) {
25
+ var _a;
26
+ const { domain, user, tx } = context.state;
27
+ const all = Promise.all(images);
28
+ if ((images === null || images === void 0 ? void 0 : images.length) > 0) {
29
+ const attachments = images.map(attachment => {
30
+ return {
31
+ file: attachment,
32
+ refBy: 100,
33
+ category: 'Reference'
34
+ };
35
+ });
36
+ await (0, attachment_base_1.createAttachments)(_, { attachments }, context);
37
+ const files = await Promise.all(images.map(async (file) => {
38
+ const { createReadStream, filename, mimetype } = await file;
39
+ const readStream = createReadStream();
40
+ const image = await this.streamToString(readStream);
41
+ // format is 'image/jpeg'
42
+ const formatArr = mimetype.split('/');
43
+ return { data: image, name: filename, format: formatArr[formatArr.length - 1] };
44
+ }));
45
+ const res = await (0, lambda_call_1.extractInfos)(files);
46
+ console.log('interpretImages response', JSON.stringify(res, null, ' '));
47
+ return (_a = res.data) === null || _a === void 0 ? void 0 : _a.extractInfos;
48
+ }
49
+ return [];
50
+ }
51
+ streamToString(stream) {
52
+ const chunks = [];
53
+ return new Promise((resolve, reject) => {
54
+ stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
55
+ stream.on('error', (err) => reject(err));
56
+ stream.on('end', () => resolve(Buffer.concat(chunks).toString('base64')));
57
+ });
58
+ }
59
+ async ocrPendingJob(_, tag, context) {
60
+ const { domain } = context.state;
61
+ for (var i = 0; i <= 100; i++) {
62
+ await (0, utils_1.sleep)(100);
63
+ (0, shell_1.publishProgress)({
64
+ domain,
65
+ tag,
66
+ progress: i,
67
+ message: `${i * 10} / 1000`
68
+ });
69
+ }
70
+ return 'success';
71
+ }
72
+ };
73
+ __decorate([
74
+ (0, type_graphql_1.Query)(returns => shell_1.ScalarAny, { description: 'To reference of ocr request' }),
75
+ __param(0, (0, type_graphql_1.Root)()),
76
+ __param(1, (0, type_graphql_1.Arg)('images', () => [graphql_upload_1.GraphQLUpload])),
77
+ __param(2, (0, type_graphql_1.Ctx)()),
78
+ __metadata("design:type", Function),
79
+ __metadata("design:paramtypes", [Object, Array, Object]),
80
+ __metadata("design:returntype", Promise)
81
+ ], ReferenceQuery.prototype, "ocrRequest", null);
82
+ __decorate([
83
+ (0, type_graphql_1.Query)(returns => String, { description: 'To reference of pending job progress' }),
84
+ __param(0, (0, type_graphql_1.Root)()),
85
+ __param(1, (0, type_graphql_1.Arg)('tag')),
86
+ __param(2, (0, type_graphql_1.Ctx)()),
87
+ __metadata("design:type", Function),
88
+ __metadata("design:paramtypes", [Object, String, Object]),
89
+ __metadata("design:returntype", Promise)
90
+ ], ReferenceQuery.prototype, "ocrPendingJob", null);
91
+ ReferenceQuery = __decorate([
92
+ (0, type_graphql_1.Resolver)()
93
+ ], ReferenceQuery);
94
+ exports.ReferenceQuery = ReferenceQuery;
95
+ //# sourceMappingURL=reference-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-query.js","sourceRoot":"","sources":["../../../server/service/reference/reference-query.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mDAA0D;AAC1D,+CAA8D;AAE9D,qEAA+E;AAC/E,iDAAkE;AAClE,iDAA6C;AAE7C,+CAA4C;AAE5C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,8BAA8B,CAAC,CAAA;AAGvD,IAAM,cAAc,GAApB,MAAM,cAAc;IAEnB,AAAN,KAAK,CAAC,UAAU,CACN,CAAC,EAET,MAAoB,EACb,OAAY;;QAEnB,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QAE/B,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,IAAG,CAAC,EAAE;YACtB,MAAM,WAAW,GAAiB,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;gBACxD,OAAO;oBACL,IAAI,EAAE,UAAU;oBAChB,KAAK,EAAE,GAAG;oBACV,QAAQ,EAAE,WAAW;iBACtB,CAAA;YACH,CAAC,CAAC,CAAA;YACF,MAAM,IAAA,mCAAiB,EAAC,CAAC,EAAE,EAAE,WAAW,EAAE,EAAE,OAAO,CAAC,CAAA;YAEpD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC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,6 @@
1
1
  {
2
2
  "name": "@things-factory/reference-app",
3
- "version": "4.3.671",
3
+ "version": "4.3.673",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -60,32 +60,32 @@
60
60
  "@operato/scene-tab": "^0.1.8",
61
61
  "@operato/shell": "^0.4.6",
62
62
  "@operato/utils": "^0.4.6",
63
- "@things-factory/api": "^4.3.671",
64
- "@things-factory/apptool-ui": "^4.3.671",
65
- "@things-factory/auth-ui": "^4.3.671",
66
- "@things-factory/board-service": "^4.3.671",
67
- "@things-factory/board-ui": "^4.3.671",
68
- "@things-factory/context-ui": "^4.3.671",
69
- "@things-factory/dashboard": "^4.3.671",
70
- "@things-factory/export-ui": "^4.3.671",
71
- "@things-factory/export-ui-excel": "^4.3.671",
72
- "@things-factory/grist-ui": "^4.3.671",
73
- "@things-factory/help": "^4.3.671",
74
- "@things-factory/integration-ui": "^4.3.671",
75
- "@things-factory/lite-menu": "^4.3.671",
76
- "@things-factory/more-ui": "^4.3.671",
77
- "@things-factory/notification": "^4.3.671",
78
- "@things-factory/oauth2-client": "^4.3.671",
79
- "@things-factory/print-ui": "^4.3.671",
80
- "@things-factory/resource-ui": "^4.3.671",
63
+ "@things-factory/api": "^4.3.673",
64
+ "@things-factory/apptool-ui": "^4.3.673",
65
+ "@things-factory/auth-ui": "^4.3.673",
66
+ "@things-factory/board-service": "^4.3.673",
67
+ "@things-factory/board-ui": "^4.3.673",
68
+ "@things-factory/context-ui": "^4.3.673",
69
+ "@things-factory/dashboard": "^4.3.673",
70
+ "@things-factory/export-ui": "^4.3.673",
71
+ "@things-factory/export-ui-excel": "^4.3.673",
72
+ "@things-factory/grist-ui": "^4.3.673",
73
+ "@things-factory/help": "^4.3.673",
74
+ "@things-factory/integration-ui": "^4.3.673",
75
+ "@things-factory/lite-menu": "^4.3.673",
76
+ "@things-factory/more-ui": "^4.3.673",
77
+ "@things-factory/notification": "^4.3.673",
78
+ "@things-factory/oauth2-client": "^4.3.673",
79
+ "@things-factory/print-ui": "^4.3.673",
80
+ "@things-factory/resource-ui": "^4.3.673",
81
81
  "@things-factory/scene-form": "^4.3.591",
82
- "@things-factory/setting-base": "^4.3.671",
83
- "@things-factory/setting-ui": "^4.3.671",
84
- "@things-factory/shell": "^4.3.671",
85
- "@things-factory/system-ui": "^4.3.671"
82
+ "@things-factory/setting-base": "^4.3.673",
83
+ "@things-factory/setting-ui": "^4.3.673",
84
+ "@things-factory/shell": "^4.3.673",
85
+ "@things-factory/system-ui": "^4.3.673"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@things-factory/builder": "^4.3.591"
89
89
  },
90
- "gitHead": "ef524cb207378186ec71917d9a8546363d4300b2"
90
+ "gitHead": "d22f985380f3af2ebc0f81ea8bec478ba00b4777"
91
91
  }