@zyacreatives/shared 2.5.27 → 2.5.29

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.
@@ -1270,6 +1270,8 @@ export declare const UpdateRoleJobInputSchema: z.ZodObject<{
1270
1270
  id: z.ZodNonOptional<z.ZodOptional<z.ZodCUID2>>;
1271
1271
  version: z.ZodNumber;
1272
1272
  }, z.core.$strip>;
1273
+ export type CreateRoleJobOutput = z.infer<typeof RoleJobEntitySchema>;
1274
+ export type CreateGigJobOutput = z.infer<typeof GigJobEntitySchema>;
1273
1275
  export type UpdateRoleJobInput = z.infer<typeof UpdateRoleJobInputSchema>;
1274
1276
  export declare const UpdateGigJobInputSchema: z.ZodObject<{
1275
1277
  overview: z.ZodOptional<z.ZodString>;
@@ -266,15 +266,15 @@ exports.JobSearchDocumentSchema = zod_openapi_1.z
266
266
  .openapi("JobSearchDocument");
267
267
  exports.UpdateRoleJobInputSchema = exports.CreateRoleJobInputSchema.partial()
268
268
  .extend({
269
- version: zod_openapi_1.z.number().int().openapi({ example: 2 })
269
+ version: zod_openapi_1.z.number().int().openapi({ example: 2 }),
270
270
  })
271
271
  .required({
272
- id: true
272
+ id: true,
273
273
  });
274
274
  exports.UpdateGigJobInputSchema = exports.CreateGigJobInputSchema.partial()
275
275
  .extend({
276
- version: zod_openapi_1.z.number().int().openapi({ example: 2 })
276
+ version: zod_openapi_1.z.number().int().openapi({ example: 2 }),
277
277
  })
278
278
  .required({
279
- id: true
279
+ id: true,
280
280
  });
@@ -1,12 +1,4 @@
1
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
2
  export declare const BaseTransactionSchema: z.ZodObject<{
11
3
  id: z.ZodCUID2;
12
4
  productId: z.ZodCUID2;
@@ -40,25 +32,25 @@ export declare const BaseTransactionSchema: z.ZodObject<{
40
32
  }>;
41
33
  providerTransactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
42
34
  discountApplied: z.ZodOptional<z.ZodNullable<z.ZodObject<{
43
- code: z.ZodOptional<z.ZodString>;
44
- amount: z.ZodNumber;
45
- type: z.ZodEnum<{
35
+ discountType: z.ZodEnum<{
46
36
  readonly FIXED_AMOUNT: "Fixed Amount";
47
37
  readonly PERCENTAGE: "Percentage";
48
38
  }>;
39
+ amount: z.ZodNumber;
40
+ discountCode: z.ZodOptional<z.ZodString>;
41
+ active: z.ZodDefault<z.ZodBoolean>;
49
42
  }, z.core.$strip>>>;
50
43
  createdAt: z.ZodCoercedDate<unknown>;
51
44
  updatedAt: z.ZodCoercedDate<unknown>;
52
45
  }, z.core.$strip>;
53
46
  export declare const InitTransactionInputSchema: z.ZodObject<{
54
47
  productId: z.ZodCUID2;
55
- paymentProvider: z.ZodEnum<{
56
- readonly STRIPE: "STRIPE";
57
- readonly PAYSTACK: "PAYSTACK";
58
- readonly NONE: "NONE";
59
- }>;
48
+ firstName: z.ZodOptional<z.ZodString>;
49
+ lastName: z.ZodOptional<z.ZodString>;
50
+ buyerId: z.ZodCUID2;
51
+ email: z.ZodOptional<z.ZodEmail>;
60
52
  discountCode: z.ZodOptional<z.ZodString>;
61
- amount: z.ZodOptional<z.ZodNumber>;
53
+ amount: z.ZodNumber;
62
54
  }, z.core.$strip>;
63
55
  export declare const CreateTransactionInputSchema: z.ZodObject<{
64
56
  status: z.ZodDefault<z.ZodEnum<{
@@ -91,12 +83,13 @@ export declare const CreateTransactionInputSchema: z.ZodObject<{
91
83
  readonly NONE: "NONE";
92
84
  }>;
93
85
  discountApplied: z.ZodOptional<z.ZodObject<{
94
- code: z.ZodOptional<z.ZodString>;
95
- amount: z.ZodNumber;
96
- type: z.ZodEnum<{
86
+ discountType: z.ZodEnum<{
97
87
  readonly FIXED_AMOUNT: "Fixed Amount";
98
88
  readonly PERCENTAGE: "Percentage";
99
89
  }>;
90
+ amount: z.ZodNumber;
91
+ discountCode: z.ZodOptional<z.ZodString>;
92
+ active: z.ZodDefault<z.ZodBoolean>;
100
93
  }, z.core.$strip>>;
101
94
  providerTransactionId: z.ZodOptional<z.ZodString>;
102
95
  }, z.core.$strip>;
@@ -141,12 +134,13 @@ export declare const TransactionEntitySchema: z.ZodObject<{
141
134
  }>;
142
135
  providerTransactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
143
136
  discountApplied: z.ZodOptional<z.ZodNullable<z.ZodObject<{
144
- code: z.ZodOptional<z.ZodString>;
145
- amount: z.ZodNumber;
146
- type: z.ZodEnum<{
137
+ discountType: z.ZodEnum<{
147
138
  readonly FIXED_AMOUNT: "Fixed Amount";
148
139
  readonly PERCENTAGE: "Percentage";
149
140
  }>;
141
+ amount: z.ZodNumber;
142
+ discountCode: z.ZodOptional<z.ZodString>;
143
+ active: z.ZodDefault<z.ZodBoolean>;
150
144
  }, z.core.$strip>>>;
151
145
  createdAt: z.ZodCoercedDate<unknown>;
152
146
  updatedAt: z.ZodCoercedDate<unknown>;
@@ -154,10 +148,66 @@ export declare const TransactionEntitySchema: z.ZodObject<{
154
148
  sellerName: z.ZodOptional<z.ZodString>;
155
149
  sellerId: z.ZodOptional<z.ZodString>;
156
150
  sellerUsername: z.ZodOptional<z.ZodString>;
151
+ buyerName: z.ZodOptional<z.ZodString>;
152
+ buyerUsername: z.ZodOptional<z.ZodString>;
153
+ buyerEmail: z.ZodEmail;
154
+ }, z.core.$strip>;
155
+ export declare const InitTransactionOutputSchema: z.ZodObject<{
156
+ transaction: z.ZodObject<{
157
+ id: z.ZodCUID2;
158
+ productId: z.ZodCUID2;
159
+ buyerId: z.ZodCUID2;
160
+ amount: z.ZodNumber;
161
+ platformFee: z.ZodNumber;
162
+ sellerAmount: z.ZodNumber;
163
+ currency: z.ZodEnum<{
164
+ readonly USD: "USD (United States Dollar)";
165
+ readonly EUR: "EUR (Euro)";
166
+ readonly GBP: "GBP (British Pound Sterling)";
167
+ readonly NGN: "NGN (Nigerian Naira)";
168
+ readonly CAD: "CAD (Canadian Dollar)";
169
+ readonly AUD: "AUD (Australian Dollar)";
170
+ readonly JPY: "JPY (Japanese Yen)";
171
+ readonly CHF: "CHF (Swiss Franc)";
172
+ readonly INR: "INR (Indian Rupee)";
173
+ readonly ZAR: "ZAR (South African Rand)";
174
+ }>;
175
+ status: z.ZodDefault<z.ZodEnum<{
176
+ readonly PENDING: "PENDING";
177
+ readonly SUCCESS: "SUCCESS";
178
+ readonly FAILED: "FAILED";
179
+ readonly REFUNDED: "REFUNDED";
180
+ }>>;
181
+ paymentProvider: z.ZodEnum<{
182
+ readonly STRIPE: "STRIPE";
183
+ readonly PAYSTACK: "PAYSTACK";
184
+ readonly NONE: "NONE";
185
+ }>;
186
+ providerTransactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
187
+ discountApplied: z.ZodOptional<z.ZodNullable<z.ZodObject<{
188
+ discountType: z.ZodEnum<{
189
+ readonly FIXED_AMOUNT: "Fixed Amount";
190
+ readonly PERCENTAGE: "Percentage";
191
+ }>;
192
+ amount: z.ZodNumber;
193
+ discountCode: z.ZodOptional<z.ZodString>;
194
+ active: z.ZodDefault<z.ZodBoolean>;
195
+ }, z.core.$strip>>>;
196
+ createdAt: z.ZodCoercedDate<unknown>;
197
+ updatedAt: z.ZodCoercedDate<unknown>;
198
+ productTitle: z.ZodOptional<z.ZodString>;
199
+ sellerName: z.ZodOptional<z.ZodString>;
200
+ sellerId: z.ZodOptional<z.ZodString>;
201
+ sellerUsername: z.ZodOptional<z.ZodString>;
202
+ buyerName: z.ZodOptional<z.ZodString>;
203
+ buyerUsername: z.ZodOptional<z.ZodString>;
204
+ buyerEmail: z.ZodEmail;
205
+ }, z.core.$strip>;
206
+ checkoutUrl: z.ZodNullable<z.ZodURL>;
157
207
  }, z.core.$strip>;
158
- export type TransactionDiscountSnapshot = z.infer<typeof TransactionDiscountSnapshotSchema>;
159
208
  export type BaseTransactionEntity = z.infer<typeof BaseTransactionSchema>;
160
209
  export type InitTransactionInput = z.infer<typeof InitTransactionInputSchema>;
161
210
  export type CreateTransactionInput = z.infer<typeof CreateTransactionInputSchema>;
162
211
  export type UpdateTransactionWebhookInput = z.infer<typeof UpdateTransactionWebhookInputSchema>;
163
212
  export type TransactionEntity = z.infer<typeof TransactionEntitySchema>;
213
+ export type InitTransactionResult = z.infer<typeof InitTransactionOutputSchema>;
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransactionEntitySchema = exports.UpdateTransactionWebhookInputSchema = exports.CreateTransactionInputSchema = exports.InitTransactionInputSchema = exports.BaseTransactionSchema = exports.TransactionDiscountSnapshotSchema = void 0;
3
+ exports.InitTransactionOutputSchema = exports.TransactionEntitySchema = exports.UpdateTransactionWebhookInputSchema = exports.CreateTransactionInputSchema = exports.InitTransactionInputSchema = exports.BaseTransactionSchema = void 0;
4
4
  const zod_openapi_1 = require("@hono/zod-openapi");
5
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
- });
6
+ const product_1 = require("./product");
11
7
  exports.BaseTransactionSchema = zod_openapi_1.z.object({
12
8
  id: zod_openapi_1.z.cuid2(),
13
9
  productId: zod_openapi_1.z.cuid2(),
@@ -20,15 +16,24 @@ exports.BaseTransactionSchema = zod_openapi_1.z.object({
20
16
  status: zod_openapi_1.z.enum(constants_1.TRANSACTION_STATUSES).default("PENDING"),
21
17
  paymentProvider: zod_openapi_1.z.enum(constants_1.PAYMENT_PROVIDERS),
22
18
  providerTransactionId: zod_openapi_1.z.string().nullable().optional(),
23
- discountApplied: exports.TransactionDiscountSnapshotSchema.nullable().optional(),
19
+ discountApplied: product_1.ProductDiscountEntitySchema.nullable().optional(),
24
20
  createdAt: zod_openapi_1.z.coerce.date(),
25
21
  updatedAt: zod_openapi_1.z.coerce.date(),
26
22
  });
23
+ // ==========================================
24
+ // INPUT SCHEMAS
25
+ // ==========================================
27
26
  exports.InitTransactionInputSchema = zod_openapi_1.z.object({
28
27
  productId: zod_openapi_1.z
29
28
  .cuid2()
30
29
  .openapi({ description: "ID of the product being purchased" }),
31
- paymentProvider: zod_openapi_1.z.enum(constants_1.PAYMENT_PROVIDERS),
30
+ firstName: zod_openapi_1.z.string().optional(),
31
+ lastName: zod_openapi_1.z.string().optional(),
32
+ buyerId: zod_openapi_1.z.cuid2(),
33
+ email: zod_openapi_1.z
34
+ .email()
35
+ .optional()
36
+ .openapi({ description: "Buyer's email address from the checkout form" }),
32
37
  discountCode: zod_openapi_1.z
33
38
  .string()
34
39
  .optional()
@@ -37,10 +42,6 @@ exports.InitTransactionInputSchema = zod_openapi_1.z.object({
37
42
  .number()
38
43
  .int("Amount must be a whole number (cents/kobo)")
39
44
  .min(0)
40
- .optional()
41
- .openapi({
42
- description: "Required for PWYW pricing. The amount the buyer chooses to pay in cents/kobo.",
43
- }),
44
45
  });
45
46
  exports.CreateTransactionInputSchema = exports.BaseTransactionSchema.pick({
46
47
  productId: true,
@@ -53,16 +54,30 @@ exports.CreateTransactionInputSchema = exports.BaseTransactionSchema.pick({
53
54
  paymentProvider: true,
54
55
  status: true,
55
56
  }).extend({
56
- discountApplied: exports.TransactionDiscountSnapshotSchema.optional(),
57
+ discountApplied: product_1.ProductDiscountEntitySchema.optional(),
57
58
  providerTransactionId: zod_openapi_1.z.string().optional(),
58
59
  });
59
60
  exports.UpdateTransactionWebhookInputSchema = zod_openapi_1.z.object({
60
61
  status: zod_openapi_1.z.enum(constants_1.TRANSACTION_STATUSES),
61
62
  providerTransactionId: zod_openapi_1.z.string(),
62
63
  });
64
+ // ==========================================
65
+ // ENTITY & OUTPUT SCHEMAS
66
+ // ==========================================
63
67
  exports.TransactionEntitySchema = exports.BaseTransactionSchema.extend({
64
68
  productTitle: zod_openapi_1.z.string().optional(),
65
69
  sellerName: zod_openapi_1.z.string().optional(),
66
70
  sellerId: zod_openapi_1.z.string().optional(),
67
71
  sellerUsername: zod_openapi_1.z.string().optional(),
72
+ buyerName: zod_openapi_1.z.string().optional(),
73
+ buyerUsername: zod_openapi_1.z.string().optional(),
74
+ buyerEmail: zod_openapi_1.z.email(),
68
75
  }).openapi({ title: "TransactionEntity" });
76
+ exports.InitTransactionOutputSchema = zod_openapi_1.z
77
+ .object({
78
+ transaction: exports.TransactionEntitySchema,
79
+ checkoutUrl: zod_openapi_1.z.url().nullable().openapi({
80
+ description: "The Stripe/Paystack checkout URL to redirect the user to",
81
+ }),
82
+ })
83
+ .openapi({ title: "InitTransactionResult" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zyacreatives/shared",
3
- "version": "2.5.27",
3
+ "version": "2.5.29",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -359,25 +359,27 @@ export const JobSearchDocumentSchema = z
359
359
  export type JobSearchDocument = z.infer<typeof JobSearchDocumentSchema>;
360
360
 
361
361
  export const UpdateRoleJobInputSchema = CreateRoleJobInputSchema.partial()
362
- .extend({
363
- version: z.number().int().openapi({ example: 2 })
362
+ .extend({
363
+ version: z.number().int().openapi({ example: 2 }),
364
364
  })
365
- .required({
366
- id: true
365
+ .required({
366
+ id: true,
367
367
  });
368
+ export type CreateRoleJobOutput = z.infer<typeof RoleJobEntitySchema>;
369
+ export type CreateGigJobOutput = z.infer<typeof GigJobEntitySchema>;
368
370
 
369
371
  export type UpdateRoleJobInput = z.infer<typeof UpdateRoleJobInputSchema>;
370
372
 
371
373
  export const UpdateGigJobInputSchema = CreateGigJobInputSchema.partial()
372
- .extend({
373
- version: z.number().int().openapi({ example: 2 })
374
+ .extend({
375
+ version: z.number().int().openapi({ example: 2 }),
374
376
  })
375
- .required({
376
- id: true
377
+ .required({
378
+ id: true,
377
379
  });
378
380
 
379
381
  export type UpdateGigJobInput = z.infer<typeof UpdateGigJobInputSchema>;
380
382
 
381
383
  export type UpdateRoleJobOutput = z.infer<typeof RoleJobEntitySchema>;
382
384
 
383
- export type UpdateGigJobOutput = z.infer<typeof GigJobEntitySchema>;
385
+ export type UpdateGigJobOutput = z.infer<typeof GigJobEntitySchema>;
@@ -5,12 +5,7 @@ import {
5
5
  TRANSACTION_STATUSES,
6
6
  PAYMENT_PROVIDERS,
7
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
- });
8
+ import { ProductDiscountEntitySchema } from "./product";
14
9
 
15
10
  export const BaseTransactionSchema = z.object({
16
11
  id: z.cuid2(),
@@ -27,17 +22,27 @@ export const BaseTransactionSchema = z.object({
27
22
  paymentProvider: z.enum(PAYMENT_PROVIDERS),
28
23
  providerTransactionId: z.string().nullable().optional(),
29
24
 
30
- discountApplied: TransactionDiscountSnapshotSchema.nullable().optional(),
25
+ discountApplied: ProductDiscountEntitySchema.nullable().optional(),
31
26
 
32
27
  createdAt: z.coerce.date(),
33
28
  updatedAt: z.coerce.date(),
34
29
  });
35
30
 
31
+ // ==========================================
32
+ // INPUT SCHEMAS
33
+ // ==========================================
34
+
36
35
  export const InitTransactionInputSchema = z.object({
37
36
  productId: z
38
37
  .cuid2()
39
38
  .openapi({ description: "ID of the product being purchased" }),
40
- paymentProvider: z.enum(PAYMENT_PROVIDERS),
39
+ firstName: z.string().optional(),
40
+ lastName: z.string().optional(),
41
+ buyerId: z.cuid2(),
42
+ email: z
43
+ .email()
44
+ .optional()
45
+ .openapi({ description: "Buyer's email address from the checkout form" }),
41
46
  discountCode: z
42
47
  .string()
43
48
  .optional()
@@ -46,11 +51,6 @@ export const InitTransactionInputSchema = z.object({
46
51
  .number()
47
52
  .int("Amount must be a whole number (cents/kobo)")
48
53
  .min(0)
49
- .optional()
50
- .openapi({
51
- description:
52
- "Required for PWYW pricing. The amount the buyer chooses to pay in cents/kobo.",
53
- }),
54
54
  });
55
55
 
56
56
  export const CreateTransactionInputSchema = BaseTransactionSchema.pick({
@@ -64,8 +64,8 @@ export const CreateTransactionInputSchema = BaseTransactionSchema.pick({
64
64
  paymentProvider: true,
65
65
  status: true,
66
66
  }).extend({
67
- discountApplied: TransactionDiscountSnapshotSchema.optional(),
68
- providerTransactionId: z.string().optional(),
67
+ discountApplied: ProductDiscountEntitySchema.optional(),
68
+ providerTransactionId: z.string().optional(),
69
69
  });
70
70
 
71
71
  export const UpdateTransactionWebhookInputSchema = z.object({
@@ -73,16 +73,32 @@ export const UpdateTransactionWebhookInputSchema = z.object({
73
73
  providerTransactionId: z.string(),
74
74
  });
75
75
 
76
+ // ==========================================
77
+ // ENTITY & OUTPUT SCHEMAS
78
+ // ==========================================
79
+
76
80
  export const TransactionEntitySchema = BaseTransactionSchema.extend({
77
81
  productTitle: z.string().optional(),
78
82
  sellerName: z.string().optional(),
79
83
  sellerId: z.string().optional(),
80
84
  sellerUsername: z.string().optional(),
85
+ buyerName: z.string().optional(),
86
+ buyerUsername: z.string().optional(),
87
+ buyerEmail: z.email(),
81
88
  }).openapi({ title: "TransactionEntity" });
82
89
 
83
- export type TransactionDiscountSnapshot = z.infer<
84
- typeof TransactionDiscountSnapshotSchema
85
- >;
90
+ export const InitTransactionOutputSchema = z
91
+ .object({
92
+ transaction: TransactionEntitySchema,
93
+ checkoutUrl: z.url().nullable().openapi({
94
+ description: "The Stripe/Paystack checkout URL to redirect the user to",
95
+ }),
96
+ })
97
+ .openapi({ title: "InitTransactionResult" });
98
+
99
+ // ==========================================
100
+ // TYPES EXPORTS
101
+ // ==========================================
86
102
 
87
103
  export type BaseTransactionEntity = z.infer<typeof BaseTransactionSchema>;
88
104
 
@@ -95,3 +111,4 @@ export type UpdateTransactionWebhookInput = z.infer<
95
111
  >;
96
112
 
97
113
  export type TransactionEntity = z.infer<typeof TransactionEntitySchema>;
114
+ export type InitTransactionResult = z.infer<typeof InitTransactionOutputSchema>;