@pdfme/cli 5.5.10-dev.125
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/README.md +870 -0
- package/dist/cjk-detect.d.ts +5 -0
- package/dist/commands/doctor.d.ts +50 -0
- package/dist/commands/examples.d.ts +35 -0
- package/dist/commands/generate.d.ts +78 -0
- package/dist/commands/pdf2img.d.ts +48 -0
- package/dist/commands/pdf2size.d.ts +19 -0
- package/dist/commands/validate.d.ts +24 -0
- package/dist/contract.d.ts +30 -0
- package/dist/diagnostics.d.ts +62 -0
- package/dist/example-fonts.d.ts +8 -0
- package/dist/example-templates.d.ts +36 -0
- package/dist/fonts.d.ts +35 -0
- package/dist/grid.d.ts +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3107 -0
- package/dist/index.js.map +1 -0
- package/dist/schema-plugins.d.ts +3 -0
- package/dist/utils.d.ts +53 -0
- package/dist/version.d.ts +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
target: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
file: {
|
|
8
|
+
type: "positional";
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
};
|
|
12
|
+
verbose: {
|
|
13
|
+
type: "boolean";
|
|
14
|
+
alias: string;
|
|
15
|
+
description: string;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
json: {
|
|
19
|
+
type: "boolean";
|
|
20
|
+
description: string;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
noAutoFont: {
|
|
24
|
+
type: "boolean";
|
|
25
|
+
description: string;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
output: {
|
|
29
|
+
type: "string";
|
|
30
|
+
alias: string;
|
|
31
|
+
description: string;
|
|
32
|
+
default: string;
|
|
33
|
+
};
|
|
34
|
+
force: {
|
|
35
|
+
type: "boolean";
|
|
36
|
+
description: string;
|
|
37
|
+
default: boolean;
|
|
38
|
+
};
|
|
39
|
+
image: {
|
|
40
|
+
type: "boolean";
|
|
41
|
+
description: string;
|
|
42
|
+
default: boolean;
|
|
43
|
+
};
|
|
44
|
+
imageFormat: {
|
|
45
|
+
type: "string";
|
|
46
|
+
description: string;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
name: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
list: {
|
|
8
|
+
type: "boolean";
|
|
9
|
+
description: string;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
output: {
|
|
13
|
+
type: "string";
|
|
14
|
+
alias: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
withInputs: {
|
|
18
|
+
type: "boolean";
|
|
19
|
+
alias: string;
|
|
20
|
+
description: string;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
verbose: {
|
|
24
|
+
type: "boolean";
|
|
25
|
+
alias: string;
|
|
26
|
+
description: string;
|
|
27
|
+
default: boolean;
|
|
28
|
+
};
|
|
29
|
+
json: {
|
|
30
|
+
type: "boolean";
|
|
31
|
+
description: string;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export default _default;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
file: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
template: {
|
|
8
|
+
type: "string";
|
|
9
|
+
alias: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
inputs: {
|
|
13
|
+
type: "string";
|
|
14
|
+
alias: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
output: {
|
|
18
|
+
type: "string";
|
|
19
|
+
alias: string;
|
|
20
|
+
description: string;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
force: {
|
|
24
|
+
type: "boolean";
|
|
25
|
+
description: string;
|
|
26
|
+
default: boolean;
|
|
27
|
+
};
|
|
28
|
+
image: {
|
|
29
|
+
type: "boolean";
|
|
30
|
+
description: string;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
imageFormat: {
|
|
34
|
+
type: "string";
|
|
35
|
+
description: string;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
scale: {
|
|
39
|
+
type: "string";
|
|
40
|
+
description: string;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
grid: {
|
|
44
|
+
type: "boolean";
|
|
45
|
+
description: string;
|
|
46
|
+
default: boolean;
|
|
47
|
+
};
|
|
48
|
+
gridSize: {
|
|
49
|
+
type: "string";
|
|
50
|
+
description: string;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
font: {
|
|
54
|
+
type: "string";
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
basePdf: {
|
|
58
|
+
type: "string";
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
noAutoFont: {
|
|
62
|
+
type: "boolean";
|
|
63
|
+
description: string;
|
|
64
|
+
default: boolean;
|
|
65
|
+
};
|
|
66
|
+
verbose: {
|
|
67
|
+
type: "boolean";
|
|
68
|
+
alias: string;
|
|
69
|
+
description: string;
|
|
70
|
+
default: boolean;
|
|
71
|
+
};
|
|
72
|
+
json: {
|
|
73
|
+
type: "boolean";
|
|
74
|
+
description: string;
|
|
75
|
+
default: boolean;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
file: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
output: {
|
|
8
|
+
type: "string";
|
|
9
|
+
alias: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
grid: {
|
|
13
|
+
type: "boolean";
|
|
14
|
+
description: string;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
gridSize: {
|
|
18
|
+
type: "string";
|
|
19
|
+
description: string;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
scale: {
|
|
23
|
+
type: "string";
|
|
24
|
+
description: string;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
imageFormat: {
|
|
28
|
+
type: "string";
|
|
29
|
+
description: string;
|
|
30
|
+
default: string;
|
|
31
|
+
};
|
|
32
|
+
pages: {
|
|
33
|
+
type: "string";
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
verbose: {
|
|
37
|
+
type: "boolean";
|
|
38
|
+
alias: string;
|
|
39
|
+
description: string;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
json: {
|
|
43
|
+
type: "boolean";
|
|
44
|
+
description: string;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
}>;
|
|
48
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
file: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
verbose: {
|
|
8
|
+
type: "boolean";
|
|
9
|
+
alias: string;
|
|
10
|
+
description: string;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
json: {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
description: string;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: import("citty").CommandDef<{
|
|
2
|
+
file: {
|
|
3
|
+
type: "positional";
|
|
4
|
+
description: string;
|
|
5
|
+
required: boolean;
|
|
6
|
+
};
|
|
7
|
+
verbose: {
|
|
8
|
+
type: "boolean";
|
|
9
|
+
alias: string;
|
|
10
|
+
description: string;
|
|
11
|
+
default: boolean;
|
|
12
|
+
};
|
|
13
|
+
json: {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
description: string;
|
|
16
|
+
default: boolean;
|
|
17
|
+
};
|
|
18
|
+
strict: {
|
|
19
|
+
type: "boolean";
|
|
20
|
+
description: string;
|
|
21
|
+
default: boolean;
|
|
22
|
+
};
|
|
23
|
+
}>;
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface CliErrorOptions {
|
|
2
|
+
code?: string;
|
|
3
|
+
exitCode?: number;
|
|
4
|
+
details?: unknown;
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface CliArgDefinition {
|
|
8
|
+
type: 'positional' | 'string' | 'boolean';
|
|
9
|
+
alias?: string | string[];
|
|
10
|
+
description?: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare class CliError extends Error {
|
|
15
|
+
readonly code: string;
|
|
16
|
+
readonly exitCode: number;
|
|
17
|
+
readonly details?: unknown;
|
|
18
|
+
constructor(message: string, options?: CliErrorOptions);
|
|
19
|
+
}
|
|
20
|
+
export declare function fail(message: string, options?: CliErrorOptions): never;
|
|
21
|
+
export declare function printJson(value: Record<string, unknown>): void;
|
|
22
|
+
export declare function runWithContract<T>(options: {
|
|
23
|
+
json: boolean;
|
|
24
|
+
}, task: () => Promise<T> | T): Promise<T>;
|
|
25
|
+
export declare function handleCommandError(error: unknown, json: boolean): never;
|
|
26
|
+
export declare function assertNoUnknownFlags(rawArgs: string[], argsDefinition: Record<string, CliArgDefinition>): void;
|
|
27
|
+
export declare function isOptionProvided(rawArgs: string[], name: string, alias?: string | string[]): boolean;
|
|
28
|
+
export declare function parseEnumArg<T extends string>(optionName: string, value: unknown, allowedValues: readonly T[]): T;
|
|
29
|
+
export declare function parsePositiveNumberArg(optionName: string, value: unknown): number;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const KNOWN_TEMPLATE_KEYS: Set<string>;
|
|
2
|
+
export declare const KNOWN_JOB_KEYS: Set<string>;
|
|
3
|
+
export interface ValidationResult {
|
|
4
|
+
errors: string[];
|
|
5
|
+
warnings: string[];
|
|
6
|
+
pages: number;
|
|
7
|
+
fields: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ValidationInspection {
|
|
10
|
+
schemaTypes: string[];
|
|
11
|
+
requiredPlugins: string[];
|
|
12
|
+
requiredFonts: string[];
|
|
13
|
+
basePdf: {
|
|
14
|
+
kind: string;
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
paperSize?: string | null;
|
|
18
|
+
path?: string;
|
|
19
|
+
resolvedPath?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface FieldInputHint {
|
|
23
|
+
name: string;
|
|
24
|
+
type: string;
|
|
25
|
+
pages: number[];
|
|
26
|
+
required: boolean;
|
|
27
|
+
expectedInput: {
|
|
28
|
+
kind: 'string' | 'jsonStringObject' | 'enumString' | 'stringMatrix';
|
|
29
|
+
variableNames?: string[];
|
|
30
|
+
allowedValues?: string[];
|
|
31
|
+
example?: string | string[][];
|
|
32
|
+
format?: string;
|
|
33
|
+
canonicalFormat?: string;
|
|
34
|
+
contentKind?: string;
|
|
35
|
+
rule?: string;
|
|
36
|
+
groupName?: string;
|
|
37
|
+
groupMemberNames?: string[];
|
|
38
|
+
columnCount?: number;
|
|
39
|
+
columnHeaders?: string[];
|
|
40
|
+
acceptsJsonString?: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface ValidationSource {
|
|
44
|
+
mode: 'template' | 'job';
|
|
45
|
+
template: Record<string, unknown>;
|
|
46
|
+
inputs?: Record<string, unknown>[];
|
|
47
|
+
options?: unknown;
|
|
48
|
+
templateDir?: string;
|
|
49
|
+
jobWarnings: string[];
|
|
50
|
+
}
|
|
51
|
+
export declare function findClosestType(type: string): string | null;
|
|
52
|
+
export declare function validateTemplate(template: Record<string, unknown>): ValidationResult;
|
|
53
|
+
export declare function inspectTemplate(template: Record<string, unknown>, templateDir?: string): ValidationInspection;
|
|
54
|
+
export declare function collectInputHints(template: Record<string, unknown>): FieldInputHint[];
|
|
55
|
+
export declare function validateInputContracts(template: Record<string, unknown>, inputs: Record<string, unknown>[]): void;
|
|
56
|
+
export declare function getInputContractIssues(template: Record<string, unknown>, inputs: Record<string, unknown>[]): string[];
|
|
57
|
+
export declare function loadValidationSource(file: string | undefined, options: {
|
|
58
|
+
noInputMessage: string;
|
|
59
|
+
}): Promise<ValidationSource>;
|
|
60
|
+
export declare function normalizeSchemaPages(rawSchemas: unknown): Array<Array<Record<string, unknown>>>;
|
|
61
|
+
export declare function getUniqueStringValues(values: unknown[]): string[];
|
|
62
|
+
export declare function summarizeBasePdf(basePdf: unknown, templateDir: string | undefined): ValidationInspection['basePdf'];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Font } from '@pdfme/common';
|
|
2
|
+
export declare const OFFICIAL_EXAMPLE_FONT_URLS: {
|
|
3
|
+
readonly NotoSansJP: "https://fonts.gstatic.com/s/notosansjp/v53/-F6jfjtqLzI2JPCgQBnw7HFyzSD-AsregP8VFBEj75vY0rw-oME.ttf";
|
|
4
|
+
readonly NotoSerifJP: "https://fonts.gstatic.com/s/notoserifjp/v30/xn71YHs72GKoTvER4Gn3b5eMRtWGkp6o7MjQ2bwxOubAILO5wBCU.ttf";
|
|
5
|
+
readonly 'PinyonScript-Regular': "https://fonts.gstatic.com/s/pinyonscript/v22/6xKpdSJbL9-e9LuoeQiDRQR8aOLQO4bhiDY.ttf";
|
|
6
|
+
};
|
|
7
|
+
export declare function collectTemplateFontNames(template: Record<string, unknown>): string[];
|
|
8
|
+
export declare function getOfficialExampleFonts(template: Record<string, unknown>): Font | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface ExampleManifestEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
author: string;
|
|
4
|
+
path: string;
|
|
5
|
+
thumbnailPath: string;
|
|
6
|
+
pageCount: number;
|
|
7
|
+
fieldCount: number;
|
|
8
|
+
schemaTypes: string[];
|
|
9
|
+
fontNames: string[];
|
|
10
|
+
hasCJK: boolean;
|
|
11
|
+
basePdfKind: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExampleManifest {
|
|
14
|
+
schemaVersion: number;
|
|
15
|
+
cliVersion: string;
|
|
16
|
+
templates: ExampleManifestEntry[];
|
|
17
|
+
}
|
|
18
|
+
export interface ExampleManifestLoadResult {
|
|
19
|
+
manifest: ExampleManifest;
|
|
20
|
+
source: 'remote';
|
|
21
|
+
url?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ExampleTemplateLoadResult {
|
|
24
|
+
template: Record<string, unknown>;
|
|
25
|
+
source: 'remote';
|
|
26
|
+
url?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function getExamplesBaseUrl(): string;
|
|
29
|
+
export declare function getExampleManifest(): Promise<ExampleManifestLoadResult>;
|
|
30
|
+
export declare function getExampleTemplateNames(): Promise<string[]>;
|
|
31
|
+
export declare function fetchExampleTemplate(name: string, options?: {
|
|
32
|
+
manifest?: ExampleManifest;
|
|
33
|
+
}): Promise<Record<string, unknown>>;
|
|
34
|
+
export declare function fetchExampleTemplateWithSource(name: string, options?: {
|
|
35
|
+
manifest?: ExampleManifest;
|
|
36
|
+
}): Promise<ExampleTemplateLoadResult>;
|
package/dist/fonts.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Font } from '@pdfme/common';
|
|
2
|
+
export declare const NOTO_CACHE_FILE: string;
|
|
3
|
+
export type ExplicitFontSourceKind = 'localPath' | 'url' | 'dataUri' | 'inlineBytes' | 'invalid';
|
|
4
|
+
export type ExplicitFontRemoteProvider = 'genericPublic' | 'googleFontsAsset' | 'googleFontsStylesheet';
|
|
5
|
+
export interface ExplicitFontSourceDiagnosis {
|
|
6
|
+
fontName: string;
|
|
7
|
+
kind: ExplicitFontSourceKind;
|
|
8
|
+
provider?: ExplicitFontRemoteProvider;
|
|
9
|
+
path?: string;
|
|
10
|
+
resolvedPath?: string;
|
|
11
|
+
exists?: boolean;
|
|
12
|
+
url?: string;
|
|
13
|
+
mediaType?: string;
|
|
14
|
+
formatHint?: string | null;
|
|
15
|
+
supportedFormat?: boolean;
|
|
16
|
+
needsNetwork: boolean;
|
|
17
|
+
dataType?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ResolveFontOptions {
|
|
20
|
+
fontArgs?: string[];
|
|
21
|
+
hasCJK: boolean;
|
|
22
|
+
noAutoFont: boolean;
|
|
23
|
+
verbose: boolean;
|
|
24
|
+
hasExplicitFontConfig?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function downloadNotoSansJP(verbose: boolean): Promise<Uint8Array | null>;
|
|
27
|
+
export declare function parseCustomFonts(fontArgs: string[]): Font;
|
|
28
|
+
export declare function analyzeExplicitFontRecord(fontRecord: Record<string, unknown>, templateDir?: string): {
|
|
29
|
+
sources: ExplicitFontSourceDiagnosis[];
|
|
30
|
+
issues: string[];
|
|
31
|
+
warnings: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare function normalizeExplicitFontOption(jobFont: unknown, templateDir?: string): Promise<Font | undefined>;
|
|
34
|
+
export declare function resolveFont(options: ResolveFontOptions): Promise<Font>;
|
|
35
|
+
export {};
|
package/dist/grid.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
interface Schema {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
position: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
};
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
type ImageFormat = 'png' | 'jpeg';
|
|
13
|
+
/**
|
|
14
|
+
* Draw grid lines and schema boundary overlays on a generated PDF page image.
|
|
15
|
+
* Used by `pdfme generate --grid`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function drawGridOnImage(imageBuffer: ArrayBuffer, schemas: Schema[], gridSizeMm: number, pageWidthMm: number, pageHeightMm: number, imageType: ImageFormat): Promise<ArrayBuffer>;
|
|
18
|
+
/**
|
|
19
|
+
* Draw grid lines with mm coordinate labels on a plain PDF image.
|
|
20
|
+
* Used by `pdfme pdf2img --grid`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function drawGridOnPdfImage(imageBuffer: ArrayBuffer, gridSizeMm: number, pageWidthMm: number, pageHeightMm: number, imageType: ImageFormat): Promise<ArrayBuffer>;
|
|
23
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|