Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@timetac/js-client-library

Package Overview
Dependencies
Maintainers
2
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@timetac/js-client-library - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

src/generalSettings/generalSettings.test.ts

2

package.json
{
"name": "@timetac/js-client-library",
"version": "0.1.1",
"version": "0.1.2",
"description": "TimeTac API JS client library",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/TimeTac/js-client-library#readme",

@@ -87,3 +87,3 @@ # TimeTac Client Library

- [ ] generalSettingsChangeLog
- [ ] generalSettings
- [x] generalSettings
- [ ] geofences

@@ -90,0 +90,0 @@ - [ ] geofenceToNodes

@@ -40,3 +40,3 @@ import AbsenceDays from './index';

mock.onGet(readPath, { params: { user_id: '1', _op__user_id: 'eq' } }).reply(200, { Success: true, NumResults: 1, Results: [{}] });
result = absenceDays.read(new RequestParams<AbsenceDay>().eq('user_id', '1'));
result = absenceDays.read(new RequestParams<AbsenceDay>().eq('user_id', 1));
await result.then((result) => expect(result).toStrictEqual([{}]));

@@ -49,3 +49,3 @@

.reply(200, { Success: true, NumResults: 1, Results: [{}] });
result = absenceDays.read(new RequestParams<AbsenceDay>().eq('user_id', '1').gteq('date', '2020-01-01'));
result = absenceDays.read(new RequestParams<AbsenceDay>().eq('user_id', 1).gteq('date', '2020-01-01'));
await result.then((result) => expect(result).toStrictEqual([{}]));

@@ -52,0 +52,0 @@ });

@@ -0,6 +1,14 @@

