@pipeline-builder/api-core 7.4.2 → 7.4.4
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/lib/types/error-codes.d.ts +4 -0
- package/lib/types/error-codes.js +6 -1
- package/lib/types/pipeline-runners.d.ts +168 -5
- package/lib/types/pipeline-runners.js +87 -6
- package/lib/types/pipeline-source.d.ts +169 -1
- package/lib/types/pipeline-source.js +320 -2
- package/lib/validation/ai-schemas.d.ts +15 -0
- package/lib/validation/ai-schemas.js +27 -3
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What a pipeline's SOURCE (`props.synth.source`) must be to deploy, as one
|
|
3
|
-
* dependency-free module
|
|
3
|
+
* dependency-free module (its one import is the equally dependency-free
|
|
4
|
+
* `pipeline-runners` catalog): the pipeline service refuses a write whose source
|
|
4
5
|
* fails {@link pipelineSourceProblem} (400 PIPELINE_SOURCE_INVALID — create,
|
|
5
6
|
* update, bulk, and `POST /pipelines/validate` reports it), and the browser
|
|
6
7
|
* imports it (`@pipeline-builder/api-core/pipeline-source`) to check the
|
|
@@ -10,7 +11,17 @@
|
|
|
10
11
|
* that reads GitHub, GitLab, Bitbucket and their self-managed servers without a
|
|
11
12
|
* token baked into the deploy account. Without a `connectionArn` the synth
|
|
12
13
|
* fails in the deploy job, long after the create looked fine.
|
|
14
|
+
*
|
|
15
|
+
* Also the source-connection vocabulary both ends of the runner's
|
|
16
|
+
* list_sources / check_source share: matching a connection to a repository
|
|
17
|
+
* host, the GitHub token secret rule (the deploy job's and the runner's), the
|
|
18
|
+
* runner's `sources` reply parser and the picker's {@link SourceOptionsDto}.
|
|
19
|
+
*
|
|
20
|
+
* And inspect_repository's: which GitHub reads a claim may ask for
|
|
21
|
+
* ({@link repositoryReadProblem}) and what a runner's answer to each may hold
|
|
22
|
+
* ({@link parseRunnerRepositoryReads}, {@link parseRepositoryReadBody}).
|
|
13
23
|
*/
|
|
24
|
+
import { type RepositoryRead, type SourceOptionsUnavailableReason } from './pipeline-runners.js';
|
|
14
25
|
/**
|
|
15
26
|
* An AWS CodeConnections connection ARN: the current `codeconnections` service
|
|
16
27
|
* prefix or the legacy `codestar-connections` one, any partition.
|
|
@@ -105,3 +116,160 @@ export declare const GIT_PROVIDERS: {
|
|
|
105
116
|
export type GitProvider = keyof typeof GIT_PROVIDERS;
|
|
106
117
|
/** The provider a hostname names (exact match), else `unknown`. */
|
|
107
118
|
export declare function providerForHost(host: string): GitProvider;
|
|
119
|
+
/** The CodeConnections provider types a pipeline source can read through. */
|
|
120
|
+
export declare const SOURCE_CONNECTION_PROVIDER_TYPES: readonly ['GitHub', 'GitHubEnterpriseServer', 'GitLab', 'GitLabSelfManaged', 'Bitbucket'];
|
|
121
|
+
export type SourceConnectionProviderType = (typeof SOURCE_CONNECTION_PROVIDER_TYPES)[number];
|
|
122
|
+
/** A CodeConnections connection's status: `PENDING` until its handshake is finished in the console. */
|
|
123
|
+
export declare const SOURCE_CONNECTION_STATUSES: readonly ['PENDING', 'AVAILABLE', 'ERROR'];
|
|
124
|
+
export type SourceConnectionStatus = (typeof SOURCE_CONNECTION_STATUSES)[number];
|
|
125
|
+
/** Where a repository lives: its (lowercased) host, the owner (first path segment) and the `owner/…/repo` path. */
|
|
126
|
+
export interface RepositoryLocation {
|
|
127
|
+
host: string;
|
|
128
|
+
owner: string;
|
|
129
|
+
path: string;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The host, owner and path of a repository URL — https (browse paths such as
|
|
133
|
+
* `/tree/…`, `/-/tree/…`, `/src/…` and a `.git` suffix removed) or scp-style
|
|
134
|
+
* ssh (`git@host:owner/repo.git`). Null when it names no `owner/repo`.
|
|
135
|
+
*/
|
|
136
|
+
export declare function repositoryLocation(gitUrl: string): RepositoryLocation | null;
|
|
137
|
+
/** The partition, region and account of a CodeConnections connection ARN, or null for anything else. */
|
|
138
|
+
export declare function connectionArnParts(arn: string): {
|
|
139
|
+
partition: string;
|
|
140
|
+
region: string;
|
|
141
|
+
accountId: string;
|
|
142
|
+
} | null;
|
|
143
|
+
/**
|
|
144
|
+
* Whether a connection can serve a repository on `repoHost`: a public host by
|
|
145
|
+
* the provider type (github.com → GitHub, …); any other host only through a
|
|
146
|
+
* self-managed connection whose host endpoint names that same host. It cannot
|
|
147
|
+
* say whether the connection's installation covers the repository's OWNER —
|
|
148
|
+
* AWS exposes no such lookup — so a match is a candidate, not a guarantee.
|
|
149
|
+
*/
|
|
150
|
+
export declare function connectionMatchesRepository(connection: {
|
|
151
|
+
providerType: SourceConnectionProviderType;
|
|
152
|
+
hostEndpoint?: string | null;
|
|
153
|
+
}, repoHost: string): boolean;
|
|
154
|
+
/** What a secret lookup found: null when there is no such secret. Never the value. */
|
|
155
|
+
export type SecretLookup = {
|
|
156
|
+
lastChangedDate: string | null;
|
|
157
|
+
} | null;
|
|
158
|
+
/** The GitHub token secret chosen for a source, and whether it exists. */
|
|
159
|
+
export interface GitHubTokenSecretChoice {
|
|
160
|
+
/** The secret's name ({@link githubTokenSecretName}). */
|
|
161
|
+
secret: string;
|
|
162
|
+
/** The source owner (lowercased) when it is a valid GitHub owner. */
|
|
163
|
+
owner?: string;
|
|
164
|
+
/** `owner` — the owner's own secret; `org` — the org default. */
|
|
165
|
+
scope: 'owner' | 'org';
|
|
166
|
+
/** The chosen secret as found, or null when it does not exist. */
|
|
167
|
+
found: SecretLookup;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* THE rule for which GitHub token secret a token-less GitHub source reads —
|
|
171
|
+
* shared by the deploy job (which synthesizes with it) and the runner (which
|
|
172
|
+
* offers it in the source picker and checks it before a deploy), so the two can
|
|
173
|
+
* never disagree: the owner's `<prefix>/<orgId>/github-token/<owner>` when it
|
|
174
|
+
* exists, else the org default `<prefix>/<orgId>/github-token` (whether or not
|
|
175
|
+
* that exists: `found` says). An owner outside GitHub's grammar is skipped.
|
|
176
|
+
* `describe` looks a name up; it may throw (access denied), which propagates.
|
|
177
|
+
*/
|
|
178
|
+
export declare function chooseGitHubTokenSecret(a: {
|
|
179
|
+
orgId: string;
|
|
180
|
+
owner?: string;
|
|
181
|
+
prefix?: string;
|
|
182
|
+
}, describe: (name: string) => Promise<SecretLookup>): Promise<GitHubTokenSecretChoice>;
|
|
183
|
+
/** At most this many connections a `sources` reply carries (the rest are reported as `truncated`). */
|
|
184
|
+
export declare const MAX_SOURCE_CONNECTIONS = 100;
|
|
185
|
+
/** One CodeConnections connection, as the runner reports it (no secrets: names, ARNs and states). */
|
|
186
|
+
export interface SourceConnectionDto {
|
|
187
|
+
arn: string;
|
|
188
|
+
name: string;
|
|
189
|
+
providerType: SourceConnectionProviderType;
|
|
190
|
+
status: SourceConnectionStatus;
|
|
191
|
+
/** A self-managed connection's host endpoint (`https://ghe.example.com`), from its CodeConnections host. */
|
|
192
|
+
hostEndpoint?: string;
|
|
193
|
+
}
|
|
194
|
+
/** The GitHub token secret a token-less GitHub source would use (api-core `chooseGitHubTokenSecret`), when it exists. */
|
|
195
|
+
export interface GitHubTokenSecretDto {
|
|
196
|
+
secretName: string;
|
|
197
|
+
/** `owner` — the source owner's own secret; `org` — the org default. */
|
|
198
|
+
scope: 'owner' | 'org';
|
|
199
|
+
/** When the secret was last changed (ISO), or null when AWS did not say. Never its value. */
|
|
200
|
+
lastChangedDate: string | null;
|
|
201
|
+
}
|
|
202
|
+
/** A runner's `sources` answer (beside `outcome`), parsed. */
|
|
203
|
+
export interface RunnerSourcesReply {
|
|
204
|
+
/** The runner's AWS account (every connection ARN is in it). */
|
|
205
|
+
accountId: string;
|
|
206
|
+
region: string;
|
|
207
|
+
/** The connections that match the repository, at most {@link MAX_SOURCE_CONNECTIONS}. */
|
|
208
|
+
connections: SourceConnectionDto[];
|
|
209
|
+
githubToken: GitHubTokenSecretDto | null;
|
|
210
|
+
/** The account had more matching connections than were sent. */
|
|
211
|
+
truncated: boolean;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* A runner's `sources` reply, kept to what can be trusted: null unless it
|
|
215
|
+
* carries a 12-digit account, a region and a connection list; connections that
|
|
216
|
+
* are malformed or not in that account and region are dropped, and at most
|
|
217
|
+
* {@link MAX_SOURCE_CONNECTIONS} are kept (`truncated` then says so).
|
|
218
|
+
*/
|
|
219
|
+
export declare function parseRunnerSourcesReply(raw: unknown): RunnerSourcesReply | null;
|
|
220
|
+
/**
|
|
221
|
+
* `GET /pipelines/source-options` — the create review's / edit page's Source
|
|
222
|
+
* connection picker. Available: the matching connections, the GitHub token
|
|
223
|
+
* secret (github.com only, when it exists), the runner's account (to warn about
|
|
224
|
+
* a pasted ARN from another account) and the org's last-used connection for the
|
|
225
|
+
* provider. Unavailable: the reason, and for an out-of-date runner the command
|
|
226
|
+
* that updates it.
|
|
227
|
+
*/
|
|
228
|
+
export type SourceOptionsDto = {
|
|
229
|
+
available: true;
|
|
230
|
+
runnerId: string;
|
|
231
|
+
region: string;
|
|
232
|
+
runnerAccountId: string;
|
|
233
|
+
connections: SourceConnectionDto[];
|
|
234
|
+
githubToken: GitHubTokenSecretDto | null;
|
|
235
|
+
truncated: boolean;
|
|
236
|
+
lastUsedConnectionArn: string | null;
|
|
237
|
+
} | {
|
|
238
|
+
available: false;
|
|
239
|
+
reason: SourceOptionsUnavailableReason;
|
|
240
|
+
updateCommand?: string;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Whether a repository is public, from its host's own flag (GitHub `private` /
|
|
244
|
+
* `visibility`, GitLab `visibility`, Bitbucket `is_private`; GitHub's and
|
|
245
|
+
* GitLab's `internal` count as private). `unknown` when the host said nothing
|
|
246
|
+
* or the repository wasn't read. The from-URL analysis's `visibility`.
|
|
247
|
+
*/
|
|
248
|
+
export type RepoVisibility = 'public' | 'private' | 'unknown';
|
|
249
|
+
/**
|
|
250
|
+
* Why `raw` is not a read an inspect_repository claim may carry, or null: the
|
|
251
|
+
* repository's metadata, its languages, or one path's contents on one ref —
|
|
252
|
+
* a path inside the repository ('' = its root), never `.`, `..` or an empty
|
|
253
|
+
* segment, so it can't step outside `/repos/<owner>/<repo>/contents/`.
|
|
254
|
+
*/
|
|
255
|
+
export declare function repositoryReadProblem(raw: unknown): string | null;
|
|
256
|
+
/** One read's answer: GitHub's status, and for a 2xx the projected body. */
|
|
257
|
+
export interface RepositoryReadResult {
|
|
258
|
+
status: number;
|
|
259
|
+
body?: unknown;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* A runner's `repository_reads` reply: one `{ status, body? }` per read, in
|
|
263
|
+
* order — null unless every entry has an HTTP status. Bodies are checked per
|
|
264
|
+
* read by {@link parseRepositoryReadBody} where the read is known.
|
|
265
|
+
*/
|
|
266
|
+
export declare function parseRunnerRepositoryReads(raw: unknown): RepositoryReadResult[] | null;
|
|
267
|
+
/**
|
|
268
|
+
* What one read's answer may hold — exactly the fields the GitHub analyzer
|
|
269
|
+
* reads — or null when it holds anything else (treated as a failed read):
|
|
270
|
+
* - repo: `default_branch`, `description`, `topics`, `private`, `visibility`;
|
|
271
|
+
* - languages: language → bytes;
|
|
272
|
+
* - contents: a listing as `{ name, type }` (files and directories only, at
|
|
273
|
+
* most {@link INSPECT_MAX_LISTING_ENTRIES}), or one base64 file.
|
|
274
|
+
*/
|
|
275
|
+
export declare function parseRepositoryReadBody(read: RepositoryRead, body: unknown): unknown;
|