@plentymarkets/shop-core 1.8.0 → 1.8.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
@@ -20,26 +20,23 @@ npx nuxi module add @plentymarkets/shop-core
20
20
 
21
21
  ```bash
22
22
  # Install dependencies
23
- bun install
23
+ npm install
24
24
 
25
25
  # Generate type stubs
26
- bun run dev:prepare
26
+ npm run dev:prepare
27
27
 
28
28
  # Develop with the playground
29
- bun run dev
29
+ npm run dev
30
30
 
31
31
  # Build the playground
32
- bun run dev:build
32
+ npm run dev:build
33
33
 
34
34
  # Run ESLint
35
- bun run lint
35
+ npm run lint
36
36
 
37
37
  # Run Vitest
38
- bun run test
39
- bun run test:watch
40
-
41
- # Release new version
42
- bun run release
38
+ npm run test
39
+ npm run test:watch
43
40
  ```
44
41
 
45
42
  <!-- Badges -->
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shop-core",
3
3
  "configKey": "shopCore",
4
- "version": "1.8.0",
4
+ "version": "1.8.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "0.8.4",
7
7
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -50,6 +50,11 @@ const module = defineNuxtModule({
50
50
  as: "useDynamicPaymentButtons",
51
51
  from: resolver.resolve("./runtime/composables/useDynamicPaymentButtons")
52
52
  });
53
+ addImports({
54
+ name: "useCartStockReservation",
55
+ as: "useCartStockReservation",
56
+ from: resolver.resolve("./runtime/composables/useCartStockReservation")
57
+ });
53
58
  }
54
59
  });
55
60
 
@@ -0,0 +1,5 @@
1
+ export declare const useCartStockReservation: () => {
2
+ reserve: () => Promise<boolean>;
3
+ unreserve: () => Promise<boolean>;
4
+ loading: import("vue").Ref<boolean, boolean>;
5
+ };
@@ -0,0 +1,50 @@
1
+ import { useState } from "nuxt/app";
2
+ import { toRefs } from "vue";
3
+ import { useSdk } from "./useSdk.js";
4
+ import { useHandleError } from "./useHandleError.js";
5
+ import { useNotification } from "./useNotification.js";
6
+ export const useCartStockReservation = () => {
7
+ const state = useState(`useCartStockReservation`, () => ({
8
+ loading: false
9
+ }));
10
+ const reserve = async () => {
11
+ state.value.loading = true;
12
+ try {
13
+ const { data } = await useSdk().plentysystems.doPreparePayment();
14
+ if (data.type === "errorCode") {
15
+ if (data.value) {
16
+ const { send } = useNotification();
17
+ send({
18
+ type: "negative",
19
+ message: data.value,
20
+ persist: true
21
+ });
22
+ }
23
+ return false;
24
+ }
25
+ return true;
26
+ } catch (error) {
27
+ useHandleError(error);
28
+ } finally {
29
+ state.value.loading = false;
30
+ }
31
+ return false;
32
+ };
33
+ const unreserve = async () => {
34
+ state.value.loading = true;
35
+ try {
36
+ await useSdk().plentysystems.deleteBasketReservations();
37
+ return true;
38
+ } catch (error) {
39
+ useHandleError(error);
40
+ } finally {
41
+ state.value.loading = false;
42
+ }
43
+ return false;
44
+ };
45
+ return {
46
+ ...toRefs(state.value),
47
+ reserve,
48
+ unreserve
49
+ };
50
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plentymarkets/shop-core",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Core module for PlentyONE Shop",
5
5
  "repository": {
6
6
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
43
43
  },
44
44
  "dependencies": {
45
- "@plentymarkets/shop-api": "^0.125.0",
45
+ "@plentymarkets/shop-api": "^0.126.0",
46
46
  "@vue-storefront/sdk": "^3.4.1",
47
47
  "js-sha256": "^0.11.0",
48
48
  "mitt": "^3.0.1",