@pressy-pub/shopify 0.1.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/dist/index.d.ts +73 -0
- package/dist/index.js +226 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
interface ShopifyConfig {
|
|
2
|
+
shopDomain: string;
|
|
3
|
+
storefrontAccessToken: string;
|
|
4
|
+
}
|
|
5
|
+
interface Product {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
handle: string;
|
|
10
|
+
priceRange: {
|
|
11
|
+
minVariantPrice: {
|
|
12
|
+
amount: string;
|
|
13
|
+
currencyCode: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
variants: {
|
|
17
|
+
edges: Array<{
|
|
18
|
+
node: {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
price: {
|
|
22
|
+
amount: string;
|
|
23
|
+
currencyCode: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface CheckoutLineItem {
|
|
30
|
+
variantId: string;
|
|
31
|
+
quantity: number;
|
|
32
|
+
}
|
|
33
|
+
interface Checkout {
|
|
34
|
+
id: string;
|
|
35
|
+
webUrl: string;
|
|
36
|
+
lineItems: {
|
|
37
|
+
edges: Array<{
|
|
38
|
+
node: {
|
|
39
|
+
id: string;
|
|
40
|
+
title: string;
|
|
41
|
+
quantity: number;
|
|
42
|
+
};
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
totalPrice: {
|
|
46
|
+
amount: string;
|
|
47
|
+
currencyCode: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare class ShopifyClient {
|
|
52
|
+
private shopDomain;
|
|
53
|
+
private storefrontAccessToken;
|
|
54
|
+
private endpoint;
|
|
55
|
+
constructor(config: ShopifyConfig);
|
|
56
|
+
private query;
|
|
57
|
+
getProduct(productId: string): Promise<Product>;
|
|
58
|
+
createCheckout(lineItems: CheckoutLineItem[]): Promise<Checkout>;
|
|
59
|
+
getCheckout(checkoutId: string): Promise<Checkout>;
|
|
60
|
+
}
|
|
61
|
+
declare function createShopifyClient(config: ShopifyConfig): ShopifyClient;
|
|
62
|
+
|
|
63
|
+
declare function createCheckout(productId: string, bookSlug?: string): Promise<string>;
|
|
64
|
+
declare function getCheckoutUrl(checkout: Checkout): string;
|
|
65
|
+
|
|
66
|
+
declare function unlockContent(bookSlug: string, data?: {
|
|
67
|
+
orderId?: string;
|
|
68
|
+
email?: string;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
declare function isContentUnlocked(bookSlug: string): Promise<boolean>;
|
|
71
|
+
declare function verifyPurchase(bookSlug: string, orderId: string): Promise<boolean>;
|
|
72
|
+
|
|
73
|
+
export { type Checkout, type CheckoutLineItem, type Product, ShopifyClient, type ShopifyConfig, createCheckout, createShopifyClient, getCheckoutUrl, isContentUnlocked, unlockContent, verifyPurchase };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var ShopifyClient = class {
|
|
3
|
+
shopDomain;
|
|
4
|
+
storefrontAccessToken;
|
|
5
|
+
endpoint;
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.shopDomain = config.shopDomain;
|
|
8
|
+
this.storefrontAccessToken = config.storefrontAccessToken;
|
|
9
|
+
this.endpoint = `https://${this.shopDomain}/api/2024-01/graphql.json`;
|
|
10
|
+
}
|
|
11
|
+
async query(query, variables) {
|
|
12
|
+
const response = await fetch(this.endpoint, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
"X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
|
|
17
|
+
},
|
|
18
|
+
body: JSON.stringify({ query, variables })
|
|
19
|
+
});
|
|
20
|
+
if (!response.ok) {
|
|
21
|
+
throw new Error(`Shopify API error: ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
const json = await response.json();
|
|
24
|
+
if (json.errors) {
|
|
25
|
+
throw new Error(`GraphQL error: ${json.errors[0].message}`);
|
|
26
|
+
}
|
|
27
|
+
return json.data;
|
|
28
|
+
}
|
|
29
|
+
async getProduct(productId) {
|
|
30
|
+
const query = `
|
|
31
|
+
query getProduct($id: ID!) {
|
|
32
|
+
product(id: $id) {
|
|
33
|
+
id
|
|
34
|
+
title
|
|
35
|
+
description
|
|
36
|
+
handle
|
|
37
|
+
priceRange {
|
|
38
|
+
minVariantPrice {
|
|
39
|
+
amount
|
|
40
|
+
currencyCode
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
variants(first: 10) {
|
|
44
|
+
edges {
|
|
45
|
+
node {
|
|
46
|
+
id
|
|
47
|
+
title
|
|
48
|
+
price {
|
|
49
|
+
amount
|
|
50
|
+
currencyCode
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
const data = await this.query(query, { id: productId });
|
|
59
|
+
return data.product;
|
|
60
|
+
}
|
|
61
|
+
async createCheckout(lineItems) {
|
|
62
|
+
const query = `
|
|
63
|
+
mutation checkoutCreate($input: CheckoutCreateInput!) {
|
|
64
|
+
checkoutCreate(input: $input) {
|
|
65
|
+
checkout {
|
|
66
|
+
id
|
|
67
|
+
webUrl
|
|
68
|
+
lineItems(first: 10) {
|
|
69
|
+
edges {
|
|
70
|
+
node {
|
|
71
|
+
id
|
|
72
|
+
title
|
|
73
|
+
quantity
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
totalPrice {
|
|
78
|
+
amount
|
|
79
|
+
currencyCode
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
checkoutUserErrors {
|
|
83
|
+
code
|
|
84
|
+
field
|
|
85
|
+
message
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
const data = await this.query(query, {
|
|
91
|
+
input: {
|
|
92
|
+
lineItems: lineItems.map((item) => ({
|
|
93
|
+
variantId: item.variantId,
|
|
94
|
+
quantity: item.quantity
|
|
95
|
+
}))
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
if (data.checkoutCreate.checkoutUserErrors.length > 0) {
|
|
99
|
+
throw new Error(data.checkoutCreate.checkoutUserErrors[0].message);
|
|
100
|
+
}
|
|
101
|
+
return data.checkoutCreate.checkout;
|
|
102
|
+
}
|
|
103
|
+
async getCheckout(checkoutId) {
|
|
104
|
+
const query = `
|
|
105
|
+
query getCheckout($id: ID!) {
|
|
106
|
+
node(id: $id) {
|
|
107
|
+
... on Checkout {
|
|
108
|
+
id
|
|
109
|
+
webUrl
|
|
110
|
+
completedAt
|
|
111
|
+
lineItems(first: 10) {
|
|
112
|
+
edges {
|
|
113
|
+
node {
|
|
114
|
+
id
|
|
115
|
+
title
|
|
116
|
+
quantity
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
totalPrice {
|
|
121
|
+
amount
|
|
122
|
+
currencyCode
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
`;
|
|
128
|
+
const data = await this.query(query, {
|
|
129
|
+
id: checkoutId
|
|
130
|
+
});
|
|
131
|
+
return data.node;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
var clientInstance = null;
|
|
135
|
+
function createShopifyClient(config) {
|
|
136
|
+
clientInstance = new ShopifyClient(config);
|
|
137
|
+
return clientInstance;
|
|
138
|
+
}
|
|
139
|
+
function getShopifyClient() {
|
|
140
|
+
if (!clientInstance) {
|
|
141
|
+
throw new Error("Shopify client not initialized. Call createShopifyClient first.");
|
|
142
|
+
}
|
|
143
|
+
return clientInstance;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/checkout.ts
|
|
147
|
+
var CHECKOUT_STORAGE_KEY = "pressy-checkout";
|
|
148
|
+
async function createCheckout(productId, bookSlug) {
|
|
149
|
+
const client = getShopifyClient();
|
|
150
|
+
const product = await client.getProduct(productId);
|
|
151
|
+
if (!product.variants.edges.length) {
|
|
152
|
+
throw new Error("Product has no variants");
|
|
153
|
+
}
|
|
154
|
+
const variantId = product.variants.edges[0].node.id;
|
|
155
|
+
const lineItems = [
|
|
156
|
+
{
|
|
157
|
+
variantId,
|
|
158
|
+
quantity: 1
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
const checkout = await client.createCheckout(lineItems);
|
|
162
|
+
if (bookSlug && typeof localStorage !== "undefined") {
|
|
163
|
+
const storedCheckout = {
|
|
164
|
+
checkoutId: checkout.id,
|
|
165
|
+
bookSlug,
|
|
166
|
+
createdAt: Date.now()
|
|
167
|
+
};
|
|
168
|
+
localStorage.setItem(CHECKOUT_STORAGE_KEY, JSON.stringify(storedCheckout));
|
|
169
|
+
}
|
|
170
|
+
return checkout.webUrl;
|
|
171
|
+
}
|
|
172
|
+
function getCheckoutUrl(checkout) {
|
|
173
|
+
return checkout.webUrl;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// src/unlock.ts
|
|
177
|
+
import { get, set, del } from "idb-keyval";
|
|
178
|
+
var UNLOCKS_PREFIX = "pressy-unlock-";
|
|
179
|
+
async function unlockContent(bookSlug, data) {
|
|
180
|
+
const unlockData = {
|
|
181
|
+
bookSlug,
|
|
182
|
+
orderId: data?.orderId,
|
|
183
|
+
email: data?.email,
|
|
184
|
+
unlockedAt: Date.now()
|
|
185
|
+
};
|
|
186
|
+
await set(`${UNLOCKS_PREFIX}${bookSlug}`, unlockData);
|
|
187
|
+
if (typeof localStorage !== "undefined") {
|
|
188
|
+
localStorage.setItem(`${UNLOCKS_PREFIX}${bookSlug}`, JSON.stringify(unlockData));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async function isContentUnlocked(bookSlug) {
|
|
192
|
+
if (typeof localStorage !== "undefined") {
|
|
193
|
+
const stored = localStorage.getItem(`${UNLOCKS_PREFIX}${bookSlug}`);
|
|
194
|
+
if (stored) return true;
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const data = await get(`${UNLOCKS_PREFIX}${bookSlug}`);
|
|
198
|
+
return !!data;
|
|
199
|
+
} catch {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function getUnlockData(bookSlug) {
|
|
204
|
+
try {
|
|
205
|
+
const data = await get(`${UNLOCKS_PREFIX}${bookSlug}`);
|
|
206
|
+
return data || null;
|
|
207
|
+
} catch {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function verifyPurchase(bookSlug, orderId) {
|
|
212
|
+
const unlockData = await getUnlockData(bookSlug);
|
|
213
|
+
if (!unlockData) return false;
|
|
214
|
+
if (!unlockData.orderId) return false;
|
|
215
|
+
return unlockData.orderId === orderId;
|
|
216
|
+
}
|
|
217
|
+
export {
|
|
218
|
+
ShopifyClient,
|
|
219
|
+
createCheckout,
|
|
220
|
+
createShopifyClient,
|
|
221
|
+
getCheckoutUrl,
|
|
222
|
+
isContentUnlocked,
|
|
223
|
+
unlockContent,
|
|
224
|
+
verifyPurchase
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/checkout.ts","../src/unlock.ts"],"sourcesContent":["import type { ShopifyConfig, Product, Checkout, CheckoutLineItem } from './types.js'\n\nexport class ShopifyClient {\n private shopDomain: string\n private storefrontAccessToken: string\n private endpoint: string\n\n constructor(config: ShopifyConfig) {\n this.shopDomain = config.shopDomain\n this.storefrontAccessToken = config.storefrontAccessToken\n this.endpoint = `https://${this.shopDomain}/api/2024-01/graphql.json`\n }\n\n private async query<T>(query: string, variables?: Record<string, unknown>): Promise<T> {\n const response = await fetch(this.endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': this.storefrontAccessToken,\n },\n body: JSON.stringify({ query, variables }),\n })\n\n if (!response.ok) {\n throw new Error(`Shopify API error: ${response.statusText}`)\n }\n\n const json = await response.json()\n\n if (json.errors) {\n throw new Error(`GraphQL error: ${json.errors[0].message}`)\n }\n\n return json.data\n }\n\n async getProduct(productId: string): Promise<Product> {\n const query = `\n query getProduct($id: ID!) {\n product(id: $id) {\n id\n title\n description\n handle\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 10) {\n edges {\n node {\n id\n title\n price {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n `\n\n const data = await this.query<{ product: Product }>(query, { id: productId })\n return data.product\n }\n\n async createCheckout(lineItems: CheckoutLineItem[]): Promise<Checkout> {\n const query = `\n mutation checkoutCreate($input: CheckoutCreateInput!) {\n checkoutCreate(input: $input) {\n checkout {\n id\n webUrl\n lineItems(first: 10) {\n edges {\n node {\n id\n title\n quantity\n }\n }\n }\n totalPrice {\n amount\n currencyCode\n }\n }\n checkoutUserErrors {\n code\n field\n message\n }\n }\n }\n `\n\n const data = await this.query<{\n checkoutCreate: {\n checkout: Checkout\n checkoutUserErrors: Array<{ code: string; field: string[]; message: string }>\n }\n }>(query, {\n input: {\n lineItems: lineItems.map((item) => ({\n variantId: item.variantId,\n quantity: item.quantity,\n })),\n },\n })\n\n if (data.checkoutCreate.checkoutUserErrors.length > 0) {\n throw new Error(data.checkoutCreate.checkoutUserErrors[0].message)\n }\n\n return data.checkoutCreate.checkout\n }\n\n async getCheckout(checkoutId: string): Promise<Checkout> {\n const query = `\n query getCheckout($id: ID!) {\n node(id: $id) {\n ... on Checkout {\n id\n webUrl\n completedAt\n lineItems(first: 10) {\n edges {\n node {\n id\n title\n quantity\n }\n }\n }\n totalPrice {\n amount\n currencyCode\n }\n }\n }\n }\n `\n\n const data = await this.query<{ node: Checkout & { completedAt: string | null } }>(query, {\n id: checkoutId,\n })\n return data.node\n }\n}\n\n// Singleton instance\nlet clientInstance: ShopifyClient | null = null\n\nexport function createShopifyClient(config: ShopifyConfig): ShopifyClient {\n clientInstance = new ShopifyClient(config)\n return clientInstance\n}\n\nexport function getShopifyClient(): ShopifyClient {\n if (!clientInstance) {\n throw new Error('Shopify client not initialized. Call createShopifyClient first.')\n }\n return clientInstance\n}\n","import { getShopifyClient } from './client.js'\nimport type { Checkout, CheckoutLineItem } from './types.js'\n\n// Store checkout ID for verification after return\nconst CHECKOUT_STORAGE_KEY = 'pressy-checkout'\n\ninterface StoredCheckout {\n checkoutId: string\n bookSlug: string\n createdAt: number\n}\n\nexport async function createCheckout(\n productId: string,\n bookSlug?: string\n): Promise<string> {\n const client = getShopifyClient()\n\n // Get the product to find the first variant\n const product = await client.getProduct(productId)\n\n if (!product.variants.edges.length) {\n throw new Error('Product has no variants')\n }\n\n const variantId = product.variants.edges[0].node.id\n\n // Create checkout with single item\n const lineItems: CheckoutLineItem[] = [\n {\n variantId,\n quantity: 1,\n },\n ]\n\n const checkout = await client.createCheckout(lineItems)\n\n // Store checkout info for verification on return\n if (bookSlug && typeof localStorage !== 'undefined') {\n const storedCheckout: StoredCheckout = {\n checkoutId: checkout.id,\n bookSlug,\n createdAt: Date.now(),\n }\n localStorage.setItem(CHECKOUT_STORAGE_KEY, JSON.stringify(storedCheckout))\n }\n\n return checkout.webUrl\n}\n\nexport function getCheckoutUrl(checkout: Checkout): string {\n return checkout.webUrl\n}\n\nexport async function verifyCheckoutReturn(): Promise<{\n success: boolean\n bookSlug?: string\n orderId?: string\n}> {\n if (typeof localStorage === 'undefined') {\n return { success: false }\n }\n\n const stored = localStorage.getItem(CHECKOUT_STORAGE_KEY)\n if (!stored) {\n return { success: false }\n }\n\n try {\n const { checkoutId, bookSlug } = JSON.parse(stored) as StoredCheckout\n\n const client = getShopifyClient()\n const checkout = await client.getCheckout(checkoutId)\n\n // Check if checkout was completed\n // Note: In real implementation, you'd verify with order webhooks\n // This is a simplified client-side check\n if ((checkout as any).completedAt) {\n // Clear stored checkout\n localStorage.removeItem(CHECKOUT_STORAGE_KEY)\n\n return {\n success: true,\n bookSlug,\n orderId: checkout.id,\n }\n }\n\n return { success: false }\n } catch (err) {\n console.error('Error verifying checkout:', err)\n return { success: false }\n }\n}\n","import { get, set, del } from 'idb-keyval'\nimport type { UnlockData } from './types.js'\n\nconst UNLOCKS_PREFIX = 'pressy-unlock-'\n\nexport async function unlockContent(\n bookSlug: string,\n data?: { orderId?: string; email?: string }\n): Promise<void> {\n const unlockData: UnlockData = {\n bookSlug,\n orderId: data?.orderId,\n email: data?.email,\n unlockedAt: Date.now(),\n }\n\n // Store in IndexedDB\n await set(`${UNLOCKS_PREFIX}${bookSlug}`, unlockData)\n\n // Also store in localStorage for quick sync checks\n if (typeof localStorage !== 'undefined') {\n localStorage.setItem(`${UNLOCKS_PREFIX}${bookSlug}`, JSON.stringify(unlockData))\n }\n}\n\nexport async function isContentUnlocked(bookSlug: string): Promise<boolean> {\n // Quick check localStorage first\n if (typeof localStorage !== 'undefined') {\n const stored = localStorage.getItem(`${UNLOCKS_PREFIX}${bookSlug}`)\n if (stored) return true\n }\n\n // Check IndexedDB\n try {\n const data = await get<UnlockData>(`${UNLOCKS_PREFIX}${bookSlug}`)\n return !!data\n } catch {\n return false\n }\n}\n\nexport async function getUnlockData(bookSlug: string): Promise<UnlockData | null> {\n try {\n const data = await get<UnlockData>(`${UNLOCKS_PREFIX}${bookSlug}`)\n return data || null\n } catch {\n return null\n }\n}\n\nexport async function revokeUnlock(bookSlug: string): Promise<void> {\n await del(`${UNLOCKS_PREFIX}${bookSlug}`)\n\n if (typeof localStorage !== 'undefined') {\n localStorage.removeItem(`${UNLOCKS_PREFIX}${bookSlug}`)\n }\n}\n\nexport async function verifyPurchase(\n bookSlug: string,\n orderId: string\n): Promise<boolean> {\n // In a production environment, this would verify with your backend\n // which would check with Shopify's API\n const unlockData = await getUnlockData(bookSlug)\n\n if (!unlockData) return false\n if (!unlockData.orderId) return false\n\n return unlockData.orderId === orderId\n}\n\n// Check URL params for checkout return and auto-unlock\nexport async function handleCheckoutReturn(): Promise<{\n unlocked: boolean\n bookSlug?: string\n}> {\n if (typeof window === 'undefined') {\n return { unlocked: false }\n }\n\n const params = new URLSearchParams(window.location.search)\n const checkoutSuccess = params.get('checkout_success')\n const bookSlug = params.get('book')\n const orderId = params.get('order_id')\n\n if (checkoutSuccess === 'true' && bookSlug) {\n await unlockContent(bookSlug, { orderId: orderId || undefined })\n\n // Clean up URL params\n const url = new URL(window.location.href)\n url.searchParams.delete('checkout_success')\n url.searchParams.delete('book')\n url.searchParams.delete('order_id')\n window.history.replaceState({}, '', url.toString())\n\n return { unlocked: true, bookSlug }\n }\n\n return { unlocked: false }\n}\n"],"mappings":";AAEO,IAAM,gBAAN,MAAoB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAAuB;AACjC,SAAK,aAAa,OAAO;AACzB,SAAK,wBAAwB,OAAO;AACpC,SAAK,WAAW,WAAW,KAAK,UAAU;AAAA,EAC5C;AAAA,EAEA,MAAc,MAAS,OAAe,WAAiD;AACrF,UAAM,WAAW,MAAM,MAAM,KAAK,UAAU;AAAA,MAC1C,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,qCAAqC,KAAK;AAAA,MAC5C;AAAA,MACA,MAAM,KAAK,UAAU,EAAE,OAAO,UAAU,CAAC;AAAA,IAC3C,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AAChB,YAAM,IAAI,MAAM,sBAAsB,SAAS,UAAU,EAAE;AAAA,IAC7D;AAEA,UAAM,OAAO,MAAM,SAAS,KAAK;AAEjC,QAAI,KAAK,QAAQ;AACf,YAAM,IAAI,MAAM,kBAAkB,KAAK,OAAO,CAAC,EAAE,OAA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U,UAAU,CAAC;AAAA,EACjF;AACF;AAEA,eAAsB,kBAAkB,UAAoC;AAE1E,MAAI,OAAO,iBAAiB,aAAa;AACvC,UAAM,SAAS,aAAa,QAAQ,GAAG,cAAc,GAAG,QAAQ,EAAE;AAClE,QAAI,OAAQ,QAAO;AAAA,EACrB;AAGA,MAAI;AACF,UAAM,OAAO,MAAM,IAAgB,GAAG,cAAc,GAAG,QAAQ,EAAE;AACjE,WAAO,CAAC,CAAC;AAAA,EACX,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,cAAc,UAA8C;AAChF,MAAI;AACF,UAAM,OAAO,MAAM,IAAgB,GAAG,cAAc,GAAG,QAAQ,EAAE;AACjE,WAAO,QAAQ;AAAA,EACjB,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAUA,eAAsB,eACpB,UACA,SACkB;AAGlB,QAAM,aAAa,MAAM,cAAc,QAAQ;AAE/C,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,CAAC,WAAW,QAAS,QAAO;AAEhC,SAAO,WAAW,YAAY;AAChC;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pressy-pub/shopify",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shopify integration for Pressy monetization",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"publishConfig": {
|
|
16
|
+
"access": "public"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"idb-keyval": "^6.2.1"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"tsup": "^8.0.0",
|
|
26
|
+
"typescript": "^5.3.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"dev": "tsup --watch",
|
|
31
|
+
"typecheck": "tsc --noEmit"
|
|
32
|
+
}
|
|
33
|
+
}
|