@nymphjs/nymph 1.0.0-beta.1 → 1.0.0-beta.100

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +535 -0
  2. package/README.md +14 -22
  3. package/dist/Entity.d.ts +293 -10
  4. package/dist/Entity.js +571 -149
  5. package/dist/Entity.js.map +1 -1
  6. package/dist/Entity.test.js +67 -26
  7. package/dist/Entity.test.js.map +1 -1
  8. package/dist/Entity.types.d.ts +256 -23
  9. package/dist/Entity.types.js +1 -2
  10. package/dist/Nymph.d.ts +497 -13
  11. package/dist/Nymph.js +761 -188
  12. package/dist/Nymph.js.map +1 -1
  13. package/dist/Nymph.types.d.ts +95 -26
  14. package/dist/Nymph.types.js +3 -5
  15. package/dist/Nymph.types.js.map +1 -1
  16. package/dist/conf/d.d.ts +43 -0
  17. package/dist/conf/d.js +1 -2
  18. package/dist/conf/defaults.d.ts +1 -1
  19. package/dist/conf/defaults.js +26 -3
  20. package/dist/conf/defaults.js.map +1 -1
  21. package/dist/conf/index.d.ts +2 -2
  22. package/dist/conf/index.js +2 -8
  23. package/dist/conf/index.js.map +1 -1
  24. package/dist/driver/NymphDriver.d.ts +181 -43
  25. package/dist/driver/NymphDriver.js +532 -285
  26. package/dist/driver/NymphDriver.js.map +1 -1
  27. package/dist/driver/index.d.ts +2 -2
  28. package/dist/driver/index.js +3 -23
  29. package/dist/driver/index.js.map +1 -1
  30. package/dist/driver/testArtifacts.d.ts +2 -2
  31. package/dist/driver/testArtifacts.js +939 -219
  32. package/dist/driver/testArtifacts.js.map +1 -1
  33. package/dist/errors/ClassNotAvailableError.js +1 -5
  34. package/dist/errors/ClassNotAvailableError.js.map +1 -1
  35. package/dist/errors/EntityConflictError.js +1 -5
  36. package/dist/errors/EntityConflictError.js.map +1 -1
  37. package/dist/errors/EntityInvalidDataError.d.ts +6 -0
  38. package/dist/errors/EntityInvalidDataError.js +8 -6
  39. package/dist/errors/EntityInvalidDataError.js.map +1 -1
  40. package/dist/errors/EntityIsSleepingReferenceError.js +1 -5
  41. package/dist/errors/EntityIsSleepingReferenceError.js.map +1 -1
  42. package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
  43. package/dist/errors/EntityUniqueConstraintError.js +7 -0
  44. package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
  45. package/dist/errors/InvalidParametersError.js +1 -5
  46. package/dist/errors/InvalidParametersError.js.map +1 -1
  47. package/dist/errors/InvalidStateError.d.ts +3 -0
  48. package/dist/errors/InvalidStateError.js +7 -0
  49. package/dist/errors/InvalidStateError.js.map +1 -0
  50. package/dist/errors/NotConfiguredError.js +1 -5
  51. package/dist/errors/NotConfiguredError.js.map +1 -1
  52. package/dist/errors/QueryFailedError.js +2 -5
  53. package/dist/errors/QueryFailedError.js.map +1 -1
  54. package/dist/errors/UnableToConnectError.js +1 -5
  55. package/dist/errors/UnableToConnectError.js.map +1 -1
  56. package/dist/errors/index.d.ts +10 -8
  57. package/dist/errors/index.js +10 -24
  58. package/dist/errors/index.js.map +1 -1
  59. package/dist/index.d.ts +11 -11
  60. package/dist/index.js +14 -34
  61. package/dist/index.js.map +1 -1
  62. package/dist/nymphJoiProps.js +10 -15
  63. package/dist/nymphJoiProps.js.map +1 -1
  64. package/dist/testArtifacts.d.ts +19 -6
  65. package/dist/testArtifacts.js +32 -37
  66. package/dist/testArtifacts.js.map +1 -1
  67. package/dist/testMocks.d.ts +28 -11
  68. package/dist/testMocks.js +44 -28
  69. package/dist/testMocks.js.map +1 -1
  70. package/dist/utils.d.ts +4 -4
  71. package/dist/utils.js +40 -29
  72. package/dist/utils.js.map +1 -1
  73. package/jest.config.js +11 -2
  74. package/package.json +24 -20
  75. package/src/Entity.test.ts +63 -13
  76. package/src/Entity.ts +498 -156
  77. package/src/Entity.types.ts +72 -74
  78. package/src/Nymph.ts +904 -336
  79. package/src/Nymph.types.ts +179 -44
  80. package/src/conf/d.ts +25 -0
  81. package/src/conf/defaults.ts +34 -1
  82. package/src/conf/index.ts +2 -2
  83. package/src/driver/NymphDriver.ts +650 -460
  84. package/src/driver/index.ts +2 -2
  85. package/src/driver/testArtifacts.ts +966 -196
  86. package/src/errors/EntityUniqueConstraintError.ts +6 -0
  87. package/src/errors/InvalidStateError.ts +6 -0
  88. package/src/errors/index.ts +12 -8
  89. package/src/index.ts +11 -11
  90. package/src/nymphJoiProps.ts +2 -2
  91. package/src/testArtifacts.ts +20 -20
  92. package/src/testMocks.ts +85 -37
  93. package/src/type/locutus.d.ts +3 -0
  94. package/src/utils.ts +39 -18
  95. package/tsconfig.json +5 -3
  96. package/typedoc.json +4 -0
@@ -1,18 +1,29 @@
1
- import fs from 'fs';
2
- import strtotime from 'locutus/php/datetime/strtotime';
1
+ import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import fs from 'node:fs';
4
+ import strtotime from 'locutus/php/datetime/strtotime.js';
3
5
  import { guid } from '@nymphjs/guid';
4
6
 
5
- import type Nymph from '../Nymph';
6
- import { TestBModel, TestModel, TestModelData } from '../testArtifacts';
7
+ import type Nymph from '../Nymph.js';
8
+ import { EntityUniqueConstraintError } from '../errors/index.js';
9
+ import {
10
+ TestBModel as TestBModelClass,
11
+ TestModel as TestModelClass,
12
+ TestModelData,
13
+ TestEmptyModel as TestEmptyModelClass,
14
+ } from '../testArtifacts.js';
7
15
 
8
- export function QueriesTest(
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+
18
+ export function EntitiesTest(
9
19
  nymph: Nymph,
10
- it: (name: string, fn: () => void) => void
20
+ it: (name: string, fn: () => void) => void,
11
21
  ) {
12
- nymph.addEntityClass(TestModel);
13
- nymph.addEntityClass(TestBModel);
22
+ const TestModel = nymph.addEntityClass(TestModelClass);
23
+ const TestBModel = nymph.addEntityClass(TestBModelClass);
24
+ const TestEmptyModel = nymph.addEntityClass(TestEmptyModelClass);
14
25
 
15
- let testEntity: TestModel & TestModelData;
26
+ let testEntity: TestModelClass & TestModelData;
16
27
  let testGuid: string;
17
28
  let refGuid: string;
18
29
  let createdMultiple = false;
@@ -30,12 +41,16 @@ export function QueriesTest(
30
41
  testEntity.name = 'Entity Test ' + new Date().toLocaleString();
31
42
  testEntity.null = null;
32
43
  testEntity.string = 'test';
33
- testEntity.array = ['full', 'of', 'values', 500];
34
- testEntity.match = `Hello, my name is Edward McCheese. It is a pleasure to meet you. As you can see, I have several hats of the most pleasant nature.
35
-
36
- This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
37
- This one's phone number is (555) 555-1818.
38
- This one's zip code is 92064.`;
44
+ testEntity.array = [
45
+ 'full',
46
+ 'of',
47
+ 'values',
48
+ 500,
49
+ { test: true },
50
+ { nullbyte: '\\\x00\u0000 \x00' },
51
+ ];
52
+ testEntity.match = matchValue;
53
+ testEntity.search = searchValue;
39
54
  testEntity.number = 30;
40
55
  testEntity.numberString = '30';
41
56
  testEntity.timestamp = Date.now();
@@ -43,7 +58,7 @@ This one's zip code is 92064.`;
43
58
  expect(testEntity.guid).not.toBeNull();
44
59
  testGuid = testEntity.guid as string;
45
60
 
46
- const entityReferenceTest: TestModel & TestModelData = new TestModel();
61
+ const entityReferenceTest: TestModelClass & TestModelData = new TestModel();
47
62
  entityReferenceTest.string = 'wrong';
48
63
  entityReferenceTest.timestamp = strtotime('-2 days') * 1000;
49
64
  expect(await entityReferenceTest.$save()).toEqual(true);
@@ -55,19 +70,11 @@ This one's zip code is 92064.`;
55
70
  entityReferenceTest.test = 'good';
56
71
  expect(await entityReferenceTest.$save()).toEqual(true);
57
72
 
58
- // Test synchronous getEntity.
59
- testEntity = nymph.driver.getEntitySync(
60
- { class: TestModel },
61
- testGuid
62
- ) as TestModel & TestModelData;
63
- expect(testEntity).toBeInstanceOf(TestModel);
64
- expect(testEntity.guid).toEqual(testGuid);
65
-
66
73
  // Test asynchronous getEntity.
67
74
  testEntity = (await nymph.getEntity(
68
75
  { class: TestModel },
69
- testGuid
70
- )) as TestModel & TestModelData;
76
+ testGuid,
77
+ )) as TestModelClass & TestModelData;
71
78
  expect(testEntity).toBeInstanceOf(TestModel);
72
79
  expect(testEntity.guid).toEqual(testGuid);
73
80
  }
@@ -80,6 +87,8 @@ This one's zip code is 92064.`;
80
87
  for (let i = 0; i < 100; i++) {
81
88
  const testEntity = await TestModel.factory();
82
89
  testEntity.name = `Multi Test ${i}`;
90
+ // Reverse the number for sort testing.
91
+ testEntity.number = 100 - i;
83
92
  testEntity.$removeTag('test');
84
93
  testEntity.$addTag('multiTest');
85
94
  expect(await testEntity.$save()).toEqual(true);
@@ -90,20 +99,36 @@ This one's zip code is 92064.`;
90
99
  }
91
100
 
92
101
  it('delete old test data', async () => {
93
- let all = await nymph.getEntities({ class: TestModel });
94
- expect(Array.isArray(all)).toEqual(true);
95
- for (const cur of all) {
102
+ let amodels = await nymph.getEntities({ class: TestModel });
103
+ expect(Array.isArray(amodels)).toEqual(true);
104
+ for (const cur of amodels) {
96
105
  expect(await cur.$delete()).toEqual(true);
97
106
  }
98
107
 
99
- all = await nymph.getEntities({ class: TestModel });
100
- expect(all.length).toEqual(0);
108
+ amodels = await nymph.getEntities({ class: TestModel });
109
+ expect(amodels.length).toEqual(0);
110
+
111
+ let bmodels = await nymph.getEntities({ class: TestBModel });
112
+ expect(Array.isArray(bmodels)).toEqual(true);
113
+ for (const cur of bmodels) {
114
+ expect(await cur.$delete()).toEqual(true);
115
+ }
116
+
117
+ bmodels = await nymph.getEntities({ class: TestBModel });
118
+ expect(bmodels.length).toEqual(0);
101
119
  });
102
120
 
103
121
  it('create entity', async () => {
104
122
  await createTestEntities();
105
123
  });
106
124
 
125
+ it("doesn't create empty entity", async () => {
126
+ const testEntity = await TestEmptyModel.factory();
127
+
128
+ expect(await testEntity.$save()).toBeFalsy();
129
+ expect(testEntity.guid).toBeNull();
130
+ });
131
+
107
132
  it('update mdate on save', async () => {
108
133
  await createTestEntities();
109
134
 
@@ -135,6 +160,35 @@ This one's zip code is 92064.`;
135
160
  expect(testEntity.$is(resultEntity)).toEqual(false);
136
161
  });
137
162
 
163
+ it('guaranteed guid', async () => {
164
+ // Creating entity...
165
+ const testEntity = await TestModel.factory();
166
+
167
+ // Saving entity...
168
+ testEntity.name = 'Entity Test ' + new Date().toLocaleString();
169
+ testEntity.null = null;
170
+ testEntity.string = 'test';
171
+ testEntity.array = [];
172
+ testEntity.match = matchValue;
173
+ testEntity.number = 30;
174
+ testEntity.numberString = '30';
175
+ testEntity.timestamp = Date.now();
176
+
177
+ // Get the guaranteed GUID.
178
+ const testGuid = testEntity.$getGuaranteedGUID();
179
+
180
+ expect(await testEntity.$save()).toEqual(true);
181
+ expect(testEntity.guid).not.toBeNull();
182
+ expect(testEntity.guid).toEqual(testGuid);
183
+
184
+ // Retrieving entity by GUID...
185
+ let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
186
+ expect(testEntity.$is(resultEntity)).toEqual(true);
187
+
188
+ // Delete the entity.
189
+ expect(await testEntity.$delete()).toEqual(true);
190
+ });
191
+
138
192
  it('transactions', async () => {
139
193
  await createTestEntities();
140
194
 
@@ -146,7 +200,7 @@ This one's zip code is 92064.`;
146
200
 
147
201
  if (!(await transaction.inTransaction())) {
148
202
  console.log(
149
- 'This Nymph driver or database seems to not support transactions. Skipping transaction tests.'
203
+ 'This Nymph driver or database seems to not support transactions. Skipping transaction tests.',
150
204
  );
151
205
  await transaction.rollback('test');
152
206
  return;
@@ -177,7 +231,7 @@ This one's zip code is 92064.`;
177
231
  expect(await testEntity.$delete()).toEqual(true);
178
232
  const resultEntity = await transaction.getEntity(
179
233
  { class: TestModel },
180
- testGuid
234
+ testGuid,
181
235
  );
182
236
  expect(resultEntity).toBeNull();
183
237
 
@@ -190,13 +244,13 @@ This one's zip code is 92064.`;
190
244
  // Verify it's back.
191
245
  testEntity = (await transaction.getEntity(
192
246
  { class: TestModel },
193
- testGuid
194
- )) as TestModel & TestModelData;
247
+ testGuid,
248
+ )) as TestModelClass & TestModelData;
195
249
 
196
250
  expect(testEntity.guid).toEqual(testGuid);
197
251
 
198
- // Start a new transaction.
199
- transaction = await nymph.startTransaction('test');
252
+ // Start a new transaction with a dot in the name.
253
+ transaction = await nymph.startTransaction('test.1');
200
254
  testEntity.$nymph = transaction;
201
255
 
202
256
  // Verify in a transaction.
@@ -207,7 +261,7 @@ This one's zip code is 92064.`;
207
261
  expect(await testEntity.$save()).toEqual(true);
208
262
 
209
263
  // Commit the transaction.
210
- await transaction.commit('test');
264
+ await transaction.commit('test.1');
211
265
  testEntity.$nymph = nymph;
212
266
 
213
267
  // Verify not in a transaction.
@@ -236,7 +290,7 @@ This one's zip code is 92064.`;
236
290
  limit: 1,
237
291
  sort: 'cdate',
238
292
  },
239
- { type: '&', tag: 'test' }
293
+ { type: '&', tag: 'test' },
240
294
  );
