@nymphjs/nymph 1.0.0-beta.10 → 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 +483 -0
  2. package/README.md +10 -20
  3. package/dist/Entity.d.ts +293 -10
  4. package/dist/Entity.js +563 -148
  5. package/dist/Entity.js.map +1 -1
  6. package/dist/Entity.test.js +52 -13
  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 +496 -12
  11. package/dist/Nymph.js +752 -179
  12. package/dist/Nymph.js.map +1 -1
  13. package/dist/Nymph.types.d.ts +77 -8
  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 +174 -40
  25. package/dist/driver/NymphDriver.js +469 -239
  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 +814 -92
  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 +27 -12
  68. package/dist/testMocks.js +40 -29
  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 +23 -19
  75. package/src/Entity.test.ts +50 -7
  76. package/src/Entity.ts +483 -147
  77. package/src/Entity.types.ts +72 -74
  78. package/src/Nymph.ts +868 -322
  79. package/src/Nymph.types.ts +146 -27
  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 +562 -414
  84. package/src/driver/index.ts +2 -2
  85. package/src/driver/testArtifacts.ts +954 -185
  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 +76 -35
  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,20 +1,27 @@
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';
7
+ import type Nymph from '../Nymph.js';
8
+ import { EntityUniqueConstraintError } from '../errors/index.js';
6
9
  import {
7
10
  TestBModel as TestBModelClass,
8
11
  TestModel as TestModelClass,
9
12
  TestModelData,
10
- } from '../testArtifacts';
13
+ TestEmptyModel as TestEmptyModelClass,
14
+ } from '../testArtifacts.js';
11
15
 
12
- export function QueriesTest(
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
17
+
18
+ export function EntitiesTest(
13
19
  nymph: Nymph,
14
- it: (name: string, fn: () => void) => void
20
+ it: (name: string, fn: () => void) => void,
15
21
  ) {
16
22
  const TestModel = nymph.addEntityClass(TestModelClass);
17
23
  const TestBModel = nymph.addEntityClass(TestBModelClass);
24
+ const TestEmptyModel = nymph.addEntityClass(TestEmptyModelClass);
18
25
 
19
26
  let testEntity: TestModelClass & TestModelData;
20
27
  let testGuid: string;
@@ -34,12 +41,16 @@ export function QueriesTest(
34
41
  testEntity.name = 'Entity Test ' + new Date().toLocaleString();
35
42
  testEntity.null = null;
36
43
  testEntity.string = 'test';
37
- testEntity.array = ['full', 'of', 'values', 500];
38
- 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.
39
-
40
- This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
41
- This one's phone number is (555) 555-1818.
42
- 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;
43
54
  testEntity.number = 30;
44
55
  testEntity.numberString = '30';
45
56
  testEntity.timestamp = Date.now();
@@ -59,18 +70,10 @@ This one's zip code is 92064.`;
59
70
  entityReferenceTest.test = 'good';
60
71
  expect(await entityReferenceTest.$save()).toEqual(true);
61
72
 
62
- // Test synchronous getEntity.
63
- testEntity = nymph.driver.getEntitySync(
64
- { class: TestModel },
65
- testGuid
66
- ) as TestModelClass & TestModelData;
67
- expect(testEntity).toBeInstanceOf(TestModel);
68
- expect(testEntity.guid).toEqual(testGuid);
69
-
70
73
  // Test asynchronous getEntity.
71
74
  testEntity = (await nymph.getEntity(
72
75
  { class: TestModel },
73
- testGuid
76
+ testGuid,
74
77
  )) as TestModelClass & TestModelData;
75
78
  expect(testEntity).toBeInstanceOf(TestModel);
76
79
  expect(testEntity.guid).toEqual(testGuid);
@@ -84,6 +87,8 @@ This one's zip code is 92064.`;
84
87
  for (let i = 0; i < 100; i++) {
85
88
  const testEntity = await TestModel.factory();
86
89
  testEntity.name = `Multi Test ${i}`;
90
+ // Reverse the number for sort testing.
91
+ testEntity.number = 100 - i;
87
92
  testEntity.$removeTag('test');
88
93
  testEntity.$addTag('multiTest');
89
94
  expect(await testEntity.$save()).toEqual(true);
@@ -94,20 +99,36 @@ This one's zip code is 92064.`;
94
99
  }
95
100
 
96
101
  it('delete old test data', async () => {
97
- let all = await nymph.getEntities({ class: TestModel });
98
- expect(Array.isArray(all)).toEqual(true);
99
- 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) {
100
105
  expect(await cur.$delete()).toEqual(true);
101
106
  }
102
107
 
103
- all = await nymph.getEntities({ class: TestModel });
104
- 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);
105
119
  });
106
120
 
107
121
  it('create entity', async () => {
108
122
  await createTestEntities();
109
123
  });
110
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
+
111
132
  it('update mdate on save', async () => {
112
133
  await createTestEntities();
113
134
 
@@ -139,6 +160,35 @@ This one's zip code is 92064.`;
139
160
  expect(testEntity.$is(resultEntity)).toEqual(false);
140
161
  });
141
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
+
142
192
  it('transactions', async () => {
143
193
  await createTestEntities();
144
194
 
@@ -150,7 +200,7 @@ This one's zip code is 92064.`;
150
200
 
151
201
  if (!(await transaction.inTransaction())) {
152
202
  console.log(
153
- '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.',
154
204
  );
155
205
  await transaction.rollback('test');
156
206
  return;
@@ -181,7 +231,7 @@ This one's zip code is 92064.`;
181
231
  expect(await testEntity.$delete()).toEqual(true);
182
232
  const resultEntity = await transaction.getEntity(
183
233
  { class: TestModel },
184
- testGuid
234
+ testGuid,
185
235
  );
186
236
  expect(resultEntity).toBeNull();
187
237
 
@@ -194,13 +244,13 @@ This one's zip code is 92064.`;
194
244
  // Verify it's back.
195
245
  testEntity = (await transaction.getEntity(
196
246
  { class: TestModel },
197
- testGuid
247
+ testGuid,
198
248
  )) as TestModelClass & TestModelData;
199
249
 
200
250
  expect(testEntity.guid).toEqual(testGuid);
201
251
 
202
- // Start a new transaction.
203
- transaction = await nymph.startTransaction('test');
252
+ // Start a new transaction with a dot in the name.
253
+ transaction = await nymph.startTransaction('test.1');
204
254
  testEntity.$nymph = transaction;
205
255
 
206
256
  // Verify in a transaction.
@@ -211,7 +261,7 @@ This one's zip code is 92064.`;
211
261
  expect(await testEntity.$save()).toEqual(true);
212
262
 
213
263
  // Commit the transaction.
214
- await transaction.commit('test');
264
+ await transaction.commit('test.1');
215
265
  testEntity.$nymph = nymph;
216
266
 
217
267
  // Verify not in a transaction.
@@ -240,7 +290,7 @@ This one's zip code is 92064.`;
240
290
  limit: 1,
241
291
  sort: 'cdate',
242
292
  },
243
- { type: '&', tag: 'test' }
293
+ { type: '&', tag: 'test' },
244
294
  );
245
295
  expect(resultEntities.length).toEqual(1);
246
296
  expect(testEntity.$is(resultEntities[0])).toEqual(true);
@@ -252,7 +302,7 @@ This one's zip code is 92064.`;
252
302
  // Retrieving entity by GUID and tags...
253
303
  const resultEntity = await nymph.getEntity(
254
304
  { class: TestModel },
255
- { type: '&', guid: testGuid, tag: 'test' }
305
+ { type: '&', guid: testGuid, tag: 'test' },
256
306
  );
257
307
  expect(testEntity.$is(resultEntity)).toEqual(true);
258
308
  });
