@agnostack/next-shopify 1.0.0
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 +12 -0
- package/LICENSE +21 -0
- package/README.md +94 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/data.d.ts +70 -0
- package/dist/utils/data.js +270 -0
- package/dist/utils/data.js.map +1 -0
- package/dist/utils/display.d.ts +16 -0
- package/dist/utils/display.js +65 -0
- package/dist/utils/display.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/locations.d.ts +20 -0
- package/dist/utils/locations.js +26 -0
- package/dist/utils/locations.js.map +1 -0
- package/dist/withPlugins.d.ts +6 -0
- package/dist/withPlugins.js +38 -0
- package/dist/withPlugins.js.map +1 -0
- package/dist/withZendeskCLI.d.ts +4 -0
- package/dist/withZendeskCLI.js +154 -0
- package/dist/withZendeskCLI.js.map +1 -0
- package/dist/zendeskCLIHandler.d.ts +1 -0
- package/dist/zendeskCLIHandler.js +109 -0
- package/dist/zendeskCLIHandler.js.map +1 -0
- package/package.json +90 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# 1.0.0 (2022-11-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* initial commit ([1bc1cf1](https://github.com/agnostack/next-shopify/commit/1bc1cf1125052a8c71778c67e68d08d0c391ee7f))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* inital commit/prerelease ([df46523](https://github.com/agnostack/next-shopify/commit/df465232c95a1162423c664473d3c535bfb7b949))
|
|
12
|
+
* initial release ([40c6a31](https://github.com/agnostack/next-shopify/commit/40c6a31786757878841849e58e6b58a5c76df5c0))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-2030 agnoStack, Inc. and Adam Grohs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# @agnostack/next-shopify
|
|
2
|
+

|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
yarn add @agnostack/next-shopify
|
|
7
|
+
# npm install @agnostack/next-shopify
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Quickstart
|
|
11
|
+
|
|
12
|
+
Inside of `next.config.js`, add the following:
|
|
13
|
+
```js
|
|
14
|
+
const { withZendeskCLI } = require('@agnostack/next-shopify')
|
|
15
|
+
|
|
16
|
+
const manifestTemplate = require('./manifestTemplate.json')
|
|
17
|
+
|
|
18
|
+
const nextConfig = withZendeskCLI({
|
|
19
|
+
zendesk: { manifestTemplate },
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Also, create an api route (`pages/api/apps.js`) containing the following:
|
|
25
|
+
```js
|
|
26
|
+
import getConfig from 'next/config'
|
|
27
|
+
import { zendeskCLIHandler } from '@agnostack/next-shopify'
|
|
28
|
+
|
|
29
|
+
const { serverRuntimeConfig } = getConfig() ?? {}
|
|
30
|
+
|
|
31
|
+
// NOTE: api routes do NOT work in `next export`
|
|
32
|
+
export default zendeskCLIHandler(serverRuntimeConfig)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Alternate Option #1
|
|
37
|
+
|
|
38
|
+
Inside of `next.config.js`, add the following:
|
|
39
|
+
```js
|
|
40
|
+
const { withPlugins, withZendeskCLI } = require('@agnostack/next-shopify')
|
|
41
|
+
|
|
42
|
+
const manifest = require('./manifest.json')
|
|
43
|
+
|
|
44
|
+
const nextPlugins = [{
|
|
45
|
+
[withZendeskCLI]: {
|
|
46
|
+
manifestTemplate: manifest,
|
|
47
|
+
/* NOTE: add optionale below
|
|
48
|
+
apiRoute: '/api/my-custom-api-json-route', // (defaults to /api/apps)
|
|
49
|
+
interactive: true, // (defaults to false)
|
|
50
|
+
data: {
|
|
51
|
+
plan: 'silver',
|
|
52
|
+
app_id: 123,
|
|
53
|
+
installation_id: 12434234,
|
|
54
|
+
my_token: 'myValue',
|
|
55
|
+
parameters: {
|
|
56
|
+
someToken: 'fksjdhfb231435',
|
|
57
|
+
someSecret: 123,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
routes: {
|
|
61
|
+
background: '/background'
|
|
62
|
+
user_sidebar: '/noTicket',
|
|
63
|
+
organization_sidebar: '/noTicket',
|
|
64
|
+
ticket_sidebar: '/ticket',
|
|
65
|
+
new_ticket_sidebar: '/ticket',
|
|
66
|
+
},
|
|
67
|
+
*/
|
|
68
|
+
},
|
|
69
|
+
}]
|
|
70
|
+
|
|
71
|
+
const nextConfig = withPlugins({
|
|
72
|
+
/* NOTE: standard nextConfig goes in here
|
|
73
|
+
reactStrictMode: true,
|
|
74
|
+
experimental: {
|
|
75
|
+
esmExternals: false,
|
|
76
|
+
},
|
|
77
|
+
*/
|
|
78
|
+
}, [nextPlugins])
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Also, create an api route (`pages/api/apps.js`) containing the following:
|
|
83
|
+
```js
|
|
84
|
+
import getConfig from 'next/config'
|
|
85
|
+
import { zendeskCLIHandler } from '@agnostack/next-shopify'
|
|
86
|
+
|
|
87
|
+
const { publicRuntimeConfig } = getConfig() ?? {}
|
|
88
|
+
|
|
89
|
+
// NOTE: api routes do NOT work in `next export`
|
|
90
|
+
export default zendeskCLIHandler(publicRuntimeConfig)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
_Contact [Adam Grohs](https://agnostack.com/founding-team/adam-grohs) @ [agnoStack](https://agnostack.com/) for any questions._
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.LOCATIONS = exports.PRODUCTS = exports.cleanURL = exports.getAppData = exports.arrowsReplace = exports.generateReplacements = exports.deepmerge = void 0;
|
|
14
|
+
var utils_1 = require("./utils");
|
|
15
|
+
Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return utils_1.deepmerge; } });
|
|
16
|
+
Object.defineProperty(exports, "generateReplacements", { enumerable: true, get: function () { return utils_1.generateReplacements; } });
|
|
17
|
+
Object.defineProperty(exports, "arrowsReplace", { enumerable: true, get: function () { return utils_1.arrowsReplace; } });
|
|
18
|
+
Object.defineProperty(exports, "getAppData", { enumerable: true, get: function () { return utils_1.getAppData; } });
|
|
19
|
+
Object.defineProperty(exports, "cleanURL", { enumerable: true, get: function () { return utils_1.cleanURL; } });
|
|
20
|
+
Object.defineProperty(exports, "PRODUCTS", { enumerable: true, get: function () { return utils_1.PRODUCTS; } });
|
|
21
|
+
Object.defineProperty(exports, "LOCATIONS", { enumerable: true, get: function () { return utils_1.LOCATIONS; } });
|
|
22
|
+
__exportStar(require("./withPlugins"), exports);
|
|
23
|
+
__exportStar(require("./withZendeskCLI"), exports);
|
|
24
|
+
__exportStar(require("./zendeskCLIHandler"), exports);
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iCAQgB;AAPd,kGAAA,SAAS,OAAA;AACT,6GAAA,oBAAoB,OAAA;AACpB,sGAAA,aAAa,OAAA;AACb,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,kGAAA,SAAS,OAAA;AAEX,gDAA6B;AAC7B,mDAAgC;AAChC,sDAAmC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export const ASSET_URL_PREFIX: "assets/";
|
|
2
|
+
export function getEnv(): {
|
|
3
|
+
params: object;
|
|
4
|
+
args: any[];
|
|
5
|
+
env: object;
|
|
6
|
+
nextEnv: {};
|
|
7
|
+
definePluginEnv: {};
|
|
8
|
+
};
|
|
9
|
+
export function arrowsReplace(template: any, replacements: any): any;
|
|
10
|
+
export function generateReplacements(_replacements: any): any;
|
|
11
|
+
export function getAppData(manifestTemplate: any, replacements: any, mergeData: any): {
|
|
12
|
+
safData: {
|
|
13
|
+
context: {
|
|
14
|
+
host: string;
|
|
15
|
+
product: any;
|
|
16
|
+
location: any;
|
|
17
|
+
instanceGuid: any;
|
|
18
|
+
account: {
|
|
19
|
+
subdomain: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
metadata: {
|
|
23
|
+
plan: {
|
|
24
|
+
name: any;
|
|
25
|
+
};
|
|
26
|
+
stripe_subscription_id: any;
|
|
27
|
+
appId: any;
|
|
28
|
+
name: any;
|
|
29
|
+
installationId: any;
|
|
30
|
+
version: any;
|
|
31
|
+
settings: any;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
manifestData: any;
|
|
35
|
+
installationData: any;
|
|
36
|
+
};
|
|
37
|
+
export function getZendeskData({ pluginConfig, ...replacements }: {
|
|
38
|
+
[x: string]: any;
|
|
39
|
+
pluginConfig: any;
|
|
40
|
+
}): {
|
|
41
|
+
zendeskData: any;
|
|
42
|
+
safData: {
|
|
43
|
+
context: {
|
|
44
|
+
host: string;
|
|
45
|
+
product: any;
|
|
46
|
+
location: any;
|
|
47
|
+
instanceGuid: any;
|
|
48
|
+
account: {
|
|
49
|
+
subdomain: any;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
metadata: {
|
|
53
|
+
plan: {
|
|
54
|
+
name: any;
|
|
55
|
+
};
|
|
56
|
+
stripe_subscription_id: any;
|
|
57
|
+
appId: any;
|
|
58
|
+
name: any;
|
|
59
|
+
installationId: any;
|
|
60
|
+
version: any;
|
|
61
|
+
settings: any;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
manifestData: any;
|
|
65
|
+
installationData: any;
|
|
66
|
+
};
|
|
67
|
+
export function getPrompts(_questions: any, { phase, disabled }?: {
|
|
68
|
+
phase: any;
|
|
69
|
+
disabled: any;
|
|
70
|
+
}): Promise<any>;
|
|
@@ -0,0 +1,270 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.getPrompts = exports.getZendeskData = exports.getAppData = exports.generateReplacements = exports.arrowsReplace = exports.getEnv = exports.ASSET_URL_PREFIX = void 0;
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
21
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
22
|
+
const browser_monads_1 = require("browser-monads");
|
|
23
|
+
const constants_1 = require("next/constants");
|
|
24
|
+
const display_1 = require("./display");
|
|
25
|
+
const locations_1 = require("./locations");
|
|
26
|
+
exports.ASSET_URL_PREFIX = 'assets/';
|
|
27
|
+
const cleanEnv = (env) => (Object.entries(display_1.ensureObject(env)).reduce((_env, [key, val]) => (Object.assign(Object.assign({}, _env), !(key.startsWith('__') || key.startsWith('NODE_')) && {
|
|
28
|
+
[key]: val,
|
|
29
|
+
})), {}));
|
|
30
|
+
const stringifyEnv = (env) => (Object.entries(display_1.ensureObject(env)).reduce((_env, [key, val]) => (Object.assign(Object.assign({}, _env), {
|
|
31
|
+
// NOTE: DefinePlugin requires stringified
|
|
32
|
+
[key]: JSON.stringify(val) })), {}));
|
|
33
|
+
// TODO!!!!: move getEnvData to lib-core (or somewhere)?
|
|
34
|
+
const getEnv = () => {
|
|
35
|
+
const { ENVIRONMENT, NODE_ENV } = process.env;
|
|
36
|
+
const _environment = [ENVIRONMENT, NODE_ENV, 'development'].find((value) => display_1.stringNotEmpty(value));
|
|
37
|
+
// eslint-disable-next-line import/order, global-require, @typescript-eslint/no-var-requires
|
|
38
|
+
const { parsed: envFlow } = require('dotenv-flow').config({
|
|
39
|
+
node_env: _environment,
|
|
40
|
+
});
|
|
41
|
+
const mergedEnv = display_1.deepmerge.all([
|
|
42
|
+
process.env,
|
|
43
|
+
envFlow,
|
|
44
|
+
{ ENVIRONMENT: _environment }
|
|
45
|
+
]);
|
|
46
|
+
const { params, args } = process.argv.reduce(({ args: _args, params: _params, }, data) => {
|
|
47
|
+
const [_param, value] = data.split('=');
|
|
48
|
+
const param = _param.replace('--', '');
|
|
49
|
+
return {
|
|
50
|
+
args: [
|
|
51
|
+
..._args,
|
|
52
|
+
...!value ? [param] : []
|
|
53
|
+
],
|
|
54
|
+
params: Object.assign(Object.assign({}, _params), value && {
|
|
55
|
+
[param]: value,
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
}, {
|
|
59
|
+
args: [],
|
|
60
|
+
params: mergedEnv,
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
params,
|
|
64
|
+
args,
|
|
65
|
+
env: mergedEnv,
|
|
66
|
+
nextEnv: cleanEnv(mergedEnv),
|
|
67
|
+
definePluginEnv: stringifyEnv(mergedEnv),
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
exports.getEnv = getEnv;
|
|
71
|
+
const getProductIcon = ({ product, location, isMultiProduct }) => {
|
|
72
|
+
var _a;
|
|
73
|
+
let productIcon;
|
|
74
|
+
// NOTE: if running in browser/old node version/old webpack version may not have method
|
|
75
|
+
if (fs_1.default === null || fs_1.default === void 0 ? void 0 : fs_1.default.existsSync) {
|
|
76
|
+
if (!((_a = locations_1.ICON_LOCATION_ALLOWLIST[product]) === null || _a === void 0 ? void 0 : _a.includes(location))) {
|
|
77
|
+
return productIcon;
|
|
78
|
+
}
|
|
79
|
+
const svgPath = isMultiProduct ? `${product}/icon_${location}.svg` : `icon_${location}.svg`;
|
|
80
|
+
const baseIconPath = path_1.default.resolve(__dirname);
|
|
81
|
+
const imagePaths = [svgPath, path_1.default.join('assets', svgPath), path_1.default.join('images', svgPath)];
|
|
82
|
+
// NOTE: intentionally using for loops instead of map so we can break to exit quickly soon as matched
|
|
83
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
84
|
+
for (const imagePath of imagePaths) {
|
|
85
|
+
if (fs_1.default.existsSync(path_1.default.join(baseIconPath, 'public', imagePath))) {
|
|
86
|
+
productIcon = {
|
|
87
|
+
svg: imagePath,
|
|
88
|
+
// HMMM: active/inactive/hover??
|
|
89
|
+
};
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return productIcon;
|
|
95
|
+
};
|
|
96
|
+
const getIconsByProduct = ({ product, productLocations, isMultiProduct }) => (Object.entries(productLocations).reduce((productLocationIcons, [location]) => {
|
|
97
|
+
const productIcon = getProductIcon({ product, location, isMultiProduct });
|
|
98
|
+
return Object.assign(Object.assign({}, productLocationIcons), (productIcon && {
|
|
99
|
+
[location]: productIcon,
|
|
100
|
+
}));
|
|
101
|
+
}, {}));
|
|
102
|
+
// HMMMMM: optimize this method!
|
|
103
|
+
const normalizeLocations = (_locations) => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
const locations = display_1.ensureObject(_locations);
|
|
106
|
+
const isMultiProduct = Object.keys(locations) > 1;
|
|
107
|
+
const productIcons = Object.entries(locations).reduce((_productIcons, [product, productLocations]) => (Object.assign(Object.assign({}, _productIcons), { [product]: getIconsByProduct({ product, productLocations, isMultiProduct }) })), {});
|
|
108
|
+
for (const product in productIcons) {
|
|
109
|
+
for (const locationName in productIcons[product]) {
|
|
110
|
+
if (typeof locations[product][locationName] === 'string') {
|
|
111
|
+
locations[product][locationName] = {
|
|
112
|
+
url: display_1.cleanURL(locations[product][locationName]),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
if (typeof ((_a = locations[product][locationName]) === null || _a === void 0 ? void 0 : _a.url) === 'string') {
|
|
116
|
+
locations[product][locationName] = Object.assign(Object.assign({}, locations[product][locationName]), { url: display_1.cleanURL(locations[product][locationName].url) });
|
|
117
|
+
}
|
|
118
|
+
if (productIcons[product][locationName].svg) {
|
|
119
|
+
locations[product][locationName].svg = productIcons[product][locationName].svg;
|
|
120
|
+
}
|
|
121
|
+
if (productIcons[product][locationName].active) {
|
|
122
|
+
locations[product][locationName].active = productIcons[product][locationName].active;
|
|
123
|
+
}
|
|
124
|
+
if (productIcons[product][locationName].inactive) {
|
|
125
|
+
locations[product][locationName].inactive = productIcons[product][locationName].inactive;
|
|
126
|
+
}
|
|
127
|
+
if (productIcons[product][locationName].hover) {
|
|
128
|
+
locations[product][locationName].hover = productIcons[product][locationName].hover;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// Handle the case where an app installation location is not an object but is a string,
|
|
133
|
+
for (const product in locations) {
|
|
134
|
+
for (const locationName in locations[product]) {
|
|
135
|
+
if (typeof locations[product][locationName] === 'string') {
|
|
136
|
+
locations[product][locationName] = {
|
|
137
|
+
url: display_1.cleanURL(locations[product][locationName]),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
else if (typeof ((_b = locations[product][locationName]) === null || _b === void 0 ? void 0 : _b.url) === 'string') {
|
|
141
|
+
locations[product][locationName] = Object.assign(Object.assign({}, locations[product][locationName]), { url: display_1.cleanURL(locations[product][locationName].url) });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return locations;
|
|
146
|
+
};
|
|
147
|
+
const templateReplace = (template, replacements, partials, tokens) => {
|
|
148
|
+
// NOTE: fixes issues where by default standard characters are HTML encoded (https://stackoverflow.com/questions/22910428/mustache-globally-disable-html-escaping)
|
|
149
|
+
mustache_1.default.escape = (value) => (value);
|
|
150
|
+
return mustache_1.default.render(display_1.ensureString(template), display_1.ensureObject(replacements), partials, tokens);
|
|
151
|
+
};
|
|
152
|
+
const arrowsReplace = (template, replacements) => (templateReplace(template, display_1.cleanObject(replacements), {}, ['<<', '>>']));
|
|
153
|
+
exports.arrowsReplace = arrowsReplace;
|
|
154
|
+
const arrowsItemReplace = (value, replacements) => (display_1.isType(value, 'object')
|
|
155
|
+
? Object.entries(value).reduce((_data, [_key, _value]) => (Object.assign(Object.assign({}, _data), { [_key]: exports.arrowsReplace(_value, replacements) })), {})
|
|
156
|
+
: exports.arrowsReplace(value, replacements));
|
|
157
|
+
const generateReplacements = (_replacements) => {
|
|
158
|
+
const replacements = display_1.cleanObject(_replacements);
|
|
159
|
+
return display_1.cleanObject(Object.entries(replacements).reduce((data, [key, _value]) => {
|
|
160
|
+
// eslint-disable-next-line no-nested-ternary
|
|
161
|
+
const value = Array.isArray(_value)
|
|
162
|
+
? _value.reduce((_data, __value) => ([
|
|
163
|
+
..._data,
|
|
164
|
+
arrowsItemReplace(__value, replacements)
|
|
165
|
+
]), [])
|
|
166
|
+
: arrowsItemReplace(_value, replacements);
|
|
167
|
+
return Object.assign(Object.assign({}, data), { [key]: value });
|
|
168
|
+
}, {}));
|
|
169
|
+
};
|
|
170
|
+
exports.generateReplacements = generateReplacements;
|
|
171
|
+
const getRouteReplacements = (_locations, defaultRoute = '/index.html') => {
|
|
172
|
+
const locations = display_1.ensureObject(_locations);
|
|
173
|
+
return {
|
|
174
|
+
location: normalizeLocations(locations),
|
|
175
|
+
// NOTE: this generates a default set of routes that can be override by any passed in..BUT not sure how location.product factors in here
|
|
176
|
+
routes: Object.values(locations).reduce((_routes, productLocations) => (Object.assign(Object.assign({}, _routes), Object.keys(display_1.ensureObject(productLocations)).reduce((_locationRoutes, productLocation) => (Object.assign(Object.assign({}, _locationRoutes), { [productLocation]: defaultRoute })), {}))), {}),
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const getManifestData = (manifestTemplate, _replacements, mergeData) => {
|
|
180
|
+
var _a;
|
|
181
|
+
const data = display_1.cleanObject(display_1.deepmerge(display_1.ensureObject(manifestTemplate), exports.generateReplacements(mergeData)));
|
|
182
|
+
const replacements = exports.generateReplacements(_replacements);
|
|
183
|
+
return JSON.parse(exports.arrowsReplace(JSON.stringify(data, null, 2), display_1.deepmerge(getRouteReplacements(data === null || data === void 0 ? void 0 : data.location, (_a = replacements === null || replacements === void 0 ? void 0 : replacements.routes) === null || _a === void 0 ? void 0 : _a.default), replacements)));
|
|
184
|
+
};
|
|
185
|
+
const getAppData = (manifestTemplate, replacements, mergeData) => {
|
|
186
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
187
|
+
const manifestData = getManifestData(manifestTemplate, replacements, mergeData);
|
|
188
|
+
const _10 = exports.generateReplacements(mergeData), { settings } = _10, _installationData = __rest(_10, ["settings"]);
|
|
189
|
+
const defaultSettings = display_1.ensureArray(manifestData === null || manifestData === void 0 ? void 0 : manifestData.parameters).reduce((_parameters, { name: _name, default: defaultValue }) => {
|
|
190
|
+
var _a;
|
|
191
|
+
return (Object.assign(Object.assign({}, _parameters), { [_name]: (_a = _parameters[_name]) !== null && _a !== void 0 ? _a : defaultValue }));
|
|
192
|
+
}, display_1.ensureObject(replacements === null || replacements === void 0 ? void 0 : replacements.parameters));
|
|
193
|
+
const installationData = Object.assign(Object.assign({ id: (_c = (_b = (_a = replacements === null || replacements === void 0 ? void 0 : replacements.installation_id) !== null && _a !== void 0 ? _a : replacements === null || replacements === void 0 ? void 0 : replacements.installationId) !== null && _b !== void 0 ? _b : replacements === null || replacements === void 0 ? void 0 : replacements.id) !== null && _c !== void 0 ? _c : display_1.getInteger(), app_id: (_e = (_d = replacements === null || replacements === void 0 ? void 0 : replacements.app_id) !== null && _d !== void 0 ? _d : replacements === null || replacements === void 0 ? void 0 : replacements.appId) !== null && _e !== void 0 ? _e : display_1.getInteger(), instance_guid: (_h = (_g = (_f = replacements === null || replacements === void 0 ? void 0 : replacements.instance_guid) !== null && _f !== void 0 ? _f : replacements === null || replacements === void 0 ? void 0 : replacements.instanceGUID) !== null && _g !== void 0 ? _g : replacements === null || replacements === void 0 ? void 0 : replacements.instanceGuid) !== null && _h !== void 0 ? _h : display_1.getGUID(), host_name: (_l = (_k = (_j = replacements === null || replacements === void 0 ? void 0 : replacements.host_name) !== null && _j !== void 0 ? _j : replacements === null || replacements === void 0 ? void 0 : replacements.host) !== null && _k !== void 0 ? _k : replacements === null || replacements === void 0 ? void 0 : replacements.hostName) !== null && _l !== void 0 ? _l : browser_monads_1.window.location.host, product: (_m = replacements === null || replacements === void 0 ? void 0 : replacements.product) !== null && _m !== void 0 ? _m : locations_1.PRODUCTS.SUPPORT, location: (_o = replacements === null || replacements === void 0 ? void 0 : replacements.location) !== null && _o !== void 0 ? _o : locations_1.LOCATIONS.SIDEBAR_TICKET, app_owner: (_p = replacements === null || replacements === void 0 ? void 0 : replacements.app_owner) !== null && _p !== void 0 ? _p : replacements === null || replacements === void 0 ? void 0 : replacements.owner, app_name: (_t = (_s = (_r = (_q = replacements === null || replacements === void 0 ? void 0 : replacements.app_name) !== null && _q !== void 0 ? _q : replacements === null || replacements === void 0 ? void 0 : replacements.appName) !== null && _r !== void 0 ? _r : manifestData === null || manifestData === void 0 ? void 0 : manifestData.appName) !== null && _s !== void 0 ? _s : replacements === null || replacements === void 0 ? void 0 : replacements.name) !== null && _t !== void 0 ? _t : manifestData === null || manifestData === void 0 ? void 0 : manifestData.name, app_name_short: (_x = (_w = (_v = (_u = replacements === null || replacements === void 0 ? void 0 : replacements.app_name_short) !== null && _u !== void 0 ? _u : replacements === null || replacements === void 0 ? void 0 : replacements.shortName) !== null && _v !== void 0 ? _v : manifestData === null || manifestData === void 0 ? void 0 : manifestData.shortName) !== null && _w !== void 0 ? _w : replacements === null || replacements === void 0 ? void 0 : replacements.name) !== null && _x !== void 0 ? _x : manifestData === null || manifestData === void 0 ? void 0 : manifestData.name, app_version: (_z = (_y = replacements === null || replacements === void 0 ? void 0 : replacements.app_version) !== null && _y !== void 0 ? _y : replacements === null || replacements === void 0 ? void 0 : replacements.version) !== null && _z !== void 0 ? _z : manifestData === null || manifestData === void 0 ? void 0 : manifestData.version, terms_conditions_url: (_1 = (_0 = replacements === null || replacements === void 0 ? void 0 : replacements.terms_conditions_url) !== null && _0 !== void 0 ? _0 : replacements === null || replacements === void 0 ? void 0 : replacements.termsConditionsURL) !== null && _1 !== void 0 ? _1 : manifestData === null || manifestData === void 0 ? void 0 : manifestData.termsConditionsURL, app_locations: normalizeLocations((_3 = (_2 = replacements === null || replacements === void 0 ? void 0 : replacements.app_locations) !== null && _2 !== void 0 ? _2 : replacements === null || replacements === void 0 ? void 0 : replacements.locations) !== null && _3 !== void 0 ? _3 : manifestData === null || manifestData === void 0 ? void 0 : manifestData.location) }, _installationData), { settings: display_1.deepmerge(exports.generateReplacements(defaultSettings), display_1.ensureObject(settings)) });
|
|
194
|
+
const subscriptionId = (_5 = (_4 = replacements === null || replacements === void 0 ? void 0 : replacements.stripe_subscription_id) !== null && _4 !== void 0 ? _4 : replacements === null || replacements === void 0 ? void 0 : replacements.subscription_id) !== null && _5 !== void 0 ? _5 : replacements === null || replacements === void 0 ? void 0 : replacements.subscriptionId;
|
|
195
|
+
const subscriptionData = Object.assign(Object.assign({}, subscriptionId && {
|
|
196
|
+
stripe_subscription_id: subscriptionId,
|
|
197
|
+
}), { plan: {
|
|
198
|
+
name: (_9 = (_8 = (_7 = (_6 = replacements === null || replacements === void 0 ? void 0 : replacements.stripe_subscription_plan) !== null && _6 !== void 0 ? _6 : replacements === null || replacements === void 0 ? void 0 : replacements.subscription_plan) !== null && _7 !== void 0 ? _7 : replacements === null || replacements === void 0 ? void 0 : replacements.subscriptionPlan) !== null && _8 !== void 0 ? _8 : replacements === null || replacements === void 0 ? void 0 : replacements.plan) !== null && _9 !== void 0 ? _9 : null,
|
|
199
|
+
} });
|
|
200
|
+
const safData = {
|
|
201
|
+
context: {
|
|
202
|
+
host: 'zendesk',
|
|
203
|
+
product: installationData.product,
|
|
204
|
+
location: installationData.location,
|
|
205
|
+
instanceGuid: installationData.instance_guid,
|
|
206
|
+
account: {
|
|
207
|
+
subdomain: installationData.host_name,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
metadata: Object.assign({ appId: installationData.app_id, name: installationData.app_name, installationId: installationData.id, version: installationData.app_version, settings: installationData.settings }, subscriptionData),
|
|
211
|
+
};
|
|
212
|
+
return {
|
|
213
|
+
safData,
|
|
214
|
+
manifestData,
|
|
215
|
+
installationData,
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
exports.getAppData = getAppData;
|
|
219
|
+
const getZendeskData = (_a) => {
|
|
220
|
+
var { pluginConfig } = _a, replacements = __rest(_a, ["pluginConfig"]);
|
|
221
|
+
const _b = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {}, { routes = {}, data = {}, manifestTemplate } = _b, zendeskData = __rest(_b, ["routes", "data", "manifestTemplate"]);
|
|
222
|
+
return Object.assign(Object.assign({}, exports.getAppData(manifestTemplate, Object.assign(Object.assign(Object.assign({}, display_1.cleanObject(replacements)), display_1.cleanObject(data)), display_1.objectNotEmpty(display_1.cleanObject(routes)) && {
|
|
223
|
+
routes,
|
|
224
|
+
}))), display_1.objectNotEmpty(display_1.cleanObject(zendeskData)) && {
|
|
225
|
+
zendeskData,
|
|
226
|
+
});
|
|
227
|
+
};
|
|
228
|
+
exports.getZendeskData = getZendeskData;
|
|
229
|
+
// TODO: externalize to shared project (shared w/ next-zcli & next-shopify)
|
|
230
|
+
const getPrompts = async (_questions, { phase, disabled } = {}) => {
|
|
231
|
+
const questions = display_1.ensureArray(_questions).reduce((__questions, _a) => {
|
|
232
|
+
var { name, message } = _a, question = __rest(_a, ["name", "message"]);
|
|
233
|
+
return ([
|
|
234
|
+
...__questions,
|
|
235
|
+
Object.assign(Object.assign({ name }, question), message && {
|
|
236
|
+
message: `[${name}] ${message}`,
|
|
237
|
+
})
|
|
238
|
+
]);
|
|
239
|
+
}, []);
|
|
240
|
+
let values = questions.reduce((_values, { name, initial: value }) => (Object.assign(Object.assign({}, _values), { [name]: value })), {});
|
|
241
|
+
if (phase === constants_1.PHASE_DEVELOPMENT_SERVER) {
|
|
242
|
+
if (!disabled) {
|
|
243
|
+
try {
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
245
|
+
const prompts = require('prompts');
|
|
246
|
+
values = await prompts(questions);
|
|
247
|
+
}
|
|
248
|
+
catch (_ignore) {
|
|
249
|
+
console.warn(`${chalk_1.default.yellow('warn')} - ${
|
|
250
|
+
// eslint-disable-next-line max-len
|
|
251
|
+
chalk_1.default.yellow(`Ignoring ${chalk_1.default.bold("missing 'devDependency' for 'prompts'")} - required when setting 'interactive: true'`)}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
Object.entries(values).forEach(([name, value]) => {
|
|
256
|
+
var _a;
|
|
257
|
+
const { message } = (_a = questions.find((question) => question.name === name)) !== null && _a !== void 0 ? _a : {};
|
|
258
|
+
if (message) {
|
|
259
|
+
console.info(`${chalk_1.default.yellowBright('next-zcli')} - ${chalk_1.default.bold(message)}: ${value}`);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
console.info(`${chalk_1.default.yellowBright('next-zcli')} - [${chalk_1.default.bold(name)}]: ${value}`);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return values;
|
|
268
|
+
};
|
|
269
|
+
exports.getPrompts = getPrompts;
|
|
270
|
+
//# sourceMappingURL=data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/utils/data.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,wDAA+B;AAC/B,mDAAuC;AACvC,8CAAyD;AAEzD,uCAYkB;AAClB,2CAA0E;AAE7D,QAAA,gBAAgB,GAAG,SAAS,CAAA;AAEzC,MAAM,QAAQ,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CACxB,MAAM,CAAC,OAAO,CAAC,sBAAY,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,iCAC1D,IAAI,GAEJ,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI;IACvD,CAAC,GAAG,CAAC,EAAE,GAAG;CACX,EACD,EAAE,EAAE,CAAC,CACR,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAC5B,MAAM,CAAC,OAAO,CAAC,sBAAY,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,iCAC1D,IAAI;IACP,0CAA0C;IAC1C,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAC1B,EAAE,EAAE,CAAC,CACR,CAAA;AAED,wDAAwD;AACjD,MAAM,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AE,CAAC,CAAA;iBACtF;qBAAM;oBACL,OAAO,CAAC,IAAI,CAAC,GAAG,eAAK,CAAC,YAAY,CAAC,WAAW,CAAC,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,CAAC,CAAA;iBACrF;YACH,CAAC,CAAC,CAAA;SACH;KACF;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AA1CY,QAAA,UAAU,cA0CtB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default as deepmerge } from "deepmerge";
|
|
2
|
+
export function getGUID(): any;
|
|
3
|
+
export function getInteger(): any;
|
|
4
|
+
export function isType(value: any, type: any): boolean;
|
|
5
|
+
export function ensureString(string: any): string;
|
|
6
|
+
export function ensureArray(array?: any[]): any[];
|
|
7
|
+
export function ensureObject(object: any): any;
|
|
8
|
+
export function objectEmpty(object: any): boolean;
|
|
9
|
+
export function objectNotEmpty(object: any): boolean;
|
|
10
|
+
export function cleanObject(object: any): any;
|
|
11
|
+
export function cleanURL(string: any): string;
|
|
12
|
+
export function removeLeadingSlash(string: any): string;
|
|
13
|
+
export function removeTrailingSlash(string: any): string;
|
|
14
|
+
export function stringNotEmpty(stringable: any): boolean;
|
|
15
|
+
export function stringEmpty(stringable: any): boolean;
|
|
16
|
+
export function isTrue(value: any, falsy: any): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
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.isTrue = exports.stringEmpty = exports.stringNotEmpty = exports.removeTrailingSlash = exports.removeLeadingSlash = exports.cleanURL = exports.cleanObject = exports.objectNotEmpty = exports.objectEmpty = exports.ensureObject = exports.ensureArray = exports.ensureString = exports.isType = exports.getInteger = exports.getGUID = exports.deepmerge = void 0;
|
|
7
|
+
/* eslint-disable no-use-before-define */
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
var deepmerge_1 = require("deepmerge");
|
|
10
|
+
Object.defineProperty(exports, "deepmerge", { enumerable: true, get: function () { return __importDefault(deepmerge_1).default; } });
|
|
11
|
+
const getGUID = () => (uuid_1.v4());
|
|
12
|
+
exports.getGUID = getGUID;
|
|
13
|
+
const getInteger = () => (exports.getGUID().replace(/\D/g, ''));
|
|
14
|
+
exports.getInteger = getInteger;
|
|
15
|
+
const isType = (value, type) => (
|
|
16
|
+
// eslint-disable-next-line eqeqeq, valid-typeof
|
|
17
|
+
value != undefined && typeof value === type);
|
|
18
|
+
exports.isType = isType;
|
|
19
|
+
// TODO: keep in sync w/ lib-core
|
|
20
|
+
const ensureString = (string) => (string ? `${string}` : '');
|
|
21
|
+
exports.ensureString = ensureString;
|
|
22
|
+
const ensureArray = (array = []) => (
|
|
23
|
+
// eslint-disable-next-line no-nested-ternary
|
|
24
|
+
!array ? [] : Array.isArray(array) ? array : [array]);
|
|
25
|
+
exports.ensureArray = ensureArray;
|
|
26
|
+
const ensureObject = (object) => (object !== null && object !== void 0 ? object : {});
|
|
27
|
+
exports.ensureObject = ensureObject;
|
|
28
|
+
const objectEmpty = (object) => (!object || !Object.keys(object).length);
|
|
29
|
+
exports.objectEmpty = objectEmpty;
|
|
30
|
+
const objectNotEmpty = (object) => (!exports.objectEmpty(object));
|
|
31
|
+
exports.objectNotEmpty = objectNotEmpty;
|
|
32
|
+
const cleanObject = (object) => (Object.entries(exports.ensureObject(object)).reduce((_cleanedObject, [key, _value]) => {
|
|
33
|
+
// eslint-disable-next-line eqeqeq
|
|
34
|
+
if (_value == undefined) {
|
|
35
|
+
return _cleanedObject; // skip key if null or undefined
|
|
36
|
+
}
|
|
37
|
+
const value = Array.isArray(_value)
|
|
38
|
+
? _value.reduce((_data, __value) => ([
|
|
39
|
+
..._data,
|
|
40
|
+
cleanObjectValue(__value)
|
|
41
|
+
]), [])
|
|
42
|
+
: cleanObjectValue(_value);
|
|
43
|
+
return Object.assign(Object.assign({}, _cleanedObject), { [key]: value });
|
|
44
|
+
}, {}));
|
|
45
|
+
exports.cleanObject = cleanObject;
|
|
46
|
+
const cleanObjectValue = (value) => (exports.isType(value, 'object') ? exports.cleanObject(value) : value);
|
|
47
|
+
const cleanURL = (string) => (exports.ensureString(string).replace(/(?<!:)\/+/gm, '/'));
|
|
48
|
+
exports.cleanURL = cleanURL;
|
|
49
|
+
const removeLeadingSlash = (string) => (exports.ensureString(string).replace(/^\//, ''));
|
|
50
|
+
exports.removeLeadingSlash = removeLeadingSlash;
|
|
51
|
+
const removeTrailingSlash = (string) => (exports.ensureString(string).replace(/\/+$/, ''));
|
|
52
|
+
exports.removeTrailingSlash = removeTrailingSlash;
|
|
53
|
+
const stringNotEmpty = (stringable) => {
|
|
54
|
+
const string = exports.ensureString(stringable);
|
|
55
|
+
return ((string.length > 0) && !['null', 'undefined'].includes(string));
|
|
56
|
+
};
|
|
57
|
+
exports.stringNotEmpty = stringNotEmpty;
|
|
58
|
+
const stringEmpty = (stringable) => (!exports.stringNotEmpty(stringable));
|
|
59
|
+
exports.stringEmpty = stringEmpty;
|
|
60
|
+
const isTrue = (value, falsy) => {
|
|
61
|
+
const string = exports.ensureString(value);
|
|
62
|
+
return ![...exports.ensureArray(falsy), '', 'false'].includes(string);
|
|
63
|
+
};
|
|
64
|
+
exports.isTrue = isTrue;
|
|
65
|
+
//# sourceMappingURL=display.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.js","sourceRoot":"","sources":["../../src/utils/display.js"],"names":[],"mappings":";;;;;;AAAA,yCAAyC;AACzC,+BAAmC;AAEnC,uCAAgD;AAAvC,uHAAA,OAAO,OAAa;AAEtB,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAC3B,SAAM,EAAE,CACT,CAAA;AAFY,QAAA,OAAO,WAEnB;AAEM,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,C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AC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACzC,CAAA;AAFY,QAAA,mBAAmB,uBAE/B;AAEM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,EAAE;IAC3C,MAAM,MAAM,GAAG,oBAAY,CAAC,UAAU,CAAC,CAAA;IACvC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;AACzE,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B;AAEM,MAAM,WAAW,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CACzC,CAAC,sBAAc,CAAC,UAAU,CAAC,CAC5B,CAAA;AAFY,QAAA,WAAW,eAEvB;AAEM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;IACrC,MAAM,MAAM,GAAG,oBAAY,CAAC,KAAK,CAAC,CAAA;IAClC,OAAO,CAAC,CAAC,GAAG,mBAAW,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AAC/D,CAAC,CAAA;AAHY,QAAA,MAAM,UAGlB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./data"), exports);
|
|
14
|
+
__exportStar(require("./display"), exports);
|
|
15
|
+
__exportStar(require("./locations"), exports);
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,4CAAyB;AACzB,8CAA2B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export namespace PRODUCTS {
|
|
2
|
+
const CHAT: string;
|
|
3
|
+
const SELL: string;
|
|
4
|
+
const SUPPORT: string;
|
|
5
|
+
}
|
|
6
|
+
export namespace LOCATIONS {
|
|
7
|
+
const SIDEBAR_TICKET: string;
|
|
8
|
+
const SIDEBAR_NEW_TICKET: string;
|
|
9
|
+
const SIDEBAR_USER: string;
|
|
10
|
+
const SIDEBAR_ORGANIZATION: string;
|
|
11
|
+
const EDITOR: string;
|
|
12
|
+
const MODAL: string;
|
|
13
|
+
const TOP: string;
|
|
14
|
+
const TOP_SYSTEM: string;
|
|
15
|
+
const FULLSCREEN: string;
|
|
16
|
+
const BACKGROUND: string;
|
|
17
|
+
}
|
|
18
|
+
export const ICON_LOCATION_ALLOWLIST: {
|
|
19
|
+
[x: string]: string[];
|
|
20
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ICON_LOCATION_ALLOWLIST = exports.LOCATIONS = exports.PRODUCTS = void 0;
|
|
4
|
+
exports.PRODUCTS = {
|
|
5
|
+
CHAT: 'chat',
|
|
6
|
+
SELL: 'sell',
|
|
7
|
+
SUPPORT: 'support',
|
|
8
|
+
};
|
|
9
|
+
exports.LOCATIONS = {
|
|
10
|
+
SIDEBAR_TICKET: 'ticket_sidebar',
|
|
11
|
+
SIDEBAR_NEW_TICKET: 'new_ticket_sidebar',
|
|
12
|
+
SIDEBAR_USER: 'user_sidebar',
|
|
13
|
+
SIDEBAR_ORGANIZATION: 'organization_sidebar',
|
|
14
|
+
EDITOR: 'ticket_editor',
|
|
15
|
+
MODAL: 'modal',
|
|
16
|
+
TOP: 'top_bar',
|
|
17
|
+
TOP_SYSTEM: 'system_top_bar',
|
|
18
|
+
FULLSCREEN: 'nav_bar',
|
|
19
|
+
BACKGROUND: 'background',
|
|
20
|
+
};
|
|
21
|
+
// The SVGs here are in the top bar or nav bar locations. Chat don’t have these locations thus not here.
|
|
22
|
+
exports.ICON_LOCATION_ALLOWLIST = {
|
|
23
|
+
[exports.PRODUCTS.SUPPORT]: [exports.LOCATIONS.FULLSCREEN, exports.LOCATIONS.TOP, exports.LOCATIONS.TOP_SYSTEM, exports.LOCATIONS.EDITOR],
|
|
24
|
+
[exports.PRODUCTS.SELL]: [exports.LOCATIONS.TOP],
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=locations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locations.js","sourceRoot":"","sources":["../../src/utils/locations.js"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;CACnB,CAAA;AAEY,QAAA,SAAS,GAAG;IACvB,cAAc,EAAE,gBAAgB;IAChC,kBAAkB,EAAE,oBAAoB;IACxC,YAAY,EAAE,cAAc;IAC5B,oBAAoB,EAAE,sBAAsB;IAC5C,MAAM,EAAE,eAAe;IACvB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,gBAAgB;IAC5B,UAAU,EAAE,SAAS;IACrB,UAAU,EAAE,YAAY;CACzB,CAAA;AAED,wGAAwG;AAC3F,QAAA,uBAAuB,GAAG;IACrC,CAAC,gBAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,iBAAS,CAAC,UAAU,EAAE,iBAAS,CAAC,GAAG,EAAE,iBAAS,CAAC,UAAU,EAAE,iBAAS,CAAC,MAAM,CAAC;IACjG,CAAC,gBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,CAAC,GAAG,CAAC;CACjC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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.withPlugins = void 0;
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const withPlugins = async (nextPhase, _a) => {
|
|
17
|
+
var { defaultConfig, nextConfig, nextPlugins } = _a, nextProps = __rest(_a, ["defaultConfig", "nextConfig", "nextPlugins"]);
|
|
18
|
+
const chainedConfig = await utils_1.ensureArray(nextPlugins).reduce(async (_chainedConfigP, chained) => {
|
|
19
|
+
const _chainedConfig = await _chainedConfigP;
|
|
20
|
+
const { plugin, config } = (typeof chained === 'function') ? { plugin: chained } : chained;
|
|
21
|
+
if (typeof plugin !== 'function') {
|
|
22
|
+
return _chainedConfig;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
// NOTE: some plugins are curried w/ second call containing nextPhase
|
|
26
|
+
return plugin(nextPhase, Object.assign({ defaultConfig, nextConfig: _chainedConfig }, config));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (!(error instanceof TypeError)) {
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
return _chainedConfig;
|
|
33
|
+
}
|
|
34
|
+
}, Promise.resolve(nextConfig));
|
|
35
|
+
return Object.assign(Object.assign({}, chainedConfig), nextProps);
|
|
36
|
+
};
|
|
37
|
+
exports.withPlugins = withPlugins;
|
|
38
|
+
//# sourceMappingURL=withPlugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withPlugins.js","sourceRoot":"","sources":["../src/withPlugins.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAqC;AAE9B,MAAM,WAAW,GAAG,KAAK,EAAE,SAAS,EAAE,EAAwD,EAAE,EAAE;QAA5D,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,OAAgB,EAAX,SAAS,cAAtD,8CAAwD,CAAF;IACjG,MAAM,aAAa,GAAG,MAAM,mBAAW,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE;QAC7F,MAAM,cAAc,GAAG,MAAM,eAAe,CAAA;QAC5C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QAE1F,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE;YAChC,OAAO,cAAc,CAAA;SACtB;QAED,IAAI;YACF,qEAAqE;YACrE,OAAO,MAAM,CAAC,SAAS,kBAAI,aAAa,EAAE,UAAU,EAAE,cAAc,IAAK,MAAM,EAAG,CAAA;SACnF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE;gBACjC,MAAM,KAAK,CAAA;aACZ;YACD,OAAO,cAAc,CAAA;SACtB;IACH,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;IAE/B,uCACK,aAAa,GACb,SAAS,EACb;AACH,CAAC,CAAA;AAxBY,QAAA,WAAW,eAwBvB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.withZendeskCLI = void 0;
|
|
18
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
+
const constants_1 = require("next/constants");
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
const withZendeskCLI = async (nextPhase, _a) => {
|
|
22
|
+
var { nextConfig } = _a, config = __rest(_a, ["nextConfig"]);
|
|
23
|
+
const _b = nextConfig !== null && nextConfig !== void 0 ? nextConfig : {}, { basePath, rewrites: _rewrites, headers: _headers, exportPathMap: _exportPathMap, publicRuntimeConfig: _publicRuntimeConfig = {}, serverRuntimeConfig: _serverRuntimeConfig = {} } = _b, _nextConfig = __rest(_b, ["basePath", "rewrites", "headers", "exportPathMap", "publicRuntimeConfig", "serverRuntimeConfig"]);
|
|
24
|
+
const _c = config !== null && config !== void 0 ? config : {}, {
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
defaultConfig } = _c, // NOTE: This is here in case we need anything from it
|
|
27
|
+
pluginConfig = __rest(_c, ["defaultConfig"]);
|
|
28
|
+
const { data: { asset_url_prefix = utils_1.ASSET_URL_PREFIX, } = {}, } = pluginConfig !== null && pluginConfig !== void 0 ? pluginConfig : {};
|
|
29
|
+
const _d = utils_1.getZendeskData({
|
|
30
|
+
asset_url_prefix: utils_1.ASSET_URL_PREFIX,
|
|
31
|
+
pluginConfig,
|
|
32
|
+
}), { zendeskData } = _d, appData = __rest(_d, ["zendeskData"]);
|
|
33
|
+
const _e = zendeskData !== null && zendeskData !== void 0 ? zendeskData : {}, { interactive, appRequirements, apiRoute: _apiRoute = '/api/apps' } = _e, _zendeskData = __rest(_e, ["interactive", "appRequirements", "apiRoute"]);
|
|
34
|
+
const { installationData: { id: _installationId, app_id: _appId, app_name: _appName, app_locations: appLocations, settings: appSettings, } = {}, safData: { metadata: { stripe_subscription_id: subscriptionId, plan: { name: subscriptionPlan, } = {}, } = {}, } = {}, manifestData: { version: appVersion, defaultLocale: appLocale, signedUrls: appSignedURLs, singleInstall: appSingleInstall, frameworkVersion: appFrameworkVersion, }, } = appData !== null && appData !== void 0 ? appData : {};
|
|
35
|
+
const { id: installationId, app_id: appId, app_name: appName, apiRoute, } = await utils_1.getPrompts([
|
|
36
|
+
{
|
|
37
|
+
type: 'text',
|
|
38
|
+
name: 'id',
|
|
39
|
+
message: 'Installation ID',
|
|
40
|
+
initial: _installationId,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: 'text',
|
|
44
|
+
name: 'app_id',
|
|
45
|
+
message: 'Application ID',
|
|
46
|
+
initial: _appId,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
name: 'app_name',
|
|
51
|
+
message: 'Application Name',
|
|
52
|
+
initial: _appName,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'text',
|
|
56
|
+
name: 'apiRoute',
|
|
57
|
+
message: 'API Route (/apps.json)',
|
|
58
|
+
initial: _apiRoute,
|
|
59
|
+
}
|
|
60
|
+
], { phase: nextPhase, disabled: !utils_1.isTrue(interactive) });
|
|
61
|
+
const isExportMode = nextPhase === constants_1.PHASE_EXPORT;
|
|
62
|
+
const isDevMode = nextPhase === constants_1.PHASE_DEVELOPMENT_SERVER;
|
|
63
|
+
// NOTE: this is to fix the issue w/ ZAS requiring local paths to start with /assets: https://github.com/zendesk/zendesk_apps_support/commit/458f077caafce67fb4a0676c26e8666f156f4286
|
|
64
|
+
const exportPathMap = async (defaultPathMap) => {
|
|
65
|
+
const baseExportPathMap = _exportPathMap ? await _exportPathMap(defaultPathMap !== null && defaultPathMap !== void 0 ? defaultPathMap : {}) : defaultPathMap;
|
|
66
|
+
if (!isExportMode || (asset_url_prefix === null || asset_url_prefix === void 0 ? void 0 : asset_url_prefix.startsWith('http'))) {
|
|
67
|
+
return baseExportPathMap;
|
|
68
|
+
}
|
|
69
|
+
return Object.entries(utils_1.ensureObject(baseExportPathMap)).reduce((pathMap, [path, value]) => {
|
|
70
|
+
const cleanAssetURLPath = utils_1.removeLeadingSlash(utils_1.removeTrailingSlash(asset_url_prefix));
|
|
71
|
+
const assetPath = utils_1.cleanURL(path === '/' ? `/${cleanAssetURLPath}/index` : `/${cleanAssetURLPath}${path}`);
|
|
72
|
+
// eslint-disable-next-line max-len
|
|
73
|
+
console.info(`${chalk_1.default.yellowBright('next-zcli')} - Added exportPathMap for: '${chalk_1.default.yellowBright(assetPath)}' to '${chalk_1.default.yellowBright(path)}'`);
|
|
74
|
+
return Object.assign(Object.assign({}, pathMap), { [path]: value, [assetPath]: value });
|
|
75
|
+
}, {});
|
|
76
|
+
};
|
|
77
|
+
const headers = async () => {
|
|
78
|
+
const baseHeaders = _headers ? await _headers() : [];
|
|
79
|
+
if (!isDevMode) {
|
|
80
|
+
return baseHeaders;
|
|
81
|
+
}
|
|
82
|
+
return [
|
|
83
|
+
...baseHeaders,
|
|
84
|
+
{
|
|
85
|
+
source: '/app.json',
|
|
86
|
+
headers: [
|
|
87
|
+
{
|
|
88
|
+
key: 'Access-Control-Allow-Methods',
|
|
89
|
+
value: 'GET',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: 'Access-Control-Allow-Credentials',
|
|
93
|
+
value: 'false',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: 'Access-Control-Allow-Origin',
|
|
97
|
+
value: '*',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: 'Access-Control-Allow-Headers',
|
|
101
|
+
value: '*',
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
}
|
|
105
|
+
];
|
|
106
|
+
};
|
|
107
|
+
// NOTE: the code below ONLY runs when running a local dev server!
|
|
108
|
+
const rewrites = async () => {
|
|
109
|
+
const _a = _rewrites ? await _rewrites() : {}, { beforeFiles = [] } = _a, baseRewrites = __rest(_a, ["beforeFiles"]);
|
|
110
|
+
if (!isDevMode) {
|
|
111
|
+
return baseRewrites;
|
|
112
|
+
}
|
|
113
|
+
const updatedRewrites = Object.assign(Object.assign({}, baseRewrites), { beforeFiles: [
|
|
114
|
+
...beforeFiles,
|
|
115
|
+
{
|
|
116
|
+
source: '/app.json',
|
|
117
|
+
destination: apiRoute,
|
|
118
|
+
}
|
|
119
|
+
] });
|
|
120
|
+
return updatedRewrites;
|
|
121
|
+
};
|
|
122
|
+
const publicRuntimeConfig = Object.assign(Object.assign({}, _publicRuntimeConfig), appData);
|
|
123
|
+
const serverRuntimeConfig = Object.assign(Object.assign({}, _serverRuntimeConfig), isDevMode && {
|
|
124
|
+
subscriptionId,
|
|
125
|
+
subscriptionPlan,
|
|
126
|
+
installationId,
|
|
127
|
+
appId,
|
|
128
|
+
appName,
|
|
129
|
+
appSettings,
|
|
130
|
+
appRequirements,
|
|
131
|
+
appLocale,
|
|
132
|
+
appVersion,
|
|
133
|
+
appSignedURLs,
|
|
134
|
+
appSingleInstall,
|
|
135
|
+
appFrameworkVersion,
|
|
136
|
+
appLocations,
|
|
137
|
+
});
|
|
138
|
+
if (isDevMode) {
|
|
139
|
+
console.log(`${chalk_1.default.green('ready')} - add ${chalk_1.default.yellowBright(chalk_1.default.bold('?zcli_apps=true'))} to the end of your Zendesk URL to load this app on your Zendesk account.\n`);
|
|
140
|
+
}
|
|
141
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (basePath && {
|
|
142
|
+
assetPrefix: `${utils_1.removeTrailingSlash(basePath)}/`, // NOTE: assetPrefix requires the trailing slash
|
|
143
|
+
})), _nextConfig), { publicRuntimeConfig,
|
|
144
|
+
serverRuntimeConfig,
|
|
145
|
+
basePath,
|
|
146
|
+
exportPathMap }), !isExportMode && {
|
|
147
|
+
headers,
|
|
148
|
+
rewrites,
|
|
149
|
+
}), utils_1.objectNotEmpty(utils_1.cleanObject(_zendeskData)) && {
|
|
150
|
+
zendesk: _zendeskData,
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
exports.withZendeskCLI = withZendeskCLI;
|
|
154
|
+
//# sourceMappingURL=withZendeskCLI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withZendeskCLI.js","sourceRoot":"","sources":["../src/withZendeskCLI.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAyB;AACzB,8CAGuB;AAEvB,mCAWgB;AAET,MAAM,cAAc,GAAG,KAAK,EAAE,SAAS,EAAE,EAAyB,EAAE,EAAE;QAA7B,EAAE,UAAU,OAAa,EAAR,MAAM,cAAvB,cAAyB,CAAF;IACrE,MAAM,KAQF,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,EAAE,EARd,EACJ,QAAQ,EACR,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,cAAc,EAC7B,mBAAmB,EAAE,oBAAoB,GAAG,EAAE,EAC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ACH,CAAC,CAAA;AA7NY,QAAA,cAAc,kBA6N1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function zendeskCLIHandler(props: any): (req: any, res: any) => Promise<any>;
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.zendeskCLIHandler = void 0;
|
|
18
|
+
const nextjs_cors_1 = __importDefault(require("nextjs-cors"));
|
|
19
|
+
const utils_1 = require("./utils");
|
|
20
|
+
const transformApp = ({ locale, asset_url_prefix, appId: _appId, appName: _appName, appLocale: _appLocale, appVersion: _appVersion, appSignedURLs: _appSignedURLs, appSingleInstall: _appSingleInstall, appFrameworkVersionL: _appFrameworkVersion, appLocations: _appLocations, installationData: { app_id, app_name, app_locations, } = {}, manifestData: { version, defaultLocale, signedUrls, singleInstall, frameworkVersion, } = {}, }) => {
|
|
21
|
+
var _a, _b, _c, _d, _e;
|
|
22
|
+
const appId = _appId !== null && _appId !== void 0 ? _appId : app_id;
|
|
23
|
+
const appName = _appName !== null && _appName !== void 0 ? _appName : app_name;
|
|
24
|
+
const appVersion = _appVersion !== null && _appVersion !== void 0 ? _appVersion : version;
|
|
25
|
+
const appSignedURLs = (_a = _appSignedURLs !== null && _appSignedURLs !== void 0 ? _appSignedURLs : signedUrls) !== null && _a !== void 0 ? _a : false;
|
|
26
|
+
const appSingleInstall = (_b = _appSingleInstall !== null && _appSingleInstall !== void 0 ? _appSingleInstall : singleInstall) !== null && _b !== void 0 ? _b : false;
|
|
27
|
+
const appFrameworkVersion = (_c = _appFrameworkVersion !== null && _appFrameworkVersion !== void 0 ? _appFrameworkVersion : frameworkVersion) !== null && _c !== void 0 ? _c : '2.0';
|
|
28
|
+
const appLocale = (_e = (_d = _appLocale !== null && _appLocale !== void 0 ? _appLocale : locale) !== null && _d !== void 0 ? _d : defaultLocale) !== null && _e !== void 0 ? _e : 'en'; // HMMM: not sure about locale here as second vs third fallback
|
|
29
|
+
const appLocations = utils_1.ensureObject(_appLocations !== null && _appLocations !== void 0 ? _appLocations : app_locations);
|
|
30
|
+
return {
|
|
31
|
+
name: appName,
|
|
32
|
+
version: appVersion,
|
|
33
|
+
signed_urls: appSignedURLs,
|
|
34
|
+
single_install: appSingleInstall,
|
|
35
|
+
framework_version: appFrameworkVersion,
|
|
36
|
+
id: appId,
|
|
37
|
+
locations: appLocations,
|
|
38
|
+
default_locale: appLocale,
|
|
39
|
+
asset_url_prefix,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const transformInstallation = ({ installationId: _installationId, appId: _appId, appName: _appName, appSettings: _appSettings, appRequirements: _appRequirements, installationData: { id, app_id, app_name, settings, } = {}, safData: { metadata: { plan: { name: subscriptionPlan, } = {}, } = {}, } = {}, }) => {
|
|
43
|
+
const installationId = _installationId !== null && _installationId !== void 0 ? _installationId : id;
|
|
44
|
+
const appId = _appId !== null && _appId !== void 0 ? _appId : app_id;
|
|
45
|
+
const appName = _appName !== null && _appName !== void 0 ? _appName : app_name;
|
|
46
|
+
const appSettings = utils_1.ensureObject(_appSettings !== null && _appSettings !== void 0 ? _appSettings : settings);
|
|
47
|
+
const appRequirements = utils_1.ensureArray(_appRequirements);
|
|
48
|
+
const appSettingsArray = Object.entries(appSettings).map(([key, value]) => ({
|
|
49
|
+
[key]: value,
|
|
50
|
+
}));
|
|
51
|
+
return Object.assign(Object.assign({ id: installationId, app_id: appId, name: appName, requirements: appRequirements, settings: [{ title: appName }, ...appSettingsArray] }, subscriptionPlan && {
|
|
52
|
+
plan: subscriptionPlan,
|
|
53
|
+
}), { updated_at: new Date().toISOString(), collapsible: true, enabled: true });
|
|
54
|
+
};
|
|
55
|
+
const buildAppJSON = (data) => {
|
|
56
|
+
const { protocol, host, asset_url_prefix, deployment_prefix = '', base_url = '' } = data;
|
|
57
|
+
let assetURLPrefix = asset_url_prefix || `${utils_1.removeTrailingSlash(deployment_prefix)}/${utils_1.removeLeadingSlash(base_url)}`;
|
|
58
|
+
if (asset_url_prefix === '/') {
|
|
59
|
+
assetURLPrefix = `${protocol}://${host}/${utils_1.removeLeadingSlash(base_url)}`;
|
|
60
|
+
}
|
|
61
|
+
const app = transformApp(Object.assign({ asset_url_prefix: assetURLPrefix }, data));
|
|
62
|
+
const installation = transformInstallation(data);
|
|
63
|
+
return {
|
|
64
|
+
apps: [app],
|
|
65
|
+
installations: [installation],
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
const getRequestData = ({ protocol: reqProtocol, query, headers, secure, encrypted } = {}) => {
|
|
69
|
+
const { host: _host, Host, origin: _origin, Origin, 'X-Forwarded-Proto': forwardedProtocol } = headers !== null && headers !== void 0 ? headers : {};
|
|
70
|
+
const { locale, subdomain } = query !== null && query !== void 0 ? query : {};
|
|
71
|
+
const host = _host || Host;
|
|
72
|
+
const origin = _origin || Origin;
|
|
73
|
+
let protocol = reqProtocol || forwardedProtocol;
|
|
74
|
+
if (!protocol && (secure != undefined)) {
|
|
75
|
+
if (secure) {
|
|
76
|
+
protocol = 'https';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!protocol && encrypted) {
|
|
80
|
+
protocol = 'https';
|
|
81
|
+
}
|
|
82
|
+
if (!protocol) {
|
|
83
|
+
protocol = 'http';
|
|
84
|
+
}
|
|
85
|
+
const { hostname } = origin ? new URL(origin) : {};
|
|
86
|
+
return { host, protocol, locale, origin, subdomain, hostname };
|
|
87
|
+
};
|
|
88
|
+
// NOTE: api routes do NOT work in `next export`
|
|
89
|
+
const zendeskCLIHandler = (props) => async (req, res) => {
|
|
90
|
+
const { protocol, query, headers, secure, socket } = req;
|
|
91
|
+
const _a = getRequestData({
|
|
92
|
+
protocol,
|
|
93
|
+
query,
|
|
94
|
+
headers,
|
|
95
|
+
secure,
|
|
96
|
+
encrypted: (socket.encrypted != undefined),
|
|
97
|
+
}), { hostname, subdomain, origin } = _a, requestData = __rest(_a, ["hostname", "subdomain", "origin"]);
|
|
98
|
+
if (!subdomain || (hostname !== `${subdomain}.zendesk.com`)) {
|
|
99
|
+
return res.status(403).json({ message: 'Missing/invalid hostname or subdomain, try running inside of zendesk w/ ?zcli_apps=true' });
|
|
100
|
+
}
|
|
101
|
+
await nextjs_cors_1.default(req, res, {
|
|
102
|
+
methods: ['GET'],
|
|
103
|
+
optionsSuccessStatus: 200,
|
|
104
|
+
origin,
|
|
105
|
+
});
|
|
106
|
+
return res.json(buildAppJSON(Object.assign(Object.assign({}, requestData), props)));
|
|
107
|
+
};
|
|
108
|
+
exports.zendeskCLIHandler = zendeskCLIHandler;
|
|
109
|
+
//# sourceMappingURL=zendeskCLIHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zendeskCLIHandler.js","sourceRoot":"","sources":["../src/zendeskCLIHandler.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8DAAkC;AAClC,mCAA4F;AAE5F,MAAM,YAAY,GAAG,CAAC,EACpB,MAAM,EACN,gBAAgB,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,WAAW,EACvB,aAAa,EAA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AC,IAAI,CAAC,EAAE,OAAO,EAAE,yFAAyF,EAAE,CAAC,CAAA;KACpI;IAED,MAAM,qBAAQ,CAAC,GAAG,EAAE,GAAG,EAAE;QACvB,OAAO,EAAE,CAAC,KAAK,CAAC;QAChB,oBAAoB,EAAE,GAAG;QACzB,MAAM;KACP,CAAC,CAAA;IAEF,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,iCAAM,WAAW,GAAK,KAAK,EAAG,CAAC,CAAA;AAC7D,CAAC,CAAA;AArBY,QAAA,iBAAiB,qBAqB7B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agnostack/next-shopify",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "agnoStack Dev <developers@agnostack.com> (https://agnostack.com)",
|
|
5
|
+
"owner": "agnoStack",
|
|
6
|
+
"description": "Please contact agnoStack via info@agnostack.com for any questions",
|
|
7
|
+
"homepage": "https://github.com/agnostack/next-shopify#readme",
|
|
8
|
+
"repository": "github:agnostack/next-shopify",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"nextjs",
|
|
11
|
+
"shopify",
|
|
12
|
+
"library",
|
|
13
|
+
"typescript",
|
|
14
|
+
"javascript",
|
|
15
|
+
"agnostack"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"typings": "dist/index.d.ts",
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=14.x"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -d",
|
|
28
|
+
"clean": "npx rimraf dist node_modules _storage",
|
|
29
|
+
"clean:install": "yarn clean && yarn install --force",
|
|
30
|
+
"lint": "eslint 'src/**' --fix",
|
|
31
|
+
"watch": "tsc -w",
|
|
32
|
+
"test": "jest --passWithNoTests",
|
|
33
|
+
"release": "npx semantic-release",
|
|
34
|
+
"release:debug": "npx semantic-release --debug",
|
|
35
|
+
"prepare": "husky install"
|
|
36
|
+
},
|
|
37
|
+
"lint-staged": {
|
|
38
|
+
"{src,test,types}/**/*.{js,ts}": [
|
|
39
|
+
"eslint --fix"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"next": "^12.1.0",
|
|
44
|
+
"react": "^17.0.2 || ^18.0.0-0",
|
|
45
|
+
"react-dom": "^17.0.2 || ^18.0.0-0",
|
|
46
|
+
"react-is": "^17.0.2 || ^18.0.0-0",
|
|
47
|
+
"prompts": "^2.4.0"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"browser-monads": "1.0.0",
|
|
51
|
+
"deepmerge": "4.2.2",
|
|
52
|
+
"dotenv-flow": "3.2.0",
|
|
53
|
+
"mustache": "4.2.0",
|
|
54
|
+
"nextjs-cors": "2.1.1"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@babel/core": "7.18.9",
|
|
58
|
+
"@babel/eslint-parser": "7.18.9",
|
|
59
|
+
"@commitlint/cli": "12.1.4",
|
|
60
|
+
"@commitlint/config-conventional": "12.1.4",
|
|
61
|
+
"@semantic-release/changelog": "5.0.1",
|
|
62
|
+
"@semantic-release/git": "9.0.1",
|
|
63
|
+
"@semantic-release/npm": "7.1.3",
|
|
64
|
+
"@semantic-release/release-notes-generator": "9.0.3",
|
|
65
|
+
"@types/jest": "26.0.24",
|
|
66
|
+
"@types/next": "9.0.0",
|
|
67
|
+
"@types/react": "17.0.2",
|
|
68
|
+
"@types/react-dom": "17.0.2",
|
|
69
|
+
"@typescript-eslint/eslint-plugin": "5.36.1",
|
|
70
|
+
"@typescript-eslint/parser": "5.36.1",
|
|
71
|
+
"chai": "4.3.6",
|
|
72
|
+
"chai-as-promised": "7.1.1",
|
|
73
|
+
"chalk": "4.1.2",
|
|
74
|
+
"chance": "1.1.8",
|
|
75
|
+
"eslint": "8.23.0",
|
|
76
|
+
"eslint-plugin-import": "2.26.0",
|
|
77
|
+
"husky": "6.0.0",
|
|
78
|
+
"jest": "26.6.3",
|
|
79
|
+
"lint-staged": "11.0.0",
|
|
80
|
+
"semantic-release": "17.4.3",
|
|
81
|
+
"sinon": "10.0.0",
|
|
82
|
+
"sinon-chai": "3.6.0",
|
|
83
|
+
"ts-jest": "26.5.6",
|
|
84
|
+
"typescript": "4.2.4",
|
|
85
|
+
"uuid": "8.3.2"
|
|
86
|
+
},
|
|
87
|
+
"publishConfig": {
|
|
88
|
+
"access": "public"
|
|
89
|
+
}
|
|
90
|
+
}
|