@shopify/create-app 4.9.5 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/{analytics-GMXMHUFA.js → analytics-NVXLO3J4.js} +19 -18
  2. package/dist/analytics-WSNO62UE.js +41 -0
  3. package/dist/{chunk-KREC6ICN.js → chunk-3S4LYDKB.js} +7 -7
  4. package/dist/{chunk-EODB55BY.js → chunk-77MCGVDL.js} +2 -2
  5. package/dist/{chunk-C3P3BBJI.js → chunk-C7SNAAK3.js} +3 -2
  6. package/dist/{chunk-P3CA5HR4.js → chunk-CXCQOKSC.js} +5 -5
  7. package/dist/{chunk-VKT2I3WB.js → chunk-D7A5DYKK.js} +10 -4
  8. package/dist/{chunk-CTYX7C3B.js → chunk-DIOGWWS3.js} +2 -2
  9. package/dist/{json-error-GH4NANA7.js → chunk-DIYGDUU2.js} +9 -39
  10. package/dist/{chunk-XIWLFYMS.js → chunk-DKAJC4S3.js} +103 -1406
  11. package/dist/{chunk-A33KVF5C.js → chunk-E4XG6SVI.js} +1 -1
  12. package/dist/{chunk-MCVF3JKC.js → chunk-F5VM2BG4.js} +199 -76
  13. package/dist/chunk-GLO2DI4E.js +3036 -0
  14. package/dist/{chunk-ATC7DBGE.js → chunk-J53FSF5Q.js} +3 -3
  15. package/dist/{chunk-YNPEWPVK.js → chunk-J6OB5R2E.js} +2 -2
  16. package/dist/{chunk-57VCTLOQ.js → chunk-JZFZ3JYG.js} +7 -2
  17. package/dist/{chunk-M3RDXLNX.js → chunk-L6U3W2XC.js} +8 -9
  18. package/dist/{chunk-T6GCTKLT.js → chunk-LQDG3VBX.js} +15 -12
  19. package/dist/{chunk-VNFX6QUY.js → chunk-MRUYZVYJ.js} +5 -3
  20. package/dist/{chunk-4ZMLBA4T.js → chunk-S3XZMGTD.js} +13 -13
  21. package/dist/{chunk-44QGQFKE.js → chunk-TES7JZAA.js} +13 -11
  22. package/dist/chunk-UJ5OJF5L.js +47 -0
  23. package/dist/{chunk-DXHBESFY.js → chunk-VHVI7YNQ.js} +43 -4
  24. package/dist/{chunk-37C3NPH2.js → chunk-VKOB4EDC.js} +17 -3040
  25. package/dist/{chunk-2BEA3V4R.js → chunk-XP6ZAZM3.js} +7 -7
  26. package/dist/{chunk-2YTKLSUT.js → chunk-YCTA633Q.js} +16 -16
  27. package/dist/{chunk-EJEHENXO.js → chunk-YYP4UTTA.js} +1 -2
  28. package/dist/{chunk-HSSZIAZA.js → chunk-ZNGF52JY.js} +2 -2
  29. package/dist/command-event-context-I6WEUQYW.js +12 -0
  30. package/dist/{command-json-schema-I7V7TBDJ.js → command-json-schema-NFKBCUYJ.js} +15 -12
  31. package/dist/{conf-store-B2TSLLPW.js → conf-store-F5RVQXAB.js} +9 -8
  32. package/dist/{custom-oclif-loader-AY2YB6FA.js → custom-oclif-loader-JCV5BKJY.js} +10 -9
  33. package/dist/{deprecations-Z2FZ3CU4.js → deprecations-D6NF6OMP.js} +15 -14
  34. package/dist/{environment-5XBFWY2A.js → environment-3MKMYTQQ.js} +4 -4
  35. package/dist/environments-RFS64LOU.js +33 -0
  36. package/dist/{error-handler-CKAKQAM5.js → error-handler-JY4HXOW5.js} +19 -18
  37. package/dist/{fs-FWPTU7RX.js → fs-7KG7OY2Z.js} +7 -6
  38. package/dist/hooks/postrun.js +8 -7
  39. package/dist/hooks/prerun.js +6 -6
  40. package/dist/index.js +11717 -8171
  41. package/dist/{is-global-BKUXICTV.js → is-global-3E5IDVMO.js} +7 -6
  42. package/dist/json-error-NQH2L57S.js +48 -0
  43. package/dist/{lib-NYDMHWZM.js → lib-7M7VJIRB.js} +2 -2
  44. package/dist/{local-7ND7KIQU.js → local-ZKE22RLD.js} +5 -5
  45. package/dist/{metadata-DBZ2VQTX.js → metadata-EACJ44OR.js} +6 -6
  46. package/dist/{node-package-manager-ULP534WO.js → node-package-manager-NFYSJBUI.js} +17 -16
  47. package/dist/{notifications-system-QWLT2Y2Y.js → notifications-system-ZDDGD7AS.js} +20 -19
  48. package/dist/{os-ZBSIDHYK.js → os-VAWLBHBF.js} +8 -7
  49. package/dist/{output-5W5HBNZ7.js → output-MFN7MN4X.js} +7 -6
  50. package/dist/{path-RDYZ7Q5T.js → path-NBWFOGJ4.js} +2 -2
  51. package/dist/{prettier-BNZDRHR4.js → prettier-XM547TFN.js} +2 -2
  52. package/dist/{system-J3NNUCJW.js → system-SDCJN2UD.js} +15 -14
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/dist/{ui-GGOBMVAN.js → ui-HZTN2YF4.js} +15 -14
  55. package/dist/upgrade-NSRTWSK6.js +295 -0
  56. package/dist/version-5LTDAJ3Z.js +37 -0
  57. package/dist/{version-6ZJE3O3B.js → version-XXTHXVKK.js} +2 -2
  58. package/oclif.manifest.json +11 -1
  59. package/package.json +3 -3
  60. package/dist/analytics-OBJJS2OD.js +0 -40
  61. package/dist/environments-LGI6IAQU.js +0 -32
  62. package/dist/upgrade-FKF5EE3S.js +0 -218
  63. package/dist/version-ARSWC6AU.js +0 -36
