@shipfox/api-runners-dto 9.0.2 → 10.2.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/CHANGELOG.md +23 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inter-module.d.ts +12 -0
- package/dist/inter-module.d.ts.map +1 -1
- package/dist/inter-module.js +12 -0
- package/dist/inter-module.js.map +1 -1
- package/dist/schemas/admin-provisioner-token.d.ts +110 -0
- package/dist/schemas/admin-provisioner-token.d.ts.map +1 -0
- package/dist/schemas/admin-provisioner-token.js +54 -0
- package/dist/schemas/admin-provisioner-token.js.map +1 -0
- package/dist/schemas/admin-runner-instances.d.ts +139 -0
- package/dist/schemas/admin-runner-instances.d.ts.map +1 -0
- package/dist/schemas/admin-runner-instances.js +62 -0
- package/dist/schemas/admin-runner-instances.js.map +1 -0
- package/dist/schemas/index.d.ts +3 -1
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +3 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/poll-demand.js +1 -1
- package/dist/schemas/poll-demand.js.map +1 -1
- package/dist/schemas/runner-enrollment.d.ts +10 -0
- package/dist/schemas/runner-enrollment.d.ts.map +1 -1
- package/dist/schemas/runner-enrollment.js +11 -2
- package/dist/schemas/runner-enrollment.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/index.ts +31 -0
- package/src/inter-module.ts +12 -0
- package/src/schemas/admin-provisioner-token.ts +94 -0
- package/src/schemas/admin-runner-instances.ts +76 -0
- package/src/schemas/index.ts +35 -0
- package/src/schemas/poll-demand.test.ts +29 -1
- package/src/schemas/poll-demand.ts +1 -1
- package/src/schemas/report-runner-instances.test.ts +18 -0
- package/src/schemas/runner-enrollment.test.ts +52 -0
- package/src/schemas/runner-enrollment.ts +19 -2
- package/tsconfig.build.tsbuildinfo +1 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,16 +3,20 @@ export {
|
|
|
3
3
|
type ActiveRunnerDto,
|
|
4
4
|
type ActiveRunnerStateDto,
|
|
5
5
|
type ActiveRunnersResponseDto,
|
|
6
|
+
type AdministratorProvisionerTokenDto,
|
|
6
7
|
type AssignRunnerInstancesBodyDto,
|
|
7
8
|
type AssignRunnerInstancesResponseDto,
|
|
8
9
|
activeProvisionerDtoSchema,
|
|
9
10
|
activeRunnerDtoSchema,
|
|
10
11
|
activeRunnerStateSchema,
|
|
11
12
|
activeRunnersResponseSchema,
|
|
13
|
+
administratorProvisionerTokenSchema,
|
|
12
14
|
assignRunnerInstancesBodySchema,
|
|
13
15
|
assignRunnerInstancesResponseSchema,
|
|
14
16
|
attachRunnerControlProviderIdBodySchema,
|
|
15
17
|
type ClaimedJobResponseDto,
|
|
18
|
+
type CreateAdministratorProvisionerTokenBodyDto,
|
|
19
|
+
type CreateAdministratorProvisionerTokenResponseDto,
|
|
16
20
|
type CreateManualRegistrationTokenBodyDto,
|
|
17
21
|
type CreateManualRegistrationTokenResponseDto,
|
|
18
22
|
type CreateProvisionerTokenBodyDto,
|
|
@@ -20,6 +24,8 @@ export {
|
|
|
20
24
|
type CreateRunnerInstancesBodyDto,
|
|
21
25
|
type CreateRunnerInstancesResponseDto,
|
|
22
26
|
claimedJobResponseSchema,
|
|
27
|
+
createAdministratorProvisionerTokenBodySchema,
|
|
28
|
+
createAdministratorProvisionerTokenResponseSchema,
|
|
23
29
|
createManualRegistrationTokenBodySchema,
|
|
24
30
|
createManualRegistrationTokenResponseSchema,
|
|
25
31
|
createProvisionerTokenBodySchema,
|
|
@@ -32,12 +38,22 @@ export {
|
|
|
32
38
|
type HeartbeatResponseDto,
|
|
33
39
|
heartbeatBodySchema,
|
|
34
40
|
heartbeatResponseSchema,
|
|
41
|
+
type InstallationProvisionerTokenStatus,
|
|
42
|
+
installationProvisionerTokenStatusSchema,
|
|
35
43
|
type ListActiveProvisionersResponseDto,
|
|
44
|
+
type ListAdministratorProvisionerTokensQueryDto,
|
|
45
|
+
type ListAdministratorProvisionerTokensResponseDto,
|
|
36
46
|
type ListManualRegistrationTokensResponseDto,
|
|
37
47
|
type ListProvisionerTokensResponseDto,
|
|
48
|
+
type ListRunnerAdministratorInstancesQueryDto,
|
|
49
|
+
type ListRunnerAdministratorInstancesResponseDto,
|
|
38
50
|
listActiveProvisionersResponseSchema,
|
|
51
|
+
listAdministratorProvisionerTokensQuerySchema,
|
|
52
|
+
listAdministratorProvisionerTokensResponseSchema,
|
|
39
53
|
listManualRegistrationTokensResponseSchema,
|
|
40
54
|
listProvisionerTokensResponseSchema,
|
|
55
|
+
listRunnerAdministratorInstancesQuerySchema,
|
|
56
|
+
listRunnerAdministratorInstancesResponseSchema,
|
|
41
57
|
MAX_MANUAL_REGISTRATION_TOKEN_TTL_SECONDS,
|
|
42
58
|
MAX_OBSERVED_PROVIDER_RUNNER_ID_LENGTH,
|
|
43
59
|
MAX_PROVIDER_KIND_LENGTH,
|
|
@@ -70,12 +86,18 @@ export {
|
|
|
70
86
|
type ReportRunnerInstancesBodyDto,
|
|
71
87
|
type ReportRunnerInstancesResponseDto,
|
|
72
88
|
type ReservationGrantDto,
|
|
89
|
+
type RevokeAdministratorProvisionerTokenBodyDto,
|
|
90
|
+
type RevokeAdministratorProvisionerTokenResponseDto,
|
|
73
91
|
type RevokeManualRegistrationTokenResponseDto,
|
|
74
92
|
type RevokeProvisionerTokenResponseDto,
|
|
93
|
+
RUNNER_ASSIGNMENT_POLL_DEFAULT_WAIT_SECONDS,
|
|
75
94
|
RUNNER_SESSION_EXHAUSTED_CODE,
|
|
95
|
+
type RunnerAdministratorInstanceDto,
|
|
96
|
+
type RunnerAssignmentPollQueryDto,
|
|
76
97
|
type RunnerBootstrapExchangeBodyDto,
|
|
77
98
|
type RunnerBootstrapExchangeResponseDto,
|
|
78
99
|
type RunnerEnrollmentBodyDto,
|
|
100
|
+
type RunnerEnrollmentResponseDto,
|
|
79
101
|
type RunnerHarnessToolCapabilitiesDto,
|
|
80
102
|
type RunnerInstanceReportEventDto,
|
|
81
103
|
type RunnerInstanceStateDto,
|
|
@@ -90,13 +112,22 @@ export {
|
|
|
90
112
|
reportRunnerInstancesBodySchema,
|
|
91
113
|
reportRunnerInstancesResponseSchema,
|
|
92
114
|
reservationGrantSchema,
|
|
115
|
+
revokeAdministratorProvisionerTokenBodySchema,
|
|
116
|
+
revokeAdministratorProvisionerTokenResponseSchema,
|
|
93
117
|
revokeManualRegistrationTokenResponseSchema,
|
|
94
118
|
revokeProvisionerTokenResponseSchema,
|
|
119
|
+
runnerAdministratorAssignmentPresenceSchema,
|
|
120
|
+
runnerAdministratorEnrollmentStateSchema,
|
|
121
|
+
runnerAdministratorInstanceSchema,
|
|
122
|
+
runnerAdministratorLifecycleStateSchema,
|
|
123
|
+
runnerAdministratorReconciliationStatusSchema,
|
|
124
|
+
runnerAssignmentPollQuerySchema,
|
|
95
125
|
runnerAssignmentPollResponseSchema,
|
|
96
126
|
runnerBootstrapExchangeBodySchema,
|
|
97
127
|
runnerBootstrapExchangeResponseSchema,
|
|
98
128
|
runnerControlHeartbeatResponseSchema,
|
|
99
129
|
runnerEnrollmentBodySchema,
|
|
130
|
+
runnerEnrollmentResponseSchema,
|
|
100
131
|
runnerHarnessToolCapabilitiesSchema,
|
|
101
132
|
runnerToolCapabilitiesSchema,
|
|
102
133
|
} from '#schemas/index.js';
|
package/src/inter-module.ts
CHANGED
|
@@ -45,6 +45,18 @@ export const runnersInterModuleContract = defineInterModuleContract({
|
|
|
45
45
|
reportFresh: z.boolean(),
|
|
46
46
|
}),
|
|
47
47
|
},
|
|
48
|
+
getWorkspaceJobCounts: {
|
|
49
|
+
input: z.object({workspaceIds: z.array(idSchema).min(1).max(100)}),
|
|
50
|
+
output: z.object({
|
|
51
|
+
counts: z.array(
|
|
52
|
+
z.object({
|
|
53
|
+
workspaceId: idSchema,
|
|
54
|
+
queued: z.number().int().nonnegative(),
|
|
55
|
+
running: z.number().int().nonnegative(),
|
|
56
|
+
}),
|
|
57
|
+
),
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
48
60
|
},
|
|
49
61
|
});
|
|
50
62
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
import {MAX_PROVISIONER_TOKEN_TTL_SECONDS} from './provisioner-token.js';
|
|
3
|
+
|
|
4
|
+
const timestampSchema = z.string().datetime();
|
|
5
|
+
const CONTROL_OR_FORMAT_CHARACTER_RE = /[\p{Cc}\p{Cf}]/u;
|
|
6
|
+
const reasonSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(512)
|
|
10
|
+
.refine((value) => value.trim().length > 0, {
|
|
11
|
+
message: 'must not be blank',
|
|
12
|
+
})
|
|
13
|
+
.refine((value) => !CONTROL_OR_FORMAT_CHARACTER_RE.test(value), {
|
|
14
|
+
message: 'must not contain control or format characters',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const installationProvisionerTokenStatusSchema = z.enum(['active', 'expired', 'revoked']);
|
|
18
|
+
|
|
19
|
+
export type InstallationProvisionerTokenStatus = z.infer<
|
|
20
|
+
typeof installationProvisionerTokenStatusSchema
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export const administratorProvisionerTokenSchema = z.object({
|
|
24
|
+
id: z.string().uuid(),
|
|
25
|
+
scope: z.literal('installation'),
|
|
26
|
+
prefix: z.string().min(1),
|
|
27
|
+
name: z.string().nullable(),
|
|
28
|
+
status: installationProvisionerTokenStatusSchema,
|
|
29
|
+
created_by_user_id: z.string().uuid(),
|
|
30
|
+
revoked_by_user_id: z.string().uuid().nullable(),
|
|
31
|
+
expires_at: timestampSchema.nullable(),
|
|
32
|
+
revoked_at: timestampSchema.nullable(),
|
|
33
|
+
last_seen_at: timestampSchema.nullable(),
|
|
34
|
+
created_at: timestampSchema,
|
|
35
|
+
updated_at: timestampSchema,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export type AdministratorProvisionerTokenDto = z.infer<typeof administratorProvisionerTokenSchema>;
|
|
39
|
+
|
|
40
|
+
export const createAdministratorProvisionerTokenBodySchema = z.object({
|
|
41
|
+
name: z.string().min(1).max(256).optional(),
|
|
42
|
+
ttl_seconds: z.number().int().positive().max(MAX_PROVISIONER_TOKEN_TTL_SECONDS).optional(),
|
|
43
|
+
reason: reasonSchema,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type CreateAdministratorProvisionerTokenBodyDto = z.infer<
|
|
47
|
+
typeof createAdministratorProvisionerTokenBodySchema
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
export const createAdministratorProvisionerTokenResponseSchema =
|
|
51
|
+
administratorProvisionerTokenSchema.extend({
|
|
52
|
+
raw_token: z.string().min(1),
|
|
53
|
+
correlation_id: z.string().min(1).max(255),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type CreateAdministratorProvisionerTokenResponseDto = z.infer<
|
|
57
|
+
typeof createAdministratorProvisionerTokenResponseSchema
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export const listAdministratorProvisionerTokensQuerySchema = z.object({
|
|
61
|
+
status: installationProvisionerTokenStatusSchema.optional(),
|
|
62
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
63
|
+
cursor: z.string().optional(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export type ListAdministratorProvisionerTokensQueryDto = z.infer<
|
|
67
|
+
typeof listAdministratorProvisionerTokensQuerySchema
|
|
68
|
+
>;
|
|
69
|
+
|
|
70
|
+
export const listAdministratorProvisionerTokensResponseSchema = z.object({
|
|
71
|
+
tokens: z.array(administratorProvisionerTokenSchema),
|
|
72
|
+
next_cursor: z.string().nullable(),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export type ListAdministratorProvisionerTokensResponseDto = z.infer<
|
|
76
|
+
typeof listAdministratorProvisionerTokensResponseSchema
|
|
77
|
+
>;
|
|
78
|
+
|
|
79
|
+
export const revokeAdministratorProvisionerTokenBodySchema = z.object({
|
|
80
|
+
reason: reasonSchema,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type RevokeAdministratorProvisionerTokenBodyDto = z.infer<
|
|
84
|
+
typeof revokeAdministratorProvisionerTokenBodySchema
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
export const revokeAdministratorProvisionerTokenResponseSchema =
|
|
88
|
+
administratorProvisionerTokenSchema.extend({
|
|
89
|
+
correlation_id: z.string().min(1).max(255),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export type RevokeAdministratorProvisionerTokenResponseDto = z.infer<
|
|
93
|
+
typeof revokeAdministratorProvisionerTokenResponseSchema
|
|
94
|
+
>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {MAX_RUNNER_LABELS} from '@shipfox/runner-labels';
|
|
2
|
+
import {z} from 'zod';
|
|
3
|
+
import {runnerLabelSchema} from './register.js';
|
|
4
|
+
import {providerRunnerStateSchema} from './report-runner-instances.js';
|
|
5
|
+
|
|
6
|
+
export const runnerAdministratorLifecycleStateSchema = z.enum([
|
|
7
|
+
'unassigned',
|
|
8
|
+
'assigned',
|
|
9
|
+
'activated',
|
|
10
|
+
'claimed',
|
|
11
|
+
'completed',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
export const runnerAdministratorEnrollmentStateSchema = z.enum([
|
|
15
|
+
'pending',
|
|
16
|
+
'enrolled',
|
|
17
|
+
'activated',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const runnerAdministratorAssignmentPresenceSchema = z.enum(['assigned', 'unassigned']);
|
|
21
|
+
|
|
22
|
+
export const runnerAdministratorReconciliationStatusSchema = z.enum([
|
|
23
|
+
'current',
|
|
24
|
+
'stale',
|
|
25
|
+
'terminal',
|
|
26
|
+
'unknown',
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
const runnerAdministratorAssignedWorkspaceSchema = z.object({
|
|
30
|
+
id: z.string().uuid(),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const runnerAdministratorProvisionerSchema = z.object({
|
|
34
|
+
id: z.string().uuid(),
|
|
35
|
+
scope: z.literal('installation'),
|
|
36
|
+
name: z.string().nullable(),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export const runnerAdministratorInstanceSchema = z.object({
|
|
40
|
+
id: z.string().uuid(),
|
|
41
|
+
lifecycle_state: runnerAdministratorLifecycleStateSchema,
|
|
42
|
+
compute_state: providerRunnerStateSchema,
|
|
43
|
+
enrollment_state: runnerAdministratorEnrollmentStateSchema,
|
|
44
|
+
assignment_presence: runnerAdministratorAssignmentPresenceSchema,
|
|
45
|
+
assigned_workspace: runnerAdministratorAssignedWorkspaceSchema.nullable(),
|
|
46
|
+
labels: z.array(runnerLabelSchema).max(MAX_RUNNER_LABELS),
|
|
47
|
+
created_at: z.string().datetime(),
|
|
48
|
+
last_heartbeat_at: z.string().datetime(),
|
|
49
|
+
closure_reason: z.string().max(500).nullable(),
|
|
50
|
+
closed_at: z.string().datetime().nullable(),
|
|
51
|
+
provisioner: runnerAdministratorProvisionerSchema,
|
|
52
|
+
reconciliation_status: runnerAdministratorReconciliationStatusSchema,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export type RunnerAdministratorInstanceDto = z.infer<typeof runnerAdministratorInstanceSchema>;
|
|
56
|
+
|
|
57
|
+
export const listRunnerAdministratorInstancesQuerySchema = z.object({
|
|
58
|
+
state: providerRunnerStateSchema.optional(),
|
|
59
|
+
assignment: runnerAdministratorAssignmentPresenceSchema.optional(),
|
|
60
|
+
label: runnerLabelSchema.optional(),
|
|
61
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
62
|
+
cursor: z.string().optional(),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export type ListRunnerAdministratorInstancesQueryDto = z.infer<
|
|
66
|
+
typeof listRunnerAdministratorInstancesQuerySchema
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export const listRunnerAdministratorInstancesResponseSchema = z.object({
|
|
70
|
+
runners: z.array(runnerAdministratorInstanceSchema),
|
|
71
|
+
next_cursor: z.string().nullable(),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export type ListRunnerAdministratorInstancesResponseDto = z.infer<
|
|
75
|
+
typeof listRunnerAdministratorInstancesResponseSchema
|
|
76
|
+
>;
|
package/src/schemas/index.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type AdministratorProvisionerTokenDto,
|
|
3
|
+
administratorProvisionerTokenSchema,
|
|
4
|
+
type CreateAdministratorProvisionerTokenBodyDto,
|
|
5
|
+
type CreateAdministratorProvisionerTokenResponseDto,
|
|
6
|
+
createAdministratorProvisionerTokenBodySchema,
|
|
7
|
+
createAdministratorProvisionerTokenResponseSchema,
|
|
8
|
+
type InstallationProvisionerTokenStatus,
|
|
9
|
+
installationProvisionerTokenStatusSchema,
|
|
10
|
+
type ListAdministratorProvisionerTokensQueryDto,
|
|
11
|
+
type ListAdministratorProvisionerTokensResponseDto,
|
|
12
|
+
listAdministratorProvisionerTokensQuerySchema,
|
|
13
|
+
listAdministratorProvisionerTokensResponseSchema,
|
|
14
|
+
type RevokeAdministratorProvisionerTokenBodyDto,
|
|
15
|
+
type RevokeAdministratorProvisionerTokenResponseDto,
|
|
16
|
+
revokeAdministratorProvisionerTokenBodySchema,
|
|
17
|
+
revokeAdministratorProvisionerTokenResponseSchema,
|
|
18
|
+
} from './admin-provisioner-token.js';
|
|
19
|
+
export {
|
|
20
|
+
type ListRunnerAdministratorInstancesQueryDto,
|
|
21
|
+
type ListRunnerAdministratorInstancesResponseDto,
|
|
22
|
+
listRunnerAdministratorInstancesQuerySchema,
|
|
23
|
+
listRunnerAdministratorInstancesResponseSchema,
|
|
24
|
+
type RunnerAdministratorInstanceDto,
|
|
25
|
+
runnerAdministratorAssignmentPresenceSchema,
|
|
26
|
+
runnerAdministratorEnrollmentStateSchema,
|
|
27
|
+
runnerAdministratorInstanceSchema,
|
|
28
|
+
runnerAdministratorLifecycleStateSchema,
|
|
29
|
+
runnerAdministratorReconciliationStatusSchema,
|
|
30
|
+
} from './admin-runner-instances.js';
|
|
1
31
|
export {
|
|
2
32
|
type AssignRunnerInstancesBodyDto,
|
|
3
33
|
type AssignRunnerInstancesResponseDto,
|
|
@@ -108,14 +138,19 @@ export {
|
|
|
108
138
|
type CreateRunnerInstancesResponseDto,
|
|
109
139
|
createRunnerInstancesBodySchema,
|
|
110
140
|
createRunnerInstancesResponseSchema,
|
|
141
|
+
RUNNER_ASSIGNMENT_POLL_DEFAULT_WAIT_SECONDS,
|
|
142
|
+
type RunnerAssignmentPollQueryDto,
|
|
111
143
|
type RunnerBootstrapExchangeBodyDto,
|
|
112
144
|
type RunnerBootstrapExchangeResponseDto,
|
|
113
145
|
type RunnerEnrollmentBodyDto,
|
|
146
|
+
type RunnerEnrollmentResponseDto,
|
|
147
|
+
runnerAssignmentPollQuerySchema,
|
|
114
148
|
runnerAssignmentPollResponseSchema,
|
|
115
149
|
runnerBootstrapExchangeBodySchema,
|
|
116
150
|
runnerBootstrapExchangeResponseSchema,
|
|
117
151
|
runnerControlHeartbeatResponseSchema,
|
|
118
152
|
runnerEnrollmentBodySchema,
|
|
153
|
+
runnerEnrollmentResponseSchema,
|
|
119
154
|
} from './runner-enrollment.js';
|
|
120
155
|
export {
|
|
121
156
|
type RunnerHarnessToolCapabilitiesDto,
|
|
@@ -1,4 +1,32 @@
|
|
|
1
|
-
import {pollDemandResponseSchema} from './poll-demand.js';
|
|
1
|
+
import {pollDemandBodySchema, pollDemandResponseSchema} from './poll-demand.js';
|
|
2
|
+
|
|
3
|
+
const pollDemandTemplate = {
|
|
4
|
+
template_key: 'linux',
|
|
5
|
+
labels: ['linux'],
|
|
6
|
+
available_slots: 1,
|
|
7
|
+
starting: 0,
|
|
8
|
+
running: 0,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe('pollDemandBodySchema', () => {
|
|
12
|
+
it('accepts up to 1000 advertised templates', () => {
|
|
13
|
+
const result = pollDemandBodySchema.safeParse({
|
|
14
|
+
max_reservations: 0,
|
|
15
|
+
templates: Array.from({length: 1000}, () => pollDemandTemplate),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
expect(result.success).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('rejects more than 1000 advertised templates', () => {
|
|
22
|
+
const result = pollDemandBodySchema.safeParse({
|
|
23
|
+
max_reservations: 0,
|
|
24
|
+
templates: Array.from({length: 1001}, () => pollDemandTemplate),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(result.success).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
2
30
|
|
|
3
31
|
describe('pollDemandResponseSchema', () => {
|
|
4
32
|
it('requires datetime response fields to be ISO datetimes', () => {
|
|
@@ -13,7 +13,7 @@ export const pollDemandTemplateSchema = z.object({
|
|
|
13
13
|
export const pollDemandBodySchema = z.object({
|
|
14
14
|
wait_seconds: z.number().int().min(0).optional(),
|
|
15
15
|
max_reservations: z.number().int().min(0).max(1000),
|
|
16
|
-
templates: z.array(pollDemandTemplateSchema).max(
|
|
16
|
+
templates: z.array(pollDemandTemplateSchema).max(1000),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
export const demandStatSchema = z.object({
|
|
@@ -41,6 +41,24 @@ describe('providerRunnerReportEventSchema', () => {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
describe('reportRunnerInstancesBodySchema', () => {
|
|
44
|
+
it('accepts a batch at the limit', () => {
|
|
45
|
+
const event = {
|
|
46
|
+
provider_runner_id: 'container-1',
|
|
47
|
+
labels: ['linux'],
|
|
48
|
+
state: 'running',
|
|
49
|
+
reported_at: new Date().toISOString(),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const result = reportRunnerInstancesBodySchema.safeParse({
|
|
53
|
+
events: Array.from({length: MAX_PROVIDER_RUNNER_REPORT_EVENTS}, (_, index) => ({
|
|
54
|
+
...event,
|
|
55
|
+
provider_runner_id: `container-${index}`,
|
|
56
|
+
})),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(result.success).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
44
62
|
it('enforces the batch size limit', () => {
|
|
45
63
|
const event = {
|
|
46
64
|
provider_runner_id: 'container-1',
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RUNNER_ASSIGNMENT_POLL_DEFAULT_WAIT_SECONDS,
|
|
3
|
+
runnerAssignmentPollQuerySchema,
|
|
4
|
+
runnerEnrollmentBodySchema,
|
|
5
|
+
} from './runner-enrollment.js';
|
|
6
|
+
|
|
7
|
+
describe('runnerAssignmentPollQuerySchema', () => {
|
|
8
|
+
it('coerces a bounded wait from the HTTP query string', () => {
|
|
9
|
+
expect(runnerAssignmentPollQuerySchema.parse({wait_seconds: '12'})).toEqual({
|
|
10
|
+
wait_seconds: 12,
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('rejects a zero-second assignment wait', () => {
|
|
15
|
+
expect(runnerAssignmentPollQuerySchema.safeParse({wait_seconds: '0'}).success).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it.each(['-1', '1.5', 'not-a-number'])('rejects invalid wait_seconds %s', (waitSeconds) => {
|
|
19
|
+
expect(runnerAssignmentPollQuerySchema.safeParse({wait_seconds: waitSeconds}).success).toBe(
|
|
20
|
+
false,
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('keeps the protocol default explicit', () => {
|
|
26
|
+
expect(RUNNER_ASSIGNMENT_POLL_DEFAULT_WAIT_SECONDS).toBe(30);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const validEnrollment = {
|
|
30
|
+
capabilities: undefined,
|
|
31
|
+
labels: ['linux'],
|
|
32
|
+
provider_kind: 'docker',
|
|
33
|
+
protocol_version: '1',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
test('accepts the shared maximum runner label count', () => {
|
|
37
|
+
const result = runnerEnrollmentBodySchema.safeParse({
|
|
38
|
+
...validEnrollment,
|
|
39
|
+
labels: Array.from({length: 20}, (_, index) => `label-${index}`),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
expect(result.success).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('rejects runner enrollment above the shared maximum label count', () => {
|
|
46
|
+
const result = runnerEnrollmentBodySchema.safeParse({
|
|
47
|
+
...validEnrollment,
|
|
48
|
+
labels: Array.from({length: 21}, (_, index) => `label-${index}`),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(result.success).toBe(false);
|
|
52
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {MAX_RUNNER_LABELS} from '@shipfox/runner-labels';
|
|
1
2
|
import {z} from 'zod';
|
|
2
3
|
import {runnerLabelSchema} from './register.js';
|
|
3
4
|
import {runnerToolCapabilitiesSchema} from './tool-capabilities.js';
|
|
@@ -9,7 +10,14 @@ export const createRunnerInstancesBodySchema = z
|
|
|
9
10
|
.object({
|
|
10
11
|
provider_kind: z.string().min(1).max(64).optional(),
|
|
11
12
|
runner_instances: z
|
|
12
|
-
.array(
|
|
13
|
+
.array(
|
|
14
|
+
z
|
|
15
|
+
.object({
|
|
16
|
+
template_key: z.string().min(1).max(255).optional(),
|
|
17
|
+
reservation_id: z.string().uuid().optional(),
|
|
18
|
+
})
|
|
19
|
+
.strict(),
|
|
20
|
+
)
|
|
13
21
|
.min(1)
|
|
14
22
|
.max(500),
|
|
15
23
|
})
|
|
@@ -26,16 +34,23 @@ export const runnerBootstrapExchangeResponseSchema = z.object({
|
|
|
26
34
|
});
|
|
27
35
|
export const runnerEnrollmentBodySchema = z
|
|
28
36
|
.object({
|
|
29
|
-
labels: z.array(runnerLabelSchema).min(1).max(
|
|
37
|
+
labels: z.array(runnerLabelSchema).min(1).max(MAX_RUNNER_LABELS),
|
|
30
38
|
capabilities: runnerToolCapabilitiesSchema.optional(),
|
|
31
39
|
provider_kind: z.string().min(1).max(64),
|
|
32
40
|
protocol_version: z.string().min(1).max(64),
|
|
33
41
|
})
|
|
34
42
|
.strict();
|
|
43
|
+
export const runnerEnrollmentResponseSchema = z.object({
|
|
44
|
+
activation_token: z.string().min(1).nullable(),
|
|
45
|
+
});
|
|
35
46
|
export const attachRunnerControlProviderIdBodySchema = z
|
|
36
47
|
.object({provider_runner_id: z.string().min(1).max(255)})
|
|
37
48
|
.strict();
|
|
38
49
|
export const runnerControlHeartbeatResponseSchema = z.object({ok: z.literal(true)});
|
|
50
|
+
export const RUNNER_ASSIGNMENT_POLL_DEFAULT_WAIT_SECONDS = 30;
|
|
51
|
+
export const runnerAssignmentPollQuerySchema = z
|
|
52
|
+
.object({wait_seconds: z.coerce.number().int().min(1).optional()})
|
|
53
|
+
.strict();
|
|
39
54
|
export const runnerAssignmentPollResponseSchema = z.object({
|
|
40
55
|
activation_token: z.string().min(1).nullable(),
|
|
41
56
|
});
|
|
@@ -47,3 +62,5 @@ export type RunnerBootstrapExchangeResponseDto = z.infer<
|
|
|
47
62
|
typeof runnerBootstrapExchangeResponseSchema
|
|
48
63
|
>;
|
|
49
64
|
export type RunnerEnrollmentBodyDto = z.infer<typeof runnerEnrollmentBodySchema>;
|
|
65
|
+
export type RunnerEnrollmentResponseDto = z.infer<typeof runnerEnrollmentResponseSchema>;
|
|
66
|
+
export type RunnerAssignmentPollQueryDto = z.infer<typeof runnerAssignmentPollQuerySchema>;
|