@zyacreatives/shared 2.2.92 → 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.
@@ -89,9 +89,7 @@ exports.PostEntitySchema = zod_openapi_1.z.object({
89
89
  });
90
90
  exports.PostFileEntitySchema = zod_openapi_1.z
91
91
  .object({
92
- id: zod_openapi_1.z
93
- .cuid2()
94
- .openapi({
92
+ id: zod_openapi_1.z.cuid2().openapi({
95
93
  description: "CUID2 of the project file record.",
96
94
  example: "cxy1a2b3c0000qwe",
97
95
  }),
@@ -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>;
@@ -16,7 +27,40 @@ export declare const ProductDiscountEntitySchema: z.ZodObject<{
16
27
  amount: z.ZodNumber;
17
28
  discountCode: z.ZodOptional<z.ZodString>;
18
29
  }, z.core.$strip>;
30
+ export declare const BaseProductSchema: z.ZodObject<{
31
+ id: z.ZodCUID2;
32
+ createdAt: z.ZodDate;
33
+ updatedAt: z.ZodDate;
34
+ deletedAt: z.ZodNullable<z.ZodDate>;
35
+ sellerId: z.ZodCUID2;
36
+ title: z.ZodString;
37
+ description: z.ZodString;
38
+ keyFeatures: z.ZodString;
39
+ category: z.ZodString;
40
+ subcategory: z.ZodNullable<z.ZodString>;
41
+ tags: z.ZodNullable<z.ZodArray<z.ZodString>>;
42
+ productLinks: z.ZodNullable<z.ZodArray<z.ZodString>>;
43
+ pricingModel: z.ZodEnum<{
44
+ readonly FREE: "Free";
45
+ readonly FIXED: "Fixed";
46
+ readonly PWYW: "Pay What You Want";
47
+ }>;
48
+ currency: z.ZodString;
49
+ price: z.ZodNullable<z.ZodNumber>;
50
+ suggestedPrice: z.ZodNullable<z.ZodNumber>;
51
+ discounts: z.ZodNullable<z.ZodArray<z.ZodObject<{
52
+ discountType: z.ZodEnum<{
53
+ readonly FIXED_AMOUNT: "Fixed Amount";
54
+ readonly PERCENTAGE: "Percentage";
55
+ }>;
56
+ amount: z.ZodNumber;
57
+ discountCode: z.ZodNullable<z.ZodOptional<z.ZodString>>;
58
+ }, z.core.$strip>>>;
59
+ supportEmail: z.ZodNullable<z.ZodString>;
60
+ supportPhone: z.ZodNullable<z.ZodString>;
61
+ }, z.core.$strip>;
19
62
  export declare const CreateProductInputSchema: z.ZodObject<{
63
+ id: z.ZodCUID2;
20
64
  title: z.ZodString;
21
65
  description: z.ZodString;
22
66
  keyFeatures: z.ZodString;
@@ -24,12 +68,14 @@ export declare const CreateProductInputSchema: z.ZodObject<{
24
68
  subcategory: z.ZodOptional<z.ZodString>;
25
69
  tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
26
70
  coverImages: z.ZodArray<z.ZodObject<{
27
- fileId: z.ZodCUID2;
71
+ key: z.ZodString;
72
+ mimeType: z.ZodString;
28
73
  isThumbnail: z.ZodDefault<z.ZodBoolean>;
29
74
  order: z.ZodDefault<z.ZodNumber>;
30
75
  }, z.core.$strip>>;
31
76
  productFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
32
- fileId: z.ZodCUID2;
77
+ key: z.ZodString;
78
+ mimeType: z.ZodString;
33
79
  order: z.ZodDefault<z.ZodNumber>;
34
80
  }, z.core.$strip>>>;
35
81
  productLinks: z.ZodDefault<z.ZodArray<z.ZodURL>>;
@@ -67,12 +113,14 @@ export declare const UpdateProductInputSchema: z.ZodObject<{
67
113
  subcategory: z.ZodOptional<z.ZodOptional<z.ZodString>>;
68
114
  tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
69
115
  coverImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
70
- fileId: z.ZodCUID2;
116
+ key: z.ZodString;
117
+ mimeType: z.ZodString;
71
118
  isThumbnail: z.ZodDefault<z.ZodBoolean>;
72
119
  order: z.ZodDefault<z.ZodNumber>;
73
120
  }, z.core.$strip>>>;
74
121
  productFiles: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
75
- fileId: z.ZodCUID2;
122
+ key: z.ZodString;
123
+ mimeType: z.ZodString;
76
124
  order: z.ZodDefault<z.ZodNumber>;
77
125
  }, z.core.$strip>>>>;
78
126
  productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodURL>>>;
@@ -105,7 +153,7 @@ export declare const ProductEntitySchema: z.ZodObject<{
105
153
  sellerId: z.ZodCUID2;
106
154
  sellerUsername: z.ZodString;
107
155
  sellerName: z.ZodString;
108
- sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
156
+ sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
109
157
  title: z.ZodString;
110
158
  description: z.ZodString;
111
159
  keyFeatures: z.ZodString;
@@ -144,6 +192,8 @@ export declare const ProductEntitySchema: z.ZodObject<{
144
192
  updatedAt: z.ZodCoercedDate<unknown>;
145
193
  deletedAt: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
146
194
  }, z.core.$strip>;
195
+ export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
196
+ export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
147
197
  export type ProductCoverImageEntity = z.infer<typeof ProductCoverImageEntitySchema>;
148
198
  export type ProductDeliveryFileEntity = z.infer<typeof ProductDeliveryFileEntitySchema>;
149
199
  export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
@@ -151,3 +201,4 @@ export type CreateProductInputEntity = z.infer<typeof CreateProductInputSchema>;
151
201
  export type ProductServiceAndComplianceInputEntity = z.infer<typeof ProductServiceAndComplianceInputSchema>;
152
202
  export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
153
203
  export type ProductEntity = z.infer<typeof ProductEntitySchema>;
204
+ export type BaseProductEntity = z.infer<typeof BaseProductSchema>;
@@ -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.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()
@@ -24,18 +37,48 @@ exports.ProductDiscountEntitySchema = zod_openapi_1.z.object({
24
37
  .min(0, "Discount amount cannot be negative"),
25
38
  discountCode: zod_openapi_1.z.string().optional(),
26
39
  });
40
+ exports.BaseProductSchema = zod_openapi_1.z.object({
41
+ id: zod_openapi_1.z.cuid2(),
42
+ createdAt: zod_openapi_1.z.date(),
43
+ updatedAt: zod_openapi_1.z.date(),
44
+ deletedAt: zod_openapi_1.z.date().nullable(),
45
+ sellerId: zod_openapi_1.z.cuid2(),
46
+ title: zod_openapi_1.z.string(),
47
+ description: zod_openapi_1.z.string(),
48
+ keyFeatures: zod_openapi_1.z.string(),
49
+ category: zod_openapi_1.z.string(),
50
+ subcategory: zod_openapi_1.z.string().nullable(),
51
+ tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).nullable(),
52
+ productLinks: zod_openapi_1.z.array(zod_openapi_1.z.string()).nullable(),
53
+ pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS),
54
+ currency: zod_openapi_1.z.string(),
55
+ price: zod_openapi_1.z.number().nullable(),
56
+ suggestedPrice: zod_openapi_1.z.number().nullable(),
57
+ discounts: zod_openapi_1.z
58
+ .array(zod_openapi_1.z.object({
59
+ discountType: zod_openapi_1.z.enum(constants_1.DISCOUNT_TYPES),
60
+ amount: zod_openapi_1.z.number(),
61
+ discountCode: zod_openapi_1.z.string().optional().nullable(),
62
+ }))
63
+ .nullable(),
64
+ supportEmail: zod_openapi_1.z.string().nullable(),
65
+ supportPhone: zod_openapi_1.z.string().nullable(),
66
+ });
67
+ // --- Core Input Schema ---
27
68
  const ProductCoreInputSchema = zod_openapi_1.z.object({
69
+ id: zod_openapi_1.z.cuid2().openapi({ description: "Client-generated ID for the product" }),
28
70
  title: zod_openapi_1.z.string().min(1, "Title is required").max(255),
29
71
  description: zod_openapi_1.z.string().min(1, "Description is required"),
30
72
  keyFeatures: zod_openapi_1.z.string(),
31
73
  category: zod_openapi_1.z.string().min(1, "Category is required"),
32
74
  subcategory: zod_openapi_1.z.string().optional(),
33
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
34
77
  coverImages: zod_openapi_1.z
35
- .array(exports.ProductCoverImageEntitySchema)
78
+ .array(exports.CoverImageInputSchema)
36
79
  .min(1, "At least one cover image is required")
37
80
  .max(3, "Maximum of 3 cover images allowed"),
38
- productFiles: zod_openapi_1.z.array(exports.ProductDeliveryFileEntitySchema).default([]),
81
+ productFiles: zod_openapi_1.z.array(exports.DeliveryFileInputSchema).default([]),
39
82
  productLinks: zod_openapi_1.z
40
83
  .array(zod_openapi_1.z.url().openapi({ example: "https://figma.com/file/..." }))
41
84
  .default([]),
@@ -99,6 +142,7 @@ exports.ProductServiceAndComplianceInputSchema = zod_openapi_1.z.object({
99
142
  providesSupport: zod_openapi_1.z.boolean(),
100
143
  agreesToTerms: zod_openapi_1.z.literal(true, "You must agree to the Terms."),
101
144
  });
145
+ // The `id` override here ensures we use the existing DB id when updating
102
146
  exports.UpdateProductInputSchema = ProductCoreInputSchema.extend(exports.ProductServiceAndComplianceInputSchema.omit({ id: true }).shape)
103
147
  .partial()
104
148
  .extend({
@@ -110,7 +154,7 @@ exports.ProductEntitySchema = zod_openapi_1.z
110
154
  sellerId: zod_openapi_1.z.cuid2().openapi({ description: "ID of the creator/seller" }),
111
155
  sellerUsername: zod_openapi_1.z.string(),
112
156
  sellerName: zod_openapi_1.z.string(),
113
- sellerImageUrl: zod_openapi_1.z.string().url().optional().nullable(),
157
+ sellerImageUrl: zod_openapi_1.z.url().optional().nullable(),
114
158
  title: zod_openapi_1.z.string(),
115
159
  description: zod_openapi_1.z.string(),
116
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.92",
3
+ "version": "2.2.94",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -3,6 +3,7 @@ import {
3
3
  ACTIVITY_PARENT_TYPES,
4
4
  POST_BADGE_TYPES,
5
5
  POST_TYPES,
6
+
6
7
  } from "../constants";
7
8
  import { CreateFileInputSchema } from "./file";
8
9
  import { CommentEntitySchema } from "./comment";
@@ -10,6 +11,8 @@ import { EntityStatsSchema } from "./entity-stats";
10
11
  import { ActivitySchema } from "./activity";
11
12
  import { cleanHtml } from "../utils/clean-html";
12
13
 
14
+
15
+
13
16
  export const PostEntitySchema = z.object({
14
17
  id: z
15
18
  .cuid2()
@@ -98,12 +101,10 @@ export const PostEntitySchema = z.object({
98
101
 
99
102
  export const PostFileEntitySchema = z
100
103
  .object({
101
- id: z
102
- .cuid2()
103
- .openapi({
104
- description: "CUID2 of the project file record.",
105
- example: "cxy1a2b3c0000qwe",
106
- }),
104
+ id: z.cuid2().openapi({
105
+ description: "CUID2 of the project file record.",
106
+ example: "cxy1a2b3c0000qwe",
107
+ }),
107
108
  postId: z.cuid2().openapi({
108
109
  description: "CUID2 of the post this file belongs to.",
109
110
  example: "ckj1a2b3c0000xyz",
@@ -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()
@@ -25,8 +42,46 @@ export const ProductDiscountEntitySchema = z.object({
25
42
  discountCode: z.string().optional(),
26
43
  });
27
44
 
45
+ export const BaseProductSchema = z.object({
46
+ id: z.cuid2(),
47
+ createdAt: z.date(),
48
+ updatedAt: z.date(),
49
+ deletedAt: z.date().nullable(),
50
+
51
+ sellerId: z.cuid2(),
52
+
53
+ title: z.string(),
54
+ description: z.string(),
55
+ keyFeatures: z.string(),
56
+
57
+ category: z.string(),
58
+ subcategory: z.string().nullable(),
59
+ tags: z.array(z.string()).nullable(),
60
+
61
+ productLinks: z.array(z.string()).nullable(),
62
+ pricingModel: z.enum(PRICING_MODELS),
63
+ currency: z.string(),
64
+ price: z.number().nullable(),
65
+ suggestedPrice: z.number().nullable(),
66
+
67
+ discounts: z
68
+ .array(
69
+ z.object({
70
+ discountType: z.enum(DISCOUNT_TYPES),
71
+ amount: z.number(),
72
+ discountCode: z.string().optional().nullable(),
73
+ }),
74
+ )
75
+ .nullable(),
76
+ supportEmail: z.string().nullable(),
77
+ supportPhone: z.string().nullable(),
78
+ });
79
+
80
+ // --- Core Input Schema ---
28
81
 
29
82
  const ProductCoreInputSchema = z.object({
83
+ id: z.cuid2().openapi({ description: "Client-generated ID for the product" }),
84
+
30
85
  title: z.string().min(1, "Title is required").max(255),
31
86
  description: z.string().min(1, "Description is required"),
32
87
  keyFeatures: z.string(),
@@ -35,12 +90,14 @@ const ProductCoreInputSchema = z.object({
35
90
  subcategory: z.string().optional(),
36
91
  tags: z.array(z.string()).max(10, "Keep tags to a maximum of 10").default([]),
37
92
 
93
+ // Swapped to the new direct-upload input schemas
38
94
  coverImages: z
39
- .array(ProductCoverImageEntitySchema)
95
+ .array(CoverImageInputSchema)
40
96
  .min(1, "At least one cover image is required")
41
97
  .max(3, "Maximum of 3 cover images allowed"),
42
98
 
43
- productFiles: z.array(ProductDeliveryFileEntitySchema).default([]),
99
+ productFiles: z.array(DeliveryFileInputSchema).default([]),
100
+
44
101
  productLinks: z
45
102
  .array(z.url().openapi({ example: "https://figma.com/file/..." }))
46
103
  .default([]),
@@ -128,6 +185,7 @@ export const ProductServiceAndComplianceInputSchema = z.object({
128
185
  agreesToTerms: z.literal(true, "You must agree to the Terms."),
129
186
  });
130
187
 
188
+ // The `id` override here ensures we use the existing DB id when updating
131
189
  export const UpdateProductInputSchema = ProductCoreInputSchema.extend(
132
190
  ProductServiceAndComplianceInputSchema.omit({ id: true }).shape,
133
191
  )
@@ -143,7 +201,7 @@ export const ProductEntitySchema = z
143
201
  sellerId: z.cuid2().openapi({ description: "ID of the creator/seller" }),
144
202
  sellerUsername: z.string(),
145
203
  sellerName: z.string(),
146
- sellerImageUrl: z.string().url().optional().nullable(),
204
+ sellerImageUrl: z.url().optional().nullable(),
147
205
 
148
206
  title: z.string(),
149
207
  description: z.string(),
@@ -172,6 +230,11 @@ export const ProductEntitySchema = z
172
230
  })
173
231
  .openapi({ title: "ProductEntity" });
174
232
 
233
+ // --- Type Exports ---
234
+
235
+ export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
236
+ export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
237
+
175
238
  export type ProductCoverImageEntity = z.infer<
176
239
  typeof ProductCoverImageEntitySchema
177
240
  >;
@@ -186,3 +249,5 @@ export type ProductServiceAndComplianceInputEntity = z.infer<
186
249
  >;
187
250
  export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
188
251
  export type ProductEntity = z.infer<typeof ProductEntitySchema>;
252
+
253
+ export type BaseProductEntity = z.infer<typeof BaseProductSchema>;