@shipfox/api-runners 2.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 +1 -0
- package/CHANGELOG.md +187 -0
- package/LICENSE +21 -0
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +208 -0
- package/dist/config.js.map +1 -0
- package/dist/core/demand.d.ts +33 -0
- package/dist/core/demand.d.ts.map +1 -0
- package/dist/core/demand.js +169 -0
- package/dist/core/demand.js.map +1 -0
- package/dist/core/entities/ephemeral-registration-token.d.ts +14 -0
- package/dist/core/entities/ephemeral-registration-token.d.ts.map +1 -0
- package/dist/core/entities/ephemeral-registration-token.js +3 -0
- package/dist/core/entities/ephemeral-registration-token.js.map +1 -0
- package/dist/core/entities/manual-registration-token.d.ts +12 -0
- package/dist/core/entities/manual-registration-token.d.ts.map +1 -0
- package/dist/core/entities/manual-registration-token.js +3 -0
- package/dist/core/entities/manual-registration-token.js.map +1 -0
- package/dist/core/entities/provisioned-runner.d.ts +24 -0
- package/dist/core/entities/provisioned-runner.d.ts.map +1 -0
- package/dist/core/entities/provisioned-runner.js +3 -0
- package/dist/core/entities/provisioned-runner.js.map +1 -0
- package/dist/core/entities/provisioner-token.d.ts +18 -0
- package/dist/core/entities/provisioner-token.d.ts.map +1 -0
- package/dist/core/entities/provisioner-token.js +3 -0
- package/dist/core/entities/provisioner-token.js.map +1 -0
- package/dist/core/entities/reservation.d.ts +10 -0
- package/dist/core/entities/reservation.d.ts.map +1 -0
- package/dist/core/entities/reservation.js +3 -0
- package/dist/core/entities/reservation.js.map +1 -0
- package/dist/core/entities/runner-session.d.ts +18 -0
- package/dist/core/entities/runner-session.d.ts.map +1 -0
- package/dist/core/entities/runner-session.js +3 -0
- package/dist/core/entities/runner-session.js.map +1 -0
- package/dist/core/ephemeral-registration-tokens.d.ts +31 -0
- package/dist/core/ephemeral-registration-tokens.d.ts.map +1 -0
- package/dist/core/ephemeral-registration-tokens.js +61 -0
- package/dist/core/ephemeral-registration-tokens.js.map +1 -0
- package/dist/core/errors.d.ts +62 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +92 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +14 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/job-executions.d.ts +14 -0
- package/dist/core/job-executions.d.ts.map +1 -0
- package/dist/core/job-executions.js +37 -0
- package/dist/core/job-executions.js.map +1 -0
- package/dist/core/maintenance-policy.d.ts +2 -0
- package/dist/core/maintenance-policy.d.ts.map +1 -0
- package/dist/core/maintenance-policy.js +3 -0
- package/dist/core/maintenance-policy.js.map +1 -0
- package/dist/core/maintenance.d.ts +33 -0
- package/dist/core/maintenance.d.ts.map +1 -0
- package/dist/core/maintenance.js +55 -0
- package/dist/core/maintenance.js.map +1 -0
- package/dist/core/manual-registration-tokens.d.ts +17 -0
- package/dist/core/manual-registration-tokens.d.ts.map +1 -0
- package/dist/core/manual-registration-tokens.js +28 -0
- package/dist/core/manual-registration-tokens.js.map +1 -0
- package/dist/core/provisioned-runners.d.ts +67 -0
- package/dist/core/provisioned-runners.d.ts.map +1 -0
- package/dist/core/provisioned-runners.js +162 -0
- package/dist/core/provisioned-runners.js.map +1 -0
- package/dist/core/provisioner-tokens.d.ts +20 -0
- package/dist/core/provisioner-tokens.d.ts.map +1 -0
- package/dist/core/provisioner-tokens.js +36 -0
- package/dist/core/provisioner-tokens.js.map +1 -0
- package/dist/core/rate-limit.d.ts +35 -0
- package/dist/core/rate-limit.d.ts.map +1 -0
- package/dist/core/rate-limit.js +74 -0
- package/dist/core/rate-limit.js.map +1 -0
- package/dist/core/runner-sessions.d.ts +26 -0
- package/dist/core/runner-sessions.d.ts.map +1 -0
- package/dist/core/runner-sessions.js +41 -0
- package/dist/core/runner-sessions.js.map +1 -0
- package/dist/core/runner-tool-capabilities.d.ts +24 -0
- package/dist/core/runner-tool-capabilities.d.ts.map +1 -0
- package/dist/core/runner-tool-capabilities.js +43 -0
- package/dist/core/runner-tool-capabilities.js.map +1 -0
- package/dist/db/db.d.ts +4478 -0
- package/dist/db/db.d.ts.map +1 -0
- package/dist/db/db.js +36 -0
- package/dist/db/db.js.map +1 -0
- package/dist/db/ephemeral-registration-tokens.d.ts +47 -0
- package/dist/db/ephemeral-registration-tokens.d.ts.map +1 -0
- package/dist/db/ephemeral-registration-tokens.js +170 -0
- package/dist/db/ephemeral-registration-tokens.js.map +1 -0
- package/dist/db/index.d.ts +19 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +15 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/job-executions.d.ts +128 -0
- package/dist/db/job-executions.d.ts.map +1 -0
- package/dist/db/job-executions.js +354 -0
- package/dist/db/job-executions.js.map +1 -0
- package/dist/db/manual-registration-tokens.d.ts +16 -0
- package/dist/db/manual-registration-tokens.d.ts.map +1 -0
- package/dist/db/manual-registration-tokens.js +37 -0
- package/dist/db/manual-registration-tokens.js.map +1 -0
- package/dist/db/provisioned-runners.d.ts +79 -0
- package/dist/db/provisioned-runners.d.ts.map +1 -0
- package/dist/db/provisioned-runners.js +466 -0
- package/dist/db/provisioned-runners.js.map +1 -0
- package/dist/db/provisioner-tokens.d.ts +26 -0
- package/dist/db/provisioner-tokens.d.ts.map +1 -0
- package/dist/db/provisioner-tokens.js +54 -0
- package/dist/db/provisioner-tokens.js.map +1 -0
- package/dist/db/rate-limits.d.ts +18 -0
- package/dist/db/rate-limits.d.ts.map +1 -0
- package/dist/db/rate-limits.js +44 -0
- package/dist/db/rate-limits.js.map +1 -0
- package/dist/db/reservations.d.ts +48 -0
- package/dist/db/reservations.d.ts.map +1 -0
- package/dist/db/reservations.js +162 -0
- package/dist/db/reservations.js.map +1 -0
- package/dist/db/runner-sessions.d.ts +18 -0
- package/dist/db/runner-sessions.d.ts.map +1 -0
- package/dist/db/runner-sessions.js +38 -0
- package/dist/db/runner-sessions.js.map +1 -0
- package/dist/db/schema/common.d.ts +2 -0
- package/dist/db/schema/common.d.ts.map +1 -0
- package/dist/db/schema/common.js +4 -0
- package/dist/db/schema/common.js.map +1 -0
- package/dist/db/schema/ephemeral-registration-tokens.d.ts +199 -0
- package/dist/db/schema/ephemeral-registration-tokens.d.ts.map +1 -0
- package/dist/db/schema/ephemeral-registration-tokens.js +45 -0
- package/dist/db/schema/ephemeral-registration-tokens.js.map +1 -0
- package/dist/db/schema/manual-registration-tokens.d.ts +165 -0
- package/dist/db/schema/manual-registration-tokens.d.ts.map +1 -0
- package/dist/db/schema/manual-registration-tokens.js +40 -0
- package/dist/db/schema/manual-registration-tokens.js.map +1 -0
- package/dist/db/schema/outbox.d.ts +195 -0
- package/dist/db/schema/outbox.d.ts.map +1 -0
- package/dist/db/schema/outbox.js +5 -0
- package/dist/db/schema/outbox.js.map +1 -0
- package/dist/db/schema/pending-job-executions.d.ts +189 -0
- package/dist/db/schema/pending-job-executions.d.ts.map +1 -0
- package/dist/db/schema/pending-job-executions.js +21 -0
- package/dist/db/schema/pending-job-executions.js.map +1 -0
- package/dist/db/schema/provisioned-runners.d.ts +379 -0
- package/dist/db/schema/provisioned-runners.d.ts.map +1 -0
- package/dist/db/schema/provisioned-runners.js +83 -0
- package/dist/db/schema/provisioned-runners.js.map +1 -0
- package/dist/db/schema/provisioner-tokens.d.ts +216 -0
- package/dist/db/schema/provisioner-tokens.d.ts.map +1 -0
- package/dist/db/schema/provisioner-tokens.js +48 -0
- package/dist/db/schema/provisioner-tokens.js.map +1 -0
- package/dist/db/schema/rate-limits.d.ts +145 -0
- package/dist/db/schema/rate-limits.d.ts.map +1 -0
- package/dist/db/schema/rate-limits.js +25 -0
- package/dist/db/schema/rate-limits.js.map +1 -0
- package/dist/db/schema/reservations.d.ts +157 -0
- package/dist/db/schema/reservations.d.ts.map +1 -0
- package/dist/db/schema/reservations.js +34 -0
- package/dist/db/schema/reservations.js.map +1 -0
- package/dist/db/schema/runner-sessions.d.ts +298 -0
- package/dist/db/schema/runner-sessions.d.ts.map +1 -0
- package/dist/db/schema/runner-sessions.js +61 -0
- package/dist/db/schema/runner-sessions.js.map +1 -0
- package/dist/db/schema/running-job-executions.d.ts +334 -0
- package/dist/db/schema/running-job-executions.d.ts.map +1 -0
- package/dist/db/schema/running-job-executions.js +41 -0
- package/dist/db/schema/running-job-executions.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics/index.d.ts +3 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +4 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/instance.d.ts +34 -0
- package/dist/metrics/instance.d.ts.map +1 -0
- package/dist/metrics/instance.js +60 -0
- package/dist/metrics/instance.js.map +1 -0
- package/dist/metrics/service.d.ts +2 -0
- package/dist/metrics/service.d.ts.map +1 -0
- package/dist/metrics/service.js +21 -0
- package/dist/metrics/service.js.map +1 -0
- package/dist/presentation/auth/index.d.ts +3 -0
- package/dist/presentation/auth/index.d.ts.map +1 -0
- package/dist/presentation/auth/index.js +4 -0
- package/dist/presentation/auth/index.js.map +1 -0
- package/dist/presentation/auth/provisioner-token-auth.d.ts +3 -0
- package/dist/presentation/auth/provisioner-token-auth.d.ts.map +1 -0
- package/dist/presentation/auth/provisioner-token-auth.js +81 -0
- package/dist/presentation/auth/provisioner-token-auth.js.map +1 -0
- package/dist/presentation/auth/runner-registration-token-auth.d.ts +17 -0
- package/dist/presentation/auth/runner-registration-token-auth.d.ts.map +1 -0
- package/dist/presentation/auth/runner-registration-token-auth.js +77 -0
- package/dist/presentation/auth/runner-registration-token-auth.js.map +1 -0
- package/dist/presentation/dto/active-provisioner.d.ts +8 -0
- package/dist/presentation/dto/active-provisioner.d.ts.map +1 -0
- package/dist/presentation/dto/active-provisioner.js +10 -0
- package/dist/presentation/dto/active-provisioner.js.map +1 -0
- package/dist/presentation/dto/index.d.ts +7 -0
- package/dist/presentation/dto/index.d.ts.map +1 -0
- package/dist/presentation/dto/index.js +8 -0
- package/dist/presentation/dto/index.js.map +1 -0
- package/dist/presentation/dto/manual-registration-token.d.ts +12 -0
- package/dist/presentation/dto/manual-registration-token.d.ts.map +1 -0
- package/dist/presentation/dto/manual-registration-token.js +14 -0
- package/dist/presentation/dto/manual-registration-token.js.map +1 -0
- package/dist/presentation/dto/mint-registration-tokens.d.ts +5 -0
- package/dist/presentation/dto/mint-registration-tokens.d.ts.map +1 -0
- package/dist/presentation/dto/mint-registration-tokens.js +19 -0
- package/dist/presentation/dto/mint-registration-tokens.js.map +1 -0
- package/dist/presentation/dto/poll-demand.d.ts +4 -0
- package/dist/presentation/dto/poll-demand.d.ts.map +1 -0
- package/dist/presentation/dto/poll-demand.js +19 -0
- package/dist/presentation/dto/poll-demand.js.map +1 -0
- package/dist/presentation/dto/provisioned-runners.d.ts +38 -0
- package/dist/presentation/dto/provisioned-runners.d.ts.map +1 -0
- package/dist/presentation/dto/provisioned-runners.js +44 -0
- package/dist/presentation/dto/provisioned-runners.js.map +1 -0
- package/dist/presentation/dto/provisioner-token.d.ts +15 -0
- package/dist/presentation/dto/provisioner-token.d.ts.map +1 -0
- package/dist/presentation/dto/provisioner-token.js +17 -0
- package/dist/presentation/dto/provisioner-token.js.map +1 -0
- package/dist/presentation/index.d.ts +4 -0
- package/dist/presentation/index.d.ts.map +1 -0
- package/dist/presentation/index.js +5 -0
- package/dist/presentation/index.js.map +1 -0
- package/dist/presentation/routes/create-manual-registration-token.d.ts +2 -0
- package/dist/presentation/routes/create-manual-registration-token.d.ts.map +1 -0
- package/dist/presentation/routes/create-manual-registration-token.js +44 -0
- package/dist/presentation/routes/create-manual-registration-token.js.map +1 -0
- package/dist/presentation/routes/create-provisioner-token.d.ts +2 -0
- package/dist/presentation/routes/create-provisioner-token.d.ts.map +1 -0
- package/dist/presentation/routes/create-provisioner-token.js +42 -0
- package/dist/presentation/routes/create-provisioner-token.js.map +1 -0
- package/dist/presentation/routes/get-provisioner-me.d.ts +2 -0
- package/dist/presentation/routes/get-provisioner-me.d.ts.map +1 -0
- package/dist/presentation/routes/get-provisioner-me.js +22 -0
- package/dist/presentation/routes/get-provisioner-me.js.map +1 -0
- package/dist/presentation/routes/heartbeat.d.ts +2 -0
- package/dist/presentation/routes/heartbeat.d.ts.map +1 -0
- package/dist/presentation/routes/heartbeat.js +64 -0
- package/dist/presentation/routes/heartbeat.js.map +1 -0
- package/dist/presentation/routes/index.d.ts +4 -0
- package/dist/presentation/routes/index.d.ts.map +1 -0
- package/dist/presentation/routes/index.js +97 -0
- package/dist/presentation/routes/index.js.map +1 -0
- package/dist/presentation/routes/list-active-provisioners.d.ts +2 -0
- package/dist/presentation/routes/list-active-provisioners.d.ts.map +1 -0
- package/dist/presentation/routes/list-active-provisioners.js +32 -0
- package/dist/presentation/routes/list-active-provisioners.js.map +1 -0
- package/dist/presentation/routes/list-active-runners.d.ts +2 -0
- package/dist/presentation/routes/list-active-runners.d.ts.map +1 -0
- package/dist/presentation/routes/list-active-runners.js +32 -0
- package/dist/presentation/routes/list-active-runners.js.map +1 -0
- package/dist/presentation/routes/list-manual-registration-tokens.d.ts +2 -0
- package/dist/presentation/routes/list-manual-registration-tokens.d.ts.map +1 -0
- package/dist/presentation/routes/list-manual-registration-tokens.js +32 -0
- package/dist/presentation/routes/list-manual-registration-tokens.js.map +1 -0
- package/dist/presentation/routes/list-provisioner-tokens.d.ts +2 -0
- package/dist/presentation/routes/list-provisioner-tokens.d.ts.map +1 -0
- package/dist/presentation/routes/list-provisioner-tokens.js +32 -0
- package/dist/presentation/routes/list-provisioner-tokens.js.map +1 -0
- package/dist/presentation/routes/mint-registration-tokens.d.ts +2 -0
- package/dist/presentation/routes/mint-registration-tokens.d.ts.map +1 -0
- package/dist/presentation/routes/mint-registration-tokens.js +74 -0
- package/dist/presentation/routes/mint-registration-tokens.js.map +1 -0
- package/dist/presentation/routes/poll-demand.d.ts +2 -0
- package/dist/presentation/routes/poll-demand.d.ts.map +1 -0
- package/dist/presentation/routes/poll-demand.js +53 -0
- package/dist/presentation/routes/poll-demand.js.map +1 -0
- package/dist/presentation/routes/rate-limit.d.ts +4 -0
- package/dist/presentation/routes/rate-limit.d.ts.map +1 -0
- package/dist/presentation/routes/rate-limit.js +94 -0
- package/dist/presentation/routes/rate-limit.js.map +1 -0
- package/dist/presentation/routes/reconcile-provisioned-runners.d.ts +2 -0
- package/dist/presentation/routes/reconcile-provisioned-runners.d.ts.map +1 -0
- package/dist/presentation/routes/reconcile-provisioned-runners.js +27 -0
- package/dist/presentation/routes/reconcile-provisioned-runners.js.map +1 -0
- package/dist/presentation/routes/register.d.ts +2 -0
- package/dist/presentation/routes/register.d.ts.map +1 -0
- package/dist/presentation/routes/register.js +63 -0
- package/dist/presentation/routes/register.js.map +1 -0
- package/dist/presentation/routes/report-provisioned-runners.d.ts +2 -0
- package/dist/presentation/routes/report-provisioned-runners.d.ts.map +1 -0
- package/dist/presentation/routes/report-provisioned-runners.js +37 -0
- package/dist/presentation/routes/report-provisioned-runners.js.map +1 -0
- package/dist/presentation/routes/request-job.d.ts +2 -0
- package/dist/presentation/routes/request-job.d.ts.map +1 -0
- package/dist/presentation/routes/request-job.js +45 -0
- package/dist/presentation/routes/request-job.js.map +1 -0
- package/dist/presentation/routes/revoke-manual-registration-token.d.ts +2 -0
- package/dist/presentation/routes/revoke-manual-registration-token.d.ts.map +1 -0
- package/dist/presentation/routes/revoke-manual-registration-token.js +42 -0
- package/dist/presentation/routes/revoke-manual-registration-token.js.map +1 -0
- package/dist/presentation/routes/revoke-provisioner-token.d.ts +2 -0
- package/dist/presentation/routes/revoke-provisioner-token.d.ts.map +1 -0
- package/dist/presentation/routes/revoke-provisioner-token.js +44 -0
- package/dist/presentation/routes/revoke-provisioner-token.js.map +1 -0
- package/dist/presentation/routes/workspace-membership.d.ts +6 -0
- package/dist/presentation/routes/workspace-membership.d.ts.map +1 -0
- package/dist/presentation/routes/workspace-membership.js +6 -0
- package/dist/presentation/routes/workspace-membership.js.map +1 -0
- package/dist/presentation/subscribers/on-workflows-job-execution-timed-out.d.ts +3 -0
- package/dist/presentation/subscribers/on-workflows-job-execution-timed-out.d.ts.map +1 -0
- package/dist/presentation/subscribers/on-workflows-job-execution-timed-out.js +14 -0
- package/dist/presentation/subscribers/on-workflows-job-execution-timed-out.js.map +1 -0
- package/dist/temporal/activities/index.d.ts +9 -0
- package/dist/temporal/activities/index.d.ts.map +1 -0
- package/dist/temporal/activities/index.js +12 -0
- package/dist/temporal/activities/index.js.map +1 -0
- package/dist/temporal/activities/maintenance-activities.d.ts +31 -0
- package/dist/temporal/activities/maintenance-activities.d.ts.map +1 -0
- package/dist/temporal/activities/maintenance-activities.js +18 -0
- package/dist/temporal/activities/maintenance-activities.js.map +1 -0
- package/dist/temporal/constants.d.ts +2 -0
- package/dist/temporal/constants.d.ts.map +1 -0
- package/dist/temporal/constants.js +3 -0
- package/dist/temporal/constants.js.map +1 -0
- package/dist/temporal/workflows/index.d.ts +2 -0
- package/dist/temporal/workflows/index.d.ts.map +1 -0
- package/dist/temporal/workflows/index.js +3 -0
- package/dist/temporal/workflows/index.js.map +1 -0
- package/dist/temporal/workflows/stuck-job-detector.d.ts +2 -0
- package/dist/temporal/workflows/stuck-job-detector.d.ts.map +1 -0
- package/dist/temporal/workflows/stuck-job-detector.js +61 -0
- package/dist/temporal/workflows/stuck-job-detector.js.map +1 -0
- package/dist/tsconfig.test.tsbuildinfo +1 -0
- package/drizzle/0000_initial.sql +185 -0
- package/drizzle/meta/0000_snapshot.json +1582 -0
- package/drizzle/meta/_journal.json +13 -0
- package/drizzle.config.ts +7 -0
- package/package.json +82 -0
- package/src/config.test.ts +374 -0
- package/src/config.ts +330 -0
- package/src/core/demand.test.ts +301 -0
- package/src/core/demand.ts +239 -0
- package/src/core/entities/ephemeral-registration-token.ts +13 -0
- package/src/core/entities/manual-registration-token.ts +11 -0
- package/src/core/entities/provisioned-runner.ts +30 -0
- package/src/core/entities/provisioner-token.ts +16 -0
- package/src/core/entities/reservation.ts +9 -0
- package/src/core/entities/runner-session.ts +18 -0
- package/src/core/ephemeral-registration-tokens.test.ts +108 -0
- package/src/core/ephemeral-registration-tokens.ts +112 -0
- package/src/core/errors.ts +128 -0
- package/src/core/index.ts +56 -0
- package/src/core/job-executions.ts +47 -0
- package/src/core/maintenance-policy.ts +1 -0
- package/src/core/maintenance.test.ts +251 -0
- package/src/core/maintenance.ts +74 -0
- package/src/core/manual-registration-tokens.test.ts +44 -0
- package/src/core/manual-registration-tokens.ts +51 -0
- package/src/core/provisioned-runners.test.ts +101 -0
- package/src/core/provisioned-runners.ts +301 -0
- package/src/core/provisioner-tokens.test.ts +61 -0
- package/src/core/provisioner-tokens.ts +61 -0
- package/src/core/rate-limit.test.ts +158 -0
- package/src/core/rate-limit.ts +121 -0
- package/src/core/runner-sessions.test.ts +209 -0
- package/src/core/runner-sessions.ts +66 -0
- package/src/core/runner-tool-capabilities.test.ts +141 -0
- package/src/core/runner-tool-capabilities.ts +75 -0
- package/src/db/db.ts +38 -0
- package/src/db/ephemeral-registration-tokens.test.ts +332 -0
- package/src/db/ephemeral-registration-tokens.ts +348 -0
- package/src/db/index.ts +90 -0
- package/src/db/job-executions.test.ts +1500 -0
- package/src/db/job-executions.ts +647 -0
- package/src/db/manual-registration-tokens.test.ts +99 -0
- package/src/db/manual-registration-tokens.ts +87 -0
- package/src/db/provisioned-runners.test.ts +1812 -0
- package/src/db/provisioned-runners.ts +886 -0
- package/src/db/provisioner-tokens.test.ts +133 -0
- package/src/db/provisioner-tokens.ts +142 -0
- package/src/db/rate-limits.test.ts +74 -0
- package/src/db/rate-limits.ts +69 -0
- package/src/db/reservations.test.ts +399 -0
- package/src/db/reservations.ts +296 -0
- package/src/db/runner-sessions.test.ts +153 -0
- package/src/db/runner-sessions.ts +97 -0
- package/src/db/schema/common.ts +3 -0
- package/src/db/schema/ephemeral-registration-tokens.ts +58 -0
- package/src/db/schema/manual-registration-tokens.ts +40 -0
- package/src/db/schema/outbox.ts +4 -0
- package/src/db/schema/pending-job-executions.ts +25 -0
- package/src/db/schema/provisioned-runners.ts +89 -0
- package/src/db/schema/provisioner-tokens.ts +50 -0
- package/src/db/schema/rate-limits.ts +27 -0
- package/src/db/schema/reservations.ts +38 -0
- package/src/db/schema/runner-sessions.ts +77 -0
- package/src/db/schema/running-job-executions.ts +50 -0
- package/src/index.ts +63 -0
- package/src/metrics/index.ts +13 -0
- package/src/metrics/instance.ts +115 -0
- package/src/metrics/service.ts +22 -0
- package/src/presentation/auth/index.ts +6 -0
- package/src/presentation/auth/provisioner-token-auth.ts +76 -0
- package/src/presentation/auth/runner-registration-token-auth.ts +105 -0
- package/src/presentation/dto/active-provisioner.ts +15 -0
- package/src/presentation/dto/index.ts +13 -0
- package/src/presentation/dto/manual-registration-token.ts +23 -0
- package/src/presentation/dto/mint-registration-tokens.ts +35 -0
- package/src/presentation/dto/poll-demand.ts +20 -0
- package/src/presentation/dto/provisioned-runners.ts +88 -0
- package/src/presentation/dto/provisioner-token.ts +29 -0
- package/src/presentation/index.ts +6 -0
- package/src/presentation/routes/create-manual-registration-token.ts +43 -0
- package/src/presentation/routes/create-provisioner-token.ts +41 -0
- package/src/presentation/routes/get-provisioner-me.ts +22 -0
- package/src/presentation/routes/heartbeat.test.ts +325 -0
- package/src/presentation/routes/heartbeat.ts +80 -0
- package/src/presentation/routes/index.ts +86 -0
- package/src/presentation/routes/list-active-provisioners.ts +25 -0
- package/src/presentation/routes/list-active-runners.test.ts +366 -0
- package/src/presentation/routes/list-active-runners.ts +25 -0
- package/src/presentation/routes/list-manual-registration-tokens.ts +25 -0
- package/src/presentation/routes/list-provisioner-tokens.ts +25 -0
- package/src/presentation/routes/manual-registration-tokens.test.ts +213 -0
- package/src/presentation/routes/mint-registration-tokens.test.ts +453 -0
- package/src/presentation/routes/mint-registration-tokens.ts +82 -0
- package/src/presentation/routes/poll-demand-release.test.ts +80 -0
- package/src/presentation/routes/poll-demand.test.ts +323 -0
- package/src/presentation/routes/poll-demand.ts +56 -0
- package/src/presentation/routes/provisioner-me.test.ts +172 -0
- package/src/presentation/routes/provisioner-tokens.test.ts +219 -0
- package/src/presentation/routes/rate-limit.ts +115 -0
- package/src/presentation/routes/reconcile-provisioned-runners.test.ts +380 -0
- package/src/presentation/routes/reconcile-provisioned-runners.ts +30 -0
- package/src/presentation/routes/register.test.ts +453 -0
- package/src/presentation/routes/register.ts +75 -0
- package/src/presentation/routes/report-provisioned-runners.test.ts +249 -0
- package/src/presentation/routes/report-provisioned-runners.ts +40 -0
- package/src/presentation/routes/request-job.test.ts +222 -0
- package/src/presentation/routes/request-job.ts +47 -0
- package/src/presentation/routes/revoke-manual-registration-token.ts +35 -0
- package/src/presentation/routes/revoke-provisioner-token.ts +37 -0
- package/src/presentation/routes/workspace-membership.ts +9 -0
- package/src/presentation/subscribers/on-workflows-job-execution-timed-out.test.ts +147 -0
- package/src/presentation/subscribers/on-workflows-job-execution-timed-out.ts +17 -0
- package/src/temporal/activities/index.ts +17 -0
- package/src/temporal/activities/maintenance-activities.test.ts +104 -0
- package/src/temporal/activities/maintenance-activities.ts +41 -0
- package/src/temporal/constants.ts +1 -0
- package/src/temporal/workflows/index.ts +1 -0
- package/src/temporal/workflows/stuck-job-detector.test.ts +93 -0
- package/src/temporal/workflows/stuck-job-detector.ts +67 -0
- package/test/env.ts +11 -0
- package/test/factories/ephemeral-registration-token.ts +41 -0
- package/test/factories/manual-registration-token.ts +37 -0
- package/test/factories/pending-job.ts +44 -0
- package/test/factories/provisioned-runner.ts +78 -0
- package/test/factories/provisioner-token.ts +41 -0
- package/test/factories/reservation.ts +33 -0
- package/test/factories/runner-session.ts +32 -0
- package/test/globalSetup.ts +23 -0
- package/test/index.ts +16 -0
- package/test/setup.ts +17 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTH_USER,
|
|
3
|
+
buildUserContext,
|
|
4
|
+
setUserContext,
|
|
5
|
+
type UserContextMembership,
|
|
6
|
+
} from '@shipfox/api-auth-context';
|
|
7
|
+
import type {AuthMethod} from '@shipfox/node-fastify';
|
|
8
|
+
import {ClientError, closeApp, createApp} from '@shipfox/node-fastify';
|
|
9
|
+
import {hashOpaqueToken, tokenTypeParts} from '@shipfox/node-tokens';
|
|
10
|
+
import {eq, sql} from 'drizzle-orm';
|
|
11
|
+
import type {FastifyInstance, FastifyRequest} from 'fastify';
|
|
12
|
+
import {db} from '#db/db.js';
|
|
13
|
+
import {revokeProvisionerToken} from '#db/provisioner-tokens.js';
|
|
14
|
+
import {provisionerTokens} from '#db/schema/provisioner-tokens.js';
|
|
15
|
+
import {createProvisionerTokenAuthMethod} from '#presentation/auth/index.js';
|
|
16
|
+
import {provisionerTokenFactory} from '#test/index.js';
|
|
17
|
+
import {provisionerRoutes} from './index.js';
|
|
18
|
+
|
|
19
|
+
const userId = crypto.randomUUID();
|
|
20
|
+
let authenticatedMemberships: ReadonlyArray<UserContextMembership> = [];
|
|
21
|
+
|
|
22
|
+
const fakeUserAuth: AuthMethod = {
|
|
23
|
+
name: AUTH_USER,
|
|
24
|
+
authenticate: (request: FastifyRequest) => {
|
|
25
|
+
if (request.headers.authorization !== 'Bearer user') {
|
|
26
|
+
throw new ClientError('Invalid user token', 'unauthorized', {status: 401});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
setUserContext(
|
|
30
|
+
request,
|
|
31
|
+
buildUserContext({
|
|
32
|
+
userId,
|
|
33
|
+
email: 'user@example.com',
|
|
34
|
+
memberships: authenticatedMemberships,
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
return Promise.resolve();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
describe('provisioner token routes', () => {
|
|
42
|
+
let app: FastifyInstance;
|
|
43
|
+
let workspaceId: string;
|
|
44
|
+
|
|
45
|
+
beforeEach(async () => {
|
|
46
|
+
await closeApp();
|
|
47
|
+
workspaceId = crypto.randomUUID();
|
|
48
|
+
authenticatedMemberships = [{workspaceId, role: 'admin'}];
|
|
49
|
+
app = await createApp({
|
|
50
|
+
auth: [fakeUserAuth, createProvisionerTokenAuthMethod()],
|
|
51
|
+
routes: provisionerRoutes,
|
|
52
|
+
swagger: false,
|
|
53
|
+
});
|
|
54
|
+
await app.ready();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterEach(async () => {
|
|
58
|
+
await closeApp();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('uses user auth for provisioner token management routes', () => {
|
|
62
|
+
expect(provisionerRoutes[0]?.auth).toBe(AUTH_USER);
|
|
63
|
+
expect(provisionerRoutes[1]?.auth).toBe(AUTH_USER);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('GET /workspaces/:workspaceId/provisioners/tokens', () => {
|
|
67
|
+
it('returns 401 without user auth', async () => {
|
|
68
|
+
const res = await app.inject({
|
|
69
|
+
method: 'GET',
|
|
70
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(res.statusCode).toBe(401);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('returns 403 when the user is not a workspace member', async () => {
|
|
77
|
+
authenticatedMemberships = [{workspaceId: crypto.randomUUID(), role: 'admin'}];
|
|
78
|
+
|
|
79
|
+
const res = await app.inject({
|
|
80
|
+
method: 'GET',
|
|
81
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
82
|
+
headers: {authorization: 'Bearer user'},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(res.statusCode).toBe(403);
|
|
86
|
+
expect(res.json().code).toBe('forbidden');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('returns only usable tokens for the workspace', async () => {
|
|
90
|
+
const usable = await provisionerTokenFactory.create({workspaceId, name: 'usable'});
|
|
91
|
+
const expired = await provisionerTokenFactory.create({
|
|
92
|
+
workspaceId,
|
|
93
|
+
name: 'expired',
|
|
94
|
+
expiresAt: new Date(Date.now() - 60_000),
|
|
95
|
+
});
|
|
96
|
+
const revoked = await provisionerTokenFactory.create({workspaceId, name: 'revoked'});
|
|
97
|
+
await provisionerTokenFactory.create({
|
|
98
|
+
workspaceId: crypto.randomUUID(),
|
|
99
|
+
name: 'other workspace',
|
|
100
|
+
});
|
|
101
|
+
await revokeProvisionerToken({tokenId: revoked.id, workspaceId, revokedByUserId: userId});
|
|
102
|
+
|
|
103
|
+
const res = await app.inject({
|
|
104
|
+
method: 'GET',
|
|
105
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
106
|
+
headers: {authorization: 'Bearer user'},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
expect(res.statusCode).toBe(200);
|
|
110
|
+
expect(res.json().tokens.map((token: {id: string}) => token.id)).toEqual([usable.id]);
|
|
111
|
+
expect(res.json().tokens.map((token: {id: string}) => token.id)).not.toContain(expired.id);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('GET /workspaces/:workspaceId/provisioners/active', () => {
|
|
116
|
+
it('returns active provisioners for the workspace', async () => {
|
|
117
|
+
const active = await provisionerTokenFactory.create({workspaceId, name: 'active'});
|
|
118
|
+
await db().execute(
|
|
119
|
+
sql`UPDATE runners_provisioner_tokens SET last_seen_at = now() WHERE id = ${active.id}`,
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const res = await app.inject({
|
|
123
|
+
method: 'GET',
|
|
124
|
+
url: `/workspaces/${workspaceId}/provisioners/active`,
|
|
125
|
+
headers: {authorization: 'Bearer user'},
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(res.statusCode).toBe(200);
|
|
129
|
+
expect(res.json()).toEqual({
|
|
130
|
+
provisioners: [
|
|
131
|
+
expect.objectContaining({
|
|
132
|
+
id: active.id,
|
|
133
|
+
name: 'active',
|
|
134
|
+
prefix: active.prefix,
|
|
135
|
+
last_seen_at: expect.any(String),
|
|
136
|
+
}),
|
|
137
|
+
],
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('POST /workspaces/:workspaceId/provisioners/tokens', () => {
|
|
143
|
+
it('returns 401 without user auth', async () => {
|
|
144
|
+
const res = await app.inject({
|
|
145
|
+
method: 'POST',
|
|
146
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
147
|
+
payload: {name: 'scaler'},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(res.statusCode).toBe(401);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('creates a workspace-scoped provisioner token and returns the raw token once', async () => {
|
|
154
|
+
const res = await app.inject({
|
|
155
|
+
method: 'POST',
|
|
156
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
157
|
+
headers: {authorization: 'Bearer user'},
|
|
158
|
+
payload: {name: 'scaler', ttl_seconds: 3600},
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(res.statusCode).toBe(201);
|
|
162
|
+
const body = res.json();
|
|
163
|
+
expect(body.raw_token.startsWith(`sf_${tokenTypeParts.provisionerToken}_`)).toBe(true);
|
|
164
|
+
expect(body.prefix).toBe(body.raw_token.slice(0, 12));
|
|
165
|
+
expect(body.name).toBe('scaler');
|
|
166
|
+
expect(body.workspace_id).toBe(workspaceId);
|
|
167
|
+
expect(body.created_by_user_id).toBe(userId);
|
|
168
|
+
expect(body.expires_at).not.toBeNull();
|
|
169
|
+
|
|
170
|
+
const rows = await db()
|
|
171
|
+
.select()
|
|
172
|
+
.from(provisionerTokens)
|
|
173
|
+
.where(eq(provisionerTokens.id, body.id));
|
|
174
|
+
expect(rows[0]?.hashedToken).toBe(hashOpaqueToken(body.raw_token));
|
|
175
|
+
expect(rows[0]?.hashedToken).not.toBe(body.raw_token);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('rejects a token TTL above one year', async () => {
|
|
179
|
+
const res = await app.inject({
|
|
180
|
+
method: 'POST',
|
|
181
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens`,
|
|
182
|
+
headers: {authorization: 'Bearer user'},
|
|
183
|
+
payload: {ttl_seconds: 31_536_001},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
expect(res.statusCode).toBe(400);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('POST /workspaces/:workspaceId/provisioners/tokens/:tokenId/revoke', () => {
|
|
191
|
+
it('revokes a token owned by the authenticated workspace', async () => {
|
|
192
|
+
const token = await provisionerTokenFactory.create({workspaceId});
|
|
193
|
+
|
|
194
|
+
const res = await app.inject({
|
|
195
|
+
method: 'POST',
|
|
196
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens/${token.id}/revoke`,
|
|
197
|
+
headers: {authorization: 'Bearer user'},
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
expect(res.statusCode).toBe(200);
|
|
201
|
+
expect(res.json().id).toBe(token.id);
|
|
202
|
+
expect(res.json().revoked_at).not.toBeNull();
|
|
203
|
+
expect(res.json().revoked_by_user_id).toBe(userId);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('returns 404 for a token owned by another workspace', async () => {
|
|
207
|
+
const token = await provisionerTokenFactory.create({workspaceId: crypto.randomUUID()});
|
|
208
|
+
|
|
209
|
+
const res = await app.inject({
|
|
210
|
+
method: 'POST',
|
|
211
|
+
url: `/workspaces/${workspaceId}/provisioners/tokens/${token.id}/revoke`,
|
|
212
|
+
headers: {authorization: 'Bearer user'},
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
expect(res.statusCode).toBe(404);
|
|
216
|
+
expect(res.json().code).toBe('not-found');
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import {requireProvisionerContext} from '@shipfox/api-auth-context';
|
|
2
|
+
import {ClientError, type FastifyReply, type FastifyRequest} from '@shipfox/node-fastify';
|
|
3
|
+
import {config} from '#config.js';
|
|
4
|
+
import {
|
|
5
|
+
checkRunnersRateLimit,
|
|
6
|
+
RunnersRateLimitExceededError,
|
|
7
|
+
RunnersRateLimitUnavailableError,
|
|
8
|
+
} from '#core/rate-limit.js';
|
|
9
|
+
import {getRunnerContext} from '#presentation/auth/index.js';
|
|
10
|
+
|
|
11
|
+
function routeName(request: FastifyRequest): string {
|
|
12
|
+
return request.routeOptions.url ?? request.url.split('?')[0] ?? 'unknown';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function enforceRateLimit(params: {
|
|
16
|
+
request: FastifyRequest;
|
|
17
|
+
reply: FastifyReply;
|
|
18
|
+
action: 'provisioner-mint' | 'ephemeral-register';
|
|
19
|
+
scope: 'provisioner' | 'ephemeral-token';
|
|
20
|
+
identifier: string;
|
|
21
|
+
limit: number;
|
|
22
|
+
windowSeconds: number;
|
|
23
|
+
}): Promise<void> {
|
|
24
|
+
try {
|
|
25
|
+
await checkRunnersRateLimit({
|
|
26
|
+
action: params.action,
|
|
27
|
+
scope: params.scope,
|
|
28
|
+
identifier: params.identifier,
|
|
29
|
+
limit: params.limit,
|
|
30
|
+
windowSeconds: params.windowSeconds,
|
|
31
|
+
});
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (error instanceof RunnersRateLimitExceededError) {
|
|
34
|
+
params.request.log.warn(
|
|
35
|
+
{
|
|
36
|
+
action: error.action,
|
|
37
|
+
scope: error.scope,
|
|
38
|
+
route: routeName(params.request),
|
|
39
|
+
retryAfterSeconds: error.retryAfterSeconds,
|
|
40
|
+
identifierHmacPrefix: error.identifierHmacPrefix,
|
|
41
|
+
},
|
|
42
|
+
'Runners rate limit blocked request',
|
|
43
|
+
);
|
|
44
|
+
params.reply.header('Retry-After', String(error.retryAfterSeconds));
|
|
45
|
+
throw new ClientError('Rate limit exceeded', 'rate-limited', {
|
|
46
|
+
status: 429,
|
|
47
|
+
details: {retry_after_seconds: error.retryAfterSeconds},
|
|
48
|
+
data: {
|
|
49
|
+
action: error.action,
|
|
50
|
+
scope: error.scope,
|
|
51
|
+
route: routeName(params.request),
|
|
52
|
+
identifierHmacPrefix: error.identifierHmacPrefix,
|
|
53
|
+
},
|
|
54
|
+
cause: error,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (error instanceof RunnersRateLimitUnavailableError) {
|
|
59
|
+
params.request.log.error(
|
|
60
|
+
{
|
|
61
|
+
action: error.action,
|
|
62
|
+
scope: error.scope,
|
|
63
|
+
route: routeName(params.request),
|
|
64
|
+
identifierHmacPrefix: error.identifierHmacPrefix,
|
|
65
|
+
err: error,
|
|
66
|
+
},
|
|
67
|
+
'Runners rate limiter unavailable',
|
|
68
|
+
);
|
|
69
|
+
throw new ClientError('Runners rate limiter unavailable', 'runners-rate-limit-unavailable', {
|
|
70
|
+
status: 503,
|
|
71
|
+
data: {
|
|
72
|
+
action: error.action,
|
|
73
|
+
scope: error.scope,
|
|
74
|
+
route: routeName(params.request),
|
|
75
|
+
identifierHmacPrefix: error.identifierHmacPrefix,
|
|
76
|
+
},
|
|
77
|
+
cause: error,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function createProvisionerMintRateLimitPreHandler() {
|
|
86
|
+
return async (request: FastifyRequest, reply: FastifyReply): Promise<void> => {
|
|
87
|
+
const {provisionerTokenId} = requireProvisionerContext(request);
|
|
88
|
+
await enforceRateLimit({
|
|
89
|
+
request,
|
|
90
|
+
reply,
|
|
91
|
+
action: 'provisioner-mint',
|
|
92
|
+
scope: 'provisioner',
|
|
93
|
+
identifier: provisionerTokenId,
|
|
94
|
+
limit: config.PROVISIONER_MINT_RATE_LIMIT_MAX_REQUESTS,
|
|
95
|
+
windowSeconds: config.PROVISIONER_MINT_RATE_LIMIT_WINDOW_SECONDS,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function createEphemeralRegisterRateLimitPreHandler() {
|
|
101
|
+
return async (request: FastifyRequest, reply: FastifyReply): Promise<void> => {
|
|
102
|
+
const runner = getRunnerContext(request);
|
|
103
|
+
if (runner.kind !== 'ephemeral') return;
|
|
104
|
+
|
|
105
|
+
await enforceRateLimit({
|
|
106
|
+
request,
|
|
107
|
+
reply,
|
|
108
|
+
action: 'ephemeral-register',
|
|
109
|
+
scope: 'ephemeral-token',
|
|
110
|
+
identifier: runner.ephemeralTokenId,
|
|
111
|
+
limit: config.EPHEMERAL_REGISTER_RATE_LIMIT_MAX_REQUESTS,
|
|
112
|
+
windowSeconds: config.EPHEMERAL_REGISTER_RATE_LIMIT_WINDOW_SECONDS,
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
}
|