ts-japi 1.12.0 → 1.12.2

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.
Files changed (114) hide show
  1. package/.commitlintrc.ts +1 -1
  2. package/.github/FUNDING.yml +1 -1
  3. package/.github/workflows/ci.yml +32 -0
  4. package/.github/workflows/release-notes.yml +53 -0
  5. package/.github/workflows/release-please.yml +20 -0
  6. package/.github/workflows/release.yml +147 -0
  7. package/.node-version +1 -0
  8. package/.release-please-manifest.json +1 -1
  9. package/CHANGELOG.md +14 -0
  10. package/LICENSE +2 -1
  11. package/README.md +9 -7
  12. package/benchmarks/playground.benchmark.ts +12 -12
  13. package/benchmarks/serializer.benchmark.ts +10 -10
  14. package/biome.json +141 -0
  15. package/lefthook.yml +12 -0
  16. package/lib/classes/cache.d.ts +4 -4
  17. package/lib/classes/cache.d.ts.map +1 -1
  18. package/lib/classes/cache.js +7 -5
  19. package/lib/classes/cache.js.map +1 -1
  20. package/lib/classes/error-serializer.d.ts +3 -3
  21. package/lib/classes/error-serializer.d.ts.map +1 -1
  22. package/lib/classes/error-serializer.js +18 -15
  23. package/lib/classes/error-serializer.js.map +1 -1
  24. package/lib/classes/linker.d.ts +3 -3
  25. package/lib/classes/linker.d.ts.map +1 -1
  26. package/lib/classes/metaizer.d.ts +2 -2
  27. package/lib/classes/metaizer.d.ts.map +1 -1
  28. package/lib/classes/paginator.d.ts +5 -5
  29. package/lib/classes/paginator.d.ts.map +1 -1
  30. package/lib/classes/paginator.js +6 -5
  31. package/lib/classes/paginator.js.map +1 -1
  32. package/lib/classes/polymorphic-serialiser.d.ts +9 -10
  33. package/lib/classes/polymorphic-serialiser.d.ts.map +1 -1
  34. package/lib/classes/polymorphic-serialiser.js +15 -6
  35. package/lib/classes/polymorphic-serialiser.js.map +1 -1
  36. package/lib/classes/relator.d.ts +11 -11
  37. package/lib/classes/relator.d.ts.map +1 -1
  38. package/lib/classes/relator.js +15 -6
  39. package/lib/classes/relator.js.map +1 -1
  40. package/lib/classes/serializer.d.ts +13 -9
  41. package/lib/classes/serializer.d.ts.map +1 -1
  42. package/lib/classes/serializer.js +44 -27
  43. package/lib/classes/serializer.js.map +1 -1
  44. package/lib/index.d.ts +21 -21
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +9 -9
  47. package/lib/index.js.map +1 -1
  48. package/lib/interfaces/cache.interface.d.ts +1 -1
  49. package/lib/interfaces/cache.interface.d.ts.map +1 -1
  50. package/lib/interfaces/error-serializer.interface.d.ts +37 -37
  51. package/lib/interfaces/error-serializer.interface.d.ts.map +1 -1
  52. package/lib/interfaces/error.interface.d.ts +21 -21
  53. package/lib/interfaces/error.interface.d.ts.map +1 -1
  54. package/lib/interfaces/json-api.interface.d.ts +12 -12
  55. package/lib/interfaces/json-api.interface.d.ts.map +1 -1
  56. package/lib/interfaces/linker.interface.d.ts +1 -1
  57. package/lib/interfaces/linker.interface.d.ts.map +1 -1
  58. package/lib/interfaces/paginator.interface.d.ts +2 -2
  59. package/lib/interfaces/paginator.interface.d.ts.map +1 -1
  60. package/lib/interfaces/relator.interface.d.ts +3 -3
  61. package/lib/interfaces/relator.interface.d.ts.map +1 -1
  62. package/lib/interfaces/serializer.interface.d.ts +78 -78
  63. package/lib/interfaces/serializer.interface.d.ts.map +1 -1
  64. package/lib/models/error.model.d.ts +4 -4
  65. package/lib/models/error.model.d.ts.map +1 -1
  66. package/lib/models/error.model.js +29 -18
  67. package/lib/models/error.model.js.map +1 -1
  68. package/lib/models/link.model.d.ts +1 -1
  69. package/lib/models/link.model.d.ts.map +1 -1
  70. package/lib/models/relationship.model.d.ts +5 -5
  71. package/lib/models/relationship.model.d.ts.map +1 -1
  72. package/lib/models/relationship.model.js +8 -5
  73. package/lib/models/relationship.model.js.map +1 -1
  74. package/lib/models/resource-identifier.model.d.ts +1 -1
  75. package/lib/models/resource-identifier.model.d.ts.map +1 -1
  76. package/lib/models/resource-identifier.model.js +2 -1
  77. package/lib/models/resource-identifier.model.js.map +1 -1
  78. package/lib/models/resource.model.d.ts +5 -5
  79. package/lib/models/resource.model.d.ts.map +1 -1
  80. package/lib/models/resource.model.js +6 -3
  81. package/lib/models/resource.model.js.map +1 -1
  82. package/lib/types/global.types.d.ts +9 -9
  83. package/lib/types/global.types.d.ts.map +1 -1
  84. package/lib/utils/is-error-document.d.ts +1 -1
  85. package/lib/utils/is-error-document.d.ts.map +1 -1
  86. package/lib/utils/is-error-document.js +3 -4
  87. package/lib/utils/is-error-document.js.map +1 -1
  88. package/lib/utils/is-object.d.ts.map +1 -1
  89. package/lib/utils/is-object.js +3 -3
  90. package/lib/utils/is-object.js.map +1 -1
  91. package/lib/utils/is-plain-object.d.ts.map +1 -1
  92. package/lib/utils/is-plain-object.js +9 -6
  93. package/lib/utils/is-plain-object.js.map +1 -1
  94. package/lib/utils/merge.d.ts +1 -1
  95. package/lib/utils/merge.d.ts.map +1 -1
  96. package/lib/utils/merge.js +5 -3
  97. package/lib/utils/merge.js.map +1 -1
  98. package/lib/utils/serializer.utils.d.ts +4 -4
  99. package/lib/utils/serializer.utils.d.ts.map +1 -1
  100. package/lib/utils/serializer.utils.js +27 -22
  101. package/lib/utils/serializer.utils.js.map +1 -1
  102. package/package.json +53 -65
  103. package/release-please-config.json +8 -3
  104. package/tools/generate_docs.ts +7 -9
  105. package/tools/internal/custom_markdown_action.ts +3 -3
  106. package/tools/internal/custom_markdown_documenter.ts +348 -244
  107. package/tsconfig.json +4 -3
  108. package/.github/release-please.yml +0 -4
  109. package/.github/workflows/ci.yaml +0 -73
  110. package/.github/workflows/publish.yaml +0 -29
  111. package/.husky/pre-commit +0 -4
  112. package/.husky/pre-push +0 -4
  113. package/.prettierignore +0 -4
  114. package/.prettierrc +0 -10
