@cbnventures/nova 0.37.2 → 0.39.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/build/package.json +1 -1
- package/build/scaffold-versions.json +20 -0
- package/build/src/api/app-store-connect.d.ts +17 -2
- package/build/src/api/app-store-connect.d.ts.map +1 -1
- package/build/src/api/app-store-connect.js +654 -171
- package/build/src/api/app-store-connect.js.map +1 -1
- package/build/src/api/github-runner-images.d.ts +13 -0
- package/build/src/api/github-runner-images.d.ts.map +1 -0
- package/build/src/api/github-runner-images.js +238 -0
- package/build/src/api/github-runner-images.js.map +1 -0
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts +2 -2
- package/build/src/cli/generate/github/workflows-blueprint-validate.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint-validate.js +226 -3
- package/build/src/cli/generate/github/workflows-blueprint-validate.js.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.d.ts +6 -4
- package/build/src/cli/generate/github/workflows-blueprint.d.ts.map +1 -1
- package/build/src/cli/generate/github/workflows-blueprint.js +804 -124
- package/build/src/cli/generate/github/workflows-blueprint.js.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.d.ts.map +1 -1
- package/build/src/cli/generate/must-haves/agent-conventions.js +1 -0
- package/build/src/cli/generate/must-haves/agent-conventions.js.map +1 -1
- package/build/src/cli/index.js +13 -1
- package/build/src/cli/index.js.map +1 -1
- package/build/src/cli/integration/app-store-connect.d.ts +10 -0
- package/build/src/cli/integration/app-store-connect.d.ts.map +1 -1
- package/build/src/cli/integration/app-store-connect.js +701 -80
- package/build/src/cli/integration/app-store-connect.js.map +1 -1
- package/build/src/cli/scaffold/app/astro.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/astro.js +8 -0
- package/build/src/cli/scaffold/app/astro.js.map +1 -1
- package/build/src/cli/scaffold/app/discord-bot.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/discord-bot.js +28 -0
- package/build/src/cli/scaffold/app/discord-bot.js.map +1 -1
- package/build/src/cli/scaffold/app/expressjs.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/expressjs.js +28 -0
- package/build/src/cli/scaffold/app/expressjs.js.map +1 -1
- package/build/src/cli/scaffold/app/nextjs.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/nextjs.js +22 -0
- package/build/src/cli/scaffold/app/nextjs.js.map +1 -1
- package/build/src/cli/scaffold/app/vite.d.ts.map +1 -1
- package/build/src/cli/scaffold/app/vite.js +8 -0
- package/build/src/cli/scaffold/app/vite.js.map +1 -1
- package/build/src/cli/scaffold/docs/docusaurus.d.ts.map +1 -1
- package/build/src/cli/scaffold/docs/docusaurus.js +8 -0
- package/build/src/cli/scaffold/docs/docusaurus.js.map +1 -1
- package/build/src/cli/scaffold/package/github-action.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/github-action.js +14 -0
- package/build/src/cli/scaffold/package/github-action.js.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/homebridge.js +22 -0
- package/build/src/cli/scaffold/package/homebridge.js.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.d.ts +3 -0
- package/build/src/cli/scaffold/package/pfsense.d.ts.map +1 -1
- package/build/src/cli/scaffold/package/pfsense.js +148 -6
- package/build/src/cli/scaffold/package/pfsense.js.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.d.ts +2 -0
- package/build/src/cli/scaffold/tool/serverless.d.ts.map +1 -1
- package/build/src/cli/scaffold/tool/serverless.js +86 -1
- package/build/src/cli/scaffold/tool/serverless.js.map +1 -1
- package/build/src/cli/utility/changelog.d.ts +7 -0
- package/build/src/cli/utility/changelog.d.ts.map +1 -1
- package/build/src/cli/utility/changelog.js +802 -7
- package/build/src/cli/utility/changelog.js.map +1 -1
- package/build/src/cli/utility/configure.d.ts +6 -1
- package/build/src/cli/utility/configure.d.ts.map +1 -1
- package/build/src/cli/utility/configure.js +278 -20
- package/build/src/cli/utility/configure.js.map +1 -1
- package/build/src/cli/utility/run-workspaces.d.ts.map +1 -1
- package/build/src/cli/utility/run-workspaces.js +1 -0
- package/build/src/cli/utility/run-workspaces.js.map +1 -1
- package/build/src/lib/artifact-assembly.d.ts +7 -0
- package/build/src/lib/artifact-assembly.d.ts.map +1 -0
- package/build/src/lib/artifact-assembly.js +122 -0
- package/build/src/lib/artifact-assembly.js.map +1 -0
- package/build/src/lib/docker-packaging.d.ts +3 -1
- package/build/src/lib/docker-packaging.d.ts.map +1 -1
- package/build/src/lib/docker-packaging.js +83 -2
- package/build/src/lib/docker-packaging.js.map +1 -1
- package/build/src/lib/env-namespace.d.ts.map +1 -1
- package/build/src/lib/env-namespace.js +2 -1
- package/build/src/lib/env-namespace.js.map +1 -1
- package/build/src/lib/item.d.ts +2 -1
- package/build/src/lib/item.d.ts.map +1 -1
- package/build/src/lib/item.js +18 -0
- package/build/src/lib/item.js.map +1 -1
- package/build/src/lib/nova-config-order.d.ts.map +1 -1
- package/build/src/lib/nova-config-order.js +1 -0
- package/build/src/lib/nova-config-order.js.map +1 -1
- package/build/src/lib/nova-config.d.ts +1 -0
- package/build/src/lib/nova-config.d.ts.map +1 -1
- package/build/src/lib/nova-config.js +150 -4
- package/build/src/lib/nova-config.js.map +1 -1
- package/build/src/lib/regex.d.ts +14 -0
- package/build/src/lib/regex.d.ts.map +1 -1
- package/build/src/lib/regex.js +14 -0
- package/build/src/lib/regex.js.map +1 -1
- package/build/src/lib/run-workspaces.d.ts.map +1 -1
- package/build/src/lib/run-workspaces.js +79 -8
- package/build/src/lib/run-workspaces.js.map +1 -1
- package/build/src/lib/scaffold.d.ts +3 -3
- package/build/src/lib/scaffold.d.ts.map +1 -1
- package/build/src/lib/scaffold.js +140 -8
- package/build/src/lib/scaffold.js.map +1 -1
- package/build/src/lib/workflow-templates.d.ts +4 -1
- package/build/src/lib/workflow-templates.d.ts.map +1 -1
- package/build/src/lib/workflow-templates.js +60 -2
- package/build/src/lib/workflow-templates.js.map +1 -1
- package/build/src/types/api/app-store-connect.d.ts +476 -33
- package/build/src/types/api/github-runner-images.d.ts +199 -0
- package/build/src/types/cli/generate/github/workflows-blueprint-validate.d.ts +76 -8
- package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +178 -11
- package/build/src/types/cli/integration/app-store-connect.d.ts +470 -6
- package/build/src/types/cli/scaffold/package/pfsense.d.ts +83 -0
- package/build/src/types/cli/scaffold/tool/serverless.d.ts +30 -0
- package/build/src/types/cli/utility/changelog.d.ts +327 -1
- package/build/src/types/cli/utility/configure.d.ts +150 -4
- package/build/src/types/lib/artifact-assembly.d.ts +102 -0
- package/build/src/types/lib/docker-packaging.d.ts +54 -1
- package/build/src/types/lib/env-namespace.d.ts +4 -1
- package/build/src/types/lib/item.d.ts +7 -0
- package/build/src/types/lib/nova-config.d.ts +91 -2
- package/build/src/types/lib/regex.d.ts +91 -0
- package/build/src/types/lib/run-workspaces.d.ts +30 -0
- package/build/src/types/lib/scaffold.d.ts +67 -4
- package/build/src/types/lib/workflow-templates.d.ts +26 -0
- package/build/src/types/shared.d.ts +315 -3
- package/build/src/types/tests/api/app-store-connect.test.d.ts +162 -0
- package/build/src/types/tests/api/github-runner-images.test.d.ts +113 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-generate.test.d.ts +19 -0
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-parity.test.d.ts +0 -9
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-publish-parity.test.d.ts +109 -26
- package/build/src/types/tests/cli/generate/github/workflows-blueprint-validate.test.d.ts +146 -30
- package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +61 -0
- package/build/src/types/tests/cli/generate/github/workflows-version-contract.test.d.ts +2 -2
- package/build/src/types/tests/cli/generate/must-haves/agent-conventions.test.d.ts +2 -0
- package/build/src/types/tests/cli/integration/app-store-connect.test.d.ts +876 -0
- package/build/src/types/tests/cli/scaffold/app/nextjs.test.d.ts +6 -0
- package/build/src/types/tests/cli/scaffold/tool/serverless.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-android.test.d.ts +14 -0
- package/build/src/types/tests/cli/utility/changelog-apple.test.d.ts +21 -0
- package/build/src/types/tests/cli/utility/changelog-fold.test.d.ts +350 -0
- package/build/src/types/tests/cli/utility/changelog.test.d.ts +50 -0
- package/build/src/types/tests/cli/utility/configure.test.d.ts +56 -0
- package/build/src/types/tests/cli/utility/run-workspaces.test.d.ts +29 -2
- package/build/src/types/tests/lib/artifact-assembly.test.d.ts +45 -0
- package/build/src/types/tests/lib/docker-packaging.test.d.ts +12 -0
- package/build/src/types/tests/lib/nova-config-artifacts.test.d.ts +40 -0
- package/build/src/types/tests/lib/nova-config.test.d.ts +28 -0
- package/build/src/types/tests/lib/scaffold.test.d.ts +59 -2
- package/build/src/types/tests/scaffold-output-contract.test.d.ts +79 -0
- package/build/templates/generators/must-haves/agent-conventions/AGENTS.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/CLAUDE.md +1 -0
- package/build/templates/generators/must-haves/agent-conventions/conventions/nova.md +7 -1
- package/build/templates/generators/must-haves/agent-conventions/conventions/pfsense.md +311 -0
- package/build/templates/scaffold/app/android/package.json +1 -1
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-ios-1024.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-128@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-16@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-256@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-32@2x.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512.png +0 -0
- package/build/templates/scaffold/app/apple/Sources/Assets.xcassets/AppIcon.appiconset/AppIcon-mac-512@2x.png +0 -0
- package/build/templates/scaffold/app/apple/package.json +1 -1
- package/build/templates/scaffold/app/astro/package.json +1 -1
- package/build/templates/scaffold/app/discord-bot/package.json +1 -1
- package/build/templates/scaffold/app/express/package.json +1 -1
- package/build/templates/scaffold/app/nextjs/package.json +1 -1
- package/build/templates/scaffold/app/vite/package.json +1 -1
- package/build/templates/scaffold/docs/docusaurus/package.json +2 -2
- package/build/templates/scaffold/package/github-action/package.json +1 -1
- package/build/templates/scaffold/package/homebridge/package.json +1 -1
- package/build/templates/scaffold/package/pfsense/package.json +1 -1
- package/build/templates/scaffold/package/pfsense/port/Makefile.template +16 -1
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/FileLock.php +93 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/PackagePaths.php +40 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__]/UpdateManager.php +1667 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].inc +161 -13
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/pkg/[__WORKSPACE_NAME__].xml +37 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/sbin/[__WORKSPACE_NAME__] +203 -8
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/logo.svg +12 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/share/pfSense-pkg-[__WORKSPACE_IDENTIFIER__]/release-signing.pub +9 -0
- package/build/templates/scaffold/package/pfsense/port/files/usr/local/www/[__WORKSPACE_NAME__]-about.php +437 -0
- package/build/templates/scaffold/package/pfsense/port/pkg-plist +6 -0
- package/build/templates/scaffold/package/pfsense/scripts/build-package.sh +54 -0
- package/build/templates/scaffold/package/pfsense/scripts/check-package.mjs +114 -1
- package/build/templates/scaffold/package/pfsense/scripts/regex.mjs +10 -0
- package/build/templates/scaffold/package/pfsense/tests/updates.php +695 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/drawable/ic_launcher_background.xml +1 -1
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/build/templates/scaffold-options/app/android-native/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/build/templates/scaffold-options/docker-image/common/Dockerfile +7 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/package.json +1 -1
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/types/worker/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.test.ts +119 -4
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/index.ts +25 -3
- package/build/templates/scaffold-options/tool/serverless/cloudflare-workers/src/worker/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.test.ts +121 -6
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/api/index.ts +49 -12
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/package.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/function/landing-page.ts +278 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.d.ts +17 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/api/index.test.d.ts +40 -2
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/src/types/function/landing-page.d.ts +23 -0
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/tsconfig.functions.json +3 -1
- package/build/templates/scaffold-options/tool/serverless/vercel-functions/vercel.json +7 -1
- package/package.json +1 -1
- package/build/templates/scaffold/package/pfsense-root/.github/workflows/pfsense-[__WORKSPACE_NAME__].yml +0 -62
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { createHash, createPrivateKey, sign, } from 'node:crypto';
|
|
2
2
|
import { requireArray, requireNonNegativeInteger, requireObject, requireString, wait, } from '../lib/integration.js';
|
|
3
|
+
import { Logger } from '../toolkit/index.js';
|
|
3
4
|
const apiBaseUrl = 'https://api.appstoreconnect.apple.com';
|
|
4
5
|
const apiRequestTimeoutMilliseconds = 60 * 1000;
|
|
5
6
|
const assetUploadTimeoutMilliseconds = 5 * 60 * 1000;
|
|
7
|
+
const initialRetryDelayMilliseconds = 1000;
|
|
8
|
+
const maximumConcurrentApiOperations = 3;
|
|
6
9
|
const maximumProcessingAttempts = 300;
|
|
7
|
-
const
|
|
10
|
+
const maximumRateLimitAttempts = 10;
|
|
11
|
+
const maximumRateLimitDelayMilliseconds = 10 * 60 * 1000;
|
|
12
|
+
const maximumTransientAttempts = 5;
|
|
13
|
+
const maximumTransientDelayMilliseconds = 15 * 1000;
|
|
14
|
+
const processingPollMaximumDelayMilliseconds = 15 * 1000;
|
|
15
|
+
const processingPollInitialDelayMilliseconds = 2 * 1000;
|
|
16
|
+
const rateLimitCriticalDelayMilliseconds = 60 * 1000;
|
|
17
|
+
const rateLimitLowDelayMilliseconds = 1000;
|
|
8
18
|
const editableAppStoreStates = new Set([
|
|
9
19
|
'DEVELOPER_REJECTED',
|
|
10
20
|
'INVALID_BINARY',
|
|
@@ -20,15 +30,24 @@ const readyAssetStates = new Set([
|
|
|
20
30
|
'READY_FOR_REVIEW',
|
|
21
31
|
'WAITING_FOR_REVIEW',
|
|
22
32
|
]);
|
|
33
|
+
const failedAssetCleanupStates = new Set([
|
|
34
|
+
'FAILED',
|
|
35
|
+
'REJECTED',
|
|
36
|
+
]);
|
|
23
37
|
const failedAssetStates = new Set([
|
|
24
38
|
'ARCHIVED',
|
|
25
39
|
'FAILED',
|
|
26
40
|
'REJECTED',
|
|
27
41
|
]);
|
|
28
42
|
export class Runner {
|
|
43
|
+
#activeApiOperations = 0;
|
|
44
|
+
#apiOperationQueue = [];
|
|
45
|
+
#apiOperationsPausedUntil = 0;
|
|
29
46
|
#issuerId;
|
|
30
47
|
#keyId;
|
|
31
48
|
#privateKey;
|
|
49
|
+
#screenshotProcessingPolls = new Map();
|
|
50
|
+
#screenshotProcessingWaiters = new Map();
|
|
32
51
|
#token;
|
|
33
52
|
#tokenExpiresAt = 0;
|
|
34
53
|
constructor(credentials) {
|
|
@@ -38,53 +57,106 @@ export class Runner {
|
|
|
38
57
|
return;
|
|
39
58
|
}
|
|
40
59
|
async request(path, options = {}) {
|
|
41
|
-
return this.requestWithAttempt(path, options,
|
|
60
|
+
return this.requestWithAttempt(path, options, 0, 0);
|
|
61
|
+
}
|
|
62
|
+
static isAmbiguousCreateError(error) {
|
|
63
|
+
return (typeof error === 'object'
|
|
64
|
+
&& error !== null
|
|
65
|
+
&& 'appStoreConnectAmbiguousCreate' in error
|
|
66
|
+
&& error['appStoreConnectAmbiguousCreate'] === true);
|
|
42
67
|
}
|
|
43
|
-
async
|
|
68
|
+
static async runOperations(items, operation) {
|
|
69
|
+
const results = [];
|
|
70
|
+
await Runner.runOperationBatch(items, operation, results, 0);
|
|
71
|
+
return results;
|
|
72
|
+
}
|
|
73
|
+
async requestWithAttempt(path, options, rateLimitAttempt, transientAttempt) {
|
|
44
74
|
const method = options['method'] ?? 'GET';
|
|
45
75
|
const body = options['body'];
|
|
46
76
|
const url = (path.startsWith('https://') === true) ? path : `${apiBaseUrl}${path}`;
|
|
47
|
-
const headers = {
|
|
48
|
-
'Accept': 'application/json',
|
|
49
|
-
'Authorization': `Bearer ${this.getToken()}`,
|
|
50
|
-
};
|
|
51
|
-
if (body !== undefined) {
|
|
52
|
-
Reflect.set(headers, 'Content-Type', 'application/json');
|
|
53
|
-
}
|
|
54
77
|
let response = undefined;
|
|
55
|
-
const
|
|
56
|
-
headers,
|
|
57
|
-
method,
|
|
58
|
-
signal: AbortSignal.timeout(apiRequestTimeoutMilliseconds),
|
|
59
|
-
};
|
|
60
|
-
if (body !== undefined) {
|
|
61
|
-
Reflect.set(requestInit, 'body', JSON.stringify(body));
|
|
62
|
-
}
|
|
78
|
+
const serializedBody = (body === undefined) ? undefined : JSON.stringify(body);
|
|
63
79
|
try {
|
|
64
|
-
response = await
|
|
80
|
+
response = await this.fetchWithLimit(url, {
|
|
81
|
+
authenticated: true,
|
|
82
|
+
body: serializedBody,
|
|
83
|
+
method,
|
|
84
|
+
rateLimitAttempt: rateLimitAttempt + 1,
|
|
85
|
+
timeoutMilliseconds: apiRequestTimeoutMilliseconds,
|
|
86
|
+
});
|
|
65
87
|
}
|
|
66
88
|
catch (error) {
|
|
67
|
-
if (
|
|
89
|
+
if (method === 'POST' && options['idempotent'] !== true) {
|
|
90
|
+
throw Runner.requestError(`${method} ${url} failed after it may have reached App Store Connect.`, true, error);
|
|
91
|
+
}
|
|
92
|
+
const networkRetryDecision = Runner.retryDecision(undefined, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
93
|
+
if (networkRetryDecision === undefined) {
|
|
68
94
|
throw new Error(`${method} ${url} failed.`, { cause: error });
|
|
69
95
|
}
|
|
70
|
-
await wait(
|
|
71
|
-
return this.requestWithAttempt(path, options,
|
|
96
|
+
await wait(networkRetryDecision['delayMilliseconds']);
|
|
97
|
+
return this.requestWithAttempt(path, options, rateLimitAttempt, transientAttempt + 1);
|
|
72
98
|
}
|
|
73
99
|
const expectedStatuses = options['expectedStatuses'] ?? [200];
|
|
74
100
|
if (expectedStatuses.includes(response.status) === true) {
|
|
75
101
|
if (response.status === 204) {
|
|
76
102
|
return undefined;
|
|
77
103
|
}
|
|
78
|
-
|
|
104
|
+
let responseData = undefined;
|
|
105
|
+
try {
|
|
106
|
+
responseData = await response.json();
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (method === 'POST' && options['idempotent'] !== true) {
|
|
110
|
+
throw Runner.requestError(`${method} ${url} returned HTTP ${response.status}, but its response body failed after the create may have reached App Store Connect.`, true, error);
|
|
111
|
+
}
|
|
112
|
+
const responseBodyRetryDecision = Runner.retryDecision(undefined, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
113
|
+
if (responseBodyRetryDecision === undefined) {
|
|
114
|
+
throw new Error(`${method} ${url} returned HTTP ${response.status}, but its response body could not be read.`, { cause: error });
|
|
115
|
+
}
|
|
116
|
+
await wait(responseBodyRetryDecision['delayMilliseconds']);
|
|
117
|
+
return this.requestWithAttempt(path, options, rateLimitAttempt, transientAttempt + 1);
|
|
118
|
+
}
|
|
79
119
|
return requireObject(responseData, `Response from ${method} ${url}`);
|
|
80
120
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
121
|
+
if (method === 'DELETE'
|
|
122
|
+
&& response.status === 404
|
|
123
|
+
&& (rateLimitAttempt > 0
|
|
124
|
+
|| transientAttempt > 0)) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
let responseText = '';
|
|
128
|
+
try {
|
|
129
|
+
responseText = await response.text();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (method === 'POST' && options['idempotent'] !== true) {
|
|
133
|
+
throw Runner.requestError(`${method} ${url} returned HTTP ${response.status}, but its response body failed after the create may have reached App Store Connect.`, true, error);
|
|
134
|
+
}
|
|
135
|
+
const errorBodyRetryDecision = Runner.retryDecision(undefined, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
136
|
+
if (errorBodyRetryDecision === undefined) {
|
|
137
|
+
throw new Error(`${method} ${url} returned HTTP ${response.status}, but its response body could not be read.`, { cause: error });
|
|
138
|
+
}
|
|
139
|
+
await wait(errorBodyRetryDecision['delayMilliseconds']);
|
|
140
|
+
return this.requestWithAttempt(path, options, rateLimitAttempt, transientAttempt + 1);
|
|
141
|
+
}
|
|
142
|
+
if (response.status === 429) {
|
|
143
|
+
const rateLimitRetryDecision = Runner.retryDecision(response, rateLimitAttempt + 1, maximumRateLimitAttempts, maximumRateLimitDelayMilliseconds);
|
|
144
|
+
if (rateLimitRetryDecision === undefined) {
|
|
145
|
+
throw new Error(`${method} ${url} failed with HTTP ${response.status}: ${responseText}. The run is safe to resume after App Store Connect's rate limit resets.`);
|
|
146
|
+
}
|
|
147
|
+
return this.requestWithAttempt(path, options, rateLimitAttempt + 1, transientAttempt);
|
|
148
|
+
}
|
|
149
|
+
if (method === 'POST'
|
|
150
|
+
&& options['idempotent'] !== true
|
|
151
|
+
&& response.status >= 500) {
|
|
152
|
+
throw Runner.requestError(`${method} ${url} failed with HTTP ${response.status}: ${responseText}`, true);
|
|
153
|
+
}
|
|
154
|
+
const responseRetryDecision = Runner.retryDecision(response, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
155
|
+
if (responseRetryDecision === undefined) {
|
|
84
156
|
throw new Error(`${method} ${url} failed with HTTP ${response.status}: ${responseText}`);
|
|
85
157
|
}
|
|
86
|
-
await wait(
|
|
87
|
-
return this.requestWithAttempt(path, options,
|
|
158
|
+
await wait(responseRetryDecision['delayMilliseconds']);
|
|
159
|
+
return this.requestWithAttempt(path, options, rateLimitAttempt, transientAttempt + 1);
|
|
88
160
|
}
|
|
89
161
|
async list(path) {
|
|
90
162
|
const resources = [];
|
|
@@ -150,31 +222,60 @@ export class Runner {
|
|
|
150
222
|
return this.list(`/v1/appStoreVersions/${versionId}/appStoreVersionLocalizations?${query.toString()}`);
|
|
151
223
|
}
|
|
152
224
|
async createLocalization(versionId, locale, attributes = {}) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
225
|
+
let attempt = 1;
|
|
226
|
+
while (attempt <= maximumTransientAttempts) {
|
|
227
|
+
let response = undefined;
|
|
228
|
+
try {
|
|
229
|
+
response = await this.request('/v1/appStoreVersionLocalizations', {
|
|
230
|
+
body: {
|
|
231
|
+
data: {
|
|
232
|
+
attributes: {
|
|
233
|
+
locale,
|
|
234
|
+
...attributes,
|
|
235
|
+
},
|
|
236
|
+
relationships: {
|
|
237
|
+
appStoreVersion: {
|
|
238
|
+
data: {
|
|
239
|
+
id: versionId,
|
|
240
|
+
type: 'appStoreVersions',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
165
243
|
},
|
|
244
|
+
type: 'appStoreVersionLocalizations',
|
|
166
245
|
},
|
|
167
246
|
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
247
|
+
expectedStatuses: [201],
|
|
248
|
+
method: 'POST',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
catch (error) {
|
|
252
|
+
if (Runner.isAmbiguousCreateError(error) === false) {
|
|
253
|
+
throw error;
|
|
254
|
+
}
|
|
255
|
+
const localizations = await this.listLocalizations(versionId);
|
|
256
|
+
const matchingLocalization = localizations.find((localization) => {
|
|
257
|
+
const matchingAttributes = requireObject(localization['attributes'], `Localization attributes while reconciling ${locale}`);
|
|
258
|
+
return matchingAttributes['locale'] === locale;
|
|
259
|
+
});
|
|
260
|
+
if (matchingLocalization !== undefined) {
|
|
261
|
+
return matchingLocalization;
|
|
262
|
+
}
|
|
263
|
+
if (attempt >= maximumTransientAttempts) {
|
|
264
|
+
throw error;
|
|
265
|
+
}
|
|
266
|
+
const retryDecision = Runner.retryDecision(undefined, attempt, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
267
|
+
if (retryDecision !== undefined) {
|
|
268
|
+
await wait(retryDecision['delayMilliseconds']);
|
|
269
|
+
}
|
|
270
|
+
attempt += 1;
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
if (response === undefined) {
|
|
274
|
+
throw new Error(`Creating ${locale} App Store localization returned no resource.`);
|
|
275
|
+
}
|
|
276
|
+
return requireObject(response['data'], `Created ${locale} localization`);
|
|
176
277
|
}
|
|
177
|
-
|
|
278
|
+
throw new Error(`Creating ${locale} App Store localization exhausted its reconciliation attempts.`);
|
|
178
279
|
}
|
|
179
280
|
async updateLocalization(localizationId, attributes) {
|
|
180
281
|
await this.request(`/v1/appStoreVersionLocalizations/${localizationId}`, {
|
|
@@ -197,82 +298,102 @@ export class Runner {
|
|
|
197
298
|
});
|
|
198
299
|
return this.list(`/v1/appStoreVersionLocalizations/${localizationId}/appScreenshotSets?${query.toString()}`);
|
|
199
300
|
}
|
|
301
|
+
async listScreenshots(screenshotSetId) {
|
|
302
|
+
const query = new URLSearchParams({
|
|
303
|
+
'fields[appScreenshots]': 'assetDeliveryState,fileName,sourceFileChecksum',
|
|
304
|
+
'limit': '200',
|
|
305
|
+
});
|
|
306
|
+
return this.list(`/v1/appScreenshotSets/${screenshotSetId}/appScreenshots?${query.toString()}`);
|
|
307
|
+
}
|
|
200
308
|
async createScreenshotSet(localizationId, displayType) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
309
|
+
let attempt = 1;
|
|
310
|
+
while (attempt <= maximumTransientAttempts) {
|
|
311
|
+
let response = undefined;
|
|
312
|
+
try {
|
|
313
|
+
response = await this.request('/v1/appScreenshotSets', {
|
|
314
|
+
body: {
|
|
315
|
+
data: {
|
|
316
|
+
attributes: {
|
|
317
|
+
screenshotDisplayType: displayType,
|
|
318
|
+
},
|
|
319
|
+
relationships: {
|
|
320
|
+
appStoreVersionLocalization: {
|
|
321
|
+
data: {
|
|
322
|
+
id: localizationId,
|
|
323
|
+
type: 'appStoreVersionLocalizations',
|
|
324
|
+
},
|
|
325
|
+
},
|
|
212
326
|
},
|
|
327
|
+
type: 'appScreenshotSets',
|
|
213
328
|
},
|
|
214
329
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
330
|
+
expectedStatuses: [201],
|
|
331
|
+
method: 'POST',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
catch (error) {
|
|
335
|
+
if (Runner.isAmbiguousCreateError(error) === false) {
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
const sets = await this.listScreenshotSets(localizationId);
|
|
339
|
+
const matchingSet = sets.find((set) => {
|
|
340
|
+
const matchingAttributes = requireObject(set['attributes'], `Screenshot set attributes while reconciling ${displayType}`);
|
|
341
|
+
return matchingAttributes['screenshotDisplayType'] === displayType;
|
|
342
|
+
});
|
|
343
|
+
if (matchingSet !== undefined) {
|
|
344
|
+
return matchingSet;
|
|
345
|
+
}
|
|
346
|
+
if (attempt >= maximumTransientAttempts) {
|
|
347
|
+
throw error;
|
|
348
|
+
}
|
|
349
|
+
const retryDecision = Runner.retryDecision(undefined, attempt, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
350
|
+
if (retryDecision !== undefined) {
|
|
351
|
+
await wait(retryDecision['delayMilliseconds']);
|
|
352
|
+
}
|
|
353
|
+
attempt += 1;
|
|
354
|
+
continue;
|
|
355
|
+
}
|
|
356
|
+
if (response === undefined) {
|
|
357
|
+
throw new Error(`Creating screenshot set ${displayType} returned no resource.`);
|
|
358
|
+
}
|
|
359
|
+
return requireObject(response['data'], `Created screenshot set ${displayType}`);
|
|
223
360
|
}
|
|
224
|
-
|
|
361
|
+
throw new Error(`Creating screenshot set ${displayType} exhausted its reconciliation attempts.`);
|
|
225
362
|
}
|
|
226
363
|
async uploadScreenshot(screenshotSetId, fileName, file) {
|
|
227
364
|
const checksum = createHash('md5').update(file).digest('hex');
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
365
|
+
const priorScreenshots = await this.listScreenshots(screenshotSetId);
|
|
366
|
+
const priorScreenshotIds = new Set(priorScreenshots.map((priorScreenshot) => requireString(priorScreenshot['id'], `Existing screenshot ID before uploading ${fileName}`)));
|
|
367
|
+
const resource = await this.reserveScreenshot(screenshotSetId, fileName, file, priorScreenshotIds, 1);
|
|
368
|
+
const resourceId = requireString(resource['id'], `Reserved screenshot ID for ${fileName}`);
|
|
369
|
+
try {
|
|
370
|
+
const attributes = requireObject(resource['attributes'], `Reserved screenshot attributes for ${fileName}`);
|
|
371
|
+
const operations = requireArray(attributes['uploadOperations'], `Upload operations for ${fileName}`).map((operation) => requireObject(operation, `Upload operation for ${fileName}`));
|
|
372
|
+
if (operations.length === 0) {
|
|
373
|
+
throw new Error(`${fileName} did not receive upload operations.`);
|
|
374
|
+
}
|
|
375
|
+
await Runner.runOperations(operations, (operation) => this.uploadOperation(operation, file));
|
|
376
|
+
await this.request(`/v1/appScreenshots/${resourceId}`, {
|
|
377
|
+
body: {
|
|
378
|
+
data: {
|
|
379
|
+
attributes: {
|
|
380
|
+
sourceFileChecksum: checksum,
|
|
381
|
+
uploaded: true,
|
|
241
382
|
},
|
|
383
|
+
id: resourceId,
|
|
384
|
+
type: 'appScreenshots',
|
|
242
385
|
},
|
|
243
|
-
type: 'appScreenshots',
|
|
244
386
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
throw new Error(`Reserving screenshot ${fileName} returned no resource.`);
|
|
387
|
+
expectedStatuses: [200],
|
|
388
|
+
method: 'PATCH',
|
|
389
|
+
});
|
|
390
|
+
await this.waitForScreenshot(screenshotSetId, resourceId, fileName);
|
|
391
|
+
return resource;
|
|
251
392
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (operations.length === 0) {
|
|
256
|
-
throw new Error(`${fileName} did not receive upload operations.`);
|
|
393
|
+
catch (error) {
|
|
394
|
+
await this.cleanupScreenshotReservation(resourceId, fileName);
|
|
395
|
+
throw error;
|
|
257
396
|
}
|
|
258
|
-
await Promise.all(operations.map((operation) => this.uploadOperation(operation, file)));
|
|
259
|
-
const resourceId = requireString(resource['id'], `Reserved screenshot ID for ${fileName}`);
|
|
260
|
-
await this.request(`/v1/appScreenshots/${resourceId}`, {
|
|
261
|
-
body: {
|
|
262
|
-
data: {
|
|
263
|
-
attributes: {
|
|
264
|
-
sourceFileChecksum: checksum,
|
|
265
|
-
uploaded: true,
|
|
266
|
-
},
|
|
267
|
-
id: resourceId,
|
|
268
|
-
type: 'appScreenshots',
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
expectedStatuses: [200],
|
|
272
|
-
method: 'PATCH',
|
|
273
|
-
});
|
|
274
|
-
await this.waitForScreenshot(resourceId, fileName);
|
|
275
|
-
return resource;
|
|
276
397
|
}
|
|
277
398
|
async reorderScreenshots(screenshotSetId, screenshotIds) {
|
|
278
399
|
await this.request(`/v1/appScreenshotSets/${screenshotSetId}/relationships/appScreenshots`, {
|
|
@@ -298,29 +419,91 @@ export class Runner {
|
|
|
298
419
|
return requireObject(response['data'], `Asset library for ${appId}`);
|
|
299
420
|
}
|
|
300
421
|
async uploadAssetLibraryImage(assetLibraryId, category, referenceName, fileName, file) {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
422
|
+
const checksum = createHash('md5').update(file).digest('hex').slice(0, 8);
|
|
423
|
+
const idempotentReferenceName = `${referenceName} [md5:${checksum}]`;
|
|
424
|
+
const query = new URLSearchParams({
|
|
425
|
+
'fields[appAssetLibraryImages]': 'category,fileName,referenceName,state,stateDetails',
|
|
426
|
+
'filter[category]': category,
|
|
427
|
+
'filter[referenceName]': idempotentReferenceName,
|
|
428
|
+
'limit': '200',
|
|
429
|
+
});
|
|
430
|
+
const existingImages = await this.list(`/v1/appAssetLibraries/${assetLibraryId}/images?${query.toString()}`);
|
|
431
|
+
const priorImageIds = new Set(existingImages.map((existingImage) => requireString(existingImage['id'], `Existing asset ID for ${fileName}`)));
|
|
432
|
+
const reusableImage = existingImages.find((existingImage) => {
|
|
433
|
+
const reusableAttributes = requireObject(existingImage['attributes'], `Existing asset attributes for ${fileName}`);
|
|
434
|
+
const reusableState = reusableAttributes['state'];
|
|
435
|
+
return (reusableAttributes['referenceName'] === idempotentReferenceName
|
|
436
|
+
&& typeof reusableState === 'string'
|
|
437
|
+
&& readyAssetStates.has(reusableState) === true);
|
|
438
|
+
});
|
|
439
|
+
if (reusableImage !== undefined) {
|
|
440
|
+
return reusableImage;
|
|
441
|
+
}
|
|
442
|
+
const abandonedImages = existingImages.filter((existingImage) => {
|
|
443
|
+
const abandonedAttributes = requireObject(existingImage['attributes'], `Existing asset attributes for ${fileName}`);
|
|
444
|
+
const abandonedState = abandonedAttributes['state'];
|
|
445
|
+
return (abandonedAttributes['referenceName'] === idempotentReferenceName
|
|
446
|
+
&& typeof abandonedState === 'string'
|
|
447
|
+
&& failedAssetCleanupStates.has(abandonedState) === true);
|
|
448
|
+
});
|
|
449
|
+
const abandonedImageIds = abandonedImages.map((abandonedImage) => requireString(abandonedImage['id'], `Abandoned asset ID for ${fileName}`));
|
|
450
|
+
await Runner.runOperations(abandonedImageIds, (abandonedImageId) => this.deleteResource('appAssetLibraryImages', abandonedImageId));
|
|
451
|
+
let reservation = undefined;
|
|
452
|
+
let reservationAttempt = 1;
|
|
453
|
+
while (reservationAttempt <= maximumTransientAttempts) {
|
|
454
|
+
try {
|
|
455
|
+
reservation = await this.request('/v1/appAssetLibraryImages', {
|
|
456
|
+
body: {
|
|
457
|
+
data: {
|
|
458
|
+
attributes: {
|
|
459
|
+
category,
|
|
460
|
+
fileName,
|
|
461
|
+
fileSize: file.length,
|
|
462
|
+
referenceName: idempotentReferenceName,
|
|
463
|
+
},
|
|
464
|
+
relationships: {
|
|
465
|
+
assetLibrary: {
|
|
466
|
+
data: {
|
|
467
|
+
id: assetLibraryId,
|
|
468
|
+
type: 'appAssetLibraries',
|
|
469
|
+
},
|
|
470
|
+
},
|
|
315
471
|
},
|
|
472
|
+
type: 'appAssetLibraryImages',
|
|
316
473
|
},
|
|
317
474
|
},
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
475
|
+
expectedStatuses: [201],
|
|
476
|
+
method: 'POST',
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
if (Runner.isAmbiguousCreateError(error) === false) {
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
const reconciliationImages = await this.list(`/v1/appAssetLibraries/${assetLibraryId}/images?${query.toString()}`);
|
|
484
|
+
const reconciledImage = reconciliationImages.find((reconciliationImage) => {
|
|
485
|
+
const reconciliationImageId = requireString(reconciliationImage['id'], `Asset ID while reconciling ${fileName}`);
|
|
486
|
+
const reconciliationAttributes = requireObject(reconciliationImage['attributes'], `Asset attributes while reconciling ${fileName}`);
|
|
487
|
+
return (priorImageIds.has(reconciliationImageId) === false
|
|
488
|
+
&& reconciliationAttributes['category'] === category
|
|
489
|
+
&& reconciliationAttributes['referenceName'] === idempotentReferenceName);
|
|
490
|
+
});
|
|
491
|
+
if (reconciledImage !== undefined) {
|
|
492
|
+
reservation = { data: reconciledImage };
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
if (reservationAttempt >= maximumTransientAttempts) {
|
|
496
|
+
throw error;
|
|
497
|
+
}
|
|
498
|
+
const reservationRetryDecision = Runner.retryDecision(undefined, reservationAttempt, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
499
|
+
if (reservationRetryDecision !== undefined) {
|
|
500
|
+
await wait(reservationRetryDecision['delayMilliseconds']);
|
|
501
|
+
}
|
|
502
|
+
reservationAttempt += 1;
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
324
507
|
if (reservation === undefined) {
|
|
325
508
|
throw new Error(`Reserving asset ${fileName} returned no resource.`);
|
|
326
509
|
}
|
|
@@ -330,7 +513,7 @@ export class Runner {
|
|
|
330
513
|
if (operations.length === 0) {
|
|
331
514
|
throw new Error(`${fileName} did not receive upload operations.`);
|
|
332
515
|
}
|
|
333
|
-
await
|
|
516
|
+
await Runner.runOperations(operations, (operation) => this.uploadOperation(operation, file));
|
|
334
517
|
const resourceId = requireString(resource['id'], `Reserved asset ID for ${fileName}`);
|
|
335
518
|
await this.request(`/v1/appAssetLibraryImages/${resourceId}`, {
|
|
336
519
|
body: {
|
|
@@ -354,6 +537,185 @@ export class Runner {
|
|
|
354
537
|
});
|
|
355
538
|
return;
|
|
356
539
|
}
|
|
540
|
+
async cleanupScreenshotReservation(screenshotId, fileName) {
|
|
541
|
+
try {
|
|
542
|
+
await this.deleteResource('appScreenshots', screenshotId);
|
|
543
|
+
Logger.info(`Removed failed screenshot reservation ${fileName} (${screenshotId}).`);
|
|
544
|
+
}
|
|
545
|
+
catch (cleanupError) {
|
|
546
|
+
Logger.warn(`Unable to remove failed screenshot reservation ${fileName} (${screenshotId}): ${String(cleanupError)}`);
|
|
547
|
+
}
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
async pollScreenshotSet(screenshotSetId, attempt) {
|
|
551
|
+
const delayMilliseconds = Math.min(processingPollInitialDelayMilliseconds * Math.pow(2, attempt - 1), processingPollMaximumDelayMilliseconds);
|
|
552
|
+
await wait(delayMilliseconds);
|
|
553
|
+
const waiters = this.#screenshotProcessingWaiters.get(screenshotSetId);
|
|
554
|
+
if (waiters === undefined || waiters.size === 0) {
|
|
555
|
+
this.#screenshotProcessingPolls.delete(screenshotSetId);
|
|
556
|
+
this.#screenshotProcessingWaiters.delete(screenshotSetId);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
if (attempt > maximumProcessingAttempts) {
|
|
560
|
+
for (const waiterEntry of waiters) {
|
|
561
|
+
const timedOutWaiter = waiterEntry[1];
|
|
562
|
+
timedOutWaiter.reject(new Error(`${timedOutWaiter['fileName']} did not finish Apple processing in time.`));
|
|
563
|
+
}
|
|
564
|
+
waiters.clear();
|
|
565
|
+
this.#screenshotProcessingPolls.delete(screenshotSetId);
|
|
566
|
+
this.#screenshotProcessingWaiters.delete(screenshotSetId);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
try {
|
|
570
|
+
const resources = await this.listScreenshots(screenshotSetId);
|
|
571
|
+
for (const waiterEntry of waiters) {
|
|
572
|
+
const screenshotId = waiterEntry[0];
|
|
573
|
+
const processingWaiter = waiterEntry[1];
|
|
574
|
+
const resource = resources.find((candidate) => candidate['id'] === screenshotId);
|
|
575
|
+
if (resource === undefined) {
|
|
576
|
+
continue;
|
|
577
|
+
}
|
|
578
|
+
const attributes = requireObject(resource['attributes'], `Screenshot attributes for ${processingWaiter['fileName']}`);
|
|
579
|
+
const state = requireObject(attributes['assetDeliveryState'], `Screenshot delivery state for ${processingWaiter['fileName']}`);
|
|
580
|
+
if (state['state'] === 'COMPLETE') {
|
|
581
|
+
waiters.delete(screenshotId);
|
|
582
|
+
processingWaiter.resolve();
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (state['state'] === 'FAILED') {
|
|
586
|
+
const errors = JSON.stringify(state['errors'] ?? []);
|
|
587
|
+
waiters.delete(screenshotId);
|
|
588
|
+
processingWaiter.reject(new Error(`${processingWaiter['fileName']} failed Apple processing: ${errors}`));
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (waiters.size === 0) {
|
|
592
|
+
this.#screenshotProcessingPolls.delete(screenshotSetId);
|
|
593
|
+
this.#screenshotProcessingWaiters.delete(screenshotSetId);
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
await this.pollScreenshotSet(screenshotSetId, attempt + 1);
|
|
597
|
+
}
|
|
598
|
+
catch (error) {
|
|
599
|
+
for (const waiterEntry of waiters) {
|
|
600
|
+
const pollingWaiter = waiterEntry[1];
|
|
601
|
+
pollingWaiter.reject(error);
|
|
602
|
+
}
|
|
603
|
+
waiters.clear();
|
|
604
|
+
this.#screenshotProcessingPolls.delete(screenshotSetId);
|
|
605
|
+
this.#screenshotProcessingWaiters.delete(screenshotSetId);
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
async reserveScreenshot(screenshotSetId, fileName, file, priorScreenshotIds, attempt) {
|
|
611
|
+
let reservation = undefined;
|
|
612
|
+
try {
|
|
613
|
+
reservation = await this.request('/v1/appScreenshots', {
|
|
614
|
+
body: {
|
|
615
|
+
data: {
|
|
616
|
+
attributes: {
|
|
617
|
+
fileName,
|
|
618
|
+
fileSize: file.length,
|
|
619
|
+
},
|
|
620
|
+
relationships: {
|
|
621
|
+
appScreenshotSet: {
|
|
622
|
+
data: {
|
|
623
|
+
id: screenshotSetId,
|
|
624
|
+
type: 'appScreenshotSets',
|
|
625
|
+
},
|
|
626
|
+
},
|
|
627
|
+
},
|
|
628
|
+
type: 'appScreenshots',
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
expectedStatuses: [201],
|
|
632
|
+
method: 'POST',
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
catch (error) {
|
|
636
|
+
if (Runner.isAmbiguousCreateError(error) === false) {
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
const resources = await this.listScreenshots(screenshotSetId);
|
|
640
|
+
const orphanIds = resources.filter((resource) => {
|
|
641
|
+
const resourceId = requireString(resource['id'], `Screenshot ID while reconciling ${fileName}`);
|
|
642
|
+
const attributes = requireObject(resource['attributes'], `Screenshot attributes while reconciling ${fileName}`);
|
|
643
|
+
const state = requireObject(attributes['assetDeliveryState'], `Screenshot delivery state while reconciling ${fileName}`);
|
|
644
|
+
return (priorScreenshotIds.has(resourceId) === false
|
|
645
|
+
&& attributes['fileName'] === fileName
|
|
646
|
+
&& state['state'] === 'AWAITING_UPLOAD');
|
|
647
|
+
}).map((resource) => requireString(resource['id'], `Orphan screenshot ID for ${fileName}`));
|
|
648
|
+
await Runner.runOperations(orphanIds, (orphanId) => this.deleteResource('appScreenshots', orphanId));
|
|
649
|
+
if (attempt >= maximumTransientAttempts) {
|
|
650
|
+
throw error;
|
|
651
|
+
}
|
|
652
|
+
const retryDecision = Runner.retryDecision(undefined, attempt, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
653
|
+
if (retryDecision !== undefined) {
|
|
654
|
+
await wait(retryDecision['delayMilliseconds']);
|
|
655
|
+
}
|
|
656
|
+
return this.reserveScreenshot(screenshotSetId, fileName, file, priorScreenshotIds, attempt + 1);
|
|
657
|
+
}
|
|
658
|
+
if (reservation === undefined) {
|
|
659
|
+
throw new Error(`Reserving screenshot ${fileName} returned no resource.`);
|
|
660
|
+
}
|
|
661
|
+
return requireObject(reservation['data'], `Reserved screenshot ${fileName}`);
|
|
662
|
+
}
|
|
663
|
+
async acquireApiOperation() {
|
|
664
|
+
if (this.#activeApiOperations < maximumConcurrentApiOperations) {
|
|
665
|
+
this.#activeApiOperations += 1;
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
await new Promise((resume) => {
|
|
669
|
+
this.#apiOperationQueue.push(resume);
|
|
670
|
+
return;
|
|
671
|
+
});
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
async waitForApiPause() {
|
|
675
|
+
const delayMilliseconds = this.#apiOperationsPausedUntil - Date.now();
|
|
676
|
+
if (delayMilliseconds <= 0) {
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
await wait(delayMilliseconds);
|
|
680
|
+
await this.waitForApiPause();
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
async fetchWithLimit(url, options) {
|
|
684
|
+
await this.acquireApiOperation();
|
|
685
|
+
try {
|
|
686
|
+
await this.waitForApiPause();
|
|
687
|
+
const headers = {
|
|
688
|
+
...(options['headers'] ?? {}),
|
|
689
|
+
};
|
|
690
|
+
if (options['authenticated'] === true) {
|
|
691
|
+
Reflect.set(headers, 'Accept', 'application/json');
|
|
692
|
+
Reflect.set(headers, 'Authorization', `Bearer ${this.getToken()}`);
|
|
693
|
+
if (options['body'] !== undefined) {
|
|
694
|
+
Reflect.set(headers, 'Content-Type', 'application/json');
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
const requestInit = {
|
|
698
|
+
headers,
|
|
699
|
+
method: options['method'],
|
|
700
|
+
signal: AbortSignal.timeout(options['timeoutMilliseconds']),
|
|
701
|
+
};
|
|
702
|
+
if (options['body'] !== undefined) {
|
|
703
|
+
Reflect.set(requestInit, 'body', options['body']);
|
|
704
|
+
}
|
|
705
|
+
const response = await fetch(url, requestInit);
|
|
706
|
+
this.applyRateLimitBudget(response);
|
|
707
|
+
if (response.status === 429) {
|
|
708
|
+
const retryDecision = Runner.retryDecision(response, options['rateLimitAttempt'], maximumRateLimitAttempts, maximumRateLimitDelayMilliseconds);
|
|
709
|
+
if (retryDecision !== undefined) {
|
|
710
|
+
this.pauseApiOperations(retryDecision['delayMilliseconds']);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return response;
|
|
714
|
+
}
|
|
715
|
+
finally {
|
|
716
|
+
this.releaseApiOperation();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
357
719
|
async uploadOperation(operation, file) {
|
|
358
720
|
const method = requireString(operation['method'], 'Upload operation method');
|
|
359
721
|
const url = requireString(operation['url'], 'Upload operation URL');
|
|
@@ -369,61 +731,71 @@ export class Runner {
|
|
|
369
731
|
if (offset + length > file.length) {
|
|
370
732
|
throw new Error(`Upload operation exceeds the ${file.length}-byte source file.`);
|
|
371
733
|
}
|
|
372
|
-
await this.uploadOperationAttempt(url, method, headers, file, offset, length,
|
|
734
|
+
await this.uploadOperationAttempt(url, method, headers, file, offset, length, 0, 0);
|
|
373
735
|
return;
|
|
374
736
|
}
|
|
375
|
-
async uploadOperationAttempt(url, method, headers, file, offset, length,
|
|
737
|
+
async uploadOperationAttempt(url, method, headers, file, offset, length, rateLimitAttempt, transientAttempt) {
|
|
376
738
|
let response = undefined;
|
|
377
739
|
try {
|
|
378
|
-
response = await
|
|
740
|
+
response = await this.fetchWithLimit(url, {
|
|
741
|
+
authenticated: false,
|
|
379
742
|
body: file.subarray(offset, offset + length),
|
|
380
743
|
headers,
|
|
381
744
|
method,
|
|
382
|
-
|
|
745
|
+
rateLimitAttempt: rateLimitAttempt + 1,
|
|
746
|
+
timeoutMilliseconds: assetUploadTimeoutMilliseconds,
|
|
383
747
|
});
|
|
384
748
|
}
|
|
385
749
|
catch (error) {
|
|
386
|
-
|
|
750
|
+
const networkRetryDecision = Runner.retryDecision(undefined, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
751
|
+
if (networkRetryDecision === undefined) {
|
|
387
752
|
throw new Error('Asset upload failed.', { cause: error });
|
|
388
753
|
}
|
|
389
|
-
await wait(
|
|
390
|
-
await this.uploadOperationAttempt(url, method, headers, file, offset, length,
|
|
754
|
+
await wait(networkRetryDecision['delayMilliseconds']);
|
|
755
|
+
await this.uploadOperationAttempt(url, method, headers, file, offset, length, rateLimitAttempt, transientAttempt + 1);
|
|
391
756
|
return;
|
|
392
757
|
}
|
|
393
758
|
if (response.ok === true) {
|
|
394
759
|
return;
|
|
395
760
|
}
|
|
396
761
|
const responseText = await response.text();
|
|
397
|
-
|
|
398
|
-
|
|
762
|
+
if (response.status === 429) {
|
|
763
|
+
const rateLimitRetryDecision = Runner.retryDecision(response, rateLimitAttempt + 1, maximumRateLimitAttempts, maximumRateLimitDelayMilliseconds);
|
|
764
|
+
if (rateLimitRetryDecision === undefined) {
|
|
765
|
+
throw new Error(`Asset upload failed with HTTP ${response.status}: ${responseText}. The run is safe to resume after App Store Connect's rate limit resets.`);
|
|
766
|
+
}
|
|
767
|
+
await this.uploadOperationAttempt(url, method, headers, file, offset, length, rateLimitAttempt + 1, transientAttempt);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const responseRetryDecision = Runner.retryDecision(response, transientAttempt + 1, maximumTransientAttempts, maximumTransientDelayMilliseconds);
|
|
771
|
+
if (responseRetryDecision === undefined) {
|
|
399
772
|
throw new Error(`Asset upload failed with HTTP ${response.status}: ${responseText}`);
|
|
400
773
|
}
|
|
401
|
-
await wait(
|
|
402
|
-
await this.uploadOperationAttempt(url, method, headers, file, offset, length,
|
|
774
|
+
await wait(responseRetryDecision['delayMilliseconds']);
|
|
775
|
+
await this.uploadOperationAttempt(url, method, headers, file, offset, length, rateLimitAttempt, transientAttempt + 1);
|
|
403
776
|
return;
|
|
404
777
|
}
|
|
405
|
-
async waitForScreenshot(screenshotId, fileName
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
const attributes = requireObject(data['attributes'], `Screenshot attributes for ${fileName}`);
|
|
418
|
-
const state = requireObject(attributes['assetDeliveryState'], `Screenshot delivery state for ${fileName}`);
|
|
419
|
-
if (state['state'] === 'COMPLETE') {
|
|
778
|
+
async waitForScreenshot(screenshotSetId, screenshotId, fileName) {
|
|
779
|
+
let waiters = this.#screenshotProcessingWaiters.get(screenshotSetId);
|
|
780
|
+
if (waiters === undefined) {
|
|
781
|
+
waiters = new Map();
|
|
782
|
+
this.#screenshotProcessingWaiters.set(screenshotSetId, waiters);
|
|
783
|
+
}
|
|
784
|
+
const processingPromise = new Promise((resolvePromise, rejectPromise) => {
|
|
785
|
+
waiters.set(screenshotId, {
|
|
786
|
+
fileName,
|
|
787
|
+
reject: rejectPromise,
|
|
788
|
+
resolve: resolvePromise,
|
|
789
|
+
});
|
|
420
790
|
return;
|
|
791
|
+
});
|
|
792
|
+
const existingPoll = this.#screenshotProcessingPolls.get(screenshotSetId);
|
|
793
|
+
if (existingPoll === undefined) {
|
|
794
|
+
const poll = this.pollScreenshotSet(screenshotSetId, 1);
|
|
795
|
+
this.#screenshotProcessingPolls.set(screenshotSetId, poll);
|
|
796
|
+
poll.catch(() => undefined);
|
|
421
797
|
}
|
|
422
|
-
|
|
423
|
-
throw new Error(`${fileName} failed Apple processing: ${JSON.stringify(state['errors'] ?? [])}`);
|
|
424
|
-
}
|
|
425
|
-
await wait(2000);
|
|
426
|
-
await this.waitForScreenshot(screenshotId, fileName, attempt + 1);
|
|
798
|
+
await processingPromise;
|
|
427
799
|
return;
|
|
428
800
|
}
|
|
429
801
|
async waitForAssetLibraryImage(imageId, fileName, attempt = 1) {
|
|
@@ -446,12 +818,56 @@ export class Runner {
|
|
|
446
818
|
if (failedAssetStates.has(state) === true) {
|
|
447
819
|
throw new Error(`${fileName} failed Apple processing in state ${state}: ${JSON.stringify(attributes['stateDetails'] ?? {})}`);
|
|
448
820
|
}
|
|
449
|
-
|
|
821
|
+
const delayMilliseconds = Math.min(processingPollInitialDelayMilliseconds * Math.pow(2, attempt - 1), processingPollMaximumDelayMilliseconds);
|
|
822
|
+
await wait(delayMilliseconds);
|
|
450
823
|
return this.waitForAssetLibraryImage(imageId, fileName, attempt + 1);
|
|
451
824
|
}
|
|
825
|
+
applyRateLimitBudget(response) {
|
|
826
|
+
const header = response.headers.get('x-rate-limit');
|
|
827
|
+
if (header === null || header === '') {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
const parts = header.split(';').map((part) => part.trim()).filter((part) => part !== '');
|
|
831
|
+
let limit = undefined;
|
|
832
|
+
let remaining = undefined;
|
|
833
|
+
for (const part of parts) {
|
|
834
|
+
const separatorIndex = part.indexOf(':');
|
|
835
|
+
if (separatorIndex === -1) {
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
const name = part.slice(0, separatorIndex);
|
|
839
|
+
const value = Number(part.slice(separatorIndex + 1));
|
|
840
|
+
if (Number.isFinite(value) === false || value < 0) {
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if (name === 'user-hour-lim') {
|
|
844
|
+
limit = value;
|
|
845
|
+
}
|
|
846
|
+
if (name === 'user-hour-rem') {
|
|
847
|
+
remaining = value;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (limit === undefined
|
|
851
|
+
|| remaining === undefined
|
|
852
|
+
|| limit <= 0) {
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
const remainingRatio = remaining / limit;
|
|
856
|
+
let delayMilliseconds = 0;
|
|
857
|
+
if (remaining <= 10 || remainingRatio <= 0.01) {
|
|
858
|
+
delayMilliseconds = rateLimitCriticalDelayMilliseconds;
|
|
859
|
+
}
|
|
860
|
+
else if (remainingRatio <= 0.05) {
|
|
861
|
+
delayMilliseconds = rateLimitLowDelayMilliseconds;
|
|
862
|
+
}
|
|
863
|
+
if (delayMilliseconds > 0) {
|
|
864
|
+
this.pauseApiOperations(delayMilliseconds);
|
|
865
|
+
}
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
452
868
|
getToken() {
|
|
453
869
|
const now = Math.floor(Date.now() / 1000);
|
|
454
|
-
if (this.#token !== undefined && now < this.#tokenExpiresAt -
|
|
870
|
+
if (this.#token !== undefined && now < this.#tokenExpiresAt - 60) {
|
|
455
871
|
return this.#token;
|
|
456
872
|
}
|
|
457
873
|
const issuedAt = now;
|
|
@@ -483,12 +899,79 @@ export class Runner {
|
|
|
483
899
|
this.#tokenExpiresAt = expiresAt;
|
|
484
900
|
return this.#token;
|
|
485
901
|
}
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
902
|
+
pauseApiOperations(delayMilliseconds) {
|
|
903
|
+
const pausedUntil = Date.now() + delayMilliseconds;
|
|
904
|
+
this.#apiOperationsPausedUntil = Math.max(this.#apiOperationsPausedUntil, pausedUntil);
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
releaseApiOperation() {
|
|
908
|
+
this.#activeApiOperations -= 1;
|
|
909
|
+
const resume = this.#apiOperationQueue.shift();
|
|
910
|
+
if (resume === undefined) {
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
this.#activeApiOperations += 1;
|
|
914
|
+
resume();
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
static retryAfterDelay(response) {
|
|
918
|
+
const value = response.headers.get('retry-after');
|
|
919
|
+
if (value === null || value === '') {
|
|
920
|
+
return undefined;
|
|
921
|
+
}
|
|
922
|
+
const seconds = Number(value);
|
|
923
|
+
if (Number.isFinite(seconds) === true && seconds >= 0) {
|
|
924
|
+
return seconds * 1000;
|
|
490
925
|
}
|
|
491
|
-
|
|
926
|
+
const date = Date.parse(value);
|
|
927
|
+
if (Number.isFinite(date) === false) {
|
|
928
|
+
return undefined;
|
|
929
|
+
}
|
|
930
|
+
return Math.max(0, date - Date.now());
|
|
931
|
+
}
|
|
932
|
+
static requestError(message, ambiguousCreate, cause = undefined) {
|
|
933
|
+
const error = (cause === undefined) ? new Error(message) : new Error(message, { cause });
|
|
934
|
+
Reflect.set(error, 'appStoreConnectAmbiguousCreate', ambiguousCreate);
|
|
935
|
+
return error;
|
|
936
|
+
}
|
|
937
|
+
static retryDecision(response, attempt, maximumAttempts, maximumDelayMilliseconds) {
|
|
938
|
+
if (response !== undefined
|
|
939
|
+
&& response.status !== 429
|
|
940
|
+
&& response.status < 500) {
|
|
941
|
+
return undefined;
|
|
942
|
+
}
|
|
943
|
+
if (attempt >= maximumAttempts) {
|
|
944
|
+
return undefined;
|
|
945
|
+
}
|
|
946
|
+
if (response !== undefined) {
|
|
947
|
+
const retryAfterDelay = Runner.retryAfterDelay(response);
|
|
948
|
+
if (retryAfterDelay !== undefined) {
|
|
949
|
+
return { delayMilliseconds: retryAfterDelay };
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
const exponentialDelay = Math.min(initialRetryDelayMilliseconds * Math.pow(2, attempt - 1), maximumDelayMilliseconds);
|
|
953
|
+
const jitterMultiplier = 0.5 + (Math.random() * 0.5);
|
|
954
|
+
return { delayMilliseconds: Math.floor(exponentialDelay * jitterMultiplier) };
|
|
955
|
+
}
|
|
956
|
+
static async runOperationBatch(items, operation, results, offset) {
|
|
957
|
+
if (offset >= items.length) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
const batchItems = items.slice(offset, offset + maximumConcurrentApiOperations);
|
|
961
|
+
const batchPromises = batchItems.map((item, index) => operation(item, offset + index));
|
|
962
|
+
const batchResults = await Promise.allSettled(batchPromises);
|
|
963
|
+
const rejectedResults = batchResults.filter((batchResult) => batchResult.status === 'rejected');
|
|
964
|
+
for (const batchResult of batchResults) {
|
|
965
|
+
if (batchResult.status === 'fulfilled') {
|
|
966
|
+
results.push(batchResult.value);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
if (rejectedResults.length > 0) {
|
|
970
|
+
const errors = rejectedResults.map((rejectedResult) => rejectedResult.reason);
|
|
971
|
+
throw new AggregateError(errors, `${rejectedResults.length} App Store Connect operation(s) failed after every in-flight operation finished.`);
|
|
972
|
+
}
|
|
973
|
+
await Runner.runOperationBatch(items, operation, results, offset + batchItems.length);
|
|
974
|
+
return;
|
|
492
975
|
}
|
|
493
976
|
}
|
|
494
977
|
//# sourceMappingURL=app-store-connect.js.map
|