@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.
Files changed (66) hide show
  1. package/README.md +533 -0
  2. package/dist/classes/Adapter.d.ts +33 -0
  3. package/dist/classes/Adapter.d.ts.map +1 -0
  4. package/dist/classes/Adapter.js +126 -0
  5. package/dist/classes/Adapter.js.map +1 -0
  6. package/dist/classes/Cart.d.ts +29 -0
  7. package/dist/classes/Cart.d.ts.map +1 -0
  8. package/dist/classes/Cart.js +272 -0
  9. package/dist/classes/Cart.js.map +1 -0
  10. package/dist/components/PersonizelyProvider.d.ts +36 -0
  11. package/dist/components/PersonizelyProvider.d.ts.map +1 -0
  12. package/dist/components/PersonizelyProvider.js +118 -0
  13. package/dist/components/PersonizelyProvider.js.map +1 -0
  14. package/dist/graphql/queries/cart.d.ts +7 -0
  15. package/dist/graphql/queries/cart.d.ts.map +1 -0
  16. package/dist/graphql/queries/cart.js +142 -0
  17. package/dist/graphql/queries/cart.js.map +1 -0
  18. package/dist/graphql/queries/customer.d.ts +5 -0
  19. package/dist/graphql/queries/customer.d.ts.map +1 -0
  20. package/dist/graphql/queries/customer.js +72 -0
  21. package/dist/graphql/queries/customer.js.map +1 -0
  22. package/dist/graphql/queries/product.d.ts +5 -0
  23. package/dist/graphql/queries/product.d.ts.map +1 -0
  24. package/dist/graphql/queries/product.js +114 -0
  25. package/dist/graphql/queries/product.js.map +1 -0
  26. package/dist/hooks/useCartAdd.d.ts +3 -0
  27. package/dist/hooks/useCartAdd.d.ts.map +1 -0
  28. package/dist/hooks/useCartAdd.js +18 -0
  29. package/dist/hooks/useCartAdd.js.map +1 -0
  30. package/dist/hooks/useCheckout.d.ts +2 -0
  31. package/dist/hooks/useCheckout.d.ts.map +1 -0
  32. package/dist/hooks/useCheckout.js +12 -0
  33. package/dist/hooks/useCheckout.js.map +1 -0
  34. package/dist/hooks/usePageContext.d.ts +3 -0
  35. package/dist/hooks/usePageContext.d.ts.map +1 -0
  36. package/dist/hooks/usePageContext.js +6 -0
  37. package/dist/hooks/usePageContext.js.map +1 -0
  38. package/dist/hooks/usePersonizely.d.ts +3 -0
  39. package/dist/hooks/usePersonizely.d.ts.map +1 -0
  40. package/dist/hooks/usePersonizely.js +11 -0
  41. package/dist/hooks/usePersonizely.js.map +1 -0
  42. package/dist/index.d.ts +10 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/types/index.d.ts +170 -0
  47. package/dist/types/index.d.ts.map +1 -0
  48. package/dist/types/index.js +2 -0
  49. package/dist/types/index.js.map +1 -0
  50. package/dist/types/interfaces.d.ts +35 -0
  51. package/dist/types/interfaces.d.ts.map +1 -0
  52. package/dist/types/interfaces.js +2 -0
  53. package/dist/types/interfaces.js.map +1 -0
  54. package/dist/utils/cookies.d.ts +4 -0
  55. package/dist/utils/cookies.d.ts.map +1 -0
  56. package/dist/utils/cookies.js +33 -0
  57. package/dist/utils/cookies.js.map +1 -0
  58. package/dist/utils/id.d.ts +3 -0
  59. package/dist/utils/id.d.ts.map +1 -0
  60. package/dist/utils/id.js +7 -0
  61. package/dist/utils/id.js.map +1 -0
  62. package/dist/utils/storefront-client.d.ts +15 -0
  63. package/dist/utils/storefront-client.d.ts.map +1 -0
  64. package/dist/utils/storefront-client.js +39 -0
  65. package/dist/utils/storefront-client.js.map +1 -0
  66. package/package.json +56 -0
@@ -0,0 +1,3 @@
1
+ export declare function toGId(id: number, type: string): string;
2
+ export declare function toId(id: string): number;
3
+ //# sourceMappingURL=id.d.ts.map
@@ -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"}
@@ -0,0 +1,7 @@
1
+ export function toGId(id, type) {
2
+ return `gid://shopify/${type}/${id}`;
3
+ }
4
+ export function toId(id) {
5
+ return Number(id.split('/').pop());
6
+ }
7
+ //# sourceMappingURL=id.js.map
@@ -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;IAS3B,YAAa,MAA8B;QACzC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC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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
+ }