@infrab4a/connect 5.3.0-beta.5 → 5.3.0-beta.7

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 CHANGED
@@ -6,6 +6,7 @@ require('reflect-metadata');
6
6
  var tslib = require('tslib');
7
7
  var classTransformer = require('class-transformer');
8
8
  var dateFns = require('date-fns');
9
+ var dateFnsTz = require('date-fns-tz');
9
10
  var lodash = require('lodash');
10
11
  var debug = require('debug');
11
12
  var serializeJavascript = require('serialize-javascript');
@@ -1813,15 +1814,17 @@ class AntifraudCardService {
1813
1814
  return true;
1814
1815
  }
1815
1816
  getTodayDateRange() {
1816
- const day = `${dateFns.format(new Date(), 'yyyy-MM-dd')}T00:00:00`;
1817
- const endOfDay = `${dateFns.format(new Date(), 'yyyy-MM-dd')}T23:59:59`;
1818
- return { day, endOfDay };
1817
+ const timeZone = 'America/Sao_Paulo';
1818
+ const today = dateFnsTz.utcToZonedTime(new Date(), timeZone);
1819
+ const day = dateFns.startOfDay(today);
1820
+ const endOfDay = dateFns.endOfDay(today);
1821
+ return { day: dateFns.addHours(day, 3), endOfDay: dateFns.addHours(endOfDay, 3) };
1819
1822
  }
1820
1823
  async getBlockedOrdersByMultipleCriteria(checkout, dateRange) {
1821
1824
  const { day, endOfDay } = dateRange;
1822
1825
  const dateFilter = [
1823
- { operator: exports.Where.GTE, value: new Date(day) },
1824
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
1826
+ { operator: exports.Where.GTE, value: day },
1827
+ { operator: exports.Where.LTE, value: endOfDay },
1825
1828
  ];
1826
1829
  const [ordersBlockedWithCpf, ordersBlockedWithEmail, ordersBlockedWithCep, ordersBlockedWithPhone] = await Promise.all([
1827
1830
  this.getBlockedOrdersByCpf(checkout.user?.cpf, dateFilter),
@@ -4835,6 +4838,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
4835
4838
  isChild(_id, _parentId) {
4836
4839
  return;
4837
4840
  }
4841
+ async getBrandsWithProducts() {
4842
+ return;
4843
+ }
4838
4844
  }
4839
4845
  tslib.__decorate([
4840
4846
  Log(),
@@ -6933,6 +6939,19 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6933
6939
  categoryFilterRepository: this.categoryFilterRepository,
6934
6940
  });
6935
6941
  }
6942
+ async getBrandsWithProducts() {
6943
+ const fields = ['id', 'name', 'slug', 'brand_category', 'published', 'images'];
6944
+ const { brands_with_products_query: data, } = await this.query('brands_with_products_query', fields);
6945
+ return data.map((brand) => Category.toInstance({
6946
+ id: brand.id,
6947
+ name: brand.name,
6948
+ slug: brand.slug,
6949
+ brandCategory: brand.brand_category,
6950
+ shops: brand.shops,
6951
+ published: brand.published,
6952
+ images: brand.images,
6953
+ }));
6954
+ }
6936
6955
  }
6937
6956
  tslib.__decorate([
6938
6957
  Log(),
@@ -7420,7 +7439,6 @@ const commonFields = [
7420
7439
  'weight',
7421
7440
  'gender',
7422
7441
  { intGender: { columnName: 'int_gender' } },
7423
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7424
7442
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7425
7443
  { isKit: { columnName: 'is_kit' } },
7426
7444
  { createdAt: { columnName: 'created_at' } },
@@ -7505,12 +7523,81 @@ const fieldsConfiguration$2 = [
7505
7523
  fields: [
7506
7524
  'id',
7507
7525
  'ean',
7508
- 'grade',
7509
- 'price',
7526
+ 'sku',
7527
+ 'description',
7528
+ {
7529
+ grade: {
7530
+ columnName: 'grade',
7531
+ type: HasuraGraphQLColumnType.Jsonb,
7532
+ },
7533
+ },
7534
+ {
7535
+ price: {
7536
+ columnName: 'price',
7537
+ from: (price, data) => ({
7538
+ price,
7539
+ fullPrice: data.full_price,
7540
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
7541
+ subscriberPrice: data.subscriber_price,
7542
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
7543
+ }),
7544
+ bindFindFilter: (sentence) => {
7545
+ const filters = Object.values(sentence).shift();
7546
+ return {
7547
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7548
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7549
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7550
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7551
+ }),
7552
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7553
+ subscriber_price: filters.subscriberPrice,
7554
+ }),
7555
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7556
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7557
+ }),
7558
+ };
7559
+ },
7560
+ bindPersistData: (priceData) => ({
7561
+ ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
7562
+ ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
7563
+ ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
7564
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7565
+ }),
7566
+ ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
7567
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
7568
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7569
+ }),
7570
+ }),
7571
+ },
7572
+ },
7510
7573
  'published',
