n8n-nodes-digit 0.1.14 → 0.1.16

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.
@@ -74,9 +74,9 @@ class DIGIT {
74
74
  this.description = exports.description;
75
75
  }
76
76
  async execute() {
77
- // -------------------------------
78
- // Load & validate credentials
79
- // -------------------------------
77
+ // --------------------------------------------------
78
+ // Credentials
79
+ // --------------------------------------------------
80
80
  var _a;
81
81
  const credentials = await this.getCredentials('digitApi');
82
82
  let baseUrl = credentials === null || credentials === void 0 ? void 0 : credentials.baseUrl;
@@ -86,17 +86,10 @@ class DIGIT {
86
86
  if (!baseUrl.startsWith('http')) {
87
87
  throw new Error('DIGIT Credentials: Base URL must start with http:// or https://');
88
88
  }
89
- // Normalize trailing slash
90
89
  baseUrl = baseUrl.replace(/\/+$/, '');
91
- // -------------------------------
92
- // Detect gateway environment
93
- // -------------------------------
94
90
  const isGatewayEnv = baseUrl.includes('digit.org') ||
95
91
  baseUrl.includes('digit-lts') ||
96
92
  baseUrl.includes('gateway');
97
- // -------------------------------
98
- // Setup
99
- // -------------------------------
100
93
  const resource = this.getNodeParameter('resource', 0);
101
94
  const items = this.getInputData();
102
95
  const returnData = [];
@@ -113,7 +106,7 @@ class DIGIT {
113
106
  const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
114
107
  const payload = JSON.parse(buffer_1.Buffer.from(base64, 'base64').toString('utf8'));
115
108
  let tenant = '';
116
- if (payload.iss) {
109
+ if (payload === null || payload === void 0 ? void 0 : payload.iss) {
117
110
  const parts = payload.iss.split('/');
118
111
  tenant = parts[parts.length - 1];
119
112
  }
@@ -123,9 +116,9 @@ class DIGIT {
123
116
  roles: ((_a = payload === null || payload === void 0 ? void 0 : payload.realm_access) === null || _a === void 0 ? void 0 : _a.roles) || [],
124
117
  clientId: (payload === null || payload === void 0 ? void 0 : payload.azp) || '',
125
118
  tenantId: tenant,
126
- username: payload.preferred_username || '',
127
- email: payload.email || '',
128
- exp: payload.exp,
119
+ username: (payload === null || payload === void 0 ? void 0 : payload.preferred_username) || '',
120
+ email: (payload === null || payload === void 0 ? void 0 : payload.email) || '',
121
+ exp: payload === null || payload === void 0 ? void 0 : payload.exp,
129
122
  },
130
123
  });
131
124
  }
@@ -133,7 +126,7 @@ class DIGIT {
133
126
  }
134
127
  }
135
128
  // ==================================================
136
- // FILESTORE — FILE FETCH
129
+ // FILESTORE — FETCH
137
130
  // ==================================================
138
131
  if (resource === 'filestore') {
139
132
  const operation = this.getNodeParameter('filestoreOperation', 0);
@@ -143,7 +136,7 @@ class DIGIT {
143
136
  const tenantId = this.getNodeParameter('tenantId', i);
144
137
  const accessToken = this.getNodeParameter('accessToken', i);
145
138
  const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
146
- const response = await this.helpers.httpRequest({
139
+ const apiResponse = await this.helpers.httpRequest({
147
140
  method: 'GET',
148
141
  url: new URL(`/filestore/v1/files/${fileId}`, baseUrl).toString(),
149
142
  qs: { tenantId },
@@ -153,13 +146,15 @@ class DIGIT {
153
146
  },
154
147
  json: true,
155
148
  });
156
- returnData.push({ json: response });
149
+ returnData.push({
150
+ json: JSON.parse(JSON.stringify(apiResponse)),
151
+ });
157
152
  }
158
153
  return [returnData];
159
154
  }
160
155
  }
161
156
  // ==================================================
162
- // BOUNDARY — SEARCH
157
+ // BOUNDARY
163
158
  // ==================================================
164
159
  if (resource === 'boundary') {
165
160
  const operation = this.getNodeParameter('boundaryOperation', 0);
@@ -167,28 +162,33 @@ class DIGIT {
167
162
  for (let i = 0; i < items.length; i++) {
168
163
  const tenantId = this.getNodeParameter('tenantId', i);
169
164
  const codes = this.getNodeParameter('codes', i);
165
+ const clientId = this.getNodeParameter('clientId', i);
170
166
  const accessToken = this.getNodeParameter('accessToken', i);
171
167
  const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
172
- const response = await this.helpers.httpRequest({
168
+ // Gateway boundary endpoint
169
+ const boundaryUrl = new URL('/boundary/v1', baseUrl).toString();
170
+ const apiResponse = await this.helpers.httpRequest({
173
171
  method: 'GET',
174
- url: new URL('/egov-location/location/v11/boundarys/_search', baseUrl).toString(),
172
+ url: boundaryUrl,
175
173
  qs: {
176
- tenantId: tenantId.toLowerCase(),
177
- boundaryCodes: codes,
174
+ codes: codes,
178
175
  },
179
176
  headers: {
180
- 'X-Tenant-Id': tenantId.toLowerCase(),
177
+ 'X-Tenant-ID': tenantId,
178
+ 'X-Client-Id': clientId,
181
179
  Authorization: `Bearer ${cleanToken}`,
182
180
  },
183
181
  json: true,
184
182
  });
185
- returnData.push({ json: response });
183
+ returnData.push({
184
+ json: JSON.parse(JSON.stringify(apiResponse)),
185
+ });
186
186
  }
187
187
  return [returnData];
188
188
  }
189
189
  }
190
190
  // ==================================================
191
- // IDGEN — GENERATE (AUTO ROUTE)
191
+ // IDGEN — GENERATE
192
192
  // ==================================================
193
193
  if (resource === 'idgen') {
194
194
  const operation = this.getNodeParameter('idgenOperation', 0);
@@ -203,10 +203,17 @@ class DIGIT {
203
203
  catch {
204
204
  throw new Error('Invalid JSON in Request Body');
205
205
  }
206
+ // Core expects RequestInfo wrapper
207
+ if (!body.RequestInfo) {
208
+ body = {
209
+ RequestInfo: {},
210
+ ...body,
211
+ };
212
+ }
206
213
  const idgenPath = isGatewayEnv
207
214
  ? '/idgen/v1/generate'
208
215
  : '/egov-idgen/id/_generate';
209
- const response = await this.helpers.httpRequest({
216
+ const apiResponse = await this.helpers.httpRequest({
210
217
  method: 'POST',
211
218
  url: new URL(idgenPath, baseUrl).toString(),
212
219
  headers: {
@@ -215,12 +222,14 @@ class DIGIT {
215
222
  body,
216
223
  json: true,
217
224
  });
218
- returnData.push({ json: response });
225
+ returnData.push({
226
+ json: JSON.parse(JSON.stringify(apiResponse)),
227
+ });
219
228
  }
220
229
  return [returnData];
221
230
  }
222
231
  }
223
- throw new Error('DIGIT node: Unsupported resource/operation combination');
232
+ throw new Error('DIGIT node: Unsupported resource / operation combination');
224
233
  }
225
234
  }
226
235
  exports.DIGIT = DIGIT;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digit",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "DIGIT Platform nodes for n8n",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-digit",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "DIGIT Platform nodes for n8n",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",