@wix/ditto-codegen-public 1.0.46 → 1.0.47
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/out.js
CHANGED
|
@@ -117469,7 +117469,7 @@ var require_utils14 = __commonJS({
|
|
|
117469
117469
|
return loadRelevantFiles(srcOnlyPaths, basePath).join("\n\n---\n\n");
|
|
117470
117470
|
}
|
|
117471
117471
|
var buildUserPromptForCodeGenerationAgent = (params, primaryAction) => {
|
|
117472
|
-
const { extension, blueprint, scaffold, userRequestSummary, relevantFilePaths,
|
|
117472
|
+
const { extension, blueprint, scaffold, userRequestSummary, relevantFilePaths, planAndResources, basePath } = params;
|
|
117473
117473
|
const contextSections = [];
|
|
117474
117474
|
if (extension.name)
|
|
117475
117475
|
contextSections.push(`Extension Name: ${extension.name}`);
|
|
@@ -117497,10 +117497,15 @@ Path: ${scaffold.path}
|
|
|
117497
117497
|
${scaffold.content}
|
|
117498
117498
|
\`\`\``);
|
|
117499
117499
|
}
|
|
117500
|
-
if (createdCollections) {
|
|
117500
|
+
if (planAndResources?.createdCollections) {
|
|
117501
117501
|
contextSections.push(`
|
|
117502
117502
|
## CREATED COLLECTIONS
|
|
117503
|
-
${JSON.stringify(createdCollections, null, 2)}`);
|
|
117503
|
+
${JSON.stringify(planAndResources.createdCollections, null, 2)}`);
|
|
117504
|
+
}
|
|
117505
|
+
if (planAndResources?.apiSpec) {
|
|
117506
|
+
contextSections.push(`
|
|
117507
|
+
## API SPEC
|
|
117508
|
+
${JSON.stringify(planAndResources.apiSpec, null, 2)}`);
|
|
117504
117509
|
}
|
|
117505
117510
|
const userMessage = `${primaryAction}:
|
|
117506
117511
|
${contextSections.join("\n")}`;
|
|
@@ -117761,10 +117766,10 @@ var require_SPIAgent = __commonJS({
|
|
|
117761
117766
|
return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData);
|
|
117762
117767
|
}
|
|
117763
117768
|
async generate(params) {
|
|
117764
|
-
const { extension, blueprint,
|
|
117769
|
+
const { extension, blueprint, planAndResources } = params;
|
|
117765
117770
|
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.ServicePluginExtension]);
|
|
117766
117771
|
const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
|
|
117767
|
-
const useData = Boolean(createdCollections
|
|
117772
|
+
const useData = Boolean(planAndResources?.createdCollections?.length);
|
|
117768
117773
|
const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData)}
|
|
117769
117774
|
${examples}
|
|
117770
117775
|
`;
|
|
@@ -117804,6 +117809,196 @@ ${examples}
|
|
|
117804
117809
|
}
|
|
117805
117810
|
});
|
|
117806
117811
|
|
|
117812
|
+
// dist/system-prompts/planner/apiSpec.js
|
|
117813
|
+
var require_apiSpec = __commonJS({
|
|
117814
|
+
"dist/system-prompts/planner/apiSpec.js"(exports2) {
|
|
117815
|
+
"use strict";
|
|
117816
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
117817
|
+
exports2.apiSpecPrompt = void 0;
|
|
117818
|
+
var todoExample = {
|
|
117819
|
+
name: "Todo API",
|
|
117820
|
+
description: "A simple todo application API for managing tasks",
|
|
117821
|
+
endpoints: [
|
|
117822
|
+
{
|
|
117823
|
+
id: "get-todos",
|
|
117824
|
+
path: "/api/todos",
|
|
117825
|
+
method: "GET",
|
|
117826
|
+
name: "Get All Todos",
|
|
117827
|
+
description: "Retrieve all todo items",
|
|
117828
|
+
parameters: [],
|
|
117829
|
+
response: {
|
|
117830
|
+
statusCode: 200,
|
|
117831
|
+
type: "array"
|
|
117832
|
+
}
|
|
117833
|
+
},
|
|
117834
|
+
{
|
|
117835
|
+
id: "create-todo",
|
|
117836
|
+
path: "/api/todos",
|
|
117837
|
+
method: "POST",
|
|
117838
|
+
name: "Create Todo",
|
|
117839
|
+
description: "Create a new todo item",
|
|
117840
|
+
parameters: [
|
|
117841
|
+
{
|
|
117842
|
+
name: "title",
|
|
117843
|
+
type: "string",
|
|
117844
|
+
required: true,
|
|
117845
|
+
location: "body"
|
|
117846
|
+
},
|
|
117847
|
+
{
|
|
117848
|
+
name: "description",
|
|
117849
|
+
type: "string",
|
|
117850
|
+
required: false,
|
|
117851
|
+
location: "body"
|
|
117852
|
+
},
|
|
117853
|
+
{
|
|
117854
|
+
name: "completed",
|
|
117855
|
+
type: "boolean",
|
|
117856
|
+
required: false,
|
|
117857
|
+
location: "body"
|
|
117858
|
+
}
|
|
117859
|
+
],
|
|
117860
|
+
response: {
|
|
117861
|
+
statusCode: 201,
|
|
117862
|
+
type: "object"
|
|
117863
|
+
}
|
|
117864
|
+
},
|
|
117865
|
+
{
|
|
117866
|
+
id: "get-todo-by-id",
|
|
117867
|
+
path: "/api/todos/[id]",
|
|
117868
|
+
method: "GET",
|
|
117869
|
+
name: "Get Todo by ID",
|
|
117870
|
+
description: "Retrieve a specific todo item by its ID",
|
|
117871
|
+
parameters: [
|
|
117872
|
+
{
|
|
117873
|
+
name: "id",
|
|
117874
|
+
type: "string",
|
|
117875
|
+
required: true,
|
|
117876
|
+
location: "path"
|
|
117877
|
+
}
|
|
117878
|
+
],
|
|
117879
|
+
response: {
|
|
117880
|
+
statusCode: 200,
|
|
117881
|
+
type: "object"
|
|
117882
|
+
}
|
|
117883
|
+
},
|
|
117884
|
+
{
|
|
117885
|
+
id: "update-todo",
|
|
117886
|
+
path: "/api/todos/[id]",
|
|
117887
|
+
method: "PUT",
|
|
117888
|
+
name: "Update Todo",
|
|
117889
|
+
description: "Update an existing todo item",
|
|
117890
|
+
parameters: [
|
|
117891
|
+
{
|
|
117892
|
+
name: "id",
|
|
117893
|
+
type: "string",
|
|
117894
|
+
required: true,
|
|
117895
|
+
location: "path"
|
|
117896
|
+
},
|
|
117897
|
+
{
|
|
117898
|
+
name: "title",
|
|
117899
|
+
type: "string",
|
|
117900
|
+
required: false,
|
|
117901
|
+
location: "body"
|
|
117902
|
+
},
|
|
117903
|
+
{
|
|
117904
|
+
name: "description",
|
|
117905
|
+
type: "string",
|
|
117906
|
+
required: false,
|
|
117907
|
+
location: "body"
|
|
117908
|
+
},
|
|
117909
|
+
{
|
|
117910
|
+
name: "completed",
|
|
117911
|
+
type: "boolean",
|
|
117912
|
+
required: false,
|
|
117913
|
+
location: "body"
|
|
117914
|
+
}
|
|
117915
|
+
],
|
|
117916
|
+
response: {
|
|
117917
|
+
statusCode: 200,
|
|
117918
|
+
type: "object"
|
|
117919
|
+
}
|
|
117920
|
+
},
|
|
117921
|
+
{
|
|
117922
|
+
id: "delete-todo",
|
|
117923
|
+
path: "/api/todos/[id]",
|
|
117924
|
+
method: "DELETE",
|
|
117925
|
+
name: "Delete Todo",
|
|
117926
|
+
description: "Delete a todo item",
|
|
117927
|
+
parameters: [
|
|
117928
|
+
{
|
|
117929
|
+
name: "id",
|
|
117930
|
+
type: "string",
|
|
117931
|
+
required: true,
|
|
117932
|
+
location: "path"
|
|
117933
|
+
}
|
|
117934
|
+
],
|
|
117935
|
+
response: {
|
|
117936
|
+
statusCode: 204,
|
|
117937
|
+
type: "object"
|
|
117938
|
+
}
|
|
117939
|
+
}
|
|
117940
|
+
],
|
|
117941
|
+
dataModels: [
|
|
117942
|
+
{
|
|
117943
|
+
name: "Todo",
|
|
117944
|
+
properties: {
|
|
117945
|
+
id: {
|
|
117946
|
+
type: "string",
|
|
117947
|
+
required: true
|
|
117948
|
+
},
|
|
117949
|
+
title: {
|
|
117950
|
+
type: "string",
|
|
117951
|
+
required: true
|
|
117952
|
+
},
|
|
117953
|
+
description: {
|
|
117954
|
+
type: "string",
|
|
117955
|
+
required: false
|
|
117956
|
+
},
|
|
117957
|
+
completed: {
|
|
117958
|
+
type: "boolean",
|
|
117959
|
+
required: true
|
|
117960
|
+
},
|
|
117961
|
+
createdAt: {
|
|
117962
|
+
type: "string",
|
|
117963
|
+
required: true
|
|
117964
|
+
},
|
|
117965
|
+
updatedAt: {
|
|
117966
|
+
type: "string",
|
|
117967
|
+
required: true
|
|
117968
|
+
}
|
|
117969
|
+
}
|
|
117970
|
+
}
|
|
117971
|
+
]
|
|
117972
|
+
};
|
|
117973
|
+
var apiSpecPrompt = () => `
|
|
117974
|
+
<API_SPEC_PLANNER_SYSTEM_PROMPT>
|
|
117975
|
+
|
|
117976
|
+
<role>
|
|
117977
|
+
You are a Fullstack API Endpoints planning expert.
|
|
117978
|
+
Given a blueprint describing an app (name, summary, and extensions), you must produce a concrete API spec.
|
|
117979
|
+
|
|
117980
|
+
Your output must be strictly JSON that conforms to the provided schema (no markdown).
|
|
117981
|
+
</role>
|
|
117982
|
+
|
|
117983
|
+
<constraints>
|
|
117984
|
+
- An API Spec is only needed if the blueprint contains an extension with type "BACKEND_API".
|
|
117985
|
+
</constraints>
|
|
117986
|
+
|
|
117987
|
+
<example_output>
|
|
117988
|
+
Expected plan (abbreviated):
|
|
117989
|
+
|
|
117990
|
+
\`\`\`
|
|
117991
|
+
${JSON.stringify({
|
|
117992
|
+
apiSpec: todoExample
|
|
117993
|
+
}, null, 2)}
|
|
117994
|
+
\`\`\`
|
|
117995
|
+
</example_output>
|
|
117996
|
+
|
|
117997
|
+
</API_SPEC_PLANNER_SYSTEM_PROMPT>`;
|
|
117998
|
+
exports2.apiSpecPrompt = apiSpecPrompt;
|
|
117999
|
+
}
|
|
118000
|
+
});
|
|
118001
|
+
|
|
117807
118002
|
// dist/system-prompts/planner/data.js
|
|
117808
118003
|
var require_data2 = __commonJS({
|
|
117809
118004
|
"dist/system-prompts/planner/data.js"(exports2) {
|
|
@@ -117906,10 +118101,13 @@ var require_planner = __commonJS({
|
|
|
117906
118101
|
"use strict";
|
|
117907
118102
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
117908
118103
|
exports2.plannerPrompt = void 0;
|
|
118104
|
+
var apiSpec_1 = require_apiSpec();
|
|
117909
118105
|
var data_1 = require_data2();
|
|
117910
118106
|
var plannerPrompt = () => `
|
|
117911
118107
|
<WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
117912
118108
|
${(0, data_1.cmsPlannerPrompt)()}
|
|
118109
|
+
|
|
118110
|
+
${(0, apiSpec_1.apiSpecPrompt)()}
|
|
117913
118111
|
</WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
117914
118112
|
`;
|
|
117915
118113
|
exports2.plannerPrompt = plannerPrompt;
|
|
@@ -119818,6 +120016,47 @@ var require_CMSAgent = __commonJS({
|
|
|
119818
120016
|
}
|
|
119819
120017
|
});
|
|
119820
120018
|
|
|
120019
|
+
// dist/ApiSpecSchema.js
|
|
120020
|
+
var require_ApiSpecSchema = __commonJS({
|
|
120021
|
+
"dist/ApiSpecSchema.js"(exports2) {
|
|
120022
|
+
"use strict";
|
|
120023
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120024
|
+
exports2.ApiSpecSchema = void 0;
|
|
120025
|
+
var zod_1 = require_zod();
|
|
120026
|
+
var HttpMethodSchema = zod_1.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
120027
|
+
var EndpointSchema = zod_1.z.object({
|
|
120028
|
+
id: zod_1.z.string().describe("Unique identifier for the endpoint"),
|
|
120029
|
+
path: zod_1.z.string().describe("API endpoint path (e.g., '/api/users', '/api/users/[id]')"),
|
|
120030
|
+
method: HttpMethodSchema.describe("HTTP method for the endpoint"),
|
|
120031
|
+
name: zod_1.z.string().describe("Human-readable name for the endpoint"),
|
|
120032
|
+
description: zod_1.z.string().describe("What the endpoint does"),
|
|
120033
|
+
parameters: zod_1.z.array(zod_1.z.object({
|
|
120034
|
+
name: zod_1.z.string(),
|
|
120035
|
+
type: zod_1.z.enum(["string", "number", "boolean", "object", "array"]),
|
|
120036
|
+
required: zod_1.z.boolean().default(false),
|
|
120037
|
+
location: zod_1.z.enum(["path", "query", "body"]).default("body")
|
|
120038
|
+
})).default([]).describe("Input parameters"),
|
|
120039
|
+
response: zod_1.z.object({
|
|
120040
|
+
statusCode: zod_1.z.number().default(200),
|
|
120041
|
+
type: zod_1.z.enum(["string", "number", "boolean", "object", "array"]).default("object")
|
|
120042
|
+
}).describe("Expected response")
|
|
120043
|
+
});
|
|
120044
|
+
var DataModelSchema = zod_1.z.object({
|
|
120045
|
+
name: zod_1.z.string().describe("Name of the data model"),
|
|
120046
|
+
properties: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
|
|
120047
|
+
type: zod_1.z.enum(["string", "number", "boolean", "object", "array"]),
|
|
120048
|
+
required: zod_1.z.boolean().default(false)
|
|
120049
|
+
})).describe("Properties of the model")
|
|
120050
|
+
});
|
|
120051
|
+
exports2.ApiSpecSchema = zod_1.z.object({
|
|
120052
|
+
name: zod_1.z.string().describe("Name of the API"),
|
|
120053
|
+
description: zod_1.z.string().describe("Overall description of the API"),
|
|
120054
|
+
endpoints: zod_1.z.array(EndpointSchema).describe("List of API endpoints to implement"),
|
|
120055
|
+
dataModels: zod_1.z.array(DataModelSchema).default([]).describe("Shared data models/types")
|
|
120056
|
+
}).describe("Complete API specification");
|
|
120057
|
+
}
|
|
120058
|
+
});
|
|
120059
|
+
|
|
119821
120060
|
// dist/agents/PlannerAgent.js
|
|
119822
120061
|
var require_PlannerAgent = __commonJS({
|
|
119823
120062
|
"dist/agents/PlannerAgent.js"(exports2) {
|
|
@@ -119830,8 +120069,10 @@ var require_PlannerAgent = __commonJS({
|
|
|
119830
120069
|
var planner_1 = require_planner();
|
|
119831
120070
|
var CMSAgent_1 = require_CMSAgent();
|
|
119832
120071
|
var utils_1 = require_utils14();
|
|
120072
|
+
var ApiSpecSchema_1 = require_ApiSpecSchema();
|
|
119833
120073
|
exports2.PlannerOutputSchema = zod_1.z.object({
|
|
119834
|
-
collections: zod_1.z.array(CMSAgent_1.CmsCollectionSchema).default([])
|
|
120074
|
+
collections: zod_1.z.array(CMSAgent_1.CmsCollectionSchema).default([]),
|
|
120075
|
+
apiSpec: ApiSpecSchema_1.ApiSpecSchema.optional()
|
|
119835
120076
|
});
|
|
119836
120077
|
var PlannerAgent = class {
|
|
119837
120078
|
constructor(apiKey) {
|
|
@@ -121543,6 +121784,149 @@ var require_SiteComponentAgent = __commonJS({
|
|
|
121543
121784
|
}
|
|
121544
121785
|
});
|
|
121545
121786
|
|
|
121787
|
+
// dist/system-prompts/backend/backendApi.js
|
|
121788
|
+
var require_backendApi = __commonJS({
|
|
121789
|
+
"dist/system-prompts/backend/backendApi.js"(exports2) {
|
|
121790
|
+
"use strict";
|
|
121791
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121792
|
+
exports2.backendApiPrompt = void 0;
|
|
121793
|
+
var backendApiPrompt = () => {
|
|
121794
|
+
return `
|
|
121795
|
+
You are a specialized code-generation agent for creating Astro Server Endpoints (API Routes) for fullstack applications.
|
|
121796
|
+
|
|
121797
|
+
## Core Knowledge
|
|
121798
|
+
|
|
121799
|
+
### Astro Server Endpoints Overview
|
|
121800
|
+
- Astro Server Endpoints are API routes that run on the server side
|
|
121801
|
+
- They are located in the \`src/pages/api/\` directory
|
|
121802
|
+
- Each file exports named functions for HTTP methods (GET, POST, PUT, DELETE, etc.)
|
|
121803
|
+
- Files use the \`.ts\` extension and are automatically converted to API endpoints
|
|
121804
|
+
|
|
121805
|
+
### File Structure and Naming
|
|
121806
|
+
- API routes are created in \`src/pages/api/\` directory
|
|
121807
|
+
- File names become the endpoint path (e.g., \`users.ts\` \u2192 \`/api/users\`)
|
|
121808
|
+
- For dynamic routes with parameters, use square brackets in the filename (e.g., \`/api/users/[id]\`)
|
|
121809
|
+
- Dynamic parameters can be extracted at runtime using the \`params\` parameter in the function
|
|
121810
|
+
|
|
121811
|
+
Example for dynamic route:
|
|
121812
|
+
\`\`\`
|
|
121813
|
+
// src/pages/api/user/[id].ts
|
|
121814
|
+
|
|
121815
|
+
export async function GET({ params }) {
|
|
121816
|
+
const id = params.id;
|
|
121817
|
+
const user = await getUser(id);
|
|
121818
|
+
|
|
121819
|
+
if (!user) {
|
|
121820
|
+
return new Response(null, {
|
|
121821
|
+
status: 404,
|
|
121822
|
+
statusText: "Not found",
|
|
121823
|
+
});
|
|
121824
|
+
}
|
|
121825
|
+
|
|
121826
|
+
return new Response(JSON.stringify(user), {
|
|
121827
|
+
status: 200,
|
|
121828
|
+
headers: {
|
|
121829
|
+
"Content-Type": "application/json",
|
|
121830
|
+
},
|
|
121831
|
+
});
|
|
121832
|
+
}
|
|
121833
|
+
\`\`\`
|
|
121834
|
+
|
|
121835
|
+
### TypeScript Patterns
|
|
121836
|
+
- Import \`APIRoute\` type from 'astro'
|
|
121837
|
+
- Export named functions for HTTP methods: \`GET\`, \`POST\`, \`PUT\`, \`DELETE\`, \`PATCH\`
|
|
121838
|
+
- Use async/await for handling asynchronous operations
|
|
121839
|
+
- Always return a \`Response\` object
|
|
121840
|
+
|
|
121841
|
+
### Request Handling
|
|
121842
|
+
- Access request data through the \`request\` parameter
|
|
121843
|
+
- Use \`request.json()\` for POST/PUT request bodies
|
|
121844
|
+
- Use \`request.url\` for the full URL
|
|
121845
|
+
- Use \`new URL(request.url).searchParams\` for query parameters
|
|
121846
|
+
- Access headers via \`request.headers\`
|
|
121847
|
+
|
|
121848
|
+
### Response Patterns
|
|
121849
|
+
- Always return a \`Response\` object
|
|
121850
|
+
- Use \`JSON.stringify()\` for JSON responses
|
|
121851
|
+
- Set appropriate status codes (200, 201, 400, 404, 500, etc.)
|
|
121852
|
+
- Include proper headers, especially \`Content-Type: application/json\`
|
|
121853
|
+
|
|
121854
|
+
### Common Patterns
|
|
121855
|
+
- GET endpoints for data retrieval
|
|
121856
|
+
- POST endpoints for data creation
|
|
121857
|
+
- PUT/PATCH endpoints for data updates
|
|
121858
|
+
- DELETE endpoints for data removal
|
|
121859
|
+
- Use proper HTTP status codes
|
|
121860
|
+
|
|
121861
|
+
### Best Practices
|
|
121862
|
+
- Use proper TypeScript types
|
|
121863
|
+
- Return appropriate HTTP status codes
|
|
121864
|
+
- Include proper headers
|
|
121865
|
+
- Use async/await for asynchronous operations
|
|
121866
|
+
- Keep endpoints focused and single-purpose
|
|
121867
|
+
|
|
121868
|
+
## Your Task
|
|
121869
|
+
Generate clean, well-structured Astro Server Endpoints based on the API Spec that follow these patterns and best practices.
|
|
121870
|
+
Focus on creating maintainable, secure, and efficient API routes that integrate well with frontend applications.
|
|
121871
|
+
`;
|
|
121872
|
+
};
|
|
121873
|
+
exports2.backendApiPrompt = backendApiPrompt;
|
|
121874
|
+
}
|
|
121875
|
+
});
|
|
121876
|
+
|
|
121877
|
+
// dist/agents/BackendApiAgent.js
|
|
121878
|
+
var require_BackendApiAgent = __commonJS({
|
|
121879
|
+
"dist/agents/BackendApiAgent.js"(exports2) {
|
|
121880
|
+
"use strict";
|
|
121881
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121882
|
+
exports2.BackendApiAgent = void 0;
|
|
121883
|
+
var anthropic_1 = require_dist5();
|
|
121884
|
+
var backendApi_1 = require_backendApi();
|
|
121885
|
+
var utils_1 = require_utils14();
|
|
121886
|
+
var ai_1 = require_dist7();
|
|
121887
|
+
var BackendApiAgent = class {
|
|
121888
|
+
constructor(apiKey) {
|
|
121889
|
+
this.apiKey = apiKey;
|
|
121890
|
+
this.name = "BackendApiAgent";
|
|
121891
|
+
}
|
|
121892
|
+
buildSystemPrompt() {
|
|
121893
|
+
return (0, backendApi_1.backendApiPrompt)();
|
|
121894
|
+
}
|
|
121895
|
+
async generate(params) {
|
|
121896
|
+
const { blueprint } = params;
|
|
121897
|
+
const systemPrompt = this.buildSystemPrompt();
|
|
121898
|
+
const primaryAction = `Create Astro Server Endpoints for the app ${blueprint?.appName}`;
|
|
121899
|
+
const userMessage = (0, utils_1.buildUserPromptForCodeGenerationAgent)(params, primaryAction);
|
|
121900
|
+
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-sonnet-4-20250514");
|
|
121901
|
+
const result = await (0, ai_1.generateObject)({
|
|
121902
|
+
model,
|
|
121903
|
+
schema: utils_1.FileSchema,
|
|
121904
|
+
messages: [
|
|
121905
|
+
{
|
|
121906
|
+
role: "system",
|
|
121907
|
+
content: systemPrompt,
|
|
121908
|
+
providerOptions: (0, utils_1.withCaching)("1h")
|
|
121909
|
+
},
|
|
121910
|
+
{
|
|
121911
|
+
role: "user",
|
|
121912
|
+
content: userMessage
|
|
121913
|
+
}
|
|
121914
|
+
],
|
|
121915
|
+
experimental_telemetry: {
|
|
121916
|
+
isEnabled: true,
|
|
121917
|
+
functionId: this.name
|
|
121918
|
+
},
|
|
121919
|
+
maxOutputTokens: 1e4,
|
|
121920
|
+
maxRetries: 3,
|
|
121921
|
+
temperature: 0
|
|
121922
|
+
});
|
|
121923
|
+
return result.object.files;
|
|
121924
|
+
}
|
|
121925
|
+
};
|
|
121926
|
+
exports2.BackendApiAgent = BackendApiAgent;
|
|
121927
|
+
}
|
|
121928
|
+
});
|
|
121929
|
+
|
|
121546
121930
|
// dist/system-prompts/iterationAgent/iterationAgentPrompt.js
|
|
121547
121931
|
var require_iterationAgentPrompt = __commonJS({
|
|
121548
121932
|
"dist/system-prompts/iterationAgent/iterationAgentPrompt.js"(exports2) {
|
|
@@ -122942,6 +123326,150 @@ var require_data3 = __commonJS({
|
|
|
122942
123326
|
}
|
|
122943
123327
|
});
|
|
122944
123328
|
|
|
123329
|
+
// dist/system-prompts/dashboardPage/apiSpecPrompt.js
|
|
123330
|
+
var require_apiSpecPrompt = __commonJS({
|
|
123331
|
+
"dist/system-prompts/dashboardPage/apiSpecPrompt.js"(exports2) {
|
|
123332
|
+
"use strict";
|
|
123333
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
123334
|
+
exports2.apiSpecPrompt = void 0;
|
|
123335
|
+
exports2.apiSpecPrompt = `
|
|
123336
|
+
<api_spec_docs>
|
|
123337
|
+
You will be given an API specification under the "API SPEC" spec.
|
|
123338
|
+
The dashboard page code you generate can make API calls to these endpoints to read and write data.
|
|
123339
|
+
You cannot write the API calls yourself, you must use the API calls provided in the API SPEC.
|
|
123340
|
+
|
|
123341
|
+
<example_api_spec>
|
|
123342
|
+
${JSON.stringify({
|
|
123343
|
+
name: "Todo Management API",
|
|
123344
|
+
description: "A simple API for managing todo items with CRUD operations",
|
|
123345
|
+
endpoints: [
|
|
123346
|
+
{
|
|
123347
|
+
id: "get-todos",
|
|
123348
|
+
path: "/api/todos",
|
|
123349
|
+
method: "GET",
|
|
123350
|
+
name: "Get All Todos",
|
|
123351
|
+
description: "Retrieve all todo items",
|
|
123352
|
+
parameters: [],
|
|
123353
|
+
response: {
|
|
123354
|
+
statusCode: 200,
|
|
123355
|
+
type: "array"
|
|
123356
|
+
}
|
|
123357
|
+
},
|
|
123358
|
+
{
|
|
123359
|
+
id: "create-todo",
|
|
123360
|
+
path: "/api/todos",
|
|
123361
|
+
method: "POST",
|
|
123362
|
+
name: "Create Todo",
|
|
123363
|
+
description: "Create a new todo item",
|
|
123364
|
+
parameters: [
|
|
123365
|
+
{
|
|
123366
|
+
name: "todo",
|
|
123367
|
+
type: "object",
|
|
123368
|
+
required: true,
|
|
123369
|
+
location: "body"
|
|
123370
|
+
}
|
|
123371
|
+
],
|
|
123372
|
+
response: {
|
|
123373
|
+
statusCode: 201,
|
|
123374
|
+
type: "object"
|
|
123375
|
+
}
|
|
123376
|
+
},
|
|
123377
|
+
{
|
|
123378
|
+
id: "update-todo",
|
|
123379
|
+
path: "/api/todos/[id]",
|
|
123380
|
+
method: "PUT",
|
|
123381
|
+
name: "Update Todo",
|
|
123382
|
+
description: "Update an existing todo item",
|
|
123383
|
+
parameters: [
|
|
123384
|
+
{
|
|
123385
|
+
name: "id",
|
|
123386
|
+
type: "string",
|
|
123387
|
+
required: true,
|
|
123388
|
+
location: "path"
|
|
123389
|
+
},
|
|
123390
|
+
{
|
|
123391
|
+
name: "todo",
|
|
123392
|
+
type: "object",
|
|
123393
|
+
required: true,
|
|
123394
|
+
location: "body"
|
|
123395
|
+
}
|
|
123396
|
+
],
|
|
123397
|
+
response: {
|
|
123398
|
+
statusCode: 200,
|
|
123399
|
+
type: "object"
|
|
123400
|
+
}
|
|
123401
|
+
}
|
|
123402
|
+
],
|
|
123403
|
+
dataModels: [
|
|
123404
|
+
{
|
|
123405
|
+
name: "Todo",
|
|
123406
|
+
properties: {
|
|
123407
|
+
id: {
|
|
123408
|
+
type: "string",
|
|
123409
|
+
required: true
|
|
123410
|
+
},
|
|
123411
|
+
title: {
|
|
123412
|
+
type: "string",
|
|
123413
|
+
required: true
|
|
123414
|
+
},
|
|
123415
|
+
description: {
|
|
123416
|
+
type: "string",
|
|
123417
|
+
required: false
|
|
123418
|
+
},
|
|
123419
|
+
completed: {
|
|
123420
|
+
type: "boolean",
|
|
123421
|
+
required: true
|
|
123422
|
+
},
|
|
123423
|
+
createdAt: {
|
|
123424
|
+
type: "string",
|
|
123425
|
+
required: true
|
|
123426
|
+
}
|
|
123427
|
+
}
|
|
123428
|
+
}
|
|
123429
|
+
]
|
|
123430
|
+
}, null, 2)}
|
|
123431
|
+
</example_api_spec>
|
|
123432
|
+
|
|
123433
|
+
<example_output_code>
|
|
123434
|
+
// Reading data - GET request
|
|
123435
|
+
async function getTodos(): Promise<Todo[]> {
|
|
123436
|
+
const response = await fetch('/api/todos');
|
|
123437
|
+
const data = await response.json();
|
|
123438
|
+
return data;
|
|
123439
|
+
}
|
|
123440
|
+
|
|
123441
|
+
// Writing data - POST request with data model entity
|
|
123442
|
+
async function createTodo(todo: Omit<Todo, 'id' | 'createdAt'>): Promise<Todo> {
|
|
123443
|
+
const response = await fetch('/api/todos', {
|
|
123444
|
+
method: 'POST',
|
|
123445
|
+
headers: {
|
|
123446
|
+
'Content-Type': 'application/json',
|
|
123447
|
+
},
|
|
123448
|
+
body: JSON.stringify(todo),
|
|
123449
|
+
});
|
|
123450
|
+
const data = await response.json();
|
|
123451
|
+
return data;
|
|
123452
|
+
}
|
|
123453
|
+
|
|
123454
|
+
// Writing data - PUT request with data model entity
|
|
123455
|
+
async function updateTodo(id: string, todo: Partial<Todo>): Promise<Todo> {
|
|
123456
|
+
const response = await fetch(\`/api/todos/\${id}\`, {
|
|
123457
|
+
method: 'PUT',
|
|
123458
|
+
headers: {
|
|
123459
|
+
'Content-Type': 'application/json',
|
|
123460
|
+
},
|
|
123461
|
+
body: JSON.stringify(todo),
|
|
123462
|
+
});
|
|
123463
|
+
const data = await response.json();
|
|
123464
|
+
return data;
|
|
123465
|
+
}
|
|
123466
|
+
</example_output_code>
|
|
123467
|
+
|
|
123468
|
+
</api_spec_docs>
|
|
123469
|
+
`;
|
|
123470
|
+
}
|
|
123471
|
+
});
|
|
123472
|
+
|
|
122945
123473
|
// dist/system-prompts/dashboardPage/dashboardPagePrompt.js
|
|
122946
123474
|
var require_dashboardPagePrompt = __commonJS({
|
|
122947
123475
|
"dist/system-prompts/dashboardPage/dashboardPagePrompt.js"(exports2) {
|
|
@@ -122952,6 +123480,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
122952
123480
|
var dashboardPackage_1 = require_dashboardPackage();
|
|
122953
123481
|
var wdsPackage_1 = require_wdsPackage();
|
|
122954
123482
|
var data_1 = require_data3();
|
|
123483
|
+
var apiSpecPrompt_1 = require_apiSpecPrompt();
|
|
122955
123484
|
var wdsPackage_2 = require_wdsPackage();
|
|
122956
123485
|
Object.defineProperty(exports2, "buildWdsSystemPrompt", { enumerable: true, get: function() {
|
|
122957
123486
|
return wdsPackage_2.buildWdsSystemPrompt;
|
|
@@ -122981,7 +123510,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
122981
123510
|
"ToggleSwitch",
|
|
122982
123511
|
"InfoIcon"
|
|
122983
123512
|
];
|
|
122984
|
-
var dashboardPagePrompt = async (useData) => {
|
|
123513
|
+
var dashboardPagePrompt = async ({ useData, useApiSpec }) => {
|
|
122985
123514
|
const wdsPrompt = await (0, wdsPackage_1.buildWdsSystemPrompt)(listOfWdsComponents);
|
|
122986
123515
|
return `
|
|
122987
123516
|
<WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
@@ -123062,6 +123591,8 @@ ${wdsPrompt}
|
|
|
123062
123591
|
</typescript_quality_guidelines>
|
|
123063
123592
|
|
|
123064
123593
|
${useData ? data_1.dataPrompt : ""}
|
|
123594
|
+
|
|
123595
|
+
${useApiSpec ? apiSpecPrompt_1.apiSpecPrompt : ""}
|
|
123065
123596
|
</WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
123066
123597
|
`;
|
|
123067
123598
|
};
|
|
@@ -123085,14 +123616,15 @@ var require_DashboardPageAgent = __commonJS({
|
|
|
123085
123616
|
this.apiKey = apiKey;
|
|
123086
123617
|
this.name = "DashboardPageAgent";
|
|
123087
123618
|
}
|
|
123088
|
-
async buildSystemPrompt(
|
|
123089
|
-
return (0, dashboardPagePrompt_1.dashboardPagePrompt)(
|
|
123619
|
+
async buildSystemPrompt(opts) {
|
|
123620
|
+
return (0, dashboardPagePrompt_1.dashboardPagePrompt)(opts);
|
|
123090
123621
|
}
|
|
123091
123622
|
async generate(params) {
|
|
123092
|
-
const { blueprint,
|
|
123623
|
+
const { blueprint, planAndResources } = params;
|
|
123093
123624
|
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.DashboardPage]);
|
|
123094
|
-
const useData = Boolean(createdCollections
|
|
123095
|
-
const
|
|
123625
|
+
const useData = Boolean(planAndResources?.createdCollections?.length);
|
|
123626
|
+
const useApiSpec = Boolean(planAndResources?.apiSpec);
|
|
123627
|
+
const systemPrompt = `${await this.buildSystemPrompt({ useData, useApiSpec })}
|
|
123096
123628
|
${examples}
|
|
123097
123629
|
`;
|
|
123098
123630
|
console.log(`Dashboard Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
|
|
@@ -123385,12 +123917,13 @@ Dashboard Page Description: ${extension.description}
|
|
|
123385
123917
|
${collectionsInfo}
|
|
123386
123918
|
</available-collections>`;
|
|
123387
123919
|
}
|
|
123388
|
-
async generate({ blueprint, extension,
|
|
123389
|
-
if (createdCollections
|
|
123920
|
+
async generate({ blueprint, extension, planAndResources }) {
|
|
123921
|
+
if (!planAndResources.createdCollections?.length) {
|
|
123390
123922
|
return {
|
|
123391
123923
|
useAutoPatterns: false
|
|
123392
123924
|
};
|
|
123393
123925
|
}
|
|
123926
|
+
const { createdCollections } = planAndResources;
|
|
123394
123927
|
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
|
|
123395
123928
|
const collectionsInfo = createdCollections.map((collection, index) => {
|
|
123396
123929
|
const userFields = collection.fields?.filter((field) => !field.key?.startsWith("_")) || [];
|
|
@@ -123609,15 +124142,11 @@ var require_scaffolding = __commonJS({
|
|
|
123609
124142
|
}
|
|
123610
124143
|
async function copyBackendApiScaffolding(extension, outputPath) {
|
|
123611
124144
|
const uniqueFolderName = toKebabCase(extension.name || "my-api");
|
|
123612
|
-
const
|
|
123613
|
-
const
|
|
123614
|
-
|
|
123615
|
-
const
|
|
123616
|
-
|
|
123617
|
-
const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingSubPath, outputPath, apiOutputFolder);
|
|
123618
|
-
console.log(` \u{1F310} Copying web method from: ${webMethodFile} to ${webMethodOutputFile}`);
|
|
123619
|
-
const webMethodFiles = (0, tools_1.copyScaffolding)(webMethodFile, outputPath, webMethodOutputFile);
|
|
123620
|
-
return [...apiFiles, ...webMethodFiles];
|
|
124145
|
+
const apiScaffoldingFile = "src/pages/api/my-api.ts";
|
|
124146
|
+
const apiOutputFile = `src/pages/api/${uniqueFolderName}.ts`;
|
|
124147
|
+
console.log(` \u{1F50C} Copying backend API scaffolding from: ${apiScaffoldingFile} to ${apiOutputFile}`);
|
|
124148
|
+
const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingFile, outputPath, apiOutputFile);
|
|
124149
|
+
return apiFiles;
|
|
123621
124150
|
}
|
|
123622
124151
|
async function copyBackendEventScaffolding(extension, outputPath) {
|
|
123623
124152
|
const scaffoldingSubPath = "src/backend/events/my-event";
|
|
@@ -124013,6 +124542,7 @@ var require_AgentsFactory = __commonJS({
|
|
|
124013
124542
|
var CMSAgent_1 = require_CMSAgent();
|
|
124014
124543
|
var CMSDataAgent_1 = require_CMSDataAgent();
|
|
124015
124544
|
var SiteComponentAgent_1 = __importDefault2(require_SiteComponentAgent());
|
|
124545
|
+
var BackendApiAgent_1 = require_BackendApiAgent();
|
|
124016
124546
|
var IterationAgent_1 = __importDefault2(require_IterationAgent());
|
|
124017
124547
|
var CustomElementAgent_1 = __importDefault2(require_CustomElementAgent());
|
|
124018
124548
|
var DashboardPageAgent_1 = __importDefault2(require_DashboardPageAgent());
|
|
@@ -124044,6 +124574,8 @@ var require_AgentsFactory = __commonJS({
|
|
|
124044
124574
|
return new SiteComponentAgent_1.default(this.apiKey);
|
|
124045
124575
|
case types_1.ExtensionType.SITE_WIDGET:
|
|
124046
124576
|
return new CustomElementAgent_1.default(this.apiKey);
|
|
124577
|
+
case types_1.ExtensionType.BACKEND_API:
|
|
124578
|
+
return new BackendApiAgent_1.BackendApiAgent(this.apiKey);
|
|
124047
124579
|
default:
|
|
124048
124580
|
throw new Error(`Unsupported extension type for AI customization: ${extension.type}`);
|
|
124049
124581
|
}
|
|
@@ -126621,9 +127153,13 @@ var require_extensionGenerators = __commonJS({
|
|
|
126621
127153
|
var ExtensionFactory = class {
|
|
126622
127154
|
static generateExtension(extension, outputPath, scaffoldPath) {
|
|
126623
127155
|
const config = this.extensionConfigs[extension.type];
|
|
126624
|
-
if (
|
|
127156
|
+
if (typeof config === "undefined") {
|
|
126625
127157
|
throw new Error(`Unsupported extension type: ${extension.type}`);
|
|
126626
127158
|
}
|
|
127159
|
+
if (config === null) {
|
|
127160
|
+
console.log(`Skipping extension type: ${extension.type}. It doesn't need presence in the extensions.ts file (e.g. Backend API is astro only)`);
|
|
127161
|
+
return;
|
|
127162
|
+
}
|
|
126627
127163
|
const scaffoldDir = path_1.default.dirname(scaffoldPath);
|
|
126628
127164
|
const name = extension.name || config.defaultName;
|
|
126629
127165
|
const id = (0, crypto_1.randomUUID)();
|
|
@@ -126726,7 +127262,8 @@ var require_extensionGenerators = __commonJS({
|
|
|
126726
127262
|
builderMethod: "customElement",
|
|
126727
127263
|
defaultName: "my-custom-element",
|
|
126728
127264
|
createExtensionData: _a2.createCustomElementData.bind(_a2)
|
|
126729
|
-
}
|
|
127265
|
+
},
|
|
127266
|
+
[types_1.ExtensionType.BACKEND_API]: null
|
|
126730
127267
|
};
|
|
126731
127268
|
ExtensionFactory.servicePluginBuilderMap = {
|
|
126732
127269
|
"ecom-shipping-rates": "ecomShippingRates",
|
|
@@ -133467,19 +134004,26 @@ var require_orchestrator = __commonJS({
|
|
|
133467
134004
|
this.emitEvent("cms:start", {});
|
|
133468
134005
|
const cmsAgent = this.agentsFactory.getAgent({ type: "CMS" });
|
|
133469
134006
|
for (const collection of plan.collections) {
|
|
133470
|
-
const
|
|
134007
|
+
const result2 = await cmsAgent.generate({
|
|
133471
134008
|
blueprint,
|
|
133472
134009
|
siteId,
|
|
133473
134010
|
accessToken,
|
|
133474
134011
|
collection
|
|
133475
134012
|
});
|
|
133476
|
-
createdCollections.push(
|
|
134013
|
+
createdCollections.push(result2.collection);
|
|
133477
134014
|
}
|
|
133478
134015
|
this.emitEvent("cms:done", {
|
|
133479
134016
|
numberOfCollections: plan.collections.length
|
|
133480
134017
|
});
|
|
133481
134018
|
}
|
|
133482
|
-
|
|
134019
|
+
const result = {};
|
|
134020
|
+
if (createdCollections.length > 0) {
|
|
134021
|
+
result.createdCollections = createdCollections;
|
|
134022
|
+
}
|
|
134023
|
+
if (plan?.apiSpec) {
|
|
134024
|
+
result.apiSpec = plan.apiSpec;
|
|
134025
|
+
}
|
|
134026
|
+
return result;
|
|
133483
134027
|
}
|
|
133484
134028
|
async runIterationPlanningAndAugmentExtensions(outputPath, chatHistory) {
|
|
133485
134029
|
const iterationAgent = this.agentsFactory.getAgent({
|
|
@@ -133490,94 +134034,70 @@ var require_orchestrator = __commonJS({
|
|
|
133490
134034
|
const iterationPlan = await iterationAgent.generate(outputPath, candidateFiles, currentUserRequest, chatHistory);
|
|
133491
134035
|
return iterationPlan;
|
|
133492
134036
|
}
|
|
133493
|
-
async processExtension({ extension, blueprint, outputPath,
|
|
134037
|
+
async processExtension({ extension, blueprint, outputPath, planAndResources }) {
|
|
133494
134038
|
switch (extension.type) {
|
|
133495
134039
|
case types_1.ExtensionType.DASHBOARD_PAGE:
|
|
133496
134040
|
return this.processDashboardPage({
|
|
133497
134041
|
extension,
|
|
133498
134042
|
blueprint,
|
|
133499
134043
|
outputPath,
|
|
133500
|
-
|
|
134044
|
+
planAndResources
|
|
133501
134045
|
});
|
|
133502
134046
|
case types_1.ExtensionType.SERVICE_PLUGIN:
|
|
133503
134047
|
return this.processServicePlugin({
|
|
133504
134048
|
extension,
|
|
133505
134049
|
blueprint,
|
|
133506
134050
|
outputPath,
|
|
133507
|
-
|
|
134051
|
+
planAndResources
|
|
133508
134052
|
});
|
|
133509
134053
|
default:
|
|
133510
134054
|
return this.processStandardExtension({
|
|
133511
134055
|
extension,
|
|
133512
134056
|
blueprint,
|
|
133513
134057
|
outputPath,
|
|
133514
|
-
|
|
134058
|
+
planAndResources
|
|
133515
134059
|
});
|
|
133516
134060
|
}
|
|
133517
134061
|
}
|
|
133518
|
-
async processDashboardPage(
|
|
134062
|
+
async processDashboardPage(opts) {
|
|
133519
134063
|
const decisionAgent = this.agentsFactory.getAgent({
|
|
133520
134064
|
type: "DASHBOARD_DECISION"
|
|
133521
134065
|
});
|
|
133522
|
-
const decision = await decisionAgent.generate(
|
|
133523
|
-
blueprint,
|
|
133524
|
-
extension,
|
|
133525
|
-
createdCollections
|
|
133526
|
-
});
|
|
134066
|
+
const decision = await decisionAgent.generate(opts);
|
|
133527
134067
|
const useAutoPatterns = decision.useAutoPatterns && decision.schema && decision.relevantCollectionId;
|
|
133528
|
-
if (useAutoPatterns) {
|
|
133529
|
-
console.log("\u{1F3AF} Using auto-patterns for dashboard generation");
|
|
133530
|
-
const relevantCollection = createdCollections.find((c) => c.id === decision.relevantCollectionId);
|
|
133531
|
-
if (!relevantCollection) {
|
|
133532
|
-
throw new Error(`\u274C Collection with ID ${decision.relevantCollectionId} not found in created collections`);
|
|
133533
|
-
}
|
|
133534
|
-
const autoPatternsGenerator = this.agentsFactory.getAgent({
|
|
133535
|
-
type: "AUTO_PATTERNS_GENERATOR"
|
|
133536
|
-
});
|
|
133537
|
-
this.emitEvent("agent:start", {
|
|
133538
|
-
extension,
|
|
133539
|
-
name: "AutoPatternsGenerator"
|
|
133540
|
-
});
|
|
133541
|
-
const files = autoPatternsGenerator.generate({
|
|
133542
|
-
collection: relevantCollection,
|
|
133543
|
-
decision,
|
|
133544
|
-
extensionName: extension.name || ""
|
|
133545
|
-
});
|
|
133546
|
-
this.writeFile(files, outputPath);
|
|
133547
|
-
const pagePath = files[0].path || "";
|
|
133548
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, pagePath);
|
|
133549
|
-
this.emitEvent("agent:done", {
|
|
133550
|
-
extension,
|
|
133551
|
-
name: "AutoPatternsGenerator",
|
|
133552
|
-
files
|
|
133553
|
-
});
|
|
133554
|
-
} else {
|
|
134068
|
+
if (!useAutoPatterns) {
|
|
133555
134069
|
console.log("\u{1F3A8} Using custom code generation for dashboard");
|
|
133556
|
-
this.
|
|
133557
|
-
|
|
133558
|
-
if (!scaffolds || scaffolds.length === 0) {
|
|
133559
|
-
throw new Error(`\u274C Failed to scaffold ${extension.type}`);
|
|
133560
|
-
}
|
|
133561
|
-
const scaffold = scaffolds[0];
|
|
133562
|
-
this.emitEvent("scaffold:done", {
|
|
133563
|
-
extension,
|
|
133564
|
-
scaffoldPath: scaffolds.map((s) => s.path).join(", ")
|
|
133565
|
-
});
|
|
133566
|
-
const agent = this.agentsFactory.getAgent(extension);
|
|
133567
|
-
this.emitEvent("agent:start", { extension, name: agent.name });
|
|
133568
|
-
const files = await agent.generate({
|
|
133569
|
-
extension,
|
|
133570
|
-
blueprint,
|
|
133571
|
-
scaffold,
|
|
133572
|
-
createdCollections,
|
|
133573
|
-
basePath: outputPath
|
|
133574
|
-
});
|
|
133575
|
-
this.writeFile(files, outputPath);
|
|
133576
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133577
|
-
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
134070
|
+
await this.processStandardExtension(opts);
|
|
134071
|
+
return;
|
|
133578
134072
|
}
|
|
134073
|
+
console.log("\u{1F3AF} Using auto-patterns for dashboard generation");
|
|
134074
|
+
const { extension, outputPath, planAndResources: { createdCollections = [] } = {} } = opts;
|
|
134075
|
+
const relevantCollection = createdCollections.find((c) => c.id === decision.relevantCollectionId);
|
|
134076
|
+
if (!relevantCollection) {
|
|
134077
|
+
throw new Error(`\u274C Collection with ID ${decision.relevantCollectionId} not found in created collections`);
|
|
134078
|
+
}
|
|
134079
|
+
const autoPatternsGenerator = this.agentsFactory.getAgent({
|
|
134080
|
+
type: "AUTO_PATTERNS_GENERATOR"
|
|
134081
|
+
});
|
|
134082
|
+
this.emitEvent("agent:start", {
|
|
134083
|
+
extension,
|
|
134084
|
+
name: "AutoPatternsGenerator"
|
|
134085
|
+
});
|
|
134086
|
+
const files = autoPatternsGenerator.generate({
|
|
134087
|
+
collection: relevantCollection,
|
|
134088
|
+
decision,
|
|
134089
|
+
extensionName: extension.name || ""
|
|
134090
|
+
});
|
|
134091
|
+
this.writeFile(files, outputPath);
|
|
134092
|
+
const pagePath = files[0].path || "";
|
|
134093
|
+
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, pagePath);
|
|
134094
|
+
this.emitEvent("agent:done", {
|
|
134095
|
+
extension,
|
|
134096
|
+
name: "AutoPatternsGenerator",
|
|
134097
|
+
files
|
|
134098
|
+
});
|
|
133579
134099
|
}
|
|
133580
|
-
async processServicePlugin({ extension, blueprint, outputPath,
|
|
134100
|
+
async processServicePlugin({ extension, blueprint, outputPath, planAndResources }) {
|
|
133581
134101
|
this.emitEvent("scaffold:start", { extension });
|
|
133582
134102
|
const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
|
|
133583
134103
|
if (!scaffolds || scaffolds.length === 0) {
|
|
@@ -133592,7 +134112,7 @@ var require_orchestrator = __commonJS({
|
|
|
133592
134112
|
extension,
|
|
133593
134113
|
blueprint,
|
|
133594
134114
|
outputPath,
|
|
133595
|
-
|
|
134115
|
+
planAndResources,
|
|
133596
134116
|
scaffolds
|
|
133597
134117
|
});
|
|
133598
134118
|
}
|
|
@@ -133603,14 +134123,14 @@ var require_orchestrator = __commonJS({
|
|
|
133603
134123
|
extension,
|
|
133604
134124
|
blueprint,
|
|
133605
134125
|
scaffold,
|
|
133606
|
-
|
|
134126
|
+
planAndResources,
|
|
133607
134127
|
basePath: outputPath
|
|
133608
134128
|
});
|
|
133609
134129
|
this.writeFile(files, outputPath);
|
|
133610
134130
|
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133611
134131
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
133612
134132
|
}
|
|
133613
|
-
async processStandardExtension({ extension, blueprint, outputPath,
|
|
134133
|
+
async processStandardExtension({ extension, blueprint, outputPath, planAndResources }) {
|
|
133614
134134
|
this.emitEvent("scaffold:start", { extension });
|
|
133615
134135
|
const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
|
|
133616
134136
|
if (!scaffolds || scaffolds.length === 0) {
|
|
@@ -133627,14 +134147,14 @@ var require_orchestrator = __commonJS({
|
|
|
133627
134147
|
extension,
|
|
133628
134148
|
blueprint,
|
|
133629
134149
|
scaffold,
|
|
133630
|
-
|
|
134150
|
+
planAndResources,
|
|
133631
134151
|
basePath: outputPath
|
|
133632
134152
|
});
|
|
133633
134153
|
this.writeFile(files, outputPath);
|
|
133634
134154
|
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133635
134155
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
133636
134156
|
}
|
|
133637
|
-
async processMultipleServicePluginScaffolds({ extension, blueprint, outputPath,
|
|
134157
|
+
async processMultipleServicePluginScaffolds({ extension, blueprint, outputPath, planAndResources, scaffolds }) {
|
|
133638
134158
|
if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
|
|
133639
134159
|
throw new Error("Service plugin extension must have related SPIs");
|
|
133640
134160
|
}
|
|
@@ -133656,7 +134176,7 @@ var require_orchestrator = __commonJS({
|
|
|
133656
134176
|
extension: spiExtension,
|
|
133657
134177
|
blueprint,
|
|
133658
134178
|
scaffold,
|
|
133659
|
-
|
|
134179
|
+
planAndResources,
|
|
133660
134180
|
basePath: outputPath
|
|
133661
134181
|
});
|
|
133662
134182
|
this.writeFile(files, outputPath);
|
|
@@ -133686,7 +134206,7 @@ var require_orchestrator = __commonJS({
|
|
|
133686
134206
|
blueprint: { extensions: [], appName: "", summary: "" },
|
|
133687
134207
|
// Minimal blueprint for iteration
|
|
133688
134208
|
outputPath,
|
|
133689
|
-
|
|
134209
|
+
planAndResources: {},
|
|
133690
134210
|
scaffolds
|
|
133691
134211
|
});
|
|
133692
134212
|
return;
|
|
@@ -133753,19 +134273,16 @@ var require_orchestrator = __commonJS({
|
|
|
133753
134273
|
});
|
|
133754
134274
|
const start = Date.now();
|
|
133755
134275
|
const { extensions = [] } = blueprint;
|
|
133756
|
-
const
|
|
133757
|
-
if (siteId && siteId !== "N/A" && accessToken) {
|
|
133758
|
-
const planAndResourcesResult = await this.generatePlanAndResources(request);
|
|
133759
|
-
createdCollections.push(...planAndResourcesResult.createdCollections);
|
|
133760
|
-
}
|
|
134276
|
+
const planAndResources = await this.generatePlanAndResources(request);
|
|
133761
134277
|
const parallelTasks = extensions.map((extension) => this.processExtension({
|
|
133762
134278
|
extension,
|
|
133763
134279
|
blueprint,
|
|
133764
134280
|
outputPath,
|
|
133765
|
-
|
|
134281
|
+
planAndResources
|
|
133766
134282
|
}));
|
|
133767
|
-
|
|
133768
|
-
|
|
134283
|
+
const collections = planAndResources.createdCollections ?? [];
|
|
134284
|
+
if (collections.length > 0 && siteId && siteId !== "N/A" && accessToken) {
|
|
134285
|
+
parallelTasks.push(this.generateCMSData(request, collections));
|
|
133769
134286
|
}
|
|
133770
134287
|
await Promise.all(parallelTasks.filter(Boolean));
|
|
133771
134288
|
await (0, extensionIndexer_1.generateMainExtensionsFile)(outputPath);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// A frontend API based on Astor's Server Endpoints (API Routes)
|
|
2
|
+
// See https://docs.astro.build/en/guides/endpoints/#server-endpoints-api-routes
|
|
3
|
+
import type { APIRoute } from "astro";
|
|
4
|
+
|
|
5
|
+
export const GET: APIRoute = async ({ request }) => {
|
|
6
|
+
return new Response(
|
|
7
|
+
JSON.stringify({
|
|
8
|
+
message: `This was a GET to ${request.url}`,
|
|
9
|
+
}),
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const POST: APIRoute = async ({ request }) => {
|
|
14
|
+
const body = await request.json();
|
|
15
|
+
|
|
16
|
+
const { name } = body;
|
|
17
|
+
|
|
18
|
+
console.log("name:", name);
|
|
19
|
+
|
|
20
|
+
return new Response(
|
|
21
|
+
JSON.stringify({
|
|
22
|
+
greeting: `Hello ${name}`,
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
status: 200,
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@wix/ditto-codegen": "1.0.0",
|
|
25
25
|
"esbuild": "^0.25.9"
|
|
26
26
|
},
|
|
27
|
-
"falconPackageHash": "
|
|
27
|
+
"falconPackageHash": "343aa69a85dc9adacb60daa8817207e375875acff998406df25af5cf"
|
|
28
28
|
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
This file allows you to call backend APIs from your frontend of this app.
|
|
3
|
-
You can generate various API methods including GET, POST, PUT, and DELETE.
|
|
4
|
-
To learn more, check out our documentation: https://wix.to/Iabrrso
|
|
5
|
-
|
|
6
|
-
Here's how you can call your API from your frontend code:
|
|
7
|
-
|
|
8
|
-
import { httpClient } from '@wix/essentials';
|
|
9
|
-
|
|
10
|
-
function MyComponent() {
|
|
11
|
-
const callMyBackend = async () => {
|
|
12
|
-
const res = await httpClient.fetchWithAuth(`${import.meta.env.BASE_API_URL}/my-api`);
|
|
13
|
-
console.log(await res.text());
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
return <button onClick={callMyBackend}>Call backend GET function</button>;
|
|
17
|
-
};
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export async function GET(req: Request) {
|
|
21
|
-
console.log('Log from GET.');
|
|
22
|
-
return new Response('Response from GET.');
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export async function POST(req: Request) {
|
|
26
|
-
const data = await req.json();
|
|
27
|
-
console.log('Log POST with body:', data);
|
|
28
|
-
return Response.json(data);
|
|
29
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
This file allows you to define backend functions that you can call from the front end of this app with type-safety.
|
|
3
|
-
|
|
4
|
-
Here's how you can call your web method from your frontend code:
|
|
5
|
-
|
|
6
|
-
import { multiply } from '<path-to-your-web-methods-directory>/my-web-method.web';
|
|
7
|
-
|
|
8
|
-
multiply(3, 4)
|
|
9
|
-
.then(result => console.log(result));
|
|
10
|
-
|
|
11
|
-
To learn more, check out our documentation: https://wix.to/6LV6Oka.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { webMethod, Permissions } from '@wix/web-methods';
|
|
15
|
-
|
|
16
|
-
export const multiply = webMethod(
|
|
17
|
-
Permissions.Anyone,
|
|
18
|
-
(a: number, b: number) => {
|
|
19
|
-
return a * b;
|
|
20
|
-
},
|
|
21
|
-
);
|