@byu-oit/ts-claims-engine-client
v4.0.3
Published
Claims engine client implementation in TypeScript
Downloads
54
Readme
Installation
npm i @byu-oit/ts-claims-engine-client
Introduction
The purpose of the Claims Adjudicator Client is to facilitate the formation of claims requests using functional syntax.
Example
const { AdjudicatorClient: CEC } = require("@byu-oit/ts-claims-engine-client");
const client = new CEC();
client
.subject("John")
.mode("all")
.claim(
CEC.claim()
.concept("subject-exists")
.relationship("eq")
.value("true")
.qualify("age", 43)
);
const valid = client.validate(); // True
console.log(JSON.stringify(client.assertion, null, 2));
:sparkles: Try it out with RunKit on NPM :sparkles:
API
Some of the parameters and return types are complex objects. Instead of listing them in the method definitions, they have been listed in the Appendix under API Reference.
AdjudicatorClient
Creates a new instance of the AdjudicatorClient.
AdjudicatorClient(options: AdjudicatorClientParams = {})
Public Data Members
id: string
: The ID of the assertion object.
assertion: PartialAssertion
: The assertion object for making a claims request.
Static Methods
AdjudicatorClient.validate
: Provides programatic access to validate an assertion/claims object.
AdjudicatorClient.validate(assertion: any): boolean
AdjudicatorClient.claim
: Provides programatic access to the ClaimClient class from the AdjudicatorClient.
AdjudicatorClient.claim(options?: ClaimClientParams): ClaimClient
AdjudicatorClient.join
: Provides a method to join assertions together.
AdjudicatorClient.join(...assertions: AdjudicaatorClient): {[key: string]: PartialAssertion}
Public Methods
subject
: Adds subject: [value]
to the assertion object.
subject(value: string): this
mode
: Adds mode: [value]
to the assertion object.
mode(value: 'all' | 'any' | 'one'): this
claim
: Adds claim: PartialClaim[]
(a claim or list of claims) to the assertion object.
claim(...values: Array<ClaimClient | ClaimItem>): this
validate
: Validates the current object schema.
validate(): boolean
Appendix
API Reference
interface AdjudicatorClientParams {
id?: string;
subject?: string;
mode?: Mode;
claims?: Array<ClaimClient | ClaimItem>;
}
interface ClaimClientParams {
concept?: string;
relationship?: Relationship;
value?: string;
qualifier?: Qualifiers;
}
interface ClaimItem {
concept: string;
relationship: Relationship;
value: string;
qualifier?: Qualifiers;
}
type Mode = "all" | "any" | "one";
interface PartialAssertion {
[key: string]: {
subject?: string;
mode?: Mode;
claims?: PartialClaim[];
};
}
interface PartialClaim {
concept?: string;
relationship?: Relationship;
value?: string;
qualifier?: Qualifiers;
}
type Relationship = "gt" | "gt_or_eq" | "lt" | "lt_or_eq" | "eq" | "not_eq";