@nymphjs/server 1.0.0-beta.45 → 1.0.0-beta.47

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 CHANGED
@@ -3,6 +3,14 @@
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.47](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.46...v1.0.0-beta.47) (2023-11-10)
7
+
8
+ **Note:** Version bump only for package @nymphjs/server
9
+
10
+ # [1.0.0-beta.46](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.45...v1.0.0-beta.46) (2023-08-29)
11
+
12
+ **Note:** Version bump only for package @nymphjs/server
13
+
6
14
  # [1.0.0-beta.45](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.44...v1.0.0-beta.45) (2023-07-17)
7
15
 
8
16
  **Note:** Version bump only for package @nymphjs/server
package/README.md CHANGED
@@ -28,7 +28,7 @@ const nymph = new Nymph(
28
28
  {},
29
29
  new SQLite3Driver({
30
30
  filename: ':memory:',
31
- })
31
+ }),
32
32
  );
33
33
  const MyEntity = nymph.addEntityClass(MyEntityClass);
34
34
 
@@ -87,7 +87,7 @@ const nymph = new Nymph(
87
87
  new SQLite3Driver({
88
88
  filename: ':memory:',
89
89
  }),
90
- tilmeld
90
+ tilmeld,
91
91
  );
92
92
  const MyEntity = nymph.addEntityClass(MyEntityClass);
93
93
 
@@ -123,8 +123,8 @@ app.user(
123
123
  {
124
124
  restUrl: 'https://mydomain.tld/rest',
125
125
  },
126
- nymph
127
- )
126
+ nymph,
127
+ ),
128
128
  );
129
129
 
130
130
  // Do anything else you need to do...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nymphjs/server",
3
- "version": "1.0.0-beta.45",
3
+ "version": "1.0.0-beta.47",
4
4
  "description": "Nymph.js - REST Server",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
@@ -31,21 +31,21 @@
31
31
  },
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
- "@nymphjs/nymph": "^1.0.0-beta.45",
34
+ "@nymphjs/nymph": "^1.0.0-beta.47",
35
35
  "cookie-parser": "^1.4.6",
36
36
  "express": "^4.18.2"
37
37
  },
38
38
  "devDependencies": {
39
- "@nymphjs/client": "^1.0.0-beta.45",
40
- "@nymphjs/client-node": "^1.0.0-beta.45",
41
- "@nymphjs/driver-sqlite3": "^1.0.0-beta.45",
42
- "@tsconfig/recommended": "^1.0.2",
43
- "@types/cookie-parser": "^1.4.3",
44
- "@types/express": "^4.17.17",
45
- "@types/jest": "^29.5.2",
46
- "jest": "^29.5.0",
47
- "ts-jest": "^29.1.0",
48
- "typescript": "^5.1.3"
39
+ "@nymphjs/client": "^1.0.0-beta.47",
40
+ "@nymphjs/client-node": "^1.0.0-beta.47",
41
+ "@nymphjs/driver-sqlite3": "^1.0.0-beta.47",
42
+ "@tsconfig/recommended": "^1.0.3",
43
+ "@types/cookie-parser": "^1.4.6",
44
+ "@types/express": "^4.17.21",
45
+ "@types/jest": "^29.5.8",
46
+ "jest": "^29.7.0",
47
+ "ts-jest": "^29.1.1",
48
+ "typescript": "^5.2.2"
49
49
  },
50
- "gitHead": "54e7585f6b1cd6c920e47e01414dfc427eb73886"
50
+ "gitHead": "228f0d25911d1b98859f2acf8ace3d3f251c4882"
51
51
  }
