@izak0s/spacebring-api 1.11.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,8 +19,8 @@ A fully-typed TypeScript client for the [Spacebring](https://www.spacebring.com)
19
19
  - **Auto-generated** from the official OpenAPI spec — types and facade regenerate anytime the spec changes
20
20
  - **Nested, discoverable API** — `sb.billing.invoices.pay(id)`, `sb.visitors.visits.checkIn(body)`
21
21
  - **Auto-pagination** — every paginated list endpoint has an `iterate()` async generator that walks `nextPageToken` for you
22
- - **Ergonomic returns** — single-property response envelopes are unwrapped: entities and plain arrays come back directly
23
- - **Readable, named types** — entities (`Booking`, `Invoice`) and query parameters (`GetBookingsQuery`) are exported named types, so hovers show `Booking[]` instead of generated type soup, and enum filters are literal unions
22
+ - **Ergonomic payloads** — single-property envelopes are unwrapped in both directions: responses hand you the entity or array directly, and create/update methods take the payload flat (`sb.plans.create({ title, price })` instead of `{ plan: { … } }`)
23
+ - **Readable, named types** — entities (`Booking`, `Invoice`) and query parameters (`GetBookingsQuery`) are exported named types, so hovers show `Booking[]` or `{ invoice?: Invoice; payment?: Payment }` instead of generated type soup, and enum filters are literal unions
24
24
  - **Rich error handling** — non-2xx responses throw a typed `SpacebringError` carrying the status, parsed body, and the operation that failed; malformed 2xx bodies and stuck pagination tokens throw instead of failing silently
25
25
  - **Resilient by default** — automatic retries for rate limits, gateway errors, and network failures (never replaying non-idempotent requests); optional per-attempt timeouts and `AbortSignal` cancellation on every method
26
26
  - **Zero runtime dependencies** — Node ≥ 20, `fetch`-based; type declarations are fully self-contained (TypeScript ≥ 5.4)
@@ -72,7 +72,14 @@ try {
72
72
  }
73
73
  ```
74
74
 
75
- Writes read the same, and endpoints that return more than one payload keep the envelope intact:
75
+ Writes take the payload directly — no `{ plan: { … } }` wrapper around request bodies:
76
+
77
+ ```ts
78
+ const plan = await sb.plans.create({ locationRef, title: "Day pass bundle", price: 99, period: "month" });
79
+ await sb.plans.update(plan.id, { price: 149 });
80
+ ```
81
+
82
+ Endpoints that genuinely send or return more than one payload keep the envelope intact:
76
83
 
77
84
  ```ts
78
85
  const { invoice, payment } = await sb.billing.invoices.pay(invoiceId, {