@fedify/vocab-runtime 2.1.0-dev.565 → 2.1.0-dev.599

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.
Files changed (71) hide show
  1. package/deno.json +4 -3
  2. package/dist/chunk-CUT6urMc.cjs +30 -0
  3. package/dist/jsonld.cjs +8 -0
  4. package/dist/jsonld.d.cts +6 -0
  5. package/dist/jsonld.d.ts +6 -0
  6. package/dist/jsonld.js +7 -0
  7. package/dist/mod.cjs +4485 -4329
  8. package/dist/mod.d.cts +95 -4
  9. package/dist/mod.d.ts +95 -4
  10. package/dist/mod.js +4474 -4299
  11. package/dist/tests/decimal.test.cjs +154 -0
  12. package/dist/tests/decimal.test.d.cts +1 -0
  13. package/dist/tests/decimal.test.d.ts +1 -0
  14. package/dist/tests/decimal.test.js +153 -0
  15. package/dist/tests/docloader-B7jXFZpf.cjs +4562 -0
  16. package/dist/tests/docloader-DMCOWvVB.js +4550 -0
  17. package/dist/tests/docloader.test.cjs +7 -4491
  18. package/dist/tests/docloader.test.js +4 -4488
  19. package/dist/tests/internal/multicodec.test.cjs +77 -0
  20. package/dist/tests/internal/multicodec.test.d.cts +1 -0
  21. package/dist/tests/internal/multicodec.test.d.ts +1 -0
  22. package/dist/tests/internal/multicodec.test.js +76 -0
  23. package/dist/tests/key-ByCmSI2y.js +183 -0
  24. package/dist/tests/key-CCPn6TEY.cjs +231 -0
  25. package/dist/tests/key.test.cjs +36 -212
  26. package/dist/tests/key.test.js +9 -185
  27. package/dist/tests/langstr-BsVE3s9u.js +30 -0
  28. package/dist/tests/langstr-EPh86hXK.cjs +36 -0
  29. package/dist/tests/langstr.test.cjs +5 -33
  30. package/dist/tests/langstr.test.js +1 -29
  31. package/dist/tests/link.test.cjs +1 -1
  32. package/dist/tests/link.test.js +1 -1
  33. package/dist/tests/multibase/multibase.test.cjs +1 -1
  34. package/dist/tests/multibase/multibase.test.js +1 -1
  35. package/dist/tests/multicodec--6hQ74zI.cjs +59 -0
  36. package/dist/tests/multicodec-Dq3IiOV4.js +41 -0
  37. package/dist/tests/{request-3ywvRFy1.js → request-BQtyeAfw.js} +6 -3
  38. package/dist/tests/{request-Dhnqve0g.cjs → request-CW9KOmQu.cjs} +6 -3
  39. package/dist/tests/request.test.cjs +1 -1
  40. package/dist/tests/request.test.js +1 -1
  41. package/dist/tests/url.test.cjs +1 -1
  42. package/dist/tests/url.test.js +1 -1
  43. package/package.json +12 -2
  44. package/src/contexts/activitystreams.json +379 -0
  45. package/src/contexts/did-v1.json +57 -0
  46. package/src/contexts/fep-5711.json +36 -0
  47. package/src/contexts/gotosocial.json +86 -0
  48. package/src/contexts/identity-v1.json +152 -0
  49. package/src/contexts/joinmastodon.json +28 -0
  50. package/src/contexts/schemaorg.json +8845 -0
  51. package/src/contexts/security-data-integrity-v1.json +78 -0
  52. package/src/contexts/security-data-integrity-v2.json +81 -0
  53. package/src/contexts/security-multikey-v1.json +35 -0
  54. package/src/contexts/security-v1.json +74 -0
  55. package/src/contexts/webfinger.json +10 -0
  56. package/src/contexts.ts +33 -4392
  57. package/src/decimal.test.ts +90 -0
  58. package/src/decimal.ts +112 -0
  59. package/src/internal/multicodec.test.ts +68 -0
  60. package/src/internal/multicodec.ts +53 -0
  61. package/src/jsonld.ts +4 -0
  62. package/src/key.test.ts +22 -1
  63. package/src/key.ts +9 -8
  64. package/src/mod.ts +6 -0
  65. package/tsdown.config.ts +1 -1
  66. /package/dist/tests/{link-Ck2yj4dH.js → link-C3q2TC2G.js} +0 -0
  67. /package/dist/tests/{link-CdFPEo9O.cjs → link-DYNFAdNu.cjs} +0 -0
  68. /package/dist/tests/{multibase-DStmqni9.js → multibase-B4g8pz6F.js} +0 -0
  69. /package/dist/tests/{multibase-BFbBiaPE.cjs → multibase-o_ovPHYJ.cjs} +0 -0
  70. /package/dist/tests/{url-fW_DHbih.js → url-CWEP9Zs9.js} +0 -0
  71. /package/dist/tests/{url-C5Vs9nYh.cjs → url-DIjOdK8Q.cjs} +0 -0
