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