export enum AbsenceStatus {
Open,
Granted,
Declined,
Cancelled,
OpenWaitingForReplacement = 5,
}
export type Absence = {
id?: number;
type_id?: number;
subtype_id?: number;
user_id?: number;
id: number;
type_id: number;
subtype_id: number;
user_id: number;
/**

@@ -20,4 +28,4 @@ * The user replacement for this request.

request_user_role_id?: number;
created?: string;
status?: number;
created: string;
status: AbsenceStatus;
granted_user_id?: number;

@@ -28,5 +36,5 @@ granted_as_substitute_user_id?: number;

granted_comment?: string;
from_date?: string;
to_date?: string;
duration?: number;
from_date: string;
to_date: string;
duration: number;
/**

@@ -40,3 +48,3 @@ * If the request ends with a partial day, the value of the last partial day.

request_partial_end_duration?: number;
duration_unit?: string;
duration_unit: 'd' | 'hs';
begin?: string;

@@ -56,3 +64,5 @@ substitute_enabled?: boolean;

chain_level?: number;
updated?: string;
updated: string;
};
export interface AbsenceCreate extends Omit<Absence, 'id' | 'created' | 'status' | 'duration' | 'duration_unit' | 'updated'> {}

@@ -5,31 +5,31 @@ export type AbsenceType = {

*/
id?: number;
id: number;
/**
* Id of the absence type.
*/
absence_type_id?: number;
absence_type_id: number;
/**
* Id of the sub absence (other paid leaves).
*/
absence_subtype_id?: number;
absence_subtype_id: number;
/**
* Group of the absence defined in pm_absece_groups.
*/
absence_group_id?: number;
absence_group_id: number;
/**
* Sort order in views.
*/
sort_order?: number;
sort_order: number;
/**
* Absence name.
*/
name_const?: string;
name_const: string;
/**
* Absence abbrevation constant.
*/
abbreviation_const?: string;
abbreviation_const: string;
/**
* If the absence is shown in the selection for user.
*/
show_in_selection?: boolean;
show_in_selection: boolean;
/**

@@ -42,3 +42,3 @@ * The task_id of pm_tasks_subprojects which will be used to automatically create timestamps based on the absence.

*/
enabled_for_requests?: boolean;
enabled_for_requests: boolean;
/**

@@ -79,3 +79,3 @@ * If the leave should be added to working hours.

*/
duration_unit?: string;
duration_unit: 'd' | 'hs';
/**

@@ -104,3 +104,3 @@ * Whether the user limitation config is enabled for this absence.

*/
color?: string;
color: string;
/**

@@ -128,1 +128,3 @@ * If there is a country restriction for this other paid leave. The limitations are defined in pm_working_hour_other_paid_leave_to_countries.

};
export interface AbsenceTypeCreate extends Omit<AbsenceType, 'id'> {}

@@ -20,3 +20,3 @@ import BaseApi from '../baseApi';

...map,
_includes: resources.join(','),
_include: resources.join(','),
},

@@ -23,0 +23,0 @@ });

@@ -5,2 +5,4 @@ import { User } from '../users/types';

import { TimeTracking } from '../timetrackings/types';
import { AbsenceType } from '..';
import { GeneralSetting } from '../generalSettings/types';

@@ -12,2 +14,4 @@ export type SyncData = {

timeTrackings: TimeTracking[];
absenceTypes: AbsenceType[];
generalSettings: GeneralSetting[];
};

@@ -14,0 +18,0 @@

import { ApiConfig } from './baseApi';
import { Credentials } from './authentication/types';
import RequestParams from './utils/requestParams';

@@ -19,5 +20,6 @@ import AbsenceDays from './absenceDays';

import UserStatusOverviews from './userStatusOverview';
import GeneralSettings from './generalSettings';
export { AbsenceDay } from './absenceDays/types';
export { Absence } from './absences/types';
export { Absence, AbsenceStatus } from './absences/types';
export { AbsenceType } from './absenceTypes/types';

@@ -27,2 +29,3 @@ export { Credentials } from './authentication/types';

export { Department } from './departments/types';
export { GeneralSetting } from './generalSettings/types';
export { Project } from './projects/types';

@@ -36,4 +39,4 @@ export { ServerCommunication } from './serverCommunication/types';

export { User } from './users/types';
export { UserStatusOverview } from './userStatusOverview/types';
export * from './utils/requestParams';
export * from './userStatusOverview/types';
export { RequestParams };

@@ -49,2 +52,3 @@ export default class Api {

public departments: Departments;
public generalSettings: GeneralSettings;
public projects: Projects;

@@ -69,2 +73,3 @@ public serverCommunication: ServerCommunication;

this.departments = new Departments(this.config);
this.generalSettings = new GeneralSettings(this.config);
this.projects = new Projects(this.config);

@@ -71,0 +76,0 @@ this.serverCommunication = new ServerCommunication(this.config);

@@ -32,2 +32,8 @@ import TimeTrackings from './index';

test('read with RequestParmas', async () => {
mock.onGet(readPath, { params: { id: '99', _op__id: 'eq' } }).reply(200, { Success: true, NumResults: 1, Results: [{}] });
result = timeTrackings.read(new RequestParams<TimeTracking>().eq('id', 99));
await result.then((result) => expect(result).toStrictEqual([{}]));
});
test('read with Success false', async () => {

@@ -34,0 +40,0 @@ mock.onGet(readPath).reply(200, { Success: false });

@@ -0,26 +1,37 @@

export enum UserStatusOverviewStatus {
Offline,
Working,
Break,
Leave,
CoreTimeViolation = 5,
}
export type UserStatusOverview = {
user_id?: number;
user_id: number;
/**
* Time tracking id of a running task
*/
time_tracking_id?: number;
time_tracking_start_time?: string;
time_tracking_start_time_timezone_id?: string;
time_tracking_task_id?: number;
time_tracking_is_nonworking?: boolean;
time_tracking_id: number;
time_tracking_start_time: string | null;
time_tracking_start_time_timezone_id: string | null;
time_tracking_task_id: number;
time_tracking_is_nonworking: boolean | null;
/**
* 1 if there is core time violation, default 0
*/
core_time_violation?: boolean;
core_time_start?: string;
updated?: string;
is_running?: boolean;
core_time_violation: boolean;
core_time_start: string;
updated: string;
is_running: boolean;
/**
* Current absence ids
*/
current_absence_ids?: string;
current_absence_ids: string | null;
/**
* Represents current status of users activity if he is offline (0), working(1),break(2),on leave(3), core time violation (5)
*/
status?: number;
status: UserStatusOverviewStatus;
profile_picture: string;
user_fullname: string;
alert_maximum_timer_violation?: boolean;
};