package/src/cache.test.ts CHANGED
@@ -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) {
@@ -43,7 +43,7 @@ export class ForbiddenClassError extends Error {
43
43
  */
44
44
  export function createServer(
45
45
  nymph: Nymph,
46
- { jsonOptions = {} }: { jsonOptions?: OptionsJson } = {}
46
+ { jsonOptions = {} }: { jsonOptions?: OptionsJson } = {},
47
47
  ) {
48
48
  const rest = express();
49
49
  rest.use(cookieParser());
@@ -52,7 +52,7 @@ export function createServer(
52
52
  function instantiateNymph(
53
53
  _request: Request,
54
54
  response: NymphResponse,
55
- next: NextFunction
55
+ next: NextFunction,
56
56
  ) {
57
57
  response.locals.nymph = nymph.clone();
58
58
  next();
@@ -61,7 +61,7 @@ export function createServer(
61
61
  async function authenticateTilmeld(
62
62
  request: Request,
63
63
  response: NymphResponse,
64
- next: NextFunction
64
+ next: NextFunction,
65
65
  ) {
66
66
  if (response.locals.nymph.tilmeld) {
67
67
  response.locals.nymph.tilmeld.request = request;
@@ -79,7 +79,7 @@ export function createServer(
79
79
  function unauthenticateTilmeld(
80
80
  _request: Request,
81
81
  response: NymphResponse,
82
- next: NextFunction
82
+ next: NextFunction,
83
83
  ) {
84
84
  if (response.locals.nymph.tilmeld) {
85
85
  response.locals.nymph.tilmeld.request = null;
@@ -163,7 +163,7 @@ export function createServer(
163
163
  selectors = classNamesToEntityConstructors(
164
164
  response.locals.nymph,
165
165
  selectors,
166
- true
166
+ true,
167
167
  );
168
168
  } catch (e: any) {
169
169
  if (e?.message === 'Not accessible.') {
@@ -185,12 +185,12 @@ export function createServer(
185
185
  if (action === 'entity') {
186
186
  result = await response.locals.nymph.getEntity(
187
187
  options,
188
- ...selectors
188
+ ...selectors,
189
189
  );
190
190
  } else {
191
191
  result = await response.locals.nymph.getEntities(
192
192
  options,
193
- ...selectors
193
+ ...selectors,
194
194
  );
195
195
  }
196
196
  } catch (e: any) {
@@ -217,7 +217,7 @@ export function createServer(
217
217
  if (
218
218
  !(await response.locals.nymph.tilmeld.checkClientUIDPermissions(
219
219
  data,
220
- TilmeldAccessLevels.READ_ACCESS
220
+ TilmeldAccessLevels.READ_ACCESS,
221
221
  ))
222
222
  ) {
223
223
  httpError(response, 403);
@@ -345,7 +345,7 @@ export function createServer(
345
345
  try {
346
346
  const params = referencesToEntities(
347
347
  [...data.params],
348
- response.locals.nymph
348
+ response.locals.nymph,
349
349
  );
350
350
  if (data.static) {
351
351
  let EntityClass: EntityConstructor;
@@ -396,7 +396,7 @@ export function createServer(
396
396
  | Iterator<any, any, boolean>
397
397
  | AsyncIterator<any, any, boolean> = method.call(
398
398
  EntityClass,
399
- ...params
399
+ ...params,
400
400
  );
401
401
  let sequence = result;
402
402
  if (result instanceof Promise) {
@@ -505,7 +505,7 @@ export function createServer(
505
505
  if (
506
506
  !(await response.locals.nymph.tilmeld.checkClientUIDPermissions(
507
507
  data,
508
- TilmeldAccessLevels.WRITE_ACCESS
508
+ TilmeldAccessLevels.WRITE_ACCESS,
509
509
  ))
510
510
  ) {
511
511
  httpError(response, 403);
@@ -565,7 +565,7 @@ export function createServer(
565
565
  response: NymphResponse,
566
566
  action: string,
567
567
  data: any,
568
- patch: boolean
568
+ patch: boolean,
569
569
  ) {
570
570
  if (action === 'uid') {
571
571
  if (typeof data.name !== 'string' || typeof data.value !== 'number') {
@@ -576,7 +576,7 @@ export function createServer(
576
576
  if (
577
577
  !(await response.locals.nymph.tilmeld.checkClientUIDPermissions(
578
578
  data.name,
579
- TilmeldAccessLevels.FULL_ACCESS
579
+ TilmeldAccessLevels.FULL_ACCESS,
580
580
  ))
581
581
  ) {
582
582
  httpError(response, 403);
@@ -716,7 +716,7 @@ export function createServer(
716
716
  try {
717
717
  entity = await response.locals.nymph.getEntity(
718
718
  { class: EntityClass },
719
- { type: '&', guid: entData.guid }
719
+ { type: '&', guid: entData.guid },
720
720
  );
721
721
  } catch (e: any) {
722
722
  lastException = e;
@@ -765,7 +765,7 @@ export function createServer(
765
765
  if (
766
766
  !(await response.locals.nymph.tilmeld.checkClientUIDPermissions(
767
767
  data,
768
- TilmeldAccessLevels.FULL_ACCESS
768
+ TilmeldAccessLevels.FULL_ACCESS,
769
769
  ))
770
770
  ) {
771
771
  httpError(response, 403);
@@ -800,12 +800,12 @@ export function createServer(
800
800
  entityData: EntityJson | EntityPatch,
801
801
  nymph: Nymph,
802
802
  patch = false,
803
- allowConflict = false
803
+ allowConflict = false,
804
804
  ): Promise<EntityInterface> {
805
805
  if (entityData.class === 'Entity') {
806
806
  // Don't let clients use the `Entity` class, since it has no validity/AC checks.
807
807
  throw new InvalidParametersError(
808
- "Can't use Entity class directly from the front end."
808
+ "Can't use Entity class directly from the front end.",
809
809
  );
810
810
  }
811
811
  let EntityClass = nymph.getEntityClass(entityData.class);
@@ -819,7 +819,7 @@ export function createServer(
819
819
  {
820
820
  type: '&',
821
821
  guid: `${entityData['guid']}`,
822
- }
822
+ },
823
823
  );
824
824
  if (entity === null) {
825
825
  throw new Error(NOT_FOUND_ERROR);
@@ -878,7 +878,7 @@ export function createServer(
878
878
  function httpError(
879
879
  res: NymphResponse,
880
880
  defaultStatusCode: number,
881
- error?: Error & { status?: number; statusText?: string }
881
+ error?: Error & { status?: number; statusText?: string },
882
882
  ) {
883
883
  const status = error?.status || defaultStatusCode;
884
884
  const statusText =
@@ -923,7 +923,7 @@ export function createServer(
923
923
  function eventStreamError(
924
924
  res: NymphResponse,
925
925
  defaultStatusCode: number,
926
- error?: Error & { status?: number; statusText?: string }
926
+ error?: Error & { status?: number; statusText?: string },
927
927
  ) {
928
928
  const status = error?.status || defaultStatusCode;
929
929
  const statusText =
package/src/index.test.ts CHANGED
@@ -134,7 +134,7 @@ describe('Nymph REST Server and Client', () => {
134
134
  {
135
135
  type: '&',
136
136
  ref: ['subordinates', jane],
137
- }
137
+ },
138
138
  );
139
139
 
140
140
  expect(checkSteve?.guid).toEqual(steve.guid);
@@ -147,7 +147,7 @@ describe('Nymph REST Server and Client', () => {
147
147
  'subordinates',
148
148
  [{ class: Employee }, { type: '&', guid: jane.guid }],
149
149
  ],
150
- }
150
+ },
151
151
  );
152
152
 
153
153
  expect(checkSteveQref?.guid).toEqual(steve.guid);
@@ -161,7 +161,7 @@ describe('Nymph REST Server and Client', () => {
161
161
  expect(entity.$hasTag('test', 'test2')).toEqual(true);
162
162
  entity.$addTag('test', 'test3', 'test4', 'test5', 'test6');
163
163
  expect(entity.$hasTag('test', 'test3', 'test4', 'test5', 'test6')).toEqual(
164
- true
164
+ true,
165
165
  );
166
166
  entity.$removeTag('test2');
167
167
  expect(!entity.$hasTag('test2')).toEqual(true);
@@ -237,7 +237,7 @@ describe('Nymph REST Server and Client', () => {
237
237
  {
238
238
  type: '&',
239
239
  equal: ['name', 'Jane Doe'],
240
- }
240
+ },
241
241
  );
242
242
 
243
243
  expect(jane).not.toBeNull();
@@ -257,7 +257,7 @@ describe('Nymph REST Server and Client', () => {
257
257
  {
258
258
  type: '&',
259
259
  tag: ['employee'],
260
- }
260
+ },
261
261
  );
262
262
 
263
263
  expect(entities.length).toEqual(4);
@@ -283,13 +283,13 @@ describe('Nymph REST Server and Client', () => {
283
283
 
284
284
  const resultSelectors = await nymph.getEntities(
285
285
  { class: Employee },
286
- { type: '&', equal: ['name', 'Jane Doe'] }
286
+ { type: '&', equal: ['name', 'Jane Doe'] },
287
287
  );
288
288
 
289
289
  // Testing count return with selectors...
290
290
  const resultSelectorsCount = await nymph.getEntities(
291
291
  { class: Employee, return: 'count' },
292
- { type: '&', equal: ['name', 'Jane Doe'] }
292
+ { type: '&', equal: ['name', 'Jane Doe'] },
293
293
  );
294
294
  expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
295
295
  expect(resultSelectorsCount).toEqual(resultSelectors.length);
@@ -312,7 +312,7 @@ describe('Nymph REST Server and Client', () => {
312
312
  // Testing empty count...
313
313
  const resultSelectorsEmpty = await nymph.getEntities(
314
314
  { class: Employee, return: 'count' },
315
- { type: '&', tag: 'pickle' }
315
+ { type: '&', tag: 'pickle' },
316
316
  );
317
317
  expect(resultSelectorsEmpty).toEqual(0);
318
318
  });
@@ -331,7 +331,7 @@ describe('Nymph REST Server and Client', () => {
331
331
  {
332
332
  type: '&',
333
333
  tag: 'employee',
334
- }
334
+ },
335
335
  );
336
336
 
337
337
  expect(entities.length).toEqual(4);
@@ -357,7 +357,7 @@ describe('Nymph REST Server and Client', () => {
357
357
  {
358
358
  type: '&',
359
359
  like: ['name', '%Jane%'],
360
- }
360
+ },
361
361
  );
362
362
 
363
363
  expect(entities.length).toEqual(4);
@@ -383,7 +383,7 @@ describe('Nymph REST Server and Client', () => {
383
383
  type: '|',
384
384
  like: ['name', '%Jane%'],
385
385
  },
386
- }
386
+ },
387
387
  );
388
388
 
389
389
  expect(entities.length).toEqual(4);
@@ -418,7 +418,7 @@ describe('Nymph REST Server and Client', () => {
418
418
  },
419
419
  ],
420
420
  },
421
- }
421
+ },
422
422
  );
423
423
 
424
424
  expect(entities.length).toEqual(4);
@@ -443,7 +443,7 @@ describe('Nymph REST Server and Client', () => {
443
443
  {
444
444
  type: '&',
445
445
  guid,
446
- }
446
+ },
447
447
  );
448
448
 
449
449
  expect(check.length).toEqual(0);
@@ -466,7 +466,7 @@ describe('Nymph REST Server and Client', () => {
466
466
  {
467
467
  type: '|',
468
468
  guid: guids,
469
- }
469
+ },
470
470
  );
471
471
 
472
472
  expect(check.length).toEqual(0);
@@ -483,7 +483,7 @@ describe('Nymph REST Server and Client', () => {
483
483
  error = e;
484
484
  }
485
485
  expect(error.message).toEqual(
486
- "Can't use Entity class directly from the front end."
486
+ "Can't use Entity class directly from the front end.",
487
487
  );
488
488
  });
489
489
 
@@ -623,7 +623,7 @@ describe('Nymph REST Server and Client', () => {
623
623
  {
624
624
  class: Employee,
625
625
  },
626
- jane1.guid
626
+ jane1.guid,
627
627
  );
628
628
  if (jane1 == null || jane2 == null) {
629
629
  throw new Error('Entity is null.');
@@ -649,7 +649,7 @@ describe('Nymph REST Server and Client', () => {
649
649
  {
650
650
  class: Employee,
651
651
  },
652
- first.guid
652
+ first.guid,
653
653
  );
654
654
 
655
655
  if (second == null || second.guid == null) {
@@ -681,7 +681,7 @@ describe('Nymph REST Server and Client', () => {
681
681
  {
682
682
  class: Employee,
683
683
  },
684
- first.guid
684
+ first.guid,
685
685
  );
686
686
 
687
687
  if (second == null || second.guid == null) {
@@ -704,7 +704,7 @@ describe('Nymph REST Server and Client', () => {
704
704
  {
705
705
  type: '&',
706
706
  '!guid': first.guid,
707
- }
707
+ },
708
708
  );
709
709
 
710
710
  if (third == null || third.guid == null) {
@@ -64,7 +64,7 @@ export class EmployeeModel extends EntityServer<EmployeeModelData> {
64
64
  ];
65
65
 
66
66
  static async factory(
67
- guid?: string
67
+ guid?: string,
68
68
  ): Promise<EmployeeModel & EmployeeModelData> {
69
69
  return (await super.factory(guid)) as EmployeeModel & EmployeeModelData;
70
70
  }
@@ -132,7 +132,7 @@ export class EmployeeModel extends EntityServer<EmployeeModelData> {
132
132
 
133
133
  if (!aborted) {
134
134
  throw new Error(
135
- "testStaticIterableAbort wasn't aborted after the first iteration."
135
+ "testStaticIterableAbort wasn't aborted after the first iteration.",
136
136
  );
137
137
  }
138
138
  }
@@ -144,7 +144,7 @@ export class EmployeeModel extends EntityServer<EmployeeModelData> {
144
144
  public static *throwErrorStaticIterable() {
145
145
  yield 1;
146
146
  throw new BadFunctionCallError(
147
- 'This function throws errors after the first iteration.'
147
+ 'This function throws errors after the first iteration.',
148
148
  );
149
149
  }
150
150
 
@@ -253,7 +253,7 @@ export class RestrictedModel extends EntityServer<RestrictedModelData> {
253
253
  public static restEnabled = false;
254
254
 
255
255
  static async factory(
256
- guid?: string
256
+ guid?: string,
257
257
  ): Promise<RestrictedModel & RestrictedModelData> {
258
258
  return (await super.factory(guid)) as RestrictedModel & RestrictedModelData;
259
259
  }
@@ -334,7 +334,7 @@ export class PubSubDisabledModel extends EntityServer<PubSubDisabledModelData> {
334
334
  public static pubSubEnabled = false;
335
335
 
336
336
  static async factory(
337
- guid?: string
337
+ guid?: string,
338
338
  ): Promise<PubSubDisabledModel & PubSubDisabledModelData> {
339
339
  return (await super.factory(guid)) as PubSubDisabledModel &
340
340
  PubSubDisabledModelData;
@@ -378,7 +378,7 @@ export class PubSubDisabled extends Entity<PubSubDisabledData> {
378
378
  }
379
379
 
380
380
  static async factory(
381
- guid?: string
381
+ guid?: string,
382
382
  ): Promise<PubSubDisabled & PubSubDisabledData> {
383
383
  return (await super.factory(guid)) as PubSubDisabled & PubSubDisabledData;
384
384
  }