@infrab4a/connect 4.0.0-beta.11 → 4.0.0-beta.13
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/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +7 -3
- package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
- package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +6 -2
- package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +6 -4
- package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +9 -3
- package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +6 -3
- package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +5 -3
- package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +7 -4
- package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +6 -4
- package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +11 -9
- package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +8 -6
- package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +10 -8
- package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +2 -0
- package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
- package/esm2020/infra/firebase/firestore/types/index.mjs +4 -3
- package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +1 -1
- package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +2 -2
- package/fesm2015/infrab4a-connect.mjs +206 -133
- package/fesm2015/infrab4a-connect.mjs.map +1 -1
- package/fesm2020/infrab4a-connect.mjs +201 -133
- package/fesm2020/infrab4a-connect.mjs.map +1 -1
- package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +2 -1
- package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +13 -4
- package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +6 -2
- package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
- package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +3 -4
- package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +14 -0
- package/infra/firebase/firestore/types/firestore.repository.type.d.ts +2 -0
- package/infra/firebase/firestore/types/index.d.ts +3 -2
- package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +3 -3
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -3
- package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +3 -3
- package/package.json +2 -2
|
@@ -1199,9 +1199,15 @@ const withFirestore = (MixinBase) => {
|
|
|
1199
1199
|
}), {});
|
|
1200
1200
|
};
|
|
1201
1201
|
return class extends MixinBase {
|
|
1202
|
-
constructor() {
|
|
1203
|
-
|
|
1202
|
+
constructor(...params) {
|
|
1203
|
+
const options = params[0];
|
|
1204
|
+
super(...params);
|
|
1204
1205
|
this.collectionName = '';
|
|
1206
|
+
this.firestore = options.firestore;
|
|
1207
|
+
this.collectionName = options.collectionName;
|
|
1208
|
+
this.model = options.model;
|
|
1209
|
+
this.fields = options.fields;
|
|
1210
|
+
this.interceptors = options.interceptors;
|
|
1205
1211
|
}
|
|
1206
1212
|
collection(path) {
|
|
1207
1213
|
return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
|
|
@@ -1248,11 +1254,14 @@ const withHelpers = (MixinBase) => {
|
|
|
1248
1254
|
const withGetFirestore = (MixinBase) => {
|
|
1249
1255
|
return class GetFirestore extends MixinBase {
|
|
1250
1256
|
async get(identifiers) {
|
|
1251
|
-
const
|
|
1257
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
|
|
1258
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
1259
|
+
const builded = intercepted?.instance || instance;
|
|
1260
|
+
const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1252
1261
|
const data = docRef.data();
|
|
1253
1262
|
if (isNil(data))
|
|
1254
1263
|
throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
|
|
1255
|
-
return data;
|
|
1264
|
+
return this.interceptors?.response?.(data, intercepted) || data;
|
|
1256
1265
|
}
|
|
1257
1266
|
buildCollectionPathForGet(identifiers) {
|
|
1258
1267
|
return this.isSubCollection(this)
|
|
@@ -1333,8 +1342,10 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1333
1342
|
return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
|
|
1334
1343
|
};
|
|
1335
1344
|
}
|
|
1336
|
-
async find(
|
|
1337
|
-
const collection = this.collection(this.buildCollectionPathForFind(filters));
|
|
1345
|
+
async find(find = {}) {
|
|
1346
|
+
const collection = this.collection(this.buildCollectionPathForFind(find.filters));
|
|
1347
|
+
const intercepted = await this.interceptors?.request?.({ find });
|
|
1348
|
+
const { filters, limits, orderBy } = intercepted.find || find;
|
|
1338
1349
|
const queries = this.makeFirestoreWhere(filters || {});
|
|
1339
1350
|
const ordination = this.makeFirestoreOrderBy(filters, orderBy);
|
|
1340
1351
|
const offsets = await this.defineLimits(filters, limits);
|
|
@@ -1342,7 +1353,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1342
1353
|
const docs = await getDocs(query(collection, ...queryArgumments));
|
|
1343
1354
|
const data = docs.docs.map((doc) => doc.data());
|
|
1344
1355
|
return {
|
|
1345
|
-
data,
|
|
1356
|
+
data: (await this.interceptors?.response?.(data, intercepted)) || data,
|
|
1346
1357
|
count: this.calculateCount(data, limits),
|
|
1347
1358
|
};
|
|
1348
1359
|
}
|
|
@@ -1378,9 +1389,13 @@ const withFindFirestore = (MixinBase) => {
|
|
|
1378
1389
|
const withCreateFirestore = (MixinBase) => {
|
|
1379
1390
|
return class CreateFirestore extends MixinBase {
|
|
1380
1391
|
async create(data) {
|
|
1381
|
-
const
|
|
1392
|
+
const instance = this.model.toInstance(data);
|
|
1393
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
1394
|
+
const builded = intercepted?.instance || instance;
|
|
1395
|
+
const docRef = await this.save(builded);
|
|
1382
1396
|
const doc = await getDoc(docRef);
|
|
1383
|
-
|
|
1397
|
+
const docBuilded = (await this.interceptors?.response?.(doc.data(), intercepted)) || doc.data();
|
|
1398
|
+
return docBuilded;
|
|
1384
1399
|
}
|
|
1385
1400
|
async save(data) {
|
|
1386
1401
|
const id = data.identifier[data.identifiersFields?.shift()]?.toString();
|
|
@@ -1424,9 +1439,12 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1424
1439
|
const model = new this.model();
|
|
1425
1440
|
const keyField = model.identifiersFields.shift();
|
|
1426
1441
|
const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
|
|
1427
|
-
|
|
1428
|
-
const
|
|
1429
|
-
|
|
1442
|
+
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
1443
|
+
const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
|
|
1444
|
+
const builded = intercepted?.instance || plainFromData;
|
|
1445
|
+
await setDoc(docRef, builded.toPlain(), { merge: true });
|
|
1446
|
+
const docData = await getDoc(docRef).then((doc) => doc.data());
|
|
1447
|
+
return this.interceptors?.response?.(docData, intercepted) || docData;
|
|
1430
1448
|
}
|
|
1431
1449
|
buildCollectionPathForUpdate(identifiers) {
|
|
1432
1450
|
return this.isSubCollection(this)
|
|
@@ -1448,7 +1466,11 @@ const withUpdateFirestore = (MixinBase) => {
|
|
|
1448
1466
|
const withDeleteFirestore = (MixinBase) => {
|
|
1449
1467
|
return class DeleteFirestore extends MixinBase {
|
|
1450
1468
|
async delete(identifiers) {
|
|
1451
|
-
|
|
1469
|
+
const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
|
|
1470
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
1471
|
+
const builded = intercepted?.instance || instance;
|
|
1472
|
+
await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
|
|
1473
|
+
await this.interceptors?.response?.(instance, intercepted);
|
|
1452
1474
|
}
|
|
1453
1475
|
buildCollectionPathForRemove(identifiers) {
|
|
1454
1476
|
return this.isSubCollection(this)
|
|
@@ -1460,8 +1482,10 @@ const withDeleteFirestore = (MixinBase) => {
|
|
|
1460
1482
|
|
|
1461
1483
|
const withSubCollection = (MixinBase, ParentModel) => {
|
|
1462
1484
|
return class SubCollectionMix extends MixinBase {
|
|
1463
|
-
constructor(...
|
|
1464
|
-
|
|
1485
|
+
constructor(...params) {
|
|
1486
|
+
const options = params[0];
|
|
1487
|
+
super(...params);
|
|
1488
|
+
this.parentIdField = options.parentIdField;
|
|
1465
1489
|
}
|
|
1466
1490
|
collection(path) {
|
|
1467
1491
|
return super.collection(path);
|
|
@@ -1475,73 +1499,87 @@ const withCrudFirestore = (MixinBase) => {
|
|
|
1475
1499
|
};
|
|
1476
1500
|
|
|
1477
1501
|
class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1478
|
-
constructor(firestore) {
|
|
1479
|
-
super(
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1502
|
+
constructor({ firestore, interceptors }) {
|
|
1503
|
+
super({
|
|
1504
|
+
firestore,
|
|
1505
|
+
collectionName: 'leads',
|
|
1506
|
+
model: Lead,
|
|
1507
|
+
interceptors,
|
|
1508
|
+
});
|
|
1483
1509
|
}
|
|
1484
1510
|
}
|
|
1485
1511
|
|
|
1486
1512
|
class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1487
|
-
constructor(firestore, parentRepository) {
|
|
1488
|
-
super(
|
|
1489
|
-
|
|
1513
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1514
|
+
super({
|
|
1515
|
+
firestore,
|
|
1516
|
+
collectionName: 'editions',
|
|
1517
|
+
parentIdField: 'subscriptionId',
|
|
1518
|
+
model: Edition,
|
|
1519
|
+
interceptors,
|
|
1520
|
+
});
|
|
1490
1521
|
this.parentRepository = parentRepository;
|
|
1491
|
-
this.collectionName = 'editions';
|
|
1492
|
-
this.parentIdField = 'subscriptionId';
|
|
1493
|
-
this.model = Edition;
|
|
1494
1522
|
}
|
|
1495
1523
|
}
|
|
1496
1524
|
|
|
1497
1525
|
class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1498
|
-
constructor(firestore) {
|
|
1499
|
-
super(
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1526
|
+
constructor({ firestore, interceptors, }) {
|
|
1527
|
+
super({
|
|
1528
|
+
firestore,
|
|
1529
|
+
collectionName: 'subscription',
|
|
1530
|
+
model: Subscription,
|
|
1531
|
+
interceptors,
|
|
1532
|
+
});
|
|
1503
1533
|
}
|
|
1504
1534
|
}
|
|
1505
1535
|
|
|
1506
1536
|
class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
|
|
1507
|
-
constructor(firestore, parentRepository) {
|
|
1508
|
-
super(
|
|
1509
|
-
|
|
1537
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1538
|
+
super({
|
|
1539
|
+
firestore,
|
|
1540
|
+
collectionName: 'payments',
|
|
1541
|
+
parentIdField: 'subscriptionId',
|
|
1542
|
+
model: SubscriptionPayment,
|
|
1543
|
+
interceptors,
|
|
1544
|
+
});
|
|
1510
1545
|
this.parentRepository = parentRepository;
|
|
1511
|
-
this.collectionName = 'payments';
|
|
1512
|
-
this.parentIdField = 'subscriptionId';
|
|
1513
|
-
this.model = SubscriptionPayment;
|
|
1514
1546
|
}
|
|
1515
1547
|
}
|
|
1516
1548
|
|
|
1517
1549
|
class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1518
|
-
constructor(firestore, parentRepository) {
|
|
1519
|
-
super(
|
|
1520
|
-
|
|
1550
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1551
|
+
super({
|
|
1552
|
+
firestore,
|
|
1553
|
+
collectionName: 'address',
|
|
1554
|
+
parentIdField: 'userId',
|
|
1555
|
+
model: UserAddress,
|
|
1556
|
+
interceptors,
|
|
1557
|
+
});
|
|
1521
1558
|
this.parentRepository = parentRepository;
|
|
1522
|
-
this.collectionName = 'address';
|
|
1523
|
-
this.parentIdField = 'userId';
|
|
1524
|
-
this.model = UserAddress;
|
|
1525
1559
|
}
|
|
1526
1560
|
}
|
|
1527
1561
|
|
|
1528
1562
|
class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1529
|
-
constructor(firestore, parentRepository) {
|
|
1530
|
-
super(
|
|
1531
|
-
|
|
1563
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1564
|
+
super({
|
|
1565
|
+
firestore,
|
|
1566
|
+
collectionName: 'CX',
|
|
1567
|
+
parentIdField: 'userId',
|
|
1568
|
+
model: BeautyProfile,
|
|
1569
|
+
interceptors,
|
|
1570
|
+
});
|
|
1532
1571
|
this.parentRepository = parentRepository;
|
|
1533
|
-
this.collectionName = 'CX';
|
|
1534
|
-
this.parentIdField = 'userId';
|
|
1535
|
-
this.model = BeautyProfile;
|
|
1536
1572
|
}
|
|
1537
1573
|
}
|
|
1538
1574
|
|
|
1539
1575
|
class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1540
|
-
constructor(firestore) {
|
|
1541
|
-
super(
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1576
|
+
constructor({ firestore, interceptors }) {
|
|
1577
|
+
super({
|
|
1578
|
+
firestore,
|
|
1579
|
+
collectionName: 'users',
|
|
1580
|
+
model: User,
|
|
1581
|
+
interceptors,
|
|
1582
|
+
});
|
|
1545
1583
|
}
|
|
1546
1584
|
async get(identifiers) {
|
|
1547
1585
|
const user = await super.get({ id: identifiers.id });
|
|
@@ -1581,22 +1619,26 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1581
1619
|
}
|
|
1582
1620
|
|
|
1583
1621
|
class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
|
|
1584
|
-
constructor(firestore, parentRepository) {
|
|
1585
|
-
super(
|
|
1586
|
-
|
|
1622
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1623
|
+
super({
|
|
1624
|
+
firestore,
|
|
1625
|
+
collectionName: 'payment_method',
|
|
1626
|
+
parentIdField: 'userId',
|
|
1627
|
+
model: UserPaymentMethod,
|
|
1628
|
+
interceptors,
|
|
1629
|
+
});
|
|
1587
1630
|
this.parentRepository = parentRepository;
|
|
1588
|
-
this.collectionName = 'payment_method';
|
|
1589
|
-
this.parentIdField = 'userId';
|
|
1590
|
-
this.model = UserPaymentMethod;
|
|
1591
1631
|
}
|
|
1592
1632
|
}
|
|
1593
1633
|
|
|
1594
1634
|
class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1595
|
-
constructor(firestore) {
|
|
1596
|
-
super(
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1635
|
+
constructor({ firestore, interceptors }) {
|
|
1636
|
+
super({
|
|
1637
|
+
firestore,
|
|
1638
|
+
collectionName: 'categories',
|
|
1639
|
+
model: Category,
|
|
1640
|
+
interceptors,
|
|
1641
|
+
});
|
|
1600
1642
|
}
|
|
1601
1643
|
async getCategoryBySlug(slug, shop) {
|
|
1602
1644
|
const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
|
|
@@ -1641,12 +1683,14 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
1641
1683
|
}
|
|
1642
1684
|
|
|
1643
1685
|
class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1644
|
-
constructor(firestore) {
|
|
1645
|
-
super(
|
|
1646
|
-
|
|
1686
|
+
constructor({ firestore, interceptors }) {
|
|
1687
|
+
super({
|
|
1688
|
+
firestore,
|
|
1689
|
+
collectionName: 'productsErpVitrine',
|
|
1690
|
+
model: Product,
|
|
1691
|
+
interceptors,
|
|
1692
|
+
});
|
|
1647
1693
|
this.reviews = {};
|
|
1648
|
-
this.collectionName = 'productsErpVitrine';
|
|
1649
|
-
this.model = Product;
|
|
1650
1694
|
}
|
|
1651
1695
|
async getBySlug(slug) {
|
|
1652
1696
|
const result = await this.find({
|
|
@@ -1684,40 +1728,48 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
1684
1728
|
}
|
|
1685
1729
|
|
|
1686
1730
|
class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
|
|
1687
|
-
constructor(firestore, parentRepository) {
|
|
1688
|
-
super(
|
|
1689
|
-
|
|
1731
|
+
constructor({ firestore, interceptors }, parentRepository) {
|
|
1732
|
+
super({
|
|
1733
|
+
firestore,
|
|
1734
|
+
collectionName: 'variants',
|
|
1735
|
+
parentIdField: 'productId',
|
|
1736
|
+
model: Variant,
|
|
1737
|
+
interceptors,
|
|
1738
|
+
});
|
|
1690
1739
|
this.parentRepository = parentRepository;
|
|
1691
|
-
this.collectionName = 'variants';
|
|
1692
|
-
this.parentIdField = 'productId';
|
|
1693
|
-
this.model = Variant;
|
|
1694
1740
|
}
|
|
1695
1741
|
}
|
|
1696
1742
|
|
|
1697
1743
|
class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1698
|
-
constructor(firestore) {
|
|
1699
|
-
super(
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1744
|
+
constructor({ firestore, interceptors }) {
|
|
1745
|
+
super({
|
|
1746
|
+
firestore,
|
|
1747
|
+
collectionName: 'subscriptionProducts',
|
|
1748
|
+
model: Product,
|
|
1749
|
+
interceptors,
|
|
1750
|
+
});
|
|
1703
1751
|
}
|
|
1704
1752
|
}
|
|
1705
1753
|
|
|
1706
1754
|
class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1707
|
-
constructor(firestore) {
|
|
1708
|
-
super(
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1755
|
+
constructor({ firestore, interceptors }) {
|
|
1756
|
+
super({
|
|
1757
|
+
firestore,
|
|
1758
|
+
collectionName: 'checkouts',
|
|
1759
|
+
model: Checkout,
|
|
1760
|
+
interceptors,
|
|
1761
|
+
});
|
|
1712
1762
|
}
|
|
1713
1763
|
}
|
|
1714
1764
|
|
|
1715
1765
|
class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1716
|
-
constructor(firestore) {
|
|
1717
|
-
super(
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1766
|
+
constructor({ firestore, interceptors }) {
|
|
1767
|
+
super({
|
|
1768
|
+
firestore,
|
|
1769
|
+
collectionName: 'coupons',
|
|
1770
|
+
model: Coupon,
|
|
1771
|
+
interceptors,
|
|
1772
|
+
});
|
|
1721
1773
|
}
|
|
1722
1774
|
buildModelInstance() {
|
|
1723
1775
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1739,9 +1791,16 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
|
|
|
1739
1791
|
}
|
|
1740
1792
|
|
|
1741
1793
|
class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1742
|
-
constructor(firestore) {
|
|
1743
|
-
super(
|
|
1744
|
-
|
|
1794
|
+
constructor({ firestore, interceptors }) {
|
|
1795
|
+
super({
|
|
1796
|
+
firestore,
|
|
1797
|
+
collectionName: 'orders',
|
|
1798
|
+
model: Order,
|
|
1799
|
+
interceptors,
|
|
1800
|
+
fields: {
|
|
1801
|
+
status: FirestoreFieldType.String,
|
|
1802
|
+
},
|
|
1803
|
+
});
|
|
1745
1804
|
this.orderFromFirestore = (order) => {
|
|
1746
1805
|
if (!!order?.lineItems?.length) {
|
|
1747
1806
|
order.lineItems = order.lineItems.map((lineItem) => {
|
|
@@ -1754,11 +1813,6 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1754
1813
|
}
|
|
1755
1814
|
return order;
|
|
1756
1815
|
};
|
|
1757
|
-
this.collectionName = 'orders';
|
|
1758
|
-
this.model = Order;
|
|
1759
|
-
this.fields = {
|
|
1760
|
-
status: FirestoreFieldType.String,
|
|
1761
|
-
};
|
|
1762
1816
|
}
|
|
1763
1817
|
buildModelInstance() {
|
|
1764
1818
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1773,53 +1827,67 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
1773
1827
|
}
|
|
1774
1828
|
|
|
1775
1829
|
class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1776
|
-
constructor(firestore) {
|
|
1777
|
-
super(
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1830
|
+
constructor({ firestore, interceptors }) {
|
|
1831
|
+
super({
|
|
1832
|
+
firestore,
|
|
1833
|
+
collectionName: 'payments',
|
|
1834
|
+
model: Payment,
|
|
1835
|
+
interceptors,
|
|
1836
|
+
});
|
|
1781
1837
|
}
|
|
1782
1838
|
}
|
|
1783
1839
|
|
|
1784
1840
|
class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1785
|
-
constructor(firestore) {
|
|
1786
|
-
super(
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1841
|
+
constructor({ firestore, interceptors, }) {
|
|
1842
|
+
super({
|
|
1843
|
+
firestore,
|
|
1844
|
+
collectionName: 'checkoutsSubscription',
|
|
1845
|
+
model: CheckoutSubscription,
|
|
1846
|
+
interceptors,
|
|
1847
|
+
});
|
|
1790
1848
|
}
|
|
1791
1849
|
}
|
|
1792
1850
|
|
|
1793
1851
|
class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1794
|
-
constructor(firestore) {
|
|
1795
|
-
super(
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1852
|
+
constructor({ firestore, interceptors, }) {
|
|
1853
|
+
super({
|
|
1854
|
+
firestore,
|
|
1855
|
+
collectionName: 'subscriptionPlans',
|
|
1856
|
+
model: SubscriptionPlan,
|
|
1857
|
+
interceptors,
|
|
1858
|
+
});
|
|
1799
1859
|
}
|
|
1800
1860
|
}
|
|
1801
1861
|
|
|
1802
1862
|
class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1803
|
-
constructor(firestore) {
|
|
1804
|
-
super(
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1863
|
+
constructor({ firestore, interceptors }) {
|
|
1864
|
+
super({
|
|
1865
|
+
firestore,
|
|
1866
|
+
collectionName: 'buy2win',
|
|
1867
|
+
model: Buy2Win,
|
|
1868
|
+
interceptors,
|
|
1869
|
+
});
|
|
1808
1870
|
}
|
|
1809
1871
|
}
|
|
1810
1872
|
|
|
1811
1873
|
class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
|
|
1812
|
-
constructor(firestore) {
|
|
1813
|
-
super(
|
|
1814
|
-
|
|
1874
|
+
constructor({ firestore, interceptors }) {
|
|
1875
|
+
super({
|
|
1876
|
+
firestore,
|
|
1877
|
+
interceptors,
|
|
1878
|
+
});
|
|
1815
1879
|
this.collectionName = 'legacyOrders';
|
|
1816
1880
|
}
|
|
1817
1881
|
}
|
|
1818
1882
|
|
|
1819
1883
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1820
|
-
constructor(firestore) {
|
|
1821
|
-
super(
|
|
1822
|
-
|
|
1884
|
+
constructor({ firestore, interceptors }) {
|
|
1885
|
+
super({
|
|
1886
|
+
firestore,
|
|
1887
|
+
collectionName: 'dms',
|
|
1888
|
+
model: Home,
|
|
1889
|
+
interceptors,
|
|
1890
|
+
});
|
|
1823
1891
|
this.homeToFirestore = (home) => {
|
|
1824
1892
|
if (home.data?.data) {
|
|
1825
1893
|
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
|
|
@@ -1848,8 +1916,6 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1848
1916
|
category: Category.toInstance(homeCategoryGroup.category),
|
|
1849
1917
|
products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
|
|
1850
1918
|
});
|
|
1851
|
-
this.collectionName = 'dms';
|
|
1852
|
-
this.model = Home;
|
|
1853
1919
|
}
|
|
1854
1920
|
buildModelInstance() {
|
|
1855
1921
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -1867,11 +1933,13 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
1867
1933
|
}
|
|
1868
1934
|
|
|
1869
1935
|
class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
1870
|
-
constructor(firestore) {
|
|
1871
|
-
super(
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1936
|
+
constructor({ firestore, interceptors }) {
|
|
1937
|
+
super({
|
|
1938
|
+
firestore,
|
|
1939
|
+
collectionName: 'shopMenus',
|
|
1940
|
+
model: ShopMenu,
|
|
1941
|
+
interceptors,
|
|
1942
|
+
});
|
|
1875
1943
|
}
|
|
1876
1944
|
}
|
|
1877
1945
|
|
|
@@ -3234,7 +3302,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3234
3302
|
subscriberPrice: data.subscriber_price,
|
|
3235
3303
|
}),
|
|
3236
3304
|
bindFindFilter: (sentence) => {
|
|
3237
|
-
const filters = Object.values(sentence
|
|
3305
|
+
const filters = Object.values(sentence).shift();
|
|
3238
3306
|
return {
|
|
3239
3307
|
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
3240
3308
|
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|