@3sixty/data-json-ld 0.0.0-stage → 0.20.0-next.1

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 (278) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +24 -2
  3. package/dist/es/compiled/validators.js +3895 -0
  4. package/dist/es/compiled/validators.js.map +1 -0
  5. package/dist/es/dataTypes/jsonLdDataTypes.js +170 -0
  6. package/dist/es/dataTypes/jsonLdDataTypes.js.map +1 -0
  7. package/dist/es/helpers/jsonLdAliasKey.js +4 -0
  8. package/dist/es/helpers/jsonLdAliasKey.js.map +1 -0
  9. package/dist/es/helpers/jsonLdExistingProperty.js +4 -0
  10. package/dist/es/helpers/jsonLdExistingProperty.js.map +1 -0
  11. package/dist/es/helpers/jsonLdExistingPropertyEither.js +2 -0
  12. package/dist/es/helpers/jsonLdExistingPropertyEither.js.map +1 -0
  13. package/dist/es/helpers/jsonLdKeys.js +4 -0
  14. package/dist/es/helpers/jsonLdKeys.js.map +1 -0
  15. package/dist/es/helpers/jsonLdObjectWithAliases.js +2 -0
  16. package/dist/es/helpers/jsonLdObjectWithAliases.js.map +1 -0
  17. package/dist/es/helpers/jsonLdObjectWithAtId.js +2 -0
  18. package/dist/es/helpers/jsonLdObjectWithAtId.js.map +1 -0
  19. package/dist/es/helpers/jsonLdObjectWithAtType.js +2 -0
  20. package/dist/es/helpers/jsonLdObjectWithAtType.js.map +1 -0
  21. package/dist/es/helpers/jsonLdObjectWithContext.js +2 -0
  22. package/dist/es/helpers/jsonLdObjectWithContext.js.map +1 -0
  23. package/dist/es/helpers/jsonLdObjectWithId.js +2 -0
  24. package/dist/es/helpers/jsonLdObjectWithId.js.map +1 -0
  25. package/dist/es/helpers/jsonLdObjectWithNoAtId.js +4 -0
  26. package/dist/es/helpers/jsonLdObjectWithNoAtId.js.map +1 -0
  27. package/dist/es/helpers/jsonLdObjectWithNoAtType.js +4 -0
  28. package/dist/es/helpers/jsonLdObjectWithNoAtType.js.map +1 -0
  29. package/dist/es/helpers/jsonLdObjectWithNoContext.js +4 -0
  30. package/dist/es/helpers/jsonLdObjectWithNoContext.js.map +1 -0
  31. package/dist/es/helpers/jsonLdObjectWithNoId.js +4 -0
  32. package/dist/es/helpers/jsonLdObjectWithNoId.js.map +1 -0
  33. package/dist/es/helpers/jsonLdObjectWithNoType.js +4 -0
  34. package/dist/es/helpers/jsonLdObjectWithNoType.js.map +1 -0
  35. package/dist/es/helpers/jsonLdObjectWithOptionalAtId.js +2 -0
  36. package/dist/es/helpers/jsonLdObjectWithOptionalAtId.js.map +1 -0
  37. package/dist/es/helpers/jsonLdObjectWithOptionalAtType.js +2 -0
  38. package/dist/es/helpers/jsonLdObjectWithOptionalAtType.js.map +1 -0
  39. package/dist/es/helpers/jsonLdObjectWithOptionalContext.js +2 -0
  40. package/dist/es/helpers/jsonLdObjectWithOptionalContext.js.map +1 -0
  41. package/dist/es/helpers/jsonLdObjectWithOptionalId.js +2 -0
  42. package/dist/es/helpers/jsonLdObjectWithOptionalId.js.map +1 -0
  43. package/dist/es/helpers/jsonLdObjectWithOptionalType.js +2 -0
  44. package/dist/es/helpers/jsonLdObjectWithOptionalType.js.map +1 -0
  45. package/dist/es/helpers/jsonLdObjectWithType.js +2 -0
  46. package/dist/es/helpers/jsonLdObjectWithType.js.map +1 -0
  47. package/dist/es/helpers/jsonLdOptionalKeys.js +4 -0
  48. package/dist/es/helpers/jsonLdOptionalKeys.js.map +1 -0
  49. package/dist/es/helpers/jsonLdRequiredKeys.js +2 -0
  50. package/dist/es/helpers/jsonLdRequiredKeys.js.map +1 -0
  51. package/dist/es/helpers/jsonLdWithAliases.js +2 -0
  52. package/dist/es/helpers/jsonLdWithAliases.js.map +1 -0
  53. package/dist/es/index.js +57 -0
  54. package/dist/es/index.js.map +1 -0
  55. package/dist/es/models/IJsonLdContainerType.js +4 -0
  56. package/dist/es/models/IJsonLdContainerType.js.map +1 -0
  57. package/dist/es/models/IJsonLdContainerTypeArray.js +2 -0
  58. package/dist/es/models/IJsonLdContainerTypeArray.js.map +1 -0
  59. package/dist/es/models/IJsonLdContextDefinition.js +2 -0
  60. package/dist/es/models/IJsonLdContextDefinition.js.map +1 -0
  61. package/dist/es/models/IJsonLdContextDefinitionElement.js +2 -0
  62. package/dist/es/models/IJsonLdContextDefinitionElement.js.map +1 -0
  63. package/dist/es/models/IJsonLdContextDefinitionRoot.js +2 -0
  64. package/dist/es/models/IJsonLdContextDefinitionRoot.js.map +1 -0
  65. package/dist/es/models/IJsonLdDocument.js +2 -0
  66. package/dist/es/models/IJsonLdDocument.js.map +1 -0
  67. package/dist/es/models/IJsonLdExpandedTermDefinition.js +2 -0
  68. package/dist/es/models/IJsonLdExpandedTermDefinition.js.map +1 -0
  69. package/dist/es/models/IJsonLdGraphObject.js +2 -0
  70. package/dist/es/models/IJsonLdGraphObject.js.map +1 -0
  71. package/dist/es/models/IJsonLdIdMap.js +2 -0
  72. package/dist/es/models/IJsonLdIdMap.js.map +1 -0
  73. package/dist/es/models/IJsonLdIncludedBlock.js +2 -0
  74. package/dist/es/models/IJsonLdIncludedBlock.js.map +1 -0
  75. package/dist/es/models/IJsonLdIndexMap.js +2 -0
  76. package/dist/es/models/IJsonLdIndexMap.js.map +1 -0
  77. package/dist/es/models/IJsonLdIndexMapItem.js +2 -0
  78. package/dist/es/models/IJsonLdIndexMapItem.js.map +1 -0
  79. package/dist/es/models/IJsonLdJsonArray.js +2 -0
  80. package/dist/es/models/IJsonLdJsonArray.js.map +1 -0
  81. package/dist/es/models/IJsonLdJsonObject.js +2 -0
  82. package/dist/es/models/IJsonLdJsonObject.js.map +1 -0
  83. package/dist/es/models/IJsonLdJsonPrimitive.js +4 -0
  84. package/dist/es/models/IJsonLdJsonPrimitive.js.map +1 -0
  85. package/dist/es/models/IJsonLdJsonValue.js +2 -0
  86. package/dist/es/models/IJsonLdJsonValue.js.map +1 -0
  87. package/dist/es/models/IJsonLdLanguageMap.js +4 -0
  88. package/dist/es/models/IJsonLdLanguageMap.js.map +1 -0
  89. package/dist/es/models/IJsonLdListObject.js +2 -0
  90. package/dist/es/models/IJsonLdListObject.js.map +1 -0
  91. package/dist/es/models/IJsonLdListOrSetItem.js +2 -0
  92. package/dist/es/models/IJsonLdListOrSetItem.js.map +1 -0
  93. package/dist/es/models/IJsonLdNodeObject.js +2 -0
  94. package/dist/es/models/IJsonLdNodeObject.js.map +1 -0
  95. package/dist/es/models/IJsonLdNodePrimitive.js +2 -0
  96. package/dist/es/models/IJsonLdNodePrimitive.js.map +1 -0
  97. package/dist/es/models/IJsonLdObject.js +2 -0
  98. package/dist/es/models/IJsonLdObject.js.map +1 -0
  99. package/dist/es/models/IJsonLdSetObject.js +2 -0
  100. package/dist/es/models/IJsonLdSetObject.js.map +1 -0
  101. package/dist/es/models/IJsonLdTypeMap.js +2 -0
  102. package/dist/es/models/IJsonLdTypeMap.js.map +1 -0
  103. package/dist/es/models/IJsonLdValueObject.js +2 -0
  104. package/dist/es/models/IJsonLdValueObject.js.map +1 -0
  105. package/dist/es/models/jsonLdContexts.js +21 -0
  106. package/dist/es/models/jsonLdContexts.js.map +1 -0
  107. package/dist/es/models/jsonLdTypes.js +113 -0
  108. package/dist/es/models/jsonLdTypes.js.map +1 -0
  109. package/dist/es/schemas/JsonLdContainerType.json +23 -0
  110. package/dist/es/schemas/JsonLdContainerTypeArray.json +166 -0
  111. package/dist/es/schemas/JsonLdContextDefinition.json +134 -0
  112. package/dist/es/schemas/JsonLdContextDefinitionElement.json +17 -0
  113. package/dist/es/schemas/JsonLdContextDefinitionRoot.json +17 -0
  114. package/dist/es/schemas/JsonLdDocument.json +48 -0
  115. package/dist/es/schemas/JsonLdExpandedTermDefinition.json +148 -0
  116. package/dist/es/schemas/JsonLdGraphObject.json +44 -0
  117. package/dist/es/schemas/JsonLdIdMap.json +10 -0
  118. package/dist/es/schemas/JsonLdIncludedBlock.json +17 -0
  119. package/dist/es/schemas/JsonLdIndexMap.json +20 -0
  120. package/dist/es/schemas/JsonLdIndexMapItem.json +32 -0
  121. package/dist/es/schemas/JsonLdJsonArray.json +10 -0
  122. package/dist/es/schemas/JsonLdJsonObject.json +10 -0
  123. package/dist/es/schemas/JsonLdJsonPrimitive.json +20 -0
  124. package/dist/es/schemas/JsonLdJsonValue.json +17 -0
  125. package/dist/es/schemas/JsonLdLanguageMap.json +23 -0
  126. package/dist/es/schemas/JsonLdListObject.json +28 -0
  127. package/dist/es/schemas/JsonLdListOrSetItem.json +26 -0
  128. package/dist/es/schemas/JsonLdNodeObject.json +40 -0
  129. package/dist/es/schemas/JsonLdNodePrimitive.json +35 -0
  130. package/dist/es/schemas/JsonLdObject.json +76 -0
  131. package/dist/es/schemas/JsonLdSetObject.json +28 -0
  132. package/dist/es/schemas/JsonLdTypeMap.json +17 -0
  133. package/dist/es/schemas/JsonLdValueObject.json +125 -0
  134. package/dist/es/utils/jsonLdHelper.js +301 -0
  135. package/dist/es/utils/jsonLdHelper.js.map +1 -0
  136. package/dist/es/utils/jsonLdProcessor.js +507 -0
  137. package/dist/es/utils/jsonLdProcessor.js.map +1 -0
  138. package/dist/types/compiled/validators.d.ts +101 -0
  139. package/dist/types/dataTypes/jsonLdDataTypes.d.ts +9 -0
  140. package/dist/types/helpers/jsonLdAliasKey.d.ts +4 -0
  141. package/dist/types/helpers/jsonLdExistingProperty.d.ts +6 -0
  142. package/dist/types/helpers/jsonLdExistingPropertyEither.d.ts +6 -0
  143. package/dist/types/helpers/jsonLdKeys.d.ts +4 -0
  144. package/dist/types/helpers/jsonLdObjectWithAliases.d.ts +7 -0
  145. package/dist/types/helpers/jsonLdObjectWithAtId.d.ts +7 -0
  146. package/dist/types/helpers/jsonLdObjectWithAtType.d.ts +7 -0
  147. package/dist/types/helpers/jsonLdObjectWithContext.d.ts +7 -0
  148. package/dist/types/helpers/jsonLdObjectWithId.d.ts +7 -0
  149. package/dist/types/helpers/jsonLdObjectWithNoAtId.d.ts +4 -0
  150. package/dist/types/helpers/jsonLdObjectWithNoAtType.d.ts +4 -0
  151. package/dist/types/helpers/jsonLdObjectWithNoContext.d.ts +5 -0
  152. package/dist/types/helpers/jsonLdObjectWithNoId.d.ts +4 -0
  153. package/dist/types/helpers/jsonLdObjectWithNoType.d.ts +4 -0
  154. package/dist/types/helpers/jsonLdObjectWithOptionalAtId.d.ts +7 -0
  155. package/dist/types/helpers/jsonLdObjectWithOptionalAtType.d.ts +7 -0
  156. package/dist/types/helpers/jsonLdObjectWithOptionalContext.d.ts +9 -0
  157. package/dist/types/helpers/jsonLdObjectWithOptionalId.d.ts +7 -0
  158. package/dist/types/helpers/jsonLdObjectWithOptionalType.d.ts +7 -0
  159. package/dist/types/helpers/jsonLdObjectWithType.d.ts +7 -0
  160. package/dist/types/helpers/jsonLdOptionalKeys.d.ts +6 -0
  161. package/dist/types/helpers/jsonLdRequiredKeys.d.ts +5 -0
  162. package/dist/types/helpers/jsonLdWithAliases.d.ts +13 -0
  163. package/dist/types/index.d.ts +54 -0
  164. package/dist/types/models/IJsonLdContainerType.d.ts +8 -0
  165. package/dist/types/models/IJsonLdContainerTypeArray.d.ts +9 -0
  166. package/dist/types/models/IJsonLdContextDefinition.d.ts +24 -0
  167. package/dist/types/models/IJsonLdContextDefinitionElement.d.ts +9 -0
  168. package/dist/types/models/IJsonLdContextDefinitionRoot.d.ts +9 -0
  169. package/dist/types/models/IJsonLdDocument.d.ts +17 -0
  170. package/dist/types/models/IJsonLdExpandedTermDefinition.d.ts +29 -0
  171. package/dist/types/models/IJsonLdGraphObject.d.ts +16 -0
  172. package/dist/types/models/IJsonLdIdMap.d.ts +12 -0
  173. package/dist/types/models/IJsonLdIncludedBlock.d.ts +10 -0
  174. package/dist/types/models/IJsonLdIndexMap.d.ts +13 -0
  175. package/dist/types/models/IJsonLdIndexMapItem.d.ts +12 -0
  176. package/dist/types/models/IJsonLdJsonArray.d.ts +9 -0
  177. package/dist/types/models/IJsonLdJsonObject.d.ts +11 -0
  178. package/dist/types/models/IJsonLdJsonPrimitive.d.ts +8 -0
  179. package/dist/types/models/IJsonLdJsonValue.d.ts +11 -0
  180. package/dist/types/models/IJsonLdLanguageMap.d.ts +11 -0
  181. package/dist/types/models/IJsonLdListObject.d.ts +13 -0
  182. package/dist/types/models/IJsonLdListOrSetItem.d.ts +10 -0
  183. package/dist/types/models/IJsonLdNodeObject.d.ts +19 -0
  184. package/dist/types/models/IJsonLdNodePrimitive.d.ts +13 -0
  185. package/dist/types/models/IJsonLdObject.d.ts +25 -0
  186. package/dist/types/models/IJsonLdSetObject.d.ts +13 -0
  187. package/dist/types/models/IJsonLdTypeMap.d.ts +12 -0
  188. package/dist/types/models/IJsonLdValueObject.d.ts +26 -0
  189. package/dist/types/models/jsonLdContexts.d.ts +21 -0
  190. package/dist/types/models/jsonLdTypes.d.ts +113 -0
  191. package/dist/types/utils/jsonLdHelper.d.ts +97 -0
  192. package/dist/types/utils/jsonLdProcessor.d.ts +117 -0
  193. package/docs/changelog.md +15 -0
  194. package/docs/examples.md +214 -0
  195. package/docs/reference/classes/JsonLdDataTypes.md +25 -0
  196. package/docs/reference/classes/JsonLdHelper.md +371 -0
  197. package/docs/reference/classes/JsonLdProcessor.md +400 -0
  198. package/docs/reference/index.md +93 -0
  199. package/docs/reference/interfaces/IJsonLdContextDefinition.md +73 -0
  200. package/docs/reference/interfaces/IJsonLdGraphObject.md +31 -0
  201. package/docs/reference/interfaces/IJsonLdIdMap.md +11 -0
  202. package/docs/reference/interfaces/IJsonLdIndexMap.md +12 -0
  203. package/docs/reference/interfaces/IJsonLdJsonObject.md +7 -0
  204. package/docs/reference/interfaces/IJsonLdLanguageMap.md +11 -0
  205. package/docs/reference/interfaces/IJsonLdListObject.md +19 -0
  206. package/docs/reference/interfaces/IJsonLdNodeObject.md +100 -0
  207. package/docs/reference/interfaces/IJsonLdObject.md +64 -0
  208. package/docs/reference/interfaces/IJsonLdSetObject.md +19 -0
  209. package/docs/reference/interfaces/IJsonLdTypeMap.md +11 -0
  210. package/docs/reference/type-aliases/IJsonLdContainerType.md +5 -0
  211. package/docs/reference/type-aliases/IJsonLdContainerTypeArray.md +5 -0
  212. package/docs/reference/type-aliases/IJsonLdContextDefinitionElement.md +5 -0
  213. package/docs/reference/type-aliases/IJsonLdContextDefinitionRoot.md +5 -0
  214. package/docs/reference/type-aliases/IJsonLdDocument.md +11 -0
  215. package/docs/reference/type-aliases/IJsonLdExpandedTermDefinition.md +41 -0
  216. package/docs/reference/type-aliases/IJsonLdIncludedBlock.md +9 -0
  217. package/docs/reference/type-aliases/IJsonLdIndexMapItem.md +5 -0
  218. package/docs/reference/type-aliases/IJsonLdJsonArray.md +5 -0
  219. package/docs/reference/type-aliases/IJsonLdJsonPrimitive.md +5 -0
  220. package/docs/reference/type-aliases/IJsonLdJsonValue.md +5 -0
  221. package/docs/reference/type-aliases/IJsonLdListOrSetItem.md +5 -0
  222. package/docs/reference/type-aliases/IJsonLdNodePrimitive.md +5 -0
  223. package/docs/reference/type-aliases/IJsonLdValueObject.md +20 -0
  224. package/docs/reference/type-aliases/JsonLdAliasKey.md +15 -0
  225. package/docs/reference/type-aliases/JsonLdContexts.md +5 -0
  226. package/docs/reference/type-aliases/JsonLdExistingProperty.md +19 -0
  227. package/docs/reference/type-aliases/JsonLdExistingPropertyEither.md +24 -0
  228. package/docs/reference/type-aliases/JsonLdKeys.md +11 -0
  229. package/docs/reference/type-aliases/JsonLdObjectWithAliases.md +16 -0
  230. package/docs/reference/type-aliases/JsonLdObjectWithAtId.md +21 -0
  231. package/docs/reference/type-aliases/JsonLdObjectWithAtType.md +21 -0
  232. package/docs/reference/type-aliases/JsonLdObjectWithContext.md +21 -0
  233. package/docs/reference/type-aliases/JsonLdObjectWithId.md +21 -0
  234. package/docs/reference/type-aliases/JsonLdObjectWithNoAtId.md +11 -0
  235. package/docs/reference/type-aliases/JsonLdObjectWithNoAtType.md +11 -0
  236. package/docs/reference/type-aliases/JsonLdObjectWithNoContext.md +12 -0
  237. package/docs/reference/type-aliases/JsonLdObjectWithNoId.md +11 -0
  238. package/docs/reference/type-aliases/JsonLdObjectWithNoType.md +11 -0
  239. package/docs/reference/type-aliases/JsonLdObjectWithOptionalAtId.md +21 -0
  240. package/docs/reference/type-aliases/JsonLdObjectWithOptionalAtType.md +21 -0
  241. package/docs/reference/type-aliases/JsonLdObjectWithOptionalContext.md +22 -0
  242. package/docs/reference/type-aliases/JsonLdObjectWithOptionalId.md +21 -0
  243. package/docs/reference/type-aliases/JsonLdObjectWithOptionalType.md +21 -0
  244. package/docs/reference/type-aliases/JsonLdObjectWithType.md +21 -0
  245. package/docs/reference/type-aliases/JsonLdOptionalKeys.md +11 -0
  246. package/docs/reference/type-aliases/JsonLdRequiredKeys.md +11 -0
  247. package/docs/reference/type-aliases/JsonLdTypes.md +5 -0
  248. package/docs/reference/type-aliases/JsonLdWithAliases.md +17 -0
  249. package/docs/reference/variables/CompiledJsonLdContainerType.md +5 -0
  250. package/docs/reference/variables/CompiledJsonLdContainerTypeArray.md +5 -0
  251. package/docs/reference/variables/CompiledJsonLdContextDefinition.md +5 -0
  252. package/docs/reference/variables/CompiledJsonLdContextDefinitionElement.md +5 -0
  253. package/docs/reference/variables/CompiledJsonLdContextDefinitionRoot.md +5 -0
  254. package/docs/reference/variables/CompiledJsonLdDocument.md +5 -0
  255. package/docs/reference/variables/CompiledJsonLdExpandedTermDefinition.md +5 -0
  256. package/docs/reference/variables/CompiledJsonLdGraphObject.md +5 -0
  257. package/docs/reference/variables/CompiledJsonLdIdMap.md +5 -0
  258. package/docs/reference/variables/CompiledJsonLdIncludedBlock.md +5 -0
  259. package/docs/reference/variables/CompiledJsonLdIndexMap.md +5 -0
  260. package/docs/reference/variables/CompiledJsonLdIndexMapItem.md +5 -0
  261. package/docs/reference/variables/CompiledJsonLdJsonArray.md +5 -0
  262. package/docs/reference/variables/CompiledJsonLdJsonObject.md +5 -0
  263. package/docs/reference/variables/CompiledJsonLdJsonPrimitive.md +5 -0
  264. package/docs/reference/variables/CompiledJsonLdJsonValue.md +5 -0
  265. package/docs/reference/variables/CompiledJsonLdLanguageMap.md +5 -0
  266. package/docs/reference/variables/CompiledJsonLdListObject.md +5 -0
  267. package/docs/reference/variables/CompiledJsonLdListOrSetItem.md +5 -0
  268. package/docs/reference/variables/CompiledJsonLdNodeObject.md +5 -0
  269. package/docs/reference/variables/CompiledJsonLdNodePrimitive.md +5 -0
  270. package/docs/reference/variables/CompiledJsonLdObject.md +5 -0
  271. package/docs/reference/variables/CompiledJsonLdSetObject.md +5 -0
  272. package/docs/reference/variables/CompiledJsonLdTypeMap.md +5 -0
  273. package/docs/reference/variables/CompiledJsonLdValueObject.md +5 -0
  274. package/docs/reference/variables/JsonLdContexts.md +25 -0
  275. package/docs/reference/variables/JsonLdTypes.md +163 -0
  276. package/locales/.validate-ignore +1 -0
  277. package/locales/en.json +11 -0
  278. package/package.json +52 -5
