@wix/ditto-codegen-public 1.0.57 → 1.0.58

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
@@ -77705,77 +77705,6 @@ var require_servicePluginDocLoader = __commonJS({
77705
77705
  }
77706
77706
  });
77707
77707
 
77708
- // dist/system-prompts/servicePlugin/data.js
77709
- var require_data = __commonJS({
77710
- "dist/system-prompts/servicePlugin/data.js"(exports2) {
77711
- "use strict";
77712
- Object.defineProperty(exports2, "__esModule", { value: true });
77713
- exports2.dataPrompt = void 0;
77714
- exports2.dataPrompt = `<wix_data_docs>
77715
- Summary:
77716
- - Read: items.query('Collection').filter/sort.limit.find() \u2192 { items, totalCount, hasNext }
77717
- - Write: items.insert | update | remove
77718
-
77719
- Access data using the collection schema:
77720
- - Always use the exact field keys you defined in the collection schema.
77721
- - YOU MUST use the collection id exactly as you defined it in the collection schema.
77722
- - YOU MUST use the collection schema's exact field types for all operations (query, insert, update, remove)
77723
- - All custom fields are stored in the [key: string]: any part of the WixDataItem interface
77724
-
77725
- Import:
77726
- import { items } from '@wix/data';
77727
-
77728
- Available Methods:
77729
-
77730
- #### items.query(dataCollectionId: string)
77731
- - **Description**: Creates a query to retrieve items from a collection. Supports filtering, sorting, and pagination via chaining methods.
77732
- Use for reading configuration settings, dynamic content, and structured data.
77733
- The query() method runs with the following WixDataQuery defaults that you can override:
77734
- - skip: 0
77735
- - limit: 50
77736
- - descending: by _createdDate
77737
- - include: none
77738
-
77739
- #### items.insert(dataCollectionId: string, item: object)
77740
- - **Description**: Inserts an item into a collection.
77741
- Use for creating configuration entries and dynamic content.
77742
- - Example:
77743
- const toInsert = {
77744
- title: "Mr.",
77745
- first_name: "John",
77746
- last_name: "Doe",
77747
- };
77748
- const inserted = await items.insert("myCollection", toInsert);
77749
-
77750
- #### items.update(dataCollectionId: string, item: WixDataItem)
77751
- - **Description**: Updates an item in a collection. The item to update must include an \`_id\` property.
77752
- Use for modifying configuration settings and content updates.
77753
- - \`WixDataItem\` is an object with the following structure:
77754
- - \`_id\` (string): Data item ID.
77755
- - Example:
77756
- const toUpdate = {
77757
- _id: "00001",
77758
- title: "Mr.",
77759
- first_name: "John",
77760
- last_name: "Doe",
77761
- };
77762
- const updated = await items.update("myCollection", toUpdate);
77763
-
77764
- #### items.get(dataCollectionId: string, itemId: string)
77765
- - **Description**: Retrieves a single item by ID from a collection.
77766
- Use for fetching specific configuration or content entries.
77767
- - Example:
77768
- const item = await items.get("myCollection", "00001");
77769
-
77770
- #### items.remove(collectionId: string, itemId: string)
77771
- - **Description**: Deletes an item from a collection.
77772
- Use for cleaning up configuration or removing content entries.
77773
- - Example:
77774
- const result = await items.remove("myCollection", "00001");
77775
- </wix_data_docs>`;
77776
- }
77777
- });
77778
-
77779
77708
  // dist/system-prompts/apiDocLoader.js
