@agnostack/next-shopify 1.3.2-alpha.4 → 1.3.2-alpha.40
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 +255 -0
- package/dist/{apiHandlers.d.ts → handlers/api.d.ts} +0 -0
- package/dist/{apiHandlers.js → handlers/api.js} +8 -8
- package/dist/handlers/api.js.map +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +15 -0
- package/dist/handlers/index.js.map +1 -0
- package/dist/{protectRoute.d.ts → handlers/ssr.d.ts} +7 -0
- package/dist/{protectRoute.js → handlers/ssr.js} +24 -10
- package/dist/handlers/ssr.js.map +1 -0
- package/dist/helpers/auth.d.ts +14 -0
- package/dist/helpers/auth.js +25 -0
- package/dist/helpers/auth.js.map +1 -0
- package/dist/helpers/callback.d.ts +9 -0
- package/dist/helpers/callback.js +71 -0
- package/dist/helpers/callback.js.map +1 -0
- package/dist/helpers/error.d.ts +13 -0
- package/dist/helpers/error.js +18 -0
- package/dist/helpers/error.js.map +1 -0
- package/dist/helpers/graph.d.ts +7 -0
- package/dist/helpers/graph.js +76 -0
- package/dist/helpers/graph.js.map +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/index.js +19 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/rest.d.ts +7 -0
- package/dist/helpers/rest.js +70 -0
- package/dist/helpers/rest.js.map +1 -0
- package/dist/helpers/uninstall.d.ts +8 -0
- package/dist/helpers/uninstall.js +28 -0
- package/dist/helpers/uninstall.js.map +1 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/billing.d.ts +0 -5
- package/dist/utils/billing.js +22 -146
- package/dist/utils/billing.js.map +1 -1
- package/dist/utils/constants.d.ts +21 -0
- package/dist/utils/constants.js +97 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/firebase.d.ts +5 -0
- package/dist/utils/firebase.js +13 -2
- package/dist/utils/firebase.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/shopify-api-node/beginAuth.d.ts +9 -0
- package/dist/utils/shopify-api-node/beginAuth.js +37 -0
- package/dist/utils/shopify-api-node/beginAuth.js.map +1 -0
- package/dist/utils/shopify-api-node/index.d.ts +1 -0
- package/dist/utils/shopify-api-node/index.js +15 -0
- package/dist/utils/shopify-api-node/index.js.map +1 -0
- package/dist/utils/shopify.d.ts +1 -10
- package/dist/utils/shopify.js +14 -55
- package/dist/utils/shopify.js.map +1 -1
- package/dist/withShopify.js +3 -27
- package/dist/withShopify.js.map +1 -1
- package/package.json +1 -1
- package/dist/apiHandlers.js.map +0 -1
- package/dist/apiHelpers.d.ts +0 -70
- package/dist/apiHelpers.js +0 -251
- package/dist/apiHelpers.js.map +0 -1
- package/dist/protectRoute.js.map +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
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 error_1 = require("./error");
|
|
17
|
+
const graphHelper = async ({ req, res, params: _params, serverRuntimeConfig }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const { body, query: _query } = req;
|
|
20
|
+
const { shop } = _query !== null && _query !== void 0 ? _query : {};
|
|
21
|
+
const _b = _params !== null && _params !== void 0 ? _params : {}, { data: dataParam, query: queryParam } = _b, params = __rest(_b, ["data", "query"]);
|
|
22
|
+
let query = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
|
|
23
|
+
const data = dataParam !== null && dataParam !== void 0 ? dataParam : JSON.parse(body !== null && body !== void 0 ? body : {});
|
|
24
|
+
if (utils_1.isType(query, 'string')) {
|
|
25
|
+
query = utils_1.querystringToObject(query);
|
|
26
|
+
}
|
|
27
|
+
if (!shop || !data) {
|
|
28
|
+
return {
|
|
29
|
+
statusCode: 400,
|
|
30
|
+
message: 'Invalid arguments',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const session = await utils_1.getVerifiedSession({ req, res, shop, serverRuntimeConfig });
|
|
35
|
+
const client = new shopify_api_1.Shopify.Clients.Graphql(shop, session === null || session === void 0 ? void 0 : session.accessToken);
|
|
36
|
+
const payload = Object.assign(Object.assign({ data }, query && { query }), params);
|
|
37
|
+
const response = await client.query(payload);
|
|
38
|
+
return {
|
|
39
|
+
statusCode: 200,
|
|
40
|
+
response,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
const errorMessage = 'Error handling query call';
|
|
45
|
+
switch (true) {
|
|
46
|
+
case error instanceof utils_1.ShopifyAuthenticationError: {
|
|
47
|
+
console.error(`${errorMessage}. Authentication Error`, error);
|
|
48
|
+
return error_1.authenticationErrorHelper({ error, shop, serverRuntimeConfig });
|
|
49
|
+
}
|
|
50
|
+
case error instanceof shopify_api_1.Shopify.Errors.BillingError: {
|
|
51
|
+
console.error(`${errorMessage}. Billing Error - ${error.message}`, error.errorData);
|
|
52
|
+
return {
|
|
53
|
+
statusCode: 500,
|
|
54
|
+
message: errorMessage,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case error instanceof shopify_api_1.Shopify.Errors.GraphqlQueryError: {
|
|
58
|
+
const errorMessages = utils_1.ensureArray((_a = error.response) === null || _a === void 0 ? void 0 : _a.errors).map(({ message }) => utils_1.ensureString(message));
|
|
59
|
+
console.error(`${errorMessage}. ${errorMessages.join('. ')}`);
|
|
60
|
+
return {
|
|
61
|
+
statusCode: 500,
|
|
62
|
+
message: errorMessage,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
default: {
|
|
66
|
+
console.error(errorMessage, error);
|
|
67
|
+
return {
|
|
68
|
+
statusCode: 500,
|
|
69
|
+
message: errorMessage,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
exports.default = graphHelper;
|
|
76
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/helpers/graph.js"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAA8C;AAE9C,oCAOiB;AACjB,mCAAmD;AAEnD,MAAM,WAAW,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,EAAE,EAAE;;IAC/E,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAA;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAA;IAC7B,MAAM,KAAoD,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EAAjE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,OAA6B,EAAxB,MAAM,cAA/C,iBAAiD,CAAgB,CAAA;IACvE,IAAI,KAAK,GAAG,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,MAAM,CAAA;IAChC,MAAM,IAAI,GAAG,SAAS,aA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YAAY,qBAAqB,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;gBACnF,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;YAED,KAAK,KAAK,YAAY,qBAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;gBACtD,MAAM,aAAa,GAAG,mBAAW,CAAC,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,oBAAY,CAAC,OAAO,CAAC,CAAC,CAAA;gBACrG,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBAC7D,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;YAED,OAAO,CAAC,CAAC;gBACP,OAAO,CAAC,KAAK,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,WAAW,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as authHelper } from "./auth";
|
|
2
|
+
export { default as callbackHelper } from "./callback";
|
|
3
|
+
export { default as authenticationErrorHelper } from "./error";
|
|
4
|
+
export { default as graphHelper } from "./graph";
|
|
5
|
+
export { default as restHelper } from "./rest";
|
|
6
|
+
export { default as uninstallHelper } from "./uninstall";
|
|
@@ -0,0 +1,19 @@
|
|
|
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.authenticationErrorHelper = 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 error_1 = require("./error");
|
|
12
|
+
Object.defineProperty(exports, "authenticationErrorHelper", { enumerable: true, get: function () { return __importDefault(error_1).default; } });
|
|
13
|
+
var graph_1 = require("./graph");
|
|
14
|
+
Object.defineProperty(exports, "graphHelper", { enumerable: true, get: function () { return __importDefault(graph_1).default; } });
|
|
15
|
+
var rest_1 = require("./rest");
|
|
16
|
+
Object.defineProperty(exports, "restHelper", { enumerable: true, get: function () { return __importDefault(rest_1).default; } });
|
|
17
|
+
var uninstall_1 = require("./uninstall");
|
|
18
|
+
Object.defineProperty(exports, "uninstallHelper", { enumerable: true, get: function () { return __importDefault(uninstall_1).default; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,iCAA8D;AAArD,mIAAA,OAAO,OAA6B;AAC7C,iCAAgD;AAAvC,qHAAA,OAAO,OAAe;AAC/B,+BAA8C;AAArC,mHAAA,OAAO,OAAc;AAC9B,yCAAwD;AAA/C,6HAAA,OAAO,OAAmB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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 error_1 = require("./error");
|
|
17
|
+
const restHelper = async ({ req, res, params: _params, serverRuntimeConfig }) => {
|
|
18
|
+
const { query: _query, method: _method, body: _body } = req;
|
|
19
|
+
const { shop } = _query !== null && _query !== void 0 ? _query : {};
|
|
20
|
+
const _a = _params !== null && _params !== void 0 ? _params : {}, { method: methodParam, query: queryParam, body: bodyParam, path } = _a, params = __rest(_a, ["method", "query", "body", "path"]);
|
|
21
|
+
let query = queryParam !== null && queryParam !== void 0 ? queryParam : _query;
|
|
22
|
+
const body = bodyParam !== null && bodyParam !== void 0 ? bodyParam : _body;
|
|
23
|
+
const method = utils_1.ensureString(methodParam !== null && methodParam !== void 0 ? methodParam : _method).toLowerCase();
|
|
24
|
+
if (utils_1.isType(query, 'string')) {
|
|
25
|
+
query = utils_1.querystringToObject(query);
|
|
26
|
+
}
|
|
27
|
+
if (!shop || !path) {
|
|
28
|
+
return {
|
|
29
|
+
statusCode: 400,
|
|
30
|
+
message: 'Invalid arguments',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const session = await utils_1.getVerifiedSession({ req, res, shop, serverRuntimeConfig });
|
|
35
|
+
const shopify = utils_1.getInitializedShopify(serverRuntimeConfig, shop, '2021-04');
|
|
36
|
+
const client = new shopify.Clients.Rest(shop, session === null || session === void 0 ? void 0 : session.accessToken);
|
|
37
|
+
const response = await client[method](Object.assign({ path,
|
|
38
|
+
query,
|
|
39
|
+
body, type: shopify_api_1.DataType.JSON }, params));
|
|
40
|
+
return {
|
|
41
|
+
statusCode: 200,
|
|
42
|
+
response,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const errorMessage = 'Error handling rest call';
|
|
47
|
+
switch (true) {
|
|
48
|
+
case error instanceof utils_1.ShopifyAuthenticationError: {
|
|
49
|
+
console.error(`${errorMessage}. Authentication Error`, error);
|
|
50
|
+
return error_1.authenticationErrorHelper({ error, shop, serverRuntimeConfig });
|
|
51
|
+
}
|
|
52
|
+
case error instanceof shopify_api_1.Shopify.Errors.BillingError: {
|
|
53
|
+
console.error(`${errorMessage}. Billing Error - ${error.message}`, error.errorData);
|
|
54
|
+
return {
|
|
55
|
+
statusCode: 500,
|
|
56
|
+
message: errorMessage,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
default: {
|
|
60
|
+
console.error(errorMessage, error);
|
|
61
|
+
return {
|
|
62
|
+
statusCode: 500,
|
|
63
|
+
message: errorMessage,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.default = restHelper;
|
|
70
|
+
//# sourceMappingURL=rest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../../src/helpers/rest.js"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,sDAAwD;AAExD,oCAOiB;AACjB,mCAAmD;AAEnD,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;IAC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IAAI,IAChB,MAAM,EACT,CAAA;QAEF,OAAO;YACL,UAAU,EAAE,GAAG;YACf,QAAQ;SACT,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,0BAA0B,CAAA;QAE/C,QAAQ,IAAI,EAAE;YACZ,KAAK,KAAK,YAAY,kCAA0B,CAAC,CAAC;gBAChD,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,wBAAwB,EAAE,KAAK,CAAC,CAAA;gBAC7D,OAAO,iCAAyB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAA;aACvE;YAED,KAAK,KAAK,YAAY,qBAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;gBACjD,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,qBAAqB,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;gBACnF,OAAO;oBACL,UAAU,EAAE,GAAG;oBACf,OAAO,EAAE,YAAY;iBACtB,CAAA;aACF;YAED,OAAO,CAAC,CAAC;gBACP,OAAO,CAAC,KAAK,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../utils");
|
|
4
|
+
const uninstallHelper = async ({ req, serverRuntimeConfig }) => {
|
|
5
|
+
var _a, _b, _c, _d;
|
|
6
|
+
try {
|
|
7
|
+
const { domain } = req.body;
|
|
8
|
+
const shopify = utils_1.getInitializedShopify(serverRuntimeConfig, domain);
|
|
9
|
+
const existingSessions = await ((_b = (_a = shopify.Context.SESSION_STORAGE) === null || _a === void 0 ? void 0 : _a.findSessionsByShop) === null || _b === void 0 ? void 0 : _b.call(_a, domain));
|
|
10
|
+
if (utils_1.arrayNotEmpty(existingSessions)) {
|
|
11
|
+
await ((_d = (_c = shopify.Context.SESSION_STORAGE) === null || _c === void 0 ? void 0 : _c.deleteSessions) === null || _d === void 0 ? void 0 : _d.call(_c, existingSessions.map((session) => session.id)));
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
statusCode: 200,
|
|
15
|
+
message: 'success',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
const errorMessage = 'Error handling uninstall route';
|
|
20
|
+
console.error(errorMessage, error);
|
|
21
|
+
return {
|
|
22
|
+
statusCode: 500,
|
|
23
|
+
message: errorMessage,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.default = uninstallHelper;
|
|
28
|
+
//# sourceMappingURL=uninstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../src/helpers/uninstall.js"],"names":[],"mappings":";;AAAA,oCAA+D;AAE/D,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,mBAAmB,EAAE,EAAE,EAAE;;IAC7D,IAAI;QACF,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAA;QAC3B,MAAM,OAAO,GAAG,6BAAqB,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAA;QAElE,MAAM,gBAAgB,GAAG,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,eAAe,0CAAE,kBAAkB,mDAAG,MAAM,CAAC,CAAA,CAAA;QAC5F,IAAI,qBAAa,CAAC,gBAAgB,CAAC,EAAE;YACnC,MAAM,CAAA,MAAA,MAAA,OAAO,CAAC,OAAO,CAAC,eAAe,0CAAE,cAAc,mDAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAA,CAAA;SACvG;QAED,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,SAAS;SACnB,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,gCAAgC,CAAA;QACrD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,CAAA;QAElC,OAAO;YACL,UAAU,EAAE,GAAG;YACf,OAAO,EAAE,YAAY;SACtB,CAAA;KACF;AACH,CAAC,CAAA;AAED,kBAAe,eAAe,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -10,8 +10,7 @@ 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("./
|
|
14
|
-
__exportStar(require("./
|
|
15
|
-
__exportStar(require("./protectRoute"), exports);
|
|
13
|
+
__exportStar(require("./handlers"), exports);
|
|
14
|
+
__exportStar(require("./helpers"), exports);
|
|
16
15
|
__exportStar(require("./withShopify"), exports);
|
|
17
16
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,4CAAyB;AACzB,gDAA6B"}
|
package/dist/utils/billing.d.ts
CHANGED
package/dist/utils/billing.js
CHANGED
|
@@ -1,90 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BillingManager =
|
|
4
|
-
const shopify_api_1 = require("@shopify/shopify-api");
|
|
3
|
+
exports.BillingManager = void 0;
|
|
4
|
+
const shopify_api_1 = require("@shopify/shopify-api");
|
|
5
5
|
const display_1 = require("./display");
|
|
6
|
-
|
|
7
|
-
ONE_TIME: 'ONE_TIME',
|
|
8
|
-
EVERY_30_DAYS: 'EVERY_30_DAYS',
|
|
9
|
-
ANNUAL: 'ANNUAL',
|
|
10
|
-
};
|
|
11
|
-
const RECURRING_INTERVALS = [
|
|
12
|
-
exports.BILLING_INTERVALS.EVERY_30_DAYS,
|
|
13
|
-
exports.BILLING_INTERVALS.ANNUAL
|
|
14
|
-
];
|
|
15
|
-
const RECURRING_PURCHASES_QUERY = `
|
|
16
|
-
query appSubscription {
|
|
17
|
-
currentAppInstallation {
|
|
18
|
-
activeSubscriptions {
|
|
19
|
-
id, name, test
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
const ONE_TIME_PURCHASES_QUERY = `
|
|
25
|
-
query appPurchases($endCursor: String) {
|
|
26
|
-
currentAppInstallation {
|
|
27
|
-
oneTimePurchases(first: 250, sortKey: CREATED_AT, after: $endCursor) {
|
|
28
|
-
edges {
|
|
29
|
-
node {
|
|
30
|
-
id, name, test, status
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
pageInfo {
|
|
34
|
-
hasNextPage, endCursor
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
const RECURRING_PURCHASE_MUTATION = `
|
|
41
|
-
mutation test(
|
|
42
|
-
$name: String!
|
|
43
|
-
$lineItems: [AppSubscriptionLineItemInput!]!
|
|
44
|
-
$returnUrl: URL!
|
|
45
|
-
$test: Boolean
|
|
46
|
-
) {
|
|
47
|
-
appSubscriptionCreate(
|
|
48
|
-
name: $name
|
|
49
|
-
lineItems: $lineItems
|
|
50
|
-
returnUrl: $returnUrl
|
|
51
|
-
test: $test
|
|
52
|
-
) {
|
|
53
|
-
confirmationUrl
|
|
54
|
-
userErrors {
|
|
55
|
-
field
|
|
56
|
-
message
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
`;
|
|
61
|
-
const ONE_TIME_PURCHASE_MUTATION = `
|
|
62
|
-
mutation test(
|
|
63
|
-
$name: String!
|
|
64
|
-
$price: MoneyInput!
|
|
65
|
-
$returnUrl: URL!
|
|
66
|
-
$test: Boolean
|
|
67
|
-
) {
|
|
68
|
-
appPurchaseOneTimeCreate(
|
|
69
|
-
name: $name
|
|
70
|
-
price: $price
|
|
71
|
-
returnUrl: $returnUrl
|
|
72
|
-
test: $test
|
|
73
|
-
) {
|
|
74
|
-
confirmationUrl
|
|
75
|
-
userErrors {
|
|
76
|
-
field
|
|
77
|
-
message
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
6
|
+
const constants_1 = require("./constants");
|
|
82
7
|
class BillingManager {
|
|
83
8
|
constructor(session, serverRuntimeConfig) {
|
|
84
9
|
const { APP_ID, APP_BASE_URL, PAYMENT_CONFIG } = serverRuntimeConfig;
|
|
85
10
|
if (display_1.stringEmpty(session === null || session === void 0 ? void 0 : session.shop) ||
|
|
86
11
|
display_1.stringEmpty(session === null || session === void 0 ? void 0 : session.accessToken) ||
|
|
87
|
-
!Object.values(
|
|
12
|
+
!Object.values(constants_1.BILLING_INTERVALS).includes(PAYMENT_CONFIG === null || PAYMENT_CONFIG === void 0 ? void 0 : PAYMENT_CONFIG.type)) {
|
|
88
13
|
throw new shopify_api_1.Shopify.Errors.BillingError({
|
|
89
14
|
message: 'Invalid billing configuration',
|
|
90
15
|
});
|
|
@@ -94,7 +19,7 @@ class BillingManager {
|
|
|
94
19
|
this.appId = APP_ID;
|
|
95
20
|
this.appBaseUrl = APP_BASE_URL;
|
|
96
21
|
this.paymentConfig = display_1.ensureObject(PAYMENT_CONFIG);
|
|
97
|
-
this.isRecurring = RECURRING_INTERVALS.includes(this.paymentConfig.type);
|
|
22
|
+
this.isRecurring = constants_1.RECURRING_INTERVALS.includes(this.paymentConfig.type);
|
|
98
23
|
}
|
|
99
24
|
async ensureBilling() {
|
|
100
25
|
var _a;
|
|
@@ -117,87 +42,40 @@ class BillingManager {
|
|
|
117
42
|
async hasActiveRecurringPayment(client) {
|
|
118
43
|
var _a, _b, _c;
|
|
119
44
|
const currentInstallations = await client.query({
|
|
120
|
-
data: RECURRING_PURCHASES_QUERY,
|
|
45
|
+
data: constants_1.RECURRING_PURCHASES_QUERY,
|
|
121
46
|
});
|
|
122
47
|
const subscriptions = (_c = (_b = (_a = currentInstallations === null || currentInstallations === void 0 ? void 0 : currentInstallations.body) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.currentAppInstallation) === null || _c === void 0 ? void 0 : _c.activeSubscriptions;
|
|
123
|
-
const matchingSubscription = display_1.ensureArray(subscriptions).find((
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return ((chargeName === this.paymentConfig.name)
|
|
127
|
-
&& (display_1.isTrue(chargeTest) === display_1.isTrue(this.paymentConfig.test)));
|
|
128
|
-
});
|
|
129
|
-
const foo = display_1.objectNotEmpty(matchingSubscription);
|
|
130
|
-
console.log(`>>> ~ hasActiveRecurringPayment`, foo);
|
|
131
|
-
return foo;
|
|
48
|
+
const matchingSubscription = display_1.ensureArray(subscriptions).find(({ name: chargeName, test: chargeTest } = {}) => ((chargeName === this.paymentConfig.name)
|
|
49
|
+
&& (display_1.isTrue(chargeTest) === this.paymentConfig.test)));
|
|
50
|
+
return display_1.objectNotEmpty(matchingSubscription);
|
|
132
51
|
}
|
|
133
52
|
async hasActiveOneTimePayment(client, endCursor = null) {
|
|
134
53
|
var _a, _b, _c, _d, _e;
|
|
135
54
|
const currentInstallations = await client.query({
|
|
136
55
|
data: {
|
|
137
|
-
query: ONE_TIME_PURCHASES_QUERY,
|
|
56
|
+
query: constants_1.ONE_TIME_PURCHASES_QUERY,
|
|
138
57
|
variables: { endCursor },
|
|
139
58
|
},
|
|
140
59
|
});
|
|
141
60
|
const purchases = (_c = (_b = (_a = currentInstallations === null || currentInstallations === void 0 ? void 0 : currentInstallations.body) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.currentAppInstallation) === null || _c === void 0 ? void 0 : _c.oneTimePurchases;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
console.log(`>>> ~ node`, node);
|
|
146
|
-
return (((node === null || node === void 0 ? void 0 : node.name) === this.paymentConfig.name)
|
|
147
|
-
&& ((node === null || node === void 0 ? void 0 : node.status) === 'ACTIVE')
|
|
148
|
-
&& (display_1.isTrue(node === null || node === void 0 ? void 0 : node.test) === display_1.isTrue(this.paymentConfig.test)));
|
|
149
|
-
});
|
|
150
|
-
console.log(`>>> ~ matchingPurchases`, matchingPurchase);
|
|
61
|
+
const matchingPurchase = display_1.ensureArray(purchases === null || purchases === void 0 ? void 0 : purchases.edges).find(({ node } = {}) => (((node === null || node === void 0 ? void 0 : node.name) === this.paymentConfig.name)
|
|
62
|
+
&& ((node === null || node === void 0 ? void 0 : node.status) === 'ACTIVE')
|
|
63
|
+
&& (display_1.isTrue(node === null || node === void 0 ? void 0 : node.test) === this.paymentConfig.test)));
|
|
151
64
|
if (display_1.objectNotEmpty(matchingPurchase)) {
|
|
152
65
|
return true;
|
|
153
66
|
}
|
|
154
67
|
if ((_d = purchases === null || purchases === void 0 ? void 0 : purchases.pageInfo) === null || _d === void 0 ? void 0 : _d.hasNextPage) {
|
|
155
68
|
return this.hasActiveOneTimePayment(client, (_e = purchases === null || purchases === void 0 ? void 0 : purchases.pageInfo) === null || _e === void 0 ? void 0 : _e.endCursor);
|
|
156
69
|
}
|
|
157
|
-
console.log(`>>> ~ NO matchingPurchases`);
|
|
158
70
|
return false;
|
|
159
71
|
}
|
|
160
72
|
async hasActivePayment() {
|
|
161
73
|
const client = new shopify_api_1.Shopify.Clients.Graphql(this.shop, this.accessToken);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
? this.hasActiveRecurringPayment(client)
|
|
165
|
-
: this.hasActiveOneTimePayment(client);
|
|
166
|
-
}
|
|
167
|
-
/*
|
|
168
|
-
// TODO ensure this logic works for recurring payments
|
|
169
|
-
async hasActivePayment () {
|
|
170
|
-
const client = new Shopify.Clients.Rest(this.shop, this.accessToken)
|
|
171
|
-
|
|
172
|
-
// TODO: move this to match scaffold (/ensure we check !test)
|
|
173
|
-
const { body: { application_charges } = {} } = ensureObject(await client.get({
|
|
174
|
-
path: 'application_charges',
|
|
175
|
-
type: DataType.JSON,
|
|
176
|
-
}))
|
|
177
|
-
|
|
178
|
-
console.log(`>>> > BillingManager > existingCharge > this.appId`, this.appId)
|
|
179
|
-
console.log(`>>> > BillingManager > hasActivePayment > ensureArray(application_charges).length`, ensureArray(application_charges).length)
|
|
180
|
-
|
|
181
|
-
const existingCharge = ensureArray(application_charges).reduce((_existingCharge, charge) => {
|
|
182
|
-
const { api_client_id, status: chargeStatus } = ensureObject(charge)
|
|
183
|
-
const isMatching = (stringNotEmpty(api_client_id) && (ensureString(api_client_id) === this.appId))
|
|
184
|
-
console.log(`>>> > BillingManager > existingCharge > ${api_client_id}`, chargeStatus)
|
|
185
|
-
|
|
186
|
-
if (_existingCharge.status === 'active') {
|
|
187
|
-
return _existingCharge
|
|
74
|
+
if (this.isRecurring) {
|
|
75
|
+
return this.hasActiveRecurringPayment(client);
|
|
188
76
|
}
|
|
189
|
-
|
|
190
|
-
if (isMatching && ['active', 'pending'].includes(chargeStatus)) {
|
|
191
|
-
return charge
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return _existingCharge
|
|
195
|
-
}, {})
|
|
196
|
-
console.log(`>>> > BillingManager > hasActivePayment > existingCharge`, existingCharge)
|
|
197
|
-
|
|
198
|
-
return objectNotEmpty(existingCharge)
|
|
77
|
+
return this.hasActiveOneTimePayment(client);
|
|
199
78
|
}
|
|
200
|
-
*/
|
|
201
79
|
async requestPayment() {
|
|
202
80
|
const client = new shopify_api_1.Shopify.Clients.Graphql(this.shop, this.accessToken);
|
|
203
81
|
// TODO: explore objectToQuerystring
|
|
@@ -219,9 +97,9 @@ class BillingManager {
|
|
|
219
97
|
async requestSinglePayment(client, returnUrl) {
|
|
220
98
|
var _a, _b, _c, _d;
|
|
221
99
|
const { price, name, test, } = this.paymentConfig;
|
|
222
|
-
const
|
|
100
|
+
const mutationResponse = await client.query({
|
|
223
101
|
data: {
|
|
224
|
-
query: ONE_TIME_PURCHASE_MUTATION,
|
|
102
|
+
query: constants_1.ONE_TIME_PURCHASE_MUTATION,
|
|
225
103
|
variables: {
|
|
226
104
|
test,
|
|
227
105
|
name,
|
|
@@ -229,8 +107,7 @@ class BillingManager {
|
|
|
229
107
|
returnUrl,
|
|
230
108
|
},
|
|
231
109
|
},
|
|
232
|
-
};
|
|
233
|
-
const mutationResponse = await client.query(payload);
|
|
110
|
+
});
|
|
234
111
|
if (((_a = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _a === void 0 ? void 0 : _a.errors) && display_1.arrayNotEmpty((_b = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _b === void 0 ? void 0 : _b.errors)) {
|
|
235
112
|
throw new shopify_api_1.Shopify.Errors.BillingError({
|
|
236
113
|
message: 'Error executing one-time purchase',
|
|
@@ -242,9 +119,9 @@ class BillingManager {
|
|
|
242
119
|
async requestRecurringPayment(client, returnUrl) {
|
|
243
120
|
var _a, _b, _c, _d;
|
|
244
121
|
const { price, name, test, type: interval, } = this.paymentConfig;
|
|
245
|
-
const
|
|
122
|
+
const mutationResponse = await client.query({
|
|
246
123
|
data: {
|
|
247
|
-
query: RECURRING_PURCHASE_MUTATION,
|
|
124
|
+
query: constants_1.RECURRING_PURCHASE_MUTATION,
|
|
248
125
|
variables: {
|
|
249
126
|
test,
|
|
250
127
|
name,
|
|
@@ -259,8 +136,7 @@ class BillingManager {
|
|
|
259
136
|
}],
|
|
260
137
|
},
|
|
261
138
|
},
|
|
262
|
-
};
|
|
263
|
-
const mutationResponse = await client.query(payload);
|
|
139
|
+
});
|
|
264
140
|
if (((_a = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _a === void 0 ? void 0 : _a.errors) && display_1.arrayNotEmpty((_b = mutationResponse === null || mutationResponse === void 0 ? void 0 : mutationResponse.body) === null || _b === void 0 ? void 0 : _b.errors)) {
|
|
265
141
|
throw new shopify_api_1.Shopify.Errors.BillingError({
|
|
266
142
|
message: 'Error executing recurring purchase',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/utils/billing.js"],"names":[],"mappings":";;;AAAA,sDAA8C
|
|
1
|
+
{"version":3,"file":"billing.js","sourceRoot":"","sources":["../../src/utils/billing.js"],"names":[],"mappings":";;;AAAA,sDAA8C;AAE9C,uCAQkB;AAClB,2CAOoB;AAEpB,MAAa,cAAc;IACzB,YAAY,OAAO,EAAE,mBAAmB;QACtC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,mBAAmB,CAAA;QAEpE,IACE,qBAAW,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC;YAC1B,qBAAW,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC;YACjC,CAAC,MAAM,CAAC,MAAM,CAAC,6BAAiB,CAAC,CAAC,QAAQ,CAAC,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,EAChE;YACA,MAAM,IAAI,qBAAO,CAAC,MAAM,CAAC,YAAY,CAAC;gBACpC,OAAO,EAAE,+BAA+B;aACzC,CAAC,CAAA;SACH;QAED,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;QACtC,IAAI,CAAC,KAAK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,IAAI,EACJ,IAAI,EAAE,QAAQ,GACf,GAAG,IAAI,CAAC,aAAa,CAAA;QAEtB,MAAM,gBAAgB,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;YAC1C,IAAI,EAAE;gBACJ,KAAK,EAAE,uCAA2B;gBAClC,SAAS,EAAE;oBACT,IAAI;oBACJ,IAAI;oBACJ,SAAS;oBACT,SAAS,EAAE,CAAC;4BACV,IAAI,EAAE;gCACJ,0BAA0B,EAAE;oCAC1B,QAAQ;oCACR,KAAK;iCACN;6BACF;yBACF,CAAC;iBACH;aACF;SACF,CAAC,CAAA;QAEF,IAAI,CAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,0CAAE,MAAM,KAAI,uBAAa,CAAC,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,0CAAE,MAAM,CAAC,EAAE;YACnF,MAAM,IAAI,qBAAO,CAAC,MAAM,CAAC,YAAY,CAAC;gBACpC,OAAO,EAAE,oCAAoC;gBAC7C,SAAS,EAAE,qBAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,sBAAY,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;aAC5G,CAAC,CAAA;SACH;QAED,OAAO,MAAA,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,IAAI,0CAAE,IAAI,0CAAE,qBAAqB,CAAA;IAC5D,CAAC;CACF;AApLD,wCAoLC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const COLLECTION_ROOT: "oauth-data";
|
|
2
|
+
export namespace PAGE_ROUTE_NAMES {
|
|
3
|
+
const EXIT: string;
|
|
4
|
+
const ERROR: string;
|
|
5
|
+
}
|
|
6
|
+
export namespace API_ROUTE_NAMES {
|
|
7
|
+
const AUTH: string;
|
|
8
|
+
const AUTH_CALLBACK: string;
|
|
9
|
+
const APP_UNINSTALLED: string;
|
|
10
|
+
}
|
|
11
|
+
export namespace BILLING_INTERVALS {
|
|
12
|
+
const ONE_TIME: string;
|
|
13
|
+
const EVERY_30_DAYS: string;
|
|
14
|
+
const ANNUAL: string;
|
|
15
|
+
}
|
|
16
|
+
export const RECURRING_INTERVALS: string[];
|
|
17
|
+
export const SHOP_QUERY: "\n {\n shop {\n name\n }\n }\n";
|
|
18
|
+
export const RECURRING_PURCHASES_QUERY: "\n query appSubscription {\n currentAppInstallation {\n activeSubscriptions {\n name, test\n }\n }\n }\n";
|
|
19
|
+
export const ONE_TIME_PURCHASES_QUERY: "\n query appPurchases($endCursor: String) {\n currentAppInstallation {\n oneTimePurchases(first: 250, sortKey: CREATED_AT, after: $endCursor) {\n edges {\n node {\n name, test, status\n }\n }\n pageInfo {\n hasNextPage, endCursor\n }\n }\n }\n }\n";
|
|
20
|
+
export const RECURRING_PURCHASE_MUTATION: "\n mutation test(\n $name: String!\n $lineItems: [AppSubscriptionLineItemInput!]!\n $returnUrl: URL!\n $test: Boolean\n ) {\n appSubscriptionCreate(\n name: $name\n lineItems: $lineItems\n returnUrl: $returnUrl\n test: $test\n ) {\n confirmationUrl\n userErrors {\n field\n message\n }\n }\n }\n";
|
|
21
|
+
export const ONE_TIME_PURCHASE_MUTATION: "\n mutation test(\n $name: String!\n $price: MoneyInput!\n $returnUrl: URL!\n $test: Boolean\n ) {\n appPurchaseOneTimeCreate(\n name: $name\n price: $price\n returnUrl: $returnUrl\n test: $test\n ) {\n confirmationUrl\n userErrors {\n field\n message\n }\n }\n }\n";
|