@t4dhg/mcp-factorial 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,241 @@
1
+ /**
2
+ * Zod schemas for runtime validation of API responses
3
+ *
4
+ * Catches API version mismatches and ensures type safety at runtime.
5
+ */
6
+ import { z } from 'zod';
7
+ import { SchemaValidationError } from './errors.js';
8
+ /**
9
+ * Employee schema
10
+ */
11
+ export const EmployeeSchema = z.object({
12
+ id: z.number(),
13
+ first_name: z.string().nullable(),
14
+ last_name: z.string().nullable(),
15
+ full_name: z.string().nullable(),
16
+ email: z.string().nullable(),
17
+ birthday_on: z.string().nullable(),
18
+ hired_on: z.string().nullable(),
19
+ start_date: z.string().nullable(),
20
+ terminated_on: z.string().nullable(),
21
+ gender: z.string().nullable(),
22
+ nationality: z.string().nullable(),
23
+ manager_id: z.number().nullable(),
24
+ role: z.string().nullable(),
25
+ timeoff_manager_id: z.number().nullable(),
26
+ company_id: z.number().nullable(),
27
+ legal_entity_id: z.number().nullable(),
28
+ team_ids: z.array(z.number()).default([]),
29
+ location_id: z.number().nullable(),
30
+ created_at: z.string().nullable(),
31
+ updated_at: z.string().nullable(),
32
+ });
33
+ /**
34
+ * Team schema
35
+ */
36
+ export const TeamSchema = z.object({
37
+ id: z.number(),
38
+ name: z.string(),
39
+ description: z.string().nullable(),
40
+ company_id: z.number().nullable(),
41
+ employee_ids: z.array(z.number()).default([]),
42
+ lead_ids: z.array(z.number()).default([]),
43
+ created_at: z.string().nullable(),
44
+ updated_at: z.string().nullable(),
45
+ });
46
+ /**
47
+ * Location schema
48
+ */
49
+ export const LocationSchema = z.object({
50
+ id: z.number(),
51
+ name: z.string(),
52
+ country: z.string().nullable(),
53
+ phone_number: z.string().nullable(),
54
+ state: z.string().nullable(),
55
+ city: z.string().nullable(),
56
+ address_line_1: z.string().nullable(),
57
+ address_line_2: z.string().nullable(),
58
+ postal_code: z.string().nullable(),
59
+ company_id: z.number().nullable(),
60
+ created_at: z.string().nullable(),
61
+ updated_at: z.string().nullable(),
62
+ });
63
+ /**
64
+ * Contract schema
65
+ */
66
+ export const ContractSchema = z.object({
67
+ id: z.number(),
68
+ employee_id: z.number(),
69
+ job_title: z.string().nullable(),
70
+ effective_on: z.string().nullable(),
71
+ created_at: z.string().nullable(),
72
+ updated_at: z.string().nullable(),
73
+ });
74
+ /**
75
+ * Leave schema
76
+ */
77
+ export const LeaveSchema = z.object({
78
+ id: z.number(),
79
+ employee_id: z.number(),
80
+ leave_type_id: z.number(),
81
+ start_on: z.string(),
82
+ finish_on: z.string(),
83
+ half_day: z.enum(['all_day', 'start', 'finish']).nullable(),
84
+ status: z.enum(['pending', 'approved', 'declined']),
85
+ description: z.string().nullable(),
86
+ deleted_at: z.string().nullable(),
87
+ duration_attributes: z
88
+ .object({
89
+ days: z.number(),
90
+ hours: z.number(),
91
+ })
92
+ .nullable(),
93
+ created_at: z.string().nullable(),
94
+ updated_at: z.string().nullable(),
95
+ });
96
+ /**
97
+ * Leave type schema
98
+ */
99
+ export const LeaveTypeSchema = z.object({
100
+ id: z.number(),
101
+ name: z.string(),
102
+ code: z.string().nullable(),
103
+ color: z.string().nullable(),
104
+ description: z.string().nullable(),
105
+ company_id: z.number().nullable(),
106
+ created_at: z.string().nullable(),
107
+ updated_at: z.string().nullable(),
108
+ });
109
+ /**
110
+ * Allowance schema
111
+ */
112
+ export const AllowanceSchema = z.object({
113
+ id: z.number(),
114
+ employee_id: z.number(),
115
+ leave_type_id: z.number(),
116
+ policy_id: z.number().nullable(),
117
+ balance_days: z.number(),
118
+ consumed_days: z.number(),
119
+ available_days: z.number(),
120
+ valid_from: z.string().nullable(),
121
+ valid_to: z.string().nullable(),
122
+ created_at: z.string().nullable(),
123
+ updated_at: z.string().nullable(),
124
+ });
125
+ /**
126
+ * Shift schema
127
+ */
128
+ export const ShiftSchema = z.object({
129
+ id: z.number(),
130
+ employee_id: z.number(),
131
+ clock_in: z.string(),
132
+ clock_out: z.string().nullable(),
133
+ worked_hours: z.number().nullable(),
134
+ break_minutes: z.number().nullable(),
135
+ location: z.string().nullable(),
136
+ notes: z.string().nullable(),
137
+ created_at: z.string().nullable(),
138
+ updated_at: z.string().nullable(),
139
+ });
140
+ /**
141
+ * Folder schema
142
+ */
143
+ export const FolderSchema = z.object({
144
+ id: z.number(),
145
+ name: z.string(),
146
+ parent_id: z.number().nullable(),
147
+ company_id: z.number().nullable(),
148
+ created_at: z.string().nullable(),
149
+ updated_at: z.string().nullable(),
150
+ });
151
+ /**
152
+ * Document schema
153
+ */
154
+ export const DocumentSchema = z.object({
155
+ id: z.number(),
156
+ name: z.string(),
157
+ folder_id: z.number().nullable(),
158
+ author_id: z.number().nullable(),
159
+ company_id: z.number().nullable(),
160
+ public: z.boolean().default(false),
161
+ space: z.string().nullable(),
162
+ file_url: z.string().nullable(),
163
+ mime_type: z.string().nullable(),
164
+ size_bytes: z.number().nullable(),
165
+ created_at: z.string().nullable(),
166
+ updated_at: z.string().nullable(),
167
+ });
168
+ /**
169
+ * Job role schema
170
+ */
171
+ export const JobRoleSchema = z.object({
172
+ id: z.number(),
173
+ name: z.string(),
174
+ description: z.string().nullable(),
175
+ company_id: z.number().nullable(),
176
+ created_at: z.string().nullable(),
177
+ updated_at: z.string().nullable(),
178
+ });
179
+ /**
180
+ * Job level schema
181
+ */
182
+ export const JobLevelSchema = z.object({
183
+ id: z.number(),
184
+ name: z.string(),
185
+ description: z.string().nullable(),
186
+ company_id: z.number().nullable(),
187
+ created_at: z.string().nullable(),
188
+ updated_at: z.string().nullable(),
189
+ });
190
+ /**
191
+ * API response wrapper schema
192
+ */
193
+ export function createApiResponseSchema(dataSchema) {
194
+ return z.object({
195
+ data: dataSchema,
196
+ });
197
+ }
198
+ /**
199
+ * API list response wrapper schema
200
+ */
201
+ export function createApiListResponseSchema(itemSchema) {
202
+ return z.object({
203
+ data: z.array(itemSchema),
204
+ });
205
+ }
206
+ /**
207
+ * Parse and validate data against a schema
208
+ * @throws SchemaValidationError if validation fails
209
+ */
210
+ export function parseData(schemaName, schema, data) {
211
+ const result = schema.safeParse(data);
212
+ if (!result.success) {
213
+ const issues = result.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join(', ');
214
+ throw new SchemaValidationError(schemaName, issues, { data });
215
+ }
216
+ return result.data;
217
+ }
218
+ /**
219
+ * Safely parse data without throwing (returns undefined on failure)
220
+ */
221
+ export function safeParseData(schema, data) {
222
+ const result = schema.safeParse(data);
223
+ return result.success ? result.data : undefined;
224
+ }
225
+ /**
226
+ * Parse an array of items against a schema
227
+ */
228
+ export function parseArray(schemaName, itemSchema, data) {
229
+ if (!Array.isArray(data)) {
230
+ throw new SchemaValidationError(schemaName, 'Expected an array', { data });
231
+ }
232
+ return data.map((item, index) => {
233
+ const result = itemSchema.safeParse(item);
234
+ if (!result.success) {
235
+ const issues = result.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join(', ');
236
+ throw new SchemaValidationError(`${schemaName}[${index}]`, issues, { item });
237
+ }
238
+ return result.data;
239
+ });
240
+ }
241
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAA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S,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAI,UAAkB,EAAE,UAA0B,EAAE,IAAa;IACzF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,qBAAqB,CAAC,UAAU,EAAE,mBAAmB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5F,MAAM,IAAI,qBAAqB,CAAC,GAAG,UAAU,IAAI,KAAK,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,57 +1,68 @@
1
- export interface Employee {
2
- id: number;
3
- first_name: string;
4
- last_name: string;
5
- full_name: string;
6
- email: string;
7
- birthday_on: string | null;
8
- hired_on: string | null;
9
- start_date: string | null;
10
- terminated_on: string | null;
11
- gender: string | null;
12
- nationality: string | null;
13
- manager_id: number | null;
14
- role: string | null;
15
- timeoff_manager_id: number | null;
16
- company_id: number;
17
- legal_entity_id: number | null;
18
- team_ids: number[];
19
- location_id: number | null;
20
- created_at: string;
21
- updated_at: string;
1
+ /**
2
+ * TypeScript types for MCP FactorialHR
3
+ *
4
+ * Re-exports types from schemas for backward compatibility
5
+ * and adds additional utility types.
6
+ */
7
+ export type { Employee, Team, Location, Contract, Leave, LeaveType, Allowance, Shift, Folder, Document, JobRole, JobLevel, } from './schemas.js';
8
+ export type { PaginationInput, PaginationParams, PaginationMeta, PaginatedResponse, } from './pagination.js';
9
+ /**
10
+ * Leave status options
11
+ */
12
+ export type LeaveStatus = 'pending' | 'approved' | 'declined';
13
+ /**
14
+ * Half day options
15
+ */
16
+ export type HalfDay = 'all_day' | 'start' | 'finish';
17
+ /**
18
+ * Options for listing employees
19
+ */
20
+ export interface ListEmployeesOptions {
21
+ team_id?: number;
22
+ location_id?: number;
23
+ page?: number;
24
+ limit?: number;
22
25
  }
23
- export interface Team {
24
- id: number;
25
- name: string;
26
- description: string | null;
27
- company_id: number;
28
- employee_ids: number[];
29
- lead_ids: number[];
30
- created_at: string;
31
- updated_at: string;
26
+ /**
27
+ * Options for listing leaves
28
+ */
29
+ export interface ListLeavesOptions {
30
+ employee_id?: number;
31
+ status?: LeaveStatus;
32
+ start_on_gte?: string;
33
+ start_on_lte?: string;
34
+ page?: number;
35
+ limit?: number;
32
36
  }
33
- export interface Location {
34
- id: number;
35
- name: string;
36
- country: string | null;
37
- phone_number: string | null;
38
- state: string | null;
39
- city: string | null;
40
- address_line_1: string | null;
41
- address_line_2: string | null;
42
- postal_code: string | null;
43
- company_id: number;
44
- created_at: string;
45
- updated_at: string;
37
+ /**
38
+ * Options for listing allowances
39
+ */
40
+ export interface ListAllowancesOptions {
41
+ employee_id?: number;
42
+ page?: number;
43
+ limit?: number;
46
44
  }
47
- export interface Contract {
48
- id: number;
49
- employee_id: number;
50
- job_title: string | null;
51
- effective_on: string;
52
- created_at: string;
53
- updated_at: string;
45
+ /**
46
+ * Options for listing shifts
47
+ */
48
+ export interface ListShiftsOptions {
49
+ employee_id?: number;
50
+ clock_in_gte?: string;
51
+ clock_in_lte?: string;
52
+ page?: number;
53
+ limit?: number;
54
54
  }
55
+ /**
56
+ * Options for listing documents
57
+ */
58
+ export interface ListDocumentsOptions {
59
+ folder_id?: number;
60
+ page?: number;
61
+ limit?: number;
62
+ }
63
+ /**
64
+ * Legacy ApiError type (for backward compatibility)
65
+ */
55
66
  export interface ApiError {
56
67
  error: string;
57
68
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,M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AAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB"}
package/dist/types.js CHANGED
@@ -1,3 +1,8 @@
1
- // FactorialHR API Response Types
1
+ /**
2
+ * TypeScript types for MCP FactorialHR
3
+ *
4
+ * Re-exports types from schemas for backward compatibility
5
+ * and adds additional utility types.
6
+ */
2
7
  export {};
3
8
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,iCAAiC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t4dhg/mcp-factorial",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "description": "MCP server for FactorialHR - Access employee and organizational data from FactorialHR in Claude Code and other MCP clients",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,29 @@
20
20
  "scripts": {
21
21
  "build": "tsc",
22
22
  "start": "node dist/index.js",
23
- "dev": "tsc --watch"
23
+ "dev": "tsc --watch",
24
+ "clean": "rm -rf dist coverage .vitest",
25
+ "rebuild": "npm run clean && npm run build",
26
+ "test": "vitest run",
27
+ "test:watch": "vitest",
28
+ "test:coverage": "vitest run --coverage",
29
+ "test:ui": "vitest --ui",
30
+ "lint": "eslint src --ext .ts",
31
+ "lint:fix": "eslint src --ext .ts --fix",
32
+ "format": "prettier --write \"src/**/*.ts\" \"*.json\" \"*.md\"",
33
+ "format:check": "prettier --check \"src/**/*.ts\" \"*.json\" \"*.md\"",
34
+ "typecheck": "tsc --noEmit",
35
+ "prepublishOnly": "npm run test && npm run build",
36
+ "prepare": "husky"
37
+ },
38
+ "lint-staged": {
39
+ "src/**/*.ts": [
40
+ "eslint --fix",
41
+ "prettier --write"
42
+ ],
43
+ "*.{json,md}": [
44
+ "prettier --write"
45
+ ]
24
46
  },
25
47
  "keywords": [
26
48
  "mcp",
@@ -29,22 +51,37 @@
29
51
  "factorialhr",
30
52
  "hr",
31
53
  "claude",
32
- "anthropic"
54
+ "anthropic",
55
+ "ai",
56
+ "llm"
33
57
  ],
34
- "author": "t4dhg",
58
+ "author": "Taig Mac Carthy <https://taigmaccarthy.com/>",
35
59
  "license": "MIT",
36
60
  "repository": {
37
61
  "type": "git",
38
62
  "url": "git+https://github.com/t4dhg/mcp-factorial.git"
39
63
  },
64
+ "bugs": {
65
+ "url": "https://github.com/t4dhg/mcp-factorial/issues"
66
+ },
67
+ "homepage": "https://github.com/t4dhg/mcp-factorial#readme",
40
68
  "dependencies": {
41
69
  "@modelcontextprotocol/sdk": "^1.0.0",
42
70
  "dotenv": "^16.4.0",
43
71
  "zod": "^3.24.0"
44
72
  },
45
73
  "devDependencies": {
74
+ "@eslint/js": "^9.17.0",
46
75
  "@types/node": "^22.10.0",
47
- "typescript": "^5.7.0"
76
+ "@vitest/coverage-v8": "^2.1.8",
77
+ "@vitest/ui": "^2.1.8",
78
+ "eslint": "^9.17.0",
79
+ "husky": "^9.1.7",
80
+ "lint-staged": "^15.2.11",
81
+ "prettier": "^3.4.2",
82
+ "typescript": "^5.7.0",
83
+ "typescript-eslint": "^8.18.2",
84
+ "vitest": "^2.1.8"
48
85
  },
49
86
  "engines": {
50
87
  "node": ">=18.0.0"