@wix/ditto-codegen-public 1.0.43 → 1.0.44

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.
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/react": "^16.0.0",
13
+ "@wix/data": "^1.0.290",
13
14
  "@types/react-dom": "^16.0.0",
14
15
  "@wix/cli": "^1.0.0",
15
16
  "@wix/cli-app": "^1.0.0",
@@ -1,24 +1,66 @@
1
- import { additionalFees } from "@wix/ecom/service-plugins";
1
+ import { additionalFees } from '@wix/ecom/service-plugins';
2
+ import { items } from '@wix/data';
3
+
4
+ interface GlobalFeeConfig {
5
+ _id: string;
6
+ feeAmount: number;
7
+ isEnabled: boolean;
8
+ }
2
9
 
3
10
  additionalFees.provideHandlers({
4
- calculateAdditionalFees: async (payload) => {
5
- const { request, metadata } = payload;
6
- // Use the `request` and `metadata` received from Wix and
7
- // apply custom logic.
8
- return {
9
- // Return your response exactly as documented to integrate with Wix.
10
- // Return value example:
11
- additionalFees: [
12
- {
13
- code: "subscription-fee",
14
- name: "Subscription Fee",
15
- price: "5",
16
- taxDetails: {
17
- taxable: true,
18
- },
19
- },
20
- ],
21
- currency: metadata.currency || "ILS",
22
- };
11
+ calculateAdditionalFees: async ({ request, metadata }) => {
12
+ try {
13
+ // Query the global additional fee configuration
14
+ const configResult = await items.query('global-additional-fee-config')
15
+ .limit(1)
16
+ .find();
17
+
18
+ // If no configuration found or fee is disabled, return empty fees
19
+ if (!configResult.items.length) {
20
+ return {
21
+ additionalFees: [],
22
+ currency: metadata.currency || 'USD'
23
+ };
24
+ }
25
+
26
+ const config = configResult.items[0] as GlobalFeeConfig;
27
+
28
+ // Check if the fee is enabled and has a valid amount
29
+ if (!config.isEnabled || !config.feeAmount || config.feeAmount <= 0) {
30
+ return {
31
+ additionalFees: [],
32
+ currency: metadata.currency || 'USD'
33
+ };
34
+ }
35
+
36
+ // Ensure currency matches site currency
37
+ const responseCurrency = metadata.currency || 'USD';
38
+
39
+ // Convert fee amount to string as required by Wix API
40
+ const feeAmountString = config.feeAmount.toString();
41
+
42
+ // Create the global additional fee
43
+ const globalFee = {
44
+ code: 'global-additional-fee',
45
+ name: 'Global Additional Fee',
46
+ translatedName: 'Global Additional Fee',
47
+ price: feeAmountString,
48
+ taxDetails: {
49
+ taxable: true
50
+ }
51
+ // No lineItemIds specified - applies to entire cart
52
+ };
53
+
54
+ return {
55
+ additionalFees: [globalFee],
56
+ currency: responseCurrency
57
+ };
58
+
59
+ } catch (error) {
60
+ return {
61
+ additionalFees: [],
62
+ currency: metadata.currency || 'USD'
63
+ };
64
+ }
23
65
  },
24
66
  });
package/dist/out.js CHANGED
@@ -77683,6 +77683,77 @@ var require_servicePluginDocLoader = __commonJS({
77683
77683
  }
77684
77684
  });
77685
77685
 
