@agnostack/next-shopify 1.7.0-alpha.51 → 1.7.0-alpha.52
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/handlers/index.d.ts +0 -1
- package/dist/handlers/index.js +5 -1
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/ssr.js +0 -6
- package/dist/handlers/ssr.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/handlers/api.d.ts +0 -10
- package/dist/handlers/api.js +0 -93
- package/dist/handlers/api.js.map +0 -1
- package/dist/helpers/auth.d.ts +0 -6
- package/dist/helpers/auth.js +0 -15
- package/dist/helpers/auth.js.map +0 -1
- package/dist/helpers/callback.d.ts +0 -9
- package/dist/helpers/callback.js +0 -77
- package/dist/helpers/callback.js.map +0 -1
- package/dist/helpers/graph.d.ts +0 -22
- package/dist/helpers/graph.js +0 -74
- package/dist/helpers/graph.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -5
- package/dist/helpers/index.js +0 -17
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/rest.d.ts +0 -22
- package/dist/helpers/rest.js +0 -68
- package/dist/helpers/rest.js.map +0 -1
- package/dist/helpers/uninstall.d.ts +0 -7
- package/dist/helpers/uninstall.js +0 -40
- package/dist/helpers/uninstall.js.map +0 -1
package/dist/handlers/index.d.ts
CHANGED
package/dist/handlers/index.js
CHANGED
|
@@ -10,6 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./auth"), exports);
|
|
14
|
+
__exportStar(require("./callback"), exports);
|
|
15
|
+
__exportStar(require("./graph"), exports);
|
|
16
|
+
__exportStar(require("./rest"), exports);
|
|
14
17
|
__exportStar(require("./ssr"), exports);
|
|
18
|
+
__exportStar(require("./uninstall"), exports);
|
|
15
19
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAqB;AACrB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,6CAA0B;AAC1B,0CAAuB;AACvB,yCAAsB;AACtB,wCAAqB;AACrB,8CAA2B"}
|
package/dist/handlers/ssr.js
CHANGED
|
@@ -29,12 +29,6 @@ const protectRoute = (props) => async ({ req, res, query, locale } = {}, data) =
|
|
|
29
29
|
const { shopify, findSession } = await utils_1.getShopifyHelpers(props, { shop });
|
|
30
30
|
const existingSessions = await findSession(shop);
|
|
31
31
|
if (utils_1.arrayEmpty(existingSessions)) {
|
|
32
|
-
// return getRedirectUrl(props, { req, res, query, id: 'SSR' })
|
|
33
|
-
// const emptySessionUrl = await getRedirectUrl(props, {
|
|
34
|
-
// req,
|
|
35
|
-
// res,
|
|
36
|
-
// query,
|
|
37
|
-
// })
|
|
38
32
|
// TODO: explore objectToQuerystring
|
|
39
33
|
const queryParams = new URLSearchParams(Object.assign(Object.assign({}, query), { shop })).toString();
|
|
40
34
|
return {
|
package/dist/handlers/ssr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ssr.js","sourceRoot":"","sources":["../../src/handlers/ssr.js"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"ssr.js","sourceRoot":"","sources":["../../src/handlers/ssr.js"],"names":[],"mappings":";;;AAAA,oCAQiB;AAEjB,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAClC,sBAAc,C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E,WAAW,EAAE,GAAG,MAAM,yBAAiB,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;IACzE,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAA;IAEhD,IAAI,kBAAU,CAAC,gBAAgB,CAAC,EAAE;QAChC,oCAAoC;QACpC,MAAM,WAAW,GAAG,IAAI,eAAe,iCAAM,KAAK,KAAE,IAAI,IAAG,CAAC,QAAQ,EAAE,CAAA;QAEtE,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,GAAG,SAAS,CAAC,uBAAe,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE;gBAChE,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,IAAI,QAAQ,KAAK,GAAG,EAAE;QACpB,OAAO;YACL,QAAQ,EAAE;gBACR,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;gBACxF,SAAS,EAAE,KAAK;aACjB;SACF,CAAA;KACF;IAED,OAAO;QACL,KAAK,EAAE,mBAAW,iBAChB,MAAM,IACH,IAAI,EACP;KACH,CAAA;AACH,CAAC,CAAA;AA9CY,QAAA,YAAY,gBA8CxB"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -11,6 +11,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./handlers"), exports);
|
|
14
|
-
__exportStar(require("./helpers"), exports);
|
|
15
14
|
__exportStar(require("./withShopify"), exports);
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,gDAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnostack/next-shopify",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.52",
|
|
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",
|
package/dist/handlers/api.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function handleRest(serverRuntimeConfig: any): (req: any, res: any, params: any) => Promise<any>;
|
|
2
|
-
export function handleGraph(serverRuntimeConfig: any): (req: any, res: any, params: any) => Promise<any>;
|
|
3
|
-
export function handleAuth(serverRuntimeConfig: any): (req: any, res: any) => Promise<any>;
|
|
4
|
-
export function handleCallback(serverRuntimeConfig: any): (req: any, res: any) => Promise<any>;
|
|
5
|
-
export function handleAppUninstalled(serverRuntimeConfig: any): (req: any, res: any) => Promise<any>;
|
|
6
|
-
export namespace rawBodyConfig {
|
|
7
|
-
namespace api {
|
|
8
|
-
const bodyParser: boolean;
|
|
9
|
-
}
|
|
10
|
-
}
|
package/dist/handlers/api.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rawBodyConfig = exports.handleAppUninstalled = exports.handleCallback = exports.handleAuth = exports.handleGraph = exports.handleRest = void 0;
|
|
7
|
-
const raw_body_1 = __importDefault(require("raw-body"));
|
|
8
|
-
// NOTE: api routes do NOT work in `next export`
|
|
9
|
-
const shopify_api_1 = require("@shopify/shopify-api");
|
|
10
|
-
const helpers_1 = require("../helpers");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const handleRest = (serverRuntimeConfig) => async (req, res, params) => {
|
|
13
|
-
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
14
|
-
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_rest_response`, } = await helpers_1.restHelper({
|
|
15
|
-
req,
|
|
16
|
-
res,
|
|
17
|
-
params,
|
|
18
|
-
serverRuntimeConfig,
|
|
19
|
-
});
|
|
20
|
-
Object.entries(utils_1.ensureObject(headers)).forEach(([key, value]) => {
|
|
21
|
-
res.setHeader(key, value);
|
|
22
|
-
});
|
|
23
|
-
// TODO: move these to helper
|
|
24
|
-
if (statusCode >= 300 && statusCode < 400) {
|
|
25
|
-
return res.redirect(statusCode, redirectUrl);
|
|
26
|
-
}
|
|
27
|
-
if (!response) {
|
|
28
|
-
return res.status(statusCode).json({ message });
|
|
29
|
-
}
|
|
30
|
-
if ((params === null || params === void 0 ? void 0 : params.type) && ![shopify_api_1.DataType.GraphQL, shopify_api_1.DataType.JSON].includes(params.type)) {
|
|
31
|
-
return res.status(statusCode).send(response);
|
|
32
|
-
}
|
|
33
|
-
if (!(response === null || response === void 0 ? void 0 : response.body)) {
|
|
34
|
-
return res.status(statusCode).json({ message });
|
|
35
|
-
}
|
|
36
|
-
return res.status(statusCode).json(response.body);
|
|
37
|
-
};
|
|
38
|
-
exports.handleRest = handleRest;
|
|
39
|
-
const handleGraph = (serverRuntimeConfig) => async (req, res, params) => {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
42
|
-
const { message, response, headers, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_query_response`, } = await helpers_1.graphHelper({
|
|
43
|
-
req,
|
|
44
|
-
res,
|
|
45
|
-
params,
|
|
46
|
-
serverRuntimeConfig,
|
|
47
|
-
});
|
|
48
|
-
Object.entries(utils_1.ensureObject(headers)).forEach(([key, value]) => {
|
|
49
|
-
res.setHeader(key, value);
|
|
50
|
-
});
|
|
51
|
-
if (statusCode >= 300 && statusCode < 400) {
|
|
52
|
-
return res.redirect(statusCode, redirectUrl);
|
|
53
|
-
}
|
|
54
|
-
if (!(response === null || response === void 0 ? void 0 : response.body)) {
|
|
55
|
-
return res.status(statusCode).json({ message });
|
|
56
|
-
}
|
|
57
|
-
return res.status(statusCode).json((_b = (_a = response.body) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : response.body);
|
|
58
|
-
};
|
|
59
|
-
exports.handleGraph = handleGraph;
|
|
60
|
-
// NOTE: typically handling: "/api/auth"
|
|
61
|
-
const handleAuth = (serverRuntimeConfig) => async (req, res) => (utils_1.getRedirectUrl(serverRuntimeConfig, { req, res })
|
|
62
|
-
// authHelper({ req, res, serverRuntimeConfig })
|
|
63
|
-
);
|
|
64
|
-
exports.handleAuth = handleAuth;
|
|
65
|
-
// NOTE: typically handling: "/api/auth/callback"
|
|
66
|
-
const handleCallback = (serverRuntimeConfig) => async (req, res) => {
|
|
67
|
-
const { PAGE_PATHS } = serverRuntimeConfig;
|
|
68
|
-
const { message, statusCode = 302, redirectUrl = `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?invalid_callback_response`, } = await helpers_1.callbackHelper({ req, res, serverRuntimeConfig });
|
|
69
|
-
if (statusCode >= 300 && statusCode < 400) {
|
|
70
|
-
return res.redirect(statusCode, redirectUrl);
|
|
71
|
-
}
|
|
72
|
-
return res.status(statusCode).send(message);
|
|
73
|
-
};
|
|
74
|
-
exports.handleCallback = handleCallback;
|
|
75
|
-
// NOTE: typically handling: "/api/webhooks/app/uninstalled"
|
|
76
|
-
const handleAppUninstalled = (serverRuntimeConfig) => async (req, res) => {
|
|
77
|
-
// NOTE raw request body is required for Shopify webhook validation
|
|
78
|
-
const rawBody = await raw_body_1.default(req).catch((error) => {
|
|
79
|
-
console.error('Error extracting raw body for app uninstall', error);
|
|
80
|
-
// HMMMM: dont think we can return a 500 here (vs a 200 w/ an error object)
|
|
81
|
-
return res.status(500).send('Unable to get request body');
|
|
82
|
-
});
|
|
83
|
-
// NOTE: Shopify webhook processers will automatically return the response
|
|
84
|
-
return helpers_1.uninstallHelper({ rawBody, req, res, serverRuntimeConfig });
|
|
85
|
-
};
|
|
86
|
-
exports.handleAppUninstalled = handleAppUninstalled;
|
|
87
|
-
// NOTE raw request body is required for Shopify webhook validation
|
|
88
|
-
exports.rawBodyConfig = {
|
|
89
|
-
api: {
|
|
90
|
-
bodyParser: false,
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=api.js.map
|
package/dist/handlers/api.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/handlers/api.js"],"names":[],"mappings":";;;;;;AAAA,wDAAiC;AACjC,gDAAgD;AAChD,sDAA+C;AAE/C,wCAMmB;AACnB,oCAAyE;AAElE,MAAM,UAAU,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;IAC5E,MAAM,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAA;IAC1C,MAAM,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,UAAU,GAAG,GAAG,EAChB,WAAW,GAAG,GAAG,UAAU,CAAC,wBAAgB,CAAC,KAAK,CAAC,wBAAwB,GAC5E,GAAG,MAAM,oBAAU,CAAC;QACnB,GAAG;QACH,GAAG;QACH,MAAM;QACN,mBAAmB;KACpB,CAAC,CAAA;IAEF,MAAM,CAAC,OAAO,CAAC,oBAAY,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC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/auth.d.ts
DELETED
package/dist/helpers/auth.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const utils_1 = require("../utils");
|
|
4
|
-
const authHelper = async ({ req, res, serverRuntimeConfig }) => {
|
|
5
|
-
let response;
|
|
6
|
-
try {
|
|
7
|
-
response = await utils_1.getRedirectUrl(serverRuntimeConfig, { req, res });
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
response = error.response;
|
|
11
|
-
}
|
|
12
|
-
return response;
|
|
13
|
-
};
|
|
14
|
-
exports.default = authHelper;
|
|
15
|
-
//# sourceMappingURL=auth.js.map
|
package/dist/helpers/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/helpers/auth.js"],"names":[],"mappings":";;AAAA,oCAAyC;AAEzC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAC7D,IAAI,QAAQ,CAAA;IACZ,IAAI;QACF,QAAQ,GAAG,MAAM,sBAAc,CAAC,mBAAmB,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;KACnE;IAAC,OAAO,KAAK,EAAE;QACd,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;KAC1B;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,kBAAe,UAAU,CAAA"}
|
package/dist/helpers/callback.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const shopify_api_1 = require("@shopify/shopify-api");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const callbackHelper = async ({ req, res, serverRuntimeConfig }) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const { PAGE_PATHS, PAYMENT_CONFIG, API_PATHS } = serverRuntimeConfig;
|
|
8
|
-
const { shop, host } = req.query;
|
|
9
|
-
if (utils_1.stringEmpty(shop) || utils_1.stringEmpty(host)) {
|
|
10
|
-
return {
|
|
11
|
-
statusCode: 303,
|
|
12
|
-
redirectUrl: `${PAGE_PATHS[utils_1.PAGE_ROUTE_NAMES.ERROR]}?code=${utils_1.ERROR_CODES.INVALID_CALLBACK}`,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
let redirectUrl;
|
|
16
|
-
try {
|
|
17
|
-
const { shopify, storeSession } = await utils_1.getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
18
|
-
const authPayload = { rawRequest: req, rawResponse: res };
|
|
19
|
-
// TODO investigate Error handling callback route. Cookie Error CookieNotFound [Error]: Cannot complete OAuth process. Could not find an OAuth cookie for shop url:
|
|
20
|
-
const { session } = await shopify.auth.callback(authPayload);
|
|
21
|
-
await storeSession(session.toObject());
|
|
22
|
-
await shopify.webhooks.register({ session });
|
|
23
|
-
// TODO: explore objectToQuerystring
|
|
24
|
-
const embeddedURL = await shopify.auth.getEmbeddedAppUrl(authPayload);
|
|
25
|
-
redirectUrl = `${embeddedURL}?${new URLSearchParams(req.query).toString()}`;
|
|
26
|
-
if (PAYMENT_CONFIG === null || PAYMENT_CONFIG === void 0 ? void 0 : PAYMENT_CONFIG.required) {
|
|
27
|
-
// HMMM: order of params/method sig??
|
|
28
|
-
const confirmationUrl = await utils_1.ensureBilling(shopify, session, PAYMENT_CONFIG);
|
|
29
|
-
if (utils_1.stringNotEmpty(confirmationUrl)) {
|
|
30
|
-
redirectUrl = confirmationUrl;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
statusCode: 302,
|
|
35
|
-
redirectUrl,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
const errorMessage = 'Error handling callback route';
|
|
40
|
-
switch (true) {
|
|
41
|
-
// TODO implement a custom SessionNotFound error
|
|
42
|
-
case error instanceof shopify_api_1.CookieNotFound: {
|
|
43
|
-
console.error(`${errorMessage}. Cookie Error`, error);
|
|
44
|
-
// TODO: explore objectToQuerystring
|
|
45
|
-
const queryParams = new URLSearchParams({ host, shop }).toString();
|
|
46
|
-
redirectUrl = `${API_PATHS[utils_1.API_ROUTE_NAMES.AUTH]}?${queryParams}`;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
case error instanceof shopify_api_1.BillingError: {
|
|
50
|
-
console.error(`${errorMessage}. Billing Error ${error.message}`, error.errorData);
|
|
51
|
-
redirectUrl = `/error?code=${utils_1.ERROR_CODES.BILLING}`;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
case error instanceof shopify_api_1.GraphqlQueryError: {
|
|
55
|
-
const errorMessages = utils_1.ensureArray((_a = error.response) === null || _a === void 0 ? void 0 : _a.errors).map(({ message }) => utils_1.ensureString(message));
|
|
56
|
-
console.error(`${errorMessage}. GraphqlQuery Error ${errorMessages.join('. ')}`);
|
|
57
|
-
redirectUrl = `/error?code=${utils_1.ERROR_CODES.QUERY}`;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case error instanceof shopify_api_1.InvalidOAuthError: {
|
|
61
|
-
console.error(`${errorMessage}. InvalidOAuth Error`, error);
|
|
62
|
-
redirectUrl = `/error?code=${utils_1.ERROR_CODES.OAUTH}`;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
default: {
|
|
66
|
-
console.error(errorMessage, error);
|
|
67
|
-
redirectUrl = `/error?code=${utils_1.ERROR_CODES.CALLBACK}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
statusCode: 302,
|
|
73
|
-
redirectUrl,
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
exports.default = callbackHelper;
|
|
77
|
-
//# sourceMappingURL=callback.js.map
|
|
@@ -1 +0,0 @@
|
|
|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,CAAC,CAAC,CAAA;gBACrG,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,wBAAwB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAChF,WAAW,GAAG,eAAe,mBAAW,CAAC,KAAK,EAAE,CAAA;gBAChD,MAAK;aACN;YAED,KAAK,KAAK,YAAY,+BAAiB,CAAC,CAAC;gBACvC,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,sBAAsB,EAAE,KAAK,CAAC,CAAA;gBAC3D,WAAW,GAAG,eAAe,mBAAW,CAAC,KAAK,EAAE,CAAA;gBAChD,MAAK;aACN;YAED,OAAO,CAAC,CAAC;gBACP,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;gBAClC,WAAW,GAAG,eAAe,mBAAW,CAAC,QAAQ,EAAE,CAAA;aACpD;SACF;KACF;IAED,OAAO;QACL,UAAU,EAAE,GAAG;QACf,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED,kBAAe,cAAc,CAAA"}
|
package/dist/helpers/graph.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default graphHelper;
|
|
2
|
-
declare function graphHelper({ req, res, params, serverRuntimeConfig }: {
|
|
3
|
-
req: any;
|
|
4
|
-
res: any;
|
|
5
|
-
params: any;
|
|
6
|
-
serverRuntimeConfig: any;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
statusCode: number;
|
|
9
|
-
message: any;
|
|
10
|
-
headers: {
|
|
11
|
-
'X-Shopify-API-Request-Failure-Reauthorize': string;
|
|
12
|
-
'X-Shopify-API-Request-Failure-Reauthorize-Url': any;
|
|
13
|
-
};
|
|
14
|
-
} | {
|
|
15
|
-
statusCode: number;
|
|
16
|
-
message: string;
|
|
17
|
-
response?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
statusCode: number;
|
|
20
|
-
response: any;
|
|
21
|
-
message?: undefined;
|
|
22
|
-
}>;
|
package/dist/helpers/graph.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const shopify_api_1 = require("@shopify/shopify-api");
|
|
15
|
-
const utils_1 = require("../utils");
|
|
16
|
-
const graphHelper = async ({ req, res, params, serverRuntimeConfig }) => {
|
|
17
|
-
var _a;
|
|
18
|
-
const { body = '{}' } = req, _b = req.query, _c = _b === void 0 ? {} : _b, { shop, apiVersion } = _c, _query = __rest(_c, ["shop", "apiVersion"]);
|
|
19
|
-
const _d = params !== null && params !== void 0 ? params : JSON.parse(body), { query: graphQuery, variables: graphVariables } = _d, graphParams = __rest(_d, ["query", "variables"]);
|
|
20
|
-
let query = _query;
|
|
21
|
-
if (utils_1.isType(query, 'string')) {
|
|
22
|
-
query = utils_1.querystringToObject(query);
|
|
23
|
-
}
|
|
24
|
-
if (utils_1.stringEmpty(shop) || utils_1.stringEmpty(graphQuery)) {
|
|
25
|
-
return {
|
|
26
|
-
statusCode: 400,
|
|
27
|
-
message: 'Invalid arguments',
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
const { Graphql } = await utils_1.getVerifiedClients(serverRuntimeConfig, { req, res, shop, apiVersion });
|
|
32
|
-
const response = await Graphql.query(Object.assign(Object.assign({ data: graphVariables ? {
|
|
33
|
-
query: graphQuery,
|
|
34
|
-
variables: graphVariables,
|
|
35
|
-
} : graphQuery }, utils_1.objectNotEmpty(query) && { query }), graphParams));
|
|
36
|
-
return {
|
|
37
|
-
statusCode: 200,
|
|
38
|
-
response,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
const errorMessage = 'Error handling query call';
|
|
43
|
-
switch (true) {
|
|
44
|
-
case error instanceof utils_1.ShopifyAuthenticationError: {
|
|
45
|
-
console.error(`${errorMessage}. Authentication Error`, error);
|
|
46
|
-
return utils_1.getAuthErrorResponse({ error, shop, serverRuntimeConfig });
|
|
47
|
-
}
|
|
48
|
-
case error instanceof shopify_api_1.BillingError: {
|
|
49
|
-
console.error(`${errorMessage}. Billing Error - ${error.message}`, error.errorData);
|
|
50
|
-
return {
|
|
51
|
-
statusCode: 500,
|
|
52
|
-
message: errorMessage,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
case error instanceof shopify_api_1.GraphqlQueryError: {
|
|
56
|
-
const errorMessages = utils_1.ensureArray((_a = error.response) === null || _a === void 0 ? void 0 : _a.errors).map(({ message }) => utils_1.ensureString(message));
|
|
57
|
-
console.error(`${errorMessage}. ${errorMessages.join('. ')}`);
|
|
58
|
-
return {
|
|
59
|
-
statusCode: 500,
|
|
60
|
-
message: errorMessage,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
default: {
|
|
64
|
-
console.error(errorMessage, error);
|
|
65
|
-
return {
|
|
66
|
-
statusCode: 500,
|
|
67
|
-
message: errorMessage,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
exports.default = graphHelper;
|
|
74
|
-
//# sourceMappingURL=graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/helpers/graph.js"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sD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/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.uninstallHelper = exports.restHelper = exports.graphHelper = exports.callbackHelper = exports.authHelper = void 0;
|
|
7
|
-
var auth_1 = require("./auth");
|
|
8
|
-
Object.defineProperty(exports, "authHelper", { enumerable: true, get: function () { return __importDefault(auth_1).default; } });
|
|
9
|
-
var callback_1 = require("./callback");
|
|
10
|
-
Object.defineProperty(exports, "callbackHelper", { enumerable: true, get: function () { return __importDefault(callback_1).default; } });
|
|
11
|
-
var graph_1 = require("./graph");
|
|
12
|
-
Object.defineProperty(exports, "graphHelper", { enumerable: true, get: function () { return __importDefault(graph_1).default; } });
|
|
13
|
-
var rest_1 = require("./rest");
|
|
14
|
-
Object.defineProperty(exports, "restHelper", { enumerable: true, get: function () { return __importDefault(rest_1).default; } });
|
|
15
|
-
var uninstall_1 = require("./uninstall");
|
|
16
|
-
Object.defineProperty(exports, "uninstallHelper", { enumerable: true, get: function () { return __importDefault(uninstall_1).default; } });
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.js"],"names":[],"mappings":";;;;;;AAAA,+BAA8C;AAArC,mHAAA,OAAO,OAAc;AAC9B,uCAAsD;AAA7C,2HAAA,OAAO,OAAkB;AAClC,iCAAgD;AAAvC,qHAAA,OAAO,OAAe;AAC/B,+BAA8C;AAArC,mHAAA,OAAO,OAAc;AAC9B,yCAAwD;AAA/C,6HAAA,OAAO,OAAmB"}
|
package/dist/helpers/rest.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default restHelper;
|
|
2
|
-
declare function restHelper({ req, res, params: _params, serverRuntimeConfig }: {
|
|
3
|
-
req: any;
|
|
4
|
-
res: any;
|
|
5
|
-
params: any;
|
|
6
|
-
serverRuntimeConfig: any;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
statusCode: number;
|
|
9
|
-
message: any;
|
|
10
|
-
headers: {
|
|
11
|
-
'X-Shopify-API-Request-Failure-Reauthorize': string;
|
|
12
|
-
'X-Shopify-API-Request-Failure-Reauthorize-Url': any;
|
|
13
|
-
};
|
|
14
|
-
} | {
|
|
15
|
-
statusCode: number;
|
|
16
|
-
message: string;
|
|
17
|
-
response?: undefined;
|
|
18
|
-
} | {
|
|
19
|
-
statusCode: number;
|
|
20
|
-
response: any;
|
|
21
|
-
message?: undefined;
|
|
22
|
-
}>;
|
package/dist/helpers/rest.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const shopify_api_1 = require("@shopify/shopify-api");
|
|
15
|
-
const utils_1 = require("../utils");
|
|
16
|
-
const restHelper = async ({ req, res, params: _params, serverRuntimeConfig }) => {
|
|
17
|
-
const { query: _query, method: _method, body: _body } = req;
|
|
18
|
-
const { shop } = _query !== null && _query !== void 0 ? _query : {};
|
|
19
|
-
const _a = _params !== null && _params !== void 0 ? _params : {}, { method: methodParam, query: queryParam, body: bodyParam, path } = _a, params = __rest(_a, ["method", "query", "body", "path"]);
|
|
20
|
-
let queryData = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
|
|
21
|
-
const body = bodyParam !== null && bodyParam !== void 0 ? bodyParam : _body;
|
|
22
|
-
const method = utils_1.ensureString(methodParam !== null && methodParam !== void 0 ? methodParam : _method).toLowerCase();
|
|
23
|
-
if (utils_1.isType(queryData, 'string')) {
|
|
24
|
-
queryData = utils_1.querystringToObject(queryData);
|
|
25
|
-
}
|
|
26
|
-
const _b = utils_1.ensureObject(queryData), { apiVersion } = _b, query = __rest(_b, ["apiVersion"]);
|
|
27
|
-
if (utils_1.stringEmpty(shop) || utils_1.stringEmpty(path)) {
|
|
28
|
-
return {
|
|
29
|
-
statusCode: 400,
|
|
30
|
-
message: 'Invalid arguments',
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
try {
|
|
34
|
-
const { Rest } = await utils_1.getVerifiedClients(serverRuntimeConfig, { req, res, shop, apiVersion });
|
|
35
|
-
const response = await Rest[method](Object.assign({ path,
|
|
36
|
-
query,
|
|
37
|
-
body, type: shopify_api_1.DataType.JSON }, params));
|
|
38
|
-
return {
|
|
39
|
-
statusCode: 200,
|
|
40
|
-
response,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
const errorMessage = 'Error handling rest call';
|
|
45
|
-
switch (true) {
|
|
46
|
-
case error instanceof utils_1.ShopifyAuthenticationError: {
|
|
47
|
-
console.error(`${errorMessage}. Authentication Error`, error);
|
|
48
|
-
return utils_1.getAuthErrorResponse({ error, shop, serverRuntimeConfig });
|
|
49
|
-
}
|
|
50
|
-
case error instanceof shopify_api_1.BillingError: {
|
|
51
|
-
console.error(`${errorMessage}. Billing Error - ${error.message}`, error.errorData);
|
|
52
|
-
return {
|
|
53
|
-
statusCode: 500,
|
|
54
|
-
message: errorMessage,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
default: {
|
|
58
|
-
console.error(errorMessage, error);
|
|
59
|
-
return {
|
|
60
|
-
statusCode: 500,
|
|
61
|
-
message: errorMessage,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
exports.default = restHelper;
|
|
68
|
-
//# sourceMappingURL=rest.js.map
|
package/dist/helpers/rest.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/helpers/rest.js"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAA6D;AAE7D,oCASiB;AAEjB,MAAM,UAAU,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAC9E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAA;IAC7B,MAAM,KAMF,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EANX,EACJ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,SAAS,EACf,IAAI,OAEW,EADZ,MAAM,cALL,mCAML,CAAgB,CAAA;IACjB,IAAI,SAAS,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,MAAM,CAAA;IACpC,MAAM,IAAI,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,KAAK,CAAA;IAC/B,MAAM,MAAM,GAAG,oBAAY,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,OAAO,CAAC,CAAC,WAAW,EAAE,CAAA;IAEjE,IAAI,cAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;QAC/B,SAAS,GAAG,2BAAmB,CAAC,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,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;gBAClC,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;SACF;KACF;AACH,CAAC,CAAA;AAED,kBAAe,UAAU,CAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const runtime_1 = require("@shopify/shopify-api/runtime");
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const uninstallHelper = async ({ rawBody, req, res, serverRuntimeConfig }) => {
|
|
6
|
-
try {
|
|
7
|
-
const shop = req.headers['x-shopify-shop-domain'];
|
|
8
|
-
if (utils_1.stringEmpty(shop)) {
|
|
9
|
-
return res.status(400).send('Invalid shop');
|
|
10
|
-
}
|
|
11
|
-
const { shopify, findSession, deleteSessions } = await utils_1.getShopifyHelpers(serverRuntimeConfig, { shop });
|
|
12
|
-
// NOTE setAbstractConvertIncomingResponseFunc is required if using setAbstractConvertResponseFunc
|
|
13
|
-
runtime_1.setAbstractConvertIncomingResponseFunc(async (args) => args);
|
|
14
|
-
runtime_1.setAbstractConvertResponseFunc(async (response, adapterArgs) => {
|
|
15
|
-
const { statusCode, statusText } = utils_1.ensureObject(response);
|
|
16
|
-
const { type, rawResponse } = utils_1.ensureObject(adapterArgs);
|
|
17
|
-
if (type === utils_1.API_WEBHOOK_TOPICS.APP_UNINSTALLED && statusCode === 200) {
|
|
18
|
-
const sessionsIds = await findSession(shop);
|
|
19
|
-
if (utils_1.arrayNotEmpty(sessionsIds)) {
|
|
20
|
-
await deleteSessions(sessionsIds.map(({ id }) => id));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return rawResponse.status(statusCode).send(statusText);
|
|
24
|
-
});
|
|
25
|
-
await shopify.webhooks.process({
|
|
26
|
-
rawBody: rawBody.toString(),
|
|
27
|
-
rawRequest: req,
|
|
28
|
-
rawResponse: res,
|
|
29
|
-
type: utils_1.API_WEBHOOK_TOPICS.APP_UNINSTALLED,
|
|
30
|
-
});
|
|
31
|
-
return res.status(200).send('ok');
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
console.error('Error handling uninstall', error);
|
|
35
|
-
// HMMM: not sure this should/can send back a 500 here (vs 200 w error object in body)
|
|
36
|
-
return res.status(500).send('Error handling uninstall');
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.default = uninstallHelper;
|
|
40
|
-
//# sourceMappingURL=uninstall.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/helpers/uninstall.js"],"names":[],"mappings":";;AAAA,0DAGqC;AAErC,oCAMiB;AAEjB,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,mBAAmB,EAAE,EAAE,EAAE;IAC3E,IAAI;QACF,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAA;QAEjD,IAAI,mBAAW,CAAC,IAAI,CAAC,EAAE;YACrB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;SAC5C;QAED,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,MAAM,yBAAiB,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QAEvG,kGAAkG;QAClG,gDAAsC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAA;QAC5D,wCAA8B,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE;YAC7D,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,oBAAY,CAAC,QAAQ,CAAC,CAAA;YACzD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,oBAAY,CAAC,WAAW,CAAC,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