@zlooks.cn/images-shared 1.0.1 → 1.0.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/dist/events/image-unavailable.d.ts.map +1 -1
- package/dist/events/image-unavailable.js.map +1 -1
- package/dist/events/image-upload-failed.d.ts.map +1 -1
- package/dist/events/image-upload-failed.js.map +1 -1
- package/dist/images.d.ts +173 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +132 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/micro.d.ts +289 -0
- package/dist/micro.d.ts.map +1 -0
- package/dist/micro.js +87 -0
- package/dist/micro.js.map +1 -0
- package/package.json +6 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-unavailable.d.ts","sourceRoot":"","sources":["../../src/events/image-unavailable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,6BAA6B,oCAAoC,CAAC;AAC/E,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;mBAA4E,CAAC;AAC7F,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"image-unavailable.d.ts","sourceRoot":"","sources":["../../src/events/image-unavailable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,6BAA6B,oCAAoC,CAAC;AAC/E,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;mBAA4E,CAAC;AAC7F,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;GAIjC,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,OAAO,6BAA6B,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC,CAAA;AACjH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAEhF;AACD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAC,GAC3E,iBAAiB,CAEnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-unavailable.js","sourceRoot":"","sources":["../../src/events/image-unavailable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAErE,MAAM,CAAC,MAAM,6BAA6B,GAAG,iCAAiC,CAAC;AAC/E,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,mCAAmC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC7F,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"image-unavailable.js","sourceRoot":"","sources":["../../src/events/image-unavailable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AAErE,MAAM,CAAC,MAAM,6BAA6B,GAAG,iCAAiC,CAAC;AAC/E,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,mCAAmC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC7F,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CACnD,6BAA6B,EAC7B,UAAU,EACV,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CACxB,CAAC;AAEF,MAAM,UAAU,0BAA0B,CAAC,KAAc;IACvD,OAAO,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AACD,MAAM,UAAU,4BAA4B,CAC1C,MAAqB,EACrB,OAA4E;IAE5E,OAAO,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-upload-failed.d.ts","sourceRoot":"","sources":["../../src/events/image-upload-failed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,+BAA+B,sCAAsC,CAAC;AACnF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;mBAA6E,CAAC;AAC9F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"image-upload-failed.d.ts","sourceRoot":"","sources":["../../src/events/image-upload-failed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACrG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,+BAA+B,sCAAsC,CAAC;AACnF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;mBAA6E,CAAC;AAC9F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;GAIlC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,OAAO,+BAA+B,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC,CAAA;AACpH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB,CAElF;AACD,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,mBAAmB,CAAC,UAAU,CAAC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,GAC5E,iBAAiB,CAEnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-upload-failed.js","sourceRoot":"","sources":["../../src/events/image-upload-failed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,CAAC,MAAM,+BAA+B,GAAG,mCAAmC,CAAC;AACnF,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9F,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"image-upload-failed.js","sourceRoot":"","sources":["../../src/events/image-upload-failed.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oCAAoC,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,CAAC,MAAM,+BAA+B,GAAG,mCAAmC,CAAC;AACnF,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,oCAAoC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9F,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CACpD,+BAA+B,EAC/B,UAAU,EACV,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CACxB,CAAC;AAEF,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,OAAO,sBAAsB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7C,CAAC;AACD,MAAM,UAAU,6BAA6B,CAC3C,MAAqB,EACrB,OAA6E;IAE7E,OAAO,MAAM,CAAC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC"}
|
package/dist/images.d.ts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const IMAGE_MAX_BYTES: number;
|
|
3
|
+
export declare const BASE64_MAX_BYTES: number;
|
|
4
|
+
export declare const imageMediaTypeSchema: z.ZodEnum<{
|
|
5
|
+
"image/avif": "image/avif";
|
|
6
|
+
"image/gif": "image/gif";
|
|
7
|
+
"image/jpeg": "image/jpeg";
|
|
8
|
+
"image/png": "image/png";
|
|
9
|
+
"image/webp": "image/webp";
|
|
10
|
+
}>;
|
|
11
|
+
export declare const imageStatusSchema: z.ZodEnum<{
|
|
12
|
+
deleted: "deleted";
|
|
13
|
+
deleting: "deleting";
|
|
14
|
+
failed: "failed";
|
|
15
|
+
ready: "ready";
|
|
16
|
+
uploading: "uploading";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const imageOperationErrorCodeSchema: z.ZodEnum<{
|
|
19
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
20
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
21
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
22
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
23
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
24
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
25
|
+
INVALID_PATH: "INVALID_PATH";
|
|
26
|
+
NOT_FOUND: "NOT_FOUND";
|
|
27
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
28
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const imageOperationFailureSchema: z.ZodObject<{
|
|
31
|
+
outcome: z.ZodLiteral<"error">;
|
|
32
|
+
code: z.ZodEnum<{
|
|
33
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
34
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
35
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
36
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
37
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
38
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
39
|
+
INVALID_PATH: "INVALID_PATH";
|
|
40
|
+
NOT_FOUND: "NOT_FOUND";
|
|
41
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
42
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
43
|
+
}>;
|
|
44
|
+
message: z.ZodString;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
export declare const uploadImageSchema: z.ZodObject<{
|
|
47
|
+
idempotencyKey: z.ZodString;
|
|
48
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
49
|
+
source: z.ZodLiteral<"base64">;
|
|
50
|
+
base64: z.ZodString;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
export declare const readImageSchema: z.ZodObject<{
|
|
53
|
+
id: z.ZodUUID;
|
|
54
|
+
}, z.core.$strict>;
|
|
55
|
+
export declare const deleteImageSchema: z.ZodObject<{
|
|
56
|
+
id: z.ZodUUID;
|
|
57
|
+
expectedSha256: z.ZodString;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
export declare const listImageSchema: z.ZodObject<{
|
|
60
|
+
createdFrom: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
|
|
61
|
+
createdTo: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
|
|
62
|
+
mediaTypes: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
63
|
+
"image/avif": "image/avif";
|
|
64
|
+
"image/gif": "image/gif";
|
|
65
|
+
"image/jpeg": "image/jpeg";
|
|
66
|
+
"image/png": "image/png";
|
|
67
|
+
"image/webp": "image/webp";
|
|
68
|
+
}>>, z.ZodTransform<("image/avif" | "image/gif" | "image/jpeg" | "image/png" | "image/webp")[], ("image/avif" | "image/gif" | "image/jpeg" | "image/png" | "image/webp")[]>>>;
|
|
69
|
+
filenameContains: z.ZodOptional<z.ZodString>;
|
|
70
|
+
minBytes: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
minWidth: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
maxWidth: z.ZodOptional<z.ZodNumber>;
|
|
74
|
+
minHeight: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
maxHeight: z.ZodOptional<z.ZodNumber>;
|
|
76
|
+
statuses: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
77
|
+
deleted: "deleted";
|
|
78
|
+
deleting: "deleting";
|
|
79
|
+
failed: "failed";
|
|
80
|
+
ready: "ready";
|
|
81
|
+
uploading: "uploading";
|
|
82
|
+
}>>>, z.ZodTransform<("deleted" | "deleting" | "failed" | "ready" | "uploading")[], ("deleted" | "deleting" | "failed" | "ready" | "uploading")[]>>;
|
|
83
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
84
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
85
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
86
|
+
asc: "asc";
|
|
87
|
+
desc: "desc";
|
|
88
|
+
}>>;
|
|
89
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
90
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strict>;
|
|
92
|
+
export declare const imageMetadataSchema: z.ZodObject<{
|
|
93
|
+
id: z.ZodUUID;
|
|
94
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
95
|
+
status: z.ZodEnum<{
|
|
96
|
+
deleted: "deleted";
|
|
97
|
+
deleting: "deleting";
|
|
98
|
+
failed: "failed";
|
|
99
|
+
ready: "ready";
|
|
100
|
+
uploading: "uploading";
|
|
101
|
+
}>;
|
|
102
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
103
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
104
|
+
"image/avif": "image/avif";
|
|
105
|
+
"image/gif": "image/gif";
|
|
106
|
+
"image/jpeg": "image/jpeg";
|
|
107
|
+
"image/png": "image/png";
|
|
108
|
+
"image/webp": "image/webp";
|
|
109
|
+
}>>;
|
|
110
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
111
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
112
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
113
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
114
|
+
createdBy: z.ZodString;
|
|
115
|
+
createdAt: z.ZodISODateTime;
|
|
116
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
117
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
118
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
119
|
+
}, z.core.$strict>;
|
|
120
|
+
export declare const imagePageSchema: z.ZodObject<{
|
|
121
|
+
items: z.ZodArray<z.ZodObject<{
|
|
122
|
+
id: z.ZodUUID;
|
|
123
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
124
|
+
status: z.ZodEnum<{
|
|
125
|
+
deleted: "deleted";
|
|
126
|
+
deleting: "deleting";
|
|
127
|
+
failed: "failed";
|
|
128
|
+
ready: "ready";
|
|
129
|
+
uploading: "uploading";
|
|
130
|
+
}>;
|
|
131
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
132
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
133
|
+
"image/avif": "image/avif";
|
|
134
|
+
"image/gif": "image/gif";
|
|
135
|
+
"image/jpeg": "image/jpeg";
|
|
136
|
+
"image/png": "image/png";
|
|
137
|
+
"image/webp": "image/webp";
|
|
138
|
+
}>>;
|
|
139
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
140
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
141
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
142
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
143
|
+
createdBy: z.ZodString;
|
|
144
|
+
createdAt: z.ZodISODateTime;
|
|
145
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
146
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
147
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
148
|
+
}, z.core.$strict>>;
|
|
149
|
+
hasMore: z.ZodBoolean;
|
|
150
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
151
|
+
}, z.core.$strict>;
|
|
152
|
+
export declare const imageUploadCommandSchema: z.ZodObject<{
|
|
153
|
+
actor: z.ZodString;
|
|
154
|
+
upload: z.ZodObject<{
|
|
155
|
+
idempotencyKey: z.ZodString;
|
|
156
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
157
|
+
source: z.ZodLiteral<"base64">;
|
|
158
|
+
base64: z.ZodString;
|
|
159
|
+
}, z.core.$strict>;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
export declare const imageEmptyRequestSchema: z.ZodObject<{}, z.core.$strict>;
|
|
162
|
+
export type ListImageInput = z.infer<typeof listImageSchema>;
|
|
163
|
+
export type ListImageQuery = z.input<typeof listImageSchema>;
|
|
164
|
+
export type ListImageRequest = ListImageQuery;
|
|
165
|
+
export type ReadImageInput = z.infer<typeof readImageSchema>;
|
|
166
|
+
export type UploadImageInput = z.infer<typeof uploadImageSchema>;
|
|
167
|
+
export type DeleteImageInput = z.infer<typeof deleteImageSchema>;
|
|
168
|
+
export type ImageUploadCommand = z.infer<typeof imageUploadCommandSchema>;
|
|
169
|
+
export type ImageMetadata = z.infer<typeof imageMetadataSchema>;
|
|
170
|
+
export type ImagePage = z.infer<typeof imagePageSchema>;
|
|
171
|
+
export type ImageOperationErrorCode = z.infer<typeof imageOperationErrorCodeSchema>;
|
|
172
|
+
export type ImageOperationFailure = z.infer<typeof imageOperationFailureSchema>;
|
|
173
|
+
//# sourceMappingURL=images.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.d.ts","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,QAAmB,CAAC;AAChD,eAAO,MAAM,gBAAgB,QAAkB,CAAC;AAChD,eAAO,MAAM,oBAAoB;;;;;;EAM/B,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;EAAkE,CAAC;AACjG,eAAO,MAAM,6BAA6B;;;;;;;;;;;EAWxC,CAAC;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;kBAItC,CAAC;AAUH,eAAO,MAAM,iBAAiB;;;;;kBAU5B,CAAC;AACH,eAAO,MAAM,eAAe;;kBAE1B,CAAC;AACH,eAAO,MAAM,iBAAiB;;;kBAE5B,CAAC;AAIH,eAAO,MAAM,eAAe;;;;;;;;;;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BYTES = 20 * 1024 * 1024;
|
|
3
|
+
export const BASE64_MAX_BYTES = 6 * 1024 * 1024;
|
|
4
|
+
export const imageMediaTypeSchema = z.enum([
|
|
5
|
+
'image/jpeg',
|
|
6
|
+
'image/png',
|
|
7
|
+
'image/webp',
|
|
8
|
+
'image/gif',
|
|
9
|
+
'image/avif',
|
|
10
|
+
]);
|
|
11
|
+
export const imageStatusSchema = z.enum(['uploading', 'ready', 'failed', 'deleting', 'deleted']);
|
|
12
|
+
export const imageOperationErrorCodeSchema = z.enum([
|
|
13
|
+
'HASH_CONFLICT',
|
|
14
|
+
'IDEMPOTENCY_CONFLICT',
|
|
15
|
+
'IMAGE_TOO_LARGE',
|
|
16
|
+
'INVALID_BASE64',
|
|
17
|
+
'INVALID_CURSOR',
|
|
18
|
+
'INVALID_IMAGE',
|
|
19
|
+
'INVALID_PATH',
|
|
20
|
+
'NOT_FOUND',
|
|
21
|
+
'STATE_CONFLICT',
|
|
22
|
+
'UPLOAD_NOT_READY',
|
|
23
|
+
]);
|
|
24
|
+
export const imageOperationFailureSchema = z.strictObject({
|
|
25
|
+
outcome: z.literal('error'),
|
|
26
|
+
code: imageOperationErrorCodeSchema,
|
|
27
|
+
message: z.string().trim().min(1).max(500),
|
|
28
|
+
});
|
|
29
|
+
const idempotencyKey = z.string()
|
|
30
|
+
.min(1)
|
|
31
|
+
.max(128)
|
|
32
|
+
.regex(/^[a-zA-Z0-9._:-]+$/)
|
|
33
|
+
.describe('调用方为一次上传指定的稳定键,1..128 字符,仅字母、数字、点、下划线、冒号和连字符。同一调用方重试相同请求使用原键;不同输入不能复用该键。确认 failed 后新上传使用新键。');
|
|
34
|
+
const filename = z.string().trim().min(1).max(200)
|
|
35
|
+
.refine((value) => !/[\x00-\x1f\x7f/\\]/.test(value), '文件名不得包含路径或控制字符');
|
|
36
|
+
export const uploadImageSchema = z.strictObject({
|
|
37
|
+
idempotencyKey,
|
|
38
|
+
filename: filename.optional().describe('可选原始文件名,用于元数据和搜索,不决定存储路径。'),
|
|
39
|
+
source: z.literal('base64').describe('提交调用方持有的图片字节,使用 Base64 编码;不接受 URL、文件路径或远程导入。'),
|
|
40
|
+
base64: z.string()
|
|
41
|
+
.min(4)
|
|
42
|
+
.max(Math.ceil(BASE64_MAX_BYTES / 3) * 4)
|
|
43
|
+
.regex(/^[A-Za-z0-9+/]*={0,2}$/)
|
|
44
|
+
.refine((value) => value.length % 4 === 0, 'Invalid Base64 length')
|
|
45
|
+
.describe(`将原图的完整文件字节编码为规范标准 Base64。字符仅 A-Z、a-z、0-9、+、/;仅末尾可使用 = 填充,必要填充不能省略,总长度必须是 4 的倍数。不含空格、换行或 data: 前缀;不接受 URL-safe 编码。解码后原图最多 6 MiB(${BASE64_MAX_BYTES} 字节),编码文本最多 ${Math.ceil(BASE64_MAX_BYTES / 3) * 4} 个字符。必须提交完整编码,不能截断、使用省略号或手工猜测补齐。`),
|
|
46
|
+
});
|
|
47
|
+
export const readImageSchema = z.strictObject({
|
|
48
|
+
id: z.uuid().describe('不可变图片 UUID,不是文件路径或公开 URL。'),
|
|
49
|
+
});
|
|
50
|
+
export const deleteImageSchema = readImageSchema.extend({
|
|
51
|
+
expectedSha256: z.string().regex(/^[a-f0-9]{64}$/).describe('最后读取元数据得到的 64 位小写十六进制 SHA-256。'),
|
|
52
|
+
});
|
|
53
|
+
const timestamp = z.iso.datetime({ offset: true }).transform((value) => new Date(value).toISOString());
|
|
54
|
+
const nonnegativeInt = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
55
|
+
const positiveInt = nonnegativeInt.min(1);
|
|
56
|
+
export const listImageSchema = z.strictObject({
|
|
57
|
+
createdFrom: timestamp.optional().describe('创建时间起点(包含)。'),
|
|
58
|
+
createdTo: timestamp.optional().describe('创建时间终点(不包含)。'),
|
|
59
|
+
mediaTypes: z.array(imageMediaTypeSchema)
|
|
60
|
+
.min(1)
|
|
61
|
+
.max(5)
|
|
62
|
+
.transform((value) => [...new Set(value)].sort())
|
|
63
|
+
.optional()
|
|
64
|
+
.describe('真实图片 MIME type。'),
|
|
65
|
+
filenameContains: z.string().trim().min(1).max(200).optional().describe('原始文件名包含文本,忽略大小写。'),
|
|
66
|
+
minBytes: nonnegativeInt.optional().describe('原始文件字节数下界。'),
|
|
67
|
+
maxBytes: nonnegativeInt.optional().describe('原始文件字节数上界。'),
|
|
68
|
+
minWidth: positiveInt.optional().describe('宽度像素下界。'),
|
|
69
|
+
maxWidth: positiveInt.optional().describe('宽度像素上界。'),
|
|
70
|
+
minHeight: positiveInt.optional().describe('高度像素下界。'),
|
|
71
|
+
maxHeight: positiveInt.optional().describe('高度像素上界。'),
|
|
72
|
+
statuses: z.array(imageStatusSchema)
|
|
73
|
+
.min(1)
|
|
74
|
+
.max(5)
|
|
75
|
+
.default(['uploading', 'ready', 'failed', 'deleting'])
|
|
76
|
+
.transform((value) => [...new Set(value)].sort())
|
|
77
|
+
.describe('状态集合,省略时排除 deleted。'),
|
|
78
|
+
createdBy: z.string().min(1).max(128).optional().describe('创建者业务审计标识。'),
|
|
79
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/).optional().describe('原始内容 SHA-256。'),
|
|
80
|
+
order: z.enum(['asc', 'desc']).default('desc').describe('按创建时间排序。'),
|
|
81
|
+
limit: z.number().int().min(1).max(100).default(20).describe('单页条数。'),
|
|
82
|
+
cursor: z.string().min(1).max(2048).optional().describe('将上次结果的 nextCursor 原样传入。'),
|
|
83
|
+
}).superRefine((value, ctx) => {
|
|
84
|
+
const ranges = [
|
|
85
|
+
['minBytes', 'maxBytes'],
|
|
86
|
+
['minWidth', 'maxWidth'],
|
|
87
|
+
['minHeight', 'maxHeight'],
|
|
88
|
+
];
|
|
89
|
+
for (const [lower, upper] of ranges) {
|
|
90
|
+
if (value[lower] !== undefined && value[upper] !== undefined && value[lower] > value[upper]) {
|
|
91
|
+
ctx.addIssue({
|
|
92
|
+
code: 'custom',
|
|
93
|
+
path: [upper],
|
|
94
|
+
message: '最大值不得小于最小值',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (value.createdFrom && value.createdTo && value.createdFrom >= value.createdTo) {
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: 'custom',
|
|
101
|
+
path: ['createdTo'],
|
|
102
|
+
message: '结束时间必须晚于开始时间',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
export const imageMetadataSchema = z.strictObject({
|
|
107
|
+
id: z.uuid().describe('不可变图片 ID。'),
|
|
108
|
+
originalFilename: z.string().max(200).nullable().describe('上传时的原始文件名;未提供时为 null。'),
|
|
109
|
+
status: imageStatusSchema.describe('图片生命周期状态。'),
|
|
110
|
+
url: z.url().nullable().describe('仅 ready 状态返回公开原图 URL。'),
|
|
111
|
+
mediaType: imageMediaTypeSchema.nullable().describe('服务检测的真实 MIME type。'),
|
|
112
|
+
byteSize: z.number().int().min(1).max(IMAGE_MAX_BYTES).nullable().describe('原始文件字节数。'),
|
|
113
|
+
width: z.number().int().positive().nullable().describe('图片宽度像素。'),
|
|
114
|
+
height: z.number().int().positive().nullable().describe('图片高度像素。'),
|
|
115
|
+
sha256: z.string().regex(/^[a-f0-9]{64}$/).nullable().describe('原始字节 SHA-256。'),
|
|
116
|
+
createdBy: z.string().min(1).max(128).describe('创建者业务审计标识。'),
|
|
117
|
+
createdAt: z.iso.datetime().describe('数据库记录创建时间。'),
|
|
118
|
+
readyAt: z.iso.datetime().nullable().describe('原图就绪时间。'),
|
|
119
|
+
deletedAt: z.iso.datetime().nullable().describe('持久删除完成时间。'),
|
|
120
|
+
failureCode: z.string().max(64).nullable().describe('安全失败码;无失败时为 null。'),
|
|
121
|
+
});
|
|
122
|
+
export const imagePageSchema = z.strictObject({
|
|
123
|
+
items: z.array(imageMetadataSchema).max(100).describe('当前页图片元数据。'),
|
|
124
|
+
hasMore: z.boolean().describe('是否还有下一页。'),
|
|
125
|
+
nextCursor: z.string().min(1).max(2048).nullable().describe('下一页游标;没有下一页时为 null。'),
|
|
126
|
+
});
|
|
127
|
+
export const imageUploadCommandSchema = z.strictObject({
|
|
128
|
+
actor: z.string().trim().min(1).max(128),
|
|
129
|
+
upload: uploadImageSchema,
|
|
130
|
+
});
|
|
131
|
+
export const imageEmptyRequestSchema = z.strictObject({});
|
|
132
|
+
//# sourceMappingURL=images.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"images.js","sourceRoot":"","sources":["../src/images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IACzC,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;AACjG,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,IAAI,CAAC;IAClD,eAAe;IACf,sBAAsB;IACtB,iBAAiB;IACjB,gBAAgB;IAChB,gBAAgB;IAChB,eAAe;IACf,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,kBAAkB;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,YAAY,CAAC;IACxD,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IAC3B,IAAI,EAAE,6BAA6B;IACnC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAA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|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC"}
|
package/dist/micro.d.ts
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { type MicroCallOptions, type MicroCaller, type MicroClient } from '@hile/micro-contract';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { IMAGES_EVENT_CATALOG } from './events/catalog.js';
|
|
4
|
+
import { imageOperationFailureSchema, type DeleteImageInput, type ImageMetadata, type ImagePage, type ImageUploadCommand, type ListImageQuery, type ReadImageInput } from './images.js';
|
|
5
|
+
export declare class ImagesOperationError extends Error {
|
|
6
|
+
readonly code: z.infer<typeof imageOperationFailureSchema>['code'];
|
|
7
|
+
constructor(code: z.infer<typeof imageOperationFailureSchema>['code'], message: string);
|
|
8
|
+
}
|
|
9
|
+
export declare const imagesMicroContract: Readonly<{
|
|
10
|
+
namespace: string;
|
|
11
|
+
operations: Readonly<{
|
|
12
|
+
upload: {
|
|
13
|
+
readonly path: "/images/upload";
|
|
14
|
+
readonly input: z.ZodObject<{
|
|
15
|
+
actor: z.ZodString;
|
|
16
|
+
upload: z.ZodObject<{
|
|
17
|
+
idempotencyKey: z.ZodString;
|
|
18
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
19
|
+
source: z.ZodLiteral<"base64">;
|
|
20
|
+
base64: z.ZodString;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
readonly output: z.ZodUnion<readonly [z.ZodObject<{
|
|
24
|
+
id: z.ZodUUID;
|
|
25
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
26
|
+
status: z.ZodEnum<{
|
|
27
|
+
deleted: "deleted";
|
|
28
|
+
deleting: "deleting";
|
|
29
|
+
failed: "failed";
|
|
30
|
+
ready: "ready";
|
|
31
|
+
uploading: "uploading";
|
|
32
|
+
}>;
|
|
33
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
34
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
35
|
+
"image/avif": "image/avif";
|
|
36
|
+
"image/gif": "image/gif";
|
|
37
|
+
"image/jpeg": "image/jpeg";
|
|
38
|
+
"image/png": "image/png";
|
|
39
|
+
"image/webp": "image/webp";
|
|
40
|
+
}>>;
|
|
41
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
43
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
44
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
45
|
+
createdBy: z.ZodString;
|
|
46
|
+
createdAt: z.ZodISODateTime;
|
|
47
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
48
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
49
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
50
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
51
|
+
outcome: z.ZodLiteral<"error">;
|
|
52
|
+
code: z.ZodEnum<{
|
|
53
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
54
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
55
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
56
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
57
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
58
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
59
|
+
INVALID_PATH: "INVALID_PATH";
|
|
60
|
+
NOT_FOUND: "NOT_FOUND";
|
|
61
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
62
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
63
|
+
}>;
|
|
64
|
+
message: z.ZodString;
|
|
65
|
+
}, z.core.$strict>]>;
|
|
66
|
+
};
|
|
67
|
+
list: {
|
|
68
|
+
readonly path: "/images/list";
|
|
69
|
+
readonly input: z.ZodObject<{
|
|
70
|
+
createdFrom: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
|
|
71
|
+
createdTo: z.ZodOptional<z.ZodPipe<z.ZodISODateTime, z.ZodTransform<string, string>>>;
|
|
72
|
+
mediaTypes: z.ZodOptional<z.ZodPipe<z.ZodArray<z.ZodEnum<{
|
|
73
|
+
"image/avif": "image/avif";
|
|
74
|
+
"image/gif": "image/gif";
|
|
75
|
+
"image/jpeg": "image/jpeg";
|
|
76
|
+
"image/png": "image/png";
|
|
77
|
+
"image/webp": "image/webp";
|
|
78
|
+
}>>, z.ZodTransform<("image/avif" | "image/gif" | "image/jpeg" | "image/png" | "image/webp")[], ("image/avif" | "image/gif" | "image/jpeg" | "image/png" | "image/webp")[]>>>;
|
|
79
|
+
filenameContains: z.ZodOptional<z.ZodString>;
|
|
80
|
+
minBytes: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
maxBytes: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
minWidth: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
maxWidth: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
minHeight: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
maxHeight: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
statuses: z.ZodPipe<z.ZodDefault<z.ZodArray<z.ZodEnum<{
|
|
87
|
+
deleted: "deleted";
|
|
88
|
+
deleting: "deleting";
|
|
89
|
+
failed: "failed";
|
|
90
|
+
ready: "ready";
|
|
91
|
+
uploading: "uploading";
|
|
92
|
+
}>>>, z.ZodTransform<("deleted" | "deleting" | "failed" | "ready" | "uploading")[], ("deleted" | "deleting" | "failed" | "ready" | "uploading")[]>>;
|
|
93
|
+
createdBy: z.ZodOptional<z.ZodString>;
|
|
94
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
95
|
+
order: z.ZodDefault<z.ZodEnum<{
|
|
96
|
+
asc: "asc";
|
|
97
|
+
desc: "desc";
|
|
98
|
+
}>>;
|
|
99
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, z.core.$strict>;
|
|
102
|
+
readonly output: z.ZodUnion<readonly [z.ZodObject<{
|
|
103
|
+
items: z.ZodArray<z.ZodObject<{
|
|
104
|
+
id: z.ZodUUID;
|
|
105
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
106
|
+
status: z.ZodEnum<{
|
|
107
|
+
deleted: "deleted";
|
|
108
|
+
deleting: "deleting";
|
|
109
|
+
failed: "failed";
|
|
110
|
+
ready: "ready";
|
|
111
|
+
uploading: "uploading";
|
|
112
|
+
}>;
|
|
113
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
114
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
115
|
+
"image/avif": "image/avif";
|
|
116
|
+
"image/gif": "image/gif";
|
|
117
|
+
"image/jpeg": "image/jpeg";
|
|
118
|
+
"image/png": "image/png";
|
|
119
|
+
"image/webp": "image/webp";
|
|
120
|
+
}>>;
|
|
121
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
122
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
123
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
124
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
125
|
+
createdBy: z.ZodString;
|
|
126
|
+
createdAt: z.ZodISODateTime;
|
|
127
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
128
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
129
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
hasMore: z.ZodBoolean;
|
|
132
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
133
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
134
|
+
outcome: z.ZodLiteral<"error">;
|
|
135
|
+
code: z.ZodEnum<{
|
|
136
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
137
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
138
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
139
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
140
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
141
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
142
|
+
INVALID_PATH: "INVALID_PATH";
|
|
143
|
+
NOT_FOUND: "NOT_FOUND";
|
|
144
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
145
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
146
|
+
}>;
|
|
147
|
+
message: z.ZodString;
|
|
148
|
+
}, z.core.$strict>]>;
|
|
149
|
+
};
|
|
150
|
+
read: {
|
|
151
|
+
readonly path: "/images/read";
|
|
152
|
+
readonly input: z.ZodObject<{
|
|
153
|
+
id: z.ZodUUID;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
readonly output: z.ZodUnion<readonly [z.ZodObject<{
|
|
156
|
+
id: z.ZodUUID;
|
|
157
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
158
|
+
status: z.ZodEnum<{
|
|
159
|
+
deleted: "deleted";
|
|
160
|
+
deleting: "deleting";
|
|
161
|
+
failed: "failed";
|
|
162
|
+
ready: "ready";
|
|
163
|
+
uploading: "uploading";
|
|
164
|
+
}>;
|
|
165
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
166
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
167
|
+
"image/avif": "image/avif";
|
|
168
|
+
"image/gif": "image/gif";
|
|
169
|
+
"image/jpeg": "image/jpeg";
|
|
170
|
+
"image/png": "image/png";
|
|
171
|
+
"image/webp": "image/webp";
|
|
172
|
+
}>>;
|
|
173
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
174
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
175
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
176
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
177
|
+
createdBy: z.ZodString;
|
|
178
|
+
createdAt: z.ZodISODateTime;
|
|
179
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
180
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
181
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
182
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
183
|
+
outcome: z.ZodLiteral<"error">;
|
|
184
|
+
code: z.ZodEnum<{
|
|
185
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
186
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
187
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
188
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
189
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
190
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
191
|
+
INVALID_PATH: "INVALID_PATH";
|
|
192
|
+
NOT_FOUND: "NOT_FOUND";
|
|
193
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
194
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
195
|
+
}>;
|
|
196
|
+
message: z.ZodString;
|
|
197
|
+
}, z.core.$strict>]>;
|
|
198
|
+
};
|
|
199
|
+
delete: {
|
|
200
|
+
readonly path: "/images/delete";
|
|
201
|
+
readonly input: z.ZodObject<{
|
|
202
|
+
id: z.ZodUUID;
|
|
203
|
+
expectedSha256: z.ZodString;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
readonly output: z.ZodUnion<readonly [z.ZodObject<{
|
|
206
|
+
id: z.ZodUUID;
|
|
207
|
+
originalFilename: z.ZodNullable<z.ZodString>;
|
|
208
|
+
status: z.ZodEnum<{
|
|
209
|
+
deleted: "deleted";
|
|
210
|
+
deleting: "deleting";
|
|
211
|
+
failed: "failed";
|
|
212
|
+
ready: "ready";
|
|
213
|
+
uploading: "uploading";
|
|
214
|
+
}>;
|
|
215
|
+
url: z.ZodNullable<z.ZodURL>;
|
|
216
|
+
mediaType: z.ZodNullable<z.ZodEnum<{
|
|
217
|
+
"image/avif": "image/avif";
|
|
218
|
+
"image/gif": "image/gif";
|
|
219
|
+
"image/jpeg": "image/jpeg";
|
|
220
|
+
"image/png": "image/png";
|
|
221
|
+
"image/webp": "image/webp";
|
|
222
|
+
}>>;
|
|
223
|
+
byteSize: z.ZodNullable<z.ZodNumber>;
|
|
224
|
+
width: z.ZodNullable<z.ZodNumber>;
|
|
225
|
+
height: z.ZodNullable<z.ZodNumber>;
|
|
226
|
+
sha256: z.ZodNullable<z.ZodString>;
|
|
227
|
+
createdBy: z.ZodString;
|
|
228
|
+
createdAt: z.ZodISODateTime;
|
|
229
|
+
readyAt: z.ZodNullable<z.ZodISODateTime>;
|
|
230
|
+
deletedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
231
|
+
failureCode: z.ZodNullable<z.ZodString>;
|
|
232
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
233
|
+
outcome: z.ZodLiteral<"error">;
|
|
234
|
+
code: z.ZodEnum<{
|
|
235
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
236
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
237
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
238
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
239
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
240
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
241
|
+
INVALID_PATH: "INVALID_PATH";
|
|
242
|
+
NOT_FOUND: "NOT_FOUND";
|
|
243
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
244
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
245
|
+
}>;
|
|
246
|
+
message: z.ZodString;
|
|
247
|
+
}, z.core.$strict>]>;
|
|
248
|
+
};
|
|
249
|
+
readEventCatalog: {
|
|
250
|
+
readonly path: "/images/events";
|
|
251
|
+
readonly input: z.ZodObject<{}, z.core.$strict>;
|
|
252
|
+
readonly output: z.ZodUnion<readonly [z.ZodCustom<import("@zlooks.cn/event-bus").EventCatalog, import("@zlooks.cn/event-bus").EventCatalog>, z.ZodObject<{
|
|
253
|
+
outcome: z.ZodLiteral<"error">;
|
|
254
|
+
code: z.ZodEnum<{
|
|
255
|
+
HASH_CONFLICT: "HASH_CONFLICT";
|
|
256
|
+
IDEMPOTENCY_CONFLICT: "IDEMPOTENCY_CONFLICT";
|
|
257
|
+
IMAGE_TOO_LARGE: "IMAGE_TOO_LARGE";
|
|
258
|
+
INVALID_BASE64: "INVALID_BASE64";
|
|
259
|
+
INVALID_CURSOR: "INVALID_CURSOR";
|
|
260
|
+
INVALID_IMAGE: "INVALID_IMAGE";
|
|
261
|
+
INVALID_PATH: "INVALID_PATH";
|
|
262
|
+
NOT_FOUND: "NOT_FOUND";
|
|
263
|
+
STATE_CONFLICT: "STATE_CONFLICT";
|
|
264
|
+
UPLOAD_NOT_READY: "UPLOAD_NOT_READY";
|
|
265
|
+
}>;
|
|
266
|
+
message: z.ZodString;
|
|
267
|
+
}, z.core.$strict>]>;
|
|
268
|
+
};
|
|
269
|
+
}>;
|
|
270
|
+
}>;
|
|
271
|
+
export declare const IMAGES_UPLOAD_OPERATION: "/images/upload";
|
|
272
|
+
export declare const IMAGES_LIST_OPERATION: "/images/list";
|
|
273
|
+
export declare const IMAGES_READ_OPERATION: "/images/read";
|
|
274
|
+
export declare const IMAGES_DELETE_OPERATION: "/images/delete";
|
|
275
|
+
export declare const IMAGES_EVENT_CATALOG_OPERATION: "/images/events";
|
|
276
|
+
export type ImagesMicroCallOptions = MicroCallOptions;
|
|
277
|
+
export type ImagesMicroCaller = MicroCaller;
|
|
278
|
+
export type ImagesContractClient<Options> = MicroClient<typeof imagesMicroContract, Options>;
|
|
279
|
+
export interface ImagesClient<Options> {
|
|
280
|
+
upload(input: ImageUploadCommand, options: Options): Promise<ImageMetadata>;
|
|
281
|
+
list(input: ListImageQuery, options: Options): Promise<ImagePage>;
|
|
282
|
+
read(input: ReadImageInput, options: Options): Promise<ImageMetadata>;
|
|
283
|
+
delete(input: DeleteImageInput, options: Options): Promise<ImageMetadata>;
|
|
284
|
+
readEventCatalog(options: Options): Promise<typeof IMAGES_EVENT_CATALOG>;
|
|
285
|
+
}
|
|
286
|
+
export type ImagesMicroClient = ImagesClient<ImagesMicroCallOptions>;
|
|
287
|
+
export declare function createImagesClient<Options>(contractClient: ImagesContractClient<Options>): ImagesClient<Options>;
|
|
288
|
+
export declare function createImagesMicroClient(caller: ImagesMicroCaller): ImagesMicroClient;
|
|
289
|
+
//# sourceMappingURL=micro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"micro.d.ts","sourceRoot":"","sources":["../src/micro.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAIL,2BAA2B,EAK3B,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAErB,qBAAa,oBAAqB,SAAQ,KAAK;aAE3B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC;IAD3E,YACkB,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,EACzE,OAAO,EAAE,MAAM,EAIhB;CACF;AAUD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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CAAC,CAAC;AAErE,wBAAgB,kBAAkB,CAAC,OAAO,EACxC,cAAc,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAC5C,YAAY,CAAC,OAAO,CAAC,CAkCvB;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAEpF"}
|
package/dist/micro.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createMicroClient, defineMicroContract, } from '@hile/micro-contract';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { IMAGES_EVENT_CATALOG } from './events/catalog.js';
|
|
4
|
+
import { IMAGES_SERVICE_NAMESPACE } from './identity.js';
|
|
5
|
+
import { deleteImageSchema, imageEmptyRequestSchema, imageMetadataSchema, imageOperationFailureSchema, imagePageSchema, imageUploadCommandSchema, listImageSchema, readImageSchema, } from './images.js';
|
|
6
|
+
export class ImagesOperationError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = 'ImagesOperationError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const eventCatalogSchema = z.custom((value) => {
|
|
15
|
+
try {
|
|
16
|
+
return JSON.stringify(value) === JSON.stringify(IMAGES_EVENT_CATALOG);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}, 'Invalid Images event catalog response');
|
|
22
|
+
export const imagesMicroContract = defineMicroContract({
|
|
23
|
+
namespace: IMAGES_SERVICE_NAMESPACE,
|
|
24
|
+
operations: {
|
|
25
|
+
upload: {
|
|
26
|
+
path: '/images/upload',
|
|
27
|
+
input: imageUploadCommandSchema,
|
|
28
|
+
output: z.union([imageMetadataSchema, imageOperationFailureSchema]),
|
|
29
|
+
},
|
|
30
|
+
list: {
|
|
31
|
+
path: '/images/list',
|
|
32
|
+
input: listImageSchema,
|
|
33
|
+
output: z.union([imagePageSchema, imageOperationFailureSchema]),
|
|
34
|
+
},
|
|
35
|
+
read: {
|
|
36
|
+
path: '/images/read',
|
|
37
|
+
input: readImageSchema,
|
|
38
|
+
output: z.union([imageMetadataSchema, imageOperationFailureSchema]),
|
|
39
|
+
},
|
|
40
|
+
delete: {
|
|
41
|
+
path: '/images/delete',
|
|
42
|
+
input: deleteImageSchema,
|
|
43
|
+
output: z.union([imageMetadataSchema, imageOperationFailureSchema]),
|
|
44
|
+
},
|
|
45
|
+
readEventCatalog: {
|
|
46
|
+
path: '/images/events',
|
|
47
|
+
input: imageEmptyRequestSchema,
|
|
48
|
+
output: z.union([eventCatalogSchema, imageOperationFailureSchema]),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
export const IMAGES_UPLOAD_OPERATION = imagesMicroContract.operations.upload.path;
|
|
53
|
+
export const IMAGES_LIST_OPERATION = imagesMicroContract.operations.list.path;
|
|
54
|
+
export const IMAGES_READ_OPERATION = imagesMicroContract.operations.read.path;
|
|
55
|
+
export const IMAGES_DELETE_OPERATION = imagesMicroContract.operations.delete.path;
|
|
56
|
+
export const IMAGES_EVENT_CATALOG_OPERATION = imagesMicroContract.operations.readEventCatalog.path;
|
|
57
|
+
export function createImagesClient(contractClient) {
|
|
58
|
+
const client = {
|
|
59
|
+
async upload(input, options) {
|
|
60
|
+
return parseOperationResult(await contractClient.upload(input, options), imageMetadataSchema);
|
|
61
|
+
},
|
|
62
|
+
async list(input, options) {
|
|
63
|
+
return parseOperationResult(await contractClient.list(input, options), imagePageSchema);
|
|
64
|
+
},
|
|
65
|
+
async read(input, options) {
|
|
66
|
+
return parseOperationResult(await contractClient.read(input, options), imageMetadataSchema);
|
|
67
|
+
},
|
|
68
|
+
async delete(input, options) {
|
|
69
|
+
return parseOperationResult(await contractClient.delete(input, options), imageMetadataSchema);
|
|
70
|
+
},
|
|
71
|
+
async readEventCatalog(options) {
|
|
72
|
+
return parseOperationResult(await contractClient.readEventCatalog({}, options), eventCatalogSchema);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
return Object.freeze(client);
|
|
76
|
+
}
|
|
77
|
+
export function createImagesMicroClient(caller) {
|
|
78
|
+
return createImagesClient(createMicroClient(caller, imagesMicroContract));
|
|
79
|
+
}
|
|
80
|
+
function parseOperationResult(input, schema) {
|
|
81
|
+
const failure = imageOperationFailureSchema.safeParse(input);
|
|
82
|
+
if (failure.success) {
|
|
83
|
+
throw new ImagesOperationError(failure.data.code, failure.data.message);
|
|
84
|
+
}
|
|
85
|
+
return schema.parse(input);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=micro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"micro.js","sourceRoot":"","sources":["../src/micro.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAIpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,eAAe,EACf,wBAAwB,EACxB,eAAe,EACf,eAAe,GAOhB,MAAM,aAAa,CAAC;AAErB,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE3B,IAAI;IADtB,YACkB,IAAyD,EACzE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;oBAHC,IAAI;QAIpB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAA8B,CAAC,KAAK,EAAE,EAAE;IACzE,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,oBAAoB,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CAAC,MAAyB;IAC/D,OAAO,kBAAkB,CAAC,iBAAiB,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,oBAAoB,CAAI,KAAc,EAAE,MAAoB;IACnE,MAAM,OAAO,GAAG,2BAA2B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zlooks.cn/images-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -19,8 +19,10 @@
|
|
|
19
19
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@
|
|
23
|
-
"@
|
|
22
|
+
"@hile/context": "4.0.3",
|
|
23
|
+
"@hile/micro-contract": "1.0.1",
|
|
24
|
+
"@zlooks.cn/event-bus": "1.0.3",
|
|
25
|
+
"@zlooks.cn/event-client": "1.0.3",
|
|
24
26
|
"zod": "4.4.3"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
@@ -29,5 +31,5 @@
|
|
|
29
31
|
"typescript": "7.0.2",
|
|
30
32
|
"vitest": "4.1.11"
|
|
31
33
|
},
|
|
32
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "93c1087350b97ab47fd9596c1e39da4ade741a49"
|
|
33
35
|
}
|