@twin.org/data-core 0.0.1-next.35 → 0.0.1-next.37

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var core = require('@twin.org/core');
4
4
  var web = require('@twin.org/web');
5
- var Ajv = require('ajv');
5
+ var Ajv = require('ajv/dist/2020.js');
6
6
  var addFormats = require('ajv-formats');
7
7
 
8
8
  // Copyright 2024 IOTA Stiftung.
@@ -249,7 +249,7 @@ class DataTypeHelper {
249
249
  properties: {
250
250
  value: data,
251
251
  schemaErrors: validationResult.error,
252
- message: validationResult.error.map(e => e.message).join(", ")
252
+ message: validationResult.error.map(e => e.message).join("\n")
253
253
  }
254
254
  });
255
255
  }
@@ -1,6 +1,6 @@
1
1
  import { Factory, Urn, Is, StringHelper } from '@twin.org/core';
2
2
  import { FetchHelper, HttpMethod } from '@twin.org/web';
3
- import Ajv from 'ajv';
3
+ import Ajv from 'ajv/dist/2020.js';
4
4
  import addFormats from 'ajv-formats';
5
5
 
6
6
  // Copyright 2024 IOTA Stiftung.
@@ -247,7 +247,7 @@ class DataTypeHelper {
247
247
  properties: {
248
248
  value: data,
249
249
  schemaErrors: validationResult.error,
250
- message: validationResult.error.map(e => e.message).join(", ")
250
+ message: validationResult.error.map(e => e.message).join("\n")
251
251
  }
252
252
  });
253
253
  }
@@ -2,6 +2,7 @@ export * from "./factories/dataTypeHandlerFactory";
2
2
  export * from "./factories/identifierHandlerFactory";
3
3
  export * from "./models/IDataTypeHandler";
4
4
  export * from "./models/IIdentifierHandler";
5
+ export * from "./models/IJsonSchema";
5
6
  export * from "./models/ISchemaValidationError";
6
7
  export * from "./models/ISchemaValidationResult";
7
8
  export * from "./models/validationMode";
@@ -1,5 +1,5 @@
1
1
  import type { IValidationFailure } from "@twin.org/core";
2
- import type { JSONSchema7 } from "json-schema";
2
+ import type { IJsonSchema } from "./IJsonSchema";
3
3
  /**
4
4
  * Interface describing a type which can handle a specific data type.
5
5
  */
