@shisho/plugin-sdk 0.0.48 → 0.0.50
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/hooks.d.ts +32 -31
- package/metadata.d.ts +7 -0
- package/package.json +4 -4
- package/testing/type-contract.ts +30 -0
- package/testing/type-contract.tsconfig.json +7 -0
package/hooks.d.ts
CHANGED
|
@@ -62,46 +62,47 @@ export interface SearchResponse {
|
|
|
62
62
|
results: ParsedMetadata[];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/** Book metadata passed to output-generator hooks. */
|
|
66
|
+
export interface OutputBookContext {
|
|
67
|
+
id?: number;
|
|
68
|
+
title?: string;
|
|
69
|
+
subtitle?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
authors?: Array<{ name: string; role?: string }>;
|
|
72
|
+
series?: Array<{ name: string; number?: number }>;
|
|
73
|
+
genres?: string[];
|
|
74
|
+
tags?: string[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** File metadata passed to output-generator hooks. */
|
|
78
|
+
export interface OutputFileContext {
|
|
79
|
+
id?: number;
|
|
80
|
+
filepath?: string;
|
|
81
|
+
fileType?: string;
|
|
82
|
+
fileRole?: string;
|
|
83
|
+
filesizeBytes?: number;
|
|
84
|
+
name?: string;
|
|
85
|
+
url?: string;
|
|
86
|
+
publisher?: string;
|
|
87
|
+
releaseDate?: string;
|
|
88
|
+
narrators?: string[];
|
|
89
|
+
identifiers?: Array<{ type: string; value: string }>;
|
|
90
|
+
}
|
|
91
|
+
|
|
65
92
|
/** Context passed to outputGenerator.generate(). */
|
|
66
93
|
export interface OutputGeneratorContext {
|
|
67
94
|
/** Path to the source book file. */
|
|
68
95
|
sourcePath: string;
|
|
69
96
|
/** Path where the output file should be written. */
|
|
70
97
|
destPath: string;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
title?: string;
|
|
74
|
-
authors?: Array<{ name: string; role?: string }>;
|
|
75
|
-
series?: string;
|
|
76
|
-
seriesNumber?: number;
|
|
77
|
-
publisher?: string;
|
|
78
|
-
description?: string;
|
|
79
|
-
genres?: string[];
|
|
80
|
-
tags?: string[];
|
|
81
|
-
identifiers?: Array<{ type: string; value: string }>;
|
|
82
|
-
};
|
|
83
|
-
/** File metadata. */
|
|
84
|
-
file: {
|
|
85
|
-
fileType?: string;
|
|
86
|
-
filePath?: string;
|
|
87
|
-
};
|
|
98
|
+
book: OutputBookContext;
|
|
99
|
+
file: OutputFileContext;
|
|
88
100
|
}
|
|
89
101
|
|
|
90
102
|
/** Context passed to outputGenerator.fingerprint(). */
|
|
91
103
|
export interface FingerprintContext {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
title?: string;
|
|
95
|
-
authors?: Array<{ name: string; role?: string }>;
|
|
96
|
-
series?: string;
|
|
97
|
-
seriesNumber?: number;
|
|
98
|
-
publisher?: string;
|
|
99
|
-
};
|
|
100
|
-
/** File metadata. */
|
|
101
|
-
file: {
|
|
102
|
-
fileType?: string;
|
|
103
|
-
filePath?: string;
|
|
104
|
-
};
|
|
104
|
+
book: OutputBookContext;
|
|
105
|
+
file: OutputFileContext;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/** Input converter hook. */
|
|
@@ -126,7 +127,7 @@ export interface OutputGeneratorHook {
|
|
|
126
127
|
fingerprint(context: FingerprintContext): string;
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
/** The plugin object
|
|
130
|
+
/** The global plugin object created by main.js. */
|
|
130
131
|
export interface ShishoPlugin {
|
|
131
132
|
inputConverter?: InputConverterHook;
|
|
132
133
|
fileParser?: FileParserHook;
|
package/metadata.d.ts
CHANGED
|
@@ -35,7 +35,14 @@ export interface ParsedMetadata {
|
|
|
35
35
|
authors?: ParsedAuthor[];
|
|
36
36
|
narrators?: string[];
|
|
37
37
|
series?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Series position. Must be finite. An optional seriesNumberEnd must also be
|
|
40
|
+
* finite and greater than this value. If the start, end, or unit is invalid,
|
|
41
|
+
* Shisho discards the complete series-number group.
|
|
42
|
+
*/
|
|
38
43
|
seriesNumber?: number;
|
|
44
|
+
/** Optional inclusive end for an omnibus series range. Requires seriesNumber. */
|
|
45
|
+
seriesNumberEnd?: number;
|
|
39
46
|
/** Whether the series number refers to a volume or a chapter. CBZ only. */
|
|
40
47
|
seriesNumberUnit?: "volume" | "chapter";
|
|
41
48
|
genres?: string[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shisho/plugin-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "TypeScript SDK for Shisho plugin development — types, host API declarations, and test utilities",
|
|
5
5
|
"homepage": "https://github.com/shishobooks/shisho/blob/master/packages/plugin-sdk/README.md",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"testing/"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "cd testing && npx tsc -p tsconfig.json"
|
|
20
|
+
"build": "cd testing && npx tsc -p tsconfig.json && npx tsc -p type-contract.tsconfig.json"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"directory": "packages/plugin-sdk"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"fast-xml-parser": "^5.
|
|
30
|
-
"linkedom": "^0.18.
|
|
29
|
+
"fast-xml-parser": "^5.10.1",
|
|
30
|
+
"linkedom": "^0.18.13",
|
|
31
31
|
"yaml": "^2.9.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { OutputGeneratorContext, ParsedMetadata } from "../index";
|
|
2
|
+
|
|
3
|
+
type Equal<Left, Right> =
|
|
4
|
+
(<Type>() => Type extends Left ? 1 : 2) extends <Type>() => Type extends Right
|
|
5
|
+
? 1
|
|
6
|
+
: 2
|
|
7
|
+
? true
|
|
8
|
+
: false;
|
|
9
|
+
type Expect<Type extends true> = Type;
|
|
10
|
+
|
|
11
|
+
type SeriesNumberEndContract = Expect<
|
|
12
|
+
Equal<ParsedMetadata["seriesNumberEnd"], number | undefined>
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
type OutputSeriesContract = Expect<
|
|
16
|
+
Equal<
|
|
17
|
+
OutputGeneratorContext["book"]["series"],
|
|
18
|
+
Array<{ name: string; number?: number }> | undefined
|
|
19
|
+
>
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
type OutputFilepathContract = Expect<
|
|
23
|
+
Equal<OutputGeneratorContext["file"]["filepath"], string | undefined>
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
export type {
|
|
27
|
+
OutputFilepathContract,
|
|
28
|
+
OutputSeriesContract,
|
|
29
|
+
SeriesNumberEndContract,
|
|
30
|
+
};
|