Skip to content

Commit

Permalink
Merge pull request #8 from klippa-app/annotation-project
Browse files Browse the repository at this point in the history
Annotation project & Dep cleanup
  • Loading branch information
elbble committed Apr 17, 2024
2 parents 792f96c + d7cded2 commit e9e0521
Show file tree
Hide file tree
Showing 24 changed files with 1,151 additions and 167 deletions.
82 changes: 62 additions & 20 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,67 @@ import { AuthService } from "./src/ApiCommunicationsWrapper/Services/Auth/Auth.s
import { ModelBuilderService } from "./src/ApiCommunicationsWrapper/Services/Capturing/ModelBuilder/ModelBuilder.service";

namespace DocHorizon {
export const Auth = AuthService;
export const Financial = FinancialService;
export const Generic = GenericService;
export const Prompt = PromptBuilderService;
//export const Model = ModelBuilderService;
//export const Cia = CIAService;
export const Capturing = CapturingService;
export const DocumentToolkit = DocumentToolkitService;
export const Storage = StorageService;

//Authenticate the API Functionalities with an api key
export function authenticate(apikey: string) {
APIFunctionalities.initAPI(apikey);
}

//Remove the API key and unauthenticate
export function unAuthenticate() {
APIFunctionalities.initAPI("");
}
/**
* Auth Service
* @namespace
*/
export const Auth = AuthService;

/**
* Financial Service
* @namespace
*/
export const Financial = FinancialService;

/**
* Generic Service
* @namespace
*/
export const Generic = GenericService;

/**
* Prompt Service
* @namespace
*/
export const Prompt = PromptBuilderService;
//export const Model = ModelBuilderService;
//export const Cia = CIAService;

/**
* Capturing Service
* @namespace
*/
export const Capturing = CapturingService;

/**
* DocumentToolkit Service
* @namespace
*/
export const DocumentToolkit = DocumentToolkitService;

/**
* Storage Service
* @namespace
*/
export const Storage = StorageService;

/**
* Authenticate the API with an API key
*
* @param apikey - the API key to authenticate with
*/
export function authenticate(apikey: string) {
APIFunctionalities.initAPI(apikey);
}

/**
* Unauthenticate by removing the API key
* this will render the user unable to do any API requests
* and will permanently remove the api key string from any vars/services
*/
export function unAuthenticate() {
APIFunctionalities.initAPI("");
}
}

export { DocHorizon };
export { DocHorizon };
99 changes: 90 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@klippa/dochorizon-sdk",
"version": "1.0.3",
"version": "1.0.4",
"description": "## NodeJS developer SDK for DocHorizon.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -39,11 +39,13 @@
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.25.12",
"typescript": "^5.3.2"
},
"dependencies": {
"dotenv": "^16.3.1",
"typedoc-plugin-markdown": "^3.17.1",
"typedoc-plugin-missing-exports": "^2.2.0",
"typescript": "^5.3.2",
"i18n-iso-countries": "^7.10.0",
"js-yaml": "^4.1.0"
},
"dependencies": {
"dotenv": "^16.3.1"
}
}
13 changes: 11 additions & 2 deletions src/ApiCommunicationsWrapper/Services/APIFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ import {
} from "../Types/ApiTypes";
import fs from "fs";

/**
* API functionalities namespace
*
* exposing all the general API functionalities such as authentication
*/
export namespace APIFunctionalities {
let key: string = "";


/**
* Initialize the API with an API key
* @param apikey - the api key to authenticate with
*/
export function initAPI(apikey: string) {
key = apikey;
}

export async function request(
requestProperties: RequestProperties,
): Promise<DocHorizonResponse> {
Expand Down
12 changes: 10 additions & 2 deletions src/ApiCommunicationsWrapper/Services/Auth/Auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { DocHorizonResponse, Endpoint } from "../../Types/ApiTypes";
import { APIFunctionalities } from "../APIFunctions";

/**
* AuthService
*/
export namespace AuthService {
const routeMapping = {
authInfo: "/api/services/auth/v1/info",
};

//Obtain information about the provided Api key

/**
* Obtain information about the used api key
*
* @returns a DocHorizonResponse object containing found information on the used api key
* @see {@link DocHorizonResponse}
*/
export async function getApiKeyInfo(): Promise<DocHorizonResponse> {
const endpoint: Endpoint = {
url: routeMapping.authInfo,
Expand Down
16 changes: 14 additions & 2 deletions src/ApiCommunicationsWrapper/Services/CIA/CIA.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ import { DocHorizonResponse, Endpoint } from "../../Types/ApiTypes";
import { CiaOptions } from "./CIA.types";
import { APIFunctionalities } from "../APIFunctions";

/**
* CIA Service
*
* Exposing the search function to search for company data
*/
export namespace CIAService {
const routeMapping = {
ciaSearch: "/api/services/company_information/v1/search",
};

//Search for company data given provided parameters

/**
* Search for company data given provided parameters/fields
*
* @param options - an object containing the search parameters/fields
* @see {@link CiaOptions}
*
* @returns a DocHorizonResponse containing any found data for the CIA search
*/
export async function search(
options: CiaOptions,
): Promise<DocHorizonResponse> {
Expand Down
Loading

0 comments on commit e9e0521

Please sign in to comment.