@personizely/shopify-hydrogen 1.0.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 +533 -0
- package/dist/classes/Adapter.d.ts +33 -0
- package/dist/classes/Adapter.d.ts.map +1 -0
- package/dist/classes/Adapter.js +126 -0
- package/dist/classes/Adapter.js.map +1 -0
- package/dist/classes/Cart.d.ts +29 -0
- package/dist/classes/Cart.d.ts.map +1 -0
- package/dist/classes/Cart.js +272 -0
- package/dist/classes/Cart.js.map +1 -0
- package/dist/components/PersonizelyProvider.d.ts +36 -0
- package/dist/components/PersonizelyProvider.d.ts.map +1 -0
- package/dist/components/PersonizelyProvider.js +118 -0
- package/dist/components/PersonizelyProvider.js.map +1 -0
- package/dist/graphql/queries/cart.d.ts +7 -0
- package/dist/graphql/queries/cart.d.ts.map +1 -0
- package/dist/graphql/queries/cart.js +142 -0
- package/dist/graphql/queries/cart.js.map +1 -0
- package/dist/graphql/queries/customer.d.ts +5 -0
- package/dist/graphql/queries/customer.d.ts.map +1 -0
- package/dist/graphql/queries/customer.js +72 -0
- package/dist/graphql/queries/customer.js.map +1 -0
- package/dist/graphql/queries/product.d.ts +5 -0
- package/dist/graphql/queries/product.d.ts.map +1 -0
- package/dist/graphql/queries/product.js +114 -0
- package/dist/graphql/queries/product.js.map +1 -0
- package/dist/hooks/useCartAdd.d.ts +3 -0
- package/dist/hooks/useCartAdd.d.ts.map +1 -0
- package/dist/hooks/useCartAdd.js +18 -0
- package/dist/hooks/useCartAdd.js.map +1 -0
- package/dist/hooks/useCheckout.d.ts +2 -0
- package/dist/hooks/useCheckout.d.ts.map +1 -0
- package/dist/hooks/useCheckout.js +12 -0
- package/dist/hooks/useCheckout.js.map +1 -0
- package/dist/hooks/usePageContext.d.ts +3 -0
- package/dist/hooks/usePageContext.d.ts.map +1 -0
- package/dist/hooks/usePageContext.js +6 -0
- package/dist/hooks/usePageContext.js.map +1 -0
- package/dist/hooks/usePersonizely.d.ts +3 -0
- package/dist/hooks/usePersonizely.d.ts.map +1 -0
- package/dist/hooks/usePersonizely.js +11 -0
- package/dist/hooks/usePersonizely.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +170 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/interfaces.d.ts +35 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/types/interfaces.js +2 -0
- package/dist/types/interfaces.js.map +1 -0
- package/dist/utils/cookies.d.ts +4 -0
- package/dist/utils/cookies.d.ts.map +1 -0
- package/dist/utils/cookies.js +33 -0
- package/dist/utils/cookies.js.map +1 -0
- package/dist/utils/id.d.ts +3 -0
- package/dist/utils/id.d.ts.map +1 -0
- package/dist/utils/id.js +7 -0
- package/dist/utils/id.js.map +1 -0
- package/dist/utils/storefront-client.d.ts +15 -0
- package/dist/utils/storefront-client.d.ts.map +1 -0
- package/dist/utils/storefront-client.js +39 -0
- package/dist/utils/storefront-client.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.d.ts","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,IAAI,CAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAExC"}
|
package/dist/utils/id.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"id.js","sourceRoot":"","sources":["../../src/utils/id.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAE,EAAU,EAAE,IAAY;IAC7C,OAAO,iBAAiB,IAAI,IAAI,EAAE,EAAE,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,IAAI,CAAE,EAAU;IAC9B,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type StorefrontClientConfig = {
|
|
2
|
+
storefrontAccessToken: string;
|
|
3
|
+
shopDomain: string;
|
|
4
|
+
apiVersion?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare class StorefrontClient {
|
|
7
|
+
private storefrontAccessToken;
|
|
8
|
+
private shopDomain;
|
|
9
|
+
private apiVersion;
|
|
10
|
+
private endpoint;
|
|
11
|
+
constructor(config: StorefrontClientConfig);
|
|
12
|
+
query<T = any>(query: string, variables?: Record<string, any>): Promise<T>;
|
|
13
|
+
mutate<T = any>(mutation: string, variables?: Record<string, any>): Promise<T>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=storefront-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-client.d.ts","sourceRoot":"","sources":["../../src/utils/storefront-client.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,sBAAsB,GAAG;IACnC,qBAAqB,EAAE,MAAM,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,qBAAqB,CAAQ;IAErC,OAAO,CAAC,UAAU,CAAQ;IAE1B,OAAO,CAAC,UAAU,CAAQ;IAE1B,OAAO,CAAC,QAAQ,CAAQ;gBAEX,MAAM,EAAE,sBAAsB;IAUrC,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAkC1E,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAGrF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class StorefrontClient {
|
|
2
|
+
constructor(config) {
|
|
3
|
+
this.storefrontAccessToken = config.storefrontAccessToken;
|
|
4
|
+
this.shopDomain = config.shopDomain;
|
|
5
|
+
this.apiVersion = config.apiVersion || '2024-01';
|
|
6
|
+
this.endpoint = `https://${this.shopDomain}/api/${this.apiVersion}/graphql.json`;
|
|
7
|
+
}
|
|
8
|
+
async query(query, variables) {
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch(this.endpoint, {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken
|
|
15
|
+
},
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
query,
|
|
18
|
+
variables
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
throw new Error(`Storefront API request failed: ${response.statusText}`);
|
|
23
|
+
}
|
|
24
|
+
const result = await response.json();
|
|
25
|
+
if (result.errors) {
|
|
26
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`);
|
|
27
|
+
}
|
|
28
|
+
return result.data;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
console.error('Storefront API error:', error);
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async mutate(mutation, variables) {
|
|
36
|
+
return this.query(mutation, variables);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=storefront-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-client.js","sourceRoot":"","sources":["../../src/utils/storefront-client.ts"],"names":[],"mappings":"AAUA,MAAM,OAAO,gBAAgB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,QAAgB,EAAE,SAA+B;QACrE,OAAO,IAAI,CAAC,KAAK,CAAI,QAAQ,EAAE,SAAS,CAAC,CAAA;IAC3C,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@personizely/shopify-hydrogen",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Personizely adapter for Shopify Hydrogen headless storefronts - Simple React Provider integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"publishConfig": { "access": "public" },
|
|
8
|
+
"type": "module",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"shopify",
|
|
15
|
+
"hydrogen",
|
|
16
|
+
"headless",
|
|
17
|
+
"personalization",
|
|
18
|
+
"ecommerce",
|
|
19
|
+
"react",
|
|
20
|
+
"remix",
|
|
21
|
+
"typescript"
|
|
22
|
+
],
|
|
23
|
+
"author": "Personizely",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/personizely/shopify-hydrogen.git"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc",
|
|
31
|
+
"clean": "rm -rf dist",
|
|
32
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
33
|
+
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
|
34
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
35
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@shopify/hydrogen": "2025.7.0",
|
|
39
|
+
"@stylistic/eslint-plugin": "^5.6.1",
|
|
40
|
+
"graphql": "^16.10.0",
|
|
41
|
+
"graphql-tag": "^2.12.6",
|
|
42
|
+
"react": "18.3.1",
|
|
43
|
+
"react-dom": "18.3.1",
|
|
44
|
+
"react-router": "7.9.2",
|
|
45
|
+
"react-router-dom": "7.9.2",
|
|
46
|
+
"typescript-eslint": "^8.50.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@stylistic/eslint-plugin-ts": "^2.12.1",
|
|
50
|
+
"@types/react": "^19.2.7",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
53
|
+
"eslint": "^9.18.0",
|
|
54
|
+
"typescript": "^5.3.0"
|
|
55
|
+
}
|
|
56
|
+
}
|