vet-sdk-core-ts 0.4.40 → 0.4.41
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/README.md
CHANGED
|
@@ -7,13 +7,15 @@ An animal is the first member of its own Individual Organization, so
|
|
|
7
7
|
human that creates it is `Organization.owner`, the controller by default;
|
|
8
8
|
`RESPRSN` must never be copied into the animal member.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
demographics.
|
|
10
|
+
Usual name, birth date, exact NCBI species and optional breed are animal
|
|
11
|
+
demographics. The usual name may be supplied by the controller or generated as
|
|
12
|
+
a pronounceable species ordinal such as `Dog 1`; it is not identity evidence.
|
|
13
|
+
Breed remains separate descriptive text. Controller-authored
|
|
12
14
|
demographics remain editable until a veterinarian attests them; attestation
|
|
13
15
|
does not rewrite the original author, and later correction creates a new
|
|
14
16
|
veterinarian-authored version.
|
|
15
17
|
|
|
16
|
-
Use `buildVetChainAnimalDraftClaims(...)` while the name, exact NCBI species or
|
|
18
|
+
Use `buildVetChainAnimalDraftClaims(...)` while the generated/supplied usual name, exact NCBI species or
|
|
17
19
|
public Card is missing. Only a draft for which
|
|
18
20
|
`readVetChainAnimalOnboardingReadiness(...)` returns `ready: true` may be
|
|
19
21
|
activated and issued a Card. See
|
|
@@ -1,3 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel-neutral form contract for animal demographics.
|
|
3
|
+
*
|
|
4
|
+
* Voice, chat and portal navigation may render this schema differently, but
|
|
5
|
+
* they must not redefine required fields or post-activation mutability.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VETCHAIN_ANIMAL_DEMOGRAPHICS_SCHEMA: Readonly<{
|
|
8
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
9
|
+
readonly $id: "https://vetchain.org/schemas/animal-demographics/v1";
|
|
10
|
+
readonly type: "object";
|
|
11
|
+
readonly additionalProperties: false;
|
|
12
|
+
readonly properties: Readonly<{
|
|
13
|
+
usualName: Readonly<{
|
|
14
|
+
type: "string";
|
|
15
|
+
maxLength: 200;
|
|
16
|
+
'x-vetchain-claim': "org.schema.Organization.alternateName";
|
|
17
|
+
'x-vetchain-auto-generated': true;
|
|
18
|
+
'x-vetchain-mutable-until-attested': true;
|
|
19
|
+
}>;
|
|
20
|
+
birthDate: Readonly<{
|
|
21
|
+
type: "string";
|
|
22
|
+
pattern: "^\\d{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12]\\d|3[01]))?)?$";
|
|
23
|
+
'x-vetchain-claim': "org.schema.Organization.member.birthDate";
|
|
24
|
+
'x-vetchain-mutable-until-attested': true;
|
|
25
|
+
}>;
|
|
26
|
+
species: Readonly<{
|
|
27
|
+
type: "string";
|
|
28
|
+
pattern: "^[1-9]\\d*$";
|
|
29
|
+
not: Readonly<{
|
|
30
|
+
const: "9606";
|
|
31
|
+
}>;
|
|
32
|
+
'x-vetchain-claim': "org.schema.Organization.member.additionalType";
|
|
33
|
+
'x-vetchain-immutable-after-activation': true;
|
|
34
|
+
}>;
|
|
35
|
+
}>;
|
|
36
|
+
readonly required: readonly string[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the controller-supplied usual name or a stable, pronounceable
|
|
40
|
+
* English fallback such as `Dog 1`. The ordinal is allocated durably by the
|
|
41
|
+
* owning BFF; this pure helper never counts records or exposes a private UUID.
|
|
42
|
+
*/
|
|
43
|
+
export declare function resolveVetChainAnimalUsualName(input: Readonly<{
|
|
44
|
+
usualName?: string;
|
|
45
|
+
ncbiTaxonomyId: string;
|
|
46
|
+
ordinal: number;
|
|
47
|
+
}>): string;
|
|
1
48
|
/** Canonical member relationship for the animal SELF subject. */
|
|
2
49
|
export declare const VetChainAnimalMemberRoles: Readonly<{
|
|
3
50
|
readonly Self: "ONESELF";
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import { parseVetChainAnimalCardDid } from 'vet-data-utils-ts';
|
|
2
2
|
import { buildAnimalIdentifier16, buildSpeciesId7 } from './animal-identity.js';
|
|
3
3
|
import { normalizeVetChainNcbiTaxonomyId } from './card-issuance.js';
|
|
4
|
+
import { findVetChainSpeciesByTaxonomyId } from './species.js';
|
|
5
|
+
/**
|
|
6
|
+
* Channel-neutral form contract for animal demographics.
|
|
7
|
+
*
|
|
8
|
+
* Voice, chat and portal navigation may render this schema differently, but
|
|
9
|
+
* they must not redefine required fields or post-activation mutability.
|
|
10
|
+
*/
|
|
11
|
+
export const VETCHAIN_ANIMAL_DEMOGRAPHICS_SCHEMA = Object.freeze({
|
|
12
|
+
$schema: 'https://json-schema.org/draft/2020-12/schema',
|
|
13
|
+
$id: 'https://vetchain.org/schemas/animal-demographics/v1',
|
|
14
|
+
type: 'object',
|
|
15
|
+
additionalProperties: false,
|
|
16
|
+
properties: Object.freeze({
|
|
17
|
+
usualName: Object.freeze({
|
|
18
|
+
type: 'string', maxLength: 200,
|
|
19
|
+
'x-vetchain-claim': 'org.schema.Organization.alternateName',
|
|
20
|
+
'x-vetchain-auto-generated': true,
|
|
21
|
+
'x-vetchain-mutable-until-attested': true,
|
|
22
|
+
}),
|
|
23
|
+
birthDate: Object.freeze({
|
|
24
|
+
type: 'string', pattern: '^\\d{4}(?:-(?:0[1-9]|1[0-2])(?:-(?:0[1-9]|[12]\\d|3[01]))?)?$',
|
|
25
|
+
'x-vetchain-claim': 'org.schema.Organization.member.birthDate',
|
|
26
|
+
'x-vetchain-mutable-until-attested': true,
|
|
27
|
+
}),
|
|
28
|
+
species: Object.freeze({
|
|
29
|
+
type: 'string', pattern: '^[1-9]\\d*$', not: Object.freeze({ const: '9606' }),
|
|
30
|
+
'x-vetchain-claim': 'org.schema.Organization.member.additionalType',
|
|
31
|
+
'x-vetchain-immutable-after-activation': true,
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
required: Object.freeze(['species']),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Returns the controller-supplied usual name or a stable, pronounceable
|
|
38
|
+
* English fallback such as `Dog 1`. The ordinal is allocated durably by the
|
|
39
|
+
* owning BFF; this pure helper never counts records or exposes a private UUID.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveVetChainAnimalUsualName(input) {
|
|
42
|
+
const supplied = String(input.usualName || '').trim();
|
|
43
|
+
if (supplied)
|
|
44
|
+
return supplied;
|
|
45
|
+
if (!Number.isSafeInteger(input.ordinal) || input.ordinal < 1) {
|
|
46
|
+
throw new TypeError('vet_animal_usual_name_ordinal_invalid');
|
|
47
|
+
}
|
|
48
|
+
const taxonomy = normalizeVetChainNcbiTaxonomyId(input.ncbiTaxonomyId);
|
|
49
|
+
const species = findVetChainSpeciesByTaxonomyId(taxonomy);
|
|
50
|
+
const label = species ? humanizeSpeciesKey(species.key) : 'Animal';
|
|
51
|
+
return `${label} ${input.ordinal}`;
|
|
52
|
+
}
|
|
4
53
|
/** Canonical member relationship for the animal SELF subject. */
|
|
5
54
|
export const VetChainAnimalMemberRoles = Object.freeze({ Self: 'ONESELF' });
|
|
6
55
|
/** Canonical schema.org claim names for the VetChain animal registration. */
|
|
@@ -136,3 +185,6 @@ function required(value, error) {
|
|
|
136
185
|
throw new TypeError(error);
|
|
137
186
|
return normalized;
|
|
138
187
|
}
|
|
188
|
+
function humanizeSpeciesKey(value) {
|
|
189
|
+
return value.replace(/([a-z0-9])([A-Z])/g, '$1 $2').trim();
|
|
190
|
+
}
|
|
@@ -40,7 +40,8 @@ readVetChainAnimalOnboardingReadiness(draft)
|
|
|
40
40
|
// { ready: false, missing: ['alternateName', 'species', 'card'] }
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
The BFF later rebuilds the same subject draft with its name
|
|
43
|
+
The BFF later rebuilds the same subject draft with its supplied usual name or a
|
|
44
|
+
durably numbered species fallback such as `Dog 1`, plus its exact NCBI
|
|
44
45
|
taxonomy, issues the public Card, and resubmits it under the same private
|
|
45
46
|
`subjectId`. GW VET alone performs the `pending -> active` transition. A draft
|
|
46
47
|
does not need a clinical `Composition`; the active clinical index is a
|
package/package.json
CHANGED