package/.commitlintrc.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export default {
2
- extends: ['@commitlint/config-conventional'],
2
+ extends: ["@commitlint/config-conventional"],
3
3
  };
@@ -1,3 +1,3 @@
1
1
  # These are supported funding model platforms
2
2
 
3
- github: jrandolf
3
+ github: mathematic-inc
@@ -0,0 +1,32 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ci-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ ci:
15
+ name: CI
16
+ runs-on: ubuntu-latest
17
+ timeout-minutes: 15
18
+ steps:
19
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20
+ - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
21
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
22
+ with:
23
+ node-version-file: .node-version
24
+ cache: pnpm
25
+ - name: Install
26
+ run: pnpm install --frozen-lockfile
27
+ - name: Lint
28
+ run: pnpm lint
29
+ - name: Build
30
+ run: pnpm build
31
+ - name: Test
32
+ run: pnpm test
@@ -0,0 +1,53 @@
1
+ name: Release Notes
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ tag:
7
+ description: "Release tag (e.g. v1.12.0)"
8
+ required: true
9
+ type: string
10
+
11
+ concurrency:
12
+ group: release-notes-${{ github.event.inputs.tag }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ enhance:
17
+ name: Enhance release notes with Claude
18
+ runs-on: ubuntu-latest
19
+ permissions:
20
+ contents: write
21
+ id-token: write
22
+ steps:
23
+ - name: Checkout
24
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
25
+ with:
26
+ fetch-depth: 0
27
+
28
+ - name: Write release notes with Claude
29
+ uses: anthropics/claude-code-action@26ec041249acb0a944c0a47b6c0c13f05dbc5b44 # v1
30
+ with:
31
+ claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
32
+ claude_args: --allowedTools "Bash(git log:*),Bash(git describe:*),Read,Write"
33
+ prompt: |
34
+ Write an exciting, polished GitHub release body for ts-japi ${{ inputs.tag }} and save it to `release-notes.md`.
35
+
36
+ ts-japi is a highly-modular, TypeScript-friendly, framework-agnostic library for serializing data to the JSON:API specification. It provides serializers, deserializers, error handling, pagination, sorting, filtering, and full relationship support.
37
+
38
+ Steps:
39
+ 1. Run `git describe --tags --abbrev=0 HEAD^` to get the previous tag, then run `git log <previous-tag>..HEAD --oneline` to see all commits in this release.
40
+ 2. Read `src/index.ts` and key source files under `src/` to understand the API surface.
41
+ 3. Write the release body to `release-notes.md`. It should:
42
+ - Open with an enthusiastic one-paragraph summary of what's new or why this release is exciting.
43
+ - Have clearly labelled sections (e.g. **✨ New Features**, **🐛 Bug Fixes**, **⚡ Improvements**) — only include sections that actually have content.
44
+ - For any significant new feature, include a short TypeScript example snippet showing it in action.
45
+ - End with an installation snippet (`npm install ts-japi` or `pnpm add ts-japi`).
46
+ - Be written in an upbeat, developer-friendly tone — celebrate the work!
47
+ Do NOT publish it yourself — a subsequent step will do that.
48
+
49
+ - name: Publish release notes
50
+ uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2
51
+ with:
52
+ tag_name: ${{ inputs.tag }}
53
+ body_path: release-notes.md
@@ -0,0 +1,20 @@
1
+ name: Release Please
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+ pull-requests: write
10
+
11
+ jobs:
12
+ release-please:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Run Release Please
16
+ uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
17
+ with:
18
+ token: ${{ secrets.RELEASE_TOKEN }}
19
+ config-file: release-please-config.json
20
+ manifest-file: .release-please-manifest.json
@@ -0,0 +1,147 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ concurrency:
9
+ group: release-${{ github.workflow }}-${{ github.ref }}
10
+ cancel-in-progress: false
11
+
12
+ permissions:
13
+ contents: write
14
+ id-token: write
15
+ attestations: write
16
+
17
+ jobs:
18
+ build-artifacts:
19
+ name: Build
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24
+ - name: Set up pnpm
25
+ uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
26
+ - name: Set up Node.js
27
+ uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
28
+ with:
29
+ node-version-file: .node-version
30
+ cache: "pnpm"
31
+ - name: Install dependencies
32
+ run: pnpm install --frozen-lockfile
33
+ - name: Build
34
+ run: pnpm build
35
+ - name: Pack
36
+ run: pnpm pack
37
+ - name: Upload artifact archive
38
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
39
+ with:
40
+ name: build-artifact
41
+ path: "*.tgz"
42
+
43
+ release-assets:
44
+ name: Assemble Release Assets
45
+ needs:
46
+ - build-artifacts
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - name: Download build artifact
50
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
51
+ with:
52
+ name: build-artifact
53
+ path: dist
54
+ - name: Upload complete release assets
55
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
56
+ with:
57
+ name: release-assets
58
+ path: dist/*
59
+
60
+ create-release:
61
+ name: Publish GitHub Release
62
+ needs:
63
+ - release-assets
64
+ runs-on: ubuntu-latest
65
+ environment: release
66
+ permissions:
67
+ contents: write
68
+ id-token: write
69
+ steps:
70
+ - name: Checkout
71
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
72
+ with:
73
+ fetch-depth: 0
74
+
75
+ - name: Download release assets
76
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
77
+ with:
78
+ name: release-assets
79
+ path: dist
80
+
81
+ - name: Create GitHub release
82
+ uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
83
+ with:
84
+ tag_name: ${{ github.ref_name }}
85
+ name: ${{ github.ref_name }}
86
+ generate_release_notes: true
87
+ prerelease: ${{ contains(github.ref_name, '-') }}
88
+ files: dist/*
89
+ fail_on_unmatched_files: true
90
+ make_latest: ${{ !contains(github.ref_name, '-') }}
91
+
92
+ - name: Trigger release notes workflow
93
+ env:
94
+ GH_TOKEN: ${{ secrets.RELEASE_TOKEN }}
95
+ run: |
96
+ gh workflow run release-notes.yml \
97
+ --field tag="${{ github.ref_name }}"
98
+
99
+ attest-provenance:
100
+ name: Attest Build Provenance
101
+ needs:
102
+ - create-release
103
+ runs-on: ubuntu-latest
104
+ permissions:
105
+ id-token: write
106
+ attestations: write
107
+ contents: read
108
+ steps:
109
+ - name: Download release assets
110
+ uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
111
+ with:
112
+ name: release-assets
113
+ path: dist
114
+ - name: Attest release assets
115
+ uses: actions/attest-build-provenance@e8998f949152b193b063cb0ec769d69d929409be # v2.4.0
116
+ with:
117
+ subject-path: |
118
+ dist/*
119
+
120
+ publish-npm:
121
+ name: Publish to npm
122
+ needs:
123
+ - create-release
124
+ runs-on: ubuntu-latest
125
+ environment: release
126
+ permissions:
127
+ contents: read
128
+ id-token: write
129
+ steps:
130
+ - name: Checkout
131
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
132
+ - name: Set up pnpm
133
+ uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
134
+ - name: Set up Node.js
135
+ uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
136
+ with:
137
+ node-version-file: .node-version
138
+ cache: "pnpm"
139
+ registry-url: "https://registry.npmjs.org"
140
+ - name: Upgrade npm
141
+ run: npm install -g npm@latest
142
+ - name: Install dependencies
143
+ run: pnpm install --frozen-lockfile
144
+ - name: Build
145
+ run: pnpm build
146
+ - name: Publish
147
+ run: pnpm publish --no-git-checks
package/.node-version ADDED
@@ -0,0 +1 @@
1
+ 20
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.12.0"
2
+ ".": "1.12.2"
3
3
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.12.2](https://github.com/mathematic-inc/ts-japi/compare/v1.12.1...v1.12.2) (2026-03-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Migrate tooling from eslint/prettier/yarn/husky to biome/pnpm/lefthook ([#110](https://github.com/mathematic-inc/ts-japi/issues/110)) ([8f18a95](https://github.com/mathematic-inc/ts-japi/commit/8f18a9507eb6fa49c778948df5970db3ec44dabd))
9
+
10
+ ## [1.12.1](https://github.com/mathematic-inc/ts-japi/compare/v1.12.0...v1.12.1) (2025-11-05)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * issue [#104](https://github.com/mathematic-inc/ts-japi/issues/104) by using the serializers 'idKey' field as the cache key, instead of hardcoding id ([#105](https://github.com/mathematic-inc/ts-japi/issues/105)) ([1464c06](https://github.com/mathematic-inc/ts-japi/commit/1464c067d88e331cde52756be6276129fa16b64a))
16
+
3
17
  ## [1.12.0](https://github.com/mathematic-inc/ts-japi/compare/v1.11.5...v1.12.0) (2025-06-10)
4
18
 
5
19
 
package/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -186,7 +187,7 @@
186
187
  same "printed page" as the copyright notice for easier
187
188
  identification within third-party archives.
188
189
 
189
- Copyright [yyyy] [name of copyright owner]
190
+ Copyright 2020 Mathematic Inc
190
191
 
191
192
  Licensed under the Apache License, Version 2.0 (the "License");
192
193
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -77,10 +77,10 @@ into the usage.
77
77
 
78
78
  ### Examples
79
79
 
80
- You can check the [examples](https://github.com/mathematic-inc/ts-japi/tree/master/examples) and the
81
- [test](https://github.com/mathematic-inc/ts-japi/tree/master/test) folders to see some examples
80
+ You can check the [examples](https://github.com/mathematic-inc/ts-japi/tree/main/examples) and the
81
+ [test](https://github.com/mathematic-inc/ts-japi/tree/main/test) folders to see some examples
82
82
  (such as the ones below). You can check
83
- [this example](https://github.com/mathematic-inc/ts-japi/blob/master/examples/full.example.ts) to
83
+ [this example](https://github.com/mathematic-inc/ts-japi/blob/main/examples/full.example.ts) to
84
84
  see almost every option of
85
85
  [`Serializer`](https://mathematic-inc.github.io/ts-japi/classes/serializer.html) exhausted.
86
86
 
@@ -293,7 +293,7 @@ option allows you to choose what attributes to use during serialization). _Alter
293
293
  for all server-to-client errors.
294
294
 
295
295
  The
296
- [error serializer test](https://github.com/mathematic-inc/ts-japi/tree/master/test/error-serializer.test.ts)
296
+ [error serializer test](https://github.com/mathematic-inc/ts-japi/tree/main/test/error-serializer.test.ts)
297
297
  includes an example of the alternative solution.
298
298
 
299
299
  The following example constructs the most basic
@@ -327,7 +327,7 @@ Alternatively, setting that option to `true` will provide a default
327
327
  [`Cache`](https://mathematic-inc.github.io/ts-japi/classes/cache.html).
328
328
 
329
329
  The default [`Cache`](https://mathematic-inc.github.io/ts-japi/classes/cache.html) uses the basic
330
- [`Object.is`](https://mathematic-inc.github.io/ts-japi/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
330
+ [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is)
331
331
  function to determine if input data are the same. If you want to adjust this, instantiate a new
332
332
  [`Cache`](https://mathematic-inc.github.io/ts-japi/classes/cache.html) with a
333
333
  [`resolver`](https://mathematic-inc.github.io/ts-japi/interfaces/cacheoptions.html#resolver).
@@ -369,7 +369,7 @@ to recurse through related resources via their
369
369
  This is should be done with caution (see
370
370
  [`SerializerOptions.depth`](https://mathematic-inc.github.io/ts-japi/interfaces/serializeroptions.html#depth)
371
371
  and
372
- [this example](https://github.com/mathematic-inc/ts-japi/blob/master/examples/resource-recursion.example.ts))
372
+ [this example](https://github.com/mathematic-inc/ts-japi/blob/main/examples/resource-recursion.example.ts))
373
373
 
374
374
  ## For Developers
375
375
 
@@ -384,10 +384,12 @@ find TS:JAPI on GitHub:
384
384
 
385
385
  Feel free to submit an issue, but please do not submit pull requests unless it is to fix some issue.
386
386
  For more information, read the
387
- [contribution guide](https://github.com/mathematic-inc/ts-japi/blob/master/CONTRIBUTING.html).
387
+ [contribution guide](https://github.com/mathematic-inc/ts-japi/blob/main/CONTRIBUTING.html).
388
388
 
389
389
  ## License
390
390
 
391
391
  Copyright © 2020 [mathematic-inc](https://github.com/mathematic-inc).
392
392
 
393
393
  Licensed under [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
394
+
395
+ > This project is free and open-source work by a 501(c)(3) non-profit. If you find it useful, please consider [donating](https://github.com/sponsors/mathematic-inc).
@@ -1,50 +1,50 @@
1
- import Benchmark from 'benchmark';
1
+ import Benchmark from "benchmark";
2
2
 
3
3
  const suite = new Benchmark.Suite();
4
4
 
5
5
  const a: any = new Map();
6
- a.set('test', 'test');
6
+ a.set("test", "test");
7
7
 
8
8
  const b: any = {};
9
- b.test = 'test';
9
+ b.test = "test";
10
10
 
11
- var length = 100; // user defined length
11
+ const length = 100; // user defined length
12
12
 
13
13
  const array: number[] = [];
14
14
  const map = new Map();
15
15
 
16
- for (var i = 0; i < length; i++) {
16
+ for (let i = 0; i < length; i++) {
17
17
  array.push(i);
18
18
  map.set(i, 0);
19
19
  }
20
- const tobepushed = [1, 2, 3];
20
+ const _tobepushed = [1, 2, 3];
21
21
 
22
22
  // add tests
23
23
  suite
24
- .add('Array#ForOf', async function () {
24
+ .add("Array#ForOf", async () => {
25
25
  const g = [];
26
26
  for (const test of array) {
27
27
  g.push(test);
28
28
  }
29
29
  })
30
- .add('Array#index', async function () {
30
+ .add("Array#index", async () => {
31
31
  const g = [];
32
32
  for (let i = 0, len = array.length; i < len; i++) {
33
33
  g.push(array[i]);
34
34
  }
35
35
  })
36
- .add('Array#indexWithTemp', async function () {
36
+ .add("Array#indexWithTemp", async () => {
37
37
  const g = [];
38
38
  for (let i = 0, temp = array[i]; i < array.length; temp = array[++i]) {
39
39
  g.push(temp);
40
40
  }
41
41
  })
42
42
  // add listeners
43
- .on('cycle', function (event: any) {
43
+ .on("cycle", (event: any) => {
44
44
  console.log(String(event.target));
45
45
  })
46
- .on('complete', function (this: any) {
47
- console.log('Fastest is ' + this.filter('fastest').map('name'));
46
+ .on("complete", function (this: any) {
47
+ console.log(`Fastest is ${this.filter("fastest").map("name")}`);
48
48
  })
49
49
  // run async
50
50
  .run({ async: true });
@@ -1,6 +1,6 @@
1
- import Benchmark from 'benchmark';
2
- import { Relator, Serializer } from '../src';
3
- import { Article, Comment, User } from '../test/models';
1
+ import Benchmark from "benchmark";
2
+ import { Relator, Serializer } from "../src";
3
+ import { Article, Comment, User } from "../test/models";
4
4
 
5
5
  const suite = new Benchmark.Suite();
6
6
 
@@ -13,12 +13,12 @@ for (let i = 0; i < 5; i++) {
13
13
  for (let i = 0; i < 10; i++) {
14
14
  Comment.save(new Comment(String(i), User.storage[0], Article.storage[0]));
15
15
  }
16
- let UserSerializer = new Serializer<User>('users', {
16
+ const UserSerializer = new Serializer<User>("users", {
17
17
  depth: 0, // Change to 2 to see the difference
18
18
  cache: true,
19
19
  });
20
- let CommentSerializer = new Serializer<Comment>('comments');
21
- let ArticleSerializer = new Serializer<Article>('articles');
20
+ const CommentSerializer = new Serializer<Comment>("comments");
21
+ const ArticleSerializer = new Serializer<Article>("articles");
22
22
  const UserArticleRelator = new Relator<User, Article>(
23
23
  async (user: User) => user.getArticles(),
24
24
  ArticleSerializer
@@ -39,15 +39,15 @@ const user = User.storage[0];
39
39
 
40
40
  // add tests
41
41
  suite
42
- .add('Serializer#Test', async function () {
42
+ .add("Serializer#Test", async () => {
43
43
  await UserSerializer.serialize(user);
44
44
  })
45
45
  // add listeners
46
- .on('cycle', function (event: any) {
46
+ .on("cycle", (event: any) => {
47
47
  console.log(String(event.target));
48
48
  })
49
- .on('complete', function (this: any) {
50
- console.log('Fastest is ' + this.filter('fastest').map('name'));
49
+ .on("complete", function (this: any) {
50
+ console.log(`Fastest is ${this.filter("fastest").map("name")}`);
51
51
  })
52
52
  // run async
53
53
  .run({ async: true });
package/biome.json ADDED
@@ -0,0 +1,141 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": true,
10
+ "includes": [
11
+ "!node_modules",
12
+ "!dist",
13
+ "!build",
14
+ "!**/dist",
15
+ "!**/build",
16
+ "!.pnpm-store"
17
+ ]
18
+ },
19
+ "formatter": {
20
+ "enabled": true,
21
+ "indentStyle": "space",
22
+ "indentWidth": 2
23
+ },
24
+ "linter": {
25
+ "enabled": true,
26
+ "rules": {
27
+ "recommended": true,
28
+ "style": {
29
+ "useConsistentMemberAccessibility": "off",
30
+ "noParameterProperties": "off"
31
+ },
32
+ "suspicious": {
33
+ "noExplicitAny": "off"
34
+ },
35
+ "complexity": {
36
+ "noExcessiveCognitiveComplexity": "off"
37
+ }
38
+ }
39
+ },
40
+ "assist": {
41
+ "actions": {
42
+ "source": {
43
+ "organizeImports": "on"
44
+ }
45
+ }
46
+ },
47
+ "extends": ["ultracite/core"],
48
+ "overrides": [
49
+ {
50
+ "includes": ["src/index.ts"],
51
+ "linter": {
52
+ "rules": {
53
+ "performance": { "noBarrelFile": "off" }
54
+ }
55
+ }
56
+ },
57
+ {
58
+ "includes": ["test/models/index.ts"],
59
+ "linter": {
60
+ "rules": {
61
+ "style": { "noExportedImports": "off" }
62
+ }
63
+ }
64
+ },
65
+ {
66
+ "includes": ["test/issue-62/**"],
67
+ "linter": {
68
+ "rules": {
69
+ "style": { "noNamespace": "off" }
70
+ }
71
+ }
72
+ },
73
+ {
74
+ "includes": ["test/models/**"],
75
+ "linter": {
76
+ "rules": {
77
+ "suspicious": { "noUnsafeDeclarationMerging": "off" }
78
+ }
79
+ }
80
+ },
81
+ {
82
+ "includes": ["tools/**"],
83
+ "linter": {
84
+ "rules": {
85
+ "style": {
86
+ "useFilenamingConvention": "off",
87
+ "useDefaultSwitchClause": "off",
88
+ "noNonNullAssertion": "off"
89
+ },
90
+ "performance": { "noNamespaceImport": "off" }
91
+ }
92
+ }
93
+ },
94
+ {
95
+ "includes": ["benchmarks/**"],
96
+ "linter": {
97
+ "rules": {
98
+ "suspicious": {
99
+ "useAwait": "off",
100
+ "noEvolvingTypes": "off",
101
+ "noImplicitAnyLet": "off"
102
+ }
103
+ }
104
+ }
105
+ },
106
+ {
107
+ "includes": [
108
+ "src/classes/polymorphic-serialiser.ts",
109
+ "test/issue-23.test.ts"
110
+ ],
111
+ "linter": {
112
+ "rules": {
113
+ "suspicious": { "useAwait": "off" }
114
+ }
115
+ }
116
+ },
117
+ {
118
+ "includes": ["test/**"],
119
+ "linter": {
120
+ "rules": {
121
+ "suspicious": {
122
+ "noEvolvingTypes": "off",
123
+ "noImplicitAnyLet": "off",
124
+ "useAwait": "off"
125
+ }
126
+ }
127
+ }
128
+ },
129
+ {
130
+ "includes": ["src/classes/serializer.ts"],
131
+ "linter": {
132
+ "rules": {
133
+ "suspicious": {
134
+ "noEvolvingTypes": "off",
135
+ "noImplicitAnyLet": "off"
136
+ }
137
+ }
138
+ }
139
+ }
140
+ ]
141
+ }
package/lefthook.yml ADDED
@@ -0,0 +1,12 @@
1
+ pre-commit:
2
+ jobs:
3
+ - run: pnpm exec ultracite fix
4
+ glob:
5
+ - "*.js"
6
+ - "*.jsx"
7
+ - "*.ts"
8
+ - "*.tsx"
9
+ - "*.json"
10
+ - "*.jsonc"
11
+ - "*.css"
12
+ stage_fixed: true
@@ -1,7 +1,7 @@
1
- import { CacheOptions } from '../interfaces/cache.interface';
2
- import { DataDocument } from '../interfaces/json-api.interface';
3
- import { SerializerOptions } from '../interfaces/serializer.interface';
4
- import { Dictionary, nullish, SingleOrArray } from '../types/global.types';
1
+ import type { CacheOptions } from "../interfaces/cache.interface";
2
+ import type { DataDocument } from "../interfaces/json-api.interface";
3
+ import type { SerializerOptions } from "../interfaces/serializer.interface";
4
+ import type { Dictionary, nullish, SingleOrArray } from "../types/global.types";
5
5
  export default class Cache<PrimaryType extends Dictionary<any>> {
6
6
  /**
7
7
  * The default max for document storage
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/classes/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3E,MAAM,CAAC,OAAO,OAAO,KAAK,CAAC,WAAW,SAAS,UAAU,CAAC,GAAG,CAAC;IAC5D;;OAEG;IACH,OAAc,YAAY,SAAM;IAEhC,0CAA0C;IAC1C,OAAO,CAAC,OAAO,CAMR;IAEP;;OAEG;IACH,OAAO,CAAC,KAAK,CAA8B;IAE3C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAGS;IAEzB;;;;OAIG;gBACgB,OAAO,GAAE,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAM;IAKnE,6CAA6C;IACtC,GAAG,CACR,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,EAC1C,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAUnD,6CAA6C;IACtC,GAAG,CACR,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,EAC1C,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAQpD"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/classes/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEhF,MAAM,CAAC,OAAO,OAAO,KAAK,CAAC,WAAW,SAAS,UAAU,CAAC,GAAG,CAAC;IAC5D;;OAEG;IACH,OAAc,YAAY,SAAM;IAEhC,0CAA0C;IAC1C,OAAO,CAAC,OAAO,CAIN;IAET;;OAEG;IACH,OAAO,CAAC,KAAK,CAA8B;IAE3C;;OAEG;IACH,OAAO,CAAC,QAAQ,CAGS;IAEzB;;;;OAIG;gBACgB,OAAO,GAAE,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAM;IASnE,6CAA6C;IACtC,GAAG,CACR,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,EAC1C,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAYnD,6CAA6C;IACtC,GAAG,CACR,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,EAC1C,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,EAC5C,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAQpD"}