model

In this section

Type Aliases

ArtifactCheck

type ArtifactCheck = {
  id?: string;
  index: number;
  problems: ValidationIssue[];
  usable: boolean;
};

Defined in: src/model/validate.ts:35

One Artifact's result: usable, or disregarded with the reasons.

Properties

id?
optional id?: string;

Defined in: src/model/validate.ts:38

index
index: number;

Defined in: src/model/validate.ts:37

Position in artifacts[].

problems
problems: ValidationIssue[];

Defined in: src/model/validate.ts:40

usable
usable: boolean;

Defined in: src/model/validate.ts:39


FhirCanonical

type FhirCanonical = string;

Defined in: src/model/types.ts:5

Transport-neutral SMART Health Check-in clinical model (spec §§5–6).


FhirProfileCollectionRef

type FhirProfileCollectionRef = FhirCanonical;

Defined in: src/model/types.ts:13

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.


FhirResourceType

type FhirResourceType = string;

Defined in: src/model/types.ts:7

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.


FhirVersion

type FhirVersion = string;

Defined in: src/model/types.ts:6

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.


ItemOutcome

type ItemOutcome = {
  artifacts: SmartArtifact[];
  id: string;
  message?: string;
  problems: ValidationIssue[];
  status?: SmartCheckinItemStatus["status"];
};

Defined in: src/model/validate.ts:44

One request item's outcome in a response.

Properties

artifacts
artifacts: SmartArtifact[];

Defined in: src/model/validate.ts:50

Usable Artifacts listing this item.

id
id: string;

Defined in: src/model/validate.ts:45

message?
optional message?: string;

Defined in: src/model/validate.ts:48

problems
problems: ValidationIssue[];

Defined in: src/model/validate.ts:51

status?
optional status?: SmartCheckinItemStatus["status"];

Defined in: src/model/validate.ts:47

The item's status, or undefined when it has no valid status ([XV-3]).


RequestValidation

type RequestValidation = 
  | {
  ok: true;
  unsupportedItems: UnsupportedItem[];
  value: SmartCheckinRequest;
}
  | {
  error: string;
  ok: false;
  rule: string;
};

Defined in: src/model/validate.ts:30


ResponseValidation

type ResponseValidation = 
  | {
  artifacts: ArtifactCheck[];
  items: ItemOutcome[];
  ok: true;
  usableArtifacts: SmartArtifact[];
  value: SmartCheckinResponse;
}
  | {
  error: string;
  ok: false;
  rule: string;
};

Defined in: src/model/validate.ts:54

Union Members

Type Literal
{
  artifacts: ArtifactCheck[];
  items: ItemOutcome[];
  ok: true;
  usableArtifacts: SmartArtifact[];
  value: SmartCheckinResponse;
}
artifacts
artifacts: ArtifactCheck[];
items
items: ItemOutcome[];

One entry per status row's item id (without a request) or per request item (with one).

ok
ok: true;
usableArtifacts
usableArtifacts: SmartArtifact[];

The Artifacts that passed every check, in response order.

value
value: SmartCheckinResponse;

The response exactly as received.


Type Literal
{
  error: string;
  ok: false;
  rule: string;
}

SmartArtifactBase

type SmartArtifactBase = {
  fulfills: ReadonlyArray<string>;
  id: string;
  mediaType: string;
};

Defined in: src/model/types.ts:77

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.

Properties

fulfills
fulfills: ReadonlyArray<string>;

Defined in: src/model/types.ts:80

id
id: string;

Defined in: src/model/types.ts:78

mediaType
mediaType: string;

Defined in: src/model/types.ts:79


SmartHealthCheckinAcceptedMediaType

type SmartHealthCheckinAcceptedMediaType = 
  | "application/smart-health-card"
  | "application/fhir+json"
  | string & {
};

Defined in: src/model/types.ts:8

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.


UnsupportedItem

type UnsupportedItem = {
  id: string;
} & ValidationIssue;

Defined in: src/model/validate.ts:28

A request item this library's validation says a Wallet can't process.

