ts-japi 1.6.1 → 1.7.0

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 (91) hide show
  1. package/.commitlintrc.ts +3 -0
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +5 -6
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +4 -5
  4. package/.github/ISSUE_TEMPLATE/request-for-comments.md +29 -42
  5. package/.github/release-please.yml +4 -0
  6. package/.github/workflows/ci.yaml +73 -0
  7. package/.github/workflows/publish.yaml +29 -0
  8. package/.husky/pre-commit +4 -0
  9. package/.husky/pre-push +4 -0
  10. package/.prettierignore +2 -0
  11. package/.release-please-manifest.json +3 -0
  12. package/CHANGELOG.md +14 -1
  13. package/Makefile +1 -27
  14. package/README.md +145 -75
  15. package/api-extractor.json +14 -0
  16. package/lib/classes/cache.d.ts +2 -2
  17. package/lib/classes/cache.js +26 -48
  18. package/lib/classes/cache.js.map +1 -1
  19. package/lib/classes/error-serializer.d.ts +6 -6
  20. package/lib/classes/error-serializer.js +58 -125
  21. package/lib/classes/error-serializer.js.map +1 -1
  22. package/lib/classes/linker.d.ts +5 -5
  23. package/lib/classes/linker.d.ts.map +1 -1
  24. package/lib/classes/linker.js +15 -41
  25. package/lib/classes/linker.js.map +1 -1
  26. package/lib/classes/metaizer.d.ts +4 -4
  27. package/lib/classes/metaizer.d.ts.map +1 -1
  28. package/lib/classes/metaizer.js +12 -38
  29. package/lib/classes/metaizer.js.map +1 -1
  30. package/lib/classes/paginator.d.ts +3 -3
  31. package/lib/classes/paginator.js +17 -16
  32. package/lib/classes/paginator.js.map +1 -1
  33. package/lib/classes/relator.d.ts +7 -7
  34. package/lib/classes/relator.d.ts.map +1 -1
  35. package/lib/classes/relator.js +75 -135
  36. package/lib/classes/relator.js.map +1 -1
  37. package/lib/classes/serializer.d.ts +9 -9
  38. package/lib/classes/serializer.d.ts.map +1 -1
  39. package/lib/classes/serializer.js +216 -316
  40. package/lib/classes/serializer.js.map +1 -1
  41. package/lib/index.js +17 -10
  42. package/lib/index.js.map +1 -1
  43. package/lib/interfaces/cache.interface.d.ts +2 -2
  44. package/lib/interfaces/cache.interface.js +1 -1
  45. package/lib/interfaces/error-serializer.interface.d.ts +11 -11
  46. package/lib/interfaces/error-serializer.interface.js +1 -1
  47. package/lib/interfaces/error.interface.js +1 -1
  48. package/lib/interfaces/json-api.interface.js +1 -1
  49. package/lib/interfaces/linker.interface.d.ts +1 -1
  50. package/lib/interfaces/linker.interface.js +1 -1
  51. package/lib/interfaces/paginator.interface.js +1 -1
  52. package/lib/interfaces/relator.interface.d.ts +5 -4
  53. package/lib/interfaces/relator.interface.d.ts.map +1 -1
  54. package/lib/interfaces/relator.interface.js +1 -1
  55. package/lib/interfaces/serializer.interface.d.ts +24 -24
  56. package/lib/interfaces/serializer.interface.js +1 -1
  57. package/lib/models/error.model.d.ts +1 -1
  58. package/lib/models/error.model.d.ts.map +1 -1
  59. package/lib/models/error.model.js +67 -22
  60. package/lib/models/error.model.js.map +1 -1
  61. package/lib/models/link.model.js +11 -10
  62. package/lib/models/link.model.js.map +1 -1
  63. package/lib/models/meta.model.js +5 -6
  64. package/lib/models/meta.model.js.map +1 -1
  65. package/lib/models/relationship.model.js +8 -6
  66. package/lib/models/relationship.model.js.map +1 -1
  67. package/lib/models/resource-identifier.model.js +11 -9
  68. package/lib/models/resource-identifier.model.js.map +1 -1
  69. package/lib/models/resource.model.js +13 -28
  70. package/lib/models/resource.model.js.map +1 -1
  71. package/lib/types/global.types.js +1 -1
  72. package/lib/utils/is-error-document.d.ts +1 -1
  73. package/lib/utils/is-error-document.js +6 -8
  74. package/lib/utils/is-error-document.js.map +1 -1
  75. package/lib/utils/is-object.js +1 -1
  76. package/lib/utils/is-plain-object.js +4 -4
  77. package/lib/utils/is-plain-object.js.map +1 -1
  78. package/lib/utils/merge.d.ts +2 -2
  79. package/lib/utils/merge.js +16 -63
  80. package/lib/utils/merge.js.map +1 -1
  81. package/lib/utils/serializer.utils.js +56 -202
  82. package/lib/utils/serializer.utils.js.map +1 -1
  83. package/package.json +47 -30
  84. package/release-please-config.json +10 -0
  85. package/tools/generate_docs.ts +33 -0
  86. package/tools/internal/custom_markdown_action.ts +32 -0
  87. package/tools/internal/custom_markdown_documenter.ts +1337 -0
  88. package/tsconfig.json +56 -80
  89. package/.changeset/README.md +0 -8
  90. package/.changeset/config.json +0 -10
  91. package/CONTRIBUTING.md +0 -127