@@ -263,7 +313,7 @@ This one's zip code is 92064.`;
263
313
  // Retrieving entity by GUID and tags...
264
314
  const resultEntity = await nymph.getEntity(
265
315
  { class: TestModel },
266
- { type: '|', guid: [testGuid, guid()] }
316
+ { type: '|', guid: [testGuid, guid()] },
267
317
  );
268
318
  expect(testEntity.$is(resultEntity)).toEqual(true);
269
319
  });
@@ -274,7 +324,7 @@ This one's zip code is 92064.`;
274
324
  // Retrieving entity by GUID and tags...
275
325
  const resultEntity = await nymph.getEntity(
276
326
  { class: TestModel },
277
- { type: '|', guid: [guid(), guid()] }
327
+ { type: '|', guid: [guid(), guid()] },
278
328
  );
279
329
  expect(testEntity.$is(resultEntity)).toEqual(false);
280
330
  });
@@ -285,7 +335,7 @@ This one's zip code is 92064.`;
285
335
  // Retrieving entity by !GUID...
286
336
  const resultEntity = await nymph.getEntities(
287
337
  { class: TestModel },
288
- { type: '&', '!guid': guid(), tag: 'test' }
338
+ { type: '&', '!guid': guid(), tag: 'test' },
289
339
  );
290
340
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
291
341
  });
@@ -296,7 +346,7 @@ This one's zip code is 92064.`;
296
346
  // Retrieving entity by !tags...
297
347
  const resultEntity = await nymph.getEntities(
298
348
  { class: TestModel },
299
- { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] }
349
+ { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] },
300
350
  );
301
351
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
302
352
  });
@@ -307,7 +357,7 @@ This one's zip code is 92064.`;
307
357
  // Testing GUID and wrong tags...
308
358
  const resultEntity = await nymph.getEntity(
309
359
  { class: TestModel },
310
- { type: '&', guid: testGuid, tag: ['pickles'] }
360
+ { type: '&', guid: testGuid, tag: ['pickles'] },
311
361
  );
312
362
  expect(resultEntity).toBeNull();
313
363
  });
@@ -318,7 +368,7 @@ This one's zip code is 92064.`;
318
368
  // Retrieving entity by tags...
319
369
  const resultEntity = await nymph.getEntities(
320
370
  { class: TestModel },
321
- { type: '&', tag: 'test' }
371
+ { type: '&', tag: 'test' },
322
372
  );
323
373
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
324
374
  });
@@ -329,7 +379,7 @@ This one's zip code is 92064.`;
329
379
  // Testing wrong tags...
330
380
  const resultEntity = await nymph.getEntities(
331
381
  { class: TestModel },
332
- { type: '&', tag: 'pickles' }
382
+ { type: '&', tag: 'pickles' },
333
383
  );
334
384
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
335
385
  });
@@ -340,7 +390,7 @@ This one's zip code is 92064.`;
340
390
  // Retrieving entity by tags inclusively...
341
391
  const resultEntity = await nymph.getEntities(
342
392
  { class: TestModel },
343
- { type: '|', tag: ['pickles', 'test', 'barbecue'] }
393
+ { type: '|', tag: ['pickles', 'test', 'barbecue'] },
344
394
  );
345
395
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
346
396
  });
@@ -351,7 +401,7 @@ This one's zip code is 92064.`;
351
401
  // Testing wrong inclusive tags...
352
402
  const resultEntity = await nymph.getEntities(
353
403
  { class: TestModel },
354
- { type: '|', tag: ['pickles', 'barbecue'] }
404
+ { type: '|', tag: ['pickles', 'barbecue'] },
355
405
  );
356
406
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
357
407
  });
@@ -363,7 +413,7 @@ This one's zip code is 92064.`;
363
413
  const resultEntity = await nymph.getEntities(
364
414
  { class: TestModel },
365
415
  { type: '&', tag: 'test' },
366
- { type: '|', tag: ['pickles', 'test', 'barbecue'] }
416
+ { type: '|', tag: ['pickles', 'test', 'barbecue'] },
367
417
  );
368
418
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
369
419
  });
@@ -375,7 +425,7 @@ This one's zip code is 92064.`;
375
425
  const resultEntity = await nymph.getEntities(
376
426
  { class: TestModel },
377
427
  { type: '&', tag: 'test' },
378
- { type: '|', tag: ['pickles', 'barbecue'] }
428
+ { type: '|', tag: ['pickles', 'barbecue'] },
379
429
  );
380
430
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
381
431
  });
@@ -387,7 +437,7 @@ This one's zip code is 92064.`;
387
437
  const resultEntity = await nymph.getEntities(
388
438
  { class: TestModel },
389
439
  { type: '&', tag: 'pickles' },
390
- { type: '|', tag: ['test', 'barbecue'] }
440
+ { type: '|', tag: ['test', 'barbecue'] },
391
441
  );
392
442
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
393
443
  });
@@ -398,7 +448,7 @@ This one's zip code is 92064.`;
398
448
  // Retrieving entity by defined...
399
449
  const resultEntity = await nymph.getEntities(
400
450
  { class: TestModel },
401
- { type: '&', defined: 'string' }
451
+ { type: '&', defined: 'string' },
402
452
  );
403
453
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
404
454
  });
@@ -409,7 +459,7 @@ This one's zip code is 92064.`;
409
459
  // Retrieving entity by !defined...
410
460
  const resultEntity = await nymph.getEntities(
411
461
  { class: TestModel },
412
- { type: '&', tag: 'test', '!defined': 'pickles' }
462
+ { type: '&', tag: 'test', '!defined': 'pickles' },
413
463
  );
