@speclynx/apidom-datamodel 1.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSES/AFL-3.0.txt +182 -0
- package/LICENSES/Apache-2.0.txt +202 -0
- package/LICENSES/BSD-3-Clause.txt +26 -0
- package/LICENSES/MIT.txt +9 -0
- package/NOTICE +74 -0
- package/README.md +479 -0
- package/dist/apidom-datamodel.browser.js +2717 -0
- package/dist/apidom-datamodel.browser.min.js +1 -0
- package/package.json +53 -0
- package/src/KeyValuePair.cjs +38 -0
- package/src/KeyValuePair.mjs +34 -0
- package/src/Namespace.cjs +212 -0
- package/src/Namespace.mjs +206 -0
- package/src/ObjectSlice.cjs +206 -0
- package/src/ObjectSlice.mjs +202 -0
- package/src/elements/LinkElement.cjs +44 -0
- package/src/elements/LinkElement.mjs +39 -0
- package/src/elements/RefElement.cjs +31 -0
- package/src/elements/RefElement.mjs +26 -0
- package/src/index.cjs +25 -0
- package/src/index.mjs +6 -0
- package/src/primitives/ArrayElement.cjs +176 -0
- package/src/primitives/ArrayElement.mjs +169 -0
- package/src/primitives/BooleanElement.cjs +20 -0
- package/src/primitives/BooleanElement.mjs +15 -0
- package/src/primitives/CollectionElement.cjs +194 -0
- package/src/primitives/CollectionElement.mjs +187 -0
- package/src/primitives/Element.cjs +438 -0
- package/src/primitives/Element.mjs +433 -0
- package/src/primitives/MemberElement.cjs +54 -0
- package/src/primitives/MemberElement.mjs +49 -0
- package/src/primitives/NullElement.cjs +28 -0
- package/src/primitives/NullElement.mjs +23 -0
- package/src/primitives/NumberElement.cjs +20 -0
- package/src/primitives/NumberElement.mjs +15 -0
- package/src/primitives/ObjectElement.cjs +222 -0
- package/src/primitives/ObjectElement.mjs +216 -0
- package/src/primitives/StringElement.cjs +27 -0
- package/src/primitives/StringElement.mjs +22 -0
- package/src/registration.cjs +87 -0
- package/src/registration.mjs +70 -0
- package/src/serialisers/JSONSerialiser.cjs +144 -0
- package/src/serialisers/JSONSerialiser.mjs +140 -0
- package/src/types.cjs +3 -0
- package/src/types.mjs +1 -0
- package/types/apidom-datamodel.d.ts +887 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
/**
|
|
6
|
+
* Callback type for ObjectSlice iteration methods.
|
|
7
|
+
* Receives (value, key, member) - the standard pattern for object-like iteration.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Callback type for ObjectSlice forEach that also receives the index.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* ObjectSlice is a collection wrapper for MemberElement arrays.
|
|
18
|
+
* It provides functional methods with (value, key, member) callback signatures,
|
|
19
|
+
* which is the standard pattern for iterating over object-like structures.
|
|
20
|
+
*
|
|
21
|
+
* Unlike ArraySlice, ObjectSlice uses composition rather than inheritance
|
|
22
|
+
* because its callback signatures are fundamentally different.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
class ObjectSlice {
|
|
27
|
+
elements;
|
|
28
|
+
constructor(elements) {
|
|
29
|
+
this.elements = elements ?? [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Converts all member elements to their JavaScript values.
|
|
34
|
+
* Returns an array of \{ key, value \} objects.
|
|
35
|
+
*/
|
|
36
|
+
toValue() {
|
|
37
|
+
return this.elements.map(member => ({
|
|
38
|
+
key: member.key?.toValue(),
|
|
39
|
+
value: member.value?.toValue()
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Maps over the member elements, calling callback with (value, key, member).
|
|
45
|
+
* @param callback - Function to execute for each member
|
|
46
|
+
* @param thisArg - Value to use as this when executing callback
|
|
47
|
+
*/
|
|
48
|
+
map(callback, thisArg) {
|
|
49
|
+
return this.elements.map(member => {
|
|
50
|
+
const value = member.value;
|
|
51
|
+
const key = member.key;
|
|
52
|
+
if (value === undefined || key === undefined) {
|
|
53
|
+
throw new Error('MemberElement must have both key and value');
|
|
54
|
+
}
|
|
55
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Filters member elements using the provided callback.
|
|
61
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
62
|
+
* @param thisArg - Value to use as this when executing callback
|
|
63
|
+
*/
|
|
64
|
+
filter(callback, thisArg) {
|
|
65
|
+
const filtered = this.elements.filter(member => {
|
|
66
|
+
const value = member.value;
|
|
67
|
+
const key = member.key;
|
|
68
|
+
if (value === undefined || key === undefined) {
|
|
69
|
+
return false; // Skip malformed members
|
|
70
|
+
}
|
|
71
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
72
|
+
});
|
|
73
|
+
return new ObjectSlice(filtered);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Rejects member elements that match the provided callback.
|
|
78
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
79
|
+
* @param thisArg - Value to use as this when executing callback
|
|
80
|
+
*/
|
|
81
|
+
reject(callback, thisArg) {
|
|
82
|
+
const results = [];
|
|
83
|
+
for (const member of this.elements) {
|
|
84
|
+
const value = member.value;
|
|
85
|
+
const key = member.key;
|
|
86
|
+
if (value === undefined || key === undefined) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (!callback.call(thisArg, value, key, member)) {
|
|
90
|
+
results.push(member);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return new ObjectSlice(results);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Executes a provided function once for each member element.
|
|
98
|
+
* @param callback - Function that receives (value, key, member, index)
|
|
99
|
+
* @param thisArg - Value to use as this when executing callback
|
|
100
|
+
*/
|
|
101
|
+
forEach(callback, thisArg) {
|
|
102
|
+
this.elements.forEach((member, index) => {
|
|
103
|
+
const value = member.value;
|
|
104
|
+
const key = member.key;
|
|
105
|
+
if (value === undefined || key === undefined) {
|
|
106
|
+
return; // Skip malformed members
|
|
107
|
+
}
|
|
108
|
+
if (thisArg !== undefined) {
|
|
109
|
+
callback.call(thisArg, value, key, member, index);
|
|
110
|
+
} else {
|
|
111
|
+
callback(value, key, member, index);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns the first member element that satisfies the callback.
|
|
118
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
119
|
+
* @param thisArg - Value to use as this when executing callback
|
|
120
|
+
*/
|
|
121
|
+
find(callback, thisArg) {
|
|
122
|
+
return this.elements.find(member => {
|
|
123
|
+
const value = member.value;
|
|
124
|
+
const key = member.key;
|
|
125
|
+
if (value === undefined || key === undefined) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Returns an array of all keys' values.
|
|
134
|
+
*/
|
|
135
|
+
keys() {
|
|
136
|
+
return this.elements.map(member => member.key?.toValue()).filter(key => key !== undefined);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Returns an array of all values' values.
|
|
141
|
+
*/
|
|
142
|
+
values() {
|
|
143
|
+
return this.elements.map(member => member.value?.toValue()).filter(value => value !== undefined);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Returns the number of elements in the slice.
|
|
148
|
+
*/
|
|
149
|
+
get length() {
|
|
150
|
+
return this.elements.length;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Returns whether the slice is empty.
|
|
155
|
+
*/
|
|
156
|
+
get isEmpty() {
|
|
157
|
+
return this.length === 0;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the first element in the slice or undefined if empty.
|
|
162
|
+
*/
|
|
163
|
+
get first() {
|
|
164
|
+
return this.elements[0];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Gets the element at the specified index.
|
|
169
|
+
* @param index - The index of the element to get
|
|
170
|
+
*/
|
|
171
|
+
get(index) {
|
|
172
|
+
return this.elements[index];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Adds the given member element to the end of the slice.
|
|
177
|
+
* @param member - The member element to add
|
|
178
|
+
*/
|
|
179
|
+
push(member) {
|
|
180
|
+
this.elements.push(member);
|
|
181
|
+
return this;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Creates a deep clone of the ObjectSlice.
|
|
186
|
+
*/
|
|
187
|
+
clone() {
|
|
188
|
+
return new ObjectSlice(this.elements.map(element => element.clone()));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Determines whether the slice includes a member with the given key value.
|
|
193
|
+
* @param keyValue - The key value to search for
|
|
194
|
+
*/
|
|
195
|
+
includesKey(keyValue) {
|
|
196
|
+
return this.elements.some(member => member.key?.equals(keyValue));
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Iterator support - allows for...of loops.
|
|
201
|
+
*/
|
|
202
|
+
[Symbol.iterator]() {
|
|
203
|
+
return this.elements[Symbol.iterator]();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
var _default = exports.default = ObjectSlice;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callback type for ObjectSlice iteration methods.
|
|
3
|
+
* Receives (value, key, member) - the standard pattern for object-like iteration.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Callback type for ObjectSlice forEach that also receives the index.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* ObjectSlice is a collection wrapper for MemberElement arrays.
|
|
14
|
+
* It provides functional methods with (value, key, member) callback signatures,
|
|
15
|
+
* which is the standard pattern for iterating over object-like structures.
|
|
16
|
+
*
|
|
17
|
+
* Unlike ArraySlice, ObjectSlice uses composition rather than inheritance
|
|
18
|
+
* because its callback signatures are fundamentally different.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
class ObjectSlice {
|
|
23
|
+
elements;
|
|
24
|
+
constructor(elements) {
|
|
25
|
+
this.elements = elements ?? [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converts all member elements to their JavaScript values.
|
|
30
|
+
* Returns an array of \{ key, value \} objects.
|
|
31
|
+
*/
|
|
32
|
+
toValue() {
|
|
33
|
+
return this.elements.map(member => ({
|
|
34
|
+
key: member.key?.toValue(),
|
|
35
|
+
value: member.value?.toValue()
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Maps over the member elements, calling callback with (value, key, member).
|
|
41
|
+
* @param callback - Function to execute for each member
|
|
42
|
+
* @param thisArg - Value to use as this when executing callback
|
|
43
|
+
*/
|
|
44
|
+
map(callback, thisArg) {
|
|
45
|
+
return this.elements.map(member => {
|
|
46
|
+
const value = member.value;
|
|
47
|
+
const key = member.key;
|
|
48
|
+
if (value === undefined || key === undefined) {
|
|
49
|
+
throw new Error('MemberElement must have both key and value');
|
|
50
|
+
}
|
|
51
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Filters member elements using the provided callback.
|
|
57
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
58
|
+
* @param thisArg - Value to use as this when executing callback
|
|
59
|
+
*/
|
|
60
|
+
filter(callback, thisArg) {
|
|
61
|
+
const filtered = this.elements.filter(member => {
|
|
62
|
+
const value = member.value;
|
|
63
|
+
const key = member.key;
|
|
64
|
+
if (value === undefined || key === undefined) {
|
|
65
|
+
return false; // Skip malformed members
|
|
66
|
+
}
|
|
67
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
68
|
+
});
|
|
69
|
+
return new ObjectSlice(filtered);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Rejects member elements that match the provided callback.
|
|
74
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
75
|
+
* @param thisArg - Value to use as this when executing callback
|
|
76
|
+
*/
|
|
77
|
+
reject(callback, thisArg) {
|
|
78
|
+
const results = [];
|
|
79
|
+
for (const member of this.elements) {
|
|
80
|
+
const value = member.value;
|
|
81
|
+
const key = member.key;
|
|
82
|
+
if (value === undefined || key === undefined) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (!callback.call(thisArg, value, key, member)) {
|
|
86
|
+
results.push(member);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return new ObjectSlice(results);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Executes a provided function once for each member element.
|
|
94
|
+
* @param callback - Function that receives (value, key, member, index)
|
|
95
|
+
* @param thisArg - Value to use as this when executing callback
|
|
96
|
+
*/
|
|
97
|
+
forEach(callback, thisArg) {
|
|
98
|
+
this.elements.forEach((member, index) => {
|
|
99
|
+
const value = member.value;
|
|
100
|
+
const key = member.key;
|
|
101
|
+
if (value === undefined || key === undefined) {
|
|
102
|
+
return; // Skip malformed members
|
|
103
|
+
}
|
|
104
|
+
if (thisArg !== undefined) {
|
|
105
|
+
callback.call(thisArg, value, key, member, index);
|
|
106
|
+
} else {
|
|
107
|
+
callback(value, key, member, index);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Returns the first member element that satisfies the callback.
|
|
114
|
+
* @param callback - Function that receives (value, key, member) and returns boolean
|
|
115
|
+
* @param thisArg - Value to use as this when executing callback
|
|
116
|
+
*/
|
|
117
|
+
find(callback, thisArg) {
|
|
118
|
+
return this.elements.find(member => {
|
|
119
|
+
const value = member.value;
|
|
120
|
+
const key = member.key;
|
|
121
|
+
if (value === undefined || key === undefined) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return thisArg !== undefined ? callback.call(thisArg, value, key, member) : callback(value, key, member);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Returns an array of all keys' values.
|
|
130
|
+
*/
|
|
131
|
+
keys() {
|
|
132
|
+
return this.elements.map(member => member.key?.toValue()).filter(key => key !== undefined);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns an array of all values' values.
|
|
137
|
+
*/
|
|
138
|
+
values() {
|
|
139
|
+
return this.elements.map(member => member.value?.toValue()).filter(value => value !== undefined);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Returns the number of elements in the slice.
|
|
144
|
+
*/
|
|
145
|
+
get length() {
|
|
146
|
+
return this.elements.length;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns whether the slice is empty.
|
|
151
|
+
*/
|
|
152
|
+
get isEmpty() {
|
|
153
|
+
return this.length === 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Returns the first element in the slice or undefined if empty.
|
|
158
|
+
*/
|
|
159
|
+
get first() {
|
|
160
|
+
return this.elements[0];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Gets the element at the specified index.
|
|
165
|
+
* @param index - The index of the element to get
|
|
166
|
+
*/
|
|
167
|
+
get(index) {
|
|
168
|
+
return this.elements[index];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Adds the given member element to the end of the slice.
|
|
173
|
+
* @param member - The member element to add
|
|
174
|
+
*/
|
|
175
|
+
push(member) {
|
|
176
|
+
this.elements.push(member);
|
|
177
|
+
return this;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Creates a deep clone of the ObjectSlice.
|
|
182
|
+
*/
|
|
183
|
+
clone() {
|
|
184
|
+
return new ObjectSlice(this.elements.map(element => element.clone()));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Determines whether the slice includes a member with the given key value.
|
|
189
|
+
* @param keyValue - The key value to search for
|
|
190
|
+
*/
|
|
191
|
+
includesKey(keyValue) {
|
|
192
|
+
return this.elements.some(member => member.key?.equals(keyValue));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Iterator support - allows for...of loops.
|
|
197
|
+
*/
|
|
198
|
+
[Symbol.iterator]() {
|
|
199
|
+
return this.elements[Symbol.iterator]();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
export default ObjectSlice;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _Element = _interopRequireDefault(require("../primitives/Element.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* LinkElement represents a hyperlink in ApiDOM.
|
|
9
|
+
*
|
|
10
|
+
* Hyperlinking MAY be used to link to other resources, provide links to
|
|
11
|
+
* instructions on how to process a given element (by way of a profile or
|
|
12
|
+
* other means), and may be used to provide meta data about the element in
|
|
13
|
+
* which it's found. The meaning and purpose of the hyperlink is defined by
|
|
14
|
+
* the link relation according to RFC 5988.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
class LinkElement extends _Element.default {
|
|
19
|
+
constructor(content, meta, attributes) {
|
|
20
|
+
super(content || [], meta, attributes);
|
|
21
|
+
this.element = 'link';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The relation identifier for the link, as defined in RFC 5988.
|
|
26
|
+
*/
|
|
27
|
+
get relation() {
|
|
28
|
+
return this.attributes.get('relation');
|
|
29
|
+
}
|
|
30
|
+
set relation(relation) {
|
|
31
|
+
this.attributes.set('relation', relation);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The URI for the given link.
|
|
36
|
+
*/
|
|
37
|
+
get href() {
|
|
38
|
+
return this.attributes.get('href');
|
|
39
|
+
}
|
|
40
|
+
set href(href) {
|
|
41
|
+
this.attributes.set('href', href);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
var _default = exports.default = LinkElement;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Element from "../primitives/Element.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* LinkElement represents a hyperlink in ApiDOM.
|
|
4
|
+
*
|
|
5
|
+
* Hyperlinking MAY be used to link to other resources, provide links to
|
|
6
|
+
* instructions on how to process a given element (by way of a profile or
|
|
7
|
+
* other means), and may be used to provide meta data about the element in
|
|
8
|
+
* which it's found. The meaning and purpose of the hyperlink is defined by
|
|
9
|
+
* the link relation according to RFC 5988.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class LinkElement extends Element {
|
|
14
|
+
constructor(content, meta, attributes) {
|
|
15
|
+
super(content || [], meta, attributes);
|
|
16
|
+
this.element = 'link';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The relation identifier for the link, as defined in RFC 5988.
|
|
21
|
+
*/
|
|
22
|
+
get relation() {
|
|
23
|
+
return this.attributes.get('relation');
|
|
24
|
+
}
|
|
25
|
+
set relation(relation) {
|
|
26
|
+
this.attributes.set('relation', relation);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The URI for the given link.
|
|
31
|
+
*/
|
|
32
|
+
get href() {
|
|
33
|
+
return this.attributes.get('href');
|
|
34
|
+
}
|
|
35
|
+
set href(href) {
|
|
36
|
+
this.attributes.set('href', href);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default LinkElement;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.default = void 0;
|
|
6
|
+
var _Element = _interopRequireDefault(require("../primitives/Element.cjs"));
|
|
7
|
+
/**
|
|
8
|
+
* RefElement represents a reference to another element in ApiDOM.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
class RefElement extends _Element.default {
|
|
12
|
+
constructor(content, meta, attributes) {
|
|
13
|
+
super(content || [], meta, attributes);
|
|
14
|
+
this.element = 'ref';
|
|
15
|
+
if (!this.path) {
|
|
16
|
+
this.path = 'element';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Path of referenced element to transclude instead of element itself.
|
|
22
|
+
* @defaultValue 'element'
|
|
23
|
+
*/
|
|
24
|
+
get path() {
|
|
25
|
+
return this.attributes.get('path');
|
|
26
|
+
}
|
|
27
|
+
set path(newValue) {
|
|
28
|
+
this.attributes.set('path', newValue);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var _default = exports.default = RefElement;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Element from "../primitives/Element.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* RefElement represents a reference to another element in ApiDOM.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
class RefElement extends Element {
|
|
7
|
+
constructor(content, meta, attributes) {
|
|
8
|
+
super(content || [], meta, attributes);
|
|
9
|
+
this.element = 'ref';
|
|
10
|
+
if (!this.path) {
|
|
11
|
+
this.path = 'element';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Path of referenced element to transclude instead of element itself.
|
|
17
|
+
* @defaultValue 'element'
|
|
18
|
+
*/
|
|
19
|
+
get path() {
|
|
20
|
+
return this.attributes.get('path');
|
|
21
|
+
}
|
|
22
|
+
set path(newValue) {
|
|
23
|
+
this.attributes.set('path', newValue);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export default RefElement;
|
package/src/index.cjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault").default;
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.refract = exports.StringElement = exports.RefElement = exports.ObjectSlice = exports.ObjectElement = exports.NumberElement = exports.NullElement = exports.Namespace = exports.MemberElement = exports.LinkElement = exports.KeyValuePair = exports.JSONSerialiser = exports.Element = exports.CollectionElement = exports.BooleanElement = exports.ArrayElement = void 0;
|
|
6
|
+
var _Namespace = _interopRequireDefault(require("./Namespace.cjs"));
|
|
7
|
+
exports.Namespace = _Namespace.default;
|
|
8
|
+
var _KeyValuePair = _interopRequireDefault(require("./KeyValuePair.cjs"));
|
|
9
|
+
exports.KeyValuePair = _KeyValuePair.default;
|
|
10
|
+
var _registration = require("./registration.cjs");
|
|
11
|
+
exports.ObjectSlice = _registration.ObjectSlice;
|
|
12
|
+
exports.Element = _registration.Element;
|
|
13
|
+
exports.CollectionElement = _registration.CollectionElement;
|
|
14
|
+
exports.StringElement = _registration.StringElement;
|
|
15
|
+
exports.NumberElement = _registration.NumberElement;
|
|
16
|
+
exports.BooleanElement = _registration.BooleanElement;
|
|
17
|
+
exports.NullElement = _registration.NullElement;
|
|
18
|
+
exports.ArrayElement = _registration.ArrayElement;
|
|
19
|
+
exports.ObjectElement = _registration.ObjectElement;
|
|
20
|
+
exports.MemberElement = _registration.MemberElement;
|
|
21
|
+
exports.RefElement = _registration.RefElement;
|
|
22
|
+
exports.LinkElement = _registration.LinkElement;
|
|
23
|
+
exports.refract = _registration.refract;
|
|
24
|
+
var _JSONSerialiser = _interopRequireDefault(require("./serialisers/JSONSerialiser.cjs"));
|
|
25
|
+
exports.JSONSerialiser = _JSONSerialiser.default;
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Namespace } from "./Namespace.mjs";
|
|
2
|
+
export { default as KeyValuePair } from "./KeyValuePair.mjs"; // Re-export elements directly to preserve JSDoc
|
|
3
|
+
export { ObjectSlice, Element, CollectionElement, StringElement, NumberElement, BooleanElement, NullElement, ArrayElement, ObjectElement, MemberElement, RefElement, LinkElement, refract } from "./registration.mjs";
|
|
4
|
+
export { default as JSONSerialiser } from "./serialisers/JSONSerialiser.mjs"; // Re-export types - essential public API
|
|
5
|
+
// Re-export types - for advanced users extending the library
|
|
6
|
+
// Re-export types - used in public method signatures
|