@sudobility/music_types 0.1.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/CLAUDE.md +46 -0
- package/README.md +42 -0
- package/dist/index.d.ts +1597 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +278 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @sudobility/music_types
|
|
2
|
+
|
|
3
|
+
TypeScript types and Zod schemas for the ScoreSmith music family (music_api, music_client, music_lib, music_app).
|
|
4
|
+
|
|
5
|
+
## Tech Stack
|
|
6
|
+
|
|
7
|
+
- TypeScript (strict), ESM only, built with `tsc -p tsconfig.esm.json`
|
|
8
|
+
- Zod v4 schemas (runtime dependency — schemas are exported values)
|
|
9
|
+
- Bun for scripts, vitest for tests
|
|
10
|
+
- Published to npm as `@sudobility/music_types` (public access) via CI on push to main
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
- `bun install` — install dependencies
|
|
15
|
+
- `bun run verify` — typecheck + lint + test + build (run before any push)
|
|
16
|
+
- `bun run test` — vitest (tests co-located in `src/*.test.ts`)
|
|
17
|
+
- `bun run build` — emit `dist/`
|
|
18
|
+
|
|
19
|
+
## Structure
|
|
20
|
+
|
|
21
|
+
Everything exports from a single sectioned `src/index.ts`:
|
|
22
|
+
|
|
23
|
+
1. Score model types (Score/Track/Measure/Voice/NoteEvent/RestEvent, DurationName, Clef, …)
|
|
24
|
+
2. Type guards (`isNoteEvent`, `isRestEvent`)
|
|
25
|
+
3. Selection/fragment types (`ScoreRange`, `ScoreSelection`, `ScoreFragment`)
|
|
26
|
+
4. Zod schemas for the score tree (`scoreSchema`, `parseScore`, …)
|
|
27
|
+
5. AI generation contracts (`GenerateScoreRequest` → `GenerateScoreResult`, `RegenerateRegionRequest` → `RegenerateRegionResult`, `MusicGenerationProvider`)
|
|
28
|
+
6. Zod schemas for the generation contracts (`parseGenerateScoreRequest`, …)
|
|
29
|
+
7. Project API types (`ProjectRecord`, `ProjectSummary`, `ProjectCreateRequest`, `ProjectUpdateRequest`, `ProjectListQuery`)
|
|
30
|
+
8. Zod schemas for the project API
|
|
31
|
+
9. Response envelope (`ApiResponse<T>`, `successResponse`, `errorResponse`, `API_ERROR_CODES`)
|
|
32
|
+
|
|
33
|
+
`src/test-helpers.ts` is a test-only factory stand-in (excluded from the published build); the real factories live in `@sudobility/music_lib`.
|
|
34
|
+
|
|
35
|
+
## Gotchas
|
|
36
|
+
|
|
37
|
+
- No domain logic here: tick math, factories, commands, validation logic all live in `@sudobility/music_lib`. This package must never depend on music_lib (music_api depends on this package and must not pull in UI/audio code).
|
|
38
|
+
- `noteEventSchema`/`restEventSchema` are `.strict()` on purpose (a stray `pitch` key must not pass as a rest); other schemas strip unknown keys for forward compatibility.
|
|
39
|
+
- Ticks are integers at 480 PPQ by convention; `startTick` is absolute.
|
|
40
|
+
|
|
41
|
+
## Related Projects
|
|
42
|
+
|
|
43
|
+
- `music_api` — backend (Hono/Drizzle/OpenAI proxy), consumes schemas for validation
|
|
44
|
+
- `music_client` — typed network client + React Query hooks
|
|
45
|
+
- `music_lib` — domain logic, adapters, store
|
|
46
|
+
- `music_app` — web app (UI/routing only)
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @sudobility/music_types
|
|
2
|
+
|
|
3
|
+
Shared TypeScript types and Zod schemas for the ScoreSmith music platform: the score data model, AI generation contracts, project API payloads, and the standard API response envelope.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @sudobility/music_types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {
|
|
15
|
+
type Score,
|
|
16
|
+
parseScore,
|
|
17
|
+
type GenerateScoreRequest,
|
|
18
|
+
successResponse,
|
|
19
|
+
} from '@sudobility/music_types';
|
|
20
|
+
|
|
21
|
+
const score: Score = parseScore(untrustedJson); // throws ZodError on invalid input
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API Summary
|
|
25
|
+
|
|
26
|
+
- **Score model** — `Score`, `Track`, `Measure`, `Voice`, `NoteEvent`, `RestEvent`, guards `isNoteEvent`/`isRestEvent`
|
|
27
|
+
- **Selection/fragments** — `ScoreRange`, `ScoreSelection`, `ScoreFragment`
|
|
28
|
+
- **Zod schemas** — `scoreSchema` tree + `parseScore`
|
|
29
|
+
- **Generation contracts** — `GenerateScoreRequest`/`GenerateScoreResult`, `RegenerateRegionRequest`/`RegenerateRegionResult`, `MusicGenerationProvider`, with schemas and `parse*` helpers
|
|
30
|
+
- **Project API** — `ProjectRecord`, `ProjectSummary`, create/update/list-query types + schemas
|
|
31
|
+
- **Envelope** — `ApiResponse<T>`, `successResponse`, `errorResponse`, `API_ERROR_CODES`
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun install
|
|
37
|
+
bun run verify # typecheck + lint + test + build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
BUSL-1.1
|