haystack-nclient
Advanced tools
Comparing version 2.0.11 to 3.0.0
import { HNamespace } from 'haystack-core'; | ||
import { getOpUrlCallback, getHaystackServiceUrlCallback, getHostServiceUrlCallback } from '../util/http'; | ||
import { RecordService } from './RecordService'; | ||
@@ -21,6 +22,2 @@ import { ClientServiceConfig } from './ClientServiceConfig'; | ||
/** | ||
* The default base ops path. | ||
*/ | ||
readonly opsBase: string; | ||
/** | ||
* The project associated with this client. | ||
@@ -83,6 +80,8 @@ */ | ||
* the FIN CSRF fetch will be used. | ||
* @param options.opsBase An optional alternative base path for making ops calls. | ||
* @param options.pathPrefix The optional path to be appended to the base URL when making certain requests. | ||
* @param options.getOpsUrl Optional function that returns the ops URL to use. | ||
* @param options.getHaystackServiceUrl Optional function that returns the haystack service URL to use. | ||
* @param options.getHostServiceUrl Optional function that returns the host service URL to use. | ||
*/ | ||
constructor({ base, project, defs, options, authBearer, fetch, opsBase, pathPrefix, }: { | ||
constructor({ base, project, defs, options, authBearer, fetch, getOpUrl, getHaystackServiceUrl, getHostServiceUrl, pathPrefix, }: { | ||
base: URL; | ||
@@ -94,3 +93,5 @@ project?: string; | ||
fetch?: FetchMethod; | ||
opsBase?: string; | ||
getOpUrl?: getOpUrlCallback; | ||
getHaystackServiceUrl?: getHaystackServiceUrlCallback; | ||
getHostServiceUrl?: getHostServiceUrlCallback; | ||
pathPrefix?: string; | ||
@@ -143,7 +144,8 @@ }); | ||
/** | ||
* @returns A JSON object of the Client. | ||
* @returns A JSON object of the Client that uniquely identifies it. | ||
*/ | ||
toJSON(): { | ||
origin: string; | ||
opsBase: string; | ||
opUrl: string; | ||
haystackServiceUrl: string; | ||
hostServiceUrl: string; | ||
project: string; | ||
@@ -150,0 +152,0 @@ pathPrefix: string; |
@@ -0,0 +0,0 @@ import { HNamespace } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HGrid, HDict, HaysonDict, HList } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HGrid } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HVal } from 'haystack-core'; |
@@ -8,2 +8,9 @@ /** | ||
/** | ||
* Asynchronously return the CSRF token for the specified host. | ||
* | ||
* @param host The host. | ||
* @returns Resolves to the CSRF token or an empty string if it can't be found. | ||
*/ | ||
export declare function getFinCsrfToken(host: string): Promise<string>; | ||
/** | ||
* An enhanced fetch API for CSRF token management with the FIN framework. | ||
@@ -10,0 +17,0 @@ * |
@@ -0,0 +0,0 @@ import { HGrid } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HGrid, HRef, HDict, HaysonDict, HList, HaysonVal, HVal, HNum, HDate, HDateTime, HUri } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { ClientServiceConfig } from './ClientServiceConfig'; |
@@ -0,0 +0,0 @@ import { HGrid, HRef, HDict, HaysonDict, HList } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HDict, HGrid, HRef } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HBool, HDate, HDateTime, HDict, HList, HNum, HRef, HStr, HTime, HVal } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { ClientServiceConfig } from './ClientServiceConfig'; |
@@ -0,0 +0,0 @@ import { HGrid, HDict, HRef } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HRef, HDict } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HRef, HDict } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HGrid, HDict } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HNum } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { HVal } from 'haystack-core'; |
@@ -0,0 +0,0 @@ import { ClientServiceConfig } from '../ClientServiceConfig'; |
@@ -0,0 +0,0 @@ import { ClientServiceConfig } from '../ClientServiceConfig'; |
@@ -0,0 +0,0 @@ import { HGrid } from 'haystack-core'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -6,28 +6,62 @@ import { HList, HRef } from 'haystack-core'; | ||
/** | ||
* The functional interface for getting the op url. | ||
*/ | ||
export interface getOpUrlCallback { | ||
({ origin, pathPrefix, project, op, }: { | ||
origin: string; | ||
pathPrefix: string; | ||
project: string; | ||
op: string; | ||
}): string; | ||
} | ||
/** | ||
* Returns the URL for an op. | ||
* | ||
* @param origin The origin for the op. | ||
* @param opsBase The base ops path. | ||
* @param project The project for the op. | ||
* @param op The op to create the URL for. | ||
* @param params.origin The origin. | ||
* @param params.pathPrefix The path prefix to use. | ||
* @param params.project The project name. | ||
* @param params.op The op name. | ||
* @returns A URL. | ||
*/ | ||
export declare function getOpUrl(origin: string, prefix: string, opsBase: string, project: string, op: string): string; | ||
export declare const getOpUrl: getOpUrlCallback; | ||
/** | ||
* The functional interface for getting the op url. | ||
*/ | ||
export interface getHaystackServiceUrlCallback { | ||
({ origin, pathPrefix, project, path, }: { | ||
origin: string; | ||
pathPrefix: string; | ||
project: string; | ||
path: string; | ||
}): string; | ||
} | ||
/** | ||
* Returns the URL for a Haystack REST service. | ||
* | ||
* @param origin The origin for the service. | ||
* @param project The project for the service. | ||
* @param pathPrefix The path prefix to use. | ||
* @param project The project for the service. May be empty and if so shouldn't be included. | ||
* @param path The service path. | ||
* @returns A URL. | ||
*/ | ||
export declare function getHaystackServiceUrl(origin: string, prefix: string, project: string, path: string): string; | ||
export declare const getHaystackServiceUrl: getHaystackServiceUrlCallback; | ||
/** | ||
* The functional interface for getting the op url. | ||
*/ | ||
export interface getHostServiceUrlCallback { | ||
({ origin, pathPrefix, path, }: { | ||
origin: string; | ||
pathPrefix: string; | ||
path: string; | ||
}): string; | ||
} | ||
/** | ||
* Returns the URL for a Host REST service. | ||
* | ||
* @param origin The origin for the service. | ||
* @param pathPrefix The path prefix to use. | ||
* @param path The service path. | ||
* @returns A URL. | ||
*/ | ||
export declare function getHostServiceUrl(origin: string, prefix: string, path: string): string; | ||
export declare const getHostServiceUrl: getHostServiceUrlCallback; | ||
/** | ||
@@ -107,7 +141,7 @@ * Encode the object as a URI query segment. | ||
/** | ||
* Removes the slashes form the start and end of a string/path | ||
* Adds a starting slash and removes any ending slash. | ||
* | ||
* @param path is the path string | ||
* @returns {string} | ||
* @param path The path to update. | ||
* @returns The updated path. | ||
*/ | ||
export declare function sanitizedPrefixPath(path?: string): string; | ||
export declare function addStartSlashRemoveEndSlash(path: string): string; |
@@ -0,0 +0,0 @@ import { HRef, HDict, HList, HGrid, HaysonDict } from 'haystack-core'; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { HDateTime, HDict, HRef } from 'haystack-core'; |
@@ -13,3 +13,3 @@ { | ||
"homepage": "https://github.com/j2inn/haystack-nclient", | ||
"version": "2.0.11", | ||
"version": "3.0.0", | ||
"module": "dist/index.es.js", | ||
@@ -29,3 +29,3 @@ "main": "dist/index.js", | ||
"prepack": "npm test && npm run build", | ||
"start": "webpack-dev-server --config webpack.config.dev.js" | ||
"start": "webpack serve --config webpack.config.dev.js" | ||
}, | ||
@@ -36,19 +36,19 @@ "files": [ | ||
"devDependencies": { | ||
"@babel/core": "^7.13.15", | ||
"@babel/preset-env": "^7.13.15", | ||
"@babel/core": "^7.14.0", | ||
"@babel/preset-env": "^7.14.1", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@types/adm-zip": "^0.4.34", | ||
"@types/jest": "^26.0.22", | ||
"@types/jest": "^26.0.23", | ||
"@types/lodash": "^4.14.168", | ||
"@types/node": "^14.14.39", | ||
"@types/node": "^15.0.2", | ||
"@types/node-fetch": "^2.5.10", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"@typescript-eslint/eslint-plugin": "^4.22.1", | ||
"@typescript-eslint/parser": "^4.22.1", | ||
"babel-jest": "^26.3.0", | ||
"copy-webpack-plugin": "^8.1.1", | ||
"eslint": "^7.24.0", | ||
"eslint-config-prettier": "^8.2.0", | ||
"eslint": "^7.25.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"fetch-mock": "^9.10.7", | ||
"haystack-core": "2.0.12", | ||
"haystack-core": "2.0.19", | ||
"html-loader": "^2.1.2", | ||
@@ -65,10 +65,10 @@ "html-webpack-plugin": "^5.3.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.45.2", | ||
"ts-jest": "^26.5.4", | ||
"ts-loader": "^8.1.0", | ||
"rollup": "^2.47.0", | ||
"ts-jest": "^26.5.6", | ||
"ts-loader": "^9.1.2", | ||
"ts-node": "^9.0.0", | ||
"typedoc": "^0.20.35", | ||
"typedoc": "^0.20.36", | ||
"typescript": "^4.2.4", | ||
"typescript-eslint-parser": "^22.0.0", | ||
"webpack": "^5.33.2", | ||
"webpack": "^5.36.2", | ||
"webpack-cli": "^4.6.0", | ||
@@ -79,4 +79,4 @@ "webpack-dev-server": "^3.11.2", | ||
"peerDependencies": { | ||
"haystack-core": "^2.0.12" | ||
"haystack-core": "^2.0.19" | ||
} | ||
} |
@@ -0,1 +1,11 @@ | ||
<p align="center"> | ||
<a href="https://github.com/j2inn/haystack-nclient/actions/workflows/master-push.yaml"> | ||
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/j2inn/haystack-nclient/Master%20push" /> | ||
</a> | ||
<a href="https://github.com/j2inn/haystack-nclient/blob/master/LICENSE"> | ||
<img alt="GitHub" src="https://img.shields.io/github/license/j2inn/haystack-nclient" /> | ||
</a> | ||
</p> | ||
# Haystack Client | ||
@@ -21,2 +31,6 @@ | ||
## APIs | ||
Please click [here](http://j2-docs.s3-website-us-east-1.amazonaws.com/j2inn/haystack-nclient/index.html) for the API documentation. | ||
## Servers | ||
@@ -65,16 +79,3 @@ | ||
``` | ||
#### FINx | ||
```typescript | ||
// For FINx... | ||
const client = new Client({ | ||
base: new URL(window.location.href), | ||
opsBase: 'haystack', | ||
// Again the project can be specified if it can't be picked from the browser's current URI. | ||
// project: 'demo', | ||
// Optionally prefer Hayson over Zinc... | ||
options: { headers: { accept: HAYSON_MIME_TYPE } } | ||
}) | ||
``` | ||
## Watch | ||
@@ -81,0 +82,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
11140
153
419551