feeef 0.0.27 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +50 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +647 -0
- package/build/index.js.map +1 -0
- package/build/src/core/embadded/address.d.ts +13 -0
- package/build/src/core/embadded/category.d.ts +7 -0
- package/build/src/core/embadded/contact.d.ts +22 -0
- package/build/src/core/entities/order.d.ts +76 -0
- package/build/src/core/entities/product.d.ts +71 -0
- package/build/src/core/entities/shipping_method.d.ts +29 -0
- package/build/src/core/entities/store.d.ts +125 -0
- package/build/src/core/entities/user.d.ts +28 -0
- package/build/src/feeef/feeef.d.ts +66 -0
- package/build/src/feeef/repositories/orders.d.ts +35 -0
- package/build/src/feeef/repositories/products.d.ts +15 -0
- package/build/src/feeef/repositories/repository.d.ts +112 -0
- package/build/src/feeef/repositories/stores.d.ts +21 -0
- package/build/src/feeef/repositories/users.d.ts +51 -0
- package/build/src/feeef/validators/auth.d.ts +76 -0
- package/build/src/feeef/validators/custom/datetime.d.ts +1 -0
- package/build/src/feeef/validators/helpers.d.ts +148 -0
- package/build/src/feeef/validators/order.d.ts +366 -0
- package/build/src/feeef/validators/product.d.ts +595 -0
- package/build/src/feeef/validators/shipping_method.d.ts +112 -0
- package/build/src/feeef/validators/stores.d.ts +590 -0
- package/build/src/feeef/validators/user_stores.d.ts +623 -0
- package/build/src/feeef/validators/users.d.ts +98 -0
- package/build/src/index.d.ts +10 -0
- package/package.json +114 -18
- package/.eslintrc.cjs +0 -19
- package/src/core/core.ts +0 -12
- package/src/core/embadded/address.ts +0 -13
- package/src/core/embadded/category.ts +0 -7
- package/src/core/embadded/contact.ts +0 -25
- package/src/core/entities/order.ts +0 -79
- package/src/core/entities/product.ts +0 -108
- package/src/core/entities/shipping_method.ts +0 -32
- package/src/core/entities/store.ts +0 -155
- package/src/core/entities/user.ts +0 -30
- package/src/feeef/feeef.ts +0 -110
- package/src/feeef/repositories/orders.ts +0 -37
- package/src/feeef/repositories/products.ts +0 -25
- package/src/feeef/repositories/repository.ts +0 -175
- package/src/feeef/repositories/stores.ts +0 -39
- package/src/feeef/repositories/users.ts +0 -92
- package/src/feeef/validators/auth.ts +0 -50
- package/src/feeef/validators/custom/datetime.ts +0 -9
- package/src/feeef/validators/helpers.ts +0 -69
- package/src/feeef/validators/order.ts +0 -89
- package/src/feeef/validators/product.ts +0 -95
- package/src/feeef/validators/shipping_method.ts +0 -44
- package/src/feeef/validators/stores.ts +0 -101
- package/src/feeef/validators/user_stores.ts +0 -85
- package/src/feeef/validators/users.ts +0 -69
- package/src/index.ts +0 -2
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -24
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -6
package/build/index.js
ADDED
|
@@ -0,0 +1,647 @@
|
|
|
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
|
+
* track the order by the order id
|
|
304
|
+
* it will return the order status and history
|
|
305
|
+
* @param options - The options for finding the model.
|
|
306
|
+
* @returns A promise that resolves to the found model.
|
|
307
|
+
*/
|
|
308
|
+
async track(options) {
|
|
309
|
+
const { id, params } = options;
|
|
310
|
+
const res = await this.client.get(`/${this.resource}/${id}`, {
|
|
311
|
+
params: {
|
|
312
|
+
...params
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
return res.data;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
// src/feeef/repositories/products.ts
|
|
320
|
+
var ProductRepository = class extends ModelRepository {
|
|
321
|
+
/**
|
|
322
|
+
* Creates a new instance of the ProductRepository class.
|
|
323
|
+
* @param client - The AxiosInstance used for making HTTP requests.
|
|
324
|
+
*/
|
|
325
|
+
constructor(client) {
|
|
326
|
+
super("products", client);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
// src/feeef/repositories/stores.ts
|
|
331
|
+
import vine6 from "@vinejs/vine";
|
|
332
|
+
|
|
333
|
+
// src/feeef/validators/user_stores.ts
|
|
334
|
+
import vine5 from "@vinejs/vine";
|
|
335
|
+
var DefaultShippingRatesSchema = vine5.array(
|
|
336
|
+
vine5.array(vine5.number().min(0).max(1e5).nullable()).nullable()
|
|
337
|
+
);
|
|
338
|
+
var CreateUserStoreSchema = vine5.object({
|
|
339
|
+
name: vine5.string().minLength(2).maxLength(32),
|
|
340
|
+
slug: vine5.string().regex(/^[a-z0-9-]+$/).minLength(2).maxLength(32),
|
|
341
|
+
// .unique(async (db, value, field) => {
|
|
342
|
+
// const store = await db.from('stores').where('slug', value).first()
|
|
343
|
+
// return !store
|
|
344
|
+
// })
|
|
345
|
+
domain: vine5.object({
|
|
346
|
+
name: vine5.string().minLength(2).maxLength(32)
|
|
347
|
+
}).optional(),
|
|
348
|
+
decoration: StoreDecorationSchema.optional(),
|
|
349
|
+
banner: StoreBunner.optional(),
|
|
350
|
+
logoUrl: vine5.string().optional(),
|
|
351
|
+
ondarkLogoUrl: vine5.string().optional(),
|
|
352
|
+
logoFile: AvatarFileSchema.optional(),
|
|
353
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
354
|
+
categories: vine5.array(EmbaddedCategorySchema).optional(),
|
|
355
|
+
title: vine5.string().minLength(2).maxLength(255).optional(),
|
|
356
|
+
description: vine5.string().minLength(2).maxLength(255).optional(),
|
|
357
|
+
addresses: vine5.array(EmbaddedAddressSchema).optional(),
|
|
358
|
+
metadata: vine5.object({}).optional(),
|
|
359
|
+
contacts: vine5.array(
|
|
360
|
+
vine5.object({
|
|
361
|
+
type: vine5.string().minLength(2).maxLength(32),
|
|
362
|
+
value: vine5.string().minLength(2).maxLength(255),
|
|
363
|
+
metadata: vine5.object({}).optional()
|
|
364
|
+
})
|
|
365
|
+
).optional(),
|
|
366
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
367
|
+
integrations: vine5.array(vine5.any()).optional()
|
|
368
|
+
});
|
|
369
|
+
var UpdateUserStoreSchema = vine5.object({
|
|
370
|
+
name: vine5.string().minLength(2).maxLength(32).optional(),
|
|
371
|
+
slug: vine5.string().regex(/^[a-z0-9-]+$/).minLength(2).maxLength(32).optional(),
|
|
372
|
+
domain: DomainSchema.optional(),
|
|
373
|
+
decoration: StoreDecorationSchema.optional(),
|
|
374
|
+
banner: StoreBunner.optional(),
|
|
375
|
+
logoUrl: vine5.string().nullable().optional(),
|
|
376
|
+
ondarkLogoUrl: vine5.string().nullable().optional(),
|
|
377
|
+
logoFile: AvatarFileSchema.optional(),
|
|
378
|
+
ondarkLogoFile: AvatarFileSchema.optional(),
|
|
379
|
+
categories: vine5.array(EmbaddedCategorySchema).optional(),
|
|
380
|
+
title: vine5.string().minLength(2).maxLength(255).optional(),
|
|
381
|
+
description: vine5.string().minLength(2).maxLength(255).optional(),
|
|
382
|
+
addresses: vine5.array(EmbaddedAddressSchema).optional(),
|
|
383
|
+
metadata: vine5.object({}).optional(),
|
|
384
|
+
contacts: vine5.array(EmbaddedContactSchema).optional(),
|
|
385
|
+
defaultShippingRates: DefaultShippingRatesSchema.optional(),
|
|
386
|
+
integrations: vine5.array(vine5.any()).optional()
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
// src/feeef/repositories/stores.ts
|
|
390
|
+
var StoreRepository = class extends ModelRepository {
|
|
391
|
+
/**
|
|
392
|
+
* Constructs a new StoreRepository instance.
|
|
393
|
+
* @param client The AxiosInstance used for making HTTP requests.
|
|
394
|
+
*/
|
|
395
|
+
constructor(client) {
|
|
396
|
+
super("stores", client);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Creates a new Store entity.
|
|
400
|
+
* @param options The options for creating the Store entity.
|
|
401
|
+
* @returns A Promise that resolves to the created Store entity.
|
|
402
|
+
*/
|
|
403
|
+
async create(options) {
|
|
404
|
+
const validator = vine6.compile(CreateUserStoreSchema);
|
|
405
|
+
const output = await validator.validate(options.data);
|
|
406
|
+
return super.create({ ...options, data: output });
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// src/feeef/repositories/users.ts
|
|
411
|
+
import vine8 from "@vinejs/vine";
|
|
412
|
+
|
|
413
|
+
// src/feeef/validators/users.ts
|
|
414
|
+
import vine7 from "@vinejs/vine";
|
|
415
|
+
var CreateUserSchema = vine7.object({
|
|
416
|
+
name: vine7.string().minLength(2).maxLength(32),
|
|
417
|
+
email: vine7.string(),
|
|
418
|
+
// .unique(async (db, value, field) => {
|
|
419
|
+
// const user = await db.from('users').where('email', value).first()
|
|
420
|
+
// return !user
|
|
421
|
+
// }),
|
|
422
|
+
phone: vine7.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/).optional(),
|
|
423
|
+
password: vine7.string().minLength(8).maxLength(32),
|
|
424
|
+
// for upload file
|
|
425
|
+
photoFile: vine7.any(),
|
|
426
|
+
// .file({
|
|
427
|
+
// size: '1mb',
|
|
428
|
+
// extnames: ['jpg', 'jpeg', 'png', 'gif', 'webp'],
|
|
429
|
+
// })
|
|
430
|
+
// .optional(),
|
|
431
|
+
photoUrl: vine7.string().optional(),
|
|
432
|
+
// metadata (any object)
|
|
433
|
+
metadata: vine7.object({}).optional(),
|
|
434
|
+
// dates
|
|
435
|
+
emailVerifiedAt: vine7.date().optional(),
|
|
436
|
+
phoneVerifiedAt: vine7.date().optional(),
|
|
437
|
+
verifiedAt: vine7.date().optional(),
|
|
438
|
+
blockedAt: vine7.date().optional()
|
|
439
|
+
});
|
|
440
|
+
var UpdateUserSchema = vine7.object({
|
|
441
|
+
name: vine7.string().minLength(2).maxLength(32).optional(),
|
|
442
|
+
email: vine7.string().optional(),
|
|
443
|
+
phone: vine7.string().regex(/^0(5|6|7)\d{8}$|^0(2)\d{7}$/).optional(),
|
|
444
|
+
password: vine7.string().minLength(8).maxLength(32).confirmed().optional(),
|
|
445
|
+
// for upload file
|
|
446
|
+
photoFile: vine7.any(),
|
|
447
|
+
photoUrl: vine7.string().optional(),
|
|
448
|
+
// metadata (any object)
|
|
449
|
+
metadata: vine7.object({}).optional(),
|
|
450
|
+
// dates
|
|
451
|
+
emailVerifiedAt: vine7.date().optional(),
|
|
452
|
+
phoneVerifiedAt: vine7.date().optional(),
|
|
453
|
+
verifiedAt: vine7.string().optional(),
|
|
454
|
+
blockedAt: vine7.date().optional()
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// src/feeef/repositories/users.ts
|
|
458
|
+
var UserRepository = class extends ModelRepository {
|
|
459
|
+
/**
|
|
460
|
+
* Represents the authentication response.
|
|
461
|
+
*/
|
|
462
|
+
auth = null;
|
|
463
|
+
/**
|
|
464
|
+
* Constructs a new UserRepository instance.
|
|
465
|
+
* @param client - The AxiosInstance used for making HTTP requests.
|
|
466
|
+
*/
|
|
467
|
+
constructor(client) {
|
|
468
|
+
super("users", client);
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Signs in a user with the provided credentials.
|
|
472
|
+
* @param credentials - The user credentials.
|
|
473
|
+
* @returns A promise that resolves to the authentication response.
|
|
474
|
+
*/
|
|
475
|
+
async signin(credentials) {
|
|
476
|
+
const validator = vine8.compile(SigninSchema);
|
|
477
|
+
const output = await validator.validate(credentials);
|
|
478
|
+
const res = await this.client.post(`/${this.resource}/auth/signin`, output);
|
|
479
|
+
this.auth = res.data;
|
|
480
|
+
return res.data;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Signs up a new user with the provided credentials.
|
|
484
|
+
* @param credentials - The user credentials.
|
|
485
|
+
* @returns A promise that resolves to the authentication response.
|
|
486
|
+
*/
|
|
487
|
+
async signup(credentials) {
|
|
488
|
+
const validator = vine8.compile(CreateUserSchema);
|
|
489
|
+
const output = await validator.validate(credentials);
|
|
490
|
+
const res = await this.client.post(`/${this.resource}/auth/signup`, output);
|
|
491
|
+
this.auth = res.data;
|
|
492
|
+
return res.data;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Signs out the currently authenticated user.
|
|
496
|
+
* @returns A promise that resolves when the user is signed out.
|
|
497
|
+
*/
|
|
498
|
+
async signout() {
|
|
499
|
+
this.auth = null;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Updates the authenticated user's data.
|
|
503
|
+
* @param data - The updated user data.
|
|
504
|
+
* @returns A promise that resolves to the updated user entity.
|
|
505
|
+
*/
|
|
506
|
+
async updateMe(data) {
|
|
507
|
+
const validator = vine8.compile(AuthUpdateUserSchema);
|
|
508
|
+
const output = await validator.validate(data);
|
|
509
|
+
const res = await this.client.put(`/${this.resource}/auth`, output);
|
|
510
|
+
return res.data;
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
// src/feeef/feeef.ts
|
|
515
|
+
var FeeeF = class {
|
|
516
|
+
/**
|
|
517
|
+
* The API key used for authentication.
|
|
518
|
+
*/
|
|
519
|
+
apiKey;
|
|
520
|
+
/**
|
|
521
|
+
* The Axios instance used for making HTTP requests.
|
|
522
|
+
*/
|
|
523
|
+
client;
|
|
524
|
+
/**
|
|
525
|
+
* The repository for managing stores.
|
|
526
|
+
*/
|
|
527
|
+
stores;
|
|
528
|
+
/**
|
|
529
|
+
* The repository for managing products.
|
|
530
|
+
*/
|
|
531
|
+
products;
|
|
532
|
+
/**
|
|
533
|
+
* The repository for managing users.
|
|
534
|
+
*/
|
|
535
|
+
users;
|
|
536
|
+
/**
|
|
537
|
+
* The repository for managing orders.
|
|
538
|
+
*/
|
|
539
|
+
orders;
|
|
540
|
+
/**
|
|
541
|
+
* Constructs a new instance of the FeeeF class.
|
|
542
|
+
* @param {FeeeFConfig} config - The configuration object.
|
|
543
|
+
* @param {string} config.apiKey - The API key used for authentication.
|
|
544
|
+
* @param {AxiosInstance} config.client - The Axios instance used for making HTTP requests.
|
|
545
|
+
* @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.
|
|
546
|
+
*/
|
|
547
|
+
//
|
|
548
|
+
constructor({ apiKey, client, cache, baseURL = "http://localhost:3333/api/v1" }) {
|
|
549
|
+
console.log(cache);
|
|
550
|
+
this.apiKey = apiKey;
|
|
551
|
+
this.client = client || axios;
|
|
552
|
+
this.client.defaults.baseURL = baseURL;
|
|
553
|
+
this.stores = new StoreRepository(this.client);
|
|
554
|
+
this.products = new ProductRepository(this.client);
|
|
555
|
+
this.users = new UserRepository(this.client);
|
|
556
|
+
this.orders = new OrderRepository(this.client);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
// src/core/entities/store.ts
|
|
561
|
+
var StoreActionType = /* @__PURE__ */ ((StoreActionType2) => {
|
|
562
|
+
StoreActionType2["link"] = "link";
|
|
563
|
+
StoreActionType2["whatsapp"] = "whatsapp";
|
|
564
|
+
StoreActionType2["telegram"] = "telegram";
|
|
565
|
+
StoreActionType2["phone"] = "phone";
|
|
566
|
+
return StoreActionType2;
|
|
567
|
+
})(StoreActionType || {});
|
|
568
|
+
var StoreSubscriptionStatus = /* @__PURE__ */ ((StoreSubscriptionStatus2) => {
|
|
569
|
+
StoreSubscriptionStatus2["active"] = "active";
|
|
570
|
+
StoreSubscriptionStatus2["inactive"] = "inactive";
|
|
571
|
+
return StoreSubscriptionStatus2;
|
|
572
|
+
})(StoreSubscriptionStatus || {});
|
|
573
|
+
var StoreSubscriptionType = /* @__PURE__ */ ((StoreSubscriptionType2) => {
|
|
574
|
+
StoreSubscriptionType2["free"] = "free";
|
|
575
|
+
StoreSubscriptionType2["quota"] = "quota";
|
|
576
|
+
StoreSubscriptionType2["percentage"] = "percentage";
|
|
577
|
+
return StoreSubscriptionType2;
|
|
578
|
+
})(StoreSubscriptionType || {});
|
|
579
|
+
|
|
580
|
+
// src/core/entities/product.ts
|
|
581
|
+
var ProductStatus = /* @__PURE__ */ ((ProductStatus2) => {
|
|
582
|
+
ProductStatus2["draft"] = "draft";
|
|
583
|
+
ProductStatus2["published"] = "published";
|
|
584
|
+
ProductStatus2["archived"] = "archived";
|
|
585
|
+
ProductStatus2["deleted"] = "deleted";
|
|
586
|
+
return ProductStatus2;
|
|
587
|
+
})(ProductStatus || {});
|
|
588
|
+
var VariantOptionType = /* @__PURE__ */ ((VariantOptionType2) => {
|
|
589
|
+
VariantOptionType2["color"] = "color";
|
|
590
|
+
VariantOptionType2["image"] = "image";
|
|
591
|
+
VariantOptionType2["text"] = "text";
|
|
592
|
+
return VariantOptionType2;
|
|
593
|
+
})(VariantOptionType || {});
|
|
594
|
+
var ProductType = /* @__PURE__ */ ((ProductType2) => {
|
|
595
|
+
ProductType2["physical"] = "physical";
|
|
596
|
+
ProductType2["digital"] = "digital";
|
|
597
|
+
ProductType2["service"] = "service";
|
|
598
|
+
return ProductType2;
|
|
599
|
+
})(ProductType || {});
|
|
600
|
+
|
|
601
|
+
// src/core/entities/shipping_method.ts
|
|
602
|
+
var ShippingMethodStatus = /* @__PURE__ */ ((ShippingMethodStatus2) => {
|
|
603
|
+
ShippingMethodStatus2["draft"] = "draft";
|
|
604
|
+
ShippingMethodStatus2["published"] = "published";
|
|
605
|
+
ShippingMethodStatus2["archived"] = "archived";
|
|
606
|
+
return ShippingMethodStatus2;
|
|
607
|
+
})(ShippingMethodStatus || {});
|
|
608
|
+
var ShippingMethodPolicy = /* @__PURE__ */ ((ShippingMethodPolicy2) => {
|
|
609
|
+
ShippingMethodPolicy2["private"] = "private";
|
|
610
|
+
ShippingMethodPolicy2["public"] = "public";
|
|
611
|
+
return ShippingMethodPolicy2;
|
|
612
|
+
})(ShippingMethodPolicy || {});
|
|
613
|
+
|
|
614
|
+
// src/core/embadded/contact.ts
|
|
615
|
+
var EmbaddedContactType = /* @__PURE__ */ ((EmbaddedContactType2) => {
|
|
616
|
+
EmbaddedContactType2["phone"] = "phone";
|
|
617
|
+
EmbaddedContactType2["email"] = "email";
|
|
618
|
+
EmbaddedContactType2["facebook"] = "facebook";
|
|
619
|
+
EmbaddedContactType2["twitter"] = "twitter";
|
|
620
|
+
EmbaddedContactType2["instagram"] = "instagram";
|
|
621
|
+
EmbaddedContactType2["linkedin"] = "linkedin";
|
|
622
|
+
EmbaddedContactType2["website"] = "website";
|
|
623
|
+
EmbaddedContactType2["whatsapp"] = "whatsapp";
|
|
624
|
+
EmbaddedContactType2["telegram"] = "telegram";
|
|
625
|
+
EmbaddedContactType2["signal"] = "signal";
|
|
626
|
+
EmbaddedContactType2["viber"] = "viber";
|
|
627
|
+
EmbaddedContactType2["skype"] = "skype";
|
|
628
|
+
EmbaddedContactType2["zoom"] = "zoom";
|
|
629
|
+
EmbaddedContactType2["other"] = "other";
|
|
630
|
+
return EmbaddedContactType2;
|
|
631
|
+
})(EmbaddedContactType || {});
|
|
632
|
+
export {
|
|
633
|
+
DeliveryStatus,
|
|
634
|
+
EmbaddedContactType,
|
|
635
|
+
FeeeF,
|
|
636
|
+
OrderStatus,
|
|
637
|
+
PaymentStatus,
|
|
638
|
+
ProductStatus,
|
|
639
|
+
ProductType,
|
|
640
|
+
ShippingMethodPolicy,
|
|
641
|
+
ShippingMethodStatus,
|
|
642
|
+
StoreActionType,
|
|
643
|
+
StoreSubscriptionStatus,
|
|
644
|
+
StoreSubscriptionType,
|
|
645
|
+
VariantOptionType
|
|
646
|
+
};
|
|
647
|
+
//# sourceMappingURL=index.js.map
|