@shopify/cli-kit 3.83.3 → 3.84.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.
- package/README.md +1 -1
- package/dist/private/node/api.js +14 -11
- package/dist/private/node/api.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.d.ts +3 -2
- package/dist/public/node/api/admin.js +12 -8
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/app-management.d.ts +0 -1
- package/dist/public/node/api/app-management.js +4 -5
- package/dist/public/node/api/app-management.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +0 -2
- package/dist/public/node/api/graphql.js +3 -3
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/archiver.js +24 -3
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/fs.d.ts +7 -0
- package/dist/public/node/fs.js +23 -0
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/ink.d.ts +1 -1
- package/dist/public/node/ink.js +1 -1
- package/dist/public/node/ink.js.map +1 -1
- package/dist/public/node/monorail.d.ts +5 -1
- package/dist/public/node/monorail.js +1 -1
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/session.d.ts +5 -6
- package/dist/public/node/session.js +7 -9
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/tcp.js +2 -2
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/themes/analytics/bounded-collections.d.ts +45 -0
- package/dist/public/node/themes/analytics/bounded-collections.js +92 -0
- package/dist/public/node/themes/analytics/bounded-collections.js.map +1 -0
- package/dist/public/node/themes/analytics/error-categorizer.d.ts +12 -0
- package/dist/public/node/themes/analytics/error-categorizer.js +49 -0
- package/dist/public/node/themes/analytics/error-categorizer.js.map +1 -0
- package/dist/public/node/themes/analytics/storage.d.ts +33 -0
- package/dist/public/node/themes/analytics/storage.js +70 -0
- package/dist/public/node/themes/analytics/storage.js.map +1 -0
- package/dist/public/node/themes/analytics.d.ts +60 -0
- package/dist/public/node/themes/analytics.js +71 -0
- package/dist/public/node/themes/analytics.js.map +1 -0
- package/dist/public/node/themes/api.js +11 -11
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/ui/components.d.ts +1 -0
- package/dist/public/node/ui/components.js +1 -0
- package/dist/public/node/ui/components.js.map +1 -1
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js +2 -1
- package/dist/public/node/vendor/otel-js/service/BaseOtelService/BaseOtelService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounded-collections.js","sourceRoot":"","sources":["../../../../../src/public/node/themes/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,CAAC,GAAG,IAAI,CAAC,CAAA;IAClB,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,EAAE,CAAA;QACd,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,IAAmB,SAAQ,GAAiB;IAAzD;;QACU,mBAAc,GAAW,EAAE,CAAA;IAoCrC,CAAC;IAlCC,GAAG,CAAC,GAAS,EAAE,KAAa;QAC1B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAC/B,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrB,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,GAAS;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC9C,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IAC1B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,KAAK,CAAC,KAAK,EAAE,CAAA;IACf,CAAC;IAED,QAAQ;QACN,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAEO,YAAY;QAClB,OAAO,IAAI,CAAC,IAAI,GAAG,YAAY,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAClE,MAAM,SAAS,GAAG,IAAI,CAAC,cAAc,CAAC,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"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum ErrorCategory {
|
|
2
|
+
ThemeCheck = "THEME_CHECK",
|
|
3
|
+
Network = "NETWORK",
|
|
4
|
+
FileSystem = "FILE_SYSTEM",
|
|
5
|
+
Authentication = "AUTHENTICATION",
|
|
6
|
+
Validation = "VALIDATION",
|
|
7
|
+
Permission = "PERMISSION",
|
|
8
|
+
RateLimit = "RATE_LIMIT",
|
|
9
|
+
Parsing = "PARSING",
|
|
10
|
+
Unknown = "UNKNOWN"
|
|
11
|
+
}
|
|
12
|
+
export declare function categorizeError(error: unknown): ErrorCategory;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export var ErrorCategory;
|
|
2
|
+
(function (ErrorCategory) {
|
|
3
|
+
ErrorCategory["ThemeCheck"] = "THEME_CHECK";
|
|
4
|
+
ErrorCategory["Network"] = "NETWORK";
|
|
5
|
+
ErrorCategory["FileSystem"] = "FILE_SYSTEM";
|
|
6
|
+
ErrorCategory["Authentication"] = "AUTHENTICATION";
|
|
7
|
+
ErrorCategory["Validation"] = "VALIDATION";
|
|
8
|
+
ErrorCategory["Permission"] = "PERMISSION";
|
|
9
|
+
ErrorCategory["RateLimit"] = "RATE_LIMIT";
|
|
10
|
+
ErrorCategory["Parsing"] = "PARSING";
|
|
11
|
+
ErrorCategory["Unknown"] = "UNKNOWN";
|
|
12
|
+
})(ErrorCategory || (ErrorCategory = {}));
|
|
13
|
+
const ERROR_CATEGORY_TERMS = {
|
|
14
|
+
[ErrorCategory.ThemeCheck]: ['theme check'],
|
|
15
|
+
[ErrorCategory.Authentication]: ['unauthorized', 'forbidden', 'auth', 'token', 'credential'],
|
|
16
|
+
[ErrorCategory.Network]: [
|
|
17
|
+
'eai_again',
|
|
18
|
+
'econn',
|
|
19
|
+
'enetunreach',
|
|
20
|
+
'enotfound',
|
|
21
|
+
'epipe',
|
|
22
|
+
'etimedout',
|
|
23
|
+
'fetch',
|
|
24
|
+
'network',
|
|
25
|
+
'request',
|
|
26
|
+
'socket',
|
|
27
|
+
'the operation was aborted',
|
|
28
|
+
'timed out',
|
|
29
|
+
'timeout',
|
|
30
|
+
],
|
|
31
|
+
[ErrorCategory.FileSystem]: ['enoent', 'eacces', 'file', 'directory', 'path'],
|
|
32
|
+
[ErrorCategory.Permission]: ['permission', 'denied', 'access', 'insufficient'],
|
|
33
|
+
[ErrorCategory.RateLimit]: ['rate limit', 'too many requests', 'throttle'],
|
|
34
|
+
[ErrorCategory.Parsing]: ['parse', 'syntax', 'json', 'invalid'],
|
|
35
|
+
[ErrorCategory.Validation]: ['validation', 'invalid', 'required'],
|
|
36
|
+
};
|
|
37
|
+
export function categorizeError(error) {
|
|
38
|
+
if (!(error instanceof Error))
|
|
39
|
+
return ErrorCategory.Unknown;
|
|
40
|
+
const message = error.message.toLowerCase();
|
|
41
|
+
for (const [category, terms] of Object.entries(ERROR_CATEGORY_TERMS)) {
|
|
42
|
+
const hasTerm = terms.some((term) => message.includes(term));
|
|
43
|
+
if (hasTerm) {
|
|
44
|
+
return category;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return ErrorCategory.Unknown;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=error-categorizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-categorizer.js","sourceRoot":"","sources":["../../../../../src/public/node/themes/analytics/error-categorizer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB,2CAA0B,CAAA;IAC1B,oCAAmB,CAAA;IACnB,2CAA0B,CAAA;IAC1B,kDAAiC,CAAA;IACjC,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;IACzB,yCAAwB,CAAA;IACxB,oCAAmB,CAAA;IACnB,oCAAmB,CAAA;AACrB,CAAC,EAVW,aAAa,KAAb,aAAa,QAUxB;AAED,MAAM,oBAAoB,GAAG;IAC3B,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC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A;QAE5D,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,QAAyB,CAAA;QAClC,CAAC;IACH,CAAC;IAED,OAAO,aAAa,CAAC,OAAO,CAAA;AAC9B,CAAC","sourcesContent":["export enum ErrorCategory {\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 Parsing = 'PARSING',\n Unknown = 'UNKNOWN',\n}\n\nconst ERROR_CATEGORY_TERMS = {\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.Parsing]: ['parse', 'syntax', 'json', 'invalid'],\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"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ErrorCategory } from './error-categorizer.js';
|
|
2
|
+
interface TimingEntry {
|
|
3
|
+
event: string;
|
|
4
|
+
duration: number;
|
|
5
|
+
}
|
|
6
|
+
interface ErrorEntry {
|
|
7
|
+
category: ErrorCategory;
|
|
8
|
+
message: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
interface RetryEntry {
|
|
12
|
+
url: string;
|
|
13
|
+
operation: string;
|
|
14
|
+
attempts: number;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
interface EventEntry {
|
|
18
|
+
name: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}
|
|
21
|
+
export interface RuntimeData {
|
|
22
|
+
timings: TimingEntry[];
|
|
23
|
+
errors: ErrorEntry[];
|
|
24
|
+
retries: RetryEntry[];
|
|
25
|
+
events: EventEntry[];
|
|
26
|
+
}
|
|
27
|
+
export declare function recordTiming(eventName: string): void;
|
|
28
|
+
export declare function recordError(error: unknown): void;
|
|
29
|
+
export declare function recordRetry(url: string, operation: string): void;
|
|
30
|
+
export declare function recordEvent(eventName: string): void;
|
|
31
|
+
export declare function compileData(): RuntimeData;
|
|
32
|
+
export declare function reset(): void;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { categorizeError } from './error-categorizer.js';
|
|
2
|
+
import { BArray, BMap } from './bounded-collections.js';
|
|
3
|
+
const _runtimeAnalyticsStore = {
|
|
4
|
+
timings: new BArray(),
|
|
5
|
+
activeTimings: new BMap(),
|
|
6
|
+
errors: new BArray(),
|
|
7
|
+
retries: new BArray(),
|
|
8
|
+
events: new BArray(),
|
|
9
|
+
};
|
|
10
|
+
export function recordTiming(eventName) {
|
|
11
|
+
const now = Date.now();
|
|
12
|
+
if (!_runtimeAnalyticsStore.activeTimings.has(eventName)) {
|
|
13
|
+
_runtimeAnalyticsStore.activeTimings.set(eventName, now);
|
|
14
|
+
recordEvent(`timing:start:${eventName}`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const startTime = _runtimeAnalyticsStore.activeTimings.get(eventName);
|
|
18
|
+
if (startTime === undefined)
|
|
19
|
+
return;
|
|
20
|
+
const duration = now - startTime;
|
|
21
|
+
_runtimeAnalyticsStore.timings.push({
|
|
22
|
+
event: eventName,
|
|
23
|
+
duration,
|
|
24
|
+
});
|
|
25
|
+
_runtimeAnalyticsStore.activeTimings.delete(eventName);
|
|
26
|
+
recordEvent(`timing:end:${eventName}`);
|
|
27
|
+
}
|
|
28
|
+
export function recordError(error) {
|
|
29
|
+
const category = categorizeError(error);
|
|
30
|
+
const errorEntry = {
|
|
31
|
+
category,
|
|
32
|
+
message: error instanceof Error ? error.message : String(error),
|
|
33
|
+
timestamp: Date.now(),
|
|
34
|
+
};
|
|
35
|
+
_runtimeAnalyticsStore.errors.push(errorEntry);
|
|
36
|
+
recordEvent(`error:${category}:${errorEntry.message.substring(0, 50)}`);
|
|
37
|
+
}
|
|
38
|
+
export function recordRetry(url, operation) {
|
|
39
|
+
const existingEntries = _runtimeAnalyticsStore.retries.filter((entry) => entry.url === url && entry.operation === operation);
|
|
40
|
+
const attemptCount = existingEntries.length + 1;
|
|
41
|
+
_runtimeAnalyticsStore.retries.push({
|
|
42
|
+
url,
|
|
43
|
+
operation,
|
|
44
|
+
attempts: attemptCount,
|
|
45
|
+
timestamp: Date.now(),
|
|
46
|
+
});
|
|
47
|
+
recordEvent(`retry:${operation}:attempt:${attemptCount}`);
|
|
48
|
+
}
|
|
49
|
+
export function recordEvent(eventName) {
|
|
50
|
+
_runtimeAnalyticsStore.events.push({
|
|
51
|
+
name: eventName,
|
|
52
|
+
timestamp: Date.now(),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export function compileData() {
|
|
56
|
+
return {
|
|
57
|
+
timings: _runtimeAnalyticsStore.timings.toArray(),
|
|
58
|
+
errors: _runtimeAnalyticsStore.errors.toArray(),
|
|
59
|
+
retries: _runtimeAnalyticsStore.retries.toArray(),
|
|
60
|
+
events: _runtimeAnalyticsStore.events.toArray(),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function reset() {
|
|
64
|
+
_runtimeAnalyticsStore.timings.clear();
|
|
65
|
+
_runtimeAnalyticsStore.activeTimings.clear();
|
|
66
|
+
_runtimeAnalyticsStore.errors.clear();
|
|
67
|
+
_runtimeAnalyticsStore.retries.clear();
|
|
68
|
+
_runtimeAnalyticsStore.events.clear();
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../../../src/public/node/themes/analytics/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAgB,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAC,MAAM,EAAE,IAAI,EAAC,MAAM,0BAA0B,CAAA;AAgCrD,MAAM,sBAAsB,GAAG;IAC7B,OAAO,EAAE,IAAI,MAAM,EAAe;IAClC,aAAa,EAAE,IAAI,IAAI,EAAkB;IACzC,MAAM,EAAE,IAAI,MAAM,EAAc;IAChC,OAAO,EAAE,IAAI,MAAM,EAAc;IACjC,MAAM,EAAE,IAAI,MAAM,EAAc;CACjC,CAAA;AAED,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;IAEtB,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QACzD,sBAAsB,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACxD,WAAW,CAAC,gBAAgB,SAAS,EAAE,CAAC,CAAA;QACxC,OAAM;IACR,CAAC;IAED,MAAM,SAAS,GAAG,sBAAsB,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACrE,IAAI,SAAS,KAAK,SAAS;QAAE,OAAM;IAEnC,MAAM,QAAQ,GAAG,GAAG,GAAG,SAAS,CAAA;IAEhC,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC;QAClC,KAAK,EAAE,SAAS;QAChB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AAI,EAAE,SAAS;QACf,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACtB,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,OAAO,EAAE,sBAAsB,CAAC,OAAO,CAAC,OAAO,EAAE;QACjD,MAAM,EAAE,sBAAsB,CAAC,MAAM,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, 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),\n timestamp: Date.now(),\n }\n\n _runtimeAnalyticsStore.errors.push(errorEntry)\n\n recordEvent(`error:${category}:${errorEntry.message.substring(0, 50)}`)\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,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records timing data for performance monitoring. Call twice with the same
|
|
3
|
+
* event name to start and stop timing. First call starts the timer, second
|
|
4
|
+
* call stops it and records the duration.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* recordTiming('theme-upload') // Start timing
|
|
9
|
+
* // ... do work ...
|
|
10
|
+
* recordTiming('theme-upload') // Stop timing and record duration
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param eventName - Unique identifier for the timing event
|
|
14
|
+
*/
|
|
15
|
+
export declare function recordTiming(eventName: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Records error information for debugging and monitoring. Use this to track
|
|
18
|
+
* any exceptions or error conditions that occur during theme operations.
|
|
19
|
+
* Errors are automatically categorized for easier analysis.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* try {
|
|
24
|
+
* // ... risky operation ...
|
|
25
|
+
* } catch (error) {
|
|
26
|
+
* recordError(error)
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param error - Error object or message to record
|
|
31
|
+
*/
|
|
32
|
+
export declare function recordError<T>(error: T): T;
|
|
33
|
+
/**
|
|
34
|
+
* Records retry attempts for network operations. Use this to track when
|
|
35
|
+
* operations are retried due to transient failures. Helps identify
|
|
36
|
+
* problematic endpoints or operations that frequently fail.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* recordRetry('https://api.shopify.com/themes', 'upload')
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @param url - The URL or endpoint being retried
|
|
44
|
+
* @param operation - Description of the operation being retried
|
|
45
|
+
*/
|
|
46
|
+
export declare function recordRetry(url: string, operation: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Records custom events for tracking specific user actions or system events.
|
|
49
|
+
* Use this for important milestones, user interactions, or significant
|
|
50
|
+
* state changes in the application.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* recordEvent('theme-dev-started')
|
|
55
|
+
* recordEvent('file-watcher-connected')
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @param eventName - Descriptive name for the event
|
|
59
|
+
*/
|
|
60
|
+
export declare function recordEvent(eventName: string): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { recordTiming as storeRecordTiming, recordError as storeRecordError, recordRetry as storeRecordRetry, recordEvent as storeRecordEvent, } from './analytics/storage.js';
|
|
2
|
+
/**
|
|
3
|
+
* Records timing data for performance monitoring. Call twice with the same
|
|
4
|
+
* event name to start and stop timing. First call starts the timer, second
|
|
5
|
+
* call stops it and records the duration.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* recordTiming('theme-upload') // Start timing
|
|
10
|
+
* // ... do work ...
|
|
11
|
+
* recordTiming('theme-upload') // Stop timing and record duration
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @param eventName - Unique identifier for the timing event
|
|
15
|
+
*/
|
|
16
|
+
export function recordTiming(eventName) {
|
|
17
|
+
storeRecordTiming(eventName);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Records error information for debugging and monitoring. Use this to track
|
|
21
|
+
* any exceptions or error conditions that occur during theme operations.
|
|
22
|
+
* Errors are automatically categorized for easier analysis.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* try {
|
|
27
|
+
* // ... risky operation ...
|
|
28
|
+
* } catch (error) {
|
|
29
|
+
* recordError(error)
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @param error - Error object or message to record
|
|
34
|
+
*/
|
|
35
|
+
export function recordError(error) {
|
|
36
|
+
storeRecordError(error);
|
|
37
|
+
return error;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Records retry attempts for network operations. Use this to track when
|
|
41
|
+
* operations are retried due to transient failures. Helps identify
|
|
42
|
+
* problematic endpoints or operations that frequently fail.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* recordRetry('https://api.shopify.com/themes', 'upload')
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param url - The URL or endpoint being retried
|
|
50
|
+
* @param operation - Description of the operation being retried
|
|
51
|
+
*/
|
|
52
|
+
export function recordRetry(url, operation) {
|
|
53
|
+
storeRecordRetry(url, operation);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Records custom events for tracking specific user actions or system events.
|
|
57
|
+
* Use this for important milestones, user interactions, or significant
|
|
58
|
+
* state changes in the application.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* recordEvent('theme-dev-started')
|
|
63
|
+
* recordEvent('file-watcher-connected')
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param eventName - Descriptive name for the event
|
|
67
|
+
*/
|
|
68
|
+
export function recordEvent(eventName) {
|
|
69
|
+
storeRecordEvent(eventName);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=analytics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../../../src/public/node/themes/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,IAAI,iBAAiB,EACjC,WAAW,IAAI,gBAAgB,EAC/B,WAAW,IAAI,gBAAgB,EAC/B,WAAW,IAAI,gBAAgB,GAChC,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,iBAAiB,CAAC,SAAS,CAAC,CAAA;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,WAAW,CAAI,KAAQ;IACrC,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACvB,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,SAAiB;IACxD,gBAAgB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;AAClC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,gBAAgB,CAAC,SAAS,CAAC,CAAA;AAC7B,CAAC","sourcesContent":["import {\n recordTiming as storeRecordTiming,\n recordError as storeRecordError,\n recordRetry as storeRecordRetry,\n recordEvent as storeRecordEvent,\n} from './analytics/storage.js'\n\n/**\n * Records timing data for performance monitoring. Call twice with the same\n * event name to start and stop timing. First call starts the timer, second\n * call stops it and records the duration.\n *\n * @example\n * ```ts\n * recordTiming('theme-upload') // Start timing\n * // ... do work ...\n * recordTiming('theme-upload') // Stop timing and record duration\n * ```\n *\n * @param eventName - Unique identifier for the timing event\n */\nexport function recordTiming(eventName: string): void {\n storeRecordTiming(eventName)\n}\n\n/**\n * Records error information for debugging and monitoring. Use this to track\n * any exceptions or error conditions that occur during theme operations.\n * Errors are automatically categorized for easier analysis.\n *\n * @example\n * ```ts\n * try {\n * // ... risky operation ...\n * } catch (error) {\n * recordError(error)\n * }\n * ```\n *\n * @param error - Error object or message to record\n */\nexport function recordError<T>(error: T): T {\n storeRecordError(error)\n return error\n}\n\n/**\n * Records retry attempts for network operations. Use this to track when\n * operations are retried due to transient failures. Helps identify\n * problematic endpoints or operations that frequently fail.\n *\n * @example\n * ```ts\n * recordRetry('https://api.shopify.com/themes', 'upload')\n * ```\n *\n * @param url - The URL or endpoint being retried\n * @param operation - Description of the operation being retried\n */\nexport function recordRetry(url: string, operation: string): void {\n storeRecordRetry(url, operation)\n}\n\n/**\n * Records custom events for tracking specific user actions or system events.\n * Use this for important milestones, user interactions, or significant\n * state changes in the application.\n *\n * @example\n * ```ts\n * recordEvent('theme-dev-started')\n * recordEvent('file-watcher-connected')\n * ```\n *\n * @param eventName - Descriptive name for the event\n */\nexport function recordEvent(eventName: string): void {\n storeRecordEvent(eventName)\n}\n"]}
|
|
@@ -31,7 +31,7 @@ export async function fetchTheme(id, session) {
|
|
|
31
31
|
session,
|
|
32
32
|
variables: { id: gid },
|
|
33
33
|
responseOptions: { handleErrors: false },
|
|
34
|
-
|
|
34
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
35
35
|
});
|
|
36
36
|
if (theme) {
|
|
37
37
|
return buildTheme({
|
|
@@ -64,7 +64,7 @@ export async function fetchThemes(session) {
|
|
|
64
64
|
session,
|
|
65
65
|
variables: { after },
|
|
66
66
|
responseOptions: { handleErrors: false },
|
|
67
|
-
|
|
67
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
68
68
|
});
|
|
69
69
|
if (!response.themes) {
|
|
70
70
|
unexpectedGraphQLError('Failed to fetch themes');
|
|
@@ -98,7 +98,7 @@ export async function themeCreate(params, session) {
|
|
|
98
98
|
role: (params.role ?? DEVELOPMENT_THEME_ROLE).toUpperCase(),
|
|
99
99
|
},
|
|
100
100
|
responseOptions: { handleErrors: false },
|
|
101
|
-
|
|
101
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
102
102
|
});
|
|
103
103
|
if (!themeCreate) {
|
|
104
104
|
unexpectedGraphQLError('Failed to create theme');
|
|
@@ -127,7 +127,7 @@ export async function fetchThemeAssets(id, filenames, session) {
|
|
|
127
127
|
session,
|
|
128
128
|
variables: { id: themeGid(id), filenames, after },
|
|
129
129
|
responseOptions: { handleErrors: false },
|
|
130
|
-
|
|
130
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
131
131
|
});
|
|
132
132
|
if (!response.theme?.files?.nodes || !response.theme?.files?.pageInfo) {
|
|
133
133
|
const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ');
|
|
@@ -164,7 +164,7 @@ export async function deleteThemeAssets(id, filenames, session) {
|
|
|
164
164
|
themeId: composeThemeGid(id),
|
|
165
165
|
files: batch,
|
|
166
166
|
},
|
|
167
|
-
|
|
167
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
168
168
|
});
|
|
169
169
|
if (!themeFilesDelete) {
|
|
170
170
|
unexpectedGraphQLError('Failed to delete theme assets');
|
|
@@ -231,7 +231,7 @@ async function uploadFiles(themeId, files, session) {
|
|
|
231
231
|
query: ThemeFilesUpsert,
|
|
232
232
|
session,
|
|
233
233
|
variables: { themeId: themeGid(themeId), files },
|
|
234
|
-
|
|
234
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
235
235
|
});
|
|
236
236
|
}
|
|
237
237
|
function processUploadResults(uploadResults) {
|
|
@@ -271,7 +271,7 @@ export async function fetchChecksums(id, session) {
|
|
|
271
271
|
session,
|
|
272
272
|
variables: { id: themeGid(id), after },
|
|
273
273
|
responseOptions: { handleErrors: false },
|
|
274
|
-
|
|
274
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
275
275
|
});
|
|
276
276
|
if (!response?.theme?.files?.nodes || !response?.theme?.files?.pageInfo) {
|
|
277
277
|
const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ');
|
|
@@ -298,7 +298,7 @@ export async function themeUpdate(id, params, session) {
|
|
|
298
298
|
query: ThemeUpdate,
|
|
299
299
|
session,
|
|
300
300
|
variables: { id: composeThemeGid(id), input },
|
|
301
|
-
|
|
301
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
302
302
|
});
|
|
303
303
|
if (!themeUpdate) {
|
|
304
304
|
// An unexpected error occurred during the GraphQL request execution
|
|
@@ -324,7 +324,7 @@ export async function themePublish(id, session) {
|
|
|
324
324
|
query: ThemePublish,
|
|
325
325
|
session,
|
|
326
326
|
variables: { id: composeThemeGid(id) },
|
|
327
|
-
|
|
327
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
328
328
|
});
|
|
329
329
|
if (!themePublish) {
|
|
330
330
|
// An unexpected error occurred during the GraphQL request execution
|
|
@@ -350,7 +350,7 @@ export async function themeDelete(id, session) {
|
|
|
350
350
|
query: ThemeDelete,
|
|
351
351
|
session,
|
|
352
352
|
variables: { id: composeThemeGid(id) },
|
|
353
|
-
|
|
353
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
354
354
|
});
|
|
355
355
|
if (!themeDelete) {
|
|
356
356
|
// An unexpected error occurred during the GraphQL request execution
|
|
@@ -373,7 +373,7 @@ export async function themeDuplicate(id, name, session) {
|
|
|
373
373
|
query: ThemeDuplicate,
|
|
374
374
|
session,
|
|
375
375
|
variables: { id: composeThemeGid(id), name },
|
|
376
|
-
|
|
376
|
+
preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,
|
|
377
377
|
version: '2025-10',
|
|
378
378
|
responseOptions: {
|
|
379
379
|
onResponse: (response) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/public/node/themes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAA2C,SAAS,EAAC,MAAM,YAAY,CAAA;AAC9E,OAAO,EAAC,WAAW,EAAC,MAAM,0DAA0D,CAAA;AACpF,OAAO,EAAC,WAAW,EAAC,MAAM,0DAA0D,CAAA;AACpF,OAAO,EAAC,cAAc,EAAC,MAAM,6DAA6D,CAAA;AAC1F,OAAO,EAAC,YAAY,EAAC,MAAM,2DAA2D,CAAA;AACtF,OAAO,EAAC,WAAW,EAAC,MAAM,0DAA0D,CAAA;AACpF,OAAO,EAAC,kBAAkB,EAAC,MAAM,mEAAmE,CAAA;AACpG,OAAO,EAAC,qBAAqB,EAAC,MAAM,sEAAsE,CAAA;AAC1G,OAAO,EACL,gBAAgB,GAEjB,MAAM,gEAAgE,CAAA;AACvE,OAAO,EAAC,gBAAgB,EAAC,MAAM,gEAAgE,CAAA;AAO/F,OAAO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gBACjD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAEtC,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAA;gBAChD,OAAO,EAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC,CAAA;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,4CAA4C;gBAC5C,MAAM,IAAI,UAAU,CAAC,uCAAuC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;YACzE,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import {composeThemeGid, parseGid, DEVELOPMENT_THEME_ROLE} from './utils.js'\nimport {buildTheme} from './factories.js'\nimport {Result, Checksum, Key, Theme, ThemeAsset, Operation} from './types.js'\nimport {ThemeUpdate} from '../../../cli/api/graphql/admin/generated/theme_update.js'\nimport {ThemeDelete} from '../../../cli/api/graphql/admin/generated/theme_delete.js'\nimport {ThemeDuplicate} from '../../../cli/api/graphql/admin/generated/theme_duplicate.js'\nimport {ThemePublish} from '../../../cli/api/graphql/admin/generated/theme_publish.js'\nimport {ThemeCreate} from '../../../cli/api/graphql/admin/generated/theme_create.js'\nimport {GetThemeFileBodies} from '../../../cli/api/graphql/admin/generated/get_theme_file_bodies.js'\nimport {GetThemeFileChecksums} from '../../../cli/api/graphql/admin/generated/get_theme_file_checksums.js'\nimport {\n ThemeFilesUpsert,\n ThemeFilesUpsertMutation,\n} from '../../../cli/api/graphql/admin/generated/theme_files_upsert.js'\nimport {ThemeFilesDelete} from '../../../cli/api/graphql/admin/generated/theme_files_delete.js'\nimport {\n OnlineStoreThemeFileBodyInputType,\n OnlineStoreThemeFilesUpsertFileInput,\n MetafieldOwnerType,\n ThemeRole,\n} from '../../../cli/api/graphql/admin/generated/types.js'\nimport {MetafieldDefinitionsByOwnerType} from '../../../cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js'\nimport {GetThemes} from '../../../cli/api/graphql/admin/generated/get_themes.js'\nimport {GetTheme} from '../../../cli/api/graphql/admin/generated/get_theme.js'\nimport {OnlineStorePasswordProtection} from '../../../cli/api/graphql/admin/generated/online_store_password_protection.js'\nimport {RequestModeInput} from '../http.js'\nimport {adminRequestDoc} from '../api/admin.js'\nimport {AdminSession} from '../session.js'\nimport {AbortError} from '../error.js'\nimport {outputDebug} from '../output.js'\n\nexport type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing' | 'src'>>\nexport type AssetParams = Pick<ThemeAsset, 'key'> & Partial<Pick<ThemeAsset, 'value' | 'attachment'>>\nconst SkeletonThemeCdn = 'https://cdn.shopify.com/static/online-store/theme-skeleton.zip'\nconst THEME_API_NETWORK_BEHAVIOUR: RequestModeInput = {\n useNetworkLevelRetry: true,\n useAbortSignal: false,\n maxRetryTimeMs: 90 * 1000,\n}\n\nexport async function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const gid = composeThemeGid(id)\n\n try {\n const {theme} = await adminRequestDoc({\n query: GetTheme,\n session,\n variables: {id: gid},\n responseOptions: {handleErrors: false},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (theme) {\n return buildTheme({\n id: parseGid(theme.id),\n processing: theme.processing,\n role: theme.role.toLowerCase(),\n name: theme.name,\n })\n }\n\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_error) {\n /**\n * Consumers of this and other theme APIs in this file expect either a theme\n * or `undefined`.\n *\n * Error handlers should not inspect GraphQL error messages directly, as\n * they are internationalized.\n */\n outputDebug(`Error fetching theme with ID: ${id}`)\n }\n}\n\nexport async function fetchThemes(session: AdminSession): Promise<Theme[]> {\n const themes: Theme[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemes,\n session,\n variables: {after},\n responseOptions: {handleErrors: false},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!response.themes) {\n unexpectedGraphQLError('Failed to fetch themes')\n }\n const {nodes, pageInfo} = response.themes\n nodes.forEach((theme) => {\n const t = buildTheme({\n id: parseGid(theme.id),\n processing: theme.processing,\n role: theme.role.toLowerCase(),\n name: theme.name,\n })\n if (t) {\n themes.push(t)\n }\n })\n if (!pageInfo.hasNextPage) {\n return themes\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function themeCreate(params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const themeSource = params.src ?? SkeletonThemeCdn\n const {themeCreate} = await adminRequestDoc({\n query: ThemeCreate,\n session,\n variables: {\n name: params.name ?? '',\n source: themeSource,\n role: (params.role ?? DEVELOPMENT_THEME_ROLE).toUpperCase() as ThemeRole,\n },\n responseOptions: {handleErrors: false},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!themeCreate) {\n unexpectedGraphQLError('Failed to create theme')\n }\n\n const {theme, userErrors} = themeCreate\n if (userErrors.length) {\n const userErrors = themeCreate.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n unexpectedGraphQLError('Failed to create theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function fetchThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<ThemeAsset[]> {\n const assets: ThemeAsset[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemeFileBodies,\n session,\n variables: {id: themeGid(id), filenames, after},\n responseOptions: {handleErrors: false},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!response.theme?.files?.nodes || !response.theme?.files?.pageInfo) {\n const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ')\n unexpectedGraphQLError(`Error fetching assets: ${userErrors}`)\n }\n\n const {nodes, pageInfo} = response.theme.files\n\n assets.push(\n // eslint-disable-next-line no-await-in-loop\n ...(await Promise.all(\n nodes.map(async (file) => {\n const {attachment, value} = await parseThemeFileContent(file.body)\n return {\n attachment,\n key: file.filename,\n checksum: file.checksumMd5 as string,\n value,\n }\n }),\n )),\n )\n\n if (!pageInfo.hasNextPage) {\n return assets\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function deleteThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<Result[]> {\n const batchSize = 50\n const results: Result[] = []\n\n for (let i = 0; i < filenames.length; i += batchSize) {\n const batch = filenames.slice(i, i + batchSize)\n // eslint-disable-next-line no-await-in-loop\n const {themeFilesDelete} = await adminRequestDoc({\n query: ThemeFilesDelete,\n session,\n variables: {\n themeId: composeThemeGid(id),\n files: batch,\n },\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!themeFilesDelete) {\n unexpectedGraphQLError('Failed to delete theme assets')\n }\n\n const {deletedThemeFiles, userErrors} = themeFilesDelete\n\n if (deletedThemeFiles) {\n deletedThemeFiles.forEach((file) => {\n results.push({key: file.filename, success: true, operation: Operation.Delete})\n })\n }\n\n if (userErrors.length > 0) {\n userErrors.forEach((error) => {\n if (error.filename) {\n results.push({\n key: error.filename,\n success: false,\n operation: Operation.Delete,\n errors: {asset: [error.message]},\n })\n } else {\n unexpectedGraphQLError(`Failed to delete theme assets: ${error.message}`)\n }\n })\n }\n }\n\n return results\n}\n\nexport async function bulkUploadThemeAssets(\n id: number,\n assets: AssetParams[],\n session: AdminSession,\n): Promise<Result[]> {\n const results: Result[] = []\n for (let i = 0; i < assets.length; i += 50) {\n const chunk = assets.slice(i, i + 50)\n const files = prepareFilesForUpload(chunk)\n // eslint-disable-next-line no-await-in-loop\n const uploadResults = await uploadFiles(id, files, session)\n results.push(...processUploadResults(uploadResults))\n }\n return results\n}\n\nfunction prepareFilesForUpload(assets: AssetParams[]): OnlineStoreThemeFilesUpsertFileInput[] {\n return assets.map((asset) => {\n if (asset.attachment) {\n return {\n filename: asset.key,\n body: {\n type: 'BASE64' as const,\n value: asset.attachment,\n },\n }\n } else {\n return {\n filename: asset.key,\n body: {\n type: 'TEXT' as const,\n value: asset.value ?? '',\n },\n }\n }\n })\n}\n\nasync function uploadFiles(\n themeId: number,\n files: {filename: string; body: {type: OnlineStoreThemeFileBodyInputType; value: string}}[],\n session: AdminSession,\n): Promise<ThemeFilesUpsertMutation> {\n return adminRequestDoc({\n query: ThemeFilesUpsert,\n session,\n variables: {themeId: themeGid(themeId), files},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n}\n\nfunction processUploadResults(uploadResults: ThemeFilesUpsertMutation): Result[] {\n const {themeFilesUpsert} = uploadResults\n\n if (!themeFilesUpsert) {\n unexpectedGraphQLError('Failed to upload theme files')\n }\n\n const {upsertedThemeFiles, userErrors} = themeFilesUpsert\n\n const results: Result[] = []\n\n upsertedThemeFiles?.forEach((file) => {\n results.push({\n key: file.filename,\n success: true,\n operation: Operation.Upload,\n })\n })\n\n userErrors.forEach((error) => {\n if (!error.filename) {\n unexpectedGraphQLError(`Error uploading theme files: ${error.message}`)\n }\n results.push({\n key: error.filename,\n success: false,\n operation: Operation.Upload,\n errors: {asset: [error.message]},\n })\n })\n\n return results\n}\n\nexport async function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]> {\n const checksums: Checksum[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemeFileChecksums,\n session,\n variables: {id: themeGid(id), after},\n responseOptions: {handleErrors: false},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!response?.theme?.files?.nodes || !response?.theme?.files?.pageInfo) {\n const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ')\n throw new AbortError(`Failed to fetch checksums for: ${userErrors}`)\n }\n\n const {nodes, pageInfo} = response.theme.files\n\n checksums.push(\n ...nodes.map((file) => ({\n key: file.filename,\n checksum: file.checksumMd5 as string,\n })),\n )\n\n if (!pageInfo.hasNextPage) {\n return checksums\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function themeUpdate(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const name = params.name\n const input: {[key: string]: string} = {}\n if (name) {\n input.name = name\n }\n\n const {themeUpdate} = await adminRequestDoc({\n query: ThemeUpdate,\n session,\n variables: {id: composeThemeGid(id), input},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themeUpdate) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {theme, userErrors} = themeUpdate\n if (userErrors.length) {\n const userErrors = themeUpdate.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function themePublish(id: number, session: AdminSession): Promise<Theme | undefined> {\n const {themePublish} = await adminRequestDoc({\n query: ThemePublish,\n session,\n variables: {id: composeThemeGid(id)},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themePublish) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {theme, userErrors} = themePublish\n if (userErrors.length) {\n const userErrors = themePublish.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function themeDelete(id: number, session: AdminSession): Promise<boolean | undefined> {\n const {themeDelete} = await adminRequestDoc({\n query: ThemeDelete,\n session,\n variables: {id: composeThemeGid(id)},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themeDelete) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {deletedThemeId, userErrors} = themeDelete\n if (userErrors.length) {\n const userErrors = themeDelete.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!deletedThemeId) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return true\n}\n\nexport interface ThemeDuplicateResult {\n theme?: Theme\n userErrors: {field?: string[] | null; message: string}[]\n requestId?: string\n}\n\nexport async function themeDuplicate(\n id: number,\n name: string | undefined,\n session: AdminSession,\n): Promise<ThemeDuplicateResult> {\n let requestId: string | undefined\n\n const {themeDuplicate} = await adminRequestDoc({\n query: ThemeDuplicate,\n session,\n variables: {id: composeThemeGid(id), name},\n requestBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n version: '2025-10',\n responseOptions: {\n onResponse: (response) => {\n requestId = response.headers.get('x-request-id') ?? undefined\n },\n },\n })\n\n if (!themeDuplicate) {\n // An unexpected error occurred during the GraphQL request execution\n return {\n theme: undefined,\n userErrors: [{message: 'Failed to duplicate theme'}],\n requestId,\n }\n }\n\n const {newTheme, userErrors} = themeDuplicate\n\n if (userErrors.length > 0) {\n return {\n theme: undefined,\n userErrors,\n requestId,\n }\n }\n\n if (!newTheme) {\n // An unexpected error if neither theme nor userErrors are returned\n return {\n theme: undefined,\n userErrors: [{message: 'Failed to duplicate theme'}],\n requestId,\n }\n }\n\n const theme = buildTheme({\n id: parseGid(newTheme.id),\n name: newTheme.name,\n role: newTheme.role.toLowerCase(),\n })\n\n return {\n theme,\n userErrors: [],\n requestId,\n }\n}\n\nexport async function metafieldDefinitionsByOwnerType(type: MetafieldOwnerType, session: AdminSession) {\n const {metafieldDefinitions} = await adminRequestDoc({\n query: MetafieldDefinitionsByOwnerType,\n session,\n variables: {ownerType: type},\n })\n\n return metafieldDefinitions.nodes.map((definition) => ({\n key: definition.key,\n namespace: definition.namespace,\n name: definition.name,\n description: definition.description,\n type: {\n name: definition.type.name,\n category: definition.type.category,\n },\n }))\n}\n\nexport async function passwordProtected(session: AdminSession): Promise<boolean> {\n const {onlineStore} = await adminRequestDoc({\n query: OnlineStorePasswordProtection,\n session,\n })\n if (!onlineStore) {\n unexpectedGraphQLError(\"Unable to get details about the storefront's password protection\")\n }\n\n const {passwordProtection} = onlineStore\n\n return passwordProtection.enabled\n}\n\nfunction unexpectedGraphQLError(message: string): never {\n throw new AbortError(message)\n}\n\nfunction themeGid(id: number): string {\n return `gid://shopify/OnlineStoreTheme/${id}`\n}\n\ntype OnlineStoreThemeFileBody =\n | {__typename: 'OnlineStoreThemeFileBodyBase64'; contentBase64: string}\n | {__typename: 'OnlineStoreThemeFileBodyText'; content: string}\n | {__typename: 'OnlineStoreThemeFileBodyUrl'; url: string}\n\nexport async function parseThemeFileContent(\n body: OnlineStoreThemeFileBody,\n): Promise<{value?: string; attachment?: string}> {\n switch (body.__typename) {\n case 'OnlineStoreThemeFileBodyText':\n return {value: body.content}\n case 'OnlineStoreThemeFileBodyBase64':\n return {attachment: body.contentBase64}\n case 'OnlineStoreThemeFileBodyUrl':\n try {\n // eslint-disable-next-line no-restricted-globals\n const response = await fetch(body.url)\n\n const arrayBuffer = await response.arrayBuffer()\n return {attachment: Buffer.from(arrayBuffer).toString('base64')}\n } catch (error) {\n // Raise error if we can't download the file\n throw new AbortError(`Error downloading content from URL: ${body.url}`)\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/public/node/themes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAE,sBAAsB,EAAC,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAA2C,SAAS,EAAC,MAAM,YAAY,CAAA;AAC9E,OAAO,EAAC,WAAW,EAAC,MAAM,0DAA0D,CAAA;AACpF,OAAO,EAAC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AAC;AAED,SAAS,QAAQ,CAAC,EAAU;IAC1B,OAAO,kCAAkC,EAAE,EAAE,CAAA;AAC/C,CAAC;AAOD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA8B;IAE9B,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QACxB,KAAK,8BAA8B;YACjC,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAC,CAAA;QAC9B,KAAK,gCAAgC;YACnC,OAAO,EAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAC,CAAA;QACzC,KAAK,6BAA6B;YAChC,IAAI,CAAC;gBACH,iDAAiD;gBACjD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBAEtC,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAA;gBAChD,OAAO,EAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC,CAAA;YAClE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,4CAA4C;gBAC5C,MAAM,IAAI,UAAU,CAAC,uCAAuC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAA;YACzE,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import {composeThemeGid, parseGid, DEVELOPMENT_THEME_ROLE} from './utils.js'\nimport {buildTheme} from './factories.js'\nimport {Result, Checksum, Key, Theme, ThemeAsset, Operation} from './types.js'\nimport {ThemeUpdate} from '../../../cli/api/graphql/admin/generated/theme_update.js'\nimport {ThemeDelete} from '../../../cli/api/graphql/admin/generated/theme_delete.js'\nimport {ThemeDuplicate} from '../../../cli/api/graphql/admin/generated/theme_duplicate.js'\nimport {ThemePublish} from '../../../cli/api/graphql/admin/generated/theme_publish.js'\nimport {ThemeCreate} from '../../../cli/api/graphql/admin/generated/theme_create.js'\nimport {GetThemeFileBodies} from '../../../cli/api/graphql/admin/generated/get_theme_file_bodies.js'\nimport {GetThemeFileChecksums} from '../../../cli/api/graphql/admin/generated/get_theme_file_checksums.js'\nimport {\n ThemeFilesUpsert,\n ThemeFilesUpsertMutation,\n} from '../../../cli/api/graphql/admin/generated/theme_files_upsert.js'\nimport {ThemeFilesDelete} from '../../../cli/api/graphql/admin/generated/theme_files_delete.js'\nimport {\n OnlineStoreThemeFileBodyInputType,\n OnlineStoreThemeFilesUpsertFileInput,\n MetafieldOwnerType,\n ThemeRole,\n} from '../../../cli/api/graphql/admin/generated/types.js'\nimport {MetafieldDefinitionsByOwnerType} from '../../../cli/api/graphql/admin/generated/metafield_definitions_by_owner_type.js'\nimport {GetThemes} from '../../../cli/api/graphql/admin/generated/get_themes.js'\nimport {GetTheme} from '../../../cli/api/graphql/admin/generated/get_theme.js'\nimport {OnlineStorePasswordProtection} from '../../../cli/api/graphql/admin/generated/online_store_password_protection.js'\nimport {RequestModeInput} from '../http.js'\nimport {adminRequestDoc} from '../api/admin.js'\nimport {AdminSession} from '../session.js'\nimport {AbortError} from '../error.js'\nimport {outputDebug} from '../output.js'\n\nexport type ThemeParams = Partial<Pick<Theme, 'name' | 'role' | 'processing' | 'src'>>\nexport type AssetParams = Pick<ThemeAsset, 'key'> & Partial<Pick<ThemeAsset, 'value' | 'attachment'>>\nconst SkeletonThemeCdn = 'https://cdn.shopify.com/static/online-store/theme-skeleton.zip'\nconst THEME_API_NETWORK_BEHAVIOUR: RequestModeInput = {\n useNetworkLevelRetry: true,\n useAbortSignal: false,\n maxRetryTimeMs: 90 * 1000,\n}\n\nexport async function fetchTheme(id: number, session: AdminSession): Promise<Theme | undefined> {\n const gid = composeThemeGid(id)\n\n try {\n const {theme} = await adminRequestDoc({\n query: GetTheme,\n session,\n variables: {id: gid},\n responseOptions: {handleErrors: false},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (theme) {\n return buildTheme({\n id: parseGid(theme.id),\n processing: theme.processing,\n role: theme.role.toLowerCase(),\n name: theme.name,\n })\n }\n\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (_error) {\n /**\n * Consumers of this and other theme APIs in this file expect either a theme\n * or `undefined`.\n *\n * Error handlers should not inspect GraphQL error messages directly, as\n * they are internationalized.\n */\n outputDebug(`Error fetching theme with ID: ${id}`)\n }\n}\n\nexport async function fetchThemes(session: AdminSession): Promise<Theme[]> {\n const themes: Theme[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemes,\n session,\n variables: {after},\n responseOptions: {handleErrors: false},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!response.themes) {\n unexpectedGraphQLError('Failed to fetch themes')\n }\n const {nodes, pageInfo} = response.themes\n nodes.forEach((theme) => {\n const t = buildTheme({\n id: parseGid(theme.id),\n processing: theme.processing,\n role: theme.role.toLowerCase(),\n name: theme.name,\n })\n if (t) {\n themes.push(t)\n }\n })\n if (!pageInfo.hasNextPage) {\n return themes\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function themeCreate(params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const themeSource = params.src ?? SkeletonThemeCdn\n const {themeCreate} = await adminRequestDoc({\n query: ThemeCreate,\n session,\n variables: {\n name: params.name ?? '',\n source: themeSource,\n role: (params.role ?? DEVELOPMENT_THEME_ROLE).toUpperCase() as ThemeRole,\n },\n responseOptions: {handleErrors: false},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!themeCreate) {\n unexpectedGraphQLError('Failed to create theme')\n }\n\n const {theme, userErrors} = themeCreate\n if (userErrors.length) {\n const userErrors = themeCreate.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n unexpectedGraphQLError('Failed to create theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function fetchThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<ThemeAsset[]> {\n const assets: ThemeAsset[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemeFileBodies,\n session,\n variables: {id: themeGid(id), filenames, after},\n responseOptions: {handleErrors: false},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!response.theme?.files?.nodes || !response.theme?.files?.pageInfo) {\n const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ')\n unexpectedGraphQLError(`Error fetching assets: ${userErrors}`)\n }\n\n const {nodes, pageInfo} = response.theme.files\n\n assets.push(\n // eslint-disable-next-line no-await-in-loop\n ...(await Promise.all(\n nodes.map(async (file) => {\n const {attachment, value} = await parseThemeFileContent(file.body)\n return {\n attachment,\n key: file.filename,\n checksum: file.checksumMd5 as string,\n value,\n }\n }),\n )),\n )\n\n if (!pageInfo.hasNextPage) {\n return assets\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function deleteThemeAssets(id: number, filenames: Key[], session: AdminSession): Promise<Result[]> {\n const batchSize = 50\n const results: Result[] = []\n\n for (let i = 0; i < filenames.length; i += batchSize) {\n const batch = filenames.slice(i, i + batchSize)\n // eslint-disable-next-line no-await-in-loop\n const {themeFilesDelete} = await adminRequestDoc({\n query: ThemeFilesDelete,\n session,\n variables: {\n themeId: composeThemeGid(id),\n files: batch,\n },\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!themeFilesDelete) {\n unexpectedGraphQLError('Failed to delete theme assets')\n }\n\n const {deletedThemeFiles, userErrors} = themeFilesDelete\n\n if (deletedThemeFiles) {\n deletedThemeFiles.forEach((file) => {\n results.push({key: file.filename, success: true, operation: Operation.Delete})\n })\n }\n\n if (userErrors.length > 0) {\n userErrors.forEach((error) => {\n if (error.filename) {\n results.push({\n key: error.filename,\n success: false,\n operation: Operation.Delete,\n errors: {asset: [error.message]},\n })\n } else {\n unexpectedGraphQLError(`Failed to delete theme assets: ${error.message}`)\n }\n })\n }\n }\n\n return results\n}\n\nexport async function bulkUploadThemeAssets(\n id: number,\n assets: AssetParams[],\n session: AdminSession,\n): Promise<Result[]> {\n const results: Result[] = []\n for (let i = 0; i < assets.length; i += 50) {\n const chunk = assets.slice(i, i + 50)\n const files = prepareFilesForUpload(chunk)\n // eslint-disable-next-line no-await-in-loop\n const uploadResults = await uploadFiles(id, files, session)\n results.push(...processUploadResults(uploadResults))\n }\n return results\n}\n\nfunction prepareFilesForUpload(assets: AssetParams[]): OnlineStoreThemeFilesUpsertFileInput[] {\n return assets.map((asset) => {\n if (asset.attachment) {\n return {\n filename: asset.key,\n body: {\n type: 'BASE64' as const,\n value: asset.attachment,\n },\n }\n } else {\n return {\n filename: asset.key,\n body: {\n type: 'TEXT' as const,\n value: asset.value ?? '',\n },\n }\n }\n })\n}\n\nasync function uploadFiles(\n themeId: number,\n files: {filename: string; body: {type: OnlineStoreThemeFileBodyInputType; value: string}}[],\n session: AdminSession,\n): Promise<ThemeFilesUpsertMutation> {\n return adminRequestDoc({\n query: ThemeFilesUpsert,\n session,\n variables: {themeId: themeGid(themeId), files},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n}\n\nfunction processUploadResults(uploadResults: ThemeFilesUpsertMutation): Result[] {\n const {themeFilesUpsert} = uploadResults\n\n if (!themeFilesUpsert) {\n unexpectedGraphQLError('Failed to upload theme files')\n }\n\n const {upsertedThemeFiles, userErrors} = themeFilesUpsert\n\n const results: Result[] = []\n\n upsertedThemeFiles?.forEach((file) => {\n results.push({\n key: file.filename,\n success: true,\n operation: Operation.Upload,\n })\n })\n\n userErrors.forEach((error) => {\n if (!error.filename) {\n unexpectedGraphQLError(`Error uploading theme files: ${error.message}`)\n }\n results.push({\n key: error.filename,\n success: false,\n operation: Operation.Upload,\n errors: {asset: [error.message]},\n })\n })\n\n return results\n}\n\nexport async function fetchChecksums(id: number, session: AdminSession): Promise<Checksum[]> {\n const checksums: Checksum[] = []\n let after: string | null = null\n\n while (true) {\n // eslint-disable-next-line no-await-in-loop\n const response = await adminRequestDoc({\n query: GetThemeFileChecksums,\n session,\n variables: {id: themeGid(id), after},\n responseOptions: {handleErrors: false},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n\n if (!response?.theme?.files?.nodes || !response?.theme?.files?.pageInfo) {\n const userErrors = response.theme?.files?.userErrors.map((error) => error.filename).join(', ')\n throw new AbortError(`Failed to fetch checksums for: ${userErrors}`)\n }\n\n const {nodes, pageInfo} = response.theme.files\n\n checksums.push(\n ...nodes.map((file) => ({\n key: file.filename,\n checksum: file.checksumMd5 as string,\n })),\n )\n\n if (!pageInfo.hasNextPage) {\n return checksums\n }\n\n after = pageInfo.endCursor as string\n }\n}\n\nexport async function themeUpdate(id: number, params: ThemeParams, session: AdminSession): Promise<Theme | undefined> {\n const name = params.name\n const input: {[key: string]: string} = {}\n if (name) {\n input.name = name\n }\n\n const {themeUpdate} = await adminRequestDoc({\n query: ThemeUpdate,\n session,\n variables: {id: composeThemeGid(id), input},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themeUpdate) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {theme, userErrors} = themeUpdate\n if (userErrors.length) {\n const userErrors = themeUpdate.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function themePublish(id: number, session: AdminSession): Promise<Theme | undefined> {\n const {themePublish} = await adminRequestDoc({\n query: ThemePublish,\n session,\n variables: {id: composeThemeGid(id)},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themePublish) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {theme, userErrors} = themePublish\n if (userErrors.length) {\n const userErrors = themePublish.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!theme) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return buildTheme({\n id: parseGid(theme.id),\n name: theme.name,\n role: theme.role.toLowerCase(),\n })\n}\n\nexport async function themeDelete(id: number, session: AdminSession): Promise<boolean | undefined> {\n const {themeDelete} = await adminRequestDoc({\n query: ThemeDelete,\n session,\n variables: {id: composeThemeGid(id)},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n })\n if (!themeDelete) {\n // An unexpected error occurred during the GraphQL request execution\n unexpectedGraphQLError('Failed to update theme')\n }\n\n const {deletedThemeId, userErrors} = themeDelete\n if (userErrors.length) {\n const userErrors = themeDelete.userErrors.map((error) => error.message).join(', ')\n throw new AbortError(userErrors)\n }\n\n if (!deletedThemeId) {\n // An unexpected error if neither theme nor userErrors are returned\n unexpectedGraphQLError('Failed to update theme')\n }\n\n return true\n}\n\nexport interface ThemeDuplicateResult {\n theme?: Theme\n userErrors: {field?: string[] | null; message: string}[]\n requestId?: string\n}\n\nexport async function themeDuplicate(\n id: number,\n name: string | undefined,\n session: AdminSession,\n): Promise<ThemeDuplicateResult> {\n let requestId: string | undefined\n\n const {themeDuplicate} = await adminRequestDoc({\n query: ThemeDuplicate,\n session,\n variables: {id: composeThemeGid(id), name},\n preferredBehaviour: THEME_API_NETWORK_BEHAVIOUR,\n version: '2025-10',\n responseOptions: {\n onResponse: (response) => {\n requestId = response.headers.get('x-request-id') ?? undefined\n },\n },\n })\n\n if (!themeDuplicate) {\n // An unexpected error occurred during the GraphQL request execution\n return {\n theme: undefined,\n userErrors: [{message: 'Failed to duplicate theme'}],\n requestId,\n }\n }\n\n const {newTheme, userErrors} = themeDuplicate\n\n if (userErrors.length > 0) {\n return {\n theme: undefined,\n userErrors,\n requestId,\n }\n }\n\n if (!newTheme) {\n // An unexpected error if neither theme nor userErrors are returned\n return {\n theme: undefined,\n userErrors: [{message: 'Failed to duplicate theme'}],\n requestId,\n }\n }\n\n const theme = buildTheme({\n id: parseGid(newTheme.id),\n name: newTheme.name,\n role: newTheme.role.toLowerCase(),\n })\n\n return {\n theme,\n userErrors: [],\n requestId,\n }\n}\n\nexport async function metafieldDefinitionsByOwnerType(type: MetafieldOwnerType, session: AdminSession) {\n const {metafieldDefinitions} = await adminRequestDoc({\n query: MetafieldDefinitionsByOwnerType,\n session,\n variables: {ownerType: type},\n })\n\n return metafieldDefinitions.nodes.map((definition) => ({\n key: definition.key,\n namespace: definition.namespace,\n name: definition.name,\n description: definition.description,\n type: {\n name: definition.type.name,\n category: definition.type.category,\n },\n }))\n}\n\nexport async function passwordProtected(session: AdminSession): Promise<boolean> {\n const {onlineStore} = await adminRequestDoc({\n query: OnlineStorePasswordProtection,\n session,\n })\n if (!onlineStore) {\n unexpectedGraphQLError(\"Unable to get details about the storefront's password protection\")\n }\n\n const {passwordProtection} = onlineStore\n\n return passwordProtection.enabled\n}\n\nfunction unexpectedGraphQLError(message: string): never {\n throw new AbortError(message)\n}\n\nfunction themeGid(id: number): string {\n return `gid://shopify/OnlineStoreTheme/${id}`\n}\n\ntype OnlineStoreThemeFileBody =\n | {__typename: 'OnlineStoreThemeFileBodyBase64'; contentBase64: string}\n | {__typename: 'OnlineStoreThemeFileBodyText'; content: string}\n | {__typename: 'OnlineStoreThemeFileBodyUrl'; url: string}\n\nexport async function parseThemeFileContent(\n body: OnlineStoreThemeFileBody,\n): Promise<{value?: string; attachment?: string}> {\n switch (body.__typename) {\n case 'OnlineStoreThemeFileBodyText':\n return {value: body.content}\n case 'OnlineStoreThemeFileBodyBase64':\n return {attachment: body.contentBase64}\n case 'OnlineStoreThemeFileBodyUrl':\n try {\n // eslint-disable-next-line no-restricted-globals\n const response = await fetch(body.url)\n\n const arrayBuffer = await response.arrayBuffer()\n return {attachment: Buffer.from(arrayBuffer).toString('base64')}\n } catch (error) {\n // Raise error if we can't download the file\n throw new AbortError(`Error downloading content from URL: ${body.url}`)\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ConcurrentOutput, ConcurrentOutputContext, useConcurrentOutputContext, } from '../../../private/node/ui/components/ConcurrentOutput.js';
|
|
2
2
|
export { Alert } from '../../../private/node/ui/components/Alert.js';
|
|
3
3
|
export { Link } from '../../../private/node/ui/components/Link.js';
|
|
4
|
+
export { TabularData } from '../../../private/node/ui/components/TabularData.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { ConcurrentOutput, useConcurrentOutputContext, } from '../../../private/node/ui/components/ConcurrentOutput.js';
|
|
2
2
|
export { Alert } from '../../../private/node/ui/components/Alert.js';
|
|
3
3
|
export { Link } from '../../../private/node/ui/components/Link.js';
|
|
4
|
+
export { TabularData } from '../../../private/node/ui/components/TabularData.js';
|
|
4
5
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../../src/public/node/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,0BAA0B,GAC3B,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,8CAA8C,CAAA;AAClE,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAA","sourcesContent":["export {\n ConcurrentOutput,\n ConcurrentOutputContext,\n useConcurrentOutputContext,\n} from '../../../private/node/ui/components/ConcurrentOutput.js'\nexport {Alert} from '../../../private/node/ui/components/Alert.js'\nexport {Link} from '../../../private/node/ui/components/Link.js'\n"]}
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../../src/public/node/ui/components.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAEhB,0BAA0B,GAC3B,MAAM,yDAAyD,CAAA;AAChE,OAAO,EAAC,KAAK,EAAC,MAAM,8CAA8C,CAAA;AAClE,OAAO,EAAC,IAAI,EAAC,MAAM,6CAA6C,CAAA;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,oDAAoD,CAAA","sourcesContent":["export {\n ConcurrentOutput,\n ConcurrentOutputContext,\n useConcurrentOutputContext,\n} from '../../../private/node/ui/components/ConcurrentOutput.js'\nexport {Alert} from '../../../private/node/ui/components/Alert.js'\nexport {Link} from '../../../private/node/ui/components/Link.js'\nexport {TabularData} from '../../../private/node/ui/components/TabularData.js'\n"]}
|
|
@@ -78,7 +78,8 @@ export class BaseOtelService {
|
|
|
78
78
|
instrument.add(finalValue, finalLabels);
|
|
79
79
|
}
|
|
80
80
|
// We flush metrics after every record - we do not await as we fire & forget.
|
|
81
|
-
|
|
81
|
+
// Catch any export errors to prevent unhandled rejections from crashing the CLI
|
|
82
|
+
void this.meterProvider.forceFlush({}).catch(() => { });
|
|
82
83
|
};
|
|
83
84
|
record(firstValue, firstLabels);
|
|
84
85
|
this.metrics.set(metricName, record);
|