wanas-zcrm-extractor 1.0.0 → 1.0.2

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.
Files changed (3) hide show
  1. package/README.md +186 -140
  2. package/bin/cli.js +3 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,140 +1,186 @@
1
- # Zoho CRM V8 Metadata Extractor
2
-
3
- A robust, production-quality local web application built using **Node.js** and **Express** that authenticates with Zoho CRM using OAuth2 (V8 APIs) and extracts all CRM metadata into structured JSON schemas stored locally.
4
-
5
- This tool is designed with a clean, modular architecture, enabling future extensions for Zoho Creator and Zoho Projects metadata extraction.
6
-
7
- ---
8
-
9
- ## 🌟 Key Features
10
-
11
- 1. **OAuth2 Connection Dashboard:** A premium, glassmorphic dark-theme user interface with a real-time system status indicator.
12
- 2. **Server-Sent Events (SSE) Progress Terminal:** Displays live step-by-step extraction logs from the backend directly in a console window.
13
- 3. **Consolidated Data Analysis:** Generates:
14
- - Module summaries detailing field types, required fields, picklists, formulas, lookup associations, and layout counts.
15
- - A unified `field_map.json` linking all module fields to their data types.
16
- - A consolidated `complete_metadata.json` merging all API responses into a single large object.
17
- 4. **Interactive Module Explorer:** Browse, search, filter, and inspect extracted modules, fields, related lists, and raw summaries through an interactive modal viewer.
18
- 5. **Consolidated ZIP Downloads:** Automatically packages all exported data in a single zip archive using native compression.
19
- 6. **Robust Error Handling:**
20
- - Automatic token refreshes on expiry.
21
- - Retry mechanism for API rate limits (HTTP 429) using exponential backoff.
22
- - Detailed failure logging in `storage/logs/errors.log`.
23
-
24
- ---
25
-
26
- ## 📂 Project Structure
27
-
28
- ```text
29
- project/
30
- ├── public/ # Glassmorphic Frontend UI Assets
31
- │ ├── index.html # Dashboard HTML
32
- │ ├── style.css # Premium Dark-Theme Styles
33
- │ └── app.js # SSE Event Listeners & Interactive Explorer logic
34
-
35
- ├── src/
36
- │ ├── controllers/ # Handles Route Requests (OAuth, Extraction, Downloads)
37
- │ │ ├── authController.js
38
- │ │ └── metadataController.js
39
- │ │
40
- ├── middleware/ # Security & Validation Middlewares
41
- │ └── authMiddleware.js
42
-
43
- │ ├── routes/ # API Endpoints Routing
44
- │ │ ├── authRoutes.js
45
- │ │ └── metadataRoutes.js
46
- │ │
47
- │ ├── services/ # Business Logic Layer
48
- │ │ ├── authService.js # Token Storage, Validation, and Refresh Flow
49
- │ │ └── metadata/ # Platform-Specific Metadata Extractors
50
- │ │ ├── baseMetadataService.js # Abstract Base Extractor
51
- │ │ ├── crmMetadataService.js # CRM V8 Extraction Implementation
52
- │ │ ├── creatorMetadataService.js # Creator Extractor Stub (Future use)
53
- │ │ └── projectsMetadataService.js # Projects Extractor Stub (Future use)
54
- │ │
55
- │ └── utils/ # Common Utilities
56
- │ ├── apiClient.js # Axios wrapper with retry, rate-limiting & refresh
57
- │ └── logger.js # Writes errors/logs to storage/logs/errors.log
58
-
59
- ├── storage/ # Local Filesystem Output
60
- │ ├── auth/
61
- │ │ └── tokens.json # Saved OAuth2 Access and Refresh Tokens
62
- │ ├── logs/
63
- │ │ └── errors.log # API and Process Error Logs
64
- │ └── metadata/ # Extracted JSON Metadata Files
65
- │ ├── index.json # Master Index file
66
- │ ├── modules.json # List of Modules
67
- │ ├── export/ # Export Files (field_map, complete_metadata, modules)
68
- │ └── modules/ # Module details, layouts, custom_views, related_lists
69
-
70
- ├── .env # Local Environment Configuration variables
71
- ├── package.json # Node.js dependencies
72
- └── server.js # Application Express Server Entrypoint
73
- ```
74
-
75
- ---
76
-
77
- ## 🛠️ Setup & Installation
78
-
79
- ### 1. Prerequisite
80
- Ensure you have [Node.js](https://nodejs.org/) (v18+ LTS recommended) installed.
81
-
82
- ### 2. Install Dependencies
83
- Run the following command inside the root folder:
84
- ```bash
85
- npm install
86
- ```
87
-
88
- ### 3. Environment Configuration
89
- Create a `.env` file in the root directory and configure your Zoho client credentials:
90
- ```env
91
- PORT=3000
92
- ZOHO_CLIENT_ID=your_client_id_here
93
- ZOHO_CLIENT_SECRET=your_client_secret_here
94
- ZOHO_REDIRECT_URI=http://localhost:3000/zoho/callback
95
- ZOHO_DC=com
96
- ```
97
- *Note: Make sure your Client ID and Client Secret match the data center domain configured in `ZOHO_DC` (e.g. `com`, `eu`, `in`, `com.au`).*
98
-
99
- ---
100
-
101
- ## 🚀 Running the Application
102
-
103
- ### Development Mode
104
- Runs the server using `nodemon` to automatically restart on code changes:
105
- ```bash
106
- npm run dev
107
- ```
108
-
109
- ### Production Mode
110
- Runs the server normally:
111
- ```bash
112
- npm start
113
- ```
114
-
115
- Once running, navigate to the local dashboard in your browser:
116
- **[http://localhost:3000](http://localhost:3000)**
117
-
118
- ---
119
-
120
- ## 🔄 How the Authentication & Extraction Works
121
-
122
- 1. **Authentication:**
123
- - Click **Login To Zoho** on the dashboard. You will be redirected to Zoho's secure OAuth2 consent screen.
124
- - Upon granting permissions, Zoho redirects back to `http://localhost:3000/zoho/callback`.
125
- - The server exchanges the authorization code for `access_token` and `refresh_token`, storing them securely in `storage/auth/tokens.json`.
126
-
127
- 2. **Metadata Extraction:**
128
- - Click **Extract Metadata** to fire the extraction task.
129
- - The UI connects to `/extract?stream=true` using standard Server-Sent Events, opening a live logging terminal showing the crawler step-by-step.
130
- - The service walks through all modules, queries fields, layouts, related lists, custom views, webhooks, and custom functions.
131
- - Summary files are written sequentially on the disk.
132
- - The master index and consolidated export files are compiled once the extraction completes.
133
-
134
- ---
135
-
136
- ## 🔧 Extensibility (Zoho Creator & Zoho Projects)
137
-
138
- To extend the extractor to Zoho Creator or Zoho Projects, simply:
139
- 1. Implement the extraction pipeline inside `src/services/metadata/creatorMetadataService.js` or `projectsMetadataService.js` which already inherit from the abstract `BaseMetadataService` template.
140
- 2. Update the target selector inside `public/index.html` to enable the platform option.
1
+ # Zoho CRM V8 Metadata Extractor (`zcrm`)
2
+
3
+ A robust, production-quality CLI utility and local web dashboard designed to authenticate with Zoho CRM (OAuth2 V8 APIs) and extract all metadata, settings, and Deluge scripts into a structured, developer-friendly local directory structure.
4
+
5
+ ---
6
+
7
+ ## 🌟 Key Features
8
+
9
+ 1. **Global CLI Wrapper (`zcrm`):** Command-line tools for authentication, data extraction, and starting the local web explorer dashboard.
10
+ 2. **Standard ZDK CLI Directory Layout:** Writes module structures, layouts, fields, profiles, and roles in a format fully compatible with the standard Zoho ZDK CLI tool.
11
+ 3. **Deluge Script Downloader:** Pulls custom function source codes, organizes them into folders by namespace, and saves them as local Deluge `.ds` files.
12
+ 4. **Interactive Dashboard:** Launch a premium, glassmorphic dark-theme dashboard to review extracted modules, view field properties, search and filter APIs, and download structured ZIP archives of the exports.
13
+ 5. **Robust Pipeline & Error Handling:**
14
+ - Interactive progress indicators showing modules and deluge functions as they download.
15
+ - Resilient Axios client with auto-refreshing OAuth tokens.
16
+ - Exponential backoff retry system to handle API rate limits (HTTP 429).
17
+ - Rich console results screen showing execution statistics.
18
+
19
+ ---
20
+
21
+ ## 🛠️ Installation
22
+
23
+ Install the CLI utility globally via npm:
24
+
25
+ ```bash
26
+ npm install -g wanas-zcrm-extractor
27
+ ```
28
+
29
+ *(Ensure you have [Node.js](https://nodejs.org/) v18+ installed on your system).*
30
+
31
+ ---
32
+
33
+ ## 🔑 Setup & Registration
34
+
35
+ To authenticate, you must register a Zoho API Client in the Zoho Developer Console:
36
+
37
+ 1. Visit the [Zoho Developer Console](https://api-console.zoho.com/).
38
+ 2. Click **Add Client** and select **Server-based Applications**.
39
+ 3. Configure your application details:
40
+ - **Client Name:** `Zoho CRM Metadata Extractor`
41
+ - **Homepage URL:** `http://localhost:3000`
42
+ - **Authorized Redirect URIs:** `http://localhost:3000/zoho/callback` (or your preferred local port redirect URI)
43
+ 4. Click **Create** to receive your **Client ID** and **Client Secret**.
44
+
45
+ ---
46
+
47
+ ## 🚀 CLI Commands Reference
48
+
49
+ ### 1. `zcrm login`
50
+ Authenticates the CLI to access your Zoho CRM account.
51
+
52
+ ```bash
53
+ zcrm login [options]
54
+ ```
55
+
56
+ **Options:**
57
+ * `--client-id <id>` - Zoho OAuth Client ID.
58
+ * `--client-secret <secret>` - Zoho OAuth Client Secret.
59
+ * `--dc <dc>` - Zoho Data Center domain (`com`, `eu`, `in`, `jp`, `com.au`, `com.cn`).
60
+ * `--redirect-uri <uri>` - Zoho OAuth Redirect URI.
61
+ * `--refresh-token <token>` - Headless authentication option (bypasses browser authorization).
62
+
63
+ **Examples:**
64
+ * *Interactive Mode (Prompts for missing details):*
65
+ ```bash
66
+ zcrm login
67
+ ```
68
+ * *Express Login with Custom Credentials:*
69
+ ```bash
70
+ zcrm login --client-id 1000.xxxxxxx --client-secret xxxxxxx --dc com --redirect-uri http://localhost:3000/zoho/callback
71
+ ```
72
+ * *Headless Login (For CI/CD or Server Scripts):*
73
+ ```bash
74
+ zcrm login --client-id 1000.xxxxxxx --client-secret xxxxxxx --dc com --refresh-token 1000.xxxxxxxxxxxxxxxxx
75
+ ```
76
+
77
+ ---
78
+
79
+ ### 2. `zcrm pull`
80
+ Crawls all Zoho CRM endpoints to extract metadata schemas and custom functions deluge scripts.
81
+
82
+ ```bash
83
+ zcrm pull [options]
84
+ ```
85
+
86
+ **Options:**
87
+ * `-o, --output <dir>` - Destination folder path (defaults to `./metadata` in the current working directory).
88
+
89
+ **What happens during a pull:**
90
+ 1. Verifies authentication and refreshes active OAuth access tokens automatically.
91
+ 2. Fetches Zoho Org information and sets up local project mapping configs.
92
+ 3. Crawls every module to pull field configurations and page layout schemas (with a beautiful progress indicator).
93
+ 4. Fetches Profiles, Roles, and Webhooks settings.
94
+ 5. Downloads all custom deluge function scripts.
95
+ 6. Compiles a consolidated database of schemas and summaries.
96
+ 7. Prints a rich-text CLI banner and statistics summary showing the number of modules, layouts, and fields processed.
97
+
98
+ ---
99
+
100
+ ### 3. `zcrm dashboard`
101
+ Launches the premium local web dashboard to explore the pulled metadata in a browser.
102
+
103
+ ```bash
104
+ zcrm dashboard [options]
105
+ ```
106
+
107
+ **Options:**
108
+ * `-p, --port <port>` - Port to run the dashboard on (defaults to `3000`).
109
+
110
+ Once launched, navigate to **`http://localhost:3000`** in your browser. From here, you can:
111
+ - View live extraction logs.
112
+ - Browse extracted modules, inspect field tables, view picklist values, and lookup relationships.
113
+ - Search and filter across field names.
114
+ - Download a consolidated `.zip` file of all extracted files.
115
+
116
+ ---
117
+
118
+ ### 4. `zcrm logout`
119
+ Clears stored configuration credentials, OAuth tokens, and active sessions from the workspace.
120
+
121
+ ```bash
122
+ zcrm logout
123
+ ```
124
+
125
+ ---
126
+
127
+ ## 📂 Generated Directory Structure
128
+
129
+ When running `zcrm pull -o ./metadata`, the following layout is compiled inside the output folder:
130
+
131
+ ```text
132
+ metadata/
133
+ ├── .zdk/ # Internal ZDK CLI stores
134
+ │ ├── .logs/ # Extractor logging files and audit history
135
+ │ ├── .org/
136
+ │ │ └── org.json # Extracted Zoho CRM Organization metadata
137
+ │ └── .store/ # Extracted cached index formats
138
+ │ ├── index.json # Master index of extracted modules
139
+ │ ├── modules_raw.json # Raw API modules catalog response
140
+ │ ├── field_map.json # Key-value map of every field's data type
141
+ │ ├── complete_metadata.json # Unified JSON database of all endpoints
142
+ │ ├── webhooks.json # Extracted webhooks metadata
143
+ │ └── functions.json # Extracted functions catalog
144
+
145
+ ├── crm/ # Standard Zoho ZDK CLI metadata layout
146
+ │ └── meta/
147
+ │ ├── modules/ # Individual Module schemas
148
+ │ │ └── <Module_API_Name>/
149
+ │ │ ├── <Module_API_Name>.modules-meta.json
150
+ │ │ ├── fields/ # Field configurations
151
+ │ │ │ └── <Field_API_Name>.fields-meta.json
152
+ │ │ └── layouts/ # Page Layout configurations
153
+ │ │ └── <Layout_API_Name>.layouts-meta.json
154
+ │ ├── profiles/ # Profile Permissions mapping
155
+ │ │ └── <Profile_Name>.profiles-meta.json
156
+ │ └── roles/ # Role Hierarchy definitions
157
+ │ └── <Role_Name>.roles-meta.json
158
+
159
+ ├── functions/ # Custom Deluge function files (.ds)
160
+ │ ├── standalone/ # Deluge scripts sorted by namespace
161
+ │ │ └── standalone.<Function_API_Name>.ds
162
+ │ ├── automation/
163
+ │ ├── button/
164
+ │ ├── related_list/
165
+ │ ├── schedule/
166
+ │ └── salessignals/
167
+
168
+ ├── extra/ # Custom analysis exports
169
+ │ └── modules/
170
+ │ └── <Module_API_Name>/
171
+ │ ├── summary.json # Custom module summary (counts, fields, picklists, formulas)
172
+ │ ├── custom_views/ # Custom View configuration JSONs
173
+ │ │ └── <View_API_Name>.custom_views-meta.json
174
+ │ └── related_lists/ # Related List configurations
175
+ │ └── <List_API_Name>.related_lists-meta.json
176
+
177
+ ├── zdk-project.json # ZDK CLI project settings config
178
+ ├── meta.json # ZDK resource configuration
179
+ └── .zdkignore # Standard gitignore rules for ZDK caches
180
+ ```
181
+
182
+ ---
183
+
184
+ ## 🤝 Contribution & License
185
+
186
+ This project is maintained by Wanas Apps and licensed under the **ISC License**. For queries or feedback, feel free to contact us.
package/bin/cli.js CHANGED
@@ -57,11 +57,13 @@ function drawProgress(current, total, label, action) {
57
57
  process.stdout.write(`\x1b[34m[${bar}]\x1b[0m \x1b[1;32m${percent}%\x1b[0m | \x1b[1m${label}\x1b[0m: ${truncatedAction}`);
58
58
  }
59
59
 
60
+ const pkg = require('../package.json');
61
+
60
62
  // Version and metadata configuration
61
63
  program
62
64
  .name('zcrm')
63
65
  .description('Zoho CRM V8 Metadata Extractor CLI Utility')
64
- .version('1.0.0')
66
+ .version(pkg.version, '-v, --version', 'output the current version')
65
67
  .addHelpText('before', getBanner());
66
68
 
67
69
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wanas-zcrm-extractor",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Local Zoho CRM V8 Metadata Extractor CLI and Web Dashboard Utility",
5
5
  "main": "server.js",
6
6
  "bin": {