Skip to content

Commit b89d621

Browse files
committed
Improved namespace mapping, improved string hasNumericalValue, fix errors snapshots
1 parent e4fd46d commit b89d621

9 files changed

Lines changed: 741 additions & 1549 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ To be released.
3030
a proposal, with `action`, `resourceConformsTo`, `resourceQuantity`,
3131
`availableQuantity`, and `minimumQuantity` properties.
3232
- Added `Measure` class for representing quantities with units of
33-
measure, with `hasUnit` and `hasNumericalValue` properties.
33+
measure, with `unit` and `numericalValue` properties.
3434

3535
[#578]: https://github.com/fedify-dev/fedify/issues/578
3636

docs/manual/vocab.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ property.
158158
> | [`alsoKnownAs`] | `Application.getAliases()`/`Group.getAliases()`/`Organization.getAliases()`/`Person.getAliases()`/`Service.getAliases()` |
159159
> | [`anyOf`] | `Question.getInclusiveOptions()` |
160160
> | [`attributedTo`] | `Object.getAttributions()` |
161+
> | [`hasNumericalValue`] | `Measure.numericalValue` |
162+
> | [`hasUnit`] | `Measure.unit` |
161163
> | [`hreflang`] | `Link.language` |
162164
> | [`inReplyTo`] | `Object.getReplyTargets()` |
163165
> | [`isCat`] | `Application.cat`/`Group.cat`/`Organization.cat`/`Person.cat`/`Service.cat` |
@@ -174,6 +176,8 @@ property.
174176
[`alsoKnownAs`]: https://www.w3.org/TR/did-core/#dfn-alsoknownas
175177
[`anyOf`]: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-anyof
176178
[`attributedTo`]: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attributedto
179+
[`hasNumericalValue`]: http://www.ontology-of-units-of-measure.org/resource/om-2/hasNumericalValue
180+
[`hasUnit`]: http://www.ontology-of-units-of-measure.org/resource/om-2/hasUnit
177181
[`hreflang`]: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-hreflang
178182
[`inReplyTo`]: https://www.w3.org/TR/activitystreams-vocabulary/#dfn-inreplyto
179183
[`isCat`]: https://misskey-hub.net/ns#iscat

packages/vocab-tools/src/__snapshots__/class.test.ts.deno.snap

Lines changed: 713 additions & 887 deletions
Large diffs are not rendered by default.

packages/vocab-tools/src/__snapshots__/class.test.ts.node.snap

Lines changed: 0 additions & 323 deletions
Large diffs are not rendered by default.

packages/vocab-tools/src/__snapshots__/class.test.ts.snap

Lines changed: 0 additions & 323 deletions
Large diffs are not rendered by default.

packages/vocab/src/__snapshots__/vocab.test.ts.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,24 +417,24 @@ snapshot[`Deno.inspect(PropertyValue) [auto] 3`] = `'PropertyValue { id: URL "ht
417417
snapshot[`Deno.inspect(Measure) [auto] 1`] = `
418418
'Measure {
419419
id: URL "https://example.com/",
420-
hasUnit: "hello",
421-
hasNumericalValue: "hello"
420+
unit: "hello",
421+
numericalValue: "12.34"
422422
}'
423423
`;
424424

425425
snapshot[`Deno.inspect(Measure) [auto] 2`] = `
426426
'Measure {
427427
id: URL "https://example.com/",
428-
hasUnit: "hello",
429-
hasNumericalValue: "hello"
428+
unit: "hello",
429+
numericalValue: "12.34"
430430
}'
431431
`;
432432

433433
snapshot[`Deno.inspect(Measure) [auto] 3`] = `
434434
'Measure {
435435
id: URL "https://example.com/",
436-
hasUnit: "hello",
437-
hasNumericalValue: "hello"
436+
unit: "hello",
437+
numericalValue: "12.34"
438438
}'
439439
`;
440440

packages/vocab/src/measure.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defaultContext:
1111
hasNumericalValue: "om2:hasNumericalValue"
1212

1313
properties:
14-
- singularName: hasUnit
14+
- singularName: unit
1515
functional: true
1616
compactName: hasUnit
1717
uri: "http://www.ontology-of-units-of-measure.org/resource/om-2/hasUnit"
@@ -21,15 +21,12 @@ properties:
2121
range:
2222
- "http://www.w3.org/2001/XMLSchema#string"
2323

24-
- singularName: hasNumericalValue
24+
- singularName: numericalValue
2525
functional: true
2626
compactName: hasNumericalValue
2727
uri: "http://www.ontology-of-units-of-measure.org/resource/om-2/hasNumericalValue"
2828
description: |
29-
The amount of the resource, represented as a decimal string. If not
30-
specified, arbitrary amounts can be used when responding to the proposal.
31-
32-
NOTE: This property uses `xsd:string` as a temporary measure until
33-
`xsd:decimal` is supported. See #617.
29+
The amount of the resource. If not specified, arbitrary amounts can be
30+
used when responding to the proposal.
3431
range:
35-
- "http://www.w3.org/2001/XMLSchema#string"
32+
- "http://www.w3.org/2001/XMLSchema#decimal"

packages/vocab/src/proposal.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ description: |
2525
defaultContext:
2626
- "https://www.w3.org/ns/activitystreams"
2727
- "https://w3id.org/security/data-integrity/v1"
28+
- "https://gotosocial.org/ns"
2829
- vf: "https://w3id.org/valueflows/ont/vf#"
2930
om2: "http://www.ontology-of-units-of-measure.org/resource/om-2/"
31+
fedibird: "http://fedibird.com/ns#"
32+
sensitive: "as:sensitive"
33+
emojiReactions:
34+
"@id": "fedibird:emojiReactions"
35+
"@type": "@id"
3036
Proposal: "vf:Proposal"
3137
Intent: "vf:Intent"
3238
purpose: "vf:purpose"

packages/vocab/src/vocab.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { mockDocumentLoader, test } from "@fedify/fixture";
2-
import { decodeMultibase, LanguageString } from "@fedify/vocab-runtime";
2+
import {
3+
decodeMultibase,
4+
LanguageString,
5+
parseDecimal,
6+
} from "@fedify/vocab-runtime";
37
import {
48
areAllScalarTypes,
59
loadSchemaFiles,
@@ -1915,6 +1919,7 @@ const sampleValues: Record<string, any> = {
19151919
"http://www.w3.org/2001/XMLSchema#integer": -123,
19161920
"http://www.w3.org/2001/XMLSchema#nonNegativeInteger": 123,
19171921
"http://www.w3.org/2001/XMLSchema#float": 12.34,
1922+
"http://www.w3.org/2001/XMLSchema#decimal": parseDecimal("12.34"),
19181923
"http://www.w3.org/2001/XMLSchema#string": "hello",
19191924
"http://www.w3.org/2001/XMLSchema#anyURI": new URL("https://example.com/"),
19201925
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString": new LanguageString(

0 commit comments

Comments
 (0)