@juanito_boop/w-sdk 0.1.0

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/index.js ADDED
@@ -0,0 +1,716 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ ActivityLogSchema: () => ActivityLogSchema,
24
+ ApiErrorSchema: () => ApiErrorSchema,
25
+ ApiKeySchema: () => ApiKeySchema,
26
+ AuthResponseSchema: () => AuthResponseSchema,
27
+ BulkInsertWinesResultSchema: () => BulkInsertWinesResultSchema,
28
+ BulkInsertWinesSchema: () => BulkInsertWinesSchema,
29
+ ClientOptionsSchema: () => ClientOptionsSchema,
30
+ CreateWineSchema: () => CreateWineSchema,
31
+ EditWineSchema: () => EditWineSchema,
32
+ ImgbbAssetSchema: () => ImgbbAssetSchema,
33
+ ImgbbUploadDataSchema: () => ImgbbUploadDataSchema,
34
+ InsertWineResultSchema: () => InsertWineResultSchema,
35
+ LoginDataSchema: () => LoginDataSchema,
36
+ MagicLinkRequestDataSchema: () => MagicLinkRequestDataSchema,
37
+ MagicLinkResponseSchema: () => MagicLinkResponseSchema,
38
+ RealtimeOptionsSchema: () => RealtimeOptionsSchema,
39
+ RegisterDataSchema: () => RegisterDataSchema,
40
+ ReusedWineImageSchema: () => ReusedWineImageSchema,
41
+ RollbackLogSchema: () => RollbackLogSchema,
42
+ SessionDataSchema: () => SessionDataSchema,
43
+ ValidateSessionResponseSchema: () => ValidateSessionResponseSchema,
44
+ WineClient: () => WineClient,
45
+ WineDataSchema: () => WineDataSchema,
46
+ WineDetailsSchema: () => WineDetailsSchema,
47
+ WineSchema: () => WineSchema,
48
+ createClient: () => createClient,
49
+ createWsImageFile: () => createWsImageFile
50
+ });
51
+ module.exports = __toCommonJS(index_exports);
52
+
53
+ // src/http/auth.ts
54
+ function buildQueryString(params) {
55
+ const query = new URLSearchParams();
56
+ Object.entries(params).forEach(([key, value]) => {
57
+ if (value) query.append(key, value);
58
+ });
59
+ const str = query.toString();
60
+ return str ? `?${str}` : "";
61
+ }
62
+ function createAuthHttp(opts) {
63
+ const fetcher = opts.fetch ?? globalThis.fetch;
64
+ async function post(path, body) {
65
+ try {
66
+ const res = await fetcher(`${opts.baseUrl}${path}`, {
67
+ method: "POST",
68
+ headers: {
69
+ "Content-Type": "application/json",
70
+ ...opts.apiKey ? { "x-api-key": opts.apiKey } : {}
71
+ },
72
+ body: JSON.stringify(body)
73
+ });
74
+ const json = await res.json().catch(() => null);
75
+ if (!res.ok) {
76
+ return {
77
+ success: false,
78
+ error: {
79
+ message: json?.message ?? res.statusText,
80
+ code: json?.code,
81
+ statusCode: res.status,
82
+ details: json
83
+ }
84
+ };
85
+ }
86
+ return { success: true, data: json };
87
+ } catch (err) {
88
+ return {
89
+ success: false,
90
+ error: {
91
+ message: err instanceof Error ? err.message : "Network error",
92
+ code: "NETWORK_ERROR"
93
+ }
94
+ };
95
+ }
96
+ }
97
+ async function get(path) {
98
+ try {
99
+ const res = await fetcher(`${opts.baseUrl}${path}`, {
100
+ method: "GET",
101
+ headers: {
102
+ "Content-Type": "application/json",
103
+ ...opts.apiKey ? { "x-api-key": opts.apiKey } : {}
104
+ }
105
+ });
106
+ const json = await res.json().catch(() => null);
107
+ if (!res.ok) {
108
+ return {
109
+ success: false,
110
+ error: {
111
+ message: json?.message ?? res.statusText,
112
+ code: json?.code,
113
+ statusCode: res.status,
114
+ details: json
115
+ }
116
+ };
117
+ }
118
+ return { success: true, data: json };
119
+ } catch (err) {
120
+ return {
121
+ success: false,
122
+ error: {
123
+ message: err instanceof Error ? err.message : "Network error",
124
+ code: "NETWORK_ERROR"
125
+ }
126
+ };
127
+ }
128
+ }
129
+ async function del(path) {
130
+ try {
131
+ const res = await fetcher(`${opts.baseUrl}${path}`, {
132
+ method: "DELETE",
133
+ headers: {
134
+ "Content-Type": "application/json",
135
+ ...opts.apiKey ? { "x-api-key": opts.apiKey } : {}
136
+ }
137
+ });
138
+ const json = await res.json().catch(() => null);
139
+ if (!res.ok) {
140
+ return {
141
+ success: false,
142
+ error: {
143
+ message: json?.message ?? res.statusText,
144
+ code: json?.code,
145
+ statusCode: res.status,
146
+ details: json
147
+ }
148
+ };
149
+ }
150
+ return { success: true, data: json };
151
+ } catch (err) {
152
+ return {
153
+ success: false,
154
+ error: {
155
+ message: err instanceof Error ? err.message : "Network error",
156
+ code: "NETWORK_ERROR"
157
+ }
158
+ };
159
+ }
160
+ }
161
+ return {
162
+ register: (data) => post("/auth/register", data),
163
+ login: (data) => post("/auth/login", data),
164
+ logout: (data) => post("/auth/logout", data),
165
+ requestMagicLink: (data) => post("/auth/magic-link/request", data),
166
+ verifyMagicLink: (token) => post("/auth/magic-link/verify", { token }),
167
+ createApiKey: (data) => post("/auth/api-keys", data),
168
+ listApiKeys: (userId) => get(`/auth/api-keys/${userId}`),
169
+ revokeApiKey: (userId, keyId) => del(`/auth/api-keys/${userId}/${keyId}`),
170
+ validateSession: (token) => post("/auth/validate-session", { token }),
171
+ rollbackApiKey: (data) => {
172
+ const query = buildQueryString({
173
+ fromActivityId: data.fromActivityId,
174
+ fromTimestamp: data.fromTimestamp,
175
+ initiatedBy: data.initiatedBy
176
+ });
177
+ return post(
178
+ `/auth/api-keys/${data.keyId}/rollback${query}`,
179
+ {}
180
+ );
181
+ },
182
+ verifyMagicLinkWithQuery: (token) => get(`/auth/magic-link/verify?token=${token}`),
183
+ getSessions: (userId) => get(`/auth/sessions/${userId}`),
184
+ getLogs: () => get("/auth/logs"),
185
+ getUserLogs: (userId) => get(`/auth/logs/${userId}`),
186
+ getRollbackHistory: (keyId, limit = 50) => get(
187
+ `/auth/rollback-history${buildQueryString({ keyId, limit: String(limit) })}`
188
+ )
189
+ };
190
+ }
191
+
192
+ // src/ws/realtime.ts
193
+ var import_socket = require("socket.io-client");
194
+ async function toBytes(input) {
195
+ if (input instanceof Uint8Array) {
196
+ return Array.from(input);
197
+ }
198
+ if (input instanceof ArrayBuffer) {
199
+ return Array.from(new Uint8Array(input));
200
+ }
201
+ const arrayBuffer = await input.arrayBuffer();
202
+ return Array.from(new Uint8Array(arrayBuffer));
203
+ }
204
+ async function createWsImageFile(file, opts) {
205
+ if (file instanceof Blob) {
206
+ const detectedMime = opts?.mime ?? file.type;
207
+ const payload2 = {
208
+ filename: opts?.filename ?? file.name ?? "image.bin",
209
+ mime: detectedMime || "application/octet-stream",
210
+ buffer: await toBytes(file),
211
+ name: opts?.name,
212
+ expiration: opts?.expiration
213
+ };
214
+ return payload2;
215
+ }
216
+ const payload = {
217
+ filename: opts?.filename ?? "image.bin",
218
+ mime: opts?.mime ?? "application/octet-stream",
219
+ buffer: await toBytes(file),
220
+ name: opts?.name,
221
+ expiration: opts?.expiration
222
+ };
223
+ return payload;
224
+ }
225
+ function createRealtime(opts) {
226
+ let socket = null;
227
+ let apiKey = opts.apiKey;
228
+ const ACK_TIMEOUT_MS = 3e4;
229
+ function connect() {
230
+ return new Promise((resolve, reject) => {
231
+ if (socket?.connected) {
232
+ resolve();
233
+ return;
234
+ }
235
+ const auth = apiKey ? { apiKey } : void 0;
236
+ const extraHeaders = apiKey ? { "x-api-key": apiKey } : void 0;
237
+ let timeoutId;
238
+ socket = (0, import_socket.io)(opts.baseUrl, {
239
+ path: "/ws",
240
+ transports: ["websocket", "polling"],
241
+ auth,
242
+ extraHeaders
243
+ });
244
+ const handleConnect = () => {
245
+ if (timeoutId) {
246
+ clearTimeout(timeoutId);
247
+ }
248
+ socket?.off("connect", handleConnect);
249
+ socket?.off("connect_error", handleError);
250
+ resolve();
251
+ };
252
+ const handleError = (error) => {
253
+ if (timeoutId) {
254
+ clearTimeout(timeoutId);
255
+ }
256
+ socket?.off("connect", handleConnect);
257
+ socket?.off("connect_error", handleError);
258
+ reject(error);
259
+ };
260
+ socket.on("connect", handleConnect);
261
+ socket.on("connect_error", handleError);
262
+ timeoutId = setTimeout(() => {
263
+ socket?.off("connect", handleConnect);
264
+ socket?.off("connect_error", handleError);
265
+ reject(new Error("Connection timeout"));
266
+ }, 5e3);
267
+ });
268
+ }
269
+ function disconnect() {
270
+ socket?.disconnect();
271
+ socket = null;
272
+ }
273
+ function setApiKey(key) {
274
+ apiKey = key;
275
+ if (socket) {
276
+ disconnect();
277
+ connect();
278
+ }
279
+ }
280
+ function emitAck(event, payload) {
281
+ if (!socket) {
282
+ return Promise.resolve({
283
+ success: false,
284
+ error: {
285
+ message: "Socket no conectado",
286
+ code: "SOCKET_NOT_CONNECTED"
287
+ }
288
+ });
289
+ }
290
+ return new Promise((resolve) => {
291
+ socket.timeout(ACK_TIMEOUT_MS).emit(event, payload, (err, res) => {
292
+ if (err) {
293
+ resolve({
294
+ success: false,
295
+ error: {
296
+ message: err.message ?? "Socket error",
297
+ code: err.code ?? "SOCKET_ERROR",
298
+ details: err
299
+ }
300
+ });
301
+ return;
302
+ }
303
+ if (res?.error) {
304
+ resolve({
305
+ success: false,
306
+ error: {
307
+ message: res.error.message,
308
+ code: res.error.code,
309
+ details: res.error
310
+ }
311
+ });
312
+ return;
313
+ }
314
+ resolve({ success: true, data: res });
315
+ });
316
+ });
317
+ }
318
+ return {
319
+ connect,
320
+ disconnect,
321
+ setApiKey,
322
+ getWines: () => emitAck("get_wines", void 0),
323
+ getWinesPage: (page = 1, perPage = 16) => emitAck("get_wines_page", { page, perPage }),
324
+ insertWine: (data) => emitAck("insert_wine", data),
325
+ insertBulkWines: (data) => emitAck("insert_bulk_wines", data),
326
+ editWine: (data) => emitAck("edit_wine", data)
327
+ };
328
+ }
329
+
330
+ // src/client.ts
331
+ var WineClient = class {
332
+ constructor(options) {
333
+ if (!options.baseUrl) {
334
+ throw new Error("baseUrl es requerido");
335
+ }
336
+ this.baseUrl = options.baseUrl;
337
+ this.apiKey = options.apiKey;
338
+ this.auth = createAuthHttp({
339
+ baseUrl: this.baseUrl,
340
+ apiKey: this.apiKey
341
+ });
342
+ this.realtime = createRealtime({
343
+ baseUrl: this.baseUrl,
344
+ apiKey: this.apiKey
345
+ });
346
+ }
347
+ setApiKey(apiKey) {
348
+ this.apiKey = apiKey;
349
+ this.realtime.setApiKey(apiKey);
350
+ }
351
+ async connectRealtime() {
352
+ await this.realtime.connect();
353
+ return this.realtime;
354
+ }
355
+ disconnectRealtime() {
356
+ this.realtime.disconnect();
357
+ }
358
+ };
359
+ function createClient(options) {
360
+ return new WineClient(options);
361
+ }
362
+
363
+ // src/types.ts
364
+ var import_zod = require("zod");
365
+
366
+ // src/types/_helpers.ts
367
+ function defineSchema(schema) {
368
+ return {
369
+ schema
370
+ };
371
+ }
372
+
373
+ // src/types.ts
374
+ var ClientOptionsDef = defineSchema(
375
+ import_zod.z.object({
376
+ baseUrl: import_zod.z.url("baseUrl debe ser una URL v\xE1lida"),
377
+ apiKey: import_zod.z.string().optional()
378
+ })
379
+ );
380
+ var ApiErrorDef = defineSchema(
381
+ import_zod.z.object({
382
+ message: import_zod.z.string(),
383
+ code: import_zod.z.string().optional(),
384
+ statusCode: import_zod.z.number().optional(),
385
+ details: import_zod.z.unknown().optional()
386
+ })
387
+ );
388
+ var LoginDataDef = defineSchema(
389
+ import_zod.z.object({
390
+ email: import_zod.z.email("Email inv\xE1lido"),
391
+ password: import_zod.z.string().min(1, "Password es requerido")
392
+ })
393
+ );
394
+ var RegisterDataDef = defineSchema(
395
+ import_zod.z.object({
396
+ email: import_zod.z.email("Email inv\xE1lido"),
397
+ password: import_zod.z.string().min(6, "Password debe tener al menos 6 caracteres"),
398
+ fullName: import_zod.z.string().optional()
399
+ })
400
+ );
401
+ var LogoutDataDef = defineSchema(
402
+ import_zod.z.object({
403
+ token: import_zod.z.string(),
404
+ logoutAll: import_zod.z.boolean().optional()
405
+ })
406
+ );
407
+ var MagicLinkRequestDataDef = defineSchema(
408
+ import_zod.z.object({
409
+ email: import_zod.z.email("Email inv\xE1lido"),
410
+ redirectUrl: import_zod.z.url().optional()
411
+ })
412
+ );
413
+ var AuthResponseDef = defineSchema(
414
+ import_zod.z.object({
415
+ token: import_zod.z.string(),
416
+ user: import_zod.z.object({
417
+ id: import_zod.z.uuid(),
418
+ email: import_zod.z.email(),
419
+ fullName: import_zod.z.string().optional()
420
+ }),
421
+ apiKey: import_zod.z.object({
422
+ id: import_zod.z.uuid(),
423
+ key: import_zod.z.string(),
424
+ name: import_zod.z.string(),
425
+ expiresAt: import_zod.z.iso.datetime()
426
+ }).optional()
427
+ })
428
+ );
429
+ var ApiKeyDef = defineSchema(
430
+ import_zod.z.object({
431
+ id: import_zod.z.uuid(),
432
+ key: import_zod.z.string(),
433
+ name: import_zod.z.string(),
434
+ expiresAt: import_zod.z.iso.datetime().optional(),
435
+ createdAt: import_zod.z.iso.datetime()
436
+ })
437
+ );
438
+ var MagicLinkResponseDef = defineSchema(
439
+ import_zod.z.object({
440
+ success: import_zod.z.boolean(),
441
+ message: import_zod.z.string(),
442
+ email: import_zod.z.email()
443
+ })
444
+ );
445
+ var CreateApiKeyDef = import_zod.z.object({
446
+ userId: import_zod.z.uuid(),
447
+ name: import_zod.z.string(),
448
+ expiresAt: import_zod.z.iso.datetime().optional(),
449
+ // ISO 8601
450
+ expiresIn: import_zod.z.number().positive().optional()
451
+ // Segundos
452
+ });
453
+ var RollbackApiKeyDataDef = import_zod.z.object({
454
+ keyId: import_zod.z.uuid(),
455
+ fromActivityId: import_zod.z.uuid().optional(),
456
+ fromTimestamp: import_zod.z.iso.datetime().optional(),
457
+ initiatedBy: import_zod.z.string().optional()
458
+ });
459
+ var RollbackResponseDef = import_zod.z.object({
460
+ success: import_zod.z.boolean(),
461
+ message: import_zod.z.string(),
462
+ changesReverted: import_zod.z.number(),
463
+ errors: import_zod.z.array(import_zod.z.string()),
464
+ rollbackSince: import_zod.z.iso.datetime().optional()
465
+ });
466
+ var SessionDataDef = defineSchema(
467
+ import_zod.z.object({
468
+ id: import_zod.z.uuid(),
469
+ userId: import_zod.z.uuid(),
470
+ token: import_zod.z.string(),
471
+ ipAddress: import_zod.z.string().nullable(),
472
+ userAgent: import_zod.z.string().nullable(),
473
+ isActive: import_zod.z.boolean(),
474
+ lastActivityAt: import_zod.z.iso.datetime(),
475
+ createdAt: import_zod.z.iso.datetime(),
476
+ expiresAt: import_zod.z.iso.datetime().nullable()
477
+ })
478
+ );
479
+ var ValidateSessionResponseDef = defineSchema(
480
+ import_zod.z.object({
481
+ valid: import_zod.z.boolean(),
482
+ userId: import_zod.z.uuid().optional(),
483
+ sessionId: import_zod.z.uuid().optional()
484
+ })
485
+ );
486
+ var ActivityLogDef = defineSchema(
487
+ import_zod.z.object({
488
+ id: import_zod.z.uuid(),
489
+ userId: import_zod.z.uuid().nullable().optional(),
490
+ apiKeyId: import_zod.z.uuid().nullable().optional(),
491
+ action: import_zod.z.string(),
492
+ ipAddress: import_zod.z.string().nullable(),
493
+ userAgent: import_zod.z.string().nullable(),
494
+ location: import_zod.z.string().nullable(),
495
+ metadata: import_zod.z.string().nullable(),
496
+ beforeState: import_zod.z.string().nullable(),
497
+ afterState: import_zod.z.string().nullable(),
498
+ tableName: import_zod.z.string().nullable(),
499
+ recordId: import_zod.z.uuid().nullable(),
500
+ timestamp: import_zod.z.iso.datetime()
501
+ })
502
+ );
503
+ var RollbackLogDef = defineSchema(
504
+ import_zod.z.object({
505
+ id: import_zod.z.uuid(),
506
+ apiKeyId: import_zod.z.uuid(),
507
+ initiatedBy: import_zod.z.uuid().nullable().optional(),
508
+ status: import_zod.z.string(),
509
+ changesReverted: import_zod.z.string(),
510
+ errorMessage: import_zod.z.string().nullable(),
511
+ createdAt: import_zod.z.iso.datetime(),
512
+ completedAt: import_zod.z.iso.datetime().nullable().optional()
513
+ })
514
+ );
515
+ var RealtimeOptionsDef = defineSchema(
516
+ import_zod.z.object({
517
+ baseUrl: import_zod.z.url(),
518
+ apiKey: import_zod.z.string().optional()
519
+ })
520
+ );
521
+ var WineDataDef = defineSchema(
522
+ import_zod.z.object({
523
+ id: import_zod.z.uuid().optional()
524
+ }).strict()
525
+ );
526
+ var WineDetailsDef = defineSchema(
527
+ import_zod.z.object({
528
+ id_detalle: import_zod.z.uuid().nullable().optional(),
529
+ id_vino: import_zod.z.uuid().nullable().optional(),
530
+ notas_cata: import_zod.z.string().nullable().optional(),
531
+ tipo_crianza: import_zod.z.string().nullable().optional(),
532
+ bodega: import_zod.z.string().nullable().optional()
533
+ })
534
+ );
535
+ var WineDef = defineSchema(
536
+ import_zod.z.object({
537
+ id_vino: import_zod.z.uuid(),
538
+ nombre: import_zod.z.string(),
539
+ precio: import_zod.z.number(),
540
+ url_imagen: import_zod.z.string(),
541
+ imgbb_delete_url: import_zod.z.string().optional(),
542
+ image_hash: import_zod.z.string().optional(),
543
+ descripcion: import_zod.z.string(),
544
+ nivel_alcohol: import_zod.z.number(),
545
+ variedades: import_zod.z.array(import_zod.z.string()),
546
+ pais_importacion: import_zod.z.string(),
547
+ color_vino: import_zod.z.string(),
548
+ stock: import_zod.z.number(),
549
+ capacidad: import_zod.z.number(),
550
+ wine_details: WineDetailsDef.schema.nullable().optional()
551
+ })
552
+ );
553
+ var EditWineDef = defineSchema(
554
+ WineDef.schema.omit({ wine_details: true }).partial().extend({
555
+ id_vino: import_zod.z.uuid(),
556
+ wine_details: WineDetailsDef.schema.partial().optional(),
557
+ image_file: import_zod.z.object({
558
+ filename: import_zod.z.string().min(1),
559
+ mime: import_zod.z.string().min(1),
560
+ buffer: import_zod.z.union([
561
+ import_zod.z.instanceof(Uint8Array),
562
+ import_zod.z.array(import_zod.z.number().int().min(0).max(255)),
563
+ import_zod.z.object({
564
+ type: import_zod.z.literal("Buffer"),
565
+ data: import_zod.z.array(import_zod.z.number().int().min(0).max(255))
566
+ })
567
+ ]),
568
+ name: import_zod.z.string().optional(),
569
+ expiration: import_zod.z.number().int().nonnegative().optional()
570
+ }).optional()
571
+ }).strict()
572
+ );
573
+ var CreateWineDef = defineSchema(
574
+ import_zod.z.object({
575
+ nombre: import_zod.z.string().min(1, 'El campo "nombre" es obligatorio'),
576
+ precio: import_zod.z.number().positive("El precio debe ser positivo"),
577
+ url_imagen: import_zod.z.string().optional(),
578
+ imgbb_delete_url: import_zod.z.string().optional(),
579
+ image_hash: import_zod.z.string().optional(),
580
+ descripcion: import_zod.z.string().optional(),
581
+ nivel_alcohol: import_zod.z.number().default(0),
582
+ variedades: import_zod.z.array(import_zod.z.string()).optional(),
583
+ pais_importacion: import_zod.z.string().optional(),
584
+ color_vino: import_zod.z.string().optional(),
585
+ stock: import_zod.z.number().default(0),
586
+ capacidad: import_zod.z.number().default(750),
587
+ notas_cata: import_zod.z.string().optional(),
588
+ tipo_crianza: import_zod.z.string().optional(),
589
+ bodega: import_zod.z.string().optional(),
590
+ image_file: import_zod.z.object({
591
+ filename: import_zod.z.string().min(1),
592
+ mime: import_zod.z.string().min(1),
593
+ buffer: import_zod.z.union([
594
+ import_zod.z.instanceof(Uint8Array),
595
+ import_zod.z.array(import_zod.z.number().int().min(0).max(255)),
596
+ import_zod.z.object({
597
+ type: import_zod.z.literal("Buffer"),
598
+ data: import_zod.z.array(import_zod.z.number().int().min(0).max(255))
599
+ })
600
+ ]),
601
+ name: import_zod.z.string().optional(),
602
+ expiration: import_zod.z.number().int().nonnegative().optional()
603
+ }).optional()
604
+ })
605
+ );
606
+ var BulkInsertWinesDef = defineSchema(import_zod.z.array(CreateWineDef.schema));
607
+ var BulkInsertWinesResultDef = defineSchema(
608
+ import_zod.z.object({
609
+ total: import_zod.z.number(),
610
+ successful: import_zod.z.number(),
611
+ failed: import_zod.z.number(),
612
+ results: import_zod.z.array(
613
+ import_zod.z.object({
614
+ insertado_id: import_zod.z.string().nullable(),
615
+ error: import_zod.z.string().nullable()
616
+ })
617
+ )
618
+ })
619
+ );
620
+ var ReusedWineImageDef = defineSchema(
621
+ import_zod.z.object({
622
+ url: import_zod.z.string(),
623
+ delete_url: import_zod.z.string()
624
+ })
625
+ );
626
+ var ImgbbAssetDef = defineSchema(
627
+ import_zod.z.object({
628
+ filename: import_zod.z.string(),
629
+ name: import_zod.z.string(),
630
+ mime: import_zod.z.string(),
631
+ extension: import_zod.z.string(),
632
+ url: import_zod.z.string()
633
+ })
634
+ );
635
+ var ImgbbUploadDataDef = defineSchema(
636
+ import_zod.z.object({
637
+ id: import_zod.z.string(),
638
+ title: import_zod.z.string(),
639
+ url_viewer: import_zod.z.string(),
640
+ url: import_zod.z.string(),
641
+ display_url: import_zod.z.string(),
642
+ width: import_zod.z.string(),
643
+ height: import_zod.z.string(),
644
+ size: import_zod.z.string(),
645
+ time: import_zod.z.string(),
646
+ expiration: import_zod.z.string(),
647
+ image: ImgbbAssetDef.schema,
648
+ thumb: ImgbbAssetDef.schema,
649
+ medium: ImgbbAssetDef.schema,
650
+ delete_url: import_zod.z.string()
651
+ })
652
+ );
653
+ var InsertWineResultDef = defineSchema(
654
+ import_zod.z.object({
655
+ insertado_id: import_zod.z.string().nullable(),
656
+ error: import_zod.z.string().nullable(),
657
+ image: import_zod.z.union([ImgbbUploadDataDef.schema, ReusedWineImageDef.schema]).optional(),
658
+ deduplicated: import_zod.z.boolean().optional()
659
+ })
660
+ );
661
+
662
+ // src/index.ts
663
+ var ClientOptionsSchema = ClientOptionsDef.schema;
664
+ var ApiErrorSchema = ApiErrorDef.schema;
665
+ var LoginDataSchema = LoginDataDef.schema;
666
+ var RegisterDataSchema = RegisterDataDef.schema;
667
+ var MagicLinkRequestDataSchema = MagicLinkRequestDataDef.schema;
668
+ var AuthResponseSchema = AuthResponseDef.schema;
669
+ var ApiKeySchema = ApiKeyDef.schema;
670
+ var MagicLinkResponseSchema = MagicLinkResponseDef.schema;
671
+ var ValidateSessionResponseSchema = ValidateSessionResponseDef.schema;
672
+ var SessionDataSchema = SessionDataDef.schema;
673
+ var ActivityLogSchema = ActivityLogDef.schema;
674
+ var RollbackLogSchema = RollbackLogDef.schema;
675
+ var RealtimeOptionsSchema = RealtimeOptionsDef.schema;
676
+ var WineSchema = WineDef.schema;
677
+ var WineDetailsSchema = WineDetailsDef.schema;
678
+ var WineDataSchema = WineDataDef.schema;
679
+ var CreateWineSchema = CreateWineDef.schema;
680
+ var EditWineSchema = EditWineDef.schema;
681
+ var BulkInsertWinesSchema = BulkInsertWinesDef.schema;
682
+ var BulkInsertWinesResultSchema = BulkInsertWinesResultDef.schema;
683
+ var ReusedWineImageSchema = ReusedWineImageDef.schema;
684
+ var ImgbbAssetSchema = ImgbbAssetDef.schema;
685
+ var ImgbbUploadDataSchema = ImgbbUploadDataDef.schema;
686
+ var InsertWineResultSchema = InsertWineResultDef.schema;
687
+ // Annotate the CommonJS export names for ESM import in node:
688
+ 0 && (module.exports = {
689
+ ActivityLogSchema,
690
+ ApiErrorSchema,
691
+ ApiKeySchema,
692
+ AuthResponseSchema,
693
+ BulkInsertWinesResultSchema,
694
+ BulkInsertWinesSchema,
695
+ ClientOptionsSchema,
696
+ CreateWineSchema,
697
+ EditWineSchema,
698
+ ImgbbAssetSchema,
699
+ ImgbbUploadDataSchema,
700
+ InsertWineResultSchema,
701
+ LoginDataSchema,
702
+ MagicLinkRequestDataSchema,
703
+ MagicLinkResponseSchema,
704
+ RealtimeOptionsSchema,
705
+ RegisterDataSchema,
706
+ ReusedWineImageSchema,
707
+ RollbackLogSchema,
708
+ SessionDataSchema,
709
+ ValidateSessionResponseSchema,
710
+ WineClient,
711
+ WineDataSchema,
712
+ WineDetailsSchema,
713
+ WineSchema,
714
+ createClient,
715
+ createWsImageFile
716
+ });