@ipetsadmin/contracts 1.3.0 → 1.3.1
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/CHANGELOG.md +27 -1
- package/README.md +42 -7
- package/dist/index.d.mts +11 -0
- package/dist/index.d.ts +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
19
19
|
|
|
20
20
|
### Security
|
|
21
21
|
|
|
22
|
+
## [1.3.1] - 2026-05-15
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- **Pet model (expanded beyond 1.2.0)**
|
|
27
|
+
- Enums: **`PetStatus`**, **`WeightUnit`**.
|
|
28
|
+
- **`IPet`**: weight, microchip fields, **`allergies`** (**`IAllergy`**), **`vaccines`** (**`IVaccine`**), **`photos`**, **`status`**, timestamps; discriminated union by **`species`** (**`DogBreed`** / **`CatBreed`**).
|
|
29
|
+
- **Pet API contracts**
|
|
30
|
+
- **`IPetService`**: `getPetById`, `getPetsByUserId`, `createPet`, `updatePet` (optional **`RepositoryOperationOptions`**).
|
|
31
|
+
- **`PetResponse`**: type alias for **`IPet`**.
|
|
32
|
+
- **`IPetRepository`**: **`update`** with partial **`CreatePetInput`**.
|
|
33
|
+
- **Treatment domain**
|
|
34
|
+
- Entity **`ITreatment`**; enums **`TreatmentStatus`**, **`TreatmentType`**.
|
|
35
|
+
- **`CreateTreatmentInput`**, **`TreatmentResponse`** (= **`ITreatment`**).
|
|
36
|
+
- **`ITreatmentRepository`**: `create`, `update`, `findById`, `findByPetId`, `delete`.
|
|
37
|
+
- **Dose domain**
|
|
38
|
+
- Entity **`IDose`** (scheduled vs administered dates, **`DoseStatus`**, optional notes).
|
|
39
|
+
- **`CreateDoseInput`**, **`DoseResponse`** (= **`IDose`**).
|
|
40
|
+
- **`IDoseRepository`**: `create`, `findById`, `findByTreatmentId`, `delete`, `deleteByTreatmentId`.
|
|
41
|
+
- **Treatment service**
|
|
42
|
+
- **`ITreatmentService`**: `createTreatment`, `updateTreatment`, `updateTreatmentStatus`, `getTreatmentById` (returns treatment **and nested `doses`**), `getTreatmentsByPetId`, `deleteTreatment`, **`getDosesByTreatmentId`**, **`createDose`**.
|
|
43
|
+
|
|
44
|
+
### Fixed
|
|
45
|
+
|
|
46
|
+
- **CHANGELOG [1.2.0]**: **`CreatePetInput`** lives under **`src/types/pet/CreatePetInput.ts`**, not `src/types/auth/`.
|
|
47
|
+
|
|
22
48
|
## [1.2.0] - 2026-05-12
|
|
23
49
|
|
|
24
50
|
### Added
|
|
@@ -26,7 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
52
|
- **Pet domain**:
|
|
27
53
|
- **`IPet`** entity: `name`, **`birthDate`**, **`breed`** (dog or cat), **`species`**, **`gender`**, **`ownerId`**, **`photos`**, and timestamps.
|
|
28
54
|
- **`IPetRepository`** port: `create`, **`findById`**, **`findByOwnerId`** (Mongo implementation in **`api-main`**; adapters can reuse the contract).
|
|
29
|
-
- **`CreatePetInput`**: payload for **`create`** (`src/types/
|
|
55
|
+
- **`CreatePetInput`**: payload for **`create`** (`src/types/pet/CreatePetInput.ts`).
|
|
30
56
|
- **Pet enums** (**`Gender`**, **`Species`**, **`DogBreed`**, **`CatBreed`**) under **`src/enums/`**, used by **`IPet`** and **`CreatePetInput`**.
|
|
31
57
|
|
|
32
58
|
## [1.1.9] - 2026-04-25
|
package/README.md
CHANGED
|
@@ -44,10 +44,10 @@ import {
|
|
|
44
44
|
IServerInit,
|
|
45
45
|
OAuthProvider,
|
|
46
46
|
type AuthSessionResponse,
|
|
47
|
+
type IUser,
|
|
47
48
|
type LoginRequest,
|
|
48
49
|
type RegisterRequest,
|
|
49
50
|
type TokenPair,
|
|
50
|
-
type User,
|
|
51
51
|
BaseError,
|
|
52
52
|
BusinessError,
|
|
53
53
|
ForbiddenError,
|
|
@@ -69,7 +69,7 @@ const health: IApiResponse<HealthCheck> = {
|
|
|
69
69
|
The package defines **shared contracts** for email/password and OAuth (Google via Auth0 on the server), **API-issued JWTs** (access) and **opaque refresh tokens** (server-side storage only—hashes are not part of the public types):
|
|
70
70
|
|
|
71
71
|
- **Enums:** `AuthMethod` (`password` | `oauth`), `OAuthProvider` (e.g. `GOOGLE`, extensible later).
|
|
72
|
-
- **Entities / DTOs:**
|
|
72
|
+
- **Entities / DTOs:** **`IUser`**, `TokenPair`, `AuthUserResponse`, `AuthSessionResponse`, `RegisterRequest`, `LoginRequest`, `RefreshRequest`, `LogoutRequest`, OAuth Google start/callback types, `CreateUserInput`.
|
|
73
73
|
- **Repository ports (implementations live in services):** `IUserRepository`, `IRefreshTokenRepository`, `IOAuthStateRepository` — keep domain types free of MongoDB/Passport imports so SQL or other adapters can implement the same interfaces later.
|
|
74
74
|
- **Service ports** (`interfaces/services/`): `IAuthService`, `IJwtTokensService`, `IAuth0GoogleOAuthService` — implemented by the API’s concrete classes for DI, testing, and clear boundaries.
|
|
75
75
|
- **Auth0/OIDC helpers:** `Auth0UserProfile`, `Auth0AuthorizationParams`, `OAuthAccessTokenResult`.
|
|
@@ -78,6 +78,36 @@ The package defines **shared contracts** for email/password and OAuth (Google vi
|
|
|
78
78
|
|
|
79
79
|
Path aliases (`@/…`) apply only inside this package’s source; consumers import from `@ipetsadmin/contracts` as above.
|
|
80
80
|
|
|
81
|
+
### Pets, treatments, and doses
|
|
82
|
+
|
|
83
|
+
Shared model for veterinary **pets**, **medication/surgery treatments**, and scheduled **doses** (consumers: **`@ipetsadmin/api-main`**, **`@ipetsadmin/api-client`**, etc.):
|
|
84
|
+
|
|
85
|
+
| Area | Highlights |
|
|
86
|
+
| --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
87
|
+
| **Pet** | **`IPet`**: discriminated **`species`** (dog vs cat) with matching **`breed`**, demographics, **`PetStatus`**, **`WeightUnit`**, allergies, vaccines, microchip fields, **`photos`**, timestamps. **`PetResponse`** is an alias for **`IPet`**. **`CreatePetInput`** is used for **`IPetRepository.create`** / **`IPetService`**. **`IPetRepository`**: **`create`**, **`findById`**, **`findByOwnerId`**, **`update`** (partial input). **`IPetService`**: **`getPetById`**, **`getPetsByUserId`**, **`createPet`**, **`updatePet`**. |
|
|
88
|
+
| **Treatment** | **`ITreatment`** (medication line, dosing schedule, **`TreatmentStatus`** / **`TreatmentType`**, optional start/end dates). **`CreateTreatmentInput`**, **`TreatmentResponse`**. **`ITreatmentRepository`**: **`create`**, **`update`**, **`findById`**, **`findByPetId`**, **`delete`**. |
|
|
89
|
+
| **Dose** | **`IDose`** links **`treatmentId`**, **`petId`**, **`ownerId`**; **`doseNumber`**, **`scheduledDate`**, optional **`actualAdministeredDate`**, **`DoseStatus`**, optional **`notes`**. **`CreateDoseInput`**, **`DoseResponse`**. **`IDoseRepository`**: **`create`**, **`findById`**, **`findByTreatmentId`**, **`delete`**, **`deleteByTreatmentId`**. |
|
|
90
|
+
| **Treatment application service** | **`ITreatmentService`**: **`createTreatment`**, **`updateTreatment`**, **`updateTreatmentStatus`**, **`getTreatmentById`** (treatment plus nested **`doses`**), **`getTreatmentsByPetId`**, **`deleteTreatment`**, **`getDosesByTreatmentId`**, **`createDose`**. All methods optionally accept **`RepositoryOperationOptions`** (e.g. Mongo session for transactions). |
|
|
91
|
+
|
|
92
|
+
Related enums (**`Species`**, **`DogBreed`**, **`CatBreed`**, **`Gender`**, **`PetStatus`**, **`WeightUnit`**, **`TreatmentStatus`**, **`TreatmentType`**, **`DoseStatus`**) live under **`src/enums/`** and are re-exported from the package root.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import {
|
|
96
|
+
type CreatePetInput,
|
|
97
|
+
type CreateTreatmentInput,
|
|
98
|
+
type CreateDoseInput,
|
|
99
|
+
type IPet,
|
|
100
|
+
type ITreatment,
|
|
101
|
+
type IDose,
|
|
102
|
+
type IPetService,
|
|
103
|
+
type ITreatmentService,
|
|
104
|
+
PetStatus,
|
|
105
|
+
TreatmentType,
|
|
106
|
+
TreatmentStatus,
|
|
107
|
+
DoseStatus,
|
|
108
|
+
} from '@ipetsadmin/contracts';
|
|
109
|
+
```
|
|
110
|
+
|
|
81
111
|
The published package is **dual CJS + ESM** (`exports.require` → `dist/index.js`, `exports.import` → `dist/index.mjs`).
|
|
82
112
|
That way **`import { BaseError, BusinessError } from '@ipetsadmin/contracts'`** works in ESM projects (`"type": "module"`,
|
|
83
113
|
Vite, etc.), and **`require('@ipetsadmin/contracts')`** still works in CommonJS. Use TypeScript
|
|
@@ -126,14 +156,15 @@ pnpm install
|
|
|
126
156
|
|
|
127
157
|
Source lives under `src/`:
|
|
128
158
|
|
|
129
|
-
- `enums/` — shared enums (
|
|
159
|
+
- `enums/` — shared enums (`Errors`, `HealthStatus`, `AuthMethod`, `OAuthProvider`, `Species`, `PetStatus`, `TreatmentStatus`, `TreatmentType`, `DoseStatus`, …)
|
|
130
160
|
- `errors/` — error classes (`BaseError`, domain errors, …)
|
|
161
|
+
- `interfaces/entities/` — domain entities (`IUser`, `IPet`, `ITreatment`, `IDose`; nested types such as **`IAllergy`**, **`IVaccine`** on **`IPet`**)
|
|
131
162
|
- `interfaces/general/` — cross-cutting interfaces (`IConfig`, pagination, API responses, server bootstrap types, …)
|
|
132
|
-
- `interfaces/
|
|
133
|
-
- `interfaces/services/` — service ports (`IAuthService`, `IJwtTokensService`, `IAuth0GoogleOAuthService`)
|
|
134
|
-
- `types/` —
|
|
163
|
+
- `interfaces/repositories/` — persistence ports (`IUserRepository`, `IPetRepository`, `ITreatmentRepository`, `IDoseRepository`, …) plus **`repositories/auth/`** for refresh/oauth tokens
|
|
164
|
+
- `interfaces/services/` — application service ports (`IAuthService`, `IJwtTokensService`, `IAuth0GoogleOAuthService`, `IUserService`, `IPetService`, `ITreatmentService`, email subfolder, …)
|
|
165
|
+
- `types/` — DTOs and aliases (`types/auth/`, `types/pet/`, `types/treatment/`, `types/dose/`, `types/user/`, `types/email/`, `HealthCheck`, `RepositoryOperationOptions`, …)
|
|
135
166
|
|
|
136
|
-
The public API is whatever `src/index.ts` re-exports. Additional
|
|
167
|
+
The public API is whatever `src/index.ts` re-exports. Additional definitions under `src/` only appear for consumers when listed there.
|
|
137
168
|
|
|
138
169
|
## Serverless / private registry notes
|
|
139
170
|
|
|
@@ -153,6 +184,10 @@ package:
|
|
|
153
184
|
|
|
154
185
|
Dependencies resolve at build time; ensure registry or Git access is configured for private packages.
|
|
155
186
|
|
|
187
|
+
## Changelog
|
|
188
|
+
|
|
189
|
+
Release notes live in [CHANGELOG.md](./CHANGELOG.md) (Keep a Changelog).
|
|
190
|
+
|
|
156
191
|
## License
|
|
157
192
|
|
|
158
193
|
See [LICENSE](./LICENSE) (MIT).
|
package/dist/index.d.mts
CHANGED
|
@@ -625,6 +625,17 @@ interface ITreatmentService {
|
|
|
625
625
|
}>;
|
|
626
626
|
getTreatmentsByPetId(petId: string, options?: RepositoryOperationOptions): Promise<ITreatment[]>;
|
|
627
627
|
deleteTreatment(id: string, options?: RepositoryOperationOptions): Promise<void>;
|
|
628
|
+
getDosesByTreatmentId(params: {
|
|
629
|
+
treatmentId: string;
|
|
630
|
+
petId: string;
|
|
631
|
+
ownerId: string;
|
|
632
|
+
}, options?: RepositoryOperationOptions): Promise<IDose[]>;
|
|
633
|
+
createDose(params: {
|
|
634
|
+
treatmentId: string;
|
|
635
|
+
petId: string;
|
|
636
|
+
ownerId: string;
|
|
637
|
+
input: CreateDoseInput;
|
|
638
|
+
}, options?: RepositoryOperationOptions): Promise<IDose>;
|
|
628
639
|
}
|
|
629
640
|
|
|
630
641
|
declare enum Errors {
|
package/dist/index.d.ts
CHANGED
|
@@ -625,6 +625,17 @@ interface ITreatmentService {
|
|
|
625
625
|
}>;
|
|
626
626
|
getTreatmentsByPetId(petId: string, options?: RepositoryOperationOptions): Promise<ITreatment[]>;
|
|
627
627
|
deleteTreatment(id: string, options?: RepositoryOperationOptions): Promise<void>;
|
|
628
|
+
getDosesByTreatmentId(params: {
|
|
629
|
+
treatmentId: string;
|
|
630
|
+
petId: string;
|
|
631
|
+
ownerId: string;
|
|
632
|
+
}, options?: RepositoryOperationOptions): Promise<IDose[]>;
|
|
633
|
+
createDose(params: {
|
|
634
|
+
treatmentId: string;
|
|
635
|
+
petId: string;
|
|
636
|
+
ownerId: string;
|
|
637
|
+
input: CreateDoseInput;
|
|
638
|
+
}, options?: RepositoryOperationOptions): Promise<IDose>;
|
|
628
639
|
}
|
|
629
640
|
|
|
630
641
|
declare enum Errors {
|