@borrowbetter/arpcsdk 0.3.0 → 0.5.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/dist/index.js CHANGED
@@ -147,6 +147,17 @@ var getARPCAchieveResolutionPartnerConnectAPI = () => {
147
147
  options
148
148
  );
149
149
  };
150
+ const selectProgram = (programSelectionRequest, options) => {
151
+ return customInstance(
152
+ {
153
+ url: `/v1/application/program-selection`,
154
+ method: "POST",
155
+ headers: { "Content-Type": "application/json" },
156
+ data: programSelectionRequest
157
+ },
158
+ options
159
+ );
160
+ };
150
161
  const checkApplicationReadiness = (statelessReadinessRequest, options) => {
151
162
  return customInstance(
152
163
  {
@@ -293,7 +304,23 @@ var getARPCAchieveResolutionPartnerConnectAPI = () => {
293
304
  options
294
305
  );
295
306
  };
296
- return { createLeadSync, checkApplicationReadiness, createSpinwheelNetworkUser, updateApplicationBankDetails, sendEmail, leadTransfer, readLead, patchLead, getApplicationReadiness, generateDra, registerApplicantV2, generateProgramV1, checkEligibility, uwSubmissionV2, createProgramSummaryTask };
307
+ return { createLeadSync, selectProgram, checkApplicationReadiness, createSpinwheelNetworkUser, updateApplicationBankDetails, sendEmail, leadTransfer, readLead, patchLead, getApplicationReadiness, generateDra, registerApplicantV2, generateProgramV1, checkEligibility, uwSubmissionV2, createProgramSummaryTask };
308
+ };
309
+
310
+ // src/draft-type.ts
311
+ var DRAFT_TYPE_LABEL = {
312
+ regular: "Regular",
313
+ split: "Split",
314
+ "bi-weekly": "Bi-Weekly"
315
+ };
316
+ var DRAFT_TYPE_CODE = {
317
+ Regular: "regular",
318
+ Split: "split",
319
+ "Bi-Weekly": "bi-weekly"
320
+ };
321
+ var draftTypeOf = (application) => {
322
+ const label = application?.draft_type;
323
+ return label ? DRAFT_TYPE_CODE[label] : void 0;
297
324
  };
298
325
 
299
326
  // src/index.ts
@@ -307,6 +334,9 @@ var ArpcSDK = class {
307
334
 
308
335
  exports.ARPC_ENDPOINTS = ARPC_ENDPOINTS;
309
336
  exports.ArpcSDK = ArpcSDK;
337
+ exports.DRAFT_TYPE_CODE = DRAFT_TYPE_CODE;
338
+ exports.DRAFT_TYPE_LABEL = DRAFT_TYPE_LABEL;
339
+ exports.draftTypeOf = draftTypeOf;
310
340
  exports.isArpcEnvironment = isArpcEnvironment;
311
341
  //# sourceMappingURL=index.js.map
312
342
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/auth.ts","../src/http/client.ts","../src/generated/arpc.ts","../src/index.ts"],"names":["ky"],"mappings":";;;;;;;;;AAwCO,IAAM,cAAA,GACZ,OAAO,MAAA,CAAO;AAAA,EACb,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT,CAAA;AAAA,EACD,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT,CAAA;AAAA,EACD,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT;AACF,CAAC;AAMK,SAAS,kBAAkB,KAAA,EAAyC;AAE1E,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,cAAc,CAAA,CAAE,SAAS,KAAK,CAAA;AAClD;AAqCA,IAAI,OAAA,GAAqC,IAAA;AAQzC,SAAS,YAAY,MAAA,EAAwC;AAC5D,EAAA,IAAI,CAAC,iBAAA,CAAkB,MAAA,CAAO,WAAW,CAAA,EAAG;AAC3C,IAAA,MAAM,IAAI,KAAA;AAAA,MACT,CAAA,qBAAA,EAAwB,MAAA,CAAO,WAAW,CAAA,kBAAA,EAAqB,MAAA,CAAO,KAAK,cAAc,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,KACtG;AAAA,EACD;AAC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AU,MAAM,CAAA;AAAA,EACjB;AACD","file":"index.js","sourcesContent":["/**\n * SDK configuration.\n *\n * The library never reads the environment itself — a consumer constructs\n * `new ArpcSDK(config)`, which calls `configure()`. Where that config comes\n * from (env vars, a secrets manager, a config service) is the caller's business.\n */\n/**\n * Bearer-token store. The SDK authenticates lazily on the first gateway call:\n * it asks `get()` for a still-valid token and, on `null`, exchanges credentials\n * and hands the fresh token to `set()`. Owning expiry is the cache's job —\n * `get()` returns `null` once the token is stale (or near-stale). The default\n * store is in-memory and per-process; supply one to persist across restarts or\n * share across workers.\n */\nexport interface TokenCache {\n\t/** Return a valid bearer token, or `null` if absent/expired. */\n\tget(): Promise<string | null>;\n\t/** Persist a freshly exchanged token. `expiresAt` already includes the SDK's refresh skew. */\n\tset(token: string, expiresAt: Date): Promise<void>;\n}\n\n/** FDR deployment target. Selects both hosts — see `ARPC_ENDPOINTS`. */\nexport type ArpcEnvironment = \"dev\" | \"stg\" | \"prd\";\n\n/** The host pair a single environment resolves to. */\nexport interface ArpcEndpoint {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\treadonly oauth: string;\n\t/** API gateway host — every non-auth call. */\n\treadonly gateway: string;\n}\n\n/**\n * Per-environment hosts. The two differ by domain, not just subdomain: the\n * OAuth host is `ffngcp.com`, the gateway is `fdrgcp.com`.\n *\n * Frozen: this table backs both host resolution and environment validation, so\n * a consumer mutating it would quietly change SDK behavior.\n */\nexport const ARPC_ENDPOINTS: Readonly<Record<ArpcEnvironment, ArpcEndpoint>> =\n\tObject.freeze({\n\t\tdev: Object.freeze({\n\t\t\toauth: \"https://oauth.dev.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.dev.fdrgcp.com\",\n\t\t}),\n\t\tstg: Object.freeze({\n\t\t\toauth: \"https://oauth.stg.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.stg.fdrgcp.com\",\n\t\t}),\n\t\tprd: Object.freeze({\n\t\t\toauth: \"https://oauth.prd.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.prd.fdrgcp.com\",\n\t\t}),\n\t});\n\n/**\n * Narrow a raw string to an `ArpcEnvironment`. Useful when the value arrives\n * untyped — an env var, a JSON config file, a request payload.\n */\nexport function isArpcEnvironment(value: string): value is ArpcEnvironment {\n\t// Own keys only — `in` would also match inherited members like `toString`.\n\treturn Object.keys(ARPC_ENDPOINTS).includes(value);\n}\n\nexport interface ArpcAuth {\n\t/**\n\t * OAuth client_id (HTTP Basic username). Also used as the lead's\n\t * `seller_agent_email` — the OAuth identity is a registered DRA agent.\n\t */\n\tusername: string;\n\t/** OAuth client_secret (HTTP Basic password). */\n\tpassword: string;\n\t/** Bearer-token store. Defaults to an in-memory, per-process cache. */\n\tcache?: TokenCache;\n}\n\n/**\n * Escape hatch — per-host overrides of the `environment` defaults. Omit a key\n * (or leave it `undefined`) to keep that environment's host.\n */\nexport interface ArpcUrls {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\toauth?: string;\n\t/** API gateway host — every non-auth call. */\n\tgateway?: string;\n}\n\nexport interface ArpcConfig {\n\t/** Selects the FDR environment. Drives both hosts. */\n\tenvironment: ArpcEnvironment;\n\tauth: ArpcAuth;\n\turls?: ArpcUrls;\n}\n\n/** Config as the internals consume it — hosts resolved to concrete strings. */\nexport interface ResolvedArpcConfig extends ArpcConfig {\n\turls: Required<ArpcUrls>;\n}\n\nlet current: ResolvedArpcConfig | null = null;\n\n/**\n * Fold the environment defaults together with any caller overrides. The guard\n * looks unreachable given the types, but `environment` routinely arrives from\n * somewhere untyped (an env var, a JSON config, a JS caller) — catch it here\n * rather than letting `undefined` reach a request URL.\n */\nfunction resolveUrls(config: ArpcConfig): Required<ArpcUrls> {\n\tif (!isArpcEnvironment(config.environment)) {\n\t\tthrow new Error(\n\t\t\t`Unknown environment: ${config.environment} (expected one of ${Object.keys(ARPC_ENDPOINTS).join(\", \")})`,\n\t\t);\n\t}\n\tconst defaults = ARPC_ENDPOINTS[config.environment];\n\treturn {\n\t\toauth: config.urls?.oauth ?? defaults.oauth,\n\t\tgateway: config.urls?.gateway ?? defaults.gateway,\n\t};\n}\n\n/** Set the active config, resolving hosts once. Called by the `ArpcSDK` constructor. */\nexport function configure(config: ArpcConfig): void {\n\tcurrent = { ...config, urls: resolveUrls(config) };\n}\n\n/** Read the active config. Throws if the SDK hasn't been constructed yet. */\nexport function getConfig(): ResolvedArpcConfig {\n\tif (!current) {\n\t\tthrow new Error(\n\t\t\t\"ArpcSDK is not configured — construct `new ArpcSDK(config)` before making calls\",\n\t\t);\n\t}\n\treturn current;\n}\n","import ky from \"ky\";\nimport { getConfig, type TokenCache } from \"./config\";\n\n// Token lifecycle lives in the orchestration layer, not the generated client:\n// the exchange targets the OAuth host (not the gateway), uses HTTP Basic, and is\n// form-encoded. Authentication is lazy — `resolveToken()` runs from the ky\n// beforeRequest hook on the first gateway call (and again once the token goes\n// stale), so callers never manage the token by hand.\nexport interface TokenResponse {\n\taccess_token: string;\n\ttoken_type?: string;\n\texpires_in?: number;\n}\n\n// Refresh this many ms before the server's stated expiry, so a token never\n// lapses mid-flight. Applied once, when we compute the stored `expiresAt`.\nconst TOKEN_SKEW_MS = 30_000;\n// FDR tokens are ~900s; fall back to that if the response omits expires_in.\nconst DEFAULT_TTL_S = 900;\n\n/** Raw credentials → bearer JWT. No storage; `resolveToken()` owns that. */\nexport async function exchangeToken(): Promise<TokenResponse> {\n\tconst { urls, auth } = getConfig();\n\tconst basic = Buffer.from(`${auth.username}:${auth.password}`).toString(\n\t\t\"base64\",\n\t);\n\n\treturn ky\n\t\t.post(`${urls.oauth}/v1/token`, {\n\t\t\theaders: { Authorization: `Basic ${basic}` },\n\t\t\tbody: new URLSearchParams({ grant_type: \"client_credentials\" }),\n\t\t})\n\t\t.json<TokenResponse>();\n}\n\n// Default store: in-memory, per-process. Used when config omits `cache`.\nlet memToken: string | null = null;\nlet memExpiresAt = 0;\nconst defaultCache: TokenCache = {\n\tasync get() {\n\t\treturn memToken && Date.now() < memExpiresAt ? memToken : null;\n\t},\n\tasync set(token, expiresAt) {\n\t\tmemToken = token;\n\t\tmemExpiresAt = expiresAt.getTime();\n\t},\n};\n\n// Single-flight guard: a cold burst of concurrent gateway calls performs one\n// exchange, not one per call.\nlet inflight: Promise<string> | null = null;\n\n/**\n * Return a valid bearer token, exchanging + caching on a miss. Called by the\n * gateway beforeRequest hook; not part of the public surface.\n */\nexport function resolveToken(): Promise<string> {\n\tconst store = getConfig().auth.cache ?? defaultCache;\n\tif (inflight) return inflight;\n\n\tinflight = (async () => {\n\t\tconst cached = await store.get();\n\t\tif (cached) return cached;\n\t\tconst res = await exchangeToken();\n\t\tconst ttl = (res.expires_in ?? DEFAULT_TTL_S) * 1000;\n\t\tawait store.set(\n\t\t\tres.access_token,\n\t\t\tnew Date(Date.now() + ttl - TOKEN_SKEW_MS),\n\t\t);\n\t\treturn res.access_token;\n\t})().finally(() => {\n\t\tinflight = null;\n\t});\n\treturn inflight;\n}\n","import ky from \"ky\";\nimport { resolveToken } from \"../auth\";\nimport { getConfig } from \"../config\";\n\n// ---------------------------------------------------------------------------\n// Orval custom mutator (ky-backed).\n//\n// Every generated operation calls `customInstance<T>(config, options)`. We\n// route all calls to the API gateway, attach the bearer token via a\n// beforeRequest hook (lazy auth — `resolveToken()` exchanges/refreshes as\n// needed), and return a small { status, data, headers } wrapper WITHOUT\n// throwing on non-2xx — the caller inspects status codes itself (202 +\n// Retry-After on program, 400 on a UW/DRA gate, etc.).\n// ---------------------------------------------------------------------------\n\n// Shape Orval passes as the first arg (axios-style request config).\nexport interface RequestConfig {\n\turl: string;\n\tmethod: string;\n\tparams?: Record<string, unknown>;\n\tdata?: unknown;\n\theaders?: Record<string, string>;\n\tsignal?: AbortSignal;\n\tresponseType?: string;\n}\n\nexport interface HttpResponse<T> {\n\tstatus: number;\n\tdata: T;\n\theaders: Headers;\n}\n\nexport const customInstance = async <T>(\n\trequest: RequestConfig,\n\toptions?: Partial<RequestConfig>,\n): Promise<HttpResponse<T>> => {\n\tconst { url, method, params, data, signal } = { ...request, ...options };\n\t// Merge headers from both sides — a per-call override (e.g. an\n\t// x-correlation-id in `options.headers`) must not drop the operation's\n\t// Content-Type. The bearer token is layered on last, below.\n\tconst headers = { ...request.headers, ...options?.headers };\n\n\tconst target = new URL(url, getConfig().urls.gateway);\n\tif (params) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\ttarget.searchParams.set(key, String(value));\n\t\t}\n\t}\n\n\tconst response = await ky(target, {\n\t\tmethod,\n\t\theaders,\n\t\thooks: {\n\t\t\t// Lazy bearer injection: resolveToken() exchanges on the first call\n\t\t\t// and refreshes once the cached token goes stale. The OAuth exchange\n\t\t\t// itself runs on a bare ky.post (no hook), so there's no recursion.\n\t\t\tbeforeRequest: [\n\t\t\t\tasync (req) => {\n\t\t\t\t\treq.headers.set(\"Authorization\", `Bearer ${await resolveToken()}`);\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t...(data !== undefined ? { json: data } : {}),\n\t\tsignal,\n\t\tthrowHttpErrors: false,\n\t\tretry: 0,\n\t\t// Some gateway calls (program generation in particular) can take well over ky's\n\t\t// 10s default to respond. Raise the per-request ceiling; the program poll loop\n\t\t// handles 202/Retry-After on top of this.\n\t\ttimeout: 60_000,\n\t});\n\n\tconst text = await response.text();\n\tlet body: T;\n\ttry {\n\t\tbody = (text ? JSON.parse(text) : undefined) as T;\n\t} catch {\n\t\t// Non-JSON body (e.g. a gateway HTML error page on a transient 5xx). Don't throw —\n\t\t// hand back the raw text so callers can inspect status/body and retry as needed.\n\t\tbody = text as unknown as T;\n\t}\n\treturn { status: response.status, data: body, headers: response.headers };\n};\n","/**\n * Generated by orval v7.21.0 🍺\n * Do not edit manually.\n * ARPC — Achieve Resolution Partner Connect API\n * FDR Wholesale API — A Hybrid Integration Model designed to maximise partner velocity without compromising enterprise data standards. DEX (Digital Enrollment Experience) is the partner-facing integration layer that powers the full applicant lifecycle. The `fdr_applicant_id` acts as the applicant's passport across all systems, persisted from first eligibility check through enrollment. All endpoints require a valid Bearer JWT with the `arpc.all` role.\n * OpenAPI spec version: 2026.15.0\n */\nimport type {\n ARPCErrorResponse,\n ApplicationSendEmailResponse,\n BankUpdateRequest,\n CreateLeadRequest,\n CreateLeadResponse,\n DraRequest,\n DraResponse,\n EligibilityRequest,\n EligibilityResponse,\n LeadPatchRequest,\n LeadResponse,\n LeadTransferRequest,\n LeadTransferResponse,\n ProgramRequest,\n ProgramSummaryTaskRequest,\n ProgramSummaryTaskResponse,\n ReadinessResponse,\n RegisterApplicantResponse,\n RegisterApplicantV2Request,\n SpinwheelNetworkUserRequest,\n SpinwheelNetworkUserResponse,\n StatelessReadinessRequest,\n UwSubmissionV2Response\n} from './model';\n\nimport { customInstance } from '../http/client';\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n export const getARPCAchieveResolutionPartnerConnectAPI = () => {\n/**\n * Synchronous Orchestration: Handles both lead creation and income/expense data in one step, eliminating the async polling black box. Data authority shifts here — Achieve (SUIP SF) becomes the Source of Truth once the lead is formally promoted. Returns the full lead creation result including program options.\n * @summary Sync wholesale lead creation\n */\nconst createLeadSync = (\n createLeadRequest: CreateLeadRequest,\n options?: SecondParameter<typeof customInstance<CreateLeadResponse>>,) => {\n return customInstance<CreateLeadResponse>(\n {url: `/v3/application`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: createLeadRequest\n },\n options);\n }\n \n/**\n * Stateless Readiness Check: Pre-flight validation before initiating program calculations. Catches duplicate SSNs or emails early to prevent downstream failures. Requires a valid Authorization header.\n * @summary Check application readiness\n */\nconst checkApplicationReadiness = (\n statelessReadinessRequest: StatelessReadinessRequest,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/readiness`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: statelessReadinessRequest\n },\n options);\n }\n \n/**\n * Recovery endpoint — only required when the async Spinwheel user creation triggered by `POST /v1/applicant/register` fails due to a user error (e.g. invalid SSN or DOB). Not needed in the happy path. Authenticates the seller, resolves the law firm / program, creates an applicant ID when needed, and connects the applicant to the Spinwheel network. Requires a valid Authorization header.\n * @summary Create / connect Spinwheel network user\n */\nconst createSpinwheelNetworkUser = (\n spinwheelNetworkUserRequest: SpinwheelNetworkUserRequest,\n options?: SecondParameter<typeof customInstance<SpinwheelNetworkUserResponse>>,) => {\n return customInstance<SpinwheelNetworkUserResponse>(\n {url: `/v1/application/spinwheel-network-user`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: spinwheelNetworkUserRequest\n },\n options);\n }\n \n/**\n * Authenticates the seller, validates banking disclosure requirements, optionally validates the submitted account and routing numbers, patches the program, and returns the refreshed lead payload. Requires a valid Authorization header.\n * @summary Update applicant bank details\n */\nconst updateApplicationBankDetails = (\n applicantId: string,\n bankUpdateRequest: BankUpdateRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/bank-update/${applicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: bankUpdateRequest\n },\n options);\n }\n \n/**\n * Banking Disclosure: Manually triggers the banking disclosure email. **This endpoint is optional** — it is only needed when the disclosure was not already sent automatically by `POST /v2/application/uw-submission/{fdrApplicantId}` (which auto-sends on full UW approval). Use this endpoint for conditional approvals or when the v1 UW submission path is in use. A critical legal prerequisite that must be completed before enrollment can proceed. Requires a valid Authorization header.\n * @summary Send banking disclosure email (optional — only if not auto-sent by v2 UW submission)\n */\nconst sendEmail = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<ApplicationSendEmailResponse>>,) => {\n return customInstance<ApplicationSendEmailResponse>(\n {url: `/v1/application/send-email/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Submits a lead evaluation request. fdr_applicant_id is required in the request body. Requires a valid Authorization header with the arpc.all role.\n * @summary Transfer a lead to the debt-resolution program\n */\nconst leadTransfer = (\n leadTransferRequest: LeadTransferRequest,\n options?: SecondParameter<typeof customInstance<LeadTransferResponse>>,) => {\n return customInstance<LeadTransferResponse>(\n {url: `/v1/application/lead-transfer`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: leadTransferRequest\n },\n options);\n }\n \n/**\n * Fetches the current state of an application / lead record by FDR applicant ID. Requires a valid Authorization header.\n * @summary Read application / lead details\n */\nconst readLead = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'GET'\n },\n options);\n }\n \n/**\n * Applies a partial update to an existing wholesale lead record. Requires a valid Authorization header and an x-correlation-id header for request tracing.\n * @summary Partial update of application / lead record\n */\nconst patchLead = (\n fdrApplicantId: string,\n leadPatchRequest: LeadPatchRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: leadPatchRequest\n },\n options);\n }\n \n/**\n * DRA Readiness Check: Final pre-flight confirming the lead is approved and all prerequisites are met before initiating the embedded signing session. Requires a valid Authorization header.\n * @summary Get application readiness status\n */\nconst getApplicationReadiness = (\n applicantId: string,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/${applicantId}/readiness`, method: 'GET'\n },\n options);\n }\n \n/**\n * Embedded DRA Signing: Returns an Embedded Signing URL so the applicant signs the Debt Resolution Agreement via DocuSign directly within the Symple UI, preventing session breakage. Successful legal execution triggers automatic enrollment. Requires a valid Authorization header.\n * @summary Generate Debt Resolution Agreement (DRA)\n */\nconst generateDra = (\n applicantId: string,\n draRequest: DraRequest,\n options?: SecondParameter<typeof customInstance<DraResponse>>,) => {\n return customInstance<DraResponse>(\n {url: `/v2/application/${applicantId}/dra`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: draRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint.** `POST /v1/applicant/register` is deprecated and will be retired by end of July 2026 (deadline can be extended on request if your team needs more time). Identity Anchoring: Persists applicant PII to the Managed Package and generates the `fdr_applicant_id` — the applicant's passport across all systems. Routes to the correct Salesforce target (MP or WiB) based on seller identity, and triggers the async credit fetch. Requires a valid Authorization header.\n * @summary Seller-aware applicant registration (v2 — unified ARPCErrorResponse envelope) — recommended\n */\nconst registerApplicantV2 = (\n registerApplicantV2Request: RegisterApplicantV2Request,\n options?: SecondParameter<typeof customInstance<RegisterApplicantResponse>>,) => {\n return customInstance<RegisterApplicantResponse>(\n {url: `/v2/applicant/register`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: registerApplicantV2Request\n },\n options);\n }\n \n/**\n * Async Polling Loop: Call this single endpoint for both initial generation and refresh. Returns 202 Accepted with a Retry-After header while credit is still pending. Once ready, the Managed Package orchestrates the calculation and persists the program result. Requires a valid Authorization header.\n * @summary Generate application program (v1)\n */\nconst generateProgramV1 = (\n programRequest: ProgramRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programRequest\n },\n options);\n }\n \n/**\n * Eligibility Scout: A stateless, real-time quote based on anonymised data — no PII required. Returns estimated program options to anchor the conversation before any registration occurs. Requires a valid Authorization header.\n * @summary Check application eligibility\n */\nconst checkEligibility = (\n eligibilityRequest: EligibilityRequest,\n options?: SecondParameter<typeof customInstance<EligibilityResponse>>,) => {\n return customInstance<EligibilityResponse>(\n {url: `/v2/application/eligibility`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: eligibilityRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint — supersedes v1.** Submits a wholesale application to the underwriting system. On full UW approval (`sub_status = 'UW Approved'`) the banking disclosure email is sent automatically — no separate `send-email` call is needed in this path. Conditional approvals suppress the auto-send; in that case the manual `POST /v1/application/send-email/{fdrApplicantId}` endpoint can be used. Uses the SF Object API directly (no suip-proxy hop). Requires a valid Authorization header.\n * @summary Submit application to underwriting (v2 — auto banking disclosure) — recommended\n */\nconst uwSubmissionV2 = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<UwSubmissionV2Response>>,) => {\n return customInstance<UwSubmissionV2Response>(\n {url: `/v2/application/uw-submission/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Creates a SUIP Salesforce 'Program Summary Recording' task for the applicant identified by the {id} path variable. For DEX (or missing header), the parent SF opportunity is additionally PATCHed with the seller-config partner default PSC. For DC, the task is created and the parent SF opportunity is PATCHed only when ws_psc_code is provided in the request payload.\n * @summary Create program-summary recording task\n */\nconst createProgramSummaryTask = (\n id: string,\n programSummaryTaskRequest: ProgramSummaryTaskRequest,\n options?: SecondParameter<typeof customInstance<ProgramSummaryTaskResponse>>,) => {\n return customInstance<ProgramSummaryTaskResponse>(\n {url: `/v2/application/program-summary-task/${id}`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSummaryTaskRequest\n },\n options);\n }\n \nreturn {createLeadSync,checkApplicationReadiness,createSpinwheelNetworkUser,updateApplicationBankDetails,sendEmail,leadTransfer,readLead,patchLead,getApplicationReadiness,generateDra,registerApplicantV2,generateProgramV1,checkEligibility,uwSubmissionV2,createProgramSummaryTask}};\nexport type CreateLeadSyncResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createLeadSync']>>>\nexport type CheckApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkApplicationReadiness']>>>\nexport type CreateSpinwheelNetworkUserResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createSpinwheelNetworkUser']>>>\nexport type UpdateApplicationBankDetailsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['updateApplicationBankDetails']>>>\nexport type SendEmailResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['sendEmail']>>>\nexport type LeadTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['leadTransfer']>>>\nexport type ReadLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['readLead']>>>\nexport type PatchLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['patchLead']>>>\nexport type GetApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['getApplicationReadiness']>>>\nexport type GenerateDraResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateDra']>>>\nexport type RegisterApplicantV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['registerApplicantV2']>>>\nexport type GenerateProgramV1Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateProgramV1']>>>\nexport type CheckEligibilityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkEligibility']>>>\nexport type UwSubmissionV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['uwSubmissionV2']>>>\nexport type CreateProgramSummaryTaskResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createProgramSummaryTask']>>>\n","import { type ArpcConfig, configure } from \"./config\";\nimport { getARPCAchieveResolutionPartnerConnectAPI } from \"./generated/arpc\";\n\nexport type {\n\tArpcAuth,\n\tArpcConfig,\n\tArpcEndpoint,\n\tArpcEnvironment,\n\tArpcUrls,\n\tTokenCache,\n} from \"./config\";\nexport { ARPC_ENDPOINTS, isArpcEnvironment } from \"./config\";\nexport type * from \"./generated/model\";\nexport type { HttpResponse } from \"./http/client\";\n\n/**\n * ARPC SDK — a typed, agnostic client for FDR's ARPC DEX API (Achieve\n * Resolution Partner Connect, Digital Enrollment Experience).\n *\n * Thin by design: it owns the two-host routing (both derived from\n * `environment`), the OAuth token lifecycle, and bearer injection, and exposes\n * the full endpoint surface as typed operations on `sdk.api`. It does not\n * orchestrate the enrollment sequence — the caller\n * assembles payloads and threads the `fdr_applicant_id` between calls. See\n * `scripts/smoke.ts` for a full end-to-end reference sequence (incl. the program\n * poll loop).\n *\n * Auth is lazy: the first `api` call exchanges credentials for a bearer JWT and\n * caches it (~900s TTL), then re-exchanges shortly before it expires. There's no\n * explicit login step. Supply `auth.cache` to persist the token across restarts\n * or share it across workers; otherwise it's held in-process.\n *\n * Operations never throw on a non-2xx: each returns `{ status, data, headers }`,\n * so a business gate (e.g. a UW/DRA readiness failure) comes back as a normal\n * response you inspect via `status`/`data`. Only transport errors throw.\n *\n * Note: config and the default token cache are process-global — construct one\n * `ArpcSDK` per process. A second instance reconfigures the first; instances are\n * not isolated (single-tenant by design).\n *\n * @example\n * ```typescript\n * const sdk = new ArpcSDK({\n * environment: \"stg\",\n * auth: {\n * username: \"borrowbetter@seller.com\",\n * password: process.env.ARPC_OAUTH_PASSWORD!,\n * },\n * });\n *\n * // The first call authenticates automatically and caches the token.\n * const elig = await sdk.api.checkEligibility({ ... });\n * const faid = elig.data.application?.applicant?.fdr_applicant_id;\n * ```\n */\nexport class ArpcSDK {\n\t/** The full typed endpoint surface — one method per gateway operation. */\n\treadonly api = getARPCAchieveResolutionPartnerConnectAPI();\n\n\tconstructor(config: ArpcConfig) {\n\t\tconfigure(config);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/auth.ts","../src/http/client.ts","../src/generated/arpc.ts","../src/draft-type.ts","../src/index.ts"],"names":["ky"],"mappings":";;;;;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P,WAAA,EAAa;AACd;AAWO,IAAM,WAAA,GAAc,CAC1B,WAAA,KACkD;AAClD,EAAA,MAAM,QAAQ,WAAA,EAAa,UAAA;AAC3B,EAAA,OAAO,KAAA,GAAQ,eAAA,CAAgB,KAAK,CAAA,GAAI,MAAA;AACzC;;;ACRO,IAAM,UAAN,MAAc;AAAA,EAIpB,YAAY,MAAA,EAAoB;AAFhC;AAAA,IAAA,IAAA,CAAS,MAAM,yCAAA,EAA0C;AAGxD,IAAA,SAAA,CAAU,MAAM,CAAA;AAAA,EACjB;AACD","file":"index.js","sourcesContent":["/**\n * SDK configuration.\n *\n * The library never reads the environment itself — a consumer constructs\n * `new ArpcSDK(config)`, which calls `configure()`. Where that config comes\n * from (env vars, a secrets manager, a config service) is the caller's business.\n */\n/**\n * Bearer-token store. The SDK authenticates lazily on the first gateway call:\n * it asks `get()` for a still-valid token and, on `null`, exchanges credentials\n * and hands the fresh token to `set()`. Owning expiry is the cache's job —\n * `get()` returns `null` once the token is stale (or near-stale). The default\n * store is in-memory and per-process; supply one to persist across restarts or\n * share across workers.\n */\nexport interface TokenCache {\n\t/** Return a valid bearer token, or `null` if absent/expired. */\n\tget(): Promise<string | null>;\n\t/** Persist a freshly exchanged token. `expiresAt` already includes the SDK's refresh skew. */\n\tset(token: string, expiresAt: Date): Promise<void>;\n}\n\n/** FDR deployment target. Selects both hosts — see `ARPC_ENDPOINTS`. */\nexport type ArpcEnvironment = \"dev\" | \"stg\" | \"prd\";\n\n/** The host pair a single environment resolves to. */\nexport interface ArpcEndpoint {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\treadonly oauth: string;\n\t/** API gateway host — every non-auth call. */\n\treadonly gateway: string;\n}\n\n/**\n * Per-environment hosts. The two differ by domain, not just subdomain: the\n * OAuth host is `ffngcp.com`, the gateway is `fdrgcp.com`.\n *\n * Frozen: this table backs both host resolution and environment validation, so\n * a consumer mutating it would quietly change SDK behavior.\n */\nexport const ARPC_ENDPOINTS: Readonly<Record<ArpcEnvironment, ArpcEndpoint>> =\n\tObject.freeze({\n\t\tdev: Object.freeze({\n\t\t\toauth: \"https://oauth.dev.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.dev.fdrgcp.com\",\n\t\t}),\n\t\tstg: Object.freeze({\n\t\t\toauth: \"https://oauth.stg.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.stg.fdrgcp.com\",\n\t\t}),\n\t\tprd: Object.freeze({\n\t\t\toauth: \"https://oauth.prd.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.prd.fdrgcp.com\",\n\t\t}),\n\t});\n\n/**\n * Narrow a raw string to an `ArpcEnvironment`. Useful when the value arrives\n * untyped — an env var, a JSON config file, a request payload.\n */\nexport function isArpcEnvironment(value: string): value is ArpcEnvironment {\n\t// Own keys only — `in` would also match inherited members like `toString`.\n\treturn Object.keys(ARPC_ENDPOINTS).includes(value);\n}\n\nexport interface ArpcAuth {\n\t/**\n\t * OAuth client_id (HTTP Basic username). Also used as the lead's\n\t * `seller_agent_email` — the OAuth identity is a registered DRA agent.\n\t */\n\tusername: string;\n\t/** OAuth client_secret (HTTP Basic password). */\n\tpassword: string;\n\t/** Bearer-token store. Defaults to an in-memory, per-process cache. */\n\tcache?: TokenCache;\n}\n\n/**\n * Escape hatch — per-host overrides of the `environment` defaults. Omit a key\n * (or leave it `undefined`) to keep that environment's host.\n */\nexport interface ArpcUrls {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\toauth?: string;\n\t/** API gateway host — every non-auth call. */\n\tgateway?: string;\n}\n\nexport interface ArpcConfig {\n\t/** Selects the FDR environment. Drives both hosts. */\n\tenvironment: ArpcEnvironment;\n\tauth: ArpcAuth;\n\turls?: ArpcUrls;\n}\n\n/** Config as the internals consume it — hosts resolved to concrete strings. */\nexport interface ResolvedArpcConfig extends ArpcConfig {\n\turls: Required<ArpcUrls>;\n}\n\nlet current: ResolvedArpcConfig | null = null;\n\n/**\n * Fold the environment defaults together with any caller overrides. The guard\n * looks unreachable given the types, but `environment` routinely arrives from\n * somewhere untyped (an env var, a JSON config, a JS caller) — catch it here\n * rather than letting `undefined` reach a request URL.\n */\nfunction resolveUrls(config: ArpcConfig): Required<ArpcUrls> {\n\tif (!isArpcEnvironment(config.environment)) {\n\t\tthrow new Error(\n\t\t\t`Unknown environment: ${config.environment} (expected one of ${Object.keys(ARPC_ENDPOINTS).join(\", \")})`,\n\t\t);\n\t}\n\tconst defaults = ARPC_ENDPOINTS[config.environment];\n\treturn {\n\t\toauth: config.urls?.oauth ?? defaults.oauth,\n\t\tgateway: config.urls?.gateway ?? defaults.gateway,\n\t};\n}\n\n/** Set the active config, resolving hosts once. Called by the `ArpcSDK` constructor. */\nexport function configure(config: ArpcConfig): void {\n\tcurrent = { ...config, urls: resolveUrls(config) };\n}\n\n/** Read the active config. Throws if the SDK hasn't been constructed yet. */\nexport function getConfig(): ResolvedArpcConfig {\n\tif (!current) {\n\t\tthrow new Error(\n\t\t\t\"ArpcSDK is not configured — construct `new ArpcSDK(config)` before making calls\",\n\t\t);\n\t}\n\treturn current;\n}\n","import ky from \"ky\";\nimport { getConfig, type TokenCache } from \"./config\";\n\n// Token lifecycle lives in the orchestration layer, not the generated client:\n// the exchange targets the OAuth host (not the gateway), uses HTTP Basic, and is\n// form-encoded. Authentication is lazy — `resolveToken()` runs from the ky\n// beforeRequest hook on the first gateway call (and again once the token goes\n// stale), so callers never manage the token by hand.\nexport interface TokenResponse {\n\taccess_token: string;\n\ttoken_type?: string;\n\texpires_in?: number;\n}\n\n// Refresh this many ms before the server's stated expiry, so a token never\n// lapses mid-flight. Applied once, when we compute the stored `expiresAt`.\nconst TOKEN_SKEW_MS = 30_000;\n// FDR tokens are ~900s; fall back to that if the response omits expires_in.\nconst DEFAULT_TTL_S = 900;\n\n/** Raw credentials → bearer JWT. No storage; `resolveToken()` owns that. */\nexport async function exchangeToken(): Promise<TokenResponse> {\n\tconst { urls, auth } = getConfig();\n\tconst basic = Buffer.from(`${auth.username}:${auth.password}`).toString(\n\t\t\"base64\",\n\t);\n\n\treturn ky\n\t\t.post(`${urls.oauth}/v1/token`, {\n\t\t\theaders: { Authorization: `Basic ${basic}` },\n\t\t\tbody: new URLSearchParams({ grant_type: \"client_credentials\" }),\n\t\t})\n\t\t.json<TokenResponse>();\n}\n\n// Default store: in-memory, per-process. Used when config omits `cache`.\nlet memToken: string | null = null;\nlet memExpiresAt = 0;\nconst defaultCache: TokenCache = {\n\tasync get() {\n\t\treturn memToken && Date.now() < memExpiresAt ? memToken : null;\n\t},\n\tasync set(token, expiresAt) {\n\t\tmemToken = token;\n\t\tmemExpiresAt = expiresAt.getTime();\n\t},\n};\n\n// Single-flight guard: a cold burst of concurrent gateway calls performs one\n// exchange, not one per call.\nlet inflight: Promise<string> | null = null;\n\n/**\n * Return a valid bearer token, exchanging + caching on a miss. Called by the\n * gateway beforeRequest hook; not part of the public surface.\n */\nexport function resolveToken(): Promise<string> {\n\tconst store = getConfig().auth.cache ?? defaultCache;\n\tif (inflight) return inflight;\n\n\tinflight = (async () => {\n\t\tconst cached = await store.get();\n\t\tif (cached) return cached;\n\t\tconst res = await exchangeToken();\n\t\tconst ttl = (res.expires_in ?? DEFAULT_TTL_S) * 1000;\n\t\tawait store.set(\n\t\t\tres.access_token,\n\t\t\tnew Date(Date.now() + ttl - TOKEN_SKEW_MS),\n\t\t);\n\t\treturn res.access_token;\n\t})().finally(() => {\n\t\tinflight = null;\n\t});\n\treturn inflight;\n}\n","import ky from \"ky\";\nimport { resolveToken } from \"../auth\";\nimport { getConfig } from \"../config\";\n\n// ---------------------------------------------------------------------------\n// Orval custom mutator (ky-backed).\n//\n// Every generated operation calls `customInstance<T>(config, options)`. We\n// route all calls to the API gateway, attach the bearer token via a\n// beforeRequest hook (lazy auth — `resolveToken()` exchanges/refreshes as\n// needed), and return a small { status, data, headers } wrapper WITHOUT\n// throwing on non-2xx — the caller inspects status codes itself (202 +\n// Retry-After on program, 400 on a UW/DRA gate, etc.).\n// ---------------------------------------------------------------------------\n\n// Shape Orval passes as the first arg (axios-style request config).\nexport interface RequestConfig {\n\turl: string;\n\tmethod: string;\n\tparams?: Record<string, unknown>;\n\tdata?: unknown;\n\theaders?: Record<string, string>;\n\tsignal?: AbortSignal;\n\tresponseType?: string;\n}\n\nexport interface HttpResponse<T> {\n\tstatus: number;\n\tdata: T;\n\theaders: Headers;\n}\n\nexport const customInstance = async <T>(\n\trequest: RequestConfig,\n\toptions?: Partial<RequestConfig>,\n): Promise<HttpResponse<T>> => {\n\tconst { url, method, params, data, signal } = { ...request, ...options };\n\t// Merge headers from both sides — a per-call override (e.g. an\n\t// x-correlation-id in `options.headers`) must not drop the operation's\n\t// Content-Type. The bearer token is layered on last, below.\n\tconst headers = { ...request.headers, ...options?.headers };\n\n\tconst target = new URL(url, getConfig().urls.gateway);\n\tif (params) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\ttarget.searchParams.set(key, String(value));\n\t\t}\n\t}\n\n\tconst response = await ky(target, {\n\t\tmethod,\n\t\theaders,\n\t\thooks: {\n\t\t\t// Lazy bearer injection: resolveToken() exchanges on the first call\n\t\t\t// and refreshes once the cached token goes stale. The OAuth exchange\n\t\t\t// itself runs on a bare ky.post (no hook), so there's no recursion.\n\t\t\tbeforeRequest: [\n\t\t\t\tasync (req) => {\n\t\t\t\t\treq.headers.set(\"Authorization\", `Bearer ${await resolveToken()}`);\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t...(data !== undefined ? { json: data } : {}),\n\t\tsignal,\n\t\tthrowHttpErrors: false,\n\t\tretry: 0,\n\t\t// Some gateway calls (program generation in particular) can take well over ky's\n\t\t// 10s default to respond. Raise the per-request ceiling; the program poll loop\n\t\t// handles 202/Retry-After on top of this.\n\t\ttimeout: 60_000,\n\t});\n\n\tconst text = await response.text();\n\tlet body: T;\n\ttry {\n\t\tbody = (text ? JSON.parse(text) : undefined) as T;\n\t} catch {\n\t\t// Non-JSON body (e.g. a gateway HTML error page on a transient 5xx). Don't throw —\n\t\t// hand back the raw text so callers can inspect status/body and retry as needed.\n\t\tbody = text as unknown as T;\n\t}\n\treturn { status: response.status, data: body, headers: response.headers };\n};\n","/**\n * Generated by orval v7.21.0 🍺\n * Do not edit manually.\n * ARPC — Achieve Resolution Partner Connect API\n * FDR Wholesale API — A Hybrid Integration Model designed to maximise partner velocity without compromising enterprise data standards. DEX (Digital Enrollment Experience) is the partner-facing integration layer that powers the full applicant lifecycle. The `fdr_applicant_id` acts as the applicant's passport across all systems, persisted from first eligibility check through enrollment. All endpoints require a valid Bearer JWT with the `arpc.all` role.\n\n**Published:** 2026-08-18\n * OpenAPI spec version: 2026.16.1\n */\nimport type {\n ARPCErrorResponse,\n ApplicationSendEmailResponse,\n BankUpdateRequest,\n CreateLeadRequest,\n CreateLeadResponse,\n DraRequest,\n DraResponse,\n EligibilityRequest,\n EligibilityResponse,\n LeadPatchRequest,\n LeadResponse,\n LeadTransferRequest,\n LeadTransferResponse,\n ProgramRequest,\n ProgramSelectionRequest,\n ProgramSummaryTaskRequest,\n ProgramSummaryTaskResponse,\n ReadinessResponse,\n RegisterApplicantV2Request,\n RegisterApplicantV2Response,\n SpinwheelNetworkUserRequest,\n SpinwheelNetworkUserResponse,\n StatelessReadinessRequest,\n UwSubmissionV2Response\n} from './model';\n\nimport { customInstance } from '../http/client';\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n export const getARPCAchieveResolutionPartnerConnectAPI = () => {\n/**\n * Synchronous Orchestration: Handles both lead creation and income/expense data in one step, eliminating the async polling black box. Data authority shifts here — Achieve becomes the Source of Truth once the lead is formally promoted. Returns the full lead creation result including program options.\n * @summary Sync wholesale lead creation\n */\nconst createLeadSync = (\n createLeadRequest: CreateLeadRequest,\n options?: SecondParameter<typeof customInstance<CreateLeadResponse>>,) => {\n return customInstance<CreateLeadResponse>(\n {url: `/v3/application`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: createLeadRequest\n },\n options);\n }\n \n/**\n * Gateway-level endpoint: selects a payment schedule for an existing lead and persists the program offer. After calling generateProgram, choose a schedule from payment_schedule_options and submit its draft_type and estimated_monthly_payment here. The gateway injects request attributes and forwards internally to POST /v3/application/program. Requires a valid Authorization header.\n * @summary Select program schedule for an existing lead\n */\nconst selectProgram = (\n programSelectionRequest: ProgramSelectionRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program-selection`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSelectionRequest\n },\n options);\n }\n \n/**\n * Stateless Readiness Check: Pre-flight validation before initiating program calculations. Catches duplicate SSNs or emails early to prevent downstream failures. Requires a valid Authorization header.\n * @summary Check application readiness\n */\nconst checkApplicationReadiness = (\n statelessReadinessRequest: StatelessReadinessRequest,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/readiness`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: statelessReadinessRequest\n },\n options);\n }\n \n/**\n * Recovery endpoint — only required when the async Spinwheel user creation triggered by `POST /v1/applicant/register` fails due to a user error (e.g. invalid SSN or DOB). Not needed in the happy path. Authenticates the seller, resolves the law firm / program, creates an applicant ID when needed, and connects the applicant to the Spinwheel network. Requires a valid Authorization header.\n * @summary Create / connect Spinwheel network user\n */\nconst createSpinwheelNetworkUser = (\n spinwheelNetworkUserRequest: SpinwheelNetworkUserRequest,\n options?: SecondParameter<typeof customInstance<SpinwheelNetworkUserResponse>>,) => {\n return customInstance<SpinwheelNetworkUserResponse>(\n {url: `/v1/application/spinwheel-network-user`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: spinwheelNetworkUserRequest\n },\n options);\n }\n \n/**\n * Authenticates the seller, validates banking disclosure requirements, optionally validates the submitted account and routing numbers, patches the program, and returns the refreshed lead payload. Requires a valid Authorization header.\n * @summary Update applicant bank details\n */\nconst updateApplicationBankDetails = (\n applicantId: string,\n bankUpdateRequest: BankUpdateRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/bank-update/${applicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: bankUpdateRequest\n },\n options);\n }\n \n/**\n * Banking Disclosure: Manually triggers the banking disclosure email. **This endpoint is optional** — it is only needed when the disclosure was not already sent automatically by `POST /v2/application/uw-submission/{fdrApplicantId}` (which auto-sends on full UW approval). Use this endpoint for conditional approvals or when the v1 UW submission path is in use. A critical legal prerequisite that must be completed before enrollment can proceed. Requires a valid Authorization header.\n * @summary Send banking disclosure email (optional — only if not auto-sent by v2 UW submission)\n */\nconst sendEmail = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<ApplicationSendEmailResponse>>,) => {\n return customInstance<ApplicationSendEmailResponse>(\n {url: `/v1/application/send-email/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Submits a lead evaluation request. fdr_applicant_id is required in the request body. Requires a valid Authorization header with the arpc.all role.\n * @summary Transfer a lead to the debt-resolution program\n */\nconst leadTransfer = (\n leadTransferRequest: LeadTransferRequest,\n options?: SecondParameter<typeof customInstance<LeadTransferResponse>>,) => {\n return customInstance<LeadTransferResponse>(\n {url: `/v1/application/lead-transfer`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: leadTransferRequest\n },\n options);\n }\n \n/**\n * Fetches the current state of an application / lead record by FDR applicant ID. Requires a valid Authorization header.\n * @summary Read application / lead details\n */\nconst readLead = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'GET'\n },\n options);\n }\n \n/**\n * Applies a partial update to an existing wholesale lead record. Requires a valid Authorization header and an x-correlation-id header for request tracing. For split drafts, update second_draft_date_split after UW submission and before generating the DRA; the bi-weekly second_draft_date_bi_weekly field is populated automatically during UW approval.\n * @summary Partial update of application / lead record\n */\nconst patchLead = (\n fdrApplicantId: string,\n leadPatchRequest: LeadPatchRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: leadPatchRequest\n },\n options);\n }\n \n/**\n * DRA Readiness Check: Final pre-flight confirming the lead is approved and all prerequisites are met before initiating the embedded signing session. Requires a valid Authorization header.\n * @summary Get application readiness status\n */\nconst getApplicationReadiness = (\n applicantId: string,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/${applicantId}/readiness`, method: 'GET'\n },\n options);\n }\n \n/**\n * Embedded DRA Signing: Returns an Embedded Signing URL so the applicant signs the Debt Resolution Agreement via DocuSign directly within the Symple UI, preventing session breakage. Successful legal execution triggers automatic enrollment. Requires a valid Authorization header.\n * @summary Generate Debt Resolution Agreement (DRA)\n */\nconst generateDra = (\n applicantId: string,\n draRequest: DraRequest,\n options?: SecondParameter<typeof customInstance<DraResponse>>,) => {\n return customInstance<DraResponse>(\n {url: `/v2/application/${applicantId}/dra`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: draRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint.** `POST /v1/applicant/register` is deprecated and will be retired by end of July 2026 (deadline can be extended on request if your team needs more time). Identity Anchoring: Persists applicant PII to Achieve's managed partner CRM and generates the `fdr_applicant_id` — the applicant's passport across all systems. Routes to the correct target system based on seller identity, and triggers the async credit fetch. Requires a valid Authorization header.\n * @summary Seller-aware applicant registration (v2 — unified ARPCErrorResponse envelope) — recommended\n */\nconst registerApplicantV2 = (\n registerApplicantV2Request: RegisterApplicantV2Request,\n options?: SecondParameter<typeof customInstance<RegisterApplicantV2Response>>,) => {\n return customInstance<RegisterApplicantV2Response>(\n {url: `/v2/applicant/register`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: registerApplicantV2Request\n },\n options);\n }\n \n/**\n * Async Polling Loop: Call this single endpoint for both initial generation and refresh. Returns 202 Accepted with a Retry-After header while credit is still pending. Once ready, the Managed Package orchestrates the calculation and persists the program result. Requires a valid Authorization header.\n * @summary Generate application program (v1)\n */\nconst generateProgramV1 = (\n programRequest: ProgramRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programRequest\n },\n options);\n }\n \n/**\n * Eligibility Scout: Two operational modes — (1) no PII required: state-based quote using provided debt accounts; (2) credit pull: full applicant PII for a live soft credit report. Returns estimated program options to anchor the conversation before any registration occurs. Requires a valid Authorization header.\n * @summary Check application eligibility\n */\nconst checkEligibility = (\n eligibilityRequest: EligibilityRequest,\n options?: SecondParameter<typeof customInstance<EligibilityResponse>>,) => {\n return customInstance<EligibilityResponse>(\n {url: `/v2/application/eligibility`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: eligibilityRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint — supersedes v1.** Submits a wholesale application to the underwriting system. On full UW approval (`sub_status = 'UW Approved'`) the banking disclosure email is sent automatically — no separate `send-email` call is needed in this path. Conditional approvals suppress the auto-send; in that case the manual `POST /v1/application/send-email/{fdrApplicantId}` endpoint can be used. Uses the SF Object API directly (no suip-proxy hop). Requires a valid Authorization header.\n * @summary Submit application to underwriting (v2 — auto banking disclosure) — recommended\n */\nconst uwSubmissionV2 = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<UwSubmissionV2Response>>,) => {\n return customInstance<UwSubmissionV2Response>(\n {url: `/v2/application/uw-submission/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Creates a SUIP Salesforce 'Program Summary Recording' task for the applicant identified by the {id} path variable. For DEX (or missing header), the parent SF opportunity is additionally PATCHed with the seller-config partner default PSC. For DC, the task is created and the parent SF opportunity is PATCHed only when ws_psc_code is provided in the request payload.\n * @summary Create program-summary recording task\n */\nconst createProgramSummaryTask = (\n id: string,\n programSummaryTaskRequest: ProgramSummaryTaskRequest,\n options?: SecondParameter<typeof customInstance<ProgramSummaryTaskResponse>>,) => {\n return customInstance<ProgramSummaryTaskResponse>(\n {url: `/v2/application/program-summary-task/${id}`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSummaryTaskRequest\n },\n options);\n }\n \nreturn {createLeadSync,selectProgram,checkApplicationReadiness,createSpinwheelNetworkUser,updateApplicationBankDetails,sendEmail,leadTransfer,readLead,patchLead,getApplicationReadiness,generateDra,registerApplicantV2,generateProgramV1,checkEligibility,uwSubmissionV2,createProgramSummaryTask}};\nexport type CreateLeadSyncResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createLeadSync']>>>\nexport type SelectProgramResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['selectProgram']>>>\nexport type CheckApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkApplicationReadiness']>>>\nexport type CreateSpinwheelNetworkUserResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createSpinwheelNetworkUser']>>>\nexport type UpdateApplicationBankDetailsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['updateApplicationBankDetails']>>>\nexport type SendEmailResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['sendEmail']>>>\nexport type LeadTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['leadTransfer']>>>\nexport type ReadLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['readLead']>>>\nexport type PatchLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['patchLead']>>>\nexport type GetApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['getApplicationReadiness']>>>\nexport type GenerateDraResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateDra']>>>\nexport type RegisterApplicantV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['registerApplicantV2']>>>\nexport type GenerateProgramV1Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateProgramV1']>>>\nexport type CheckEligibilityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkEligibility']>>>\nexport type UwSubmissionV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['uwSubmissionV2']>>>\nexport type CreateProgramSummaryTaskResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createProgramSummaryTask']>>>\n","import type {\n\tLeadApplication,\n\tLeadApplicationDraftType,\n\tProgramSelectionRequestDraftType,\n} from \"./generated/model\";\n\n/**\n * FDR's API speaks two vocabularies for the same value. You *send* a lowercase\n * schedule code (`bi-weekly`) to `selectProgram`; the lead *reports* a\n * capitalised label (`Bi-Weekly`) back on `application.draft_type`. Nothing in\n * the spec connects them, and the mismatch is silent — comparing what you sent\n * against what came back always looks like a failure.\n *\n * The labels below were confirmed against live STG by selecting each draft type\n * in turn. Through 2026.16.0 the spec documented `Monthly [Regular]` and\n * `Twice Monthly [Split]` for two of them and the API returned neither; 16.1\n * corrected the response enum, so the generated types now agree with the wire.\n * The two *vocabularies* remain — a corrected enum is not a unified one.\n *\n * Scope is narrow: `LeadApplication.draft_type` is the only label-valued site\n * in the whole spec. `PaymentSchedule` and `ProgramSelectionRequest` are both\n * already lowercase, and `LeadPatchRequest` has no `draft_type` at all, so\n * `selectProgram` is the only write path.\n *\n * These maps are annotated as `Record<>` over the generated enums on purpose:\n * if FDR ever adds a fourth draft type, codegen widens the enum and these fail\n * to compile until someone fills in the new key. The mapping keeps itself\n * honest without any bespoke assertion.\n */\n\n/** Schedule code → the label the lead reports back. */\nexport const DRAFT_TYPE_LABEL: Record<\n\tProgramSelectionRequestDraftType,\n\tLeadApplicationDraftType\n> = {\n\tregular: \"Regular\",\n\tsplit: \"Split\",\n\t\"bi-weekly\": \"Bi-Weekly\",\n};\n\n/** Lead-reported label → the schedule code `selectProgram` accepts. */\nexport const DRAFT_TYPE_CODE: Record<\n\tLeadApplicationDraftType,\n\tProgramSelectionRequestDraftType\n> = {\n\tRegular: \"regular\",\n\tSplit: \"split\",\n\t\"Bi-Weekly\": \"bi-weekly\",\n};\n\n/**\n * Read a lead's current draft type as a value you can hand straight back to\n * `selectProgram` — closing the round-trip FDR's two vocabularies leave open.\n *\n * Returns `undefined` when the lead has no selection yet, and also when the\n * label isn't one we know: the server can start returning a new picklist value\n * before we've regenerated against a newer spec, and guessing would be worse\n * than admitting we don't recognise it.\n */\nexport const draftTypeOf = (\n\tapplication: LeadApplication | undefined | null,\n): ProgramSelectionRequestDraftType | undefined => {\n\tconst label = application?.draft_type;\n\treturn label ? DRAFT_TYPE_CODE[label] : undefined;\n};\n","import { type ArpcConfig, configure } from \"./config\";\nimport { getARPCAchieveResolutionPartnerConnectAPI } from \"./generated/arpc\";\n\nexport type {\n\tArpcAuth,\n\tArpcConfig,\n\tArpcEndpoint,\n\tArpcEnvironment,\n\tArpcUrls,\n\tTokenCache,\n} from \"./config\";\nexport { ARPC_ENDPOINTS, isArpcEnvironment } from \"./config\";\nexport { DRAFT_TYPE_CODE, DRAFT_TYPE_LABEL, draftTypeOf } from \"./draft-type\";\nexport type * from \"./generated/model\";\nexport type { HttpResponse } from \"./http/client\";\n\n/**\n * ARPC SDK — a typed, agnostic client for FDR's ARPC DEX API (Achieve\n * Resolution Partner Connect, Digital Enrollment Experience).\n *\n * Thin by design: it owns the two-host routing (both derived from\n * `environment`), the OAuth token lifecycle, and bearer injection, and exposes\n * the full endpoint surface as typed operations on `sdk.api`. It does not\n * orchestrate the enrollment sequence — the caller\n * assembles payloads and threads the `fdr_applicant_id` between calls. See\n * `scripts/smoke.ts` for a full end-to-end reference sequence (incl. the program\n * poll loop).\n *\n * Auth is lazy: the first `api` call exchanges credentials for a bearer JWT and\n * caches it (~900s TTL), then re-exchanges shortly before it expires. There's no\n * explicit login step. Supply `auth.cache` to persist the token across restarts\n * or share it across workers; otherwise it's held in-process.\n *\n * Operations never throw on a non-2xx: each returns `{ status, data, headers }`,\n * so a business gate (e.g. a UW/DRA readiness failure) comes back as a normal\n * response you inspect via `status`/`data`. Only transport errors throw.\n *\n * Note: config and the default token cache are process-global — construct one\n * `ArpcSDK` per process. A second instance reconfigures the first; instances are\n * not isolated (single-tenant by design).\n *\n * @example\n * ```typescript\n * const sdk = new ArpcSDK({\n * environment: \"stg\",\n * auth: {\n * username: \"borrowbetter@seller.com\",\n * password: process.env.ARPC_OAUTH_PASSWORD!,\n * },\n * });\n *\n * // The first call authenticates automatically and caches the token.\n * const elig = await sdk.api.checkEligibility({ ... });\n * const faid = elig.data.application?.applicant?.fdr_applicant_id;\n * ```\n */\nexport class ArpcSDK {\n\t/** The full typed endpoint surface — one method per gateway operation. */\n\treadonly api = getARPCAchieveResolutionPartnerConnectAPI();\n\n\tconstructor(config: ArpcConfig) {\n\t\tconfigure(config);\n\t}\n}\n"]}
package/dist/index.mjs CHANGED
@@ -141,6 +141,17 @@ var getARPCAchieveResolutionPartnerConnectAPI = () => {
141
141
  options
142
142
  );