package/dist/mod.d.cts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Logger } from "@logtape/logtape";
2
2
 
3
3
  //#region src/contexts.d.ts
4
- // Preloaded context documents
5
- // https://github.com/fedify-dev/fedify/issues/74
6
- // cSpell: disable
7
4
  declare const preloadedContexts: Record<string, unknown>;
8
5
  //#endregion
9
6
  //#region src/request.d.ts
@@ -251,6 +248,100 @@ declare function importMultibaseKey(key: string): Promise<CryptoKey>;
251
248
  */
252
249
  declare function exportMultibaseKey(key: CryptoKey): Promise<string>;
253
250
  //#endregion
251
+ //#region src/decimal.d.ts
252
+ /**
253
+ * A branded string representing an `xsd:decimal` value.
254
+ *
255
+ * Unlike JavaScript's `number`, `xsd:decimal` is intended for exact decimal
256
+ * values such as prices, quantities, and measurements where binary
257
+ * floating-point rounding would be inappropriate. Fedify therefore represents
258
+ * these values as validated strings at runtime while preserving a distinct
259
+ * TypeScript type.
260
+ *
261
+ * Values of this type must be created through {@link parseDecimal}, which
262
+ * validates that the string matches the XML Schema `xsd:decimal` lexical form.
263
+ *
264
+ * The runtime representation is still a plain string. The brand exists only
265
+ * at the type level so APIs can distinguish arbitrary strings from validated
266
+ * decimal literals without introducing a decimal arithmetic dependency.
267
+ *
268
+ * Supported lexical forms include signed and unsigned integers and decimal
269
+ * fractions such as `"-1.23"`, `"+100000.00"`, `"210"`, `".5"`, and `"5."`.
270
+ * Scientific notation such as `"1e3"` and special values like `"NaN"` are
271
+ * rejected. Strings with surrounding XML Schema whitespace can be normalized
272
+ * by {@link parseDecimal}, but values of this type are always stored in their
273
+ * normalized lexical form.
274
+ *
275
+ * This representation is designed to be forward-compatible with a future
276
+ * native decimal type if JavaScript eventually gains one, while keeping the
277
+ * public API semantically precise today.
278
+ *
279
+ * @since 2.1.0
280
+ */
281
+ type Decimal = string & {
282
+ readonly __brand: "Decimal";
283
+ };
284
+ /**
285
+ * Checks whether a string is a valid `xsd:decimal` lexical form.
286
+ *
287
+ * This predicate checks the lexical form strictly, without applying XML Schema
288
+ * whitespace normalization first. It is useful as a type guard for values
289
+ * that are already expected to be normalized decimal strings.
290
+ *
291
+ * @param value A candidate `xsd:decimal` lexical form.
292
+ * @returns `true` if the string matches the XML Schema `xsd:decimal` lexical
293
+ * form, or `false` otherwise.
294
+ * @since 2.1.0
295
+ */
296
+ declare function isDecimal(value: string): value is Decimal;
297
+ /**
298
+ * Checks whether a string can be parsed as an `xsd:decimal` lexical form.
299
+ *
300
+ * Unlike {@link isDecimal}, this predicate first applies the XML Schema
301
+ * `whiteSpace="collapse"` normalization step and then validates the
302
+ * normalized string. This means values like `" 12.50 "` are parseable even
303
+ * though they are not already normalized decimal literals.
304
+ *
305
+ * @param value A candidate `xsd:decimal` lexical form.
306
+ * @returns `true` if the normalized string matches the XML Schema
307
+ * `xsd:decimal` lexical form, or `false` otherwise.
308
+ * @since 2.1.0
309
+ */
310
+ declare function canParseDecimal(value: string): boolean;
311
+ /**
312
+ * Parses a string as an `xsd:decimal` lexical form and returns it as a
313
+ * branded {@link Decimal}.
314
+ *
315
+ * This function validates the input against the XML Schema `xsd:decimal`
316
+ * lexical space after applying the XML Schema `whiteSpace="collapse"`
317
+ * normalization step. It returns the normalized string without any further
318
+ * canonicalization.
319
+ *
320
+ * @param value A candidate `xsd:decimal` lexical form.
321
+ * @returns The normalized string branded as {@link Decimal}.
322
+ * @throws {TypeError} Thrown when the value is not a valid `xsd:decimal`
323
+ * lexical form.
324
+ * @example
325
+ * ```typescript
326
+ * const price = parseDecimal("12.50");
327
+ * ```
328
+ * @example
329
+ * ```typescript
330
+ * const price = parseDecimal(" 12.50 ");
331
+ * console.assert(price === "12.50");
332
+ * ```
333
+ * @example
334
+ * ```typescript
335
+ * try {
336
+ * parseDecimal("1e3");
337
+ * } catch (error) {
338
+ * console.assert(error instanceof TypeError);
339
+ * }
340
+ * ```
341
+ * @since 2.1.0
342
+ */
343
+ declare function parseDecimal(value: string): Decimal;
344
+ //#endregion
254
345
  //#region src/langstr.d.ts
