@zlooks.cn/images-shared 1.0.2 → 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/micro.d.ts +279 -21
- package/dist/micro.d.ts.map +1 -1
- package/dist/micro.js +45 -17
- package/dist/micro.js.map +1 -1
- package/package.json +5 -4
package/dist/micro.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MicroCallOptions, type MicroCaller, type MicroClient } from '@hile/micro-contract';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { IMAGES_EVENT_CATALOG } from './events/catalog.js';
|
|
4
4
|
import { imageOperationFailureSchema, type DeleteImageInput, type ImageMetadata, type ImagePage, type ImageUploadCommand, type ListImageQuery, type ReadImageInput } from './images.js';
|
|
@@ -6,26 +6,284 @@ export declare class ImagesOperationError extends Error {
|
|
|
6
6
|
readonly code: z.infer<typeof imageOperationFailureSchema>['code'];
|
|
7
7
|
constructor(code: z.infer<typeof imageOperationFailureSchema>['code'], message: string);
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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>;
|
|
29
285
|
}
|
|
286
|
+
export type ImagesMicroClient = ImagesClient<ImagesMicroCallOptions>;
|
|
287
|
+
export declare function createImagesClient<Options>(contractClient: ImagesContractClient<Options>): ImagesClient<Options>;
|
|
30
288
|
export declare function createImagesMicroClient(caller: ImagesMicroCaller): ImagesMicroClient;
|
|
31
289
|
//# sourceMappingURL=micro.d.ts.map
|
package/dist/micro.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro.d.ts","sourceRoot":"","sources":["../src/micro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
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,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AC,CAAC;AAE7F,MAAM,WAAW,YAAY,CAAC,OAAO;IACnC,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5E,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClE,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACtE,MAAM,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1E,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,oBAAoB,CAAC,CAAC;CAC1E;AAED,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAC,sBAAsB,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
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createMicroClient, defineMicroContract, } from '@hile/micro-contract';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { IMAGES_EVENT_CATALOG } from './events/catalog.js';
|
|
3
4
|
import { IMAGES_SERVICE_NAMESPACE } from './identity.js';
|
|
@@ -10,11 +11,6 @@ export class ImagesOperationError extends Error {
|
|
|
10
11
|
this.name = 'ImagesOperationError';
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
export const IMAGES_UPLOAD_OPERATION = '/images/upload';
|
|
14
|
-
export const IMAGES_LIST_OPERATION = '/images/list';
|
|
15
|
-
export const IMAGES_READ_OPERATION = '/images/read';
|
|
16
|
-
export const IMAGES_DELETE_OPERATION = '/images/delete';
|
|
17
|
-
export const IMAGES_EVENT_CATALOG_OPERATION = '/images/events';
|
|
18
14
|
const eventCatalogSchema = z.custom((value) => {
|
|
19
15
|
try {
|
|
20
16
|
return JSON.stringify(value) === JSON.stringify(IMAGES_EVENT_CATALOG);
|
|
@@ -23,32 +19,64 @@ const eventCatalogSchema = z.custom((value) => {
|
|
|
23
19
|
return false;
|
|
24
20
|
}
|
|
25
21
|
}, 'Invalid Images event catalog response');
|
|
26
|
-
export
|
|
27
|
-
|
|
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) {
|
|
28
58
|
const client = {
|
|
29
59
|
async upload(input, options) {
|
|
30
|
-
|
|
31
|
-
return parseOperationResult(await call(IMAGES_UPLOAD_OPERATION, command, options), imageMetadataSchema);
|
|
60
|
+
return parseOperationResult(await contractClient.upload(input, options), imageMetadataSchema);
|
|
32
61
|
},
|
|
33
62
|
async list(input, options) {
|
|
34
|
-
|
|
35
|
-
return parseOperationResult(await call(IMAGES_LIST_OPERATION, query, options), imagePageSchema);
|
|
63
|
+
return parseOperationResult(await contractClient.list(input, options), imagePageSchema);
|
|
36
64
|
},
|
|
37
65
|
async read(input, options) {
|
|
38
|
-
|
|
39
|
-
return parseOperationResult(await call(IMAGES_READ_OPERATION, query, options), imageMetadataSchema);
|
|
66
|
+
return parseOperationResult(await contractClient.read(input, options), imageMetadataSchema);
|
|
40
67
|
},
|
|
41
68
|
async delete(input, options) {
|
|
42
|
-
|
|
43
|
-
return parseOperationResult(await call(IMAGES_DELETE_OPERATION, command, options), imageMetadataSchema);
|
|
69
|
+
return parseOperationResult(await contractClient.delete(input, options), imageMetadataSchema);
|
|
44
70
|
},
|
|
45
71
|
async readEventCatalog(options) {
|
|
46
|
-
|
|
47
|
-
return parseOperationResult(result, eventCatalogSchema);
|
|
72
|
+
return parseOperationResult(await contractClient.readEventCatalog({}, options), eventCatalogSchema);
|
|
48
73
|
},
|
|
49
74
|
};
|
|
50
75
|
return Object.freeze(client);
|
|
51
76
|
}
|
|
77
|
+
export function createImagesMicroClient(caller) {
|
|
78
|
+
return createImagesClient(createMicroClient(caller, imagesMicroContract));
|
|
79
|
+
}
|
|
52
80
|
function parseOperationResult(input, schema) {
|
|
53
81
|
const failure = imageOperationFailureSchema.safeParse(input);
|
|
54
82
|
if (failure.success) {
|
package/dist/micro.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"micro.js","sourceRoot":"","sources":["../src/micro.ts"],"names":[],"mappings":"
|
|
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,CAAC,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,EAAE,uCAAuC,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;IACrD,SAAS,EAAE,wBAAwB;IACnC,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE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,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": {
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@hile/context": "4.0.3",
|
|
23
|
-
"@
|
|
24
|
-
"@zlooks.cn/event-
|
|
23
|
+
"@hile/micro-contract": "1.0.1",
|
|
24
|
+
"@zlooks.cn/event-bus": "1.0.3",
|
|
25
|
+
"@zlooks.cn/event-client": "1.0.3",
|
|
25
26
|
"zod": "4.4.3"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"typescript": "7.0.2",
|
|
31
32
|
"vitest": "4.1.11"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "93c1087350b97ab47fd9596c1e39da4ade741a49"
|
|
34
35
|
}
|