@plentymarkets/shop-core 1.1.0 → 1.2.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/README.md +25 -36
- package/dist/module.json +1 -1
- package/dist/runtime/composables/__tests__/useCookieBar.spec.js +8 -0
- package/dist/runtime/composables/__tests__/useCookieConsent.spec.js +0 -7
- package/dist/runtime/composables/useCookieBar.d.ts +1 -0
- package/dist/runtime/composables/useCookieBar.js +12 -1
- package/dist/runtime/composables/useCookieConsent.d.ts +0 -1
- package/dist/runtime/composables/useCookieConsent.js +1 -14
- package/dist/runtime/types/events.d.ts +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
# Shop Core
|
|
2
2
|
|
|
3
|
-
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
-
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
-
[![License][license-src]][license-href]
|
|
6
|
-
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
-
|
|
8
|
-
My new Nuxt module for doing amazing things.
|
|
9
|
-
|
|
10
3
|
- [✨ Release Notes](/CHANGELOG.md)
|
|
11
|
-
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/shop-core?file=playground%2Fapp.vue) -->
|
|
12
|
-
<!-- - [📖 Documentation](https://example.com) -->
|
|
13
4
|
|
|
14
5
|
## Features
|
|
15
6
|
|
|
@@ -22,36 +13,34 @@ My new Nuxt module for doing amazing things.
|
|
|
22
13
|
Install the module to your Nuxt application with one command:
|
|
23
14
|
|
|
24
15
|
```bash
|
|
25
|
-
npx nuxi module add shop-core
|
|
16
|
+
npx nuxi module add @plentymarkets/shop-core
|
|
26
17
|
```
|
|
27
18
|
|
|
28
|
-
That's it! You can now use My Module in your Nuxt app ✨
|
|
29
|
-
|
|
30
19
|
## Contribution
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install dependencies
|
|
23
|
+
bun install
|
|
24
|
+
|
|
25
|
+
# Generate type stubs
|
|
26
|
+
bun run dev:prepare
|
|
27
|
+
|
|
28
|
+
# Develop with the playground
|
|
29
|
+
bun run dev
|
|
30
|
+
|
|
31
|
+
# Build the playground
|
|
32
|
+
bun run dev:build
|
|
33
|
+
|
|
34
|
+
# Run ESLint
|
|
35
|
+
bun run lint
|
|
36
|
+
|
|
37
|
+
# Run Vitest
|
|
38
|
+
bun run test
|
|
39
|
+
bun run test:watch
|
|
40
|
+
|
|
41
|
+
# Release new version
|
|
42
|
+
bun run release
|
|
43
|
+
```
|
|
55
44
|
|
|
56
45
|
<!-- Badges -->
|
|
57
46
|
|
package/dist/module.json
CHANGED
|
@@ -2,6 +2,7 @@ import { useRuntimeConfig } from "nuxt/app";
|
|
|
2
2
|
import { describe, it, expect } from "vitest";
|
|
3
3
|
import { mockNuxtImport } from "@nuxt/test-utils/runtime";
|
|
4
4
|
import { useCookieBar } from "../useCookieBar.js";
|
|
5
|
+
import { useCookieConsent } from "../useCookieConsent.js";
|
|
5
6
|
const { useCookie } = vi.hoisted(() => ({
|
|
6
7
|
useCookie: vi.fn().mockReturnValue({})
|
|
7
8
|
}));
|
|
@@ -140,4 +141,11 @@ describe("useCookieBar", () => {
|
|
|
140
141
|
"https://cdn02.plentymarkets.com/mevofvd5omld/frontend/test-cookie-external-script.js"
|
|
141
142
|
);
|
|
142
143
|
});
|
|
144
|
+
it("accepts the specific cookie correctly", () => {
|
|
145
|
+
const { data, accept } = useCookieBar();
|
|
146
|
+
const { consent } = useCookieConsent("testCookie");
|
|
147
|
+
accept("testCookie");
|
|
148
|
+
expect(data.value.groups[1].cookies[0].accepted).toBe(true);
|
|
149
|
+
expect(consent.value).toBe(true);
|
|
150
|
+
});
|
|
143
151
|
});
|
|
@@ -44,11 +44,4 @@ describe("useCookieConsent", () => {
|
|
|
44
44
|
const { consent } = useCookieConsent("CookieBar.essentials.cookies.payPal.name");
|
|
45
45
|
expect(consent.value).toBe(true);
|
|
46
46
|
});
|
|
47
|
-
it("accepts the specific cookie correctly", () => {
|
|
48
|
-
const { data } = useCookieBar();
|
|
49
|
-
const { accept, consent } = useCookieConsent("testCookie");
|
|
50
|
-
accept();
|
|
51
|
-
expect(data.value.groups[1].cookies[0].accepted).toBe(true);
|
|
52
|
-
expect(consent.value).toBe(true);
|
|
53
|
-
});
|
|
54
47
|
});
|
|
@@ -14,6 +14,7 @@ export declare const useCookieBar: () => {
|
|
|
14
14
|
initializeCookies: () => void;
|
|
15
15
|
setAllCookiesState: (accepted: boolean) => void;
|
|
16
16
|
removeCookies: (cookie: Cookie) => void;
|
|
17
|
+
accept: (name: string) => void;
|
|
17
18
|
data: import("vue").Ref<CookieGroupFromNuxtConfig, CookieGroupFromNuxtConfig>;
|
|
18
19
|
visible: import("vue").Ref<boolean, boolean>;
|
|
19
20
|
loading: import("vue").Ref<boolean, boolean>;
|
|
@@ -78,6 +78,16 @@ export const useCookieBar = () => {
|
|
|
78
78
|
});
|
|
79
79
|
setConsent();
|
|
80
80
|
};
|
|
81
|
+
const accept = (name) => {
|
|
82
|
+
state.value.data.groups.forEach((group) => {
|
|
83
|
+
group.cookies.forEach((cookie) => {
|
|
84
|
+
if (cookie.name === name) {
|
|
85
|
+
cookie.accepted = true;
|
|
86
|
+
setConsent();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
81
91
|
const removeCookies = (cookie) => {
|
|
82
92
|
if (cookie.cookieNames) {
|
|
83
93
|
cookie.cookieNames.forEach((cookieName) => {
|
|
@@ -98,7 +108,8 @@ export const useCookieBar = () => {
|
|
|
98
108
|
setConsent,
|
|
99
109
|
initializeCookies,
|
|
100
110
|
setAllCookiesState,
|
|
101
|
-
removeCookies
|
|
111
|
+
removeCookies,
|
|
112
|
+
accept
|
|
102
113
|
};
|
|
103
114
|
};
|
|
104
115
|
export const fetchScripts = (scripts) => {
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
import { useState } from "nuxt/app";
|
|
2
2
|
import { toRefs } from "vue";
|
|
3
|
-
import { useCookieBar } from "./useCookieBar.js";
|
|
4
3
|
export const useCookieConsent = (name) => {
|
|
5
4
|
const state = useState("useCookieConsent_" + name, () => ({
|
|
6
5
|
consent: false
|
|
7
6
|
}));
|
|
8
|
-
const accept = () => {
|
|
9
|
-
const { data, setConsent } = useCookieBar();
|
|
10
|
-
data.value.groups.forEach((group) => {
|
|
11
|
-
group.cookies.forEach((cookie) => {
|
|
12
|
-
if (cookie.name === name) {
|
|
13
|
-
cookie.accepted = true;
|
|
14
|
-
setConsent();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
7
|
return {
|
|
20
|
-
...toRefs(state.value)
|
|
21
|
-
accept
|
|
8
|
+
...toRefs(state.value)
|
|
22
9
|
};
|
|
23
10
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Order, CartItem, DoAddItemParams, DeleteCartItemParams, User, Cart, AfterBasketChanged, CheckoutChanged, AfterAccountAuthentication, FrontendUpdateCustomerSettings } from '@plentymarkets/shop-api';
|
|
2
2
|
export type Events = {
|
|
3
3
|
'frontend:addToCart': {
|
|
4
4
|
item: CartItem;
|
|
@@ -23,4 +23,8 @@ export type Events = {
|
|
|
23
23
|
};
|
|
24
24
|
'frontend:orderCreated': Order;
|
|
25
25
|
'frontend:searchProduct': string;
|
|
26
|
+
'backend:AfterBasketChanged': AfterBasketChanged;
|
|
27
|
+
'backend:CheckoutChanged': CheckoutChanged;
|
|
28
|
+
'backend:AfterAccountAuthentication': AfterAccountAuthentication;
|
|
29
|
+
'backend:FrontendUpdateCustomerSettings': FrontendUpdateCustomerSettings;
|
|
26
30
|
};
|