@getcheddar/cheddar-mcp 1.0.4 → 2.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 CHANGED
@@ -1,197 +1,88 @@
1
- # Cheddar MCP Server
1
+ # Cheddar MCP Server (legacy API)
2
2
 
3
- A Model Context Protocol (MCP) server for integrating with the Cheddar Payment Platform. This server provides AI assistants with tools to manage customers, payment methods, subscriptions, and generate checkout integration code.
3
+ Model Context Protocol server that calls the **legacy Cheddar merchant API** documented at [https://docs.getcheddar.com/](https://docs.getcheddar.com/) using **HTTP Basic** authentication (`Authorization: Basic …`).
4
4
 
5
- ## Features
5
+ This package **does not** use `https://api.*` OAuth2 / Bearer REST.
6
6
 
7
- - **Customer Management**: Create, read, and update customers
8
- - **Payment Methods**: Tokenize cards and manage payment methods (PCI-compliant)
9
- - **Subscriptions**: View subscription details and manage promotions
10
- - **Checkout Integration**: Generate hosted checkout URLs and embedded form code
11
- - **Code Generation**: Produce framework-specific integration code (React, Vue, Next.js, Vanilla JS)
12
- - **Webhook Handling**: Validate and configure webhook endpoints
7
+ **Package:** `@getcheddar/cheddar-mcp`
8
+ **Version:** 2.0.0
13
9
 
14
- ## Installation
10
+ ## Requirements
15
11
 
16
- ### Option 1: Run with npx (recommended)
12
+ - Node.js **18+**
13
+ - A Cheddar **product site** base URL (same host you use for admin/checkout, e.g. `https://yoursubdomain.chargevault.com`)
14
+ - **Product code** (`productCode` in URLs)
15
+ - An **authorized user email** and **password** *or* the product **API key** (“secret key” from Configuration → Settings) as the Basic password ([auth docs](https://docs.getcheddar.com/#authentication))
17
16
 
18
- ```bash
19
- npx -y @getcheddar/cheddar-mcp
20
- ```
17
+ ## Environment variables
21
18
 
22
- ### Option 2: Install globally
19
+ | Variable | Required | Description |
20
+ |----------|----------|-------------|
21
+ | `CHEDDAR_BASE_URL` | **Yes** | Origin of your product app, no trailing slash (e.g. `https://cvences.chargevault.com`). |
22
+ | `CHEDDAR_PRODUCT_CODE` | **Yes** | Your product’s `productCode` segment in legacy URLs. |
23
+ | `CHEDDAR_USERNAME` | **Yes** | Email of an API-enabled user on that product. |
24
+ | `CHEDDAR_PASSWORD` | One of | That user’s login password. |
25
+ | `CHEDDAR_PRODUCT_API_KEY` | One of | Product secret key from admin settings; used as Basic **password** if `CHEDDAR_PASSWORD` is unset. |
26
+ | `CHEDDAR_SKIP_PREFLIGHT` | No | If set to `1`, skip startup `GET /xml/plans/get/...` check. |
27
+
28
+ ## Install & run
23
29
 
24
30
  ```bash
25
- npm install -g @getcheddar/cheddar-mcp
26
- cheddar-mcp
31
+ cd packages/cheddar-mcp
32
+ npm install
33
+ npm run build
27
34
  ```
28
35
 
29
- ### Option 3: Docker
30
-
31
- Build the image from this package (there is no guaranteed public image on a registry yet):
32
-
33
36
  ```bash
34
- # From the repository root, or set context to this directory
35
- docker build -t cheddar-mcp ./packages/cheddar-mcp
37
+ export CHEDDAR_BASE_URL=https://your-product-host.example
38
+ export CHEDDAR_PRODUCT_CODE=YOUR_PRODUCT_CODE
39
+ export CHEDDAR_USERNAME=api-user@example.com
40
+ export CHEDDAR_PRODUCT_API_KEY=your_secret_key
36
41
 
37
- docker run -i --rm \
38
- -e CHEDDAR_API_URL=https://api.getcheddar.com \
39
- -e CHEDDAR_ACCESS_TOKEN=your_token \
40
- cheddar-mcp
42
+ node dist/index.js
41
43
  ```
42
44
 
43
- ## Configuration
44
-
45
- Set the following environment variables:
46
-
47
- | Variable | Required for API calls | Description |
48
- | ------------------------- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
- | `CHEDDAR_API_URL` | No | REST API base URL. **Production:** `https://api.getcheddar.com`. If unset, the server defaults to `https://api.chdr.dev`. For local Cheddar docker development, use the API host from your stack (often `http://api.chdrdev.com` or `http://api.chdrdev.com:8888` with hosts file entries). |
50
- | `CHEDDAR_ACCESS_TOKEN` | **Yes** | OAuth2 access token, sent as `Authorization: Bearer …` on every request. |
51
- | `CHEDDAR_CLIENT_ID` | No† | OAuth2 client ID (reserved for future automatic token acquisition in this package). |
52
- | `CHEDDAR_CLIENT_SECRET` | No† | OAuth2 client secret (same as above). |
53
-
54
- †The process may start if both `CHEDDAR_CLIENT_ID` and `CHEDDAR_CLIENT_SECRET` are set without a token, but **API calls will fail** until `CHEDDAR_ACCESS_TOKEN` is set. Client-credentials exchange is not implemented in the client yet—use a bearer token.
55
-
56
- ### Getting credentials and an access token
45
+ Or with `npx` after publish:
57
46
 
58
- 1. Sign in to your Cheddar merchant admin (production login: [https://login.getcheddar.com](https://login.getcheddar.com)).
59
- 2. In the dashboard, open the section where **API / OAuth2** clients (or API keys) are managed, and create or copy a client that supports the **client credentials** grant.
60
- 3. Request an access token from the OAuth token endpoint:
61
-
62
- - **Production:** `POST` [https://login.getcheddar.com/oauth/token](https://login.getcheddar.com/oauth/token)
63
- - **Headers:** `Content-Type: application/json`
64
- - **Body (example):**
47
+ ```bash
48
+ npx -y @getcheddar/cheddar-mcp
49
+ ```
65
50
 
66
- ```json
67
- {
68
- "grant_type": "client_credentials",
69
- "client_id": "your-client-id",
70
- "client_secret": "your-client-secret"
71
- }
72
- ```
51
+ ## Tools
73
52
 
74
- 4. Set `CHEDDAR_ACCESS_TOKEN` to the `access_token` value from the response.
75
- 5. Set `CHEDDAR_API_URL` to the API base for that environment (production: `https://api.getcheddar.com`).
53
+ | Tool | Legacy endpoint (conceptually) |
54
+ |------|--------------------------------|
55
+ | `cheddar_customer_get` | `GET /xml/customers/get/productCode/.../code/…` or `/id/…` |
56
+ | `cheddar_customers_search` | `GET /xml/customers/search/productCode/...` (requests `format=json` when supported) |
57
+ | `cheddar_customer_create` | `POST /xml/customers/new/productCode/...` (form body) |
58
+ | `cheddar_customer_update` | `POST /xml/customers/edit/productCode/.../code/...` |
59
+ | `cheddar_plans_get` | `GET /xml/plans/get/productCode/...` (optional `planCode`) |
76
60
 
77
- ## Usage with Claude Desktop
61
+ Responses are returned as **JSON text**: XML from the API is parsed to a plain object where possible.
78
62
 
79
- Add to your Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS or `%APPDATA%/Claude/claude_desktop_config.json` on Windows):
63
+ ## Claude Desktop example
80
64
 
81
65
  ```json
82
66
  {
83
67
  "mcpServers": {
84
68
  "cheddar": {
85
- "command": "npx",
86
- "args": ["-y", "@getcheddar/cheddar-mcp"],
69
+ "command": "node",
70
+ "args": ["/absolute/path/to/cheddar-mcp/dist/index.js"],
87
71
  "env": {
88
- "CHEDDAR_API_URL": "https://api.getcheddar.com",
89
- "CHEDDAR_ACCESS_TOKEN": "your-access-token"
72
+ "CHEDDAR_BASE_URL": "https://your-product-host.example",
73
+ "CHEDDAR_PRODUCT_CODE": "YOUR_PRODUCT_CODE",
74
+ "CHEDDAR_USERNAME": "api-user@example.com",
75
+ "CHEDDAR_PRODUCT_API_KEY": "your_secret_key"
90
76
  }
91
77
  }
92
78
  }
93
79
  }
94
80
  ```
95
81
 
96
- ## Usage with Cursor
97
-
98
- 1. Open Cursor Settings.
99
- 2. Navigate to **Features → MCP**.
100
- 3. Add a new MCP server:
101
- - **Name:** `cheddar`
102
- - **Command:** `npx`
103
- - **Arguments:** `-y`, `@getcheddar/cheddar-mcp`
104
- - **Environment:** same variables as above (`CHEDDAR_API_URL`, `CHEDDAR_ACCESS_TOKEN`), or rely on a wrapper script that exports them.
105
-
106
- Prefer defining `env` in the MCP server configuration so the token is not tied to a single terminal session.
107
-
108
- ## Available Tools
109
-
110
- ### Customer Management
111
-
112
- | Tool | Description |
113
- | ------------------------- | ----------------------------------- |
114
- | `cheddar_customer_get` | Retrieve a customer by ID or code |
115
- | `cheddar_customer_create` | Create a new customer |
116
- | `cheddar_customer_update` | Update customer information |
117
-
118
- ### Payment Methods
119
-
120
- | Tool | Description |
121
- | -------------------------------------------- | ---------------------------------------- |
122
- | `cheddar_payment_method_get` | Retrieve a payment method by ID |
123
- | `cheddar_payment_method_get_customer` | Get customer from payment method |
124
- | `cheddar_payment_method_get_gateway_account` | Get gateway account for payment method |
125
- | `cheddar_payment_token_create` | Tokenize card data (PCI-compliant) |
126
- | `cheddar_payment_method_add_to_customer` | Add tokenized payment method to customer |
127
-
128
- ### Subscriptions & Plans
129
-
130
- | Tool | Description |
131
- | ----------------------------------------- | ------------------------------------ |
132
- | `cheddar_subscription_get` | Retrieve subscription by ID |
133
- | `cheddar_subscription_get_customer` | Get customer from subscription |
134
- | `cheddar_subscription_get_plan` | Get plan from subscription |
135
- | `cheddar_subscription_get_payment_method` | Get payment method from subscription |
136
- | `cheddar_subscription_delete_promotion` | Remove promotion from subscription |
137
- | `cheddar_plan_get` | Retrieve plan by ID or code |
138
- | `cheddar_gateway_account_get` | Get gateway account details |
139
-
140
- ### Checkout Integration
141
-
142
- | Tool | Description |
143
- | -------------------------------------------- | ------------------------------------ |
144
- | `cheddar_checkout_generate_hosted_url` | Generate hosted checkout page URL |
145
- | `cheddar_checkout_generate_embedded_form` | Generate embedded checkout form code |
146
- | `cheddar_checkout_generate_integration_code` | Generate framework-specific code |
147
- | `cheddar_checkout_validate_webhook` | Validate webhook signature |
148
- | `cheddar_checkout_configure_webhook` | Generate webhook handler code |
149
-
150
- ## Example Usage
151
-
152
- ### Get a Customer
153
-
154
- ```
155
- Use the cheddar_customer_get tool with ID "cust_12345"
156
- ```
157
-
158
- ### Create a Payment Method Token
159
-
160
- ```
161
- Use the cheddar_payment_token_create tool with:
162
- - cardNumber: "4111111111111111"
163
- - expirationDate: "12/25"
164
- - cvv: "123"
165
- - cardholderName: "John Doe"
166
- ```
167
-
168
- ### Generate React Integration
169
-
170
- ```
171
- Use the cheddar_checkout_generate_integration_code tool with:
172
- - framework: "react"
173
- - integrationType: "embedded"
174
- - features: ["card", "subscriptions"]
175
- - styling: "tailwind"
176
- ```
177
-
178
82
  ## Development
179
83
 
180
84
  ```bash
181
- # Clone the repository
182
- git clone https://github.com/chdr/cheddar-ai-tools.git
183
- cd cheddar-ai-tools/packages/cheddar-mcp
184
-
185
- # Install dependencies
186
- npm install
187
-
188
- # Build
189
85
  npm run build
190
-
191
- # Run in development mode
192
- npm run dev
193
-
194
- # Test
195
86
  npm test
196
87
  ```
197
88
 
@@ -201,6 +92,6 @@ MIT © Cheddar (chdr)
201
92
 
202
93
  ## Support
203
94
 
204
- - Documentation: https://docs.cheddar.com
205
- - Support: support@cheddar.com
95
+ - Documentation: https://docs.getcheddar.com
96
+ - Support: support@getcheddar.com
206
97
  - Issues: https://github.com/chdr/cheddar-ai-tools/issues
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * CLI entry for npm `bin` (stable path). npm 10+ may reject `bin` pointing at build output under `dist/`.
4
+ */
5
+ import "../dist/index.js";
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ import "dotenv/config";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,84 +1,86 @@
1
+ import "dotenv/config";
1
2
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
4
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
4
- import { CheddarApiClient } from "./lib/cheddar-client.js";
5
+ import { LegacyApiError, LegacyCheddarClient } from "./lib/legacy-client.js";
5
6
  import { customerTools, handleCustomerTool } from "./tools/customers.js";
6
- import { paymentMethodTools, handlePaymentMethodTool } from "./tools/payment-methods.js";
7
- import { subscriptionTools, handleSubscriptionTool } from "./tools/subscriptions.js";
8
- import { checkoutTools, handleCheckoutTool } from "./tools/checkout.js";
9
- // Configuration from environment
10
- const config = {
11
- apiUrl: process.env.CHEDDAR_API_URL || "https://api.chdr.dev",
12
- clientId: process.env.CHEDDAR_CLIENT_ID || "",
13
- clientSecret: process.env.CHEDDAR_CLIENT_SECRET || "",
14
- accessToken: process.env.CHEDDAR_ACCESS_TOKEN || "",
15
- };
16
- // Validate required config
17
- if (!config.accessToken && (!config.clientId || !config.clientSecret)) {
18
- console.error("Error: CHEDDAR_ACCESS_TOKEN or both CHEDDAR_CLIENT_ID and CHEDDAR_CLIENT_SECRET must be set");
7
+ import { planTools, handlePlanTool } from "./tools/plans.js";
8
+ const baseUrl = (process.env.CHEDDAR_BASE_URL || "").replace(/\/+$/, "");
9
+ const productCode = process.env.CHEDDAR_PRODUCT_CODE || "";
10
+ const username = process.env.CHEDDAR_USERNAME || "";
11
+ const password = process.env.CHEDDAR_PASSWORD || process.env.CHEDDAR_PRODUCT_API_KEY || "";
12
+ if (!baseUrl || !productCode || !username || !password) {
13
+ console.error("Missing config. Set CHEDDAR_BASE_URL, CHEDDAR_PRODUCT_CODE, CHEDDAR_USERNAME, and CHEDDAR_PASSWORD or CHEDDAR_PRODUCT_API_KEY.");
19
14
  process.exit(1);
20
15
  }
21
- // Initialize Cheddar API client
22
- const cheddarClient = new CheddarApiClient(config);
23
- // Combine all tools
24
- const ALL_TOOLS = [
25
- ...customerTools,
26
- ...paymentMethodTools,
27
- ...subscriptionTools,
28
- ...checkoutTools,
29
- ];
30
- // Create MCP server
16
+ const client = new LegacyCheddarClient({
17
+ baseUrl,
18
+ productCode,
19
+ username,
20
+ password,
21
+ });
22
+ const ALL_TOOLS = [...customerTools, ...planTools];
31
23
  const server = new Server({
32
24
  name: "cheddar-mcp",
33
- version: "0.1.0",
25
+ version: "2.0.0",
34
26
  }, {
35
27
  capabilities: {
36
28
  tools: {},
37
29
  },
38
30
  });
39
- // Handler for listing available tools
40
- server.setRequestHandler(ListToolsRequestSchema, async () => {
41
- return {
42
- tools: ALL_TOOLS,
43
- };
44
- });
45
- // Handler for tool execution
31
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: ALL_TOOLS }));
32
+ function toolErrorMessage(error) {
33
+ if (error instanceof LegacyApiError) {
34
+ return `Cheddar API error (HTTP ${error.status}). See server logs for details.`;
35
+ }
36
+ if (error instanceof Error) {
37
+ return error.message;
38
+ }
39
+ return String(error);
40
+ }
46
41
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
47
42
  const { name, arguments: args } = request.params;
48
43
  try {
49
- // Route to appropriate handler based on tool name prefix
50
- if (name.startsWith("cheddar_customer_")) {
51
- return await handleCustomerTool(cheddarClient, name, args);
52
- }
53
- if (name.startsWith("cheddar_payment_")) {
54
- return await handlePaymentMethodTool(cheddarClient, name, args);
44
+ if (name.startsWith("cheddar_customer")) {
45
+ return await handleCustomerTool(client, name, args);
55
46
  }
56
- if (name.startsWith("cheddar_subscription_")) {
57
- return await handleSubscriptionTool(cheddarClient, name, args);
58
- }
59
- if (name.startsWith("cheddar_checkout_")) {
60
- return await handleCheckoutTool(cheddarClient, name, args);
47
+ if (name.startsWith("cheddar_plans_")) {
48
+ return await handlePlanTool(client, name, args);
61
49
  }
62
50
  throw new Error(`Unknown tool: ${name}`);
63
51
  }
64
52
  catch (error) {
65
- const errorMessage = error instanceof Error ? error.message : String(error);
53
+ if (error instanceof LegacyApiError) {
54
+ console.error("[cheddar-mcp] LegacyApiError body:", typeof error.body === "string" ? error.body.slice(0, 4000) : JSON.stringify(error.body).slice(0, 4000));
55
+ }
56
+ else {
57
+ console.error("[cheddar-mcp] Tool error:", error);
58
+ }
66
59
  return {
67
- content: [
68
- {
69
- type: "text",
70
- text: `Error: ${errorMessage}`,
71
- },
72
- ],
60
+ content: [{ type: "text", text: `Error: ${toolErrorMessage(error)}` }],
73
61
  isError: true,
74
62
  };
75
63
  }
76
64
  });
77
- // Start server
78
65
  async function main() {
66
+ if (!process.env.CHEDDAR_SKIP_PREFLIGHT) {
67
+ try {
68
+ await client.ping();
69
+ }
70
+ catch (err) {
71
+ const msg = err instanceof Error ? err.message : String(err);
72
+ console.error(`Cheddar legacy API preflight failed: ${msg}`);
73
+ if (err instanceof LegacyApiError) {
74
+ console.error("[cheddar-mcp] Preflight response body:", typeof err.body === "string"
75
+ ? err.body.slice(0, 4000)
76
+ : JSON.stringify(err.body).slice(0, 4000));
77
+ }
78
+ process.exit(1);
79
+ }
80
+ }
79
81
  const transport = new StdioServerTransport();
80
82
  await server.connect(transport);
81
- console.error("Cheddar MCP server running on stdio");
83
+ console.error("Cheddar MCP (legacy HTTP Basic) running on stdio");
82
84
  }
83
85
  main().catch((error) => {
84
86
  console.error("Fatal error:", error);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAExE,iCAAiC;AACjC,MAAM,MAAM,GAAG;IACb,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,sBAAsB;IAC7D,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE;IAC7C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE;IACrD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,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C,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACpE,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,44 @@
1
+ export interface LegacyCheddarConfig {
2
+ /** Product site origin, e.g. https://yoursubdomain.chargevault.com (no trailing slash) */
3
+ baseUrl: string;
4
+ productCode: string;
5
+ /** HTTP Basic username (authorized user email) */
6
+ username: string;
7
+ /** HTTP Basic password (user password or product API key) */
8
+ password: string;
9
+ }
10
+ export declare class LegacyCheddarClient {
11
+ private readonly base;
12
+ private readonly productCode;
13
+ private readonly auth;
14
+ constructor(cfg: LegacyCheddarConfig);
15
+ private parseBody;
16
+ /**
17
+ * GET legacy XML (or JSON if the endpoint supports `format=json`).
18
+ */
19
+ get(pathWithLeadingSlash: string, query?: Record<string, string>): Promise<unknown>;
20
+ /**
21
+ * POST `application/x-www-form-urlencoded` (legacy API style).
22
+ */
23
+ postForm(pathWithLeadingSlash: string, fields: Record<string, string>): Promise<unknown>;
24
+ ping(): Promise<unknown>;
25
+ getCustomer(by: "code" | "id", value: string): Promise<unknown>;
26
+ searchCustomers(params: Record<string, string>): Promise<unknown>;
27
+ getPlans(planCode?: string): Promise<unknown>;
28
+ /**
29
+ * Flat object keys become form keys; nested objects use bracket notation (subscription[planCode]).
30
+ */
31
+ createCustomer(fields: Record<string, unknown>): Promise<unknown>;
32
+ updateCustomer(customerCode: string, fields: Record<string, unknown>): Promise<unknown>;
33
+ }
34
+ export declare class LegacyApiError extends Error {
35
+ readonly status: number;
36
+ readonly body: unknown;
37
+ constructor(status: number, body: unknown);
38
+ }
39
+ /**
40
+ * Flattens `{ firstName: "a", subscription: { planCode: "FREE" } }` into
41
+ * `firstName`, `subscription[planCode]` for legacy form posts.
42
+ */
43
+ export declare function flattenFormFields(obj: Record<string, unknown>, prefix?: string): Record<string, string>;
44
+ //# sourceMappingURL=legacy-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-client.d.ts","sourceRoot":"","sources":["../../src/lib/legacy-client.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgBD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;gBAElB,GAAG,EAAE,mBAAmB;YAMtB,SAAS;IAiBvB;;OAEG;IACG,GAAG,CAAC,oBAAoB,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBzF;;OAEG;IACG,QAAQ,CAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAmBxF,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/D,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAOjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASnD;;OAEG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjE,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;CAO9F;AAED,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM1C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,MAAM,SAAK,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB"}
@@ -0,0 +1,149 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+ function trimSlash(s) {
3
+ return s.replace(/\/+$/, "");
4
+ }
5
+ function basicAuthHeader(username, password) {
6
+ const token = Buffer.from(`${username}:${password}`, "utf8").toString("base64");
7
+ return `Basic ${token}`;
8
+ }
9
+ const xmlParser = new XMLParser({
10
+ ignoreAttributes: false,
11
+ attributeNamePrefix: "@_",
12
+ });
13
+ export class LegacyCheddarClient {
14
+ base;
15
+ productCode;
16
+ auth;
17
+ constructor(cfg) {
18
+ this.base = trimSlash(cfg.baseUrl);
19
+ this.productCode = encodeURIComponent(cfg.productCode);
20
+ this.auth = basicAuthHeader(cfg.username, cfg.password);
21
+ }
22
+ async parseBody(res) {
23
+ const text = await res.text();
24
+ const ct = res.headers.get("content-type") || "";
25
+ if (ct.includes("json") || (text.startsWith("{") && text.endsWith("}"))) {
26
+ try {
27
+ return JSON.parse(text);
28
+ }
29
+ catch {
30
+ /* fall through */
31
+ }
32
+ }
33
+ try {
34
+ return xmlParser.parse(text);
35
+ }
36
+ catch {
37
+ return { _raw: text };
38
+ }
39
+ }
40
+ /**
41
+ * GET legacy XML (or JSON if the endpoint supports `format=json`).
42
+ */
43
+ async get(pathWithLeadingSlash, query) {
44
+ const q = new URLSearchParams(query);
45
+ const qs = q.toString();
46
+ const url = `${this.base}${pathWithLeadingSlash}${qs ? `?${qs}` : ""}`;
47
+ const res = await fetch(url, {
48
+ method: "GET",
49
+ headers: {
50
+ Authorization: this.auth,
51
+ Accept: "application/xml, application/json;q=0.9, text/xml;q=0.8, */*;q=0.1",
52
+ },
53
+ });
54
+ const body = await this.parseBody(res);
55
+ if (!res.ok) {
56
+ throw new LegacyApiError(res.status, body);
57
+ }
58
+ return body;
59
+ }
60
+ /**
61
+ * POST `application/x-www-form-urlencoded` (legacy API style).
62
+ */
63
+ async postForm(pathWithLeadingSlash, fields) {
64
+ const url = `${this.base}${pathWithLeadingSlash}`;
65
+ const body = new URLSearchParams(fields);
66
+ const res = await fetch(url, {
67
+ method: "POST",
68
+ headers: {
69
+ Authorization: this.auth,
70
+ "Content-Type": "application/x-www-form-urlencoded",
71
+ Accept: "application/xml, application/json;q=0.9, text/xml;q=0.8, */*;q=0.1",
72
+ },
73
+ body,
74
+ });
75
+ const parsed = await this.parseBody(res);
76
+ if (!res.ok) {
77
+ throw new LegacyApiError(res.status, parsed);
78
+ }
79
+ return parsed;
80
+ }
81
+ async ping() {
82
+ return this.get(`/xml/plans/get/productCode/${this.productCode}`);
83
+ }
84
+ async getCustomer(by, value) {
85
+ const v = encodeURIComponent(value);
86
+ return this.get(`/xml/customers/get/productCode/${this.productCode}/${by}/${v}`);
87
+ }
88
+ async searchCustomers(params) {
89
+ return this.get(`/xml/customers/search/productCode/${this.productCode}`, {
90
+ ...params,
91
+ format: "json",
92
+ });
93
+ }
94
+ async getPlans(planCode) {
95
+ if (planCode) {
96
+ return this.get(`/xml/plans/get/productCode/${this.productCode}/code/${encodeURIComponent(planCode)}`);
97
+ }
98
+ return this.get(`/xml/plans/get/productCode/${this.productCode}`);
99
+ }
100
+ /**
101
+ * Flat object keys become form keys; nested objects use bracket notation (subscription[planCode]).
102
+ */
103
+ async createCustomer(fields) {
104
+ const flat = flattenFormFields(fields);
105
+ return this.postForm(`/xml/customers/new/productCode/${this.productCode}`, flat);
106
+ }
107
+ async updateCustomer(customerCode, fields) {
108
+ const flat = flattenFormFields(fields);
109
+ return this.postForm(`/xml/customers/edit/productCode/${this.productCode}/code/${encodeURIComponent(customerCode)}`, flat);
110
+ }
111
+ }
112
+ export class LegacyApiError extends Error {
113
+ status;
114
+ body;
115
+ constructor(status, body) {
116
+ super(`Cheddar legacy API request failed (HTTP ${status}).`);
117
+ this.name = "LegacyApiError";
118
+ this.status = status;
119
+ this.body = body;
120
+ }
121
+ }
122
+ /**
123
+ * Flattens `{ firstName: "a", subscription: { planCode: "FREE" } }` into
124
+ * `firstName`, `subscription[planCode]` for legacy form posts.
125
+ */
126
+ export function flattenFormFields(obj, prefix = "") {
127
+ const out = {};
128
+ for (const [k, val] of Object.entries(obj)) {
129
+ if (val === undefined || val === null)
130
+ continue;
131
+ const key = prefix ? `${prefix}[${k}]` : k;
132
+ if (typeof val === "object" && !Array.isArray(val)) {
133
+ Object.assign(out, flattenFormFields(val, key));
134
+ }
135
+ else if (Array.isArray(val)) {
136
+ val.forEach((item, i) => {
137
+ out[`${key}[${i}]`] = String(item);
138
+ });
139
+ }
140
+ else if (typeof val === "boolean") {
141
+ out[key] = val ? "1" : "0";
142
+ }
143
+ else {
144
+ out[key] = String(val);
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ //# sourceMappingURL=legacy-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy-client.js","sourceRoot":"","sources":["../../src/lib/legacy-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAA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