@twin.org/data-framework 0.0.2-next.4 → 0.0.3-next.2
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.
- package/dist/{esm/index.mjs → es/dataTypes/frameworkDataTypes.js} +9 -61
- package/dist/es/dataTypes/frameworkDataTypes.js.map +1 -0
- package/dist/es/index.js +6 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/frameworkContexts.js +13 -0
- package/dist/es/models/frameworkContexts.js.map +1 -0
- package/dist/es/models/frameworkTypes.js +21 -0
- package/dist/es/models/frameworkTypes.js.map +1 -0
- package/dist/es/schemas/TimestampMilliseconds.json +4 -0
- package/dist/es/schemas/TimestampSeconds.json +4 -0
- package/dist/es/schemas/URN.json +4 -0
- package/dist/types/index.d.ts +3 -3
- package/docs/changelog.md +38 -0
- package/package.json +7 -9
- package/dist/cjs/index.cjs +0 -97
|
@@ -1,67 +1,16 @@
|
|
|
1
|
-
import { Urn, Validation } from '@twin.org/core';
|
|
2
|
-
import { DataTypeHandlerFactory } from '@twin.org/data-core';
|
|
3
|
-
|
|
4
|
-
// Copyright 2024 IOTA Stiftung.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
6
|
-
/**
|
|
7
|
-
* The contexts of framework data.
|
|
8
|
-
*/
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
10
|
-
const FrameworkContexts = {
|
|
11
|
-
/**
|
|
12
|
-
* Context Root.
|
|
13
|
-
*/
|
|
14
|
-
ContextRoot: "https://schema.twindev.org/framework/"
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Copyright 2024 IOTA Stiftung.
|
|
18
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
19
|
-
/**
|
|
20
|
-
* The types of framework data.
|
|
21
|
-
*/
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
23
|
-
const FrameworkTypes = {
|
|
24
|
-
/**
|
|
25
|
-
* Represents a urn.
|
|
26
|
-
*/
|
|
27
|
-
Urn: "URN",
|
|
28
|
-
/**
|
|
29
|
-
* Represents a timestamp as an integer, milliseconds since 1 Jan 1970.
|
|
30
|
-
*/
|
|
31
|
-
TimestampMilliseconds: "TimestampMilliseconds",
|
|
32
|
-
/**
|
|
33
|
-
* Represents a timestamp as an integer, seconds since 1 Jan 1970.
|
|
34
|
-
*/
|
|
35
|
-
TimestampSeconds: "TimestampSeconds"
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
var type$2 = "integer";
|
|
39
|
-
var minimum$1 = 0;
|
|
40
|
-
var TimestampMillisecondsSchema = {
|
|
41
|
-
type: type$2,
|
|
42
|
-
minimum: minimum$1
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var type$1 = "integer";
|
|
46
|
-
var minimum = 0;
|
|
47
|
-
var TimestampSecondsSchema = {
|
|
48
|
-
type: type$1,
|
|
49
|
-
minimum: minimum
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var type = "string";
|
|
53
|
-
var format = "uri";
|
|
54
|
-
var URNSchema = {
|
|
55
|
-
type: type,
|
|
56
|
-
format: format
|
|
57
|
-
};
|
|
58
|
-
|
|
59
1
|
// Copyright 2024 IOTA Stiftung.
|
|
60
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Urn, Validation } from "@twin.org/core";
|
|
4
|
+
import { DataTypeHandlerFactory } from "@twin.org/data-core";
|
|
5
|
+
import { FrameworkContexts } from "../models/frameworkContexts.js";
|
|
6
|
+
import { FrameworkTypes } from "../models/frameworkTypes.js";
|
|
7
|
+
import TimestampMillisecondsSchema from "../schemas/TimestampMilliseconds.json" with { type: "json" };
|
|
8
|
+
import TimestampSecondsSchema from "../schemas/TimestampSeconds.json" with { type: "json" };
|
|
9
|
+
import URNSchema from "../schemas/URN.json" with { type: "json" };
|
|
61
10
|
/**
|
|
62
11
|
* Handle all the framework data types.
|
|
63
12
|
*/
|
|
64
|
-
class FrameworkDataTypes {
|
|
13
|
+
export class FrameworkDataTypes {
|
|
65
14
|
/**
|
|
66
15
|
* Register all the data types.
|
|
67
16
|
*/
|
|
@@ -89,5 +38,4 @@ class FrameworkDataTypes {
|
|
|
89
38
|
}));
|
|
90
39
|
}
|
|
91
40
|
}
|
|
92
|
-
|
|
93
|
-
export { FrameworkContexts, FrameworkDataTypes, FrameworkTypes };
|
|
41
|
+
//# sourceMappingURL=frameworkDataTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkDataTypes.js","sourceRoot":"","sources":["../../../src/dataTypes/frameworkDataTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAoB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,2BAA2B,MAAM,uCAAuC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACtG,OAAO,sBAAsB,MAAM,kCAAkC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5F,OAAO,SAAS,MAAM,qBAAqB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAElE;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAC,aAAa;QAC1B,sBAAsB,CAAC,QAAQ,CAC9B,GAAG,iBAAiB,CAAC,WAAW,GAAG,cAAc,CAAC,GAAG,EAAE,EACvD,GAAG,EAAE,CAAC,CAAC;YACN,OAAO,EAAE,iBAAiB,CAAC,WAAW;YACtC,IAAI,EAAE,cAAc,CAAC,GAAG;YACxB,YAAY,EAAE,EAAE;YAChB,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,SAAwB;YAChD,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,CAC5D,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SAC5C,CAAC,CACF,CAAC;QAEF,sBAAsB,CAAC,QAAQ,CAC9B,GAAG,iBAAiB,CAAC,WAAW,GAAG,cAAc,CAAC,qBAAqB,EAAE,EACzE,GAAG,EAAE,CAAC,CAAC;YACN,OAAO,EAAE,iBAAiB,CAAC,WAAW;YACtC,IAAI,EAAE,cAAc,CAAC,qBAAqB;YAC1C,YAAY,EAAE,IAAI,CAAC,GAAG,EAAE;YACxB,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,2BAA0C;YAClE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,CAC5D,UAAU,CAAC,qBAAqB,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SAChE,CAAC,CACF,CAAC;QAEF,sBAAsB,CAAC,QAAQ,CAC9B,GAAG,iBAAiB,CAAC,WAAW,GAAG,cAAc,CAAC,gBAAgB,EAAE,EACpE,GAAG,EAAE,CAAC,CAAC;YACN,OAAO,EAAE,iBAAiB,CAAC,WAAW;YACtC,IAAI,EAAE,cAAc,CAAC,gBAAgB;YACrC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;YAC3C,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,sBAAqC;YAC7D,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,CAC5D,UAAU,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,EAAE,QAAQ,CAAC;SAC3D,CAAC,CACF,CAAC;IACH,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Urn, Validation } from \"@twin.org/core\";\nimport { DataTypeHandlerFactory, type IJsonSchema } from \"@twin.org/data-core\";\nimport { FrameworkContexts } from \"../models/frameworkContexts.js\";\nimport { FrameworkTypes } from \"../models/frameworkTypes.js\";\nimport TimestampMillisecondsSchema from \"../schemas/TimestampMilliseconds.json\" with { type: \"json\" };\nimport TimestampSecondsSchema from \"../schemas/TimestampSeconds.json\" with { type: \"json\" };\nimport URNSchema from \"../schemas/URN.json\" with { type: \"json\" };\n\n/**\n * Handle all the framework data types.\n */\nexport class FrameworkDataTypes {\n\t/**\n\t * Register all the data types.\n\t */\n\tpublic static registerTypes(): void {\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${FrameworkContexts.ContextRoot}${FrameworkTypes.Urn}`,\n\t\t\t() => ({\n\t\t\t\tcontext: FrameworkContexts.ContextRoot,\n\t\t\t\ttype: FrameworkTypes.Urn,\n\t\t\t\tdefaultValue: \"\",\n\t\t\t\tjsonSchema: async () => URNSchema as IJsonSchema,\n\t\t\t\tvalidate: async (propertyName, value, failures, container) =>\n\t\t\t\t\tUrn.validate(propertyName, value, failures)\n\t\t\t})\n\t\t);\n\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${FrameworkContexts.ContextRoot}${FrameworkTypes.TimestampMilliseconds}`,\n\t\t\t() => ({\n\t\t\t\tcontext: FrameworkContexts.ContextRoot,\n\t\t\t\ttype: FrameworkTypes.TimestampMilliseconds,\n\t\t\t\tdefaultValue: Date.now(),\n\t\t\t\tjsonSchema: async () => TimestampMillisecondsSchema as IJsonSchema,\n\t\t\t\tvalidate: async (propertyName, value, failures, container) =>\n\t\t\t\t\tValidation.timestampMilliseconds(propertyName, value, failures)\n\t\t\t})\n\t\t);\n\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${FrameworkContexts.ContextRoot}${FrameworkTypes.TimestampSeconds}`,\n\t\t\t() => ({\n\t\t\t\tcontext: FrameworkContexts.ContextRoot,\n\t\t\t\ttype: FrameworkTypes.TimestampSeconds,\n\t\t\t\tdefaultValue: Math.floor(Date.now() / 1000),\n\t\t\t\tjsonSchema: async () => TimestampSecondsSchema as IJsonSchema,\n\t\t\t\tvalidate: async (propertyName, value, failures, container) =>\n\t\t\t\t\tValidation.timestampSeconds(propertyName, value, failures)\n\t\t\t})\n\t\t);\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataTypes/frameworkDataTypes.js\";\nexport * from \"./models/frameworkContexts.js\";\nexport * from \"./models/frameworkTypes.js\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The contexts of framework data.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const FrameworkContexts = {
|
|
8
|
+
/**
|
|
9
|
+
* Context Root.
|
|
10
|
+
*/
|
|
11
|
+
ContextRoot: "https://schema.twindev.org/framework/"
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=frameworkContexts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkContexts.js","sourceRoot":"","sources":["../../../src/models/frameworkContexts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAChC;;OAEG;IACH,WAAW,EAAE,uCAAuC;CAC3C,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts of framework data.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const FrameworkContexts = {\n\t/**\n\t * Context Root.\n\t */\n\tContextRoot: \"https://schema.twindev.org/framework/\"\n} as const;\n\n/**\n * The contexts of framework data.\n */\nexport type FrameworkContexts = (typeof FrameworkContexts)[keyof typeof FrameworkContexts];\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
/**
|
|
4
|
+
* The types of framework data.
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
export const FrameworkTypes = {
|
|
8
|
+
/**
|
|
9
|
+
* Represents a urn.
|
|
10
|
+
*/
|
|
11
|
+
Urn: "URN",
|
|
12
|
+
/**
|
|
13
|
+
* Represents a timestamp as an integer, milliseconds since 1 Jan 1970.
|
|
14
|
+
*/
|
|
15
|
+
TimestampMilliseconds: "TimestampMilliseconds",
|
|
16
|
+
/**
|
|
17
|
+
* Represents a timestamp as an integer, seconds since 1 Jan 1970.
|
|
18
|
+
*/
|
|
19
|
+
TimestampSeconds: "TimestampSeconds"
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=frameworkTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworkTypes.js","sourceRoot":"","sources":["../../../src/models/frameworkTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,GAAG,EAAE,KAAK;IAEV;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAE9C;;OAEG;IACH,gBAAgB,EAAE,kBAAkB;CAC3B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The types of framework data.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const FrameworkTypes = {\n\t/**\n\t * Represents a urn.\n\t */\n\tUrn: \"URN\",\n\n\t/**\n\t * Represents a timestamp as an integer, milliseconds since 1 Jan 1970.\n\t */\n\tTimestampMilliseconds: \"TimestampMilliseconds\",\n\n\t/**\n\t * Represents a timestamp as an integer, seconds since 1 Jan 1970.\n\t */\n\tTimestampSeconds: \"TimestampSeconds\"\n} as const;\n\n/**\n * The types of framework data.\n */\nexport type FrameworkTypes = (typeof FrameworkTypes)[keyof typeof FrameworkTypes];\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./dataTypes/frameworkDataTypes";
|
|
2
|
-
export * from "./models/frameworkContexts";
|
|
3
|
-
export * from "./models/frameworkTypes";
|
|
1
|
+
export * from "./dataTypes/frameworkDataTypes.js";
|
|
2
|
+
export * from "./models/frameworkContexts.js";
|
|
3
|
+
export * from "./models/frameworkTypes.js";
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @twin.org/data-framework - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.2](https://github.com/twinfoundation/data/compare/data-framework-v0.0.3-next.1...data-framework-v0.0.3-next.2) (2025-11-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **data-framework:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/data-core bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
16
|
+
* @twin.org/data-json-ld bumped from 0.0.3-next.1 to 0.0.3-next.2
|
|
17
|
+
|
|
18
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/data/compare/data-framework-v0.0.3-next.0...data-framework-v0.0.3-next.1) (2025-11-10)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add context id features ([#25](https://github.com/twinfoundation/data/issues/25)) ([6592f2e](https://github.com/twinfoundation/data/commit/6592f2e4e59021cc42a079a4f46242758a54313d))
|
|
24
|
+
* add document cache access methods ([dbf1e36](https://github.com/twinfoundation/data/commit/dbf1e36d176c5f428f8c52628fb5a1ff7a6a174a))
|
|
25
|
+
* add validate-locales ([cf9b761](https://github.com/twinfoundation/data/commit/cf9b76160820fe0b13b4fe56ed241c1d5511b7c1))
|
|
26
|
+
* eslint migration to flat config ([b0db6e6](https://github.com/twinfoundation/data/commit/b0db6e69a90046fc60d29e4273fcdfee13c16088))
|
|
27
|
+
* expand Json LD Keyword ([70632d1](https://github.com/twinfoundation/data/commit/70632d1e11ad85cf3c57e118476b125a673f1681))
|
|
28
|
+
* update framework core ([c077b8c](https://github.com/twinfoundation/data/commit/c077b8c07e7ee66b5482254eab6f2a52cd911270))
|
|
29
|
+
* use fully qualified names for data type lookups ([b7b5c74](https://github.com/twinfoundation/data/commit/b7b5c746b0180a87baa976f6a7a76cedd53d8ff7))
|
|
30
|
+
* use shared store mechanism ([#3](https://github.com/twinfoundation/data/issues/3)) ([33eb221](https://github.com/twinfoundation/data/commit/33eb221ccec2b4a79549c06e9a04225009b93a46))
|
|
31
|
+
* use updated Is.function ([46a4715](https://github.com/twinfoundation/data/commit/46a4715f995aea34f2011138662fe003c9727d07))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Dependencies
|
|
35
|
+
|
|
36
|
+
* The following workspace dependencies were updated
|
|
37
|
+
* dependencies
|
|
38
|
+
* @twin.org/data-core bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
39
|
+
* @twin.org/data-json-ld bumped from 0.0.3-next.0 to 0.0.3-next.1
|
|
40
|
+
|
|
3
41
|
## [0.0.2-next.4](https://github.com/twinfoundation/data/compare/data-framework-v0.0.2-next.3...data-framework-v0.0.2-next.4) (2025-10-09)
|
|
4
42
|
|
|
5
43
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3-next.2",
|
|
4
4
|
"description": "Models which define the structure of framework types",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,25 +15,23 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.
|
|
19
|
-
"@twin.org/data-json-ld": "0.0.
|
|
18
|
+
"@twin.org/data-core": "0.0.3-next.2",
|
|
19
|
+
"@twin.org/data-json-ld": "0.0.3-next.2",
|
|
20
20
|
"@twin.org/entity": "next",
|
|
21
21
|
"@twin.org/nameof": "next"
|
|
22
22
|
},
|
|
23
|
-
"main": "./dist/
|
|
24
|
-
"module": "./dist/esm/index.mjs",
|
|
23
|
+
"main": "./dist/es/index.js",
|
|
25
24
|
"types": "./dist/types/index.d.ts",
|
|
26
25
|
"exports": {
|
|
27
26
|
".": {
|
|
28
27
|
"types": "./dist/types/index.d.ts",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"import": "./dist/es/index.js",
|
|
29
|
+
"default": "./dist/es/index.js"
|
|
31
30
|
},
|
|
32
31
|
"./locales/*.json": "./locales/*.json"
|
|
33
32
|
},
|
|
34
33
|
"files": [
|
|
35
|
-
"dist/
|
|
36
|
-
"dist/esm",
|
|
34
|
+
"dist/es",
|
|
37
35
|
"dist/types",
|
|
38
36
|
"locales",
|
|
39
37
|
"docs"
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@twin.org/core');
|
|
4
|
-
var dataCore = require('@twin.org/data-core');
|
|
5
|
-
|
|
6
|
-
// Copyright 2024 IOTA Stiftung.
|
|
7
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
8
|
-
/**
|
|
9
|
-
* The contexts of framework data.
|
|
10
|
-
*/
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
12
|
-
const FrameworkContexts = {
|
|
13
|
-
/**
|
|
14
|
-
* Context Root.
|
|
15
|
-
*/
|
|
16
|
-
ContextRoot: "https://schema.twindev.org/framework/"
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Copyright 2024 IOTA Stiftung.
|
|
20
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
21
|
-
/**
|
|
22
|
-
* The types of framework data.
|
|
23
|
-
*/
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
-
const FrameworkTypes = {
|
|
26
|
-
/**
|
|
27
|
-
* Represents a urn.
|
|
28
|
-
*/
|
|
29
|
-
Urn: "URN",
|
|
30
|
-
/**
|
|
31
|
-
* Represents a timestamp as an integer, milliseconds since 1 Jan 1970.
|
|
32
|
-
*/
|
|
33
|
-
TimestampMilliseconds: "TimestampMilliseconds",
|
|
34
|
-
/**
|
|
35
|
-
* Represents a timestamp as an integer, seconds since 1 Jan 1970.
|
|
36
|
-
*/
|
|
37
|
-
TimestampSeconds: "TimestampSeconds"
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var type$2 = "integer";
|
|
41
|
-
var minimum$1 = 0;
|
|
42
|
-
var TimestampMillisecondsSchema = {
|
|
43
|
-
type: type$2,
|
|
44
|
-
minimum: minimum$1
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
var type$1 = "integer";
|
|
48
|
-
var minimum = 0;
|
|
49
|
-
var TimestampSecondsSchema = {
|
|
50
|
-
type: type$1,
|
|
51
|
-
minimum: minimum
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
var type = "string";
|
|
55
|
-
var format = "uri";
|
|
56
|
-
var URNSchema = {
|
|
57
|
-
type: type,
|
|
58
|
-
format: format
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Copyright 2024 IOTA Stiftung.
|
|
62
|
-
// SPDX-License-Identifier: Apache-2.0.
|
|
63
|
-
/**
|
|
64
|
-
* Handle all the framework data types.
|
|
65
|
-
*/
|
|
66
|
-
class FrameworkDataTypes {
|
|
67
|
-
/**
|
|
68
|
-
* Register all the data types.
|
|
69
|
-
*/
|
|
70
|
-
static registerTypes() {
|
|
71
|
-
dataCore.DataTypeHandlerFactory.register(`${FrameworkContexts.ContextRoot}${FrameworkTypes.Urn}`, () => ({
|
|
72
|
-
context: FrameworkContexts.ContextRoot,
|
|
73
|
-
type: FrameworkTypes.Urn,
|
|
74
|
-
defaultValue: "",
|
|
75
|
-
jsonSchema: async () => URNSchema,
|
|
76
|
-
validate: async (propertyName, value, failures, container) => core.Urn.validate(propertyName, value, failures)
|
|
77
|
-
}));
|
|
78
|
-
dataCore.DataTypeHandlerFactory.register(`${FrameworkContexts.ContextRoot}${FrameworkTypes.TimestampMilliseconds}`, () => ({
|
|
79
|
-
context: FrameworkContexts.ContextRoot,
|
|
80
|
-
type: FrameworkTypes.TimestampMilliseconds,
|
|
81
|
-
defaultValue: Date.now(),
|
|
82
|
-
jsonSchema: async () => TimestampMillisecondsSchema,
|
|
83
|
-
validate: async (propertyName, value, failures, container) => core.Validation.timestampMilliseconds(propertyName, value, failures)
|
|
84
|
-
}));
|
|
85
|
-
dataCore.DataTypeHandlerFactory.register(`${FrameworkContexts.ContextRoot}${FrameworkTypes.TimestampSeconds}`, () => ({
|
|
86
|
-
context: FrameworkContexts.ContextRoot,
|
|
87
|
-
type: FrameworkTypes.TimestampSeconds,
|
|
88
|
-
defaultValue: Math.floor(Date.now() / 1000),
|
|
89
|
-
jsonSchema: async () => TimestampSecondsSchema,
|
|
90
|
-
validate: async (propertyName, value, failures, container) => core.Validation.timestampSeconds(propertyName, value, failures)
|
|
91
|
-
}));
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
exports.FrameworkContexts = FrameworkContexts;
|
|
96
|
-
exports.FrameworkDataTypes = FrameworkDataTypes;
|
|
97
|
-
exports.FrameworkTypes = FrameworkTypes;
|