@infrab4a/connect-nestjs 2.9.0-alpha.1 → 2.9.0-alpha.2

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