@yuchaocheng/yusijia 0.1.0-beta.1

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.
@@ -0,0 +1,70 @@
1
+ import { z } from 'zod';
2
+ export declare const hashSchema: z.ZodString;
3
+ export declare const candidateSchema: z.ZodObject<{
4
+ localCandidateId: z.ZodString;
5
+ contentHash: z.ZodString;
6
+ relativePathHash: z.ZodString;
7
+ originalName: z.ZodString;
8
+ mimeType: z.ZodEnum<{
9
+ "image/jpeg": "image/jpeg";
10
+ "image/png": "image/png";
11
+ "image/webp": "image/webp";
12
+ }>;
13
+ fileSize: z.ZodNumber;
14
+ status: z.ZodEnum<{
15
+ SELECTED: "SELECTED";
16
+ ALTERNATE: "ALTERNATE";
17
+ EXCLUDED: "EXCLUDED";
18
+ NEEDS_REVIEW: "NEEDS_REVIEW";
19
+ }>;
20
+ takenAt: z.ZodOptional<z.ZodISODateTime>;
21
+ gpsLatitude: z.ZodOptional<z.ZodNumber>;
22
+ gpsLongitude: z.ZodOptional<z.ZodNumber>;
23
+ width: z.ZodOptional<z.ZodNumber>;
24
+ height: z.ZodOptional<z.ZodNumber>;
25
+ deviceModel: z.ZodOptional<z.ZodString>;
26
+ groupKey: z.ZodOptional<z.ZodString>;
27
+ perceptualHash: z.ZodOptional<z.ZodString>;
28
+ recommendationScore: z.ZodOptional<z.ZodNumber>;
29
+ recommendationReason: z.ZodOptional<z.ZodString>;
30
+ exclusionReason: z.ZodOptional<z.ZodString>;
31
+ }, z.core.$strict>;
32
+ export declare const manifestSchema: z.ZodObject<{
33
+ schemaVersion: z.ZodLiteral<1>;
34
+ sourceType: z.ZodEnum<{
35
+ DIRECTORY: "DIRECTORY";
36
+ ZIP: "ZIP";
37
+ }>;
38
+ sourceLabel: z.ZodOptional<z.ZodString>;
39
+ candidates: z.ZodArray<z.ZodObject<{
40
+ localCandidateId: z.ZodString;
41
+ contentHash: z.ZodString;
42
+ relativePathHash: z.ZodString;
43
+ originalName: z.ZodString;
44
+ mimeType: z.ZodEnum<{
45
+ "image/jpeg": "image/jpeg";
46
+ "image/png": "image/png";
47
+ "image/webp": "image/webp";
48
+ }>;
49
+ fileSize: z.ZodNumber;
50
+ status: z.ZodEnum<{
51
+ SELECTED: "SELECTED";
52
+ ALTERNATE: "ALTERNATE";
53
+ EXCLUDED: "EXCLUDED";
54
+ NEEDS_REVIEW: "NEEDS_REVIEW";
55
+ }>;
56
+ takenAt: z.ZodOptional<z.ZodISODateTime>;
57
+ gpsLatitude: z.ZodOptional<z.ZodNumber>;
58
+ gpsLongitude: z.ZodOptional<z.ZodNumber>;
59
+ width: z.ZodOptional<z.ZodNumber>;
60
+ height: z.ZodOptional<z.ZodNumber>;
61
+ deviceModel: z.ZodOptional<z.ZodString>;
62
+ groupKey: z.ZodOptional<z.ZodString>;
63
+ perceptualHash: z.ZodOptional<z.ZodString>;
64
+ recommendationScore: z.ZodOptional<z.ZodNumber>;
65
+ recommendationReason: z.ZodOptional<z.ZodString>;
66
+ exclusionReason: z.ZodOptional<z.ZodString>;
67
+ }, z.core.$strict>>;
68
+ }, z.core.$strict>;
69
+ export type Candidate = z.infer<typeof candidateSchema>;
70
+ export type Manifest = z.infer<typeof manifestSchema>;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { LIMITS } from './core.js';
3
+ export const hashSchema = z.string().regex(/^[a-f0-9]{64}$/);
4
+ export const candidateSchema = z.object({
5
+ localCandidateId: z.string().min(1).max(100).regex(/^[a-zA-Z0-9_-]+$/), contentHash: hashSchema, relativePathHash: hashSchema,
6
+ originalName: z.string().min(1).max(500),
7
+ mimeType: z.enum(['image/jpeg', 'image/png', 'image/webp']), fileSize: z.number().int().min(1).max(LIMITS.maxFileBytes),
8
+ status: z.enum(['SELECTED', 'ALTERNATE', 'EXCLUDED', 'NEEDS_REVIEW']),
9
+ takenAt: z.iso.datetime().optional(), gpsLatitude: z.number().min(-90).max(90).optional(), gpsLongitude: z.number().min(-180).max(180).optional(),
10
+ width: z.number().int().positive().max(100000).optional(), height: z.number().int().positive().max(100000).optional(),
11
+ deviceModel: z.string().max(255).optional(), groupKey: z.string().max(100).optional(), perceptualHash: z.string().max(128).optional(),
12
+ recommendationScore: z.number().min(0).max(100).optional(), recommendationReason: z.string().max(2000).optional(),
13
+ exclusionReason: z.string().max(2000).optional(),
14
+ }).strict().refine(c => (c.gpsLatitude === undefined) === (c.gpsLongitude === undefined), 'GPS must be paired');
15
+ export const manifestSchema = z.object({
16
+ schemaVersion: z.literal(1), sourceType: z.enum(['DIRECTORY', 'ZIP']), sourceLabel: z.string().max(255).optional(),
17
+ candidates: z.array(candidateSchema).min(1).max(LIMITS.maxCandidates),
18
+ }).strict().refine(m => new Set(m.candidates.map(c => c.localCandidateId)).size === m.candidates.length && new Set(m.candidates.map(c => c.contentHash)).size === m.candidates.length, 'Duplicate candidates');