@wix/vibe-forms-app-plugin 0.32.0 → 0.32.1

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/index.cjs CHANGED
@@ -8,9 +8,224 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
+ // ../../../node_modules/dedent/dist/dedent.mjs
12
+ function ownKeys(object, enumerableOnly) {
13
+ var keys = Object.keys(object);
14
+ if (Object.getOwnPropertySymbols) {
15
+ var symbols = Object.getOwnPropertySymbols(object);
16
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
17
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
18
+ })), keys.push.apply(keys, symbols);
19
+ }
20
+ return keys;
21
+ }
22
+ function _objectSpread(target) {
23
+ for (var i = 1; i < arguments.length; i++) {
24
+ var source = null != arguments[i] ? arguments[i] : {};
25
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
26
+ _defineProperty(target, key, source[key]);
27
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
28
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
29
+ });
30
+ }
31
+ return target;
32
+ }
33
+ function _defineProperty(obj, key, value) {
34
+ key = _toPropertyKey(key);
35
+ if (key in obj) {
36
+ Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
37
+ } else {
38
+ obj[key] = value;
39
+ }
40
+ return obj;
41
+ }
42
+ function _toPropertyKey(arg) {
43
+ var key = _toPrimitive(arg, "string");
44
+ return typeof key === "symbol" ? key : String(key);
45
+ }
46
+ function _toPrimitive(input, hint) {
47
+ if (typeof input !== "object" || input === null) return input;
48
+ var prim = input[Symbol.toPrimitive];
49
+ if (prim !== void 0) {
50
+ var res = prim.call(input, hint);
51
+ if (typeof res !== "object") return res;
52
+ throw new TypeError("@@toPrimitive must return a primitive value.");
53
+ }
54
+ return (hint === "string" ? String : Number)(input);
55
+ }
56
+ var dedent = createDedent({});
57
+ var dedent_default = dedent;
58
+ function createDedent(options) {
59
+ dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
60
+ return dedent2;
61
+ function dedent2(strings, ...values) {
62
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
63
+ const {
64
+ escapeSpecialCharacters = Array.isArray(strings),
65
+ trimWhitespace = true
66
+ } = options;
67
+ let result = "";
68
+ for (let i = 0; i < raw.length; i++) {
69
+ let next = raw[i];
70
+ if (escapeSpecialCharacters) {
71
+ next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
72
+ }
73
+ result += next;
74
+ if (i < values.length) {
75
+ result += values[i];
76
+ }
77
+ }
78
+ const lines = result.split("\n");
79
+ let mindent = null;
80
+ for (const l of lines) {
81
+ const m = l.match(/^(\s+)\S+/);
82
+ if (m) {
83
+ const indent = m[1].length;
84
+ if (!mindent) {
85
+ mindent = indent;
86
+ } else {
87
+ mindent = Math.min(mindent, indent);
88
+ }
89
+ }
90
+ }
91
+ if (mindent !== null) {
92
+ const m = mindent;
93
+ result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
94
+ }
95
+ if (trimWhitespace) {
96
+ result = result.trim();
97
+ }
98
+ if (escapeSpecialCharacters) {
99
+ result = result.replace(/\\n/g, "\n");
100
+ }
101
+ return result;
102
+ }
103
+ }
104
+
105
+ // src/forms-app-instructions.ts
106
+ var getContactPageExample = (formId) => {
107
+ return dedent_default`
108
+ // src/pages/ContactPage.tsx
109
+ import Form from '@/components/forms/Form';
110
+
111
+ export function ContactPage() {
112
+ return (
113
+ <div className="max-w-4xl mx-auto px-4 py-8">
114
+ <div className="text-center mb-12">
115
+ <h1 className="font-heading text-4xl font-bold text-foreground mb-4">
116
+ Contact Us
117
+ </h1>
118
+ <p className="text-lg text-secondary-foreground">
119
+ We'd love to hear from you. Send us a message and we'll respond as soon as possible.
120
+ </p>
121
+ </div>
122
+
123
+ <div className="max-w-2xl mx-auto">
124
+ {/* Contact Form */}
125
+ <div className="bg-background border border-foreground rounded-lg p-8">
126
+ <h2 className="font-heading text-2xl font-semibold text-foreground mb-6">
127
+ Send us a Message
128
+ </h2>
129
+ {/* Use the formId from generated data */}
130
+ <Form formServiceConfig={{ formId: "${formId}" }} />
131
+ </div>
132
+ </div>
133
+ </div>
134
+ );
135
+ }
136
+ `;
137
+ };
138
+ var getExampleFormPurpose = (purpose, formId) => {
139
+ const lowerPurpose = purpose.toLowerCase();
140
+ if (lowerPurpose.includes("contact") || lowerPurpose.includes("inquiry") || lowerPurpose.includes("message")) {
141
+ return `**Example for integrating into a contact page:**
142
+
143
+ \`\`\`tsx
144
+ ${getContactPageExample(formId)}
145
+ \`\`\``;
146
+ }
147
+ if (lowerPurpose.includes("newsletter") || lowerPurpose.includes("signup") || lowerPurpose.includes("subscribe")) {
148
+ return `**Example for integrating into a newsletter signup section:**
149
+
150
+ \`\`\`tsx
151
+ // src/components/NewsletterSignup.tsx
152
+ import Form from '@/components/forms/Form';
153
+
154
+ export function NewsletterSignup() {
155
+ return (
156
+ <div className="bg-background border border-foreground rounded-lg p-6">
157
+ <h3 className="font-heading text-xl font-semibold text-foreground mb-4">
158
+ Stay Updated
159
+ </h3>
160
+ <p className="text-secondary-foreground mb-4">
161
+ Subscribe to our newsletter for the latest updates.
162
+ </p>
163
+ <Form formServiceConfig={{ formId: "${formId}" }} />
164
+ </div>
165
+ );
166
+ }
167
+ \`\`\``;
168
+ } else {
169
+ return `**Example for integrating into a page:**
170
+
171
+ \`\`\`tsx
172
+ // src/components/NewsletterSignup.tsx
173
+ import Form from '@/components/forms/Form';
174
+
175
+ export function Page() {
176
+ return (
177
+ <div className="bg-background border border-foreground rounded-lg p-6">
178
+ <Form formServiceConfig={{ formId: "${formId}" }} />
179
+ </div>
180
+ );
181
+ }
182
+ \`\`\``;
183
+ }
184
+ };
185
+ var getFormsCodingInstructions = (generatedData) => {
186
+ const formInstructions = generatedData.map((form) => {
187
+ return dedent_default`
188
+ ## Form: ${form.name}
189
+ - **Form ID**: ${form.id}
190
+ - **Description**: ${form.description}
191
+
192
+ ### Integration:
193
+ \`\`\`tsx
194
+ <Form formServiceConfig={{ formId: "${form.id}" }} />
195
+ \`\`\`
196
+
197
+ ${getExampleFormPurpose(form.description, form.id)}
198
+ `;
199
+ }).join("\n\n");
200
+ return dedent_default`
201
+ <forms_instructions>
202
+
203
+ Your tasks for implementing and integrating the Forms features of the site are:
204
+
205
+ # FIRST TASK: Analyze pages and determine form placement
206
+
207
+ Analyze site pages and determine the best location for each form based on their description.
208
+
209
+ **Common page types for forms:**
210
+ - **Contact page** - Perfect for contact forms, inquiry forms
211
+ - **About page** - Good for contact or feedback forms
212
+ - **Homepage** - Suitable for lead generation or newsletter signup
213
+
214
+ # SECOND TASK: Integrate Form components into appropriate pages
215
+
216
+ Import Form component:
217
+ \`\`\`tsx
218
+ import Form from '@/components/forms/Form';
219
+ \`\`\`
220
+
221
+ ${formInstructions}
222
+
223
+ </forms_instructions>
224
+ `;
225
+ };
226
+
11
227
  // src/constants.ts
