rapida-partner 8.10.0 → 8.12.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 +3 -0
- package/src/interfaces/store-collection.interface.ts +18 -0
- package/src/interfaces/store-coupon.interface.ts +4 -0
- package/src/interfaces/store-settings.interface.ts +3 -1
- package/src/schemas/backend.ref.json +1 -0
- package/src/schemas/project-store.ref.json +1 -1
- package/src/schemas/store-settings.ref.json +2 -0
- package/src/utils/store-collection.ts +3 -0
- package/src/utils/store-coupon.ts +2 -0
- package/src/utils/store-references.test.ts +30 -0
- package/src/utils/store-references.ts +24 -2
package/package.json
CHANGED
|
@@ -118,6 +118,9 @@ interface IMarketplace {
|
|
|
118
118
|
// os selos em badgeIds da configuração de venda, por isso exige também
|
|
119
119
|
// productSellingSettingsEndpoint.
|
|
120
120
|
badgesEndpoint?: string;
|
|
121
|
+
// Coleções da home (módulo de rapida-projects getStoreCollectionsModule,
|
|
122
|
+
// funcionalidade "collections"): o cadastro IStoreCollection.
|
|
123
|
+
collectionsEndpoint?: string;
|
|
121
124
|
}
|
|
122
125
|
|
|
123
126
|
export interface IMarketplaceProductFieldMap {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coleção da home da loja (funcionalidade "collections"), como "Lançamentos"
|
|
3
|
+
* ou "Para o fim de semana": um título e os produtos, na ordem escolhida.
|
|
4
|
+
* Cadastrada no Backoffice do vendedor pelo módulo de rapida-projects
|
|
5
|
+
* getStoreCollectionsModule e lida pela loja por IMarketplace.collectionsEndpoint.
|
|
6
|
+
* É um cadastro próprio, e não uma lista na configuração da loja, porque os
|
|
7
|
+
* forms não guardam lista dentro de lista. Os campos são os nomes do form.
|
|
8
|
+
*/
|
|
9
|
+
export interface IStoreCollection {
|
|
10
|
+
title: string;
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
// Ids dos produtos do vendedor, na ordem em que aparecem.
|
|
13
|
+
productIds: string[];
|
|
14
|
+
// Ordem entre as coleções da home (menor primeiro).
|
|
15
|
+
displayOrder?: number;
|
|
16
|
+
// Desligada, a coleção sai da home.
|
|
17
|
+
isActive: boolean;
|
|
18
|
+
}
|
|
@@ -23,4 +23,8 @@ export interface IStoreCoupon {
|
|
|
23
23
|
usageLimit?: number;
|
|
24
24
|
usageLimitPerCustomer?: number;
|
|
25
25
|
isActive: boolean;
|
|
26
|
+
// Vitrine de cupons (funcionalidade "couponShowcase"): o cupom aparece na
|
|
27
|
+
// página pública /cupons e pode ir para o aviso da home. Sem o campo, o
|
|
28
|
+
// cupom continua só para quem conhece o código.
|
|
29
|
+
isPublic?: boolean;
|
|
26
30
|
}
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"optionGroupsEndpoint": { "type": "string" },
|
|
162
162
|
"optionsEndpoint": { "type": "string" },
|
|
163
163
|
"badgesEndpoint": { "type": "string" },
|
|
164
|
+
"collectionsEndpoint": { "type": "string" },
|
|
164
165
|
"productFieldMap": {
|
|
165
166
|
"type": "object",
|
|
166
167
|
"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"]
|
|
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"]
|
|
15
15
|
},
|
|
16
16
|
"uniqueItems": true
|
|
17
17
|
},
|
|
@@ -136,6 +136,8 @@
|
|
|
136
136
|
"attendeesEnabled": { "type": "boolean" },
|
|
137
137
|
"ticketsEnabled": { "type": "boolean" },
|
|
138
138
|
"productBadgesEnabled": { "type": "boolean" },
|
|
139
|
+
"couponShowcaseEnabled": { "type": "boolean" },
|
|
140
|
+
"collectionsEnabled": { "type": "boolean" },
|
|
139
141
|
"returnsEnabled": { "type": "boolean" }
|
|
140
142
|
},
|
|
141
143
|
"additionalProperties": false
|
|
@@ -49,3 +49,33 @@ describe("store.features com endereços obrigatórios", () => {
|
|
|
49
49
|
expect(checkStoreReferences(projectWith("referralCommerce", { features: ["productBadges"] }))).toEqual([]);
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
|
+
|
|
53
|
+
describe("vitrine de cupons", () => {
|
|
54
|
+
const store = (features: string[], marketplace: Record<string, string>): IProject =>
|
|
55
|
+
({ id: "p", title: "p", skeleton: "ecommerce", store: { features }, backend: [{ marketplace }] }) as unknown as IProject;
|
|
56
|
+
|
|
57
|
+
test("com cupons e couponsEndpoint não avisa", () => {
|
|
58
|
+
expect(checkStoreReferences(store(["coupons", "couponShowcase"], { couponsEndpoint: "/store-coupons" }))).toEqual([]);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("sem couponsEndpoint ou sem a funcionalidade de cupons avisa", () => {
|
|
62
|
+
expect(checkStoreReferences(store(["coupons", "couponShowcase"], {}))).toEqual([
|
|
63
|
+
"store.features \"couponShowcase\" precisa de backend.marketplace.couponsEndpoint; sem ele a funcionalidade não é gerada",
|
|
64
|
+
]);
|
|
65
|
+
expect(checkStoreReferences(store(["couponShowcase"], { couponsEndpoint: "/store-coupons" }))).toEqual([
|
|
66
|
+
"store.features \"couponShowcase\" só funciona junto com \"coupons\"; sem ela a funcionalidade não é gerada",
|
|
67
|
+
]);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("coleções da home", () => {
|
|
72
|
+
const store = (marketplace: Record<string, string>): IProject =>
|
|
73
|
+
({ id: "p", title: "p", skeleton: "marketplace", store: { features: ["collections"] }, backend: [{ marketplace }] }) as unknown as IProject;
|
|
74
|
+
|
|
75
|
+
test("com collectionsEndpoint não avisa; sem ele avisa", () => {
|
|
76
|
+
expect(checkStoreReferences(store({ collectionsEndpoint: "/store-collections" }))).toEqual([]);
|
|
77
|
+
expect(checkStoreReferences(store({}))).toEqual([
|
|
78
|
+
"store.features \"collections\" precisa de backend.marketplace.collectionsEndpoint; sem ele a funcionalidade não é gerada",
|
|
79
|
+
]);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -13,6 +13,13 @@ type TMarketplaceEndpoint = keyof {
|
|
|
13
13
|
/** Endereços de IMarketplace sem os quais a funcionalidade não é gerada. */
|
|
14
14
|
const FEATURE_ENDPOINTS: Partial<Record<TStoreFeature, TMarketplaceEndpoint[]>> = {
|
|
15
15
|
productBadges: ["badgesEndpoint", "productSellingSettingsEndpoint"],
|
|
16
|
+
couponShowcase: ["couponsEndpoint"],
|
|
17
|
+
collections: ["collectionsEndpoint"],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Funcionalidades que só existem junto com outra. */
|
|
21
|
+
const FEATURE_REQUIRES: Partial<Record<TStoreFeature, TStoreFeature>> = {
|
|
22
|
+
couponShowcase: "coupons",
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
const checkSegment = (project: IProject): string[] => {
|
|
@@ -31,9 +38,24 @@ const checkFeatureEndpoints = (project: IProject): string[] => {
|
|
|
31
38
|
const endpoints = FEATURE_ENDPOINTS[feature];
|
|
32
39
|
if (!endpoints || marketplaces.some((marketplace) => endpoints.every((endpoint) => !!marketplace[endpoint]))) return [];
|
|
33
40
|
return [
|
|
34
|
-
"store.features \"" + feature + "\" precisa de backend.marketplace." + endpoints.join(" e backend.marketplace.") + "; sem eles a funcionalidade não é gerada",
|
|
41
|
+
"store.features \"" + feature + "\" precisa de backend.marketplace." + endpoints.join(" e backend.marketplace.") + (endpoints.length > 1 ? "; sem eles" : "; sem ele") + " a funcionalidade não é gerada",
|
|
35
42
|
];
|
|
36
43
|
});
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
|
|
46
|
+
const checkFeatureRequires = (project: IProject): string[] => {
|
|
47
|
+
if (!project.store || !SELLING_SKELETONS.includes(project.skeleton)) return [];
|
|
48
|
+
const features = storeFeaturesOf(project.store);
|
|
49
|
+
return features.flatMap((feature) => {
|
|
50
|
+
const required = FEATURE_REQUIRES[feature];
|
|
51
|
+
return required && !features.includes(required)
|
|
52
|
+
? ["store.features \"" + feature + "\" só funciona junto com \"" + required + "\"; sem ela a funcionalidade não é gerada"]
|
|
53
|
+
: [];
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const checkStoreReferences = (project: IProject): string[] => [
|
|
58
|
+
...checkSegment(project),
|
|
59
|
+
...checkFeatureEndpoints(project),
|
|
60
|
+
...checkFeatureRequires(project),
|
|
61
|
+
];
|