414
464
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
415
465
  });
@@ -421,7 +471,7 @@ This one's zip code is 92064.`;
421
471
  const resultEntity = await nymph.getEntities(
422
472
  { class: TestModel },
423
473
  { type: '!&', defined: 'pickles' },
424
- { type: '&', tag: 'test' }
474
+ { type: '&', tag: 'test' },
425
475
  );
426
476
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
427
477
  });
@@ -430,9 +480,60 @@ This one's zip code is 92064.`;
430
480
  await createTestEntities();
431
481
 
432
482
  // Retrieving entity by equal...
433
- 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(
434
532
  { class: TestModel },
435
- { type: '&', equal: ['string', 'test'] }
533
+ {
534
+ type: '&',
535
+ equal: ['match', matchValue],
536
+ },
436
537
  );
437
538
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
438
539
  });
@@ -446,7 +547,7 @@ This one's zip code is 92064.`;
446
547
  // Retrieving entity by !equal...
447
548
  const resultEntity = await nymph.getEntities(
448
549
  { class: TestModel },
449
- { type: '&', tag: 'test', '!equal': ['string', 'wrong'] }
550
+ { type: '&', tag: 'test', '!equal': ['string', 'wrong'] },
450
551
  );
451
552
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
452
553
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -458,7 +559,7 @@ This one's zip code is 92064.`;
458
559
  // Retrieving entity by like...
459
560
  const resultEntity = await nymph.getEntities(
460
561
  { class: TestModel },
461
- { type: '&', like: ['string', 't_s%'] }
562
+ { type: '&', like: ['string', 't_s%'] },
462
563
  );
463
564
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
464
565
  });
@@ -472,7 +573,7 @@ This one's zip code is 92064.`;
472
573
  // Retrieving entity by !like...
473
574
  const resultEntity = await nymph.getEntities(
474
575
  { class: TestModel },
475
- { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] }
576
+ { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] },
476
577
  );
477
578
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
478
579
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -484,7 +585,7 @@ This one's zip code is 92064.`;
484
585
  // Retrieving entity by ilike...
485
586
  const resultEntity = await nymph.getEntities(
486
587
  { class: TestModel },
487
- { type: '&', ilike: ['string', 'T_s%'] }
588
+ { type: '&', ilike: ['string', 'T_s%'] },
488
589
  );
489
590
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
490
591
  });
@@ -498,7 +599,7 @@ This one's zip code is 92064.`;
498
599
  // Retrieving entity by !ilike...
499
600
  const resultEntity = await nymph.getEntities(
500
601
  { class: TestModel },
501
- { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] }
602
+ { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] },
502
603
  );
503
604
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
504
605
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -510,7 +611,7 @@ This one's zip code is 92064.`;
510
611
  // Retrieving entity by like...
511
612
  const resultEntity = await nymph.getEntities(
512
613
  { class: TestModel },
513
- { type: '&', like: ['string', 'T_s%'] }
614
+ { type: '&', like: ['string', 'T_s%'] },
514
615
  );
515
616
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
516
617
  });
@@ -521,7 +622,7 @@ This one's zip code is 92064.`;
521
622
  // Retrieving entity by tags and equal...
522
623
  const resultEntity = await nymph.getEntities(
523
624
  { class: TestModel },
524
- { type: '&', tag: 'test', equal: ['string', 'test'] }
625
+ { type: '&', tag: 'test', equal: ['string', 'test'] },
525
626
  );
526
627
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
527
628
  });
@@ -532,7 +633,7 @@ This one's zip code is 92064.`;
532
633
  // Testing wrong tags and right equal...
533
634
  const resultEntity = await nymph.getEntities(
534
635
  { class: TestModel },
535
- { type: '&', tag: 'pickles', equal: ['string', 'test'] }
636
+ { type: '&', tag: 'pickles', equal: ['string', 'test'] },
536
637
  );
537
638
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
538
639
  });
@@ -543,7 +644,7 @@ This one's zip code is 92064.`;
543
644
  // Testing right tags and wrong equal...
544
645
  const resultEntity = await nymph.getEntities(
545
646
  { class: TestModel },
546
- { type: '&', tag: 'test', equal: ['string', 'pickles'] }
647
+ { type: '&', tag: 'test', equal: ['string', 'pickles'] },
547
648
  );
548
649
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
549
650
  });
@@ -554,7 +655,7 @@ This one's zip code is 92064.`;
554
655
  // Testing wrong tags and wrong equal...
555
656
  const resultEntity = await nymph.getEntities(
556
657
  { class: TestModel },
557
- { type: '&', tag: 'pickles', equal: ['string', 'pickles'] }
658
+ { type: '&', tag: 'pickles', equal: ['string', 'pickles'] },
558
659
  );
559
660
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
560
661
  });
@@ -565,14 +666,21 @@ This one's zip code is 92064.`;
565
666
  // Retrieving entity by contain...
566
667
  let resultEntity = await nymph.getEntities(
567
668
  { class: TestModel },
568
- { 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] },
569
677
  );
570
678
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
571
679
 
572
- // Retrieving entity by contain with full match...
680
+ // Retrieving entity by contain...
573
681
  resultEntity = await nymph.getEntities(
574
682
  { class: TestModel },
575
- { type: '&', contain: ['string', 'test'] }
683
+ { type: '&', contain: ['array', { test: true }] },
576
684
  );
577
685
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
578
686
  });
@@ -584,7 +692,7 @@ This one's zip code is 92064.`;
584
692
  const resultEntity = await nymph.getEntities(
585
693
  { class: TestModel },
586
694
  { type: '&', tag: 'test' },
587
- { type: '!&', contain: ['array', 'pickles'] }
695
+ { type: '!&', contain: ['array', 'pickles'] },
588
696
  );
589
697
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
590
698
  });
@@ -595,14 +703,14 @@ This one's zip code is 92064.`;
595
703
  // Testing wrong contain...
596
704
  let resultEntity = await nymph.getEntities(
597
705
  { class: TestModel },
598
- { type: '&', contain: ['array', 'pickles'] }
706
+ { type: '&', contain: ['array', 'pickles'] },
599
707
  );
600
708
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
601
709
 
602
710
  // Testing wrong contain...
603
711
  resultEntity = await nymph.getEntities(
604
712
  { class: TestModel },
605
- { type: '&', contain: ['string', 'pickles'] }
713
+ { type: '&', contain: ['string', 'pickles'] },
606
714
  );
607
715
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
608
716
  });
@@ -613,12 +721,12 @@ This one's zip code is 92064.`;
613
721
  // Retrieving entity by regex match...
