@shopify/cli 3.66.0 → 3.67.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 (109) hide show
  1. package/dist/assets/cli-ruby/lib/shopify_cli/theme/dev_server/proxy.rb +3 -7
  2. package/dist/assets/hydrogen/starter/CHANGELOG.md +105 -0
  3. package/dist/assets/hydrogen/starter/app/components/CartSummary.tsx +79 -0
  4. package/dist/assets/hydrogen/starter/app/components/Header.tsx +3 -9
  5. package/dist/assets/hydrogen/starter/app/lib/fragments.ts +6 -0
  6. package/dist/assets/hydrogen/starter/app/lib/search.ts +2 -2
  7. package/dist/assets/hydrogen/starter/app/root.tsx +5 -3
  8. package/dist/assets/hydrogen/starter/app/routes/cart.tsx +14 -0
  9. package/dist/assets/hydrogen/starter/package.json +5 -5
  10. package/dist/assets/hydrogen/starter/storefrontapi.generated.d.ts +5 -0
  11. package/dist/{chunk-UUUKSZ6D.js → chunk-2A4NZDBL.js} +25 -8
  12. package/dist/{lib-CPSRXLFM.js → chunk-2HGYYNE5.js} +5 -2
  13. package/dist/{chunk-D2RO6JR3.js → chunk-33B37WAX.js} +148 -39
  14. package/dist/{chunk-XC2GDHJG.js → chunk-56GJOU7U.js} +29 -5
  15. package/dist/{chunk-WX53MNQL.js → chunk-66CAOMYB.js} +3 -3
  16. package/dist/{chunk-UVGRJGX3.js → chunk-6JA2FWML.js} +3 -3
  17. package/dist/{chunk-PBJ5OTM2.js → chunk-6RGB2VE4.js} +2 -2
  18. package/dist/{chunk-JDW4FALN.js → chunk-7QTS6ZWN.js} +29 -89
  19. package/dist/{chunk-33TKMDCD.js → chunk-7TTWOW5T.js} +2 -2
  20. package/dist/{chunk-WPNX6KPH.js → chunk-7VVKCVPD.js} +4 -4
  21. package/dist/{chunk-BVIU4OLB.js → chunk-A3ZREYWQ.js} +4 -4
  22. package/dist/{chunk-2VOIYZPC.js → chunk-ALNQ5ENK.js} +4 -4
  23. package/dist/{chunk-6DU4BL5F.js → chunk-BFQFJ7IZ.js} +28 -17
  24. package/dist/{chunk-NKAOPMA3.js → chunk-BLVJTR72.js} +2 -2
  25. package/dist/{chunk-IZJK3NZC.js → chunk-BPTBCC7K.js} +9 -4
  26. package/dist/{chunk-AUKMJHJ7.js → chunk-CLB5CEKJ.js} +3 -3
  27. package/dist/{chunk-TGZ5RXOR.js → chunk-DFWU3T6T.js} +3 -3
  28. package/dist/{chunk-RUEXD2UR.js → chunk-DQX6APZ7.js} +3 -3
  29. package/dist/{chunk-7V5O7LKT.js → chunk-DZU2Z54P.js} +75 -75
  30. package/dist/{chunk-JFQDBJAJ.js → chunk-ETEUMLXG.js} +4 -4
  31. package/dist/{chunk-43EGEYB7.js → chunk-FCZFZS5D.js} +5 -5
  32. package/dist/{chunk-W6UL6CVM.js → chunk-HDUCYBDJ.js} +5 -5
  33. package/dist/{chunk-YGXFX272.js → chunk-HH6CL4YY.js} +4 -4
  34. package/dist/{chunk-AAMOUWCA.js → chunk-NTY5IMTJ.js} +3 -3
  35. package/dist/{chunk-F6BSBHJJ.js → chunk-NZDBLGNM.js} +4 -3
  36. package/dist/{chunk-HL64VUCA.js → chunk-RG3ZCNYG.js} +2 -2
  37. package/dist/{chunk-2BSR7GRJ.js → chunk-ROVTA24T.js} +3 -3
  38. package/dist/{chunk-J234SME4.js → chunk-RZAH6V72.js} +3 -3
  39. package/dist/{chunk-3VYZWAW4.js → chunk-SMD4PKJ4.js} +2 -2
  40. package/dist/{chunk-DCRMMYAV.js → chunk-T5OZRID5.js} +7 -7
  41. package/dist/{chunk-B5ORJYIJ.js → chunk-TLEQTJSL.js} +3 -3
  42. package/dist/{chunk-63P6ZWRY.js → chunk-UNEY6YDL.js} +2 -2
  43. package/dist/{chunk-BBI25NNF.js → chunk-UYB6BQ5X.js} +4 -4
  44. package/dist/{chunk-LLQ4TNJH.js → chunk-V4VZ6RSC.js} +2 -2
  45. package/dist/{chunk-3XL2MNVX.js → chunk-V7FFSXYT.js} +24 -11
  46. package/dist/{chunk-BZEWEVNQ.js → chunk-W44P3FXC.js} +2 -2
  47. package/dist/{chunk-YCRQGCGC.js → chunk-X5O6SBDL.js} +3 -3
  48. package/dist/{chunk-ZJQEUNZ4.js → chunk-ZEKYC6RR.js} +5 -5
  49. package/dist/cli/commands/auth/logout.js +13 -12
  50. package/dist/cli/commands/auth/logout.test.js +14 -13
  51. package/dist/cli/commands/debug/command-flags.js +12 -11
  52. package/dist/cli/commands/demo/catalog.js +13 -12
  53. package/dist/cli/commands/demo/generate-file.js +13 -12
  54. package/dist/cli/commands/demo/index.js +13 -12
  55. package/dist/cli/commands/demo/print-ai-prompt.js +13 -12
  56. package/dist/cli/commands/docs/generate.js +12 -11
  57. package/dist/cli/commands/docs/generate.test.js +12 -11
  58. package/dist/cli/commands/help.js +12 -11
  59. package/dist/cli/commands/kitchen-sink/async.js +13 -12
  60. package/dist/cli/commands/kitchen-sink/async.test.js +13 -12
  61. package/dist/cli/commands/kitchen-sink/index.js +15 -14
  62. package/dist/cli/commands/kitchen-sink/index.test.js +15 -14
  63. package/dist/cli/commands/kitchen-sink/prompts.js +13 -12
  64. package/dist/cli/commands/kitchen-sink/prompts.test.js +13 -12
  65. package/dist/cli/commands/kitchen-sink/static.js +13 -12
  66. package/dist/cli/commands/kitchen-sink/static.test.js +13 -12
  67. package/dist/cli/commands/search.js +13 -12
  68. package/dist/cli/commands/upgrade.js +13 -12
  69. package/dist/cli/commands/version.js +13 -12
  70. package/dist/cli/commands/version.test.js +13 -12
  71. package/dist/cli/services/commands/search.js +5 -4
  72. package/dist/cli/services/commands/search.test.js +5 -4
  73. package/dist/cli/services/commands/version.js +6 -5
  74. package/dist/cli/services/commands/version.test.js +7 -6
  75. package/dist/cli/services/demo.js +5 -4
  76. package/dist/cli/services/demo.test.js +5 -4
  77. package/dist/cli/services/kitchen-sink/async.js +5 -4
  78. package/dist/cli/services/kitchen-sink/prompts.js +5 -4
  79. package/dist/cli/services/kitchen-sink/static.js +5 -4
  80. package/dist/cli/services/upgrade.js +6 -5
  81. package/dist/cli/services/upgrade.test.js +8 -7
  82. package/dist/configs/all.yml +3 -0
  83. package/dist/configs/recommended.yml +3 -0
  84. package/dist/{constants-C6OOAW2P.js → constants-TR6ABVLJ.js} +4 -2
  85. package/dist/{custom-oclif-loader-4KICIK45.js → custom-oclif-loader-GZT2PBX4.js} +5 -4
  86. package/dist/data/default_setting_values.json +56 -0
  87. package/dist/data/filters.json +34 -2
  88. package/dist/data/latest.json +1 -1
  89. package/dist/data/objects.json +1644 -6
  90. package/dist/data/section.json +23 -1
  91. package/dist/data/setting.json +411 -2
  92. package/dist/data/shopify_system_translations.json +17 -4
  93. package/dist/data/tags.json +37 -0
  94. package/dist/{error-handler-UFJVKOUN.js → error-handler-H2JO5MGI.js} +11 -10
  95. package/dist/hooks/postrun.js +9 -8
  96. package/dist/hooks/prerun.js +9 -8
  97. package/dist/index.js +4317 -1907
  98. package/dist/{lib-6LEA5PZ7.js → lib-4WCTNKJK.js} +2 -2
  99. package/dist/lib-PPXZBVZX.js +6 -0
  100. package/dist/{local-EJNZF46J.js → local-PNRP6M3C.js} +5 -4
  101. package/dist/{morph-M726AOW6.js → morph-WDFBUXWF.js} +9 -9
  102. package/dist/{node-NWEY2HB4.js → node-FRKV7HYW.js} +16 -15
  103. package/dist/{node-package-manager-ZNXNWMEY.js → node-package-manager-XKAH57SF.js} +6 -5
  104. package/dist/{system-77XITWYJ.js → system-5YQPPSYJ.js} +7 -6
  105. package/dist/tsconfig.tsbuildinfo +1 -1
  106. package/dist/{ui-KJYD6TV3.js → ui-TWN6LBOI.js} +5 -4
  107. package/dist/{workerd-CCFQNJAE.js → workerd-EK4JHLXE.js} +15 -14
  108. package/oclif.manifest.json +86 -88
  109. package/package.json +7 -7
