rapida-partner 8.12.0 → 8.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapida-partner",
3
- "version": "8.12.0",
3
+ "version": "8.14.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -121,6 +121,10 @@ interface IMarketplace {
121
121
  // Coleções da home (módulo de rapida-projects getStoreCollectionsModule,
122
122
  // funcionalidade "collections"): o cadastro IStoreCollection.
123
123
  collectionsEndpoint?: string;
124
+ // Fidelidade (módulo de rapida-projects getStoreLoyaltyModule, funcionalidade
125
+ // "loyalty"): níveis (IStoreLoyaltyTier) e vantagens (IStoreLoyaltyBenefit).
126
+ loyaltyTiersEndpoint?: string;
127
+ loyaltyBenefitsEndpoint?: string;
124
128
  }
125
129
 
126
130
  export interface IMarketplaceProductFieldMap {
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Oferta ao adicionar (funcionalidade "crossSell"): outro produto com preço
3
+ * especial levando este, como "Batata frita por R$ 5,00 levando este lanche".
4
+ * Fica no campo crossSellOffers da configuração de venda do produto de origem
5
+ * (form productSellingSettingForm de rapida-projects, que recebe a lista por
6
+ * withCrossSellInSellingSettings). Ao adicionar o produto de origem, a loja
7
+ * mostra as ofertas; a oferta aceita é outra linha do carrinho.
8
+ *
9
+ * O servidor só aplica offerPrice até a quantidade do produto de origem no
10
+ * mesmo pedido; o que passar sai pelo preço normal. O produto ofertado é
11
+ * simples (sem variações nem adicionais); com variação, aponte o filho.
12
+ */
13
+ export interface IProductCrossSellOffer {
14
+ offerProductId: string;
15
+ // Preço especial por unidade; só vale se for menor que o preço normal.
16
+ offerPrice: number;
17
+ }
18
+
19
+ export interface IProductCrossSellLinks {
20
+ crossSellOffers?: IProductCrossSellOffer[];
21
+ }
@@ -0,0 +1,34 @@
1
+ import type { TStoreWeekday } from "./store-settings.interface";
2
+
3
+ /**
4
+ * Nível de fidelidade da loja (funcionalidade "loyalty"), o mesmo cadastro do
5
+ * loyaltyTier do rapida-projects: na loja, minVisits conta os pedidos pagos do
6
+ * cliente nos últimos periodDays dias. O nível do cliente é o de maior
7
+ * minVisits que ele atinge; não é gravado, é calculado a cada consulta.
8
+ * Lido pela loja por IMarketplace.loyaltyTiersEndpoint.
9
+ */
10
+ export interface IStoreLoyaltyTier {
11
+ name: string;
12
+ minVisits: number;
13
+ periodDays: number;
14
+ description?: string;
15
+ }
16
+
17
+ /**
18
+ * Vantagem de um nível (o mesmo cadastro do loyaltyBenefit): na loja, vira um
19
+ * desconto automático em % no fechamento, calculado no servidor. Fidelidade e
20
+ * cupom não somam: vale o maior. Sem loyaltyTierIds, vale para qualquer nível
21
+ * atingido. Lida pela loja por IMarketplace.loyaltyBenefitsEndpoint.
22
+ */
23
+ export interface IStoreLoyaltyBenefit {
24
+ name: string;
25
+ discountPercentage?: number;
26
+ isActive: boolean;
27
+ loyaltyTierIds?: string[];
28
+ // Sem dias, vale todos os dias (no fuso STORE_LOYALTY_TIME_ZONE).
29
+ weekDays?: TStoreWeekday[];
30
+ // A loja não conhece o aniversário do cliente: vantagem só no mês de aniversário não vale na loja.
31
+ isBirthdayMonthOnly?: boolean;
32
+ validFrom?: string;
33
+ validUntil?: string;
34
+ }
@@ -101,6 +101,10 @@ export interface IStoreOrder {
101
101
  // Telefone do cliente, só dígitos com DDD (Fase 8.1), para o WhatsApp do pedido.
102
102
  customerPhone?: string;
103
103
  items: IStoreOrderItem[];
104
+ // Fidelidade (funcionalidade "loyalty", Fase 7.3): nível do cliente no
105
+ // fechamento e o desconto que ele deu (já somado em discount).
106
+ loyaltyTierName?: string;
107
+ loyaltyDiscount?: number;
104
108
  // Endereço de entrega, em campos próprios (os forms não aninham objetos).
105
109
  addressZipCode?: string;
106
110
  addressStreet?: string;
@@ -27,7 +27,9 @@ export type TStoreFeature =
27
27
  | "tickets"
28
28
  | "productBadges"
29
29
  | "couponShowcase"
30
- | "collections";
30
+ | "collections"
31
+ | "crossSell"
32
+ | "loyalty";
31
33
 
32
34
  export type TStoreFeatureToggle = `${TStoreFeature}Enabled`;
33
35
 
@@ -162,6 +162,8 @@
162
162
  "optionsEndpoint": { "type": "string" },
163
163
  "badgesEndpoint": { "type": "string" },
164
164
  "collectionsEndpoint": { "type": "string" },
165
+ "loyaltyTiersEndpoint": { "type": "string" },
166
+ "loyaltyBenefitsEndpoint": { "type": "string" },
165
167
  "productFieldMap": {
166
168
  "type": "object",
167
169
  "properties": {
@@ -11,7 +11,7 @@
11
11
  "type": "array",
12
12
  "items": {
13
13
  "type": "string",
14
- "enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping", "coupons", "reviews", "returns", "openingHours", "pickup", "districtDelivery", "payOnDelivery", "itemNotes", "productOptions", "productVariants", "stockReservation", "attendees", "tickets", "productBadges", "couponShowcase", "collections"]
14
+ "enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping", "coupons", "reviews", "returns", "openingHours", "pickup", "districtDelivery", "payOnDelivery", "itemNotes", "productOptions", "productVariants", "stockReservation", "attendees", "tickets", "productBadges", "couponShowcase", "collections", "crossSell", "loyalty"]
15
15
  },
16
16
  "uniqueItems": true
17
17
  },
@@ -138,6 +138,8 @@
138
138
  "productBadgesEnabled": { "type": "boolean" },
139
139
  "couponShowcaseEnabled": { "type": "boolean" },
140
140
  "collectionsEnabled": { "type": "boolean" },
141
+ "crossSellEnabled": { "type": "boolean" },
142
+ "loyaltyEnabled": { "type": "boolean" },
141
143
  "returnsEnabled": { "type": "boolean" }
142
144
  },
