@fedify/vocab-runtime 2.1.0-dev.592 → 2.1.0-dev.600
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 +4428 -4289
- package/dist/mod.d.cts +95 -4
- package/dist/mod.d.ts +95 -4
- package/dist/mod.js +4426 -4290
- package/dist/tests/decimal.test.cjs +154 -0
- package/dist/tests/decimal.test.d.cts +1 -0
- package/dist/tests/decimal.test.d.ts +1 -0
- package/dist/tests/decimal.test.js +153 -0
- package/dist/tests/docloader-jdqVG3g0.js +4550 -0
- package/dist/tests/docloader-nnrZVFak.cjs +4562 -0
- package/dist/tests/docloader.test.cjs +7 -4491
- package/dist/tests/docloader.test.js +4 -4488
- package/dist/tests/internal/multicodec.test.cjs +1 -1
- package/dist/tests/internal/multicodec.test.js +1 -1
- package/dist/tests/key-ByCmSI2y.js +183 -0
- package/dist/tests/key-CCPn6TEY.cjs +231 -0
- package/dist/tests/key.test.cjs +33 -211
- package/dist/tests/key.test.js +3 -181
- package/dist/tests/langstr-BsVE3s9u.js +30 -0
- package/dist/tests/langstr-EPh86hXK.cjs +36 -0
- package/dist/tests/langstr.test.cjs +5 -33
- package/dist/tests/langstr.test.js +1 -29
- package/dist/tests/link.test.cjs +1 -1
- package/dist/tests/link.test.js +1 -1
- package/dist/tests/multibase/multibase.test.cjs +1 -1
- package/dist/tests/multibase/multibase.test.js +1 -1
- package/dist/tests/{request-DKDE-Rcx.js → request-BmHXdzZg.js} +1 -1
- package/dist/tests/{request-CK7hgRUX.cjs → request-_M2j5bTc.cjs} +1 -1
- package/dist/tests/request.test.cjs +1 -1
- package/dist/tests/request.test.js +1 -1
- package/dist/tests/url.test.cjs +1 -1
- package/dist/tests/url.test.js +1 -1
- package/package.json +2 -2
- package/src/contexts/activitystreams.json +379 -0
- package/src/contexts/did-v1.json +57 -0
- package/src/contexts/fep-5711.json +36 -0
- package/src/contexts/gotosocial.json +86 -0
- package/src/contexts/identity-v1.json +152 -0
- package/src/contexts/joinmastodon.json +28 -0
- package/src/contexts/schemaorg.json +8845 -0
- package/src/contexts/security-data-integrity-v1.json +78 -0
- package/src/contexts/security-data-integrity-v2.json +81 -0
- package/src/contexts/security-multikey-v1.json +35 -0
- package/src/contexts/security-v1.json +74 -0
- package/src/contexts/webfinger.json +10 -0
- package/src/contexts.ts +33 -4392
- package/src/decimal.test.ts +90 -0
- package/src/decimal.ts +112 -0
- package/src/mod.ts +6 -0
- /package/dist/tests/{link-Ck2yj4dH.js → link-C3q2TC2G.js} +0 -0
- /package/dist/tests/{link-CdFPEo9O.cjs → link-DYNFAdNu.cjs} +0 -0
- /package/dist/tests/{multibase-BdHCGO4H.js → multibase-B4g8pz6F.js} +0 -0
- /package/dist/tests/{multibase-B2D6B0V4.cjs → multibase-o_ovPHYJ.cjs} +0 -0
- /package/dist/tests/{multicodec-mHcRzSGY.cjs → multicodec--6hQ74zI.cjs} +0 -0
- /package/dist/tests/{multicodec-DvC5xnX2.js → multicodec-Dq3IiOV4.js} +0 -0
- /package/dist/tests/{url-fW_DHbih.js → url-CWEP9Zs9.js} +0 -0
- /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 };
|