@@ -19,19 +19,22 @@ import {
19
19
  retryAwareRequest,
20
20
  sanitizedHeadersOutput,
21
21
  shopifyFetch
22
- } from "./chunk-UUUKSZ6D.js";
22
+ } from "./chunk-2A4NZDBL.js";
23
23
  import {
24
24
  base64URLEncode,
25
+ nonRandomUUID,
25
26
  randomBytes,
26
27
  randomHex,
27
28
  sha256
28
- } from "./chunk-IZJK3NZC.js";
29
+ } from "./chunk-BPTBCC7K.js";
29
30
  import {
30
31
  cacheRetrieveOrRepopulate,
32
+ getCachedPartnerAccountStatus,
31
33
  getSession,
32
34
  removeSession,
35
+ setCachedPartnerAccountStatus,
33
36
  setSession
34
- } from "./chunk-XC2GDHJG.js";
37
+ } from "./chunk-56GJOU7U.js";
35
38
  import {
36
39
  AbortError,
37
40
  BugError,
@@ -43,7 +46,6 @@ import {
43
46
  import_ts_error,
44
47
  isCloudEnvironment,
45
48
  isSpin,
46
- isSpinEnvironment,
47
49
  isTTY,
48
50
  isTruthy,
49
51
  keypress,
@@ -61,10 +63,10 @@ import {
61
63
  spinFqdn,
62
64
  stringifyMessage,
63
65
  useDeviceAuth
64
- } from "./chunk-JDW4FALN.js";
66
+ } from "./chunk-7QTS6ZWN.js";
65
67
  import {
66
68
  sessionConstants
67
- } from "./chunk-F6BSBHJJ.js";
69
+ } from "./chunk-NZDBLGNM.js";
68
70
  import {
69
71
  moduleDirectory
70
72
  } from "./chunk-T2GATXSP.js";
