@zyacreatives/shared 2.5.3 → 2.5.6

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,24 +1,4 @@
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>;
13
- export declare const ProductCoverImageEntitySchema: z.ZodObject<{
14
- fileId: z.ZodCUID2;
15
- isThumbnail: z.ZodDefault<z.ZodBoolean>;
16
- order: z.ZodDefault<z.ZodNumber>;
17
- }, z.core.$strip>;
18
- export declare const ProductDeliveryFileEntitySchema: z.ZodObject<{
19
- fileId: z.ZodCUID2;
20
- order: z.ZodDefault<z.ZodNumber>;
21
- }, z.core.$strip>;
22
2
  export declare const ProductDiscountEntitySchema: z.ZodObject<{
23
3
  discountType: z.ZodEnum<{
24
4
  readonly FIXED_AMOUNT: "Fixed Amount";
@@ -32,61 +12,6 @@ export declare const ProductLinkSchema: z.ZodObject<{
32
12
  title: z.ZodNullable<z.ZodString>;
33
13
  url: z.ZodString;
34
14
  }, z.core.$strip>;
35
- export type ProductLink = z.infer<typeof ProductLinkSchema>;
36
- export declare const BaseProductSchema: z.ZodObject<{
37
- id: z.ZodCUID2;
38
- createdAt: z.ZodDate;
39
- updatedAt: z.ZodDate;
40
- deletedAt: z.ZodNullable<z.ZodDate>;
41
- status: z.ZodDefault<z.ZodEnum<{
42
- readonly ACTIVE: "ACTIVE";
43
- readonly UNDER_REVIEW: "UNDER_REVIEW";
44
- readonly DRAFT: "DRAFT";
45
- readonly ARCHIVED: "ARCHIVED";
46
- readonly DELETED: "DELETED";
47
- }>>;
48
- sellerId: z.ZodCUID2;
49
- title: z.ZodString;
50
- description: z.ZodString;
51
- keyFeatures: z.ZodString;
52
- category: z.ZodString;
53
- subcategory: z.ZodNullable<z.ZodString>;
54
- tags: z.ZodNullable<z.ZodArray<z.ZodString>>;
55
- productLinks: z.ZodNullable<z.ZodArray<z.ZodObject<{
56
- title: z.ZodNullable<z.ZodString>;
57
- url: z.ZodString;
58
- }, z.core.$strip>>>;
59
- pricingModel: z.ZodEnum<{
60
- readonly FREE: "Free";
61
- readonly FIXED: "Fixed";
62
- readonly PWYW: "Pay What You Want";
63
- }>;
64
- currency: z.ZodEnum<{
65
- readonly USD: "USD (United States Dollar)";
66
- readonly EUR: "EUR (Euro)";
67
- readonly GBP: "GBP (British Pound Sterling)";
68
- readonly NGN: "NGN (Nigerian Naira)";
69
- readonly CAD: "CAD (Canadian Dollar)";
70
- readonly AUD: "AUD (Australian Dollar)";
71
- readonly JPY: "JPY (Japanese Yen)";
72
- readonly CHF: "CHF (Swiss Franc)";
73
- readonly INR: "INR (Indian Rupee)";
74
- readonly ZAR: "ZAR (South African Rand)";
75
- }>;
76
- price: z.ZodNullable<z.ZodNumber>;
77
- suggestedPrice: z.ZodNullable<z.ZodNumber>;
78
- discounts: z.ZodNullable<z.ZodArray<z.ZodObject<{
79
- discountType: z.ZodEnum<{
80
- readonly FIXED_AMOUNT: "Fixed Amount";
81
- readonly PERCENTAGE: "Percentage";
82
- }>;
83
- amount: z.ZodNumber;
84
- discountCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
85
- expiry: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
86
- }, z.core.$strip>>>;
87
- supportEmail: z.ZodNullable<z.ZodString>;
88
- supportPhone: z.ZodNullable<z.ZodString>;
89
- }, z.core.$strip>;
90
15
  export declare const CreateProductInputSchema: z.ZodObject<{
91
16
  id: z.ZodCUID2;
92
17
  title: z.ZodString;
@@ -102,12 +27,28 @@ export declare const CreateProductInputSchema: z.ZodObject<{
102
27
  category: z.ZodString;
103
28
  subcategory: z.ZodOptional<z.ZodString>;
104
29
  tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
105
- coverImages: z.ZodArray<z.ZodObject<{
30
+ files: z.ZodDefault<z.ZodArray<z.ZodObject<{
106
31
  key: z.ZodString;
107
32
  mimeType: z.ZodString;
108
- isThumbnail: z.ZodDefault<z.ZodBoolean>;
109
- order: z.ZodDefault<z.ZodNumber>;
110
- }, z.core.$strip>>;
33
+ parentId: z.ZodOptional<z.ZodCUID2>;
34
+ parentType: z.ZodOptional<z.ZodEnum<{
35
+ readonly PROJECT: "PROJECT";
36
+ readonly USER: "USER";
37
+ readonly JOB: "JOB";
38
+ readonly POST: "POST";
39
+ readonly PRODUCT: "PRODUCT";
40
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
41
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
42
+ readonly COMMENT: "COMMENT";
43
+ readonly JOB_APPLICATION: "JOB_APPLICATION";
44
+ }>>;
45
+ isThumbnail: z.ZodOptional<z.ZodBoolean>;
46
+ order: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
47
+ }, z.core.$strip>>>;
48
+ productLinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
49
+ title: z.ZodNullable<z.ZodString>;
50
+ url: z.ZodString;
51
+ }, z.core.$strip>>>;
111
52
  currency: z.ZodEnum<{
112
53
  readonly USD: "USD (United States Dollar)";
113
54
  readonly EUR: "EUR (Euro)";
@@ -120,15 +61,6 @@ export declare const CreateProductInputSchema: z.ZodObject<{
120
61
  readonly INR: "INR (Indian Rupee)";
121
62
  readonly ZAR: "ZAR (South African Rand)";
122
63
  }>;
123
- productFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
124
- key: z.ZodString;
125
- mimeType: z.ZodString;
126
- order: z.ZodDefault<z.ZodNumber>;
127
- }, z.core.$strip>>>;
128
- productLinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
129
- title: z.ZodNullable<z.ZodString>;
130
- url: z.ZodString;
131
- }, z.core.$strip>>>;
132
64
  pricingModel: z.ZodDefault<z.ZodEnum<{
133
65
  readonly FREE: "Free";
134
66
  readonly FIXED: "Fixed";
@@ -169,12 +101,28 @@ export declare const UpdateProductInputSchema: z.ZodObject<{
169
101
  category: z.ZodOptional<z.ZodString>;
170
102
  subcategory: z.ZodOptional<z.ZodOptional<z.ZodString>>;
171
103
  tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
172
- coverImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
104
+ files: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
173
105
  key: z.ZodString;
174
106
  mimeType: z.ZodString;
175
- isThumbnail: z.ZodDefault<z.ZodBoolean>;
176
- order: z.ZodDefault<z.ZodNumber>;
177
- }, z.core.$strip>>>;
107
+ parentId: z.ZodOptional<z.ZodCUID2>;
108
+ parentType: z.ZodOptional<z.ZodEnum<{
109
+ readonly PROJECT: "PROJECT";
110
+ readonly USER: "USER";
111
+ readonly JOB: "JOB";
112
+ readonly POST: "POST";
113
+ readonly PRODUCT: "PRODUCT";
114
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
115
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
116
+ readonly COMMENT: "COMMENT";
117
+ readonly JOB_APPLICATION: "JOB_APPLICATION";
118
+ }>>;
119
+ isThumbnail: z.ZodOptional<z.ZodBoolean>;
120
+ order: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
121
+ }, z.core.$strip>>>>;
122
+ productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
123
+ title: z.ZodNullable<z.ZodString>;
124
+ url: z.ZodString;
125
+ }, z.core.$strip>>>>;
178
126
  currency: z.ZodOptional<z.ZodEnum<{
179
127
  readonly USD: "USD (United States Dollar)";
180
128
  readonly EUR: "EUR (Euro)";
@@ -187,15 +135,6 @@ export declare const UpdateProductInputSchema: z.ZodObject<{
187
135
  readonly INR: "INR (Indian Rupee)";
188
136
  readonly ZAR: "ZAR (South African Rand)";
189
137
  }>>;
190
- productFiles: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
191
- key: z.ZodString;
192
- mimeType: z.ZodString;
193
- order: z.ZodDefault<z.ZodNumber>;
194
- }, z.core.$strip>>>>;
195
- productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
196
- title: z.ZodNullable<z.ZodString>;
197
- url: z.ZodString;
198
- }, z.core.$strip>>>>;
199
138
  pricingModel: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
