dryvPacks

@dryv/typescriptv0.3.0

Shared TypeScript enums, type aliases and schema interfaces for other packs to import.

TypeScript typesTypesInjectPublished 7 days ago2 downloads

dryv pack add @dryv/typescript
3.3 KBRaw ↗

TypeScript types pack

Generates framework-free TypeScript declarations once per IR property and schema, under <group>/, in a folder for each kind (enum/, type/, interface/), so other packs import them instead of generating their own copies:

IROutputExample
property.enumenum/<name>.enum.tsexport enum UserStatus { ACTIVE = "active" }
named property.primitivetype/<name>.type.tsexport type Email = string;
property.temporaltype/<name>.type.tsexport type CreatedAt = string; (ISO-8601 text)
property.literaltype/<name>.type.tsexport type ActiveStatus = "active";
property.uniontype/<name>.type.tsexport type UserLookup = DisplayName | UserId;
property.record / property.tupletype/<name>.type.tsRecord<string, string>, [number, number]
property.generictype/<name>.type.tsexport type Page<T> = { items: Array<T>; total: Count }; / Page<UserProfile>
property.compositetype/<name>.type.tsexport interface NamePair { … }
schemainterface/<name>.interface.tsexport interface UserProfile { … }

Stored schemas (role entity) are not selected: a project's own entity types, for example a type-files pack, own those, so no duplicate interface is generated. Other schemas (query rows, inputs, responses) are.

It provides property.enum.types, property.types (one template per property kind) and schema.types. DTO, entity and server packs need those slots and import the declarations through Usage bind.

Inline types inside a property definition are rendered to three levels of nesting. A deeper inline type renders DryvTypeNestingTooDeep, which fails type checking and names the problem; references to other named properties or schemas don't count toward the limit.

unknown fields render unknown; dynamic fields render Record<string, unknown>.

Test: bun scripts/test-pack.ts inject/types/typescript renders the shared fixture IR, typechecks every declaration and checks representative shapes.

Layout. Enums, named types and non-entity interfaces are written under <group>/schema/enum/, schema/type/ and schema/interface/.

When a response or generic type refers to a stored entity owned by another pack, bind the optional schema.entity.types need to that entity-type owner. Internal non-entity schemas remain generated here. Missing external ownership must be resolved explicitly; the pack does not invent another entity interface. The NestJS fixture demonstrates the binding.