feeef 0.0.9 → 0.0.12

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.
@@ -0,0 +1,175 @@
1
+ import { AxiosInstance } from "axios";
2
+
3
+ /**
4
+ * Represents a generic model repository.
5
+ * @template T - The type of the model.
6
+ * @template C - The type of the create options.
7
+ * @template U - The type of the update options.
8
+ */
9
+ export abstract class ModelRepository<T, C, U> {
10
+ resource: string;
11
+ // client
12
+ client: AxiosInstance;
13
+
14
+ /**
15
+ * Constructs a new instance of the ModelRepository class.
16
+ * @param resource - The resource name.
17
+ * @param client - The Axios instance used for making HTTP requests.
18
+ */
19
+ constructor(resource: string, client: AxiosInstance) {
20
+ this.resource = resource;
21
+ this.client = client;
22
+ }
23
+
24
+ /**
25
+ * Finds a model by its ID or other criteria.
26
+ * @param options - The options for finding the model.
27
+ * @returns A promise that resolves to the found model.
28
+ */
29
+ async find(options: ModelFindOptions): Promise<T> {
30
+ const { id, by, params } = options;
31
+ const res = await this.client.get(`/${this.resource}/${id}`, {
32
+ params: {
33
+ by: by || "id",
34
+ ...params,
35
+ },
36
+ });
37
+ return res.data;
38
+ }
39
+
40
+ /**
41
+ * Lists models with optional pagination and filtering.
42
+ * @param options - The options for listing the models.
43
+ * @returns A promise that resolves to a list of models.
44
+ */
45
+ async list(options?: ModelListOptions): Promise<ListResponse<T>> {
46
+ const { page, offset, limit, params } = options || {};
47
+ const res = await this.client.get(`/${this.resource}`, {
48
+ params: { page, offset, limit, ...params },
49
+ });
50
+ // if res.data is an array then create ListResponse
51
+ if (Array.isArray(res.data)) {
52
+ return {
53
+ data: res.data,
54
+ };
55
+ } else {
56
+ return {
57
+ data: res.data.data,
58
+ total: res.data.meta.total,
59
+ page: res.data.meta.currentPage,
60
+ limit: res.data.meta.perPage,
61
+ };
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Creates a new model.
67
+ * @param options - The options for creating the model.
68
+ * @returns A promise that resolves to the created model.
69
+ */
70
+ async create(options: ModelCreateOptions<C>): Promise<T> {
71
+ const { data, params } = options;
72
+ const res = await this.client.post(`/${this.resource}`, data, { params });
73
+ return res.data;
74
+ }
75
+
76
+ /**
77
+ * Updates an existing model.
78
+ * @param options - The options for updating the model.
79
+ * @returns A promise that resolves to the updated model.
80
+ */
81
+ async update(options: ModelUpdateOptions<U>): Promise<T> {
82
+ const { id, data, params } = options;
83
+ const res = await this.client.put(`/${this.resource}/${id}`, data, {
84
+ params,
85
+ });
86
+ return res.data;
87
+ }
88
+
89
+ /**
90
+ * Deletes a model by its ID or other criteria.
91
+ * @param options - The options for deleting the model.
92
+ * @returns A promise that resolves when the model is deleted.
93
+ */
94
+ async delete(options: ModelFindOptions): Promise<void> {
95
+ const { id, by, params } = options;
96
+ await this.client.delete(`/${this.resource}/${id}`, {
97
+ params: {
98
+ by: by || "id",
99
+ ...params,
100
+ },
101
+ });
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Represents a list response containing an array of data of type T.
107
+ */
108
+ export interface ListResponse<T> {
109
+ data: T[];
110
+ total?: number;
111
+ page?: number;
112
+ limit?: number;
113
+ }
114
+
115
+ /**
116
+ * Represents the options for making a request.
117
+ */
118
+ interface RequestOptions {
119
+ params?: Record<string, any>;
120
+ }
121
+
122
+ export interface ModelFindOptions extends RequestOptions {
123
+ /**
124
+ * The ID of the model to find or the value to find by.
125
+ */
126
+ id: string;
127
+ /**
128
+ * The field to find by.
129
+ * @default "id" - The ID field.
130
+ */
131
+ by?: string;
132
+ }
133
+
134
+ /**
135
+ * Options for listing models.
136
+ */
137
+ export interface ModelListOptions extends RequestOptions {
138
+ /**
139
+ * The page number to retrieve.
140
+ */
141
+ page?: number;
142
+
143
+ /**
144
+ * The offset from the beginning of the list.
145
+ */
146
+ offset?: number;
147
+
148
+ /**
149
+ * The maximum number of models to retrieve per page.
150
+ */
151
+ limit?: number;
152
+ }
153
+
154
+ /**
155
+ * Represents the options for creating a model.
156
+ * @template T - The type of data being created.
157
+ */
158
+ export interface ModelCreateOptions<T> extends RequestOptions {
159
+ data: T;
160
+ }
161
+
162
+ /**
163
+ * Represents the options for updating a model.
164
+ * @template T - The type of the data being updated.
165
+ */
166
+ export interface ModelUpdateOptions<T> extends RequestOptions {
167
+ /**
168
+ * The ID of the model to update.
169
+ */
170
+ id: string;
171
+ /**
172
+ * The data to update the model with.
173
+ */
174
+ data: T;
175
+ }
@@ -0,0 +1,39 @@
1
+ import vine from "@vinejs/vine";
2
+ import { InferInput } from "@vinejs/vine/types";
3
+ import { AxiosInstance } from "axios";
4
+ import { StoreEntity } from "../../core/core";
5
+ import {
6
+ CreateUserStoreSchema,
7
+ UpdateUserStoreSchema,
8
+ } from "../validators/user_stores";
9
+ import { ModelRepository, ModelCreateOptions } from "./repository";
10
+
11
+ /**
12
+ * Repository for managing Store entities.
13
+ */
14
+ export class StoreRepository extends ModelRepository<
15
+ StoreEntity,
16
+ InferInput<typeof CreateUserStoreSchema>,
17
+ InferInput<typeof UpdateUserStoreSchema>
18
+ > {
19
+ /**
20
+ * Constructs a new StoreRepository instance.
21
+ * @param client The AxiosInstance used for making HTTP requests.
22
+ */
23
+ constructor(client: AxiosInstance) {
24
+ super("stores", client);
25
+ }
26
+
27
+ /**
28
+ * Creates a new Store entity.
29
+ * @param options The options for creating the Store entity.
30
+ * @returns A Promise that resolves to the created Store entity.
31
+ */
32
+ async create(
33
+ options: ModelCreateOptions<InferInput<typeof CreateUserStoreSchema>>
34
+ ): Promise<StoreEntity> {
35
+ const validator = vine.compile(CreateUserStoreSchema);
36
+ const output = await validator.validate(options.data);
37
+ return super.create({ ...options, data: output });
38
+ }
39
+ }
@@ -0,0 +1,92 @@
1
+ import vine from "@vinejs/vine";
2
+ import { InferInput } from "@vinejs/vine/types";
3
+ import { AxiosInstance } from "axios";
4
+ import { AuthToken, UserEntity } from "../../core/core";
5
+ import { SigninSchema, AuthUpdateUserSchema } from "../validators/auth";
6
+ import { CreateUserSchema, UpdateUserSchema } from "../validators/users";
7
+ import { ModelRepository } from "./repository";
8
+
9
+ /**
10
+ * Represents the response returned by the authentication process.
11
+ */
12
+ export interface AuthResponse {
13
+ token: AuthToken;
14
+ user: UserEntity;
15
+ }
16
+
17
+ /**
18
+ * Represents a repository for managing user data.
19
+ * Extends the ModelRepository class.
20
+ */
21
+ export class UserRepository extends ModelRepository<
22
+ UserEntity,
23
+ InferInput<typeof CreateUserSchema>,
24
+ InferInput<typeof UpdateUserSchema>
25
+ > {
26
+ /**
27
+ * Represents the authentication response.
28
+ */
29
+ auth: AuthResponse | null = null;
30
+
31
+ /**
32
+ * Constructs a new UserRepository instance.
33
+ * @param client - The AxiosInstance used for making HTTP requests.
34
+ */
35
+ constructor(client: AxiosInstance) {
36
+ super("users", client);
37
+ }
38
+
39
+ /**
40
+ * Signs in a user with the provided credentials.
41
+ * @param credentials - The user credentials.
42
+ * @returns A promise that resolves to the authentication response.
43
+ */
44
+ async signin(
45
+ credentials: InferInput<typeof SigninSchema>
46
+ ): Promise<AuthResponse> {
47
+ // validate the input
48
+ const validator = vine.compile(SigninSchema);
49
+ const output = await validator.validate(credentials);
50
+ const res = await this.client.post(`/${this.resource}/auth/signin`, output);
51
+ this.auth = res.data;
52
+ return res.data;
53
+ }
54
+
55
+ /**
56
+ * Signs up a new user with the provided credentials.
57
+ * @param credentials - The user credentials.
58
+ * @returns A promise that resolves to the authentication response.
59
+ */
60
+ async signup(
61
+ credentials: InferInput<typeof CreateUserSchema>
62
+ ): Promise<AuthResponse> {
63
+ // validate the input
64
+ const validator = vine.compile(CreateUserSchema);
65
+ const output = await validator.validate(credentials);
66
+ const res = await this.client.post(`/${this.resource}/auth/signup`, output);
67
+ this.auth = res.data;
68
+ return res.data;
69
+ }
70
+
71
+ /**
72
+ * Signs out the currently authenticated user.
73
+ * @returns A promise that resolves when the user is signed out.
74
+ */
75
+ async signout(): Promise<void> {
76
+ this.auth = null;
77
+ }
78
+
79
+ /**
80
+ * Updates the authenticated user's data.
81
+ * @param data - The updated user data.
82
+ * @returns A promise that resolves to the updated user entity.
83
+ */
84
+ async updateMe(
85
+ data: InferInput<typeof AuthUpdateUserSchema>
86
+ ): Promise<UserEntity> {
87
+ const validator = vine.compile(AuthUpdateUserSchema);
88
+ const output = await validator.validate(data);
89
+ const res = await this.client.put(`/${this.resource}/auth`, output);
90
+ return res.data;
91
+ }
92
+ }
@@ -0,0 +1,50 @@
1
+ import vine from '@vinejs/vine'
2
+ import { ImageFileSchema } from './helpers.js'
3
+
4
+ export const PhoneShema = vine.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/)
5
+
6
+ export const SignupSchema = vine.object({
7
+ name: vine.string().minLength(2).maxLength(32),
8
+ email: vine.string()
9
+ // .unique(async (db, value, field) => {
10
+ // const user = await db.from('users').where('email', value).first()
11
+ // return !user
12
+ // })
13
+ ,
14
+ phone: PhoneShema
15
+ // .unique(async (db, value, field) => {
16
+ // const user = await db.from('users').where('phone', value).first()
17
+ // return !user
18
+ // })
19
+ .optional(),
20
+ photoFile: ImageFileSchema.optional(),
21
+ photoUrl: vine.string().optional(),
22
+ password: vine.string().minLength(8).maxLength(32),
23
+ })
24
+
25
+ export const SigninSchema = vine.object({
26
+ email: vine.string().email(),
27
+ password: vine.string().minLength(8).maxLength(32),
28
+ })
29
+
30
+ export const AuthUpdateUserSchema = vine.object({
31
+ name: vine.string().minLength(2).maxLength(32).optional(),
32
+ email: vine
33
+ .string()
34
+ // .unique(async (db, value, field) => {
35
+ // const user = await db.from('users').where('email', value).first()
36
+ // return !user
37
+ // })
38
+ .optional(),
39
+ phone: PhoneShema.optional(),
40
+ // for upload file
41
+ photoFile: vine
42
+ // .file({
43
+ // size: '1mb',
44
+ // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
45
+ // })
46
+ .any(),
47
+ photoUrl: vine.string().optional(),
48
+ oldPassword: vine.string().minLength(8).maxLength(32).optional(),
49
+ newPassword: vine.string().minLength(8).maxLength(32).notSameAs('oldPassword').optional(),
50
+ })
@@ -0,0 +1,9 @@
1
+ // import { FieldContext } from '@vinejs/compiler/types'
2
+ // import vine from '@vinejs/vine'
3
+
4
+ // type Options = {}
5
+
6
+ // // custom rule (datetime ISO 8601)
7
+ // async function datetime(value: unknown, options: Options, field: FieldContext) {}
8
+
9
+ // export const datetimeRule = vine.createRule(datetime)
@@ -0,0 +1,76 @@
1
+ import vine from "@vinejs/vine";
2
+
3
+ export const AvatarFileSchema = vine.any();
4
+ // .file({
5
+ // size: '1mb',
6
+ // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
7
+ // })
8
+
9
+ export const ImageFileSchema = vine.any();
10
+ // .file({
11
+ // size: '1mb',
12
+ // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
13
+ // })
14
+
15
+ export const DomainSchema = vine.object({
16
+ name: vine.string().minLength(3).maxLength(32),
17
+ verifiedAt: vine.date().optional(),
18
+ metadata: vine.object({}).optional(),
19
+ });
20
+
21
+ // decoration
22
+ export const StoreDecorationSchema = vine.object({
23
+ primary: vine.number().min(0x0).max(0xffffffff),
24
+ onPrimary: vine.number().min(0x0).max(0xffffffff),
25
+ showStoreLogoInHeader: vine.boolean().optional(),
26
+ logoFullHeight: vine.boolean().optional(),
27
+ showStoreNameInHeader: vine.boolean().optional(),
28
+ metadata: vine.any().optional(),
29
+ });
30
+
31
+ // export const EmbaddedImageSchema = vine.object({
32
+ // url: vine.string().url(),
33
+ // alt: vine.string().optional(),
34
+ // width: vine.number().optional(),
35
+ // height: vine.number().optional(),
36
+ // })
37
+
38
+ export const EmbaddedCategorySchema = vine.object({
39
+ name: vine.string().minLength(2).maxLength(32),
40
+ description: vine.string().minLength(2).maxLength(255).optional(),
41
+ photoUrl: vine.string().optional(),
42
+ ondarkPhotoUrl: vine.string().optional(),
43
+ photoFile: AvatarFileSchema.optional(),
44
+ ondarkPhotoFile: AvatarFileSchema.optional(),
45
+ metadata: vine.object({}).optional(),
46
+ });
47
+
48
+ export const EmbaddedAddressSchema = vine.object({
49
+ country: vine.string().minLength(2).maxLength(32).optional(),
50
+ state: vine.string().minLength(2).maxLength(32).optional(),
51
+ city: vine.string().minLength(2).maxLength(32).optional(),
52
+ street: vine.string().minLength(2).maxLength(32).optional(),
53
+ zip: vine.string().minLength(2).maxLength(32).optional(),
54
+ metadata: vine.object({}).optional().optional(),
55
+ });
56
+
57
+ export const EmbaddedContactSchema = vine.object({
58
+ type: vine.string().minLength(2).maxLength(32),
59
+ value: vine.string().minLength(2).maxLength(255),
60
+ metadata: vine.object({}).optional(),
61
+ });
62
+
63
+ export const ContactSchema = vine.object({
64
+ type: vine.string().minLength(2).maxLength(32),
65
+ value: vine.string().minLength(2).maxLength(255),
66
+ metadata: vine.object({}).optional(),
67
+ });
68
+
69
+
70
+ // StoreBunner
71
+ export const StoreBunnerSchema = vine.object({
72
+ url: vine.string().url().optional(),
73
+ title: vine.string(),
74
+ enabled: vine.boolean().optional(),
75
+ metadata: vine.object({}).optional(),
76
+ })
@@ -0,0 +1,89 @@
1
+ // import { OrderStatus } from '#core/core'
2
+ import vine from "@vinejs/vine";
3
+ import { PhoneShema } from "./auth.js";
4
+ import { OrderStatus } from "../../core/core.js";
5
+
6
+ export const OrderItemSchema = vine.object({
7
+ productId: vine.string(),
8
+ // productId: vine.string().exists(async (db, value, field) => {
9
+ // const product = await db.from('products').where('id', value).first()
10
+ // return !!product
11
+ // }),
12
+ productName: vine.string().optional(),
13
+ variant: vine.any().optional(),
14
+ quantity: vine.number(),
15
+ price: vine.number().optional(),
16
+ });
17
+
18
+ export const GuestOrderItemSchema = vine.object({
19
+ productId: vine.string(),
20
+ variantPath: vine.string().optional(),
21
+ quantity: vine.number(),
22
+ });
23
+
24
+ export const SendOrderSchema = vine.object({
25
+ id: vine.string().optional(),
26
+ customerName: vine.string().optional(),
27
+ customerPhone: vine.string(),
28
+ // customerIp: vine.string().optional(),
29
+ shippingAddress: vine.string().optional(),
30
+ shippingCity: vine.string().optional(),
31
+ shippingState: vine.string().optional(),
32
+ shippingMethodId: vine.string().optional(),
33
+ paymentMethodId: vine.string().optional(),
34
+ items: vine.array(GuestOrderItemSchema).minLength(1),
35
+ // subtotal: vine.number().optional(),
36
+ // shippingPrice: vine.number().optional(),
37
+ // total: vine.number().optional(),
38
+ // discount: vine.number().optional(),
39
+ coupon: vine.string().optional(),
40
+ status: vine.enum(["pending", "draft"]),
41
+ // TODO: validate storeId is exists and not blocked
42
+ storeId: vine.string(),
43
+ metadata: vine.any().optional(),
44
+ });
45
+
46
+ /// store owner section
47
+ // CreateOrderSchema
48
+ export const CreateOrderSchema = vine.object({
49
+ id: vine.string().optional(),
50
+ customerName: vine.string().optional(),
51
+ customerPhone: PhoneShema,
52
+ customerIp: vine.string().optional(),
53
+ shippingAddress: vine.string().optional(),
54
+ shippingCity: vine.string().optional(),
55
+ shippingState: vine.string().optional(),
56
+ shippingMethodId: vine.string().optional(),
57
+ paymentMethodId: vine.string().optional(),
58
+ items: vine.array(OrderItemSchema).minLength(1),
59
+ subtotal: vine.number().optional(),
60
+ shippingPrice: vine.number().optional(),
61
+ total: vine.number().optional(),
62
+ discount: vine.number().optional(),
63
+ coupon: vine.string().optional(),
64
+ status: vine.enum(OrderStatus),
65
+ storeId: vine.string(),
66
+ metadata: vine.any().optional(),
67
+ });
68
+
69
+ // UpdateOrderSchema
70
+ export const UpdateOrderSchema = vine.object({
71
+ id: vine.string().optional(),
72
+ customerName: vine.string().optional(),
73
+ customerPhone: PhoneShema.optional(),
74
+ customerIp: vine.string().optional(),
75
+ shippingAddress: vine.string().optional(),
76
+ shippingCity: vine.string().optional(),
77
+ shippingState: vine.string().optional(),
78
+ shippingMethodId: vine.string().optional(),
79
+ paymentMethodId: vine.string().optional(),
80
+ items: vine.array(OrderItemSchema).minLength(1).optional(),
81
+ subtotal: vine.number().optional(),
82
+ shippingPrice: vine.number().optional(),
83
+ total: vine.number().optional(),
84
+ discount: vine.number().optional(),
85
+ coupon: vine.string().optional(),
86
+ status: vine.enum(OrderStatus).optional(),
87
+ storeId: vine.string(),
88
+ metadata: vine.any().optional(),
89
+ });
@@ -0,0 +1,95 @@
1
+ // import { ProductStatus } from '#models/product'
2
+ import vine from "@vinejs/vine";
3
+ import { EmbaddedCategorySchema, ImageFileSchema } from "./helpers.js";
4
+ import { ProductStatus } from "../../core/core.js";
5
+ // import Store from '#models/store'
6
+
7
+ export const ProductVariantOptionSchema = vine.object({
8
+ name: vine.string().minLength(1).maxLength(32),
9
+ sku: vine.string().optional(),
10
+ price: vine.number().min(0).max(1000000).optional().nullable(),
11
+ discount: vine.number().min(0).max(1000000).optional().nullable(),
12
+ stock: vine.number().min(0).max(1000000).optional().nullable(),
13
+ sold: vine.number().min(0).max(1000000).optional().nullable(),
14
+ child: vine.any().optional().nullable(),
15
+ });
16
+
17
+ export const ProductVariantSchema = vine
18
+ .object({
19
+ name: vine.string().minLength(1).maxLength(32),
20
+ options: vine.array(ProductVariantOptionSchema),
21
+ })
22
+ .optional();
23
+ export const CreateProductSchema = vine.object({
24
+ slug: vine
25
+ .string()
26
+ .regex(/^[a-z0-9-]+$/)
27
+ .minLength(2)
28
+ .maxLength(32),
29
+ // .unique(async (db, value, field) => {
30
+ // const product = await db.from('products').where('slug', value).first()
31
+ // return !product
32
+ // }),
33
+ sku: vine.string().optional(),
34
+ decoration: vine.object({}).optional(),
35
+ name: vine.string().minLength(2).maxLength(32),
36
+ photoUrl: vine.string().optional(),
37
+ photoFile: ImageFileSchema.optional(),
38
+ media: vine.array(vine.string()).optional(),
39
+ mediaFiles: vine.array(ImageFileSchema).optional(),
40
+ // storeId must exist in the database
41
+ storeId: vine.string(),
42
+ // .exists(async (db, value, field) => {
43
+ // return !!field.meta.store && (field.meta.store as Store).userId === field.meta.userId
44
+ // }),
45
+ category: EmbaddedCategorySchema.optional(),
46
+ title: vine.string().minLength(2).maxLength(255),
47
+ description: vine.string().minLength(2).maxLength(255).optional(),
48
+ body: vine.string().minLength(2).maxLength(1000).optional(),
49
+ price: vine.number().min(0).max(1000000),
50
+ discount: vine.number().min(0).max(1000000).optional(),
51
+ stock: vine.number().min(0).max(1000000).optional(),
52
+ variant: ProductVariantSchema,
53
+ metadata: vine.object({}).optional(),
54
+ status: vine.enum(ProductStatus),
55
+ verifiedAt: vine.date().optional(),
56
+ blockedAt: vine.date().optional(),
57
+ });
58
+
59
+ export const UpdateProductSchema = vine.object({
60
+ slug: vine
61
+ .string()
62
+ .regex(/^[a-z0-9-]+$/)
63
+ .minLength(2)
64
+ .maxLength(32)
65
+ // .unique(async (db, value, field) => {
66
+ // const product = await db.from('products').where('slug', value).first()
67
+ // return !product
68
+ // })
69
+ .optional(),
70
+ sku: vine.string().optional(),
71
+ decoration: vine.object({}).optional(),
72
+ name: vine.string().minLength(2).maxLength(32).optional(),
73
+ photoUrl: vine.string().optional(),
74
+ photoFile: ImageFileSchema.optional(),
75
+ media: vine.array(vine.string()).optional(),
76
+ mediaFiles: vine.array(ImageFileSchema).optional(),
77
+ // storeId must exist in the database
78
+ storeId: vine.string(),
79
+ // .exists(async (db, value, field) => {
80
+ // return !!field.meta.store && (field.meta.store as Store).userId === field.meta.userId
81
+ // })
82
+ // .optional(),
83
+ category: EmbaddedCategorySchema.optional(),
84
+ title: vine.string().minLength(2).maxLength(255).optional(),
85
+ description: vine.string().minLength(2).maxLength(255).optional(),
86
+ body: vine.string().minLength(2).maxLength(1000).optional(),
87
+ price: vine.number().min(0).max(1000000).optional(),
88
+ discount: vine.number().min(0).max(1000000).optional(),
89
+ stock: vine.number().min(0).max(1000000).optional(),
90
+ variant: ProductVariantSchema,
91
+ metadata: vine.object({}).optional(),
92
+ status: vine.enum(ProductStatus).optional(),
93
+ verifiedAt: vine.date().optional(),
94
+ blockedAt: vine.date().optional(),
95
+ });
@@ -0,0 +1,44 @@
1
+ import vine from "@vinejs/vine";
2
+ import { ImageFileSchema } from "./helpers.js";
3
+ import { ShippingMethodPolicy, ShippingMethodStatus } from "../../core/core.js";
4
+ // import { ShippingMethodPolicy, ShippingMethodStatus } from '#models/shipping_method'
5
+
6
+ export const CreateShippingMethodSchema = vine.object({
7
+ name: vine.string(),
8
+ description: vine.string().optional(),
9
+ photoUrl: vine.string().optional(),
10
+ ondarkPhotoUrl: vine.string().optional(),
11
+ photoFile: ImageFileSchema.optional(),
12
+ ondarkPhotoFile: ImageFileSchema.optional(),
13
+ price: vine.number(),
14
+ // forks: vine.number(),
15
+ // sourceId: vine.string(),
16
+ storeId: vine.string(),
17
+ rates: vine.array(vine.number().optional()),
18
+ status: vine.enum(ShippingMethodStatus),
19
+ policy: vine.enum(ShippingMethodPolicy),
20
+ // verifiedAt: vine.date(),
21
+ });
22
+
23
+ export const UpdateShippingMethodSchema = vine.object({
24
+ name: vine.string().optional(),
25
+ description: vine.string().optional(),
26
+ photoUrl: vine.string().optional(),
27
+ ondarkPhotoUrl: vine.string().optional(),
28
+ photoFile: ImageFileSchema.optional(),
29
+ ondarkPhotoFile: ImageFileSchema.optional(),
30
+ price: vine.number().optional(),
31
+ // forks: vine.number().optional(),
32
+ // sourceId: vine.string().optional(),
33
+ storeId: vine.string().optional(),
34
+ rates: vine.array(vine.number().optional()).optional(),
35
+ status: vine.enum(ShippingMethodStatus).optional(),
36
+ policy: vine.enum(ShippingMethodPolicy).optional(),
37
+ // verifiedAt: vine.date().optional(),
38
+ });
39
+
40
+ // ForkShippingMethodSchema
41
+ export const ForkShippingMethodSchema = vine.object({
42
+ sourceId: vine.string(),
43
+ storeId: vine.string(),
44
+ });