@borrowbetter/arpcsdk 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -6
- package/dist/index.d.mts +1467 -617
- package/dist/index.d.ts +1467 -617
- package/dist/index.js +79 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,8 @@ sequenceDiagram
|
|
|
114
114
|
- `createProgramSummaryTask()` — records the program-summary review. **This gates DRA generation** — skip it and the `dra` readiness check fails. Returns `201`, not `200`, on success.
|
|
115
115
|
- `getApplicationReadiness()` — pre-flight; confirms the `uw_submission` and `dra` gates are verified.
|
|
116
116
|
- `generateDra()` — returns a **DocuSign embedded signing URL** (`dra.data.applicant?.url`). Single-use, ~5 min TTL. Successful signing triggers enrollment downstream.
|
|
117
|
+
- `resendAgreement()` — fresh signing URL (or email) for the **same** envelope. Reach for this when a URL expired or got lost; don't void just to get another URL.
|
|
118
|
+
- `voidAgreement()` — cancels the envelope for good; only when the agreement is wrong or superseded. `generateDra()` afterwards mints a new envelope. `ER40501` = unknown or already voided/completed/declined — terminal, don't retry.
|
|
117
119
|
|
|
118
120
|
### Endpoint reference
|
|
119
121
|
|
|
@@ -124,6 +126,7 @@ sequenceDiagram
|
|
|
124
126
|
| `generateProgramV1` | `POST /v1/application/program` (202 → … → 200 poll) |
|
|
125
127
|
| `createLeadSync` | `POST /v3/application` |
|
|
126
128
|
| `readLead` / `patchLead` | `GET` / `PATCH /v1/application/{id}` |
|
|
129
|
+
| `getApplicationStatus` | `GET /v1/application/{id}/status` (flat record; `?query=` picks fields, so the response is untyped) |
|
|
127
130
|
| `selectProgram` | `POST /v1/application/program-selection` (commit to a payment schedule) |
|
|
128
131
|
| `uwSubmissionV2` | `POST /v2/application/uw-submission/{id}` |
|
|
129
132
|
| `sendEmail` | `POST /v1/application/send-email/{id}` (only if UW didn't auto-send) |
|
|
@@ -131,6 +134,8 @@ sequenceDiagram
|
|
|
131
134
|
| `createProgramSummaryTask` | `POST /v2/application/program-summary-task/{id}` — **gates DRA** |
|
|
132
135
|
| `getApplicationReadiness` | `GET /v1/application/{id}/readiness` |
|
|
133
136
|
| `generateDra` | `POST /v2/application/{id}/dra` (DocuSign embedded signing URL) |
|
|
137
|
+
| `resendAgreement` | `POST /v2/application/{id}/agreement/{envelopeId}/resend` (not in FDR's spec — see repairs) |
|
|
138
|
+
| `voidAgreement` | `PUT /v1/application/{id}/agreement/{envelopeId}/void` (not in FDR's spec — see repairs) |
|
|
134
139
|
| `leadTransfer` | `POST /v1/application/lead-transfer` (retail handoff — see below) |
|
|
135
140
|
|
|
136
141
|
## Choosing a payment schedule
|
|
@@ -171,9 +176,9 @@ Two things to know:
|
|
|
171
176
|
- **Branch on `res.status`, not exceptions.** A gated call returns e.g. `{ status: 400, data: { error_code: "ER40301", … } }`.
|
|
172
177
|
- **UW submission rewrites the program selection to `Bi-Weekly`.** Not a clear — an overwrite, with the draft amount changed to match. Observed on both `regular` and `split`. Always call `selectProgram()` again after `uwSubmissionV2()`. It's invisible if you selected bi-weekly in the first place, which is why it's easy to miss. Note the UW response's own `application` is a thin projection (identity + status, no program fields — typed as `UwSubmissionV2Application` since 2026.16.1), so re-read the lead to check what actually happened.
|
|
173
178
|
- **`ER40301` at UW is often transient** — the readiness check hasn't caught up with the condition-verify you just did (live eventual consistency). Retry the UW submission after a short delay before treating it as terminal.
|
|
174
|
-
- **`ER40303` at DRA = the `dra` readiness gate rejected.** Read `error_details[]` for the specific field. The draft/program dates it checks are backend-derived
|
|
179
|
+
- **`ER40303` at DRA = the `dra` readiness gate rejected.** Read `error_details[]` for the specific field. The draft/program dates it checks are backend-derived, populated by `selectProgram()` and `createProgramSummaryTask()` upstream rather than by the DRA call itself. `first_draft_date` defaults to the applicant's `next_pay_date` at UW; since 2026.21.0 you can `patchLead()` it after UW approval to pick another date. **`split` needs one extra call.** It fails the `secondDraftDateMissing` check ("Second draft date is required when draft type is split or bi-weekly") unless you `patchLead()` a `second_draft_date_split` **after UW submission and before generating the DRA** — added in 2026.16.1 in response to our report. Bi-weekly needs nothing: `second_draft_date_bi_weekly` is populated automatically at UW approval, and there is no patch field for it. `bi-weekly` and `regular` are what the smoke run exercises end-to-end; the `split` patch is documented but not yet driven by it.
|
|
175
180
|
- **Hardship and goal fields are UW-required despite being spec-optional.** `CreateLeadRequest` marks nothing required, and lead creation happily returns `200` without them — then UW fails with `ER40301` / `HARDSHIP_CHECK_FAILED`. Empirically the gate needs **all three** of `hardship_category`, `hardship_category_other` and `goal_category`; `goal_category_other` is genuinely optional. Note `hardship_category_other` is required even when the category isn't `Other`, contradicting its own description — reported to FDR. Also don't trust the `field` on that error: it has been observed naming a field that *was* supplied.
|
|
176
|
-
- **Readiness gates return the breakdown on `error_details`.** Since 2026.16.1 `ARPCErrorResponse.error_details` is a typed `ErrorDetails` (`checks[]`, `is_program_refresh_required`, `is_uw_approved`, `message`), so `ER40301` at UW and `ER40303`/`ER40305` at DRA are readable without a cast.
|
|
181
|
+
- **Readiness gates return the breakdown on `error_details`.** Since 2026.16.1 `ARPCErrorResponse.error_details` is a typed `ErrorDetails` (`checks[]`, `is_program_refresh_required`, `is_uw_approved`, `message`), so `ER40301` at UW and `ER40303`/`ER40305` at DRA are readable without a cast. 2026.21.0 documents the UW `ER40301` under both `400` and `422`; STG still returns **`400`** (observed 2026-10-30), so branch on `error_code` rather than status.
|
|
177
182
|
- **Read per-check failures off `error_details[]`, not `errors[]`.** Each `ReadinessCheck` now carries structured entries with a stable `reason_code` (`REQUIRED`, `DUPLICATE_EMAIL`, `CONDITION_NOT_VERIFIED`, `DEBT_TOTAL_MISMATCH`, …) and a dotted `field` path. `errors[]` is free text kept for compat — its wording changes.
|
|
178
183
|
- **Conditional vs full approval changes the email path** — always check `banking_disclosure_email_sent` before deciding whether to call `sendEmail()`.
|
|
179
184
|
- **Program timing varies** — the poll can take 20s+; don't set a tight timeout around the loop.
|
|
@@ -267,20 +272,22 @@ ARPC_OAUTH_PASSWORD=...
|
|
|
267
272
|
|
|
268
273
|
These are the smoke script's, not the SDK's — the library never reads `process.env`. The script pins `environment: "stg"` in code rather than taking it from `.env`: it drives a real enrollment against the canned STG test identity, so it must not be pointable at PRD.
|
|
269
274
|
|
|
270
|
-
The typed client (`src/generated/`) is generated from the committed spec (`openapi/api-v2026.
|
|
275
|
+
The typed client (`src/generated/`) is generated from the committed spec (`openapi/api-v2026.21.0.json`) and is not checked in — `pnpm codegen` (run automatically by `build`) reproduces it. To move to a newer spec, drop the JSON in `openapi/` and update `input.target` in `codegen.ts`.
|
|
271
276
|
|
|
272
277
|
The spec's `Authentication` tag is excluded from codegen (`input.filters`): it documents `POST /v1/token`, which lives on the OAuth host with HTTP Basic and a form-encoded body, while every generated operation runs through the ky mutator and targets the gateway. `src/auth.ts` owns that exchange.
|
|
273
278
|
|
|
274
279
|
### Spec repairs
|
|
275
280
|
|
|
276
|
-
The vendored spec is byte-identical to what FDR published. Defects
|
|
281
|
+
The vendored spec is byte-identical to what FDR published. Defects — including live endpoints the spec omits — are patched at codegen time by `openapi/repairs.ts` (wired in as orval's `input.override.transformer`), so **the generated types intentionally differ from FDR's published docs** in these places:
|
|
277
282
|
|
|
278
283
|
| Repair | FDR ships | We generate |
|
|
279
284
|
|---|---|---|
|
|
280
|
-
| `
|
|
285
|
+
| `nullable-refs` | OpenAPI 3.1 `{ $ref, type: "null" }` on 5 properties (`error_details`, `bank_details`, `co_applicant`, `readiness`, `credit_pull_consent`) — orval drops the null | `anyOf: [{ $ref }, { type: "null" }]`, so they generate as `T \| null` |
|
|
281
286
|
| `program-selection-applicant-id` | `ProgramSelectionApplicant.fdr_applicant_id` optional, so `{ applicant: {} }` type-checks and 400s at runtime | the one field the endpoint reads, marked `required` |
|
|
287
|
+
| `agreement-resend` | no resend endpoint (documented only in FDR's prose guide) | `resendAgreement`; error shapes confirmed against STG, the 200 from FDR's guide |
|
|
288
|
+
| `agreement-void` | no void endpoint (same guide) | `voidAgreement`, plus `AgreementErrorResponse` — its `error_details` is `{ envelope_id }`, not the readiness `ErrorDetails` |
|
|
282
289
|
|
|
283
|
-
2026.16.1 fixed three of the four repairs this file carried against 16.0 — the `draft_type` response enum, the `ProgramSelectionRequest.applicant` reference, and the readiness error envelope (`ARPCErrorResponse.error_details`). Their guards fired on the version bump and the repairs were deleted, which is the mechanism working as designed. Note `ReadinessErrorResponse` is no longer exported: readiness detail now hangs off `ARPCErrorResponse.error_details` as FDR's own `ErrorDetails`.
|
|
290
|
+
2026.16.1 fixed three of the four repairs this file carried against 16.0 — the `draft_type` response enum, the `ProgramSelectionRequest.applicant` reference, and the readiness error envelope (`ARPCErrorResponse.error_details`). Their guards fired on the version bump and the repairs were deleted, which is the mechanism working as designed. Note `ReadinessErrorResponse` is no longer exported: readiness detail now hangs off `ARPCErrorResponse.error_details` as FDR's own `ErrorDetails`. 2026.21.0 fixed `select-program-error-responses` (`selectProgram` 401/500 now point at `ARPCErrorResponse`), and its move to OpenAPI 3.1 introduced `nullable-refs`.
|
|
284
291
|
|
|
285
292
|
Each patched schema carries a `⚠️ Patched locally` note in its TSDoc, so the divergence is visible at the point of use.
|
|
286
293
|
|