77686
+ // dist/system-prompts/servicePlugin/data.js
77687
+ var require_data = __commonJS({
77688
+ "dist/system-prompts/servicePlugin/data.js"(exports2) {
77689
+ "use strict";
77690
+ Object.defineProperty(exports2, "__esModule", { value: true });
77691
+ exports2.dataPrompt = void 0;
77692
+ exports2.dataPrompt = `<wix_data_docs>
77693
+ Summary:
77694
+ - Read: items.query('Collection').filter/sort.limit.find() \u2192 { items, totalCount, hasNext }
77695
+ - Write: items.insert | update | remove
77696
+
77697
+ Access data using the collection schema:
77698
+ - Always use the exact field keys you defined in the collection schema.
77699
+ - YOU MUST use the collection id exactly as you defined it in the collection schema.
77700
+ - YOU MUST use the collection schema's exact field types for all operations (query, insert, update, remove)
77701
+ - All custom fields are stored in the [key: string]: any part of the WixDataItem interface
77702
+
77703
+ Import:
77704
+ import { items } from '@wix/data';
77705
+
77706
+ Available Methods:
77707
+
77708
+ #### items.query(dataCollectionId: string)
77709
+ - **Description**: Creates a query to retrieve items from a collection. Supports filtering, sorting, and pagination via chaining methods.
77710
+ Use for reading configuration settings, dynamic content, and structured data.
77711
+ The query() method runs with the following WixDataQuery defaults that you can override:
77712
+ - skip: 0
77713
+ - limit: 50
77714
+ - descending: by _createdDate
77715
+ - include: none
77716
+
77717
+ #### items.insert(dataCollectionId: string, item: object)
77718
+ - **Description**: Inserts an item into a collection.
77719
+ Use for creating configuration entries and dynamic content.
77720
+ - Example:
77721
+ const toInsert = {
77722
+ title: "Mr.",
77723
+ first_name: "John",
77724
+ last_name: "Doe",
77725
+ };
77726
+ const inserted = await items.insert("myCollection", toInsert);
77727
+
77728
+ #### items.update(dataCollectionId: string, item: WixDataItem)
77729
+ - **Description**: Updates an item in a collection. The item to update must include an \`_id\` property.
77730
+ Use for modifying configuration settings and content updates.
77731
+ - \`WixDataItem\` is an object with the following structure:
77732
+ - \`_id\` (string): Data item ID.
77733
+ - Example:
77734
+ const toUpdate = {
77735
+ _id: "00001",
77736
+ title: "Mr.",
77737
+ first_name: "John",
77738
+ last_name: "Doe",
77739
+ };
77740
+ const updated = await items.update("myCollection", toUpdate);
77741
+
77742
+ #### items.get(dataCollectionId: string, itemId: string)
77743
+ - **Description**: Retrieves a single item by ID from a collection.
77744
+ Use for fetching specific configuration or content entries.
77745
+ - Example:
77746
+ const item = await items.get("myCollection", "00001");
77747
+
77748
+ #### items.remove(collectionId: string, itemId: string)
77749
+ - **Description**: Deletes an item from a collection.
77750
+ Use for cleaning up configuration or removing content entries.
77751
+ - Example:
77752
+ const result = await items.remove("myCollection", "00001");
77753
+ </wix_data_docs>`;
77754
+ }
77755
+ });
77756
+
77686
77757
  // dist/system-prompts/servicePlugin/servicePluginPrompt.js
