@generacy-ai/generacy-plugin-cloud-build 0.0.0-preview-20260304013206
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/LICENSE +191 -0
- package/README.md +228 -0
- package/dist/auth/auth-provider.d.ts +26 -0
- package/dist/auth/auth-provider.d.ts.map +1 -0
- package/dist/auth/auth-provider.js +72 -0
- package/dist/auth/auth-provider.js.map +1 -0
- package/dist/auth/types.d.ts +26 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +5 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/client.d.ts +43 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +87 -0
- package/dist/client.js.map +1 -0
- package/dist/config/schema.d.ts +73 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +32 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/types.d.ts +30 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +11 -0
- package/dist/config/types.js.map +1 -0
- package/dist/errors.d.ts +75 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +144 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/operations/artifacts.d.ts +35 -0
- package/dist/operations/artifacts.d.ts.map +1 -0
- package/dist/operations/artifacts.js +168 -0
- package/dist/operations/artifacts.js.map +1 -0
- package/dist/operations/builds.d.ts +91 -0
- package/dist/operations/builds.d.ts.map +1 -0
- package/dist/operations/builds.js +397 -0
- package/dist/operations/builds.js.map +1 -0
- package/dist/operations/logs.d.ts +56 -0
- package/dist/operations/logs.d.ts.map +1 -0
- package/dist/operations/logs.js +207 -0
- package/dist/operations/logs.js.map +1 -0
- package/dist/operations/triggers.d.ts +76 -0
- package/dist/operations/triggers.d.ts.map +1 -0
- package/dist/operations/triggers.js +308 -0
- package/dist/operations/triggers.js.map +1 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +270 -0
- package/dist/plugin.js.map +1 -0
- package/dist/streaming/log-stream.d.ts +34 -0
- package/dist/streaming/log-stream.d.ts.map +1 -0
- package/dist/streaming/log-stream.js +89 -0
- package/dist/streaming/log-stream.js.map +1 -0
- package/dist/streaming/types.d.ts +27 -0
- package/dist/streaming/types.d.ts.map +1 -0
- package/dist/streaming/types.js +6 -0
- package/dist/streaming/types.js.map +1 -0
- package/dist/types/artifacts.d.ts +46 -0
- package/dist/types/artifacts.d.ts.map +1 -0
- package/dist/types/artifacts.js +6 -0
- package/dist/types/artifacts.js.map +1 -0
- package/dist/types/builds.d.ts +134 -0
- package/dist/types/builds.d.ts.map +1 -0
- package/dist/types/builds.js +5 -0
- package/dist/types/builds.js.map +1 -0
- package/dist/types/logs.d.ts +18 -0
- package/dist/types/logs.d.ts.map +1 -0
- package/dist/types/logs.js +5 -0
- package/dist/types/logs.js.map +1 -0
- package/dist/types/triggers.d.ts +71 -0
- package/dist/types/triggers.d.ts.map +1 -0
- package/dist/types/triggers.js +5 -0
- package/dist/types/triggers.js.map +1 -0
- package/dist/utils/retry.d.ts +41 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +107 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/validation.d.ts +53 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +75 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 The Generacy AI Authors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# @generacy-ai/generacy-plugin-cloud-build
|
|
2
|
+
|
|
3
|
+
Google Cloud Build integration plugin for Generacy. Enables triggering builds, monitoring status, streaming logs, accessing artifacts, and managing triggers through a typed TypeScript interface.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @generacy-ai/generacy-plugin-cloud-build
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { CloudBuildPlugin } from '@generacy-ai/generacy-plugin-cloud-build';
|
|
15
|
+
|
|
16
|
+
// Create plugin instance
|
|
17
|
+
const plugin = new CloudBuildPlugin({
|
|
18
|
+
projectId: 'my-gcp-project',
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Trigger a build
|
|
22
|
+
const build = await plugin.triggerBuild('my-trigger-id');
|
|
23
|
+
console.log(`Build started: ${build.id}`);
|
|
24
|
+
|
|
25
|
+
// Monitor build status
|
|
26
|
+
const status = await plugin.getBuild(build.id);
|
|
27
|
+
console.log(`Build status: ${status.status}`);
|
|
28
|
+
|
|
29
|
+
// Stream logs
|
|
30
|
+
for await (const log of plugin.streamLogs(build.id)) {
|
|
31
|
+
console.log(`[${log.severity}] ${log.message}`);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
interface CloudBuildConfig {
|
|
39
|
+
projectId: string; // Required: GCP project ID
|
|
40
|
+
location?: string; // Default: 'global'
|
|
41
|
+
serviceAccountKey?: string; // Optional: JSON service account key
|
|
42
|
+
defaultTrigger?: string; // Optional: default trigger ID
|
|
43
|
+
artifactBucket?: string; // Optional: GCS bucket for artifacts
|
|
44
|
+
retry?: {
|
|
45
|
+
maxAttempts?: number; // Default: 3
|
|
46
|
+
initialDelayMs?: number; // Default: 1000
|
|
47
|
+
maxDelayMs?: number; // Default: 30000
|
|
48
|
+
};
|
|
49
|
+
logPollingIntervalMs?: number; // Default: 2000
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Authentication
|
|
54
|
+
|
|
55
|
+
The plugin supports two authentication methods:
|
|
56
|
+
|
|
57
|
+
1. **Service Account Key** (highest priority): Pass the JSON key as a string
|
|
58
|
+
2. **Application Default Credentials (ADC)**: Uses ambient credentials
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Using service account key
|
|
62
|
+
const plugin = new CloudBuildPlugin({
|
|
63
|
+
projectId: 'my-project',
|
|
64
|
+
serviceAccountKey: process.env.GCP_SERVICE_ACCOUNT_KEY,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Using ADC (no explicit credentials)
|
|
68
|
+
const plugin = new CloudBuildPlugin({
|
|
69
|
+
projectId: 'my-project',
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### Build Operations
|
|
76
|
+
|
|
77
|
+
#### `triggerBuild(triggerId: string, source?: BuildSource): Promise<Build>`
|
|
78
|
+
|
|
79
|
+
Trigger a build from an existing trigger.
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const build = await plugin.triggerBuild('my-trigger', {
|
|
83
|
+
repoSource: {
|
|
84
|
+
repoName: 'my-repo',
|
|
85
|
+
branchName: 'main',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### `runBuild(config: BuildConfig): Promise<Build>`
|
|
91
|
+
|
|
92
|
+
Run a build from inline configuration.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const build = await plugin.runBuild({
|
|
96
|
+
steps: [
|
|
97
|
+
{ name: 'node:20', args: ['install'] },
|
|
98
|
+
{ name: 'node:20', args: ['test'] },
|
|
99
|
+
],
|
|
100
|
+
timeout: '3600s',
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### `getBuild(buildId: string): Promise<Build>`
|
|
105
|
+
|
|
106
|
+
Get a single build by ID.
|
|
107
|
+
|
|
108
|
+
#### `listBuilds(filter?: BuildFilter): Promise<PaginatedResult<Build>>`
|
|
109
|
+
|
|
110
|
+
List builds with optional filtering.
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const { items, nextPageToken } = await plugin.listBuilds({
|
|
114
|
+
status: ['SUCCESS', 'FAILURE'],
|
|
115
|
+
triggerId: 'my-trigger',
|
|
116
|
+
pageSize: 20,
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### `cancelBuild(buildId: string): Promise<void>`
|
|
121
|
+
|
|
122
|
+
Cancel a running build.
|
|
123
|
+
|
|
124
|
+
#### `retryBuild(buildId: string): Promise<Build>`
|
|
125
|
+
|
|
126
|
+
Retry a failed build.
|
|
127
|
+
|
|
128
|
+
### Log Streaming
|
|
129
|
+
|
|
130
|
+
#### `streamLogs(buildId: string, options?: LogStreamOptions): AsyncIterable<LogEntry>`
|
|
131
|
+
|
|
132
|
+
Stream logs from a build as an AsyncIterable.
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
for await (const log of plugin.streamLogs(buildId)) {
|
|
136
|
+
if (log.severity === 'ERROR') {
|
|
137
|
+
console.error(log.message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Options:
|
|
143
|
+
- `pollingIntervalMs`: Override default polling interval
|
|
144
|
+
- `startOffset`: Start from a specific log offset
|
|
145
|
+
|
|
146
|
+
### Artifact Operations
|
|
147
|
+
|
|
148
|
+
#### `listArtifacts(buildId: string): Promise<Artifact[]>`
|
|
149
|
+
|
|
150
|
+
List artifacts for a build.
|
|
151
|
+
|
|
152
|
+
#### `getArtifact(buildId: string, path: string): Promise<Buffer>`
|
|
153
|
+
|
|
154
|
+
Download an artifact as a Buffer. Throws if > 100MB.
|
|
155
|
+
|
|
156
|
+
#### `getArtifactStream(buildId: string, path: string): Promise<ReadableStream>`
|
|
157
|
+
|
|
158
|
+
Download an artifact as a ReadableStream. Use for large files.
|
|
159
|
+
|
|
160
|
+
### Trigger Management
|
|
161
|
+
|
|
162
|
+
#### `listTriggers(): Promise<BuildTrigger[]>`
|
|
163
|
+
|
|
164
|
+
List all build triggers.
|
|
165
|
+
|
|
166
|
+
#### `createTrigger(config: TriggerConfig): Promise<BuildTrigger>`
|
|
167
|
+
|
|
168
|
+
Create a new build trigger.
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const trigger = await plugin.createTrigger({
|
|
172
|
+
name: 'my-trigger',
|
|
173
|
+
github: {
|
|
174
|
+
owner: 'my-org',
|
|
175
|
+
name: 'my-repo',
|
|
176
|
+
push: { branch: 'main' },
|
|
177
|
+
},
|
|
178
|
+
filename: 'cloudbuild.yaml',
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### `updateTrigger(triggerId: string, config: Partial<TriggerConfig>): Promise<BuildTrigger>`
|
|
183
|
+
|
|
184
|
+
Update an existing trigger.
|
|
185
|
+
|
|
186
|
+
#### `deleteTrigger(triggerId: string): Promise<void>`
|
|
187
|
+
|
|
188
|
+
Delete a trigger.
|
|
189
|
+
|
|
190
|
+
## Error Handling
|
|
191
|
+
|
|
192
|
+
The plugin throws typed errors for different failure scenarios:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import {
|
|
196
|
+
CloudBuildError,
|
|
197
|
+
AuthError,
|
|
198
|
+
NotFoundError,
|
|
199
|
+
RateLimitError,
|
|
200
|
+
ValidationError,
|
|
201
|
+
isTransientError,
|
|
202
|
+
} from '@generacy-ai/generacy-plugin-cloud-build';
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
await plugin.getBuild('nonexistent');
|
|
206
|
+
} catch (error) {
|
|
207
|
+
if (error instanceof NotFoundError) {
|
|
208
|
+
console.log('Build not found');
|
|
209
|
+
} else if (isTransientError(error)) {
|
|
210
|
+
console.log('Transient error, retry later');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Error Types
|
|
216
|
+
|
|
217
|
+
| Error | Code | Retryable | Description |
|
|
218
|
+
|-------|------|-----------|-------------|
|
|
219
|
+
| `AuthError` | AUTH_FAILED | No | Authentication failed |
|
|
220
|
+
| `NotFoundError` | NOT_FOUND | No | Resource not found |
|
|
221
|
+
| `RateLimitError` | RESOURCE_EXHAUSTED | Yes | Rate limited |
|
|
222
|
+
| `TimeoutError` | DEADLINE_EXCEEDED | Yes | Operation timed out |
|
|
223
|
+
| `ValidationError` | INVALID_ARGUMENT | No | Invalid input |
|
|
224
|
+
| `ServiceUnavailableError` | UNAVAILABLE | Yes | Service unavailable |
|
|
225
|
+
|
|
226
|
+
## License
|
|
227
|
+
|
|
228
|
+
MIT
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication provider for the Cloud Build plugin.
|
|
3
|
+
*
|
|
4
|
+
* Priority order:
|
|
5
|
+
* 1. Explicit serviceAccountKey in config (highest priority)
|
|
6
|
+
* 2. Application Default Credentials (ADC) as fallback
|
|
7
|
+
*/
|
|
8
|
+
import { CloudBuildClient } from '@google-cloud/cloudbuild';
|
|
9
|
+
import { Storage } from '@google-cloud/storage';
|
|
10
|
+
import type { AuthOptions, AuthProvider } from './types.js';
|
|
11
|
+
export declare class DefaultAuthProvider implements AuthProvider {
|
|
12
|
+
private readonly projectId;
|
|
13
|
+
private readonly credentials?;
|
|
14
|
+
private cloudBuildClient?;
|
|
15
|
+
private storageClient?;
|
|
16
|
+
constructor(options: AuthOptions);
|
|
17
|
+
getCloudBuildClient(): CloudBuildClient;
|
|
18
|
+
getStorageClient(): Storage;
|
|
19
|
+
private createCloudBuildClient;
|
|
20
|
+
private createStorageClient;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create an auth provider from options.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createAuthProvider(options: AuthOptions): AuthProvider;
|
|
26
|
+
//# sourceMappingURL=auth-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.d.ts","sourceRoot":"","sources":["../../src/auth/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAA6B,MAAM,YAAY,CAAC;AAGvF,qBAAa,mBAAoB,YAAW,YAAY;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAA4B;IACzD,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,aAAa,CAAC,CAAU;gBAEpB,OAAO,EAAE,WAAW;IAchC,mBAAmB,IAAI,gBAAgB;IAOvC,gBAAgB,IAAI,OAAO;IAO3B,OAAO,CAAC,sBAAsB;IAc9B,OAAO,CAAC,mBAAmB;CAa5B;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,YAAY,CAErE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication provider for the Cloud Build plugin.
|
|
3
|
+
*
|
|
4
|
+
* Priority order:
|
|
5
|
+
* 1. Explicit serviceAccountKey in config (highest priority)
|
|
6
|
+
* 2. Application Default Credentials (ADC) as fallback
|
|
7
|
+
*/
|
|
8
|
+
import { CloudBuildClient } from '@google-cloud/cloudbuild';
|
|
9
|
+
import { Storage } from '@google-cloud/storage';
|
|
10
|
+
import { AuthError } from '../errors.js';
|
|
11
|
+
export class DefaultAuthProvider {
|
|
12
|
+
projectId;
|
|
13
|
+
credentials;
|
|
14
|
+
cloudBuildClient;
|
|
15
|
+
storageClient;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.projectId = options.projectId;
|
|
18
|
+
if (options.serviceAccountKey) {
|
|
19
|
+
try {
|
|
20
|
+
this.credentials = JSON.parse(options.serviceAccountKey);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
throw new AuthError('Invalid service account key JSON', {
|
|
24
|
+
reason: 'Failed to parse serviceAccountKey as JSON',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getCloudBuildClient() {
|
|
30
|
+
if (!this.cloudBuildClient) {
|
|
31
|
+
this.cloudBuildClient = this.createCloudBuildClient();
|
|
32
|
+
}
|
|
33
|
+
return this.cloudBuildClient;
|
|
34
|
+
}
|
|
35
|
+
getStorageClient() {
|
|
36
|
+
if (!this.storageClient) {
|
|
37
|
+
this.storageClient = this.createStorageClient();
|
|
38
|
+
}
|
|
39
|
+
return this.storageClient;
|
|
40
|
+
}
|
|
41
|
+
createCloudBuildClient() {
|
|
42
|
+
if (this.credentials) {
|
|
43
|
+
return new CloudBuildClient({
|
|
44
|
+
projectId: this.projectId,
|
|
45
|
+
credentials: this.credentials,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// Use Application Default Credentials
|
|
49
|
+
return new CloudBuildClient({
|
|
50
|
+
projectId: this.projectId,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
createStorageClient() {
|
|
54
|
+
if (this.credentials) {
|
|
55
|
+
return new Storage({
|
|
56
|
+
projectId: this.projectId,
|
|
57
|
+
credentials: this.credentials,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// Use Application Default Credentials
|
|
61
|
+
return new Storage({
|
|
62
|
+
projectId: this.projectId,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create an auth provider from options.
|
|
68
|
+
*/
|
|
69
|
+
export function createAuthProvider(options) {
|
|
70
|
+
return new DefaultAuthProvider(options);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=auth-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-provider.js","sourceRoot":"","sources":["../../src/auth/auth-provider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH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IAAI,gBAAgB,CAAC;YAC1B,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,IAAI,OAAO,CAAC;gBACjB,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC,CAAC;QACL,CAAC;QAED,sCAAsC;QACtC,OAAO,IAAI,OAAO,CAAC;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication types for the Cloud Build plugin.
|
|
3
|
+
*/
|
|
4
|
+
import type { CloudBuildClient } from '@google-cloud/cloudbuild';
|
|
5
|
+
import type { Storage } from '@google-cloud/storage';
|
|
6
|
+
export interface AuthOptions {
|
|
7
|
+
projectId: string;
|
|
8
|
+
serviceAccountKey?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AuthProvider {
|
|
11
|
+
getCloudBuildClient(): CloudBuildClient;
|
|
12
|
+
getStorageClient(): Storage;
|
|
13
|
+
}
|
|
14
|
+
export interface ServiceAccountCredentials {
|
|
15
|
+
type: string;
|
|
16
|
+
project_id: string;
|
|
17
|
+
private_key_id: string;
|
|
18
|
+
private_key: string;
|
|
19
|
+
client_email: string;
|
|
20
|
+
client_id: string;
|
|
21
|
+
auth_uri: string;
|
|
22
|
+
token_uri: string;
|
|
23
|
+
auth_provider_x509_cert_url: string;
|
|
24
|
+
client_x509_cert_url: string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,YAAY;IAC3B,mBAAmB,IAAI,gBAAgB,CAAC;IACxC,gBAAgB,IAAI,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,2BAA2B,EAAE,MAAM,CAAC;IACpC,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/auth/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Build API client wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Wraps @google-cloud/cloudbuild with:
|
|
5
|
+
* - Authentication integration
|
|
6
|
+
* - Error handling
|
|
7
|
+
* - Retry logic for transient failures
|
|
8
|
+
*/
|
|
9
|
+
import { CloudBuildClient } from '@google-cloud/cloudbuild';
|
|
10
|
+
import { Storage } from '@google-cloud/storage';
|
|
11
|
+
import type { Logger } from 'pino';
|
|
12
|
+
import type { CloudBuildConfig } from './config/types.js';
|
|
13
|
+
import type { AuthProvider } from './auth/types.js';
|
|
14
|
+
import { CloudBuildError } from './errors.js';
|
|
15
|
+
export interface CloudBuildClientWrapper {
|
|
16
|
+
readonly cloudBuild: CloudBuildClient;
|
|
17
|
+
readonly storage: Storage;
|
|
18
|
+
readonly projectId: string;
|
|
19
|
+
readonly location: string;
|
|
20
|
+
/**
|
|
21
|
+
* Execute an operation with retry logic.
|
|
22
|
+
*/
|
|
23
|
+
withRetry<T>(operation: () => Promise<T>, operationName: string): Promise<T>;
|
|
24
|
+
}
|
|
25
|
+
export declare class DefaultCloudBuildClient implements CloudBuildClientWrapper {
|
|
26
|
+
readonly cloudBuild: CloudBuildClient;
|
|
27
|
+
readonly storage: Storage;
|
|
28
|
+
readonly projectId: string;
|
|
29
|
+
readonly location: string;
|
|
30
|
+
private readonly config;
|
|
31
|
+
private readonly logger;
|
|
32
|
+
constructor(config: CloudBuildConfig, logger: Logger, authProvider?: AuthProvider);
|
|
33
|
+
withRetry<T>(operation: () => Promise<T>, operationName: string): Promise<T>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a Cloud Build client wrapper.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createCloudBuildClient(config: CloudBuildConfig, logger: Logger, authProvider?: AuthProvider): CloudBuildClientWrapper;
|
|
39
|
+
/**
|
|
40
|
+
* Map Google Cloud API errors to CloudBuildError.
|
|
41
|
+
*/
|
|
42
|
+
export declare function mapApiError(error: unknown, context?: Record<string, unknown>): CloudBuildError;
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;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