@twin.org/data-json-ld 0.0.3-next.1 → 0.0.3-next.11

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 (34) hide show
  1. package/dist/es/dataTypes/jsonLdDataTypes.js +104 -131
  2. package/dist/es/dataTypes/jsonLdDataTypes.js.map +1 -1
  3. package/dist/es/helpers/jsonLdHelperTypes.js +2 -0
  4. package/dist/es/helpers/jsonLdHelperTypes.js.map +1 -0
  5. package/dist/es/index.js +1 -0
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/models/jsonLdContexts.js +10 -2
  8. package/dist/es/models/jsonLdContexts.js.map +1 -1
  9. package/dist/es/utils/jsonLdHelper.js +213 -4
  10. package/dist/es/utils/jsonLdHelper.js.map +1 -1
  11. package/dist/es/utils/jsonLdProcessor.js +1 -1
  12. package/dist/es/utils/jsonLdProcessor.js.map +1 -1
  13. package/dist/types/helpers/jsonLdHelperTypes.d.ts +77 -0
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/models/jsonLdContexts.d.ts +10 -2
  16. package/dist/types/utils/jsonLdHelper.d.ts +65 -2
  17. package/docs/changelog.md +145 -0
  18. package/docs/reference/classes/JsonLdHelper.md +255 -3
  19. package/docs/reference/index.md +13 -0
  20. package/docs/reference/type-aliases/JsonLdAliasKey.md +15 -0
  21. package/docs/reference/type-aliases/JsonLdExistingProperty.md +19 -0
  22. package/docs/reference/type-aliases/JsonLdKeys.md +11 -0
  23. package/docs/reference/type-aliases/JsonLdObjectWithAliases.md +16 -0
  24. package/docs/reference/type-aliases/JsonLdObjectWithContext.md +21 -0
  25. package/docs/reference/type-aliases/JsonLdObjectWithId.md +21 -0
  26. package/docs/reference/type-aliases/JsonLdObjectWithOptionalContext.md +22 -0
  27. package/docs/reference/type-aliases/JsonLdObjectWithOptionalId.md +21 -0
  28. package/docs/reference/type-aliases/JsonLdObjectWithOptionalType.md +21 -0
  29. package/docs/reference/type-aliases/JsonLdObjectWithType.md +21 -0
  30. package/docs/reference/type-aliases/JsonLdOptionalKeys.md +11 -0
  31. package/docs/reference/type-aliases/JsonLdRequiredKeys.md +11 -0
  32. package/docs/reference/type-aliases/JsonLdWithAliases.md +17 -0
  33. package/docs/reference/variables/JsonLdContexts.md +15 -3
  34. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { DataTypeHandlerFactory } from "@twin.org/data-core";
3
+ import { DataTypeHelper } from "@twin.org/data-core";
4
4
  import { JsonLdContexts } from "../models/jsonLdContexts.js";
5
5
  import { JsonLdTypes } from "../models/jsonLdTypes.js";
6
6
  import JsonLdContainerTypeSchema from "../schemas/JsonLdContainerType.json" with { type: "json" };