614
722
  let resultEntity = await nymph.getEntities(
615
723
  { class: TestModel },
616
- { type: '&', match: ['match', '.*'] } // anything
724
+ { type: '&', match: ['match', '.*'] }, // anything
617
725
  );
618
726
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
619
727
  resultEntity = await nymph.getEntities(
620
728
  { class: TestModel },
621
- { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] } // a substring
729
+ { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] }, // a substring
622
730
  );
623
731
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
624
732
  resultEntity = await nymph.getEntities(
@@ -630,7 +738,7 @@ This one's zip code is 92064.`;
630
738
  ['string', '[0-9]'],
631
739
  ['match', 'Edward McCheese'],
632
740
  ],
633
- } // inclusive test
741
+ }, // inclusive test
634
742
  );
635
743
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
636
744
  resultEntity = await nymph.getEntities(
@@ -639,7 +747,7 @@ This one's zip code is 92064.`;
639
747
  type: '&',
640
748
  tag: 'test',
641
749
  match: ['match', '[-a-zA-Z0-9+_]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9_]{2,4}'],
642
- } // a simple email
750
+ }, // a simple email
643
751
  );
644
752
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
645
753
  resultEntity = await nymph.getEntities(
@@ -648,7 +756,7 @@ This one's zip code is 92064.`;
648
756
  type: '&',
649
757
  tag: 'test',
650
758
  match: ['match', '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'],
651
- } // a phone number
759
+ }, // a phone number
652
760
  );
653
761
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
654
762
  });
@@ -659,7 +767,7 @@ This one's zip code is 92064.`;
659
767
  // Retrieving entity by regex match...
660
768
  const resultEntity = await nymph.getEntities(
661
769
  { class: TestModel },
662
- { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] } // a substring
770
+ { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] }, // a substring
663
771
  );
664
772
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
665
773
  });
@@ -670,12 +778,12 @@ This one's zip code is 92064.`;
670
778
  // Testing wrong regex match...
671
779
  let resultEntity = await nymph.getEntities(
672
780
  { class: TestModel },
673
- { type: '&', match: ['match', 'Q'] }
781
+ { type: '&', match: ['match', '='] },
674
782
  );
675
783
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
676
784
  resultEntity = await nymph.getEntities(
677
785
  { class: TestModel },
678
- { type: '&', tag: 'pickle', match: ['match', '.*'] }
786
+ { type: '&', tag: 'pickle', match: ['match', '.*'] },
679
787
  );
680
788
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
681
789
  resultEntity = await nymph.getEntities(
@@ -686,7 +794,7 @@ This one's zip code is 92064.`;
686
794
  ['string', '[0-9]'],
687
795
  ['match', ',,'],
688
796
  ],
689
- }
797
+ },
690
798
  );
691
799
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
692
800
  });
@@ -697,7 +805,7 @@ This one's zip code is 92064.`;
697
805
  // Retrieving entity by regex match...
698
806
  const resultEntity = await nymph.getEntities(
699
807
  { class: TestModel },
700
- { type: '&', tag: 'test', match: ['match', 'edward mccheese'] } // a substring
808
+ { type: '&', tag: 'test', match: ['match', 'edward mccheese'] }, // a substring
701
809
  );
702
810
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
703
811
  });
@@ -709,7 +817,181 @@ This one's zip code is 92064.`;
709
817
  const resultEntity = await nymph.getEntities(
710
818
  { class: TestModel },
711
819
  { type: '&', tag: 'test' },
712
- { 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'] },
713
995
  );
714
996
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
715
997
  });
@@ -726,7 +1008,7 @@ This one's zip code is 92064.`;
726
1008
  ['number', 30],
727
1009
  ['pickles', 100],
728
1010
  ],
729
- }
1011
+ },
730
1012
  );
731
1013
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
732
1014
 
@@ -739,7 +1021,7 @@ This one's zip code is 92064.`;
739
1021
  ['number', 31],
740
1022
  ['pickles', 100],
741
1023
  ],
742
- }
1024
+ },
743
1025
  );
744
1026
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
745
1027
 
@@ -752,7 +1034,7 @@ This one's zip code is 92064.`;
752
1034
  ['number', 29],
753
1035
  ['pickles', 100],
754
1036
  ],
755
- }
1037
+ },
756
1038
  );
757
1039
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
758
1040
 
@@ -765,7 +1047,7 @@ This one's zip code is 92064.`;
765
1047
  ['numberString', 30],
766
1048
  ['pickles', 100],
767
1049
  ],
768
- }
1050
+ },
769
1051
  );
770
1052
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
771
1053
 
@@ -778,7 +1060,7 @@ This one's zip code is 92064.`;
778
1060
  ['numberString', 31],
779
1061
  ['pickles', 100],
780
1062
  ],
781
- }
1063
+ },
782
1064
  );
783
1065
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
784
1066
 
@@ -791,7 +1073,7 @@ This one's zip code is 92064.`;
791
1073
  ['numberString', 29],
792
1074
  ['pickles', 100],
793
1075
  ],
794
- }
1076
+ },
795
1077
  );
796
1078
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
797
1079
  });
@@ -808,7 +1090,7 @@ This one's zip code is 92064.`;
808
1090
  ['number', 30],
809
1091
  ['pickles', 100],
810
1092
  ],
811
- }
1093
+ },
812
1094
  );
813
1095
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
814
1096
 
@@ -821,7 +1103,7 @@ This one's zip code is 92064.`;
821
1103
  ['number', 31],
822
1104
  ['pickles', 100],
823
1105
  ],
824
- }
1106
+ },
825
1107
  );
826
1108
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
827
1109
 
@@ -834,7 +1116,7 @@ This one's zip code is 92064.`;
834
1116
  ['number', 29],
835
1117
  ['pickles', 100],
836
1118
  ],
837
- }
1119
+ },
838
1120
  );
839
1121
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
840
1122
 
@@ -847,7 +1129,7 @@ This one's zip code is 92064.`;
847
1129
  ['numberString', 30],
848
1130
  ['pickles', 100],
849
1131
  ],
850
- }
1132
+ },
851
1133
  );
852
1134
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
853
1135
 
@@ -860,7 +1142,7 @@ This one's zip code is 92064.`;
860
1142
  ['numberString', 31],
861
1143
  ['pickles', 100],
862
1144
  ],
863
- }
1145
+ },
864
1146
  );
865
1147
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
866
1148
 
@@ -873,7 +1155,7 @@ This one's zip code is 92064.`;
873
1155
  ['numberString', 29],
874
1156
  ['pickles', 100],
875
1157
  ],
876
- }
1158
+ },
877
1159
  );
878
1160
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
879
1161
  });
@@ -890,7 +1172,7 @@ This one's zip code is 92064.`;
890
1172
  ['number', 30],
