Skip to content

Commit

Permalink
feat(QuickMongo): completely reworked types system
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowplay1 committed Aug 21, 2024
1 parent ab65277 commit 903da72
Show file tree
Hide file tree
Showing 24 changed files with 837 additions and 290 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/type-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Run the type tests

on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
push:

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Install TypeScript
run: npm i typescript ts-node -g

- name: Compile test file
run: npx tsc --noEmit --target ESNext --moduleResolution nodenext --module nodenext --skipLibCheck tests/types-test.ts
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
. "$(dirname -- "$0")/_/husky.sh"

bash ./scripts/lint.sh --fix
rm -rf ./dist && tsc
rm -rf ./dist && npx tsc

git add .
12 changes: 9 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# git files
# git & github files
.git/
.github/

# husky scripts
.husky/

# ci/cd
.github/

# documentation
# documentation & changelog
docs/
changelog.md

# bash scripts
scripts/
Expand All @@ -19,8 +21,9 @@ node_modules/
# utilities
utils/

# local testing
# testing
test/
tests/
misc/
dist/misc/
dist/test
Expand All @@ -35,11 +38,14 @@ src/
.gitattributes
.eslintrc.js
tsconfig.json
jest.config.js
commitlint.config.js

# ignore lists
.gitignore
.npmignore

# to reduce the final package size
package-lock.json
bun.lockb
examples/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## 📂 | Installation
<b>Please note:</br><b>
<b>Node.js 14.0.0 or newer is required.</b><br>
<b>Node.js v14.0.0 or newer is required.</b><br>
```bash
$ npm i quick-mongo-super
$ yarn add quick-mongo-super
Expand Down Expand Up @@ -52,6 +52,6 @@ $ pnpm add quick-mongo-super
<br>
<b>If you don't understand something or you are experiencing problems, feel free to join our <a href="https://discord.gg/4pWKq8vUnb">Support Server</a>.</b>
<br>
<b>Module Created by ShadowPlay.</b>
<b>Module Created by <b>@shadowplay_</b> on discord.</b>

# ❤️ Thanks for choosing Quick Mongo Super ❤️
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

## 🕘 | Changelog

**v3.0.0**
- Improved documentation, fixed typos & mismatches.
- Fixed minor types bugs.
- Bumped `mongoose` to the latest version, `v8.5.3`
- Added unneeded package files into `.npmignore` to reduce the final npm package size.
- Completely changed the type system - now all the values are being **inferred** from the object keys you specify in database requests (with keys autocomplete as well 👀)!
- Added a new `QuickMongo.getFromDatabase()` method that works the same way as `QuickMongo.get()`, but instead of getting the data from **cache**, a request being made to **remote cluster**.

**NOTE:** This release is being considered **major** due to **significant** changes to the types system of the module which might **impact** TypeScript users.

**v2.2.0**
- Added `QuickMongo.values()` method; it works the same way as `QuickMongo.keys()`, but returns the object **values** instead of object **keys**.
- Added **6** new **array-like** methods in `QuickMongo` class that simplify the **read** operations on **database object values**:
Expand Down
14 changes: 13 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# `quick-mongo-super` documentation
# `quick-mongo-super v3.0.0` documentation

## Classes
- [`QuickMongo<K, V>`](classes/QuickMongo.md)
- [`QuickMongoClient<TInitialDatabaseData>`](classes/QuickMongoClient.md)
- [`TypedObject`](classes/TypedObject.md)

## Types
- [`If<T, IfTrue, IfFalse>`](types/If.md)
- [`IsObject<T>`](types/IsObject.md)
- [`Maybe<T>`](types/Maybe.md)
- [`RestOrArray<T>`](types/RestOrArray.md)
- [`TupleOrArray<T>`](types/TupleOrArray.md)
- [`ExtractFromArray<A>`](types/ExtractFromArray.md)
- [`ExtractFromRestOrArray<T>`](types/ExtractFromRestOrArray.md)
- [`QueryFunction<T, R>`](types/QueryFunction.md)
- [`FirstObjectKey<TKey>`](types/FirstObjectKey.md)
- [`ObjectPath<T, TKey>`](types/ObjectPath.md)
- [`ObjectValue<T, P>`](types/ObjectValue.md)
- [`IsAny<T>`](types/IsAny.md)
- [`ExtractObjectKeys<T>`](types/ExtractObjectKeys.md)
- [`ExtractObjectValues<T>`](types/ExtractObjectValues.md)
- [`ExtractObjectEntries<T>`](types/ExtractObjectEntries.md)

## Interfaces
- [`IDatabaseConfiguration`](interfaces/IDatabaseConfiguration.md)
Expand Down
Loading

0 comments on commit 903da72

Please sign in to comment.