@shipfox/api-runners-dto 2.0.0 → 6.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/CHANGELOG.md +30 -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 +64 -0
- package/dist/inter-module.d.ts.map +1 -0
- package/dist/inter-module.js +57 -0
- package/dist/inter-module.js.map +1 -0
- package/dist/schemas/assign-capacity.d.ts +18 -0
- package/dist/schemas/assign-capacity.d.ts.map +1 -0
- package/dist/schemas/assign-capacity.js +19 -0
- package/dist/schemas/assign-capacity.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -3
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +5 -3
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/mint-registration-tokens.d.ts +7 -7
- package/dist/schemas/mint-registration-tokens.d.ts.map +1 -1
- package/dist/schemas/mint-registration-tokens.js +7 -7
- package/dist/schemas/mint-registration-tokens.js.map +1 -1
- package/dist/schemas/poll-demand.d.ts +5 -1
- package/dist/schemas/poll-demand.d.ts.map +1 -1
- package/dist/schemas/poll-demand.js +4 -2
- package/dist/schemas/poll-demand.js.map +1 -1
- package/dist/schemas/provisioner-token.d.ts +10 -2
- package/dist/schemas/provisioner-token.d.ts.map +1 -1
- package/dist/schemas/provisioner-token.js +15 -6
- package/dist/schemas/provisioner-token.js.map +1 -1
- package/dist/schemas/{reconcile-provisioned-runners.d.ts → reconcile-runner-instances.d.ts} +12 -12
- package/dist/schemas/reconcile-runner-instances.d.ts.map +1 -0
- package/dist/schemas/reconcile-runner-instances.js +36 -0
- package/dist/schemas/reconcile-runner-instances.js.map +1 -0
- package/dist/schemas/register.d.ts +1 -0
- package/dist/schemas/register.d.ts.map +1 -1
- package/dist/schemas/register.js +2 -1
- package/dist/schemas/register.js.map +1 -1
- package/dist/schemas/{report-provisioned-runners.d.ts → report-runner-instances.d.ts} +32 -15
- package/dist/schemas/report-runner-instances.d.ts.map +1 -0
- package/dist/schemas/{report-provisioned-runners.js → report-runner-instances.js} +25 -12
- package/dist/schemas/report-runner-instances.js.map +1 -0
- package/dist/schemas/runner-enrollment.d.ts +51 -0
- package/dist/schemas/runner-enrollment.d.ts.map +1 -0
- package/dist/schemas/runner-enrollment.js +40 -0
- package/dist/schemas/runner-enrollment.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +15 -20
- package/src/index.ts +44 -19
- package/src/inter-module.test.ts +40 -0
- package/src/inter-module.ts +51 -0
- package/src/schemas/assign-capacity.ts +22 -0
- package/src/schemas/index.ts +50 -21
- package/src/schemas/mint-registration-tokens.test.ts +7 -7
- package/src/schemas/mint-registration-tokens.ts +10 -18
- package/src/schemas/poll-demand.test.ts +1 -1
- package/src/schemas/poll-demand.ts +4 -2
- package/src/schemas/provisioner-token.test.ts +9 -0
- package/src/schemas/provisioner-token.ts +6 -4
- package/src/schemas/{reconcile-provisioned-runners.test.ts → reconcile-runner-instances.test.ts} +21 -21
- package/src/schemas/reconcile-runner-instances.ts +58 -0
- package/src/schemas/register.ts +1 -1
- package/src/schemas/{report-provisioned-runners.test.ts → report-runner-instances.test.ts} +16 -16
- package/src/schemas/report-runner-instances.ts +91 -0
- package/src/schemas/runner-enrollment.ts +49 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/dist/schemas/reconcile-provisioned-runners.d.ts.map +0 -1
- package/dist/schemas/reconcile-provisioned-runners.js +0 -36
- package/dist/schemas/reconcile-provisioned-runners.js.map +0 -1
- package/dist/schemas/report-provisioned-runners.d.ts.map +0 -1
- package/dist/schemas/report-provisioned-runners.js.map +0 -1
- package/src/schemas/reconcile-provisioned-runners.ts +0 -61
- package/src/schemas/report-provisioned-runners.ts +0 -75
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfox/api-runners-dto",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/ShipfoxHQ/shipfox.git",
|
|
@@ -13,35 +13,30 @@
|
|
|
13
13
|
"types": "dist/index.d.ts",
|
|
14
14
|
"imports": {
|
|
15
15
|
"#test/*": "./test/*",
|
|
16
|
-
"#*":
|
|
17
|
-
"workspace-source": "./src/*",
|
|
18
|
-
"development": "./src/*",
|
|
19
|
-
"default": "./dist/*"
|
|
20
|
-
}
|
|
16
|
+
"#*": "./dist/*"
|
|
21
17
|
},
|
|
22
18
|
"exports": {
|
|
23
19
|
".": {
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"default": "./dist/index.js"
|
|
31
|
-
}
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./inter-module": {
|
|
24
|
+
"types": "./dist/inter-module.d.ts",
|
|
25
|
+
"default": "./dist/inter-module.js"
|
|
32
26
|
}
|
|
33
27
|
},
|
|
34
28
|
"dependencies": {
|
|
35
29
|
"zod": "^4.4.3",
|
|
36
|
-
"@shipfox/
|
|
30
|
+
"@shipfox/inter-module": "0.2.0",
|
|
31
|
+
"@shipfox/runner-labels": "0.1.1"
|
|
37
32
|
},
|
|
38
33
|
"devDependencies": {
|
|
39
|
-
"@shipfox/
|
|
40
|
-
"@shipfox/
|
|
41
|
-
"@shipfox/
|
|
34
|
+
"@shipfox/biome": "1.8.2",
|
|
35
|
+
"@shipfox/depcruise": "1.0.2",
|
|
36
|
+
"@shipfox/swc": "1.2.6",
|
|
42
37
|
"@shipfox/ts-config": "1.3.8",
|
|
43
|
-
"@shipfox/
|
|
44
|
-
"@shipfox/
|
|
38
|
+
"@shipfox/typescript": "1.1.7",
|
|
39
|
+
"@shipfox/vitest": "1.2.3"
|
|
45
40
|
},
|
|
46
41
|
"scripts": {
|
|
47
42
|
"build": "shipfox-swc",
|
package/src/index.ts
CHANGED
|
@@ -3,20 +3,37 @@ export {
|
|
|
3
3
|
type ActiveRunnerDto,
|
|
4
4
|
type ActiveRunnerStateDto,
|
|
5
5
|
type ActiveRunnersResponseDto,
|
|
6
|
+
type AssignCapacityBatchBodyDto,
|
|
7
|
+
type AssignCapacityBatchResponseDto,
|
|
8
|
+
type AttachProviderRunnerBodyDto,
|
|
9
|
+
type AttachProviderRunnerResponseDto,
|
|
6
10
|
activeProvisionerDtoSchema,
|
|
7
11
|
activeRunnerDtoSchema,
|
|
8
12
|
activeRunnerStateSchema,
|
|
9
13
|
activeRunnersResponseSchema,
|
|
14
|
+
assignCapacityBatchBodySchema,
|
|
15
|
+
assignCapacityBatchResponseSchema,
|
|
16
|
+
attachProviderRunnerBodySchema,
|
|
17
|
+
attachProviderRunnerResponseSchema,
|
|
18
|
+
attachRunnerControlProviderIdBodySchema,
|
|
10
19
|
type ClaimedJobResponseDto,
|
|
11
20
|
type CreateManualRegistrationTokenBodyDto,
|
|
12
21
|
type CreateManualRegistrationTokenResponseDto,
|
|
22
|
+
type CreatePlannedCapacityBodyDto,
|
|
23
|
+
type CreatePlannedCapacityResponseDto,
|
|
13
24
|
type CreateProvisionerTokenBodyDto,
|
|
14
25
|
type CreateProvisionerTokenResponseDto,
|
|
26
|
+
type CreateRunnerInstancesBodyDto,
|
|
27
|
+
type CreateRunnerInstancesResponseDto,
|
|
15
28
|
claimedJobResponseSchema,
|
|
16
29
|
createManualRegistrationTokenBodySchema,
|
|
17
30
|
createManualRegistrationTokenResponseSchema,
|
|
31
|
+
createPlannedCapacityBodySchema,
|
|
32
|
+
createPlannedCapacityResponseSchema,
|
|
18
33
|
createProvisionerTokenBodySchema,
|
|
19
34
|
createProvisionerTokenResponseSchema,
|
|
35
|
+
createRunnerInstancesBodySchema,
|
|
36
|
+
createRunnerInstancesResponseSchema,
|
|
20
37
|
type DemandStatDto,
|
|
21
38
|
demandStatSchema,
|
|
22
39
|
type HeartbeatBodyDto,
|
|
@@ -30,65 +47,73 @@ export {
|
|
|
30
47
|
listManualRegistrationTokensResponseSchema,
|
|
31
48
|
listProvisionerTokensResponseSchema,
|
|
32
49
|
MAX_MANUAL_REGISTRATION_TOKEN_TTL_SECONDS,
|
|
33
|
-
|
|
50
|
+
MAX_OBSERVED_PROVIDER_RUNNER_ID_LENGTH,
|
|
34
51
|
MAX_PROVIDER_KIND_LENGTH,
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
MAX_PROVIDER_RUNNER_REASON_LENGTH,
|
|
53
|
+
MAX_PROVIDER_RUNNER_REPORT_EVENTS,
|
|
37
54
|
MAX_PROVISIONER_TOKEN_TTL_SECONDS,
|
|
38
55
|
MAX_RECONCILE_OBSERVED_RUNNERS,
|
|
39
56
|
type ManualRegistrationTokenDto,
|
|
40
57
|
type MintedRegistrationTokenDto,
|
|
41
58
|
type MintRegistrationTokensBatchBodyDto,
|
|
42
59
|
type MintRegistrationTokensBatchResponseDto,
|
|
43
|
-
type
|
|
60
|
+
type MintRegistrationTokensRunnerInstanceDto,
|
|
44
61
|
manualRegistrationTokenDtoSchema,
|
|
45
62
|
mintedRegistrationTokenSchema,
|
|
46
63
|
mintRegistrationTokensBatchBodySchema,
|
|
47
64
|
mintRegistrationTokensBatchResponseSchema,
|
|
48
|
-
|
|
65
|
+
mintRegistrationTokensRunnerInstanceSchema,
|
|
49
66
|
type PollDemandBodyDto,
|
|
50
67
|
type PollDemandResponseDto,
|
|
51
68
|
type PollDemandTemplateDto,
|
|
52
|
-
type ProvisionedRunnerReportEventDto,
|
|
53
|
-
type ProvisionedRunnerStateDto,
|
|
54
69
|
type ProvisionerIdentityResponseDto,
|
|
55
70
|
type ProvisionerTokenDto,
|
|
56
71
|
pollDemandBodySchema,
|
|
57
72
|
pollDemandResponseSchema,
|
|
58
73
|
pollDemandTemplateSchema,
|
|
59
74
|
providerKindSchema,
|
|
60
|
-
|
|
61
|
-
|
|
75
|
+
providerRunnerReportEventSchema,
|
|
76
|
+
providerRunnerStateSchema,
|
|
62
77
|
provisionerIdentityResponseSchema,
|
|
63
78
|
provisionerTokenDtoSchema,
|
|
64
79
|
REGISTRATION_TOKEN_BATCH_HARD_MAX,
|
|
65
80
|
type ReconcileDesiredIntentDto,
|
|
66
81
|
type ReconciledBoundJobDto,
|
|
67
|
-
type
|
|
68
|
-
type
|
|
69
|
-
type
|
|
82
|
+
type ReconciledRunnerInstanceDto,
|
|
83
|
+
type ReconcileRunnerInstancesBodyDto,
|
|
84
|
+
type ReconcileRunnerInstancesResponseDto,
|
|
70
85
|
type RegisterRunnerBodyDto,
|
|
71
86
|
type RegisterRunnerResponseDto,
|
|
72
|
-
type
|
|
73
|
-
type
|
|
87
|
+
type ReportRunnerInstancesBodyDto,
|
|
88
|
+
type ReportRunnerInstancesResponseDto,
|
|
74
89
|
type ReservationGrantDto,
|
|
75
90
|
type RevokeManualRegistrationTokenResponseDto,
|
|
76
91
|
type RevokeProvisionerTokenResponseDto,
|
|
77
92
|
RUNNER_SESSION_EXHAUSTED_CODE,
|
|
93
|
+
type RunnerBootstrapExchangeBodyDto,
|
|
94
|
+
type RunnerBootstrapExchangeResponseDto,
|
|
95
|
+
type RunnerEnrollmentBodyDto,
|
|
78
96
|
type RunnerHarnessToolCapabilitiesDto,
|
|
97
|
+
type RunnerInstanceReportEventDto,
|
|
98
|
+
type RunnerInstanceStateDto,
|
|
79
99
|
type RunnerToolCapabilitiesDto,
|
|
80
100
|
reconcileDesiredIntentSchema,
|
|
81
101
|
reconciledBoundJobSchema,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
reconciledRunnerInstanceSchema,
|
|
103
|
+
reconcileRunnerInstancesBodySchema,
|
|
104
|
+
reconcileRunnerInstancesResponseSchema,
|
|
85
105
|
registerRunnerBodySchema,
|
|
86
106
|
registerRunnerResponseSchema,
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
reportRunnerInstancesBodySchema,
|
|
108
|
+
reportRunnerInstancesResponseSchema,
|
|
89
109
|
reservationGrantSchema,
|
|
90
110
|
revokeManualRegistrationTokenResponseSchema,
|
|
91
111
|
revokeProvisionerTokenResponseSchema,
|
|
112
|
+
runnerAssignmentPollResponseSchema,
|
|
113
|
+
runnerBootstrapExchangeBodySchema,
|
|
114
|
+
runnerBootstrapExchangeResponseSchema,
|
|
115
|
+
runnerControlHeartbeatResponseSchema,
|
|
116
|
+
runnerEnrollmentBodySchema,
|
|
92
117
|
runnerHarnessToolCapabilitiesSchema,
|
|
93
118
|
runnerToolCapabilitiesSchema,
|
|
94
119
|
} from '#schemas/index.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {runnersInterModuleContract} from './inter-module.js';
|
|
2
|
+
|
|
3
|
+
const id = '00000000-0000-4000-8000-000000000001';
|
|
4
|
+
|
|
5
|
+
describe('runnersInterModuleContract', () => {
|
|
6
|
+
test('accepts stable job-execution identities for idempotent commands', () => {
|
|
7
|
+
const input = runnersInterModuleContract.methods.enqueueJobExecution.input.parse({
|
|
8
|
+
workspaceId: id,
|
|
9
|
+
workflowRunId: id,
|
|
10
|
+
workflowRunAttemptId: id,
|
|
11
|
+
jobId: id,
|
|
12
|
+
jobExecutionId: id,
|
|
13
|
+
projectId: id,
|
|
14
|
+
requiredLabels: ['linux'],
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
expect(input.jobExecutionId).toBe(id);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('exposes bounded JSON capability results', () => {
|
|
21
|
+
const result =
|
|
22
|
+
runnersInterModuleContract.methods.getEffectiveRunnerToolCapabilities.output.parse({
|
|
23
|
+
capabilities: {harnesses: {pi: {tools: ['read']}}},
|
|
24
|
+
reportFresh: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(result).toEqual({
|
|
28
|
+
capabilities: {harnesses: {pi: {tools: ['read']}}},
|
|
29
|
+
reportFresh: true,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('defines the scheduling validation failure', () => {
|
|
34
|
+
const details = runnersInterModuleContract.methods.enqueueJobExecution.errors[
|
|
35
|
+
'empty-required-labels'
|
|
36
|
+
].parse({});
|
|
37
|
+
|
|
38
|
+
expect(details).toEqual({});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {defineInterModuleContract, type InterModuleClient} from '@shipfox/inter-module';
|
|
2
|
+
import {z} from 'zod';
|
|
3
|
+
import {runnerToolCapabilitiesSchema} from '#schemas/tool-capabilities.js';
|
|
4
|
+
|
|
5
|
+
const idSchema = z.string().uuid();
|
|
6
|
+
|
|
7
|
+
export const runnersInterModuleContract = defineInterModuleContract({
|
|
8
|
+
module: 'runners',
|
|
9
|
+
methods: {
|
|
10
|
+
enqueueJobExecution: {
|
|
11
|
+
input: z.object({
|
|
12
|
+
workspaceId: idSchema,
|
|
13
|
+
workflowRunId: idSchema,
|
|
14
|
+
workflowRunAttemptId: idSchema,
|
|
15
|
+
jobId: idSchema,
|
|
16
|
+
jobExecutionId: idSchema,
|
|
17
|
+
projectId: idSchema,
|
|
18
|
+
requiredLabels: z.array(z.string()),
|
|
19
|
+
}),
|
|
20
|
+
output: z.object({}),
|
|
21
|
+
errors: {
|
|
22
|
+
'empty-required-labels': z.object({}),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
releaseJobExecution: {
|
|
26
|
+
input: z.object({jobExecutionId: idSchema}),
|
|
27
|
+
output: z.object({}),
|
|
28
|
+
},
|
|
29
|
+
cancelJobs: {
|
|
30
|
+
input: z.object({jobIds: z.array(idSchema)}),
|
|
31
|
+
output: z.object({}),
|
|
32
|
+
},
|
|
33
|
+
getLeaseState: {
|
|
34
|
+
input: z.object({
|
|
35
|
+
jobId: idSchema,
|
|
36
|
+
jobExecutionId: idSchema,
|
|
37
|
+
runnerSessionId: idSchema,
|
|
38
|
+
}),
|
|
39
|
+
output: z.object({active: z.boolean()}),
|
|
40
|
+
},
|
|
41
|
+
getEffectiveRunnerToolCapabilities: {
|
|
42
|
+
input: z.object({runnerSessionId: idSchema}),
|
|
43
|
+
output: z.object({
|
|
44
|
+
capabilities: runnerToolCapabilitiesSchema,
|
|
45
|
+
reportFresh: z.boolean(),
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export type RunnersInterModuleClient = InterModuleClient<typeof runnersInterModuleContract>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {z} from 'zod';
|
|
2
|
+
|
|
3
|
+
export const assignCapacityBatchBodySchema = z
|
|
4
|
+
.object({
|
|
5
|
+
reservation_id: z.string().uuid(),
|
|
6
|
+
capacity_ids: z.array(z.string().uuid()).min(1).max(1000),
|
|
7
|
+
})
|
|
8
|
+
.refine((body) => new Set(body.capacity_ids).size === body.capacity_ids.length, {
|
|
9
|
+
message: 'capacity_ids values must be unique',
|
|
10
|
+
path: ['capacity_ids'],
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const assignedCapacitySchema = z.object({
|
|
14
|
+
capacity_id: z.string().uuid(),
|
|
15
|
+
assignment_id: z.string().uuid(),
|
|
16
|
+
});
|
|
17
|
+
export const assignCapacityBatchResponseSchema = z.object({
|
|
18
|
+
assignments: z.array(assignedCapacitySchema),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type AssignCapacityBatchBodyDto = z.infer<typeof assignCapacityBatchBodySchema>;
|
|
22
|
+
export type AssignCapacityBatchResponseDto = z.infer<typeof assignCapacityBatchResponseSchema>;
|
package/src/schemas/index.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export {
|
|
2
|
+
type AssignCapacityBatchBodyDto,
|
|
3
|
+
type AssignCapacityBatchResponseDto,
|
|
4
|
+
assignCapacityBatchBodySchema,
|
|
5
|
+
assignCapacityBatchResponseSchema,
|
|
6
|
+
} from './assign-capacity.js';
|
|
1
7
|
export {
|
|
2
8
|
type ClaimedJobResponseDto,
|
|
3
9
|
claimedJobResponseSchema,
|
|
@@ -32,11 +38,11 @@ export {
|
|
|
32
38
|
type MintedRegistrationTokenDto,
|
|
33
39
|
type MintRegistrationTokensBatchBodyDto,
|
|
34
40
|
type MintRegistrationTokensBatchResponseDto,
|
|
35
|
-
type
|
|
41
|
+
type MintRegistrationTokensRunnerInstanceDto,
|
|
36
42
|
mintedRegistrationTokenSchema,
|
|
37
43
|
mintRegistrationTokensBatchBodySchema,
|
|
38
44
|
mintRegistrationTokensBatchResponseSchema,
|
|
39
|
-
|
|
45
|
+
mintRegistrationTokensRunnerInstanceSchema,
|
|
40
46
|
REGISTRATION_TOKEN_BATCH_HARD_MAX,
|
|
41
47
|
} from './mint-registration-tokens.js';
|
|
42
48
|
export {
|
|
@@ -67,19 +73,19 @@ export {
|
|
|
67
73
|
revokeProvisionerTokenResponseSchema,
|
|
68
74
|
} from './provisioner-token.js';
|
|
69
75
|
export {
|
|
70
|
-
|
|
76
|
+
MAX_OBSERVED_PROVIDER_RUNNER_ID_LENGTH,
|
|
71
77
|
MAX_RECONCILE_OBSERVED_RUNNERS,
|
|
72
78
|
type ReconcileDesiredIntentDto,
|
|
73
79
|
type ReconciledBoundJobDto,
|
|
74
|
-
type
|
|
75
|
-
type
|
|
76
|
-
type
|
|
80
|
+
type ReconciledRunnerInstanceDto,
|
|
81
|
+
type ReconcileRunnerInstancesBodyDto,
|
|
82
|
+
type ReconcileRunnerInstancesResponseDto,
|
|
77
83
|
reconcileDesiredIntentSchema,
|
|
78
84
|
reconciledBoundJobSchema,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} from './reconcile-
|
|
85
|
+
reconciledRunnerInstanceSchema,
|
|
86
|
+
reconcileRunnerInstancesBodySchema,
|
|
87
|
+
reconcileRunnerInstancesResponseSchema,
|
|
88
|
+
} from './reconcile-runner-instances.js';
|
|
83
89
|
export {
|
|
84
90
|
type RegisterRunnerBodyDto,
|
|
85
91
|
type RegisterRunnerResponseDto,
|
|
@@ -91,22 +97,45 @@ export {
|
|
|
91
97
|
type ActiveRunnerDto,
|
|
92
98
|
type ActiveRunnerStateDto,
|
|
93
99
|
type ActiveRunnersResponseDto,
|
|
100
|
+
type AttachProviderRunnerBodyDto,
|
|
101
|
+
type AttachProviderRunnerResponseDto,
|
|
94
102
|
activeRunnerDtoSchema,
|
|
95
103
|
activeRunnerStateSchema,
|
|
96
104
|
activeRunnersResponseSchema,
|
|
105
|
+
attachProviderRunnerBodySchema,
|
|
106
|
+
attachProviderRunnerResponseSchema,
|
|
107
|
+
type CreatePlannedCapacityBodyDto,
|
|
108
|
+
type CreatePlannedCapacityResponseDto,
|
|
109
|
+
createPlannedCapacityBodySchema,
|
|
110
|
+
createPlannedCapacityResponseSchema,
|
|
97
111
|
MAX_PROVIDER_KIND_LENGTH,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
type ProvisionedRunnerReportEventDto,
|
|
101
|
-
type ProvisionedRunnerStateDto,
|
|
112
|
+
MAX_PROVIDER_RUNNER_REASON_LENGTH,
|
|
113
|
+
MAX_PROVIDER_RUNNER_REPORT_EVENTS,
|
|
102
114
|
providerKindSchema,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
type
|
|
106
|
-
type
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
providerRunnerReportEventSchema,
|
|
116
|
+
providerRunnerStateSchema,
|
|
117
|
+
type ReportRunnerInstancesBodyDto,
|
|
118
|
+
type ReportRunnerInstancesResponseDto,
|
|
119
|
+
type RunnerInstanceReportEventDto,
|
|
120
|
+
type RunnerInstanceStateDto,
|
|
121
|
+
reportRunnerInstancesBodySchema,
|
|
122
|
+
reportRunnerInstancesResponseSchema,
|
|
123
|
+
} from './report-runner-instances.js';
|
|
124
|
+
export {
|
|
125
|
+
attachRunnerControlProviderIdBodySchema,
|
|
126
|
+
type CreateRunnerInstancesBodyDto,
|
|
127
|
+
type CreateRunnerInstancesResponseDto,
|
|
128
|
+
createRunnerInstancesBodySchema,
|
|
129
|
+
createRunnerInstancesResponseSchema,
|
|
130
|
+
type RunnerBootstrapExchangeBodyDto,
|
|
131
|
+
type RunnerBootstrapExchangeResponseDto,
|
|
132
|
+
type RunnerEnrollmentBodyDto,
|
|
133
|
+
runnerAssignmentPollResponseSchema,
|
|
134
|
+
runnerBootstrapExchangeBodySchema,
|
|
135
|
+
runnerBootstrapExchangeResponseSchema,
|
|
136
|
+
runnerControlHeartbeatResponseSchema,
|
|
137
|
+
runnerEnrollmentBodySchema,
|
|
138
|
+
} from './runner-enrollment.js';
|
|
110
139
|
export {
|
|
111
140
|
type RunnerHarnessToolCapabilitiesDto,
|
|
112
141
|
type RunnerToolCapabilitiesDto,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mintRegistrationTokensBatchBodySchema,
|
|
3
|
-
|
|
3
|
+
mintRegistrationTokensRunnerInstanceSchema,
|
|
4
4
|
} from './mint-registration-tokens.js';
|
|
5
5
|
|
|
6
|
-
describe('
|
|
6
|
+
describe('mintRegistrationTokensRunnerInstanceSchema', () => {
|
|
7
7
|
it('accepts provisioned runner ids up to the lifecycle report limit', () => {
|
|
8
|
-
const result =
|
|
9
|
-
|
|
8
|
+
const result = mintRegistrationTokensRunnerInstanceSchema.safeParse({
|
|
9
|
+
provider_runner_id: 'a'.repeat(255),
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
expect(result.success).toBe(true);
|
|
@@ -17,9 +17,9 @@ describe('mintRegistrationTokensBatchBodySchema', () => {
|
|
|
17
17
|
it('rejects duplicate provisioned runner ids', () => {
|
|
18
18
|
const result = mintRegistrationTokensBatchBodySchema.safeParse({
|
|
19
19
|
reservation_id: crypto.randomUUID(),
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
{
|
|
20
|
+
runner_instances: [
|
|
21
|
+
{provider_runner_id: 'provisioned-runner-1'},
|
|
22
|
+
{provider_runner_id: 'provisioned-runner-1'},
|
|
23
23
|
],
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
import {z} from 'zod';
|
|
2
2
|
|
|
3
3
|
export const REGISTRATION_TOKEN_BATCH_HARD_MAX = 1000;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
provisioned_runner_id: z.string().min(1).max(255),
|
|
4
|
+
export const mintRegistrationTokensRunnerInstanceSchema = z.object({
|
|
5
|
+
provider_runner_id: z.string().min(1).max(255),
|
|
7
6
|
});
|
|
8
|
-
|
|
9
7
|
export const mintRegistrationTokensBatchBodySchema = z
|
|
10
8
|
.object({
|
|
11
9
|
reservation_id: z.string().uuid(),
|
|
12
|
-
|
|
13
|
-
.array(
|
|
10
|
+
runner_instances: z
|
|
11
|
+
.array(mintRegistrationTokensRunnerInstanceSchema)
|
|
14
12
|
.min(1)
|
|
15
13
|
.max(REGISTRATION_TOKEN_BATCH_HARD_MAX),
|
|
16
14
|
})
|
|
17
15
|
.refine(
|
|
18
16
|
(body) =>
|
|
19
|
-
new Set(
|
|
20
|
-
body.
|
|
21
|
-
|
|
22
|
-
),
|
|
23
|
-
).size === body.provisioned_runners.length,
|
|
24
|
-
{message: 'provisioned_runner_id values must be unique', path: ['provisioned_runners']},
|
|
17
|
+
new Set(body.runner_instances.map((providerRunner) => providerRunner.provider_runner_id))
|
|
18
|
+
.size === body.runner_instances.length,
|
|
19
|
+
{message: 'provider_runner_id values must be unique', path: ['runner_instances']},
|
|
25
20
|
);
|
|
26
|
-
|
|
27
21
|
export const mintedRegistrationTokenSchema = z.object({
|
|
28
|
-
|
|
22
|
+
provider_runner_id: z.string(),
|
|
29
23
|
registration_token: z.string(),
|
|
30
24
|
expires_at: z.string().datetime(),
|
|
31
25
|
});
|
|
32
|
-
|
|
33
26
|
export const mintRegistrationTokensBatchResponseSchema = z.object({
|
|
34
27
|
tokens: z.array(mintedRegistrationTokenSchema),
|
|
35
28
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
typeof mintRegistrationTokensProvisionedRunnerSchema
|
|
29
|
+
export type MintRegistrationTokensRunnerInstanceDto = z.infer<
|
|
30
|
+
typeof mintRegistrationTokensRunnerInstanceSchema
|
|
39
31
|
>;
|
|
40
32
|
export type MintRegistrationTokensBatchBodyDto = z.infer<
|
|
41
33
|
typeof mintRegistrationTokensBatchBodySchema
|
|
@@ -13,10 +13,11 @@ 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).
|
|
16
|
+
templates: z.array(pollDemandTemplateSchema).max(100),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
export const demandStatSchema = z.object({
|
|
20
|
+
workspace_id: z.string().uuid().optional(),
|
|
20
21
|
labels: z.array(z.string()),
|
|
21
22
|
queued: z.number().int().min(0),
|
|
22
23
|
reserved: z
|
|
@@ -31,6 +32,7 @@ export const demandStatSchema = z.object({
|
|
|
31
32
|
|
|
32
33
|
export const reservationGrantSchema = z.object({
|
|
33
34
|
reservation_id: z.string().uuid(),
|
|
35
|
+
workspace_id: z.string().uuid().optional(),
|
|
34
36
|
labels: z.array(z.string()),
|
|
35
37
|
count: z.number().int().positive(),
|
|
36
38
|
expires_at: z.string().datetime(),
|
|
@@ -39,7 +41,7 @@ export const reservationGrantSchema = z.object({
|
|
|
39
41
|
export const pollDemandResponseSchema = z.object({
|
|
40
42
|
stats: z.array(demandStatSchema),
|
|
41
43
|
reservations: z.array(reservationGrantSchema),
|
|
42
|
-
|
|
44
|
+
terminate_provider_runner_ids: z.array(z.string()),
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
export type PollDemandTemplateDto = z.infer<typeof pollDemandTemplateSchema>;
|
|
@@ -28,6 +28,7 @@ describe('provisioner token schemas', () => {
|
|
|
28
28
|
it('parses provisioner identity responses', () => {
|
|
29
29
|
const identity = {
|
|
30
30
|
id: crypto.randomUUID(),
|
|
31
|
+
scope: 'workspace',
|
|
31
32
|
workspace_id: crypto.randomUUID(),
|
|
32
33
|
};
|
|
33
34
|
|
|
@@ -35,4 +36,12 @@ describe('provisioner token schemas', () => {
|
|
|
35
36
|
|
|
36
37
|
expect(result).toEqual(identity);
|
|
37
38
|
});
|
|
39
|
+
|
|
40
|
+
it('parses installation provisioner identities without a workspace', () => {
|
|
41
|
+
const identity = {id: crypto.randomUUID(), scope: 'installation'};
|
|
42
|
+
|
|
43
|
+
const result = provisionerIdentityResponseSchema.parse(identity);
|
|
44
|
+
|
|
45
|
+
expect(result).toEqual(identity);
|
|
46
|
+
});
|
|
38
47
|
});
|
|
@@ -22,6 +22,7 @@ export const createProvisionerTokenResponseSchema = z.object({
|
|
|
22
22
|
last_seen_at: z.string().nullable(),
|
|
23
23
|
created_at: z.string(),
|
|
24
24
|
updated_at: z.string(),
|
|
25
|
+
scope: z.literal('workspace'),
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
export type CreateProvisionerTokenResponseDto = z.infer<
|
|
@@ -40,6 +41,7 @@ export const provisionerTokenDtoSchema = z.object({
|
|
|
40
41
|
last_seen_at: z.string().nullable(),
|
|
41
42
|
created_at: z.string(),
|
|
42
43
|
updated_at: z.string(),
|
|
44
|
+
scope: z.literal('workspace'),
|
|
43
45
|
});
|
|
44
46
|
|
|
45
47
|
export type ProvisionerTokenDto = z.infer<typeof provisionerTokenDtoSchema>;
|
|
@@ -56,9 +58,9 @@ export type RevokeProvisionerTokenResponseDto = z.infer<
|
|
|
56
58
|
typeof revokeProvisionerTokenResponseSchema
|
|
57
59
|
>;
|
|
58
60
|
|
|
59
|
-
export const provisionerIdentityResponseSchema = z.
|
|
60
|
-
id: z.string().uuid(),
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
export const provisionerIdentityResponseSchema = z.discriminatedUnion('scope', [
|
|
62
|
+
z.object({id: z.string().uuid(), scope: z.literal('workspace'), workspace_id: z.string().uuid()}),
|
|
63
|
+
z.object({id: z.string().uuid(), scope: z.literal('installation')}),
|
|
64
|
+
]);
|
|
63
65
|
|
|
64
66
|
export type ProvisionerIdentityResponseDto = z.infer<typeof provisionerIdentityResponseSchema>;
|