@tiboli/types 0.0.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/.editorconfig +39 -0
- package/.github/CODE_OF_CONDUCT.md +59 -0
- package/.github/CONTRIBUTING.md +148 -0
- package/.github/workflows/ci.yml +36 -0
- package/.github/workflows/release.yml +108 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.prettierignore +3 -0
- package/.prettierrc +19 -0
- package/README.md +7 -0
- package/eslint.config.mjs +112 -0
- package/jest.config.js +11 -0
- package/package.json +78 -0
- package/src/index.ts +2 -0
- package/src/schemas/book.schema.ts +10 -0
- package/src/schemas/copy.schema.ts +9 -0
- package/src/schemas/customer.schema.ts +11 -0
- package/src/schemas/group.schema.ts +9 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/loan.schema.ts +13 -0
- package/src/types/book.type.ts +6 -0
- package/src/types/copy.type.ts +6 -0
- package/src/types/customer.type.ts +6 -0
- package/src/types/group.types.ts +6 -0
- package/src/types/index.ts +9 -0
- package/src/types/loan.type.ts +6 -0
- package/test/schemas/book.schema.test.ts +20 -0
- package/tsconfig.json +21 -0
package/.editorconfig
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
indent_style = tab
|
|
6
|
+
indent_size = 4
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
charset = utf-8
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
insert_final_newline = true
|
|
11
|
+
|
|
12
|
+
# The JSON files contain newlines inconsistently
|
|
13
|
+
[*.json]
|
|
14
|
+
insert_final_newline = ignore
|
|
15
|
+
|
|
16
|
+
# Minified JavaScript files shouldn't be changed
|
|
17
|
+
[**.min.js]
|
|
18
|
+
indent_style = ignore
|
|
19
|
+
insert_final_newline = ignore
|
|
20
|
+
|
|
21
|
+
# Makefiles always use tabs for indentation
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
24
|
+
|
|
25
|
+
# Batch files use tabs for indentation
|
|
26
|
+
[*.bat]
|
|
27
|
+
indent_style = tab
|
|
28
|
+
|
|
29
|
+
[*.md]
|
|
30
|
+
trim_trailing_whitespace = false
|
|
31
|
+
|
|
32
|
+
[*.yml]
|
|
33
|
+
indent_style = space
|
|
34
|
+
indent_size = 2
|
|
35
|
+
insert_final_newline = false
|
|
36
|
+
[*.yaml]
|
|
37
|
+
indent_style = space
|
|
38
|
+
indent_size = 2
|
|
39
|
+
insert_final_newline = false
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We, as contributors and maintainers, pledge to make participation in this project and our community a welcoming, inclusive, and respectful experience for everyone.
|
|
6
|
+
We are committed to ensuring that all people, regardless of age, body size, visible or invisible disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation, feel safe and valued.
|
|
7
|
+
|
|
8
|
+
## Our Standards
|
|
9
|
+
|
|
10
|
+
Examples of behavior that contributes to a positive environment include:
|
|
11
|
+
|
|
12
|
+
- Being respectful, kind, and patient in all interactions
|
|
13
|
+
- Giving and gracefully accepting constructive feedback
|
|
14
|
+
- Using inclusive language and assuming good intent
|
|
15
|
+
- Helping others understand and grow, especially newcomers
|
|
16
|
+
- Focusing on what is best for the community and project
|
|
17
|
+
|
|
18
|
+
Examples of unacceptable behavior include:
|
|
19
|
+
|
|
20
|
+
- Harassment, discrimination, or personal attacks
|
|
21
|
+
- Trolling, insulting or derogatory comments, and personal or political fights
|
|
22
|
+
- Publishing others’ private information without permission
|
|
23
|
+
- Excessive negativity, sarcasm, or unconstructive criticism
|
|
24
|
+
- Any behavior that could make others feel unsafe or unwelcome
|
|
25
|
+
|
|
26
|
+
## Our Responsibilities
|
|
27
|
+
|
|
28
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take fair and consistent corrective action in response to any unacceptable conduct.
|
|
29
|
+
|
|
30
|
+
Maintainers have the right and responsibility to remove, edit, or reject contributions that are not aligned with this Code of Conduct (such as comments, commits, code, issues, or pull requests), and may temporarily or permanently ban contributors for behavior they deem inappropriate, threatening, or harmful.
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
|
|
34
|
+
This Code of Conduct applies both within project spaces (such as issues, pull requests, and discussions) and in public spaces when an individual is representing the project or its community.
|
|
35
|
+
|
|
36
|
+
Examples include using an official project email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
37
|
+
|
|
38
|
+
## Enforcement
|
|
39
|
+
|
|
40
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project maintainers at:
|
|
41
|
+
|
|
42
|
+
📧 **[[your-contact@example.com](mailto:your-contact@example.com)]**
|
|
43
|
+
(Replace this with your real contact email or a team alias.)
|
|
44
|
+
|
|
45
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
46
|
+
Maintainers are obligated to respect the privacy and safety of reporters of incidents.
|
|
47
|
+
|
|
48
|
+
## Enforcement Guidelines
|
|
49
|
+
|
|
50
|
+
Project maintainers will follow these steps when handling violations:
|
|
51
|
+
|
|
52
|
+
1. **Warning** – A private, written warning for minor violations.
|
|
53
|
+
2. **Temporary Ban** – For repeated or serious violations, temporary removal from participation.
|
|
54
|
+
3. **Permanent Ban** – For sustained harmful behavior, permanent removal from the community.
|
|
55
|
+
|
|
56
|
+
## Attribution
|
|
57
|
+
|
|
58
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1, available at:
|
|
59
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html](https://www.contributor-covenant.org/version/2/1/code_of_conduct.html)
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Contributing Guidelines
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing! 🎉
|
|
4
|
+
We value clear communication, respectful collaboration, and clean, maintainable code.
|
|
5
|
+
Please take a few minutes to review these guidelines before submitting your first pull request (PR).
|
|
6
|
+
|
|
7
|
+
## 🧭 Branching Strategy
|
|
8
|
+
|
|
9
|
+
We follow a simplified Git Flow model:
|
|
10
|
+
|
|
11
|
+
- **`main`**
|
|
12
|
+
- Contains _production-ready_ code only.
|
|
13
|
+
- Protected branch — no direct commits or pushes allowed.
|
|
14
|
+
- Only receives changes via PRs from `develop` after testing and review.
|
|
15
|
+
- Each merge triggers a release tag using the version from `package.json`.
|
|
16
|
+
|
|
17
|
+
- **`develop`**
|
|
18
|
+
- The integration branch for active development.
|
|
19
|
+
- Receives merged `feature/*` branches.
|
|
20
|
+
- CI ensures all builds, lints, and tests pass before promotion to `main`.
|
|
21
|
+
|
|
22
|
+
- **`feature/*`**
|
|
23
|
+
- For individual features, fixes, or small experiments.
|
|
24
|
+
- Branch off from `develop` and merge back into `develop` via PR.
|
|
25
|
+
- Keep them **short-lived** and **focused on one topic**.
|
|
26
|
+
|
|
27
|
+
## 🔄 Development Workflow
|
|
28
|
+
|
|
29
|
+
1. **Create a Feature Branch**
|
|
30
|
+
From `develop`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git checkout develop
|
|
34
|
+
git pull
|
|
35
|
+
git checkout -b feature/your-feature-name
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. **Make Small, Clear Commits**
|
|
39
|
+
- Commit frequently and keep each commit focused on a single logical change.
|
|
40
|
+
- Avoid bundling unrelated edits in the same commit.
|
|
41
|
+
- Use meaningful messages (see [Commit Style](#-commit-style) below).
|
|
42
|
+
- Run tests and lint before committing:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm run lint
|
|
46
|
+
npm test
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. **Push and Open a Pull Request (PR)**
|
|
50
|
+
- Push your branch and open a PR targeting `develop`.
|
|
51
|
+
- Clearly describe what your change does and _why_ it’s needed.
|
|
52
|
+
- If your PR closes an issue, reference it in the description (e.g. “Fixes #42”).
|
|
53
|
+
- Keep your PRs small — large ones are harder to review.
|
|
54
|
+
|
|
55
|
+
4. **Continuous Integration (CI)**
|
|
56
|
+
All pushes and PRs trigger automated:
|
|
57
|
+
- Linting
|
|
58
|
+
- Build checks (`npm run build`)
|
|
59
|
+
- Tests (`npm test`)
|
|
60
|
+
|
|
61
|
+
5. **Merge Process**
|
|
62
|
+
- Wait for CI to pass and code review approval.
|
|
63
|
+
- Avoid rebasing public branches; use `git merge develop` to stay up-to-date.
|
|
64
|
+
- Once approved, the branch is merged into `develop`.
|
|
65
|
+
|
|
66
|
+
6. **Prepare a Release**
|
|
67
|
+
When `develop` is stable and tested, open a PR to merge into `main`.
|
|
68
|
+
|
|
69
|
+
7. **Release & Tagging**
|
|
70
|
+
On merge to `main`, a GitHub Action automatically:
|
|
71
|
+
- Reads the `version` in `package.json`
|
|
72
|
+
- Creates a tag (e.g. `v1.2.3`)
|
|
73
|
+
- Publishes a GitHub Release with autogenerated notes
|
|
74
|
+
|
|
75
|
+
## 🧩 Versioning
|
|
76
|
+
|
|
77
|
+
We use [Semantic Versioning](https://semver.org/) — `MAJOR.MINOR.PATCH`.
|
|
78
|
+
|
|
79
|
+
### Version Bump Workflow
|
|
80
|
+
|
|
81
|
+
1. Create a new branch from `develop`:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git checkout -b version-bump/1.2.3
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
2. Update the `"version"` field in `package.json`.
|
|
88
|
+
3. Commit with:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
chore: bump version to 1.2.3
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
4. Open a PR targeting `develop`.
|
|
95
|
+
5. After CI and review, merge into `develop`.
|
|
96
|
+
6. When `develop` merges into `main`, the release workflow tags and publishes automatically.
|
|
97
|
+
|
|
98
|
+
## ✍️ Commit Style
|
|
99
|
+
|
|
100
|
+
Please use clear, consistent, and meaningful commit messages.
|
|
101
|
+
Follow this general structure:
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
<type>: short description
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Types:**
|
|
108
|
+
|
|
109
|
+
- `feat:` – new feature
|
|
110
|
+
- `fix:` – bug fix
|
|
111
|
+
- `chore:` – maintenance, tooling, version bumps
|
|
112
|
+
- `docs:` – documentation changes
|
|
113
|
+
- `test:` – add or update tests
|
|
114
|
+
- `refactor:` – code improvement without functional change
|
|
115
|
+
|
|
116
|
+
**Examples:**
|
|
117
|
+
|
|
118
|
+
- `feat: add search filter for book titles`
|
|
119
|
+
- `fix: correct null pointer on user login`
|
|
120
|
+
- `docs: update setup instructions`
|
|
121
|
+
|
|
122
|
+
## 🤝 Collaboration & Behavior
|
|
123
|
+
|
|
124
|
+
We’re building a welcoming, respectful community. Please:
|
|
125
|
+
|
|
126
|
+
- Be **kind**, **patient**, and **constructive** in discussions and reviews.
|
|
127
|
+
- Avoid personal remarks — focus on the code, not the coder.
|
|
128
|
+
- Use **inclusive language** and assume good intent.
|
|
129
|
+
- Respect the existing code style and project conventions.
|
|
130
|
+
- Ask before making large-scale refactors or changes that affect multiple areas.
|
|
131
|
+
- Keep your PRs **small and focused** — it helps everyone review faster and with fewer conflicts.
|
|
132
|
+
|
|
133
|
+
If you’re unsure about something, open a **Draft PR** or start a **Discussion** — collaboration is always better than guessing.
|
|
134
|
+
|
|
135
|
+
## 🧰 Building Locally
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm install
|
|
139
|
+
npm run build
|
|
140
|
+
npm test
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Run the test suite before committing to ensure everything works as expected.
|
|
144
|
+
|
|
145
|
+
## 🙌 Thank You!
|
|
146
|
+
|
|
147
|
+
Your time and contributions make this project better for everyone.
|
|
148
|
+
We appreciate every PR, suggestion, and improvement — even small ones!
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- develop
|
|
7
|
+
- "feature/**"
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- develop
|
|
11
|
+
- main
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build-test:
|
|
15
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version-file: .nvmrc
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Lint code
|
|
30
|
+
run: npm run lint
|
|
31
|
+
|
|
32
|
+
- name: Build TypeScript
|
|
33
|
+
run: npm run build
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: npm run test
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
name: Generate Release Tag from package.json and Publish to NPM
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
lint:
|
|
10
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout code
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
- name: Setup Node.js
|
|
15
|
+
uses: actions/setup-node@v4
|
|
16
|
+
with:
|
|
17
|
+
node-version-file: .nvmrc
|
|
18
|
+
- name: Install dependencies
|
|
19
|
+
run: npm ci
|
|
20
|
+
- name: Lint code
|
|
21
|
+
run: npm run lint
|
|
22
|
+
|
|
23
|
+
test:
|
|
24
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
25
|
+
steps:
|
|
26
|
+
- name: Checkout code
|
|
27
|
+
uses: actions/checkout@v4
|
|
28
|
+
- name: Setup Node.js
|
|
29
|
+
uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version-file: .nvmrc
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: npm ci
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: npm run test
|
|
36
|
+
|
|
37
|
+
build:
|
|
38
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
39
|
+
needs: [lint, test]
|
|
40
|
+
steps:
|
|
41
|
+
- name: Checkout code
|
|
42
|
+
uses: actions/checkout@v4
|
|
43
|
+
- name: Setup Node.js
|
|
44
|
+
uses: actions/setup-node@v4
|
|
45
|
+
with:
|
|
46
|
+
node-version-file: .nvmrc
|
|
47
|
+
- name: Install dependencies
|
|
48
|
+
run: npm ci
|
|
49
|
+
- name: Run Build
|
|
50
|
+
run: npm run build
|
|
51
|
+
|
|
52
|
+
github-release:
|
|
53
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
54
|
+
needs: [build]
|
|
55
|
+
permissions:
|
|
56
|
+
contents: write
|
|
57
|
+
steps:
|
|
58
|
+
- name: Checkout code
|
|
59
|
+
uses: actions/checkout@v4
|
|
60
|
+
with:
|
|
61
|
+
fetch-depth: 0
|
|
62
|
+
|
|
63
|
+
- name: Setup Node.js
|
|
64
|
+
uses: actions/setup-node@v4
|
|
65
|
+
with:
|
|
66
|
+
node-version-file: .nvmrc
|
|
67
|
+
|
|
68
|
+
- name: Get version from package.json
|
|
69
|
+
id: get_version
|
|
70
|
+
run: |
|
|
71
|
+
VERSION="v$(node -p "require('./package.json').version")"
|
|
72
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
73
|
+
|
|
74
|
+
- name: Check if tag exists
|
|
75
|
+
id: tag_check
|
|
76
|
+
run: |
|
|
77
|
+
if git rev-parse "${{ steps.get_version.outputs.version }}" >/dev/null 2>&1; then
|
|
78
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
79
|
+
else
|
|
80
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
- name: Create GitHub release
|
|
84
|
+
if: steps.tag_check.outputs.exists == 'false'
|
|
85
|
+
uses: softprops/action-gh-release@v2
|
|
86
|
+
with:
|
|
87
|
+
tag_name: ${{ steps.get_version.outputs.version }}
|
|
88
|
+
generate_release_notes: true
|
|
89
|
+
|
|
90
|
+
npm-release:
|
|
91
|
+
runs-on: [ubuntu-latest, self-hosted]
|
|
92
|
+
needs: [build]
|
|
93
|
+
permissions:
|
|
94
|
+
contents: read
|
|
95
|
+
id-token: write
|
|
96
|
+
steps:
|
|
97
|
+
- name: Checkout code
|
|
98
|
+
uses: actions/checkout@v4
|
|
99
|
+
- name: Setup Node.js
|
|
100
|
+
uses: actions/setup-node@v4
|
|
101
|
+
with:
|
|
102
|
+
node-version-file: .nvmrc
|
|
103
|
+
registry-url: 'https://registry.npmjs.org/'
|
|
104
|
+
- run: npm ci
|
|
105
|
+
- run: npm run build
|
|
106
|
+
- run: npm publish --provenance --access public
|
|
107
|
+
env:
|
|
108
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm run lint:staged
|
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v22.14.0
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"useTabs": true,
|
|
3
|
+
"tabWidth": 4,
|
|
4
|
+
"endOfLine": "lf",
|
|
5
|
+
"printWidth": 100,
|
|
6
|
+
"semi": true,
|
|
7
|
+
"singleQuote": true,
|
|
8
|
+
"trailingComma": "es5",
|
|
9
|
+
"overrides": [
|
|
10
|
+
{
|
|
11
|
+
"files": ["*.yml", "*.yaml"],
|
|
12
|
+
"options": {
|
|
13
|
+
"tabWidth": 2,
|
|
14
|
+
"singleQuote": false,
|
|
15
|
+
"useTabs": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# TiBoLi Types
|
|
2
|
+
|
|
3
|
+
Here you can find all the type definitions for [TiBoLi](https://tiboli.tech4web.de). These are all Typescript Definitions using [Zod](https://zod.dev/).
|
|
4
|
+
|
|
5
|
+
## Contributing
|
|
6
|
+
|
|
7
|
+
If you want to Contribute, make sure to follow the Guidelines highlighted in `CONTRIBUTING.md`
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { fixupConfigRules } from '@eslint/compat';
|
|
2
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
3
|
+
import js from '@eslint/js';
|
|
4
|
+
import tsParser from '@typescript-eslint/parser';
|
|
5
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
6
|
+
import globals from 'globals';
|
|
7
|
+
|
|
8
|
+
const compat = new FlatCompat({
|
|
9
|
+
baseDirectory: import.meta.dirname,
|
|
10
|
+
recommendedConfig: js.configs.recommended,
|
|
11
|
+
allConfig: js.configs.all,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export default defineConfig([
|
|
15
|
+
{
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parser: tsParser,
|
|
18
|
+
ecmaVersion: 2020,
|
|
19
|
+
sourceType: 'module',
|
|
20
|
+
|
|
21
|
+
parserOptions: {
|
|
22
|
+
project: ['./tsconfig.json'],
|
|
23
|
+
tsconfigRootDir: import.meta.dirname,
|
|
24
|
+
},
|
|
25
|
+
globals: globals.node,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
extends: fixupConfigRules(
|
|
29
|
+
compat.extends(
|
|
30
|
+
'eslint:recommended',
|
|
31
|
+
'plugin:@typescript-eslint/eslint-recommended',
|
|
32
|
+
'plugin:@typescript-eslint/recommended',
|
|
33
|
+
'plugin:prettier/recommended',
|
|
34
|
+
'plugin:import/errors',
|
|
35
|
+
'plugin:import/warnings',
|
|
36
|
+
'plugin:import/typescript'
|
|
37
|
+
)
|
|
38
|
+
),
|
|
39
|
+
|
|
40
|
+
rules: {
|
|
41
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
42
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
43
|
+
|
|
44
|
+
'no-constant-condition': [
|
|
45
|
+
'error',
|
|
46
|
+
{
|
|
47
|
+
checkLoops: false,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
|
|
51
|
+
'import/order': [
|
|
52
|
+
'error',
|
|
53
|
+
{
|
|
54
|
+
groups: ['builtin', 'external', 'internal'],
|
|
55
|
+
|
|
56
|
+
pathGroups: [
|
|
57
|
+
{
|
|
58
|
+
pattern: '(^src)|(^test)\\/*',
|
|
59
|
+
group: 'internal',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pattern: '^(?!src|test).*',
|
|
63
|
+
group: 'external',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
|
|
67
|
+
alphabetize: {
|
|
68
|
+
order: 'asc',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
|
|
73
|
+
'import/no-unresolved': 'off',
|
|
74
|
+
|
|
75
|
+
'@typescript-eslint/naming-convention': [
|
|
76
|
+
'warn',
|
|
77
|
+
{
|
|
78
|
+
selector: 'enumMember',
|
|
79
|
+
format: ['PascalCase'],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
selector: 'variableLike',
|
|
83
|
+
format: ['camelCase'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
selector: 'variable',
|
|
87
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
selector: 'parameter',
|
|
91
|
+
format: ['camelCase'],
|
|
92
|
+
leadingUnderscore: 'allow',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
selector: 'typeLike',
|
|
96
|
+
format: ['PascalCase'],
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
100
|
+
'error',
|
|
101
|
+
{ accessibility: 'explicit', overrides: { constructors: 'off' } },
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
globalIgnores([
|
|
106
|
+
'**/webpack.config.js',
|
|
107
|
+
'**/jest.config.js',
|
|
108
|
+
'**/jest.setup.js',
|
|
109
|
+
'**/eslint.config.mjs',
|
|
110
|
+
]),
|
|
111
|
+
globalIgnores(['**/cache', '**/input', '**/dist', '**/node_modules', '**/output', '**/test']),
|
|
112
|
+
]);
|
package/jest.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiboli/types",
|
|
3
|
+
"scope": "@tiboli",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"description": "Typedefinitions for Tiboli",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"tiboli",
|
|
8
|
+
"types",
|
|
9
|
+
"typescript",
|
|
10
|
+
"definitions",
|
|
11
|
+
"tiboli-types"
|
|
12
|
+
],
|
|
13
|
+
"private": false,
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
|
|
18
|
+
"watch": "tsc --project tsconfig.json --watch",
|
|
19
|
+
"start": "node dist/index.js",
|
|
20
|
+
"dev": "tsx watch -r tsconfig-paths/register src",
|
|
21
|
+
"prepare": "husky",
|
|
22
|
+
"lint": "eslint --max-warnings=0 .",
|
|
23
|
+
"lint:staged": "lint-staged",
|
|
24
|
+
"test": "jest"
|
|
25
|
+
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=20"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+ssh://git@github.com/TinyCodeLabs/typescript-template.git"
|
|
38
|
+
},
|
|
39
|
+
"author": "Tim Gabrikowski",
|
|
40
|
+
"license": "ISC",
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/TinyCodeLabs/tiboli-types/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/TinyCodeLabs/tiboli-types#readme",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@eslint/compat": "^1.3.1",
|
|
47
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
48
|
+
"@eslint/js": "^9.31.0",
|
|
49
|
+
"@types/jest": "^30.0.0",
|
|
50
|
+
"@types/node": "^24.0.3",
|
|
51
|
+
"@typescript-eslint/eslint-plugin": "^8.37.0",
|
|
52
|
+
"@typescript-eslint/parser": "^8.37.0",
|
|
53
|
+
"eslint": "^9.31.0",
|
|
54
|
+
"eslint-config-prettier": "^10.1.8",
|
|
55
|
+
"eslint-plugin-import": "^2.32.0",
|
|
56
|
+
"eslint-plugin-prettier": "^5.5.3",
|
|
57
|
+
"globals": "^16.3.0",
|
|
58
|
+
"husky": "^9.1.7",
|
|
59
|
+
"jest": "^30.0.5",
|
|
60
|
+
"lint-staged": "^16.1.2",
|
|
61
|
+
"prettier": "^3.6.2",
|
|
62
|
+
"ts-jest": "^29.4.0",
|
|
63
|
+
"tsc-alias": "^1.8.10",
|
|
64
|
+
"tsconfig-paths": "^4.2.0",
|
|
65
|
+
"tsx": "^4.20.3",
|
|
66
|
+
"typescript": "^5.8.3",
|
|
67
|
+
"typescript-eslint": "^8.37.0"
|
|
68
|
+
},
|
|
69
|
+
"lint-staged": {
|
|
70
|
+
"*.ts": [
|
|
71
|
+
"prettier --write",
|
|
72
|
+
"eslint --max-warnings=0 --no-warn-ignored"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
75
|
+
"dependencies": {
|
|
76
|
+
"zod": "^4.0.13"
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
export const BookSchema = z.object({
|
|
4
|
+
id: z.int(),
|
|
5
|
+
title: z.string(),
|
|
6
|
+
author: z.string(),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const BookCreationSchema = BookSchema.omit({ id: true });
|
|
10
|
+
export const BookUpdateSchema = BookSchema.partial().required({ id: true });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
export const CustomerSchema = z.object({
|
|
4
|
+
id: z.int(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
lastname: z.string(),
|
|
7
|
+
email: z.email(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export const CustomerCreationSchema = CustomerSchema.omit({ id: true });
|
|
11
|
+
export const CustomerUpdateSchema = CustomerSchema.partial().required({ id: true });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BookSchema, BookCreationSchema, BookUpdateSchema } from './book.schema';
|
|
2
|
+
export { CopySchema, CopyCreationSchema, CopyUpdateSchema } from './copy.schema';
|
|
3
|
+
export { CustomerSchema, CustomerCreationSchema, CustomerUpdateSchema } from './customer.schema';
|
|
4
|
+
export { GroupSchema, GroupCreationSchema, GroupUpdateSchema } from './group.schema';
|
|
5
|
+
export { LoanSchema, LoanCreationSchema, LoanUpdateSchema } from './loan.schema';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
|
|
3
|
+
export const LoanSchema = z.object({
|
|
4
|
+
id: z.int(),
|
|
5
|
+
copyId: z.int(),
|
|
6
|
+
customerId: z.int(),
|
|
7
|
+
lentDate: z.date(),
|
|
8
|
+
dueDate: z.date(),
|
|
9
|
+
returnDate: z.date(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const LoanCreationSchema = LoanSchema.omit({ id: true });
|
|
13
|
+
export const LoanUpdateSchema = LoanSchema.partial().required({ id: true });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BookCreationSchema, BookSchema, BookUpdateSchema } from '../schemas';
|
|
3
|
+
|
|
4
|
+
export type BookAttributes = z.infer<typeof BookSchema>;
|
|
5
|
+
export type BookCreationAttributes = z.infer<typeof BookCreationSchema>;
|
|
6
|
+
export type BookUpdateAttributes = z.infer<typeof BookUpdateSchema>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CopyCreationSchema, CopySchema, CopyUpdateSchema } from '../schemas';
|
|
3
|
+
|
|
4
|
+
export type CopyAttributes = z.infer<typeof CopySchema>;
|
|
5
|
+
export type CopyCreationAttributes = z.infer<typeof CopyCreationSchema>;
|
|
6
|
+
export type CopyUpdateAttributes = z.infer<typeof CopyUpdateSchema>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CustomerSchema, CustomerCreationSchema, CustomerUpdateSchema } from '../schemas';
|
|
3
|
+
|
|
4
|
+
export type CustomerAttributes = z.infer<typeof CustomerSchema>;
|
|
5
|
+
export type CustomerCreationAttributes = z.infer<typeof CustomerCreationSchema>;
|
|
6
|
+
export type CustomerUpdateAttributes = z.infer<typeof CustomerUpdateSchema>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GroupSchema, GroupCreationSchema, GroupUpdateSchema } from '../schemas';
|
|
3
|
+
|
|
4
|
+
export type GroupAttributes = z.infer<typeof GroupSchema>;
|
|
5
|
+
export type GroupCreationAttributes = z.infer<typeof GroupCreationSchema>;
|
|
6
|
+
export type GroupUpdateAttributes = z.infer<typeof GroupUpdateSchema>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { BookAttributes, BookCreationAttributes, BookUpdateAttributes } from './book.type';
|
|
2
|
+
export { CopyAttributes, CopyCreationAttributes, CopyUpdateAttributes } from './copy.type';
|
|
3
|
+
export {
|
|
4
|
+
CustomerAttributes,
|
|
5
|
+
CustomerCreationAttributes,
|
|
6
|
+
CustomerUpdateAttributes,
|
|
7
|
+
} from './customer.type';
|
|
8
|
+
export { GroupAttributes, GroupCreationAttributes, GroupUpdateAttributes } from './group.types';
|
|
9
|
+
export { LoanAttributes, LoanCreationAttributes, LoanUpdateAttributes } from './loan.type';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LoanCreationSchema, LoanSchema, LoanUpdateSchema } from '../schemas';
|
|
3
|
+
|
|
4
|
+
export type LoanAttributes = z.infer<typeof LoanSchema>;
|
|
5
|
+
export type LoanCreationAttributes = z.infer<typeof LoanCreationSchema>;
|
|
6
|
+
export type LoanUpdateAttributes = z.infer<typeof LoanUpdateSchema>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BookSchema } from '../../src/schemas/book.schema';
|
|
2
|
+
|
|
3
|
+
describe('BookSchema', () => {
|
|
4
|
+
it('should validate a valid book object', () => {
|
|
5
|
+
const validBook = {
|
|
6
|
+
id: 1,
|
|
7
|
+
title: '1984',
|
|
8
|
+
author: 'George Orwell',
|
|
9
|
+
};
|
|
10
|
+
expect(() => BookSchema.parse(validBook)).not.toThrow();
|
|
11
|
+
});
|
|
12
|
+
it('should throw an error for an invalid book object', () => {
|
|
13
|
+
const invalidBook = {
|
|
14
|
+
id: 'one',
|
|
15
|
+
title: 1984,
|
|
16
|
+
author: 12345,
|
|
17
|
+
};
|
|
18
|
+
expect(() => BookSchema.parse(invalidBook)).toThrow();
|
|
19
|
+
});
|
|
20
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
4
|
+
"module": "commonjs" /* Specify what module code is generated. */,
|
|
5
|
+
"baseUrl": "./src" /* Specify the base directory to resolve non-relative module names. */,
|
|
6
|
+
"paths": {
|
|
7
|
+
"@/*": ["src/*"],
|
|
8
|
+
"@schemas/*": ["src/schemas/*"]
|
|
9
|
+
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
|
|
10
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
11
|
+
"declarationDir": "./dist" /* Specify the output folder for generated declaration files. */,
|
|
12
|
+
"declaration": true,
|
|
13
|
+
"rootDir": "./src" /* Specify the root folder within your source files. */,
|
|
14
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
15
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
16
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
17
|
+
"skipLibCheck": false /* Skip type checking all .d.ts files. */,
|
|
18
|
+
"sourceMap": true /* Generates corresponding '.map' file. */
|
|
19
|
+
},
|
|
20
|
+
"exclude": ["test", "node_modules", "dist"]
|
|
21
|
+
}
|