@wix/ditto-codegen-public 1.0.45 → 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
|
@@ -117398,7 +117398,7 @@ var require_utils14 = __commonJS({
|
|
|
117398
117398
|
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
117399
117399
|
};
|
|
117400
117400
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
117401
|
-
exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = void 0;
|
|
117401
|
+
exports2.getErrorMessage = exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = void 0;
|
|
117402
117402
|
exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
|
|
117403
117403
|
var zod_1 = require_zod();
|
|
117404
117404
|
var http_client_1 = require_index_node();
|
|
@@ -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,16 +117497,31 @@ 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")}`;
|
|
117507
117512
|
return userMessage;
|
|
117508
117513
|
};
|
|
117509
117514
|
exports2.buildUserPromptForCodeGenerationAgent = buildUserPromptForCodeGenerationAgent;
|
|
117515
|
+
var getErrorMessage = (error) => {
|
|
117516
|
+
if (error?.response?.data && error?.response?.data?.message.length > 0) {
|
|
117517
|
+
return JSON.stringify(error.response.data);
|
|
117518
|
+
} else if (error?.message && error?.message.length > 0) {
|
|
117519
|
+
return JSON.stringify(error.message);
|
|
117520
|
+
} else {
|
|
117521
|
+
return JSON.stringify(error);
|
|
117522
|
+
}
|
|
117523
|
+
};
|
|
117524
|
+
exports2.getErrorMessage = getErrorMessage;
|
|
117510
117525
|
}
|
|
117511
117526
|
});
|
|
117512
117527
|
|
|
@@ -117751,10 +117766,10 @@ var require_SPIAgent = __commonJS({
|
|
|
117751
117766
|
return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData);
|
|
117752
117767
|
}
|
|
117753
117768
|
async generate(params) {
|
|
117754
|
-
const { extension, blueprint,
|
|
117769
|
+
const { extension, blueprint, planAndResources } = params;
|
|
117755
117770
|
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.ServicePluginExtension]);
|
|
117756
117771
|
const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
|
|
117757
|
-
const useData = Boolean(createdCollections
|
|
117772
|
+
const useData = Boolean(planAndResources?.createdCollections?.length);
|
|
117758
117773
|
const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData)}
|
|
117759
117774
|
${examples}
|
|
117760
117775
|
`;
|
|
@@ -117794,6 +117809,196 @@ ${examples}
|
|
|
117794
117809
|
}
|
|
117795
117810
|
});
|
|
117796
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
|
+
|
|
117797
118002
|
// dist/system-prompts/planner/data.js
|
|
117798
118003
|
var require_data2 = __commonJS({
|
|
117799
118004
|
"dist/system-prompts/planner/data.js"(exports2) {
|
|
@@ -117896,10 +118101,13 @@ var require_planner = __commonJS({
|
|
|
117896
118101
|
"use strict";
|
|
117897
118102
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
117898
118103
|
exports2.plannerPrompt = void 0;
|
|
118104
|
+
var apiSpec_1 = require_apiSpec();
|
|
117899
118105
|
var data_1 = require_data2();
|
|
117900
118106
|
var plannerPrompt = () => `
|
|
117901
118107
|
<WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
117902
118108
|
${(0, data_1.cmsPlannerPrompt)()}
|
|
118109
|
+
|
|
118110
|
+
${(0, apiSpec_1.apiSpecPrompt)()}
|
|
117903
118111
|
</WIXCLI_PLANNER_SYSTEM_PROMPT>
|
|
117904
118112
|
`;
|
|
117905
118113
|
exports2.plannerPrompt = plannerPrompt;
|
|
@@ -119791,9 +119999,8 @@ var require_CMSAgent = __commonJS({
|
|
|
119791
119999
|
collection: this.currentCollectionSchema
|
|
119792
120000
|
});
|
|
119793
120001
|
} catch (err) {
|
|
119794
|
-
|
|
119795
|
-
|
|
119796
|
-
const fixedCollection = await this.proposeFixedCollection(errormessage, this.currentCollectionSchema, payload.blueprint.summary ?? "");
|
|
120002
|
+
lastError = (0, utils_1.getErrorMessage)(err);
|
|
120003
|
+
const fixedCollection = await this.proposeFixedCollection(lastError, this.currentCollectionSchema, payload.blueprint.summary ?? "");
|
|
119797
120004
|
this.currentCollectionSchema = fixedCollection;
|
|
119798
120005
|
continue;
|
|
119799
120006
|
}
|
|
@@ -119809,6 +120016,47 @@ var require_CMSAgent = __commonJS({
|
|
|
119809
120016
|
}
|
|
119810
120017
|
});
|
|
119811
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
|
+
|
|
119812
120060
|
// dist/agents/PlannerAgent.js
|
|
119813
120061
|
var require_PlannerAgent = __commonJS({
|
|
119814
120062
|
"dist/agents/PlannerAgent.js"(exports2) {
|
|
@@ -119821,8 +120069,10 @@ var require_PlannerAgent = __commonJS({
|
|
|
119821
120069
|
var planner_1 = require_planner();
|
|
119822
120070
|
var CMSAgent_1 = require_CMSAgent();
|
|
119823
120071
|
var utils_1 = require_utils14();
|
|
120072
|
+
var ApiSpecSchema_1 = require_ApiSpecSchema();
|
|
119824
120073
|
exports2.PlannerOutputSchema = zod_1.z.object({
|
|
119825
|
-
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()
|
|
119826
120076
|
});
|
|
119827
120077
|
var PlannerAgent = class {
|
|
119828
120078
|
constructor(apiKey) {
|
|
@@ -121408,10 +121658,9 @@ Generate diverse, realistic sample data that would be appropriate for this type
|
|
|
121408
121658
|
});
|
|
121409
121659
|
success = true;
|
|
121410
121660
|
} catch (error) {
|
|
121411
|
-
|
|
121412
|
-
lastError = errorMessage;
|
|
121661
|
+
lastError = (0, utils_1.getErrorMessage)(error);
|
|
121413
121662
|
const systemPrompt = this.buildPrompt([collection], blueprint, {
|
|
121414
|
-
error:
|
|
121663
|
+
error: lastError,
|
|
121415
121664
|
originalItems: dataItems
|
|
121416
121665
|
});
|
|
121417
121666
|
const fixedData = await this.generateData(DataFixOutputSchema, (0, dataFixPrompt_1.dataFixPrompt)(), systemPrompt, `${this.name}_fix`);
|
|
@@ -121535,6 +121784,149 @@ var require_SiteComponentAgent = __commonJS({
|
|
|
121535
121784
|
}
|
|
121536
121785
|
});
|
|
121537
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
|
+
|
|
121538
121930
|
// dist/system-prompts/iterationAgent/iterationAgentPrompt.js
|
|
121539
121931
|
var require_iterationAgentPrompt = __commonJS({
|
|
121540
121932
|
"dist/system-prompts/iterationAgent/iterationAgentPrompt.js"(exports2) {
|
|
@@ -122934,6 +123326,150 @@ var require_data3 = __commonJS({
|
|
|
122934
123326
|
}
|
|
122935
123327
|
});
|
|
122936
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
|
+
|
|
122937
123473
|
// dist/system-prompts/dashboardPage/dashboardPagePrompt.js
|
|
122938
123474
|
var require_dashboardPagePrompt = __commonJS({
|
|
122939
123475
|
"dist/system-prompts/dashboardPage/dashboardPagePrompt.js"(exports2) {
|
|
@@ -122944,6 +123480,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
122944
123480
|
var dashboardPackage_1 = require_dashboardPackage();
|
|
122945
123481
|
var wdsPackage_1 = require_wdsPackage();
|
|
122946
123482
|
var data_1 = require_data3();
|
|
123483
|
+
var apiSpecPrompt_1 = require_apiSpecPrompt();
|
|
122947
123484
|
var wdsPackage_2 = require_wdsPackage();
|
|
122948
123485
|
Object.defineProperty(exports2, "buildWdsSystemPrompt", { enumerable: true, get: function() {
|
|
122949
123486
|
return wdsPackage_2.buildWdsSystemPrompt;
|
|
@@ -122973,7 +123510,7 @@ var require_dashboardPagePrompt = __commonJS({
|
|
|
122973
123510
|
"ToggleSwitch",
|
|
122974
123511
|
"InfoIcon"
|
|
122975
123512
|
];
|
|
122976
|
-
var dashboardPagePrompt = async (useData) => {
|
|
123513
|
+
var dashboardPagePrompt = async ({ useData, useApiSpec }) => {
|
|
122977
123514
|
const wdsPrompt = await (0, wdsPackage_1.buildWdsSystemPrompt)(listOfWdsComponents);
|
|
122978
123515
|
return `
|
|
122979
123516
|
<WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
@@ -123054,6 +123591,8 @@ ${wdsPrompt}
|
|
|
123054
123591
|
</typescript_quality_guidelines>
|
|
123055
123592
|
|
|
123056
123593
|
${useData ? data_1.dataPrompt : ""}
|
|
123594
|
+
|
|
123595
|
+
${useApiSpec ? apiSpecPrompt_1.apiSpecPrompt : ""}
|
|
123057
123596
|
</WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
|
|
123058
123597
|
`;
|
|
123059
123598
|
};
|
|
@@ -123077,14 +123616,15 @@ var require_DashboardPageAgent = __commonJS({
|
|
|
123077
123616
|
this.apiKey = apiKey;
|
|
123078
123617
|
this.name = "DashboardPageAgent";
|
|
123079
123618
|
}
|
|
123080
|
-
async buildSystemPrompt(
|
|
123081
|
-
return (0, dashboardPagePrompt_1.dashboardPagePrompt)(
|
|
123619
|
+
async buildSystemPrompt(opts) {
|
|
123620
|
+
return (0, dashboardPagePrompt_1.dashboardPagePrompt)(opts);
|
|
123082
123621
|
}
|
|
123083
123622
|
async generate(params) {
|
|
123084
|
-
const { blueprint,
|
|
123623
|
+
const { blueprint, planAndResources } = params;
|
|
123085
123624
|
const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.DashboardPage]);
|
|
123086
|
-
const useData = Boolean(createdCollections
|
|
123087
|
-
const
|
|
123625
|
+
const useData = Boolean(planAndResources?.createdCollections?.length);
|
|
123626
|
+
const useApiSpec = Boolean(planAndResources?.apiSpec);
|
|
123627
|
+
const systemPrompt = `${await this.buildSystemPrompt({ useData, useApiSpec })}
|
|
123088
123628
|
${examples}
|
|
123089
123629
|
`;
|
|
123090
123630
|
console.log(`Dashboard Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
|
|
@@ -123377,12 +123917,13 @@ Dashboard Page Description: ${extension.description}
|
|
|
123377
123917
|
${collectionsInfo}
|
|
123378
123918
|
</available-collections>`;
|
|
123379
123919
|
}
|
|
123380
|
-
async generate({ blueprint, extension,
|
|
123381
|
-
if (createdCollections
|
|
123920
|
+
async generate({ blueprint, extension, planAndResources }) {
|
|
123921
|
+
if (!planAndResources.createdCollections?.length) {
|
|
123382
123922
|
return {
|
|
123383
123923
|
useAutoPatterns: false
|
|
123384
123924
|
};
|
|
123385
123925
|
}
|
|
123926
|
+
const { createdCollections } = planAndResources;
|
|
123386
123927
|
const model = (0, anthropic_1.createAnthropic)({ apiKey: this.apiKey })("claude-3-5-haiku-latest");
|
|
123387
123928
|
const collectionsInfo = createdCollections.map((collection, index) => {
|
|
123388
123929
|
const userFields = collection.fields?.filter((field) => !field.key?.startsWith("_")) || [];
|
|
@@ -123601,15 +124142,11 @@ var require_scaffolding = __commonJS({
|
|
|
123601
124142
|
}
|
|
123602
124143
|
async function copyBackendApiScaffolding(extension, outputPath) {
|
|
123603
124144
|
const uniqueFolderName = toKebabCase(extension.name || "my-api");
|
|
123604
|
-
const
|
|
123605
|
-
const
|
|
123606
|
-
|
|
123607
|
-
const
|
|
123608
|
-
|
|
123609
|
-
const apiFiles = (0, tools_1.copyScaffolding)(apiScaffoldingSubPath, outputPath, apiOutputFolder);
|
|
123610
|
-
console.log(` \u{1F310} Copying web method from: ${webMethodFile} to ${webMethodOutputFile}`);
|
|
123611
|
-
const webMethodFiles = (0, tools_1.copyScaffolding)(webMethodFile, outputPath, webMethodOutputFile);
|
|
123612
|
-
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;
|
|
123613
124150
|
}
|
|
123614
124151
|
async function copyBackendEventScaffolding(extension, outputPath) {
|
|
123615
124152
|
const scaffoldingSubPath = "src/backend/events/my-event";
|
|
@@ -124005,6 +124542,7 @@ var require_AgentsFactory = __commonJS({
|
|
|
124005
124542
|
var CMSAgent_1 = require_CMSAgent();
|
|
124006
124543
|
var CMSDataAgent_1 = require_CMSDataAgent();
|
|
124007
124544
|
var SiteComponentAgent_1 = __importDefault2(require_SiteComponentAgent());
|
|
124545
|
+
var BackendApiAgent_1 = require_BackendApiAgent();
|
|
124008
124546
|
var IterationAgent_1 = __importDefault2(require_IterationAgent());
|
|
124009
124547
|
var CustomElementAgent_1 = __importDefault2(require_CustomElementAgent());
|
|
124010
124548
|
var DashboardPageAgent_1 = __importDefault2(require_DashboardPageAgent());
|
|
@@ -124036,6 +124574,8 @@ var require_AgentsFactory = __commonJS({
|
|
|
124036
124574
|
return new SiteComponentAgent_1.default(this.apiKey);
|
|
124037
124575
|
case types_1.ExtensionType.SITE_WIDGET:
|
|
124038
124576
|
return new CustomElementAgent_1.default(this.apiKey);
|
|
124577
|
+
case types_1.ExtensionType.BACKEND_API:
|
|
124578
|
+
return new BackendApiAgent_1.BackendApiAgent(this.apiKey);
|
|
124039
124579
|
default:
|
|
124040
124580
|
throw new Error(`Unsupported extension type for AI customization: ${extension.type}`);
|
|
124041
124581
|
}
|
|
@@ -126613,9 +127153,13 @@ var require_extensionGenerators = __commonJS({
|
|
|
126613
127153
|
var ExtensionFactory = class {
|
|
126614
127154
|
static generateExtension(extension, outputPath, scaffoldPath) {
|
|
126615
127155
|
const config = this.extensionConfigs[extension.type];
|
|
126616
|
-
if (
|
|
127156
|
+
if (typeof config === "undefined") {
|
|
126617
127157
|
throw new Error(`Unsupported extension type: ${extension.type}`);
|
|
126618
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
|
+
}
|
|
126619
127163
|
const scaffoldDir = path_1.default.dirname(scaffoldPath);
|
|
126620
127164
|
const name = extension.name || config.defaultName;
|
|
126621
127165
|
const id = (0, crypto_1.randomUUID)();
|
|
@@ -126718,7 +127262,8 @@ var require_extensionGenerators = __commonJS({
|
|
|
126718
127262
|
builderMethod: "customElement",
|
|
126719
127263
|
defaultName: "my-custom-element",
|
|
126720
127264
|
createExtensionData: _a2.createCustomElementData.bind(_a2)
|
|
126721
|
-
}
|
|
127265
|
+
},
|
|
127266
|
+
[types_1.ExtensionType.BACKEND_API]: null
|
|
126722
127267
|
};
|
|
126723
127268
|
ExtensionFactory.servicePluginBuilderMap = {
|
|
126724
127269
|
"ecom-shipping-rates": "ecomShippingRates",
|
|
@@ -133459,19 +134004,26 @@ var require_orchestrator = __commonJS({
|
|
|
133459
134004
|
this.emitEvent("cms:start", {});
|
|
133460
134005
|
const cmsAgent = this.agentsFactory.getAgent({ type: "CMS" });
|
|
133461
134006
|
for (const collection of plan.collections) {
|
|
133462
|
-
const
|
|
134007
|
+
const result2 = await cmsAgent.generate({
|
|
133463
134008
|
blueprint,
|
|
133464
134009
|
siteId,
|
|
133465
134010
|
accessToken,
|
|
133466
134011
|
collection
|
|
133467
134012
|
});
|
|
133468
|
-
createdCollections.push(
|
|
134013
|
+
createdCollections.push(result2.collection);
|
|
133469
134014
|
}
|
|
133470
134015
|
this.emitEvent("cms:done", {
|
|
133471
134016
|
numberOfCollections: plan.collections.length
|
|
133472
134017
|
});
|
|
133473
134018
|
}
|
|
133474
|
-
|
|
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;
|
|
133475
134027
|
}
|
|
133476
134028
|
async runIterationPlanningAndAugmentExtensions(outputPath, chatHistory) {
|
|
133477
134029
|
const iterationAgent = this.agentsFactory.getAgent({
|
|
@@ -133482,94 +134034,70 @@ var require_orchestrator = __commonJS({
|
|
|
133482
134034
|
const iterationPlan = await iterationAgent.generate(outputPath, candidateFiles, currentUserRequest, chatHistory);
|
|
133483
134035
|
return iterationPlan;
|
|
133484
134036
|
}
|
|
133485
|
-
async processExtension({ extension, blueprint, outputPath,
|
|
134037
|
+
async processExtension({ extension, blueprint, outputPath, planAndResources }) {
|
|
133486
134038
|
switch (extension.type) {
|
|
133487
134039
|
case types_1.ExtensionType.DASHBOARD_PAGE:
|
|
133488
134040
|
return this.processDashboardPage({
|
|
133489
134041
|
extension,
|
|
133490
134042
|
blueprint,
|
|
133491
134043
|
outputPath,
|
|
133492
|
-
|
|
134044
|
+
planAndResources
|
|
133493
134045
|
});
|
|
133494
134046
|
case types_1.ExtensionType.SERVICE_PLUGIN:
|
|
133495
134047
|
return this.processServicePlugin({
|
|
133496
134048
|
extension,
|
|
133497
134049
|
blueprint,
|
|
133498
134050
|
outputPath,
|
|
133499
|
-
|
|
134051
|
+
planAndResources
|
|
133500
134052
|
});
|
|
133501
134053
|
default:
|
|
133502
134054
|
return this.processStandardExtension({
|
|
133503
134055
|
extension,
|
|
133504
134056
|
blueprint,
|
|
133505
134057
|
outputPath,
|
|
133506
|
-
|
|
134058
|
+
planAndResources
|
|
133507
134059
|
});
|
|
133508
134060
|
}
|
|
133509
134061
|
}
|
|
133510
|
-
async processDashboardPage(
|
|
134062
|
+
async processDashboardPage(opts) {
|
|
133511
134063
|
const decisionAgent = this.agentsFactory.getAgent({
|
|
133512
134064
|
type: "DASHBOARD_DECISION"
|
|
133513
134065
|
});
|
|
133514
|
-
const decision = await decisionAgent.generate(
|
|
133515
|
-
blueprint,
|
|
133516
|
-
extension,
|
|
133517
|
-
createdCollections
|
|
133518
|
-
});
|
|
134066
|
+
const decision = await decisionAgent.generate(opts);
|
|
133519
134067
|
const useAutoPatterns = decision.useAutoPatterns && decision.schema && decision.relevantCollectionId;
|
|
133520
|
-
if (useAutoPatterns) {
|
|
133521
|
-
console.log("\u{1F3AF} Using auto-patterns for dashboard generation");
|
|
133522
|
-
const relevantCollection = createdCollections.find((c) => c.id === decision.relevantCollectionId);
|
|
133523
|
-
if (!relevantCollection) {
|
|
133524
|
-
throw new Error(`\u274C Collection with ID ${decision.relevantCollectionId} not found in created collections`);
|
|
133525
|
-
}
|
|
133526
|
-
const autoPatternsGenerator = this.agentsFactory.getAgent({
|
|
133527
|
-
type: "AUTO_PATTERNS_GENERATOR"
|
|
133528
|
-
});
|
|
133529
|
-
this.emitEvent("agent:start", {
|
|
133530
|
-
extension,
|
|
133531
|
-
name: "AutoPatternsGenerator"
|
|
133532
|
-
});
|
|
133533
|
-
const files = autoPatternsGenerator.generate({
|
|
133534
|
-
collection: relevantCollection,
|
|
133535
|
-
decision,
|
|
133536
|
-
extensionName: extension.name || ""
|
|
133537
|
-
});
|
|
133538
|
-
this.writeFile(files, outputPath);
|
|
133539
|
-
const pagePath = files[0].path || "";
|
|
133540
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, pagePath);
|
|
133541
|
-
this.emitEvent("agent:done", {
|
|
133542
|
-
extension,
|
|
133543
|
-
name: "AutoPatternsGenerator",
|
|
133544
|
-
files
|
|
133545
|
-
});
|
|
133546
|
-
} else {
|
|
134068
|
+
if (!useAutoPatterns) {
|
|
133547
134069
|
console.log("\u{1F3A8} Using custom code generation for dashboard");
|
|
133548
|
-
this.
|
|
133549
|
-
|
|
133550
|
-
if (!scaffolds || scaffolds.length === 0) {
|
|
133551
|
-
throw new Error(`\u274C Failed to scaffold ${extension.type}`);
|
|
133552
|
-
}
|
|
133553
|
-
const scaffold = scaffolds[0];
|
|
133554
|
-
this.emitEvent("scaffold:done", {
|
|
133555
|
-
extension,
|
|
133556
|
-
scaffoldPath: scaffolds.map((s) => s.path).join(", ")
|
|
133557
|
-
});
|
|
133558
|
-
const agent = this.agentsFactory.getAgent(extension);
|
|
133559
|
-
this.emitEvent("agent:start", { extension, name: agent.name });
|
|
133560
|
-
const files = await agent.generate({
|
|
133561
|
-
extension,
|
|
133562
|
-
blueprint,
|
|
133563
|
-
scaffold,
|
|
133564
|
-
createdCollections,
|
|
133565
|
-
basePath: outputPath
|
|
133566
|
-
});
|
|
133567
|
-
this.writeFile(files, outputPath);
|
|
133568
|
-
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133569
|
-
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
134070
|
+
await this.processStandardExtension(opts);
|
|
134071
|
+
return;
|
|
133570
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
|
+
});
|
|
133571
134099
|
}
|
|
133572
|
-
async processServicePlugin({ extension, blueprint, outputPath,
|
|
134100
|
+
async processServicePlugin({ extension, blueprint, outputPath, planAndResources }) {
|
|
133573
134101
|
this.emitEvent("scaffold:start", { extension });
|
|
133574
134102
|
const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
|
|
133575
134103
|
if (!scaffolds || scaffolds.length === 0) {
|
|
@@ -133584,7 +134112,7 @@ var require_orchestrator = __commonJS({
|
|
|
133584
134112
|
extension,
|
|
133585
134113
|
blueprint,
|
|
133586
134114
|
outputPath,
|
|
133587
|
-
|
|
134115
|
+
planAndResources,
|
|
133588
134116
|
scaffolds
|
|
133589
134117
|
});
|
|
133590
134118
|
}
|
|
@@ -133595,14 +134123,14 @@ var require_orchestrator = __commonJS({
|
|
|
133595
134123
|
extension,
|
|
133596
134124
|
blueprint,
|
|
133597
134125
|
scaffold,
|
|
133598
|
-
|
|
134126
|
+
planAndResources,
|
|
133599
134127
|
basePath: outputPath
|
|
133600
134128
|
});
|
|
133601
134129
|
this.writeFile(files, outputPath);
|
|
133602
134130
|
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133603
134131
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
133604
134132
|
}
|
|
133605
|
-
async processStandardExtension({ extension, blueprint, outputPath,
|
|
134133
|
+
async processStandardExtension({ extension, blueprint, outputPath, planAndResources }) {
|
|
133606
134134
|
this.emitEvent("scaffold:start", { extension });
|
|
133607
134135
|
const scaffolds = await (0, ditto_scaffolding_1.copyScaffoldingTemplate)(extension, outputPath);
|
|
133608
134136
|
if (!scaffolds || scaffolds.length === 0) {
|
|
@@ -133619,14 +134147,14 @@ var require_orchestrator = __commonJS({
|
|
|
133619
134147
|
extension,
|
|
133620
134148
|
blueprint,
|
|
133621
134149
|
scaffold,
|
|
133622
|
-
|
|
134150
|
+
planAndResources,
|
|
133623
134151
|
basePath: outputPath
|
|
133624
134152
|
});
|
|
133625
134153
|
this.writeFile(files, outputPath);
|
|
133626
134154
|
extensionGenerators_1.ExtensionFactory.generateExtension(extension, outputPath, scaffold.path);
|
|
133627
134155
|
this.emitEvent("agent:done", { extension, name: agent.name, files });
|
|
133628
134156
|
}
|
|
133629
|
-
async processMultipleServicePluginScaffolds({ extension, blueprint, outputPath,
|
|
134157
|
+
async processMultipleServicePluginScaffolds({ extension, blueprint, outputPath, planAndResources, scaffolds }) {
|
|
133630
134158
|
if (!extension.relatedSpis || extension.relatedSpis.length === 0) {
|
|
133631
134159
|
throw new Error("Service plugin extension must have related SPIs");
|
|
133632
134160
|
}
|
|
@@ -133648,7 +134176,7 @@ var require_orchestrator = __commonJS({
|
|
|
133648
134176
|
extension: spiExtension,
|
|
133649
134177
|
blueprint,
|
|
133650
134178
|
scaffold,
|
|
133651
|
-
|
|
134179
|
+
planAndResources,
|
|
133652
134180
|
basePath: outputPath
|
|
133653
134181
|
});
|
|
133654
134182
|
this.writeFile(files, outputPath);
|
|
@@ -133678,7 +134206,7 @@ var require_orchestrator = __commonJS({
|
|
|
133678
134206
|
blueprint: { extensions: [], appName: "", summary: "" },
|
|
133679
134207
|
// Minimal blueprint for iteration
|
|
133680
134208
|
outputPath,
|
|
133681
|
-
|
|
134209
|
+
planAndResources: {},
|
|
133682
134210
|
scaffolds
|
|
133683
134211
|
});
|
|
133684
134212
|
return;
|
|
@@ -133745,19 +134273,16 @@ var require_orchestrator = __commonJS({
|
|
|
133745
134273
|
});
|
|
133746
134274
|
const start = Date.now();
|
|
133747
134275
|
const { extensions = [] } = blueprint;
|
|
133748
|
-
const
|
|
133749
|
-
if (siteId && siteId !== "N/A" && accessToken) {
|
|
133750
|
-
const planAndResourcesResult = await this.generatePlanAndResources(request);
|
|
133751
|
-
createdCollections.push(...planAndResourcesResult.createdCollections);
|
|
133752
|
-
}
|
|
134276
|
+
const planAndResources = await this.generatePlanAndResources(request);
|
|
133753
134277
|
const parallelTasks = extensions.map((extension) => this.processExtension({
|
|
133754
134278
|
extension,
|
|
133755
134279
|
blueprint,
|
|
133756
134280
|
outputPath,
|
|
133757
|
-
|
|
134281
|
+
planAndResources
|
|
133758
134282
|
}));
|
|
133759
|
-
|
|
133760
|
-
|
|
134283
|
+
const collections = planAndResources.createdCollections ?? [];
|
|
134284
|
+
if (collections.length > 0 && siteId && siteId !== "N/A" && accessToken) {
|
|
134285
|
+
parallelTasks.push(this.generateCMSData(request, collections));
|
|
133761
134286
|
}
|
|
133762
134287
|
await Promise.all(parallelTasks.filter(Boolean));
|
|
133763
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
|
-
);
|