@shipfox/api-agent-access-dto 20.2.0 → 21.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.
- package/.turbo/turbo-build.log +2 -0
- package/.turbo/turbo-type$colon$emit.log +1 -0
- package/.turbo/turbo-type.log +2 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/schemas/diagnostic-tools.d.ts +322 -0
- package/dist/schemas/diagnostic-tools.d.ts.map +1 -0
- package/dist/schemas/diagnostic-tools.js +330 -0
- package/dist/schemas/diagnostic-tools.js.map +1 -0
- package/dist/schemas/paged-tools.d.ts +774 -0
- package/dist/schemas/paged-tools.d.ts.map +1 -0
- package/dist/schemas/paged-tools.js +915 -0
- package/dist/schemas/paged-tools.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +23 -13
- package/src/index.ts +61 -0
- package/src/schemas/diagnostic-tools.ts +266 -0
- package/src/schemas/paged-tools.test.ts +106 -0
- package/src/schemas/paged-tools.ts +684 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-agent-access-dto",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "21.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -11,25 +11,35 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#test/*": "./test/*",
|
|
16
|
+
"#*": {
|
|
17
|
+
"workspace-source": "./src/*",
|
|
18
|
+
"default": "./dist/*"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
14
21
|
"exports": {
|
|
15
22
|
".": {
|
|
16
|
-
"
|
|
17
|
-
|
|
23
|
+
"workspace-source": {
|
|
24
|
+
"types": "./src/index.ts",
|
|
25
|
+
"default": "./src/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
32
|
},
|
|
20
33
|
"dependencies": {
|
|
21
34
|
"zod": "^4.4.3"
|
|
22
35
|
},
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"kind": "dto",
|
|
31
|
-
"context": "agent-access"
|
|
32
|
-
}
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@shipfox/biome": "1.10.1",
|
|
38
|
+
"@shipfox/depcruise": "1.0.5",
|
|
39
|
+
"@shipfox/swc": "1.2.8",
|
|
40
|
+
"@shipfox/ts-config": "1.3.9",
|
|
41
|
+
"@shipfox/typescript": "1.1.10",
|
|
42
|
+
"@shipfox/vitest": "1.2.6"
|
|
33
43
|
},
|
|
34
44
|
"scripts": {
|
|
35
45
|
"build": "shipfox-swc",
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
export {
|
|
2
|
+
AGENT_ACCESS_FACET_MAX_ITEMS,
|
|
3
|
+
AGENT_ACCESS_FACET_VALUE_MAX_BYTES,
|
|
4
|
+
AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES,
|
|
5
|
+
AGENT_ACCESS_TRIGGER_DECISION_MAX_ITEMS,
|
|
6
|
+
AGENT_ACCESS_TRIGGER_REPLAY_MAX_ITEMS,
|
|
7
|
+
type GetTriggerEventFacetsInputDto,
|
|
8
|
+
type GetTriggerEventFacetsResultDto,
|
|
9
|
+
type GetTriggerEventInputDto,
|
|
10
|
+
type GetTriggerEventResultDto,
|
|
11
|
+
getTriggerEventFacetsInputJsonSchema,
|
|
12
|
+
getTriggerEventFacetsInputSchema,
|
|
13
|
+
getTriggerEventFacetsResultJsonSchema,
|
|
14
|
+
getTriggerEventFacetsResultSchema,
|
|
15
|
+
getTriggerEventInputJsonSchema,
|
|
16
|
+
getTriggerEventInputSchema,
|
|
17
|
+
getTriggerEventResultJsonSchema,
|
|
18
|
+
getTriggerEventResultSchema,
|
|
19
|
+
} from './schemas/diagnostic-tools.js';
|
|
1
20
|
export {
|
|
2
21
|
AGENT_ACCESS_ERROR_CODE_MAX_LENGTH,
|
|
3
22
|
AGENT_ACCESS_ERROR_MESSAGE_MAX_LENGTH,
|
|
@@ -10,3 +29,45 @@ export {
|
|
|
10
29
|
agentAccessErrorSchema,
|
|
11
30
|
agentAccessOutputSchema,
|
|
12
31
|
} from './schemas/envelope.js';
|
|
32
|
+
export {
|
|
33
|
+
AGENT_ACCESS_ANNOTATION_BODY_MAX_BYTES,
|
|
34
|
+
AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES,
|
|
35
|
+
AGENT_ACCESS_DEFAULT_PAGE_LIMIT,
|
|
36
|
+
AGENT_ACCESS_DIAGNOSTIC_CODE_MAX_BYTES,
|
|
37
|
+
AGENT_ACCESS_DIAGNOSTIC_MAX_ITEMS,
|
|
38
|
+
AGENT_ACCESS_DIAGNOSTIC_MESSAGE_MAX_BYTES,
|
|
39
|
+
AGENT_ACCESS_DIAGNOSTIC_PATH_MAX_BYTES,
|
|
40
|
+
AGENT_ACCESS_PAGE_LIMIT_MAX,
|
|
41
|
+
AGENT_ACCESS_RESPONSE_MAX_BYTES,
|
|
42
|
+
AGENT_ACCESS_TEXT_MAX_BYTES,
|
|
43
|
+
type GetRunAnnotationsInputDto,
|
|
44
|
+
type GetRunAnnotationsResultDto,
|
|
45
|
+
getRunAnnotationsInputJsonSchema,
|
|
46
|
+
getRunAnnotationsInputSchema,
|
|
47
|
+
getRunAnnotationsResultJsonSchema,
|
|
48
|
+
getRunAnnotationsResultSchema,
|
|
49
|
+
type ListProjectsInputDto,
|
|
50
|
+
type ListProjectsResultDto,
|
|
51
|
+
type ListTriggerEventsInputDto,
|
|
52
|
+
type ListTriggerEventsResultDto,
|
|
53
|
+
type ListWorkflowDefinitionsInputDto,
|
|
54
|
+
type ListWorkflowDefinitionsResultDto,
|
|
55
|
+
type ListWorkflowRunsInputDto,
|
|
56
|
+
type ListWorkflowRunsResultDto,
|
|
57
|
+
listProjectsInputJsonSchema,
|
|
58
|
+
listProjectsInputSchema,
|
|
59
|
+
listProjectsResultJsonSchema,
|
|
60
|
+
listProjectsResultSchema,
|
|
61
|
+
listTriggerEventsInputJsonSchema,
|
|
62
|
+
listTriggerEventsInputSchema,
|
|
63
|
+
listTriggerEventsResultJsonSchema,
|
|
64
|
+
listTriggerEventsResultSchema,
|
|
65
|
+
listWorkflowDefinitionsInputJsonSchema,
|
|
66
|
+
listWorkflowDefinitionsInputSchema,
|
|
67
|
+
listWorkflowDefinitionsResultJsonSchema,
|
|
68
|
+
listWorkflowDefinitionsResultSchema,
|
|
69
|
+
listWorkflowRunsInputJsonSchema,
|
|
70
|
+
listWorkflowRunsInputSchema,
|
|
71
|
+
listWorkflowRunsResultJsonSchema,
|
|
72
|
+
listWorkflowRunsResultSchema,
|
|
73
|
+
} from './schemas/paged-tools.js';
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import type {AgentAccessObjectSchema} from './envelope.js';
|
|
3
|
+
import {
|
|
4
|
+
AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES,
|
|
5
|
+
AGENT_ACCESS_TEXT_MAX_BYTES,
|
|
6
|
+
} from './paged-tools.js';
|
|
7
|
+
|
|
8
|
+
export const AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES = 16 * 1024;
|
|
9
|
+
export const AGENT_ACCESS_TRIGGER_DECISION_MAX_ITEMS = 50;
|
|
10
|
+
export const AGENT_ACCESS_TRIGGER_REPLAY_MAX_ITEMS = 20;
|
|
11
|
+
export const AGENT_ACCESS_FACET_MAX_ITEMS = 50;
|
|
12
|
+
export const AGENT_ACCESS_FACET_VALUE_MAX_BYTES = 256;
|
|
13
|
+
|
|
14
|
+
const idSchema = z.string().uuid();
|
|
15
|
+
const dateTimeSchema = z.string().datetime();
|
|
16
|
+
const utf8Encoder = new TextEncoder();
|
|
17
|
+
|
|
18
|
+
const utf8CappedString = (maxBytes: number) =>
|
|
19
|
+
z
|
|
20
|
+
.string()
|
|
21
|
+
.max(maxBytes)
|
|
22
|
+
.refine((value) => utf8Encoder.encode(value).byteLength <= maxBytes, {
|
|
23
|
+
message: `String must contain at most ${maxBytes} UTF-8 bytes`,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const textSchema = utf8CappedString(AGENT_ACCESS_TEXT_MAX_BYTES);
|
|
27
|
+
const shortTextSchema = utf8CappedString(AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES);
|
|
28
|
+
const serializedJsonSchema = utf8CappedString(AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES).refine(
|
|
29
|
+
isSerializedJson,
|
|
30
|
+
{message: 'String must contain valid serialized JSON'},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const getTriggerEventInputSchema = z.object({event_id: idSchema}).strict();
|
|
34
|
+
|
|
35
|
+
export const getTriggerEventFacetsInputSchema = z.object({}).strict();
|
|
36
|
+
|
|
37
|
+
export type GetTriggerEventInputDto = z.infer<typeof getTriggerEventInputSchema>;
|
|
38
|
+
export type GetTriggerEventFacetsInputDto = z.infer<typeof getTriggerEventFacetsInputSchema>;
|
|
39
|
+
|
|
40
|
+
const triggerOriginSchema = z.enum(['integration', 'manual', 'cron', 'dev']);
|
|
41
|
+
const triggerOutcomeSchema = z.enum(['received', 'routed', 'discarded', 'failed', 'errored']);
|
|
42
|
+
const triggerDecisionOutcomeSchema = z.enum(['triggered', 'filter-error', 'dispatch-error']);
|
|
43
|
+
const triggerDecisionSchema = z
|
|
44
|
+
.object({
|
|
45
|
+
id: idSchema,
|
|
46
|
+
subscription_kind: z.enum(['trigger', 'listener', 'dev']),
|
|
47
|
+
outcome: triggerDecisionOutcomeSchema,
|
|
48
|
+
reason: textSchema.nullable(),
|
|
49
|
+
workflow_definition_id: idSchema.nullable(),
|
|
50
|
+
project_id: idSchema.nullable(),
|
|
51
|
+
workflow_run_id: idSchema.nullable(),
|
|
52
|
+
job_id: idSchema.nullable(),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
55
|
+
|
|
56
|
+
const triggerReplaySchema = z
|
|
57
|
+
.object({
|
|
58
|
+
id: idSchema,
|
|
59
|
+
workflow_run_id: idSchema.nullable(),
|
|
60
|
+
created_at: dateTimeSchema,
|
|
61
|
+
})
|
|
62
|
+
.strict();
|
|
63
|
+
|
|
64
|
+
export const getTriggerEventResultSchema = z
|
|
65
|
+
.object({
|
|
66
|
+
id: idSchema,
|
|
67
|
+
origin: triggerOriginSchema,
|
|
68
|
+
provider: textSchema.nullable(),
|
|
69
|
+
source: textSchema,
|
|
70
|
+
event: textSchema,
|
|
71
|
+
outcome: triggerOutcomeSchema,
|
|
72
|
+
matched_count: z.number().int().nonnegative(),
|
|
73
|
+
connection_id: idSchema.nullable(),
|
|
74
|
+
connection_name: shortTextSchema.nullable(),
|
|
75
|
+
replay_of_event_id: idSchema.nullable(),
|
|
76
|
+
received_at: dateTimeSchema,
|
|
77
|
+
processed_at: dateTimeSchema.nullable(),
|
|
78
|
+
payload_preview: serializedJsonSchema,
|
|
79
|
+
payload_preview_truncated: z.literal(true).optional(),
|
|
80
|
+
payload_preview_total_bytes: z.number().int().nonnegative().optional(),
|
|
81
|
+
decisions: z.array(triggerDecisionSchema).max(AGENT_ACCESS_TRIGGER_DECISION_MAX_ITEMS),
|
|
82
|
+
decisions_truncated: z.literal(true).optional(),
|
|
83
|
+
decisions_total_count: z.number().int().nonnegative(),
|
|
84
|
+
replays: z.array(triggerReplaySchema).max(AGENT_ACCESS_TRIGGER_REPLAY_MAX_ITEMS),
|
|
85
|
+
replays_truncated: z.literal(true).optional(),
|
|
86
|
+
replays_total_count: z.number().int().nonnegative(),
|
|
87
|
+
})
|
|
88
|
+
.strict();
|
|
89
|
+
|
|
90
|
+
const facetSchema = z
|
|
91
|
+
.object({
|
|
92
|
+
value: utf8CappedString(AGENT_ACCESS_FACET_VALUE_MAX_BYTES),
|
|
93
|
+
count: z.number().int().nonnegative(),
|
|
94
|
+
})
|
|
95
|
+
.strict();
|
|
96
|
+
|
|
97
|
+
export const getTriggerEventFacetsResultSchema = z
|
|
98
|
+
.object({
|
|
99
|
+
sources: z.array(facetSchema).max(AGENT_ACCESS_FACET_MAX_ITEMS),
|
|
100
|
+
events: z.array(facetSchema).max(AGENT_ACCESS_FACET_MAX_ITEMS),
|
|
101
|
+
origins: z.array(facetSchema).max(AGENT_ACCESS_FACET_MAX_ITEMS),
|
|
102
|
+
})
|
|
103
|
+
.strict();
|
|
104
|
+
|
|
105
|
+
export type GetTriggerEventResultDto = z.infer<typeof getTriggerEventResultSchema>;
|
|
106
|
+
export type GetTriggerEventFacetsResultDto = z.infer<typeof getTriggerEventFacetsResultSchema>;
|
|
107
|
+
|
|
108
|
+
const uuid = {type: 'string', format: 'uuid'} as const;
|
|
109
|
+
const dateTime = {type: 'string', format: 'date-time'} as const;
|
|
110
|
+
const text = {type: 'string', maxLength: AGENT_ACCESS_TEXT_MAX_BYTES} as const;
|
|
111
|
+
const shortText = {
|
|
112
|
+
type: 'string',
|
|
113
|
+
maxLength: AGENT_ACCESS_CONNECTION_NAME_MAX_BYTES,
|
|
114
|
+
} as const;
|
|
115
|
+
const serializedJson = {
|
|
116
|
+
type: 'string',
|
|
117
|
+
maxLength: AGENT_ACCESS_SERIALIZED_JSON_MAX_BYTES,
|
|
118
|
+
contentMediaType: 'application/json',
|
|
119
|
+
} as const;
|
|
120
|
+
const nullable = (schema: Record<string, unknown>) => ({anyOf: [schema, {type: 'null'}]}) as const;
|
|
121
|
+
|
|
122
|
+
export const getTriggerEventInputJsonSchema = {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {event_id: uuid},
|
|
125
|
+
required: ['event_id'],
|
|
126
|
+
additionalProperties: false,
|
|
127
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
128
|
+
|
|
129
|
+
function isSerializedJson(value: string): boolean {
|
|
130
|
+
try {
|
|
131
|
+
JSON.parse(value);
|
|
132
|
+
return true;
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export const getTriggerEventFacetsInputJsonSchema = {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {},
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
143
|
+
|
|
144
|
+
const triggerDecisionJsonSchema = {
|
|
145
|
+
type: 'object',
|
|
146
|
+
properties: {
|
|
147
|
+
id: uuid,
|
|
148
|
+
subscription_kind: {type: 'string', enum: ['trigger', 'listener', 'dev']},
|
|
149
|
+
outcome: {type: 'string', enum: ['triggered', 'filter-error', 'dispatch-error']},
|
|
150
|
+
reason: nullable(text),
|
|
151
|
+
workflow_definition_id: nullable(uuid),
|
|
152
|
+
project_id: nullable(uuid),
|
|
153
|
+
workflow_run_id: nullable(uuid),
|
|
154
|
+
job_id: nullable(uuid),
|
|
155
|
+
},
|
|
156
|
+
required: [
|
|
157
|
+
'id',
|
|
158
|
+
'subscription_kind',
|
|
159
|
+
'outcome',
|
|
160
|
+
'reason',
|
|
161
|
+
'workflow_definition_id',
|
|
162
|
+
'project_id',
|
|
163
|
+
'workflow_run_id',
|
|
164
|
+
'job_id',
|
|
165
|
+
],
|
|
166
|
+
additionalProperties: false,
|
|
167
|
+
} as const;
|
|
168
|
+
|
|
169
|
+
const triggerReplayJsonSchema = {
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: {
|
|
172
|
+
id: uuid,
|
|
173
|
+
workflow_run_id: nullable(uuid),
|
|
174
|
+
created_at: dateTime,
|
|
175
|
+
},
|
|
176
|
+
required: ['id', 'workflow_run_id', 'created_at'],
|
|
177
|
+
additionalProperties: false,
|
|
178
|
+
} as const;
|
|
179
|
+
|
|
180
|
+
export const getTriggerEventResultJsonSchema = {
|
|
181
|
+
type: 'object',
|
|
182
|
+
properties: {
|
|
183
|
+
id: uuid,
|
|
184
|
+
origin: {type: 'string', enum: ['integration', 'manual', 'cron', 'dev']},
|
|
185
|
+
provider: nullable(text),
|
|
186
|
+
source: text,
|
|
187
|
+
event: text,
|
|
188
|
+
outcome: {type: 'string', enum: ['received', 'routed', 'discarded', 'failed', 'errored']},
|
|
189
|
+
matched_count: {type: 'integer', minimum: 0},
|
|
190
|
+
connection_id: nullable(uuid),
|
|
191
|
+
connection_name: nullable(shortText),
|
|
192
|
+
replay_of_event_id: nullable(uuid),
|
|
193
|
+
received_at: dateTime,
|
|
194
|
+
processed_at: nullable(dateTime),
|
|
195
|
+
payload_preview: serializedJson,
|
|
196
|
+
payload_preview_truncated: {const: true},
|
|
197
|
+
payload_preview_total_bytes: {type: 'integer', minimum: 0},
|
|
198
|
+
decisions: {
|
|
199
|
+
type: 'array',
|
|
200
|
+
maxItems: AGENT_ACCESS_TRIGGER_DECISION_MAX_ITEMS,
|
|
201
|
+
items: triggerDecisionJsonSchema,
|
|
202
|
+
},
|
|
203
|
+
decisions_truncated: {const: true},
|
|
204
|
+
decisions_total_count: {type: 'integer', minimum: 0},
|
|
205
|
+
replays: {
|
|
206
|
+
type: 'array',
|
|
207
|
+
maxItems: AGENT_ACCESS_TRIGGER_REPLAY_MAX_ITEMS,
|
|
208
|
+
items: triggerReplayJsonSchema,
|
|
209
|
+
},
|
|
210
|
+
replays_truncated: {const: true},
|
|
211
|
+
replays_total_count: {type: 'integer', minimum: 0},
|
|
212
|
+
},
|
|
213
|
+
required: [
|
|
214
|
+
'id',
|
|
215
|
+
'origin',
|
|
216
|
+
'provider',
|
|
217
|
+
'source',
|
|
218
|
+
'event',
|
|
219
|
+
'outcome',
|
|
220
|
+
'matched_count',
|
|
221
|
+
'connection_id',
|
|
222
|
+
'connection_name',
|
|
223
|
+
'replay_of_event_id',
|
|
224
|
+
'received_at',
|
|
225
|
+
'processed_at',
|
|
226
|
+
'payload_preview',
|
|
227
|
+
'decisions',
|
|
228
|
+
'decisions_total_count',
|
|
229
|
+
'replays',
|
|
230
|
+
'replays_total_count',
|
|
231
|
+
],
|
|
232
|
+
additionalProperties: false,
|
|
233
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
234
|
+
|
|
235
|
+
const facetJsonSchema = {
|
|
236
|
+
type: 'object',
|
|
237
|
+
properties: {
|
|
238
|
+
value: {type: 'string', maxLength: AGENT_ACCESS_FACET_VALUE_MAX_BYTES},
|
|
239
|
+
count: {type: 'integer', minimum: 0},
|
|
240
|
+
},
|
|
241
|
+
required: ['value', 'count'],
|
|
242
|
+
additionalProperties: false,
|
|
243
|
+
} as const;
|
|
244
|
+
|
|
245
|
+
export const getTriggerEventFacetsResultJsonSchema = {
|
|
246
|
+
type: 'object',
|
|
247
|
+
properties: {
|
|
248
|
+
sources: {
|
|
249
|
+
type: 'array',
|
|
250
|
+
maxItems: AGENT_ACCESS_FACET_MAX_ITEMS,
|
|
251
|
+
items: facetJsonSchema,
|
|
252
|
+
},
|
|
253
|
+
events: {
|
|
254
|
+
type: 'array',
|
|
255
|
+
maxItems: AGENT_ACCESS_FACET_MAX_ITEMS,
|
|
256
|
+
items: facetJsonSchema,
|
|
257
|
+
},
|
|
258
|
+
origins: {
|
|
259
|
+
type: 'array',
|
|
260
|
+
maxItems: AGENT_ACCESS_FACET_MAX_ITEMS,
|
|
261
|
+
items: facetJsonSchema,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
required: ['sources', 'events', 'origins'],
|
|
265
|
+
additionalProperties: false,
|
|
266
|
+
} as const satisfies AgentAccessObjectSchema;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AGENT_ACCESS_DEFAULT_PAGE_LIMIT,
|
|
3
|
+
getRunAnnotationsInputSchema,
|
|
4
|
+
getRunAnnotationsResultSchema,
|
|
5
|
+
listProjectsInputSchema,
|
|
6
|
+
listProjectsResultJsonSchema,
|
|
7
|
+
listProjectsResultSchema,
|
|
8
|
+
listTriggerEventsInputSchema,
|
|
9
|
+
listWorkflowDefinitionsResultSchema,
|
|
10
|
+
listWorkflowRunsInputSchema,
|
|
11
|
+
} from './paged-tools.js';
|
|
12
|
+
|
|
13
|
+
const projectId = '00000000-0000-4000-8000-000000000001';
|
|
14
|
+
|
|
15
|
+
describe('paged agent-access schemas', () => {
|
|
16
|
+
test('defaults page size and rejects gateway-owned workspace arguments', () => {
|
|
17
|
+
expect(listProjectsInputSchema.parse({})).toEqual({limit: AGENT_ACCESS_DEFAULT_PAGE_LIMIT});
|
|
18
|
+
expect(listProjectsInputSchema.safeParse({workspace_id: projectId}).success).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('validates date windows and strict list filters', () => {
|
|
22
|
+
expect(
|
|
23
|
+
listWorkflowRunsInputSchema.safeParse({
|
|
24
|
+
project_id: projectId,
|
|
25
|
+
created_from: '2026-08-02T00:00:00.000Z',
|
|
26
|
+
created_to: '2026-08-01T00:00:00.000Z',
|
|
27
|
+
}).success,
|
|
28
|
+
).toBe(false);
|
|
29
|
+
expect(listTriggerEventsInputSchema.safeParse({source: ['push'], extra: true}).success).toBe(
|
|
30
|
+
false,
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('keeps output schemas as one strict object envelope result', () => {
|
|
35
|
+
expect(listProjectsResultJsonSchema).not.toHaveProperty('oneOf');
|
|
36
|
+
expect(listProjectsResultJsonSchema.properties.projects).toBeDefined();
|
|
37
|
+
expect(listProjectsResultSchema.safeParse({projects: [], next_cursor: null}).success).toBe(
|
|
38
|
+
true,
|
|
39
|
+
);
|
|
40
|
+
expect(
|
|
41
|
+
listProjectsResultSchema.safeParse({projects: [], next_cursor: null, workspace_id: projectId})
|
|
42
|
+
.success,
|
|
43
|
+
).toBe(false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('requires annotation body truncation metadata to remain a boolean marker and byte count', () => {
|
|
47
|
+
const valid = {
|
|
48
|
+
id: projectId,
|
|
49
|
+
origin_step_id: '00000000-0000-4000-8000-000000000002',
|
|
50
|
+
origin_step_attempt: 1,
|
|
51
|
+
job_execution_id: '00000000-0000-4000-8000-000000000003',
|
|
52
|
+
sequence: 1,
|
|
53
|
+
created_at: '2026-08-01T00:00:00.000Z',
|
|
54
|
+
body: 'body',
|
|
55
|
+
};
|
|
56
|
+
expect(
|
|
57
|
+
getRunAnnotationsResultSchema.safeParse({annotations: [valid], next_cursor: null}).success,
|
|
58
|
+
).toBe(true);
|
|
59
|
+
const truncated = {...valid, body_truncated: true, body_total_bytes: 8_192};
|
|
60
|
+
expect(
|
|
61
|
+
getRunAnnotationsResultSchema.safeParse({
|
|
62
|
+
annotations: [truncated],
|
|
63
|
+
next_cursor: null,
|
|
64
|
+
}).success,
|
|
65
|
+
).toBe(true);
|
|
66
|
+
expect(
|
|
67
|
+
getRunAnnotationsResultSchema.safeParse({
|
|
68
|
+
annotations: [{...truncated, body_truncated: false}],
|
|
69
|
+
next_cursor: null,
|
|
70
|
+
}).success,
|
|
71
|
+
).toBe(false);
|
|
72
|
+
expect(
|
|
73
|
+
getRunAnnotationsResultSchema.safeParse({
|
|
74
|
+
annotations: [{...truncated, body_total_bytes: '8192'}],
|
|
75
|
+
next_cursor: null,
|
|
76
|
+
}).success,
|
|
77
|
+
).toBe(false);
|
|
78
|
+
expect(getRunAnnotationsInputSchema.safeParse({run_id: projectId, attempt: 0}).success).toBe(
|
|
79
|
+
false,
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('keeps definition sync error codes aligned with the producer enum', () => {
|
|
84
|
+
const sync = {
|
|
85
|
+
ref: null,
|
|
86
|
+
status: 'failed' as const,
|
|
87
|
+
last_sync_at: '2026-08-01T00:00:00.000Z',
|
|
88
|
+
started_at: null,
|
|
89
|
+
finished_at: '2026-08-01T00:00:00.000Z',
|
|
90
|
+
last_error_code: 'provider-timeout',
|
|
91
|
+
last_error_message: 'timed out',
|
|
92
|
+
diagnostics: {error_count: 0, warning_count: 0, items: []},
|
|
93
|
+
};
|
|
94
|
+
expect(
|
|
95
|
+
listWorkflowDefinitionsResultSchema.safeParse({definitions: [], sync, next_cursor: null})
|
|
96
|
+
.success,
|
|
97
|
+
).toBe(true);
|
|
98
|
+
expect(
|
|
99
|
+
listWorkflowDefinitionsResultSchema.safeParse({
|
|
100
|
+
definitions: [],
|
|
101
|
+
sync: {...sync, last_error_code: 'untrusted-instruction'},
|
|
102
|
+
next_cursor: null,
|
|
103
|
+
}).success,
|
|
104
|
+
).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
});
|