@shisho/plugin-sdk 0.1.1 → 0.2.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/README.md +1 -1
- package/hooks.d.ts +0 -50
- package/manifest.d.ts +0 -12
- package/package.json +1 -1
- package/testing/type-contract.ts +2 -17
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install --save-dev @shisho/plugin-sdk
|
|
|
13
13
|
The types provide autocompletion for:
|
|
14
14
|
|
|
15
15
|
- **`shisho.*`** - Host APIs (log, config, http, fs, archive, xml, ffmpeg)
|
|
16
|
-
- **`plugin`** - Hook structure (inputConverter, fileParser, metadataEnricher
|
|
16
|
+
- **`plugin`** - Hook structure (inputConverter, fileParser, metadataEnricher)
|
|
17
17
|
- **Hook contexts** - Typed `context` parameters for each hook method
|
|
18
18
|
- **Return types** - `ParsedMetadata`, `ConvertResult`, `SearchResponse`, etc.
|
|
19
19
|
|
package/hooks.d.ts
CHANGED
|
@@ -62,49 +62,6 @@ 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
|
-
|
|
92
|
-
/** Context passed to outputGenerator.generate(). */
|
|
93
|
-
export interface OutputGeneratorContext {
|
|
94
|
-
/** Path to the source book file. */
|
|
95
|
-
sourcePath: string;
|
|
96
|
-
/** Path where the output file should be written. */
|
|
97
|
-
destPath: string;
|
|
98
|
-
book: OutputBookContext;
|
|
99
|
-
file: OutputFileContext;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** Context passed to outputGenerator.fingerprint(). */
|
|
103
|
-
export interface FingerprintContext {
|
|
104
|
-
book: OutputBookContext;
|
|
105
|
-
file: OutputFileContext;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
65
|
/** Input converter hook. */
|
|
109
66
|
export interface InputConverterHook {
|
|
110
67
|
convert(context: InputConverterContext): ConvertResult;
|
|
@@ -121,18 +78,11 @@ export interface MetadataEnricherHook {
|
|
|
121
78
|
search(context: SearchContext): SearchResponse;
|
|
122
79
|
}
|
|
123
80
|
|
|
124
|
-
/** Output generator hook. */
|
|
125
|
-
export interface OutputGeneratorHook {
|
|
126
|
-
generate(context: OutputGeneratorContext): void;
|
|
127
|
-
fingerprint(context: FingerprintContext): string;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
81
|
/** The global plugin object created by main.js. */
|
|
131
82
|
export interface ShishoPlugin {
|
|
132
83
|
inputConverter?: InputConverterHook;
|
|
133
84
|
fileParser?: FileParserHook;
|
|
134
85
|
metadataEnricher?: MetadataEnricherHook;
|
|
135
|
-
outputGenerator?: OutputGeneratorHook;
|
|
136
86
|
|
|
137
87
|
/**
|
|
138
88
|
* Optional lifecycle hook called before the plugin is uninstalled.
|
package/manifest.d.ts
CHANGED
|
@@ -18,17 +18,6 @@ export interface FileParserCap {
|
|
|
18
18
|
mimeTypes?: string[];
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
/** Output generator capability declaration. */
|
|
22
|
-
export interface OutputGeneratorCap {
|
|
23
|
-
description?: string;
|
|
24
|
-
/** Unique format identifier (e.g., "mobi"). */
|
|
25
|
-
id: string;
|
|
26
|
-
/** Display name (e.g., "MOBI"). */
|
|
27
|
-
name: string;
|
|
28
|
-
/** Source file types this generator can convert from. */
|
|
29
|
-
sourceTypes: string[];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
21
|
/** Valid metadata field names for enricher declarations. */
|
|
33
22
|
export type MetadataField =
|
|
34
23
|
| "title"
|
|
@@ -102,7 +91,6 @@ export interface ShellAccessCap {
|
|
|
102
91
|
export interface Capabilities {
|
|
103
92
|
inputConverter?: InputConverterCap;
|
|
104
93
|
fileParser?: FileParserCap;
|
|
105
|
-
outputGenerator?: OutputGeneratorCap;
|
|
106
94
|
metadataEnricher?: MetadataEnricherCap;
|
|
107
95
|
identifierTypes?: IdentifierTypeCap[];
|
|
108
96
|
httpAccess?: HTTPAccessCap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shisho/plugin-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|
package/testing/type-contract.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ParsedMetadata } from "../index";
|
|
2
2
|
|
|
3
3
|
type Equal<Left, Right> =
|
|
4
4
|
(<Type>() => Type extends Left ? 1 : 2) extends <Type>() => Type extends Right
|
|
@@ -12,19 +12,4 @@ type SeriesNumberEndContract = Expect<
|
|
|
12
12
|
Equal<ParsedMetadata["seriesNumberEnd"], number | undefined>
|
|
13
13
|
>;
|
|
14
14
|
|
|
15
|
-
type
|
|
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
|
-
};
|
|
15
|
+
export type { SeriesNumberEndContract };
|