241
295
  expect(resultEntities.length).toEqual(1);
242
296
  expect(testEntity.$is(resultEntities[0])).toEqual(true);
@@ -248,7 +302,7 @@ This one's zip code is 92064.`;
248
302
  // Retrieving entity by GUID and tags...
249
303
  const resultEntity = await nymph.getEntity(
250
304
  { class: TestModel },
251
- { type: '&', guid: testGuid, tag: 'test' }
305
+ { type: '&', guid: testGuid, tag: 'test' },
252
306
  );
253
307
  expect(testEntity.$is(resultEntity)).toEqual(true);
254
308
  });
@@ -259,7 +313,7 @@ This one's zip code is 92064.`;
259
313
  // Retrieving entity by GUID and tags...
260
314
  const resultEntity = await nymph.getEntity(
261
315
  { class: TestModel },
262
- { type: '|', guid: [testGuid, guid()] }
316
+ { type: '|', guid: [testGuid, guid()] },
263
317
  );
264
318
  expect(testEntity.$is(resultEntity)).toEqual(true);
265
319
  });
@@ -270,7 +324,7 @@ This one's zip code is 92064.`;
270
324
  // Retrieving entity by GUID and tags...
271
325
  const resultEntity = await nymph.getEntity(
272
326
  { class: TestModel },
273
- { type: '|', guid: [guid(), guid()] }
327
+ { type: '|', guid: [guid(), guid()] },
274
328
  );
275
329
  expect(testEntity.$is(resultEntity)).toEqual(false);
276
330
  });
@@ -281,7 +335,7 @@ This one's zip code is 92064.`;
281
335
  // Retrieving entity by !GUID...
282
336
  const resultEntity = await nymph.getEntities(
283
337
  { class: TestModel },
284
- { type: '&', '!guid': guid(), tag: 'test' }
338
+ { type: '&', '!guid': guid(), tag: 'test' },
285
339
  );
286
340
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
287
341
  });
@@ -292,7 +346,7 @@ This one's zip code is 92064.`;
292
346
  // Retrieving entity by !tags...
293
347
  const resultEntity = await nymph.getEntities(
294
348
  { class: TestModel },
295
- { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] }
349
+ { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] },
296
350
  );
297
351
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
298
352
  });
@@ -303,7 +357,7 @@ This one's zip code is 92064.`;
303
357
  // Testing GUID and wrong tags...
304
358
  const resultEntity = await nymph.getEntity(
305
359
  { class: TestModel },
306
- { type: '&', guid: testGuid, tag: ['pickles'] }
360
+ { type: '&', guid: testGuid, tag: ['pickles'] },
307
361
  );
308
362
  expect(resultEntity).toBeNull();
309
363
  });
@@ -314,7 +368,7 @@ This one's zip code is 92064.`;
314
368
  // Retrieving entity by tags...
315
369
  const resultEntity = await nymph.getEntities(
316
370
  { class: TestModel },
317
- { type: '&', tag: 'test' }
371
+ { type: '&', tag: 'test' },
318
372
  );
319
373
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
320
374
  });
@@ -325,7 +379,7 @@ This one's zip code is 92064.`;
325
379
  // Testing wrong tags...
326
380
  const resultEntity = await nymph.getEntities(
327
381
  { class: TestModel },
328
- { type: '&', tag: 'pickles' }
382
+ { type: '&', tag: 'pickles' },
329
383
  );
330
384
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
331
385
  });
@@ -336,7 +390,7 @@ This one's zip code is 92064.`;
336
390
  // Retrieving entity by tags inclusively...
337
391
  const resultEntity = await nymph.getEntities(
338
392
  { class: TestModel },
339
- { type: '|', tag: ['pickles', 'test', 'barbecue'] }
393
+ { type: '|', tag: ['pickles', 'test', 'barbecue'] },
340
394
  );
341
395
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
342
396
  });
@@ -347,7 +401,7 @@ This one's zip code is 92064.`;
347
401
  // Testing wrong inclusive tags...
348
402
  const resultEntity = await nymph.getEntities(
349
403
  { class: TestModel },
350
- { type: '|', tag: ['pickles', 'barbecue'] }
404
+ { type: '|', tag: ['pickles', 'barbecue'] },
351
405
  );
352
406
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
353
407
  });
@@ -359,7 +413,7 @@ This one's zip code is 92064.`;
359
413
  const resultEntity = await nymph.getEntities(
360
414
  { class: TestModel },
361
415
  { type: '&', tag: 'test' },
362
- { type: '|', tag: ['pickles', 'test', 'barbecue'] }
416
+ { type: '|', tag: ['pickles', 'test', 'barbecue'] },
363
417
  );
364
418
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
365
419
  });
@@ -371,7 +425,7 @@ This one's zip code is 92064.`;
371
425
  const resultEntity = await nymph.getEntities(
372
426
  { class: TestModel },
373
427
  { type: '&', tag: 'test' },
374
- { type: '|', tag: ['pickles', 'barbecue'] }
428
+ { type: '|', tag: ['pickles', 'barbecue'] },
375
429
  );
376
430
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
377
431
  });
@@ -383,7 +437,7 @@ This one's zip code is 92064.`;
383
437
  const resultEntity = await nymph.getEntities(
384
438
  { class: TestModel },
385
439
  { type: '&', tag: 'pickles' },
386
- { type: '|', tag: ['test', 'barbecue'] }
440
+ { type: '|', tag: ['test', 'barbecue'] },
387
441
  );
388
442
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
389
443
  });
@@ -394,7 +448,7 @@ This one's zip code is 92064.`;
394
448
  // Retrieving entity by defined...
395
449
  const resultEntity = await nymph.getEntities(
396
450
  { class: TestModel },
397
- { type: '&', defined: 'string' }
451
+ { type: '&', defined: 'string' },
398
452
  );
399
453
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
400
454
  });
@@ -405,7 +459,7 @@ This one's zip code is 92064.`;
405
459
  // Retrieving entity by !defined...
406
460
  const resultEntity = await nymph.getEntities(
407
461
  { class: TestModel },
408
- { type: '&', tag: 'test', '!defined': 'pickles' }
462
+ { type: '&', tag: 'test', '!defined': 'pickles' },
409
463
  );
410
464
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
411
465
  });
@@ -417,7 +471,7 @@ This one's zip code is 92064.`;
417
471
  const resultEntity = await nymph.getEntities(
418
472
  { class: TestModel },
419
473
  { type: '!&', defined: 'pickles' },
420
- { type: '&', tag: 'test' }
474
+ { type: '&', tag: 'test' },
421
475
  );
422
476
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
423
477
  });
@@ -426,9 +480,60 @@ This one's zip code is 92064.`;
426
480
  await createTestEntities();
427
481
 
428
482
  // Retrieving entity by equal...
429
- const resultEntity = await nymph.getEntities(
483
+ let resultEntity = await nymph.getEntities(
484
+ { class: TestModel },
485
+ { type: '&', equal: ['string', 'test'] },
486
+ );
487
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
488
+
489
+ // Retrieving entity by equal...
490
+ resultEntity = await nymph.getEntities(
491
+ { class: TestModel },
492
+ { type: '&', equal: ['null', null] },
493
+ );
494
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
495
+
496
+ // Retrieving entity by equal...
497
+ resultEntity = await nymph.getEntities(
498
+ { class: TestModel },
499
+ { type: '&', equal: ['boolean', true] },
500
+ );
501
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
502
+
503
+ // Retrieving entity by equal...
504
+ resultEntity = await nymph.getEntities(
505
+ { class: TestModel },
506
+ { type: '&', equal: ['number', 30] },
507
+ );
508
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
509
+
510
+ // Retrieving entity by equal...
511
+ resultEntity = await nymph.getEntities(
512
+ { class: TestModel },
513
+ {
514
+ type: '&',
515
+ equal: [
516
+ 'array',
517
+ [
518
+ 'full',
519
+ 'of',
520
+ 'values',
521
+ 500,
522
+ { test: true },
523
+ { nullbyte: '\\\x00\u0000 \x00' },
524
+ ],
525
+ ],
526
+ },
527
+ );
528
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
529
+
530
+ // Retrieving entity by equal...
531
+ resultEntity = await nymph.getEntities(
430
532
  { class: TestModel },
431
- { type: '&', equal: ['string', 'test'] }
533
+ {
534
+ type: '&',
535
+ equal: ['match', matchValue],
536
+ },
432
537
  );
433
538
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
434
539
  });
@@ -442,7 +547,7 @@ This one's zip code is 92064.`;
442
547
  // Retrieving entity by !equal...
443
548
  const resultEntity = await nymph.getEntities(
444
549
  { class: TestModel },
445
- { type: '&', tag: 'test', '!equal': ['string', 'wrong'] }
550
+ { type: '&', tag: 'test', '!equal': ['string', 'wrong'] },
446
551
  );
447
552
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
448
553
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -454,7 +559,7 @@ This one's zip code is 92064.`;
454
559
  // Retrieving entity by like...
455
560
  const resultEntity = await nymph.getEntities(
456
561
  { class: TestModel },
457
- { type: '&', like: ['string', 't_s%'] }
562
+ { type: '&', like: ['string', 't_s%'] },
458
563
  );
459
564
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
460
565
  });
@@ -468,7 +573,7 @@ This one's zip code is 92064.`;
468
573
  // Retrieving entity by !like...
469
574
  const resultEntity = await nymph.getEntities(
470
575
  { class: TestModel },
471
- { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] }
576
+ { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] },
472
577
  );
473
578
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
474
579
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -480,7 +585,7 @@ This one's zip code is 92064.`;
480
585
  // Retrieving entity by ilike...
481
586
  const resultEntity = await nymph.getEntities(
482
587
  { class: TestModel },
483
- { type: '&', ilike: ['string', 'T_s%'] }
588
+ { type: '&', ilike: ['string', 'T_s%'] },
484
589
  );
485
590
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
486
591
  });
@@ -494,7 +599,7 @@ This one's zip code is 92064.`;
494
599
  // Retrieving entity by !ilike...
495
600
  const resultEntity = await nymph.getEntities(
496
601
  { class: TestModel },
497
- { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] }
602
+ { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] },
498
603
  );
499
604
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
500
605
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -506,7 +611,7 @@ This one's zip code is 92064.`;
506
611
  // Retrieving entity by like...
507
612
  const resultEntity = await nymph.getEntities(
508
613
  { class: TestModel },
509
- { type: '&', like: ['string', 'T_s%'] }
614
+ { type: '&', like: ['string', 'T_s%'] },
510
615
  );
511
616
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
512
617
  });
@@ -517,7 +622,7 @@ This one's zip code is 92064.`;
517
622
  // Retrieving entity by tags and equal...
518
623
  const resultEntity = await nymph.getEntities(
519
624
  { class: TestModel },
520
- { type: '&', tag: 'test', equal: ['string', 'test'] }
625
+ { type: '&', tag: 'test', equal: ['string', 'test'] },
521
626
  );
522
627
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
523
628
  });
@@ -528,7 +633,7 @@ This one's zip code is 92064.`;
528
633
  // Testing wrong tags and right equal...
529
634
  const resultEntity = await nymph.getEntities(
530
635
  { class: TestModel },
531
- { type: '&', tag: 'pickles', equal: ['string', 'test'] }
636
+ { type: '&', tag: 'pickles', equal: ['string', 'test'] },
532
637
  );
533
638
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
534
639
  });
@@ -539,7 +644,7 @@ This one's zip code is 92064.`;
539
644
  // Testing right tags and wrong equal...
540
645
  const resultEntity = await nymph.getEntities(
541
646
  { class: TestModel },
542
- { type: '&', tag: 'test', equal: ['string', 'pickles'] }
647
+ { type: '&', tag: 'test', equal: ['string', 'pickles'] },
543
648
  );
544
649
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
545
650
  });
@@ -550,7 +655,7 @@ This one's zip code is 92064.`;
550
655
  // Testing wrong tags and wrong equal...
551
656
  const resultEntity = await nymph.getEntities(
552
657
  { class: TestModel },
553
- { type: '&', tag: 'pickles', equal: ['string', 'pickles'] }
658
+ { type: '&', tag: 'pickles', equal: ['string', 'pickles'] },
554
659
  );
555
660
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
556
661
  });
@@ -561,14 +666,21 @@ This one's zip code is 92064.`;
561
666
  // Retrieving entity by contain...
562
667
  let resultEntity = await nymph.getEntities(
563
668
  { class: TestModel },
564
- { type: '&', contain: ['array', 'values'] }
669
+ { type: '&', contain: ['array', 'values'] },
670
+ );
671
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
672
+
673
+ // Retrieving entity by contain...
674
+ resultEntity = await nymph.getEntities(
675
+ { class: TestModel },
676
+ { type: '&', contain: ['array', 500] },
565
677
  );
566
678
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
567
679
 
