vet-sdk-core-ts 0.4.0
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 +37 -0
- package/dist/animal-identity.d.ts +109 -0
- package/dist/animal-identity.js +207 -0
- package/dist/card-issuance.d.ts +20 -0
- package/dist/card-issuance.js +59 -0
- package/dist/gateway-contract.d.ts +60 -0
- package/dist/gateway-contract.js +73 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/species.d.ts +484 -0
- package/dist/species.js +76 -0
- package/node_modules/vet-data-utils-ts/README.md +14 -0
- package/node_modules/vet-data-utils-ts/dist/animal-card.d.ts +14 -0
- package/node_modules/vet-data-utils-ts/dist/animal-card.js +44 -0
- package/node_modules/vet-data-utils-ts/dist/assistant.d.ts +7 -0
- package/node_modules/vet-data-utils-ts/dist/assistant.js +6 -0
- package/node_modules/vet-data-utils-ts/dist/digital-twin.d.ts +13 -0
- package/node_modules/vet-data-utils-ts/dist/digital-twin.js +24 -0
- package/node_modules/vet-data-utils-ts/dist/emergency.d.ts +17 -0
- package/node_modules/vet-data-utils-ts/dist/emergency.js +25 -0
- package/node_modules/vet-data-utils-ts/dist/index.d.ts +5 -0
- package/node_modules/vet-data-utils-ts/dist/index.js +5 -0
- package/node_modules/vet-data-utils-ts/dist/veterinary-sections.d.ts +101 -0
- package/node_modules/vet-data-utils-ts/dist/veterinary-sections.js +25 -0
- package/node_modules/vet-data-utils-ts/package.json +29 -0
- package/package.json +59 -0
- package/vendor/vet-data-utils-ts-0.3.0.tgz +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isVeterinarySummarySection } from './veterinary-sections.js';
|
|
2
|
+
export const VeterinaryDigitalTwinFormats = Object.freeze({ Api: 'org.hl7.fhir.api', R4: 'org.hl7.fhir.r4' });
|
|
3
|
+
/** Bounds one section-first pseudonymous search and rejects direct identifiers. */
|
|
4
|
+
export function parseVeterinaryDigitalTwinSearch(input) {
|
|
5
|
+
const value = (input || {});
|
|
6
|
+
for (const forbidden of ['name', 'email', 'telephone', 'identifier', 'subjectDid', 'cardNumber']) {
|
|
7
|
+
if (String(value[forbidden] || '').trim())
|
|
8
|
+
throw new TypeError('veterinary_digital_twin_identifying_filter_forbidden');
|
|
9
|
+
}
|
|
10
|
+
const section = String(value.section || '').trim();
|
|
11
|
+
const resourceType = String(value.resourceType || '').trim();
|
|
12
|
+
const claim = String(value.claim || '').trim();
|
|
13
|
+
const filterValue = String(value.value || '').trim();
|
|
14
|
+
if (!isVeterinarySummarySection(section))
|
|
15
|
+
throw new TypeError('veterinary_digital_twin_section_invalid');
|
|
16
|
+
if (!/^[A-Z][A-Za-z]{1,63}$/.test(resourceType))
|
|
17
|
+
throw new TypeError('veterinary_digital_twin_resource_invalid');
|
|
18
|
+
if (!new RegExp(`^${resourceType.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.[A-Za-z0-9][A-Za-z0-9.-]{0,127}$`).test(claim)) {
|
|
19
|
+
throw new TypeError('veterinary_digital_twin_claim_invalid');
|
|
20
|
+
}
|
|
21
|
+
if (!filterValue || filterValue.length > 256)
|
|
22
|
+
throw new TypeError('veterinary_digital_twin_value_invalid');
|
|
23
|
+
return Object.freeze({ section, resourceType, claim, value: filterValue });
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const VeterinaryOccupationCodes: Readonly<{
|
|
2
|
+
Veterinarian: "2250";
|
|
3
|
+
}>;
|
|
4
|
+
export declare const VeterinaryEmergencyReasonCodes: Readonly<{
|
|
5
|
+
AnimalEmergency: "animal-emergency";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const VeterinaryBreakGlassMaxLifetimeSeconds: number;
|
|
8
|
+
export type VeterinaryBreakGlassRequestData = Readonly<{
|
|
9
|
+
subjectDid: string;
|
|
10
|
+
requestedSections: readonly string[];
|
|
11
|
+
incidentId: string;
|
|
12
|
+
justification: string;
|
|
13
|
+
subjectKind: 'animal';
|
|
14
|
+
reasonCode: 'animal-emergency';
|
|
15
|
+
}>;
|
|
16
|
+
/** Normalizes transport-neutral animal emergency data; GW remains the policy authority. */
|
|
17
|
+
export declare function parseVeterinaryBreakGlassRequestData(input: unknown): VeterinaryBreakGlassRequestData;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isVetChainAnimalCardDid } from './animal-card.js';
|
|
2
|
+
import { isVeterinarySummarySection } from './veterinary-sections.js';
|
|
3
|
+
export const VeterinaryOccupationCodes = Object.freeze({ Veterinarian: '2250' });
|
|
4
|
+
export const VeterinaryEmergencyReasonCodes = Object.freeze({ AnimalEmergency: 'animal-emergency' });
|
|
5
|
+
export const VeterinaryBreakGlassMaxLifetimeSeconds = 15 * 60;
|
|
6
|
+
/** Normalizes transport-neutral animal emergency data; GW remains the policy authority. */
|
|
7
|
+
export function parseVeterinaryBreakGlassRequestData(input) {
|
|
8
|
+
const value = (input || {});
|
|
9
|
+
const subjectDid = String(value.subjectDid || '').trim();
|
|
10
|
+
if (!isVetChainAnimalCardDid(subjectDid))
|
|
11
|
+
throw new TypeError('veterinary_break_glass_animal_required');
|
|
12
|
+
const incidentId = String(value.incidentId || '').trim();
|
|
13
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{7,127}$/.test(incidentId))
|
|
14
|
+
throw new TypeError('veterinary_break_glass_incident_invalid');
|
|
15
|
+
const justification = String(value.justification || '').trim();
|
|
16
|
+
if (justification.length < 20 || justification.length > 500)
|
|
17
|
+
throw new TypeError('veterinary_break_glass_justification_invalid');
|
|
18
|
+
const requestedSections = [...new Set(Array.isArray(value.requestedSections)
|
|
19
|
+
? value.requestedSections.map(String).map(item => item.trim()).filter(Boolean)
|
|
20
|
+
: [])];
|
|
21
|
+
if (!requestedSections.length || requestedSections.some(section => !isVeterinarySummarySection(section))) {
|
|
22
|
+
throw new TypeError('veterinary_break_glass_sections_invalid');
|
|
23
|
+
}
|
|
24
|
+
return Object.freeze({ subjectDid, requestedSections, incidentId, justification, subjectKind: 'animal', reasonCode: 'animal-emergency' });
|
|
25
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export type VeterinarySummarySection = Readonly<{
|
|
2
|
+
system: 'http://loinc.org';
|
|
3
|
+
code: string;
|
|
4
|
+
value: `LOINC|${string}`;
|
|
5
|
+
titleEn: string;
|
|
6
|
+
}>;
|
|
7
|
+
/** VetChain-owned clinical section catalog. It is not an alias of human IPS. */
|
|
8
|
+
export declare const VeterinarySummarySections: Readonly<{
|
|
9
|
+
Problems: Readonly<{
|
|
10
|
+
system: "http://loinc.org";
|
|
11
|
+
code: string;
|
|
12
|
+
value: `LOINC|${string}`;
|
|
13
|
+
titleEn: string;
|
|
14
|
+
}>;
|
|
15
|
+
Allergies: Readonly<{
|
|
16
|
+
system: "http://loinc.org";
|
|
17
|
+
code: string;
|
|
18
|
+
value: `LOINC|${string}`;
|
|
19
|
+
titleEn: string;
|
|
20
|
+
}>;
|
|
21
|
+
Medications: Readonly<{
|
|
22
|
+
system: "http://loinc.org";
|
|
23
|
+
code: string;
|
|
24
|
+
value: `LOINC|${string}`;
|
|
25
|
+
titleEn: string;
|
|
26
|
+
}>;
|
|
27
|
+
Immunizations: Readonly<{
|
|
28
|
+
system: "http://loinc.org";
|
|
29
|
+
code: string;
|
|
30
|
+
value: `LOINC|${string}`;
|
|
31
|
+
titleEn: string;
|
|
32
|
+
}>;
|
|
33
|
+
Results: Readonly<{
|
|
34
|
+
system: "http://loinc.org";
|
|
35
|
+
code: string;
|
|
36
|
+
value: `LOINC|${string}`;
|
|
37
|
+
titleEn: string;
|
|
38
|
+
}>;
|
|
39
|
+
Procedures: Readonly<{
|
|
40
|
+
system: "http://loinc.org";
|
|
41
|
+
code: string;
|
|
42
|
+
value: `LOINC|${string}`;
|
|
43
|
+
titleEn: string;
|
|
44
|
+
}>;
|
|
45
|
+
Devices: Readonly<{
|
|
46
|
+
system: "http://loinc.org";
|
|
47
|
+
code: string;
|
|
48
|
+
value: `LOINC|${string}`;
|
|
49
|
+
titleEn: string;
|
|
50
|
+
}>;
|
|
51
|
+
VitalSigns: Readonly<{
|
|
52
|
+
system: "http://loinc.org";
|
|
53
|
+
code: string;
|
|
54
|
+
value: `LOINC|${string}`;
|
|
55
|
+
titleEn: string;
|
|
56
|
+
}>;
|
|
57
|
+
EnvironmentAndLifestyle: Readonly<{
|
|
58
|
+
system: "http://loinc.org";
|
|
59
|
+
code: string;
|
|
60
|
+
value: `LOINC|${string}`;
|
|
61
|
+
titleEn: string;
|
|
62
|
+
}>;
|
|
63
|
+
Alerts: Readonly<{
|
|
64
|
+
system: "http://loinc.org";
|
|
65
|
+
code: string;
|
|
66
|
+
value: `LOINC|${string}`;
|
|
67
|
+
titleEn: string;
|
|
68
|
+
}>;
|
|
69
|
+
CareGoalsAndControllerPreferences: Readonly<{
|
|
70
|
+
system: "http://loinc.org";
|
|
71
|
+
code: string;
|
|
72
|
+
value: `LOINC|${string}`;
|
|
73
|
+
titleEn: string;
|
|
74
|
+
}>;
|
|
75
|
+
FunctionalStatus: Readonly<{
|
|
76
|
+
system: "http://loinc.org";
|
|
77
|
+
code: string;
|
|
78
|
+
value: `LOINC|${string}`;
|
|
79
|
+
titleEn: string;
|
|
80
|
+
}>;
|
|
81
|
+
PastIllness: Readonly<{
|
|
82
|
+
system: "http://loinc.org";
|
|
83
|
+
code: string;
|
|
84
|
+
value: `LOINC|${string}`;
|
|
85
|
+
titleEn: string;
|
|
86
|
+
}>;
|
|
87
|
+
ReproductiveHistory: Readonly<{
|
|
88
|
+
system: "http://loinc.org";
|
|
89
|
+
code: string;
|
|
90
|
+
value: `LOINC|${string}`;
|
|
91
|
+
titleEn: string;
|
|
92
|
+
}>;
|
|
93
|
+
CarePlan: Readonly<{
|
|
94
|
+
system: "http://loinc.org";
|
|
95
|
+
code: string;
|
|
96
|
+
value: `LOINC|${string}`;
|
|
97
|
+
titleEn: string;
|
|
98
|
+
}>;
|
|
99
|
+
}>;
|
|
100
|
+
export declare const VeterinarySummarySectionValues: readonly `LOINC|${string}`[];
|
|
101
|
+
export declare function isVeterinarySummarySection(value: unknown): value is string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function loinc(code, titleEn) {
|
|
2
|
+
return Object.freeze({ system: 'http://loinc.org', code, value: `LOINC|${code}`, titleEn });
|
|
3
|
+
}
|
|
4
|
+
/** VetChain-owned clinical section catalog. It is not an alias of human IPS. */
|
|
5
|
+
export const VeterinarySummarySections = Object.freeze({
|
|
6
|
+
Problems: loinc('11450-4', 'Problems and active conditions'),
|
|
7
|
+
Allergies: loinc('48765-2', 'Allergies and adverse reactions'),
|
|
8
|
+
Medications: loinc('10160-0', 'Medication history'),
|
|
9
|
+
Immunizations: loinc('11369-6', 'Vaccination history'),
|
|
10
|
+
Results: loinc('30954-2', 'Diagnostic and laboratory results'),
|
|
11
|
+
Procedures: loinc('47519-4', 'Procedure history'),
|
|
12
|
+
Devices: loinc('46264-8', 'Implants and animal devices'),
|
|
13
|
+
VitalSigns: loinc('8716-3', 'Vital signs'),
|
|
14
|
+
EnvironmentAndLifestyle: loinc('29762-2', 'Environment, lifestyle and husbandry history'),
|
|
15
|
+
Alerts: loinc('104605-1', 'Clinical alerts'),
|
|
16
|
+
CareGoalsAndControllerPreferences: loinc('81338-6', 'Care goals and controller preferences'),
|
|
17
|
+
FunctionalStatus: loinc('47420-5', 'Functional status'),
|
|
18
|
+
PastIllness: loinc('11348-0', 'History of past illness'),
|
|
19
|
+
ReproductiveHistory: loinc('10162-6', 'Reproductive history'),
|
|
20
|
+
CarePlan: loinc('18776-5', 'Veterinary care plan'),
|
|
21
|
+
});
|
|
22
|
+
export const VeterinarySummarySectionValues = Object.freeze(Object.values(VeterinarySummarySections).map(({ value }) => value));
|
|
23
|
+
export function isVeterinarySummarySection(value) {
|
|
24
|
+
return VeterinarySummarySectionValues.includes(String(value || '').trim());
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vet-data-utils-ts",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Browser-safe governed VetChain data contracts",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Connecting Solution & Applications Ltd",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
12
|
+
"./animal-card": { "types": "./dist/animal-card.d.ts", "default": "./dist/animal-card.js" },
|
|
13
|
+
"./digital-twin": { "types": "./dist/digital-twin.d.ts", "default": "./dist/digital-twin.js" },
|
|
14
|
+
"./emergency": { "types": "./dist/emergency.d.ts", "default": "./dist/emergency.js" },
|
|
15
|
+
"./veterinary-sections": { "types": "./dist/veterinary-sections.d.ts", "default": "./dist/veterinary-sections.js" },
|
|
16
|
+
"./assistant": { "types": "./dist/assistant.d.ts", "default": "./dist/assistant.js" }
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", "README.md"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
21
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
22
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
24
|
+
"prepare": "npm run build",
|
|
25
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": { "@types/node": "^22.0.0", "typescript": "^5.5.4" },
|
|
28
|
+
"engines": { "node": ">=20" }
|
|
29
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vet-sdk-core-ts",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Browser-safe VetChain core contracts and governed animal species identifiers",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Connecting Solution & Applications Ltd",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./species": {
|
|
16
|
+
"types": "./dist/species.d.ts",
|
|
17
|
+
"default": "./dist/species.js"
|
|
18
|
+
},
|
|
19
|
+
"./animal-identity": {
|
|
20
|
+
"types": "./dist/animal-identity.d.ts",
|
|
21
|
+
"default": "./dist/animal-identity.js"
|
|
22
|
+
},
|
|
23
|
+
"./gateway-contract": {
|
|
24
|
+
"types": "./dist/gateway-contract.d.ts",
|
|
25
|
+
"default": "./dist/gateway-contract.js"
|
|
26
|
+
},
|
|
27
|
+
"./card-issuance": {
|
|
28
|
+
"types": "./dist/card-issuance.d.ts",
|
|
29
|
+
"default": "./dist/card-issuance.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"vendor/vet-data-utils-ts-0.3.0.tgz"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
39
|
+
"build": "npm run clean && tsc -p tsconfig.json",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
42
|
+
"prepare": "npm run build",
|
|
43
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/node": "^22.0.0",
|
|
47
|
+
"typescript": "^5.5.4"
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=20"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@noble/hashes": "^2.2.0",
|
|
54
|
+
"vet-data-utils-ts": "file:vendor/vet-data-utils-ts-0.3.0.tgz"
|
|
55
|
+
},
|
|
56
|
+
"bundledDependencies": [
|
|
57
|
+
"vet-data-utils-ts"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
Binary file
|