@fedify/vocab-tools 2.0.35 → 2.0.36-dev.2530

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.0.35",
3
+ "version": "2.0.36-dev.2530+fb03bc56",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
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.0.35";
11
+ var version = "2.0.36-dev.2530+fb03bc56";
12
12
  //#endregion
13
13
  //#region src/type.ts
14
14
  const HEURISTICS_CONTEXTS = [
@@ -200,16 +200,15 @@ const scalarTypes = {
200
200
  return `typeof ${v} === "object" && "@type" in ${v}
201
201
  && "@value" in ${v} && typeof ${v}["@value"] === "string"
202
202
  && ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"
203
- // Check if the value is a valid RFC 3339 date-time string
204
- && new Date(${v}["@value"]).toString() !== "Invalid Date"
203
+ // Date rejects a fraction right after the minutes, hence the normalized
204
+ // form; the raw form keeps other date-like values failing at decoding
205
+ && (new Date(${v}["@value"]).toString() !== "Invalid Date"
206
+ || new Date(normalizeDateTimeLiteral(${v}["@value"])).toString()
207
+ !== "Invalid Date")
205
208
  `;
206
209
  },
207
210
  decoder(v) {
208
- return `Temporal.Instant.from(
209
- ${v}["@value"].substring(19).match(/[Z+-]/)
210
- ? ${v}["@value"]
211
- : ${v}["@value"] + "Z"
212
- )`;
211
+ return `Temporal.Instant.from(normalizeDateTimeLiteral(${v}["@value"]))`;
213
212
  }
214
213
  },
