@infrab4a/connect 5.5.6-beta.10 → 5.5.6-beta.11

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
@@ -7409,6 +7409,44 @@ class ProductVariantReportHelper {
7409
7409
  }
7410
7410
  }
7411
7411
 
7412
+ const BFLU_OR_GLAMGIRL_WISHLIST_LISTING_FIELDS = [
7413
+ 'id',
7414
+ 'name',
7415
+ 'slug',
7416
+ 'personName',
7417
+ 'personPhoto',
7418
+ 'personHasPhoto',
7419
+ 'personType',
7420
+ 'published',
7421
+ 'updatedAt',
7422
+ ];
7423
+ const BFLU_OR_GLAMGIRL_WISHLIST_CACHE_DEFAULT = {
7424
+ enabled: true,
7425
+ ttl: 300,
7426
+ };
7427
+ function resolveBfluOrGlamgirlWishlistCacheOptions(options) {
7428
+ return { cache: options?.cache ?? BFLU_OR_GLAMGIRL_WISHLIST_CACHE_DEFAULT };
7429
+ }
7430
+ function buildBfluOrGlamgirlWishlistFindParams(params, shops) {
7431
+ return {
7432
+ ...params,
7433
+ fields: params.fields ?? BFLU_OR_GLAMGIRL_WISHLIST_LISTING_FIELDS,
7434
+ filters: {
7435
+ ...params.filters,
7436
+ published: true,
7437
+ shops: { operator: exports.Where.IN, value: shops },
7438
+ personType: params.filters?.personType ?? {
7439
+ operator: exports.Where.IN,
7440
+ value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
7441
+ },
7442
+ },
7443
+ orderBy: {
7444
+ personHasPhoto: 'desc',
7445
+ ...lodash.omit(params.orderBy, ['personHasPhoto']),
7446
+ },
7447
+ };
7448
+ }
7449
+
7412
7450
  const fieldsConfiguration$4 = [
7413
7451
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
7414
7452
  { firestoreId: { columnName: 'firestore_id' } },
@@ -9977,7 +10015,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
9977
10015
  throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
9978
10016
  return data;
9979
10017
  }
9980
- async find(params) {
10018
+ async find(params, options) {
9981
10019
  const { filters, ...rest } = params;
9982
10020
  return await super.find({
9983
10021
  ...rest,
@@ -9985,7 +10023,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
9985
10023
  ...filters,
9986
10024
  isWishlist: { operator: exports.Where.EQUALS, value: true },
9987
10025
  },
9988
- });
10026
+ }, options);
9989
10027
  }
9990
10028
  async update(params) {
9991
10029
  const { id: checkId, metadatas, ...data } = lodash.omit(params, ['products', 'filters']);
@@ -10053,23 +10091,8 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
10053
10091
  });
10054
10092
  return data;
10055
10093
  }
