@hellena-sdk/hellena 1.0.6 → 1.0.7
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/README.md +277 -50
- package/dist/core/HellenaConnect.d.ts +27 -2
- package/dist/main.d.ts +13 -3
- package/dist/main.js +297 -38
- package/dist/resources/comment/comment.feature.d.ts +22 -0
- package/dist/resources/comment/comment.model.d.ts +3 -0
- package/dist/resources/comment/dto/comment.dto.d.ts +31 -0
- package/dist/resources/comment/service/comment.ser.d.ts +17 -0
- package/dist/resources/order/dto/order.dto.d.ts +57 -52
- package/dist/resources/order/order.feature.d.ts +12 -3
- package/dist/resources/order/order.model.d.ts +1 -2
- package/dist/resources/order/service/order.ser.d.ts +8 -3
- package/dist/resources/organization/dto/organization.dto.d.ts +0 -1
- package/dist/resources/organization/organization.feature.d.ts +4 -3
- package/dist/resources/organization/organization.model.d.ts +0 -1
- package/dist/resources/organization/service/organization.ser.d.ts +0 -1
- package/dist/resources/payment/dto/payment.dto.d.ts +14 -0
- package/dist/resources/payment/payment.feature.d.ts +10 -0
- package/dist/resources/payment/payment.model.d.ts +3 -0
- package/dist/resources/payment/service/payment.ser.d.ts +8 -0
- package/dist/resources/product/dto/product.dto.d.ts +39 -4
- package/dist/resources/product/product.feature.d.ts +7 -6
- package/dist/resources/product/product.model.d.ts +1 -2
- package/dist/resources/product/service/product.ser.d.ts +4 -4
- package/dist/resources/rating/dto/rating.dto.d.ts +25 -0
- package/dist/resources/rating/rating.feature.d.ts +19 -0
- package/dist/resources/rating/rating.model.d.ts +3 -0
- package/dist/resources/rating/service/rating.ser.d.ts +15 -0
- package/package.json +5 -3
- package/dist/core/HellenaConnect.d.ts.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/resources/order/dto/order.dto.d.ts.map +0 -1
- package/dist/resources/order/order.feature.d.ts.map +0 -1
- package/dist/resources/order/order.model.d.ts.map +0 -1
- package/dist/resources/order/service/order.ser.d.ts.map +0 -1
- package/dist/resources/organization/dto/organization.dto.d.ts.map +0 -1
- package/dist/resources/organization/organization.feature.d.ts.map +0 -1
- package/dist/resources/organization/organization.model.d.ts.map +0 -1
- package/dist/resources/organization/service/organization.ser.d.ts.map +0 -1
- package/dist/resources/product/dto/product.dto.d.ts.map +0 -1
- package/dist/resources/product/product.feature.d.ts.map +0 -1
- package/dist/resources/product/product.model.d.ts.map +0 -1
- package/dist/resources/product/service/product.ser.d.ts.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,22 +1,100 @@
|
|
|
1
1
|
// src/core/HellenaConnect.ts
|
|
2
|
+
class HellenaAPIError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
response;
|
|
5
|
+
path;
|
|
6
|
+
constructor(message, status, path, response) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "HellenaAPIError";
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.path = path;
|
|
11
|
+
this.response = response;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
2
15
|
class HellenaConnect {
|
|
3
16
|
apiKey;
|
|
4
17
|
apiUrl;
|
|
5
18
|
apiVersion;
|
|
6
|
-
|
|
19
|
+
timeout;
|
|
20
|
+
constructor(apiKey, options = {}) {
|
|
7
21
|
this.apiKey = apiKey;
|
|
8
|
-
|
|
9
|
-
|
|
22
|
+
if (!apiKey?.trim()) {
|
|
23
|
+
throw new Error("A API Key da Hellena é obrigatória.");
|
|
24
|
+
}
|
|
25
|
+
this.apiUrl = (options.apiUrl ?? "https://api.hellena.app").replace(/\/+$/, "");
|
|
26
|
+
this.apiVersion = (options.apiVersion ?? "v1").replace(/^\/+|\/+$/g, "");
|
|
27
|
+
this.timeout = options.timeout ?? 30000;
|
|
10
28
|
}
|
|
11
29
|
get apiEndpoint() {
|
|
12
30
|
return `${this.apiUrl}/${this.apiVersion}`;
|
|
13
31
|
}
|
|
14
32
|
getHeaders() {
|
|
15
33
|
return {
|
|
34
|
+
Accept: "application/json",
|
|
16
35
|
"Content-Type": "application/json",
|
|
17
36
|
"x-hellena-api-key": this.apiKey
|
|
18
37
|
};
|
|
19
38
|
}
|
|
39
|
+
async sendRestRequest(path, options = {}) {
|
|
40
|
+
const normalizedPath = path.replace(/^\/+/, "");
|
|
41
|
+
const url = new URL(`${this.apiEndpoint}/${normalizedPath}`);
|
|
42
|
+
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
43
|
+
if (value !== undefined && value !== null)
|
|
44
|
+
url.searchParams.set(key, String(value));
|
|
45
|
+
}
|
|
46
|
+
const controller = new AbortController;
|
|
47
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
48
|
+
const externalSignal = options.signal;
|
|
49
|
+
const abortFromExternal = () => controller.abort();
|
|
50
|
+
externalSignal?.addEventListener("abort", abortFromExternal, { once: true });
|
|
51
|
+
try {
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
method: options.method ?? "GET",
|
|
54
|
+
headers: { ...this.getHeaders(), ...options.headers },
|
|
55
|
+
...options.body !== undefined ? { body: JSON.stringify(options.body) } : {},
|
|
56
|
+
signal: externalSignal?.aborted ? externalSignal : controller.signal
|
|
57
|
+
});
|
|
58
|
+
const raw = await response.text();
|
|
59
|
+
let data = undefined;
|
|
60
|
+
if (raw) {
|
|
61
|
+
try {
|
|
62
|
+
data = JSON.parse(raw);
|
|
63
|
+
} catch {
|
|
64
|
+
data = raw;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const payload = data;
|
|
69
|
+
const message = Array.isArray(payload?.message) ? payload.message.join(", ") : typeof payload?.message === "string" ? payload.message : typeof payload?.error === "string" ? payload.error : `Pedido à Hellena falhou (${response.status} ${response.statusText})`;
|
|
70
|
+
throw new HellenaAPIError(message, response.status, url.toString(), data);
|
|
71
|
+
}
|
|
72
|
+
return data;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
if (error instanceof HellenaAPIError)
|
|
75
|
+
throw error;
|
|
76
|
+
if (controller.signal.aborted) {
|
|
77
|
+
throw new Error(`O pedido à Hellena excedeu o limite de ${this.timeout} ms ou foi cancelado.`, { cause: error });
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`Não foi possível comunicar com a API Hellena: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
80
|
+
} finally {
|
|
81
|
+
clearTimeout(timeoutId);
|
|
82
|
+
externalSignal?.removeEventListener("abort", abortFromExternal);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async graphql(query, variables) {
|
|
86
|
+
const response = await fetch(`${this.apiUrl}/graphql`, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: this.getHeaders(),
|
|
89
|
+
body: JSON.stringify({ query, variables })
|
|
90
|
+
});
|
|
91
|
+
const payload = await response.json();
|
|
92
|
+
if (!response.ok || payload.errors?.length) {
|
|
93
|
+
const message = payload.errors?.map((item) => item.message ?? "Erro GraphQL").join("; ") ?? `Pedido GraphQL falhou (${response.status})`;
|
|
94
|
+
throw new HellenaAPIError(message, response.status, `${this.apiUrl}/graphql`, payload);
|
|
95
|
+
}
|
|
96
|
+
return payload.data;
|
|
97
|
+
}
|
|
20
98
|
}
|
|
21
99
|
|
|
22
100
|
// src/resources/order/service/order.ser.ts
|
|
@@ -25,20 +103,20 @@ class OrderService {
|
|
|
25
103
|
constructor(connect) {
|
|
26
104
|
this.connect = connect;
|
|
27
105
|
}
|
|
28
|
-
|
|
29
|
-
|
|
106
|
+
make({ data }) {
|
|
107
|
+
return this.connect.sendRestRequest("orders/new", {
|
|
30
108
|
method: "POST",
|
|
31
|
-
|
|
32
|
-
body: JSON.stringify(data)
|
|
109
|
+
body: data
|
|
33
110
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
111
|
+
}
|
|
112
|
+
renewTransactionId(id) {
|
|
113
|
+
return this.connect.sendRestRequest(`orders/${encodeURIComponent(id)}/renew-transaction`, { method: "POST" });
|
|
114
|
+
}
|
|
115
|
+
getFrete(payload) {
|
|
116
|
+
return this.connect.sendRestRequest("orders/checkout/frete", { method: "POST", body: payload });
|
|
117
|
+
}
|
|
118
|
+
calculateCouponDiscount(payload) {
|
|
119
|
+
return this.connect.sendRestRequest("orders/checkout/coupon-discount", { method: "POST", body: payload });
|
|
42
120
|
}
|
|
43
121
|
}
|
|
44
122
|
|
|
@@ -48,9 +126,17 @@ class OrderFeature {
|
|
|
48
126
|
constructor(service) {
|
|
49
127
|
this.service = service;
|
|
50
128
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
129
|
+
createOrder(data) {
|
|
130
|
+
return this.service.make({ data });
|
|
131
|
+
}
|
|
132
|
+
renewOrderTransactionId(id) {
|
|
133
|
+
return this.service.renewTransactionId(id);
|
|
134
|
+
}
|
|
135
|
+
calculateShippingCost(data) {
|
|
136
|
+
return this.service.getFrete(data);
|
|
137
|
+
}
|
|
138
|
+
calculateCouponDiscount(data) {
|
|
139
|
+
return this.service.calculateCouponDiscount(data);
|
|
54
140
|
}
|
|
55
141
|
}
|
|
56
142
|
|
|
@@ -66,58 +152,231 @@ class ProductService {
|
|
|
66
152
|
constructor(connect) {
|
|
67
153
|
this.connect = connect;
|
|
68
154
|
}
|
|
69
|
-
|
|
70
|
-
|
|
155
|
+
getAllProducts(params = {}) {
|
|
156
|
+
return this.connect.sendRestRequest("products/all", { query: { page: params.page, limit: params.limit } });
|
|
157
|
+
}
|
|
158
|
+
searchProducts(params) {
|
|
159
|
+
const { ref, ...pagination } = params;
|
|
160
|
+
return this.connect.sendRestRequest("products/search", { query: { ref, ...pagination } });
|
|
161
|
+
}
|
|
162
|
+
getProductById(id) {
|
|
163
|
+
return this.connect.sendRestRequest(`products/${encodeURIComponent(id)}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// src/resources/product/product.feature.ts
|
|
168
|
+
class ProductFeature {
|
|
169
|
+
service;
|
|
170
|
+
constructor(service) {
|
|
171
|
+
this.service = service;
|
|
172
|
+
}
|
|
173
|
+
listProducts(params = {}) {
|
|
174
|
+
return this.service.getAllProducts(params);
|
|
175
|
+
}
|
|
176
|
+
searchProducts(params) {
|
|
177
|
+
return this.service.searchProducts(params);
|
|
178
|
+
}
|
|
179
|
+
getProductByIdOrSlug(id) {
|
|
180
|
+
return this.service.getProductById(id);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// src/resources/product/product.model.ts
|
|
185
|
+
function ProductModel(connect) {
|
|
186
|
+
const service = new ProductService(connect);
|
|
187
|
+
return new ProductFeature(service);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/resources/organization/service/organization.ser.ts
|
|
191
|
+
class OrganizationService {
|
|
192
|
+
connect;
|
|
193
|
+
constructor(connect) {
|
|
194
|
+
this.connect = connect;
|
|
195
|
+
}
|
|
196
|
+
async getInfo() {
|
|
197
|
+
const response = await fetch(`${this.connect["apiEndpoint"]}/organization/info`, {
|
|
71
198
|
method: "GET",
|
|
72
199
|
headers: this.connect["getHeaders"]()
|
|
73
200
|
});
|
|
74
201
|
if (!response.ok) {
|
|
75
|
-
throw new Error(`Erro ao buscar
|
|
202
|
+
throw new Error(`Erro ao buscar informações da organização (${response.status})`);
|
|
76
203
|
}
|
|
77
204
|
return response.json();
|
|
78
205
|
}
|
|
79
|
-
async
|
|
80
|
-
const response = await fetch(`${this.connect["apiEndpoint"]}/
|
|
206
|
+
async getLinks() {
|
|
207
|
+
const response = await fetch(`${this.connect["apiEndpoint"]}/organization/links`, {
|
|
81
208
|
method: "GET",
|
|
82
209
|
headers: this.connect["getHeaders"]()
|
|
83
210
|
});
|
|
84
211
|
if (!response.ok) {
|
|
85
|
-
throw new Error(`Erro ao buscar
|
|
212
|
+
throw new Error(`Erro ao buscar links da organização (${response.status})`);
|
|
86
213
|
}
|
|
87
214
|
return response.json();
|
|
88
215
|
}
|
|
89
216
|
}
|
|
90
217
|
|
|
91
|
-
// src/resources/
|
|
92
|
-
class
|
|
218
|
+
// src/resources/organization/organization.feature.ts
|
|
219
|
+
class OrganizationFeature {
|
|
93
220
|
service;
|
|
94
221
|
constructor(service) {
|
|
95
222
|
this.service = service;
|
|
96
223
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return products;
|
|
224
|
+
getOrganizationInfo() {
|
|
225
|
+
return this.service.getInfo();
|
|
100
226
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return product;
|
|
227
|
+
getOrganizationSocialLinks() {
|
|
228
|
+
return this.service.getLinks();
|
|
104
229
|
}
|
|
105
230
|
}
|
|
106
231
|
|
|
107
|
-
// src/resources/
|
|
108
|
-
function
|
|
109
|
-
const service = new
|
|
110
|
-
return new
|
|
232
|
+
// src/resources/organization/organization.model.ts
|
|
233
|
+
function OrganizationModel(connect) {
|
|
234
|
+
const service = new OrganizationService(connect);
|
|
235
|
+
return new OrganizationFeature(service);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/resources/comment/comment.feature.ts
|
|
239
|
+
class CommentFeature {
|
|
240
|
+
service;
|
|
241
|
+
constructor(service) {
|
|
242
|
+
this.service = service;
|
|
243
|
+
}
|
|
244
|
+
listProductComments(params) {
|
|
245
|
+
return this.service.findMany(params);
|
|
246
|
+
}
|
|
247
|
+
getCommentById(id) {
|
|
248
|
+
return this.service.findOne(id);
|
|
249
|
+
}
|
|
250
|
+
createComment(data) {
|
|
251
|
+
return this.service.create(data);
|
|
252
|
+
}
|
|
253
|
+
updateComment(id, data) {
|
|
254
|
+
return this.service.update(id, data);
|
|
255
|
+
}
|
|
256
|
+
deleteComment(id) {
|
|
257
|
+
return this.service.delete(id);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/resources/comment/service/comment.ser.ts
|
|
262
|
+
class CommentService {
|
|
263
|
+
connect;
|
|
264
|
+
constructor(connect) {
|
|
265
|
+
this.connect = connect;
|
|
266
|
+
}
|
|
267
|
+
findMany(params) {
|
|
268
|
+
return this.connect.sendRestRequest("comments", { query: params });
|
|
269
|
+
}
|
|
270
|
+
findOne(id) {
|
|
271
|
+
return this.connect.sendRestRequest(`comments/${encodeURIComponent(id)}`);
|
|
272
|
+
}
|
|
273
|
+
create(data) {
|
|
274
|
+
return this.connect.sendRestRequest("comments", { method: "POST", body: data });
|
|
275
|
+
}
|
|
276
|
+
update(id, data) {
|
|
277
|
+
return this.connect.sendRestRequest(`comments/${encodeURIComponent(id)}`, { method: "PATCH", body: data });
|
|
278
|
+
}
|
|
279
|
+
delete(id) {
|
|
280
|
+
return this.connect.sendRestRequest(`comments/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// src/resources/comment/comment.model.ts
|
|
285
|
+
function CommentModel(connect) {
|
|
286
|
+
return new CommentFeature(new CommentService(connect));
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/resources/rating/rating.feature.ts
|
|
290
|
+
class RatingFeature {
|
|
291
|
+
service;
|
|
292
|
+
constructor(service) {
|
|
293
|
+
this.service = service;
|
|
294
|
+
}
|
|
295
|
+
getProductRatingSummary(stockId) {
|
|
296
|
+
return this.service.summary(stockId);
|
|
297
|
+
}
|
|
298
|
+
getCustomerProductRating(params) {
|
|
299
|
+
return this.service.findOne(params);
|
|
300
|
+
}
|
|
301
|
+
createProductRating(data) {
|
|
302
|
+
return this.service.create(data);
|
|
303
|
+
}
|
|
304
|
+
deleteProductRating(id) {
|
|
305
|
+
return this.service.delete(id);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// src/resources/rating/service/rating.ser.ts
|
|
310
|
+
class RatingService {
|
|
311
|
+
connect;
|
|
312
|
+
constructor(connect) {
|
|
313
|
+
this.connect = connect;
|
|
314
|
+
}
|
|
315
|
+
summary(stockId) {
|
|
316
|
+
return this.connect.sendRestRequest(`ratings/products/${encodeURIComponent(stockId)}/summary`);
|
|
317
|
+
}
|
|
318
|
+
findOne(params) {
|
|
319
|
+
return this.connect.sendRestRequest(`ratings/products/${encodeURIComponent(params.stockId)}`, { query: { customerId: params.customerId } });
|
|
320
|
+
}
|
|
321
|
+
create(data) {
|
|
322
|
+
return this.connect.sendRestRequest("ratings", { method: "POST", body: data });
|
|
323
|
+
}
|
|
324
|
+
delete(id) {
|
|
325
|
+
return this.connect.sendRestRequest(`ratings/${encodeURIComponent(id)}`, { method: "DELETE" });
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// src/resources/rating/rating.model.ts
|
|
330
|
+
function RatingModel(connect) {
|
|
331
|
+
return new RatingFeature(new RatingService(connect));
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/resources/payment/payment.feature.ts
|
|
335
|
+
class PaymentFeature {
|
|
336
|
+
service;
|
|
337
|
+
constructor(service) {
|
|
338
|
+
this.service = service;
|
|
339
|
+
}
|
|
340
|
+
listAvailablePaymentMethods() {
|
|
341
|
+
return this.service.methods();
|
|
342
|
+
}
|
|
343
|
+
createWiPayPayment(data) {
|
|
344
|
+
return this.service.createWiPayPayment(data);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/resources/payment/service/payment.ser.ts
|
|
349
|
+
class PaymentService {
|
|
350
|
+
connect;
|
|
351
|
+
constructor(connect) {
|
|
352
|
+
this.connect = connect;
|
|
353
|
+
}
|
|
354
|
+
methods() {
|
|
355
|
+
return this.connect.sendRestRequest("payment/methods");
|
|
356
|
+
}
|
|
357
|
+
createWiPayPayment(data) {
|
|
358
|
+
return this.connect.sendRestRequest("payment/wipay/create", { method: "POST", body: data });
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// src/resources/payment/payment.model.ts
|
|
363
|
+
function PaymentModel(connect) {
|
|
364
|
+
return new PaymentFeature(new PaymentService(connect));
|
|
111
365
|
}
|
|
112
366
|
|
|
113
367
|
// src/main.ts
|
|
114
368
|
class HellenaClient extends HellenaConnect {
|
|
115
369
|
product = ProductModel(this);
|
|
116
370
|
order = OrderModel(this);
|
|
117
|
-
|
|
118
|
-
|
|
371
|
+
organization = OrganizationModel(this);
|
|
372
|
+
comment = CommentModel(this);
|
|
373
|
+
rating = RatingModel(this);
|
|
374
|
+
payment = PaymentModel(this);
|
|
375
|
+
constructor(apiKey, options = {}) {
|
|
376
|
+
super(apiKey, options);
|
|
119
377
|
}
|
|
120
378
|
}
|
|
121
379
|
export {
|
|
380
|
+
HellenaAPIError,
|
|
122
381
|
HellenaClient
|
|
123
382
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { AddCommentDTO, CommentDTO, PaginatedCommentsDTO, UpdateCommentDTO } from "./dto/comment.dto";
|
|
2
|
+
import type { CommentService } from "./service/comment.ser";
|
|
3
|
+
export declare class CommentFeature {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: CommentService);
|
|
6
|
+
/** Lista os comentários de um produto. */
|
|
7
|
+
listProductComments(params: {
|
|
8
|
+
stockId: string;
|
|
9
|
+
page?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
}): Promise<PaginatedCommentsDTO>;
|
|
12
|
+
/** Obtém um comentário pelo seu identificador. */
|
|
13
|
+
getCommentById(id: string): Promise<CommentDTO>;
|
|
14
|
+
/** Publica um comentário num produto. */
|
|
15
|
+
createComment(data: AddCommentDTO): Promise<CommentDTO>;
|
|
16
|
+
/** Atualiza o conteúdo ou as reações de um comentário. */
|
|
17
|
+
updateComment(id: string, data: UpdateCommentDTO): Promise<CommentDTO>;
|
|
18
|
+
/** Elimina um comentário pelo seu identificador. */
|
|
19
|
+
deleteComment(id: string): Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PaginatedResponse } from "../../product/dto/product.dto";
|
|
2
|
+
export interface CommentDTO {
|
|
3
|
+
id: string;
|
|
4
|
+
stockId: string;
|
|
5
|
+
content: string;
|
|
6
|
+
customerId?: string | null;
|
|
7
|
+
customerProfile?: string | null;
|
|
8
|
+
customerName?: string | null;
|
|
9
|
+
customerEmail?: string | null;
|
|
10
|
+
parentId?: string | null;
|
|
11
|
+
reactions?: string | null;
|
|
12
|
+
replies?: CommentDTO[];
|
|
13
|
+
parent?: CommentDTO | null;
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
updatedAt?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface AddCommentDTO {
|
|
18
|
+
stockId: string;
|
|
19
|
+
content: string;
|
|
20
|
+
customerId?: string;
|
|
21
|
+
customerProfile?: string;
|
|
22
|
+
customerName?: string;
|
|
23
|
+
customerEmail?: string;
|
|
24
|
+
parentId?: string;
|
|
25
|
+
reactions?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UpdateCommentDTO {
|
|
28
|
+
content?: string;
|
|
29
|
+
reactions?: string;
|
|
30
|
+
}
|
|
31
|
+
export type PaginatedCommentsDTO = PaginatedResponse<CommentDTO>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HellenaConnect } from "../../../core/HellenaConnect";
|
|
2
|
+
import type { AddCommentDTO, CommentDTO, PaginatedCommentsDTO, UpdateCommentDTO } from "../dto/comment.dto";
|
|
3
|
+
export declare class CommentService {
|
|
4
|
+
private readonly connect;
|
|
5
|
+
constructor(connect: HellenaConnect);
|
|
6
|
+
findMany(params: {
|
|
7
|
+
stockId: string;
|
|
8
|
+
page?: number;
|
|
9
|
+
limit?: number;
|
|
10
|
+
}): Promise<PaginatedCommentsDTO>;
|
|
11
|
+
findOne(id: string): Promise<CommentDTO>;
|
|
12
|
+
create(data: AddCommentDTO): Promise<CommentDTO>;
|
|
13
|
+
update(id: string, data: UpdateCommentDTO): Promise<CommentDTO>;
|
|
14
|
+
delete(id: string): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
@@ -1,71 +1,76 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
customerName?: string;
|
|
3
|
-
customerEmail?: string;
|
|
1
|
+
export interface DashboardOrderInfoDTO {
|
|
4
2
|
customerId?: string;
|
|
5
3
|
customerProfile?: string;
|
|
4
|
+
customerName?: string;
|
|
5
|
+
customerEmail?: string;
|
|
6
|
+
customerPhone?: string;
|
|
7
|
+
customerNIF?: string;
|
|
6
8
|
notes?: string;
|
|
7
9
|
lat?: number;
|
|
8
10
|
lng?: number;
|
|
9
|
-
origin?: string;
|
|
10
|
-
shippingMethod?: string;
|
|
11
|
-
paymentMethod?: string;
|
|
12
|
-
cupon?: string;
|
|
13
|
-
meta?: Record<string, any>;
|
|
14
11
|
address?: string;
|
|
15
|
-
items: Order_ItemsDTO[];
|
|
16
12
|
}
|
|
17
|
-
interface
|
|
13
|
+
export interface DashboardOrderItemDTO {
|
|
18
14
|
productId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
category?: string;
|
|
17
|
+
image?: string;
|
|
19
18
|
quantity: number;
|
|
19
|
+
size?: string;
|
|
20
|
+
color?: string;
|
|
21
|
+
material?: string;
|
|
22
|
+
model?: string;
|
|
23
|
+
gender?: string;
|
|
20
24
|
price: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
}
|
|
26
|
+
export interface OrderDTO {
|
|
27
|
+
info?: DashboardOrderInfoDTO;
|
|
28
|
+
items: DashboardOrderItemDTO[];
|
|
29
|
+
coupon?: string;
|
|
30
|
+
frete?: number;
|
|
31
|
+
localization?: string;
|
|
24
32
|
}
|
|
25
33
|
export interface Order_Return {
|
|
26
34
|
id: string;
|
|
35
|
+
invoice?: string | null;
|
|
36
|
+
invoice_link?: string | null;
|
|
27
37
|
organizationId: string;
|
|
28
|
-
createdAt: string;
|
|
29
|
-
updatedAt: any;
|
|
30
|
-
origin: string;
|
|
31
|
-
status: string;
|
|
32
38
|
amount: number;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
cupon: any;
|
|
40
|
-
meta: any;
|
|
41
|
-
orderInfo: OrderInfo;
|
|
42
|
-
items: Item[];
|
|
39
|
+
couponCode?: string | null;
|
|
40
|
+
couponDiscount?: number | null;
|
|
41
|
+
frete?: number | null;
|
|
42
|
+
status: string;
|
|
43
|
+
transactionId?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
43
45
|
}
|
|
44
|
-
export interface
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
customerEmail: string;
|
|
51
|
-
notes: any;
|
|
52
|
-
lat: string;
|
|
53
|
-
lng: string;
|
|
54
|
-
address: string;
|
|
55
|
-
createdAt: string;
|
|
56
|
-
updatedAt: any;
|
|
46
|
+
export interface GetFreteDTO {
|
|
47
|
+
localization?: string;
|
|
48
|
+
lat?: number;
|
|
49
|
+
long?: number;
|
|
50
|
+
coupon?: string;
|
|
51
|
+
items?: DashboardOrderItemDTO[];
|
|
57
52
|
}
|
|
58
|
-
export interface
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
export interface CouponDiscountDTO {
|
|
54
|
+
code: string;
|
|
55
|
+
items: DashboardOrderItemDTO[];
|
|
56
|
+
customerId?: string;
|
|
57
|
+
customerEmail?: string;
|
|
58
|
+
fretePrice?: number;
|
|
59
|
+
}
|
|
60
|
+
export interface FreteResponseDTO {
|
|
61
|
+
required: boolean;
|
|
66
62
|
price: number;
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
isFreeShipping: boolean;
|
|
64
|
+
message?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface CouponDiscountResponseDTO {
|
|
67
|
+
valid: boolean;
|
|
68
|
+
message?: string;
|
|
69
|
+
code?: string;
|
|
70
|
+
discountType?: string;
|
|
71
|
+
discountValue?: number;
|
|
72
|
+
discountAmount?: number;
|
|
73
|
+
isFreeShipping?: boolean;
|
|
74
|
+
subtotal?: number;
|
|
75
|
+
finalAmount?: number;
|
|
69
76
|
}
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=order.dto.d.ts.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CouponDiscountDTO, CouponDiscountResponseDTO, GetFreteDTO, FreteResponseDTO, OrderDTO, Order_Return } from "./dto/order.dto";
|
|
2
2
|
import type { OrderService } from "./service/order.ser";
|
|
3
3
|
export declare class OrderFeature {
|
|
4
4
|
private readonly service;
|
|
5
5
|
constructor(service: OrderService);
|
|
6
|
-
|
|
6
|
+
/** Cria uma encomenda através do serviço central de checkout Hellena. */
|
|
7
|
+
createOrder(data: OrderDTO): Promise<Order_Return>;
|
|
8
|
+
/** Renova o identificador de transação de uma encomenda existente. */
|
|
9
|
+
renewOrderTransactionId(id: string): Promise<{
|
|
10
|
+
id: string;
|
|
11
|
+
transactionId: string;
|
|
12
|
+
}>;
|
|
13
|
+
/** Calcula o custo de entrega para os artigos e a localização indicados. */
|
|
14
|
+
calculateShippingCost(data: GetFreteDTO): Promise<FreteResponseDTO>;
|
|
15
|
+
/** Calcula o desconto aplicável a um cupão e aos artigos indicados. */
|
|
16
|
+
calculateCouponDiscount(data: CouponDiscountDTO): Promise<CouponDiscountResponseDTO>;
|
|
7
17
|
}
|
|
8
|
-
//# sourceMappingURL=order.feature.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HellenaConnect } from "@//core/HellenaConnect";
|
|
2
1
|
import { OrderFeature } from "./order.feature";
|
|
2
|
+
import type { HellenaConnect } from "@/core/HellenaConnect";
|
|
3
3
|
export declare function OrderModel(connect: HellenaConnect): OrderFeature;
|
|
4
|
-
//# sourceMappingURL=order.model.d.ts.map
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import type { HellenaConnect } from "
|
|
2
|
-
import type {
|
|
1
|
+
import type { HellenaConnect } from "../../../core/HellenaConnect";
|
|
2
|
+
import type { CouponDiscountDTO, CouponDiscountResponseDTO, GetFreteDTO, FreteResponseDTO, OrderDTO, Order_Return } from "../dto/order.dto";
|
|
3
3
|
export declare class OrderService {
|
|
4
4
|
private readonly connect;
|
|
5
5
|
constructor(connect: HellenaConnect);
|
|
6
6
|
make({ data }: {
|
|
7
7
|
data: OrderDTO;
|
|
8
8
|
}): Promise<Order_Return>;
|
|
9
|
+
renewTransactionId(id: string): Promise<{
|
|
10
|
+
id: string;
|
|
11
|
+
transactionId: string;
|
|
12
|
+
}>;
|
|
13
|
+
getFrete(payload: GetFreteDTO): Promise<FreteResponseDTO>;
|
|
14
|
+
calculateCouponDiscount(payload: CouponDiscountDTO): Promise<CouponDiscountResponseDTO>;
|
|
9
15
|
}
|
|
10
|
-
//# sourceMappingURL=order.ser.d.ts.map
|
|
@@ -3,7 +3,8 @@ import { OrganizationService } from "./service/organization.ser";
|
|
|
3
3
|
export declare class OrganizationFeature {
|
|
4
4
|
private readonly service;
|
|
5
5
|
constructor(service: OrganizationService);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/** Obtém as informações públicas da organização associada à API Key. */
|
|
7
|
+
getOrganizationInfo(): Promise<OrganizationInfoResponseDTO>;
|
|
8
|
+
/** Obtém os links sociais configurados pela organização. */
|
|
9
|
+
getOrganizationSocialLinks(): Promise<OrganizationLinkDTO[]>;
|
|
8
10
|
}
|
|
9
|
-
//# sourceMappingURL=organization.feature.d.ts.map
|