@jsdev_ninja/core 0.5.66 → 0.6.0

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,15 +1,13 @@
1
1
  import { z } from "zod";
2
2
 
3
- // 6. Address Schema
4
3
  export const AddressSchema = z.object({
5
- id: z.string().uuid(),
6
- userId: z.string().uuid(), // Reference to User ID
7
- street: z.string().min(1, { message: "Street is required." }),
8
- city: z.string().min(1, { message: "City is required." }),
9
- state: z.string().min(1, { message: "State is required." }),
10
- country: z.string().min(1, { message: "Country is required." }),
11
- zipCode: z.string().min(1, { message: "Zip code is required." }),
12
- isDefault: z.boolean().default(false),
13
- createdAt: z.date().default(new Date()),
14
- updatedAt: z.date().optional(),
4
+ country: z.string(),
5
+ city: z.string(),
6
+ street: z.string(),
7
+ streetNumber: z.string(),
8
+ floor: z.string(),
9
+ apartmentEnterNumber: z.string(),
10
+ apartmentNumber: z.string(),
15
11
  });
12
+
13
+ export type TAddress = z.infer<typeof AddressSchema>;
@@ -1,15 +1,35 @@
1
1
  import { z } from "zod";
2
+ import { ProductSchema } from "@jsdev_ninja/core";
3
+ import { AddressSchema } from "./Address";
4
+
5
+ // pending - order created / by user
6
+ // processing order accepted by store by admin
7
+ // delivered - order delivered by admin
8
+ // canceled - order canceled by user/admin
9
+ // completed - order paid by admin
10
+
11
+ // type PaymentStatus = "pending" | "completed" | "failed" | "refunded" | "partially_refunded";
12
+
13
+ // type PaymentMethod = "credit_card" | "paypal" | "bank_transfer" | "cash_on_delivery";
2
14
 
3
- // 4. Order Schema
4
15
  export const OrderSchema = z.object({
5
- id: z.string().uuid(),
6
- userId: z.string().uuid(), // Reference to User ID
7
- productIds: z.array(z.string().uuid()), // References to Product IDs
8
- totalAmount: z.number().positive({ message: "Total amount must be a positive number." }),
9
- status: z
10
- .enum(["pending", "processing", "shipped", "delivered", "cancelled"])
11
- .default("pending"),
12
- paymentId: z.string().uuid().optional(), // Reference to Payment ID
13
- createdAt: z.date().default(new Date()),
14
- updatedAt: z.date().optional(),
16
+ type: z.literal("Order"),
17
+ id: z.string(),
18
+ companyId: z.string(),
19
+ storeId: z.string(),
20
+ userId: z.string(),
21
+ status: z.enum(["pending", "processing", "delivered", "canceled", "completed", "refunded"]),
22
+ cart: z.object({
23
+ id: z.string(),
24
+ items: z.array(z.object({ product: ProductSchema, amount: z.number() })),
25
+ cartTotal: z.number(),
26
+ cartDiscount: z.number(),
27
+ cartVat: z.number(),
28
+ }),
29
+ date: z.number(),
30
+ deliveryDate: z.number().optional(),
31
+ client: ProfileSchema,
32
+ address: AddressSchema,
15
33
  });
34
+
35
+ export type TOrder = z.infer<typeof OrderSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import { AddressSchema } from "./Address";
3
+
4
+ export const ProfileSchema = z.object({
5
+ type: z.literal("Profile"),
6
+ id: z.string(),
7
+ companyId: z.string(),
8
+ storeId: z.string(),
9
+ tenantId: z.string(),
10
+ clientType: z.enum(["user", "company"]),
11
+ displayName: z.string().min(1),
12
+ email: z.string().email(),
13
+ phoneNumber: z.object({
14
+ code: z.string(),
15
+ number: z.string(),
16
+ }),
17
+ address: AddressSchema,
18
+ });
19
+ export type TProfile = z.infer<typeof ProfileSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsdev_ninja/core",
3
- "version": "0.5.66",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "main": "dist/core.cjs.js",
6
6
  "module": "dist/core.es.js",
package/vite.config.ts CHANGED
@@ -2,7 +2,6 @@ import { defineConfig } from "vite";
2
2
  import react from "@vitejs/plugin-react-swc";
3
3
  import { resolve } from "path";
4
4
 
5
- // https://vitejs.dev/config/
6
5
  export default defineConfig({
7
6
  plugins: [react()],
8
7
 
@@ -1 +0,0 @@
1
- export const appApi = {};