@cbnventures/nova 0.38.0 → 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 +210 -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 +685 -70
- 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 +12 -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/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 +140 -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 +35 -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 +800 -7
- package/build/src/cli/utility/changelog.js.map +1 -1
- package/build/src/cli/utility/configure.d.ts +3 -1
- package/build/src/cli/utility/configure.d.ts.map +1 -1
- package/build/src/cli/utility/configure.js +196 -20
- package/build/src/cli/utility/configure.js.map +1 -1
- package/build/src/lib/docker-packaging.d.ts +1 -0
- package/build/src/lib/docker-packaging.d.ts.map +1 -1
- package/build/src/lib/docker-packaging.js +39 -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.d.ts.map +1 -1
- package/build/src/lib/nova-config.js +46 -2
- 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/scaffold.d.ts +3 -3
- package/build/src/lib/scaffold.d.ts.map +1 -1
- package/build/src/lib/scaffold.js +111 -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 +69 -8
- package/build/src/types/cli/generate/github/workflows-blueprint.d.ts +132 -9
- 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 +92 -4
- package/build/src/types/lib/docker-packaging.d.ts +25 -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 +24 -0
- package/build/src/types/lib/regex.d.ts +91 -0
- package/build/src/types/lib/scaffold.d.ts +48 -4
- package/build/src/types/lib/workflow-templates.d.ts +26 -0
- package/build/src/types/shared.d.ts +241 -2
- 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 +123 -30
- package/build/src/types/tests/cli/generate/github/workflows-blueprint.test.d.ts +45 -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/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 +55 -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/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,11 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { promises as fs } from 'node:fs';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
4
|
import { join } from 'node:path';
|
|
4
5
|
import prompts from 'prompts';
|
|
5
6
|
import { parse as parseYaml } from 'yaml';
|
|
6
7
|
import { Runner as AppStoreConnect } from '../../api/app-store-connect.js';
|
|
7
|
-
import { collectAssetTargets, collectMetadataTargets, confirmPlan, parseCommaSeparated, reportPlan, requireArray, requireObject, requireString, resolveWorkspace, } from '../../lib/integration.js';
|
|
8
|
+
import { collectAssetTargets, collectMetadataTargets, confirmPlan, parseCommaSeparated, reportPlan, requireArray, requireObject, requireString, resolveWorkspace, wait, } from '../../lib/integration.js';
|
|
8
9
|
import { pathExists } from '../../lib/utility.js';
|
|
9
10
|
import { Logger } from '../../toolkit/index.js';
|
|
10
11
|
const metadataFields = [
|
|
@@ -51,6 +52,79 @@ const screenshotDisplayTypes = new Map([
|
|
|
51
52
|
'APP_APPLE_VISION_PRO',
|
|
52
53
|
],
|
|
53
54
|
]);
|
|
55
|
+
const screenshotSizeSpecifications = new Map([
|
|
56
|
+
[
|
|
57
|
+
'apple-watch',
|
|
58
|
+
['416x496'],
|
|
59
|
+
],
|
|
60
|
+
[
|
|
61
|
+
'ipad',
|
|
62
|
+
[
|
|
63
|
+
'2064x2752',
|
|
64
|
+
'2752x2064',
|
|
65
|
+
'2048x2732',
|
|
66
|
+
'2732x2048',
|
|
67
|
+
],
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
'iphone',
|
|
71
|
+
[
|
|
72
|
+
'1260x2736',
|
|
73
|
+
'2736x1260',
|
|
74
|
+
'1290x2796',
|
|
75
|
+
'2796x1290',
|
|
76
|
+
'1320x2868',
|
|
77
|
+
'2868x1320',
|
|
78
|
+
],
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
'iphone-duo',
|
|
82
|
+
[
|
|
83
|
+
'1398x2034',
|
|
84
|
+
'2034x1398',
|
|
85
|
+
'2007x2853',
|
|
86
|
+
'2853x2007',
|
|
87
|
+
],
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
'mac',
|
|
91
|
+
[
|
|
92
|
+
'1280x800',
|
|
93
|
+
'1440x900',
|
|
94
|
+
'2560x1600',
|
|
95
|
+
'2880x1800',
|
|
96
|
+
],
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
'vision-pro',
|
|
100
|
+
['3840x2160'],
|
|
101
|
+
],
|
|
102
|
+
]);
|
|
103
|
+
const pngSignature = Buffer.from([
|
|
104
|
+
137,
|
|
105
|
+
80,
|
|
106
|
+
78,
|
|
107
|
+
71,
|
|
108
|
+
13,
|
|
109
|
+
10,
|
|
110
|
+
26,
|
|
111
|
+
10,
|
|
112
|
+
]);
|
|
113
|
+
const jpegStartOfFrameMarkers = new Set([
|
|
114
|
+
parseInt('C0', 16),
|
|
115
|
+
parseInt('C1', 16),
|
|
116
|
+
parseInt('C2', 16),
|
|
117
|
+
parseInt('C3', 16),
|
|
118
|
+
parseInt('C5', 16),
|
|
119
|
+
parseInt('C6', 16),
|
|
120
|
+
parseInt('C7', 16),
|
|
121
|
+
parseInt('C9', 16),
|
|
122
|
+
parseInt('CA', 16),
|
|
123
|
+
parseInt('CB', 16),
|
|
124
|
+
parseInt('CD', 16),
|
|
125
|
+
parseInt('CE', 16),
|
|
126
|
+
parseInt('CF', 16),
|
|
127
|
+
]);
|
|
54
128
|
const creativePlacementTypes = new Map([
|
|
55
129
|
[
|
|
56
130
|
'product-page-header',
|
|
@@ -61,6 +135,21 @@ const creativePlacementTypes = new Map([
|
|
|
61
135
|
'APP_STORE_SEARCH_RESULTS_ASSET',
|
|
62
136
|
],
|
|
63
137
|
]);
|
|
138
|
+
const maximumPlacementCounts = new Map([
|
|
139
|
+
[
|
|
140
|
+
'APP_SCREENSHOT',
|
|
141
|
+
10,
|
|
142
|
+
],
|
|
143
|
+
[
|
|
144
|
+
'APP_STORE_SEARCH_RESULTS_ASSET',
|
|
145
|
+
1,
|
|
146
|
+
],
|
|
147
|
+
[
|
|
148
|
+
'PRODUCT_PAGE_HEADER_ASSET',
|
|
149
|
+
1,
|
|
150
|
+
],
|
|
151
|
+
]);
|
|
152
|
+
const maximumScreenshotCount = 10;
|
|
64
153
|
export class Runner {
|
|
65
154
|
static async metadata(options) {
|
|
66
155
|
const workspaceContext = await Runner.prepareWorkspace(options);
|
|
@@ -76,12 +165,12 @@ export class Runner {
|
|
|
76
165
|
const client = await Runner.createClient(options);
|
|
77
166
|
const app = await client.findApp(workspaceContext['bundleIdentifier']);
|
|
78
167
|
const appId = Runner.resourceId(app, 'App');
|
|
79
|
-
await
|
|
168
|
+
await AppStoreConnect.runOperations(targets, async (target) => {
|
|
80
169
|
const context = await Runner.resolveContext(client, app, workspaceContext['version'], target['platform'], target['locale']);
|
|
81
170
|
const localizationId = Runner.resourceId(context['localization'], `${target['locale']} localization`);
|
|
82
171
|
await client.updateLocalization(localizationId, target['attributes']);
|
|
83
172
|
return;
|
|
84
|
-
})
|
|
173
|
+
});
|
|
85
174
|
Logger.info(`Updated ${targets.length} App Store Connect metadata target(s) for app ${appId}.`);
|
|
86
175
|
return;
|
|
87
176
|
}
|
|
@@ -100,6 +189,7 @@ export class Runner {
|
|
|
100
189
|
const lines = targets.map((target) => `${target['relativePath']}: ${target['files'].length} ordered image(s)`);
|
|
101
190
|
Runner.validateTargets(targets);
|
|
102
191
|
Runner.validateScreenshotTargets(targets);
|
|
192
|
+
await Runner.validateScreenshotImages(targets, options['skipImageChecks'] === true);
|
|
103
193
|
reportPlan(`Replace App Store Connect screenshots for ${workspaceContext['bundleIdentifier']} ${workspaceContext['version']}:`, lines);
|
|
104
194
|
if (await confirmPlan(options['dryRun'] === true, options['nonInteractive'] === true, options['yes'] === true) === false || options['dryRun'] === true) {
|
|
105
195
|
return;
|
|
@@ -110,7 +200,7 @@ export class Runner {
|
|
|
110
200
|
const contextCache = new Map();
|
|
111
201
|
const duoTargets = targets.filter((target) => target['target'] === 'iphone-duo');
|
|
112
202
|
const standardTargets = targets.filter((target) => target['target'] !== 'iphone-duo');
|
|
113
|
-
await
|
|
203
|
+
await AppStoreConnect.runOperations(standardTargets, async (target) => {
|
|
114
204
|
const standardContext = await Runner.resolveCachedContext(contextCache, client, app, workspaceContext['version'], target['platform'], target['locale']);
|
|
115
205
|
const localizationId = Runner.resourceId(standardContext['localization'], `${target['locale']} localization`);
|
|
116
206
|
const displayType = screenshotDisplayTypes.get(target['target']);
|
|
@@ -122,30 +212,113 @@ export class Runner {
|
|
|
122
212
|
const attributes = requireObject(candidate['attributes'], 'Screenshot set attributes');
|
|
123
213
|
return attributes['screenshotDisplayType'] === displayType;
|
|
124
214
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
215
|
+
const activeSet = (set === undefined) ? await client.createScreenshotSet(localizationId, displayType) : set;
|
|
216
|
+
const setId = Runner.resourceId(activeSet, `${displayType} screenshot set`);
|
|
217
|
+
const existingScreenshots = (set === undefined) ? [] : await client.listScreenshots(setId);
|
|
218
|
+
const incompleteScreenshots = existingScreenshots.filter((screenshot) => {
|
|
219
|
+
const incompleteAttributes = requireObject(screenshot['attributes'], 'Existing screenshot attributes');
|
|
220
|
+
const incompleteDeliveryState = requireObject(incompleteAttributes['assetDeliveryState'], 'Existing screenshot delivery state');
|
|
221
|
+
return incompleteDeliveryState['state'] !== 'COMPLETE';
|
|
222
|
+
});
|
|
223
|
+
const incompleteScreenshotIds = incompleteScreenshots.map((incompleteScreenshot) => Runner.resourceId(incompleteScreenshot, 'Incomplete screenshot'));
|
|
224
|
+
if (incompleteScreenshotIds.length > 0) {
|
|
225
|
+
try {
|
|
226
|
+
await AppStoreConnect.runOperations(incompleteScreenshotIds, (incompleteScreenshotId) => client.deleteResource('appScreenshots', incompleteScreenshotId));
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
throw new Error(`Unable to clean incomplete screenshots for ${target['relativePath']}. Existing complete screenshots were left in place.`, { cause: error });
|
|
230
|
+
}
|
|
231
|
+
Logger.info(`Cleaned ${incompleteScreenshotIds.length} incomplete screenshot reservation(s) before replacing ${target['relativePath']}.`);
|
|
232
|
+
}
|
|
233
|
+
const completeScreenshots = existingScreenshots.filter((screenshot) => {
|
|
234
|
+
const completeAttributes = requireObject(screenshot['attributes'], 'Existing screenshot attributes');
|
|
235
|
+
const completeDeliveryState = requireObject(completeAttributes['assetDeliveryState'], 'Existing screenshot delivery state');
|
|
236
|
+
return completeDeliveryState['state'] === 'COMPLETE';
|
|
237
|
+
});
|
|
238
|
+
if (completeScreenshots.length > maximumScreenshotCount) {
|
|
239
|
+
throw new Error(`${target['relativePath']} contains ${completeScreenshots.length} complete screenshots, exceeding Apple's ${maximumScreenshotCount}-screenshot limit.`);
|
|
240
|
+
}
|
|
241
|
+
const fileBuffers = await Runner.readFiles(target);
|
|
242
|
+
const fileChecksums = fileBuffers.map((fileBuffer) => createHash('md5').update(fileBuffer).digest('hex'));
|
|
243
|
+
const availableScreenshots = [...completeScreenshots];
|
|
244
|
+
const desiredScreenshotIds = target['files'].map(() => undefined);
|
|
245
|
+
const pendingFileIndexes = [];
|
|
246
|
+
for (let fileIndex = 0; fileIndex < fileChecksums.length; fileIndex += 1) {
|
|
247
|
+
const fileChecksum = fileChecksums[fileIndex];
|
|
248
|
+
if (fileChecksum === undefined) {
|
|
249
|
+
throw new Error(`Unable to calculate a checksum for local screenshot index ${fileIndex} in ${target['relativePath']}.`);
|
|
250
|
+
}
|
|
251
|
+
const matchingScreenshotIndex = availableScreenshots.findIndex((availableScreenshot) => {
|
|
252
|
+
const matchingAttributes = requireObject(availableScreenshot['attributes'], 'Existing screenshot attributes');
|
|
253
|
+
const matchingChecksum = matchingAttributes['sourceFileChecksum'];
|
|
254
|
+
return typeof matchingChecksum === 'string' && matchingChecksum.toLowerCase() === fileChecksum;
|
|
255
|
+
});
|
|
256
|
+
if (matchingScreenshotIndex === -1) {
|
|
257
|
+
pendingFileIndexes.push(fileIndex);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
const matchingScreenshot = availableScreenshots[matchingScreenshotIndex];
|
|
261
|
+
if (matchingScreenshot === undefined) {
|
|
262
|
+
throw new Error(`Unable to reuse local screenshot index ${fileIndex} in ${target['relativePath']}.`);
|
|
263
|
+
}
|
|
264
|
+
const matchingScreenshotId = Runner.resourceId(matchingScreenshot, 'Matching screenshot');
|
|
265
|
+
Reflect.set(desiredScreenshotIds, fileIndex, matchingScreenshotId);
|
|
266
|
+
availableScreenshots.splice(matchingScreenshotIndex, 1);
|
|
267
|
+
}
|
|
268
|
+
const remainingOldScreenshotIds = new Set(availableScreenshots.map((availableScreenshot) => Runner.resourceId(availableScreenshot, 'Existing screenshot')));
|
|
269
|
+
const freeSlots = maximumScreenshotCount - completeScreenshots.length;
|
|
270
|
+
try {
|
|
271
|
+
await Runner.replaceScreenshotBatch(client, setId, target, fileBuffers, pendingFileIndexes, desiredScreenshotIds, remainingOldScreenshotIds, freeSlots);
|
|
272
|
+
}
|
|
273
|
+
catch (error) {
|
|
274
|
+
let oldScreenshotCount = remainingOldScreenshotIds.size;
|
|
275
|
+
let desiredScreenshotCount = desiredScreenshotIds.filter((desiredScreenshotId) => desiredScreenshotId !== undefined).length;
|
|
276
|
+
let placeholderCount = 0;
|
|
277
|
+
let remainingDescription = '';
|
|
278
|
+
try {
|
|
279
|
+
const remainingScreenshots = await client.listScreenshots(setId);
|
|
280
|
+
const desiredIdSet = new Set(desiredScreenshotIds.filter((desiredScreenshotId) => desiredScreenshotId !== undefined));
|
|
281
|
+
const remainingPlaceholders = [];
|
|
282
|
+
oldScreenshotCount = 0;
|
|
283
|
+
desiredScreenshotCount = 0;
|
|
284
|
+
for (const remainingScreenshot of remainingScreenshots) {
|
|
285
|
+
const remainingScreenshotId = Runner.resourceId(remainingScreenshot, 'Remaining screenshot');
|
|
286
|
+
const remainingAttributes = requireObject(remainingScreenshot['attributes'], 'Remaining screenshot attributes');
|
|
287
|
+
const remainingState = requireObject(remainingAttributes['assetDeliveryState'], 'Remaining screenshot delivery state');
|
|
288
|
+
if (remainingState['state'] !== 'COMPLETE') {
|
|
289
|
+
const remainingFileName = (typeof remainingAttributes['fileName'] === 'string') ? remainingAttributes['fileName'] : remainingScreenshotId;
|
|
290
|
+
remainingPlaceholders.push(`${remainingFileName}:${String(remainingState['state'] ?? 'UNKNOWN')}`);
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (desiredIdSet.has(remainingScreenshotId) === true) {
|
|
294
|
+
desiredScreenshotCount += 1;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
oldScreenshotCount += 1;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
placeholderCount = remainingPlaceholders.length;
|
|
301
|
+
remainingDescription = (placeholderCount === 0) ? 'none' : remainingPlaceholders.join(', ');
|
|
302
|
+
}
|
|
303
|
+
catch (stateError) {
|
|
304
|
+
remainingDescription = `unavailable (${String(stateError)})`;
|
|
305
|
+
}
|
|
306
|
+
throw new Error(`Replacing ${target['relativePath']} stopped after an App Store Connect failure. Remaining set: ${oldScreenshotCount} old COMPLETE screenshot(s), ${desiredScreenshotCount} replacement COMPLETE screenshot(s), and ${placeholderCount} non-COMPLETE placeholder(s) (${remainingDescription}).`, { cause: error });
|
|
307
|
+
}
|
|
135
308
|
return;
|
|
136
|
-
})
|
|
309
|
+
});
|
|
137
310
|
if (duoTargets.length > 0) {
|
|
138
311
|
const assetLibrary = await client.findAssetLibrary(appId);
|
|
139
312
|
const assetLibraryId = Runner.resourceId(assetLibrary, 'App asset library');
|
|
140
313
|
const placementGroup = await Runner.resolveDuoPlacementGroup(client);
|
|
141
|
-
await
|
|
314
|
+
await AppStoreConnect.runOperations(duoTargets, async (target) => {
|
|
142
315
|
const duoContext = await Runner.resolveCachedContext(contextCache, client, app, workspaceContext['version'], target['platform'], target['locale']);
|
|
143
316
|
const buffers = await Runner.readFiles(target);
|
|
144
|
-
const images = await
|
|
317
|
+
const images = await AppStoreConnect.runOperations(target['files'], (file, index) => client.uploadAssetLibraryImage(assetLibraryId, 'APP_SCREENSHOTS_AND_PREVIEWS', `${workspaceContext['workspace']['name']} ${target['platform']} ${target['locale']} iPhone Duo ${file['position']}`, file['fileName'], Runner.fileBuffer(buffers, index, file['fileName'])));
|
|
145
318
|
const imageIds = images.map((image) => Runner.resourceId(image, 'Uploaded iPhone Duo screenshot'));
|
|
146
319
|
await Runner.replacePlacement(client, duoContext, 'APP_SCREENSHOT', placementGroup, imageIds);
|
|
147
320
|
return;
|
|
148
|
-
})
|
|
321
|
+
});
|
|
149
322
|
}
|
|
150
323
|
Logger.info(`Updated ${targets.length} App Store Connect screenshot target(s).`);
|
|
151
324
|
return;
|
|
@@ -179,7 +352,7 @@ export class Runner {
|
|
|
179
352
|
const assetLibrary = await client.findAssetLibrary(appId);
|
|
180
353
|
const assetLibraryId = Runner.resourceId(assetLibrary, 'App asset library');
|
|
181
354
|
const contextCache = new Map();
|
|
182
|
-
await
|
|
355
|
+
await AppStoreConnect.runOperations(targets, async (target) => {
|
|
183
356
|
const context = await Runner.resolveCachedContext(contextCache, client, app, workspaceContext['version'], target['platform'], target['locale']);
|
|
184
357
|
const placementType = creativePlacementTypes.get(target['target']);
|
|
185
358
|
if (placementType === undefined) {
|
|
@@ -190,13 +363,110 @@ export class Runner {
|
|
|
190
363
|
throw new Error(`Creative asset target is empty: ${target['relativePath']}.`);
|
|
191
364
|
}
|
|
192
365
|
const buffers = await Runner.readFiles(target);
|
|
193
|
-
const image = await client.uploadAssetLibraryImage(assetLibraryId, 'CREATIVE_ASSETS', `${workspaceContext['workspace']['name']} ${target['locale']} ${target['target']}`, uploadedFile['fileName'], Runner.fileBuffer(buffers, 0, uploadedFile['fileName']));
|
|
366
|
+
const image = await client.uploadAssetLibraryImage(assetLibraryId, 'CREATIVE_ASSETS', `${workspaceContext['workspace']['name']} ${target['platform']} ${target['locale']} ${target['target']}`, uploadedFile['fileName'], Runner.fileBuffer(buffers, 0, uploadedFile['fileName']));
|
|
194
367
|
await Runner.replacePlacement(client, context, placementType, 'DEFAULT_PROFILE', [Runner.resourceId(image, 'Uploaded creative asset')]);
|
|
195
368
|
return;
|
|
196
|
-
})
|
|
369
|
+
});
|
|
197
370
|
Logger.info(`Updated ${targets.length} App Store Connect creative asset target(s).`);
|
|
198
371
|
return;
|
|
199
372
|
}
|
|
373
|
+
static async createPlacement(client, localizationId, placementType, placementGroup, imageId, attempt = 1) {
|
|
374
|
+
let response = undefined;
|
|
375
|
+
try {
|
|
376
|
+
response = await client.request('/v1/appAssetLibraryPlacements', {
|
|
377
|
+
body: {
|
|
378
|
+
data: {
|
|
379
|
+
attributes: {
|
|
380
|
+
placementGroup,
|
|
381
|
+
placementType,
|
|
382
|
+
},
|
|
383
|
+
relationships: {
|
|
384
|
+
appStoreVersionLocalization: {
|
|
385
|
+
data: {
|
|
386
|
+
id: localizationId,
|
|
387
|
+
type: 'appStoreVersionLocalizations',
|
|
388
|
+
},
|
|
389
|
+
},
|
|
390
|
+
image: {
|
|
391
|
+
data: {
|
|
392
|
+
id: imageId,
|
|
393
|
+
type: 'appAssetLibraryImages',
|
|
394
|
+
},
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
type: 'appAssetLibraryPlacements',
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
expectedStatuses: [201],
|
|
401
|
+
method: 'POST',
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
if (AppStoreConnect.isAmbiguousCreateError(error) === false) {
|
|
406
|
+
throw error;
|
|
407
|
+
}
|
|
408
|
+
const query = new URLSearchParams({
|
|
409
|
+
'fields[appAssetLibraryImages]': 'referenceName',
|
|
410
|
+
'fields[appAssetLibraryPlacements]': 'image,placementGroup,placementType',
|
|
411
|
+
'filter[placementGroup]': placementGroup,
|
|
412
|
+
'filter[placementType]': placementType,
|
|
413
|
+
'include': 'image',
|
|
414
|
+
'limit': '50',
|
|
415
|
+
});
|
|
416
|
+
const reconciliationResponse = await client.request(`/v1/appStoreVersionLocalizations/${localizationId}/placements?${query.toString()}`);
|
|
417
|
+
const placements = (reconciliationResponse === undefined) ? [] : requireArray(reconciliationResponse['data'], 'Reconciled asset placements').map((placement) => requireObject(placement, 'Reconciled asset placement'));
|
|
418
|
+
const matchingPlacement = placements.find((placement) => Runner.placementImageId(placement) === imageId);
|
|
419
|
+
if (matchingPlacement !== undefined) {
|
|
420
|
+
return Runner.resourceId(matchingPlacement, 'Reconciled asset placement');
|
|
421
|
+
}
|
|
422
|
+
if (attempt >= 5) {
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
425
|
+
const delayMilliseconds = Math.min(1000 * Math.pow(2, attempt - 1), 15 * 1000);
|
|
426
|
+
await wait(delayMilliseconds);
|
|
427
|
+
return Runner.createPlacement(client, localizationId, placementType, placementGroup, imageId, attempt + 1);
|
|
428
|
+
}
|
|
429
|
+
if (response === undefined) {
|
|
430
|
+
throw new Error('Creating an App Asset Library placement returned no resource.');
|
|
431
|
+
}
|
|
432
|
+
return Runner.resourceId(requireObject(response['data'], 'Created asset placement'), 'Created asset placement');
|
|
433
|
+
}
|
|
434
|
+
static async createPlacements(client, localizationId, placementType, placementGroup, imageIds) {
|
|
435
|
+
return AppStoreConnect.runOperations(imageIds, (imageId) => Runner.createPlacement(client, localizationId, placementType, placementGroup, imageId));
|
|
436
|
+
}
|
|
437
|
+
static async orderPlacements(client, localizationId, placementGroup, placementIds) {
|
|
438
|
+
if (placementIds.length <= 1) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
await client.request('/v1/appAssetLibraryPlacementOrderingRequests', {
|
|
442
|
+
body: {
|
|
443
|
+
data: {
|
|
444
|
+
attributes: {
|
|
445
|
+
placementGroup,
|
|
446
|
+
},
|
|
447
|
+
relationships: {
|
|
448
|
+
appStoreVersionLocalization: {
|
|
449
|
+
data: {
|
|
450
|
+
id: localizationId,
|
|
451
|
+
type: 'appStoreVersionLocalizations',
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
orderedPlacements: {
|
|
455
|
+
data: placementIds.map((placementId) => ({
|
|
456
|
+
id: placementId,
|
|
457
|
+
type: 'appAssetLibraryPlacements',
|
|
458
|
+
})),
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
type: 'appAssetLibraryPlacementOrderingRequests',
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
expectedStatuses: [201],
|
|
465
|
+
idempotent: true,
|
|
466
|
+
method: 'POST',
|
|
467
|
+
});
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
200
470
|
static async prepareWorkspace(options) {
|
|
201
471
|
const workspace = await resolveWorkspace(options, ['project.yml']);
|
|
202
472
|
let bundleIdentifier = options['bundleId'];
|
|
@@ -253,6 +523,201 @@ export class Runner {
|
|
|
253
523
|
}
|
|
254
524
|
return;
|
|
255
525
|
}
|
|
526
|
+
static async validateScreenshotImages(targets, skipImageChecks) {
|
|
527
|
+
const failures = [];
|
|
528
|
+
for (const target of targets) {
|
|
529
|
+
if (target['files'].length < 1 || target['files'].length > maximumScreenshotCount) {
|
|
530
|
+
failures.push(`${target['relativePath']}: ${target['files'].length} file(s); accepted 1-${maximumScreenshotCount} files per set.`);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
if (skipImageChecks === true) {
|
|
534
|
+
if (failures.length > 0) {
|
|
535
|
+
const capacityFailureLines = [
|
|
536
|
+
'Screenshot preflight failed:',
|
|
537
|
+
...failures.map((failure) => `- ${failure}`),
|
|
538
|
+
];
|
|
539
|
+
throw new Error(capacityFailureLines.join('\n'));
|
|
540
|
+
}
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
const fileEntries = targets.flatMap((target) => target['files'].map((file) => ({
|
|
544
|
+
file,
|
|
545
|
+
target,
|
|
546
|
+
})));
|
|
547
|
+
const fileResults = await Promise.allSettled(fileEntries.map((fileEntry) => fs.readFile(fileEntry['file']['filePath'])));
|
|
548
|
+
for (let fileIndex = 0; fileIndex < fileEntries.length; fileIndex += 1) {
|
|
549
|
+
const fileEntry = fileEntries[fileIndex];
|
|
550
|
+
const fileResult = fileResults[fileIndex];
|
|
551
|
+
if (fileEntry === undefined) {
|
|
552
|
+
failures.push(`Selected screenshot index ${fileIndex}: actual missing local file entry; accepted a readable opaque PNG or JPEG.`);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
const targetName = fileEntry['target']['target'];
|
|
556
|
+
const acceptedSizes = screenshotSizeSpecifications.get(targetName) ?? [];
|
|
557
|
+
const acceptedDescription = acceptedSizes.join(', ');
|
|
558
|
+
const displayPath = `${fileEntry['target']['relativePath']}/${fileEntry['file']['fileName']}`;
|
|
559
|
+
if (fileResult === undefined || fileResult.status === 'rejected') {
|
|
560
|
+
const readFailure = (fileResult === undefined) ? 'missing read result' : String(fileResult.reason);
|
|
561
|
+
failures.push(`${displayPath}: actual unreadable file (${readFailure}); accepted opaque PNG or JPEG at ${acceptedDescription}.`);
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
const buffer = fileResult.value;
|
|
565
|
+
let image = undefined;
|
|
566
|
+
try {
|
|
567
|
+
image = Runner.inspectScreenshotImage(buffer);
|
|
568
|
+
}
|
|
569
|
+
catch (error) {
|
|
570
|
+
failures.push(`${displayPath}: actual ${String(error)}; accepted opaque PNG or JPEG at ${acceptedDescription}.`);
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
const actualSize = `${image['width']}x${image['height']}`;
|
|
574
|
+
if (acceptedSizes.includes(actualSize) === false) {
|
|
575
|
+
failures.push(`${displayPath}: actual ${actualSize} ${image['format']}; accepted ${acceptedDescription}.`);
|
|
576
|
+
}
|
|
577
|
+
if (image['hasAlpha'] === true) {
|
|
578
|
+
failures.push(`${displayPath}: actual ${actualSize} PNG with alpha; accepted opaque PNG or JPEG at ${acceptedDescription}.`);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (failures.length > 0) {
|
|
582
|
+
const preflightFailureLines = [
|
|
583
|
+
'Screenshot preflight failed before any App Store Connect request:',
|
|
584
|
+
...failures.map((failure) => `- ${failure}`),
|
|
585
|
+
];
|
|
586
|
+
throw new Error(preflightFailureLines.join('\n'));
|
|
587
|
+
}
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
static inspectScreenshotImage(buffer) {
|
|
591
|
+
if (buffer.length >= pngSignature.length && buffer.subarray(0, pngSignature.length).equals(pngSignature) === true) {
|
|
592
|
+
return Runner.inspectScreenshotPng(buffer);
|
|
593
|
+
}
|
|
594
|
+
if (buffer.length >= 2
|
|
595
|
+
&& buffer[0] === parseInt('FF', 16)
|
|
596
|
+
&& buffer[1] === parseInt('D8', 16)) {
|
|
597
|
+
return Runner.inspectScreenshotJpeg(buffer);
|
|
598
|
+
}
|
|
599
|
+
throw new Error('unrecognized image header');
|
|
600
|
+
}
|
|
601
|
+
static inspectScreenshotJpeg(buffer) {
|
|
602
|
+
let offset = 2;
|
|
603
|
+
let width = undefined;
|
|
604
|
+
let height = undefined;
|
|
605
|
+
let hasEndOfImage = false;
|
|
606
|
+
while (offset < buffer.length) {
|
|
607
|
+
while (offset < buffer.length && buffer[offset] !== parseInt('FF', 16)) {
|
|
608
|
+
offset += 1;
|
|
609
|
+
}
|
|
610
|
+
while (offset < buffer.length && buffer[offset] === parseInt('FF', 16)) {
|
|
611
|
+
offset += 1;
|
|
612
|
+
}
|
|
613
|
+
if (offset >= buffer.length) {
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
const marker = buffer[offset];
|
|
617
|
+
offset += 1;
|
|
618
|
+
if (marker === undefined) {
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
if (marker === parseInt('00', 16)) {
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
if (marker === parseInt('D9', 16)) {
|
|
625
|
+
hasEndOfImage = true;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
if (marker === parseInt('01', 16)
|
|
629
|
+
|| marker === parseInt('D8', 16)
|
|
630
|
+
|| (marker >= parseInt('D0', 16)
|
|
631
|
+
&& marker <= parseInt('D7', 16))) {
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
634
|
+
if (offset + 2 > buffer.length) {
|
|
635
|
+
throw new Error('truncated JPEG segment length');
|
|
636
|
+
}
|
|
637
|
+
const segmentLength = buffer.readUInt16BE(offset);
|
|
638
|
+
if (segmentLength < 2 || offset + segmentLength > buffer.length) {
|
|
639
|
+
throw new Error('invalid JPEG segment length');
|
|
640
|
+
}
|
|
641
|
+
if (jpegStartOfFrameMarkers.has(marker) === true) {
|
|
642
|
+
if (segmentLength < 7) {
|
|
643
|
+
throw new Error('truncated JPEG start-of-frame segment');
|
|
644
|
+
}
|
|
645
|
+
height = buffer.readUInt16BE(offset + 3);
|
|
646
|
+
width = buffer.readUInt16BE(offset + 5);
|
|
647
|
+
}
|
|
648
|
+
offset += segmentLength;
|
|
649
|
+
}
|
|
650
|
+
if (width === undefined || height === undefined) {
|
|
651
|
+
throw new Error('JPEG has no supported start-of-frame segment');
|
|
652
|
+
}
|
|
653
|
+
if (hasEndOfImage === false) {
|
|
654
|
+
throw new Error('JPEG has no complete end-of-image marker');
|
|
655
|
+
}
|
|
656
|
+
return {
|
|
657
|
+
format: 'JPEG',
|
|
658
|
+
hasAlpha: false,
|
|
659
|
+
height,
|
|
660
|
+
width,
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
static inspectScreenshotPng(buffer) {
|
|
664
|
+
let offset = pngSignature.length;
|
|
665
|
+
let width = undefined;
|
|
666
|
+
let height = undefined;
|
|
667
|
+
let colorType = undefined;
|
|
668
|
+
let hasTransparencyChunk = false;
|
|
669
|
+
let hasEndChunk = false;
|
|
670
|
+
while (offset + 12 <= buffer.length) {
|
|
671
|
+
const chunkLength = buffer.readUInt32BE(offset);
|
|
672
|
+
const chunkType = buffer.subarray(offset + 4, offset + 8).toString('ascii');
|
|
673
|
+
const dataOffset = offset + 8;
|
|
674
|
+
const nextOffset = dataOffset + chunkLength + 4;
|
|
675
|
+
if (nextOffset > buffer.length) {
|
|
676
|
+
throw new Error(`truncated PNG ${chunkType || 'unknown'} chunk`);
|
|
677
|
+
}
|
|
678
|
+
if (offset === pngSignature.length && chunkType !== 'IHDR') {
|
|
679
|
+
throw new Error('PNG has no complete leading IHDR chunk');
|
|
680
|
+
}
|
|
681
|
+
if (chunkType === 'IHDR') {
|
|
682
|
+
if (offset !== pngSignature.length || chunkLength !== 13) {
|
|
683
|
+
throw new Error('invalid PNG IHDR length');
|
|
684
|
+
}
|
|
685
|
+
width = buffer.readUInt32BE(dataOffset);
|
|
686
|
+
height = buffer.readUInt32BE(dataOffset + 4);
|
|
687
|
+
colorType = buffer[dataOffset + 9];
|
|
688
|
+
}
|
|
689
|
+
if (chunkType === 'tRNS') {
|
|
690
|
+
hasTransparencyChunk = true;
|
|
691
|
+
}
|
|
692
|
+
offset = nextOffset;
|
|
693
|
+
if (chunkType === 'IEND') {
|
|
694
|
+
if (chunkLength !== 0) {
|
|
695
|
+
throw new Error('invalid PNG IEND length');
|
|
696
|
+
}
|
|
697
|
+
if (nextOffset !== buffer.length) {
|
|
698
|
+
throw new Error('PNG contains data after its IEND chunk');
|
|
699
|
+
}
|
|
700
|
+
hasEndChunk = true;
|
|
701
|
+
break;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
if (width === undefined
|
|
705
|
+
|| height === undefined
|
|
706
|
+
|| colorType === undefined) {
|
|
707
|
+
throw new Error('PNG has no complete IHDR chunk');
|
|
708
|
+
}
|
|
709
|
+
if (hasEndChunk === false) {
|
|
710
|
+
throw new Error('PNG has no complete IEND chunk');
|
|
711
|
+
}
|
|
712
|
+
return {
|
|
713
|
+
format: 'PNG',
|
|
714
|
+
hasAlpha: (colorType === 4
|
|
715
|
+
|| colorType === 6
|
|
716
|
+
|| hasTransparencyChunk === true),
|
|
717
|
+
height,
|
|
718
|
+
width,
|
|
719
|
+
};
|
|
720
|
+
}
|
|
256
721
|
static validateScreenshotTargets(targets) {
|
|
257
722
|
for (const target of targets) {
|
|
258
723
|
const isDuo = target['target'] === 'iphone-duo';
|
|
@@ -412,77 +877,233 @@ export class Runner {
|
|
|
412
877
|
}
|
|
413
878
|
throw new Error('Unable to read the iPhone Duo placement-group identifier from Apple reference data.');
|
|
414
879
|
}
|
|
880
|
+
static async replaceScreenshotBatch(client, setId, target, fileBuffers, pendingFileIndexes, desiredScreenshotIds, remainingOldScreenshotIds, freeSlots, windowSize = 1, oldScreenshotDeleteCount = 0, uploadedScreenshotCount = 0) {
|
|
881
|
+
let availableSlots = freeSlots;
|
|
882
|
+
let deletedOldScreenshotCount = oldScreenshotDeleteCount;
|
|
883
|
+
if (availableSlots === 0 && pendingFileIndexes.length > 0) {
|
|
884
|
+
const completeReplacementCount = uploadedScreenshotCount;
|
|
885
|
+
const permittedOldScreenshotDeleteCount = Math.max(0, completeReplacementCount + 1 - deletedOldScreenshotCount);
|
|
886
|
+
const oldScreenshotIdsForCapacity = [...remainingOldScreenshotIds].slice(0, Math.min(windowSize, pendingFileIndexes.length, permittedOldScreenshotDeleteCount));
|
|
887
|
+
if (oldScreenshotIdsForCapacity.length === 0) {
|
|
888
|
+
throw new Error(`Unable to free screenshot capacity for ${target['relativePath']} without exceeding the completed-replacement safety window.`);
|
|
889
|
+
}
|
|
890
|
+
await AppStoreConnect.runOperations(oldScreenshotIdsForCapacity, async (oldScreenshotId) => {
|
|
891
|
+
await client.deleteResource('appScreenshots', oldScreenshotId);
|
|
892
|
+
remainingOldScreenshotIds.delete(oldScreenshotId);
|
|
893
|
+
return;
|
|
894
|
+
});
|
|
895
|
+
availableSlots += oldScreenshotIdsForCapacity.length;
|
|
896
|
+
deletedOldScreenshotCount += oldScreenshotIdsForCapacity.length;
|
|
897
|
+
}
|
|
898
|
+
const batchFileIndexes = pendingFileIndexes.slice(0, Math.min(windowSize, availableSlots));
|
|
899
|
+
if (batchFileIndexes.length > 0) {
|
|
900
|
+
await AppStoreConnect.runOperations(batchFileIndexes, async (fileIndex) => {
|
|
901
|
+
const file = target['files'][fileIndex];
|
|
902
|
+
if (file === undefined) {
|
|
903
|
+
throw new Error(`Unable to find local screenshot index ${fileIndex} for ${target['relativePath']}.`);
|
|
904
|
+
}
|
|
905
|
+
const uploadedScreenshot = await client.uploadScreenshot(setId, file['fileName'], Runner.fileBuffer(fileBuffers, fileIndex, file['fileName']));
|
|
906
|
+
const uploadedScreenshotId = Runner.resourceId(uploadedScreenshot, 'Uploaded screenshot');
|
|
907
|
+
Reflect.set(desiredScreenshotIds, fileIndex, uploadedScreenshotId);
|
|
908
|
+
return;
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
const remainingPendingFileIndexes = pendingFileIndexes.slice(batchFileIndexes.length);
|
|
912
|
+
const completedUploadedScreenshotCount = uploadedScreenshotCount + batchFileIndexes.length;
|
|
913
|
+
if (remainingPendingFileIndexes.length === 0) {
|
|
914
|
+
const resourcesBeforeSweep = await client.listScreenshots(setId);
|
|
915
|
+
const incompleteScreenshotIds = resourcesBeforeSweep.filter((resource) => {
|
|
916
|
+
const attributes = requireObject(resource['attributes'], 'Screenshot attributes before final ordering');
|
|
917
|
+
const state = requireObject(attributes['assetDeliveryState'], 'Screenshot delivery state before final ordering');
|
|
918
|
+
return state['state'] !== 'COMPLETE';
|
|
919
|
+
}).map((resource) => Runner.resourceId(resource, 'Incomplete screenshot before final ordering'));
|
|
920
|
+
await AppStoreConnect.runOperations(incompleteScreenshotIds, (incompleteScreenshotId) => client.deleteResource('appScreenshots', incompleteScreenshotId));
|
|
921
|
+
const remainingResources = (incompleteScreenshotIds.length === 0) ? resourcesBeforeSweep : await client.listScreenshots(setId);
|
|
922
|
+
const desiredOrderedScreenshotIds = desiredScreenshotIds.map((desiredScreenshotId) => {
|
|
923
|
+
if (desiredScreenshotId === undefined) {
|
|
924
|
+
throw new Error(`Screenshot replacement for ${target['relativePath']} ended without every local screenshot.`);
|
|
925
|
+
}
|
|
926
|
+
return desiredScreenshotId;
|
|
927
|
+
});
|
|
928
|
+
const remainingScreenshotIds = remainingResources.map((remainingResource) => Runner.resourceId(remainingResource, 'Screenshot before final ordering'));
|
|
929
|
+
for (const desiredOrderedScreenshotId of desiredOrderedScreenshotIds) {
|
|
930
|
+
if (remainingScreenshotIds.includes(desiredOrderedScreenshotId) === false) {
|
|
931
|
+
throw new Error(`Screenshot replacement for ${target['relativePath']} is missing completed resource ${desiredOrderedScreenshotId}.`);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
const supersededScreenshotIds = remainingScreenshotIds.filter((remainingScreenshotId) => desiredOrderedScreenshotIds.includes(remainingScreenshotId) === false);
|
|
935
|
+
const orderedScreenshotIds = [
|
|
936
|
+
...desiredOrderedScreenshotIds,
|
|
937
|
+
...supersededScreenshotIds,
|
|
938
|
+
];
|
|
939
|
+
await client.reorderScreenshots(setId, orderedScreenshotIds);
|
|
940
|
+
await AppStoreConnect.runOperations(supersededScreenshotIds, async (oldScreenshotId) => {
|
|
941
|
+
await client.deleteResource('appScreenshots', oldScreenshotId);
|
|
942
|
+
remainingOldScreenshotIds.delete(oldScreenshotId);
|
|
943
|
+
return;
|
|
944
|
+
});
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
const nextFreeSlots = availableSlots - batchFileIndexes.length;
|
|
948
|
+
const nextWindowSize = (nextFreeSlots === 0) ? 1 : Math.min(windowSize * 2, maximumScreenshotCount);
|
|
949
|
+
await Runner.replaceScreenshotBatch(client, setId, target, fileBuffers, remainingPendingFileIndexes, desiredScreenshotIds, remainingOldScreenshotIds, nextFreeSlots, nextWindowSize, deletedOldScreenshotCount, completedUploadedScreenshotCount);
|
|
950
|
+
return;
|
|
951
|
+
}
|
|
952
|
+
static placementImageId(placement) {
|
|
953
|
+
const relationships = placement['relationships'];
|
|
954
|
+
if (typeof relationships === 'object'
|
|
955
|
+
&& relationships !== null
|
|
956
|
+
&& 'image' in relationships) {
|
|
957
|
+
const imageRelationship = relationships['image'];
|
|
958
|
+
if (typeof imageRelationship === 'object'
|
|
959
|
+
&& imageRelationship !== null
|
|
960
|
+
&& 'data' in imageRelationship) {
|
|
961
|
+
const imageData = imageRelationship['data'];
|
|
962
|
+
if (typeof imageData === 'object'
|
|
963
|
+
&& imageData !== null
|
|
964
|
+
&& 'id' in imageData
|
|
965
|
+
&& typeof imageData['id'] === 'string'
|
|
966
|
+
&& imageData['id'] !== '') {
|
|
967
|
+
return imageData['id'];
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
return undefined;
|
|
972
|
+
}
|
|
415
973
|
static async replacePlacement(client, context, placementType, placementGroup, imageIds) {
|
|
416
974
|
const localizationId = Runner.resourceId(context['localization'], 'App Store localization');
|
|
417
975
|
const query = new URLSearchParams({
|
|
976
|
+
'fields[appAssetLibraryImages]': 'referenceName',
|
|
977
|
+
'fields[appAssetLibraryPlacements]': 'image,placementGroup,placementType',
|
|
418
978
|
'filter[placementGroup]': placementGroup,
|
|
419
979
|
'filter[placementType]': placementType,
|
|
980
|
+
'include': 'image',
|
|
420
981
|
'limit': '50',
|
|
421
982
|
});
|
|
422
983
|
const response = await client.request(`/v1/appStoreVersionLocalizations/${localizationId}/placements?${query.toString()}`);
|
|
423
984
|
const existingPlacements = (response === undefined) ? [] : requireArray(response['data'], 'Existing asset placements').map((placement) => requireObject(placement, 'Asset placement'));
|
|
424
|
-
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
id: localizationId,
|
|
436
|
-
type: 'appStoreVersionLocalizations',
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
image: {
|
|
440
|
-
data: {
|
|
441
|
-
id: imageId,
|
|
442
|
-
type: 'appAssetLibraryImages',
|
|
443
|
-
},
|
|
444
|
-
},
|
|
445
|
-
},
|
|
446
|
-
type: 'appAssetLibraryPlacements',
|
|
447
|
-
},
|
|
448
|
-
},
|
|
449
|
-
expectedStatuses: [201],
|
|
450
|
-
method: 'POST',
|
|
451
|
-
})));
|
|
452
|
-
const placementIds = placementResponses.map((placementResponse) => {
|
|
453
|
-
if (placementResponse === undefined) {
|
|
454
|
-
throw new Error('Creating an App Asset Library placement returned no resource.');
|
|
985
|
+
const maximumPlacementCount = maximumPlacementCounts.get(placementType) ?? 1;
|
|
986
|
+
const availablePlacements = [...existingPlacements];
|
|
987
|
+
const desiredPlacementIds = imageIds.map(() => undefined);
|
|
988
|
+
const pendingImageIndexes = [];
|
|
989
|
+
if (existingPlacements.length > maximumPlacementCount) {
|
|
990
|
+
throw new Error(`${placementType}/${placementGroup} contains ${existingPlacements.length} placements, exceeding Apple's ${maximumPlacementCount}-placement limit.`);
|
|
991
|
+
}
|
|
992
|
+
for (let imageIndex = 0; imageIndex < imageIds.length; imageIndex += 1) {
|
|
993
|
+
const imageId = imageIds[imageIndex];
|
|
994
|
+
if (imageId === undefined) {
|
|
995
|
+
throw new Error(`Unable to resolve replacement image index ${imageIndex} for ${placementType}/${placementGroup}.`);
|
|
455
996
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
997
|
+
const matchingPlacementIndex = availablePlacements.findIndex((availablePlacement) => Runner.placementImageId(availablePlacement) === imageId);
|
|
998
|
+
if (matchingPlacementIndex === -1) {
|
|
999
|
+
pendingImageIndexes.push(imageIndex);
|
|
1000
|
+
continue;
|
|
1001
|
+
}
|
|
1002
|
+
const matchingPlacement = availablePlacements[matchingPlacementIndex];
|
|
1003
|
+
if (matchingPlacement === undefined) {
|
|
1004
|
+
throw new Error(`Unable to reuse replacement image index ${imageIndex} for ${placementType}/${placementGroup}.`);
|
|
1005
|
+
}
|
|
1006
|
+
const matchingPlacementId = Runner.resourceId(matchingPlacement, 'Matching asset placement');
|
|
1007
|
+
Reflect.set(desiredPlacementIds, imageIndex, matchingPlacementId);
|
|
1008
|
+
availablePlacements.splice(matchingPlacementIndex, 1);
|
|
1009
|
+
}
|
|
1010
|
+
const remainingOldPlacementIds = new Set(availablePlacements.map((availablePlacement) => Runner.resourceId(availablePlacement, 'Existing asset placement')));
|
|
1011
|
+
const freeSlots = maximumPlacementCount - existingPlacements.length;
|
|
1012
|
+
try {
|
|
1013
|
+
const initialDesiredPlacementCount = desiredPlacementIds.filter((desiredPlacementId) => desiredPlacementId !== undefined).length;
|
|
1014
|
+
if (maximumPlacementCount === 1
|
|
1015
|
+
&& pendingImageIndexes.length > freeSlots
|
|
1016
|
+
&& initialDesiredPlacementCount === 0) {
|
|
1017
|
+
Logger.warn(`Apple limits ${placementType}/${placementGroup} to one placement, so the old and replacement placements cannot coexist. The old placement will be removed only after the replacement asset finishes processing.`);
|
|
1018
|
+
}
|
|
1019
|
+
await Runner.replacePlacementBatch(client, localizationId, placementType, placementGroup, imageIds, pendingImageIndexes, desiredPlacementIds, remainingOldPlacementIds, freeSlots);
|
|
1020
|
+
}
|
|
1021
|
+
catch (error) {
|
|
1022
|
+
const failureResponse = await client.request(`/v1/appStoreVersionLocalizations/${localizationId}/placements?${query.toString()}`);
|
|
1023
|
+
const failurePlacements = (failureResponse === undefined) ? [] : requireArray(failureResponse['data'], 'Asset placements after failure').map((placement) => requireObject(placement, 'Asset placement after failure'));
|
|
1024
|
+
const failureNewPlacementCount = failurePlacements.filter((placement) => {
|
|
1025
|
+
const placementImageId = Runner.placementImageId(placement);
|
|
1026
|
+
return placementImageId !== undefined && imageIds.includes(placementImageId);
|
|
1027
|
+
}).length;
|
|
1028
|
+
const failureOldPlacementCount = failurePlacements.length - failureNewPlacementCount;
|
|
1029
|
+
throw new Error(`Replacing ${placementType}/${placementGroup} stopped after an App Store Connect failure. ${failureOldPlacementCount} old placement(s) and ${failureNewPlacementCount} new placement(s) remain; processed assets stay reusable in the App Asset Library.`, { cause: error });
|
|
1030
|
+
}
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
static async replacePlacementBatch(client, localizationId, placementType, placementGroup, imageIds, pendingImageIndexes, desiredPlacementIds, remainingOldPlacementIds, freeSlots, windowSize = 1, oldPlacementDeleteCount = 0, createdPlacementCount = 0) {
|
|
1034
|
+
let availableSlots = freeSlots;
|
|
1035
|
+
let deletedOldPlacementCount = oldPlacementDeleteCount;
|
|
1036
|
+
if (availableSlots === 0 && pendingImageIndexes.length > 0) {
|
|
1037
|
+
const completeReplacementCount = createdPlacementCount;
|
|
1038
|
+
const permittedOldPlacementDeleteCount = Math.max(0, completeReplacementCount + 1 - deletedOldPlacementCount);
|
|
1039
|
+
const oldPlacementIdsToDelete = [...remainingOldPlacementIds].slice(0, Math.min(windowSize, pendingImageIndexes.length, permittedOldPlacementDeleteCount));
|
|
1040
|
+
if (oldPlacementIdsToDelete.length === 0) {
|
|
1041
|
+
throw new Error(`Unable to free placement capacity for ${placementType}/${placementGroup} without exceeding the completed-replacement safety window.`);
|
|
1042
|
+
}
|
|
1043
|
+
await AppStoreConnect.runOperations(oldPlacementIdsToDelete, async (oldPlacementId) => {
|
|
1044
|
+
await client.deleteResource('appAssetLibraryPlacements', oldPlacementId);
|
|
1045
|
+
remainingOldPlacementIds.delete(oldPlacementId);
|
|
1046
|
+
return;
|
|
1047
|
+
});
|
|
1048
|
+
availableSlots += oldPlacementIdsToDelete.length;
|
|
1049
|
+
deletedOldPlacementCount += oldPlacementIdsToDelete.length;
|
|
1050
|
+
}
|
|
1051
|
+
const batchImageIndexes = pendingImageIndexes.slice(0, Math.min(windowSize, availableSlots));
|
|
1052
|
+
if (batchImageIndexes.length > 0) {
|
|
1053
|
+
await AppStoreConnect.runOperations(batchImageIndexes, async (imageIndex) => {
|
|
1054
|
+
const imageId = imageIds[imageIndex];
|
|
1055
|
+
if (imageId === undefined) {
|
|
1056
|
+
throw new Error(`Unable to find replacement image index ${imageIndex} for ${placementType}/${placementGroup}.`);
|
|
1057
|
+
}
|
|
1058
|
+
const createdPlacementIds = await Runner.createPlacements(client, localizationId, placementType, placementGroup, [imageId]);
|
|
1059
|
+
const createdPlacementId = createdPlacementIds[0];
|
|
1060
|
+
if (createdPlacementId === undefined) {
|
|
1061
|
+
throw new Error(`Creating replacement image index ${imageIndex} returned no placement.`);
|
|
1062
|
+
}
|
|
1063
|
+
Reflect.set(desiredPlacementIds, imageIndex, createdPlacementId);
|
|
1064
|
+
return;
|
|
484
1065
|
});
|
|
485
1066
|
}
|
|
1067
|
+
const remainingPendingImageIndexes = pendingImageIndexes.slice(batchImageIndexes.length);
|
|
1068
|
+
const nextCreatedPlacementCount = createdPlacementCount + batchImageIndexes.length;
|
|
1069
|
+
if (remainingPendingImageIndexes.length === 0) {
|
|
1070
|
+
const desiredOrderedPlacementIds = desiredPlacementIds.map((desiredPlacementId) => {
|
|
1071
|
+
if (desiredPlacementId === undefined) {
|
|
1072
|
+
throw new Error(`Placement replacement for ${placementType}/${placementGroup} ended without every replacement image.`);
|
|
1073
|
+
}
|
|
1074
|
+
return desiredPlacementId;
|
|
1075
|
+
});
|
|
1076
|
+
const freshQuery = new URLSearchParams({
|
|
1077
|
+
'fields[appAssetLibraryPlacements]': 'image,placementGroup,placementType',
|
|
1078
|
+
'filter[placementGroup]': placementGroup,
|
|
1079
|
+
'filter[placementType]': placementType,
|
|
1080
|
+
'limit': '50',
|
|
1081
|
+
});
|
|
1082
|
+
const freshResponse = await client.request(`/v1/appStoreVersionLocalizations/${localizationId}/placements?${freshQuery.toString()}`);
|
|
1083
|
+
const freshPlacements = (freshResponse === undefined) ? [] : requireArray(freshResponse['data'], 'Placements before final ordering').map((placement) => requireObject(placement, 'Placement before final ordering'));
|
|
1084
|
+
const freshPlacementIds = freshPlacements.map((placement) => Runner.resourceId(placement, 'Placement before final ordering'));
|
|
1085
|
+
for (const desiredOrderedPlacementId of desiredOrderedPlacementIds) {
|
|
1086
|
+
if (freshPlacementIds.includes(desiredOrderedPlacementId) === false) {
|
|
1087
|
+
throw new Error(`Placement replacement for ${placementType}/${placementGroup} is missing completed resource ${desiredOrderedPlacementId}.`);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
const supersededPlacementIds = freshPlacementIds.filter((freshPlacementId) => desiredOrderedPlacementIds.includes(freshPlacementId) === false);
|
|
1091
|
+
const orderedPlacementIds = [
|
|
1092
|
+
...desiredOrderedPlacementIds,
|
|
1093
|
+
...supersededPlacementIds,
|
|
1094
|
+
];
|
|
1095
|
+
await Runner.orderPlacements(client, localizationId, placementGroup, orderedPlacementIds);
|
|
1096
|
+
const remainingOldPlacementIdsToDelete = supersededPlacementIds;
|
|
1097
|
+
await AppStoreConnect.runOperations(remainingOldPlacementIdsToDelete, async (oldPlacementId) => {
|
|
1098
|
+
await client.deleteResource('appAssetLibraryPlacements', oldPlacementId);
|
|
1099
|
+
remainingOldPlacementIds.delete(oldPlacementId);
|
|
1100
|
+
return;
|
|
1101
|
+
});
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
const nextFreeSlots = availableSlots - batchImageIndexes.length;
|
|
1105
|
+
const nextWindowSize = (nextFreeSlots === 0) ? 1 : Math.min(windowSize * 2, maximumPlacementCounts.get(placementType) ?? 1);
|
|
1106
|
+
await Runner.replacePlacementBatch(client, localizationId, placementType, placementGroup, imageIds, remainingPendingImageIndexes, desiredPlacementIds, remainingOldPlacementIds, nextFreeSlots, nextWindowSize, deletedOldPlacementCount, nextCreatedPlacementCount);
|
|
486
1107
|
return;
|
|
487
1108
|
}
|
|
488
1109
|
static resourceId(resource, name) {
|