@fedify/vocab-tools 2.4.0-dev.2030 → 2.4.0-dev.2047
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/mod.cjs +48 -1
- package/dist/mod.js +48 -1
- package/package.json +2 -2
- package/src/__snapshots__/class.test.ts.deno.snap +6503 -242
- package/src/__snapshots__/class.test.ts.node.snap +6503 -242
- package/src/__snapshots__/class.test.ts.snap +6503 -242
- package/src/class.ts +6 -0
- package/src/property.ts +44 -0
package/deno.json
CHANGED
package/dist/mod.cjs
CHANGED
|
@@ -8,7 +8,7 @@ let yaml = require("yaml");
|
|
|
8
8
|
let es_toolkit = require("es-toolkit");
|
|
9
9
|
//#region deno.json
|
|
10
10
|
var name = "@fedify/vocab-tools";
|
|
11
|
-
var version = "2.4.0-dev.
|
|
11
|
+
var version = "2.4.0-dev.2047+140b94db";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/type.ts
|
|
14
14
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -1657,6 +1657,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1657
1657
|
suppressError?: boolean,
|
|
1658
1658
|
tracerProvider?: TracerProvider,
|
|
1659
1659
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1660
|
+
gateways?: readonly (string | URL)[];
|
|
1661
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1660
1662
|
} = {},
|
|
1661
1663
|
): Promise<${getTypeNames(property.range, types)} | null> {
|
|
1662
1664
|
const documentLoader =
|
|
@@ -1670,6 +1672,44 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1670
1672
|
${JSON.stringify(version)},
|
|
1671
1673
|
);
|
|
1672
1674
|
return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
|
|
1675
|
+
if (isPortableIri(url)) {
|
|
1676
|
+
try {
|
|
1677
|
+
const obj = await dereferencePortableIri(url, {
|
|
1678
|
+
documentLoader,
|
|
1679
|
+
contextLoader,
|
|
1680
|
+
tracerProvider,
|
|
1681
|
+
gateways: options.gateways,
|
|
1682
|
+
verifyPortableObject: options.verifyPortableObject,
|
|
1683
|
+
suppressError: options.suppressError,
|
|
1684
|
+
crossOrigin: options.crossOrigin,
|
|
1685
|
+
span,
|
|
1686
|
+
parse: (document, parseOptions) =>
|
|
1687
|
+
this.#${property.singularName}_fromJsonLd(document, {
|
|
1688
|
+
documentLoader,
|
|
1689
|
+
contextLoader: parseOptions.contextLoader,
|
|
1690
|
+
tracerProvider,
|
|
1691
|
+
baseUrl: parseOptions.baseUrl,
|
|
1692
|
+
}),
|
|
1693
|
+
});
|
|
1694
|
+
if (obj != null) {
|
|
1695
|
+
span.setAttribute("activitypub.object.id", (obj.id ?? url).href);
|
|
1696
|
+
span.setAttribute(
|
|
1697
|
+
"activitypub.object.type",
|
|
1698
|
+
// @ts-ignore: obj.constructor always has a typeId.
|
|
1699
|
+
obj.constructor.typeId.href
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
return obj;
|
|
1703
|
+
} catch (e) {
|
|
1704
|
+
span.setStatus({
|
|
1705
|
+
code: SpanStatusCode.ERROR,
|
|
1706
|
+
message: String(e),
|
|
1707
|
+
});
|
|
1708
|
+
throw e;
|
|
1709
|
+
} finally {
|
|
1710
|
+
span.end();
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1673
1713
|
const lookupUrl = formatIri(url);
|
|
1674
1714
|
let fetchResult: RemoteDocument;
|
|
1675
1715
|
try {
|
|
@@ -1835,6 +1875,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1835
1875
|
suppressError?: boolean,
|
|
1836
1876
|
tracerProvider?: TracerProvider,
|
|
1837
1877
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1878
|
+
gateways?: readonly (string | URL)[];
|
|
1879
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1838
1880
|
} = {}
|
|
1839
1881
|
): Promise<${getTypeNames(property.range, types)} | null> {
|
|
1840
1882
|
if (this._warning != null) {
|
|
@@ -1940,6 +1982,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1940
1982
|
suppressError?: boolean,
|
|
1941
1983
|
tracerProvider?: TracerProvider,
|
|
1942
1984
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1985
|
+
gateways?: readonly (string | URL)[];
|
|
1986
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1943
1987
|
} = {}
|
|
1944
1988
|
): AsyncIterable<${getTypeNames(property.range, types)}> {
|
|
1945
1989
|
if (this._warning != null) {
|
|
@@ -2036,6 +2080,7 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2036
2080
|
"isTrustedIriOrigin",
|
|
2037
2081
|
"normalizeJsonLdIris"
|
|
2038
2082
|
].join(",\n ");
|
|
2083
|
+
const PORTABLE_DEREFERENCE_IMPORTS = ["dereferencePortableIri", "isPortableIri"].join(",\n ");
|
|
2039
2084
|
const SIGNED_REPRESENTATION_IMPORTS = [
|
|
2040
2085
|
"enterSignedValueScope",
|
|
2041
2086
|
"resolveSignedValues",
|
|
@@ -2060,6 +2105,7 @@ const RUNTIME_IMPORTS = [
|
|
|
2060
2105
|
"parseGatewayUrl",
|
|
2061
2106
|
"parseIri",
|
|
2062
2107
|
"parseJsonLdId",
|
|
2108
|
+
"type PortableObjectVerifier",
|
|
2063
2109
|
"type RemoteDocument"
|
|
2064
2110
|
].join(",\n ");
|
|
2065
2111
|
/**
|
|
@@ -2236,6 +2282,7 @@ async function* generateClasses(types) {
|
|
|
2236
2282
|
from "@opentelemetry/api";\n`;
|
|
2237
2283
|
yield `import {\n ${RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime";\n`;
|
|
2238
2284
|
yield `import {\n ${INTERNAL_RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime/internal/jsonld-cache";\n`;
|
|
2285
|
+
yield `import {\n ${PORTABLE_DEREFERENCE_IMPORTS}\n} from "@fedify/vocab-runtime/internal/portable-dereference";\n`;
|
|
2239
2286
|
yield `import {\n ${SIGNED_REPRESENTATION_IMPORTS}\n} from "@fedify/vocab-runtime/internal/signed-representation";\n`;
|
|
2240
2287
|
yield `import {
|
|
2241
2288
|
isTemporalDuration,
|
package/dist/mod.js
CHANGED
|
@@ -7,7 +7,7 @@ import { parse } from "yaml";
|
|
|
7
7
|
import { pascalCase } from "es-toolkit";
|
|
8
8
|
//#region deno.json
|
|
9
9
|
var name = "@fedify/vocab-tools";
|
|
10
|
-
var version = "2.4.0-dev.
|
|
10
|
+
var version = "2.4.0-dev.2047+140b94db";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/type.ts
|
|
13
13
|
const HEURISTICS_CONTEXTS = [
|
|
@@ -1656,6 +1656,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1656
1656
|
suppressError?: boolean,
|
|
1657
1657
|
tracerProvider?: TracerProvider,
|
|
1658
1658
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1659
|
+
gateways?: readonly (string | URL)[];
|
|
1660
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1659
1661
|
} = {},
|
|
1660
1662
|
): Promise<${getTypeNames(property.range, types)} | null> {
|
|
1661
1663
|
const documentLoader =
|
|
@@ -1669,6 +1671,44 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1669
1671
|
${JSON.stringify(version)},
|
|
1670
1672
|
);
|
|
1671
1673
|
return await tracer.startActiveSpan("activitypub.lookup_object", async (span) => {
|
|
1674
|
+
if (isPortableIri(url)) {
|
|
1675
|
+
try {
|
|
1676
|
+
const obj = await dereferencePortableIri(url, {
|
|
1677
|
+
documentLoader,
|
|
1678
|
+
contextLoader,
|
|
1679
|
+
tracerProvider,
|
|
1680
|
+
gateways: options.gateways,
|
|
1681
|
+
verifyPortableObject: options.verifyPortableObject,
|
|
1682
|
+
suppressError: options.suppressError,
|
|
1683
|
+
crossOrigin: options.crossOrigin,
|
|
1684
|
+
span,
|
|
1685
|
+
parse: (document, parseOptions) =>
|
|
1686
|
+
this.#${property.singularName}_fromJsonLd(document, {
|
|
1687
|
+
documentLoader,
|
|
1688
|
+
contextLoader: parseOptions.contextLoader,
|
|
1689
|
+
tracerProvider,
|
|
1690
|
+
baseUrl: parseOptions.baseUrl,
|
|
1691
|
+
}),
|
|
1692
|
+
});
|
|
1693
|
+
if (obj != null) {
|
|
1694
|
+
span.setAttribute("activitypub.object.id", (obj.id ?? url).href);
|
|
1695
|
+
span.setAttribute(
|
|
1696
|
+
"activitypub.object.type",
|
|
1697
|
+
// @ts-ignore: obj.constructor always has a typeId.
|
|
1698
|
+
obj.constructor.typeId.href
|
|
1699
|
+
);
|
|
1700
|
+
}
|
|
1701
|
+
return obj;
|
|
1702
|
+
} catch (e) {
|
|
1703
|
+
span.setStatus({
|
|
1704
|
+
code: SpanStatusCode.ERROR,
|
|
1705
|
+
message: String(e),
|
|
1706
|
+
});
|
|
1707
|
+
throw e;
|
|
1708
|
+
} finally {
|
|
1709
|
+
span.end();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1672
1712
|
const lookupUrl = formatIri(url);
|
|
1673
1713
|
let fetchResult: RemoteDocument;
|
|
1674
1714
|
try {
|
|
@@ -1834,6 +1874,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1834
1874
|
suppressError?: boolean,
|
|
1835
1875
|
tracerProvider?: TracerProvider,
|
|
1836
1876
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1877
|
+
gateways?: readonly (string | URL)[];
|
|
1878
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1837
1879
|
} = {}
|
|
1838
1880
|
): Promise<${getTypeNames(property.range, types)} | null> {
|
|
1839
1881
|
if (this._warning != null) {
|
|
@@ -1939,6 +1981,8 @@ async function* generateProperty(type, property, types, moduleVarNames) {
|
|
|
1939
1981
|
suppressError?: boolean,
|
|
1940
1982
|
tracerProvider?: TracerProvider,
|
|
1941
1983
|
crossOrigin?: "ignore" | "throw" | "trust";
|
|
1984
|
+
gateways?: readonly (string | URL)[];
|
|
1985
|
+
verifyPortableObject?: PortableObjectVerifier;
|
|
1942
1986
|
} = {}
|
|
1943
1987
|
): AsyncIterable<${getTypeNames(property.range, types)}> {
|
|
1944
1988
|
if (this._warning != null) {
|
|
@@ -2035,6 +2079,7 @@ const INTERNAL_RUNTIME_IMPORTS = [
|
|
|
2035
2079
|
"isTrustedIriOrigin",
|
|
2036
2080
|
"normalizeJsonLdIris"
|
|
2037
2081
|
].join(",\n ");
|
|
2082
|
+
const PORTABLE_DEREFERENCE_IMPORTS = ["dereferencePortableIri", "isPortableIri"].join(",\n ");
|
|
2038
2083
|
const SIGNED_REPRESENTATION_IMPORTS = [
|
|
2039
2084
|
"enterSignedValueScope",
|
|
2040
2085
|
"resolveSignedValues",
|
|
@@ -2059,6 +2104,7 @@ const RUNTIME_IMPORTS = [
|
|
|
2059
2104
|
"parseGatewayUrl",
|
|
2060
2105
|
"parseIri",
|
|
2061
2106
|
"parseJsonLdId",
|
|
2107
|
+
"type PortableObjectVerifier",
|
|
2062
2108
|
"type RemoteDocument"
|
|
2063
2109
|
].join(",\n ");
|
|
2064
2110
|
/**
|
|
@@ -2235,6 +2281,7 @@ async function* generateClasses(types) {
|
|
|
2235
2281
|
from "@opentelemetry/api";\n`;
|
|
2236
2282
|
yield `import {\n ${RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime";\n`;
|
|
2237
2283
|
yield `import {\n ${INTERNAL_RUNTIME_IMPORTS}\n} from "@fedify/vocab-runtime/internal/jsonld-cache";\n`;
|
|
2284
|
+
yield `import {\n ${PORTABLE_DEREFERENCE_IMPORTS}\n} from "@fedify/vocab-runtime/internal/portable-dereference";\n`;
|
|
2238
2285
|
yield `import {\n ${SIGNED_REPRESENTATION_IMPORTS}\n} from "@fedify/vocab-runtime/internal/signed-representation";\n`;
|
|
2239
2286
|
yield `import {
|
|
2240
2287
|
isTemporalDuration,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/vocab-tools",
|
|
3
|
-
"version": "2.4.0-dev.
|
|
3
|
+
"version": "2.4.0-dev.2047+140b94db",
|
|
4
4
|
"description": "Code generator for Activity Vocabulary APIs",
|
|
5
5
|
"homepage": "https://fedify.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"license": "MIT",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^
|
|
49
|
+
"@types/node": "^24.12.2",
|
|
50
50
|
"tsdown": "^0.22.0",
|
|
51
51
|
"typescript": "^6.0.0"
|
|
52
52
|
},
|