@things-factory/pdf 7.0.28 → 7.0.36
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/client/bootstrap.js +6 -0
- package/client/pages/pdf-template/pdf-template-importer.ts +86 -0
- package/client/pages/pdf-template/pdf-template-list-page.ts +491 -0
- package/client/route.ts +7 -0
- package/client/tsconfig.json +13 -0
- package/dist-client/bootstrap.d.ts +1 -0
- package/dist-client/bootstrap.js +6 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/pages/pdf-template/pdf-template-importer.d.ts +23 -0
- package/dist-client/pages/pdf-template/pdf-template-importer.js +93 -0
- package/dist-client/pages/pdf-template/pdf-template-importer.js.map +1 -0
- package/dist-client/pages/pdf-template/pdf-template-list-page.d.ts +66 -0
- package/dist-client/pages/pdf-template/pdf-template-list-page.js +464 -0
- package/dist-client/pages/pdf-template/pdf-template-list-page.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +8 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-server/index.d.ts +1 -0
- package/dist-server/index.js +2 -0
- package/dist-server/index.js.map +1 -1
- package/dist-server/routers/pdf-private-router.d.ts +1 -0
- package/dist-server/routers/pdf-private-router.js +25 -0
- package/dist-server/routers/pdf-private-router.js.map +1 -0
- package/dist-server/routers/pdf-public-router.d.ts +1 -0
- package/dist-server/routers/{pdf-router.js → pdf-public-router.js} +6 -6
- package/dist-server/routers/pdf-public-router.js.map +1 -0
- package/dist-server/routes.js +13 -2
- package/dist-server/routes.js.map +1 -1
- package/dist-server/service/index.d.ts +6 -0
- package/dist-server/service/index.js +23 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/pdf-template/index.d.ts +6 -0
- package/dist-server/service/pdf-template/index.js +10 -0
- package/dist-server/service/pdf-template/index.js.map +1 -0
- package/dist-server/service/pdf-template/pdf-template-mutation.d.ts +10 -0
- package/dist-server/service/pdf-template/pdf-template-mutation.js +127 -0
- package/dist-server/service/pdf-template/pdf-template-mutation.js.map +1 -0
- package/dist-server/service/pdf-template/pdf-template-query.d.ts +11 -0
- package/dist-server/service/pdf-template/pdf-template-query.js +79 -0
- package/dist-server/service/pdf-template/pdf-template-query.js.map +1 -0
- package/dist-server/service/pdf-template/pdf-template-type.d.ts +32 -0
- package/dist-server/service/pdf-template/pdf-template-type.js +125 -0
- package/dist-server/service/pdf-template/pdf-template-type.js.map +1 -0
- package/dist-server/service/pdf-template/pdf-template.d.ts +28 -0
- package/dist-server/service/pdf-template/pdf-template.js +125 -0
- package/dist-server/service/pdf-template/pdf-template.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/pdf/pdf-template.md +160 -0
- package/package.json +14 -9
- package/server/index.ts +2 -0
- package/server/routers/pdf-private-router.ts +24 -0
- package/server/routers/{pdf-router.ts → pdf-public-router.ts} +4 -4
- package/server/routes.ts +14 -2
- package/server/service/index.ts +26 -0
- package/server/service/pdf-template/index.ts +7 -0
- package/server/service/pdf-template/pdf-template-mutation.ts +138 -0
- package/server/service/pdf-template/pdf-template-query.ts +51 -0
- package/server/service/pdf-template/pdf-template-type.ts +87 -0
- package/server/service/pdf-template/pdf-template.ts +108 -0
- package/server/tsconfig.json +10 -0
- package/things-factory.config.js +8 -1
- package/translations/en.json +11 -0
- package/translations/ja.json +9 -0
- package/translations/ko.json +11 -0
- package/translations/ms.json +9 -0
- package/translations/zh.json +9 -0
- package/dist-server/routers/pdf-router.d.ts +0 -1
- package/dist-server/routers/pdf-router.js.map +0 -1
- package/tsconfig.json +0 -9
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
}
|
package/things-factory.config.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"field.content_template": "content template",
|
|
3
|
+
"field.header_template": "header template",
|
|
4
|
+
"field.footer_template": "footer template",
|
|
5
|
+
"field.cover_template": "cover template",
|
|
6
|
+
"field.last_template": "last template",
|
|
7
|
+
"field.page_size": "page size",
|
|
8
|
+
"field.state": "state",
|
|
9
|
+
"field.watermark": "watermark",
|
|
10
|
+
"title.pdf-template list": "PDF template list"
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"field.content_template": "コンテンツテンプレート",
|
|
3
|
+
"field.header_template": "ヘッダーテンプレート",
|
|
4
|
+
"field.footer_template": "フッターテンプレート",
|
|
5
|
+
"field.cover_template": "カバーテンプレート",
|
|
6
|
+
"field.last_template": "最後のテンプレート",
|
|
7
|
+
"field.page_size": "ページサイズ",
|
|
8
|
+
"field.watermark": "ウォーターマーク"
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"field.content_template": "본문 템플릿",
|
|
3
|
+
"field.header_template": "머릿글 템플릿",
|
|
4
|
+
"field.footer_template": "바닥글 템플릿",
|
|
5
|
+
"field.cover_template": "표지 템플릿",
|
|
6
|
+
"field.last_template": "뒷표지 템플릿",
|
|
7
|
+
"field.page_size": "크기",
|
|
8
|
+
"field.state": "상태",
|
|
9
|
+
"field.watermark": "워터마크",
|
|
10
|
+
"title.pdf-template list": "PDF 템플릿 리스트"
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"field.content_template": "templat kandungan",
|
|
3
|
+
"field.header_template": "templat pengepala",
|
|
4
|
+
"field.footer_template": "templat pengaki",
|
|
5
|
+
"field.cover_template": "templat muka depan",
|
|
6
|
+
"field.last_template": "templat terakhir",
|
|
7
|
+
"field.page_size": "saiz halaman",
|
|
8
|
+
"field.watermark": "tanda air"
|
|
9
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const pdf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,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,iBAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC9C,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7D,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAExC,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAA;IAErC,OAAO,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAChC,OAAO,CAAC,IAAI,GAAG,GAAG,CAAA;AACpB,CAAC,CAAC,CAAA;AAEF,iBAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC/C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAA;IAErC,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAA;IAErC,OAAO,CAAC,IAAI,GAAG,iBAAiB,CAAA;IAChC,OAAO,CAAC,IAAI,GAAG,GAAG,CAAA;AACpB,CAAC,CAAC,CAAA","sourcesContent":["import await_spawn from 'await-spawn'\nimport { promises as fs } from 'fs'\nimport Router from 'koa-router'\nimport path from 'path'\nimport { withTempDir } from '@things-factory/utils'\n\nexport const pdfRouter = new Router()\n\n/* to-png */\npdfRouter.get('/to-png', async (context, next) => {\n const { url } = context.query\n\n const images = await withTempDir(async tmpDir => {\n const curl = await_spawn('curl', ['-s', url])\n\n await await_spawn('gs', ['-q', '-sDEVICE=png16m', '-o', `${tmpDir}/%d.png`, '-r300', '-'], {\n stdio: [curl.child.stdout, 'pipe', 'pipe']\n })\n\n const files = await fs.readdir(tmpDir)\n return Promise.all(\n files\n .sort(new Intl.Collator(undefined, { numeric: true }).compare)\n .map(filename => fs.readFile(path.join(tmpDir, filename)))\n )\n })\n\n /* TODO make it possible to return multiple images */\n context.type = 'image/png'\n context.body = images[0]\n})\n\n/* merge-pdf */\nconst mergePDFfiles = async urls => {\n return await withTempDir(async tmpdir => {\n const sources = typeof urls == 'string' ? [urls] : urls\n const output = path.join(tmpdir, 'output.pdf')\n const inputs = sources.map((source, idx) => path.join(tmpdir, `${idx}.pdf`))\n\n try {\n await Promise.all(\n sources.map((source, idx) => await_spawn('curl', ['-sSL', source, '-o', path.join(tmpdir, `${idx}.pdf`)]))\n )\n\n await await_spawn('gs', [\n '-q',\n '-sDEVICE=pdfwrite',\n '-dAutoRotatePages=/None',\n '-dNOPAUSE',\n '-dBATCH',\n '-dSAFER',\n `-sOutputFile=${output}`,\n ...inputs\n ])\n\n return await fs.readFile(output)\n } catch (e) {\n console.error('mergePDFfiles', 'error', e)\n }\n })\n}\n\npdfRouter.get('/merge', async (context, next) => {\n const searchParams = new URLSearchParams(context.querystring)\n const urls = searchParams.getAll('urls')\n\n const pdf = await mergePDFfiles(urls)\n\n context.type = 'application/pdf'\n context.body = pdf\n})\n\npdfRouter.post('/merge', async (context, next) => {\n const { urls } = context.request.body\n\n const pdf = await mergePDFfiles(urls)\n\n context.type = 'application/pdf'\n context.body = pdf\n})\n"]}
|