@@ -20,7 +20,7 @@ export interface IDataTypeHandler {
20
20
  * Get the JSON schema for the data type.
21
21
  * @returns The JSON schema for the data type.
22
22
  */
23
- jsonSchema?(): Promise<JSONSchema7 | undefined>;
23
+ jsonSchema?(): Promise<IJsonSchema | undefined>;
24
24
  /**
25
25
  * A method for validating the data type.
26
26
  * @param propertyName The name of the property being validated.
@@ -0,0 +1,5 @@
1
+ import type { SchemaObject } from "ajv/dist/2020";
2
+ /**
3
+ * Default schema type.
4
+ */
5
+ export type IJsonSchema = SchemaObject;
@@ -1,5 +1,5 @@
1
1
  import type { IEntitySchema } from "@twin.org/entity";
2
- import type { JSONSchema7 } from "json-schema";
2
+ import type { IJsonSchema } from "../models/IJsonSchema";
3
3
  import type { ISchemaValidationResult } from "../models/ISchemaValidationResult";
4
4
  /**
5
5
  * A helper for JSON schemas.
@@ -16,8 +16,8 @@ export declare class JsonSchemaHelper {
16
16
  * @param additionalTypes Additional types to add for reference, not already in DataTypeHandlerFactory.
17
17
  * @returns Result containing errors if there are any.
18
18
  */
19
- static validate<T = unknown>(schema: JSONSchema7, data: T, additionalTypes?: {
20
- [id: string]: JSONSchema7;
19
+ static validate<T = unknown>(schema: IJsonSchema, data: T, additionalTypes?: {
20
+ [id: string]: IJsonSchema;
21
21
  }): Promise<ISchemaValidationResult>;
22
22
  /**
23
23
  * Get the property type from a schema.
@@ -25,12 +25,12 @@ export declare class JsonSchemaHelper {
25
25
  * @param propertyName The name of the property to get the type for.
26
26
  * @returns The types of the property.
27
27
  */
28
- static getPropertyType(schema: JSONSchema7, propertyName: string): string | undefined;
28
+ static getPropertyType(schema: IJsonSchema, propertyName: string): string | undefined;
29
29
  /**
30
30
  * Convert an entity schema to JSON schema e.g https://example.com/schemas/.
31
31
  * @param entitySchema The entity schema to convert.
32
32
  * @param baseDomain The base domain for local schemas e.g. https://example.com/
33
33
  * @returns The JSON schema for the entity.
34
34
  */
35
- static entitySchemaToJsonSchema(entitySchema: IEntitySchema | undefined, baseDomain?: string): JSONSchema7;
35
+ static entitySchemaToJsonSchema(entitySchema: IEntitySchema | undefined, baseDomain?: string): IJsonSchema;
36
36
  }
package/docs/changelog.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @twin.org/data-core - Changelog
2
2
 
3
+ ## [0.0.1-next.37](https://github.com/twinfoundation/data/compare/data-core-v0.0.1-next.36...data-core-v0.0.1-next.37) (2025-06-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * use updated JSON schema specs ([465223a](https://github.com/twinfoundation/data/commit/465223a9e9c24af546480ef084327a78fa366eaa))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * remove undici reference ([d77721e](https://github.com/twinfoundation/data/commit/d77721e21d23c7a6750c2f5cac8104851dfaa6d7))
14
+
15
+ ## [0.0.1-next.36](https://github.com/twinfoundation/data/compare/data-core-v0.0.1-next.35...data-core-v0.0.1-next.36) (2025-06-10)
16
+
17
+
18
+ ### Features
19
+
20
+ * expand Json LD Keyword ([70632d1](https://github.com/twinfoundation/data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
21
+
3
22
  ## [0.0.1-next.35](https://github.com/twinfoundation/data/compare/data-core-v0.0.1-next.34...data-core-v0.0.1-next.35) (2025-06-03)
4
23
 
5
24
 
@@ -38,7 +38,7 @@ Validates data against the schema.
38
38
 
39
39
  ##### schema
40
40
 
41
- `JSONSchema7`
41
+ `SchemaObject`
42
42
 
43
43
  The schema to validate the data with.
44
44
 
@@ -70,7 +70,7 @@ Get the property type from a schema.
70
70
 
71
71
  ##### schema
72
72
 
73
- `JSONSchema7`
73
+ `SchemaObject`
74
74
 
75
75
  The schema to extract the types from.
76
76
 
@@ -90,7 +90,7 @@ The types of the property.
90
90
 
91
91
  ### entitySchemaToJsonSchema()
92
92
 
93
- > `static` **entitySchemaToJsonSchema**(`entitySchema`, `baseDomain?`): `JSONSchema7`
93
+ > `static` **entitySchemaToJsonSchema**(`entitySchema`, `baseDomain?`): `SchemaObject`
94
94
 
95
95
  Convert an entity schema to JSON schema e.g https://example.com/schemas/.
96
96
 
@@ -110,6 +110,6 @@ The base domain for local schemas e.g. https://example.com/
110
110
 
111
111
  #### Returns
112
112
 
113
- `JSONSchema7`
113
+ `SchemaObject`
114
114
 
115
115
  The JSON schema for the entity.
@@ -13,6 +13,7 @@
13
13
 
14
14
  ## Type Aliases
15
15
 
16
+ - [IJsonSchema](type-aliases/IJsonSchema.md)
16
17
  - [ISchemaValidationError](type-aliases/ISchemaValidationError.md)
17
18
  - [ValidationMode](type-aliases/ValidationMode.md)
18
19
 
@@ -30,13 +30,13 @@ The default value for the item to use when constructing a new object.
30
30
 
31
31
  ### jsonSchema()?
32
32
 
33
- > `optional` **jsonSchema**(): `Promise`\<`undefined` \| `JSONSchema7`\>
33
+ > `optional` **jsonSchema**(): `Promise`\<`undefined` \| `SchemaObject`\>
34
34
 
35
35
  Get the JSON schema for the data type.
36
36
 
37
37
  #### Returns
38
38
 
39
- `Promise`\<`undefined` \| `JSONSchema7`\>
39
+ `Promise`\<`undefined` \| `SchemaObject`\>
40
40
 
41
41
  The JSON schema for the data type.
42
42
 
@@ -0,0 +1,5 @@
1
+ # Type Alias: IJsonSchema
2
+
3
+ > **IJsonSchema** = `SchemaObject`
4
+
5
+ Default schema type.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/data-core",
3
- "version": "0.0.1-next.35",
3
+ "version": "0.0.1-next.37",
4
4
  "description": "Definitions and helpers for using with data and schemas",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,6 @@
18
18
  "@twin.org/entity": "next",
19
19
  "@twin.org/nameof": "next",
20
20
  "@twin.org/web": "next",
21
- "@types/json-schema": "7.0.15",
22
21
  "ajv": "8.17.1",
23
22
  "ajv-formats": "3.0.1"
24
23
  },