@tsofist/schema-forge 2.5.1 → 2.7.0

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.
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const guards_1 = require("@tsofist/stem/lib/cldr/date-time/guards");
4
4
  const types_1 = require("@tsofist/stem/lib/cldr/date-time/types");
5
5
  const enum_1 = require("@tsofist/stem/lib/enum");
6
- const guards_2 = require("@tsofist/stem/lib/number/guards");
6
+ const guards_2 = require("@tsofist/stem/lib/number/integer/guards");
7
7
  const entries_1 = require("@tsofist/stem/lib/object/entries");
8
8
  const camel_1 = require("@tsofist/stem/lib/string/case/camel");
9
9
  const fake_generator_1 = require("./fake-generator");
@@ -95,7 +95,7 @@ describe('validator for a7', () => {
95
95
  expect(initial).toStrictEqual(2);
96
96
  validator.warmupCacheSync();
97
97
  const warmed = validator.compilationArtifactCount;
98
- expect(warmed).toStrictEqual(10);
98
+ expect(warmed).toStrictEqual(9);
99
99
  validator.clear();
100
100
  const cleared = validator.compilationArtifactCount;
101
101
  expect(cleared).toStrictEqual(1);
@@ -471,8 +471,12 @@ describe('generator for a1', () => {
471
471
  expect(forgeSchemaResult.refs.length).toStrictEqual(10);
472
472
  });
473
473
  it('getSchema', () => {
474
- expect(validator.getValidator('test#/definitions/Int').schema).toStrictEqual({
474
+ expect(validator.getValidator('test#/definitions/PositiveInt').schema).toStrictEqual({
475
475
  type: 'integer',
476
+ minimum: 1,
477
+ maximum: 9007199254740991,
478
+ description: 'Positive integer value.',
479
+ faker: { 'number.int': [{ max: 10000, min: 1 }] },
476
480
  });
477
481
  expect(validator.getValidator('#/definitions/NotExists')).toStrictEqual(undefined);
478
482
  expect(validator.getSchema('test#/definitions/SomeName')).toStrictEqual({
@@ -486,14 +490,16 @@ describe('generator for a1', () => {
486
490
  });
487
491
  });
488
492
  it('hasSchema', () => {
489
- expect(validator.hasValidator('test#/definitions/Int')).toStrictEqual(true);
493
+ expect(validator.hasValidator('test#/definitions/SomeType1')).toStrictEqual(true);
494
+ expect(validator.hasValidator('test#/definitions/PositiveInt')).toStrictEqual(true);
495
+ expect(validator.hasValidator('test#/definitions/Int')).toStrictEqual(false);
490
496
  expect(validator.hasValidator('test#/definitions/!Int')).toStrictEqual(false);
491
497
  });
492
498
  it('checkBySchema', () => {
493
499
  expect(() => validator.checkBySchema('test#/definitions/ExportedInterfaceB_InterfaceDeclaration', {})).toThrow(types_1.SchemaForgeValidationErrorCode);
494
- expect(validator.checkBySchema('test#/definitions/Int', 1)).toStrictEqual(true);
495
- expect(() => validator.checkBySchema('test#/definitions/Int', 1.1)).toThrow(types_1.SchemaForgeValidationErrorCode);
496
- expect(() => validator.checkBySchema('!test#/definitions/Int', 1)).toThrow(types_1.SchemaNotFoundErrorCode);
500
+ expect(validator.checkBySchema('test#/definitions/PositiveInt', 1)).toStrictEqual(true);
501
+ expect(() => validator.checkBySchema('test#/definitions/PositiveInt', 1.1)).toThrow(types_1.SchemaForgeValidationErrorCode);
502
+ expect(() => validator.checkBySchema('!test#/definitions/PositiveInt', 1)).toThrow(types_1.SchemaNotFoundErrorCode);
497
503
  {
498
504
  const schema = '!test#/definitions/Int';
499
505
  try {
@@ -510,7 +516,7 @@ describe('generator for a1', () => {
510
516
  }
511
517
  }
512
518
  {
513
- const schema = 'test#/definitions/Int';
519
+ const schema = 'test#/definitions/PositiveInt';
514
520
  const message = 'ERROR!';
515
521
  try {
516
522
  validator.checkBySchema(schema, 1.1, { errorMessage: message });
@@ -568,13 +574,6 @@ describe('generator for a1', () => {
568
574
  interface: 'ExportedInterfaceB',
569
575
  method: 'methodB',
570
576
  },
571
- {
572
- ref: 'test#/definitions/Int',
573
- kind: 0,
574
- name: 'Int',
575
- schemaId: 'test',
576
- type: 'Int',
577
- },
578
577
  {
579
578
  ref: 'test#/definitions/NonExportedInterfaceD_InterfaceDeclaration',
580
579
  kind: 1,
@@ -625,7 +624,7 @@ describe('generator for a1', () => {
625
624
  defsByName[def.name] = def;
626
625
  }
627
626
  expect(validator.listDefinitions()).toStrictEqual(defs);
628
- expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.Type && !info.name.startsWith('Some'))).toStrictEqual([defsByName['Int'], defsByName['PositiveInt']]);
627
+ expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.Type && !info.name.startsWith('Some'))).toStrictEqual([defsByName['PositiveInt']]);
629
628
  expect(validator.listDefinitions((info) => info.kind === types_1.SchemaDefinitionKind.API)).toStrictEqual([
630
629
  defsByName['ExportedInterfaceB_InterfaceDeclaration'],
631
630
  defsByName['NonExportedInterfaceD_InterfaceDeclaration'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsofist/schema-forge",
3
- "version": "2.5.1",
3
+ "version": "2.7.0",
4
4
  "description": "Generate JSON schema from TypeScript types",
5
5
  "author": "Andrew Berdnikov <tsofistgudmen@gmail.com>",
6
6
  "license": "LGPL-3.0",
@@ -20,11 +20,11 @@
20
20
  "test:watch": "jest --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@faker-js/faker": "^9.6.0",
24
- "@tsofist/stem": "^2.2.0",
23
+ "@faker-js/faker": "^9.7.0",
24
+ "@tsofist/stem": "^4.0.0",
25
25
  "ajv": "^8.17.1",
26
26
  "ajv-formats": "^3.0.1",
27
- "json-schema-faker": "^0.5.8",
27
+ "json-schema-faker": "^0.5.9",
28
28
  "jsonpath-plus": "^10.3.0",
29
29
  "ts-json-schema-generator": "~2.3.0",
30
30
  "tslib": "^2.8.1"
@@ -32,13 +32,13 @@
32
32
  "devDependencies": {
33
33
  "@tsofist/web-buddy": "^1.21.0",
34
34
  "@types/jest": "^29.5.14",
35
- "@types/node": "^20.17.28",
35
+ "@types/node": "^20.17.30",
36
36
  "@types/supertest": "^6.0.3",
37
- "jest": "^29.7.0",
37
+ "jest": "~29.7.0",
38
38
  "rimraf": "^6.0.1",
39
39
  "supertest": "^7.1.0",
40
- "ts-jest": "^29.3.0",
41
- "typescript": "~5.8.2"
40
+ "ts-jest": "~29.3.2",
41
+ "typescript": "~5.8.3"
42
42
  },
43
43
  "publishConfig": {
44
44
  "registry": "https://registry.npmjs.org/",