7511
- 'stock',
7512
- { tagsCollection: { columnName: 'tags_collection' } },
7574
+ {
7575
+ stock: {
7576
+ columnName: 'stock',
7577
+ from: (quantity) => ({ quantity }),
7578
+ to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
7579
+ },
7580
+ },
7581
+ {
7582
+ images: {
7583
+ columnName: 'images',
7584
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7585
+ },
7586
+ },
7587
+ {
7588
+ miniatures: {
7589
+ columnName: 'miniatures',
7590
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7591
+ },
7592
+ },
7593
+ {
7594
+ imagesCard: {
7595
+ columnName: 'images_card',
7596
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7597
+ },
7598
+ },
7513
7599
  { tagsProfile: { columnName: 'tags_profile' } },
7600
+ { tagsCollection: { columnName: 'tags_collection' } },
7514
7601
  ],
7515
7602
  },
7516
7603
  },
@@ -8175,8 +8262,10 @@ const fieldsConfiguration$1 = [
8175
8262
  },
8176
8263
  'group',
8177
8264
  'validity',
8178
- // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8179
8265
  'published',
8266
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8267
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8268
+ { daysOfUse: { columnName: 'days_of_use' } },
8180
8269
  {
8181
8270
  images: {
8182
8271
  columnName: 'images',
@@ -8561,6 +8650,9 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
8561
8650
  productId: +productId,
8562
8651
  });
8563
8652
  }
8653
+ async getBrandsWithProducts() {
8654
+ return;
8655
+ }
8564
8656
  }
