@rytass/cms-base-nestjs-graphql-module 0.1.26 → 0.1.27
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/LICENSE +21 -0
- package/cms-base-graphql.module.d.ts +9 -0
- package/cms-base-graphql.module.js +114 -0
- package/constants/enum/base-action.enum.d.ts +14 -0
- package/constants/enum/base-action.enum.js +17 -0
- package/constants/enum/base-resource.enum.d.ts +4 -0
- package/constants/enum/base-resource.enum.js +7 -0
- package/constants/option-providers.d.ts +2 -0
- package/constants/option-providers.js +20 -0
- package/data-loaders/article.dataloader.d.ts +17 -0
- package/data-loaders/article.dataloader.js +68 -0
- package/data-loaders/members.dataloader.d.ts +8 -0
- package/data-loaders/members.dataloader.js +56 -0
- package/decorators/language.decorator.d.ts +2 -0
- package/decorators/language.decorator.js +32 -0
- package/dto/article-collection.dto.d.ts +5 -0
- package/dto/article-collection.dto.js +27 -0
- package/dto/article-multi-language-content.dto.d.ts +7 -0
- package/dto/article-multi-language-content.dto.js +41 -0
- package/dto/article-signature-step.dto.d.ts +4 -0
- package/dto/article-signature-step.dto.js +28 -0
- package/dto/article-signature.dto.d.ts +7 -0
- package/dto/article-signature.dto.js +44 -0
- package/dto/article-stage-version.dto.d.ts +9 -0
- package/dto/article-stage-version.dto.js +59 -0
- package/dto/article-version-content.input.d.ts +7 -0
- package/dto/article-version-content.input.js +43 -0
- package/dto/article.dto.d.ts +7 -0
- package/dto/article.dto.js +37 -0
- package/dto/articles.args.d.ts +6 -0
- package/dto/articles.args.js +48 -0
- package/dto/backstage-article-collection.dto.d.ts +5 -0
- package/dto/backstage-article-collection.dto.js +27 -0
- package/dto/backstage-article.args.d.ts +6 -0
- package/dto/backstage-article.args.js +38 -0
- package/dto/backstage-article.dto.d.ts +6 -0
- package/dto/backstage-article.dto.js +38 -0
- package/dto/backstage-category.dto.d.ts +3 -0
- package/dto/backstage-category.dto.js +16 -0
- package/dto/base-article.dto.d.ts +7 -0
- package/dto/base-article.dto.js +47 -0
- package/dto/base-category.dto.d.ts +5 -0
- package/dto/base-category.dto.js +33 -0
- package/dto/categories.args.d.ts +8 -0
- package/dto/categories.args.js +62 -0
- package/dto/category-multi-language-name.dto.d.ts +4 -0
- package/dto/category-multi-language-name.dto.js +28 -0
- package/dto/category-multi-language-name.input.d.ts +4 -0
- package/dto/category-multi-language-name.input.js +30 -0
- package/dto/category.dto.d.ts +4 -0
- package/dto/category.dto.js +24 -0
- package/dto/collection.dto.d.ts +5 -0
- package/dto/collection.dto.js +33 -0
- package/dto/create-article.args.d.ts +11 -0
- package/dto/create-article.args.js +71 -0
- package/dto/create-category.args.d.ts +7 -0
- package/dto/create-category.args.js +45 -0
- package/dto/custom-field.input.d.ts +4 -0
- package/dto/custom-field.input.js +28 -0
- package/dto/update-article.args.d.ts +4 -0
- package/dto/update-article.args.js +24 -0
- package/dto/update-category.args.d.ts +4 -0
- package/dto/update-category.args.js +24 -0
- package/dto/user.dto.d.ts +4 -0
- package/dto/user.dto.js +28 -0
- package/index.cjs.js +2334 -0
- package/{src/index.ts → index.d.ts} +0 -2
- package/index.js +8 -0
- package/mutations/article.mutations.d.ts +22 -0
- package/mutations/article.mutations.js +338 -0
- package/mutations/category.mutations.d.ts +15 -0
- package/mutations/category.mutations.js +134 -0
- package/package.json +6 -10
- package/queries/article.queries.d.ts +16 -0
- package/queries/article.queries.js +132 -0
- package/queries/category.queries.d.ts +13 -0
- package/queries/category.queries.js +124 -0
- package/resolvers/article-signature.resolver.d.ts +10 -0
- package/resolvers/article-signature.resolver.js +68 -0
- package/resolvers/article.resolver.d.ts +14 -0
- package/resolvers/article.resolver.js +95 -0
- package/resolvers/backstage-article.resolver.d.ts +33 -0
- package/resolvers/backstage-article.resolver.js +296 -0
- package/resolvers/backstage-category.resolver.d.ts +8 -0
- package/resolvers/backstage-category.resolver.js +76 -0
- package/scalars/quadrats-element.scalar.d.ts +3 -0
- package/scalars/quadrats-element.scalar.js +47 -0
- package/typings/cms-graphql-base-providers.d.ts +3 -0
- package/typings/cms-graphql-base-providers.js +5 -0
- package/{src/typings/cms-graphql-base-root-module-async-options.dto.ts → typings/cms-graphql-base-root-module-async-options.dto.d.ts} +4 -6
- package/{src/typings/cms-graphql-base-root-module-option-factory.ts → typings/cms-graphql-base-root-module-option-factory.d.ts} +1 -2
- package/typings/cms-graphql-base-root-module-options.dto.d.ts +6 -0
- package/typings/dto/resolved-create-article-args.dto.d.ts +24 -0
- package/typings/dto/resolved-create-category-args.dto.d.ts +13 -0
- package/CHANGELOG.md +0 -306
- package/__tests__/enums.spec.ts +0 -76
- package/__tests__/language-decorator.spec.ts +0 -17
- package/__tests__/quadrats-element-scalar.spec.ts +0 -123
- package/llms.txt +0 -361
- package/project.json +0 -23
- package/src/cms-base-graphql.module.ts +0 -101
- package/src/constants/enum/base-action.enum.ts +0 -17
- package/src/constants/enum/base-resource.enum.ts +0 -4
- package/src/constants/option-providers.ts +0 -35
- package/src/data-loaders/article.dataloader.ts +0 -84
- package/src/data-loaders/members.dataloader.ts +0 -36
- package/src/decorators/language.decorator.ts +0 -45
- package/src/dto/article-collection.dto.ts +0 -9
- package/src/dto/article-multi-language-content.dto.ts +0 -18
- package/src/dto/article-signature-step.dto.ts +0 -10
- package/src/dto/article-signature.dto.ts +0 -21
- package/src/dto/article-stage-version.dto.ts +0 -23
- package/src/dto/article-version-content.input.ts +0 -18
- package/src/dto/article.dto.ts +0 -16
- package/src/dto/articles.args.ts +0 -16
- package/src/dto/backstage-article-collection.dto.ts +0 -9
- package/src/dto/backstage-article.args.ts +0 -20
- package/src/dto/backstage-article.dto.ts +0 -14
- package/src/dto/backstage-category.dto.ts +0 -5
- package/src/dto/base-article.dto.ts +0 -19
- package/src/dto/base-category.dto.ts +0 -13
- package/src/dto/categories.args.ts +0 -27
- package/src/dto/category-multi-language-name.dto.ts +0 -10
- package/src/dto/category-multi-language-name.input.ts +0 -10
- package/src/dto/category.dto.ts +0 -8
- package/src/dto/collection.dto.ts +0 -13
- package/src/dto/create-article.args.ts +0 -27
- package/src/dto/create-category.args.ts +0 -15
- package/src/dto/custom-field.input.ts +0 -10
- package/src/dto/update-article.args.ts +0 -8
- package/src/dto/update-category.args.ts +0 -8
- package/src/dto/user.dto.ts +0 -10
- package/src/mutations/article.mutations.ts +0 -177
- package/src/mutations/category.mutations.ts +0 -78
- package/src/queries/article.queries.ts +0 -71
- package/src/queries/category.queries.ts +0 -53
- package/src/resolvers/article-signature.resolver.ts +0 -29
- package/src/resolvers/article.resolver.ts +0 -41
- package/src/resolvers/backstage-article.resolver.ts +0 -161
- package/src/resolvers/backstage-category.resolver.ts +0 -40
- package/src/scalars/quadrats-element.scalar.ts +0 -56
- package/src/typings/cms-graphql-base-providers.ts +0 -3
- package/src/typings/cms-graphql-base-root-module-options.dto.ts +0 -11
- package/src/typings/dto/resolved-create-article-args.dto.ts +0 -33
- package/src/typings/dto/resolved-create-category-args.dto.ts +0 -19
- package/tsconfig.build.json +0 -8
- /package/{src/typings/custom-field-value.type.ts → typings/custom-field-value.type.d.ts} +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { ResolveField, ID, Root, Resolver } from '@nestjs/graphql';
|
|
2
|
+
import { MemberDataLoader } from '../data-loaders/members.dataloader.js';
|
|
3
|
+
import { UserDto } from '../dto/user.dto.js';
|
|
4
|
+
import { Authenticated } from '@rytass/member-base-nestjs-module';
|
|
5
|
+
import { ArticleStage, MULTIPLE_LANGUAGE_MODE, DEFAULT_LANGUAGE, ArticleVersionDataLoader, ArticleDataLoader as ArticleDataLoader$1, ArticleSignatureDataLoader } from '@rytass/cms-base-nestjs-module';
|
|
6
|
+
import { CategoryDto } from '../dto/category.dto.js';
|
|
7
|
+
import { ArticleDataLoader } from '../data-loaders/article.dataloader.js';
|
|
8
|
+
import { Language } from '../decorators/language.decorator.js';
|
|
9
|
+
import { Inject, BadRequestException } from '@nestjs/common';
|
|
10
|
+
import { BackstageArticleDto } from '../dto/backstage-article.dto.js';
|
|
11
|
+
import { ArticleMultiLanguageContentDto } from '../dto/article-multi-language-content.dto.js';
|
|
12
|
+
import { QuadratsContentScalar } from '../scalars/quadrats-element.scalar.js';
|
|
13
|
+
import { ArticleStageVersionDto } from '../dto/article-stage-version.dto.js';
|
|
14
|
+
import { ArticleSignatureDto } from '../dto/article-signature.dto.js';
|
|
15
|
+
|
|
16
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
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;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
}
|
|
22
|
+
function _ts_metadata(k, v) {
|
|
23
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
+
}
|
|
25
|
+
function _ts_param(paramIndex, decorator) {
|
|
26
|
+
return function(target, key) {
|
|
27
|
+
decorator(target, key, paramIndex);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
class BackstageArticleResolver {
|
|
31
|
+
memberDataloader;
|
|
32
|
+
articleDataloader;
|
|
33
|
+
multiLanguage;
|
|
34
|
+
articleVersionDataLoader;
|
|
35
|
+
moduleArticleDataLoader;
|
|
36
|
+
versionSignaturesLoader;
|
|
37
|
+
constructor(memberDataloader, articleDataloader, multiLanguage, articleVersionDataLoader, moduleArticleDataLoader, versionSignaturesLoader){
|
|
38
|
+
this.memberDataloader = memberDataloader;
|
|
39
|
+
this.articleDataloader = articleDataloader;
|
|
40
|
+
this.multiLanguage = multiLanguage;
|
|
41
|
+
this.articleVersionDataLoader = articleVersionDataLoader;
|
|
42
|
+
this.moduleArticleDataLoader = moduleArticleDataLoader;
|
|
43
|
+
this.versionSignaturesLoader = versionSignaturesLoader;
|
|
44
|
+
}
|
|
45
|
+
id(article) {
|
|
46
|
+
return `${article.id}:${article.version}`;
|
|
47
|
+
}
|
|
48
|
+
articleId(article) {
|
|
49
|
+
return article.id;
|
|
50
|
+
}
|
|
51
|
+
submittedBy(article) {
|
|
52
|
+
return article.submittedBy ? this.memberDataloader.loader.load(article.submittedBy) : null;
|
|
53
|
+
}
|
|
54
|
+
lastEditor(article) {
|
|
55
|
+
return article.updatedBy ? this.memberDataloader.loader.load(article.updatedBy) : null;
|
|
56
|
+
}
|
|
57
|
+
releasedBy(article) {
|
|
58
|
+
return article.releasedBy ? this.memberDataloader.loader.load(article.releasedBy) : null;
|
|
59
|
+
}
|
|
60
|
+
categories(article, language = DEFAULT_LANGUAGE) {
|
|
61
|
+
return this.articleDataloader.categoriesLoaderNoCache.load({
|
|
62
|
+
articleId: article.id,
|
|
63
|
+
language: this.multiLanguage ? language : DEFAULT_LANGUAGE
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
title(article) {
|
|
67
|
+
if ('title' in article && !this.multiLanguage) {
|
|
68
|
+
return article.title;
|
|
69
|
+
}
|
|
70
|
+
throw new BadRequestException('Title field is not available in multi-language mode.');
|
|
71
|
+
}
|
|
72
|
+
description(article) {
|
|
73
|
+
if ('description' in article && !this.multiLanguage) {
|
|
74
|
+
return article.description ?? null;
|
|
75
|
+
}
|
|
76
|
+
throw new BadRequestException('Description field is not available in multi-language mode.');
|
|
77
|
+
}
|
|
78
|
+
content(article) {
|
|
79
|
+
if ('content' in article && !this.multiLanguage) {
|
|
80
|
+
return article.content;
|
|
81
|
+
}
|
|
82
|
+
throw new BadRequestException('Content field is not available in multi-language mode.');
|
|
83
|
+
}
|
|
84
|
+
multiLanguageContents(article) {
|
|
85
|
+
if ('multiLanguageContents' in article) {
|
|
86
|
+
return article.multiLanguageContents;
|
|
87
|
+
}
|
|
88
|
+
return [
|
|
89
|
+
{
|
|
90
|
+
language: DEFAULT_LANGUAGE,
|
|
91
|
+
title: article.title,
|
|
92
|
+
description: article.description,
|
|
93
|
+
content: article.content
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
}
|
|
97
|
+
versions(article) {
|
|
98
|
+
return this.articleVersionDataLoader.versionsLoader.load(article.id);
|
|
99
|
+
}
|
|
100
|
+
stage(article) {
|
|
101
|
+
return this.moduleArticleDataLoader.stageLoader.load({
|
|
102
|
+
id: article.id,
|
|
103
|
+
version: article.version
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
signatures(article) {
|
|
107
|
+
return this.versionSignaturesLoader.versionSignaturesLoader.load({
|
|
108
|
+
id: article.id,
|
|
109
|
+
version: article.version
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async stageVersions(article) {
|
|
113
|
+
const versions = await this.articleVersionDataLoader.stageVersionsLoader.load(article.id);
|
|
114
|
+
return {
|
|
115
|
+
id: article.id,
|
|
116
|
+
draft: versions[ArticleStage.DRAFT] ?? null,
|
|
117
|
+
reviewing: versions[ArticleStage.REVIEWING] ?? null,
|
|
118
|
+
verified: versions[ArticleStage.VERIFIED] ?? null,
|
|
119
|
+
scheduled: versions[ArticleStage.SCHEDULED] ?? null,
|
|
120
|
+
released: versions[ArticleStage.RELEASED] ?? null
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
_ts_decorate([
|
|
125
|
+
ResolveField(()=>ID),
|
|
126
|
+
Authenticated(),
|
|
127
|
+
_ts_param(0, Root()),
|
|
128
|
+
_ts_metadata("design:type", Function),
|
|
129
|
+
_ts_metadata("design:paramtypes", [
|
|
130
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
131
|
+
]),
|
|
132
|
+
_ts_metadata("design:returntype", String)
|
|
133
|
+
], BackstageArticleResolver.prototype, "id", null);
|
|
134
|
+
_ts_decorate([
|
|
135
|
+
ResolveField(()=>String),
|
|
136
|
+
Authenticated(),
|
|
137
|
+
_ts_param(0, Root()),
|
|
138
|
+
_ts_metadata("design:type", Function),
|
|
139
|
+
_ts_metadata("design:paramtypes", [
|
|
140
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
141
|
+
]),
|
|
142
|
+
_ts_metadata("design:returntype", String)
|
|
143
|
+
], BackstageArticleResolver.prototype, "articleId", null);
|
|
144
|
+
_ts_decorate([
|
|
145
|
+
ResolveField(()=>UserDto, {
|
|
146
|
+
nullable: true
|
|
147
|
+
}),
|
|
148
|
+
Authenticated(),
|
|
149
|
+
_ts_param(0, Root()),
|
|
150
|
+
_ts_metadata("design:type", Function),
|
|
151
|
+
_ts_metadata("design:paramtypes", [
|
|
152
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
153
|
+
]),
|
|
154
|
+
_ts_metadata("design:returntype", Object)
|
|
155
|
+
], BackstageArticleResolver.prototype, "submittedBy", null);
|
|
156
|
+
_ts_decorate([
|
|
157
|
+
ResolveField(()=>UserDto, {
|
|
158
|
+
nullable: true
|
|
159
|
+
}),
|
|
160
|
+
Authenticated(),
|
|
161
|
+
_ts_param(0, Root()),
|
|
162
|
+
_ts_metadata("design:type", Function),
|
|
163
|
+
_ts_metadata("design:paramtypes", [
|
|
164
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
165
|
+
]),
|
|
166
|
+
_ts_metadata("design:returntype", Object)
|
|
167
|
+
], BackstageArticleResolver.prototype, "lastEditor", null);
|
|
168
|
+
_ts_decorate([
|
|
169
|
+
ResolveField(()=>UserDto, {
|
|
170
|
+
nullable: true
|
|
171
|
+
}),
|
|
172
|
+
Authenticated(),
|
|
173
|
+
_ts_param(0, Root()),
|
|
174
|
+
_ts_metadata("design:type", Function),
|
|
175
|
+
_ts_metadata("design:paramtypes", [
|
|
176
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
177
|
+
]),
|
|
178
|
+
_ts_metadata("design:returntype", Object)
|
|
179
|
+
], BackstageArticleResolver.prototype, "releasedBy", null);
|
|
180
|
+
_ts_decorate([
|
|
181
|
+
ResolveField(()=>[
|
|
182
|
+
CategoryDto
|
|
183
|
+
]),
|
|
184
|
+
Authenticated(),
|
|
185
|
+
_ts_param(0, Root()),
|
|
186
|
+
_ts_param(1, Language()),
|
|
187
|
+
_ts_metadata("design:type", Function),
|
|
188
|
+
_ts_metadata("design:paramtypes", [
|
|
189
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto,
|
|
190
|
+
String
|
|
191
|
+
]),
|
|
192
|
+
_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
193
|
+
], BackstageArticleResolver.prototype, "categories", null);
|
|
194
|
+
_ts_decorate([
|
|
195
|
+
ResolveField(()=>String),
|
|
196
|
+
Authenticated(),
|
|
197
|
+
_ts_param(0, Root()),
|
|
198
|
+
_ts_metadata("design:type", Function),
|
|
199
|
+
_ts_metadata("design:paramtypes", [
|
|
200
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
201
|
+
]),
|
|
202
|
+
_ts_metadata("design:returntype", String)
|
|
203
|
+
], BackstageArticleResolver.prototype, "title", null);
|
|
204
|
+
_ts_decorate([
|
|
205
|
+
ResolveField(()=>String, {
|
|
206
|
+
nullable: true
|
|
207
|
+
}),
|
|
208
|
+
Authenticated(),
|
|
209
|
+
_ts_param(0, Root()),
|
|
210
|
+
_ts_metadata("design:type", Function),
|
|
211
|
+
_ts_metadata("design:paramtypes", [
|
|
212
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
213
|
+
]),
|
|
214
|
+
_ts_metadata("design:returntype", Object)
|
|
215
|
+
], BackstageArticleResolver.prototype, "description", null);
|
|
216
|
+
_ts_decorate([
|
|
217
|
+
ResolveField(()=>QuadratsContentScalar),
|
|
218
|
+
Authenticated(),
|
|
219
|
+
_ts_param(0, Root()),
|
|
220
|
+
_ts_metadata("design:type", Function),
|
|
221
|
+
_ts_metadata("design:paramtypes", [
|
|
222
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
223
|
+
]),
|
|
224
|
+
_ts_metadata("design:returntype", Array)
|
|
225
|
+
], BackstageArticleResolver.prototype, "content", null);
|
|
226
|
+
_ts_decorate([
|
|
227
|
+
ResolveField(()=>[
|
|
228
|
+
ArticleMultiLanguageContentDto
|
|
229
|
+
]),
|
|
230
|
+
Authenticated(),
|
|
231
|
+
_ts_param(0, Root()),
|
|
232
|
+
_ts_metadata("design:type", Function),
|
|
233
|
+
_ts_metadata("design:paramtypes", [
|
|
234
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
235
|
+
]),
|
|
236
|
+
_ts_metadata("design:returntype", Array)
|
|
237
|
+
], BackstageArticleResolver.prototype, "multiLanguageContents", null);
|
|
238
|
+
_ts_decorate([
|
|
239
|
+
ResolveField(()=>[
|
|
240
|
+
BackstageArticleDto
|
|
241
|
+
]),
|
|
242
|
+
Authenticated(),
|
|
243
|
+
_ts_param(0, Root()),
|
|
244
|
+
_ts_metadata("design:type", Function),
|
|
245
|
+
_ts_metadata("design:paramtypes", [
|
|
246
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
247
|
+
]),
|
|
248
|
+
_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
249
|
+
], BackstageArticleResolver.prototype, "versions", null);
|
|
250
|
+
_ts_decorate([
|
|
251
|
+
ResolveField(()=>ArticleStage),
|
|
252
|
+
Authenticated(),
|
|
253
|
+
_ts_param(0, Root()),
|
|
254
|
+
_ts_metadata("design:type", Function),
|
|
255
|
+
_ts_metadata("design:paramtypes", [
|
|
256
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
257
|
+
]),
|
|
258
|
+
_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
259
|
+
], BackstageArticleResolver.prototype, "stage", null);
|
|
260
|
+
_ts_decorate([
|
|
261
|
+
ResolveField(()=>[
|
|
262
|
+
ArticleSignatureDto
|
|
263
|
+
]),
|
|
264
|
+
Authenticated(),
|
|
265
|
+
_ts_param(0, Root()),
|
|
266
|
+
_ts_metadata("design:type", Function),
|
|
267
|
+
_ts_metadata("design:paramtypes", [
|
|
268
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
269
|
+
]),
|
|
270
|
+
_ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
271
|
+
], BackstageArticleResolver.prototype, "signatures", null);
|
|
272
|
+
_ts_decorate([
|
|
273
|
+
ResolveField(()=>ArticleStageVersionDto),
|
|
274
|
+
Authenticated(),
|
|
275
|
+
_ts_param(0, Root()),
|
|
276
|
+
_ts_metadata("design:type", Function),
|
|
277
|
+
_ts_metadata("design:paramtypes", [
|
|
278
|
+
typeof ArticleBaseDto === "undefined" ? Object : ArticleBaseDto
|
|
279
|
+
]),
|
|
280
|
+
_ts_metadata("design:returntype", Promise)
|
|
281
|
+
], BackstageArticleResolver.prototype, "stageVersions", null);
|
|
282
|
+
BackstageArticleResolver = _ts_decorate([
|
|
283
|
+
Resolver(()=>BackstageArticleDto),
|
|
284
|
+
_ts_param(2, Inject(MULTIPLE_LANGUAGE_MODE)),
|
|
285
|
+
_ts_metadata("design:type", Function),
|
|
286
|
+
_ts_metadata("design:paramtypes", [
|
|
287
|
+
typeof MemberDataLoader === "undefined" ? Object : MemberDataLoader,
|
|
288
|
+
typeof ArticleDataLoader === "undefined" ? Object : ArticleDataLoader,
|
|
289
|
+
Boolean,
|
|
290
|
+
typeof ArticleVersionDataLoader === "undefined" ? Object : ArticleVersionDataLoader,
|
|
291
|
+
typeof ArticleDataLoader$1 === "undefined" ? Object : ArticleDataLoader$1,
|
|
292
|
+
typeof ArticleSignatureDataLoader === "undefined" ? Object : ArticleSignatureDataLoader
|
|
293
|
+
])
|
|
294
|
+
], BackstageArticleResolver);
|
|
295
|
+
|
|
296
|
+
export { BackstageArticleResolver };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CategoryBaseDto } from '@rytass/cms-base-nestjs-module';
|
|
2
|
+
import { CategoryMultiLanguageNameDto } from '../dto/category-multi-language-name.dto';
|
|
3
|
+
export declare class BackstageCategoryResolver {
|
|
4
|
+
private readonly multiLanguage;
|
|
5
|
+
constructor(multiLanguage: boolean);
|
|
6
|
+
name(category: CategoryBaseDto): string;
|
|
7
|
+
multiLanguageNames(category: CategoryBaseDto): CategoryMultiLanguageNameDto[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ResolveField, Root, Resolver } from '@nestjs/graphql';
|
|
2
|
+
import { Authenticated } from '@rytass/member-base-nestjs-module';
|
|
3
|
+
import { MULTIPLE_LANGUAGE_MODE, DEFAULT_LANGUAGE } from '@rytass/cms-base-nestjs-module';
|
|
4
|
+
import { Inject, BadRequestException } from '@nestjs/common';
|
|
5
|
+
import { CategoryMultiLanguageNameDto } from '../dto/category-multi-language-name.dto.js';
|
|
6
|
+
import { BackstageCategoryDto } from '../dto/backstage-category.dto.js';
|
|
7
|
+
|
|
8
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
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;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
}
|
|
14
|
+
function _ts_metadata(k, v) {
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
16
|
+
}
|
|
17
|
+
function _ts_param(paramIndex, decorator) {
|
|
18
|
+
return function(target, key) {
|
|
19
|
+
decorator(target, key, paramIndex);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
class BackstageCategoryResolver {
|
|
23
|
+
multiLanguage;
|
|
24
|
+
constructor(multiLanguage){
|
|
25
|
+
this.multiLanguage = multiLanguage;
|
|
26
|
+
}
|
|
27
|
+
name(category) {
|
|
28
|
+
if ('name' in category && !this.multiLanguage) {
|
|
29
|
+
return category.name;
|
|
30
|
+
}
|
|
31
|
+
throw new BadRequestException('Name field is not available in multi-language mode.');
|
|
32
|
+
}
|
|
33
|
+
multiLanguageNames(category) {
|
|
34
|
+
if ('multiLanguageNames' in category) {
|
|
35
|
+
return category.multiLanguageNames;
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
language: DEFAULT_LANGUAGE,
|
|
40
|
+
name: category.name
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_ts_decorate([
|
|
46
|
+
ResolveField(()=>String),
|
|
47
|
+
Authenticated(),
|
|
48
|
+
_ts_param(0, Root()),
|
|
49
|
+
_ts_metadata("design:type", Function),
|
|
50
|
+
_ts_metadata("design:paramtypes", [
|
|
51
|
+
typeof CategoryBaseDto === "undefined" ? Object : CategoryBaseDto
|
|
52
|
+
]),
|
|
53
|
+
_ts_metadata("design:returntype", String)
|
|
54
|
+
], BackstageCategoryResolver.prototype, "name", null);
|
|
55
|
+
_ts_decorate([
|
|
56
|
+
ResolveField(()=>[
|
|
57
|
+
CategoryMultiLanguageNameDto
|
|
58
|
+
]),
|
|
59
|
+
Authenticated(),
|
|
60
|
+
_ts_param(0, Root()),
|
|
61
|
+
_ts_metadata("design:type", Function),
|
|
62
|
+
_ts_metadata("design:paramtypes", [
|
|
63
|
+
typeof CategoryBaseDto === "undefined" ? Object : CategoryBaseDto
|
|
64
|
+
]),
|
|
65
|
+
_ts_metadata("design:returntype", Array)
|
|
66
|
+
], BackstageCategoryResolver.prototype, "multiLanguageNames", null);
|
|
67
|
+
BackstageCategoryResolver = _ts_decorate([
|
|
68
|
+
Resolver(()=>BackstageCategoryDto),
|
|
69
|
+
_ts_param(0, Inject(MULTIPLE_LANGUAGE_MODE)),
|
|
70
|
+
_ts_metadata("design:type", Function),
|
|
71
|
+
_ts_metadata("design:paramtypes", [
|
|
72
|
+
Boolean
|
|
73
|
+
])
|
|
74
|
+
], BackstageCategoryResolver);
|
|
75
|
+
|
|
76
|
+
export { BackstageCategoryResolver };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Logger, InternalServerErrorException, BadRequestException } from '@nestjs/common';
|
|
2
|
+
import { GraphQLScalarType, Kind } from 'graphql';
|
|
3
|
+
|
|
4
|
+
const QuadratsContentScalar = new GraphQLScalarType({
|
|
5
|
+
name: 'QuadratsContent',
|
|
6
|
+
description: 'QuadratsContent custom scalar type (as JSON string)',
|
|
7
|
+
parseValue: (value)=>{
|
|
8
|
+
if (typeof value === 'string') {
|
|
9
|
+
let parsedValue;
|
|
10
|
+
try {
|
|
11
|
+
parsedValue = JSON.parse(value);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
Logger.error(`Error parsing QuadratsContent (parseValue): ${error}`);
|
|
14
|
+
throw new InternalServerErrorException('Invalid QuadratsElement value');
|
|
15
|
+
}
|
|
16
|
+
if (!Array.isArray(parsedValue)) {
|
|
17
|
+
throw new BadRequestException('Expected a JSON string for QuadratsContent');
|
|
18
|
+
}
|
|
19
|
+
return parsedValue;
|
|
20
|
+
}
|
|
21
|
+
throw new BadRequestException('Expected a JSON string for QuadratsContent');
|
|
22
|
+
},
|
|
23
|
+
serialize: (value)=>{
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
return JSON.stringify(value);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
Logger.error(`Error serializing QuadratsContent: ${error}`);
|
|
31
|
+
throw new InternalServerErrorException('Error serializing QuadratsElement');
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
parseLiteral: (ast)=>{
|
|
35
|
+
try {
|
|
36
|
+
if (ast.kind === Kind.STRING) {
|
|
37
|
+
return JSON.parse(ast.value);
|
|
38
|
+
}
|
|
39
|
+
} catch (error) {
|
|
40
|
+
Logger.error(`Error parsing QuadratsContent (parseLiteral): ${error}`);
|
|
41
|
+
throw new InternalServerErrorException('Invalid QuadratsElement value');
|
|
42
|
+
}
|
|
43
|
+
throw new Error('Expected string literal for QuadratsContent');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export { QuadratsContentScalar };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const CMS_BASE_GRAPHQL_MODULE_OPTIONS = Symbol('CMS_BASE_GRAPHQL_MODULE_OPTIONS');
|
|
2
|
+
const MAP_ARTICLE_CUSTOM_FIELDS_TO_ENTITY_COLUMNS = Symbol('MAP_ARTICLE_CUSTOM_FIELDS_TO_ENTITY_COLUMNS');
|
|
3
|
+
const MAP_CATEGORY_CUSTOM_FIELDS_TO_ENTITY_COLUMNS = Symbol('MAP_CATEGORY_CUSTOM_FIELDS_TO_ENTITY_COLUMNS');
|
|
4
|
+
|
|
5
|
+
export { CMS_BASE_GRAPHQL_MODULE_OPTIONS, MAP_ARTICLE_CUSTOM_FIELDS_TO_ENTITY_COLUMNS, MAP_CATEGORY_CUSTOM_FIELDS_TO_ENTITY_COLUMNS };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { InjectionToken, ModuleMetadata, OptionalFactoryDependency, Type } from '@nestjs/common';
|
|
2
2
|
import { CMSGraphqlBaseModuleOptionFactory } from './cms-graphql-base-root-module-option-factory';
|
|
3
3
|
import { CMSGraphqlBaseModuleOptionsDto } from './cms-graphql-base-root-module-options.dto';
|
|
4
|
-
|
|
5
4
|
export interface CMSGraphqlBaseModuleAsyncOptionsDto extends Pick<ModuleMetadata, 'imports'> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
useExisting?: Type<CMSGraphqlBaseModuleOptionFactory>;
|
|
5
|
+
useFactory?: (...args: any[]) => Promise<CMSGraphqlBaseModuleOptionsDto> | CMSGraphqlBaseModuleOptionsDto;
|
|
6
|
+
inject?: (InjectionToken | OptionalFactoryDependency)[];
|
|
7
|
+
useClass?: Type<CMSGraphqlBaseModuleOptionFactory>;
|
|
8
|
+
useExisting?: Type<CMSGraphqlBaseModuleOptionFactory>;
|
|
11
9
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CMSGraphqlBaseModuleOptionsDto } from './cms-graphql-base-root-module-options.dto';
|
|
2
|
-
|
|
3
2
|
export interface CMSGraphqlBaseModuleOptionFactory {
|
|
4
|
-
|
|
3
|
+
createCMSOptions(): Promise<CMSGraphqlBaseModuleOptionsDto> | CMSGraphqlBaseModuleOptionsDto;
|
|
5
4
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CMSBaseModuleOptionsDto } from '@rytass/cms-base-nestjs-module';
|
|
2
|
+
import { CustomFieldInput } from '../dto/custom-field.input';
|
|
3
|
+
export interface CMSGraphqlBaseModuleOptionsDto extends CMSBaseModuleOptionsDto {
|
|
4
|
+
mapArticleCustomFieldsToEntityColumns?: (customFields: CustomFieldInput[]) => Promise<Record<string, string | object>> | Record<string, string | object>;
|
|
5
|
+
mapCategoryCustomFieldsToEntityColumns?: (customFields: CustomFieldInput[]) => Promise<Record<string, string | object>> | Record<string, string | object>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { QuadratsElement } from '@quadrats/core';
|
|
2
|
+
import { CustomFieldValue } from '../custom-field-value.type';
|
|
3
|
+
type BaseResolvedCreateArticleArgsDto = {
|
|
4
|
+
categoryIds: string[];
|
|
5
|
+
tags: string[];
|
|
6
|
+
submitted?: boolean;
|
|
7
|
+
signatureLevel?: string | null;
|
|
8
|
+
releasedAt?: Date | null;
|
|
9
|
+
[key: string]: CustomFieldValue;
|
|
10
|
+
};
|
|
11
|
+
export type SingleLanguageResolvedCreateArticleArgsDto = BaseResolvedCreateArticleArgsDto & {
|
|
12
|
+
title: string;
|
|
13
|
+
content: QuadratsElement[];
|
|
14
|
+
description?: string;
|
|
15
|
+
};
|
|
16
|
+
export type MultiLanguageResolvedCreateArticleArgsDto = BaseResolvedCreateArticleArgsDto & {
|
|
17
|
+
multiLanguageContents: Record<string, {
|
|
18
|
+
title: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
content: QuadratsElement[];
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
export type ResolvedCreateArticleArgsDto = SingleLanguageResolvedCreateArticleArgsDto | MultiLanguageResolvedCreateArticleArgsDto;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CustomFieldValue } from '../custom-field-value.type';
|
|
2
|
+
type BaseResolvedCreateCategoryArgsDto = {
|
|
3
|
+
parentIds?: string[] | null;
|
|
4
|
+
[key: string]: CustomFieldValue;
|
|
5
|
+
};
|
|
6
|
+
export type SingleLanguageResolvedCreateCategoryArgsDto = BaseResolvedCreateCategoryArgsDto & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
export type MultiLanguageResolvedCreateCategoryArgsDto = BaseResolvedCreateCategoryArgsDto & {
|
|
10
|
+
multiLanguageNames: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
export type ResolvedCreateCategoryArgsDto = SingleLanguageResolvedCreateCategoryArgsDto | MultiLanguageResolvedCreateCategoryArgsDto;
|
|
13
|
+
export {};
|