@superbright/indexeddb-orm 1.0.49 → 1.0.51
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
|
@@ -96,10 +96,33 @@ Each `generate:api-schema:*` script calls `scripts/generate-api-schema.mjs --url
|
|
|
96
96
|
2. Generates `src/api/api.generated.ts` — TypeScript interfaces for all paths and operations (openapi-typescript)
|
|
97
97
|
3. Runs `scripts/gen-schemas.mjs`, which emits:
|
|
98
98
|
- `src/api/schemas.generated.ts` — Zod schemas inferred from `openapi.json` component schemas (circular refs use `z.lazy()`)
|
|
99
|
-
- `src/api/
|
|
99
|
+
- `src/api/embed-schemas.generated.ts` — strict embed API response schemas from `src/scripts/embed-schema-overrides.json` (see below)
|
|
100
|
+
- `src/api/cms-schemas.generated.ts` — CMS admin API response schemas from `src/scripts/cms-schema-overrides.json` (permanent)
|
|
100
101
|
|
|
101
102
|
Never edit `*.generated.ts` files by hand — they will be overwritten on the next generation run.
|
|
102
103
|
|
|
104
|
+
### embed-schema-overrides.json
|
|
105
|
+
|
|
106
|
+
`src/scripts/embed-schema-overrides.json` is a hand-maintained JSON Schema-like file that provides strict, fully-typed Zod schemas for the embed API responses. It exists because the live OpenAPI spec is incomplete in several ways:
|
|
107
|
+
|
|
108
|
+
- **`Media` is under-specified** — the spec has all fields optional; the real response has 20+ fields with required markers, and includes `signed2180Url`, `signed1080Url`, `signed720Url` that are absent from the spec entirely.
|
|
109
|
+
- **Embed-specific schemas are missing** — `PropertyResponseData`, `BootstrapData`, `UnitsByIdsResponse`, `FiltersResponseData`, and others do not exist in the spec at all.
|
|
110
|
+
- **Embed endpoint response types are wrong** — e.g. `/embed/{slug}/filters` declares `Unit[]` but actually returns a full filters + questionnaire payload.
|
|
111
|
+
|
|
112
|
+
`gen-schemas.mjs` reads the overrides file and compiles it into `embed-schemas.generated.ts` using a small code-generator that supports a subset of JSON Schema plus two escape hatches:
|
|
113
|
+
|
|
114
|
+
- **`"x-zod": "<expr>"`** — emits a raw Zod expression verbatim. Use this for types that can't be expressed in JSON Schema (e.g. `z.record(z.unknown())`, `z.union([...])`).
|
|
115
|
+
- **`"x-coerce": true`** — on a `string`/`date-time` field, emits `z.coerce.date()` instead of `z.string()`.
|
|
116
|
+
|
|
117
|
+
Fields listed in `"required"` are emitted without `.optional()`; all others get `.optional()`. `$ref` values resolve to `<Name>Schema` within the same file. Nullable fields use `"nullable": true` alongside their type.
|
|
118
|
+
|
|
119
|
+
**To remove the overrides** once the API spec is fixed, the spec needs:
|
|
120
|
+
1. Full `Media` shape with all required fields and the `signed*Url` variants
|
|
121
|
+
2. `PropertyResponseData`, `BootstrapData`, `UnitsByIdsResponse`, `FiltersResponseData`, and the remaining embed-specific schemas added as components
|
|
122
|
+
3. Correct response types on the embed endpoints that reference those components
|
|
123
|
+
|
|
124
|
+
Once those are in place, `embed-schemas.generated.ts` can be generated directly from `schemas.generated.ts` and the overrides file and its generator path can be removed.
|
|
125
|
+
|
|
103
126
|
## Development
|
|
104
127
|
|
|
105
128
|
```bash
|