@@ -3014,8 +3016,17 @@ async function identityFqdn() {
3014
3016
  }
3015
3017
  }
3016
3018
  async function normalizeStoreFqdn(store2) {
3017
- let storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, ""), addDomain = async (storeFqdn2) => isSpinEnvironment() ? `${storeFqdn2}.shopify.${await spinFqdn()}` : `${storeFqdn2}.myshopify.com`;
3018
- return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
3019
+ let storeFqdn = store2.replace(/^https?:\/\//, "").replace(/\/$/, ""), addDomain = async (storeFqdn2) => {
3020
+ switch (serviceEnvironment()) {
3021
+ case "local":
3022
+ return `${storeFqdn2}.myshopify.io`;
3023
+ case "spin":
3024
+ return `${storeFqdn2}.shopify.${await spinFqdn()}`;
3025
+ default:
3026
+ return `${storeFqdn2}.myshopify.com`;
3027
+ }
3028
+ };
3029
+ return ((storeFqdn2) => storeFqdn2.includes(".myshopify.com") || storeFqdn2.includes("spin.dev") || storeFqdn2.includes("shopify.io"))(storeFqdn) ? storeFqdn : addDomain(storeFqdn);
3019
3030
  }
3020
3031
 
3021
3032
  // ../cli-kit/dist/private/node/session/store.js
@@ -3027,7 +3038,8 @@ var DateSchema = z.preprocess((arg) => typeof arg == "string" || arg instanceof
3027
3038
  accessToken: z.string(),
3028
3039
  refreshToken: z.string(),
3029
3040
  expiresAt: DateSchema,
3030
- scopes: z.array(z.string())
3041
+ scopes: z.array(z.string()),
3042
+ userId: z.string()
3031
3043
  }), ApplicationTokenSchema = z.object({
3032
3044
  accessToken: z.string(),
3033
3045
  expiresAt: DateSchema,
@@ -3045,6 +3057,9 @@ var DateSchema = z.preprocess((arg) => typeof arg == "string" || arg instanceof
3045
3057
  */
3046
3058
  applications: z.object({}).catchall(ApplicationTokenSchema)
3047
3059
  }));
