@infrab4a/connect-nestjs 3.0.0-alpha.0 → 3.0.0-alpha.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.
Files changed (98) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.default.js +1 -0
  3. package/index.cjs.js +1334 -0
  4. package/index.cjs.mjs +2 -0
  5. package/index.esm.js +1317 -0
  6. package/package.json +13 -3
  7. package/src/consts/es-config.const.d.ts +1 -0
  8. package/src/consts/hasura-options.const.d.ts +1 -0
  9. package/src/consts/index.d.ts +4 -0
  10. package/src/consts/storage.const.d.ts +1 -0
  11. package/src/consts/vertex-config.const.d.ts +1 -0
  12. package/src/index.d.ts +7 -0
  13. package/src/infra/elasticsearch/adapters/index.d.ts +1 -0
  14. package/src/infra/elasticsearch/adapters/native-elasticsearch-adapter.d.ts +19 -0
  15. package/src/infra/elasticsearch/index.d.ts +1 -0
  16. package/src/infra/firebase/firestore/index.d.ts +2 -0
  17. package/src/infra/firebase/firestore/services/connect-collection-reference.d.ts +19 -0
  18. package/src/infra/firebase/firestore/services/connect-collection.service.d.ts +32 -0
  19. package/src/infra/firebase/firestore/services/connect-document-reference.d.ts +11 -0
  20. package/src/infra/firebase/firestore/services/connect-document.service.d.ts +17 -0
  21. package/src/infra/firebase/firestore/services/connect-firestore.d.ts +7 -0
  22. package/src/infra/firebase/firestore/services/connect-firestore.service.d.ts +8 -0
  23. package/src/infra/firebase/firestore/services/index.d.ts +6 -0
  24. package/src/infra/firebase/firestore/types/connect-query-snapshot.type.d.ts +4 -0
  25. package/src/infra/firebase/firestore/types/index.d.ts +1 -0
  26. package/src/infra/firebase/firestore/vo/connect-base-document-snapshot.vo.d.ts +12 -0
  27. package/src/infra/firebase/firestore/vo/index.d.ts +1 -0
  28. package/src/infra/firebase/index.d.ts +1 -0
  29. package/src/infra/index.d.ts +4 -0
  30. package/src/infra/pagarme/adapters/index.d.ts +3 -0
  31. package/src/infra/pagarme/adapters/pagarme-bank-slip-api.adapter.d.ts +9 -0
  32. package/src/infra/pagarme/adapters/pagarme-card-api.adapter.d.ts +21 -0
  33. package/src/infra/pagarme/adapters/pagarme-pix-api.adapter.d.ts +8 -0
  34. package/src/infra/pagarme/index.d.ts +1 -0
  35. package/src/infra/vertex-ai/adapters/discovery-engine-adapter.d.ts +17 -0
  36. package/src/infra/vertex-ai/adapters/index.d.ts +1 -0
  37. package/src/infra/vertex-ai/helpers/index.d.ts +1 -0
  38. package/src/infra/vertex-ai/helpers/product-vertex-ai.helper.d.ts +7 -0
  39. package/src/infra/vertex-ai/index.d.ts +3 -0
  40. package/src/infra/vertex-ai/types/index.d.ts +2 -0
  41. package/src/infra/vertex-ai/types/vertex-config.d.ts +23 -0
  42. package/src/infra/vertex-ai/types/vertex-search-result.d.ts +18 -0
  43. package/src/nest-connect.module.d.ts +13 -0
  44. package/src/nest-elastic-search.module.d.ts +5 -0
  45. package/src/nest-firestore.module.d.ts +10 -0
  46. package/src/nest-hasura-graphql.module.d.ts +13 -0
  47. package/src/nest-storage.module.d.ts +2 -0
  48. package/src/nest-vertex-ai-search.module.d.ts +5 -0
  49. package/eslint.config.js +0 -17
  50. package/project.json +0 -49
  51. package/rollup.config.js +0 -17
  52. package/src/consts/es-config.const.ts +0 -1
  53. package/src/consts/hasura-options.const.ts +0 -1
  54. package/src/consts/index.ts +0 -4
  55. package/src/consts/storage.const.ts +0 -1
  56. package/src/consts/vertex-config.const.ts +0 -1
  57. package/src/index.ts +0 -7
  58. package/src/infra/elasticsearch/adapters/index.ts +0 -1
  59. package/src/infra/elasticsearch/adapters/native-elasticsearch-adapter.ts +0 -137
  60. package/src/infra/elasticsearch/index.ts +0 -1
  61. package/src/infra/firebase/firestore/index.ts +0 -2
  62. package/src/infra/firebase/firestore/services/connect-collection-reference.ts +0 -27
  63. package/src/infra/firebase/firestore/services/connect-collection.service.ts +0 -137
  64. package/src/infra/firebase/firestore/services/connect-document-reference.ts +0 -12
  65. package/src/infra/firebase/firestore/services/connect-document.service.ts +0 -51
  66. package/src/infra/firebase/firestore/services/connect-firestore.service.ts +0 -24
  67. package/src/infra/firebase/firestore/services/connect-firestore.ts +0 -9
  68. package/src/infra/firebase/firestore/services/index.ts +0 -6
  69. package/src/infra/firebase/firestore/types/connect-query-snapshot.type.ts +0 -6
  70. package/src/infra/firebase/firestore/types/index.ts +0 -1
  71. package/src/infra/firebase/firestore/vo/connect-base-document-snapshot.vo.ts +0 -27
  72. package/src/infra/firebase/firestore/vo/index.ts +0 -1
  73. package/src/infra/firebase/index.ts +0 -1
  74. package/src/infra/index.ts +0 -4
  75. package/src/infra/pagarme/adapters/index.ts +0 -3
  76. package/src/infra/pagarme/adapters/pagarme-bank-slip-api.adapter.ts +0 -96
  77. package/src/infra/pagarme/adapters/pagarme-card-api.adapter.ts +0 -226
  78. package/src/infra/pagarme/adapters/pagarme-pix-api.adapter.ts +0 -69
  79. package/src/infra/pagarme/index.ts +0 -1
  80. package/src/infra/vertex-ai/adapters/discovery-engine-adapter.ts +0 -148
  81. package/src/infra/vertex-ai/adapters/index.ts +0 -1
  82. package/src/infra/vertex-ai/helpers/index.ts +0 -1
  83. package/src/infra/vertex-ai/helpers/product-vertex-ai.helper.ts +0 -52
  84. package/src/infra/vertex-ai/index.ts +0 -3
  85. package/src/infra/vertex-ai/types/index.ts +0 -2
  86. package/src/infra/vertex-ai/types/vertex-config.ts +0 -23
  87. package/src/infra/vertex-ai/types/vertex-search-result.ts +0 -17
  88. package/src/nest-connect.module.ts +0 -36
  89. package/src/nest-elastic-search.module.ts +0 -26
  90. package/src/nest-firestore.module.ts +0 -363
  91. package/src/nest-hasura-graphql.module.ts +0 -227
  92. package/src/nest-storage.module.ts +0 -16
  93. package/src/nest-vertex-ai-search.module.ts +0 -26
  94. package/src/types/pagarme.d.ts +0 -25
  95. package/tsconfig.json +0 -15
  96. package/tsconfig.lib.json +0 -7
  97. package/tsconfig.lib.prod.json +0 -10
  98. package/tsconfig.spec.json +0 -17
