@nymphjs/server 1.0.0-beta.11 → 1.0.0-beta.111
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 +438 -0
- package/README.md +75 -3
- package/dist/cache.test.js +14 -18
- package/dist/cache.test.js.map +1 -1
- package/dist/createServer.d.ts +17 -0
- package/dist/createServer.js +907 -0
- package/dist/createServer.js.map +1 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -793
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +138 -24
- package/dist/index.test.js.map +1 -1
- package/dist/statusDescriptions.d.ts +6 -0
- package/dist/statusDescriptions.js +69 -0
- package/dist/statusDescriptions.js.map +1 -0
- package/dist/testArtifacts.d.ts +55 -7
- package/dist/testArtifacts.js +160 -74
- package/dist/testArtifacts.js.map +1 -1
- package/jest.config.js +11 -2
- package/package.json +20 -20
- package/src/cache.test.ts +5 -5
- package/src/createServer.ts +981 -0
- package/src/index.test.ts +171 -27
- package/src/index.ts +4 -873
- package/src/statusDescriptions.ts +68 -0
- package/src/testArtifacts.ts +171 -42
- package/tsconfig.json +5 -3
- package/typedoc.json +4 -0
- package/dist/HttpError.d.ts +0 -5
- package/dist/HttpError.js +0 -13
- package/dist/HttpError.js.map +0 -1
- package/src/HttpError.ts +0 -12
package/dist/testArtifacts.js
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Employee = exports.BadFunctionCallError = exports.EmployeeModel = void 0;
|
|
4
|
-
const nymph_1 = require("@nymphjs/nymph");
|
|
5
|
-
const client_1 = require("@nymphjs/client");
|
|
6
|
-
const HttpError_1 = require("./HttpError");
|
|
1
|
+
import { Entity as EntityServer, EntityInvalidDataError, HttpError, } from '@nymphjs/nymph';
|
|
2
|
+
import { Entity } from '@nymphjs/client';
|
|
7
3
|
const IS_MANAGER = true;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
static
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This class is a test class that extends the Entity class.
|
|
6
|
+
*/
|
|
7
|
+
export class EmployeeModel extends EntityServer {
|
|
8
|
+
static ETYPE = 'employee';
|
|
9
|
+
static class = 'Employee';
|
|
10
|
+
$clientEnabledMethods = [
|
|
11
|
+
'$testMethodStateless',
|
|
12
|
+
'$testMethod',
|
|
13
|
+
'$throwError',
|
|
14
|
+
'$throwHttpError',
|
|
15
|
+
'$throwHttpErrorWithDescription',
|
|
16
|
+
];
|
|
17
|
+
static clientEnabledStaticMethods = [
|
|
18
|
+
'testStatic',
|
|
19
|
+
'testStaticIterable',
|
|
20
|
+
'testStaticIterableAbort',
|
|
21
|
+
'throwErrorStatic',
|
|
22
|
+
'throwErrorStaticIterable',
|
|
23
|
+
];
|
|
24
|
+
$protectedTags = ['employee'];
|
|
25
|
+
$allowlistTags = ['boss', 'bigcheese'];
|
|
26
|
+
$allowlistData = [
|
|
27
|
+
'name',
|
|
28
|
+
'id',
|
|
29
|
+
'title',
|
|
30
|
+
'department',
|
|
31
|
+
'subordinates',
|
|
32
|
+
'salary',
|
|
33
|
+
'current',
|
|
34
|
+
'startDate',
|
|
35
|
+
'endDate',
|
|
36
|
+
'phone',
|
|
37
|
+
'manager',
|
|
38
|
+
'building',
|
|
39
|
+
];
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
this.$addTag('employee');
|
|
43
|
+
this.$data.current = true;
|
|
44
|
+
this.$data.startDate = Date.now();
|
|
45
|
+
this.$data.subordinates = [];
|
|
46
|
+
if (!IS_MANAGER) {
|
|
47
|
+
this.$privateData.push('salary');
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async $save() {
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Validate employee data.
|
|
52
|
+
const error = new EntityInvalidDataError('Invalid entity data.');
|
|
53
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
53
54
|
error.addField('name');
|
|
54
55
|
}
|
|
55
|
-
if (this.$data.title == null || this.$data.title
|
|
56
|
+
if (this.$data.title == null || this.$data.title === '') {
|
|
56
57
|
error.addField('title');
|
|
57
58
|
}
|
|
58
59
|
if (this.$data.startDate == null) {
|
|
@@ -61,6 +62,7 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
61
62
|
if (error.getFields().length) {
|
|
62
63
|
throw error;
|
|
63
64
|
}
|
|
65
|
+
// Generate employee ID.
|
|
64
66
|
if (this.$data.id == null) {
|
|
65
67
|
this.$data.id = (await this.$nymph.newUID('employee')) ?? undefined;
|
|
66
68
|
}
|
|
@@ -77,47 +79,51 @@ class EmployeeModel extends nymph_1.Entity {
|
|
|
77
79
|
static testStatic(value) {
|
|
78
80
|
return value * 2;
|
|
79
81
|
}
|
|
82
|
+
static *testStaticIterable(value) {
|
|
83
|
+
yield value + 1;
|
|
84
|
+
yield value + 2;
|
|
85
|
+
yield value + 3;
|
|
86
|
+
}
|
|
87
|
+
static *testStaticIterableAbort() {
|
|
88
|
+
let aborted = yield 1;
|
|
89
|
+
if (!aborted) {
|
|
90
|
+
throw new Error("testStaticIterableAbort wasn't aborted after the first iteration.");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
80
93
|
static throwErrorStatic() {
|
|
81
94
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
82
95
|
}
|
|
96
|
+
static *throwErrorStaticIterable() {
|
|
97
|
+
yield 1;
|
|
98
|
+
throw new BadFunctionCallError('This function throws errors after the first iteration.');
|
|
99
|
+
}
|
|
83
100
|
$throwError() {
|
|
84
101
|
throw new BadFunctionCallError('This function only throws errors.');
|
|
85
102
|
}
|
|
86
103
|
$throwHttpError() {
|
|
87
|
-
throw new
|
|
104
|
+
throw new HttpError('A 501 HTTP error.', 501);
|
|
88
105
|
}
|
|
89
106
|
$throwHttpErrorWithDescription() {
|
|
90
|
-
throw new
|
|
107
|
+
throw new HttpError('A 512 HTTP error.', 512, 'Some Error');
|
|
91
108
|
}
|
|
92
109
|
static inaccessibleMethod() {
|
|
93
110
|
return true;
|
|
94
111
|
}
|
|
95
112
|
}
|
|
96
|
-
|
|
97
|
-
EmployeeModel.ETYPE = 'employee';
|
|
98
|
-
EmployeeModel.class = 'Employee';
|
|
99
|
-
EmployeeModel.clientEnabledStaticMethods = ['testStatic', 'throwErrorStatic'];
|
|
100
|
-
class BadFunctionCallError extends Error {
|
|
113
|
+
export class BadFunctionCallError extends Error {
|
|
101
114
|
constructor(message) {
|
|
102
115
|
super(message);
|
|
103
116
|
this.name = 'BadFunctionCallError';
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
static async factory(guid) {
|
|
117
|
-
return (await super.factory(guid));
|
|
118
|
-
}
|
|
119
|
-
static factorySync(guid) {
|
|
120
|
-
return super.factorySync(guid);
|
|
119
|
+
export class Employee extends Entity {
|
|
120
|
+
// The name of the server class
|
|
121
|
+
static class = 'Employee';
|
|
122
|
+
constructor() {
|
|
123
|
+
super();
|
|
124
|
+
this.$addTag('employee');
|
|
125
|
+
this.$data.current = true;
|
|
126
|
+
this.$data.subordinates = [];
|
|
121
127
|
}
|
|
122
128
|
$testMethod(value) {
|
|
123
129
|
return this.$serverCall('$testMethod', [value]);
|
|
@@ -137,14 +143,94 @@ class Employee extends client_1.Entity {
|
|
|
137
143
|
static testStatic(value) {
|
|
138
144
|
return this.serverCallStatic('testStatic', [value]);
|
|
139
145
|
}
|
|
146
|
+
static testStaticIterable(value) {
|
|
147
|
+
return this.serverCallStaticIterator('testStaticIterable', [value]);
|
|
148
|
+
}
|
|
149
|
+
static testStaticIterableAbort() {
|
|
150
|
+
return this.serverCallStaticIterator('testStaticIterableAbort', []);
|
|
151
|
+
}
|
|
140
152
|
static throwErrorStatic() {
|
|
141
153
|
return this.serverCallStatic('throwErrorStatic', []);
|
|
142
154
|
}
|
|
155
|
+
static throwErrorStaticIterable() {
|
|
156
|
+
return this.serverCallStaticIterator('throwErrorStaticIterable', []);
|
|
157
|
+
}
|
|
143
158
|
static inaccessibleMethod() {
|
|
144
159
|
return this.serverCallStatic('inaccessibleMethod', []);
|
|
145
160
|
}
|
|
146
161
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
/**
|
|
163
|
+
* This class is a test class that extends the Entity class.
|
|
164
|
+
*/
|
|
165
|
+
export class RestrictedModel extends EntityServer {
|
|
166
|
+
static ETYPE = 'restricted';
|
|
167
|
+
static class = 'Restricted';
|
|
168
|
+
static restEnabled = false;
|
|
169
|
+
constructor() {
|
|
170
|
+
super();
|
|
171
|
+
this.$data.name = '';
|
|
172
|
+
}
|
|
173
|
+
async $save() {
|
|
174
|
+
// Validate entity data.
|
|
175
|
+
const error = new EntityInvalidDataError('Invalid entity data.');
|
|
176
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
177
|
+
error.addField('name');
|
|
178
|
+
}
|
|
179
|
+
if (error.getFields().length) {
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
return await super.$save();
|
|
183
|
+
}
|
|
184
|
+
$testMethod(value) {
|
|
185
|
+
return value;
|
|
186
|
+
}
|
|
187
|
+
static testStatic(value) {
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export class Restricted extends Entity {
|
|
192
|
+
// The name of the server class
|
|
193
|
+
static class = 'Restricted';
|
|
194
|
+
constructor() {
|
|
195
|
+
super();
|
|
196
|
+
this.$data.name = '';
|
|
197
|
+
}
|
|
198
|
+
$testMethod(value) {
|
|
199
|
+
return this.$serverCall('$testMethod', [value]);
|
|
200
|
+
}
|
|
201
|
+
static testStatic(value) {
|
|
202
|
+
return this.serverCallStatic('testStatic', [value]);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* This class is a test class that extends the Entity class.
|
|
207
|
+
*/
|
|
208
|
+
export class PubSubDisabledModel extends EntityServer {
|
|
209
|
+
static ETYPE = 'pubsub_disabled';
|
|
210
|
+
static class = 'PubSubDisabled';
|
|
211
|
+
static pubSubEnabled = false;
|
|
212
|
+
constructor() {
|
|
213
|
+
super();
|
|
214
|
+
this.$data.name = '';
|
|
215
|
+
}
|
|
216
|
+
async $save() {
|
|
217
|
+
// Validate entity data.
|
|
218
|
+
const error = new EntityInvalidDataError('Invalid entity data.');
|
|
219
|
+
if (this.$data.name == null || this.$data.name === '') {
|
|
220
|
+
error.addField('name');
|
|
221
|
+
}
|
|
222
|
+
if (error.getFields().length) {
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
return await super.$save();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
export class PubSubDisabled extends Entity {
|
|
229
|
+
// The name of the server class
|
|
230
|
+
static class = 'PubSubDisabled';
|
|
231
|
+
constructor() {
|
|
232
|
+
super();
|
|
233
|
+
this.$data.name = '';
|
|
234
|
+
}
|
|
235
|
+
}
|
|
150
236
|
//# sourceMappingURL=testArtifacts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testArtifacts.js","sourceRoot":"","sources":["../src/testArtifacts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":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aultEsmPreset();
|
|
4
|
+
|
|
1
5
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
|
-
|
|
3
|
-
|
|
6
|
+
const jestConfig = {
|
|
7
|
+
...presetConfig,
|
|
4
8
|
testEnvironment: 'node',
|
|
5
9
|
rootDir: 'src/',
|
|
10
|
+
moduleNameMapper: {
|
|
11
|
+
'^(\\.|\\.\\.)\\/(.+)\\.js': '$1/$2',
|
|
12
|
+
},
|
|
6
13
|
};
|
|
14
|
+
|
|
15
|
+
export default jestConfig;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nymphjs/server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "
|
|
5
|
-
"type": "
|
|
3
|
+
"version": "1.0.0-beta.111",
|
|
4
|
+
"description": "Nymph.js - REST Server",
|
|
5
|
+
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"keywords": [
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"clean": "test -d dist && rm -r dist || true",
|
|
15
15
|
"build": "tsc",
|
|
16
16
|
"watch": "tsc --watch",
|
|
17
|
-
"
|
|
18
|
-
"test": "jest",
|
|
19
|
-
"test:watch": "jest --watch"
|
|
17
|
+
"prepublish": "npm run clean && npm run build",
|
|
18
|
+
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
|
|
19
|
+
"test:watch": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --watch"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
@@ -31,21 +31,21 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@nymphjs/nymph": "^1.0.0-beta.
|
|
35
|
-
"cookie-parser": "^1.4.
|
|
36
|
-
"express": "^
|
|
34
|
+
"@nymphjs/nymph": "^1.0.0-beta.111",
|
|
35
|
+
"cookie-parser": "^1.4.7",
|
|
36
|
+
"express": "^5.2.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@nymphjs/client": "^1.0.0-beta.
|
|
40
|
-
"@nymphjs/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/
|
|
45
|
-
"
|
|
46
|
-
"jest": "^29.4.
|
|
47
|
-
"ts-
|
|
48
|
-
"typescript": "^
|
|
39
|
+
"@nymphjs/client": "^1.0.0-beta.111",
|
|
40
|
+
"@nymphjs/driver-sqlite3": "^1.0.0-beta.111",
|
|
41
|
+
"@tsconfig/recommended": "^1.0.13",
|
|
42
|
+
"@types/cookie-parser": "^1.4.10",
|
|
43
|
+
"@types/express": "^5.0.6",
|
|
44
|
+
"@types/jest": "^30.0.0",
|
|
45
|
+
"jest": "^30.2.0",
|
|
46
|
+
"ts-jest": "^29.4.6",
|
|
47
|
+
"ts-node": "^10.9.2",
|
|
48
|
+
"typescript": "^5.9.3"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "8028358367d8fd89bb434f122b243bec4c71f2e1"
|
|
51
51
|
}
|
package/src/cache.test.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import SQLite3Driver from '@nymphjs/driver-sqlite3';
|
|
3
3
|
import { Nymph as NymphServer } from '@nymphjs/nymph';
|
|
4
|
-
import { Nymph } from '@nymphjs/client
|
|
4
|
+
import { Nymph } from '@nymphjs/client';
|
|
5
5
|
|
|
6
|
-
import createServer from './index';
|
|
6
|
+
import createServer from './index.js';
|
|
7
7
|
import {
|
|
8
8
|
EmployeeModel as EmployeeModelClass,
|
|
9
9
|
Employee as EmployeeClass,
|
|
10
|
-
} from './testArtifacts';
|
|
10
|
+
} from './testArtifacts.js';
|
|
11
11
|
|
|
12
12
|
const sqliteConfig = {
|
|
13
13
|
filename: ':memory:',
|
|
@@ -48,7 +48,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
48
48
|
// @ts-ignore TS doesn't know about WeakRef.
|
|
49
49
|
if (typeof WeakRef === 'undefined') {
|
|
50
50
|
throw new Error(
|
|
51
|
-
'You must run this test in an environment that includes WeakRef.'
|
|
51
|
+
'You must run this test in an environment that includes WeakRef.',
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -61,7 +61,7 @@ describe('Nymph REST Server and Client with Client Weak Ref Cache', () => {
|
|
|
61
61
|
const checkA = await Employee.factory(employee.guid);
|
|
62
62
|
const checkB = await nymph.getEntity(
|
|
63
63
|
{ class: Employee },
|
|
64
|
-
{ type: '&', guid: employee.guid }
|
|
64
|
+
{ type: '&', guid: employee.guid },
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
if (!checkB) {
|