@fedify/vocab-tools 2.4.0-dev.1599 → 2.4.0-dev.1634

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/src/class.ts CHANGED
@@ -31,8 +31,10 @@ const RUNTIME_IMPORTS = [
31
31
  "importMultibaseKey",
32
32
  "importPem",
33
33
  "isDecimal",
34
+ "isGatewayUrl",
34
35
  "LanguageString",
35
36
  "parseDecimal",
37
+ "parseGatewayUrl",
36
38
  "parseIri",
37
39
  "parseJsonLdId",
38
40
  "type RemoteDocument",
package/src/type.ts CHANGED
@@ -6,8 +6,10 @@ const HEURISTICS_CONTEXTS: string[] = [
6
6
  "https://www.w3.org/ns/activitystreams",
7
7
  "https://w3id.org/security/v1",
8
8
  "https://w3id.org/security/data-integrity/v1",
9
+ "https://w3id.org/security/data-integrity/v2",
9
10
  "https://www.w3.org/ns/did/v1",
10
11
  "https://w3id.org/security/multikey/v1",
12
+ "https://w3id.org/fep/ef61",
11
13
  ];
12
14
 
13
15
  interface ScalarType {
@@ -324,6 +326,28 @@ const scalarTypes: Record<string, ScalarType> = {
324
326
  return `parseIri(${v}["@value"])`;
325
327
  },
326
328
  },
329
+ "fedify:gatewayUrl": {
330
+ name: "URL",
331
+ typeGuard(v) {
332
+ return `${v} instanceof URL && isGatewayUrl(${v})`;
333
+ },
334
+ encoder(v) {
335
+ return `{ "@id": formatIri(${v}) }`;
336
+ },
337
+ compactEncoder(v) {
338
+ return `formatIri(${v})`;
339
+ },
340
+ dataCheck(v) {
341
+ return `${v} != null && typeof ${v} === "object" &&
342
+ (("@id" in ${v} && typeof ${v}["@id"] === "string" &&
343
+ ${v}["@id"] !== "" && ${v}["@id"] !== "/") ||
344
+ ("@value" in ${v} && typeof ${v}["@value"] === "string" &&
345
+ ${v}["@value"] !== "" && ${v}["@value"] !== "/"))`;
346
+ },
347
+ decoder(v) {
348
+ return `parseGatewayUrl(typeof ${v}["@id"] === "string" ? ${v}["@id"] : ${v}["@value"])`;
349
+ },
350
+ },
327
351
  "fedify:publicKey": {
328
352
  name: "CryptoKey",
329
353
  typeGuard(v) {