Skip to content

Commit 222f13b

Browse files
authored
Initial commit
0 parents  commit 222f13b

33 files changed

+1052
-0
lines changed

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "20"
23+
24+
- name: Install
25+
run: npm ci
26+
27+
- name: Lint
28+
run: npm run lint

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.DS_Store
3+
.dist
4+
.npm
5+
.tshy
6+
.eslintcache
7+
dist

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.DS_Store
3+
.dist
4+
.npm
5+
.tshy
6+
.eslintcache
7+
dist

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing
2+
3+
Thanks for contributing! Please keep changes small and focused.
4+
5+
## Development
6+
7+
```bash
8+
npm install
9+
npm run lint
10+
npm run build
11+
```
12+
13+
## Conventions
14+
15+
- Mirror the core SDK structure: models, operations, funcs, sdk.
16+
- Use `zod/v4` and `.loose()` for forward compatibility.
17+
- Keep public types clean; transform HAL fields in schemas.

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Ominity
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

MODULES.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Module Template Notes
2+
3+
This template mirrors the core SDK structure and conventions:
4+
5+
- Models live in `src/models/**`
6+
- Operation types in `src/models/operations/**`
7+
- Funcs in `src/funcs/**`
8+
- SDK classes in `src/sdk/**`
9+
- Exports in `src/index.ts`
10+
11+
## HAL Behavior
12+
13+
- Public types should not expose `_links` or `_embedded`.
14+
- Use Zod `.transform()` to map `_links` -> `links` and `_embedded` to typed fields.
15+
- Use `.loose()` for forward compatibility.
16+
17+
## Pagination
18+
19+
- Use `buildPaginated()` and `applyPaginationParams()` from `@ominity/api-typescript/models`.
20+
- Page/limit are optional; API defaults to page 1 / limit 20.
21+
22+
## Module Wiring
23+
24+
- Export `bookingsModule()` (factory) and `BookingsModule` (prebuilt instance).
25+
- Use module augmentation so `ominity.modules.bookings` is typed.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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.

RENAME_CHECKLIST.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Rename Checklist
2+
3+
Use this when turning the template into a real module package.
4+
5+
1. Update `package.json`:
6+
- `name`
7+
- `tshy.sourceDialects`
8+
- `exports` (source dialect keys)
9+
- `peerDependencies` target version if needed
10+
11+
1. Update `jsr.json`:
12+
- `name`
13+
- `version`
14+
15+
1. Rename module identifiers:
16+
- `src/sdk/index.ts`: module name string (e.g. `"bookings"`)
17+
- `src/sdk/index.ts`: type names (e.g. `BookingsModule`)
18+
- `src/sdk/bookings` folder name
19+
- `src/models/bookings` folder name
20+
- `src/funcs/bookings` folder name
21+
22+
1. Update imports/exports:
23+
- `src/index.ts`
24+
- `src/models/index.ts`
25+
- `src/models/operations/index.ts`
26+
- `src/funcs/index.ts`
27+
- `src/sdk/index.ts`
28+
29+
1. Update README examples:
30+
- Package name
31+
- Module name
32+
- Example paths
33+
34+
1. Remove template markers:
35+
- Replace placeholder resource names (`BookingEvent`, `events`) with real ones
36+
- Replace `/modules/bookings/events` paths
37+

RUNTIMES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Runtimes
2+
3+
This SDK module targets Node.js and modern browsers.
4+
5+
- Node.js 20+ recommended.
6+
- Browser usage depends on CORS restrictions (cannot set User-Agent header).

USAGE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Usage
2+
3+
```ts
4+
import { Ominity } from "@ominity/api-typescript";
5+
import { bookingsModule } from "@ominity/api-modules-bookings";
6+
7+
const ominity = new Ominity({
8+
serverURL: "https://tenant-a.ominity.com/api",
9+
security: { apiKey: process.env["OMINITY_API_KEY"] ?? "" },
10+
modules: [bookingsModule()],
11+
});
12+
13+
const res = await ominity.modules.bookings.events.list({
14+
page: 1,
15+
limit: 20,
16+
});
17+
18+
console.log(res.items);
19+
```

0 commit comments

Comments
 (0)