n8n-nodes-vh3ai 0.2.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.
Files changed (89) hide show
  1. package/README.md +216 -0
  2. package/dist/credentials/Vh3AiApi.credentials.d.ts +9 -0
  3. package/dist/credentials/Vh3AiApi.credentials.js +65 -0
  4. package/dist/credentials/Vh3AiApi.credentials.js.map +1 -0
  5. package/dist/nodes/Vh3Ai/GenericFunctions.d.ts +29 -0
  6. package/dist/nodes/Vh3Ai/GenericFunctions.js +130 -0
  7. package/dist/nodes/Vh3Ai/GenericFunctions.js.map +1 -0
  8. package/dist/nodes/Vh3Ai/Vh3Ai.node.d.ts +5 -0
  9. package/dist/nodes/Vh3Ai/Vh3Ai.node.js +1328 -0
  10. package/dist/nodes/Vh3Ai/Vh3Ai.node.js.map +1 -0
  11. package/dist/nodes/Vh3Ai/Vh3Ai.node.json +18 -0
  12. package/dist/nodes/Vh3Ai/descriptions/ContactsDescription.d.ts +3 -0
  13. package/dist/nodes/Vh3Ai/descriptions/ContactsDescription.js +680 -0
  14. package/dist/nodes/Vh3Ai/descriptions/ContactsDescription.js.map +1 -0
  15. package/dist/nodes/Vh3Ai/descriptions/InvoicesDescription.d.ts +3 -0
  16. package/dist/nodes/Vh3Ai/descriptions/InvoicesDescription.js +601 -0
  17. package/dist/nodes/Vh3Ai/descriptions/InvoicesDescription.js.map +1 -0
  18. package/dist/nodes/Vh3Ai/descriptions/JobGroupsDescription.d.ts +3 -0
  19. package/dist/nodes/Vh3Ai/descriptions/JobGroupsDescription.js +442 -0
  20. package/dist/nodes/Vh3Ai/descriptions/JobGroupsDescription.js.map +1 -0
  21. package/dist/nodes/Vh3Ai/descriptions/JobTypesDescription.d.ts +3 -0
  22. package/dist/nodes/Vh3Ai/descriptions/JobTypesDescription.js +115 -0
  23. package/dist/nodes/Vh3Ai/descriptions/JobTypesDescription.js.map +1 -0
  24. package/dist/nodes/Vh3Ai/descriptions/JobsDescription.d.ts +3 -0
  25. package/dist/nodes/Vh3Ai/descriptions/JobsDescription.js +1031 -0
  26. package/dist/nodes/Vh3Ai/descriptions/JobsDescription.js.map +1 -0
  27. package/dist/nodes/Vh3Ai/descriptions/NotesDescription.d.ts +3 -0
  28. package/dist/nodes/Vh3Ai/descriptions/NotesDescription.js +535 -0
  29. package/dist/nodes/Vh3Ai/descriptions/NotesDescription.js.map +1 -0
  30. package/dist/nodes/Vh3Ai/descriptions/PersonsDescription.d.ts +3 -0
  31. package/dist/nodes/Vh3Ai/descriptions/PersonsDescription.js +377 -0
  32. package/dist/nodes/Vh3Ai/descriptions/PersonsDescription.js.map +1 -0
  33. package/dist/nodes/Vh3Ai/descriptions/ReferenceDataDescription.d.ts +3 -0
  34. package/dist/nodes/Vh3Ai/descriptions/ReferenceDataDescription.js +200 -0
  35. package/dist/nodes/Vh3Ai/descriptions/ReferenceDataDescription.js.map +1 -0
  36. package/dist/nodes/Vh3Ai/descriptions/ResourcesDescription.d.ts +3 -0
  37. package/dist/nodes/Vh3Ai/descriptions/ResourcesDescription.js +306 -0
  38. package/dist/nodes/Vh3Ai/descriptions/ResourcesDescription.js.map +1 -0
  39. package/dist/nodes/Vh3Ai/descriptions/StockDescription.d.ts +3 -0
  40. package/dist/nodes/Vh3Ai/descriptions/StockDescription.js +843 -0
  41. package/dist/nodes/Vh3Ai/descriptions/StockDescription.js.map +1 -0
  42. package/dist/nodes/Vh3Ai/descriptions/VehiclesDescription.d.ts +3 -0
  43. package/dist/nodes/Vh3Ai/descriptions/VehiclesDescription.js +304 -0
  44. package/dist/nodes/Vh3Ai/descriptions/VehiclesDescription.js.map +1 -0
  45. package/dist/nodes/Vh3Ai/descriptions/WorksheetGroupsDescription.d.ts +3 -0
  46. package/dist/nodes/Vh3Ai/descriptions/WorksheetGroupsDescription.js +93 -0
  47. package/dist/nodes/Vh3Ai/descriptions/WorksheetGroupsDescription.js.map +1 -0
  48. package/dist/nodes/Vh3Ai/descriptions/WorksheetsDescription.d.ts +3 -0
  49. package/dist/nodes/Vh3Ai/descriptions/WorksheetsDescription.js +221 -0
  50. package/dist/nodes/Vh3Ai/descriptions/WorksheetsDescription.js.map +1 -0
  51. package/dist/nodes/Vh3Ai/vh3ai-inverted.svg +48 -0
  52. package/dist/nodes/Vh3Ai/vh3ai-original.svg +14 -0
  53. package/dist/nodes/Vh3Ai/vh3ai-wordmark.svg +34 -0
  54. package/dist/nodes/Vh3Ai/vh3ai.svg +14 -0
  55. package/dist/nodes/Vh3AiPro/GenericFunctions.d.ts +23 -0
  56. package/dist/nodes/Vh3AiPro/GenericFunctions.js +122 -0
  57. package/dist/nodes/Vh3AiPro/GenericFunctions.js.map +1 -0
  58. package/dist/nodes/Vh3AiPro/Vh3AiPro.node.d.ts +5 -0
  59. package/dist/nodes/Vh3AiPro/Vh3AiPro.node.js +366 -0
  60. package/dist/nodes/Vh3AiPro/Vh3AiPro.node.js.map +1 -0
  61. package/dist/nodes/Vh3AiPro/Vh3AiPro.node.json +31 -0
  62. package/dist/nodes/Vh3AiPro/descriptions/FsiAccountReviewDescription.d.ts +3 -0
  63. package/dist/nodes/Vh3AiPro/descriptions/FsiAccountReviewDescription.js +72 -0
  64. package/dist/nodes/Vh3AiPro/descriptions/FsiAccountReviewDescription.js.map +1 -0
  65. package/dist/nodes/Vh3AiPro/descriptions/FsiAgentDescription.d.ts +3 -0
  66. package/dist/nodes/Vh3AiPro/descriptions/FsiAgentDescription.js +118 -0
  67. package/dist/nodes/Vh3AiPro/descriptions/FsiAgentDescription.js.map +1 -0
  68. package/dist/nodes/Vh3AiPro/descriptions/FsiBriefingDescription.d.ts +3 -0
  69. package/dist/nodes/Vh3AiPro/descriptions/FsiBriefingDescription.js +85 -0
  70. package/dist/nodes/Vh3AiPro/descriptions/FsiBriefingDescription.js.map +1 -0
  71. package/dist/nodes/Vh3AiPro/descriptions/FsiEmailDescription.d.ts +3 -0
  72. package/dist/nodes/Vh3AiPro/descriptions/FsiEmailDescription.js +299 -0
  73. package/dist/nodes/Vh3AiPro/descriptions/FsiEmailDescription.js.map +1 -0
  74. package/dist/nodes/Vh3AiPro/descriptions/FsiJobsDescription.d.ts +3 -0
  75. package/dist/nodes/Vh3AiPro/descriptions/FsiJobsDescription.js +370 -0
  76. package/dist/nodes/Vh3AiPro/descriptions/FsiJobsDescription.js.map +1 -0
  77. package/dist/nodes/Vh3AiPro/descriptions/FsiReportsDescription.d.ts +3 -0
  78. package/dist/nodes/Vh3AiPro/descriptions/FsiReportsDescription.js +87 -0
  79. package/dist/nodes/Vh3AiPro/descriptions/FsiReportsDescription.js.map +1 -0
  80. package/dist/nodes/Vh3AiPro/descriptions/FsiSearchDescription.d.ts +3 -0
  81. package/dist/nodes/Vh3AiPro/descriptions/FsiSearchDescription.js +143 -0
  82. package/dist/nodes/Vh3AiPro/descriptions/FsiSearchDescription.js.map +1 -0
  83. package/dist/nodes/Vh3AiPro/descriptions/FsiSentinelDescription.d.ts +3 -0
  84. package/dist/nodes/Vh3AiPro/descriptions/FsiSentinelDescription.js +69 -0
  85. package/dist/nodes/Vh3AiPro/descriptions/FsiSentinelDescription.js.map +1 -0
  86. package/dist/nodes/Vh3AiPro/vh3ai-original.svg +14 -0
  87. package/dist/nodes/Vh3AiPro/vh3ai.svg +14 -0
  88. package/index.js +1 -0
  89. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,216 @@