215
214
  "http://www.w3.org/2001/XMLSchema#duration": {
@@ -1924,6 +1923,7 @@ async function* generateClasses(types) {
1924
1923
  yield `import {
1925
1924
  isTemporalDuration,
1926
1925
  isTemporalInstant,
1926
+ normalizeDateTimeLiteral,
1927
1927
  } from "@fedify/vocab-runtime/temporal";\n`;
1928
1928
  yield `
1929
1929
  function canDecodeIri(iri: string): boolean {
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.0.35";
10
+ var version = "2.0.36-dev.2530+fb03bc56";
11
11
  //#endregion
12
12
  //#region src/type.ts
13
13
  const HEURISTICS_CONTEXTS = [
@@ -199,16 +199,15 @@ const scalarTypes = {
199
199
  return `typeof ${v} === "object" && "@type" in ${v}
200
200
  && "@value" in ${v} && typeof ${v}["@value"] === "string"
201
201
  && ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"
202
- // Check if the value is a valid RFC 3339 date-time string
203
- && new Date(${v}["@value"]).toString() !== "Invalid Date"
202
+ // Date rejects a fraction right after the minutes, hence the normalized
203
+ // form; the raw form keeps other date-like values failing at decoding
204
+ && (new Date(${v}["@value"]).toString() !== "Invalid Date"
205
+ || new Date(normalizeDateTimeLiteral(${v}["@value"])).toString()
206
+ !== "Invalid Date")
204
207
  `;
205
208
  },
206
209
  decoder(v) {
207
- return `Temporal.Instant.from(
208
- ${v}["@value"].substring(19).match(/[Z+-]/)
209
- ? ${v}["@value"]
210
- : ${v}["@value"] + "Z"
211
- )`;
210
+ return `Temporal.Instant.from(normalizeDateTimeLiteral(${v}["@value"]))`;
212
211
  }
213
212
  },
214
213
  "http://www.w3.org/2001/XMLSchema#duration": {
@@ -1923,6 +1922,7 @@ async function* generateClasses(types) {
1923
1922
  yield `import {
1924
1923
  isTemporalDuration,
1925
1924
  isTemporalInstant,
1925
+ normalizeDateTimeLiteral,
1926
1926
  } from "@fedify/vocab-runtime/temporal";\n`;
1927
1927
  yield `
1928
1928
  function canDecodeIri(iri: string): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab-tools",
3
- "version": "2.0.35",
3
+ "version": "2.0.36-dev.2530+fb03bc56",
4
4
  "description": "Code generator for Activity Vocabulary APIs",
5
5
  "homepage": "https://fedify.dev/",
6
6
  "repository": {
@@ -22,6 +22,7 @@ import {
22
22
  import {
23
23
  isTemporalDuration,
24
24
  isTemporalInstant,
25
+ normalizeDateTimeLiteral,
25
26
  } from \\"@fedify/vocab-runtime/temporal\\";
26
27
 
27
28
  function canDecodeIri(iri: string): boolean {
@@ -10009,11 +10010,7 @@ get urls(): ((URL | Link))[] {
10009
10010
  if (v == null) continue;
10010
10011
 
10011
10012
  const decoded =
10012
- Temporal.Instant.from(
10013
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10014
- ? v[\\"@value\\"]
10015
- : v[\\"@value\\"] + \\"Z\\"
10016
- )
10013
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10017
10014
  ;
10018
10015
 
10019
10016
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10319,11 +10316,7 @@ get urls(): ((URL | Link))[] {
10319
10316
  if (v == null) continue;
10320
10317
 
10321
10318
  const decoded =
10322
- Temporal.Instant.from(
10323
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10324
- ? v[\\"@value\\"]
10325
- : v[\\"@value\\"] + \\"Z\\"
10326
- )
10319
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10327
10320
  ;
10328
10321
 
10329
10322
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10503,11 +10496,7 @@ get urls(): ((URL | Link))[] {
10503
10496
  if (v == null) continue;
10504
10497
 
10505
10498
  const decoded =
10506
- Temporal.Instant.from(
10507
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10508
- ? v[\\"@value\\"]
10509
- : v[\\"@value\\"] + \\"Z\\"
10510
- )
10499
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10511
10500
  ;
10512
10501
 
10513
10502
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10615,11 +10604,7 @@ get urls(): ((URL | Link))[] {
10615
10604
  if (v == null) continue;
10616
10605
 
10617
10606
  const decoded =
10618
- Temporal.Instant.from(
10619
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10620
- ? v[\\"@value\\"]
10621
- : v[\\"@value\\"] + \\"Z\\"
10622
- )
10607
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10623
10608
  ;
10624
10609
 
10625
10610
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -18875,11 +18860,7 @@ cryptosuite?: \\"eddsa-jcs-2022\\" | null;verificationMethod?: Multikey | URL |
18875
18860
  if (v == null) continue;
18876
18861
 
18877
18862
  const decoded =
18878
- Temporal.Instant.from(
18879
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
18880
- ? v[\\"@value\\"]
18881
- : v[\\"@value\\"] + \\"Z\\"
18882
- )
18863
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
18883
18864
  ;
18884
18865
 
18885
18866
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -72339,13 +72320,12 @@ instruments?: (Object | URL)[];exclusiveOptions?: (Object | URL)[];inclusiveOpti
72339
72320
  typeof v === \\"object\\" && \\"@type\\" in v
72340
72321
  && \\"@value\\" in v && typeof v[\\"@value\\"] === \\"string\\"
72341
72322
  && v[\\"@type\\"] === \\"http://www.w3.org/2001/XMLSchema#dateTime\\"
72342
- // Check if the value is a valid RFC 3339 date-time string
72343
- && new Date(v[\\"@value\\"]).toString() !== \\"Invalid Date\\"
72344
- ? Temporal.Instant.from(
72345
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
72346
- ? v[\\"@value\\"]
72347
- : v[\\"@value\\"] + \\"Z\\"
72348
- ) : typeof v === \\"object\\" && \\"@value\\" in v
72323
+ // Date rejects a fraction right after the minutes, hence the normalized
72324
+ // form; the raw form keeps other date-like values failing at decoding
72325
+ && (new Date(v[\\"@value\\"]).toString() !== \\"Invalid Date\\"
72326
+ || new Date(normalizeDateTimeLiteral(v[\\"@value\\"])).toString()
72327
+ !== \\"Invalid Date\\")
72328
+ ? Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"])) : typeof v === \\"object\\" && \\"@value\\" in v
72349
72329
  && typeof v[\\"@value\\"] === \\"boolean\\" ? v[\\"@value\\"] : undefined
72350
72330
  ;
72351
72331
 
@@ -84038,11 +84018,7 @@ proofs?: (DataIntegrityProof | URL)[];deleted?: Temporal.Instant | null;}
84038
84018
  if (v == null) continue;
84039
84019
 
84040
84020
  const decoded =
84041
- Temporal.Instant.from(
84042
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
84043
- ? v[\\"@value\\"]
84044
- : v[\\"@value\\"] + \\"Z\\"
84045
- )
84021
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
84046
84022
  ;
84047
84023
 
84048
84024
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -20,6 +20,7 @@ import {
20
20
  import {
21
21
  isTemporalDuration,
22
22
  isTemporalInstant,
23
+ normalizeDateTimeLiteral,
23
24
  } from \\"@fedify/vocab-runtime/temporal\\";
24
25
 
25
26
  function canDecodeIri(iri: string): boolean {
@@ -10007,11 +10008,7 @@ get urls(): ((URL | Link))[] {
10007
10008
  if (v == null) continue;
10008
10009
 
10009
10010
  const decoded =
10010
- Temporal.Instant.from(
10011
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10012
- ? v[\\"@value\\"]
10013
- : v[\\"@value\\"] + \\"Z\\"
10014
- )
10011
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10015
10012
  ;
10016
10013
 
10017
10014
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10317,11 +10314,7 @@ get urls(): ((URL | Link))[] {
10317
10314
  if (v == null) continue;
10318
10315
 
10319
10316
  const decoded =
10320
- Temporal.Instant.from(
10321
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10322
- ? v[\\"@value\\"]
10323
- : v[\\"@value\\"] + \\"Z\\"
10324
- )
10317
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10325
10318
  ;
10326
10319
 
10327
10320
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10501,11 +10494,7 @@ get urls(): ((URL | Link))[] {
10501
10494
  if (v == null) continue;
10502
10495
 
10503
10496
  const decoded =
10504
- Temporal.Instant.from(
10505
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10506
- ? v[\\"@value\\"]
10507
- : v[\\"@value\\"] + \\"Z\\"
10508
- )
10497
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10509
10498
  ;
10510
10499
 
10511
10500
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10613,11 +10602,7 @@ get urls(): ((URL | Link))[] {
10613
10602
  if (v == null) continue;
10614
10603
 
10615
10604
  const decoded =
10616
- Temporal.Instant.from(
10617
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
10618
- ? v[\\"@value\\"]
10619
- : v[\\"@value\\"] + \\"Z\\"
10620
- )
10605
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
10621
10606
  ;
10622
10607
 
10623
10608
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -18873,11 +18858,7 @@ cryptosuite?: \\"eddsa-jcs-2022\\" | null;verificationMethod?: Multikey | URL |
18873
18858
  if (v == null) continue;
18874
18859
 
18875
18860
  const decoded =
18876
- Temporal.Instant.from(
18877
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
18878
- ? v[\\"@value\\"]
18879
- : v[\\"@value\\"] + \\"Z\\"
18880
- )
18861
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
18881
18862
  ;
18882
18863
 
18883
18864
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -72337,13 +72318,12 @@ instruments?: (Object | URL)[];exclusiveOptions?: (Object | URL)[];inclusiveOpti
72337
72318
  typeof v === \\"object\\" && \\"@type\\" in v
72338
72319
  && \\"@value\\" in v && typeof v[\\"@value\\"] === \\"string\\"
72339
72320
  && v[\\"@type\\"] === \\"http://www.w3.org/2001/XMLSchema#dateTime\\"
72340
- // Check if the value is a valid RFC 3339 date-time string
72341
- && new Date(v[\\"@value\\"]).toString() !== \\"Invalid Date\\"
72342
- ? Temporal.Instant.from(
72343
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
72344
- ? v[\\"@value\\"]
72345
- : v[\\"@value\\"] + \\"Z\\"
72346
- ) : typeof v === \\"object\\" && \\"@value\\" in v
72321
+ // Date rejects a fraction right after the minutes, hence the normalized
72322
+ // form; the raw form keeps other date-like values failing at decoding
72323
+ && (new Date(v[\\"@value\\"]).toString() !== \\"Invalid Date\\"
72324
+ || new Date(normalizeDateTimeLiteral(v[\\"@value\\"])).toString()
72325
+ !== \\"Invalid Date\\")
72326
+ ? Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"])) : typeof v === \\"object\\" && \\"@value\\" in v
72347
72327
  && typeof v[\\"@value\\"] === \\"boolean\\" ? v[\\"@value\\"] : undefined
72348
72328
  ;
72349
72329
 
@@ -84036,11 +84016,7 @@ proofs?: (DataIntegrityProof | URL)[];deleted?: Temporal.Instant | null;}
84036
84016
  if (v == null) continue;
84037
84017
 
84038
84018
  const decoded =
84039
- Temporal.Instant.from(
84040
- v[\\"@value\\"].substring(19).match(/[Z+-]/)
84041
- ? v[\\"@value\\"]
84042
- : v[\\"@value\\"] + \\"Z\\"
84043
- )
84019
+ Temporal.Instant.from(normalizeDateTimeLiteral(v[\\"@value\\"]))
84044
84020
  ;
84045
84021
 
84046
84022
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -22,6 +22,7 @@ import {
22
22
  import {
23
23
  isTemporalDuration,
24
24
  isTemporalInstant,
25
+ normalizeDateTimeLiteral,
25
26
  } from "@fedify/vocab-runtime/temporal";
26
27
 
27
28
  function canDecodeIri(iri: string): boolean {
@@ -10009,11 +10010,7 @@ get urls(): ((URL | Link))[] {
10009
10010
  if (v == null) continue;
10010
10011
 
10011
10012
  const decoded =
10012
- Temporal.Instant.from(
10013
- v["@value"].substring(19).match(/[Z+-]/)
10014
- ? v["@value"]
10015
- : v["@value"] + "Z"
10016
- )
10013
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
10017
10014
  ;
10018
10015
 
10019
10016
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10319,11 +10316,7 @@ get urls(): ((URL | Link))[] {
10319
10316
  if (v == null) continue;
10320
10317
 
10321
10318
  const decoded =
10322
- Temporal.Instant.from(
10323
- v["@value"].substring(19).match(/[Z+-]/)
10324
- ? v["@value"]
10325
- : v["@value"] + "Z"
10326
- )
10319
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
10327
10320
  ;
10328
10321
 
10329
10322
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10503,11 +10496,7 @@ get urls(): ((URL | Link))[] {
10503
10496
  if (v == null) continue;
10504
10497
 
10505
10498
  const decoded =
10506
- Temporal.Instant.from(
10507
- v["@value"].substring(19).match(/[Z+-]/)
10508
- ? v["@value"]
10509
- : v["@value"] + "Z"
10510
- )
10499
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
10511
10500
  ;
10512
10501
 
10513
10502
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -10615,11 +10604,7 @@ get urls(): ((URL | Link))[] {
10615
10604
  if (v == null) continue;
10616
10605
 
10617
10606
  const decoded =
10618
- Temporal.Instant.from(
10619
- v["@value"].substring(19).match(/[Z+-]/)
10620
- ? v["@value"]
10621
- : v["@value"] + "Z"
10622
- )
10607
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
10623
10608
  ;
10624
10609
 
10625
10610
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -18875,11 +18860,7 @@ cryptosuite?: "eddsa-jcs-2022" | null;verificationMethod?: Multikey | URL | null
18875
18860
  if (v == null) continue;
18876
18861
 
18877
18862
  const decoded =
18878
- Temporal.Instant.from(
18879
- v["@value"].substring(19).match(/[Z+-]/)
18880
- ? v["@value"]
18881
- : v["@value"] + "Z"
18882
- )
18863
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
18883
18864
  ;
18884
18865
 
18885
18866
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
@@ -72339,13 +72320,12 @@ instruments?: (Object | URL)[];exclusiveOptions?: (Object | URL)[];inclusiveOpti
72339
72320
  typeof v === "object" && "@type" in v
72340
72321
  && "@value" in v && typeof v["@value"] === "string"
72341
72322
  && v["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"
72342
- // Check if the value is a valid RFC 3339 date-time string
72343
- && new Date(v["@value"]).toString() !== "Invalid Date"
72344
- ? Temporal.Instant.from(
72345
- v["@value"].substring(19).match(/[Z+-]/)
72346
- ? v["@value"]
72347
- : v["@value"] + "Z"
72348
- ) : typeof v === "object" && "@value" in v
72323
+ // Date rejects a fraction right after the minutes, hence the normalized
72324
+ // form; the raw form keeps other date-like values failing at decoding
72325
+ && (new Date(v["@value"]).toString() !== "Invalid Date"
72326
+ || new Date(normalizeDateTimeLiteral(v["@value"])).toString()
72327
+ !== "Invalid Date")
72328
+ ? Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"])) : typeof v === "object" && "@value" in v
72349
72329
  && typeof v["@value"] === "boolean" ? v["@value"] : undefined
72350
72330
  ;
72351
72331
 
@@ -84038,11 +84018,7 @@ proofs?: (DataIntegrityProof | URL)[];deleted?: Temporal.Instant | null;}
84038
84018
  if (v == null) continue;
84039
84019
 
84040
84020
  const decoded =
84041
- Temporal.Instant.from(
84042
- v["@value"].substring(19).match(/[Z+-]/)
84043
- ? v["@value"]
84044
- : v["@value"] + "Z"
84045
- )
84021
+ Temporal.Instant.from(normalizeDateTimeLiteral(v["@value"]))
84046
84022
  ;
84047
84023
 
84048
84024
  if (!this._shouldCacheDecodedJsonLd(decoded)) {
package/src/class.ts CHANGED
@@ -158,6 +158,7 @@ export async function* generateClasses(
158
158
  yield `import {
159
159
  isTemporalDuration,
160
160
  isTemporalInstant,
161
+ normalizeDateTimeLiteral,
161
162
  } from "@fedify/vocab-runtime/temporal";\n`;
162
163
  yield `
163
164
  function canDecodeIri(iri: string): boolean {
package/src/type.ts CHANGED
@@ -207,16 +207,15 @@ const scalarTypes: Record<string, ScalarType> = {
207
207
  return `typeof ${v} === "object" && "@type" in ${v}
208
208
  && "@value" in ${v} && typeof ${v}["@value"] === "string"
209
209
  && ${v}["@type"] === "http://www.w3.org/2001/XMLSchema#dateTime"
210
- // Check if the value is a valid RFC 3339 date-time string
211
- && new Date(${v}["@value"]).toString() !== "Invalid Date"
210
+ // Date rejects a fraction right after the minutes, hence the normalized
211
+ // form; the raw form keeps other date-like values failing at decoding
212
+ && (new Date(${v}["@value"]).toString() !== "Invalid Date"
213
+ || new Date(normalizeDateTimeLiteral(${v}["@value"])).toString()
214
+ !== "Invalid Date")
212
215
  `;
213
216
  },
214
217
  decoder(v) {
215
- return `Temporal.Instant.from(
216
- ${v}["@value"].substring(19).match(/[Z+-]/)
217
- ? ${v}["@value"]
218
- : ${v}["@value"] + "Z"
219
- )`;
218
+ return `Temporal.Instant.from(normalizeDateTimeLiteral(${v}["@value"]))`;
220
219
  },
221
220
  },
222
221
  "http://www.w3.org/2001/XMLSchema#duration": {