@@ -13859,4 +13859,4 @@ export {
13859
13859
  debugApis,
13860
13860
  init_prettier
13861
13861
  };
13862
- //# sourceMappingURL=chunk-A33KVF5C.js.map
13862
+ //# sourceMappingURL=chunk-E4XG6SVI.js.map
@@ -4,10 +4,10 @@ import {
4
4
  import {
5
5
  getPackageManager,
6
6
  packageManagerFromUserAgent
7
- } from "./chunk-KREC6ICN.js";
7
+ } from "./chunk-3S4LYDKB.js";
8
8
  import {
9
9
  CLI_KIT_VERSION
10
- } from "./chunk-HSSZIAZA.js";
10
+ } from "./chunk-ZNGF52JY.js";
11
11
  import {
12
12
  FormData,
13
13
  fetch_blob_default,
@@ -27,7 +27,7 @@ import {
27
27
  setCurrentSessionId,
28
28
  setSessions,
29
29
  timeIntervalToMilliseconds
30
- } from "./chunk-4ZMLBA4T.js";
30
+ } from "./chunk-S3XZMGTD.js";
31
31
  import {
32
32
  isCI,
33
33
  isWsl,
@@ -35,25 +35,29 @@ import {
35
35
  require_baseForOwn,
36
36
  require_stacktracey,
37
37
  sleep
38
- } from "./chunk-XIWLFYMS.js";
38
+ } from "./chunk-DKAJC4S3.js";
39
39
  import {
40
40
  platformAndArch
41
- } from "./chunk-CTYX7C3B.js";
41
+ } from "./chunk-DIOGWWS3.js";
42
42
  import {
43
43
  addPublicMetadata,
44
44
  addSensitiveMetadata,
45
45
  getAllPublicMetadata,
46
46
  getAllSensitiveMetadata,
47
47
  runWithTimer
48
- } from "./chunk-ATC7DBGE.js";
48
+ } from "./chunk-J53FSF5Q.js";
49
49
  import {
50
+ automationTokenAuthMethod,
51
+ automationTokenVariable,
52
+ automationTokenVariablesProblem,
50
53
  getAppAutomationToken,
51
54
  getIdentityTokenInformation,
52
55
  hashString,
53
56
  maxRequestTimeForNetworkCallsMs,
54
57
  nonRandomUUID,
58
+ sha256,
55
59
  skipNetworkLevelRetry
56
- } from "./chunk-DXHBESFY.js";
60
+ } from "./chunk-VHVI7YNQ.js";
57
61
  import {
58
62
  AbortError,
59
63
  AbortSilentError,
@@ -64,15 +68,13 @@ import {
64
68
  errorMapper,
65
69
  graphQLErrorCodes,
66
70
  handler,
67
- hasRateLimitCode,
68
71
  isGatewayErrorStatus,
69
72
  isPermissionCode,
70
73
  isRateLimitCode,
71
74
  shouldReportErrorAsUnexpected
72
- } from "./chunk-M3RDXLNX.js";
75
+ } from "./chunk-L6U3W2XC.js";
73
76
  import {
74
77
  currentProcessIsGlobal,
75
- external_exports,
76
78
  getArrayContainsDuplicates,
77
79
  getArrayRejectingUndefined,
78
80
  inferPackageManagerForGlobalCLI,
@@ -115,7 +117,7 @@ import {
115
117
  slugify,
116
118
  stringifyMessage,
117
119
  uniq
118
- } from "./chunk-37C3NPH2.js";
120
+ } from "./chunk-VKOB4EDC.js";
119
121
  import {
120
122
  alwaysLogAnalytics,
121
123
  alwaysLogMetrics,
@@ -129,22 +131,26 @@ import {
129
131
  macAddress,
130
132
  opentelemetryDomain,
131
133
  themeToken
132
- } from "./chunk-P3CA5HR4.js";
134
+ } from "./chunk-CXCQOKSC.js";
133
135
  import {
134
136
  bugsnagApiKey,
137
+ environmentVariables,
135
138
  reportingRateLimit,
136
139
  sessionConstants
137
- } from "./chunk-C3P3BBJI.js";
140
+ } from "./chunk-C7SNAAK3.js";
141
+ import {
142
+ external_exports
143
+ } from "./chunk-GLO2DI4E.js";
138
144
  import {
139
145
  require_lib
140
- } from "./chunk-EJEHENXO.js";
146
+ } from "./chunk-YYP4UTTA.js";
141
147
  import {
142
148
  cwd,
143
149
  isAbsolutePath,
144
150
  joinPath,
145
151
  normalizePath,
146
152
  relativePath
147
- } from "./chunk-57VCTLOQ.js";
153
+ } from "./chunk-JZFZ3JYG.js";
148
154
  import {
149
155
  __commonJS,
150
156
  __esm,
@@ -10157,7 +10163,7 @@ var require_GraphQLError = __commonJS({
10157
10163
  extensions: args[5]
10158
10164
  } : firstArg;
10159
10165
  }
10160
- var GraphQLError = class _GraphQLError extends Error {
10166
+ var GraphQLError2 = class _GraphQLError extends Error {
10161
10167
  /**
10162
10168
  * An array of `{ line, column }` locations within the source GraphQL document
10163
10169
  * which correspond to this error.
@@ -10374,7 +10380,7 @@ var require_GraphQLError = __commonJS({
10374
10380
  return this.locations != null && (formattedError.locations = this.locations), this.path != null && (formattedError.path = this.path), this.extensions != null && Object.keys(this.extensions).length > 0 && (formattedError.extensions = this.extensions), formattedError;
10375
10381
  }
10376
10382
  };
10377
- exports2.GraphQLError = GraphQLError;
10383
+ exports2.GraphQLError = GraphQLError2;
10378
10384
  function undefinedIfEmpty(array) {
10379
10385
  return array === void 0 || array.length === 0 ? void 0 : array;
10380
10386
  }
@@ -11693,13 +11699,13 @@ var require_parser = __commonJS({
11693
11699
  value: !0
11694
11700
  });
11695
11701
  exports2.Parser = void 0;
11696
- exports2.parse = parse2;
11702
+ exports2.parse = parse3;
11697
11703
  exports2.parseConstValue = parseConstValue;
11698
11704
  exports2.parseSchemaCoordinate = parseSchemaCoordinate;
11699
11705
  exports2.parseType = parseType;
11700
11706
  exports2.parseValue = parseValue;
11701
11707
  var _syntaxError = require_syntaxError(), _ast = require_ast(), _directiveLocation = require_directiveLocation(), _kinds = require_kinds(), _lexer = require_lexer(), _schemaCoordinateLexer = require_schemaCoordinateLexer(), _source = require_source(), _tokenKind = require_tokenKind();
11702
- function parse2(source, options2) {
11708
+ function parse3(source, options2) {
11703
11709
  let parser2 = new Parser(source, options2), document = parser2.parseDocument();
11704
11710
  return Object.defineProperty(document, "tokenCount", {
11705
11711
  enumerable: !1,
@@ -24585,9 +24591,9 @@ var require_getOperationAST = __commonJS({
24585
24591
  Object.defineProperty(exports2, "__esModule", {
24586
24592
  value: !0
24587
24593
  });
24588
- exports2.getOperationAST = getOperationAST;
24594
+ exports2.getOperationAST = getOperationAST2;
24589
24595
  var _kinds = require_kinds();
24590
- function getOperationAST(documentAST, operationName) {
24596
+ function getOperationAST2(documentAST, operationName) {
24591
24597
  let operation = null;
24592
24598
  for (let definition of documentAST.definitions)
24593
24599
  if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
@@ -32507,10 +32513,10 @@ metadata was removed`
32507
32513
  var payload = _$safeJsonStringify_1(session, null, null);
32508
32514
  return payload;
32509
32515
  };
32510
- var http4 = __require("http"), https4 = __require("https"), ___require_37 = __require("url"), parse2 = ___require_37.parse, _$request_37 = function(_ref, cb) {
32516
+ var http4 = __require("http"), https4 = __require("https"), ___require_37 = __require("url"), parse3 = ___require_37.parse, _$request_37 = function(_ref, cb) {
32511
32517
  var url5 = _ref.url, headers = _ref.headers, body = _ref.body, agent = _ref.agent, didError = !1, onError = function(err2) {
32512
32518
  didError || (didError = !0, cb(err2));
32513
- }, parsedUrl = parse2(url5), secure = parsedUrl.protocol === "https:", transport = secure ? https4 : http4, req = transport.request({
32519
+ }, parsedUrl = parse3(url5), secure = parsedUrl.protocol === "https:", transport = secure ? https4 : http4, req = transport.request({
32514
32520
  method: "POST",
32515
32521
  hostname: parsedUrl.hostname,
32516
32522
  port: parsedUrl.port,
@@ -61548,7 +61554,7 @@ async function sendAnalyticsEvent(payload, skipMonorailAnalytics, skipMetricAnal
61548
61554
  }
61549
61555
  async function sendAnalyticsEventFromStdin() {
61550
61556
  try {
61551
- let { readStdinString } = await import("./system-J3NNUCJW.js"), payloadStr = await readStdinString();
61557
+ let { readStdinString } = await import("./system-SDCJN2UD.js"), payloadStr = await readStdinString();
61552
61558
  if (payloadStr === void 0)
61553
61559
  throw new Error("No analytics payload received from stdin");
61554
61560
  let { payload, skipMonorailAnalytics, skipMetricAnalytics } = JSON.parse(payloadStr);
@@ -61582,12 +61588,12 @@ async function reportAnalyticsEvent(options2) {
61582
61588
  outputDebug(outputContent`Skipping command analytics, payload: ${outputToken.json(payload)}`);
61583
61589
  return;
61584
61590
  }
61585
- let [{ platformAndArch: platformAndArch2 }, { isInsideContainer }] = await Promise.all([import("./os-ZBSIDHYK.js"), import("./system-J3NNUCJW.js")]), sendInBackground = !commandStartOptions?.requiresSyncAnalytics && platformAndArch2().platform !== "windows" && !ciPlatform().isCI && !isInsideContainer();
61591
+ let [{ platformAndArch: platformAndArch2 }, { isInsideContainer }] = await Promise.all([import("./os-VAWLBHBF.js"), import("./system-SDCJN2UD.js")]), sendInBackground = !commandStartOptions?.requiresSyncAnalytics && platformAndArch2().platform !== "windows" && !ciPlatform().isCI && !isInsideContainer();
61586
61592
  if (outputDebug(outputContent`Sending command analytics${sendInBackground ? " in background" : ""}, payload: ${outputToken.json(payload)}`), !sendInBackground) {
61587
61593
  await sendAnalyticsEvent(payload, skipMonorailAnalytics, skipMetricAnalytics);
61588
61594
  return;
61589
61595
  }
61590
- let { exec } = await import("./system-J3NNUCJW.js"), argv = process.argv;
61596
+ let { exec } = await import("./system-SDCJN2UD.js"), argv = process.argv;
61591
61597
  if (!argv[1])
61592
61598
  return;
61593
61599
  let nodeBinary = process.execPath, args = [argv[1], "send-analytics"], analyticsProcess = exec(nodeBinary, args, {
@@ -61672,8 +61678,9 @@ function compileData2() {
61672
61678
  }
61673
61679
 
61674
61680
  // ../cli-kit/dist/private/node/api.js
61681
+ var import_graphql2 = __toESM(require_graphql2(), 1);
61675
61682
  import { performance as performance2 } from "perf_hooks";
61676
- var allAPIs = ["admin", "storefront-renderer", "partners", "business-platform", "app-management"], DEFAULT_RETRY_DELAY_MS2 = 1e3, DEFAULT_RETRY_LIMIT = 10, interestingResponseHeaders = /* @__PURE__ */ new Set([
61683
+ var allAPIs = ["admin", "storefront-renderer", "partners", "business-platform", "app-management"], DEFAULT_RETRY_DELAY_MS2 = 1e3, DEFAULT_RETRY_LIMIT = 10, MAX_THROTTLE_RETRY_DELAY_MS = 8e3, MAX_THROTTLE_RETRY_TIME_MS = 3e4, interestingResponseHeaders = /* @__PURE__ */ new Set([
61677
61684
  "cache-control",
61678
61685
  "content-type",
61679
61686
  "etag",
@@ -61751,32 +61758,23 @@ async function makeVerboseRequest(requestOptions) {
61751
61758
  for (let [key, value] of err2.response.headers)
61752
61759
  responseHeaderIsInteresting(key) && (responseHeaders[key] = value);
61753
61760
  let sanitizedHeaders = sanitizedHeadersOutput(responseHeaders);
61754
- if (isThrottled(err2)) {
61755
- let delayMs;
61756
- try {
61757
- delayMs = responseHeaders["retry-after"] ? Number.parseInt(responseHeaders["retry-after"], 10) : void 0;
61758
- } catch {
61759
- }
61760
- return {
61761
- status: "can-retry",
61762
- clientError: err2,
61763
- duration,
61764
- sanitizedHeaders,
61765
- sanitizedUrl,
61766
- requestId: responseHeaders["x-request-id"],
61767
- delayMs
61768
- };
61769
- } else if (err2.response.status === 401)
61770
- return {
61771
- status: "unauthorized",
61772
- clientError: err2,
61773
- duration,
61774
- sanitizedHeaders,
61775
- sanitizedUrl,
61776
- requestId: responseHeaders["x-request-id"],
61777
- delayMs: 500
61778
- };
61779
- return {
61761
+ return isThrottled(err2) ? {
61762
+ status: "can-retry",
61763
+ clientError: err2,
61764
+ duration,
61765
+ sanitizedHeaders,
61766
+ sanitizedUrl,
61767
+ requestId: responseHeaders["x-request-id"],
61768
+ delayMs: retryAfterDelayMs(responseHeaders["retry-after"])
61769
+ } : err2.response.status === 401 ? {
61770
+ status: "unauthorized",
61771
+ clientError: err2,
61772
+ duration,
61773
+ sanitizedHeaders,
61774
+ sanitizedUrl,
61775
+ requestId: responseHeaders["x-request-id"],
61776
+ delayMs: 500
61777
+ } : {
61780
61778
  status: "client-error",
61781
61779
  clientError: err2,
61782
61780
  duration,
@@ -61805,7 +61803,34 @@ async function makeVerboseRequest(requestOptions) {
61805
61803
  };
61806
61804
  }
61807
61805
  function isThrottled(error) {
61808
- return error.response.status === 429 ? !0 : hasRateLimitCode(error.response.errors);
61806
+ if (error.response.data != null && !isReadOnlyQuery(error.request.query))
61807
+ return !1;
61808
+ let httpRateLimited = error.response.status === 429, errors = error.response.errors;
61809
+ return !Array.isArray(errors) || errors.length === 0 ? httpRateLimited : errors.every((entry) => {
61810
+ let codes = graphQLErrorCodes([entry]);
61811
+ return (codes.length > 0 || httpRateLimited) && codes.every(isRateLimitCode);
61812
+ });
61813
+ }
61814
+ function isReadOnlyQuery(query) {
61815
+ if (typeof query != "string")
61816
+ return !1;
61817
+ try {
61818
+ return (0, import_graphql2.getOperationAST)((0, import_graphql2.parse)(query))?.operation === "query";
61819
+ } catch (error) {
61820
+ if (error instanceof import_graphql2.GraphQLError)
61821
+ return !1;
61822
+ throw error;
61823
+ }
61824
+ }
61825
+ function retryAfterDelayMs(retryAfter) {
61826
+ let value = retryAfter?.trim();
61827
+ if (!value)
61828
+ return;
61829
+ let seconds = Number(value);
61830
+ if (!Number.isNaN(seconds))
61831
+ return Number.isFinite(seconds) && seconds >= 0 ? seconds * 1e3 : void 0;
61832
+ let isAsctimeDate = /^[A-Za-z]{3} [A-Za-z]{3} (?: \d|\d{2}) \d{2}:\d{2}:\d{2} \d{4}$/.test(value), retryAt = Date.parse(isAsctimeDate ? `${value} GMT` : value);
61833
+ return Number.isNaN(retryAt) ? void 0 : Math.max(0, retryAt - Date.now());
61809
61834
  }
61810
61835
  async function simpleRequestWithDebugLog(requestOptions, errorHandler3) {
61811
61836
  let result = await makeVerboseRequest(requestOptions);
@@ -61828,7 +61853,7 @@ ${result.sanitizedHeaders}
61828
61853
  async function retryAwareRequest(requestOptions, errorHandler3, retryOptions = {
61829
61854
  scheduleDelay: setTimeout
61830
61855
  }) {
61831
- let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest(requestOptions);
61856
+ let retriesUsed = 0, limitRetriesTo = retryOptions.limitRetriesTo ?? DEFAULT_RETRY_LIMIT, result = await makeVerboseRequest(requestOptions), retryDeadline = performance2.now() + MAX_THROTTLE_RETRY_TIME_MS;
61832
61857
  for (outputDebug(`Request to ${result.sanitizedUrl} completed in ${result.duration} ms
61833
61858
  With response headers:
61834
61859
  ${result.sanitizedHeaders}
@@ -61841,13 +61866,14 @@ ${result.sanitizedHeaders}
61841
61866
  throw errorHandler3 ? errorHandler3(result.error, result.requestId) : result.error;
61842
61867
  if (result.status === "unauthorized")
61843
61868
  throw result.clientError;
61844
- if (limitRetriesTo <= retriesUsed)
61845
- throw outputDebug(`${limitRetriesTo} retries exhausted for request to ${result.sanitizedUrl}`), errorHandler3 ? errorHandler3(result.clientError, result.requestId) : result.clientError;
61846
- retriesUsed += 1, requestOptions.recordCommandRetries && recordRetry2(requestOptions.url, `http-retry-${retriesUsed}:${result.status}:`);
61847
- let retryDelayMs = result.delayMs ?? retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS2;
61848
- outputDebug(`Scheduling retry request #${retriesUsed} to ${result.sanitizedUrl} in ${retryDelayMs} ms`), result = await new Promise((resolve) => {
61869
+ let maximumDelayMs = Math.min((retryOptions.defaultDelayMs ?? DEFAULT_RETRY_DELAY_MS2) * 2 ** retriesUsed, MAX_THROTTLE_RETRY_DELAY_MS), retryDelayMs = result.delayMs ?? Math.floor(maximumDelayMs * (0.5 + Math.random() / 2));
61870
+ if (limitRetriesTo <= retriesUsed || retryDelayMs >= retryDeadline - performance2.now())
61871
+ throw outputDebug(`Rate-limit retry budget exhausted after ${retriesUsed} retries for request to ${result.sanitizedUrl}`), errorHandler3 ? errorHandler3(result.clientError, result.requestId) : result.clientError;
61872
+ retriesUsed += 1, requestOptions.recordCommandRetries && recordRetry2(requestOptions.url, `http-retry-${retriesUsed}:${result.status}:`), outputDebug(`Scheduling retry request #${retriesUsed} to ${result.sanitizedUrl} in ${retryDelayMs} ms`);
61873
+ let previousResult = result;
61874
+ result = await new Promise((resolve) => {
61849
61875
  retryOptions.scheduleDelay(() => {
61850
- resolve(makeVerboseRequest(requestOptions));
61876
+ resolve(performance2.now() < retryDeadline ? makeVerboseRequest(requestOptions) : previousResult);
61851
61877
  }, retryDelayMs);
61852
61878
  });
61853
61879
  }
@@ -62426,7 +62452,7 @@ async function exchangeAppAutomationTokenForAccessToken(apiName, token, scopes)
62426
62452
  let appId = applicationId(apiName);
62427
62453
  try {
62428
62454
  let accessToken = (await requestAppToken(apiName, token, scopes))[appId].accessToken, userId2 = nonRandomUUID(token);
62429
- return setLastSeenUserIdAfterAuth(userId2), setLastSeenAuthMethod("partners_token"), { accessToken, userId: userId2 };
62455
+ return setLastSeenUserIdAfterAuth(userId2), setLastSeenAuthMethod(automationTokenAuthMethod()), { accessToken, userId: userId2 };
62430
62456
  } catch (error) {
62431
62457
  let prettyName = apiName.replace(/-/g, " ").replace(/\b\w/g, (char) => char.toUpperCase()), reason = error instanceof Error ? error.message.slice(0, 200) : "unknown error";
62432
62458
  throw outputDebug(`Token exchange for the ${prettyName} API failed: ${reason}`), new AbortError(`The custom token provided can't be used for the ${prettyName} API.`, "Ensure the token is correct and not expired.");
@@ -62438,8 +62464,8 @@ async function exchangeCustomPartnerToken(token) {
62438
62464
  async function exchangeAppAutomationTokenForAppManagementAccessToken(token) {
62439
62465
  return exchangeAppAutomationTokenForAccessToken("app-management", token, tokenExchangeScopes("app-management"));
62440
62466
  }
62441
- async function exchangeAppAutomationTokenForBusinessPlatformAccessToken(token) {
62442
- return exchangeAppAutomationTokenForAccessToken("business-platform", token, tokenExchangeScopes("business-platform"));
62467
+ async function exchangeAppAutomationTokenForBusinessPlatformAccessToken(token, scopes = tokenExchangeScopes("business-platform")) {
62468
+ return exchangeAppAutomationTokenForAccessToken("business-platform", token, scopes);
62443
62469
  }
62444
62470
  var identityDeviceErrors = [
62445
62471
  "authorization_pending",
@@ -62673,6 +62699,66 @@ var UserEmailQueryString = `
62673
62699
 
62674
62700
  // ../cli-kit/dist/public/node/session.js
62675
62701
  init_cjs_shims();
62702
+
62703
+ // ../cli-kit/dist/private/node/session/permanent-store-domain.js
62704
+ init_cjs_shims();
62705
+
62706
+ // ../cli-kit/dist/public/common/url.js
62707
+ init_cjs_shims();
62708
+ function safeParseURL(url4) {
62709
+ try {
62710
+ return new URL(url4);
62711
+ } catch {
62712
+ return;
62713
+ }
62714
+ }
62715
+ function extractHost(value) {
62716
+ if (!value)
62717
+ return;
62718
+ let lowered = value.toLowerCase();
62719
+ for (let candidate of [lowered, `https://${lowered}`]) {
62720
+ let hostname = safeParseURL(candidate)?.hostname;
62721
+ if (hostname)
62722
+ return hostname;
62723
+ }
62724
+ let fallback = lowered.replace(/^https?:\/\//, "").split("/")[0];
62725
+ if (fallback)
62726
+ return fallback;
62727
+ }
62728
+ function extractMyshopifyHandle(value) {
62729
+ let host3 = extractHost(value);
62730
+ if (!host3)
62731
+ return;
62732
+ let match = host3.match(/^([^.]+)\.myshopify\.com$/);
62733
+ return match ? match[1] : void 0;
62734
+ }
62735
+
62736
+ // ../cli-kit/dist/private/node/session/permanent-store-domain.js
62737
+ var PERMANENT_DOMAIN_LOOKUP_TIMEOUT_MS = 5e3, resolvedStoreFqdns = /* @__PURE__ */ new Map();
62738
+ async function resolvePermanentStoreFqdn(storeFqdn) {
62739
+ if (serviceEnvironment() === "local")
62740
+ return storeFqdn;
62741
+ let cached = resolvedStoreFqdns.get(storeFqdn);
62742
+ if (cached)
62743
+ return cached;
62744
+ let permanentStoreFqdn = await fetchPermanentStoreFqdn(storeFqdn);
62745
+ return resolvedStoreFqdns.set(storeFqdn, permanentStoreFqdn), permanentStoreFqdn !== storeFqdn && (resolvedStoreFqdns.set(permanentStoreFqdn, permanentStoreFqdn), outputInfo(outputContent`Using the permanent domain ${outputToken.raw(permanentStoreFqdn)} for ${outputToken.raw(storeFqdn)}.`)), permanentStoreFqdn;
62746
+ }
62747
+ async function fetchPermanentStoreFqdn(storeFqdn) {
62748
+ let url4 = `https://${storeFqdn}/meta.json`;
62749
+ try {
62750
+ let response = await fetch2(url4, { headers: { Accept: "application/json" } }, { useNetworkLevelRetry: !1, useAbortSignal: !0, timeoutMs: PERMANENT_DOMAIN_LOOKUP_TIMEOUT_MS });
62751
+ if (!response.ok)
62752
+ return outputDebug(`Could not look up the permanent domain of ${storeFqdn}: ${url4} returned HTTP ${response.status}`), storeFqdn;
62753
+ let body = await response.json(), permanentStoreFqdn = typeof body?.myshopify_domain == "string" ? body.myshopify_domain.toLowerCase() : "", handle = extractMyshopifyHandle(permanentStoreFqdn);
62754
+ return !handle || `${handle}.myshopify.com` !== permanentStoreFqdn ? (outputDebug(`Could not look up the permanent domain of ${storeFqdn}: ${url4} has no valid myshopify_domain`), storeFqdn) : permanentStoreFqdn;
62755
+ } catch (error) {
62756
+ let message = error instanceof Error ? error.message : String(error);
62757
+ return outputDebug(`Could not look up the permanent domain of ${storeFqdn}: ${message}`), storeFqdn;
62758
+ }
62759
+ }
62760
+
62761
+ // ../cli-kit/dist/public/node/session.js
62676
62762
  function setLastSeenUserId(userId2) {
62677
62763
  setLastSeenUserIdAfterAuth(userId2);
62678
62764
  }
@@ -62759,8 +62845,8 @@ async function ensureAuthenticatedThemes(store2, password, scopes = [], options2
62759
62845
  if (outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:
62760
62846
  ${outputToken.json(scopes)}
62761
62847
  `), password) {
62762
- let session = { token: password, storeFqdn: store2 }, authMethod2 = isThemeAccessSession(session) ? "theme_access_token" : "custom_app_token";
62763
- return setLastSeenAuthMethod(authMethod2), setLastSeenUserIdAfterAuth(nonRandomUUID(password)), session;
62848
+ let session = { token: password, storeFqdn: store2 }, themeAccess = isThemeAccessSession(session);
62849
+ return setLastSeenAuthMethod(themeAccess ? "theme_access_token" : "custom_app_token"), setLastSeenUserIdAfterAuth(nonRandomUUID(password)), themeAccess && (session.storeFqdn = await resolvePermanentStoreFqdn(store2)), session;
62764
62850
  }
62765
62851
  return ensureAuthenticatedAdmin(store2, scopes, options2);
62766
62852
  }
@@ -62768,11 +62854,23 @@ async function ensureAuthenticatedBusinessPlatform(scopes = [], options2 = {}) {
62768
62854
  outputDebug(outputContent`Ensuring that the user is authenticated with the Business Platform API with the following scopes:
62769
62855
  ${outputToken.json(scopes)}
62770
62856
  `);
62771
- let tokens = await ensureAuthenticated({ businessPlatformApi: { scopes } }, process.env, options2);
62857
+ let { allowAutomationToken = !1, ...authenticationOptions } = options2, automationToken = allowAutomationToken ? getAppAutomationToken() : void 0;
62858
+ if (automationToken)
62859
+ return (await exchangeAppAutomationTokenForBusinessPlatformAccessToken(automationToken, [])).accessToken;
62860
+ let tokens = await ensureAuthenticated({ businessPlatformApi: { scopes } }, process.env, authenticationOptions);
62772
62861
  if (!tokens.businessPlatform)
62773
62862
  throw new BugError("No business-platform token found after ensuring authenticated");
62774
62863
  return tokens.businessPlatform;
62775
62864
  }
62865
+ function isServiceAccountTokenSet() {
62866
+ return automationTokenVariable() === environmentVariables.serviceAccountToken;
62867
+ }
62868
+ function ensureNoServiceAccountToken() {
62869
+ if (!isServiceAccountTokenSet())
62870
+ return;
62871
+ let variable = environmentVariables.serviceAccountToken;
62872
+ throw new AbortError(`This command can't use ${variable}.`, `Unset ${variable} to run it with your Shopify account.`);
62873
+ }
62776
62874
  function logout() {
62777
62875
  return remove();
62778
62876
  }
@@ -62859,7 +62957,7 @@ ${sanitizedHeadersOutput(headers)}\n
62859
62957
  to ${sanitizeURL(url4)}`);
62860
62958
  }
62861
62959
  function sanitizeVariables(variables) {
62862
- let result = { ...variables }, sanitizedResult = sanitizeDeepVariables(result, ["apiKey", "serialized_script"]);
62960
+ let result = { ...variables }, sanitizedResult = sanitizeDeepVariables(result, ["apiKey", "serialized_script", "sharedSecret", "shared_secret"]);
62863
62961
  return JSON.stringify(sanitizedResult, null, 2);
62864
62962
  }
62865
62963
  function sanitizeDeepVariables(value, sensitiveKeys) {
@@ -62913,7 +63011,7 @@ function errorHandler2(api) {
62913
63011
  return (error, requestId) => {
62914
63012
  if (error instanceof ClientError) {
62915
63013
  let { status } = error.response, extractedMessages = extractGraphQLErrorMessages(error.response.errors), errorMessage2;
62916
- extractedMessages && status < 500 ? errorMessage2 = extractedMessages : extractedMessages && status >= 500 ? errorMessage2 = `The ${api} GraphQL API responded with HTTP status ${status}: ${extractedMessages}` : errorMessage2 = stringifyMessage(outputContent`
63014
+ extractedMessages && status < 500 ? errorMessage2 = extractedMessages : extractedMessages && status >= 500 ? errorMessage2 = `The ${api} GraphQL API responded with HTTP status ${status}: ${extractedMessages}` : error.response.errors === void 0 ? errorMessage2 = `The ${api} GraphQL API responded unsuccessfully with the HTTP status ${status}.` : errorMessage2 = stringifyMessage(outputContent`
62917
63015
  The ${outputToken.raw(api)} GraphQL API responded unsuccessfully with${status === 200 ? "" : ` the HTTP status ${status} and`} errors:
62918
63016
 
62919
63017
  ${outputToken.json(error.response.errors)}
@@ -62926,6 +63024,9 @@ Request ID: ${requestId}`);
62926
63024
  return error;
62927
63025
  };
62928
63026
  }
63027
+ function extractGraphQLErrors(error) {
63028
+ return error instanceof ClientError ? Array.isArray(error.response.errors) ? error.response.errors : [] : error instanceof GraphQLClientError ? Array.isArray(error.errors) ? error.errors : [] : [];
63029
+ }
62929
63030
 
62930
63031
  // ../cli-kit/dist/public/node/api/graphql.js
62931
63032
  var MAX_RATE_LIMIT_RESTORE_DELAY_SECONDS = 0.3;
@@ -62980,29 +63081,43 @@ async function performGraphQLRequest(options2) {
62980
63081
  return client = newClient, headers = newHeaders, !0;
62981
63082
  } else
62982
63083
  return !1;
62983
- } : void 0, request3 = () => retryAwareRequest({ request: rawGraphQLRequest, url: url4, ...behaviour }, responseOptions?.handleErrors === !1 ? void 0 : errorHandler2(api)), executeWithTimer = () => runWithTimer("cmd_all_timing_network_ms")(async () => {
63084
+ } : void 0, handleErrors = responseOptions?.handleErrors !== !1, request3 = () => retryAwareRequest({ request: rawGraphQLRequest, url: url4, ...behaviour }, handleErrors ? errorHandler2(api) : void 0), unauthorizedError = (error) => !handleErrors || !(error instanceof ClientError) || error.response.status !== 401 ? error : errorHandler2(api)(error, requestIdFromClientError(error)), executeWithTimer = () => runWithTimer("cmd_all_timing_network_ms")(async () => {
62984
63085
  let response;
62985
63086
  try {
62986
63087
  response = await request3();
62987
63088
  } catch (error) {
62988
63089
  if (error instanceof ClientError && error.response.status === 401 && tokenRefreshUnauthorizedHandlerFunction)
62989
63090
  if (await tokenRefreshUnauthorizedHandlerFunction())
62990
- response = await request3();
63091
+ try {
63092
+ response = await request3();
63093
+ } catch (retryError) {
63094
+ throw unauthorizedError(retryError);
63095
+ }
62991
63096
  else
62992
- throw error;
63097
+ throw unauthorizedError(error);
62993
63098
  else
62994
- throw error;
63099
+ throw unauthorizedError(error);
62995
63100
  }
62996
63101
  return responseOptions?.onResponse && responseOptions.onResponse(response), response.data;
62997
63102
  });
62998
63103
  if (cacheOptions === void 0)
62999
63104
  return executeWithTimer();
63000
- let { cacheTTL, cacheExtraKey, cacheStore } = cacheOptions, queryHash = nonRandomUUID(queryAsString), variablesHash = nonRandomUUID(JSON.stringify(variables ?? {})), cacheKey = `q-${queryHash}-${variablesHash}-${CLI_KIT_VERSION}-${cacheExtraKey ?? ""}`, result = await cacheRetrieveOrRepopulate(cacheKey, async () => {
63105
+ let { cacheTTL, cacheExtraKey, cacheStore } = cacheOptions, queryHash = nonRandomUUID(queryAsString), variablesHash = nonRandomUUID(JSON.stringify(variables ?? {})), principalHash = graphQLCachePrincipalHash(url4, token), cacheKey = `q-${queryHash}-${variablesHash}-${CLI_KIT_VERSION}-${principalHash}-${cacheExtraKey ?? ""}`, result = await cacheRetrieveOrRepopulate(cacheKey, async () => {
63001
63106
  let result2 = await executeWithTimer();
63002
63107
  return JSON.stringify(result2);
63003
63108
  }, timeIntervalToMilliseconds(cacheTTL), cacheStore);
63004
63109
  return JSON.parse(result);
63005
63110
  }
63111
+ function requestIdFromClientError(error) {
63112
+ try {
63113
+ return error.response.headers?.get?.("x-request-id") ?? void 0;
63114
+ } catch {
63115
+ return;
63116
+ }
63117
+ }
63118
+ function graphQLCachePrincipalHash(url4, token) {
63119
+ return sha256(JSON.stringify([url4, token ?? ""])).toString("hex");
63120
+ }
63006
63121
  async function logLastRequestIdFromResponse(response) {
63007
63122
  try {
63008
63123
  let requestId = response.headers.get("x-request-id");
@@ -63142,7 +63257,7 @@ async function getLastSeenAuthMethod() {
63142
63257
  if (getCurrentSessionId())
63143
63258
  return "device_auth";
63144
63259
  if (getAppAutomationToken())
63145
- return "partners_token";
63260
+ return automationTokenAuthMethod();
63146
63261
  let themePassword = themeToken();
63147
63262
  return themePassword ? isThemeAccessSession({ token: themePassword, storeFqdn: "" }) ? "theme_access_token" : "custom_app_token" : "none";
63148
63263
  }
@@ -63153,6 +63268,10 @@ function setCommandSessionId(sessionId) {
63153
63268
  commandSessionId = sessionId;
63154
63269
  }
63155
63270
  async function ensureAuthenticated(applications, _env, { forceRefresh = !1, noPrompt = !1, forceNewSession = !1 } = {}) {
63271
+ let variablesProblem = automationTokenVariablesProblem();
63272
+ if (variablesProblem)
63273
+ throw new AbortError(variablesProblem.message, variablesProblem.tryMessage);
63274
+ ensureNoServiceAccountToken();
63156
63275
  let fqdn = await identityFqdn(), previousStoreFqdn = applications.adminApi?.storeFqdn;
63157
63276
  if (previousStoreFqdn) {
63158
63277
  let normalizedStoreName = normalizeStoreFqdn(previousStoreFqdn);
@@ -63398,6 +63517,8 @@ export {
63398
63517
  ok,
63399
63518
  err,
63400
63519
  isThemeAccessSession,
63520
+ safeParseURL,
63521
+ extractMyshopifyHandle,
63401
63522
  setLastSeenUserId,
63402
63523
  setCurrentSessionAlias,
63403
63524
  isUserAccount,
@@ -63408,6 +63529,7 @@ export {
63408
63529
  ensureAuthenticatedAdmin,
63409
63530
  ensureAuthenticatedThemes,
63410
63531
  ensureAuthenticatedBusinessPlatform,
63532
+ isServiceAccountTokenSet,
63411
63533
  ensureAuthenticatedAdminAsApp,
63412
63534
  require_cjs,
63413
63535
  require_baseAssignValue,
@@ -63424,6 +63546,7 @@ export {
63424
63546
  setPathValue,
63425
63547
  isEmpty,
63426
63548
  compact,
63549
+ extractGraphQLErrors,
63427
63550
  graphqlRequest,
63428
63551
  graphqlRequestDoc,
63429
63552
  require_lib4 as require_lib2,
@@ -63468,4 +63591,4 @@ mime-types/index.js:
63468
63591
  * MIT Licensed
63469
63592
  *)
63470
63593
  */
63471
- //# sourceMappingURL=chunk-MCVF3JKC.js.map
63594
+ //# sourceMappingURL=chunk-F5VM2BG4.js.map