sos-sdk-core-ts 0.1.5 → 0.2.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/CHANGELOG.md +10 -4
- package/README.md +30 -7
- package/dist/emergency-authorization.d.ts +17 -18
- package/dist/emergency-authorization.js +3 -1
- package/dist/emergency-group.d.ts +2 -46
- package/dist/emergency-group.js +2 -48
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/place-card-association.d.ts +2 -35
- package/dist/place-card-association.js +2 -30
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Redefine `sos-sdk-core-ts` as the runtime-neutral orchestration layer consumed
|
|
6
|
+
by SOSChain, Vet and UHC, above `sos-data-utils-ts` and below product SDKs.
|
|
7
|
+
- Remove the accidental dependency on and root reexport of `uhc-sdk-core-ts`.
|
|
8
|
+
- Add neutral `authorizeEmergencyAction` and `EmergencyDeliveryTarget` APIs;
|
|
9
|
+
retain the older `Soschain*` names as deprecated compatibility aliases.
|
|
10
|
+
- Consume emergency evidence, Group/ServiceRequest and card-target contracts
|
|
11
|
+
from `sos-data-utils-ts@0.3.0` instead of maintaining SDK-local copies.
|
|
12
|
+
- Preserve the existing SDK root and subpath exports as compatibility aliases.
|
|
7
13
|
|
|
8
14
|
## 0.1.5
|
|
9
15
|
|
package/README.md
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Shared SOS SDK Core
|
|
2
2
|
|
|
3
|
-
Runtime-neutral SOSChain
|
|
3
|
+
Runtime-neutral shared SDK for SOSChain, VetChain and UHC. Deterministic
|
|
4
|
+
cross-product record types and builders come from `sos-data-utils-ts`; this SDK
|
|
5
|
+
owns reusable authorization and orchestration without Node, browser, gateway or
|
|
6
|
+
product-specific behavior.
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
The canonical architecture keeps both shared layers visible:
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
gdc-* frozen
|
|
12
|
+
↓
|
|
13
|
+
sos-data-utils-ts
|
|
14
|
+
↓
|
|
15
|
+
sos-sdk-core-ts
|
|
16
|
+
├──→ vet-sdk-core-ts
|
|
17
|
+
├──→ uhc-sdk-core-ts
|
|
18
|
+
└──→ sos-sdk-node-ts
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Vet and UHC may also depend directly on `sos-data-utils-ts` when they import or
|
|
22
|
+
expose its types. `sos-sdk-core-ts` never depends on or reexports either product
|
|
23
|
+
SDK. `sos-sdk-node-ts` owns SOSChain-specific Node transport, persistence and
|
|
24
|
+
jobs; those adapters do not belong here.
|
|
25
|
+
|
|
26
|
+
Git, workspace, vendored and `file:` dependencies are forbidden in committed
|
|
27
|
+
or deployed dependency state.
|
|
8
28
|
|
|
9
29
|
The emergency-group contract treats `emergencyGroupId`, `subjectId` and
|
|
10
30
|
`callerId` as opaque business identifiers. A group assistance request is one
|
|
@@ -14,14 +34,17 @@ other resource is projected only at an integration boundary.
|
|
|
14
34
|
Groups are named collections. A scanned card is attached to one selected group
|
|
15
35
|
before that group's identifiers are projected into a single service request.
|
|
16
36
|
|
|
17
|
-
`
|
|
37
|
+
`authorizeEmergencyAction` separately checks trusted evidence for every
|
|
18
38
|
member and for `sos:call` or `sos:request`. Identity verification alone never
|
|
19
39
|
grants an emergency capability. Regional/local delivery is represented by
|
|
20
|
-
`
|
|
40
|
+
`EmergencyDeliveryTarget`; transport and tenant routing stay outside FHIR.
|
|
21
41
|
The `incident-reporter` relationship represents a short-lived grant issued by
|
|
22
42
|
a trusted scan resolver to an already verified person at the scene; it does
|
|
23
43
|
not imply guardianship, control or professional status.
|
|
24
44
|
|
|
45
|
+
The older `SoschainEmergency*` names remain deprecated compatibility aliases
|
|
46
|
+
to the same types and implementation; they are not a second contract.
|
|
47
|
+
|
|
25
48
|
`buildSoschainPlaceCardAssociationClaims` records a UHC/VetChain card link to
|
|
26
49
|
a canonical SOSChain Place or vehicle without merging either identity.
|
|
27
50
|
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
3
|
-
/**
|
|
4
|
-
export type
|
|
5
|
-
evidenceId: string;
|
|
6
|
-
issuerId: string;
|
|
7
|
-
holderId: string;
|
|
8
|
-
subjectIds: readonly string[];
|
|
9
|
-
capabilities: readonly SoschainEmergencyCapability[];
|
|
10
|
-
domains: readonly SoschainEvidenceDomain[];
|
|
11
|
-
relationship: 'self' | 'guardian' | 'professional' | 'institution' | 'incident-reporter';
|
|
12
|
-
verifiedAt: string;
|
|
13
|
-
validUntil?: string;
|
|
14
|
-
}>;
|
|
15
|
-
export type SoschainEmergencyDeliveryTarget = Readonly<{
|
|
1
|
+
import type { EmergencyAuthorizationEvidence, EmergencyCapability, EvidenceDomain } from 'sos-data-utils-ts/emergency-evidence';
|
|
2
|
+
export type { EmergencyAuthorizationEvidence, EmergencyCapability, EvidenceDomain, } from 'sos-data-utils-ts/emergency-evidence';
|
|
3
|
+
/** Runtime-neutral endpoint selected after authorization succeeds. */
|
|
4
|
+
export type EmergencyDeliveryTarget = Readonly<{
|
|
16
5
|
tenantId: string;
|
|
17
6
|
jurisdiction: string;
|
|
18
7
|
locality?: string;
|
|
@@ -22,10 +11,20 @@ export type SoschainEmergencyDeliveryTarget = Readonly<{
|
|
|
22
11
|
* Requires current trusted evidence for every affected subject and capability.
|
|
23
12
|
* Identifier syntax and the legal meaning of each issuer remain policy concerns.
|
|
24
13
|
*/
|
|
25
|
-
export declare function
|
|
14
|
+
export declare function authorizeEmergencyAction(input: Readonly<{
|
|
26
15
|
callerId: string;
|
|
27
16
|
memberSubjectIds: readonly string[];
|
|
28
|
-
capability:
|
|
29
|
-
evidence: readonly
|
|
17
|
+
capability: EmergencyCapability;
|
|
18
|
+
evidence: readonly EmergencyAuthorizationEvidence[];
|
|
30
19
|
now?: string;
|
|
31
20
|
}>): readonly string[];
|
|
21
|
+
/** @deprecated Use `EmergencyDeliveryTarget`. */
|
|
22
|
+
export type SoschainEmergencyDeliveryTarget = EmergencyDeliveryTarget;
|
|
23
|
+
/** @deprecated Import `EmergencyAuthorizationEvidence` from this module. */
|
|
24
|
+
export type SoschainEmergencyAuthorizationEvidence = EmergencyAuthorizationEvidence;
|
|
25
|
+
/** @deprecated Import `EmergencyCapability` from this module. */
|
|
26
|
+
export type SoschainEmergencyCapability = EmergencyCapability;
|
|
27
|
+
/** @deprecated Import `EvidenceDomain` from this module. */
|
|
28
|
+
export type SoschainEvidenceDomain = EvidenceDomain;
|
|
29
|
+
/** @deprecated Use `authorizeEmergencyAction`. */
|
|
30
|
+
export declare const authorizeSoschainEmergencyAction: typeof authorizeEmergencyAction;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Requires current trusted evidence for every affected subject and capability.
|
|
3
3
|
* Identifier syntax and the legal meaning of each issuer remain policy concerns.
|
|
4
4
|
*/
|
|
5
|
-
export function
|
|
5
|
+
export function authorizeEmergencyAction(input) {
|
|
6
6
|
const at = Date.parse(input.now ?? new Date().toISOString());
|
|
7
7
|
const evidenceIds = new Set();
|
|
8
8
|
for (const subjectId of input.memberSubjectIds) {
|
|
@@ -17,3 +17,5 @@ export function authorizeSoschainEmergencyAction(input) {
|
|
|
17
17
|
}
|
|
18
18
|
return [...evidenceIds];
|
|
19
19
|
}
|
|
20
|
+
/** @deprecated Use `authorizeEmergencyAction`. */
|
|
21
|
+
export const authorizeSoschainEmergencyAction = authorizeEmergencyAction;
|
|
@@ -1,46 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
/** Canonical claims-first group record stored under resource.meta.claims. */
|
|
4
|
-
export type SoschainEmergencyGroupClaims = Readonly<{
|
|
5
|
-
'@context': typeof SOSCHAIN_FHIR_CLAIMS_CONTEXT;
|
|
6
|
-
'Group.identifier': string;
|
|
7
|
-
'Group.name': string;
|
|
8
|
-
'Group.member-subject': readonly string[];
|
|
9
|
-
'Group.soschain-caller': string;
|
|
10
|
-
'Group.period-start': string;
|
|
11
|
-
}>;
|
|
12
|
-
/** Canonical claims-first request; FHIR version projection happens later. */
|
|
13
|
-
export type SoschainEmergencyServiceRequestClaims = Readonly<{
|
|
14
|
-
'@context': typeof SOSCHAIN_FHIR_CLAIMS_CONTEXT;
|
|
15
|
-
'ServiceRequest.identifier': string;
|
|
16
|
-
'ServiceRequest.status': 'active';
|
|
17
|
-
'ServiceRequest.intent': 'order';
|
|
18
|
-
'ServiceRequest.code': string;
|
|
19
|
-
'ServiceRequest.code-system': typeof SOSCHAIN_EMERGENCY_ASSISTANCE_CODE_SYSTEM;
|
|
20
|
-
'ServiceRequest.code-display'?: string;
|
|
21
|
-
'ServiceRequest.subject': string;
|
|
22
|
-
'ServiceRequest.subject-type': 'Group';
|
|
23
|
-
'ServiceRequest.requester': string;
|
|
24
|
-
'ServiceRequest.authored-on': string;
|
|
25
|
-
'ServiceRequest.soschain-member-subject': readonly string[];
|
|
26
|
-
}>;
|
|
27
|
-
/** Builds flat, version-neutral FHIR claims without interpreting identifier syntax. */
|
|
28
|
-
export declare function buildSoschainEmergencyGroupClaims(input: Readonly<{
|
|
29
|
-
emergencyGroupId: string;
|
|
30
|
-
displayName: string;
|
|
31
|
-
memberSubjectIds: readonly string[];
|
|
32
|
-
callerId: string;
|
|
33
|
-
createdAt?: string;
|
|
34
|
-
}>): SoschainEmergencyGroupClaims;
|
|
35
|
-
/**
|
|
36
|
-
* Builds one flat ServiceRequest claim set for all members of one emergency
|
|
37
|
-
* group. It deliberately does not construct a FHIR R5/R6 resource.
|
|
38
|
-
*/
|
|
39
|
-
export declare function buildSoschainEmergencyServiceRequestClaims(input: Readonly<{
|
|
40
|
-
requestId: string;
|
|
41
|
-
groupClaims: SoschainEmergencyGroupClaims;
|
|
42
|
-
assistanceCode?: string;
|
|
43
|
-
assistanceDisplay?: string;
|
|
44
|
-
authoredOn?: string;
|
|
45
|
-
}>): SoschainEmergencyServiceRequestClaims;
|
|
46
|
-
export declare function readSoschainEmergencySubjectIds(claims: SoschainEmergencyServiceRequestClaims): readonly string[];
|
|
1
|
+
/** Compatibility subpath for the canonical shared emergency record contracts. */
|
|
2
|
+
export * from 'sos-data-utils-ts/emergency-group';
|
package/dist/emergency-group.js
CHANGED
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
function requiredIdentifier(value, name) {
|
|
4
|
-
const normalized = String(value).trim();
|
|
5
|
-
if (!normalized)
|
|
6
|
-
throw new TypeError(`${name} is required.`);
|
|
7
|
-
return normalized;
|
|
8
|
-
}
|
|
9
|
-
function uniqueIdentifiers(values) {
|
|
10
|
-
const identifiers = [...new Set(values.map((value) => requiredIdentifier(value, 'memberSubjectId')))];
|
|
11
|
-
if (identifiers.length === 0)
|
|
12
|
-
throw new TypeError('At least one memberSubjectId is required.');
|
|
13
|
-
return identifiers;
|
|
14
|
-
}
|
|
15
|
-
/** Builds flat, version-neutral FHIR claims without interpreting identifier syntax. */
|
|
16
|
-
export function buildSoschainEmergencyGroupClaims(input) {
|
|
17
|
-
return {
|
|
18
|
-
'@context': SOSCHAIN_FHIR_CLAIMS_CONTEXT,
|
|
19
|
-
'Group.identifier': requiredIdentifier(input.emergencyGroupId, 'emergencyGroupId'),
|
|
20
|
-
'Group.name': requiredIdentifier(input.displayName, 'displayName'),
|
|
21
|
-
'Group.member-subject': uniqueIdentifiers(input.memberSubjectIds),
|
|
22
|
-
'Group.soschain-caller': requiredIdentifier(input.callerId, 'callerId'),
|
|
23
|
-
'Group.period-start': input.createdAt ?? new Date().toISOString(),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Builds one flat ServiceRequest claim set for all members of one emergency
|
|
28
|
-
* group. It deliberately does not construct a FHIR R5/R6 resource.
|
|
29
|
-
*/
|
|
30
|
-
export function buildSoschainEmergencyServiceRequestClaims(input) {
|
|
31
|
-
return {
|
|
32
|
-
'@context': SOSCHAIN_FHIR_CLAIMS_CONTEXT,
|
|
33
|
-
'ServiceRequest.identifier': requiredIdentifier(input.requestId, 'requestId'),
|
|
34
|
-
'ServiceRequest.status': 'active',
|
|
35
|
-
'ServiceRequest.intent': 'order',
|
|
36
|
-
'ServiceRequest.code': input.assistanceCode?.trim() || 'emergency-assistance',
|
|
37
|
-
'ServiceRequest.code-system': SOSCHAIN_EMERGENCY_ASSISTANCE_CODE_SYSTEM,
|
|
38
|
-
...(input.assistanceDisplay ? { 'ServiceRequest.code-display': input.assistanceDisplay } : {}),
|
|
39
|
-
'ServiceRequest.subject': input.groupClaims['Group.identifier'],
|
|
40
|
-
'ServiceRequest.subject-type': 'Group',
|
|
41
|
-
'ServiceRequest.requester': input.groupClaims['Group.soschain-caller'],
|
|
42
|
-
'ServiceRequest.authored-on': input.authoredOn ?? new Date().toISOString(),
|
|
43
|
-
'ServiceRequest.soschain-member-subject': uniqueIdentifiers(input.groupClaims['Group.member-subject']),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function readSoschainEmergencySubjectIds(claims) {
|
|
47
|
-
return claims['ServiceRequest.soschain-member-subject'];
|
|
48
|
-
}
|
|
1
|
+
/** Compatibility subpath for the canonical shared emergency record contracts. */
|
|
2
|
+
export * from 'sos-data-utils-ts/emergency-group';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export
|
|
1
|
+
/** Shared runtime-neutral orchestration remains independent from product SDKs. */
|
|
2
|
+
export { EmergencyCapabilities, EvidenceDomains, EvidenceRelationships, SoschainEmergencyCapabilities, SoschainEvidenceDomains, SoschainEvidenceRelationships, } from 'sos-data-utils-ts/emergency-evidence';
|
|
3
|
+
export type { EvidenceRelationship, SoschainEvidenceRelationship, } from 'sos-data-utils-ts/emergency-evidence';
|
|
3
4
|
export * from './emergency-group.js';
|
|
4
5
|
export * from './emergency-authorization.js';
|
|
5
6
|
export * from './place-card-association.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
export
|
|
1
|
+
/** Shared runtime-neutral orchestration remains independent from product SDKs. */
|
|
2
|
+
export { EmergencyCapabilities, EvidenceDomains, EvidenceRelationships, SoschainEmergencyCapabilities, SoschainEvidenceDomains, SoschainEvidenceRelationships, } from 'sos-data-utils-ts/emergency-evidence';
|
|
3
3
|
export * from './emergency-group.js';
|
|
4
4
|
export * from './emergency-authorization.js';
|
|
5
5
|
export * from './place-card-association.js';
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export type SoschainAssociationRole = 'controller' | 'occupant' | 'employee' | 'guardian';
|
|
4
|
-
/** Flat association record stored under resource.meta.claims. */
|
|
5
|
-
export type SoschainPlaceCardAssociationClaims = Readonly<{
|
|
6
|
-
'@context': typeof SOSCHAIN_FHIR_CLAIMS_CONTEXT;
|
|
7
|
-
'Basic.identifier': string;
|
|
8
|
-
'Basic.code': 'soschain-card-target-association';
|
|
9
|
-
'Basic.subject': string;
|
|
10
|
-
'Basic.soschain-target': string;
|
|
11
|
-
'Basic.soschain-target-hash': string;
|
|
12
|
-
'Basic.soschain-target-type': SoschainAssociationTargetType;
|
|
13
|
-
'Basic.soschain-role': SoschainAssociationRole;
|
|
14
|
-
'Basic.period-start': string;
|
|
15
|
-
}>;
|
|
16
|
-
export type SoschainCanonicalTargetMatch = Readonly<{
|
|
17
|
-
status: 'created' | 'existing';
|
|
18
|
-
canonicalTargetId: string;
|
|
19
|
-
targetType: SoschainAssociationTargetType;
|
|
20
|
-
}>;
|
|
21
|
-
export declare function buildSoschainPlaceCardAssociationClaims(input: Readonly<{
|
|
22
|
-
associationId: string;
|
|
23
|
-
cardId: string;
|
|
24
|
-
canonicalTargetId: string;
|
|
25
|
-
canonicalTargetHash: string;
|
|
26
|
-
targetType: SoschainAssociationTargetType;
|
|
27
|
-
role: SoschainAssociationRole;
|
|
28
|
-
createdAt?: string;
|
|
29
|
-
}>): SoschainPlaceCardAssociationClaims;
|
|
30
|
-
/** Public deterministic SHA3-384/CID lookup key for smart-contract deduplication. */
|
|
31
|
-
export declare function buildSoschainCanonicalTargetHash(input: Readonly<{
|
|
32
|
-
targetType: SoschainAssociationTargetType;
|
|
33
|
-
countryCode: string;
|
|
34
|
-
canonicalValue: string;
|
|
35
|
-
}>): string;
|
|
1
|
+
/** Compatibility subpath for the canonical shared card-target contracts. */
|
|
2
|
+
export * from 'sos-data-utils-ts/place-card-association';
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
function required(value, name) {
|
|
4
|
-
const normalized = String(value).trim();
|
|
5
|
-
if (!normalized)
|
|
6
|
-
throw new TypeError(`${name} is required.`);
|
|
7
|
-
return normalized;
|
|
8
|
-
}
|
|
9
|
-
export function buildSoschainPlaceCardAssociationClaims(input) {
|
|
10
|
-
return {
|
|
11
|
-
'@context': SOSCHAIN_FHIR_CLAIMS_CONTEXT,
|
|
12
|
-
'Basic.identifier': required(input.associationId, 'associationId'),
|
|
13
|
-
'Basic.code': 'soschain-card-target-association',
|
|
14
|
-
'Basic.subject': required(input.cardId, 'cardId'),
|
|
15
|
-
'Basic.soschain-target': required(input.canonicalTargetId, 'canonicalTargetId'),
|
|
16
|
-
'Basic.soschain-target-hash': required(input.canonicalTargetHash, 'canonicalTargetHash'),
|
|
17
|
-
'Basic.soschain-target-type': input.targetType,
|
|
18
|
-
'Basic.soschain-role': input.role,
|
|
19
|
-
'Basic.period-start': input.createdAt ?? new Date().toISOString(),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/** Public deterministic SHA3-384/CID lookup key for smart-contract deduplication. */
|
|
23
|
-
export function buildSoschainCanonicalTargetHash(input) {
|
|
24
|
-
const canonical = [
|
|
25
|
-
input.targetType,
|
|
26
|
-
required(input.countryCode, 'countryCode').toUpperCase(),
|
|
27
|
-
required(input.canonicalValue, 'canonicalValue').normalize('NFC').trim().replace(/\s+/g, ' ').toLowerCase(),
|
|
28
|
-
].join('|');
|
|
29
|
-
return buildRawCidV1FromUtf8String(canonical);
|
|
30
|
-
}
|
|
1
|
+
/** Compatibility subpath for the canonical shared card-target contracts. */
|
|
2
|
+
export * from 'sos-data-utils-ts/place-card-association';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sos-sdk-core-ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Runtime-neutral
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Runtime-neutral shared orchestration for SOS, Vet and UHC products",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Connecting Solution & Applications Ltd",
|
|
7
7
|
"repository": {
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"prepack": "npm run check"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"uhc-sdk-core-ts": "0.6.0"
|
|
42
|
+
"sos-data-utils-ts": "0.3.2"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
45
|
"@types/node": "^22.5.0",
|