891
1173
  ['pickles', 100],
892
1174
  ],
893
- }
1175
+ },
894
1176
  );
895
1177
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
896
1178
 
@@ -903,7 +1185,7 @@ This one's zip code is 92064.`;
903
1185
  ['number', 31],
904
1186
  ['pickles', 100],
905
1187
  ],
906
- }
1188
+ },
907
1189
  );
908
1190
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
909
1191
 
@@ -916,7 +1198,7 @@ This one's zip code is 92064.`;
916
1198
  ['number', 29],
917
1199
  ['pickles', 100],
918
1200
  ],
919
- }
1201
+ },
920
1202
  );
921
1203
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
922
1204
 
@@ -929,7 +1211,7 @@ This one's zip code is 92064.`;
929
1211
  ['numberString', 30],
930
1212
  ['pickles', 100],
931
1213
  ],
932
- }
1214
+ },
933
1215
  );
934
1216
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
935
1217
 
@@ -942,7 +1224,7 @@ This one's zip code is 92064.`;
942
1224
  ['numberString', 31],
943
1225
  ['pickles', 100],
944
1226
  ],
945
- }
1227
+ },
946
1228
  );
947
1229
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
948
1230
 
@@ -955,7 +1237,7 @@ This one's zip code is 92064.`;
955
1237
  ['numberString', 29],
956
1238
  ['pickles', 100],
957
1239
  ],
958
- }
1240
+ },
959
1241
  );
960
1242
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
961
1243
  });
@@ -972,7 +1254,7 @@ This one's zip code is 92064.`;
972
1254
  ['number', 30],
973
1255
  ['pickles', 100],
974
1256
  ],
975
- }
1257
+ },
976
1258
  );
977
1259
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
978
1260
 
@@ -985,7 +1267,7 @@ This one's zip code is 92064.`;
985
1267
  ['number', 31],
986
1268
  ['pickles', 100],
987
1269
  ],
988
- }
1270
+ },
989
1271
  );
990
1272
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
991
1273
 
@@ -998,7 +1280,7 @@ This one's zip code is 92064.`;
998
1280
  ['number', 29],
999
1281
  ['pickles', 100],
1000
1282
  ],
1001
- }
1283
+ },
1002
1284
  );
1003
1285
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1004
1286
 
@@ -1011,7 +1293,7 @@ This one's zip code is 92064.`;
1011
1293
  ['numberString', 30],
1012
1294
  ['pickles', 100],
1013
1295
  ],
1014
- }
1296
+ },
1015
1297
  );
1016
1298
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1017
1299
 
@@ -1024,7 +1306,7 @@ This one's zip code is 92064.`;
1024
1306
  ['numberString', 31],
1025
1307
  ['pickles', 100],
1026
1308
  ],
1027
- }
1309
+ },
1028
1310
  );
1029
1311
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1030
1312
 
@@ -1037,7 +1319,7 @@ This one's zip code is 92064.`;
1037
1319
  ['numberString', 29],
1038
1320
  ['pickles', 100],
1039
1321
  ],
1040
- }
1322
+ },
1041
1323
  );
1042
1324
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1043
1325
  });
@@ -1049,7 +1331,7 @@ This one's zip code is 92064.`;
1049
1331
  const resultEntity = await nymph.getEntities(
1050
1332
  { class: TestModel },
1051
1333
  { type: '&', tag: 'test' },
1052
- { type: '!&', gte: ['number', 60] }
1334
+ { type: '!&', gte: ['number', 60] },
1053
1335
  );
1054
1336
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1055
1337
  });
@@ -1060,7 +1342,7 @@ This one's zip code is 92064.`;
1060
1342
  // Testing wrong inequality...
1061
1343
  const resultEntity = await nymph.getEntities(
1062
1344
  { class: TestModel },
1063
- { type: '&', lte: ['number', 29.99] }
1345
+ { type: '&', lte: ['number', 29.99] },
1064
1346
  );
1065
1347
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1066
1348
  });
@@ -1071,7 +1353,7 @@ This one's zip code is 92064.`;
1071
1353
  // Retrieving entity by time...
1072
1354
  const resultEntity = await nymph.getEntities(
1073
1355
  { class: TestModel },
1074
- { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] }
1356
+ { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] },
1075
1357
  );
1076
1358
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1077
1359
  });
@@ -1082,7 +1364,7 @@ This one's zip code is 92064.`;
1082
1364
  // Testing wrong time...
1083
1365
  const resultEntity = await nymph.getEntities(
1084
1366
  { class: TestModel },
1085
- { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] }
1367
+ { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] },
1086
1368
  );
1087
1369
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1088
1370
  });
@@ -1095,7 +1377,7 @@ This one's zip code is 92064.`;
1095
1377
  // Retrieving entity by relative time...
1096
1378
  let resultEntity = await nymph.getEntities(
1097
1379
  { class: TestModel },
1098
- { type: '&', gt: ['timestamp', null, '-1 day'] }
1380
+ { type: '&', gt: ['timestamp', null, '-1 day'] },
1099
1381
  );
1100
1382
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1101
1383
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1109,7 +1391,7 @@ This one's zip code is 92064.`;
1109
1391
  ['timestamp', null, '-1 day'],
1110
1392
  ['timestamp', null, '+5 days'],
1111
1393
  ],
1112
- }
1394
+ },
1113
1395
  );
1114
1396
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1115
1397
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1117,7 +1399,7 @@ This one's zip code is 92064.`;
1117
1399
  // Retrieving entity by relative time...
1118
1400
  resultEntity = await nymph.getEntities(
1119
1401
  { class: TestModel },
1120
- { type: '&', gt: ['timestamp', null, '-3 days'] }
1402
+ { type: '&', gt: ['timestamp', null, '-3 days'] },
1121
1403
  );
1122
1404
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1123
1405
  expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
@@ -1125,7 +1407,7 @@ This one's zip code is 92064.`;
1125
1407
  // Retrieving entity by relative time...
1126
1408
  resultEntity = await nymph.getEntities(
1127
1409
  { class: TestModel },
1128
- { type: '&', gt: ['cdate', null, '-1 day'] }
1410
+ { type: '&', gt: ['cdate', null, '-1 day'] },
1129
1411
  );
1130
1412
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1131
1413
  expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
@@ -1139,7 +1421,7 @@ This one's zip code is 92064.`;
1139
1421
  // Retrieving entity by relative time...
1140
1422
  let resultEntity = await nymph.getEntities(
1141
1423
  { class: TestModel },
1142
- { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] }
1424
+ { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] },
1143
1425
  );
