mirror of
https://github.com/hanzo-js/sdk.git
synced 2026-11-09 11:17:16 +00:00
Restructures @hanzo/sdk from a Commerce-only SDK into the canonical
TypeScript client for every Hanzo backend. One install (`npm i @hanzo/sdk`),
typed clients for every service via tree-shakable subpath imports.
Services covered (1:1 with hanzoai/* Go upstreams):
@hanzo/sdk/iam hanzoai/iam OIDC, applications, redirect URIs, users, orgs
@hanzo/sdk/kms hanzoai/kms Secrets get/set/list, envelope encrypt/decrypt
@hanzo/sdk/commerce hanzoai/commerce Existing storefront+admin (preserved, moved under /commerce)
@hanzo/sdk/billing hanzoai/billing Subscriptions, invoices (scaffold)
@hanzo/sdk/mpc hanzoai/mpc Threshold sign CGGMP21/FROST (scaffold)
@hanzo/sdk/paas hanzoai/paas Deployments, environments (scaffold)
@hanzo/sdk/team hanzoai/team Members, invites (scaffold)
@hanzo/sdk/api hanzoai/api Generic gateway passthrough
IAM and KMS are production-grade today (the two surfaces most reached
for in ops). The rest are typed scaffolds that compile + emit .d.ts —
they fill out as each upstream Go service's REST API stabilises.
Architecture:
src/_shared/client.ts BaseClient — one HTTP layer, used by every service
client. Token + fetch + HanzoAPIError surface.
src/<service>/index.ts Service-specific client classes. Public methods
are deliberately named (fetch / list / upsert / remove
/ add) to avoid colliding with BaseClient.get/post.
src/index.ts HanzoSDK umbrella — mounts every service under one
config with per-service base-URL overrides for
envs where services live on different hostnames
(e.g. Liquidity: iam.dev.satschel.com vs
kms.dev.satschel.com vs api.dev.satschel.com).
Top-of-thread motivation: today's Slack thread asking "how do I add a
redirect URI to vcc-exchange-client-id?" The answer used to be "clone
github.com/hanzo-js/iam and call addRedirectUri()". Now it's:
await new IAMClient({ baseUrl, token })
.applications.redirectURIs.add('vcc-exchange-client-id', urls)
Or via the CLI side (liquidityio/cli):
liquid iam redirect add vcc-exchange-client-id <url> [<url> ...]
Both layers (CLI + SDK) call the same upstream IAM admin endpoint
(POST /v1/iam/admin/applications/upsert). One canonical operation,
three surfaces (REST / TS SDK / CLI) — no drift.
Breaking change from v1.x: HanzoSDK.admin / .store / .auth moved
under HanzoSDK.commerce.{admin,store,auth}. Migration is a single
search-replace per consumer; the old surface lives at
@hanzo/sdk/commerce instead of the root if back-compat shims are
needed.
Build: tsup, dual ESM + CJS, splitting on, full .d.ts emit. 11 entry
points × 2 formats × 1 dts pass = 33 build artifacts. Typecheck
clean, build clean.
28 lines
876 B
TypeScript
28 lines
876 B
TypeScript
import { defineConfig } from 'tsup'
|
|
|
|
/**
|
|
* One entry per subpath export — produces tree-shakable ESM + CJS
|
|
* bundles + .d.ts under dist/. package.json `exports` mirrors this
|
|
* matrix; every change to entries should be reflected there.
|
|
*/
|
|
export default defineConfig({
|
|
entry: {
|
|
index: 'src/index.ts',
|
|
'iam/index': 'src/iam/index.ts',
|
|
'kms/index': 'src/kms/index.ts',
|
|
'commerce/index': 'src/commerce/index.ts',
|
|
'commerce/admin/index': 'src/commerce/admin/index.ts',
|
|
'commerce/store/index': 'src/commerce/store/index.ts',
|
|
'commerce/types': 'src/commerce/types.ts',
|
|
'billing/index': 'src/billing/index.ts',
|
|
'mpc/index': 'src/mpc/index.ts',
|
|
'paas/index': 'src/paas/index.ts',
|
|
'team/index': 'src/team/index.ts',
|
|
'api/index': 'src/api/index.ts',
|
|
},
|
|
format: ['cjs', 'esm'],
|
|
dts: true,
|
|
clean: true,
|
|
splitting: true,
|
|
})
|