|
| 1 | +# Ominity API Module Template |
| 2 | + |
| 3 | +This is a template repo for creating a modular Ominity API package that plugs into `@ominity/api-typescript`. |
| 4 | + |
| 5 | +See `RENAME_CHECKLIST.md` for the exact rename steps. |
| 6 | + |
| 7 | +## What to Rename |
| 8 | + |
| 9 | +- Package name in `package.json` |
| 10 | +- Source dialect in `package.json` (`@ominity/api-modules-template/source`) |
| 11 | +- Module name inside `src/sdk/index.ts` |
| 12 | +- Folder names under `src/models` and `src/funcs` |
| 13 | +- README examples |
| 14 | + |
| 15 | +If you plan to publish, remove `"private": true` in `package.json`. |
| 16 | + |
| 17 | +## Install |
| 18 | + |
| 19 | +```bash |
| 20 | +npm install @ominity/api-typescript |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage (example) |
| 24 | + |
| 25 | +```ts |
| 26 | +import { Ominity } from "@ominity/api-typescript"; |
| 27 | +import { bookingsModule, BookingsModule } from "@ominity/api-modules-bookings"; |
| 28 | + |
| 29 | +const ominity = new Ominity({ |
| 30 | + serverURL: "https://tenant-a.ominity.com/api", |
| 31 | + security: { apiKey: process.env["OMINITY_API_KEY"] ?? "" }, |
| 32 | +}); |
| 33 | + |
| 34 | +// Either option is supported |
| 35 | +ominity.use(BookingsModule); |
| 36 | +// or |
| 37 | +ominity.use(bookingsModule()); |
| 38 | + |
| 39 | +// Constructor option |
| 40 | +const ominity2 = new Ominity({ |
| 41 | + serverURL: "https://tenant-a.ominity.com/api", |
| 42 | + security: { apiKey: process.env["OMINITY_API_KEY"] ?? "" }, |
| 43 | + modules: [bookingsModule()], |
| 44 | +}); |
| 45 | + |
| 46 | +const res = await ominity.modules.bookings.events.list({ page: 1, limit: 20 }); |
| 47 | +console.log(res.items); |
| 48 | +``` |
| 49 | + |
| 50 | +## Structure |
| 51 | + |
| 52 | +``` |
| 53 | +src/ |
| 54 | + funcs/ |
| 55 | + models/ |
| 56 | + models/operations/ |
| 57 | + sdk/ |
| 58 | + index.ts |
| 59 | +``` |
| 60 | + |
| 61 | +## Development |
| 62 | + |
| 63 | +```bash |
| 64 | +npm run lint |
| 65 | +npm run build |
| 66 | +``` |
| 67 | + |
| 68 | +## Notes |
| 69 | + |
| 70 | +- This template mirrors the core SDK architecture (models, operations, funcs, sdk). |
| 71 | +- HAL responses are transformed; public types should not expose `_links` or `_embedded`. |
| 72 | +- Use `zod/v4` and `.loose()` for forward compatibility. |
0 commit comments