@wix/ditto-codegen-public 1.0.49 → 1.0.50
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/dist/examples-apps/event-countdown/README.md +13 -0
- package/dist/examples-apps/event-countdown/astro.config.mjs +31 -0
- package/dist/examples-apps/event-countdown/package.json +51 -0
- package/dist/examples-apps/event-countdown/src/components/countdown-preview.tsx +164 -0
- package/dist/examples-apps/event-countdown/src/components/countdown-timer-settings.tsx +199 -0
- package/dist/examples-apps/event-countdown/src/dashboard/pages/countdown-timer-settings/extensions.ts +7 -0
- package/dist/examples-apps/event-countdown/src/dashboard/pages/countdown-timer-settings/page.tsx +142 -0
- package/dist/examples-apps/event-countdown/src/dashboard/withProviders.tsx +22 -0
- package/dist/examples-apps/event-countdown/src/extensions.ts +12 -0
- package/dist/examples-apps/event-countdown/src/index.ts +2 -0
- package/dist/examples-apps/event-countdown/src/site/embedded-scripts/countdown-timer/embedded.html +328 -0
- package/dist/examples-apps/event-countdown/src/site/embedded-scripts/countdown-timer/extensions.ts +8 -0
- package/dist/examples-apps/event-countdown/src/types.ts +11 -0
- package/dist/examples-apps/event-countdown/tsconfig.json +9 -0
- package/dist/examples-apps/event-countdown/wix.config.json +4 -0
- package/dist/examples-apps/site-popup/package.json +43 -26
- package/dist/examples-apps/site-popup/src/components/activation-configuration.tsx +1 -1
- package/dist/examples-apps/site-popup/src/components/close-button.css +33 -0
- package/dist/examples-apps/site-popup/src/components/close-button.tsx +4 -3
- package/dist/examples-apps/site-popup/src/components/popup/index.css +133 -3
- package/dist/examples-apps/site-popup/src/components/popup/index.tsx +10 -10
- package/dist/examples-apps/site-popup/src/components/site-popup-settings.tsx +4 -4
- package/dist/examples-apps/site-popup/src/dashboard/pages/page.tsx +2 -2
- package/dist/examples-apps/site-popup/src/dashboard/withProviders.tsx +4 -1
- package/dist/examples-apps/site-popup/src/extensions.ts +21 -0
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/embedded.html +1 -0
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.css +21 -3
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.tsx +8 -9
- package/dist/examples-apps/site-popup/src/types.ts +1 -1
- package/dist/out.js +1003 -63
- package/dist/wix-cli-templates/src/dashboard/pages/page.tsx +0 -4
- package/dist/wix-cli-templates/src/site/embedded-scripts/my-script/embedded.html +1 -2
- package/package.json +2 -2
- package/dist/examples-apps/mixpanel-analytics/src/dashboard/pages/page.json +0 -5
- package/dist/examples-apps/mixpanel-analytics/src/site/embedded-scripts/mixpanel-analytics/embedded.json +0 -7
- package/dist/examples-apps/site-popup/package-lock.json +0 -8033
- package/dist/examples-apps/site-popup/postcss.config.js +0 -7
- package/dist/examples-apps/site-popup/src/env.d.ts +0 -4
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/embedded.json +0 -7
- package/dist/examples-apps/site-popup/src/site/embedded-scripts/site-popup/params.dev.json +0 -7
- package/dist/examples-apps/site-popup/tailwind.config.js +0 -8
- package/dist/wix-cli-templates/src/dashboard/pages/wix_logo.svg +0 -18
- package/dist/wix-cli-templates/src/site/embedded-scripts/my-script/embedded.json +0 -7
- package/dist/wix-cli-templates/src/site/embedded-scripts/my-script/logger.ts +0 -1
- package/dist/wix-cli-templates/src/site/embedded-scripts/my-script/params.dev.json +0 -3
package/dist/out.js
CHANGED
|
@@ -120276,19 +120276,19 @@ var require_utils14 = __commonJS({
|
|
|
120276
120276
|
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
120277
120277
|
};
|
|
120278
120278
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120279
|
-
exports2.getErrorMessage = exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = void 0;
|
|
120279
|
+
exports2.getErrorMessage = exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = exports2.FileItemSchema = void 0;
|
|
120280
120280
|
exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
|
|
120281
120281
|
var zod_1 = require_zod();
|
|
120282
120282
|
var http_client_1 = require_index_node();
|
|
120283
120283
|
var fs_1 = __importDefault2(require("fs"));
|
|
120284
120284
|
var path_1 = __importDefault2(require("path"));
|
|
120285
|
-
|
|
120285
|
+
exports2.FileItemSchema = zod_1.z.object({
|
|
120286
120286
|
operation: zod_1.z.enum(["insert", "update", "delete"]).describe("File operation: insert (new file), update (modify existing), delete (remove file)").default("insert"),
|
|
120287
120287
|
path: zod_1.z.string().describe("Relative file path from project root").optional(),
|
|
120288
120288
|
content: zod_1.z.string().describe("Complete file content as a string (for JSON files, stringify the object). Required for insert and update operations.").optional()
|
|
120289
120289
|
});
|
|
120290
120290
|
exports2.FileSchema = zod_1.z.object({
|
|
120291
|
-
files: zod_1.z.array(FileItemSchema).default([])
|
|
120291
|
+
files: zod_1.z.array(exports2.FileItemSchema).default([])
|
|
120292
120292
|
});
|
|
120293
120293
|
var withCaching = (ttl = "5m") => {
|
|
120294
120294
|
return {
|
|
@@ -120384,6 +120384,11 @@ ${JSON.stringify(planAndResources.createdCollections, null, 2)}`);
|
|
|
120384
120384
|
contextSections.push(`
|
|
120385
120385
|
## API SPEC
|
|
120386
120386
|
${JSON.stringify(planAndResources.apiSpec, null, 2)}`);
|
|
120387
|
+
}
|
|
120388
|
+
if (planAndResources?.embeddedScriptParameters) {
|
|
120389
|
+
contextSections.push(`
|
|
120390
|
+
## EMBEDDED SCRIPT PARAMETERS
|
|
120391
|
+
${JSON.stringify(planAndResources.embeddedScriptParameters, null, 2)}`);
|
|
120387
120392
|
}
|
|
120388
120393
|
const userMessage = `${primaryAction}:
|
|
120389
120394
|
${contextSections.join("\n")}`;
|
|
@@ -120502,6 +120507,7 @@ var require_load_examples = __commonJS({
|
|
|
120502
120507
|
"site-popup/src/components/site-popup-settings.tsx",
|
|
120503
120508
|
"site-popup/src/components/activation-configuration.tsx",
|
|
120504
120509
|
"site-popup/src/components/close-button.tsx",
|
|
120510
|
+
"site-popup/src/components/close-button.css",
|
|
120505
120511
|
"site-popup/src/components/date-range-picker.tsx",
|
|
120506
120512
|
"site-popup/src/components/image-picker.tsx",
|
|
120507
120513
|
"site-popup/src/components/popup/index.tsx",
|
|
@@ -120512,7 +120518,11 @@ var require_load_examples = __commonJS({
|
|
|
120512
120518
|
"site-popup/src/site/embedded-scripts/site-popup/embedded.html",
|
|
120513
120519
|
"site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.tsx",
|
|
120514
120520
|
"site-popup/src/site/embedded-scripts/site-popup/popup-overlay/index.css",
|
|
120515
|
-
"site-popup/src/types.ts"
|
|
120521
|
+
"site-popup/src/types.ts",
|
|
120522
|
+
"site-popup/src/components/popup/index.tsx",
|
|
120523
|
+
"site-popup/src/components/popup/index.css",
|
|
120524
|
+
"site-popup/src/components/close-button.tsx",
|
|
120525
|
+
"site-popup/src/components/close-button.css"
|
|
120516
120526
|
]
|
|
120517
120527
|
}
|
|
120518
120528
|
},
|
|
@@ -120555,12 +120565,30 @@ var require_load_examples = __commonJS({
|
|
|
120555
120565
|
files: {
|
|
120556
120566
|
[types.DashboardPage]: ["survey-manager/src/dashboard/pages/page.tsx"]
|
|
120557
120567
|
}
|
|
120568
|
+
},
|
|
120569
|
+
EventCountdown: {
|
|
120570
|
+
path: "event-countdown",
|
|
120571
|
+
description: "A dashboard app that allows administrators to create and manage countdown timers for events",
|
|
120572
|
+
files: {
|
|
120573
|
+
[types.DashboardPage]: [
|
|
120574
|
+
"event-countdown/src/dashboard/pages/countdown-timer-settings/page.tsx",
|
|
120575
|
+
"event-countdown/src/components/countdown-timer-settings.tsx",
|
|
120576
|
+
"event-countdown/src/components/countdown-preview.tsx",
|
|
120577
|
+
"event-countdown/src/types.ts",
|
|
120578
|
+
"event-countdown/src/dashboard/withProviders.tsx"
|
|
120579
|
+
],
|
|
120580
|
+
[types.EmbeddedScript]: [
|
|
120581
|
+
"event-countdown/src/site/embedded-scripts/countdown-timer/embedded.html"
|
|
120582
|
+
]
|
|
120583
|
+
}
|
|
120558
120584
|
}
|
|
120559
120585
|
};
|
|
120560
120586
|
exports2.examples = {
|
|
120561
120587
|
[types.APIExtension]: [appsExamples.AIChatbot],
|
|
120562
120588
|
[types.DashboardPage]: [
|
|
120563
120589
|
appsExamples.SurveyManager,
|
|
120590
|
+
appsExamples.EventCountdown,
|
|
120591
|
+
appsExamples.SitePopup,
|
|
120564
120592
|
appsExamples.AIChatbot,
|
|
120565
120593
|
appsExamples.CustomProductsCatalog,
|
|
120566
120594
|
appsExamples.MixPanelAnalystic,
|
|
@@ -120571,7 +120599,8 @@ var require_load_examples = __commonJS({
|
|
|
120571
120599
|
],
|
|
120572
120600
|
[types.EmbeddedScript]: [
|
|
120573
120601
|
appsExamples.MixPanelAnalystic,
|
|
120574
|
-
appsExamples.SitePopup
|
|
120602
|
+
appsExamples.SitePopup,
|
|
120603
|
+
appsExamples.EventCountdown
|
|
120575
120604
|
],
|
|
120576
120605
|
[types.ServicePluginExtension]: [appsExamples.SPISExample],
|
|
120577
120606
|
[types.CustomElementPlugin]: [appsExamples.InventoryCountdown],
|
|
@@ -120866,9 +120895,7 @@ Your output must be strictly JSON that conforms to the provided schema (no markd
|
|
|
120866
120895
|
Expected plan (abbreviated):
|
|
120867
120896
|
|
|
120868
120897
|
\`\`\`
|
|
120869
|
-
${JSON.stringify(
|
|
120870
|
-
apiSpec: todoExample
|
|
120871
|
-
}, null, 2)}
|
|
120898
|
+
${JSON.stringify(todoExample, null, 2)}
|
|
120872
120899
|
\`\`\`
|
|
120873
120900
|
</example_output>
|
|
120874
120901
|
|
|
@@ -120914,6 +120941,7 @@ Your output must be strictly JSON that conforms to the provided schema (no markd
|
|
|
120914
120941
|
- Do NOT create audit, transaction, log, history, or analytics collections unless the blueprint explicitly requests them.
|
|
120915
120942
|
- If the blueprint does not request persistent data, do not create any collections.
|
|
120916
120943
|
- For static or hardcoded behaviors, at most create one minimal read-only configuration collection only when strictly necessary.
|
|
120944
|
+
- NEVER create CMS collections to store embedded script configuration parameters. Embedded script parameters (colors, messages, positions, display settings, etc.) are ALREADY persisted via the embeddedScripts API and are managed through embeddedScriptParameters. Creating duplicate CMS collections for this data is redundant and incorrect.
|
|
120917
120945
|
</constraints>
|
|
120918
120946
|
|
|
120919
120947
|
<typing_rules>
|
|
@@ -120963,6 +120991,11 @@ For the collections field, return:
|
|
|
120963
120991
|
2) Propose collections only when the blueprint clearly requires persistent data. Define only the fields that are strictly required to fulfill the blueprint's functionality.
|
|
120964
120992
|
3) For any field that references products, categories, or orders: ALWAYS use REFERENCE type with proper typeMetadata.
|
|
120965
120993
|
4) Pick clear collection ids derived from the domain, lower-kebab or lower_underscore; avoid spaces.
|
|
120994
|
+
5) Avoid Duplicate Data Storage:
|
|
120995
|
+
- Embedded script parameters (defined in embeddedScriptParameters) are ALREADY saved and persisted via the embeddedScripts API
|
|
120996
|
+
- NEVER create CMS collections that duplicate these parameters (colors, messages, positions, display settings, etc.)
|
|
120997
|
+
- CMS collections should ONLY be created for additional business data that is NOT covered by embeddedScriptParameters
|
|
120998
|
+
- Only create CMS collections if there's genuinely new data needed beyond what's in embeddedScriptParameters (e.g., user-generated content, analytics, logs if explicitly requested)
|
|
120966
120999
|
</approach>
|
|
120967
121000
|
|
|
120968
121001
|
</CMS_PLANNER_SYSTEM_PROMPT>
|
|
@@ -120971,6 +121004,183 @@ For the collections field, return:
|
|
|
120971
121004
|
}
|
|
120972
121005
|
});
|
|
120973
121006
|
|
|
121007
|
+
// dist/system-prompts/planner/dynamicParameters.js
|
|
121008
|
+
var require_dynamicParameters = __commonJS({
|
|
121009
|
+
"dist/system-prompts/planner/dynamicParameters.js"(exports2) {
|
|
121010
|
+
"use strict";
|
|
121011
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121012
|
+
exports2.dynamicParametersPrompt = void 0;
|
|
121013
|
+
var dynamicParametersPrompt = () => `
|
|
121014
|
+
<DYNAMIC_PARAMETERS_PLANNER_SYSTEM_PROMPT>
|
|
121015
|
+
|
|
121016
|
+
<role>
|
|
121017
|
+
You are a Wix CLI planner expert specialized in determining dynamic parameters for embedded scripts. Given a blueprint with EMBEDDED_SCRIPT extensions, you must decide if the embedded script needs dynamic parameters that can be configured via the dashboard, and if so, define them.
|
|
121018
|
+
</role>
|
|
121019
|
+
|
|
121020
|
+
<description>
|
|
121021
|
+
Dynamic parameters allow embedded scripts to be configurable through a dashboard interface. They are template variables ({{variableName}}) that get replaced with actual values set by the site owner in the dashboard.
|
|
121022
|
+
|
|
121023
|
+
Common use cases:
|
|
121024
|
+
- Configuration values (API keys, script settings, display options)
|
|
121025
|
+
- Content that changes (headlines, messages, display text)
|
|
121026
|
+
- Visual customization (colors, sizes, images)
|
|
121027
|
+
- Timing and scheduling (dates, durations, intervals)
|
|
121028
|
+
- Feature toggles (enable/disable functionality)
|
|
121029
|
+
</description>
|
|
121030
|
+
|
|
121031
|
+
<when_to_use_dynamic_parameters>
|
|
121032
|
+
Use dynamic parameters when:
|
|
121033
|
+
- The embedded script needs configurable values that site owners should be able to change
|
|
121034
|
+
- The script's behavior or appearance should be customizable without code changes
|
|
121035
|
+
- Different instances or configurations are needed for different sites
|
|
121036
|
+
- Content, styling, or functionality needs to be adjusted through a UI
|
|
121037
|
+
|
|
121038
|
+
Do NOT use dynamic parameters when:
|
|
121039
|
+
- The script is fully static and requires no configuration
|
|
121040
|
+
- All values are hardcoded and never need to change
|
|
121041
|
+
</when_to_use_dynamic_parameters>
|
|
121042
|
+
|
|
121043
|
+
<output_structure>
|
|
121044
|
+
Your output must include an array of embeddedScriptParameters. This array can be:
|
|
121045
|
+
- Empty array [] if there are no EMBEDDED_SCRIPT extensions in the blueprint or no dynamic parameters are needed
|
|
121046
|
+
- Array of embedded script parameter objects if there are EMBEDDED_SCRIPT extensions
|
|
121047
|
+
|
|
121048
|
+
Each embedded script parameter object contains:
|
|
121049
|
+
- extensionId (string): The name of the embedded script extension these parameters belong to (use the extension.name field)
|
|
121050
|
+
- parameters (array): Array of dynamic parameter definitions
|
|
121051
|
+
|
|
121052
|
+
Each dynamic parameter must include:
|
|
121053
|
+
- key (string, lowerCamelCase): The template variable name used as {{key}} in the embedded script
|
|
121054
|
+
- displayName (string): Human-readable label for the dashboard UI
|
|
121055
|
+
- type (ParameterType): The data type of the parameter
|
|
121056
|
+
- description (string, optional): Help text explaining the parameter's purpose
|
|
121057
|
+
- required (boolean): Whether the parameter must have a value
|
|
121058
|
+
- defaultValue (string, optional): Default value if not set by the user
|
|
121059
|
+
- options (array of strings, optional): For SELECT type parameters, the available options
|
|
121060
|
+
|
|
121061
|
+
Example output structures:
|
|
121062
|
+
|
|
121063
|
+
No embedded script extensions:
|
|
121064
|
+
[]
|
|
121065
|
+
|
|
121066
|
+
With embedded script extensions:
|
|
121067
|
+
[
|
|
121068
|
+
{
|
|
121069
|
+
"extensionId": "site-popup",
|
|
121070
|
+
"parameters": [
|
|
121071
|
+
{ "key": "headline", "displayName": "Headline", "type": "TEXT", "required": true },
|
|
121072
|
+
{ "key": "text", "displayName": "Text", "type": "TEXTAREA", "required": true }
|
|
121073
|
+
]
|
|
121074
|
+
}
|
|
121075
|
+
]
|
|
121076
|
+
|
|
121077
|
+
Supported parameter types:
|
|
121078
|
+
- TEXT: Single-line text input
|
|
121079
|
+
- TEXTAREA: Multi-line text input
|
|
121080
|
+
- NUMBER: Numeric input
|
|
121081
|
+
- BOOLEAN: Checkbox or toggle
|
|
121082
|
+
- IMAGE: Image picker
|
|
121083
|
+
- DATE: Date picker
|
|
121084
|
+
- DATETIME: Date and time picker
|
|
121085
|
+
- URL: URL input with validation
|
|
121086
|
+
- SELECT: Dropdown with predefined options (must include options array)
|
|
121087
|
+
- COLOR: Color picker
|
|
121088
|
+
</output_structure>
|
|
121089
|
+
|
|
121090
|
+
<examples>
|
|
121091
|
+
|
|
121092
|
+
Example 1 - Site Popup (dynamic parameters needed):
|
|
121093
|
+
Blueprint: A popup that appears on the site with configurable message and timing
|
|
121094
|
+
Extension Name: "site-popup"
|
|
121095
|
+
Output:
|
|
121096
|
+
[
|
|
121097
|
+
{
|
|
121098
|
+
"extensionId": "site-popup",
|
|
121099
|
+
"parameters": [
|
|
121100
|
+
{
|
|
121101
|
+
"key": "headline",
|
|
121102
|
+
"displayName": "Headline",
|
|
121103
|
+
"type": "TEXT",
|
|
121104
|
+
"description": "The main headline shown in the popup",
|
|
121105
|
+
"required": true,
|
|
121106
|
+
"defaultValue": "Sale 20% Off"
|
|
121107
|
+
},
|
|
121108
|
+
{
|
|
121109
|
+
"key": "text",
|
|
121110
|
+
"displayName": "Text",
|
|
121111
|
+
"type": "TEXTAREA",
|
|
121112
|
+
"description": "The message content of the popup",
|
|
121113
|
+
"required": true,
|
|
121114
|
+
"defaultValue": "Sign up and get 20% off on our Winter Sale"
|
|
121115
|
+
},
|
|
121116
|
+
{
|
|
121117
|
+
"key": "imageUrl",
|
|
121118
|
+
"displayName": "Image",
|
|
121119
|
+
"type": "IMAGE",
|
|
121120
|
+
"description": "The image displayed in the popup",
|
|
121121
|
+
"required": false
|
|
121122
|
+
},
|
|
121123
|
+
{
|
|
121124
|
+
"key": "imageTitle",
|
|
121125
|
+
"displayName": "Image Title",
|
|
121126
|
+
"type": "TEXT",
|
|
121127
|
+
"description": "Alt text for the popup image",
|
|
121128
|
+
"required": false
|
|
121129
|
+
},
|
|
121130
|
+
{
|
|
121131
|
+
"key": "activationMode",
|
|
121132
|
+
"displayName": "Activation Mode",
|
|
121133
|
+
"type": "SELECT",
|
|
121134
|
+
"description": "When the popup should be active",
|
|
121135
|
+
"required": true,
|
|
121136
|
+
"defaultValue": "active",
|
|
121137
|
+
"options": ["active", "timed", "disabled"]
|
|
121138
|
+
},
|
|
121139
|
+
{
|
|
121140
|
+
"key": "startDate",
|
|
121141
|
+
"displayName": "Start Date",
|
|
121142
|
+
"type": "DATE",
|
|
121143
|
+
"description": "Start date for timed activation",
|
|
121144
|
+
"required": false
|
|
121145
|
+
},
|
|
121146
|
+
{
|
|
121147
|
+
"key": "endDate",
|
|
121148
|
+
"displayName": "End Date",
|
|
121149
|
+
"type": "DATE",
|
|
121150
|
+
"description": "End date for timed activation",
|
|
121151
|
+
"required": false
|
|
121152
|
+
}
|
|
121153
|
+
]
|
|
121154
|
+
}
|
|
121155
|
+
]
|
|
121156
|
+
|
|
121157
|
+
Example 2 - Static Pixel (no dynamic parameters needed):
|
|
121158
|
+
Blueprint: Add a Facebook Pixel with a hardcoded pixel ID
|
|
121159
|
+
Extension Name: "facebook-pixel"
|
|
121160
|
+
Output: []
|
|
121161
|
+
|
|
121162
|
+
</examples>
|
|
121163
|
+
|
|
121164
|
+
<guidelines>
|
|
121165
|
+
- If there are NO EMBEDDED_SCRIPT extensions in the blueprint, return an empty array: "embeddedScriptParameters": []
|
|
121166
|
+
- If there are EMBEDDED_SCRIPT extensions, ONLY include them if they truly need configurable parameters
|
|
121167
|
+
- The extensionId MUST match the exact name of the embedded script extension from the blueprint
|
|
121168
|
+
- Only define parameters that truly need to be configurable by the site owner
|
|
121169
|
+
- Keep parameter keys descriptive and in lowerCamelCase
|
|
121170
|
+
- Provide clear displayName and description for each parameter
|
|
121171
|
+
- Set appropriate required flags based on functionality needs
|
|
121172
|
+
- Choose the most appropriate type for the data
|
|
121173
|
+
- For SELECT types, MUST include the options array with all possible values
|
|
121174
|
+
- Consider grouping related parameters (e.g., activation settings, appearance settings)
|
|
121175
|
+
- Default values should be sensible and demonstrate the expected format
|
|
121176
|
+
</guidelines>
|
|
121177
|
+
|
|
121178
|
+
</DYNAMIC_PARAMETERS_PLANNER_SYSTEM_PROMPT>
|
|
121179
|
+
`;
|
|
121180
|
+
exports2.dynamicParametersPrompt = dynamicParametersPrompt;
|
|
121181
|
+
}
|
|
121182
|
+
});
|
|
121183
|
+
|
|
120974
121184
|
// dist/system-prompts/planner/planner.js
|
|
120975
121185
|
var require_planner = __commonJS({
|
|
120976
121186
|
"dist/system-prompts/planner/planner.js"(exports2) {
|
|
@@ -120979,13 +121189,18 @@ var require_planner = __commonJS({
|
|
|
120979
121189
|
exports2.plannerPrompt = void 0;
|
|
120980
121190
|
var apiSpec_1 = require_apiSpec();
|
|
120981
121191
|
var data_1 = require_data2();
|
|
120982
|
-
var
|
|
121192
|
+
var dynamicParameters_1 = require_dynamicParameters();
|
|
121193
|
+
var plannerPrompt = (hasEmbeddedScriptExtensions, hasBackendApiExtensions) => {
|
|
121194
|
+
return `
|
|
120983
121195
|
<WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
120984
121196
|
${(0, data_1.cmsPlannerPrompt)()}
|
|
120985
121197
|
|
|
120986
|
-
${(0, apiSpec_1.apiSpecPrompt)()}
|
|
121198
|
+
${hasBackendApiExtensions ? (0, apiSpec_1.apiSpecPrompt)() : "No backend API extensions in the blueprint, return an empty object: {}"}
|
|
121199
|
+
|
|
121200
|
+
${hasEmbeddedScriptExtensions ? (0, dynamicParameters_1.dynamicParametersPrompt)() : 'No embeddedScriptParameters needed, no embedded scripts in the blueprint, return an empty array: "embeddedScriptParameters": []'}
|
|
120987
121201
|
</WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
120988
121202
|
`;
|
|
121203
|
+
};
|
|
120989
121204
|
exports2.plannerPrompt = plannerPrompt;
|
|
120990
121205
|
}
|
|
120991
121206
|
});
|
|
@@ -122933,12 +123148,48 @@ var require_ApiSpecSchema = __commonJS({
|
|
|
122933
123148
|
}
|
|
122934
123149
|
});
|
|
122935
123150
|
|
|
123151
|
+
// dist/EmbeddedScriptSchema.js
|
|
123152
|
+
var require_EmbeddedScriptSchema = __commonJS({
|
|
123153
|
+
"dist/EmbeddedScriptSchema.js"(exports2) {
|
|
123154
|
+
"use strict";
|
|
123155
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
123156
|
+
exports2.EmbeddedScriptParametersSchema = exports2.DynamicParameterSchema = void 0;
|
|
123157
|
+
var zod_1 = require_zod();
|
|
123158
|
+
var ParameterTypeEnum = zod_1.z.enum([
|
|
123159
|
+
"TEXT",
|
|
123160
|
+
"TEXTAREA",
|
|
123161
|
+
"NUMBER",
|
|
123162
|
+
"BOOLEAN",
|
|
123163
|
+
"IMAGE",
|
|
123164
|
+
"DATE",
|
|
123165
|
+
"DATETIME",
|
|
123166
|
+
"URL",
|
|
123167
|
+
"SELECT",
|
|
123168
|
+
"COLOR"
|
|
123169
|
+
]).describe("The data type of a dynamic parameter for embedded scripts");
|
|
123170
|
+
exports2.DynamicParameterSchema = zod_1.z.object({
|
|
123171
|
+
key: zod_1.z.string().describe("The template variable name used as {{key}} in the embedded script (lowerCamelCase)"),
|
|
123172
|
+
displayName: zod_1.z.string().describe("Human-readable label for the dashboard UI"),
|
|
123173
|
+
type: ParameterTypeEnum.describe("The data type of the parameter"),
|
|
123174
|
+
description: zod_1.z.string().optional().describe("Help text explaining the parameter's purpose"),
|
|
123175
|
+
required: zod_1.z.boolean().describe("Whether the parameter must have a value"),
|
|
123176
|
+
defaultValue: zod_1.z.string().optional().describe("Default value if not set by the user"),
|
|
123177
|
+
options: zod_1.z.array(zod_1.z.string()).optional().describe("For SELECT type parameters, the available options")
|
|
123178
|
+
}).describe("A dynamic parameter definition for embedded script configuration");
|
|
123179
|
+
exports2.EmbeddedScriptParametersSchema = zod_1.z.object({
|
|
123180
|
+
extensionId: zod_1.z.string().describe("The name of the embedded script extension these parameters belong to"),
|
|
123181
|
+
parameters: zod_1.z.array(exports2.DynamicParameterSchema).default([]).describe("Array of dynamic parameter definitions for this embedded script")
|
|
123182
|
+
}).describe("Dynamic parameters configuration for a specific embedded script extension");
|
|
123183
|
+
}
|
|
123184
|
+
});
|
|
123185
|
+
|
|
122936
123186
|
// dist/agents/PlannerAgent.js
|
|
122937
123187
|
var require_PlannerAgent = __commonJS({
|
|
122938
123188
|
"dist/agents/PlannerAgent.js"(exports2) {
|
|
122939
123189
|
"use strict";
|
|
122940
123190
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
122941
123191
|
exports2.PlannerAgent = exports2.PlannerOutputSchema = void 0;
|
|
123192
|
+
var types_1 = require_types_impl();
|
|
122942
123193
|
var anthropic_1 = require_dist5();
|
|
122943
123194
|
var ai_1 = require_dist9();
|
|
122944
123195
|
var zod_1 = require_zod();
|
|
@@ -122946,27 +123197,31 @@ var require_PlannerAgent = __commonJS({
|
|
|
122946
123197
|
var CMSAgent_1 = require_CMSAgent();
|
|
122947
123198
|
var utils_1 = require_utils14();
|
|
122948
123199
|
var ApiSpecSchema_1 = require_ApiSpecSchema();
|
|
123200
|
+
var EmbeddedScriptSchema_1 = require_EmbeddedScriptSchema();
|
|
122949
123201
|
exports2.PlannerOutputSchema = zod_1.z.object({
|
|
122950
|
-
collections: zod_1.z.array(CMSAgent_1.CmsCollectionSchema).default([]),
|
|
122951
|
-
|
|
123202
|
+
collections: zod_1.z.array(CMSAgent_1.CmsCollectionSchema).default([]).describe("CMS collections to be created for the app"),
|
|
123203
|
+
embeddedScriptParameters: zod_1.z.array(EmbeddedScriptSchema_1.EmbeddedScriptParametersSchema).default([]).describe("Dynamic parameters for embedded script extensions (empty array if no embedded scripts)"),
|
|
123204
|
+
apiSpec: ApiSpecSchema_1.ApiSpecSchema.optional().describe("API specification for the app")
|
|
122952
123205
|
});
|
|
122953
123206
|
var PlannerAgent = class {
|
|
122954
123207
|
constructor(apiKey) {
|
|
122955
123208
|
this.apiKey = apiKey;
|
|
122956
123209
|
this.name = "PlannerAgent";
|
|
122957
123210
|
}
|
|
122958
|
-
buildSystemPrompt() {
|
|
122959
|
-
return (0, planner_1.plannerPrompt)();
|
|
123211
|
+
buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions) {
|
|
123212
|
+
return (0, planner_1.plannerPrompt)(hasEmbeddedScriptExtensions, hasBackendApiExtensions);
|
|
122960
123213
|
}
|
|
122961
123214
|
async generate(blueprint) {
|
|
122962
123215
|
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
|
|
123216
|
+
const hasEmbeddedScriptExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.EMBEDDED_SCRIPT) ?? false;
|
|
123217
|
+
const hasBackendApiExtensions = blueprint?.extensions?.some((ext) => ext.type === types_1.ExtensionType.BACKEND_API) ?? false;
|
|
122963
123218
|
const result = await (0, ai_1.generateObject)({
|
|
122964
123219
|
model,
|
|
122965
123220
|
schema: exports2.PlannerOutputSchema,
|
|
122966
123221
|
messages: [
|
|
122967
123222
|
{
|
|
122968
123223
|
role: "system",
|
|
122969
|
-
content: this.buildSystemPrompt(),
|
|
123224
|
+
content: this.buildSystemPrompt(hasEmbeddedScriptExtensions, hasBackendApiExtensions),
|
|
122970
123225
|
providerOptions: (0, utils_1.withCaching)("1h")
|
|
122971
123226
|
},
|
|
122972
123227
|
{
|
|
@@ -124305,7 +124560,8 @@ var require_shared = __commonJS({
|
|
|
124305
124560
|
exports2.FIELD_TYPES_REFERENCE = `- TEXT: String values
|
|
124306
124561
|
- NUMBER: Numeric values
|
|
124307
124562
|
- BOOLEAN: true/false
|
|
124308
|
-
- DATE:
|
|
124563
|
+
- DATE: Date-only strings in YYYY-MM-DD format (e.g., "2024-01-15")
|
|
124564
|
+
- DATETIME: ISO 8601 datetime strings (e.g., "2024-01-15T10:30:00.000Z")
|
|
124309
124565
|
- RICH_TEXT: HTML formatted strings
|
|
124310
124566
|
- IMAGE: Image URLs or empty strings
|
|
124311
124567
|
- REFERENCE: Object references - NEVER use null, undefined, or generate sample data. Return empty dataItems array [] for collections with REFERENCE fields
|
|
@@ -126346,6 +126602,273 @@ async function updateTodo(id: string, todo: Partial<Todo>): Promise<Todo> {
|
|
|
126346
126602
|
}
|
|
126347
126603
|
});
|
|
126348
126604
|
|
|
126605
|
+
// dist/system-prompts/dashboardPage/dynamicParameters.js
|
|
126606
|
+
var require_dynamicParameters2 = __commonJS({
|
|
126607
|
+
"dist/system-prompts/dashboardPage/dynamicParameters.js"(exports2) {
|
|
126608
|
+
"use strict";
|
|
126609
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
126610
|
+
exports2.dynamicParametersManagementPrompt = void 0;
|
|
126611
|
+
var dynamicParametersManagementPrompt = () => {
|
|
126612
|
+
return `
|
|
126613
|
+
<DYNAMIC_PARAMETERS_MANAGEMENT>
|
|
126614
|
+
|
|
126615
|
+
<description>
|
|
126616
|
+
This dashboard page manages dynamic parameters for an embedded script. The parameters are configurable values that site owners can set through this dashboard interface, and they will be passed to the embedded script as template variables.
|
|
126617
|
+
|
|
126618
|
+
IMPORTANT: Only implement UI for parameters that are relevant to your current use case. Ignore parameters that don't apply to the functionality you're building. It's perfectly fine to not use all parameters if they're not applicable.
|
|
126619
|
+
</description>
|
|
126620
|
+
|
|
126621
|
+
<implementation_requirements>
|
|
126622
|
+
|
|
126623
|
+
1. Import embeddedScripts:
|
|
126624
|
+
- Import embeddedScripts directly from '@wix/app-management'
|
|
126625
|
+
- Use embeddedScripts.getEmbeddedScript() to load parameters
|
|
126626
|
+
- Use embeddedScripts.embedScript({ parameters }) to save parameters
|
|
126627
|
+
- Example:
|
|
126628
|
+
import { embeddedScripts } from '@wix/app-management';
|
|
126629
|
+
|
|
126630
|
+
2. Type Definition:
|
|
126631
|
+
- Create a TypeScript type/interface that includes all the dynamic parameters
|
|
126632
|
+
- Example:
|
|
126633
|
+
export type MyScriptOptions = {
|
|
126634
|
+
headline: string;
|
|
126635
|
+
text: string;
|
|
126636
|
+
imageUrl: string;
|
|
126637
|
+
activationMode: 'active' | 'timed' | 'disabled';
|
|
126638
|
+
startDate?: string;
|
|
126639
|
+
endDate?: string;
|
|
126640
|
+
};
|
|
126641
|
+
|
|
126642
|
+
3. State Management:
|
|
126643
|
+
- Use React useState to manage the parameter values locally
|
|
126644
|
+
- Initialize with default values for all parameters
|
|
126645
|
+
- Add separate state for isLoading and isSaving
|
|
126646
|
+
- Use useEffect to load parameters on mount
|
|
126647
|
+
- IMPORTANT: Parameters are returned as strings from the API, so you must handle type conversions:
|
|
126648
|
+
* BOOLEAN parameters: Convert from string 'true'/'false' to boolean
|
|
126649
|
+
* NUMBER parameters: Convert from string to number using Number()
|
|
126650
|
+
* Other types: Use as-is
|
|
126651
|
+
- Example:
|
|
126652
|
+
const [options, setOptions] = useState<MyScriptOptions>(defaultOptions);
|
|
126653
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
126654
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
126655
|
+
|
|
126656
|
+
useEffect(() => {
|
|
126657
|
+
const loadSettings = async () => {
|
|
126658
|
+
try {
|
|
126659
|
+
const embeddedScript = await embeddedScripts.getEmbeddedScript();
|
|
126660
|
+
const data = embeddedScript.parameters as Partial<Record<keyof MyScriptOptions, string>> || {};
|
|
126661
|
+
|
|
126662
|
+
setOptions((prev) => ({
|
|
126663
|
+
...prev,
|
|
126664
|
+
textField: data?.textField || prev.textField,
|
|
126665
|
+
booleanField: data?.booleanField === 'true' ? true : data?.booleanField === 'false' ? false : prev.booleanField,
|
|
126666
|
+
numberField: Number(data?.numberField) || prev.numberField,
|
|
126667
|
+
}));
|
|
126668
|
+
} catch (error) {
|
|
126669
|
+
console.error('Failed to load settings:', error);
|
|
126670
|
+
} finally {
|
|
126671
|
+
setIsLoading(false);
|
|
126672
|
+
}
|
|
126673
|
+
};
|
|
126674
|
+
|
|
126675
|
+
loadSettings();
|
|
126676
|
+
}, []);
|
|
126677
|
+
|
|
126678
|
+
4. Loading State:
|
|
126679
|
+
- Show a Loader component while isLoading is true
|
|
126680
|
+
- Example:
|
|
126681
|
+
{isLoading ? (
|
|
126682
|
+
<Box align="center" verticalAlign="middle" height="50vh">
|
|
126683
|
+
<Loader text="Loading..." />
|
|
126684
|
+
</Box>
|
|
126685
|
+
) : (
|
|
126686
|
+
// ... form content
|
|
126687
|
+
)}
|
|
126688
|
+
|
|
126689
|
+
5. Form Components:
|
|
126690
|
+
- IMPORTANT: Only create form fields for parameters relevant to your use case
|
|
126691
|
+
- Skip parameters that don't apply to the functionality being built
|
|
126692
|
+
- Create appropriate WDS form fields based on parameter types:
|
|
126693
|
+
* TEXT \u2192 Input component with FormField
|
|
126694
|
+
* TEXTAREA \u2192 InputArea component with FormField
|
|
126695
|
+
* NUMBER \u2192 Input component with type="number"
|
|
126696
|
+
* BOOLEAN \u2192 Checkbox or ToggleSwitch
|
|
126697
|
+
* IMAGE \u2192 Custom ImagePicker component (see components/image-picker.tsx)
|
|
126698
|
+
* DATE \u2192 DatePicker component
|
|
126699
|
+
* SELECT \u2192 Dropdown component with options
|
|
126700
|
+
* URL \u2192 Input with URL validation
|
|
126701
|
+
- Use FormField wrapper for labels and validation messages
|
|
126702
|
+
- Set required validation based on parameter.required flag
|
|
126703
|
+
- Show validation errors using FormField status and statusMessage props
|
|
126704
|
+
|
|
126705
|
+
6. Save Functionality:
|
|
126706
|
+
- Add a Save button in the Page.Header actionsBar
|
|
126707
|
+
- Make handleSave an async function
|
|
126708
|
+
- CRITICAL: All parameters must be passed as STRING values because they are used as template variables in the embedded script
|
|
126709
|
+
- Convert all values to strings before saving:
|
|
126710
|
+
* BOOLEAN: Use String(value) or value.toString()
|
|
126711
|
+
* NUMBER: Use String(value) or value.toString()
|
|
126712
|
+
* Other types: Already strings, use as-is
|
|
126713
|
+
- Disable the Save button if required fields are missing or while saving
|
|
126714
|
+
- Add proper error handling
|
|
126715
|
+
|
|
126716
|
+
7. Form Validation:
|
|
126717
|
+
- Implement validation for required fields
|
|
126718
|
+
- Show error states on FormField components
|
|
126719
|
+
- Display clear error messages
|
|
126720
|
+
|
|
126721
|
+
8. Layout and Organization:
|
|
126722
|
+
- Use Card components to group related fields
|
|
126723
|
+
- Use Box with direction="vertical" for form layout
|
|
126724
|
+
- Add appropriate spacing with gap props
|
|
126725
|
+
- Include helpful descriptions using Card subtitle or FormField infoContent
|
|
126726
|
+
- Consider creating a separate settings component for complex forms
|
|
126727
|
+
|
|
126728
|
+
9. Preview Component (Optional but Recommended):
|
|
126729
|
+
- If applicable, create a preview component that shows how the configuration will look
|
|
126730
|
+
- Display the preview alongside the settings form using Layout and Cell components
|
|
126731
|
+
- The preview should react to parameter changes in real-time
|
|
126732
|
+
|
|
126733
|
+
</implementation_requirements>
|
|
126734
|
+
|
|
126735
|
+
<parameter_type_mapping>
|
|
126736
|
+
|
|
126737
|
+
<example_implementation>
|
|
126738
|
+
See the generated site-popup example for a complete reference implementation:
|
|
126739
|
+
- src/dashboard/withProviders.tsx - Provider wrapper with WDS
|
|
126740
|
+
- src/dashboard/pages/page.tsx - Dashboard page with parameter management (wrapped with withProviders)
|
|
126741
|
+
- src/components/site-popup-settings.tsx - Settings form component
|
|
126742
|
+
- src/types.ts - Type definitions
|
|
126743
|
+
|
|
126744
|
+
Key implementation patterns from the example:
|
|
126745
|
+
1. withProviders.tsx wraps the component with WixDesignSystemProvider
|
|
126746
|
+
2. page.tsx exports the component wrapped: export default withProviders(MyComponent)
|
|
126747
|
+
3. Parameters are saved as individual string fields, not as JSON
|
|
126748
|
+
4. Parameters are loaded with proper type conversion (string to boolean, string to number, etc.)
|
|
126749
|
+
5. Use embeddedScripts directly from '@wix/app-management'
|
|
126750
|
+
</example_implementation>
|
|
126751
|
+
|
|
126752
|
+
<file_generation_requirements>
|
|
126753
|
+
When dynamic parameters are present, you MUST generate these files:
|
|
126754
|
+
1. src/dashboard/withProviders.tsx - Provider wrapper (REQUIRED for WDS)
|
|
126755
|
+
2. src/dashboard/pages/page.tsx - The main dashboard page component
|
|
126756
|
+
3. src/types.ts - Type definitions for the parameters (if needed)
|
|
126757
|
+
4. Any additional component files (settings forms, previews, etc.)
|
|
126758
|
+
|
|
126759
|
+
The withProviders.tsx is NOT optional - it must always be generated when there are dynamic parameters.
|
|
126760
|
+
</file_generation_requirements>
|
|
126761
|
+
|
|
126762
|
+
<provider_wrapper_implementation>
|
|
126763
|
+
You MUST generate the following file: src/dashboard/withProviders.tsx
|
|
126764
|
+
|
|
126765
|
+
This file is REQUIRED to wrap dashboard components with the Wix Design System provider.
|
|
126766
|
+
|
|
126767
|
+
import React from 'react';
|
|
126768
|
+
import { WixDesignSystemProvider } from '@wix/design-system';
|
|
126769
|
+
import { i18n } from '@wix/essentials';
|
|
126770
|
+
|
|
126771
|
+
export default function withProviders<P extends {} = {}>(Component: React.FC<P>) {
|
|
126772
|
+
return function DashboardProviders(props: P) {
|
|
126773
|
+
const locale = i18n.getLocale();
|
|
126774
|
+
return (
|
|
126775
|
+
<WixDesignSystemProvider locale={locale} features={{ newColorsBranding: true }}>
|
|
126776
|
+
<Component {...props} />
|
|
126777
|
+
</WixDesignSystemProvider>
|
|
126778
|
+
);
|
|
126779
|
+
};
|
|
126780
|
+
}
|
|
126781
|
+
|
|
126782
|
+
// Also export as named export for backwards compatibility
|
|
126783
|
+
export { withProviders };
|
|
126784
|
+
|
|
126785
|
+
This file must be included in your generated files output.
|
|
126786
|
+
</provider_wrapper_implementation>
|
|
126787
|
+
|
|
126788
|
+
<using_provider_wrapper>
|
|
126789
|
+
In your dashboard page component (page.tsx):
|
|
126790
|
+
1. Import the withProviders wrapper: import withProviders from '../../withProviders';
|
|
126791
|
+
2. Import embeddedScripts from '@wix/app-management'
|
|
126792
|
+
3. DO NOT wrap your component with WixDesignSystemProvider - the provider wrapper does this
|
|
126793
|
+
4. Export the component wrapped with withProviders: export default withProviders(MyComponent);
|
|
126794
|
+
5. Your component should only contain the Page component and its content, not providers
|
|
126795
|
+
|
|
126796
|
+
Example structure:
|
|
126797
|
+
import { useEffect, useState, type FC } from 'react';
|
|
126798
|
+
import { dashboard } from '@wix/dashboard';
|
|
126799
|
+
import { embeddedScripts } from '@wix/app-management';
|
|
126800
|
+
import { Page, Card, Button, ... } from '@wix/design-system';
|
|
126801
|
+
import '@wix/design-system/styles.global.css';
|
|
126802
|
+
import withProviders from '../../withProviders';
|
|
126803
|
+
|
|
126804
|
+
const MyDashboardPage: FC = () => {
|
|
126805
|
+
const [options, setOptions] = useState<MyScriptOptions>(defaultOptions);
|
|
126806
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
126807
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
126808
|
+
|
|
126809
|
+
useEffect(() => {
|
|
126810
|
+
const loadSettings = async () => {
|
|
126811
|
+
try {
|
|
126812
|
+
const embeddedScript = await embeddedScripts.getEmbeddedScript();
|
|
126813
|
+
const data = embeddedScript.parameters || {};
|
|
126814
|
+
// ... update options with data
|
|
126815
|
+
} catch (error) {
|
|
126816
|
+
console.error('Failed to load settings:', error);
|
|
126817
|
+
} finally {
|
|
126818
|
+
setIsLoading(false);
|
|
126819
|
+
}
|
|
126820
|
+
};
|
|
126821
|
+
loadSettings();
|
|
126822
|
+
}, []);
|
|
126823
|
+
|
|
126824
|
+
const handleSave = async () => {
|
|
126825
|
+
setIsSaving(true);
|
|
126826
|
+
try {
|
|
126827
|
+
await embeddedScripts.embedScript({ parameters: { /* ... */ } });
|
|
126828
|
+
dashboard.showToast({ message: 'Saved!', type: 'success' });
|
|
126829
|
+
} catch (error) {
|
|
126830
|
+
console.error('Failed to save:', error);
|
|
126831
|
+
dashboard.showToast({ message: 'Failed to save', type: 'error' });
|
|
126832
|
+
} finally {
|
|
126833
|
+
setIsSaving(false);
|
|
126834
|
+
}
|
|
126835
|
+
};
|
|
126836
|
+
|
|
126837
|
+
return (
|
|
126838
|
+
<Page height="100vh">
|
|
126839
|
+
{/* Page content - NO WixDesignSystemProvider here */}
|
|
126840
|
+
</Page>
|
|
126841
|
+
);
|
|
126842
|
+
};
|
|
126843
|
+
|
|
126844
|
+
export default withProviders(MyDashboardPage);
|
|
126845
|
+
</using_provider_wrapper>
|
|
126846
|
+
|
|
126847
|
+
<critical_notes>
|
|
126848
|
+
- Only implement UI for parameters that are relevant to your specific use case - ignore parameters that don't apply
|
|
126849
|
+
- ALWAYS generate withProviders.tsx when there are dynamic parameters
|
|
126850
|
+
- ALWAYS wrap the dashboard page export with withProviders()
|
|
126851
|
+
- DO NOT use WixDesignSystemProvider directly in the dashboard page component - use withProviders instead
|
|
126852
|
+
- ALWAYS use embeddedScripts directly from '@wix/app-management'
|
|
126853
|
+
- ALWAYS convert parameter values to strings when saving (embeddedScripts.embedScript must receive all string values in the parameters object)
|
|
126854
|
+
- ALWAYS convert string parameters back to proper types when loading (e.g., 'true' -> true for booleans, string to number for numbers)
|
|
126855
|
+
- ALWAYS handle the loading state with isLoading state variable
|
|
126856
|
+
- ALWAYS handle the saving state with isSaving state variable
|
|
126857
|
+
- ALWAYS add try/catch blocks for async operations (loading and saving)
|
|
126858
|
+
- ALWAYS use async/await for embeddedScripts operations
|
|
126859
|
+
- ALWAYS merge parameter values correctly in useEffect with proper type conversions
|
|
126860
|
+
- ALWAYS validate required fields and show appropriate error states
|
|
126861
|
+
- The parameter keys MUST match exactly what is expected in the embedded script template variables
|
|
126862
|
+
- Each parameter is saved as a separate field, NOT as a JSON string
|
|
126863
|
+
</critical_notes>
|
|
126864
|
+
|
|
126865
|
+
</DYNAMIC_PARAMETERS_MANAGEMENT>
|
|
126866
|
+
`;
|
|
126867
|
+
};
|
|
126868
|
+
exports2.dynamicParametersManagementPrompt = dynamicParametersManagementPrompt;
|
|
126869
|
+
}
|
|
126870
|
+
});
|
|
126871
|
+
|
|
126349
126872
|
// dist/system-prompts/dashboardPage/dashboardPagePrompt.js
|
|
126350
126873
|
var require_dashboardPagePrompt = __commonJS({
|
|
126351
126874
|
"dist/system-prompts/dashboardPage/dashboardPagePrompt.js"(exports2) {
|
|
@@ -126357,6 +126880,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
126357
126880
|
var wdsPackage_1 = require_wdsPackage();
|
|
126358
126881
|
var data_1 = require_data3();
|
|
126359
126882
|
var apiSpecPrompt_1 = require_apiSpecPrompt();
|
|
126883
|
+
var dynamicParameters_1 = require_dynamicParameters2();
|
|
126360
126884
|
var wdsPackage_2 = require_wdsPackage();
|
|
126361
126885
|
Object.defineProperty(exports2, "buildWdsSystemPrompt", { enumerable: true, get: function() {
|
|
126362
126886
|
return wdsPackage_2.buildWdsSystemPrompt;
|
|
@@ -126386,7 +126910,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
126386
126910
|
"ToggleSwitch",
|
|
126387
126911
|
"InfoIcon"
|
|
126388
126912
|
];
|
|
126389
|
-
var dashboardPagePrompt = async ({ useData, useApiSpec }) => {
|
|
126913
|
+
var dashboardPagePrompt = async ({ useData, useApiSpec, useDynamicParameters }) => {
|
|
126390
126914
|
const wdsPrompt = await (0, wdsPackage_1.buildWdsSystemPrompt)(listOfWdsComponents);
|
|
126391
126915
|
return `
|
|
126392
126916
|
<WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
@@ -126469,6 +126993,8 @@ ${wdsPrompt}
|
|
|
126469
126993
|
${useData ? data_1.dataPrompt : ""}
|
|
126470
126994
|
|
|
126471
126995
|
${useApiSpec ? apiSpecPrompt_1.apiSpecPrompt : ""}
|
|
126996
|
+
|
|
126997
|
+
${useDynamicParameters ? (0, dynamicParameters_1.dynamicParametersManagementPrompt)() : ""}
|
|
126472
126998
|
</WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
126473
126999
|
`;
|
|
126474
127000
|
};
|
|
@@ -126500,7 +127026,8 @@ var require_DashboardPageAgent = __commonJS({
|
|
|
126500
127026
|
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.DashboardPage]);
|
|
126501
127027
|
const useData = Boolean(planAndResources?.createdCollections?.length);
|
|
126502
127028
|
const useApiSpec = Boolean(planAndResources?.apiSpec);
|
|
126503
|
-
const
|
|
127029
|
+
const useDynamicParameters = Boolean(planAndResources?.embeddedScriptParameters?.length);
|
|
127030
|
+
const systemPrompt = `${await this.buildSystemPrompt({ useData, useApiSpec, useDynamicParameters })}
|
|
126504
127031
|
${examples}
|
|
126505
127032
|
`;
|
|
126506
127033
|
console.log(`Dashboard Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
|
|
@@ -126659,6 +127186,7 @@ Auto-patterns is suitable for:
|
|
|
126659
127186
|
|
|
126660
127187
|
<custom-code-needed-for>
|
|
126661
127188
|
Custom code is required for:
|
|
127189
|
+
- Embedded script parameter management
|
|
126662
127190
|
- Custom business logic or calculations
|
|
126663
127191
|
- Complex workflows or state management
|
|
126664
127192
|
- External API integrations or webhooks
|
|
@@ -126672,12 +127200,36 @@ Custom code is required for:
|
|
|
126672
127200
|
</custom-code-needed-for>
|
|
126673
127201
|
|
|
126674
127202
|
<task>
|
|
126675
|
-
1. Analyze the dashboard page description and
|
|
126676
|
-
2.
|
|
126677
|
-
3.
|
|
127203
|
+
1. Analyze the dashboard page description and determine what functionality is actually needed
|
|
127204
|
+
2. Consider only the collections and embedded script parameters that are RELEVANT to this specific dashboard page
|
|
127205
|
+
3. Decide whether auto-patterns is sufficient or if custom code is needed
|
|
127206
|
+
4. If auto-patterns is suitable, generate the complete schema for the SINGLE most relevant collection
|
|
126678
127207
|
|
|
126679
|
-
IMPORTANT:
|
|
127208
|
+
IMPORTANT: Focus only on what's relevant to the current use case. Not all collections or parameters need to be used.
|
|
127209
|
+
|
|
127210
|
+
CRITICAL: EMBEDDED SCRIPT SETTINGS/CONFIGURATION PAGES
|
|
127211
|
+
You will receive information about embedded script parameters in the <embedded-script-parameters> section.
|
|
127212
|
+
|
|
127213
|
+
IMPORTANT: Only consider embedded script parameters that are RELEVANT to the current dashboard page use case.
|
|
127214
|
+
- Some embedded script parameters may exist but not be relevant to this specific dashboard page
|
|
127215
|
+
- Only return useAutoPatterns: false if the dashboard page is actually meant to configure those parameters
|
|
127216
|
+
- Ignore embedded script parameters that don't apply to the current functionality
|
|
127217
|
+
|
|
127218
|
+
Return useAutoPatterns: false if:
|
|
127219
|
+
1. The dashboard page description specifically mentions configuring/managing embedded script settings
|
|
127220
|
+
2. The dashboard page is clearly meant to configure widgets, scripts, or embedded functionality
|
|
127221
|
+
3. The embedded script parameters are directly relevant to what this dashboard page should do
|
|
127222
|
+
|
|
127223
|
+
Do NOT return useAutoPatterns: false just because parameters exist - only if they're relevant to this page.
|
|
127224
|
+
|
|
127225
|
+
IMPORTANT: MULTIPLE COLLECTIONS
|
|
126680
127226
|
Auto-patterns ONLY supports displaying/managing data from a SINGLE collection.
|
|
127227
|
+
|
|
127228
|
+
RELEVANCE MATTERS: You may receive information about multiple collections, but only consider collections that are RELEVANT to the current dashboard page use case.
|
|
127229
|
+
- Not every collection needs to be displayed or managed in this dashboard page
|
|
127230
|
+
- Only focus on collections that are directly related to what the user wants to accomplish
|
|
127231
|
+
- Ignore collections that don't apply to the current functionality
|
|
127232
|
+
|
|
126681
127233
|
Return useAutoPatterns: false if the dashboard page requires:
|
|
126682
127234
|
- Joining or combining data from multiple collections
|
|
126683
127235
|
- Displaying fields from different collections together
|
|
@@ -126692,10 +127244,12 @@ Examples requiring MULTIPLE collections (return useAutoPatterns: false):
|
|
|
126692
127244
|
- "Show inventory items with supplier details" (inventory + suppliers)
|
|
126693
127245
|
|
|
126694
127246
|
ONLY return useAutoPatterns: true if the page description can be fully satisfied by:
|
|
126695
|
-
- Reading/displaying items from ONE collection only
|
|
126696
|
-
- Creating/editing items in ONE collection only
|
|
126697
|
-
- Deleting items from ONE collection only
|
|
126698
|
-
- Filtering/sorting items in ONE collection only
|
|
127247
|
+
- Reading/displaying items from ONE relevant collection only
|
|
127248
|
+
- Creating/editing items in ONE relevant collection only
|
|
127249
|
+
- Deleting items from ONE relevant collection only
|
|
127250
|
+
- Filtering/sorting items in ONE relevant collection only
|
|
127251
|
+
- NO embedded script configuration or settings management
|
|
127252
|
+
- The collection is actually relevant to what the user wants to accomplish
|
|
126699
127253
|
|
|
126700
127254
|
Return your response in the following format:
|
|
126701
127255
|
- If useAutoPatterns is false: return only useAutoPatterns
|
|
@@ -126779,40 +127333,17 @@ var require_DashboardDecisionAgent = __commonJS({
|
|
|
126779
127333
|
buildSystemPrompt() {
|
|
126780
127334
|
return (0, autoPatternPrompt_1.autoPatternDecisionPrompt)();
|
|
126781
127335
|
}
|
|
126782
|
-
|
|
126783
|
-
|
|
126784
|
-
|
|
126785
|
-
</user-request>
|
|
126786
|
-
|
|
126787
|
-
<dashboard-page-description>
|
|
126788
|
-
Dashboard Page Name: ${extension.name}
|
|
126789
|
-
Dashboard Page Description: ${extension.description}
|
|
126790
|
-
</dashboard-page-description>
|
|
126791
|
-
|
|
126792
|
-
<available-collections>
|
|
126793
|
-
${collectionsInfo}
|
|
126794
|
-
</available-collections>`;
|
|
126795
|
-
}
|
|
126796
|
-
async generate({ blueprint, extension, planAndResources }) {
|
|
126797
|
-
if (!planAndResources.createdCollections?.length) {
|
|
127336
|
+
async generate(params) {
|
|
127337
|
+
const { planAndResources } = params;
|
|
127338
|
+
if (!planAndResources?.createdCollections?.length) {
|
|
126798
127339
|
return {
|
|
126799
127340
|
useAutoPatterns: false
|
|
126800
127341
|
};
|
|
126801
127342
|
}
|
|
126802
|
-
const { createdCollections } = planAndResources;
|
|
126803
127343
|
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
|
|
126804
|
-
const collectionsInfo = createdCollections.map((collection, index) => {
|
|
126805
|
-
const userFields = collection.fields?.filter((field) => !field.key?.startsWith("_")) || [];
|
|
126806
|
-
const fieldsDetail = userFields.map((f) => ` - ${f.key} (${f.type}): ${f.displayName}`).join("\n");
|
|
126807
|
-
return `
|
|
126808
|
-
Collection ${index + 1}:
|
|
126809
|
-
ID: ${collection.id}
|
|
126810
|
-
Display Name: ${collection.displayName}
|
|
126811
|
-
Fields (${userFields.length}):
|
|
126812
|
-
${fieldsDetail}`;
|
|
126813
|
-
}).join("\n");
|
|
126814
127344
|
const systemPrompt = this.buildSystemPrompt();
|
|
126815
|
-
const
|
|
127345
|
+
const primaryAction = "Decide whether to use auto patterns for the dashboard page";
|
|
127346
|
+
const userPrompt = (0, utils_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
|
|
126816
127347
|
const result = await (0, ai_1.generateObject)({
|
|
126817
127348
|
model,
|
|
126818
127349
|
schema: autoPatternsLlmConfig,
|
|
@@ -127403,6 +127934,305 @@ export default withDashboard(CollectionPage);
|
|
|
127403
127934
|
}
|
|
127404
127935
|
});
|
|
127405
127936
|
|
|
127937
|
+
// dist/system-prompts/embeddedScript/embededScript.js
|
|
127938
|
+
var require_embededScript = __commonJS({
|
|
127939
|
+
"dist/system-prompts/embeddedScript/embededScript.js"(exports2) {
|
|
127940
|
+
"use strict";
|
|
127941
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
127942
|
+
exports2.embeddedScriptPrompt = void 0;
|
|
127943
|
+
var embeddedScriptPrompt = (hasDynamicParameters) => {
|
|
127944
|
+
return `
|
|
127945
|
+
<WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
|
|
127946
|
+
|
|
127947
|
+
<role>
|
|
127948
|
+
You are a senior Wix CLI App Developer Expert specialized in creating embedded scripts for Wix applications. You have deep knowledge of embedded script best practices, HTML/JavaScript injection patterns, and third-party integrations.
|
|
127949
|
+
|
|
127950
|
+
You are tasked with generating a complete Wix CLI embedded script implementation based on the user's requirements.
|
|
127951
|
+
</role>
|
|
127952
|
+
|
|
127953
|
+
<embedded_script_extension_files_and_code>
|
|
127954
|
+
<description>
|
|
127955
|
+
Embedded scripts are HTML code fragments that get injected into the DOM of Wix sites. They enable integration with third-party services, analytics tracking, advertising, and custom JavaScript functionality.
|
|
127956
|
+
|
|
127957
|
+
Each embedded script lives in its own folder under src/site/embedded-scripts/ and you generate the embedded.html file containing the HTML/JavaScript code to be injected.
|
|
127958
|
+
</description>
|
|
127959
|
+
|
|
127960
|
+
<metadata_fields>
|
|
127961
|
+
You will also specify metadata that determines how the script is injected:
|
|
127962
|
+
- scriptType: ESSENTIAL | FUNCTIONAL | ANALYTICS | ADVERTISING
|
|
127963
|
+
- placement: HEAD | BODY_START | BODY_END
|
|
127964
|
+
|
|
127965
|
+
These are returned separately from the HTML file.
|
|
127966
|
+
</metadata_fields>
|
|
127967
|
+
|
|
127968
|
+
<script_types>
|
|
127969
|
+
An enum used by consent management apps to determine whether site visitors consent to having your script run during their visit. Possible values are:
|
|
127970
|
+
- ESSENTIAL: Enables site visitors to move around the site and use essential features like secure and private areas crucial to the functioning of the site.
|
|
127971
|
+
- FUNCTIONAL: Remembers choices site visitors make to improve their experience, such as language.
|
|
127972
|
+
- ANALYTICS: Provides statistics to the site owner on how visitors use the site, such as which pages they visit. This helps improve the site by identifying errors and performance issues.
|
|
127973
|
+
- ADVERTISING: Provides visitor information to the site owner to help market their products, such as data on the impact of marketing campaigns, re-targeted advertising, and so on.
|
|
127974
|
+
An embedded script must have a type. If your script falls into more than one type, choose the option closest to the bottom of the list above. For example, if your script has Advertising and Analytics aspects, choose Advertising as its type. It's unlikely that you'll need to mark it as Essential.
|
|
127975
|
+
</script_types>
|
|
127976
|
+
|
|
127977
|
+
<placement_options>
|
|
127978
|
+
An enum indicating where in the page's DOM the HTML code will be injected. Possible values are:
|
|
127979
|
+
- HEAD: Injects the code between the page's <head> and </head> tags.
|
|
127980
|
+
- BODY_START: Injects the code immediately after the page's opening <body> tag.
|
|
127981
|
+
- BODY_END: Injects the code immediately before the page's closing </body> tag.
|
|
127982
|
+
</placement_options>
|
|
127983
|
+
|
|
127984
|
+
<template_variables>
|
|
127985
|
+
Embedded scripts support parameterization using template variable syntax {{variableName}}.
|
|
127986
|
+
- Correct: <div data-value="{{myVariable}}"></div>
|
|
127987
|
+
- Common use cases: API keys, configuration values, user-specific data
|
|
127988
|
+
</template_variables>
|
|
127989
|
+
|
|
127990
|
+
</embedded_script_extension_files_and_code>
|
|
127991
|
+
|
|
127992
|
+
<core_principles>
|
|
127993
|
+
- Do NOT invent or assume new types, modules, functions, or imports not available in standard browser APIs or explicitly imported libraries
|
|
127994
|
+
- NEVER use mocks, placeholders, or TODOs in any code
|
|
127995
|
+
- ALWAYS implement complete, production-ready functionality
|
|
127996
|
+
- Handle errors gracefully and fail silently when appropriate for embedded scripts
|
|
127997
|
+
- Minimize performance impact - embedded scripts should be lightweight and non-blocking
|
|
127998
|
+
- Follow web security best practices (avoid inline event handlers, validate data, escape user input)
|
|
127999
|
+
</core_principles>
|
|
128000
|
+
|
|
128001
|
+
<generation_requirements>
|
|
128002
|
+
1. Generate the embedded.html file with complete HTML/JavaScript implementation
|
|
128003
|
+
2. Specify appropriate scriptType based on the use case:
|
|
128004
|
+
- Analytics tools \u2192 ANALYTICS
|
|
128005
|
+
- Ad networks, marketing pixels \u2192 ADVERTISING
|
|
128006
|
+
- Core functionality \u2192 ESSENTIAL
|
|
128007
|
+
- Enhanced features \u2192 FUNCTIONAL
|
|
128008
|
+
3. Choose optimal placement:
|
|
128009
|
+
- Analytics/tracking \u2192 HEAD (initialize early)
|
|
128010
|
+
- Advertising \u2192 BODY_END (non-blocking)
|
|
128011
|
+
- Critical functionality \u2192 HEAD or BODY_START
|
|
128012
|
+
- Non-critical features \u2192 BODY_END (performance)
|
|
128013
|
+
4. Implement complete business logic with proper error handling
|
|
128014
|
+
5. Use template variables {{variableName}} for configurable values (API keys, settings, etc.)
|
|
128015
|
+
6. Include proper TypeScript imports when using external modules
|
|
128016
|
+
</generation_requirements>
|
|
128017
|
+
|
|
128018
|
+
<implementation_guidelines>
|
|
128019
|
+
|
|
128020
|
+
${hasDynamicParameters ? `
|
|
128021
|
+
<dynamic_parameters_usage>
|
|
128022
|
+
|
|
128023
|
+
<description>
|
|
128024
|
+
This embedded script uses dynamic parameters that are configured through the dashboard. These parameters are passed as template variables and should be used in your HTML/JavaScript code.
|
|
128025
|
+
</description>
|
|
128026
|
+
|
|
128027
|
+
<usage_instructions>
|
|
128028
|
+
|
|
128029
|
+
1. Template Variable Syntax:
|
|
128030
|
+
- Use {{parameterKey}} syntax to insert parameter values into your HTML
|
|
128031
|
+
- Template variables work in HTML attributes
|
|
128032
|
+
- They will be replaced with actual values when the script is injected
|
|
128033
|
+
|
|
128034
|
+
2. HTML Attributes (REQUIRED):
|
|
128035
|
+
- Store ALL parameter values in data attributes on a configuration element
|
|
128036
|
+
- Template variables can ONLY be used here, not directly in JavaScript
|
|
128037
|
+
- Example: <div id="config" data-headline="{{headline}}" data-text="{{text}}"></div>
|
|
128038
|
+
|
|
128039
|
+
3. JavaScript Access:
|
|
128040
|
+
- JavaScript must read parameter values from the data attributes
|
|
128041
|
+
- Use getAttribute() or the dataset property
|
|
128042
|
+
- Examples:
|
|
128043
|
+
const config = document.getElementById('config');
|
|
128044
|
+
const headline = config?.getAttribute('data-headline');
|
|
128045
|
+
// OR using dataset:
|
|
128046
|
+
const { headline, text } = config.dataset;
|
|
128047
|
+
|
|
128048
|
+
4. Type Safety:
|
|
128049
|
+
- Be aware of parameter types when using them in JavaScript
|
|
128050
|
+
- NUMBER types: convert with Number() or parseInt()
|
|
128051
|
+
- BOOLEAN types: compare with 'true' or 'false' strings
|
|
128052
|
+
- DATE/DATETIME: parse with new Date()
|
|
128053
|
+
|
|
128054
|
+
5. Required vs Optional:
|
|
128055
|
+
- Required parameters will always have values
|
|
128056
|
+
- Optional parameters may be empty - handle gracefully
|
|
128057
|
+
- Provide fallback values for optional parameters
|
|
128058
|
+
|
|
128059
|
+
6. Relevant Parameter Usage:
|
|
128060
|
+
- Only use dynamic parameters that are relevant to your current use case
|
|
128061
|
+
- Ignore parameters that don't apply to the functionality you're implementing
|
|
128062
|
+
- Each parameter you use should serve a clear purpose in the script's functionality
|
|
128063
|
+
- It's perfectly fine to not use all parameters if they're not applicable
|
|
128064
|
+
|
|
128065
|
+
</usage_instructions>
|
|
128066
|
+
|
|
128067
|
+
<example_patterns>
|
|
128068
|
+
|
|
128069
|
+
Pattern 1 - Configuration in Data Attributes:
|
|
128070
|
+
<div
|
|
128071
|
+
id="script-config"
|
|
128072
|
+
data-api-key="{{apiKey}}"
|
|
128073
|
+
data-enabled="{{enabled}}"
|
|
128074
|
+
data-color="{{primaryColor}}"
|
|
128075
|
+
></div>
|
|
128076
|
+
<script>
|
|
128077
|
+
const config = document.getElementById('script-config');
|
|
128078
|
+
const apiKey = config.getAttribute('data-api-key');
|
|
128079
|
+
const enabled = config.getAttribute('data-enabled') === 'true';
|
|
128080
|
+
const color = config.getAttribute('data-color');
|
|
128081
|
+
|
|
128082
|
+
if (enabled && apiKey) {
|
|
128083
|
+
// Initialize with configuration
|
|
128084
|
+
}
|
|
128085
|
+
</script>
|
|
128086
|
+
|
|
128087
|
+
Pattern 2 - Using dataset Property:
|
|
128088
|
+
<div
|
|
128089
|
+
id="script-config"
|
|
128090
|
+
data-headline="{{headline}}"
|
|
128091
|
+
data-message="{{message}}"
|
|
128092
|
+
data-image-url="{{imageUrl}}"
|
|
128093
|
+
></div>
|
|
128094
|
+
<script>
|
|
128095
|
+
const config = document.getElementById('script-config');
|
|
128096
|
+
const { headline, message, imageUrl } = config.dataset;
|
|
128097
|
+
|
|
128098
|
+
// Use the variables in your script logic
|
|
128099
|
+
if (headline) {
|
|
128100
|
+
document.querySelector('#headline').textContent = headline;
|
|
128101
|
+
}
|
|
128102
|
+
</script>
|
|
128103
|
+
|
|
128104
|
+
Pattern 3 - Conditional Logic:
|
|
128105
|
+
<div
|
|
128106
|
+
id="config"
|
|
128107
|
+
data-mode="{{activationMode}}"
|
|
128108
|
+
data-start="{{startDate}}"
|
|
128109
|
+
data-end="{{endDate}}"
|
|
128110
|
+
></div>
|
|
128111
|
+
<script>
|
|
128112
|
+
const config = document.getElementById('config');
|
|
128113
|
+
const mode = config.getAttribute('data-mode');
|
|
128114
|
+
|
|
128115
|
+
if (mode === 'timed') {
|
|
128116
|
+
const startDate = new Date(config.getAttribute('data-start'));
|
|
128117
|
+
const endDate = new Date(config.getAttribute('data-end'));
|
|
128118
|
+
const now = new Date();
|
|
128119
|
+
|
|
128120
|
+
if (now >= startDate && now <= endDate) {
|
|
128121
|
+
// Show content
|
|
128122
|
+
}
|
|
128123
|
+
} else if (mode === 'active') {
|
|
128124
|
+
// Show content immediately
|
|
128125
|
+
}
|
|
128126
|
+
</script>
|
|
128127
|
+
|
|
128128
|
+
</example_patterns>
|
|
128129
|
+
|
|
128130
|
+
<validation_requirements>
|
|
128131
|
+
- Only use dynamic parameters that are relevant to your specific use case
|
|
128132
|
+
- Ignore parameters that don't apply to the functionality being implemented
|
|
128133
|
+
- Template variables {{parameterKey}} must match the exact key names from the parameter definitions
|
|
128134
|
+
- Handle both required and optional parameters appropriately
|
|
128135
|
+
- Provide sensible default behavior when optional parameters are not set
|
|
128136
|
+
- Ensure type-appropriate usage (don't use NUMBER parameters as strings without conversion)
|
|
128137
|
+
</validation_requirements>
|
|
128138
|
+
|
|
128139
|
+
</dynamic_parameters_usage>
|
|
128140
|
+
` : ""}
|
|
128141
|
+
|
|
128142
|
+
</WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
|
|
128143
|
+
`;
|
|
128144
|
+
};
|
|
128145
|
+
exports2.embeddedScriptPrompt = embeddedScriptPrompt;
|
|
128146
|
+
}
|
|
128147
|
+
});
|
|
128148
|
+
|
|
128149
|
+
// dist/agents/EmbeddedScriptAgent.js
|
|
128150
|
+
var require_EmbeddedScriptAgent = __commonJS({
|
|
128151
|
+
"dist/agents/EmbeddedScriptAgent.js"(exports2) {
|
|
128152
|
+
"use strict";
|
|
128153
|
+
var __importDefault2 = exports2 && exports2.__importDefault || function(mod2) {
|
|
128154
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
128155
|
+
};
|
|
128156
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
128157
|
+
exports2.EmbeddedScriptAgent = exports2.EmbeddedScriptSchema = exports2.EmbeddedScriptType = exports2.EmbeddedScriptPlacement = void 0;
|
|
128158
|
+
var anthropic_1 = require_dist5();
|
|
128159
|
+
var ai_1 = require_dist9();
|
|
128160
|
+
var utils_1 = require_utils14();
|
|
128161
|
+
var load_examples_1 = require_load_examples();
|
|
128162
|
+
var zod_1 = __importDefault2(require_zod());
|
|
128163
|
+
var embededScript_1 = require_embededScript();
|
|
128164
|
+
var EmbeddedScriptPlacement;
|
|
128165
|
+
(function(EmbeddedScriptPlacement2) {
|
|
128166
|
+
EmbeddedScriptPlacement2["HEAD"] = "HEAD";
|
|
128167
|
+
EmbeddedScriptPlacement2["BODY_START"] = "BODY_START";
|
|
128168
|
+
EmbeddedScriptPlacement2["BODY_END"] = "BODY_END";
|
|
128169
|
+
})(EmbeddedScriptPlacement || (exports2.EmbeddedScriptPlacement = EmbeddedScriptPlacement = {}));
|
|
128170
|
+
var EmbeddedScriptType;
|
|
128171
|
+
(function(EmbeddedScriptType2) {
|
|
128172
|
+
EmbeddedScriptType2["ESSENTIAL"] = "ESSENTIAL";
|
|
128173
|
+
EmbeddedScriptType2["FUNCTIONAL"] = "FUNCTIONAL";
|
|
128174
|
+
EmbeddedScriptType2["ANALYTICS"] = "ANALYTICS";
|
|
128175
|
+
EmbeddedScriptType2["ADVERTISING"] = "ADVERTISING";
|
|
128176
|
+
})(EmbeddedScriptType || (exports2.EmbeddedScriptType = EmbeddedScriptType = {}));
|
|
128177
|
+
exports2.EmbeddedScriptSchema = zod_1.default.object({
|
|
128178
|
+
files: zod_1.default.array(utils_1.FileItemSchema).default([]),
|
|
128179
|
+
scriptType: zod_1.default.enum(Object.values(EmbeddedScriptType)),
|
|
128180
|
+
placement: zod_1.default.enum(Object.values(EmbeddedScriptPlacement))
|
|
128181
|
+
});
|
|
128182
|
+
var EmbeddedScriptAgent = class {
|
|
128183
|
+
constructor(apiKey) {
|
|
128184
|
+
this.apiKey = apiKey;
|
|
128185
|
+
this.name = "EmbeddedScriptAgent";
|
|
128186
|
+
}
|
|
128187
|
+
async buildSystemPrompt(hasDynamicParameters) {
|
|
128188
|
+
return (0, embededScript_1.embeddedScriptPrompt)(hasDynamicParameters);
|
|
128189
|
+
}
|
|
128190
|
+
async generate(params) {
|
|
128191
|
+
const { blueprint, planAndResources } = params;
|
|
128192
|
+
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.EmbeddedScript]);
|
|
128193
|
+
const hasDynamicParameters = Boolean(planAndResources?.embeddedScriptParameters && planAndResources.embeddedScriptParameters.length > 0);
|
|
128194
|
+
const systemPrompt = `${await this.buildSystemPrompt(hasDynamicParameters)}
|
|
128195
|
+
${examples}
|
|
128196
|
+
`;
|
|
128197
|
+
console.log(`Embedded Script Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
|
|
128198
|
+
const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
|
|
128199
|
+
const primaryAction = `Customize the Wix CLI embedded script scaffolding for the app ${appName}`;
|
|
128200
|
+
const userMessage = (0, utils_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
|
|
128201
|
+
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-sonnet-4-20250514");
|
|
128202
|
+
const result = await (0, ai_1.generateObject)({
|
|
128203
|
+
model,
|
|
128204
|
+
schema: exports2.EmbeddedScriptSchema,
|
|
128205
|
+
messages: [
|
|
128206
|
+
{
|
|
128207
|
+
role: "system",
|
|
128208
|
+
content: systemPrompt,
|
|
128209
|
+
providerOptions: (0, utils_1.withCaching)("1h")
|
|
128210
|
+
},
|
|
128211
|
+
{
|
|
128212
|
+
role: "user",
|
|
128213
|
+
content: userMessage
|
|
128214
|
+
}
|
|
128215
|
+
],
|
|
128216
|
+
experimental_telemetry: {
|
|
128217
|
+
isEnabled: true,
|
|
128218
|
+
functionId: this.name
|
|
128219
|
+
},
|
|
128220
|
+
maxOutputTokens: 1e4,
|
|
128221
|
+
maxRetries: 3,
|
|
128222
|
+
temperature: 0
|
|
128223
|
+
});
|
|
128224
|
+
return {
|
|
128225
|
+
files: result.object.files,
|
|
128226
|
+
scriptType: result.object.scriptType,
|
|
128227
|
+
placement: result.object.placement
|
|
128228
|
+
};
|
|
128229
|
+
}
|
|
128230
|
+
};
|
|
128231
|
+
exports2.EmbeddedScriptAgent = EmbeddedScriptAgent;
|
|
128232
|
+
exports2.default = EmbeddedScriptAgent;
|
|
128233
|
+
}
|
|
128234
|
+
});
|
|
128235
|
+
|
|
127406
128236
|
// dist/agents/AgentsFactory.js
|
|
127407
128237
|
var require_AgentsFactory = __commonJS({
|
|
127408
128238
|
"dist/agents/AgentsFactory.js"(exports2) {
|
|
@@ -127424,6 +128254,7 @@ var require_AgentsFactory = __commonJS({
|
|
|
127424
128254
|
var DashboardPageAgent_1 = __importDefault2(require_DashboardPageAgent());
|
|
127425
128255
|
var DashboardDecisionAgent_1 = require_DashboardDecisionAgent();
|
|
127426
128256
|
var AutoPatternsGenerator_1 = require_AutoPatternsGenerator();
|
|
128257
|
+
var EmbeddedScriptAgent_1 = __importDefault2(require_EmbeddedScriptAgent());
|
|
127427
128258
|
var AgentsFactory = class {
|
|
127428
128259
|
constructor(apiKey) {
|
|
127429
128260
|
this.apiKey = apiKey;
|
|
@@ -127452,6 +128283,8 @@ var require_AgentsFactory = __commonJS({
|
|
|
127452
128283
|
return new CustomElementAgent_1.default(this.apiKey);
|
|
127453
128284
|
case types_1.ExtensionType.BACKEND_API:
|
|
127454
128285
|
return new BackendApiAgent_1.BackendApiAgent(this.apiKey);
|
|
128286
|
+
case "EMBEDDED_SCRIPT":
|
|
128287
|
+
return new EmbeddedScriptAgent_1.default(this.apiKey);
|
|
127455
128288
|
default:
|
|
127456
128289
|
throw new Error(`Unsupported extension type for AI customization: ${extension.type}`);
|
|
127457
128290
|
}
|
|
@@ -130025,8 +130858,9 @@ var require_extensionGenerators = __commonJS({
|
|
|
130025
130858
|
var ditto_scaffolding_1 = require_dist13();
|
|
130026
130859
|
var types_1 = require_types_impl();
|
|
130027
130860
|
var ditto_scaffolding_2 = require_dist13();
|
|
130861
|
+
var EmbeddedScriptAgent_1 = require_EmbeddedScriptAgent();
|
|
130028
130862
|
var ExtensionFactory = class {
|
|
130029
|
-
static generateExtension(extension, outputPath, scaffoldPath) {
|
|
130863
|
+
static generateExtension({ extension, outputPath, scaffoldPath, generatedConfig }) {
|
|
130030
130864
|
const scaffoldDir = path_1.default.dirname(scaffoldPath);
|
|
130031
130865
|
const id = (0, crypto_1.randomUUID)();
|
|
130032
130866
|
switch (extension.type) {
|
|
@@ -130084,6 +130918,23 @@ var require_extensionGenerators = __commonJS({
|
|
|
130084
130918
|
});
|
|
130085
130919
|
break;
|
|
130086
130920
|
}
|
|
130921
|
+
case types_1.ExtensionType.EMBEDDED_SCRIPT: {
|
|
130922
|
+
const name = extension.name || "My Embedded Script";
|
|
130923
|
+
const { placement, scriptType } = generatedConfig?.type === types_1.ExtensionType.EMBEDDED_SCRIPT ? generatedConfig : {
|
|
130924
|
+
placement: EmbeddedScriptAgent_1.EmbeddedScriptPlacement.HEAD,
|
|
130925
|
+
scriptType: EmbeddedScriptAgent_1.EmbeddedScriptType.ESSENTIAL
|
|
130926
|
+
};
|
|
130927
|
+
const extensionConfig = this.createEmbeddedScriptData(id, name, scaffoldDir, placement, scriptType);
|
|
130928
|
+
writeExtensionFile({
|
|
130929
|
+
outputPath,
|
|
130930
|
+
name,
|
|
130931
|
+
builderMethodName: "embeddedScript",
|
|
130932
|
+
extensionConfig,
|
|
130933
|
+
extensionType: extension.type,
|
|
130934
|
+
scaffoldDir
|
|
130935
|
+
});
|
|
130936
|
+
break;
|
|
130937
|
+
}
|
|
130087
130938
|
default:
|
|
130088
130939
|
console.log(`Skipping extension type: ${extension.type}. It doesn't need presence in the extensions.ts file (e.g. Backend API is astro only)`);
|
|
130089
130940
|
return;
|
|
@@ -130165,6 +131016,16 @@ var require_extensionGenerators = __commonJS({
|
|
|
130165
131016
|
}
|
|
130166
131017
|
};
|
|
130167
131018
|
}
|
|
131019
|
+
static createEmbeddedScriptData(id, name, scaffoldDir, placement, scriptType) {
|
|
131020
|
+
const source = "./" + path_1.default.join(scaffoldDir, "embedded.html").replace(/^src\//, "");
|
|
131021
|
+
return {
|
|
131022
|
+
id,
|
|
131023
|
+
name,
|
|
131024
|
+
source,
|
|
131025
|
+
placement,
|
|
131026
|
+
scriptType
|
|
131027
|
+
};
|
|
131028
|
+
}
|
|
130168
131029
|
};
|
|
130169
131030
|
exports2.ExtensionFactory = ExtensionFactory;
|
|
130170
131031
|
ExtensionFactory.servicePluginBuilderMap = {
|
|
@@ -136893,6 +137754,7 @@ var require_orchestrator = __commonJS({
|
|
|
136893
137754
|
this.emitEvent("planner:start", {});
|
|
136894
137755
|
const planner = this.agentsFactory.getAgent({ type: "PLANNER" });
|
|
136895
137756
|
const plan = await planner.generate(blueprint);
|
|
137757
|
+
console.log("Plan", JSON.stringify(plan));
|
|
136896
137758
|
this.emitEvent("planner:done", {});
|
|
136897
137759
|
const createdCollections = [];
|
|
136898
137760
|
if (plan?.collections?.length > 0) {
|
|
@@ -136918,6 +137780,9 @@ var require_orchestrator = __commonJS({
|
|
|
136918
137780
|
if (plan?.apiSpec) {
|
|
136919
137781
|
result.apiSpec = plan.apiSpec;
|
|
136920
137782
|
}
|
|
137783
|
+
if (plan?.embeddedScriptParameters) {
|
|
137784
|
+
result.embeddedScriptParameters = plan.embeddedScriptParameters;
|
|
137785
|
+
}
|
|
136921
137786
|
return result;
|
|
136922
137787
|
}
|
|
136923
137788
|
async runIterationPlanningAndAugmentExtensions(outputPath, chatHistory) {
|
|
@@ -136945,6 +137810,13 @@ var require_orchestrator = __commonJS({
|
|
|
136945
137810
|
outputPath,
|
|
136946
137811
|
planAndResources
|
|
136947
137812
|
});
|
|
137813
|
+
case types_1.ExtensionType.EMBEDDED_SCRIPT:
|
|
137814
|
+
return this.processEmbeddedScript({
|
|
137815
|
+
extension,
|
|
137816
|
+
blueprint,
|
|
137817
|
+
outputPath,
|
|
137818
|
+
planAndResources
|
|
137819
|
+
});
|
|
136948
137820
|
default:
|
|
136949
137821
|
return this.processStandardExtension({
|
|
136950
137822
|
extension,
|
|
@@ -136954,11 +137826,60 @@ var require_orchestrator = __commonJS({
|
|
|
136954
137826
|
});
|
|
136955
137827
|
}
|
|
136956
137828
|
}
|
|
137829
|
+
async processEmbeddedScript(opts) {
|
|
137830
|
+
const { extension, blueprint, outputPath, planAndResources } = opts;
|
|
137831
|
+
this.emitEvent("scaffold:start", { extension });
|
|
137832
|
+
const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
|
|
137833
|
+
if (!scaffolds || scaffolds.length === 0) {
|
|
137834
|
+
throw new Error(`\u274C Failed to scaffold ${extension.type}`);
|
|
137835
|
+
}
|
|
137836
|
+
const scaffold = scaffolds[0];
|
|
137837
|
+
this.emitEvent("scaffold:done", {
|
|
137838
|
+
extension,
|
|
137839
|
+
scaffoldPath: scaffolds.map((s) => s.path).join(", ")
|
|
137840
|
+
});
|
|
137841
|
+
const embeddedScriptAgent = this.agentsFactory.getAgent({
|
|
137842
|
+
type: "EMBEDDED_SCRIPT"
|
|
137843
|
+
});
|
|
137844
|
+
this.emitEvent("agent:start", {
|
|
137845
|
+
extension,
|
|
137846
|
+
name: embeddedScriptAgent.name
|
|
137847
|
+
});
|
|
137848
|
+
const { files, scriptType, placement } = await embeddedScriptAgent.generate({
|
|
137849
|
+
extension,
|
|
137850
|
+
blueprint,
|
|
137851
|
+
scaffold,
|
|
137852
|
+
basePath: outputPath,
|
|
137853
|
+
planAndResources
|
|
137854
|
+
});
|
|
137855
|
+
this.writeFile(files, outputPath);
|
|
137856
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
137857
|
+
extension,
|
|
137858
|
+
outputPath,
|
|
137859
|
+
scaffoldPath: scaffold.path,
|
|
137860
|
+
generatedConfig: {
|
|
137861
|
+
type: types_1.ExtensionType.EMBEDDED_SCRIPT,
|
|
137862
|
+
scriptType,
|
|
137863
|
+
placement
|
|
137864
|
+
}
|
|
137865
|
+
});
|
|
137866
|
+
this.emitEvent("agent:done", {
|
|
137867
|
+
extension,
|
|
137868
|
+
name: embeddedScriptAgent.name,
|
|
137869
|
+
files
|
|
137870
|
+
});
|
|
137871
|
+
}
|
|
136957
137872
|
async processDashboardPage(opts) {
|
|
137873
|
+
const { extension, blueprint, outputPath, planAndResources } = opts;
|
|
136958
137874
|
const decisionAgent = this.agentsFactory.getAgent({
|
|
136959
137875
|
type: "DASHBOARD_DECISION"
|
|
136960
137876
|
});
|
|
136961
|
-
const decision = await decisionAgent.generate(
|
|
137877
|
+
const decision = await decisionAgent.generate({
|
|
137878
|
+
extension,
|
|
137879
|
+
blueprint,
|
|
137880
|
+
planAndResources,
|
|
137881
|
+
basePath: outputPath
|
|
137882
|
+
});
|
|
136962
137883
|
const useAutoPatterns = decision.useAutoPatterns && decision.schema && decision.relevantCollectionId;
|
|
136963
137884
|
if (!useAutoPatterns) {
|
|
136964
137885
|
console.log("\u{1F3A8} Using custom code generation for dashboard");
|
|
@@ -136966,8 +137887,7 @@ var require_orchestrator = __commonJS({
|
|
|
136966
137887
|
return;
|
|
136967
137888
|
}
|
|
136968
137889
|
console.log("\u{1F3AF} Using auto-patterns for dashboard generation");
|
|
136969
|
-
const
|
|
136970
|
-
const relevantCollection = createdCollections.find((c) => c.id === decision.relevantCollectionId);
|
|
137890
|
+
const relevantCollection = planAndResources.createdCollections?.find((c) => c.id === decision.relevantCollectionId);
|
|
136971
137891
|
if (!relevantCollection) {
|
|
136972
137892
|
throw new Error(`\u274C Collection with ID ${decision.relevantCollectionId} not found in created collections`);
|
|
136973
137893
|
}
|
|
@@ -136985,7 +137905,11 @@ var require_orchestrator = __commonJS({
|
|
|
136985
137905
|
});
|
|
136986
137906
|
this.writeFile(files, outputPath);
|
|
136987
137907
|
const pagePath = files[0].path || "";
|
|
136988
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(
|
|
137908
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
137909
|
+
extension,
|
|
137910
|
+
outputPath,
|
|
137911
|
+
scaffoldPath: pagePath
|
|
137912
|
+
});
|
|
136989
137913
|
this.emitEvent("agent:done", {
|
|
136990
137914
|
extension,
|
|
136991
137915
|
name: "AutoPatternsGenerator",
|
|
@@ -137022,7 +137946,11 @@ var require_orchestrator = __commonJS({
|
|
|
137022
137946
|
basePath: outputPath
|
|
137023
137947
|
});
|
|
137024
137948
|
this.writeFile(files, outputPath);
|
|
137025
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(
|
|
137949
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
137950
|
+
extension,
|
|
137951
|
+
outputPath,
|
|
137952
|
+
scaffoldPath: scaffold.path
|
|
137953
|
+
});
|
|
137026
137954
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
137027
137955
|
}
|
|
137028
137956
|
async processStandardExtension({ extension, blueprint, outputPath, planAndResources }) {
|
|
@@ -137046,7 +137974,11 @@ var require_orchestrator = __commonJS({
|
|
|
137046
137974
|
basePath: outputPath
|
|
137047
137975
|
});
|
|
137048
137976
|
this.writeFile(files, outputPath);
|
|
137049
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(
|
|
137977
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
137978
|
+
extension,
|
|
137979
|
+
outputPath,
|
|
137980
|
+
scaffoldPath: scaffold.path
|
|
137981
|
+
});
|
|
137050
137982
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
137051
137983
|
}
|
|
137052
137984
|
async processMultipleServicePluginScaffolds({ extension, blueprint, outputPath, planAndResources, scaffolds }) {
|
|
@@ -137075,7 +138007,11 @@ var require_orchestrator = __commonJS({
|
|
|
137075
138007
|
basePath: outputPath
|
|
137076
138008
|
});
|
|
137077
138009
|
this.writeFile(files, outputPath);
|
|
137078
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(
|
|
138010
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
138011
|
+
extension: spiExtension,
|
|
138012
|
+
outputPath,
|
|
138013
|
+
scaffoldPath: scaffold.path
|
|
138014
|
+
});
|
|
137079
138015
|
this.emitEvent("agent:done", {
|
|
137080
138016
|
extension: spiExtension,
|
|
137081
138017
|
name: agent.name,
|
|
@@ -137117,7 +138053,11 @@ var require_orchestrator = __commonJS({
|
|
|
137117
138053
|
basePath: outputPath
|
|
137118
138054
|
});
|
|
137119
138055
|
this.writeFile(files, outputPath);
|
|
137120
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(
|
|
138056
|
+
extensionGenerators_1.ExtensionFactory.generateExtension({
|
|
138057
|
+
extension,
|
|
138058
|
+
outputPath,
|
|
138059
|
+
scaffoldPath: scaffold.path
|
|
138060
|
+
});
|
|
137121
138061
|
this.emitEvent("agent:done", {
|
|
137122
138062
|
extension,
|
|
137123
138063
|
name: agent.name,
|