143
143
  };
144
+ const selectProgram = (programSelectionRequest, options) => {
145
+ return customInstance(
146
+ {
147
+ url: `/v1/application/program-selection`,
148
+ method: "POST",
149
+ headers: { "Content-Type": "application/json" },
150
+ data: programSelectionRequest
151
+ },
152
+ options
153
+ );
154
+ };
144
155
  const checkApplicationReadiness = (statelessReadinessRequest, options) => {
145
156
  return customInstance(
146
157
  {
@@ -287,7 +298,23 @@ var getARPCAchieveResolutionPartnerConnectAPI = () => {
287
298
  options
288
299
  );
289
300
  };
290
- return { createLeadSync, checkApplicationReadiness, createSpinwheelNetworkUser, updateApplicationBankDetails, sendEmail, leadTransfer, readLead, patchLead, getApplicationReadiness, generateDra, registerApplicantV2, generateProgramV1, checkEligibility, uwSubmissionV2, createProgramSummaryTask };
301
+ return { createLeadSync, selectProgram, checkApplicationReadiness, createSpinwheelNetworkUser, updateApplicationBankDetails, sendEmail, leadTransfer, readLead, patchLead, getApplicationReadiness, generateDra, registerApplicantV2, generateProgramV1, checkEligibility, uwSubmissionV2, createProgramSummaryTask };
302
+ };
303
+
304
+ // src/draft-type.ts
305
+ var DRAFT_TYPE_LABEL = {
306
+ regular: "Regular",
307
+ split: "Split",
308
+ "bi-weekly": "Bi-Weekly"
309
+ };
310
+ var DRAFT_TYPE_CODE = {
311
+ Regular: "regular",
312
+ Split: "split",
313
+ "Bi-Weekly": "bi-weekly"
314
+ };
315
+ var draftTypeOf = (application) => {
316
+ const label = application?.draft_type;
317
+ return label ? DRAFT_TYPE_CODE[label] : void 0;
291
318
  };
292
319
 
293
320
  // src/index.ts
@@ -299,6 +326,6 @@ var ArpcSDK = class {
299
326
  }
300
327
  };
