@fedify/vocab-runtime 2.4.0-dev.2122 → 2.4.0-dev.2129
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/deno.json +1 -1
- package/dist/{docloader-Dr8wEkif.d.cts → docloader-oRpq1nQ8.d.cts} +8 -1
- package/dist/{docloader-Dr8wEkif.d.ts → docloader-oRpq1nQ8.d.ts} +8 -1
- package/dist/internal/jsonld-cache.cjs +50 -0
- package/dist/internal/jsonld-cache.d.cts +28 -2
- package/dist/internal/jsonld-cache.d.ts +28 -2
- package/dist/internal/jsonld-cache.js +48 -1
- package/dist/internal/portable-dereference.cjs +28 -12
- package/dist/internal/portable-dereference.d.cts +12 -4
- package/dist/internal/portable-dereference.d.ts +12 -4
- package/dist/internal/portable-dereference.js +28 -12
- package/dist/mod.cjs +15 -9
- package/dist/mod.d.cts +8 -2
- package/dist/mod.d.ts +8 -2
- package/dist/mod.js +15 -9
- package/dist/{portable-comBI05Y.d.cts → portable-Drfl02vZ.d.cts} +1 -1
- package/dist/{portable-DH3947GK.d.ts → portable-rwhiyMvY.d.ts} +1 -1
- package/dist/tests/{body-tLaZa-9t.cjs → body-B98QT2cn.cjs} +1 -1
- package/dist/tests/{body-DkyJy_0c.mjs → body-CrD70FCs.mjs} +1 -1
- package/dist/tests/body.test.cjs +1 -1
- package/dist/tests/body.test.mjs +1 -1
- package/dist/tests/decimal.test.cjs +1 -1
- package/dist/tests/decimal.test.mjs +1 -1
- package/dist/tests/{docloader-DFs6K8ol.cjs → docloader-BVoNdutR.cjs} +16 -10
- package/dist/tests/{docloader-CSfFzxWm.mjs → docloader-CBscxl9w.mjs} +16 -10
- package/dist/tests/docloader.test.cjs +49 -2
- package/dist/tests/docloader.test.mjs +49 -2
- package/dist/tests/internal/portable-dereference.test.cjs +67 -6
- package/dist/tests/internal/portable-dereference.test.mjs +67 -6
- package/dist/tests/jsonld-cache-9jap4yM0.cjs +373 -0
- package/dist/tests/jsonld-cache-DnZS0z1G.mjs +324 -0
- package/dist/tests/jsonld-cache.test.cjs +20 -291
- package/dist/tests/jsonld-cache.test.mjs +2 -273
- package/dist/tests/{request-BLe2W5ua.cjs → request-BMNsRCJF.cjs} +1 -1
- package/dist/tests/{request-CmMy4YVK.mjs → request-CRVyLEa-.mjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.mjs +1 -1
- package/package.json +1 -1
- package/src/docloader.test.ts +73 -0
- package/src/docloader.ts +46 -17
- package/src/internal/jsonld-cache.ts +60 -0
- package/src/internal/portable-dereference.test.ts +71 -0
- package/src/internal/portable-dereference.ts +37 -24
- package/src/preprocessor.ts +7 -0
- package/dist/tests/jsonld-CmDhHNTx.cjs +0 -12
- package/dist/tests/jsonld-DweIJ07b.mjs +0 -5
|
@@ -1,286 +1,15 @@
|
|
|
1
1
|
const require_url = require("./url-BqlldzT8.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_jsonld_cache = require("./jsonld-cache-9jap4yM0.cjs");
|
|
3
3
|
let node_test = require("node:test");
|
|
4
4
|
let node_assert = require("node:assert");
|
|
5
|
-
//#region src/internal/jsonld-cache.ts
|
|
6
|
-
const noJsonLdContext = Symbol("noJsonLdContext");
|
|
7
|
-
/**
|
|
8
|
-
* Checks whether an IRI is trusted relative to another IRI.
|
|
9
|
-
*
|
|
10
|
-
* @internal Technically exported for generated vocabulary classes, but not
|
|
11
|
-
* part of the public API contract. This is not considered public API for
|
|
12
|
-
* Semantic Versioning decisions.
|
|
13
|
-
*/
|
|
14
|
-
function isTrustedIriOrigin(options, left, right) {
|
|
15
|
-
return options.crossOrigin === "trust" || left == null || right != null && (require_url.haveSameIriOrigin(left, right) || require_url.haveSameFe34Origin(left, right));
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Normalizes portable IRIs in JSON-LD cache data.
|
|
19
|
-
*
|
|
20
|
-
* @internal Technically exported for generated vocabulary classes, but not
|
|
21
|
-
* part of the public API contract. This is not considered public API for
|
|
22
|
-
* Semantic Versioning decisions.
|
|
23
|
-
*/
|
|
24
|
-
function normalizeJsonLdIris(value, iriKeys, iriPattern = /^ap(?:\+ef61)?:\/\//i) {
|
|
25
|
-
return normalize(value, void 0, 0, void 0);
|
|
26
|
-
function isIriPosition(key, parentKey) {
|
|
27
|
-
return iriKeys.has(key) || (key === "@value" || key === "@list" || key === "@set") && parentKey != null && iriKeys.has(parentKey);
|
|
28
|
-
}
|
|
29
|
-
function arrayItemParentKey(key, parentKey) {
|
|
30
|
-
return key === "@list" || key === "@set" ? parentKey : key;
|
|
31
|
-
}
|
|
32
|
-
function entryParentKey(entryKey, key, parentKey) {
|
|
33
|
-
if (entryKey === "@list" || entryKey === "@set") return parentKey ?? key;
|
|
34
|
-
return key === "@list" || key === "@set" ? parentKey : key;
|
|
35
|
-
}
|
|
36
|
-
function normalize(value, key, depth = 0, parentKey) {
|
|
37
|
-
if (depth > 32 || key === "@context") return value;
|
|
38
|
-
if (typeof value === "string") {
|
|
39
|
-
if (key != null && isIriPosition(key, parentKey) && iriPattern.test(value)) try {
|
|
40
|
-
return require_url.formatIri(value);
|
|
41
|
-
} catch {
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
if (Array.isArray(value)) {
|
|
47
|
-
let clone;
|
|
48
|
-
const itemParentKey = arrayItemParentKey(key, parentKey);
|
|
49
|
-
for (let i = 0; i < value.length; i++) {
|
|
50
|
-
const result = normalize(value[i], key, depth + 1, itemParentKey);
|
|
51
|
-
if (result !== value[i]) {
|
|
52
|
-
clone ??= value.slice(0, i);
|
|
53
|
-
clone.push(result);
|
|
54
|
-
} else if (clone != null) clone.push(value[i]);
|
|
55
|
-
}
|
|
56
|
-
return clone ?? value;
|
|
57
|
-
}
|
|
58
|
-
if (value == null || typeof value !== "object") return value;
|
|
59
|
-
const object = value;
|
|
60
|
-
let clone;
|
|
61
|
-
for (const entryKey of globalThis.Object.keys(object)) {
|
|
62
|
-
const result = normalize(object[entryKey], entryKey, depth + 1, entryParentKey(entryKey, key, parentKey));
|
|
63
|
-
if (result !== object[entryKey]) {
|
|
64
|
-
clone ??= { ...object };
|
|
65
|
-
defineJsonLdProperty(clone, entryKey, result);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return clone ?? object;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Finds the first JSON-LD context in a value.
|
|
73
|
-
*
|
|
74
|
-
* @internal Technically exported for generated vocabulary classes, but not
|
|
75
|
-
* part of the public API contract. This is not considered public API for
|
|
76
|
-
* Semantic Versioning decisions.
|
|
77
|
-
*/
|
|
78
|
-
function getJsonLdContext(value, depth = 0) {
|
|
79
|
-
if (depth > 32) return void 0;
|
|
80
|
-
if (Array.isArray(value)) {
|
|
81
|
-
for (const item of value) {
|
|
82
|
-
const context = getJsonLdContext(item, depth + 1);
|
|
83
|
-
if (context !== void 0) return context;
|
|
84
|
-
}
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (value == null || typeof value !== "object" || !("@context" in value)) return;
|
|
88
|
-
return value["@context"];
|
|
89
|
-
}
|
|
90
|
-
function getOwnJsonLdContext(value) {
|
|
91
|
-
if (value == null || typeof value !== "object" || Array.isArray(value) || !("@context" in value)) return noJsonLdContext;
|
|
92
|
-
return value["@context"];
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Recompacts normalized JSON-LD cache data against the original context.
|
|
96
|
-
*
|
|
97
|
-
* @internal Technically exported for generated vocabulary classes, but not
|
|
98
|
-
* part of the public API contract. This is not considered public API for
|
|
99
|
-
* Semantic Versioning decisions.
|
|
100
|
-
*/
|
|
101
|
-
async function compactJsonLdCache(normalized, original, documentLoader, depth = 0, inheritedContext) {
|
|
102
|
-
if (depth > 32) return normalized;
|
|
103
|
-
if (Array.isArray(original)) {
|
|
104
|
-
const normalizedArray = Array.isArray(normalized) ? normalized : normalized != null && typeof normalized === "object" && "@graph" in normalized && Array.isArray(normalized["@graph"]) ? normalized["@graph"] : void 0;
|
|
105
|
-
if (normalizedArray == null) return normalized;
|
|
106
|
-
let clone;
|
|
107
|
-
for (let i = 0; i < normalizedArray.length; i++) {
|
|
108
|
-
const item = await compactJsonLdCache(normalizedArray[i], original[i], documentLoader, depth + 1, inheritedContext);
|
|
109
|
-
if (item !== normalizedArray[i]) {
|
|
110
|
-
clone ??= normalizedArray.slice(0, i);
|
|
111
|
-
clone.push(item);
|
|
112
|
-
} else if (clone != null) clone.push(normalizedArray[i]);
|
|
113
|
-
}
|
|
114
|
-
return clone ?? (Array.isArray(normalized) ? normalized : normalizedArray);
|
|
115
|
-
}
|
|
116
|
-
const ownContext = getOwnJsonLdContext(original);
|
|
117
|
-
const context = ownContext === noJsonLdContext ? inheritedContext : ownContext;
|
|
118
|
-
if (context == null) return preserveNoContextJsonLdShape(normalized, original, depth);
|
|
119
|
-
return await preserveJsonLdShape(await mergeUnmappedTerms(await require_jsonld.jsonld_default.compact(Array.isArray(normalized) && normalized.length === 1 ? normalized[0] : normalized, context, { documentLoader }), original, context, documentLoader), original, context, documentLoader, depth);
|
|
120
|
-
}
|
|
121
|
-
function preserveNoContextJsonLdShape(normalized, original, depth = 0) {
|
|
122
|
-
if (depth > 32) return normalized;
|
|
123
|
-
if (original == null || typeof original !== "object" || Array.isArray(original)) return normalized;
|
|
124
|
-
const normalizedObject = Array.isArray(normalized) && normalized.length === 1 ? normalized[0] : normalized;
|
|
125
|
-
if (normalizedObject == null || typeof normalizedObject !== "object" || Array.isArray(normalizedObject)) return normalized;
|
|
126
|
-
const source = normalizedObject;
|
|
127
|
-
const originalObject = original;
|
|
128
|
-
let clone;
|
|
129
|
-
for (const key of globalThis.Object.keys(originalObject)) {
|
|
130
|
-
if (!globalThis.Object.prototype.hasOwnProperty.call(source, key)) continue;
|
|
131
|
-
const value = preserveNoContextValue(source[key], originalObject[key], depth + 1);
|
|
132
|
-
if (value !== originalObject[key]) {
|
|
133
|
-
clone ??= { ...originalObject };
|
|
134
|
-
defineJsonLdProperty(clone, key, value);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return clone ?? original;
|
|
138
|
-
}
|
|
139
|
-
function preserveNoContextValue(normalized, original, depth) {
|
|
140
|
-
if (depth > 32) return normalized;
|
|
141
|
-
if (Array.isArray(original)) {
|
|
142
|
-
const normalizedArray = Array.isArray(normalized) ? normalized : [normalized];
|
|
143
|
-
let clone;
|
|
144
|
-
for (let i = 0; i < original.length; i++) {
|
|
145
|
-
const value = preserveNoContextValue(normalizedArray[i], original[i], depth + 1);
|
|
146
|
-
if (value !== original[i]) {
|
|
147
|
-
clone ??= original.slice(0, i);
|
|
148
|
-
clone.push(value);
|
|
149
|
-
} else if (clone != null) clone.push(original[i]);
|
|
150
|
-
}
|
|
151
|
-
return clone ?? original;
|
|
152
|
-
}
|
|
153
|
-
const normalizedValue = Array.isArray(normalized) ? normalized[0] : normalized;
|
|
154
|
-
if (normalizedValue == null || typeof normalizedValue !== "object" || Array.isArray(normalizedValue)) return normalizedValue;
|
|
155
|
-
const normalizedObject = normalizedValue;
|
|
156
|
-
if (original != null && typeof original === "object" && !Array.isArray(original)) return preserveNoContextJsonLdShape(normalizedObject, original, depth + 1);
|
|
157
|
-
if (typeof normalizedObject["@id"] === "string") return normalizedObject["@id"];
|
|
158
|
-
if ("@value" in normalizedObject) return normalizedObject["@value"];
|
|
159
|
-
return normalizedValue;
|
|
160
|
-
}
|
|
161
|
-
function getTopLevelTerms(value) {
|
|
162
|
-
const terms = /* @__PURE__ */ new Set();
|
|
163
|
-
const nodes = Array.isArray(value) ? value : [value];
|
|
164
|
-
for (const node of nodes) {
|
|
165
|
-
if (node == null || typeof node !== "object" || Array.isArray(node)) continue;
|
|
166
|
-
for (const key of globalThis.Object.keys(node)) {
|
|
167
|
-
if (key.startsWith("@")) continue;
|
|
168
|
-
terms.add(key);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
return terms;
|
|
172
|
-
}
|
|
173
|
-
async function mergeUnmappedTerms(compacted, original, context, documentLoader) {
|
|
174
|
-
if (original == null || typeof original !== "object" || Array.isArray(original) || compacted == null || typeof compacted !== "object" || Array.isArray(compacted)) return compacted;
|
|
175
|
-
const unmappedKeys = globalThis.Object.keys(original).filter((key) => key !== "@context" && !globalThis.Object.prototype.hasOwnProperty.call(compacted, key));
|
|
176
|
-
if (unmappedKeys.length < 1) return compacted;
|
|
177
|
-
const result = { ...compacted };
|
|
178
|
-
const compactedWithContext = compacted != null && typeof compacted === "object" && !Array.isArray(compacted) && !("@context" in compacted) ? {
|
|
179
|
-
"@context": context,
|
|
180
|
-
...compacted
|
|
181
|
-
} : compacted;
|
|
182
|
-
const compactedTerms = getTopLevelTerms(await require_jsonld.jsonld_default.expand(compactedWithContext, { documentLoader }));
|
|
183
|
-
const dummyPrefix = "urn:fedify:dummy:";
|
|
184
|
-
const dummy = { "@context": context };
|
|
185
|
-
for (let i = 0; i < unmappedKeys.length; i++) defineJsonLdProperty(dummy, unmappedKeys[i], `${dummyPrefix}${i}`);
|
|
186
|
-
const expanded = await require_jsonld.jsonld_default.expand(dummy, { documentLoader });
|
|
187
|
-
const representedKeys = /* @__PURE__ */ new Set();
|
|
188
|
-
const nodes = Array.isArray(expanded) ? expanded : [expanded];
|
|
189
|
-
for (const node of nodes) {
|
|
190
|
-
if (node == null || typeof node !== "object" || Array.isArray(node)) continue;
|
|
191
|
-
for (const [term, termValue] of globalThis.Object.entries(node)) {
|
|
192
|
-
if (!compactedTerms.has(term)) continue;
|
|
193
|
-
for (let i = 0; i < unmappedKeys.length; i++) if (containsValue(termValue, `${dummyPrefix}${i}`)) representedKeys.add(unmappedKeys[i]);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
for (const key of unmappedKeys) if (!representedKeys.has(key)) defineJsonLdProperty(result, key, original[key]);
|
|
197
|
-
return result;
|
|
198
|
-
}
|
|
199
|
-
function defineJsonLdProperty(object, key, value) {
|
|
200
|
-
globalThis.Object.defineProperty(object, key, {
|
|
201
|
-
value,
|
|
202
|
-
enumerable: true,
|
|
203
|
-
configurable: true,
|
|
204
|
-
writable: true
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function containsValue(value, expected, depth = 0) {
|
|
208
|
-
if (depth > 32) return false;
|
|
209
|
-
if (value === expected) return true;
|
|
210
|
-
if (Array.isArray(value)) return value.some((item) => containsValue(item, expected, depth + 1));
|
|
211
|
-
if (value == null || typeof value !== "object") return false;
|
|
212
|
-
return globalThis.Object.entries(value).some(([key, item]) => key !== "@context" && containsValue(item, expected, depth + 1));
|
|
213
|
-
}
|
|
214
|
-
async function preserveJsonLdShape(compacted, original, context, documentLoader, depth = 0) {
|
|
215
|
-
if (depth > 32) return compacted;
|
|
216
|
-
if (compacted === original) return compacted;
|
|
217
|
-
if (original == null || typeof original !== "object" || compacted == null || typeof compacted !== "object") return compacted;
|
|
218
|
-
if (Array.isArray(original)) {
|
|
219
|
-
const compactedArray = Array.isArray(compacted) ? compacted : "@graph" in compacted && Array.isArray(compacted["@graph"]) ? compacted["@graph"] : void 0;
|
|
220
|
-
if (compactedArray == null) return compacted;
|
|
221
|
-
let clone;
|
|
222
|
-
for (let i = 0; i < compactedArray.length; i++) {
|
|
223
|
-
const value = await preserveJsonLdShape(compactedArray[i], original[i], context, documentLoader, depth + 1);
|
|
224
|
-
const originalContext = original[i] != null && typeof original[i] === "object" && !Array.isArray(original[i]) && "@context" in original[i] ? original[i]["@context"] : void 0;
|
|
225
|
-
const shaped = originalContext !== void 0 && value != null && typeof value === "object" && !Array.isArray(value) && !("@context" in value) ? {
|
|
226
|
-
"@context": originalContext,
|
|
227
|
-
...value
|
|
228
|
-
} : value;
|
|
229
|
-
if (shaped !== compactedArray[i]) {
|
|
230
|
-
clone ??= compactedArray.slice(0, i);
|
|
231
|
-
clone.push(shaped);
|
|
232
|
-
} else if (clone != null) clone.push(compactedArray[i]);
|
|
233
|
-
}
|
|
234
|
-
return clone ?? (Array.isArray(compacted) ? compacted : compactedArray);
|
|
235
|
-
}
|
|
236
|
-
if (Array.isArray(compacted)) return compacted;
|
|
237
|
-
let clone;
|
|
238
|
-
const ownContext = getOwnJsonLdContext(original);
|
|
239
|
-
const objectContext = combineContexts(context, ownContext);
|
|
240
|
-
const objectCompacted = depth > 0 && ownContext === null ? await compactWithEmptyContext(compacted, context, documentLoader) : compacted;
|
|
241
|
-
const compactedObject = depth > 0 ? await mergeUnmappedTerms(objectCompacted, original, objectContext, documentLoader) : objectCompacted;
|
|
242
|
-
const originalObject = original;
|
|
243
|
-
for (const key of globalThis.Object.keys(compactedObject)) {
|
|
244
|
-
if (key === "@context") continue;
|
|
245
|
-
const value = await preserveJsonLdShape(compactedObject[key], originalObject[key], objectContext, documentLoader, depth + 1);
|
|
246
|
-
const shaped = Array.isArray(originalObject[key]) && !Array.isArray(value) ? [value] : value;
|
|
247
|
-
if (shaped !== compactedObject[key]) {
|
|
248
|
-
clone ??= { ...compactedObject };
|
|
249
|
-
defineJsonLdProperty(clone, key, shaped);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
if (depth > 0) {
|
|
253
|
-
if ("@context" in originalObject && !("@context" in compactedObject)) {
|
|
254
|
-
clone ??= { ...compactedObject };
|
|
255
|
-
clone["@context"] = originalObject["@context"];
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return clone ?? compactedObject;
|
|
259
|
-
}
|
|
260
|
-
async function compactWithEmptyContext(compacted, context, documentLoader) {
|
|
261
|
-
const compactedWithContext = compacted != null && typeof compacted === "object" && !Array.isArray(compacted) && !("@context" in compacted) ? {
|
|
262
|
-
"@context": context,
|
|
263
|
-
...compacted
|
|
264
|
-
} : compacted;
|
|
265
|
-
const expanded = await require_jsonld.jsonld_default.expand(compactedWithContext, { documentLoader });
|
|
266
|
-
return await require_jsonld.jsonld_default.compact(expanded, {}, { documentLoader });
|
|
267
|
-
}
|
|
268
|
-
function combineContexts(inheritedContext, ownContext) {
|
|
269
|
-
if (ownContext === noJsonLdContext || ownContext === inheritedContext) return inheritedContext;
|
|
270
|
-
if (ownContext == null) return ownContext;
|
|
271
|
-
const inherited = Array.isArray(inheritedContext) ? inheritedContext : [inheritedContext];
|
|
272
|
-
const own = Array.isArray(ownContext) ? ownContext : [ownContext];
|
|
273
|
-
return [...inherited, ...own];
|
|
274
|
-
}
|
|
275
|
-
//#endregion
|
|
276
5
|
//#region src/jsonld-cache.test.ts
|
|
277
6
|
(0, node_test.test)("isTrustedIriOrigin() trusts same portable IRI origins", () => {
|
|
278
|
-
(0, node_assert.ok)(isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap+ef61://did:key:z6Mkabc/outbox")));
|
|
279
|
-
(0, node_assert.ok)(!isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
280
|
-
(0, node_assert.ok)(isTrustedIriOrigin({ crossOrigin: "trust" }, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
7
|
+
(0, node_assert.ok)(require_jsonld_cache.isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap+ef61://did:key:z6Mkabc/outbox")));
|
|
8
|
+
(0, node_assert.ok)(!require_jsonld_cache.isTrustedIriOrigin({}, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
9
|
+
(0, node_assert.ok)(require_jsonld_cache.isTrustedIriOrigin({ crossOrigin: "trust" }, require_url.parseIri("ap://did:key:z6Mkabc/actor"), require_url.parseIri("ap://did:key:z6Mkdef/outbox")));
|
|
281
10
|
});
|
|
282
11
|
(0, node_test.test)("normalizeJsonLdIris() normalizes selected JSON-LD IRI positions", () => {
|
|
283
|
-
(0, node_assert.deepStrictEqual)(normalizeJsonLdIris({
|
|
12
|
+
(0, node_assert.deepStrictEqual)(require_jsonld_cache.normalizeJsonLdIris({
|
|
284
13
|
"@id": "ap://did:key:z6Mkabc/object",
|
|
285
14
|
"https://example.com/ns#ref": [{ "@value": "ap://did:key:z6Mkabc/ref" }],
|
|
286
15
|
"https://example.com/ns#text": [{ "@value": "ap://did:key:z6Mkabc/not-an-iri-position" }]
|
|
@@ -291,7 +20,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
291
20
|
});
|
|
292
21
|
});
|
|
293
22
|
(0, node_test.test)("normalizeJsonLdIris() preserves IRI context in list/set wrappers", () => {
|
|
294
|
-
(0, node_assert.deepStrictEqual)(normalizeJsonLdIris({ "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap://did:key:z6Mkabc/set" }] }] }, /* @__PURE__ */ new Set(["https://example.com/ns#ref"])), { "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap+ef61://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap+ef61://did:key:z6Mkabc/set" }] }] });
|
|
23
|
+
(0, node_assert.deepStrictEqual)(require_jsonld_cache.normalizeJsonLdIris({ "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap://did:key:z6Mkabc/set" }] }] }, /* @__PURE__ */ new Set(["https://example.com/ns#ref"])), { "https://example.com/ns#ref": [{ "@list": [{ "@value": "ap+ef61://did:key:z6Mkabc/listed" }] }, { "@set": [{ "@value": "ap+ef61://did:key:z6Mkabc/set" }] }] });
|
|
295
24
|
});
|
|
296
25
|
(0, node_test.test)("normalizeJsonLdIris() defines prototype-like keys safely", () => {
|
|
297
26
|
const iriKeys = /* @__PURE__ */ new Set(["__proto__"]);
|
|
@@ -302,13 +31,13 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
302
31
|
configurable: true,
|
|
303
32
|
writable: true
|
|
304
33
|
});
|
|
305
|
-
const normalized = normalizeJsonLdIris(value, iriKeys);
|
|
34
|
+
const normalized = require_jsonld_cache.normalizeJsonLdIris(value, iriKeys);
|
|
306
35
|
(0, node_assert.strictEqual)(globalThis.Object.getOwnPropertyDescriptor(normalized, "__proto__")?.value, "ap+ef61://did:key:z6Mkabc/object");
|
|
307
36
|
(0, node_assert.strictEqual)(globalThis.Object.getPrototypeOf(normalized), Object.prototype);
|
|
308
37
|
});
|
|
309
38
|
(0, node_test.test)("getJsonLdContext() finds nested contexts", () => {
|
|
310
39
|
const context = { name: "https://example.com/ns#name" };
|
|
311
|
-
(0, node_assert.deepStrictEqual)(getJsonLdContext([{ type: "Note" }, { "@context": context }]), context);
|
|
40
|
+
(0, node_assert.deepStrictEqual)(require_jsonld_cache.getJsonLdContext([{ type: "Note" }, { "@context": context }]), context);
|
|
312
41
|
});
|
|
313
42
|
(0, node_test.test)("compactJsonLdCache() preserves no-context object shape", async () => {
|
|
314
43
|
const original = {
|
|
@@ -317,7 +46,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
317
46
|
"https://www.w3.org/ns/activitystreams#attributedTo": [{ "@id": "ap://did:key:z6Mkabc/actor" }],
|
|
318
47
|
"https://www.w3.org/ns/activitystreams#content": [{ "@value": "No-context object shape should stay cached." }]
|
|
319
48
|
};
|
|
320
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
49
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id", "https://www.w3.org/ns/activitystreams#attributedTo"])), original), {
|
|
321
50
|
"@id": "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
322
51
|
"@type": ["https://www.w3.org/ns/activitystreams#Note"],
|
|
323
52
|
"https://www.w3.org/ns/activitystreams#attributedTo": [{ "@id": "ap+ef61://did:key:z6Mkabc/actor" }],
|
|
@@ -338,7 +67,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
338
67
|
name: "Nested object"
|
|
339
68
|
}]
|
|
340
69
|
};
|
|
341
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
70
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
342
71
|
"@id": "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
343
72
|
"@type": ["https://www.w3.org/ns/activitystreams#Note"],
|
|
344
73
|
"https://www.w3.org/ns/activitystreams#attachment": [{
|
|
@@ -363,7 +92,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
363
92
|
configurable: true,
|
|
364
93
|
writable: true
|
|
365
94
|
});
|
|
366
|
-
const compacted = await compactJsonLdCache([normalized], original);
|
|
95
|
+
const compacted = await require_jsonld_cache.compactJsonLdCache([normalized], original);
|
|
367
96
|
(0, node_assert.strictEqual)(globalThis.Object.getOwnPropertyDescriptor(compacted, "__proto__")?.value, "ap+ef61://did:key:z6Mkabc/proto");
|
|
368
97
|
(0, node_assert.strictEqual)(globalThis.Object.getPrototypeOf(compacted), Object.prototype);
|
|
369
98
|
});
|
|
@@ -385,7 +114,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
385
114
|
extra: "This nested unmapped property should stay cached."
|
|
386
115
|
}
|
|
387
116
|
};
|
|
388
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
117
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
389
118
|
"@context": context,
|
|
390
119
|
type: "as:Note",
|
|
391
120
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
@@ -417,7 +146,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
417
146
|
extra
|
|
418
147
|
}
|
|
419
148
|
};
|
|
420
|
-
const compacted = await compactJsonLdCache(normalizeJsonLdIris(await
|
|
149
|
+
const compacted = await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
|
|
421
150
|
(0, node_assert.strictEqual)(compacted.rootExtra, rootExtra);
|
|
422
151
|
(0, node_assert.strictEqual)(compacted.attachment.extra, extra);
|
|
423
152
|
});
|
|
@@ -438,7 +167,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
438
167
|
configurable: true,
|
|
439
168
|
writable: true
|
|
440
169
|
});
|
|
441
|
-
const compacted = await compactJsonLdCache(normalizeJsonLdIris(await
|
|
170
|
+
const compacted = await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
|
|
442
171
|
(0, node_assert.strictEqual)(globalThis.Object.getOwnPropertyDescriptor(compacted, "__proto__")?.value, protoValue);
|
|
443
172
|
(0, node_assert.strictEqual)(globalThis.Object.getPrototypeOf(compacted), Object.prototype);
|
|
444
173
|
});
|
|
@@ -465,7 +194,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
465
194
|
configurable: true,
|
|
466
195
|
writable: true
|
|
467
196
|
});
|
|
468
|
-
const compacted = await compactJsonLdCache(normalizeJsonLdIris(await
|
|
197
|
+
const compacted = await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original);
|
|
469
198
|
const protoDescriptor = globalThis.Object.getOwnPropertyDescriptor(compacted, "__proto__");
|
|
470
199
|
(0, node_assert.ok)(protoDescriptor?.value === "Alias represented by the compacted term." || Array.isArray(protoDescriptor?.value) && protoDescriptor.value.includes("Alias represented by the compacted term."));
|
|
471
200
|
(0, node_assert.strictEqual)(protoDescriptor?.enumerable, true);
|
|
@@ -495,7 +224,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
495
224
|
title: "Nested title."
|
|
496
225
|
}
|
|
497
226
|
};
|
|
498
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
227
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
499
228
|
"@context": context,
|
|
500
229
|
type: "as:Note",
|
|
501
230
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
@@ -527,7 +256,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
527
256
|
title: "Nested title."
|
|
528
257
|
}
|
|
529
258
|
};
|
|
530
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
259
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
531
260
|
"@context": context,
|
|
532
261
|
type: "as:Note",
|
|
533
262
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
@@ -555,7 +284,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
555
284
|
"https://example.com/ns#title": "Absolute title."
|
|
556
285
|
}
|
|
557
286
|
};
|
|
558
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
287
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
559
288
|
"@context": context,
|
|
560
289
|
type: "as:Note",
|
|
561
290
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
@@ -594,7 +323,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
594
323
|
actorRef: "ap://did:key:z6Mkabc/actor"
|
|
595
324
|
}
|
|
596
325
|
};
|
|
597
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
326
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id", "https://www.w3.org/ns/activitystreams#actor"])), original), {
|
|
598
327
|
"@context": context,
|
|
599
328
|
type: "as:Note",
|
|
600
329
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
@@ -628,7 +357,7 @@ function combineContexts(inheritedContext, ownContext) {
|
|
|
628
357
|
key9: "Extension 9",
|
|
629
358
|
key10: "Alias represented by the compacted term."
|
|
630
359
|
};
|
|
631
|
-
(0, node_assert.deepStrictEqual)(await compactJsonLdCache(normalizeJsonLdIris(await
|
|
360
|
+
(0, node_assert.deepStrictEqual)(await require_jsonld_cache.compactJsonLdCache(require_jsonld_cache.normalizeJsonLdIris(await require_jsonld_cache.jsonld_default.expand(original), /* @__PURE__ */ new Set(["@id"])), original), {
|
|
632
361
|
"@context": context,
|
|
633
362
|
id: "ap+ef61://did:key:z6Mkabc/objects/1",
|
|
634
363
|
key0: "Extension 0",
|