@shopify/cli-kit 4.1.0 → 4.2.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.
Files changed (63) hide show
  1. package/assets/graphiql/favicon.ico +0 -0
  2. package/assets/graphiql/style.css +58 -0
  3. package/dist/private/common/array.js +2 -1
  4. package/dist/private/common/array.js.map +1 -1
  5. package/dist/private/node/api/headers.js +6 -3
  6. package/dist/private/node/api/headers.js.map +1 -1
  7. package/dist/private/node/session/device-authorization.js +4 -16
  8. package/dist/private/node/session/device-authorization.js.map +1 -1
  9. package/dist/private/node/ui.js +4 -1
  10. package/dist/private/node/ui.js.map +1 -1
  11. package/dist/public/common/gid.d.ts +24 -0
  12. package/dist/public/common/gid.js +32 -0
  13. package/dist/public/common/gid.js.map +1 -0
  14. package/dist/public/common/url.d.ts +16 -0
  15. package/dist/public/common/url.js +30 -0
  16. package/dist/public/common/url.js.map +1 -1
  17. package/dist/public/common/version.d.ts +1 -1
  18. package/dist/public/common/version.js +1 -1
  19. package/dist/public/common/version.js.map +1 -1
  20. package/dist/public/node/analytics.js +3 -5
  21. package/dist/public/node/analytics.js.map +1 -1
  22. package/dist/public/node/cli.d.ts +13 -0
  23. package/dist/public/node/cli.js +12 -0
  24. package/dist/public/node/cli.js.map +1 -1
  25. package/dist/public/node/error-handler.js +1 -1
  26. package/dist/public/node/error-handler.js.map +1 -1
  27. package/dist/public/node/graphiql/server.d.ts +80 -0
  28. package/dist/public/node/graphiql/server.js +234 -0
  29. package/dist/public/node/graphiql/server.js.map +1 -0
  30. package/dist/public/node/graphiql/templates/graphiql.d.ts +12 -0
  31. package/dist/public/node/graphiql/templates/graphiql.js +314 -0
  32. package/dist/public/node/graphiql/templates/graphiql.js.map +1 -0
  33. package/dist/public/node/graphiql/templates/unauthorized.d.ts +5 -0
  34. package/dist/public/node/graphiql/templates/unauthorized.js +111 -0
  35. package/dist/public/node/graphiql/templates/unauthorized.js.map +1 -0
  36. package/dist/public/node/graphiql/utilities.d.ts +12 -0
  37. package/dist/public/node/graphiql/utilities.js +44 -0
  38. package/dist/public/node/graphiql/utilities.js.map +1 -0
  39. package/dist/public/node/graphql.d.ts +19 -0
  40. package/dist/public/node/graphql.js +41 -0
  41. package/dist/public/node/graphql.js.map +1 -0
  42. package/dist/public/node/hooks/postrun.js +12 -2
  43. package/dist/public/node/hooks/postrun.js.map +1 -1
  44. package/dist/public/node/http.js +27 -31
  45. package/dist/public/node/http.js.map +1 -1
  46. package/dist/public/node/metadata.d.ts +3 -0
  47. package/dist/public/node/metadata.js.map +1 -1
  48. package/dist/public/node/monorail.d.ts +2 -1
  49. package/dist/public/node/monorail.js +1 -1
  50. package/dist/public/node/monorail.js.map +1 -1
  51. package/dist/public/node/output.js +20 -11
  52. package/dist/public/node/output.js.map +1 -1
  53. package/dist/public/node/system.js +3 -0
  54. package/dist/public/node/system.js.map +1 -1
  55. package/dist/public/node/tcp.js +11 -3
  56. package/dist/public/node/tcp.js.map +1 -1
  57. package/dist/public/node/themes/api.js +76 -4
  58. package/dist/public/node/themes/api.js.map +1 -1
  59. package/dist/public/node/toml/toml-file.d.ts +3 -2
  60. package/dist/public/node/toml/toml-file.js +3 -2
  61. package/dist/public/node/toml/toml-file.js.map +1 -1
  62. package/dist/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +34 -29
