feeef 0.0.10 → 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.
Files changed (76) hide show
  1. package/.eslintrc.cjs +19 -0
  2. package/package.json +4 -24
  3. package/src/core/core.ts +10 -0
  4. package/src/core/embadded/address.ts +13 -0
  5. package/src/core/embadded/category.ts +7 -0
  6. package/src/core/embadded/contact.ts +24 -0
  7. package/src/core/entities/order.ts +52 -0
  8. package/src/core/entities/product.ts +99 -0
  9. package/src/core/entities/shipping_method.ts +32 -0
  10. package/src/core/entities/store.ts +84 -0
  11. package/src/core/entities/user.ts +24 -0
  12. package/src/core/sdk/fif.ts +3 -0
  13. package/src/feeef/feeef.ts +99 -0
  14. package/src/feeef/repositories/orders.ts +37 -0
  15. package/src/feeef/repositories/products.ts +25 -0
  16. package/src/feeef/repositories/repository.ts +175 -0
  17. package/src/feeef/repositories/stores.ts +39 -0
  18. package/src/feeef/repositories/users.ts +92 -0
  19. package/src/feeef/validators/auth.ts +50 -0
  20. package/{build/src/feeef/validators/custom/datetime.js → src/feeef/validators/custom/datetime.ts} +3 -1
  21. package/src/feeef/validators/helpers.ts +76 -0
  22. package/src/feeef/validators/order.ts +89 -0
  23. package/src/feeef/validators/product.ts +95 -0
  24. package/src/feeef/validators/shipping_method.ts +44 -0
  25. package/src/feeef/validators/stores.ts +108 -0
  26. package/src/feeef/validators/user_stores.ts +89 -0
  27. package/src/feeef/validators/users.ts +69 -0
  28. package/src/index.ts +0 -0
  29. package/src/vite-env.d.ts +1 -0
  30. package/tsconfig.json +24 -0
  31. package/tsconfig.node.json +10 -0
  32. package/{build/vite.config.js → vite.config.ts} +2 -1
  33. package/build/index.d.ts +0 -1
  34. package/build/index.js +0 -1
  35. package/build/src/core/core.d.ts +0 -8
  36. package/build/src/core/core.js +0 -10
  37. package/build/src/core/embadded/address.d.ts +0 -13
  38. package/build/src/core/embadded/address.js +0 -1
  39. package/build/src/core/embadded/category.d.ts +0 -7
  40. package/build/src/core/embadded/category.js +0 -1
  41. package/build/src/core/embadded/contact.d.ts +0 -21
  42. package/build/src/core/embadded/contact.js +0 -17
  43. package/build/src/core/entities/order.d.ts +0 -49
  44. package/build/src/core/entities/order.js +0 -22
  45. package/build/src/core/entities/product.d.ts +0 -65
  46. package/build/src/core/entities/product.js +0 -19
  47. package/build/src/core/entities/shipping_method.d.ts +0 -29
  48. package/build/src/core/entities/shipping_method.js +0 -11
  49. package/build/src/core/entities/store.d.ts +0 -71
  50. package/build/src/core/entities/store.js +0 -15
  51. package/build/src/core/entities/user.d.ts +0 -23
  52. package/build/src/core/entities/user.js +0 -1
  53. package/build/src/core/sdk/fif.d.ts +0 -1
  54. package/build/src/core/sdk/fif.js +0 -4
  55. package/build/src/feeef/feeef.d.ts +0 -62
  56. package/build/src/feeef/feeef.js +0 -65
  57. package/build/src/feeef/repositories/orders.d.ts +0 -21
  58. package/build/src/feeef/repositories/orders.js +0 -27
  59. package/build/src/feeef/repositories/products.d.ts +0 -15
  60. package/build/src/feeef/repositories/products.js +0 -13
  61. package/build/src/feeef/repositories/repository.d.ts +0 -112
  62. package/build/src/feeef/repositories/repository.js +0 -96
  63. package/build/src/feeef/repositories/stores.d.ts +0 -22
  64. package/build/src/feeef/repositories/stores.js +0 -25
  65. package/build/src/feeef/repositories/users.d.ts +0 -51
  66. package/build/src/feeef/repositories/users.js +0 -65
  67. package/build/src/feeef/validators/auth.js +0 -46
  68. package/build/src/feeef/validators/custom/datetime.d.ts +0 -1
  69. package/build/src/feeef/validators/helpers.js +0 -65
  70. package/build/src/feeef/validators/order.js +0 -84
  71. package/build/src/feeef/validators/product.js +0 -92
  72. package/build/src/feeef/validators/shipping_method.js +0 -41
  73. package/build/src/feeef/validators/stores.js +0 -97
  74. package/build/src/feeef/validators/user_stores.js +0 -74
  75. package/build/src/feeef/validators/users.js +0 -67
  76. package/build/vite.config.d.ts +0 -2
