@nymphjs/nymph 1.0.0-beta.81 → 1.0.0-beta.83

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/Entity.d.ts +3 -3
  4. package/dist/Entity.js +29 -32
  5. package/dist/Entity.js.map +1 -1
  6. package/dist/Entity.test.js +10 -11
  7. package/dist/Entity.test.js.map +1 -1
  8. package/dist/Entity.types.d.ts +2 -2
  9. package/dist/Entity.types.js +1 -2
  10. package/dist/Nymph.d.ts +5 -5
  11. package/dist/Nymph.js +8 -14
  12. package/dist/Nymph.js.map +1 -1
  13. package/dist/Nymph.types.d.ts +2 -2
  14. package/dist/Nymph.types.js +2 -5
  15. package/dist/Nymph.types.js.map +1 -1
  16. package/dist/conf/d.d.ts +8 -0
  17. package/dist/conf/d.js +1 -2
  18. package/dist/conf/defaults.d.ts +1 -1
  19. package/dist/conf/defaults.js +6 -10
  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 +4 -4
  25. package/dist/driver/NymphDriver.js +46 -50
  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 +1 -1
  31. package/dist/driver/testArtifacts.js +42 -48
  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.js +1 -5
  38. package/dist/errors/EntityInvalidDataError.js.map +1 -1
  39. package/dist/errors/EntityIsSleepingReferenceError.js +1 -5
  40. package/dist/errors/EntityIsSleepingReferenceError.js.map +1 -1
  41. package/dist/errors/EntityUniqueConstraintError.js +1 -5
  42. package/dist/errors/EntityUniqueConstraintError.js.map +1 -1
  43. package/dist/errors/InvalidParametersError.js +1 -5
  44. package/dist/errors/InvalidParametersError.js.map +1 -1
  45. package/dist/errors/InvalidStateError.js +1 -5
  46. package/dist/errors/InvalidStateError.js.map +1 -1
  47. package/dist/errors/NotConfiguredError.js +1 -5
  48. package/dist/errors/NotConfiguredError.js.map +1 -1
  49. package/dist/errors/QueryFailedError.js +1 -5
  50. package/dist/errors/QueryFailedError.js.map +1 -1
  51. package/dist/errors/UnableToConnectError.js +1 -5
  52. package/dist/errors/UnableToConnectError.js.map +1 -1
  53. package/dist/errors/index.d.ts +10 -10
  54. package/dist/errors/index.js +10 -26
  55. package/dist/errors/index.js.map +1 -1
  56. package/dist/index.d.ts +11 -11
  57. package/dist/index.js +14 -34
  58. package/dist/index.js.map +1 -1
  59. package/dist/nymphJoiProps.js +10 -15
  60. package/dist/nymphJoiProps.js.map +1 -1
  61. package/dist/testArtifacts.d.ts +1 -1
  62. package/dist/testArtifacts.js +4 -13
  63. package/dist/testArtifacts.js.map +1 -1
  64. package/dist/testMocks.d.ts +4 -4
  65. package/dist/testMocks.js +9 -17
  66. package/dist/testMocks.js.map +1 -1
  67. package/dist/utils.d.ts +2 -2
  68. package/dist/utils.js +9 -21
  69. package/dist/utils.js.map +1 -1
  70. package/jest.config.js +11 -2
  71. package/package.json +16 -15
  72. package/src/Entity.test.ts +5 -3
  73. package/src/Entity.ts +8 -9
  74. package/src/Entity.types.ts +2 -2
  75. package/src/Nymph.ts +254 -254
  76. package/src/Nymph.types.ts +2 -2
  77. package/src/conf/d.ts +8 -0
  78. package/src/conf/defaults.ts +3 -1
  79. package/src/conf/index.ts +2 -2
  80. package/src/driver/NymphDriver.ts +17 -12
  81. package/src/driver/index.ts +2 -2
  82. package/src/driver/testArtifacts.ts +9 -5
  83. package/src/errors/index.ts +10 -10
  84. package/src/index.ts +11 -11
  85. package/src/testArtifacts.ts +1 -1
  86. package/src/testMocks.ts +6 -6
  87. package/src/type/locutus.d.ts +3 -0
  88. package/src/utils.ts +4 -4
  89. package/tsconfig.json +3 -1
