@nymphjs/server 1.0.0-alpha.9 → 1.0.0-beta.1
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 +163 -0
- package/dist/cache.test.d.ts +1 -0
- package/dist/cache.test.js +64 -0
- package/dist/cache.test.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +160 -167
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +191 -176
- package/dist/index.test.js.map +1 -1
- package/dist/testArtifacts.d.ts +3 -3
- package/dist/testArtifacts.js +26 -51
- package/dist/testArtifacts.js.map +1 -1
- package/jest.config.js +1 -1
- package/package.json +14 -14
- package/src/cache.test.ts +77 -0
- package/src/index.test.ts +52 -1
- package/src/index.ts +25 -9
- package/tsconfig.json +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,169 @@
|
|
|
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.1](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2022-11-21)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- adjust typescript targets to output node 16 code ([36f15a6](https://github.com/sciactive/nymphjs/commit/36f15a601362ed54f4465ef6527402c026bbcf61))
|
|
11
|
+
|
|
12
|
+
# [1.0.0-beta.0](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.43...v1.0.0-beta.0) (2022-11-16)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- update packages and fix issues, new guid package to use latest esm nanoid ([fd66aab](https://github.com/sciactive/nymphjs/commit/fd66aab465e6b1d83f4238bb16bc88d851ef5e92))
|
|
17
|
+
|
|
18
|
+
# [1.0.0-alpha.43](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.42...v1.0.0-alpha.43) (2022-03-07)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
21
|
+
|
|
22
|
+
# [1.0.0-alpha.42](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.41...v1.0.0-alpha.42) (2022-03-06)
|
|
23
|
+
|
|
24
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
25
|
+
|
|
26
|
+
# [1.0.0-alpha.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.40...v1.0.0-alpha.41) (2022-03-06)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
29
|
+
|
|
30
|
+
# [1.0.0-alpha.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.39...v1.0.0-alpha.40) (2022-03-05)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
33
|
+
|
|
34
|
+
# [1.0.0-alpha.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.38...v1.0.0-alpha.39) (2022-03-05)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
37
|
+
|
|
38
|
+
# [1.0.0-alpha.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.37...v1.0.0-alpha.38) (2022-02-10)
|
|
39
|
+
|
|
40
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
41
|
+
|
|
42
|
+
# [1.0.0-alpha.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.36...v1.0.0-alpha.37) (2022-02-02)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
45
|
+
|
|
46
|
+
# [1.0.0-alpha.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.35...v1.0.0-alpha.36) (2022-01-26)
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
- entity count return option ([f1e34e8](https://github.com/sciactive/nymphjs/commit/f1e34e8f74d9fdda58989fc101f4381243a86ec3))
|
|
51
|
+
- support subscribing to queries with qref in pubsub server ([6d9a0af](https://github.com/sciactive/nymphjs/commit/6d9a0afea653ae00130c47087b21d87c5666d229))
|
|
52
|
+
|
|
53
|
+
# [1.0.0-alpha.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.34...v1.0.0-alpha.35) (2022-01-19)
|
|
54
|
+
|
|
55
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
56
|
+
|
|
57
|
+
# [1.0.0-alpha.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.33...v1.0.0-alpha.34) (2022-01-08)
|
|
58
|
+
|
|
59
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
60
|
+
|
|
61
|
+
# [1.0.0-alpha.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.32...v1.0.0-alpha.33) (2022-01-08)
|
|
62
|
+
|
|
63
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
64
|
+
|
|
65
|
+
# [1.0.0-alpha.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.31...v1.0.0-alpha.32) (2022-01-08)
|
|
66
|
+
|
|
67
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
68
|
+
|
|
69
|
+
# [1.0.0-alpha.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.30...v1.0.0-alpha.31) (2022-01-08)
|
|
70
|
+
|
|
71
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
72
|
+
|
|
73
|
+
# [1.0.0-alpha.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2022-01-07)
|
|
74
|
+
|
|
75
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
76
|
+
|
|
77
|
+
# [1.0.0-alpha.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2022-01-07)
|
|
78
|
+
|
|
79
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
80
|
+
|
|
81
|
+
# [1.0.0-alpha.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2022-01-07)
|
|
82
|
+
|
|
83
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
84
|
+
|
|
85
|
+
# [1.0.0-alpha.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-01-05)
|
|
86
|
+
|
|
87
|
+
### Features
|
|
88
|
+
|
|
89
|
+
- update smui to latest versions ([7ed7bd3](https://github.com/sciactive/nymphjs/commit/7ed7bd34d01a155c7001a2671de25ef2f3363682))
|
|
90
|
+
|
|
91
|
+
# [1.0.0-alpha.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2021-12-30)
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
- add json options rest server option ([35cbff4](https://github.com/sciactive/nymphjs/commit/35cbff4b8dbc3e112604119efe05b813f5948dff))
|
|
96
|
+
|
|
97
|
+
# [1.0.0-alpha.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.24...v1.0.0-alpha.25) (2021-12-30)
|
|
98
|
+
|
|
99
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
100
|
+
|
|
101
|
+
# [1.0.0-alpha.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.23...v1.0.0-alpha.24) (2021-12-30)
|
|
102
|
+
|
|
103
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
104
|
+
|
|
105
|
+
# [1.0.0-alpha.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2021-12-30)
|
|
106
|
+
|
|
107
|
+
### Features
|
|
108
|
+
|
|
109
|
+
- add optional weakly referenced cache to client lib ([fbb184c](https://github.com/sciactive/nymphjs/commit/fbb184c6a721968bb92cc9b05c328594618554ed))
|
|
110
|
+
|
|
111
|
+
# [1.0.0-alpha.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2021-12-14)
|
|
112
|
+
|
|
113
|
+
### Features
|
|
114
|
+
|
|
115
|
+
- update smui to latest versions ([912873b](https://github.com/sciactive/nymphjs/commit/912873b863d1ae5d51c359a3c0558bff38ce85cd))
|
|
116
|
+
|
|
117
|
+
# [1.0.0-alpha.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.20...v1.0.0-alpha.21) (2021-11-29)
|
|
118
|
+
|
|
119
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
120
|
+
|
|
121
|
+
# [1.0.0-alpha.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.19...v1.0.0-alpha.20) (2021-11-24)
|
|
122
|
+
|
|
123
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
124
|
+
|
|
125
|
+
# [1.0.0-alpha.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2021-11-18)
|
|
126
|
+
|
|
127
|
+
### Features
|
|
128
|
+
|
|
129
|
+
- update smui and other packages to latest versions ([2465340](https://github.com/sciactive/nymphjs/commit/24653400d887bc04c41c3c4ee0c73ce2f2289e0d))
|
|
130
|
+
|
|
131
|
+
# [1.0.0-alpha.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2021-11-09)
|
|
132
|
+
|
|
133
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
134
|
+
|
|
135
|
+
# [1.0.0-alpha.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2021-10-14)
|
|
136
|
+
|
|
137
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
138
|
+
|
|
139
|
+
# [1.0.0-alpha.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2021-10-14)
|
|
140
|
+
|
|
141
|
+
### Bug Fixes
|
|
142
|
+
|
|
143
|
+
- don't ignore built files in npm packages ([7d688db](https://github.com/sciactive/nymphjs/commit/7d688dbec362f1f71fb451a1d0dbcaecc15d99fc))
|
|
144
|
+
|
|
145
|
+
# [1.0.0-alpha.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2021-10-14)
|
|
146
|
+
|
|
147
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
148
|
+
|
|
149
|
+
# [1.0.0-alpha.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.13...v1.0.0-alpha.14) (2021-10-14)
|
|
150
|
+
|
|
151
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
152
|
+
|
|
153
|
+
# [1.0.0-alpha.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2021-10-14)
|
|
154
|
+
|
|
155
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
156
|
+
|
|
157
|
+
# [1.0.0-alpha.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.11...v1.0.0-alpha.12) (2021-10-13)
|
|
158
|
+
|
|
159
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
160
|
+
|
|
161
|
+
# [1.0.0-alpha.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2021-10-13)
|
|
162
|
+
|
|
163
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
164
|
+
|
|
165
|
+
# [1.0.0-alpha.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2021-10-12)
|
|
166
|
+
|
|
167
|
+
**Note:** Version bump only for package @nymphjs/server
|
|
168
|
+
|
|
6
169
|
# [1.0.0-alpha.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2021-10-12)
|
|
7
170
|
|
|
8
171
|
**Note:** Version bump only for package @nymphjs/server
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const express_1 = __importDefault(require("express"));
|
|
7
|
+
const driver_sqlite3_1 = __importDefault(require("@nymphjs/driver-sqlite3"));
|
|
8
|
+
const nymph_1 = require("@nymphjs/nymph");
|
|
9
|
+
const client_node_1 = require("@nymphjs/client-node");
|
|
10
|
+
const index_1 = __importDefault(require("./index"));
|
|
11
|
+
const testArtifacts_1 = require("./testArtifacts");
|
|
12
|
+
const sqliteConfig = {
|
|
13
|
+
filename: ':memory:',
|
|
14
|
+
};
|
|
15
|
+
const nymphServer = new nymph_1.Nymph({}, new driver_sqlite3_1.default(sqliteConfig));
|
|
16
|
+
nymphServer.addEntityClass(testArtifacts_1.EmployeeModel);
|
|
17
|
+
const app = (0, express_1.default)();
|
|
18
|
+
app.use('/test', (0, index_1.default)(nymphServer));
|
|
19
|
+
const server = app.listen(5081);
|
|
20
|
+
const nymph = new client_node_1.Nymph({
|
|
21
|
+
restUrl: 'http://localhost:5081/test/',
|
|
22
|
+
weakCache: true,
|
|
23
|
+
});
|
|
24
|
+
nymph.addEntityClass(testArtifacts_1.Employee);
|
|
25
|
+
describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
26
|
+
async function createJane() {
|
|
27
|
+
const jane = await testArtifacts_1.Employee.factory();
|
|
28
|
+
jane.name = 'Jane Doe';
|
|
29
|
+
jane.current = true;
|
|
30
|
+
jane.salary = 8000000;
|
|
31
|
+
jane.startDate = Date.now();
|
|
32
|
+
jane.subordinates = [];
|
|
33
|
+
jane.title = 'Seniorer Person';
|
|
34
|
+
try {
|
|
35
|
+
await jane.$save();
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
console.error('Error creating entity: ', e);
|
|
39
|
+
throw e;
|
|
40
|
+
}
|
|
41
|
+
return jane;
|
|
42
|
+
}
|
|
43
|
+
it('change an entity and check weakCache', async () => {
|
|
44
|
+
if (typeof WeakRef === 'undefined') {
|
|
45
|
+
throw new Error('You must run this test in an environment that includes WeakRef.');
|
|
46
|
+
}
|
|
47
|
+
const employee = await createJane();
|
|
48
|
+
if (employee.guid == null) {
|
|
49
|
+
throw new Error('Entity is null.');
|
|
50
|
+
}
|
|
51
|
+
const checkA = await testArtifacts_1.Employee.factory(employee.guid);
|
|
52
|
+
const checkB = await nymph.getEntity({ class: testArtifacts_1.Employee }, { type: '&', guid: employee.guid });
|
|
53
|
+
if (!checkB) {
|
|
54
|
+
throw new Error("Couldn't fetch entity.");
|
|
55
|
+
}
|
|
56
|
+
employee.current = false;
|
|
57
|
+
expect(checkA.current).toEqual(false);
|
|
58
|
+
expect(checkB.current).toEqual(false);
|
|
59
|
+
});
|
|
60
|
+
afterAll(() => {
|
|
61
|
+
server.close();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
//# sourceMappingURL=cache.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.test.js","sourceRoot":"","sources":["../src/cache.test.ts"],"names":[],"mappings":";;;;;AAAA,sDAA8B;AAC9B,6EAAoD;AACpD,0CAAsD;AACtD,sDAA6C;AAE7C,oDAAmC;AACnC,mDAA0D;AAE1D,MAAM,YAAY,GAAG;IACnB,QAAQ,EAAE,UAAU;CACrB,CAAC;AAEF,MAAM,WAAW,GAAG,IAAI,aAAW,CAAC,EAAE,EAAE,IAAI,wBAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AACzE,WAAW,CAAC,cAAc,CAAC,6BAAa,CAAC,CAAC;AAE1C,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AACtB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,IAAA,eAAY,EAAC,WAAW,CAAC,CAAC,CAAC;AAC5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC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AE,KAAK,EAAE,wBAAQ,EAAE,EACnB,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CACnC,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,QAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;QAEzB,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE;QACZ,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import type { OptionsJson } from 'body-parser';
|
|
1
2
|
import { Nymph } from '@nymphjs/nymph';
|
|
2
|
-
export default function createServer(nymph: Nymph
|
|
3
|
+
export default function createServer(nymph: Nymph, { jsonOptions }?: {
|
|
4
|
+
jsonOptions?: OptionsJson;
|
|
5
|
+
}): import("express-serve-static-core").Express;
|