@shisho/plugin-types 0.0.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 +114 -0
- package/global.d.ts +11 -0
- package/hooks.d.ts +149 -0
- package/host-api.d.ts +140 -0
- package/index.d.ts +6 -0
- package/manifest.d.ts +133 -0
- package/metadata.d.ts +61 -0
- package/package.json +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @shisho/plugin-types
|
|
2
|
+
|
|
3
|
+
TypeScript type definitions for [Shisho](https://github.com/shishobooks/shisho) plugin development. Provides IDE autocompletion and type checking for the `shisho.*` host APIs, hook contexts, metadata structures, and manifest schema.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @shisho/plugin-types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The types provide autocompletion for:
|
|
14
|
+
|
|
15
|
+
- **`shisho.*`** - Host APIs (log, config, http, fs, archive, xml, ffmpeg)
|
|
16
|
+
- **`plugin`** - Hook structure (inputConverter, fileParser, metadataEnricher, outputGenerator)
|
|
17
|
+
- **Hook contexts** - Typed `context` parameters for each hook method
|
|
18
|
+
- **Return types** - `ParsedMetadata`, `ConvertResult`, `EnrichmentResult`, etc.
|
|
19
|
+
|
|
20
|
+
### TypeScript
|
|
21
|
+
|
|
22
|
+
If you write your plugin in TypeScript (and compile to JavaScript for deployment), import the types directly:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import type {
|
|
26
|
+
EnrichmentResult,
|
|
27
|
+
FileParserContext,
|
|
28
|
+
MetadataEnricherContext,
|
|
29
|
+
ParsedMetadata,
|
|
30
|
+
ShishoPlugin,
|
|
31
|
+
} from "@shisho/plugin-types";
|
|
32
|
+
|
|
33
|
+
const plugin: ShishoPlugin = {
|
|
34
|
+
fileParser: {
|
|
35
|
+
parse(context: FileParserContext): ParsedMetadata {
|
|
36
|
+
const content = shisho.fs.readTextFile(context.filePath);
|
|
37
|
+
return {
|
|
38
|
+
title: "My Book",
|
|
39
|
+
authors: [{ name: "Author Name", role: "writer" }],
|
|
40
|
+
identifiers: [{ type: "isbn_13", value: "9781234567890" }],
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
metadataEnricher: {
|
|
46
|
+
enrich(context: MetadataEnricherContext): EnrichmentResult {
|
|
47
|
+
const apiKey = shisho.config.get("apiKey");
|
|
48
|
+
const resp = shisho.http.fetch(
|
|
49
|
+
`https://api.example.com/lookup?title=${context.book.title}`,
|
|
50
|
+
{ method: "GET" },
|
|
51
|
+
);
|
|
52
|
+
const data = resp.json() as { description: string };
|
|
53
|
+
return {
|
|
54
|
+
modified: true,
|
|
55
|
+
metadata: { description: data.description },
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### JavaScript with JSDoc
|
|
63
|
+
|
|
64
|
+
Add a triple-slash reference at the top of your `main.js` and use JSDoc annotations for type checking:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
/// <reference types="@shisho/plugin-types" />
|
|
68
|
+
|
|
69
|
+
var plugin = (function () {
|
|
70
|
+
return {
|
|
71
|
+
fileParser: {
|
|
72
|
+
/** @param {FileParserContext} context @returns {ParsedMetadata} */
|
|
73
|
+
parse: function (context) {
|
|
74
|
+
var content = shisho.fs.readTextFile(context.filePath);
|
|
75
|
+
return {
|
|
76
|
+
title: "My Book",
|
|
77
|
+
authors: [{ name: "Author Name" }],
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
metadataEnricher: {
|
|
83
|
+
/** @param {MetadataEnricherContext} context @returns {EnrichmentResult} */
|
|
84
|
+
enrich: function (context) {
|
|
85
|
+
var apiKey = shisho.config.get("apiKey");
|
|
86
|
+
var resp = shisho.http.fetch(
|
|
87
|
+
"https://api.example.com/lookup?title=" + context.book.title,
|
|
88
|
+
{ method: "GET" },
|
|
89
|
+
);
|
|
90
|
+
var data = resp.json();
|
|
91
|
+
return {
|
|
92
|
+
modified: true,
|
|
93
|
+
metadata: { description: data.description },
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
})();
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## What's Included
|
|
102
|
+
|
|
103
|
+
| File | Contents |
|
|
104
|
+
| --------------- | --------------------------------------------------------------------- |
|
|
105
|
+
| `global.d.ts` | Global `shisho` and `plugin` variable declarations |
|
|
106
|
+
| `host-api.d.ts` | `ShishoHostAPI` and all namespace interfaces |
|
|
107
|
+
| `hooks.d.ts` | Hook context/result types and `ShishoPlugin` interface |
|
|
108
|
+
| `metadata.d.ts` | `ParsedMetadata`, `ParsedAuthor`, `ParsedIdentifier`, `ParsedChapter` |
|
|
109
|
+
| `manifest.d.ts` | `PluginManifest`, `Capabilities`, `ConfigSchema` |
|
|
110
|
+
|
|
111
|
+
## Links
|
|
112
|
+
|
|
113
|
+
- [Plugin Development Guide](https://github.com/shishobooks/shisho/blob/master/docs/plugins.md)
|
|
114
|
+
- [Shisho Repository](https://github.com/shishobooks/shisho)
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ShishoPlugin } from "./hooks";
|
|
2
|
+
import { ShishoHostAPI } from "./host-api";
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
/** Host API object providing logging, config, HTTP, filesystem, archive, XML, and FFmpeg access. */
|
|
6
|
+
// eslint-disable-next-line no-var
|
|
7
|
+
var shisho: ShishoHostAPI;
|
|
8
|
+
/** Plugin object that defines hook implementations. */
|
|
9
|
+
// eslint-disable-next-line no-var
|
|
10
|
+
var plugin: ShishoPlugin;
|
|
11
|
+
}
|
package/hooks.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ParsedMetadata } from "./metadata";
|
|
2
|
+
|
|
3
|
+
/** Context passed to inputConverter.convert(). */
|
|
4
|
+
export interface InputConverterContext {
|
|
5
|
+
/** Path to the input file. */
|
|
6
|
+
sourcePath: string;
|
|
7
|
+
/** Directory where the converted output should be written. */
|
|
8
|
+
targetDir: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** Result returned from inputConverter.convert(). */
|
|
12
|
+
export interface ConvertResult {
|
|
13
|
+
/** Whether conversion succeeded. */
|
|
14
|
+
success: boolean;
|
|
15
|
+
/** Path to the converted output file. */
|
|
16
|
+
targetPath: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Context passed to fileParser.parse(). */
|
|
20
|
+
export interface FileParserContext {
|
|
21
|
+
/** Path to the file being parsed. */
|
|
22
|
+
filePath: string;
|
|
23
|
+
/** File extension (e.g., "pdf", "epub"). */
|
|
24
|
+
fileType: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Context passed to metadataEnricher.enrich(). */
|
|
28
|
+
export interface MetadataEnricherContext {
|
|
29
|
+
/** Metadata freshly parsed from the file on disk (e.g., from ComicInfo.xml, OPF, etc.). */
|
|
30
|
+
parsedMetadata: {
|
|
31
|
+
title?: string;
|
|
32
|
+
subtitle?: string;
|
|
33
|
+
series?: string;
|
|
34
|
+
seriesNumber?: number;
|
|
35
|
+
description?: string;
|
|
36
|
+
publisher?: string;
|
|
37
|
+
imprint?: string;
|
|
38
|
+
url?: string;
|
|
39
|
+
dataSource?: string;
|
|
40
|
+
authors?: Array<{ name: string; role?: string }>;
|
|
41
|
+
narrators?: string[];
|
|
42
|
+
genres?: string[];
|
|
43
|
+
tags?: string[];
|
|
44
|
+
releaseDate?: string;
|
|
45
|
+
identifiers?: Array<{ type: string; value: string }>;
|
|
46
|
+
};
|
|
47
|
+
/** File information from the database. */
|
|
48
|
+
file: {
|
|
49
|
+
id?: number;
|
|
50
|
+
filepath?: string;
|
|
51
|
+
fileType?: string;
|
|
52
|
+
fileRole?: string;
|
|
53
|
+
filesizeBytes?: number;
|
|
54
|
+
name?: string;
|
|
55
|
+
url?: string;
|
|
56
|
+
};
|
|
57
|
+
/** Current book state from the database, including manually-edited fields. */
|
|
58
|
+
book: {
|
|
59
|
+
id?: number;
|
|
60
|
+
title?: string;
|
|
61
|
+
subtitle?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
series?: Array<{ name: string; number?: number }>;
|
|
64
|
+
authors?: Array<{ name: string; role?: string }>;
|
|
65
|
+
genres?: string[];
|
|
66
|
+
tags?: string[];
|
|
67
|
+
identifiers?: Array<{ type: string; value: string }>;
|
|
68
|
+
publisher?: string;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Result returned from metadataEnricher.enrich(). */
|
|
73
|
+
export interface EnrichmentResult {
|
|
74
|
+
/** Whether metadata was modified. */
|
|
75
|
+
modified: boolean;
|
|
76
|
+
/** Updated metadata (only used if modified is true). */
|
|
77
|
+
metadata?: ParsedMetadata;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Context passed to outputGenerator.generate(). */
|
|
81
|
+
export interface OutputGeneratorContext {
|
|
82
|
+
/** Path to the source book file. */
|
|
83
|
+
sourcePath: string;
|
|
84
|
+
/** Path where the output file should be written. */
|
|
85
|
+
destPath: string;
|
|
86
|
+
/** Book metadata. */
|
|
87
|
+
book: {
|
|
88
|
+
title?: string;
|
|
89
|
+
authors?: Array<{ name: string; role?: string }>;
|
|
90
|
+
series?: string;
|
|
91
|
+
seriesNumber?: number;
|
|
92
|
+
publisher?: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
genres?: string[];
|
|
95
|
+
tags?: string[];
|
|
96
|
+
identifiers?: Array<{ type: string; value: string }>;
|
|
97
|
+
};
|
|
98
|
+
/** File metadata. */
|
|
99
|
+
file: {
|
|
100
|
+
fileType?: string;
|
|
101
|
+
filePath?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Context passed to outputGenerator.fingerprint(). */
|
|
106
|
+
export interface FingerprintContext {
|
|
107
|
+
/** Book metadata. */
|
|
108
|
+
book: {
|
|
109
|
+
title?: string;
|
|
110
|
+
authors?: Array<{ name: string; role?: string }>;
|
|
111
|
+
series?: string;
|
|
112
|
+
seriesNumber?: number;
|
|
113
|
+
publisher?: string;
|
|
114
|
+
};
|
|
115
|
+
/** File metadata. */
|
|
116
|
+
file: {
|
|
117
|
+
fileType?: string;
|
|
118
|
+
filePath?: string;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Input converter hook. */
|
|
123
|
+
export interface InputConverterHook {
|
|
124
|
+
convert(context: InputConverterContext): ConvertResult;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** File parser hook. */
|
|
128
|
+
export interface FileParserHook {
|
|
129
|
+
parse(context: FileParserContext): ParsedMetadata;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Metadata enricher hook. */
|
|
133
|
+
export interface MetadataEnricherHook {
|
|
134
|
+
enrich(context: MetadataEnricherContext): EnrichmentResult;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Output generator hook. */
|
|
138
|
+
export interface OutputGeneratorHook {
|
|
139
|
+
generate(context: OutputGeneratorContext): void;
|
|
140
|
+
fingerprint(context: FingerprintContext): string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The plugin object exported by main.js via IIFE. */
|
|
144
|
+
export interface ShishoPlugin {
|
|
145
|
+
inputConverter?: InputConverterHook;
|
|
146
|
+
fileParser?: FileParserHook;
|
|
147
|
+
metadataEnricher?: MetadataEnricherHook;
|
|
148
|
+
outputGenerator?: OutputGeneratorHook;
|
|
149
|
+
}
|
package/host-api.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/** Logging methods. */
|
|
2
|
+
export interface ShishoLog {
|
|
3
|
+
debug(msg: string): void;
|
|
4
|
+
info(msg: string): void;
|
|
5
|
+
warn(msg: string): void;
|
|
6
|
+
error(msg: string): void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Plugin configuration access. */
|
|
10
|
+
export interface ShishoConfig {
|
|
11
|
+
/** Get a single config value by key. Returns undefined if not set. */
|
|
12
|
+
get(key: string): string | undefined;
|
|
13
|
+
/** Get all config values as a key-value map. */
|
|
14
|
+
getAll(): Record<string, string>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Options for shisho.http.fetch(). */
|
|
18
|
+
export interface FetchOptions {
|
|
19
|
+
/** HTTP method (default: "GET"). */
|
|
20
|
+
method?: string;
|
|
21
|
+
/** Request headers. */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/** Request body string. */
|
|
24
|
+
body?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Response from shisho.http.fetch(). */
|
|
28
|
+
export interface FetchResponse {
|
|
29
|
+
/** Whether the status code is 2xx. */
|
|
30
|
+
ok: boolean;
|
|
31
|
+
/** HTTP status code. */
|
|
32
|
+
status: number;
|
|
33
|
+
/** HTTP status text. */
|
|
34
|
+
statusText: string;
|
|
35
|
+
/** Response headers (lowercase keys). */
|
|
36
|
+
headers: Record<string, string>;
|
|
37
|
+
/** Get response body as string. */
|
|
38
|
+
text(): string;
|
|
39
|
+
/** Get response body as ArrayBuffer. */
|
|
40
|
+
arrayBuffer(): ArrayBuffer;
|
|
41
|
+
/** Parse response body as JSON. */
|
|
42
|
+
json(): unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** HTTP client with domain whitelisting. */
|
|
46
|
+
export interface ShishoHTTP {
|
|
47
|
+
/** Fetch a URL. Domain must be declared in manifest httpAccess.domains. */
|
|
48
|
+
fetch(url: string, options?: FetchOptions): FetchResponse;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Filesystem operations (sandboxed). */
|
|
52
|
+
export interface ShishoFS {
|
|
53
|
+
/** Read file contents as ArrayBuffer. */
|
|
54
|
+
readFile(path: string): ArrayBuffer;
|
|
55
|
+
/** Read file contents as UTF-8 string. */
|
|
56
|
+
readTextFile(path: string): string;
|
|
57
|
+
/** Write ArrayBuffer data to a file. */
|
|
58
|
+
writeFile(path: string, data: ArrayBuffer): void;
|
|
59
|
+
/** Write string content to a file. */
|
|
60
|
+
writeTextFile(path: string, content: string): void;
|
|
61
|
+
/** Check if a path exists. */
|
|
62
|
+
exists(path: string): boolean;
|
|
63
|
+
/** Create a directory (and parents). */
|
|
64
|
+
mkdir(path: string): void;
|
|
65
|
+
/** List directory entries (file/dir names). */
|
|
66
|
+
listDir(path: string): string[];
|
|
67
|
+
/** Get a temporary directory path (auto-cleaned after hook returns). */
|
|
68
|
+
tempDir(): string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** ZIP archive operations. */
|
|
72
|
+
export interface ShishoArchive {
|
|
73
|
+
/** Extract all entries from a ZIP archive to a directory. */
|
|
74
|
+
extractZip(archivePath: string, destDir: string): void;
|
|
75
|
+
/** Create a ZIP archive from a directory's contents. */
|
|
76
|
+
createZip(srcDir: string, destPath: string): void;
|
|
77
|
+
/** Read a specific entry from a ZIP archive as ArrayBuffer. */
|
|
78
|
+
readZipEntry(archivePath: string, entryPath: string): ArrayBuffer;
|
|
79
|
+
/** List all entry paths in a ZIP archive. */
|
|
80
|
+
listZipEntries(archivePath: string): string[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A parsed XML element. */
|
|
84
|
+
export interface XMLElement {
|
|
85
|
+
/** Element tag name (local part). */
|
|
86
|
+
tag: string;
|
|
87
|
+
/** Element namespace URI. */
|
|
88
|
+
namespace: string;
|
|
89
|
+
/** Direct text content. */
|
|
90
|
+
text: string;
|
|
91
|
+
/** Element attributes. */
|
|
92
|
+
attributes: Record<string, string>;
|
|
93
|
+
/** Child elements. */
|
|
94
|
+
children: XMLElement[];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** XML parsing and querying. */
|
|
98
|
+
export interface ShishoXML {
|
|
99
|
+
/** Parse an XML string into an element tree. */
|
|
100
|
+
parse(content: string): XMLElement;
|
|
101
|
+
/** Find the first element matching a selector. Supports "prefix|tag" namespace syntax. */
|
|
102
|
+
querySelector(
|
|
103
|
+
doc: XMLElement,
|
|
104
|
+
selector: string,
|
|
105
|
+
namespaces?: Record<string, string>,
|
|
106
|
+
): XMLElement | null;
|
|
107
|
+
/** Find all elements matching a selector. Supports "prefix|tag" namespace syntax. */
|
|
108
|
+
querySelectorAll(
|
|
109
|
+
doc: XMLElement,
|
|
110
|
+
selector: string,
|
|
111
|
+
namespaces?: Record<string, string>,
|
|
112
|
+
): XMLElement[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Result from shisho.ffmpeg.run(). */
|
|
116
|
+
export interface FFmpegResult {
|
|
117
|
+
/** Process exit code (0 = success). */
|
|
118
|
+
exitCode: number;
|
|
119
|
+
/** Standard output. */
|
|
120
|
+
stdout: string;
|
|
121
|
+
/** Standard error. */
|
|
122
|
+
stderr: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** FFmpeg subprocess execution. */
|
|
126
|
+
export interface ShishoFFmpeg {
|
|
127
|
+
/** Run FFmpeg with the given arguments. Requires ffmpegAccess capability. */
|
|
128
|
+
run(args: string[]): FFmpegResult;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Top-level host API object available as the global `shisho` variable. */
|
|
132
|
+
export interface ShishoHostAPI {
|
|
133
|
+
log: ShishoLog;
|
|
134
|
+
config: ShishoConfig;
|
|
135
|
+
http: ShishoHTTP;
|
|
136
|
+
fs: ShishoFS;
|
|
137
|
+
archive: ShishoArchive;
|
|
138
|
+
xml: ShishoXML;
|
|
139
|
+
ffmpeg: ShishoFFmpeg;
|
|
140
|
+
}
|
package/index.d.ts
ADDED
package/manifest.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Input converter capability declaration. */
|
|
2
|
+
export interface InputConverterCap {
|
|
3
|
+
description?: string;
|
|
4
|
+
/** File extensions this converter accepts (e.g., ["mobi"]). */
|
|
5
|
+
sourceTypes: string[];
|
|
6
|
+
/** MIME types this converter accepts. */
|
|
7
|
+
mimeTypes?: string[];
|
|
8
|
+
/** Target file type to convert to (e.g., "epub"). */
|
|
9
|
+
targetType: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** File parser capability declaration. */
|
|
13
|
+
export interface FileParserCap {
|
|
14
|
+
description?: string;
|
|
15
|
+
/** File extensions this parser handles (e.g., ["pdf"]). */
|
|
16
|
+
types: string[];
|
|
17
|
+
/** MIME types this parser handles (e.g., ["application/pdf"]). */
|
|
18
|
+
mimeTypes?: string[];
|
|
19
|
+
}
|
|
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
|
+
/** Metadata enricher capability declaration. */
|
|
33
|
+
export interface MetadataEnricherCap {
|
|
34
|
+
description?: string;
|
|
35
|
+
/** File types this enricher applies to (e.g., ["epub", "cbz"]). */
|
|
36
|
+
fileTypes?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Custom identifier type declaration. */
|
|
40
|
+
export interface IdentifierTypeCap {
|
|
41
|
+
/** Unique identifier type ID (e.g., "goodreads"). */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Display name (e.g., "Goodreads"). */
|
|
44
|
+
name: string;
|
|
45
|
+
/** URL template with {value} placeholder. */
|
|
46
|
+
urlTemplate?: string;
|
|
47
|
+
/** Regex pattern for validation. */
|
|
48
|
+
pattern?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** HTTP access capability declaration. */
|
|
52
|
+
export interface HTTPAccessCap {
|
|
53
|
+
description?: string;
|
|
54
|
+
/** Allowed domains for HTTP requests. */
|
|
55
|
+
domains: string[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** File access capability declaration. */
|
|
59
|
+
export interface FileAccessCap {
|
|
60
|
+
/** Access level: "read" or "readwrite". */
|
|
61
|
+
level: "read" | "readwrite";
|
|
62
|
+
description?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** FFmpeg access capability declaration. */
|
|
66
|
+
export interface FFmpegAccessCap {
|
|
67
|
+
description?: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** All plugin capabilities. */
|
|
71
|
+
export interface Capabilities {
|
|
72
|
+
inputConverter?: InputConverterCap;
|
|
73
|
+
fileParser?: FileParserCap;
|
|
74
|
+
outputGenerator?: OutputGeneratorCap;
|
|
75
|
+
metadataEnricher?: MetadataEnricherCap;
|
|
76
|
+
identifierTypes?: IdentifierTypeCap[];
|
|
77
|
+
httpAccess?: HTTPAccessCap;
|
|
78
|
+
fileAccess?: FileAccessCap;
|
|
79
|
+
ffmpegAccess?: FFmpegAccessCap;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Option for select-type config fields. */
|
|
83
|
+
export interface SelectOption {
|
|
84
|
+
value: string;
|
|
85
|
+
label: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A single configuration field definition. */
|
|
89
|
+
export interface ConfigField {
|
|
90
|
+
/** Field type. */
|
|
91
|
+
type: "string" | "boolean" | "number" | "select" | "textarea";
|
|
92
|
+
/** Display label. */
|
|
93
|
+
label: string;
|
|
94
|
+
/** Help text description. */
|
|
95
|
+
description?: string;
|
|
96
|
+
/** Whether this field is required. */
|
|
97
|
+
required?: boolean;
|
|
98
|
+
/** Whether this field contains sensitive data. */
|
|
99
|
+
secret?: boolean;
|
|
100
|
+
/** Default value. */
|
|
101
|
+
default?: string | number | boolean;
|
|
102
|
+
/** Minimum value (number fields). */
|
|
103
|
+
min?: number;
|
|
104
|
+
/** Maximum value (number fields). */
|
|
105
|
+
max?: number;
|
|
106
|
+
/** Options (select fields). */
|
|
107
|
+
options?: SelectOption[];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Configuration schema mapping field keys to definitions. */
|
|
111
|
+
export interface ConfigSchema {
|
|
112
|
+
[key: string]: ConfigField;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Complete plugin manifest (manifest.json). */
|
|
116
|
+
export interface PluginManifest {
|
|
117
|
+
/** Must be 1. */
|
|
118
|
+
manifestVersion: 1;
|
|
119
|
+
/** Plugin identifier (e.g., "goodreads-metadata"). */
|
|
120
|
+
id: string;
|
|
121
|
+
/** Display name. */
|
|
122
|
+
name: string;
|
|
123
|
+
/** Semver version string. */
|
|
124
|
+
version: string;
|
|
125
|
+
description?: string;
|
|
126
|
+
author?: string;
|
|
127
|
+
homepage?: string;
|
|
128
|
+
license?: string;
|
|
129
|
+
/** Minimum Shisho version required. */
|
|
130
|
+
minShishoVersion?: string;
|
|
131
|
+
capabilities?: Capabilities;
|
|
132
|
+
configSchema?: ConfigSchema;
|
|
133
|
+
}
|
package/metadata.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** An author with optional role information. */
|
|
2
|
+
export interface ParsedAuthor {
|
|
3
|
+
/** Author name. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Role (empty for generic author, or one of: writer, penciller, inker, colorist, letterer, cover_artist, editor, translator). */
|
|
6
|
+
role?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** An identifier parsed from file metadata. */
|
|
10
|
+
export interface ParsedIdentifier {
|
|
11
|
+
/** Identifier type (e.g., isbn_10, isbn_13, asin, uuid, goodreads, google, other). */
|
|
12
|
+
type: string;
|
|
13
|
+
/** The identifier value. */
|
|
14
|
+
value: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A chapter parsed from file metadata. */
|
|
18
|
+
export interface ParsedChapter {
|
|
19
|
+
/** Chapter title. */
|
|
20
|
+
title: string;
|
|
21
|
+
/** CBZ: 0-indexed page number. */
|
|
22
|
+
startPage?: number;
|
|
23
|
+
/** M4B: milliseconds from start. */
|
|
24
|
+
startTimestampMs?: number;
|
|
25
|
+
/** EPUB: content document href. */
|
|
26
|
+
href?: string;
|
|
27
|
+
/** Nested child chapters (EPUB nesting only). */
|
|
28
|
+
children?: ParsedChapter[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Full metadata object returned by file parsers and metadata enrichers. */
|
|
32
|
+
export interface ParsedMetadata {
|
|
33
|
+
title?: string;
|
|
34
|
+
subtitle?: string;
|
|
35
|
+
authors?: ParsedAuthor[];
|
|
36
|
+
narrators?: string[];
|
|
37
|
+
series?: string;
|
|
38
|
+
seriesNumber?: number;
|
|
39
|
+
genres?: string[];
|
|
40
|
+
tags?: string[];
|
|
41
|
+
description?: string;
|
|
42
|
+
publisher?: string;
|
|
43
|
+
imprint?: string;
|
|
44
|
+
url?: string;
|
|
45
|
+
/** ISO 8601 date string (e.g., "2023-06-15T00:00:00Z"). */
|
|
46
|
+
releaseDate?: string;
|
|
47
|
+
/** MIME type of cover image (e.g., "image/jpeg"). */
|
|
48
|
+
coverMimeType?: string;
|
|
49
|
+
/** Cover image data as ArrayBuffer. */
|
|
50
|
+
coverData?: ArrayBuffer;
|
|
51
|
+
/** 0-indexed page number for CBZ cover. */
|
|
52
|
+
coverPage?: number;
|
|
53
|
+
/** Duration in seconds (float, M4B files). */
|
|
54
|
+
duration?: number;
|
|
55
|
+
/** Audio bitrate in bits per second (M4B files). */
|
|
56
|
+
bitrateBps?: number;
|
|
57
|
+
/** Number of pages (CBZ files). */
|
|
58
|
+
pageCount?: number;
|
|
59
|
+
identifiers?: ParsedIdentifier[];
|
|
60
|
+
chapters?: ParsedChapter[];
|
|
61
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shisho/plugin-types",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "TypeScript type definitions for Shisho plugin development",
|
|
5
|
+
"homepage": "https://github.com/shishobooks/shisho/blob/master/packages/plugin-types/README.md",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"*.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT"
|
|
11
|
+
}
|