1144
1426
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1145
1427
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1147,7 +1429,7 @@ This one's zip code is 92064.`;
1147
1429
  // Retrieving entity by relative time...
1148
1430
  resultEntity = await nymph.getEntities(
1149
1431
  { class: TestModel },
1150
- { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] }
1432
+ { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] },
1151
1433
  );
1152
1434
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1153
1435
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1155,7 +1437,7 @@ This one's zip code is 92064.`;
1155
1437
  // Retrieving entity by relative time...
1156
1438
  resultEntity = await nymph.getEntities(
1157
1439
  { class: TestModel },
1158
- { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] }
1440
+ { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] },
1159
1441
  );
1160
1442
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1161
1443
  expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
@@ -1165,9 +1447,11 @@ This one's zip code is 92064.`;
1165
1447
  await createTestEntities();
1166
1448
 
1167
1449
  // Testing referenced entities...
1450
+ await testEntity.reference?.$wake();
1168
1451
  expect(testEntity.reference?.test).toEqual('good');
1169
1452
 
1170
1453
  // Testing referenced entity arrays...
1454
+ await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
1171
1455
  expect(testEntity.refArray?.[0].test).toEqual('good');
1172
1456
  });
1173
1457
 
@@ -1177,7 +1461,7 @@ This one's zip code is 92064.`;
1177
1461
  // Retrieving entity by reference...
1178
1462
  const resultEntity = await nymph.getEntities(
1179
1463
  { class: TestModel },
1180
- { type: '&', ref: ['reference', refGuid] }
1464
+ { type: '&', ref: ['reference', refGuid] },
1181
1465
  );
1182
1466
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1183
1467
  });
@@ -1189,7 +1473,7 @@ This one's zip code is 92064.`;
1189
1473
  const resultEntity = await nymph.getEntities(
1190
1474
  { class: TestModel },
1191
1475
  { type: '&', tag: 'test' },
1192
- { type: '!&', ref: ['reference', guid()] }
1476
+ { type: '!&', ref: ['reference', guid()] },
1193
1477
  );
1194
1478
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1195
1479
  });
@@ -1200,7 +1484,7 @@ This one's zip code is 92064.`;
1200
1484
  // Testing wrong reference...
1201
1485
  const resultEntity = await nymph.getEntities(
1202
1486
  { class: TestModel },
1203
- { type: '&', ref: ['reference', guid()] }
1487
+ { type: '&', ref: ['reference', guid()] },
1204
1488
  );
1205
1489
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1206
1490
  });
@@ -1211,7 +1495,7 @@ This one's zip code is 92064.`;
1211
1495
  // Testing non-existent reference...
1212
1496
  const resultEntity = await nymph.getEntities(
1213
1497
  { class: TestModel },
1214
- { type: '&', ref: ['pickle', refGuid] }
1498
+ { type: '&', ref: ['pickle', refGuid] },
1215
1499
  );
1216
1500
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1217
1501
  });
@@ -1228,7 +1512,7 @@ This one's zip code is 92064.`;
1228
1512
  ['reference', refGuid],
1229
1513
  ['reference', guid()],
1230
1514
  ],
1231
- }
1515
+ },
1232
1516
  );
1233
1517
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1234
1518
  });
@@ -1245,7 +1529,7 @@ This one's zip code is 92064.`;
1245
1529
  ['reference', guid()],
1246
1530
  ['reference', guid()],
1247
1531
  ],
1248
- }
1532
+ },
1249
1533
  );
1250
1534
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1251
1535
  });
@@ -1256,7 +1540,7 @@ This one's zip code is 92064.`;
1256
1540
  // Retrieving entity by array reference...
1257
1541
  const resultEntity = await nymph.getEntities(
1258
1542
  { class: TestModel },
1259
- { type: '&', ref: ['refArray', refGuid] }
1543
+ { type: '&', ref: ['refArray', refGuid] },
1260
1544
  );
1261
1545
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1262
1546
  });
@@ -1273,7 +1557,7 @@ This one's zip code is 92064.`;
1273
1557
  ['refArray', refGuid],
1274
1558
  ['refArray', guid()],
1275
1559
  ],
1276
- }
1560
+ },
1277
1561
  );
1278
1562
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1279
1563
  });
@@ -1307,6 +1591,8 @@ This one's zip code is 92064.`;
1307
1591
  ['array', 'of'],
1308
1592
  ['array', 'values'],
1309
1593
  ['array', 500],
1594
+ ['array', { test: true }],
1595
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1310
1596
  ],
1311
1597
  },
1312
1598
  {
@@ -1318,7 +1604,7 @@ This one's zip code is 92064.`;
1318
1604
  ['array', 'values'],
1319
1605
  ['array', 500],
1320
1606
  ],
1321
- }
1607
+ },
1322
1608
  );
1323
1609
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1324
1610
  });
@@ -1338,13 +1624,13 @@ This one's zip code is 92064.`;
1338
1624
 
1339
1625
  const resultSelectors = await nymph.getEntities(
1340
1626
  { class: TestModel },
1341
- { type: '&', ref: ['reference', refGuid] }
1627
+ { type: '&', ref: ['reference', refGuid] },
1342
1628
  );
1343
1629
 
1344
1630
  // Testing count return with selectors...
1345
1631
  const resultSelectorsCount = await nymph.getEntities(
1346
1632
  { class: TestModel, return: 'count' },
1347
- { type: '&', ref: ['reference', refGuid] }
1633
+ { type: '&', ref: ['reference', refGuid] },
1348
1634
  );
1349
1635
  expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
1350
1636
  expect(resultSelectorsCount).toEqual(resultSelectors.length);
@@ -1367,7 +1653,7 @@ This one's zip code is 92064.`;
1367
1653
  // Testing empty count...
1368
1654
  const resultSelectorsEmpty = await nymph.getEntities(
1369
1655
  { class: TestModel, return: 'count' },
1370
- { type: '&', ref: ['reference', guid()] }
1656
+ { type: '&', ref: ['reference', guid()] },
1371
1657
  );
1372
1658
  expect(resultSelectorsEmpty).toEqual(0);
1373
1659
  });
@@ -1401,6 +1687,8 @@ This one's zip code is 92064.`;
1401
1687
  ['array', 'of'],
1402
1688
  ['array', 'values'],
1403
1689
  ['array', 500],
1690
+ ['array', { test: true }],
1691
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1404
1692
  ],
1405
1693
  },
1406
1694
  {
@@ -1412,11 +1700,66 @@ This one's zip code is 92064.`;
1412
1700
  ['array', 'values'],
1413
1701
  ['array', 500],
1414
1702
  ],
1415
- }
1703
+ },
1416
1704
  );
1417
1705
  expect(resultGuid.indexOf(testEntity.guid ?? '')).toBeGreaterThan(-1);
