@wix/ditto-codegen-public 1.0.126 → 1.0.128

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
@@ -122274,8 +122245,8 @@ var require_DashboardDecisionAgent = __commonJS({
122274
122245
  })),
122275
122246
  gridItem: zod_1.z.object({
122276
122247
  titleFieldId: zod_1.z.string(),
122277
- subtitleFieldId: zod_1.z.string().optional().nullable(),
122278
- imageFieldId: zod_1.z.string()
122248
+ subtitleFieldId: zod_1.z.string().optional(),
122249
+ imageFieldId: zod_1.z.string().optional()
122279
122250
  }).optional().nullable()
122280
122251
  }).optional(),
122281
122252
  relevantCollectionId: zod_1.z.string().optional()
@@ -122665,7 +122636,7 @@ var require_AutoPatternsGenerator = __commonJS({
122665
122636
  grid: {
122666
122637
  item: {
122667
122638
  titleFieldId: contentResult.schema?.gridItem?.titleFieldId,
122668
- subtitleFieldId: contentResult.schema?.gridItem?.subtitleFieldId || "",
122639
+ subtitleFieldId: contentResult.schema?.gridItem?.subtitleFieldId,
122669
122640
  imageFieldId: contentResult.schema?.gridItem?.imageFieldId,
122670
122641
  cardContentMode: contentResult.schema?.gridItem?.subtitleFieldId ? "full" : "title"
122671
122642
  }
@@ -132932,7 +132903,7 @@ var require_extensionGenerators = __commonJS({
132932
132903
  }
132933
132904
  case types_1.ExtensionType.BACKEND_EVENT: {
132934
132905
  const name = extension.name || "My Backend Event";
132935
- const extensionConfig = this.createBackendEventData(id, extension.relatedApis || [], scaffoldDir);
132906
+ const extensionConfig = this.createBackendEventData(id, scaffoldDir);
132936
132907
  return writeExtensionFile({
132937
132908
  outputPath,
132938
132909
  name,
@@ -132953,27 +132924,9 @@ var require_extensionGenerators = __commonJS({
132953
132924
  return null;
132954
132925
  }
132955
132926
  }
132956
- static createBackendEventData(id, relatedApis, scaffoldDir) {
132957
- const slug = this.getSlugFromBlueprint(relatedApis || []);
132927
+ static createBackendEventData(id, scaffoldDir) {
132958
132928
  const source = getScaffoldPath(scaffoldDir, "event.ts");
132959
- return { id, slug, source };
132960
- }
132961
- static getSlugFromBlueprint(relatedApis) {
132962
- if (!Array.isArray(relatedApis) || relatedApis.length === 0) {
132963
- throw new ditto_codegen_types_12.UnsupportedExtensionTypeError("Backend event extension must have at least one related API", {
132964
- extensionType: types_1.ExtensionType.BACKEND_EVENT,
132965
- origin: ditto_codegen_types_12.ErrorOrigin.INITIAL
132966
- });
132967
- }
132968
- for (const api of relatedApis) {
132969
- const apiName = api?.name;
132970
- if (!apiName)
132971
- continue;
132972
- const slug = this.apiToSlug[apiName];
132973
- if (slug)
132974
- return slug;
132975
- }
132976
- throw new ditto_codegen_types_12.MissingSlugError("No valid slug found for backend event");
132929
+ return { id, source };
132977
132930
  }
132978
132931
  static getServicePluginType(ext) {
132979
132932
  if (!ext.relatedSpis || ext.relatedSpis.length !== 1) {
@@ -133078,13 +133031,6 @@ var require_extensionGenerators = __commonJS({
133078
133031
  "ecom-gift-cards": "ecomGiftCards",
133079
133032
  "ecom-payment-settings": "ecomPaymentSettings"
133080
133033
  };
133081
- ExtensionFactory.apiToSlug = {
133082
- "stores.productsV3.onProductCreated": "wix.stores.catalog.v3.product_created",
133083
- "crm.contacts.onContactCreated": "wix.contacts.v4.contact_created",
133084
- "data.items.onDataItemCreated": "wix.data.v2.data_item_created",
133085
- "ecom.cart.onCartCreated": "wix.ecom.v1.cart_created",
133086
- "ecom.cart.onCartUpdated": "wix.ecom.v1.cart_updated"
133087
- };
133088
133034
  function getScaffoldPath(scaffoldDir, file) {
133089
133035
  return "./" + path_1.default.join(scaffoldDir, file).replace(/^src\//, "");
133090
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.126",
3
+ "version": "1.0.128",
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": "810359ce9a00090f61214bd9bb182d9cff93f02f1fec87ddc440a53e"
27
+ "falconPackageHash": "12e7dff1ae096376b0361ff041381787492ced0624ffae8cb99fbc79"
28
28
  }