@shopify/cli-kit 3.84.2 → 3.85.1

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 (118) hide show
  1. package/README.md +1 -1
  2. package/dist/private/node/analytics/bounded-collections.js.map +1 -0
  3. package/dist/{public/node/themes → private/node}/analytics/error-categorizer.d.ts +7 -1
  4. package/dist/private/node/analytics/error-categorizer.js +106 -0
  5. package/dist/private/node/analytics/error-categorizer.js.map +1 -0
  6. package/dist/{public/node/themes → private/node}/analytics/storage.js +8 -3
  7. package/dist/private/node/analytics/storage.js.map +1 -0
  8. package/dist/private/node/api/graphql/business-platform-destinations/user-email.d.ts +6 -0
  9. package/dist/private/node/api/graphql/business-platform-destinations/user-email.js +8 -0
  10. package/dist/private/node/api/graphql/business-platform-destinations/user-email.js.map +1 -0
  11. package/dist/private/node/api/headers.d.ts +3 -6
  12. package/dist/private/node/api/headers.js +8 -24
  13. package/dist/private/node/api/headers.js.map +1 -1
  14. package/dist/private/node/conf-store.d.ts +20 -3
  15. package/dist/private/node/conf-store.js +32 -7
  16. package/dist/private/node/conf-store.js.map +1 -1
  17. package/dist/private/node/constants.d.ts +0 -1
  18. package/dist/private/node/constants.js +0 -1
  19. package/dist/private/node/constants.js.map +1 -1
  20. package/dist/private/node/context/service.d.ts +8 -2
  21. package/dist/private/node/context/service.js +9 -5
  22. package/dist/private/node/context/service.js.map +1 -1
  23. package/dist/private/node/otel-metrics.js +2 -3
  24. package/dist/private/node/otel-metrics.js.map +1 -1
  25. package/dist/private/node/session/schema.d.ts +796 -41
  26. package/dist/private/node/session/schema.js +24 -25
  27. package/dist/private/node/session/schema.js.map +1 -1
  28. package/dist/private/node/session/store.d.ts +21 -11
  29. package/dist/private/node/session/store.js +52 -18
  30. package/dist/private/node/session/store.js.map +1 -1
  31. package/dist/private/node/session/validate.d.ts +2 -7
  32. package/dist/private/node/session/validate.js.map +1 -1
  33. package/dist/private/node/session.d.ts +8 -6
  34. package/dist/private/node/session.js +99 -71
  35. package/dist/private/node/session.js.map +1 -1
  36. package/dist/private/node/ui/components/LoadingBar.d.ts +8 -0
  37. package/dist/private/node/ui/components/LoadingBar.js +21 -0
  38. package/dist/private/node/ui/components/LoadingBar.js.map +1 -0
  39. package/dist/private/node/ui/components/LoadingBar.test.d.ts +1 -0
  40. package/dist/private/node/ui/components/LoadingBar.test.js +182 -0
  41. package/dist/private/node/ui/components/LoadingBar.test.js.map +1 -0
  42. package/dist/private/node/ui/components/SingleTask.d.ts +8 -0
  43. package/dist/private/node/ui/components/SingleTask.js +27 -0
  44. package/dist/private/node/ui/components/SingleTask.js.map +1 -0
  45. package/dist/private/node/ui/components/SingleTask.test.d.ts +1 -0
  46. package/dist/private/node/ui/components/SingleTask.test.js +145 -0
  47. package/dist/private/node/ui/components/SingleTask.test.js.map +1 -0
  48. package/dist/private/node/ui/components/Tasks.d.ts +2 -1
  49. package/dist/private/node/ui/components/Tasks.js +5 -25
  50. package/dist/private/node/ui/components/Tasks.js.map +1 -1
  51. package/dist/private/node/ui/components/Tasks.test.js +19 -103
  52. package/dist/private/node/ui/components/Tasks.test.js.map +1 -1
  53. package/dist/private/node/ui/hooks/use-exit-on-ctrl-c.d.ts +4 -0
  54. package/dist/private/node/ui/hooks/use-exit-on-ctrl-c.js +15 -0
  55. package/dist/private/node/ui/hooks/use-exit-on-ctrl-c.js.map +1 -0
  56. package/dist/public/common/version.d.ts +1 -1
  57. package/dist/public/common/version.js +1 -1
  58. package/dist/public/common/version.js.map +1 -1
  59. package/dist/public/node/analytics.d.ts +77 -0
  60. package/dist/public/node/analytics.js +88 -0
  61. package/dist/public/node/analytics.js.map +1 -1
  62. package/dist/public/node/api/admin.js +2 -3
  63. package/dist/public/node/api/admin.js.map +1 -1
  64. package/dist/public/node/api/app-dev.d.ts +2 -0
  65. package/dist/public/node/api/app-dev.js +1 -0
  66. package/dist/public/node/api/app-dev.js.map +1 -1
  67. package/dist/public/node/base-command.d.ts +22 -0
  68. package/dist/public/node/base-command.js +1 -1
  69. package/dist/public/node/base-command.js.map +1 -1
  70. package/dist/public/node/context/fqdn.d.ts +0 -4
  71. package/dist/public/node/context/fqdn.js +1 -23
  72. package/dist/public/node/context/fqdn.js.map +1 -1
  73. package/dist/public/node/context/local.d.ts +2 -2
  74. package/dist/public/node/context/local.js +2 -6
  75. package/dist/public/node/context/local.js.map +1 -1
  76. package/dist/public/node/error-handler.js +2 -1
  77. package/dist/public/node/error-handler.js.map +1 -1
  78. package/dist/public/node/http.d.ts +1 -1
  79. package/dist/public/node/http.js +1 -1
  80. package/dist/public/node/http.js.map +1 -1
  81. package/dist/public/node/metadata.d.ts +31 -4
  82. package/dist/public/node/metadata.js.map +1 -1
  83. package/dist/public/node/session-prompt.d.ts +10 -0
  84. package/dist/public/node/session-prompt.js +86 -0
  85. package/dist/public/node/session-prompt.js.map +1 -0
  86. package/dist/public/node/session.d.ts +11 -6
  87. package/dist/public/node/session.js +15 -4
  88. package/dist/public/node/session.js.map +1 -1
  89. package/dist/public/node/themes/api.js +28 -8
  90. package/dist/public/node/themes/api.js.map +1 -1
  91. package/dist/public/node/ui.d.ts +17 -1
  92. package/dist/public/node/ui.js +26 -2
  93. package/dist/public/node/ui.js.map +1 -1
  94. package/dist/public/node/vendor/dev_server/dev-server.js +1 -5
  95. package/dist/public/node/vendor/dev_server/dev-server.js.map +1 -1
  96. package/dist/public/node/vendor/dev_server/env.js +2 -2
  97. package/dist/public/node/vendor/dev_server/env.js.map +1 -1
  98. package/dist/tsconfig.tsbuildinfo +1 -1
  99. package/package.json +2 -2
  100. package/dist/private/node/context/spin-cache.d.ts +0 -2
  101. package/dist/private/node/context/spin-cache.js +0 -8
  102. package/dist/private/node/context/spin-cache.js.map +0 -1
  103. package/dist/public/node/context/spin.d.ts +0 -69
  104. package/dist/public/node/context/spin.js +0 -152
  105. package/dist/public/node/context/spin.js.map +0 -1
  106. package/dist/public/node/themes/analytics/bounded-collections.js.map +0 -1
  107. package/dist/public/node/themes/analytics/error-categorizer.js +0 -49
  108. package/dist/public/node/themes/analytics/error-categorizer.js.map +0 -1
  109. package/dist/public/node/themes/analytics/storage.js.map +0 -1
  110. package/dist/public/node/themes/analytics.d.ts +0 -60
  111. package/dist/public/node/themes/analytics.js +0 -71
  112. package/dist/public/node/themes/analytics.js.map +0 -1
  113. package/dist/public/node/vendor/dev_server/dev-server-spin.d.ts +0 -5
  114. package/dist/public/node/vendor/dev_server/dev-server-spin.js +0 -28
  115. package/dist/public/node/vendor/dev_server/dev-server-spin.js.map +0 -1
  116. /package/dist/{public/node/themes → private/node}/analytics/bounded-collections.d.ts +0 -0
  117. /package/dist/{public/node/themes → private/node}/analytics/bounded-collections.js +0 -0
  118. /package/dist/{public/node/themes → private/node}/analytics/storage.d.ts +0 -0
