@agnostack/next-shopify 1.7.0 → 1.7.1-alpha.2

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.
@@ -1,5 +1,6 @@
1
1
  export * from "./auth";
2
2
  export * from "./callback";
3
3
  export * from "./graph";
4
+ export * from "./proxy";
4
5
  export * from "./rest";
5
6
  export * from "./uninstall";
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./auth"), exports);
14
14
  __exportStar(require("./callback"), exports);
15
15
  __exportStar(require("./graph"), exports);
16
+ __exportStar(require("./proxy"), exports);
16
17
  __exportStar(require("./rest"), exports);
17
18
  __exportStar(require("./uninstall"), exports);
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/api/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,6CAA0B;AAC1B,0CAAuB;AACvB,yCAAsB;AACtB,8CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/api/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,6CAA0B;AAC1B,0CAAuB;AACvB,0CAAuB;AACvB,yCAAsB;AACtB,8CAA2B"}
@@ -0,0 +1 @@
1
+ export function handleProxy(): (req: any, res: any, _params: any) => Promise<any>;
@@ -0,0 +1,89 @@
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
+ exports.handleProxy = void 0;
15
+ // NOTE: api routes do NOT work in `next export`
16
+ const shopify_api_1 = require("@shopify/shopify-api");
17
+ // import {
18
+ // isType,
19
+ // stringEmpty,
20
+ // ensureString,
21
+ // ensureObject,
22
+ // getVerifiedClients,
23
+ // querystringToObject,
24
+ // getAuthErrorResponse,
25
+ // ShopifyAuthenticationError,
26
+ // } from '../../utils'
27
+ const handleProxy = () => async (req, res, _params) => {
28
+ console.log(`>>> ~ _params`, _params);
29
+ const { query: _query, method: _method, body: _body } = req;
30
+ console.log(`>>> ~ req`, { _query, _method, _body });
31
+ // const { shop } = _query ?? {}
32
+ const _a = _params !== null && _params !== void 0 ? _params : {}, {
33
+ // method: methodParam,
34
+ // query: queryParam,
35
+ // body: bodyParam,
36
+ path } = _a, params = __rest(_a, ["path"]);
37
+ console.log(`>>> ~ path`, path);
38
+ // if (stringEmpty(shop) || stringEmpty(path)) {
39
+ // return {
40
+ // statusCode: 400,
41
+ // message: 'Invalid arguments',
42
+ // }
43
+ // }
44
+ let statusCode;
45
+ let response;
46
+ let message;
47
+ let headers = {};
48
+ try {
49
+ response = 'proxy success';
50
+ statusCode = 200;
51
+ }
52
+ catch (error) {
53
+ message = 'Error handling proxy call';
54
+ statusCode = 500;
55
+ switch (true) {
56
+ // case error instanceof ShopifyAuthenticationError: {
57
+ // console.error(`${message}. Authentication Error`, error)
58
+ // const errroResponse = getAuthErrorResponse({ error, shop, serverRuntimeConfig })
59
+ // statusCode = errroResponse.statusCode
60
+ // message = errroResponse.message
61
+ // headers = errroResponse.headers
62
+ // break
63
+ // }
64
+ case error instanceof shopify_api_1.BillingError: {
65
+ console.error(`${message}. Billing Error - ${error.message}`, error.errorData);
66
+ break;
67
+ }
68
+ default: {
69
+ console.error(message, error);
70
+ break;
71
+ }
72
+ }
73
+ }
74
+ Object.entries(headers).forEach(([key, value]) => {
75
+ res.setHeader(key, value);
76
+ });
77
+ if (!response) {
78
+ return res.status(statusCode).json({ message });
79
+ }
80
+ if ((params === null || params === void 0 ? void 0 : params.type) && ![shopify_api_1.DataType.GraphQL, shopify_api_1.DataType.JSON].includes(params.type)) {
81
+ return res.status(statusCode).send(response);
82
+ }
83
+ if (!(response === null || response === void 0 ? void 0 : response.body)) {
84
+ return res.status(statusCode).json({ message });
85
+ }
86
+ return res.status(statusCode).json(response.body);
87
+ };
88
+ exports.handleProxy = handleProxy;
89
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/handlers/api/proxy.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gDAAgD;AAChD,sDAA6D;AAE7D,WAAW;AACX,YAAY;AACZ,iBAAiB;AACjB,kBAAkB;AAClB,kBAAkB;AAClB,wBAAwB;AACxB,yBAAyB;AACzB,0BAA0B;AAC1B,gCAAgC;AAChC,uBAAuB;AAEhB,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;IAC3D,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;IACrC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;IAC3D,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;IACpD,gCAAgC;IAChC,MAAM,KAMF,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,EANX;IACJ,uBAAuB;IACvB,qBAAqB;IACrB,mBAAmB;IACnB,IAAI,OAEW,EADZ,MAAM,cALL,QAML,CAAgB,CAAA;IACjB,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,CAAA;IAE/B,gDAAgD;IAChD,aAAa;IACb,uBAAuB;IACvB,oC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AE;QAC5E,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAC7C;IAED,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAA,EAAE;QACnB,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;KAChD;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AACnD,CAAC,CAAA;AAxEY,QAAA,WAAW,eAwEvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agnostack/next-shopify",
3
- "version": "1.7.0",
3
+ "version": "1.7.1-alpha.2",
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",