3060
+ function validateCachedIdentityTokenStructure(identityToken) {
3061
+ return IdentityTokenSchema.safeParse(identityToken).success;
3062
+ }
3048
3063
 
3049
3064
  // ../cli-kit/dist/private/node/session/store.js
3050
3065
  async function store(session) {
@@ -3212,9 +3227,103 @@ var ok = (value) => new Ok(value), err = (err2) => new Err(err2), Ok = class {
3212
3227
  }
3213
3228
  };
3214
3229
 
3230
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/index.js
3231
+ init_cjs_shims();
3232
+
3233
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/runtime/base64url.js
3234
+ init_cjs_shims();
3235
+ import { Buffer } from "node:buffer";
3236
+
3237
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/lib/buffer_utils.js
3238
+ init_cjs_shims();
3239
+ var encoder = new TextEncoder(), decoder = new TextDecoder(), MAX_INT32 = 2 ** 32;
3240
+
3241
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/runtime/base64url.js
3242
+ function normalize(input) {
3243
+ let encoded = input;
3244
+ return encoded instanceof Uint8Array && (encoded = decoder.decode(encoded)), encoded;
3245
+ }
3246
+ var decode = (input) => new Uint8Array(Buffer.from(normalize(input), "base64"));
3247
+
3248
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/util/errors.js
3249
+ init_cjs_shims();
3250
+ var JOSEError = class extends Error {
3251
+ static get code() {
3252
+ return "ERR_JOSE_GENERIC";
3253
+ }
3254
+ code = "ERR_JOSE_GENERIC";
3255
+ constructor(message) {
3256
+ super(message), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
3257
+ }
3258
+ };
3259
+ var JWTInvalid = class extends JOSEError {
3260
+ static get code() {
3261
+ return "ERR_JWT_INVALID";
3262
+ }
3263
+ code = "ERR_JWT_INVALID";
3264
+ };
3265
+ var JWKSMultipleMatchingKeys = class extends JOSEError {
3266
+ [Symbol.asyncIterator];
3267
+ static get code() {
3268
+ return "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
3269
+ }
3270
+ code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
3271
+ message = "multiple matching keys found in the JSON Web Key Set";
3272
+ };
3273
+
3274
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/lib/is_object.js
3275
+ init_cjs_shims();
3276
+ function isObjectLike(value) {
3277
+ return typeof value == "object" && value !== null;
3278
+ }
3279
+ function isObject(input) {
3280
+ if (!isObjectLike(input) || Object.prototype.toString.call(input) !== "[object Object]")
3281
+ return !1;
3282
+ if (Object.getPrototypeOf(input) === null)
3283
+ return !0;
3284
+ let proto = input;
3285
+ for (; Object.getPrototypeOf(proto) !== null; )
3286
+ proto = Object.getPrototypeOf(proto);
3287
+ return Object.getPrototypeOf(input) === proto;
3288
+ }
3289
+
3290
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/util/base64url.js
3291
+ init_cjs_shims();
3292
+ var decode2 = decode;
3293
+
3294
+ // ../../node_modules/.pnpm/jose@5.8.0/node_modules/jose/dist/node/esm/util/decode_jwt.js
3295
+ init_cjs_shims();
3296
+ function decodeJwt(jwt) {
3297
+ if (typeof jwt != "string")
3298
+ throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
3299
+ let { 1: payload, length } = jwt.split(".");
3300
+ if (length === 5)
3301
+ throw new JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");
3302
+ if (length !== 3)
3303
+ throw new JWTInvalid("Invalid JWT");
3304
+ if (!payload)
3305
+ throw new JWTInvalid("JWTs must contain a payload");
3306
+ let decoded;
3307
+ try {
3308
+ decoded = decode2(payload);
3309
+ } catch {
3310
+ throw new JWTInvalid("Failed to base64url decode the payload");
3311
+ }
3312
+ let result;
3313
+ try {
3314
+ result = JSON.parse(decoder.decode(decoded));
3315
+ } catch {
3316
+ throw new JWTInvalid("Failed to parse the decoded payload as JSON");
3317
+ }
3318
+ if (!isObject(result))
3319
+ throw new JWTInvalid("Invalid JWT Claims Set");
3320
+ return result;
3321
+ }
3322
+
3215
3323
  // ../cli-kit/dist/private/node/session/exchange.js
