Skip to content

Commit

Permalink
feat: refactor deserialization process
Browse files Browse the repository at this point in the history
This refactor simplifies the TypeScript types of document results to a more
readable level, as well as allowing to specifiy optional links and meta schemas
for resources.

BREAKING CHANGE: _links and _meta are now not included in resources by default
anymore.
  • Loading branch information
DASPRiD committed May 14, 2024
1 parent 73320ff commit 41b8b5d
Show file tree
Hide file tree
Showing 13 changed files with 833 additions and 1,102 deletions.
1 change: 0 additions & 1 deletion .lefthook/commit-msg/commitlint.sh

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,9 @@ must define one of the following two properties:
> },
> });
> ```
### Resource links and meta
If you want to retrieve links or meta for resources, you can specify `linksSchema` and `metaSchema` respectively. Once
defined, you'll either get a `$links` or `$meta` property on your resources. The `$` prefix is a design decision in
order to avoid name clashes with attributes or relationships with the same name.
32 changes: 10 additions & 22 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,38 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.2/schema.json",
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"organizeImports": {
"enabled": true
},
"files": {
"include": [
"biome.json",
"release.config.cjs",
"commitlint.config.cjs",
"src/**/*",
"test/**/*"
]
"include": ["biome.json", "commitlint.config.cjs", "src/**/*"]
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"noEmptyTypeParameters": "error",
"noInvalidUseBeforeDeclaration": "error",
"noUnusedImports": "error",
"noUnusedPrivateClassMembers": "error",
"noUselessLoneBlockStatements": "error",
"noUselessTernary": "error",
"useExportType": "error",
"useImportType": "error",
"useForOf": "error",
"useGroupedTypeImport": "error"
},
"complexity": {
"noExcessiveCognitiveComplexity": "warn",
"useSimplifiedLogicExpression": "error"
},
"correctness": {
"noNewSymbol": "error"
"noNewSymbol": "error",
"noUnusedImports": "error",
"noUnusedPrivateClassMembers": "error",
"useHookAtTopLevel": "error"
},
"style": {
"useBlockStatements": "error",
"useCollapsedElseIf": "error",
"useForOf": "error",
"useFragmentSyntax": "error",
"useShorthandArrayType": "error",
"useShorthandAssign": "error",
"useSingleCaseStatement": "error"
},
"suspicious": {
"noApproximativeNumericConstant": "warn",
"noConsoleLog": "error"
"noConsoleLog": "error",
"noEmptyBlockStatements": "error"
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ pre-commit:
run: npx biome check --apply --no-errors-on-unmatched --files-ignore-unknown=true {staged_files} && git update-index --again

commit-msg:
scripts:
"commitlint.sh":
runner: bash
commands:
lint-commit-msg:
run: pnpm exec commitlint --edit
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
"check": "biome check . --apply"
},
"devDependencies": {
"@biomejs/biome": "1.5.2",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@tsconfig/vite-react": "^3.0.0",
"@vitest/coverage-v8": "^1.2.2",
"lefthook": "^1.5.6",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2",
"vitest": "^1.2.2",
"zod": "^3.22.4"
"@biomejs/biome": "1.7.3",
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"@tsconfig/vite-react": "^3.0.2",
"@vitest/coverage-v8": "^1.6.0",
"lefthook": "^1.6.11",
"typescript": "^5.4.5",
"vite": "^5.2.11",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0",
"zod": "^3.23.8"
},
"peerDependencies": {
"zod": "^3.22.4"
Expand Down
Loading

0 comments on commit 41b8b5d

Please sign in to comment.