@wix/ditto-codegen-public 1.0.50 → 1.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "my-custom-app",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "scripts": {
6
+ "astro": "astro",
7
+ "dev": "wix dev",
8
+ "build": "wix build",
9
+ "wix": "wix",
10
+ "preview": "wix preview",
11
+ "release": "wix release",
12
+ "generate": "wix generate",
13
+ "env": "wix env"
14
+ },
15
+ "dependencies": {
16
+ "@wix/astro": "0.0.4-experimental-react-component",
17
+ "@wix/crm": "^1.0.1071",
18
+ "@wix/dashboard": "^1.3.36",
19
+ "@wix/data": "^1.0.290",
20
+ "@wix/design-system": "^1.111.0",
21
+ "@wix/ecom": "^1.0.1354",
22
+ "@wix/essentials": "^0.1.23",
23
+ "@wix/sdk": "^1.15.23",
24
+ "@wix/stores": "^1.0.533",
25
+ "astro": "^5.8.0",
26
+ "typescript": "^5.8.3"
27
+ },
28
+ "devDependencies": {
29
+ "@astrojs/cloudflare": "^12.5.3",
30
+ "@astrojs/react": "^4.3.0",
31
+ "@types/react": "^18.3.1",
32
+ "@types/react-dom": "^18.3.1",
33
+ "@wix/cli": "^1.1.92",
34
+ "react": "18.3.1",
35
+ "react-dom": "18.3.1"
36
+ }
37
+ }
@@ -0,0 +1,67 @@
1
+ import { productsV3 } from '@wix/stores';
2
+ import { items } from '@wix/data';
3
+
4
+ productsV3.onProductCreated(async (event) => {
5
+ const productIdFromEvent = event.entity?._id;
6
+ try {
7
+ console.log('Product created event triggered:', event);
8
+
9
+ // Extract product information from the event
10
+ const productId = productIdFromEvent;
11
+
12
+ if (!productId) {
13
+ console.error('No product ID found in event');
14
+ return;
15
+ }
16
+
17
+ const product = event.entity;
18
+
19
+ // Create detailed creation information
20
+ const creationDetails = {
21
+ productName: product.name || 'Unknown Product',
22
+ productSlug: product.slug,
23
+ visible: product.visible,
24
+ inventory: product.inventory,
25
+ brand: product.brand
26
+ };
27
+
28
+ // Create log entry in the product-creation-logs collection
29
+ const logEntry = {
30
+ productId: productId,
31
+ changeType: 'PRODUCT_CREATED',
32
+ changedFields: ['CREATED'],
33
+ timestamp: new Date(),
34
+ changeDetails: JSON.stringify(creationDetails, null, 2)
35
+ };
36
+
37
+ // Insert the log entry into the collection
38
+ await items.insert('product-creation-logs', logEntry);
39
+
40
+ console.log('Product creation logged successfully:', {
41
+ productId,
42
+ productName: product.name,
43
+ changedFields: logEntry.changedFields,
44
+ timestamp: logEntry.timestamp
45
+ });
46
+
47
+ } catch (error) {
48
+ console.error('Error processing product creation event:', {
49
+ productId: productIdFromEvent || 'unknown',
50
+ error: error instanceof Error ? error.message : String(error),
51
+ timestamp: new Date()
52
+ });
53
+
54
+ // Try to log the error to the collection as well
55
+ try {
56
+ await items.insert('product-creation-logs', {
57
+ productId: productIdFromEvent || 'unknown',
58
+ changeType: 'ERROR',
59
+ changedFields: [],
60
+ timestamp: new Date(),
61
+ changeDetails: `Error processing product creation: ${error instanceof Error ? error.message : String(error)}`
62
+ });
63
+ } catch (logError) {
64
+ console.error('Failed to log error to collection:', logError);
65
+ }
66
+ }
67
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "astro/tsconfigs/strict",
3
+ "include": [".astro/types.d.ts", "**/*"],
4
+ "exclude": ["dist"]
5
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "appId": "54ed7c99-07c1-4992-b961-f5b4a9bd6d7f",
3
+ "siteId": "6e13b6b4-0b79-4c81-b430-d9b6a0c8e4f9"
4
+ }