@things-factory/pdf 8.0.37 → 9.0.0-9.0.0-beta.59.0
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-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/client/bootstrap.js +0 -6
- package/client/pages/pdf-release/pdf-release-importer.ts +0 -87
- package/client/pages/pdf-release/pdf-release-list-page.ts +0 -398
- package/client/pages/pdf-template/pdf-template-importer.ts +0 -87
- package/client/pages/pdf-template/pdf-template-list-page.ts +0 -491
- package/client/route.ts +0 -11
- package/client/tsconfig.json +0 -13
- package/server/controller/pdf-service.ts +0 -35
- package/server/index.ts +0 -3
- package/server/routers/pdf-private-router.ts +0 -85
- package/server/routers/pdf-public-router.ts +0 -80
- package/server/routers/proxy-router.ts +0 -9
- package/server/routes.ts +0 -25
- package/server/service/index.ts +0 -38
- package/server/service/pdf-generate/pdf-generate-resolver.ts +0 -81
- package/server/service/pdf-release/index.ts +0 -7
- package/server/service/pdf-release/pdf-release-mutation.ts +0 -138
- package/server/service/pdf-release/pdf-release-query.ts +0 -51
- package/server/service/pdf-release/pdf-release-type.ts +0 -55
- package/server/service/pdf-release/pdf-release.ts +0 -103
- package/server/service/pdf-template/index.ts +0 -7
- package/server/service/pdf-template/pdf-template-mutation.ts +0 -138
- package/server/service/pdf-template/pdf-template-query.ts +0 -51
- package/server/service/pdf-template/pdf-template-type.ts +0 -87
- package/server/service/pdf-template/pdf-template.ts +0 -108
- package/server/tsconfig.json +0 -10
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { In } from 'typeorm'
|
|
3
|
-
|
|
4
|
-
import { PDFTemplate } from './pdf-template'
|
|
5
|
-
import { NewPDFTemplate, PDFTemplatePatch } from './pdf-template-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(PDFTemplate)
|
|
8
|
-
export class PDFTemplateMutation {
|
|
9
|
-
@Directive('@transaction')
|
|
10
|
-
@Mutation(returns => PDFTemplate, { description: 'To create new PDFTemplate' })
|
|
11
|
-
async createPDFTemplate(
|
|
12
|
-
@Arg('pdfTemplate') pdfTemplate: NewPDFTemplate,
|
|
13
|
-
@Ctx() context: ResolverContext
|
|
14
|
-
): Promise<PDFTemplate> {
|
|
15
|
-
const { domain, user, tx } = context.state
|
|
16
|
-
|
|
17
|
-
const result = await tx.getRepository(PDFTemplate).save({
|
|
18
|
-
...pdfTemplate,
|
|
19
|
-
domain,
|
|
20
|
-
creator: user,
|
|
21
|
-
updater: user
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
return result
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@Directive('@transaction')
|
|
28
|
-
@Mutation(returns => PDFTemplate, { description: 'To modify PDFTemplate information' })
|
|
29
|
-
async updatePDFTemplate(
|
|
30
|
-
@Arg('id') id: string,
|
|
31
|
-
@Arg('patch') patch: PDFTemplatePatch,
|
|
32
|
-
@Ctx() context: ResolverContext
|
|
33
|
-
): Promise<PDFTemplate> {
|
|
34
|
-
const { domain, user, tx } = context.state
|
|
35
|
-
|
|
36
|
-
const repository = tx.getRepository(PDFTemplate)
|
|
37
|
-
const pdfTemplate = await repository.findOne({
|
|
38
|
-
where: { domain: { id: domain.id }, id }
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const result = await repository.save({
|
|
42
|
-
...pdfTemplate,
|
|
43
|
-
...patch,
|
|
44
|
-
updater: user
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
return result
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Directive('@transaction')
|
|
51
|
-
@Mutation(returns => [PDFTemplate], { description: "To modify multiple PDFTemplates' information" })
|
|
52
|
-
async updateMultiplePDFTemplate(
|
|
53
|
-
@Arg('patches', type => [PDFTemplatePatch]) patches: PDFTemplatePatch[],
|
|
54
|
-
@Ctx() context: ResolverContext
|
|
55
|
-
): Promise<PDFTemplate[]> {
|
|
56
|
-
const { domain, user, tx } = context.state
|
|
57
|
-
|
|
58
|
-
let results = []
|
|
59
|
-
const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
|
|
60
|
-
const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
|
|
61
|
-
const pdfTemplateRepo = tx.getRepository(PDFTemplate)
|
|
62
|
-
|
|
63
|
-
if (_createRecords.length > 0) {
|
|
64
|
-
for (let i = 0; i < _createRecords.length; i++) {
|
|
65
|
-
const newRecord = _createRecords[i]
|
|
66
|
-
|
|
67
|
-
const result = await pdfTemplateRepo.save({
|
|
68
|
-
...newRecord,
|
|
69
|
-
domain,
|
|
70
|
-
creator: user,
|
|
71
|
-
updater: user
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
results.push({ ...result, cuFlag: '+' })
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (_updateRecords.length > 0) {
|
|
79
|
-
for (let i = 0; i < _updateRecords.length; i++) {
|
|
80
|
-
const updateRecord = _updateRecords[i]
|
|
81
|
-
const pdfTemplate = await pdfTemplateRepo.findOneBy({ id: updateRecord.id })
|
|
82
|
-
|
|
83
|
-
const result = await pdfTemplateRepo.save({
|
|
84
|
-
...pdfTemplate,
|
|
85
|
-
...updateRecord,
|
|
86
|
-
updater: user
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
results.push({ ...result, cuFlag: 'M' })
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return results
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@Directive('@transaction')
|
|
97
|
-
@Mutation(returns => Boolean, { description: 'To delete PDFTemplate' })
|
|
98
|
-
async deletePDFTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {
|
|
99
|
-
const { domain, tx } = context.state
|
|
100
|
-
|
|
101
|
-
await tx.getRepository(PDFTemplate).delete({ domain: { id: domain.id }, id })
|
|
102
|
-
|
|
103
|
-
return true
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
@Directive('@transaction')
|
|
107
|
-
@Mutation(returns => Boolean, { description: 'To delete multiple PDFTemplates' })
|
|
108
|
-
async deletePDFTemplates(
|
|
109
|
-
@Arg('ids', type => [String]) ids: string[],
|
|
110
|
-
@Ctx() context: ResolverContext
|
|
111
|
-
): Promise<boolean> {
|
|
112
|
-
const { domain, tx } = context.state
|
|
113
|
-
|
|
114
|
-
await tx.getRepository(PDFTemplate).delete({
|
|
115
|
-
domain: { id: domain.id },
|
|
116
|
-
id: In(ids)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
return true
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
@Directive('@transaction')
|
|
123
|
-
@Mutation(returns => Boolean, { description: 'To import multiple PDFTemplates' })
|
|
124
|
-
async importPDFTemplates(
|
|
125
|
-
@Arg('pdfTemplates', type => [PDFTemplatePatch]) pdfTemplates: PDFTemplatePatch[],
|
|
126
|
-
@Ctx() context: ResolverContext
|
|
127
|
-
): Promise<boolean> {
|
|
128
|
-
const { domain, tx } = context.state
|
|
129
|
-
|
|
130
|
-
await Promise.all(
|
|
131
|
-
pdfTemplates.map(async (pdfTemplate: PDFTemplatePatch) => {
|
|
132
|
-
const createdPDFTemplate: PDFTemplate = await tx.getRepository(PDFTemplate).save({ domain, ...pdfTemplate })
|
|
133
|
-
})
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
return true
|
|
137
|
-
}
|
|
138
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
|
|
2
|
-
import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
|
|
3
|
-
import { User } from '@things-factory/auth-base'
|
|
4
|
-
import { PDFTemplate } from './pdf-template'
|
|
5
|
-
import { PDFTemplateList } from './pdf-template-type'
|
|
6
|
-
|
|
7
|
-
@Resolver(PDFTemplate)
|
|
8
|
-
export class PDFTemplateQuery {
|
|
9
|
-
@Query(returns => PDFTemplate!, { nullable: true, description: 'To fetch a PDFTemplate' })
|
|
10
|
-
async PDFTemplate(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<PDFTemplate> {
|
|
11
|
-
const { domain } = context.state
|
|
12
|
-
|
|
13
|
-
return await getRepository(PDFTemplate).findOne({
|
|
14
|
-
where: { domain: { id: domain.id }, id }
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@Query(returns => PDFTemplateList, { description: 'To fetch multiple PDFTemplates' })
|
|
19
|
-
async PDFTemplates(
|
|
20
|
-
@Args(type => ListParam) params: ListParam,
|
|
21
|
-
@Ctx() context: ResolverContext
|
|
22
|
-
): Promise<PDFTemplateList> {
|
|
23
|
-
const { domain } = context.state
|
|
24
|
-
|
|
25
|
-
const queryBuilder = getQueryBuilderFromListParams({
|
|
26
|
-
domain,
|
|
27
|
-
params,
|
|
28
|
-
repository: await getRepository(PDFTemplate),
|
|
29
|
-
searchables: ['name', 'description']
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
const [items, total] = await queryBuilder.getManyAndCount()
|
|
33
|
-
|
|
34
|
-
return { items, total }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@FieldResolver(type => Domain)
|
|
38
|
-
async domain(@Root() pdfTemplate: PDFTemplate): Promise<Domain> {
|
|
39
|
-
return pdfTemplate.domainId && (await getRepository(Domain).findOneBy({ id: pdfTemplate.domainId }))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
@FieldResolver(type => User)
|
|
43
|
-
async updater(@Root() pdfTemplate: PDFTemplate): Promise<User> {
|
|
44
|
-
return pdfTemplate.updaterId && (await getRepository(User).findOneBy({ id: pdfTemplate.updaterId }))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
@FieldResolver(type => User)
|
|
48
|
-
async creator(@Root() pdfTemplate: PDFTemplate): Promise<User> {
|
|
49
|
-
return pdfTemplate.creatorId && (await getRepository(User).findOneBy({ id: pdfTemplate.creatorId }))
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
|
|
2
|
-
|
|
3
|
-
import { PDFTemplate, PDFTemplateStatus } from './pdf-template'
|
|
4
|
-
|
|
5
|
-
@InputType()
|
|
6
|
-
export class NewPDFTemplate {
|
|
7
|
-
@Field()
|
|
8
|
-
name: string
|
|
9
|
-
|
|
10
|
-
@Field({ nullable: true })
|
|
11
|
-
description?: string
|
|
12
|
-
|
|
13
|
-
@Field(type => PDFTemplateStatus, { nullable: true })
|
|
14
|
-
state?: PDFTemplateStatus
|
|
15
|
-
|
|
16
|
-
@Field({ nullable: true })
|
|
17
|
-
active?: boolean
|
|
18
|
-
|
|
19
|
-
@Field({ nullable: true })
|
|
20
|
-
content_template?: string
|
|
21
|
-
|
|
22
|
-
@Field({ nullable: true })
|
|
23
|
-
header_template?: string
|
|
24
|
-
|
|
25
|
-
@Field({ nullable: true })
|
|
26
|
-
footer_template?: string
|
|
27
|
-
|
|
28
|
-
@Field({ nullable: true })
|
|
29
|
-
cover_template?: string
|
|
30
|
-
|
|
31
|
-
@Field({ nullable: true })
|
|
32
|
-
last_template?: string
|
|
33
|
-
|
|
34
|
-
@Field({ nullable: true, defaultValue: 'A4' })
|
|
35
|
-
page_size: string
|
|
36
|
-
|
|
37
|
-
@Field({ nullable: true })
|
|
38
|
-
watermark: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@InputType()
|
|
42
|
-
export class PDFTemplatePatch {
|
|
43
|
-
@Field(type => ID, { nullable: true })
|
|
44
|
-
id?: string
|
|
45
|
-
|
|
46
|
-
@Field({ nullable: true })
|
|
47
|
-
name?: string
|
|
48
|
-
|
|
49
|
-
@Field({ nullable: true })
|
|
50
|
-
description?: string
|
|
51
|
-
|
|
52
|
-
@Field(type => PDFTemplateStatus, { nullable: true })
|
|
53
|
-
state?: PDFTemplateStatus
|
|
54
|
-
|
|
55
|
-
@Field({ nullable: true })
|
|
56
|
-
active?: boolean
|
|
57
|
-
|
|
58
|
-
@Field({ nullable: true })
|
|
59
|
-
content_template?: string
|
|
60
|
-
|
|
61
|
-
@Field({ nullable: true })
|
|
62
|
-
header_template?: string
|
|
63
|
-
|
|
64
|
-
@Field({ nullable: true })
|
|
65
|
-
footer_template?: string
|
|
66
|
-
|
|
67
|
-
@Field({ nullable: true })
|
|
68
|
-
cover_template?: string
|
|
69
|
-
|
|
70
|
-
@Field({ nullable: true })
|
|
71
|
-
last_template?: string
|
|
72
|
-
|
|
73
|
-
@Field({ nullable: true, defaultValue: 'A4' })
|
|
74
|
-
page_size?: string
|
|
75
|
-
|
|
76
|
-
@Field({ nullable: true })
|
|
77
|
-
cuFlag?: string
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
@ObjectType()
|
|
81
|
-
export class PDFTemplateList {
|
|
82
|
-
@Field(type => [PDFTemplate])
|
|
83
|
-
items: PDFTemplate[]
|
|
84
|
-
|
|
85
|
-
@Field(type => Int)
|
|
86
|
-
total: number
|
|
87
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateDateColumn,
|
|
3
|
-
UpdateDateColumn,
|
|
4
|
-
Entity,
|
|
5
|
-
Index,
|
|
6
|
-
Column,
|
|
7
|
-
RelationId,
|
|
8
|
-
ManyToOne,
|
|
9
|
-
PrimaryGeneratedColumn
|
|
10
|
-
} from 'typeorm'
|
|
11
|
-
import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
|
|
12
|
-
|
|
13
|
-
import { Domain } from '@things-factory/shell'
|
|
14
|
-
import { User } from '@things-factory/auth-base'
|
|
15
|
-
|
|
16
|
-
export enum PDFTemplateStatus {
|
|
17
|
-
draft = 'draft',
|
|
18
|
-
released = 'released'
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
registerEnumType(PDFTemplateStatus, {
|
|
22
|
-
name: 'PDFTemplateStatus',
|
|
23
|
-
description: 'state enumeration of a PDF Template'
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
@Entity()
|
|
27
|
-
@Index('ix_pdf_template_0', (pdfTemplate: PDFTemplate) => [pdfTemplate.domain, pdfTemplate.name], {
|
|
28
|
-
unique: true
|
|
29
|
-
})
|
|
30
|
-
@ObjectType({ description: 'Entity for PDFTemplate' })
|
|
31
|
-
export class PDFTemplate {
|
|
32
|
-
@PrimaryGeneratedColumn('uuid')
|
|
33
|
-
@Field(type => ID)
|
|
34
|
-
readonly id: string
|
|
35
|
-
|
|
36
|
-
@ManyToOne(type => Domain)
|
|
37
|
-
@Field({ nullable: true })
|
|
38
|
-
domain?: Domain
|
|
39
|
-
|
|
40
|
-
@RelationId((pdfTemplate: PDFTemplate) => pdfTemplate.domain)
|
|
41
|
-
domainId?: string
|
|
42
|
-
|
|
43
|
-
@Column()
|
|
44
|
-
@Field({ nullable: true })
|
|
45
|
-
name?: string
|
|
46
|
-
|
|
47
|
-
@Column({ nullable: true })
|
|
48
|
-
@Field({ nullable: true })
|
|
49
|
-
description?: string
|
|
50
|
-
|
|
51
|
-
@Column({ nullable: true })
|
|
52
|
-
@Field({ nullable: true })
|
|
53
|
-
active?: boolean
|
|
54
|
-
|
|
55
|
-
@Column({ nullable: true })
|
|
56
|
-
@Field({ nullable: true })
|
|
57
|
-
state?: PDFTemplateStatus
|
|
58
|
-
|
|
59
|
-
@Column({ type: 'text', nullable: true })
|
|
60
|
-
@Field({ nullable: true })
|
|
61
|
-
content_template?: string
|
|
62
|
-
|
|
63
|
-
@Column({ type: 'text', nullable: true })
|
|
64
|
-
@Field({ nullable: true })
|
|
65
|
-
header_template?: string
|
|
66
|
-
|
|
67
|
-
@Column({ type: 'text', nullable: true })
|
|
68
|
-
@Field({ nullable: true })
|
|
69
|
-
footer_template?: string
|
|
70
|
-
|
|
71
|
-
@Column({ type: 'text', nullable: true })
|
|
72
|
-
@Field({ nullable: true })
|
|
73
|
-
cover_template?: string
|
|
74
|
-
|
|
75
|
-
@Column({ type: 'text', nullable: true })
|
|
76
|
-
@Field({ nullable: true })
|
|
77
|
-
last_template?: string
|
|
78
|
-
|
|
79
|
-
@Column({ default: 'A4' })
|
|
80
|
-
@Field({ nullable: true, defaultValue: 'A4' })
|
|
81
|
-
page_size?: string
|
|
82
|
-
|
|
83
|
-
@Column({ type: 'text', nullable: true })
|
|
84
|
-
@Field({ nullable: true })
|
|
85
|
-
watermark?: string
|
|
86
|
-
|
|
87
|
-
@CreateDateColumn()
|
|
88
|
-
@Field({ nullable: true })
|
|
89
|
-
createdAt?: Date
|
|
90
|
-
|
|
91
|
-
@UpdateDateColumn()
|
|
92
|
-
@Field({ nullable: true })
|
|
93
|
-
updatedAt?: Date
|
|
94
|
-
|
|
95
|
-
@ManyToOne(type => User, { nullable: true })
|
|
96
|
-
@Field(type => User, { nullable: true })
|
|
97
|
-
creator?: User
|
|
98
|
-
|
|
99
|
-
@RelationId((pdfTemplate: PDFTemplate) => pdfTemplate.creator)
|
|
100
|
-
creatorId?: string
|
|
101
|
-
|
|
102
|
-
@ManyToOne(type => User, { nullable: true })
|
|
103
|
-
@Field(type => User, { nullable: true })
|
|
104
|
-
updater?: User
|
|
105
|
-
|
|
106
|
-
@RelationId((pdfTemplate: PDFTemplate) => pdfTemplate.updater)
|
|
107
|
-
updaterId?: string
|
|
108
|
-
}
|