@infrab4a/connect 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +356 -230
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/lib/domain/catalog/models/product.js +3 -2
- package/esm2015/lib/domain/catalog/repositories/category.repository.js +1 -1
- package/esm2015/lib/domain/shopping/models/buy-2-win.js +8 -1
- package/esm2015/lib/domain/shopping/models/checkout.js +32 -1
- package/esm2015/lib/domain/shopping/models/coupons/coupon.js +8 -4
- package/esm2015/lib/domain/shopping/models/order.js +8 -1
- package/esm2015/lib/domain/shopping/models/payment.js +82 -42
- package/esm2015/lib/domain/shopping/models/subscription/checkout.js +22 -1
- package/esm2015/lib/domain/users/models/subscription/payment.js +8 -1
- package/esm2015/lib/domain/users/models/subscription/subscription.js +37 -1
- package/esm2015/lib/domain/users/models/user.js +11 -2
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +21 -23
- package/esm2015/public-api.js +2 -1
- package/fesm2015/infrab4a-connect.js +339 -212
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/lib/domain/catalog/repositories/category.repository.d.ts +1 -1
- package/lib/domain/shopping/models/buy-2-win.d.ts +1 -1
- package/lib/domain/shopping/models/checkout.d.ts +6 -6
- package/lib/domain/shopping/models/subscription/checkout.d.ts +4 -4
- package/lib/domain/users/models/subscription/payment.d.ts +1 -1
- package/lib/domain/users/models/subscription/subscription.d.ts +6 -6
- package/lib/domain/users/models/user.d.ts +1 -1
- package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { plainToClass, classToPlain, Expose, Type } from 'class-transformer';
|
|
3
|
+
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
3
4
|
import { isNil, isNumber, isString, isEmpty } from 'lodash';
|
|
4
5
|
export { chunk, isEmpty, isNil, isNumber, isString } from 'lodash';
|
|
5
6
|
import { Md5 } from 'ts-md5';
|
|
@@ -115,31 +116,235 @@ class Edition extends BaseModel {
|
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
class
|
|
119
|
+
class Payment extends BaseModel {
|
|
119
120
|
identifierFields() {
|
|
120
121
|
return ['id'];
|
|
121
122
|
}
|
|
122
123
|
}
|
|
124
|
+
__decorate([
|
|
125
|
+
Expose({ name: 'refuse_reason' }),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], Payment.prototype, "refuseReason", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
Expose({ name: 'status_reason' }),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], Payment.prototype, "statusReason", void 0);
|
|
132
|
+
__decorate([
|
|
133
|
+
Expose({ name: 'acquirer_response_code' }),
|
|
134
|
+
__metadata("design:type", String)
|
|
135
|
+
], Payment.prototype, "acquirerResponseCode", void 0);
|
|
136
|
+
__decorate([
|
|
137
|
+
Expose({ name: 'acquirer_name' }),
|
|
138
|
+
__metadata("design:type", String)
|
|
139
|
+
], Payment.prototype, "acquirerName", void 0);
|
|
140
|
+
__decorate([
|
|
141
|
+
Expose({ name: 'acquirer_id' }),
|
|
142
|
+
__metadata("design:type", String)
|
|
143
|
+
], Payment.prototype, "acquirerId", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
Expose({ name: 'authorization_code' }),
|
|
146
|
+
__metadata("design:type", String)
|
|
147
|
+
], Payment.prototype, "authorizationCode", void 0);
|
|
148
|
+
__decorate([
|
|
149
|
+
Expose({ name: 'soft_descriptor' }),
|
|
150
|
+
__metadata("design:type", String)
|
|
151
|
+
], Payment.prototype, "softDescriptor", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
Expose({ name: 'date_created' }),
|
|
154
|
+
__metadata("design:type", String)
|
|
155
|
+
], Payment.prototype, "dateCreated", void 0);
|
|
156
|
+
__decorate([
|
|
157
|
+
Expose({ name: 'date_updated' }),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], Payment.prototype, "dateUpdated", void 0);
|
|
160
|
+
__decorate([
|
|
161
|
+
Expose({ name: 'authorized_amount' }),
|
|
162
|
+
__metadata("design:type", Number)
|
|
163
|
+
], Payment.prototype, "authorizedAmount", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
Expose({ name: 'paid_amount' }),
|
|
166
|
+
__metadata("design:type", Number)
|
|
167
|
+
], Payment.prototype, "paidAmount", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
Expose({ name: 'refunded_amount' }),
|
|
170
|
+
__metadata("design:type", Number)
|
|
171
|
+
], Payment.prototype, "refundedAmount", void 0);
|
|
172
|
+
__decorate([
|
|
173
|
+
Expose({ name: 'card_holder_name' }),
|
|
174
|
+
__metadata("design:type", String)
|
|
175
|
+
], Payment.prototype, "cardHolderName", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
Expose({ name: 'card_last_digits' }),
|
|
178
|
+
__metadata("design:type", String)
|
|
179
|
+
], Payment.prototype, "cardLastDigits", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
Expose({ name: 'card_first_digits' }),
|
|
182
|
+
__metadata("design:type", String)
|
|
183
|
+
], Payment.prototype, "cardFirstDigits", void 0);
|
|
184
|
+
__decorate([
|
|
185
|
+
Expose({ name: 'card_brand' }),
|
|
186
|
+
__metadata("design:type", String)
|
|
187
|
+
], Payment.prototype, "cardBrand", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
Expose({ name: 'card_pin_mode' }),
|
|
190
|
+
__metadata("design:type", String)
|
|
191
|
+
], Payment.prototype, "cardPinMode", void 0);
|
|
192
|
+
__decorate([
|
|
193
|
+
Expose({ name: 'card_magstripe_fallback' }),
|
|
194
|
+
__metadata("design:type", Boolean)
|
|
195
|
+
], Payment.prototype, "cardMagstripeFallback", void 0);
|
|
196
|
+
__decorate([
|
|
197
|
+
Expose({ name: 'cvm_pin' }),
|
|
198
|
+
__metadata("design:type", Boolean)
|
|
199
|
+
], Payment.prototype, "cvmPin", void 0);
|
|
200
|
+
__decorate([
|
|
201
|
+
Expose({ name: 'postback_url' }),
|
|
202
|
+
__metadata("design:type", String)
|
|
203
|
+
], Payment.prototype, "postbackUrl", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
Expose({ name: 'payment_method' }),
|
|
206
|
+
__metadata("design:type", String)
|
|
207
|
+
], Payment.prototype, "paymentMethod", void 0);
|
|
208
|
+
__decorate([
|
|
209
|
+
Expose({ name: 'capture_method' }),
|
|
210
|
+
__metadata("design:type", String)
|
|
211
|
+
], Payment.prototype, "captureMethod", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
Expose({ name: 'antifraud_score' }),
|
|
214
|
+
__metadata("design:type", String)
|
|
215
|
+
], Payment.prototype, "antifraudScore", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
Expose({ name: 'boleto_url' }),
|
|
218
|
+
__metadata("design:type", String)
|
|
219
|
+
], Payment.prototype, "boletoUrl", void 0);
|
|
220
|
+
__decorate([
|
|
221
|
+
Expose({ name: 'boleto_barcode' }),
|
|
222
|
+
__metadata("design:type", String)
|
|
223
|
+
], Payment.prototype, "boletoBarcode", void 0);
|
|
224
|
+
__decorate([
|
|
225
|
+
Expose({ name: 'boleto_expiration_date' }),
|
|
226
|
+
__metadata("design:type", String)
|
|
227
|
+
], Payment.prototype, "boletoExpirationDate", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
Expose({ name: 'subscription_id' }),
|
|
230
|
+
__metadata("design:type", String)
|
|
231
|
+
], Payment.prototype, "subscriptionId", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
Expose({ name: 'split_rules' }),
|
|
234
|
+
__metadata("design:type", String)
|
|
235
|
+
], Payment.prototype, "splitRules", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
Expose({ name: 'antifraud_metadata' }),
|
|
238
|
+
__metadata("design:type", Object)
|
|
239
|
+
], Payment.prototype, "antifraudMetadata", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
Expose({ name: 'reference_key' }),
|
|
242
|
+
__metadata("design:type", String)
|
|
243
|
+
], Payment.prototype, "referenceKey", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
Expose({ name: 'local_transaction_id' }),
|
|
246
|
+
__metadata("design:type", String)
|
|
247
|
+
], Payment.prototype, "localTransactionId", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
Expose({ name: 'local_time' }),
|
|
250
|
+
__metadata("design:type", String)
|
|
251
|
+
], Payment.prototype, "localTime", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
Expose({ name: 'fraud_covered' }),
|
|
254
|
+
__metadata("design:type", Boolean)
|
|
255
|
+
], Payment.prototype, "fraudCovered", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
Expose({ name: 'fraud_reimbursed' }),
|
|
258
|
+
__metadata("design:type", String)
|
|
259
|
+
], Payment.prototype, "fraudReimbursed", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
Expose({ name: 'order_id' }),
|
|
262
|
+
__metadata("design:type", String)
|
|
263
|
+
], Payment.prototype, "orderId", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
Expose({ name: 'risk_level' }),
|
|
266
|
+
__metadata("design:type", String)
|
|
267
|
+
], Payment.prototype, "riskLevel", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
Expose({ name: 'receipt_url' }),
|
|
270
|
+
__metadata("design:type", String)
|
|
271
|
+
], Payment.prototype, "receiptUrl", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
Expose({ name: 'private_label' }),
|
|
274
|
+
__metadata("design:type", String)
|
|
275
|
+
], Payment.prototype, "privateLabel", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
Expose({ name: 'pix_qr_code' }),
|
|
278
|
+
__metadata("design:type", String)
|
|
279
|
+
], Payment.prototype, "pixQrCode", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
Expose({ name: 'pix_expiration_date' }),
|
|
282
|
+
__metadata("design:type", String)
|
|
283
|
+
], Payment.prototype, "pixExpirationDate", void 0);
|
|
123
284
|
|
|
124
|
-
class
|
|
285
|
+
class SubscriptionPayment extends BaseModel {
|
|
125
286
|
identifierFields() {
|
|
126
287
|
return ['id'];
|
|
127
288
|
}
|
|
128
289
|
}
|
|
290
|
+
__decorate([
|
|
291
|
+
Type(() => Payment),
|
|
292
|
+
__metadata("design:type", Payment)
|
|
293
|
+
], SubscriptionPayment.prototype, "payment", void 0);
|
|
129
294
|
|
|
130
|
-
class
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
295
|
+
class Address extends BaseModel {
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var CheckoutTypes;
|
|
299
|
+
(function (CheckoutTypes) {
|
|
300
|
+
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
301
|
+
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
302
|
+
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
303
|
+
|
|
304
|
+
var CouponTypes;
|
|
305
|
+
(function (CouponTypes) {
|
|
306
|
+
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
307
|
+
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
308
|
+
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
309
|
+
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
310
|
+
})(CouponTypes || (CouponTypes = {}));
|
|
311
|
+
|
|
312
|
+
var CouponSubtypes;
|
|
313
|
+
(function (CouponSubtypes) {
|
|
314
|
+
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
315
|
+
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
316
|
+
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
317
|
+
|
|
318
|
+
var Exclusivities;
|
|
319
|
+
(function (Exclusivities) {
|
|
320
|
+
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
321
|
+
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
322
|
+
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
323
|
+
})(Exclusivities || (Exclusivities = {}));
|
|
324
|
+
|
|
325
|
+
class Coupon extends BaseModel {
|
|
326
|
+
identifierFields() {
|
|
327
|
+
return ['id'];
|
|
135
328
|
}
|
|
329
|
+
}
|
|
330
|
+
__decorate([
|
|
331
|
+
Expose({ name: 'checkout_type' }),
|
|
332
|
+
__metadata("design:type", Number)
|
|
333
|
+
], Coupon.prototype, "checkoutType", void 0);
|
|
334
|
+
__decorate([
|
|
335
|
+
Expose({ name: 'exclusivity_type' }),
|
|
336
|
+
__metadata("design:type", Number)
|
|
337
|
+
], Coupon.prototype, "exclusivityType", void 0);
|
|
338
|
+
|
|
339
|
+
class SubscriptionPlan extends BaseModel {
|
|
136
340
|
identifierFields() {
|
|
137
341
|
return ['id'];
|
|
138
342
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
class Base {
|
|
346
|
+
constructor(...args) {
|
|
347
|
+
Object.assign(this, ...args);
|
|
143
348
|
}
|
|
144
349
|
}
|
|
145
350
|
|
|
@@ -154,18 +359,64 @@ class BeautyProfile extends BaseModel {
|
|
|
154
359
|
}
|
|
155
360
|
}
|
|
156
361
|
|
|
157
|
-
class
|
|
362
|
+
class User extends BaseModel {
|
|
363
|
+
static toInstance(data) {
|
|
364
|
+
const instance = super.toInstance(data);
|
|
365
|
+
if (!isNil(data.firstName))
|
|
366
|
+
instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
|
|
367
|
+
return instance;
|
|
368
|
+
}
|
|
369
|
+
identifierFields() {
|
|
370
|
+
return ['id'];
|
|
371
|
+
}
|
|
372
|
+
toPlain() {
|
|
373
|
+
const plain = super.toPlain();
|
|
374
|
+
delete plain.beautyProfile;
|
|
375
|
+
return plain;
|
|
376
|
+
}
|
|
158
377
|
}
|
|
378
|
+
__decorate([
|
|
379
|
+
Type(() => BeautyProfile),
|
|
380
|
+
__metadata("design:type", BeautyProfile)
|
|
381
|
+
], User.prototype, "beautyProfile", void 0);
|
|
159
382
|
|
|
160
|
-
class
|
|
383
|
+
class Subscription extends BaseModel {
|
|
161
384
|
identifierFields() {
|
|
162
385
|
return ['id'];
|
|
163
386
|
}
|
|
164
387
|
}
|
|
388
|
+
__decorate([
|
|
389
|
+
Type(() => User),
|
|
390
|
+
__metadata("design:type", User)
|
|
391
|
+
], Subscription.prototype, "user", void 0);
|
|
392
|
+
__decorate([
|
|
393
|
+
Type(() => SubscriptionPlan),
|
|
394
|
+
__metadata("design:type", SubscriptionPlan)
|
|
395
|
+
], Subscription.prototype, "subscriptionPlan", void 0);
|
|
396
|
+
__decorate([
|
|
397
|
+
Type(() => Address),
|
|
398
|
+
__metadata("design:type", Address)
|
|
399
|
+
], Subscription.prototype, "shippingAddress", void 0);
|
|
400
|
+
__decorate([
|
|
401
|
+
Type(() => Address),
|
|
402
|
+
__metadata("design:type", Address)
|
|
403
|
+
], Subscription.prototype, "billingAddress", void 0);
|
|
404
|
+
__decorate([
|
|
405
|
+
Type(() => Coupon),
|
|
406
|
+
__metadata("design:type", Coupon)
|
|
407
|
+
], Subscription.prototype, "coupon", void 0);
|
|
408
|
+
__decorate([
|
|
409
|
+
Type(() => Edition),
|
|
410
|
+
__metadata("design:type", Array)
|
|
411
|
+
], Subscription.prototype, "editions", void 0);
|
|
412
|
+
__decorate([
|
|
413
|
+
Type(() => SubscriptionPayment),
|
|
414
|
+
__metadata("design:type", Array)
|
|
415
|
+
], Subscription.prototype, "payment", void 0);
|
|
165
416
|
|
|
166
|
-
class
|
|
167
|
-
|
|
168
|
-
|
|
417
|
+
class UserAddress extends Address {
|
|
418
|
+
identifierFields() {
|
|
419
|
+
return ['id'];
|
|
169
420
|
}
|
|
170
421
|
}
|
|
171
422
|
|
|
@@ -240,7 +491,8 @@ class Product extends BaseModel {
|
|
|
240
491
|
return ['id'];
|
|
241
492
|
}
|
|
242
493
|
getInfoByShop(shop) {
|
|
243
|
-
|
|
494
|
+
var _a, _b, _c, _d, _e, _f;
|
|
495
|
+
return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
|
|
244
496
|
}
|
|
245
497
|
}
|
|
246
498
|
|
|
@@ -250,45 +502,6 @@ class Variant extends BaseModel {
|
|
|
250
502
|
}
|
|
251
503
|
}
|
|
252
504
|
|
|
253
|
-
var CouponTypes;
|
|
254
|
-
(function (CouponTypes) {
|
|
255
|
-
CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
|
|
256
|
-
CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
|
|
257
|
-
CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
|
|
258
|
-
CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
|
|
259
|
-
})(CouponTypes || (CouponTypes = {}));
|
|
260
|
-
|
|
261
|
-
var CouponSubtypes;
|
|
262
|
-
(function (CouponSubtypes) {
|
|
263
|
-
CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
|
|
264
|
-
CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
|
|
265
|
-
})(CouponSubtypes || (CouponSubtypes = {}));
|
|
266
|
-
|
|
267
|
-
var Exclusivities;
|
|
268
|
-
(function (Exclusivities) {
|
|
269
|
-
Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
|
|
270
|
-
Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
|
|
271
|
-
Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
|
|
272
|
-
})(Exclusivities || (Exclusivities = {}));
|
|
273
|
-
|
|
274
|
-
class Coupon extends BaseModel {
|
|
275
|
-
identifierFields() {
|
|
276
|
-
return ['id'];
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
__decorate([
|
|
280
|
-
Expose({ name: 'checkout_type' })
|
|
281
|
-
], Coupon.prototype, "checkoutType", void 0);
|
|
282
|
-
__decorate([
|
|
283
|
-
Expose({ name: 'exclusivity_type' })
|
|
284
|
-
], Coupon.prototype, "exclusivityType", void 0);
|
|
285
|
-
|
|
286
|
-
var CheckoutTypes;
|
|
287
|
-
(function (CheckoutTypes) {
|
|
288
|
-
CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
|
|
289
|
-
CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
|
|
290
|
-
})(CheckoutTypes || (CheckoutTypes = {}));
|
|
291
|
-
|
|
292
505
|
const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
|
|
293
506
|
class FinancialCoupon extends Coupon {
|
|
294
507
|
constructor() {
|
|
@@ -325,167 +538,83 @@ var OrderStatus;
|
|
|
325
538
|
OrderStatus["CREDIT_CARD"] = "credit_card";
|
|
326
539
|
})(OrderStatus || (OrderStatus = {}));
|
|
327
540
|
|
|
328
|
-
class Checkout extends BaseModel {
|
|
329
|
-
identifierFields() {
|
|
330
|
-
return ['id'];
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
541
|
class LineItem extends Product {
|
|
335
542
|
}
|
|
336
543
|
|
|
337
|
-
class
|
|
544
|
+
class ShippingMethod extends BaseModel {
|
|
545
|
+
identifierFields() {
|
|
546
|
+
return ['id'];
|
|
547
|
+
}
|
|
338
548
|
}
|
|
339
549
|
|
|
340
|
-
class
|
|
550
|
+
class Checkout extends BaseModel {
|
|
341
551
|
identifierFields() {
|
|
342
552
|
return ['id'];
|
|
343
553
|
}
|
|
344
554
|
}
|
|
345
555
|
__decorate([
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
Expose({ name: 'status_reason' })
|
|
350
|
-
], Payment.prototype, "statusReason", void 0);
|
|
556
|
+
Type(() => LineItem),
|
|
557
|
+
__metadata("design:type", Array)
|
|
558
|
+
], Checkout.prototype, "lineItems", void 0);
|
|
351
559
|
__decorate([
|
|
352
|
-
|
|
353
|
-
|
|
560
|
+
Type(() => User),
|
|
561
|
+
__metadata("design:type", User)
|
|
562
|
+
], Checkout.prototype, "user", void 0);
|
|
354
563
|
__decorate([
|
|
355
|
-
|
|
356
|
-
|
|
564
|
+
Type(() => Address),
|
|
565
|
+
__metadata("design:type", Address)
|
|
566
|
+
], Checkout.prototype, "shippingAddress", void 0);
|
|
357
567
|
__decorate([
|
|
358
|
-
|
|
359
|
-
|
|
568
|
+
Type(() => Address),
|
|
569
|
+
__metadata("design:type", Address)
|
|
570
|
+
], Checkout.prototype, "billingAddress", void 0);
|
|
360
571
|
__decorate([
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
Expose({ name: 'soft_descriptor' })
|
|
365
|
-
], Payment.prototype, "softDescriptor", void 0);
|
|
366
|
-
__decorate([
|
|
367
|
-
Expose({ name: 'date_created' })
|
|
368
|
-
], Payment.prototype, "dateCreated", void 0);
|
|
369
|
-
__decorate([
|
|
370
|
-
Expose({ name: 'date_updated' })
|
|
371
|
-
], Payment.prototype, "dateUpdated", void 0);
|
|
372
|
-
__decorate([
|
|
373
|
-
Expose({ name: 'authorized_amount' })
|
|
374
|
-
], Payment.prototype, "authorizedAmount", void 0);
|
|
572
|
+
Type(() => ShippingMethod),
|
|
573
|
+
__metadata("design:type", ShippingMethod)
|
|
574
|
+
], Checkout.prototype, "shipping", void 0);
|
|
375
575
|
__decorate([
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
Expose({ name: 'refunded_amount' })
|
|
380
|
-
], Payment.prototype, "refundedAmount", void 0);
|
|
381
|
-
__decorate([
|
|
382
|
-
Expose({ name: 'card_holder_name' })
|
|
383
|
-
], Payment.prototype, "cardHolderName", void 0);
|
|
384
|
-
__decorate([
|
|
385
|
-
Expose({ name: 'card_last_digits' })
|
|
386
|
-
], Payment.prototype, "cardLastDigits", void 0);
|
|
387
|
-
__decorate([
|
|
388
|
-
Expose({ name: 'card_first_digits' })
|
|
389
|
-
], Payment.prototype, "cardFirstDigits", void 0);
|
|
390
|
-
__decorate([
|
|
391
|
-
Expose({ name: 'card_brand' })
|
|
392
|
-
], Payment.prototype, "cardBrand", void 0);
|
|
393
|
-
__decorate([
|
|
394
|
-
Expose({ name: 'card_pin_mode' })
|
|
395
|
-
], Payment.prototype, "cardPinMode", void 0);
|
|
396
|
-
__decorate([
|
|
397
|
-
Expose({ name: 'card_magstripe_fallback' })
|
|
398
|
-
], Payment.prototype, "cardMagstripeFallback", void 0);
|
|
399
|
-
__decorate([
|
|
400
|
-
Expose({ name: 'cvm_pin' })
|
|
401
|
-
], Payment.prototype, "cvmPin", void 0);
|
|
402
|
-
__decorate([
|
|
403
|
-
Expose({ name: 'postback_url' })
|
|
404
|
-
], Payment.prototype, "postbackUrl", void 0);
|
|
405
|
-
__decorate([
|
|
406
|
-
Expose({ name: 'payment_method' })
|
|
407
|
-
], Payment.prototype, "paymentMethod", void 0);
|
|
408
|
-
__decorate([
|
|
409
|
-
Expose({ name: 'capture_method' })
|
|
410
|
-
], Payment.prototype, "captureMethod", void 0);
|
|
411
|
-
__decorate([
|
|
412
|
-
Expose({ name: 'antifraud_score' })
|
|
413
|
-
], Payment.prototype, "antifraudScore", void 0);
|
|
414
|
-
__decorate([
|
|
415
|
-
Expose({ name: 'boleto_url' })
|
|
416
|
-
], Payment.prototype, "boletoUrl", void 0);
|
|
417
|
-
__decorate([
|
|
418
|
-
Expose({ name: 'boleto_barcode' })
|
|
419
|
-
], Payment.prototype, "boletoBarcode", void 0);
|
|
420
|
-
__decorate([
|
|
421
|
-
Expose({ name: 'boleto_expiration_date' })
|
|
422
|
-
], Payment.prototype, "boletoExpirationDate", void 0);
|
|
423
|
-
__decorate([
|
|
424
|
-
Expose({ name: 'subscription_id' })
|
|
425
|
-
], Payment.prototype, "subscriptionId", void 0);
|
|
426
|
-
__decorate([
|
|
427
|
-
Expose({ name: 'split_rules' })
|
|
428
|
-
], Payment.prototype, "splitRules", void 0);
|
|
429
|
-
__decorate([
|
|
430
|
-
Expose({ name: 'antifraud_metadata' })
|
|
431
|
-
], Payment.prototype, "antifraudMetadata", void 0);
|
|
432
|
-
__decorate([
|
|
433
|
-
Expose({ name: 'reference_key' })
|
|
434
|
-
], Payment.prototype, "referenceKey", void 0);
|
|
435
|
-
__decorate([
|
|
436
|
-
Expose({ name: 'local_transaction_id' })
|
|
437
|
-
], Payment.prototype, "localTransactionId", void 0);
|
|
438
|
-
__decorate([
|
|
439
|
-
Expose({ name: 'local_time' })
|
|
440
|
-
], Payment.prototype, "localTime", void 0);
|
|
441
|
-
__decorate([
|
|
442
|
-
Expose({ name: 'fraud_covered' })
|
|
443
|
-
], Payment.prototype, "fraudCovered", void 0);
|
|
444
|
-
__decorate([
|
|
445
|
-
Expose({ name: 'fraud_reimbursed' })
|
|
446
|
-
], Payment.prototype, "fraudReimbursed", void 0);
|
|
447
|
-
__decorate([
|
|
448
|
-
Expose({ name: 'order_id' })
|
|
449
|
-
], Payment.prototype, "orderId", void 0);
|
|
450
|
-
__decorate([
|
|
451
|
-
Expose({ name: 'risk_level' })
|
|
452
|
-
], Payment.prototype, "riskLevel", void 0);
|
|
453
|
-
__decorate([
|
|
454
|
-
Expose({ name: 'receipt_url' })
|
|
455
|
-
], Payment.prototype, "receiptUrl", void 0);
|
|
456
|
-
__decorate([
|
|
457
|
-
Expose({ name: 'private_label' })
|
|
458
|
-
], Payment.prototype, "privateLabel", void 0);
|
|
459
|
-
__decorate([
|
|
460
|
-
Expose({ name: 'pix_qr_code' })
|
|
461
|
-
], Payment.prototype, "pixQrCode", void 0);
|
|
462
|
-
__decorate([
|
|
463
|
-
Expose({ name: 'pix_expiration_date' })
|
|
464
|
-
], Payment.prototype, "pixExpirationDate", void 0);
|
|
576
|
+
Type(() => Coupon),
|
|
577
|
+
__metadata("design:type", Coupon)
|
|
578
|
+
], Checkout.prototype, "coupon", void 0);
|
|
465
579
|
|
|
466
|
-
class
|
|
467
|
-
identifierFields() {
|
|
468
|
-
return ['id'];
|
|
469
|
-
}
|
|
580
|
+
class Order extends Checkout {
|
|
470
581
|
}
|
|
582
|
+
__decorate([
|
|
583
|
+
Type(() => Payment),
|
|
584
|
+
__metadata("design:type", Payment)
|
|
585
|
+
], Order.prototype, "payment", void 0);
|
|
471
586
|
|
|
472
587
|
class CheckoutSubscription extends BaseModel {
|
|
473
588
|
identifierFields() {
|
|
474
589
|
return ['id'];
|
|
475
590
|
}
|
|
476
591
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
592
|
+
__decorate([
|
|
593
|
+
Type(() => Address),
|
|
594
|
+
__metadata("design:type", Address)
|
|
595
|
+
], CheckoutSubscription.prototype, "shippingAddress", void 0);
|
|
596
|
+
__decorate([
|
|
597
|
+
Type(() => Address),
|
|
598
|
+
__metadata("design:type", Address)
|
|
599
|
+
], CheckoutSubscription.prototype, "billingAddress", void 0);
|
|
600
|
+
__decorate([
|
|
601
|
+
Type(() => SubscriptionPlan),
|
|
602
|
+
__metadata("design:type", SubscriptionPlan)
|
|
603
|
+
], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
|
|
604
|
+
__decorate([
|
|
605
|
+
Type(() => Coupon),
|
|
606
|
+
__metadata("design:type", Coupon)
|
|
607
|
+
], CheckoutSubscription.prototype, "coupon", void 0);
|
|
483
608
|
|
|
484
609
|
class Buy2Win extends BaseModel {
|
|
485
610
|
identifierFields() {
|
|
486
611
|
return ['id'];
|
|
487
612
|
}
|
|
488
613
|
}
|
|
614
|
+
__decorate([
|
|
615
|
+
Type(() => Category),
|
|
616
|
+
__metadata("design:type", Array)
|
|
617
|
+
], Buy2Win.prototype, "categories", void 0);
|
|
489
618
|
|
|
490
619
|
class Home extends BaseModel {
|
|
491
620
|
identifierFields() {
|
|
@@ -873,36 +1002,37 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
873
1002
|
}
|
|
874
1003
|
getCategoryBySlug(slug, shop) {
|
|
875
1004
|
return this.collection(this.collectionName)
|
|
876
|
-
.where(
|
|
877
|
-
.where(
|
|
878
|
-
.where(
|
|
879
|
-
.get()
|
|
1005
|
+
.where('slug', '==', slug)
|
|
1006
|
+
.where('shop', '==', shop)
|
|
1007
|
+
.where('published', '==', true)
|
|
1008
|
+
.get()
|
|
1009
|
+
.then((snap) => {
|
|
880
1010
|
if (snap.size > 1)
|
|
881
|
-
throw new DuplicatedResultsError(
|
|
1011
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
882
1012
|
if (snap.empty)
|
|
883
1013
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
884
1014
|
return snap.docs[0].data();
|
|
885
|
-
})
|
|
1015
|
+
})
|
|
1016
|
+
.catch((error) => error);
|
|
886
1017
|
}
|
|
887
1018
|
getCategoriesForHome(categoryIds) {
|
|
888
1019
|
return __awaiter(this, void 0, void 0, function* () {
|
|
889
1020
|
const categorySnap = yield this.collection(this.collectionName)
|
|
890
|
-
.where(
|
|
891
|
-
.where(
|
|
1021
|
+
.where('id', 'in', categoryIds)
|
|
1022
|
+
.where('published', '==', true)
|
|
892
1023
|
.get();
|
|
893
1024
|
if (categorySnap.empty)
|
|
894
|
-
throw new NotFoundError(
|
|
895
|
-
const categories = categorySnap.docs.map(doc => doc.data());
|
|
1025
|
+
throw new NotFoundError('Categories not found');
|
|
1026
|
+
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
896
1027
|
const homeSections = [];
|
|
897
1028
|
for (const category of categories) {
|
|
898
|
-
const productSnap = yield this.collection(
|
|
899
|
-
.where(
|
|
900
|
-
|
|
901
|
-
.where("stock.quantity", ">", 1)
|
|
1029
|
+
const productSnap = yield this.collection('products')
|
|
1030
|
+
.where('categories', 'array-contains', category.id)
|
|
1031
|
+
.where('stock.quantity', '>', 1)
|
|
902
1032
|
.limit(4)
|
|
903
1033
|
.get();
|
|
904
|
-
const products = productSnap.docs.map(doc => doc.data());
|
|
905
|
-
homeSections.push({
|
|
1034
|
+
const products = productSnap.docs.map((doc) => doc.data());
|
|
1035
|
+
homeSections.push({ category, products });
|
|
906
1036
|
}
|
|
907
1037
|
return homeSections;
|
|
908
1038
|
});
|
|
@@ -910,7 +1040,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
910
1040
|
mountCategory(category) {
|
|
911
1041
|
return __awaiter(this, void 0, void 0, function* () {
|
|
912
1042
|
if (!category.products)
|
|
913
|
-
throw new RequiredArgumentError([
|
|
1043
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
914
1044
|
const chunks = category.products.reduce((resultArray, item, index) => {
|
|
915
1045
|
const chunkIndex = Math.floor(index / 10);
|
|
916
1046
|
if (!resultArray[chunkIndex])
|
|
@@ -920,13 +1050,10 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
920
1050
|
}, []);
|
|
921
1051
|
const products = [];
|
|
922
1052
|
for (const productIds of chunks) {
|
|
923
|
-
const productSnap = yield this.collection(
|
|
924
|
-
.where("id", "in", productIds)
|
|
925
|
-
// .where("published", "==", true)
|
|
926
|
-
.get();
|
|
1053
|
+
const productSnap = yield this.collection('products').where('id', 'in', productIds).get();
|
|
927
1054
|
if (productSnap.empty)
|
|
928
1055
|
continue;
|
|
929
|
-
products.push(...productSnap.docs.map(doc => doc.data()));
|
|
1056
|
+
products.push(...productSnap.docs.map((doc) => doc.data()));
|
|
930
1057
|
}
|
|
931
1058
|
return products;
|
|
932
1059
|
});
|