PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/AutoLaunch/functions/patterns.js +11 -7 3.0.5 → trunk View file →
@@ -2,14 +2,19 @@
2 2 import { reqDataBasics } from '@shared/lib/data';
3 3 import { retryTwice } from './helpers';
4 4
5 5 const generatePatterns = async (page, data) => {
6 - const { siteProfile } = data;
6 + const { siteProfile, designBuild } = data;
7 7 return await retryTwice(async () => {
8 8 const response = await fetch(`${AI_HOST}/api/patterns`, {
9 9 method: 'POST',
10 10 headers: { 'Content-Type': 'application/json' },
11 - body: JSON.stringify({ ...reqDataBasics, siteProfile, page }),
11 + body: JSON.stringify({
12 + ...reqDataBasics,
13 + siteProfile,
14 + page,
15 + buildId: designBuild?.buildId,
16 + }),
12 17 });
13 18 if (!response.ok) {
14 19 throw new Error(
15 20 `Pattern generation failed with status ${response.status}`,
@@ -29,13 +34,12 @@
29 34 export const generatePageContent = async (pages, data) => {
30 35 const splits = pages.map(splitGeneratedContent);
31 36
32 37 const result = await Promise.allSettled(
33 - splits.map(
34 - ({ toGenerate }) =>
35 - generatePatterns(toGenerate, data)
36 - .then((response) => response)
37 - .catch(() => toGenerate), // safe fallback
38 + splits.map(({ toGenerate }) =>
39 + toGenerate.patterns.length
40 + ? generatePatterns(toGenerate, data).catch(() => toGenerate)
41 + : Promise.resolve(toGenerate),
38 42 ),
39 43 );
40 44
41 45 return result?.map((pageResult, i) => {