@wix/ditto-codegen-public 1.0.52 → 1.0.54
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.
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<ecom_cart_onCartCreated>
|
|
2
|
+
<purpose>Registers a callback function as an event handler. Triggered when a cart is created. This method registers a callback function as an event handler. When developing websites or building apps with Blocks, use a Velo backend event instead of this method. The way you call this method differs depending on the framework you are working in: When using the CLI, run the generate command to add an event extension, and then call this method within the extension code. When building a self-hosted app, subscribe your app to the relevant event, and then call this method on your server.</purpose>
|
|
3
|
+
<use_cases>
|
|
4
|
+
- Initialize cart tracking and analytics when a new cart is created
|
|
5
|
+
- Send welcome messages or onboarding communications to new cart owners
|
|
6
|
+
- Trigger automated workflows when a cart is first created
|
|
7
|
+
- Sync cart creation events with external systems or databases
|
|
8
|
+
- Apply initial cart settings or default configurations
|
|
9
|
+
- Send notifications when new shopping sessions begin
|
|
10
|
+
- Log new cart creation events for analytics and monitoring
|
|
11
|
+
- Initialize cart-specific features or personalization
|
|
12
|
+
</use_cases>
|
|
13
|
+
|
|
14
|
+
<method_declaration>
|
|
15
|
+
cart.onCartCreated(handler)
|
|
16
|
+
</method_declaration>
|
|
17
|
+
<required_parameters>
|
|
18
|
+
- handler: function - handler(event: CartCreatedEnvelope): void | Promise<void>
|
|
19
|
+
</required_parameters>
|
|
20
|
+
<optional_parameters>
|
|
21
|
+
None
|
|
22
|
+
</optional_parameters>
|
|
23
|
+
<import>import { cart } from '@wix/ecom'</import>
|
|
24
|
+
<types>
|
|
25
|
+
**CartCreatedEnvelope**
|
|
26
|
+
Properties:
|
|
27
|
+
- event: CartCreatedEnvelope - The cart update event envelope
|
|
28
|
+
|
|
29
|
+
**CartCreatedEnvelope**
|
|
30
|
+
Properties:
|
|
31
|
+
- entity: Cart - The updated cart entity
|
|
32
|
+
- metadata: EventMetadata - Event metadata
|
|
33
|
+
|
|
34
|
+
**Cart**
|
|
35
|
+
Properties:
|
|
36
|
+
- buyerInfo: BuyerInfo - Buyer information.
|
|
37
|
+
|
|
38
|
+
**BuyerInfo**
|
|
39
|
+
- contactId: string - Contact ID. For more information, see the Contacts API.
|
|
40
|
+
- email: string - Buyer email address.
|
|
41
|
+
- one of (id):
|
|
42
|
+
* visitorId: string - Visitor ID (format: GUID). If the buyer is not a site member.
|
|
43
|
+
* memberId: string - Member ID (format: GUID). If the buyer is a site member.
|
|
44
|
+
* userId: string - User ID (format: GUID). If the buyer, or cart owner, is a Wix user.
|
|
45
|
+
</types>
|
|
46
|
+
<important_notes>
|
|
47
|
+
- This method registers a callback function as an event handler
|
|
48
|
+
- When developing websites or building apps with Blocks, use a Velo backend event instead of this method
|
|
49
|
+
- The way you call this method differs depending on the framework you are working in:
|
|
50
|
+
- When using the CLI, run the generate command to add an event extension, and then call this method within the extension code
|
|
51
|
+
- When building a self-hosted app, subscribe your app to the relevant event, and then call this method on your server
|
|
52
|
+
- The handler function can be either synchronous (void) or asynchronous (Promise<void>)
|
|
53
|
+
- Triggered when a cart is created
|
|
54
|
+
- Required Permission: Read Orders
|
|
55
|
+
</important_notes>
|
|
56
|
+
|
|
57
|
+
<event_triggers>
|
|
58
|
+
- Cart Created: Triggered automatically when a new cart is successfully created
|
|
59
|
+
</event_triggers>
|
|
60
|
+
<example_usage>
|
|
61
|
+
```typescript
|
|
62
|
+
import { cart } from '@wix/ecom';
|
|
63
|
+
|
|
64
|
+
// Register event handler for cart creation
|
|
65
|
+
cart.onCartCreated((event) => {
|
|
66
|
+
console.log('Cart created:', event);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Async handler example
|
|
70
|
+
cart.onCartCreated(async (event) => {
|
|
71
|
+
await trackNewCart(event);
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
</example_usage>
|
|
75
|
+
<related_methods>
|
|
76
|
+
- cart.onCartUpdated() - Event handler for cart updates
|
|
77
|
+
- cart.onCartDeleted() - Event handler for cart deletion
|
|
78
|
+
- cart.getCurrentCart() - Retrieve the current cart
|
|
79
|
+
- cart.createCurrentCart() - Create a new cart
|
|
80
|
+
- cart.updateCurrentCart() - Update cart properties
|
|
81
|
+
- cart.addToCurrentCart() - Add items to cart
|
|
82
|
+
- cart.removeLineItemsFromCurrentCart() - Remove items from cart
|
|
83
|
+
</related_methods>
|
|
84
|
+
</ecom_cart_onCartCreated>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<ecom_cart_onCartUpdated>
|
|
2
|
+
<purpose>Registers a callback function as an event handler. Triggered when a cart is updated. This method registers a callback function as an event handler. When developing websites or building apps with Blocks, use a Velo backend event instead of this method. The way you call this method differs depending on the framework you are working in: When using the CLI, run the generate command to add an event extension, and then call this method within the extension code. When building a self-hosted app, subscribe your app to the relevant event, and then call this method on your server.</purpose>
|
|
3
|
+
<use_cases>
|
|
4
|
+
- Track cart changes for analytics and monitoring
|
|
5
|
+
- Update inventory systems when cart contents change
|
|
6
|
+
- Apply dynamic pricing or discounts based on cart updates
|
|
7
|
+
- Sync cart data with external systems or databases
|
|
8
|
+
- Trigger automated workflows when cart items change
|
|
9
|
+
- Send notifications or alerts for specific cart updates
|
|
10
|
+
- Log cart modifications for compliance and auditing
|
|
11
|
+
- Update product recommendations based on cart changes
|
|
12
|
+
</use_cases>
|
|
13
|
+
|
|
14
|
+
<method_declaration>
|
|
15
|
+
cart.onCartUpdated(handler)
|
|
16
|
+
</method_declaration>
|
|
17
|
+
<required_parameters>
|
|
18
|
+
- handler: function - handler(event: CartUpdatedEnvelope): void | Promise<void>
|
|
19
|
+
</required_parameters>
|
|
20
|
+
<optional_parameters>
|
|
21
|
+
None
|
|
22
|
+
</optional_parameters>
|
|
23
|
+
<import>import { cart } from '@wix/ecom'</import>
|
|
24
|
+
<types>
|
|
25
|
+
**CartUpdatedEnvelope**
|
|
26
|
+
Properties:
|
|
27
|
+
- event: CartUpdatedEnvelope - The cart update event envelope
|
|
28
|
+
|
|
29
|
+
**CartUpdatedEnvelope**
|
|
30
|
+
Properties:
|
|
31
|
+
- entity: Cart - The updated cart entity
|
|
32
|
+
- metadata: EventMetadata - Event metadata
|
|
33
|
+
|
|
34
|
+
**Cart**
|
|
35
|
+
Properties:
|
|
36
|
+
- buyerInfo: BuyerInfo - Buyer information.
|
|
37
|
+
|
|
38
|
+
**BuyerInfo**
|
|
39
|
+
- contactId: string - Contact ID. For more information, see the Contacts API.
|
|
40
|
+
- email: string - Buyer email address.
|
|
41
|
+
- one of (id):
|
|
42
|
+
* visitorId: string - Visitor ID (format: GUID). If the buyer is not a site member.
|
|
43
|
+
* memberId: string - Member ID (format: GUID). If the buyer is a site member.
|
|
44
|
+
* userId: string - User ID (format: GUID). If the buyer, or cart owner, is a Wix user.
|
|
45
|
+
</types>
|
|
46
|
+
<important_notes>
|
|
47
|
+
- This method registers a callback function as an event handler
|
|
48
|
+
- When developing websites or building apps with Blocks, use a Velo backend event instead of this method
|
|
49
|
+
- The way you call this method differs depending on the framework you are working in:
|
|
50
|
+
- When using the CLI, run the generate command to add an event extension, and then call this method within the extension code
|
|
51
|
+
- When building a self-hosted app, subscribe your app to the relevant event, and then call this method on your server
|
|
52
|
+
- The handler function can be either synchronous (void) or asynchronous (Promise<void>)
|
|
53
|
+
- Triggered when a cart is updated
|
|
54
|
+
- Required Permission: Read Orders
|
|
55
|
+
</important_notes>
|
|
56
|
+
|
|
57
|
+
<event_triggers>
|
|
58
|
+
- Cart Updated: Triggered automatically when a cart's contents, quantities, or properties are modified
|
|
59
|
+
</event_triggers>
|
|
60
|
+
<example_usage>
|
|
61
|
+
```typescript
|
|
62
|
+
import { cart } from '@wix/ecom';
|
|
63
|
+
|
|
64
|
+
// Register event handler for cart updates
|
|
65
|
+
cart.onCartUpdated((event) => {
|
|
66
|
+
console.log('Cart updated:', event);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Async handler example
|
|
70
|
+
cart.onCartUpdated(async (event) => {
|
|
71
|
+
await trackCartChanges(event);
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
</example_usage>
|
|
75
|
+
<related_methods>
|
|
76
|
+
- cart.onCartCreated() - Event handler for cart creation
|
|
77
|
+
- cart.onCartDeleted() - Event handler for cart deletion
|
|
78
|
+
- cart.getCurrentCart() - Retrieve the current cart
|
|
79
|
+
- cart.updateCurrentCart() - Update cart properties
|
|
80
|
+
- cart.addToCurrentCart() - Add items to cart
|
|
81
|
+
- cart.removeLineItemsFromCurrentCart() - Remove items from cart
|
|
82
|
+
- cart.updateCurrentCartLineItemQuantity() - Update line item quantities
|
|
83
|
+
</related_methods>
|
|
84
|
+
</ecom_cart_onCartUpdated>
|
package/dist/out.js
CHANGED
|
@@ -120290,6 +120290,27 @@ var require_index_node = __commonJS({
|
|
|
120290
120290
|
}
|
|
120291
120291
|
});
|
|
120292
120292
|
|
|
120293
|
+
// dist/system-prompts/apiDocLoader.js
|
|
120294
|
+
var require_apiDocLoader = __commonJS({
|
|
120295
|
+
"dist/system-prompts/apiDocLoader.js"(exports2) {
|
|
120296
|
+
"use strict";
|
|
120297
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120298
|
+
exports2.loadApiDocumentation = loadApiDocumentation;
|
|
120299
|
+
var docLoader_1 = require_docLoader();
|
|
120300
|
+
var API_TO_DOC_MAPPING = {
|
|
120301
|
+
"stores.productsV3.updateProduct": "stores-productsV3-updateProduct-doc.txt",
|
|
120302
|
+
"stores.products.onProductCreated": "stores-productV3-onProductCreated-doc.txt",
|
|
120303
|
+
"data.items.onDataItemCreated": "data-items-onDataItemCreated.txt",
|
|
120304
|
+
"crm.contacts.onContactCreated": "crm-contacts-onContactCreated-doc.txt",
|
|
120305
|
+
"ecom.cart.onCartCreated": "ecom-cart-onCartCreated-doc.txt",
|
|
120306
|
+
"ecom.cart.onCartUpdated": "ecom-cart-onCartUpdated-doc.txt"
|
|
120307
|
+
};
|
|
120308
|
+
function loadApiDocumentation(apiNames) {
|
|
120309
|
+
return (0, docLoader_1.loadDocumentation)(apiNames, API_TO_DOC_MAPPING, docLoader_1.DocType.API);
|
|
120310
|
+
}
|
|
120311
|
+
}
|
|
120312
|
+
});
|
|
120313
|
+
|
|
120293
120314
|
// dist/agents/utils.js
|
|
120294
120315
|
var require_utils14 = __commonJS({
|
|
120295
120316
|
"dist/agents/utils.js"(exports2) {
|
|
@@ -120298,12 +120319,13 @@ var require_utils14 = __commonJS({
|
|
|
120298
120319
|
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
|
120299
120320
|
};
|
|
120300
120321
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120301
|
-
exports2.getErrorMessage = exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = exports2.FileItemSchema = void 0;
|
|
120322
|
+
exports2.extractApiNames = exports2.getErrorMessage = exports2.buildUserPromptForCodeGenerationAgent = exports2.getHttpClient = exports2.withCaching = exports2.FileSchema = exports2.FileItemSchema = void 0;
|
|
120302
120323
|
exports2.loadRelevantFilesAsString = loadRelevantFilesAsString;
|
|
120303
120324
|
var zod_1 = require_zod();
|
|
120304
120325
|
var http_client_1 = require_index_node();
|
|
120305
120326
|
var fs_1 = __importDefault2(require("fs"));
|
|
120306
120327
|
var path_1 = __importDefault2(require("path"));
|
|
120328
|
+
var apiDocLoader_1 = require_apiDocLoader();
|
|
120307
120329
|
exports2.FileItemSchema = zod_1.z.object({
|
|
120308
120330
|
operation: zod_1.z.enum(["insert", "update", "delete"]).describe("File operation: insert (new file), update (modify existing), delete (remove file)").default("insert"),
|
|
120309
120331
|
path: zod_1.z.string().describe("Relative file path from project root").optional(),
|
|
@@ -120411,6 +120433,13 @@ ${JSON.stringify(planAndResources.apiSpec, null, 2)}`);
|
|
|
120411
120433
|
contextSections.push(`
|
|
120412
120434
|
## EMBEDDED SCRIPT PARAMETERS
|
|
120413
120435
|
${JSON.stringify(planAndResources.embeddedScriptParameters, null, 2)}`);
|
|
120436
|
+
}
|
|
120437
|
+
if (extension.relatedApis?.length) {
|
|
120438
|
+
const apiNames = (0, exports2.extractApiNames)(params.extension);
|
|
120439
|
+
const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
|
|
120440
|
+
contextSections.push(`
|
|
120441
|
+
## RELATED APIS
|
|
120442
|
+
${apiDocs}`);
|
|
120414
120443
|
}
|
|
120415
120444
|
const userMessage = `${primaryAction}:
|
|
120416
120445
|
${contextSections.join("\n")}`;
|
|
@@ -120427,6 +120456,10 @@ ${contextSections.join("\n")}`;
|
|
|
120427
120456
|
}
|
|
120428
120457
|
};
|
|
120429
120458
|
exports2.getErrorMessage = getErrorMessage;
|
|
120459
|
+
var extractApiNames = (extension) => {
|
|
120460
|
+
return extension.relatedApis?.map((api) => api.name).filter((name) => !!name) || [];
|
|
120461
|
+
};
|
|
120462
|
+
exports2.extractApiNames = extractApiNames;
|
|
120430
120463
|
}
|
|
120431
120464
|
});
|
|
120432
120465
|
|
|
@@ -124961,34 +124994,13 @@ var require_SiteComponentAgent = __commonJS({
|
|
|
124961
124994
|
}
|
|
124962
124995
|
});
|
|
124963
124996
|
|
|
124964
|
-
// dist/system-prompts/apiDocLoader.js
|
|
124965
|
-
var require_apiDocLoader = __commonJS({
|
|
124966
|
-
"dist/system-prompts/apiDocLoader.js"(exports2) {
|
|
124967
|
-
"use strict";
|
|
124968
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
124969
|
-
exports2.loadApiDocumentation = loadApiDocumentation;
|
|
124970
|
-
var docLoader_1 = require_docLoader();
|
|
124971
|
-
var API_TO_DOC_MAPPING = {
|
|
124972
|
-
"stores.productsV3.updateProduct": "stores-productsV3-updateProduct-doc.txt",
|
|
124973
|
-
"stores.products.onProductCreated": "stores-productV3-onProductCreated-doc.txt",
|
|
124974
|
-
"data.items.onDataItemCreated": "data-items-onDataItemCreated.txt",
|
|
124975
|
-
"crm.contacts.onContactCreated": "crm-contacts-onContactCreated-doc.txt"
|
|
124976
|
-
};
|
|
124977
|
-
function loadApiDocumentation(apiNames) {
|
|
124978
|
-
return (0, docLoader_1.loadDocumentation)(apiNames, API_TO_DOC_MAPPING, docLoader_1.DocType.API);
|
|
124979
|
-
}
|
|
124980
|
-
}
|
|
124981
|
-
});
|
|
124982
|
-
|
|
124983
124997
|
// dist/system-prompts/backendEvent/backendEventPrompt.js
|
|
124984
124998
|
var require_backendEventPrompt = __commonJS({
|
|
124985
124999
|
"dist/system-prompts/backendEvent/backendEventPrompt.js"(exports2) {
|
|
124986
125000
|
"use strict";
|
|
124987
125001
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
124988
125002
|
exports2.backendEventPrompt = void 0;
|
|
124989
|
-
var
|
|
124990
|
-
var backendEventPrompt = (apiNames) => {
|
|
124991
|
-
const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
|
|
125003
|
+
var backendEventPrompt = () => {
|
|
124992
125004
|
return `<BACKEND_EVENT_PROMPT>
|
|
124993
125005
|
<role>
|
|
124994
125006
|
You are a Wix backend event handler generator. Create event extensions for Wix CLI apps using the JavaScript SDK. Events are triggered when specific conditions on the app or user's site are met.
|
|
@@ -125022,10 +125034,6 @@ You are a Wix backend event handler generator. Create event extensions for Wix C
|
|
|
125022
125034
|
- Reference the corresponding SDK submodule category for event-specific information
|
|
125023
125035
|
- Events run automatically when triggered - no manual invocation needed
|
|
125024
125036
|
</implementation_guidelines>
|
|
125025
|
-
|
|
125026
|
-
<api_docs>
|
|
125027
|
-
${apiDocs}
|
|
125028
|
-
</api_docs>
|
|
125029
125037
|
</BACKEND_EVENT_PROMPT>`;
|
|
125030
125038
|
};
|
|
125031
125039
|
exports2.backendEventPrompt = backendEventPrompt;
|
|
@@ -125085,14 +125093,13 @@ var require_BackendEventAgent = __commonJS({
|
|
|
125085
125093
|
this.apiKey = apiKey;
|
|
125086
125094
|
this.name = "BackendEventAgent";
|
|
125087
125095
|
}
|
|
125088
|
-
buildSystemPrompt(
|
|
125089
|
-
return (0, backendEventPrompt_1.backendEventPrompt)(
|
|
125096
|
+
buildSystemPrompt() {
|
|
125097
|
+
return (0, backendEventPrompt_1.backendEventPrompt)();
|
|
125090
125098
|
}
|
|
125091
125099
|
async generate(params) {
|
|
125092
125100
|
const { blueprint } = params;
|
|
125093
125101
|
const examples = (0, load_examples_1.default)([load_examples_1.types.BackendEvent]);
|
|
125094
|
-
const
|
|
125095
|
-
const systemPrompt = `${this.buildSystemPrompt(allApiNames)}
|
|
125102
|
+
const systemPrompt = `${this.buildSystemPrompt()}
|
|
125096
125103
|
${examples}
|
|
125097
125104
|
`;
|
|
125098
125105
|
const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
|
|
@@ -131287,7 +131294,9 @@ var require_extensionGenerators = __commonJS({
|
|
|
131287
131294
|
ExtensionFactory.apiToSlug = {
|
|
131288
131295
|
"stores.productsV3.onProductCreated": "wix.stores.catalog.v3.product_created",
|
|
131289
131296
|
"crm.contacts.onContactCreated": "wix.contacts.v4.contact_created",
|
|
131290
|
-
"data.items.onDataItemCreated": "wix.data.v2.data_item_created"
|
|
131297
|
+
"data.items.onDataItemCreated": "wix.data.v2.data_item_created",
|
|
131298
|
+
"ecom.cart.onCartCreated": "wix.ecom.v1.cart_created",
|
|
131299
|
+
"ecom.cart.onCartUpdated": "wix.ecom.v1.cart_updated"
|
|
131291
131300
|
};
|
|
131292
131301
|
function getScaffoldPath(scaffoldDir, file) {
|
|
131293
131302
|
return "./" + path_1.default.join(scaffoldDir, file).replace(/^src\//, "");
|
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.54",
|
|
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": "d1a0ebf97acef33131fa09a202f3c6ccf08a381afd538155ebd4da4d"
|
|
28
28
|
}
|