255
346
  /**
256
347
  * A language-tagged string which corresponds to the `rdf:langString` type.
@@ -336,4 +427,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
336
427
  declare function isValidPublicIPv6Address(address: string): boolean;
337
428
  declare function expandIPv6Address(address: string): string;
338
429
  //#endregion
339
- export { AuthenticatedDocumentLoaderFactory, CreateRequestOptions, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, FetchError, GetDocumentLoaderOptions, GetUserAgentOptions, LanguageString, RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
430
+ export { AuthenticatedDocumentLoaderFactory, CreateRequestOptions, Decimal, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, FetchError, GetDocumentLoaderOptions, GetUserAgentOptions, LanguageString, RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, preloadedContexts, validatePublicUrl };
package/dist/mod.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import { Logger } from "@logtape/logtape";
2
2
 
3
3
  //#region src/contexts.d.ts
4
- // Preloaded context documents
5
- // https://github.com/fedify-dev/fedify/issues/74
6
- // cSpell: disable
7
4
  declare const preloadedContexts: Record<string, unknown>;
8
5
  //#endregion
9
6
  //#region src/request.d.ts
@@ -251,6 +248,100 @@ declare function importMultibaseKey(key: string): Promise<CryptoKey>;
251
248
  */
252
249
  declare function exportMultibaseKey(key: CryptoKey): Promise<string>;
253
250
  //#endregion