568
- // Retrieving entity by contain with full match...
680
+ // Retrieving entity by contain...
569
681
  resultEntity = await nymph.getEntities(
570
682
  { class: TestModel },
571
- { type: '&', contain: ['string', 'test'] }
683
+ { type: '&', contain: ['array', { test: true }] },
572
684
  );
573
685
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
574
686
  });
@@ -580,7 +692,7 @@ This one's zip code is 92064.`;
580
692
  const resultEntity = await nymph.getEntities(
581
693
  { class: TestModel },
582
694
  { type: '&', tag: 'test' },
583
- { type: '!&', contain: ['array', 'pickles'] }
695
+ { type: '!&', contain: ['array', 'pickles'] },
584
696
  );
585
697
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
586
698
  });
@@ -591,14 +703,14 @@ This one's zip code is 92064.`;
591
703
  // Testing wrong contain...
592
704
  let resultEntity = await nymph.getEntities(
593
705
  { class: TestModel },
594
- { type: '&', contain: ['array', 'pickles'] }
706
+ { type: '&', contain: ['array', 'pickles'] },
595
707
  );
596
708
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
597
709
 
598
710
  // Testing wrong contain...
599
711
  resultEntity = await nymph.getEntities(
600
712
  { class: TestModel },
601
- { type: '&', contain: ['string', 'pickles'] }
713
+ { type: '&', contain: ['string', 'pickles'] },
602
714
  );
603
715
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
604
716
  });
@@ -609,12 +721,12 @@ This one's zip code is 92064.`;
609
721
  // Retrieving entity by regex match...
610
722
  let resultEntity = await nymph.getEntities(
611
723
  { class: TestModel },
612
- { type: '&', match: ['match', '.*'] } // anything
724
+ { type: '&', match: ['match', '.*'] }, // anything
613
725
  );
614
726
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
615
727
  resultEntity = await nymph.getEntities(
616
728
  { class: TestModel },
617
- { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] } // a substring
729
+ { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] }, // a substring
618
730
  );
619
731
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
620
732
  resultEntity = await nymph.getEntities(
@@ -626,7 +738,7 @@ This one's zip code is 92064.`;
626
738
  ['string', '[0-9]'],
627
739
  ['match', 'Edward McCheese'],
628
740
  ],
629
- } // inclusive test
741
+ }, // inclusive test
630
742
  );
631
743
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
632
744
  resultEntity = await nymph.getEntities(
@@ -635,7 +747,7 @@ This one's zip code is 92064.`;
635
747
  type: '&',
636
748
  tag: 'test',
637
749
  match: ['match', '[-a-zA-Z0-9+_]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9_]{2,4}'],
638
- } // a simple email
750
+ }, // a simple email
639
751
  );
640
752
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
641
753
  resultEntity = await nymph.getEntities(
@@ -644,7 +756,7 @@ This one's zip code is 92064.`;
644
756
  type: '&',
645
757
  tag: 'test',
646
758
  match: ['match', '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'],
647
- } // a phone number
759
+ }, // a phone number
648
760
  );
649
761
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
650
762
  });
@@ -655,7 +767,7 @@ This one's zip code is 92064.`;
655
767
  // Retrieving entity by regex match...
656
768
  const resultEntity = await nymph.getEntities(
657
769
  { class: TestModel },
658
- { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] } // a substring
770
+ { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] }, // a substring
659
771
  );
660
772
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
661
773
  });
@@ -666,12 +778,12 @@ This one's zip code is 92064.`;
666
778
  // Testing wrong regex match...
667
779
  let resultEntity = await nymph.getEntities(
668
780
  { class: TestModel },
669
- { type: '&', match: ['match', 'Q'] }
781
+ { type: '&', match: ['match', '='] },
670
782
  );
671
783
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
672
784
  resultEntity = await nymph.getEntities(
673
785
  { class: TestModel },
674
- { type: '&', tag: 'pickle', match: ['match', '.*'] }
786
+ { type: '&', tag: 'pickle', match: ['match', '.*'] },
675
787
  );
676
788
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
677
789
  resultEntity = await nymph.getEntities(
@@ -682,7 +794,7 @@ This one's zip code is 92064.`;
682
794
  ['string', '[0-9]'],
683
795
  ['match', ',,'],
684
796
  ],
685
- }
797
+ },
686
798
  );
687
799
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
688
800
  });
@@ -693,7 +805,7 @@ This one's zip code is 92064.`;
693
805
  // Retrieving entity by regex match...
694
806
  const resultEntity = await nymph.getEntities(
695
807
  { class: TestModel },
696
- { type: '&', tag: 'test', match: ['match', 'edward mccheese'] } // a substring
808
+ { type: '&', tag: 'test', match: ['match', 'edward mccheese'] }, // a substring
697
809
  );
698
810
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
699
811
  });
@@ -705,7 +817,181 @@ This one's zip code is 92064.`;
705
817
  const resultEntity = await nymph.getEntities(
706
818
  { class: TestModel },
707
819
  { type: '&', tag: 'test' },
708
- { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] }
820
+ { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] },
821
+ );
822
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
823
+ });
824
+
825
+ it('basic search', async () => {
826
+ await createTestEntities();
827
+
828
+ // Retrieving entity by full text search...
829
+ let resultEntity = await nymph.getEntities(
830
+ { class: TestModel },
831
+ {
832
+ type: '&',
833
+ tag: 'test',
834
+ search: [
835
+ 'search',
836
+ 'Declaration of the thirteen united States of America',
837
+ ],
838
+ }, // a substring
839
+ );
840
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
841
+ resultEntity = await nymph.getEntities(
842
+ { class: TestModel },
843
+ { type: '&', tag: 'test' },
844
+ {
845
+ type: '|',
846
+ search: [
847
+ ['string', 'pickle'],
848
+ ['search', 'Declaration of the thirteen united States of America'],
849
+ ],
850
+ }, // inclusive test
851
+ );
852
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
853
+ resultEntity = await nymph.getEntities(
854
+ { class: TestModel },
855
+ {
856
+ type: '&',
857
+ tag: 'test',
858
+ search: ['search', 'July 4, 1776'],
859
+ }, // a string with a number
860
+ );
861
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
862
+ });
863
+
864
+ it('or search', async () => {
865
+ await createTestEntities();
866
+
867
+ // Retrieving entity by full text search...
868
+ let resultEntity = await nymph.getEntities(
869
+ { class: TestModel },
870
+ {
871
+ type: '&',
872
+ tag: 'test',
873
+ search: ['search', 'Declaration or pickles'],
874
+ }, // a string with an or
875
+ );
876
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
877
+ });
878
+
879
+ it('series search', async () => {
880
+ await createTestEntities();
881
+
882
+ // Retrieving entity by full text search...
883
+ let resultEntity = await nymph.getEntities(
884
+ { class: TestModel },
885
+ {
886
+ type: '&',
887
+ tag: 'test',
888
+ search: ['search', '"excited domestic insurrections"'],
889
+ }, // double quoted substring
890
+ );
891
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
892
+ resultEntity = await nymph.getEntities(
893
+ { class: TestModel },
894
+ {
895
+ type: '&',
896
+ tag: 'test',
897
+ search: ['search', "'exciting domestic insurrected'"],
898
+ }, // single quoted substring
899
+ );
900
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
901
+ });
902
+
903
+ it('negated search', async () => {
904
+ await createTestEntities();
905
+
906
+ // Retrieving entity by full text search...
907
+ let resultEntity = await nymph.getEntities(
908
+ { class: TestModel },
909
+ {
910
+ type: '&',
911
+ tag: 'test',
912
+ search: ['search', '-pickle'],
913
+ }, // negated term
914
+ );
915
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
916
+ });
917
+
918
+ it('combined search', async () => {
919
+ await createTestEntities();
920
+
921
+ // Retrieving entity by full text search...
922
+ let resultEntity = await nymph.getEntities(
923
+ { class: TestModel },
924
+ {
925
+ type: '&',
926
+ tag: 'test',
927
+ search: ['search', 'Declaration -pickle'],
928
+ }, // negated term with positive term
929
+ );
930
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
931
+ resultEntity = await nymph.getEntities(
932
+ { class: TestModel },
933
+ {
934
+ type: '&',
935
+ tag: 'test',
936
+ search: ['search', 'Declaration "General Congress"'],
937
+ }, // terms found in separate areas
938
+ );
939
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
940
+ });
941
+
942
+ it('wrong search', async () => {
943
+ await createTestEntities();
944
+
945
+ // Testing wrong search...
946
+ let resultEntity = await nymph.getEntities(
947
+ { class: TestModel },
948
+ { type: '&', search: ['search', 'pickles'] },
949
+ );
950
+ expect(testEntity.$inArray(resultEntity)).toEqual(false);
951
+ resultEntity = await nymph.getEntities(
952
+ { class: TestModel },
953
+ { type: '&', tag: 'pickle', search: ['search', 'Declaration'] },
954
+ );
955
+ expect(testEntity.$inArray(resultEntity)).toEqual(false);
956
+ resultEntity = await nymph.getEntities(
957
+ { class: TestModel },
958
+ {
959
+ type: '|',
960
+ search: [
961
+ ['string', 'pickle'],
962
+ ['search', 'Hawaii'],
963
+ ],
964
+ },
965
+ );
966
+ expect(testEntity.$inArray(resultEntity)).toEqual(false);
967
+ });
968
+
969
+ it('search must be case insensitive', async () => {
970
+ await createTestEntities();
971
+
972
+ // Retrieving entity by full text search...
973
+ const resultEntity = await nymph.getEntities(
974
+ { class: TestModel },
975
+ {
976
+ type: '&',
977
+ tag: 'test',
978
+ search: [
979
+ 'search',
980
+ 'DECLARATION OF THE THIRTEEN UNITED STATES OF AMERICA',
981
+ ],
982
+ }, // a substring
983
+ );
984
+ expect(testEntity.$inArray(resultEntity)).toEqual(true);
985
+ });
986
+
987
+ it('search and equal inclusive', async () => {
988
+ await createTestEntities();
989
+
990
+ // Retrieving entity by fts + equal inclusively...
991
+ const resultEntity = await nymph.getEntities(
992
+ { class: TestModel },
993
+ { type: '&', tag: 'test' },
994
+ { type: '|', equal: ['string', 'pickles'], search: ['string', 'test'] },
709
995
  );
710
996
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
711
997
  });
@@ -722,7 +1008,7 @@ This one's zip code is 92064.`;
722
1008
  ['number', 30],
723
1009
  ['pickles', 100],
724
1010
  ],
725
- }
1011
+ },
726
1012
  );
727
1013
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
728
1014
 
@@ -735,7 +1021,7 @@ This one's zip code is 92064.`;
735
1021
  ['number', 31],
736
1022
  ['pickles', 100],
737
1023
  ],
738
- }
1024
+ },
739
1025
  );
740
1026
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
741
1027
 
@@ -748,7 +1034,7 @@ This one's zip code is 92064.`;
748
1034
  ['number', 29],
749
1035
  ['pickles', 100],
750
1036
  ],
751
- }
1037
+ },
752
1038
  );
753
1039
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
754
1040
 
@@ -761,7 +1047,7 @@ This one's zip code is 92064.`;
761
1047
  ['numberString', 30],
762
1048
  ['pickles', 100],
763
1049
  ],
764
- }
1050
+ },
765
1051
  );
766
1052
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
767
1053
 
@@ -774,7 +1060,7 @@ This one's zip code is 92064.`;
774
1060
  ['numberString', 31],
775
1061
  ['pickles', 100],
776
1062
  ],
777
- }
1063
+ },
778
1064
  );
779
1065
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
780
1066
 
@@ -787,7 +1073,7 @@ This one's zip code is 92064.`;
787
1073
  ['numberString', 29],
788
1074
  ['pickles', 100],
789
1075
  ],
790
- }
1076
+ },
791
1077
  );
792
1078
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
793
1079
  });
@@ -804,7 +1090,7 @@ This one's zip code is 92064.`;
804
1090
  ['number', 30],
805
1091
  ['pickles', 100],
806
1092
  ],
807
- }
1093
+ },
808
1094
  );
809
1095
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
810
1096
 
@@ -817,7 +1103,7 @@ This one's zip code is 92064.`;
817
1103
  ['number', 31],
818
1104
  ['pickles', 100],
819
1105
  ],
820
- }
1106
+ },
821
1107
  );
822
1108
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
823
1109
 
@@ -830,7 +1116,7 @@ This one's zip code is 92064.`;
830
1116
  ['number', 29],
831
1117
  ['pickles', 100],
832
1118
  ],
833
- }
1119
+ },
834
1120
  );
835
1121
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
836
1122
 
@@ -843,7 +1129,7 @@ This one's zip code is 92064.`;
843
1129
  ['numberString', 30],
844
1130
  ['pickles', 100],
845
1131
  ],
846
- }
1132
+ },
847
1133
  );
848
1134
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
849
1135
 
@@ -856,7 +1142,7 @@ This one's zip code is 92064.`;
856
1142
  ['numberString', 31],
857
1143
  ['pickles', 100],
858
1144
  ],
859
- }
1145
+ },
860
1146
  );
861
1147
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
862
1148
 
@@ -869,7 +1155,7 @@ This one's zip code is 92064.`;
869
1155
  ['numberString', 29],
870
1156
  ['pickles', 100],
871
1157
  ],
872
- }
1158
+ },
873
1159
  );
874
1160
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
875
1161
  });
@@ -886,7 +1172,7 @@ This one's zip code is 92064.`;
886
1172
  ['number', 30],
887
1173
  ['pickles', 100],
888
1174
  ],
889
- }
1175
+ },
890
1176
  );
891
1177
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
892
1178
 
@@ -899,7 +1185,7 @@ This one's zip code is 92064.`;
899
1185
  ['number', 31],
900
1186
  ['pickles', 100],
901
1187
  ],
902
- }
1188
+ },
903
1189
  );
904
1190
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
905
1191
 
@@ -912,7 +1198,7 @@ This one's zip code is 92064.`;
912
1198
  ['number', 29],
913
1199
  ['pickles', 100],
914
1200
  ],
915
- }
1201
+ },
916
1202
  );
917
1203
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
918
1204
 
@@ -925,7 +1211,7 @@ This one's zip code is 92064.`;
925
1211
  ['numberString', 30],
