{"id":15352,"library":"leadconduit-integration","title":"LeadConduit Integration Utilities","description":"The `leadconduit-integration` package provides a specialized set of Node.js utility functions designed to streamline the development of integrations with the LeadConduit platform. Currently at version 0.6.3, it offers core functionalities such as the `HttpError` class, which allows developers to construct immediate HTTP responses with specific status codes, headers, and body content for inbound integrations, effectively short-circuiting request processing. Additionally, it includes a `test.parser` helper, invaluable for simulating and parsing richly typed LeadConduit data during unit testing, transforming raw input objects into structured, validated data based on predefined request variable configurations. Given its highly specialized niche within the LeadConduit ecosystem, its release cadence is typically driven by internal development needs rather than a strict public schedule. Its primary differentiator is its direct utility for simplifying common integration patterns and data handling specific to the LeadConduit platform, abstracting away much of the boilerplate associated with bespoke integration development for that environment.","status":"active","version":"0.6.3","language":"javascript","source_language":"en","source_url":"https://github.com/activeprospect/leadconduit-integration","tags":["javascript"],"install":[{"cmd":"npm install leadconduit-integration","lang":"bash","label":"npm"},{"cmd":"yarn add leadconduit-integration","lang":"bash","label":"yarn"},{"cmd":"pnpm add leadconduit-integration","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"HttpError is a named export. The README shows CommonJS `require('leadconduit-integration').HttpError`, which is also a correct way to access it in CJS projects.","wrong":"import HttpError from 'leadconduit-integration';\nconst HttpError = require('leadconduit-integration');","symbol":"HttpError","correct":"import { HttpError } from 'leadconduit-integration';"},{"note":"The `parser` function is a nested utility under the `test` object. Access it via `test.parser` from the named ESM export, or `require('leadconduit-integration').test.parser` in CommonJS.","wrong":"import { parser } from 'leadconduit-integration';\nconst parser = require('leadconduit-integration').parser;","symbol":"test.parser","correct":"import { test } from 'leadconduit-integration';\nconst parser = test.parser;"},{"note":"This is the idiomatic way to destructure named exports in CommonJS, providing direct access to `HttpError` and the `test` utility object.","wrong":"const lcIntegration = require('leadconduit-integration'); // then expect lcIntegration.HttpError to be a class directly without destructuring","symbol":"CommonJS named exports","correct":"const { HttpError, test } = require('leadconduit-integration');"}],"quickstart":{"code":"import { HttpError, test } from 'leadconduit-integration';\n\n// Example 1: Handling immediate HTTP responses in an inbound integration\nfunction handleIncomingRequest(req: { method?: string }): { status: number; body: string; headers?: Record<string, string> } {\n  const method = req.method?.toLowerCase();\n  if (method !== 'get' && method !== 'post') {\n    throw new HttpError(\n      415,\n      { 'Content-Type': 'text/plain', Allow: 'GET, POST' },\n      `The ${method?.toUpperCase() || 'UNKNOWN'} method is not allowed`\n    );\n  }\n  console.log(`Processing ${method?.toUpperCase()} request...`);\n  // ... actual request processing logic ...\n  return { status: 200, body: 'Request handled successfully!' };\n}\n\ntry {\n  handleIncomingRequest({ method: 'PUT' }); // Simulate an unsupported method\n} catch (e) {\n  if (e instanceof HttpError) {\n    console.log(`\\nCaught HttpError: Status ${e.status}, Body: '${e.body}'`);\n  } else {\n    console.error(`\\nAn unexpected error occurred: ${e instanceof Error ? e.message : String(e)}`);\n  }\n}\n\n// Example 2: Using test.parser to simulate and parse richly typed data for tests\nconst requestVariables = [\n  { name: 'zip_code', type: 'postal_code' },\n  { name: 'contact_phone', type: 'phone' },\n  { name: 'age_years', type: 'integer' },\n  { name: 'enrollment_date', type: 'date' }\n];\n\nconst parseLeadData = test.parser(requestVariables);\n\nconst rawLeadInput = {\n  first_name: 'Alice',\n  zip_code: '90210',\n  contact_phone: '1-800-555-0199',\n  age_years: '25',\n  enrollment_date: '2023-11-15'\n};\n\nconst parsedLeadData = parseLeadData(rawLeadInput);\nconsole.log('\\nParsed Lead Data for Testing:');\nconsole.log(JSON.stringify(parsedLeadData, null, 2));\n","lang":"typescript","description":"Demonstrates how to handle immediate HTTP responses using `HttpError` in an inbound integration, and how to use `test.parser` to simulate and parse richly typed LeadConduit data for unit testing purposes."},"warnings":[{"fix":"Always pin to exact versions or test thoroughly before deploying new minor versions in production environments. Refer to the GitHub repository for release notes and detailed changes.","message":"This package is currently in a pre-1.0 release phase (v0.6.3). Breaking changes may be introduced in minor version updates without strictly adhering to semantic versioning for major increments. Always review the release notes carefully when upgrading.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"For ESM, use named imports: `import { HttpError, test } from 'leadconduit-integration';`. For nested properties, access them directly: `const parser = test.parser;`.","message":"The documentation and examples primarily feature CommonJS (`require`) syntax. While the package supports ESM `import` statements, users integrating into pure ESM projects should ensure their build setup correctly handles named exports, especially for nested utilities like `test.parser`.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Refer to the official LeadConduit documentation for context on integration development and data structures before implementing with this library.","message":"This is a highly specialized utility module designed for LeadConduit integrations. Its concepts (e.g., 'request vars', 'type parser') are specific to the LeadConduit platform. Developers unfamiliar with LeadConduit's integration patterns might find it difficult to use without prior context.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Use ESM `import { HttpError, test } from 'leadconduit-integration';` instead of `require()`. Ensure your Node.js project is configured for ESM (e.g., `\"type\": \"module\"` in `package.json`) or use a bundler that handles CommonJS interoperability.","cause":"Attempting to use `require()` in an ECMAScript Module (ESM) context without proper transpilation or a Node.js wrapper.","error":"TypeError: require is not a function"},{"fix":"Use named import `import { HttpError } from 'leadconduit-integration';` for ESM, or destructure from `require`: `const { HttpError } = require('leadconduit-integration');` for CommonJS.","cause":"Incorrectly importing `HttpError` as a default export, or not accessing it as a named property from the `require()` result.","error":"TypeError: HttpError is not a constructor"},{"fix":"Ensure `test` is correctly imported as a named export (`import { test } from 'leadconduit-integration';`) or accessed as a property of the main CommonJS `require` object (`const parser = require('leadconduit-integration').test.parser;`). Then, access `parser` via `test.parser`.","cause":"Attempting to access `parser` from an `undefined` `test` object, often due to incorrect import or destructuring of the `test` utility.","error":"TypeError: Cannot read properties of undefined (reading 'parser')"}],"ecosystem":"npm"}