dsh-pdf-mineru 0.2.0 → 0.2.2
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/CHANGELOG.md +48 -0
- package/README.md +89 -300
- package/assets/icon.svg +15 -0
- package/lib/client.js +2308 -2765
- package/lib/client.js.map +1 -1
- package/lib/index.js +6645 -6991
- package/lib/pdfjs-worker.mjs +40 -16
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +92 -73
- package/lib/types/adapters/dsh-document-source.d.ts +0 -16
- package/lib/types/client/DisclosureCard.d.ts +0 -15
- package/lib/types/client/NumericInput.d.ts +0 -23
- package/lib/types/client/SettingsPage.d.ts +0 -10
- package/lib/types/client/StorageOperations.d.ts +0 -10
- package/lib/types/client/helpers.d.ts +0 -27
- package/lib/types/client/icons.d.ts +0 -17
- package/lib/types/client/index.d.ts +0 -9
- package/lib/types/client/locales.d.ts +0 -4
- package/lib/types/client/sections/AdvancedSections.d.ts +0 -11
- package/lib/types/client/sections/DefaultsSection.d.ts +0 -12
- package/lib/types/client/sections/ProviderSection.d.ts +0 -24
- package/lib/types/config/migration-values.d.ts +0 -6
- package/lib/types/config/pure.d.ts +0 -94
- package/lib/types/config.d.ts +0 -34
- package/lib/types/domain/cache-key.d.ts +0 -7
- package/lib/types/domain/errors.d.ts +0 -20
- package/lib/types/domain/ids.d.ts +0 -20
- package/lib/types/domain/job.d.ts +0 -2
- package/lib/types/domain/request.d.ts +0 -90
- package/lib/types/domain/result.d.ts +0 -32
- package/lib/types/domain/schemas.d.ts +0 -33
- package/lib/types/index.d.ts +0 -20
- package/lib/types/loopback-rpc.d.ts +0 -8
- package/lib/types/observability.d.ts +0 -32
- package/lib/types/providers/http-client.d.ts +0 -48
- package/lib/types/providers/official-v4-types.d.ts +0 -55
- package/lib/types/providers/official-v4.d.ts +0 -20
- package/lib/types/providers/provider.d.ts +0 -139
- package/lib/types/providers/registry.d.ts +0 -15
- package/lib/types/providers/retry.d.ts +0 -66
- package/lib/types/providers/safe-zip.d.ts +0 -23
- package/lib/types/providers/self-hosted-legacy-v2.d.ts +0 -62
- package/lib/types/providers/self-hosted-v1.d.ts +0 -141
- package/lib/types/rpc.d.ts +0 -31
- package/lib/types/service/document-index.d.ts +0 -36
- package/lib/types/service/image-policy.d.ts +0 -11
- package/lib/types/service/mineru-service.d.ts +0 -88
- package/lib/types/service/page-renderer.d.ts +0 -64
- package/lib/types/service/pdfjs-backend.d.ts +0 -5
- package/lib/types/service/read-cursor.d.ts +0 -44
- package/lib/types/service/read-delivery.d.ts +0 -28
- package/lib/types/service/request-normalizer.d.ts +0 -13
- package/lib/types/service/result-presenter.d.ts +0 -197
- package/lib/types/service/shared-operations.d.ts +0 -47
- package/lib/types/storage/access-gate.d.ts +0 -40
- package/lib/types/storage/artifact-sink.d.ts +0 -24
- package/lib/types/storage/index.d.ts +0 -9
- package/lib/types/storage/maintenance-service.d.ts +0 -193
- package/lib/types/storage/paths.d.ts +0 -34
- package/lib/types/storage/process-lock.d.ts +0 -43
- package/lib/types/storage/result-repository.d.ts +0 -68
- package/lib/types/tools.d.ts +0 -29
- package/lib/types/utils/crypto.d.ts +0 -2
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { MinerUModel, ParseDefaults, ParseMethod } from '../domain/request.js';
|
|
2
|
-
import { type ProviderConfigId } from '../domain/ids.js';
|
|
3
|
-
/** Plugin configuration version, independent of upstream APIs and cached result schemas. */
|
|
4
|
-
export declare const MINERU_CONFIG_SCHEMA_VERSION: 3;
|
|
5
|
-
/** Parse tiers advertised by the MinerU 4.0+ self-hosted V1 API. */
|
|
6
|
-
export declare const SELF_HOSTED_TIERS: readonly ["flash", "basic", "standard", "advanced"];
|
|
7
|
-
export type SelfHostedTier = typeof SELF_HOSTED_TIERS[number];
|
|
8
|
-
export interface SelfHostedLegacyV2Config {
|
|
9
|
-
readonly id: ProviderConfigId;
|
|
10
|
-
readonly type: 'self-hosted-legacy-v2';
|
|
11
|
-
readonly baseURL: string;
|
|
12
|
-
readonly apiKeyEnv?: string;
|
|
13
|
-
readonly modelMap: Readonly<Record<MinerUModel, string>>;
|
|
14
|
-
readonly configuredVersion?: string;
|
|
15
|
-
readonly allowInsecureHttp: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface SelfHostedV1Config {
|
|
18
|
-
readonly id: ProviderConfigId;
|
|
19
|
-
readonly type: 'self-hosted-v1';
|
|
20
|
-
readonly baseURL: string;
|
|
21
|
-
readonly apiKeyEnv?: string;
|
|
22
|
-
readonly tier?: SelfHostedTier;
|
|
23
|
-
readonly ocrMode: ParseMethod;
|
|
24
|
-
readonly configuredVersion?: string;
|
|
25
|
-
readonly allowInsecureHttp: boolean;
|
|
26
|
-
}
|
|
27
|
-
export interface OfficialV4Config {
|
|
28
|
-
readonly id: ProviderConfigId;
|
|
29
|
-
readonly type: 'official-v4';
|
|
30
|
-
readonly baseURL: string;
|
|
31
|
-
readonly apiKeyEnv: string;
|
|
32
|
-
readonly models: readonly MinerUModel[];
|
|
33
|
-
readonly configuredVersion: 'v4';
|
|
34
|
-
}
|
|
35
|
-
export type ProviderConfig = SelfHostedV1Config | SelfHostedLegacyV2Config | OfficialV4Config;
|
|
36
|
-
export interface StorageConfig {
|
|
37
|
-
readonly storageRoot: string;
|
|
38
|
-
readonly cacheEnabled: boolean;
|
|
39
|
-
readonly retainSources: false;
|
|
40
|
-
readonly stagingTtlMs: number;
|
|
41
|
-
}
|
|
42
|
-
export interface PollingConfig {
|
|
43
|
-
readonly pollIntervalMs: number;
|
|
44
|
-
readonly pollTimeoutMs: number;
|
|
45
|
-
readonly requestTimeoutMs: number;
|
|
46
|
-
readonly operationTimeoutMs: number;
|
|
47
|
-
}
|
|
48
|
-
export interface RetryConfig {
|
|
49
|
-
readonly maxAttempts: number;
|
|
50
|
-
readonly baseDelayMs: number;
|
|
51
|
-
readonly maxDelayMs: number;
|
|
52
|
-
}
|
|
53
|
-
export interface OutputConfig {
|
|
54
|
-
/** Character budget (UTF-16 units) for one structured/prose read response, excluding image bytes. */
|
|
55
|
-
readonly maxInlineChars: number;
|
|
56
|
-
/** Maximum number of image attachments emitted by one read response. */
|
|
57
|
-
readonly maxInlineImages: number;
|
|
58
|
-
}
|
|
59
|
-
export declare const MIN_INLINE_IMAGE_BUDGET: 0;
|
|
60
|
-
export declare const MAX_INLINE_IMAGE_BUDGET: 100;
|
|
61
|
-
export interface SecurityLimits {
|
|
62
|
-
readonly maxFileBytes: number;
|
|
63
|
-
readonly maxApiResponseBytes: number;
|
|
64
|
-
readonly maxZipDownloadBytes: number;
|
|
65
|
-
readonly maxZipEntries: number;
|
|
66
|
-
readonly maxZipEntryBytes: number;
|
|
67
|
-
readonly maxZipTotalBytes: number;
|
|
68
|
-
readonly maxZipCompressionRatio: number;
|
|
69
|
-
}
|
|
70
|
-
export interface MinerUConfig {
|
|
71
|
-
readonly schemaVersion: typeof MINERU_CONFIG_SCHEMA_VERSION;
|
|
72
|
-
readonly activeProvider: ProviderConfigId;
|
|
73
|
-
readonly providers: readonly ProviderConfig[];
|
|
74
|
-
readonly defaults: ParseDefaults;
|
|
75
|
-
readonly storage: StorageConfig;
|
|
76
|
-
readonly polling: PollingConfig;
|
|
77
|
-
readonly retry: RetryConfig;
|
|
78
|
-
readonly output: OutputConfig;
|
|
79
|
-
readonly limits: SecurityLimits;
|
|
80
|
-
}
|
|
81
|
-
export declare function defaultProviderConfig(type: ProviderConfig['type']): ProviderConfig;
|
|
82
|
-
export declare function providerById(config: MinerUConfig, id: ProviderConfigId): ProviderConfig | undefined;
|
|
83
|
-
export declare const DEFAULT_PARSE_DEFAULTS: ParseDefaults;
|
|
84
|
-
/** V1 has no model/language/formula/table selectors; use stable internal sentinels for cache identity. */
|
|
85
|
-
export declare function effectiveParseDefaults(defaults: ParseDefaults, provider: ProviderConfig): ParseDefaults;
|
|
86
|
-
export declare const DEFAULT_POLLING_CONFIG: PollingConfig;
|
|
87
|
-
export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
88
|
-
export declare const DEFAULT_OUTPUT_CONFIG: OutputConfig;
|
|
89
|
-
export declare const DEFAULT_SECURITY_LIMITS: SecurityLimits;
|
|
90
|
-
export declare const DEFAULT_STORAGE_OPTIONS: {
|
|
91
|
-
cacheEnabled: boolean;
|
|
92
|
-
retainSources: false;
|
|
93
|
-
stagingTtlMs: number;
|
|
94
|
-
};
|
package/lib/types/config.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type MinerUConfig, type SelfHostedLegacyV2Config } from './config/pure.js';
|
|
2
|
-
export * from './config/pure.js';
|
|
3
|
-
export declare function defaultMinerUConfig(): MinerUConfig;
|
|
4
|
-
export interface SelfHostedProviderMigration {
|
|
5
|
-
readonly providerId: SelfHostedLegacyV2Config['id'];
|
|
6
|
-
readonly from: 'self-hosted-v2';
|
|
7
|
-
readonly to: 'self-hosted-legacy-v2';
|
|
8
|
-
/** V1-only fields removed when an old mixed profile is explicitly migrated to legacy. */
|
|
9
|
-
readonly removedFields: readonly 'tier'[];
|
|
10
|
-
}
|
|
11
|
-
export interface ConfigMigrationStep {
|
|
12
|
-
readonly from: number;
|
|
13
|
-
readonly to: number;
|
|
14
|
-
}
|
|
15
|
-
export interface ParsedMinerUConfig {
|
|
16
|
-
readonly config: MinerUConfig;
|
|
17
|
-
readonly migrated: boolean;
|
|
18
|
-
readonly migratedFrom?: 1 | 2;
|
|
19
|
-
/** Versionless Provider-based documents predate schema 3 and are interpreted as schema 2. */
|
|
20
|
-
readonly assumedVersion?: 2;
|
|
21
|
-
readonly migrationSteps?: readonly ConfigMigrationStep[];
|
|
22
|
-
/** Paths only: never record old values, credentials, endpoints or filesystem paths. */
|
|
23
|
-
readonly defaultedFields?: readonly string[];
|
|
24
|
-
readonly providerMigrations?: readonly SelfHostedProviderMigration[];
|
|
25
|
-
}
|
|
26
|
-
/** Parse startup/settings input, including known field and self-hosted profile migrations. */
|
|
27
|
-
export declare function parseConfigWithMigration(value: unknown): ParsedMinerUConfig;
|
|
28
|
-
/** Strict canonical parser for current-version edits; loading historical documents uses the migration entry point. */
|
|
29
|
-
export declare function parseConfig(value: unknown): MinerUConfig;
|
|
30
|
-
export declare function pruneConfigToDiff(next: MinerUConfig, base?: MinerUConfig): Record<string, unknown>;
|
|
31
|
-
export declare function detectBloatedSettingsOps(userSection: Record<string, unknown>, base?: MinerUConfig): Array<{
|
|
32
|
-
op: 'unset';
|
|
33
|
-
path: string[];
|
|
34
|
-
}>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type CacheKey } from './ids.js';
|
|
2
|
-
import { type CanonicalParseRequest, type CanonicalSourceFile } from './request.js';
|
|
3
|
-
export declare function canonicalJson(value: unknown): string;
|
|
4
|
-
export declare function computeCacheKey(request: CanonicalParseRequest, file: CanonicalSourceFile, providerCompatibilityKey: string, versions?: {
|
|
5
|
-
readonly cacheKey?: number;
|
|
6
|
-
readonly result?: number;
|
|
7
|
-
}): CacheKey;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { MinerUFileId } from './ids.js';
|
|
2
|
-
export type MinerUProviderId = 'self-hosted-v1' | 'self-hosted-legacy-v2' | 'official-v4';
|
|
3
|
-
export type MinerUErrorCode = 'INVALID_REQUEST' | 'FILE_NOT_FOUND' | 'FILE_TOO_LARGE' | 'UNSUPPORTED_OPTION' | 'CREDENTIAL_MISSING' | 'AUTHENTICATION_FAILED' | 'PROVIDER_UNAVAILABLE' | 'PROVIDER_CONFIG_MISSING' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_QUOTA_EXHAUSTED' | 'UPLOAD_FAILED' | 'REMOTE_PARSE_FAILED' | 'RESULT_NOT_READY' | 'RESULT_DOWNLOAD_FAILED' | 'RESULT_ARCHIVE_INVALID' | 'RESULT_TOO_LARGE' | 'CACHE_CORRUPT' | 'CACHE_CONFLICT' | 'CACHE_EVICTED' | 'INTERRUPTED_UPLOAD' | 'POLL_TIMEOUT' | 'CANCELLED' | 'UNAUTHENTICATED_SESSION' | 'JOB_NOT_FOUND' | 'STORAGE_LOCKED';
|
|
4
|
-
export interface MinerUFailure {
|
|
5
|
-
readonly code: MinerUErrorCode;
|
|
6
|
-
readonly message: string;
|
|
7
|
-
readonly retryable: boolean;
|
|
8
|
-
readonly provider?: MinerUProviderId;
|
|
9
|
-
readonly providerCode?: string;
|
|
10
|
-
readonly traceId?: string;
|
|
11
|
-
readonly fileId?: MinerUFileId;
|
|
12
|
-
}
|
|
13
|
-
export declare class MinerUError extends Error {
|
|
14
|
-
readonly failure: MinerUFailure;
|
|
15
|
-
constructor(failure: MinerUFailure, options?: ErrorOptions);
|
|
16
|
-
}
|
|
17
|
-
export declare function sanitizeDiagnostic(input: string, secrets?: readonly string[]): string;
|
|
18
|
-
export declare function failure(code: MinerUErrorCode, message: string, retryable?: boolean, details?: Omit<MinerUFailure, 'code' | 'message' | 'retryable'>): MinerUFailure;
|
|
19
|
-
export declare function toMinerUFailure(error: unknown, fallback?: MinerUErrorCode): MinerUFailure;
|
|
20
|
-
export declare function throwMinerU(code: MinerUErrorCode, message: string, retryable?: boolean): never;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type Brand<T, Name extends string> = T & {
|
|
2
|
-
readonly __brand: Name;
|
|
3
|
-
};
|
|
4
|
-
export type MinerUResultId = Brand<string, 'MinerUResultId'>;
|
|
5
|
-
export type MinerUFileId = Brand<string, 'MinerUFileId'>;
|
|
6
|
-
export type ProviderConfigId = Brand<string, 'ProviderConfigId'>;
|
|
7
|
-
export type CacheKey = Brand<string, 'CacheKey'>;
|
|
8
|
-
export type OperationId = Brand<string, 'OperationId'>;
|
|
9
|
-
export type SessionId = Brand<string, 'SessionId'>;
|
|
10
|
-
export declare function assertSafePathSegment(value: string, label: string): string;
|
|
11
|
-
export declare const asResultId: (value: string) => MinerUResultId;
|
|
12
|
-
export declare const asFileId: (value: string) => MinerUFileId;
|
|
13
|
-
export declare const asProviderConfigId: (value: string) => ProviderConfigId;
|
|
14
|
-
export declare const asOperationId: (value: string) => OperationId;
|
|
15
|
-
export declare function asSessionId(value: string): SessionId;
|
|
16
|
-
export declare function asCacheKey(value: string): CacheKey;
|
|
17
|
-
export declare const createOperationId: () => OperationId;
|
|
18
|
-
export declare function createFileId(sha256: string, index?: number): MinerUFileId;
|
|
19
|
-
export declare function resultIdForCacheKey(cacheKey: CacheKey): MinerUResultId;
|
|
20
|
-
export {};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { MinerUFileId } from './ids.js';
|
|
2
|
-
export declare const CANONICAL_PARSE_REQUEST_SCHEMA_VERSION: 1;
|
|
3
|
-
export declare const CACHE_KEY_SPEC_VERSION: 1;
|
|
4
|
-
export declare const RESULT_SCHEMA_VERSION: 1;
|
|
5
|
-
export declare const ARTIFACT_KINDS: readonly ["markdown", "layout", "model-output", "content-list", "images"];
|
|
6
|
-
export type ArtifactKind = typeof ARTIFACT_KINDS[number];
|
|
7
|
-
export type MinerUModel = 'pipeline' | 'vlm';
|
|
8
|
-
export type ParseMethod = 'auto' | 'txt' | 'ocr';
|
|
9
|
-
export declare const FOCUS_KINDS: readonly ["all", "text", "table", "image", "toc", "artifacts"];
|
|
10
|
-
export type FocusKind = typeof FOCUS_KINDS[number];
|
|
11
|
-
/** Public page selection: a single page, a range string, or an array of page numbers. */
|
|
12
|
-
export type PageSelection = number | string | readonly number[];
|
|
13
|
-
export interface ParseSemantics {
|
|
14
|
-
readonly model: MinerUModel;
|
|
15
|
-
readonly ocr: boolean;
|
|
16
|
-
/** Parse method remains explicit because txt and auto have different cache semantics. */
|
|
17
|
-
readonly parseMethod: ParseMethod;
|
|
18
|
-
readonly language: string;
|
|
19
|
-
readonly formula: boolean;
|
|
20
|
-
readonly table: boolean;
|
|
21
|
-
readonly pages?: string;
|
|
22
|
-
}
|
|
23
|
-
export interface CanonicalSourceFile {
|
|
24
|
-
readonly fileId: MinerUFileId;
|
|
25
|
-
readonly name: string;
|
|
26
|
-
readonly bytes: number;
|
|
27
|
-
readonly sha256: string;
|
|
28
|
-
}
|
|
29
|
-
export interface CanonicalParseRequest {
|
|
30
|
-
readonly schemaVersion: typeof CANONICAL_PARSE_REQUEST_SCHEMA_VERSION;
|
|
31
|
-
readonly files: readonly CanonicalSourceFile[];
|
|
32
|
-
readonly semantics: ParseSemantics;
|
|
33
|
-
readonly requiredArtifacts: readonly ArtifactKind[];
|
|
34
|
-
}
|
|
35
|
-
export interface PreparedSourceFile extends CanonicalSourceFile {
|
|
36
|
-
/** Ephemeral execution input. This field is never persisted. */
|
|
37
|
-
readonly path: string;
|
|
38
|
-
readonly fingerprint: {
|
|
39
|
-
readonly size: number;
|
|
40
|
-
readonly mtimeMs: number;
|
|
41
|
-
readonly device: number;
|
|
42
|
-
readonly inode: number;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export interface PreparedParseRequest {
|
|
46
|
-
readonly request: CanonicalParseRequest;
|
|
47
|
-
readonly sources: readonly PreparedSourceFile[];
|
|
48
|
-
}
|
|
49
|
-
export interface ReadCursorInput {
|
|
50
|
-
/** Opaque continuation token from a previous partial read. */
|
|
51
|
-
readonly cursor?: string;
|
|
52
|
-
/** Exact stable block identifier returned by read_pdf. */
|
|
53
|
-
readonly block_id?: string;
|
|
54
|
-
/** Case-insensitive literal search within the selected document blocks. */
|
|
55
|
-
readonly query?: string;
|
|
56
|
-
}
|
|
57
|
-
export interface ParseRequestInput extends ReadCursorInput {
|
|
58
|
-
readonly file_path?: string;
|
|
59
|
-
readonly model?: MinerUModel;
|
|
60
|
-
readonly ocr?: boolean;
|
|
61
|
-
readonly language?: string;
|
|
62
|
-
readonly formula?: boolean;
|
|
63
|
-
readonly table?: boolean;
|
|
64
|
-
readonly pages?: PageSelection;
|
|
65
|
-
readonly focus?: FocusKind | readonly FocusKind[];
|
|
66
|
-
readonly artifacts?: readonly ArtifactKind[];
|
|
67
|
-
readonly inline_images?: boolean;
|
|
68
|
-
readonly poll_timeout_ms?: number;
|
|
69
|
-
}
|
|
70
|
-
export interface ParseDefaults {
|
|
71
|
-
readonly model: MinerUModel;
|
|
72
|
-
readonly ocr: boolean;
|
|
73
|
-
readonly parseMethod: ParseMethod;
|
|
74
|
-
readonly language: string;
|
|
75
|
-
readonly formula: boolean;
|
|
76
|
-
readonly table: boolean;
|
|
77
|
-
}
|
|
78
|
-
export declare function normalizePageRanges(input: string): string;
|
|
79
|
-
export interface PageNarrowing {
|
|
80
|
-
readonly pagesSet: Set<number> | undefined;
|
|
81
|
-
readonly pagesLabel: string;
|
|
82
|
-
/** Pages requested but outside 1..totalPages; reported, never silently replaced. */
|
|
83
|
-
readonly outOfRange: readonly number[];
|
|
84
|
-
/** True when the request asked for pages but none overlap the document. */
|
|
85
|
-
readonly fullyOutOfRange: boolean;
|
|
86
|
-
}
|
|
87
|
-
export declare function narrowPageSelection(requested: ReadonlySet<number> | undefined, totalPages: number | undefined): PageNarrowing;
|
|
88
|
-
export declare function normalizePageSelection(input: unknown): Set<number> | undefined;
|
|
89
|
-
export declare function normalizeFocusSelection(input: unknown): Set<FocusKind>;
|
|
90
|
-
export declare function normalizeArtifactKinds(kinds: readonly ArtifactKind[]): readonly ArtifactKind[];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { CacheKey, MinerUFileId, MinerUResultId, ProviderConfigId } from './ids.js';
|
|
2
|
-
import type { MinerUProviderId } from './errors.js';
|
|
3
|
-
import type { ArtifactKind, CanonicalParseRequest } from './request.js';
|
|
4
|
-
export declare const MINERU_RESULT_MANIFEST_SCHEMA_VERSION: 1;
|
|
5
|
-
export interface ArtifactRef {
|
|
6
|
-
readonly kind: ArtifactKind | 'manifest';
|
|
7
|
-
readonly relativePath: string;
|
|
8
|
-
readonly mediaType: string;
|
|
9
|
-
readonly bytes: number;
|
|
10
|
-
readonly sha256: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ParsedDocumentManifest {
|
|
13
|
-
readonly fileId: MinerUFileId;
|
|
14
|
-
readonly name: string;
|
|
15
|
-
readonly artifacts: readonly ArtifactRef[];
|
|
16
|
-
}
|
|
17
|
-
export interface ResultProducer {
|
|
18
|
-
readonly providerId: MinerUProviderId;
|
|
19
|
-
readonly providerConfigId: ProviderConfigId;
|
|
20
|
-
readonly compatibilityKey: string;
|
|
21
|
-
}
|
|
22
|
-
/** A published manifest is one immutable source-file result. */
|
|
23
|
-
export interface MinerUResultManifest {
|
|
24
|
-
readonly schemaVersion: typeof MINERU_RESULT_MANIFEST_SCHEMA_VERSION;
|
|
25
|
-
readonly id: MinerUResultId;
|
|
26
|
-
readonly cacheKey: CacheKey;
|
|
27
|
-
readonly sourceSha256: string;
|
|
28
|
-
readonly request: CanonicalParseRequest;
|
|
29
|
-
readonly producer: ResultProducer;
|
|
30
|
-
readonly files: readonly [ParsedDocumentManifest];
|
|
31
|
-
readonly createdAt: number;
|
|
32
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* schemas.ts — Strict runtime parsers and validators for persistent domain JSON records.
|
|
3
|
-
*
|
|
4
|
-
* Enforces:
|
|
5
|
-
* - Pinned schemaVersion validation (unknown versions rejected)
|
|
6
|
-
* - Closed record shapes (additional/unknown properties rejected)
|
|
7
|
-
* - Safe, branded identifier validation
|
|
8
|
-
* - Clean POSIX relative paths for artifact references (rejection of traversal, absolute paths, NUL, backslashes)
|
|
9
|
-
* - Elimination of local source paths, tokens, query parameters, presigned/CDN URLs from persistent records
|
|
10
|
-
*/
|
|
11
|
-
import { type ArtifactKind, type CanonicalParseRequest, type CanonicalSourceFile, type MinerUModel, type ParseMethod, type ParseSemantics } from './request.js';
|
|
12
|
-
import { type ArtifactRef, type ParsedDocumentManifest, type ResultProducer, type MinerUResultManifest } from './result.js';
|
|
13
|
-
import type { MinerUProviderId } from './errors.js';
|
|
14
|
-
export declare const VALID_MODELS: Set<MinerUModel>;
|
|
15
|
-
export declare const VALID_PARSE_METHODS: Set<ParseMethod>;
|
|
16
|
-
export declare const VALID_PROVIDERS: Set<MinerUProviderId>;
|
|
17
|
-
export declare const VALID_ARTIFACT_KINDS: Set<"markdown" | "layout" | "model-output" | "content-list" | "images">;
|
|
18
|
-
export declare function assertPlainObject(value: unknown, label: string): Record<string, unknown>;
|
|
19
|
-
export declare function assertNoAdditionalProperties(record: Record<string, unknown>, allowedKeys: readonly string[], label: string): void;
|
|
20
|
-
export declare function assertNonEmptyString(value: unknown, label: string): string;
|
|
21
|
-
export declare function assertNonNegativeSafeInteger(value: unknown, label: string): number;
|
|
22
|
-
export declare function assertSha256(value: unknown, label?: string): string;
|
|
23
|
-
export declare function assertNoUrlOrSecret(value: string, label: string): string;
|
|
24
|
-
export declare function assertSafeFileName(value: unknown, label?: string): string;
|
|
25
|
-
export declare function assertSafeArtifactRelativePath(value: unknown, label?: string): string;
|
|
26
|
-
export declare function parseArtifactKind(input: unknown): ArtifactKind;
|
|
27
|
-
export declare function parseParseSemantics(input: unknown): ParseSemantics;
|
|
28
|
-
export declare function parseCanonicalSourceFile(input: unknown): CanonicalSourceFile;
|
|
29
|
-
export declare function parseCanonicalParseRequest(input: unknown): CanonicalParseRequest;
|
|
30
|
-
export declare function parseArtifactRef(input: unknown): ArtifactRef;
|
|
31
|
-
export declare function parseParsedDocumentManifest(input: unknown): ParsedDocumentManifest;
|
|
32
|
-
export declare function parseResultProducer(input: unknown): ResultProducer;
|
|
33
|
-
export declare function parseMinerUResultManifest(input: unknown): MinerUResultManifest;
|
package/lib/types/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import z from '@deepseek-ai/schemastery';
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
export declare const name = "dsh-pdf-mineru";
|
|
4
|
-
export declare const inject: string[];
|
|
5
|
-
export declare const Config: z<unknown>;
|
|
6
|
-
export declare function apply(ctx: Context, entryConfig?: unknown): Promise<() => Promise<void>>;
|
|
7
|
-
export * from './config.js';
|
|
8
|
-
export * from './domain/ids.js';
|
|
9
|
-
export * from './domain/request.js';
|
|
10
|
-
export * from './domain/result.js';
|
|
11
|
-
export { parseMinerUResultManifest } from './domain/schemas.js';
|
|
12
|
-
export * from './domain/errors.js';
|
|
13
|
-
export * from './providers/provider.js';
|
|
14
|
-
export * from './providers/self-hosted-legacy-v2.js';
|
|
15
|
-
export * from './providers/self-hosted-v1.js';
|
|
16
|
-
export * from './providers/official-v4.js';
|
|
17
|
-
export * from './providers/http-client.js';
|
|
18
|
-
export * from './service/mineru-service.js';
|
|
19
|
-
export * from './observability.js';
|
|
20
|
-
export * from './storage/maintenance-service.js';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
-
import type { ConnectionRpcHandler } from '@deepseek-ai/dsh-client-connection';
|
|
3
|
-
/**
|
|
4
|
-
* Retain channel-local loopback policy on 0.2.0-rc.2, whose native rpc.handle no longer
|
|
5
|
-
* accepts an authority option. Only this caller's route registration is wrapped;
|
|
6
|
-
* the real Connection still owns authentication, envelopes, and cancellation.
|
|
7
|
-
*/
|
|
8
|
-
export declare function registerLoopbackRpc(ctx: Context, channel: string, handler: ConnectionRpcHandler): () => Promise<void>;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { MinerUErrorCode, MinerUProviderId } from './domain/errors.js';
|
|
2
|
-
import type { ProviderRetryOperation } from './providers/retry.js';
|
|
3
|
-
export type MinerUDiagnosticLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
4
|
-
export type MinerUDiagnosticPhase = 'job-created' | 'cache-hit' | 'shared-operation' | 'uploading' | 'provider-accepted' | 'processing' | 'collecting' | 'published' | 'provider-retry' | 'failed';
|
|
5
|
-
export interface MinerUDiagnosticEvent {
|
|
6
|
-
readonly level: MinerUDiagnosticLevel;
|
|
7
|
-
readonly phase: MinerUDiagnosticPhase;
|
|
8
|
-
readonly provider?: MinerUProviderId;
|
|
9
|
-
readonly jobId?: string;
|
|
10
|
-
readonly operationId?: string;
|
|
11
|
-
readonly providerOperation?: ProviderRetryOperation;
|
|
12
|
-
readonly durationMs?: number;
|
|
13
|
-
readonly bytes?: number;
|
|
14
|
-
readonly cacheHit?: boolean;
|
|
15
|
-
readonly waiterCount?: number;
|
|
16
|
-
readonly errorCode?: MinerUErrorCode;
|
|
17
|
-
readonly retryable?: boolean;
|
|
18
|
-
readonly attempt?: number;
|
|
19
|
-
readonly maxAttempts?: number;
|
|
20
|
-
readonly delayMs?: number;
|
|
21
|
-
readonly status?: number;
|
|
22
|
-
readonly reason?: 'transport' | 'http-status';
|
|
23
|
-
}
|
|
24
|
-
export type MinerUDiagnosticSink = (event: MinerUDiagnosticEvent) => void;
|
|
25
|
-
export interface MinerUStructuredLogger {
|
|
26
|
-
debug(...args: unknown[]): void;
|
|
27
|
-
info(...args: unknown[]): void;
|
|
28
|
-
warn(...args: unknown[]): void;
|
|
29
|
-
error(...args: unknown[]): void;
|
|
30
|
-
}
|
|
31
|
-
export declare function createStructuredDiagnosticSink(logger: MinerUStructuredLogger): MinerUDiagnosticSink;
|
|
32
|
-
export declare function emitDiagnostic(sink: MinerUDiagnosticSink | undefined, event: MinerUDiagnosticEvent): void;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { MinerUError } from '../domain/errors.js';
|
|
2
|
-
import type { MinerUProviderId } from '../domain/errors.js';
|
|
3
|
-
import type { ProviderCallContext } from './provider.js';
|
|
4
|
-
import { type ProviderRetryOperation, type ProviderRetryOptions } from './retry.js';
|
|
5
|
-
export declare function validateSelfHostedBaseURL(rawUrl: string, allowInsecureHttp?: boolean): URL;
|
|
6
|
-
export interface ProviderHttpClientOptions {
|
|
7
|
-
readonly baseURL: URL | string;
|
|
8
|
-
readonly provider: MinerUProviderId;
|
|
9
|
-
readonly defaultRetry?: ProviderRetryOptions;
|
|
10
|
-
readonly providerLabel?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface JsonRequestOptions<T = unknown> {
|
|
13
|
-
readonly method?: string;
|
|
14
|
-
readonly path: string;
|
|
15
|
-
readonly body?: BodyInit;
|
|
16
|
-
readonly headers?: Record<string, string>;
|
|
17
|
-
readonly context: ProviderCallContext;
|
|
18
|
-
readonly acceptedStatuses?: readonly number[];
|
|
19
|
-
readonly operation?: ProviderRetryOperation;
|
|
20
|
-
readonly retry?: boolean;
|
|
21
|
-
readonly validateResponse?: (parsed: Record<string, unknown>, response: Response) => T | void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Resolves a request path against a base URL, preserving pathname prefix if any.
|
|
25
|
-
*/
|
|
26
|
-
export declare function resolveProviderUrl(baseUrl: URL | string, path: string): string;
|
|
27
|
-
/**
|
|
28
|
-
* Extracts human-readable error messages from an API response body.
|
|
29
|
-
* Inspects JSON fields detail, message, error, msg (prioritizing msg for official-v4, detail for self-hosted),
|
|
30
|
-
* or falls back to truncated raw text for non-JSON bodies.
|
|
31
|
-
*/
|
|
32
|
-
export declare function extractErrorMessage(bodyText: string, provider?: MinerUProviderId): string | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Maps HTTP error status codes to typed MinerUError instances with provider-specific diagnostic phrasing.
|
|
35
|
-
*/
|
|
36
|
-
export declare function createHttpStatusError(provider: MinerUProviderId, status: number, diagnostic: string, retryAfterMs?: number): MinerUError;
|
|
37
|
-
/**
|
|
38
|
-
* Reusable HTTP client for MinerU providers encapsulating request setup, credential injection,
|
|
39
|
-
* timeout management, error body extraction, status code mapping, and bounded retries.
|
|
40
|
-
*/
|
|
41
|
-
export declare class ProviderHttpClient {
|
|
42
|
-
readonly baseUrl: URL;
|
|
43
|
-
readonly provider: MinerUProviderId;
|
|
44
|
-
readonly defaultRetry: ProviderRetryOptions;
|
|
45
|
-
readonly providerLabel: string;
|
|
46
|
-
constructor(options: ProviderHttpClientOptions);
|
|
47
|
-
requestJson<T>(opts: JsonRequestOptions<T>): Promise<T>;
|
|
48
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { MinerUFileId } from '../domain/ids.js';
|
|
2
|
-
export interface OfficialV4BatchFileItem {
|
|
3
|
-
readonly name: string;
|
|
4
|
-
readonly data_id: string;
|
|
5
|
-
readonly is_ocr?: boolean;
|
|
6
|
-
readonly enable_formula?: boolean;
|
|
7
|
-
readonly enable_table?: boolean;
|
|
8
|
-
readonly language?: string;
|
|
9
|
-
readonly page_ranges?: string;
|
|
10
|
-
readonly layout_model?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface OfficialV4BatchSubmitRequest {
|
|
13
|
-
readonly files: readonly OfficialV4BatchFileItem[];
|
|
14
|
-
readonly model_version?: string;
|
|
15
|
-
readonly extra_formats?: readonly string[];
|
|
16
|
-
readonly no_cache?: boolean;
|
|
17
|
-
readonly cache_tolerance?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface OfficialV4BatchSubmitData {
|
|
20
|
-
readonly batch_id: string;
|
|
21
|
-
readonly file_urls: readonly string[];
|
|
22
|
-
}
|
|
23
|
-
export interface OfficialV4ApiResponse<T> {
|
|
24
|
-
readonly code: number | string;
|
|
25
|
-
readonly msg: string;
|
|
26
|
-
readonly trace_id?: string;
|
|
27
|
-
readonly data?: T;
|
|
28
|
-
}
|
|
29
|
-
export interface OfficialV4ExtractProgressObject {
|
|
30
|
-
readonly extracted_pages?: number;
|
|
31
|
-
readonly total_pages?: number;
|
|
32
|
-
}
|
|
33
|
-
export interface OfficialV4ExtractResultItem {
|
|
34
|
-
readonly data_id?: string;
|
|
35
|
-
readonly file_name?: string;
|
|
36
|
-
readonly state: string;
|
|
37
|
-
readonly full_zip_url?: string;
|
|
38
|
-
readonly err_msg?: string;
|
|
39
|
-
readonly extract_progress?: OfficialV4ExtractProgressObject | number | null | unknown;
|
|
40
|
-
}
|
|
41
|
-
export interface OfficialV4ExtractResultsData {
|
|
42
|
-
readonly batch_id: string;
|
|
43
|
-
readonly extract_result?: readonly OfficialV4ExtractResultItem[];
|
|
44
|
-
}
|
|
45
|
-
export interface SafeZipLimits {
|
|
46
|
-
readonly maxZipEntries: number;
|
|
47
|
-
readonly maxZipEntryBytes: number;
|
|
48
|
-
readonly maxZipTotalBytes: number;
|
|
49
|
-
readonly maxZipCompressionRatio: number;
|
|
50
|
-
}
|
|
51
|
-
export interface ExtractZipTargetFile {
|
|
52
|
-
readonly fileId: MinerUFileId;
|
|
53
|
-
readonly dataId: string;
|
|
54
|
-
readonly name: string;
|
|
55
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CanonicalParseRequest, PreparedSourceFile } from '../domain/request.js';
|
|
2
|
-
import { type ArtifactSink, type MinerUProvider, type ProviderCallContext, type ProviderCapabilities, type ProviderCollection, type ProviderCompatibilityContext, type ProviderJobRef, type ProviderJobSnapshot, type ProviderOptions, type ProviderProbeResult, type ProviderSubmission } from './provider.js';
|
|
3
|
-
import type { OfficialV4Config } from '../config.js';
|
|
4
|
-
export declare class OfficialV4Provider implements MinerUProvider {
|
|
5
|
-
readonly id: "official-v4";
|
|
6
|
-
readonly config: OfficialV4Config;
|
|
7
|
-
readonly capabilities: ProviderCapabilities;
|
|
8
|
-
private readonly parsedBaseUrl;
|
|
9
|
-
private readonly retryOptions;
|
|
10
|
-
private readonly client;
|
|
11
|
-
constructor(config: OfficialV4Config, options?: ProviderOptions);
|
|
12
|
-
compatibilityKey(request: CanonicalParseRequest, context: ProviderCompatibilityContext): Promise<string>;
|
|
13
|
-
probe(context: ProviderCallContext): Promise<ProviderProbeResult>;
|
|
14
|
-
submit(request: CanonicalParseRequest, sources: readonly PreparedSourceFile[], context: ProviderCallContext): Promise<ProviderSubmission>;
|
|
15
|
-
inspect(ref: ProviderJobRef, context: ProviderCallContext): Promise<ProviderJobSnapshot>;
|
|
16
|
-
collect(ref: ProviderJobRef, request: CanonicalParseRequest, sink: ArtifactSink, context: ProviderCallContext): Promise<ProviderCollection>;
|
|
17
|
-
private requestJson;
|
|
18
|
-
private barePutStream;
|
|
19
|
-
private downloadZipToTemporary;
|
|
20
|
-
}
|