926
1212
  ['pickles', 100],
927
1213
  ],
928
- }
1214
+ },
929
1215
  );
930
1216
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
931
1217
 
@@ -938,7 +1224,7 @@ This one's zip code is 92064.`;
938
1224
  ['numberString', 31],
939
1225
  ['pickles', 100],
940
1226
  ],
941
- }
1227
+ },
942
1228
  );
943
1229
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
944
1230
 
@@ -951,7 +1237,7 @@ This one's zip code is 92064.`;
951
1237
  ['numberString', 29],
952
1238
  ['pickles', 100],
953
1239
  ],
954
- }
1240
+ },
955
1241
  );
956
1242
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
957
1243
  });
@@ -968,7 +1254,7 @@ This one's zip code is 92064.`;
968
1254
  ['number', 30],
969
1255
  ['pickles', 100],
970
1256
  ],
971
- }
1257
+ },
972
1258
  );
973
1259
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
974
1260
 
@@ -981,7 +1267,7 @@ This one's zip code is 92064.`;
981
1267
  ['number', 31],
982
1268
  ['pickles', 100],
983
1269
  ],
984
- }
1270
+ },
985
1271
  );
986
1272
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
987
1273
 
@@ -994,7 +1280,7 @@ This one's zip code is 92064.`;
994
1280
  ['number', 29],
995
1281
  ['pickles', 100],
996
1282
  ],
997
- }
1283
+ },
998
1284
  );
999
1285
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1000
1286
 
@@ -1007,7 +1293,7 @@ This one's zip code is 92064.`;
1007
1293
  ['numberString', 30],
1008
1294
  ['pickles', 100],
1009
1295
  ],
1010
- }
1296
+ },
1011
1297
  );
1012
1298
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1013
1299
 
@@ -1020,7 +1306,7 @@ This one's zip code is 92064.`;
1020
1306
  ['numberString', 31],
1021
1307
  ['pickles', 100],
1022
1308
  ],
1023
- }
1309
+ },
1024
1310
  );
1025
1311
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1026
1312
 
@@ -1033,7 +1319,7 @@ This one's zip code is 92064.`;
1033
1319
  ['numberString', 29],
1034
1320
  ['pickles', 100],
1035
1321
  ],
1036
- }
1322
+ },
1037
1323
  );
1038
1324
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1039
1325
  });
@@ -1045,7 +1331,7 @@ This one's zip code is 92064.`;
1045
1331
  const resultEntity = await nymph.getEntities(
1046
1332
  { class: TestModel },
1047
1333
  { type: '&', tag: 'test' },
1048
- { type: '!&', gte: ['number', 60] }
1334
+ { type: '!&', gte: ['number', 60] },
1049
1335
  );
1050
1336
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1051
1337
  });
@@ -1056,7 +1342,7 @@ This one's zip code is 92064.`;
1056
1342
  // Testing wrong inequality...
1057
1343
  const resultEntity = await nymph.getEntities(
1058
1344
  { class: TestModel },
1059
- { type: '&', lte: ['number', 29.99] }
1345
+ { type: '&', lte: ['number', 29.99] },
1060
1346
  );
1061
1347
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1062
1348
  });
@@ -1067,7 +1353,7 @@ This one's zip code is 92064.`;
1067
1353
  // Retrieving entity by time...
1068
1354
  const resultEntity = await nymph.getEntities(
1069
1355
  { class: TestModel },
1070
- { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] }
1356
+ { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] },
1071
1357
  );
1072
1358
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1073
1359
  });
@@ -1078,7 +1364,7 @@ This one's zip code is 92064.`;
1078
1364
  // Testing wrong time...
1079
1365
  const resultEntity = await nymph.getEntities(
1080
1366
  { class: TestModel },
1081
- { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] }
1367
+ { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] },
1082
1368
  );
1083
1369
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1084
1370
  });
@@ -1091,7 +1377,7 @@ This one's zip code is 92064.`;
1091
1377
  // Retrieving entity by relative time...
1092
1378
  let resultEntity = await nymph.getEntities(
1093
1379
  { class: TestModel },
1094
- { type: '&', gt: ['timestamp', null, '-1 day'] }
1380
+ { type: '&', gt: ['timestamp', null, '-1 day'] },
1095
1381
  );
1096
1382
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1097
1383
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1105,7 +1391,7 @@ This one's zip code is 92064.`;
1105
1391
  ['timestamp', null, '-1 day'],
1106
1392
  ['timestamp', null, '+5 days'],
1107
1393
  ],
1108
- }
1394
+ },
1109
1395
  );
1110
1396
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1111
1397
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1113,7 +1399,7 @@ This one's zip code is 92064.`;
1113
1399
  // Retrieving entity by relative time...
1114
1400
  resultEntity = await nymph.getEntities(
1115
1401
  { class: TestModel },
1116
- { type: '&', gt: ['timestamp', null, '-3 days'] }
1402
+ { type: '&', gt: ['timestamp', null, '-3 days'] },
1117
1403
  );
1118
1404
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1119
1405
  expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
@@ -1121,7 +1407,7 @@ This one's zip code is 92064.`;
1121
1407
  // Retrieving entity by relative time...
1122
1408
  resultEntity = await nymph.getEntities(
1123
1409
  { class: TestModel },
1124
- { type: '&', gt: ['cdate', null, '-1 day'] }
1410
+ { type: '&', gt: ['cdate', null, '-1 day'] },
1125
1411
  );
1126
1412
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1127
1413
  expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
@@ -1135,7 +1421,7 @@ This one's zip code is 92064.`;
1135
1421
  // Retrieving entity by relative time...
1136
1422
  let resultEntity = await nymph.getEntities(
1137
1423
  { class: TestModel },
1138
- { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] }
1424
+ { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] },
1139
1425
  );
1140
1426
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1141
1427
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1143,7 +1429,7 @@ This one's zip code is 92064.`;
1143
1429
  // Retrieving entity by relative time...
1144
1430
  resultEntity = await nymph.getEntities(
1145
1431
  { class: TestModel },
1146
- { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] }
1432
+ { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] },
1147
1433
  );
1148
1434
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1149
1435
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1151,7 +1437,7 @@ This one's zip code is 92064.`;
1151
1437
  // Retrieving entity by relative time...
1152
1438
  resultEntity = await nymph.getEntities(
1153
1439
  { class: TestModel },
1154
- { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] }
1440
+ { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] },
1155
1441
  );
1156
1442
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1157
1443
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1161,9 +1447,11 @@ This one's zip code is 92064.`;
1161
1447
  await createTestEntities();
1162
1448
 
1163
1449
  // Testing referenced entities...
1450
+ await testEntity.reference?.$wake();
1164
1451
  expect(testEntity.reference?.test).toEqual('good');
1165
1452
 
1166
1453
  // Testing referenced entity arrays...
1454
+ await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
1167
1455
  expect(testEntity.refArray?.[0].test).toEqual('good');
1168
1456
  });
1169
1457
 
@@ -1173,7 +1461,7 @@ This one's zip code is 92064.`;
1173
1461
  // Retrieving entity by reference...
1174
1462
  const resultEntity = await nymph.getEntities(
1175
1463
  { class: TestModel },
1176
- { type: '&', ref: ['reference', refGuid] }
1464
+ { type: '&', ref: ['reference', refGuid] },
1177
1465
  );
1178
1466
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1179
1467
  });
@@ -1185,7 +1473,7 @@ This one's zip code is 92064.`;
1185
1473
  const resultEntity = await nymph.getEntities(
1186
1474
  { class: TestModel },
1187
1475
  { type: '&', tag: 'test' },
1188
- { type: '!&', ref: ['reference', guid()] }
1476
+ { type: '!&', ref: ['reference', guid()] },
1189
1477
  );
1190
1478
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1191
1479
  });
@@ -1196,7 +1484,7 @@ This one's zip code is 92064.`;
1196
1484
  // Testing wrong reference...
1197
1485
  const resultEntity = await nymph.getEntities(
1198
1486
  { class: TestModel },
1199
- { type: '&', ref: ['reference', guid()] }
1487
+ { type: '&', ref: ['reference', guid()] },
1200
1488
  );
1201
1489
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1202
1490
  });
@@ -1207,7 +1495,7 @@ This one's zip code is 92064.`;
1207
1495
  // Testing non-existent reference...
1208
1496
  const resultEntity = await nymph.getEntities(
1209
1497
  { class: TestModel },
1210
- { type: '&', ref: ['pickle', refGuid] }
1498
+ { type: '&', ref: ['pickle', refGuid] },
1211
1499
  );
1212
1500
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1213
1501
  });
@@ -1224,7 +1512,7 @@ This one's zip code is 92064.`;
1224
1512
  ['reference', refGuid],
1225
1513
  ['reference', guid()],
1226
1514
  ],
1227
- }
1515
+ },
1228
1516
  );
1229
1517
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1230
1518
  });
@@ -1241,7 +1529,7 @@ This one's zip code is 92064.`;
1241
1529
  ['reference', guid()],
1242
1530
  ['reference', guid()],
1243
1531
  ],
1244
- }
1532
+ },
1245
1533
  );
1246
1534
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1247
1535
  });
@@ -1252,7 +1540,7 @@ This one's zip code is 92064.`;
1252
1540
  // Retrieving entity by array reference...
1253
1541
  const resultEntity = await nymph.getEntities(
1254
1542
  { class: TestModel },
1255
- { type: '&', ref: ['refArray', refGuid] }
1543
+ { type: '&', ref: ['refArray', refGuid] },
1256
1544
  );
1257
1545
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1258
1546
  });
@@ -1269,7 +1557,7 @@ This one's zip code is 92064.`;
1269
1557
  ['refArray', refGuid],
1270
1558
  ['refArray', guid()],
1271
1559
  ],
1272
- }
1560
+ },
1273
1561
  );
1274
1562
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1275
1563
  });
@@ -1303,6 +1591,8 @@ This one's zip code is 92064.`;
1303
1591
  ['array', 'of'],
1304
1592
  ['array', 'values'],
1305
1593
  ['array', 500],
1594
+ ['array', { test: true }],
1595
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1306
1596
  ],
1307
1597
  },
1308
1598
  {
@@ -1314,7 +1604,7 @@ This one's zip code is 92064.`;
1314
1604
  ['array', 'values'],
1315
1605
  ['array', 500],
1316
1606
  ],
1317
- }
1607
+ },
1318
1608
  );
1319
1609
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1320
1610
  });
@@ -1334,13 +1624,13 @@ This one's zip code is 92064.`;
1334
1624
 
1335
1625
  const resultSelectors = await nymph.getEntities(
1336
1626
  { class: TestModel },
1337
- { type: '&', ref: ['reference', refGuid] }
1627
+ { type: '&', ref: ['reference', refGuid] },
1338
1628
  );
1339
1629
 
1340
1630
  // Testing count return with selectors...
1341
1631
  const resultSelectorsCount = await nymph.getEntities(
1342
1632
  { class: TestModel, return: 'count' },
1343
- { type: '&', ref: ['reference', refGuid] }
1633
+ { type: '&', ref: ['reference', refGuid] },
1344
1634
  );
1345
1635
  expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
1346
1636
  expect(resultSelectorsCount).toEqual(resultSelectors.length);
@@ -1363,7 +1653,7 @@ This one's zip code is 92064.`;
1363
1653
  // Testing empty count...
1364
1654
  const resultSelectorsEmpty = await nymph.getEntities(
1365
1655
  { class: TestModel, return: 'count' },
1366
- { type: '&', ref: ['reference', guid()] }
1656
+ { type: '&', ref: ['reference', guid()] },
1367
1657
  );
1368
1658
  expect(resultSelectorsEmpty).toEqual(0);
1369
1659
  });
@@ -1397,6 +1687,8 @@ This one's zip code is 92064.`;
1397
1687
  ['array', 'of'],
1398
1688
  ['array', 'values'],
1399
1689
  ['array', 500],
1690
+ ['array', { test: true }],
1691
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1400
1692
  ],
1401
1693
  },
1402
1694
  {
@@ -1408,11 +1700,66 @@ This one's zip code is 92064.`;
1408
1700
  ['array', 'values'],
1409
1701
  ['array', 500],
1410
1702
  ],
1411
- }
1703
+ },
1412
1704
  );
1413
1705
  expect(resultGuid.indexOf(testEntity.guid ?? '')).toBeGreaterThan(-1);
1414
1706
  });
1415
1707
 
1708
+ it('object return', async () => {
1709
+ await createTestEntities();
1710
+
1711
+ // Testing object return using logic operations...
1712
+ const resultObjects = await nymph.getEntities(
1713
+ { class: TestModel, return: 'object' },
1714
+ {
1715
+ type: '&',
1716
+ '!ref': [
1717
+ ['refArray', guid()],
1718
+ ['refArray', guid()],
1719
+ ],
1720
+ '!lte': ['number', 29.99],
1721
+ },
1722
+ {
1723
+ type: '|',
1724
+ '!lte': [
1725
+ ['number', 29.99],
1726
+ ['number', 30],
1727
+ ],
1728
+ },
1729
+ {
1730
+ type: '!&',
1731
+ '!equal': ['string', 'test'],
1732
+ '!contain': [
1733
+ ['array', 'full'],
1734
+ ['array', 'of'],
1735
+ ['array', 'values'],
1736
+ ['array', 500],
1737
+ ['array', { test: true }],
1738
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1739
+ ],
1740
+ },
1741
+ {
1742
+ type: '!|',
1743
+ '!equal': ['string', 'test'],
1744
+ contain: [
1745
+ ['array', 'full'],
1746
+ ['array', 'of'],
1747
+ ['array', 'values'],
1748
+ ['array', 500],
1749
+ ],
1750
+ },
1751
+ );
1752
+
1753
+ const resultObject = resultObjects.find(
1754
+ (entity) => entity.guid === testEntity.guid,
1755
+ );
1756
+
1757
+ expect(resultObject).toBeInstanceOf(Object);
1758
+ expect(resultObject).not.toBeInstanceOf(TestModel);
1759
+ expect(Array.isArray(resultObject?.tags)).toBeTruthy();
1760
+ expect(resultObject?.string).toEqual('test');
1761
+ });
1762
+
1416
1763
  it('deep selector', async () => {
1417
1764
  await createTestEntities();
1418
1765
 
@@ -1445,6 +1792,8 @@ This one's zip code is 92064.`;
1445
1792
  ['array', 'of'],
1446
1793
  ['array', 'values'],
1447
1794
  ['array', 500],
1795
+ ['array', { test: true }],
1796
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1448
1797
  ],
1449
1798
  },