3216
3324
  var InvalidGrantError = class extends import_ts_error.ExtendableError {
3217
3325
  }, InvalidRequestError = class extends import_ts_error.ExtendableError {
3326
+ }, InvalidTargetError = class extends AbortError {
3218
3327
  };
3219
3328
  async function exchangeCodeForAccessToken(codeData) {
3220
3329
  let clientId2 = await clientId(), params = {
@@ -3249,7 +3358,7 @@ async function refreshAccessToken(currentToken) {
3249
3358
  refresh_token: currentToken.refreshToken,
3250
3359
  client_id: clientId2
3251
3360
  }, value = (await tokenRequest(params)).mapError(tokenRequestErrorHandler).valueOrBug();
3252
- return buildIdentityToken(value);
3361
+ return buildIdentityToken(value, currentToken.userId);
3253
3362
  }
3254
3363
  async function exchangeCustomPartnerToken(token) {
3255
3364
  let appId = applicationId("partners");
@@ -3286,7 +3395,12 @@ async function requestAppToken(api, token, scopes = [], store2) {
3286
3395
  return { [identifier]: appToken };
3287
3396
  }
3288
3397
  function tokenRequestErrorHandler(error) {
3289
- return error === "invalid_grant" ? new InvalidGrantError() : error === "invalid_request" ? new InvalidRequestError() : new AbortError(error);
3398
+ let invalidTargetErrorMessage = `You are not authorized to use the CLI to develop in the provided store.
3399
+
3400
+ You can't use Shopify CLI with development stores if you only have Partner staff member access. If you want to use Shopify CLI to work on a development store, then you should be the store owner or create a staff account on the store.
3401
+
3402
+ If you're the store owner, then you need to log in to the store directly using the store URL at least once before you log in using Shopify CLI.Logging in to the Shopify admin directly connects the development store with your Shopify login.`;
3403
+ return error === "invalid_grant" ? new InvalidGrantError() : error === "invalid_request" ? new InvalidRequestError() : error === "invalid_target" ? new InvalidTargetError(invalidTargetErrorMessage) : new AbortError(error);
3290
3404
  }
3291
3405
  async function tokenRequest(params) {
3292
3406
  let fqdn = await identityFqdn(), url2 = new URL(`https://${fqdn}/oauth/token`);
@@ -3294,12 +3408,16 @@ async function tokenRequest(params) {
3294
3408
  let res = await shopifyFetch(url2.href, { method: "POST" }), payload = await res.json();
3295
3409
  return res.ok ? ok(payload) : err(payload.error);
3296
3410
  }
3297
- function buildIdentityToken(result) {
3411
+ function buildIdentityToken(result, existingUserId) {
3412
+ let userId = existingUserId ?? (result.id_token ? decodeJwt(result.id_token).sub : void 0);
3413
+ if (!userId)
3414
+ throw new BugError("Error setting userId for session. No id_token or pre-existing user ID provided.");
3298
3415
  return {
3299
3416
  accessToken: result.access_token,
3300
3417
  refreshToken: result.refresh_token,
3301
3418
  expiresAt: new Date(Date.now() + result.expires_in * 1e3),
3302
- scopes: result.scope.split(" ")
3419
+ scopes: result.scope.split(" "),
3420
+ userId
3303
3421
  };
3304
3422
  }
3305
3423
  function buildApplicationToken(result) {
@@ -3391,7 +3509,7 @@ async function validateSession(scopes, applications, session) {
3391
3509
  The validation of the token for application/identity completed with the following results:
3392
3510
  - It's expired: ${tokensAreExpired}
3393
3511
  - It's invalid in identity: ${!identityIsValid}
3394
- `), tokensAreExpired ? "needs_refresh" : identityIsValid ? "ok" : "needs_full_auth";
3512
+ `), validateCachedIdentityTokenStructure(session.identity) ? tokensAreExpired ? "needs_refresh" : identityIsValid ? "ok" : "needs_full_auth" : "needs_full_auth";
3395
3513
  }
3396
3514
  function isTokenExpired(token) {
3397
3515
  return token ? token.expiresAt < expireThreshold() : !0;
@@ -3880,19 +3998,6 @@ async function partnersRequestDoc(query, token, variables) {
3880
3998
  variables
3881
3999
  }));
3882
4000
  }
3883
- var FunctionUploadUrlGenerateMutation = gql`
3884
- mutation functionUploadUrlGenerateMutation {
3885
- functionUploadUrlGenerate {
3886
- generatedUrlDetails {
3887
- url
3888
- moduleId
3889
- headers
3890
- maxBytes
3891
- maxSize
3892
- }
3893
- }
3894
- }
3895
- `;
3896
4001
  function handleDeprecations(response) {
3897
4002
  if (!response.extensions)
3898
4003
  return;
@@ -3939,7 +4044,7 @@ Error validating auth session`, "We've cleared the current session, please try a
3939
4044
  let completeSession = { ...currentSession, ...newSession };
3940
4045
  Object.keys(newSession).length > 0 && await store(completeSession);
3941
4046
  let tokens = await tokensFor(applications, completeSession, fqdn), envToken = getPartnersToken();
3942
- return envToken && applications.partnersApi && (tokens.partners = (await exchangeCustomPartnerToken(envToken)).accessToken), !envToken && tokens.partners && await ensureUserHasPartnerAccount(tokens.partners), tokens;
4047
+ return envToken && applications.partnersApi && (tokens.partners = (await exchangeCustomPartnerToken(envToken)).accessToken), !envToken && tokens.partners && await ensureUserHasPartnerAccount(tokens.partners, tokens.userId), tokens;
3943
4048
  }
3944
4049
  async function executeCompleteFlow(applications, identityFqdn2) {
3945
4050
  let scopes = getFlattenScopes(applications), exchangeScopes = getExchangeScopes(applications), store2 = applications.adminApi?.storeFqdn;
@@ -3965,9 +4070,9 @@ async function executeCompleteFlow(applications, identityFqdn2) {
3965
4070
  };
3966
4071
  return outputCompleted("Logged in."), session;
3967
4072
  }
3968
- async function ensureUserHasPartnerAccount(partnersToken) {
3969
- if (!isTruthy(process.env.USE_APP_MANAGEMENT_API) && (outputDebug(outputContent`Verifying that the user has a Partner organization`), !await hasPartnerAccount(partnersToken) && (outputInfo(`
3970
- A Shopify Partners organization is needed to proceed.`), outputInfo("\u{1F449} Press any key to create one"), await keypress(), await openURL(`https://${await partnersFqdn()}/signup`), outputInfo(outputContent`👉 Press any key when you have ${outputToken.cyan("created the organization")}`), outputWarn(outputContent`Make sure you've confirmed your Shopify and the Partner organization from the email`), await keypress(), !await hasPartnerAccount(partnersToken))))
4073
+ async function ensureUserHasPartnerAccount(partnersToken, userId) {
4074
+ if (!isTruthy(process.env.USE_APP_MANAGEMENT_API) && (outputDebug(outputContent`Verifying that the user has a Partner organization`), !await hasPartnerAccount(partnersToken, userId) && (outputInfo(`
4075
+ A Shopify Partners organization is needed to proceed.`), outputInfo("\u{1F449} Press any key to create one"), await keypress(), await openURL(`https://${await partnersFqdn()}/signup`), outputInfo(outputContent`👉 Press any key when you have ${outputToken.cyan("created the organization")}`), outputWarn(outputContent`Make sure you've confirmed your Shopify and the Partner organization from the email`), await keypress(), !await hasPartnerAccount(partnersToken, userId))))
3971
4076
  throw new AbortError("Couldn't find your Shopify Partners organization", "Have you confirmed your accounts from the emails you received?");
3972
4077
  }
3973
4078
  var getFirstOrganization = gql`
@@ -3979,9 +4084,12 @@ var getFirstOrganization = gql`
3979
4084
  }
3980
4085
  }
3981
4086
  `;
3982
- async function hasPartnerAccount(partnersToken) {
4087
+ async function hasPartnerAccount(partnersToken, userId) {
4088
+ let cacheKey = userId ?? partnersToken;
4089
+ if (getCachedPartnerAccountStatus(cacheKey))
4090
+ return outputDebug("Confirmed partner account exists from cache"), !0;
3983
4091
  try {
3984
- return await partnersRequest(getFirstOrganization, partnersToken), !0;
4092
+ return await partnersRequest(getFirstOrganization, partnersToken), setCachedPartnerAccountStatus(cacheKey), !0;
3985
4093
  } catch (error) {
3986
4094
  return !(error instanceof RequestClientError && error.statusCode === 404);
3987
4095
  }
@@ -3999,7 +4107,9 @@ async function tokensFor(applications, session, fqdn) {
3999
4107
  let fqdnSession = session[fqdn];
4000
4108
  if (!fqdnSession)
4001
4109
  throw new BugError("No session found after ensuring authenticated");
4002
- let tokens = {};
4110
+ let tokens = {
4111
+ userId: fqdnSession.identity.userId
4112
+ };
4003
4113
  if (applications.adminApi) {
4004
4114
  let appId = applicationId("admin"), realAppId = `${applications.adminApi.storeFqdn}-${appId}`, token = fqdnSession.applications[realAppId]?.accessToken;
4005
4115
  token && (tokens.admin = { token, storeFqdn: applications.adminApi.storeFqdn });
@@ -4051,11 +4161,11 @@ ${outputToken.json(scopes)}
4051
4161
  `);
