@hellena-sdk/hellena 1.0.5 → 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 +274 -27
- package/dist/core/HellenaConnect.d.ts +32 -10
- package/dist/main.d.ts +15 -6
- package/dist/main.js +382 -13
- 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 +62 -15
- package/dist/resources/order/order.feature.d.ts +13 -4
- package/dist/resources/order/order.model.d.ts +2 -3
- 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 +6 -5
- package/dist/resources/organization/organization.model.d.ts +0 -1
- package/dist/resources/organization/service/organization.ser.d.ts +2 -3
- 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 +8 -7
- package/dist/resources/product/product.model.d.ts +2 -3
- 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 +34 -28
- package/LICENSE +0 -21
- package/dist/core/HellenaConnect.d.ts.map +0 -1
- package/dist/core/HellenaConnect.js +0 -15
- package/dist/core/HellenaConnect.js.map +0 -1
- package/dist/libs/graphql-client.ts.d.ts +0 -2
- package/dist/libs/graphql-client.ts.d.ts.map +0 -1
- package/dist/libs/graphql-client.ts.js +0 -3
- package/dist/libs/graphql-client.ts.js.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/resources/order/dto/order.dto.d.ts.map +0 -1
- package/dist/resources/order/dto/order.dto.js +0 -2
- package/dist/resources/order/dto/order.dto.js.map +0 -1
- package/dist/resources/order/order.feature.d.ts.map +0 -1
- package/dist/resources/order/order.feature.js +0 -7
- package/dist/resources/order/order.feature.js.map +0 -1
- package/dist/resources/order/order.model.d.ts.map +0 -1
- package/dist/resources/order/order.model.js +0 -7
- package/dist/resources/order/order.model.js.map +0 -1
- package/dist/resources/order/service/order.ser.d.ts.map +0 -1
- package/dist/resources/order/service/order.ser.js +0 -21
- package/dist/resources/order/service/order.ser.js.map +0 -1
- package/dist/resources/organization/dto/organization.dto.d.ts.map +0 -1
- package/dist/resources/organization/dto/organization.dto.js +0 -2
- package/dist/resources/organization/dto/organization.dto.js.map +0 -1
- package/dist/resources/organization/organization.feature.d.ts.map +0 -1
- package/dist/resources/organization/organization.feature.js +0 -9
- package/dist/resources/organization/organization.feature.js.map +0 -1
- package/dist/resources/organization/organization.model.d.ts.map +0 -1
- package/dist/resources/organization/organization.model.js +0 -7
- package/dist/resources/organization/organization.model.js.map +0 -1
- package/dist/resources/organization/service/organization.ser.d.ts.map +0 -1
- package/dist/resources/organization/service/organization.ser.js +0 -26
- package/dist/resources/organization/service/organization.ser.js.map +0 -1
- package/dist/resources/product/dto/product.dto.d.ts.map +0 -1
- package/dist/resources/product/dto/product.dto.js +0 -2
- package/dist/resources/product/dto/product.dto.js.map +0 -1
- package/dist/resources/product/product.feature.d.ts.map +0 -1
- package/dist/resources/product/product.feature.js +0 -8
- package/dist/resources/product/product.feature.js.map +0 -1
- package/dist/resources/product/product.model.d.ts.map +0 -1
- package/dist/resources/product/product.model.js +0 -7
- package/dist/resources/product/product.model.js.map +0 -1
- package/dist/resources/product/service/product.ser.d.ts.map +0 -1
- package/dist/resources/product/service/product.ser.js +0 -26
- package/dist/resources/product/service/product.ser.js.map +0 -1
- package/dist/test.d.ts +0 -2
- package/dist/test.d.ts.map +0 -1
- package/dist/test.js +0 -38
- package/dist/test.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -1,13 +1,382 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
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
|
+
|
|
15
|
+
class HellenaConnect {
|
|
16
|
+
apiKey;
|
|
17
|
+
apiUrl;
|
|
18
|
+
apiVersion;
|
|
19
|
+
timeout;
|
|
20
|
+
constructor(apiKey, options = {}) {
|
|
21
|
+
this.apiKey = apiKey;
|
|
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;
|
|
28
|
+
}
|
|
29
|
+
get apiEndpoint() {
|
|
30
|
+
return `${this.apiUrl}/${this.apiVersion}`;
|
|
31
|
+
}
|
|
32
|
+
getHeaders() {
|
|
33
|
+
return {
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
"x-hellena-api-key": this.apiKey
|
|
37
|
+
};
|
|
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
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/resources/order/service/order.ser.ts
|
|
101
|
+
class OrderService {
|
|
102
|
+
connect;
|
|
103
|
+
constructor(connect) {
|
|
104
|
+
this.connect = connect;
|
|
105
|
+
}
|
|
106
|
+
make({ data }) {
|
|
107
|
+
return this.connect.sendRestRequest("orders/new", {
|
|
108
|
+
method: "POST",
|
|
109
|
+
body: data
|
|
110
|
+
});
|
|
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 });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// src/resources/order/order.feature.ts
|
|
124
|
+
class OrderFeature {
|
|
125
|
+
service;
|
|
126
|
+
constructor(service) {
|
|
127
|
+
this.service = service;
|
|
128
|
+
}
|
|
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);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// src/resources/order/order.model.ts
|
|
144
|
+
function OrderModel(connect) {
|
|
145
|
+
const service = new OrderService(connect);
|
|
146
|
+
return new OrderFeature(service);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/resources/product/service/product.ser.ts
|
|
150
|
+
class ProductService {
|
|
151
|
+
connect;
|
|
152
|
+
constructor(connect) {
|
|
153
|
+
this.connect = connect;
|
|
154
|
+
}
|
|
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`, {
|
|
198
|
+
method: "GET",
|
|
199
|
+
headers: this.connect["getHeaders"]()
|
|
200
|
+
});
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
throw new Error(`Erro ao buscar informações da organização (${response.status})`);
|
|
203
|
+
}
|
|
204
|
+
return response.json();
|
|
205
|
+
}
|
|
206
|
+
async getLinks() {
|
|
207
|
+
const response = await fetch(`${this.connect["apiEndpoint"]}/organization/links`, {
|
|
208
|
+
method: "GET",
|
|
209
|
+
headers: this.connect["getHeaders"]()
|
|
210
|
+
});
|
|
211
|
+
if (!response.ok) {
|
|
212
|
+
throw new Error(`Erro ao buscar links da organização (${response.status})`);
|
|
213
|
+
}
|
|
214
|
+
return response.json();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/resources/organization/organization.feature.ts
|
|
219
|
+
class OrganizationFeature {
|
|
220
|
+
service;
|
|
221
|
+
constructor(service) {
|
|
222
|
+
this.service = service;
|
|
223
|
+
}
|
|
224
|
+
getOrganizationInfo() {
|
|
225
|
+
return this.service.getInfo();
|
|
226
|
+
}
|
|
227
|
+
getOrganizationSocialLinks() {
|
|
228
|
+
return this.service.getLinks();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
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));
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/main.ts
|
|
368
|
+
class HellenaClient extends HellenaConnect {
|
|
369
|
+
product = ProductModel(this);
|
|
370
|
+
order = OrderModel(this);
|
|
371
|
+
organization = OrganizationModel(this);
|
|
372
|
+
comment = CommentModel(this);
|
|
373
|
+
rating = RatingModel(this);
|
|
374
|
+
payment = PaymentModel(this);
|
|
375
|
+
constructor(apiKey, options = {}) {
|
|
376
|
+
super(apiKey, options);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
export {
|
|
380
|
+
HellenaAPIError,
|
|
381
|
+
HellenaClient
|
|
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,29 +1,76 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
interface Order_InfoDTO {
|
|
1
|
+
export interface DashboardOrderInfoDTO {
|
|
2
|
+
customerId?: string;
|
|
3
|
+
customerProfile?: string;
|
|
6
4
|
customerName?: string;
|
|
7
5
|
customerEmail?: string;
|
|
6
|
+
customerPhone?: string;
|
|
7
|
+
customerNIF?: string;
|
|
8
8
|
notes?: string;
|
|
9
9
|
lat?: number;
|
|
10
10
|
lng?: number;
|
|
11
11
|
address?: string;
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
export interface DashboardOrderItemDTO {
|
|
14
14
|
productId: string;
|
|
15
|
+
name: string;
|
|
16
|
+
category?: string;
|
|
17
|
+
image?: string;
|
|
15
18
|
quantity: number;
|
|
19
|
+
size?: string;
|
|
20
|
+
color?: string;
|
|
21
|
+
material?: string;
|
|
22
|
+
model?: string;
|
|
23
|
+
gender?: string;
|
|
16
24
|
price: number;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
}
|
|
26
|
+
export interface OrderDTO {
|
|
27
|
+
info?: DashboardOrderInfoDTO;
|
|
28
|
+
items: DashboardOrderItemDTO[];
|
|
29
|
+
coupon?: string;
|
|
30
|
+
frete?: number;
|
|
31
|
+
localization?: string;
|
|
20
32
|
}
|
|
21
33
|
export interface Order_Return {
|
|
22
34
|
id: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
invoice?: string | null;
|
|
36
|
+
invoice_link?: string | null;
|
|
37
|
+
organizationId: string;
|
|
38
|
+
amount: number;
|
|
39
|
+
couponCode?: string | null;
|
|
40
|
+
couponDiscount?: number | null;
|
|
41
|
+
frete?: number | null;
|
|
42
|
+
status: string;
|
|
43
|
+
transactionId?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
export interface GetFreteDTO {
|
|
47
|
+
localization?: string;
|
|
48
|
+
lat?: number;
|
|
49
|
+
long?: number;
|
|
50
|
+
coupon?: string;
|
|
51
|
+
items?: DashboardOrderItemDTO[];
|
|
52
|
+
}
|
|
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;
|
|
62
|
+
price: number;
|
|
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;
|
|
27
76
|
}
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=order.dto.d.ts.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { OrderService } from "./service/order.ser
|
|
1
|
+
import type { CouponDiscountDTO, CouponDiscountResponseDTO, GetFreteDTO, FreteResponseDTO, OrderDTO, Order_Return } from "./dto/order.dto";
|
|
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
|
|
2
|
-
import {
|
|
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
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { OrganizationInfoResponseDTO, OrganizationLinkDTO } from "./dto/organization.dto
|
|
2
|
-
import { OrganizationService } from "./service/organization.ser
|
|
1
|
+
import type { OrganizationInfoResponseDTO, OrganizationLinkDTO } from "./dto/organization.dto";
|
|
2
|
+
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
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { HellenaConnect } from "
|
|
2
|
-
import type { OrganizationInfoResponseDTO, OrganizationLinkDTO } from "../dto/organization.dto
|
|
1
|
+
import type { HellenaConnect } from "@//core/HellenaConnect";
|
|
2
|
+
import type { OrganizationInfoResponseDTO, OrganizationLinkDTO } from "../dto/organization.dto";
|
|
3
3
|
export declare class OrganizationService {
|
|
4
4
|
private readonly connect;
|
|
5
5
|
constructor(connect: HellenaConnect);
|
|
6
6
|
getInfo(): Promise<OrganizationInfoResponseDTO>;
|
|
7
7
|
getLinks(): Promise<OrganizationLinkDTO[]>;
|
|
8
8
|
}
|
|
9
|
-
//# sourceMappingURL=organization.ser.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PaymentMethodDTO {
|
|
2
|
+
id: string;
|
|
3
|
+
method: string;
|
|
4
|
+
testMode: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface CreateWiPayPaymentDTO {
|
|
7
|
+
customer: string;
|
|
8
|
+
reference: string;
|
|
9
|
+
failure_url: string;
|
|
10
|
+
success_url: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CreateWiPayPaymentResponseDTO {
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateWiPayPaymentDTO, CreateWiPayPaymentResponseDTO, PaymentMethodDTO } from "./dto/payment.dto";
|
|
2
|
+
import type { PaymentService } from "./service/payment.ser";
|
|
3
|
+
export declare class PaymentFeature {
|
|
4
|
+
private readonly service;
|
|
5
|
+
constructor(service: PaymentService);
|
|
6
|
+
/** Lista os métodos de pagamento configurados para a organização. */
|
|
7
|
+
listAvailablePaymentMethods(): Promise<PaymentMethodDTO[]>;
|
|
8
|
+
/** Cria uma sessão de pagamento WiPay e devolve o URL para continuar o fluxo. */
|
|
9
|
+
createWiPayPayment(data: CreateWiPayPaymentDTO): Promise<CreateWiPayPaymentResponseDTO>;
|
|
10
|
+
}
|