@designcrowd/library.brand-page 5.17.6 → 5.17.7
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/lib/src/{CreatedOnBrandCrowd-de-de-BI2KuOEF.js → CreatedOnBrandCrowd-de-de-BUQFMhZb.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-en-us-BYLJCjLJ.js → CreatedOnBrandCrowd-en-us-QS-5r4XI.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-es-es-Y_D6cuGE.js → CreatedOnBrandCrowd-es-es-CP2iH-n0.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-fr-CqCBRjYh.js → CreatedOnBrandCrowd-fr-ca-qfD4NmQZ.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-fr-ca-CqCBRjYh.js → CreatedOnBrandCrowd-fr-fr-qfD4NmQZ.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-pt-Bt0YF6DA.js → CreatedOnBrandCrowd-pt-br-CfmaB7zE.js} +1 -1
- package/lib/src/{CreatedOnBrandCrowd-pt-br-Bt0YF6DA.js → CreatedOnBrandCrowd-pt-pt-CfmaB7zE.js} +1 -1
- package/lib/src/{CreatedOnDcom-de-de-CEk8FBEG.js → CreatedOnDcom-de-de-BxSUWfGN.js} +1 -1
- package/lib/src/{CreatedOnDcom-en-us-DWw4Tm2L.js → CreatedOnDcom-en-us-CSeUdR6v.js} +1 -1
- package/lib/src/{CreatedOnDcom-es-es-DpG-8o98.js → CreatedOnDcom-es-es-g7rCfAtP.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-ca-CEla7RmR.js → CreatedOnDcom-fr-ca-Bh_BTb-O.js} +1 -1
- package/lib/src/{CreatedOnDcom-fr-fr-DRXeVTlV.js → CreatedOnDcom-fr-fr-Clgd_Ujm.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-br-Bzu_phZc.js → CreatedOnDcom-pt-br-Dlgk0myX.js} +1 -1
- package/lib/src/{CreatedOnDcom-pt-pt-DWax8Er7.js → CreatedOnDcom-pt-pt-B14APfrn.js} +1 -1
- package/lib/src/brand-page/models/brand-page-context.model.d.ts +2 -1
- package/lib/src/brand-page/models/brand-page-context.model.js +5 -0
- package/lib/src/brand-page/models/index.d.ts +1 -0
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.d.ts +62 -2
- package/lib/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.js +1 -0
- package/lib/src/brand-page-maker/components/brandpage-maker-page/BrandPageMakerPage.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/preview/Preview.mixin.d.ts +30 -1
- package/lib/src/brand-page-maker/components/quick-link-bar/QuickLinkBar.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/SeoPageSettings.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/UrlSettings.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/seo-settings/UseExistingDomainModal.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/template-preview/TemplatePreview.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/components/upgrade-to-premium-button/UpgradeToPremiumButton.mixin.d.ts +60 -2
- package/lib/src/brand-page-maker/composables/ai-chat/useAiChat.js +3 -1
- package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.d.ts +1 -1
- package/lib/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.js +6 -6
- package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.d.ts +2 -0
- package/lib/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.js +258 -0
- package/lib/src/brand-page-maker/constants/sidebar-constant.d.ts +1 -0
- package/lib/src/brand-page-maker/constants/sidebar-constant.js +8 -0
- package/lib/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.d.ts +16 -0
- package/lib/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.js +14 -0
- package/lib/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.d.ts +62 -3
- package/lib/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.js +2 -0
- package/lib/src/brand-page-maker/stores/index.d.ts +1 -0
- package/lib/src/brand-page-maker/stores/index.js +1 -0
- package/lib/src/brand-page-maker/stores/snapshot/snapshot-store.d.ts +2 -0
- package/lib/src/brand-page-maker/stores/snapshot/snapshot-store.js +9 -0
- package/lib/src/clients/ai-assistant-client.d.ts +8 -0
- package/lib/src/clients/ai-assistant-client.js +11 -1
- package/lib/src/composables/useSnapshot.js +33 -0
- package/lib/src/css/library.brand-page-brandCrowd.min.css +19 -6
- package/lib/src/css/library.brand-page-brandPage.min.css +19 -6
- package/lib/src/css/library.brand-page-designCom.min.css +19 -6
- package/lib/src/css/library.brand-page-preview.min.css +19 -6
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.mjs +42 -41
- package/lib/src/{lib-DODSa6QK.js → lib-pOkCQP0J.js} +28820 -26841
- package/lib/src/lib.js +1 -0
- package/lib/src/metadata-builder/ai-metadata-executor.d.ts +1 -1
- package/lib/src/metadata-builder/ai-metadata-executor.js +68 -7
- package/lib/src/metadata-builder/builders/add-page-builder.d.ts +14 -0
- package/lib/src/metadata-builder/builders/add-page-builder.js +66 -0
- package/lib/src/metadata-builder/builders/remove-page-builder.d.ts +13 -0
- package/lib/src/metadata-builder/builders/remove-page-builder.js +50 -0
- package/lib/src/metadata-builder/builders/section-builders/about-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/about-section-builder.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/banner-section-builder.js +25 -0
- package/lib/src/metadata-builder/builders/section-builders/base-section-builder.d.ts +40 -0
- package/lib/src/metadata-builder/builders/section-builders/base-section-builder.js +108 -0
- package/lib/src/metadata-builder/builders/section-builders/button-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/button-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/contact-form-builder.js +27 -0
- package/lib/src/metadata-builder/builders/section-builders/delete-section-builder.d.ts +13 -0
- package/lib/src/metadata-builder/builders/section-builders/delete-section-builder.js +37 -0
- package/lib/src/metadata-builder/builders/section-builders/divider-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/divider-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/image-gallery-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/image-gallery-builder.js +76 -0
- package/lib/src/metadata-builder/builders/section-builders/image-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/image-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/images-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/images-section-builder.js +158 -0
- package/lib/src/metadata-builder/builders/section-builders/index.d.ts +17 -0
- package/lib/src/metadata-builder/builders/section-builders/index.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-builder.js +17 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/mailing-list-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/move-section-builder.d.ts +15 -0
- package/lib/src/metadata-builder/builders/section-builders/move-section-builder.js +62 -0
- package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/profile-section-builder.js +16 -0
- package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/shapes-section-builder.js +162 -0
- package/lib/src/metadata-builder/builders/section-builders/social-links-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/social-links-builder.js +50 -0
- package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/testimonial-section-builder.js +133 -0
- package/lib/src/metadata-builder/builders/section-builders/text-section-builder.d.ts +6 -0
- package/lib/src/metadata-builder/builders/section-builders/text-section-builder.js +154 -0
- package/lib/src/metadata-builder/builders/section-content-factory.d.ts +3 -0
- package/lib/src/metadata-builder/builders/section-content-factory.js +13 -0
- package/lib/src/metadata-builder/builders/section-field-maps.d.ts +12 -0
- package/lib/src/metadata-builder/builders/section-field-maps.js +180 -0
- package/lib/src/metadata-builder/builders/section-field-utils.d.ts +11 -0
- package/lib/src/metadata-builder/builders/section-field-utils.js +109 -0
- package/lib/src/metadata-builder/helpers/rte.helpers.d.ts +6 -0
- package/lib/src/metadata-builder/helpers/rte.helpers.js +16 -1
- package/lib/src/metadata-builder/metadata-executor.js +71 -1
- package/lib/src/metadata-builder/models.d.ts +54 -0
- package/lib/src/metadata-builder/models.js +58 -0
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.d.ts +51 -3
- package/lib/src/metadata-builder/parsers/ai-toolcall-parser.js +110 -13
- package/lib/src/metadata-builder/parsers/section-tool-arguments.d.ts +285 -0
- package/lib/src/metadata-builder/parsers/section-tool-arguments.js +7 -0
- package/lib/src/shared/content-settings/components/payment-config-field/PaymentConfigField.mixin.d.ts +60 -2
- package/lib/src/shared/logo-settings/components/LogoSettings.mixin.d.ts +60 -2
- package/lib/src/shared/page-settings/components/page-settings/PageSettings.mixin.d.ts +60 -2
- package/lib/src/shared/page-settings/components/page-settings-section-styles/PageSettingsSectionStyles.mixin.d.ts +60 -2
- package/lib/src/shared/publish-brand-page-with-state/PublishBrandPageModalWithState.mixin.d.ts +90 -3
- package/lib/src/shared/side-bar/components/SideBar.mixin.d.ts +61 -2
- package/lib/src/shared/side-bar/components/SideBar.mixin.js +6 -0
- package/lib/src/shared/style-settings/components/StyleSettings.mixin.d.ts +60 -2
- package/lib/src/utils/minify-brand-page-metadata.d.ts +22 -0
- package/lib/src/utils/minify-brand-page-metadata.js +344 -0
- package/package.json +1 -1
- package/src/brand-page/models/brand-page-context.model.ts +12 -3
- package/src/brand-page/models/index.ts +1 -0
- package/src/brand-page-maker/components/ai-website-builder/AiWebsiteBuilder.vue +80 -0
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.mixin.ts +4 -0
- package/src/brand-page-maker/components/brand-page-maker/BrandPageMaker.vue +9 -2
- package/src/brand-page-maker/composables/ai-chat/useAiChat.ts +4 -1
- package/src/brand-page-maker/composables/ai-chat/useAiMetadataBuilder.ts +6 -6
- package/src/brand-page-maker/composables/ai-chat/useAiWebsiteBuilderChat.ts +363 -0
- package/src/brand-page-maker/constants/sidebar-constant.ts +8 -0
- package/src/brand-page-maker/stores/ai-thread/ai-website-builder-thread-store.ts +19 -0
- package/src/brand-page-maker/stores/brandpage-container/brand-page-container-store.ts +3 -1
- package/src/brand-page-maker/stores/brandpage-maker/brandpage-maker-store.ts +4 -0
- package/src/brand-page-maker/stores/index.ts +1 -0
- package/src/brand-page-maker/stores/snapshot/snapshot-store.ts +12 -0
- package/src/clients/ai-assistant-client.ts +17 -1
- package/src/composables/useSnapshot.ts +47 -0
- package/src/lib.ts +4 -0
- package/src/metadata-builder/ai-metadata-executor.ts +116 -26
- package/src/metadata-builder/builders/add-page-builder.ts +98 -0
- package/src/metadata-builder/builders/remove-page-builder.ts +83 -0
- package/src/metadata-builder/builders/section-builders/about-section-builder.ts +28 -0
- package/src/metadata-builder/builders/section-builders/banner-section-builder.ts +45 -0
- package/src/metadata-builder/builders/section-builders/base-section-builder.ts +160 -0
- package/src/metadata-builder/builders/section-builders/button-section-builder.ts +24 -0
- package/src/metadata-builder/builders/section-builders/contact-form-builder.ts +43 -0
- package/src/metadata-builder/builders/section-builders/delete-section-builder.ts +63 -0
- package/src/metadata-builder/builders/section-builders/divider-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/image-gallery-builder.ts +111 -0
- package/src/metadata-builder/builders/section-builders/image-section-builder.ts +24 -0
- package/src/metadata-builder/builders/section-builders/images-section-builder.ts +223 -0
- package/src/metadata-builder/builders/section-builders/index.ts +21 -0
- package/src/metadata-builder/builders/section-builders/mailing-list-builder.ts +29 -0
- package/src/metadata-builder/builders/section-builders/mailing-list-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/move-section-builder.ts +100 -0
- package/src/metadata-builder/builders/section-builders/profile-section-builder.ts +27 -0
- package/src/metadata-builder/builders/section-builders/shapes-section-builder.ts +231 -0
- package/src/metadata-builder/builders/section-builders/social-links-builder.ts +79 -0
- package/src/metadata-builder/builders/section-builders/testimonial-section-builder.ts +194 -0
- package/src/metadata-builder/builders/section-builders/text-section-builder.ts +234 -0
- package/src/metadata-builder/builders/section-content-factory.ts +20 -0
- package/src/metadata-builder/builders/section-field-maps.ts +235 -0
- package/src/metadata-builder/builders/section-field-utils.ts +157 -0
- package/src/metadata-builder/helpers/rte.helpers.ts +23 -1
- package/src/metadata-builder/metadata-executor.ts +96 -4
- package/src/metadata-builder/models.ts +62 -0
- package/src/metadata-builder/parsers/ai-toolcall-parser.ts +141 -17
- package/src/metadata-builder/parsers/section-tool-arguments.ts +417 -0
- package/src/shared/side-bar/components/SideBar.mixin.ts +10 -0
- package/src/utils/minify-brand-page-metadata.ts +407 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { RTE_ALLOWED_SECTION_TYPES } from '../../brand-page-maker/utils';
|
|
2
|
+
import { updateRTEText } from '../helpers/rte.helpers';
|
|
3
|
+
import { getSectionFieldMap, getStyleFieldMap } from './section-field-maps';
|
|
4
|
+
const isUrlField = (aiKey) => aiKey.endsWith('_url');
|
|
5
|
+
const isValidUrl = (value) => {
|
|
6
|
+
if (typeof value !== 'string' || !value)
|
|
7
|
+
return false;
|
|
8
|
+
try {
|
|
9
|
+
new URL(value);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const applyScalarFields = (content, args, sectionType) => {
|
|
17
|
+
const fieldMap = getSectionFieldMap(sectionType);
|
|
18
|
+
if (!fieldMap)
|
|
19
|
+
return;
|
|
20
|
+
const record = content;
|
|
21
|
+
for (const [aiKey, modelKey] of Object.entries(fieldMap)) {
|
|
22
|
+
if (aiKey in args) {
|
|
23
|
+
// Skip invalid URLs — don't overwrite model with malformed values
|
|
24
|
+
if (isUrlField(aiKey) && !isValidUrl(args[aiKey]))
|
|
25
|
+
continue;
|
|
26
|
+
record[modelKey] = args[aiKey];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Convert AI-sent style value to the format expected by the model.
|
|
32
|
+
* - letterSpacing: unitless 0-100 → em string (e.g., 50 → '0.5em')
|
|
33
|
+
* - null → '' (explicitly clear/reset the property)
|
|
34
|
+
* - everything else passes through as-is
|
|
35
|
+
*/
|
|
36
|
+
const normalizeStyleValue = (key, value) => {
|
|
37
|
+
if (value === null)
|
|
38
|
+
return '';
|
|
39
|
+
if (value === undefined)
|
|
40
|
+
return undefined;
|
|
41
|
+
if (key === 'letterSpacing' && typeof value === 'number') {
|
|
42
|
+
return `${value / 100}em`;
|
|
43
|
+
}
|
|
44
|
+
if (key === 'lineHeight' && typeof value === 'number') {
|
|
45
|
+
return String(value);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
};
|
|
49
|
+
export const applyStyleFields = (content, args, sectionType) => {
|
|
50
|
+
const styleMap = getStyleFieldMap(sectionType);
|
|
51
|
+
if (!styleMap)
|
|
52
|
+
return;
|
|
53
|
+
const record = content;
|
|
54
|
+
for (const [aiKey, modelKey] of Object.entries(styleMap)) {
|
|
55
|
+
if (aiKey in args && args[aiKey] && typeof args[aiKey] === 'object') {
|
|
56
|
+
const existing = content[modelKey] || {};
|
|
57
|
+
const aiStyle = args[aiKey];
|
|
58
|
+
const filtered = {};
|
|
59
|
+
for (const [k, v] of Object.entries(aiStyle)) {
|
|
60
|
+
const normalized = normalizeStyleValue(k, v);
|
|
61
|
+
if (normalized !== undefined)
|
|
62
|
+
filtered[k] = normalized;
|
|
63
|
+
}
|
|
64
|
+
record[modelKey] = {
|
|
65
|
+
...existing,
|
|
66
|
+
...filtered,
|
|
67
|
+
textStyleType: undefined,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* RTE field → style field pairs for fields that support rich text editing.
|
|
74
|
+
* Matches the RTE_ALLOWED_FIELDS constant from rich-text-editor.util.ts:
|
|
75
|
+
* ['title', 'description', 'text', 'textItems']
|
|
76
|
+
*
|
|
77
|
+
* textItems is excluded here because it requires per-item handling
|
|
78
|
+
* (each TextItem has its own textStyle) — handled by TextSectionBuilder.
|
|
79
|
+
*/
|
|
80
|
+
const RTE_FIELD_STYLE_PAIRS = [
|
|
81
|
+
{ textField: 'title', styleField: 'titleStyle', argKey: 'title_style' },
|
|
82
|
+
{
|
|
83
|
+
textField: 'description',
|
|
84
|
+
styleField: 'descriptionStyle',
|
|
85
|
+
argKey: 'description_style',
|
|
86
|
+
},
|
|
87
|
+
{ textField: 'text', styleField: 'textStyle', argKey: 'text_style' },
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* Re-applies merged styles to RTE content fields after applyStyleFields has
|
|
91
|
+
* updated the style objects. Only runs for section types that support RTE
|
|
92
|
+
* (defined by RTE_ALLOWED_SECTION_TYPES) and only touches fields in the
|
|
93
|
+
* RTE_ALLOWED_FIELDS list.
|
|
94
|
+
*/
|
|
95
|
+
export const applyRTEStyles = (content, args, sectionType) => {
|
|
96
|
+
if (!RTE_ALLOWED_SECTION_TYPES.includes(sectionType))
|
|
97
|
+
return;
|
|
98
|
+
const record = content;
|
|
99
|
+
const argsRecord = args;
|
|
100
|
+
for (const { textField, styleField, argKey } of RTE_FIELD_STYLE_PAIRS) {
|
|
101
|
+
if (!argsRecord[argKey])
|
|
102
|
+
continue;
|
|
103
|
+
const text = record[textField];
|
|
104
|
+
const style = record[styleField];
|
|
105
|
+
if (typeof text === 'string' && style) {
|
|
106
|
+
record[textField] = updateRTEText(text, style);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { TextStyleDeclaration } from '../../brand-page';
|
|
2
2
|
import type { Editor } from '@tiptap/vue-3';
|
|
3
3
|
export declare const applyStyleToRTEText: (externalEditor: Editor, contentText: string, newContentStyle: TextStyleDeclaration) => string;
|
|
4
|
+
/**
|
|
5
|
+
* If `text` contains RTE markup, re-applies `style` to the RTE content
|
|
6
|
+
* so inline formatting matches the updated TextStyleDeclaration.
|
|
7
|
+
* Returns the original text unchanged when it has no RTE content.
|
|
8
|
+
*/
|
|
9
|
+
export declare const updateRTEText: (text: string, style: TextStyleDeclaration) => string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getRTEColor } from '../../brand-page-maker/utils';
|
|
1
|
+
import { getRTEColor, hasRTEContent } from '../../brand-page-maker/utils';
|
|
2
|
+
import { useExternalRichTextEditor } from '../../brand-page-maker/composables/rich-text-editor/useRichTextEditor';
|
|
2
3
|
import { getRenderText } from '../../brand-page/utils';
|
|
3
4
|
import { ESCAPED_NEWLINE_CHARACTER } from '../../constants/ui';
|
|
4
5
|
export const applyStyleToRTEText = (externalEditor, contentText, newContentStyle) => {
|
|
@@ -51,3 +52,17 @@ export const applyStyleToRTEText = (externalEditor, contentText, newContentStyle
|
|
|
51
52
|
const html = externalEditor.getHTML();
|
|
52
53
|
return html;
|
|
53
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* If `text` contains RTE markup, re-applies `style` to the RTE content
|
|
57
|
+
* so inline formatting matches the updated TextStyleDeclaration.
|
|
58
|
+
* Returns the original text unchanged when it has no RTE content.
|
|
59
|
+
*/
|
|
60
|
+
export const updateRTEText = (text, style) => {
|
|
61
|
+
if (!text || typeof text !== 'string' || !hasRTEContent(text)) {
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
const { externalEditor } = useExternalRichTextEditor();
|
|
65
|
+
const updatedText = applyStyleToRTEText(externalEditor, text, style);
|
|
66
|
+
externalEditor.destroy();
|
|
67
|
+
return updatedText;
|
|
68
|
+
};
|
|
@@ -3,10 +3,71 @@ import {} from '../brand-page/models';
|
|
|
3
3
|
import { BUILDER_TYPES, } from './models';
|
|
4
4
|
import { UpdateContentTextBuilder } from './builders/update-content-text-builder';
|
|
5
5
|
import { UpdateContentTextStyleBuilder } from './builders/update-content-text-style-builder';
|
|
6
|
+
import { BannerSectionBuilder, AboutSectionBuilder, ContactFormBuilder, DividerSectionBuilder, TextSectionBuilder, TestimonialSectionBuilder, ImagesSectionBuilder, ShapesSectionBuilder, SocialLinksBuilder, ImageGalleryBuilder, ProfileSectionBuilder, MailingListSectionBuilder, ImageSectionBuilder, ButtonSectionBuilder, DeleteSectionBuilder, MoveSectionBuilder, } from './builders/section-builders';
|
|
7
|
+
import { AddPageBuilder } from './builders/add-page-builder';
|
|
8
|
+
import { RemovePageBuilder } from './builders/remove-page-builder';
|
|
6
9
|
// Lazy initialization to avoid circular dependency issues
|
|
7
10
|
const getBuilderRegistry = () => ({
|
|
8
11
|
[BUILDER_TYPES.UPDATE_CONTENT_TEXT]: UpdateContentTextBuilder,
|
|
9
12
|
[BUILDER_TYPES.UPDATE_CONTENT_TEXT_STYLE]: UpdateContentTextStyleBuilder,
|
|
13
|
+
// Section builders (create)
|
|
14
|
+
[BUILDER_TYPES.CREATE_BANNER_SECTION]: BannerSectionBuilder,
|
|
15
|
+
[BUILDER_TYPES.CREATE_ABOUT_SECTION]: AboutSectionBuilder,
|
|
16
|
+
[BUILDER_TYPES.CREATE_CONTACT_FORM]: ContactFormBuilder,
|
|
17
|
+
[BUILDER_TYPES.CREATE_DIVIDER_SECTION]: DividerSectionBuilder,
|
|
18
|
+
[BUILDER_TYPES.CREATE_TEXT]: TextSectionBuilder,
|
|
19
|
+
[BUILDER_TYPES.CREATE_TESTIMONIAL_SECTION]: TestimonialSectionBuilder,
|
|
20
|
+
[BUILDER_TYPES.CREATE_IMAGES_SECTION]: ImagesSectionBuilder,
|
|
21
|
+
[BUILDER_TYPES.CREATE_SHAPES_SECTION]: ShapesSectionBuilder,
|
|
22
|
+
[BUILDER_TYPES.CREATE_SOCIAL_LINKS]: SocialLinksBuilder,
|
|
23
|
+
[BUILDER_TYPES.CREATE_IMAGE_GALLERY]: ImageGalleryBuilder,
|
|
24
|
+
[BUILDER_TYPES.CREATE_PROFILE]: ProfileSectionBuilder,
|
|
25
|
+
[BUILDER_TYPES.CREATE_MAILING_LIST]: MailingListSectionBuilder,
|
|
26
|
+
[BUILDER_TYPES.CREATE_IMAGE]: ImageSectionBuilder,
|
|
27
|
+
[BUILDER_TYPES.CREATE_GENERAL_LINK]: ButtonSectionBuilder,
|
|
28
|
+
[BUILDER_TYPES.CREATE_WEBSITE]: ButtonSectionBuilder,
|
|
29
|
+
[BUILDER_TYPES.CREATE_EMAIL]: ButtonSectionBuilder,
|
|
30
|
+
[BUILDER_TYPES.CREATE_PHONE]: ButtonSectionBuilder,
|
|
31
|
+
[BUILDER_TYPES.CREATE_FACEBOOK]: ButtonSectionBuilder,
|
|
32
|
+
[BUILDER_TYPES.CREATE_X]: ButtonSectionBuilder,
|
|
33
|
+
[BUILDER_TYPES.CREATE_INSTAGRAM]: ButtonSectionBuilder,
|
|
34
|
+
[BUILDER_TYPES.CREATE_YOUTUBE]: ButtonSectionBuilder,
|
|
35
|
+
[BUILDER_TYPES.CREATE_LINKEDIN]: ButtonSectionBuilder,
|
|
36
|
+
[BUILDER_TYPES.CREATE_PINTEREST]: ButtonSectionBuilder,
|
|
37
|
+
[BUILDER_TYPES.CREATE_TWITCH]: ButtonSectionBuilder,
|
|
38
|
+
[BUILDER_TYPES.CREATE_TIKTOK]: ButtonSectionBuilder,
|
|
39
|
+
// Section builders (update)
|
|
40
|
+
[BUILDER_TYPES.UPDATE_BANNER_SECTION]: BannerSectionBuilder,
|
|
41
|
+
[BUILDER_TYPES.UPDATE_ABOUT_SECTION]: AboutSectionBuilder,
|
|
42
|
+
[BUILDER_TYPES.UPDATE_CONTACT_FORM]: ContactFormBuilder,
|
|
43
|
+
[BUILDER_TYPES.UPDATE_DIVIDER_SECTION]: DividerSectionBuilder,
|
|
44
|
+
[BUILDER_TYPES.UPDATE_TEXT]: TextSectionBuilder,
|
|
45
|
+
[BUILDER_TYPES.UPDATE_TESTIMONIAL_SECTION]: TestimonialSectionBuilder,
|
|
46
|
+
[BUILDER_TYPES.UPDATE_IMAGES_SECTION]: ImagesSectionBuilder,
|
|
47
|
+
[BUILDER_TYPES.UPDATE_SHAPES_SECTION]: ShapesSectionBuilder,
|
|
48
|
+
[BUILDER_TYPES.UPDATE_SOCIAL_LINKS]: SocialLinksBuilder,
|
|
49
|
+
[BUILDER_TYPES.UPDATE_IMAGE_GALLERY]: ImageGalleryBuilder,
|
|
50
|
+
[BUILDER_TYPES.UPDATE_PROFILE]: ProfileSectionBuilder,
|
|
51
|
+
[BUILDER_TYPES.UPDATE_MAILING_LIST]: MailingListSectionBuilder,
|
|
52
|
+
[BUILDER_TYPES.UPDATE_IMAGE]: ImageSectionBuilder,
|
|
53
|
+
[BUILDER_TYPES.UPDATE_GENERAL_LINK]: ButtonSectionBuilder,
|
|
54
|
+
[BUILDER_TYPES.UPDATE_WEBSITE]: ButtonSectionBuilder,
|
|
55
|
+
[BUILDER_TYPES.UPDATE_EMAIL]: ButtonSectionBuilder,
|
|
56
|
+
[BUILDER_TYPES.UPDATE_PHONE]: ButtonSectionBuilder,
|
|
57
|
+
[BUILDER_TYPES.UPDATE_FACEBOOK]: ButtonSectionBuilder,
|
|
58
|
+
[BUILDER_TYPES.UPDATE_X]: ButtonSectionBuilder,
|
|
59
|
+
[BUILDER_TYPES.UPDATE_INSTAGRAM]: ButtonSectionBuilder,
|
|
60
|
+
[BUILDER_TYPES.UPDATE_YOUTUBE]: ButtonSectionBuilder,
|
|
61
|
+
[BUILDER_TYPES.UPDATE_LINKEDIN]: ButtonSectionBuilder,
|
|
62
|
+
[BUILDER_TYPES.UPDATE_PINTEREST]: ButtonSectionBuilder,
|
|
63
|
+
[BUILDER_TYPES.UPDATE_TWITCH]: ButtonSectionBuilder,
|
|
64
|
+
[BUILDER_TYPES.UPDATE_TIKTOK]: ButtonSectionBuilder,
|
|
65
|
+
// Section-level operations
|
|
66
|
+
[BUILDER_TYPES.DELETE_SECTION]: DeleteSectionBuilder,
|
|
67
|
+
[BUILDER_TYPES.MOVE_SECTION]: MoveSectionBuilder,
|
|
68
|
+
// Page-level operations
|
|
69
|
+
[BUILDER_TYPES.ADD_PAGE]: AddPageBuilder,
|
|
70
|
+
[BUILDER_TYPES.REMOVE_PAGE]: RemovePageBuilder,
|
|
10
71
|
});
|
|
11
72
|
let builderRegistry = null;
|
|
12
73
|
const resolveBuilder = (request, logger) => {
|
|
@@ -15,7 +76,8 @@ const resolveBuilder = (request, logger) => {
|
|
|
15
76
|
}
|
|
16
77
|
const BuilderClass = builderRegistry[request.type];
|
|
17
78
|
if (!BuilderClass) {
|
|
18
|
-
|
|
79
|
+
console.error(`No builder registered for request type: "${request.type}"`);
|
|
80
|
+
return null;
|
|
19
81
|
}
|
|
20
82
|
return new BuilderClass(request, logger);
|
|
21
83
|
};
|
|
@@ -25,6 +87,14 @@ export class MetadataExecutor {
|
|
|
25
87
|
const results = [];
|
|
26
88
|
for (const request of requests) {
|
|
27
89
|
const builder = resolveBuilder(request, logger);
|
|
90
|
+
if (!builder) {
|
|
91
|
+
results.push({
|
|
92
|
+
request,
|
|
93
|
+
model,
|
|
94
|
+
errors: [`No builder found for request type: "${request.type}"`],
|
|
95
|
+
});
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
28
98
|
const result = await builder.buildAsync(model);
|
|
29
99
|
results.push(result);
|
|
30
100
|
model = result.model;
|
|
@@ -3,6 +3,60 @@ import type { Logger } from './logger';
|
|
|
3
3
|
export declare const BUILDER_TYPES: {
|
|
4
4
|
readonly UPDATE_CONTENT_TEXT: "update-content-text";
|
|
5
5
|
readonly UPDATE_CONTENT_TEXT_STYLE: "update-content-text-style";
|
|
6
|
+
readonly CREATE_BANNER_SECTION: "create-banner-section";
|
|
7
|
+
readonly CREATE_ABOUT_SECTION: "create-about-section";
|
|
8
|
+
readonly CREATE_CONTACT_FORM: "create-contact-form";
|
|
9
|
+
readonly CREATE_DIVIDER_SECTION: "create-divider-section";
|
|
10
|
+
readonly CREATE_TEXT: "create-text";
|
|
11
|
+
readonly CREATE_TESTIMONIAL_SECTION: "create-testimonial-section";
|
|
12
|
+
readonly CREATE_IMAGES_SECTION: "create-images-section";
|
|
13
|
+
readonly CREATE_SHAPES_SECTION: "create-shapes-section";
|
|
14
|
+
readonly CREATE_SOCIAL_LINKS: "create-social-links";
|
|
15
|
+
readonly CREATE_IMAGE_GALLERY: "create-image-gallery";
|
|
16
|
+
readonly CREATE_PROFILE: "create-profile";
|
|
17
|
+
readonly CREATE_MAILING_LIST: "create-mailing-list";
|
|
18
|
+
readonly CREATE_IMAGE: "create-image";
|
|
19
|
+
readonly CREATE_GENERAL_LINK: "create-general-link";
|
|
20
|
+
readonly CREATE_WEBSITE: "create-website";
|
|
21
|
+
readonly CREATE_EMAIL: "create-email";
|
|
22
|
+
readonly CREATE_PHONE: "create-phone";
|
|
23
|
+
readonly CREATE_FACEBOOK: "create-facebook";
|
|
24
|
+
readonly CREATE_X: "create-x";
|
|
25
|
+
readonly CREATE_INSTAGRAM: "create-instagram";
|
|
26
|
+
readonly CREATE_YOUTUBE: "create-youtube";
|
|
27
|
+
readonly CREATE_LINKEDIN: "create-linkedin";
|
|
28
|
+
readonly CREATE_PINTEREST: "create-pinterest";
|
|
29
|
+
readonly CREATE_TWITCH: "create-twitch";
|
|
30
|
+
readonly CREATE_TIKTOK: "create-tiktok";
|
|
31
|
+
readonly UPDATE_BANNER_SECTION: "update-banner-section";
|
|
32
|
+
readonly UPDATE_ABOUT_SECTION: "update-about-section";
|
|
33
|
+
readonly UPDATE_CONTACT_FORM: "update-contact-form";
|
|
34
|
+
readonly UPDATE_DIVIDER_SECTION: "update-divider-section";
|
|
35
|
+
readonly UPDATE_TEXT: "update-text";
|
|
36
|
+
readonly UPDATE_TESTIMONIAL_SECTION: "update-testimonial-section";
|
|
37
|
+
readonly UPDATE_IMAGES_SECTION: "update-images-section";
|
|
38
|
+
readonly UPDATE_SHAPES_SECTION: "update-shapes-section";
|
|
39
|
+
readonly UPDATE_SOCIAL_LINKS: "update-social-links";
|
|
40
|
+
readonly UPDATE_IMAGE_GALLERY: "update-image-gallery";
|
|
41
|
+
readonly UPDATE_PROFILE: "update-profile";
|
|
42
|
+
readonly UPDATE_MAILING_LIST: "update-mailing-list";
|
|
43
|
+
readonly UPDATE_IMAGE: "update-image";
|
|
44
|
+
readonly UPDATE_GENERAL_LINK: "update-general-link";
|
|
45
|
+
readonly UPDATE_WEBSITE: "update-website";
|
|
46
|
+
readonly UPDATE_EMAIL: "update-email";
|
|
47
|
+
readonly UPDATE_PHONE: "update-phone";
|
|
48
|
+
readonly UPDATE_FACEBOOK: "update-facebook";
|
|
49
|
+
readonly UPDATE_X: "update-x";
|
|
50
|
+
readonly UPDATE_INSTAGRAM: "update-instagram";
|
|
51
|
+
readonly UPDATE_YOUTUBE: "update-youtube";
|
|
52
|
+
readonly UPDATE_LINKEDIN: "update-linkedin";
|
|
53
|
+
readonly UPDATE_PINTEREST: "update-pinterest";
|
|
54
|
+
readonly UPDATE_TWITCH: "update-twitch";
|
|
55
|
+
readonly UPDATE_TIKTOK: "update-tiktok";
|
|
56
|
+
readonly DELETE_SECTION: "delete-section";
|
|
57
|
+
readonly MOVE_SECTION: "move-section";
|
|
58
|
+
readonly ADD_PAGE: "add-page";
|
|
59
|
+
readonly REMOVE_PAGE: "remove-page";
|
|
6
60
|
};
|
|
7
61
|
export type BuilderType = (typeof BUILDER_TYPES)[keyof typeof BUILDER_TYPES];
|
|
8
62
|
export interface MetadataBuilderRequest<T = unknown> {
|
|
@@ -2,6 +2,64 @@ import {} from '../brand-page/models';
|
|
|
2
2
|
export const BUILDER_TYPES = {
|
|
3
3
|
UPDATE_CONTENT_TEXT: 'update-content-text',
|
|
4
4
|
UPDATE_CONTENT_TEXT_STYLE: 'update-content-text-style',
|
|
5
|
+
// Per-section builder types (create)
|
|
6
|
+
CREATE_BANNER_SECTION: 'create-banner-section',
|
|
7
|
+
CREATE_ABOUT_SECTION: 'create-about-section',
|
|
8
|
+
CREATE_CONTACT_FORM: 'create-contact-form',
|
|
9
|
+
CREATE_DIVIDER_SECTION: 'create-divider-section',
|
|
10
|
+
CREATE_TEXT: 'create-text',
|
|
11
|
+
CREATE_TESTIMONIAL_SECTION: 'create-testimonial-section',
|
|
12
|
+
CREATE_IMAGES_SECTION: 'create-images-section',
|
|
13
|
+
CREATE_SHAPES_SECTION: 'create-shapes-section',
|
|
14
|
+
CREATE_SOCIAL_LINKS: 'create-social-links',
|
|
15
|
+
CREATE_IMAGE_GALLERY: 'create-image-gallery',
|
|
16
|
+
CREATE_PROFILE: 'create-profile',
|
|
17
|
+
CREATE_MAILING_LIST: 'create-mailing-list',
|
|
18
|
+
CREATE_IMAGE: 'create-image',
|
|
19
|
+
CREATE_GENERAL_LINK: 'create-general-link',
|
|
20
|
+
CREATE_WEBSITE: 'create-website',
|
|
21
|
+
CREATE_EMAIL: 'create-email',
|
|
22
|
+
CREATE_PHONE: 'create-phone',
|
|
23
|
+
CREATE_FACEBOOK: 'create-facebook',
|
|
24
|
+
CREATE_X: 'create-x',
|
|
25
|
+
CREATE_INSTAGRAM: 'create-instagram',
|
|
26
|
+
CREATE_YOUTUBE: 'create-youtube',
|
|
27
|
+
CREATE_LINKEDIN: 'create-linkedin',
|
|
28
|
+
CREATE_PINTEREST: 'create-pinterest',
|
|
29
|
+
CREATE_TWITCH: 'create-twitch',
|
|
30
|
+
CREATE_TIKTOK: 'create-tiktok',
|
|
31
|
+
// Per-section builder types (update)
|
|
32
|
+
UPDATE_BANNER_SECTION: 'update-banner-section',
|
|
33
|
+
UPDATE_ABOUT_SECTION: 'update-about-section',
|
|
34
|
+
UPDATE_CONTACT_FORM: 'update-contact-form',
|
|
35
|
+
UPDATE_DIVIDER_SECTION: 'update-divider-section',
|
|
36
|
+
UPDATE_TEXT: 'update-text',
|
|
37
|
+
UPDATE_TESTIMONIAL_SECTION: 'update-testimonial-section',
|
|
38
|
+
UPDATE_IMAGES_SECTION: 'update-images-section',
|
|
39
|
+
UPDATE_SHAPES_SECTION: 'update-shapes-section',
|
|
40
|
+
UPDATE_SOCIAL_LINKS: 'update-social-links',
|
|
41
|
+
UPDATE_IMAGE_GALLERY: 'update-image-gallery',
|
|
42
|
+
UPDATE_PROFILE: 'update-profile',
|
|
43
|
+
UPDATE_MAILING_LIST: 'update-mailing-list',
|
|
44
|
+
UPDATE_IMAGE: 'update-image',
|
|
45
|
+
UPDATE_GENERAL_LINK: 'update-general-link',
|
|
46
|
+
UPDATE_WEBSITE: 'update-website',
|
|
47
|
+
UPDATE_EMAIL: 'update-email',
|
|
48
|
+
UPDATE_PHONE: 'update-phone',
|
|
49
|
+
UPDATE_FACEBOOK: 'update-facebook',
|
|
50
|
+
UPDATE_X: 'update-x',
|
|
51
|
+
UPDATE_INSTAGRAM: 'update-instagram',
|
|
52
|
+
UPDATE_YOUTUBE: 'update-youtube',
|
|
53
|
+
UPDATE_LINKEDIN: 'update-linkedin',
|
|
54
|
+
UPDATE_PINTEREST: 'update-pinterest',
|
|
55
|
+
UPDATE_TWITCH: 'update-twitch',
|
|
56
|
+
UPDATE_TIKTOK: 'update-tiktok',
|
|
57
|
+
// Section-level operations
|
|
58
|
+
DELETE_SECTION: 'delete-section',
|
|
59
|
+
MOVE_SECTION: 'move-section',
|
|
60
|
+
// Page-level operations
|
|
61
|
+
ADD_PAGE: 'add-page',
|
|
62
|
+
REMOVE_PAGE: 'remove-page',
|
|
5
63
|
};
|
|
6
64
|
export class BaseMetadataBuilder {
|
|
7
65
|
request;
|
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
import type { AiAssistantToolCall } from '../../clients/ai-assistant-client';
|
|
2
|
+
import type { SectionType } from './section-tool-arguments';
|
|
2
3
|
export declare const AI_ASSISTANT_TOOL_NAMES: {
|
|
3
4
|
readonly UPDATE_TEXT: "updateText";
|
|
4
5
|
readonly UPDATE_STYLE: "updateStyle";
|
|
6
|
+
readonly BUILD_PROFILE_SECTION: "build_profile_section";
|
|
7
|
+
readonly BUILD_TEXT_SECTION: "build_text_section";
|
|
8
|
+
readonly BUILD_IMAGE_SECTION: "build_image_section";
|
|
9
|
+
readonly BUILD_IMAGE_GALLERY_SECTION: "build_image-gallery_section";
|
|
10
|
+
readonly BUILD_GENERAL_LINK_SECTION: "build_general-link_section";
|
|
11
|
+
readonly BUILD_WEBSITE_SECTION: "build_website_section";
|
|
12
|
+
readonly BUILD_EMAIL_SECTION: "build_email_section";
|
|
13
|
+
readonly BUILD_PHONE_SECTION: "build_phone_section";
|
|
14
|
+
readonly BUILD_FACEBOOK_SECTION: "build_facebook_section";
|
|
15
|
+
readonly BUILD_X_SECTION: "build_x_section";
|
|
16
|
+
readonly BUILD_INSTAGRAM_SECTION: "build_instagram_section";
|
|
17
|
+
readonly BUILD_YOUTUBE_SECTION: "build_youtube_section";
|
|
18
|
+
readonly BUILD_LINKEDIN_SECTION: "build_linkedin_section";
|
|
19
|
+
readonly BUILD_PINTEREST_SECTION: "build_pinterest_section";
|
|
20
|
+
readonly BUILD_TWITCH_SECTION: "build_twitch_section";
|
|
21
|
+
readonly BUILD_TIKTOK_SECTION: "build_tiktok_section";
|
|
22
|
+
readonly BUILD_SOCIAL_LINKS_SECTION: "build_social-links_section";
|
|
23
|
+
readonly BUILD_MAILING_LIST_SECTION: "build_mailing-list_section";
|
|
24
|
+
readonly BUILD_CONTACT_FORM_SECTION: "build_contact-form_section";
|
|
25
|
+
readonly BUILD_BANNER_SECTION: "build_banner_section";
|
|
26
|
+
readonly BUILD_ABOUT_SECTION: "build_about_section";
|
|
27
|
+
readonly BUILD_IMAGES_SECTION: "build_images_section";
|
|
28
|
+
readonly BUILD_SHAPES_SECTION: "build_shapes_section";
|
|
29
|
+
readonly BUILD_TESTIMONIAL_SECTION: "build_testimonial_section";
|
|
30
|
+
readonly BUILD_DIVIDER_SECTION: "build_divider_section";
|
|
31
|
+
readonly DELETE_SECTION: "delete_section";
|
|
32
|
+
readonly MOVE_SECTION: "move_section";
|
|
33
|
+
readonly ADD_PAGE: "add_page";
|
|
34
|
+
readonly REMOVE_PAGE: "remove_page";
|
|
5
35
|
};
|
|
6
36
|
export type AiAssistantToolName = (typeof AI_ASSISTANT_TOOL_NAMES)[keyof typeof AI_ASSISTANT_TOOL_NAMES];
|
|
7
37
|
export interface ParsedToolCall {
|
|
8
38
|
toolId: string;
|
|
9
|
-
function:
|
|
10
|
-
arguments:
|
|
39
|
+
function: string;
|
|
40
|
+
arguments: Record<string, unknown>;
|
|
11
41
|
usage_type?: 'free' | 'paid';
|
|
12
42
|
}
|
|
13
43
|
export interface BaseArguments {
|
|
@@ -27,4 +57,22 @@ export interface UpdateStyleToolArguments extends BaseArguments {
|
|
|
27
57
|
style: BrandPageCssStyle;
|
|
28
58
|
};
|
|
29
59
|
}
|
|
30
|
-
export declare const
|
|
60
|
+
export declare const SECTION_TOOL_MAP: Record<string, {
|
|
61
|
+
sectionType: SectionType;
|
|
62
|
+
}>;
|
|
63
|
+
export interface DeleteSectionArguments {
|
|
64
|
+
content_id: string;
|
|
65
|
+
}
|
|
66
|
+
export interface MoveSectionArguments {
|
|
67
|
+
content_id: string;
|
|
68
|
+
position: number;
|
|
69
|
+
target_page_id?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface AddPageArguments {
|
|
72
|
+
page_id: string;
|
|
73
|
+
page_name: string;
|
|
74
|
+
}
|
|
75
|
+
export interface RemovePageArguments {
|
|
76
|
+
page_id: string;
|
|
77
|
+
}
|
|
78
|
+
export declare const parseToolCalls: (toolCalls: AiAssistantToolCall[]) => ParsedToolCall[];
|
|
@@ -1,21 +1,118 @@
|
|
|
1
|
-
// Tool names
|
|
1
|
+
// Tool names — must match the function names generated by the AI pipeline.
|
|
2
|
+
// Text element tools use camelCase names.
|
|
3
|
+
// Section tools follow the pattern: build_{sectionType}_section
|
|
4
|
+
// where sectionType matches the ContentType value (e.g. 'banner-section', 'profile').
|
|
5
|
+
// The mode ('create' | 'update') is a field in the tool arguments, not the tool name.
|
|
2
6
|
export const AI_ASSISTANT_TOOL_NAMES = {
|
|
7
|
+
// Text element agent tools
|
|
3
8
|
UPDATE_TEXT: 'updateText',
|
|
4
9
|
UPDATE_STYLE: 'updateStyle',
|
|
10
|
+
// Website builder agent tools — unified build
|
|
11
|
+
BUILD_PROFILE_SECTION: 'build_profile_section',
|
|
12
|
+
BUILD_TEXT_SECTION: 'build_text_section',
|
|
13
|
+
BUILD_IMAGE_SECTION: 'build_image_section',
|
|
14
|
+
BUILD_IMAGE_GALLERY_SECTION: 'build_image-gallery_section',
|
|
15
|
+
BUILD_GENERAL_LINK_SECTION: 'build_general-link_section',
|
|
16
|
+
BUILD_WEBSITE_SECTION: 'build_website_section',
|
|
17
|
+
BUILD_EMAIL_SECTION: 'build_email_section',
|
|
18
|
+
BUILD_PHONE_SECTION: 'build_phone_section',
|
|
19
|
+
BUILD_FACEBOOK_SECTION: 'build_facebook_section',
|
|
20
|
+
BUILD_X_SECTION: 'build_x_section',
|
|
21
|
+
BUILD_INSTAGRAM_SECTION: 'build_instagram_section',
|
|
22
|
+
BUILD_YOUTUBE_SECTION: 'build_youtube_section',
|
|
23
|
+
BUILD_LINKEDIN_SECTION: 'build_linkedin_section',
|
|
24
|
+
BUILD_PINTEREST_SECTION: 'build_pinterest_section',
|
|
25
|
+
BUILD_TWITCH_SECTION: 'build_twitch_section',
|
|
26
|
+
BUILD_TIKTOK_SECTION: 'build_tiktok_section',
|
|
27
|
+
BUILD_SOCIAL_LINKS_SECTION: 'build_social-links_section',
|
|
28
|
+
BUILD_MAILING_LIST_SECTION: 'build_mailing-list_section',
|
|
29
|
+
BUILD_CONTACT_FORM_SECTION: 'build_contact-form_section',
|
|
30
|
+
BUILD_BANNER_SECTION: 'build_banner_section',
|
|
31
|
+
BUILD_ABOUT_SECTION: 'build_about_section',
|
|
32
|
+
BUILD_IMAGES_SECTION: 'build_images_section',
|
|
33
|
+
BUILD_SHAPES_SECTION: 'build_shapes_section',
|
|
34
|
+
BUILD_TESTIMONIAL_SECTION: 'build_testimonial_section',
|
|
35
|
+
BUILD_DIVIDER_SECTION: 'build_divider_section',
|
|
36
|
+
// Section-level operation tools
|
|
37
|
+
DELETE_SECTION: 'delete_section',
|
|
38
|
+
MOVE_SECTION: 'move_section',
|
|
39
|
+
// Page-level operation tools
|
|
40
|
+
ADD_PAGE: 'add_page',
|
|
41
|
+
REMOVE_PAGE: 'remove_page',
|
|
5
42
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
43
|
+
// Maps each section tool name to its SectionType.
|
|
44
|
+
// Mode is now determined from the tool arguments, not the tool name.
|
|
45
|
+
export const SECTION_TOOL_MAP = {
|
|
46
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_PROFILE_SECTION]: { sectionType: 'profile' },
|
|
47
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_TEXT_SECTION]: { sectionType: 'text' },
|
|
48
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_IMAGE_SECTION]: { sectionType: 'image' },
|
|
49
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_IMAGE_GALLERY_SECTION]: {
|
|
50
|
+
sectionType: 'image-gallery',
|
|
51
|
+
},
|
|
52
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_GENERAL_LINK_SECTION]: {
|
|
53
|
+
sectionType: 'general-link',
|
|
54
|
+
},
|
|
55
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_WEBSITE_SECTION]: { sectionType: 'website' },
|
|
56
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_EMAIL_SECTION]: { sectionType: 'email' },
|
|
57
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_PHONE_SECTION]: { sectionType: 'phone' },
|
|
58
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_FACEBOOK_SECTION]: { sectionType: 'facebook' },
|
|
59
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_X_SECTION]: { sectionType: 'x' },
|
|
60
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_INSTAGRAM_SECTION]: {
|
|
61
|
+
sectionType: 'instagram',
|
|
62
|
+
},
|
|
63
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_YOUTUBE_SECTION]: { sectionType: 'youtube' },
|
|
64
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_LINKEDIN_SECTION]: { sectionType: 'linkedin' },
|
|
65
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_PINTEREST_SECTION]: {
|
|
66
|
+
sectionType: 'pinterest',
|
|
67
|
+
},
|
|
68
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_TWITCH_SECTION]: { sectionType: 'twitch' },
|
|
69
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_TIKTOK_SECTION]: { sectionType: 'tiktok' },
|
|
70
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_SOCIAL_LINKS_SECTION]: {
|
|
71
|
+
sectionType: 'social-links',
|
|
72
|
+
},
|
|
73
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_MAILING_LIST_SECTION]: {
|
|
74
|
+
sectionType: 'mailing-list',
|
|
75
|
+
},
|
|
76
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_CONTACT_FORM_SECTION]: {
|
|
77
|
+
sectionType: 'contact-form',
|
|
78
|
+
},
|
|
79
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_BANNER_SECTION]: {
|
|
80
|
+
sectionType: 'banner-section',
|
|
81
|
+
},
|
|
82
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_ABOUT_SECTION]: {
|
|
83
|
+
sectionType: 'about-section',
|
|
84
|
+
},
|
|
85
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_IMAGES_SECTION]: {
|
|
86
|
+
sectionType: 'images-section',
|
|
87
|
+
},
|
|
88
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_SHAPES_SECTION]: {
|
|
89
|
+
sectionType: 'shapes-section',
|
|
90
|
+
},
|
|
91
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_TESTIMONIAL_SECTION]: {
|
|
92
|
+
sectionType: 'testimonial-section',
|
|
93
|
+
},
|
|
94
|
+
[AI_ASSISTANT_TOOL_NAMES.BUILD_DIVIDER_SECTION]: {
|
|
95
|
+
sectionType: 'divider-section',
|
|
96
|
+
},
|
|
13
97
|
};
|
|
14
|
-
export const
|
|
15
|
-
if (!
|
|
98
|
+
export const parseToolCalls = (toolCalls) => {
|
|
99
|
+
if (!toolCalls || toolCalls.length === 0) {
|
|
16
100
|
return [];
|
|
17
101
|
}
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
102
|
+
return toolCalls
|
|
103
|
+
.map((toolCall) => {
|
|
104
|
+
try {
|
|
105
|
+
return {
|
|
106
|
+
toolId: toolCall.toolId,
|
|
107
|
+
function: toolCall.function,
|
|
108
|
+
arguments: JSON.parse(toolCall.arguments),
|
|
109
|
+
usage_type: toolCall.usage_type,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
console.warn(`[parseToolCalls] Failed to parse arguments for ${toolCall.function} (${toolCall.toolId}):`, error);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
.filter((tc) => tc !== null);
|
|
21
118
|
};
|