@@ -0,0 +1,314 @@
1
+ import { platformAndArch } from '../../os.js';
2
+ import { MUTATIONS_BLOCKED_MESSAGE } from '../server.js';
3
+ import React from 'react';
4
+ import { renderToStaticMarkup } from 'react-dom/server';
5
+ import { AppProvider, Badge, Banner, BlockStack, Box, Grid, InlineStack, Link, Select, Text } from '@shopify/polaris';
6
+ import { AlertCircleIcon, DisabledIcon, LinkIcon } from '@shopify/polaris-icons';
7
+ const controlKey = platformAndArch().platform === 'darwin' ? 'MAC_COMMAND_KEY' : 'Ctrl';
8
+ const graphiqlIntroMessage = `
9
+ # Welcome to GraphiQL for the Shopify Admin API! If you've used
10
+ # GraphiQL before, you can jump to the next tab.
11
+ #
12
+ # GraphiQL is an in-browser tool for writing, validating, and
13
+ # testing GraphQL queries.
14
+ #
15
+ # Type queries into this side of the screen, and you will see intelligent
16
+ # typeaheads aware of the current GraphQL type schema and live syntax and
17
+ # validation errors highlighted within the text.
18
+ #
19
+ # GraphQL queries typically start with a "{" character. Lines that start
20
+ # with a # are ignored.
21
+ #
22
+ # Keyboard shortcuts:
23
+ #
24
+ # Prettify query: Shift-${controlKey}-P (or press the prettify button)
25
+ #
26
+ # Merge fragments: Shift-${controlKey}-M (or press the merge button)
27
+ #
28
+ # Run Query: ${controlKey}-Enter (or press the play button)
29
+ #
30
+ # Auto Complete: ${controlKey}-Space (or just start typing)
31
+ #
32
+ `;
33
+ export const defaultQuery = `query shopInfo {
34
+ shop {
35
+ name
36
+ url
37
+ myshopifyDomain
38
+ plan {
39
+ displayName
40
+ partnerDevelopment
41
+ shopifyPlus
42
+ }
43
+ }
44
+ }
45
+ `.replace(/\n/g, '\\n');
46
+ export function graphiqlTemplate({ apiVersion, apiVersions, appName, appUrl, key, storeFqdn, protectMutations = false, }) {
47
+ const hasAppContext = Boolean(appName && appUrl);
48
+ const unauthorizedLabel = hasAppContext ? 'App uninstalled' : 'Auth invalid';
49
+ return `<!DOCTYPE html>
50
+ <html lang="en">
51
+ <head>
52
+ <title>GraphiQL</title>
53
+ <link rel="shortcut icon" href="{{url}}/graphiql/favicon.ico" type="image/x-icon" />
54
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
55
+ <style>
56
+ body {
57
+ height: 100%;
58
+ margin: 0;
59
+ width: 100%;
60
+ overflow: hidden;
61
+ }
62
+ .Polaris-Page--fullWidth {
63
+ width: 100%;
64
+ }
65
+ #top-bar {
66
+ border-bottom: 1px solid var(--p-color-border);
67
+ }
68
+ #top-bar #top-error-bar {
69
+ display: none;
70
+ }
71
+ #top-error-bar .Polaris-FullscreenBar__BackAction {
72
+ /* hide default back button in FullscreenBar component */
73
+ display: none;
74
+ }
75
+ #top-error-bar button {
76
+ /* hide X to dismiss banner */
77
+ display: none;
78
+ }
79
+ #top-bar .top-bar-section {
80
+ display: inline-flex;
81
+ align-items: center;
82
+ gap: 8px;
83
+ }
84
+ #top-bar .Polaris-Grid-Cell:nth-child(2) {
85
+ justify-self: right;
86
+ }
87
+ #top-bar #scopes-note {
88
+ display: inline-flex;
89
+ align-items: center;
90
+ height: 100%;
91
+ }
92
+ #top-bar .status-badge-option {
93
+ gap: 8px;
94
+ display: none;
95
+ }
96
+ #top-bar #status-badge-running {
97
+ display: flex;
98
+ }
99
+ #graphiql {
100
+ height: 100vh;
101
+ display: flex;
102
+ flex-direction: column;
103
+ }
104
+ #graphiql-explorer {
105
+ flex-grow: 1;
106
+ overflow: auto;
107
+ }
108
+ #top-bar #outbound-links a {
109
+ line-height: 0;
110
+ }
111
+ #top-bar #outbound-links a:hover .Polaris-Text--root {
112
+ text-decoration: underline;
113
+ }
114
+ #top-bar #outbound-links a span.Polaris-Text--root {
115
+ max-width: max(12vw, 150px);
116
+ text-overflow: ellipsis;
117
+ overflow: hidden;
118
+ white-space: nowrap;
119
+ }
120
+ .with-shrunk-icon .Polaris-Icon {
121
+ height: 1rem;
122
+ width: 1rem;
123
+ margin: 0.125rem;
124
+ }
125
+ @media only screen and (max-width: 1550px) {
126
+ .top-bar-section-title {
127
+ display: none;
128
+ }
129
+ }
130
+ @media only screen and (max-width: 1150px) {
131
+ #top-bar #outbound-links a span.Polaris-Text--root {
132
+ max-width: max(12vw, 140px);
133
+ }
134
+ }
135
+ @media only screen and (max-width: 1080px) {
136
+ #top-bar .Polaris-Grid-Cell:nth-child(2) {
137
+ justify-self: left;
138
+ }
139
+ }
140
+ @media only screen and (max-width: 650px) {
141
+ #top-bar #outbound-links a span.Polaris-Text--root {
142
+ max-width: 17vw;
143
+ }
144
+ }
145
+ </style>
146
+
147
+ <script
148
+ src="https://cdn.jsdelivr.net/npm/react@17/umd/react.development.js"
149
+ integrity="sha512-Vf2xGDzpqUOEIKO+X2rgTLWPY+65++WPwCHkX2nFMu9IcstumPsf/uKKRd5prX3wOu8Q0GBylRpsDB26R6ExOg=="
150
+ crossorigin="anonymous"
151
+ ></script>
152
+ <script
153
+ src="https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.development.js"
154
+ integrity="sha512-Wr9OKCTtq1anK0hq5bY3X/AvDI5EflDSAh0mE9gma+4hl+kXdTJPKZ3TwLMBcrgUeoY0s3dq9JjhCQc7vddtFg=="
155
+ crossorigin="anonymous"
156
+ ></script>
157
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.css" />
158
+ </head>
159
+ <body>
160
+ <div id="graphiql">
161
+ ${renderToStaticMarkup(React.createElement(AppProvider, { i18n: {} },
162
+ React.createElement("div", { id: "top-bar" },
163
+ React.createElement(Box, { background: "bg-surface", padding: "400" },
164
+ React.createElement(BlockStack, { gap: "300" },
165
+ React.createElement(Grid, { columns: { xs: 3, sm: 3, md: 3 } },
166
+ React.createElement(Grid.Cell, { columnSpan: { xs: 3, sm: 3, md: 3, lg: 7, xl: 7 } },
167
+ React.createElement(InlineStack, { gap: "400" },
168
+ React.createElement("div", { id: "status-badge", className: "top-bar-section" },
169
+ React.createElement("div", { className: "status-badge-option", id: "status-badge-running" },
170
+ React.createElement("span", { className: "top-bar-section-title" }, "Status: "),
171
+ React.createElement(Badge, { tone: "success", progress: "complete" }, "Running")),
172
+ React.createElement("div", { className: "status-badge-option with-shrunk-icon", id: "status-badge-unauthorized" },
173
+ React.createElement("span", { className: "top-bar-section-title" }, "Status: "),
174
+ React.createElement(Badge, { tone: "attention", icon: AlertCircleIcon }, unauthorizedLabel)),
175
+ React.createElement("div", { className: "status-badge-option with-shrunk-icon", id: "status-badge-disconnected" },
176
+ React.createElement("span", { className: "top-bar-section-title" }, "Status: "),
177
+ React.createElement(Badge, { tone: "critical", icon: DisabledIcon }, "Disconnected"))),
178
+ React.createElement("div", { id: "version-select", className: "top-bar-section" },
179
+ React.createElement("span", { className: "top-bar-section-title" }, "API version: "),
180
+ React.createElement(Select, { label: "API version", labelHidden: true, options: apiVersions, value: apiVersion, onChange: () => { } })),
181
+ linkPills({ storeFqdn, appName, appUrl }))),
182
+ React.createElement(Grid.Cell, { columnSpan: { xs: 3, sm: 3, md: 3, lg: 5, xl: 5 } },
183
+ React.createElement("div", { id: "scopes-note", className: "top-bar-section" },
184
+ React.createElement(Text, { as: "span", tone: "subdued" }, scopesNoteText({ hasAppContext, protectMutations }))))),
185
+ React.createElement("div", { id: "top-error-bar" },
186
+ React.createElement(Banner, { tone: "critical", onDismiss: () => { }, icon: DisabledIcon },
187
+ React.createElement("p", null,
188
+ "The server has been stopped. Restart ",
189
+ React.createElement("code", null, "dev"),
190
+ " from the CLI."))))))))}
191
+ <div id="graphiql-explorer">Loading...</div>
192
+ </div>
193
+ <script
194
+ src="https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.js"
195
+ type="application/javascript"
196
+ ></script>
197
+ <script>
198
+ const macCommandKey = String.fromCodePoint(8984)
199
+ const renderGraphiQL = function(apiVersion) {
200
+ ReactDOM.render(
201
+ React.createElement(GraphiQL, {
202
+ fetcher: GraphiQL.createFetcher({
203
+ url: '{{url}}/graphiql/graphql.json?key=${encodeURIComponent(key)}&api_version=' + apiVersion,
204
+ }),
205
+ defaultEditorToolsVisibility: true,
206
+ {% if query %}
207
+ query: {{query}},
208
+ {% endif %}
209
+ {% if variables %}
210
+ variables: {{variables}},
211
+ {% endif %}
212
+ defaultTabs: [
213
+ {query: "${graphiqlIntroMessage
214
+ .replace(/"/g, '\\"')
215
+ .replace(/\n/g, '\\n')}".replace(/MAC_COMMAND_KEY/g, macCommandKey)},
216
+ {%for query in defaultQueries%}
217
+ {query: "{%if query.preface %}{{query.preface}}\\n{% endif %}{{query.query}}", variables: "{{query.variables}}"},
218
+ {%endfor%}
219
+ ],
220
+ isHeadersEditorEnabled: true,
221
+ }),
222
+ document.getElementById('graphiql-explorer'),
223
+ )
224
+ }
225
+ renderGraphiQL('${apiVersion}')
226
+
227
+ // Update the version when the select changes
228
+ document.getElementById('version-select').addEventListener('change', function(event) {
229
+ document.querySelector('#version-select .Polaris-Select__SelectedOption').innerText = event.target.value
230
+ renderGraphiQL(event.target.value)
231
+ })
232
+
233
+ // Start out optimistic
234
+ let serverIsLive = true
235
+ let appIsInstalled = true
236
+
237
+ const updateBadge = function() {
238
+ const topErrorBar = document.querySelector('#graphiql #top-error-bar')
239
+ const statusDiv = document.querySelector('#graphiql #status-badge')
240
+ const allBadgeDivs = Array.from(statusDiv.querySelectorAll('.status-badge-option'))
241
+ let activeBadge = 'running'
242
+ if (!appIsInstalled) activeBadge = 'unauthorized'
243
+ if (!serverIsLive) activeBadge = 'disconnected'
244
+ allBadgeDivs.forEach(function(badge) {
245
+ if (badge.id == ('status-badge-' + activeBadge)) {
246
+ badge.style.display = 'flex'
247
+ } else {
248
+ badge.style.display = 'none'
249
+ }
250
+ })
251
+ topErrorBar.style.display = serverIsLive ? 'none' : 'block'
252
+ }
253
+ const statusInterval = setInterval(updateBadge, 1000)
254
+
255
+ // Warn when the server has been stopped
256
+ const displayErrorServerStoppedTimeouts = []
257
+ const pingInterval = setInterval(function() {
258
+ displayErrorServerStoppedTimeouts.push(setTimeout(function() { serverIsLive = false }, 3000))
259
+ fetch('{{url}}/graphiql/ping')
260
+ .then(function(response) {
261
+ if (response.status === 200) {
262
+ while (displayErrorServerStoppedTimeouts.length > 0) {
263
+ const timeout = displayErrorServerStoppedTimeouts.pop()
264
+ clearTimeout(timeout)
265
+ }
266
+ serverIsLive = true
267
+ } else {
268
+ serverIsLive = false
269
+ }
270
+ })
271
+ }, 2000)
272
+
273
+ // Verify the current store/app connection
274
+ setInterval(function() {
275
+ fetch('{{ url }}/graphiql/status?key=${encodeURIComponent(key)}')
276
+ .then(async function(response) {
277
+ const {status, storeFqdn, appName, appUrl} = await response.json()
278
+ appIsInstalled = status === 'OK'
279
+ if (storeFqdn) {
280
+ ${hasAppContext
281
+ ? `document.getElementById('outbound-links').innerHTML = \`${renderToStaticMarkup(React.createElement(AppProvider, { i18n: {} },
282
+ // eslint-disable-next-line no-template-curly-in-string
283
+ linkPills({ storeFqdn: '${storeFqdn}', appName: '${appName}', appUrl: '${appUrl}' })))}\``
284
+ : `document.getElementById('outbound-links').innerHTML = \`${renderToStaticMarkup(React.createElement(AppProvider, { i18n: {} },
285
+ // eslint-disable-next-line no-template-curly-in-string
286
+ linkPills({ storeFqdn: '${storeFqdn}' })))}\``}
287
+ }
288
+ })
289
+ }, 5000)
290
+ </script>
291
+ </body>
292
+ </html>
293
+ `;
294
+ }
295
+ function linkPills({ storeFqdn, appName, appUrl }) {
296
+ return (React.createElement("div", { id: "outbound-links", className: "top-bar-section with-shrunk-icon" },
297
+ React.createElement("span", { className: "top-bar-section-title" }, "Store: "),
298
+ React.createElement(Link, { url: `https://${storeFqdn}/admin`, target: "_blank" },
299
+ React.createElement(Badge, { tone: "info", icon: LinkIcon, children: storeFqdn })),
300
+ appName && appUrl ? (React.createElement(React.Fragment, null,
301
+ React.createElement("span", { className: "top-bar-section-title" }, "App: "),
302
+ React.createElement(Link, { url: appUrl, target: "_blank" },
303
+ React.createElement(Badge, { tone: "info", icon: LinkIcon, children: appName })))) : null));
304
+ }
305
+ function scopesNoteText({ hasAppContext, protectMutations, }) {
306
+ if (protectMutations) {
307
+ return MUTATIONS_BLOCKED_MESSAGE;
308
+ }
309
+ if (hasAppContext) {
310
+ return "GraphiQL runs on the same access scopes you've defined in the TOML file for your app.";
311
+ }
312
+ return 'GraphiQL runs with the access scopes granted to the stored app authentication for this store.';
313
+ }
314
+ //# sourceMappingURL=graphiql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphiql.js","sourceRoot":"","sources":["../../../../../src/public/node/graphiql/templates/graphiql.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAA;AAC3C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LOCKED_MESSAGE} from '../server.js'\nimport React from 'react'\nimport {renderToStaticMarkup} from 'react-dom/server'\nimport {AppProvider, Badge, Banner, BlockStack, Box, Grid, InlineStack, Link, Select, Text} from '@shopify/polaris'\nimport {AlertCircleIcon, DisabledIcon, LinkIcon} from '@shopify/polaris-icons'\n\nconst controlKey = platformAndArch().platform === 'darwin' ? 'MAC_COMMAND_KEY' : 'Ctrl'\n\nconst graphiqlIntroMessage = `\n# Welcome to GraphiQL for the Shopify Admin API! If you've used\n# GraphiQL before, you can jump to the next tab.\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a \"{\" character. Lines that start\n# with a # are ignored.\n#\n# Keyboard shortcuts:\n#\n# Prettify query: Shift-${controlKey}-P (or press the prettify button)\n#\n# Merge fragments: Shift-${controlKey}-M (or press the merge button)\n#\n# Run Query: ${controlKey}-Enter (or press the play button)\n#\n# Auto Complete: ${controlKey}-Space (or just start typing)\n#\n`\n\nexport const defaultQuery = `query shopInfo {\n shop {\n name\n url\n myshopifyDomain\n plan {\n displayName\n partnerDevelopment\n shopifyPlus\n }\n }\n}\n`.replace(/\\n/g, '\\\\n')\n\ninterface GraphiQLTemplateOptions {\n apiVersion: string\n apiVersions: string[]\n appName?: string\n appUrl?: string\n key: string\n storeFqdn: string\n protectMutations?: boolean\n}\n\nexport function graphiqlTemplate({\n apiVersion,\n apiVersions,\n appName,\n appUrl,\n key,\n storeFqdn,\n protectMutations = false,\n}: GraphiQLTemplateOptions): string {\n const hasAppContext = Boolean(appName && appUrl)\n const unauthorizedLabel = hasAppContext ? 'App uninstalled' : 'Auth invalid'\n return `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <title>GraphiQL</title>\n <link rel=\"shortcut icon\" href=\"{{url}}/graphiql/favicon.ico\" type=\"image/x-icon\" />\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css\" />\n <style>\n body {\n height: 100%;\n margin: 0;\n width: 100%;\n overflow: hidden;\n }\n .Polaris-Page--fullWidth {\n width: 100%;\n }\n #top-bar {\n border-bottom: 1px solid var(--p-color-border);\n }\n #top-bar #top-error-bar {\n display: none;\n }\n #top-error-bar .Polaris-FullscreenBar__BackAction {\n /* hide default back button in FullscreenBar component */\n display: none;\n }\n #top-error-bar button {\n /* hide X to dismiss banner */\n display: none;\n }\n #top-bar .top-bar-section {\n display: inline-flex;\n align-items: center;\n gap: 8px;\n }\n #top-bar .Polaris-Grid-Cell:nth-child(2) {\n justify-self: right;\n }\n #top-bar #scopes-note {\n display: inline-flex;\n align-items: center;\n height: 100%;\n }\n #top-bar .status-badge-option {\n gap: 8px;\n display: none;\n }\n #top-bar #status-badge-running {\n display: flex;\n }\n #graphiql {\n height: 100vh;\n display: flex;\n flex-direction: column;\n }\n #graphiql-explorer {\n flex-grow: 1;\n overflow: auto;\n }\n #top-bar #outbound-links a {\n line-height: 0;\n }\n #top-bar #outbound-links a:hover .Polaris-Text--root {\n text-decoration: underline;\n }\n #top-bar #outbound-links a span.Polaris-Text--root {\n max-width: max(12vw, 150px);\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n }\n .with-shrunk-icon .Polaris-Icon {\n height: 1rem;\n width: 1rem;\n margin: 0.125rem;\n }\n @media only screen and (max-width: 1550px) {\n .top-bar-section-title {\n display: none;\n }\n }\n @media only screen and (max-width: 1150px) {\n #top-bar #outbound-links a span.Polaris-Text--root {\n max-width: max(12vw, 140px);\n }\n }\n @media only screen and (max-width: 1080px) {\n #top-bar .Polaris-Grid-Cell:nth-child(2) {\n justify-self: left;\n }\n }\n @media only screen and (max-width: 650px) {\n #top-bar #outbound-links a span.Polaris-Text--root {\n max-width: 17vw;\n }\n }\n </style>\n\n <script\n src=\"https://cdn.jsdelivr.net/npm/react@17/umd/react.development.js\"\n integrity=\"sha512-Vf2xGDzpqUOEIKO+X2rgTLWPY+65++WPwCHkX2nFMu9IcstumPsf/uKKRd5prX3wOu8Q0GBylRpsDB26R6ExOg==\"\n crossorigin=\"anonymous\"\n ></script>\n <script\n src=\"https://cdn.jsdelivr.net/npm/react-dom@17/umd/react-dom.development.js\"\n integrity=\"sha512-Wr9OKCTtq1anK0hq5bY3X/AvDI5EflDSAh0mE9gma+4hl+kXdTJPKZ3TwLMBcrgUeoY0s3dq9JjhCQc7vddtFg==\"\n crossorigin=\"anonymous\"\n ></script>\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.css\" />\n </head>\n <body>\n <div id=\"graphiql\">\n ${renderToStaticMarkup(\n <AppProvider i18n={{}}>\n <div id=\"top-bar\">\n <Box background=\"bg-surface\" padding=\"400\">\n <BlockStack gap=\"300\">\n <Grid columns={{xs: 3, sm: 3, md: 3}}>\n <Grid.Cell columnSpan={{xs: 3, sm: 3, md: 3, lg: 7, xl: 7}}>\n <InlineStack gap=\"400\">\n <div id=\"status-badge\" className=\"top-bar-section\">\n <div className=\"status-badge-option\" id=\"status-badge-running\">\n <span className=\"top-bar-section-title\">Status: </span>\n <Badge tone=\"success\" progress=\"complete\">\n Running\n </Badge>\n </div>\n <div className=\"status-badge-option with-shrunk-icon\" id=\"status-badge-unauthorized\">\n <span className=\"top-bar-section-title\">Status: </span>\n <Badge tone=\"attention\" icon={AlertCircleIcon}>\n {unauthorizedLabel}\n </Badge>\n </div>\n <div className=\"status-badge-option with-shrunk-icon\" id=\"status-badge-disconnected\">\n <span className=\"top-bar-section-title\">Status: </span>\n <Badge tone=\"critical\" icon={DisabledIcon}>\n Disconnected\n </Badge>\n </div>\n </div>\n <div id=\"version-select\" className=\"top-bar-section\">\n <span className=\"top-bar-section-title\">API version: </span>\n <Select\n label=\"API version\"\n labelHidden\n options={apiVersions}\n value={apiVersion}\n onChange={() => {}}\n />\n </div>\n {linkPills({storeFqdn, appName, appUrl})}\n </InlineStack>\n </Grid.Cell>\n <Grid.Cell columnSpan={{xs: 3, sm: 3, md: 3, lg: 5, xl: 5}}>\n <div id=\"scopes-note\" className=\"top-bar-section\">\n <Text as=\"span\" tone=\"subdued\">\n {scopesNoteText({hasAppContext, protectMutations})}\n </Text>\n </div>\n </Grid.Cell>\n </Grid>\n <div id=\"top-error-bar\">\n <Banner tone=\"critical\" onDismiss={() => {}} icon={DisabledIcon}>\n <p>\n The server has been stopped. Restart <code>dev</code> from the CLI.\n </p>\n </Banner>\n </div>\n </BlockStack>\n </Box>\n </div>\n </AppProvider>,\n )}\n <div id=\"graphiql-explorer\">Loading...</div>\n </div>\n <script\n src=\"https://cdn.jsdelivr.net/npm/graphiql@3.0.4/graphiql.min.js\"\n type=\"application/javascript\"\n ></script>\n <script>\n const macCommandKey = String.fromCodePoint(8984)\n const renderGraphiQL = function(apiVersion) {\n ReactDOM.render(\n React.createElement(GraphiQL, {\n fetcher: GraphiQL.createFetcher({\n url: '{{url}}/graphiql/graphql.json?key=${encodeURIComponent(key)}&api_version=' + apiVersion,\n }),\n defaultEditorToolsVisibility: true,\n {% if query %}\n query: {{query}},\n {% endif %}\n {% if variables %}\n variables: {{variables}},\n {% endif %}\n defaultTabs: [\n {query: \"${graphiqlIntroMessage\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, '\\\\n')}\".replace(/MAC_COMMAND_KEY/g, macCommandKey)},\n {%for query in defaultQueries%}\n {query: \"{%if query.preface %}{{query.preface}}\\\\n{% endif %}{{query.query}}\", variables: \"{{query.variables}}\"},\n {%endfor%}\n ],\n isHeadersEditorEnabled: true,\n }),\n document.getElementById('graphiql-explorer'),\n )\n }\n renderGraphiQL('${apiVersion}')\n\n // Update the version when the select changes\n document.getElementById('version-select').addEventListener('change', function(event) {\n document.querySelector('#version-select .Polaris-Select__SelectedOption').innerText = event.target.value\n renderGraphiQL(event.target.value)\n })\n\n // Start out optimistic\n let serverIsLive = true\n let appIsInstalled = true\n\n const updateBadge = function() {\n const topErrorBar = document.querySelector('#graphiql #top-error-bar')\n const statusDiv = document.querySelector('#graphiql #status-badge')\n const allBadgeDivs = Array.from(statusDiv.querySelectorAll('.status-badge-option'))\n let activeBadge = 'running'\n if (!appIsInstalled) activeBadge = 'unauthorized'\n if (!serverIsLive) activeBadge = 'disconnected'\n allBadgeDivs.forEach(function(badge) {\n if (badge.id == ('status-badge-' + activeBadge)) {\n badge.style.display = 'flex'\n } else {\n badge.style.display = 'none'\n }\n })\n topErrorBar.style.display = serverIsLive ? 'none' : 'block'\n }\n const statusInterval = setInterval(updateBadge, 1000)\n\n // Warn when the server has been stopped\n const displayErrorServerStoppedTimeouts = []\n const pingInterval = setInterval(function() {\n displayErrorServerStoppedTimeouts.push(setTimeout(function() { serverIsLive = false }, 3000))\n fetch('{{url}}/graphiql/ping')\n .then(function(response) {\n if (response.status === 200) {\n while (displayErrorServerStoppedTimeouts.length > 0) {\n const timeout = displayErrorServerStoppedTimeouts.pop()\n clearTimeout(timeout)\n }\n serverIsLive = true\n } else {\n serverIsLive = false\n }\n })\n }, 2000)\n\n // Verify the current store/app connection\n setInterval(function() {\n fetch('{{ url }}/graphiql/status?key=${encodeURIComponent(key)}')\n .then(async function(response) {\n const {status, storeFqdn, appName, appUrl} = await response.json()\n appIsInstalled = status === 'OK'\n if (storeFqdn) {\n ${\n hasAppContext\n ? `document.getElementById('outbound-links').innerHTML = \\`${renderToStaticMarkup(\n <AppProvider i18n={{}}>\n {\n // eslint-disable-next-line no-template-curly-in-string\n linkPills({storeFqdn: '${storeFqdn}', appName: '${appName}', appUrl: '${appUrl}'})\n }\n </AppProvider>,\n )}\\``\n : `document.getElementById('outbound-links').innerHTML = \\`${renderToStaticMarkup(\n <AppProvider i18n={{}}>\n {\n // eslint-disable-next-line no-template-curly-in-string\n linkPills({storeFqdn: '${storeFqdn}'})\n }\n </AppProvider>,\n )}\\``\n }\n }\n })\n }, 5000)\n </script>\n </body>\n</html>\n`\n}\n\ninterface LinkPillOptions {\n storeFqdn: string\n appName?: string\n appUrl?: string\n}\n\nfunction linkPills({storeFqdn, appName, appUrl}: LinkPillOptions) {\n return (\n <div id=\"outbound-links\" className=\"top-bar-section with-shrunk-icon\">\n <span className=\"top-bar-section-title\">Store: </span>\n <Link url={`https://${storeFqdn}/admin`} target=\"_blank\">\n <Badge tone=\"info\" icon={LinkIcon} children={storeFqdn} />\n </Link>\n {appName && appUrl ? (\n <>\n <span className=\"top-bar-section-title\">App: </span>\n <Link url={appUrl} target=\"_blank\">\n <Badge tone=\"info\" icon={LinkIcon} children={appName} />\n </Link>\n </>\n ) : null}\n </div>\n )\n}\n\nfunction scopesNoteText({\n hasAppContext,\n protectMutations,\n}: {\n hasAppContext: boolean\n protectMutations: boolean\n}): string {\n if (protectMutations) {\n return MUTATIONS_BLOCKED_MESSAGE\n }\n if (hasAppContext) {\n return \"GraphiQL runs on the same access scopes you've defined in the TOML file for your app.\"\n }\n return 'GraphiQL runs with the access scopes granted to the stored app authentication for this store.'\n}\n"]}
@@ -0,0 +1,5 @@
1
+ interface UnauthorizedTemplateOptions {
2
+ hasAppContext: boolean;
3
+ }
4
+ export declare function unauthorizedTemplate({ hasAppContext }: UnauthorizedTemplateOptions): string;
5
+ export {};
@@ -0,0 +1,111 @@
1
+ import React from 'react';
2
+ import { renderToStaticMarkup } from 'react-dom/server';
3
+ import { AppProvider, BlockStack, Button, Card, Link, Page, Text } from '@shopify/polaris';
4
+ const shopifySvg = (React.createElement("svg", { width: "102", height: "28", viewBox: "0 0 102 28", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
5
+ React.createElement("path", { d: "M21.4028 5.3032C21.3836 5.16414 21.2615 5.08697 21.16 5.07856C21.0594 5.07016 19.0881 5.04036 19.0881 5.04036C19.0881 5.04036 17.4395 3.44802 17.2767 3.28603C17.1138 3.12405 16.7957 3.17295 16.6721 3.20962C16.6705 3.21039 16.3625 3.30513 15.8439 3.46483C15.7571 3.18517 15.6296 2.84134 15.4475 2.49597C14.8606 1.38194 14.0009 0.792838 12.9623 0.79131C12.9608 0.79131 12.96 0.79131 12.9585 0.79131C12.8862 0.79131 12.8148 0.798187 12.7426 0.804299C12.7119 0.767624 12.6811 0.731712 12.6489 0.696564C12.1964 0.215194 11.6164 -0.0193788 10.9211 0.00125134C9.57979 0.0394553 8.24384 1.00296 7.16064 2.7145C6.39856 3.91869 5.81855 5.43157 5.65415 6.6029C4.11386 7.0774 3.0368 7.40901 3.01299 7.41665C2.23554 7.65962 2.21096 7.68331 2.10955 8.41224C2.03427 8.96314 0 24.6084 0 24.6084L17.0477 27.541L24.4365 25.7141C24.4365 25.7141 21.422 5.44226 21.4028 5.3032ZM14.9904 3.72767C14.5979 3.84839 14.1515 3.98593 13.6675 4.13492C13.6575 3.45948 13.5769 2.51966 13.2604 1.70744C14.2783 1.89923 14.7792 3.04458 14.9904 3.72767ZM12.7756 4.40999C11.8822 4.68506 10.9073 4.98534 9.92933 5.28639C10.2044 4.23884 10.726 3.19587 11.3667 2.51202C11.6048 2.25758 11.9382 1.97411 12.3331 1.81212C12.7042 2.58231 12.7848 3.67266 12.7756 4.40999ZM10.948 0.889112C11.263 0.882236 11.528 0.951003 11.7546 1.09923C11.392 1.28643 11.0417 1.55539 10.7129 1.9061C9.86096 2.81536 9.20797 4.22661 8.94754 5.5882C8.13552 5.83806 7.34118 6.08333 6.60983 6.30797C7.07153 4.16472 8.87763 0.94871 10.948 0.889112Z", fill: "#95BF47" }),
6
+ React.createElement("path", { d: "M21.1611 5.07934C21.0605 5.07093 19.0892 5.04114 19.0892 5.04114C19.0892 5.04114 17.4406 3.44879 17.2778 3.28681C17.2171 3.22645 17.1349 3.19512 17.0488 3.18213L17.0496 27.5402L24.4376 25.7141C24.4376 25.7141 21.4231 5.44304 21.4039 5.30398C21.3847 5.16492 21.2618 5.08774 21.1611 5.07934Z", fill: "#5E8E3E" }),
7
+ React.createElement("path", { d: "M12.9528 8.85773L12.0947 12.0508C12.0947 12.0508 11.1375 11.6176 10.0028 11.6886C8.33885 11.7933 8.32118 12.8371 8.33808 13.0991C8.42873 14.5272 12.2061 14.8389 12.4181 18.1841C12.5848 20.8156 11.0146 22.6158 8.75216 22.7579C6.03647 22.9283 4.5415 21.3352 4.5415 21.3352L5.11691 18.9008C5.11691 18.9008 6.62186 20.0301 7.82644 19.9545C8.61311 19.9048 8.89428 19.2683 8.86585 18.8183C8.74755 16.9554 5.67157 17.0655 5.4772 14.0046C5.31357 11.4289 7.01443 8.81876 10.7672 8.58343C12.213 8.49097 12.9528 8.85773 12.9528 8.85773Z", fill: "white" }),
8
+ React.createElement("path", { d: "M34.1664 15.544C33.3168 15.0855 32.8802 14.699 32.8802 14.1677C32.8802 13.4917 33.4867 13.0575 34.4338 13.0575C35.5364 13.0575 36.5208 13.516 36.5208 13.516L37.2973 11.15C37.2973 11.15 36.5833 10.5945 34.4818 10.5945C31.5574 10.5945 29.5306 12.2602 29.5306 14.602C29.5306 15.9297 30.4769 16.9437 31.7395 17.6675C32.759 18.2465 33.1232 18.6572 33.1232 19.2605C33.1232 19.888 32.6135 20.395 31.6671 20.395C30.2567 20.395 28.9248 19.6705 28.9248 19.6705L28.0996 22.0365C28.0996 22.0365 29.3302 22.8572 31.4004 22.8572C34.4102 22.8572 36.5704 21.3847 36.5704 18.7292C36.5696 17.306 35.4777 16.292 34.1664 15.544Z", fill: "black" }),
9
+ React.createElement("path", { d: "M46.1564 10.571C44.6759 10.571 43.5108 11.2712 42.6132 12.333L42.5645 12.3087L43.8507 5.62222H40.5011L37.249 22.6405H40.5986L41.7149 16.8232C42.1515 14.6262 43.2922 13.275 44.3604 13.275C45.1125 13.275 45.4043 13.782 45.4043 14.5065C45.4043 14.965 45.3555 15.5205 45.2588 15.979L43.997 22.6412H47.3466L48.6571 15.7615C48.8027 15.037 48.9002 14.1685 48.9002 13.5887C48.8987 11.7055 47.9036 10.571 46.1564 10.571Z", fill: "black" }),
10
+ React.createElement("path", { d: "M56.4709 10.571C52.4416 10.571 49.7725 14.192 49.7725 18.223C49.7725 20.8058 51.3741 22.8815 54.3839 22.8815C58.34 22.8815 61.0099 19.3575 61.0099 15.2295C61.0099 12.84 59.6018 10.571 56.4709 10.571ZM54.8205 20.3238C53.6798 20.3238 53.1944 19.3583 53.1944 18.151C53.1944 16.2443 54.1896 13.1303 56.0099 13.1303C57.1993 13.1303 57.5872 14.1443 57.5872 15.134C57.5872 17.1855 56.5928 20.3238 54.8205 20.3238Z", fill: "black" }),
11
+ React.createElement("path", { d: "M69.5778 10.571C67.3171 10.571 66.0339 12.5505 66.0339 12.5505H65.9859L66.1802 10.7643H63.2192C63.0737 11.9715 62.8062 13.8055 62.5396 15.1818L60.2095 27.3718H63.5591L64.481 22.4473H64.5542C64.5542 22.4473 65.2415 22.8815 66.5201 22.8815C70.4518 22.8815 73.0242 18.8748 73.0242 14.8187C73.0242 12.5748 72.029 10.571 69.5778 10.571ZM66.3738 20.3715C65.5044 20.3715 64.99 19.8888 64.99 19.8888L65.5485 16.7748C65.9371 14.699 67.029 13.3228 68.1941 13.3228C69.2136 13.3228 69.529 14.264 69.529 15.1575C69.529 17.306 68.2428 20.3715 66.3738 20.3715Z", fill: "black" }),
12
+ React.createElement("path", { d: "M77.8058 5.79121C76.7383 5.79121 75.8887 6.63622 75.8887 7.72221C75.8887 8.71197 76.5196 9.38797 77.4659 9.38797H77.5147C78.5586 9.38797 79.4562 8.68771 79.4806 7.45697C79.4806 6.49147 78.8253 5.79121 77.8058 5.79121Z", fill: "black" }),
13
+ React.createElement("path", { d: "M73.1216 22.6405H76.4704L78.7525 10.837H75.3785L73.1216 22.6405Z", fill: "black" }),
14
+ React.createElement("path", { d: "M87.2711 10.8127H84.9411L85.0622 10.2572C85.2565 9.12274 85.9362 8.10874 87.0525 8.10874C87.6483 8.10874 88.12 8.27774 88.12 8.27774L88.7753 5.67074C88.7753 5.67074 88.1931 5.38124 86.9549 5.38124C85.7655 5.38124 84.5768 5.71924 83.6785 6.49149C82.5378 7.45699 82.0037 8.85674 81.737 10.2572L81.6402 10.8127H80.0866L79.6012 13.3235H81.1549L79.3833 22.6413H82.7329L84.5045 13.3235H86.8102L87.2711 10.8127Z", fill: "black" }),
15
+ React.createElement("path", { d: "M95.3288 10.837C95.3288 10.837 93.2349 16.0836 92.2947 18.9475H92.2459C92.1819 18.0252 91.4207 10.837 91.4207 10.837H87.9012L89.9166 21.675C89.9653 21.916 89.9409 22.0615 89.8434 22.2305C89.4548 22.9785 88.7995 23.703 88.0231 24.2343C87.3922 24.6928 86.6881 24.9823 86.1304 25.1755L87.0523 28C87.732 27.8553 89.1394 27.2998 90.3288 26.1895C91.858 24.7655 93.2654 22.5685 94.7215 19.575L98.8231 10.8362H95.3288V10.837Z", fill: "black" })));
16
+ function polarisUnauthorizedContent({ hasAppContext }) {
17
+ return renderToStaticMarkup(React.createElement(AppProvider, { i18n: {} },
18
+ React.createElement(Page, { narrowWidth: true },
19
+ React.createElement("div", { className: "card-wrapper" },
20
+ React.createElement(Card, { padding: "600" },
21
+ React.createElement(BlockStack, { gap: "500" },
22
+ shopifySvg,
23
+ React.createElement("div", { id: "pre-install" }, hasAppContext ? React.createElement(AppUnauthorizedContent, null) : React.createElement(StoreUnauthorizedContent, null)),
24
+ React.createElement("div", { id: "post-install" },
25
+ React.createElement(BlockStack, { gap: "200" },
26
+ React.createElement(Text, { variant: "headingMd", as: "h2" }, "Loading GraphiQL..."),
27
+ React.createElement("p", null,
28
+ "If you're not redirected automatically, ",
29
+ React.createElement(Link, { url: "{{url}}/graphiql" }, "click here"),
30
+ ".")))))))));
31
+ }
32
+ function AppUnauthorizedContent() {
33
+ return (React.createElement(BlockStack, { gap: "200" },
34
+ React.createElement(Text, { variant: "headingMd", as: "h2" }, "Install your app to access GraphiQL"),
35
+ React.createElement("p", null, "The GraphiQL Explorer relies on your app being installed on your dev store to access its data."),
36
+ React.createElement("p", { id: "card-cta" },
37
+ React.createElement(Button, { id: "app-install-button" }, "Install your app"))));
38
+ }
39
+ function StoreUnauthorizedContent() {
40
+ return (React.createElement(BlockStack, { gap: "200" },
41
+ React.createElement(Text, { variant: "headingMd", as: "h2" }, "Reconnect store authentication to access GraphiQL"),
42
+ React.createElement("p", null, "The GraphiQL Explorer couldn't access this store with the stored authentication."),
43
+ React.createElement("p", null,
44
+ "Run ",
45
+ React.createElement("code", null, 'shopify store auth --store {{storeFqdn}}'),
46
+ ", then refresh this page.")));
47
+ }
48
+ export function unauthorizedTemplate({ hasAppContext }) {
49
+ return `
50
+ <!DOCTYPE html>
51
+ <html>
52
+ <head>
53
+ <title>GraphiQL Explorer - Authentication Required</title>
54
+ <meta charset="UTF-8">
55
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
56
+
57
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
58
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css" />
59
+ <style>
60
+ .vertical-center {
61
+ display: flex;
62
+ flex-direction: row;
63
+ align-items: center;
64
+ height: 100%;
65
+ }
66
+ .card-wrapper {
67
+ max-width: 480px;
68
+ margin-left: 20px;
69
+ margin-right: 20px;
70
+ }
71
+ #post-install {
72
+ display: none;
73
+ }
74
+ </style>
75
+
76
+ <script type="text/javascript">
77
+ let appInstalled = false
78
+ let newTab = null
79
+
80
+ setInterval(function() {
81
+ fetch('{{ url }}/graphiql/status')
82
+ .then(async function(response) {
83
+ const body = await response.json()
84
+ if (body.status === 'OK') {
85
+ if (newTab) newTab.close()
86
+ document.getElementById('pre-install').style.display = 'none'
87
+ document.getElementById('post-install').style.display = 'block'
88
+ window.location.href = window.location.href
89
+ }
90
+ })
91
+ }, 5000)
92
+
93
+ function openAppInstallTab() {
94
+ newTab = window.open('{{ previewUrl }}', '_blank')
95
+ }
96
+
97
+ document.addEventListener("DOMContentLoaded", function() {
98
+ const installButton = document.getElementById('app-install-button')
99
+ if (installButton) installButton.onclick = openAppInstallTab
100
+ })
101
+ </script>
102
+ </head>
103
+ <body>
104
+ <div class="vertical-center">
105
+ ${polarisUnauthorizedContent({ hasAppContext })}
106
+ </div>
107
+ </body>
108
+ </html>
109
+ `;
110
+ }
111
+ //# sourceMappingURL=unauthorized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../../../../src/public/node/graphiql/templates/unauthorized.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAExF,MAAM,UAAU,GAAG,CACjB,6BAAK,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,YAAY,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAC,4BAA4B;IAC9F,8BACE,CAAC,EAAC,y8CAAy8C,EAC38C,IAAI,EAAC,SAAS,GACd;IACF,8BACE,CAAC,EAAC,mSAAmS,EACrS,IAAI,EAAC,SAAS,GACd;IACF,8BACE,CAAC,EAAC,+gBAA+gB,EACjhB,IAAI,EAAC,OAAO,GACZ;IACF,8BACE,CAAC,EAAC,kmBAAkmB,EACpmB,IAAI,EAAC,OAAO,GACZ;IACF,8BACE,CAAC,EAAC,6ZAA6Z,EAC/Z,IAAI,EAAC,OAAO,GACZ;IACF,8BACE,CAAC,EAAC,wZAAwZ,EAC1Z,IAAI,EAAC,OAAO,GACZ;IACF,8BACE,CAAC,EAAC,miBAAmiB,EACriB,IAAI,EAAC,OAAO,GACZ;IACF,8BACE,CAAC,EAAC,2NAA2N,EAC7N,IAAI,EAAC,OAAO,GACZ;IACF,8BAAM,CAAC,EAAC,kEAAkE,EAAC,IAAI,EAAC,OAAO,GAAG;IAC1F,8BACE,CAAC,EAAC,sZAAsZ,EACxZ,IAAI,EAAC,OAAO,GACZ;IACF,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;wCAC3D,CACO,CACd,CAAA;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,EAAC,aAAa,EAA8B;IAC/E,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDD,0BAA0B,CAAC,EAAC,aAAa,EAAC,CAAC;;;;CAIlD,CAAA;AACD,CAAC","sourcesContent":["import React from 'react'\nimport {renderToStaticMarkup} from 'react-dom/server'\nimport {AppProvider, BlockStack, Button, Card, Link, Page, Text} from '@shopify/polaris'\n\nconst shopifySvg = (\n <svg width=\"102\" height=\"28\" viewBox=\"0 0 102 28\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M21.4028 5.3032C21.3836 5.16414 21.2615 5.08697 21.16 5.07856C21.0594 5.07016 19.0881 5.04036 19.0881 5.04036C19.0881 5.04036 17.4395 3.44802 17.2767 3.28603C17.1138 3.12405 16.7957 3.17295 16.6721 3.20962C16.6705 3.21039 16.3625 3.30513 15.8439 3.46483C15.7571 3.18517 15.6296 2.84134 15.4475 2.49597C14.8606 1.38194 14.0009 0.792838 12.9623 0.79131C12.9608 0.79131 12.96 0.79131 12.9585 0.79131C12.8862 0.79131 12.8148 0.798187 12.7426 0.804299C12.7119 0.767624 12.6811 0.731712 12.6489 0.696564C12.1964 0.215194 11.6164 -0.0193788 10.9211 0.00125134C9.57979 0.0394553 8.24384 1.00296 7.16064 2.7145C6.39856 3.91869 5.81855 5.43157 5.65415 6.6029C4.11386 7.0774 3.0368 7.40901 3.01299 7.41665C2.23554 7.65962 2.21096 7.68331 2.10955 8.41224C2.03427 8.96314 0 24.6084 0 24.6084L17.0477 27.541L24.4365 25.7141C24.4365 25.7141 21.422 5.44226 21.4028 5.3032ZM14.9904 3.72767C14.5979 3.84839 14.1515 3.98593 13.6675 4.13492C13.6575 3.45948 13.5769 2.51966 13.2604 1.70744C14.2783 1.89923 14.7792 3.04458 14.9904 3.72767ZM12.7756 4.40999C11.8822 4.68506 10.9073 4.98534 9.92933 5.28639C10.2044 4.23884 10.726 3.19587 11.3667 2.51202C11.6048 2.25758 11.9382 1.97411 12.3331 1.81212C12.7042 2.58231 12.7848 3.67266 12.7756 4.40999ZM10.948 0.889112C11.263 0.882236 11.528 0.951003 11.7546 1.09923C11.392 1.28643 11.0417 1.55539 10.7129 1.9061C9.86096 2.81536 9.20797 4.22661 8.94754 5.5882C8.13552 5.83806 7.34118 6.08333 6.60983 6.30797C7.07153 4.16472 8.87763 0.94871 10.948 0.889112Z\"\n fill=\"#95BF47\"\n />\n <path\n d=\"M21.1611 5.07934C21.0605 5.07093 19.0892 5.04114 19.0892 5.04114C19.0892 5.04114 17.4406 3.44879 17.2778 3.28681C17.2171 3.22645 17.1349 3.19512 17.0488 3.18213L17.0496 27.5402L24.4376 25.7141C24.4376 25.7141 21.4231 5.44304 21.4039 5.30398C21.3847 5.16492 21.2618 5.08774 21.1611 5.07934Z\"\n fill=\"#5E8E3E\"\n />\n <path\n d=\"M12.9528 8.85773L12.0947 12.0508C12.0947 12.0508 11.1375 11.6176 10.0028 11.6886C8.33885 11.7933 8.32118 12.8371 8.33808 13.0991C8.42873 14.5272 12.2061 14.8389 12.4181 18.1841C12.5848 20.8156 11.0146 22.6158 8.75216 22.7579C6.03647 22.9283 4.5415 21.3352 4.5415 21.3352L5.11691 18.9008C5.11691 18.9008 6.62186 20.0301 7.82644 19.9545C8.61311 19.9048 8.89428 19.2683 8.86585 18.8183C8.74755 16.9554 5.67157 17.0655 5.4772 14.0046C5.31357 11.4289 7.01443 8.81876 10.7672 8.58343C12.213 8.49097 12.9528 8.85773 12.9528 8.85773Z\"\n fill=\"white\"\n />\n <path\n d=\"M34.1664 15.544C33.3168 15.0855 32.8802 14.699 32.8802 14.1677C32.8802 13.4917 33.4867 13.0575 34.4338 13.0575C35.5364 13.0575 36.5208 13.516 36.5208 13.516L37.2973 11.15C37.2973 11.15 36.5833 10.5945 34.4818 10.5945C31.5574 10.5945 29.5306 12.2602 29.5306 14.602C29.5306 15.9297 30.4769 16.9437 31.7395 17.6675C32.759 18.2465 33.1232 18.6572 33.1232 19.2605C33.1232 19.888 32.6135 20.395 31.6671 20.395C30.2567 20.395 28.9248 19.6705 28.9248 19.6705L28.0996 22.0365C28.0996 22.0365 29.3302 22.8572 31.4004 22.8572C34.4102 22.8572 36.5704 21.3847 36.5704 18.7292C36.5696 17.306 35.4777 16.292 34.1664 15.544Z\"\n fill=\"black\"\n />\n <path\n d=\"M46.1564 10.571C44.6759 10.571 43.5108 11.2712 42.6132 12.333L42.5645 12.3087L43.8507 5.62222H40.5011L37.249 22.6405H40.5986L41.7149 16.8232C42.1515 14.6262 43.2922 13.275 44.3604 13.275C45.1125 13.275 45.4043 13.782 45.4043 14.5065C45.4043 14.965 45.3555 15.5205 45.2588 15.979L43.997 22.6412H47.3466L48.6571 15.7615C48.8027 15.037 48.9002 14.1685 48.9002 13.5887C48.8987 11.7055 47.9036 10.571 46.1564 10.571Z\"\n fill=\"black\"\n />\n <path\n d=\"M56.4709 10.571C52.4416 10.571 49.7725 14.192 49.7725 18.223C49.7725 20.8058 51.3741 22.8815 54.3839 22.8815C58.34 22.8815 61.0099 19.3575 61.0099 15.2295C61.0099 12.84 59.6018 10.571 56.4709 10.571ZM54.8205 20.3238C53.6798 20.3238 53.1944 19.3583 53.1944 18.151C53.1944 16.2443 54.1896 13.1303 56.0099 13.1303C57.1993 13.1303 57.5872 14.1443 57.5872 15.134C57.5872 17.1855 56.5928 20.3238 54.8205 20.3238Z\"\n fill=\"black\"\n />\n <path\n d=\"M69.5778 10.571C67.3171 10.571 66.0339 12.5505 66.0339 12.5505H65.9859L66.1802 10.7643H63.2192C63.0737 11.9715 62.8062 13.8055 62.5396 15.1818L60.2095 27.3718H63.5591L64.481 22.4473H64.5542C64.5542 22.4473 65.2415 22.8815 66.5201 22.8815C70.4518 22.8815 73.0242 18.8748 73.0242 14.8187C73.0242 12.5748 72.029 10.571 69.5778 10.571ZM66.3738 20.3715C65.5044 20.3715 64.99 19.8888 64.99 19.8888L65.5485 16.7748C65.9371 14.699 67.029 13.3228 68.1941 13.3228C69.2136 13.3228 69.529 14.264 69.529 15.1575C69.529 17.306 68.2428 20.3715 66.3738 20.3715Z\"\n fill=\"black\"\n />\n <path\n d=\"M77.8058 5.79121C76.7383 5.79121 75.8887 6.63622 75.8887 7.72221C75.8887 8.71197 76.5196 9.38797 77.4659 9.38797H77.5147C78.5586 9.38797 79.4562 8.68771 79.4806 7.45697C79.4806 6.49147 78.8253 5.79121 77.8058 5.79121Z\"\n fill=\"black\"\n />\n <path d=\"M73.1216 22.6405H76.4704L78.7525 10.837H75.3785L73.1216 22.6405Z\" fill=\"black\" />\n <path\n d=\"M87.2711 10.8127H84.9411L85.0622 10.2572C85.2565 9.12274 85.9362 8.10874 87.0525 8.10874C87.6483 8.10874 88.12 8.27774 88.12 8.27774L88.7753 5.67074C88.7753 5.67074 88.1931 5.38124 86.9549 5.38124C85.7655 5.38124 84.5768 5.71924 83.6785 6.49149C82.5378 7.45699 82.0037 8.85674 81.737 10.2572L81.6402 10.8127H80.0866L79.6012 13.3235H81.1549L79.3833 22.6413H82.7329L84.5045 13.3235H86.8102L87.2711 10.8127Z\"\n fill=\"black\"\n />\n <path\n d=\"M95.3288 10.837C95.3288 10.837 93.2349 16.0836 92.2947 18.9475H92.2459C92.1819 18.0252 91.4207 10.837 91.4207 10.837H87.9012L89.9166 21.675C89.9653 21.916 89.9409 22.0615 89.8434 22.2305C89.4548 22.9785 88.7995 23.703 88.0231 24.2343C87.3922 24.6928 86.6881 24.9823 86.1304 25.1755L87.0523 28C87.732 27.8553 89.1394 27.2998 90.3288 26.1895C91.858 24.7655 93.2654 22.5685 94.7215 19.575L98.8231 10.8362H95.3288V10.837Z\"\n fill=\"black\"\n />\n </svg>\n)\n\ninterface UnauthorizedTemplateOptions {\n hasAppContext: boolean\n}\n\nfunction polarisUnauthorizedContent({hasAppContext}: UnauthorizedTemplateOptions) {\n return renderToStaticMarkup(\n <AppProvider i18n={{}}>\n <Page narrowWidth>\n <div className=\"card-wrapper\">\n <Card padding=\"600\">\n <BlockStack gap=\"500\">\n {shopifySvg}\n <div id=\"pre-install\">{hasAppContext ? <AppUnauthorizedContent /> : <StoreUnauthorizedContent />}</div>\n\n <div id=\"post-install\">\n <BlockStack gap=\"200\">\n <Text variant=\"headingMd\" as=\"h2\">\n Loading GraphiQL...\n </Text>\n <p>\n If you're not redirected automatically, <Link url=\"{{url}}/graphiql\">click here</Link>.\n </p>\n </BlockStack>\n </div>\n </BlockStack>\n </Card>\n </div>\n </Page>\n </AppProvider>,\n )\n}\n\nfunction AppUnauthorizedContent() {\n return (\n <BlockStack gap=\"200\">\n <Text variant=\"headingMd\" as=\"h2\">\n Install your app to access GraphiQL\n </Text>\n <p>The GraphiQL Explorer relies on your app being installed on your dev store to access its data.</p>\n <p id=\"card-cta\">\n <Button id=\"app-install-button\">Install your app</Button>\n </p>\n </BlockStack>\n )\n}\n\nfunction StoreUnauthorizedContent() {\n return (\n <BlockStack gap=\"200\">\n <Text variant=\"headingMd\" as=\"h2\">\n Reconnect store authentication to access GraphiQL\n </Text>\n <p>The GraphiQL Explorer couldn't access this store with the stored authentication.</p>\n <p>\n Run <code>{'shopify store auth --store {{storeFqdn}}'}</code>, then refresh this page.\n </p>\n </BlockStack>\n )\n}\n\nexport function unauthorizedTemplate({hasAppContext}: UnauthorizedTemplateOptions): string {\n return `\n<!DOCTYPE html>\n<html>\n <head>\n <title>GraphiQL Explorer - Authentication Required</title>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/@shopify/polaris@12.10.0/build/esm/styles.css\" />\n <style>\n .vertical-center {\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 100%;\n }\n .card-wrapper {\n max-width: 480px;\n margin-left: 20px;\n margin-right: 20px;\n }\n #post-install {\n display: none;\n }\n </style>\n\n <script type=\"text/javascript\">\n let appInstalled = false\n let newTab = null\n\n setInterval(function() {\n fetch('{{ url }}/graphiql/status')\n .then(async function(response) {\n const body = await response.json()\n if (body.status === 'OK') {\n if (newTab) newTab.close()\n document.getElementById('pre-install').style.display = 'none'\n document.getElementById('post-install').style.display = 'block'\n window.location.href = window.location.href\n }\n })\n }, 5000)\n\n function openAppInstallTab() {\n newTab = window.open('{{ previewUrl }}', '_blank')\n }\n\n document.addEventListener(\"DOMContentLoaded\", function() {\n const installButton = document.getElementById('app-install-button')\n if (installButton) installButton.onclick = openAppInstallTab\n })\n </script>\n </head>\n <body>\n <div class=\"vertical-center\">\n ${polarisUnauthorizedContent({hasAppContext})}\n </div>\n </body>\n</html>\n`\n}\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Filters request headers to extract only custom headers that are safe to forward.
3
+ * Blocked headers and non-string values are excluded.
4
+ *
5
+ * @param headers - The raw incoming request headers.
6
+ * @returns The subset of headers that are safe to forward to the Admin API.
7
+ */
8
+ export declare function filterCustomHeaders(headers: {
9
+ [key: string]: string | string[] | undefined;
10
+ }): {
11
+ [key: string]: string;
12
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Headers that should NOT be forwarded from the GraphiQL client to the Admin API.
3
+ * These include:
4
+ * - Hop-by-hop headers (RFC 7230) that are connection-specific.
5
+ * - Browser-specific headers that are not relevant to API requests.
6
+ * - Headers the proxy sets itself (auth, content-type, etc.).
7
+ */
8
+ const BLOCKED_HEADERS = new Set([
9
+ // Hop-by-hop headers (RFC 7230 Section 6.1)
10
+ 'connection',
11
+ 'keep-alive',
12
+ 'proxy-authenticate',
13
+ 'proxy-authorization',
14
+ 'te',
15
+ 'trailer',
16
+ 'transfer-encoding',
17
+ 'upgrade',
18
+ // Headers the proxy controls
19
+ 'host',
20
+ 'content-length',
21
+ 'content-type',
22
+ 'accept',
23
+ 'user-agent',
24
+ 'authorization',
25
+ 'cookie',
26
+ 'x-shopify-access-token',
27
+ ]);
28
+ /**
29
+ * Filters request headers to extract only custom headers that are safe to forward.
30
+ * Blocked headers and non-string values are excluded.
31
+ *
32
+ * @param headers - The raw incoming request headers.
33
+ * @returns The subset of headers that are safe to forward to the Admin API.
34
+ */
35
+ export function filterCustomHeaders(headers) {
36
+ const customHeaders = {};
37
+ for (const [key, value] of Object.entries(headers)) {
38
+ if (!BLOCKED_HEADERS.has(key.toLowerCase()) && typeof value === 'string') {
39
+ customHeaders[key] = value;
40
+ }
41
+ }
42
+ return customHeaders;
43
+ }
44
+ //# sourceMappingURL=utilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utilities.js","sourceRoot":"","sources":["../../../../src/public/node/graphiql/utilities.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,4CAA4C;IAC5C,YAAY;IACZ,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,IAAI;IACJ,SAAS;IACT,mBAAmB;IACnB,SAAS;IAET,6BAA6B;IAC7B,MAAM;IACN,gBAAgB;IAChB,cAAc;IACd,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,QAAQ;IACR,wBAAwB;CACzB,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuD;IACzF,MAAM,aAAa,GAA4B,EAAE,CAAA;IACjD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACzE,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,aAAa,CAAA;AACtB,CAAC","sourcesContent":["/**\n * Headers that should NOT be forwarded from the GraphiQL client to the Admin API.\n * These include:\n * - Hop-by-hop headers (RFC 7230) that are connection-specific.\n * - Browser-specific headers that are not relevant to API requests.\n * - Headers the proxy sets itself (auth, content-type, etc.).\n */\nconst BLOCKED_HEADERS = new Set([\n // Hop-by-hop headers (RFC 7230 Section 6.1)\n 'connection',\n 'keep-alive',\n 'proxy-authenticate',\n 'proxy-authorization',\n 'te',\n 'trailer',\n 'transfer-encoding',\n 'upgrade',\n\n // Headers the proxy controls\n 'host',\n 'content-length',\n 'content-type',\n 'accept',\n 'user-agent',\n 'authorization',\n 'cookie',\n 'x-shopify-access-token',\n])\n\n/**\n * Filters request headers to extract only custom headers that are safe to forward.\n * Blocked headers and non-string values are excluded.\n *\n * @param headers - The raw incoming request headers.\n * @returns The subset of headers that are safe to forward to the Admin API.\n */\nexport function filterCustomHeaders(headers: {[key: string]: string | string[] | undefined}): {[key: string]: string} {\n const customHeaders: {[key: string]: string} = {}\n for (const [key, value] of Object.entries(headers)) {\n if (!BLOCKED_HEADERS.has(key.toLowerCase()) && typeof value === 'string') {\n customHeaders[key] = value\n }\n }\n return customHeaders\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Returns true if the GraphQL document contains a mutation operation that
3
+ * would actually be executed for the given (optional) operation name.
4
+ *
5
+ * - When `operationName` is provided, only the matching operation is checked.
6
+ * - When `operationName` is omitted and the document has a single operation,
7
+ * that operation is checked.
8
+ * - When the document has multiple operations and no operation name is given,
9
+ * any mutation in the document is treated as a mutation request (the GraphQL
10
+ * server would reject the ambiguous request anyway).
11
+ *
12
+ * Returns false for queries, subscriptions, fragment-only documents, and any
13
+ * input that fails to parse as GraphQL.
14
+ *
15
+ * @param query - The GraphQL document to inspect.
16
+ * @param operationName - Optional name of the operation to check; when set, only that operation is considered.
17
+ * @returns True if the relevant operation is a mutation; false otherwise.
18
+ */
19
+ export declare function containsMutation(query: string, operationName?: string): boolean;
@@ -0,0 +1,41 @@
1
+ import { parse } from 'graphql';
2
+ /**
3
+ * Returns true if the GraphQL document contains a mutation operation that
4
+ * would actually be executed for the given (optional) operation name.
5
+ *
6
+ * - When `operationName` is provided, only the matching operation is checked.
7
+ * - When `operationName` is omitted and the document has a single operation,
8
+ * that operation is checked.
9
+ * - When the document has multiple operations and no operation name is given,
10
+ * any mutation in the document is treated as a mutation request (the GraphQL
11
+ * server would reject the ambiguous request anyway).
12
+ *
13
+ * Returns false for queries, subscriptions, fragment-only documents, and any
14
+ * input that fails to parse as GraphQL.
15
+ *
16
+ * @param query - The GraphQL document to inspect.
17
+ * @param operationName - Optional name of the operation to check; when set, only that operation is considered.
18
+ * @returns True if the relevant operation is a mutation; false otherwise.
19
+ */
20
+ export function containsMutation(query, operationName) {
21
+ let document;
22
+ try {
23
+ document = parse(query);
24
+ // eslint-disable-next-line no-catch-all/no-catch-all -- swallowing parse errors is the entire purpose
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ const operations = document.definitions.filter((definition) => definition.kind === 'OperationDefinition');
30
+ if (operations.length === 0)
31
+ return false;
32
+ if (operationName) {
33
+ const target = operations.find((operation) => operation.name?.value === operationName);
34
+ return target?.operation === 'mutation';
35
+ }
36
+ if (operations.length === 1) {
37
+ return operations[0].operation === 'mutation';
38
+ }
39
+ return operations.some((operation) => operation.operation === 'mutation');
40
+ }
41
+ //# sourceMappingURL=graphql.js.map