@wix/ditto-codegen-public 1.0.125 → 1.0.127

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.
@@ -156,14 +156,14 @@ Properties:
156
156
  import { contacts } from '@wix/crm';
157
157
 
158
158
  // Register event handler for contact creation
159
- contacts.onContactCreated((event) => {
159
+ export default contacts.onContactCreated((event) => {
160
160
  const created = event.entity;
161
161
  console.log('New contact created:', created._id);
162
162
  console.log('Primary email:', created.primaryInfo?.email);
163
163
  });
164
164
 
165
165
  // Async handler example
166
- contacts.onContactCreated(async (event) => {
166
+ export default contacts.onContactCreated(async (event) => {
167
167
  const created = event.entity;
168
168
  await syncToExternalCrm(created._id, created);
169
169
  });
@@ -76,7 +76,7 @@ Properties:
76
76
  import { items } from '@wix/data';
77
77
 
78
78
  // Register event handler for data item creation
79
- items.onDataItemCreated((event) => {
79
+ export default items.onDataItemCreated((event) => {
80
80
  const created = event.entity;
81
81
  console.log('Item created in collection:', created.dataCollectionId);
82
82
  console.log('New item ID:', created._id);
@@ -85,7 +85,7 @@ items.onDataItemCreated((event) => {
85
85
  });
86
86
 
87
87
  // Async handler example
88
- items.onDataItemCreated(async (event) => {
88
+ export default items.onDataItemCreated(async (event) => {
89
89
  const created = event.entity;
90
90
  const createdItem = await items.get(created.dataCollectionId, created._id);
91
91
  console.log('Created item:', createdItem);
@@ -13,7 +13,7 @@
13
13
  <usage>
14
14
  import { cart } from "@wix/ecom";
15
15
 
16
- cart.onCartCreated((event) => {
16
+ export default cart.onCartCreated((event) => {
17
17
  // handle your event here
18
18
  });
19
19
  </usage>
@@ -13,7 +13,7 @@
13
13
  <usage>
14
14
  import { cart } from "@wix/ecom";
15
15
 
16
- cart.onCartUpdated((event) => {
16
+ export default cart.onCartUpdated((event) => {
17
17
  // handle your event here
18
18
  });
19
19
  </usage>
@@ -90,13 +90,13 @@ Properties:
90
90
  import { products } from '@wix/stores';
91
91
 
92
92
  // Register event handler for product creation
93
- products.onProductCreated((event) => {
93
+ export default products.onProductCreated((event) => {
94
94
  console.log('New product created:', event.data.name);
95
95
  console.log('Product ID:', event.data.productId);
96
96
  });
97
97
 
98
98
  // Async event handler example
99
- products.onProductCreated(async (event) => {
99
+ export default products.onProductCreated(async (event) => {
100
100
  try {
101
101
  console.log('Processing product creation event');
102
102
  // Perform async operations
@@ -163,7 +163,7 @@ Properties:
163
163
  import { productsV3 } from '@wix/stores';
164
164
 
165
165
  // Basic example
166
- productsV3.onProductCreated(async (event) => {
166
+ export default productsV3.onProductCreated(async (event) => {
167
167
  console.log('New product created:', event.entity.name);
168
168
  console.log('Product ID:', event.entity._id);
169
169
  console.log('Visible:', event.entity.visible);
@@ -174,7 +174,7 @@ productsV3.onProductCreated(async (event) => {
174
174
  });
175
175
 
176
176
  // Async example
177
- productsV3.onProductCreated(async (event) => {
177
+ export default productsV3.onProductCreated(async (event) => {
178
178
  try {
179
179
  console.log('Processing product creation for:', event.entity.name);
180
180
  await syncProductToExternalSystem(event.entity);
@@ -11,41 +11,46 @@ SDK modules and their available events are documented here: https://dev.wix.com/
11
11
 
12
12
  import { contacts } from '@wix/crm';
13
13
 
14
- contacts.onContactCreated(async (event) => {
14
+ export default contacts.onContactCreated(async (event) => {
15
15
  try {
16
16
  console.log('🎉 New contact created event received!');
17
-
17
+
18
18
  // Log the entire event for debugging purposes
19
19
  console.log('Event data:', JSON.stringify(event, null, 2));
20
-
20
+
21
21
  // Access contact information from the event
22
22
  const contactData = event.entity;
23
23
  const eventMetadata = event.metadata;
24
-
24
+
25
25
  if (contactData) {
26
26
  console.log(`📝 Contact Creation Details:`);
27
27
  console.log(`- Contact ID: ${contactData._id || 'N/A'}`);
28
- console.log(`- Email: ${contactData.info?.emails?.items?.[0]?.email || 'N/A'}`);
28
+ console.log(
29
+ `- Email: ${contactData.info?.emails?.items?.[0]?.email || 'N/A'}`
30
+ );
29
31
  console.log(`- First Name: ${contactData.info?.name?.first || 'N/A'}`);
30
32
  console.log(`- Last Name: ${contactData.info?.name?.last || 'N/A'}`);
31
- console.log(`- Phone: ${contactData.info?.phones?.items?.[0]?.phone || 'N/A'}`);
33
+ console.log(
34
+ `- Phone: ${contactData.info?.phones?.items?.[0]?.phone || 'N/A'}`
35
+ );
32
36
  console.log(`- Created Date: ${contactData._createdDate || 'N/A'}`);
33
37
  }
34
-
38
+
35
39
  if (eventMetadata) {
36
40
  console.log(`📊 Event Metadata:`);
37
41
  console.log(`- Event ID: ${eventMetadata.entityId || 'N/A'}`);
38
42
  console.log(`- Event Time: ${eventMetadata.eventTime || 'N/A'}`);
39
- console.log(`- Triggered By: ${eventMetadata.triggeredByAnonymizeRequest ? 'Anonymize Request' : 'Normal Creation'}`);
43
+ console.log(
44
+ `- Triggered By: ${eventMetadata.triggeredByAnonymizeRequest ? 'Anonymize Request' : 'Normal Creation'}`
45
+ );
40
46
  }
41
-
47
+
42
48
  console.log('✅ Contact creation logging completed successfully');
43
-
44
49
  } catch (error) {
45
50
  console.error('❌ Error processing contact creation event:', error);
46
51
  console.error('Error details:', {
47
52
  message: error instanceof Error ? error.message : 'Unknown error',
48
- stack: error instanceof Error ? error.stack : undefined
53
+ stack: error instanceof Error ? error.stack : undefined,
49
54
  });
50
55
  }
51
- });
56
+ });
@@ -1,56 +1,55 @@
1
1
  import { productsV3 } from '@wix/stores';
2
2
  import { items } from '@wix/data';
3
3
 
4
- productsV3.onProductCreated(async (event) => {
4
+ export default productsV3.onProductCreated(async (event) => {
5
5
  const productIdFromEvent = event.entity?._id;
6
6
  try {
7
7
  console.log('Product created event triggered:', event);
8
-
8
+
9
9
  // Extract product information from the event
10
10
  const productId = productIdFromEvent;
11
-
11
+
12
12
  if (!productId) {
13
13
  console.error('No product ID found in event');
14
14
  return;
15
15
  }
16
16
 
17
17
  const product = event.entity;
18
-
18
+
19
19
  // Create detailed creation information
20
20
  const creationDetails = {
21
21
  productName: product.name || 'Unknown Product',
22
22
  productSlug: product.slug,
23
23
  visible: product.visible,
24
24
  inventory: product.inventory,
25
- brand: product.brand
25
+ brand: product.brand,
26
26
  };
27
-
27
+
28
28
  // Create log entry in the product-creation-logs collection
29
29
  const logEntry = {
30
30
  productId: productId,
31
31
  changeType: 'PRODUCT_CREATED',
32
32
  changedFields: ['CREATED'],
33
33
  timestamp: new Date(),
34
- changeDetails: JSON.stringify(creationDetails, null, 2)
34
+ changeDetails: JSON.stringify(creationDetails, null, 2),
35
35
  };
36
-
36
+
37
37
  // Insert the log entry into the collection
38
38
  await items.insert('product-creation-logs', logEntry);
39
-
39
+
40
40
  console.log('Product creation logged successfully:', {
41
41
  productId,
42
42
  productName: product.name,
43
43
  changedFields: logEntry.changedFields,
44
- timestamp: logEntry.timestamp
44
+ timestamp: logEntry.timestamp,
45
45
  });
46
-
47
46
  } catch (error) {
48
47
  console.error('Error processing product creation event:', {
49
48
  productId: productIdFromEvent || 'unknown',
50
49
  error: error instanceof Error ? error.message : String(error),
51
- timestamp: new Date()
50
+ timestamp: new Date(),
52
51
  });
53
-
52
+
54
53
  // Try to log the error to the collection as well
55
54
  try {
56
55
  await items.insert('product-creation-logs', {
@@ -58,7 +57,7 @@ productsV3.onProductCreated(async (event) => {
58
57
  changeType: 'ERROR',
59
58
  changedFields: [],
60
59
  timestamp: new Date(),
61
- changeDetails: `Error processing product creation: ${error instanceof Error ? error.message : String(error)}`
60
+ changeDetails: `Error processing product creation: ${error instanceof Error ? error.message : String(error)}`,
62
61
  });
63
62
  } catch (logError) {
64
63
  console.error('Failed to log error to collection:', logError);
package/dist/out.js CHANGED
@@ -65668,7 +65668,6 @@ var require_ErrorTypes = __commonJS({
65668
65668
  ErrorType2["AI_RATE_LIMIT_ERROR"] = "AI_RATE_LIMIT_ERROR";
65669
65669
  ErrorType2["AI_NETWORK_ERROR"] = "AI_NETWORK_ERROR";
65670
65670
  ErrorType2["FILE_SYSTEM_ERROR"] = "FILE_SYSTEM_ERROR";
65671
- ErrorType2["MISSING_SLUG_ERROR"] = "MISSING_SLUG_ERROR";
65672
65671
  ErrorType2["PROCESS_EXECUTION_ERROR"] = "PROCESS_EXECUTION_ERROR";
65673
65672
  ErrorType2["AGENT_CONFIGURATION_ERROR"] = "AGENT_CONFIGURATION_ERROR";
65674
65673
  ErrorType2["SCAFFOLDING_ERROR"] = "SCAFFOLDING_ERROR";
@@ -65939,34 +65938,6 @@ var require_FileSystemError = __commonJS({
65939
65938
  }
65940
65939
  });
65941
65940
 
65942
- // ../codegen-types/dist/errors/MissingSlugError.js
65943
- var require_MissingSlugError = __commonJS({
65944
- "../codegen-types/dist/errors/MissingSlugError.js"(exports2) {
65945
- "use strict";
65946
- Object.defineProperty(exports2, "__esModule", { value: true });
65947
- exports2.MissingSlugError = void 0;
65948
- var BaseCodegenError_1 = require_BaseCodegenError();
65949
- var ErrorTypes_1 = require_ErrorTypes();
65950
- var MissingSlugError = class extends BaseCodegenError_1.BaseCodegenError {
65951
- constructor(message, options) {
65952
- super(message);
65953
- this.name = "MissingSlugError";
65954
- this.errorType = ErrorTypes_1.ErrorType.MISSING_SLUG_ERROR;
65955
- this.expected = false;
65956
- this.retryable = false;
65957
- this.cause = options?.cause;
65958
- }
65959
- getAdditionalProperties() {
65960
- const props = {};
65961
- if (this.cause)
65962
- props.cause = this.cause;
65963
- return props;
65964
- }
65965
- };
65966
- exports2.MissingSlugError = MissingSlugError;
65967
- }
65968
- });
65969
-
65970
65941
  // ../codegen-types/dist/errors/ProcessExecutionError.js
65971
65942
  var require_ProcessExecutionError = __commonJS({
65972
65943
  "../codegen-types/dist/errors/ProcessExecutionError.js"(exports2) {
@@ -66314,7 +66285,6 @@ var require_errors = __commonJS({
66314
66285
  __exportStar2(require_UnsupportedExtensionTypeError(), exports2);
66315
66286
  __exportStar2(require_AIErrors(), exports2);
66316
66287
  __exportStar2(require_FileSystemError(), exports2);
66317
- __exportStar2(require_MissingSlugError(), exports2);
66318
66288
  __exportStar2(require_ProcessExecutionError(), exports2);
66319
66289
  __exportStar2(require_AgentConfigurationError(), exports2);
66320
66290
  __exportStar2(require_ScaffoldingError(), exports2);
@@ -121110,6 +121080,7 @@ ${(0, corePrinciples_1.getCorePrinciples)()}
121110
121080
  <event_handler_patterns>
121111
121081
  - Use the correct SDK import for the service (e.g., import { products } from '@wix/stores')
121112
121082
  - Implement event listeners using the .on[EventName]() pattern
121083
+ - Always export the event handler function using the \`export default\` keyword
121113
121084
  - Always use async functions for event handlers
121114
121085
  - Include proper error handling and logging
121115
121086
  - Follow Wix backend event naming conventions
@@ -123237,8 +123208,10 @@ ${extensionDoc}
123237
123208
 
123238
123209
  3. **Make your decision and submit**:
123239
123210
  - Decide if this extension should be updated based on the user's request
123240
- - Identify ONLY the files that are directly relevant to the user's use case
123241
- - Not all files you read will be relevant - filter to only what needs modification- Use the extension type documentation above to understand what this extension does
123211
+ - Identify ONLY the files that belong to THIS extension and are directly relevant to the user's use case
123212
+ - Not all files you read will be relevant - filter to only what needs modification
123213
+ - **IMPORTANT**: Only return files that are part of the extension being evaluated, never include files from other extensions
123214
+ - Use the extension type documentation above to understand what this extension does
123242
123215
  - **Call the submit_evaluation tool** with your decision
123243
123216
 
123244
123217
  ## Constraints
@@ -123247,7 +123220,10 @@ ${extensionDoc}
123247
123220
  - **File scope**: Only consider files under src/ directory
123248
123221
  - **Efficiency**: Be strategic with tool calls - don't read unnecessary files
123249
123222
  - **Uncertainty**: If you're unsure, mark as not relevant
123250
- - **Output filtering**: Return only files that directly relate to the user's request, not all files you read
123223
+ - **Output filtering**: Return only files that:
123224
+ * Belong to the extension being evaluated (never include files from other extensions)
123225
+ * Directly relate to the user's request
123226
+ * Actually need modification (not all files you read)
123251
123227
  - **SPI Matching (for SERVICE_PLUGIN extensions)**: If the extension uses a specific SPI (Service Provider Interface), understand that:
123252
123228
  * Each SPI handles a specific business domain (e.g., additional fees, shipping rates, product validation)
123253
123229
  * Different SPIs are NOT interchangeable - they serve different purposes
@@ -132927,7 +132903,7 @@ var require_extensionGenerators = __commonJS({
132927
132903
  }
132928
132904
  case types_1.ExtensionType.BACKEND_EVENT: {
132929
132905
  const name = extension.name || "My Backend Event";
132930
- const extensionConfig = this.createBackendEventData(id, extension.relatedApis || [], scaffoldDir);
132906
+ const extensionConfig = this.createBackendEventData(id, scaffoldDir);
132931
132907
  return writeExtensionFile({
132932
132908
  outputPath,
132933
132909
  name,
@@ -132948,27 +132924,9 @@ var require_extensionGenerators = __commonJS({
132948
132924
  return null;
132949
132925
  }
132950
132926
  }
132951
- static createBackendEventData(id, relatedApis, scaffoldDir) {
132952
- const slug = this.getSlugFromBlueprint(relatedApis || []);
132927
+ static createBackendEventData(id, scaffoldDir) {
132953
132928
  const source = getScaffoldPath(scaffoldDir, "event.ts");
132954
- return { id, slug, source };
132955
- }
132956
- static getSlugFromBlueprint(relatedApis) {
132957
- if (!Array.isArray(relatedApis) || relatedApis.length === 0) {
132958
- throw new ditto_codegen_types_12.UnsupportedExtensionTypeError("Backend event extension must have at least one related API", {
132959
- extensionType: types_1.ExtensionType.BACKEND_EVENT,
132960
- origin: ditto_codegen_types_12.ErrorOrigin.INITIAL
132961
- });
132962
- }
132963
- for (const api of relatedApis) {
132964
- const apiName = api?.name;
132965
- if (!apiName)
132966
- continue;
132967
- const slug = this.apiToSlug[apiName];
132968
- if (slug)
132969
- return slug;
132970
- }
132971
- throw new ditto_codegen_types_12.MissingSlugError("No valid slug found for backend event");
132929
+ return { id, source };
132972
132930
  }
132973
132931
  static getServicePluginType(ext) {
132974
132932
  if (!ext.relatedSpis || ext.relatedSpis.length !== 1) {
@@ -133073,13 +133031,6 @@ var require_extensionGenerators = __commonJS({
133073
133031
  "ecom-gift-cards": "ecomGiftCards",
133074
133032
  "ecom-payment-settings": "ecomPaymentSettings"
133075
133033
  };
133076
- ExtensionFactory.apiToSlug = {
133077
- "stores.productsV3.onProductCreated": "wix.stores.catalog.v3.product_created",
133078
- "crm.contacts.onContactCreated": "wix.contacts.v4.contact_created",
133079
- "data.items.onDataItemCreated": "wix.data.v2.data_item_created",
133080
- "ecom.cart.onCartCreated": "wix.ecom.v1.cart_created",
133081
- "ecom.cart.onCartUpdated": "wix.ecom.v1.cart_updated"
133082
- };
133083
133034
  function getScaffoldPath(scaffoldDir, file) {
133084
133035
  return "./" + path_1.default.join(scaffoldDir, file).replace(/^src\//, "");
133085
133036
  }
@@ -11,6 +11,6 @@ SDK modules and their available events are documented here: https://dev.wix.com/
11
11
 
12
12
  import { contacts } from '@wix/crm';
13
13
 
14
- contacts.onContactCreated((event) => {
14
+ export default contacts.onContactCreated((event) => {
15
15
  // Add you logic here
16
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/ditto-codegen-public",
3
- "version": "1.0.125",
3
+ "version": "1.0.127",
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": "999c0c914818f243602e8995ec8c13ec98a9631166ba923f55c51136"
27
+ "falconPackageHash": "09c097e6eef0264946cb5f3c925807d7a7f5c5f227520c06b9249f9d"
28
28
  }