@fedify/vocab-tools 2.1.0-dev.406 → 2.1.0-dev.411

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.1.0-dev.406+61a21e4e",
3
+ "version": "2.1.0-dev.411+13731841",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/mod.cjs CHANGED
@@ -31,7 +31,7 @@ const es_toolkit = __toESM(require("es-toolkit"));
31
31
 
32
32
  //#region deno.json
33
33
  var name = "@fedify/vocab-tools";
34
- var version = "2.1.0-dev.406+61a21e4e";
34
+ var version = "2.1.0-dev.411+13731841";
35
35
  var license = "MIT";
36
36
  var exports$1 = { ".": "./src/mod.ts" };
37
37
  var author = {
@@ -798,7 +798,7 @@ async function* generateEncoder(typeUri, types) {
798
798
  `;
799
799
  }
800
800
  yield `
801
- result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};
801
+ ${type.typeless ? "" : `result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};`}
802
802
  if (this.id != null) result["id"] = this.id.href;
803
803
  result["@context"] = ${JSON.stringify(type.defaultContext)};
804
804
  return result;
@@ -853,7 +853,7 @@ async function* generateEncoder(typeUri, types) {
853
853
  `;
854
854
  }
855
855
  yield `
856
- values["@type"] = [${JSON.stringify(type.uri)}];
856
+ ${type.typeless ? "" : `values["@type"] = [${JSON.stringify(type.uri)}];`}
857
857
  if (this.id != null) values["@id"] = this.id.href;
858
858
  if (options.format === "expand") {
859
859
  return await jsonld.expand(
package/dist/mod.d.cts CHANGED
@@ -36,6 +36,16 @@ interface TypeSchema {
36
36
  */
37
37
  entity: boolean;
38
38
  /**
39
+ * Whether the type omits `@type` in JSON-LD serialization. When `true`,
40
+ * the generated `toJsonLd()` method will not emit `@type` (or `type` in
41
+ * compact form) in the serialized JSON-LD. The generated `fromJsonLd()`
42
+ * method will still accept `@type` if present for backward compatibility.
43
+ *
44
+ * This is useful for types that are not real vocabulary types but rather
45
+ * anonymous object structures (e.g., `Endpoints`, `Source` in ActivityStreams).
46
+ */
47
+ typeless?: boolean;
48
+ /**
39
49
  * The description of the type. It is used as the doc comment of
40
50
  * the generated class.
41
51
  */
package/dist/mod.d.ts CHANGED
@@ -36,6 +36,16 @@ interface TypeSchema {
36
36
  */
37
37
  entity: boolean;
38
38
  /**
39
+ * Whether the type omits `@type` in JSON-LD serialization. When `true`,
40
+ * the generated `toJsonLd()` method will not emit `@type` (or `type` in
41
+ * compact form) in the serialized JSON-LD. The generated `fromJsonLd()`
42
+ * method will still accept `@type` if present for backward compatibility.
43
+ *
44
+ * This is useful for types that are not real vocabulary types but rather
45
+ * anonymous object structures (e.g., `Endpoints`, `Source` in ActivityStreams).
46
+ */
47
+ typeless?: boolean;
48
+ /**
39
49
  * The description of the type. It is used as the doc comment of
40
50
  * the generated class.
41
51
  */
package/dist/mod.js CHANGED
@@ -8,7 +8,7 @@ import { pascalCase } from "es-toolkit";
8
8
 
9
9
  //#region deno.json
10
10
  var name = "@fedify/vocab-tools";
11
- var version = "2.1.0-dev.406+61a21e4e";
11
+ var version = "2.1.0-dev.411+13731841";
12
12
  var license = "MIT";
13
13
  var exports = { ".": "./src/mod.ts" };
14
14
  var author = {
@@ -775,7 +775,7 @@ async function* generateEncoder(typeUri, types) {
775
775
  `;
776
776
  }
777
777
  yield `
778
- result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};
778
+ ${type.typeless ? "" : `result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};`}
779
779
  if (this.id != null) result["id"] = this.id.href;
780
780
  result["@context"] = ${JSON.stringify(type.defaultContext)};
781
781
  return result;
@@ -830,7 +830,7 @@ async function* generateEncoder(typeUri, types) {
830
830
  `;
831
831
  }
832
832
  yield `
833
- values["@type"] = [${JSON.stringify(type.uri)}];
833
+ ${type.typeless ? "" : `values["@type"] = [${JSON.stringify(type.uri)}];`}
834
834
  if (this.id != null) values["@id"] = this.id.href;
835
835
  if (options.format === "expand") {
836
836
  return await jsonld.expand(
package/dist/schema.yaml CHANGED
@@ -223,6 +223,17 @@ properties:
223
223
 
224
224
  The extended subtypes must have the consistent value of this flag.
225
225
  type: boolean
226
+ typeless:
227
+ description: >-
228
+ Whether the type omits @type in JSON-LD serialization. When true,
229
+ the generated toJsonLd() method will not emit @type (or type in
230
+ compact form) in the serialized JSON-LD. The generated fromJsonLd()
231
+ method will still accept @type if present for backward compatibility.
232
+
233
+ This is useful for types that are not real vocabulary types but rather
234
+ anonymous object structures (e.g., Endpoints, Source in
235
+ ActivityStreams).
236
+ type: boolean
226
237
  description:
227
238
  description: >-
228
239
  The description of the type. It is used as the doc comment of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.1.0-dev.406+61a21e4e",
3
+ "version": "2.1.0-dev.411+13731841",
4
4
  "description": "Code generator for Activity Vocabulary APIs",
5
5
  "homepage": "https://fedify.dev/",
6
6
  "repository": {
@@ -37458,7 +37458,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37458
37458
 
37459
37459
  }
37460
37460
 
37461
- result[\\"type\\"] = \\"as:Endpoints\\";
37461
+
37462
37462
  if (this.id != null) result[\\"id\\"] = this.id.href;
37463
37463
  result[\\"@context\\"] = \\"https://www.w3.org/ns/activitystreams\\";
37464
37464
  return result;
@@ -37557,7 +37557,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37557
37557
 
37558
37558
  }
37559
37559
 
37560
- values[\\"@type\\"] = [\\"https://www.w3.org/ns/activitystreams#Endpoints\\"];
37560
+
37561
37561
  if (this.id != null) values[\\"@id\\"] = this.id.href;
37562
37562
  if (options.format === \\"expand\\") {
37563
37563
  return await jsonld.expand(
@@ -78693,7 +78693,7 @@ get contents(): ((string | LanguageString))[] {
78693
78693
 
78694
78694
  }
78695
78695
 
78696
- result[\\"type\\"] = \\"as:Source\\";
78696
+
78697
78697
  if (this.id != null) result[\\"id\\"] = this.id.href;
78698
78698
  result[\\"@context\\"] = \\"https://www.w3.org/ns/activitystreams\\";
78699
78699
  return result;
@@ -78735,7 +78735,7 @@ get contents(): ((string | LanguageString))[] {
78735
78735
 
78736
78736
  }
78737
78737
 
78738
- values[\\"@type\\"] = [\\"https://www.w3.org/ns/activitystreams#Source\\"];
78738
+
78739
78739
  if (this.id != null) values[\\"@id\\"] = this.id.href;
78740
78740
  if (options.format === \\"expand\\") {
78741
78741
  return await jsonld.expand(
@@ -37456,7 +37456,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37456
37456
 
37457
37457
  }
37458
37458
 
37459
- result[\\"type\\"] = \\"as:Endpoints\\";
37459
+
37460
37460
  if (this.id != null) result[\\"id\\"] = this.id.href;
37461
37461
  result[\\"@context\\"] = \\"https://www.w3.org/ns/activitystreams\\";
37462
37462
  return result;
@@ -37555,7 +37555,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37555
37555
 
37556
37556
  }
37557
37557
 
37558
- values[\\"@type\\"] = [\\"https://www.w3.org/ns/activitystreams#Endpoints\\"];
37558
+
37559
37559
  if (this.id != null) values[\\"@id\\"] = this.id.href;
37560
37560
  if (options.format === \\"expand\\") {
37561
37561
  return await jsonld.expand(
@@ -78691,7 +78691,7 @@ get contents(): ((string | LanguageString))[] {
78691
78691
 
78692
78692
  }
78693
78693
 
78694
- result[\\"type\\"] = \\"as:Source\\";
78694
+
78695
78695
  if (this.id != null) result[\\"id\\"] = this.id.href;
78696
78696
  result[\\"@context\\"] = \\"https://www.w3.org/ns/activitystreams\\";
78697
78697
  return result;
@@ -78733,7 +78733,7 @@ get contents(): ((string | LanguageString))[] {
78733
78733
 
78734
78734
  }
78735
78735
 
78736
- values[\\"@type\\"] = [\\"https://www.w3.org/ns/activitystreams#Source\\"];
78736
+
78737
78737
  if (this.id != null) values[\\"@id\\"] = this.id.href;
78738
78738
  if (options.format === \\"expand\\") {
78739
78739
  return await jsonld.expand(
@@ -37458,7 +37458,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37458
37458
 
37459
37459
  }
37460
37460
 
37461
- result["type"] = "as:Endpoints";
37461
+
37462
37462
  if (this.id != null) result["id"] = this.id.href;
37463
37463
  result["@context"] = "https://www.w3.org/ns/activitystreams";
37464
37464
  return result;
@@ -37557,7 +37557,7 @@ proxyUrl?: URL | null;oauthAuthorizationEndpoint?: URL | null;oauthTokenEndpoint
37557
37557
 
37558
37558
  }
37559
37559
 
37560
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Endpoints"];
37560
+
37561
37561
  if (this.id != null) values["@id"] = this.id.href;
37562
37562
  if (options.format === "expand") {
37563
37563
  return await jsonld.expand(
@@ -78693,7 +78693,7 @@ get contents(): ((string | LanguageString))[] {
78693
78693
 
78694
78694
  }
78695
78695
 
78696
- result["type"] = "as:Source";
78696
+
78697
78697
  if (this.id != null) result["id"] = this.id.href;
78698
78698
  result["@context"] = "https://www.w3.org/ns/activitystreams";
78699
78699
  return result;
@@ -78735,7 +78735,7 @@ get contents(): ((string | LanguageString))[] {
78735
78735
 
78736
78736
  }
78737
78737
 
78738
- values["@type"] = ["https://www.w3.org/ns/activitystreams#Source"];
78738
+
78739
78739
  if (this.id != null) values["@id"] = this.id.href;
78740
78740
  if (options.format === "expand") {
78741
78741
  return await jsonld.expand(
package/src/codec.ts CHANGED
@@ -125,7 +125,11 @@ export async function* generateEncoder(
125
125
  `;
126
126
  }
127
127
  yield `
128
- result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};
128
+ ${
129
+ type.typeless
130
+ ? ""
131
+ : `result["type"] = ${JSON.stringify(type.compactName ?? type.uri)};`
132
+ }
129
133
  if (this.id != null) result["id"] = this.id.href;
130
134
  result["@context"] = ${JSON.stringify(type.defaultContext)};
131
135
  return result;
@@ -197,7 +201,7 @@ export async function* generateEncoder(
197
201
  `;
198
202
  }
199
203
  yield `
200
- values["@type"] = [${JSON.stringify(type.uri)}];
204
+ ${type.typeless ? "" : `values["@type"] = [${JSON.stringify(type.uri)}];`}
201
205
  if (this.id != null) values["@id"] = this.id.href;
202
206
  if (options.format === "expand") {
203
207
  return await jsonld.expand(
package/src/schema.ts CHANGED
@@ -47,6 +47,17 @@ export interface TypeSchema {
47
47
  */
48
48
  entity: boolean;
49
49
 
50
+ /**
51
+ * Whether the type omits `@type` in JSON-LD serialization. When `true`,
52
+ * the generated `toJsonLd()` method will not emit `@type` (or `type` in
53
+ * compact form) in the serialized JSON-LD. The generated `fromJsonLd()`
54
+ * method will still accept `@type` if present for backward compatibility.
55
+ *
56
+ * This is useful for types that are not real vocabulary types but rather
57
+ * anonymous object structures (e.g., `Endpoints`, `Source` in ActivityStreams).
58
+ */
59
+ typeless?: boolean;
60
+
50
61
  /**
51
62
  * The description of the type. It is used as the doc comment of
52
63
  * the generated class.
package/src/schema.yaml CHANGED
@@ -223,6 +223,17 @@ properties:
223
223
 
224
224
  The extended subtypes must have the consistent value of this flag.
225
225
  type: boolean
226
+ typeless:
227
+ description: >-
228
+ Whether the type omits @type in JSON-LD serialization. When true,
229
+ the generated toJsonLd() method will not emit @type (or type in
230
+ compact form) in the serialized JSON-LD. The generated fromJsonLd()
231
+ method will still accept @type if present for backward compatibility.
232
+
233
+ This is useful for types that are not real vocabulary types but rather
234
+ anonymous object structures (e.g., Endpoints, Source in
235
+ ActivityStreams).
236
+ type: boolean
226
237
  description:
227
238
  description: >-
228
239
  The description of the type. It is used as the doc comment of