@@ -0,0 +1,3 @@
1
+ export default {
2
+ extends: ['@commitlint/config-conventional'],
3
+ };
@@ -1,21 +1,20 @@
1
1
  ---
2
2
  name: Bug report
3
3
  about: Create a report to help us improve
4
- title: "[BUG] {{issue name}}"
4
+ title: '[BUG] {{issue name}}'
5
5
  labels: bug
6
6
  assignees: jun-sheaf
7
-
8
7
  ---
9
8
 
10
- ## Describe the bug<sup>*</sup>
9
+ ## Describe the bug<sup>\*</sup>
11
10
 
12
11
  {{A clear and concise description of what the bug is.}}
13
12
 
14
- ## To Reproduce<sup>*</sup>
13
+ ## To Reproduce<sup>\*</sup>
15
14
 
16
15
  {{Add steps/examples to reproduce the behavior.}}
17
16
 
18
- ## Expected behavior<sup>*</sup>
17
+ ## Expected behavior<sup>\*</sup>
19
18
 
20
19
  {{A clear and concise description of what you expected to happen.}}
21
20
 
@@ -23,7 +22,7 @@ assignees: jun-sheaf
23
22
 
24
23
  {{Add screenshots to help explain your problem.}}
25
24
 
26
- ## Platform<sup>*</sup>
25
+ ## Platform<sup>\*</sup>
27
26
 
28
27
  - [ ] OS: {{ Write the OS name and its version }}
29
28
  - [ ] Browser {{ Write the browser name and its version }}
@@ -1,21 +1,20 @@
1
1
  ---
2
2
  name: Feature request
3
3
  about: Suggest an idea for this project
4
- title: "[FR] {{feature request name}}"
4
+ title: '[FR] {{feature request name}}'
5
5
  labels: enhancement
6
6
  assignees: jun-sheaf
7
-
8
7
  ---
9
8
 
10
- ## Is your feature request related to a problem? <sup>*</sup>
9
+ ## Is your feature request related to a problem? <sup>\*</sup>
11
10
 
12
11
  {{A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]}}
13
12
 
14
- ## Describe the solution you'd like<sup>*</sup>
13
+ ## Describe the solution you'd like<sup>\*</sup>
15
14
 
16
15
  {{A clear and concise description of what you want to happen.}}
17
16
 
18
- ## Describe alternatives you've considered<sup>*</sup>
17
+ ## Describe alternatives you've considered<sup>\*</sup>
19
18
 
