ts-japi 1.5.1 → 1.6.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.
- package/.prettierrc +10 -0
- package/CHANGELOG.md +56 -16
- package/Makefile +19 -0
- package/README.md +235 -159
- package/api-extractor.json +14 -0
- package/benchmarks/playground.benchmark.ts +32 -32
- package/benchmarks/serializer.benchmark.ts +29 -29
- package/lib/classes/cache.d.ts +6 -6
- package/lib/classes/cache.d.ts.map +1 -1
- package/lib/classes/cache.js +26 -48
- package/lib/classes/cache.js.map +1 -1
- package/lib/classes/error-serializer.d.ts +9 -9
- package/lib/classes/error-serializer.d.ts.map +1 -1
- package/lib/classes/error-serializer.js +58 -125
- package/lib/classes/error-serializer.js.map +1 -1
- package/lib/classes/linker.d.ts +8 -8
- package/lib/classes/linker.d.ts.map +1 -1
- package/lib/classes/linker.js +15 -40
- package/lib/classes/linker.js.map +1 -1
- package/lib/classes/metaizer.d.ts +6 -6
- package/lib/classes/metaizer.d.ts.map +1 -1
- package/lib/classes/metaizer.js +12 -37
- package/lib/classes/metaizer.js.map +1 -1
- package/lib/classes/paginator.d.ts +6 -6
- package/lib/classes/paginator.d.ts.map +1 -1
- package/lib/classes/paginator.js +17 -16
- package/lib/classes/paginator.js.map +1 -1
- package/lib/classes/relator.d.ts +19 -18
- package/lib/classes/relator.d.ts.map +1 -1
- package/lib/classes/relator.js +70 -110
- package/lib/classes/relator.js.map +1 -1
- package/lib/classes/serializer.d.ts +20 -19
- package/lib/classes/serializer.d.ts.map +1 -1
- package/lib/classes/serializer.js +213 -311
- package/lib/classes/serializer.js.map +1 -1
- package/lib/index.d.ts +20 -20
- package/lib/index.js +17 -10
- package/lib/index.js.map +1 -1
- package/lib/interfaces/cache.interface.d.ts +3 -3
- package/lib/interfaces/cache.interface.d.ts.map +1 -1
- package/lib/interfaces/cache.interface.js +1 -1
- package/lib/interfaces/error-serializer.interface.d.ts +15 -15
- package/lib/interfaces/error-serializer.interface.d.ts.map +1 -1
- package/lib/interfaces/error-serializer.interface.js +1 -1
- package/lib/interfaces/error.interface.d.ts.map +1 -1
- package/lib/interfaces/error.interface.js +1 -1
- package/lib/interfaces/json-api.interface.d.ts +7 -7
- package/lib/interfaces/json-api.interface.d.ts.map +1 -1
- package/lib/interfaces/json-api.interface.js +1 -1
- package/lib/interfaces/linker.interface.d.ts +2 -2
- package/lib/interfaces/linker.interface.d.ts.map +1 -1
- package/lib/interfaces/linker.interface.js +1 -1
- package/lib/interfaces/paginator.interface.d.ts +1 -1
- package/lib/interfaces/paginator.interface.d.ts.map +1 -1
- package/lib/interfaces/paginator.interface.js +1 -1
- package/lib/interfaces/relator.interface.d.ts +7 -7
- package/lib/interfaces/relator.interface.d.ts.map +1 -1
- package/lib/interfaces/relator.interface.js +1 -1
- package/lib/interfaces/serializer.interface.d.ts +30 -30
- package/lib/interfaces/serializer.interface.d.ts.map +1 -1
- package/lib/interfaces/serializer.interface.js +1 -1
- package/lib/models/error.model.d.ts +5 -5
- package/lib/models/error.model.d.ts.map +1 -1
- package/lib/models/error.model.js +59 -22
- package/lib/models/error.model.js.map +1 -1
- package/lib/models/link.model.d.ts +2 -2
- package/lib/models/link.model.d.ts.map +1 -1
- package/lib/models/link.model.js +11 -10
- package/lib/models/link.model.js.map +1 -1
- package/lib/models/meta.model.d.ts.map +1 -1
- package/lib/models/meta.model.js +5 -6
- package/lib/models/meta.model.js.map +1 -1
- package/lib/models/relationship.model.d.ts +4 -4
- package/lib/models/relationship.model.d.ts.map +1 -1
- package/lib/models/relationship.model.js +11 -9
- package/lib/models/relationship.model.js.map +1 -1
- package/lib/models/resource-identifier.model.d.ts +1 -1
- package/lib/models/resource-identifier.model.d.ts.map +1 -1
- package/lib/models/resource-identifier.model.js +11 -9
- package/lib/models/resource-identifier.model.js.map +1 -1
- package/lib/models/resource.model.d.ts +4 -4
- package/lib/models/resource.model.d.ts.map +1 -1
- package/lib/models/resource.model.js +13 -26
- package/lib/models/resource.model.js.map +1 -1
- package/lib/tsdoc-metadata.json +11 -0
- package/lib/types/global.types.d.ts.map +1 -1
- package/lib/types/global.types.js +1 -1
- package/lib/utils/is-error-document.d.ts +2 -2
- package/lib/utils/is-error-document.js +7 -9
- package/lib/utils/is-error-document.js.map +1 -1
- package/lib/utils/is-object.js +2 -2
- package/lib/utils/is-object.js.map +1 -1
- package/lib/utils/is-plain-object.js +6 -6
- package/lib/utils/is-plain-object.js.map +1 -1
- package/lib/utils/merge.d.ts +3 -3
- package/lib/utils/merge.d.ts.map +1 -1
- package/lib/utils/merge.js +16 -62
- package/lib/utils/merge.js.map +1 -1
- package/lib/utils/serializer.utils.d.ts +5 -4
- package/lib/utils/serializer.utils.d.ts.map +1 -1
- package/lib/utils/serializer.utils.js +57 -168
- package/lib/utils/serializer.utils.js.map +1 -1
- package/package.json +94 -107
- package/tools/generate_docs.ts +33 -0
- package/tools/internal/custom_markdown_action.ts +32 -0
- package/tools/internal/custom_markdown_documenter.ts +1337 -0
- package/tsconfig.json +60 -83
- package/CONTRIBUTING.md +0 -127
package/.prettierrc
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c5a8201: Add customisable relationship names
|
|
8
|
+
|
|
9
|
+
## 1.6.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- d5cd4d1: Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 1.6.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- bd4c358: Add `relatorDataCache` in serialize method to avoid duplicate lookups during
|
|
20
|
+
`recurseRelators` call
|
|
21
|
+
|
|
3
22
|
## 1.5.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -11,7 +30,7 @@
|
|
|
11
30
|
|
|
12
31
|
### Minor Changes
|
|
13
32
|
|
|
14
|
-
- Fixes https://github.com/
|
|
33
|
+
- Fixes https://github.com/mathematic-inc/ts-japi/issues/23
|
|
15
34
|
|
|
16
35
|
## 1.4.0
|
|
17
36
|
|
|
@@ -23,8 +42,12 @@
|
|
|
23
42
|
|
|
24
43
|
### Added
|
|
25
44
|
|
|
26
|
-
- Added an `isErrorDocument` function to detect JSON:API Error documents. This function allows you
|
|
27
|
-
|
|
45
|
+
- Added an `isErrorDocument` function to detect JSON:API Error documents. This function allows you
|
|
46
|
+
to treat the argument _as if it were an error document_ (there is obviously no way to know if it
|
|
47
|
+
really is a JSON:API error document at runtime).
|
|
48
|
+
- Added an `isLikeJapiError` function to detect JSON:API Error. This function allows you to treat
|
|
49
|
+
the argument _as if it were an JSON:API error_ (there is obviously no way to know if it really is
|
|
50
|
+
a JSON:API error at runtime).
|
|
28
51
|
|
|
29
52
|
### Changed
|
|
30
53
|
|
|
@@ -47,7 +70,8 @@
|
|
|
47
70
|
### Changed
|
|
48
71
|
|
|
49
72
|
- Exported interfaces related to JSON:API.
|
|
50
|
-
- The Error and Data document interfaces now require the "errors" and "data" properties
|
|
73
|
+
- The Error and Data document interfaces now require the "errors" and "data" properties
|
|
74
|
+
respectively.
|
|
51
75
|
- The Base document interface has been abstracted further by removing the "meta" property.
|
|
52
76
|
- A _new_ Meta document interface is now available for type-checking.
|
|
53
77
|
|
|
@@ -68,8 +92,10 @@
|
|
|
68
92
|
|
|
69
93
|
### Added
|
|
70
94
|
|
|
71
|
-
- A new `Cache` class is now available to use for caching. You can set this in the `cache` option
|
|
72
|
-
|
|
95
|
+
- A new `Cache` class is now available to use for caching. You can set this in the `cache` option
|
|
96
|
+
for a `Serializer` (use `true` if you want the built in cache).
|
|
97
|
+
- With caching, there is a ~586% speed improvement (412,768 ops/sec over the previous 70,435
|
|
98
|
+
ops/sec). Without-caching rates have stayed the same.
|
|
73
99
|
|
|
74
100
|
## [1.2.1] - 2020-05-27
|
|
75
101
|
|
|
@@ -79,11 +105,15 @@
|
|
|
79
105
|
|
|
80
106
|
## [1.2.0] - 2020-05-26
|
|
81
107
|
|
|
82
|
-
So, `ts-japi` has only been released a few days, but after some significant use in my APIs, I have
|
|
108
|
+
So, `ts-japi` has only been released a few days, but after some significant use in my APIs, I have
|
|
109
|
+
realized a few things:
|
|
83
110
|
|
|
84
|
-
1. Linkers and certain classes should be allowed to parse `nullish` data (`nullish` meaning
|
|
85
|
-
|
|
86
|
-
|
|
111
|
+
1. Linkers and certain classes should be allowed to parse `nullish` data (`nullish` meaning
|
|
112
|
+
`undefined` or `null`).
|
|
113
|
+
2. The `relationships object` should be allowed to have custom keys, not dependent on the `relators`
|
|
114
|
+
options
|
|
115
|
+
- `Relator`s should always have a `Serializer`; otherwise, they wouldn't relate to any `resource`
|
|
116
|
+
per se.
|
|
87
117
|
3. Projections should be "choose included" or "choose excluded" similar to MongoDB's.
|
|
88
118
|
4. The code can be faster.
|
|
89
119
|
|
|
@@ -91,15 +121,22 @@ With this in mind, here are the changes.
|
|
|
91
121
|
|
|
92
122
|
### Changed
|
|
93
123
|
|
|
94
|
-
- **[Breaking Change]** Every relator must define a `Serializer` as the second argument in its
|
|
95
|
-
|
|
96
|
-
-
|
|
124
|
+
- **[Breaking Change]** Every relator must define a `Serializer` as the second argument in its
|
|
125
|
+
constructor (as opposed to the relator's options. Options can go in the third argument.
|
|
126
|
+
- It may be subtle, but the reason for this lies in the fact `relationships object` must be keyed
|
|
127
|
+
by the related object. If the relator has no serializer, then the relator has no related name,
|
|
128
|
+
hence there is no canonical way to key the relationship.
|
|
129
|
+
- We will now allow objects of relators to be defined as an option for `relators` on
|
|
130
|
+
`Serializer`s. By using objects, the key for the relationship generated by the relator will
|
|
131
|
+
correspond to the same key for that of the relator's.
|
|
97
132
|
- Several functional options now allow for `nullish` (`null` or `undefined`) arguments:
|
|
98
133
|
- Resource Linkers can now type-safely use `nullish` arguments.
|
|
99
134
|
- Resource Metaizers can now type-safely use `nullish` arguments.
|
|
100
135
|
- Several plain options now allow for `nullish` (`null` or `undefined`):
|
|
101
|
-
- Serializer `projection` option has changed significantly (see the option itself) with `nullish`
|
|
102
|
-
|
|
136
|
+
- Serializer `projection` option has changed significantly (see the option itself) with `nullish`
|
|
137
|
+
values.
|
|
138
|
+
- There is a ~33% speed improvement. (70,435 ops/sec over 52,843 ops/sec on a low-end Macbook Pro
|
|
139
|
+
15")
|
|
103
140
|
|
|
104
141
|
### Added
|
|
105
142
|
|
|
@@ -107,4 +144,7 @@ With this in mind, here are the changes.
|
|
|
107
144
|
|
|
108
145
|
#### Important Note
|
|
109
146
|
|
|
110
|
-
I want to say this IS unusual to have a breaking change without depreciation, but given the fact
|
|
147
|
+
I want to say this IS unusual to have a breaking change without depreciation, but given the fact
|
|
148
|
+
this package is only a few days old, I want to apologize if you are bothered by the above break.
|
|
149
|
+
However, I will guarantee that API changes will go through depreciation before removal, so happy
|
|
150
|
+
coding :)
|
package/Makefile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
PATH:=$(PATH):$(PWD)/node_modules/.bin
|
|
2
|
+
SHELL:=env PATH=$(PATH) /bin/bash
|
|
3
|
+
|
|
4
|
+
clean: clean-build clean-coverage
|
|
5
|
+
|
|
6
|
+
clean-lib:
|
|
7
|
+
@echo 'Cleaning build artifacts...'
|
|
8
|
+
@rm -rf ./lib
|
|
9
|
+
|
|
10
|
+
clean-coverage:
|
|
11
|
+
@echo 'Cleaning test coverage...'
|
|
12
|
+
@rm -rf ./coverage
|
|
13
|
+
|
|
14
|
+
.PHONY: all
|
|
15
|
+
.PHONY: clean
|
|
16
|
+
.PHONY: clean-docs
|
|
17
|
+
.PHONY: clean-readme
|
|
18
|
+
.PHONY: clean-lib
|
|
19
|
+
.PHONY: clean-coverage
|