@@ -19,3 +19,3 @@ import RequestParams from './requestParams';

test('single eq', () => {
const requestParams = new RequestParams<Resource>().eq('id', '1');
const requestParams = new RequestParams<Resource>().eq('id', 1);
expect(requestParams.getParams()).toStrictEqual({ id: '1', _op__id: 'eq' });

@@ -25,3 +25,3 @@ });

test('double eq', () => {
const requestParams = new RequestParams<Resource>().eq('id', '1').eq('user_id', '2');
const requestParams = new RequestParams<Resource>().eq('id', 1).eq('user_id', 2);
expect(requestParams.getParams()).toStrictEqual({ id: '1', _op__id: 'eq', user_id: '2', _op__user_id: 'eq' });

@@ -41,3 +41,3 @@ });

test('between', () => {
const requestParams = new RequestParams<Resource>().between('status', '1', '3');
const requestParams = new RequestParams<Resource>().between('status', 1, 3);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'betw', status: '1|3' });

@@ -47,3 +47,3 @@ });

test('gt', () => {
const requestParams = new RequestParams<Resource>().gt('status', '1');
const requestParams = new RequestParams<Resource>().gt('status', 1);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'gt', status: '1' });

@@ -53,3 +53,3 @@ });

test('gteq', () => {
const requestParams = new RequestParams<Resource>().gteq('status', '1');
const requestParams = new RequestParams<Resource>().gteq('status', 1);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'gteq', status: '1' });

@@ -59,3 +59,3 @@ });

test('lt', () => {
const requestParams = new RequestParams<Resource>().lt('status', '5');
const requestParams = new RequestParams<Resource>().lt('status', 5);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'lt', status: '5' });

@@ -65,3 +65,3 @@ });

test('lteq', () => {
const requestParams = new RequestParams<Resource>().lteq('status', '5');
const requestParams = new RequestParams<Resource>().lteq('status', 5);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'lteq', status: '5' });

@@ -71,3 +71,3 @@ });

test('in', () => {
const requestParams = new RequestParams<Resource>().in('status', '5', '3');
const requestParams = new RequestParams<Resource>().in('status', 5, 3);
expect(requestParams.getParams()).toStrictEqual({ _op__status: 'in', status: '5|3' });

@@ -74,0 +74,0 @@ });

@@ -19,39 +19,39 @@ export default class RequestParams<R extends Object> {

eq<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
eq<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'eq';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
gt<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
gt<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'gt';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
gteq<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
gteq<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'gteq';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
lt<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
lt<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'lt';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
lteq<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
lteq<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'lteq';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
like<F extends keyof R & string>(field: F, value: string): RequestParams<R> {
like<F extends keyof R & string>(field: F, value: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'like';
this.criteria[field] = value;
this.criteria[field] = String(value);
return this;
}
in<F extends keyof R & string>(field: F, ...values: string[]): RequestParams<R> {
in<F extends keyof R & string>(field: F, ...values: Array<R[F]>): RequestParams<R> {
this.criteria[`_op__${field}`] = 'in';

@@ -62,3 +62,3 @@ this.criteria[field] = values.join('|');

between<F extends keyof R & string>(field: F, min: String, max: string): RequestParams<R> {
between<F extends keyof R & string>(field: F, min: R[F], max: R[F]): RequestParams<R> {
this.criteria[`_op__${field}`] = 'betw';

@@ -65,0 +65,0 @@ this.criteria[field] = [min, max].join('|');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc