feeef 0.0.25 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +50 -2
  3. package/build/index.d.ts +1 -0
  4. package/build/index.js +632 -0
  5. package/build/index.js.map +1 -0
  6. package/build/src/core/embadded/address.d.ts +13 -0
  7. package/build/src/core/embadded/category.d.ts +7 -0
  8. package/build/src/core/embadded/contact.d.ts +22 -0
  9. package/build/src/core/entities/order.d.ts +76 -0
  10. package/build/src/core/entities/product.d.ts +71 -0
  11. package/build/src/core/entities/shipping_method.d.ts +29 -0
  12. package/build/src/core/entities/store.d.ts +125 -0
  13. package/build/src/core/entities/user.d.ts +28 -0
  14. package/build/src/feeef/feeef.d.ts +66 -0
  15. package/build/src/feeef/repositories/orders.d.ts +21 -0
  16. package/build/src/feeef/repositories/products.d.ts +15 -0
  17. package/build/src/feeef/repositories/repository.d.ts +112 -0
  18. package/build/src/feeef/repositories/stores.d.ts +21 -0
  19. package/build/src/feeef/repositories/users.d.ts +51 -0
  20. package/build/src/feeef/validators/auth.d.ts +76 -0
  21. package/build/src/feeef/validators/custom/datetime.d.ts +1 -0
  22. package/build/src/feeef/validators/helpers.d.ts +148 -0
  23. package/build/src/feeef/validators/order.d.ts +366 -0
  24. package/build/src/feeef/validators/product.d.ts +595 -0
  25. package/build/src/feeef/validators/shipping_method.d.ts +112 -0
  26. package/build/src/feeef/validators/stores.d.ts +590 -0
  27. package/build/src/feeef/validators/user_stores.d.ts +623 -0
  28. package/build/src/feeef/validators/users.d.ts +98 -0
  29. package/build/src/index.d.ts +10 -0
  30. package/package.json +116 -18
  31. package/.eslintrc.cjs +0 -19
  32. package/src/core/core.ts +0 -12
  33. package/src/core/embadded/address.ts +0 -13
  34. package/src/core/embadded/category.ts +0 -7
  35. package/src/core/embadded/contact.ts +0 -25
  36. package/src/core/entities/order.ts +0 -79
  37. package/src/core/entities/product.ts +0 -108
  38. package/src/core/entities/shipping_method.ts +0 -32
  39. package/src/core/entities/store.ts +0 -138
  40. package/src/core/entities/user.ts +0 -30
  41. package/src/feeef/feeef.ts +0 -110
  42. package/src/feeef/repositories/orders.ts +0 -37
  43. package/src/feeef/repositories/products.ts +0 -25
  44. package/src/feeef/repositories/repository.ts +0 -175
  45. package/src/feeef/repositories/stores.ts +0 -39
  46. package/src/feeef/repositories/users.ts +0 -92
  47. package/src/feeef/validators/auth.ts +0 -50
  48. package/src/feeef/validators/custom/datetime.ts +0 -9
  49. package/src/feeef/validators/helpers.ts +0 -69
  50. package/src/feeef/validators/order.ts +0 -89
  51. package/src/feeef/validators/product.ts +0 -95
  52. package/src/feeef/validators/shipping_method.ts +0 -44
  53. package/src/feeef/validators/stores.ts +0 -101
  54. package/src/feeef/validators/user_stores.ts +0 -85
  55. package/src/feeef/validators/users.ts +0 -69
  56. package/src/index.ts +0 -2
  57. package/src/vite-env.d.ts +0 -1
  58. package/tsconfig.json +0 -24
  59. package/tsconfig.node.json +0 -10
  60. package/vite.config.ts +0 -6