12
228
  var VERTICAL_NAME = "forms-app";
13
- var FORMS_APP_DEF_ID = "225dd912-7dea-4738-8688-4b8c6955ffc2";
14
229
  var PROMPT_ID = "b04334db-8243-4b9e-9773-ecb2775f329e";
15
230
 
16
231
  // ../../../node_modules/@wix/sdk-runtime/build/constants.js
@@ -158973,24 +159188,6 @@ var callWixAPI = async ({
158973
159188
  return null;
158974
159189
  }
158975
159190
  };
158976
- var installWixApp = async (appDefId, siteId, env) => {
158977
- env.logger.debug("Installing Wix app...", { appDefId, siteId });
158978
- const response = await callWixAPI({
158979
- url: "https://www.wixapis.com/apps-installer-service/v1/app-instance/install",
158980
- method: "POST",
158981
- body: {
158982
- tenant: {
158983
- tenantType: "SITE",
158984
- id: siteId
158985
- },
158986
- appInstance: {
158987
- appDefId
158988
- }
158989
- },
158990
- env
158991
- });
158992
- return response;
158993
- };
158994
159191
 
158995
159192
  // src/wix-forms-apis.ts
158996
159193
  var getWixClient = async (siteId, env) => {
@@ -159055,14 +159252,6 @@ async function createForm5(schema, siteId, env) {
159055
159252
  }
159056
159253
 
159057
159254
  // src/utils.ts
159058
- var installFormsApp = async (env) => {
159059
- env.logger.debug(
159060
- `[${VERTICAL_NAME}-plugin-install] Installing vertical functionality...`,
159061
- env
159062
- );
159063
- await installWixApp(FORMS_APP_DEF_ID, env.WIX_SITE_ID, env);
159064
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Installation completed`);
159065
- };
159066
159255
  var generateFormDefinitions = async (env) => {
159067
159256
  try {
159068
159257
  const userMessage = env.userRequest;
@@ -159201,239 +159390,9 @@ var generateForms = async (env, forms) => {
159201
159390
  }
159202
159391
  };
159203
159392
 
159204
- // ../../../node_modules/dedent/dist/dedent.mjs
159205
- function ownKeys(object, enumerableOnly) {
159206
- var keys = Object.keys(object);
159207
- if (Object.getOwnPropertySymbols) {
159208
- var symbols = Object.getOwnPropertySymbols(object);
159209
- enumerableOnly && (symbols = symbols.filter(function(sym) {
159210
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
159211
- })), keys.push.apply(keys, symbols);
159212
- }
159213
- return keys;
159214
- }
159215
- function _objectSpread(target) {
159216
- for (var i = 1; i < arguments.length; i++) {
159217
- var source = null != arguments[i] ? arguments[i] : {};
159218
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
159219
- _defineProperty(target, key, source[key]);
159220
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
159221
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
159222
- });
159223
- }
159224
- return target;
159225
- }
159226
- function _defineProperty(obj, key, value) {
159227
- key = _toPropertyKey(key);
159228
- if (key in obj) {
159229
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
159230
- } else {
159231
- obj[key] = value;
159232
- }
159233
- return obj;
159234
- }
159235
- function _toPropertyKey(arg) {
159236
- var key = _toPrimitive(arg, "string");
159237
- return typeof key === "symbol" ? key : String(key);
159238
- }
159239
- function _toPrimitive(input, hint) {
159240
- if (typeof input !== "object" || input === null) return input;
159241
- var prim = input[Symbol.toPrimitive];
159242
- if (prim !== void 0) {
159243
- var res = prim.call(input, hint);
159244
- if (typeof res !== "object") return res;
159245
- throw new TypeError("@@toPrimitive must return a primitive value.");
159246
- }
159247
- return (hint === "string" ? String : Number)(input);
159248
- }
159249
- var dedent = createDedent({});
159250
- var dedent_default = dedent;
159251
- function createDedent(options) {
159252
- dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
159253
- return dedent2;
159254
- function dedent2(strings, ...values) {
159255
- const raw = typeof strings === "string" ? [strings] : strings.raw;
159256
- const {
159257
- escapeSpecialCharacters = Array.isArray(strings),
159258
- trimWhitespace = true
159259
- } = options;
159260
- let result = "";
159261
- for (let i = 0; i < raw.length; i++) {
159262
- let next = raw[i];
159263
- if (escapeSpecialCharacters) {
159264
- next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
159265
- }
159266
- result += next;
159267
- if (i < values.length) {
159268
- result += values[i];
159269
- }
159270
- }
159271
- const lines = result.split("\n");
159272
- let mindent = null;
159273
- for (const l of lines) {
159274
- const m = l.match(/^(\s+)\S+/);
159275
- if (m) {
159276
- const indent = m[1].length;
159277
- if (!mindent) {
159278
- mindent = indent;
159279
- } else {
159280
- mindent = Math.min(mindent, indent);
159281
- }
159282
- }
159283
- }
159284
- if (mindent !== null) {
159285
- const m = mindent;
159286
- result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
159287
- }
159288
- if (trimWhitespace) {
159289
- result = result.trim();
159290
- }
159291
- if (escapeSpecialCharacters) {
159292
- result = result.replace(/\\n/g, "\n");
159293
- }
159294
- return result;
159295
- }
159296
- }
159297
-
159298
- // src/forms-app-instructions.ts
159299
- var getContactPageExample = (formId) => {
159300
- return dedent_default`
159301
- // src/pages/ContactPage.tsx
159302
- import Form from '@/components/forms/Form';
159303
-
159304
- export function ContactPage() {
159305
- return (
159306
- <div className="max-w-4xl mx-auto px-4 py-8">
159307
- <div className="text-center mb-12">
159308
- <h1 className="font-heading text-4xl font-bold text-foreground mb-4">
159309
- Contact Us
159310
- </h1>
159311
- <p className="text-lg text-secondary-foreground">
159312
- We'd love to hear from you. Send us a message and we'll respond as soon as possible.
159313
- </p>
159314
- </div>
159315
-
159316
- <div className="max-w-2xl mx-auto">
159317
- {/* Contact Form */}
159318
- <div className="bg-background border border-foreground rounded-lg p-8">
159319
- <h2 className="font-heading text-2xl font-semibold text-foreground mb-6">
159320
- Send us a Message
159321
- </h2>
159322
- {/* Use the formId from generated data */}
159323
- <Form formServiceConfig={{ formId: "${formId}" }} />
159324
- </div>
159325
- </div>
159326
- </div>
159327
- );
159328
- }
159329
- `;
159330
- };
159331
- var getExampleFormPurpose = (purpose, formId) => {
159332
- const lowerPurpose = purpose.toLowerCase();
159333
- if (lowerPurpose.includes("contact") || lowerPurpose.includes("inquiry") || lowerPurpose.includes("message")) {
159334
- return `**Example for integrating into a contact page:**
159335
-
159336
- \`\`\`tsx
159337
- ${getContactPageExample(formId)}
159338
- \`\`\``;
159339
- }
159340
- if (lowerPurpose.includes("newsletter") || lowerPurpose.includes("signup") || lowerPurpose.includes("subscribe")) {
159341
- return `**Example for integrating into a newsletter signup section:**
159342
-
159343
- \`\`\`tsx
159344
- // src/components/NewsletterSignup.tsx
159345
- import Form from '@/components/forms/Form';
159346
-
159347
- export function NewsletterSignup() {
159348
- return (
159349
- <div className="bg-background border border-foreground rounded-lg p-6">
159350
- <h3 className="font-heading text-xl font-semibold text-foreground mb-4">
159351
- Stay Updated
159352
- </h3>
159353
- <p className="text-secondary-foreground mb-4">
159354
- Subscribe to our newsletter for the latest updates.
159355
- </p>
159356
- <Form formServiceConfig={{ formId: "${formId}" }} />
159357
- </div>
159358
- );
159359
- }
159360
- \`\`\``;
159361
- } else {
159362
- return `**Example for integrating into a page:**
159363
-
159364
- \`\`\`tsx
159365
- // src/components/NewsletterSignup.tsx
159366
- import Form from '@/components/forms/Form';
159367
-
159368
- export function Page() {
159369
- return (
159370
- <div className="bg-background border border-foreground rounded-lg p-6">
159371
- <Form formServiceConfig={{ formId: "${formId}" }} />
159372
- </div>
159373
- );
159374
- }
159375
- \`\`\``;
159376
- }
159377
- };
159378
- var getFormsCodingInstructions = (generatedData) => {
159379
- const formInstructions = generatedData.map((form) => {
159380
- return dedent_default`
159381
- ## Form: ${form.name}
159382
- - **Form ID**: ${form.id}
159383
- - **Description**: ${form.description}
159384
-
159385
- ### Integration:
159386
- \`\`\`tsx
159387
- <Form formServiceConfig={{ formId: "${form.id}" }} />
159388
- \`\`\`
159389
-
159390
- ${getExampleFormPurpose(form.description, form.id)}
159391
- `;
159392
- }).join("\n\n");
159393
- return dedent_default`
159394
- <forms_instructions>
159395
-
159396
- Your tasks for implementing and integrating the Forms features of the site are:
159397
-
159398
- # FIRST TASK: Analyze pages and determine form placement
159399
-
159400
- Analyze site pages and determine the best location for each form based on their description.
159401
-
159402
- **Common page types for forms:**
159403
- - **Contact page** - Perfect for contact forms, inquiry forms
159404
- - **About page** - Good for contact or feedback forms
159405
- - **Homepage** - Suitable for lead generation or newsletter signup
159406
-
159407
- # SECOND TASK: Integrate Form components into appropriate pages
159408
-
159409
- Import Form component:
159410
- \`\`\`tsx
159411
- import Form from '@/components/forms/Form';
159412
- \`\`\`
159413
-
159414
- ${formInstructions}
159415
-
159416
- </forms_instructions>
159417
- `;
159418
- };
159419
-
159420
159393
  // src/index.ts
159421
159394
  var install = async (env) => {
159422
- env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Starting installation`, {
159423
- env
159424
- });
159425
- env.logger.debug(
159426
- `[${VERTICAL_NAME}-plugin-install] Installing forms app functionality...`
159427
- );
159428
- await installFormsApp(env);
159429
- env.logger.debug(
159430
- `[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`
159431
- );
159432
- env.logger.info(
159433
- `
159434
- \x1B[34m ==== ${VERTICAL_NAME} installation completed ==== \x1B[0m
159435
- `
159436
- );
159395
+ env.logger.info(`[${VERTICAL_NAME}-plugin-install] Generating forms...`);
159437
159396
  const formDefinitions = await generateFormDefinitions(env);
159438
159397
  const data = await generateForms(env, formDefinitions);
159439
159398
  env.logger.debug(`[${VERTICAL_NAME}-plugin-install] Generated data`, {