@picked/shopify 0.0.1-dev.1764785614477 → 0.0.1-dev.1764789407645
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@shopify/storefront-api-client");require("@picked/client");const p=require("../../picked-config-OpJ03CX7.cjs"),f=require("../../global-obj-OziQiQ8j.cjs");function l(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@shopify/storefront-api-client");require("@picked/client");const p=require("../../picked-config-OpJ03CX7.cjs"),f=require("../../global-obj-OziQiQ8j.cjs");function l(t){const o=f.getShopify(),e=p.getPickedConfigStorefrontApiToken();if(!e)throw new Error("Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront");return u.createStorefrontApiClient({storeDomain:o.shop,apiVersion:t.apiVersion,publicAccessToken:e})}const n=()=>{if(!client)throw new Error("Storefront API client not found");return client};async function C(t,o){if(!t)throw new Error("Cart token is required to apply discount codes");const e=n(),i=`gid://shopify/Cart/${t}`,s=`
|
|
2
2
|
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
|
|
3
3
|
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
4
4
|
userErrors {
|
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`,c={cartId:i,discountCodes:o},r=await
|
|
10
|
+
`,c={cartId:i,discountCodes:o},r=await e.request(s,{variables:c});if(r.data.cartDiscountCodesUpdate.userErrors.length>0){const a=r.data.cartDiscountCodesUpdate.userErrors.map(d=>d.message).join(", ");throw new Error(`Discount code application failed: ${a}`)}return r}exports.cartDiscountCodesUpdate=C;exports.createStorefrontApiClient=l;exports.getStorefrontApiClient=n;
|
|
@@ -2,16 +2,16 @@ import { createStorefrontApiClient as d } from "@shopify/storefront-api-client";
|
|
|
2
2
|
import "@picked/client";
|
|
3
3
|
import { g as p } from "../../picked-config-DcKNgPpy.js";
|
|
4
4
|
import { g as f } from "../../global-obj-DQ6S7d00.js";
|
|
5
|
-
function
|
|
6
|
-
const r = f(),
|
|
7
|
-
if (!
|
|
5
|
+
function S(t) {
|
|
6
|
+
const r = f(), o = p();
|
|
7
|
+
if (!o)
|
|
8
8
|
throw new Error(
|
|
9
9
|
"Shopify Storefront API token not found. Ensure the Picked Script is enabled on your Shopify storefront"
|
|
10
10
|
);
|
|
11
11
|
return d({
|
|
12
12
|
storeDomain: r.shop,
|
|
13
|
-
apiVersion:
|
|
14
|
-
publicAccessToken:
|
|
13
|
+
apiVersion: t.apiVersion,
|
|
14
|
+
publicAccessToken: o
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
const u = () => {
|
|
@@ -19,8 +19,10 @@ const u = () => {
|
|
|
19
19
|
throw new Error("Storefront API client not found");
|
|
20
20
|
return client;
|
|
21
21
|
};
|
|
22
|
-
async function
|
|
23
|
-
|
|
22
|
+
async function g(t, r) {
|
|
23
|
+
if (!t)
|
|
24
|
+
throw new Error("Cart token is required to apply discount codes");
|
|
25
|
+
const o = u(), n = `gid://shopify/Cart/${t}`, i = `
|
|
24
26
|
mutation cartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!]) {
|
|
25
27
|
cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
|
|
26
28
|
userErrors {
|
|
@@ -32,7 +34,7 @@ async function h(o, r) {
|
|
|
32
34
|
`, s = {
|
|
33
35
|
cartId: n,
|
|
34
36
|
discountCodes: r
|
|
35
|
-
}, e = await
|
|
37
|
+
}, e = await o.request(
|
|
36
38
|
i,
|
|
37
39
|
{
|
|
38
40
|
variables: s
|
|
@@ -45,7 +47,7 @@ async function h(o, r) {
|
|
|
45
47
|
return e;
|
|
46
48
|
}
|
|
47
49
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
g as cartDiscountCodesUpdate,
|
|
51
|
+
S as createStorefrontApiClient,
|
|
50
52
|
u as getStorefrontApiClient
|
|
51
53
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storefront-api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAExG,OAAO,KAAK,EACV,0BAA0B,EAC1B,mDAAmD,EACpD,MAAM,SAAS,CAAA;AAEhB,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,MAAM,EAAE,0BAA0B,GAAG,SAAS,CAAA;CACrD;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,gEAiB9E;AAED,eAAO,MAAM,sBAAsB,kCAMlC,CAAA;AAED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,mDAAmD,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/storefront-api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,IAAI,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AAExG,OAAO,KAAK,EACV,0BAA0B,EAC1B,mDAAmD,EACpD,MAAM,SAAS,CAAA;AAEhB,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,MAAM,EAAE,0BAA0B,GAAG,SAAS,CAAA;CACrD;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,gEAiB9E;AAED,eAAO,MAAM,sBAAsB,kCAMlC,CAAA;AAED,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,mDAAmD,CAAC,CAuC9D"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/shopify",
|
|
3
3
|
"description": "Shopify plugin for @picked/client",
|
|
4
|
-
"version": "0.0.1-dev.
|
|
4
|
+
"version": "0.0.1-dev.1764789407645",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@picked/client": "workspace:*",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"main": "./dist/cjs/index.js",
|
|
70
70
|
"module": "./dist/esm/index.js",
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@picked/client": "0.0.1-dev.
|
|
72
|
+
"@picked/client": "0.0.1-dev.1764789407645",
|
|
73
73
|
"@shopify/storefront-api-client": "^1.0.9",
|
|
74
74
|
"effector": "^23.3.0"
|
|
75
75
|
},
|