403Webshell
Server IP : 66.29.153.156  /  Your IP : 216.73.217.22
Web Server : LiteSpeed
System : Linux premium322.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User : lastyfjz ( 1521)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/lastyfjz/././unicitys.com/wp-content/plugins/extendify/src/AutoLaunch/functions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/lastyfjz/././unicitys.com/wp-content/plugins/extendify/src/AutoLaunch/functions/patterns.js
import { AI_HOST } from '@constants';
import { reqDataBasics } from '@shared/lib/data';
import { retryTwice } from './helpers';

const generatePatterns = async (page, data) => {
	const { siteProfile } = data;
	return await retryTwice(async () => {
		const response = await fetch(`${AI_HOST}/api/patterns`, {
			method: 'POST',
			headers: { 'Content-Type': 'application/json' },
			body: JSON.stringify({ ...reqDataBasics, siteProfile, page }),
		});
		if (!response.ok) {
			throw new Error(
				`Pattern generation failed with status ${response.status}`,
			);
		}
		return await response.json();
	});
};

// Hold back patterns that already have finalized content (e.g. design build)
const splitGeneratedContent = (page) => {
	const generated = page.patterns?.filter((p) => p.contentGenerated) ?? [];
	const rest = page.patterns?.filter((p) => !p.contentGenerated) ?? [];
	return { generated, toGenerate: { ...page, patterns: rest } };
};

export const generatePageContent = async (pages, data) => {
	const splits = pages.map(splitGeneratedContent);

	const result = await Promise.allSettled(
		splits.map(
			({ toGenerate }) =>
				generatePatterns(toGenerate, data)
					.then((response) => response)
					.catch(() => toGenerate), // safe fallback
		),
	);

	return result?.map((pageResult, i) => {
		const original = pages[i];
		const { generated } = splits[i];
		const merged =
			pageResult.status === 'fulfilled' && pageResult.value
				? { ...original, ...pageResult.value }
				: original;
		return {
			...merged,
			patterns: [...generated, ...(merged.patterns ?? [])],
		};
	});
};

Youez - 2016 - github.com/yon3zu
LinuXploit