@timetac/js-client-library
Advanced tools
Comparing version 0.2.4 to 0.2.6
@@ -5,4 +5,4 @@ "use strict"; | ||
const baseApi_1 = require("../baseApi"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
const responseHandlers = require("../utils/response/responseHandlers"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
class AbsencesEndpoint extends baseApi_1.default { | ||
@@ -9,0 +9,0 @@ constructor() { |
import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
import { TokenResponse } from './authentication/types'; | ||
import { RequestPromise } from './utils/response/responseHandlers'; | ||
import { TokenResponse } from './authentication/types'; | ||
export declare type Tokens = { | ||
@@ -5,0 +5,0 @@ accessToken: string; |
@@ -41,7 +41,6 @@ "use strict"; | ||
getAccountUrl() { | ||
var _a; | ||
if (!this.config.account) { | ||
throw 'Account is not set'; | ||
} | ||
return `https://${(_a = this.config.host) !== null && _a !== void 0 ? _a : DEFAULT_HOST}/${this.config.account}/`; | ||
return `${this.config.account}/`; | ||
} | ||
@@ -48,0 +47,0 @@ setAccount(account) { |
import BaseApi from '../baseApi'; | ||
import { ApiResponse } from '../utils/response/apiResponse'; | ||
import { SyncResource } from './types'; | ||
import { ApiResponse } from '../utils/response/apiResponse'; | ||
export declare class DeltaSyncEndpoint extends BaseApi { | ||
@@ -5,0 +5,0 @@ readonly resourceName = "deltaSync"; |
@@ -1,8 +0,8 @@ | ||
import { User } from '../users/types'; | ||
import { Task } from '../tasks/types'; | ||
import { Project } from '../projects/types'; | ||
import { TimeTracking } from '../timetrackings/types'; | ||
import { AbsenceType } from '..'; | ||
import { GeneralSetting } from '../generalSettings/types'; | ||
import { Project } from '../projects/types'; | ||
import { Task } from '../tasks/types'; | ||
import { TimesheetAccounting } from '../timesheetAccountings/types'; | ||
import { TimeTracking } from '../timetrackings/types'; | ||
import { User } from '../users/types'; | ||
export declare type SyncData = { | ||
@@ -9,0 +9,0 @@ users: User[]; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const baseApi_1 = require("../baseApi"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
const responseHandlers = require("../utils/response/responseHandlers"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
class FavouriteTasksEndpoint extends baseApi_1.default { | ||
@@ -9,0 +9,0 @@ constructor() { |
import BaseApi from '../baseApi'; | ||
import { RequestParams } from '../utils/params/requestParams'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
import { GeneralSetting } from './types'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
export declare class GeneralSettingsEndpoint extends BaseApi { | ||
@@ -6,0 +6,0 @@ readonly resourceName = "generalSettings"; |
@@ -1,2 +0,1 @@ | ||
import { ApiConfig, ApiState } from './baseApi'; | ||
import { AbsenceDaysEndpoint } from './absenceDays'; | ||
@@ -6,5 +5,7 @@ import { AbsencesEndpoint } from './absences'; | ||
import { AuthenticationEndpoint } from './authentication'; | ||
import { ApiConfig, ApiState } from './baseApi'; | ||
import { DeltaSyncEndpoint } from './deltaSync'; | ||
import { DepartmentsEndpoint } from './departments'; | ||
import { FavouriteTasksEndpoint } from './favouriteTasks'; | ||
import { GeneralSettingsEndpoint } from './generalSettings'; | ||
import { ProjectsEndpoint } from './projects'; | ||
@@ -21,4 +22,2 @@ import { RecentTasksEndpoint } from './recentTasks'; | ||
import { UserStatusOverviewsEndpoint } from './userStatusOverview'; | ||
import { GeneralSettingsEndpoint } from './generalSettings'; | ||
export { Tokens } from './baseApi'; | ||
export { AbsenceDay } from './absenceDays/types'; | ||
@@ -28,4 +27,7 @@ export { Absence, AbsenceApprove, AbsenceCreate, AbsenceReject, AbsenceUpdate } from './absences/types'; | ||
export { Credentials } from './authentication/types'; | ||
export { Tokens } from './baseApi'; | ||
export { SyncData, SyncResource, SyncResourceField } from './deltaSync/types'; | ||
export { Department } from './departments/types'; | ||
export * from './enums'; | ||
export { AbsenceDayType, AbsenceDurationUnit, AbsenceStatus, UserStatusOverviewStatus } from './enums'; | ||
export { FavouriteTask, FavouriteTaskCreate } from './favouriteTasks/types'; | ||
@@ -40,9 +42,8 @@ export { GeneralSetting } from './generalSettings/types'; | ||
export { TimesheetAccounting } from './timesheetAccountings/types'; | ||
export { TimeTracking, TimeTrackingCreate, StartTimeTrackingData, StopTimeTrackingData } from './timetrackings/types'; | ||
export { StartTimeTrackingData, StopTimeTrackingData, TimeTracking, TimeTrackingCreate } from './timetrackings/types'; | ||
export { TodoTask, TodoTaskCreate } from './todoTasks/types'; | ||
export { User } from './users/types'; | ||
export { UserStatusOverview } from './userStatusOverview/types'; | ||
export * from './enums'; | ||
export { PagingParams } from './utils/params/pagingParams'; | ||
export { RequestParams } from './utils/params/requestParams'; | ||
export { PagingParams } from './utils/params/pagingParams'; | ||
export { Response } from './utils/response/response'; | ||
@@ -49,0 +50,0 @@ export default class Api { |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PagingParams = exports.RequestParams = void 0; | ||
exports.RequestParams = exports.PagingParams = exports.UserStatusOverviewStatus = exports.AbsenceStatus = exports.AbsenceDurationUnit = exports.AbsenceDayType = void 0; | ||
const absenceDays_1 = require("./absenceDays"); | ||
@@ -22,2 +22,3 @@ const absences_1 = require("./absences"); | ||
const favouriteTasks_1 = require("./favouriteTasks"); | ||
const generalSettings_1 = require("./generalSettings"); | ||
const projects_1 = require("./projects"); | ||
@@ -34,11 +35,17 @@ const recentTasks_1 = require("./recentTasks"); | ||
const userStatusOverview_1 = require("./userStatusOverview"); | ||
const generalSettings_1 = require("./generalSettings"); | ||
const axiosSetup_1 = require("./utils/axiosSetup"); | ||
__exportStar(require("./enums"), exports); | ||
var enums_1 = require("./enums"); | ||
Object.defineProperty(exports, "AbsenceDayType", { enumerable: true, get: function () { return enums_1.AbsenceDayType; } }); | ||
Object.defineProperty(exports, "AbsenceDurationUnit", { enumerable: true, get: function () { return enums_1.AbsenceDurationUnit; } }); | ||
Object.defineProperty(exports, "AbsenceStatus", { enumerable: true, get: function () { return enums_1.AbsenceStatus; } }); | ||
Object.defineProperty(exports, "UserStatusOverviewStatus", { enumerable: true, get: function () { return enums_1.UserStatusOverviewStatus; } }); | ||
var pagingParams_1 = require("./utils/params/pagingParams"); | ||
Object.defineProperty(exports, "PagingParams", { enumerable: true, get: function () { return pagingParams_1.PagingParams; } }); | ||
var requestParams_1 = require("./utils/params/requestParams"); | ||
Object.defineProperty(exports, "RequestParams", { enumerable: true, get: function () { return requestParams_1.RequestParams; } }); | ||
var pagingParams_1 = require("./utils/params/pagingParams"); | ||
Object.defineProperty(exports, "PagingParams", { enumerable: true, get: function () { return pagingParams_1.PagingParams; } }); | ||
const DEFAULT_HOST = 'go.timetac.com'; | ||
class Api { | ||
constructor(config) { | ||
var _a; | ||
this.config = config; | ||
@@ -68,3 +75,4 @@ this.config.autoRefreshToken = config.autoRefreshToken || true; | ||
this.userStatusOverviews = new userStatusOverview_1.UserStatusOverviewsEndpoint(this.config); | ||
axiosSetup_1.default({ state: this.state, config: this.config, authentication: this.authentication }); | ||
axiosSetup_1.interceptor({ state: this.state, config: this.config, authentication: this.authentication }); | ||
axiosSetup_1.setAxiosDefaults({ baseURL: `https://${(_a = this.config.host) !== null && _a !== void 0 ? _a : DEFAULT_HOST}/` }); | ||
} | ||
@@ -71,0 +79,0 @@ setAccount(account) { |
import BaseApi from '../baseApi'; | ||
import { RequestParams } from '../utils/params/requestParams'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
import { Project } from './types'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
export declare class ProjectsEndpoint extends BaseApi { | ||
@@ -6,0 +6,0 @@ readonly resourceName = "projects"; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const baseApi_1 = require("../baseApi"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
const responseHandlers = require("../utils/response/responseHandlers"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
class RecentTasksEndpoint extends baseApi_1.default { | ||
@@ -9,0 +9,0 @@ constructor() { |
import BaseApi from '../baseApi'; | ||
import { PagingParams } from '../utils/params/pagingParams'; | ||
import { RequestParams } from '../utils/params/requestParams'; | ||
import { Response } from '../utils/response/response'; | ||
import { Task } from './types'; | ||
import { PagingParams } from '../utils/params/pagingParams'; | ||
import { Response } from '../utils/response/response'; | ||
export declare class TasksEndpoint extends BaseApi { | ||
@@ -7,0 +7,0 @@ readonly resourceName = "tasks"; |
@@ -6,4 +6,4 @@ "use strict"; | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
const response_1 = require("../utils/response/response"); | ||
const responseHandlers = require("../utils/response/responseHandlers"); | ||
const response_1 = require("../utils/response/response"); | ||
class TasksEndpoint extends baseApi_1.default { | ||
@@ -10,0 +10,0 @@ constructor() { |
import BaseApi from '../baseApi'; | ||
import { RequestParams } from '../utils/params/requestParams'; | ||
import { TimeTracking, TimeTrackingCreate, StartTimeTrackingData, StopTimeTrackingData } from './types'; | ||
import { StartTimeTrackingData, StopTimeTrackingData, TimeTracking, TimeTrackingCreate } from './types'; | ||
export declare class TimeTrackingsEndpoint extends BaseApi { | ||
@@ -5,0 +5,0 @@ readonly resourceName = "timeTrackings"; |
@@ -5,4 +5,4 @@ "use strict"; | ||
const baseApi_1 = require("../baseApi"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
const responseHandlers = require("../utils/response/responseHandlers"); | ||
const requestParams_1 = require("../utils/params/requestParams"); | ||
class TodoTasksEndpoint extends baseApi_1.default { | ||
@@ -9,0 +9,0 @@ constructor() { |
import BaseApi from '../baseApi'; | ||
import { RequestParams } from '../utils/params/requestParams'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
import { User } from './types'; | ||
import { ApiResponseOnSuccess } from '../utils/response/apiResponse'; | ||
export declare class UsersEndpoint extends BaseApi { | ||
@@ -6,0 +6,0 @@ readonly resourceName = "users"; |
@@ -0,3 +1,3 @@ | ||
import { AuthenticationEndpoint } from '../authentication'; | ||
import { ApiConfig, ApiState } from '../baseApi'; | ||
import { AuthenticationEndpoint } from '../authentication'; | ||
declare type interceptorParams = { | ||
@@ -8,3 +8,4 @@ state: ApiState; | ||
}; | ||
declare const interceptor: (apiInstanceData: interceptorParams) => void; | ||
export default interceptor; | ||
export declare const interceptor: (apiInstanceData: interceptorParams) => void; | ||
export declare const setAxiosDefaults: (defaults: object) => void; | ||
export {}; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.setAxiosDefaults = exports.interceptor = void 0; | ||
const axios_1 = require("axios"); | ||
@@ -24,3 +25,3 @@ const interceptor = (apiInstanceData) => { | ||
} | ||
return error; | ||
throw error; | ||
} | ||
@@ -33,2 +34,3 @@ if (error.response.status === 401 && !untouchedRequest._retry) { | ||
const res = yield apiInstanceData.state.refreshingToken; | ||
apiInstanceData.state.refreshingToken = false; | ||
if (res.status === 200 && res.data.access_token) { | ||
@@ -43,9 +45,15 @@ const { access_token: accessToken, refresh_token: refreshToken } = res.data; | ||
} | ||
else if (apiInstanceData.config.onTokenRefreshedFailed) { | ||
apiInstanceData.config.onTokenRefreshedFailed(); | ||
} | ||
} | ||
return Promise.reject(error.response); | ||
} | ||
return error.response; | ||
throw error.response || error; | ||
})); | ||
}; | ||
exports.default = interceptor; | ||
exports.interceptor = interceptor; | ||
const setAxiosDefaults = (defaults) => { | ||
axios_1.default.defaults = Object.assign(Object.assign({}, axios_1.default.defaults), defaults); | ||
}; | ||
exports.setAxiosDefaults = setAxiosDefaults; | ||
//# sourceMappingURL=axiosSetup.js.map |
@@ -0,3 +1,3 @@ | ||
import { ApiResponseOnSuccess } from '../response/apiResponse'; | ||
import { RequestParams } from './requestParams'; | ||
import { ApiResponseOnSuccess } from '../response/apiResponse'; | ||
export declare class PagingParams<T extends Object> extends RequestParams<T> { | ||
@@ -4,0 +4,0 @@ private readonly valid; |
@@ -15,3 +15,7 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const apiResponse = (yield promise).data; | ||
const resolved = yield promise; | ||
if (resolved === undefined) { | ||
throw new Error('Promise resolve is undefined, please contact administrator.'); | ||
} | ||
const apiResponse = resolved.data; | ||
if (apiResponse.Success) { | ||
@@ -18,0 +22,0 @@ return apiResponse; |
{ | ||
"name": "@timetac/js-client-library", | ||
"version": "0.2.4", | ||
"version": "0.2.6", | ||
"description": "TimeTac API JS client library", | ||
@@ -30,2 +30,3 @@ "homepage": "https://github.com/TimeTac/js-client-library#readme", | ||
"lint": "eslint --max-warnings=0 --ext .ts,.tsx,.js,.jsx src", | ||
"lintfix": "eslint --max-warnings=0 --ext .ts,.tsx,.js,.jsx src --fix", | ||
"prettycheck": "prettier -c 'src/**/*.{ts,js,css,html}'", | ||
@@ -52,2 +53,3 @@ "prettyfix": "prettier --write 'src/**/*.{ts,js,css,html}'", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-simple-import-sort": "^7.0.0", | ||
"husky": "^4.3.6", | ||
@@ -54,0 +56,0 @@ "jest": "^26.6.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157221
2229
14