@@ -1,65 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- import { SigninSchema, AuthUpdateUserSchema } from "../validators/auth";
3
- import { CreateUserSchema } from "../validators/users";
4
- import { ModelRepository } from "./repository";
5
- /**
6
- * Represents a repository for managing user data.
7
- * Extends the ModelRepository class.
8
- */
9
- export class UserRepository extends ModelRepository {
10
- /**
11
- * Represents the authentication response.
12
- */
13
- auth = null;
14
- /**
15
- * Constructs a new UserRepository instance.
16
- * @param client - The AxiosInstance used for making HTTP requests.
17
- */
18
- constructor(client) {
19
- super("users", client);
20
- }
21
- /**
22
- * Signs in a user with the provided credentials.
23
- * @param credentials - The user credentials.
24
- * @returns A promise that resolves to the authentication response.
25
- */
26
- async signin(credentials) {
27
- // validate the input
28
- const validator = vine.compile(SigninSchema);
29
- const output = await validator.validate(credentials);
30
- const res = await this.client.post(`/${this.resource}/auth/signin`, output);
31
- this.auth = res.data;
32
- return res.data;
33
- }
34
- /**
35
- * Signs up a new user with the provided credentials.
36
- * @param credentials - The user credentials.
37
- * @returns A promise that resolves to the authentication response.
38
- */
39
- async signup(credentials) {
40
- // validate the input
41
- const validator = vine.compile(CreateUserSchema);
42
- const output = await validator.validate(credentials);
43
- const res = await this.client.post(`/${this.resource}/auth/signup`, output);
44
- this.auth = res.data;
45
- return res.data;
46
- }
47
- /**
48
- * Signs out the currently authenticated user.
49
- * @returns A promise that resolves when the user is signed out.
50
- */
51
- async signout() {
52
- this.auth = null;
53
- }
54
- /**
55
- * Updates the authenticated user's data.
56
- * @param data - The updated user data.
57
- * @returns A promise that resolves to the updated user entity.
58
- */
59
- async updateMe(data) {
60
- const validator = vine.compile(AuthUpdateUserSchema);
61
- const output = await validator.validate(data);
62
- const res = await this.client.put(`/${this.resource}/auth`, output);
63
- return res.data;
64
- }
65
- }
@@ -1,46 +0,0 @@
1
- import vine from '@vinejs/vine';
2
- import { ImageFileSchema } from './helpers.js';
3
- export const PhoneShema = vine.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/);
4
- export const SignupSchema = vine.object({
5
- name: vine.string().minLength(2).maxLength(32),
6
- email: vine.string()
7
- // .unique(async (db, value, field) => {
8
- // const user = await db.from('users').where('email', value).first()
9
- // return !user
10
- // })
11
- ,
12
- phone: PhoneShema
13
- // .unique(async (db, value, field) => {
14
- // const user = await db.from('users').where('phone', value).first()
15
- // return !user
16
- // })
17
- .optional(),
18
- photoFile: ImageFileSchema.optional(),
19
- photoUrl: vine.string().optional(),
20
- password: vine.string().minLength(8).maxLength(32),
21
- });
22
- export const SigninSchema = vine.object({
23
- email: vine.string().email(),
24
- password: vine.string().minLength(8).maxLength(32),
25
- });
26
- export const AuthUpdateUserSchema = vine.object({
27
- name: vine.string().minLength(2).maxLength(32).optional(),
28
- email: vine
29
- .string()
30
- // .unique(async (db, value, field) => {
31
- // const user = await db.from('users').where('email', value).first()
32
- // return !user
33
- // })
34
- .optional(),
35
- phone: PhoneShema.optional(),
36
- // for upload file
37
- photoFile: vine
38
- // .file({
39
- // size: '1mb',
40
- // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
41
- // })
42
- .any(),
43
- photoUrl: vine.string().optional(),
44
- oldPassword: vine.string().minLength(8).maxLength(32).optional(),
45
- newPassword: vine.string().minLength(8).maxLength(32).notSameAs('oldPassword').optional(),
46
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,65 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- export const AvatarFileSchema = vine.any();
3
- // .file({
4
- // size: '1mb',
5
- // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
6
- // })
7
- export const ImageFileSchema = vine.any();
8
- // .file({
9
- // size: '1mb',
10
- // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
11
- // })
12
- export const DomainSchema = vine.object({
13
- name: vine.string().minLength(3).maxLength(32),
14
- verifiedAt: vine.date().optional(),
15
- metadata: vine.object({}).optional(),
16
- });
17
- // decoration
18
- export const StoreDecorationSchema = vine.object({
19
- primary: vine.number().min(0x0).max(0xffffffff),
20
- onPrimary: vine.number().min(0x0).max(0xffffffff),
21
- showStoreLogoInHeader: vine.boolean().optional(),
22
- logoFullHeight: vine.boolean().optional(),
23
- showStoreNameInHeader: vine.boolean().optional(),
24
- metadata: vine.any().optional(),
25
- });
26
- // export const EmbaddedImageSchema = vine.object({
27
- // url: vine.string().url(),
28
- // alt: vine.string().optional(),
29
- // width: vine.number().optional(),
30
- // height: vine.number().optional(),
31
- // })
32
- export const EmbaddedCategorySchema = vine.object({
33
- name: vine.string().minLength(2).maxLength(32),
34
- description: vine.string().minLength(2).maxLength(255).optional(),
35
- photoUrl: vine.string().optional(),
36
- ondarkPhotoUrl: vine.string().optional(),
37
- photoFile: AvatarFileSchema.optional(),
38
- ondarkPhotoFile: AvatarFileSchema.optional(),
39
- metadata: vine.object({}).optional(),
40
- });
41
- export const EmbaddedAddressSchema = vine.object({
42
- country: vine.string().minLength(2).maxLength(32).optional(),
43
- state: vine.string().minLength(2).maxLength(32).optional(),
44
- city: vine.string().minLength(2).maxLength(32).optional(),
45
- street: vine.string().minLength(2).maxLength(32).optional(),
46
- zip: vine.string().minLength(2).maxLength(32).optional(),
47
- metadata: vine.object({}).optional().optional(),
48
- });
49
- export const EmbaddedContactSchema = vine.object({
50
- type: vine.string().minLength(2).maxLength(32),
51
- value: vine.string().minLength(2).maxLength(255),
52
- metadata: vine.object({}).optional(),
53
- });
54
- export const ContactSchema = vine.object({
55
- type: vine.string().minLength(2).maxLength(32),
56
- value: vine.string().minLength(2).maxLength(255),
57
- metadata: vine.object({}).optional(),
58
- });
59
- // StoreBunner
60
- export const StoreBunner = vine.object({
61
- url: vine.string().url().optional(),
62
- title: vine.string(),
63
- enabled: vine.boolean().optional(),
64
- metadata: vine.object({}).optional(),
65
- });
@@ -1,84 +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
- export const OrderItemSchema = vine.object({
6
- productId: vine.string(),
7
- // productId: vine.string().exists(async (db, value, field) => {
8
- // const product = await db.from('products').where('id', value).first()
9
- // return !!product
10
- // }),
11
- productName: vine.string().optional(),
12
- variant: vine.any().optional(),
13
- quantity: vine.number(),
14
- price: vine.number().optional(),
15
- });
16
- export const GuestOrderItemSchema = vine.object({
17
- productId: vine.string(),
18
- variantPath: vine.string().optional(),
19
- quantity: vine.number(),
20
- });
21
- export const SendOrderSchema = vine.object({
22
- id: vine.string().optional(),
23
- customerName: vine.string().optional(),
24
- customerPhone: vine.string(),
25
- // customerIp: vine.string().optional(),
26
- shippingAddress: vine.string().optional(),
27
- shippingCity: vine.string().optional(),
28
- shippingState: vine.string().optional(),
29
- shippingMethodId: vine.string().optional(),
30
- paymentMethodId: vine.string().optional(),
31
- items: vine.array(GuestOrderItemSchema).minLength(1),
32
- // subtotal: vine.number().optional(),
33
- // shippingPrice: vine.number().optional(),
34
- // total: vine.number().optional(),
35
- // discount: vine.number().optional(),
36
- coupon: vine.string().optional(),
37
- status: vine.enum(["pending", "draft"]),
38
- // TODO: validate storeId is exists and not blocked
39
- storeId: vine.string(),
40
- metadata: vine.any().optional(),
41
- });
42
- /// store owner section
43
- // CreateOrderSchema
44
- export const CreateOrderSchema = vine.object({
45
- id: vine.string().optional(),
46
- customerName: vine.string().optional(),
47
- customerPhone: PhoneShema,
48
- customerIp: vine.string().optional(),
49
- shippingAddress: vine.string().optional(),
50
- shippingCity: vine.string().optional(),
51
- shippingState: vine.string().optional(),
52
- shippingMethodId: vine.string().optional(),
53
- paymentMethodId: vine.string().optional(),
54
- items: vine.array(OrderItemSchema).minLength(1),
55
- subtotal: vine.number().optional(),
56
- shippingPrice: vine.number().optional(),
57
- total: vine.number().optional(),
58
- discount: vine.number().optional(),
59
- coupon: vine.string().optional(),
60
- status: vine.enum(OrderStatus),
61
- storeId: vine.string(),
62
- metadata: vine.any().optional(),
63
- });
64
- // UpdateOrderSchema
65
- export const UpdateOrderSchema = vine.object({
66
- id: vine.string().optional(),
67
- customerName: vine.string().optional(),
68
- customerPhone: PhoneShema.optional(),
69
- customerIp: vine.string().optional(),
70
- shippingAddress: vine.string().optional(),
71
- shippingCity: vine.string().optional(),
72
- shippingState: vine.string().optional(),
73
- shippingMethodId: vine.string().optional(),
74
- paymentMethodId: vine.string().optional(),
75
- items: vine.array(OrderItemSchema).minLength(1).optional(),
76
- subtotal: vine.number().optional(),
77
- shippingPrice: vine.number().optional(),
78
- total: vine.number().optional(),
79
- discount: vine.number().optional(),
80
- coupon: vine.string().optional(),
81
- status: vine.enum(OrderStatus).optional(),
82
- storeId: vine.string(),
83
- metadata: vine.any().optional(),
84
- });
@@ -1,92 +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
- export const ProductVariantOptionSchema = vine.object({
7
- name: vine.string().minLength(1).maxLength(32),
8
- sku: vine.string().optional(),
9
- price: vine.number().min(0).max(1000000).optional().nullable(),
10
- discount: vine.number().min(0).max(1000000).optional().nullable(),
11
- stock: vine.number().min(0).max(1000000).optional().nullable(),
12
- sold: vine.number().min(0).max(1000000).optional().nullable(),
13
- child: vine.any().optional().nullable(),
14
- });
15
- export const ProductVariantSchema = vine
16
- .object({
17
- name: vine.string().minLength(1).maxLength(32),
18
- options: vine.array(ProductVariantOptionSchema),
19
- })
20
- .optional();
21
- export const CreateProductSchema = vine.object({
22
- slug: vine
23
- .string()
24
- .regex(/^[a-z0-9-]+$/)
25
- .minLength(2)
26
- .maxLength(32),
27
- // .unique(async (db, value, field) => {
28
- // const product = await db.from('products').where('slug', value).first()
29
- // return !product
30
- // }),
31
- sku: vine.string().optional(),
32
- decoration: vine.object({}).optional(),
33
- name: vine.string().minLength(2).maxLength(32),
34
- photoUrl: vine.string().optional(),
35
- photoFile: ImageFileSchema.optional(),
36
- media: vine.array(vine.string()).optional(),
37
- mediaFiles: vine.array(ImageFileSchema).optional(),
38
- // storeId must exist in the database
39
- storeId: vine.string(),
40
- // .exists(async (db, value, field) => {
41
- // return !!field.meta.store && (field.meta.store as Store).userId === field.meta.userId
42
- // }),
43
- category: EmbaddedCategorySchema.optional(),
44
- title: vine.string().minLength(2).maxLength(255),
45
- description: vine.string().minLength(2).maxLength(255).optional(),
46
- body: vine.string().minLength(2).maxLength(1000).optional(),
47
- price: vine.number().min(0).max(1000000),
48
- discount: vine.number().min(0).max(1000000).optional(),
49
- stock: vine.number().min(0).max(1000000).optional(),
50
- variant: ProductVariantSchema,
51
- metadata: vine.object({}).optional(),
52
- status: vine.enum(ProductStatus),
53
- verifiedAt: vine.date().optional(),
54
- blockedAt: vine.date().optional(),
55
- });
56
- export const UpdateProductSchema = vine.object({
57
- slug: vine
58
- .string()
59
- .regex(/^[a-z0-9-]+$/)
60
- .minLength(2)
61
- .maxLength(32)
62
- // .unique(async (db, value, field) => {
63
- // const product = await db.from('products').where('slug', value).first()
64
- // return !product
65
- // })
66
- .optional(),
67
- sku: vine.string().optional(),
68
- decoration: vine.object({}).optional(),
69
- name: vine.string().minLength(2).maxLength(32).optional(),
70
- photoUrl: vine.string().optional(),
71
- photoFile: ImageFileSchema.optional(),
72
- media: vine.array(vine.string()).optional(),
73
- mediaFiles: vine.array(ImageFileSchema).optional(),
74
- // storeId must exist in the database
75
- storeId: vine.string(),
76
- // .exists(async (db, value, field) => {
77
- // return !!field.meta.store && (field.meta.store as Store).userId === field.meta.userId
78
- // })
79
- // .optional(),
80
- category: EmbaddedCategorySchema.optional(),
81
- title: vine.string().minLength(2).maxLength(255).optional(),
82
- description: vine.string().minLength(2).maxLength(255).optional(),
83
- body: vine.string().minLength(2).maxLength(1000).optional(),
84
- price: vine.number().min(0).max(1000000).optional(),
85
- discount: vine.number().min(0).max(1000000).optional(),
86
- stock: vine.number().min(0).max(1000000).optional(),
87
- variant: ProductVariantSchema,
88
- metadata: vine.object({}).optional(),
89
- status: vine.enum(ProductStatus).optional(),
90
- verifiedAt: vine.date().optional(),
91
- blockedAt: vine.date().optional(),
92
- });
@@ -1,41 +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
- export const CreateShippingMethodSchema = vine.object({
6
- name: vine.string(),
7
- description: vine.string().optional(),
8
- photoUrl: vine.string().optional(),
9
- ondarkPhotoUrl: vine.string().optional(),
10
- photoFile: ImageFileSchema.optional(),
11
- ondarkPhotoFile: ImageFileSchema.optional(),
12
- price: vine.number(),
13
- // forks: vine.number(),
14
- // sourceId: vine.string(),
15
- storeId: vine.string(),
16
- rates: vine.array(vine.number().optional()),
17
- status: vine.enum(ShippingMethodStatus),
18
- policy: vine.enum(ShippingMethodPolicy),
19
- // verifiedAt: vine.date(),
20
- });
21
- export const UpdateShippingMethodSchema = vine.object({
22
- name: vine.string().optional(),
23
- description: vine.string().optional(),
24
- photoUrl: vine.string().optional(),
25
- ondarkPhotoUrl: vine.string().optional(),
26
- photoFile: ImageFileSchema.optional(),
27
- ondarkPhotoFile: ImageFileSchema.optional(),
28
- price: vine.number().optional(),
29
- // forks: vine.number().optional(),
30
- // sourceId: vine.string().optional(),
31
- storeId: vine.string().optional(),
32
- rates: vine.array(vine.number().optional()).optional(),
33
- status: vine.enum(ShippingMethodStatus).optional(),
34
- policy: vine.enum(ShippingMethodPolicy).optional(),
35
- // verifiedAt: vine.date().optional(),
36
- });
37
- // ForkShippingMethodSchema
38
- export const ForkShippingMethodSchema = vine.object({
39
- sourceId: vine.string(),
40
- storeId: vine.string(),
41
- });
@@ -1,97 +0,0 @@
1
- import vine from '@vinejs/vine';
2
- import { AvatarFileSchema, ContactSchema, DomainSchema, EmbaddedAddressSchema, EmbaddedCategorySchema, StoreDecorationSchema, } from './helpers.js';
3
- import { DefaultShippingRatesSchema } from './user_stores.js';
4
- export const CreateStoreSchema = vine.object({
5
- name: vine.string().minLength(2).maxLength(32),
6
- slug: vine
7
- .string()
8
- .regex(/^[a-z0-9-]+$/)
9
- .minLength(2)
10
- .maxLength(32)
11
- // .unique(async (db, value, field) => {
12
- // const store = await db.from('stores').where('slug', value).first()
13
- // return !store
14
- // })
15
- ,
16
- domain: vine
17
- .object({
18
- name: vine.string().minLength(2).maxLength(32),
19
- verifiedAt: vine.date().optional(),
20
- metadata: vine.object({}).optional(),
21
- })
22
- .optional(),
23
- decoration: vine
24
- .object({
25
- primaryColor: vine.number().min(0x0).max(0xffffffff),
26
- metadata: vine.any().optional(),
27
- })
28
- .optional(),
29
- logoUrl: vine.string().optional(),
30
- ondarkLogoUrl: vine.string().optional(),
31
- logoFile: AvatarFileSchema.optional(),
32
- ondarkLogoFile: AvatarFileSchema.optional(),
33
- userId: vine.string()
34
- // .exists(async (db, value, field) => {
35
- // const user = await db.from('users').where('id', value).first()
36
- // return !!user
37
- // })
38
- ,
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(vine.object({
46
- type: vine.string().minLength(2).maxLength(32),
47
- value: vine.string().minLength(2).maxLength(255),
48
- metadata: vine.object({}).optional(),
49
- }))
50
- .optional(),
51
- shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
52
- verifiedAt: vine.date().optional(),
53
- blockedAt: vine.date().optional(),
54
- integrations: vine.array(vine.any()).optional(),
55
- // default_shipping_rates
56
- defaultShippingRates: DefaultShippingRatesSchema.optional(),
57
- });
58
- // UpdateStoreSchema
59
- export const UpdateStoreSchema = vine.object({
60
- name: vine.string().minLength(2).maxLength(32).optional(),
61
- slug: vine
62
- .string()
63
- .regex(/^[a-z0-9-]+$/)
64
- .minLength(2)
65
- .maxLength(32)
66
- // .unique(async (db, value, field) => {
67
- // const store = await db.from('stores').where('slug', value).first()
68
- // return !store
69
- // })
70
- .optional(),
71
- domain: DomainSchema.optional(),
72
- decoration: StoreDecorationSchema.optional(),
73
- logoUrl: vine.string().optional(),
74
- ondarkLogoUrl: vine.string().optional(),
75
- logoFile: AvatarFileSchema.optional(),
76
- ondarkLogoFile: AvatarFileSchema.optional(),
77
- userId: vine
78
- .string()
79
- // .exists(async (db, value, field) => {
80
- // const user = await db.from('users').where('id', value).first()
81
- // return !!user
82
- // })
83
- .optional(),
84
- categories: vine.array(EmbaddedCategorySchema).optional(),
85
- title: vine.string().minLength(2).maxLength(255).optional(),
86
- description: vine.string().minLength(2).maxLength(255).optional(),
87
- addresses: vine.array(EmbaddedAddressSchema).optional(),
88
- metadata: vine.object({}).optional(),
89
- contacts: vine.array(ContactSchema).optional(),
90
- shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
91
- verifiedAt: vine.date().optional(),
92
- blockedAt: vine.date().optional(),
93
- // integrations
94
- integrations: vine.array(vine.any()).optional(),
95
- // default_shipping_rates
96
- defaultShippingRates: DefaultShippingRatesSchema.optional(),
97
- });
@@ -1,74 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- import { AvatarFileSchema, ContactSchema, DomainSchema, EmbaddedAddressSchema, EmbaddedCategorySchema, StoreBunner, StoreDecorationSchema, } from "./helpers.js";
3
- // "defaultShippingRates.1"
4
- export const DefaultShippingRatesSchema = vine.array(vine.array(vine.number().min(0).max(10000).nullable()).nullable());
5
- export const CreateUserStoreSchema = vine.object({
6
- name: vine.string().minLength(2).maxLength(32),
7
- slug: vine
8
- .string()
9
- .regex(/^[a-z0-9-]+$/)
10
- .minLength(2)
11
- .maxLength(32),
12
- // .unique(async (db, value, field) => {
13
- // const store = await db.from('stores').where('slug', value).first()
14
- // return !store
15
- // })
16
- domain: vine
17
- .object({
18
- name: vine.string().minLength(2).maxLength(32),
19
- })
20
- .optional(),
21
- decoration: vine
22
- .object({
23
- primaryColor: vine.number().min(0x0).max(0xffffffff),
24
- })
25
- .optional(),
26
- banner: StoreBunner.optional(),
27
- logoUrl: vine.string().optional(),
28
- ondarkLogoUrl: vine.string().optional(),
29
- logoFile: AvatarFileSchema.optional(),
30
- ondarkLogoFile: AvatarFileSchema.optional(),
31
- categories: vine.array(EmbaddedCategorySchema).optional(),
32
- title: vine.string().minLength(2).maxLength(255).optional(),
33
- description: vine.string().minLength(2).maxLength(255).optional(),
34
- addresses: vine.array(EmbaddedAddressSchema).optional(),
35
- metadata: vine.object({}).optional(),
36
- contacts: vine
37
- .array(vine.object({
38
- type: vine.string().minLength(2).maxLength(32),
39
- value: vine.string().minLength(2).maxLength(255),
40
- metadata: vine.object({}).optional(),
41
- }))
42
- .optional(),
43
- defaultShippingRates: DefaultShippingRatesSchema.optional(),
44
- integrations: vine.array(vine.any()).optional(),
45
- });
46
- // UpdateStoreSchema
47
- export const UpdateUserStoreSchema = vine.object({
48
- name: vine.string().minLength(2).maxLength(32).optional(),
49
- slug: vine
50
- .string()
51
- .regex(/^[a-z0-9-]+$/)
52
- .minLength(2)
53
- .maxLength(32)
54
- // .unique(async (db, value, field) => {
55
- // const store = await db.from('stores').where('slug', value).first()
56
- // return !store
57
- // })
58
- .optional(),
59
- domain: DomainSchema.optional(),
60
- decoration: StoreDecorationSchema.optional(),
61
- banner: StoreBunner.optional(),
62
- logoUrl: vine.string().nullable().optional(),
63
- ondarkLogoUrl: vine.string().nullable().optional(),
64
- logoFile: AvatarFileSchema.optional(),
65
- ondarkLogoFile: AvatarFileSchema.optional(),
66
- categories: vine.array(EmbaddedCategorySchema).optional(),
67
- title: vine.string().minLength(2).maxLength(255).optional(),
68
- description: vine.string().minLength(2).maxLength(255).optional(),
69
- addresses: vine.array(EmbaddedAddressSchema).optional(),
70
- metadata: vine.object({}).optional(),
71
- contacts: vine.array(ContactSchema).optional(),
72
- defaultShippingRates: DefaultShippingRatesSchema.optional(),
73
- integrations: vine.array(vine.any()).optional(),
74
- });
@@ -1,67 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- // User Schemas
3
- //CreateUserSchema
4
- export const CreateUserSchema = vine.object({
5
- name: vine.string().minLength(2).maxLength(32),
6
- email: vine.string(),
7
- // .unique(async (db, value, field) => {
8
- // const user = await db.from('users').where('email', value).first()
9
- // return !user
10
- // }),
11
- phone: vine
12
- .string()
13
- .regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/)
14
- // .unique(async (db, value, field) => {
15
- // const user = await db.from('users').where('phone', value).first()
16
- // return !user
17
- // })
18
- .optional(),
19
- password: vine.string().minLength(8).maxLength(32),
20
- // for upload file
21
- photoFile: vine.any(),
22
- // .file({
23
- // size: '1mb',
24
- // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
25
- // })
26
- // .optional(),
27
- photoUrl: vine.string().optional(),
28
- // metadata (any object)
29
- metadata: vine.object({}).optional(),
30
- // dates
31
- emailVerifiedAt: vine.date().optional(),
32
- phoneVerifiedAt: vine.date().optional(),
33
- verifiedAt: vine.date().optional(),
34
- blockedAt: vine.date().optional(),
35
- });
36
- //UpdateUserSchema
37
- export const UpdateUserSchema = vine.object({
38
- name: vine.string().minLength(2).maxLength(32).optional(),
39
- email: vine
40
- .string()
41
- // .unique(async (db, value, field) => {
42
- // const user = await db.from('users').where('email', value).first()
43
- // return !user
44
- // })
45
- .optional(),
46
- phone: vine
47
- .string()
48
- // must start with 0 then if secend is (5|6|7) then 8 digits and if secend is (2) then 7 digits
49
- .regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/)
50
- .optional(),
51
- password: vine.string().minLength(8).maxLength(32).confirmed().optional(),
52
- // for upload file
53
- photoFile: vine
54
- // .file({
55
- // size: '1mb',
56
- // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
57
- // })
58
- .any(),
59
- photoUrl: vine.string().optional(),
60
- // metadata (any object)
61
- metadata: vine.object({}).optional(),
62
- // dates
63
- emailVerifiedAt: vine.date().optional(),
64
- phoneVerifiedAt: vine.date().optional(),
65
- verifiedAt: vine.string().optional(),
66
- blockedAt: vine.date().optional(),
67
- });
@@ -1,2 +0,0 @@
1
- declare const _default: import("vite").UserConfig;
2
- export default _default;