@@ -36,136 +36,109 @@ export class JsonLdDataTypes {
36
36
  * Register all the data types.
37
37
  */
38
38
  static registerTypes() {
39
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Document}`, () => ({
40
- context: JsonLdContexts.ContextRoot,
41
- type: JsonLdTypes.Document,
42
- jsonSchema: async () => JsonLdDocumentSchema
43
- }));
44
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Object}`, () => ({
45
- context: JsonLdContexts.ContextRoot,
46
- type: JsonLdTypes.Object,
47
- jsonSchema: async () => JsonLdObjectSchema
48
- }));
49
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodeObject}`, () => ({
50
- context: JsonLdContexts.ContextRoot,
51
- type: JsonLdTypes.NodeObject,
52
- jsonSchema: async () => JsonLdNodeObjectSchema
53
- }));
54
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodePrimitive}`, () => ({
55
- context: JsonLdContexts.ContextRoot,
56
- type: JsonLdTypes.NodePrimitive,
57
- jsonSchema: async () => JsonLdNodePrimitiveSchema
58
- }));
59
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.GraphObject}`, () => ({
60
- context: JsonLdContexts.ContextRoot,
61
- type: JsonLdTypes.GraphObject,
62
- jsonSchema: async () => JsonLdGraphObjectSchema
63
- }));
64
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ValueObject}`, () => ({
65
- context: JsonLdContexts.ContextRoot,
66
- type: JsonLdTypes.ValueObject,
67
- jsonSchema: async () => JsonLdValueObjectSchema
68
- }));
69
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
70
- context: JsonLdContexts.ContextRoot,
71
- type: JsonLdTypes.ListObject,
72
- jsonSchema: async () => JsonLdListObjectSchema
73
- }));
74
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`, () => ({
75
- context: JsonLdContexts.ContextRoot,
76
- type: JsonLdTypes.ListObject,
77
- jsonSchema: async () => JsonLdListObjectSchema
78
- }));
79
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.SetObject}`, () => ({
80
- context: JsonLdContexts.ContextRoot,
81
- type: JsonLdTypes.SetObject,
82
- jsonSchema: async () => JsonLdSetObjectSchema
83
- }));
84
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.LanguageMap}`, () => ({
85
- context: JsonLdContexts.ContextRoot,
86
- type: JsonLdTypes.LanguageMap,
87
- jsonSchema: async () => JsonLdLanguageMapSchema
88
- }));
89
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMap}`, () => ({
90
- context: JsonLdContexts.ContextRoot,
91
- type: JsonLdTypes.IndexMap,
92
- jsonSchema: async () => JsonLdIndexMapSchema
93
- }));
94
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMapItem}`, () => ({
95
- context: JsonLdContexts.ContextRoot,
96
- type: JsonLdTypes.IndexMapItem,
97
- jsonSchema: async () => JsonLdIndexMapItemSchema
98
- }));
99
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IdMap}`, () => ({
100
- context: JsonLdContexts.ContextRoot,
101
- type: JsonLdTypes.IdMap,
102
- jsonSchema: async () => JsonLdIdMapSchema
103
- }));
104
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.TypeMap}`, () => ({
105
- context: JsonLdContexts.ContextRoot,
106
- type: JsonLdTypes.TypeMap,
107
- jsonSchema: async () => JsonLdTypeMapSchema
108
- }));
109
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IncludedBlock}`, () => ({
110
- context: JsonLdContexts.ContextRoot,
111
- type: JsonLdTypes.IncludedBlock,
112
- jsonSchema: async () => JsonLdIncludedBlockSchema
113
- }));
114
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinition}`, () => ({
115
- context: JsonLdContexts.ContextRoot,
116
- type: JsonLdTypes.ContextDefinition,
117
- jsonSchema: async () => JsonLdContextDefinitionSchema
118
- }));
119
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionElement}`, () => ({
120
- context: JsonLdContexts.ContextRoot,
121
- type: JsonLdTypes.ContextDefinitionElement,
122
- jsonSchema: async () => JsonLdContextDefinitionElementSchema
123
- }));
124
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionRoot}`, () => ({
125
- context: JsonLdContexts.ContextRoot,
126
- type: JsonLdTypes.ContextDefinitionRoot,
127
- jsonSchema: async () => JsonLdContextDefinitionRootSchema
128
- }));
129
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ExpandedTermDefinition}`, () => ({
130
- context: JsonLdContexts.ContextRoot,
131
- type: JsonLdTypes.ExpandedTermDefinition,
132
- jsonSchema: async () => JsonLdExpandedTermDefinitionSchema
133
- }));
134
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListOrSetItem}`, () => ({
135
- context: JsonLdContexts.ContextRoot,
136
- type: JsonLdTypes.ListOrSetItem,
137
- jsonSchema: async () => JsonLdListOrSetItemSchema
138
- }));
139
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerType}`, () => ({
140
- context: JsonLdContexts.ContextRoot,
141
- type: JsonLdTypes.ContainerType,
142
- jsonSchema: async () => JsonLdContainerTypeSchema
143
- }));
144
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerTypeArray}`, () => ({
145
- context: JsonLdContexts.ContextRoot,
146
- type: JsonLdTypes.ContainerTypeArray,
147
- jsonSchema: async () => JsonLdContainerTypeArraySchema
148
- }));
149
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonPrimitive}`, () => ({
150
- context: JsonLdContexts.ContextRoot,
151
- type: JsonLdTypes.JsonPrimitive,
152
- jsonSchema: async () => JsonLdJsonPrimitiveSchema
153
- }));
154
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonArray}`, () => ({
155
- context: JsonLdContexts.ContextRoot,
156
- type: JsonLdTypes.JsonArray,
157
- jsonSchema: async () => JsonLdJsonArraySchema
158
- }));
159
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonObject}`, () => ({
160
- context: JsonLdContexts.ContextRoot,
161
- type: JsonLdTypes.JsonObject,
162
- jsonSchema: async () => JsonLdJsonObjectSchema
163
- }));
164
- DataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonValue}`, () => ({
165
- context: JsonLdContexts.ContextRoot,
166
- type: JsonLdTypes.JsonValue,
167
- jsonSchema: async () => JsonLdJsonValueSchema
168
- }));
39
+ const types = [
40
+ {
41
+ type: JsonLdTypes.Document,
42
+ schema: JsonLdDocumentSchema
43
+ },
44
+ {
45
+ type: JsonLdTypes.Object,
46
+ schema: JsonLdObjectSchema
47
+ },
48
+ {
49
+ type: JsonLdTypes.NodeObject,
50
+ schema: JsonLdNodeObjectSchema
51
+ },
52
+ {
53
+ type: JsonLdTypes.NodePrimitive,
54
+ schema: JsonLdNodePrimitiveSchema
55
+ },
56
+ {
57
+ type: JsonLdTypes.GraphObject,
58
+ schema: JsonLdGraphObjectSchema
59
+ },
60
+ {
61
+ type: JsonLdTypes.ValueObject,
62
+ schema: JsonLdValueObjectSchema
63
+ },
64
+ {
65
+ type: JsonLdTypes.ListObject,
66
+ schema: JsonLdListObjectSchema
67
+ },
68
+ {
69
+ type: JsonLdTypes.SetObject,
70
+ schema: JsonLdSetObjectSchema
71
+ },
72
+ {
73
+ type: JsonLdTypes.LanguageMap,
74
+ schema: JsonLdLanguageMapSchema
75
+ },
76
+ {
77
+ type: JsonLdTypes.IndexMap,
78
+ schema: JsonLdIndexMapSchema
79
+ },
80
+ {
81
+ type: JsonLdTypes.IndexMapItem,
82
+ schema: JsonLdIndexMapItemSchema
83
+ },
84
+ {
85
+ type: JsonLdTypes.IdMap,
86
+ schema: JsonLdIdMapSchema
87
+ },
88
+ {
89
+ type: JsonLdTypes.TypeMap,
90
+ schema: JsonLdTypeMapSchema
91
+ },
92
+ {
93
+ type: JsonLdTypes.IncludedBlock,
94
+ schema: JsonLdIncludedBlockSchema
95
+ },
96
+ {
97
+ type: JsonLdTypes.ContextDefinition,
98
+ schema: JsonLdContextDefinitionSchema
99
+ },
100
+ {
101
+ type: JsonLdTypes.ContextDefinitionElement,
102
+ schema: JsonLdContextDefinitionElementSchema
103
+ },
104
+ {
105
+ type: JsonLdTypes.ContextDefinitionRoot,
106
+ schema: JsonLdContextDefinitionRootSchema
107
+ },
108
+ {
109
+ type: JsonLdTypes.ExpandedTermDefinition,
110
+ schema: JsonLdExpandedTermDefinitionSchema
111
+ },
112
+ {
113
+ type: JsonLdTypes.ListOrSetItem,
114
+ schema: JsonLdListOrSetItemSchema
115
+ },
116
+ {
117
+ type: JsonLdTypes.ContainerType,
118
+ schema: JsonLdContainerTypeSchema
119
+ },
120
+ {
121
+ type: JsonLdTypes.ContainerTypeArray,
122
+ schema: JsonLdContainerTypeArraySchema
123
+ },
124
+ {
125
+ type: JsonLdTypes.JsonPrimitive,
126
+ schema: JsonLdJsonPrimitiveSchema
127
+ },
128
+ {
129
+ type: JsonLdTypes.JsonArray,
130
+ schema: JsonLdJsonArraySchema
131
+ },
132
+ {
133
+ type: JsonLdTypes.JsonObject,
134
+ schema: JsonLdJsonObjectSchema
135
+ },
136
+ {
137
+ type: JsonLdTypes.JsonValue,
138
+ schema: JsonLdJsonValueSchema
139
+ }
140
+ ];
141
+ DataTypeHelper.registerTypes(JsonLdContexts.Namespace, JsonLdContexts.JsonLdContext, types);
169
142
  }
170
143
  }
171
144
  //# sourceMappingURL=jsonLdDataTypes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonLdDataTypes.js","sourceRoot":"","sources":["../../../src/dataTypes/jsonLdDataTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,sBAAsB,EAAoB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,yBAAyB,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClG,OAAO,8BAA8B,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5G,OAAO,6BAA6B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1G,OAAO,oCAAoC,MAAM,gDAAgD,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxH,OAAO,iCAAiC,MAAM,6CAA6C,CAA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ftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { DataTypeHandlerFactory, type IJsonSchema } from \"@twin.org/data-core\";\nimport { JsonLdContexts } from \"../models/jsonLdContexts.js\";\nimport { JsonLdTypes } from \"../models/jsonLdTypes.js\";\nimport JsonLdContainerTypeSchema from \"../schemas/JsonLdContainerType.json\" with { type: \"json\" };\nimport JsonLdContainerTypeArraySchema from \"../schemas/JsonLdContainerTypeArray.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionSchema from \"../schemas/JsonLdContextDefinition.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionElementSchema from \"../schemas/JsonLdContextDefinitionElement.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionRootSchema from \"../schemas/JsonLdContextDefinitionRoot.json\" with { type: \"json\" };\nimport JsonLdDocumentSchema from \"../schemas/JsonLdDocument.json\" with { type: \"json\" };\nimport JsonLdExpandedTermDefinitionSchema from \"../schemas/JsonLdExpandedTermDefinition.json\" with { type: \"json\" };\nimport JsonLdGraphObjectSchema from \"../schemas/JsonLdGraphObject.json\" with { type: \"json\" };\nimport JsonLdIdMapSchema from \"../schemas/JsonLdIdMap.json\" with { type: \"json\" };\nimport JsonLdIncludedBlockSchema from \"../schemas/JsonLdIncludedBlock.json\" with { type: \"json\" };\nimport JsonLdIndexMapSchema from \"../schemas/JsonLdIndexMap.json\" with { type: \"json\" };\nimport JsonLdIndexMapItemSchema from \"../schemas/JsonLdIndexMapItem.json\" with { type: \"json\" };\nimport JsonLdJsonArraySchema from \"../schemas/JsonLdJsonArray.json\" with { type: \"json\" };\nimport JsonLdJsonObjectSchema from \"../schemas/JsonLdJsonObject.json\" with { type: \"json\" };\nimport JsonLdJsonPrimitiveSchema from \"../schemas/JsonLdJsonPrimitive.json\" with { type: \"json\" };\nimport JsonLdJsonValueSchema from \"../schemas/JsonLdJsonValue.json\" with { type: \"json\" };\nimport JsonLdLanguageMapSchema from \"../schemas/JsonLdLanguageMap.json\" with { type: \"json\" };\nimport JsonLdListObjectSchema from \"../schemas/JsonLdListObject.json\" with { type: \"json\" };\nimport JsonLdListOrSetItemSchema from \"../schemas/JsonLdListOrSetItem.json\" with { type: \"json\" };\nimport JsonLdNodeObjectSchema from \"../schemas/JsonLdNodeObject.json\" with { type: \"json\" };\nimport JsonLdNodePrimitiveSchema from \"../schemas/JsonLdNodePrimitive.json\" with { type: \"json\" };\nimport JsonLdObjectSchema from \"../schemas/JsonLdObject.json\" with { type: \"json\" };\nimport JsonLdSetObjectSchema from \"../schemas/JsonLdSetObject.json\" with { type: \"json\" };\nimport JsonLdTypeMapSchema from \"../schemas/JsonLdTypeMap.json\" with { type: \"json\" };\nimport JsonLdValueObjectSchema from \"../schemas/JsonLdValueObject.json\" with { type: \"json\" };\n\n/**\n * Handle all the data types for JSON-LD.\n */\nexport class JsonLdDataTypes {\n\t/**\n\t * Register all the data types.\n\t */\n\tpublic static registerTypes(): void {\n\t\tDataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Document}`, () => ({\n\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\ttype: JsonLdTypes.Document,\n\t\t\tjsonSchema: async () => JsonLdDocumentSchema as IJsonSchema\n\t\t}));\n\t\tDataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.Object}`, () => ({\n\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\ttype: JsonLdTypes.Object,\n\t\t\tjsonSchema: async () => JsonLdObjectSchema as IJsonSchema\n\t\t}));\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodeObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.NodeObject,\n\t\t\t\tjsonSchema: async () => JsonLdNodeObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.NodePrimitive}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.NodePrimitive,\n\t\t\t\tjsonSchema: async () => JsonLdNodePrimitiveSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.GraphObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.GraphObject,\n\t\t\t\tjsonSchema: async () => JsonLdGraphObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ValueObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ValueObject,\n\t\t\t\tjsonSchema: async () => JsonLdValueObjectSchema as unknown as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ListObject,\n\t\t\t\tjsonSchema: async () => JsonLdListObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ListObject,\n\t\t\t\tjsonSchema: async () => JsonLdListObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.SetObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.SetObject,\n\t\t\t\tjsonSchema: async () => JsonLdSetObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.LanguageMap}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.LanguageMap,\n\t\t\t\tjsonSchema: async () => JsonLdLanguageMapSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMap}`, () => ({\n\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\ttype: JsonLdTypes.IndexMap,\n\t\t\tjsonSchema: async () => JsonLdIndexMapSchema as IJsonSchema\n\t\t}));\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.IndexMapItem}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.IndexMapItem,\n\t\t\t\tjsonSchema: async () => JsonLdIndexMapItemSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.IdMap}`, () => ({\n\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\ttype: JsonLdTypes.IdMap,\n\t\t\tjsonSchema: async () => JsonLdIdMapSchema as IJsonSchema\n\t\t}));\n\t\tDataTypeHandlerFactory.register(`${JsonLdContexts.ContextRoot}${JsonLdTypes.TypeMap}`, () => ({\n\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\ttype: JsonLdTypes.TypeMap,\n\t\t\tjsonSchema: async () => JsonLdTypeMapSchema as IJsonSchema\n\t\t}));\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.IncludedBlock}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.IncludedBlock,\n\t\t\t\tjsonSchema: async () => JsonLdIncludedBlockSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinition}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ContextDefinition,\n\t\t\t\tjsonSchema: async () => JsonLdContextDefinitionSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionElement}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ContextDefinitionElement,\n\t\t\t\tjsonSchema: async () => JsonLdContextDefinitionElementSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContextDefinitionRoot}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ContextDefinitionRoot,\n\t\t\t\tjsonSchema: async () => JsonLdContextDefinitionRootSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ExpandedTermDefinition}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ExpandedTermDefinition,\n\t\t\t\tjsonSchema: async () => JsonLdExpandedTermDefinitionSchema as unknown as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ListOrSetItem}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ListOrSetItem,\n\t\t\t\tjsonSchema: async () => JsonLdListOrSetItemSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerType}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ContainerType,\n\t\t\t\tjsonSchema: async () => JsonLdContainerTypeSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.ContainerTypeArray}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.ContainerTypeArray,\n\t\t\t\tjsonSchema: async () => JsonLdContainerTypeArraySchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonPrimitive}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.JsonPrimitive,\n\t\t\t\tjsonSchema: async () => JsonLdJsonPrimitiveSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonArray}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.JsonArray,\n\t\t\t\tjsonSchema: async () => JsonLdJsonArraySchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonObject}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.JsonObject,\n\t\t\t\tjsonSchema: async () => JsonLdJsonObjectSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t\tDataTypeHandlerFactory.register(\n\t\t\t`${JsonLdContexts.ContextRoot}${JsonLdTypes.JsonValue}`,\n\t\t\t() => ({\n\t\t\t\tcontext: JsonLdContexts.ContextRoot,\n\t\t\t\ttype: JsonLdTypes.JsonValue,\n\t\t\t\tjsonSchema: async () => JsonLdJsonValueSchema as IJsonSchema\n\t\t\t})\n\t\t);\n\t}\n}\n"]}
1
+ {"version":3,"file":"jsonLdDataTypes.js","sourceRoot":"","sources":["../../../src/dataTypes/jsonLdDataTypes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,yBAAyB,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClG,OAAO,8BAA8B,MAAM,0CAA0C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5G,OAAO,6BAA6B,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1G,OAAO,oCAAoC,MAAM,gDAAgD,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxH,OAAO,iCAAiC,MAAM,6CAA6C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAClH,OAAO,oBAAoB,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACxF,OAAO,kCAAkC,MAAM,8CAA8C,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpH,OAAO,uBAAuB,MAAM,mCAAmC,CAAC,OAAO,IAAI,EAAE,MAAM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AAa;gBAC/B,MAAM,EAAE,yBAAyB;aACjC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,iBAAiB;gBACnC,MAAM,EAAE,6BAA6B;aACrC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,wBAAwB;gBAC1C,MAAM,EAAE,oCAAoC;aAC5C;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,qBAAqB;gBACvC,MAAM,EAAE,iCAAiC;aACzC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,sBAAsB;gBACxC,MAAM,EAAE,kCAAkC;aAC1C;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,aAAa;gBAC/B,MAAM,EAAE,yBAAyB;aACjC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,aAAa;gBAC/B,MAAM,EAAE,yBAAyB;aACjC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,kBAAkB;gBACpC,MAAM,EAAE,8BAA8B;aACtC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,aAAa;gBAC/B,MAAM,EAAE,yBAAyB;aACjC;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,SAAS;gBAC3B,MAAM,EAAE,qBAAqB;aAC7B;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,UAAU;gBAC5B,MAAM,EAAE,sBAAsB;aAC9B;YACD;gBACC,IAAI,EAAE,WAAW,CAAC,SAAS;gBAC3B,MAAM,EAAE,qBAAqB;aAC7B;SACD,CAAC;QAEF,cAAc,CAAC,aAAa,CAAC,cAAc,CAAC,SAAS,EAAE,cAAc,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC7F,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { DataTypeHelper } from \"@twin.org/data-core\";\nimport { JsonLdContexts } from \"../models/jsonLdContexts.js\";\nimport { JsonLdTypes } from \"../models/jsonLdTypes.js\";\nimport JsonLdContainerTypeSchema from \"../schemas/JsonLdContainerType.json\" with { type: \"json\" };\nimport JsonLdContainerTypeArraySchema from \"../schemas/JsonLdContainerTypeArray.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionSchema from \"../schemas/JsonLdContextDefinition.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionElementSchema from \"../schemas/JsonLdContextDefinitionElement.json\" with { type: \"json\" };\nimport JsonLdContextDefinitionRootSchema from \"../schemas/JsonLdContextDefinitionRoot.json\" with { type: \"json\" };\nimport JsonLdDocumentSchema from \"../schemas/JsonLdDocument.json\" with { type: \"json\" };\nimport JsonLdExpandedTermDefinitionSchema from \"../schemas/JsonLdExpandedTermDefinition.json\" with { type: \"json\" };\nimport JsonLdGraphObjectSchema from \"../schemas/JsonLdGraphObject.json\" with { type: \"json\" };\nimport JsonLdIdMapSchema from \"../schemas/JsonLdIdMap.json\" with { type: \"json\" };\nimport JsonLdIncludedBlockSchema from \"../schemas/JsonLdIncludedBlock.json\" with { type: \"json\" };\nimport JsonLdIndexMapSchema from \"../schemas/JsonLdIndexMap.json\" with { type: \"json\" };\nimport JsonLdIndexMapItemSchema from \"../schemas/JsonLdIndexMapItem.json\" with { type: \"json\" };\nimport JsonLdJsonArraySchema from \"../schemas/JsonLdJsonArray.json\" with { type: \"json\" };\nimport JsonLdJsonObjectSchema from \"../schemas/JsonLdJsonObject.json\" with { type: \"json\" };\nimport JsonLdJsonPrimitiveSchema from \"../schemas/JsonLdJsonPrimitive.json\" with { type: \"json\" };\nimport JsonLdJsonValueSchema from \"../schemas/JsonLdJsonValue.json\" with { type: \"json\" };\nimport JsonLdLanguageMapSchema from \"../schemas/JsonLdLanguageMap.json\" with { type: \"json\" };\nimport JsonLdListObjectSchema from \"../schemas/JsonLdListObject.json\" with { type: \"json\" };\nimport JsonLdListOrSetItemSchema from \"../schemas/JsonLdListOrSetItem.json\" with { type: \"json\" };\nimport JsonLdNodeObjectSchema from \"../schemas/JsonLdNodeObject.json\" with { type: \"json\" };\nimport JsonLdNodePrimitiveSchema from \"../schemas/JsonLdNodePrimitive.json\" with { type: \"json\" };\nimport JsonLdObjectSchema from \"../schemas/JsonLdObject.json\" with { type: \"json\" };\nimport JsonLdSetObjectSchema from \"../schemas/JsonLdSetObject.json\" with { type: \"json\" };\nimport JsonLdTypeMapSchema from \"../schemas/JsonLdTypeMap.json\" with { type: \"json\" };\nimport JsonLdValueObjectSchema from \"../schemas/JsonLdValueObject.json\" with { type: \"json\" };\n\n/**\n * Handle all the data types for JSON-LD.\n */\nexport class JsonLdDataTypes {\n\t/**\n\t * Register all the data types.\n\t */\n\tpublic static registerTypes(): void {\n\t\tconst types = [\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.Document,\n\t\t\t\tschema: JsonLdDocumentSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.Object,\n\t\t\t\tschema: JsonLdObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.NodeObject,\n\t\t\t\tschema: JsonLdNodeObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.NodePrimitive,\n\t\t\t\tschema: JsonLdNodePrimitiveSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.GraphObject,\n\t\t\t\tschema: JsonLdGraphObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ValueObject,\n\t\t\t\tschema: JsonLdValueObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ListObject,\n\t\t\t\tschema: JsonLdListObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.SetObject,\n\t\t\t\tschema: JsonLdSetObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.LanguageMap,\n\t\t\t\tschema: JsonLdLanguageMapSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.IndexMap,\n\t\t\t\tschema: JsonLdIndexMapSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.IndexMapItem,\n\t\t\t\tschema: JsonLdIndexMapItemSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.IdMap,\n\t\t\t\tschema: JsonLdIdMapSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.TypeMap,\n\t\t\t\tschema: JsonLdTypeMapSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.IncludedBlock,\n\t\t\t\tschema: JsonLdIncludedBlockSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ContextDefinition,\n\t\t\t\tschema: JsonLdContextDefinitionSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ContextDefinitionElement,\n\t\t\t\tschema: JsonLdContextDefinitionElementSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ContextDefinitionRoot,\n\t\t\t\tschema: JsonLdContextDefinitionRootSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ExpandedTermDefinition,\n\t\t\t\tschema: JsonLdExpandedTermDefinitionSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ListOrSetItem,\n\t\t\t\tschema: JsonLdListOrSetItemSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ContainerType,\n\t\t\t\tschema: JsonLdContainerTypeSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.ContainerTypeArray,\n\t\t\t\tschema: JsonLdContainerTypeArraySchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.JsonPrimitive,\n\t\t\t\tschema: JsonLdJsonPrimitiveSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.JsonArray,\n\t\t\t\tschema: JsonLdJsonArraySchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.JsonObject,\n\t\t\t\tschema: JsonLdJsonObjectSchema\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: JsonLdTypes.JsonValue,\n\t\t\t\tschema: JsonLdJsonValueSchema\n\t\t\t}\n\t\t];\n\n\t\tDataTypeHelper.registerTypes(JsonLdContexts.Namespace, JsonLdContexts.JsonLdContext, types);\n\t}\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=jsonLdHelperTypes.js.map
@@ -0,0 +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"]}
package/dist/es/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Copyright 2024 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  export * from "./dataTypes/jsonLdDataTypes.js";
4
+ export * from "./helpers/jsonLdHelperTypes.js";
4
5
  export * from "./models/IJsonLdContainerType.js";
5
6
  export * from "./models/IJsonLdContainerTypeArray.js";
6
7
  export * from "./models/IJsonLdContextDefinition.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataTypes/jsonLdDataTypes.js\";\nexport * from \"./models/IJsonLdContainerType.js\";\nexport * from \"./models/IJsonLdContainerTypeArray.js\";\nexport * from \"./models/IJsonLdContextDefinition.js\";\nexport * from \"./models/IJsonLdContextDefinitionElement.js\";\nexport * from \"./models/IJsonLdContextDefinitionRoot.js\";\nexport * from \"./models/IJsonLdDocument.js\";\nexport * from \"./models/IJsonLdExpandedTermDefinition.js\";\nexport * from \"./models/IJsonLdGraphObject.js\";\nexport * from \"./models/IJsonLdIdMap.js\";\nexport * from \"./models/IJsonLdIncludedBlock.js\";\nexport * from \"./models/IJsonLdIndexMap.js\";\nexport * from \"./models/IJsonLdIndexMapItem.js\";\nexport * from \"./models/IJsonLdJsonArray.js\";\nexport * from \"./models/IJsonLdJsonObject.js\";\nexport * from \"./models/IJsonLdJsonPrimitive.js\";\nexport * from \"./models/IJsonLdJsonValue.js\";\nexport * from \"./models/IJsonLdLanguageMap.js\";\nexport * from \"./models/IJsonLdListObject.js\";\nexport * from \"./models/IJsonLdListOrSetItem.js\";\nexport * from \"./models/IJsonLdNodeObject.js\";\nexport * from \"./models/IJsonLdNodePrimitive.js\";\nexport * from \"./models/IJsonLdObject.js\";\nexport * from \"./models/IJsonLdSetObject.js\";\nexport * from \"./models/IJsonLdTypeMap.js\";\nexport * from \"./models/IJsonLdValueObject.js\";\nexport * from \"./models/jsonLdContexts.js\";\nexport * from \"./models/jsonLdTypes.js\";\nexport * from \"./utils/jsonLdHelper.js\";\nexport * from \"./utils/jsonLdProcessor.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./dataTypes/jsonLdDataTypes.js\";\nexport * from \"./helpers/jsonLdHelperTypes.js\";\nexport * from \"./models/IJsonLdContainerType.js\";\nexport * from \"./models/IJsonLdContainerTypeArray.js\";\nexport * from \"./models/IJsonLdContextDefinition.js\";\nexport * from \"./models/IJsonLdContextDefinitionElement.js\";\nexport * from \"./models/IJsonLdContextDefinitionRoot.js\";\nexport * from \"./models/IJsonLdDocument.js\";\nexport * from \"./models/IJsonLdExpandedTermDefinition.js\";\nexport * from \"./models/IJsonLdGraphObject.js\";\nexport * from \"./models/IJsonLdIdMap.js\";\nexport * from \"./models/IJsonLdIncludedBlock.js\";\nexport * from \"./models/IJsonLdIndexMap.js\";\nexport * from \"./models/IJsonLdIndexMapItem.js\";\nexport * from \"./models/IJsonLdJsonArray.js\";\nexport * from \"./models/IJsonLdJsonObject.js\";\nexport * from \"./models/IJsonLdJsonPrimitive.js\";\nexport * from \"./models/IJsonLdJsonValue.js\";\nexport * from \"./models/IJsonLdLanguageMap.js\";\nexport * from \"./models/IJsonLdListObject.js\";\nexport * from \"./models/IJsonLdListOrSetItem.js\";\nexport * from \"./models/IJsonLdNodeObject.js\";\nexport * from \"./models/IJsonLdNodePrimitive.js\";\nexport * from \"./models/IJsonLdObject.js\";\nexport * from \"./models/IJsonLdSetObject.js\";\nexport * from \"./models/IJsonLdTypeMap.js\";\nexport * from \"./models/IJsonLdValueObject.js\";\nexport * from \"./models/jsonLdContexts.js\";\nexport * from \"./models/jsonLdTypes.js\";\nexport * from \"./utils/jsonLdHelper.js\";\nexport * from \"./utils/jsonLdProcessor.js\";\n"]}
@@ -6,8 +6,16 @@
6
6
  // eslint-disable-next-line @typescript-eslint/naming-convention
7
7
  export const JsonLdContexts = {
8
8
  /**
9
- * Context Root.
9
+ * The canonical RDF namespace URI for JSON-LD.
10
10
  */
11
- ContextRoot: "https://schema.twindev.org/json-ld/"
11
+ Namespace: "https://schema.twindev.org/json-ld/",
12
+ /**
13
+ * The value to use in JSON-LD context for JSON-LD.
14
+ */
15
+ Context: "https://schema.twindev.org/json-ld/",
16
+ /**
17
+ * The JSON-LD Context URL for JSON-LD.
18
+ */
19
+ JsonLdContext: "https://schema.twindev.org/json-ld/types.jsonld"
12
20
  };
13
21
  //# sourceMappingURL=jsonLdContexts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonLdContexts.js","sourceRoot":"","sources":["../../../src/models/jsonLdContexts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,WAAW,EAAE,qCAAqC;CACzC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts of JSON-LD data.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const JsonLdContexts = {\n\t/**\n\t * Context Root.\n\t */\n\tContextRoot: \"https://schema.twindev.org/json-ld/\"\n} as const;\n\n/**\n * The contexts of JSON-LD data.\n */\nexport type JsonLdContexts = (typeof JsonLdContexts)[keyof typeof JsonLdContexts];\n"]}
1
+ {"version":3,"file":"jsonLdContexts.js","sourceRoot":"","sources":["../../../src/models/jsonLdContexts.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AAEvC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,SAAS,EAAE,qCAAqC;IAEhD;;OAEG;IACH,OAAO,EAAE,qCAAqC;IAE9C;;OAEG;IACH,aAAa,EAAE,iDAAiD;CACvD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The contexts of JSON-LD data.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const JsonLdContexts = {\n\t/**\n\t * The canonical RDF namespace URI for JSON-LD.\n\t */\n\tNamespace: \"https://schema.twindev.org/json-ld/\",\n\n\t/**\n\t * The value to use in JSON-LD context for JSON-LD.\n\t */\n\tContext: \"https://schema.twindev.org/json-ld/\",\n\n\t/**\n\t * The JSON-LD Context URL for JSON-LD.\n\t */\n\tJsonLdContext: \"https://schema.twindev.org/json-ld/types.jsonld\"\n} as const;\n\n/**\n * The contexts of JSON-LD data.\n */\nexport type JsonLdContexts = (typeof JsonLdContexts)[keyof typeof JsonLdContexts];\n"]}
@@ -51,16 +51,33 @@ export class JsonLdHelper {
51
51
  }
52
52
  return validationFailures.length === 0;
53
53
  }
54
+ /**
55
+ * Expand an object to a JSON-LD node object.
56
+ * @param object The object to expand.
57
+ * @returns The expanded JSON-LD node object.
58
+ */
59
+ static toNodeObject(object) {
60
+ Guards.object(JsonLdHelper.CLASS_NAME, "object", object);
61
+ return object;
62
+ }
63
+ /**
64
+ * Expand the JSON-LD document.
65
+ * @param document The JSON-LD document to expand.
66
+ * @returns The expanded JSON-LD document.
67
+ */
68
+ static async expand(document) {
69
+ Guards.object(JsonLdHelper.CLASS_NAME, "document", document);
70
+ return JsonLdProcessor.expand(document);
71
+ }
54
72
  /**
55
73
  * Expand the JSON-LD document and check if it is of a specific type.
56
- * @param document The JSON-LD document to check.
74
+ * @param documentOrExpanded The JSON-LD document to check or already expanded document.
57
75
  * @param type The type to check for.
58
76
  * @returns True if the document is of the specified type.
59
77
  */
60
- static async isType(document, type) {
61
- Guards.object(JsonLdHelper.CLASS_NAME, "document", document);
78
+ static async isType(documentOrExpanded, type) {
79
+ const expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);
62
80
  Guards.arrayValue(JsonLdHelper.CLASS_NAME, "type", type);
63
- const expanded = await JsonLdProcessor.expand(document);
64
81
  if (Is.arrayValue(expanded)) {
65
82
  for (const item of expanded) {
66
83
  const types = ArrayHelper.fromObjectOrArray(item["@type"]);
@@ -75,5 +92,197 @@ export class JsonLdHelper {
75
92
  }
76
93
  return false;
77
94
  }
95
+ /**
96
+ * Get the types from the document.
97
+ * @param documentOrExpanded The JSON-LD document to check or already expanded document.
98
+ * @returns The type(s) extracted from the document.
99
+ */
100
+ static async getType(documentOrExpanded) {
101
+ const expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);
102
+ const types = new Set();
103
+ const props = ["@type", "type"];
104
+ for (const expandedDoc of expanded) {
105
+ for (const prop of props) {
106
+ const expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);
107
+ if (Is.arrayValue(expandedProps)) {
108
+ for (const expandedProp of expandedProps) {
109
+ const arr = ArrayHelper.fromObjectOrArray(expandedProp);
110
+ for (const arrValue of arr) {
111
+ if (Is.stringValue(arrValue)) {
112
+ types.add(arrValue);
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ return Array.from(types);
120
+ }
121
+ /**
122
+ * Get the id from the document.
123
+ * @param documentOrExpanded The JSON-LD document to get the id from or already expanded document.
124
+ * @param additionalIdProperties Optional additional properties to check for the id, in addition to "@id" and "id".
125
+ * @returns The id extracted from the document.
126
+ */
127
+ static async getId(documentOrExpanded, additionalIdProperties) {
128
+ const expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);
129
+ const props = ["@id", "id", ...(additionalIdProperties ?? [])];
130
+ for (const expandedDoc of expanded) {
131
+ for (const prop of props) {
132
+ const expandedProps = ArrayHelper.fromObjectOrArray(expandedDoc[prop]);
133
+ if (Is.arrayValue(expandedProps)) {
134
+ for (const expandedProp of expandedProps) {
135
+ const arr = ArrayHelper.fromObjectOrArray(expandedProp);
136
+ for (const arrValue of arr) {
137
+ if (Is.stringValue(arrValue)) {
138
+ return arrValue;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ /**
147
+ * Get property values by a single full expanded property name.
148
+ * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.
149
+ * @param propertyFullName The full expanded property name.
150
+ * @param language Optional filter values by their language property.
151
+ * @returns Matching property values for the input property.
152
+ */
153
+ static async getPropertyValue(documentOrExpanded, propertyFullName, language) {
154
+ const results = await JsonLdHelper.getPropertyValues(documentOrExpanded, [propertyFullName], language);
155
+ return results[0];
156
+ }
157
+ /**
158
+ * Get property values by their full expanded property names.
159
+ * @param documentOrExpanded The JSON-LD document to get the property from or already expanded document.
160
+ * @param propertyFullNames The full expanded property names.
161
+ * @param language Optional filter values by their language property.
162
+ * @returns Matching property values for each input property, in the same index order.
163
+ */
164
+ static async getPropertyValues(documentOrExpanded, propertyFullNames, language) {
165
+ const expanded = await JsonLdHelper.getExpandedDocument(documentOrExpanded);
166
+ Guards.arrayValue(JsonLdHelper.CLASS_NAME, "propertyFullNames", propertyFullNames);
167
+ if (Is.stringValue(language)) {
168
+ Guards.stringValue(JsonLdHelper.CLASS_NAME, "language", language);
169
+ }
170
+ const languageLower = Is.stringValue(language) ? language.toLowerCase() : undefined;
171
+ const result = [];
172
+ for (const propertyFullName of propertyFullNames) {
173
+ Guards.stringValue(JsonLdHelper.CLASS_NAME, "propertyFullName", propertyFullName);
174
+ const values = [];
175
+ for (const expandedDoc of expanded) {
176
+ const propValue = expandedDoc[propertyFullName];
177
+ if (!Is.empty(propValue)) {
178
+ const expandedProps = ArrayHelper.fromObjectOrArray(propValue);
179
+ if (Is.arrayValue(expandedProps)) {
180
+ for (const expandedProp of expandedProps) {
181
+ if (Is.object(expandedProp)) {
182
+ if (!Is.empty(expandedProp["@value"])) {
183
+ let shouldAdd = true;
184
+ if (Is.stringValue(languageLower)) {
185
+ const itemLanguage = Is.stringValue(expandedProp["@language"])
186
+ ? expandedProp["@language"].toLowerCase()
187
+ : undefined;
188
+ shouldAdd = itemLanguage === languageLower;
189
+ }
190
+ if (shouldAdd) {
191
+ values.push(expandedProp["@value"]);
192
+ }
193
+ }
194
+ else if (!Is.stringValue(languageLower)) {
195
+ values.push(expandedProp);
196
+ }
197
+ }
198
+ else if (Is.stringValue(expandedProp) ||
199
+ Is.boolean(expandedProp) ||
200
+ Is.number(expandedProp)) {
201
+ if (!Is.stringValue(languageLower)) {
202
+ values.push(expandedProp);
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+ }
209
+ result.push(values.length > 0 ? values : undefined);
210
+ }
211
+ return result;
212
+ }
213
+ /**
214
+ * Prefix all properties in the document with the provided prefix, except for JSON-LD properties.
215
+ * This is useful for ensuring that all properties are fully qualified with a namespace.
216
+ * For example, if the prefix is "ex" and the document has a property "name", it will be transformed to "ex:name".
217
+ * @param nodeObject The JSON-LD node object to prefix properties on.
218
+ * @param prefix The prefix to add to the properties.
219
+ * @param properties Optional list of properties to prefix. If not provided, all properties except for JSON-LD properties.
220
+ * @returns A new JSON-LD node object with the properties prefixed.
221
+ */
222
+ static prefixProperties(nodeObject, prefix, properties) {
223
+ Guards.object(JsonLdHelper.CLASS_NAME, "nodeObject", nodeObject);
224
+ Guards.stringValue(JsonLdHelper.CLASS_NAME, "prefix", prefix);
225
+ const normalizedPrefix = prefix.endsWith(":") ? prefix.slice(0, -1) : prefix;
226
+ const hasNoPropertiesFilter = !Is.arrayValue(properties);
227
+ const prefixedNodeObject = {};
228
+ for (const key in nodeObject) {
229
+ const value = nodeObject[key];
230
+ if (Is.stringValue(key) &&
231
+ !key.startsWith("@") &&
232
+ (hasNoPropertiesFilter || properties.includes(key))) {
233
+ prefixedNodeObject[`${normalizedPrefix}:${key}`] = value;
234
+ }
235
+ else {
236
+ prefixedNodeObject[key] = value;
237
+ }
238
+ }
239
+ return prefixedNodeObject;
240
+ }
241
+ /**
242
+ * Strip a prefix from properties in the document, except for JSON-LD properties.
243
+ * This is useful for converting fully qualified namespaced properties back to local names.
244
+ * For example, if the prefix is "ex" and the document has a property "ex:name", it will be transformed to "name".
245
+ * @param nodeObject The JSON-LD node object to strip prefixed properties from.
246
+ * @param prefix The prefix to remove from the properties.
247
+ * @param properties Optional list of unprefixed properties to strip. If not provided, all matching prefixed properties.
248
+ * @returns A new JSON-LD node object with the prefix stripped from matching properties.
249
+ */
250
+ static stripPrefixProperties(nodeObject, prefix, properties) {
251
+ Guards.object(JsonLdHelper.CLASS_NAME, "nodeObject", nodeObject);
252
+ Guards.stringValue(JsonLdHelper.CLASS_NAME, "prefix", prefix);
253
+ const normalizedPrefix = prefix.endsWith(":") ? prefix.slice(0, -1) : prefix;
254
+ const hasNoPropertiesFilter = !Is.arrayValue(properties);
255
+ const strippedNodeObject = {};
256
+ for (const key in nodeObject) {
257
+ const value = nodeObject[key];
258
+ if (Is.stringValue(key) && !key.startsWith("@") && key.startsWith(`${normalizedPrefix}:`)) {
259
+ const strippedKey = key.slice(normalizedPrefix.length + 1);
260
+ if (hasNoPropertiesFilter || properties.includes(strippedKey)) {
261
+ strippedNodeObject[strippedKey] = value;
262
+ }
263
+ else {
264
+ strippedNodeObject[key] = value;
265
+ }
266
+ }
267
+ else {
268
+ strippedNodeObject[key] = value;
269
+ }
270
+ }
271
+ return strippedNodeObject;
272
+ }
273
+ /**
274
+ * Get an expanded JSON-LD document from either compact or expanded input.
275
+ * @param documentOrExpanded The JSON-LD document or expanded document.
276
+ * @returns The expanded JSON-LD document.
277
+ * @internal
278
+ */
279
+ static async getExpandedDocument(documentOrExpanded) {
280
+ if (Is.array(documentOrExpanded)) {
281
+ Guards.array(JsonLdHelper.CLASS_NAME, "documentOrExpanded", documentOrExpanded);
282
+ return documentOrExpanded;
283
+ }
284
+ Guards.object(JsonLdHelper.CLASS_NAME, "documentOrExpanded", documentOrExpanded);
285
+ return JsonLdProcessor.expand(documentOrExpanded);
286
+ }
78
287
  }
79
288
  //# sourceMappingURL=jsonLdHelper.js.map