143
145
  "additionalProperties": false
@@ -0,0 +1,2 @@
1
+ /** Oferta ao adicionar (funcionalidade "crossSell"): quantas ofertas a loja mostra por produto, no máximo. */
2
+ export const STORE_CROSS_SELL_OFFERS_LIMIT = 3;
@@ -0,0 +1,2 @@
1
+ /** Fidelidade (funcionalidade "loyalty"): fuso dos dias da semana das vantagens. */
2
+ export const STORE_LOYALTY_TIME_ZONE = "America/Sao_Paulo";
@@ -79,3 +79,25 @@ describe("coleções da home", () => {
79
79
  ]);
80
80
  });
81
81
  });
82
+
83
+ describe("oferta ao adicionar", () => {
84
+ test("crossSell sem productSellingSettingsEndpoint avisa", () => {
85
+ const store = (marketplace: Record<string, string>): IProject =>
86
+ ({ id: "p", title: "p", skeleton: "ecommerce", store: { segment: "food", features: ["crossSell"] }, backend: [{ marketplace }] }) as unknown as IProject;
87
+ expect(checkStoreReferences(store({ productSellingSettingsEndpoint: "/product-selling-settings" }))).toEqual([]);
88
+ expect(checkStoreReferences(store({}))).toEqual([
89
+ "store.features \"crossSell\" precisa de backend.marketplace.productSellingSettingsEndpoint; sem ele a funcionalidade não é gerada",
90
+ ]);
91
+ });
92
+ });
93
+
94
+ describe("fidelidade", () => {
95
+ test("loyalty sem os dois endereços avisa", () => {
96
+ const store = (marketplace: Record<string, string>): IProject =>
97
+ ({ id: "p", title: "p", skeleton: "ecommerce", store: { features: ["loyalty"] }, backend: [{ marketplace }] }) as unknown as IProject;
98
+ expect(checkStoreReferences(store({ loyaltyTiersEndpoint: "/loyalty-tiers", loyaltyBenefitsEndpoint: "/loyalty-benefits" }))).toEqual([]);
99
+ expect(checkStoreReferences(store({ loyaltyTiersEndpoint: "/loyalty-tiers" }))).toEqual([
100
+ "store.features \"loyalty\" precisa de backend.marketplace.loyaltyTiersEndpoint e backend.marketplace.loyaltyBenefitsEndpoint; sem eles a funcionalidade não é gerada",
101
+ ]);
102
+ });
103
+ });
@@ -15,6 +15,8 @@ const FEATURE_ENDPOINTS: Partial<Record<TStoreFeature, TMarketplaceEndpoint[]>>
15
15
  productBadges: ["badgesEndpoint", "productSellingSettingsEndpoint"],
16
16
  couponShowcase: ["couponsEndpoint"],
17
17
  collections: ["collectionsEndpoint"],
18
+ crossSell: ["productSellingSettingsEndpoint"],
19
+ loyalty: ["loyaltyTiersEndpoint", "loyaltyBenefitsEndpoint"],
18
20
  };
19
21
 
20
22
  /** Funcionalidades que só existem junto com outra. */