8565
8657
  tslib.__decorate([
8566
8658
  Log(),
@@ -9619,6 +9711,14 @@ Object.defineProperty(exports, 'subDays', {
9619
9711
  enumerable: true,
9620
9712
  get: function () { return dateFns.subDays; }
9621
9713
  });
9714
+ Object.defineProperty(exports, 'formatInTimeZone', {
9715
+ enumerable: true,
9716
+ get: function () { return dateFnsTz.formatInTimeZone; }
9717
+ });
9718
+ Object.defineProperty(exports, 'utcToZonedTime', {
9719
+ enumerable: true,
9720
+ get: function () { return dateFnsTz.utcToZonedTime; }
9721
+ });
9622
9722
  Object.defineProperty(exports, 'chunk', {
9623
9723
  enumerable: true,
9624
9724
  get: function () { return lodash.chunk; }
package/index.esm.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import 'reflect-metadata';
2
2
  import { __decorate, __metadata } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
4
- import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
4
+ import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
6
+ import { utcToZonedTime } from 'date-fns-tz';
7
+ export { formatInTimeZone, utcToZonedTime } from 'date-fns-tz';
6
8
  import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
7
9
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
8
10
  import { debug } from 'debug';
@@ -1788,15 +1790,17 @@ class AntifraudCardService {
1788
1790
  return true;
1789
1791
  }
1790
1792
  getTodayDateRange() {
1791
- const day = `${format(new Date(), 'yyyy-MM-dd')}T00:00:00`;
1792
- const endOfDay = `${format(new Date(), 'yyyy-MM-dd')}T23:59:59`;
1793
- return { day, endOfDay };
1793
+ const timeZone = 'America/Sao_Paulo';
1794
+ const today = utcToZonedTime(new Date(), timeZone);
1795
+ const day = startOfDay(today);
1796
+ const endOfDay$1 = endOfDay(today);
1797
+ return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
1794
1798
  }
1795
1799
  async getBlockedOrdersByMultipleCriteria(checkout, dateRange) {
1796
1800
  const { day, endOfDay } = dateRange;
1797
1801
  const dateFilter = [
1798
- { operator: Where.GTE, value: new Date(day) },
1799
- { operator: Where.LTE, value: new Date(endOfDay) },
1802
+ { operator: Where.GTE, value: day },
1803
+ { operator: Where.LTE, value: endOfDay },
1800
1804
  ];
1801
1805
  const [ordersBlockedWithCpf, ordersBlockedWithEmail, ordersBlockedWithCep, ordersBlockedWithPhone] = await Promise.all([
1802
1806
  this.getBlockedOrdersByCpf(checkout.user?.cpf, dateFilter),
@@ -4810,6 +4814,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
4810
4814
  isChild(_id, _parentId) {
4811
4815
  return;
4812
4816
  }
4817
+ async getBrandsWithProducts() {
4818
+ return;
4819
+ }
4813
4820
  }
4814
4821
  __decorate([
4815
4822
  Log(),
@@ -6908,6 +6915,19 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6908
6915
  categoryFilterRepository: this.categoryFilterRepository,
6909
6916
  });
6910
6917
  }
6918
+ async getBrandsWithProducts() {
6919
+ const fields = ['id', 'name', 'slug', 'brand_category', 'published', 'images'];
6920
+ const { brands_with_products_query: data, } = await this.query('brands_with_products_query', fields);
6921
+ return data.map((brand) => Category.toInstance({
6922
+ id: brand.id,
6923
+ name: brand.name,
6924
+ slug: brand.slug,
6925
+ brandCategory: brand.brand_category,
6926
+ shops: brand.shops,
6927
+ published: brand.published,
6928
+ images: brand.images,
6929
+ }));
6930
+ }
6911
6931
  }
6912
6932
  __decorate([
6913
6933
  Log(),
@@ -7395,7 +7415,6 @@ const commonFields = [
7395
7415
  'weight',
7396
7416
  'gender',
7397
7417
  { intGender: { columnName: 'int_gender' } },
7398
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7399
7418
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7400
7419
  { isKit: { columnName: 'is_kit' } },
7401
7420
  { createdAt: { columnName: 'created_at' } },
@@ -7480,12 +7499,81 @@ const fieldsConfiguration$2 = [
7480
7499
  fields: [
7481
7500
  'id',
7482
7501
  'ean',
7483
- 'grade',
7484
- 'price',
7502
+ 'sku',
7503
+ 'description',
7504
+ {
7505
+ grade: {
7506
+ columnName: 'grade',
7507
+ type: HasuraGraphQLColumnType.Jsonb,
7508
+ },
7509
+ },
7510
+ {
7511
+ price: {
7512
+ columnName: 'price',
7513
+ from: (price, data) => ({
7514
+ price,
7515
+ fullPrice: data.full_price,
7516
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
7517
+ subscriberPrice: data.subscriber_price,
7518
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
7519
+ }),
7520
+ bindFindFilter: (sentence) => {
7521
+ const filters = Object.values(sentence).shift();
7522
+ return {
7523
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7524
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7525
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7526
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7527
+ }),
7528
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7529
+ subscriber_price: filters.subscriberPrice,
7530
+ }),
7531
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7532
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7533
+ }),
7534
+ };
7535
+ },
7536
+ bindPersistData: (priceData) => ({
7537
+ ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
7538
+ ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
7539
+ ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
7540
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7541
+ }),
7542
+ ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
7543
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
7544
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7545
+ }),
7546
+ }),
7547
+ },
7548
+ },
7485
7549
  'published',
7486
- 'stock',
7487
- { tagsCollection: { columnName: 'tags_collection' } },
7550
+ {
7551
+ stock: {
7552
+ columnName: 'stock',
7553
+ from: (quantity) => ({ quantity }),
7554
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7555
+ },
7556
+ },
7557
+ {
7558
+ images: {
7559
+ columnName: 'images',
7560
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7561
+ },
7562
+ },
7563
+ {
7564
+ miniatures: {
7565
+ columnName: 'miniatures',
7566
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7567
+ },
7568
+ },
7569
+ {
7570
+ imagesCard: {
7571
+ columnName: 'images_card',
7572
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7573
+ },
7574
+ },
7488
7575
  { tagsProfile: { columnName: 'tags_profile' } },
7576
+ { tagsCollection: { columnName: 'tags_collection' } },
7489
7577
  ],
7490
7578
  },
7491
7579
  },
@@ -8150,8 +8238,10 @@ const fieldsConfiguration$1 = [
8150
8238
  },
8151
8239
  'group',
8152
8240
  'validity',
8153
- // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8154
8241
  'published',
