@zyacreatives/shared 2.2.93 → 2.2.94

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.
@@ -1,4 +1,15 @@
1
1
  import { z } from "@hono/zod-openapi";
2
+ export declare const CoverImageInputSchema: z.ZodObject<{
3
+ key: z.ZodString;
4
+ mimeType: z.ZodString;
5
+ isThumbnail: z.ZodDefault<z.ZodBoolean>;
6
+ order: z.ZodDefault<z.ZodNumber>;
7
+ }, z.core.$strip>;
8
+ export declare const DeliveryFileInputSchema: z.ZodObject<{
9
+ key: z.ZodString;
10
+ mimeType: z.ZodString;
11
+ order: z.ZodDefault<z.ZodNumber>;
12
+ }, z.core.$strip>;
2
13
  export declare const ProductCoverImageEntitySchema: z.ZodObject<{
3
14
  fileId: z.ZodCUID2;
4
15
  isThumbnail: z.ZodDefault<z.ZodBoolean>;
@@ -49,6 +60,7 @@ export declare const BaseProductSchema: z.ZodObject<{
49
60
  supportPhone: z.ZodNullable<z.ZodString>;
50
61
  }, z.core.$strip>;
51
62
  export declare const CreateProductInputSchema: z.ZodObject<{
63
+ id: z.ZodCUID2;
52
64
  title: z.ZodString;
53
65
  description: z.ZodString;
54
66
  keyFeatures: z.ZodString;
@@ -56,12 +68,14 @@ export declare const CreateProductInputSchema: z.ZodObject<{
56
68
  subcategory: z.ZodOptional<z.ZodString>;
57
69
  tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
58
70
  coverImages: z.ZodArray<z.ZodObject<{
59
- fileId: z.ZodCUID2;
71
+ key: z.ZodString;
72
+ mimeType: z.ZodString;
60
73
  isThumbnail: z.ZodDefault<z.ZodBoolean>;
61
74
  order: z.ZodDefault<z.ZodNumber>;
62
75
  }, z.core.$strip>>;
63
76
  productFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
64
- fileId: z.ZodCUID2;
77
+ key: z.ZodString;
78
+ mimeType: z.ZodString;
65
79
  order: z.ZodDefault<z.ZodNumber>;
66
80
  }, z.core.$strip>>>;
67
81
  productLinks: z.ZodDefault<z.ZodArray<z.ZodURL>>;
@@ -99,12 +113,14 @@ export declare const UpdateProductInputSchema: z.ZodObject<{
99
113
  subcategory: z.ZodOptional<z.ZodOptional<z.ZodString>>;
100
114
  tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
101
115
  coverImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
102
- fileId: z.ZodCUID2;
116
+ key: z.ZodString;
117
+ mimeType: z.ZodString;
103
118
  isThumbnail: z.ZodDefault<z.ZodBoolean>;
104
119
  order: z.ZodDefault<z.ZodNumber>;
105
120
  }, z.core.$strip>>>;
106
121
  productFiles: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
107
- fileId: z.ZodCUID2;
122
+ key: z.ZodString;
123
+ mimeType: z.ZodString;
108
124
  order: z.ZodDefault<z.ZodNumber>;
109
125
  }, z.core.$strip>>>>;
110
126
  productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodURL>>>;
@@ -137,7 +153,7 @@ export declare const ProductEntitySchema: z.ZodObject<{
137
153
  sellerId: z.ZodCUID2;
138
154
  sellerUsername: z.ZodString;
139
155
  sellerName: z.ZodString;
140
- sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
156
+ sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
141
157
  title: z.ZodString;
142
158
  description: z.ZodString;
143
159
  keyFeatures: z.ZodString;
@@ -176,6 +192,8 @@ export declare const ProductEntitySchema: z.ZodObject<{
176
192
  updatedAt: z.ZodCoercedDate<unknown>;
177
193
  deletedAt: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
178
194
  }, z.core.$strip>;
195
+ export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
196
+ export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
179
197
  export type ProductCoverImageEntity = z.infer<typeof ProductCoverImageEntitySchema>;
180
198
  export type ProductDeliveryFileEntity = z.infer<typeof ProductDeliveryFileEntitySchema>;
181
199
  export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
@@ -1,8 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProductEntitySchema = exports.UpdateProductInputSchema = exports.ProductServiceAndComplianceInputSchema = exports.CreateProductInputSchema = exports.BaseProductSchema = exports.ProductDiscountEntitySchema = exports.ProductDeliveryFileEntitySchema = exports.ProductCoverImageEntitySchema = void 0;
3
+ exports.ProductEntitySchema = exports.UpdateProductInputSchema = exports.ProductServiceAndComplianceInputSchema = exports.CreateProductInputSchema = exports.BaseProductSchema = exports.ProductDiscountEntitySchema = exports.ProductDeliveryFileEntitySchema = exports.ProductCoverImageEntitySchema = exports.DeliveryFileInputSchema = exports.CoverImageInputSchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
+ // --- File Input Schemas ---
7
+ exports.CoverImageInputSchema = zod_openapi_1.z.object({
8
+ key: zod_openapi_1.z.string().openapi({ description: "Storage key of the uploaded file" }),
9
+ mimeType: zod_openapi_1.z.string().openapi({ example: "image/jpeg" }),
10
+ isThumbnail: zod_openapi_1.z.boolean().default(false),
11
+ order: zod_openapi_1.z.number().int().default(0),
12
+ });
13
+ exports.DeliveryFileInputSchema = zod_openapi_1.z.object({
14
+ key: zod_openapi_1.z.string().openapi({ description: "Storage key of the uploaded file" }),
15
+ mimeType: zod_openapi_1.z.string().openapi({ example: "application/zip" }),
16
+ order: zod_openapi_1.z.number().int().default(0),
17
+ });
18
+ // --- Entity Schemas ---
6
19
  exports.ProductCoverImageEntitySchema = zod_openapi_1.z.object({
7
20
  fileId: zod_openapi_1.z
8
21
  .cuid2()
@@ -51,18 +64,21 @@ exports.BaseProductSchema = zod_openapi_1.z.object({
51
64
  supportEmail: zod_openapi_1.z.string().nullable(),
52
65
  supportPhone: zod_openapi_1.z.string().nullable(),
53
66
  });
67
+ // --- Core Input Schema ---
54
68
  const ProductCoreInputSchema = zod_openapi_1.z.object({
69
+ id: zod_openapi_1.z.cuid2().openapi({ description: "Client-generated ID for the product" }),
55
70
  title: zod_openapi_1.z.string().min(1, "Title is required").max(255),
56
71
  description: zod_openapi_1.z.string().min(1, "Description is required"),
57
72
  keyFeatures: zod_openapi_1.z.string(),
58
73
  category: zod_openapi_1.z.string().min(1, "Category is required"),
59
74
  subcategory: zod_openapi_1.z.string().optional(),
60
75
  tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).max(10, "Keep tags to a maximum of 10").default([]),
76
+ // Swapped to the new direct-upload input schemas
61
77
  coverImages: zod_openapi_1.z
62
- .array(exports.ProductCoverImageEntitySchema)
78
+ .array(exports.CoverImageInputSchema)
63
79
  .min(1, "At least one cover image is required")
64
80
  .max(3, "Maximum of 3 cover images allowed"),
65
- productFiles: zod_openapi_1.z.array(exports.ProductDeliveryFileEntitySchema).default([]),
81
+ productFiles: zod_openapi_1.z.array(exports.DeliveryFileInputSchema).default([]),
66
82
  productLinks: zod_openapi_1.z
67
83
  .array(zod_openapi_1.z.url().openapi({ example: "https://figma.com/file/..." }))
68
84
  .default([]),
@@ -126,6 +142,7 @@ exports.ProductServiceAndComplianceInputSchema = zod_openapi_1.z.object({
126
142
  providesSupport: zod_openapi_1.z.boolean(),
127
143
  agreesToTerms: zod_openapi_1.z.literal(true, "You must agree to the Terms."),
128
144
  });
145
+ // The `id` override here ensures we use the existing DB id when updating
129
146
  exports.UpdateProductInputSchema = ProductCoreInputSchema.extend(exports.ProductServiceAndComplianceInputSchema.omit({ id: true }).shape)
130
147
  .partial()
131
148
  .extend({
@@ -137,7 +154,7 @@ exports.ProductEntitySchema = zod_openapi_1.z
137
154
  sellerId: zod_openapi_1.z.cuid2().openapi({ description: "ID of the creator/seller" }),
138
155
  sellerUsername: zod_openapi_1.z.string(),
139
156
  sellerName: zod_openapi_1.z.string(),
140
- sellerImageUrl: zod_openapi_1.z.string().url().optional().nullable(),
157
+ sellerImageUrl: zod_openapi_1.z.url().optional().nullable(),
141
158
  title: zod_openapi_1.z.string(),
142
159
  description: zod_openapi_1.z.string(),
143
160
  keyFeatures: zod_openapi_1.z.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.2.93",
3
+ "version": "2.2.94",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,6 +1,23 @@
1
1
  import { z } from "@hono/zod-openapi";
2
2
  import { DISCOUNT_TYPES, PRICING_MODELS } from "../constants";
3
3
 
4
+ // --- File Input Schemas ---
5
+
6
+ export const CoverImageInputSchema = z.object({
7
+ key: z.string().openapi({ description: "Storage key of the uploaded file" }),
8
+ mimeType: z.string().openapi({ example: "image/jpeg" }),
9
+ isThumbnail: z.boolean().default(false),
10
+ order: z.number().int().default(0),
11
+ });
12
+
13
+ export const DeliveryFileInputSchema = z.object({
14
+ key: z.string().openapi({ description: "Storage key of the uploaded file" }),
15
+ mimeType: z.string().openapi({ example: "application/zip" }),
16
+ order: z.number().int().default(0),
17
+ });
18
+
19
+ // --- Entity Schemas ---
20
+
4
21
  export const ProductCoverImageEntitySchema = z.object({
5
22
  fileId: z
6
23
  .cuid2()
@@ -60,7 +77,11 @@ export const BaseProductSchema = z.object({
60
77
  supportPhone: z.string().nullable(),
61
78
  });
62
79
 
80
+ // --- Core Input Schema ---
81
+
63
82
  const ProductCoreInputSchema = z.object({
83
+ id: z.cuid2().openapi({ description: "Client-generated ID for the product" }),
84
+
64
85
  title: z.string().min(1, "Title is required").max(255),
65
86
  description: z.string().min(1, "Description is required"),
66
87
  keyFeatures: z.string(),
@@ -69,12 +90,14 @@ const ProductCoreInputSchema = z.object({
69
90
  subcategory: z.string().optional(),
70
91
  tags: z.array(z.string()).max(10, "Keep tags to a maximum of 10").default([]),
71
92
 
93
+ // Swapped to the new direct-upload input schemas
72
94
  coverImages: z
73
- .array(ProductCoverImageEntitySchema)
95
+ .array(CoverImageInputSchema)
74
96
  .min(1, "At least one cover image is required")
75
97
  .max(3, "Maximum of 3 cover images allowed"),
76
98
 
77
- productFiles: z.array(ProductDeliveryFileEntitySchema).default([]),
99
+ productFiles: z.array(DeliveryFileInputSchema).default([]),
100
+
78
101
  productLinks: z
79
102
  .array(z.url().openapi({ example: "https://figma.com/file/..." }))
80
103
  .default([]),
@@ -162,6 +185,7 @@ export const ProductServiceAndComplianceInputSchema = z.object({
162
185
  agreesToTerms: z.literal(true, "You must agree to the Terms."),
163
186
  });
164
187
 
188
+ // The `id` override here ensures we use the existing DB id when updating
165
189
  export const UpdateProductInputSchema = ProductCoreInputSchema.extend(
166
190
  ProductServiceAndComplianceInputSchema.omit({ id: true }).shape,
167
191
  )
@@ -177,7 +201,7 @@ export const ProductEntitySchema = z
177
201
  sellerId: z.cuid2().openapi({ description: "ID of the creator/seller" }),
178
202
  sellerUsername: z.string(),
179
203
  sellerName: z.string(),
180
- sellerImageUrl: z.string().url().optional().nullable(),
204
+ sellerImageUrl: z.url().optional().nullable(),
181
205
 
182
206
  title: z.string(),
183
207
  description: z.string(),
@@ -206,6 +230,11 @@ export const ProductEntitySchema = z
206
230
  })
207
231
  .openapi({ title: "ProductEntity" });
208
232
 
233
+ // --- Type Exports ---
234
+
235
+ export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
236
+ export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
237
+
209
238
  export type ProductCoverImageEntity = z.infer<
210
239
  typeof ProductCoverImageEntitySchema
211
240
  >;
@@ -221,4 +250,4 @@ export type ProductServiceAndComplianceInputEntity = z.infer<
221
250
  export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
222
251
  export type ProductEntity = z.infer<typeof ProductEntitySchema>;
223
252
 
224
- export type BaseProductEntity = z.infer<typeof BaseProductSchema>;
253
+ export type BaseProductEntity = z.infer<typeof BaseProductSchema>;