@zyacreatives/shared 2.5.2 → 2.5.3
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/constants.d.ts +12 -0
- package/dist/constants.js +15 -7
- package/dist/schemas/index.d.ts +1 -0
- package/dist/schemas/index.js +1 -0
- package/dist/schemas/transaction.d.ts +158 -0
- package/dist/schemas/transaction.js +60 -0
- package/dist/utils/generate-file-url.js +1 -1
- package/package.json +1 -1
- package/src/constants.ts +22 -9
- package/src/schemas/index.ts +1 -0
- package/src/schemas/transaction.ts +88 -0
- package/src/utils/generate-file-url.ts +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -297,6 +297,18 @@ export declare const DISCOUNT_TYPES: {
|
|
|
297
297
|
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
298
298
|
readonly PERCENTAGE: "Percentage";
|
|
299
299
|
};
|
|
300
|
+
export declare const TRANSACTION_STATUSES: {
|
|
301
|
+
readonly PENDING: "PENDING";
|
|
302
|
+
readonly SUCCESS: "SUCCESS";
|
|
303
|
+
readonly FAILED: "FAILED";
|
|
304
|
+
readonly REFUNDED: "REFUNDED";
|
|
305
|
+
};
|
|
306
|
+
export declare const PAYMENT_PROVIDERS: {
|
|
307
|
+
readonly STRIPE: "STRIPE";
|
|
308
|
+
readonly PAYSTACK: "PAYSTACK";
|
|
309
|
+
};
|
|
310
|
+
export type PaymentProvider = (typeof PAYMENT_PROVIDERS)[keyof typeof PAYMENT_PROVIDERS];
|
|
311
|
+
export type TransactionStatus = (typeof TRANSACTION_STATUSES)[keyof typeof TRANSACTION_STATUSES];
|
|
300
312
|
export type SignalInterestType = (typeof SIGNAL_INTEREST_TYPES)[keyof typeof SIGNAL_INTEREST_TYPES];
|
|
301
313
|
export type SignalStatus = (typeof SIGNAL_STATUS)[keyof typeof SIGNAL_STATUS];
|
|
302
314
|
export type NotificationType = (typeof NOTIFICATION_TYPES)[keyof typeof NOTIFICATION_TYPES];
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBCATEGORIES_MAP = exports.CATEGORIES_MAP = exports.MARKETPLACE_CATEGORIES = exports.ANALYTICS_EVENTS = exports.DEFAULT_DISCIPLINES = exports.API_ROUTES = exports.DISCOUNT_TYPES = exports.PRICING_MODELS = exports.GATEWAY_PROVIDER = exports.COUNTRY_OF_OPERATION = exports.SIGNAL_STATUS = exports.SIGNAL_INTEREST_TYPES = exports.VENTURE_STAGES = exports.NOTIFICATION_TYPES = exports.APPLICATION_STATUS = exports.LINK_TYPES = exports.ACTIVITY_TYPES = exports.POST_BADGE_TYPES = exports.PROJECT_STATUS = exports.MESSAGE_REQUEST_STATUS = exports.PRODUCT_STATUS = exports.JOB_STATUS = exports.WAGES_CURRENCY = exports.GIG_TYPE = exports.MESSAGE_TYPES = exports.JOB_LOCATIONS = exports.JOB_SECTIONS = exports.WAGE_TYPES = exports.JOB_AVAILABILITY_TYPES = exports.EMPLOYMENT_TYPE = exports.WORK_MODE = exports.JOB_TYPE = exports.POST_TYPES = exports.ACTIVITY_PARENT_TYPES = exports.INVESTOR_VERIFICATION_DOCUMENT_TYPES = exports.INVESTOR_VERIFICATION_DOCUMENT_STATUSES = exports.GEOGRAPHIC_FOCUS = exports.INVESTMENT_SIZES = exports.INVESTOR_TYPES = exports.ONBOARDING_PAGES = exports.PAYMENT_METHOD_STATUS = exports.SELLER_STATUS = exports.EXPERIENCE_LEVELS = exports.CLIENT_TYPES = exports.USER_STATUSES = exports.ROLES = void 0;
|
|
3
|
+
exports.SUBCATEGORIES_MAP = exports.CATEGORIES_MAP = exports.MARKETPLACE_CATEGORIES = exports.ANALYTICS_EVENTS = exports.DEFAULT_DISCIPLINES = exports.API_ROUTES = exports.PAYMENT_PROVIDERS = exports.TRANSACTION_STATUSES = exports.DISCOUNT_TYPES = exports.PRICING_MODELS = exports.GATEWAY_PROVIDER = exports.COUNTRY_OF_OPERATION = exports.SIGNAL_STATUS = exports.SIGNAL_INTEREST_TYPES = exports.VENTURE_STAGES = exports.NOTIFICATION_TYPES = exports.APPLICATION_STATUS = exports.LINK_TYPES = exports.ACTIVITY_TYPES = exports.POST_BADGE_TYPES = exports.PROJECT_STATUS = exports.MESSAGE_REQUEST_STATUS = exports.PRODUCT_STATUS = exports.JOB_STATUS = exports.WAGES_CURRENCY = exports.GIG_TYPE = exports.MESSAGE_TYPES = exports.JOB_LOCATIONS = exports.JOB_SECTIONS = exports.WAGE_TYPES = exports.JOB_AVAILABILITY_TYPES = exports.EMPLOYMENT_TYPE = exports.WORK_MODE = exports.JOB_TYPE = exports.POST_TYPES = exports.ACTIVITY_PARENT_TYPES = exports.INVESTOR_VERIFICATION_DOCUMENT_TYPES = exports.INVESTOR_VERIFICATION_DOCUMENT_STATUSES = exports.GEOGRAPHIC_FOCUS = exports.INVESTMENT_SIZES = exports.INVESTOR_TYPES = exports.ONBOARDING_PAGES = exports.PAYMENT_METHOD_STATUS = exports.SELLER_STATUS = exports.EXPERIENCE_LEVELS = exports.CLIENT_TYPES = exports.USER_STATUSES = exports.ROLES = void 0;
|
|
4
4
|
exports.ROLES = {
|
|
5
5
|
CREATIVE: "CREATIVE",
|
|
6
6
|
BRAND: "BRAND",
|
|
@@ -295,6 +295,16 @@ exports.DISCOUNT_TYPES = {
|
|
|
295
295
|
FIXED_AMOUNT: "Fixed Amount",
|
|
296
296
|
PERCENTAGE: "Percentage",
|
|
297
297
|
};
|
|
298
|
+
exports.TRANSACTION_STATUSES = {
|
|
299
|
+
PENDING: "PENDING",
|
|
300
|
+
SUCCESS: "SUCCESS",
|
|
301
|
+
FAILED: "FAILED",
|
|
302
|
+
REFUNDED: "REFUNDED",
|
|
303
|
+
};
|
|
304
|
+
exports.PAYMENT_PROVIDERS = {
|
|
305
|
+
STRIPE: "STRIPE",
|
|
306
|
+
PAYSTACK: "PAYSTACK",
|
|
307
|
+
};
|
|
298
308
|
exports.API_ROUTES = {
|
|
299
309
|
healthCheck: "/health",
|
|
300
310
|
username: {
|
|
@@ -593,9 +603,7 @@ exports.CATEGORIES_MAP = {
|
|
|
593
603
|
"Planner & Journal Inserts",
|
|
594
604
|
"Pattern & Surface Design",
|
|
595
605
|
],
|
|
596
|
-
|
|
597
|
-
"Bundles & Kits",
|
|
598
|
-
],
|
|
606
|
+
Other: ["Bundles & Kits"],
|
|
599
607
|
};
|
|
600
608
|
exports.SUBCATEGORIES_MAP = {
|
|
601
609
|
// Design & Illustration
|
|
@@ -638,7 +646,7 @@ exports.SUBCATEGORIES_MAP = {
|
|
|
638
646
|
"Luxury",
|
|
639
647
|
"Playful",
|
|
640
648
|
],
|
|
641
|
-
|
|
649
|
+
Illustrations: [
|
|
642
650
|
"Flat",
|
|
643
651
|
"Isometric",
|
|
644
652
|
"Character",
|
|
@@ -699,7 +707,7 @@ exports.SUBCATEGORIES_MAP = {
|
|
|
699
707
|
"Mailchimp",
|
|
700
708
|
"Minimal",
|
|
701
709
|
],
|
|
702
|
-
|
|
710
|
+
Infographics: [
|
|
703
711
|
"Data Viz",
|
|
704
712
|
"Timeline",
|
|
705
713
|
"Process",
|
|
@@ -933,7 +941,7 @@ exports.SUBCATEGORIES_MAP = {
|
|
|
933
941
|
"Brand Voice",
|
|
934
942
|
"Story",
|
|
935
943
|
],
|
|
936
|
-
|
|
944
|
+
Scripts: [
|
|
937
945
|
"YouTube",
|
|
938
946
|
"TikTok",
|
|
939
947
|
"Podcast",
|
package/dist/schemas/index.d.ts
CHANGED
package/dist/schemas/index.js
CHANGED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
export declare const TransactionDiscountSnapshotSchema: z.ZodObject<{
|
|
3
|
+
code: z.ZodOptional<z.ZodString>;
|
|
4
|
+
amount: z.ZodNumber;
|
|
5
|
+
type: z.ZodEnum<{
|
|
6
|
+
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
7
|
+
readonly PERCENTAGE: "Percentage";
|
|
8
|
+
}>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const BaseTransactionSchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodCUID2;
|
|
12
|
+
productId: z.ZodCUID2;
|
|
13
|
+
buyerId: z.ZodCUID2;
|
|
14
|
+
sellerId: z.ZodCUID2;
|
|
15
|
+
amount: z.ZodNumber;
|
|
16
|
+
platformFee: z.ZodNumber;
|
|
17
|
+
sellerAmount: z.ZodNumber;
|
|
18
|
+
currency: z.ZodEnum<{
|
|
19
|
+
readonly USD: "USD (United States Dollar)";
|
|
20
|
+
readonly EUR: "EUR (Euro)";
|
|
21
|
+
readonly GBP: "GBP (British Pound Sterling)";
|
|
22
|
+
readonly NGN: "NGN (Nigerian Naira)";
|
|
23
|
+
readonly CAD: "CAD (Canadian Dollar)";
|
|
24
|
+
readonly AUD: "AUD (Australian Dollar)";
|
|
25
|
+
readonly JPY: "JPY (Japanese Yen)";
|
|
26
|
+
readonly CHF: "CHF (Swiss Franc)";
|
|
27
|
+
readonly INR: "INR (Indian Rupee)";
|
|
28
|
+
readonly ZAR: "ZAR (South African Rand)";
|
|
29
|
+
}>;
|
|
30
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
31
|
+
readonly PENDING: "PENDING";
|
|
32
|
+
readonly SUCCESS: "SUCCESS";
|
|
33
|
+
readonly FAILED: "FAILED";
|
|
34
|
+
readonly REFUNDED: "REFUNDED";
|
|
35
|
+
}>>;
|
|
36
|
+
paymentProvider: z.ZodEnum<{
|
|
37
|
+
readonly STRIPE: "STRIPE";
|
|
38
|
+
readonly PAYSTACK: "PAYSTACK";
|
|
39
|
+
}>;
|
|
40
|
+
providerTransactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
discountApplied: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
42
|
+
code: z.ZodOptional<z.ZodString>;
|
|
43
|
+
amount: z.ZodNumber;
|
|
44
|
+
type: z.ZodEnum<{
|
|
45
|
+
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
46
|
+
readonly PERCENTAGE: "Percentage";
|
|
47
|
+
}>;
|
|
48
|
+
}, z.core.$strip>>>;
|
|
49
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
50
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export declare const InitTransactionInputSchema: z.ZodObject<{
|
|
53
|
+
productId: z.ZodCUID2;
|
|
54
|
+
paymentProvider: z.ZodEnum<{
|
|
55
|
+
readonly STRIPE: "STRIPE";
|
|
56
|
+
readonly PAYSTACK: "PAYSTACK";
|
|
57
|
+
}>;
|
|
58
|
+
discountCode: z.ZodOptional<z.ZodString>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export declare const CreateTransactionInputSchema: z.ZodObject<{
|
|
61
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
62
|
+
readonly PENDING: "PENDING";
|
|
63
|
+
readonly SUCCESS: "SUCCESS";
|
|
64
|
+
readonly FAILED: "FAILED";
|
|
65
|
+
readonly REFUNDED: "REFUNDED";
|
|
66
|
+
}>>;
|
|
67
|
+
amount: z.ZodNumber;
|
|
68
|
+
sellerId: z.ZodCUID2;
|
|
69
|
+
currency: z.ZodEnum<{
|
|
70
|
+
readonly USD: "USD (United States Dollar)";
|
|
71
|
+
readonly EUR: "EUR (Euro)";
|
|
72
|
+
readonly GBP: "GBP (British Pound Sterling)";
|
|
73
|
+
readonly NGN: "NGN (Nigerian Naira)";
|
|
74
|
+
readonly CAD: "CAD (Canadian Dollar)";
|
|
75
|
+
readonly AUD: "AUD (Australian Dollar)";
|
|
76
|
+
readonly JPY: "JPY (Japanese Yen)";
|
|
77
|
+
readonly CHF: "CHF (Swiss Franc)";
|
|
78
|
+
readonly INR: "INR (Indian Rupee)";
|
|
79
|
+
readonly ZAR: "ZAR (South African Rand)";
|
|
80
|
+
}>;
|
|
81
|
+
productId: z.ZodCUID2;
|
|
82
|
+
buyerId: z.ZodCUID2;
|
|
83
|
+
platformFee: z.ZodNumber;
|
|
84
|
+
sellerAmount: z.ZodNumber;
|
|
85
|
+
paymentProvider: z.ZodEnum<{
|
|
86
|
+
readonly STRIPE: "STRIPE";
|
|
87
|
+
readonly PAYSTACK: "PAYSTACK";
|
|
88
|
+
}>;
|
|
89
|
+
discountApplied: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
code: z.ZodOptional<z.ZodString>;
|
|
91
|
+
amount: z.ZodNumber;
|
|
92
|
+
type: z.ZodEnum<{
|
|
93
|
+
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
94
|
+
readonly PERCENTAGE: "Percentage";
|
|
95
|
+
}>;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
providerTransactionId: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export declare const UpdateTransactionWebhookInputSchema: z.ZodObject<{
|
|
100
|
+
status: z.ZodEnum<{
|
|
101
|
+
readonly PENDING: "PENDING";
|
|
102
|
+
readonly SUCCESS: "SUCCESS";
|
|
103
|
+
readonly FAILED: "FAILED";
|
|
104
|
+
readonly REFUNDED: "REFUNDED";
|
|
105
|
+
}>;
|
|
106
|
+
providerTransactionId: z.ZodString;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
export declare const TransactionEntitySchema: z.ZodObject<{
|
|
109
|
+
id: z.ZodCUID2;
|
|
110
|
+
productId: z.ZodCUID2;
|
|
111
|
+
buyerId: z.ZodCUID2;
|
|
112
|
+
amount: z.ZodNumber;
|
|
113
|
+
platformFee: z.ZodNumber;
|
|
114
|
+
sellerAmount: z.ZodNumber;
|
|
115
|
+
currency: z.ZodEnum<{
|
|
116
|
+
readonly USD: "USD (United States Dollar)";
|
|
117
|
+
readonly EUR: "EUR (Euro)";
|
|
118
|
+
readonly GBP: "GBP (British Pound Sterling)";
|
|
119
|
+
readonly NGN: "NGN (Nigerian Naira)";
|
|
120
|
+
readonly CAD: "CAD (Canadian Dollar)";
|
|
121
|
+
readonly AUD: "AUD (Australian Dollar)";
|
|
122
|
+
readonly JPY: "JPY (Japanese Yen)";
|
|
123
|
+
readonly CHF: "CHF (Swiss Franc)";
|
|
124
|
+
readonly INR: "INR (Indian Rupee)";
|
|
125
|
+
readonly ZAR: "ZAR (South African Rand)";
|
|
126
|
+
}>;
|
|
127
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
128
|
+
readonly PENDING: "PENDING";
|
|
129
|
+
readonly SUCCESS: "SUCCESS";
|
|
130
|
+
readonly FAILED: "FAILED";
|
|
131
|
+
readonly REFUNDED: "REFUNDED";
|
|
132
|
+
}>>;
|
|
133
|
+
paymentProvider: z.ZodEnum<{
|
|
134
|
+
readonly STRIPE: "STRIPE";
|
|
135
|
+
readonly PAYSTACK: "PAYSTACK";
|
|
136
|
+
}>;
|
|
137
|
+
providerTransactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
138
|
+
discountApplied: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
139
|
+
code: z.ZodOptional<z.ZodString>;
|
|
140
|
+
amount: z.ZodNumber;
|
|
141
|
+
type: z.ZodEnum<{
|
|
142
|
+
readonly FIXED_AMOUNT: "Fixed Amount";
|
|
143
|
+
readonly PERCENTAGE: "Percentage";
|
|
144
|
+
}>;
|
|
145
|
+
}, z.core.$strip>>>;
|
|
146
|
+
createdAt: z.ZodCoercedDate<unknown>;
|
|
147
|
+
updatedAt: z.ZodCoercedDate<unknown>;
|
|
148
|
+
productTitle: z.ZodOptional<z.ZodString>;
|
|
149
|
+
sellerName: z.ZodOptional<z.ZodString>;
|
|
150
|
+
sellerId: z.ZodOptional<z.ZodString>;
|
|
151
|
+
sellerUsername: z.ZodOptional<z.ZodString>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
export type TransactionDiscountSnapshot = z.infer<typeof TransactionDiscountSnapshotSchema>;
|
|
154
|
+
export type BaseTransactionEntity = z.infer<typeof BaseTransactionSchema>;
|
|
155
|
+
export type InitTransactionInput = z.infer<typeof InitTransactionInputSchema>;
|
|
156
|
+
export type CreateTransactionInput = z.infer<typeof CreateTransactionInputSchema>;
|
|
157
|
+
export type UpdateTransactionWebhookInput = z.infer<typeof UpdateTransactionWebhookInputSchema>;
|
|
158
|
+
export type TransactionEntity = z.infer<typeof TransactionEntitySchema>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionEntitySchema = exports.UpdateTransactionWebhookInputSchema = exports.CreateTransactionInputSchema = exports.InitTransactionInputSchema = exports.BaseTransactionSchema = exports.TransactionDiscountSnapshotSchema = void 0;
|
|
4
|
+
const zod_openapi_1 = require("@hono/zod-openapi");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
exports.TransactionDiscountSnapshotSchema = zod_openapi_1.z.object({
|
|
7
|
+
code: zod_openapi_1.z.string().optional(),
|
|
8
|
+
amount: zod_openapi_1.z.number().int("Amount must be a whole number"),
|
|
9
|
+
type: zod_openapi_1.z.enum(constants_1.DISCOUNT_TYPES),
|
|
10
|
+
});
|
|
11
|
+
exports.BaseTransactionSchema = zod_openapi_1.z.object({
|
|
12
|
+
id: zod_openapi_1.z.cuid2(),
|
|
13
|
+
productId: zod_openapi_1.z.cuid2(),
|
|
14
|
+
buyerId: zod_openapi_1.z.cuid2(),
|
|
15
|
+
sellerId: zod_openapi_1.z.cuid2(),
|
|
16
|
+
amount: zod_openapi_1.z.number().int(),
|
|
17
|
+
platformFee: zod_openapi_1.z.number().int(),
|
|
18
|
+
sellerAmount: zod_openapi_1.z.number().int(),
|
|
19
|
+
currency: zod_openapi_1.z.enum(constants_1.WAGES_CURRENCY),
|
|
20
|
+
status: zod_openapi_1.z.enum(constants_1.TRANSACTION_STATUSES).default("PENDING"),
|
|
21
|
+
paymentProvider: zod_openapi_1.z.enum(constants_1.PAYMENT_PROVIDERS),
|
|
22
|
+
providerTransactionId: zod_openapi_1.z.string().nullable().optional(),
|
|
23
|
+
discountApplied: exports.TransactionDiscountSnapshotSchema.nullable().optional(),
|
|
24
|
+
createdAt: zod_openapi_1.z.coerce.date(),
|
|
25
|
+
updatedAt: zod_openapi_1.z.coerce.date(),
|
|
26
|
+
});
|
|
27
|
+
exports.InitTransactionInputSchema = zod_openapi_1.z.object({
|
|
28
|
+
productId: zod_openapi_1.z
|
|
29
|
+
.cuid2()
|
|
30
|
+
.openapi({ description: "ID of the product being purchased" }),
|
|
31
|
+
paymentProvider: zod_openapi_1.z.enum(constants_1.PAYMENT_PROVIDERS),
|
|
32
|
+
discountCode: zod_openapi_1.z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.openapi({ description: "Optional discount code applied at checkout" }),
|
|
36
|
+
});
|
|
37
|
+
exports.CreateTransactionInputSchema = exports.BaseTransactionSchema.pick({
|
|
38
|
+
productId: true,
|
|
39
|
+
buyerId: true,
|
|
40
|
+
sellerId: true,
|
|
41
|
+
amount: true,
|
|
42
|
+
platformFee: true,
|
|
43
|
+
sellerAmount: true,
|
|
44
|
+
currency: true,
|
|
45
|
+
paymentProvider: true,
|
|
46
|
+
status: true,
|
|
47
|
+
}).extend({
|
|
48
|
+
discountApplied: exports.TransactionDiscountSnapshotSchema.optional(),
|
|
49
|
+
providerTransactionId: zod_openapi_1.z.string().optional(), // Might not exist until after init
|
|
50
|
+
});
|
|
51
|
+
exports.UpdateTransactionWebhookInputSchema = zod_openapi_1.z.object({
|
|
52
|
+
status: zod_openapi_1.z.enum(constants_1.TRANSACTION_STATUSES),
|
|
53
|
+
providerTransactionId: zod_openapi_1.z.string(),
|
|
54
|
+
});
|
|
55
|
+
exports.TransactionEntitySchema = exports.BaseTransactionSchema.extend({
|
|
56
|
+
productTitle: zod_openapi_1.z.string().optional(),
|
|
57
|
+
sellerName: zod_openapi_1.z.string().optional(),
|
|
58
|
+
sellerId: zod_openapi_1.z.string().optional(),
|
|
59
|
+
sellerUsername: zod_openapi_1.z.string().optional(),
|
|
60
|
+
}).openapi({ title: "TransactionEntity" });
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateFileUrl = void 0;
|
|
4
4
|
const generateFileUrl = (key, isProd) => {
|
|
5
|
-
return `https
|
|
5
|
+
return `https://cdn.tryzya.date/${key}`;
|
|
6
6
|
};
|
|
7
7
|
exports.generateFileUrl = generateFileUrl;
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -338,6 +338,23 @@ export const DISCOUNT_TYPES = {
|
|
|
338
338
|
PERCENTAGE: "Percentage",
|
|
339
339
|
} as const;
|
|
340
340
|
|
|
341
|
+
export const TRANSACTION_STATUSES = {
|
|
342
|
+
PENDING: "PENDING",
|
|
343
|
+
SUCCESS: "SUCCESS",
|
|
344
|
+
FAILED: "FAILED",
|
|
345
|
+
REFUNDED: "REFUNDED",
|
|
346
|
+
} as const;
|
|
347
|
+
|
|
348
|
+
export const PAYMENT_PROVIDERS = {
|
|
349
|
+
STRIPE: "STRIPE",
|
|
350
|
+
PAYSTACK: "PAYSTACK",
|
|
351
|
+
} as const;
|
|
352
|
+
|
|
353
|
+
export type PaymentProvider =
|
|
354
|
+
(typeof PAYMENT_PROVIDERS)[keyof typeof PAYMENT_PROVIDERS];
|
|
355
|
+
export type TransactionStatus =
|
|
356
|
+
(typeof TRANSACTION_STATUSES)[keyof typeof TRANSACTION_STATUSES];
|
|
357
|
+
|
|
341
358
|
export type SignalInterestType =
|
|
342
359
|
(typeof SIGNAL_INTEREST_TYPES)[keyof typeof SIGNAL_INTEREST_TYPES];
|
|
343
360
|
export type SignalStatus = (typeof SIGNAL_STATUS)[keyof typeof SIGNAL_STATUS];
|
|
@@ -638,7 +655,6 @@ export const MARKETPLACE_CATEGORIES: MarketplaceCategory[] = [
|
|
|
638
655
|
},
|
|
639
656
|
] as const;
|
|
640
657
|
|
|
641
|
-
|
|
642
658
|
export const CATEGORIES_MAP: Record<string, string[]> = {
|
|
643
659
|
"Design & Illustration": [
|
|
644
660
|
"Website Templates",
|
|
@@ -713,12 +729,9 @@ export const CATEGORIES_MAP: Record<string, string[]> = {
|
|
|
713
729
|
"Planner & Journal Inserts",
|
|
714
730
|
"Pattern & Surface Design",
|
|
715
731
|
],
|
|
716
|
-
|
|
717
|
-
"Bundles & Kits",
|
|
718
|
-
],
|
|
732
|
+
Other: ["Bundles & Kits"],
|
|
719
733
|
} as const;
|
|
720
734
|
|
|
721
|
-
|
|
722
735
|
export const SUBCATEGORIES_MAP: Record<string, string[]> = {
|
|
723
736
|
// Design & Illustration
|
|
724
737
|
"Website Templates": [
|
|
@@ -760,7 +773,7 @@ export const SUBCATEGORIES_MAP: Record<string, string[]> = {
|
|
|
760
773
|
"Luxury",
|
|
761
774
|
"Playful",
|
|
762
775
|
],
|
|
763
|
-
|
|
776
|
+
Illustrations: [
|
|
764
777
|
"Flat",
|
|
765
778
|
"Isometric",
|
|
766
779
|
"Character",
|
|
@@ -821,7 +834,7 @@ export const SUBCATEGORIES_MAP: Record<string, string[]> = {
|
|
|
821
834
|
"Mailchimp",
|
|
822
835
|
"Minimal",
|
|
823
836
|
],
|
|
824
|
-
|
|
837
|
+
Infographics: [
|
|
825
838
|
"Data Viz",
|
|
826
839
|
"Timeline",
|
|
827
840
|
"Process",
|
|
@@ -1058,7 +1071,7 @@ export const SUBCATEGORIES_MAP: Record<string, string[]> = {
|
|
|
1058
1071
|
"Brand Voice",
|
|
1059
1072
|
"Story",
|
|
1060
1073
|
],
|
|
1061
|
-
|
|
1074
|
+
Scripts: [
|
|
1062
1075
|
"YouTube",
|
|
1063
1076
|
"TikTok",
|
|
1064
1077
|
"Podcast",
|
|
@@ -1397,4 +1410,4 @@ export const SUBCATEGORIES_MAP: Record<string, string[]> = {
|
|
|
1397
1410
|
"Limited Edition",
|
|
1398
1411
|
"Seasonal",
|
|
1399
1412
|
],
|
|
1400
|
-
} as const;
|
|
1413
|
+
} as const;
|
package/src/schemas/index.ts
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from "@hono/zod-openapi";
|
|
2
|
+
import {
|
|
3
|
+
DISCOUNT_TYPES,
|
|
4
|
+
WAGES_CURRENCY,
|
|
5
|
+
TRANSACTION_STATUSES,
|
|
6
|
+
PAYMENT_PROVIDERS,
|
|
7
|
+
} from "../constants";
|
|
8
|
+
|
|
9
|
+
export const TransactionDiscountSnapshotSchema = z.object({
|
|
10
|
+
code: z.string().optional(),
|
|
11
|
+
amount: z.number().int("Amount must be a whole number"),
|
|
12
|
+
type: z.enum(DISCOUNT_TYPES),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const BaseTransactionSchema = z.object({
|
|
16
|
+
id: z.cuid2(),
|
|
17
|
+
productId: z.cuid2(),
|
|
18
|
+
buyerId: z.cuid2(),
|
|
19
|
+
sellerId: z.cuid2(),
|
|
20
|
+
|
|
21
|
+
amount: z.number().int(),
|
|
22
|
+
platformFee: z.number().int(),
|
|
23
|
+
sellerAmount: z.number().int(),
|
|
24
|
+
currency: z.enum(WAGES_CURRENCY),
|
|
25
|
+
|
|
26
|
+
status: z.enum(TRANSACTION_STATUSES).default("PENDING"),
|
|
27
|
+
paymentProvider: z.enum(PAYMENT_PROVIDERS),
|
|
28
|
+
providerTransactionId: z.string().nullable().optional(),
|
|
29
|
+
|
|
30
|
+
discountApplied: TransactionDiscountSnapshotSchema.nullable().optional(),
|
|
31
|
+
|
|
32
|
+
createdAt: z.coerce.date(),
|
|
33
|
+
updatedAt: z.coerce.date(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const InitTransactionInputSchema = z.object({
|
|
37
|
+
productId: z
|
|
38
|
+
.cuid2()
|
|
39
|
+
.openapi({ description: "ID of the product being purchased" }),
|
|
40
|
+
paymentProvider: z.enum(PAYMENT_PROVIDERS),
|
|
41
|
+
discountCode: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.openapi({ description: "Optional discount code applied at checkout" }),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const CreateTransactionInputSchema = BaseTransactionSchema.pick({
|
|
49
|
+
productId: true,
|
|
50
|
+
buyerId: true,
|
|
51
|
+
sellerId: true,
|
|
52
|
+
amount: true,
|
|
53
|
+
platformFee: true,
|
|
54
|
+
sellerAmount: true,
|
|
55
|
+
currency: true,
|
|
56
|
+
paymentProvider: true,
|
|
57
|
+
status: true,
|
|
58
|
+
}).extend({
|
|
59
|
+
discountApplied: TransactionDiscountSnapshotSchema.optional(),
|
|
60
|
+
providerTransactionId: z.string().optional(), // Might not exist until after init
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const UpdateTransactionWebhookInputSchema = z.object({
|
|
64
|
+
status: z.enum(TRANSACTION_STATUSES),
|
|
65
|
+
providerTransactionId: z.string(),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const TransactionEntitySchema = BaseTransactionSchema.extend({
|
|
69
|
+
productTitle: z.string().optional(),
|
|
70
|
+
sellerName: z.string().optional(),
|
|
71
|
+
sellerId: z.string().optional(),
|
|
72
|
+
sellerUsername: z.string().optional(),
|
|
73
|
+
}).openapi({ title: "TransactionEntity" });
|
|
74
|
+
|
|
75
|
+
export type TransactionDiscountSnapshot = z.infer<
|
|
76
|
+
typeof TransactionDiscountSnapshotSchema
|
|
77
|
+
>;
|
|
78
|
+
export type BaseTransactionEntity = z.infer<typeof BaseTransactionSchema>;
|
|
79
|
+
|
|
80
|
+
export type InitTransactionInput = z.infer<typeof InitTransactionInputSchema>;
|
|
81
|
+
export type CreateTransactionInput = z.infer<
|
|
82
|
+
typeof CreateTransactionInputSchema
|
|
83
|
+
>;
|
|
84
|
+
export type UpdateTransactionWebhookInput = z.infer<
|
|
85
|
+
typeof UpdateTransactionWebhookInputSchema
|
|
86
|
+
>;
|
|
87
|
+
|
|
88
|
+
export type TransactionEntity = z.infer<typeof TransactionEntitySchema>;
|