@twin.org/data-json-ld 0.0.3-next.13 → 0.0.3-next.15
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/es/helpers/jsonLdHelperTypes.js.map +1 -1
- package/dist/es/schemas/JsonLdContextDefinition.json +1 -2
- package/dist/es/schemas/JsonLdDocument.json +1 -2
- package/dist/es/schemas/JsonLdExpandedTermDefinition.json +0 -2
- package/dist/es/schemas/JsonLdGraphObject.json +1 -2
- package/dist/es/schemas/JsonLdListObject.json +1 -2
- package/dist/es/schemas/JsonLdObject.json +1 -2
- package/dist/es/schemas/JsonLdSetObject.json +1 -2
- package/dist/es/schemas/JsonLdValueObject.json +0 -3
- package/dist/types/helpers/jsonLdHelperTypes.d.ts +13 -0
- package/docs/changelog.md +28 -0
- package/docs/reference/index.md +3 -0
- package/docs/reference/type-aliases/JsonLdObjectWithNoContext.md +12 -0
- package/docs/reference/type-aliases/JsonLdObjectWithNoId.md +11 -0
- package/docs/reference/type-aliases/JsonLdObjectWithNoType.md +11 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonLdHelperTypes.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdHelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\n\n/**\n * Extract the optional property names from a type.\n */\nexport type JsonLdOptionalKeys<T> = {\n\t[K in keyof T]-?: {} extends Pick<T, K> ? K : never;\n}[keyof T];\n\n/**\n * Extract the required property names from a type.\n */\nexport type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;\n\n/**\n * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.\n */\nexport type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}`\n\t? K\n\t: `${Prefix}:${K}`;\n\n/**\n * Remap an object type so JSON-LD keys (\"@...\") are preserved and\n * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving\n * each key's original required/optional status.\n */\nexport type JsonLdWithAliases<T extends object, Prefix extends string> = {\n\t[K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];\n} & {\n\t[K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];\n};\n\n/**\n * Keep only JSON-LD keys (\"@...\") from a type.\n */\nexport type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;\n\n/**\n * Create a JSON-LD object shape containing only JSON-LD keys plus aliased\n * non-JSON-LD keys.\n */\nexport type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> &\n\tJsonLdWithAliases<T, Prefix>;\n\n/**\n * Add \"@context\" to a type.\n */\nexport type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<\n\tT,\n\t\"@context\"\n> & {\n\t\"@context\": C;\n};\n\n/**\n * Infer an existing property's type from a source type, or fall back to a default.\n */\nexport type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {\n\t[K in P]?: infer PropertyType;\n}\n\t? Exclude<PropertyType, undefined>\n\t: D;\n\n/**\n * Add optional \"@context\" to a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithOptionalContext<\n\tT extends object,\n\tC = JsonLdExistingProperty<T, \"@context\", IJsonLdContextDefinitionRoot>\n> = Omit<T, \"@context\"> & {\n\t\"@context\"?: C;\n};\n\n/**\n * Add \"@type\" to a type.\n */\nexport type JsonLdObjectWithType<\n\tT extends object,\n\tTy = JsonLdExistingProperty<T, \"@type\", string | string[]>\n> = Omit<T, \"@type\"> & {\n\t\"@type\": Ty;\n};\n\n/**\n * Add optional \"@type\" to a type.\n */\nexport type JsonLdObjectWithOptionalType<\n\tT extends object,\n\tTy = JsonLdExistingProperty<T, \"@type\", string | string[]>\n> = Omit<T, \"@type\"> & {\n\t\"@type\"?: Ty;\n};\n\n/**\n * Add \"@id\" to a type.\n */\nexport type JsonLdObjectWithId<\n\tT extends object,\n\tId = JsonLdExistingProperty<T, \"@id\", string>\n> = Omit<T, \"@id\"> & {\n\t\"@id\": Id;\n};\n\n/**\n * Add optional \"@id\" to a type.\n */\nexport type JsonLdObjectWithOptionalId<\n\tT extends object,\n\tId = JsonLdExistingProperty<T, \"@id\", string>\n> = Omit<T, \"@id\"> & {\n\t\"@id\"?: Id;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"jsonLdHelperTypes.js","sourceRoot":"","sources":["../../../src/helpers/jsonLdHelperTypes.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2026 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdContextDefinitionRoot } from \"../models/IJsonLdContextDefinitionRoot.js\";\n\n/**\n * Extract the optional property names from a type.\n */\nexport type JsonLdOptionalKeys<T> = {\n\t[K in keyof T]-?: {} extends Pick<T, K> ? K : never;\n}[keyof T];\n\n/**\n * Extract the required property names from a type.\n */\nexport type JsonLdRequiredKeys<T> = Exclude<keyof T, JsonLdOptionalKeys<T>>;\n\n/**\n * Keep JSON-LD keys as-is and prefix non-JSON-LD keys.\n */\nexport type JsonLdAliasKey<K extends string, Prefix extends string> = K extends `@${string}`\n\t? K\n\t: `${Prefix}:${K}`;\n\n/**\n * Remap an object type so JSON-LD keys (\"@...\") are preserved and\n * non-JSON-LD keys are exposed as `Prefix:key` aliases, while preserving\n * each key's original required/optional status.\n */\nexport type JsonLdWithAliases<T extends object, Prefix extends string> = {\n\t[K in Extract<JsonLdRequiredKeys<T>, string> as JsonLdAliasKey<K, Prefix>]: T[K];\n} & {\n\t[K in Extract<JsonLdOptionalKeys<T>, string> as JsonLdAliasKey<K, Prefix>]?: T[K];\n};\n\n/**\n * Keep only JSON-LD keys (\"@...\") from a type.\n */\nexport type JsonLdKeys<T extends object> = Pick<T, Extract<keyof T, `@${string}`>>;\n\n/**\n * Create a JSON-LD object shape containing only JSON-LD keys plus aliased\n * non-JSON-LD keys.\n */\nexport type JsonLdObjectWithAliases<T extends object, Prefix extends string> = JsonLdKeys<T> &\n\tJsonLdWithAliases<T, Prefix>;\n\n/**\n * Add \"@context\" to a type.\n */\nexport type JsonLdObjectWithContext<T extends object, C = IJsonLdContextDefinitionRoot> = Omit<\n\tT,\n\t\"@context\"\n> & {\n\t\"@context\": C;\n};\n\n/**\n * Infer an existing property's type from a source type, or fall back to a default.\n */\nexport type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> = T extends {\n\t[K in P]?: infer PropertyType;\n}\n\t? Exclude<PropertyType, undefined>\n\t: D;\n\n/**\n * Add optional \"@context\" to a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithOptionalContext<\n\tT extends object,\n\tC = JsonLdExistingProperty<T, \"@context\", IJsonLdContextDefinitionRoot>\n> = Omit<T, \"@context\"> & {\n\t\"@context\"?: C;\n};\n\n/**\n * Omit optional \"@context\" from a type, inferring an existing context type from\n * the source type when available, otherwise using the provided default.\n */\nexport type JsonLdObjectWithNoContext<T extends object> = Omit<T, \"@context\">;\n\n/**\n * Add \"@type\" to a type.\n */\nexport type JsonLdObjectWithType<\n\tT extends object,\n\tTy = JsonLdExistingProperty<T, \"@type\", string | string[]>\n> = Omit<T, \"@type\"> & {\n\t\"@type\": Ty;\n};\n\n/**\n * Add optional \"@type\" to a type.\n */\nexport type JsonLdObjectWithOptionalType<\n\tT extends object,\n\tTy = JsonLdExistingProperty<T, \"@type\", string | string[]>\n> = Omit<T, \"@type\"> & {\n\t\"@type\"?: Ty;\n};\n\n/**\n * Omit \"@type\" from a type.\n */\nexport type JsonLdObjectWithNoType<T extends object> = Omit<T, \"@type\">;\n\n/**\n * Add \"@id\" to a type.\n */\nexport type JsonLdObjectWithId<\n\tT extends object,\n\tId = JsonLdExistingProperty<T, \"@id\", string>\n> = Omit<T, \"@id\"> & {\n\t\"@id\": Id;\n};\n\n/**\n * Add optional \"@id\" to a type.\n */\nexport type JsonLdObjectWithOptionalId<\n\tT extends object,\n\tId = JsonLdExistingProperty<T, \"@id\", string>\n> = Omit<T, \"@id\"> & {\n\t\"@id\"?: Id;\n};\n\n/**\n * Omit \"@id\" from a type.\n */\nexport type JsonLdObjectWithNoId<T extends object> = Omit<T, \"@id\">;\n"]}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"anyOf": [
|
|
6
6
|
{
|
|
7
7
|
"type": "object",
|
|
8
|
-
"additionalProperties": false,
|
|
9
8
|
"properties": {
|
|
10
9
|
"@id": {
|
|
11
10
|
"anyOf": [
|
|
@@ -90,7 +89,6 @@
|
|
|
90
89
|
},
|
|
91
90
|
{
|
|
92
91
|
"type": "object",
|
|
93
|
-
"additionalProperties": false,
|
|
94
92
|
"properties": {
|
|
95
93
|
"@reverse": {
|
|
96
94
|
"type": "string"
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
"anyOf": [
|
|
6
6
|
{
|
|
7
7
|
"type": "object",
|
|
8
|
-
"additionalProperties": false,
|
|
9
8
|
"properties": {
|
|
10
9
|
"@value": {
|
|
11
10
|
"type": [
|
|
@@ -42,7 +41,6 @@
|
|
|
42
41
|
},
|
|
43
42
|
{
|
|
44
43
|
"type": "object",
|
|
45
|
-
"additionalProperties": false,
|
|
46
44
|
"properties": {
|
|
47
45
|
"@value": {
|
|
48
46
|
"type": [
|
|
@@ -69,7 +67,6 @@
|
|
|
69
67
|
},
|
|
70
68
|
{
|
|
71
69
|
"type": "object",
|
|
72
|
-
"additionalProperties": false,
|
|
73
70
|
"properties": {
|
|
74
71
|
"@value": {
|
|
75
72
|
"anyOf": [
|
|
@@ -51,6 +51,11 @@ export type JsonLdExistingProperty<T extends object, P extends PropertyKey, D> =
|
|
|
51
51
|
export type JsonLdObjectWithOptionalContext<T extends object, C = JsonLdExistingProperty<T, "@context", IJsonLdContextDefinitionRoot>> = Omit<T, "@context"> & {
|
|
52
52
|
"@context"?: C;
|
|
53
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Omit optional "@context" from a type, inferring an existing context type from
|
|
56
|
+
* the source type when available, otherwise using the provided default.
|
|
57
|
+
*/
|
|
58
|
+
export type JsonLdObjectWithNoContext<T extends object> = Omit<T, "@context">;
|
|
54
59
|
/**
|
|
55
60
|
* Add "@type" to a type.
|
|
56
61
|
*/
|
|
@@ -63,6 +68,10 @@ export type JsonLdObjectWithType<T extends object, Ty = JsonLdExistingProperty<T
|
|
|
63
68
|
export type JsonLdObjectWithOptionalType<T extends object, Ty = JsonLdExistingProperty<T, "@type", string | string[]>> = Omit<T, "@type"> & {
|
|
64
69
|
"@type"?: Ty;
|
|
65
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* Omit "@type" from a type.
|
|
73
|
+
*/
|
|
74
|
+
export type JsonLdObjectWithNoType<T extends object> = Omit<T, "@type">;
|
|
66
75
|
/**
|
|
67
76
|
* Add "@id" to a type.
|
|
68
77
|
*/
|
|
@@ -75,3 +84,7 @@ export type JsonLdObjectWithId<T extends object, Id = JsonLdExistingProperty<T,
|
|
|
75
84
|
export type JsonLdObjectWithOptionalId<T extends object, Id = JsonLdExistingProperty<T, "@id", string>> = Omit<T, "@id"> & {
|
|
76
85
|
"@id"?: Id;
|
|
77
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* Omit "@id" from a type.
|
|
89
|
+
*/
|
|
90
|
+
export type JsonLdObjectWithNoId<T extends object> = Omit<T, "@id">;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @twin.org/data-json-ld - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.15](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.3-next.14...data-json-ld-v0.0.3-next.15) (2026-02-27)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* additional json-ld helpers ([c74cbd6](https://github.com/twinfoundation/data/commit/c74cbd60e423c5f780243da9868723e9d54d068a))
|
|
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.14 to 0.0.3-next.15
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.14](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.3-next.13...data-json-ld-v0.0.3-next.14) (2026-02-25)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* update schemas ([c30159c](https://github.com/twinfoundation/data/commit/c30159cd24e5f60f9124752738dd1c0312ee17dd))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/data-core bumped from 0.0.3-next.13 to 0.0.3-next.14
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.13](https://github.com/twinfoundation/data/compare/data-json-ld-v0.0.3-next.12...data-json-ld-v0.0.3-next.13) (2026-02-25)
|
|
4
32
|
|
|
5
33
|
|
package/docs/reference/index.md
CHANGED
|
@@ -31,10 +31,13 @@
|
|
|
31
31
|
- [JsonLdObjectWithContext](type-aliases/JsonLdObjectWithContext.md)
|
|
32
32
|
- [JsonLdExistingProperty](type-aliases/JsonLdExistingProperty.md)
|
|
33
33
|
- [JsonLdObjectWithOptionalContext](type-aliases/JsonLdObjectWithOptionalContext.md)
|
|
34
|
+
- [JsonLdObjectWithNoContext](type-aliases/JsonLdObjectWithNoContext.md)
|
|
34
35
|
- [JsonLdObjectWithType](type-aliases/JsonLdObjectWithType.md)
|
|
35
36
|
- [JsonLdObjectWithOptionalType](type-aliases/JsonLdObjectWithOptionalType.md)
|
|
37
|
+
- [JsonLdObjectWithNoType](type-aliases/JsonLdObjectWithNoType.md)
|
|
36
38
|
- [JsonLdObjectWithId](type-aliases/JsonLdObjectWithId.md)
|
|
37
39
|
- [JsonLdObjectWithOptionalId](type-aliases/JsonLdObjectWithOptionalId.md)
|
|
40
|
+
- [JsonLdObjectWithNoId](type-aliases/JsonLdObjectWithNoId.md)
|
|
38
41
|
- [IJsonLdContainerType](type-aliases/IJsonLdContainerType.md)
|
|
39
42
|
- [IJsonLdContainerTypeArray](type-aliases/IJsonLdContainerTypeArray.md)
|
|
40
43
|
- [IJsonLdContextDefinitionElement](type-aliases/IJsonLdContextDefinitionElement.md)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Type Alias: JsonLdObjectWithNoContext\<T\>
|
|
2
|
+
|
|
3
|
+
> **JsonLdObjectWithNoContext**\<`T`\> = `Omit`\<`T`, `"@context"`\>
|
|
4
|
+
|
|
5
|
+
Omit optional "@context" from a type, inferring an existing context type from
|
|
6
|
+
the source type when available, otherwise using the provided default.
|
|
7
|
+
|
|
8
|
+
## Type Parameters
|
|
9
|
+
|
|
10
|
+
### T
|
|
11
|
+
|
|
12
|
+
`T` *extends* `object`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/data-json-ld",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.15",
|
|
4
4
|
"description": "Models which define the structure of JSON LD",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@twin.org/core": "next",
|
|
18
|
-
"@twin.org/data-core": "0.0.3-next.
|
|
18
|
+
"@twin.org/data-core": "0.0.3-next.15",
|
|
19
19
|
"@twin.org/entity": "next",
|
|
20
20
|
"@twin.org/nameof": "next",
|
|
21
21
|
"@twin.org/web": "next",
|