@byu-oit/ts-claims-engine-client
TypeScript icon, indicating that this package has built-in type declarations

4.0.3 • Public • Published

Claims Adjudicator Client

CI Code Coverage GitHub package.json version code style: prettier


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));

Try it out with RunKit on NPM

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";

Related Packages

Package Sidebar

Install

npm i @byu-oit/ts-claims-engine-client

Weekly Downloads

4

Version

4.0.3

License

Apache-2.0

Unpacked Size

34.2 kB

Total Files

11

Last publish

Collaborators

  • mjweather
  • yoshutch
  • lehinpm
  • oscea
  • stuft2
  • mhailstone
  • arasmus8
  • garygsc
  • martingarn
  • snelg
  • byu-oit-bot