1418
1706
  });
1419
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
+
1420
1763
  it('deep selector', async () => {
1421
1764
  await createTestEntities();
1422
1765
 
@@ -1449,6 +1792,8 @@ This one's zip code is 92064.`;
1449
1792
  ['array', 'of'],
1450
1793
  ['array', 'values'],
1451
1794
  ['array', 500],
1795
+ ['array', { test: true }],
1796
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1452
1797
  ],
1453
1798
  },
1454
1799
  {
@@ -1462,7 +1807,7 @@ This one's zip code is 92064.`;
1462
1807
  ],
1463
1808
  },
1464
1809
  ],
1465
- }
1810
+ },
1466
1811
  );
1467
1812
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1468
1813
 
@@ -1494,6 +1839,8 @@ This one's zip code is 92064.`;
1494
1839
  ['array', 'of'],
1495
1840
  ['array', 'values'],
1496
1841
  ['array', 500],
1842
+ ['array', { test: true }],
1843
+ ['array', { nullbyte: '\\\x00\u0000 \x00' }],
1497
1844
  ],
1498
1845
  },
1499
1846
  {
@@ -1507,7 +1854,7 @@ This one's zip code is 92064.`;
1507
1854
  ],
1508
1855
  },
1509
1856
  ],
1510
- }
1857
+ },
1511
1858
  );
1512
1859
  expect(testEntity.$inArray(resultEntity2)).toEqual(true);
1513
1860
 
@@ -1523,7 +1870,7 @@ This one's zip code is 92064.`;
1523
1870
  },
1524
1871
  { type: '&', gte: ['number', 16000] },
1525
1872
  ],
1526
- }
1873
+ },
1527
1874
  );
1528
1875
  expect(testEntity.$inArray(resultEntity3)).toEqual(true);
1529
1876
 
@@ -1545,7 +1892,7 @@ This one's zip code is 92064.`;
1545
1892
  },
1546
1893
  },
1547
1894
  ],
1548
- }
1895
+ },
1549
1896
  );
1550
1897
  expect(testEntity.$inArray(resultEntity4)).toEqual(true);
1551
1898
  });
@@ -1564,7 +1911,7 @@ This one's zip code is 92064.`;
1564
1911
  },
1565
1912
  { type: '&', gte: ['number', 16000] },
1566
1913
  ],
1567
- }
1914
+ },
1568
1915
  );
1569
1916
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1570
1917
  });
@@ -1581,7 +1928,7 @@ This one's zip code is 92064.`;
1581
1928
  'reference',
1582
1929
  [{ class: TestModel }, { type: '&', equal: ['test', 'good'] }],
1583
1930
  ],
1584
- }
1931
+ },
1585
1932
  );
1586
1933
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1587
1934
  });
@@ -1598,7 +1945,7 @@ This one's zip code is 92064.`;
1598
1945
  'reference',
1599
1946
  [{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
1600
1947
  ],
1601
- }
1948
+ },
1602
1949
  );
1603
1950
  expect(testEntity.$inArray(resultEntity)).toEqual(true);
1604
1951
  });
@@ -1615,7 +1962,7 @@ This one's zip code is 92064.`;
1615
1962
  'reference',
1616
1963
  [{ class: TestBModel }, { type: '&', equal: ['test', 'good'] }],
1617
1964
  ],
1618
- }
1965
+ },
1619
1966
  );
1620
1967
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1621
1968
  });
@@ -1632,31 +1979,28 @@ This one's zip code is 92064.`;
1632
1979
  'reference',
1633
1980
  [{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
1634
1981
  ],
1635
- }
1982
+ },
1636
1983
  );
1637
1984
  expect(testEntity.$inArray(resultEntity)).toEqual(false);
1638
1985
  });
1639
1986
 
