AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PlanSchema.php 6.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. namespace App\StorePlan;
  3. /**
  4. * The single definition of what a "store plan" may contain.
  5. *
  6. * A store plan is the saved design of a store: a theme plus an ordered list of sections.
  7. * It belongs to us, not to any AI provider. Whoever writes a plan (a person, Claude,
  8. * DeepSeek, anything later) must produce this shape, and PlanValidator checks it.
  9. *
  10. * Keep this file in step with resources/js/storefront/types.ts.
  11. */
  12. final class PlanSchema
  13. {
  14. public const int VERSION = 1;
  15. /**
  16. * Theme colours every plan must define, as 6-digit hex values.
  17. *
  18. * @var list<string>
  19. */
  20. public const array COLORS = [
  21. 'background',
  22. 'surface',
  23. 'foreground',
  24. 'muted',
  25. 'primary',
  26. 'primaryForeground',
  27. 'accent',
  28. 'border',
  29. ];
  30. /**
  31. * Fonts the storefront can load. Key is what the plan stores, value is the font family name.
  32. *
  33. * @var array<string, string>
  34. */
  35. public const array FONTS = [
  36. 'inter' => 'Inter',
  37. 'dm-sans' => 'DM Sans',
  38. 'poppins' => 'Poppins',
  39. 'manrope' => 'Manrope',
  40. 'space-grotesk' => 'Space Grotesk',
  41. 'playfair-display' => 'Playfair Display',
  42. 'lora' => 'Lora',
  43. 'fraunces' => 'Fraunces',
  44. ];
  45. /**
  46. * How rounded corners are.
  47. *
  48. * @var list<string>
  49. */
  50. public const array RADII = ['none', 'small', 'medium', 'large', 'full'];
  51. /**
  52. * Section types and the layout variants each one supports.
  53. *
  54. * @var array<string, list<string>>
  55. */
  56. public const array SECTIONS = [
  57. 'header' => ['simple', 'centered'],
  58. 'hero' => ['centered', 'split'],
  59. 'product_grid' => ['grid', 'minimal'],
  60. 'featured_product' => ['image-left', 'image-right'],
  61. 'about' => ['simple', 'with-stats'],
  62. 'testimonials' => ['cards', 'single'],
  63. 'faq' => ['list', 'two-column'],
  64. 'newsletter' => ['banner', 'card'],
  65. 'contact' => ['simple', 'card'],
  66. 'footer' => ['simple', 'centered'],
  67. ];
  68. public const int MAX_SECTIONS = 20;
  69. /**
  70. * Links may only point inside the page, inside the site, or to safe outside targets.
  71. * This blocks things like "javascript:" links.
  72. */
  73. public const string LINK_PATTERN = '/^(#[A-Za-z0-9_-]*|\/(?!\/)[^\s]*|https:\/\/[^\s]+|mailto:[^\s]+|tel:[0-9+\-\s]+)$/';
  74. public const string COLOR_PATTERN = '/^#[0-9A-Fa-f]{6}$/';
  75. public const string SECTION_ID_PATTERN = '/^[a-z][a-z0-9-]{0,39}$/';
  76. /**
  77. * Validation rules for the content of one section type.
  78. * Keys are relative to the section's "content" object.
  79. *
  80. * @return array<string, list<string>>
  81. */
  82. public static function contentRules(string $type): array
  83. {
  84. $text = fn (int $max) => ['required', 'string', 'max:'.$max];
  85. $optionalText = fn (int $max) => ['nullable', 'string', 'max:'.$max];
  86. $link = ['required', 'string', 'max:300', 'regex:'.self::LINK_PATTERN];
  87. $price = ['required', 'numeric', 'min:0', 'max:999999'];
  88. return match ($type) {
  89. 'header' => [
  90. 'logoText' => $text(40),
  91. 'links' => ['present', 'array', 'max:6'],
  92. 'links.*.label' => $text(30),
  93. 'links.*.href' => $link,
  94. 'cta' => ['nullable', 'array'],
  95. 'cta.label' => ['required_with:cta', 'string', 'max:30'],
  96. 'cta.href' => ['required_with:cta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN],
  97. ],
  98. 'hero' => [
  99. 'eyebrow' => $optionalText(60),
  100. 'headline' => $text(120),
  101. 'subheadline' => $text(300),
  102. 'primaryCta' => ['required', 'array'],
  103. 'primaryCta.label' => $text(30),
  104. 'primaryCta.href' => $link,
  105. 'secondaryCta' => ['nullable', 'array'],
  106. 'secondaryCta.label' => ['required_with:secondaryCta', 'string', 'max:30'],
  107. 'secondaryCta.href' => ['required_with:secondaryCta', 'string', 'max:300', 'regex:'.self::LINK_PATTERN],
  108. ],
  109. 'product_grid' => [
  110. 'heading' => $text(80),
  111. 'subheading' => $optionalText(200),
  112. 'items' => ['required', 'array', 'min:2', 'max:8'],
  113. 'items.*.name' => $text(80),
  114. 'items.*.price' => $price,
  115. 'items.*.badge' => $optionalText(20),
  116. ],
  117. 'featured_product' => [
  118. 'eyebrow' => $optionalText(60),
  119. 'name' => $text(80),
  120. 'description' => $text(500),
  121. 'price' => $price,
  122. 'bullets' => ['present', 'array', 'max:5'],
  123. 'bullets.*' => $text(100),
  124. 'cta' => ['required', 'array'],
  125. 'cta.label' => $text(30),
  126. 'cta.href' => $link,
  127. ],
  128. 'about' => [
  129. 'heading' => $text(80),
  130. 'body' => $text(1200),
  131. 'stats' => ['present', 'array', 'max:4'],
  132. 'stats.*.value' => $text(12),
  133. 'stats.*.label' => $text(40),
  134. ],
  135. 'testimonials' => [
  136. 'heading' => $text(80),
  137. 'items' => ['required', 'array', 'min:1', 'max:6'],
  138. 'items.*.quote' => $text(400),
  139. 'items.*.name' => $text(60),
  140. 'items.*.role' => $optionalText(60),
  141. ],
  142. 'faq' => [
  143. 'heading' => $text(80),
  144. 'items' => ['required', 'array', 'min:1', 'max:10'],
  145. 'items.*.question' => $text(160),
  146. 'items.*.answer' => $text(600),
  147. ],
  148. 'newsletter' => [
  149. 'heading' => $text(80),
  150. 'body' => $optionalText(240),
  151. 'placeholder' => $text(40),
  152. 'buttonLabel' => $text(30),
  153. ],
  154. 'contact' => [
  155. 'heading' => $text(80),
  156. 'body' => $optionalText(300),
  157. 'email' => ['nullable', 'email', 'max:120'],
  158. 'phone' => $optionalText(30),
  159. 'whatsapp' => ['nullable', 'string', 'regex:/^[0-9]{8,15}$/'],
  160. 'address' => $optionalText(200),
  161. ],
  162. 'footer' => [
  163. 'text' => $text(160),
  164. 'links' => ['present', 'array', 'max:8'],
  165. 'links.*.label' => $text(30),
  166. 'links.*.href' => $link,
  167. ],
  168. default => [],
  169. };
  170. }
  171. }