/
constants.ts
127 lines (118 loc) · 2.99 KB
/
constants.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import {getInput} from '@actions/core'
import {isNullOrUndefined} from './util'
/**
* Describes the action interface.
*/
export interface ActionInterface {
/** Deployment token. */
token?: string
/** The template to use. */
template: string
/** The file to replace the content in. */
file: string
/** The minimum amount sponsored to be included. */
minimum: number
/** The maximum amount sponsored to be included. */
maximum: number
/** The marker at which the content should be included within. */
marker: string
/** If the user has no sponsors, we can replace it with a fallback. */
fallback: string
/** Fetches organization level sponsors if true. */
organization: boolean
/** Determines if inactive sponsors should be returned or not. */
activeOnly: boolean
}
/**
* Gets the action configuration.
*/
export const action = {
token: getInput('token'),
template: !isNullOrUndefined(getInput('template'))
? getInput('template')
: `<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="60px" alt="{{{ name }}}" /></a>`,
minimum: !isNullOrUndefined(getInput('minimum'))
? parseInt(getInput('minimum'))
: 0,
maximum: !isNullOrUndefined(getInput('maximum'))
? parseInt(getInput('maximum'))
: 0,
marker: !isNullOrUndefined(getInput('marker'))
? getInput('marker')
: 'sponsors',
file: !isNullOrUndefined(getInput('file')) ? getInput('file') : 'README.md',
fallback: !isNullOrUndefined(getInput('fallback'))
? getInput('fallback')
: ``,
organization: !isNullOrUndefined(getInput('organization'))
? getInput('organization').toLowerCase() === 'true'
: false,
activeOnly: !isNullOrUndefined(getInput('active-only'))
? getInput('active-only').toLowerCase() === 'true'
: false
}
/**
* Describes the sponsor object.
*/
export interface Sponsor {
sponsorEntity: {
name: string | null
login: string
url: string
websiteUrl: string | null
}
createdAt: string
privacyLevel: PrivacyLevel
tier?: {
monthlyPriceInCents?: number
}
}
/**
* Describes the response from the GitHub GraphQL query.
*/
export interface SponsorshipsAsMaintainer {
totalCount: number
pageInfo: {
endCursor: string
}
nodes: Sponsor[]
}
/**
* Describes the response from the GitHub GraphQL query.
*/
export interface GitHubResponse {
data: {
organization?: {
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer
}
viewer?: {
sponsorshipsAsMaintainer: SponsorshipsAsMaintainer
}
}
}
/**
* Describes the action interface.
*/
export type RequiredActionParameters = Pick<ActionInterface, 'token'>
/**
* Privacy levels for the sponsorship.
*/
export enum PrivacyLevel {
PUBLIC = 'PUBLIC',
PRIVATE = 'PRIVATE'
}
/**
* Statuses for the action.
*/
export enum Status {
SUCCESS = 'success',
FAILED = 'failed',
RUNNING = 'running',
SKIPPED = 'skipped'
}
/**
* URLs used within the action.
*/
export enum Urls {
GITHUB_API = 'https://api.github.com'
}