11import * as core from "@actions/core" ;
22
33import { ActionsEnv , getActionsEnv } from "./actions-util" ;
4- import { Env } from "./environment" ;
5- import { FeatureEnablement } from "./feature-flags" ;
4+ import type { ApiClient } from "./api-client" ;
5+ import { Env , ReadOnlyEnv } from "./environment" ;
6+ import type { FeatureEnablement } from "./feature-flags" ;
67import { getActionsLogger , Logger } from "./logging" ;
78import {
89 ActionName ,
@@ -11,7 +12,7 @@ import {
1112} from "./status-report" ;
1213import { getEnv , getErrorMessage } from "./util" ;
1314
14- /** Common state that is always available in `ActionState` . */
15+ /** Base state that is available to an Action on startup . */
1516export interface BaseState {
1617 /** The name of the Action. */
1718 name : ActionName ;
@@ -21,6 +22,7 @@ export interface BaseState {
2122
2223/** Describes different state features that an Action may have. */
2324export interface FeatureState {
25+ Base : BaseState ;
2426 Logger : {
2527 /** The logger that is in use. */
2628 logger : Logger ;
@@ -29,10 +31,17 @@ export interface FeatureState {
2931 /** Information about environment variables. */
3032 env : Env ;
3133 } ;
34+ ReadOnlyEnv : {
35+ env : ReadOnlyEnv ;
36+ } ;
3237 Actions : {
3338 /** Access to Actions-related functionality. */
3439 actions : ActionsEnv ;
3540 } ;
41+ Api : {
42+ /** A GitHub API client. */
43+ apiClient : ApiClient ;
44+ } ;
3645 FeatureFlags : {
3746 /** Information about enabled feature flags. */
3847 features : FeatureEnablement ;
@@ -44,7 +53,7 @@ export type StateFeature = keyof FeatureState;
4453
4554/** Constructs the intersection of all state types identifies by `Fs`. */
4655export type FieldsOf < Fs extends readonly StateFeature [ ] > = Fs extends [ ]
47- ? BaseState
56+ ? Record < never , never >
4857 : Fs extends [
4958 infer Head extends StateFeature ,
5059 ...infer Tail extends readonly StateFeature [ ] ,
@@ -60,7 +69,7 @@ export type ActionState<Fs extends readonly StateFeature[]> = FieldsOf<Fs>;
6069 * Each Action can then augment the `state` further if additional features are required.
6170 */
6271export type ActionMain = (
63- state : ActionState < [ "Logger" , "Env" , "Actions" ] > ,
72+ state : ActionState < [ "Base" , " Logger", "Env" , "Actions" ] > ,
6473) => Promise < void > ;
6574
6675/** A specification for a CodeQL Action step. */
0 commit comments