@@ -1,138 +0,0 @@
1
- import { EmbaddedAddress } from '../embadded/address.js'
2
- import { EmbaddedCategory } from '../embadded/category.js'
3
- import { EmbaddedContact } from '../embadded/contact.js'
4
- // import { OrderEntity } from "./order.js";
5
- // import { ShippingMethodEntity } from "./shipping_method.js";
6
- import { UserEntity } from './user.js'
7
- import { DateTime } from 'luxon'
8
-
9
- export interface StoreEntity {
10
- id: string
11
- slug: string
12
- banner: StoreBanner | null
13
- action: StoreAction | null
14
- domain: StoreDomain | null
15
- decoration: StoreDecoration | null
16
- name: string
17
- logoUrl: string | null
18
- ondarkLogoUrl: string | null
19
- userId: string
20
- categories: EmbaddedCategory[]
21
- title: string | null
22
- description: string | null
23
- addresses: EmbaddedAddress[]
24
- metadata: Record<string, any>
25
- contacts: EmbaddedContact[]
26
- integrations: StoreIntegrations
27
- verifiedAt: any | null
28
- blockedAt: any | null
29
- createdAt: any
30
- updatedAt: any
31
- // products: ProductEntity[];
32
- user?: UserEntity
33
- // orders: OrderEntity[];
34
- // shippingMethods: ShippingMethodEntity[];
35
- defaultShippingRates: (number | null)[][] | null
36
-
37
- // subscription
38
- subscriptio?: any
39
- due?: number
40
-
41
- // StoreConfigs
42
- configs?: StoreConfigs
43
- }
44
-
45
- export interface StoreConfigs {
46
- currencies: StoreCurrencyConfig[]
47
- defaultCurrency: number
48
- }
49
-
50
- export interface StoreCurrencyConfig {
51
- code: string
52
- symbol: string
53
- precision: number
54
- rate: number
55
- }
56
-
57
- export interface StoreDomain {
58
- name: string
59
- verifiedAt: any | null
60
- metadata: Record<string, any>
61
- }
62
- export interface StoreBanner {
63
- title: string
64
- url?: string | null
65
- enabled: boolean
66
- metadata: Record<string, any>
67
- }
68
-
69
- export interface StoreDecoration {
70
- primary: number
71
- onPrimary?: number
72
- showStoreLogoInHeader?: boolean
73
- logoFullHeight?: boolean
74
- showStoreNameInHeader?: boolean
75
- metadata?: Record<string, any>
76
- }
77
-
78
- export interface StoreAction {
79
- label: string
80
- url: string
81
- type: StoreActionType
82
- }
83
-
84
- export enum StoreActionType {
85
- link = 'link',
86
- whatsapp = 'whatsapp',
87
- telegram = 'telegram',
88
- phone = 'phone',
89
- }
90
-
91
- export interface StoreIntegrations {
92
- [key: string]: any
93
- metadata?: Record<string, any>
94
-
95
- metaPixel?: any
96
- googleAnalytics?: any
97
- googleSheet?: any
98
- sms?: any
99
- telegram?: any
100
- yalidine?: any
101
- maystroDelivery?: any
102
- echotrak?: any
103
- procolis?: any
104
- noest?: any
105
- }
106
-
107
- export enum StoreSubscriptionStatus {
108
- active = 'active',
109
- inactive = 'inactive',
110
- }
111
-
112
- export enum StoreSubscriptionType {
113
- free = 'free',
114
- quota = 'quota',
115
- percentage = 'percentage',
116
- }
117
-
118
- export interface StoreSubscription {
119
- type: StoreSubscriptionType
120
- status: StoreSubscriptionStatus
121
- startedAt: DateTime
122
- expiresAt: DateTime | null
123
- metadata: Record<string, any>
124
- }
125
-
126
- export interface StoreFreeSubscription extends StoreSubscription {
127
- type: StoreSubscriptionType.free
128
- }
129
-
130
- export interface StoreQuotaSubscription extends StoreSubscription {
131
- type: StoreSubscriptionType.quota
132
- quota: number
133
- }
134
- // another way is by taking percentage of the sales
135
- export interface StorePercentageSubscription extends StoreSubscription {
136
- type: StoreSubscriptionType.percentage
137
- percentage: number
138
- }
@@ -1,30 +0,0 @@
1
- export interface UserEntity {
2
- id: string
3
- name: string | null
4
- email: string
5
- phone: string
6
- password: string
7
- photoUrl: string | null
8
- emailVerifiedAt: any | null
9
- phoneVerifiedAt: any | null
10
- verifiedAt: any | null
11
- blockedAt: any | null
12
- createdAt: any
13
- updatedAt: any | null
14
- metadata: Record<string, any>
15
- wallet: EmbaddedWallet
16
- }
17
-
18
- export interface EmbaddedWallet {
19
- currency: 'DZD' | 'USD' | 'EUR'
20
- balance: number
21
- }
22
-
23
- export interface AuthToken {
24
- type: string
25
- name: string | null
26
- token: string
27
- abilities: string[]
28
- lastUsedAt: any
29
- expiresAt: any
30
- }
@@ -1,110 +0,0 @@
1
- import axios, { AxiosInstance } from "axios";
2
- import {
3
- buildMemoryStorage,
4
- buildWebStorage,
5
- setupCache,
6
- } from "axios-cache-interceptor";
7
- import { OrderRepository } from "./repositories/orders";
8
- import { ProductRepository } from "./repositories/products";
9
- import { StoreRepository } from "./repositories/stores";
10
- import { UserRepository } from "./repositories/users";
11
-
12
- /**
13
- * Configuration options for the FeeeF module.
14
- */
15
- export interface FeeeFConfig {
16
- /**
17
- * The API key to be used for authentication.
18
- */
19
- apiKey: string;
20
-
21
- /**
22
- * An optional Axios instance to be used for making HTTP requests.
23
- */
24
- client?: AxiosInstance;
25
-
26
- /**
27
- * Specifies whether caching should be enabled or disabled.
28
- * If set to a number, it represents the maximum number of seconds to cache the responses.
29
- * If set to `false`, caching will be disabled (5s).
30
- * cannot be less than 5 seconds
31
- */
32
- cache?: false | number;
33
-
34
- /**
35
- * The base URL for the API.
36
- */
37
- baseURL?: string;
38
- }
39
-
40
- /**
41
- * Represents the FeeeF class.
42
- */
43
- export class FeeeF {
44
- /**
45
- * The API key used for authentication.
46
- */
47
- apiKey: string;
48
-
49
- /**
50
- * The Axios instance used for making HTTP requests.
51
- */
52
- client: AxiosInstance;
53
-
54
- /**
55
- * The repository for managing stores.
56
- */
57
- stores: StoreRepository;
58
-
59
- /**
60
- * The repository for managing products.
61
- */
62
- products: ProductRepository;
63
-
64
- /**
65
- * The repository for managing users.
66
- */
67
- users: UserRepository;
68
-
69
- /**
70
- * The repository for managing orders.
71
- */
72
- orders: OrderRepository;
73
-
74
- /**
75
- * Constructs a new instance of the FeeeF class.
76
- * @param {FeeeFConfig} config - The configuration object.
77
- * @param {string} config.apiKey - The API key used for authentication.
78
- * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.
79
- * @param {boolean | number} config.cache - The caching configuration. Set to `false` to disable caching, or provide a number to set the cache TTL in milliseconds.
80
- */
81
- constructor({
82
- apiKey,
83
- client,
84
- cache,
85
- baseURL = "http://localhost:3333/api/v1",
86
- }: FeeeFConfig) {
87
- this.apiKey = apiKey;
88
- // get th "cache" search param
89
- // if is 0 or false, disable cache
90
- if (cache === false) {
91
- this.client = client || axios;
92
- } else {
93
- const isInBrowser =
94
- typeof window !== "undefined" && typeof localStorage !== "undefined";
95
- this.client = setupCache(client || axios, {
96
- ttl: cache === undefined ? 1000 * 60 * 5 : Math.max(cache!, 1000), //|| 1 * 60 * 1000, // 1 minute by default
97
- // for persistent cache use buildWebStorage
98
- storage: isInBrowser
99
- ? buildWebStorage(localStorage, "ff:")
100
- : buildMemoryStorage(),
101
- });
102
- }
103
- // set base url
104
- this.client.defaults.baseURL = baseURL;
105
- this.stores = new StoreRepository(this.client);
106
- this.products = new ProductRepository(this.client);
107
- this.users = new UserRepository(this.client);
108
- this.orders = new OrderRepository(this.client);
109
- }
110
- }
@@ -1,37 +0,0 @@
1
- import vine from "@vinejs/vine";
2
- import { InferInput } from "@vinejs/vine/types";
3
- import { AxiosInstance } from "axios";
4
- import { OrderEntity } from "../../core/core";
5
- import { CreateOrderSchema, SendOrderSchema } from "../validators/order";
6
- import { ModelRepository } from "./repository";
7
-
8
- /**
9
- * Represents a repository for managing orders.
10
- */
11
- export class OrderRepository extends ModelRepository<
12
- OrderEntity,
13
- InferInput<typeof CreateOrderSchema>,
14
- InferInput<typeof CreateOrderSchema>
15
- > {
16
- /**
17
- * Constructs a new OrderRepository instance.
18
- * @param client - The AxiosInstance used for making HTTP requests.
19
- */
20
- constructor(client: AxiosInstance) {
21
- super("orders", client);
22
- }
23
-
24
- /**
25
- * Sends an order from an anonymous user.
26
- * @param data - The data representing the order to be sent.
27
- * @returns A Promise that resolves to the sent OrderEntity.
28
- */
29
- async send(data: InferInput<typeof SendOrderSchema>): Promise<OrderEntity> {
30
- const validator = vine.compile(SendOrderSchema);
31
- const output = await validator.validate(data);
32
- const res = await this.client.post(`/${this.resource}/send`, output);
33
-
34
- // Return the sent OrderEntity
35
- return res.data;
36
- }
37
- }
@@ -1,25 +0,0 @@
1
- import { InferInput } from "@vinejs/vine/types";
2
- import { AxiosInstance } from "axios";
3
- import { ProductEntity } from "../../core/core";
4
- import {
5
- CreateProductSchema,
6
- UpdateProductSchema,
7
- } from "../validators/product";
8
- import { ModelRepository } from "./repository";
9
-
10
- /**
11
- * Represents a repository for managing products.
12
- */
13
- export class ProductRepository extends ModelRepository<
14
- ProductEntity,
15
- InferInput<typeof CreateProductSchema>,
16
- InferInput<typeof UpdateProductSchema>
17
- > {
18
- /**
19
- * Creates a new instance of the ProductRepository class.
20
- * @param client - The AxiosInstance used for making HTTP requests.
21
- */
22
- constructor(client: AxiosInstance) {
23
- super("products", client);
24
- }
25
- }
@@ -1,175 +0,0 @@
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
- }
@@ -1,39 +0,0 @@
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
- }
@@ -1,92 +0,0 @@
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
- }
@@ -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
- })