zotero-bridge 1.1.1 → 1.1.3
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-en.md +426 -324
- package/README.md +424 -323
- package/dist/database.js +4 -4
- package/dist/index.js +38 -22
- package/dist/index.js.map +1 -1
- package/dist/pdf.d.ts.map +1 -1
- package/dist/pdf.js +3 -2
- package/dist/pdf.js.map +1 -1
- package/dist/tools.d.ts +78 -164
- package/dist/tools.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/database.ts +4 -4
- package/src/index.ts +39 -23
- package/src/pdf.ts +3 -2
package/src/index.ts
CHANGED
|
@@ -533,52 +533,68 @@ async function main() {
|
|
|
533
533
|
console.error(`Database: ${db.getPath()}`);
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
// Helper function to convert Zod type to JSON Schema
|
|
537
|
-
function zodToJsonSchema(zodType:
|
|
538
|
-
//
|
|
539
|
-
|
|
540
|
-
|
|
536
|
+
// Helper function to convert Zod type to JSON Schema (Zod v4 compatible)
|
|
537
|
+
function zodToJsonSchema(zodType: any): Record<string, any> {
|
|
538
|
+
// Get the type name from _zod property or check type directly
|
|
539
|
+
const typeName = zodType?._zod?.def?.type || zodType?.constructor?.name || '';
|
|
540
|
+
|
|
541
|
+
// Unwrap optional types
|
|
542
|
+
if (typeName === 'optional' || zodType instanceof z.ZodOptional) {
|
|
543
|
+
const inner = zodType._zod?.def?.innerType || zodType._def?.innerType;
|
|
544
|
+
if (inner) return zodToJsonSchema(inner);
|
|
541
545
|
}
|
|
542
|
-
|
|
543
|
-
|
|
546
|
+
|
|
547
|
+
// Unwrap default types
|
|
548
|
+
if (typeName === 'default' || zodType instanceof z.ZodDefault) {
|
|
549
|
+
const inner = zodType._zod?.def?.innerType || zodType._def?.innerType;
|
|
550
|
+
if (inner) return zodToJsonSchema(inner);
|
|
544
551
|
}
|
|
545
|
-
|
|
546
|
-
|
|
552
|
+
|
|
553
|
+
// Unwrap nullable types
|
|
554
|
+
if (typeName === 'nullable' || zodType instanceof z.ZodNullable) {
|
|
555
|
+
const inner = zodType._zod?.def?.innerType || zodType._def?.innerType;
|
|
556
|
+
if (inner) return zodToJsonSchema(inner);
|
|
547
557
|
}
|
|
548
558
|
|
|
549
559
|
// Handle basic types
|
|
550
|
-
if (zodType instanceof z.ZodString) {
|
|
560
|
+
if (typeName === 'string' || zodType instanceof z.ZodString) {
|
|
551
561
|
return { type: 'string' };
|
|
552
562
|
}
|
|
553
|
-
if (zodType instanceof z.ZodNumber) {
|
|
563
|
+
if (typeName === 'number' || zodType instanceof z.ZodNumber) {
|
|
554
564
|
return { type: 'number' };
|
|
555
565
|
}
|
|
556
|
-
if (zodType instanceof z.ZodBoolean) {
|
|
566
|
+
if (typeName === 'boolean' || zodType instanceof z.ZodBoolean) {
|
|
557
567
|
return { type: 'boolean' };
|
|
558
568
|
}
|
|
559
569
|
|
|
560
|
-
// Handle enum types
|
|
561
|
-
if (zodType instanceof z.ZodEnum) {
|
|
562
|
-
|
|
570
|
+
// Handle enum types (Zod v4 uses 'entries' instead of 'values')
|
|
571
|
+
if (typeName === 'enum' || zodType instanceof z.ZodEnum) {
|
|
572
|
+
const enumValues = zodType._zod?.def?.entries
|
|
573
|
+
|| zodType._def?.values
|
|
574
|
+
|| Object.keys(zodType._zod?.def?.entries || {});
|
|
575
|
+
return { type: 'string', enum: Array.isArray(enumValues) ? enumValues : Object.keys(enumValues) };
|
|
563
576
|
}
|
|
564
577
|
|
|
565
578
|
// Handle array types
|
|
566
|
-
if (zodType instanceof z.ZodArray) {
|
|
567
|
-
const elementType = zodType._def
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
579
|
+
if (typeName === 'array' || zodType instanceof z.ZodArray) {
|
|
580
|
+
const elementType = zodType._zod?.def?.element || zodType._def?.type;
|
|
581
|
+
if (elementType) {
|
|
582
|
+
const itemSchema = zodToJsonSchema(elementType);
|
|
583
|
+
if (Object.keys(itemSchema).length === 0) {
|
|
584
|
+
return { type: 'array', items: { type: 'string' } };
|
|
585
|
+
}
|
|
586
|
+
return { type: 'array', items: itemSchema };
|
|
571
587
|
}
|
|
572
|
-
return { type: 'array', items:
|
|
588
|
+
return { type: 'array', items: { type: 'string' } };
|
|
573
589
|
}
|
|
574
590
|
|
|
575
591
|
// Handle object types
|
|
576
|
-
if (zodType instanceof z.ZodObject) {
|
|
592
|
+
if (typeName === 'object' || zodType instanceof z.ZodObject) {
|
|
577
593
|
return { type: 'object' };
|
|
578
594
|
}
|
|
579
595
|
|
|
580
596
|
// Handle ZodAny
|
|
581
|
-
if (zodType instanceof z.ZodAny) {
|
|
597
|
+
if (typeName === 'any' || zodType instanceof z.ZodAny) {
|
|
582
598
|
return {};
|
|
583
599
|
}
|
|
584
600
|
|
package/src/pdf.ts
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
import { readFileSync, existsSync } from 'fs';
|
|
10
10
|
import { join } from 'path';
|
|
11
|
-
//
|
|
12
|
-
import
|
|
11
|
+
// pdf-parse v2.x uses named export
|
|
12
|
+
import * as pdfParseModule from 'pdf-parse';
|
|
13
|
+
const pdfParse = (pdfParseModule as any).default || pdfParseModule;
|
|
13
14
|
import { ZoteroDatabase } from './database.js';
|
|
14
15
|
|
|
15
16
|
export interface PDFContent {
|