20
19
  {{A clear and concise description of any alternative solutions or features you've considered.}}
21
20
 
@@ -1,24 +1,23 @@
1
1
  ---
2
2
  name: Request for comments
3
3
  about: Request for comments around the community.
4
- title: "[RFC] {{RFC name}}"
4
+ title: '[RFC] {{RFC name}}'
5
5
  labels: good first issue, question
6
6
  assignees: jun-sheaf
7
-
8
7
  ---
9
8
 
10
- ## Summary<sup>*</sup>
9
+ ## Summary<sup>\*</sup>
11
10
 
12
11
  {{One paragraph explanation of the change}}
13
12
 
14
- ## Motivation<sup>*</sup>
13
+ ## Motivation<sup>\*</sup>
15
14
 
16
15
  {{
17
16
  Why are we doing this? What use cases does it support? What is the expected
18
17
  outcome?
19
18
  }}
20
19
 
21
- ## Design Detail<sup>*</sup>
20
+ ## Design Detail<sup>\*</sup>
22
21
 
23
22
  {{
24
23
  Explain the design in enough detail for somebody familiar with the
@@ -27,7 +26,7 @@ and can include examples of how the service is used. Any new terminology should
27
26
  be defined here.
28
27
  }}
29
28
 
30
- ## Drawbacks<sup>*</sup>
29
+ ## Drawbacks<sup>\*</sup>
31
30
 
32
31
  {{
33
32
  Why should we *not* do this? Please consider the impact on users, on the
@@ -35,50 +34,38 @@ integration of this change with other existing and planned features etc. There
35
34
  are tradeoffs to choosing any path, please attempt to identify them here.
36
35
  }}
37
36
 
38
- ## Rationale and Alternatives<sup>*</sup>
37
+ ## Rationale and Alternatives<sup>\*</sup>
39
38
 
40
- {{
41
- Why is this design the best in the space of possible designs?
39
+ {{ Why is this design the best in the space of possible designs?
42
40
 
43
- What other designs have been considered and what is the rationale for not
44
- choosing them?
41
+ What other designs have been considered and what is the rationale for not choosing them?
45
42
 
46
- What is the impact of not doing this?
47
- }}
43
+ What is the impact of not doing this? }}
48
44
 
49
- ## Prior Art<sup>*</sup>
45
+ ## Prior Art<sup>\*</sup>
50
46
 
51
- {{
52
- Discuss prior art, both the good and the bad, in relation to this proposal. A
53
- few examples of what this can include are:
54
-
55
- {{
56
- How other services / infrastructures in the same domain have solved this
57
- problem.
58
-
59
- Are there any published papers or great posts that discuss this? If you have
60
- some relevant papers to refer to, this can serve as a more detailed
61
- theoretical background.
62
- }}
63
-
64
- This section is intended to encourage you as an author to think about the
65
- lessons from other organisations, provide readers of your RFC with a fuller
66
- picture. If there is no prior art, that is fine - your ideas are interesting
67
- whether they are brand new or if it is an adaptation from other services.
68
- }}
47
+ {{ Discuss prior art, both the good and the bad, in relation to this proposal. A few examples of
48
+ what this can include are:
69
49
 
70
- ## Unresolved questions<sup>*</sup>
50
+ {{ How other services / infrastructures in the same domain have solved this problem.
71
51
 
72
- {{
73
- What parts of the design do you expect to resolve through the RFC process
74
- before this gets merged?
52
+ Are there any published papers or great posts that discuss this? If you have some relevant papers to
53
+ refer to, this can serve as a more detailed theoretical background. }}
75
54
 
76
- What parts of the design do you expect to resolve through the implementation of
77
- this feature before stabilisation?
55
+ This section is intended to encourage you as an author to think about the lessons from other
56
+ organisations, provide readers of your RFC with a fuller picture. If there is no prior art, that is
57
+ fine - your ideas are interesting whether they are brand new or if it is an adaptation from other
58
+ services. }}
78
59
 
79
- What related issues do you consider out of scope for this RFC that could be
80
- addressed in the future independently of the solution that comes out of this
81
- RFC?
82
- }}
60
+ ## Unresolved questions<sup>\*</sup>
61
+
62
+ {{ What parts of the design do you expect to resolve through the RFC process before this gets
63
+ merged?
64
+
65
+ What parts of the design do you expect to resolve through the implementation of this feature before
66
+ stabilisation?
67
+
68
+ What related issues do you consider out of scope for this RFC that could be addressed in the future
69
+ independently of the solution that comes out of this RFC? }}
83
70
 
84
71
  \* means required.
@@ -0,0 +1,4 @@
1
+ releaseType: node
2
+ primaryBranch: main
3
+ handleGHRelease: true
4
+ manifest: true
@@ -0,0 +1,73 @@
1
+ name: CI
2
+
3
+ # Declare default permissions as read only.
4
+ permissions: read-all
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - main
10
+ pull_request:
11
+ branches:
12
+ - '**'
13
+
14
+ concurrency:
15
+ group: ${{ github.head_ref || github.run_id }}
16
+ cancel-in-progress: true
17
+
18
+ jobs:
19
+ inspect-code:
20
+ name: Inspect code
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - name: Checkout
24
+ uses: actions/checkout@v3
25
+ with:
26
+ fetch-depth: 2
27
+ - name: Set up Node.js
28
+ uses: actions/setup-node@v3.4.1
29
+ with:
30
+ node-version: 18
31
+ - name: Install dependencies
32
+ run: yarn install --frozen-lockfile
33
+ - name: Lint code
34
+ run: yarn lint
35
+ - name: Lint commits
36
+ run: yarn commitlint
37
+ if: github.event_name != 'pull_request'
38
+
39
+ tests:
40
+ name: ${{ matrix.spec.name }} tests (${{ matrix.spec.node }})
41
+ runs-on: ${{ matrix.spec.machine }}
42
+ continue-on-error: true
43
+ strategy:
44
+ matrix:
45
+ spec:
46
+ - name: Linux
47
+ machine: ubuntu-latest
48
+ node: 14
49
+ - name: Linux
50
+ machine: ubuntu-latest
51
+ node: 16
52
+ - name: Linux
53
+ machine: ubuntu-latest
54
+ node: 18
55
+ - name: macOS
56
+ machine: macos-latest
57
+ node: 14
58
+ - name: Windows
59
+ machine: windows-latest
60
+ node: 14
61
+ steps:
62
+ - name: Checkout
63
+ uses: actions/checkout@v3
64
+ - name: Set up Node.js
65
+ uses: actions/setup-node@v3.4.1
66
+ with:
67
+ node-version: ${{ matrix.spec.node }}
68
+ - name: Install dependencies
69
+ run: yarn install --frozen-lockfile
70
+ - name: Build
71
+ run: yarn build
72
+ - name: Test
73
+ run: yarn test
@@ -0,0 +1,29 @@
1
+ name: Publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ tags:
7
+ - v*
8
+
9
+ jobs:
10
+ publish:
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v3
17
+ - name: Set up Node.js
18
+ uses: actions/setup-node@v3.4.1
19
+ with:
20
+ node-version: 18
21
+ registry-url: 'https://registry.npmjs.org'
22
+ - name: Install dependencies
23
+ run: yarn install --frozen-lockfile
24
+ - name: Build
25
+ run: yarn build
26
+ - name: Publish
27
+ run: npm publish
28
+ env:
29
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ yarn lint
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ yarn commitlint
@@ -0,0 +1,2 @@
1
+ CHANGELOG.md
2
+ docs
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "1.7.0"
3
+ }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.7.0](https://github.com/mathematic-inc/ts-japi/compare/v1.6.3...v1.7.0) (2022-08-05)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * ignore relationships if they're not set to support optional relations ([#49](https://github.com/mathematic-inc/ts-japi/issues/49)) ([7bd7d53](https://github.com/mathematic-inc/ts-japi/commit/7bd7d5372c96841583dce9bd01a8bbb4cb220b8e))
9
+
10
+ ## 1.6.2
11
+
12
+ ### Patch Changes
13
+
14
+ - c5a8201: Add customisable relationship names
15
+
3
16
  ## 1.6.1
4
17
 
5
18
  ### Patch Changes
@@ -24,7 +37,7 @@
24
37
 
25
38
  ### Minor Changes
26
39
 
27
- - Fixes https://github.com/mu-io/ts-japi/issues/23
40
+ - Fixes https://github.com/mathematic-inc/ts-japi/issues/23
28
41
 
29
42
  ## 1.4.0
30
43
 
package/Makefile CHANGED
@@ -1,33 +1,7 @@
1
1
  PATH:=$(PATH):$(PWD)/node_modules/.bin
2
2
  SHELL:=env PATH=$(PATH) /bin/bash
3
3
 
4
- all: lib docs README.md
5
-
6
- lib: $(shell find src -name '*.ts')
7
- @echo 'Building library...'
8
- @tsc
9
-
10
- docs: $(shell find src -name '*.ts')
11
- @echo 'Building documentation...'
12
- @typedoc
13
- @rsync -a ./src/docs/assets ./docs
14
-
15
- README.md: src/docs/README.md
16
- @echo 'Building README...'
17
- @typedoc --plugin typedoc-plugin-markdown --out ./md-docs --theme markdown
18
- @mv md-docs/README.md README.md
19
- @rm -rf md-docs
20
- @ts-node scripts/readme-postbuild.ts
21
-
22
- clean: clean-docs clean-readme clean-build clean-coverage
23
-
24
- clean-docs:
25
- @echo 'Cleaning documentation...'
26
- @rm -rf ./docs
27
-
28
- clean-readme:
29
- @echo 'Cleaning README...'
30
- @rm -rf ./readme
4
+ clean: clean-build clean-coverage
31
5
 
32
6
  clean-lib:
33
7
  @echo 'Cleaning build artifacts...'