@shipfox/api-agent-access-dto 20.3.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 +1 -1
- package/.turbo/turbo-type.log +1 -0
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -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/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +19 -0
- package/src/schemas/diagnostic-tools.ts +266 -0
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
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,
|
|
@@ -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;
|