8242
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8243
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8244
+ { daysOfUse: { columnName: 'days_of_use' } },
8155
8245
  {
8156
8246
  images: {
8157
8247
  columnName: 'images',
@@ -8536,6 +8626,9 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
8536
8626
  productId: +productId,
8537
8627
  });
8538
8628
  }
8629
+ async getBrandsWithProducts() {
8630
+ return;
8631
+ }
8539
8632
  }
8540
8633
  __decorate([
8541
8634
  Log(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.3.0-beta.5",
3
+ "version": "5.3.0-beta.7",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -11,7 +11,8 @@
11
11
  "dependencies": {
12
12
  "axios": "^0.27.2",
13
13
  "class-transformer": "^0.5.1",
14
- "date-fns": "^2.28.0",
14
+ "date-fns": "2.28.0",
15
+ "date-fns-tz": "2.0.1",
15
16
  "debug": "^4.3.4",
16
17
  "firebase": "^10.12.0",
17
18
  "gql-query-builder": "3.7.0",
@@ -24,7 +24,6 @@ export declare class ProductBase<T extends ProductBase<T, I>, I = ProductIdentif
24
24
  createdAt?: Date;
25
25
  updatedAt?: Date;
26
26
  brand: string;
27
- tags?: string[];
28
27
  tagsCollection?: string[];
29
28
  tagsProfile?: string[];
30
29
  filters?: string[];
@@ -0,0 +1,13 @@
1
+ import { CategoryImages } from './category-images.type';
2
+ export type BrandsShopMenu = {
3
+ id: string;
4
+ name: string;
5
+ slug: string;
6
+ brand_category: boolean;
7
+ published: boolean;
8
+ images: CategoryImages;
9
+ shops?: string[];
10
+ brand_logo?: string;
11
+ brand_banner?: string;
12
+ brand_banner_mobile?: string;
13
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './brand-equity-option.type';
2
+ export * from './brands-shop-menu.type';
2
3
  export * from './category-condition.type';
3
4
  export * from './category-images.type';
4
5
  export * from './category-metadata.type';
@@ -38,5 +38,6 @@ export interface CategoryRepository<T extends Category = Category> extends CrudR
38
38
  cache?: RepositoryCacheOptions;
39
39
  }): Promise<Category[]>;
40
40
  isChild(id: number, parentId: number): Promise<boolean>;
41
+ getBrandsWithProducts(): Promise<Category[]>;
41
42
  }
42
43
  export {};
@@ -28,5 +28,6 @@ export declare class CategoryFirestoreRepository extends CategoryFirestoreReposi
28
28
  getCategoryByShop(_shop: string): Promise<Category[]>;
29
29
  getChildren(_parentId: number): Promise<Category[]>;
30
30
  isChild(_id: number, _parentId: number): Promise<boolean>;
31
+ getBrandsWithProducts(): Promise<Category[]>;
31
32
  }
32
33
  export {};
@@ -33,5 +33,6 @@ export declare class CategoryHasuraGraphQLRepository extends CategoryHasuraGraph
33
33
  private updateProducts;
34
34
  private updateMetadata;
35
35
  private updateFilters;
36
+ getBrandsWithProducts(): Promise<Category[]>;
36
37
  }
37
38
  export {};
@@ -25,5 +25,6 @@ export declare class WishlistHasuraGraphQLRepository extends WishlistHasuraGraph
25
25
  private updateMetadata;
26
26
  addProduct(wishlistId: string, productId: string): Promise<void>;
27
27
  removeProduct(wishlistId: string, productId: string): Promise<void>;
28
+ getBrandsWithProducts(): Promise<Category[]>;
28
29
  }
29
30
  export {};
@@ -1,4 +1,5 @@
1
1
  import { add, addBusinessDays, addDays, addMonths, addYears, Duration, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
2
+ import { formatInTimeZone, utcToZonedTime } from 'date-fns-tz';
2
3
  import { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
3
4
  export type DateDuration = Duration;
4
5
  export * from './circular-dependencies';
@@ -13,4 +14,4 @@ export * from './obs-emitter';
13
14
  export * from './parse-datetime';
14
15
  export * from './serialize';
15
16
  export * from './types';
16
- export { add, addBusinessDays, addDays, addMonths, addYears, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };
17
+ export { add, addBusinessDays, addDays, addMonths, addYears, utcToZonedTime, formatInTimeZone, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };