@shopify/create-app 3.84.2 → 3.85.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.
@@ -3,11 +3,12 @@ import {
3
3
  fetch,
4
4
  getEnvironmentData,
5
5
  getLastSeenUserIdAfterAuth,
6
- getSensitiveEnvironmentData
7
- } from "./chunk-5OIQQPNB.js";
6
+ getSensitiveEnvironmentData,
7
+ requestIdsCollection
8
+ } from "./chunk-JZCHSJAA.js";
8
9
  import {
9
10
  runWithRateLimit
10
- } from "./chunk-REUQOPSX.js";
11
+ } from "./chunk-PGTPDPDU.js";
11
12
  import {
12
13
  alwaysLogAnalytics,
13
14
  alwaysLogMetrics,
@@ -17,14 +18,13 @@ import {
17
18
  getArrayContainsDuplicates,
18
19
  getArrayRejectingUndefined,
19
20
  isShopify,
20
- isSpinEnvironment,
21
21
  isUnitTest,
22
22
  opentelemetryDomain,
23
23
  outputContent,
24
24
  outputDebug,
25
25
  outputToken,
26
26
  reportingRateLimit
27
- } from "./chunk-UVDRANBC.js";
27
+ } from "./chunk-POCJD2ES.js";
28
28
  import {
29
29
  __commonJS,
30
30
  __esm,
@@ -15499,6 +15499,165 @@ var buildHeaders = (currentTime) => ({
15499
15499
  "X-Monorail-Edge-Event-Sent-At-Ms": currentTime.toString()
15500
15500
  });
15501
15501
 
15502
+ // ../cli-kit/dist/private/node/analytics/storage.js
15503
+ init_cjs_shims();
15504
+
15505
+ // ../cli-kit/dist/private/node/analytics/error-categorizer.js
15506
+ init_cjs_shims();
15507
+ var ErrorCategory;
15508
+ (function(ErrorCategory2) {
15509
+ ErrorCategory2.Liquid = "LIQUID", ErrorCategory2.ThemeCheck = "THEME_CHECK", ErrorCategory2.Network = "NETWORK", ErrorCategory2.FileSystem = "FILE_SYSTEM", ErrorCategory2.Authentication = "AUTHENTICATION", ErrorCategory2.Validation = "VALIDATION", ErrorCategory2.Permission = "PERMISSION", ErrorCategory2.RateLimit = "RATE_LIMIT", ErrorCategory2.Json = "JSON", ErrorCategory2.Unknown = "UNKNOWN";
15510
+ })(ErrorCategory || (ErrorCategory = {}));
15511
+ var ERROR_CATEGORY_TERMS = {
15512
+ [ErrorCategory.Liquid]: ["liquid"],
15513
+ [ErrorCategory.Json]: ["json", "parse response"],
15514
+ [ErrorCategory.ThemeCheck]: ["theme check"],
15515
+ [ErrorCategory.Authentication]: ["unauthorized", "forbidden", "auth", "token", "credential"],
15516
+ [ErrorCategory.Network]: [
15517
+ "eai_again",
15518
+ "econn",
15519
+ "enetunreach",
15520
+ "enotfound",
15521
+ "epipe",
15522
+ "etimedout",
15523
+ "fetch",
15524
+ "network",
15525
+ "request",
15526
+ "socket",
15527
+ "the operation was aborted",
15528
+ "timed out",
15529
+ "timeout"
15530
+ ],
15531
+ [ErrorCategory.FileSystem]: ["enoent", "eacces", "file", "directory", "path"],
15532
+ [ErrorCategory.Permission]: ["permission", "denied", "access", "insufficient"],
15533
+ [ErrorCategory.RateLimit]: ["rate limit", "too many requests", "throttle"],
15534
+ [ErrorCategory.Validation]: ["validation", "invalid", "required"]
15535
+ };
15536
+ function categorizeError(error) {
15537
+ if (!(error instanceof Error))
15538
+ return ErrorCategory.Unknown;
15539
+ let message = error.message.toLowerCase();
15540
+ for (let [category, terms] of Object.entries(ERROR_CATEGORY_TERMS))
15541
+ if (terms.some((term) => message.includes(term)))
15542
+ return category;
15543
+ return ErrorCategory.Unknown;
15544
+ }
15545
+ function formatErrorMessage(error, category) {
15546
+ let message = error instanceof Error ? error.message : String(error);
15547
+ return (ERROR_FORMATTERS[category] || formatGenericError)(message);
15548
+ }
15549
+ var ERROR_FORMATTERS = {
15550
+ [ErrorCategory.Network]: formatNetworkError,
15551
+ [ErrorCategory.Authentication]: formatGenericError,
15552
+ [ErrorCategory.FileSystem]: formatGenericError,
15553
+ [ErrorCategory.RateLimit]: formatGenericError,
15554
+ [ErrorCategory.Json]: formatGenericError,
15555
+ [ErrorCategory.Validation]: formatGenericError,
15556
+ [ErrorCategory.Permission]: formatGenericError,
15557
+ [ErrorCategory.Liquid]: formatGenericError,
15558
+ [ErrorCategory.ThemeCheck]: formatGenericError,
15559
+ [ErrorCategory.Unknown]: formatGenericError
15560
+ };
15561
+ function formatNetworkError(message) {
15562
+ let httpStatusMatch = message.match(/\b([1-5]\d{2})\b/), connectionErrorMatch = message.match(/\b(E[A-Z]+)\b/), graphqlCodeMatch = message.match(/(?:code|error)[:\s]*(\d{3})/i), normalized = message.toLowerCase().substring(0, 50);
15563
+ return httpStatusMatch?.[1] ? normalized = `http-${httpStatusMatch[1]}-${normalized.replace(/\b\d{3}\b/g, "").trim()}` : graphqlCodeMatch?.[1] ? normalized = `http-${graphqlCodeMatch[1]}-${normalized.replace(/(?:code|error)[:\s]*\d{3}/gi, "").trim()}` : connectionErrorMatch?.[1] ? normalized = `http-000-${connectionErrorMatch[1].toLowerCase()}-${normalized.replace(/\b[eE][A-Z]+\b/g, "").trim()}` : normalized = `http-000-${normalized}`, normalized.replace(/[^a-zA-Z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").substring(0, 50);
15564
+ }
15565
+ function formatGenericError(message) {
15566
+ return message.toLowerCase().substring(0, 50).replace(/[^a-zA-Z0-9]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
15567
+ }
15568
+
15569
+ // ../cli-kit/dist/private/node/analytics/bounded-collections.js
15570
+ init_cjs_shims();
15571
+ var BArray = class extends Array {
15572
+ push(...items) {
15573
+ let result = super.push(...items);
15574
+ return this.enforceLimit(), result;
15575
+ }
15576
+ clear() {
15577
+ this.length = 0;
15578
+ }
15579
+ toArray() {
15580
+ return [...this];
15581
+ }
15582
+ enforceLimit() {
15583
+ for (; this.length > 1e3; )
15584
+ this.shift();
15585
+ }
15586
+ }, BMap = class extends Map {
15587
+ constructor() {
15588
+ super(...arguments), this.insertionOrder = [];
15589
+ }
15590
+ set(key, value) {
15591
+ return this.has(key) || this.insertionOrder.push(key), super.set(key, value), this.enforceLimit(), this;
15592
+ }
15593
+ delete(key) {
15594
+ let index = this.insertionOrder.indexOf(key);
15595
+ return index > -1 && this.insertionOrder.splice(index, 1), super.delete(key);
15596
+ }
15597
+ clear() {
15598
+ this.insertionOrder = [], super.clear();
15599
+ }
15600
+ toObject() {
15601
+ return Object.fromEntries(this);
15602
+ }
15603
+ enforceLimit() {
15604
+ for (; this.size > 1e3 && this.insertionOrder.length > 0; ) {
15605
+ let oldestKey = this.insertionOrder.shift();
15606
+ oldestKey !== void 0 && super.delete(oldestKey);
15607
+ }
15608
+ }
15609
+ };
15610
+
15611
+ // ../cli-kit/dist/private/node/analytics/storage.js
15612
+ var _runtimeAnalyticsStore = {
15613
+ timings: new BArray(),
15614
+ activeTimings: new BMap(),
15615
+ errors: new BArray(),
15616
+ retries: new BArray(),
15617
+ events: new BArray()
15618
+ };
15619
+ function recordTiming(eventName) {
15620
+ let now = Date.now();
15621
+ if (!_runtimeAnalyticsStore.activeTimings.has(eventName)) {
15622
+ _runtimeAnalyticsStore.activeTimings.set(eventName, now), recordEvent(`timing:start:${eventName}`);
15623
+ return;
15624
+ }
15625
+ let startTime = _runtimeAnalyticsStore.activeTimings.get(eventName);
15626
+ if (startTime === void 0)
15627
+ return;
15628
+ let duration = now - startTime;
15629
+ _runtimeAnalyticsStore.timings.push({
15630
+ event: eventName,
15631
+ duration
15632
+ }), _runtimeAnalyticsStore.activeTimings.delete(eventName), recordEvent(`timing:end:${eventName}`);
15633
+ }
15634
+ function recordError(error) {
15635
+ let category = categorizeError(error), errorEntry = {
15636
+ category,
15637
+ message: (error instanceof Error ? error.message : String(error)).substring(0, 200),
15638
+ timestamp: Date.now()
15639
+ };
15640
+ if (errorEntry.category === ErrorCategory.Unknown && !errorEntry.message)
15641
+ return;
15642
+ _runtimeAnalyticsStore.errors.push(errorEntry);
15643
+ let normalizedErrorCategory = category.toLowerCase(), normalizedErrorMessage = formatErrorMessage(error, category);
15644
+ recordEvent(`error:${normalizedErrorCategory}:${normalizedErrorMessage}`);
15645
+ }
15646
+ function recordEvent(eventName) {
15647
+ _runtimeAnalyticsStore.events.push({
15648
+ name: eventName,
15649
+ timestamp: Date.now()
15650
+ });
15651
+ }
15652
+ function compileData() {
15653
+ return {
15654
+ timings: _runtimeAnalyticsStore.timings.toArray(),
15655
+ errors: _runtimeAnalyticsStore.errors.toArray(),
15656
+ retries: _runtimeAnalyticsStore.retries.toArray(),
15657
+ events: _runtimeAnalyticsStore.events.toArray()
15658
+ };
15659
+ }
15660
+
15502
15661
  // ../cli-kit/dist/private/node/otel-metrics.js
15503
15662
  init_cjs_shims();
15504
15663
 
@@ -15764,7 +15923,7 @@ function defaultOtelOptions() {
15764
15923
  }
15765
15924
  function createMetricRecorder(options) {
15766
15925
  let recorder = "console";
15767
- return options.skipMetricAnalytics || isUnitTest() || isSpinEnvironment() || (recorder = {
15926
+ return options.skipMetricAnalytics || isUnitTest() || (recorder = {
15768
15927
  type: "otel",
15769
15928
  otel: globalOtelService(options)
15770
15929
  }), recorder;
@@ -15794,36 +15953,6 @@ function recordCommandTiming(recorder, labels, timing) {
15794
15953
  timing.active > 0 && (recorder.otel.record(Name.Duration, timing.active, labels), recorder.otel.record(Name.Elapsed, timing.active, { ...labels, stage: "active" })), timing.network > 0 && recorder.otel.record(Name.Elapsed, timing.network, { ...labels, stage: "network" }), timing.prompt > 0 && recorder.otel.record(Name.Elapsed, timing.prompt, { ...labels, stage: "prompt" });
15795
15954
  }
15796
15955
 
15797
- // ../cli-kit/dist/private/node/request-ids.js
15798
- init_cjs_shims();
15799
- var RequestIDCollection = class _RequestIDCollection {
15800
- constructor() {
15801
- this.requestIds = [];
15802
- }
15803
- static getInstance() {
15804
- return _RequestIDCollection.instance || (_RequestIDCollection.instance = new _RequestIDCollection()), _RequestIDCollection.instance;
15805
- }
15806
- /**
15807
- * Add a request ID to the collection
15808
- * We only report the first MAX_REQUEST_IDS request IDs.
15809
- */
15810
- addRequestId(requestId) {
15811
- requestId && this.requestIds.length < 100 && this.requestIds.push(requestId);
15812
- }
15813
- /**
15814
- * Get all collected request IDs
15815
- */
15816
- getRequestIds() {
15817
- return this.requestIds;
15818
- }
15819
- /**
15820
- * Clear all stored request IDs
15821
- */
15822
- clear() {
15823
- this.requestIds = [];
15824
- }
15825
- }, requestIdsCollection = RequestIDCollection.getInstance();
15826
-
15827
15956
  // ../cli-kit/dist/public/node/analytics.js
15828
15957
  async function reportAnalyticsEvent(options) {
15829
15958
  try {
@@ -15920,11 +16049,26 @@ function sanitizePayload2(payload) {
15920
16049
  let sanitizedPayloadString = JSON.stringify(payload).replace(/shptka_\w*/g, "*****");
15921
16050
  return JSON.parse(sanitizedPayloadString);
15922
16051
  }
16052
+ function recordTiming2(eventName) {
16053
+ recordTiming(eventName);
16054
+ }
16055
+ function recordError2(error) {
16056
+ return recordError(error), error;
16057
+ }
16058
+ function recordEvent2(eventName) {
16059
+ recordEvent(eventName);
16060
+ }
16061
+ function compileData2() {
16062
+ return compileData();
16063
+ }
15923
16064
 
15924
16065
  export {
15925
16066
  fanoutHooks,
15926
16067
  getListOfTunnelPlugins,
15927
- requestIdsCollection,
15928
- reportAnalyticsEvent
16068
+ reportAnalyticsEvent,
16069
+ recordTiming2 as recordTiming,
16070
+ recordError2 as recordError,
16071
+ recordEvent2 as recordEvent,
16072
+ compileData2 as compileData
15929
16073
  };
15930
- //# sourceMappingURL=chunk-X3DDDXQD.js.map
16074
+ //# sourceMappingURL=chunk-OE3KB4ED.js.map
@@ -18,10 +18,10 @@ import {
18
18
  require_get_stream,
19
19
  runWithTimer,
20
20
  writeFile
21
- } from "./chunk-UVDRANBC.js";
21
+ } from "./chunk-POCJD2ES.js";
22
22
  import {
23
23
  require_semver
24
- } from "./chunk-H3GWNOGA.js";
24
+ } from "./chunk-G5HUFNZJ.js";
25
25
  import {
26
26
  dirname,
27
27
  joinPath
@@ -9825,15 +9825,24 @@ var _instance;
9825
9825
  function cliKitStore() {
9826
9826
  return _instance || (_instance = new LocalStorage({ projectName: `shopify-cli-kit${isUnitTest() ? "-test" : ""}` })), _instance;
9827
9827
  }
9828
- function getSession(config = cliKitStore()) {
9828
+ function getSessions(config = cliKitStore()) {
9829
9829
  return outputDebug(outputContent`Getting session store...`), config.get("sessionStore");
9830
9830
  }
9831
- function setSession(session, config = cliKitStore()) {
9831
+ function setSessions(session, config = cliKitStore()) {
9832
9832
  outputDebug(outputContent`Setting session store...`), config.set("sessionStore", session);
9833
9833
  }
9834
- function removeSession(config = cliKitStore()) {
9834
+ function removeSessions(config = cliKitStore()) {
9835
9835
  outputDebug(outputContent`Removing session store...`), config.delete("sessionStore");
9836
9836
  }
9837
+ function getCurrentSessionId(config = cliKitStore()) {
9838
+ return outputDebug(outputContent`Getting current session ID...`), config.get("currentSessionId");
9839
+ }
9840
+ function setCurrentSessionId(sessionId, config = cliKitStore()) {
9841
+ outputDebug(outputContent`Setting current session ID...`), config.set("currentSessionId", sessionId);
9842
+ }
9843
+ function removeCurrentSessionId(config = cliKitStore()) {
9844
+ outputDebug(outputContent`Removing current session ID...`), config.delete("currentSessionId");
9845
+ }
9837
9846
  async function cacheRetrieveOrRepopulate(key, fn, timeout, config = cliKitStore()) {
9838
9847
  let cached = cacheRetrieve(key, config);
9839
9848
  if (cached?.value !== void 0 && (timeout === void 0 || Date.now() - cached.timestamp < timeout))
@@ -9842,21 +9851,21 @@ async function cacheRetrieveOrRepopulate(key, fn, timeout, config = cliKitStore(
9842
9851
  return cacheStore(key, value, config), value;
9843
9852
  }
9844
9853
  function cacheStore(key, value, config = cliKitStore()) {
9845
- let cache = config.get("cache") || {};
9854
+ let cache = config.get("cache") ?? {};
9846
9855
  cache[key] = { value, timestamp: Date.now() }, config.set("cache", cache);
9847
9856
  }
9848
9857
  function cacheRetrieve(key, config = cliKitStore()) {
9849
- return (config.get("cache") || {})[key];
9858
+ return (config.get("cache") ?? {})[key];
9850
9859
  }
9851
9860
  function timeIntervalToMilliseconds({ days = 0, hours = 0, minutes = 0, seconds = 0 }) {
9852
9861
  return (days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds) * 1e3;
9853
9862
  }
9854
9863
  async function runAtMinimumInterval(key, timeout, task, config = cliKitStore()) {
9855
- let cache = config.get("cache") || {}, cacheKey = `most-recent-occurrence-${key}`, cached = cache[cacheKey];
9864
+ let cache = config.get("cache") ?? {}, cacheKey = `most-recent-occurrence-${key}`, cached = cache[cacheKey];
9856
9865
  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);
9857
9866
  }
9858
9867
  async function runWithRateLimit(options, config = cliKitStore()) {
9859
- let { key, limit, timeout, task } = options, cache = config.get("cache") || {}, cacheKey = `rate-limited-occurrences-${key}`, cached = cache[cacheKey], now = Date.now();
9868
+ let { key, limit, timeout, task } = options, cache = config.get("cache") ?? {}, cacheKey = `rate-limited-occurrences-${key}`, cached = cache[cacheKey], now = Date.now();
9860
9869
  if (cached?.value) {
9861
9870
  let windowStart = now - timeIntervalToMilliseconds(timeout), occurrences = cached.value.filter((occurrence) => occurrence >= windowStart);
9862
9871
  if (occurrences.length >= limit)
@@ -10491,7 +10500,7 @@ import urlLib from "node:url";
10491
10500
  import crypto2 from "node:crypto";
10492
10501
  import stream, { PassThrough as PassThroughStream } from "node:stream";
10493
10502
 
10494
- // ../../node_modules/.pnpm/normalize-url@8.0.1/node_modules/normalize-url/index.js
10503
+ // ../../node_modules/.pnpm/normalize-url@8.1.0/node_modules/normalize-url/index.js
10495
10504
  init_cjs_shims();
10496
10505
  var DATA_URL_DEFAULT_MIME_TYPE = "text/plain", DATA_URL_DEFAULT_CHARSET = "us-ascii", testParameter = (name, filters) => filters.some((filter) => filter instanceof RegExp ? filter.test(name) : filter === name), supportedProtocols = /* @__PURE__ */ new Set([
10497
10506
  "https:",
@@ -10536,6 +10545,8 @@ function normalizeUrl(urlString, options) {
10536
10545
  removeDirectoryIndex: !1,
10537
10546
  removeExplicitPort: !1,
10538
10547
  sortQueryParameters: !0,
10548
+ removePath: !1,
10549
+ transformPath: !1,
10539
10550
  ...options
10540
10551
  }, typeof options.defaultProtocol == "string" && !options.defaultProtocol.endsWith(":") && (options.defaultProtocol = `${options.defaultProtocol}:`), urlString = urlString.trim(), /^data:/i.test(urlString))
10541
10552
  return normalizeDataURL(urlString, options);
@@ -10560,13 +10571,17 @@ function normalizeUrl(urlString, options) {
10560
10571
  }
10561
10572
  if (urlObject.pathname)
10562
10573
  try {
10563
- urlObject.pathname = decodeURI(urlObject.pathname);
10574
+ urlObject.pathname = decodeURI(urlObject.pathname).replace(/\\/g, "%5C");
10564
10575
  } catch {
10565
10576
  }
10566
10577
  if (options.removeDirectoryIndex === !0 && (options.removeDirectoryIndex = [/^index\.[a-z]+$/]), Array.isArray(options.removeDirectoryIndex) && options.removeDirectoryIndex.length > 0) {
10567
10578
  let pathComponents = urlObject.pathname.split("/"), lastComponent = pathComponents[pathComponents.length - 1];
10568
10579
  testParameter(lastComponent, options.removeDirectoryIndex) && (pathComponents = pathComponents.slice(0, -1), urlObject.pathname = pathComponents.slice(1).join("/") + "/");
10569
10580
  }
10581
+ if (options.removePath && (urlObject.pathname = "/"), options.transformPath && typeof options.transformPath == "function") {
10582
+ let pathComponents = urlObject.pathname.split("/").filter(Boolean), newComponents = options.transformPath(pathComponents);
10583
+ urlObject.pathname = newComponents?.length > 0 ? `/${newComponents.join("/")}` : "/";
10584
+ }
10570
10585
  if (urlObject.hostname && (urlObject.hostname = urlObject.hostname.replace(/\.$/, ""), options.stripWWW && /^www\.(?!www\.)[a-z\-\d]{1,63}\.[a-z.\-\d]{2,63}$/.test(urlObject.hostname) && (urlObject.hostname = urlObject.hostname.replace(/^www\./, ""))), Array.isArray(options.removeQueryParameters))
10571
10586
  for (let key of [...urlObject.searchParams.keys()])
10572
10587
  testParameter(key, options.removeQueryParameters) && urlObject.searchParams.delete(key);
@@ -10574,11 +10589,17 @@ function normalizeUrl(urlString, options) {
10574
10589
  for (let key of [...urlObject.searchParams.keys()])
10575
10590
  testParameter(key, options.keepQueryParameters) || urlObject.searchParams.delete(key);
10576
10591
  if (options.sortQueryParameters) {
10592
+ let originalSearch = urlObject.search;
10577
10593
  urlObject.searchParams.sort();
10578
10594
  try {
10579
10595
  urlObject.search = decodeURIComponent(urlObject.search);
10580
10596
  } catch {
10581
10597
  }
10598
+ let partsWithoutEquals = originalSearch.slice(1).split("&").filter((p) => p && !p.includes("="));
10599
+ for (let part of partsWithoutEquals) {
10600
+ let decoded = decodeURIComponent(part);
10601
+ urlObject.search = urlObject.search.replace(`?${decoded}=`, `?${decoded}`).replace(`&${decoded}=`, `&${decoded}`);
10602
+ }
10582
10603
  }
10583
10604
  options.removeTrailingSlash && (urlObject.pathname = urlObject.pathname.replace(/\/$/, "")), options.removeExplicitPort && urlObject.port && (urlObject.port = "");
10584
10605
  let oldUrlString = urlString;
@@ -13839,9 +13860,12 @@ function inferPackageManager(optionsPackageManager, env = process.env) {
13839
13860
  export {
13840
13861
  require_ajv,
13841
13862
  LocalStorage,
13842
- getSession,
13843
- setSession,
13844
- removeSession,
13863
+ getSessions,
13864
+ setSessions,
13865
+ removeSessions,
13866
+ getCurrentSessionId,
13867
+ setCurrentSessionId,
13868
+ removeCurrentSessionId,
13845
13869
  cacheRetrieveOrRepopulate,
13846
13870
  cacheStore,
13847
13871
  cacheRetrieve,
@@ -13909,4 +13933,4 @@ deep-extend/lib/deep-extend.js:
13909
13933
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13910
13934
  *)
13911
13935
  */
13912
- //# sourceMappingURL=chunk-REUQOPSX.js.map
13936
+ //# sourceMappingURL=chunk-PGTPDPDU.js.map