https://github.com/byu-oit/ts-claims-engine-client
Claims engine client implementation in TypeScript
https://github.com/byu-oit/ts-claims-engine-client
Last synced: 10 months ago
JSON representation
Claims engine client implementation in TypeScript
- Host: GitHub
- URL: https://github.com/byu-oit/ts-claims-engine-client
- Owner: byu-oit
- License: apache-2.0
- Created: 2019-09-25T06:19:33.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-19T00:26:25.000Z (about 3 years ago)
- Last Synced: 2025-10-11T02:42:42.571Z (10 months ago)
- Language: TypeScript
- Size: 599 KB
- Stars: 0
- Watchers: 18
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Claims Adjudicator Client
## 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
```ts
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](https://npm.runkit.com/@byu-oit/ts-claims-engine-client) :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](#appendix) under [API Reference](#api-reference).
### AdjudicatorClient
Creates a new instance of the AdjudicatorClient.
```ts
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.
```ts
AdjudicatorClient.validate(assertion: any): boolean
```
`AdjudicatorClient.claim`: Provides programatic access to the ClaimClient class from the AdjudicatorClient.
```ts
AdjudicatorClient.claim(options?: ClaimClientParams): ClaimClient
```
`AdjudicatorClient.join`: Provides a method to join assertions together.
```ts
AdjudicatorClient.join(...assertions: AdjudicaatorClient): {[key: string]: PartialAssertion}
```
### Public Methods
`subject`: Adds `subject: [value]` to the assertion object.
```ts
subject(value: string): this
```
`mode`: Adds `mode: [value]` to the assertion object.
```ts
mode(value: 'all' | 'any' | 'one'): this
```
`claim`: Adds `claim: PartialClaim[]` (a claim or list of claims) to the assertion object.
```ts
claim(...values: Array): this
```
`validate`: Validates the current object schema.
```ts
validate(): boolean
```
## Appendix
### API Reference
```ts
interface AdjudicatorClientParams {
id?: string;
subject?: string;
mode?: Mode;
claims?: Array;
}
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
- [Claims Adjudicator Module (CAM)](https://github.com/byu-oit/ts-claims-engine)
- [Claims Adjudicator Middleware](https://github.com/byu-oit/ts-claims-engine-middleware)
- [Claims Adjudicator Client](https://github.com/byu-oit/ts-claims-engine-client)
- [Claims Adjudicator WSO2 Request](https://github.com/byu-oit/ts-wso2-claims-request)