@agnostack/next-shopify 1.8.7-beta.7 → 1.8.7-beta.8
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function handleAppInstallation(serverRuntimeConfig: any): (req: any, res: any, params: any) => Promise<any>;
|
|
@@ -0,0 +1,84 @@
|
|
|
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.handleAppInstallation = void 0;
|
|
15
|
+
const utils_1 = require("../../utils");
|
|
16
|
+
const graph_1 = require("./graph");
|
|
17
|
+
const APP_INSTALLATION_QUERY = `
|
|
18
|
+
query getAppInstallation($namespace: String!) {
|
|
19
|
+
currentAppInstallation {
|
|
20
|
+
id
|
|
21
|
+
launchUrl
|
|
22
|
+
uninstallUrl
|
|
23
|
+
activeSubscriptions {
|
|
24
|
+
id
|
|
25
|
+
name
|
|
26
|
+
test
|
|
27
|
+
}
|
|
28
|
+
oneTimePurchases(first: 250, reverse: true) {
|
|
29
|
+
nodes {
|
|
30
|
+
id
|
|
31
|
+
status
|
|
32
|
+
name
|
|
33
|
+
test
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
metafields(namespace: $namespace, first: 50, reverse: true) {
|
|
37
|
+
nodes {
|
|
38
|
+
id
|
|
39
|
+
key
|
|
40
|
+
type
|
|
41
|
+
value
|
|
42
|
+
namespace
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
// NOTE: typically handling: "/api/admin/installation/[appId]"
|
|
49
|
+
const handleAppInstallation = (serverRuntimeConfig) => async (req, res, params) => {
|
|
50
|
+
const { appId } = params !== null && params !== void 0 ? params : {};
|
|
51
|
+
if (utils_1.stringEmpty(appId)) {
|
|
52
|
+
return res.status(412).json({ message: 'Missing required param' });
|
|
53
|
+
}
|
|
54
|
+
const _handleGraph = graph_1.handleGraph(serverRuntimeConfig);
|
|
55
|
+
return _handleGraph(req, res, {
|
|
56
|
+
query: APP_INSTALLATION_QUERY,
|
|
57
|
+
variables: { namespace: `${appId}-metafields` },
|
|
58
|
+
transform: (data) => {
|
|
59
|
+
const { id: appInstallationId, launchUrl, uninstallUrl, activeSubscriptions, oneTimePurchases: { nodes: oneTimePurchases, } = {}, metafields: { nodes: metafields, } = {}, } = data !== null && data !== void 0 ? data : {};
|
|
60
|
+
return {
|
|
61
|
+
appInstallation: {
|
|
62
|
+
id: appInstallationId,
|
|
63
|
+
launchUrl,
|
|
64
|
+
uninstallUrl,
|
|
65
|
+
oneTimePurchases,
|
|
66
|
+
activeSubscriptions,
|
|
67
|
+
},
|
|
68
|
+
// NOTE: removing namespace for security
|
|
69
|
+
appMetafields: utils_1.ensureArray(metafields).reduce((_appMetafields,
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
_a) => {
|
|
72
|
+
var
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
+
{ namespace: _namespace, key } = _a, metafield = __rest(_a,
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
76
|
+
["namespace", "key"]);
|
|
77
|
+
return (Object.assign(Object.assign({}, _appMetafields), { [key]: metafield }));
|
|
78
|
+
}, {}),
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
exports.handleAppInstallation = handleAppInstallation;
|
|
84
|
+
//# sourceMappingURL=appInstallation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appInstallation.js","sourceRoot":"","sources":["../../../src/handlers/api/appInstallation.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uCAAsD;AACtD,mCAAqC;AAErC,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B9B,CAAA;AAED,8DAA8D;AACvD,MAAM,qBAAqB,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;IACvF,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAA;IAE9B,IAAI,mBAAW,CAAC,KAAK,CAAC,EAAE;QACtB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,CAAC,CAAA;KACnE;IAED,MAAM,YAAY,GAAG,mBAAW,CAAC,mBAAmB,CAAC,CAAA;IAErD,OAAO,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE;QAC5B,KAAK,EAAE,sBAAsB;QAC7B,SAAS,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,aAAa,EAAE;QAC/C,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,MAAM,EACJ,EAAE,EAAE,iBAAiB,EACrB,SAAS,EACT,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAAE,EAChB,KAAK,EAAE,gBAAgB,GACxB,GAAG,EAAE,EACN,UAAU,EAAE,EACV,KAAK,EAAE,UAAU,GAClB,GAAG,EAAE,GACP,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAA;YAEd,OAAO;gBACL,eAAe,EAAE;oBACf,EAAE,EAAE,iBAAiB;oBACrB,SAAS;oBACT,YAAY;oBACZ,gBAAgB;oBAChB,mBAAmB;iBACpB;gBACD,wCAAwC;gBACxC,aAAa,EAAE,mBAAW,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAC5C,cAAc;gBACd,6DAA6D;gBAC7D,EAA4C,EAC5C,EAAE;;oBAFF,6DAA6D;oBAC7D,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,OAAgB,EAAX,SAAS;oBAD1C,6DAA6D;oBAC7D,oBAA4C,CAAF;oBACvC,OAAA,iCACA,cAAc,KACjB,CAAC,GAAG,CAAC,EAAE,SAAS,IAChB,CAAA;iBAAA,EAAE,EAAE,CAAC;aACR,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAA;AA9CY,QAAA,qBAAqB,yBA8CjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnostack/next-shopify",
|
|
3
|
-
"version": "1.8.7-beta.
|
|
3
|
+
"version": "1.8.7-beta.8",
|
|
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",
|