@ketrics/sdk-backend 0.2.0 → 0.4.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/pdf.d.ts ADDED
@@ -0,0 +1,268 @@
1
+ /**
2
+ * PDF SDK Types
3
+ *
4
+ * Type definitions for PDF file reading, creation, and modification in tenant applications.
5
+ */
6
+ /**
7
+ * Standard page sizes
8
+ */
9
+ export type PdfPageSize = 'A4' | 'Letter' | 'Legal' | 'Tabloid' | 'A3' | 'A5';
10
+ /**
11
+ * Standard PDF fonts
12
+ */
13
+ export type PdfStandardFont = 'Courier' | 'CourierBold' | 'CourierBoldOblique' | 'CourierOblique' | 'Helvetica' | 'HelveticaBold' | 'HelveticaBoldOblique' | 'HelveticaOblique' | 'TimesRoman' | 'TimesRomanBold' | 'TimesRomanBoldItalic' | 'TimesRomanItalic' | 'Symbol' | 'ZapfDingbats';
14
+ /**
15
+ * RGB color (values 0-1)
16
+ */
17
+ export interface PdfRgbColor {
18
+ r: number;
19
+ g: number;
20
+ b: number;
21
+ }
22
+ /**
23
+ * Options for drawing text
24
+ */
25
+ export interface PdfDrawTextOptions {
26
+ /** X coordinate */
27
+ x?: number;
28
+ /** Y coordinate */
29
+ y?: number;
30
+ /** Font size */
31
+ size?: number;
32
+ /** Font to use */
33
+ font?: PdfEmbeddedFont;
34
+ /** Text color */
35
+ color?: PdfRgbColor;
36
+ /** Rotation in degrees */
37
+ rotate?: number;
38
+ /** Opacity (0-1) */
39
+ opacity?: number;
40
+ /** Line height for multiline text */
41
+ lineHeight?: number;
42
+ /** Maximum width for text wrapping */
43
+ maxWidth?: number;
44
+ }
45
+ /**
46
+ * Options for drawing rectangles
47
+ */
48
+ export interface PdfDrawRectOptions {
49
+ /** X coordinate */
50
+ x: number;
51
+ /** Y coordinate */
52
+ y: number;
53
+ /** Width */
54
+ width: number;
55
+ /** Height */
56
+ height: number;
57
+ /** Fill color */
58
+ color?: PdfRgbColor;
59
+ /** Border color */
60
+ borderColor?: PdfRgbColor;
61
+ /** Border width */
62
+ borderWidth?: number;
63
+ /** Opacity (0-1) */
64
+ opacity?: number;
65
+ /** Rotation in degrees */
66
+ rotate?: number;
67
+ }
68
+ /**
69
+ * Options for drawing lines
70
+ */
71
+ export interface PdfDrawLineOptions {
72
+ /** Start point */
73
+ start: {
74
+ x: number;
75
+ y: number;
76
+ };
77
+ /** End point */
78
+ end: {
79
+ x: number;
80
+ y: number;
81
+ };
82
+ /** Line thickness */
83
+ thickness?: number;
84
+ /** Line color */
85
+ color?: PdfRgbColor;
86
+ /** Opacity (0-1) */
87
+ opacity?: number;
88
+ }
89
+ /**
90
+ * Options for drawing circles
91
+ */
92
+ export interface PdfDrawCircleOptions {
93
+ /** Center X coordinate */
94
+ x: number;
95
+ /** Center Y coordinate */
96
+ y: number;
97
+ /** Radius */
98
+ radius: number;
99
+ /** Fill color */
100
+ color?: PdfRgbColor;
101
+ /** Border color */
102
+ borderColor?: PdfRgbColor;
103
+ /** Border width */
104
+ borderWidth?: number;
105
+ /** Opacity (0-1) */
106
+ opacity?: number;
107
+ }
108
+ /**
109
+ * Options for drawing images
110
+ */
111
+ export interface PdfDrawImageOptions {
112
+ /** X coordinate */
113
+ x?: number;
114
+ /** Y coordinate */
115
+ y?: number;
116
+ /** Width (scales image) */
117
+ width?: number;
118
+ /** Height (scales image) */
119
+ height?: number;
120
+ /** Rotation in degrees */
121
+ rotate?: number;
122
+ /** Opacity (0-1) */
123
+ opacity?: number;
124
+ }
125
+ /**
126
+ * Embedded image in PDF
127
+ */
128
+ export interface PdfEmbeddedImage {
129
+ /** Original image width */
130
+ readonly width: number;
131
+ /** Original image height */
132
+ readonly height: number;
133
+ /** Scale image by factor */
134
+ scale(factor: number): {
135
+ width: number;
136
+ height: number;
137
+ };
138
+ /** Scale image to fit within bounds */
139
+ scaleToFit(width: number, height: number): {
140
+ width: number;
141
+ height: number;
142
+ };
143
+ }
144
+ /**
145
+ * Embedded font in PDF
146
+ */
147
+ export interface PdfEmbeddedFont {
148
+ /** Font name */
149
+ readonly name: string;
150
+ /** Calculate width of text at given size */
151
+ widthOfTextAtSize(text: string, size: number): number;
152
+ /** Get font height at given size */
153
+ heightAtSize(size: number): number;
154
+ }
155
+ /**
156
+ * PDF Page Interface
157
+ *
158
+ * Represents a single page in a PDF document.
159
+ */
160
+ export interface IPdfPage {
161
+ /** Page width in points */
162
+ readonly width: number;
163
+ /** Page height in points */
164
+ readonly height: number;
165
+ /** Get page dimensions */
166
+ getSize(): {
167
+ width: number;
168
+ height: number;
169
+ };
170
+ /** Set page dimensions */
171
+ setSize(width: number, height: number): void;
172
+ /** Draw text on the page */
173
+ drawText(text: string, options?: PdfDrawTextOptions): Promise<void>;
174
+ /** Draw a rectangle */
175
+ drawRectangle(options: PdfDrawRectOptions): void;
176
+ /** Draw a line */
177
+ drawLine(options: PdfDrawLineOptions): void;
178
+ /** Draw a circle */
179
+ drawCircle(options: PdfDrawCircleOptions): void;
180
+ /** Draw an embedded image */
181
+ drawImage(image: PdfEmbeddedImage, options?: PdfDrawImageOptions): void;
182
+ }
183
+ /**
184
+ * PDF Document Interface
185
+ *
186
+ * Main container for pages in a PDF file.
187
+ */
188
+ export interface IPdfDocument {
189
+ /** Get total page count */
190
+ getPageCount(): number;
191
+ /** Get all pages */
192
+ getPages(): IPdfPage[];
193
+ /** Get page by index (0-based) */
194
+ getPage(index: number): IPdfPage;
195
+ /** Add a new page */
196
+ addPage(size?: PdfPageSize | [number, number]): IPdfPage;
197
+ /** Insert a page at index */
198
+ insertPage(index: number, size?: PdfPageSize | [number, number]): IPdfPage;
199
+ /** Remove a page by index */
200
+ removePage(index: number): void;
201
+ /** Copy pages from another document */
202
+ copyPages(sourceDoc: IPdfDocument, pageIndices: number[]): Promise<IPdfPage[]>;
203
+ /** Embed a PNG image */
204
+ embedPng(imageData: Buffer | Uint8Array): Promise<PdfEmbeddedImage>;
205
+ /** Embed a JPG image */
206
+ embedJpg(imageData: Buffer | Uint8Array): Promise<PdfEmbeddedImage>;
207
+ /** Embed a custom font */
208
+ embedFont(fontData: Buffer | Uint8Array): Promise<PdfEmbeddedFont>;
209
+ /** Embed a standard font */
210
+ embedStandardFont(font: PdfStandardFont): Promise<PdfEmbeddedFont>;
211
+ /** Set document title */
212
+ setTitle(title: string): void;
213
+ /** Set document author */
214
+ setAuthor(author: string): void;
215
+ /** Set document subject */
216
+ setSubject(subject: string): void;
217
+ /** Set document keywords */
218
+ setKeywords(keywords: string[]): void;
219
+ /** Set document creator */
220
+ setCreator(creator: string): void;
221
+ /** Set document producer */
222
+ setProducer(producer: string): void;
223
+ /** Get document title */
224
+ getTitle(): string | undefined;
225
+ /** Get document author */
226
+ getAuthor(): string | undefined;
227
+ /** Get document subject */
228
+ getSubject(): string | undefined;
229
+ /** Get document keywords */
230
+ getKeywords(): string | undefined;
231
+ /** Get document creator */
232
+ getCreator(): string | undefined;
233
+ /** Get document producer */
234
+ getProducer(): string | undefined;
235
+ /** Write document to buffer */
236
+ toBuffer(): Promise<Buffer>;
237
+ }
238
+ /**
239
+ * PDF Manager Interface
240
+ *
241
+ * Static class interface for reading and creating PDF files.
242
+ */
243
+ export interface PdfManager {
244
+ /**
245
+ * Read a PDF file from a buffer
246
+ *
247
+ * @param buffer - Buffer containing PDF file data
248
+ * @returns Parsed PDF document
249
+ * @throws PdfParseError if file cannot be parsed
250
+ */
251
+ read(buffer: Buffer): Promise<IPdfDocument>;
252
+ /**
253
+ * Create a new empty PDF document
254
+ *
255
+ * @returns New empty PDF document
256
+ */
257
+ create(): Promise<IPdfDocument>;
258
+ /**
259
+ * Create an RGB color object
260
+ *
261
+ * @param r - Red component (0-1)
262
+ * @param g - Green component (0-1)
263
+ * @param b - Blue component (0-1)
264
+ * @returns RGB color object
265
+ */
266
+ rgb(r: number, g: number, b: number): PdfRgbColor;
267
+ }
268
+ //# sourceMappingURL=pdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../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IG;IACH,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAEhC;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CACnD"}
package/dist/pdf.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * PDF SDK Types
4
+ *
5
+ * Type definitions for PDF file reading, creation, and modification in tenant applications.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ //# sourceMappingURL=pdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdf.js","sourceRoot":"","sources":["../src/pdf.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ketrics/sdk-backend",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Ketrics SDK for backend tenant application code (VM sandbox)",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "license": "MIT",
25
25
  "repository": {
26
26
  "type": "git",
27
- "url": "https://github.com/ketrics/cl-ketrics-mvp.git",
27
+ "url": "https://github.com/ketrics/cl-ketrics.git",
28
28
  "directory": "ketrics-sdk-backend"
29
29
  },
30
30
  "devDependencies": {