@schandlergarcia/sf-web-components 1.9.31 → 1.9.33

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/README.md CHANGED
@@ -68,6 +68,21 @@ This library includes:
68
68
  - Filter components
69
69
  - Layout components
70
70
 
71
+ ## Sample Data
72
+
73
+ The package includes pre-seeded sample data in the `data/` directory:
74
+ - **Engine Travel Command Center** sample data with real Salesforce field names
75
+ - Dashboard-ready data (map markers, chart data, metrics, etc.)
76
+ - Easy to swap for live data later
77
+
78
+ **Copy to your project:**
79
+ ```bash
80
+ # From your webapp directory
81
+ cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/
82
+ ```
83
+
84
+ See `data/README.md` and `data/USAGE.md` in the package for full documentation.
85
+
71
86
  ## Utilities
72
87
 
73
88
  ```tsx
package/data/USAGE.md ADDED
@@ -0,0 +1,81 @@
1
+ # Using Sample Data from the Package
2
+
3
+ When you install `@schandlergarcia/sf-web-components`, the sample data is included in the package.
4
+
5
+ ## Quick Copy Command
6
+
7
+ From your webapp directory:
8
+
9
+ ```bash
10
+ # Copy sample data to your webapp's src/data directory
11
+ cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/
12
+
13
+ # Or use the included copy script
14
+ bash node_modules/@schandlergarcia/sf-web-components/data/copy-to-webapp.sh .
15
+ ```
16
+
17
+ ## Manual Copy
18
+
19
+ ```bash
20
+ # Create data directory if it doesn't exist
21
+ mkdir -p src/data
22
+
23
+ # Copy the sample data file
24
+ cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/
25
+ ```
26
+
27
+ ## Import in Your Components
28
+
29
+ Once copied to `src/data/`, import the data:
30
+
31
+ ```javascript
32
+ import {
33
+ MAP_MARKERS,
34
+ MAP_ARCS,
35
+ MAP_OVERLAYS,
36
+ FLIGHT_STATUS_LIST,
37
+ TRAVELER_CARDS,
38
+ DISRUPTION_CARDS,
39
+ EVA_ACTIONS,
40
+ BOOKING_ROWS,
41
+ POLICY_ITEMS,
42
+ DESTINATION_CHART_DATA,
43
+ SPEND_CHART_DATA,
44
+ METRICS,
45
+ } from '@/data/engine-sample-data';
46
+
47
+ // Use in components
48
+ <GeoMap markers={MAP_MARKERS} arcs={MAP_ARCS} overlays={MAP_OVERLAYS} />
49
+ ```
50
+
51
+ ## What's Included
52
+
53
+ See the [README.md](./README.md) for full documentation of available data exports.
54
+
55
+ **Raw Salesforce records:**
56
+ - AIRPORTS, TRAVELERS, TRIPS, FLIGHTS, HOTELS, DISRUPTIONS, BOOKINGS, etc.
57
+
58
+ **Dashboard-ready derivatives:**
59
+ - MAP_MARKERS, MAP_ARCS, FLIGHT_STATUS_LIST, TRAVELER_CARDS, etc.
60
+
61
+ All data uses real Salesforce API field names, making it easy to swap for live data later.
62
+
63
+ ## Why Copy Instead of Import Directly?
64
+
65
+ The data file is intentionally designed to be copied to your `src/` directory rather than imported directly from `node_modules` because:
66
+
67
+ 1. **Customization** - You can modify the sample data to match your specific use case
68
+ 2. **Version control** - Your data lives in your repo, not tied to package updates
69
+ 3. **Build optimization** - Some bundlers work better with files in `src/`
70
+ 4. **Switching to live data** - When ready, you replace the file with live queries
71
+
72
+ ## Switching to Live Data
73
+
74
+ When you're ready to use live Salesforce data:
75
+
76
+ 1. Create a new file `src/data/live-data.js`
77
+ 2. Query the Salesforce objects (Trip__c, Flight__c, etc.) using GraphQL
78
+ 3. Transform the results to match the same shape as the sample data
79
+ 4. Update your imports from `engine-sample-data` to `live-data`
80
+
81
+ Your components don't need to change - just the data source!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schandlergarcia/sf-web-components",
3
- "version": "1.9.31",
3
+ "version": "1.9.33",
4
4
  "description": "Reusable Salesforce web components library with Tailwind CSS v4 and shadcn/ui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script for @schandlergarcia/sf-web-components
5
+ *
6
+ * Automatically copies sample data to the consuming project's src/data directory
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import { fileURLToPath } from 'url';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+
16
+ // Get the package root (one level up from scripts/)
17
+ const PACKAGE_ROOT = path.resolve(__dirname, '..');
18
+
19
+ // Get the project root (where the consuming project installed this package)
20
+ // Go up from node_modules/@schandlergarcia/sf-web-components
21
+ const PROJECT_ROOT = path.resolve(PACKAGE_ROOT, '../../..');
22
+
23
+ console.log('\n📦 @schandlergarcia/sf-web-components post-install');
24
+
25
+ // Check if we're in a node_modules context (not during package development)
26
+ if (!PACKAGE_ROOT.includes('node_modules')) {
27
+ console.log(' ℹ️ Running in development mode, skipping data copy');
28
+ process.exit(0);
29
+ }
30
+
31
+ // Find src/data directory in the consuming project
32
+ const possiblePaths = [
33
+ path.join(PROJECT_ROOT, 'src/data'),
34
+ path.join(PROJECT_ROOT, 'force-app/main/default/webapplications/src/data'),
35
+ ];
36
+
37
+ // Try to find an existing src directory
38
+ let targetDir = null;
39
+ for (const p of possiblePaths) {
40
+ const srcDir = path.dirname(p); // Get src directory
41
+ if (fs.existsSync(srcDir)) {
42
+ targetDir = p;
43
+ break;
44
+ }
45
+ }
46
+
47
+ // If no src directory found, look for any webapp with src/
48
+ const webappPattern = /force-app\/main\/default\/webapplications\/[^/]+$/;
49
+ if (!targetDir) {
50
+ try {
51
+ const webappRoot = path.join(PROJECT_ROOT, 'force-app/main/default/webapplications');
52
+ if (fs.existsSync(webappRoot)) {
53
+ const webapps = fs.readdirSync(webappRoot, { withFileTypes: true });
54
+ for (const webapp of webapps) {
55
+ if (webapp.isDirectory()) {
56
+ const srcDir = path.join(webappRoot, webapp.name, 'src');
57
+ if (fs.existsSync(srcDir)) {
58
+ targetDir = path.join(srcDir, 'data');
59
+ break;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ } catch (err) {
65
+ // Ignore errors
66
+ }
67
+ }
68
+
69
+ if (!targetDir) {
70
+ console.log(' ⚠️ Could not find src/ directory in project');
71
+ console.log(' ℹ️ To manually copy sample data, run:');
72
+ console.log('');
73
+ console.log(' mkdir -p src/data');
74
+ console.log(' cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/');
75
+ console.log('');
76
+ process.exit(0);
77
+ }
78
+
79
+ // Create target directory if it doesn't exist
80
+ try {
81
+ if (!fs.existsSync(targetDir)) {
82
+ fs.mkdirSync(targetDir, { recursive: true });
83
+ }
84
+ } catch (err) {
85
+ console.error(' ❌ Failed to create data directory:', err.message);
86
+ process.exit(0); // Don't fail the install
87
+ }
88
+
89
+ // Copy sample data file
90
+ const sourceFile = path.join(PACKAGE_ROOT, 'data/engine-sample-data.js');
91
+ const targetFile = path.join(targetDir, 'engine-sample-data.js');
92
+
93
+ try {
94
+ // Only copy if target doesn't exist (don't overwrite user's modifications)
95
+ if (!fs.existsSync(targetFile)) {
96
+ fs.copyFileSync(sourceFile, targetFile);
97
+ console.log(' ✅ Sample data copied to:', path.relative(PROJECT_ROOT, targetFile));
98
+ console.log('');
99
+ console.log(' Import in your components:');
100
+ console.log('');
101
+ console.log(" import { MAP_MARKERS, METRICS } from '@/data/engine-sample-data';");
102
+ console.log('');
103
+ } else {
104
+ console.log(' ℹ️ Sample data already exists (not overwriting)');
105
+ console.log(' 📁', path.relative(PROJECT_ROOT, targetFile));
106
+ console.log('');
107
+ }
108
+ } catch (err) {
109
+ console.error(' ⚠️ Could not copy sample data:', err.message);
110
+ console.log(' ℹ️ To manually copy, run:');
111
+ console.log('');
112
+ console.log(' cp node_modules/@schandlergarcia/sf-web-components/data/engine-sample-data.js src/data/');
113
+ console.log('');
114
+ }
115
+
116
+ process.exit(0);