251
+ //#region src/decimal.d.ts
252
+ /**
253
+ * A branded string representing an `xsd:decimal` value.
254
+ *
255
+ * Unlike JavaScript's `number`, `xsd:decimal` is intended for exact decimal
256
+ * values such as prices, quantities, and measurements where binary
257
+ * floating-point rounding would be inappropriate. Fedify therefore represents
258
+ * these values as validated strings at runtime while preserving a distinct
259
+ * TypeScript type.
260
+ *
261
+ * Values of this type must be created through {@link parseDecimal}, which
262
+ * validates that the string matches the XML Schema `xsd:decimal` lexical form.
263
+ *
264
+ * The runtime representation is still a plain string. The brand exists only
265
+ * at the type level so APIs can distinguish arbitrary strings from validated
266
+ * decimal literals without introducing a decimal arithmetic dependency.
267
+ *
268
+ * Supported lexical forms include signed and unsigned integers and decimal
269
+ * fractions such as `"-1.23"`, `"+100000.00"`, `"210"`, `".5"`, and `"5."`.
270
+ * Scientific notation such as `"1e3"` and special values like `"NaN"` are
271
+ * rejected. Strings with surrounding XML Schema whitespace can be normalized
272
+ * by {@link parseDecimal}, but values of this type are always stored in their
273
+ * normalized lexical form.
274
+ *
275
+ * This representation is designed to be forward-compatible with a future
276
+ * native decimal type if JavaScript eventually gains one, while keeping the
277
+ * public API semantically precise today.
278
+ *
279
+ * @since 2.1.0
280
+ */
281
+ type Decimal = string & {
282
+ readonly __brand: "Decimal";
283
+ };
284
+ /**
285
+ * Checks whether a string is a valid `xsd:decimal` lexical form.
286
+ *
287
+ * This predicate checks the lexical form strictly, without applying XML Schema
288
+ * whitespace normalization first. It is useful as a type guard for values
289
+ * that are already expected to be normalized decimal strings.
290
+ *
291
+ * @param value A candidate `xsd:decimal` lexical form.
292
+ * @returns `true` if the string matches the XML Schema `xsd:decimal` lexical
293
+ * form, or `false` otherwise.
294
+ * @since 2.1.0
295
+ */
296
+ declare function isDecimal(value: string): value is Decimal;
297
+ /**
298
+ * Checks whether a string can be parsed as an `xsd:decimal` lexical form.
299
+ *
300
+ * Unlike {@link isDecimal}, this predicate first applies the XML Schema
301
+ * `whiteSpace="collapse"` normalization step and then validates the
302
+ * normalized string. This means values like `" 12.50 "` are parseable even
303
+ * though they are not already normalized decimal literals.
304
+ *
305
+ * @param value A candidate `xsd:decimal` lexical form.
306
+ * @returns `true` if the normalized string matches the XML Schema
307
+ * `xsd:decimal` lexical form, or `false` otherwise.
308
+ * @since 2.1.0
309
+ */
310
+ declare function canParseDecimal(value: string): boolean;
311
+ /**
312
+ * Parses a string as an `xsd:decimal` lexical form and returns it as a
313
+ * branded {@link Decimal}.
314
+ *
315
+ * This function validates the input against the XML Schema `xsd:decimal`
316
+ * lexical space after applying the XML Schema `whiteSpace="collapse"`
317
+ * normalization step. It returns the normalized string without any further
318
+ * canonicalization.
319
+ *
320
+ * @param value A candidate `xsd:decimal` lexical form.
321
+ * @returns The normalized string branded as {@link Decimal}.
322
+ * @throws {TypeError} Thrown when the value is not a valid `xsd:decimal`
323
+ * lexical form.
324
+ * @example
325
+ * ```typescript
326
+ * const price = parseDecimal("12.50");
327
+ * ```
328
+ * @example
329
+ * ```typescript
330
+ * const price = parseDecimal(" 12.50 ");
331
+ * console.assert(price === "12.50");
332
+ * ```
333
+ * @example
334
+ * ```typescript
335
+ * try {
336
+ * parseDecimal("1e3");
337
+ * } catch (error) {
338
+ * console.assert(error instanceof TypeError);
339
+ * }
340
+ * ```
341
+ * @since 2.1.0
342
+ */
343
+ declare function parseDecimal(value: string): Decimal;
344
+ //#endregion
254
345
  //#region src/langstr.d.ts
255
346
  /**
256
347
  * A language-tagged string which corresponds to the `rdf:langString` type.
@@ -336,4 +427,4 @@ declare function isValidPublicIPv4Address(address: string): boolean;
336
427
  declare function isValidPublicIPv6Address(address: string): boolean;
337
428
  declare function expandIPv6Address(address: string): string;
338
429
  //#endregion
339
- export { AuthenticatedDocumentLoaderFactory, CreateRequestOptions, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, FetchError, GetDocumentLoaderOptions, GetUserAgentOptions, LanguageString, RemoteDocument, UrlError, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, preloadedContexts, validatePublicUrl };
430
+ export { AuthenticatedDocumentLoaderFactory, CreateRequestOptions, Decimal, DocumentLoader, DocumentLoaderFactory, DocumentLoaderFactoryOptions, DocumentLoaderOptions, FetchError, GetDocumentLoaderOptions, GetUserAgentOptions, LanguageString, RemoteDocument, UrlError, canParseDecimal, createActivityPubRequest, decodeMultibase, encodeMultibase, encodingFromBaseData, expandIPv6Address, exportMultibaseKey, exportSpki, getDocumentLoader, getRemoteDocument, getUserAgent, importMultibaseKey, importPem, importPkcs1, importSpki, isDecimal, isValidPublicIPv4Address, isValidPublicIPv6Address, logRequest, parseDecimal, preloadedContexts, validatePublicUrl };