@nymphjs/nymph 1.0.0-beta.6 → 1.0.0-beta.61
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/CHANGELOG.md +277 -0
- package/README.md +13 -21
- package/dist/Entity.d.ts +269 -7
- package/dist/Entity.js +431 -89
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +38 -16
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +225 -19
- package/dist/Nymph.d.ts +423 -11
- package/dist/Nymph.js +649 -156
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +31 -7
- package/dist/Nymph.types.js +2 -1
- package/dist/Nymph.types.js.map +1 -1
- package/dist/conf/d.d.ts +26 -0
- package/dist/conf/defaults.js +22 -0
- package/dist/conf/defaults.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +111 -36
- package/dist/driver/NymphDriver.js +169 -68
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.d.ts +1 -1
- package/dist/driver/testArtifacts.js +285 -18
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/EntityInvalidDataError.d.ts +6 -0
- package/dist/errors/EntityInvalidDataError.js +6 -0
- package/dist/errors/EntityInvalidDataError.js.map +1 -1
- package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
- package/dist/errors/EntityUniqueConstraintError.js +11 -0
- package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
- package/dist/errors/InvalidStateError.d.ts +3 -0
- package/dist/errors/InvalidStateError.js +11 -0
- package/dist/errors/InvalidStateError.js.map +1 -0
- package/dist/errors/QueryFailedError.js.map +1 -1
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +17 -5
- package/dist/testArtifacts.js +23 -19
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +15 -10
- package/dist/testMocks.js +34 -11
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +21 -5
- package/dist/utils.js.map +1 -1
- package/package.json +16 -14
- package/src/Entity.test.ts +30 -10
- package/src/Entity.ts +406 -135
- package/src/Entity.types.ts +32 -66
- package/src/Nymph.ts +626 -196
- package/src/Nymph.types.ts +97 -26
- package/src/conf/d.ts +8 -0
- package/src/conf/defaults.ts +24 -0
- package/src/driver/NymphDriver.ts +187 -243
- package/src/driver/testArtifacts.ts +327 -146
- package/src/errors/EntityUniqueConstraintError.ts +6 -0
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/index.ts +4 -0
- package/src/nymphJoiProps.ts +2 -2
- package/src/testArtifacts.ts +18 -19
- package/src/testMocks.ts +64 -32
- package/src/utils.ts +22 -8
- package/tsconfig.json +1 -1
- package/typedoc.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,283 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-beta.61](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.60...v1.0.0-beta.61) (2024-06-14)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
9
|
+
|
|
10
|
+
# [1.0.0-beta.60](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.59...v1.0.0-beta.60) (2024-06-14)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
13
|
+
|
|
14
|
+
# [1.0.0-beta.59](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.58...v1.0.0-beta.59) (2024-06-14)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- add uniqueness constraint feature, refactor some types ([8133d32](https://github.com/sciactive/nymphjs/commit/8133d32b2c04907182dca2e9171b8217ed1b57e4))
|
|
19
|
+
|
|
20
|
+
# [1.0.0-beta.58](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.57...v1.0.0-beta.58) (2024-06-12)
|
|
21
|
+
|
|
22
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
23
|
+
|
|
24
|
+
# [1.0.0-beta.57](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.56...v1.0.0-beta.57) (2024-06-12)
|
|
25
|
+
|
|
26
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
27
|
+
|
|
28
|
+
# [1.0.0-beta.56](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.55...v1.0.0-beta.56) (2024-06-11)
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
|
|
32
|
+
- add debug and error logging feature ([95680ef](https://github.com/sciactive/nymphjs/commit/95680efad0a260589f32e3d8cff0f4c4e7de413b))
|
|
33
|
+
- allow connections where tokens are not renewed ([39071a5](https://github.com/sciactive/nymphjs/commit/39071a545644075190bd8213be25e0a0c46d2b5d))
|
|
34
|
+
- make transaction optional during import and off by default ([08d79f8](https://github.com/sciactive/nymphjs/commit/08d79f8f803c846ac79c0c489fc754437dae082b))
|
|
35
|
+
|
|
36
|
+
# [1.0.0-beta.55](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.54...v1.0.0-beta.55) (2024-05-26)
|
|
37
|
+
|
|
38
|
+
### Bug Fixes
|
|
39
|
+
|
|
40
|
+
- cache check with no selectors ([f3a6215](https://github.com/sciactive/nymphjs/commit/f3a6215c7b1443f039b979ed400823c6f7f88236))
|
|
41
|
+
|
|
42
|
+
# [1.0.0-beta.54](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.53...v1.0.0-beta.54) (2024-05-26)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
45
|
+
|
|
46
|
+
# [1.0.0-beta.53](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.52...v1.0.0-beta.53) (2024-05-26)
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
- add pragma statements config to sqlite3 driver ([b0f27e2](https://github.com/sciactive/nymphjs/commit/b0f27e24df85663ea777565e5d352775efcad858))
|
|
51
|
+
|
|
52
|
+
# [1.0.0-beta.52](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.51...v1.0.0-beta.52) (2024-05-25)
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
- support setup app and users and groups when userFields is limited ([20e25a2](https://github.com/sciactive/nymphjs/commit/20e25a2bcc35f96b3146fd9d973e34083a85f854))
|
|
57
|
+
|
|
58
|
+
# [1.0.0-beta.51](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.50...v1.0.0-beta.51) (2024-04-12)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
61
|
+
|
|
62
|
+
# [1.0.0-beta.50](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.49...v1.0.0-beta.50) (2024-04-08)
|
|
63
|
+
|
|
64
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
65
|
+
|
|
66
|
+
# [1.0.0-beta.49](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.48...v1.0.0-beta.49) (2024-03-04)
|
|
67
|
+
|
|
68
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
69
|
+
|
|
70
|
+
# [1.0.0-beta.48](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.47...v1.0.0-beta.48) (2023-11-10)
|
|
71
|
+
|
|
72
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
73
|
+
|
|
74
|
+
# [1.0.0-beta.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
|
|
75
|
+
|
|
76
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
77
|
+
|
|
78
|
+
# [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
|
|
79
|
+
|
|
80
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
81
|
+
|
|
82
|
+
# [1.0.0-beta.45](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2023-07-17)
|
|
83
|
+
|
|
84
|
+
### Bug Fixes
|
|
85
|
+
|
|
86
|
+
- missing pubsub updates when new top level match uses qref with multiple results ([6dc26e2](https://github.com/sciactive/nymphjs/commit/6dc26e280453794ea9ce6c2b77482f85eb62bd23))
|
|
87
|
+
|
|
88
|
+
# [1.0.0-beta.44](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.43...v1.0.0-beta.44) (2023-07-13)
|
|
89
|
+
|
|
90
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
91
|
+
|
|
92
|
+
# [1.0.0-beta.43](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.42...v1.0.0-beta.43) (2023-07-12)
|
|
93
|
+
|
|
94
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
95
|
+
|
|
96
|
+
# [1.0.0-beta.42](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.41...v1.0.0-beta.42) (2023-07-12)
|
|
97
|
+
|
|
98
|
+
### Features
|
|
99
|
+
|
|
100
|
+
- make fillSession async so that gatekeeper can be sync ([fb6def4](https://github.com/sciactive/nymphjs/commit/fb6def45cd031516c9bcd3438f905e2ff881707b))
|
|
101
|
+
|
|
102
|
+
# [1.0.0-beta.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2023-07-12)
|
|
103
|
+
|
|
104
|
+
### Features
|
|
105
|
+
|
|
106
|
+
- remove synchronous database queries ([b579fb2](https://github.com/sciactive/nymphjs/commit/b579fb2eacd96cdd1b386a62c5c00cdbb2438f6e))
|
|
107
|
+
- rewrite server side async api to match client side api ([9c537a8](https://github.com/sciactive/nymphjs/commit/9c537a8be49e9b989af0822a4c2236e8c2d20f87))
|
|
108
|
+
|
|
109
|
+
# [1.0.0-beta.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2023-07-10)
|
|
110
|
+
|
|
111
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
112
|
+
|
|
113
|
+
# [1.0.0-beta.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2023-07-09)
|
|
114
|
+
|
|
115
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
116
|
+
|
|
117
|
+
# [1.0.0-beta.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2023-07-09)
|
|
118
|
+
|
|
119
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
120
|
+
|
|
121
|
+
# [1.0.0-beta.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2023-07-09)
|
|
122
|
+
|
|
123
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
124
|
+
|
|
125
|
+
# [1.0.0-beta.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2023-07-09)
|
|
126
|
+
|
|
127
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
128
|
+
|
|
129
|
+
# [1.0.0-beta.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2023-06-14)
|
|
130
|
+
|
|
131
|
+
### Bug Fixes
|
|
132
|
+
|
|
133
|
+
- get class from nymph instead of using constructor ([fc8538e](https://github.com/sciactive/nymphjs/commit/fc8538ea24be79b845ab1e00f930542f34517bfb))
|
|
134
|
+
|
|
135
|
+
# [1.0.0-beta.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2023-05-13)
|
|
136
|
+
|
|
137
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
138
|
+
|
|
139
|
+
# [1.0.0-beta.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2023-05-13)
|
|
140
|
+
|
|
141
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
142
|
+
|
|
143
|
+
# [1.0.0-beta.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2023-05-13)
|
|
144
|
+
|
|
145
|
+
### Features
|
|
146
|
+
|
|
147
|
+
- issue initial request with pubsub instead of rest on subscribe ([8a232d2](https://github.com/sciactive/nymphjs/commit/8a232d2faeb8622924f9c35a01a8f71a70659bb3))
|
|
148
|
+
|
|
149
|
+
# [1.0.0-beta.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2023-05-12)
|
|
150
|
+
|
|
151
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
152
|
+
|
|
153
|
+
# [1.0.0-beta.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2023-05-12)
|
|
154
|
+
|
|
155
|
+
### Features
|
|
156
|
+
|
|
157
|
+
- allow providing getEntityClass with a class instead of string ([ecd64c1](https://github.com/sciactive/nymphjs/commit/ecd64c1bf92e3657889613b76bcc46652f371ead))
|
|
158
|
+
|
|
159
|
+
# [1.0.0-beta.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2023-05-08)
|
|
160
|
+
|
|
161
|
+
### Bug Fixes
|
|
162
|
+
|
|
163
|
+
- use 4 byte utf8 encoding in mysql ([c335b6e](https://github.com/sciactive/nymphjs/commit/c335b6e8416f935c9116e7f54de753d4b2255a73))
|
|
164
|
+
|
|
165
|
+
# [1.0.0-beta.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2023-05-05)
|
|
166
|
+
|
|
167
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
168
|
+
|
|
169
|
+
# [1.0.0-beta.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2023-05-04)
|
|
170
|
+
|
|
171
|
+
### Bug Fixes
|
|
172
|
+
|
|
173
|
+
- properly escape mysql ids with dots ([64bfaa5](https://github.com/sciactive/nymphjs/commit/64bfaa5d606f97a753ca7e6c5d2d86f7c0f7729a))
|
|
174
|
+
|
|
175
|
+
# [1.0.0-beta.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2023-05-04)
|
|
176
|
+
|
|
177
|
+
### Features
|
|
178
|
+
|
|
179
|
+
- update packages and migrate to mysql2 ([72ad611](https://github.com/sciactive/nymphjs/commit/72ad611bd2bf7bf85c3ba8a3486503d9b50c49d6))
|
|
180
|
+
|
|
181
|
+
# [1.0.0-beta.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2023-05-04)
|
|
182
|
+
|
|
183
|
+
### Bug Fixes
|
|
184
|
+
|
|
185
|
+
- don't create empty entities ([1d4d2e9](https://github.com/sciactive/nymphjs/commit/1d4d2e99af2e9cdc647bcf58ac34572836f41176))
|
|
186
|
+
- tilmeld uses wrong class when cloned with user ([059c2ce](https://github.com/sciactive/nymphjs/commit/059c2cedf1b07b9681e87c240eb36723a4581918))
|
|
187
|
+
|
|
188
|
+
### Features
|
|
189
|
+
|
|
190
|
+
- add flags to disable rest and pubsub support on an entity class ([52106a3](https://github.com/sciactive/nymphjs/commit/52106a3d44065bcfec40d361344bf1eba59a5136)), closes [#1](https://github.com/sciactive/nymphjs/issues/1)
|
|
191
|
+
|
|
192
|
+
# [1.0.0-beta.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2023-05-02)
|
|
193
|
+
|
|
194
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
195
|
+
|
|
196
|
+
# [1.0.0-beta.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2023-05-02)
|
|
197
|
+
|
|
198
|
+
### Bug Fixes
|
|
199
|
+
|
|
200
|
+
- rare case where currentUser isn't corrent ([97f233a](https://github.com/sciactive/nymphjs/commit/97f233a5fcfd4b97dd282562b0c99097ac3ef41d))
|
|
201
|
+
|
|
202
|
+
# [1.0.0-beta.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2023-05-01)
|
|
203
|
+
|
|
204
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
205
|
+
|
|
206
|
+
# [1.0.0-beta.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
|
|
207
|
+
|
|
208
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
209
|
+
|
|
210
|
+
# [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
|
|
211
|
+
|
|
212
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
213
|
+
|
|
214
|
+
# [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
|
|
215
|
+
|
|
216
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
217
|
+
|
|
218
|
+
# [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
|
|
219
|
+
|
|
220
|
+
### Bug Fixes
|
|
221
|
+
|
|
222
|
+
- small type issues ([b91579c](https://github.com/sciactive/nymphjs/commit/b91579c9c1e96500d903332648f5a93c9a7e7d9b))
|
|
223
|
+
|
|
224
|
+
### Features
|
|
225
|
+
|
|
226
|
+
- add the ability to switch to a user without their password ([ca4466a](https://github.com/sciactive/nymphjs/commit/ca4466af1704d68905ac087350a8cf151c1072d9))
|
|
227
|
+
- forbid modifying ac props from client ([f9e896f](https://github.com/sciactive/nymphjs/commit/f9e896f6c57b08ae100bc50d33a0234b6a431333))
|
|
228
|
+
|
|
229
|
+
# [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
|
|
230
|
+
|
|
231
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
232
|
+
|
|
233
|
+
# [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
|
|
234
|
+
|
|
235
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
236
|
+
|
|
237
|
+
# [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
|
|
238
|
+
|
|
239
|
+
### Features
|
|
240
|
+
|
|
241
|
+
- add option to sort results by a property ([16384e7](https://github.com/sciactive/nymphjs/commit/16384e7bdab88abb55ccccabb06ac09f92fa8a03))
|
|
242
|
+
|
|
243
|
+
# [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
|
|
244
|
+
|
|
245
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
246
|
+
|
|
247
|
+
# [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
|
|
248
|
+
|
|
249
|
+
### Bug Fixes
|
|
250
|
+
|
|
251
|
+
- pubsub publishing changes before transaction is finished ([a918cc1](https://github.com/sciactive/nymphjs/commit/a918cc1451e03015ecce20f1c9bf6ceb62b7dff1))
|
|
252
|
+
|
|
253
|
+
# [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
|
|
254
|
+
|
|
255
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
256
|
+
|
|
257
|
+
# [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
|
|
258
|
+
|
|
259
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
260
|
+
|
|
261
|
+
# [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
|
|
262
|
+
|
|
263
|
+
**Note:** Version bump only for package @nymphjs/nymph
|
|
264
|
+
|
|
265
|
+
# [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
|
|
266
|
+
|
|
267
|
+
### Bug Fixes
|
|
268
|
+
|
|
269
|
+
- reworked $is and $equals to better work with new instance based classes ([b1f3f0c](https://github.com/sciactive/nymphjs/commit/b1f3f0cca3e2b0dd392cd9da31167a6bd9487b40))
|
|
270
|
+
|
|
271
|
+
# [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
|
|
272
|
+
|
|
273
|
+
### Features
|
|
274
|
+
|
|
275
|
+
- make entities in nymph client instance specific too ([1029f06](https://github.com/sciactive/nymphjs/commit/1029f061a1ad193e4a8a2dab0186b9a4b517f646))
|
|
276
|
+
|
|
277
|
+
# [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
|
|
278
|
+
|
|
279
|
+
### Bug Fixes
|
|
280
|
+
|
|
281
|
+
- sqlite transaction returns wrong instance of nymph if it has been cloned ([b278c76](https://github.com/sciactive/nymphjs/commit/b278c7633722cb1cca7a941187ae2f1ff8ebdc7b))
|
|
282
|
+
|
|
6
283
|
# [1.0.0-beta.6](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-01-05)
|
|
7
284
|
|
|
8
285
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Here's an overview:
|
|
|
22
22
|
// main.ts
|
|
23
23
|
import { Nymph } from '@nymphjs/nymph';
|
|
24
24
|
import MySQLDriver from '@nymphjs/driver-mysql';
|
|
25
|
-
import
|
|
25
|
+
import TodoClass from './Todo';
|
|
26
26
|
|
|
27
27
|
const mysqlConfig = {
|
|
28
28
|
host: 'your_db_host',
|
|
@@ -31,8 +31,10 @@ const mysqlConfig = {
|
|
|
31
31
|
password: 'your_password',
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
+
// Create a new instance of Nymph.
|
|
34
35
|
const nymph = new Nymph({}, new MySQLDriver(mysqlConfig));
|
|
35
|
-
|
|
36
|
+
// addEntityClass returns the class you should use for this instance of Nymph.
|
|
37
|
+
const Todo = nymph.addEntityClass(TodoClass);
|
|
36
38
|
|
|
37
39
|
// You are set up. Now you can use entity classes like `Todo` to store data,
|
|
38
40
|
// and Nymph's query methods like `getEntities` to retrieve them.
|
|
@@ -44,7 +46,7 @@ async function run() {
|
|
|
44
46
|
|
|
45
47
|
const otherPendingTodos = await nymph.getEntities(
|
|
46
48
|
{ class: Todo },
|
|
47
|
-
{ type: '&', '!guid': myEntity.guid, equal: ['done', false] }
|
|
49
|
+
{ type: '&', '!guid': myEntity.guid, equal: ['done', false] },
|
|
48
50
|
);
|
|
49
51
|
|
|
50
52
|
const total = otherPendingTodos.length;
|
|
@@ -52,7 +54,7 @@ async function run() {
|
|
|
52
54
|
console.log(
|
|
53
55
|
`Besides the one I just created, there ${
|
|
54
56
|
single ? 'is' : 'are'
|
|
55
|
-
} ${total} pending todo${single ? '' : 's'} in the database
|
|
57
|
+
} ${total} pending todo${single ? '' : 's'} in the database.`,
|
|
56
58
|
);
|
|
57
59
|
}
|
|
58
60
|
```
|
|
@@ -70,23 +72,13 @@ export default class Todo extends Entity<TodoData> {
|
|
|
70
72
|
static ETYPE = 'todo'; // This is used for the table name(s) in the DB.
|
|
71
73
|
static class = 'Todo'; // This is used to map references to their class.
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
static factorySync(guid?: string): Todo & TodoData {
|
|
78
|
-
return super.factorySync(guid) as Todo & TodoData;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
constructor(guid?: string) {
|
|
82
|
-
super(guid);
|
|
75
|
+
constructor() {
|
|
76
|
+
super();
|
|
83
77
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.$data.done = false;
|
|
89
|
-
}
|
|
78
|
+
// Within the methods of an entity, you will use `this.$data` to access
|
|
79
|
+
// its data. Outside, you don't need the $data part.
|
|
80
|
+
this.$data.text = '';
|
|
81
|
+
this.$data.done = false;
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
async $getOtherTodos() {
|
|
@@ -95,7 +87,7 @@ export default class Todo extends Entity<TodoData> {
|
|
|
95
87
|
// instance of Nymph, so it could be a transactional instance.
|
|
96
88
|
const otherTodos = await this.$nymph.getEntities(
|
|
97
89
|
{ class: Todo },
|
|
98
|
-
{ type: '!&', guid: this.guid }
|
|
90
|
+
{ type: '!&', guid: this.guid },
|
|
99
91
|
);
|
|
100
92
|
return otherTodos;
|
|
101
93
|
}
|
package/dist/Entity.d.ts
CHANGED
|
@@ -1,34 +1,273 @@
|
|
|
1
1
|
import type Nymph from './Nymph';
|
|
2
|
-
import {
|
|
2
|
+
import type { Options } from './Nymph.types';
|
|
3
|
+
import type { ACProperties, EntityConstructor, EntityData, EntityInterface, EntityJson, EntityPatch, EntityReference, SerializedEntityData } from './Entity.types';
|
|
4
|
+
export type EntityDataType<T> = T extends Entity<infer DataType> ? DataType : never;
|
|
5
|
+
export type EntityInstanceType<T extends EntityConstructor> = T extends new () => infer E ? E & EntityDataType<E> : never;
|
|
6
|
+
/**
|
|
7
|
+
* Database abstraction object.
|
|
8
|
+
*
|
|
9
|
+
* Provides a way to access, manipulate, and store data in Nymph.
|
|
10
|
+
*
|
|
11
|
+
* The GUID is not set until the entity is saved. GUIDs must be unique forever,
|
|
12
|
+
* even after deletion. It's the job of the Nymph DB driver to make sure no two
|
|
13
|
+
* entities ever have the same GUID. This is generally done by using a large
|
|
14
|
+
* randomly generated ID.
|
|
15
|
+
*
|
|
16
|
+
* Each entity class has an etype that determines which table(s) in the database
|
|
17
|
+
* it belongs to. If two entity classes have the same etype, their data will be
|
|
18
|
+
* stored in the same table(s). This isn't a good idea, however, because
|
|
19
|
+
* references to an entity store a class name, not an etype.
|
|
20
|
+
*
|
|
21
|
+
* Tags are used to classify entities. Where an etype is used to separate data
|
|
22
|
+
* by tables, tags can be used to separate entities within a table. You can
|
|
23
|
+
* define specific tags to be protected, meaning they cannot be added/removed
|
|
24
|
+
* from the client. It can be useful to allow user defined tags, such as for
|
|
25
|
+
* blog posts.
|
|
26
|
+
*
|
|
27
|
+
* Simply calling $delete() will not unset the entity. It will still take up
|
|
28
|
+
* memory. Likewise, simply calling unset will not delete the entity from the
|
|
29
|
+
* DB.
|
|
30
|
+
*
|
|
31
|
+
* Some notes about $equals() and $is(), the replacements for "==":
|
|
32
|
+
*
|
|
33
|
+
* The == operator will likely not give you the result you want, since two
|
|
34
|
+
* instances of the same entity will fail that check, even though they represent
|
|
35
|
+
* the same data in the database.
|
|
36
|
+
*
|
|
37
|
+
* $equals() performs a more strict comparison of the entity to another. Use
|
|
38
|
+
* $equals() instead of the == operator when you want to check both the entities
|
|
39
|
+
* they represent, and the data inside them. In order to return true for
|
|
40
|
+
* $equals(), the entity and object must meet the following criteria:
|
|
41
|
+
*
|
|
42
|
+
* - They must be entities.
|
|
43
|
+
* - They must have equal GUIDs, or both must have no GUID.
|
|
44
|
+
* - Their data and tags must be equal.
|
|
45
|
+
*
|
|
46
|
+
* $is() performs a less strict comparison of the entity to another. Use $is()
|
|
47
|
+
* instead of the == operator when the entity's data may have been changed, but
|
|
48
|
+
* you only care if they represent the same entity. In order to return true, the
|
|
49
|
+
* entity and object must meet the following criteria:
|
|
50
|
+
*
|
|
51
|
+
* - They must be entities.
|
|
52
|
+
* - They must have equal GUIDs, or both must have no GUID.
|
|
53
|
+
* - If they have no GUIDs, their data and tags must be equal.
|
|
54
|
+
*
|
|
55
|
+
* Some notes about saving entities in other entity's properties:
|
|
56
|
+
*
|
|
57
|
+
* Entities use references in the DB to store an entity in their properties. The
|
|
58
|
+
* reference is stored as an array with the values:
|
|
59
|
+
*
|
|
60
|
+
* - 0 => The string 'nymph_entity_reference'
|
|
61
|
+
* - 1 => The referenced entity's GUID.
|
|
62
|
+
* - 2 => The referenced entity's class name.
|
|
63
|
+
*
|
|
64
|
+
* Since the referenced entity's class name (meaning the `class` static
|
|
65
|
+
* property, not the name of the class itself) is stored in the reference on the
|
|
66
|
+
* parent entity, if you change the class name in an update, you need to
|
|
67
|
+
* reassign all referenced entities of that class and resave.
|
|
68
|
+
*
|
|
69
|
+
* When an entity is loaded, it does not request its referenced entities from
|
|
70
|
+
* Nymph. Instead, it creates instances without data called sleeping references.
|
|
71
|
+
* When you first access an entity's data, if it is a sleeping reference, it
|
|
72
|
+
* will fill its data from the DB. You can call clearCache() to turn all the
|
|
73
|
+
* entities back into sleeping references.
|
|
74
|
+
*/
|
|
3
75
|
export default class Entity<T extends EntityData = EntityData> implements EntityInterface {
|
|
76
|
+
/**
|
|
77
|
+
* The instance of Nymph to use for queries.
|
|
78
|
+
*/
|
|
4
79
|
static nymph: Nymph;
|
|
80
|
+
/**
|
|
81
|
+
* A unique name for this type of entity used to separate its data from other
|
|
82
|
+
* types of entities in the database.
|
|
83
|
+
*/
|
|
5
84
|
static ETYPE: string;
|
|
85
|
+
/**
|
|
86
|
+
* The lookup name for this entity.
|
|
87
|
+
*
|
|
88
|
+
* This is used for reference arrays (and sleeping references) and client
|
|
89
|
+
* requests.
|
|
90
|
+
*/
|
|
6
91
|
static class: string;
|
|
7
92
|
$nymph: Nymph;
|
|
8
93
|
guid: string | null;
|
|
9
94
|
cdate: number | null;
|
|
10
95
|
mdate: number | null;
|
|
11
96
|
tags: string[];
|
|
97
|
+
/**
|
|
98
|
+
* The data proxy handler.
|
|
99
|
+
*/
|
|
12
100
|
protected $dataHandler: Object;
|
|
101
|
+
/**
|
|
102
|
+
* The actual data store.
|
|
103
|
+
*/
|
|
13
104
|
protected $dataStore: T;
|
|
105
|
+
/**
|
|
106
|
+
* The actual sdata store.
|
|
107
|
+
*/
|
|
14
108
|
protected $sdata: SerializedEntityData;
|
|
109
|
+
/**
|
|
110
|
+
* The data proxy object.
|
|
111
|
+
*/
|
|
15
112
|
protected $data: T;
|
|
113
|
+
/**
|
|
114
|
+
* Whether this instance is a sleeping reference.
|
|
115
|
+
*/
|
|
16
116
|
protected $isASleepingReference: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The reference to use to wake.
|
|
119
|
+
*/
|
|
17
120
|
protected $sleepingReference: EntityReference | null;
|
|
121
|
+
/**
|
|
122
|
+
* A promise that resolved when the entity's data is wake.
|
|
123
|
+
*/
|
|
124
|
+
protected $wakePromise: Promise<Entity<T>> | null;
|
|
125
|
+
/**
|
|
126
|
+
* Properties that will not be serialized into JSON with toJSON(). This
|
|
127
|
+
* can be considered a denylist, because these properties will not be set
|
|
128
|
+
* with incoming JSON.
|
|
129
|
+
*
|
|
130
|
+
* Clients CAN still determine what is in these properties, unless they are
|
|
131
|
+
* also listed in searchRestrictedData.
|
|
132
|
+
*/
|
|
18
133
|
protected $privateData: string[];
|
|
134
|
+
/**
|
|
135
|
+
* Whether this entity should publish changes to PubSub servers.
|
|
136
|
+
*/
|
|
137
|
+
static pubSubEnabled: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Whether this entity should be accessible on the frontend through the REST
|
|
140
|
+
* server.
|
|
141
|
+
*
|
|
142
|
+
* If this is false, any request from the client that attempts to use this
|
|
143
|
+
* entity will fail.
|
|
144
|
+
*/
|
|
145
|
+
static restEnabled: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Properties that will not be searchable from the frontend. If the frontend
|
|
148
|
+
* includes any of these properties in any of their clauses, they will be
|
|
149
|
+
* filtered out before the search is executed.
|
|
150
|
+
*/
|
|
19
151
|
static searchRestrictedData: string[];
|
|
152
|
+
/**
|
|
153
|
+
* Properties that can only be modified by server side code. They will still
|
|
154
|
+
* be visible on the frontend, unlike $privateData, but any changes to them
|
|
155
|
+
* that come from the frontend will be ignored.
|
|
156
|
+
*
|
|
157
|
+
* In addition to what's listed here, all of the access control properties
|
|
158
|
+
* will be included when Tilmeld is being used. These are:
|
|
159
|
+
*
|
|
160
|
+
* - acUser
|
|
161
|
+
* - acGroup
|
|
162
|
+
* - acOther
|
|
163
|
+
* - acRead
|
|
164
|
+
* - acWrite
|
|
165
|
+
* - acFull
|
|
166
|
+
* - user
|
|
167
|
+
* - group
|
|
168
|
+
*
|
|
169
|
+
* You should modify these through client enabled methods or the $save method
|
|
170
|
+
* instead, for safety.
|
|
171
|
+
*/
|
|
20
172
|
protected $protectedData: string[];
|
|
173
|
+
/**
|
|
174
|
+
* If this is defined, then it lists the only properties that will be
|
|
175
|
+
* accepted from incoming JSON. Any other properties will be ignored.
|
|
176
|
+
*
|
|
177
|
+
* If you use an allowlist, you don't need to use protectedData, since you
|
|
178
|
+
* can simply leave those entries out of allowlistData.
|
|
179
|
+
*/
|
|
21
180
|
protected $allowlistData?: string[];
|
|
181
|
+
/**
|
|
182
|
+
* Tags that can only be added/removed by server side code. They will still be
|
|
183
|
+
* visible on the frontend, but any changes to them that come from the
|
|
184
|
+
* frontend will be ignored.
|
|
185
|
+
*/
|
|
22
186
|
protected $protectedTags: string[];
|
|
187
|
+
/**
|
|
188
|
+
* If this is defined, then it lists the only tags that will be accepted from
|
|
189
|
+
* incoming JSON. Any other tags will be ignored.
|
|
190
|
+
*/
|
|
23
191
|
protected $allowlistTags?: string[];
|
|
192
|
+
/**
|
|
193
|
+
* The names of methods allowed to be called by the frontend with serverCall.
|
|
194
|
+
*/
|
|
24
195
|
protected $clientEnabledMethods: string[];
|
|
196
|
+
/**
|
|
197
|
+
* The names of static methods allowed to be called by the frontend with
|
|
198
|
+
* serverCallStatic.
|
|
199
|
+
*/
|
|
25
200
|
static clientEnabledStaticMethods: string[];
|
|
201
|
+
/**
|
|
202
|
+
* Whether to use "skipAc" when accessing entity references.
|
|
203
|
+
*/
|
|
26
204
|
private $skipAc;
|
|
205
|
+
/**
|
|
206
|
+
* The AC properties' values when the entity was loaded.
|
|
207
|
+
*/
|
|
27
208
|
private $originalAcValues;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Alter the options for a query for this entity.
|
|
211
|
+
*
|
|
212
|
+
* @param options The current options.
|
|
213
|
+
* @returns The altered options.
|
|
214
|
+
*/
|
|
215
|
+
static alterOptions?<T extends Options>(options: T): T;
|
|
216
|
+
/**
|
|
217
|
+
* Initialize an entity.
|
|
218
|
+
*/
|
|
219
|
+
constructor(..._rest: any[]);
|
|
220
|
+
/**
|
|
221
|
+
* Create or retrieve a new entity instance.
|
|
222
|
+
*
|
|
223
|
+
* Note that this will always return an entity, even if the GUID is not found.
|
|
224
|
+
*
|
|
225
|
+
* @param guid An optional GUID to retrieve.
|
|
226
|
+
*/
|
|
227
|
+
static factory<E extends Entity>(this: {
|
|
228
|
+
new (): E;
|
|
229
|
+
}, guid?: string): Promise<E & EntityDataType<E>>;
|
|
230
|
+
/**
|
|
231
|
+
* Create a new entity instance.
|
|
232
|
+
*/
|
|
233
|
+
static factorySync<E extends Entity>(this: {
|
|
234
|
+
new (): E;
|
|
235
|
+
}): E & EntityDataType<E>;
|
|
236
|
+
/**
|
|
237
|
+
* Create a new sleeping reference instance.
|
|
238
|
+
*
|
|
239
|
+
* Sleeping references won't retrieve their data from the database until they
|
|
240
|
+
* are readied with `$wake()` or a parent's `$wakeAll()`.
|
|
241
|
+
*
|
|
242
|
+
* @param reference The Nymph Entity Reference to use to wake.
|
|
243
|
+
* @returns The new instance.
|
|
244
|
+
*/
|
|
245
|
+
static factoryReference<E extends Entity>(this: {
|
|
246
|
+
new (): E;
|
|
247
|
+
}, reference: EntityReference): E & EntityDataType<E>;
|
|
248
|
+
/**
|
|
249
|
+
* Get an array of strings that **must** be unique across the current etype.
|
|
250
|
+
*
|
|
251
|
+
* When you try to save another entity with any of the same unique strings,
|
|
252
|
+
* Nymph will throw an error.
|
|
253
|
+
*
|
|
254
|
+
* The default implementation of this static method instantiates the entity,
|
|
255
|
+
* assigns all of the given data, then calls `$getUniques` and returns its
|
|
256
|
+
* output. This can have a performance impact if a lot of extra processing
|
|
257
|
+
* happens during any of these steps. You can override this method to
|
|
258
|
+
* calculate the unique strings faster, but you must return the same strings
|
|
259
|
+
* that would be returned by `$getUniques`.
|
|
260
|
+
*
|
|
261
|
+
* @returns Resolves to an array of entity's unique constraint strings.
|
|
262
|
+
*/
|
|
263
|
+
static getUniques({ guid, cdate, mdate, tags, data, sdata, }: {
|
|
264
|
+
guid?: string;
|
|
265
|
+
cdate?: number;
|
|
266
|
+
mdate?: number;
|
|
267
|
+
tags: string[];
|
|
268
|
+
data: EntityData;
|
|
269
|
+
sdata?: SerializedEntityData;
|
|
270
|
+
}): Promise<string[]>;
|
|
32
271
|
toJSON(): EntityReference | EntityJson | null;
|
|
33
272
|
$addTag(...tags: string[]): void;
|
|
34
273
|
$arraySearch(array: any[], strict?: boolean): number;
|
|
@@ -38,7 +277,14 @@ export default class Entity<T extends EntityData = EntityData> implements Entity
|
|
|
38
277
|
$equals(object: any): boolean;
|
|
39
278
|
$getData(includeSData?: boolean): any;
|
|
40
279
|
$getSData(): SerializedEntityData;
|
|
280
|
+
$getUniques(): Promise<string[]>;
|
|
41
281
|
$getOriginalAcValues(): ACProperties;
|
|
282
|
+
$getCurrentAcValues(): ACProperties;
|
|
283
|
+
$getAcUid(): string | null;
|
|
284
|
+
$getAcGid(): string | null;
|
|
285
|
+
$getAcReadIds(): (string | null)[] | null;
|
|
286
|
+
$getAcWriteIds(): (string | null)[] | null;
|
|
287
|
+
$getAcFullIds(): (string | null)[] | null;
|
|
42
288
|
$getValidatable(): any;
|
|
43
289
|
$getTags(): string[];
|
|
44
290
|
$hasTag(...tags: string[]): boolean;
|
|
@@ -47,11 +293,27 @@ export default class Entity<T extends EntityData = EntityData> implements Entity
|
|
|
47
293
|
$jsonAcceptData(input: EntityJson, allowConflict?: boolean): void;
|
|
48
294
|
$jsonAcceptPatch(patch: EntityPatch, allowConflict?: boolean): void;
|
|
49
295
|
$putData(data: EntityData, sdata?: SerializedEntityData): void;
|
|
296
|
+
/**
|
|
297
|
+
* Set up a sleeping reference.
|
|
298
|
+
* @param array $reference The reference to use to wake.
|
|
299
|
+
*/
|
|
50
300
|
protected $referenceSleep(reference: EntityReference): void;
|
|
51
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Check if this is a sleeping reference and throw an error if so.
|
|
303
|
+
*/
|
|
304
|
+
protected $check(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Check if this is a sleeping reference.
|
|
307
|
+
*/
|
|
308
|
+
$asleep(): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* Wake from a sleeping reference.
|
|
311
|
+
*/
|
|
312
|
+
$wake(): Promise<Entity<T>>;
|
|
313
|
+
$wakeAll(level?: number): Promise<Entity<T>>;
|
|
52
314
|
$refresh(): Promise<boolean | 0>;
|
|
53
315
|
$removeTag(...tags: string[]): void;
|
|
54
316
|
$save(): Promise<boolean>;
|
|
55
|
-
$toReference():
|
|
317
|
+
$toReference(): this | EntityReference;
|
|
56
318
|
$useSkipAc(skipAc: boolean): void;
|
|
57
319
|
}
|