@verdocs/js-sdk
Advanced tools
Comparing version 1.0.14 to 1.0.15
export * as Documents from './Documents'; | ||
export * as Stars from './Stars'; | ||
export * as Signatures from './Signatures'; | ||
export * as Templates from './Templates'; | ||
export * as Types from './Types'; |
export * as Documents from './Documents'; | ||
export * as Stars from './Stars'; | ||
export * as Signatures from './Signatures'; | ||
export * as Templates from './Templates'; | ||
export * as Types from './Types'; |
@@ -0,1 +1,2 @@ | ||
import { AxiosInstance } from 'axios'; | ||
/** | ||
@@ -51,2 +52,2 @@ * Set the auth token that will be used for Verdocs API calls. | ||
*/ | ||
export declare const getEndpoint: () => import("axios").AxiosInstance; | ||
export declare const getEndpoint: () => AxiosInstance; |
import axios from 'axios'; | ||
var TRACE_ID = '' + Math.floor(Math.random() * 100000); | ||
// tslint:disable-next-line | ||
console.log('[JS-SDK Loaded]', TRACE_ID, import.meta.url); | ||
var config = { | ||
@@ -7,3 +10,12 @@ baseURL: 'https://api.verdocs.com/', | ||
}; | ||
var endpoint = axios.create(config); | ||
var recreateEndpoint = function () { | ||
endpoint = axios.create(config); | ||
endpoint.interceptors.request.use(function (r) { | ||
// tslint:disable-next-line | ||
console.log("[JS-SDK] " + TRACE_ID + " :: " + r.method.toUpperCase() + " " + r.url, JSON.stringify(r.data), JSON.stringify(r.headers)); | ||
return r; | ||
}); | ||
}; | ||
var endpoint; | ||
recreateEndpoint(); | ||
/** | ||
@@ -20,10 +32,8 @@ * Set the auth token that will be used for Verdocs API calls. | ||
if (accessToken) { | ||
config.headers['Authorization'] = "Bearer " + accessToken; | ||
config.headers.Authorization = "Bearer " + accessToken; | ||
} | ||
else { | ||
delete config.headers['Authorization']; | ||
delete config.headers.Authorization; | ||
} | ||
if (endpoint) { | ||
endpoint = axios.create(config); | ||
} | ||
recreateEndpoint(); | ||
}; | ||
@@ -41,5 +51,3 @@ /** | ||
config.headers['X-Client-ID'] = clientID; | ||
if (endpoint) { | ||
endpoint = axios.create(config); | ||
} | ||
recreateEndpoint(); | ||
}; | ||
@@ -58,5 +66,3 @@ /** | ||
config.baseURL = baseUrl; | ||
if (endpoint) { | ||
endpoint = axios.create(config); | ||
} | ||
recreateEndpoint(); | ||
}; | ||
@@ -74,5 +80,3 @@ /** | ||
config.timeout = timeout; | ||
if (endpoint) { | ||
endpoint = axios.create(config); | ||
} | ||
recreateEndpoint(); | ||
}; | ||
@@ -90,5 +94,5 @@ /** | ||
if (!endpoint) { | ||
endpoint = axios.create(config); | ||
recreateEndpoint(); | ||
} | ||
return endpoint; | ||
}; |
@@ -17,7 +17,3 @@ /** | ||
export * as Organizations from './Organizations'; | ||
export * as Signatures from './Signatures'; | ||
export * as Tags from './Tags'; | ||
export * as Users from './Users'; | ||
export * as Utils from './Utils'; | ||
export * as Validators from './Validators'; | ||
export * as Whitelabel from './Whitelabel'; |
@@ -17,7 +17,3 @@ /** | ||
export * as Organizations from './Organizations'; | ||
export * as Signatures from './Signatures'; | ||
export * as Tags from './Tags'; | ||
export * as Users from './Users'; | ||
export * as Utils from './Utils'; | ||
export * as Validators from './Validators'; | ||
export * as Whitelabel from './Whitelabel'; |
@@ -16,1 +16,2 @@ /** | ||
export * as Webhooks from './Webhooks'; | ||
export * as Whitelabel from './Whitelabel'; |
@@ -16,1 +16,2 @@ /** | ||
export * as Webhooks from './Webhooks'; | ||
export * as Whitelabel from './Whitelabel'; |
{ | ||
"name": "@verdocs/js-sdk", | ||
"version": "1.0.14", | ||
"version": "1.0.15", | ||
"private": false, | ||
@@ -18,3 +18,3 @@ "homepage": "https://github.com/Verdocs/js-sdk", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"Xfiles": [ | ||
"**/*" | ||
@@ -30,15 +30,16 @@ ], | ||
"scripts": { | ||
"build": "rm -rf dist/* && tsc && cp README.md package.json .npmignore dist", | ||
"Xprepare": "npm run build", | ||
"XprepublishOnly": "npm test && npm run lint", | ||
"build": "npm run clean && tsc && npm run lint && npm run docs", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run lint", | ||
"OldprepublishOnly": "npm test && npm run lint", | ||
"preversion": "npm run lint", | ||
"version": "npm run format && git add -A src", | ||
"postversion": "git push && git push --tags", | ||
"test": "jest --config jestconfig.json", | ||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jestconfig.json", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"lint": "tslint -p tsconfig.json", | ||
"docs-md": "typedoc && git add --all docs", | ||
"docs-md": "typedoc", | ||
"docs-html": "typedoc --plugin none --out docs-html", | ||
"docs": "npm run docs-md && npm run docs-html && cp -aR docs-html/* ../partner-portal/site/static/js-sdk/", | ||
"pkg": "npm version patch && npm run build && npm run docs" | ||
"clean": "rm -rf Documents HTTP Organizations Search Templates Users Utils index.js index.d.ts" | ||
}, | ||
@@ -55,7 +56,7 @@ "publishConfig": { | ||
"devDependencies": { | ||
"@types/jest": "^27.0.1", | ||
"jest": "^27.2.1", | ||
"jest-mock-axios": "^4.4.0", | ||
"@types/jest": "^27.0.2", | ||
"jest": "^27.3.1", | ||
"jest-mock-axios": "^4.4.1", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.3", | ||
"ts-jest": "^27.0.7", | ||
"tslint": "^6.1.3", | ||
@@ -62,0 +63,0 @@ "tslint-config-prettier": "^1.18.0", |
@@ -69,1 +69,8 @@ # Verdocs JS SDK | ||
suggestions! Please file a pull request with any change requests and we will review them as soon as possible. | ||
## TODO | ||
Currently, we have placeholder tests for a number of functions but had to disable the test suite. See | ||
https://jestjs.io/docs/ecmascript-modules and https://github.com/facebook/jest/issues/10025 for more information. Since we manage our | ||
own transport endpoint, we can probably do this mocking ourselves and eliminate the dependency in the first place. | ||
@@ -10,1 +10,2 @@ export * as Documents from './Documents'; | ||
export * as Types from './Types'; | ||
export * as Validators from './Validators'; |
@@ -10,1 +10,2 @@ export * as Documents from './Documents'; | ||
export * as Types from './Types'; | ||
export * as Validators from './Validators'; |
@@ -1,4 +0,7 @@ | ||
import { ITag } from './Types'; | ||
export declare const createTag: (templateId: string, params: any) => Promise<ITag>; | ||
export declare const getTags: (templateId: string) => Promise<ITag[]>; | ||
export declare const deleteTag: (templateId: string, tagName: string) => Promise<any>; | ||
import { ITag, ITags } from './Types'; | ||
export declare const addTemplateTag: (templateId: string, params: any) => Promise<ITag>; | ||
export declare const getTemplateTags: (templateId: string) => Promise<ITag[]>; | ||
export declare const deleteTemplateTag: (templateId: string, tagName: string) => Promise<any>; | ||
export declare const createTag: (params: ITags) => Promise<ITags>; | ||
export declare const getTag: (tagName: string) => Promise<ITags>; | ||
export declare const getAllTags: (params: any) => Promise<ITags[]>; |
import { getEndpoint } from '../HTTP/Transport'; | ||
export var createTag = function (templateId, params) { | ||
export var addTemplateTag = function (templateId, params) { | ||
return getEndpoint() | ||
@@ -7,3 +7,3 @@ .post("/templates/" + templateId + "/tags/", params) | ||
}; | ||
export var getTags = function (templateId) { | ||
export var getTemplateTags = function (templateId) { | ||
return getEndpoint() | ||
@@ -13,3 +13,3 @@ .get("/templates/" + templateId + "/tags/") | ||
}; | ||
export var deleteTag = function (templateId, tagName) { | ||
export var deleteTemplateTag = function (templateId, tagName) { | ||
return getEndpoint() | ||
@@ -19,1 +19,16 @@ .post("/templates/" + templateId + "/tags/" + tagName) | ||
}; | ||
export var createTag = function (params) { | ||
return getEndpoint() | ||
.post('/tags', params) | ||
.then(function (r) { return r.data; }); | ||
}; | ||
export var getTag = function (tagName) { | ||
return getEndpoint() | ||
.get("/tags/" + tagName) | ||
.then(function (r) { return r.data; }); | ||
}; | ||
export var getAllTags = function (params) { | ||
return getEndpoint() | ||
.get('/tags', params) | ||
.then(function (r) { return r.data; }); | ||
}; |
@@ -118,2 +118,7 @@ export interface ITemplate { | ||
} | ||
export interface ITags { | ||
name: string; | ||
featured?: boolean; | ||
created_at?: Date; | ||
} | ||
export interface IStar { | ||
@@ -120,0 +125,0 @@ template_id: string; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
103294
2515
76
0
85