@zyacreatives/shared 2.2.93 → 2.2.95
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 +40 -8
- package/dist/schemas/product.js +27 -8
- package/package.json +1 -1
- package/src/schemas/product.ts +41 -8
|
@@ -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,6 +27,11 @@ 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 ProductLinkSchema: z.ZodObject<{
|
|
31
|
+
title: z.ZodNullable<z.ZodString>;
|
|
32
|
+
url: z.ZodString;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type ProductLink = z.infer<typeof ProductLinkSchema>;
|
|
19
35
|
export declare const BaseProductSchema: z.ZodObject<{
|
|
20
36
|
id: z.ZodCUID2;
|
|
21
37
|
createdAt: z.ZodDate;
|
|
@@ -28,7 +44,10 @@ export declare const BaseProductSchema: z.ZodObject<{
|
|
|
28
44
|
category: z.ZodString;
|
|
29
45
|
subcategory: z.ZodNullable<z.ZodString>;
|
|
30
46
|
tags: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
31
|
-
productLinks: z.ZodNullable<z.ZodArray<z.
|
|
47
|
+
productLinks: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
48
|
+
title: z.ZodNullable<z.ZodString>;
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
}, z.core.$strip>>>;
|
|
32
51
|
pricingModel: z.ZodEnum<{
|
|
33
52
|
readonly FREE: "Free";
|
|
34
53
|
readonly FIXED: "Fixed";
|
|
@@ -49,6 +68,7 @@ export declare const BaseProductSchema: z.ZodObject<{
|
|
|
49
68
|
supportPhone: z.ZodNullable<z.ZodString>;
|
|
50
69
|
}, z.core.$strip>;
|
|
51
70
|
export declare const CreateProductInputSchema: z.ZodObject<{
|
|
71
|
+
id: z.ZodCUID2;
|
|
52
72
|
title: z.ZodString;
|
|
53
73
|
description: z.ZodString;
|
|
54
74
|
keyFeatures: z.ZodString;
|
|
@@ -56,15 +76,20 @@ export declare const CreateProductInputSchema: z.ZodObject<{
|
|
|
56
76
|
subcategory: z.ZodOptional<z.ZodString>;
|
|
57
77
|
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
58
78
|
coverImages: z.ZodArray<z.ZodObject<{
|
|
59
|
-
|
|
79
|
+
key: z.ZodString;
|
|
80
|
+
mimeType: z.ZodString;
|
|
60
81
|
isThumbnail: z.ZodDefault<z.ZodBoolean>;
|
|
61
82
|
order: z.ZodDefault<z.ZodNumber>;
|
|
62
83
|
}, z.core.$strip>>;
|
|
63
84
|
productFiles: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
64
|
-
|
|
85
|
+
key: z.ZodString;
|
|
86
|
+
mimeType: z.ZodString;
|
|
65
87
|
order: z.ZodDefault<z.ZodNumber>;
|
|
66
88
|
}, z.core.$strip>>>;
|
|
67
|
-
productLinks: z.ZodDefault<z.ZodArray<z.
|
|
89
|
+
productLinks: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
90
|
+
title: z.ZodNullable<z.ZodString>;
|
|
91
|
+
url: z.ZodString;
|
|
92
|
+
}, z.core.$strip>>>;
|
|
68
93
|
pricingModel: z.ZodDefault<z.ZodEnum<{
|
|
69
94
|
readonly FREE: "Free";
|
|
70
95
|
readonly FIXED: "Fixed";
|
|
@@ -99,15 +124,20 @@ export declare const UpdateProductInputSchema: z.ZodObject<{
|
|
|
99
124
|
subcategory: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
100
125
|
tags: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString>>>;
|
|
101
126
|
coverImages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
-
|
|
127
|
+
key: z.ZodString;
|
|
128
|
+
mimeType: z.ZodString;
|
|
103
129
|
isThumbnail: z.ZodDefault<z.ZodBoolean>;
|
|
104
130
|
order: z.ZodDefault<z.ZodNumber>;
|
|
105
131
|
}, z.core.$strip>>>;
|
|
106
132
|
productFiles: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
107
|
-
|
|
133
|
+
key: z.ZodString;
|
|
134
|
+
mimeType: z.ZodString;
|
|
108
135
|
order: z.ZodDefault<z.ZodNumber>;
|
|
109
136
|
}, z.core.$strip>>>>;
|
|
110
|
-
productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.
|
|
137
|
+
productLinks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
138
|
+
title: z.ZodNullable<z.ZodString>;
|
|
139
|
+
url: z.ZodString;
|
|
140
|
+
}, z.core.$strip>>>>;
|
|
111
141
|
pricingModel: z.ZodOptional<z.ZodDefault<z.ZodEnum<{
|
|
112
142
|
readonly FREE: "Free";
|
|
113
143
|
readonly FIXED: "Fixed";
|
|
@@ -137,7 +167,7 @@ export declare const ProductEntitySchema: z.ZodObject<{
|
|
|
137
167
|
sellerId: z.ZodCUID2;
|
|
138
168
|
sellerUsername: z.ZodString;
|
|
139
169
|
sellerName: z.ZodString;
|
|
140
|
-
sellerImageUrl: z.ZodNullable<z.ZodOptional<z.
|
|
170
|
+
sellerImageUrl: z.ZodNullable<z.ZodOptional<z.ZodURL>>;
|
|
141
171
|
title: z.ZodString;
|
|
142
172
|
description: z.ZodString;
|
|
143
173
|
keyFeatures: z.ZodString;
|
|
@@ -176,6 +206,8 @@ export declare const ProductEntitySchema: z.ZodObject<{
|
|
|
176
206
|
updatedAt: z.ZodCoercedDate<unknown>;
|
|
177
207
|
deletedAt: z.ZodNullable<z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
178
208
|
}, z.core.$strip>;
|
|
209
|
+
export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
|
|
210
|
+
export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
|
|
179
211
|
export type ProductCoverImageEntity = z.infer<typeof ProductCoverImageEntitySchema>;
|
|
180
212
|
export type ProductDeliveryFileEntity = z.infer<typeof ProductDeliveryFileEntitySchema>;
|
|
181
213
|
export type ProductDiscountEntity = z.infer<typeof ProductDiscountEntitySchema>;
|
package/dist/schemas/product.js
CHANGED
|
@@ -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.ProductLinkSchema = 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,6 +37,10 @@ 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.ProductLinkSchema = zod_openapi_1.z.object({
|
|
41
|
+
title: zod_openapi_1.z.string().nullable(),
|
|
42
|
+
url: zod_openapi_1.z.string(),
|
|
43
|
+
});
|
|
27
44
|
exports.BaseProductSchema = zod_openapi_1.z.object({
|
|
28
45
|
id: zod_openapi_1.z.cuid2(),
|
|
29
46
|
createdAt: zod_openapi_1.z.date(),
|
|
@@ -36,7 +53,7 @@ exports.BaseProductSchema = zod_openapi_1.z.object({
|
|
|
36
53
|
category: zod_openapi_1.z.string(),
|
|
37
54
|
subcategory: zod_openapi_1.z.string().nullable(),
|
|
38
55
|
tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).nullable(),
|
|
39
|
-
productLinks: zod_openapi_1.z.array(
|
|
56
|
+
productLinks: zod_openapi_1.z.array(exports.ProductLinkSchema).nullable(),
|
|
40
57
|
pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS),
|
|
41
58
|
currency: zod_openapi_1.z.string(),
|
|
42
59
|
price: zod_openapi_1.z.number().nullable(),
|
|
@@ -51,21 +68,22 @@ exports.BaseProductSchema = zod_openapi_1.z.object({
|
|
|
51
68
|
supportEmail: zod_openapi_1.z.string().nullable(),
|
|
52
69
|
supportPhone: zod_openapi_1.z.string().nullable(),
|
|
53
70
|
});
|
|
71
|
+
// --- Core Input Schema ---
|
|
54
72
|
const ProductCoreInputSchema = zod_openapi_1.z.object({
|
|
73
|
+
id: zod_openapi_1.z.cuid2().openapi({ description: "Client-generated ID for the product" }),
|
|
55
74
|
title: zod_openapi_1.z.string().min(1, "Title is required").max(255),
|
|
56
75
|
description: zod_openapi_1.z.string().min(1, "Description is required"),
|
|
57
76
|
keyFeatures: zod_openapi_1.z.string(),
|
|
58
77
|
category: zod_openapi_1.z.string().min(1, "Category is required"),
|
|
59
78
|
subcategory: zod_openapi_1.z.string().optional(),
|
|
60
79
|
tags: zod_openapi_1.z.array(zod_openapi_1.z.string()).max(10, "Keep tags to a maximum of 10").default([]),
|
|
80
|
+
// Swapped to the new direct-upload input schemas
|
|
61
81
|
coverImages: zod_openapi_1.z
|
|
62
|
-
.array(exports.
|
|
82
|
+
.array(exports.CoverImageInputSchema)
|
|
63
83
|
.min(1, "At least one cover image is required")
|
|
64
84
|
.max(3, "Maximum of 3 cover images allowed"),
|
|
65
|
-
productFiles: zod_openapi_1.z.array(exports.
|
|
66
|
-
productLinks: zod_openapi_1.z
|
|
67
|
-
.array(zod_openapi_1.z.url().openapi({ example: "https://figma.com/file/..." }))
|
|
68
|
-
.default([]),
|
|
85
|
+
productFiles: zod_openapi_1.z.array(exports.DeliveryFileInputSchema).default([]),
|
|
86
|
+
productLinks: zod_openapi_1.z.array(exports.ProductLinkSchema).default([]),
|
|
69
87
|
pricingModel: zod_openapi_1.z.enum(constants_1.PRICING_MODELS).default(constants_1.PRICING_MODELS.FIXED),
|
|
70
88
|
currency: zod_openapi_1.z.string().default("USD").openapi({ example: "USD" }),
|
|
71
89
|
price: zod_openapi_1.z.number().int("Must be in cents").min(0).optional(),
|
|
@@ -126,6 +144,7 @@ exports.ProductServiceAndComplianceInputSchema = zod_openapi_1.z.object({
|
|
|
126
144
|
providesSupport: zod_openapi_1.z.boolean(),
|
|
127
145
|
agreesToTerms: zod_openapi_1.z.literal(true, "You must agree to the Terms."),
|
|
128
146
|
});
|
|
147
|
+
// The `id` override here ensures we use the existing DB id when updating
|
|
129
148
|
exports.UpdateProductInputSchema = ProductCoreInputSchema.extend(exports.ProductServiceAndComplianceInputSchema.omit({ id: true }).shape)
|
|
130
149
|
.partial()
|
|
131
150
|
.extend({
|
|
@@ -137,7 +156,7 @@ exports.ProductEntitySchema = zod_openapi_1.z
|
|
|
137
156
|
sellerId: zod_openapi_1.z.cuid2().openapi({ description: "ID of the creator/seller" }),
|
|
138
157
|
sellerUsername: zod_openapi_1.z.string(),
|
|
139
158
|
sellerName: zod_openapi_1.z.string(),
|
|
140
|
-
sellerImageUrl: zod_openapi_1.z.
|
|
159
|
+
sellerImageUrl: zod_openapi_1.z.url().optional().nullable(),
|
|
141
160
|
title: zod_openapi_1.z.string(),
|
|
142
161
|
description: zod_openapi_1.z.string(),
|
|
143
162
|
keyFeatures: zod_openapi_1.z.string(),
|
package/package.json
CHANGED
package/src/schemas/product.ts
CHANGED
|
@@ -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,6 +42,12 @@ export const ProductDiscountEntitySchema = z.object({
|
|
|
25
42
|
discountCode: z.string().optional(),
|
|
26
43
|
});
|
|
27
44
|
|
|
45
|
+
export const ProductLinkSchema = z.object({
|
|
46
|
+
title: z.string().nullable(),
|
|
47
|
+
url: z.string(),
|
|
48
|
+
});
|
|
49
|
+
export type ProductLink = z.infer<typeof ProductLinkSchema>;
|
|
50
|
+
|
|
28
51
|
export const BaseProductSchema = z.object({
|
|
29
52
|
id: z.cuid2(),
|
|
30
53
|
createdAt: z.date(),
|
|
@@ -41,7 +64,7 @@ export const BaseProductSchema = z.object({
|
|
|
41
64
|
subcategory: z.string().nullable(),
|
|
42
65
|
tags: z.array(z.string()).nullable(),
|
|
43
66
|
|
|
44
|
-
productLinks: z.array(
|
|
67
|
+
productLinks: z.array(ProductLinkSchema).nullable(),
|
|
45
68
|
pricingModel: z.enum(PRICING_MODELS),
|
|
46
69
|
currency: z.string(),
|
|
47
70
|
price: z.number().nullable(),
|
|
@@ -60,7 +83,11 @@ export const BaseProductSchema = z.object({
|
|
|
60
83
|
supportPhone: z.string().nullable(),
|
|
61
84
|
});
|
|
62
85
|
|
|
86
|
+
// --- Core Input Schema ---
|
|
87
|
+
|
|
63
88
|
const ProductCoreInputSchema = z.object({
|
|
89
|
+
id: z.cuid2().openapi({ description: "Client-generated ID for the product" }),
|
|
90
|
+
|
|
64
91
|
title: z.string().min(1, "Title is required").max(255),
|
|
65
92
|
description: z.string().min(1, "Description is required"),
|
|
66
93
|
keyFeatures: z.string(),
|
|
@@ -69,15 +96,15 @@ const ProductCoreInputSchema = z.object({
|
|
|
69
96
|
subcategory: z.string().optional(),
|
|
70
97
|
tags: z.array(z.string()).max(10, "Keep tags to a maximum of 10").default([]),
|
|
71
98
|
|
|
99
|
+
// Swapped to the new direct-upload input schemas
|
|
72
100
|
coverImages: z
|
|
73
|
-
.array(
|
|
101
|
+
.array(CoverImageInputSchema)
|
|
74
102
|
.min(1, "At least one cover image is required")
|
|
75
103
|
.max(3, "Maximum of 3 cover images allowed"),
|
|
76
104
|
|
|
77
|
-
productFiles: z.array(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
.default([]),
|
|
105
|
+
productFiles: z.array(DeliveryFileInputSchema).default([]),
|
|
106
|
+
|
|
107
|
+
productLinks: z.array(ProductLinkSchema).default([]),
|
|
81
108
|
|
|
82
109
|
pricingModel: z.enum(PRICING_MODELS).default(PRICING_MODELS.FIXED),
|
|
83
110
|
currency: z.string().default("USD").openapi({ example: "USD" }),
|
|
@@ -162,6 +189,7 @@ export const ProductServiceAndComplianceInputSchema = z.object({
|
|
|
162
189
|
agreesToTerms: z.literal(true, "You must agree to the Terms."),
|
|
163
190
|
});
|
|
164
191
|
|
|
192
|
+
// The `id` override here ensures we use the existing DB id when updating
|
|
165
193
|
export const UpdateProductInputSchema = ProductCoreInputSchema.extend(
|
|
166
194
|
ProductServiceAndComplianceInputSchema.omit({ id: true }).shape,
|
|
167
195
|
)
|
|
@@ -177,7 +205,7 @@ export const ProductEntitySchema = z
|
|
|
177
205
|
sellerId: z.cuid2().openapi({ description: "ID of the creator/seller" }),
|
|
178
206
|
sellerUsername: z.string(),
|
|
179
207
|
sellerName: z.string(),
|
|
180
|
-
sellerImageUrl: z.
|
|
208
|
+
sellerImageUrl: z.url().optional().nullable(),
|
|
181
209
|
|
|
182
210
|
title: z.string(),
|
|
183
211
|
description: z.string(),
|
|
@@ -206,6 +234,11 @@ export const ProductEntitySchema = z
|
|
|
206
234
|
})
|
|
207
235
|
.openapi({ title: "ProductEntity" });
|
|
208
236
|
|
|
237
|
+
// --- Type Exports ---
|
|
238
|
+
|
|
239
|
+
export type CoverImageInput = z.infer<typeof CoverImageInputSchema>;
|
|
240
|
+
export type DeliveryFileInput = z.infer<typeof DeliveryFileInputSchema>;
|
|
241
|
+
|
|
209
242
|
export type ProductCoverImageEntity = z.infer<
|
|
210
243
|
typeof ProductCoverImageEntitySchema
|
|
211
244
|
>;
|
|
@@ -221,4 +254,4 @@ export type ProductServiceAndComplianceInputEntity = z.infer<
|
|
|
221
254
|
export type UpdateProductInputEntity = z.infer<typeof UpdateProductInputSchema>;
|
|
222
255
|
export type ProductEntity = z.infer<typeof ProductEntitySchema>;
|
|
223
256
|
|
|
224
|
-
export type BaseProductEntity = z.infer<typeof BaseProductSchema>;
|
|
257
|
+
export type BaseProductEntity = z.infer<typeof BaseProductSchema>;
|