@jsdev_ninja/core 0.11.0 → 0.11.2

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.
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { ProfileSchema } from "./Profile";
3
- import { ProductSchema } from "./Product";
4
3
  import { notEmptyTextSchema } from "./Atoms";
4
+ import { CartItemProductSchema } from "./Cart";
5
5
  // pending - order created / by user
6
6
  // processing order accepted by store by admin
7
7
  // delivered - order delivered by admin
@@ -27,7 +27,7 @@ export const OrderSchema = z.object({
27
27
  paymentStatus: z.enum(["pending", "pending_j5", "completed", "failed", "refunded"]), //todo check if hyp support partial refund
28
28
  cart: z.object({
29
29
  id: z.string(),
30
- items: z.array(z.object({ product: ProductSchema, amount: z.number() })),
30
+ items: z.array(CartItemProductSchema),
31
31
  cartDiscount: z.number(),
32
32
  cartTotal: z.number(),
33
33
  cartVat: z.number(),
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./entities";
2
+ export * from "./utils";
2
3
  export { FirebaseAPI } from "./firebase-api";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.tsx"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./entities";
2
+ export * from "./utils";
2
3
  export { FirebaseAPI } from "./firebase-api";
@@ -1,6 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import { ProductSchema } from "./Product";
3
3
 
4
+ export const CartItemProductSchema = z.object({
5
+ product: ProductSchema,
6
+ originalPrice: z.number().optional(),
7
+ finalPrice: z.number().optional(),
8
+ finalDiscount: z.number().optional(),
9
+ amount: z.number().int().positive({ message: "Quantity must be a positive integer." }),
10
+ });
11
+
12
+ export type TCartItemProduct = z.infer<typeof CartItemProductSchema>;
13
+
4
14
  export const CartSchema = z.object({
5
15
  type: z.literal("Cart"),
6
16
  id: z.string().uuid(),
@@ -8,12 +18,7 @@ export const CartSchema = z.object({
8
18
  storeId: z.string().uuid(),
9
19
  userId: z.string().uuid(),
10
20
  status: z.enum(["active", "draft", "completed"]),
11
- items: z.array(
12
- z.object({
13
- product: ProductSchema,
14
- amount: z.number().int().positive({ message: "Quantity must be a positive integer." }),
15
- })
16
- ),
21
+ items: z.array(CartItemProductSchema),
17
22
  });
18
23
 
19
24
  export type TCart = z.infer<typeof CartSchema>;
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { ProfileSchema } from "./Profile";
3
3
  import { ProductSchema } from "./Product";
4
4
  import { notEmptyTextSchema } from "./Atoms";
5
+ import { CartItemProductSchema } from "./Cart";
5
6
 
6
7
  // pending - order created / by user
7
8
  // processing order accepted by store by admin
@@ -30,7 +31,7 @@ export const OrderSchema = z.object({
30
31
  paymentStatus: z.enum(["pending", "pending_j5", "completed", "failed", "refunded"]), //todo check if hyp support partial refund
31
32
  cart: z.object({
32
33
  id: z.string(),
33
- items: z.array(z.object({ product: ProductSchema, amount: z.number() })),
34
+ items: z.array(CartItemProductSchema),
34
35
  cartDiscount: z.number(),
35
36
  cartTotal: z.number(),
36
37
  cartVat: z.number(),
package/lib/index.tsx CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./entities";
2
+ export * from "./utils";
2
3
  export { FirebaseAPI } from "./firebase-api";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsdev_ninja/core",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "main": "dist/core.cjs.js",
5
5
  "module": "dist/core.es.js",
6
6
  "types": "dist/index.d.ts",