10056
- async findBfluOrGlamgirlWishlists(params, shops) {
10057
- return this.find({
10058
- ...params,
10059
- filters: {
10060
- ...params.filters,
10061
- published: true,
10062
- shops: { operator: exports.Where.LIKE, value: shops },
10063
- personType: params.filters?.personType ?? {
10064
- operator: exports.Where.IN,
10065
- value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
10066
- },
10067
- },
10068
- orderBy: {
10069
- personHasPhoto: 'desc',
10070
- ...lodash.omit(params.orderBy, ['personHasPhoto']),
10071
- },
10072
- });
10094
+ async findBfluOrGlamgirlWishlists(params, shops, options) {
10095
+ return this.find(buildBfluOrGlamgirlWishlistFindParams(params, shops), resolveBfluOrGlamgirlWishlistCacheOptions(options));
10073
10096
  }
10074
10097
  getCategoriesForHome() {
10075
10098
  return;
@@ -10156,7 +10179,7 @@ tslib.__decorate([
10156
10179
  tslib.__decorate([
10157
10180
  Log(),
10158
10181
  tslib.__metadata("design:type", Function),
10159
- tslib.__metadata("design:paramtypes", [Object, Array]),
10182
+ tslib.__metadata("design:paramtypes", [Object, Array, Object]),
10160
10183
  tslib.__metadata("design:returntype", Promise)
10161
10184
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
10162
10185
 
@@ -11098,20 +11121,24 @@ class PagarMeV5RequestHelper {
11098
11121
  };
11099
11122
  }
11100
11123
  static getCardOrder(checkout, card) {
11124
+ const billingAddress = {
11125
+ line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
11126
+ zip_code: checkout.billingAddress.zip,
11127
+ city: checkout.billingAddress.city,
11128
+ state: checkout.billingAddress.state,
11129
+ country: 'BR',
11130
+ };
11131
+ // Tokenized charges (e.g. shopping recurrence renewals) must not send empty/undefined CVV.
11132
+ // First checkout still passes cardCvv when the shopper types it.
11133
+ const cardPayload = {
11134
+ billing_address: billingAddress,
11135
+ ...(card.cardCvv ? { cvv: card.cardCvv } : {}),
11136
+ };
11101
11137
  return {
11102
11138
  installments: card.installments,
11103
11139
  statement_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'loja glam' : 'mens market',
11104
11140
  card_id: card.cardId,
11105
- card: {
11106
- cvv: card.cardCvv,
11107
- billing_address: {
11108
- line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
11109
- zip_code: checkout.billingAddress.zip,
11110
- city: checkout.billingAddress.city,
11111
- state: checkout.billingAddress.state,
11112
- country: 'BR',
11113
- },
11114
- },
11141
+ card: cardPayload,
11115
11142
  };
11116
11143
  }
11117
11144
  static buildAdditionalInfo(checkout) {
package/index.esm.js CHANGED
@@ -7410,6 +7410,44 @@ class ProductVariantReportHelper {
7410
7410
  }
7411
7411
  }
7412
7412
 
7413
+ const BFLU_OR_GLAMGIRL_WISHLIST_LISTING_FIELDS = [
7414
+ 'id',
7415
+ 'name',
7416
+ 'slug',
7417
+ 'personName',
7418
+ 'personPhoto',
7419
+ 'personHasPhoto',
7420
+ 'personType',
7421
+ 'published',
7422
+ 'updatedAt',
7423
+ ];
7424
+ const BFLU_OR_GLAMGIRL_WISHLIST_CACHE_DEFAULT = {
7425
+ enabled: true,
7426
+ ttl: 300,
7427
+ };
7428
+ function resolveBfluOrGlamgirlWishlistCacheOptions(options) {
7429
+ return { cache: options?.cache ?? BFLU_OR_GLAMGIRL_WISHLIST_CACHE_DEFAULT };
7430
+ }
7431
+ function buildBfluOrGlamgirlWishlistFindParams(params, shops) {
7432
+ return {
7433
+ ...params,
7434
+ fields: params.fields ?? BFLU_OR_GLAMGIRL_WISHLIST_LISTING_FIELDS,
7435
+ filters: {
7436
+ ...params.filters,
7437
+ published: true,
7438
+ shops: { operator: Where.IN, value: shops },
7439
+ personType: params.filters?.personType ?? {
7440
+ operator: Where.IN,
7441
+ value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
7442
+ },
7443
+ },
7444
+ orderBy: {
7445
+ personHasPhoto: 'desc',
7446
+ ...omit(params.orderBy, ['personHasPhoto']),
7447
+ },
7448
+ };
7449
+ }
7450
+
7413
7451
  const fieldsConfiguration$4 = [
7414
7452
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
7415
7453
  { firestoreId: { columnName: 'firestore_id' } },
@@ -9978,7 +10016,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
9978
10016
  throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
9979
10017
  return data;
9980
10018
  }
9981
- async find(params) {
10019
+ async find(params, options) {
9982
10020
  const { filters, ...rest } = params;
9983
10021
  return await super.find({
9984
10022
  ...rest,
@@ -9986,7 +10024,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
9986
10024
  ...filters,
9987
10025
  isWishlist: { operator: Where.EQUALS, value: true },
9988
10026
  },
9989
- });
10027
+ }, options);
9990
10028
  }
9991
10029
  async update(params) {
9992
10030
  const { id: checkId, metadatas, ...data } = omit(params, ['products', 'filters']);
@@ -10054,23 +10092,8 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
10054
10092
  });
10055
10093
  return data;
10056
10094
  }
10057
- async findBfluOrGlamgirlWishlists(params, shops) {
10058
- return this.find({
10059
- ...params,
10060
- filters: {
10061
- ...params.filters,
10062
- published: true,
10063
- shops: { operator: Where.LIKE, value: shops },
10064
- personType: params.filters?.personType ?? {
10065
- operator: Where.IN,
10066
- value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
10067
- },
10068
- },
10069
- orderBy: {
10070
- personHasPhoto: 'desc',
10071
- ...omit(params.orderBy, ['personHasPhoto']),
10072
- },
10073
- });
10095
+ async findBfluOrGlamgirlWishlists(params, shops, options) {
10096
+ return this.find(buildBfluOrGlamgirlWishlistFindParams(params, shops), resolveBfluOrGlamgirlWishlistCacheOptions(options));
10074
10097
  }
10075
10098
  getCategoriesForHome() {
10076
10099
  return;
@@ -10157,7 +10180,7 @@ __decorate([
10157
10180
  __decorate([
10158
10181
  Log(),
10159
10182
  __metadata("design:type", Function),
10160
- __metadata("design:paramtypes", [Object, Array]),
10183
+ __metadata("design:paramtypes", [Object, Array, Object]),
10161
10184
  __metadata("design:returntype", Promise)
10162
10185
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
10163
10186
 
@@ -11099,20 +11122,24 @@ class PagarMeV5RequestHelper {
11099
11122
  };
11100
11123
  }
11101
11124
  static getCardOrder(checkout, card) {
11125
+ const billingAddress = {
11126
+ line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
11127
+ zip_code: checkout.billingAddress.zip,
11128
+ city: checkout.billingAddress.city,
11129
+ state: checkout.billingAddress.state,
11130
+ country: 'BR',
11131
+ };
11132
+ // Tokenized charges (e.g. shopping recurrence renewals) must not send empty/undefined CVV.
11133
+ // First checkout still passes cardCvv when the shopper types it.
11134
+ const cardPayload = {
11135
+ billing_address: billingAddress,
11136
+ ...(card.cardCvv ? { cvv: card.cardCvv } : {}),
11137
+ };
11102
11138
  return {
11103
11139
  installments: card.installments,
11104
11140
  statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'loja glam' : 'mens market',
11105
11141
  card_id: card.cardId,
11106
- card: {
11107
- cvv: card.cardCvv,
11108
- billing_address: {
11109
- line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
11110
- zip_code: checkout.billingAddress.zip,
11111
- city: checkout.billingAddress.city,
11112
- state: checkout.billingAddress.state,
11113
- country: 'BR',
11114
- },
11115
- },
11142
+ card: cardPayload,
11116
11143
  };
11117
11144
  }
11118
11145
  static buildAdditionalInfo(checkout) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.5.6-beta.10",
3
+ "version": "5.5.6-beta.11",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -1,11 +1,13 @@
1
- import { FindRepositoryParams, RepositoryFindResult } from '../../generic';
1
+ import { FindRepositoryParams, RepositoryCacheOptions, RepositoryFindResult } from '../../generic';
2
2
  import { Shops } from '../models';
3
3
  import { Wishlist } from '../models/wishlist';
4
4
  import { CategoryRepository } from '.';
5
5
  export interface WishlistRepository extends CategoryRepository<Wishlist> {
6
6
  getWishlistBySlug(slug: string): Promise<Wishlist>;
7
7
  getWishlistByPerson(personId: string): Promise<Wishlist[]>;
8
- findBfluOrGlamgirlWishlists(params: FindRepositoryParams<Wishlist>, shops: Shops[]): Promise<RepositoryFindResult<Wishlist>>;
8
+ findBfluOrGlamgirlWishlists(params: FindRepositoryParams<Wishlist>, shops: Shops[], options?: {
9
+ cache?: RepositoryCacheOptions;
10
+ }): Promise<RepositoryFindResult<Wishlist>>;
9
11
  addProduct(wishlistId: string, productId: string): Promise<void>;
10
12
  removeProduct(wishlistId: string, productId: string): Promise<void>;
11
13
  }
@@ -19,6 +19,10 @@ export declare class Checkout extends BaseModel<Checkout> {
19
19
  glampoints?: number;
20
20
  pointsUsed?: number;
21
21
  pointsDiscount?: number;
22
+ /**
23
+ * Why shippingDiscount was applied. Null/absent when no shipping discount.
24
+ */
25
+ shippingDiscountSource?: 'threshold_sp' | 'coupon' | null;
22
26
  lineItems?: LineItem[];
23
27
  user?: User;
24
28
  shippingAddress?: UserAddress;
@@ -1,8 +1,7 @@
1
1
  import { Shops } from '../../../catalog/models/enums/shops.enum';
2
2
  import { BaseModel, GenericIdentifier } from '../../../generic/model/base.model';
3
3
  import { User, UserAddress } from '../../../users';
4
- import { PaymentMethod } from '../../types';
5
- import { PaymentProvider } from '../../types/payment-provider.type';
4
+ import { CardForPaymentInfo, PaymentMethod } from '../../types';
6
5
  import { Coupon } from '../coupons/coupon';
7
6
  import { ShoppingRecurrenceCycle } from '../enums/shopping-recurrence-cycle.enum';
8
7
  import { ShoppingRecurrenceStatus } from '../enums/shopping-recurrence-status.enum';
@@ -23,10 +22,7 @@ export declare class ShoppingRecurrence extends BaseModel<ShoppingRecurrence> {
23
22
  discount?: number;
24
23
  totalPrice: number;
25
24
  paymentMethod: PaymentMethod;
26
- cards: Array<{
27
- paymentProvider: PaymentProvider;
28
- cardId: string;
29
- }>;
25
+ cards: CardForPaymentInfo[];
30
26
  originalOrderId: string;
31
27
  lastOrderId?: string;
32
28
  user: User;
@@ -1,3 +1,4 @@
1
+ export type ShippingFreeShippingSource = 'edition' | 'threshold_sp';
1
2
  export type ShippingMethodResponse = {
2
3
  daysToDelivery: number;
3
4
  currency?: string;
@@ -10,4 +11,16 @@ export type ShippingMethodResponse = {
10
11
  additionalDescription?: string;
11
12
  cnpj?: string;
12
13
  ShippingCompanyName?: string;
14
+ /**
15
+ * Original quote before free-shipping zeroing (when a benefit applied).
16
+ */
17
+ listTotalPrice?: number;
18
+ /**
19
+ * Cheapest non-Same Day quote at the time free shipping was evaluated.
20
+ */
21
+ cheapestListTotalPrice?: number;
22
+ /**
23
+ * Why free shipping was applied to this option (UI still shows totalPrice 0).
24
+ */
25
+ freeShippingSource?: ShippingFreeShippingSource;
13
26
  };
@@ -8,3 +8,4 @@ export * from './product-review-cache.helper';
8
8
  export * from './product-review-operations.helper';
9
9
  export * from './product-review-update.helper';
10
10
  export * from './product-variant-report.helper';
11
+ export * from './wishlist-listing-find.helper';
@@ -0,0 +1,10 @@
1
+ import { FindRepositoryParams, NonFunctionPropertyNames, RepositoryCacheOptions, Shops } from '../../../../../domain';
2
+ import { WishlistHasuraGraphQL } from '../../../models/wishlist-hasura-graphql';
3
+ export declare const BFLU_OR_GLAMGIRL_WISHLIST_LISTING_FIELDS: NonFunctionPropertyNames<WishlistHasuraGraphQL>[];
4
+ export declare const BFLU_OR_GLAMGIRL_WISHLIST_CACHE_DEFAULT: RepositoryCacheOptions;
5
+ export declare function resolveBfluOrGlamgirlWishlistCacheOptions(options?: {
6
+ cache?: RepositoryCacheOptions;
7
+ }): {
8
+ cache?: RepositoryCacheOptions;
9
+ };
10
+ export declare function buildBfluOrGlamgirlWishlistFindParams(params: FindRepositoryParams<WishlistHasuraGraphQL>, shops: Shops[]): FindRepositoryParams<WishlistHasuraGraphQL>;
@@ -1,4 +1,4 @@
1
- import { Category, CreateRepositoryParams, FindRepositoryParams, GetRepositoryParams, Product, RepositoryFindResult, Shops, UpdateRepositoryParams, Wishlist, WishlistRepository } from '../../../../domain';
1
+ import { Category, CreateRepositoryParams, FindRepositoryParams, GetRepositoryParams, Product, RepositoryCacheOptions, RepositoryFindResult, Shops, UpdateRepositoryParams, Wishlist, WishlistRepository } from '../../../../domain';
2
2
  import { HasuraConstructorParams } from '../../mixins';
3
3
  import { WishlistHasuraGraphQL } from '../../models/wishlist-hasura-graphql';
4
4
  import { CategoryProductHasuraGraphQLRepository } from './category-product-hasura-graphql.repository';
@@ -8,13 +8,17 @@ export declare class WishlistHasuraGraphQLRepository extends WishlistHasuraGraph
8
8
  constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<Wishlist>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>, categoryProductRepository: CategoryProductHasuraGraphQLRepository);
9
9
  create(params: CreateRepositoryParams<WishlistHasuraGraphQL>): Promise<WishlistHasuraGraphQL>;
10
10
  get(identifiers: GetRepositoryParams<WishlistHasuraGraphQL>): Promise<WishlistHasuraGraphQL>;
11
- find(params?: FindRepositoryParams<WishlistHasuraGraphQL>): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
11
+ find(params?: FindRepositoryParams<WishlistHasuraGraphQL>, options?: {
12
+ cache?: RepositoryCacheOptions;
13
+ }): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
12
14
  update(params: UpdateRepositoryParams<WishlistHasuraGraphQL>): Promise<WishlistHasuraGraphQL>;
13
15
  getWishlistBySlug(slug: string): Promise<WishlistHasuraGraphQL>;
14
16
  getWishlistByPerson(personId: string): Promise<WishlistHasuraGraphQL[]>;
15
17
  getCategoryBySlug(slug: string, _shop: Shops): Promise<Wishlist>;
16
18
  getCategoryByShop(shop: string): Promise<any>;
17
- findBfluOrGlamgirlWishlists(params: FindRepositoryParams<WishlistHasuraGraphQL>, shops: Shops[]): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
19
+ findBfluOrGlamgirlWishlists(params: FindRepositoryParams<WishlistHasuraGraphQL>, shops: Shops[], options?: {
20
+ cache?: RepositoryCacheOptions;
21
+ }): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
18
22
  getCategoriesForHome(): Promise<{
19
23
  category: Category;
20
24
  products: Product[];
@@ -65,7 +65,8 @@ export type PagarMeV5OrderPaymentCardInfo = {
65
65
  statement_descriptor: string;
66
66
  card_id: string;
67
67
  card: {
68
- cvv: string;
68
+ /** Present only on first charge when the shopper types CVV. Omitted for tokenized renewals. */
69
+ cvv?: string;
69
70
  billing_address?: {
70
71
  line_1: string;
71
72
  zip_code: string;
package/src/test.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};