77687
77758
  var require_servicePluginPrompt = __commonJS({
77688
77759
  "dist/system-prompts/servicePlugin/servicePluginPrompt.js"(exports2) {
@@ -77691,7 +77762,8 @@ var require_servicePluginPrompt = __commonJS({
77691
77762
  exports2.servicePluginPrompt = void 0;
77692
77763
  exports2.getServicePluginPrompt = getServicePluginPrompt;
77693
77764
  var servicePluginDocLoader_1 = require_servicePluginDocLoader();
77694
- function getServicePluginPrompt(spiNames = []) {
77765
+ var data_1 = require_data();
77766
+ function getServicePluginPrompt(spiNames = [], useData = false) {
77695
77767
  const servicePluginDocs = (0, servicePluginDocLoader_1.loadServicePluginDocumentation)(spiNames);
77696
77768
  return `
77697
77769
  <WIXCLI_SERVICE_PLUGIN_SYSTEM_PROMPT>
@@ -77732,23 +77804,6 @@ src/
77732
77804
  1. Implement ALL required handler functions with complete business logic
77733
77805
  2. Include proper TypeScript types and error handling
77734
77806
 
77735
- <data_handling_strategy>
77736
- CRITICAL: Use simple logic instead of complex data operations when not explicitly required:
77737
-
77738
- - For fee calculations \u2192 Use hardcoded values or simple configuration
77739
- - For shipping rates \u2192 Use static calculation logic, not database lookups
77740
- - For validations \u2192 Use business rules in code, not external data queries
77741
- - Avoid @wix/data, database queries, or collection creation unless explicitly needed
77742
-
77743
- EXAMPLES:
77744
- \u274C DON'T: Create data collections to store simple configuration values
77745
- \u2705 DO: Use constants, environment variables, or simple object configurations
77746
-
77747
- Only use data persistence when:
77748
- - User explicitly requests data storage/retrieval
77749
- - Complex configuration management is specifically required
77750
- - The business logic explicitly requires persistent state
77751
- </data_handling_strategy>
77752
77807
 
77753
77808
  Focus on implementing the EXACT business logic described in the user prompt.
77754
77809
  </generation_requirements>
@@ -77802,7 +77857,6 @@ Focus on implementing the EXACT business logic described in the user prompt.
77802
77857
 
77803
77858
  <common_patterns>
77804
77859
 
77805
-
77806
77860
  <external_api_integration>
77807
77861
  When integrating with external services:
77808
77862
  \`\`\`typescript
@@ -77824,6 +77878,7 @@ When integrating with external services:
77824
77878
  ${servicePluginDocs}
77825
77879
  </available_service_plugins>
77826
77880
 
77881
+ ${useData ? data_1.dataPrompt : ""}
77827
77882
  `;
77828
77883
  }
77829
77884
  exports2.servicePluginPrompt = getServicePluginPrompt();
@@ -117692,14 +117747,15 @@ var require_SPIAgent = __commonJS({
117692
117747
  this.apiKey = apiKey;
117693
117748
  this.name = "SPIAgent";
117694
117749
  }
117695
- buildSystemPrompt(spiNames = []) {
117696
- return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames);
117750
+ buildSystemPrompt(spiNames = [], useData = false) {
117751
+ return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData);
117697
117752
  }
117698
117753
  async generate(params) {
117699
- const { extension, blueprint } = params;
117754
+ const { extension, blueprint, createdCollections } = params;
117700
117755
  const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.ServicePluginExtension]);
117701
117756
  const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
117702
- const systemPrompt = `${this.buildSystemPrompt(allSpiNames)}
117757
+ const useData = Boolean(createdCollections && createdCollections.length > 0);
117758
+ const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData)}
117703
117759
  ${examples}
117704
117760
  `;
117705
117761
  console.log(`SPI Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
@@ -118560,7 +118616,7 @@ ${blocks}
118560
118616
  });
118561
118617
 
118562
118618
  // dist/system-prompts/dashboardPage/data.js
118563
- var require_data = __commonJS({
118619
+ var require_data2 = __commonJS({
118564
118620
  "dist/system-prompts/dashboardPage/data.js"(exports2) {
118565
118621
  "use strict";
118566
118622
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -118701,7 +118757,7 @@ var require_dashboardPagePrompt = __commonJS({
118701
118757
  var ecomPackage_1 = require_ecomPackage();
118702
118758
  var dashboardPackage_1 = require_dashboardPackage();
118703
118759
  var wdsPackage_1 = require_wdsPackage();
118704
- var data_1 = require_data();
118760
+ var data_1 = require_data2();
118705
118761
  var wdsPackage_2 = require_wdsPackage();
118706
118762
  Object.defineProperty(exports2, "buildWdsSystemPrompt", { enumerable: true, get: function() {
118707
118763
  return wdsPackage_2.buildWdsSystemPrompt;
@@ -118881,7 +118937,7 @@ ${examples}
118881
118937
  });
118882
118938
 
118883
118939
  // dist/system-prompts/planner/data.js
118884
- var require_data2 = __commonJS({
118940
+ var require_data3 = __commonJS({
118885
118941
  "dist/system-prompts/planner/data.js"(exports2) {
118886
118942
  "use strict";
118887
118943
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -118982,7 +119038,7 @@ var require_planner = __commonJS({
118982
119038
  "use strict";
118983
119039
  Object.defineProperty(exports2, "__esModule", { value: true });
118984
119040
  exports2.plannerPrompt = void 0;
118985
- var data_1 = require_data2();
119041
+ var data_1 = require_data3();
118986
119042
  var plannerPrompt = () => `
118987
119043
  <WIXCLI_PLANNER_SYSTEM_PROMPT>
118988
119044
  ${(0, data_1.cmsPlannerPrompt)()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.43",
3
+ "version": "1.0.44",
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": "0069e609e9e75fcd22fbc0c90a8243c34e49285ca4a4a8c58939a77d"
27
+ "falconPackageHash": "3254b85ce3f6a07759b648c92740d7080e54b0bd29784305e1d4074a"
28
28
  }