@shopify/cli-kit 3.0.24 → 3.0.27
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 +32 -0
- package/assets/auth-error.html +2 -4
- package/assets/empty-url.html +2 -4
- package/assets/missing-code.html +2 -4
- package/assets/missing-state.html +2 -4
- package/assets/style.css +5 -8
- package/assets/success.html +1 -1
- package/dist/abort.d.ts +1 -0
- package/dist/abort.js +2 -0
- package/dist/abort.js.map +1 -0
- package/dist/analytics.d.ts +11 -0
- package/dist/analytics.js +96 -0
- package/dist/analytics.js.map +1 -0
- package/dist/api/admin.d.ts +3 -0
- package/dist/api/admin.js +80 -0
- package/dist/api/admin.js.map +1 -0
- package/dist/api/common.d.ts +11 -0
- package/dist/api/common.js +40 -0
- package/dist/api/common.js.map +1 -0
- package/dist/api/graphql/all_app_extension_registrations.d.ts +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js +14 -0
- package/dist/api/graphql/all_app_extension_registrations.js.map +1 -0
- package/dist/api/graphql/all_orgs.d.ts +12 -0
- package/dist/api/graphql/all_orgs.js +14 -0
- package/dist/api/graphql/all_orgs.js.map +1 -0
- package/dist/api/graphql/all_stores_by_org.d.ts +18 -0
- package/dist/api/graphql/all_stores_by_org.js +21 -0
- package/dist/api/graphql/all_stores_by_org.js.map +1 -0
- package/dist/api/graphql/convert_dev_to_test_store.d.ts +16 -0
- package/dist/api/graphql/convert_dev_to_test_store.js +13 -0
- package/dist/api/graphql/convert_dev_to_test_store.js.map +1 -0
- package/dist/api/graphql/create_app.d.ts +28 -0
- package/dist/api/graphql/create_app.js +32 -0
- package/dist/api/graphql/create_app.js.map +1 -0
- package/dist/api/graphql/create_deployment.d.ts +33 -0
- package/dist/api/graphql/create_deployment.js +25 -0
- package/dist/api/graphql/create_deployment.js.map +1 -0
- package/dist/api/graphql/extension_create.d.ts +30 -0
- package/dist/api/graphql/extension_create.js +26 -0
- package/dist/api/graphql/extension_create.js.map +1 -0
- package/dist/api/graphql/extension_specifications.d.ts +18 -0
- package/dist/api/graphql/extension_specifications.js +18 -0
- package/dist/api/graphql/extension_specifications.js.map +1 -0
- package/dist/api/graphql/find_app.d.ts +13 -0
- package/dist/api/graphql/find_app.js +16 -0
- package/dist/api/graphql/find_app.js.map +1 -0
- package/dist/api/graphql/find_org.d.ts +23 -0
- package/dist/api/graphql/find_org.js +26 -0
- package/dist/api/graphql/find_org.js.map +1 -0
- package/dist/api/graphql/find_org_basic.d.ts +11 -0
- package/dist/api/graphql/find_org_basic.js +14 -0
- package/dist/api/graphql/find_org_basic.js.map +1 -0
- package/dist/api/graphql/functions/app_function_set.d.ts +43 -0
- package/dist/api/graphql/functions/app_function_set.js +52 -0
- package/dist/api/graphql/functions/app_function_set.js.map +1 -0
- package/dist/api/graphql/functions/compile_module.d.ts +15 -0
- package/dist/api/graphql/functions/compile_module.js +13 -0
- package/dist/api/graphql/functions/compile_module.js.map +1 -0
- package/dist/api/graphql/functions/function_service_proxy.d.ts +4 -0
- package/dist/api/graphql/functions/function_service_proxy.js +7 -0
- package/dist/api/graphql/functions/function_service_proxy.js.map +1 -0
- package/dist/api/graphql/functions/get_app_functions.d.ts +1 -0
- package/dist/api/graphql/functions/get_app_functions.js +10 -0
- package/dist/api/graphql/functions/get_app_functions.js.map +1 -0
- package/dist/api/graphql/functions/module_compilation_status.d.ts +15 -0
- package/dist/api/graphql/functions/module_compilation_status.js +13 -0
- package/dist/api/graphql/functions/module_compilation_status.js.map +1 -0
- package/dist/api/graphql/functions/module_upload_url_generate.d.ts +18 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js +17 -0
- package/dist/api/graphql/functions/module_upload_url_generate.js.map +1 -0
- package/dist/api/graphql/generate_signed_upload_url.d.ts +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js +15 -0
- package/dist/api/graphql/generate_signed_upload_url.js.map +1 -0
- package/dist/api/graphql/get_variant_id.d.ts +17 -0
- package/dist/api/graphql/get_variant_id.js +20 -0
- package/dist/api/graphql/get_variant_id.js.map +1 -0
- package/dist/api/graphql/index.d.ts +21 -0
- package/dist/api/graphql/index.js +22 -0
- package/dist/api/graphql/index.js.map +1 -0
- package/dist/api/graphql/update_draft.d.ts +33 -0
- package/dist/api/graphql/update_draft.js +24 -0
- package/dist/api/graphql/update_draft.js.map +1 -0
- package/dist/api/graphql/update_urls.d.ts +14 -0
- package/dist/api/graphql/update_urls.js +12 -0
- package/dist/api/graphql/update_urls.js.map +1 -0
- package/dist/api/identity.d.ts +1 -0
- package/dist/api/identity.js +32 -0
- package/dist/api/identity.js.map +1 -0
- package/dist/api/partners.d.ts +25 -0
- package/dist/api/partners.js +100 -0
- package/dist/api/partners.js.map +1 -0
- package/dist/api.d.ts +5 -0
- package/dist/api.js +6 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -0
- package/dist/colors.d.ts +1 -0
- package/dist/colors.js +8 -0
- package/dist/colors.js.map +1 -0
- package/dist/constants.d.ts +43 -0
- package/dist/constants.js +63 -0
- package/dist/constants.js.map +1 -0
- package/dist/dependency.d.ts +128 -0
- package/dist/dependency.js +302 -0
- package/dist/dependency.js.map +1 -0
- package/dist/environment/fqdn.d.ts +23 -0
- package/dist/environment/fqdn.js +61 -0
- package/dist/environment/fqdn.js.map +1 -0
- package/dist/environment/local.d.ts +48 -0
- package/dist/environment/local.js +82 -0
- package/dist/environment/local.js.map +1 -0
- package/dist/environment/service.d.ts +17 -0
- package/dist/environment/service.js +41 -0
- package/dist/environment/service.js.map +1 -0
- package/dist/environment/spin.d.ts +47 -0
- package/dist/environment/spin.js +83 -0
- package/dist/environment/spin.js.map +1 -0
- package/dist/environment/utilities.d.ts +6 -0
- package/dist/environment/utilities.js +12 -0
- package/dist/environment/utilities.js.map +1 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +6 -0
- package/dist/environment.js.map +1 -0
- package/dist/error.d.ts +44 -0
- package/dist/error.js +91 -0
- package/dist/error.js.map +1 -0
- package/dist/file.d.ts +67 -0
- package/dist/file.js +165 -0
- package/dist/file.js.map +1 -0
- package/dist/git.d.ts +15 -0
- package/dist/git.js +48 -0
- package/dist/git.js.map +1 -0
- package/dist/github.d.ts +33 -0
- package/dist/github.js +56 -0
- package/dist/github.js.map +1 -0
- package/dist/haiku.d.ts +1 -0
- package/dist/haiku.js +8 -0
- package/dist/haiku.js.map +1 -0
- package/dist/http/fetch.d.ts +16 -0
- package/dist/http/fetch.js +18 -0
- package/dist/http/fetch.js.map +1 -0
- package/dist/http/formdata.d.ts +3 -0
- package/dist/http/formdata.js +6 -0
- package/dist/http/formdata.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +3 -0
- package/dist/http.js.map +1 -0
- package/dist/id.d.ts +6 -0
- package/dist/id.js +18 -0
- package/dist/id.js.map +1 -0
- package/dist/index.d.ts +34 -2115
- package/dist/index.js +35 -46
- package/dist/index.js.map +1 -1
- package/dist/network/api.d.ts +2 -0
- package/dist/network/api.js +2 -0
- package/dist/network/api.js.map +1 -0
- package/dist/network/service.d.ts +16 -0
- package/dist/network/service.js +12 -0
- package/dist/network/service.js.map +1 -0
- package/dist/node/archiver.d.ts +6 -0
- package/dist/node/archiver.js +24 -0
- package/dist/node/archiver.js.map +1 -0
- package/dist/node/checksum.d.ts +20 -0
- package/dist/node/checksum.js +32 -0
- package/dist/node/checksum.js.map +1 -0
- package/dist/node/cli.d.ts +18 -0
- package/dist/node/cli.js +91 -0
- package/dist/node/cli.js.map +1 -0
- package/dist/node/dot-env.d.ts +33 -0
- package/dist/node/dot-env.js +36 -0
- package/dist/node/dot-env.js.map +1 -0
- package/dist/node/ruby.d.ts +30 -0
- package/dist/node/ruby.js +197 -0
- package/dist/node/ruby.js.map +1 -0
- package/dist/npm.d.ts +27 -0
- package/dist/npm.js +20 -0
- package/dist/npm.js.map +1 -0
- package/dist/os.d.ts +10 -0
- package/dist/os.js +70 -0
- package/dist/os.js.map +1 -0
- package/dist/output.d.ts +142 -0
- package/dist/output.js +505 -0
- package/dist/output.js.map +1 -0
- package/dist/path.d.ts +22 -0
- package/dist/path.js +43 -0
- package/dist/path.js.map +1 -0
- package/dist/plugins.d.ts +9 -0
- package/dist/plugins.js +12 -0
- package/dist/plugins.js.map +1 -0
- package/dist/port.d.ts +5 -0
- package/dist/port.js +13 -0
- package/dist/port.js.map +1 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/secure-store.d.ts +19 -0
- package/dist/secure-store.js +63 -0
- package/dist/secure-store.js.map +1 -0
- package/dist/semver.d.ts +3 -0
- package/dist/semver.js +6 -0
- package/dist/semver.js.map +1 -0
- package/dist/session/authorize.d.ts +7 -0
- package/dist/session/authorize.js +40 -0
- package/dist/session/authorize.js.map +1 -0
- package/dist/session/exchange.d.ts +42 -0
- package/dist/session/exchange.js +144 -0
- package/dist/session/exchange.js.map +1 -0
- package/dist/session/identity.d.ts +3 -0
- package/dist/session/identity.js +58 -0
- package/dist/session/identity.js.map +1 -0
- package/dist/session/post-auth.d.ts +13 -0
- package/dist/session/post-auth.js +56 -0
- package/dist/session/post-auth.js.map +1 -0
- package/dist/session/redirect-listener.d.ts +34 -0
- package/dist/session/redirect-listener.js +97 -0
- package/dist/session/redirect-listener.js.map +1 -0
- package/dist/session/schema.d.ts +174 -0
- package/dist/session/schema.js +59 -0
- package/dist/session/schema.js.map +1 -0
- package/dist/session/scopes.d.ts +16 -0
- package/dist/session/scopes.js +53 -0
- package/dist/session/scopes.js.map +1 -0
- package/dist/session/store.d.ts +24 -0
- package/dist/session/store.js +88 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/token.d.ts +40 -0
- package/dist/session/token.js +22 -0
- package/dist/session/token.js.map +1 -0
- package/dist/session/validate.d.ts +17 -0
- package/dist/session/validate.js +75 -0
- package/dist/session/validate.js.map +1 -0
- package/dist/session.d.ts +88 -0
- package/dist/session.js +251 -0
- package/dist/session.js.map +1 -0
- package/dist/store/schema.d.ts +3 -0
- package/dist/store/schema.js +27 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store.d.ts +32 -0
- package/dist/store.js +102 -0
- package/dist/store.js.map +1 -0
- package/dist/string.d.ts +22 -0
- package/dist/string.js +38 -0
- package/dist/string.js.map +1 -0
- package/dist/system.d.ts +53 -0
- package/dist/system.js +109 -0
- package/dist/system.js.map +1 -0
- package/dist/template.d.ts +11 -0
- package/dist/template.js +50 -0
- package/dist/template.js.map +1 -0
- package/dist/testing/output.d.ts +9 -0
- package/dist/testing/output.js +15 -0
- package/dist/testing/output.js.map +1 -0
- package/dist/testing/store.d.ts +7 -0
- package/dist/testing/store.js +26 -0
- package/dist/testing/store.js.map +1 -0
- package/dist/toml.d.ts +3 -0
- package/dist/toml.js +8 -0
- package/dist/toml.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/autocomplete.d.ts +7 -0
- package/dist/ui/autocomplete.js +43 -0
- package/dist/ui/autocomplete.js.map +1 -0
- package/dist/ui/input.d.ts +7 -0
- package/dist/ui/input.js +48 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/select.d.ts +6 -0
- package/dist/ui/select.js +30 -0
- package/dist/ui/select.js.map +1 -0
- package/dist/ui.d.ts +36 -0
- package/dist/ui.js +124 -0
- package/dist/ui.js.map +1 -0
- package/dist/version.d.ts +19 -0
- package/dist/version.js +34 -0
- package/dist/version.js.map +1 -0
- package/dist/vscode.d.ts +8 -0
- package/dist/vscode.js +36 -0
- package/dist/vscode.js.map +1 -0
- package/dist/yaml.d.ts +2 -0
- package/dist/yaml.js +8 -0
- package/dist/yaml.js.map +1 -0
- package/package.json +32 -21
- package/dist/index-eb280c22.js +0 -175294
- package/dist/index-eb280c22.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/multipart-parser-84c10b92.js +0 -477
- package/dist/multipart-parser-84c10b92.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @shopify/cli-kit
|
|
2
2
|
|
|
3
|
+
## 3.0.27
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e2e8b4db: Fix identity token validation which is requiring a new login every time
|
|
8
|
+
|
|
9
|
+
## 3.0.26
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- dbcffdbb: Fix issue when exchanging an identity token fails
|
|
14
|
+
- 022a4e24: Internal: build cli-kit using tsc instead of rollup+esbuild
|
|
15
|
+
- e81e52b1: Report error events
|
|
16
|
+
- c16035f1: Fix post auth screen styling
|
|
17
|
+
- 61f595df: Fix an issue that will force the users to re-login when the token expires
|
|
18
|
+
- 87f7843f: Show validation errors when deploying UI extensions
|
|
19
|
+
- 8ff4e3d7: Fix runCreateCLI's detection of the executable index
|
|
20
|
+
- 168bb4c6: Add total time to analytics reports
|
|
21
|
+
- 0a9dbc63: Fix path outputs for the working directory
|
|
22
|
+
- 2d8e4458: Log Listr task titles to logfile
|
|
23
|
+
|
|
24
|
+
## 3.0.25
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- a6ea9c8d: Fix shopify upgrade
|
|
29
|
+
- 822d0fd3: Move archiver to @shopify/node/archiver and export it from the package.json
|
|
30
|
+
- bf8137c2: Save session to local storage when secure storage (keychain) is not available
|
|
31
|
+
- e650b499: Add project type to analytics reports
|
|
32
|
+
- 3360289d: Compile function module before deploying function to the registry
|
|
33
|
+
- 2a666db7: Fix the formatting of errors' next steps not respecting the line breaks
|
|
34
|
+
|
|
3
35
|
## 3.0.24
|
|
4
36
|
|
|
5
37
|
## 3.0.23
|
package/assets/auth-error.html
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
<body class="body-error">
|
|
13
13
|
<div class="app-error">
|
|
14
14
|
<div class="container">
|
|
15
|
-
<h1>Something went wrong!</
|
|
15
|
+
<h1>Something went wrong!</h1>
|
|
16
16
|
<p>There was an issue while trying to authenticate.</p>
|
|
17
17
|
<br />
|
|
18
18
|
<br />
|
|
19
|
-
<
|
|
20
|
-
<p>Return to your terminal and try running the previous command again.</p>
|
|
21
|
-
</div>
|
|
19
|
+
<p>Return to your terminal and try running the previous command again.</p>
|
|
22
20
|
</div>
|
|
23
21
|
</div>
|
|
24
22
|
</body>
|
package/assets/empty-url.html
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
<body class="body-error">
|
|
13
13
|
<div class="app-error">
|
|
14
14
|
<div class="container">
|
|
15
|
-
<h1>Something went wrong!</
|
|
15
|
+
<h1>Something went wrong!</h1>
|
|
16
16
|
<p>We received the authentication redirect but the URL is empty.</p>
|
|
17
17
|
<br />
|
|
18
18
|
<br />
|
|
19
|
-
<
|
|
20
|
-
<p>Return to your terminal and try running the previous command again.</p>
|
|
21
|
-
</div>
|
|
19
|
+
<p>Return to your terminal and try running the previous command again.</p>
|
|
22
20
|
</div>
|
|
23
21
|
</div>
|
|
24
22
|
</body>
|
package/assets/missing-code.html
CHANGED
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
<body class="body-error">
|
|
13
13
|
<div class="app-error">
|
|
14
14
|
<div class="container">
|
|
15
|
-
<h1>Something went wrong!</
|
|
15
|
+
<h1>Something went wrong!</h1>
|
|
16
16
|
<p>The authentication can't continue because the redirect doesn't include the code.</p>
|
|
17
17
|
<br />
|
|
18
18
|
<br />
|
|
19
|
-
<
|
|
20
|
-
<p>Return to your terminal and try running the previous command again.</p>
|
|
21
|
-
</div>
|
|
19
|
+
<p>Return to your terminal and try running the previous command again.</p>
|
|
22
20
|
</div>
|
|
23
21
|
</div>
|
|
24
22
|
</body>
|
|
@@ -12,13 +12,11 @@
|
|
|
12
12
|
<body class="body-error">
|
|
13
13
|
<div class="app-error">
|
|
14
14
|
<div class="container">
|
|
15
|
-
<h1>Something went wrong!</
|
|
15
|
+
<h1>Something went wrong!</h1>
|
|
16
16
|
<p>The authentication can't continue because the redirect doesn't include the state.</p>
|
|
17
17
|
<br />
|
|
18
18
|
<br />
|
|
19
|
-
<
|
|
20
|
-
<p>Return to your terminal and try running the previous command again.</p>
|
|
21
|
-
</div>
|
|
19
|
+
<p>Return to your terminal and try running the previous command again.</p>
|
|
22
20
|
</div>
|
|
23
21
|
</div>
|
|
24
22
|
</body>
|
package/assets/style.css
CHANGED
|
@@ -7,7 +7,7 @@ html {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
body {
|
|
10
|
-
font-size:
|
|
10
|
+
font-size: 26px;
|
|
11
11
|
line-height: normal;
|
|
12
12
|
margin: 0;
|
|
13
13
|
padding: 0;
|
|
@@ -19,6 +19,7 @@ button, input, optgroup, select, textarea {
|
|
|
19
19
|
|
|
20
20
|
h1 {
|
|
21
21
|
font-weight: 600;
|
|
22
|
+
font-size: 1em;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
p {
|
|
@@ -49,13 +50,9 @@ p {
|
|
|
49
50
|
|
|
50
51
|
.container {
|
|
51
52
|
display: flex;
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
justify-content: center;
|
|
54
55
|
width: 100%;
|
|
55
56
|
height: 100%;
|
|
56
|
-
padding-left:
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.subtext-container {
|
|
60
|
-
width: 35em;
|
|
57
|
+
padding-left: 7.5em;
|
|
61
58
|
}
|
package/assets/success.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<body class="body-success">
|
|
13
13
|
<div class="app-success">
|
|
14
14
|
<div class="container">
|
|
15
|
-
<h1>You've successfuly logged into the Shopify CLI!</
|
|
15
|
+
<h1>You've successfuly logged into the Shopify CLI!</h1>
|
|
16
16
|
<p>You can close this tab and return to your terminal.</p>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
package/dist/abort.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AbortController as Controller, AbortSignal as Signal } from 'abort-controller';
|
package/dist/abort.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.js","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,IAAI,UAAU,EAAE,WAAW,IAAI,MAAM,EAAC,MAAM,kBAAkB,CAAA","sourcesContent":["export {AbortController as Controller, AbortSignal as Signal} from 'abort-controller'\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface startOptions {
|
|
2
|
+
command: string;
|
|
3
|
+
args: string;
|
|
4
|
+
currentTime?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare const start: ({ command, args, currentTime }: startOptions) => void;
|
|
7
|
+
interface ReportEventOptions {
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const reportEvent: (options?: ReportEventOptions) => Promise<void>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
import * as environment from './environment.js';
|
|
3
|
+
import { fetch } from './http.js';
|
|
4
|
+
import { platformAndArch } from './os.js';
|
|
5
|
+
import { join, resolve } from './path.js';
|
|
6
|
+
import { version as rubyVersion } from './node/ruby.js';
|
|
7
|
+
import { debug, content, token } from './output.js';
|
|
8
|
+
import { getProjectType } from './dependency.js';
|
|
9
|
+
import constants from './constants.js';
|
|
10
|
+
import { cliKitStore } from './store.js';
|
|
11
|
+
const url = 'https://monorail-edge.shopifysvc.com/v1/produce';
|
|
12
|
+
let startTime;
|
|
13
|
+
let startCommand;
|
|
14
|
+
let startArgs;
|
|
15
|
+
export const start = ({ command, args, currentTime = new Date().getTime() }) => {
|
|
16
|
+
startCommand = command;
|
|
17
|
+
startArgs = args;
|
|
18
|
+
startTime = currentTime;
|
|
19
|
+
};
|
|
20
|
+
export const reportEvent = async (options = {}) => {
|
|
21
|
+
if (environment.local.analyticsDisabled())
|
|
22
|
+
return;
|
|
23
|
+
if (startCommand === undefined)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
const currentTime = new Date().getTime();
|
|
27
|
+
const payload = await buildPayload(options.errorMessage, currentTime);
|
|
28
|
+
const body = JSON.stringify(payload);
|
|
29
|
+
const headers = buildHeaders(currentTime);
|
|
30
|
+
const response = await fetch(url, { method: 'POST', body, headers });
|
|
31
|
+
if (response.status === 200) {
|
|
32
|
+
debug(content `Analytics event sent: ${token.json(payload)}`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
debug(`Failed to report usage analytics: ${response.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
// eslint-disable-next-line no-catch-all/no-catch-all
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
let message = 'Failed to report usage analytics';
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
message = message.concat(`: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
debug(message);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const totalTime = (currentTime) => {
|
|
48
|
+
if (startTime === undefined)
|
|
49
|
+
return undefined;
|
|
50
|
+
return currentTime - startTime;
|
|
51
|
+
};
|
|
52
|
+
const buildHeaders = (currentTime) => {
|
|
53
|
+
return {
|
|
54
|
+
'Content-Type': 'application/json; charset=utf-8',
|
|
55
|
+
'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),
|
|
56
|
+
'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const buildPayload = async (errorMessage, currentTime) => {
|
|
60
|
+
let directory = process.cwd();
|
|
61
|
+
const pathFlagIndex = startArgs.indexOf('--path');
|
|
62
|
+
if (pathFlagIndex >= 0) {
|
|
63
|
+
directory = resolve(startArgs[pathFlagIndex + 1]);
|
|
64
|
+
}
|
|
65
|
+
const appInfo = cliKitStore().getAppInfo(directory);
|
|
66
|
+
const { platform, arch } = platformAndArch();
|
|
67
|
+
const rawPartnerId = appInfo?.orgId;
|
|
68
|
+
let partnerIdAsInt;
|
|
69
|
+
if (rawPartnerId !== undefined) {
|
|
70
|
+
partnerIdAsInt = parseInt(rawPartnerId, 10);
|
|
71
|
+
if (isNaN(partnerIdAsInt)) {
|
|
72
|
+
partnerIdAsInt = undefined;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
schema_id: 'app_cli3_command/1.0',
|
|
77
|
+
payload: {
|
|
78
|
+
project_type: await getProjectType(join(directory, 'web')),
|
|
79
|
+
command: startCommand,
|
|
80
|
+
args: startArgs,
|
|
81
|
+
time_start: startTime,
|
|
82
|
+
time_end: currentTime,
|
|
83
|
+
total_time: totalTime(currentTime),
|
|
84
|
+
success: errorMessage === undefined,
|
|
85
|
+
error_message: errorMessage,
|
|
86
|
+
uname: `${platform} ${arch}`,
|
|
87
|
+
cli_version: await constants.versions.cliKit(),
|
|
88
|
+
ruby_version: (await rubyVersion()) || '',
|
|
89
|
+
node_version: process.version.replace('v', ''),
|
|
90
|
+
is_employee: await environment.local.isShopify(),
|
|
91
|
+
api_key: appInfo?.appId,
|
|
92
|
+
partner_id: partnerIdAsInt,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,WAAW,CAAA;AAC/B,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAA;AACvC,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAA;AACvC,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAC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YAAY,GAAG,OAAO,EAAE,KAAK,CAAA;IACnC,IAAI,cAAkC,CAAA;IACtC,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,cAAc,GAAG,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;QAC3C,IAAI,KAAK,CAAC,cAAc,CAAC,EAAE;YACzB,cAAc,GAAG,SAAS,CAAA;SAC3B;KACF;IAED,OAAO;QACL,SAAS,EAAE,sBAAsB;QACjC,OAAO,EAAE;YACP,YAAY,EAAE,MAAM,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1D,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,SAAS;YACrB,QAAQ,EAAE,WAAW;YACrB,UAAU,EAAE,SAAS,CAAC,WAAW,CAAC;YAClC,OAAO,EAAE,YAAY,KAAK,SAAS;YACnC,aAAa,EAAE,YAAY;YAC3B,KAAK,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE;YAC5B,WAAW,EAAE,MAAM,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YAC9C,YAAY,EAAE,CAAC,MAAM,WAAW,EAAE,CAAC,IAAI,EAAE;YACzC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9C,WAAW,EAAE,MAAM,WAAW,CAAC,KAAK,CAAC,SAAS,EAAE;YAChD,OAAO,EAAE,OAAO,EAAE,KAAK;YACvB,UAAU,EAAE,cAAc;SAC3B;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\nimport * as environment from './environment.js'\nimport {fetch} from './http.js'\nimport {platformAndArch} from './os.js'\nimport {join, resolve} from './path.js'\nimport {version as rubyVersion} from './node/ruby.js'\nimport {debug, content, token} from './output.js'\nimport {getProjectType} from './dependency.js'\nimport constants from './constants.js'\nimport {cliKitStore} from './store.js'\n\nconst url = 'https://monorail-edge.shopifysvc.com/v1/produce'\nlet startTime: number | undefined\nlet startCommand: string\nlet startArgs: string\n\ninterface startOptions {\n command: string\n args: string\n currentTime?: number\n}\n\nexport const start = ({command, args, currentTime = new Date().getTime()}: startOptions) => {\n startCommand = command\n startArgs = args\n startTime = currentTime\n}\n\ninterface ReportEventOptions {\n errorMessage?: string\n}\n\nexport const reportEvent = async (options: ReportEventOptions = {}) => {\n if (environment.local.analyticsDisabled()) return\n if (startCommand === undefined) return\n\n try {\n const currentTime = new Date().getTime()\n const payload = await buildPayload(options.errorMessage, currentTime)\n const body = JSON.stringify(payload)\n const headers = buildHeaders(currentTime)\n\n const response = await fetch(url, {method: 'POST', body, headers})\n if (response.status === 200) {\n debug(content`Analytics event sent: ${token.json(payload)}`)\n } else {\n debug(`Failed to report usage analytics: ${response.statusText}`)\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n let message = 'Failed to report usage analytics'\n if (error instanceof Error) {\n message = message.concat(`: ${error.message}`)\n }\n debug(message)\n }\n}\n\nconst totalTime = (currentTime: number): number | undefined => {\n if (startTime === undefined) return undefined\n return currentTime - startTime\n}\n\nconst buildHeaders = (currentTime: number) => {\n return {\n 'Content-Type': 'application/json; charset=utf-8',\n 'X-Monorail-Edge-Event-Created-At-Ms': currentTime.toString(),\n 'X-Monorail-Edge-Event-Sent-At-Ms': currentTime.toString(),\n }\n}\n\nconst buildPayload = async (errorMessage: string | undefined, currentTime: number) => {\n let directory = process.cwd()\n const pathFlagIndex = startArgs.indexOf('--path')\n if (pathFlagIndex >= 0) {\n directory = resolve(startArgs[pathFlagIndex + 1])\n }\n const appInfo = cliKitStore().getAppInfo(directory)\n const {platform, arch} = platformAndArch()\n\n const rawPartnerId = appInfo?.orgId\n let partnerIdAsInt: number | undefined\n if (rawPartnerId !== undefined) {\n partnerIdAsInt = parseInt(rawPartnerId, 10)\n if (isNaN(partnerIdAsInt)) {\n partnerIdAsInt = undefined\n }\n }\n\n return {\n schema_id: 'app_cli3_command/1.0',\n payload: {\n project_type: await getProjectType(join(directory, 'web')),\n command: startCommand,\n args: startArgs,\n time_start: startTime,\n time_end: currentTime,\n total_time: totalTime(currentTime),\n success: errorMessage === undefined,\n error_message: errorMessage,\n uname: `${platform} ${arch}`,\n cli_version: await constants.versions.cliKit(),\n ruby_version: (await rubyVersion()) || '',\n node_version: process.version.replace('v', ''),\n is_employee: await environment.local.isShopify(),\n api_key: appInfo?.appId,\n partner_id: partnerIdAsInt,\n },\n }\n}\n"]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { buildHeaders, sanitizedHeadersOutput } from './common.js';
|
|
2
|
+
import { debug, content, token as outputToken } from '../output.js';
|
|
3
|
+
import { Bug, Abort } from '../error.js';
|
|
4
|
+
import { request as graphqlRequest, gql, ClientError } from 'graphql-request';
|
|
5
|
+
const UnauthorizedAccessError = (store) => {
|
|
6
|
+
const adminLink = outputToken.link(`URL`, `https://${store}/admin`);
|
|
7
|
+
const storeName = store.replace('.myshopify.com', '');
|
|
8
|
+
return new Abort(content `Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`, content `• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.
|
|
9
|
+
• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.
|
|
10
|
+
`);
|
|
11
|
+
};
|
|
12
|
+
const UnknownError = () => {
|
|
13
|
+
return new Bug(`Unknown error connecting to your store`);
|
|
14
|
+
};
|
|
15
|
+
export async function request(query, session, variables) {
|
|
16
|
+
const version = await fetchApiVersion(session);
|
|
17
|
+
const url = adminUrl(session.storeFqdn, version);
|
|
18
|
+
const headers = await buildHeaders(session.token);
|
|
19
|
+
debug(`
|
|
20
|
+
Sending Admin GraphQL request:
|
|
21
|
+
${query}
|
|
22
|
+
|
|
23
|
+
With variables:
|
|
24
|
+
${variables ? JSON.stringify(variables, null, 2) : ''}
|
|
25
|
+
|
|
26
|
+
And headers:
|
|
27
|
+
${sanitizedHeadersOutput(headers)}
|
|
28
|
+
`);
|
|
29
|
+
try {
|
|
30
|
+
const response = await graphqlRequest(url, query, variables, headers);
|
|
31
|
+
return response;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof ClientError) {
|
|
35
|
+
const errorMessage = content `
|
|
36
|
+
The Admin GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:
|
|
37
|
+
|
|
38
|
+
${outputToken.json(error.response.errors)}
|
|
39
|
+
`;
|
|
40
|
+
const abortError = new Abort(errorMessage.value);
|
|
41
|
+
abortError.stack = error.stack;
|
|
42
|
+
throw abortError;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function fetchApiVersion(session) {
|
|
50
|
+
const url = adminUrl(session.storeFqdn, 'unstable');
|
|
51
|
+
const query = apiVersionQuery();
|
|
52
|
+
const headers = await buildHeaders(session.token);
|
|
53
|
+
debug(`
|
|
54
|
+
Sending Admin GraphQL request to URL ${url} with query:
|
|
55
|
+
${query}
|
|
56
|
+
`);
|
|
57
|
+
const data = await graphqlRequest(url, query, {}, headers).catch((err) => {
|
|
58
|
+
throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError();
|
|
59
|
+
});
|
|
60
|
+
return data.publicApiVersions
|
|
61
|
+
.filter((item) => item.supported)
|
|
62
|
+
.map((item) => item.handle)
|
|
63
|
+
.sort()
|
|
64
|
+
.reverse()[0];
|
|
65
|
+
}
|
|
66
|
+
function adminUrl(store, version) {
|
|
67
|
+
const realVersion = version || 'unstable';
|
|
68
|
+
return `https://${store}/admin/api/${realVersion}/graphql.json`;
|
|
69
|
+
}
|
|
70
|
+
function apiVersionQuery() {
|
|
71
|
+
return gql `
|
|
72
|
+
query {
|
|
73
|
+
publicApiVersions {
|
|
74
|
+
handle
|
|
75
|
+
supported
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+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AAG,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,CAAA;IACjG,CAAC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC,iBAAiB;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;SAChC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,IAAI,EAAE;SACN,OAAO,EAAE,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,OAA2B;IAC1D,MAAM,WAAW,GAAG,OAAO,IAAI,UAAU,CAAA;IACzC,OAAO,WAAW,KAAK,cAAc,WAAW,eAAe,CAAA;AACjE,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,GAAG,CAAA;;;;;;;GAOT,CAAA;AACH,CAAC","sourcesContent":["import {buildHeaders, sanitizedHeadersOutput} from './common.js'\nimport {AdminSession} from '../session.js'\nimport {debug, content, token as outputToken} from '../output.js'\nimport {Bug, Abort} from '../error.js'\nimport {request as graphqlRequest, gql, RequestDocument, Variables, ClientError} from 'graphql-request'\n\nconst UnauthorizedAccessError = (store: string) => {\n const adminLink = outputToken.link(`URL`, `https://${store}/admin`)\n const storeName = store.replace('.myshopify.com', '')\n return new Abort(\n content`Looks like you need access to this dev store (${outputToken.link(storeName, `https://${store}`)})`,\n content`• Log in to the store directly from this ${adminLink}. If you're the store owner, then that direct log in should solve your access issue.\n• If you're not the owner, create a dev store staff account for yourself. Then log in directly from the link above.\n `,\n )\n}\n\nconst UnknownError = () => {\n return new Bug(`Unknown error connecting to your store`)\n}\n\nexport async function request<T>(query: RequestDocument, session: AdminSession, variables?: Variables): Promise<T> {\n const version = await fetchApiVersion(session)\n const url = adminUrl(session.storeFqdn, version)\n const headers = await buildHeaders(session.token)\n debug(`\nSending Admin GraphQL request:\n${query}\n\nWith variables:\n${variables ? JSON.stringify(variables, null, 2) : ''}\n\nAnd headers:\n${sanitizedHeadersOutput(headers)}\n`)\n try {\n const response = await graphqlRequest<T>(url, query, variables, headers)\n return response\n } catch (error) {\n if (error instanceof ClientError) {\n const errorMessage = content`\nThe Admin GraphQL API responded unsuccessfully with the HTTP status ${`${error.response.status}`} and errors:\n\n${outputToken.json(error.response.errors)}\n `\n const abortError = new Abort(errorMessage.value)\n abortError.stack = error.stack\n throw abortError\n } else {\n throw error\n }\n }\n}\n\nasync function fetchApiVersion(session: AdminSession): Promise<string> {\n const url = adminUrl(session.storeFqdn, 'unstable')\n const query = apiVersionQuery()\n const headers = await buildHeaders(session.token)\n\n debug(`\nSending Admin GraphQL request to URL ${url} with query:\n${query}\n `)\n const data = await graphqlRequest<{\n publicApiVersions: {handle: string; supported: boolean}[]\n }>(url, query, {}, headers).catch((err) => {\n throw err.response.status === 403 ? UnauthorizedAccessError(session.storeFqdn) : UnknownError()\n })\n\n return data.publicApiVersions\n .filter((item) => item.supported)\n .map((item) => item.handle)\n .sort()\n .reverse()[0]\n}\n\nfunction adminUrl(store: string, version: string | undefined): string {\n const realVersion = version || 'unstable'\n return `https://${store}/admin/api/${realVersion}/graphql.json`\n}\n\nfunction apiVersionQuery(): string {\n return gql`\n query {\n publicApiVersions {\n handle\n supported\n }\n }\n `\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function buildHeaders(token: string): Promise<{
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}>;
|
|
4
|
+
/**
|
|
5
|
+
* Remvoes the sensitive data from the headers and outputs them as a string.
|
|
6
|
+
* @param headers {{[key: string]: string}} HTTP headers.
|
|
7
|
+
* @returns {string} A sanitized version of the headers as a string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function sanitizedHeadersOutput(headers: {
|
|
10
|
+
[key: string]: string;
|
|
11
|
+
}): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isShopify } from '../environment/local.js';
|
|
2
|
+
import constants from '../constants.js';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
export async function buildHeaders(token) {
|
|
5
|
+
const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`;
|
|
6
|
+
const isEmployee = await isShopify();
|
|
7
|
+
const headers = {
|
|
8
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
9
|
+
'User-Agent': userAgent,
|
|
10
|
+
// 'Sec-CH-UA': secCHUA, This header requires the Git sha.
|
|
11
|
+
'Sec-CH-UA-PLATFORM': process.platform,
|
|
12
|
+
'X-Request-Id': randomUUID(),
|
|
13
|
+
authorization: `Bearer ${token}`,
|
|
14
|
+
'X-Shopify-Access-Token': `Bearer ${token}`,
|
|
15
|
+
'Content-Type': 'application/json',
|
|
16
|
+
// ...(isEmployee && {'X-Shopify-Cli-Employee': '1'}),
|
|
17
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
18
|
+
};
|
|
19
|
+
return headers;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Remvoes the sensitive data from the headers and outputs them as a string.
|
|
23
|
+
* @param headers {{[key: string]: string}} HTTP headers.
|
|
24
|
+
* @returns {string} A sanitized version of the headers as a string.
|
|
25
|
+
*/
|
|
26
|
+
export function sanitizedHeadersOutput(headers) {
|
|
27
|
+
const sanitized = {};
|
|
28
|
+
const keywords = ['token', 'authorization'];
|
|
29
|
+
Object.keys(headers).forEach((header) => {
|
|
30
|
+
if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {
|
|
31
|
+
sanitized[header] = headers[header];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return Object.keys(sanitized)
|
|
35
|
+
.map((header) => {
|
|
36
|
+
return ` - ${header}: ${sanitized[header]}`;
|
|
37
|
+
})
|
|
38
|
+
.join('\n');
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=common.js.map
|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ACF,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SAC1B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,OAAO,MAAM,MAAM,KAAK,SAAS,CAAC,MAAM,CAAC,EAAE,CAAA;IAC7C,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC","sourcesContent":["import {isShopify} from '../environment/local.js'\nimport constants from '../constants.js'\nimport {randomUUID} from 'crypto'\n\nexport async function buildHeaders(token: string): Promise<{[key: string]: string}> {\n const userAgent = `Shopify CLI; v=${await constants.versions.cliKit()}`\n const isEmployee = await isShopify()\n\n const headers = {\n /* eslint-disable @typescript-eslint/naming-convention */\n 'User-Agent': userAgent,\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'X-Request-Id': randomUUID(),\n authorization: `Bearer ${token}`,\n 'X-Shopify-Access-Token': `Bearer ${token}`,\n 'Content-Type': 'application/json',\n // ...(isEmployee && {'X-Shopify-Cli-Employee': '1'}),\n /* eslint-enable @typescript-eslint/naming-convention */\n }\n\n return headers\n}\n\n/**\n * Remvoes the sensitive data from the headers and outputs them as a string.\n * @param headers {{[key: string]: string}} HTTP headers.\n * @returns {string} A sanitized version of the headers as a string.\n */\nexport function sanitizedHeadersOutput(headers: {[key: string]: string}): string {\n const sanitized: {[key: string]: string} = {}\n const keywords = ['token', 'authorization']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n sanitized[header] = headers[header]\n }\n })\n return Object.keys(sanitized)\n .map((header) => {\n return ` - ${header}: ${sanitized[header]}`\n })\n .join('\\n')\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const AllAppExtensionRegistrationsQuery: string;
|
|
2
|
+
export interface AllAppExtensionRegistrationsQueryVariables {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
export interface AllAppExtensionRegistrationsQuerySchema {
|
|
6
|
+
app: {
|
|
7
|
+
extensionRegistrations: {
|
|
8
|
+
id: string;
|
|
9
|
+
uuid: string;
|
|
10
|
+
title: string;
|
|
11
|
+
type: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { gql } from 'graphql-request';
|
|
2
|
+
export const AllAppExtensionRegistrationsQuery = gql `
|
|
3
|
+
query allAppExtensionRegistrations($apiKey: String!) {
|
|
4
|
+
app(apiKey: $apiKey) {
|
|
5
|
+
extensionRegistrations {
|
|
6
|
+
id
|
|
7
|
+
uuid
|
|
8
|
+
title
|
|
9
|
+
type
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
//# sourceMappingURL=all_app_extension_registrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all_app_extension_registrations.js","sourceRoot":"","sources":["../../../src/api/graphql/all_app_extension_registrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAA;;;;;;;;;;;CAWnD,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const AllAppExtensionRegistrationsQuery = gql`\n query allAppExtensionRegistrations($apiKey: String!) {\n app(apiKey: $apiKey) {\n extensionRegistrations {\n id\n uuid\n title\n type\n }\n }\n }\n`\n\nexport interface AllAppExtensionRegistrationsQueryVariables {\n apiKey: string\n}\n\nexport interface AllAppExtensionRegistrationsQuerySchema {\n app: {\n extensionRegistrations: {\n id: string\n uuid: string\n title: string\n type: string\n }[]\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AllOrganizationsQuerySchemaOrganization {
|
|
2
|
+
id: string;
|
|
3
|
+
businessName: string;
|
|
4
|
+
website: string;
|
|
5
|
+
appsNext: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface AllOrganizationsQuerySchema {
|
|
8
|
+
organizations: {
|
|
9
|
+
nodes: AllOrganizationsQuerySchemaOrganization[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const AllOrganizationsQuery: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all_orgs.js","sourceRoot":"","sources":["../../../src/api/graphql/all_orgs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAenC,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;;;;;;;;;CAWvC,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport interface AllOrganizationsQuerySchemaOrganization {\n id: string\n businessName: string\n website: string\n appsNext: boolean\n}\n\nexport interface AllOrganizationsQuerySchema {\n organizations: {\n nodes: AllOrganizationsQuerySchemaOrganization[]\n }\n}\n\nexport const AllOrganizationsQuery = gql`\n {\n organizations(first: 200) {\n nodes {\n id\n businessName\n website\n appsNext\n }\n }\n }\n`\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const AllStoresByOrganizationQuery: string;
|
|
2
|
+
export interface AllStoresByOrganizationSchema {
|
|
3
|
+
organizations: {
|
|
4
|
+
nodes: {
|
|
5
|
+
id: string;
|
|
6
|
+
stores: {
|
|
7
|
+
nodes: {
|
|
8
|
+
shopId: string;
|
|
9
|
+
link: string;
|
|
10
|
+
shopDomain: string;
|
|
11
|
+
shopName: string;
|
|
12
|
+
transferDisabled: boolean;
|
|
13
|
+
convertableToPartnerTest: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gql } from 'graphql-request';
|
|
2
|
+
export const AllStoresByOrganizationQuery = gql `
|
|
3
|
+
query FindOrganization($id: ID!) {
|
|
4
|
+
organizations(id: $id, first: 1) {
|
|
5
|
+
nodes {
|
|
6
|
+
id
|
|
7
|
+
stores(first: 500, archived: false) {
|
|
8
|
+
nodes {
|
|
9
|
+
shopId
|
|
10
|
+
link
|
|
11
|
+
shopDomain
|
|
12
|
+
shopName
|
|
13
|
+
transferDisabled
|
|
14
|
+
convertableToPartnerTest
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
//# sourceMappingURL=all_stores_by_org.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all_stores_by_org.js","sourceRoot":"","sources":["../../../src/api/graphql/all_stores_by_org.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkB9C,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const AllStoresByOrganizationQuery = gql`\n query FindOrganization($id: ID!) {\n organizations(id: $id, first: 1) {\n nodes {\n id\n stores(first: 500, archived: false) {\n nodes {\n shopId\n link\n shopDomain\n shopName\n transferDisabled\n convertableToPartnerTest\n }\n }\n }\n }\n }\n`\n\nexport interface AllStoresByOrganizationSchema {\n organizations: {\n nodes: {\n id: string\n stores: {\n nodes: {\n shopId: string\n link: string\n shopDomain: string\n shopName: string\n transferDisabled: boolean\n convertableToPartnerTest: boolean\n }[]\n }\n }[]\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const ConvertDevToTestStoreQuery: string;
|
|
2
|
+
export interface ConvertDevToTestStoreVariables {
|
|
3
|
+
input: {
|
|
4
|
+
organizationID: number;
|
|
5
|
+
shopId: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export interface ConvertDevToTestStoreSchema {
|
|
9
|
+
convertDevToTestStore: {
|
|
10
|
+
convertedToTestStore: boolean;
|
|
11
|
+
userErrors: {
|
|
12
|
+
field: string[];
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { gql } from 'graphql-request';
|
|
2
|
+
export const ConvertDevToTestStoreQuery = gql `
|
|
3
|
+
mutation convertDevToTestStore($input: ConvertDevToTestStoreInput!) {
|
|
4
|
+
convertDevToTestStore(input: $input) {
|
|
5
|
+
convertedToTestStore
|
|
6
|
+
userErrors {
|
|
7
|
+
message
|
|
8
|
+
field
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
//# sourceMappingURL=convert_dev_to_test_store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convert_dev_to_test_store.js","sourceRoot":"","sources":["../../../src/api/graphql/convert_dev_to_test_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,iBAAiB,CAAA;AAEnC,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAA;;;;;;;;;;CAU5C,CAAA","sourcesContent":["import {gql} from 'graphql-request'\n\nexport const ConvertDevToTestStoreQuery = gql`\n mutation convertDevToTestStore($input: ConvertDevToTestStoreInput!) {\n convertDevToTestStore(input: $input) {\n convertedToTestStore\n userErrors {\n message\n field\n }\n }\n }\n`\n\nexport interface ConvertDevToTestStoreVariables {\n input: {\n organizationID: number\n shopId: string\n }\n}\n\nexport interface ConvertDevToTestStoreSchema {\n convertDevToTestStore: {\n convertedToTestStore: boolean\n userErrors: {\n field: string[]\n message: string\n }[]\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const CreateAppQuery: string;
|
|
2
|
+
export interface CreateAppQueryVariables {
|
|
3
|
+
org: number;
|
|
4
|
+
title: string;
|
|
5
|
+
appUrl: string;
|
|
6
|
+
redir: string[];
|
|
7
|
+
type: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateAppQuerySchema {
|
|
10
|
+
appCreate: {
|
|
11
|
+
app: {
|
|
12
|
+
id: string;
|
|
13
|
+
apiKey: string;
|
|
14
|
+
title: string;
|
|
15
|
+
applicationUrl: string;
|
|
16
|
+
redirectUrlWhitelist: string[];
|
|
17
|
+
organizationId: string;
|
|
18
|
+
apiSecretKeys: {
|
|
19
|
+
secret: string;
|
|
20
|
+
}[];
|
|
21
|
+
appType: string;
|
|
22
|
+
};
|
|
23
|
+
userErrors: {
|
|
24
|
+
field: string[];
|
|
25
|
+
message: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
}
|