1
+ # n8n-nodes-vh3ai
2
+
3
+ Community node for [n8n](https://n8n.io/) that integrates with the [VH3 AI](https://vh3.ai) field service management API.
4
+
5
+ This package provides two nodes:
6
+
7
+ - **VH3 AI** — BigChange proxy operations for jobs, contacts, resources, vehicles, and worksheets
8
+ - **VH3 AI PRO** — AI-powered Field Service Intelligence (FSI) operations for enriched job feeds, operational reports, and email processing
9
+
10
+ Both nodes connect through the VH3 Connect gateway at `api.vh3connect.io`.
11
+
12
+ ## Installation
13
+
14
+ ### Self-hosted n8n
15
+
16
+ Go to **Settings > Community Nodes**, click **Install**, and enter:
17
+
18
+ ```
19
+ n8n-nodes-vh3ai
20
+ ```
21
+
22
+ ### n8n Cloud
23
+
24
+ Search for **VH3 AI** in the nodes panel (verified nodes only).
25
+
26
+ ### Manual / Development
27
+
28
+ ```bash
29
+ cd n8n-nodes-vh3ai
30
+ npm install
31
+ npm run build
32
+ npm link
33
+
34
+ mkdir -p ~/.n8n/custom && cd ~/.n8n/custom
35
+ npm init -y
36
+ npm link n8n-nodes-vh3ai
37
+
38
+ n8n start
39
+ ```
40
+
41
+ ## Credentials
42
+
43
+ | Field | Description | Default |
44
+ | ------------ | ----------------------------------------------------- | -------------------------------------------- |
45
+ | API Key | Your VH3 API key (issued by VH3 AI) | — |
46
+ | Company ID | Your tenant/company ID | — |
47
+ | Base URL | VH3 Connect gateway URL | `https://api.vh3connect.io` |
48
+ | FSI Base URL | VH3 Field Service Intelligence API (Xano proxy) | `https://api.vh3connect.io/api:kP8T1CK7` |
49
+
50
+ - **VH3 AI node**: authenticates via `X-API-KEY` header on every request.
51
+ - **VH3 AI PRO node**: authenticates by injecting `company_id` and `api_key` as body/query parameters (no header auth). The Xano proxy handles the auth check server-side.
52
+
53
+ ---
54
+
55
+ ## VH3 AI — Resources & Operations
56
+
57
+ ### Job
58
+
59
+ | Operation | Description |
60
+ | --------- | ----------- |
61
+ | **Get Job** | Full details for a single job including worksheets, assigned engineer, and status history |
62
+ | **List Jobs** | Search jobs with filters for status, date range, job type, contact, resource, and reference |
63
+
64
+ ### Contact
65
+
66
+ | Operation | Description |
67
+ | --------- | ----------- |
68
+ | **Get Contact** | Full details for a single contact (customer or site) |
69
+ | **List Contacts** | Paginated list of contacts (sites/customers) with date filtering |
70
+ | **List Contact Groups** | Retrieve all contact groups |
71
+
72
+ ### Resource (Engineer)
73
+
74
+ | Operation | Description |
75
+ | --------- | ----------- |
76
+ | **List Resources** | All engineers and technicians available for job assignments |
77
+ | **List Resource Groups** | Retrieve all resource groups (teams) |
78
+
79
+ ### Job Type
80
+
81
+ | Operation | Description |
82
+ | --------- | ----------- |
83
+ | **List Job Types** | All job type definitions (installation, repair, maintenance, etc.) with custom field schemas |
84
+
85
+ ### Vehicle
86
+
87
+ | Operation | Description |
88
+ | --------- | ----------- |
89
+ | **List Vehicles** | All fleet vehicles including registration, make, model, and assignment details |
90
+
91
+ ### Worksheet
92
+
93
+ | Operation | Description |
94
+ | --------- | ----------- |
95
+ | **List Worksheet Definitions** | All worksheet form templates and question schemas |
96
+ | **List Worksheet Answers** | Completed worksheet answers for specific jobs (inspection data, safety checks, parts, signatures) |
97
+
98
+ ---
99
+
100
+ ## VH3 AI PRO — Resources & Operations
101
+
102
+ ### Agent
103
+
104
+ | Operation | Description |
105
+ | --------- | ----------- |
106
+ | **Chat with Connie** | AI-powered operations intelligence agent with multi-turn conversation and contextual tool use. Queries jobs, engineers, sites, and operational metrics from the knowledge graph. |
107
+
108
+ All agent operations share the same interface:
109
+
110
+ - **Message** (required) — the user message to send to the agent
111
+ - **Experimental Mode** (boolean, default off) — toggles between the production and experimental pipeline variant. When enabled, routes to `/{agent}/experimental/chat` instead of `/{agent}/chat`.
112
+ - **Additional Fields** — session ID (for multi-turn), user ID, user name, user company name, customer summary, contact ID, current job reference
113
+
114
+ The agent handler derives the endpoint path dynamically from the operation value, so adding a new agent requires only one dropdown option — no handler code changes.
115
+
116
+ ### Email
117
+
118
+ | Operation | Description |
119
+ | --------- | ----------- |
120
+ | **Classify Email** | Classify an incoming email using the AI triage pipeline. Returns category, urgency, sentiment, and routing decision using a configurable taxonomy. |
121
+ | **Ingest Email** | Extract structured job data from an FM portal email and resolve entities. Parses email content, intelligently matches Customer/Site/JobType, classifies job type, evaluates confidence, and either auto-creates the job or queues it for review. |
122
+
123
+ Both email operations support an optional **Attachment Source** (None / From URL / From Binary Data):
124
+
125
+ - **From URL** — passes `{ filename, url, mimeType }` to the backend for server-side fetch
126
+ - **From Binary Data** — reads n8n binary data, base64-encodes, sends `{ filename, contentBase64, mimeType }`
127
+ - **None** — sends `attachments: []`
128
+
129
+ The Ingest Email operation also accepts **Preferred Type IDs** (comma-separated integers) for extraction weighting.
130
+
131
+ ### Job Feed
132
+
133
+ | Operation | Description |
134
+ | --------- | ----------- |
135
+ | **Aggregate Jobs** | Compute job metrics (count, completion rate, first-visit fix rate, avg delays) with grouping, time-axis control, and period-over-period comparison. |
136
+ | **Get Enriched Job** | Single enriched job by ID with full FSI context. |
137
+ | **List Job Feed** | AI-enriched job feed with filters for status, result, contact, resource, type, and category. Supports auto-pagination. |
138
+
139
+ ### Report
140
+
141
+ | Operation | Description |
142
+ | --------- | ----------- |
143
+ | **Generate Report** | Generate an operational report (daily, weekly, monthly) with optional AI narrative. |
144
+ | **List Report Sections** | Available report section definitions. |
145
+
146
+ ### Search
147
+
148
+ | Operation | Description |
149
+ | --------- | ----------- |
150
+ | **Autocomplete** | Fast fuzzy search across customers, engineers, jobs, and sites. Ideal for type-ahead lookups. |
151
+ | **Search Outcomes** | Search job outcome and diagnostic summaries using natural language. Supports filtering by type, category, resource, contact, and site. |
152
+ | **Search Intake** | Search intake descriptions with enriched job context using natural language. Same filter options as Search Outcomes. |
153
+
154
+ ### Sentinel
155
+
156
+ Proactive early-warning system — 12 deterministic checks that detect operational issues before they escalate. Pure database reads, zero LLM cost.
157
+
158
+ | Operation | Description |
159
+ | --------- | ----------- |
160
+ | **Run All Sentinels** | Run all (or selected) sentinel checks for your tenant. Returns only triggered alerts — empty means all clear. |
161
+ | **Run Single Sentinel** | Run a specific sentinel by ID (dropdown of all 12). |
162
+ | **List Sentinel Registry** | List all sentinel definitions with thresholds, categories, and recommended run schedules. |
163
+ | **Get Latest Results** | Retrieve cached results from the most recent sentinel run. |
164
+
165
+ Available sentinels: Engineer Performance Slip, FVF Rate Drop, Workload Imbalance, Site Deterioration, Repeat Failure Escalation, New Problem Site, SLA Breach Cluster, Customer Risk Escalation, Customer Non-Complete Anomaly, Scheduling Accuracy Drift, Carryover Accumulation, Data Quality Alert.
166
+
167
+ ---
168
+
169
+ ## Architecture & Patterns
170
+
171
+ ### Parameter Casing Convention
172
+
173
+ The n8n UI uses **camelCase** field names (e.g. `emailBody`, `senderAddress`, `preferredTypeIds`). The handlers map these to **snake_case** API parameters (e.g. `email_body`, `sender_address`, `preferred_type_ids`) before sending to the Xano proxy, which forwards to FastAPI.
174
+
175
+ ### FSI API Authentication
176
+
177
+ The VH3 AI PRO node does **not** use the `X-API-KEY` header. Instead, `company_id` and `api_key` are injected directly:
178
+ - **GET requests** — as query string parameters
179
+ - **POST requests** — into the JSON body
180
+
181
+ This is handled by `vh3FsiGetRequest` and `vh3FsiPostRequest` in `GenericFunctions.ts`.
182
+
183
+ ### Attachment Handling
184
+
185
+ Both email operations share the `buildAttachments()` helper from `GenericFunctions.ts`:
186
+
187
+ 1. Reads `attachmentSource` parameter from the n8n UI
188
+ 2. For **URL mode**: constructs `{ filename, url, mimeType }` — no download on n8n side, backend fetches server-side
189
+ 3. For **Binary mode**: reads binary data buffer, base64-encodes, constructs `{ filename, contentBase64, mimeType }`
190
+ 4. Returns `[]` when no attachment is selected
191
+
192
+ The FastAPI `AttachmentInput` models on both endpoints accept `content_base64`, `url`, `mime_type`, and `filename` — either URL or base64 can be provided. File processing is a future scope item; the interface is ready.
193
+
194
+ ### Xano Proxy Input Types
195
+
196
+ List-type parameters (`attachments`, `preferred_type_ids`) must be defined as array types in Xano (e.g. `json[]?`, `int[]?`) — **not** `json`. Using plain `json` defaults unset inputs to `{}` (empty object) instead of `[]`/`null`, which causes FastAPI Pydantic validation failures.
197
+
198
+ ---
199
+
200
+ ## Features
201
+
202
+ - **Auto-pagination**: Toggle "Return All" to fetch every page automatically (capped at 20,000 items for safety)
203
+ - **Rich filters**: Job listing supports status, date range, job type, contact, resource, and reference filters
204
+ - **Enum dropdowns**: Job statuses, sort fields, and directions are presented as selectable options
205
+ - **Response normalization**: Three BigChange envelope shapes are automatically unwrapped to flat item arrays
206
+ - **AI tool compatible**: Both nodes are marked `usableAsTool` with rich descriptions for use with n8n AI agents
207
+ - **Error context**: API errors include the endpoint that failed for easier debugging
208
+
209
+ ## Compatibility
210
+
211
+ - n8n version: 1.0+
212
+ - Node.js: 18.10+
213
+
214
+ ## License
215
+
216
+ MIT
@@ -0,0 +1,9 @@
1
+ import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, INodeProperties } from 'n8n-workflow';
2
+ export declare class Vh3AiApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ documentationUrl: string;
6
+ properties: INodeProperties[];
7
+ authenticate: IAuthenticateGeneric;
8
+ test: ICredentialTestRequest;
9
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Vh3AiApi = void 0;
4
+ class Vh3AiApi {
5
+ constructor() {
6
+ this.name = 'vh3AiApi';
7
+ this.displayName = 'VH3 AI API';
8
+ this.documentationUrl = 'https://vh3.ai/docs';
9
+ this.properties = [
10
+ {
11
+ displayName: 'API Key',
12
+ name: 'apiKey',
13
+ type: 'string',
14
+ typeOptions: { password: true },
15
+ default: '',
16
+ required: true,
17
+ description: 'Your VH3 AI API key',
18
+ },
19
+ {
20
+ displayName: 'Company ID',
21
+ name: 'companyId',
22
+ type: 'string',
23
+ default: '',
24
+ description: 'Your tenant/company ID — required for operations that retrieve a single record (e.g. Get Job)',
25
+ },
26
+ {
27
+ displayName: 'Base URL',
28
+ name: 'baseUrl',
29
+ type: 'string',
30
+ default: 'https://api.vh3connect.io',
31
+ required: true,
32
+ description: 'Base URL of the VH3 Connect API gateway',
33
+ },
34
+ {
35
+ displayName: 'FSI Base URL',
36
+ name: 'fsiBaseUrl',
37
+ type: 'string',
38
+ default: 'https://api.vh3connect.io/api:kP8T1CK7',
39
+ required: true,
40
+ description: 'Base URL of the VH3 Field Service Intelligence API',
41
+ },
42
+ ];
43
+ this.authenticate = {
44
+ type: 'generic',
45
+ properties: {
46
+ headers: {
47
+ 'X-API-KEY': '={{$credentials.apiKey}}',
48
+ },
49
+ },
50
+ };
51
+ this.test = {
52
+ request: {
53
+ baseURL: '={{$credentials.baseUrl}}',
54
+ url: '/api:YdihQNr3/resource_groups/list',
55
+ method: 'POST',
56
+ body: JSON.stringify({ pageNumber: 1, pageSize: 1 }),
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ },
60
+ },
61
+ };
62
+ }
63
+ }
64
+ exports.Vh3AiApi = Vh3AiApi;
65
+ //# sourceMappingURL=Vh3AiApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Vh3AiApi.credentials.js","sourceRoot":"","sources":["../../credentials/Vh3AiApi.credentials.ts"],"names":[],"mappings":";;;AAOA,MAAa,QAAQ;IAArB;QACC,SAAI,GAAG,UAAU,CAAC;QAElB,gBAAW,GAAG,YAAY,CAAC;QAE3B,qBAAgB,GAAG,qBAAqB,CAAC;QAEzC,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,qBAAqB;aAClC;YACD;gBACC,WAAW,EAAE,YAAY;gBACzB,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,WAAW,EACV,+FAA+F;aAChG;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,2BAA2B;gBACpC,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,yCAAyC;aACtD;YACD;gBACC,WAAW,EAAE,cAAc;gBAC3B,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,wCAAwC;gBACjD,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,oDAAoD;aACjE;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,WAAW,EAAE,0BAA0B;iBACvC;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,2BAA2B;gBACpC,GAAG,EAAE,oCAAoC;gBACzC,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;gBACpD,OAAO,EAAE;oBACR,cAAc,EAAE,kBAAkB;iBAClC;aACD;SACD,CAAC;IACH,CAAC;CAAA;AA/DD,4BA+DC"}
@@ -0,0 +1,29 @@
1
+ import type { IExecuteFunctions, JsonObject } from 'n8n-workflow';
2
+ /**
3
+ * Normalise the three BigChange response envelope shapes into a flat items array.
4
+ *
5
+ * Shape A: { response: { result: { items, pageItemCount } } }
6
+ * Shape B: { result: { items, pageItemCount } }
7
+ * Shape C: { items, pageItemCount }
8
+ */
9
+ export declare function extractItems(raw: JsonObject): {
10
+ items: JsonObject[];
11
+ pageItemCount: number;
12
+ };
13
+ /**
14
+ * Make an authenticated POST request to a VH3 list API endpoint.
15
+ */
16
+ export declare function vh3ListApiRequest(this: IExecuteFunctions, endpoint: string, body: JsonObject): Promise<JsonObject>;
17
+ /**
18
+ * Validate that companyId is present in credentials before calling enrich endpoints.
19
+ */
20
+ export declare function requireCompanyId(context: IExecuteFunctions, companyId: unknown): asserts companyId is string;
21
+ /**
22
+ * Make an authenticated GET request to the VH3 enrichment API.
23
+ */
24
+ export declare function vh3EnrichApiRequest(this: IExecuteFunctions, endpoint: string, qs: Record<string, string | number>): Promise<JsonObject>;
25
+ /**
26
+ * Make an authenticated GET request to a VH3 proxy API endpoint.
27
+ */
28
+ export declare function vh3ProxyGetRequest(this: IExecuteFunctions, endpoint: string, qs: Record<string, string | number>): Promise<JsonObject>;
29
+ export declare function vh3ListApiRequestAllPages(this: IExecuteFunctions, endpoint: string, body: JsonObject, pageSize?: number): Promise<JsonObject[]>;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractItems = extractItems;
4
+ exports.vh3ListApiRequest = vh3ListApiRequest;
5
+ exports.requireCompanyId = requireCompanyId;
6
+ exports.vh3EnrichApiRequest = vh3EnrichApiRequest;
7
+ exports.vh3ProxyGetRequest = vh3ProxyGetRequest;
8
+ exports.vh3ListApiRequestAllPages = vh3ListApiRequestAllPages;
9
+ const n8n_workflow_1 = require("n8n-workflow");
10
+ const LIST_API_PREFIX = '/api:YdihQNr3';
11
+ const ENRICH_API_PREFIX = '/api:6q5N0phZ';
12
+ /**
13
+ * Normalise the three BigChange response envelope shapes into a flat items array.
14
+ *
15
+ * Shape A: { response: { result: { items, pageItemCount } } }
16
+ * Shape B: { result: { items, pageItemCount } }
17
+ * Shape C: { items, pageItemCount }
18
+ */
19
+ function extractItems(raw) {
20
+ let result = raw;
21
+ if (result.response && typeof result.response === 'object') {
22
+ result = result.response;
23
+ }
24
+ if (result.result && typeof result.result === 'object') {
25
+ result = result.result;
26
+ }
27
+ const items = (Array.isArray(result.items) ? result.items : []);
28
+ const pageItemCount = typeof result.pageItemCount === 'number' ? result.pageItemCount : items.length;
29
+ return { items, pageItemCount };
30
+ }
31
+ /**
32
+ * Make an authenticated POST request to a VH3 list API endpoint.
33
+ */
34
+ async function vh3ListApiRequest(endpoint, body) {
35
+ const credentials = await this.getCredentials('vh3AiApi');
36
+ const baseUrl = credentials.baseUrl.replace(/\/$/, '');
37
+ const options = {
38
+ method: 'POST',
39
+ url: `${baseUrl}${LIST_API_PREFIX}${endpoint}`,
40
+ body: JSON.stringify(body),
41
+ headers: {
42
+ 'Content-Type': 'application/json',
43
+ },
44
+ };
45
+ try {
46
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'vh3AiApi', options);
47
+ if (typeof response === 'string') {
48
+ return JSON.parse(response);
49
+ }
50
+ return response;
51
+ }
52
+ catch (error) {
53
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
54
+ message: `List API request failed: POST ${endpoint}`,
55
+ description: error.message,
56
+ });
57
+ }
58
+ }
59
+ /**
60
+ * Validate that companyId is present in credentials before calling enrich endpoints.
61
+ */
62
+ function requireCompanyId(context, companyId) {
63
+ if (!companyId || (typeof companyId === 'string' && companyId.trim() === '')) {
64
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'Company ID is required for this operation. Set it in your VH3 AI API credentials.');
65
+ }
66
+ }
67
+ /**
68
+ * Make an authenticated GET request to the VH3 enrichment API.
69
+ */
70
+ async function vh3EnrichApiRequest(endpoint, qs) {
71
+ const credentials = await this.getCredentials('vh3AiApi');
72
+ const baseUrl = credentials.baseUrl.replace(/\/$/, '');
73
+ const options = {
74
+ method: 'GET',
75
+ url: `${baseUrl}${ENRICH_API_PREFIX}${endpoint}`,
76
+ qs,
77
+ json: true,
78
+ };
79
+ try {
80
+ return (await this.helpers.httpRequestWithAuthentication.call(this, 'vh3AiApi', options));
81
+ }
82
+ catch (error) {
83
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
84
+ message: `Enrich API request failed: GET ${endpoint}`,
85
+ description: error.message,
86
+ });
87
+ }
88
+ }
89
+ /**
90
+ * Make an authenticated GET request to a VH3 proxy API endpoint.
91
+ */
92
+ async function vh3ProxyGetRequest(endpoint, qs) {
93
+ const credentials = await this.getCredentials('vh3AiApi');
94
+ const baseUrl = credentials.baseUrl.replace(/\/$/, '');
95
+ const options = {
96
+ method: 'GET',
97
+ url: `${baseUrl}${LIST_API_PREFIX}${endpoint}`,
98
+ qs,
99
+ json: true,
100
+ };
101
+ try {
102
+ return (await this.helpers.httpRequestWithAuthentication.call(this, 'vh3AiApi', options));
103
+ }
104
+ catch (error) {
105
+ throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
106
+ message: `Proxy API request failed: GET ${endpoint}`,
107
+ description: error.message,
108
+ });
109
+ }
110
+ }
111
+ /**
112
+ * Fetch all pages from a list endpoint, auto-paginating until all items are collected.
113
+ */
114
+ const MAX_PAGES = 200;
115
+ async function vh3ListApiRequestAllPages(endpoint, body, pageSize = 100) {
116
+ const allItems = [];
117
+ let page = 1;
118
+ while (page <= MAX_PAGES) {
119
+ const pagedBody = { ...body, pageNumber: page, pageSize };
120
+ const raw = await vh3ListApiRequest.call(this, endpoint, pagedBody);
121
+ const { items, pageItemCount } = extractItems(raw);
122
+ allItems.push(...items);
123
+ if (pageItemCount < pageSize) {
124
+ break;
125
+ }
126
+ page++;
127
+ }
128
+ return allItems;
129
+ }
130
+ //# sourceMappingURL=GenericFunctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GenericFunctions.js","sourceRoot":"","sources":["../../../nodes/Vh3Ai/GenericFunctions.ts"],"names":[],"mappings":";;AAiBA,oCAeC;AAKD,8CAiCC;AAKD,4CAOC;AAKD,kDA2BC;AAKD,gDA2BC;AAOD,8DAuBC;AA3KD,+CAAgE;AAEhE,MAAM,eAAe,GAAG,eAAe,CAAC;AACxC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAE1C;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,GAAe;IAC3C,IAAI,MAAM,GAAe,GAAG,CAAC;IAE7B,IAAI,MAAM,CAAC,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC5D,MAAM,GAAG,MAAM,CAAC,QAAsB,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;QACxD,MAAM,GAAG,MAAM,CAAC,MAAoB,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAiB,CAAC;IAChF,MA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-0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Vh3Ai implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }