@rytass/cms-base-nestjs-graphql-module 0.1.25 → 0.1.26
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/CHANGELOG.md +306 -0
- package/__tests__/enums.spec.ts +76 -0
- package/__tests__/language-decorator.spec.ts +17 -0
- package/__tests__/quadrats-element-scalar.spec.ts +123 -0
- package/llms.txt +361 -0
- package/package.json +10 -6
- package/project.json +23 -0
- package/src/cms-base-graphql.module.ts +101 -0
- package/src/constants/enum/base-action.enum.ts +17 -0
- package/src/constants/enum/base-resource.enum.ts +4 -0
- package/src/constants/option-providers.ts +35 -0
- package/src/data-loaders/article.dataloader.ts +84 -0
- package/src/data-loaders/members.dataloader.ts +36 -0
- package/src/decorators/language.decorator.ts +45 -0
- package/src/dto/article-collection.dto.ts +9 -0
- package/src/dto/article-multi-language-content.dto.ts +18 -0
- package/src/dto/article-signature-step.dto.ts +10 -0
- package/src/dto/article-signature.dto.ts +21 -0
- package/src/dto/article-stage-version.dto.ts +23 -0
- package/src/dto/article-version-content.input.ts +18 -0
- package/src/dto/article.dto.ts +16 -0
- package/src/dto/articles.args.ts +16 -0
- package/src/dto/backstage-article-collection.dto.ts +9 -0
- package/src/dto/backstage-article.args.ts +20 -0
- package/src/dto/backstage-article.dto.ts +14 -0
- package/src/dto/backstage-category.dto.ts +5 -0
- package/src/dto/base-article.dto.ts +19 -0
- package/src/dto/base-category.dto.ts +13 -0
- package/src/dto/categories.args.ts +27 -0
- package/src/dto/category-multi-language-name.dto.ts +10 -0
- package/src/dto/category-multi-language-name.input.ts +10 -0
- package/src/dto/category.dto.ts +8 -0
- package/src/dto/collection.dto.ts +13 -0
- package/src/dto/create-article.args.ts +27 -0
- package/src/dto/create-category.args.ts +15 -0
- package/src/dto/custom-field.input.ts +10 -0
- package/src/dto/update-article.args.ts +8 -0
- package/src/dto/update-category.args.ts +8 -0
- package/src/dto/user.dto.ts +10 -0
- package/{index.d.ts → src/index.ts} +2 -0
- package/src/mutations/article.mutations.ts +177 -0
- package/src/mutations/category.mutations.ts +78 -0
- package/src/queries/article.queries.ts +71 -0
- package/src/queries/category.queries.ts +53 -0
- package/src/resolvers/article-signature.resolver.ts +29 -0
- package/src/resolvers/article.resolver.ts +41 -0
- package/src/resolvers/backstage-article.resolver.ts +161 -0
- package/src/resolvers/backstage-category.resolver.ts +40 -0
- package/src/scalars/quadrats-element.scalar.ts +56 -0
- package/src/typings/cms-graphql-base-providers.ts +3 -0
- package/{typings/cms-graphql-base-root-module-async-options.dto.d.ts → src/typings/cms-graphql-base-root-module-async-options.dto.ts} +6 -4
- package/{typings/cms-graphql-base-root-module-option-factory.d.ts → src/typings/cms-graphql-base-root-module-option-factory.ts} +2 -1
- package/src/typings/cms-graphql-base-root-module-options.dto.ts +11 -0
- package/src/typings/dto/resolved-create-article-args.dto.ts +33 -0
- package/src/typings/dto/resolved-create-category-args.dto.ts +19 -0
- package/tsconfig.build.json +8 -0
- package/LICENSE +0 -21
- package/cms-base-graphql.module.d.ts +0 -9
- package/cms-base-graphql.module.js +0 -114
- package/constants/enum/base-action.enum.d.ts +0 -14
- package/constants/enum/base-action.enum.js +0 -17
- package/constants/enum/base-resource.enum.d.ts +0 -4
- package/constants/enum/base-resource.enum.js +0 -7
- package/constants/option-providers.d.ts +0 -2
- package/constants/option-providers.js +0 -20
- package/data-loaders/article.dataloader.d.ts +0 -17
- package/data-loaders/article.dataloader.js +0 -68
- package/data-loaders/members.dataloader.d.ts +0 -8
- package/data-loaders/members.dataloader.js +0 -56
- package/decorators/language.decorator.d.ts +0 -2
- package/decorators/language.decorator.js +0 -32
- package/dto/article-collection.dto.d.ts +0 -5
- package/dto/article-collection.dto.js +0 -27
- package/dto/article-multi-language-content.dto.d.ts +0 -7
- package/dto/article-multi-language-content.dto.js +0 -41
- package/dto/article-signature-step.dto.d.ts +0 -4
- package/dto/article-signature-step.dto.js +0 -28
- package/dto/article-signature.dto.d.ts +0 -7
- package/dto/article-signature.dto.js +0 -44
- package/dto/article-stage-version.dto.d.ts +0 -9
- package/dto/article-stage-version.dto.js +0 -59
- package/dto/article-version-content.input.d.ts +0 -7
- package/dto/article-version-content.input.js +0 -43
- package/dto/article.dto.d.ts +0 -7
- package/dto/article.dto.js +0 -37
- package/dto/articles.args.d.ts +0 -6
- package/dto/articles.args.js +0 -48
- package/dto/backstage-article-collection.dto.d.ts +0 -5
- package/dto/backstage-article-collection.dto.js +0 -27
- package/dto/backstage-article.args.d.ts +0 -6
- package/dto/backstage-article.args.js +0 -38
- package/dto/backstage-article.dto.d.ts +0 -6
- package/dto/backstage-article.dto.js +0 -38
- package/dto/backstage-category.dto.d.ts +0 -3
- package/dto/backstage-category.dto.js +0 -16
- package/dto/base-article.dto.d.ts +0 -7
- package/dto/base-article.dto.js +0 -47
- package/dto/base-category.dto.d.ts +0 -5
- package/dto/base-category.dto.js +0 -33
- package/dto/categories.args.d.ts +0 -8
- package/dto/categories.args.js +0 -62
- package/dto/category-multi-language-name.dto.d.ts +0 -4
- package/dto/category-multi-language-name.dto.js +0 -28
- package/dto/category-multi-language-name.input.d.ts +0 -4
- package/dto/category-multi-language-name.input.js +0 -30
- package/dto/category.dto.d.ts +0 -4
- package/dto/category.dto.js +0 -24
- package/dto/collection.dto.d.ts +0 -5
- package/dto/collection.dto.js +0 -33
- package/dto/create-article.args.d.ts +0 -11
- package/dto/create-article.args.js +0 -71
- package/dto/create-category.args.d.ts +0 -7
- package/dto/create-category.args.js +0 -45
- package/dto/custom-field.input.d.ts +0 -4
- package/dto/custom-field.input.js +0 -28
- package/dto/update-article.args.d.ts +0 -4
- package/dto/update-article.args.js +0 -24
- package/dto/update-category.args.d.ts +0 -4
- package/dto/update-category.args.js +0 -24
- package/dto/user.dto.d.ts +0 -4
- package/dto/user.dto.js +0 -28
- package/index.cjs.js +0 -2334
- package/index.js +0 -8
- package/mutations/article.mutations.d.ts +0 -22
- package/mutations/article.mutations.js +0 -338
- package/mutations/category.mutations.d.ts +0 -15
- package/mutations/category.mutations.js +0 -134
- package/queries/article.queries.d.ts +0 -16
- package/queries/article.queries.js +0 -132
- package/queries/category.queries.d.ts +0 -13
- package/queries/category.queries.js +0 -124
- package/resolvers/article-signature.resolver.d.ts +0 -10
- package/resolvers/article-signature.resolver.js +0 -68
- package/resolvers/article.resolver.d.ts +0 -14
- package/resolvers/article.resolver.js +0 -95
- package/resolvers/backstage-article.resolver.d.ts +0 -33
- package/resolvers/backstage-article.resolver.js +0 -296
- package/resolvers/backstage-category.resolver.d.ts +0 -8
- package/resolvers/backstage-category.resolver.js +0 -76
- package/scalars/quadrats-element.scalar.d.ts +0 -3
- package/scalars/quadrats-element.scalar.js +0 -47
- package/typings/cms-graphql-base-providers.d.ts +0 -3
- package/typings/cms-graphql-base-providers.js +0 -5
- package/typings/cms-graphql-base-root-module-options.dto.d.ts +0 -6
- package/typings/dto/resolved-create-article-args.dto.d.ts +0 -24
- package/typings/dto/resolved-create-category-args.dto.d.ts +0 -13
- /package/{typings/custom-field-value.type.d.ts → src/typings/custom-field-value.type.ts} +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
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 };
|
|
@@ -1,47 +0,0 @@
|
|
|
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 };
|
|
@@ -1,5 +0,0 @@
|
|
|
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,6 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|
|
File without changes
|