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
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # The MIT License
2
+
3
+ Copyright (c) 2023 VineJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # PiShop
1
+ # @vinejs/vine
2
2
 
3
- a simple shop for ecommerce in algeria.
3
+ <hr>
4
+ <br />
5
+
6
+ <div align="center">
7
+ <h3>One of the fastest validation library for Node.js</h3>
8
+ <p>VineJS is a form data validation library for Node.js. You may use it to validate the HTTP request body in your backend applications.</p>
9
+ </div>
10
+
11
+ <br />
12
+
13
+ <div align="center">
14
+
15
+ [![gh-workflow-image]][gh-workflow-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url]
16
+
17
+ </div>
18
+
19
+ <div align="center">
20
+ <h3>
21
+ <a href="./benchmarks.md">
22
+ Benchmarks
23
+ </a>
24
+ <span> | </span>
25
+ <a href="https://vinejs.dev/docs/introduction">
26
+ Documentation
27
+ </a>
28
+ <span> | </span>
29
+ <a href="https://github.com/vinejs/.github/blob/main/docs/CONTRIBUTING.md">
30
+ Contributing
31
+ </a>
32
+ </h3>
33
+ </div>
34
+
35
+ <div align="center">
36
+ <sub>Built with ❤︎ by <a href="https://github.com/thetutlage">Harminder Virk</a>
37
+ </div>
38
+
39
+ <br />
40
+ <hr>
41
+ <br />
42
+
43
+ ![](https://github.com/thetutlage/static/blob/main/sponsorkit/sponsors.png?raw=true)
44
+
45
+ [gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/vinejs/vine/checks.yml?style=for-the-badge
46
+ [gh-workflow-url]: https://github.com/vinejs/vine/actions/workflows/checks.yml 'Github action'
47
+ [npm-image]: https://img.shields.io/npm/v/@vinejs/vine/latest.svg?style=for-the-badge&logo=npm
48
+ [npm-url]: https://www.npmjs.com/package/@vinejs/vine/v/latest 'npm'
49
+ [typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
50
+ [license-url]: LICENSE.md
51
+ [license-image]: https://img.shields.io/github/license/vinejs/vine?style=for-the-badge
@@ -0,0 +1 @@
1
+ export * from './src/index.js';
package/build/index.js ADDED
@@ -0,0 +1,632 @@
1
+ // src/feeef/feeef.ts
2
+ import axios from "axios";
3
+
4
+ // src/feeef/repositories/orders.ts
5
+ import vine4 from "@vinejs/vine";
6
+
7
+ // src/feeef/validators/order.ts
8
+ import vine3 from "@vinejs/vine";
9
+
10
+ // src/feeef/validators/auth.ts
11
+ import vine2 from "@vinejs/vine";
12
+
13
+ // src/feeef/validators/helpers.ts
14
+ import vine from "@vinejs/vine";
15
+ var AvatarFileSchema = vine.any();
16
+ var ImageFileSchema = vine.any();
17
+ var DomainSchema = vine.object({
18
+ name: vine.string().minLength(3).maxLength(32),
19
+ verifiedAt: vine.date().optional(),
20
+ metadata: vine.object({}).optional()
21
+ });
22
+ var StoreDecorationSchema = vine.object({
23
+ primary: vine.number().min(0).max(4294967295),
24
+ onPrimary: vine.number().min(0).max(4294967295),
25
+ showStoreLogoInHeader: vine.boolean().optional(),
26
+ logoFullHeight: vine.boolean().optional(),
27
+ showStoreNameInHeader: vine.boolean().optional(),
28
+ metadata: vine.any().optional()
29
+ });
30
+ var EmbaddedCategorySchema = vine.object({
31
+ name: vine.string().minLength(2).maxLength(32),
32
+ description: vine.string().minLength(2).maxLength(255).optional(),
33
+ photoUrl: vine.string().optional(),
34
+ ondarkPhotoUrl: vine.string().optional(),
35
+ photoFile: AvatarFileSchema.optional(),
36
+ ondarkPhotoFile: AvatarFileSchema.optional(),
37
+ metadata: vine.object({}).optional()
38
+ });
39
+ var EmbaddedAddressSchema = vine.object({
40
+ country: vine.string().minLength(2).maxLength(32).optional(),
41
+ state: vine.string().minLength(2).maxLength(32).optional(),
42
+ city: vine.string().minLength(2).maxLength(32).optional(),
43
+ street: vine.string().minLength(2).maxLength(32).optional(),
44
+ zip: vine.string().minLength(2).maxLength(32).optional(),
45
+ metadata: vine.object({}).optional().optional()
46
+ });
47
+ var EmbaddedContactSchema = 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
+ var StoreBunner = vine.object({
53
+ url: vine.string().url().optional(),
54
+ title: vine.string(),
55
+ enabled: vine.boolean().optional(),
56
+ metadata: vine.object({}).optional()
57
+ });
58
+
59
+ // src/feeef/validators/auth.ts
60
+ var PhoneShema = vine2.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/);
61
+ var SignupSchema = vine2.object({
62
+ name: vine2.string().minLength(2).maxLength(32),
63
+ email: vine2.string(),
64
+ // .unique(async (db, value, field) => {
65
+ // const user = await db.from('users').where('email', value).first()
66
+ // return !user
67
+ // })
68
+ phone: PhoneShema.optional(),
69
+ photoFile: ImageFileSchema.optional(),
70
+ photoUrl: vine2.string().optional(),
71
+ password: vine2.string().minLength(8).maxLength(32)
72
+ });
73
+ var SigninSchema = vine2.object({
74
+ email: vine2.string().email(),
75
+ password: vine2.string().minLength(8).maxLength(32)
76
+ });
77
+ var AuthUpdateUserSchema = vine2.object({
78
+ name: vine2.string().minLength(2).maxLength(32).optional(),
79
+ email: vine2.string().optional(),
80
+ phone: PhoneShema.optional(),
81
+ // for upload file
82
+ photoFile: vine2.any(),
83
+ photoUrl: vine2.string().optional(),
84
+ oldPassword: vine2.string().minLength(8).maxLength(32).optional(),
85
+ newPassword: vine2.string().minLength(8).maxLength(32).notSameAs("oldPassword").optional()
86
+ });
87
+
88
+ // src/core/entities/order.ts
89
+ var OrderStatus = /* @__PURE__ */ ((OrderStatus2) => {
90
+ OrderStatus2["draft"] = "draft";
91
+ OrderStatus2["pending"] = "pending";
92
+ OrderStatus2["review"] = "review";
93
+ OrderStatus2["accepted"] = "accepted";
94
+ OrderStatus2["processing"] = "processing";
95
+ OrderStatus2["completed"] = "completed";
96
+ OrderStatus2["cancelled"] = "cancelled";
97
+ return OrderStatus2;
98
+ })(OrderStatus || {});
99
+ var PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
100
+ PaymentStatus2["unpaid"] = "unpaid";
101
+ PaymentStatus2["paid"] = "paid";
102
+ PaymentStatus2["received"] = "received";
103
+ return PaymentStatus2;
104
+ })(PaymentStatus || {});
105
+ var DeliveryStatus = /* @__PURE__ */ ((DeliveryStatus2) => {
106
+ DeliveryStatus2["pending"] = "pending";
107
+ DeliveryStatus2["delivering"] = "delivering";
108
+ DeliveryStatus2["delivered"] = "delivered";
109
+ DeliveryStatus2["returned"] = "returned";
110
+ return DeliveryStatus2;
111
+ })(DeliveryStatus || {});
112
+
113
+ // src/feeef/validators/order.ts
114
+ var OrderItemSchema = vine3.object({
115
+ productId: vine3.string(),
116
+ // productId: vine.string().exists(async (db, value, field) => {
117
+ // const product = await db.from('products').where('id', value).first()
118
+ // return !!product
119
+ // }),
120
+ productName: vine3.string().optional(),
121
+ variant: vine3.any().optional(),
122
+ quantity: vine3.number(),
123
+ price: vine3.number().optional()
124
+ });
125
+ var GuestOrderItemSchema = vine3.object({
126
+ productId: vine3.string(),
127
+ variantPath: vine3.string().optional(),
128
+ quantity: vine3.number()
129
+ });
130
+ var SendOrderSchema = vine3.object({
131
+ id: vine3.string().optional(),
132
+ customerName: vine3.string().optional(),
133
+ customerPhone: vine3.string(),
134
+ // customerIp: vine.string().optional(),
135
+ shippingAddress: vine3.string().optional(),
136
+ shippingCity: vine3.string().optional(),
137
+ shippingState: vine3.string().optional(),
138
+ shippingMethodId: vine3.string().optional(),
139
+ paymentMethodId: vine3.string().optional(),
140
+ items: vine3.array(GuestOrderItemSchema).minLength(1),
141
+ // subtotal: vine.number().optional(),
142
+ // shippingPrice: vine.number().optional(),
143
+ // total: vine.number().optional(),
144
+ // discount: vine.number().optional(),
145
+ coupon: vine3.string().optional(),
146
+ status: vine3.enum(["pending", "draft"]),
147
+ // TODO: validate storeId is exists and not blocked
148
+ storeId: vine3.string(),
149
+ metadata: vine3.any().optional()
150
+ });
151
+ var CreateOrderSchema = vine3.object({
152
+ id: vine3.string().optional(),
153
+ customerName: vine3.string().optional(),
154
+ customerPhone: PhoneShema,
155
+ customerIp: vine3.string().optional(),
156
+ shippingAddress: vine3.string().optional(),
157
+ shippingCity: vine3.string().optional(),
158
+ shippingState: vine3.string().optional(),
159
+ shippingMethodId: vine3.string().optional(),
160
+ paymentMethodId: vine3.string().optional(),
161
+ items: vine3.array(OrderItemSchema).minLength(1),
162
+ subtotal: vine3.number().optional(),
163
+ shippingPrice: vine3.number().optional(),
164
+ total: vine3.number().optional(),
165
+ discount: vine3.number().optional(),
166
+ coupon: vine3.string().optional(),
167
+ status: vine3.enum(Object.values(OrderStatus)).optional(),
168
+ storeId: vine3.string(),
169
+ metadata: vine3.any().optional()
170
+ });
171
+ var UpdateOrderSchema = vine3.object({
172
+ id: vine3.string().optional(),
173
+ customerName: vine3.string().optional(),
174
+ customerPhone: PhoneShema.optional(),
175
+ customerIp: vine3.string().optional(),
176
+ shippingAddress: vine3.string().optional(),
177
+ shippingCity: vine3.string().optional(),
178
+ shippingState: vine3.string().optional(),
179
+ shippingMethodId: vine3.string().optional(),
180
+ paymentMethodId: vine3.string().optional(),
181
+ items: vine3.array(OrderItemSchema).minLength(1).optional(),
182
+ subtotal: vine3.number().optional(),
183
+ shippingPrice: vine3.number().optional(),
184
+ total: vine3.number().optional(),
185
+ discount: vine3.number().optional(),
186
+ coupon: vine3.string().optional(),
187
+ status: vine3.enum(Object.values(OrderStatus)).optional(),
188
+ storeId: vine3.string(),
189
+ metadata: vine3.any().optional()
190
+ });
191
+
192
+ // src/feeef/repositories/repository.ts
193
+ var ModelRepository = class {
194
+ resource;
195
+ // client
196
+ client;
197
+ /**
198
+ * Constructs a new instance of the ModelRepository class.
199
+ * @param resource - The resource name.
200
+ * @param client - The Axios instance used for making HTTP requests.
201
+ */
202
+ constructor(resource, client) {
203
+ this.resource = resource;
204
+ this.client = client;
205
+ }
206
+ /**
207
+ * Finds a model by its ID or other criteria.
208
+ * @param options - The options for finding the model.
209
+ * @returns A promise that resolves to the found model.
210
+ */
211
+ async find(options) {
212
+ const { id, by, params } = options;
213
+ const res = await this.client.get(`/${this.resource}/${id}`, {
214
+ params: {
215
+ by: by || "id",
216
+ ...params
217
+ }
218
+ });
219
+ return res.data;
220
+ }
221
+ /**
222
+ * Lists models with optional pagination and filtering.
223
+ * @param options - The options for listing the models.
224
+ * @returns A promise that resolves to a list of models.
225
+ */
226
+ async list(options) {
227
+ const { page, offset, limit, params } = options || {};
228
+ const res = await this.client.get(`/${this.resource}`, {
229
+ params: { page, offset, limit, ...params }
230
+ });
231
+ if (Array.isArray(res.data)) {
232
+ return {
233
+ data: res.data
234
+ };
235
+ } else {
236
+ return {
237
+ data: res.data.data,
238
+ total: res.data.meta.total,
239
+ page: res.data.meta.currentPage,
240
+ limit: res.data.meta.perPage
241
+ };
242
+ }
243
+ }
244
+ /**
245
+ * Creates a new model.
246
+ * @param options - The options for creating the model.
247
+ * @returns A promise that resolves to the created model.
248
+ */
249
+ async create(options) {
250
+ const { data, params } = options;
251
+ const res = await this.client.post(`/${this.resource}`, data, { params });
252
+ return res.data;
253
+ }
254
+ /**
255
+ * Updates an existing model.
256
+ * @param options - The options for updating the model.
257
+ * @returns A promise that resolves to the updated model.
258
+ */
259
+ async update(options) {
260
+ const { id, data, params } = options;
261
+ const res = await this.client.put(`/${this.resource}/${id}`, data, {
262
+ params
263
+ });
264
+ return res.data;
265
+ }
266
+ /**
267
+ * Deletes a model by its ID or other criteria.
268
+ * @param options - The options for deleting the model.
269
+ * @returns A promise that resolves when the model is deleted.
270
+ */
271
+ async delete(options) {
272
+ const { id, by, params } = options;
273
+ await this.client.delete(`/${this.resource}/${id}`, {
274
+ params: {
275
+ by: by || "id",
276
+ ...params
277
+ }
278
+ });
279
+ }
280
+ };
281
+
282
+ // src/feeef/repositories/orders.ts
283
+ var OrderRepository = class extends ModelRepository {
284
+ /**
285
+ * Constructs a new OrderRepository instance.
286
+ * @param client - The AxiosInstance used for making HTTP requests.
287
+ */
288
+ constructor(client) {
289
+ super("orders", client);
290
+ }
291
+ /**
292
+ * Sends an order from an anonymous user.
293
+ * @param data - The data representing the order to be sent.
294
+ * @returns A Promise that resolves to the sent OrderEntity.
295
+ */
296
+ async send(data) {
297
+ const validator = vine4.compile(SendOrderSchema);
298
+ const output = await validator.validate(data);
299
+ const res = await this.client.post(`/${this.resource}/send`, output);
300
+ return res.data;
301
+ }
302
+ };
303
+
304
+ // src/feeef/repositories/products.ts
305
+ var ProductRepository = class extends ModelRepository {
306
+ /**
307
+ * Creates a new instance of the ProductRepository class.
308
+ * @param client - The AxiosInstance used for making HTTP requests.
309
+ */
310
+ constructor(client) {
311
+ super("products", client);
312
+ }
313
+ };
314
+
315
+ // src/feeef/repositories/stores.ts
316
+ import vine6 from "@vinejs/vine";
317
+
318
+ // src/feeef/validators/user_stores.ts
319
+ import vine5 from "@vinejs/vine";
320
+ var DefaultShippingRatesSchema = vine5.array(
321
+ vine5.array(vine5.number().min(0).max(1e5).nullable()).nullable()
322
+ );
323
+ var CreateUserStoreSchema = vine5.object({
324
+ name: vine5.string().minLength(2).maxLength(32),
325
+ slug: vine5.string().regex(/^[a-z0-9-]+$/).minLength(2).maxLength(32),
326
+ // .unique(async (db, value, field) => {
327
+ // const store = await db.from('stores').where('slug', value).first()
328
+ // return !store
329
+ // })
330
+ domain: vine5.object({
331
+ name: vine5.string().minLength(2).maxLength(32)
332
+ }).optional(),
333
+ decoration: StoreDecorationSchema.optional(),
334
+ banner: StoreBunner.optional(),
335
+ logoUrl: vine5.string().optional(),
336
+ ondarkLogoUrl: vine5.string().optional(),
337
+ logoFile: AvatarFileSchema.optional(),
338
+ ondarkLogoFile: AvatarFileSchema.optional(),
339
+ categories: vine5.array(EmbaddedCategorySchema).optional(),
340
+ title: vine5.string().minLength(2).maxLength(255).optional(),
341
+ description: vine5.string().minLength(2).maxLength(255).optional(),
342
+ addresses: vine5.array(EmbaddedAddressSchema).optional(),
343
+ metadata: vine5.object({}).optional(),
344
+ contacts: vine5.array(
345
+ vine5.object({
346
+ type: vine5.string().minLength(2).maxLength(32),
347
+ value: vine5.string().minLength(2).maxLength(255),
348
+ metadata: vine5.object({}).optional()
349
+ })
350
+ ).optional(),
351
+ defaultShippingRates: DefaultShippingRatesSchema.optional(),
352
+ integrations: vine5.array(vine5.any()).optional()
353
+ });
354
+ var UpdateUserStoreSchema = vine5.object({
355
+ name: vine5.string().minLength(2).maxLength(32).optional(),
356
+ slug: vine5.string().regex(/^[a-z0-9-]+$/).minLength(2).maxLength(32).optional(),
357
+ domain: DomainSchema.optional(),
358
+ decoration: StoreDecorationSchema.optional(),
359
+ banner: StoreBunner.optional(),
360
+ logoUrl: vine5.string().nullable().optional(),
361
+ ondarkLogoUrl: vine5.string().nullable().optional(),
362
+ logoFile: AvatarFileSchema.optional(),
363
+ ondarkLogoFile: AvatarFileSchema.optional(),
364
+ categories: vine5.array(EmbaddedCategorySchema).optional(),
365
+ title: vine5.string().minLength(2).maxLength(255).optional(),
366
+ description: vine5.string().minLength(2).maxLength(255).optional(),
367
+ addresses: vine5.array(EmbaddedAddressSchema).optional(),
368
+ metadata: vine5.object({}).optional(),
369
+ contacts: vine5.array(EmbaddedContactSchema).optional(),
370
+ defaultShippingRates: DefaultShippingRatesSchema.optional(),
371
+ integrations: vine5.array(vine5.any()).optional()
372
+ });
373
+
374
+ // src/feeef/repositories/stores.ts
375
+ var StoreRepository = class extends ModelRepository {
376
+ /**
377
+ * Constructs a new StoreRepository instance.
378
+ * @param client The AxiosInstance used for making HTTP requests.
379
+ */
380
+ constructor(client) {
381
+ super("stores", client);
382
+ }
383
+ /**
384
+ * Creates a new Store entity.
385
+ * @param options The options for creating the Store entity.
386
+ * @returns A Promise that resolves to the created Store entity.
387
+ */
388
+ async create(options) {
389
+ const validator = vine6.compile(CreateUserStoreSchema);
390
+ const output = await validator.validate(options.data);
391
+ return super.create({ ...options, data: output });
392
+ }
393
+ };
394
+
395
+ // src/feeef/repositories/users.ts
396
+ import vine8 from "@vinejs/vine";
397
+
398
+ // src/feeef/validators/users.ts
399
+ import vine7 from "@vinejs/vine";
400
+ var CreateUserSchema = vine7.object({
401
+ name: vine7.string().minLength(2).maxLength(32),
402
+ email: vine7.string(),
403
+ // .unique(async (db, value, field) => {
404
+ // const user = await db.from('users').where('email', value).first()
405
+ // return !user
406
+ // }),
407
+ phone: vine7.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/).optional(),
408
+ password: vine7.string().minLength(8).maxLength(32),
409
+ // for upload file
410
+ photoFile: vine7.any(),
411
+ // .file({
412
+ // size: '1mb',
413
+ // extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
414
+ // })
415
+ // .optional(),
416
+ photoUrl: vine7.string().optional(),
417
+ // metadata (any object)
418
+ metadata: vine7.object({}).optional(),
419
+ // dates
420
+ emailVerifiedAt: vine7.date().optional(),
421
+ phoneVerifiedAt: vine7.date().optional(),
422
+ verifiedAt: vine7.date().optional(),
423
+ blockedAt: vine7.date().optional()
424
+ });
425
+ var UpdateUserSchema = vine7.object({
426
+ name: vine7.string().minLength(2).maxLength(32).optional(),
427
+ email: vine7.string().optional(),
428
+ phone: vine7.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/).optional(),
429
+ password: vine7.string().minLength(8).maxLength(32).confirmed().optional(),
430
+ // for upload file
431
+ photoFile: vine7.any(),
432
+ photoUrl: vine7.string().optional(),
433
+ // metadata (any object)
434
+ metadata: vine7.object({}).optional(),
435
+ // dates
436
+ emailVerifiedAt: vine7.date().optional(),
437
+ phoneVerifiedAt: vine7.date().optional(),
438
+ verifiedAt: vine7.string().optional(),
439
+ blockedAt: vine7.date().optional()
440
+ });
441
+
442
+ // src/feeef/repositories/users.ts
443
+ var UserRepository = class extends ModelRepository {
444
+ /**
445
+ * Represents the authentication response.
446
+ */
447
+ auth = null;
448
+ /**
449
+ * Constructs a new UserRepository instance.
450
+ * @param client - The AxiosInstance used for making HTTP requests.
451
+ */
452
+ constructor(client) {
453
+ super("users", client);
454
+ }
455
+ /**
456
+ * Signs in a user with the provided credentials.
457
+ * @param credentials - The user credentials.
458
+ * @returns A promise that resolves to the authentication response.
459
+ */
460
+ async signin(credentials) {
461
+ const validator = vine8.compile(SigninSchema);
462
+ const output = await validator.validate(credentials);
463
+ const res = await this.client.post(`/${this.resource}/auth/signin`, output);
464
+ this.auth = res.data;
465
+ return res.data;
466
+ }
467
+ /**
468
+ * Signs up a new user with the provided credentials.
469
+ * @param credentials - The user credentials.
470
+ * @returns A promise that resolves to the authentication response.
471
+ */
472
+ async signup(credentials) {
473
+ const validator = vine8.compile(CreateUserSchema);
474
+ const output = await validator.validate(credentials);
475
+ const res = await this.client.post(`/${this.resource}/auth/signup`, output);
476
+ this.auth = res.data;
477
+ return res.data;
478
+ }
479
+ /**
480
+ * Signs out the currently authenticated user.
481
+ * @returns A promise that resolves when the user is signed out.
482
+ */
483
+ async signout() {
484
+ this.auth = null;
485
+ }
486
+ /**
487
+ * Updates the authenticated user's data.
488
+ * @param data - The updated user data.
489
+ * @returns A promise that resolves to the updated user entity.
490
+ */
491
+ async updateMe(data) {
492
+ const validator = vine8.compile(AuthUpdateUserSchema);
493
+ const output = await validator.validate(data);
494
+ const res = await this.client.put(`/${this.resource}/auth`, output);
495
+ return res.data;
496
+ }
497
+ };
498
+
499
+ // src/feeef/feeef.ts
500
+ var FeeeF = class {
501
+ /**
502
+ * The API key used for authentication.
503
+ */
504
+ apiKey;
505
+ /**
506
+ * The Axios instance used for making HTTP requests.
507
+ */
508
+ client;
509
+ /**
510
+ * The repository for managing stores.
511
+ */
512
+ stores;
513
+ /**
514
+ * The repository for managing products.
515
+ */
516
+ products;
517
+ /**
518
+ * The repository for managing users.
519
+ */
520
+ users;
521
+ /**
522
+ * The repository for managing orders.
523
+ */
524
+ orders;
525
+ /**
526
+ * Constructs a new instance of the FeeeF class.
527
+ * @param {FeeeFConfig} config - The configuration object.
528
+ * @param {string} config.apiKey - The API key used for authentication.
529
+ * @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.
530
+ * @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.
531
+ */
532
+ //
533
+ constructor({ apiKey, client, cache, baseURL = "http://localhost:3333/api/v1" }) {
534
+ console.log(cache);
535
+ this.apiKey = apiKey;
536
+ this.client = client || axios;
537
+ this.client.defaults.baseURL = baseURL;
538
+ this.stores = new StoreRepository(this.client);
539
+ this.products = new ProductRepository(this.client);
540
+ this.users = new UserRepository(this.client);
541
+ this.orders = new OrderRepository(this.client);
542
+ }
543
+ };
544
+
545
+ // src/core/entities/store.ts
546
+ var StoreActionType = /* @__PURE__ */ ((StoreActionType2) => {
547
+ StoreActionType2["link"] = "link";
548
+ StoreActionType2["whatsapp"] = "whatsapp";
549
+ StoreActionType2["telegram"] = "telegram";
550
+ StoreActionType2["phone"] = "phone";
551
+ return StoreActionType2;
552
+ })(StoreActionType || {});
553
+ var StoreSubscriptionStatus = /* @__PURE__ */ ((StoreSubscriptionStatus2) => {
554
+ StoreSubscriptionStatus2["active"] = "active";
555
+ StoreSubscriptionStatus2["inactive"] = "inactive";
556
+ return StoreSubscriptionStatus2;
557
+ })(StoreSubscriptionStatus || {});
558
+ var StoreSubscriptionType = /* @__PURE__ */ ((StoreSubscriptionType2) => {
559
+ StoreSubscriptionType2["free"] = "free";
560
+ StoreSubscriptionType2["quota"] = "quota";
561
+ StoreSubscriptionType2["percentage"] = "percentage";
562
+ return StoreSubscriptionType2;
563
+ })(StoreSubscriptionType || {});
564
+
565
+ // src/core/entities/product.ts
566
+ var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
567
+ ProductStatus2["draft"] = "draft";
568
+ ProductStatus2["published"] = "published";
569
+ ProductStatus2["archived"] = "archived";
570
+ ProductStatus2["deleted"] = "deleted";
571
+ return ProductStatus2;
572
+ })(ProductStatus || {});
573
+ var VariantOptionType = /* @__PURE__ */ ((VariantOptionType2) => {
574
+ VariantOptionType2["color"] = "color";
575
+ VariantOptionType2["image"] = "image";
576
+ VariantOptionType2["text"] = "text";
577
+ return VariantOptionType2;
578
+ })(VariantOptionType || {});
579
+ var ProductType = /* @__PURE__ */ ((ProductType2) => {
580
+ ProductType2["physical"] = "physical";
581
+ ProductType2["digital"] = "digital";
582
+ ProductType2["service"] = "service";
583
+ return ProductType2;
584
+ })(ProductType || {});
585
+
586
+ // src/core/entities/shipping_method.ts
587
+ var ShippingMethodStatus = /* @__PURE__ */ ((ShippingMethodStatus2) => {
588
+ ShippingMethodStatus2["draft"] = "draft";
589
+ ShippingMethodStatus2["published"] = "published";
590
+ ShippingMethodStatus2["archived"] = "archived";
591
+ return ShippingMethodStatus2;
592
+ })(ShippingMethodStatus || {});
593
+ var ShippingMethodPolicy = /* @__PURE__ */ ((ShippingMethodPolicy2) => {
594
+ ShippingMethodPolicy2["private"] = "private";
595
+ ShippingMethodPolicy2["public"] = "public";
596
+ return ShippingMethodPolicy2;
597
+ })(ShippingMethodPolicy || {});
598
+
599
+ // src/core/embadded/contact.ts
600
+ var EmbaddedContactType = /* @__PURE__ */ ((EmbaddedContactType2) => {
601
+ EmbaddedContactType2["phone"] = "phone";
602
+ EmbaddedContactType2["email"] = "email";
603
+ EmbaddedContactType2["facebook"] = "facebook";
604
+ EmbaddedContactType2["twitter"] = "twitter";
605
+ EmbaddedContactType2["instagram"] = "instagram";
606
+ EmbaddedContactType2["linkedin"] = "linkedin";
607
+ EmbaddedContactType2["website"] = "website";
608
+ EmbaddedContactType2["whatsapp"] = "whatsapp";
609
+ EmbaddedContactType2["telegram"] = "telegram";
610
+ EmbaddedContactType2["signal"] = "signal";
611
+ EmbaddedContactType2["viber"] = "viber";
612
+ EmbaddedContactType2["skype"] = "skype";
613
+ EmbaddedContactType2["zoom"] = "zoom";
614
+ EmbaddedContactType2["other"] = "other";
615
+ return EmbaddedContactType2;
616
+ })(EmbaddedContactType || {});
617
+ export {
618
+ DeliveryStatus,
619
+ EmbaddedContactType,
620
+ FeeeF,
621
+ OrderStatus,
622
+ PaymentStatus,
623
+ ProductStatus,
624
+ ProductType,
625
+ ShippingMethodPolicy,
626
+ ShippingMethodStatus,
627
+ StoreActionType,
628
+ StoreSubscriptionStatus,
629
+ StoreSubscriptionType,
630
+ VariantOptionType
631
+ };
632
+ //# sourceMappingURL=index.js.map