vet-data-utils-ts 0.5.3 → 0.5.4

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
@@ -1,5 +1,8 @@
1
1
  # vet-data-utils-ts
2
2
 
3
+ Development and releases follow the mandatory
4
+ [`local-first TDD and release contract`](docs/LOCAL_FIRST_RELEASE_CONTRACT.md).
5
+
3
6
  Browser-safe, transport-neutral VetChain data contracts shared by GW VET and
4
7
  `vet-sdk-core-ts`. The package owns governed values and validation only; GW VET
5
8
  owns authorization and the SDK owns request construction.
@@ -19,6 +19,23 @@ export declare const VeterinaryTerminologySourceScopes: Readonly<{
19
19
  readonly Icd10: "ICD10";
20
20
  readonly AtcVet: "ATCVET";
21
21
  }>;
22
+ /** Deterministic standards-based data for the isolated local terminology upstream. */
23
+ export declare const VET_TERMINOLOGY_TEST_DATA: Readonly<{
24
+ readonly localApiKey: "local-playwright-umls-key";
25
+ readonly bodyTemperature: Readonly<{
26
+ source: "LNC";
27
+ system: "http://loinc.org";
28
+ code: "8310-5";
29
+ display: "Body temperature:Temp:Pt:^Patient:Qn";
30
+ }>;
31
+ readonly otitisExternaSpanish: Readonly<{
32
+ scope: "SNOMED_CT";
33
+ umlsSource: "SCTSPA";
34
+ system: "http://snomed.info/sct";
35
+ code: "3135009";
36
+ display: "otitis externa";
37
+ }>;
38
+ }>;
22
39
  export type VeterinaryTerminologySourceScope = typeof VeterinaryTerminologySourceScopes[keyof typeof VeterinaryTerminologySourceScopes];
