@agnostack/next-shopify 1.6.0-alpha.4 → 1.6.0-alpha.41
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/CHANGELOG.md +262 -0
- package/dist/handlers/api.js +24 -32
- package/dist/handlers/api.js.map +1 -1
- package/dist/handlers/ssr.d.ts +10 -1
- package/dist/handlers/ssr.js +17 -15
- package/dist/handlers/ssr.js.map +1 -1
- package/dist/helpers/auth.d.ts +9 -1
- package/dist/helpers/auth.js +9 -16
- package/dist/helpers/auth.js.map +1 -1
- package/dist/helpers/callback.d.ts +4 -1
- package/dist/helpers/callback.js +27 -35
- package/dist/helpers/callback.js.map +1 -1
- package/dist/helpers/graph.js +2 -2
- package/dist/helpers/graph.js.map +1 -1
- package/dist/helpers/rest.js +3 -3
- package/dist/helpers/rest.js.map +1 -1
- package/dist/helpers/uninstall.d.ts +2 -1
- package/dist/helpers/uninstall.js +23 -7
- package/dist/helpers/uninstall.js.map +1 -1
- package/dist/utils/billing.d.ts +1 -0
- package/dist/utils/billing.js +47 -1
- package/dist/utils/billing.js.map +1 -1
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.js +16 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/firebase.js +1 -0
- package/dist/utils/firebase.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/session.d.ts +14 -0
- package/dist/utils/session.js +83 -0
- package/dist/utils/session.js.map +1 -0
- package/dist/utils/shopify-api-node/beginAuth.d.ts +2 -5
- package/dist/utils/shopify-api-node/beginAuth.js +17 -10
- package/dist/utils/shopify-api-node/beginAuth.js.map +1 -1
- package/dist/utils/shopify.d.ts +2 -38
- package/dist/utils/shopify.js +15 -171
- package/dist/utils/shopify.js.map +1 -1
- package/dist/utils/webhooks.d.ts +1 -0
- package/dist/utils/webhooks.js +50 -0
- package/dist/utils/webhooks.js.map +1 -0
- package/package.json +1 -1
package/dist/utils/shopify.js
CHANGED
|
@@ -1,168 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getRedirectUrl = exports.getInitializedShopify = void 0;
|
|
4
4
|
require("@shopify/shopify-api/adapters/node");
|
|
5
5
|
const shopify_api_1 = require("@shopify/shopify-api");
|
|
6
6
|
// // TODO validate if we still need a custom/local beginAuth
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const errors_1 = require("./errors");
|
|
7
|
+
const shopify_api_node_1 = require("./shopify-api-node");
|
|
8
|
+
const webhooks_1 = require("./webhooks");
|
|
10
9
|
const display_1 = require("./display");
|
|
11
|
-
const firebase_1 = require("./firebase");
|
|
12
10
|
const constants_1 = require("./constants");
|
|
13
|
-
const getInitializedShopify = (serverRuntimeConfig, _shop, version) => {
|
|
14
|
-
const { APP_CONFIG
|
|
15
|
-
// TODO ensure APP_CONFIG values are all matching the new renamed options
|
|
16
|
-
const shopify = shopify_api_1.shopifyApi(Object.assign(Object.assign({}, APP_CONFIG), (display_1.stringNotEmpty(version)) && {
|
|
11
|
+
const getInitializedShopify = async (serverRuntimeConfig, _shop, version) => {
|
|
12
|
+
const shopify = shopify_api_1.shopifyApi(Object.assign(Object.assign({}, serverRuntimeConfig === null || serverRuntimeConfig === void 0 ? void 0 : serverRuntimeConfig.APP_CONFIG), (display_1.stringNotEmpty(version)) && {
|
|
17
13
|
apiVersion: version,
|
|
18
14
|
}));
|
|
15
|
+
await webhooks_1.addWebhookHandlers(serverRuntimeConfig, shopify);
|
|
19
16
|
return shopify;
|
|
20
17
|
};
|
|
21
18
|
exports.getInitializedShopify = getInitializedShopify;
|
|
22
|
-
|
|
23
|
-
// TODO!!!!: explore moving into FirebaseSessionHandler.getInstance and/or another singleton here??
|
|
24
|
-
// export const getInitializedShopify = (serverRuntimeConfig, _shop, version) => {
|
|
25
|
-
// const { FB_CONFIG, FB_ROOT_COLLECTION, APP_ID, APP_CONFIG } = serverRuntimeConfig
|
|
26
|
-
// const data = { app: APP_ID, shop: Shopify.Utils.sanitizeShop(_shop)}
|
|
27
|
-
// const sessionHandler = FirebaseSessionHandler.getInstance(FB_CONFIG, FB_ROOT_COLLECTION)
|
|
28
|
-
// Shopify.Context.initialize({
|
|
29
|
-
// ...APP_CONFIG,
|
|
30
|
-
// ...(stringNotEmpty(version)) && {
|
|
31
|
-
// API_VERSION: version,
|
|
32
|
-
// },
|
|
33
|
-
// SESSION_STORAGE: new Shopify.Session.CustomSessionStorage(
|
|
34
|
-
// (session) => storeCallback(session, data, sessionHandler),
|
|
35
|
-
// (id) => loadCallback(id, data, sessionHandler),
|
|
36
|
-
// (id) => deleteSessionsCallback(id, data, sessionHandler),
|
|
37
|
-
// (ids) => deleteSessionsCallback(ids, data, sessionHandler),
|
|
38
|
-
// (__shop) => findSessionsByShop(Shopify.Utils.sanitizeShop(__shop), data, sessionHandler)
|
|
39
|
-
// ),
|
|
40
|
-
// })
|
|
41
|
-
// return Shopify
|
|
42
|
-
// }
|
|
43
|
-
const getSessionStorage = (serverRuntimeConfig, _shop) => {
|
|
44
|
-
const { FB_CONFIG, FB_ROOT_COLLECTION, APP_ID } = serverRuntimeConfig;
|
|
45
|
-
const shopify = exports.getInitializedShopify(serverRuntimeConfig);
|
|
46
|
-
const data = { app: APP_ID, shop: shopify.utils.sanitizeShop(_shop) };
|
|
47
|
-
const sessionHandler = firebase_1.FirebaseSessionHandler.getInstance(FB_CONFIG, FB_ROOT_COLLECTION);
|
|
48
|
-
return {
|
|
49
|
-
store: (session) => firebase_1.storeCallback(session, data, sessionHandler),
|
|
50
|
-
load: (id) => firebase_1.loadCallback(id, data, sessionHandler),
|
|
51
|
-
delete: (id) => firebase_1.deleteSessionsCallback(id, data, sessionHandler),
|
|
52
|
-
deleteMany: (ids) => firebase_1.deleteSessionsCallback(ids, data, sessionHandler),
|
|
53
|
-
find: (__shop) => firebase_1.findSessionsByShop(shopify.utils.sanitizeShop(__shop), data, sessionHandler),
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
exports.getSessionStorage = getSessionStorage;
|
|
57
|
-
const generatePaymentConfig = (paymentConfig, data) => {
|
|
58
|
-
const { name, price, currency = 'USD', type = constants_1.BILLING_INTERVALS.ONE_TIME, } = display_1.ensureObject(paymentConfig);
|
|
59
|
-
const { debugMode, environment } = display_1.ensureObject(data);
|
|
60
|
-
if (display_1.objectEmpty(paymentConfig) || display_1.stringEmpty(environment)) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
const notProduction = (environment !== 'production');
|
|
64
|
-
// TODO ensure this logic is correct
|
|
65
|
-
let test = environment !== 'production';
|
|
66
|
-
if (debugMode) {
|
|
67
|
-
test = true;
|
|
68
|
-
}
|
|
69
|
-
const _paymentConfig = {
|
|
70
|
-
type,
|
|
71
|
-
required: (environment !== 'development'),
|
|
72
|
-
test,
|
|
73
|
-
name: `${name}${notProduction ? ` - ${environment}` : ''} - ${display_1.unsnakecase(type)}`,
|
|
74
|
-
price: {
|
|
75
|
-
amount: price,
|
|
76
|
-
currencyCode: currency,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
console.log(`>>> ~ _paymentConfig`, {
|
|
80
|
-
_paymentConfig,
|
|
81
|
-
debugMode,
|
|
82
|
-
debugEnv: process.env.DEBUG,
|
|
83
|
-
});
|
|
84
|
-
return _paymentConfig;
|
|
85
|
-
};
|
|
86
|
-
exports.generatePaymentConfig = generatePaymentConfig;
|
|
87
|
-
const getVerifiedSession = async ({ req, res, shop, serverRuntimeConfig }) => {
|
|
88
|
-
console.log('getVerifiedSession');
|
|
89
|
-
try {
|
|
90
|
-
const shopify = exports.getInitializedShopify(serverRuntimeConfig, shop);
|
|
91
|
-
const sessionStorage = exports.getSessionStorage(serverRuntimeConfig, shop);
|
|
92
|
-
if (sessionStorage) {
|
|
93
|
-
console.log('have sessionStorage');
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
console.log('have NO sessionStorage');
|
|
97
|
-
}
|
|
98
|
-
const { PAYMENT_CONFIG } = serverRuntimeConfig !== null && serverRuntimeConfig !== void 0 ? serverRuntimeConfig : {};
|
|
99
|
-
// TODO OLD/Remove
|
|
100
|
-
// const session = await shopify.Utils.loadCurrentSession(req, res)
|
|
101
|
-
const sessionId = await shopify.session.getCurrentId({
|
|
102
|
-
rawRequest: req,
|
|
103
|
-
rawResponse: res,
|
|
104
|
-
});
|
|
105
|
-
console.log('sessionId:', sessionId);
|
|
106
|
-
const session = await sessionStorage.load(sessionId);
|
|
107
|
-
console.log('session:', session);
|
|
108
|
-
if (shop && (session === null || session === void 0 ? void 0 : session.shop) !== shop) {
|
|
109
|
-
throw new errors_1.ShopifyAuthenticationError('Invalid shop');
|
|
110
|
-
}
|
|
111
|
-
if (!session.isActive(shopify.config.scopes)) {
|
|
112
|
-
throw new errors_1.ShopifyAuthenticationError('Inactive session');
|
|
113
|
-
}
|
|
114
|
-
if (PAYMENT_CONFIG === null || PAYMENT_CONFIG === void 0 ? void 0 : PAYMENT_CONFIG.required) {
|
|
115
|
-
const billingManager = new billing_1.BillingManager(shopify, session, serverRuntimeConfig);
|
|
116
|
-
const confirmationUrl = await billingManager.ensureBilling();
|
|
117
|
-
console.log('confirmationUrl:', confirmationUrl);
|
|
118
|
-
if (display_1.stringNotEmpty(confirmationUrl)) {
|
|
119
|
-
throw new errors_1.ShopifyAuthenticationError('Invalid payment status', { redirectUrl: confirmationUrl });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
// NOTE making a test call to ensure a valid session for free apps
|
|
124
|
-
const client = new shopify.clients.Graphql({ session });
|
|
125
|
-
await client.query({ data: constants_1.SHOP_QUERY });
|
|
126
|
-
}
|
|
127
|
-
return session;
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
if (error instanceof shopify_api_1.HttpResponseError &&
|
|
131
|
-
error.response.code === 401) {
|
|
132
|
-
throw new errors_1.ShopifyAuthenticationError('Not authenticated');
|
|
133
|
-
}
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
exports.getVerifiedSession = getVerifiedSession;
|
|
138
|
-
const registerTopicWebhook = async ({ serverRuntimeConfig, webhook, topic, session }) => {
|
|
139
|
-
console.log('registerTopicWebhook');
|
|
140
|
-
const shopify = exports.getInitializedShopify(serverRuntimeConfig, session === null || session === void 0 ? void 0 : session.shop);
|
|
141
|
-
const webhookResponse = await shopify.webhooks.register({ session });
|
|
142
|
-
// TODO validate this is the correct conditional
|
|
143
|
-
if (!webhookResponse[topic][0].success) {
|
|
144
|
-
throw new Error(`Failed to register ${webhook.path} on topic: ${topic} webhook`, webhookResponse.result);
|
|
145
|
-
}
|
|
146
|
-
// TODO validate this is the correct conditional
|
|
147
|
-
return webhookResponse[topic][0].success;
|
|
148
|
-
};
|
|
149
|
-
const registerWebhooks = async (serverRuntimeConfig, webhookRegistry, session) => {
|
|
150
|
-
console.log('registerWebhooks');
|
|
151
|
-
return Promise.all(Object.entries(webhookRegistry).map(async ([topic, webhooks]) => (Promise.all(webhooks.map(async (webhook) => registerTopicWebhook({ serverRuntimeConfig, webhook, topic, session }))))));
|
|
152
|
-
};
|
|
153
|
-
exports.registerWebhooks = registerWebhooks;
|
|
154
|
-
const getRedirectUrl = (props, { req, res, query: _query, }) => {
|
|
19
|
+
const getRedirectUrl = async (props, { req, res, query: _query, }) => {
|
|
155
20
|
var _a;
|
|
156
|
-
console.log('getRedirectUrl');
|
|
157
21
|
const { API_URLS, PAGE_PATHS } = props;
|
|
158
|
-
console.log('props:', props);
|
|
159
22
|
const query = (_a = _query !== null && _query !== void 0 ? _query : req.query) !== null && _a !== void 0 ? _a : {};
|
|
160
|
-
console.log('query:', query);
|
|
161
23
|
const { embedded, host, shop: _shop } = query !== null && query !== void 0 ? query : {};
|
|
162
|
-
const shopify = exports.getInitializedShopify(props, _shop);
|
|
163
|
-
|
|
24
|
+
const shopify = await exports.getInitializedShopify(props, _shop);
|
|
25
|
+
// // if (registerHandlers) {
|
|
26
|
+
// console.log('await addWebhookHandlers')
|
|
27
|
+
// await addWebhookHandlers(props, shopify)
|
|
28
|
+
// // }
|
|
164
29
|
const shop = shopify.utils.sanitizeShop(_shop);
|
|
165
|
-
console.log('shop:', shop);
|
|
166
30
|
if (display_1.stringEmpty(shop)) {
|
|
167
31
|
return `${PAGE_PATHS[constants_1.PAGE_ROUTE_NAMES.ERROR]}?code=no_shop_provided&type=getRedirectUrl`;
|
|
168
32
|
}
|
|
@@ -174,31 +38,11 @@ const getRedirectUrl = (props, { req, res, query: _query, }) => {
|
|
|
174
38
|
}).toString();
|
|
175
39
|
// TODO: explore objectToQuerystring
|
|
176
40
|
const queryParams = new URLSearchParams(Object.assign(Object.assign({}, query), { shop, redirectUri: `${API_URLS[constants_1.API_ROUTE_NAMES.AUTH_CALLBACK]}?${redirectUriParams}` })).toString();
|
|
177
|
-
console.log('embedded queryParams:', queryParams)
|
|
41
|
+
// console.log('embedded queryParams:', queryParams)
|
|
178
42
|
return `${PAGE_PATHS[constants_1.PAGE_ROUTE_NAMES.EXIT]}?${queryParams}`;
|
|
179
43
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
return shopify.auth.begin({
|
|
183
|
-
shop,
|
|
184
|
-
isOnline: true,
|
|
185
|
-
rawRequest: req,
|
|
186
|
-
rawResponse: res,
|
|
187
|
-
});
|
|
44
|
+
console.log('beginAuth');
|
|
45
|
+
return shopify_api_node_1.beginAuth(props, { req, res, shop });
|
|
188
46
|
};
|
|
189
47
|
exports.getRedirectUrl = getRedirectUrl;
|
|
190
|
-
const getAuthErrorResponse = ({ error, shop, serverRuntimeConfig }) => {
|
|
191
|
-
const { message, data } = error;
|
|
192
|
-
const { API_URLS } = serverRuntimeConfig;
|
|
193
|
-
const reauthorizationUrl = (data === null || data === void 0 ? void 0 : data.redirectUrl) || `${API_URLS[constants_1.API_ROUTE_NAMES.AUTH]}?shop=${shop}`;
|
|
194
|
-
return {
|
|
195
|
-
statusCode: 403,
|
|
196
|
-
message,
|
|
197
|
-
headers: {
|
|
198
|
-
'X-Shopify-API-Request-Failure-Reauthorize': '1',
|
|
199
|
-
'X-Shopify-API-Request-Failure-Reauthorize-Url': reauthorizationUrl,
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
exports.getAuthErrorResponse = getAuthErrorResponse;
|
|
204
48
|
//# sourceMappingURL=shopify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shopify.js","sourceRoot":"","sources":["../../src/utils/shopify.js"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"shopify.js","sourceRoot":"","sources":["../../src/utils/shopify.js"],"names":[],"mappings":";;;AAAA,8CAA2C;AAC3C,sDAAiD;AAEjD,6DAA6D;AAC7D,yDAA8C;AAC9C,yCAA+C;AAC/C,uCAAuD;AACvD,2CAA+D;AAExD,MAAM,qBAAqB,GAAG,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;IACjF,MAAM,OAAO,GAAG,wBAAU,iCACrB,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,UAAU,GAC/B,CAAC,wBAAc,CAAC,OAAO,CAAC,CAAC,IAAI;QAC9B,UAAU,EAAE,OAAO;KACpB,EACD,CAAA;IAEF,MAAM,6BAAkB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;IAEtD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAXY,QAAA,qBAAqB,yBAWjC;AAEM,MAAM,cAAc,GAAG,KAAK,EAAE,KAAK,EAAE,EAC1C,GAAG,EACH,GAAG,EACH,KAAK,EAAE,MAAM,GACd,EAAE,EAAE;;IACH,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,KAAK,CAAA;IACtC,MAAM,KAAK,GAA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ntimeConfig: any, shopify: any): Promise<void>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addWebhookHandlers = void 0;
|
|
4
|
+
const shopify_api_1 = require("@shopify/shopify-api");
|
|
5
|
+
const session_1 = require("./session");
|
|
6
|
+
const shopify_1 = require("./shopify");
|
|
7
|
+
const handleWebhook = async (topic, shop, webhookRequestBody) => {
|
|
8
|
+
console.log('handleWebhook:', { topic, shop, webhookRequestBody });
|
|
9
|
+
try {
|
|
10
|
+
const config = JSON.parse(webhookRequestBody);
|
|
11
|
+
const shopify = await shopify_1.getInitializedShopify(config, shop);
|
|
12
|
+
const sessionStorage = session_1.getSessionStorage(shopify, config, shop);
|
|
13
|
+
console.log('sessionStorage:', sessionStorage);
|
|
14
|
+
switch (topic) {
|
|
15
|
+
case 'app/uninstalled': {
|
|
16
|
+
const sessionsIds = await sessionStorage.find(shop);
|
|
17
|
+
console.log('sessionsIds:', sessionsIds);
|
|
18
|
+
if (sessionsIds.length) {
|
|
19
|
+
await sessionStorage.deleteMany(sessionsIds);
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
default: {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
console.log(`Error Handling Webhook for ${topic}`, e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const addWebhookHandlers = async (serverRuntimeConfig, shopify) => {
|
|
33
|
+
const { APP_WEBHOOKS } = serverRuntimeConfig;
|
|
34
|
+
// TODO look for all topics via APP_WEBHOOKS
|
|
35
|
+
const existingHandlers = await shopify.webhooks.getHandlers('APP_UNINSTALLED');
|
|
36
|
+
console.log('existingHandlers:', existingHandlers);
|
|
37
|
+
// if (!existingHandlers.length) {
|
|
38
|
+
console.log('NEEDEM addWebhookHandlers');
|
|
39
|
+
const handlers = Object.entries(APP_WEBHOOKS).reduce((__payload, [topic, webhooks]) => (Object.assign(Object.assign({}, __payload), { [topic]: webhooks.map((webhook) => ({
|
|
40
|
+
deliveryMethod: shopify_api_1.DeliveryMethod.Http,
|
|
41
|
+
callbackUrl: webhook.path,
|
|
42
|
+
callback: handleWebhook,
|
|
43
|
+
})) })), {});
|
|
44
|
+
await shopify.webhooks.addHandlers(handlers);
|
|
45
|
+
// } else {
|
|
46
|
+
// console.log('GOTEM addWebhookHandlers')
|
|
47
|
+
// }
|
|
48
|
+
};
|
|
49
|
+
exports.addWebhookHandlers = addWebhookHandlers;
|
|
50
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/utils/webhooks.js"],"names":[],"mappings":";;;AAAA,sDAAqD;AAErD,uCAA6C;AAC7C,uCAAiD;AAEjD,MAAM,aAAa,GAAG,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,EAAE;IAC9D,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAA;IAClE,IAAI;QACF,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC7C,MAAM,OAAO,GAAG,MAAM,+BAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACzD,MAAM,cAAc,GAAG,2BAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAC/D,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAA;QAE9C,QAAQ,KAAK,EAAE;YACb,KAAK,iBAAiB,CAAC,CAAC;gBACtB,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;gBACnD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAA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@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnostack/next-shopify",
|
|
3
|
-
"version": "1.6.0-alpha.
|
|
3
|
+
"version": "1.6.0-alpha.41",
|
|
4
4
|
"author": "agnoStack Dev <developers@agnostack.com> (https://agnostack.com)",
|
|
5
5
|
"owner": "agnoStack",
|
|
6
6
|
"description": "Please contact agnoStack via info@agnostack.com for any questions",
|