Overview
@saflib/sdk is the platform library for TanStack Query clients, MSW fakes, and shared Vue components tied to an OpenAPI contract. SPAs import the SDK for making calls to the service backend.
Layout and naming for service packages are in monorepo — service/. The golden product SDK is base/service/sdk.
Use sdk/add-query and sdk/add-mutation to create TanStack functions, and sdk/add-component for standalone components.
What this package provides
| Export | Role |
|---|---|
createSafClient / handleClientMethod | Typed openapi-fetch client with CSRF, subdomain routing, and TanStack error typing |
createTanstackQueryClient | Default QueryClient (stale time, selective retries) for SPAs |
useDownload | Cookie-authenticated file downloads |
createCredentialsEventSource | Cookie-authenticated SSE (cross-subdomain) |
./testing | withVueQuery, typedCreateHandler |
./testing/mock | Vitest + MSW setupMockServer helper |
./components | Cross-product shared components (e.g. AddressForm) |
./workflows | Scaffold and extend product SDK packages |