@@ -0,0 +1,214 @@
1
+ # Data Json Ld Examples
2
+
3
+ These examples walk through context management, document processing, validation, and property access patterns for JSON-LD documents.
4
+
5
+ ## JsonLdProcessor
6
+
7
+ ```typescript
8
+ import { JsonLdProcessor } from '@3sixty/data-json-ld';
9
+
10
+ JsonLdProcessor.setCacheLimit(900000);
11
+ console.log('Cache limit:', JsonLdProcessor.getCacheLimit());
12
+
13
+ JsonLdProcessor.setRedirects([
14
+ {
15
+ from: /^https:\/\/raw\.githubusercontent\.com\//,
16
+ to: 'https://cdn.example.org/github-content'
17
+ }
18
+ ]);
19
+
20
+ JsonLdProcessor.addRedirect(/^https:\/\/schema\.org\//, 'https://schema.org/');
21
+ console.log('Has redirects:', JsonLdProcessor.getRedirects().length > 0);
22
+
23
+ const loader = JsonLdProcessor.getDocumentLoader();
24
+ console.log('Loader type:', typeof loader);
25
+ ```
26
+
27
+ ```typescript
28
+ import { JsonLdProcessor, type IJsonLdNodeObject } from '@3sixty/data-json-ld';
29
+
30
+ const compactedDoc = {
31
+ '@context': {
32
+ ex: 'https://example.org/vocab/',
33
+ name: 'ex:name'
34
+ },
35
+ '@id': 'urn:example:person:1',
36
+ name: 'Ada'
37
+ };
38
+
39
+ const expanded = await JsonLdProcessor.expand(compactedDoc);
40
+ const compactedAgain = await JsonLdProcessor.compact(expanded[0], compactedDoc['@context']);
41
+
42
+ console.log('Compacted id:', compactedAgain['@id']);
43
+
44
+ const canonical = await JsonLdProcessor.canonize(expanded[0] as IJsonLdNodeObject);
45
+ console.log('Canonical includes id:', canonical.includes('urn:example:person:1'));
46
+ ```
47
+
48
+ ```typescript
49
+ import { JsonLdProcessor, type IJsonLdNodeObject } from '@3sixty/data-json-ld';
50
+
51
+ const contextA = 'https://example.org/context/base';
52
+ const contextB = {
53
+ ex: 'https://example.org/vocab/',
54
+ name: 'ex:name'
55
+ };
56
+
57
+ const combined = JsonLdProcessor.combineContexts(contextA, contextB);
58
+
59
+ const documentWithNestedContexts: IJsonLdNodeObject = {
60
+ '@context': contextA,
61
+ '@graph': [
62
+ {
63
+ '@context': contextB,
64
+ '@id': 'urn:example:item:1',
65
+ '@type': 'ex:Person',
66
+ 'ex:name': 'Ada'
67
+ }
68
+ ]
69
+ };
70
+
71
+ const gathered = JsonLdProcessor.gatherContexts(documentWithNestedContexts);
72
+ const filtered = JsonLdProcessor.removeContexts(gathered, [contextB]);
73
+
74
+ console.log('Combined is array:', Array.isArray(combined));
75
+ console.log('Filtered context equals contextA:', filtered === contextA);
76
+ ```
77
+
78
+ ```typescript
79
+ import { JsonLdProcessor } from '@3sixty/data-json-ld';
80
+
81
+ await JsonLdProcessor.documentCacheAdd('https://example.org/context', {
82
+ '@context': {
83
+ ex: 'https://example.org/vocab/'
84
+ }
85
+ });
86
+
87
+ await JsonLdProcessor.documentCacheRemove('https://example.org/context');
88
+ ```
89
+
90
+ ### Remote `@context` URLs: redirects and HTTP `Link` discovery
91
+
92
+ When a remote `@context` URL is a string, the default document loader resolves it in this order:
93
+
94
+ 1. **Registered redirects** — `setRedirects` / `addRedirect` run first. If a pattern matches, the request uses the replacement URL only (no `HEAD` or discovery against the original namespace URL).
95
+ 2. **GET with `Accept: application/ld+json`**. If the response is an **HTTP error** (for example **404**), the load fails and discovery does not run. If the response is **OK** but the body is **not valid JSON** (for example HTML), retry **GET** with **`Accept: application/json`**.
96
+ 3. **HTTP `Link` discovery** — only if **both** `GET`s in step 2 failed with a **JSON decode** error: `HEAD` on the current URL (or `GET` if the server returns **405** / **501** for `HEAD`), then inspect `Link` for `rel="alternate"` and `type="application/ld+json"`, resolve the target URL, and **fetch that context document once** (at most **one** discovery hop per load chain).
97
+
98
+ Use **manual redirects** for stable overrides, offline tests, or hosts that do not expose a suitable `Link` header. Rely on **discovery** when the namespace URL serves HTML but advertises a JSON-LD context via `Link`.
99
+
100
+ ```typescript
101
+ import { JsonLdProcessor } from '@3sixty/data-json-ld';
102
+
103
+ // Optional: force a namespace URL to a known context document (runs before discovery).
104
+ JsonLdProcessor.addRedirect(
105
+ /^https:\/\/example\.org\/vocab\/?$/,
106
+ 'https://example.org/context/doc.jsonld'
107
+ );
108
+ ```
109
+
110
+ ### Standards packages and `registerRedirects()`
111
+
112
+ Vocabulary packages (for example `@3sixty/standards-schema-org`) often expose `SchemaOrgDataTypes.registerRedirects()`, which forwards to `JsonLdProcessor.addRedirect` for a known namespace URL. That call is **optional** in many deployments: the default loader can reach the same JSON-LD context via **HTTP `Link` discovery** when the namespace URL returns HTML and advertises `rel="alternate"` with `type="application/ld+json"`. Prefer **explicit redirects** when you want predictable URLs without an extra `HEAD`/`GET` for discovery, **fully offline** or hermetic tests, or when the host does not send a usable `Link` header.
113
+
114
+ ## JsonLdHelper
115
+
116
+ ```typescript
117
+ import { type IValidationFailure } from '@3sixty/core';
118
+ import { ValidationMode } from '@3sixty/data-core';
119
+ import { JsonLdHelper, type IJsonLdNodeObject } from '@3sixty/data-json-ld';
120
+
121
+ const compactedDocument = {
122
+ '@context': {
123
+ ex: 'https://example.org/vocab/',
124
+ id: '@id',
125
+ type: '@type',
126
+ name: 'ex:name'
127
+ },
128
+ id: 'urn:example:person:1',
129
+ type: 'ex:Person',
130
+ name: 'Ada'
131
+ };
132
+
133
+ const failures: IValidationFailure[] = [];
134
+ await JsonLdHelper.validate(compactedDocument, failures, {
135
+ validationMode: ValidationMode.Either,
136
+ failOnMissingType: false
137
+ });
138
+
139
+ const expanded = await JsonLdHelper.expand(compactedDocument);
140
+ const hasPersonType = await JsonLdHelper.isType(expanded, ['https://example.org/vocab/Person']);
141
+ const types = await JsonLdHelper.getType(expanded);
142
+ const id = await JsonLdHelper.getId(expanded);
143
+
144
+ console.log('Failure count:', failures.length);
145
+ console.log('Has person type:', hasPersonType);
146
+ console.log('Type list includes person:', types.includes('https://example.org/vocab/Person'));
147
+ console.log('Document id:', id);
148
+
149
+ const nodeObject = JsonLdHelper.toNodeObject(compactedDocument);
150
+ const structuredObject = JsonLdHelper.toStructuredObject<{ name: string }>(
151
+ nodeObject as IJsonLdNodeObject
152
+ );
153
+
154
+ console.log('Structured name:', structuredObject.name);
155
+ ```
156
+
157
+ ```typescript
158
+ import { JsonLdHelper } from '@3sixty/data-json-ld';
159
+
160
+ const expandedDocument = [
161
+ {
162
+ '@id': 'urn:example:article:1',
163
+ 'https://schema.org/name': [
164
+ { '@value': 'Hello', '@language': 'en' },
165
+ { '@value': 'Hallo', '@language': 'de' }
166
+ ],
167
+ 'https://schema.org/wordCount': [{ '@value': 240 }]
168
+ }
169
+ ];
170
+
171
+ const title = await JsonLdHelper.getPropertyValue(
172
+ expandedDocument,
173
+ 'https://schema.org/name',
174
+ 'en'
175
+ );
176
+ const [nameValues, wordCountValues] = await JsonLdHelper.getPropertyValues(expandedDocument, [
177
+ 'https://schema.org/name',
178
+ 'https://schema.org/wordCount'
179
+ ]);
180
+
181
+ console.log('English title:', title?.[0]);
182
+ console.log('Name value count:', nameValues?.length);
183
+ console.log('Word count value:', wordCountValues?.[0]);
184
+ ```
185
+
186
+ ```typescript
187
+ import { JsonLdHelper } from '@3sixty/data-json-ld';
188
+
189
+ const node = {
190
+ '@id': 'urn:example:item:1',
191
+ name: 'Ada',
192
+ role: 'Engineer'
193
+ };
194
+
195
+ const prefixed = JsonLdHelper.prefixProperties(node, 'ex', ['name', 'role']);
196
+ const stripped = JsonLdHelper.stripPrefixProperties(prefixed, 'ex');
197
+
198
+ console.log('Prefixed name:', prefixed['ex:name']);
199
+ console.log('Stripped name:', stripped.name);
200
+ ```
201
+
202
+ ## JsonLdDataTypes
203
+
204
+ ```typescript
205
+ import { DataTypeHelper } from '@3sixty/data-core';
206
+ import { JsonLdContexts, JsonLdDataTypes, JsonLdTypes } from '@3sixty/data-json-ld';
207
+
208
+ JsonLdDataTypes.registerTypes();
209
+
210
+ const schema = await DataTypeHelper.getSchemaForType(
211
+ `${JsonLdContexts.Namespace}${JsonLdTypes.Document}`
212
+ );
213
+ console.log('Registered schema type:', schema?.type);
214
+ ```
@@ -0,0 +1,25 @@
1
+ # Class: JsonLdDataTypes
2
+
3
+ Handle all the data types for JSON-LD.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new JsonLdDataTypes**(): `JsonLdDataTypes`
10
+
11
+ #### Returns
12
+
13
+ `JsonLdDataTypes`
14
+
15
+ ## Methods
16
+
17
+ ### registerTypes() {#registertypes}
18
+
19
+ > `static` **registerTypes**(): `void`
20
+
21
+ Register all the data types.
22
+
23
+ #### Returns
24
+
25
+ `void`
@@ -0,0 +1,371 @@
1
+ # Class: JsonLdHelper
2
+
3
+ Class to help with JSON LD.
4
+
5
+ ## Constructors
6
+
7
+ ### Constructor
8
+
9
+ > **new JsonLdHelper**(): `JsonLdHelper`
10
+
11
+ #### Returns
12
+
13
+ `JsonLdHelper`
14
+
15
+ ## Methods
16
+
17
+ ### validate() {#validate}
18
+
19
+ > `static` **validate**\<`T`\>(`document`, `validationFailures`, `options?`): `Promise`\<`boolean`\>
20
+
21
+ Validate a JSON-LD document.
22
+
23
+ #### Type Parameters
24
+
25
+ ##### T
26
+
27
+ `T` *extends* [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md) = [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
28
+
29
+ #### Parameters
30
+
31
+ ##### document
32
+
33
+ `T`
34
+
35
+ The JSON-LD document to validate.
36
+
37
+ ##### validationFailures
38
+
39
+ `IValidationFailure`[]
40
+
41
+ The list of validation failures to add to.
42
+
43
+ ##### options?
44
+
45
+ Optional options for validation.
46
+
47
+ ###### validationMode?
48
+
49
+ `ValidationMode`
50
+
51
+ The validation mode to use, defaults to either.
52
+
53
+ ###### failOnMissingType?
54
+
55
+ `boolean`
56
+
57
+ If true, will fail validation if the data type is missing, defaults to false.
58
+
59
+ #### Returns
60
+
61
+ `Promise`\<`boolean`\>
62
+
63
+ True if the document was valid.
64
+
65
+ ***
66
+
67
+ ### toNodeObject() {#tonodeobject}
68
+
69
+ > `static` **toNodeObject**\<`T`\>(`object`): `T` & [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
70
+
71
+ Convert an object to a JSON-LD node object.
72
+
73
+ #### Type Parameters
74
+
75
+ ##### T
76
+
77
+ `T` = `unknown`
78
+
79
+ #### Parameters
80
+
81
+ ##### object
82
+
83
+ `T`
84
+
85
+ The object to convert.
86
+
87
+ #### Returns
88
+
89
+ `T` & [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
90
+
91
+ The JSON-LD node object.
92
+
93
+ ***
94
+
95
+ ### toStructuredObject() {#tostructuredobject}
96
+
97
+ > `static` **toStructuredObject**\<`T`\>(`nodeObject`): `T`
98
+
99
+ Convert the JSON-LD node object to a structured object.
100
+
101
+ #### Type Parameters
102
+
103
+ ##### T
104
+
105
+ `T` = `unknown`
106
+
107
+ #### Parameters
108
+
109
+ ##### nodeObject
110
+
111
+ [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
112
+
113
+ The JSON-LD node object to convert.
114
+
115
+ #### Returns
116
+
117
+ `T`
118
+
119
+ The structured object.
120
+
121
+ ***
122
+
123
+ ### expand() {#expand}
124
+
125
+ > `static` **expand**(`document`): `Promise`\<[`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)[]\>
126
+
127
+ Expand the JSON-LD document.
128
+
129
+ #### Parameters
130
+
131
+ ##### document
132
+
133
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
134
+
135
+ The JSON-LD document to expand.
136
+
137
+ #### Returns
138
+
139
+ `Promise`\<[`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)[]\>
140
+
141
+ The expanded JSON-LD document.
142
+
143
+ ***
144
+
145
+ ### isType() {#istype}
146
+
147
+ > `static` **isType**(`documentOrExpanded`, `type`): `Promise`\<`boolean`\>
148
+
149
+ Expand the JSON-LD document and check if it is of a specific type.
150
+
151
+ #### Parameters
152
+
153
+ ##### documentOrExpanded
154
+
155
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
156
+
157
+ The JSON-LD document to check or already expanded document.
158
+
159
+ ##### type
160
+
161
+ `string`[]
162
+
163
+ The type to check for.
164
+
165
+ #### Returns
166
+
167
+ `Promise`\<`boolean`\>
168
+
169
+ True if the document is of the specified type.
170
+
171
+ ***
172
+
173
+ ### getType() {#gettype}
174
+
175
+ > `static` **getType**(`documentOrExpanded`): `Promise`\<`string`[]\>
176
+
177
+ Get the types from the document.
178
+
179
+ #### Parameters
180
+
181
+ ##### documentOrExpanded
182
+
183
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
184
+
185
+ The JSON-LD document to check or already expanded document.
186
+
187
+ #### Returns
188
+
189
+ `Promise`\<`string`[]\>
190
+
191
+ The type(s) extracted from the document.
192
+
193
+ ***
194
+
195
+ ### getId() {#getid}
196
+
197
+ > `static` **getId**(`documentOrExpanded`, `additionalIdProperties?`): `Promise`\<`string` \| `undefined`\>
198
+
199
+ Get the id from the document.
200
+
201
+ #### Parameters
202
+
203
+ ##### documentOrExpanded
204
+
205
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
206
+
207
+ The JSON-LD document to get the id from or already expanded document.
208
+
209
+ ##### additionalIdProperties?
210
+
211
+ `string`[]
212
+
213
+ Optional additional properties to check for the id, in addition to "@id" and "id".
214
+
215
+ #### Returns
216
+
217
+ `Promise`\<`string` \| `undefined`\>
218
+
219
+ The id extracted from the document.
220
+
221
+ ***
222
+
223
+ ### getPropertyValue() {#getpropertyvalue}
224
+
225
+ > `static` **getPropertyValue**(`documentOrExpanded`, `propertyFullName`, `language?`): `Promise`\<[`IJsonLdNodePrimitive`](../type-aliases/IJsonLdNodePrimitive.md)[] \| `undefined`\>
226
+
227
+ Get property values by a single full expanded property name.
228
+
229
+ #### Parameters
230
+
231
+ ##### documentOrExpanded
232
+
233
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
234
+
235
+ The JSON-LD document to get the property from or already expanded document.
236
+
237
+ ##### propertyFullName
238
+
239
+ `string`
240
+
241
+ The full expanded property name.
242
+
243
+ ##### language?
244
+
245
+ `string`
246
+
247
+ Optional filter values by their language property.
248
+
249
+ #### Returns
250
+
251
+ `Promise`\<[`IJsonLdNodePrimitive`](../type-aliases/IJsonLdNodePrimitive.md)[] \| `undefined`\>
252
+
253
+ Matching property values for the input property.
254
+
255
+ ***
256
+
257
+ ### getPropertyValues() {#getpropertyvalues}
258
+
259
+ > `static` **getPropertyValues**(`documentOrExpanded`, `propertyFullNames`, `language?`): `Promise`\<([`IJsonLdNodePrimitive`](../type-aliases/IJsonLdNodePrimitive.md)[] \| `undefined`)[]\>
260
+
261
+ Get property values by their full expanded property names.
262
+
263
+ #### Parameters
264
+
265
+ ##### documentOrExpanded
266
+
267
+ [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
268
+
269
+ The JSON-LD document to get the property from or already expanded document.
270
+
271
+ ##### propertyFullNames
272
+
273
+ `string`[]
274
+
275
+ The full expanded property names.
276
+
277
+ ##### language?
278
+
279
+ `string`
280
+
281
+ Optional filter values by their language property.
282
+
283
+ #### Returns
284
+
285
+ `Promise`\<([`IJsonLdNodePrimitive`](../type-aliases/IJsonLdNodePrimitive.md)[] \| `undefined`)[]\>
286
+
287
+ Matching property values for each input property, in the same index order.
288
+
289
+ ***
290
+
291
+ ### prefixProperties() {#prefixproperties}
292
+
293
+ > `static` **prefixProperties**\<`T`\>(`nodeObject`, `prefix`, `properties?`): [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
294
+
295
+ Prefix all properties in the document with the provided prefix, except for JSON-LD properties.
296
+ This is useful for ensuring that all properties are fully qualified with a namespace.
297
+ For example, if the prefix is "ex" and the document has a property "name", it will be transformed to "ex:name".
298
+
299
+ #### Type Parameters
300
+
301
+ ##### T
302
+
303
+ `T` *extends* [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
304
+
305
+ #### Parameters
306
+
307
+ ##### nodeObject
308
+
309
+ `T`
310
+
311
+ The JSON-LD node object to prefix properties on.
312
+
313
+ ##### prefix
314
+
315
+ `string`
316
+
317
+ The prefix to add to the properties.
318
+
319
+ ##### properties?
320
+
321
+ `string`[]
322
+
323
+ Optional list of properties to prefix. If not provided, all properties except for JSON-LD properties.
324
+
325
+ #### Returns
326
+
327
+ [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
328
+
329
+ A new JSON-LD node object with the properties prefixed.
330
+
331
+ ***
332
+
333
+ ### stripPrefixProperties() {#stripprefixproperties}
334
+
335
+ > `static` **stripPrefixProperties**\<`T`\>(`nodeObject`, `prefix`, `properties?`): [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
336
+
337
+ Strip a prefix from properties in the document, except for JSON-LD properties.
338
+ This is useful for converting fully qualified namespaced properties back to local names.
339
+ For example, if the prefix is "ex" and the document has a property "ex:name", it will be transformed to "name".
340
+
341
+ #### Type Parameters
342
+
343
+ ##### T
344
+
345
+ `T` *extends* [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
346
+
347
+ #### Parameters
348
+
349
+ ##### nodeObject
350
+
351
+ `T`
352
+
353
+ The JSON-LD node object to strip prefixed properties from.
354
+
355
+ ##### prefix
356
+
357
+ `string`
358
+
359
+ The prefix to remove from the properties.
360
+
361
+ ##### properties?
362
+
363
+ `string`[]
364
+
365
+ Optional list of unprefixed properties to strip. If not provided, all matching prefixed properties.
366
+
367
+ #### Returns
368
+
369
+ [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
370
+
371
+ A new JSON-LD node object with the prefix stripped from matching properties.