feeef 0.0.27 → 0.1.1
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/LICENSE.md +9 -0
- package/README.md +50 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +647 -0
- package/build/index.js.map +1 -0
- package/build/src/core/embadded/address.d.ts +13 -0
- package/build/src/core/embadded/category.d.ts +7 -0
- package/build/src/core/embadded/contact.d.ts +22 -0
- package/build/src/core/entities/order.d.ts +76 -0
- package/build/src/core/entities/product.d.ts +71 -0
- package/build/src/core/entities/shipping_method.d.ts +29 -0
- package/build/src/core/entities/store.d.ts +125 -0
- package/build/src/core/entities/user.d.ts +28 -0
- package/build/src/feeef/feeef.d.ts +66 -0
- package/build/src/feeef/repositories/orders.d.ts +35 -0
- package/build/src/feeef/repositories/products.d.ts +15 -0
- package/build/src/feeef/repositories/repository.d.ts +112 -0
- package/build/src/feeef/repositories/stores.d.ts +21 -0
- package/build/src/feeef/repositories/users.d.ts +51 -0
- package/build/src/feeef/validators/auth.d.ts +76 -0
- package/build/src/feeef/validators/custom/datetime.d.ts +1 -0
- package/build/src/feeef/validators/helpers.d.ts +148 -0
- package/build/src/feeef/validators/order.d.ts +366 -0
- package/build/src/feeef/validators/product.d.ts +595 -0
- package/build/src/feeef/validators/shipping_method.d.ts +112 -0
- package/build/src/feeef/validators/stores.d.ts +590 -0
- package/build/src/feeef/validators/user_stores.d.ts +623 -0
- package/build/src/feeef/validators/users.d.ts +98 -0
- package/build/src/index.d.ts +10 -0
- package/package.json +114 -18
- package/.eslintrc.cjs +0 -19
- package/src/core/core.ts +0 -12
- package/src/core/embadded/address.ts +0 -13
- package/src/core/embadded/category.ts +0 -7
- package/src/core/embadded/contact.ts +0 -25
- package/src/core/entities/order.ts +0 -79
- package/src/core/entities/product.ts +0 -108
- package/src/core/entities/shipping_method.ts +0 -32
- package/src/core/entities/store.ts +0 -155
- package/src/core/entities/user.ts +0 -30
- package/src/feeef/feeef.ts +0 -110
- package/src/feeef/repositories/orders.ts +0 -37
- package/src/feeef/repositories/products.ts +0 -25
- package/src/feeef/repositories/repository.ts +0 -175
- package/src/feeef/repositories/stores.ts +0 -39
- package/src/feeef/repositories/users.ts +0 -92
- package/src/feeef/validators/auth.ts +0 -50
- package/src/feeef/validators/custom/datetime.ts +0 -9
- package/src/feeef/validators/helpers.ts +0 -69
- package/src/feeef/validators/order.ts +0 -89
- package/src/feeef/validators/product.ts +0 -95
- package/src/feeef/validators/shipping_method.ts +0 -44
- package/src/feeef/validators/stores.ts +0 -101
- package/src/feeef/validators/user_stores.ts +0 -85
- package/src/feeef/validators/users.ts +0 -69
- package/src/index.ts +0 -2
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -24
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -6
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,9 +0,0 @@
|
|
|
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)
|
|
@@ -1,69 +0,0 @@
|
|
|
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
|
-
// StoreBunner
|
|
64
|
-
export const StoreBunner = vine.object({
|
|
65
|
-
url: vine.string().url().optional(),
|
|
66
|
-
title: vine.string(),
|
|
67
|
-
enabled: vine.boolean().optional(),
|
|
68
|
-
metadata: vine.object({}).optional(),
|
|
69
|
-
})
|
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import vine from '@vinejs/vine'
|
|
2
|
-
import {
|
|
3
|
-
AvatarFileSchema,
|
|
4
|
-
EmbaddedContactSchema,
|
|
5
|
-
DomainSchema,
|
|
6
|
-
EmbaddedAddressSchema,
|
|
7
|
-
EmbaddedCategorySchema,
|
|
8
|
-
StoreDecorationSchema,
|
|
9
|
-
} from './helpers.js'
|
|
10
|
-
import { DefaultShippingRatesSchema } from './user_stores.js'
|
|
11
|
-
|
|
12
|
-
export const CreateStoreSchema = vine.object({
|
|
13
|
-
name: vine.string().minLength(2).maxLength(32),
|
|
14
|
-
slug: vine
|
|
15
|
-
.string()
|
|
16
|
-
.regex(/^[a-z0-9-]+$/)
|
|
17
|
-
.minLength(2)
|
|
18
|
-
.maxLength(32),
|
|
19
|
-
// .unique(async (db, value, field) => {
|
|
20
|
-
// const store = await db.from('stores').where('slug', value).first()
|
|
21
|
-
// return !store
|
|
22
|
-
// })
|
|
23
|
-
domain: vine
|
|
24
|
-
.object({
|
|
25
|
-
name: vine.string().minLength(2).maxLength(32),
|
|
26
|
-
verifiedAt: vine.date().optional(),
|
|
27
|
-
metadata: vine.object({}).optional(),
|
|
28
|
-
})
|
|
29
|
-
.optional(),
|
|
30
|
-
decoration: StoreDecorationSchema.optional(),
|
|
31
|
-
logoUrl: vine.string().optional(),
|
|
32
|
-
ondarkLogoUrl: vine.string().optional(),
|
|
33
|
-
logoFile: AvatarFileSchema.optional(),
|
|
34
|
-
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
35
|
-
userId: vine.string(),
|
|
36
|
-
// .exists(async (db, value, field) => {
|
|
37
|
-
// const user = await db.from('users').where('id', value).first()
|
|
38
|
-
// return !!user
|
|
39
|
-
// })
|
|
40
|
-
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
41
|
-
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
42
|
-
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
43
|
-
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
44
|
-
metadata: vine.object({}).optional(),
|
|
45
|
-
contacts: vine
|
|
46
|
-
.array(
|
|
47
|
-
vine.object({
|
|
48
|
-
type: vine.string().minLength(2).maxLength(32),
|
|
49
|
-
value: vine.string().minLength(2).maxLength(255),
|
|
50
|
-
metadata: vine.object({}).optional(),
|
|
51
|
-
})
|
|
52
|
-
)
|
|
53
|
-
.optional(),
|
|
54
|
-
shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
|
|
55
|
-
verifiedAt: vine.date().optional(),
|
|
56
|
-
blockedAt: vine.date().optional(),
|
|
57
|
-
integrations: vine.array(vine.any()).optional(),
|
|
58
|
-
// default_shipping_rates
|
|
59
|
-
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
// UpdateStoreSchema
|
|
63
|
-
export const UpdateStoreSchema = vine.object({
|
|
64
|
-
name: vine.string().minLength(2).maxLength(32).optional(),
|
|
65
|
-
slug: vine
|
|
66
|
-
.string()
|
|
67
|
-
.regex(/^[a-z0-9-]+$/)
|
|
68
|
-
.minLength(2)
|
|
69
|
-
.maxLength(32)
|
|
70
|
-
// .unique(async (db, value, field) => {
|
|
71
|
-
// const store = await db.from('stores').where('slug', value).first()
|
|
72
|
-
// return !store
|
|
73
|
-
// })
|
|
74
|
-
.optional(),
|
|
75
|
-
domain: DomainSchema.optional(),
|
|
76
|
-
decoration: StoreDecorationSchema.optional(),
|
|
77
|
-
logoUrl: vine.string().optional(),
|
|
78
|
-
ondarkLogoUrl: vine.string().optional(),
|
|
79
|
-
logoFile: AvatarFileSchema.optional(),
|
|
80
|
-
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
81
|
-
userId: vine
|
|
82
|
-
.string()
|
|
83
|
-
// .exists(async (db, value, field) => {
|
|
84
|
-
// const user = await db.from('users').where('id', value).first()
|
|
85
|
-
// return !!user
|
|
86
|
-
// })
|
|
87
|
-
.optional(),
|
|
88
|
-
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
89
|
-
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
90
|
-
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
91
|
-
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
92
|
-
metadata: vine.object({}).optional(),
|
|
93
|
-
contacts: vine.array(EmbaddedContactSchema).optional(),
|
|
94
|
-
shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
|
|
95
|
-
verifiedAt: vine.date().optional(),
|
|
96
|
-
blockedAt: vine.date().optional(),
|
|
97
|
-
// integrations
|
|
98
|
-
integrations: vine.array(vine.any()).optional(),
|
|
99
|
-
// default_shipping_rates
|
|
100
|
-
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
101
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import vine from '@vinejs/vine'
|
|
2
|
-
import {
|
|
3
|
-
AvatarFileSchema,
|
|
4
|
-
EmbaddedContactSchema,
|
|
5
|
-
DomainSchema,
|
|
6
|
-
EmbaddedAddressSchema,
|
|
7
|
-
EmbaddedCategorySchema,
|
|
8
|
-
StoreBunner,
|
|
9
|
-
StoreDecorationSchema,
|
|
10
|
-
} from './helpers.js'
|
|
11
|
-
// "defaultShippingRates.1"
|
|
12
|
-
export const DefaultShippingRatesSchema = vine.array(
|
|
13
|
-
vine.array(vine.number().min(0).max(100000).nullable()).nullable()
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
export const CreateUserStoreSchema = vine.object({
|
|
17
|
-
name: vine.string().minLength(2).maxLength(32),
|
|
18
|
-
slug: vine
|
|
19
|
-
.string()
|
|
20
|
-
.regex(/^[a-z0-9-]+$/)
|
|
21
|
-
.minLength(2)
|
|
22
|
-
.maxLength(32),
|
|
23
|
-
// .unique(async (db, value, field) => {
|
|
24
|
-
// const store = await db.from('stores').where('slug', value).first()
|
|
25
|
-
// return !store
|
|
26
|
-
// })
|
|
27
|
-
domain: vine
|
|
28
|
-
.object({
|
|
29
|
-
name: vine.string().minLength(2).maxLength(32),
|
|
30
|
-
})
|
|
31
|
-
.optional(),
|
|
32
|
-
decoration: StoreDecorationSchema.optional(),
|
|
33
|
-
|
|
34
|
-
banner: StoreBunner.optional(),
|
|
35
|
-
logoUrl: vine.string().optional(),
|
|
36
|
-
ondarkLogoUrl: vine.string().optional(),
|
|
37
|
-
logoFile: AvatarFileSchema.optional(),
|
|
38
|
-
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
39
|
-
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
40
|
-
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
41
|
-
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
42
|
-
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
43
|
-
metadata: vine.object({}).optional(),
|
|
44
|
-
contacts: vine
|
|
45
|
-
.array(
|
|
46
|
-
vine.object({
|
|
47
|
-
type: vine.string().minLength(2).maxLength(32),
|
|
48
|
-
value: vine.string().minLength(2).maxLength(255),
|
|
49
|
-
metadata: vine.object({}).optional(),
|
|
50
|
-
})
|
|
51
|
-
)
|
|
52
|
-
.optional(),
|
|
53
|
-
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
54
|
-
integrations: vine.array(vine.any()).optional(),
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
// UpdateStoreSchema
|
|
58
|
-
export const UpdateUserStoreSchema = vine.object({
|
|
59
|
-
name: vine.string().minLength(2).maxLength(32).optional(),
|
|
60
|
-
slug: vine
|
|
61
|
-
.string()
|
|
62
|
-
.regex(/^[a-z0-9-]+$/)
|
|
63
|
-
.minLength(2)
|
|
64
|
-
.maxLength(32)
|
|
65
|
-
// .unique(async (db, value, field) => {
|
|
66
|
-
// const store = await db.from('stores').where('slug', value).first()
|
|
67
|
-
// return !store
|
|
68
|
-
// })
|
|
69
|
-
.optional(),
|
|
70
|
-
domain: DomainSchema.optional(),
|
|
71
|
-
decoration: StoreDecorationSchema.optional(),
|
|
72
|
-
banner: StoreBunner.optional(),
|
|
73
|
-
logoUrl: vine.string().nullable().optional(),
|
|
74
|
-
ondarkLogoUrl: vine.string().nullable().optional(),
|
|
75
|
-
logoFile: AvatarFileSchema.optional(),
|
|
76
|
-
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
77
|
-
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
78
|
-
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
79
|
-
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
80
|
-
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
81
|
-
metadata: vine.object({}).optional(),
|
|
82
|
-
contacts: vine.array(EmbaddedContactSchema).optional(),
|
|
83
|
-
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
84
|
-
integrations: vine.array(vine.any()).optional(),
|
|
85
|
-
})
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import vine from "@vinejs/vine";
|
|
2
|
-
|
|
3
|
-
// User Schemas
|
|
4
|
-
//CreateUserSchema
|
|
5
|
-
export const CreateUserSchema = vine.object({
|
|
6
|
-
name: vine.string().minLength(2).maxLength(32),
|
|
7
|
-
email: vine.string(),
|
|
8
|
-
// .unique(async (db, value, field) => {
|
|
9
|
-
// const user = await db.from('users').where('email', value).first()
|
|
10
|
-
// return !user
|
|
11
|
-
// }),
|
|
12
|
-
phone: vine
|
|
13
|
-
.string()
|
|
14
|
-
.regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/)
|
|
15
|
-
// .unique(async (db, value, field) => {
|
|
16
|
-
// const user = await db.from('users').where('phone', value).first()
|
|
17
|
-
// return !user
|
|
18
|
-
// })
|
|
19
|
-
.optional(),
|
|
20
|
-
password: vine.string().minLength(8).maxLength(32),
|
|
21
|
-
// for upload file
|
|
22
|
-
photoFile: vine.any(),
|
|
23
|
-
// .file({
|
|
24
|
-
// size: '1mb',
|
|
25
|
-
// extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
|
|
26
|
-
// })
|
|
27
|
-
// .optional(),
|
|
28
|
-
photoUrl: vine.string().optional(),
|
|
29
|
-
// metadata (any object)
|
|
30
|
-
metadata: vine.object({}).optional(),
|
|
31
|
-
// dates
|
|
32
|
-
emailVerifiedAt: vine.date().optional(),
|
|
33
|
-
phoneVerifiedAt: vine.date().optional(),
|
|
34
|
-
verifiedAt: vine.date().optional(),
|
|
35
|
-
blockedAt: vine.date().optional(),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
//UpdateUserSchema
|
|
39
|
-
export const UpdateUserSchema = vine.object({
|
|
40
|
-
name: vine.string().minLength(2).maxLength(32).optional(),
|
|
41
|
-
email: vine
|
|
42
|
-
.string()
|
|
43
|
-
// .unique(async (db, value, field) => {
|
|
44
|
-
// const user = await db.from('users').where('email', value).first()
|
|
45
|
-
// return !user
|
|
46
|
-
// })
|
|
47
|
-
.optional(),
|
|
48
|
-
phone: vine
|
|
49
|
-
.string()
|
|
50
|
-
// must start with 0 then if secend is (5|6|7) then 8 digits and if secend is (2) then 7 digits
|
|
51
|
-
.regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/)
|
|
52
|
-
.optional(),
|
|
53
|
-
password: vine.string().minLength(8).maxLength(32).confirmed().optional(),
|
|
54
|
-
// for upload file
|
|
55
|
-
photoFile: vine
|
|
56
|
-
// .file({
|
|
57
|
-
// size: '1mb',
|
|
58
|
-
// extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
|
|
59
|
-
// })
|
|
60
|
-
.any(),
|
|
61
|
-
photoUrl: vine.string().optional(),
|
|
62
|
-
// metadata (any object)
|
|
63
|
-
metadata: vine.object({}).optional(),
|
|
64
|
-
// dates
|
|
65
|
-
emailVerifiedAt: vine.date().optional(),
|
|
66
|
-
phoneVerifiedAt: vine.date().optional(),
|
|
67
|
-
verifiedAt: vine.string().optional(),
|
|
68
|
-
blockedAt: vine.date().optional(),
|
|
69
|
-
});
|
package/src/index.ts
DELETED
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "bundler",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
|
|
16
|
-
/* Linting */
|
|
17
|
-
"strict": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true
|
|
21
|
-
},
|
|
22
|
-
"include": ["src"],
|
|
23
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
24
|
-
}
|
package/tsconfig.node.json
DELETED