feeef 0.0.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/.eslintrc.cjs +19 -0
- package/README.md +3 -0
- package/package.json +28 -0
- package/src/core/core.ts +10 -0
- package/src/core/embadded/address.ts +13 -0
- package/src/core/embadded/category.ts +7 -0
- package/src/core/embadded/contact.ts +24 -0
- package/src/core/entities/order.ts +52 -0
- package/src/core/entities/product.ts +99 -0
- package/src/core/entities/shipping_method.ts +32 -0
- package/src/core/entities/store.ts +84 -0
- package/src/core/entities/user.ts +24 -0
- package/src/core/sdk/fif.ts +3 -0
- package/src/feeef/feeef.ts +94 -0
- package/src/feeef/repositories/orders.ts +37 -0
- package/src/feeef/repositories/products.ts +25 -0
- package/src/feeef/repositories/repository.ts +175 -0
- package/src/feeef/repositories/stores.ts +40 -0
- package/src/feeef/repositories/users.ts +92 -0
- package/src/feeef/validators/auth.ts +50 -0
- package/src/feeef/validators/custom/datetime.ts +9 -0
- package/src/feeef/validators/helpers.ts +75 -0
- package/src/feeef/validators/order.ts +89 -0
- package/src/feeef/validators/product.ts +95 -0
- package/src/feeef/validators/shipping_method.ts +44 -0
- package/src/feeef/validators/stores.ts +108 -0
- package/src/feeef/validators/user_stores.ts +89 -0
- package/src/feeef/validators/users.ts +69 -0
- package/src/index.ts +0 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +24 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +6 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import vine from '@vinejs/vine'
|
|
2
|
+
import {
|
|
3
|
+
AvatarFileSchema,
|
|
4
|
+
ContactSchema,
|
|
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
|
+
,
|
|
24
|
+
domain: vine
|
|
25
|
+
.object({
|
|
26
|
+
name: vine.string().minLength(2).maxLength(32),
|
|
27
|
+
verifiedAt: vine.date().optional(),
|
|
28
|
+
metadata: vine.object({}).optional(),
|
|
29
|
+
})
|
|
30
|
+
.optional(),
|
|
31
|
+
decoration: vine
|
|
32
|
+
.object({
|
|
33
|
+
primaryColor: vine.number().min(0x0).max(0xffffffff),
|
|
34
|
+
metadata: vine.any().optional(),
|
|
35
|
+
})
|
|
36
|
+
.optional(),
|
|
37
|
+
logoUrl: vine.string().optional(),
|
|
38
|
+
ondarkLogoUrl: vine.string().optional(),
|
|
39
|
+
logoFile: AvatarFileSchema.optional(),
|
|
40
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
41
|
+
userId: vine.string()
|
|
42
|
+
// .exists(async (db, value, field) => {
|
|
43
|
+
// const user = await db.from('users').where('id', value).first()
|
|
44
|
+
// return !!user
|
|
45
|
+
// })
|
|
46
|
+
,
|
|
47
|
+
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
48
|
+
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
49
|
+
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
50
|
+
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
51
|
+
metadata: vine.object({}).optional(),
|
|
52
|
+
contacts: vine
|
|
53
|
+
.array(
|
|
54
|
+
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
|
+
)
|
|
60
|
+
.optional(),
|
|
61
|
+
shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
|
|
62
|
+
verifiedAt: vine.date().optional(),
|
|
63
|
+
blockedAt: vine.date().optional(),
|
|
64
|
+
integrations: vine.array(vine.any()).optional(),
|
|
65
|
+
// default_shipping_rates
|
|
66
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// UpdateStoreSchema
|
|
70
|
+
export const UpdateStoreSchema = vine.object({
|
|
71
|
+
name: vine.string().minLength(2).maxLength(32).optional(),
|
|
72
|
+
slug: vine
|
|
73
|
+
.string()
|
|
74
|
+
.regex(/^[a-z0-9-]+$/)
|
|
75
|
+
.minLength(2)
|
|
76
|
+
.maxLength(32)
|
|
77
|
+
// .unique(async (db, value, field) => {
|
|
78
|
+
// const store = await db.from('stores').where('slug', value).first()
|
|
79
|
+
// return !store
|
|
80
|
+
// })
|
|
81
|
+
.optional(),
|
|
82
|
+
domain: DomainSchema.optional(),
|
|
83
|
+
decoration: StoreDecorationSchema.optional(),
|
|
84
|
+
logoUrl: vine.string().optional(),
|
|
85
|
+
ondarkLogoUrl: vine.string().optional(),
|
|
86
|
+
logoFile: AvatarFileSchema.optional(),
|
|
87
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
88
|
+
userId: vine
|
|
89
|
+
.string()
|
|
90
|
+
// .exists(async (db, value, field) => {
|
|
91
|
+
// const user = await db.from('users').where('id', value).first()
|
|
92
|
+
// return !!user
|
|
93
|
+
// })
|
|
94
|
+
.optional(),
|
|
95
|
+
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
96
|
+
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
97
|
+
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
98
|
+
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
99
|
+
metadata: vine.object({}).optional(),
|
|
100
|
+
contacts: vine.array(ContactSchema).optional(),
|
|
101
|
+
shippingRates: vine.array(vine.string().minLength(2).maxLength(48)).optional(),
|
|
102
|
+
verifiedAt: vine.date().optional(),
|
|
103
|
+
blockedAt: vine.date().optional(),
|
|
104
|
+
// integrations
|
|
105
|
+
integrations: vine.array(vine.any()).optional(),
|
|
106
|
+
// default_shipping_rates
|
|
107
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
108
|
+
})
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import vine from "@vinejs/vine";
|
|
2
|
+
import {
|
|
3
|
+
AvatarFileSchema,
|
|
4
|
+
ContactSchema,
|
|
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(10000).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: vine
|
|
33
|
+
.object({
|
|
34
|
+
primaryColor: vine.number().min(0x0).max(0xffffffff),
|
|
35
|
+
})
|
|
36
|
+
.optional(),
|
|
37
|
+
|
|
38
|
+
banner: StoreBunner.optional(),
|
|
39
|
+
logoUrl: vine.string().optional(),
|
|
40
|
+
ondarkLogoUrl: vine.string().optional(),
|
|
41
|
+
logoFile: AvatarFileSchema.optional(),
|
|
42
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
43
|
+
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
44
|
+
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
45
|
+
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
46
|
+
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
47
|
+
metadata: vine.object({}).optional(),
|
|
48
|
+
contacts: vine
|
|
49
|
+
.array(
|
|
50
|
+
vine.object({
|
|
51
|
+
type: vine.string().minLength(2).maxLength(32),
|
|
52
|
+
value: vine.string().minLength(2).maxLength(255),
|
|
53
|
+
metadata: vine.object({}).optional(),
|
|
54
|
+
})
|
|
55
|
+
)
|
|
56
|
+
.optional(),
|
|
57
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
58
|
+
integrations: vine.array(vine.any()).optional(),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// UpdateStoreSchema
|
|
62
|
+
export const UpdateUserStoreSchema = vine.object({
|
|
63
|
+
name: vine.string().minLength(2).maxLength(32).optional(),
|
|
64
|
+
slug: vine
|
|
65
|
+
.string()
|
|
66
|
+
.regex(/^[a-z0-9-]+$/)
|
|
67
|
+
.minLength(2)
|
|
68
|
+
.maxLength(32)
|
|
69
|
+
// .unique(async (db, value, field) => {
|
|
70
|
+
// const store = await db.from('stores').where('slug', value).first()
|
|
71
|
+
// return !store
|
|
72
|
+
// })
|
|
73
|
+
.optional(),
|
|
74
|
+
domain: DomainSchema.optional(),
|
|
75
|
+
decoration: StoreDecorationSchema.optional(),
|
|
76
|
+
banner: StoreBunner.optional(),
|
|
77
|
+
logoUrl: vine.string().nullable().optional(),
|
|
78
|
+
ondarkLogoUrl: vine.string().nullable().optional(),
|
|
79
|
+
logoFile: AvatarFileSchema.optional(),
|
|
80
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
81
|
+
categories: vine.array(EmbaddedCategorySchema).optional(),
|
|
82
|
+
title: vine.string().minLength(2).maxLength(255).optional(),
|
|
83
|
+
description: vine.string().minLength(2).maxLength(255).optional(),
|
|
84
|
+
addresses: vine.array(EmbaddedAddressSchema).optional(),
|
|
85
|
+
metadata: vine.object({}).optional(),
|
|
86
|
+
contacts: vine.array(ContactSchema).optional(),
|
|
87
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
88
|
+
integrations: vine.array(vine.any()).optional(),
|
|
89
|
+
});
|
|
@@ -0,0 +1,69 @@
|
|
|
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
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|