1640
- it('sort option', async () => {
1987
+ it('cdate and mdate sort option', async () => {
1641
1988
  await createMultipleTestEntities();
1642
1989
 
1643
- for (const sort of ['cdate', 'mdate']) {
1990
+ for (const sort of ['cdate', 'mdate'] as ('cdate' | 'mdate')[]) {
1644
1991
  // Retrieving entities sorted...
1645
- let resultEntities = await nymph.getEntities({
1646
- class: TestModel,
1647
- sort: sort as 'cdate' | 'mdate',
1648
- });
1992
+ let resultEntities = await nymph.getEntities({ class: TestModel, sort });
1649
1993
  expect(resultEntities.length).toBeGreaterThan(100);
1650
1994
  for (let i = 0; i < resultEntities.length - 1; i++) {
1651
- expect(
1652
- resultEntities[i + 1][sort as 'cdate' | 'mdate']
1653
- ).toBeGreaterThan(resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0);
1995
+ expect(resultEntities[i + 1][sort]).toBeGreaterThan(
1996
+ resultEntities[i][sort] ?? 0,
1997
+ );
1654
1998
  }
1655
1999
 
1656
2000
  // And test the same with guid return...
1657
2001
  let resultGuids = await nymph.getEntities({
1658
2002
  class: TestModel,
1659
- sort: sort as 'cdate' | 'mdate',
2003
+ sort,
1660
2004
  return: 'guid',
1661
2005
  });
1662
2006
  expect(resultGuids.length).toBeGreaterThan(100);
@@ -1667,48 +2011,121 @@ This one's zip code is 92064.`;
1667
2011
  // Retrieving entities reverse sorted...
1668
2012
  resultEntities = await nymph.getEntities({
1669
2013
  class: TestModel,
1670
- sort: sort as 'cdate' | 'mdate',
2014
+ sort,
1671
2015
  reverse: true,
1672
2016
  });
1673
2017
  expect(resultEntities.length).toBeGreaterThan(100);
1674
2018
  for (let i = 0; i < resultEntities.length - 1; i++) {
1675
- expect(resultEntities[i + 1][sort as 'cdate' | 'mdate']).toBeLessThan(
1676
- resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0
2019
+ expect(resultEntities[i + 1][sort]).toBeLessThan(
2020
+ resultEntities[i][sort] ?? 0,
1677
2021
  );
1678
2022
  }
1679
2023
 
1680
2024
  // And again with other selectors.
1681
2025
  // Retrieving entities sorted...
1682
2026
  resultEntities = await nymph.getEntities(
1683
- { class: TestModel, sort: sort as 'cdate' | 'mdate' },
1684
- { type: '&', match: ['name', '^Multi Test '] }
2027
+ { class: TestModel, sort },
2028
+ { type: '&', match: ['name', '^Multi Test '] },
1685
2029
  );
1686
2030
  expect(resultEntities.length).toEqual(100);
1687
2031
  for (let i = 0; i < resultEntities.length - 1; i++) {
1688
- expect(
1689
- resultEntities[i + 1][sort as 'cdate' | 'mdate']
1690
- ).toBeGreaterThan(resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0);
2032
+ expect(resultEntities[i + 1][sort]).toBeGreaterThan(
2033
+ resultEntities[i][sort] ?? 0,
2034
+ );
1691
2035
  }
1692
2036
 
1693
2037
  // Retrieving entities reverse sorted...
1694
2038
  resultEntities = await nymph.getEntities(
1695
- { class: TestModel, sort: sort as 'cdate' | 'mdate', reverse: true },
1696
- { type: '&', match: ['name', '^Multi Test '] }
2039
+ { class: TestModel, sort, reverse: true },
2040
+ { type: '&', match: ['name', '^Multi Test '] },
1697
2041
  );
1698
2042
  expect(resultEntities.length).toEqual(100);
1699
2043
  for (let i = 0; i < resultEntities.length - 1; i++) {
1700
- expect(resultEntities[i + 1][sort as 'cdate' | 'mdate']).toBeLessThan(
1701
- resultEntities[i][sort as 'cdate' | 'mdate'] ?? 0
2044
+ expect(resultEntities[i + 1][sort]).toBeLessThan(
2045
+ resultEntities[i][sort] ?? 0,
1702
2046
  );
1703
2047
  }
1704
2048
  }
1705
2049
  });
1706
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
+
1707
2122
  it('delete reference', async () => {
1708
2123
  await createTestEntities();
1709
2124
 
1710
2125
  // Deleting referenced entities...
2126
+ await testEntity.reference?.$wake();
1711
2127
  expect(await testEntity.reference?.$delete()).toEqual(true);
2128
+ await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
1712
2129
  expect(testEntity.reference?.guid).toBeNull();
1713
2130
  });
1714
2131
 
@@ -1721,16 +2138,116 @@ This one's zip code is 92064.`;
1721
2138
 
1722
2139
  const entity = await nymph.getEntity(
1723
2140
  { class: TestModel },
1724
- { type: '&', guid: testGuid }
2141
+ { type: '&', guid: testGuid },
1725
2142
  );
1726
2143
 
1727
2144
  expect(entity).toBeNull();
1728
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
+ });
1729
2246
  }
1730
2247
 
1731
2248
  export function UIDTest(
1732
2249
  nymph: Nymph,
1733
- it: (name: string, fn: () => void) => void
2250
+ it: (name: string, fn: () => void) => void,
1734
2251
  ) {
1735
2252
  it('delete old test data', async () => {
1736
2253
  expect(await nymph.deleteUID('TestUID')).toEqual(true);
@@ -1771,7 +2288,7 @@ export function UIDTest(
1771
2288
 
1772
2289
  export function ExportImportTest(
1773
2290
  nymph: Nymph,
1774
- it: (name: string, fn: () => void) => void
2291
+ it: (name: string, fn: () => void) => void,
1775
2292
  ) {
1776
2293
  const TestModel = nymph.addEntityClass(TestModelClass);
1777
2294
  const TestBModel = nymph.addEntityClass(TestBModelClass);
@@ -1807,23 +2324,38 @@ export function ExportImportTest(
1807
2324
  const bmodels = await nymph.getEntities({ class: TestBModel });
1808
2325
 
1809
2326
  expect(models.length).toEqual(30);
1810
- expect(bmodels.length).toEqual(10);
1811
-
1812
- const all = [...models, ...bmodels];
1813
- for (const model of all) {
1814
- if (model.index?.match(/^\d+a$/)) {
1815
- expect(model.null).toBeNull();
1816
- expect(model.string).toEqual('test');
1817
- expect(model.array).toEqual(['full', 'of', 'values', 500]);
1818
- expect(model.number).toEqual(30);
1819
- expect(model.timestamp).toBeGreaterThanOrEqual(strtotime('-2 minutes'));
1820
-
1821
- expect(model.reference?.guid).not.toBeNull();
1822
- expect(model.reference?.string).toEqual('another');
1823
- expect(model.reference?.index?.match(/^\d+b$/)).toBeTruthy();
1824
- expect(model.refArray?.[0].guid).not.toBeNull();
1825
- expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
1826
- }
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);
1827
2359
  }
1828
2360
  }
1829
2361
 
@@ -1836,22 +2368,29 @@ export function ExportImportTest(
1836
2368
  expect(await nymph.newUID('TestUID')).toEqual(2);
1837
2369
  expect(await nymph.newUID('TestUID2')).toEqual(1);
1838
2370
 
1839
- for (let i = 0; i < 20; i++) {
1840
- const EntityClass = i < 15 ? TestModel : TestBModel;
1841
-
2371
+ for (let i = 0; i < 30; i++) {
1842
2372
  // Creating entity...
1843
- const testEntity = await EntityClass.factory();
2373
+ const testEntity = await TestModel.factory();
1844
2374
 
1845
2375
  // Saving entity...
1846
2376
  testEntity.name = 'Entity Test ' + new Date().toLocaleString();
1847
2377
  testEntity.null = null;
1848
2378
  testEntity.string = 'test';
1849
- 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;
1850
2388
  testEntity.number = 30;
2389
+ testEntity.numberString = '30';
1851
2390
  testEntity.timestamp = Date.now();
1852
2391
  testEntity.index = i + 'a';
1853
2392
 
1854
- const entityReferenceTest = await EntityClass.factory();
2393
+ const entityReferenceTest = await TestBModel.factory();
1855
2394
  entityReferenceTest.string = 'another';
1856
2395
  entityReferenceTest.index = i + 'b';
1857
2396
 
@@ -1865,9 +2404,13 @@ export function ExportImportTest(
1865
2404
  await checkEntityDataAndCount();
1866
2405
  });
1867
2406
 
2407
+ it('needs migration', async () => {
2408
+ expect(await nymph.needsMigration()).toEqual(false);
2409
+ });
2410
+
1868
2411
  it('export data', async () => {
1869
2412
  expect(await nymph.export(__dirname + '/testentityexport.nex')).toEqual(
1870
- true
2413
+ true,
1871
2414
  );
1872
2415
  });
1873
2416
 
@@ -1884,11 +2427,237 @@ export function ExportImportTest(
1884
2427
  expect(bmodels.length).toEqual(0);
1885
2428
 
1886
2429
  expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(
1887
- true
2430
+ true,
1888
2431
  );
1889
2432
 
1890
2433
  await checkEntityDataAndCount();
1891
2434
 
1892
2435
  fs.unlinkSync(__dirname + '/testentityexport.nex');
1893
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
+ });
1894
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.`;