1450
1799
  {
@@ -1458,7 +1807,7 @@ This one's zip code is 92064.`;
1458
1807
  ],
1459
1808
  },
1460
1809
  ],
1461
- }
1810
+ },
1462
1811
  );
1463
1812
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1464
1813
 
@@ -1490,6 +1839,8 @@ This one's zip code is 92064.`;
1490
1839
  ['array', 'of'],
1491
1840
  ['array', 'values'],
1492
1841
  ['array', 500],
1842
+ ['array', { test: true }],
1843
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1493
1844
  ],
1494
1845
  },
1495
1846
  {
@@ -1503,7 +1854,7 @@ This one's zip code is 92064.`;
1503
1854
  ],
1504
1855
  },
1505
1856
  ],
1506
- }
1857
+ },
1507
1858
  );
1508
1859
  expect(testEntity.$inArray(resultEntity2)).toEqual(true);
1509
1860
 
@@ -1519,7 +1870,7 @@ This one's zip code is 92064.`;
1519
1870
  },
1520
1871
  { type: '&', gte: ['number', 16000] },
1521
1872
  ],
1522
- }
1873
+ },
1523
1874
  );
1524
1875
  expect(testEntity.$inArray(resultEntity3)).toEqual(true);
1525
1876
 
@@ -1541,7 +1892,7 @@ This one's zip code is 92064.`;
1541
1892
  },
1542
1893
  },
1543
1894
  ],
1544
- }
1895
+ },
1545
1896
  );
1546
1897
  expect(testEntity.$inArray(resultEntity4)).toEqual(true);
1547
1898
  });
@@ -1560,7 +1911,7 @@ This one's zip code is 92064.`;
1560
1911
  },
1561
1912
  { type: '&', gte: ['number', 16000] },
1562
1913
  ],
1563
- }
1914
+ },
1564
1915
  );
1565
1916
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1566
1917
  });
@@ -1577,7 +1928,7 @@ This one's zip code is 92064.`;
1577
1928
  'reference',
1578
1929
  [{ class: TestModel }, { type: '&', equal: ['test', 'good'] }],
1579
1930
  ],
1580
- }
1931
+ },
1581
1932
  );
1582
1933
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1583
1934
  });
@@ -1594,7 +1945,7 @@ This one's zip code is 92064.`;
1594
1945
  'reference',
1595
1946
  [{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
1596
1947
  ],
1597
- }
1948
+ },
1598
1949
  );
1599
1950
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1600
1951
  });
@@ -1611,7 +1962,7 @@ This one's zip code is 92064.`;
1611
1962
  'reference',
1612
1963
  [{ class: TestBModel }, { type: '&', equal: ['test', 'good'] }],
1613
1964
  ],
1614
- }
1965
+ },
1615
1966
  );
1616
1967
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1617
1968
  });
@@ -1628,31 +1979,28 @@ This one's zip code is 92064.`;
1628
1979
  'reference',
1629
1980
  [{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
1630
1981
  ],
1631
- }
1982
+ },
1632
1983
  );
1633
1984
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1634
1985
  });
1635
1986
 
