@zyacreatives/shared 2.2.89 → 2.2.91
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/schemas/product.d.ts +75 -1
- package/dist/schemas/product.js +31 -10
- package/package.json +1 -1
- package/src/schemas/product.ts +74 -28
|
@@ -16,6 +16,10 @@ export declare const ProductDiscountEntitySchema: z.ZodObject<{
|
|
|
16
16
|
amount: z.ZodNumber;
|
|
17
17
|
discountCode: z.ZodOptional<z.ZodString>;
|
|
18
18
|
}, z.core.$strip>;
|
|
19
|
+
export declare const ProductAdditionalServiceSchema: z.ZodObject<{
|
|
20
|
+
title: z.ZodString;
|
|
21
|
+
price: z.ZodNumber;
|
|
22
|
+
}, z.core.$strip>;
|
|
19
23
|
export declare const CreateProductInputSchema: z.ZodObject<{
|
|
20
24
|
title: z.ZodString;
|
|
21
25
|
description: z.ZodString;
|
|
@@ -50,9 +54,70 @@ export declare const CreateProductInputSchema: z.ZodObject<{
|
|
|
50
54
|
discountCode: z.ZodOptional<z.ZodString>;
|
|
51
55
|
}, z.core.$strip>>>;
|
|
52
56
|
}, z.core.$strip>;
|
|
57
|
+
export declare const ProductServiceAndComplianceInputSchema: z.ZodObject<{
|
|
58
|
+
id: z.ZodCUID2;
|
|
59
|
+
supportEmail: z.ZodEmail;
|
|
60
|
+
supportPhone: z.ZodOptional<z.ZodString>;
|
|
61
|
+
additionalServices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
62
|
+
title: z.ZodString;
|
|
63
|
+
price: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>>>;
|
|
65
|
+
ownsRights: z.ZodLiteral<true>;
|
|
66
|
+
noHarmfulContent: z.ZodLiteral<true>;
|
|
67
|
+
providesSupport: z.ZodBoolean;
|
|
68
|
+
agreesToTerms: z.ZodLiteral<true>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export declare const UpdateProductInputSchema: z.ZodObject<{
|
|
71
|
+
title: z.ZodOptional<z.ZodString>;
|
|
72
|
+
description: z.ZodOptional<z.ZodString>;
|
|
73
|
+
keyFeatures: z.ZodOptional<z.ZodString>;
|
|
74
|
+
category: z.ZodOptional<z.ZodString>;
|
|
75
|
+
subcategory: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
76
|
+
tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
77
|
+
coverImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
78
|
+
fileId: z.ZodCUID2;
|
|
79
|
+
isThumbnail: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
order: z.ZodDefault<z.ZodNumber>;
|
|
81
|
+
}, z.core.$strip>>>;
|
|
82
|
+
productFiles: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
83
|
+
fileId: z.ZodCUID2;
|
|
84
|
+
order: z.ZodDefault<z.ZodNumber>;
|
|
85
|
+
}, z.core.$strip>>>>;
|
|
86
|
+
productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodURL>>>;
|
|
87
|
+
pricingModel: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
88
|
+
readonly FREE: "Free";
|
|
89
|
+
readonly FIXED: "Fixed";
|
|
90
|
+
readonly PWYW: "Pay What You Want";
|
|
91
|
+
}>>>;
|
|
92
|
+
currency: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
93
|
+
price: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
94
|
+
suggestedPrice: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
95
|
+
discounts: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
96
|
+
discountType: z.ZodEnum<{
|
|
97
|
+
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
98
|
+
readonly PERCENTAGE: "Percentage";
|
|
99
|
+
}>;
|
|
100
|
+
amount: z.ZodNumber;
|
|
101
|
+
discountCode: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>>>>;
|
|
103
|
+
supportEmail: z.ZodOptional<z.ZodEmail>;
|
|
104
|
+
supportPhone: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
105
|
+
additionalServices: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
106
|
+
title: z.ZodString;
|
|
107
|
+
price: z.ZodNumber;
|
|
108
|
+
}, z.core.$strip>>>>;
|
|
109
|
+
ownsRights: z.ZodOptional<z.ZodLiteral<true>>;
|
|
110
|
+
noHarmfulContent: z.ZodOptional<z.ZodLiteral<true>>;
|
|
111
|
+
providesSupport: z.ZodOptional<z.ZodBoolean>;
|
|
112
|
+
agreesToTerms: z.ZodOptional<z.ZodLiteral<true>>;
|
|
113
|
+
id: z.ZodCUID2;
|
|
114
|
+
}, z.core.$strip>;
|
|
53
115
|
export declare const ProductEntitySchema: z.ZodObject<{
|
|
54
116
|
id: z.ZodCUID2;
|
|
55
|
-
|
|
117
|
+
sellerId: z.ZodCUID2;
|
|
118
|
+
sellerUsername: z.ZodString;
|
|
119
|
+
sellerName: z.ZodString;
|
|
120
|
+
sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
56
121
|
title: z.ZodString;
|
|
57
122
|
description: z.ZodString;
|
|
58
123
|
keyFeatures: z.ZodString;
|
|
@@ -85,6 +150,12 @@ export declare const ProductEntitySchema: z.ZodObject<{
|
|
|
85
150
|
amount: z.ZodNumber;
|
|
86
151
|
discountCode: z.ZodOptional<z.ZodString>;
|
|
87
152
|
}, z.core.$strip>>>;
|
|
153
|
+
supportEmail: z.ZodNullable<z.ZodOptional<z.ZodEmail>>;
|
|
154
|
+
supportPhone: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
155
|
+
additionalServices: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
156
|
+
title: z.ZodString;
|
|
157
|
+
price: z.ZodNumber;
|
|
158
|
+
}, z.core.$strip>>>;
|
|
88
159
|
createdAt: z.ZodCoercedDate<unknown>;
|
|
89
160
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
90
161
|
deletedAt: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
@@ -92,5 +163,8 @@ export declare const ProductEntitySchema: z.ZodObject<{
|
|
|
92
163
|
export type ProductCoverImageEntity = z.infer<typeof ProductCoverImageEntitySchema>;
|
|
93
164
|
export type ProductDeliveryFileEntity = z.infer<typeof ProductDeliveryFileEntitySchema>;
|
|
94
165
|
export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
|
|
166
|
+
export type ProductAdditionalService = z.infer<typeof ProductAdditionalServiceSchema>;
|
|
95
167
|
export type CreateProductInputEntity = z.infer<typeof CreateProductInputSchema>;
|
|
168
|
+
export type ProductServiceAndComplianceInputEntity = z.infer<typeof ProductServiceAndComplianceInputSchema>;
|
|
169
|
+
export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
|
|
96
170
|
export type ProductEntity = z.infer<typeof ProductEntitySchema>;
|
package/dist/schemas/product.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProductEntitySchema = exports.CreateProductInputSchema = exports.ProductDiscountEntitySchema = exports.ProductDeliveryFileEntitySchema = exports.ProductCoverImageEntitySchema = void 0;
|
|
3
|
+
exports.ProductEntitySchema = exports.UpdateProductInputSchema = exports.ProductServiceAndComplianceInputSchema = exports.CreateProductInputSchema = exports.ProductAdditionalServiceSchema = exports.ProductDiscountEntitySchema = exports.ProductDeliveryFileEntitySchema = exports.ProductCoverImageEntitySchema = void 0;
|
|
4
4
|
const zod_openapi_1 = require("@hono/zod-openapi");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
exports.ProductCoverImageEntitySchema = zod_openapi_1.z.object({
|
|
@@ -24,17 +24,17 @@ exports.ProductDiscountEntitySchema = zod_openapi_1.z.object({
|
|
|
24
24
|
.min(0, "Discount amount cannot be negative"),
|
|
25
25
|
discountCode: zod_openapi_1.z.string().optional(),
|
|
26
26
|
});
|
|
27
|
-
exports.
|
|
28
|
-
.
|
|
27
|
+
exports.ProductAdditionalServiceSchema = zod_openapi_1.z.object({
|
|
28
|
+
title: zod_openapi_1.z.string().min(1, "Service title is required"),
|
|
29
|
+
price: zod_openapi_1.z.number().int("Price must be in cents").min(0),
|
|
30
|
+
});
|
|
31
|
+
const ProductCoreInputSchema = zod_openapi_1.z.object({
|
|
29
32
|
title: zod_openapi_1.z.string().min(1, "Title is required").max(255),
|
|
30
33
|
description: zod_openapi_1.z.string().min(1, "Description is required"),
|
|
31
34
|
keyFeatures: zod_openapi_1.z.string(),
|
|
32
35
|
category: zod_openapi_1.z.string().min(1, "Category is required"),
|
|
33
36
|
subcategory: zod_openapi_1.z.string().optional(),
|
|
34
|
-
tags: zod_openapi_1.z
|
|
35
|
-
.array(zod_openapi_1.z.string())
|
|
36
|
-
.max(10, "Keep tags to a maximum of 10")
|
|
37
|
-
.default([]),
|
|
37
|
+
tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).max(10, "Keep tags to a maximum of 10").default([]),
|
|
38
38
|
coverImages: zod_openapi_1.z
|
|
39
39
|
.array(exports.ProductCoverImageEntitySchema)
|
|
40
40
|
.min(1, "At least one cover image is required")
|
|
@@ -48,8 +48,8 @@ exports.CreateProductInputSchema = zod_openapi_1.z
|
|
|
48
48
|
price: zod_openapi_1.z.number().int("Must be in cents").min(0).optional(),
|
|
49
49
|
suggestedPrice: zod_openapi_1.z.number().int("Must be in cents").min(0).optional(),
|
|
50
50
|
discounts: zod_openapi_1.z.array(exports.ProductDiscountEntitySchema).default([]),
|
|
51
|
-
})
|
|
52
|
-
|
|
51
|
+
});
|
|
52
|
+
exports.CreateProductInputSchema = ProductCoreInputSchema.superRefine((data, ctx) => {
|
|
53
53
|
if (data.pricingModel === constants_1.PRICING_MODELS.FIXED &&
|
|
54
54
|
(!data.price || data.price <= 0)) {
|
|
55
55
|
ctx.addIssue({
|
|
@@ -94,10 +94,28 @@ exports.CreateProductInputSchema = zod_openapi_1.z
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
|
+
exports.ProductServiceAndComplianceInputSchema = zod_openapi_1.z.object({
|
|
98
|
+
id: zod_openapi_1.z.cuid2().openapi({ description: "ID of the product" }),
|
|
99
|
+
supportEmail: zod_openapi_1.z.email("A valid support email is required"),
|
|
100
|
+
supportPhone: zod_openapi_1.z.string().optional(),
|
|
101
|
+
additionalServices: zod_openapi_1.z.array(exports.ProductAdditionalServiceSchema).default([]),
|
|
102
|
+
ownsRights: zod_openapi_1.z.literal(true, "You must confirm you own the rights to this product."),
|
|
103
|
+
noHarmfulContent: zod_openapi_1.z.literal(true, "You must confirm no harmful content."),
|
|
104
|
+
providesSupport: zod_openapi_1.z.boolean(),
|
|
105
|
+
agreesToTerms: zod_openapi_1.z.literal(true, "You must agree to the Terms."),
|
|
106
|
+
});
|
|
107
|
+
exports.UpdateProductInputSchema = ProductCoreInputSchema.extend(exports.ProductServiceAndComplianceInputSchema.omit({ id: true }).shape)
|
|
108
|
+
.partial()
|
|
109
|
+
.extend({
|
|
110
|
+
id: zod_openapi_1.z.cuid2().openapi({ description: "ID of the product being updated" }),
|
|
111
|
+
});
|
|
97
112
|
exports.ProductEntitySchema = zod_openapi_1.z
|
|
98
113
|
.object({
|
|
99
114
|
id: zod_openapi_1.z.cuid2(),
|
|
100
|
-
|
|
115
|
+
sellerId: zod_openapi_1.z.cuid2().openapi({ description: "ID of the creator/seller" }),
|
|
116
|
+
sellerUsername: zod_openapi_1.z.string(),
|
|
117
|
+
sellerName: zod_openapi_1.z.string(),
|
|
118
|
+
sellerImageUrl: zod_openapi_1.z.string().url().optional().nullable(),
|
|
101
119
|
title: zod_openapi_1.z.string(),
|
|
102
120
|
description: zod_openapi_1.z.string(),
|
|
103
121
|
keyFeatures: zod_openapi_1.z.string(),
|
|
@@ -112,6 +130,9 @@ exports.ProductEntitySchema = zod_openapi_1.z
|
|
|
112
130
|
price: zod_openapi_1.z.number().int().optional().nullable(),
|
|
113
131
|
suggestedPrice: zod_openapi_1.z.number().int().optional().nullable(),
|
|
114
132
|
discounts: zod_openapi_1.z.array(exports.ProductDiscountEntitySchema).default([]),
|
|
133
|
+
supportEmail: zod_openapi_1.z.email().optional().nullable(),
|
|
134
|
+
supportPhone: zod_openapi_1.z.string().optional().nullable(),
|
|
135
|
+
additionalServices: zod_openapi_1.z.array(exports.ProductAdditionalServiceSchema).default([]),
|
|
115
136
|
createdAt: zod_openapi_1.z.coerce.date(),
|
|
116
137
|
updatedAt: zod_openapi_1.z.coerce.date(),
|
|
117
138
|
deletedAt: zod_openapi_1.z.coerce.date().optional().nullable(),
|
package/package.json
CHANGED
package/src/schemas/product.ts
CHANGED
|
@@ -18,7 +18,6 @@ export const ProductDeliveryFileEntitySchema = z.object({
|
|
|
18
18
|
|
|
19
19
|
export const ProductDiscountEntitySchema = z.object({
|
|
20
20
|
discountType: z.enum(DISCOUNT_TYPES),
|
|
21
|
-
|
|
22
21
|
amount: z
|
|
23
22
|
.number()
|
|
24
23
|
.int("Amount must be a whole number")
|
|
@@ -26,38 +25,41 @@ export const ProductDiscountEntitySchema = z.object({
|
|
|
26
25
|
discountCode: z.string().optional(),
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
export const
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
keyFeatures: z.string(),
|
|
28
|
+
export const ProductAdditionalServiceSchema = z.object({
|
|
29
|
+
title: z.string().min(1, "Service title is required"),
|
|
30
|
+
price: z.number().int("Price must be in cents").min(0),
|
|
31
|
+
});
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.max(10, "Keep tags to a maximum of 10")
|
|
40
|
-
.default([]),
|
|
33
|
+
const ProductCoreInputSchema = z.object({
|
|
34
|
+
title: z.string().min(1, "Title is required").max(255),
|
|
35
|
+
description: z.string().min(1, "Description is required"),
|
|
36
|
+
keyFeatures: z.string(),
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.max(3, "Maximum of 3 cover images allowed"),
|
|
38
|
+
category: z.string().min(1, "Category is required"),
|
|
39
|
+
subcategory: z.string().optional(),
|
|
40
|
+
tags: z.array(z.string()).max(10, "Keep tags to a maximum of 10").default([]),
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
coverImages: z
|
|
43
|
+
.array(ProductCoverImageEntitySchema)
|
|
44
|
+
.min(1, "At least one cover image is required")
|
|
45
|
+
.max(3, "Maximum of 3 cover images allowed"),
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
productFiles: z.array(ProductDeliveryFileEntitySchema).default([]),
|
|
48
|
+
productLinks: z
|
|
49
|
+
.array(z.url().openapi({ example: "https://figma.com/file/..." }))
|
|
50
|
+
.default([]),
|
|
54
51
|
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
pricingModel: z.enum(PRICING_MODELS).default(PRICING_MODELS.FIXED),
|
|
53
|
+
currency: z.string().default("USD").openapi({ example: "USD" }),
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
price: z.number().int("Must be in cents").min(0).optional(),
|
|
56
|
+
suggestedPrice: z.number().int("Must be in cents").min(0).optional(),
|
|
57
|
+
|
|
58
|
+
discounts: z.array(ProductDiscountEntitySchema).default([]),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const CreateProductInputSchema = ProductCoreInputSchema.superRefine(
|
|
62
|
+
(data, ctx) => {
|
|
61
63
|
if (
|
|
62
64
|
data.pricingModel === PRICING_MODELS.FIXED &&
|
|
63
65
|
(!data.price || data.price <= 0)
|
|
@@ -110,12 +112,44 @@ export const CreateProductInputSchema = z
|
|
|
110
112
|
path: ["coverImages"],
|
|
111
113
|
});
|
|
112
114
|
}
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
export const ProductServiceAndComplianceInputSchema = z.object({
|
|
119
|
+
id: z.cuid2().openapi({ description: "ID of the product" }),
|
|
120
|
+
|
|
121
|
+
supportEmail: z.email("A valid support email is required"),
|
|
122
|
+
supportPhone: z.string().optional(),
|
|
123
|
+
|
|
124
|
+
additionalServices: z.array(ProductAdditionalServiceSchema).default([]),
|
|
125
|
+
|
|
126
|
+
ownsRights: z.literal(
|
|
127
|
+
true,
|
|
128
|
+
"You must confirm you own the rights to this product.",
|
|
129
|
+
),
|
|
130
|
+
|
|
131
|
+
noHarmfulContent: z.literal(true, "You must confirm no harmful content."),
|
|
132
|
+
|
|
133
|
+
providesSupport: z.boolean(),
|
|
134
|
+
agreesToTerms: z.literal(true, "You must agree to the Terms."),
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const UpdateProductInputSchema = ProductCoreInputSchema.extend(
|
|
138
|
+
ProductServiceAndComplianceInputSchema.omit({ id: true }).shape,
|
|
139
|
+
)
|
|
140
|
+
.partial()
|
|
141
|
+
.extend({
|
|
142
|
+
id: z.cuid2().openapi({ description: "ID of the product being updated" }),
|
|
113
143
|
});
|
|
114
144
|
|
|
115
145
|
export const ProductEntitySchema = z
|
|
116
146
|
.object({
|
|
117
147
|
id: z.cuid2(),
|
|
118
|
-
|
|
148
|
+
|
|
149
|
+
sellerId: z.cuid2().openapi({ description: "ID of the creator/seller" }),
|
|
150
|
+
sellerUsername: z.string(),
|
|
151
|
+
sellerName: z.string(),
|
|
152
|
+
sellerImageUrl: z.string().url().optional().nullable(),
|
|
119
153
|
|
|
120
154
|
title: z.string(),
|
|
121
155
|
description: z.string(),
|
|
@@ -136,6 +170,10 @@ export const ProductEntitySchema = z
|
|
|
136
170
|
|
|
137
171
|
discounts: z.array(ProductDiscountEntitySchema).default([]),
|
|
138
172
|
|
|
173
|
+
supportEmail: z.email().optional().nullable(),
|
|
174
|
+
supportPhone: z.string().optional().nullable(),
|
|
175
|
+
additionalServices: z.array(ProductAdditionalServiceSchema).default([]),
|
|
176
|
+
|
|
139
177
|
createdAt: z.coerce.date(),
|
|
140
178
|
updatedAt: z.coerce.date(),
|
|
141
179
|
deletedAt: z.coerce.date().optional().nullable(),
|
|
@@ -149,5 +187,13 @@ export type ProductDeliveryFileEntity = z.infer<
|
|
|
149
187
|
typeof ProductDeliveryFileEntitySchema
|
|
150
188
|
>;
|
|
151
189
|
export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
|
|
190
|
+
export type ProductAdditionalService = z.infer<
|
|
191
|
+
typeof ProductAdditionalServiceSchema
|
|
192
|
+
>;
|
|
193
|
+
|
|
152
194
|
export type CreateProductInputEntity = z.infer<typeof CreateProductInputSchema>;
|
|
195
|
+
export type ProductServiceAndComplianceInputEntity = z.infer<
|
|
196
|
+
typeof ProductServiceAndComplianceInputSchema
|
|
197
|
+
>;
|
|
198
|
+
export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
|
|
153
199
|
export type ProductEntity = z.infer<typeof ProductEntitySchema>;
|