@betorigami/game-ui-shared 8.1.0 → 8.2.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
@@ -36,7 +36,7 @@ The package does not read environment variables. A host that wants a different p
36
36
 
37
37
  ## Provider API client
38
38
 
39
- `ProviderApi` is a client for provider-api, generated with [hey-api](https://heyapi.dev) from provider-api's OpenAPI spec. Every response is checked against the spec with zod/mini before the caller sees it.
39
+ `ProviderApi` is a client for provider-api, generated with [hey-api](https://heyapi.dev) from provider-api's OpenAPI spec. Every response is parsed with zod/mini before the caller sees it. Schemas the spec marks `"x-origami-type": "Money"` arrive as `Money` and those marked `"x-origami-type": "MoneyMultiplier"` arrive as `MoneyMultiplier`.
40
40
 
41
41
  ```ts
42
42
  import { ProviderApi } from '@betorigami/game-ui-shared';
@@ -45,7 +45,7 @@ const client = ProviderApi.createProviderApiClient({ baseUrl, authToken });
45
45
  const { data, error } = await ProviderApi.postGamesDicePlay({ client, body });
46
46
  ```
47
47
 
48
- `createProviderApiClient` adds the auth token, a fresh `X-Origami-Trace` id and a `REQUEST_TIMEOUT_MS` timeout to every request. `data` is set when the request succeeds and the response matches the spec. Otherwise `error` holds the error body, which `resolveApiErrorCode` turns into an `ErrorCode`. A response that doesn't match the spec throws. Inside this package, import from `src/shared/provider-api/provider-api-client` instead.
48
+ `createProviderApiClient` adds the auth token, a fresh `X-Origami-Trace` id and a `REQUEST_TIMEOUT_MS` timeout to every request. `data` is set when the request succeeds and the response matches the spec. Otherwise `error` holds the error body, which `resolveApiErrorCode` turns into an `ErrorCode`. A response that doesn't match the spec leaves `data` unset and puts the `ZodError` in `error`, which `resolveApiErrorCode` turns into `ErrorCode.UNKNOWN`. Inside this package, import from `src/shared/provider-api/provider-api-client` instead.
49
49
 
50
50
  To regenerate it after provider-api's endpoints change:
51
51
 
@@ -53,7 +53,7 @@ To regenerate it after provider-api's endpoints change:
53
53
  2. Run `pnpm run generate:provider-api` in this package.
54
54
  3. Commit the changes under `src/shared/provider-api/generated/`.
55
55
 
56
- The settings, including the excluded `/internal/*` routes, are in `openapi-ts.config.ts`. Don't edit the generated files by hand.
56
+ The settings, including the excluded `/internal/*` routes and the resolvers that build `Money` and `MoneyMultiplier`, are in `openapi-ts.config.ts`. Don't edit the generated files by hand.
57
57
 
58
58
  ## Pinning
59
59