@things-factory/board-service 9.0.0-beta.3 → 9.0.0-beta.30
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.
- package/dist-server/controllers/analyzer/analyze-integration.js +2 -2
- package/dist-server/controllers/analyzer/analyze-integration.js.map +1 -1
- package/dist-server/controllers/headless-model.d.ts +1 -1
- package/dist-server/controllers/headless-model.js +6 -6
- package/dist-server/controllers/headless-model.js.map +1 -1
- package/dist-server/controllers/headless-playlist.d.ts +1 -1
- package/dist-server/controllers/headless-playlist.js +5 -5
- package/dist-server/controllers/headless-playlist.js.map +1 -1
- package/dist-server/controllers/headless-pool-for-label.js +2 -2
- package/dist-server/controllers/headless-pool-for-label.js.map +1 -1
- package/dist-server/controllers/index.d.ts +1 -1
- package/dist-server/controllers/index.js +8 -8
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/label-command.js +5 -5
- package/dist-server/controllers/label-command.js.map +1 -1
- package/dist-server/controllers/pdf.js +7 -7
- package/dist-server/controllers/pdf.js.map +1 -1
- package/dist-server/controllers/screenshot.js +7 -7
- package/dist-server/controllers/screenshot.js.map +1 -1
- package/dist-server/controllers/thumbnail.js +2 -2
- package/dist-server/controllers/thumbnail.js.map +1 -1
- package/dist-server/errors/index.d.ts +1 -1
- package/dist-server/errors/index.js +1 -1
- package/dist-server/errors/index.js.map +1 -1
- package/dist-server/errors/license-error.js +1 -1
- package/dist-server/errors/license-error.js.map +1 -1
- package/dist-server/index.d.ts +4 -4
- package/dist-server/index.js +4 -4
- package/dist-server/index.js.map +1 -1
- package/dist-server/migrations/1556862253000-SeedGroup.js +3 -3
- package/dist-server/migrations/1556862253000-SeedGroup.js.map +1 -1
- package/dist-server/routers/standalone-board-service-router.js +28 -28
- package/dist-server/routers/standalone-board-service-router.js.map +1 -1
- package/dist-server/routes.js +11 -10
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/analysis/analysis-query.js +2 -2
- package/dist-server/service/analysis/analysis-query.js.map +1 -1
- package/dist-server/service/analysis/index.d.ts +1 -1
- package/dist-server/service/analysis/index.js +2 -2
- package/dist-server/service/analysis/index.js.map +1 -1
- package/dist-server/service/board/board-history.d.ts +3 -3
- package/dist-server/service/board/board-history.js +7 -7
- package/dist-server/service/board/board-history.js.map +1 -1
- package/dist-server/service/board/board-mutation.d.ts +2 -2
- package/dist-server/service/board/board-mutation.js +39 -39
- package/dist-server/service/board/board-mutation.js.map +1 -1
- package/dist-server/service/board/board-query.d.ts +5 -5
- package/dist-server/service/board/board-query.js +34 -34
- package/dist-server/service/board/board-query.js.map +1 -1
- package/dist-server/service/board/board-subscription.d.ts +1 -1
- package/dist-server/service/board/board-subscription.js +3 -3
- package/dist-server/service/board/board-subscription.js.map +1 -1
- package/dist-server/service/board/board-type.d.ts +2 -2
- package/dist-server/service/board/board-type.js +4 -4
- package/dist-server/service/board/board-type.js.map +1 -1
- package/dist-server/service/board/board.d.ts +2 -2
- package/dist-server/service/board/board.js +7 -7
- package/dist-server/service/board/board.js.map +1 -1
- package/dist-server/service/board/event-subscriber.d.ts +2 -2
- package/dist-server/service/board/event-subscriber.js +6 -6
- package/dist-server/service/board/event-subscriber.js.map +1 -1
- package/dist-server/service/board/index.d.ts +6 -6
- package/dist-server/service/board/index.js +9 -9
- package/dist-server/service/board/index.js.map +1 -1
- package/dist-server/service/board-favorite/board-favorite-query.d.ts +1 -1
- package/dist-server/service/board-favorite/board-favorite-query.js +5 -5
- package/dist-server/service/board-favorite/board-favorite-query.js.map +1 -1
- package/dist-server/service/board-favorite/board-favorite-type.d.ts +1 -1
- package/dist-server/service/board-favorite/board-favorite-type.js +2 -2
- package/dist-server/service/board-favorite/board-favorite-type.js.map +1 -1
- package/dist-server/service/board-favorite/index.d.ts +1 -1
- package/dist-server/service/board-favorite/index.js +2 -2
- package/dist-server/service/board-favorite/index.js.map +1 -1
- package/dist-server/service/board-template/board-template-mutation.d.ts +2 -2
- package/dist-server/service/board-template/board-template-mutation.js +19 -19
- package/dist-server/service/board-template/board-template-mutation.js.map +1 -1
- package/dist-server/service/board-template/board-template-query.d.ts +2 -2
- package/dist-server/service/board-template/board-template-query.js +13 -13
- package/dist-server/service/board-template/board-template-query.js.map +1 -1
- package/dist-server/service/board-template/board-template-type.d.ts +1 -1
- package/dist-server/service/board-template/board-template-type.js +2 -2
- package/dist-server/service/board-template/board-template-type.js.map +1 -1
- package/dist-server/service/board-template/index.d.ts +3 -3
- package/dist-server/service/board-template/index.js +5 -5
- package/dist-server/service/board-template/index.js.map +1 -1
- package/dist-server/service/group/group-mutation.d.ts +2 -2
- package/dist-server/service/group/group-mutation.js +14 -14
- package/dist-server/service/group/group-mutation.js.map +1 -1
- package/dist-server/service/group/group-query.d.ts +3 -3
- package/dist-server/service/group/group-query.js +14 -14
- package/dist-server/service/group/group-query.js.map +1 -1
- package/dist-server/service/group/group-type.d.ts +1 -1
- package/dist-server/service/group/group-type.js +2 -2
- package/dist-server/service/group/group-type.js.map +1 -1
- package/dist-server/service/group/group.d.ts +1 -1
- package/dist-server/service/group/group.js +3 -3
- package/dist-server/service/group/group.js.map +1 -1
- package/dist-server/service/group/index.d.ts +3 -3
- package/dist-server/service/group/index.js +5 -5
- package/dist-server/service/group/index.js.map +1 -1
- package/dist-server/service/index.d.ts +6 -6
- package/dist-server/service/index.js +31 -31
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/permission/domain-permission-subscriber.js +3 -3
- package/dist-server/service/permission/domain-permission-subscriber.js.map +1 -1
- package/dist-server/service/permission/index.d.ts +1 -1
- package/dist-server/service/permission/index.js +2 -2
- package/dist-server/service/permission/index.js.map +1 -1
- package/dist-server/service/play-group/event-subscriber.d.ts +1 -1
- package/dist-server/service/play-group/event-subscriber.js +3 -3
- package/dist-server/service/play-group/event-subscriber.js.map +1 -1
- package/dist-server/service/play-group/index.d.ts +5 -5
- package/dist-server/service/play-group/index.js +8 -8
- package/dist-server/service/play-group/index.js.map +1 -1
- package/dist-server/service/play-group/play-group-mutation.d.ts +2 -2
- package/dist-server/service/play-group/play-group-mutation.js +19 -19
- package/dist-server/service/play-group/play-group-mutation.js.map +1 -1
- package/dist-server/service/play-group/play-group-query.d.ts +3 -3
- package/dist-server/service/play-group/play-group-query.js +15 -15
- package/dist-server/service/play-group/play-group-query.js.map +1 -1
- package/dist-server/service/play-group/play-group-subscription.d.ts +1 -1
- package/dist-server/service/play-group/play-group-subscription.js +3 -3
- package/dist-server/service/play-group/play-group-subscription.js.map +1 -1
- package/dist-server/service/play-group/play-group-type.d.ts +1 -1
- package/dist-server/service/play-group/play-group-type.js +2 -2
- package/dist-server/service/play-group/play-group-type.js.map +1 -1
- package/dist-server/service/play-group/play-group.d.ts +1 -1
- package/dist-server/service/play-group/play-group.js +3 -3
- package/dist-server/service/play-group/play-group.js.map +1 -1
- package/dist-server/service/theme/index.d.ts +3 -3
- package/dist-server/service/theme/index.js +5 -5
- package/dist-server/service/theme/index.js.map +1 -1
- package/dist-server/service/theme/theme-mutation.d.ts +2 -2
- package/dist-server/service/theme/theme-mutation.js +16 -16
- package/dist-server/service/theme/theme-mutation.js.map +1 -1
- package/dist-server/service/theme/theme-query.d.ts +2 -2
- package/dist-server/service/theme/theme-query.js +10 -10
- package/dist-server/service/theme/theme-query.js.map +1 -1
- package/dist-server/service/theme/theme-type.d.ts +1 -1
- package/dist-server/service/theme/theme-type.js +2 -2
- package/dist-server/service/theme/theme-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/views/internal-board-full-feature-view.html +0 -1
- package/views/internal-board-player-view.html +0 -1
- package/views/internal-board-service-view.html +0 -1
|
@@ -4,14 +4,14 @@ exports.BoardTemplateMutation = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
6
|
const shell_1 = require("@things-factory/shell");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
7
|
+
const board_template_js_1 = require("./board-template.js");
|
|
8
|
+
const board_js_1 = require("../board/board.js");
|
|
9
|
+
const board_template_type_js_1 = require("./board-template-type.js");
|
|
10
|
+
const thumbnail_js_1 = require("../../controllers/thumbnail.js");
|
|
11
11
|
let BoardTemplateMutation = class BoardTemplateMutation {
|
|
12
12
|
async createBoardTemplate(boardTemplate, context) {
|
|
13
13
|
const { domain, user, tx } = context.state;
|
|
14
|
-
const repository =
|
|
14
|
+
const repository = (0, shell_1.getRepository)(board_template_js_1.BoardTemplate, tx);
|
|
15
15
|
const oldBoardTemplate = await repository.findOneBy({
|
|
16
16
|
name: boardTemplate.name,
|
|
17
17
|
domain: { id: domain.id }
|
|
@@ -20,7 +20,7 @@ let BoardTemplateMutation = class BoardTemplateMutation {
|
|
|
20
20
|
throw new Error(context.t('error.board-template name is already taken', { name: boardTemplate.name }));
|
|
21
21
|
}
|
|
22
22
|
const newBoardTemplate = Object.assign({}, boardTemplate);
|
|
23
|
-
const base64 = await (0,
|
|
23
|
+
const base64 = await (0, thumbnail_js_1.thumbnail)({
|
|
24
24
|
model: boardTemplate.model,
|
|
25
25
|
context
|
|
26
26
|
});
|
|
@@ -34,12 +34,12 @@ let BoardTemplateMutation = class BoardTemplateMutation {
|
|
|
34
34
|
}
|
|
35
35
|
async updateBoardTemplate(id, patch, context) {
|
|
36
36
|
const { domain, user, tx } = context.state;
|
|
37
|
-
const repository =
|
|
37
|
+
const repository = (0, shell_1.getRepository)(board_template_js_1.BoardTemplate, tx);
|
|
38
38
|
const boardTemplate = await repository.findOne({
|
|
39
39
|
where: { domain: { id: domain.id }, id }
|
|
40
40
|
});
|
|
41
41
|
if (patch.model) {
|
|
42
|
-
const base64 = await (0,
|
|
42
|
+
const base64 = await (0, thumbnail_js_1.thumbnail)({
|
|
43
43
|
model: patch.model,
|
|
44
44
|
context
|
|
45
45
|
});
|
|
@@ -54,13 +54,13 @@ let BoardTemplateMutation = class BoardTemplateMutation {
|
|
|
54
54
|
}
|
|
55
55
|
async deleteBoardTemplate(id, context) {
|
|
56
56
|
const { domain, tx } = context.state;
|
|
57
|
-
await
|
|
57
|
+
await (0, shell_1.getRepository)(board_template_js_1.BoardTemplate, tx).delete({ domain: { id: domain.id }, id });
|
|
58
58
|
return true;
|
|
59
59
|
}
|
|
60
60
|
async registerBoardAsTemplate(id, name, description, visibility, context) {
|
|
61
61
|
const { domain, user, notify, tx } = context.state;
|
|
62
|
-
const boardTemplateRepository =
|
|
63
|
-
const board = await
|
|
62
|
+
const boardTemplateRepository = (0, shell_1.getRepository)(board_template_js_1.BoardTemplate, tx);
|
|
63
|
+
const board = await (0, shell_1.getRepository)(board_js_1.Board, tx).findOne({
|
|
64
64
|
where: { domain: { id: domain.id }, id }
|
|
65
65
|
});
|
|
66
66
|
if (!board) {
|
|
@@ -89,8 +89,8 @@ let BoardTemplateMutation = class BoardTemplateMutation {
|
|
|
89
89
|
mode: 'in-app',
|
|
90
90
|
title: `BoardTemplate '${registered.name}' registered`,
|
|
91
91
|
body: `BoardTemplate '${registered.name}' registered by ${user.name}\n${registered.description}`,
|
|
92
|
-
image: (0, shell_1.getRedirectSubdomainPath)(context, domain
|
|
93
|
-
url: (0, shell_1.getRedirectSubdomainPath)(context, domain
|
|
92
|
+
image: (0, shell_1.getRedirectSubdomainPath)(context, domain, `/board-template-thumbnail/${registered.id}`),
|
|
93
|
+
url: (0, shell_1.getRedirectSubdomainPath)(context, domain, `/board-template-viewer/${registered.id}`)
|
|
94
94
|
});
|
|
95
95
|
return registered;
|
|
96
96
|
}
|
|
@@ -99,22 +99,22 @@ exports.BoardTemplateMutation = BoardTemplateMutation;
|
|
|
99
99
|
tslib_1.__decorate([
|
|
100
100
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
101
101
|
(0, type_graphql_1.Directive)('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)'),
|
|
102
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
102
|
+
(0, type_graphql_1.Mutation)(returns => board_template_js_1.BoardTemplate, { description: 'To create new BoardTemplate' }),
|
|
103
103
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('boardTemplate')),
|
|
104
104
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
105
105
|
tslib_1.__metadata("design:type", Function),
|
|
106
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
106
|
+
tslib_1.__metadata("design:paramtypes", [board_template_type_js_1.NewBoardTemplate, Object]),
|
|
107
107
|
tslib_1.__metadata("design:returntype", Promise)
|
|
108
108
|
], BoardTemplateMutation.prototype, "createBoardTemplate", null);
|
|
109
109
|
tslib_1.__decorate([
|
|
110
110
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
111
111
|
(0, type_graphql_1.Directive)('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)'),
|
|
112
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
112
|
+
(0, type_graphql_1.Mutation)(returns => board_template_js_1.BoardTemplate, { description: 'To modify BoardTemplate information' }),
|
|
113
113
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
114
114
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
115
115
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
116
116
|
tslib_1.__metadata("design:type", Function),
|
|
117
|
-
tslib_1.__metadata("design:paramtypes", [String,
|
|
117
|
+
tslib_1.__metadata("design:paramtypes", [String, board_template_type_js_1.BoardTemplatePatch, Object]),
|
|
118
118
|
tslib_1.__metadata("design:returntype", Promise)
|
|
119
119
|
], BoardTemplateMutation.prototype, "updateBoardTemplate", null);
|
|
120
120
|
tslib_1.__decorate([
|
|
@@ -130,7 +130,7 @@ tslib_1.__decorate([
|
|
|
130
130
|
tslib_1.__decorate([
|
|
131
131
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
132
132
|
(0, type_graphql_1.Directive)('@privilege(category: "board-template", privilege: "mutation", domainOwnerGranted: true)'),
|
|
133
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
133
|
+
(0, type_graphql_1.Mutation)(returns => board_template_js_1.BoardTemplate, { description: 'To register a board as a board template with the given ID' }),
|
|
134
134
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id', { description: 'board Id to be regiestered' })),
|
|
135
135
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('name', { description: 'name of board template to be regiestered' })),
|
|
136
136
|
tslib_1.__param(2, (0, type_graphql_1.Arg)('description', { description: 'description of board template to be regiestered' })),
|
|
@@ -141,6 +141,6 @@ tslib_1.__decorate([
|
|
|
141
141
|
tslib_1.__metadata("design:returntype", Promise)
|
|
142
142
|
], BoardTemplateMutation.prototype, "registerBoardAsTemplate", null);
|
|
143
143
|
exports.BoardTemplateMutation = BoardTemplateMutation = tslib_1.__decorate([
|
|
144
|
-
(0, type_graphql_1.Resolver)(
|
|
144
|
+
(0, type_graphql_1.Resolver)(board_template_js_1.BoardTemplate)
|
|
145
145
|
], BoardTemplateMutation);
|
|
146
146
|
//# sourceMappingURL=board-template-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-template-mutation.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAAgE;AAChE,qDAAgD;AAChD,0CAAsC;AACtC,+DAA4E;AAC5E,2DAAuD;AAGhD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAI1B,AAAN,KAAK,CAAC,mBAAmB,CACD,aAA+B,EAC9C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAA;QAElD,MAAM,gBAAgB,GAAkB,MAAM,UAAU,CAAC,SAAS,CAAC;YACjE,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,MAAM,EAAE,EAAE,EAAE,EAAE,MA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A2D,EAAE,CAAC;IAE9G,mBAAA,IAAA,kBAAG,EAAC,IAAI,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACxD,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAA;IACxE,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC,CAAA;IACtF,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,CAAA;IACpF,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEAqDP;gCAtJU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,qBAAqB,CAuJjC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { getRedirectSubdomainPath } from '@things-factory/shell'\nimport { BoardTemplate } from './board-template'\nimport { Board } from '../board/board'\nimport { NewBoardTemplate, BoardTemplatePatch } from './board-template-type'\nimport { thumbnail } from '../../controllers/thumbnail'\n\n@Resolver(BoardTemplate)\nexport class BoardTemplateMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To create new BoardTemplate' })\n async createBoardTemplate(\n @Arg('boardTemplate') boardTemplate: NewBoardTemplate,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(BoardTemplate)\n\n const oldBoardTemplate: BoardTemplate = await repository.findOneBy({\n name: boardTemplate.name,\n domain: { id: domain.id }\n })\n\n if (oldBoardTemplate) {\n throw new Error(context.t('error.board-template name is already taken', { name: boardTemplate.name }))\n }\n\n const newBoardTemplate: Partial<BoardTemplate> = {\n ...boardTemplate\n }\n\n const base64 = await thumbnail({\n model: boardTemplate.model,\n context\n })\n\n if (base64) {\n newBoardTemplate.thumbnail = 'data:image/png;base64,' + base64.toString('base64')\n } else {\n newBoardTemplate.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='\n }\n\n return await repository.save({\n domain,\n ...newBoardTemplate,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To modify BoardTemplate information' })\n async updateBoardTemplate(\n @Arg('id') id: string,\n @Arg('patch') patch: BoardTemplatePatch,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(BoardTemplate)\n\n const boardTemplate = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (patch.model) {\n const base64 = await thumbnail({\n model: patch.model,\n context\n })\n\n if (base64) {\n patch.thumbnail = 'data:image/png;base64,' + base64.toString('base64')\n } else {\n patch.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='\n }\n }\n\n return await repository.save({\n ...boardTemplate,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete BoardTemplate' })\n async deleteBoardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(BoardTemplate).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To register a board as a board template with the given ID' })\n async registerBoardAsTemplate(\n @Arg('id', { description: 'board Id to be regiestered' }) id: string,\n @Arg('name', { description: 'name of board template to be regiestered' }) name: string,\n @Arg('description', { description: 'description of board template to be regiestered' }) description: string,\n @Arg('visibility', { description: 'visibility of board template to be regiestered' }) visibility: string,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, notify, tx } = context.state\n\n const boardTemplateRepository = tx.getRepository(BoardTemplate)\n\n const board = await tx.getRepository(Board).findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (!board) {\n throw `Board given id(${id}) is not found`\n }\n\n name ||= board.name\n\n const { model, thumbnail } = board\n\n const boardTemplate = await boardTemplateRepository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n const registered = boardTemplate\n ? await boardTemplateRepository.save({\n ...boardTemplate,\n name,\n description: description || boardTemplate.description,\n visibility: visibility || boardTemplate.visibility,\n model,\n thumbnail,\n updater: user\n })\n : await boardTemplateRepository.save({\n domain: { id: domain.id },\n name,\n description: description || board.description,\n model,\n thumbnail,\n visibility: visibility || 'private',\n updater: user,\n creator: user\n })\n\n notify &&\n notify({\n mode: 'in-app',\n title: `BoardTemplate '${registered.name}' registered`,\n body: `BoardTemplate '${registered.name}' registered by ${user.name}\\n${registered.description}`,\n image: getRedirectSubdomainPath(context, domain.subdomain, `/board-template-thumbnail/${registered.id}`),\n url: getRedirectSubdomainPath(context, domain.subdomain, `/board-template-viewer/${registered.id}`)\n })\n\n return registered\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"board-template-mutation.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,iDAA+E;AAC/E,2DAAmD;AACnD,gDAAyC;AACzC,qEAA+E;AAC/E,iEAA0D;AAGnD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAI1B,AAAN,KAAK,CAAC,mBAAmB,CACD,aAA+B,EAC9C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,UAAU,GAAG,IAAA,q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CAAA;;;;gEAMtD;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,iCAAa,EAAE,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC;IAE9G,mBAAA,IAAA,kBAAG,EAAC,IAAI,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACxD,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC,CAAA;IACxE,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,EAAE,WAAW,EAAE,iDAAiD,EAAE,CAAC,CAAA;IACtF,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE,CAAC,CAAA;IACpF,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oEAqDP;gCAtJU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,iCAAa,CAAC;GACX,qBAAqB,CAuJjC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\n\nimport { getRedirectSubdomainPath, getRepository } from '@things-factory/shell'\nimport { BoardTemplate } from './board-template.js'\nimport { Board } from '../board/board.js'\nimport { NewBoardTemplate, BoardTemplatePatch } from './board-template-type.js'\nimport { thumbnail } from '../../controllers/thumbnail.js'\n\n@Resolver(BoardTemplate)\nexport class BoardTemplateMutation {\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To create new BoardTemplate' })\n async createBoardTemplate(\n @Arg('boardTemplate') boardTemplate: NewBoardTemplate,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, tx } = context.state\n const repository = getRepository(BoardTemplate, tx)\n\n const oldBoardTemplate: BoardTemplate = await repository.findOneBy({\n name: boardTemplate.name,\n domain: { id: domain.id }\n })\n\n if (oldBoardTemplate) {\n throw new Error(context.t('error.board-template name is already taken', { name: boardTemplate.name }))\n }\n\n const newBoardTemplate: Partial<BoardTemplate> = {\n ...boardTemplate\n }\n\n const base64 = await thumbnail({\n model: boardTemplate.model,\n context\n })\n\n if (base64) {\n newBoardTemplate.thumbnail = 'data:image/png;base64,' + base64.toString('base64')\n } else {\n newBoardTemplate.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='\n }\n\n return await repository.save({\n domain,\n ...newBoardTemplate,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To modify BoardTemplate information' })\n async updateBoardTemplate(\n @Arg('id') id: string,\n @Arg('patch') patch: BoardTemplatePatch,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, tx } = context.state\n const repository = getRepository(BoardTemplate, tx)\n\n const boardTemplate = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (patch.model) {\n const base64 = await thumbnail({\n model: patch.model,\n context\n })\n\n if (base64) {\n patch.thumbnail = 'data:image/png;base64,' + base64.toString('base64')\n } else {\n patch.thumbnail = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=='\n }\n }\n\n return await repository.save({\n ...boardTemplate,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => Boolean, { description: 'To delete BoardTemplate' })\n async deleteBoardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(BoardTemplate, tx).delete({ domain: { id: domain.id }, id })\n\n return true\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"board-template\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => BoardTemplate, { description: 'To register a board as a board template with the given ID' })\n async registerBoardAsTemplate(\n @Arg('id', { description: 'board Id to be regiestered' }) id: string,\n @Arg('name', { description: 'name of board template to be regiestered' }) name: string,\n @Arg('description', { description: 'description of board template to be regiestered' }) description: string,\n @Arg('visibility', { description: 'visibility of board template to be regiestered' }) visibility: string,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplate> {\n const { domain, user, notify, tx } = context.state\n\n const boardTemplateRepository = getRepository(BoardTemplate, tx)\n\n const board = await getRepository(Board, tx).findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n if (!board) {\n throw `Board given id(${id}) is not found`\n }\n\n name ||= board.name\n\n const { model, thumbnail } = board\n\n const boardTemplate = await boardTemplateRepository.findOne({\n where: { domain: { id: domain.id }, name }\n })\n\n const registered = boardTemplate\n ? await boardTemplateRepository.save({\n ...boardTemplate,\n name,\n description: description || boardTemplate.description,\n visibility: visibility || boardTemplate.visibility,\n model,\n thumbnail,\n updater: user\n })\n : await boardTemplateRepository.save({\n domain: { id: domain.id },\n name,\n description: description || board.description,\n model,\n thumbnail,\n visibility: visibility || 'private',\n updater: user,\n creator: user\n })\n\n notify &&\n notify({\n mode: 'in-app',\n title: `BoardTemplate '${registered.name}' registered`,\n body: `BoardTemplate '${registered.name}' registered by ${user.name}\\n${registered.description}`,\n image: getRedirectSubdomainPath(context, domain, `/board-template-thumbnail/${registered.id}`),\n url: getRedirectSubdomainPath(context, domain, `/board-template-viewer/${registered.id}`)\n })\n\n return registered\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Domain, ListParam } from '@things-factory/shell';
|
|
2
2
|
import { User } from '@things-factory/auth-base';
|
|
3
|
-
import { BoardTemplate } from './board-template';
|
|
4
|
-
import { BoardTemplateList } from './board-template-type';
|
|
3
|
+
import { BoardTemplate } from './board-template.js';
|
|
4
|
+
import { BoardTemplateList } from './board-template-type.js';
|
|
5
5
|
export declare class BoardTemplateQuery {
|
|
6
6
|
boardTemplate(id: string, context: ResolverContext): Promise<BoardTemplate>;
|
|
7
7
|
boardTemplatesCreatedByMe(params: ListParam, context: ResolverContext): Promise<BoardTemplateList>;
|
|
@@ -6,12 +6,12 @@ const typeorm_1 = require("typeorm");
|
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const board_template_js_1 = require("./board-template.js");
|
|
10
|
+
const board_template_type_js_1 = require("./board-template-type.js");
|
|
11
11
|
let BoardTemplateQuery = class BoardTemplateQuery {
|
|
12
12
|
async boardTemplate(id, context) {
|
|
13
13
|
const { domain, user } = context.state;
|
|
14
|
-
const qb = await (0, shell_1.getRepository)(
|
|
14
|
+
const qb = await (0, shell_1.getRepository)(board_template_js_1.BoardTemplate)
|
|
15
15
|
.createQueryBuilder('BoardTemplate')
|
|
16
16
|
.where('id=:id', { id })
|
|
17
17
|
.andWhere(new typeorm_1.Brackets(qb => {
|
|
@@ -36,7 +36,7 @@ let BoardTemplateQuery = class BoardTemplateQuery {
|
|
|
36
36
|
async boardTemplatesCreatedByMe(params, context) {
|
|
37
37
|
const { user } = context.state;
|
|
38
38
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
39
|
-
repository: (0, shell_1.getRepository)(
|
|
39
|
+
repository: (0, shell_1.getRepository)(board_template_js_1.BoardTemplate),
|
|
40
40
|
params,
|
|
41
41
|
alias: 'template',
|
|
42
42
|
searchables: ['name', 'description']
|
|
@@ -54,7 +54,7 @@ let BoardTemplateQuery = class BoardTemplateQuery {
|
|
|
54
54
|
*/
|
|
55
55
|
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
56
56
|
params,
|
|
57
|
-
repository: await (0, shell_1.getRepository)(
|
|
57
|
+
repository: await (0, shell_1.getRepository)(board_template_js_1.BoardTemplate),
|
|
58
58
|
searchables: ['name', 'description']
|
|
59
59
|
}).andWhere(new typeorm_1.Brackets(qb => {
|
|
60
60
|
qb.where({ visibility: 'public' })
|
|
@@ -87,7 +87,7 @@ let BoardTemplateQuery = class BoardTemplateQuery {
|
|
|
87
87
|
};
|
|
88
88
|
exports.BoardTemplateQuery = BoardTemplateQuery;
|
|
89
89
|
tslib_1.__decorate([
|
|
90
|
-
(0, type_graphql_1.Query)(returns =>
|
|
90
|
+
(0, type_graphql_1.Query)(returns => board_template_js_1.BoardTemplate, { nullable: true, description: 'To fetch a BoardTemplate' }),
|
|
91
91
|
(0, type_graphql_1.Directive)('@privilege(category: "board-template", privilege: "query", domainOwnerGranted: true)'),
|
|
92
92
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
93
93
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -96,7 +96,7 @@ tslib_1.__decorate([
|
|
|
96
96
|
tslib_1.__metadata("design:returntype", Promise)
|
|
97
97
|
], BoardTemplateQuery.prototype, "boardTemplate", null);
|
|
98
98
|
tslib_1.__decorate([
|
|
99
|
-
(0, type_graphql_1.Query)(returns =>
|
|
99
|
+
(0, type_graphql_1.Query)(returns => board_template_type_js_1.BoardTemplateList, { description: 'To fetch BoardTemplates created by me' }),
|
|
100
100
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
101
101
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
102
102
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -104,7 +104,7 @@ tslib_1.__decorate([
|
|
|
104
104
|
tslib_1.__metadata("design:returntype", Promise)
|
|
105
105
|
], BoardTemplateQuery.prototype, "boardTemplatesCreatedByMe", null);
|
|
106
106
|
tslib_1.__decorate([
|
|
107
|
-
(0, type_graphql_1.Query)(returns =>
|
|
107
|
+
(0, type_graphql_1.Query)(returns => board_template_type_js_1.BoardTemplateList, { description: 'To fetch multiple BoardTemplates' }),
|
|
108
108
|
(0, type_graphql_1.Directive)('@privilege(category: "board-template", privilege: "query", domainOwnerGranted: true)'),
|
|
109
109
|
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
110
110
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
@@ -117,31 +117,31 @@ tslib_1.__decorate([
|
|
|
117
117
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
118
118
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
119
119
|
tslib_1.__metadata("design:type", Function),
|
|
120
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
120
|
+
tslib_1.__metadata("design:paramtypes", [board_template_js_1.BoardTemplate, Object]),
|
|
121
121
|
tslib_1.__metadata("design:returntype", Promise)
|
|
122
122
|
], BoardTemplateQuery.prototype, "mine", null);
|
|
123
123
|
tslib_1.__decorate([
|
|
124
124
|
(0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
|
|
125
125
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
126
126
|
tslib_1.__metadata("design:type", Function),
|
|
127
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
127
|
+
tslib_1.__metadata("design:paramtypes", [board_template_js_1.BoardTemplate]),
|
|
128
128
|
tslib_1.__metadata("design:returntype", Promise)
|
|
129
129
|
], BoardTemplateQuery.prototype, "domain", null);
|
|
130
130
|
tslib_1.__decorate([
|
|
131
131
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
132
132
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
133
133
|
tslib_1.__metadata("design:type", Function),
|
|
134
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
134
|
+
tslib_1.__metadata("design:paramtypes", [board_template_js_1.BoardTemplate]),
|
|
135
135
|
tslib_1.__metadata("design:returntype", Promise)
|
|
136
136
|
], BoardTemplateQuery.prototype, "updater", null);
|
|
137
137
|
tslib_1.__decorate([
|
|
138
138
|
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
|
|
139
139
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
140
140
|
tslib_1.__metadata("design:type", Function),
|
|
141
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
141
|
+
tslib_1.__metadata("design:paramtypes", [board_template_js_1.BoardTemplate]),
|
|
142
142
|
tslib_1.__metadata("design:returntype", Promise)
|
|
143
143
|
], BoardTemplateQuery.prototype, "creator", null);
|
|
144
144
|
exports.BoardTemplateQuery = BoardTemplateQuery = tslib_1.__decorate([
|
|
145
|
-
(0, type_graphql_1.Resolver)(
|
|
145
|
+
(0, type_graphql_1.Resolver)(board_template_js_1.BoardTemplate)
|
|
146
146
|
], BoardTemplateQuery);
|
|
147
147
|
//# sourceMappingURL=board-template-query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-template-query.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-query.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,+CAA8F;
|
|
1
|
+
{"version":3,"file":"board-template-query.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-query.ts"],"names":[],"mappings":";;;;AAAA,qCAAsC;AACtC,+CAA8F;AAC9F,iDAAuG;AACvG,yDAAgD;AAChD,2DAAmD;AACnD,qEAA4D;AAGrD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,aAAa,CAAY,EAAU,EAAS,OAAwB;QACxE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAa,EAAC,iCAAa,CAAC;aAC1C,kBAAkB,CAAC,eAAe,CAAC;aACnC,KAAK,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC;aACvB,QAAQ,CACP,IAAI,kBAAQ,CAAC,EAAE,CAAC,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iBAAS;;wDAgC3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;IACnB,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAgC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CAArB,iCAAa;;8CAK9C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,iCAAa;;gDAEhD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,iCAAa;;iDAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,iCAAa;;iDAEjD;6BA9GU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,iCAAa,CAAC;GACX,kBAAkB,CA+G9B","sourcesContent":["import { Brackets, In } from 'typeorm'\nimport { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { BoardTemplate } from './board-template.js'\nimport { BoardTemplateList } from './board-template-type.js'\n\n@Resolver(BoardTemplate)\nexport class BoardTemplateQuery {\n @Query(returns => BoardTemplate!, { nullable: true, description: 'To fetch a BoardTemplate' })\n @Directive('@privilege(category: \"board-template\", privilege: \"query\", domainOwnerGranted: true)')\n async boardTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<BoardTemplate> {\n const { domain, user } = context.state\n\n const qb = await getRepository(BoardTemplate)\n .createQueryBuilder('BoardTemplate')\n .where('id=:id', { id })\n .andWhere(\n new Brackets(qb => {\n qb.where({ visibility: 'public' })\n .orWhere({\n visibility: 'domain',\n domain: { id: In([domain.id, domain.parentId]) }\n })\n .orWhere({\n visibility: 'private',\n creator: { id: user.id }\n })\n })\n )\n\n return qb.getOne()\n\n // return await getRepository(BoardTemplate).findOne({\n // where: {\n // domain: { id: In([domain.id, domain.parentId].filter(Boolean)) },\n // id\n // }\n // })\n }\n\n @Query(returns => BoardTemplateList, { description: 'To fetch BoardTemplates created by me' })\n async boardTemplatesCreatedByMe(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplateList> {\n const { user } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(BoardTemplate),\n params,\n alias: 'template',\n searchables: ['name', 'description']\n }).andWhere('template.creator = :user', { user: user.id })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => BoardTemplateList, { description: 'To fetch multiple BoardTemplates' })\n @Directive('@privilege(category: \"board-template\", privilege: \"query\", domainOwnerGranted: true)')\n async boardTemplates(\n @Args(type => ListParam) params: ListParam,\n @Ctx() context: ResolverContext\n ): Promise<BoardTemplateList> {\n const { domain, user } = context.state\n /* \n 리스트에 포함되는 보드템플릿들 \n - visibility가 public 인 경우\n - visibility가 domain이며 컨텍스트의 도메인과 같은 경우\n - visibility가 private 이며, creator가 나인 경우\n */\n\n const queryBuilder = getQueryBuilderFromListParams({\n params,\n repository: await getRepository(BoardTemplate),\n searchables: ['name', 'description']\n }).andWhere(\n new Brackets(qb => {\n qb.where({ visibility: 'public' })\n .orWhere({\n visibility: 'domain',\n domain: { id: In([domain.id, domain.parentId]) }\n })\n .orWhere({\n visibility: 'private',\n creator: { id: user.id }\n })\n })\n )\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => Boolean)\n async mine(@Root() boardTemplate: BoardTemplate, @Ctx() context: ResolverContext): Promise<boolean> {\n const { creatorId } = boardTemplate\n const { user } = context.state\n\n return creatorId == user.id\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() boardTemplate: BoardTemplate): Promise<Domain> {\n return boardTemplate.domainId && (await getRepository(Domain).findOneBy({ id: boardTemplate.domainId }))\n }\n\n @FieldResolver(type => User)\n async updater(@Root() boardTemplate: BoardTemplate): Promise<User> {\n return boardTemplate.updaterId && (await getRepository(User).findOneBy({ id: boardTemplate.updaterId }))\n }\n\n @FieldResolver(type => User)\n async creator(@Root() boardTemplate: BoardTemplate): Promise<User> {\n return boardTemplate.creatorId && (await getRepository(User).findOneBy({ id: boardTemplate.creatorId }))\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BoardTemplateList = exports.BoardTemplatePatch = exports.NewBoardTemplate = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const
|
|
6
|
+
const board_template_js_1 = require("./board-template.js");
|
|
7
7
|
let NewBoardTemplate = class NewBoardTemplate {
|
|
8
8
|
};
|
|
9
9
|
exports.NewBoardTemplate = NewBoardTemplate;
|
|
@@ -68,7 +68,7 @@ let BoardTemplateList = class BoardTemplateList {
|
|
|
68
68
|
};
|
|
69
69
|
exports.BoardTemplateList = BoardTemplateList;
|
|
70
70
|
tslib_1.__decorate([
|
|
71
|
-
(0, type_graphql_1.Field)(type => [
|
|
71
|
+
(0, type_graphql_1.Field)(type => [board_template_js_1.BoardTemplate]),
|
|
72
72
|
tslib_1.__metadata("design:type", Array)
|
|
73
73
|
], BoardTemplateList.prototype, "items", void 0);
|
|
74
74
|
tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-template-type.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AACpE,
|
|
1
|
+
{"version":3,"file":"board-template-type.js","sourceRoot":"","sources":["../../../server/service/board-template/board-template-type.ts"],"names":[],"mappings":";;;;AAAA,+CA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C;;gDACT;AAGtB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;gDACN;4BALF,iBAAiB;IAD7B,IAAA,yBAAU,GAAE;GACA,iBAAiB,CAM7B","sourcesContent":["import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'\nimport { BoardTemplate } from './board-template.js'\n\n@InputType()\nexport class NewBoardTemplate {\n @Field()\n name: string\n\n @Field()\n description: string\n\n @Field()\n model: string\n\n @Field()\n visibility: 'private' | 'public'\n\n @Field({ nullable: true })\n thumbnail: string\n}\n\n@InputType()\nexport class BoardTemplatePatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n name?: string\n\n @Field({ nullable: true })\n description?: string\n\n @Field({ nullable: true })\n model: string\n\n @Field({ nullable: true })\n visibility?: 'private' | 'public'\n\n @Field({ nullable: true })\n thumbnail?: string\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class BoardTemplateList {\n @Field(type => [BoardTemplate])\n items: BoardTemplate[]\n\n @Field(type => Int)\n total: number\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BoardTemplate } from './board-template';
|
|
2
|
-
import { BoardTemplateQuery } from './board-template-query';
|
|
3
|
-
import { BoardTemplateMutation } from './board-template-mutation';
|
|
1
|
+
import { BoardTemplate } from './board-template.js';
|
|
2
|
+
import { BoardTemplateQuery } from './board-template-query.js';
|
|
3
|
+
import { BoardTemplateMutation } from './board-template-mutation.js';
|
|
4
4
|
export declare const entities: (typeof BoardTemplate)[];
|
|
5
5
|
export declare const resolvers: (typeof BoardTemplateQuery | typeof BoardTemplateMutation)[];
|
|
6
6
|
export declare const subscribers: any[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.subscribers = exports.resolvers = exports.entities = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
exports.entities = [
|
|
8
|
-
exports.resolvers = [
|
|
4
|
+
const board_template_js_1 = require("./board-template.js");
|
|
5
|
+
const board_template_query_js_1 = require("./board-template-query.js");
|
|
6
|
+
const board_template_mutation_js_1 = require("./board-template-mutation.js");
|
|
7
|
+
exports.entities = [board_template_js_1.BoardTemplate];
|
|
8
|
+
exports.resolvers = [board_template_query_js_1.BoardTemplateQuery, board_template_mutation_js_1.BoardTemplateMutation];
|
|
9
9
|
exports.subscribers = [];
|
|
10
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/board-template/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/board-template/index.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AACnD,uEAA8D;AAC9D,6EAAoE;AAEvD,QAAA,QAAQ,GAAG,CAAC,iCAAa,CAAC,CAAA;AAC1B,QAAA,SAAS,GAAG,CAAC,4CAAkB,EAAE,kDAAqB,CAAC,CAAA;AACvD,QAAA,WAAW,GAAG,EAAE,CAAA","sourcesContent":["import { BoardTemplate } from './board-template.js'\nimport { BoardTemplateQuery } from './board-template-query.js'\nimport { BoardTemplateMutation } from './board-template-mutation.js'\n\nexport const entities = [BoardTemplate]\nexport const resolvers = [BoardTemplateQuery, BoardTemplateMutation]\nexport const subscribers = []\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Group } from './group';
|
|
2
|
-
import { GroupPatch, NewGroup } from './group-type';
|
|
1
|
+
import { Group } from './group.js';
|
|
2
|
+
import { GroupPatch, NewGroup } from './group-type.js';
|
|
3
3
|
export declare class GroupMutation {
|
|
4
4
|
createGroup(group: NewGroup, context: ResolverContext): Promise<Group>;
|
|
5
5
|
updateGroup(id: string, patch: GroupPatch, context: ResolverContext): Promise<Group>;
|
|
@@ -3,25 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GroupMutation = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const board_js_1 = require("../board/board.js");
|
|
7
|
+
const group_js_1 = require("./group.js");
|
|
8
|
+
const group_type_js_1 = require("./group-type.js");
|
|
9
9
|
let GroupMutation = class GroupMutation {
|
|
10
10
|
async createGroup(group, context) {
|
|
11
11
|
const { domain, user, tx } = context.state;
|
|
12
|
-
return await tx.getRepository(
|
|
12
|
+
return await tx.getRepository(group_js_1.Group).save(Object.assign(Object.assign({ domain }, group), { creator: user, updater: user }));
|
|
13
13
|
}
|
|
14
14
|
async updateGroup(id, patch, context) {
|
|
15
15
|
const { domain, user, tx } = context.state;
|
|
16
|
-
const repository = tx.getRepository(
|
|
16
|
+
const repository = tx.getRepository(group_js_1.Group);
|
|
17
17
|
const group = await repository.findOneBy({ domain: { id: domain.id }, id });
|
|
18
18
|
return await repository.save(Object.assign(Object.assign(Object.assign({}, group), patch), { updater: user }));
|
|
19
19
|
}
|
|
20
20
|
async joinGroup(id, boardIds, context) {
|
|
21
21
|
const { domain, tx } = context.state;
|
|
22
|
-
const repository = tx.getRepository(
|
|
22
|
+
const repository = tx.getRepository(group_js_1.Group);
|
|
23
23
|
const group = await repository.findOneBy({ domain: { id: domain.id }, id });
|
|
24
|
-
const boardRepository = tx.getRepository(
|
|
24
|
+
const boardRepository = tx.getRepository(board_js_1.Board);
|
|
25
25
|
await boardIds.forEach(async (boardId) => {
|
|
26
26
|
let board = await boardRepository.findOneBy({ domain: { id: domain.id }, id: boardId });
|
|
27
27
|
board.group = group;
|
|
@@ -34,7 +34,7 @@ let GroupMutation = class GroupMutation {
|
|
|
34
34
|
}
|
|
35
35
|
async deleteGroup(id, context) {
|
|
36
36
|
const { domain, tx } = context.state;
|
|
37
|
-
const repository = tx.getRepository(
|
|
37
|
+
const repository = tx.getRepository(group_js_1.Group);
|
|
38
38
|
/* TODO - 그룹에 소속된 보드가 있는 경우에는 그룹을 지워서는 안된다. */
|
|
39
39
|
const group = await repository.findOneBy({
|
|
40
40
|
domain: { id: domain.id },
|
|
@@ -47,26 +47,26 @@ let GroupMutation = class GroupMutation {
|
|
|
47
47
|
exports.GroupMutation = GroupMutation;
|
|
48
48
|
tslib_1.__decorate([
|
|
49
49
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
50
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
50
|
+
(0, type_graphql_1.Mutation)(returns => group_js_1.Group, { nullable: true, description: 'To create new Group' }),
|
|
51
51
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('group')),
|
|
52
52
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
53
53
|
tslib_1.__metadata("design:type", Function),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [group_type_js_1.NewGroup, Object]),
|
|
55
55
|
tslib_1.__metadata("design:returntype", Promise)
|
|
56
56
|
], GroupMutation.prototype, "createGroup", null);
|
|
57
57
|
tslib_1.__decorate([
|
|
58
58
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
59
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
59
|
+
(0, type_graphql_1.Mutation)(returns => group_js_1.Group, { description: 'To modify Group information' }),
|
|
60
60
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
61
61
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch')),
|
|
62
62
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
63
63
|
tslib_1.__metadata("design:type", Function),
|
|
64
|
-
tslib_1.__metadata("design:paramtypes", [String,
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [String, group_type_js_1.GroupPatch, Object]),
|
|
65
65
|
tslib_1.__metadata("design:returntype", Promise)
|
|
66
66
|
], GroupMutation.prototype, "updateGroup", null);
|
|
67
67
|
tslib_1.__decorate([
|
|
68
68
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
69
|
-
(0, type_graphql_1.Mutation)(returns =>
|
|
69
|
+
(0, type_graphql_1.Mutation)(returns => group_js_1.Group, { description: 'To make the board to join the group' }),
|
|
70
70
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
71
71
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('boardIds', type => [String])),
|
|
72
72
|
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
@@ -84,6 +84,6 @@ tslib_1.__decorate([
|
|
|
84
84
|
tslib_1.__metadata("design:returntype", Promise)
|
|
85
85
|
], GroupMutation.prototype, "deleteGroup", null);
|
|
86
86
|
exports.GroupMutation = GroupMutation = tslib_1.__decorate([
|
|
87
|
-
(0, type_graphql_1.Resolver)(
|
|
87
|
+
(0, type_graphql_1.Resolver)(group_js_1.Group)
|
|
88
88
|
], GroupMutation);
|
|
89
89
|
//# sourceMappingURL=group-mutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group-mutation.js","sourceRoot":"","sources":["../../../server/service/group/group-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,
|
|
1
|
+
{"version":3,"file":"group-mutation.js","sourceRoot":"","sources":["../../../server/service/group/group-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AAEtE,gDAAyC;AACzC,yCAAkC;AAClC,mDAAsD;AAG/C,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGlB,AAAN,KAAK,CAAC,WAAW,CAAe,KAAe,EAAS,OAAwB;QAC9E,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,gBAAK,CAAC,CAAC,IAAI,+BACvC,MAAM,IACH,KAAK,KACR,OAAO,EAAE,I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AAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;qDADe,0BAAU;;gDAahC;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,gBAAK,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;IAEhF,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IACjC,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8CAkBP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gDAa9C;wBAzEU,aAAa;IADzB,IAAA,uBAAQ,EAAC,gBAAK,CAAC;GACH,aAAa,CA0EzB","sourcesContent":["import { Arg, Ctx, Mutation, Resolver, Directive } from 'type-graphql'\n\nimport { Board } from '../board/board.js'\nimport { Group } from './group.js'\nimport { GroupPatch, NewGroup } from './group-type.js'\n\n@Resolver(Group)\nexport class GroupMutation {\n @Directive('@transaction')\n @Mutation(returns => Group, { nullable: true, description: 'To create new Group' })\n async createGroup(@Arg('group') group: NewGroup, @Ctx() context: ResolverContext): Promise<Group> {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(Group).save({\n domain,\n ...group,\n creator: user,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Group, { description: 'To modify Group information' })\n async updateGroup(\n @Arg('id') id: string,\n @Arg('patch') patch: GroupPatch,\n @Ctx() context: ResolverContext\n ): Promise<Group> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(Group)\n\n const group = await repository.findOneBy({ domain: { id: domain.id }, id })\n\n return await repository.save({\n ...group,\n ...patch,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Group, { description: 'To make the board to join the group' })\n async joinGroup(\n @Arg('id') id: string,\n @Arg('boardIds', type => [String]) boardIds: string[],\n @Ctx() context: ResolverContext\n ) {\n const { domain, tx } = context.state\n const repository = tx.getRepository(Group)\n const group = await repository.findOneBy({ domain: { id: domain.id }, id })\n\n const boardRepository = tx.getRepository(Board)\n\n await boardIds.forEach(async boardId => {\n let board = await boardRepository.findOneBy({ domain: { id: domain.id }, id: boardId })\n board.group = group\n await boardRepository.save(board)\n })\n\n return await repository.findOne({\n where: { domain: { id: domain.id }, id },\n relations: ['boards']\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Group' })\n async deleteGroup(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n const repository = tx.getRepository(Group)\n\n /* TODO - 그룹에 소속된 보드가 있는 경우에는 그룹을 지워서는 안된다. */\n const group = await repository.findOneBy({\n domain: { id: domain.id },\n id\n })\n\n await repository.delete(id)\n return true\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { User } from '@things-factory/auth-base';
|
|
2
2
|
import { Domain, ListParam } from '@things-factory/shell';
|
|
3
|
-
import { Board } from '../board/board';
|
|
4
|
-
import { Group } from './group';
|
|
5
|
-
import { GroupList } from './group-type';
|
|
3
|
+
import { Board } from '../board/board.js';
|
|
4
|
+
import { Group } from './group.js';
|
|
5
|
+
import { GroupList } from './group-type.js';
|
|
6
6
|
export declare class GroupQuery {
|
|
7
7
|
group(id: string, context: ResolverContext): Promise<Group>;
|
|
8
8
|
groups(params: ListParam, context: ResolverContext): Promise<GroupList>;
|