freestyle 0.1.44 → 0.1.46
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/cli.mjs +4 -4
- package/index.cjs +9 -1
- package/index.d.cts +11 -2
- package/index.d.mts +11 -2
- package/index.js +391 -0
- package/index.mjs +9 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -457,7 +457,7 @@ async function getTeamsForCli() {
|
|
|
457
457
|
const stored = loadStoredAuth(config);
|
|
458
458
|
if (!stored?.refreshToken) {
|
|
459
459
|
throw new Error(
|
|
460
|
-
"No authentication found. Please run 'npx freestyle
|
|
460
|
+
"No authentication found. Please run 'npx freestyle@latest login' first."
|
|
461
461
|
);
|
|
462
462
|
}
|
|
463
463
|
const tokenResponse = await refreshStackAccessToken(
|
|
@@ -480,7 +480,7 @@ async function setDefaultTeam(teamId) {
|
|
|
480
480
|
const stored = loadStoredAuth(config);
|
|
481
481
|
if (!stored?.refreshToken) {
|
|
482
482
|
throw new Error(
|
|
483
|
-
"No authentication found. Please run 'npx freestyle
|
|
483
|
+
"No authentication found. Please run 'npx freestyle@latest login' first."
|
|
484
484
|
);
|
|
485
485
|
}
|
|
486
486
|
const auth = {
|
|
@@ -595,14 +595,14 @@ async function getFreestyleClient(teamId) {
|
|
|
595
595
|
const accessToken = await getStackAccessTokenForCli();
|
|
596
596
|
if (!accessToken) {
|
|
597
597
|
console.error(
|
|
598
|
-
"Error: No API key found. Please run 'npx freestyle
|
|
598
|
+
"Error: No API key found. Please run 'npx freestyle@latest login' or set FREESTYLE_API_KEY in your .env file."
|
|
599
599
|
);
|
|
600
600
|
process.exit(1);
|
|
601
601
|
}
|
|
602
602
|
const resolvedTeamId = process.env.FREESTYLE_TEAM_ID ?? getDefaultTeamId();
|
|
603
603
|
if (!resolvedTeamId) {
|
|
604
604
|
console.error(
|
|
605
|
-
"Error: No team selected. Please run 'npx freestyle
|
|
605
|
+
"Error: No team selected. Please run 'npx freestyle@latest login' to set a default team."
|
|
606
606
|
);
|
|
607
607
|
process.exit(1);
|
|
608
608
|
}
|
package/index.cjs
CHANGED
|
@@ -3931,10 +3931,18 @@ class ApiClient {
|
|
|
3931
3931
|
};
|
|
3932
3932
|
return this.fetchFn(url, finalOptions);
|
|
3933
3933
|
}
|
|
3934
|
+
resolveUrl(path, params, query) {
|
|
3935
|
+
return this.buildUrl(path, params, query);
|
|
3936
|
+
}
|
|
3934
3937
|
getRaw(path, options) {
|
|
3935
3938
|
const url = this.buildUrl(path, options?.params, options?.query);
|
|
3936
3939
|
return this.requestRaw("GET", url, void 0, options?.headers);
|
|
3937
3940
|
}
|
|
3941
|
+
postRaw(path, ...args) {
|
|
3942
|
+
const options = args[0];
|
|
3943
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
3944
|
+
return this.requestRaw("POST", url, options?.body, options?.headers);
|
|
3945
|
+
}
|
|
3938
3946
|
get(path, ...args) {
|
|
3939
3947
|
const options = args[0];
|
|
3940
3948
|
const url = this.buildUrl(path, options?.params, options?.query);
|
|
@@ -7559,7 +7567,7 @@ class VmsNamespace {
|
|
|
7559
7567
|
function enhanceError(e) {
|
|
7560
7568
|
if (e instanceof VmSetupFailedError) {
|
|
7561
7569
|
if (!e.message.includes("create --snapshot")) {
|
|
7562
|
-
e.message = `${e.message}. Hint: use \`npx freestyle
|
|
7570
|
+
e.message = `${e.message}. Hint: use \`npx freestyle@latest vm create --snapshot ${e.body.snapshotId} --ssh --delete\` to debug.`;
|
|
7563
7571
|
}
|
|
7564
7572
|
if (e.body.diagnostics) {
|
|
7565
7573
|
const d = e.body.diagnostics;
|
package/index.d.cts
CHANGED
|
@@ -6298,6 +6298,13 @@ type GetPathMap = {
|
|
|
6298
6298
|
};
|
|
6299
6299
|
response: void;
|
|
6300
6300
|
};
|
|
6301
|
+
"/auth/v1/background-test": {
|
|
6302
|
+
options: {
|
|
6303
|
+
query?: GetAuthV1BackgroundTestQueryParams;
|
|
6304
|
+
headers?: Record<string, string>;
|
|
6305
|
+
};
|
|
6306
|
+
response: ResponseGetAuthV1BackgroundTest200;
|
|
6307
|
+
};
|
|
6301
6308
|
"/auth/v1/whoami": {
|
|
6302
6309
|
options?: {
|
|
6303
6310
|
headers?: Record<string, string>;
|
|
@@ -7272,7 +7279,9 @@ declare class ApiClient {
|
|
|
7272
7279
|
private requestRaw;
|
|
7273
7280
|
private request;
|
|
7274
7281
|
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
7282
|
+
resolveUrl(path: string, params?: Record<string, string>, query?: Record<string, any>): string;
|
|
7275
7283
|
getRaw<P extends keyof GetPathMap>(path: P, options?: GetPathMap[P]["options"]): Promise<Response>;
|
|
7284
|
+
postRaw<P extends keyof PostPathMap>(path: P, ...args: PostPathMap[P]["options"] extends undefined ? [options?: PostPathMap[P]["options"]] : [options: PostPathMap[P]["options"]]): Promise<Response>;
|
|
7276
7285
|
get<P extends keyof GetPathMap>(path: P, ...args: GetPathMap[P]["options"] extends undefined ? [options?: GetPathMap[P]["options"]] : [options: GetPathMap[P]["options"]]): Promise<GetPathMap[P]["response"]>;
|
|
7277
7286
|
post<P extends keyof PostPathMap>(path: P, ...args: PostPathMap[P]["options"] extends undefined ? [options?: PostPathMap[P]["options"]] : [options: PostPathMap[P]["options"]]): Promise<PostPathMap[P]["response"]>;
|
|
7278
7287
|
put<P extends keyof PutPathMap>(path: P, ...args: PutPathMap[P]["options"] extends undefined ? [options?: PutPathMap[P]["options"]] : [options: PutPathMap[P]["options"]]): Promise<PutPathMap[P]["response"]>;
|
|
@@ -13380,9 +13389,9 @@ type SystemdServiceInput = Omit<RawSystemdService, "mode" | "exec"> & {
|
|
|
13380
13389
|
*/
|
|
13381
13390
|
bash?: string;
|
|
13382
13391
|
};
|
|
13383
|
-
type VmWaitForConfig = Omit<SystemdServiceInput, "mode" | "exec" | "bash" | "deleteAfterSuccess"> & {
|
|
13392
|
+
type VmWaitForConfig = Partial<Omit<SystemdServiceInput, "mode" | "exec" | "bash" | "deleteAfterSuccess"> & {
|
|
13384
13393
|
intervalSeconds?: number;
|
|
13385
|
-
}
|
|
13394
|
+
}>;
|
|
13386
13395
|
type BackgroundRequestLogger = (message: string) => void;
|
|
13387
13396
|
type SnapshotCreateOptions<T extends Record<string, VmWithLike> = {}> = Omit<PostV1VmsSnapshotsRequestBody, "template"> & {
|
|
13388
13397
|
template?: VmTemplate<T> | PostV1VmsSnapshotsRequestBody["template"];
|
package/index.d.mts
CHANGED
|
@@ -6298,6 +6298,13 @@ type GetPathMap = {
|
|
|
6298
6298
|
};
|
|
6299
6299
|
response: void;
|
|
6300
6300
|
};
|
|
6301
|
+
"/auth/v1/background-test": {
|
|
6302
|
+
options: {
|
|
6303
|
+
query?: GetAuthV1BackgroundTestQueryParams;
|
|
6304
|
+
headers?: Record<string, string>;
|
|
6305
|
+
};
|
|
6306
|
+
response: ResponseGetAuthV1BackgroundTest200;
|
|
6307
|
+
};
|
|
6301
6308
|
"/auth/v1/whoami": {
|
|
6302
6309
|
options?: {
|
|
6303
6310
|
headers?: Record<string, string>;
|
|
@@ -7272,7 +7279,9 @@ declare class ApiClient {
|
|
|
7272
7279
|
private requestRaw;
|
|
7273
7280
|
private request;
|
|
7274
7281
|
fetch(url: string, options?: RequestInit): Promise<Response>;
|
|
7282
|
+
resolveUrl(path: string, params?: Record<string, string>, query?: Record<string, any>): string;
|
|
7275
7283
|
getRaw<P extends keyof GetPathMap>(path: P, options?: GetPathMap[P]["options"]): Promise<Response>;
|
|
7284
|
+
postRaw<P extends keyof PostPathMap>(path: P, ...args: PostPathMap[P]["options"] extends undefined ? [options?: PostPathMap[P]["options"]] : [options: PostPathMap[P]["options"]]): Promise<Response>;
|
|
7276
7285
|
get<P extends keyof GetPathMap>(path: P, ...args: GetPathMap[P]["options"] extends undefined ? [options?: GetPathMap[P]["options"]] : [options: GetPathMap[P]["options"]]): Promise<GetPathMap[P]["response"]>;
|
|
7277
7286
|
post<P extends keyof PostPathMap>(path: P, ...args: PostPathMap[P]["options"] extends undefined ? [options?: PostPathMap[P]["options"]] : [options: PostPathMap[P]["options"]]): Promise<PostPathMap[P]["response"]>;
|
|
7278
7287
|
put<P extends keyof PutPathMap>(path: P, ...args: PutPathMap[P]["options"] extends undefined ? [options?: PutPathMap[P]["options"]] : [options: PutPathMap[P]["options"]]): Promise<PutPathMap[P]["response"]>;
|
|
@@ -13380,9 +13389,9 @@ type SystemdServiceInput = Omit<RawSystemdService, "mode" | "exec"> & {
|
|
|
13380
13389
|
*/
|
|
13381
13390
|
bash?: string;
|
|
13382
13391
|
};
|
|
13383
|
-
type VmWaitForConfig = Omit<SystemdServiceInput, "mode" | "exec" | "bash" | "deleteAfterSuccess"> & {
|
|
13392
|
+
type VmWaitForConfig = Partial<Omit<SystemdServiceInput, "mode" | "exec" | "bash" | "deleteAfterSuccess"> & {
|
|
13384
13393
|
intervalSeconds?: number;
|
|
13385
|
-
}
|
|
13394
|
+
}>;
|
|
13386
13395
|
type BackgroundRequestLogger = (message: string) => void;
|
|
13387
13396
|
type SnapshotCreateOptions<T extends Record<string, VmWithLike> = {}> = Omit<PostV1VmsSnapshotsRequestBody, "template"> & {
|
|
13388
13397
|
template?: VmTemplate<T> | PostV1VmsSnapshotsRequestBody["template"];
|
package/index.js
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// generated/client.ts
|
|
2
|
+
function errorFromJSON(json, statusCode) {
|
|
3
|
+
if (json && typeof json.message === "string") {
|
|
4
|
+
const error = new Error(json.message);
|
|
5
|
+
Object.assign(error, json);
|
|
6
|
+
return error;
|
|
7
|
+
}
|
|
8
|
+
if (json && json.error && typeof json.error === "string") {
|
|
9
|
+
return new Error(json.error);
|
|
10
|
+
}
|
|
11
|
+
if (typeof json === "string") {
|
|
12
|
+
return new Error(json);
|
|
13
|
+
}
|
|
14
|
+
return new Error(`API Error (${statusCode}): ${JSON.stringify(json)}`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class ApiClient {
|
|
18
|
+
baseUrl;
|
|
19
|
+
apiKey;
|
|
20
|
+
fetchFn;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.baseUrl = config.baseUrl || "https://api.freestyle.sh";
|
|
23
|
+
this.apiKey = config.apiKey;
|
|
24
|
+
this.fetchFn = config.fetch || fetch;
|
|
25
|
+
}
|
|
26
|
+
buildUrl(path, params, query) {
|
|
27
|
+
let url = path;
|
|
28
|
+
if (params) {
|
|
29
|
+
for (const [key, value] of Object.entries(params)) {
|
|
30
|
+
url = url.replace(`{${key}}`, encodeURIComponent(value));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (query) {
|
|
34
|
+
const searchParams = new URLSearchParams;
|
|
35
|
+
for (const [key, value] of Object.entries(query)) {
|
|
36
|
+
if (value !== undefined && value !== null) {
|
|
37
|
+
searchParams.append(key, String(value));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const queryString = searchParams.toString();
|
|
41
|
+
if (queryString) {
|
|
42
|
+
url += `?${queryString}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return this.baseUrl + url;
|
|
46
|
+
}
|
|
47
|
+
async request(method, url, body) {
|
|
48
|
+
const headers = {
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
50
|
+
};
|
|
51
|
+
if (body) {
|
|
52
|
+
headers["Content-Type"] = "application/json";
|
|
53
|
+
}
|
|
54
|
+
const response = await this.fetchFn(url, {
|
|
55
|
+
method,
|
|
56
|
+
headers,
|
|
57
|
+
body: body ? JSON.stringify(body) : undefined
|
|
58
|
+
});
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
const errorData = await response.json();
|
|
61
|
+
throw errorFromJSON(errorData, response.status);
|
|
62
|
+
}
|
|
63
|
+
return response.json();
|
|
64
|
+
}
|
|
65
|
+
get(path, ...args) {
|
|
66
|
+
const options = args[0];
|
|
67
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
68
|
+
return this.request("GET", url, options?.body);
|
|
69
|
+
}
|
|
70
|
+
post(path, ...args) {
|
|
71
|
+
const options = args[0];
|
|
72
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
73
|
+
return this.request("POST", url, options?.body);
|
|
74
|
+
}
|
|
75
|
+
put(path, ...args) {
|
|
76
|
+
const options = args[0];
|
|
77
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
78
|
+
return this.request("PUT", url, options?.body);
|
|
79
|
+
}
|
|
80
|
+
delete(path, ...args) {
|
|
81
|
+
const options = args[0];
|
|
82
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
83
|
+
return this.request("DELETE", url, options?.body);
|
|
84
|
+
}
|
|
85
|
+
patch(path, ...args) {
|
|
86
|
+
const options = args[0];
|
|
87
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
88
|
+
return this.request("PATCH", url, options?.body);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// src/index.ts
|
|
92
|
+
class Freestyle {
|
|
93
|
+
apiClient;
|
|
94
|
+
options;
|
|
95
|
+
constructor({ apiKey, baseUrl } = {}) {
|
|
96
|
+
if (!apiKey && !process.env.FREESTYLE_API_KEY) {
|
|
97
|
+
throw new Error("API key is required. Please provide it in the constructor or set the FREESTYLE_API_KEY environment variable.");
|
|
98
|
+
}
|
|
99
|
+
this.options = {
|
|
100
|
+
apiKey: apiKey ?? process.env.FREESTYLE_API_KEY,
|
|
101
|
+
baseUrl: baseUrl ?? process.env.FREESTYLE_API_URL
|
|
102
|
+
};
|
|
103
|
+
this.apiClient = new ApiClient(this.options);
|
|
104
|
+
}
|
|
105
|
+
async executeScript(script, config) {
|
|
106
|
+
return this.apiClient.post("/execute/v1/script", {
|
|
107
|
+
body: { script, config }
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async deployWebV2(body) {
|
|
111
|
+
return this.apiClient.post("/web/v1/deployment", { body });
|
|
112
|
+
}
|
|
113
|
+
async getLogs(deploymentId) {
|
|
114
|
+
return this.apiClient.get("/observability/v1/logs", {
|
|
115
|
+
query: { deploymentId }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async createDomainVerificationRequest(domain) {
|
|
119
|
+
return this.apiClient.post("/domains/v1/verifications", {
|
|
120
|
+
body: { domain }
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async verifyDomainVerificationRequest(id) {
|
|
124
|
+
return this.apiClient.put("/domains/v1/verifications", {
|
|
125
|
+
body: { id }
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async verifyDomain(domain) {
|
|
129
|
+
return this.apiClient.put("/domains/v1/verifications", {
|
|
130
|
+
body: { domain }
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async listDomains(limit, offset) {
|
|
134
|
+
return this.apiClient.get("/domains/v1/domains", {
|
|
135
|
+
query: { limit, offset }
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
async listDomainVerificationRequests() {
|
|
139
|
+
return this.apiClient.get("/domains/v1/verifications", undefined);
|
|
140
|
+
}
|
|
141
|
+
async deleteDomainVerificationRequest(domain, verificationCode) {
|
|
142
|
+
return this.apiClient.delete("/domains/v1/verifications", {
|
|
143
|
+
body: { domain, verificationCode }
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async listWebDeployments(limit, offset) {
|
|
147
|
+
return this.apiClient.get("/web/v1/deployments", {
|
|
148
|
+
query: { limit: limit ?? 50, offset: offset ?? 0 }
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async listExecuteRuns(limit, offset) {
|
|
152
|
+
return this.apiClient.get("/execute/v1/deployments", {
|
|
153
|
+
query: { limit, offset }
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async getExecuteRun(deployment) {
|
|
157
|
+
return this.apiClient.get("/execute/v1/deployments/{deployment}", {
|
|
158
|
+
params: { deployment }
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
async provisionWildcard(domain) {
|
|
162
|
+
return this.apiClient.post("/domains/v1/certs/{domain}/wildcard", {
|
|
163
|
+
params: { domain }
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async insertDomainMapping({
|
|
167
|
+
domain,
|
|
168
|
+
deploymentId
|
|
169
|
+
}) {
|
|
170
|
+
return this.apiClient.post("/domains/v1/mappings/{domain}", {
|
|
171
|
+
params: { domain },
|
|
172
|
+
body: { deploymentId }
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async removeDomainMapping({
|
|
176
|
+
domain
|
|
177
|
+
}) {
|
|
178
|
+
return this.apiClient.delete("/domains/v1/mappings/{domain}", {
|
|
179
|
+
params: { domain }
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
async listDomainMappings({
|
|
183
|
+
domain,
|
|
184
|
+
domainOwnership,
|
|
185
|
+
limit = 10,
|
|
186
|
+
offset = 0
|
|
187
|
+
} = {}) {
|
|
188
|
+
return this.apiClient.get("/domains/v1/mappings", {
|
|
189
|
+
query: { domain, domainOwnership, limit, offset }
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
async createGitRepository(body) {
|
|
193
|
+
return this.apiClient.post("/git/v1/repo", { body });
|
|
194
|
+
}
|
|
195
|
+
async listGitRepositories({
|
|
196
|
+
limit = 10,
|
|
197
|
+
offset = 0
|
|
198
|
+
} = {}) {
|
|
199
|
+
return this.apiClient.get("/git/v1/repo", {
|
|
200
|
+
query: { limit, offset }
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async deleteGitRepository({
|
|
204
|
+
repo
|
|
205
|
+
}) {
|
|
206
|
+
return this.apiClient.delete("/git/v1/repo/{repo}", {
|
|
207
|
+
params: { repo }
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
async createGitIdentity() {
|
|
211
|
+
return this.apiClient.post("/git/v1/identity", undefined);
|
|
212
|
+
}
|
|
213
|
+
async deleteGitIdentity({
|
|
214
|
+
identity
|
|
215
|
+
}) {
|
|
216
|
+
return this.apiClient.delete("/git/v1/identity/{identity}", {
|
|
217
|
+
params: { identity }
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
async grantGitPermission({
|
|
221
|
+
repo,
|
|
222
|
+
identity,
|
|
223
|
+
permission
|
|
224
|
+
}) {
|
|
225
|
+
return this.apiClient.post("/git/v1/identity/{identity}/permissions/{repo}", {
|
|
226
|
+
params: { identity, repo },
|
|
227
|
+
body: { permission }
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async updateGitPermission({
|
|
231
|
+
repo,
|
|
232
|
+
identity,
|
|
233
|
+
permission
|
|
234
|
+
}) {
|
|
235
|
+
return this.apiClient.patch("/git/v1/identity/{identity}/permissions/{repo}", {
|
|
236
|
+
params: { identity, repo },
|
|
237
|
+
body: { permission }
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
async revokeGitPermission({
|
|
241
|
+
repo,
|
|
242
|
+
identity
|
|
243
|
+
}) {
|
|
244
|
+
return this.apiClient.delete("/git/v1/identity/{identity}/permissions/{repo}", {
|
|
245
|
+
params: { identity, repo }
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
async listGitPermissions({
|
|
249
|
+
identity,
|
|
250
|
+
limit,
|
|
251
|
+
offset
|
|
252
|
+
}) {
|
|
253
|
+
return this.apiClient.get("/git/v1/identity/{identity}/permissions", {
|
|
254
|
+
params: { identity },
|
|
255
|
+
query: { limit, offset }
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
async getGitPermission({
|
|
259
|
+
repo,
|
|
260
|
+
identity
|
|
261
|
+
}) {
|
|
262
|
+
return this.apiClient.get("/git/v1/identity/{identity}/permissions/{repo}", {
|
|
263
|
+
params: { identity, repo }
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
async createGitAccessToken({
|
|
267
|
+
identity
|
|
268
|
+
}) {
|
|
269
|
+
return this.apiClient.post("/git/v1/identity/{identity}/tokens", {
|
|
270
|
+
params: { identity }
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
async revokeGitAccessToken({
|
|
274
|
+
identity,
|
|
275
|
+
tokenId
|
|
276
|
+
}) {
|
|
277
|
+
return this.apiClient.delete("/git/v1/identity/{identity}/tokens", {
|
|
278
|
+
params: { identity },
|
|
279
|
+
body: { tokenId }
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
async listGitAccessTokens({
|
|
283
|
+
identity
|
|
284
|
+
}) {
|
|
285
|
+
return this.apiClient.get("/git/v1/identity/{identity}/tokens", {
|
|
286
|
+
params: { identity }
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
async listGitTriggers({
|
|
290
|
+
repo
|
|
291
|
+
}) {
|
|
292
|
+
return this.apiClient.get("/git/v1/repo/{repo}/trigger", {
|
|
293
|
+
params: { repo }
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
async createGitTrigger({
|
|
297
|
+
repo,
|
|
298
|
+
trigger,
|
|
299
|
+
action
|
|
300
|
+
}) {
|
|
301
|
+
return this.apiClient.post("/git/v1/repo/{repo}/trigger", {
|
|
302
|
+
params: { repo },
|
|
303
|
+
body: { trigger, action }
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
async deleteGitTrigger({
|
|
307
|
+
repo,
|
|
308
|
+
trigger
|
|
309
|
+
}) {
|
|
310
|
+
return this.apiClient.delete("/git/v1/repo/{repo}/trigger/{trigger}", {
|
|
311
|
+
params: { repo, trigger }
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
async setGitRepoDefaultBranch({
|
|
315
|
+
repo_id,
|
|
316
|
+
defaultBranch
|
|
317
|
+
}) {
|
|
318
|
+
return this.apiClient.put("/git/v1/repo/{repo_id}/default-branch", {
|
|
319
|
+
params: { repo_id },
|
|
320
|
+
body: { defaultBranch }
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
async getGitRepoDefaultBranch({
|
|
324
|
+
repo_id
|
|
325
|
+
}) {
|
|
326
|
+
return this.apiClient.get("/git/v1/repo/{repo_id}/default-branch", {
|
|
327
|
+
params: { repo_id }
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async getGitRepoContents({
|
|
331
|
+
repo,
|
|
332
|
+
path = "",
|
|
333
|
+
ref
|
|
334
|
+
}) {
|
|
335
|
+
return this.apiClient.get("/git/v1/repo/{repo}/contents/{path}", {
|
|
336
|
+
params: { repo, path },
|
|
337
|
+
query: { ref }
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
async configureGitRepoGitHubSync({
|
|
341
|
+
repo_id,
|
|
342
|
+
githubRepoName
|
|
343
|
+
}) {
|
|
344
|
+
throw new Error("Not implemented - endpoint missing from OpenAPI spec");
|
|
345
|
+
}
|
|
346
|
+
async removeGitRepoGitHubSync({ repo_id }) {
|
|
347
|
+
throw new Error("Not implemented - endpoint missing from OpenAPI spec");
|
|
348
|
+
}
|
|
349
|
+
async getGitRepoGitHubSyncConfig({
|
|
350
|
+
repo_id
|
|
351
|
+
}) {
|
|
352
|
+
try {
|
|
353
|
+
return await this.apiClient.get("/git/v1/repo/{repo_id}/github-sync", {
|
|
354
|
+
params: { repo_id }
|
|
355
|
+
});
|
|
356
|
+
} catch (error) {
|
|
357
|
+
if (error.message?.includes("404")) {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
throw error;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async createDnsRecord(body) {
|
|
364
|
+
return this.apiClient.post("/dns/v1/records", { body });
|
|
365
|
+
}
|
|
366
|
+
async listDnsRecords(query) {
|
|
367
|
+
return this.apiClient.get("/dns/v1/records", { query });
|
|
368
|
+
}
|
|
369
|
+
async deleteDnsRecord(query) {
|
|
370
|
+
return this.apiClient.delete("/dns/v1/records", { query });
|
|
371
|
+
}
|
|
372
|
+
fetch(path, init) {
|
|
373
|
+
const headers = new Headers(init?.headers);
|
|
374
|
+
if (!headers.has("Authorization")) {
|
|
375
|
+
headers.append("Authorization", `Bearer ${this.options.apiKey}`);
|
|
376
|
+
}
|
|
377
|
+
if (!headers.has("Content-Type") && init?.body) {
|
|
378
|
+
headers.append("Content-Type", "application/json");
|
|
379
|
+
}
|
|
380
|
+
const url = new URL(path, this.options.baseUrl ?? "https://api.freestyle.sh");
|
|
381
|
+
return fetch(url, {
|
|
382
|
+
...init ?? {},
|
|
383
|
+
headers
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
var src_default = Freestyle;
|
|
388
|
+
export {
|
|
389
|
+
src_default as default,
|
|
390
|
+
Freestyle
|
|
391
|
+
};
|
package/index.mjs
CHANGED
|
@@ -3929,10 +3929,18 @@ class ApiClient {
|
|
|
3929
3929
|
};
|
|
3930
3930
|
return this.fetchFn(url, finalOptions);
|
|
3931
3931
|
}
|
|
3932
|
+
resolveUrl(path, params, query) {
|
|
3933
|
+
return this.buildUrl(path, params, query);
|
|
3934
|
+
}
|
|
3932
3935
|
getRaw(path, options) {
|
|
3933
3936
|
const url = this.buildUrl(path, options?.params, options?.query);
|
|
3934
3937
|
return this.requestRaw("GET", url, void 0, options?.headers);
|
|
3935
3938
|
}
|
|
3939
|
+
postRaw(path, ...args) {
|
|
3940
|
+
const options = args[0];
|
|
3941
|
+
const url = this.buildUrl(path, options?.params, options?.query);
|
|
3942
|
+
return this.requestRaw("POST", url, options?.body, options?.headers);
|
|
3943
|
+
}
|
|
3936
3944
|
get(path, ...args) {
|
|
3937
3945
|
const options = args[0];
|
|
3938
3946
|
const url = this.buildUrl(path, options?.params, options?.query);
|
|
@@ -7557,7 +7565,7 @@ class VmsNamespace {
|
|
|
7557
7565
|
function enhanceError(e) {
|
|
7558
7566
|
if (e instanceof VmSetupFailedError) {
|
|
7559
7567
|
if (!e.message.includes("create --snapshot")) {
|
|
7560
|
-
e.message = `${e.message}. Hint: use \`npx freestyle
|
|
7568
|
+
e.message = `${e.message}. Hint: use \`npx freestyle@latest vm create --snapshot ${e.body.snapshotId} --ssh --delete\` to debug.`;
|
|
7561
7569
|
}
|
|
7562
7570
|
if (e.body.diagnostics) {
|
|
7563
7571
|
const d = e.body.diagnostics;
|