n8n-nodes-bazi 1.0.0

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 ADDED
@@ -0,0 +1,33 @@
1
+ # n8n-nodes-bazi
2
+
3
+ This is an n8n community node that lets you calculate and analyze Chinese Four Pillars of Destiny (BaZi / 八字) astrology charts in your [n8n](https://n8n.io/) workflows.
4
+
5
+ ---
6
+
7
+ ## 📦 Installation
8
+
9
+ Follow the [Community Nodes installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in n8n.
10
+
11
+ 1. Go to **Settings > Community Nodes**.
12
+ 2. Select **Install**.
13
+ 3. Enter `n8n-nodes-bazi` in the **npm Package Name** field.
14
+ 4. Agree to the risks of using community packages and select **Install**.
15
+
16
+ ---
17
+
18
+ ## 🔑 Credentials Setup
19
+
20
+ 1. In n8n, create a new credential of type **BaZi API**.
21
+ 2. Enter your API Key (e.g. `bazi_live_xxxx`).
22
+ 3. Set your Base URL (default: `https://api.baziapi.pro`).
23
+
24
+ ---
25
+
26
+ ## ⚡ Operations
27
+
28
+ - **Chart > Calculate:** Calculate full Four Pillars chart (Heavenly Stems, Earthly Branches, Ten Gods, Hidden Stems, Five Elements, and Luck Pillars).
29
+
30
+ ---
31
+
32
+ ## 📄 License
33
+ MIT License.
@@ -0,0 +1,7 @@
1
+ import type { ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class BaziApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaziApi = void 0;
4
+ class BaziApi {
5
+ name = 'baziApi';
6
+ displayName = 'BaZi API';
7
+ documentationUrl = 'https://docs.baziapi.pro';
8
+ properties = [
9
+ {
10
+ displayName: 'API Key',
11
+ name: 'apiKey',
12
+ type: 'string',
13
+ typeOptions: {
14
+ password: true,
15
+ },
16
+ default: '',
17
+ required: true,
18
+ description: 'Your BaZi API Key (prefix: bazi_)',
19
+ },
20
+ {
21
+ displayName: 'Base URL',
22
+ name: 'baseUrl',
23
+ type: 'string',
24
+ default: 'https://api.baziapi.pro',
25
+ required: true,
26
+ description: 'Base URL of the BaZi SaaS API instance',
27
+ },
28
+ ];
29
+ }
30
+ exports.BaziApi = BaziApi;
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Bazi implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,207 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bazi = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ class Bazi {
6
+ description = {
7
+ displayName: 'BaZi Astrology',
8
+ name: 'bazi',
9
+ icon: 'file:bazi.svg',
10
+ group: ['transform'],
11
+ version: 1,
12
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
13
+ description: 'Calculate Chinese Four Pillars of Destiny (BaZi) and interpret astrological charts',
14
+ defaults: {
15
+ name: 'BaZi',
16
+ },
17
+ inputs: ['main'],
18
+ outputs: ['main'],
19
+ credentials: [
20
+ {
21
+ name: 'baziApi',
22
+ required: true,
23
+ },
24
+ ],
25
+ properties: [
26
+ {
27
+ displayName: 'Resource',
28
+ name: 'resource',
29
+ type: 'options',
30
+ noDataExpression: true,
31
+ options: [
32
+ {
33
+ name: 'Chart',
34
+ value: 'chart',
35
+ },
36
+ ],
37
+ default: 'chart',
38
+ },
39
+ {
40
+ displayName: 'Operation',
41
+ name: 'operation',
42
+ type: 'options',
43
+ noDataExpression: true,
44
+ displayOptions: {
45
+ show: {
46
+ resource: ['chart'],
47
+ },
48
+ },
49
+ options: [
50
+ {
51
+ name: 'Calculate',
52
+ value: 'calculate',
53
+ description: 'Calculate complete BaZi Four Pillars chart',
54
+ action: 'Calculate a bazi chart',
55
+ },
56
+ ],
57
+ default: 'calculate',
58
+ },
59
+ // Calculate fields
60
+ {
61
+ displayName: 'Birth Date',
62
+ name: 'birthDate',
63
+ type: 'string',
64
+ required: true,
65
+ default: '',
66
+ placeholder: '1998-08-12',
67
+ description: 'Date of birth in YYYY-MM-DD format',
68
+ displayOptions: {
69
+ show: {
70
+ resource: ['chart'],
71
+ operation: ['calculate'],
72
+ },
73
+ },
74
+ },
75
+ {
76
+ displayName: 'Birth Time',
77
+ name: 'birthTime',
78
+ type: 'string',
79
+ required: true,
80
+ default: '10:30',
81
+ placeholder: '10:30',
82
+ description: 'Time of birth in 24-hour HH:mm format',
83
+ displayOptions: {
84
+ show: {
85
+ resource: ['chart'],
86
+ operation: ['calculate'],
87
+ },
88
+ },
89
+ },
90
+ {
91
+ displayName: 'Gender',
92
+ name: 'gender',
93
+ type: 'options',
94
+ required: true,
95
+ options: [
96
+ {
97
+ name: 'Male',
98
+ value: 'male',
99
+ },
100
+ {
101
+ name: 'Female',
102
+ value: 'female',
103
+ },
104
+ ],
105
+ default: 'male',
106
+ description: 'Biological gender for Luck Pillar calculation direction',
107
+ displayOptions: {
108
+ show: {
109
+ resource: ['chart'],
110
+ operation: ['calculate'],
111
+ },
112
+ },
113
+ },
114
+ {
115
+ displayName: 'Timezone',
116
+ name: 'timezone',
117
+ type: 'string',
118
+ default: 'Asia/Shanghai',
119
+ placeholder: 'Asia/Dhaka',
120
+ description: 'IANA Timezone string for solar time adjustment',
121
+ displayOptions: {
122
+ show: {
123
+ resource: ['chart'],
124
+ operation: ['calculate'],
125
+ },
126
+ },
127
+ },
128
+ {
129
+ displayName: 'Language',
130
+ name: 'language',
131
+ type: 'options',
132
+ options: [
133
+ {
134
+ name: 'English',
135
+ value: 'en',
136
+ },
137
+ {
138
+ name: 'Chinese',
139
+ value: 'zh',
140
+ },
141
+ ],
142
+ default: 'en',
143
+ description: 'Language of the chart output',
144
+ displayOptions: {
145
+ show: {
146
+ resource: ['chart'],
147
+ operation: ['calculate'],
148
+ },
149
+ },
150
+ },
151
+ ],
152
+ };
153
+ async execute() {
154
+ const items = this.getInputData();
155
+ const returnData = [];
156
+ const credentials = await this.getCredentials('baziApi');
157
+ const baseUrl = (credentials.baseUrl || 'https://api.baziapi.pro').replace(/\/$/, '');
158
+ const apiKey = credentials.apiKey;
159
+ for (let i = 0; i < items.length; i++) {
160
+ try {
161
+ const resource = this.getNodeParameter('resource', i);
162
+ const operation = this.getNodeParameter('operation', i);
163
+ if (resource === 'chart' && operation === 'calculate') {
164
+ const birthDate = this.getNodeParameter('birthDate', i);
165
+ const birthTime = this.getNodeParameter('birthTime', i);
166
+ const gender = this.getNodeParameter('gender', i);
167
+ const timezone = this.getNodeParameter('timezone', i);
168
+ const language = this.getNodeParameter('language', i);
169
+ const options = {
170
+ method: 'POST',
171
+ url: `${baseUrl}/api/v1/bazi/calculate`,
172
+ headers: {
173
+ 'Content-Type': 'application/json',
174
+ 'x-api-key': apiKey,
175
+ 'User-Agent': 'n8n-nodes-bazi/1.0.0',
176
+ },
177
+ body: {
178
+ birthDate,
179
+ birthTime,
180
+ gender,
181
+ timezone,
182
+ language,
183
+ },
184
+ json: true,
185
+ };
186
+ const responseData = await this.helpers.httpRequest(options);
187
+ returnData.push({
188
+ json: responseData.data || responseData,
189
+ pairedItem: { item: i },
190
+ });
191
+ }
192
+ }
193
+ catch (error) {
194
+ if (this.continueOnFail()) {
195
+ returnData.push({
196
+ json: { error: error.message },
197
+ pairedItem: { item: i },
198
+ });
199
+ continue;
200
+ }
201
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
202
+ }
203
+ }
204
+ return [returnData];
205
+ }
206
+ }
207
+ exports.Bazi = Bazi;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "n8n-nodes-bazi",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "n8n community node for Chinese Four Pillars of Destiny (BaZi) Astrology API",
6
+ "keywords": [
7
+ "n8n-community-node-package",
8
+ "bazi",
9
+ "astrology",
10
+ "four-pillars",
11
+ "chinese-astrology",
12
+ "destiny",
13
+ "lunar"
14
+ ],
15
+ "license": "MIT",
16
+ "homepage": "https://baziapi.pro",
17
+ "author": {
18
+ "name": "Md. Nasir Uddin Shoyas",
19
+ "email": "support@baziapi.pro"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/Shoyas/bazi-api-sdk.git",
24
+ "directory": "packages/n8n-nodes-bazi"
25
+ },
26
+ "main": "index.js",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "n8n": {
31
+ "n8nNodesApiVersion": 1,
32
+ "credentials": [
33
+ "dist/credentials/BaziApi.credentials.js"
34
+ ],
35
+ "nodes": [
36
+ "dist/nodes/Bazi/Bazi.node.js"
37
+ ]
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^20.14.0",
41
+ "n8n-workflow": "^1.40.0",
42
+ "typescript": "^5.4.5"
43
+ },
44
+ "scripts": {
45
+ "build": "tsc",
46
+ "dev": "tsc --watch",
47
+ "lint": "eslint nodes credentials"
48
+ }
49
+ }