200
139
  readonly FREE: "Free";
201
140
  readonly FIXED: "Fixed";
@@ -239,18 +178,33 @@ export declare const ProductEntitySchema: z.ZodObject<{
239
178
  category: z.ZodString;
240
179
  subcategory: z.ZodNullable<z.ZodOptional<z.ZodString>>;
241
180
  tags: z.ZodArray<z.ZodString>;
242
- coverImages: z.ZodDefault<z.ZodArray<z.ZodObject<{
243
- fileId: z.ZodCUID2;
244
- isThumbnail: z.ZodDefault<z.ZodBoolean>;
245
- order: z.ZodDefault<z.ZodNumber>;
181
+ files: z.ZodDefault<z.ZodArray<z.ZodObject<{
182
+ id: z.ZodCUID2;
183
+ key: z.ZodString;
184
+ mimeType: z.ZodString;
246
185
  url: z.ZodURL;
186
+ parentId: z.ZodNullable<z.ZodCUID2>;
187
+ parentType: z.ZodNullable<z.ZodEnum<{
188
+ readonly PROJECT: "PROJECT";
189
+ readonly USER: "USER";
190
+ readonly JOB: "JOB";
191
+ readonly POST: "POST";
192
+ readonly PRODUCT: "PRODUCT";
193
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
194
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
195
+ readonly COMMENT: "COMMENT";
196
+ readonly JOB_APPLICATION: "JOB_APPLICATION";
197
+ }>>;
198
+ isThumbnail: z.ZodNullable<z.ZodBoolean>;
199
+ order: z.ZodNumber;
200
+ createdAt: z.ZodCoercedDate<unknown>;
201
+ updatedAt: z.ZodCoercedDate<unknown>;
202
+ deletedAt: z.ZodNullable<z.ZodCoercedDate<unknown>>;
247
203
  }, z.core.$strip>>>;
248
- productFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
249
- fileId: z.ZodCUID2;
250
- order: z.ZodDefault<z.ZodNumber>;
251
- url: z.ZodURL;
204
+ productLinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
205
+ title: z.ZodNullable<z.ZodString>;
206
+ url: z.ZodString;
252
207
  }, z.core.$strip>>>;
253
- productLinks: z.ZodDefault<z.ZodArray<z.ZodURL>>;
254
208
  pricingModel: z.ZodEnum<{
255
209
  readonly FREE: "Free";
256
210
  readonly FIXED: "Fixed";
@@ -279,6 +233,10 @@ export declare const ProductEntitySchema: z.ZodObject<{
279
233
  discountCode: z.ZodOptional<z.ZodString>;
280
234
  expiry: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
281
235
  }, z.core.$strip>>>;
236
+ ownsRights: z.ZodBoolean;
237
+ noHarmfulContent: z.ZodBoolean;
238
+ providesSupport: z.ZodBoolean;
239
+ agreesToTerms: z.ZodBoolean;
282
240
  supportEmail: z.ZodNullable<z.ZodOptional<z.ZodEmail>>;
283
241
  supportPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
284
242
  createdAt: z.ZodCoercedDate<unknown>;
@@ -453,18 +411,14 @@ export declare const GetMarketplaceInfoOutputSchema: z.ZodObject<{
453
411
  deletedAt: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
454
412
  }, z.core.$strip>>;
455
413
  }, z.core.$strip>;
414
+ export type ProductLink = z.infer<typeof ProductLinkSchema>;
456
415
  export type SearchProductInput = z.infer<typeof SearchProductInputSchema>;
457
416
  export type SearchProductOutput = z.infer<typeof SearchProductOutputSchema>;
458
- export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
459
- export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
460
417
  export type MarketplaceCategoryOutput = z.infer<typeof MarketplaceCategorySchema>;
461
418
  export type GetMarketplaceInfoOutput = z.infer<typeof GetMarketplaceInfoOutputSchema>;
462
- export type ProductCoverImageEntity = z.infer<typeof ProductCoverImageEntitySchema>;
463
- export type ProductDeliveryFileEntity = z.infer<typeof ProductDeliveryFileEntitySchema>;
464
419
  export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
465
420
  export type CreateProductInputEntity = z.infer<typeof CreateProductInputSchema>;
466
421
  export type ProductServiceAndComplianceInputEntity = z.infer<typeof ProductServiceAndComplianceInputSchema>;
467
422
  export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
468
423
  export type ProductEntity = z.infer<typeof ProductEntitySchema>;
469
- export type BaseProductEntity = z.infer<typeof BaseProductSchema>;
470
424
  export type ProductSearchDocument = z.infer<typeof ProductSearchDocumentSchema>;
@@ -1,32 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetMarketplaceInfoOutputSchema = exports.MarketplaceCategorySchema = exports.SearchProductOutputSchema = exports.SearchProductInputSchema = exports.ProductSearchDocumentSchema = exports.ProductEntitySchema = exports.UpdateProductInputSchema = exports.ProductServiceAndComplianceInputSchema = exports.CreateProductInputSchema = exports.BaseProductSchema = exports.ProductLinkSchema = exports.ProductDiscountEntitySchema = exports.ProductDeliveryFileEntitySchema = exports.ProductCoverImageEntitySchema = exports.DeliveryFileInputSchema = exports.CoverImageInputSchema = void 0;
3
+ exports.GetMarketplaceInfoOutputSchema = exports.MarketplaceCategorySchema = exports.SearchProductOutputSchema = exports.SearchProductInputSchema = exports.ProductSearchDocumentSchema = exports.ProductEntitySchema = exports.UpdateProductInputSchema = exports.ProductServiceAndComplianceInputSchema = exports.CreateProductInputSchema = exports.ProductLinkSchema = exports.ProductDiscountEntitySchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
5
  const constants_1 = require("../constants");
6
- exports.CoverImageInputSchema = zod_openapi_1.z.object({
7
- key: zod_openapi_1.z.string().openapi({ description: "Storage key of the uploaded file" }),
8
- mimeType: zod_openapi_1.z.string().openapi({ example: "image/jpeg" }),
9
- isThumbnail: zod_openapi_1.z.boolean().default(false),
10
- order: zod_openapi_1.z.number().int().default(0),
11
- });
12
- exports.DeliveryFileInputSchema = zod_openapi_1.z.object({
13
- key: zod_openapi_1.z.string().openapi({ description: "Storage key of the uploaded file" }),
14
- mimeType: zod_openapi_1.z.string().openapi({ example: "application/zip" }),
15
- order: zod_openapi_1.z.number().int().default(0),
16
- });
17
- exports.ProductCoverImageEntitySchema = zod_openapi_1.z.object({
18
- fileId: zod_openapi_1.z
19
- .cuid2()
20
- .openapi({ example: "f123e4567-e89b-12d3-a456-426614174000" }),
21
- isThumbnail: zod_openapi_1.z.boolean().default(false),
22
- order: zod_openapi_1.z.number().int().default(0),
23
- });
24
- exports.ProductDeliveryFileEntitySchema = zod_openapi_1.z.object({
25
- fileId: zod_openapi_1.z
26
- .cuid2()
27
- .openapi({ example: "f987e6543-e89b-12d3-a456-426614174000" }),
28
- order: zod_openapi_1.z.number().int().default(0),
29
- });
6
+ const file_1 = require("./file");
30
7
  exports.ProductDiscountEntitySchema = zod_openapi_1.z.object({
31
8
  discountType: zod_openapi_1.z.enum(constants_1.DISCOUNT_TYPES),
32
9
  amount: zod_openapi_1.z
@@ -40,35 +17,7 @@ exports.ProductLinkSchema = zod_openapi_1.z.object({
40
17
  title: zod_openapi_1.z.string().nullable(),
41
18
  url: zod_openapi_1.z.string(),
42
19
  });
43
- exports.BaseProductSchema = zod_openapi_1.z.object({
44
- id: zod_openapi_1.z.cuid2(),
45
- createdAt: zod_openapi_1.z.date(),
46
- updatedAt: zod_openapi_1.z.date(),
47
- deletedAt: zod_openapi_1.z.date().nullable(),
48
- status: zod_openapi_1.z.enum(constants_1.PRODUCT_STATUS).default("DRAFT"),
49
- sellerId: zod_openapi_1.z.cuid2(),
50
- title: zod_openapi_1.z.string(),
51
- description: zod_openapi_1.z.string(),
52
- keyFeatures: zod_openapi_1.z.string(),
53
- category: zod_openapi_1.z.string(),
54
- subcategory: zod_openapi_1.z.string().nullable(),
55
- tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).nullable(),
56
- productLinks: zod_openapi_1.z.array(exports.ProductLinkSchema).nullable(),
57
- pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS),
58
- currency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY),
59
- price: zod_openapi_1.z.number().nullable(),
60
- suggestedPrice: zod_openapi_1.z.number().nullable(),
61
- discounts: zod_openapi_1.z
62
- .array(zod_openapi_1.z.object({
63
- discountType: zod_openapi_1.z.enum(constants_1.DISCOUNT_TYPES),
64
- amount: zod_openapi_1.z.number(),
65
- discountCode: zod_openapi_1.z.string().optional().nullable(),
66
- expiry: zod_openapi_1.z.coerce.date().optional().nullable(),
67
- }))
68
- .nullable(),
69
- supportEmail: zod_openapi_1.z.string().nullable(),
70
- supportPhone: zod_openapi_1.z.string().nullable(),
71
- });
20
+ // --- 3. Input Validation Schemas ---
72
21
  const ProductCoreInputSchema = zod_openapi_1.z.object({
73
22
  id: zod_openapi_1.z.cuid2().openapi({ description: "Client-generated ID for the product" }),
74
23
  title: zod_openapi_1.z.string().min(1, "Title is required").max(255),
@@ -78,19 +27,16 @@ const ProductCoreInputSchema = zod_openapi_1.z.object({
78
27
  category: zod_openapi_1.z.string().min(1, "Category is required"),
79
28
  subcategory: zod_openapi_1.z.string().optional(),
80
29
  tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).max(10, "Keep tags to a maximum of 10").default([]),
81
- coverImages: zod_openapi_1.z
82
- .array(exports.CoverImageInputSchema)
83
- .min(1, "At least one cover image is required")
84
- .max(5, "Maximum of 5 cover images allowed"),
85
- currency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY),
86
- productFiles: zod_openapi_1.z.array(exports.DeliveryFileInputSchema).default([]),
30
+ files: zod_openapi_1.z.array(file_1.CreateFileInputSchema).default([]),
87
31
  productLinks: zod_openapi_1.z.array(exports.ProductLinkSchema).default([]),
32
+ currency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY),
88
33
  pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS).default(constants_1.PRICING_MODELS.FIXED),