4052
4162
  let envToken = getPartnersToken();
4053
4163
  if (envToken)
4054
- return (await exchangeCustomPartnerToken(envToken)).accessToken;
4164
+ return { token: (await exchangeCustomPartnerToken(envToken)).accessToken, userId: nonRandomUUID(envToken) };
4055
4165
  let tokens = await ensureAuthenticated({ partnersApi: { scopes } }, env, options2);
4056
4166
  if (!tokens.partners)
4057
4167
  throw new BugError("No partners token found after ensuring authenticated");
4058
- return tokens.partners;
4168
+ return { token: tokens.partners, userId: tokens.userId };
4059
4169
  }
4060
4170
  async function ensureAuthenticatedAppManagement(scopes = [], env = process.env, options2 = {}) {
4061
4171
  outputDebug(outputContent`Ensuring that the user is authenticated with the App Management API with the following scopes:
@@ -4064,7 +4174,7 @@ ${outputToken.json(scopes)}
4064
4174
  let tokens = await ensureAuthenticated({ appManagementApi: { scopes } }, env, options2);
4065
4175
  if (!tokens)
4066
4176
  throw new BugError("No App Management token found after ensuring authenticated");
4067
- return tokens.appManagement;
4177
+ return { token: tokens.appManagement, userId: tokens.userId };
4068
4178
  }
4069
4179
  async function ensureAuthenticatedStorefront(scopes = [], password = void 0, forceRefresh = !1) {
4070
4180
  if (password)
@@ -4122,7 +4232,6 @@ export {
4122
4232
  require_lib,
4123
4233
  partnersRequest,
4124
4234
  partnersRequestDoc,
4125
- FunctionUploadUrlGenerateMutation,
4126
4235
  handleDeprecations,
4127
4236
  ensureAuthenticatedPartners,
4128
4237
  ensureAuthenticatedAppManagement,
@@ -4132,4 +4241,4 @@ export {
4132
4241
  ensureAuthenticatedBusinessPlatform,
4133
4242
  logout
4134
4243
  };
4135
- //# sourceMappingURL=chunk-D2RO6JR3.js.map
4244
+ //# sourceMappingURL=chunk-33B37WAX.js.map
@@ -19,10 +19,10 @@ import {
19
19
  require_get_stream,
20
20
  runWithTimer,
21
21
  writeFile
22
- } from "./chunk-JDW4FALN.js";
22
+ } from "./chunk-7QTS6ZWN.js";
23
23
  import {
24
24
  envPaths
25
- } from "./chunk-F6BSBHJJ.js";
25
+ } from "./chunk-NZDBLGNM.js";
26
26
  import {
27
27
  dirname,
28
28
  joinPath
@@ -9902,8 +9902,29 @@ function timeIntervalToMilliseconds({ days = 0, hours = 0, minutes = 0, seconds
9902
9902
  }
9903
9903
  async function runAtMinimumInterval(key, timeout, task, config = cliKitStore()) {
9904
9904
  let cache = config.get("cache") || {}, cacheKey = `most-recent-occurrence-${key}`, cached = cache[cacheKey];
9905
- if (!(cached?.value !== void 0 && Date.now() - cached.timestamp < timeIntervalToMilliseconds(timeout)))
9906
- return await task(), cache[cacheKey] = { value: !0, timestamp: Date.now() }, config.set("cache", cache), !0;
9905
+ return cached?.value !== void 0 && Date.now() - cached.timestamp < timeIntervalToMilliseconds(timeout) ? !1 : (await task(), cache[cacheKey] = { value: !0, timestamp: Date.now() }, config.set("cache", cache), !0);
9906
+ }
9907
+ async function runWithRateLimit(options, config = cliKitStore()) {
9908
+ let { key, limit, timeout, task } = options, cache = config.get("cache") || {}, cacheKey = `rate-limited-occurrences-${key}`, cached = cache[cacheKey], now = Date.now();
9909
+ if (cached?.value) {
9910
+ let windowStart = now - timeIntervalToMilliseconds(timeout), occurrences = cached.value.filter((occurrence) => occurrence >= windowStart);
9911
+ if (occurrences.length >= limit)
9912
+ return cache[cacheKey] = { value: occurrences, timestamp: Date.now() }, config.set("cache", cache), !1;
9913
+ await task(), cache[cacheKey] = { value: [...occurrences, now], timestamp: now };
9914
+ } else
9915
+ await task(), cache[cacheKey] = { value: [now], timestamp: now };
9916
+ return config.set("cache", cache), !0;
9917
+ }
9918
+ function getConfigStoreForPartnerStatus() {
9919
+ return new LocalStorage({
9920
+ projectName: "shopify-cli-kit-partner-status"
9921
+ });
9922
+ }
9923
+ function getCachedPartnerAccountStatus(partnersToken) {
9924
+ return partnersToken && getConfigStoreForPartnerStatus().get(partnersToken) ? !0 : null;
9925
+ }
9926
+ function setCachedPartnerAccountStatus(partnersToken) {
9927
+ getConfigStoreForPartnerStatus().set(partnersToken, { status: !0, checkedAt: (/* @__PURE__ */ new Date()).toISOString() });
9907
9928
  }
9908
9929
 
9909
9930
  // ../../node_modules/.pnpm/latest-version@7.0.0/node_modules/latest-version/index.js
@@ -13875,6 +13896,9 @@ export {
13875
13896
  removeSession,
13876
13897
  cacheRetrieveOrRepopulate,
13877
13898
  runAtMinimumInterval,
13899
+ runWithRateLimit,
13900
+ getCachedPartnerAccountStatus,
13901
+ setCachedPartnerAccountStatus,
13878
13902
  yarnLockfile,
13879
13903
  npmLockfile,
13880
13904
  pnpmLockfile,
@@ -13938,4 +13962,4 @@ deep-extend/lib/deep-extend.js:
13938
13962
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13939
13963
  *)
13940
13964
  */
13941
- //# sourceMappingURL=chunk-XC2GDHJG.js.map
13965
+ //# sourceMappingURL=chunk-56GJOU7U.js.map
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  base_command_default
3
- } from "./chunk-DCRMMYAV.js";
3
+ } from "./chunk-T5OZRID5.js";
4
4
  import {
5
5
  mkdir,
6
6
  outputInfo,
7
7
  rmdir,
8
8
  writeFile
9
- } from "./chunk-JDW4FALN.js";
9
+ } from "./chunk-7QTS6ZWN.js";
10
10
  import {
11
11
  cwd,
12
12
  joinPath
@@ -116,4 +116,4 @@ export {
116
116
  writeCommandFlagInterface,
117
117
  writeCommandUsageExampleFile
118
118
  };
119
- //# sourceMappingURL=chunk-WX53MNQL.js.map
119
+ //# sourceMappingURL=chunk-66CAOMYB.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  prompts
3
- } from "./chunk-63P6ZWRY.js";
3
+ } from "./chunk-UNEY6YDL.js";
4
4
  import {
5
5
  base_command_default
6
- } from "./chunk-DCRMMYAV.js";
6
+ } from "./chunk-T5OZRID5.js";
7
7
  import {
8
8
  init_cjs_shims
9
9
  } from "./chunk-POZ5MGPT.js";
@@ -25,4 +25,4 @@ var KitchenSinkPrompts = class extends base_command_default {
25
25
  export {
26
26
  KitchenSinkPrompts
27
27
  };
28
- //# sourceMappingURL=chunk-UVGRJGX3.js.map
28
+ //# sourceMappingURL=chunk-6JA2FWML.js.map
@@ -7,7 +7,7 @@ import {
7
7
  renderSuccess,
8
8
  renderTable,
9
9
  renderWarning
10
- } from "./chunk-JDW4FALN.js";
10
+ } from "./chunk-7QTS6ZWN.js";
11
11
  import {
12
12
  init_cjs_shims
13
13
  } from "./chunk-POZ5MGPT.js";
@@ -185,4 +185,4 @@ async function staticService() {
185
185
  export {
186
186
  staticService
187
187
  };
188
- //# sourceMappingURL=chunk-PBJ5OTM2.js.map
188
+ //# sourceMappingURL=chunk-6RGB2VE4.js.map