@plentymarkets/shop-core 1.1.0 → 1.1.1

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 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
- <!-- - [📖 &nbsp;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
- ```bash
33
- # Install dependencies
34
- bun install
35
-
36
- # Generate type stubs
37
- bun run dev:prepare
38
-
39
- # Develop with the playground
40
- bun run dev
41
-
42
- # Build the playground
43
- bun run dev:build
44
-
45
- # Run ESLint
46
- bun run lint
47
-
48
- # Run Vitest
49
- bun run test
50
- bun run test:watch
51
-
52
- # Release new version
53
- bun run release
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
@@ -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) => {
@@ -4,6 +4,5 @@
4
4
  * @example const { consent } = useCookieConsent('CookieBar.essentials.cookies.payPal.name');
5
5
  */
6
6
  export declare const useCookieConsent: (name: string) => {
7
- accept: () => void;
8
7
  consent: import("vue").Ref<boolean, boolean>;
9
8
  };
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",