@@ -1,21 +1,24 @@
1
- import fs from 'fs';
2
- import { difference } from 'lodash';
1
+ import fs from 'node:fs';
2
+ import { difference } from 'lodash-es';
3
3
  import ReadLines from 'n-readlines';
4
- import strtotime from 'locutus/php/datetime/strtotime';
4
+ import strtotime from 'locutus/php/datetime/strtotime.js';
5
5
  import { guid } from '@nymphjs/guid';
6
6
 
7
- import type Nymph from '../Nymph';
8
- import type { Selector, Options, FormattedSelector } from '../Nymph.types';
9
- import Entity, { type EntityInstanceType } from '../Entity';
7
+ import type Nymph from '../Nymph.js';
8
+ import type { Selector, Options, FormattedSelector } from '../Nymph.types.js';
9
+ import Entity, { type EntityInstanceType } from '../Entity.js';
10
10
  import type {
11
11
  EntityConstructor,
12
12
  EntityData,
13
13
  EntityInterface,
14
14
  EntityReference,
15
15
  SerializedEntityData,
16
- } from '../Entity.types';
17
- import { InvalidParametersError, UnableToConnectError } from '../errors';
18
- import { xor } from '../utils';
16
+ } from '../Entity.types.js';
17
+ import {
18
+ InvalidParametersError,
19
+ UnableToConnectError,
20
+ } from '../errors/index.js';
21
+ import { xor } from '../utils.js';
19
22
 
20
23
  // from: https://stackoverflow.com/a/6969486/664915
21
24
  function escapeRegExp(string: string): string {
@@ -910,8 +913,8 @@ export default abstract class NymphDriver {
910
913
  ? 1
911
914
  : 0
912
915
  : options.return === 'guid'
913
- ? [guid]
914
- : [entity],
916
+ ? [guid]
917
+ : [entity],
915
918
  };
916
919
  }
917
920
  }
@@ -1035,7 +1038,9 @@ export default abstract class NymphDriver {
1035
1038
  | null = null,
1036
1039
  ) {
1037
1040
  // Get a modified date.
1038
- const mdate = Date.now();
1041
+ const mdate = this.nymph.config.updateMDate
1042
+ ? Date.now()
1043
+ : (entity.mdate ?? Date.now());
1039
1044
  const tags = difference(entity.tags, ['']);
1040
1045
  const data = entity.$getData();
1041
1046
  const sdata = entity.$getSData();
@@ -1,4 +1,4 @@
1
- import NymphDriver from './NymphDriver';
1
+ import NymphDriver from './NymphDriver.js';
2
2
  export { NymphDriver };
3
3
 
4
- export * from './testArtifacts';
4
+ export * from './testArtifacts.js';
@@ -1,15 +1,19 @@
1
- import fs from 'fs';
2
- import strtotime from 'locutus/php/datetime/strtotime';
1
+ import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import fs from 'node:fs';
4
+ import strtotime from 'locutus/php/datetime/strtotime.js';
3
5
  import { guid } from '@nymphjs/guid';
4
6
 
5
- import type Nymph from '../Nymph';
6
- import { EntityUniqueConstraintError } from '../errors';
7
+ import type Nymph from '../Nymph.js';
8
+ import { EntityUniqueConstraintError } from '../errors/index.js';
7
9
  import {
8
10
  TestBModel as TestBModelClass,
9
11
  TestModel as TestModelClass,
10
12
  TestModelData,
11
13
  TestEmptyModel as TestEmptyModelClass,
12
- } from '../testArtifacts';
14
+ } from '../testArtifacts.js';
15
+
16
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
17
 