301
328
 
302
- export { ARPC_ENDPOINTS, ArpcSDK, isArpcEnvironment };
329
+ export { ARPC_ENDPOINTS, ArpcSDK, DRAFT_TYPE_CODE, DRAFT_TYPE_LABEL, draftTypeOf, isArpcEnvironment };
303
330
  //# sourceMappingURL=index.mjs.map
304
331
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/auth.ts","../src/http/client.ts","../src/generated/arpc.ts","../src/index.ts"],"names":["ky"],"mappings":";;;AAwCO,IAAM,cAAA,GACZ,OAAO,MAAA,CAAO;AAAA,EACb,GAA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CAAA,CAAA;AAAA,QAAI,MAAA,EAAQ;AAAA,OACnE;AAAA,MACE;AAAA,KAAO;AAAA,EACT,CAAA;AAMJ,EAAA,MAAM,wBAAA,GAA2B,CAC7B,EAAA,EACA,yBAAA,EACH,OAAA,KAAkF;AAC7E,IAAA,OAAO,cAAA;AAAA,MACP;AAAA,QAAC,GAAA,EAAK,wCAAwC,EAAE,CAAA,CAAA;AAAA,QAAI,MAAA,EAAQ,MAAA;AAAA,QAC5D,OAAA,EAAS,EAAC,cAAA,EAAgB,kBAAA,EAAoB;AAAA,QAC9C,IAAA,EAAM;AAAA,OACR;AAAA,MACE;AAAA,KAAO;AAAA,EACT,CAAA;AAEJ,EAAA,OAAO,EAAC,cAAA,EAAe,yBAAA,EAA0B,0BAAA,EAA2B,8BAA6B,SAAA,EAAU,YAAA,EAAa,QAAA,EAAS,SAAA,EAAU,yBAAwB,WAAA,EAAY,mBAAA,EAAoB,iBAAA,EAAkB,gBAAA,EAAiB,gBAAe,wBAAA,EAAwB;AAAC,CAAA;;;AC5M/Q,IAAM,UAAN,MAAc;AAAA,EAIpB,YAAY,MAAA,EAAoB;AAFhC;AAAA,IAAA,IAAA,CAAS,MAAM,yCAAA,EAA0C;AAGxD,IAAA,SAAA,CAAU,MAAM,CAAA;AAAA,EACjB;AACD","file":"index.mjs","sourcesContent":["/**\n * SDK configuration.\n *\n * The library never reads the environment itself — a consumer constructs\n * `new ArpcSDK(config)`, which calls `configure()`. Where that config comes\n * from (env vars, a secrets manager, a config service) is the caller's business.\n */\n/**\n * Bearer-token store. The SDK authenticates lazily on the first gateway call:\n * it asks `get()` for a still-valid token and, on `null`, exchanges credentials\n * and hands the fresh token to `set()`. Owning expiry is the cache's job —\n * `get()` returns `null` once the token is stale (or near-stale). The default\n * store is in-memory and per-process; supply one to persist across restarts or\n * share across workers.\n */\nexport interface TokenCache {\n\t/** Return a valid bearer token, or `null` if absent/expired. */\n\tget(): Promise<string | null>;\n\t/** Persist a freshly exchanged token. `expiresAt` already includes the SDK's refresh skew. */\n\tset(token: string, expiresAt: Date): Promise<void>;\n}\n\n/** FDR deployment target. Selects both hosts — see `ARPC_ENDPOINTS`. */\nexport type ArpcEnvironment = \"dev\" | \"stg\" | \"prd\";\n\n/** The host pair a single environment resolves to. */\nexport interface ArpcEndpoint {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\treadonly oauth: string;\n\t/** API gateway host — every non-auth call. */\n\treadonly gateway: string;\n}\n\n/**\n * Per-environment hosts. The two differ by domain, not just subdomain: the\n * OAuth host is `ffngcp.com`, the gateway is `fdrgcp.com`.\n *\n * Frozen: this table backs both host resolution and environment validation, so\n * a consumer mutating it would quietly change SDK behavior.\n */\nexport const ARPC_ENDPOINTS: Readonly<Record<ArpcEnvironment, ArpcEndpoint>> =\n\tObject.freeze({\n\t\tdev: Object.freeze({\n\t\t\toauth: \"https://oauth.dev.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.dev.fdrgcp.com\",\n\t\t}),\n\t\tstg: Object.freeze({\n\t\t\toauth: \"https://oauth.stg.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.stg.fdrgcp.com\",\n\t\t}),\n\t\tprd: Object.freeze({\n\t\t\toauth: \"https://oauth.prd.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.prd.fdrgcp.com\",\n\t\t}),\n\t});\n\n/**\n * Narrow a raw string to an `ArpcEnvironment`. Useful when the value arrives\n * untyped — an env var, a JSON config file, a request payload.\n */\nexport function isArpcEnvironment(value: string): value is ArpcEnvironment {\n\t// Own keys only — `in` would also match inherited members like `toString`.\n\treturn Object.keys(ARPC_ENDPOINTS).includes(value);\n}\n\nexport interface ArpcAuth {\n\t/**\n\t * OAuth client_id (HTTP Basic username). Also used as the lead's\n\t * `seller_agent_email` — the OAuth identity is a registered DRA agent.\n\t */\n\tusername: string;\n\t/** OAuth client_secret (HTTP Basic password). */\n\tpassword: string;\n\t/** Bearer-token store. Defaults to an in-memory, per-process cache. */\n\tcache?: TokenCache;\n}\n\n/**\n * Escape hatch — per-host overrides of the `environment` defaults. Omit a key\n * (or leave it `undefined`) to keep that environment's host.\n */\nexport interface ArpcUrls {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\toauth?: string;\n\t/** API gateway host — every non-auth call. */\n\tgateway?: string;\n}\n\nexport interface ArpcConfig {\n\t/** Selects the FDR environment. Drives both hosts. */\n\tenvironment: ArpcEnvironment;\n\tauth: ArpcAuth;\n\turls?: ArpcUrls;\n}\n\n/** Config as the internals consume it — hosts resolved to concrete strings. */\nexport interface ResolvedArpcConfig extends ArpcConfig {\n\turls: Required<ArpcUrls>;\n}\n\nlet current: ResolvedArpcConfig | null = null;\n\n/**\n * Fold the environment defaults together with any caller overrides. The guard\n * looks unreachable given the types, but `environment` routinely arrives from\n * somewhere untyped (an env var, a JSON config, a JS caller) — catch it here\n * rather than letting `undefined` reach a request URL.\n */\nfunction resolveUrls(config: ArpcConfig): Required<ArpcUrls> {\n\tif (!isArpcEnvironment(config.environment)) {\n\t\tthrow new Error(\n\t\t\t`Unknown environment: ${config.environment} (expected one of ${Object.keys(ARPC_ENDPOINTS).join(\", \")})`,\n\t\t);\n\t}\n\tconst defaults = ARPC_ENDPOINTS[config.environment];\n\treturn {\n\t\toauth: config.urls?.oauth ?? defaults.oauth,\n\t\tgateway: config.urls?.gateway ?? defaults.gateway,\n\t};\n}\n\n/** Set the active config, resolving hosts once. Called by the `ArpcSDK` constructor. */\nexport function configure(config: ArpcConfig): void {\n\tcurrent = { ...config, urls: resolveUrls(config) };\n}\n\n/** Read the active config. Throws if the SDK hasn't been constructed yet. */\nexport function getConfig(): ResolvedArpcConfig {\n\tif (!current) {\n\t\tthrow new Error(\n\t\t\t\"ArpcSDK is not configured — construct `new ArpcSDK(config)` before making calls\",\n\t\t);\n\t}\n\treturn current;\n}\n","import ky from \"ky\";\nimport { getConfig, type TokenCache } from \"./config\";\n\n// Token lifecycle lives in the orchestration layer, not the generated client:\n// the exchange targets the OAuth host (not the gateway), uses HTTP Basic, and is\n// form-encoded. Authentication is lazy — `resolveToken()` runs from the ky\n// beforeRequest hook on the first gateway call (and again once the token goes\n// stale), so callers never manage the token by hand.\nexport interface TokenResponse {\n\taccess_token: string;\n\ttoken_type?: string;\n\texpires_in?: number;\n}\n\n// Refresh this many ms before the server's stated expiry, so a token never\n// lapses mid-flight. Applied once, when we compute the stored `expiresAt`.\nconst TOKEN_SKEW_MS = 30_000;\n// FDR tokens are ~900s; fall back to that if the response omits expires_in.\nconst DEFAULT_TTL_S = 900;\n\n/** Raw credentials → bearer JWT. No storage; `resolveToken()` owns that. */\nexport async function exchangeToken(): Promise<TokenResponse> {\n\tconst { urls, auth } = getConfig();\n\tconst basic = Buffer.from(`${auth.username}:${auth.password}`).toString(\n\t\t\"base64\",\n\t);\n\n\treturn ky\n\t\t.post(`${urls.oauth}/v1/token`, {\n\t\t\theaders: { Authorization: `Basic ${basic}` },\n\t\t\tbody: new URLSearchParams({ grant_type: \"client_credentials\" }),\n\t\t})\n\t\t.json<TokenResponse>();\n}\n\n// Default store: in-memory, per-process. Used when config omits `cache`.\nlet memToken: string | null = null;\nlet memExpiresAt = 0;\nconst defaultCache: TokenCache = {\n\tasync get() {\n\t\treturn memToken && Date.now() < memExpiresAt ? memToken : null;\n\t},\n\tasync set(token, expiresAt) {\n\t\tmemToken = token;\n\t\tmemExpiresAt = expiresAt.getTime();\n\t},\n};\n\n// Single-flight guard: a cold burst of concurrent gateway calls performs one\n// exchange, not one per call.\nlet inflight: Promise<string> | null = null;\n\n/**\n * Return a valid bearer token, exchanging + caching on a miss. Called by the\n * gateway beforeRequest hook; not part of the public surface.\n */\nexport function resolveToken(): Promise<string> {\n\tconst store = getConfig().auth.cache ?? defaultCache;\n\tif (inflight) return inflight;\n\n\tinflight = (async () => {\n\t\tconst cached = await store.get();\n\t\tif (cached) return cached;\n\t\tconst res = await exchangeToken();\n\t\tconst ttl = (res.expires_in ?? DEFAULT_TTL_S) * 1000;\n\t\tawait store.set(\n\t\t\tres.access_token,\n\t\t\tnew Date(Date.now() + ttl - TOKEN_SKEW_MS),\n\t\t);\n\t\treturn res.access_token;\n\t})().finally(() => {\n\t\tinflight = null;\n\t});\n\treturn inflight;\n}\n","import ky from \"ky\";\nimport { resolveToken } from \"../auth\";\nimport { getConfig } from \"../config\";\n\n// ---------------------------------------------------------------------------\n// Orval custom mutator (ky-backed).\n//\n// Every generated operation calls `customInstance<T>(config, options)`. We\n// route all calls to the API gateway, attach the bearer token via a\n// beforeRequest hook (lazy auth — `resolveToken()` exchanges/refreshes as\n// needed), and return a small { status, data, headers } wrapper WITHOUT\n// throwing on non-2xx — the caller inspects status codes itself (202 +\n// Retry-After on program, 400 on a UW/DRA gate, etc.).\n// ---------------------------------------------------------------------------\n\n// Shape Orval passes as the first arg (axios-style request config).\nexport interface RequestConfig {\n\turl: string;\n\tmethod: string;\n\tparams?: Record<string, unknown>;\n\tdata?: unknown;\n\theaders?: Record<string, string>;\n\tsignal?: AbortSignal;\n\tresponseType?: string;\n}\n\nexport interface HttpResponse<T> {\n\tstatus: number;\n\tdata: T;\n\theaders: Headers;\n}\n\nexport const customInstance = async <T>(\n\trequest: RequestConfig,\n\toptions?: Partial<RequestConfig>,\n): Promise<HttpResponse<T>> => {\n\tconst { url, method, params, data, signal } = { ...request, ...options };\n\t// Merge headers from both sides — a per-call override (e.g. an\n\t// x-correlation-id in `options.headers`) must not drop the operation's\n\t// Content-Type. The bearer token is layered on last, below.\n\tconst headers = { ...request.headers, ...options?.headers };\n\n\tconst target = new URL(url, getConfig().urls.gateway);\n\tif (params) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\ttarget.searchParams.set(key, String(value));\n\t\t}\n\t}\n\n\tconst response = await ky(target, {\n\t\tmethod,\n\t\theaders,\n\t\thooks: {\n\t\t\t// Lazy bearer injection: resolveToken() exchanges on the first call\n\t\t\t// and refreshes once the cached token goes stale. The OAuth exchange\n\t\t\t// itself runs on a bare ky.post (no hook), so there's no recursion.\n\t\t\tbeforeRequest: [\n\t\t\t\tasync (req) => {\n\t\t\t\t\treq.headers.set(\"Authorization\", `Bearer ${await resolveToken()}`);\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t...(data !== undefined ? { json: data } : {}),\n\t\tsignal,\n\t\tthrowHttpErrors: false,\n\t\tretry: 0,\n\t\t// Some gateway calls (program generation in particular) can take well over ky's\n\t\t// 10s default to respond. Raise the per-request ceiling; the program poll loop\n\t\t// handles 202/Retry-After on top of this.\n\t\ttimeout: 60_000,\n\t});\n\n\tconst text = await response.text();\n\tlet body: T;\n\ttry {\n\t\tbody = (text ? JSON.parse(text) : undefined) as T;\n\t} catch {\n\t\t// Non-JSON body (e.g. a gateway HTML error page on a transient 5xx). Don't throw —\n\t\t// hand back the raw text so callers can inspect status/body and retry as needed.\n\t\tbody = text as unknown as T;\n\t}\n\treturn { status: response.status, data: body, headers: response.headers };\n};\n","/**\n * Generated by orval v7.21.0 🍺\n * Do not edit manually.\n * ARPC — Achieve Resolution Partner Connect API\n * FDR Wholesale API — A Hybrid Integration Model designed to maximise partner velocity without compromising enterprise data standards. DEX (Digital Enrollment Experience) is the partner-facing integration layer that powers the full applicant lifecycle. The `fdr_applicant_id` acts as the applicant's passport across all systems, persisted from first eligibility check through enrollment. All endpoints require a valid Bearer JWT with the `arpc.all` role.\n * OpenAPI spec version: 2026.15.0\n */\nimport type {\n ARPCErrorResponse,\n ApplicationSendEmailResponse,\n BankUpdateRequest,\n CreateLeadRequest,\n CreateLeadResponse,\n DraRequest,\n DraResponse,\n EligibilityRequest,\n EligibilityResponse,\n LeadPatchRequest,\n LeadResponse,\n LeadTransferRequest,\n LeadTransferResponse,\n ProgramRequest,\n ProgramSummaryTaskRequest,\n ProgramSummaryTaskResponse,\n ReadinessResponse,\n RegisterApplicantResponse,\n RegisterApplicantV2Request,\n SpinwheelNetworkUserRequest,\n SpinwheelNetworkUserResponse,\n StatelessReadinessRequest,\n UwSubmissionV2Response\n} from './model';\n\nimport { customInstance } from '../http/client';\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n export const getARPCAchieveResolutionPartnerConnectAPI = () => {\n/**\n * Synchronous Orchestration: Handles both lead creation and income/expense data in one step, eliminating the async polling black box. Data authority shifts here — Achieve (SUIP SF) becomes the Source of Truth once the lead is formally promoted. Returns the full lead creation result including program options.\n * @summary Sync wholesale lead creation\n */\nconst createLeadSync = (\n createLeadRequest: CreateLeadRequest,\n options?: SecondParameter<typeof customInstance<CreateLeadResponse>>,) => {\n return customInstance<CreateLeadResponse>(\n {url: `/v3/application`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: createLeadRequest\n },\n options);\n }\n \n/**\n * Stateless Readiness Check: Pre-flight validation before initiating program calculations. Catches duplicate SSNs or emails early to prevent downstream failures. Requires a valid Authorization header.\n * @summary Check application readiness\n */\nconst checkApplicationReadiness = (\n statelessReadinessRequest: StatelessReadinessRequest,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/readiness`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: statelessReadinessRequest\n },\n options);\n }\n \n/**\n * Recovery endpoint — only required when the async Spinwheel user creation triggered by `POST /v1/applicant/register` fails due to a user error (e.g. invalid SSN or DOB). Not needed in the happy path. Authenticates the seller, resolves the law firm / program, creates an applicant ID when needed, and connects the applicant to the Spinwheel network. Requires a valid Authorization header.\n * @summary Create / connect Spinwheel network user\n */\nconst createSpinwheelNetworkUser = (\n spinwheelNetworkUserRequest: SpinwheelNetworkUserRequest,\n options?: SecondParameter<typeof customInstance<SpinwheelNetworkUserResponse>>,) => {\n return customInstance<SpinwheelNetworkUserResponse>(\n {url: `/v1/application/spinwheel-network-user`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: spinwheelNetworkUserRequest\n },\n options);\n }\n \n/**\n * Authenticates the seller, validates banking disclosure requirements, optionally validates the submitted account and routing numbers, patches the program, and returns the refreshed lead payload. Requires a valid Authorization header.\n * @summary Update applicant bank details\n */\nconst updateApplicationBankDetails = (\n applicantId: string,\n bankUpdateRequest: BankUpdateRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/bank-update/${applicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: bankUpdateRequest\n },\n options);\n }\n \n/**\n * Banking Disclosure: Manually triggers the banking disclosure email. **This endpoint is optional** — it is only needed when the disclosure was not already sent automatically by `POST /v2/application/uw-submission/{fdrApplicantId}` (which auto-sends on full UW approval). Use this endpoint for conditional approvals or when the v1 UW submission path is in use. A critical legal prerequisite that must be completed before enrollment can proceed. Requires a valid Authorization header.\n * @summary Send banking disclosure email (optional — only if not auto-sent by v2 UW submission)\n */\nconst sendEmail = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<ApplicationSendEmailResponse>>,) => {\n return customInstance<ApplicationSendEmailResponse>(\n {url: `/v1/application/send-email/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Submits a lead evaluation request. fdr_applicant_id is required in the request body. Requires a valid Authorization header with the arpc.all role.\n * @summary Transfer a lead to the debt-resolution program\n */\nconst leadTransfer = (\n leadTransferRequest: LeadTransferRequest,\n options?: SecondParameter<typeof customInstance<LeadTransferResponse>>,) => {\n return customInstance<LeadTransferResponse>(\n {url: `/v1/application/lead-transfer`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: leadTransferRequest\n },\n options);\n }\n \n/**\n * Fetches the current state of an application / lead record by FDR applicant ID. Requires a valid Authorization header.\n * @summary Read application / lead details\n */\nconst readLead = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'GET'\n },\n options);\n }\n \n/**\n * Applies a partial update to an existing wholesale lead record. Requires a valid Authorization header and an x-correlation-id header for request tracing.\n * @summary Partial update of application / lead record\n */\nconst patchLead = (\n fdrApplicantId: string,\n leadPatchRequest: LeadPatchRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: leadPatchRequest\n },\n options);\n }\n \n/**\n * DRA Readiness Check: Final pre-flight confirming the lead is approved and all prerequisites are met before initiating the embedded signing session. Requires a valid Authorization header.\n * @summary Get application readiness status\n */\nconst getApplicationReadiness = (\n applicantId: string,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/${applicantId}/readiness`, method: 'GET'\n },\n options);\n }\n \n/**\n * Embedded DRA Signing: Returns an Embedded Signing URL so the applicant signs the Debt Resolution Agreement via DocuSign directly within the Symple UI, preventing session breakage. Successful legal execution triggers automatic enrollment. Requires a valid Authorization header.\n * @summary Generate Debt Resolution Agreement (DRA)\n */\nconst generateDra = (\n applicantId: string,\n draRequest: DraRequest,\n options?: SecondParameter<typeof customInstance<DraResponse>>,) => {\n return customInstance<DraResponse>(\n {url: `/v2/application/${applicantId}/dra`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: draRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint.** `POST /v1/applicant/register` is deprecated and will be retired by end of July 2026 (deadline can be extended on request if your team needs more time). Identity Anchoring: Persists applicant PII to the Managed Package and generates the `fdr_applicant_id` — the applicant's passport across all systems. Routes to the correct Salesforce target (MP or WiB) based on seller identity, and triggers the async credit fetch. Requires a valid Authorization header.\n * @summary Seller-aware applicant registration (v2 — unified ARPCErrorResponse envelope) — recommended\n */\nconst registerApplicantV2 = (\n registerApplicantV2Request: RegisterApplicantV2Request,\n options?: SecondParameter<typeof customInstance<RegisterApplicantResponse>>,) => {\n return customInstance<RegisterApplicantResponse>(\n {url: `/v2/applicant/register`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: registerApplicantV2Request\n },\n options);\n }\n \n/**\n * Async Polling Loop: Call this single endpoint for both initial generation and refresh. Returns 202 Accepted with a Retry-After header while credit is still pending. Once ready, the Managed Package orchestrates the calculation and persists the program result. Requires a valid Authorization header.\n * @summary Generate application program (v1)\n */\nconst generateProgramV1 = (\n programRequest: ProgramRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programRequest\n },\n options);\n }\n \n/**\n * Eligibility Scout: A stateless, real-time quote based on anonymised data — no PII required. Returns estimated program options to anchor the conversation before any registration occurs. Requires a valid Authorization header.\n * @summary Check application eligibility\n */\nconst checkEligibility = (\n eligibilityRequest: EligibilityRequest,\n options?: SecondParameter<typeof customInstance<EligibilityResponse>>,) => {\n return customInstance<EligibilityResponse>(\n {url: `/v2/application/eligibility`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: eligibilityRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint — supersedes v1.** Submits a wholesale application to the underwriting system. On full UW approval (`sub_status = 'UW Approved'`) the banking disclosure email is sent automatically — no separate `send-email` call is needed in this path. Conditional approvals suppress the auto-send; in that case the manual `POST /v1/application/send-email/{fdrApplicantId}` endpoint can be used. Uses the SF Object API directly (no suip-proxy hop). Requires a valid Authorization header.\n * @summary Submit application to underwriting (v2 — auto banking disclosure) — recommended\n */\nconst uwSubmissionV2 = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<UwSubmissionV2Response>>,) => {\n return customInstance<UwSubmissionV2Response>(\n {url: `/v2/application/uw-submission/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Creates a SUIP Salesforce 'Program Summary Recording' task for the applicant identified by the {id} path variable. For DEX (or missing header), the parent SF opportunity is additionally PATCHed with the seller-config partner default PSC. For DC, the task is created and the parent SF opportunity is PATCHed only when ws_psc_code is provided in the request payload.\n * @summary Create program-summary recording task\n */\nconst createProgramSummaryTask = (\n id: string,\n programSummaryTaskRequest: ProgramSummaryTaskRequest,\n options?: SecondParameter<typeof customInstance<ProgramSummaryTaskResponse>>,) => {\n return customInstance<ProgramSummaryTaskResponse>(\n {url: `/v2/application/program-summary-task/${id}`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSummaryTaskRequest\n },\n options);\n }\n \nreturn {createLeadSync,checkApplicationReadiness,createSpinwheelNetworkUser,updateApplicationBankDetails,sendEmail,leadTransfer,readLead,patchLead,getApplicationReadiness,generateDra,registerApplicantV2,generateProgramV1,checkEligibility,uwSubmissionV2,createProgramSummaryTask}};\nexport type CreateLeadSyncResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createLeadSync']>>>\nexport type CheckApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkApplicationReadiness']>>>\nexport type CreateSpinwheelNetworkUserResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createSpinwheelNetworkUser']>>>\nexport type UpdateApplicationBankDetailsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['updateApplicationBankDetails']>>>\nexport type SendEmailResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['sendEmail']>>>\nexport type LeadTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['leadTransfer']>>>\nexport type ReadLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['readLead']>>>\nexport type PatchLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['patchLead']>>>\nexport type GetApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['getApplicationReadiness']>>>\nexport type GenerateDraResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateDra']>>>\nexport type RegisterApplicantV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['registerApplicantV2']>>>\nexport type GenerateProgramV1Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateProgramV1']>>>\nexport type CheckEligibilityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkEligibility']>>>\nexport type UwSubmissionV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['uwSubmissionV2']>>>\nexport type CreateProgramSummaryTaskResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createProgramSummaryTask']>>>\n","import { type ArpcConfig, configure } from \"./config\";\nimport { getARPCAchieveResolutionPartnerConnectAPI } from \"./generated/arpc\";\n\nexport type {\n\tArpcAuth,\n\tArpcConfig,\n\tArpcEndpoint,\n\tArpcEnvironment,\n\tArpcUrls,\n\tTokenCache,\n} from \"./config\";\nexport { ARPC_ENDPOINTS, isArpcEnvironment } from \"./config\";\nexport type * from \"./generated/model\";\nexport type { HttpResponse } from \"./http/client\";\n\n/**\n * ARPC SDK — a typed, agnostic client for FDR's ARPC DEX API (Achieve\n * Resolution Partner Connect, Digital Enrollment Experience).\n *\n * Thin by design: it owns the two-host routing (both derived from\n * `environment`), the OAuth token lifecycle, and bearer injection, and exposes\n * the full endpoint surface as typed operations on `sdk.api`. It does not\n * orchestrate the enrollment sequence — the caller\n * assembles payloads and threads the `fdr_applicant_id` between calls. See\n * `scripts/smoke.ts` for a full end-to-end reference sequence (incl. the program\n * poll loop).\n *\n * Auth is lazy: the first `api` call exchanges credentials for a bearer JWT and\n * caches it (~900s TTL), then re-exchanges shortly before it expires. There's no\n * explicit login step. Supply `auth.cache` to persist the token across restarts\n * or share it across workers; otherwise it's held in-process.\n *\n * Operations never throw on a non-2xx: each returns `{ status, data, headers }`,\n * so a business gate (e.g. a UW/DRA readiness failure) comes back as a normal\n * response you inspect via `status`/`data`. Only transport errors throw.\n *\n * Note: config and the default token cache are process-global — construct one\n * `ArpcSDK` per process. A second instance reconfigures the first; instances are\n * not isolated (single-tenant by design).\n *\n * @example\n * ```typescript\n * const sdk = new ArpcSDK({\n * environment: \"stg\",\n * auth: {\n * username: \"borrowbetter@seller.com\",\n * password: process.env.ARPC_OAUTH_PASSWORD!,\n * },\n * });\n *\n * // The first call authenticates automatically and caches the token.\n * const elig = await sdk.api.checkEligibility({ ... });\n * const faid = elig.data.application?.applicant?.fdr_applicant_id;\n * ```\n */\nexport class ArpcSDK {\n\t/** The full typed endpoint surface — one method per gateway operation. */\n\treadonly api = getARPCAchieveResolutionPartnerConnectAPI();\n\n\tconstructor(config: ArpcConfig) {\n\t\tconfigure(config);\n\t}\n}\n"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/auth.ts","../src/http/client.ts","../src/generated/arpc.ts","../src/draft-type.ts","../src/index.ts"],"names":["ky"],"mappings":";;;AAwCO,IAAM,cAAA,GACZ,OAAO,MAAA,CAAO;AAAA,EACb,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT,CAAA;AAAA,EACD,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT,CAAA;AAAA,EACD,GAAA,EAAK,OAAO,MAAA,CAAO;AAAA,IAClB,KAAA,EAAO,8BAAA;AAAA,IACP,OAAA,EAAS;AAAA,GACT;AACF,CAAC;AAMK,SAAS,kBAAkB,KAAA,EAAyC;AAE1E,EAAA,OAAO,MAAA,CAAO,IAAA,CA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AMJ,EAAA,MAAM,wBAAA,GAA2B,CAC7B,EAAA,EACA,yBAAA,EACH,OAAA,KAAkF;AAC7E,IAAA,OAAO,cAAA;AAAA,MACP;AAAA,QAAC,GAAA,EAAK,wCAAwC,EAAE,CAAA,CAAA;AAAA,QAAI,MAAA,EAAQ,MAAA;AAAA,QAC5D,OAAA,EAAS,EAAC,cAAA,EAAgB,kBAAA,EAAoB;AAAA,QAC9C,IAAA,EAAM;AAAA,OACR;AAAA,MACE;AAAA,KAAO;AAAA,EACT,CAAA;AAEJ,EAAA,OAAO,EAAC,cAAA,EAAe,aAAA,EAAc,yBAAA,EAA0B,0BAAA,EAA2B,8BAA6B,SAAA,EAAU,YAAA,EAAa,QAAA,EAAS,SAAA,EAAU,yBAAwB,WAAA,EAAY,mBAAA,EAAoB,iBAAA,EAAkB,gBAAA,EAAiB,gBAAe,wBAAA,EAAwB;AAAC,CAAA;;;ACtP7R,IAAM,gBAAA,GAGT;AAAA,EACH,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa;AACd;AAGO,IAAM,eAAA,GAGT;AAAA,EACH,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,OAAA;AAAA,EACP,WAAA,EAAa;AACd;AAWO,IAAM,WAAA,GAAc,CAC1B,WAAA,KACkD;AAClD,EAAA,MAAM,QAAQ,WAAA,EAAa,UAAA;AAC3B,EAAA,OAAO,KAAA,GAAQ,eAAA,CAAgB,KAAK,CAAA,GAAI,MAAA;AACzC;;;ACRO,IAAM,UAAN,MAAc;AAAA,EAIpB,YAAY,MAAA,EAAoB;AAFhC;AAAA,IAAA,IAAA,CAAS,MAAM,yCAAA,EAA0C;AAGxD,IAAA,SAAA,CAAU,MAAM,CAAA;AAAA,EACjB;AACD","file":"index.mjs","sourcesContent":["/**\n * SDK configuration.\n *\n * The library never reads the environment itself — a consumer constructs\n * `new ArpcSDK(config)`, which calls `configure()`. Where that config comes\n * from (env vars, a secrets manager, a config service) is the caller's business.\n */\n/**\n * Bearer-token store. The SDK authenticates lazily on the first gateway call:\n * it asks `get()` for a still-valid token and, on `null`, exchanges credentials\n * and hands the fresh token to `set()`. Owning expiry is the cache's job —\n * `get()` returns `null` once the token is stale (or near-stale). The default\n * store is in-memory and per-process; supply one to persist across restarts or\n * share across workers.\n */\nexport interface TokenCache {\n\t/** Return a valid bearer token, or `null` if absent/expired. */\n\tget(): Promise<string | null>;\n\t/** Persist a freshly exchanged token. `expiresAt` already includes the SDK's refresh skew. */\n\tset(token: string, expiresAt: Date): Promise<void>;\n}\n\n/** FDR deployment target. Selects both hosts — see `ARPC_ENDPOINTS`. */\nexport type ArpcEnvironment = \"dev\" | \"stg\" | \"prd\";\n\n/** The host pair a single environment resolves to. */\nexport interface ArpcEndpoint {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\treadonly oauth: string;\n\t/** API gateway host — every non-auth call. */\n\treadonly gateway: string;\n}\n\n/**\n * Per-environment hosts. The two differ by domain, not just subdomain: the\n * OAuth host is `ffngcp.com`, the gateway is `fdrgcp.com`.\n *\n * Frozen: this table backs both host resolution and environment validation, so\n * a consumer mutating it would quietly change SDK behavior.\n */\nexport const ARPC_ENDPOINTS: Readonly<Record<ArpcEnvironment, ArpcEndpoint>> =\n\tObject.freeze({\n\t\tdev: Object.freeze({\n\t\t\toauth: \"https://oauth.dev.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.dev.fdrgcp.com\",\n\t\t}),\n\t\tstg: Object.freeze({\n\t\t\toauth: \"https://oauth.stg.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.stg.fdrgcp.com\",\n\t\t}),\n\t\tprd: Object.freeze({\n\t\t\toauth: \"https://oauth.prd.ffngcp.com\",\n\t\t\tgateway: \"https://apis-gateway-v2.prd.fdrgcp.com\",\n\t\t}),\n\t});\n\n/**\n * Narrow a raw string to an `ArpcEnvironment`. Useful when the value arrives\n * untyped — an env var, a JSON config file, a request payload.\n */\nexport function isArpcEnvironment(value: string): value is ArpcEnvironment {\n\t// Own keys only — `in` would also match inherited members like `toString`.\n\treturn Object.keys(ARPC_ENDPOINTS).includes(value);\n}\n\nexport interface ArpcAuth {\n\t/**\n\t * OAuth client_id (HTTP Basic username). Also used as the lead's\n\t * `seller_agent_email` — the OAuth identity is a registered DRA agent.\n\t */\n\tusername: string;\n\t/** OAuth client_secret (HTTP Basic password). */\n\tpassword: string;\n\t/** Bearer-token store. Defaults to an in-memory, per-process cache. */\n\tcache?: TokenCache;\n}\n\n/**\n * Escape hatch — per-host overrides of the `environment` defaults. Omit a key\n * (or leave it `undefined`) to keep that environment's host.\n */\nexport interface ArpcUrls {\n\t/** OAuth host — token exchange only (`POST /v1/token`). */\n\toauth?: string;\n\t/** API gateway host — every non-auth call. */\n\tgateway?: string;\n}\n\nexport interface ArpcConfig {\n\t/** Selects the FDR environment. Drives both hosts. */\n\tenvironment: ArpcEnvironment;\n\tauth: ArpcAuth;\n\turls?: ArpcUrls;\n}\n\n/** Config as the internals consume it — hosts resolved to concrete strings. */\nexport interface ResolvedArpcConfig extends ArpcConfig {\n\turls: Required<ArpcUrls>;\n}\n\nlet current: ResolvedArpcConfig | null = null;\n\n/**\n * Fold the environment defaults together with any caller overrides. The guard\n * looks unreachable given the types, but `environment` routinely arrives from\n * somewhere untyped (an env var, a JSON config, a JS caller) — catch it here\n * rather than letting `undefined` reach a request URL.\n */\nfunction resolveUrls(config: ArpcConfig): Required<ArpcUrls> {\n\tif (!isArpcEnvironment(config.environment)) {\n\t\tthrow new Error(\n\t\t\t`Unknown environment: ${config.environment} (expected one of ${Object.keys(ARPC_ENDPOINTS).join(\", \")})`,\n\t\t);\n\t}\n\tconst defaults = ARPC_ENDPOINTS[config.environment];\n\treturn {\n\t\toauth: config.urls?.oauth ?? defaults.oauth,\n\t\tgateway: config.urls?.gateway ?? defaults.gateway,\n\t};\n}\n\n/** Set the active config, resolving hosts once. Called by the `ArpcSDK` constructor. */\nexport function configure(config: ArpcConfig): void {\n\tcurrent = { ...config, urls: resolveUrls(config) };\n}\n\n/** Read the active config. Throws if the SDK hasn't been constructed yet. */\nexport function getConfig(): ResolvedArpcConfig {\n\tif (!current) {\n\t\tthrow new Error(\n\t\t\t\"ArpcSDK is not configured — construct `new ArpcSDK(config)` before making calls\",\n\t\t);\n\t}\n\treturn current;\n}\n","import ky from \"ky\";\nimport { getConfig, type TokenCache } from \"./config\";\n\n// Token lifecycle lives in the orchestration layer, not the generated client:\n// the exchange targets the OAuth host (not the gateway), uses HTTP Basic, and is\n// form-encoded. Authentication is lazy — `resolveToken()` runs from the ky\n// beforeRequest hook on the first gateway call (and again once the token goes\n// stale), so callers never manage the token by hand.\nexport interface TokenResponse {\n\taccess_token: string;\n\ttoken_type?: string;\n\texpires_in?: number;\n}\n\n// Refresh this many ms before the server's stated expiry, so a token never\n// lapses mid-flight. Applied once, when we compute the stored `expiresAt`.\nconst TOKEN_SKEW_MS = 30_000;\n// FDR tokens are ~900s; fall back to that if the response omits expires_in.\nconst DEFAULT_TTL_S = 900;\n\n/** Raw credentials → bearer JWT. No storage; `resolveToken()` owns that. */\nexport async function exchangeToken(): Promise<TokenResponse> {\n\tconst { urls, auth } = getConfig();\n\tconst basic = Buffer.from(`${auth.username}:${auth.password}`).toString(\n\t\t\"base64\",\n\t);\n\n\treturn ky\n\t\t.post(`${urls.oauth}/v1/token`, {\n\t\t\theaders: { Authorization: `Basic ${basic}` },\n\t\t\tbody: new URLSearchParams({ grant_type: \"client_credentials\" }),\n\t\t})\n\t\t.json<TokenResponse>();\n}\n\n// Default store: in-memory, per-process. Used when config omits `cache`.\nlet memToken: string | null = null;\nlet memExpiresAt = 0;\nconst defaultCache: TokenCache = {\n\tasync get() {\n\t\treturn memToken && Date.now() < memExpiresAt ? memToken : null;\n\t},\n\tasync set(token, expiresAt) {\n\t\tmemToken = token;\n\t\tmemExpiresAt = expiresAt.getTime();\n\t},\n};\n\n// Single-flight guard: a cold burst of concurrent gateway calls performs one\n// exchange, not one per call.\nlet inflight: Promise<string> | null = null;\n\n/**\n * Return a valid bearer token, exchanging + caching on a miss. Called by the\n * gateway beforeRequest hook; not part of the public surface.\n */\nexport function resolveToken(): Promise<string> {\n\tconst store = getConfig().auth.cache ?? defaultCache;\n\tif (inflight) return inflight;\n\n\tinflight = (async () => {\n\t\tconst cached = await store.get();\n\t\tif (cached) return cached;\n\t\tconst res = await exchangeToken();\n\t\tconst ttl = (res.expires_in ?? DEFAULT_TTL_S) * 1000;\n\t\tawait store.set(\n\t\t\tres.access_token,\n\t\t\tnew Date(Date.now() + ttl - TOKEN_SKEW_MS),\n\t\t);\n\t\treturn res.access_token;\n\t})().finally(() => {\n\t\tinflight = null;\n\t});\n\treturn inflight;\n}\n","import ky from \"ky\";\nimport { resolveToken } from \"../auth\";\nimport { getConfig } from \"../config\";\n\n// ---------------------------------------------------------------------------\n// Orval custom mutator (ky-backed).\n//\n// Every generated operation calls `customInstance<T>(config, options)`. We\n// route all calls to the API gateway, attach the bearer token via a\n// beforeRequest hook (lazy auth — `resolveToken()` exchanges/refreshes as\n// needed), and return a small { status, data, headers } wrapper WITHOUT\n// throwing on non-2xx — the caller inspects status codes itself (202 +\n// Retry-After on program, 400 on a UW/DRA gate, etc.).\n// ---------------------------------------------------------------------------\n\n// Shape Orval passes as the first arg (axios-style request config).\nexport interface RequestConfig {\n\turl: string;\n\tmethod: string;\n\tparams?: Record<string, unknown>;\n\tdata?: unknown;\n\theaders?: Record<string, string>;\n\tsignal?: AbortSignal;\n\tresponseType?: string;\n}\n\nexport interface HttpResponse<T> {\n\tstatus: number;\n\tdata: T;\n\theaders: Headers;\n}\n\nexport const customInstance = async <T>(\n\trequest: RequestConfig,\n\toptions?: Partial<RequestConfig>,\n): Promise<HttpResponse<T>> => {\n\tconst { url, method, params, data, signal } = { ...request, ...options };\n\t// Merge headers from both sides — a per-call override (e.g. an\n\t// x-correlation-id in `options.headers`) must not drop the operation's\n\t// Content-Type. The bearer token is layered on last, below.\n\tconst headers = { ...request.headers, ...options?.headers };\n\n\tconst target = new URL(url, getConfig().urls.gateway);\n\tif (params) {\n\t\tfor (const [key, value] of Object.entries(params)) {\n\t\t\tif (value !== undefined && value !== null)\n\t\t\t\ttarget.searchParams.set(key, String(value));\n\t\t}\n\t}\n\n\tconst response = await ky(target, {\n\t\tmethod,\n\t\theaders,\n\t\thooks: {\n\t\t\t// Lazy bearer injection: resolveToken() exchanges on the first call\n\t\t\t// and refreshes once the cached token goes stale. The OAuth exchange\n\t\t\t// itself runs on a bare ky.post (no hook), so there's no recursion.\n\t\t\tbeforeRequest: [\n\t\t\t\tasync (req) => {\n\t\t\t\t\treq.headers.set(\"Authorization\", `Bearer ${await resolveToken()}`);\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t\t...(data !== undefined ? { json: data } : {}),\n\t\tsignal,\n\t\tthrowHttpErrors: false,\n\t\tretry: 0,\n\t\t// Some gateway calls (program generation in particular) can take well over ky's\n\t\t// 10s default to respond. Raise the per-request ceiling; the program poll loop\n\t\t// handles 202/Retry-After on top of this.\n\t\ttimeout: 60_000,\n\t});\n\n\tconst text = await response.text();\n\tlet body: T;\n\ttry {\n\t\tbody = (text ? JSON.parse(text) : undefined) as T;\n\t} catch {\n\t\t// Non-JSON body (e.g. a gateway HTML error page on a transient 5xx). Don't throw —\n\t\t// hand back the raw text so callers can inspect status/body and retry as needed.\n\t\tbody = text as unknown as T;\n\t}\n\treturn { status: response.status, data: body, headers: response.headers };\n};\n","/**\n * Generated by orval v7.21.0 🍺\n * Do not edit manually.\n * ARPC — Achieve Resolution Partner Connect API\n * FDR Wholesale API — A Hybrid Integration Model designed to maximise partner velocity without compromising enterprise data standards. DEX (Digital Enrollment Experience) is the partner-facing integration layer that powers the full applicant lifecycle. The `fdr_applicant_id` acts as the applicant's passport across all systems, persisted from first eligibility check through enrollment. All endpoints require a valid Bearer JWT with the `arpc.all` role.\n\n**Published:** 2026-08-18\n * OpenAPI spec version: 2026.16.1\n */\nimport type {\n ARPCErrorResponse,\n ApplicationSendEmailResponse,\n BankUpdateRequest,\n CreateLeadRequest,\n CreateLeadResponse,\n DraRequest,\n DraResponse,\n EligibilityRequest,\n EligibilityResponse,\n LeadPatchRequest,\n LeadResponse,\n LeadTransferRequest,\n LeadTransferResponse,\n ProgramRequest,\n ProgramSelectionRequest,\n ProgramSummaryTaskRequest,\n ProgramSummaryTaskResponse,\n ReadinessResponse,\n RegisterApplicantV2Request,\n RegisterApplicantV2Response,\n SpinwheelNetworkUserRequest,\n SpinwheelNetworkUserResponse,\n StatelessReadinessRequest,\n UwSubmissionV2Response\n} from './model';\n\nimport { customInstance } from '../http/client';\ntype SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];\n\n\n export const getARPCAchieveResolutionPartnerConnectAPI = () => {\n/**\n * Synchronous Orchestration: Handles both lead creation and income/expense data in one step, eliminating the async polling black box. Data authority shifts here — Achieve becomes the Source of Truth once the lead is formally promoted. Returns the full lead creation result including program options.\n * @summary Sync wholesale lead creation\n */\nconst createLeadSync = (\n createLeadRequest: CreateLeadRequest,\n options?: SecondParameter<typeof customInstance<CreateLeadResponse>>,) => {\n return customInstance<CreateLeadResponse>(\n {url: `/v3/application`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: createLeadRequest\n },\n options);\n }\n \n/**\n * Gateway-level endpoint: selects a payment schedule for an existing lead and persists the program offer. After calling generateProgram, choose a schedule from payment_schedule_options and submit its draft_type and estimated_monthly_payment here. The gateway injects request attributes and forwards internally to POST /v3/application/program. Requires a valid Authorization header.\n * @summary Select program schedule for an existing lead\n */\nconst selectProgram = (\n programSelectionRequest: ProgramSelectionRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program-selection`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSelectionRequest\n },\n options);\n }\n \n/**\n * Stateless Readiness Check: Pre-flight validation before initiating program calculations. Catches duplicate SSNs or emails early to prevent downstream failures. Requires a valid Authorization header.\n * @summary Check application readiness\n */\nconst checkApplicationReadiness = (\n statelessReadinessRequest: StatelessReadinessRequest,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/readiness`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: statelessReadinessRequest\n },\n options);\n }\n \n/**\n * Recovery endpoint — only required when the async Spinwheel user creation triggered by `POST /v1/applicant/register` fails due to a user error (e.g. invalid SSN or DOB). Not needed in the happy path. Authenticates the seller, resolves the law firm / program, creates an applicant ID when needed, and connects the applicant to the Spinwheel network. Requires a valid Authorization header.\n * @summary Create / connect Spinwheel network user\n */\nconst createSpinwheelNetworkUser = (\n spinwheelNetworkUserRequest: SpinwheelNetworkUserRequest,\n options?: SecondParameter<typeof customInstance<SpinwheelNetworkUserResponse>>,) => {\n return customInstance<SpinwheelNetworkUserResponse>(\n {url: `/v1/application/spinwheel-network-user`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: spinwheelNetworkUserRequest\n },\n options);\n }\n \n/**\n * Authenticates the seller, validates banking disclosure requirements, optionally validates the submitted account and routing numbers, patches the program, and returns the refreshed lead payload. Requires a valid Authorization header.\n * @summary Update applicant bank details\n */\nconst updateApplicationBankDetails = (\n applicantId: string,\n bankUpdateRequest: BankUpdateRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/bank-update/${applicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: bankUpdateRequest\n },\n options);\n }\n \n/**\n * Banking Disclosure: Manually triggers the banking disclosure email. **This endpoint is optional** — it is only needed when the disclosure was not already sent automatically by `POST /v2/application/uw-submission/{fdrApplicantId}` (which auto-sends on full UW approval). Use this endpoint for conditional approvals or when the v1 UW submission path is in use. A critical legal prerequisite that must be completed before enrollment can proceed. Requires a valid Authorization header.\n * @summary Send banking disclosure email (optional — only if not auto-sent by v2 UW submission)\n */\nconst sendEmail = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<ApplicationSendEmailResponse>>,) => {\n return customInstance<ApplicationSendEmailResponse>(\n {url: `/v1/application/send-email/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Submits a lead evaluation request. fdr_applicant_id is required in the request body. Requires a valid Authorization header with the arpc.all role.\n * @summary Transfer a lead to the debt-resolution program\n */\nconst leadTransfer = (\n leadTransferRequest: LeadTransferRequest,\n options?: SecondParameter<typeof customInstance<LeadTransferResponse>>,) => {\n return customInstance<LeadTransferResponse>(\n {url: `/v1/application/lead-transfer`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: leadTransferRequest\n },\n options);\n }\n \n/**\n * Fetches the current state of an application / lead record by FDR applicant ID. Requires a valid Authorization header.\n * @summary Read application / lead details\n */\nconst readLead = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'GET'\n },\n options);\n }\n \n/**\n * Applies a partial update to an existing wholesale lead record. Requires a valid Authorization header and an x-correlation-id header for request tracing. For split drafts, update second_draft_date_split after UW submission and before generating the DRA; the bi-weekly second_draft_date_bi_weekly field is populated automatically during UW approval.\n * @summary Partial update of application / lead record\n */\nconst patchLead = (\n fdrApplicantId: string,\n leadPatchRequest: LeadPatchRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/${fdrApplicantId}`, method: 'PATCH',\n headers: {'Content-Type': 'application/json', },\n data: leadPatchRequest\n },\n options);\n }\n \n/**\n * DRA Readiness Check: Final pre-flight confirming the lead is approved and all prerequisites are met before initiating the embedded signing session. Requires a valid Authorization header.\n * @summary Get application readiness status\n */\nconst getApplicationReadiness = (\n applicantId: string,\n options?: SecondParameter<typeof customInstance<ReadinessResponse>>,) => {\n return customInstance<ReadinessResponse>(\n {url: `/v1/application/${applicantId}/readiness`, method: 'GET'\n },\n options);\n }\n \n/**\n * Embedded DRA Signing: Returns an Embedded Signing URL so the applicant signs the Debt Resolution Agreement via DocuSign directly within the Symple UI, preventing session breakage. Successful legal execution triggers automatic enrollment. Requires a valid Authorization header.\n * @summary Generate Debt Resolution Agreement (DRA)\n */\nconst generateDra = (\n applicantId: string,\n draRequest: DraRequest,\n options?: SecondParameter<typeof customInstance<DraResponse>>,) => {\n return customInstance<DraResponse>(\n {url: `/v2/application/${applicantId}/dra`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: draRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint.** `POST /v1/applicant/register` is deprecated and will be retired by end of July 2026 (deadline can be extended on request if your team needs more time). Identity Anchoring: Persists applicant PII to Achieve's managed partner CRM and generates the `fdr_applicant_id` — the applicant's passport across all systems. Routes to the correct target system based on seller identity, and triggers the async credit fetch. Requires a valid Authorization header.\n * @summary Seller-aware applicant registration (v2 — unified ARPCErrorResponse envelope) — recommended\n */\nconst registerApplicantV2 = (\n registerApplicantV2Request: RegisterApplicantV2Request,\n options?: SecondParameter<typeof customInstance<RegisterApplicantV2Response>>,) => {\n return customInstance<RegisterApplicantV2Response>(\n {url: `/v2/applicant/register`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: registerApplicantV2Request\n },\n options);\n }\n \n/**\n * Async Polling Loop: Call this single endpoint for both initial generation and refresh. Returns 202 Accepted with a Retry-After header while credit is still pending. Once ready, the Managed Package orchestrates the calculation and persists the program result. Requires a valid Authorization header.\n * @summary Generate application program (v1)\n */\nconst generateProgramV1 = (\n programRequest: ProgramRequest,\n options?: SecondParameter<typeof customInstance<LeadResponse>>,) => {\n return customInstance<LeadResponse>(\n {url: `/v1/application/program`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programRequest\n },\n options);\n }\n \n/**\n * Eligibility Scout: Two operational modes — (1) no PII required: state-based quote using provided debt accounts; (2) credit pull: full applicant PII for a live soft credit report. Returns estimated program options to anchor the conversation before any registration occurs. Requires a valid Authorization header.\n * @summary Check application eligibility\n */\nconst checkEligibility = (\n eligibilityRequest: EligibilityRequest,\n options?: SecondParameter<typeof customInstance<EligibilityResponse>>,) => {\n return customInstance<EligibilityResponse>(\n {url: `/v2/application/eligibility`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: eligibilityRequest\n },\n options);\n }\n \n/**\n * **Recommended endpoint — supersedes v1.** Submits a wholesale application to the underwriting system. On full UW approval (`sub_status = 'UW Approved'`) the banking disclosure email is sent automatically — no separate `send-email` call is needed in this path. Conditional approvals suppress the auto-send; in that case the manual `POST /v1/application/send-email/{fdrApplicantId}` endpoint can be used. Uses the SF Object API directly (no suip-proxy hop). Requires a valid Authorization header.\n * @summary Submit application to underwriting (v2 — auto banking disclosure) — recommended\n */\nconst uwSubmissionV2 = (\n fdrApplicantId: string,\n options?: SecondParameter<typeof customInstance<UwSubmissionV2Response>>,) => {\n return customInstance<UwSubmissionV2Response>(\n {url: `/v2/application/uw-submission/${fdrApplicantId}`, method: 'POST'\n },\n options);\n }\n \n/**\n * Creates a SUIP Salesforce 'Program Summary Recording' task for the applicant identified by the {id} path variable. For DEX (or missing header), the parent SF opportunity is additionally PATCHed with the seller-config partner default PSC. For DC, the task is created and the parent SF opportunity is PATCHed only when ws_psc_code is provided in the request payload.\n * @summary Create program-summary recording task\n */\nconst createProgramSummaryTask = (\n id: string,\n programSummaryTaskRequest: ProgramSummaryTaskRequest,\n options?: SecondParameter<typeof customInstance<ProgramSummaryTaskResponse>>,) => {\n return customInstance<ProgramSummaryTaskResponse>(\n {url: `/v2/application/program-summary-task/${id}`, method: 'POST',\n headers: {'Content-Type': 'application/json', },\n data: programSummaryTaskRequest\n },\n options);\n }\n \nreturn {createLeadSync,selectProgram,checkApplicationReadiness,createSpinwheelNetworkUser,updateApplicationBankDetails,sendEmail,leadTransfer,readLead,patchLead,getApplicationReadiness,generateDra,registerApplicantV2,generateProgramV1,checkEligibility,uwSubmissionV2,createProgramSummaryTask}};\nexport type CreateLeadSyncResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createLeadSync']>>>\nexport type SelectProgramResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['selectProgram']>>>\nexport type CheckApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkApplicationReadiness']>>>\nexport type CreateSpinwheelNetworkUserResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createSpinwheelNetworkUser']>>>\nexport type UpdateApplicationBankDetailsResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['updateApplicationBankDetails']>>>\nexport type SendEmailResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['sendEmail']>>>\nexport type LeadTransferResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['leadTransfer']>>>\nexport type ReadLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['readLead']>>>\nexport type PatchLeadResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['patchLead']>>>\nexport type GetApplicationReadinessResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['getApplicationReadiness']>>>\nexport type GenerateDraResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateDra']>>>\nexport type RegisterApplicantV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['registerApplicantV2']>>>\nexport type GenerateProgramV1Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['generateProgramV1']>>>\nexport type CheckEligibilityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['checkEligibility']>>>\nexport type UwSubmissionV2Result = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['uwSubmissionV2']>>>\nexport type CreateProgramSummaryTaskResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getARPCAchieveResolutionPartnerConnectAPI>['createProgramSummaryTask']>>>\n","import type {\n\tLeadApplication,\n\tLeadApplicationDraftType,\n\tProgramSelectionRequestDraftType,\n} from \"./generated/model\";\n\n/**\n * FDR's API speaks two vocabularies for the same value. You *send* a lowercase\n * schedule code (`bi-weekly`) to `selectProgram`; the lead *reports* a\n * capitalised label (`Bi-Weekly`) back on `application.draft_type`. Nothing in\n * the spec connects them, and the mismatch is silent — comparing what you sent\n * against what came back always looks like a failure.\n *\n * The labels below were confirmed against live STG by selecting each draft type\n * in turn. Through 2026.16.0 the spec documented `Monthly [Regular]` and\n * `Twice Monthly [Split]` for two of them and the API returned neither; 16.1\n * corrected the response enum, so the generated types now agree with the wire.\n * The two *vocabularies* remain — a corrected enum is not a unified one.\n *\n * Scope is narrow: `LeadApplication.draft_type` is the only label-valued site\n * in the whole spec. `PaymentSchedule` and `ProgramSelectionRequest` are both\n * already lowercase, and `LeadPatchRequest` has no `draft_type` at all, so\n * `selectProgram` is the only write path.\n *\n * These maps are annotated as `Record<>` over the generated enums on purpose:\n * if FDR ever adds a fourth draft type, codegen widens the enum and these fail\n * to compile until someone fills in the new key. The mapping keeps itself\n * honest without any bespoke assertion.\n */\n\n/** Schedule code → the label the lead reports back. */\nexport const DRAFT_TYPE_LABEL: Record<\n\tProgramSelectionRequestDraftType,\n\tLeadApplicationDraftType\n> = {\n\tregular: \"Regular\",\n\tsplit: \"Split\",\n\t\"bi-weekly\": \"Bi-Weekly\",\n};\n\n/** Lead-reported label → the schedule code `selectProgram` accepts. */\nexport const DRAFT_TYPE_CODE: Record<\n\tLeadApplicationDraftType,\n\tProgramSelectionRequestDraftType\n> = {\n\tRegular: \"regular\",\n\tSplit: \"split\",\n\t\"Bi-Weekly\": \"bi-weekly\",\n};\n\n/**\n * Read a lead's current draft type as a value you can hand straight back to\n * `selectProgram` — closing the round-trip FDR's two vocabularies leave open.\n *\n * Returns `undefined` when the lead has no selection yet, and also when the\n * label isn't one we know: the server can start returning a new picklist value\n * before we've regenerated against a newer spec, and guessing would be worse\n * than admitting we don't recognise it.\n */\nexport const draftTypeOf = (\n\tapplication: LeadApplication | undefined | null,\n): ProgramSelectionRequestDraftType | undefined => {\n\tconst label = application?.draft_type;\n\treturn label ? DRAFT_TYPE_CODE[label] : undefined;\n};\n","import { type ArpcConfig, configure } from \"./config\";\nimport { getARPCAchieveResolutionPartnerConnectAPI } from \"./generated/arpc\";\n\nexport type {\n\tArpcAuth,\n\tArpcConfig,\n\tArpcEndpoint,\n\tArpcEnvironment,\n\tArpcUrls,\n\tTokenCache,\n} from \"./config\";\nexport { ARPC_ENDPOINTS, isArpcEnvironment } from \"./config\";\nexport { DRAFT_TYPE_CODE, DRAFT_TYPE_LABEL, draftTypeOf } from \"./draft-type\";\nexport type * from \"./generated/model\";\nexport type { HttpResponse } from \"./http/client\";\n\n/**\n * ARPC SDK — a typed, agnostic client for FDR's ARPC DEX API (Achieve\n * Resolution Partner Connect, Digital Enrollment Experience).\n *\n * Thin by design: it owns the two-host routing (both derived from\n * `environment`), the OAuth token lifecycle, and bearer injection, and exposes\n * the full endpoint surface as typed operations on `sdk.api`. It does not\n * orchestrate the enrollment sequence — the caller\n * assembles payloads and threads the `fdr_applicant_id` between calls. See\n * `scripts/smoke.ts` for a full end-to-end reference sequence (incl. the program\n * poll loop).\n *\n * Auth is lazy: the first `api` call exchanges credentials for a bearer JWT and\n * caches it (~900s TTL), then re-exchanges shortly before it expires. There's no\n * explicit login step. Supply `auth.cache` to persist the token across restarts\n * or share it across workers; otherwise it's held in-process.\n *\n * Operations never throw on a non-2xx: each returns `{ status, data, headers }`,\n * so a business gate (e.g. a UW/DRA readiness failure) comes back as a normal\n * response you inspect via `status`/`data`. Only transport errors throw.\n *\n * Note: config and the default token cache are process-global — construct one\n * `ArpcSDK` per process. A second instance reconfigures the first; instances are\n * not isolated (single-tenant by design).\n *\n * @example\n * ```typescript\n * const sdk = new ArpcSDK({\n * environment: \"stg\",\n * auth: {\n * username: \"borrowbetter@seller.com\",\n * password: process.env.ARPC_OAUTH_PASSWORD!,\n * },\n * });\n *\n * // The first call authenticates automatically and caches the token.\n * const elig = await sdk.api.checkEligibility({ ... });\n * const faid = elig.data.application?.applicant?.fdr_applicant_id;\n * ```\n */\nexport class ArpcSDK {\n\t/** The full typed endpoint surface — one method per gateway operation. */\n\treadonly api = getARPCAchieveResolutionPartnerConnectAPI();\n\n\tconstructor(config: ArpcConfig) {\n\t\tconfigure(config);\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@borrowbetter/arpcsdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Typed, agnostic client for FDR's ARPC DEX API — Achieve Resolution Partner Connect (Digital Enrollment Experience)",
5
5
  "author": "BorrowBetter",
6
6
  "license": "MIT",
@@ -35,7 +35,6 @@
35
35
  "codegen": "orval --config codegen.ts",
36
36
  "dev": "tsup --watch",
37
37
  "typecheck": "tsc --noEmit",
38
- "typecheck:scripts": "tsc --noEmit --project scripts/tsconfig.json",
39
38
  "smoke": "tsx scripts/smoke.ts",
40
39
  "prepublishOnly": "pnpm build",
41
40
  "lint": "biome check",
@@ -54,6 +53,7 @@
54
53
  "@changesets/cli": "^2.27.0",
55
54
  "@types/node": "^22.10.5",
56
55
  "dotenv-flow": "^4.1.0",
56
+ "openapi3-ts": "^4.6.1",
57
57
  "orval": "^7.13.0",
58
58
  "tsup": "^8.0.0",
59
59
  "tsx": "^4.21.0",