89
34
  price: zod_openapi_1.z.number().int("Must be a whole number").min(0).optional(),
90
35
  suggestedPrice: zod_openapi_1.z.number().int("Must be in cents").min(0).optional(),
91
36
  discounts: zod_openapi_1.z.array(exports.ProductDiscountEntitySchema).max(3).default([]),
92
37
  });
93
38
  exports.CreateProductInputSchema = ProductCoreInputSchema.superRefine((data, ctx) => {
39
+ // Pricing Validation
94
40
  if (data.pricingModel === constants_1.PRICING_MODELS.FIXED &&
95
41
  (!data.price || data.price <= 0)) {
96
42
  ctx.addIssue({
@@ -101,14 +47,13 @@ exports.CreateProductInputSchema = ProductCoreInputSchema.superRefine((data, ctx
101
47
  }
102
48
  if (data.pricingModel === constants_1.PRICING_MODELS.PWYW &&
103
49
  data.suggestedPrice !== undefined &&
104
- data.price !== undefined) {
105
- if (data.suggestedPrice < data.price) {
106
- ctx.addIssue({
107
- code: "custom",
108
- message: "Suggested price cannot be lower than the minimum price.",
109
- path: ["suggestedPrice"],
110
- });
111
- }
50
+ data.price !== undefined &&
51
+ data.suggestedPrice < data.price) {
52
+ ctx.addIssue({
53
+ code: "custom",
54
+ message: "Suggested price cannot be lower than the minimum price.",
55
+ path: ["suggestedPrice"],
56
+ });
112
57
  }
113
58
  if (data.pricingModel === constants_1.PRICING_MODELS.FREE &&
114
59
  data.price &&
@@ -119,21 +64,33 @@ exports.CreateProductInputSchema = ProductCoreInputSchema.superRefine((data, ctx
119
64
  path: ["price"],
120
65
  });
121
66
  }
122
- if (data.productFiles.length === 0 && data.productLinks.length === 0) {
67
+ // File Validation based on parentType
68
+ const deliveryFiles = data.files.filter((f) => f.parentType === "PRODUCT_DELIVERY");
69
+ const coverImages = data.files.filter((f) => f.parentType === "PRODUCT_COVER");
70
+ if (deliveryFiles.length === 0 && data.productLinks.length === 0) {
123
71
  ctx.addIssue({
124
72
  code: "custom",
125
73
  message: "You must provide at least one product file or a link for the buyer to receive.",
126
- path: ["productFiles"],
74
+ path: ["files"],
127
75
  });
128
76
  }
129
- const thumbnails = data.coverImages.filter((img) => img.isThumbnail);
130
- if (thumbnails.length !== 1) {
77
+ if (coverImages.length < 1 || coverImages.length > 5) {
131
78
  ctx.addIssue({
132
79
  code: "custom",
133
- message: "Exactly one cover image must be set as the thumbnail.",
134
- path: ["coverImages"],
80
+ message: "Between 1 and 5 cover images are required.",
81
+ path: ["files"],
135
82
  });
136
83
  }
84
+ else {
85
+ const thumbnails = coverImages.filter((img) => img.isThumbnail);
86
+ if (thumbnails.length !== 1) {
87
+ ctx.addIssue({
88
+ code: "custom",
89
+ message: "Exactly one cover image must be set as the thumbnail.",
90
+ path: ["files"],
91
+ });
92
+ }
93
+ }
137
94
  data.discounts.forEach((discount, index) => {
138
95
  const isPercentage = String(discount.discountType).toUpperCase() === "PERCENTAGE";
139
96
  const isFixed = String(discount.discountType).toUpperCase() === "FIXED";
@@ -144,14 +101,14 @@ exports.CreateProductInputSchema = ProductCoreInputSchema.superRefine((data, ctx
144
101
  path: ["discounts", index, "amount"],
145
102
  });
146
103
  }
147
- if (isFixed && data.price !== undefined) {
148
- if (discount.amount >= data.price) {
149
- ctx.addIssue({
150
- code: "custom",
151
- message: "Fixed discount amounts must be less than the product price.",
152
- path: ["discounts", index, "amount"],
153
- });
154
- }
104
+ if (isFixed &&
105
+ data.price !== undefined &&
106
+ discount.amount >= data.price) {
107
+ ctx.addIssue({
108
+ code: "custom",
109
+ message: "Fixed discount amounts must be less than the product price.",
110
+ path: ["discounts", index, "amount"],
111
+ });
155
112
  }
156
113
  });
157
114
  });
@@ -159,17 +116,17 @@ exports.ProductServiceAndComplianceInputSchema = zod_openapi_1.z.object({
159
116
  id: zod_openapi_1.z.cuid2().openapi({ description: "ID of the product" }),
160
117
  supportEmail: zod_openapi_1.z.email("A valid support email is required"),
161
118
  supportPhone: zod_openapi_1.z.string().optional(),
162
- ownsRights: zod_openapi_1.z.literal(true, "You must confirm you own the rights to this product."),
119
+ ownsRights: zod_openapi_1.z.literal(true, '"You must confirm you own the rights to this product."'),
163
120
  noHarmfulContent: zod_openapi_1.z.literal(true, "You must confirm no harmful content."),
164
121
  providesSupport: zod_openapi_1.z.boolean(),
165
122
  agreesToTerms: zod_openapi_1.z.literal(true, "You must agree to the Terms."),
166
123
  });
167
- // The `id` override here ensures we use the existing DB id when updating
168
124
  exports.UpdateProductInputSchema = ProductCoreInputSchema.extend(exports.ProductServiceAndComplianceInputSchema.omit({ id: true }).shape)
169
125
  .partial()
170
126
  .extend({
171
127
  id: zod_openapi_1.z.cuid2().openapi({ description: "ID of the product being updated" }),
172
128
  });
129
+ // --- 4. Entity & Output Schemas ---
173
130
  exports.ProductEntitySchema = zod_openapi_1.z
174
131
  .object({
175
132
  id: zod_openapi_1.z.cuid2(),
@@ -184,18 +141,18 @@ exports.ProductEntitySchema = zod_openapi_1.z
184
141
  category: zod_openapi_1.z.string(),
185
142
  subcategory: zod_openapi_1.z.string().optional().nullable(),
186
143
  tags: zod_openapi_1.z.array(zod_openapi_1.z.string()),
187
- coverImages: zod_openapi_1.z
188
- .array(exports.ProductCoverImageEntitySchema.extend({ url: zod_openapi_1.z.url() }))
189
- .default([]),
190
- productFiles: zod_openapi_1.z
191
- .array(exports.ProductDeliveryFileEntitySchema.extend({ url: zod_openapi_1.z.url() }))
192
- .default([]),
193
- productLinks: zod_openapi_1.z.array(zod_openapi_1.z.url()).default([]),
144
+ // Unified files array for output
145
+ files: zod_openapi_1.z.array(file_1.FileEntitySchema).default([]),
146
+ productLinks: zod_openapi_1.z.array(exports.ProductLinkSchema).default([]),
194
147
  pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS),
195
148
  currency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY),
196
149
  price: zod_openapi_1.z.number().int().optional().nullable(),
197
150
  suggestedPrice: zod_openapi_1.z.number().int().optional().nullable(),
198
151
  discounts: zod_openapi_1.z.array(exports.ProductDiscountEntitySchema).default([]),
152
+ ownsRights: zod_openapi_1.z.boolean(),
153
+ noHarmfulContent: zod_openapi_1.z.boolean(),
154
+ providesSupport: zod_openapi_1.z.boolean(),
155
+ agreesToTerms: zod_openapi_1.z.boolean(),
199
156
  supportEmail: zod_openapi_1.z.email().optional().nullable(),
200
157
  supportPhone: zod_openapi_1.z.string().optional().nullable(),
201
158
  createdAt: zod_openapi_1.z.coerce.date(),
@@ -169,6 +169,8 @@ export declare const CommentOnProjectInputSchema: z.ZodObject<{
169
169
  readonly JOB: "JOB";
170
170
  readonly POST: "POST";
171
171
  readonly PRODUCT: "PRODUCT";
172
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
173
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
172
174
  readonly COMMENT: "COMMENT";
173
175
  readonly JOB_APPLICATION: "JOB_APPLICATION";
174
176
  }>;
@@ -466,6 +468,8 @@ export declare const ProjectWithProjectCommentsEntitySchema: z.ZodObject<{
466
468
  readonly JOB: "JOB";
467
469
  readonly POST: "POST";
468
470
  readonly PRODUCT: "PRODUCT";
471
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
472
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
469
473
  readonly COMMENT: "COMMENT";
470
474
  readonly JOB_APPLICATION: "JOB_APPLICATION";
471
475
  }>;
@@ -500,6 +504,8 @@ export declare const GetProjectWithCommentsOutputSchema: z.ZodObject<{
500
504
  readonly JOB: "JOB";
501
505
  readonly POST: "POST";
502
506
  readonly PRODUCT: "PRODUCT";
507
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
508
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
503
509
  readonly COMMENT: "COMMENT";
504
510
  readonly JOB_APPLICATION: "JOB_APPLICATION";
505
511
  }>;
@@ -587,6 +593,8 @@ export declare const ProjectWithProjectViewsEntitySchema: z.ZodObject<{
587
593
  readonly JOB: "JOB";
588
594
  readonly POST: "POST";
589
595
  readonly PRODUCT: "PRODUCT";
596
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
597
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
590
598
  readonly COMMENT: "COMMENT";
591
599
  readonly JOB_APPLICATION: "JOB_APPLICATION";
592
600
  }>;
@@ -614,6 +622,8 @@ export declare const ProjectWithProjectBookmarksEntitySchema: z.ZodObject<{
614
622
  readonly JOB: "JOB";
615
623
  readonly POST: "POST";
616
624
  readonly PRODUCT: "PRODUCT";
625
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
626
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
617
627
  readonly COMMENT: "COMMENT";
618
628
  readonly JOB_APPLICATION: "JOB_APPLICATION";
619
629
  }>;
@@ -819,6 +829,8 @@ export declare const CommentOnProjectOutputSchema: z.ZodObject<{
819
829
  readonly JOB: "JOB";
820
830
  readonly POST: "POST";
821
831
  readonly PRODUCT: "PRODUCT";
832
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
833
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
822
834
  readonly COMMENT: "COMMENT";
823
835
  readonly JOB_APPLICATION: "JOB_APPLICATION";
824
836
  }>;
@@ -65,7 +65,6 @@ export declare const CreateTransactionInputSchema: z.ZodObject<{
65
65
  readonly REFUNDED: "REFUNDED";
66
66
  }>>;
67
67
  amount: z.ZodNumber;
68
- sellerId: z.ZodCUID2;
69
68
  currency: z.ZodEnum<{
70
69
  readonly USD: "USD (United States Dollar)";
71
70
  readonly EUR: "EUR (Euro)";
@@ -78,6 +77,7 @@ export declare const CreateTransactionInputSchema: z.ZodObject<{
78
77
  readonly INR: "INR (Indian Rupee)";
79
78
  readonly ZAR: "ZAR (South African Rand)";
80
79
  }>;
80
+ sellerId: z.ZodCUID2;
81
81
  productId: z.ZodCUID2;
82
82
  buyerId: z.ZodCUID2;
83
83
  platformFee: z.ZodNumber;
@@ -11,6 +11,8 @@ export declare const UserStrikeEntitySchema: z.ZodObject<{
11
11
  readonly JOB: "JOB";
12
12
  readonly POST: "POST";
13
13
  readonly PRODUCT: "PRODUCT";
14
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
15
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
14
16
  readonly COMMENT: "COMMENT";
15
17
  readonly JOB_APPLICATION: "JOB_APPLICATION";
16
18
  }>>;
@@ -27,6 +29,8 @@ export declare const UpsertUserStrikeInputSchema: z.ZodObject<{
27
29
  readonly JOB: "JOB";
28
30
  readonly POST: "POST";
29
31
  readonly PRODUCT: "PRODUCT";
32
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
33
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
30
34
  readonly COMMENT: "COMMENT";
31
35
  readonly JOB_APPLICATION: "JOB_APPLICATION";
32
36
  }>>;
@@ -43,6 +47,8 @@ export declare const UpsertUserStrikeOutputSchema: z.ZodObject<{
43
47
  readonly JOB: "JOB";
44
48
  readonly POST: "POST";
45
49
  readonly PRODUCT: "PRODUCT";
50
+ readonly PRODUCT_COVER: "PRODUCT_COVER";
51
+ readonly PRODUCT_DELIVERY: "PRODUCT_DELIVERY";
46
52
  readonly COMMENT: "COMMENT";
47
53
  readonly JOB_APPLICATION: "JOB_APPLICATION";
48
54
  }>>;