rapida-partner 8.13.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 +1 -1
- package/src/interfaces/project-backend.interface.ts +4 -0
- package/src/interfaces/store-loyalty.interface.ts +34 -0
- package/src/interfaces/store-order.interface.ts +4 -0
- package/src/interfaces/store-settings.interface.ts +2 -1
- package/src/schemas/backend.ref.json +2 -0
- package/src/schemas/project-store.ref.json +1 -1
- package/src/schemas/store-settings.ref.json +1 -0
- package/src/utils/store-loyalty.ts +2 -0
- package/src/utils/store-references.test.ts +11 -0
- package/src/utils/store-references.ts +1 -0
package/package.json
CHANGED
|
@@ -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,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;
|
|
@@ -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", "crossSell"]
|
|
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
|
},
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"couponShowcaseEnabled": { "type": "boolean" },
|
|
140
140
|
"collectionsEnabled": { "type": "boolean" },
|
|
141
141
|
"crossSellEnabled": { "type": "boolean" },
|
|
142
|
+
"loyaltyEnabled": { "type": "boolean" },
|
|
142
143
|
"returnsEnabled": { "type": "boolean" }
|
|
143
144
|
},
|
|
144
145
|
"additionalProperties": false
|
|
@@ -90,3 +90,14 @@ describe("oferta ao adicionar", () => {
|
|
|
90
90
|
]);
|
|
91
91
|
});
|
|
92
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
|
+
});
|
|
@@ -16,6 +16,7 @@ const FEATURE_ENDPOINTS: Partial<Record<TStoreFeature, TMarketplaceEndpoint[]>>
|
|
|
16
16
|
couponShowcase: ["couponsEndpoint"],
|
|
17
17
|
collections: ["collectionsEndpoint"],
|
|
18
18
|
crossSell: ["productSellingSettingsEndpoint"],
|
|
19
|
+
loyalty: ["loyaltyTiersEndpoint", "loyaltyBenefitsEndpoint"],
|
|
19
20
|
};
|
|
20
21
|
|
|
21
22
|
/** Funcionalidades que só existem junto com outra. */
|