@aiconnect/agentjobs-mcp 1.2.0 → 1.3.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.
- package/.env.example +4 -0
- package/README.md +39 -6
- package/build/index.js +1 -1
- package/build/test-tools.js +1 -1
- package/build/tools/get_job.js +39 -9
- package/build/tools/get_job_activities.js +68 -0
- package/build/tools/list_jobs.js +38 -4
- package/build/utils/formatters.js +218 -23
- package/build/utils/schemas.js +8 -0
- package/docs/agent-jobs-api.md +115 -0
- package/package.json +1 -1
- package/build/config.test.js +0 -22
- package/build/utils/formatters.test.js +0 -629
- package/build/utils/schemas.test.js +0 -95
- package/build/utils/version.test.js +0 -9
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
4
|
-
import { flexibleDateTimeSchema } from './schemas.js';
|
|
5
|
-
describe('flexibleDateTimeSchema', () => {
|
|
6
|
-
it('should validate a correct ISO 8601 string with Zulu time', () => {
|
|
7
|
-
const result = flexibleDateTimeSchema().safeParse('2025-07-23T21:00:00Z');
|
|
8
|
-
expect(result.success).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
it('should validate a correct ISO 8601 string with a positive offset', () => {
|
|
11
|
-
const result = flexibleDateTimeSchema().safeParse('2025-07-23T22:00:00+01:00');
|
|
12
|
-
expect(result.success).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
it('should validate a correct ISO 8601 string with a negative offset', () => {
|
|
15
|
-
const result = flexibleDateTimeSchema().safeParse('2025-07-23T16:00:00-05:00');
|
|
16
|
-
expect(result.success).toBe(true);
|
|
17
|
-
});
|
|
18
|
-
it('should not validate an incorrect date format', () => {
|
|
19
|
-
const result = flexibleDateTimeSchema().safeParse('23/07/2025 21:00:00');
|
|
20
|
-
expect(result.success).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
it('should not validate a gibberish string', () => {
|
|
23
|
-
const result = flexibleDateTimeSchema().safeParse('not-a-date');
|
|
24
|
-
expect(result.success).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
it('should not validate an empty string', () => {
|
|
27
|
-
const result = flexibleDateTimeSchema().safeParse('');
|
|
28
|
-
expect(result.success).toBe(false);
|
|
29
|
-
});
|
|
30
|
-
it('should validate a date-only string (no time component)', () => {
|
|
31
|
-
const result = flexibleDateTimeSchema().safeParse('2024-07-23');
|
|
32
|
-
expect(result.success).toBe(true);
|
|
33
|
-
});
|
|
34
|
-
it('should reject invalid string with the exact ISO 8601 error message', () => {
|
|
35
|
-
const result = flexibleDateTimeSchema().safeParse('not-a-date');
|
|
36
|
-
expect(result.success).toBe(false);
|
|
37
|
-
if (!result.success) {
|
|
38
|
-
expect(result.error.issues[0].message).toBe('Invalid date-time string. Please use a valid ISO 8601 format.');
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
it('should reject null when used with .optional() (string | undefined, not nullable)', () => {
|
|
42
|
-
const schema = flexibleDateTimeSchema().optional();
|
|
43
|
-
expect(schema.safeParse(undefined).success).toBe(true);
|
|
44
|
-
const nullResult = schema.safeParse(null);
|
|
45
|
-
expect(nullResult.success).toBe(false);
|
|
46
|
-
if (!nullResult.success) {
|
|
47
|
-
const issue = nullResult.error.issues[0];
|
|
48
|
-
expect(issue.code).toBe('invalid_type');
|
|
49
|
-
// Zod 3: { expected: 'string', received: 'null' }
|
|
50
|
-
expect(issue.expected).toBe('string');
|
|
51
|
-
expect(issue.received).toBe('null');
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe('JSON Schema serialization', () => {
|
|
56
|
-
it('should inline each list_jobs date filter field without $ref', () => {
|
|
57
|
-
const shape = z.object({
|
|
58
|
-
scheduled_at: flexibleDateTimeSchema().optional(),
|
|
59
|
-
scheduled_at_gte: flexibleDateTimeSchema().optional(),
|
|
60
|
-
scheduled_at_lte: flexibleDateTimeSchema().optional(),
|
|
61
|
-
created_at_gte: flexibleDateTimeSchema().optional(),
|
|
62
|
-
created_at_lte: flexibleDateTimeSchema().optional(),
|
|
63
|
-
});
|
|
64
|
-
const json = zodToJsonSchema(shape);
|
|
65
|
-
const expectedFields = [
|
|
66
|
-
'scheduled_at',
|
|
67
|
-
'scheduled_at_gte',
|
|
68
|
-
'scheduled_at_lte',
|
|
69
|
-
'created_at_gte',
|
|
70
|
-
'created_at_lte',
|
|
71
|
-
];
|
|
72
|
-
for (const field of expectedFields) {
|
|
73
|
-
const prop = json.properties[field];
|
|
74
|
-
expect(prop.$ref, `expected ${field} to be inline, got $ref ${String(prop.$ref)}`).toBeUndefined();
|
|
75
|
-
expect(prop.type, `expected ${field} to have type 'string', got ${String(prop.type)}`).toBe('string');
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
it('should produce $ref-free JSON for both list_jobs and get_jobs_stats shapes', () => {
|
|
79
|
-
const listJobsShape = z.object({
|
|
80
|
-
scheduled_at: flexibleDateTimeSchema().optional(),
|
|
81
|
-
scheduled_at_gte: flexibleDateTimeSchema().optional(),
|
|
82
|
-
scheduled_at_lte: flexibleDateTimeSchema().optional(),
|
|
83
|
-
created_at_gte: flexibleDateTimeSchema().optional(),
|
|
84
|
-
created_at_lte: flexibleDateTimeSchema().optional(),
|
|
85
|
-
});
|
|
86
|
-
const statsShape = z.object({
|
|
87
|
-
scheduled_at_gte: flexibleDateTimeSchema().optional(),
|
|
88
|
-
scheduled_at_lte: flexibleDateTimeSchema().optional(),
|
|
89
|
-
created_at_gte: flexibleDateTimeSchema().optional(),
|
|
90
|
-
created_at_lte: flexibleDateTimeSchema().optional(),
|
|
91
|
-
});
|
|
92
|
-
expect(JSON.stringify(zodToJsonSchema(listJobsShape))).not.toContain('$ref');
|
|
93
|
-
expect(JSON.stringify(zodToJsonSchema(statsShape))).not.toContain('$ref');
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { mcpServerVersion } from './version.js';
|
|
3
|
-
describe('mcpServerVersion', () => {
|
|
4
|
-
it('resolves to a non-empty string from package.json in dev tree', () => {
|
|
5
|
-
expect(typeof mcpServerVersion).toBe('string');
|
|
6
|
-
expect(mcpServerVersion.length).toBeGreaterThan(0);
|
|
7
|
-
expect(mcpServerVersion).not.toBe('unknown');
|
|
8
|
-
});
|
|
9
|
-
});
|