@shopify/cli-kit 3.65.2 → 3.66.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/dist/private/node/api.d.ts +10 -2
- package/dist/private/node/api.js +151 -14
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/conf-store.d.ts +27 -1
- package/dist/private/node/conf-store.js +39 -1
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/ui/components/SelectInput.js +1 -1
- package/dist/private/node/ui/components/SelectInput.js.map +1 -1
- package/dist/public/common/string.d.ts +7 -0
- package/dist/public/common/string.js +11 -0
- package/dist/public/common/string.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/app-dev.js +3 -1
- package/dist/public/node/api/app-dev.js.map +1 -1
- package/dist/public/node/api/business-platform.d.ts +11 -1
- package/dist/public/node/api/business-platform.js +35 -8
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/graphql.js +2 -2
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/rest-api-throttler.d.ts +23 -0
- package/dist/public/node/api/rest-api-throttler.js +239 -0
- package/dist/public/node/api/rest-api-throttler.js.map +1 -0
- package/dist/public/node/custom-oclif-loader.js +2 -1
- package/dist/public/node/custom-oclif-loader.js.map +1 -1
- package/dist/public/node/fs.d.ts +5 -0
- package/dist/public/node/fs.js +8 -1
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/hooks/prerun.d.ts +4 -0
- package/dist/public/node/hooks/prerun.js +27 -1
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/http.d.ts +3 -3
- package/dist/public/node/http.js +6 -3
- package/dist/public/node/http.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/node-package-manager.d.ts +8 -1
- package/dist/public/node/node-package-manager.js +19 -3
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/output.d.ts +0 -8
- package/dist/public/node/output.js +0 -14
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +1 -1
- package/dist/public/node/themes/api.js +16 -8
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/theme-manager.d.ts +1 -0
- package/dist/public/node/themes/theme-manager.js +3 -0
- package/dist/public/node/themes/theme-manager.js.map +1 -1
- package/dist/public/node/themes/types.d.ts +4 -0
- package/dist/public/node/themes/types.js.map +1 -1
- package/dist/public/node/ui.d.ts +2 -2
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/upgrade.d.ts +14 -0
- package/dist/public/node/upgrade.js +38 -0
- package/dist/public/node/upgrade.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/dist/private/node/themes/themes-api/headers.d.ts +0 -3
- package/dist/private/node/themes/themes-api/headers.js +0 -29
- package/dist/private/node/themes/themes-api/headers.js.map +0 -1
- package/dist/private/node/themes/themes-api/retry.d.ts +0 -1
- package/dist/private/node/themes/themes-api/retry.js +0 -6
- package/dist/private/node/themes/themes-api/retry.js.map +0 -1
- package/dist/private/node/themes/themes-api/throttler.d.ts +0 -2
- package/dist/private/node/themes/themes-api/throttler.js +0 -82
- package/dist/private/node/themes/themes-api/throttler.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/cli-kit",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.66.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A set of utilities, interfaces, and models that are common across all the platform features",
|
|
6
6
|
"keywords": [
|
|
@@ -156,8 +156,7 @@
|
|
|
156
156
|
"node-stream-zip": "^1.15.0",
|
|
157
157
|
"ts-morph": "^17.0.1",
|
|
158
158
|
"typedoc": "^0.25.7",
|
|
159
|
-
"typescript": "5.2.2"
|
|
160
|
-
"vitest": "^1.6.0"
|
|
159
|
+
"typescript": "5.2.2"
|
|
161
160
|
},
|
|
162
161
|
"engines": {
|
|
163
162
|
"node": "^18.20.0 || >=20.10.0"
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { tryParseInt } from '@shopify/cli-kit/common/string';
|
|
2
|
-
export function retryAfter(response) {
|
|
3
|
-
const retryAfterStr = header(response, 'retry-after');
|
|
4
|
-
const retryAfter = tryParseInt(retryAfterStr);
|
|
5
|
-
if (!retryAfter) {
|
|
6
|
-
return 0;
|
|
7
|
-
}
|
|
8
|
-
return retryAfter;
|
|
9
|
-
}
|
|
10
|
-
export function apiCallLimit(response) {
|
|
11
|
-
const apiCallLimit = header(response, 'x-shopify-shop-api-call-limit');
|
|
12
|
-
const [used, limit] = apiCallLimit
|
|
13
|
-
.split('/')
|
|
14
|
-
.map((num) => tryParseInt(num))
|
|
15
|
-
.filter(Boolean);
|
|
16
|
-
if (!used || !limit) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
return [used, limit];
|
|
20
|
-
}
|
|
21
|
-
function header(response, name) {
|
|
22
|
-
const headers = response.headers;
|
|
23
|
-
const header = headers[name];
|
|
24
|
-
if (header?.length === 1) {
|
|
25
|
-
return header[0] ?? '';
|
|
26
|
-
}
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=headers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../../src/private/node/themes/themes-api/headers.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAA;AAE1D,MAAM,UAAU,UAAU,CAAC,QAAsB;IAC/C,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;IACrD,MAAM,UAAU,GAAG,WAAW,CAAC,aAAa,CAAC,CAAA;IAE7C,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,CAAC,CAAA;KACT;IAED,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAsB;IACjD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAA;IAEtE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,YAAY;SAC/B,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;SAC9B,MAAM,CAAC,OAAO,CAAC,CAAA;IAElB,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;QACnB,OAAM;KACP;IAED,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACtB,CAAC;AAED,SAAS,MAAM,CAAC,QAAsB,EAAE,IAAY;IAClD,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B,IAAI,MAAM,EAAE,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;KACvB;IAED,OAAO,EAAE,CAAA;AACX,CAAC","sourcesContent":["import {RestResponse} from '@shopify/cli-kit/node/api/admin'\nimport {tryParseInt} from '@shopify/cli-kit/common/string'\n\nexport function retryAfter(response: RestResponse): number {\n const retryAfterStr = header(response, 'retry-after')\n const retryAfter = tryParseInt(retryAfterStr)\n\n if (!retryAfter) {\n return 0\n }\n\n return retryAfter\n}\n\nexport function apiCallLimit(response: RestResponse): [number, number] | undefined {\n const apiCallLimit = header(response, 'x-shopify-shop-api-call-limit')\n\n const [used, limit] = apiCallLimit\n .split('/')\n .map((num) => tryParseInt(num))\n .filter(Boolean)\n\n if (!used || !limit) {\n return\n }\n\n return [used, limit]\n}\n\nfunction header(response: RestResponse, name: string): string {\n const headers = response.headers\n const header = headers[name]\n\n if (header?.length === 1) {\n return header[0] ?? ''\n }\n\n return ''\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function retry<T>(operation: () => T, retryDelay: number): Promise<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../../../src/private/node/themes/themes-api/retry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,KAAK,CAAI,SAAkB,EAAE,UAAkB;IACnE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACzC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,UAAU,CAAC,CAAA;IACpD,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["export async function retry<T>(operation: () => T, retryDelay: number) {\n return new Promise<T>((resolve, _reject) => {\n setTimeout(() => resolve(operation()), retryDelay)\n })\n}\n"]}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const MAX_NUMBER_OF_PARALLEL_REQUESTS = 5;
|
|
2
|
-
const MARGIN_TO_RATE_LIMIT = 5;
|
|
3
|
-
export async function throttle(request) {
|
|
4
|
-
return new Promise((resolve, _reject) => {
|
|
5
|
-
const performRequest = () => {
|
|
6
|
-
throttlingState().requestCounter += 1;
|
|
7
|
-
resolve(request());
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Performs the {@link performRequest} taking into account the
|
|
11
|
-
* limit of parallel requests only when the API limit has not
|
|
12
|
-
* been reached.
|
|
13
|
-
*
|
|
14
|
-
* Otherwise, performs the request to get the updated API limit
|
|
15
|
-
* headers, so throttler parameters get updates.
|
|
16
|
-
*/
|
|
17
|
-
const throttleByHeader = () => {
|
|
18
|
-
if (!isReachingApiLimit()) {
|
|
19
|
-
throttleByCounter(performRequest);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
setTimeout(() => throttleByCounter(performRequest), 4000);
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Performs the {@link command} only when the the limit
|
|
26
|
-
* of parallel request has not been reached.
|
|
27
|
-
*
|
|
28
|
-
* Otherwise, defers the execution to the {@link throttleByHeader},
|
|
29
|
-
* still respecting the limit of parallel requests.
|
|
30
|
-
*/
|
|
31
|
-
const throttleByCounter = (command) => {
|
|
32
|
-
if (!hasTooManyRequests()) {
|
|
33
|
-
command();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
setTimeout(() => throttleByCounter(throttleByHeader), 1000);
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Start throttling by counter to get the API limit headers.
|
|
40
|
-
*/
|
|
41
|
-
throttleByCounter(throttleByHeader);
|
|
42
|
-
}).finally(() => {
|
|
43
|
-
throttlingState().requestCounter -= 1;
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
export function updateApiCallLimit(callLimit) {
|
|
47
|
-
if (!callLimit) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const [used, limit] = callLimit;
|
|
51
|
-
latestRequestInfo().apiCallLimit = { used, limit };
|
|
52
|
-
}
|
|
53
|
-
function hasTooManyRequests() {
|
|
54
|
-
return throttlingState().requestCounter > MAX_NUMBER_OF_PARALLEL_REQUESTS;
|
|
55
|
-
}
|
|
56
|
-
function isReachingApiLimit() {
|
|
57
|
-
const { used, limit } = latestRequestInfo().apiCallLimit;
|
|
58
|
-
return used >= limit - MARGIN_TO_RATE_LIMIT;
|
|
59
|
-
}
|
|
60
|
-
function latestRequestInfo() {
|
|
61
|
-
return throttlingState().latestRequestInfo;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Even considering the Stateless modules convention,
|
|
65
|
-
* tracking information about the latest request is
|
|
66
|
-
* critical to optimize the request throttler efficiently.
|
|
67
|
-
*
|
|
68
|
-
* Thus, in this case, this module deliberately avoids
|
|
69
|
-
* IO cost and uses the `_throttlingState` instance for
|
|
70
|
-
* that purpose.
|
|
71
|
-
*/
|
|
72
|
-
function throttlingState() {
|
|
73
|
-
return (_throttlingState ??
|
|
74
|
-
(_throttlingState = {
|
|
75
|
-
requestCounter: 0,
|
|
76
|
-
latestRequestInfo: {
|
|
77
|
-
apiCallLimit: { used: 0, limit: 40 },
|
|
78
|
-
},
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
let _throttlingState;
|
|
82
|
-
//# sourceMappingURL=throttler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"throttler.js","sourceRoot":"","sources":["../../../../../src/private/node/themes/themes-api/throttler.ts"],"names":[],"mappings":"AAAA,MAAM,+BAA+B,GAAG,CAAC,CAAA;AACzC,MAAM,oBAAoB,GAAG,CAAC,CAAA;AAE9B,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAI,OAAgB;IAChD,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;QACzC,MAAM,cAAc,GAAG,GAAG,EAAE;YAC1B,eAAe,EAAE,CAAC,cAAc,IAAI,CAAC,CAAA;YACrC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;QACpB,CAAC,CAAA;QAED;;;;;;;WAOG;QACH,MAAM,gBAAgB,GAAG,GAAG,EAAE;YAC5B,IAAI,CAAC,kBAAkB,EAAE,EAAE;gBACzB,iBAAiB,CAAC,cAAc,CAAC,CAAA;gBACjC,OAAM;aACP;YAED,UAAU,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,CAAA;QAC3D,CAAC,CAAA;QAED;;;;;;WAMG;QACH,MAAM,iBAAiB,GAAG,CAAC,OAAmB,EAAE,EAAE;YAChD,IAAI,CAAC,kBAAkB,EAAE,EAAE;gBACzB,OAAO,EAAE,CAAA;gBACT,OAAM;aACP;YAED,UAAU,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC,CAAA;QAC7D,CAAC,CAAA;QAED;;WAEG;QACH,iBAAiB,CAAC,gBAAgB,CAAC,CAAA;IACrC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;QACd,eAAe,EAAE,CAAC,cAAc,IAAI,CAAC,CAAA;IACvC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,SAAuC;IACxE,IAAI,CAAC,SAAS,EAAE;QACd,OAAM;KACP;IAED,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,SAAS,CAAA;IAE/B,iBAAiB,EAAE,CAAC,YAAY,GAAG,EAAC,IAAI,EAAE,KAAK,EAAC,CAAA;AAClD,CAAC;AAED,SAAS,kBAAkB;IACzB,OAAO,eAAe,EAAE,CAAC,cAAc,GAAG,+BAA+B,CAAA;AAC3E,CAAC;AAED,SAAS,kBAAkB;IACzB,MAAM,EAAC,IAAI,EAAE,KAAK,EAAC,GAAG,iBAAiB,EAAE,CAAC,YAAY,CAAA;IACtD,OAAO,IAAI,IAAI,KAAK,GAAG,oBAAoB,CAAA;AAC7C,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO,eAAe,EAAE,CAAC,iBAAiB,CAAA;AAC5C,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,eAAe;IACtB,OAAO,CACL,gBAAgB;QAChB,CAAC,gBAAgB,GAAG;YAClB,cAAc,EAAE,CAAC;YACjB,iBAAiB,EAAE;gBACjB,YAAY,EAAE,EAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAC;aACnC;SACF,CAAC,CACH,CAAA;AACH,CAAC;AAED,IAAI,gBAUH,CAAA","sourcesContent":["const MAX_NUMBER_OF_PARALLEL_REQUESTS = 5\nconst MARGIN_TO_RATE_LIMIT = 5\n\nexport async function throttle<T>(request: () => T) {\n return new Promise<T>((resolve, _reject) => {\n const performRequest = () => {\n throttlingState().requestCounter += 1\n resolve(request())\n }\n\n /**\n * Performs the {@link performRequest} taking into account the\n * limit of parallel requests only when the API limit has not\n * been reached.\n *\n * Otherwise, performs the request to get the updated API limit\n * headers, so throttler parameters get updates.\n */\n const throttleByHeader = () => {\n if (!isReachingApiLimit()) {\n throttleByCounter(performRequest)\n return\n }\n\n setTimeout(() => throttleByCounter(performRequest), 4000)\n }\n\n /**\n * Performs the {@link command} only when the the limit\n * of parallel request has not been reached.\n *\n * Otherwise, defers the execution to the {@link throttleByHeader},\n * still respecting the limit of parallel requests.\n */\n const throttleByCounter = (command: () => void) => {\n if (!hasTooManyRequests()) {\n command()\n return\n }\n\n setTimeout(() => throttleByCounter(throttleByHeader), 1000)\n }\n\n /**\n * Start throttling by counter to get the API limit headers.\n */\n throttleByCounter(throttleByHeader)\n }).finally(() => {\n throttlingState().requestCounter -= 1\n })\n}\n\nexport function updateApiCallLimit(callLimit: [number, number] | undefined) {\n if (!callLimit) {\n return\n }\n\n const [used, limit] = callLimit\n\n latestRequestInfo().apiCallLimit = {used, limit}\n}\n\nfunction hasTooManyRequests() {\n return throttlingState().requestCounter > MAX_NUMBER_OF_PARALLEL_REQUESTS\n}\n\nfunction isReachingApiLimit() {\n const {used, limit} = latestRequestInfo().apiCallLimit\n return used >= limit - MARGIN_TO_RATE_LIMIT\n}\n\nfunction latestRequestInfo() {\n return throttlingState().latestRequestInfo\n}\n\n/**\n * Even considering the Stateless modules convention,\n * tracking information about the latest request is\n * critical to optimize the request throttler efficiently.\n *\n * Thus, in this case, this module deliberately avoids\n * IO cost and uses the `_throttlingState` instance for\n * that purpose.\n */\nfunction throttlingState() {\n return (\n _throttlingState ??\n (_throttlingState = {\n requestCounter: 0,\n latestRequestInfo: {\n apiCallLimit: {used: 0, limit: 40},\n },\n })\n )\n}\n\nlet _throttlingState: {\n /**\n * Number of parallel requests */\n requestCounter: number\n\n /**\n * Latest request information */\n latestRequestInfo: {\n apiCallLimit: {used: number; limit: number}\n }\n}\n"]}
|