@wix/vibe-forms-app-plugin 0.1.0
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/README.md +3 -0
- package/dist/index.cjs +273 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -0
- package/package.json +56 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// ../../../node_modules/dedent/dist/dedent.mjs
|
|
6
|
+
function ownKeys(object, enumerableOnly) {
|
|
7
|
+
var keys = Object.keys(object);
|
|
8
|
+
if (Object.getOwnPropertySymbols) {
|
|
9
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
10
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
11
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
12
|
+
})), keys.push.apply(keys, symbols);
|
|
13
|
+
}
|
|
14
|
+
return keys;
|
|
15
|
+
}
|
|
16
|
+
function _objectSpread(target) {
|
|
17
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
19
|
+
i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
|
|
20
|
+
_defineProperty(target, key, source[key]);
|
|
21
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
22
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
function _defineProperty(obj, key, value) {
|
|
28
|
+
key = _toPropertyKey(key);
|
|
29
|
+
if (key in obj) {
|
|
30
|
+
Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
function _toPropertyKey(arg) {
|
|
37
|
+
var key = _toPrimitive(arg, "string");
|
|
38
|
+
return typeof key === "symbol" ? key : String(key);
|
|
39
|
+
}
|
|
40
|
+
function _toPrimitive(input, hint) {
|
|
41
|
+
if (typeof input !== "object" || input === null) return input;
|
|
42
|
+
var prim = input[Symbol.toPrimitive];
|
|
43
|
+
if (prim !== void 0) {
|
|
44
|
+
var res = prim.call(input, hint);
|
|
45
|
+
if (typeof res !== "object") return res;
|
|
46
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
47
|
+
}
|
|
48
|
+
return (hint === "string" ? String : Number)(input);
|
|
49
|
+
}
|
|
50
|
+
var dedent = createDedent({});
|
|
51
|
+
var dedent_default = dedent;
|
|
52
|
+
function createDedent(options) {
|
|
53
|
+
dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
|
|
54
|
+
return dedent2;
|
|
55
|
+
function dedent2(strings, ...values) {
|
|
56
|
+
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
|
57
|
+
const {
|
|
58
|
+
escapeSpecialCharacters = Array.isArray(strings),
|
|
59
|
+
trimWhitespace = true
|
|
60
|
+
} = options;
|
|
61
|
+
let result = "";
|
|
62
|
+
for (let i = 0; i < raw.length; i++) {
|
|
63
|
+
let next = raw[i];
|
|
64
|
+
if (escapeSpecialCharacters) {
|
|
65
|
+
next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
|
|
66
|
+
}
|
|
67
|
+
result += next;
|
|
68
|
+
if (i < values.length) {
|
|
69
|
+
result += values[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const lines = result.split("\n");
|
|
73
|
+
let mindent = null;
|
|
74
|
+
for (const l of lines) {
|
|
75
|
+
const m = l.match(/^(\s+)\S+/);
|
|
76
|
+
if (m) {
|
|
77
|
+
const indent = m[1].length;
|
|
78
|
+
if (!mindent) {
|
|
79
|
+
mindent = indent;
|
|
80
|
+
} else {
|
|
81
|
+
mindent = Math.min(mindent, indent);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (mindent !== null) {
|
|
86
|
+
const m = mindent;
|
|
87
|
+
result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
|
|
88
|
+
}
|
|
89
|
+
if (trimWhitespace) {
|
|
90
|
+
result = result.trim();
|
|
91
|
+
}
|
|
92
|
+
if (escapeSpecialCharacters) {
|
|
93
|
+
result = result.replace(/\\n/g, "\n");
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/constants.ts
|
|
100
|
+
var VERTICAL_NAME = "forms-app";
|
|
101
|
+
|
|
102
|
+
// src/utils.ts
|
|
103
|
+
var getSetupPrompt = () => {
|
|
104
|
+
return dedent_default`
|
|
105
|
+
You are a helpful assistant that generates mock data for a vertical.
|
|
106
|
+
You will be given a user request and you will need to generate mock data for the vertical.
|
|
107
|
+
|
|
108
|
+
# Output example:
|
|
109
|
+
User request: Example of a user request
|
|
110
|
+
|
|
111
|
+
# Output:
|
|
112
|
+
\`\`\`json
|
|
113
|
+
{
|
|
114
|
+
"message": "Replace this with your actual mock data",
|
|
115
|
+
"userRequest": "Example of a user request",
|
|
116
|
+
// Add your generated data here
|
|
117
|
+
}
|
|
118
|
+
\`\`\`
|
|
119
|
+
`;
|
|
120
|
+
};
|
|
121
|
+
var generateMockData = async (env) => {
|
|
122
|
+
console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock data...`);
|
|
123
|
+
const model = await env.providers.getOpenAIProvider({
|
|
124
|
+
model: "O3_MINI_2025_01_31",
|
|
125
|
+
tag: "Some Vertical Data Generation",
|
|
126
|
+
responseFormat: { type: "json_object" }
|
|
127
|
+
});
|
|
128
|
+
const userMessage = env.userRequest;
|
|
129
|
+
const response = await model.doGenerate({
|
|
130
|
+
prompt: [
|
|
131
|
+
{ role: "system", content: getSetupPrompt() },
|
|
132
|
+
{
|
|
133
|
+
role: "user",
|
|
134
|
+
content: [
|
|
135
|
+
{
|
|
136
|
+
type: "text",
|
|
137
|
+
text: `The User original request is: ${userMessage}`
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
inputFormat: "messages",
|
|
143
|
+
mode: { type: "regular" }
|
|
144
|
+
});
|
|
145
|
+
if (!response?.text) {
|
|
146
|
+
console.error(
|
|
147
|
+
`[${VERTICAL_NAME}-plugin-generateData] Error generating mock data:`,
|
|
148
|
+
{ response, userMessage }
|
|
149
|
+
);
|
|
150
|
+
return {};
|
|
151
|
+
}
|
|
152
|
+
let parsedResult;
|
|
153
|
+
try {
|
|
154
|
+
parsedResult = JSON.parse(response.text);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(
|
|
157
|
+
`[${VERTICAL_NAME}-plugin-generateData] Error parsing result:`,
|
|
158
|
+
error
|
|
159
|
+
);
|
|
160
|
+
parsedResult = response.text;
|
|
161
|
+
}
|
|
162
|
+
console.log(
|
|
163
|
+
`[${VERTICAL_NAME}-plugin-generateData] parsedResult`,
|
|
164
|
+
parsedResult
|
|
165
|
+
);
|
|
166
|
+
return parsedResult;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// src/forms-app-instructions.ts
|
|
170
|
+
var getFormsCodingInstructions = () => dedent_default`
|
|
171
|
+
<forms_instructions>
|
|
172
|
+
|
|
173
|
+
Your tasks for implementing and integrating the Forms features of the site are:
|
|
174
|
+
|
|
175
|
+
# FIRST TASK: ADD FORMS COMPONENT ON A SITE PAGE
|
|
176
|
+
|
|
177
|
+
Add the form component on a site page.
|
|
178
|
+
|
|
179
|
+
## Usage Examples
|
|
180
|
+
|
|
181
|
+
### Form component
|
|
182
|
+
\`\`\`tsx
|
|
183
|
+
import { FormComponent } from '@/components/forms/Form';
|
|
184
|
+
|
|
185
|
+
<FormComponent formServiceConfig={{ formId: "custom-form" }} />
|
|
186
|
+
\`\`\`
|
|
187
|
+
|
|
188
|
+
## Form Service Configuration
|
|
189
|
+
|
|
190
|
+
Forms are configured using a \`formServiceConfig\` object:
|
|
191
|
+
|
|
192
|
+
\`\`\`tsx
|
|
193
|
+
interface FormProps {
|
|
194
|
+
formServiceConfig: {
|
|
195
|
+
form?: forms.Form; // Pre-loaded form data (SSR/SSG)
|
|
196
|
+
formId?: string; // Form ID for lazy loading (client-side)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Example usage
|
|
201
|
+
const formServiceConfig = {
|
|
202
|
+
formId: "contact-form", // Lazy load form by ID
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// Or with pre-loaded data
|
|
206
|
+
const formServiceConfig = {
|
|
207
|
+
form: formData, // Use pre-loaded form data
|
|
208
|
+
};
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
# SECOND TASK: FORMS CODE CHANGES:
|
|
214
|
+
- The general instruction is to NOT CHANGE THE FORMS COMPONENTS CODE and only integrate the forms components into a site page.
|
|
215
|
+
- i.e DO NOT EDIT or READ ANY FILE in <code>./src/wix-verticals/</code> USE EVERYTHING AS IS!!
|
|
216
|
+
<code-changes-exceptions>
|
|
217
|
+
- Exceptions are when the user explicitly asks for changes to the forms components code
|
|
218
|
+
- For example, if the user asks a site in non english language, you REQUIRED to go make changes to forms composite components in: \`src/components/forms/...\`:
|
|
219
|
+
|
|
220
|
+
\`\`\`bash
|
|
221
|
+
src/components/forms/Form.tsx
|
|
222
|
+
src/components/forms/fields.tsx
|
|
223
|
+
\`\`\`
|
|
224
|
+
|
|
225
|
+
and change the static text the translate it to the new language.
|
|
226
|
+
</code-changes-exceptions>
|
|
227
|
+
|
|
228
|
+
# THIRD TASK: CODE THE REST OF THE SITE PAGES
|
|
229
|
+
|
|
230
|
+
<important_notes>
|
|
231
|
+
<strong>ALL FORMS FEATURES (submit button, validation, etc.) ARE ALREADY IMPLEMENTED BY THE FORMS COMPONENTS.</strong>
|
|
232
|
+
<strong>THE REST OF THE SITE PAGES SHOULD BE IMPLEMENTED AS USUAL ACCORDING TO THE PLAN AND USER REQUESTS, FOLLOWING THE OTHER INSTRUCTIONS IN THE CONTEXT.</strong>
|
|
233
|
+
|
|
234
|
+
</important_notes>
|
|
235
|
+
|
|
236
|
+
</forms_instructions>
|
|
237
|
+
`;
|
|
238
|
+
|
|
239
|
+
// src/index.ts
|
|
240
|
+
var generateData = async (env) => {
|
|
241
|
+
console.log(
|
|
242
|
+
`[${VERTICAL_NAME}-plugin-generateData] Starting data generation`,
|
|
243
|
+
env
|
|
244
|
+
);
|
|
245
|
+
console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock data...`);
|
|
246
|
+
const generatedData = await generateMockData(env);
|
|
247
|
+
console.log(`
|
|
248
|
+
\x1B[34m ==== Forms data generation completed ==== \x1B[0m
|
|
249
|
+
`);
|
|
250
|
+
return generatedData;
|
|
251
|
+
};
|
|
252
|
+
var getInstructions = async (params) => {
|
|
253
|
+
const actualInstructions = getFormsCodingInstructions();
|
|
254
|
+
console.log(
|
|
255
|
+
`[${VERTICAL_NAME}-plugin-getInstructions] Getting instructions`,
|
|
256
|
+
{
|
|
257
|
+
result: params.result,
|
|
258
|
+
originalInstructions: params.originalInstructions,
|
|
259
|
+
actualInstructions
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
return actualInstructions;
|
|
263
|
+
};
|
|
264
|
+
var formsPlugin = {
|
|
265
|
+
generateData,
|
|
266
|
+
getInstructions
|
|
267
|
+
};
|
|
268
|
+
var index_default = formsPlugin;
|
|
269
|
+
|
|
270
|
+
exports.default = index_default;
|
|
271
|
+
exports.formsPlugin = formsPlugin;
|
|
272
|
+
//# sourceMappingURL=index.cjs.map
|
|
273
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/dedent/dist/dedent.mjs","../src/constants.ts","../src/utils.ts","../src/forms-app-instructions.ts","../src/index.ts"],"names":["dedent"],"mappings":";;;;;AAAA,SAAS,OAAA,CAAQ,QAAQ,cAAA,EAAgB;AAAE,EAAA,IAAI,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA;AAAG,EAAA,IAAI,OAAO,qBAAA,EAAuB;AAAE,IAAA,IAAI,OAAA,GAAU,MAAA,CAAO,qBAAA,CAAsB,MAAM,CAAA;AAAG,IAAA,cAAA,KAAmB,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,SAAU,GAAA,EAAK;AAAE,MAAA,OAAO,MAAA,CAAO,wBAAA,CAAyB,MAAA,EAAQ,GAAG,CAAA,CAAE,UAAA;AAAA,IAAY,CAAC,CAAA,CAAA,EAAI,IAAA,CAAK,IAAA,CAAK,KAAA,CAAM,MAAM,OAAO,CAAA;AAAA,EAAG;AAAE,EAAA,OAAO,IAAA;AAAM;AACpV,SAAS,cAAc,MAAA,EAAQ;AAAE,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,SAAA,CAAU,QAAQ,CAAA,EAAA,EAAK;AAAE,IAAA,IAAI,MAAA,GAAS,QAAQ,SAAA,CAAU,CAAC,IAAI,SAAA,CAAU,CAAC,IAAI,EAAC;AAAG,IAAA,CAAA,GAAI,CAAA,GAAI,QAAQ,MAAA,CAAO,MAAM,GAAG,IAAE,CAAA,CAAE,OAAA,CAAQ,SAAU,GAAA,EAAK;AAAE,MAAA,eAAA,CAAgB,MAAA,EAAQ,GAAA,EAAK,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,IAAG,CAAC,CAAA,GAAI,MAAA,CAAO,4BAA4B,MAAA,CAAO,gBAAA,CAAiB,QAAQ,MAAA,CAAO,yBAAA,CA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,OAAO,kBAAA;AACT,CAAA;AAEO,IAAM,WAAA,GAA4B;AAAA,EACvC,YAAA;AAAA,EACA;AACF;AAEA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return typeof key === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (typeof input !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (typeof res !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nconst dedent = createDedent({});\nexport default dedent;\nfunction createDedent(options) {\n dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));\n return dedent;\n function dedent(strings, ...values) {\n const raw = typeof strings === \"string\" ? [strings] : strings.raw;\n const {\n escapeSpecialCharacters = Array.isArray(strings),\n trimWhitespace = true\n } = options;\n\n // first, perform interpolation\n let result = \"\";\n for (let i = 0; i < raw.length; i++) {\n let next = raw[i];\n if (escapeSpecialCharacters) {\n // handle escaped newlines, backticks, and interpolation characters\n next = next.replace(/\\\\\\n[ \\t]*/g, \"\").replace(/\\\\`/g, \"`\").replace(/\\\\\\$/g, \"$\").replace(/\\\\\\{/g, \"{\");\n }\n result += next;\n if (i < values.length) {\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\n result += values[i];\n }\n }\n\n // now strip indentation\n const lines = result.split(\"\\n\");\n let mindent = null;\n for (const l of lines) {\n const m = l.match(/^(\\s+)\\S+/);\n if (m) {\n const indent = m[1].length;\n if (!mindent) {\n // this is the first indented line\n mindent = indent;\n } else {\n mindent = Math.min(mindent, indent);\n }\n }\n }\n if (mindent !== null) {\n const m = mindent; // appease TypeScript\n result = lines\n // https://github.com/typescript-eslint/typescript-eslint/issues/7140\n // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n .map(l => l[0] === \" \" || l[0] === \"\\t\" ? l.slice(m) : l).join(\"\\n\");\n }\n\n // dedent eats leading and trailing whitespace too\n if (trimWhitespace) {\n result = result.trim();\n }\n\n // handle escaped newlines at the end to ensure they don't get stripped too\n if (escapeSpecialCharacters) {\n result = result.replace(/\\\\n/g, \"\\n\");\n }\n return result;\n }\n}\n","export const VERTICAL_NAME = \"forms-app\";\n","import dedent from \"dedent\";\nimport { PluginEnv } from \"./types\";\nimport { VERTICAL_NAME } from \"./constants\";\n\nconst getSetupPrompt = () => {\n return dedent`\n You are a helpful assistant that generates mock data for a vertical.\n You will be given a user request and you will need to generate mock data for the vertical.\n\n # Output example:\n User request: Example of a user request\n\n # Output:\n \\`\\`\\`json\n {\n \"message\": \"Replace this with your actual mock data\",\n \"userRequest\": \"Example of a user request\",\n // Add your generated data here\n }\n \\`\\`\\`\n `;\n};\n\n/**\n * Generate mock data for your vertical\n * This is where you would create sample data for development/testing\n */\nexport const generateMockData = async (env: PluginEnv) => {\n console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock data...`);\n\n // you can replace all the code below with your own vertical-specific data generation logic\n // env.providers is a util for you to use the Wix Vibe LLM providers\n // besides generating the data payload,you can (and should) use env.generateImage to generate images for your data (according to the user request)\n\n const model = await (env.providers as any).getOpenAIProvider({\n model: \"O3_MINI_2025_01_31\" as any,\n tag: \"Some Vertical Data Generation\",\n responseFormat: { type: \"json_object\" },\n });\n\n const userMessage = env.userRequest;\n\n const response = await model.doGenerate({\n prompt: [\n { role: \"system\", content: getSetupPrompt() },\n {\n role: \"user\",\n content: [\n {\n type: \"text\",\n text: `The User original request is: ${userMessage}`,\n },\n ],\n },\n ],\n inputFormat: \"messages\",\n mode: { type: \"regular\" },\n });\n\n if (!response?.text) {\n console.error(\n `[${VERTICAL_NAME}-plugin-generateData] Error generating mock data:`,\n { response, userMessage },\n );\n return {};\n }\n\n let parsedResult;\n try {\n parsedResult = JSON.parse(response.text!);\n } catch (error) {\n console.error(\n `[${VERTICAL_NAME}-plugin-generateData] Error parsing result:`,\n error,\n );\n parsedResult = response.text;\n }\n\n console.log(\n `[${VERTICAL_NAME}-plugin-generateData] parsedResult`,\n parsedResult,\n );\n\n return parsedResult;\n};\n","import dedent from \"dedent\";\n\nexport const getFormsCodingInstructions = () => dedent`\n<forms_instructions>\n\nYour tasks for implementing and integrating the Forms features of the site are:\n\n# FIRST TASK: ADD FORMS COMPONENT ON A SITE PAGE\n\nAdd the form component on a site page.\n\n## Usage Examples\n\n### Form component\n\\`\\`\\`tsx\nimport { FormComponent } from '@/components/forms/Form';\n\n<FormComponent formServiceConfig={{ formId: \"custom-form\" }} />\n\\`\\`\\`\n\n## Form Service Configuration\n\nForms are configured using a \\`formServiceConfig\\` object:\n\n\\`\\`\\`tsx\ninterface FormProps {\n formServiceConfig: {\n form?: forms.Form; // Pre-loaded form data (SSR/SSG)\n formId?: string; // Form ID for lazy loading (client-side)\n };\n}\n\n// Example usage\nconst formServiceConfig = {\n formId: \"contact-form\", // Lazy load form by ID\n};\n\n// Or with pre-loaded data\nconst formServiceConfig = {\n form: formData, // Use pre-loaded form data\n};\n\\`\\`\\`\n\n\n\n# SECOND TASK: FORMS CODE CHANGES:\n- The general instruction is to NOT CHANGE THE FORMS COMPONENTS CODE and only integrate the forms components into a site page.\n- i.e DO NOT EDIT or READ ANY FILE in <code>./src/wix-verticals/</code> USE EVERYTHING AS IS!!\n<code-changes-exceptions>\n- Exceptions are when the user explicitly asks for changes to the forms components code\n- For example, if the user asks a site in non english language, you REQUIRED to go make changes to forms composite components in: \\`src/components/forms/...\\`:\n\n\\`\\`\\`bash\nsrc/components/forms/Form.tsx\nsrc/components/forms/fields.tsx\n\\`\\`\\`\n\nand change the static text the translate it to the new language.\n</code-changes-exceptions>\n\n# THIRD TASK: CODE THE REST OF THE SITE PAGES\n\n<important_notes>\n<strong>ALL FORMS FEATURES (submit button, validation, etc.) ARE ALREADY IMPLEMENTED BY THE FORMS COMPONENTS.</strong>\n<strong>THE REST OF THE SITE PAGES SHOULD BE IMPLEMENTED AS USUAL ACCORDING TO THE PLAN AND USER REQUESTS, FOLLOWING THE OTHER INSTRUCTIONS IN THE CONTEXT.</strong>\n\n</important_notes>\n\n</forms_instructions>\n`;\n","import { PluginModule } from \"@wix/wix-vibe-plugins\";\nimport { PluginEnv } from \"./types\";\nimport { generateMockData } from \"./utils\";\nimport { getFormsCodingInstructions } from \"./forms-app-instructions\";\nimport { VERTICAL_NAME } from \"./constants\";\n\nconst generateData = async (env: PluginEnv): Promise<any> => {\n console.log(\n `[${VERTICAL_NAME}-plugin-generateData] Starting data generation`,\n env,\n );\n\n // Generate mock data based on the user's request\n console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock data...`);\n // const userRequest = env.userRequest;\n\n // TODO: call rocky\n const generatedData = await generateMockData(env);\n\n console.log(`\\n\\x1b[34m ==== Forms data generation completed ==== \\x1b[0m\\n`);\n\n return generatedData;\n};\n\n/**\n * Get instructions function - provides coding guidance to the AI\n * This helps the AI understand how to work with your vertical\n * originalInstructions is the instructions from dev center\n * result is the result of the install function\n */\nconst getInstructions = async (params: {\n result: unknown;\n originalInstructions: string | undefined;\n}) => {\n const actualInstructions = getFormsCodingInstructions();\n\n console.log(\n `[${VERTICAL_NAME}-plugin-getInstructions] Getting instructions`,\n {\n result: params.result,\n originalInstructions: params.originalInstructions,\n actualInstructions,\n },\n );\n\n return actualInstructions;\n};\n\nexport const formsPlugin: PluginModule = {\n generateData,\n getInstructions,\n};\n\nexport default formsPlugin;\n"]}
|
package/dist/index.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wix/vibe-forms-app-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/index.cjs",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"default": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"vibe-plugin"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org/",
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"jsdelivr": "dist/index.js",
|
|
23
|
+
"unpkg": "dist/index.js",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"lint:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
|
29
|
+
"lint:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\""
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@wix/wix-vibe-plugins": "^0.0.1",
|
|
33
|
+
"dedent": "^1.6.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
37
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
38
|
+
"eslint": "^9.26.0",
|
|
39
|
+
"prettier": "^3.6.2",
|
|
40
|
+
"tsup": "^8.1.0",
|
|
41
|
+
"typescript": "^5.8.3",
|
|
42
|
+
"vitest": "^2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"wix": {
|
|
45
|
+
"artifact": {
|
|
46
|
+
"groupId": "com.wixpress.ai-systems",
|
|
47
|
+
"artifactId": "vibe-forms-app-plugin"
|
|
48
|
+
},
|
|
49
|
+
"validations": {
|
|
50
|
+
"postDependenciesBuild": [
|
|
51
|
+
"lint:check"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"falconPackageHash": "aacf95477a9af478ccd871a35e3c0c98dc5b50c34856c356ba639fdb"
|
|
56
|
+
}
|