77780
77709
  var require_apiDocLoader = __commonJS({
77781
77710
  "dist/system-prompts/apiDocLoader.js"(exports2) {
@@ -77787,9 +77716,15 @@ var require_apiDocLoader = __commonJS({
77787
77716
  "stores.productsV3.updateProduct": "stores-productsV3-updateProduct-doc.txt",
77788
77717
  "stores.products.onProductCreated": "stores-productV3-onProductCreated-doc.txt",
77789
77718
  "data.items.onDataItemCreated": "data-items-onDataItemCreated.txt",
77719
+ "data.items.query": "data-items-query-doc.tsx",
77720
+ "data.items.insert": "data-items-insert-doc.txt",
77721
+ "data.items.remove": "data-items-remove-doc.txt",
77722
+ "data.items.update": "data-items-update-doc.txt",
77723
+ "data.items.get": "data-items-get-doc.txt",
77790
77724
  "crm.contacts.onContactCreated": "crm-contacts-onContactCreated-doc.txt",
77791
77725
  "ecom.cart.onCartCreated": "ecom-cart-onCartCreated-doc.txt",
77792
- "ecom.cart.onCartUpdated": "ecom-cart-onCartUpdated-doc.txt"
77726
+ "ecom.cart.onCartUpdated": "ecom-cart-onCartUpdated-doc.txt",
77727
+ "ecom.currentCart.getCurrentCart": "ecom-currentCart-getCurrentCart-doc.txt"
77793
77728
  };
77794
77729
  function loadApiDocumentation(apiNames) {
77795
77730
  const apiDocs = (0, docLoader_1.loadDocumentation)(apiNames, API_TO_DOC_MAPPING, docLoader_1.DocType.API);
@@ -77810,9 +77745,8 @@ var require_servicePluginPrompt = __commonJS({
77810
77745
  exports2.servicePluginPrompt = void 0;
77811
77746
  exports2.getServicePluginPrompt = getServicePluginPrompt;
77812
77747
  var servicePluginDocLoader_1 = require_servicePluginDocLoader();
77813
- var data_1 = require_data();
77814
77748
  var apiDocLoader_1 = require_apiDocLoader();
77815
- function getServicePluginPrompt(spiNames = [], useData = false, apiNames = []) {
77749
+ function getServicePluginPrompt(spiNames = [], apiNames = []) {
77816
77750
  const servicePluginDocs = (0, servicePluginDocLoader_1.loadServicePluginDocumentation)(spiNames);
77817
77751
  const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
77818
77752
  return `
@@ -77928,7 +77862,6 @@ When integrating with external services:
77928
77862
  ${servicePluginDocs}
77929
77863
  </available_service_plugins>
77930
77864
  ${apiDocs}
77931
- ${useData ? data_1.dataPrompt : ""}
77932
77865
  `;
77933
77866
  }
77934
77867
  exports2.servicePluginPrompt = getServicePluginPrompt();
@@ -120746,16 +120679,15 @@ var require_SPIAgent = __commonJS({
120746
120679
  this.apiKey = apiKey;
120747
120680
  this.name = "SPIAgent";
120748
120681
  }
120749
- buildSystemPrompt(spiNames = [], useData = false, apiNames = []) {
120750
- return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData, apiNames);
120682
+ buildSystemPrompt(spiNames = [], apiNames = []) {
120683
+ return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, apiNames);
120751
120684
  }
120752
120685
  async generate(params) {
120753
- const { extension, blueprint, planAndResources } = params;
120686
+ const { extension, blueprint } = params;
120754
120687
  const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.ServicePluginExtension]);
120755
120688
  const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
120756
120689
  const apiNames = (0, utils_1.extractApiNames)(params.extension);
120757
- const useData = Boolean(planAndResources?.createdCollections?.length);
120758
- const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData, apiNames)}
120690
+ const systemPrompt = `${this.buildSystemPrompt(allSpiNames, apiNames)}
120759
120691
  ${examples}
120760
120692
  `;
120761
120693
  console.log(`SPI Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
@@ -120983,7 +120915,7 @@ ${JSON.stringify(todoExample, null, 2)}
120983
120915
  });
120984
120916
 
120985
120917
  // dist/system-prompts/planner/data.js
120986
- var require_data2 = __commonJS({
120918
+ var require_data = __commonJS({
120987
120919
  "dist/system-prompts/planner/data.js"(exports2) {
120988
120920
  "use strict";
120989
120921
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -121266,7 +121198,7 @@ var require_planner = __commonJS({
121266
121198
  Object.defineProperty(exports2, "__esModule", { value: true });
121267
121199
  exports2.plannerPrompt = void 0;
121268
121200
  var apiSpec_1 = require_apiSpec();
121269
- var data_1 = require_data2();
121201
+ var data_1 = require_data();
121270
121202
  var dynamicParameters_1 = require_dynamicParameters();
121271
121203
  var plannerPrompt = (hasEmbeddedScriptExtensions, hasBackendApiExtensions) => {
121272
121204
  return `
@@ -126550,7 +126482,7 @@ ${blocks}
126550
126482
  });
126551
126483
 
126552
126484
  // dist/system-prompts/dashboardPage/data.js
126553
- var require_data3 = __commonJS({
126485
+ var require_data2 = __commonJS({
126554
126486
  "dist/system-prompts/dashboardPage/data.js"(exports2) {
126555
126487
  "use strict";
126556
126488
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -127102,7 +127034,7 @@ var require_dashboardPagePrompt = __commonJS({
127102
127034
  var ecomPackage_1 = require_ecomPackage();
127103
127035
  var dashboardPackage_1 = require_dashboardPackage();
127104
127036
  var wdsPackage_1 = require_wdsPackage();
127105
- var data_1 = require_data3();
127037
+ var data_1 = require_data2();
127106
127038
  var apiSpecPrompt_1 = require_apiSpecPrompt();
127107
127039
  var dynamicParameters_1 = require_dynamicParameters2();
127108
127040
  var apiDocLoader_1 = require_apiDocLoader();
@@ -128161,1135 +128093,6 @@ export default withDashboard(CollectionPage);
128161
128093
  }
128162
128094
  });
128163
128095
 
128164
- // dist/system-prompts/SDK/ecom/cart.js
128165
- var require_cart = __commonJS({
128166
- "dist/system-prompts/SDK/ecom/cart.js"(exports2) {
128167
- "use strict";
128168
- Object.defineProperty(exports2, "__esModule", { value: true });
128169
- exports2.cartPrompt = void 0;
128170
- var cartPrompt = () => `
128171
- <ecom_cart_docs>
128172
-
128173
- <description>
128174
- This is a comprehensive reference guide for the Wix Ecom Current Cart SDK.
128175
- The cart is the first phase of a purchase, followed by checkout, then order.
128176
- The current cart is the cart that is currently being used by the site visitor or logged-in member.
128177
-
128178
- CRITICAL FOR EMBEDDED SCRIPTS:
128179
- - Embedded scripts MUST use the @wix/ecom SDK directly - DO NOT create fetch() calls to arbitrary API endpoints
128180
- - Import the currentCart module from '@wix/ecom' directly in your embedded script
128181
- - NEVER create fetch() calls to /api/* endpoints for cart operations unless those endpoints are explicitly defined in the API spec
128182
- - Use currentCart.getCurrentCart() and other cart methods directly in embedded script code
128183
- </description>
128184
-
128185
- <introduction>
128186
- # About the eCommerce Current Cart API
128187
-
128188
- A cart holds information about purchased items, prices, discounts, site details, buyer IDs (contact and member/visitor) and more.
128189
-
128190
- With the eCommerce Cart API you can:
128191
- - Get the current cart
128192
- - Add items to the current cart
128193
- - Create a checkout from the current cart
128194
- - Estimate the price totals for the current cart
128195
- - Update the properties of the current cart
128196
- - Update the quantity of line items in the current cart
128197
- - Remove a coupon from the current cart
128198
- - Remove line items from the current cart
128199
- - Delete the current cart
128200
-
128201
- You can also listen for events when a cart is created, updated, and deleted.
128202
-
128203
- </introduction>
128204
-
128205
- <type_signatures>
128206
- # Method Signatures & Types
128207
-
128208
- ## getCurrentCart()
128209
- \`\`\`typescript
128210
- function getCurrentCart(): Promise<Cart>
128211
- \`\`\`
128212
- **Returns:** Promise<Cart> - The current visitor's cart object
128213
-
128214
- ## addToCurrentCart(options)
128215
- \`\`\`typescript
128216
- function addToCurrentCart(options: AddToCurrentCartOptions): Promise<AddToCartResponse>
128217
-
128218
- interface AddToCurrentCartOptions {
128219
- lineItems?: Array<{
128220
- catalogReference: {
128221
- appId: string; // Required
128222
- catalogItemId: string; // Required
128223
- options?: Record<string, any>;
128224
- };
128225
- quantity: number; // Required
128226
- catalogOverrideFields?: object;
128227
- extendedFields?: object;
128228
- }>;
128229
- customLineItems?: Array<CustomLineItem>;
128230
- businessLocationId?: string;
128231
- }
128232
- \`\`\`
128233
- **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128234
-
128235
- ## createCheckoutFromCurrentCart(options)
128236
- \`\`\`typescript
128237
- function createCheckoutFromCurrentCart(options: CreateCheckoutFromCurrentCartOptions): Promise<CreateCheckoutResponse>
128238
-
128239
- interface CreateCheckoutFromCurrentCartOptions {
128240
- channelType: ChannelType; // Required: "WEB", "POS", "EBAY", etc.
128241
- email?: string;
128242
- shippingAddress?: Address;
128243
- billingAddress?: Address;
128244
- selectedShippingOption?: SelectedShippingOption;
128245
- }
128246
- \`\`\`
128247
- **Returns:** Promise<{checkoutId: string}> - The created checkout ID
128248
-
128249
- ## estimateCurrentCartTotals(options)
128250
- \`\`\`typescript
128251
- function estimateCurrentCartTotals(options?: EstimateCurrentCartTotalsOptions): Promise<EstimateTotalsResponse>
128252
-
128253
- interface EstimateCurrentCartTotalsOptions {
128254
- selectedShippingOption?: SelectedShippingOption;
128255
- shippingAddress?: Address;
128256
- billingAddress?: Address;
128257
- calculateShipping?: boolean; // Default: true
128258
- calculateTax?: boolean; // Default: true
128259
- selectedMemberships?: SelectedMemberships;
128260
- }
128261
- \`\`\`
128262
- **Returns:** Promise<EstimateTotalsResponse> - Price totals, shipping info, tax summary
128263
-
128264
- ## updateCurrentCart(options)
128265
- \`\`\`typescript
128266
- function updateCurrentCart(options: UpdateCurrentCartOptions): Promise<Cart>
128267
-
128268
- interface UpdateCurrentCartOptions {
128269
- cartInfo?: {
128270
- buyerNote?: string;
128271
- buyerInfo?: BuyerInfo;
128272
- contactInfo?: AddressWithContact;
128273
- selectedShippingOption?: SelectedShippingOption;
128274
- extendedFields?: ExtendedFields;
128275
- businessLocationId?: string;
128276
- overrideCheckoutUrl?: string;
128277
- };
128278
- lineItems?: Array<LineItem>;
128279
- customLineItems?: Array<CustomLineItem>;
128280
- couponCode?: string;
128281
- }
128282
- \`\`\`
128283
- **Returns:** Promise<Cart> - The updated cart object
128284
-
128285
- ## updateCurrentCartLineItemQuantity(lineItems)
128286
- \`\`\`typescript
128287
- function updateCurrentCartLineItemQuantity(lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
128288
-
128289
- interface LineItemQuantityUpdate {
128290
- _id: string; // Required: Line item ID
128291
- quantity: number; // Required: New quantity (min: 1)
128292
- }
128293
- \`\`\`
128294
- **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128295
-
128296
- ## removeCouponFromCurrentCart()
128297
- \`\`\`typescript
128298
- function removeCouponFromCurrentCart(): Promise<RemoveCouponResponse>
128299
- \`\`\`
128300
- **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128301
-
128302
- ## removeLineItemsFromCurrentCart(lineItemIds)
128303
- \`\`\`typescript
128304
- function removeLineItemsFromCurrentCart(lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
128305
- \`\`\`
128306
- **Parameters:**
128307
- - lineItemIds: Array<string> - Required. IDs of line items to remove
128308
-
128309
- **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128310
-
128311
- ## deleteCurrentCart()
128312
- \`\`\`typescript
128313
- function deleteCurrentCart(): Promise<void>
128314
- \`\`\`
128315
- **Returns:** Promise<void> - No return value
128316
-
128317
- ## Event Handlers
128318
-
128319
- ### onCartCreated(handler)
128320
- \`\`\`typescript
128321
- function onCartCreated(handler: (event: CartEvent) => void): void
128322
-
128323
- interface CartEvent {
128324
- entity: Cart;
128325
- metadata: EventMetadata;
128326
- }
128327
- \`\`\`
128328
-
128329
- ### onCartUpdated(handler)
128330
- \`\`\`typescript
128331
- function onCartUpdated(handler: (event: CartEvent) => void): void
128332
- \`\`\`
128333
-
128334
- ### onCartDeleted(handler)
128335
- \`\`\`typescript
128336
- function onCartDeleted(handler: (event: DeletedCartEvent) => void): void
128337
-
128338
- interface DeletedCartEvent {
128339
- metadata: {
128340
- entityId: string;
128341
- eventTime: string;
128342
- };
128343
- }
128344
- \`\`\`
128345
-
128346
- ## Common Types
128347
-
128348
- ### Cart Object
128349
- \`\`\`typescript
128350
- interface Cart {
128351
- _id: string;
128352
- _createdDate: Date;
128353
- _updatedDate: Date;
128354
- lineItems: Array<LineItem>;
128355
- buyerInfo?: BuyerInfo;
128356
- currency: string;
128357
- conversionCurrency: string;
128358
- paymentCurrency: string;
128359
- subtotal: MultiCurrencyPrice;
128360
- appliedDiscounts?: Array<CartDiscount>;
128361
- taxIncludedInPrices: boolean;
128362
- weightUnit: "KG" | "LB";
128363
- buyerLanguage: string;
128364
- siteLanguage: string;
128365
- checkoutId?: string;
128366
- purchaseFlowId: string;
128367
- // ... additional fields
128368
- }
128369
- \`\`\`
128370
-
128371
- ### LineItem Object
128372
- \`\`\`typescript
128373
- interface LineItem {
128374
- _id: string;
128375
- quantity: number;
128376
- catalogReference: {
128377
- appId: string;
128378
- catalogItemId: string;
128379
- options?: Record<string, any>;
128380
- };
128381
- productName: {
128382
- original: string;
128383
- translated?: string;
128384
- };
128385
- price: MultiCurrencyPrice;
128386
- fullPrice: MultiCurrencyPrice;
128387
- priceBeforeDiscounts: MultiCurrencyPrice;
128388
- lineItemPrice: MultiCurrencyPrice;
128389
- image?: string;
128390
- url?: string;
128391
- availability?: ItemAvailabilityInfo;
128392
- physicalProperties?: PhysicalProperties;
128393
- itemType: ItemType;
128394
- // ... additional fields
128395
- }
128396
- \`\`\`
128397
-
128398
- ### Address Object
128399
- \`\`\`typescript
128400
- interface Address {
128401
- addressLine1?: string;
128402
- addressLine2?: string;
128403
- city?: string;
128404
- country?: string; // ISO-3166 alpha-2 format
128405
- subdivision?: string; // ISO 3166-2 format
128406
- postalCode?: string;
128407
- streetAddress?: {
128408
- name?: string;
128409
- number?: string;
128410
- };
128411
- }
128412
- \`\`\`
128413
-
128414
- ### MultiCurrencyPrice Object
128415
- \`\`\`typescript
128416
- interface MultiCurrencyPrice {
128417
- amount: string;
128418
- convertedAmount: string;
128419
- formattedAmount: string;
128420
- formattedConvertedAmount: string;
128421
- }
128422
- \`\`\`
128423
-
128424
- ### CartDiscount Object
128425
- \`\`\`typescript
128426
- interface CartDiscount {
128427
- coupon?: {
128428
- _id: string;
128429
- code: string;
128430
- };
128431
- merchantDiscount?: {
128432
- amount: MultiCurrencyPrice;
128433
- };
128434
- }
128435
- \`\`\`
128436
-
128437
- ### BuyerInfo Object
128438
- \`\`\`typescript
128439
- interface BuyerInfo {
128440
- contactId?: string;
128441
- email?: string;
128442
- memberId?: string; // If buyer is a site member
128443
- userId?: string; // If buyer is a Wix user
128444
- visitorId?: string; // If buyer is not a site member
128445
- }
128446
- \`\`\`
128447
-
128448
- **Getting User ID:**
128449
- To get the user's ID, use \`getCurrentCart()\` and access the \`buyerInfo\` object. The user will have one of three ID types:
128450
- - \`buyerInfo.memberId\` - Present when the buyer is a logged-in site member
128451
- - \`buyerInfo.userId\` - Present when the buyer is a Wix user (cart owner)
128452
- - \`buyerInfo.visitorId\` - Present when the buyer is an anonymous visitor (not logged in)
128453
-
128454
- Example:
128455
- \`\`\`javascript
128456
- const cart = await currentCart.getCurrentCart();
128457
- const userId = cart.buyerInfo?.memberId || cart.buyerInfo?.userId || cart.buyerInfo?.visitorId;
128458
- \`\`\`
128459
-
128460
- ### ItemAvailabilityInfo Object
128461
- \`\`\`typescript
128462
- interface ItemAvailabilityInfo {
128463
- status: "AVAILABLE" | "NOT_AVAILABLE" | "NOT_FOUND" | "PARTIALLY_AVAILABLE";
128464
- quantityAvailable?: number;
128465
- }
128466
- \`\`\`
128467
-
128468
- ### PhysicalProperties Object
128469
- \`\`\`typescript
128470
- interface PhysicalProperties {
128471
- sku?: string;
128472
- shippable?: boolean;
128473
- weight?: number; // Measurement unit matches weightUnit in cart
128474
- }
128475
- \`\`\`
128476
-
128477
- ### ItemType Object
128478
- \`\`\`typescript
128479
- interface ItemType {
128480
- preset?: "PHYSICAL" | "DIGITAL" | "GIFT_CARD" | "SERVICE" | "UNRECOGNISED";
128481
- custom?: string; // Custom type when preset is not suitable
128482
- }
128483
- \`\`\`
128484
-
128485
- ### ProductName Object
128486
- \`\`\`typescript
128487
- interface ProductName {
128488
- original: string; // Required - in site's default language
128489
- translated?: string; // Translated into buyer's language
128490
- }
128491
- \`\`\`
128492
-
128493
- ### DescriptionLine Object
128494
- \`\`\`typescript
128495
- interface DescriptionLine {
128496
- name: {
128497
- original: string;
128498
- translated?: string;
128499
- };
128500
- colorInfo?: {
128501
- original: string;
128502
- translated?: string;
128503
- code: string; // HEX or RGB color code
128504
- };
128505
- plainText?: {
128506
- original: string;
128507
- translated?: string;
128508
- };
128509
- lineType?: string;
128510
- }
128511
- \`\`\`
128512
-
128513
- ### SelectedShippingOption Object
128514
- \`\`\`typescript
128515
- interface SelectedShippingOption {
128516
- carrierId?: string;
128517
- code?: string; // e.g., "usps_std_overnight"
128518
- }
128519
- \`\`\`
128520
-
128521
- ### AddressWithContact Object
128522
- \`\`\`typescript
128523
- interface AddressWithContact {
128524
- address?: Address;
128525
- contactDetails?: {
128526
- firstName?: string;
128527
- lastName?: string;
128528
- phone?: string;
128529
- company?: string;
128530
- vatId?: {
128531
- _id?: string;
128532
- type?: "CPF" | "CNPJ" | "UNSPECIFIED"; // For Brazil only
128533
- };
128534
- };
128535
- }
128536
- \`\`\`
128537
-
128538
- ### ExtendedFields Object
128539
- \`\`\`typescript
128540
- interface ExtendedFields {
128541
- namespaces?: Record<string, any>; // App-specific extended field data
128542
- }
128543
- \`\`\`
128544
-
128545
- ### CustomLineItem Object
128546
- \`\`\`typescript
128547
- interface CustomLineItem {
128548
- _id?: string; // Auto-generated if not provided
128549
- productName: ProductName; // Required
128550
- price: string; // Required - number or decimal without symbols
128551
- itemType: ItemType; // Required
128552
- quantity?: number; // Min: 1, Max: 100000
128553
- catalogReference?: CatalogReference;
128554
- descriptionLines?: Array<DescriptionLine>;
128555
- media?: string; // Image from Wix media manager
128556
- url?: string;
128557
- fullPrice?: string;
128558
- quantityAvailable?: number;
128559
- physicalProperties?: PhysicalProperties;
128560
- deliveryProfileId?: string;
128561
- taxGroupId?: string;
128562
- membersOnly?: boolean;
128563
- paymentOption?: PaymentOptionType;
128564
- depositAmount?: string;
128565
- // ... additional fields
128566
- }
128567
- \`\`\`
128568
-
128569
- ### CatalogReference Object
128570
- \`\`\`typescript
128571
- interface CatalogReference {
128572
- appId: string; // Required
128573
- catalogItemId: string; // Required
128574
- options?: Record<string, any>; // Additional item details
128575
- }
128576
- \`\`\`
128577
-
128578
- ### PaymentOptionType
128579
- \`\`\`typescript
128580
- type PaymentOptionType =
128581
- | "FULL_PAYMENT_ONLINE" // Entire payment during checkout
128582
- | "FULL_PAYMENT_OFFLINE" // Payment after checkout (cash, check, etc.)
128583
- | "MEMBERSHIP" // Charged to membership
128584
- | "MEMBERSHIP_OFFLINE" // Membership, manually redeemed by admin
128585
- | "DEPOSIT_ONLINE" // Partial payment upfront
128586
- | "MEMBERSHIP_ONLINE_WITH_OFFLINE_REMAINDER"; // Membership + offline remainder
128587
- \`\`\`
128588
-
128589
- ### ChannelType
128590
- \`\`\`typescript
128591
- type ChannelType =
128592
- | "WEB" // Web client
128593
- | "POS" // Point of sale
128594
- | "EBAY" // eBay shop
128595
- | "AMAZON" // Amazon shop
128596
- | "FACEBOOK" // Facebook shop
128597
- | "WIX_APP_STORE" // Wix Owner app
128598
- | "BACKOFFICE_MERCHANT" // Wix merchant backoffice
128599
- | "OTHER_PLATFORM"; // Other platform
128600
- \`\`\`
128601
-
128602
- ### ModifierGroup Object
128603
- \`\`\`typescript
128604
- interface ModifierGroup {
128605
- _id?: string;
128606
- name?: {
128607
- original: string;
128608
- translated?: string;
128609
- };
128610
- modifiers?: Array<{
128611
- _id?: string;
128612
- label?: {
128613
- original: string;
128614
- translated?: string;
128615
- };
128616
- price?: MultiCurrencyPrice;
128617
- quantity?: number;
128618
- details?: {
128619
- original: string;
128620
- translated?: string;
128621
- };
128622
- }>;
128623
- }
128624
- \`\`\`
128625
-
128626
- ### SelectedMembership Object
128627
- \`\`\`typescript
128628
- interface SelectedMembership {
128629
- _id: string; // Required - Membership GUID
128630
- appId: string; // Required - App GUID providing this payment option
128631
- }
128632
- \`\`\`
128633
-
128634
- ### ServiceProperties Object
128635
- \`\`\`typescript
128636
- interface ServiceProperties {
128637
- numberOfParticipants?: number; // Number of people (class size, hotel room, etc.)
128638
- scheduledDate?: Date; // ISO-8601 format - when service is provided
128639
- }
128640
- \`\`\`
128641
-
128642
- ### EstimateTotalsResponse Object
128643
- \`\`\`typescript
128644
- interface EstimateTotalsResponse {
128645
- cart: Cart;
128646
- calculatedLineItems: Array<{
128647
- lineItemId: string;
128648
- pricesBreakdown: LineItemPricesData;
128649
- paymentOption?: PaymentOptionType;
128650
- taxableAddress?: TaxableAddress;
128651
- }>;
128652
- priceSummary: PriceSummary;
128653
- shippingInfo?: ShippingInformation;
128654
- taxSummary?: TaxSummary;
128655
- appliedDiscounts?: Array<AppliedDiscount>;
128656
- additionalFees?: Array<AdditionalFee>;
128657
- calculationErrors?: CalculationErrors;
128658
- membershipOptions?: MembershipOptions;
128659
- currency: string;
128660
- weightUnit: "KG" | "LB";
128661
- // ... additional fields
128662
- }
128663
- \`\`\`
128664
-
128665
- ### PriceSummary Object
128666
- \`\`\`typescript
128667
- interface PriceSummary {
128668
- subtotal: MultiCurrencyPrice;
128669
- shipping?: MultiCurrencyPrice;
128670
- tax?: MultiCurrencyPrice;
128671
- discount?: MultiCurrencyPrice;
128672
- total: MultiCurrencyPrice;
128673
- additionalFees?: MultiCurrencyPrice;
128674
- }
128675
- \`\`\`
128676
-
128677
- ### TaxSummary Object
128678
- \`\`\`typescript
128679
- interface TaxSummary {
128680
- taxableAmount?: MultiCurrencyPrice;
128681
- totalTax?: MultiCurrencyPrice;
128682
- }
128683
- \`\`\`
128684
-
128685
- ### ShippingInformation Object
128686
- \`\`\`typescript
128687
- interface ShippingInformation {
128688
- region?: {
128689
- _id: string;
128690
- name: string;
128691
- };
128692
- selectedCarrierServiceOption?: {
128693
- carrierId: string;
128694
- code: string;
128695
- title: string;
128696
- cost: {
128697
- price: MultiCurrencyPrice;
128698
- totalPriceBeforeTax: MultiCurrencyPrice;
128699
- totalPriceAfterTax: MultiCurrencyPrice;
128700
- taxDetails?: ItemTaxFullDetails;
128701
- totalDiscount?: MultiCurrencyPrice;
128702
- };
128703
- logistics?: DeliveryLogistics;
128704
- requestedShippingOption?: boolean;
128705
- };
128706
- carrierServiceOptions?: Array<CarrierServiceOption>;
128707
- }
128708
- \`\`\`
128709
-
128710
- </type_signatures>
128711
-
128712
- <methods>
128713
-
128714
- ## getCurrentCart()
128715
-
128716
- Retrieves the current site visitor's cart.
128717
-
128718
- **Important Notes:**
128719
- - This method requires visitor or member authentication.
128720
-
128721
- **Import:**
128722
- \`\`\`javascript
128723
- import { currentCart } from '@wix/ecom';
128724
- \`\`\`
128725
-
128726
- **Example - General Usage:**
128727
- \`\`\`javascript
128728
- import { currentCart } from '@wix/ecom';
128729
-
128730
- currentCart.getCurrentCart()
128731
- .then((myCurrentCart) => {
128732
- const cartId = myCurrentCart._id;
128733
- const cartLineItems = myCurrentCart.lineItems;
128734
- console.log('Success! Retrieved myCurrentCart:', myCurrentCart);
128735
- return myCurrentCart;
128736
- })
128737
- .catch((error) => {
128738
- console.error(error);
128739
- });
128740
- \`\`\`
128741
-
128742
- ---
128743
-
128744
- ## addToCurrentCart(options)
128745
-
128746
- Adds catalog line items to the current site visitor's cart.
128747
-
128748
- **Important Notes:**
128749
- - When adding catalog line items, the \`lineItems.catalogReference.appId\` and \`lineItems.catalogReference.catalogItemId\` fields are required.
128750
- - This method requires visitor or member authentication.
128751
- - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128752
-
128753
- **Example - Add a Wix Stores product to the current cart:**
128754
- \`\`\`javascript
128755
- // Backend code - my-backend-file.web.js/ts
128756
- import { Permissions, webMethod } from '@wix/web-methods';
128757
- import { currentCart } from '@wix/ecom';
128758
-
128759
- export const myAddToCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128760
- try {
128761
- const updatedCurrentCart = await currentCart.addToCurrentCart(options);
128762
- console.log('Success! Updated current cart:', updatedCurrentCart);
128763
- return updatedCurrentCart;
128764
- } catch (error) {
128765
- console.error(error);
128766
- }
128767
- });
128768
-
128769
- // Page code
128770
- import { ecom } from "@wix/site-ecom";
128771
- import { myAddToCurrentCartFunction } from 'backend/my-backend-file.web';
128772
-
128773
- const options = {
128774
- "lineItems": [{
128775
- "catalogReference": {
128776
- "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", // Wix Stores appId
128777
- "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", // Wix Stores productId
128778
- "options": {
128779
- "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4" // Wix Stores variantId
128780
- }
128781
- },
128782
- "quantity": 1
128783
- }]
128784
- };
128785
-
128786
- const updatedCurrentCart = await myAddToCurrentCartFunction(options);
128787
- await ecom.refreshCart();
128788
- await ecom.navigateToCartPage();
128789
- \`\`\`
128790
-
128791
- ---
128792
-
128793
- ## createCheckoutFromCurrentCart(options)
128794
-
128795
- Creates a checkout from the current site visitor's cart. If a checkout was already created from the current cart, that checkout will be updated with any new information from the cart.
128796
-
128797
- **Important Notes:**
128798
- - \`channelType\` is a required field.
128799
- - This method requires visitor or member authentication.
128800
-
128801
- **Example:**
128802
- \`\`\`javascript
128803
- // Backend code - my-backend-file.web.js/ts
128804
- import { Permissions, webMethod } from '@wix/web-methods';
128805
- import { currentCart } from '@wix/ecom';
128806
-
128807
- export const myCreateCheckoutFromCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128808
- try {
128809
- const checkoutId = await currentCart.createCheckoutFromCurrentCart(options);
128810
- console.log('Success! Checkout created, checkoutId:', checkoutId);
128811
- return checkoutId;
128812
- } catch (error) {
128813
- console.error(error);
128814
- }
128815
- });
128816
-
128817
- // Page code
128818
- import { myCreateCheckoutFromCurrentCartFunction } from 'backend/my-backend-file.web';
128819
-
128820
- const options = {
128821
- "channelType": "WEB", // required field
128822
- "email": "janedoe@example.com",
128823
- "shippingAddress": {
128824
- "addressLine1": "235 West 23rd Street",
128825
- "addressLine2": "3rd floor",
128826
- "city": "New York",
128827
- "country": "US",
128828
- "postalCode": "10011",
128829
- "streetAddress": {
128830
- "name": "West 23rd Street",
128831
- "number": "235"
128832
- },
128833
- "subdivision": "US-NY"
128834
- }
128835
- };
128836
-
128837
- const checkoutId = await myCreateCheckoutFromCurrentCartFunction(options);
128838
- \`\`\`
128839
-
128840
- ---
128841
-
128842
- ## estimateCurrentCartTotals(options)
128843
-
128844
- Estimates the current cart's price totals (including tax), based on a selected carrier service, shipping address, and billing information.
128845
-
128846
- **Important Notes:**
128847
- - Not passing any properties will only estimate the cart items price totals, without considering shipping and billing information.
128848
- - This method requires visitor or member authentication.
128849
-
128850
- **Example:**
128851
- \`\`\`javascript
128852
- // Backend code - my-backend-file.web.js/ts
128853
- import { Permissions, webMethod } from '@wix/web-methods';
128854
- import { currentCart } from '@wix/ecom';
128855
-
128856
- export const myEstimateCurrentCartTotalsFunction = webMethod(Permissions.Anyone, async (estimateOptions) => {
128857
- try {
128858
- const estimatedCartTotals = await currentCart.estimateCurrentCartTotals(estimateOptions);
128859
- console.log('Success! Cart totals estimated:', estimatedCartTotals);
128860
- return estimatedCartTotals;
128861
- } catch (error) {
128862
- console.error(error);
128863
- }
128864
- });
128865
-
128866
- // Page code
128867
- import { myEstimateCurrentCartTotalsFunction } from 'backend/my-backend-file.web';
128868
-
128869
- const estimateOptions = {
128870
- "selectedShippingOption": {
128871
- "code": "standard_us_shipping"
128872
- },
128873
- "shippingAddress": {
128874
- "addressLine1": "235 West 23rd Street",
128875
- "addressLine2": "3rd floor",
128876
- "city": "New York",
128877
- "country": "US",
128878
- "postalCode": "10011",
128879
- "streetAddress": {
128880
- "name": "West 23rd Street",
128881
- "number": "235"
128882
- },
128883
- "subdivision": "US-NY"
128884
- },
128885
- "billingAddress": {
128886
- "addressLine1": "235 West 23rd Street",
128887
- "addressLine2": "3rd floor",
128888
- "city": "New York",
128889
- "country": "US",
128890
- "postalCode": "10011",
128891
- "streetAddress": {
128892
- "name": "West 23rd Street",
128893
- "number": "235"
128894
- },
128895
- "subdivision": "US-NY"
128896
- }
128897
- };
128898
-
128899
- const estimatedCartTotals = await myEstimateCurrentCartTotalsFunction(estimateOptions);
128900
- const formattedShippingPrice = estimatedCartTotals.priceSummary.shipping.formattedAmount;
128901
- const estimatedCartTotal = estimatedCartTotals.priceSummary.total.formattedAmount;
128902
- \`\`\`
128903
-
128904
- ---
128905
-
128906
- ## updateCurrentCart(options)
128907
-
128908
- Updates the current site visitor's cart.
128909
-
128910
- **Important Notes:**
128911
- - When adding catalog line items, the \`lineItems.catalogReference.appId\` and \`lineItems.catalogReference.catalogItemId\` fields are required.
128912
- - This method requires visitor or member authentication.
128913
- - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128914
-
128915
- **Example - Apply a coupon to the current cart:**
128916
- \`\`\`javascript
128917
- // Backend code - my-backend-file.web.js/ts
128918
- import { Permissions, webMethod } from '@wix/web-methods';
128919
- import { currentCart } from '@wix/ecom';
128920
-
128921
- export const myUpdateCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128922
- try {
128923
- const updatedCurrentCart = await currentCart.updateCurrentCart(options);
128924
- console.log('Success! Updated current cart:', updatedCurrentCart);
128925
- return updatedCurrentCart;
128926
- } catch (error) {
128927
- console.error(error);
128928
- }
128929
- });
128930
-
128931
- // Page code
128932
- import { ecom } from "@wix/site-ecom";
128933
- import { myUpdateCurrentCartFunction } from 'backend/my-backend-file.web';
128934
-
128935
- const updateOptions = {
128936
- "couponCode": "SUMMERSALE10"
128937
- };
128938
-
128939
- const updatedCurrentCart = await myUpdateCurrentCartFunction(updateOptions);
128940
- await ecom.refreshCart();
128941
- await ecom.navigateToCartPage();
128942
- \`\`\`
128943
-
128944
- ---
128945
-
128946
- ## updateCurrentCartLineItemQuantity(lineItems)
128947
-
128948
- Updates the quantity of 1 or more line items in the current site visitor's cart.
128949
-
128950
- **Important Notes:**
128951
- - This method is only for updating the quantity of line items.
128952
- - To entirely remove a line item from the current cart, use the removeLineItemsFromCurrentCart method.
128953
- - To add a new line item to the current cart, use the addToCurrentCart method.
128954
- - This method checks the amount of stock remaining for this line item. If the specified quantity is greater than the remaining stock, then the quantity returned in the response is the total amount of remaining stock.
128955
- - This method requires visitor or member authentication.
128956
- - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128957
-
128958
- **Example:**
128959
- \`\`\`javascript
128960
- // Backend code - my-backend-file.web.js/ts
128961
- import { Permissions, webMethod } from '@wix/web-methods';
128962
- import { currentCart } from '@wix/ecom';
128963
-
128964
- export const myUpdateCurrentCartLineItemQuantityFunction = webMethod(Permissions.Anyone, async (lineItems) => {
128965
- try {
128966
- const updatedCurrentCart = await currentCart.updateCurrentCartLineItemQuantity(lineItems);
128967
- console.log('Success! Line item quantities updated:', updatedCurrentCart);
128968
- return updatedCurrentCart;
128969
- } catch (error) {
128970
- console.error(error);
128971
- }
128972
- });
128973
-
128974
- // Page code
128975
- import { ecom } from "@wix/site-ecom";
128976
- import { myUpdateCurrentCartLineItemQuantityFunction } from 'backend/my-backend-file.web';
128977
-
128978
- const lineItems = [
128979
- {
128980
- "_id": '00000000-0000-0000-0000-000000000001',
128981
- "quantity": 2
128982
- },
128983
- {
128984
- "_id": '00000000-0000-0000-0000-000000000002',
128985
- "quantity": 3
128986
- }
128987
- ];
128988
-
128989
- const updatedCurrentCart = await myUpdateCurrentCartLineItemQuantityFunction(lineItems);
128990
- await ecom.refreshCart();
128991
- await ecom.navigateToCartPage();
128992
- \`\`\`
128993
-
128994
- ---
128995
-
128996
- ## removeCouponFromCurrentCart()
128997
-
128998
- Removes the coupon from the current site visitor's cart.
128999
-
129000
- **Important Notes:**
129001
- - This method requires visitor or member authentication.
129002
- - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
129003
-
129004
- **Example:**
129005
- \`\`\`javascript
129006
- // Backend code - my-backend-file.web.js/ts
129007
- import { Permissions, webMethod } from '@wix/web-methods';
129008
- import { currentCart } from '@wix/ecom';
129009
-
129010
- export const myRemoveCouponFromCurrentCartFunction = webMethod(Permissions.Anyone, async () => {
129011
- try {
129012
- const updatedCurrentCart = await currentCart.removeCouponFromCurrentCart();
129013
- console.log('Success! Updated current cart:', updatedCurrentCart);
129014
- return updatedCurrentCart;
129015
- } catch (error) {
129016
- console.error(error);
129017
- }
129018
- });
129019
-
129020
- // Page code
129021
- import { ecom } from "@wix/site-ecom";
129022
- import { myRemoveCouponFromCurrentCartFunction } from 'backend/my-backend-file.web';
129023
-
129024
- const updatedCurrentCart = await myRemoveCouponFromCurrentCartFunction();
129025
- await ecom.refreshCart();
129026
- await ecom.navigateToCartPage();
129027
- \`\`\`
129028
-
129029
- ---
129030
-
129031
- ## removeLineItemsFromCurrentCart(lineItemIds)
129032
-
129033
- Removes line items from the current site visitor's cart.
129034
-
129035
- **Important Notes:**
129036
- - This method requires visitor or member authentication.
129037
- - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
129038
-
129039
- **Example - Remove 3 line items from the current cart:**
129040
- \`\`\`javascript
129041
- // Backend code - my-backend-file.web.js/ts
129042
- import { Permissions, webMethod } from '@wix/web-methods';
129043
- import { currentCart } from '@wix/ecom';
129044
-
129045
- export const myRemoveLineItemsFromCurrentCartFunction = webMethod(Permissions.Anyone, async (lineItemIds) => {
129046
- try {
129047
- const updatedCurrentCart = await currentCart.removeLineItemsFromCurrentCart(lineItemIds);
129048
- console.log('Success! Line items removed from cart:', updatedCurrentCart);
129049
- return updatedCurrentCart;
129050
- } catch (error) {
129051
- console.error(error);
129052
- }
129053
- });
129054
-
129055
- // Page code
129056
- import { ecom } from "@wix/site-ecom";
129057
- import { myRemoveLineItemsFromCurrentCartFunction } from 'backend/my-backend-file.web';
129058
-
129059
- const lineItemIds = [
129060
- '00000000-0000-0000-0000-000000000001',
129061
- '00000000-0000-0000-0000-000000000002',
129062
- '00000000-0000-0000-0000-000000000003'
129063
- ];
129064
-
129065
- const updatedCurrentCart = await myRemoveLineItemsFromCurrentCartFunction(lineItemIds);
129066
- await ecom.refreshCart();
129067
- await ecom.navigateToCartPage();
129068
- \`\`\`
129069
-
129070
- ---
129071
-
129072
- ## deleteCurrentCart()
129073
-
129074
- Deletes the current site visitor's cart.
129075
-
129076
- **Important Notes:**
129077
- - This method requires visitor or member authentication.
129078
-
129079
- **Example:**
129080
- \`\`\`javascript
129081
- // Backend code - my-backend-file.web.js/ts
129082
- import { Permissions, webMethod } from '@wix/web-methods';
129083
- import { currentCart } from '@wix/ecom';
129084
-
129085
- export const myDeleteCurrentCartFunction = webMethod(Permissions.Anyone, async () => {
129086
- try {
129087
- await currentCart.deleteCurrentCart();
129088
- console.log('Success! Deleted cart');
129089
- return;
129090
- } catch (error) {
129091
- console.error(error);
129092
- }
129093
- });
129094
-
129095
- // Page code
129096
- import { myDeleteCurrentCartFunction } from 'backend/my-backend-file.web';
129097
-
129098
- myDeleteCurrentCartFunction()
129099
- .then(() => {
129100
- console.log('Success! Deleted current cart');
129101
- })
129102
- .catch((error) => {
129103
- console.error(error);
129104
- });
129105
- \`\`\`
129106
-
129107
- </methods>
129108
-
129109
- <events>
129110
-
129111
- ## onCartCreated(handler)
129112
-
129113
- Triggered when a cart is created.
129114
-
129115
- **Event Handler:**
129116
- \`\`\`javascript
129117
- import { currentCart } from '@wix/ecom';
129118
-
129119
- currentCart.onCartCreated((event) => {
129120
- const cart = event.entity;
129121
- console.log('Cart created:', cart);
129122
- });
129123
- \`\`\`
129124
-
129125
- ---
129126
-
129127
- ## onCartUpdated(handler)
129128
-
129129
- Triggered when a cart is updated.
129130
-
129131
- **Event Handler:**
129132
- \`\`\`javascript
129133
- import { currentCart } from '@wix/ecom';
129134
-
129135
- currentCart.onCartUpdated((event) => {
129136
- const cart = event.entity;
129137
- console.log('Cart updated:', cart);
129138
- });
129139
- \`\`\`
129140
-
129141
- ---
129142
-
129143
- ## onCartDeleted(handler)
129144
-
129145
- Triggered when a cart is deleted.
129146
-
129147
- **Event Handler:**
129148
- \`\`\`javascript
129149
- import { currentCart } from '@wix/ecom';
129150
-
129151
- currentCart.onCartDeleted((event) => {
129152
- const cartId = event.metadata.entityId;
129153
- console.log('Cart deleted:', cartId);
129154
- });
129155
- \`\`\`
129156
-
129157
- </events>
129158
-
129159
- <migration_note>
129160
- To assist in migration from the Stores to eCommerce APIs, please refer to the Stores to eCommerce Cart Conversion Table.
129161
- </migration_note>
129162
-
129163
- </ecom_cart_docs>
129164
- `;
129165
- exports2.cartPrompt = cartPrompt;
129166
- }
129167
- });
129168
-
129169
- // dist/system-prompts/embeddedScript/data.js
129170
- var require_data4 = __commonJS({
129171
- "dist/system-prompts/embeddedScript/data.js"(exports2) {
129172
- "use strict";
129173
- Object.defineProperty(exports2, "__esModule", { value: true });
129174
- exports2.dataPrompt = void 0;
129175
- var dataPrompt = () => `
129176
- <wix_data_integration>
129177
- <description>
129178
- This embedded script can access and display dynamic content from Wix Data collections.
129179
-
129180
- IMPORTANT: Since collections are provided in the CREATED COLLECTIONS section, you MUST use @wix/data to interact with them - BUT ONLY if the collection is relevant to your use case. Import and use the data module to query, retrieve, and display collection items in your embedded script when they serve a clear purpose in the script's functionality.
129181
- </description>
129182
-
129183
- <wix_data_docs>
129184
- Summary:
129185
- - Read: items.query('Collection').filter/sort.limit.find() \u2192 { items, totalCount, hasNext }
129186
- - Embedded scripts primarily use read-only data operations for displaying dynamic content
129187
-
129188
- Access data using the collection schema:
129189
- - Always use the exact field keys you defined in the collection schema.
129190
- - YOU MUST use the collection id exactly as you defined it in the collection schema.
129191
- - YOU MUST use the collection schema's exact field types for all operations (query, insert, update, remove)
129192
- - All custom fields are stored in the [key: string]: any part of the WixDataItem interface
129193
-
129194
- Import (for backend-rendered embedded scripts):
129195
- import { items } from '@wix/data';
129196
-
129197
- Available Methods:
129198
-
129199
- #### items.query(dataCollectionId: string)
129200
- - **Description**: Creates a query to retrieve items from a collection. Supports filtering, sorting, and pagination via chaining methods.
129201
- Use for reading dynamic content to display in embedded scripts.
129202
- The query() method runs with the following WixDataQuery defaults that you can override:
129203
- - skip: 0
129204
- - limit: 50
129205
- - descending: by _createdDate
129206
- - include: none
129207
- - Example:
129208
- const result = await items.query("myCollection")
129209
- .eq("status", "active")
129210
- .limit(10)
129211
- .find();
129212
-
129213
- #### items.get(dataCollectionId: string, itemId: string)
129214
- - **Description**: Retrieves a single item by ID from a collection.
129215
- Use for fetching specific content entries.
129216
- - Example:
129217
- const item = await items.get("myCollection", "00001");
129218
-
129219
- Note: Embedded scripts should primarily focus on read operations. For write operations (insert, update, remove),
129220
- consider using backend code (HTTP functions or service plugins) and calling them from the embedded script via fetch/AJAX.
129221
- </wix_data_docs>
129222
-
129223
- <usage_in_embedded_scripts>
129224
-
129225
- 1. Relevant Collection Usage (CRITICAL):
129226
- - Only use collections that are directly relevant to your embedded script's functionality
129227
- - Ignore collections that don't apply to what you're implementing
129228
- - Each collection you query should serve a clear purpose in the script's behavior
129229
- - It's perfectly fine to not use any collections if they're not applicable to your use case
129230
- - Don't force data usage just because collections exist - use them only when they add value
129231
-
129232
- 2. DIRECT SDK USAGE (REQUIRED):
129233
- - Embedded scripts MUST use @wix/data SDK directly - DO NOT use fetch() calls to API endpoints
129234
- - Import and use the items module from @wix/data directly in your embedded script
129235
- - NEVER create fetch() calls to /api/* endpoints for data operations
129236
- - Use items.query() directly in the embedded script code
129237
-
129238
- 3. Display Dynamic Content:
129239
- - Query collections directly using @wix/data to get dynamic content that's relevant to your embedded script
129240
- - Render the data in your HTML/JavaScript
129241
- - Handle loading states and errors gracefully
129242
-
129243
- 4. Example Pattern - Displaying Collection Items:
129244
- <div id="content-container"></div>
129245
- <script type="module">
129246
- import { items } from '@wix/data';
129247
-
129248
- // CORRECT: Use @wix/data directly
129249
- async function loadContent() {
129250
- try {
129251
- const result = await items.query('myCollection')
129252
- .limit(10)
129253
- .find();
129254
-
129255
- const container = document.getElementById('content-container');
129256
- result.items.forEach(item => {
129257
- const el = document.createElement('div');
129258
- el.textContent = item.title;
129259
- container.appendChild(el);
129260
- });
129261
- } catch (error) {
129262
- console.error('Failed to load content:', error);
129263
- }
129264
- }
129265
-
129266
- loadContent();
129267
- </script>
129268
-
129269
- 5. Best Practices:
129270
- - Cache data when appropriate to reduce queries
129271
- - Handle empty states gracefully
129272
- - Show loading indicators for better UX
129273
- - Implement error handling for failed queries
129274
- - Consider pagination for large datasets
129275
-
129276
- </usage_in_embedded_scripts>
129277
-
129278
- <validation_requirements>
129279
- - Only query collections that are directly relevant to your embedded script's specific use case
129280
- - Ignore collections that don't contribute to the functionality you're implementing
129281
- - Each collection query should serve a clear, necessary purpose
129282
- - Don't include data operations just because collections are available
129283
- - Use the exact collection IDs and field keys as defined in the collection schema
129284
- - Handle cases where collections might be empty or queries might fail
129285
- </validation_requirements>
129286
-
129287
- </wix_data_integration>
129288
- `;
129289
- exports2.dataPrompt = dataPrompt;
129290
- }
129291
- });
129292
-
129293
128096
  // dist/system-prompts/embeddedScript/dynamicParameters.js
129294
128097
  var require_dynamicParameters3 = __commonJS({
129295
128098
  "dist/system-prompts/embeddedScript/dynamicParameters.js"(exports2) {
@@ -129428,10 +128231,8 @@ var require_embededScript = __commonJS({
129428
128231
  Object.defineProperty(exports2, "__esModule", { value: true });
129429
128232
  exports2.embeddedScriptPrompt = void 0;
129430
128233
  var apiDocLoader_1 = require_apiDocLoader();
129431
- var cart_1 = require_cart();
129432
- var data_1 = require_data4();
129433
128234
  var dynamicParameters_1 = require_dynamicParameters3();
129434
- var embeddedScriptPrompt = (hasDynamicParameters, useData = false, apiNames) => {
128235
+ var embeddedScriptPrompt = (hasDynamicParameters, apiNames) => {
129435
128236
  const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
129436
128237
  return `
129437
128238
  <WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
@@ -129510,13 +128311,8 @@ Embedded scripts support parameterization using template variable syntax {{varia
129510
128311
  </generation_requirements>
129511
128312
 
129512
128313
  <implementation_guidelines>
129513
-
129514
- ${useData ? (0, data_1.dataPrompt)() : ""}
129515
-
129516
128314
  ${hasDynamicParameters ? (0, dynamicParameters_1.dynamicParametersPrompt)() : ""}
129517
128315
 
129518
- ${(0, cart_1.cartPrompt)()}
129519
-
129520
128316
  ${apiDocs}
129521
128317
  </WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
129522
128318
  `;
@@ -129563,16 +128359,15 @@ var require_EmbeddedScriptAgent = __commonJS({
129563
128359
  this.apiKey = apiKey;
129564
128360
  this.name = "EmbeddedScriptAgent";
129565
128361
  }
129566
- buildSystemPrompt(hasDynamicParameters, useData, apiNames) {
129567
- return (0, embededScript_1.embeddedScriptPrompt)(hasDynamicParameters, useData, apiNames);
128362
+ buildSystemPrompt(hasDynamicParameters, apiNames) {
128363
+ return (0, embededScript_1.embeddedScriptPrompt)(hasDynamicParameters, apiNames);
129568
128364
  }
129569
128365
  async generate(params) {
129570
128366
  const { blueprint, planAndResources } = params;
129571
128367
  const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.EmbeddedScript]);
129572
128368
  const hasDynamicParameters = Boolean(planAndResources?.embeddedScriptParameters && planAndResources.embeddedScriptParameters.length > 0);
129573
- const useData = Boolean(planAndResources?.createdCollections?.length);
129574
128369
  const apiNames = (0, utils_1.extractApiNames)(params.extension);
129575
- const systemPrompt = `${this.buildSystemPrompt(hasDynamicParameters, useData, apiNames)}
128370
+ const systemPrompt = `${this.buildSystemPrompt(hasDynamicParameters, apiNames)}
129576
128371
  ${examples}
129577
128372
  `;
129578
128373
  console.log(`Embedded Script Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);