@infrab4a/connect-nestjs 2.0.0-alpha.9 → 3.0.0-alpha.0

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