@rytass/cms-base-nestjs-graphql-module 0.1.24 → 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,114 +0,0 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
2
|
-
import { CMSBaseModule } from '@rytass/cms-base-nestjs-module';
|
|
3
|
-
import { ArticleMutations } from './mutations/article.mutations.js';
|
|
4
|
-
import { CategoryMutations } from './mutations/category.mutations.js';
|
|
5
|
-
import { ArticleQueries } from './queries/article.queries.js';
|
|
6
|
-
import { CategoryQueries } from './queries/category.queries.js';
|
|
7
|
-
import { MemberDataLoader } from './data-loaders/members.dataloader.js';
|
|
8
|
-
import { ArticleDataLoader } from './data-loaders/article.dataloader.js';
|
|
9
|
-
import { ArticleResolver } from './resolvers/article.resolver.js';
|
|
10
|
-
import { BackstageArticleResolver } from './resolvers/backstage-article.resolver.js';
|
|
11
|
-
import { ArticleSignatureResolver } from './resolvers/article-signature.resolver.js';
|
|
12
|
-
import { BackstageCategoryResolver } from './resolvers/backstage-category.resolver.js';
|
|
13
|
-
import { OptionProviders } from './constants/option-providers.js';
|
|
14
|
-
import { CMS_BASE_GRAPHQL_MODULE_OPTIONS } from './typings/cms-graphql-base-providers.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
|
-
class CMSBaseGraphQLModule {
|
|
23
|
-
static forRootAsync(options) {
|
|
24
|
-
return {
|
|
25
|
-
module: CMSBaseGraphQLModule,
|
|
26
|
-
imports: [
|
|
27
|
-
...options.imports || [],
|
|
28
|
-
CMSBaseModule.forRootAsync(options)
|
|
29
|
-
],
|
|
30
|
-
exports: [
|
|
31
|
-
CMSBaseModule
|
|
32
|
-
],
|
|
33
|
-
providers: [
|
|
34
|
-
...this.createAsyncProvider(options),
|
|
35
|
-
...OptionProviders,
|
|
36
|
-
MemberDataLoader,
|
|
37
|
-
ArticleDataLoader,
|
|
38
|
-
ArticleResolver,
|
|
39
|
-
BackstageArticleResolver,
|
|
40
|
-
ArticleSignatureResolver,
|
|
41
|
-
ArticleQueries,
|
|
42
|
-
ArticleMutations,
|
|
43
|
-
CategoryQueries,
|
|
44
|
-
CategoryMutations,
|
|
45
|
-
BackstageCategoryResolver
|
|
46
|
-
]
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
static forRoot(options) {
|
|
50
|
-
return {
|
|
51
|
-
module: CMSBaseGraphQLModule,
|
|
52
|
-
imports: [
|
|
53
|
-
CMSBaseModule.forRoot(options)
|
|
54
|
-
],
|
|
55
|
-
exports: [
|
|
56
|
-
CMSBaseModule
|
|
57
|
-
],
|
|
58
|
-
providers: [
|
|
59
|
-
{
|
|
60
|
-
provide: CMS_BASE_GRAPHQL_MODULE_OPTIONS,
|
|
61
|
-
useValue: options
|
|
62
|
-
},
|
|
63
|
-
...OptionProviders,
|
|
64
|
-
MemberDataLoader,
|
|
65
|
-
ArticleDataLoader,
|
|
66
|
-
ArticleResolver,
|
|
67
|
-
BackstageArticleResolver,
|
|
68
|
-
ArticleSignatureResolver,
|
|
69
|
-
ArticleQueries,
|
|
70
|
-
ArticleMutations,
|
|
71
|
-
CategoryQueries,
|
|
72
|
-
CategoryMutations,
|
|
73
|
-
BackstageCategoryResolver
|
|
74
|
-
]
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
static createAsyncProvider(options) {
|
|
78
|
-
if (options.useExisting || options.useFactory) {
|
|
79
|
-
return [
|
|
80
|
-
this.createAsyncOptionsProvider(options)
|
|
81
|
-
];
|
|
82
|
-
}
|
|
83
|
-
return [
|
|
84
|
-
this.createAsyncOptionsProvider(options),
|
|
85
|
-
...options.useClass ? [
|
|
86
|
-
{
|
|
87
|
-
provide: options.useClass,
|
|
88
|
-
useClass: options.useClass
|
|
89
|
-
}
|
|
90
|
-
] : []
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
static createAsyncOptionsProvider(options) {
|
|
94
|
-
if (options.useFactory) {
|
|
95
|
-
return {
|
|
96
|
-
provide: CMS_BASE_GRAPHQL_MODULE_OPTIONS,
|
|
97
|
-
useFactory: options.useFactory,
|
|
98
|
-
inject: options.inject || []
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
provide: CMS_BASE_GRAPHQL_MODULE_OPTIONS,
|
|
103
|
-
useFactory: async (optionsFactory)=>await optionsFactory.createCMSOptions(),
|
|
104
|
-
inject: [
|
|
105
|
-
options.useExisting || options.useClass
|
|
106
|
-
]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
CMSBaseGraphQLModule = _ts_decorate([
|
|
111
|
-
Module({})
|
|
112
|
-
], CMSBaseGraphQLModule);
|
|
113
|
-
|
|
114
|
-
export { CMSBaseGraphQLModule };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare enum BaseAction {
|
|
2
|
-
LIST = "LIST",
|
|
3
|
-
READ = "READ",
|
|
4
|
-
CREATE = "CREATE",
|
|
5
|
-
UPDATE = "UPDATE",
|
|
6
|
-
DELETE = "DELETE",
|
|
7
|
-
DELETE_VERSION = "DELETE_VERSION",
|
|
8
|
-
SUBMIT = "SUBMIT",
|
|
9
|
-
PUT_BACK = "PUT_BACK",
|
|
10
|
-
APPROVE = "APPROVE",
|
|
11
|
-
REJECT = "REJECT",
|
|
12
|
-
RELEASE = "RELEASE",
|
|
13
|
-
WITHDRAW = "WITHDRAW"
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
var BaseAction = /*#__PURE__*/ function(BaseAction) {
|
|
2
|
-
BaseAction["LIST"] = "LIST";
|
|
3
|
-
BaseAction["READ"] = "READ";
|
|
4
|
-
BaseAction["CREATE"] = "CREATE";
|
|
5
|
-
BaseAction["UPDATE"] = "UPDATE";
|
|
6
|
-
BaseAction["DELETE"] = "DELETE";
|
|
7
|
-
BaseAction["DELETE_VERSION"] = "DELETE_VERSION";
|
|
8
|
-
BaseAction["SUBMIT"] = "SUBMIT";
|
|
9
|
-
BaseAction["PUT_BACK"] = "PUT_BACK";
|
|
10
|
-
BaseAction["APPROVE"] = "APPROVE";
|
|
11
|
-
BaseAction["REJECT"] = "REJECT";
|
|
12
|
-
BaseAction["RELEASE"] = "RELEASE";
|
|
13
|
-
BaseAction["WITHDRAW"] = "WITHDRAW";
|
|
14
|
-
return BaseAction;
|
|
15
|
-
}({});
|
|
16
|
-
|
|
17
|
-
export { BaseAction };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CMS_BASE_GRAPHQL_MODULE_OPTIONS, MAP_ARTICLE_CUSTOM_FIELDS_TO_ENTITY_COLUMNS, MAP_CATEGORY_CUSTOM_FIELDS_TO_ENTITY_COLUMNS } from '../typings/cms-graphql-base-providers.js';
|
|
2
|
-
|
|
3
|
-
const OptionProviders = [
|
|
4
|
-
{
|
|
5
|
-
provide: MAP_ARTICLE_CUSTOM_FIELDS_TO_ENTITY_COLUMNS,
|
|
6
|
-
useFactory: async (options)=>options?.mapArticleCustomFieldsToEntityColumns ? options.mapArticleCustomFieldsToEntityColumns : ()=>({}),
|
|
7
|
-
inject: [
|
|
8
|
-
CMS_BASE_GRAPHQL_MODULE_OPTIONS
|
|
9
|
-
]
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
provide: MAP_CATEGORY_CUSTOM_FIELDS_TO_ENTITY_COLUMNS,
|
|
13
|
-
useFactory: async (options)=>options?.mapCategoryCustomFieldsToEntityColumns ? options.mapCategoryCustomFieldsToEntityColumns : ()=>({}),
|
|
14
|
-
inject: [
|
|
15
|
-
CMS_BASE_GRAPHQL_MODULE_OPTIONS
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export { OptionProviders };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import DataLoader from 'dataloader';
|
|
2
|
-
import { Repository } from 'typeorm';
|
|
3
|
-
import { BaseArticleEntity } from '@rytass/cms-base-nestjs-module';
|
|
4
|
-
import { CategoryDto } from '../dto/category.dto';
|
|
5
|
-
export declare class ArticleDataLoader {
|
|
6
|
-
private readonly articleRepo;
|
|
7
|
-
constructor(articleRepo: Repository<BaseArticleEntity>);
|
|
8
|
-
private readonly batchLoadCategories;
|
|
9
|
-
readonly categoriesLoader: DataLoader<{
|
|
10
|
-
articleId: string;
|
|
11
|
-
language?: string;
|
|
12
|
-
}, CategoryDto[], string>;
|
|
13
|
-
readonly categoriesLoaderNoCache: DataLoader<{
|
|
14
|
-
articleId: string;
|
|
15
|
-
language?: string;
|
|
16
|
-
}, CategoryDto[], string>;
|
|
17
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Injectable, Inject } from '@nestjs/common';
|
|
2
|
-
import DataLoader from 'dataloader';
|
|
3
|
-
import { Repository } from 'typeorm';
|
|
4
|
-
import { LRUCache } from 'lru-cache';
|
|
5
|
-
import { RESOLVED_ARTICLE_REPO, DEFAULT_LANGUAGE } from '@rytass/cms-base-nestjs-module';
|
|
6
|
-
|
|
7
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
8
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
-
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;
|
|
11
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
-
}
|
|
13
|
-
function _ts_metadata(k, v) {
|
|
14
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
15
|
-
}
|
|
16
|
-
function _ts_param(paramIndex, decorator) {
|
|
17
|
-
return function(target, key) {
|
|
18
|
-
decorator(target, key, paramIndex);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
class ArticleDataLoader {
|
|
22
|
-
articleRepo;
|
|
23
|
-
constructor(articleRepo){
|
|
24
|
-
this.articleRepo = articleRepo;
|
|
25
|
-
}
|
|
26
|
-
batchLoadCategories = async (queryArgs)=>{
|
|
27
|
-
const qb = this.articleRepo.createQueryBuilder('articles');
|
|
28
|
-
qb.leftJoinAndSelect('articles.categories', 'categories');
|
|
29
|
-
qb.leftJoinAndSelect('categories.multiLanguageNames', 'multiLanguageNames');
|
|
30
|
-
qb.andWhere('articles.id IN (:...ids)', {
|
|
31
|
-
ids: queryArgs.map((arg)=>arg.articleId)
|
|
32
|
-
});
|
|
33
|
-
const articles = await qb.getMany();
|
|
34
|
-
const categoryMap = articles.reduce((vars, article)=>article.categories.reduce((cVars, category)=>category.multiLanguageNames.reduce((mVars, multiLanguageName)=>({
|
|
35
|
-
...mVars,
|
|
36
|
-
[`${article.id}:${multiLanguageName.language}`]: [
|
|
37
|
-
...mVars[`${article.id}:${multiLanguageName.language}`] || [],
|
|
38
|
-
{
|
|
39
|
-
...category,
|
|
40
|
-
...multiLanguageName
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}), cVars), vars), {});
|
|
44
|
-
return queryArgs.map((arg)=>categoryMap[`${arg.articleId}:${arg.language ?? DEFAULT_LANGUAGE}`] ?? []);
|
|
45
|
-
};
|
|
46
|
-
categoriesLoader = new DataLoader(this.batchLoadCategories, {
|
|
47
|
-
cache: true,
|
|
48
|
-
cacheMap: new LRUCache({
|
|
49
|
-
ttl: 1000 * 60,
|
|
50
|
-
ttlAutopurge: true,
|
|
51
|
-
max: 1000
|
|
52
|
-
}),
|
|
53
|
-
cacheKeyFn: (queryArgs)=>`${queryArgs.articleId}:${queryArgs.language ?? DEFAULT_LANGUAGE}`
|
|
54
|
-
});
|
|
55
|
-
categoriesLoaderNoCache = new DataLoader(this.batchLoadCategories, {
|
|
56
|
-
cache: false
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
ArticleDataLoader = _ts_decorate([
|
|
60
|
-
Injectable(),
|
|
61
|
-
_ts_param(0, Inject(RESOLVED_ARTICLE_REPO)),
|
|
62
|
-
_ts_metadata("design:type", Function),
|
|
63
|
-
_ts_metadata("design:paramtypes", [
|
|
64
|
-
typeof Repository === "undefined" ? Object : Repository
|
|
65
|
-
])
|
|
66
|
-
], ArticleDataLoader);
|
|
67
|
-
|
|
68
|
-
export { ArticleDataLoader };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseMemberEntity } from '@rytass/member-base-nestjs-module';
|
|
2
|
-
import DataLoader from 'dataloader';
|
|
3
|
-
import { Repository } from 'typeorm';
|
|
4
|
-
export declare class MemberDataLoader {
|
|
5
|
-
private readonly memberRepo;
|
|
6
|
-
constructor(memberRepo: Repository<BaseMemberEntity>);
|
|
7
|
-
readonly loader: DataLoader<string, BaseMemberEntity | null, string>;
|
|
8
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Injectable, Inject } from '@nestjs/common';
|
|
2
|
-
import { RESOLVED_MEMBER_REPO } from '@rytass/member-base-nestjs-module';
|
|
3
|
-
import DataLoader from 'dataloader';
|
|
4
|
-
import { LRUCache } from 'lru-cache';
|
|
5
|
-
import { Repository } from 'typeorm';
|
|
6
|
-
|
|
7
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
8
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10
|
-
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;
|
|
11
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
12
|
-
}
|
|
13
|
-
function _ts_metadata(k, v) {
|
|
14
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
15
|
-
}
|
|
16
|
-
function _ts_param(paramIndex, decorator) {
|
|
17
|
-
return function(target, key) {
|
|
18
|
-
decorator(target, key, paramIndex);
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
class MemberDataLoader {
|
|
22
|
-
memberRepo;
|
|
23
|
-
constructor(memberRepo){
|
|
24
|
-
this.memberRepo = memberRepo;
|
|
25
|
-
}
|
|
26
|
-
loader = new DataLoader(async (ids)=>{
|
|
27
|
-
const qb = this.memberRepo.createQueryBuilder('members');
|
|
28
|
-
qb.withDeleted();
|
|
29
|
-
qb.andWhere('members.id IN (:...ids)', {
|
|
30
|
-
ids
|
|
31
|
-
});
|
|
32
|
-
const users = await qb.getMany();
|
|
33
|
-
const userMap = new Map(users.map((user)=>[
|
|
34
|
-
user.id,
|
|
35
|
-
user
|
|
36
|
-
]));
|
|
37
|
-
return ids.map((id)=>userMap.get(id) ?? null);
|
|
38
|
-
}, {
|
|
39
|
-
cache: true,
|
|
40
|
-
cacheMap: new LRUCache({
|
|
41
|
-
ttl: 1000 * 60 * 10,
|
|
42
|
-
ttlAutopurge: true,
|
|
43
|
-
max: 1000
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
MemberDataLoader = _ts_decorate([
|
|
48
|
-
Injectable(),
|
|
49
|
-
_ts_param(0, Inject(RESOLVED_MEMBER_REPO)),
|
|
50
|
-
_ts_metadata("design:type", Function),
|
|
51
|
-
_ts_metadata("design:paramtypes", [
|
|
52
|
-
typeof Repository === "undefined" ? Object : Repository
|
|
53
|
-
])
|
|
54
|
-
], MemberDataLoader);
|
|
55
|
-
|
|
56
|
-
export { MemberDataLoader };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createParamDecorator } from '@nestjs/common';
|
|
2
|
-
import { DEFAULT_LANGUAGE } from '@rytass/cms-base-nestjs-module';
|
|
3
|
-
|
|
4
|
-
const LANGUAGE_HEADER_KEY = 'x-language';
|
|
5
|
-
const Language = createParamDecorator(async (_data, context)=>{
|
|
6
|
-
const contextType = context.getType();
|
|
7
|
-
switch(contextType){
|
|
8
|
-
case 'graphql':
|
|
9
|
-
{
|
|
10
|
-
const { GqlExecutionContext } = await import('@nestjs/graphql');
|
|
11
|
-
const ctx = GqlExecutionContext.create(context).getContext();
|
|
12
|
-
const headers = ctx.req.headers;
|
|
13
|
-
const requestLanguage = headers[LANGUAGE_HEADER_KEY];
|
|
14
|
-
if (typeof requestLanguage === 'string') return requestLanguage;
|
|
15
|
-
const acceptLanguage = headers['accept-language'] ?? '';
|
|
16
|
-
if (!acceptLanguage || typeof acceptLanguage !== 'string') return DEFAULT_LANGUAGE;
|
|
17
|
-
return acceptLanguage.split(',')[0].split(';')[0].trim();
|
|
18
|
-
}
|
|
19
|
-
case 'http':
|
|
20
|
-
default:
|
|
21
|
-
{
|
|
22
|
-
const headers = context.switchToHttp().getRequest().headers;
|
|
23
|
-
const requestLanguage = headers[LANGUAGE_HEADER_KEY];
|
|
24
|
-
if (typeof requestLanguage === 'string') return requestLanguage;
|
|
25
|
-
const acceptLanguage = headers['accept-language'] ?? '';
|
|
26
|
-
if (!acceptLanguage || typeof acceptLanguage !== 'string') return DEFAULT_LANGUAGE;
|
|
27
|
-
return acceptLanguage.split(',')[0].split(';')[0].trim();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export { LANGUAGE_HEADER_KEY, Language };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
|
-
import { Collection } from './collection.dto.js';
|
|
3
|
-
import { ArticleDto } from './article.dto.js';
|
|
4
|
-
|
|
5
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
6
|
-
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
7
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
8
|
-
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;
|
|
9
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10
|
-
}
|
|
11
|
-
function _ts_metadata(k, v) {
|
|
12
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
13
|
-
}
|
|
14
|
-
class ArticleCollectionDto extends Collection {
|
|
15
|
-
articles;
|
|
16
|
-
}
|
|
17
|
-
_ts_decorate([
|
|
18
|
-
Field(()=>[
|
|
19
|
-
ArticleDto
|
|
20
|
-
]),
|
|
21
|
-
_ts_metadata("design:type", Array)
|
|
22
|
-
], ArticleCollectionDto.prototype, "articles", void 0);
|
|
23
|
-
ArticleCollectionDto = _ts_decorate([
|
|
24
|
-
ObjectType('ArticleCollection')
|
|
25
|
-
], ArticleCollectionDto);
|
|
26
|
-
|
|
27
|
-
export { ArticleCollectionDto };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Field, ObjectType } from '@nestjs/graphql';
|
|
2
|
-
import { QuadratsContentScalar } from '../scalars/quadrats-element.scalar.js';
|
|
3
|
-
|
|
4
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
6
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
-
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;
|
|
8
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
-
}
|
|
10
|
-
function _ts_metadata(k, v) {
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
-
}
|
|
13
|
-
class ArticleMultiLanguageContentDto {
|
|
14
|
-
language;
|
|
15
|
-
title;
|
|
16
|
-
description;
|
|
17
|
-
content;
|
|
18
|
-
}
|
|
19
|
-
_ts_decorate([
|
|
20
|
-
Field(()=>String),
|
|
21
|
-
_ts_metadata("design:type", String)
|
|
22
|
-
], ArticleMultiLanguageContentDto.prototype, "language", void 0);
|
|
23
|
-
_ts_decorate([
|
|
24
|
-
Field(()=>String),
|
|
25
|
-
_ts_metadata("design:type", String)
|
|
26
|
-
], ArticleMultiLanguageContentDto.prototype, "title", void 0);
|
|
27
|
-
_ts_decorate([
|
|
28
|
-
Field(()=>String, {
|
|
29
|
-
nullable: true
|
|
30
|
-
}),
|
|
31
|
-
_ts_metadata("design:type", Object)
|
|
32
|
-
], ArticleMultiLanguageContentDto.prototype, "description", void 0);
|
|
33
|
-
_ts_decorate([
|
|
34
|
-
Field(()=>QuadratsContentScalar),
|
|
35
|
-
_ts_metadata("design:type", Array)
|
|
36
|
-
], ArticleMultiLanguageContentDto.prototype, "content", void 0);
|
|
37
|
-
ArticleMultiLanguageContentDto = _ts_decorate([
|
|
38
|
-
ObjectType('ArticleMultiLanguageContent')
|
|
39
|
-
], ArticleMultiLanguageContentDto);
|
|
40
|
-
|
|
41
|
-
export { ArticleMultiLanguageContentDto };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
|
2
|
-
|
|
3
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
4
|
-
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
5
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
-
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;
|
|
7
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
-
}
|
|
9
|
-
function _ts_metadata(k, v) {
|
|
10
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
11
|
-
}
|
|
12
|
-
class ArticleSignatureStepDto {
|
|
13
|
-
id;
|
|
14
|
-
name;
|
|
15
|
-
}
|
|
16
|
-
_ts_decorate([
|
|
17
|
-
Field(()=>ID),
|
|
18
|
-
_ts_metadata("design:type", String)
|
|
19
|
-
], ArticleSignatureStepDto.prototype, "id", void 0);
|
|
20
|
-
_ts_decorate([
|
|
21
|
-
Field(()=>String),
|
|
22
|
-
_ts_metadata("design:type", String)
|
|
23
|
-
], ArticleSignatureStepDto.prototype, "name", void 0);
|
|
24
|
-
ArticleSignatureStepDto = _ts_decorate([
|
|
25
|
-
ObjectType('ArticleSignatureStep')
|
|
26
|
-
], ArticleSignatureStepDto);
|
|
27
|
-
|
|
28
|
-
export { ArticleSignatureStepDto };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType, registerEnumType } from '@nestjs/graphql';
|
|
2
|
-
import { ArticleSignatureResult } from '@rytass/cms-base-nestjs-module';
|
|
3
|
-
|
|
4
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
6
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
-
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;
|
|
8
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
-
}
|
|
10
|
-
function _ts_metadata(k, v) {
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
-
}
|
|
13
|
-
class ArticleSignatureDto {
|
|
14
|
-
id;
|
|
15
|
-
signedAt;
|
|
16
|
-
result;
|
|
17
|
-
rejectReason;
|
|
18
|
-
}
|
|
19
|
-
_ts_decorate([
|
|
20
|
-
Field(()=>ID),
|
|
21
|
-
_ts_metadata("design:type", String)
|
|
22
|
-
], ArticleSignatureDto.prototype, "id", void 0);
|
|
23
|
-
_ts_decorate([
|
|
24
|
-
Field(()=>Date),
|
|
25
|
-
_ts_metadata("design:type", typeof Date === "undefined" ? Object : Date)
|
|
26
|
-
], ArticleSignatureDto.prototype, "signedAt", void 0);
|
|
27
|
-
_ts_decorate([
|
|
28
|
-
Field(()=>ArticleSignatureResult),
|
|
29
|
-
_ts_metadata("design:type", typeof ArticleSignatureResult === "undefined" ? Object : ArticleSignatureResult)
|
|
30
|
-
], ArticleSignatureDto.prototype, "result", void 0);
|
|
31
|
-
_ts_decorate([
|
|
32
|
-
Field(()=>String, {
|
|
33
|
-
nullable: true
|
|
34
|
-
}),
|
|
35
|
-
_ts_metadata("design:type", Object)
|
|
36
|
-
], ArticleSignatureDto.prototype, "rejectReason", void 0);
|
|
37
|
-
ArticleSignatureDto = _ts_decorate([
|
|
38
|
-
ObjectType('ArticleSignature')
|
|
39
|
-
], ArticleSignatureDto);
|
|
40
|
-
registerEnumType(ArticleSignatureResult, {
|
|
41
|
-
name: 'ArticleSignatureResult'
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
export { ArticleSignatureDto };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BackstageArticleDto } from './backstage-article.dto';
|
|
2
|
-
export declare class ArticleStageVersionDto {
|
|
3
|
-
id: string;
|
|
4
|
-
draft: BackstageArticleDto | null;
|
|
5
|
-
reviewing: BackstageArticleDto | null;
|
|
6
|
-
verified: BackstageArticleDto | null;
|
|
7
|
-
scheduled: BackstageArticleDto | null;
|
|
8
|
-
released: BackstageArticleDto | null;
|
|
9
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Field, ID, ObjectType } from '@nestjs/graphql';
|
|
2
|
-
import { BackstageArticleDto } from './backstage-article.dto.js';
|
|
3
|
-
|
|
4
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
5
|
-
var c = arguments.length, r = c < 3 ? target : desc, d;
|
|
6
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
-
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;
|
|
8
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
-
}
|
|
10
|
-
function _ts_metadata(k, v) {
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
-
}
|
|
13
|
-
class ArticleStageVersionDto {
|
|
14
|
-
id;
|
|
15
|
-
draft;
|
|
16
|
-
reviewing;
|
|
17
|
-
verified;
|
|
18
|
-
scheduled;
|
|
19
|
-
released;
|
|
20
|
-
}
|
|
21
|
-
_ts_decorate([
|
|
22
|
-
Field(()=>ID),
|
|
23
|
-
_ts_metadata("design:type", String)
|
|
24
|
-
], ArticleStageVersionDto.prototype, "id", void 0);
|
|
25
|
-
_ts_decorate([
|
|
26
|
-
Field(()=>BackstageArticleDto, {
|
|
27
|
-
nullable: true
|
|
28
|
-
}),
|
|
29
|
-
_ts_metadata("design:type", Object)
|
|
30
|
-
], ArticleStageVersionDto.prototype, "draft", void 0);
|
|
31
|
-
_ts_decorate([
|
|
32
|
-
Field(()=>BackstageArticleDto, {
|
|
33
|
-
nullable: true
|
|
34
|
-
}),
|
|
35
|
-
_ts_metadata("design:type", Object)
|
|
36
|
-
], ArticleStageVersionDto.prototype, "reviewing", void 0);
|
|
37
|
-
_ts_decorate([
|
|
38
|
-
Field(()=>BackstageArticleDto, {
|
|
39
|
-
nullable: true
|
|
40
|
-
}),
|
|
41
|
-
_ts_metadata("design:type", Object)
|
|
42
|
-
], ArticleStageVersionDto.prototype, "verified", void 0);
|
|
43
|
-
_ts_decorate([
|
|
44
|
-
Field(()=>BackstageArticleDto, {
|
|
45
|
-
nullable: true
|
|
46
|
-
}),
|
|
47
|
-
_ts_metadata("design:type", Object)
|
|
48
|
-
], ArticleStageVersionDto.prototype, "scheduled", void 0);
|
|
49
|
-
_ts_decorate([
|
|
50
|
-
Field(()=>BackstageArticleDto, {
|
|
51
|
-
nullable: true
|
|
52
|
-
}),
|
|
53
|
-
_ts_metadata("design:type", Object)
|
|
54
|
-
], ArticleStageVersionDto.prototype, "released", void 0);
|
|
55
|
-
ArticleStageVersionDto = _ts_decorate([
|
|
56
|
-
ObjectType('ArticleStageVersion')
|
|
57
|
-
], ArticleStageVersionDto);
|
|
58
|
-
|
|
59
|
-
export { ArticleStageVersionDto };
|