package/index.cjs.js ADDED
@@ -0,0 +1,1334 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var elasticsearch = require('@elastic/elasticsearch');
6
+ var connect = require('@infrab4a/connect');
7
+ var common = require('@nestjs/common');
8
+ var firestore = require('firebase-admin/firestore');
9
+ var pagarme = require('pagarme');
10
+ var discoveryengine = require('@google-cloud/discoveryengine');
11
+ var v1beta = require('@google-cloud/discoveryengine/build/src/v1beta');
12
+ var nestjsFirebase = require('nestjs-firebase');
13
+
14
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
+
16
+ var pagarme__default = /*#__PURE__*/_interopDefaultLegacy(pagarme);
17
+
18
+ const ES_CONFIG = 'ES_CONFIG';
19
+
20
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
21
+
22
+ const FIREBASE_STORAGE = 'FIREBASE_STORAGE';
23
+
24
+ const VERTEX_CONFIG = 'VERTEX_CONFIG';
25
+
26
+ /******************************************************************************
27
+ Copyright (c) Microsoft Corporation.
28
+
29
+ Permission to use, copy, modify, and/or distribute this software for any
30
+ purpose with or without fee is hereby granted.
31
+
32
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
33
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
34
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
35
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
36
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
37
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
38
+ PERFORMANCE OF THIS SOFTWARE.
39
+ ***************************************************************************** */
40
+
41
+ function __decorate(decorators, target, key, desc) {
42
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
43
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
44
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
45
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
46
+ }
47
+
48
+ function __param(paramIndex, decorator) {
49
+ return function (target, key) { decorator(target, key, paramIndex); }
50
+ }
51
+
52
+ function __metadata(metadataKey, metadataValue) {
53
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
54
+ }
55
+
56
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
57
+ var e = new Error(message);
58
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
59
+ };
60
+
61
+ exports.NativeElasticSearchAdapter = class NativeElasticSearchAdapter {
62
+ constructor(config) {
63
+ this.logger = connect.DebugHelper.from(this);
64
+ try {
65
+ this.client = !connect.isEmpty(config.cloud.id) && !connect.isEmpty(config.auth.apiKey) && new elasticsearch.Client(config);
66
+ }
67
+ catch (error) {
68
+ this.logger.error({ req: config, res: error });
69
+ throw error;
70
+ }
71
+ }
72
+ async get(index, id) {
73
+ const logger = this.logger.with('get');
74
+ const req = { index, id };
75
+ try {
76
+ const data = await this.client.get({ index, id });
77
+ logger.log({ req, res: data });
78
+ return data._source;
79
+ }
80
+ catch (error) {
81
+ const message = error instanceof Error ? error.message : `${index}/${id} not found`;
82
+ logger.log({ req, res: error });
83
+ throw new connect.NotFoundError(message);
84
+ }
85
+ }
86
+ async query(index, query) {
87
+ const logger = this.logger.with('query');
88
+ const params = {
89
+ index,
90
+ query,
91
+ };
92
+ try {
93
+ const result = await this.client.search(params);
94
+ const res = {
95
+ total: result.hits.total,
96
+ hits: result.hits.hits,
97
+ };
98
+ logger.log({ req: params, res });
99
+ return res;
100
+ }
101
+ catch (error) {
102
+ logger.error({ req: params, res: error });
103
+ throw error;
104
+ }
105
+ }
106
+ async save(index, data) {
107
+ const logger = this.logger.with('save');
108
+ const req = {
109
+ index,
110
+ id: data.identifiersFields.length > 1
111
+ ? JSON.stringify(data.identifier)
112
+ : Object.values(data.identifier).shift().toString(),
113
+ document: data.toPlain(),
114
+ };
115
+ try {
116
+ const res = await this.client.index(req);
117
+ logger.log({ req, res });
118
+ }
119
+ catch (error) {
120
+ logger.error({ req, res: error });
121
+ throw error;
122
+ }
123
+ }
124
+ async update(index, id, data) {
125
+ const logger = this.logger.with('update');
126
+ const req = {
127
+ index,
128
+ id,
129
+ doc: data,
130
+ };
131
+ try {
132
+ await this.client.update(req);
133
+ logger.log({ req, res: undefined });
134
+ }
135
+ catch (error) {
136
+ logger.error({ req, res: error });
137
+ throw error;
138
+ }
139
+ }
140
+ async delete(index, id) {
141
+ const logger = this.logger.with('delete');
142
+ const req = {
143
+ index,
144
+ id,
145
+ };
146
+ try {
147
+ await this.client.delete(req);
148
+ logger.log({ req, res: undefined });
149
+ }
150
+ catch (error) {
151
+ logger.error({ req, res: error });
152
+ throw error;
153
+ }
154
+ }
155
+ };
156
+ exports.NativeElasticSearchAdapter = __decorate([
157
+ common.Injectable(),
158
+ __param(0, common.Inject(ES_CONFIG)),
159
+ __metadata("design:paramtypes", [Object])
160
+ ], exports.NativeElasticSearchAdapter);
161
+
162
+ class ConnectBaseDocumentSnapshot {
163
+ constructor(connectDocumentSnapshot) {
164
+ this.connectDocumentSnapshot = connectDocumentSnapshot;
165
+ this.id = connectDocumentSnapshot.id;
166
+ }
167
+ isNotEmpty() {
168
+ return this.connectDocumentSnapshot.exists;
169
+ }
170
+ data(_options) {
171
+ return this.connectDocumentSnapshot.data();
172
+ }
173
+ get(fieldPath) {
174
+ return this.connectDocumentSnapshot.get(fieldPath);
175
+ }
176
+ }
177
+
178
+ class ConnectDocumentService {
179
+ constructor(path, firestore) {
180
+ this.path = path;
181
+ this.firestore = firestore;
182
+ this.reference = this.firestore.doc(this.path).withConverter({
183
+ toFirestore: (data) => data,
184
+ fromFirestore: (snapshot) => {
185
+ return Object.assign({ id: snapshot.id }, snapshot.data());
186
+ },
187
+ });
188
+ }
189
+ async get() {
190
+ return new ConnectBaseDocumentSnapshot(await this.reference.get());
191
+ }
192
+ getId() {
193
+ return this.reference.id;
194
+ }
195
+ async save(data) {
196
+ if (this.reference)
197
+ this.reference.update(data);
198
+ else
199
+ await this.reference.set(data);
200
+ return this;
201
+ }
202
+ async delete() {
203
+ await this.reference.delete();
204
+ }
205
+ withConverter(params) {
206
+ this.reference = this.reference.withConverter({
207
+ toFirestore: (data) => params.toFirestore(data),
208
+ fromFirestore: (snapshot, options) => params.fromFirestore(new ConnectBaseDocumentSnapshot(snapshot), options),
209
+ });
210
+ return this;
211
+ }
212
+ }
213
+
214
+ class ConnectCollectionService {
215
+ constructor(path, firestore) {
216
+ this.firestore = firestore;
217
+ this.reference = firestore.collection(path).withConverter({
218
+ toFirestore: (data) => data,
219
+ fromFirestore: (snapshot) => {
220
+ return Object.assign({ id: snapshot.id }, snapshot.data());
221
+ },
222
+ });
223
+ }
224
+ async add(data, id) {
225
+ const newDoc = await this.save(data, id);
226
+ return new ConnectDocumentService(newDoc.path, this.firestore).withConverter(this.converter);
227
+ }
228
+ async getDocs() {
229
+ if (this.startingAt)
230
+ this.limitBy += this.startingAt;
231
+ let query = this.query ? this.query : this.reference;
232
+ query = this.orderBy ? query.orderBy(this.orderBy.fieldPath, this.orderBy.directionStr) : query;
233
+ query = this.limitBy ? query.limit(this.limitBy) : query;
234
+ return query.get().then((docs) => {
235
+ const docsPaginated = this.startingAt ? docs.docs.slice(this.startingAt, this.limitBy) : docs.docs;
236
+ return {
237
+ empty: Boolean(docsPaginated.length),
238
+ size: docsPaginated.length,
239
+ docs: docsPaginated.map((doc) => new ConnectBaseDocumentSnapshot(doc)),
240
+ };
241
+ });
242
+ }
243
+ getDoc(id) {
244
+ return new ConnectDocumentService(`${this.reference.path}/${id}`, this.firestore).withConverter(this.converter);
245
+ }
246
+ where(fieldPath, opStr, value) {
247
+ this.query = this.query ? this.query.where(fieldPath, opStr, value) : this.reference.where(fieldPath, opStr, value);
248
+ return this;
249
+ }
250
+ order(attribute, order) {
251
+ this.orderBy = { fieldPath: attribute, directionStr: order };
252
+ return this;
253
+ }
254
+ limit(quantity) {
255
+ this.limitBy = quantity;
256
+ return this;
257
+ }
258
+ offset(offsetBy) {
259
+ this.offsetBy = offsetBy;
260
+ return this;
261
+ }
262
+ fromStartAt(startingAt) {
263
+ this.startingAt = startingAt;
264
+ return this;
265
+ }
266
+ fromStartAfter(startingAt) {
267
+ this.startingAfter = startingAt;
268
+ return this;
269
+ }
270
+ withConverter(params) {
271
+ this.converter = params;
272
+ this.reference = this.reference.withConverter({
273
+ toFirestore: (data) => params.toFirestore(data),
274
+ fromFirestore: (snapshot, options) => params.fromFirestore(new ConnectBaseDocumentSnapshot(snapshot), options),
275
+ });
276
+ return this;
277
+ }
278
+ async save(data, id) {
279
+ if (connect.isEmpty(id))
280
+ return this.reference.add(data);
281
+ const docRef = this.reference.doc(id);
282
+ await docRef.set(data);
283
+ return docRef;
284
+ }
285
+ }
286
+
287
+ exports.ConnectFirestoreService = class ConnectFirestoreService {
288
+ constructor(firestore) {
289
+ this.firestore = firestore;
290
+ }
291
+ getCollection(path) {
292
+ return new ConnectCollectionService(path, this.firestore);
293
+ }
294
+ getDocument(path) {
295
+ return new ConnectDocumentService(path, this.firestore);
296
+ }
297
+ };
298
+ exports.ConnectFirestoreService = __decorate([
299
+ common.Injectable(),
300
+ __metadata("design:paramtypes", [firestore.Firestore])
301
+ ], exports.ConnectFirestoreService);
302
+
303
+ class PagarmeBankSlipAPIAdapter {
304
+ constructor(credentials, paymentRepository) {
305
+ this.credentials = credentials;
306
+ this.paymentRepository = paymentRepository;
307
+ }
308
+ async pay(checkout) {
309
+ try {
310
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
311
+ const payload = this.createBoletoPayment(checkout);
312
+ const result = await client.transactions.create(payload);
313
+ console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
314
+ console.warn('result PagarmeBankSlipAPIAdapter', JSON.stringify(result));
315
+ if (result.status !== connect.PagarmePaymentStatus['Em processamento']) {
316
+ return Promise.reject(new connect.PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
317
+ checkoutId: checkout.id,
318
+ userEmail: checkout.user.email,
319
+ info: result,
320
+ }));
321
+ }
322
+ const payment = await this.paymentRepository.create({
323
+ createdAt: new Date(),
324
+ updatedAt: new Date(),
325
+ userId: checkout.user.id,
326
+ checkoutId: checkout.id,
327
+ totalPrice: checkout.totalPrice,
328
+ paymentProvider: 'pagarMe',
329
+ transaction: result,
330
+ });
331
+ return payment;
332
+ }
333
+ catch (error) {
334
+ console.error('Error PagarmeBankSlipAPIAdapter', JSON.stringify(error));
335
+ throw new connect.PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
336
+ checkoutId: checkout.id,
337
+ userEmail: checkout.user.email,
338
+ info: error,
339
+ });
340
+ }
341
+ }
342
+ async getBoletoTransaction(paymentId) {
343
+ try {
344
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
345
+ const result = await client.transactions.find({ id: paymentId });
346
+ return result;
347
+ }
348
+ catch (error) {
349
+ throw new connect.BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
350
+ paymentId,
351
+ info: error,
352
+ });
353
+ }
354
+ }
355
+ createBoletoPayment(checkout) {
356
+ return {
357
+ api_key: this.credentials.API_KEY,
358
+ amount: Math.floor(checkout.totalPrice * 100),
359
+ boleto_rules: ['strict_expiration_date'],
360
+ boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
361
+ boleto_expiration_date: connect.format(connect.addDays(new Date(), 3), 'yyyy-MM-dd'),
362
+ payment_method: 'boleto',
363
+ postback_url: this.credentials.URL_POSTBACK,
364
+ customer: {
365
+ external_id: checkout.user.id,
366
+ type: 'individual',
367
+ country: 'br',
368
+ name: checkout.user.displayName,
369
+ documents: [
370
+ {
371
+ type: 'cpf',
372
+ number: checkout.user.cpf,
373
+ },
374
+ ],
375
+ },
376
+ };
377
+ }
378
+ }
379
+
380
+ class PagarmeCardAPIAdapter {
381
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
382
+ this.credentials = credentials;
383
+ this.paymentRepository = paymentRepository;
384
+ this.orderBlockedRepository = orderBlockedRepository;
385
+ }
386
+ async pay(checkout, card) {
387
+ try {
388
+ const client = await this.createPagarmeClient();
389
+ const transactionResult = await this.executeCardTransaction(client, checkout, card);
390
+ await this.validateTransactionResult(transactionResult, checkout, card);
391
+ return await this.createPaymentRecord(checkout, transactionResult);
392
+ }
393
+ catch (error) {
394
+ this.handlePaymentError(error, checkout);
395
+ }
396
+ }
397
+ async createPagarmeClient() {
398
+ return await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
399
+ }
400
+ async executeCardTransaction(client, checkout, card) {
401
+ const payload = this.createCardPayment(checkout, card);
402
+ const result = await client.transactions.create(payload);
403
+ this.logTransactionDetails(payload, result);
404
+ return result;
405
+ }
406
+ logTransactionDetails(payload, result) {
407
+ console.warn('[PAGARME CARD DATA TO SEND]', payload);
408
+ console.warn('result PagarmeCardAPIAdapter', JSON.stringify(result));
409
+ }
410
+ async validateTransactionResult(result, checkout, card) {
411
+ if (result.status !== connect.PagarmePaymentStatus.Pago) {
412
+ await this.handleUnauthorizedPayment(checkout, card, result);
413
+ }
414
+ }
415
+ async handleUnauthorizedPayment(checkout, card, result) {
416
+ await this.createBlockedOrderRecord(checkout, card);
417
+ throw new connect.PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
418
+ checkoutId: checkout.id,
419
+ userEmail: checkout.user.email,
420
+ info: result,
421
+ });
422
+ }
423
+ async createBlockedOrderRecord(checkout, card) {
424
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
425
+ checkout,
426
+ blockType: 'Card not authorized',
427
+ type: 'Card',
428
+ limiteRange: 'day',
429
+ card,
430
+ });
431
+ }
432
+ async createPaymentRecord(checkout, transactionResult) {
433
+ return await this.paymentRepository.create({
434
+ createdAt: new Date(),
435
+ updatedAt: new Date(),
436
+ userId: checkout.user.id,
437
+ checkoutId: checkout.id,
438
+ totalPrice: checkout.totalPrice,
439
+ paymentProvider: connect.PaymentProviders.PAGARME,
440
+ transaction: Object.assign(Object.assign({}, transactionResult), { paidAt: new Date() }),
441
+ });
442
+ }
443
+ handlePaymentError(error, checkout) {
444
+ console.error('Error PagarmeCardAPIAdapter', JSON.stringify(error));
445
+ throw new connect.PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
446
+ checkoutId: checkout.id,
447
+ userEmail: checkout.user.email,
448
+ info: error,
449
+ });
450
+ }
451
+ async addCard(card) {
452
+ try {
453
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
454
+ const result = await client.cards.create({
455
+ card_number: card.number,
456
+ card_expiration_date: card.expirationDate.replace('/', ''),
457
+ card_holder_name: card.name,
458
+ card_cvv: card.cvv,
459
+ });
460
+ return result;
461
+ }
462
+ catch (error) {
463
+ throw new connect.BusinessError('Houve uma falha adicionar o cartão', {
464
+ info: error,
465
+ });
466
+ }
467
+ }
468
+ async createCardHash(bu, card) {
469
+ try {
470
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
471
+ const result = await client.security.encrypt({
472
+ card_number: card.number,
473
+ card_expiration_date: card.expirationDate.replace('/', ''),
474
+ card_holder_name: card.name,
475
+ card_cvv: card.cvv,
476
+ });
477
+ return result;
478
+ }
479
+ catch (error) {
480
+ throw new connect.BusinessError('Houve uma falha ao gerar o hash do cartão', {
481
+ info: error,
482
+ });
483
+ }
484
+ }
485
+ async getCardByToken(id) {
486
+ try {
487
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
488
+ const result = await client.cards.find({
489
+ id,
490
+ });
491
+ return result;
492
+ }
493
+ catch (error) {
494
+ throw new connect.BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
495
+ info: error,
496
+ });
497
+ }
498
+ }
499
+ async createTransaction(data) {
500
+ try {
501
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
502
+ const result = await client.transactions.create(data);
503
+ return result;
504
+ }
505
+ catch (error) {
506
+ throw new connect.BusinessError('Houve uma falha ao criar a transação', {
507
+ info: error,
508
+ });
509
+ }
510
+ }
511
+ createCardPayment(checkout, card) {
512
+ var _a, _b, _c, _d, _e, _f;
513
+ return {
514
+ api_key: this.credentials.API_KEY,
515
+ amount: Math.floor(checkout.totalPrice * 100),
516
+ card_id: card.cardId,
517
+ card_cvv: card.cardCvv,
518
+ payment_method: 'credit_card',
519
+ installments: card.installments,
520
+ soft_descriptor: checkout.shop === connect.Shops.GLAMSHOP ? 'Glam' : "Men's Market",
521
+ customer: {
522
+ external_id: checkout.user.id,
523
+ name: checkout.user.displayName,
524
+ type: 'individual',
525
+ country: 'br',
526
+ email: checkout.user.email,
527
+ phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
528
+ documents: [
529
+ {
530
+ type: 'cpf',
531
+ number: checkout.user.cpf,
532
+ },
533
+ ],
534
+ },
535
+ billing: {
536
+ name: checkout.user.displayName,
537
+ address: {
538
+ country: 'br',
539
+ state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
540
+ city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
541
+ neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
542
+ street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
543
+ street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
544
+ zipcode: checkout.billingAddress
545
+ ? checkout.billingAddress.zip.replace('-', '')
546
+ : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
547
+ },
548
+ },
549
+ items: checkout.lineItems.map((item) => {
550
+ return {
551
+ id: item.id,
552
+ title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
553
+ unit_price: Math.floor(item.pricePaid * 100),
554
+ quantity: item.quantity,
555
+ tangible: true,
556
+ };
557
+ }),
558
+ };
559
+ }
560
+ }
561
+
562
+ class PagarmePixAPIAdapter {
563
+ constructor(credentials, paymentRepository) {
564
+ this.credentials = credentials;
565
+ this.paymentRepository = paymentRepository;
566
+ }
567
+ async pay(checkout) {
568
+ try {
569
+ const client = await pagarme__default["default"].client.connect({ api_key: this.credentials.API_KEY });
570
+ const payload = this.createPixPayment(checkout);
571
+ const result = await client.transactions.create(payload);
572
+ console.warn('[PAGARME PIX DATA TO SEND]', payload);
573
+ console.warn('result PagarmePixAPIAdapter', JSON.stringify(result));
574
+ const payment = await this.paymentRepository.create({
575
+ createdAt: new Date(),
576
+ updatedAt: new Date(),
577
+ userId: checkout.user.id,
578
+ checkoutId: checkout.id,
579
+ totalPrice: checkout.totalPrice,
580
+ paymentProvider: 'pagarMe',
581
+ transaction: result,
582
+ });
583
+ return payment;
584
+ }
585
+ catch (error) {
586
+ console.error('Error PagarmePixAPIAdapter', JSON.stringify(error));
587
+ throw new connect.PaymentError('Houve uma falha ao processar pagamento com pix', {
588
+ checkoutId: checkout.id,
589
+ userEmail: checkout.user.email,
590
+ info: error,
591
+ });
592
+ }
593
+ }
594
+ createPixPayment(checkout) {
595
+ return {
596
+ payment_method: 'pix',
597
+ amount: Math.floor(checkout.totalPrice * 100),
598
+ api_key: this.credentials.API_KEY,
599
+ postback_url: this.credentials.URL_POSTBACK,
600
+ pix_expiration_date: connect.format(connect.addDays(new Date(), 1), 'yyyy-MM-dd'),
601
+ customer: {
602
+ external_id: checkout.user.id,
603
+ type: 'individual',
604
+ country: 'br',
605
+ name: checkout.user.displayName,
606
+ email: checkout.user.email.trim(),
607
+ phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
608
+ documents: [
609
+ {
610
+ type: 'cpf',
611
+ number: checkout.user.cpf,
612
+ },
613
+ ],
614
+ },
615
+ };
616
+ }
617
+ }
618
+
619
+ class ProductVertexHelper {
620
+ constructor() { }
621
+ static productMapper(product) {
622
+ var _a, _b;
623
+ const image = product.miniatures && product.miniatures.length ? product.miniatures[0] : null;
624
+ return {
625
+ id: product.id.toString(),
626
+ miniatures: image,
627
+ icon: image,
628
+ name: product.name,
629
+ brand: ((_a = product.brand) === null || _a === void 0 ? void 0 : _a.toString().trim()) ? (_b = product.brand) === null || _b === void 0 ? void 0 : _b.toString().trim() : null,
630
+ ean: product.EAN,
631
+ sku: product.sku,
632
+ slug: product.slug,
633
+ published: product.published,
634
+ gender: product.gender,
635
+ stock: product.stock.quantity,
636
+ rating: product.rate,
637
+ shoppingCount: product.shoppingCount,
638
+ description: product.description.description,
639
+ fullPrice: product.fullPrice,
640
+ price: product.price.price,
641
+ subscriberPrice: product.subscriberPrice,
642
+ outlet: product.outlet,
643
+ createdAt: product.createdAt,
644
+ };
645
+ }
646
+ static resultProductMapper(result) {
647
+ return result[0].length
648
+ ? result[0].map((result) => {
649
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
650
+ return {
651
+ id: (_a = result.document) === null || _a === void 0 ? void 0 : _a.structData.fields.id.stringValue,
652
+ name: (_b = result.document) === null || _b === void 0 ? void 0 : _b.structData.fields.name.stringValue,
653
+ brand: (_d = (_c = result.document) === null || _c === void 0 ? void 0 : _c.structData.fields.brand) === null || _d === void 0 ? void 0 : _d.stringValue,
654
+ stock: (_f = (_e = result.document) === null || _e === void 0 ? void 0 : _e.structData.fields.stock) === null || _f === void 0 ? void 0 : _f.numberValue,
655
+ rating: (_h = (_g = result.document) === null || _g === void 0 ? void 0 : _g.structData.fields.rating) === null || _h === void 0 ? void 0 : _h.stringValue,
656
+ gender: (_k = (_j = result.document) === null || _j === void 0 ? void 0 : _j.structData.fields.gender) === null || _k === void 0 ? void 0 : _k.stringValue,
657
+ slug: (_m = (_l = result.document) === null || _l === void 0 ? void 0 : _l.structData.fields.slug) === null || _m === void 0 ? void 0 : _m.stringValue,
658
+ sku: (_p = (_o = result.document) === null || _o === void 0 ? void 0 : _o.structData.fields.sku) === null || _p === void 0 ? void 0 : _p.stringValue,
659
+ ean: (_r = (_q = result.document) === null || _q === void 0 ? void 0 : _q.structData.fields.ean) === null || _r === void 0 ? void 0 : _r.stringValue,
660
+ description: (_t = (_s = result.document) === null || _s === void 0 ? void 0 : _s.structData.fields.description) === null || _t === void 0 ? void 0 : _t.stringValue,
661
+ };
662
+ })
663
+ : [];
664
+ }
665
+ }
666
+
667
+ exports.DiscoveryEngineVertexAdapter = class DiscoveryEngineVertexAdapter {
668
+ constructor(configuration) {
669
+ this.config = configuration;
670
+ this.parentEngine =
671
+ `projects/${this.config.projectId}/locations/${this.config.location}/` +
672
+ `collections/default_collection/engines/${this.config.dataStoreId}`;
673
+ this.parentDataStore =
674
+ `projects/${this.config.projectId}/locations/${this.config.location}/` +
675
+ `collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch/documents`;
676
+ this.searchClient = new v1beta.SearchServiceClient({
677
+ apiEndpoint: configuration.apiEndpoint,
678
+ credentials: configuration.credentials,
679
+ });
680
+ this.documentClient = new discoveryengine.DocumentServiceClient({
681
+ apiEndpoint: configuration.apiEndpoint,
682
+ credentials: configuration.credentials,
683
+ });
684
+ this.servingConfig = this.searchClient.projectLocationCollectionDataStoreServingConfigPath(configuration.projectId, configuration.location, configuration.collectionId, configuration.dataStoreId, configuration.servingConfigId);
685
+ }
686
+ async save(product) {
687
+ const productSearch = ProductVertexHelper.productMapper(product);
688
+ const request = {
689
+ parent: this.parentEngine,
690
+ allowMissing: true,
691
+ document: {
692
+ name: this.parentDataStore + `/${product.id}`,
693
+ jsonData: JSON.stringify(productSearch),
694
+ data: 'jsonData',
695
+ },
696
+ };
697
+ const response = await this.documentClient.updateDocument(request);
698
+ return response;
699
+ }
700
+ async update(id, data) {
701
+ const productSearch = ProductVertexHelper.productMapper(data);
702
+ const request = {
703
+ parent: this.parentEngine,
704
+ allowMissing: true,
705
+ document: {
706
+ name: this.parentDataStore + `/${id}`,
707
+ jsonData: JSON.stringify(productSearch),
708
+ data: 'jsonData',
709
+ },
710
+ };
711
+ const response = await this.documentClient.updateDocument(request);
712
+ return response;
713
+ }
714
+ async query(term, total) {
715
+ const response = (await this.searchClient.search({
716
+ pageSize: total,
717
+ query: term,
718
+ filter: '',
719
+ languageCode: 'pt-BR',
720
+ servingConfig: this.servingConfig,
721
+ relevanceThreshold: 'MEDIUM',
722
+ }, {
723
+ autoPaginate: false,
724
+ }));
725
+ return ProductVertexHelper.resultProductMapper(response);
726
+ }
727
+ async get(id) {
728
+ const request = {
729
+ name: this.parentDataStore + `/${id}`,
730
+ };
731
+ const response = await this.documentClient.getDocument(request);
732
+ const document = JSON.parse(response[0].jsonData);
733
+ return document;
734
+ }
735
+ async delete(id) {
736
+ const request = {
737
+ name: this.parentDataStore + `/${id}`,
738
+ };
739
+ await this.documentClient.deleteDocument(request);
740
+ }
741
+ async bulkProducts(products) {
742
+ try {
743
+ const batchSize = 100;
744
+ let total = 0;
745
+ for (let index = 0; index < products.length; index += batchSize) {
746
+ const bulkProducts = products.slice(index, index + batchSize);
747
+ const [operation] = await this.documentClient.importDocuments({
748
+ parent: `projects/${this.config.projectId}/locations/${this.config.location}/` +
749
+ `collections/default_collection/dataStores/${this.config.dataStoreId}/branches/default_branch`,
750
+ inlineSource: {
751
+ documents: bulkProducts,
752
+ },
753
+ });
754
+ total += bulkProducts.length;
755
+ const [response] = await operation.promise();
756
+ console.warn(`Imported: ${total} documents`, ((total / products.length) * 100).toFixed(2) + '%', 'Erros: ', response.errorSamples ? response.errorSamples : []);
757
+ }
758
+ }
759
+ catch (error) {
760
+ console.error(error);
761
+ }
762
+ }
763
+ };
764
+ exports.DiscoveryEngineVertexAdapter = __decorate([
765
+ common.Injectable(),
766
+ __param(0, common.Inject(VERTEX_CONFIG)),
767
+ __metadata("design:paramtypes", [Object])
768
+ ], exports.DiscoveryEngineVertexAdapter);
769
+
770
+ var NestElasticSeachModule_1;
771
+ exports.NestElasticSeachModule = NestElasticSeachModule_1 = class NestElasticSeachModule {
772
+ static initializeApp(options) {
773
+ return {
774
+ module: NestElasticSeachModule_1,
775
+ providers: [{ provide: ES_CONFIG, useValue: options }],
776
+ exports: [ES_CONFIG],
777
+ };
778
+ }
779
+ };
780
+ exports.NestElasticSeachModule = NestElasticSeachModule_1 = __decorate([
781
+ common.Module({
782
+ providers: [
783
+ exports.NativeElasticSearchAdapter,
784
+ {
785
+ provide: connect.ProductsIndex,
786
+ useFactory: (adapter) => new connect.ProductsIndex(adapter),
787
+ inject: [exports.NativeElasticSearchAdapter],
788
+ },
789
+ ],
790
+ exports: [connect.ProductsIndex],
791
+ })
792
+ ], exports.NestElasticSeachModule);
793
+
794
+ exports.NestStorageModule = class NestStorageModule {
795
+ };
796
+ exports.NestStorageModule = __decorate([
797
+ common.Module({
798
+ providers: [
799
+ {
800
+ provide: FIREBASE_STORAGE,
801
+ useFactory: (firebaseAdmin) => firebaseAdmin.storage,
802
+ inject: [nestjsFirebase.FirebaseConstants.FIREBASE_TOKEN],
803
+ },
804
+ ],
805
+ exports: [FIREBASE_STORAGE],
806
+ })
807
+ ], exports.NestStorageModule);
808
+
809
+ var NestFirestoreModule_1;
810
+ exports.NestFirestoreModule = NestFirestoreModule_1 = class NestFirestoreModule {
811
+ static initializeApp(options) {
812
+ var _a;
813
+ return {
814
+ module: NestFirestoreModule_1,
815
+ imports: [
816
+ nestjsFirebase.FirebaseModule.forRoot({
817
+ googleApplicationCredential: (_a = options === null || options === void 0 ? void 0 : options.firebase) === null || _a === void 0 ? void 0 : _a.googleApplicationCredential,
818
+ }),
819
+ exports.NestStorageModule,
820
+ ],
821
+ exports: [nestjsFirebase.FirebaseModule, exports.NestStorageModule],
822
+ };
823
+ }
824
+ };
825
+ exports.NestFirestoreModule = NestFirestoreModule_1 = __decorate([
826
+ common.Module({
827
+ providers: [
828
+ {
829
+ provide: exports.ConnectFirestoreService,
830
+ useFactory: (firebaseAdmin) => new exports.ConnectFirestoreService(firebaseAdmin.firestore),
831
+ inject: [nestjsFirebase.FirebaseConstants.FIREBASE_TOKEN],
832
+ },
833
+ {
834
+ provide: 'FirestoreOptions',
835
+ useFactory: (connectFirestoreService) => ({
836
+ firestore: connectFirestoreService,
837
+ }),
838
+ inject: [exports.ConnectFirestoreService],
839
+ },
840
+ {
841
+ provide: 'BeautyProfileRepository',
842
+ useFactory: (config, userRepository) => {
843
+ return new connect.UserBeautyProfileFirestoreRepository(config, userRepository);
844
+ },
845
+ inject: ['FirestoreOptions', 'UserRepository'],
846
+ },
847
+ {
848
+ provide: 'Buy2WinRepository',
849
+ useFactory: (options) => {
850
+ return new connect.Buy2WinFirestoreRepository(options);
851
+ },
852
+ inject: ['FirestoreOptions'],
853
+ },
854
+ {
855
+ provide: connect.CategoryFirestoreRepository,
856
+ useFactory: (options) => {
857
+ return new connect.CategoryFirestoreRepository(options);
858
+ },
859
+ inject: ['FirestoreOptions'],
860
+ },
861
+ {
862
+ provide: 'CheckoutRepository',
863
+ useFactory: (options) => {
864
+ return new connect.CheckoutFirestoreRepository(options);
865
+ },
866
+ inject: ['FirestoreOptions'],
867
+ },
868
+ {
869
+ provide: 'CheckoutSubscriptionRepository',
870
+ useFactory: (options) => {
871
+ return new connect.CheckoutSubscriptionFirestoreRepository(options);
872
+ },
873
+ inject: ['FirestoreOptions'],
874
+ },
875
+ {
876
+ provide: 'CouponRepository',
877
+ useFactory: (options) => {
878
+ return new connect.CouponFirestoreRepository(options);
879
+ },
880
+ inject: ['FirestoreOptions'],
881
+ },
882
+ {
883
+ provide: 'CampaignHashtagRepository',
884
+ useFactory: (options) => {
885
+ return new connect.CampaignHashtagFirestoreRepository(options);
886
+ },
887
+ inject: ['FirestoreOptions'],
888
+ },
889
+ {
890
+ provide: 'CampaignDashboardRepository',
891
+ useFactory: (options) => {
892
+ return new connect.CampaignDashboardFirestoreRepository(options);
893
+ },
894
+ inject: ['FirestoreOptions'],
895
+ },
896
+ {
897
+ provide: 'EditionRepository',
898
+ useFactory: (options, subscriptionRepository) => {
899
+ return new connect.SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
900
+ },
901
+ inject: ['FirestoreOptions', 'SubscriptionRepository'],
902
+ },
903
+ {
904
+ provide: 'GroupRepository',
905
+ useFactory: (options) => {
906
+ return new connect.GroupFirestoreRepository(options);
907
+ },
908
+ inject: ['FirestoreOptions'],
909
+ },
910
+ {
911
+ provide: 'HomeRepository',
912
+ useFactory: (options) => {
913
+ return new connect.HomeFirestoreRepository(options);
914
+ },
915
+ inject: ['FirestoreOptions'],
916
+ },
917
+ {
918
+ provide: 'LeadRepository',
919
+ useFactory: (options) => {
920
+ return new connect.LeadFirestoreRepository(options);
921
+ },
922
+ inject: ['FirestoreOptions'],
923
+ },
924
+ {
925
+ provide: 'LegacyOrderRepository',
926
+ useFactory: (options) => {
927
+ return new connect.LegacyOrderFirestoreRepository(options);
928
+ },
929
+ inject: ['FirestoreOptions'],
930
+ },
931
+ {
932
+ provide: 'ShopMenuRepository',
933
+ useFactory: (options) => {
934
+ return new connect.ShopMenuFirestoreRepository(options);
935
+ },
936
+ inject: ['FirestoreOptions'],
937
+ },
938
+ {
939
+ provide: 'OrderRepository',
940
+ useFactory: (options) => {
941
+ return new connect.OrderFirestoreRepository(options);
942
+ },
943
+ inject: ['FirestoreOptions'],
944
+ },
945
+ {
946
+ provide: 'PaymentRepository',
947
+ useFactory: (options) => {
948
+ return new connect.PaymentFirestoreRepository(options);
949
+ },
950
+ inject: ['FirestoreOptions'],
951
+ },
952
+ {
953
+ provide: connect.ProductFirestoreRepository,
954
+ useFactory: (options) => {
955
+ return new connect.ProductFirestoreRepository(options);
956
+ },
957
+ inject: ['FirestoreOptions'],
958
+ },
959
+ {
960
+ provide: 'ShopSettingsRepository',
961
+ useFactory: (options) => {
962
+ return new connect.ShopSettingsFirestoreRepository(options);
963
+ },
964
+ inject: ['FirestoreOptions'],
965
+ },
966
+ {
967
+ provide: 'SubscriptionPaymentRepository',
968
+ useFactory: (options, subscriptionRepository) => {
969
+ return new connect.SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
970
+ },
971
+ inject: ['FirestoreOptions', 'SubscriptionRepository'],
972
+ },
973
+ {
974
+ provide: 'SubscriptionPlanRepository',
975
+ useFactory: (options) => {
976
+ return new connect.SubscriptionPlanFirestoreRepository(options);
977
+ },
978
+ inject: ['FirestoreOptions'],
979
+ },
980
+ {
981
+ provide: 'SubscriptionProductRepository',
982
+ useFactory: (options) => {
983
+ return new connect.SubscriptionProductFirestoreRepository(options);
984
+ },
985
+ inject: ['FirestoreOptions'],
986
+ },
987
+ {
988
+ provide: 'SubscriptionRepository',
989
+ useFactory: (options) => {
990
+ return new connect.SubscriptionFirestoreRepository(options);
991
+ },
992
+ inject: ['FirestoreOptions'],
993
+ },
994
+ {
995
+ provide: 'UserRepository',
996
+ useFactory: (options) => {
997
+ return new connect.UserFirestoreRepository(options);
998
+ },
999
+ inject: ['FirestoreOptions'],
1000
+ },
1001
+ {
1002
+ provide: 'UserAddressRepository',
1003
+ useFactory: (options, userRepository) => {
1004
+ return new connect.UserAddressFirestoreRepository(options, userRepository);
1005
+ },
1006
+ inject: ['FirestoreOptions', 'UserRepository'],
1007
+ },
1008
+ {
1009
+ provide: 'UserPaymentMethodRepository',
1010
+ useFactory: (options, userRepository) => {
1011
+ return new connect.UserPaymentMethodFirestoreRepository(options, userRepository);
1012
+ },
1013
+ inject: ['FirestoreOptions', 'UserRepository'],
1014
+ },
1015
+ {
1016
+ provide: 'SubscriptionMaterializationRepository',
1017
+ useFactory: (options) => {
1018
+ return new connect.SubscriptionMaterializationFirestoreRepository(options);
1019
+ },
1020
+ inject: ['FirestoreOptions'],
1021
+ },
1022
+ {
1023
+ provide: 'SubscriptionSummaryRepository',
1024
+ useFactory: (options) => {
1025
+ return new connect.SubscriptionSummaryFirestoreRepository(options);
1026
+ },
1027
+ inject: ['FirestoreOptions'],
1028
+ },
1029
+ {
1030
+ provide: connect.ProductVariantFirestoreRepository,
1031
+ useFactory: (options, productRepository) => {
1032
+ return new connect.ProductVariantFirestoreRepository(options, productRepository);
1033
+ },
1034
+ inject: ['FirestoreOptions', connect.ProductFirestoreRepository],
1035
+ },
1036
+ {
1037
+ provide: 'OrderBlockedRepository',
1038
+ useFactory: (options) => {
1039
+ return new connect.OrderBlockedFirestoreRepository(options);
1040
+ },
1041
+ inject: ['FirestoreOptions'],
1042
+ },
1043
+ {
1044
+ provide: 'LogRepository',
1045
+ useFactory: (options) => {
1046
+ return new connect.LogFirestoreRepository(options);
1047
+ },
1048
+ inject: ['FirestoreOptions'],
1049
+ },
1050
+ {
1051
+ provide: 'SequenceRepository',
1052
+ useFactory: (options) => {
1053
+ return new connect.SequenceFirestoreRepository(options);
1054
+ },
1055
+ inject: ['FirestoreOptions'],
1056
+ },
1057
+ ],
1058
+ exports: [
1059
+ 'BeautyProfileRepository',
1060
+ 'Buy2WinRepository',
1061
+ connect.CategoryFirestoreRepository,
1062
+ 'CheckoutRepository',
1063
+ 'CheckoutSubscriptionRepository',
1064
+ 'CouponRepository',
1065
+ 'CampaignHashtagRepository',
1066
+ 'CampaignDashboardRepository',
1067
+ 'EditionRepository',
1068
+ 'GroupRepository',
1069
+ 'HomeRepository',
1070
+ 'LeadRepository',
1071
+ 'LegacyOrderRepository',
1072
+ 'ShopMenuRepository',
1073
+ 'OrderRepository',
1074
+ 'OrderBlockedRepository',
1075
+ 'PaymentRepository',
1076
+ 'SequenceRepository',
1077
+ 'LogRepository',
1078
+ connect.ProductFirestoreRepository,
1079
+ 'ShopSettingsRepository',
1080
+ 'SubscriptionPaymentRepository',
1081
+ 'SubscriptionPlanRepository',
1082
+ 'SubscriptionProductRepository',
1083
+ 'SubscriptionRepository',
1084
+ 'UserRepository',
1085
+ 'UserAddressRepository',
1086
+ 'UserPaymentMethodRepository',
1087
+ 'SubscriptionMaterializationRepository',
1088
+ 'SubscriptionSummaryRepository',
1089
+ connect.ProductVariantFirestoreRepository,
1090
+ exports.ConnectFirestoreService,
1091
+ ],
1092
+ })
1093
+ ], exports.NestFirestoreModule);
1094
+
1095
+ var NestHasuraGraphQLModule_1;
1096
+ exports.NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = class NestHasuraGraphQLModule {
1097
+ static initializeApp(options) {
1098
+ return {
1099
+ module: NestHasuraGraphQLModule_1,
1100
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1101
+ exports: [HASURA_OPTIONS],
1102
+ };
1103
+ }
1104
+ };
1105
+ exports.NestHasuraGraphQLModule = NestHasuraGraphQLModule_1 = __decorate([
1106
+ common.Module({
1107
+ providers: [
1108
+ {
1109
+ provide: 'HasuraConfig',
1110
+ useFactory: (options) => ({
1111
+ endpoint: options.endpoint,
1112
+ authOptions: options.credentials,
1113
+ cache: options.cache,
1114
+ }),
1115
+ inject: [HASURA_OPTIONS],
1116
+ },
1117
+ {
1118
+ provide: 'CategoryRepository',
1119
+ useExisting: connect.CategoryHasuraGraphQLRepository,
1120
+ },
1121
+ {
1122
+ provide: connect.CategoryHasuraGraphQLRepository,
1123
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1124
+ return new connect.CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
1125
+ },
1126
+ inject: ['HasuraConfig', connect.ProductHasuraGraphQLRepository, connect.CategoryFilterHasuraGraphQLRepository],
1127
+ },
1128
+ {
1129
+ provide: 'ProductRepository',
1130
+ useExisting: connect.ProductHasuraGraphQLRepository,
1131
+ },
1132
+ {
1133
+ provide: connect.ProductHasuraGraphQLRepository,
1134
+ useFactory: (hasuraConfig) => {
1135
+ return new connect.ProductHasuraGraphQLRepository(hasuraConfig);
1136
+ },
1137
+ inject: ['HasuraConfig'],
1138
+ },
1139
+ {
1140
+ provide: 'ProductReviewRepository',
1141
+ useExisting: connect.ProductReviewHasuraGraphQLRepository,
1142
+ },
1143
+ {
1144
+ provide: connect.ProductReviewHasuraGraphQLRepository,
1145
+ useFactory: (hasuraConfig) => {
1146
+ return new connect.ProductReviewHasuraGraphQLRepository(hasuraConfig);
1147
+ },
1148
+ inject: ['HasuraConfig'],
1149
+ },
1150
+ {
1151
+ provide: 'VariantRepository',
1152
+ useExisting: connect.VariantHasuraGraphQLRepository,
1153
+ },
1154
+ {
1155
+ provide: connect.VariantHasuraGraphQLRepository,
1156
+ useFactory: (hasuraConfig) => {
1157
+ return new connect.VariantHasuraGraphQLRepository(hasuraConfig);
1158
+ },
1159
+ inject: ['HasuraConfig'],
1160
+ },
1161
+ {
1162
+ provide: 'ProductStockNotificationRepository',
1163
+ useExisting: connect.ProductStockNotificationHasuraGraphQLRepository,
1164
+ },
1165
+ {
1166
+ provide: connect.ProductStockNotificationHasuraGraphQLRepository,
1167
+ useFactory: (hasuraConfig) => {
1168
+ return new connect.ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
1169
+ },
1170
+ inject: ['HasuraConfig'],
1171
+ },
1172
+ {
1173
+ provide: 'CategoryFilterRepository',
1174
+ useExisting: connect.CategoryFilterHasuraGraphQLRepository,
1175
+ },
1176
+ {
1177
+ provide: connect.CategoryFilterHasuraGraphQLRepository,
1178
+ useFactory: (options) => {
1179
+ return new connect.CategoryFilterHasuraGraphQLRepository(options);
1180
+ },
1181
+ inject: ['HasuraConfig'],
1182
+ },
1183
+ {
1184
+ provide: 'FilterOptionRepository',
1185
+ useExisting: connect.FilterOptionHasuraGraphQLRepository,
1186
+ },
1187
+ {
1188
+ provide: connect.FilterOptionHasuraGraphQLRepository,
1189
+ useFactory: (options) => {
1190
+ return new connect.FilterOptionHasuraGraphQLRepository(options);
1191
+ },
1192
+ inject: ['HasuraConfig'],
1193
+ },
1194
+ {
1195
+ provide: 'FilterRepository',
1196
+ useExisting: connect.FilterHasuraGraphQLRepository,
1197
+ },
1198
+ {
1199
+ provide: connect.FilterHasuraGraphQLRepository,
1200
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1201
+ return new connect.FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
1202
+ },
1203
+ inject: ['HasuraConfig', connect.FilterOptionHasuraGraphQLRepository, connect.CategoryFilterHasuraGraphQLRepository],
1204
+ },
1205
+ {
1206
+ provide: connect.CategoryCollectionChildrenHasuraGraphQLRepository,
1207
+ useFactory: (options) => new connect.CategoryCollectionChildrenHasuraGraphQLRepository(options),
1208
+ inject: ['HasuraConfig'],
1209
+ },
1210
+ {
1211
+ provide: 'CategoryCollectionChildrenRepository',
1212
+ useExisting: connect.CategoryCollectionChildrenHasuraGraphQLRepository,
1213
+ },
1214
+ {
1215
+ provide: connect.CategoryProductHasuraGraphQLRepository,
1216
+ useFactory: (options) => {
1217
+ return new connect.CategoryProductHasuraGraphQLRepository(options);
1218
+ },
1219
+ inject: ['HasuraConfig'],
1220
+ },
1221
+ {
1222
+ provide: 'CategoryProductRepository',
1223
+ useExisting: connect.CategoryProductHasuraGraphQLRepository,
1224
+ },
1225
+ {
1226
+ provide: connect.WishlistHasuraGraphQLRepository,
1227
+ useFactory: (options, categoryProductRepository) => {
1228
+ return new connect.WishlistHasuraGraphQLRepository(options, categoryProductRepository);
1229
+ },
1230
+ inject: ['HasuraConfig', connect.CategoryProductHasuraGraphQLRepository],
1231
+ },
1232
+ {
1233
+ provide: 'WishlistRepository',
1234
+ useExisting: connect.WishlistHasuraGraphQLRepository,
1235
+ },
1236
+ {
1237
+ provide: connect.ProductErrorsHasuraGraphQLRepository,
1238
+ useFactory: (options, productRepository) => {
1239
+ return new connect.ProductErrorsHasuraGraphQLRepository(options, productRepository);
1240
+ },
1241
+ inject: ['HasuraConfig', connect.ProductHasuraGraphQLRepository],
1242
+ },
1243
+ {
1244
+ provide: 'ProductErrorsRepository',
1245
+ useExisting: connect.ProductErrorsHasuraGraphQLRepository,
1246
+ },
1247
+ ],
1248
+ exports: [
1249
+ 'CategoryRepository',
1250
+ connect.CategoryHasuraGraphQLRepository,
1251
+ 'ProductRepository',
1252
+ connect.ProductHasuraGraphQLRepository,
1253
+ 'ProductReviewRepository',
1254
+ connect.ProductReviewHasuraGraphQLRepository,
1255
+ 'VariantRepository',
1256
+ connect.VariantHasuraGraphQLRepository,
1257
+ 'ProductStockNotificationRepository',
1258
+ connect.ProductStockNotificationHasuraGraphQLRepository,
1259
+ 'CategoryFilterRepository',
1260
+ connect.CategoryFilterHasuraGraphQLRepository,
1261
+ 'FilterOptionRepository',
1262
+ connect.FilterOptionHasuraGraphQLRepository,
1263
+ 'FilterRepository',
1264
+ connect.FilterHasuraGraphQLRepository,
1265
+ 'CategoryCollectionChildrenRepository',
1266
+ connect.CategoryCollectionChildrenHasuraGraphQLRepository,
1267
+ 'WishlistRepository',
1268
+ connect.WishlistHasuraGraphQLRepository,
1269
+ 'CategoryProductRepository',
1270
+ connect.CategoryProductHasuraGraphQLRepository,
1271
+ 'ProductErrorsRepository',
1272
+ connect.ProductErrorsHasuraGraphQLRepository,
1273
+ ],
1274
+ })
1275
+ ], exports.NestHasuraGraphQLModule);
1276
+
1277
+ var NestVertexSeachModule_1;
1278
+ let NestVertexSeachModule = NestVertexSeachModule_1 = class NestVertexSeachModule {
1279
+ static initializeApp(options) {
1280
+ return {
1281
+ module: NestVertexSeachModule_1,
1282
+ providers: [{ provide: VERTEX_CONFIG, useValue: options }],
1283
+ exports: [VERTEX_CONFIG],
1284
+ };
1285
+ }
1286
+ };
1287
+ NestVertexSeachModule = NestVertexSeachModule_1 = __decorate([
1288
+ common.Module({
1289
+ providers: [
1290
+ exports.DiscoveryEngineVertexAdapter,
1291
+ {
1292
+ provide: connect.ProductsVertexSearch,
1293
+ useFactory: (adapter) => new connect.ProductsVertexSearch(adapter),
1294
+ inject: [exports.DiscoveryEngineVertexAdapter],
1295
+ },
1296
+ ],
1297
+ exports: [connect.ProductsVertexSearch],
1298
+ })
1299
+ ], NestVertexSeachModule);
1300
+
1301
+ var NestConnectModule_1;
1302
+ exports.NestConnectModule = NestConnectModule_1 = class NestConnectModule {
1303
+ static initializeApp(options) {
1304
+ return {
1305
+ module: NestConnectModule_1,
1306
+ imports: [
1307
+ ...(options.firebase ? [exports.NestFirestoreModule.initializeApp({ firebase: options.firebase })] : []),
1308
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule.initializeApp(options.hasura)]),
1309
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [exports.NestElasticSeachModule.initializeApp(options.elasticSearch)]),
1310
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule.initializeApp(options.vertex)]),
1311
+ ],
1312
+ exports: [
1313
+ ...(options.firebase ? [exports.NestFirestoreModule] : []),
1314
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [exports.NestHasuraGraphQLModule]),
1315
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [exports.NestElasticSeachModule]),
1316
+ ...(connect.isNil(options === null || options === void 0 ? void 0 : options.vertex) ? [] : [NestVertexSeachModule]),
1317
+ ],
1318
+ };
1319
+ }
1320
+ };
1321
+ exports.NestConnectModule = NestConnectModule_1 = __decorate([
1322
+ common.Module({})
1323
+ ], exports.NestConnectModule);
1324
+
1325
+ exports.ConnectCollectionService = ConnectCollectionService;
1326
+ exports.ConnectDocumentService = ConnectDocumentService;
1327
+ exports.ES_CONFIG = ES_CONFIG;
1328
+ exports.FIREBASE_STORAGE = FIREBASE_STORAGE;
1329
+ exports.HASURA_OPTIONS = HASURA_OPTIONS;
1330
+ exports.PagarmeBankSlipAPIAdapter = PagarmeBankSlipAPIAdapter;
1331
+ exports.PagarmeCardAPIAdapter = PagarmeCardAPIAdapter;
1332
+ exports.PagarmePixAPIAdapter = PagarmePixAPIAdapter;
1333
+ exports.ProductVertexHelper = ProductVertexHelper;
1334
+ exports.VERTEX_CONFIG = VERTEX_CONFIG;