23
40
  export type VeterinaryTerminologyCapability = Readonly<{
24
41
  type: 'terminology-capability';
@@ -19,6 +19,23 @@ export const VeterinaryTerminologySourceScopes = Object.freeze({
19
19
  Icd10: 'ICD10',
20
20
  AtcVet: 'ATCVET',
21
21
  });
22
+ /** Deterministic standards-based data for the isolated local terminology upstream. */
23
+ export const VET_TERMINOLOGY_TEST_DATA = Object.freeze({
24
+ localApiKey: 'local-playwright-umls-key',
25
+ bodyTemperature: Object.freeze({
26
+ source: VeterinaryTerminologySourceScopes.Loinc,
27
+ system: VeterinaryClinicalTerminologySystems.Loinc,
28
+ code: '8310-5',
29
+ display: 'Body temperature:Temp:Pt:^Patient:Qn',
30
+ }),
31
+ otitisExternaSpanish: Object.freeze({
32
+ scope: VeterinaryTerminologySourceScopes.SnomedCt,
33
+ umlsSource: 'SCTSPA',
34
+ system: VeterinaryClinicalTerminologySystems.SnomedCt,
35
+ code: '3135009',
36
+ display: 'otitis externa',
37
+ }),
38
+ });
22
39
  /**
23
40
  * ISO 3166-1 alpha-2 territories enumerated by the official SNOMED
24
41
  * International member page on 2026-09-05.
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './financial.js';
8
8
  export * from './group.js';
9
9
  export * from './iso-jurisdictions.js';
10
10
  export * from './organization-application.js';
11
+ export * from './payment.js';
11
12
  export * from './research-study.js';
12
13
  export * from './sectors.js';
13
14
  export * from './veterinary-sections.js';
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from './financial.js';
8
8
  export * from './group.js';
9
9
  export * from './iso-jurisdictions.js';
10
10
  export * from './organization-application.js';
11
+ export * from './payment.js';
11
12
  export * from './research-study.js';
12
13
  export * from './sectors.js';
13
14
  export * from './veterinary-sections.js';
@@ -0,0 +1,96 @@
1
+ /** Provider and asset identifiers for VetChain payment adapters. */
2
+ export declare const PaymentProviderIds: Readonly<{
3
+ readonly Stripe: "STRIPE";
4
+ readonly UsdcEvm: "USDC_EVM";
5
+ }>;
6
+ export declare const PaymentAssetIds: Readonly<{
7
+ readonly Usdc: "USDC";
8
+ }>;
9
+ export declare const PaymentCurrencyCodes: Readonly<{
10
+ readonly Usd: "USD";
11
+ }>;
12
+ export declare const USDC_DECIMALS: 6;
13
+ export declare const PaymentFlowActions: Readonly<{
14
+ readonly Quote: "quote";
15
+ readonly Confirm: "confirm";
16
+ }>;
17
+ export type PaymentFlowAction = typeof PaymentFlowActions[keyof typeof PaymentFlowActions];
18
+ export type UsdcPaymentConfirmation = Readonly<{
19
+ offerId: string;
20
+ transactionHash: `0x${string}`;
21
+ }>;
22
+ export declare const EvmPaymentNetworkIds: Readonly<{
23
+ readonly LocalAnvil: "local-anvil";
24
+ readonly BaseSepolia: "base-sepolia";
25
+ readonly BaseMainnet: "base-mainnet";
26
+ }>;
27
+ export type PaymentProviderId = typeof PaymentProviderIds[keyof typeof PaymentProviderIds];
28
+ export type EvmPaymentNetworkId = typeof EvmPaymentNetworkIds[keyof typeof EvmPaymentNetworkIds];
29
+ export type UsdcEvmNetwork = Readonly<{
30
+ id: EvmPaymentNetworkId;
31
+ chainId: number;
32
+ usdcContract: `0x${string}`;
33
+ mainnet: boolean;
34
+ }>;
35
+ /** Circle-issued native USDC contracts for Base. */
36
+ export declare const USDC_BASE_NETWORKS: Readonly<{
37
+ "base-sepolia": Readonly<{
38
+ id: "base-sepolia";
39
+ chainId: 84532;
40
+ usdcContract: "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
41
+ mainnet: false;
42
+ }>;
43
+ "base-mainnet": Readonly<{
44
+ id: "base-mainnet";
45
+ chainId: 8453;
46
+ usdcContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
47
+ mainnet: true;
48
+ }>;
49
+ }>;
50
+ export type UsdcPaymentQuote = Readonly<{
51
+ version: 1;
52
+ provider: typeof PaymentProviderIds.UsdcEvm;
53
+ paymentReference: string;
54
+ invoiceId: string;
55
+ network: EvmPaymentNetworkId;
56
+ chainId: number;
57
+ tokenContract: `0x${string}`;
58
+ recipient: `0x${string}`;
59
+ amountMinor: string;
60
+ decimals: typeof USDC_DECIMALS;
61
+ expiresAt: string;
62
+ }>;
63
+ /** Reusable deterministic values for package, GW, BFF and browser tests. */
64
+ export declare const VET_PAYMENT_TEST_DATA: Readonly<{
65
+ readonly recipient: "0x1111111111111111111111111111111111111111";
66
+ readonly otherRecipient: "0x2222222222222222222222222222222222222222";
67
+ readonly payer: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
68
+ readonly localPayerPrivateKey: "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
69
+ readonly localUsdcContract: "0x5FbDB2315678afecb367f032d93F642f64180aa3";
70
+ readonly localRpcUrl: "http://127.0.0.1:3270";
71
+ readonly transactionHash: `0x${string}`;
72
+ readonly amountMinor: 10000000n;
73
+ readonly amountMinorText: "10000000";
74
+ readonly zeroPriceText: "0";
75
+ readonly invalidAmountMinorText: "10.5";
76
+ readonly invalidOfferPriceText: "10.0000001";
77
+ readonly decimals: 6;
78
+ readonly priceText: "10";
79
+ readonly currency: "USD";
80
+ readonly localChainId: 31337;
81
+ readonly receiptBlockNumber: 100n;
82
+ readonly confirmedBlockNumber: 102n;
83
+ readonly minimumConfirmations: 3;
84
+ readonly quantity: 1;
85
+ readonly localPurchaseQuantity: 3;
86
+ readonly paymentReference: "pay_test_01";
87
+ readonly invoiceId: "invoice_test_01";
88
+ readonly validAt: "2026-09-07T12:00:00.000Z";
89
+ readonly expiresAt: "2026-09-07T12:10:00.000Z";
90
+ readonly expiredAt: "2026-09-07T12:11:00.000Z";
91
+ }>;
92
+ export declare function usdOfferToUsdcMinor(input: Readonly<{
93
+ price: unknown;
94
+ priceCurrency: unknown;
95
+ quantity: unknown;
96
+ }>): bigint;
@@ -0,0 +1,80 @@
1
+ /** Provider and asset identifiers for VetChain payment adapters. */
2
+ export const PaymentProviderIds = Object.freeze({
3
+ Stripe: 'STRIPE',
4
+ UsdcEvm: 'USDC_EVM',
5
+ });
6
+ export const PaymentAssetIds = Object.freeze({ Usdc: 'USDC' });
7
+ export const PaymentCurrencyCodes = Object.freeze({ Usd: 'USD' });
8
+ export const USDC_DECIMALS = 6;
9
+ export const PaymentFlowActions = Object.freeze({
10
+ Quote: 'quote',
11
+ Confirm: 'confirm',
12
+ });
13
+ export const EvmPaymentNetworkIds = Object.freeze({
14
+ LocalAnvil: 'local-anvil',
15
+ BaseSepolia: 'base-sepolia',
16
+ BaseMainnet: 'base-mainnet',
17
+ });
18
+ /** Circle-issued native USDC contracts for Base. */
19
+ export const USDC_BASE_NETWORKS = Object.freeze({
20
+ [EvmPaymentNetworkIds.BaseSepolia]: Object.freeze({
21
+ id: EvmPaymentNetworkIds.BaseSepolia,
22
+ chainId: 84532,
23
+ usdcContract: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
24
+ mainnet: false,
25
+ }),
26
+ [EvmPaymentNetworkIds.BaseMainnet]: Object.freeze({
27
+ id: EvmPaymentNetworkIds.BaseMainnet,
28
+ chainId: 8453,
29
+ usdcContract: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
30
+ mainnet: true,
31
+ }),
32
+ });
33
+ /** Reusable deterministic values for package, GW, BFF and browser tests. */
34
+ export const VET_PAYMENT_TEST_DATA = Object.freeze({
35
+ recipient: '0x1111111111111111111111111111111111111111',
36
+ otherRecipient: '0x2222222222222222222222222222222222222222',
37
+ payer: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
38
+ localPayerPrivateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
39
+ localUsdcContract: '0x5FbDB2315678afecb367f032d93F642f64180aa3',
40
+ localRpcUrl: 'http://127.0.0.1:3270',
41
+ transactionHash: `0x${'a'.repeat(64)}`,
42
+ amountMinor: 10000000n,
43
+ amountMinorText: '10000000',
44
+ zeroPriceText: '0',
45
+ invalidAmountMinorText: '10.5',
46
+ invalidOfferPriceText: '10.0000001',
47
+ decimals: USDC_DECIMALS,
48
+ priceText: '10',
49
+ currency: PaymentCurrencyCodes.Usd,
50
+ localChainId: 31337,
51
+ receiptBlockNumber: 100n,
52
+ confirmedBlockNumber: 102n,
53
+ minimumConfirmations: 3,
54
+ quantity: 1,
55
+ localPurchaseQuantity: 3,
56
+ paymentReference: 'pay_test_01',
57
+ invoiceId: 'invoice_test_01',
58
+ validAt: '2026-09-07T12:00:00.000Z',
59
+ expiresAt: '2026-09-07T12:10:00.000Z',
60
+ expiredAt: '2026-09-07T12:11:00.000Z',
61
+ });
62
+ export function usdOfferToUsdcMinor(input) {
63
+ if (String(input.priceCurrency || '').trim().toUpperCase() !== PaymentCurrencyCodes.Usd) {
64
+ throw new Error('usdc_offer_currency_invalid');
65
+ }
66
+ const price = String(input.price || '').trim();
67
+ if (!/^(?:0|[1-9][0-9]*)(?:\.[0-9]{1,6})?$/.test(price)) {
68
+ throw new Error('usdc_offer_amount_invalid');
69
+ }
70
+ const quantity = Number(input.quantity);
71
+ if (!Number.isSafeInteger(quantity) || quantity < 1) {
72
+ throw new Error('usdc_offer_quantity_invalid');
73
+ }
74
+ const [whole, fraction = ''] = price.split('.');
75
+ const unitAmountMinor = BigInt(whole) * 1000000n + BigInt(fraction.padEnd(6, '0'));
76
+ if (unitAmountMinor <= 0n) {
77
+ throw new Error('usdc_offer_amount_invalid');
78
+ }
79
+ return unitAmountMinor * BigInt(quantity);
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vet-data-utils-ts",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Browser-safe governed VetChain data contracts",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Connecting Solution & Applications Ltd",
@@ -48,6 +48,10 @@
48
48
  "types": "./dist/organization-application.d.ts",
49
49
  "default": "./dist/organization-application.js"
50
50
  },
51
+ "./payment": {
52
+ "types": "./dist/payment.d.ts",
53
+ "default": "./dist/payment.js"
54
+ },
51
55
  "./research-study": {
52
56
  "types": "./dist/research-study.d.ts",
53
57
  "default": "./dist/research-study.js"