Type Declaration

id
id: string;

ValidationIssue

type ValidationIssue = {
  message: string;
  rule: string;
};

Defined in: src/model/validate.ts:25

One problem found, with the spec requirement it comes from.

Properties

message
message: string;

Defined in: src/model/validate.ts:25

rule
rule: string;

Defined in: src/model/validate.ts:25


ValidationResult

type ValidationResult<T> = 
  | {
  ok: true;
  value: T;
}
  | {
  error: string;
  ok: false;
};

Defined in: src/model/types.ts:106

model — transport-neutral SMART Health Check-in request/response types and validators (spec §§5–6), checked against the spec's conformance cases.

Type Parameters

Type Parameter
T

Variables

STATUS_CODES

const STATUS_CODES: readonly ["fulfilled", "partial", "unavailable", "declined", "unsupported", "error"];

Defined in: src/model/validate.ts:67

Functions

findWallet()

function findWallet(registry, id): WebWalletEntry | undefined;

Defined in: src/model/registry.ts:107

Look one up by id.

Parameters

Parameter Type
registry WalletRegistry
id string

Returns

WebWalletEntry | undefined


loadWalletRegistry()

function loadWalletRegistry(source, options?): Promise<WalletRegistry>;

Defined in: src/model/registry.ts:79

Resolve a registry from whatever a deployment configured: the built-in default, an inline object or array, or a URL to fetch JSON from.

const registry = await loadWalletRegistry("/config/wallets.json");

A fetched list is validated before use; a malformed one throws rather than silently falling back, because "which wallet are we sending people to" is not a question to answer by accident.

Parameters

Parameter Type
source | string | WebWalletEntry[] | WalletRegistry
options { fetchImpl?: FetchLike; }
options.fetchImpl? FetchLike

Returns

Promise<WalletRegistry>


parseSmartCheckinRequest()

function parseSmartCheckinRequest(text): RequestValidation;

Defined in: src/model/validate.ts:73

Parse and validate SMART request JSON text, rejecting duplicate member names ([JSON-2]).

Parameters

Parameter Type
text string

Returns

RequestValidation


parseSmartCheckinResponse()

function parseSmartCheckinResponse(text, request?): ResponseValidation;

Defined in: src/model/validate.ts:149

Parse and validate SMART response JSON text, rejecting duplicate member names ([JSON-2]).

Parameters

Parameter Type
text string
request? unknown

Returns

ResponseValidation


validateResponseAgainstRequest()

function validateResponseAgainstRequest(request, response): ResponseValidation;

Defined in: src/model/validate.ts:169

Check a response against the request it answers ([XV-1]..[XV-12]). Fails only when the request is invalid or on [XV-1] and [XV-2].

Parameters

Parameter Type
request unknown
response unknown

Returns

ResponseValidation


validateSmartCheckinRequest()

function validateSmartCheckinRequest(v): RequestValidation;

Defined in: src/model/validate.ts:78

Parameters

Parameter Type
v unknown

Returns

RequestValidation


validateSmartCheckinResponse()

function validateSmartCheckinResponse(v): ResponseValidation;

Defined in: src/model/validate.ts:156

Validate a response on its own: the checks that don't need the request.

Parameters

Parameter Type
v unknown

Returns

ResponseValidation


validateWalletRegistry()

function validateWalletRegistry(value): ValidationResult<WalletRegistry>;

Defined in: src/model/registry.ts:37

Parameters

Parameter Type
value unknown

Returns

ValidationResult<WalletRegistry>

References

SmartArtifact

Re-exports SmartArtifact


SmartCheckinContentSelector

Re-exports SmartCheckinContentSelector


SmartCheckinItemStatus

Re-exports SmartCheckinItemStatus


SmartCheckinRequest

Re-exports SmartCheckinRequest


SmartCheckinRequestItem

Re-exports SmartCheckinRequestItem


SmartCheckinResponse

Re-exports SmartCheckinResponse


WalletRegistry

Re-exports WalletRegistry


WebWalletEntry

Re-exports WebWalletEntry