1636
- it('sort option', async () => {
1987
+ it('cdate and mdate sort option', async () => {
1637
1988
  await createMultipleTestEntities();
1638
1989
 
1639
- for (const sort of ['cdate', 'mdate']) {
1990
+ for (const sort of ['cdate', 'mdate'] as ('cdate' | 'mdate')[]) {
1640
1991
  // Retrieving entities sorted...
1641
- let resultEntities = await nymph.getEntities({
1642
- class: TestModel,
1643
- sort: sort as 'cdate' | 'mdate',
1644
- });
1992
+ let resultEntities = await nymph.getEntities({ class: TestModel, sort });
1645
1993
  expect(resultEntities.length).toBeGreaterThan(100);
1646
1994
  for (let i = 0; i < resultEntities.length - 1; i++) {
1647
- expect(
1648
- resultEntities[i + 1][sort as 'cdate' | 'mdate']
1649
- ).toBeGreaterThan(resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0);
1995
+ expect(resultEntities[i + 1][sort]).toBeGreaterThan(
1996
+ resultEntities[i][sort] ?? 0,
1997
+ );
1650
1998
  }
1651
1999
 
1652
2000
  // And test the same with guid return...
1653
2001
  let resultGuids = await nymph.getEntities({
1654
2002
  class: TestModel,
1655
- sort: sort as 'cdate' | 'mdate',
2003
+ sort,
1656
2004
  return: 'guid',
1657
2005
  });
1658
2006
  expect(resultGuids.length).toBeGreaterThan(100);
@@ -1663,48 +2011,121 @@ This one's zip code is 92064.`;
1663
2011
  // Retrieving entities reverse sorted...
1664
2012
  resultEntities = await nymph.getEntities({
1665
2013
  class: TestModel,
1666
- sort: sort as 'cdate' | 'mdate',
2014
+ sort,
1667
2015
  reverse: true,
1668
2016
  });
1669
2017
  expect(resultEntities.length).toBeGreaterThan(100);
1670
2018
  for (let i = 0; i < resultEntities.length - 1; i++) {
1671
- expect(resultEntities[i + 1][sort as 'cdate' | 'mdate']).toBeLessThan(
1672
- resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0
2019
+ expect(resultEntities[i + 1][sort]).toBeLessThan(
2020
+ resultEntities[i][sort] ?? 0,
1673
2021
  );
1674
2022
  }
1675
2023
 
1676
2024
  // And again with other selectors.
1677
2025
  // Retrieving entities sorted...
1678
2026
  resultEntities = await nymph.getEntities(
1679
- { class: TestModel, sort: sort as 'cdate' | 'mdate' },
1680
- { type: '&', match: ['name', '^Multi Test '] }
2027
+ { class: TestModel, sort },
2028
+ { type: '&', match: ['name', '^Multi Test '] },
1681
2029
  );
1682
2030
  expect(resultEntities.length).toEqual(100);
1683
2031
  for (let i = 0; i < resultEntities.length - 1; i++) {
1684
- expect(
1685
- resultEntities[i + 1][sort as 'cdate' | 'mdate']
1686
- ).toBeGreaterThan(resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0);
2032
+ expect(resultEntities[i + 1][sort]).toBeGreaterThan(
2033
+ resultEntities[i][sort] ?? 0,
2034
+ );
1687
2035
  }
1688
2036
 
1689
2037
  // Retrieving entities reverse sorted...
1690
2038
  resultEntities = await nymph.getEntities(
1691
- { class: TestModel, sort: sort as 'cdate' | 'mdate', reverse: true },
1692
- { type: '&', match: ['name', '^Multi Test '] }
2039
+ { class: TestModel, sort, reverse: true },
2040
+ { type: '&', match: ['name', '^Multi Test '] },
1693
2041
  );
1694
2042
  expect(resultEntities.length).toEqual(100);
1695
2043
  for (let i = 0; i < resultEntities.length - 1; i++) {
1696
- expect(resultEntities[i + 1][sort as 'cdate' | 'mdate']).toBeLessThan(
1697
- resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0
2044
+ expect(resultEntities[i + 1][sort]).toBeLessThan(
2045
+ resultEntities[i][sort] ?? 0,
1698
2046
  );
1699
2047
  }
1700
2048
  }
1701
2049
  });
1702
2050
 
2051
+ it('property sort option', async () => {
2052
+ await createMultipleTestEntities();
2053
+
2054
+ // Retrieving entities sorted...
2055
+ let resultEntities = await nymph.getEntities({
2056
+ class: TestModel,
2057
+ sort: 'number',
2058
+ });
2059
+ expect(resultEntities.length).toBeGreaterThan(100);
2060
+ for (let i = 0; i < resultEntities.length - 1; i++) {
2061
+ expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThanOrEqual(
2062
+ resultEntities[i].number ?? 0,
2063
+ );
2064
+ }
2065
+
2066
+ // And test the same with guid return...
2067
+ let resultGuids = await nymph.getEntities({
2068
+ class: TestModel,
2069
+ sort: 'number',
2070
+ return: 'guid',
2071
+ });
2072
+ expect(resultGuids.length).toBeGreaterThan(100);
2073
+ for (let i = 0; i < resultGuids.length - 1; i++) {
2074
+ expect(resultGuids[i]).toEqual(resultEntities[i].guid);
2075
+ }
2076
+
2077
+ // Retrieving entities reverse sorted...
2078
+ resultEntities = await nymph.getEntities({
2079
+ class: TestModel,
2080
+ sort: 'number',
2081
+ reverse: true,
2082
+ });
2083
+ expect(resultEntities.length).toBeGreaterThan(100);
2084
+ for (let i = 0; i < resultEntities.length - 1; i++) {
2085
+ expect(resultEntities[i + 1].number ?? 0).toBeLessThanOrEqual(
2086
+ resultEntities[i].number ?? Infinity,
2087
+ );
2088
+ }
2089
+
2090
+ // And again with other selectors.
2091
+ // Retrieving entities sorted...
2092
+ resultEntities = await nymph.getEntities(
2093
+ { class: TestModel, sort: 'number' },
2094
+ { type: '&', match: ['name', '^Multi Test '] },
2095
+ );
2096
+ expect(resultEntities.length).toEqual(100);
2097
+ for (let i = 0; i < resultEntities.length - 1; i++) {
2098
+ expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThan(
2099
+ resultEntities[i].number ?? 0,
2100
+ );
2101
+ expect(resultEntities[i].name).toEqual(
2102
+ `Multi Test ${100 - (resultEntities[i].number ?? 0)}`,
2103
+ );
2104
+ }
2105
+
2106
+ // Retrieving entities reverse sorted...
2107
+ resultEntities = await nymph.getEntities(
2108
+ { class: TestModel, sort: 'number', reverse: true },
2109
+ { type: '&', match: ['name', '^Multi Test '] },
2110
+ );
2111
+ expect(resultEntities.length).toEqual(100);
2112
+ for (let i = 0; i < resultEntities.length - 1; i++) {
2113
+ expect(resultEntities[i + 1].number ?? 0).toBeLessThan(
2114
+ resultEntities[i].number ?? Infinity,
2115
+ );
2116
+ expect(resultEntities[i].name).toEqual(
2117
+ `Multi Test ${100 - (resultEntities[i].number ?? 0)}`,
2118
+ );
2119
+ }
2120
+ });
2121
+
1703
2122
  it('delete reference', async () => {
1704
2123
  await createTestEntities();
1705
2124
 
1706
2125
  // Deleting referenced entities...
2126
+ await testEntity.reference?.$wake();
1707
2127
  expect(await testEntity.reference?.$delete()).toEqual(true);
2128
+ await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
1708
2129
  expect(testEntity.reference?.guid).toBeNull();
1709
2130
  });
1710
2131
 
@@ -1717,20 +2138,117 @@ This one's zip code is 92064.`;
1717
2138
 
1718
2139
  const entity = await nymph.getEntity(
1719
2140
  { class: TestModel },
1720
- { type: '&', guid: testGuid }
2141
+ { type: '&', guid: testGuid },
1721
2142
  );
1722
2143
 
1723
2144
  expect(entity).toBeNull();
1724
2145
  });
2146
+
2147
+ it('allows non-duplicate unique strings', async () => {
2148
+ // Creating entity...
2149
+ const uniqueEntityA = await TestModel.factory();
2150
+ uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
2151
+ uniqueEntityA.uniques = ['test a'];
2152
+
2153
+ // Saving entity...
2154
+ expect(await uniqueEntityA.$save()).toEqual(true);
2155
+ expect(uniqueEntityA.guid).not.toBeNull();
2156
+
2157
+ // Creating entity...
2158
+ const uniqueEntityB = await TestModel.factory();
2159
+ uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
2160
+ uniqueEntityB.uniques = ['test b'];
2161
+
2162
+ // Saving entity...
2163
+ expect(await uniqueEntityB.$save()).toEqual(true);
2164
+ expect(uniqueEntityB.guid).not.toBeNull();
2165
+
2166
+ expect(uniqueEntityA.guid).not.toEqual(uniqueEntityB.guid);
2167
+
2168
+ expect(await uniqueEntityA.$delete()).toEqual(true);
2169
+ expect(await uniqueEntityB.$delete()).toEqual(true);
2170
+ });
2171
+
2172
+ it('throws on duplicate unique strings', async () => {
2173
+ // Creating entity...
2174
+ const uniqueEntityA = await TestModel.factory();
2175
+ uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
2176
+ uniqueEntityA.uniques = ['test a'];
2177
+
2178
+ // Saving entity...
2179
+ expect(await uniqueEntityA.$save()).toEqual(true);
2180
+ expect(uniqueEntityA.guid).not.toBeNull();
2181
+
2182
+ // Creating entity...
2183
+ const uniqueEntityB = await TestModel.factory();
2184
+ uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
2185
+ uniqueEntityB.uniques = ['test a'];
2186
+
2187
+ // Saving entity...
2188
+ try {
2189
+ await uniqueEntityB.$save();
2190
+
2191
+ throw Error("Shouldn't get past the uniqueness check.");
2192
+ } catch (e: any) {
2193
+ expect(e).toBeInstanceOf(EntityUniqueConstraintError);
2194
+ }
2195
+ expect(uniqueEntityB.guid).toBeNull();
2196
+
2197
+ expect(await uniqueEntityA.$delete()).toEqual(true);
2198
+ });
2199
+
2200
+ it('allows duplicate unique string if first transaction is rolled back', async () => {
2201
+ // Creating transaction entity...
2202
+ const tnymphA = await nymph.startTransaction('test-unique-a');
2203
+ const TestModelA = tnymphA.getEntityClass(TestModel);
2204
+ const uniqueEntityA = await TestModelA.factory();
2205
+ uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
2206
+ uniqueEntityA.uniques = ['test a'];
2207
+
2208
+ // Saving entity...
2209
+ expect(await uniqueEntityA.$save()).toEqual(true);
2210
+ expect(uniqueEntityA.guid).not.toBeNull();
2211
+
2212
+ // Rolling back transaction...
2213
+ expect(await tnymphA.rollback('test-unique-a')).toEqual(true);
2214
+
2215
+ // Creating transaction entity...
2216
+ const tnymphB = await nymph.startTransaction('test-unique-b');
2217
+ const TestModelB = tnymphB.getEntityClass(TestModel);
2218
+ const uniqueEntityB = await TestModelB.factory();
2219
+ uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
2220
+ uniqueEntityB.uniques = ['test a'];
2221
+
2222
+ // Saving entity...
2223
+ expect(await uniqueEntityB.$save()).toEqual(true);
2224
+ expect(uniqueEntityB.guid).not.toBeNull();
2225
+
2226
+ expect(uniqueEntityA.guid).not.toEqual(uniqueEntityB.guid);
2227
+
2228
+ expect(await tnymphB.commit('test-unique-b')).toEqual(true);
2229
+
2230
+ const uniqueEntityACheck = await nymph.getEntity(
2231
+ { class: TestModel },
2232
+ { type: '&', guid: uniqueEntityA.guid ?? '' },
2233
+ );
2234
+ expect(uniqueEntityACheck).toBeNull();
2235
+
2236
+ const uniqueEntityBCheck = await nymph.getEntity(
2237
+ { class: TestModel },
2238
+ { type: '&', guid: uniqueEntityB.guid ?? '' },
2239
+ );
2240
+ expect(uniqueEntityBCheck).not.toBeNull();
2241
+
2242
+ if (uniqueEntityBCheck != null) {
2243
+ expect(await uniqueEntityBCheck.$delete()).toEqual(true);
2244
+ }
2245
+ });
1725
2246
  }
1726
2247
 
1727
2248
  export function UIDTest(
1728
2249
  nymph: Nymph,
1729
- it: (name: string, fn: () => void) => void
2250
+ it: (name: string, fn: () => void) => void,
1730
2251
  ) {
1731
- nymph.addEntityClass(TestModel);
1732
- nymph.addEntityClass(TestBModel);
1733
-
1734
2252
  it('delete old test data', async () => {
1735
2253
  expect(await nymph.deleteUID('TestUID')).toEqual(true);
1736
2254
  expect(await nymph.deleteUID('NewUID')).toEqual(true);
@@ -1770,10 +2288,10 @@ export function UIDTest(
1770
2288
 
1771
2289
  export function ExportImportTest(
1772
2290
  nymph: Nymph,
1773
- it: (name: string, fn: () => void) => void
2291
+ it: (name: string, fn: () => void) => void,
1774
2292
  ) {
1775
- nymph.addEntityClass(TestModel);
1776
- nymph.addEntityClass(TestBModel);
2293
+ const TestModel = nymph.addEntityClass(TestModelClass);
2294
+ const TestBModel = nymph.addEntityClass(TestBModelClass);
1777
2295
 
1778
2296
  async function deleteTestData() {
1779
2297
  let all = await nymph.getEntities({ class: TestModel });
@@ -1806,23 +2324,38 @@ export function ExportImportTest(
1806
2324
  const bmodels = await nymph.getEntities({ class: TestBModel });
1807
2325
 
1808
2326
  expect(models.length).toEqual(30);
1809
- expect(bmodels.length).toEqual(10);
1810
-
1811
- const all = [...models, ...bmodels];
1812
- for (const model of all) {
1813
- if (model.index?.match(/^\d+a$/)) {
1814
- expect(model.null).toBeNull();
1815
- expect(model.string).toEqual('test');
1816
- expect(model.array).toEqual(['full', 'of', 'values', 500]);
1817
- expect(model.number).toEqual(30);
1818
- expect(model.timestamp).toBeGreaterThanOrEqual(strtotime('-2 minutes'));
1819
-
1820
- expect(model.reference?.guid).not.toBeNull();
1821
- expect(model.reference?.string).toEqual('another');
1822
- expect(model.reference?.index?.match(/^\d+b$/)).toBeTruthy();
1823
- expect(model.refArray?.[0].guid).not.toBeNull();
1824
- expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
1825
- }
2327
+ expect(bmodels.length).toEqual(30);
2328
+
2329
+ for (const model of models) {
2330
+ expect(model.name).toMatch(/^Entity Test /);
2331
+ expect(model.null).toBeDefined();
2332
+ expect(model.null).toBeNull();
2333
+ expect(model.string).toEqual('test');
2334
+ expect(model.array).toEqual([
2335
+ 'full',
2336
+ 'of',
2337
+ 'values',
2338
+ 500,
2339
+ { test: true },
2340
+ { nullbyte: '\\\x00\u0000 \x00' },
2341
+ ]);
2342
+ expect(model.match).toEqual(matchValue);
2343
+ expect(model.number).toEqual(30);
2344
+ expect(model.numberString).toEqual('30');
2345
+ expect(model.timestamp).toBeGreaterThanOrEqual(strtotime('-2 minutes'));
2346
+ expect(model.index).toMatch(/^\d+a$/);
2347
+
2348
+ await model.reference?.$wake();
2349
+ expect(model.reference?.guid).not.toBeNull();
2350
+ expect(model.reference?.string).toEqual('another');
2351
+ expect(model.reference?.index).toMatch(/^\d+b$/);
2352
+ expect(model.index?.substring(0, -1)).toEqual(
2353
+ model.reference?.index?.substring(0, -1),
2354
+ );
2355
+ expect(model.reference?.$inArray(bmodels)).toEqual(true);
2356
+ await Promise.all(model.refArray?.map((e) => e.$wake()) || []);
2357
+ expect(model.refArray?.[0].guid).not.toBeNull();
2358
+ expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
1826
2359
  }
1827
2360
  }
1828
2361
 
@@ -1835,22 +2368,29 @@ export function ExportImportTest(
1835
2368
  expect(await nymph.newUID('TestUID')).toEqual(2);
1836
2369
  expect(await nymph.newUID('TestUID2')).toEqual(1);
1837
2370
 
1838
- for (let i = 0; i < 20; i++) {
1839
- const EntityClass = i < 15 ? TestModel : TestBModel;
1840
-
2371
+ for (let i = 0; i < 30; i++) {
1841
2372
  // Creating entity...
1842
- const testEntity = await EntityClass.factory();
2373
+ const testEntity = await TestModel.factory();
1843
2374
 
1844
2375
  // Saving entity...
1845
2376
  testEntity.name = 'Entity Test ' + new Date().toLocaleString();
1846
2377
  testEntity.null = null;
1847
2378
  testEntity.string = 'test';
1848
- testEntity.array = ['full', 'of', 'values', 500];
2379
+ testEntity.array = [
2380
+ 'full',
2381
+ 'of',
2382
+ 'values',
2383
+ 500,
2384
+ { test: true },
2385
+ { nullbyte: '\\\x00\u0000 \x00' },
2386
+ ];
2387
+ testEntity.match = matchValue;
1849
2388
  testEntity.number = 30;
2389
+ testEntity.numberString = '30';
1850
2390
  testEntity.timestamp = Date.now();
1851
2391
  testEntity.index = i + 'a';
1852
2392
 
1853
- const entityReferenceTest = await EntityClass.factory();
2393
+ const entityReferenceTest = await TestBModel.factory();
1854
2394
  entityReferenceTest.string = 'another';
1855
2395
  entityReferenceTest.index = i + 'b';
1856
2396
 
@@ -1864,9 +2404,13 @@ export function ExportImportTest(
1864
2404
  await checkEntityDataAndCount();
1865
2405
  });
1866
2406
 
2407
+ it('needs migration', async () => {
2408
+ expect(await nymph.needsMigration()).toEqual(false);
2409
+ });
2410
+
1867
2411
  it('export data', async () => {
1868
2412
  expect(await nymph.export(__dirname + '/testentityexport.nex')).toEqual(
1869
- true
2413
+ true,
1870
2414
  );
1871
2415
  });
1872
2416
 
@@ -1883,11 +2427,237 @@ export function ExportImportTest(
1883
2427
  expect(bmodels.length).toEqual(0);
1884
2428
 
1885
2429
  expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(
1886
- true
2430
+ true,
1887
2431
  );
1888
2432
 
1889
2433
  await checkEntityDataAndCount();
1890
2434
 
1891
2435
  fs.unlinkSync(__dirname + '/testentityexport.nex');
1892
2436
  });
2437
+
2438
+ it('import tokens only', async () => {
2439
+ const model = await nymph.getEntity({ class: TestModel });
2440
+
2441
+ expect(model).not.toBeNull();
2442
+
2443
+ if (model != null) {
2444
+ const data = model.$getData(true);
2445
+ // These should not actually be saved in the DB.
2446
+ data.number = 424242424242;
2447
+ // But this should become searchable.
2448
+ data.search = 'peanuts and pickles on a hot bun';
2449
+
2450
+ const sdata = Object.fromEntries(
2451
+ Object.entries(data).map(([name, value]) => [
2452
+ name,
2453
+ JSON.stringify(value),
2454
+ ]),
2455
+ );
2456
+
2457
+ if (model.guid == null || model.cdate == null || model.mdate == null) {
2458
+ throw new Error('Model data is wrong.');
2459
+ }
2460
+
2461
+ await nymph.importEntityTokens({
2462
+ guid: model.guid,
2463
+ // Again, these should not actually be changed in the DB.
2464
+ cdate: model.cdate + 1000,
2465
+ mdate: model.mdate + 1000,
2466
+ tags: [...model.tags, 'helicopter'],
2467
+ sdata,
2468
+ etype: TestModel.ETYPE,
2469
+ });
2470
+
2471
+ const modelCheck = await nymph.getEntity(
2472
+ { class: TestModel },
2473
+ { type: '&', search: ['search', '"peanuts and pickles on a hot bun"'] },
2474
+ );
2475
+
2476
+ expect(modelCheck?.guid).toEqual(model.guid);
2477
+ expect(modelCheck?.cdate).toEqual(model.cdate);
2478
+ expect(modelCheck?.mdate).toEqual(model.mdate);
2479
+ expect(modelCheck?.$hasTag('helicopter')).toEqual(false);
2480
+ expect(modelCheck?.number).not.toEqual(424242424242);
2481
+ expect(modelCheck?.search).not.toEqual(
2482
+ 'peanuts and pickles on a hot bun',
2483
+ );
2484
+ }
2485
+ });
1893
2486
  }
2487
+
2488
+ const matchValue = `Hello, my name is Edward McCheese. It is a pleasure to meet you. As you can see, I have several hats of the most pleasant nature.
2489
+
2490
+ This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
2491
+ This one's phone number is (555) 555-1818.
2492
+ This one's zip code is 92064.
2493
+ This one's favorite emojis are 🔥❤️😊😂⭐🤔
2494
+
2495
+ These hats are absolutely fantastic.
2496
+
2497
+ \x00\x00\x00
2498
+
2499
+ Lorem ipsum odor amet, consectetuer adipiscing elit. Metus ad mattis sit pretium per, dignissim imperdiet luctus. Congue rhoncus turpis etiam aenean ultricies dapibus justo nunc. Netus non primis quis habitasse lacus. Nascetur dapibus sociosqu ridiculus primis; elementum netus consectetur ridiculus litora. Tristique facilisis erat ex class nulla cursus amet. Metus vitae tempor euismod vel; ullamcorper ac quisque vestibulum. Mauris libero pulvinar facilisi eros natoque massa.
2500
+
2501
+ Nunc vel hac nec tristique vivamus. Leo volutpat convallis eget integer tellus cubilia tincidunt malesuada? Consequat elit nisi tristique vehicula cubilia maecenas metus facilisi malesuada. In mattis euismod ad magnis fusce. Nisi congue sociosqu rhoncus lobortis fringilla sollicitudin at platea. Iaculis ut et varius metus eleifend laoreet hac odio libero. Non ridiculus tempus ultricies nullam curabitur.
2502
+
2503
+ Amet pellentesque aliquam placerat; vestibulum blandit platea porttitor pulvinar. Tellus tristique ad morbi in ac placerat luctus. Ante efficitur inceptos commodo lacus sodales sit varius nunc consequat. Senectus non vel est convallis mauris. Venenatis feugiat massa nostra, purus class primis sodales odio. Risus nulla integer feugiat ridiculus porta nascetur. Rutrum tincidunt enim parturient libero nisl ante sagittis nisi. Cubilia massa non vehicula vehicula amet parturient pellentesque. Habitant dapibus fames lectus pretium rhoncus.
2504
+
2505
+ Ridiculus nascetur mauris iaculis hendrerit ridiculus gravida auctor in. Class suscipit augue finibus semper vulputate nec. Tristique mi eu praesent commodo fermentum inceptos penatibus lobortis. Libero enim orci ultricies egestas ut pellentesque. Laoreet massa ad curabitur tellus libero laoreet habitasse enim nascetur. Iaculis euismod a euismod conubia purus. Commodo condimentum ultrices lorem ligula aenean; netus mattis sem non.
2506
+
2507
+ Curabitur duis imperdiet mus integer vel bibendum; fusce malesuada. Dignissim duis himenaeos primis odio, congue pharetra? Egestas mus sit eget proin quis. Neque dapibus dapibus nam sociosqu; maecenas viverra himenaeos. Himenaeos faucibus himenaeos faucibus ex litora eros faucibus cras. Maximus scelerisque nullam nunc congue fringilla. Nisi eu magna erat morbi cras enim amet litora. Nostra primis vitae arcu, accumsan sollicitudin curabitur. Potenti sit vel vehicula metus leo id. Etiam blandit quisque nam orci; neque lacinia rutrum.
2508
+
2509
+ Aliquam mollis varius hendrerit sem eleifend fermentum. Sapien rutrum condimentum inceptos ex feugiat consectetur mollis magna diam. Natoque enim nisi, ex risus finibus lacinia conubia vivamus suscipit. Habitasse interdum lorem ante, bibendum posuere dis. Lacus porttitor sapien proin; consequat velit ipsum venenatis. Vivamus porta mattis morbi nunc torquent neque. Senectus vehicula tincidunt parturient fringilla id amet urna libero pharetra.
2510
+
2511
+ Faucibus netus tincidunt et viverra augue ligula est quis. Ipsum tempus vehicula tortor dis tortor ad. Ex tincidunt torquent eleifend aenean urna commodo. Quam nullam imperdiet volutpat vel condimentum cubilia sociosqu. Etiam tempor sapien mattis, venenatis aptent id risus. Efficitur luctus vel; nam ut commodo sociosqu hendrerit. Quisque placerat gravida rhoncus blandit vitae. Himenaeos id risus est mollis aliquet nam curabitur.
2512
+
2513
+ Habitasse sed est fames quis lobortis leo mattis. Nisl cursus tincidunt cursus felis porttitor. Ante integer turpis non class lobortis suscipit. Condimentum velit vulputate quis sapien, lacus magna adipiscing nec primis. Blandit consequat ipsum nostra dignissim; tincidunt torquent fames. Ac faucibus elit iaculis duis lobortis. Euismod facilisi massa turpis mus neque. Class vulputate quisque elementum suscipit nostra tempus adipiscing. Malesuada himenaeos finibus ad inceptos volutpat scelerisque inceptos.
2514
+
2515
+ Natoque platea at feugiat cras tellus facilisi suspendisse lacinia maximus. Duis vestibulum eget molestie turpis risus dapibus dignissim torquent? Nulla nibh aptent fringilla scelerisque euismod mauris ornare. Orci finibus taciti habitasse fringilla laoreet convallis. Class sed fringilla eget quisque sit auctor. Id cursus mauris praesent maecenas iaculis. Ullamcorper luctus habitant ultrices pharetra etiam mattis morbi fringilla lorem.
2516
+
2517
+ Pharetra porta orci ridiculus inceptos eleifend sem ante quis. Molestie velit penatibus libero per sem litora congue. Porta quis egestas vivamus vitae potenti ornare. Elit molestie nullam vitae quam viverra. Nisl fringilla massa ridiculus donec ridiculus sed magnis. Cursus ad enim consequat ultricies tortor rhoncus pellentesque augue. Netus facilisis tempor elementum interdum at sagittis habitasse. Pretium imperdiet duis diam ullamcorper donec at suscipit. Id per inceptos ac luctus massa imperdiet tempor. Parturient libero suscipit non tempor ligula ullamcorper placerat varius.
2518
+
2519
+ Libero duis suspendisse cubilia rhoncus scelerisque faucibus mattis. Leo fusce urna at per inceptos vel lobortis. Quisque ex duis euismod dictum hac nibh eros. Penatibus eleifend tellus donec elit primis phasellus habitant dictum. Imperdiet consequat facilisi massa, lacus gravida sodales id sapien. Ornare sapien sit convallis suscipit nunc enim. Tempus at vitae class sollicitudin proin. Dolor aenean felis netus consectetur mattis phasellus vestibulum. Orci fringilla sodales montes sed himenaeos ex massa natoque porttitor.
2520
+
2521
+ Mus condimentum dui mollis dolor accumsan ligula pretium? Est phasellus platea iaculis vehicula et eros vel rutrum placerat. Nulla laoreet faucibus; congue netus magna senectus lectus dictum. Sodales aliquam eget himenaeos adipiscing, tempor feugiat. Lorem pellentesque iaculis fames lectus cubilia ornare sagittis rhoncus? Bibendum viverra tellus libero congue dignissim metus tellus aenean ultrices. Sollicitudin cras sollicitudin mattis lacus facilisis fermentum scelerisque porttitor rutrum.
2522
+
2523
+ Sapien aptent fames curae, consectetur dapibus mauris sollicitudin tellus. Laoreet etiam dignissim, suscipit platea libero vitae taciti eu nec. Donec lobortis metus nisi; est enim himenaeos molestie tellus sapien. Sapien tellus rhoncus blandit fusce hendrerit feugiat. Maximus sit hendrerit tincidunt nec imperdiet hendrerit semper suscipit. Quam augue proin netus rutrum et sem. Neque penatibus cubilia nec metus porta. Ornare pulvinar quam auctor, elit curae ad donec dis. Egestas aptent non tortor potenti morbi mauris.
2524
+
2525
+ Montes dui in pharetra primis consequat ante integer. Vulputate libero gravida rutrum tortor suscipit massa! Netus rhoncus platea torquent dapibus consectetur suspendisse etiam sociosqu. Quis placerat mauris et quam nascetur. Dictumst mi rutrum justo vitae ultricies feugiat nulla faucibus morbi. Consectetur nec condimentum euismod sodales nisi purus; finibus elementum facilisi.
2526
+
2527
+ Senectus mus faucibus ut morbi eu maximus. Turpis tincidunt sodales sociosqu lorem amet pulvinar laoreet faucibus. Mus bibendum vulputate hendrerit sollicitudin eu ridiculus posuere augue leo? Cubilia nostra consequat; fusce egestas himenaeos class ornare nec. Est montes tortor vivamus congue inceptos erat mi eget pellentesque. Amet vulputate fringilla aliquet fames tristique. Rutrum malesuada dapibus vehicula risus nunc torquent habitant turpis habitant. Ipsum proin viverra adipiscing cras et augue hendrerit. Efficitur euismod aliquam habitant; sit nisl potenti.
2528
+
2529
+ Conubia dignissim metus phasellus tristique augue, nullam quam finibus. Dignissim vel enim mattis praesent penatibus. Sapien pharetra curae torquent turpis fermentum feugiat facilisis nisi. Lacinia justo ante mauris finibus vitae ante efficitur dis. Urna gravida conubia amet rhoncus felis ut lorem placerat. Quisque fermentum suscipit aenean nisi suscipit ac? Quis ornare faucibus amet conubia justo maximus hendrerit phasellus aenean. Ex vivamus vulputate in mollis mauris praesent vehicula erat neque.
2530
+
2531
+ Orci nullam commodo habitant volutpat per tincidunt mus sit. Nisi cubilia fringilla viverra at orci magnis massa nam orci. Duis iaculis sapien nulla nascetur elit porta fermentum. Amus libero vivamus vel finibus magnis placerat himenaeos. Integer posuere suscipit non vulputate enim. Conubia id lobortis habitasse luctus odio maecenas enim conubia non. Mus egestas massa platea nullam sociosqu, magnis cras. Quam placerat nisi dui gravida ultricies, facilisis eu pharetra vivamus.
2532
+
2533
+ Fusce maecenas dis finibus senectus nascetur tortor. Nec rhoncus pretium vivamus donec vel ligula curabitur. Velit dis laoreet aenean, fusce metus blandit erat. Ligula purus natoque, arcu finibus tincidunt efficitur dolor curabitur. Ac risus et ipsum; consequat integer phasellus diam. Praesent ipsum gravida placerat porta volutpat tincidunt maximus sapien. Phasellus gravida orci enim velit condimentum.
2534
+
2535
+ Dui id laoreet penatibus orci sit a. Iaculis dis porttitor luctus; lacus dignissim quam commodo lorem. Nullam dictum quisque accumsan porttitor tortor fusce aenean. Aliquet quisque ultricies malesuada auctor facilisi tristique. Dolor nulla conubia ultricies odio ad. Nunc consectetur venenatis consequat nisi habitant. Praesent accumsan scelerisque morbi aliquam sociosqu auctor, nostra aenean.
2536
+
2537
+ Mauris amet conubia egestas eu posuere nullam. Est neque dictum in, lacus aliquam ultrices vestibulum. Dapibus dis habitasse cras conubia felis nibh. Egestas nisl iaculis nostra neque enim, ridiculus praesent. Consectetur eleifend eu mus; elit sed pellentesque fringilla. Ullamcorper hendrerit nibh aptent per congue libero ultrices eget. Mollis velit ad tortor lobortis ipsum.
2538
+
2539
+ Tristique neque justo potenti himenaeos; pellentesque nam vehicula. Maximus etiam ut nullam semper; fames curabitur quam ad morbi. Interdum curabitur platea augue porttitor a gravida. Leo imperdiet id aenean sit; habitasse quam tempus pellentesque? Nostra leo aenean amet lectus ultricies ridiculus nascetur ullamcorper. Taciti in iaculis quam nascetur proin varius eget vehicula.
2540
+
2541
+ Mattis hendrerit tempus interdum diam elementum primis augue phasellus sociosqu. Imperdiet pulvinar imperdiet lacinia posuere class magnis. Montes viverra scelerisque laoreet sociosqu proin lacus. Nam id justo praesent curabitur nam accumsan imperdiet commodo. Sociosqu netus sapien proin interdum ac. Dapibus tempor et sodales, natoque consequat torquent.
2542
+
2543
+ Lectus ultricies amet bibendum blandit finibus erat pellentesque. Nam quis ultrices curae; lorem gravida malesuada velit taciti enim. Facilisis fermentum suspendisse leo tristique litora dapibus rhoncus convallis. Netus iaculis eleifend viverra urna, vulputate ac convallis. Faucibus torquent dictum, nisl sed parturient libero. Ornare class habitant per consequat adipiscing rhoncus feugiat.
2544
+
2545
+ Proin molestie nullam eros parturient parturient curabitur aliquet. Rhoncus mus aenean sem aliquet sem finibus neque rutrum commodo. Efficitur litora lobortis nascetur adipiscing curae faucibus? Bibendum leo velit augue; potenti primis malesuada lacus ipsum. Facilisi potenti facilisis nam tempor consequat. Magnis suspendisse primis duis quam; suscipit quis fermentum phasellus. Massa ridiculus habitasse ipsum arcu sit maecenas gravida nisi? Dolor egestas lacinia lacinia libero nam curae suspendisse purus. Tristique inceptos curae netus scelerisque magna hendrerit commodo quis parturient. Eget accumsan erat sociosqu vestibulum platea turpis habitasse.
2546
+
2547
+ Maximus dignissim sed conubia a ipsum nullam condimentum dictumst. Suspendisse congue phasellus congue lacus sollicitudin senectus curae. Consequat sagittis in fringilla suscipit scelerisque suscipit. Rhoncus pharetra sodales malesuada sollicitudin lectus. Est primis pretium finibus felis pharetra nulla sapien lacinia. Nunc lorem aptent tristique quisque etiam posuere non ullamcorper. Potenti mus sed mus; non id eleifend pellentesque magnis.
2548
+
2549
+ Iaculis morbi mattis; ornare tincidunt neque mus egestas consectetur ultrices. Porta dapibus pretium, vulputate dis amet neque. Posuere auctor lacinia maecenas ridiculus ullamcorper tempus egestas cubilia nec. Cursus nulla lacinia mi facilisi, nisl tempor. Tempus elementum laoreet magnis neque morbi felis per. Suspendisse lectus vitae nunc amet himenaeos euismod aliquam. Quisque integer dictum aenean fermentum dictumst torquent.
2550
+
2551
+ Sociosqu per suspendisse augue phasellus velit dapibus parturient. At sit eu finibus posuere tincidunt. Phasellus duis scelerisque scelerisque taciti est venenatis. Arcu habitant augue amet eget maximus torquent. Eget gravida ut quisque ligula vel mus. Erat quis himenaeos; velit eget varius viverra interdum. Neque dapibus malesuada est a gravida libero integer aptent. Semper eleifend per at magnis, laoreet nibh orci vel ligula.
2552
+
2553
+ Odio purus finibus inceptos malesuada duis. Neque magnis est laoreet nibh gravida sagittis ullamcorper sodales. Parturient ultricies mattis lacus risus laoreet praesent. Tincidunt eleifend quis sagittis id nascetur. Nam scelerisque varius feugiat phasellus enim mauris nam. Tortor iaculis et cras; blandit sollicitudin pellentesque justo. Nam lacinia volutpat fusce nibh mollis; himenaeos iaculis. Vulputate dictum mattis sollicitudin accumsan at hendrerit.
2554
+
2555
+ Ipsum augue faucibus senectus porta dapibus metus. Netus sem amet nullam fermentum in dolor bibendum. Lacus quis enim vivamus enim risus elit suspendisse arcu. Penatibus proin pellentesque consequat nibh turpis fusce. Potenti sociosqu nunc tempor amet torquent. Aliquet porttitor adipiscing parturient curabitur hac? Condimentum morbi netus erat class hendrerit aptent. Placerat viverra molestie at eget donec quisque. Varius sem erat dolor, urna nunc ac duis inceptos maximus.
2556
+
2557
+ Nostra adipiscing dapibus eros vivamus accumsan elementum curae dignissim dignissim. Iaculis quisque fusce at conubia est habitant ipsum. Porttitor libero lobortis lobortis habitasse quis quisque nunc euismod aenean. Bibendum nullam volutpat quam vitae felis sit. Mauris bibendum nulla litora nec id, elit lacinia. Orci odio nunc est ante commodo dis quis diam convallis? Mattis a per cras amet egestas ex pellentesque nascetur augue. Egestas per massa per non metus hendrerit feugiat eu?
2558
+
2559
+ Praesent habitasse est elementum mattis potenti. Fermentum interdum enim orci dui faucibus sodales nisi mus. Tortor facilisi nunc potenti; dignissim magna varius! Risus cursus ornare tincidunt a feugiat massa cubilia. Sociosqu quis pharetra efficitur lorem ornare sapien arcu euismod. Elementum donec maecenas praesent scelerisque viverra mi natoque. Lacinia nibh eu commodo ut class blandit magnis.
2560
+
2561
+ Ullamcorper himenaeos mollis nostra placerat quam pellentesque nibh. Curae posuere cras dis senectus fringilla congue ipsum sit. Eros maecenas duis morbi consequat himenaeos ridiculus purus erat. Nascetur maximus massa eros class phasellus integer sed gravida. Vel donec lacinia donec curabitur penatibus integer ornare. Varius quam lectus magna per a mauris.
2562
+
2563
+ Imperdiet tempus malesuada ultrices egestas taciti nibh elit lacus. Nunc tempus tellus vitae duis rhoncus leo facilisis. Sapien nec mi lacus mi aliquet. Diam convallis fringilla libero duis integer integer dictum vel. Dolor montes nibh sapien dapibus ultrices praesent. Aeuismod phasellus taciti elit vehicula sit sociosqu. Lobortis neque urna dignissim penatibus felis vulputate. Primis magnis placerat, ligula massa facilisis nec.
2564
+
2565
+ Duis interdum himenaeos dis nisl et tortor condimentum accumsan. Laoreet amet fusce dis malesuada iaculis maximus fringilla. Conubia mus nibh felis vestibulum ad convallis mollis. Metus vivamus lobortis habitasse id nam. Egestas pretium eu penatibus consectetur malesuada congue tempus fusce. Rutrum neque pulvinar duis ligula fermentum malesuada. Tincidunt mollis molestie imperdiet ridiculus pharetra maximus sodales curabitur.
2566
+
2567
+ Sem nec integer fusce neque sagittis. Rutrum ipsum ante; urna enim primis consectetur nulla. Arcu ligula lectus varius magna ipsum, et dictum. Pharetra dignissim inceptos tristique natoque tempor volutpat. Luctus tristique himenaeos duis orci maecenas vel morbi. Habitasse a lacinia dignissim commodo elementum maecenas eu mollis. Fermentum tellus sem condimentum mattis elit lectus. Platea fusce arcu cras varius natoque? Volutpat tincidunt ridiculus mus massa ante dis sem ornare magna. Bibendum ornare ultrices proin efficitur; nascetur risus arcu.
2568
+
2569
+ Orci erat orci amet mollis venenatis. Feugiat torquent ex mattis, inceptos etiam integer. Class senectus aptent vivamus, semper dolor nisi at pretium volutpat. Natoque semper enim enim primis ultricies, pharetra pulvinar. Natoque litora tortor accumsan ridiculus lacinia integer; aliquet penatibus ridiculus. Placerat vestibulum justo tristique sapien senectus, et interdum et ridiculus. Urna aenean vel himenaeos; finibus a est efficitur donec. Dictum egestas quis fusce arcu; sapien himenaeos pretium congue. Semper et sapien nisi nascetur venenatis eros integer blandit.
2570
+
2571
+ Arcu per phasellus vehicula ad molestie? Eget arcu eget inceptos, eu ullamcorper diam. Gravida placerat elit ut hendrerit odio. Est lobortis imperdiet venenatis primis a. Facilisis integer maecenas adipiscing metus, rutrum curabitur. Dolor adipiscing himenaeos senectus tempus faucibus cras.
2572
+
2573
+ Massa torquent torquent ullamcorper erat nisl parturient primis eu pulvinar! Ridiculus sollicitudin dis eu, laoreet praesent hendrerit platea euismod. Lacinia dignissim suspendisse sagittis eu rutrum himenaeos curae massa diam. Platea ornare ridiculus consequat curabitur augue vestibulum ridiculus. Vel consectetur vivamus accumsan risus elementum? Imperdiet nascetur efficitur aliquam habitasse nascetur. Hendrerit quisque magnis in lacinia quis mauris.
2574
+
2575
+ Molestie fermentum blandit, viverra condimentum purus himenaeos. Fermentum congue a suspendisse ornare semper laoreet. Pharetra lacus non, iaculis ad taciti varius. Etiam nam risus vestibulum curabitur facilisis mattis, lorem hac id. Dignissim nibh tempor quam porta lectus nunc tincidunt aliquet. Tortor maximus maximus natoque nam magna torquent nec lectus mus. Vel fermentum semper vulputate penatibus vel purus.
2576
+
2577
+ Fermentum tincidunt penatibus platea himenaeos etiam sodales ad erat posuere. Vehicula vulputate sem blandit nullam sem. Condimentum eget lacus ad malesuada augue dui justo. Lobortis quis mauris pellentesque quam interdum sagittis. Nulla ullamcorper aptent hendrerit fusce hendrerit, cras cras magna. Ex quam torquent, congue dis est vulputate lacinia. Dignissim proin lacinia platea tortor elementum nullam. Purus natoque scelerisque habitant vestibulum; metus dui neque ipsum. Pellentesque augue montes fringilla et, maecenas habitant a.
2578
+
2579
+ Quam sapien eu scelerisque tristique, integer in rutrum gravida. Egestas lacinia nisi praesent turpis lacus maximus mus gravida. Dolor eget ultrices rhoncus velit; mollis id. Mi vulputate sed blandit nullam parturient venenatis. Neque vulputate iaculis nascetur felis fames ipsum adipiscing nullam? Vitae faucibus elit congue himenaeos orci volutpat nam. Magna tempus convallis vivamus eu semper. Egestas curabitur integer quis habitasse id taciti hac sociosqu morbi. Duis felis cursus potenti blandit cras dolor pharetra.
2580
+
2581
+ Ultricies vel primis nec mus malesuada congue? Habitasse semper mus ultricies; fermentum himenaeos placerat sodales. Platea sapien malesuada dignissim suscipit dis cras. Etiam odio pharetra metus donec odio natoque. Cras diam curae dapibus accumsan tortor mi laoreet. Ex mollis massa inceptos inceptos adipiscing. Cras rhoncus natoque accumsan augue enim. Parturient porttitor habitant semper platea elementum dictum ornare? Sociosqu blandit nullam vivamus elementum semper himenaeos.
2582
+
2583
+ Orci elit aliquam luctus habitant interdum. Tellus sollicitudin aliquam donec potenti praesent augue magnis auctor. Mattis faucibus iaculis etiam imperdiet lectus ad habitasse sollicitudin ac. Consequat maecenas quam dis adipiscing neque sociosqu. Ullamcorper in praesent himenaeos purus blandit nibh. Dignissim platea amet urna laoreet sociosqu lacinia accumsan consectetur risus. Adipiscing nullam arcu lobortis mi scelerisque feugiat non. Accumsan lacinia urna sit urna tincidunt nam pulvinar urna. Tellus cursus ac himenaeos sed aptent phasellus.
2584
+
2585
+ Scelerisque curabitur eget morbi leo phasellus morbi magnis. Elit nunc non vulputate eget at. Viverra efficitur dignissim fames ut condimentum tincidunt elementum lacus egestas. Dictum phasellus leo auctor dui diam. Sollicitudin placerat elit vehicula vulputate et at eleifend ullamcorper. Primis diam hac class leo justo etiam magnis. Justo maximus venenatis facilisis egestas hendrerit aptent arcu tortor consectetur. Consequat mus curabitur nisl; blandit enim at bibendum tempor bibendum. Ad nam arcu vehicula himenaeos sociosqu eu faucibus accumsan.
2586
+
2587
+ Maximus malesuada faucibus phasellus donec ligula. Rutrum pellentesque ultricies nullam; aenean scelerisque elementum. Porta luctus consectetur pharetra consequat varius. Ut dapibus senectus venenatis scelerisque fames ligula congue. Magna hendrerit faucibus ultricies tincidunt phasellus pellentesque, maecenas consequat! Malesuada senectus praesent sed condimentum aenean mi. Interdum sollicitudin mattis, purus vitae netus gravida. Nullam magna risus leo sit urna aenean.
2588
+
2589
+ Ut lacinia potenti vel varius habitant mus nullam adipiscing. Commodo potenti conubia hendrerit enim massa ad blandit. Nisl a massa nunc risus, condimentum enim. Hac aenean massa lacinia lobortis ad dolor sem. Nisl ex interdum blandit pulvinar pellentesque lorem. Sapien proin malesuada netus parturient pulvinar nec. Ex semper amet sem maximus blandit cras felis. Donec tellus auctor eleifend placerat natoque. Rutrum maecenas sollicitudin nisl consectetur in nulla rhoncus. Id rhoncus nec mi non lacinia leo efficitur nisi.
2590
+
2591
+ Dolor non phasellus id nascetur id nisi litora cubilia interdum. Lectus dolor sodales eu nulla porttitor placerat vulputate. Praesent ullamcorper consequat nulla torquent facilisis nunc. Rhoncus augue eleifend mauris erat duis varius felis. Dignissim nunc pulvinar vehicula dignissim maximus elit metus senectus. Venenatis conubia pulvinar commodo dui montes cubilia.
2592
+
2593
+ Cursus velit lacus aenean elit conubia. Velit in inceptos enim, elit lobortis est facilisis. Suscipit cursus dictum enim libero neque dolor himenaeos eu. Porta in integer praesent quisque quis sit. Primis velit tempus sit curae vehicula porttitor. Scelerisque nisi diam vehicula mi fusce dictum. Tincidunt mus eleifend commodo ridiculus adipiscing.
2594
+
2595
+ Pellentesque quis dignissim euismod in fermentum quam lobortis porta. Dis euismod ultricies montes odio sapien condimentum integer per. Torquent nascetur ante ante; diam ultrices nec habitant. Augue congue a conubia commodo ultricies tortor. Quis ridiculus netus vivamus dictumst efficitur parturient hendrerit. Facilisis ultrices suspendisse elit sodales eleifend maecenas tempor. Habitasse platea congue ac, pretium augue odio interdum netus. Mattis odio mi leo integer nisi diam phasellus elementum. Tortor himenaeos curabitur enim sit ac mi dictumst faucibus sociosqu.
2596
+
2597
+ Duis ex viverra auctor praesent elit ac. Sit ex at cubilia aenean scelerisque finibus ridiculus. Hendrerit imperdiet potenti erat risus commodo. Sit donec ullamcorper facilisi neque varius, suscipit malesuada hac. Nulla lacinia pulvinar non volutpat pellentesque lobortis ultrices dis. Faucibus luctus fusce, aliquam magnis pharetra sed dui nulla viverra. Lectus hendrerit eu pellentesque nostra mauris suspendisse himenaeos. Lectus bibendum inceptos commodo nulla magnis proin.`;
2598
+
2599
+ const searchValue = `In Congress, July 4, 1776
2600
+
2601
+ The unanimous Declaration of the thirteen united States of America, When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.
2602
+
2603
+ We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world.
2604
+
2605
+ He has refused his Assent to Laws, the most wholesome and necessary for the public good.
2606
+
2607
+ He has forbidden his Governors to pass Laws of immediate and pressing importance, unless suspended in their operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them.
2608
+
2609
+ He has refused to pass other Laws for the accommodation of large districts of people, unless those people would relinquish the right of Representation in the Legislature, a right inestimable to them and formidable to tyrants only.
2610
+
2611
+ He has called together legislative bodies at places unusual, uncomfortable, and distant from the depository of their public Records, for the sole purpose of fatiguing them into compliance with his measures.
2612
+
2613
+ He has dissolved Representative Houses repeatedly, for opposing with manly firmness his invasions on the rights of the people.
2614
+
2615
+ He has refused for a long time, after such dissolutions, to cause others to be elected; whereby the Legislative powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the dangers of invasion from without, and convulsions within.
2616
+
2617
+ He has endeavoured to prevent the population of these States; for that purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their migrations hither, and raising the conditions of new Appropriations of Lands.
2618
+
2619
+ He has obstructed the Administration of Justice, by refusing his Assent to Laws for establishing Judiciary powers.
2620
+
2621
+ He has made Judges dependent on his Will alone, for the tenure of their offices, and the amount and payment of their salaries.
2622
+
2623
+ He has erected a multitude of New Offices, and sent hither swarms of Officers to harrass our people, and eat out their substance.
2624
+
2625
+ He has kept among us, in times of peace, Standing Armies without the Consent of our legislatures.
2626
+
2627
+ He has affected to render the Military independent of and superior to the Civil power.
2628
+
2629
+ He has combined with others to subject us to a jurisdiction foreign to our constitution, and unacknowledged by our laws; giving his Assent to their Acts of pretended Legislation:
2630
+
2631
+ For Quartering large bodies of armed troops among us:
2632
+
2633
+ For protecting them, by a mock Trial, from punishment for any Murders which they should commit on the Inhabitants of these States:
2634
+
2635
+ For cutting off our Trade with all parts of the world:
2636
+
2637
+ For imposing Taxes on us without our Consent:
2638
+
2639
+ For depriving us in many cases, of the benefits of Trial by Jury:
2640
+
2641
+ For transporting us beyond Seas to be tried for pretended offences:
2642
+
2643
+ For abolishing the free System of English Laws in a neighbouring Province, establishing therein an Arbitrary government, and enlarging its Boundaries so as to render it at once an example and fit instrument for introducing the same absolute rule into these Colonies:
2644
+
2645
+ For taking away our Charters, abolishing our most valuable Laws, and altering fundamentally the Forms of our Governments:
2646
+
2647
+ For suspending our own Legislatures, and declaring themselves invested with power to legislate for us in all cases whatsoever.
2648
+
2649
+ He has abdicated Government here, by declaring us out of his Protection and waging War against us.
2650
+
2651
+ He has plundered our seas, ravaged our Coasts, burnt our towns, and destroyed the lives of our people.
2652
+
2653
+ He is at this time transporting large Armies of foreign Mercenaries to compleat the works of death, desolation and tyranny, already begun with circumstances of Cruelty & perfidy scarcely paralleled in the most barbarous ages, and totally unworthy the Head of a civilized nation.
2654
+
2655
+ He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands.
2656
+
2657
+ He has excited domestic insurrections amongst us, and has endeavoured to bring on the inhabitants of our frontiers, the merciless Indian Savages, whose known rule of warfare, is an undistinguished destruction of all ages, sexes and conditions.
2658
+
2659
+ In every stage of these Oppressions We have Petitioned for Redress in the most humble terms: Our repeated Petitions have been answered only by repeated injury. A Prince, whose character is thus marked by every act which may define a Tyrant, is unfit to be the ruler of a free people.
2660
+
2661
+ Nor have We been wanting in attentions to our Brittish brethren. We have warned them from time to time of attempts by their legislature to extend an unwarrantable jurisdiction over us. We have reminded them of the circumstances of our emigration and settlement here. We have appealed to their native justice and magnanimity, and we have conjured them by the ties of our common kindred to disavow these usurpations, which, would inevitably interrupt our connections and correspondence. They too have been deaf to the voice of justice and of consanguinity. We must, therefore, acquiesce in the necessity, which denounces our Separation, and hold them, as we hold the rest of mankind, Enemies in War, in Peace Friends.
2662
+
2663
+ We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States; that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm reliance on the protection of divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor.`;