@twin.org/data-json-ld 0.0.1-next.20 → 0.0.1-next.21

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.
@@ -1,7 +1,7 @@
1
1
  import type { RemoteDocument, Url } from "jsonld/jsonld-spec";
2
2
  import type { IJsonLdContextDefinitionElement } from "../models/IJsonLdContextDefinitionElement";
3
3
  import type { IJsonLdContextDefinitionRoot } from "../models/IJsonLdContextDefinitionRoot";
4
- import type { IJsonLdDocument } from "../models/IJsonLdDocument";
4
+ import type { IJsonLdNodeObject } from "../models/IJsonLdNodeObject";
5
5
  /**
6
6
  * JSON-LD Processor.
7
7
  */
@@ -20,13 +20,13 @@ export declare class JsonLdProcessor {
20
20
  * @param context The context to compact the document to, if not provided will try and gather from the object.
21
21
  * @returns The compacted JSON-LD document.
22
22
  */
23
- static compact(document: IJsonLdDocument, context?: IJsonLdContextDefinitionRoot): Promise<IJsonLdDocument>;
23
+ static compact<T extends IJsonLdNodeObject>(document: T, context?: IJsonLdContextDefinitionRoot): Promise<T>;
24
24
  /**
25
25
  * Expand a document, removing its context.
26
26
  * @param compacted The compacted JSON-LD document to expand.
27
27
  * @returns The expanded JSON-LD document.
28
28
  */
29
- static expand(compacted: IJsonLdDocument): Promise<IJsonLdDocument>;
29
+ static expand<T extends IJsonLdNodeObject>(compacted: T): Promise<IJsonLdNodeObject[]>;
30
30
  /**
31
31
  * Add a redirect to use during document resolution.
32
32
  * @param from The URL to redirect from.
@@ -46,9 +46,7 @@ export declare class JsonLdProcessor {
46
46
  * @param initial The initial context.
47
47
  * @returns The combined contexts.
48
48
  */
49
- static gatherContexts(element: {
50
- [id: string]: unknown;
51
- }, initial?: IJsonLdContextDefinitionRoot): IJsonLdContextDefinitionRoot | undefined;
49
+ static gatherContexts<T extends IJsonLdNodeObject>(element: T, initial?: IJsonLdContextDefinitionRoot): IJsonLdContextDefinitionRoot | undefined;
52
50
  /**
53
51
  * Remove all the contexts that match the pattern.
54
52
  * @param context The context to remove the entries from.
package/docs/changelog.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # @twin.org/data-json-ld - Changelog
2
2
 
3
- ## v0.0.1-next.20
3
+ ## v0.0.1-next.21
4
4
 
5
5
  - Initial Release
@@ -34,15 +34,19 @@ The document loader to use.
34
34
 
35
35
  ### compact()
36
36
 
37
- > `static` **compact**(`document`, `context`?): `Promise`\<[`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)\>
37
+ > `static` **compact**\<`T`\>(`document`, `context`?): `Promise`\<`T`\>
38
38
 
39
39
  Compact a document according to a particular context.
40
40
 
41
+ #### Type Parameters
42
+
43
+ • **T** *extends* [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
44
+
41
45
  #### Parameters
42
46
 
43
47
  ##### document
44
48
 
45
- [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
49
+ `T`
46
50
 
47
51
  The JSON-LD document to compact.
48
52
 
@@ -54,7 +58,7 @@ The context to compact the document to, if not provided will try and gather from
54
58
 
55
59
  #### Returns
56
60
 
57
- `Promise`\<[`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)\>
61
+ `Promise`\<`T`\>
58
62
 
59
63
  The compacted JSON-LD document.
60
64
 
@@ -62,21 +66,25 @@ The compacted JSON-LD document.
62
66
 
63
67
  ### expand()
64
68
 
65
- > `static` **expand**(`compacted`): `Promise`\<[`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)\>
69
+ > `static` **expand**\<`T`\>(`compacted`): `Promise`\<[`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)[]\>
66
70
 
67
71
  Expand a document, removing its context.
68
72
 
73
+ #### Type Parameters
74
+
75
+ • **T** *extends* [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
76
+
69
77
  #### Parameters
70
78
 
71
79
  ##### compacted
72
80
 
73
- [`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)
81
+ `T`
74
82
 
75
83
  The compacted JSON-LD document to expand.
76
84
 
77
85
  #### Returns
78
86
 
79
- `Promise`\<[`IJsonLdDocument`](../type-aliases/IJsonLdDocument.md)\>
87
+ `Promise`\<[`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)[]\>
80
88
 
81
89
  The expanded JSON-LD document.
82
90
 
@@ -138,14 +146,20 @@ The combined context.
138
146
 
139
147
  ### gatherContexts()
140
148
 
141
- > `static` **gatherContexts**(`element`, `initial`?): `undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
149
+ > `static` **gatherContexts**\<`T`\>(`element`, `initial`?): `undefined` \| [`IJsonLdContextDefinitionRoot`](../type-aliases/IJsonLdContextDefinitionRoot.md)
142
150
 
143
151
  Gather all the contexts from the element and it's children.
144
152
 
153
+ #### Type Parameters
154
+
155
+ • **T** *extends* [`IJsonLdNodeObject`](../interfaces/IJsonLdNodeObject.md)
156
+
145
157
  #### Parameters
146
158
 
147
159
  ##### element
148
160
 
161
+ `T`
162
+
149
163
  The element to gather the contexts from.
150
164
 
151
165
  ##### initial?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/data-json-ld",
3
- "version": "0.0.1-next.20",
3
+ "version": "0.0.1-next.21",
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.1-next.20",
18
+ "@twin.org/data-core": "0.0.1-next.21",
19
19
  "@twin.org/entity": "next",
20
20
  "@twin.org/nameof": "next",
21
21
  "@twin.org/web": "next",