package/README.md CHANGED
@@ -13,7 +13,7 @@ Learn more in the [commands docs](./packages/cli/README.md#commands).
13
13
 
14
14
  <p>&nbsp;</p>
15
15
 
16
- ### Before you begin ###
16
+ ## Before you begin
17
17
 
18
18
  Install the latest version of [Node.js](https://nodejs.org/en/download/) and [npm](https://docs.npmjs.com/getting-started) (or another package manager of your choice).
19
19
 
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded-collections.js","sourceRoot":"","sources":["../../../../src/private/node/analytics/bounded-collections.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,cAAc,GAAG,IAAI,CAAA;AAE3B;;GAEG;AACH,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,MAAU,SAAQ,KAAQ;IACrC,IAAI,CAAC,GAAG,KAAU;QAChB,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;QACnC,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,OAAO,MAAM,CAAA;IACf,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;IACjB,CAAC;IAED,OAAO;QACL,OAAO,C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KAAK,EAAE,CAAA;YAC7C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;gBAC5B,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;YACzB,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * Ensures bounded arrays stay within reasonable memory limits.\n */\nconst MAX_ARRAY_SIZE = 1000\n\n/**\n * Estimated ~500KB total across timing, error, retry, and event entries.\n */\nconst MAX_MAP_KEYS = 1000\n\n/**\n * A bounded array that automatically maintains a maximum size by removing\n * the oldest entries when new items are added beyond the limit.\n *\n * Extends the native Array class to provide all standard array methods\n * while enforcing a fixed maximum size of MAX_ARRAY_SIZE (1000 entries).\n *\n * When the size limit is exceeded, the oldest entries (at the beginning\n * of the array) are automatically removed to make room for new ones.\n *\n * @example\n * const commands = new BArray()\n * commands.push(entry) // Automatically removes oldest if over 1000\n */\nexport class BArray<T> extends Array<T> {\n push(...items: T[]): number {\n const result = super.push(...items)\n this.enforceLimit()\n return result\n }\n\n clear(): void {\n this.length = 0\n }\n\n toArray(): T[] {\n return [...this]\n }\n\n private enforceLimit(): void {\n while (this.length > MAX_ARRAY_SIZE) {\n this.shift()\n }\n }\n}\n\n/**\n * A bounded map that automatically maintains a maximum number of keys by\n * removing the oldest entries when new keys are added beyond the limit.\n *\n * Extends the native Map class to provide all standard map methods while\n * enforcing a fixed maximum size of MAX_MAP_KEYS (1000 entries).\n *\n * Tracks insertion order to ensure the oldest keys are removed first when\n * the limit is exceeded. This provides LRU-like behavior based on insertion\n * time rather than access time.\n *\n * @example\n * const events = new BMap()\n * events.set('event', 1) // Automatically removes oldest if over 1000\n */\nexport class BMap<TKey, TValue> extends Map<TKey, TValue> {\n private insertionOrder: TKey[] = []\n\n set(key: TKey, value: TValue): this {\n if (!this.has(key)) {\n this.insertionOrder.push(key)\n }\n super.set(key, value)\n this.enforceLimit()\n return this\n }\n\n delete(key: TKey): boolean {\n const index = this.insertionOrder.indexOf(key)\n if (index > -1) {\n this.insertionOrder.splice(index, 1)\n }\n return super.delete(key)\n }\n\n clear(): void {\n this.insertionOrder = []\n super.clear()\n }\n\n toObject(): {[key: string]: TValue} {\n return Object.fromEntries(this)\n }\n\n private enforceLimit(): void {\n while (this.size > MAX_MAP_KEYS && this.insertionOrder.length > 0) {\n const oldestKey = this.insertionOrder.shift()\n if (oldestKey !== undefined) {\n super.delete(oldestKey)\n }\n }\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  export declare enum ErrorCategory {
2
+ Liquid = "LIQUID",
2
3
  ThemeCheck = "THEME_CHECK",
3
4
  Network = "NETWORK",
4
5
  FileSystem = "FILE_SYSTEM",
@@ -6,7 +7,12 @@ export declare enum ErrorCategory {
6
7
  Validation = "VALIDATION",
7
8
  Permission = "PERMISSION",
8
9
  RateLimit = "RATE_LIMIT",
9
- Parsing = "PARSING",
10
+ Json = "JSON",
10
11
  Unknown = "UNKNOWN"
11
12
  }
12
13
  export declare function categorizeError(error: unknown): ErrorCategory;
14
+ /**
15
+ * Formats an error message for analytics tracking, preserving important information
16
+ * based on the error category while keeping it concise and normalized.
17
+ */
18
+ export declare function formatErrorMessage(error: unknown, category: ErrorCategory): string;
@@ -0,0 +1,106 @@
1
+ export var ErrorCategory;
2
+ (function (ErrorCategory) {
3
+ ErrorCategory["Liquid"] = "LIQUID";
4
+ ErrorCategory["ThemeCheck"] = "THEME_CHECK";
5
+ ErrorCategory["Network"] = "NETWORK";
6
+ ErrorCategory["FileSystem"] = "FILE_SYSTEM";
7
+ ErrorCategory["Authentication"] = "AUTHENTICATION";
8
+ ErrorCategory["Validation"] = "VALIDATION";
9
+ ErrorCategory["Permission"] = "PERMISSION";
10
+ ErrorCategory["RateLimit"] = "RATE_LIMIT";
11
+ ErrorCategory["Json"] = "JSON";
12
+ ErrorCategory["Unknown"] = "UNKNOWN";
13
+ })(ErrorCategory || (ErrorCategory = {}));
14
+ const ERROR_CATEGORY_TERMS = {
15
+ [ErrorCategory.Liquid]: ['liquid'],
16
+ [ErrorCategory.Json]: ['json', 'parse response'],
17
+ [ErrorCategory.ThemeCheck]: ['theme check'],
18
+ [ErrorCategory.Authentication]: ['unauthorized', 'forbidden', 'auth', 'token', 'credential'],
19
+ [ErrorCategory.Network]: [
20
+ 'eai_again',
21
+ 'econn',
22
+ 'enetunreach',
23
+ 'enotfound',
24
+ 'epipe',
25
+ 'etimedout',
26
+ 'fetch',
27
+ 'network',
28
+ 'request',
29
+ 'socket',
30
+ 'the operation was aborted',
31
+ 'timed out',
32
+ 'timeout',
33
+ ],
34
+ [ErrorCategory.FileSystem]: ['enoent', 'eacces', 'file', 'directory', 'path'],
35
+ [ErrorCategory.Permission]: ['permission', 'denied', 'access', 'insufficient'],
36
+ [ErrorCategory.RateLimit]: ['rate limit', 'too many requests', 'throttle'],
37
+ [ErrorCategory.Validation]: ['validation', 'invalid', 'required'],
38
+ };
39
+ export function categorizeError(error) {
40
+ if (!(error instanceof Error))
41
+ return ErrorCategory.Unknown;
42
+ const message = error.message.toLowerCase();
43
+ for (const [category, terms] of Object.entries(ERROR_CATEGORY_TERMS)) {
44
+ const hasTerm = terms.some((term) => message.includes(term));
45
+ if (hasTerm) {
46
+ return category;
47
+ }
48
+ }
49
+ return ErrorCategory.Unknown;
50
+ }
51
+ /**
52
+ * Formats an error message for analytics tracking, preserving important information
53
+ * based on the error category while keeping it concise and normalized.
54
+ */
55
+ export function formatErrorMessage(error, category) {
56
+ const message = error instanceof Error ? error.message : String(error);
57
+ const formatter = ERROR_FORMATTERS[category] || formatGenericError;
58
+ return formatter(message);
59
+ }
60
+ const ERROR_FORMATTERS = {
61
+ [ErrorCategory.Network]: formatNetworkError,
62
+ [ErrorCategory.Authentication]: formatGenericError,
63
+ [ErrorCategory.FileSystem]: formatGenericError,
64
+ [ErrorCategory.RateLimit]: formatGenericError,
65
+ [ErrorCategory.Json]: formatGenericError,
66
+ [ErrorCategory.Validation]: formatGenericError,
67
+ [ErrorCategory.Permission]: formatGenericError,
68
+ [ErrorCategory.Liquid]: formatGenericError,
69
+ [ErrorCategory.ThemeCheck]: formatGenericError,
70
+ [ErrorCategory.Unknown]: formatGenericError,
71
+ };
72
+ function formatNetworkError(message) {
73
+ const httpStatusMatch = message.match(/\b([1-5]\d{2})\b/);
74
+ const connectionErrorMatch = message.match(/\b(E[A-Z]+)\b/);
75
+ const graphqlCodeMatch = message.match(/(?:code|error)[:\s]*(\d{3})/i);
76
+ let normalized = message.toLowerCase().substring(0, 50);
77
+ if (httpStatusMatch?.[1]) {
78
+ const statusCode = httpStatusMatch[1];
79
+ normalized = `http-${statusCode}-${normalized.replace(/\b\d{3}\b/g, '').trim()}`;
80
+ }
81
+ else if (graphqlCodeMatch?.[1]) {
82
+ const statusCode = graphqlCodeMatch[1];
83
+ normalized = `http-${statusCode}-${normalized.replace(/(?:code|error)[:\s]*\d{3}/gi, '').trim()}`;
84
+ }
85
+ else if (connectionErrorMatch?.[1]) {
86
+ const errorCode = connectionErrorMatch[1].toLowerCase();
87
+ normalized = `http-000-${errorCode}-${normalized.replace(/\b[eE][A-Z]+\b/g, '').trim()}`;
88
+ }
89
+ else {
90
+ normalized = `http-000-${normalized}`;
91
+ }
92
+ return normalized
93
+ .replace(/[^a-zA-Z0-9-]/g, '-')
94
+ .replace(/-+/g, '-')
95
+ .replace(/^-|-$/g, '')
96
+ .substring(0, 50);
97
+ }
98
+ function formatGenericError(message) {
99
+ return message
100
+ .toLowerCase()
101
+ .substring(0, 50)
102
+ .replace(/[^a-zA-Z0-9]/g, '-')
103
+ .replace(/-+/g, '-')
104
+ .replace(/^-|-$/g, '');
105
+ }
106
+ //# sourceMappingURL=error-categorizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-categorizer.js","sourceRoot":"","sources":["../../../../src/private/node/analytics/error-categorizer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAWX;AAXD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,2CAA0B,CAAA;IAC1B,oCAAmB,CAAA;IACnB,2CA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AC,gBAAgB,EAAE,GAAG,CAAC;SAC9B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;SACrB,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACrB,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,OAAO,OAAO;SACX,WAAW,EAAE;SACb,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC;SAChB,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAC1B,CAAC","sourcesContent":["export enum ErrorCategory {\n Liquid = 'LIQUID',\n ThemeCheck = 'THEME_CHECK',\n Network = 'NETWORK',\n FileSystem = 'FILE_SYSTEM',\n Authentication = 'AUTHENTICATION',\n Validation = 'VALIDATION',\n Permission = 'PERMISSION',\n RateLimit = 'RATE_LIMIT',\n Json = 'JSON',\n Unknown = 'UNKNOWN',\n}\n\nconst ERROR_CATEGORY_TERMS = {\n [ErrorCategory.Liquid]: ['liquid'],\n [ErrorCategory.Json]: ['json', 'parse response'],\n [ErrorCategory.ThemeCheck]: ['theme check'],\n [ErrorCategory.Authentication]: ['unauthorized', 'forbidden', 'auth', 'token', 'credential'],\n [ErrorCategory.Network]: [\n 'eai_again',\n 'econn',\n 'enetunreach',\n 'enotfound',\n 'epipe',\n 'etimedout',\n 'fetch',\n 'network',\n 'request',\n 'socket',\n 'the operation was aborted',\n 'timed out',\n 'timeout',\n ],\n [ErrorCategory.FileSystem]: ['enoent', 'eacces', 'file', 'directory', 'path'],\n [ErrorCategory.Permission]: ['permission', 'denied', 'access', 'insufficient'],\n [ErrorCategory.RateLimit]: ['rate limit', 'too many requests', 'throttle'],\n [ErrorCategory.Validation]: ['validation', 'invalid', 'required'],\n}\n\nexport function categorizeError(error: unknown): ErrorCategory {\n if (!(error instanceof Error)) return ErrorCategory.Unknown\n\n const message = error.message.toLowerCase()\n\n for (const [category, terms] of Object.entries(ERROR_CATEGORY_TERMS)) {\n const hasTerm = terms.some((term) => message.includes(term))\n\n if (hasTerm) {\n return category as ErrorCategory\n }\n }\n\n return ErrorCategory.Unknown\n}\n\n/**\n * Formats an error message for analytics tracking, preserving important information\n * based on the error category while keeping it concise and normalized.\n */\nexport function formatErrorMessage(error: unknown, category: ErrorCategory): string {\n const message = error instanceof Error ? error.message : String(error)\n\n const formatter = ERROR_FORMATTERS[category] || formatGenericError\n return formatter(message)\n}\n\nconst ERROR_FORMATTERS: {[key in ErrorCategory]: (message: string) => string} = {\n [ErrorCategory.Network]: formatNetworkError,\n [ErrorCategory.Authentication]: formatGenericError,\n [ErrorCategory.FileSystem]: formatGenericError,\n [ErrorCategory.RateLimit]: formatGenericError,\n [ErrorCategory.Json]: formatGenericError,\n [ErrorCategory.Validation]: formatGenericError,\n [ErrorCategory.Permission]: formatGenericError,\n [ErrorCategory.Liquid]: formatGenericError,\n [ErrorCategory.ThemeCheck]: formatGenericError,\n [ErrorCategory.Unknown]: formatGenericError,\n}\n\nfunction formatNetworkError(message: string): string {\n const httpStatusMatch = message.match(/\\b([1-5]\\d{2})\\b/)\n const connectionErrorMatch = message.match(/\\b(E[A-Z]+)\\b/)\n const graphqlCodeMatch = message.match(/(?:code|error)[:\\s]*(\\d{3})/i)\n\n let normalized = message.toLowerCase().substring(0, 50)\n\n if (httpStatusMatch?.[1]) {\n const statusCode = httpStatusMatch[1]\n normalized = `http-${statusCode}-${normalized.replace(/\\b\\d{3}\\b/g, '').trim()}`\n } else if (graphqlCodeMatch?.[1]) {\n const statusCode = graphqlCodeMatch[1]\n normalized = `http-${statusCode}-${normalized.replace(/(?:code|error)[:\\s]*\\d{3}/gi, '').trim()}`\n } else if (connectionErrorMatch?.[1]) {\n const errorCode = connectionErrorMatch[1].toLowerCase()\n normalized = `http-000-${errorCode}-${normalized.replace(/\\b[eE][A-Z]+\\b/g, '').trim()}`\n } else {\n normalized = `http-000-${normalized}`\n }\n\n return normalized\n .replace(/[^a-zA-Z0-9-]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n .substring(0, 50)\n}\n\nfunction formatGenericError(message: string): string {\n return message\n .toLowerCase()\n .substring(0, 50)\n .replace(/[^a-zA-Z0-9]/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { categorizeError } from './error-categorizer.js';
1
+ import { categorizeError, formatErrorMessage, ErrorCategory } from './error-categorizer.js';
2
2
  import { BArray, BMap } from './bounded-collections.js';
3
3
  const _runtimeAnalyticsStore = {
4
4
  timings: new BArray(),
@@ -29,11 +29,16 @@ export function recordError(error) {
29
29
  const category = categorizeError(error);
30
30
  const errorEntry = {
31
31
  category,
32
- message: error instanceof Error ? error.message : String(error),
32
+ message: (error instanceof Error ? error.message : String(error)).substring(0, 200),
33
33
  timestamp: Date.now(),
34
34
  };
35
+ if (errorEntry.category === ErrorCategory.Unknown && !errorEntry.message) {
36
+ return;
37
+ }
35
38
  _runtimeAnalyticsStore.errors.push(errorEntry);
36
- recordEvent(`error:${category}:${errorEntry.message.substring(0, 50)}`);
39
+ const normalizedErrorCategory = category.toLowerCase();
40
+ const normalizedErrorMessage = formatErrorMessage(error, category);
41
+ recordEvent(`error:${normalizedErrorCategory}:${normalizedErrorMessage}`);
37
42
  }
38
43
  export function recordRetry(url, operation) {
39
44
  const existingEntries = _runtimeAnalyticsStore.retries.filter((entry) => entry.url === url && entry.operation === operation);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../src/private/node/analytics/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,kBAAkB,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAA;AACzF,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,0BAA0B,CAAA;AAgCrD,MAAM,sBAAsB,GAAG;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CAAC,OAAO,EAAE;QAC/C,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE;QACjD,MAAM,EAAE,sBAAsB,CAAC,MAAM,CAAC,OAAO,EAAE;KAChD,CAAA;AACH,CAAC;AAED,MAAM,UAAU,KAAK;IACnB,sBAAsB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IACtC,sBAAsB,CAAC,aAAa,CAAC,KAAK,EAAE,CAAA;IAC5C,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrC,sBAAsB,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IACtC,sBAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;AACvC,CAAC","sourcesContent":["import {categorizeError, formatErrorMessage, ErrorCategory} from './error-categorizer.js'\nimport {BArray, BMap} from './bounded-collections.js'\n\ninterface TimingEntry {\n event: string\n duration: number\n}\n\ninterface ErrorEntry {\n category: ErrorCategory\n message: string\n timestamp: number\n}\n\ninterface RetryEntry {\n url: string\n operation: string\n attempts: number\n timestamp: number\n}\n\ninterface EventEntry {\n name: string\n timestamp: number\n}\n\nexport interface RuntimeData {\n timings: TimingEntry[]\n errors: ErrorEntry[]\n retries: RetryEntry[]\n events: EventEntry[]\n}\n\nconst _runtimeAnalyticsStore = {\n timings: new BArray<TimingEntry>(),\n activeTimings: new BMap<string, number>(),\n errors: new BArray<ErrorEntry>(),\n retries: new BArray<RetryEntry>(),\n events: new BArray<EventEntry>(),\n}\n\nexport function recordTiming(eventName: string): void {\n const now = Date.now()\n\n if (!_runtimeAnalyticsStore.activeTimings.has(eventName)) {\n _runtimeAnalyticsStore.activeTimings.set(eventName, now)\n recordEvent(`timing:start:${eventName}`)\n return\n }\n\n const startTime = _runtimeAnalyticsStore.activeTimings.get(eventName)\n if (startTime === undefined) return\n\n const duration = now - startTime\n\n _runtimeAnalyticsStore.timings.push({\n event: eventName,\n duration,\n })\n\n _runtimeAnalyticsStore.activeTimings.delete(eventName)\n\n recordEvent(`timing:end:${eventName}`)\n}\n\nexport function recordError(error: unknown): void {\n const category = categorizeError(error)\n const errorEntry: ErrorEntry = {\n category,\n message: (error instanceof Error ? error.message : String(error)).substring(0, 200),\n timestamp: Date.now(),\n }\n\n if (errorEntry.category === ErrorCategory.Unknown && !errorEntry.message) {\n return\n }\n\n _runtimeAnalyticsStore.errors.push(errorEntry)\n\n const normalizedErrorCategory = category.toLowerCase()\n const normalizedErrorMessage = formatErrorMessage(error, category)\n\n recordEvent(`error:${normalizedErrorCategory}:${normalizedErrorMessage}`)\n}\n\nexport function recordRetry(url: string, operation: string): void {\n const existingEntries = _runtimeAnalyticsStore.retries.filter(\n (entry) => entry.url === url && entry.operation === operation,\n )\n const attemptCount = existingEntries.length + 1\n\n _runtimeAnalyticsStore.retries.push({\n url,\n operation,\n attempts: attemptCount,\n timestamp: Date.now(),\n })\n\n recordEvent(`retry:${operation}:attempt:${attemptCount}`)\n}\n\nexport function recordEvent(eventName: string): void {\n _runtimeAnalyticsStore.events.push({\n name: eventName,\n timestamp: Date.now(),\n })\n}\n\nexport function compileData(): RuntimeData {\n return {\n timings: _runtimeAnalyticsStore.timings.toArray(),\n errors: _runtimeAnalyticsStore.errors.toArray(),\n retries: _runtimeAnalyticsStore.retries.toArray(),\n events: _runtimeAnalyticsStore.events.toArray(),\n }\n}\n\nexport function reset(): void {\n _runtimeAnalyticsStore.timings.clear()\n _runtimeAnalyticsStore.activeTimings.clear()\n _runtimeAnalyticsStore.errors.clear()\n _runtimeAnalyticsStore.retries.clear()\n _runtimeAnalyticsStore.events.clear()\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export interface UserEmailQuery {
2
+ currentUserAccount?: {
3
+ email: string;
4
+ } | null;
5
+ }
6
+ export declare const UserEmailQueryString = "\n query UserEmail {\n currentUserAccount {\n email\n }\n }\n";
@@ -0,0 +1,8 @@
1
+ export const UserEmailQueryString = `
2
+ query UserEmail {
3
+ currentUserAccount {
4
+ email
5
+ }
6
+ }
7
+ `;
8
+ //# sourceMappingURL=user-email.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-email.js","sourceRoot":"","sources":["../../../../../../src/private/node/api/graphql/business-platform-destinations/user-email.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;CAMnC,CAAA","sourcesContent":["// UserEmail query for fetching user email from Business Platform API\nexport interface UserEmailQuery {\n currentUserAccount?: {\n email: string\n } | null\n}\n\nexport const UserEmailQueryString = `\n query UserEmail {\n currentUserAccount {\n email\n }\n }\n`\n"]}
@@ -1,6 +1,6 @@
1
- import { ExtendableError } from '../../../public/node/error.js';
1
+ import { AbortError } from '../../../public/node/error.js';
2
2
  import https from 'https';
3
- declare class RequestClientError extends ExtendableError {
3
+ declare class RequestClientError extends AbortError {
4
4
  statusCode: number;
5
5
  constructor(message: string, statusCode: number);
6
6
  }
@@ -20,10 +20,7 @@ export declare function buildHeaders(token?: string): {
20
20
  [key: string]: string;
21
21
  };
22
22
  /**
23
- * This utility function returns the https.Agent to use for a given service. The agent
24
- * includes the right configuration based on the service's environment. For example,
25
- * if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
26
- * set to false
23
+ * This utility function returns the https.Agent to use for a given service.
27
24
  */
28
25
  export declare function httpsAgent(): Promise<https.Agent>;
29
26
  export {};
@@ -1,11 +1,13 @@
1
1
  import { CLI_KIT_VERSION } from '../../../public/common/version.js';
2
2
  import { firstPartyDev } from '../../../public/node/context/local.js';
3
- import { Environment, serviceEnvironment } from '../context/service.js';
4
- import { ExtendableError } from '../../../public/node/error.js';
3
+ import { AbortError } from '../../../public/node/error.js';
5
4
  import https from 'https';
6
- class RequestClientError extends ExtendableError {
5
+ class RequestClientError extends AbortError {
7
6
  constructor(message, statusCode) {
8
- super(message);
7
+ const tryMessage = statusCode === 403
8
+ ? 'Ensure you are using the correct account. You can switch with `shopify auth login`'
9
+ : undefined;
10
+ super(message, tryMessage);
9
11
  this.statusCode = statusCode;
10
12
  }
11
13
  }
@@ -55,30 +57,12 @@ export function buildHeaders(token) {
55
57
  return headers;
56
58
  }
57
59
  /**
58
- * This utility function returns the https.Agent to use for a given service. The agent
59
- * includes the right configuration based on the service's environment. For example,
60
- * if the service is running in a Spin environment, the attribute "rejectUnauthorized" is
61
- * set to false
60
+ * This utility function returns the https.Agent to use for a given service.
62
61
  */
63
62
  export async function httpsAgent() {
64
63
  return new https.Agent({
65
- rejectUnauthorized: await shouldRejectUnauthorizedRequests(),
64
+ rejectUnauthorized: true,
66
65
  keepAlive: true,
67
66
  });
68
67
  }
69
- /**
70
- * Spin stores the CA certificate in the keychain and it should be used when sending HTTP
71
- * requests to Spin instances. However, Node doesn't read certificates from the Keychain
72
- * by default, which leads to Shopifolks running into issues that they workaround by setting the
73
- * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP
74
- * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)
75
- * This utility function allows controlling the behavior in a per-service level by returning
76
- * the value of for the "rejectUnauthorized" attribute that's used in the https agent.
77
- *
78
- * @returns A promise that resolves with a boolean indicating whether
79
- * unauthorized requests should be rejected or not.
80
- */
81
- async function shouldRejectUnauthorizedRequests() {
82
- return (await serviceEnvironment()) !== Environment.Spin;
83
- }
84
68
  //# sourceMappingURL=headers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,+BAA+B,CAAA;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,kBAAmB,SAAQ,eAAe;IAE9C,YAAmB,OAAe,EAAE,UAAkB;QACpD,KAAK,CAAC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;QAC1B,0DAA0D;QAC1D,oBAAoB,EAAE,OAAO,CAAC,QAAQ;QACtC,cAAc,EAAE,kBAAkB;QAClC,GAAG,CAAC,aAAa,EAAE,IAAI,EAAC,wBAAwB,EAAE,GAAG,EAAC,CAAC;KACxD,CAAA;IACD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAA;QAEhF,OAAO,CAAC,aAAa,GAAG,UAAU,CAAA;QAClC,OAAO,CAAC,wBAAwB,CAAC,GAAG,UAAU,CAAA;IAChD,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC;QACrB,kBAAkB,EAAE,MAAM,gCAAgC,EAAE;QAC5D,SAAS,EAAE,IAAI;KAChB,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,gCAAgC;IAC7C,OAAO,CAAC,MAAM,kBAAkB,EAAE,CAAC,KAAK,WAAW,CAAC,IAAI,CAAA;AAC1D,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../../public/common/version.js'\nimport {firstPartyDev} from '../../../public/node/context/local.js'\nimport {Environment, serviceEnvironment} from '../context/service.js'\nimport {ExtendableError} from '../../../public/node/error.js'\nimport https from 'https'\n\nclass RequestClientError extends ExtendableError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n super(message)\n this.statusCode = statusCode\n }\n}\nexport class GraphQLClientError extends RequestClientError {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errors?: any[]\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(message: string, statusCode: number, errors?: any[]) {\n super(message, statusCode)\n this.errors = errors\n this.stack = undefined\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns 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', 'subject_token']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\nexport function buildHeaders(token?: string): {[key: string]: string} {\n const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n 'Keep-Alive': 'timeout=30',\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n const authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`\n\n headers.authorization = authString\n headers['X-Shopify-Access-Token'] = authString\n }\n\n return headers\n}\n\n/**\n * This utility function returns the https.Agent to use for a given service. The agent\n * includes the right configuration based on the service's environment. For example,\n * if the service is running in a Spin environment, the attribute \"rejectUnauthorized\" is\n * set to false\n */\nexport async function httpsAgent(): Promise<https.Agent> {\n return new https.Agent({\n rejectUnauthorized: await shouldRejectUnauthorizedRequests(),\n keepAlive: true,\n })\n}\n\n/**\n * Spin stores the CA certificate in the keychain and it should be used when sending HTTP\n * requests to Spin instances. However, Node doesn't read certificates from the Keychain\n * by default, which leads to Shopifolks running into issues that they workaround by setting the\n * NODE_TLS_REJECT_UNAUTHORIZED=0 environment variable, which applies to all the HTTP\n * requests sent from the CLI (context: https://github.com/nodejs/node/issues/39657)\n * This utility function allows controlling the behavior in a per-service level by returning\n * the value of for the \"rejectUnauthorized\" attribute that's used in the https agent.\n *\n * @returns A promise that resolves with a boolean indicating whether\n * unauthorized requests should be rejected or not.\n */\nasync function shouldRejectUnauthorizedRequests(): Promise<boolean> {\n return (await serviceEnvironment()) !== Environment.Spin\n}\n"]}
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/private/node/api/headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mCAAmC,CAAA;AACjE,OAAO,EAAC,aAAa,EAAC,MAAM,uCAAuC,CAAA;AACnE,OAAO,EAAC,UAAU,EAAC,MAAM,+BAA+B,CAAA;AACxD,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,kBAAmB,SAAQ,UAAU;IAEzC,YAAmB,OAAe,EAAE,UAAkB;QACpD,MAAM,UAAU,GACd,UAAU,KAAK,GAAG;YAChB,CAAC,CAAC,oFAAoF;YACtF,CAAC,CAAC,SAAS,CAAA;QACf,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC1B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;CACF;AACD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IAIxD,8DAA8D;IAC9D,YAAmB,OAAe,EAAE,UAAkB,EAAE,MAAc;QACpE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;IACxB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgC;IACrE,MAAM,SAAS,GAA4B,EAAE,CAAA;IAC7C,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,eAAe,EAAE,eAAe,CAAC,CAAA;IAC5D,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QACtC,IAAI,QAAQ,CAAC,IAAI,C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,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {CLI_KIT_VERSION} from '../../../public/common/version.js'\nimport {firstPartyDev} from '../../../public/node/context/local.js'\nimport {AbortError} from '../../../public/node/error.js'\nimport https from 'https'\n\nclass RequestClientError extends AbortError {\n statusCode: number\n public constructor(message: string, statusCode: number) {\n const tryMessage =\n statusCode === 403\n ? 'Ensure you are using the correct account. You can switch with `shopify auth login`'\n : undefined\n super(message, tryMessage)\n this.statusCode = statusCode\n }\n}\nexport class GraphQLClientError extends RequestClientError {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errors?: any[]\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(message: string, statusCode: number, errors?: any[]) {\n super(message, statusCode)\n this.errors = errors\n this.stack = undefined\n }\n}\n\n/**\n * Removes the sensitive data from the headers and outputs them as a string.\n * @param headers - HTTP headers.\n * @returns 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', 'subject_token']\n Object.keys(headers).forEach((header) => {\n if (keywords.find((keyword) => header.toLocaleLowerCase().includes(keyword)) === undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\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\nexport function buildHeaders(token?: string): {[key: string]: string} {\n const userAgent = `Shopify CLI; v=${CLI_KIT_VERSION}`\n\n const headers: {[header: string]: string} = {\n 'User-Agent': userAgent,\n 'Keep-Alive': 'timeout=30',\n // 'Sec-CH-UA': secCHUA, This header requires the Git sha.\n 'Sec-CH-UA-PLATFORM': process.platform,\n 'Content-Type': 'application/json',\n ...(firstPartyDev() && {'X-Shopify-Cli-Employee': '1'}),\n }\n if (token) {\n const authString = token.match(/^shp(at|ua|ca|tka)/) ? token : `Bearer ${token}`\n\n headers.authorization = authString\n headers['X-Shopify-Access-Token'] = authString\n }\n\n return headers\n}\n\n/**\n * This utility function returns the https.Agent to use for a given service.\n */\nexport async function httpsAgent(): Promise<https.Agent> {\n return new https.Agent({\n rejectUnauthorized: true,\n keepAlive: true,\n })\n}\n"]}
@@ -20,6 +20,7 @@ interface Cache {
20
20
  }
21
21
  export interface ConfSchema {
22
22
  sessionStore: string;
23
+ currentSessionId?: string;
23
24
  cache?: Cache;
24
25
  }
25
26
  /**
@@ -27,17 +28,33 @@ export interface ConfSchema {
27
28
  *
28
29
  * @returns Session.
29
30
  */
30
- export declare function getSession(config?: LocalStorage<ConfSchema>): string | undefined;
31
+ export declare function getSessions(config?: LocalStorage<ConfSchema>): string | undefined;
31
32
  /**
32
33
  * Set session.
33
34
  *
34
35
  * @param session - Session.
35
36
  */
36
- export declare function setSession(session: string, config?: LocalStorage<ConfSchema>): void;
37
+ export declare function setSessions(session: string, config?: LocalStorage<ConfSchema>): void;
37
38
  /**
38
39
  * Remove session.
39
40
  */
40
- export declare function removeSession(config?: LocalStorage<ConfSchema>): void;
41
+ export declare function removeSessions(config?: LocalStorage<ConfSchema>): void;
42
+ /**
43
+ * Get current session ID.
44
+ *
45
+ * @returns Current session ID.
46
+ */
47
+ export declare function getCurrentSessionId(config?: LocalStorage<ConfSchema>): string | undefined;
48
+ /**
49
+ * Set current session ID.
50
+ *
51
+ * @param sessionId - Session ID.
52
+ */
53
+ export declare function setCurrentSessionId(sessionId: string, config?: LocalStorage<ConfSchema>): void;
54
+ /**
55
+ * Remove current session ID.
56
+ */
57
+ export declare function removeCurrentSessionId(config?: LocalStorage<ConfSchema>): void;
41
58
  type CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value'];
42
59
  /**
43
60
  * Fetch from cache, or run the provided function to get the value, and cache it
@@ -18,7 +18,7 @@ function cliKitStore() {
18
18
  *
19
19
  * @returns Session.
20
20
  */
21
- export function getSession(config = cliKitStore()) {
21
+ export function getSessions(config = cliKitStore()) {
22
22
  outputDebug(outputContent `Getting session store...`);
23
23
  return config.get('sessionStore');
24
24
  }
@@ -27,17 +27,42 @@ export function getSession(config = cliKitStore()) {
27
27
  *
28
28
  * @param session - Session.
29
29
  */
30
- export function setSession(session, config = cliKitStore()) {
30
+ export function setSessions(session, config = cliKitStore()) {
31
31
  outputDebug(outputContent `Setting session store...`);
32
32
  config.set('sessionStore', session);
33
33
  }
34
34
  /**
35
35
  * Remove session.
36
36
  */
37
- export function removeSession(config = cliKitStore()) {
37
+ export function removeSessions(config = cliKitStore()) {
38
38
  outputDebug(outputContent `Removing session store...`);
39
39
  config.delete('sessionStore');
40
40
  }
41
+ /**
42
+ * Get current session ID.
43
+ *
44
+ * @returns Current session ID.
45
+ */
46
+ export function getCurrentSessionId(config = cliKitStore()) {
47
+ outputDebug(outputContent `Getting current session ID...`);
48
+ return config.get('currentSessionId');
49
+ }
50
+ /**
51
+ * Set current session ID.
52
+ *
53
+ * @param sessionId - Session ID.
54
+ */
55
+ export function setCurrentSessionId(sessionId, config = cliKitStore()) {
56
+ outputDebug(outputContent `Setting current session ID...`);
57
+ config.set('currentSessionId', sessionId);
58
+ }
59
+ /**
60
+ * Remove current session ID.
61
+ */
62
+ export function removeCurrentSessionId(config = cliKitStore()) {
63
+ outputDebug(outputContent `Removing current session ID...`);
64
+ config.delete('currentSessionId');
65
+ }
41
66
  /**
42
67
  * Fetch from cache, or run the provided function to get the value, and cache it
43
68
  * before returning it.
@@ -57,7 +82,7 @@ export async function cacheRetrieveOrRepopulate(key, fn, timeout, config = cliKi
57
82
  return value;
58
83
  }
59
84
  export function cacheStore(key, value, config = cliKitStore()) {
60
- const cache = config.get('cache') || {};
85
+ const cache = config.get('cache') ?? {};
61
86
  cache[key] = { value, timestamp: Date.now() };
62
87
  config.set('cache', cache);
63
88
  }
@@ -67,7 +92,7 @@ export function cacheStore(key, value, config = cliKitStore()) {
67
92
  * @returns The chache element.
68
93
  */
69
94
  export function cacheRetrieve(key, config = cliKitStore()) {
70
- const cache = config.get('cache') || {};
95
+ const cache = config.get('cache') ?? {};
71
96
  return cache[key];
72
97
  }
73
98
  export function cacheClear(config = cliKitStore()) {
@@ -86,7 +111,7 @@ export function timeIntervalToMilliseconds({ days = 0, hours = 0, minutes = 0, s
86
111
  * @returns true if the task was run, or false if the task was not run.
87
112
  */
88
113
  export async function runAtMinimumInterval(key, timeout, task, config = cliKitStore()) {
89
- const cache = config.get('cache') || {};
114
+ const cache = config.get('cache') ?? {};
90
115
  const cacheKey = `most-recent-occurrence-${key}`;
91
116
  const cached = cache[cacheKey];
92
117
  if (cached?.value !== undefined && Date.now() - cached.timestamp < timeIntervalToMilliseconds(timeout)) {
@@ -110,7 +135,7 @@ export async function runAtMinimumInterval(key, timeout, task, config = cliKitSt
110
135
  */
111
136
  export async function runWithRateLimit(options, config = cliKitStore()) {
112
137
  const { key, limit, timeout, task } = options;
113
- const cache = config.get('cache') || {};
138
+ const cache = config.get('cache') ?? {};
114
139
  const cacheKey = `rate-limited-occurrences-${key}`;
115
140
  const cached = cache[cacheKey];
116
141
  const now = Date.now();
@@ -1 +1 @@
1
- {"version":3,"file":"conf-store.js","sourceRoot":"","sources":["../../../src/private/node/conf-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AA8BtE,IAAI,SAA+C,CAAA;AAEnD;;;;GAIG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,YAAY,CAAa,EAAC,WAAW,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,CAAC,CAAA;IAC1G,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,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CAAA;YAE1B,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,IAAI,EAAE,CAAA;QACZ,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAC,KAAK,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,EAAC,CAAA;IAClE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,EAAE,CAAA;QACZ,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,GAAG,EAAC,CAAA;IAClD,CAAC;IACD,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAE1B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,8BAA8B;IAC5C,OAAO,IAAI,YAAY,CAA8D;QACnF,WAAW,EAAE,gCAAgC;KAC9C,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,aAAqB;IACjE,IAAI,CAAC,aAAa;QAAE,OAAO,IAAI,CAAA;IAC/B,MAAM,KAAK,GAAG,8BAA8B,EAAE,CAAA;IAE9C,MAAM,iBAAiB,GAAG,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IAClD,IAAI,iBAAiB,EAAE,CAAC;QACtB,6BAA6B;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,6BAA6B,CAAC,aAAqB;IACjE,MAAM,KAAK,GAAG,8BAA8B,EAAE,CAAA;IAE9C,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAC,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import {isUnitTest} from '../../public/node/context/local.js'\nimport {LocalStorage} from '../../public/node/local-storage.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\n\ninterface CacheValue<T> {\n value: T\n timestamp: number\n}\n\nexport type PackageVersionKey = `npm-package-${string}`\nexport type NotificationsKey = `notifications-${string}`\nexport type NotificationKey = `notification-${string}`\nexport type GraphQLRequestKey = `q-${string}-${string}-${string}`\ntype MostRecentOccurrenceKey = `most-recent-occurrence-${string}`\ntype RateLimitKey = `rate-limited-occurrences-${string}`\n\ntype ExportedKey = PackageVersionKey | NotificationsKey | NotificationKey | GraphQLRequestKey\n\ninterface Cache {\n [packageVersionKey: PackageVersionKey]: CacheValue<string>\n [notifications: NotificationsKey]: CacheValue<string>\n [notification: NotificationKey]: CacheValue<string>\n [graphQLRequestKey: GraphQLRequestKey]: CacheValue<string>\n [mostRecentOccurrenceKey: MostRecentOccurrenceKey]: CacheValue<boolean>\n [rateLimitKey: RateLimitKey]: CacheValue<number[]>\n}\n\nexport interface ConfSchema {\n sessionStore: string\n cache?: Cache\n}\n\nlet _instance: LocalStorage<ConfSchema> | undefined\n\n/**\n * CLIKIT Store.\n *\n * @returns CLIKitStore.\n */\nfunction cliKitStore() {\n if (!_instance) {\n _instance = new LocalStorage<ConfSchema>({projectName: `shopify-cli-kit${isUnitTest() ? '-test' : ''}`})\n }\n return _instance\n}\n\n/**\n * Get session.\n *\n * @returns Session.\n */\nexport function getSession(config: LocalStorage<ConfSchema> = cliKitStore()): string | undefined {\n outputDebug(outputContent`Getting session store...`)\n return config.get('sessionStore')\n}\n\n/**\n * Set session.\n *\n * @param session - Session.\n */\nexport function setSession(session: string, config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Setting session store...`)\n config.set('sessionStore', session)\n}\n\n/**\n * Remove session.\n */\nexport function removeSession(config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Removing session store...`)\n config.delete('sessionStore')\n}\n\ntype CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value']\n\n/**\n * Fetch from cache, or run the provided function to get the value, and cache it\n * before returning it.\n * @param key - The key to use for the cache.\n * @param fn - The function to run to get the value to cache, if a cache miss occurs.\n * @param timeout - The maximum valid age of a cached value, in milliseconds.\n * If the cached value is older than this, it will be refreshed.\n * @returns The value from the cache or the result of the function.\n */\nexport async function cacheRetrieveOrRepopulate(\n key: ExportedKey,\n fn: () => Promise<CacheValueForKey<typeof key>>,\n timeout?: number,\n config = cliKitStore(),\n): Promise<CacheValueForKey<typeof key>> {\n const cached = cacheRetrieve(key, config)\n\n if (cached?.value !== undefined && (timeout === undefined || Date.now() - cached.timestamp < timeout)) {\n return cached.value\n }\n\n const value = await fn()\n cacheStore(key, value, config)\n return value\n}\n\nexport function cacheStore(key: ExportedKey, value: string, config = cliKitStore()): void {\n const cache: Cache = config.get('cache') || {}\n cache[key] = {value, timestamp: Date.now()}\n config.set('cache', cache)\n}\n\n/**\n * Fetch from cache if already populated, otherwise return undefined.\n * @param key - The key to use for the cache.\n * @returns The chache element.\n */\nexport function cacheRetrieve(key: ExportedKey, config = cliKitStore()): CacheValue<string> | undefined {\n const cache: Cache = config.get('cache') || {}\n return cache[key]\n}\n\nexport function cacheClear(config = cliKitStore()): void {\n config.delete('cache')\n}\n\nexport interface TimeInterval {\n days?: number\n hours?: number\n minutes?: number\n seconds?: number\n}\n\nexport function timeIntervalToMilliseconds({days = 0, hours = 0, minutes = 0, seconds = 0}: TimeInterval): number {\n return (days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds) * 1000\n}\n\n/**\n * Execute a task only if the most recent occurrence of the task is older than the specified timeout.\n * @param key - The key to use for the cache.\n * @param timeout - The maximum valid age of the most recent occurrence, expressed as an object with\n * days, hours, minutes, and seconds properties.\n * If the most recent occurrence is older than this, the task will be executed.\n * @param task - The task to run if the most recent occurrence is older than the timeout.\n * @returns true if the task was run, or false if the task was not run.\n */\nexport async function runAtMinimumInterval(\n key: string,\n timeout: TimeInterval,\n task: () => Promise<void>,\n config = cliKitStore(),\n): Promise<boolean> {\n const cache: Cache = config.get('cache') || {}\n const cacheKey: MostRecentOccurrenceKey = `most-recent-occurrence-${key}`\n const cached = cache[cacheKey]\n\n if (cached?.value !== undefined && Date.now() - cached.timestamp < timeIntervalToMilliseconds(timeout)) {\n return false\n }\n\n await task()\n cache[cacheKey] = {value: true, timestamp: Date.now()}\n config.set('cache', cache)\n return true\n}\n\ninterface RunWithRateLimitOptions {\n /**\n * The key to use for the cache.\n */\n key: string\n\n /**\n * The number of times the task can be run within the limit\n */\n limit: number\n\n /**\n * The window of time after which the rate limit is refreshed,\n * expressed as an object with days, hours, minutes, and seconds properties.\n * If the most recent occurrence is older than this, the task will be executed.\n */\n timeout: TimeInterval\n\n /**\n * The task to run if the most recent occurrence is older than the timeout.\n */\n task: () => Promise<void>\n}\n\n/**\n * Execute a task with a time-based rate limit. The rate limit is enforced by\n * checking how many times that task has been executed in a window of time ending\n * at the current time. If the task has been executed more than the allowed number\n * of times in that window, the task will not be executed.\n *\n * Note that this function has side effects, as it will also remove events prior\n * to the window of time that is being checked.\n * @param options - The options for the rate limiting.\n * @returns true, or undefined if the task was not run.\n */\nexport async function runWithRateLimit(options: RunWithRateLimitOptions, config = cliKitStore()): Promise<boolean> {\n const {key, limit, timeout, task} = options\n const cache: Cache = config.get('cache') || {}\n const cacheKey: RateLimitKey = `rate-limited-occurrences-${key}`\n const cached = cache[cacheKey]\n const now = Date.now()\n\n if (cached?.value) {\n // First sweep through the cache and eliminate old events\n const windowStart = now - timeIntervalToMilliseconds(timeout)\n const occurrences = cached.value.filter((occurrence) => occurrence >= windowStart)\n\n // Now check that the number of occurrences within the interval is below the limit\n if (occurrences.length >= limit) {\n // First remove the old occurrences from the cache\n cache[cacheKey] = {value: occurrences, timestamp: Date.now()}\n config.set('cache', cache)\n\n return false\n }\n\n await task()\n cache[cacheKey] = {value: [...occurrences, now], timestamp: now}\n } else {\n await task()\n cache[cacheKey] = {value: [now], timestamp: now}\n }\n config.set('cache', cache)\n\n return true\n}\n\nexport function getConfigStoreForPartnerStatus() {\n return new LocalStorage<{[partnerToken: string]: {status: true; checkedAt: string}}>({\n projectName: 'shopify-cli-kit-partner-status',\n })\n}\n\nexport function getCachedPartnerAccountStatus(partnersToken: string): true | null {\n if (!partnersToken) return null\n const store = getConfigStoreForPartnerStatus()\n\n const hasPartnerAccount = store.get(partnersToken)\n if (hasPartnerAccount) {\n // this never needs to expire\n return true\n }\n return null\n}\n\nexport function setCachedPartnerAccountStatus(partnersToken: string) {\n const store = getConfigStoreForPartnerStatus()\n\n store.set(partnersToken, {status: true, checkedAt: new Date().toISOString()})\n}\n"]}
1
+ {"version":3,"file":"conf-store.js","sourceRoot":"","sources":["../../../src/private/node/conf-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,oCAAoC,CAAA;AAC7D,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAA;AAC/D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AA+BtE,IAAI,SAA+C,CAAA;AAEnD;;;;GAIG;AACH,SAAS,WAAW;IAClB,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,SAAS,GAAG,IAAI,YAAY,CAAa,EAAC,WAAW,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,EAAC,CAAC,CAAA;IAC1G,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAmC,WAAW,EAAE;IAC1E,WAAW,CAAC,aAAa,CAAA,0BAA0B,CAAC,CAAA;IACpD,OAAO,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe,EAAE,SAAmC,WAAW,EAAE;IAC3F,WAAW,CAAC,aAAa,CAAA,0BAA0B,CAAC,CAAA;IACpD,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,OAA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AE9C,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAC,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import {isUnitTest} from '../../public/node/context/local.js'\nimport {LocalStorage} from '../../public/node/local-storage.js'\nimport {outputContent, outputDebug} from '../../public/node/output.js'\n\ninterface CacheValue<T> {\n value: T\n timestamp: number\n}\n\nexport type PackageVersionKey = `npm-package-${string}`\nexport type NotificationsKey = `notifications-${string}`\nexport type NotificationKey = `notification-${string}`\nexport type GraphQLRequestKey = `q-${string}-${string}-${string}`\ntype MostRecentOccurrenceKey = `most-recent-occurrence-${string}`\ntype RateLimitKey = `rate-limited-occurrences-${string}`\n\ntype ExportedKey = PackageVersionKey | NotificationsKey | NotificationKey | GraphQLRequestKey\n\ninterface Cache {\n [packageVersionKey: PackageVersionKey]: CacheValue<string>\n [notifications: NotificationsKey]: CacheValue<string>\n [notification: NotificationKey]: CacheValue<string>\n [graphQLRequestKey: GraphQLRequestKey]: CacheValue<string>\n [mostRecentOccurrenceKey: MostRecentOccurrenceKey]: CacheValue<boolean>\n [rateLimitKey: RateLimitKey]: CacheValue<number[]>\n}\n\nexport interface ConfSchema {\n sessionStore: string\n currentSessionId?: string\n cache?: Cache\n}\n\nlet _instance: LocalStorage<ConfSchema> | undefined\n\n/**\n * CLIKIT Store.\n *\n * @returns CLIKitStore.\n */\nfunction cliKitStore() {\n if (!_instance) {\n _instance = new LocalStorage<ConfSchema>({projectName: `shopify-cli-kit${isUnitTest() ? '-test' : ''}`})\n }\n return _instance\n}\n\n/**\n * Get session.\n *\n * @returns Session.\n */\nexport function getSessions(config: LocalStorage<ConfSchema> = cliKitStore()): string | undefined {\n outputDebug(outputContent`Getting session store...`)\n return config.get('sessionStore')\n}\n\n/**\n * Set session.\n *\n * @param session - Session.\n */\nexport function setSessions(session: string, config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Setting session store...`)\n config.set('sessionStore', session)\n}\n\n/**\n * Remove session.\n */\nexport function removeSessions(config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Removing session store...`)\n config.delete('sessionStore')\n}\n\n/**\n * Get current session ID.\n *\n * @returns Current session ID.\n */\nexport function getCurrentSessionId(config: LocalStorage<ConfSchema> = cliKitStore()): string | undefined {\n outputDebug(outputContent`Getting current session ID...`)\n return config.get('currentSessionId')\n}\n\n/**\n * Set current session ID.\n *\n * @param sessionId - Session ID.\n */\nexport function setCurrentSessionId(sessionId: string, config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Setting current session ID...`)\n config.set('currentSessionId', sessionId)\n}\n\n/**\n * Remove current session ID.\n */\nexport function removeCurrentSessionId(config: LocalStorage<ConfSchema> = cliKitStore()): void {\n outputDebug(outputContent`Removing current session ID...`)\n config.delete('currentSessionId')\n}\n\ntype CacheValueForKey<TKey extends keyof Cache> = NonNullable<Cache[TKey]>['value']\n\n/**\n * Fetch from cache, or run the provided function to get the value, and cache it\n * before returning it.\n * @param key - The key to use for the cache.\n * @param fn - The function to run to get the value to cache, if a cache miss occurs.\n * @param timeout - The maximum valid age of a cached value, in milliseconds.\n * If the cached value is older than this, it will be refreshed.\n * @returns The value from the cache or the result of the function.\n */\nexport async function cacheRetrieveOrRepopulate(\n key: ExportedKey,\n fn: () => Promise<CacheValueForKey<typeof key>>,\n timeout?: number,\n config = cliKitStore(),\n): Promise<CacheValueForKey<typeof key>> {\n const cached = cacheRetrieve(key, config)\n\n if (cached?.value !== undefined && (timeout === undefined || Date.now() - cached.timestamp < timeout)) {\n return cached.value\n }\n\n const value = await fn()\n cacheStore(key, value, config)\n return value\n}\n\nexport function cacheStore(key: ExportedKey, value: string, config = cliKitStore()): void {\n const cache: Cache = config.get('cache') ?? {}\n cache[key] = {value, timestamp: Date.now()}\n config.set('cache', cache)\n}\n\n/**\n * Fetch from cache if already populated, otherwise return undefined.\n * @param key - The key to use for the cache.\n * @returns The chache element.\n */\nexport function cacheRetrieve(key: ExportedKey, config = cliKitStore()): CacheValue<string> | undefined {\n const cache: Cache = config.get('cache') ?? {}\n return cache[key]\n}\n\nexport function cacheClear(config = cliKitStore()): void {\n config.delete('cache')\n}\n\nexport interface TimeInterval {\n days?: number\n hours?: number\n minutes?: number\n seconds?: number\n}\n\nexport function timeIntervalToMilliseconds({days = 0, hours = 0, minutes = 0, seconds = 0}: TimeInterval): number {\n return (days * 24 * 60 * 60 + hours * 60 * 60 + minutes * 60 + seconds) * 1000\n}\n\n/**\n * Execute a task only if the most recent occurrence of the task is older than the specified timeout.\n * @param key - The key to use for the cache.\n * @param timeout - The maximum valid age of the most recent occurrence, expressed as an object with\n * days, hours, minutes, and seconds properties.\n * If the most recent occurrence is older than this, the task will be executed.\n * @param task - The task to run if the most recent occurrence is older than the timeout.\n * @returns true if the task was run, or false if the task was not run.\n */\nexport async function runAtMinimumInterval(\n key: string,\n timeout: TimeInterval,\n task: () => Promise<void>,\n config = cliKitStore(),\n): Promise<boolean> {\n const cache: Cache = config.get('cache') ?? {}\n const cacheKey: MostRecentOccurrenceKey = `most-recent-occurrence-${key}`\n const cached = cache[cacheKey]\n\n if (cached?.value !== undefined && Date.now() - cached.timestamp < timeIntervalToMilliseconds(timeout)) {\n return false\n }\n\n await task()\n cache[cacheKey] = {value: true, timestamp: Date.now()}\n config.set('cache', cache)\n return true\n}\n\ninterface RunWithRateLimitOptions {\n /**\n * The key to use for the cache.\n */\n key: string\n\n /**\n * The number of times the task can be run within the limit\n */\n limit: number\n\n /**\n * The window of time after which the rate limit is refreshed,\n * expressed as an object with days, hours, minutes, and seconds properties.\n * If the most recent occurrence is older than this, the task will be executed.\n */\n timeout: TimeInterval\n\n /**\n * The task to run if the most recent occurrence is older than the timeout.\n */\n task: () => Promise<void>\n}\n\n/**\n * Execute a task with a time-based rate limit. The rate limit is enforced by\n * checking how many times that task has been executed in a window of time ending\n * at the current time. If the task has been executed more than the allowed number\n * of times in that window, the task will not be executed.\n *\n * Note that this function has side effects, as it will also remove events prior\n * to the window of time that is being checked.\n * @param options - The options for the rate limiting.\n * @returns true, or undefined if the task was not run.\n */\nexport async function runWithRateLimit(options: RunWithRateLimitOptions, config = cliKitStore()): Promise<boolean> {\n const {key, limit, timeout, task} = options\n const cache: Cache = config.get('cache') ?? {}\n const cacheKey: RateLimitKey = `rate-limited-occurrences-${key}`\n const cached = cache[cacheKey]\n const now = Date.now()\n\n if (cached?.value) {\n // First sweep through the cache and eliminate old events\n const windowStart = now - timeIntervalToMilliseconds(timeout)\n const occurrences = cached.value.filter((occurrence) => occurrence >= windowStart)\n\n // Now check that the number of occurrences within the interval is below the limit\n if (occurrences.length >= limit) {\n // First remove the old occurrences from the cache\n cache[cacheKey] = {value: occurrences, timestamp: Date.now()}\n config.set('cache', cache)\n\n return false\n }\n\n await task()\n cache[cacheKey] = {value: [...occurrences, now], timestamp: now}\n } else {\n await task()\n cache[cacheKey] = {value: [now], timestamp: now}\n }\n config.set('cache', cache)\n\n return true\n}\n\nexport function getConfigStoreForPartnerStatus() {\n return new LocalStorage<{[partnerToken: string]: {status: true; checkedAt: string}}>({\n projectName: 'shopify-cli-kit-partner-status',\n })\n}\n\nexport function getCachedPartnerAccountStatus(partnersToken: string): true | null {\n if (!partnersToken) return null\n const store = getConfigStoreForPartnerStatus()\n\n const hasPartnerAccount = store.get(partnersToken)\n if (hasPartnerAccount) {\n // this never needs to expire\n return true\n }\n return null\n}\n\nexport function setCachedPartnerAccountStatus(partnersToken: string) {\n const store = getConfigStoreForPartnerStatus()\n\n store.set(partnersToken, {status: true, checkedAt: new Date().toISOString()})\n}\n"]}
@@ -20,7 +20,6 @@ export declare const environmentVariables: {
20
20
  codespacePortForwardingDomain: string;
21
21
  gitpod: string;
22
22
  cloudShell: string;
23
- spin: string;
24
23
  spinAppPort: string;
25
24
  spinAppHost: string;
26
25
  organization: string;
@@ -31,7 +31,6 @@ export const environmentVariables = {
31
31
  codespacePortForwardingDomain: 'GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN',
32
32
  gitpod: 'GITPOD_WORKSPACE_URL',
33
33
  cloudShell: 'CLOUD_SHELL',
34
- spin: 'SPIN',
35
34
  spinAppPort: 'SERVER_PORT',
36
35
  spinAppHost: 'SPIN_APP_HOST',
37
36
  organization: 'SHOPIFY_CLI_ORGANIZATION',
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/private/node/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAA;AAClD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAA;IACjE,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,KAAK,CAAA;AACnC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE;IAC7B,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,CAAA;AACjC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kBAAkB,EAAE,kCAAkC;IACtD,gBAAgB,EAAE,gCAAgC;IAClD,UAAU,EAAE,yBAAyB;IACrC,iBAAiB,EAAE,iCAAiC;IACpD,GAAG,EAAE,iBAAiB;IACtB,aAAa,EAAE,oBAAoB;IACnC,WAAW,EAAE,0BAA0B;IACvC,aAAa,EAAE,4BAA4B;IAC3C,SAAS,EAAE,qBAAqB;IAChC,UAAU,EAAE,qBAAqB;IACjC,eAAe,EAAE,+BAA+B;IAChD,YAAY,EAAE,eAAe;IAC7B,UAAU,EAAE,yBAAyB;IACrC,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,sBAAsB;IAC/B,mEAAm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KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,EAAC,CAAA;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAC/B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,IAAI,2BAA2B,CAAA","sourcesContent":["import {joinPath} from '../../public/node/path.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nexport const logsFolder = () => {\n return envPaths(identifier).log\n}\n\nexport const environmentVariables = {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n alwaysLogMetrics: 'SHOPIFY_CLI_ALWAYS_LOG_METRICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinInstance: 'SPIN_INSTANCE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n // Variables to detect if the CLI is running in a cloud environment\n codespaces: 'CODESPACES',\n codespaceName: 'CODESPACE_NAME',\n codespacePortForwardingDomain: 'GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN',\n gitpod: 'GITPOD_WORKSPACE_URL',\n cloudShell: 'CLOUD_SHELL',\n spin: 'SPIN',\n spinAppPort: 'SERVER_PORT',\n spinAppHost: 'SPIN_APP_HOST',\n organization: 'SHOPIFY_CLI_ORGANIZATION',\n identityToken: 'SHOPIFY_CLI_IDENTITY_TOKEN',\n refreshToken: 'SHOPIFY_CLI_REFRESH_TOKEN',\n otelURL: 'SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT',\n themeKitAccessDomain: 'SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN',\n json: 'SHOPIFY_FLAG_JSON',\n neverUsePartnersApi: 'SHOPIFY_CLI_NEVER_USE_PARTNERS_API',\n skipNetworkLevelRetry: 'SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY',\n maxRequestTimeForNetworkCalls: 'SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS',\n}\n\nexport const defaultThemeKitAccessDomain = 'theme-kit-access.shopifyapps.com'\n\nexport const systemEnvironmentVariables = {\n backendPort: 'BACKEND_PORT',\n}\n\nexport const pathConstants = {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return joinPath(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return joinPath(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n}\n\nexport const sessionConstants = {\n expirationTimeMarginInMinutes: 4,\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport const reportingRateLimit = {limit: 300, timeout: {days: 1}}\n\nexport const themeKitAccessDomain =\n process.env[environmentVariables.themeKitAccessDomain] ?? defaultThemeKitAccessDomain\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/private/node/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,2BAA2B,CAAA;AAClD,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,MAAM,WAAW,GAAG,GAAG,EAAE;IACvB,IAAI,OAA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E,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW,EAAE,cAAc;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,WAAW,EAAE;QACX,GAAG,EAAE,kBAAkB;KACxB;IACD,WAAW,EAAE;QACX,KAAK,EAAE;YACL,IAAI,EAAE,GAAG,EAAE;gBACT,OAAO,WAAW,EAAE,CAAA;YACtB,CAAC;YACD,MAAM,EAAE;gBACN,IAAI,EAAE,GAAG,EAAE;oBACT,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAA;gBAC1C,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,OAAO,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;gBACtD,CAAC;aACF;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,6BAA6B,EAAE,CAAC;CACjC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,kCAAkC,CAAA;AAE/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAC,IAAI,EAAE,CAAC,EAAC,EAAC,CAAA;AAElE,MAAM,CAAC,MAAM,oBAAoB,GAC/B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,IAAI,2BAA2B,CAAA","sourcesContent":["import {joinPath} from '../../public/node/path.js'\nimport envPaths from 'env-paths'\n\nconst identifier = 'shopify-cli'\n\nconst cacheFolder = () => {\n if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME\n return envPaths(identifier).cache\n}\n\nexport const logsFolder = () => {\n return envPaths(identifier).log\n}\n\nexport const environmentVariables = {\n alwaysLogAnalytics: 'SHOPIFY_CLI_ALWAYS_LOG_ANALYTICS',\n alwaysLogMetrics: 'SHOPIFY_CLI_ALWAYS_LOG_METRICS',\n deviceAuth: 'SHOPIFY_CLI_DEVICE_AUTH',\n enableCliRedirect: 'SHOPIFY_CLI_ENABLE_CLI_REDIRECT',\n env: 'SHOPIFY_CLI_ENV',\n firstPartyDev: 'SHOPIFY_CLI_1P_DEV',\n noAnalytics: 'SHOPIFY_CLI_NO_ANALYTICS',\n partnersToken: 'SHOPIFY_CLI_PARTNERS_TOKEN',\n runAsUser: 'SHOPIFY_RUN_AS_USER',\n serviceEnv: 'SHOPIFY_SERVICE_ENV',\n skipCliRedirect: 'SHOPIFY_CLI_SKIP_CLI_REDIRECT',\n spinInstance: 'SPIN_INSTANCE',\n themeToken: 'SHOPIFY_CLI_THEME_TOKEN',\n unitTest: 'SHOPIFY_UNIT_TEST',\n verbose: 'SHOPIFY_FLAG_VERBOSE',\n // Variables to detect if the CLI is running in a cloud environment\n codespaces: 'CODESPACES',\n codespaceName: 'CODESPACE_NAME',\n codespacePortForwardingDomain: 'GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN',\n gitpod: 'GITPOD_WORKSPACE_URL',\n cloudShell: 'CLOUD_SHELL',\n spinAppPort: 'SERVER_PORT',\n spinAppHost: 'SPIN_APP_HOST',\n organization: 'SHOPIFY_CLI_ORGANIZATION',\n identityToken: 'SHOPIFY_CLI_IDENTITY_TOKEN',\n refreshToken: 'SHOPIFY_CLI_REFRESH_TOKEN',\n otelURL: 'SHOPIFY_CLI_OTEL_EXPORTER_OTLP_ENDPOINT',\n themeKitAccessDomain: 'SHOPIFY_CLI_THEME_KIT_ACCESS_DOMAIN',\n json: 'SHOPIFY_FLAG_JSON',\n neverUsePartnersApi: 'SHOPIFY_CLI_NEVER_USE_PARTNERS_API',\n skipNetworkLevelRetry: 'SHOPIFY_CLI_SKIP_NETWORK_LEVEL_RETRY',\n maxRequestTimeForNetworkCalls: 'SHOPIFY_CLI_MAX_REQUEST_TIME_FOR_NETWORK_CALLS',\n}\n\nexport const defaultThemeKitAccessDomain = 'theme-kit-access.shopifyapps.com'\n\nexport const systemEnvironmentVariables = {\n backendPort: 'BACKEND_PORT',\n}\n\nexport const pathConstants = {\n executables: {\n dev: '/opt/dev/bin/dev',\n },\n directories: {\n cache: {\n path: () => {\n return cacheFolder()\n },\n vendor: {\n path: () => {\n return joinPath(cacheFolder(), 'vendor')\n },\n binaries: () => {\n return joinPath(cacheFolder(), 'vendor', 'binaries')\n },\n },\n },\n },\n}\n\nexport const sessionConstants = {\n expirationTimeMarginInMinutes: 4,\n}\n\nexport const bugsnagApiKey = '9e1e6889176fd0c795d5c659225e0fae'\n\nexport const reportingRateLimit = {limit: 300, timeout: {days: 1}}\n\nexport const themeKitAccessDomain =\n process.env[environmentVariables.themeKitAccessDomain] ?? defaultThemeKitAccessDomain\n"]}
@@ -5,8 +5,7 @@
5
5
  */
6
6
  export declare enum Environment {
7
7
  Local = "local",
8
- Production = "production",
9
- Spin = "spin"
8
+ Production = "production"
10
9
  }
11
10
  /**
12
11
  * Returns the environment to use for a given service.
@@ -15,3 +14,10 @@ export declare enum Environment {
15
14
  * @returns The environment to use for a given service.
16
15
  */
17
16
  export declare function serviceEnvironment(env?: NodeJS.ProcessEnv): Environment;
17
+ /**
18
+ * Returns true if the environment is local.
19
+ *
20
+ * @param env - Environment variables.
21
+ * @returns True if the environment is local.
22
+ */
23
+ export declare function isLocalEnvironment(env?: NodeJS.ProcessEnv): boolean;