14
18
  export function EntitiesTest(
15
19
  nymph: Nymph,
@@ -1,19 +1,19 @@
1
- export * from './ClassNotAvailableError';
1
+ export * from './ClassNotAvailableError.js';
2
2
 
3
- export * from './EntityConflictError';
3
+ export * from './EntityConflictError.js';
4
4
 
5
- export * from './EntityInvalidDataError';
5
+ export * from './EntityInvalidDataError.js';
6
6
 
7
- export * from './EntityIsSleepingReferenceError';
7
+ export * from './EntityIsSleepingReferenceError.js';
8
8
 
9
- export * from './EntityUniqueConstraintError';
9
+ export * from './EntityUniqueConstraintError.js';
10
10
 
11
- export * from './InvalidParametersError';
11
+ export * from './InvalidParametersError.js';
12
12
 
13
- export * from './InvalidStateError';
13
+ export * from './InvalidStateError.js';
14
14
 
15
- export * from './NotConfiguredError';
15
+ export * from './NotConfiguredError.js';
16
16
 
17
- export * from './QueryFailedError';
17
+ export * from './QueryFailedError.js';
18
18
 
19
- export * from './UnableToConnectError';
19
+ export * from './UnableToConnectError.js';
package/src/index.ts CHANGED
@@ -1,20 +1,20 @@
1
- export * from './conf';
2
- export * from './driver';
3
- export * from './errors';
1
+ export * from './conf/index.js';
2
+ export * from './driver/index.js';
3
+ export * from './errors/index.js';
4
4
 
5
- export * from './Entity.types';
5
+ export * from './Entity.types.js';
6
6
 
7
- export * from './Entity';
8
- import Entity from './Entity';
7
+ export * from './Entity.js';
8
+ import Entity from './Entity.js';
9
9
  export { Entity };
10
10
 
11
- export * from './Nymph.types';
11
+ export * from './Nymph.types.js';
12
12
 
13
- export * from './Nymph';
14
- import Nymph from './Nymph';
13
+ export * from './Nymph.js';
14
+ import Nymph from './Nymph.js';
15
15
  export { Nymph };
16
16
 
17
- import nymphJoiProps from './nymphJoiProps';
17
+ import nymphJoiProps from './nymphJoiProps.js';
18
18
  export { nymphJoiProps };
19
19
 
20
- export * from './utils';
20
+ export * from './utils.js';
@@ -1,4 +1,4 @@
1
- import Entity from './Entity';
1
+ import Entity from './Entity.js';
2
2
 
3
3
  export type TestModelData = {
4
4
  name?: string;
package/src/testMocks.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  import { guid } from '@nymphjs/guid';
2
2
 
3
- import type Nymph from './Nymph';
4
- import type { EntityInstanceType } from './Entity';
3
+ import type Nymph from './Nymph.js';
4
+ import type { EntityInstanceType } from './Entity.js';
5
5
  import type {
6
6
  EntityConstructor,
7
7
  EntityInterface,
8
8
  EntityJson,
9
- } from './Entity.types';
10
- import { Options, Selector } from './Nymph.types';
11
- import { ClassNotAvailableError } from './errors';
12
- import Entity from './Entity';
9
+ } from './Entity.types.js';
10
+ import { Options, Selector } from './Nymph.types.js';
11
+ import { ClassNotAvailableError } from './errors/index.js';
12
+ import Entity from './Entity.js';
13
13
 
14
14
  const entities: { [k: string]: EntityJson } = {};
15
15
 
@@ -0,0 +1,3 @@
1
+ declare module 'locutus/php/datetime/strtotime.js' {
2
+ export default function (str: string, now?: number): number;
3
+ }
package/src/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
- import Entity from './Entity';
2
- import { EntityReference } from './Entity.types';
3
- import Nymph from './Nymph';
4
- import { Options, Selector } from './Nymph.types';
1
+ import Entity from './Entity.js';
2
+ import { EntityReference } from './Entity.types.js';
3
+ import Nymph from './Nymph.js';
4
+ import { Options, Selector } from './Nymph.types.js';
5
5
 
6
6
  export function xor(a: any, b: any): boolean {
7
7
  return !!(a && !b) || (!a && b);
package/tsconfig.json CHANGED
@@ -2,7 +2,9 @@
2
2
  "extends": "@tsconfig/recommended/tsconfig.json",
3
3
 
4
4
  "compilerOptions": {
5
- "lib": ["ES2023"],
5
+ "module": "ES2022",
6
+ "moduleResolution": "node",
7
+ "lib": ["ES2022"],
6
8
  "target": "ES2022",
7
9
  "noImplicitAny": true,
8
10
  "removeComments": false,