@remixhq/core 0.1.7 → 0.1.9
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/dist/api.d.ts +115 -7
- package/dist/api.js +1 -1
- package/dist/binding.js +1 -1
- package/dist/chunk-CJFGQE7D.js +46 -0
- package/dist/chunk-GEHSFPCD.js +93 -0
- package/dist/chunk-J3J4PBQ7.js +710 -0
- package/dist/chunk-OBYR4JHZ.js +374 -0
- package/dist/chunk-POYB6MCQ.js +373 -0
- package/dist/chunk-RREREIGW.js +710 -0
- package/dist/chunk-XC2FV57P.js +385 -0
- package/dist/collab.d.ts +89 -7
- package/dist/collab.js +159 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/repo.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RemixError
|
|
3
|
+
} from "./chunk-YZ34ICNN.js";
|
|
4
|
+
|
|
5
|
+
// src/api/client.ts
|
|
6
|
+
async function readJsonSafe(res) {
|
|
7
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
8
|
+
if (!ct.toLowerCase().includes("application/json")) return null;
|
|
9
|
+
try {
|
|
10
|
+
return await res.json();
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function createApiClient(config, opts) {
|
|
16
|
+
const apiKey = (opts?.apiKey ?? "").trim();
|
|
17
|
+
const tokenProvider = opts?.tokenProvider;
|
|
18
|
+
const CLIENT_KEY_HEADER = "x-comerge-api-key";
|
|
19
|
+
async function request(path, init) {
|
|
20
|
+
if (!tokenProvider) {
|
|
21
|
+
throw new RemixError("API client is missing a token provider.", {
|
|
22
|
+
exitCode: 1,
|
|
23
|
+
hint: "Configure auth before creating the Remix API client."
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const auth = await tokenProvider();
|
|
27
|
+
const url = new URL(path, config.apiUrl).toString();
|
|
28
|
+
const doFetch = async (bearer) => fetch(url, {
|
|
29
|
+
...init,
|
|
30
|
+
headers: {
|
|
31
|
+
Accept: "application/json",
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
...init?.headers ?? {},
|
|
34
|
+
Authorization: `Bearer ${bearer}`,
|
|
35
|
+
...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
let res = await doFetch(auth.token);
|
|
39
|
+
if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
|
|
40
|
+
const refreshed = await tokenProvider({ forceRefresh: true });
|
|
41
|
+
res = await doFetch(refreshed.token);
|
|
42
|
+
}
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const body = await readJsonSafe(res);
|
|
45
|
+
const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
|
|
46
|
+
throw new RemixError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
|
|
47
|
+
}
|
|
48
|
+
const json = await readJsonSafe(res);
|
|
49
|
+
return json ?? null;
|
|
50
|
+
}
|
|
51
|
+
async function requestBinary(path, init) {
|
|
52
|
+
if (!tokenProvider) {
|
|
53
|
+
throw new RemixError("API client is missing a token provider.", {
|
|
54
|
+
exitCode: 1,
|
|
55
|
+
hint: "Configure auth before creating the Remix API client."
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const auth = await tokenProvider();
|
|
59
|
+
const url = new URL(path, config.apiUrl).toString();
|
|
60
|
+
const doFetch = async (bearer) => fetch(url, {
|
|
61
|
+
...init,
|
|
62
|
+
headers: {
|
|
63
|
+
Accept: "*/*",
|
|
64
|
+
...init?.headers ?? {},
|
|
65
|
+
Authorization: `Bearer ${bearer}`,
|
|
66
|
+
...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
let res = await doFetch(auth.token);
|
|
70
|
+
if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
|
|
71
|
+
const refreshed = await tokenProvider({ forceRefresh: true });
|
|
72
|
+
res = await doFetch(refreshed.token);
|
|
73
|
+
}
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
const body = await readJsonSafe(res);
|
|
76
|
+
const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
|
|
77
|
+
throw new RemixError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
|
|
78
|
+
}
|
|
79
|
+
const contentDisposition = res.headers.get("content-disposition") ?? "";
|
|
80
|
+
const fileNameMatch = contentDisposition.match(/filename=\"([^\"]+)\"/i);
|
|
81
|
+
return {
|
|
82
|
+
data: Buffer.from(await res.arrayBuffer()),
|
|
83
|
+
fileName: fileNameMatch?.[1] ?? null,
|
|
84
|
+
contentType: res.headers.get("content-type")
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
getMe: () => request("/v1/me", { method: "GET" }),
|
|
89
|
+
listOrganizations: () => request("/v1/organizations", { method: "GET" }),
|
|
90
|
+
getOrganization: (orgId) => request(`/v1/organizations/${encodeURIComponent(orgId)}`, { method: "GET" }),
|
|
91
|
+
listProjects: (params) => {
|
|
92
|
+
const qs = new URLSearchParams();
|
|
93
|
+
if (params?.organizationId) qs.set("organizationId", params.organizationId);
|
|
94
|
+
if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
|
|
95
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
96
|
+
return request(`/v1/projects${suffix}`, { method: "GET" });
|
|
97
|
+
},
|
|
98
|
+
getProject: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}`, { method: "GET" }),
|
|
99
|
+
resolveProjectBinding: (params) => {
|
|
100
|
+
const qs = new URLSearchParams();
|
|
101
|
+
if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
|
|
102
|
+
if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
|
|
103
|
+
return request(`/v1/projects/bindings/resolve?${qs.toString()}`, { method: "GET" });
|
|
104
|
+
},
|
|
105
|
+
autoEnableDeveloper: () => request("/v1/developer/auto-enable", { method: "POST" }),
|
|
106
|
+
listClientApps: (params) => {
|
|
107
|
+
const qs = params?.orgId ? `?orgId=${encodeURIComponent(params.orgId)}` : "";
|
|
108
|
+
return request(`/v1/developer/client-apps${qs}`, { method: "GET" });
|
|
109
|
+
},
|
|
110
|
+
createClientApp: (payload) => request("/v1/developer/client-apps", { method: "POST", body: JSON.stringify(payload) }),
|
|
111
|
+
createClientAppKey: (clientAppId, payload) => request(`/v1/developer/client-apps/${encodeURIComponent(clientAppId)}/keys`, {
|
|
112
|
+
method: "POST",
|
|
113
|
+
body: JSON.stringify(payload ?? {})
|
|
114
|
+
}),
|
|
115
|
+
listApps: (params) => {
|
|
116
|
+
const qs = new URLSearchParams();
|
|
117
|
+
if (params?.projectId) qs.set("projectId", params.projectId);
|
|
118
|
+
if (params?.organizationId) qs.set("organizationId", params.organizationId);
|
|
119
|
+
if (params?.forked) qs.set("forked", params.forked);
|
|
120
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
121
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
122
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
123
|
+
return request(`/v1/apps${suffix}`, { method: "GET" });
|
|
124
|
+
},
|
|
125
|
+
getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
|
|
126
|
+
getAppContext: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/context`, { method: "GET" }),
|
|
127
|
+
getAppOverview: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/overview`, { method: "GET" }),
|
|
128
|
+
listAppTimeline: (appId, params) => {
|
|
129
|
+
const qs = new URLSearchParams();
|
|
130
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
131
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
132
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
133
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/timeline${suffix}`, { method: "GET" });
|
|
134
|
+
},
|
|
135
|
+
getAppTimelineEvent: (appId, eventId) => request(`/v1/apps/${encodeURIComponent(appId)}/timeline/${encodeURIComponent(eventId)}`, { method: "GET" }),
|
|
136
|
+
listAppEditQueue: (appId, params) => {
|
|
137
|
+
const qs = new URLSearchParams();
|
|
138
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
139
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
140
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
141
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/edit-queue${suffix}`, { method: "GET" });
|
|
142
|
+
},
|
|
143
|
+
getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
|
|
144
|
+
presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
|
|
145
|
+
importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
|
|
146
|
+
presignImportUploadFirstParty: (payload) => request("/v1/apps/import/upload/presign/first-party", { method: "POST", body: JSON.stringify(payload) }),
|
|
147
|
+
importFromUploadFirstParty: (payload) => request("/v1/apps/import/upload/first-party", { method: "POST", body: JSON.stringify(payload) }),
|
|
148
|
+
importFromGithubFirstParty: (payload) => request("/v1/apps/import/github/first-party", { method: "POST", body: JSON.stringify(payload) }),
|
|
149
|
+
forkApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/fork`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
|
|
150
|
+
downloadAppBundle: (appId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/download.bundle`, { method: "GET" }),
|
|
151
|
+
createChangeStep: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps`, {
|
|
152
|
+
method: "POST",
|
|
153
|
+
body: JSON.stringify(payload)
|
|
154
|
+
}),
|
|
155
|
+
createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
|
|
156
|
+
method: "POST",
|
|
157
|
+
body: JSON.stringify(payload)
|
|
158
|
+
}),
|
|
159
|
+
listCollabTurns: (appId, params) => {
|
|
160
|
+
const qs = new URLSearchParams();
|
|
161
|
+
if (params?.limit !== void 0) qs.set("limit", String(params.limit));
|
|
162
|
+
if (params?.offset !== void 0) qs.set("offset", String(params.offset));
|
|
163
|
+
if (params?.changeStepId) qs.set("changeStepId", params.changeStepId);
|
|
164
|
+
if (params?.threadId) qs.set("threadId", params.threadId);
|
|
165
|
+
if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
|
|
166
|
+
if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
|
|
167
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
168
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix}`, { method: "GET" });
|
|
169
|
+
},
|
|
170
|
+
getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
|
|
171
|
+
method: "GET"
|
|
172
|
+
}),
|
|
173
|
+
getAgentMemorySummary: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/summary`, { method: "GET" }),
|
|
174
|
+
listAgentMemoryTimeline: (appId, params) => {
|
|
175
|
+
const qs = new URLSearchParams();
|
|
176
|
+
if (params?.limit !== void 0) qs.set("limit", String(params.limit));
|
|
177
|
+
if (params?.offset !== void 0) qs.set("offset", String(params.offset));
|
|
178
|
+
if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
|
|
179
|
+
if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
|
|
180
|
+
if (params?.kinds?.length) {
|
|
181
|
+
for (const kind of params.kinds) qs.append("kinds", kind);
|
|
182
|
+
}
|
|
183
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
184
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix}`, { method: "GET" });
|
|
185
|
+
},
|
|
186
|
+
searchAgentMemory: (appId, params) => {
|
|
187
|
+
const qs = new URLSearchParams();
|
|
188
|
+
qs.set("q", params.q);
|
|
189
|
+
if (params.limit !== void 0) qs.set("limit", String(params.limit));
|
|
190
|
+
if (params.offset !== void 0) qs.set("offset", String(params.offset));
|
|
191
|
+
if (params.createdAfter) qs.set("createdAfter", params.createdAfter);
|
|
192
|
+
if (params.createdBefore) qs.set("createdBefore", params.createdBefore);
|
|
193
|
+
if (params.kinds?.length) {
|
|
194
|
+
for (const kind of params.kinds) qs.append("kinds", kind);
|
|
195
|
+
}
|
|
196
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/search?${qs.toString()}`, { method: "GET" });
|
|
197
|
+
},
|
|
198
|
+
getChangeStep: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}`, { method: "GET" }),
|
|
199
|
+
getChangeStepDiff: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}/diff`, {
|
|
200
|
+
method: "GET"
|
|
201
|
+
}),
|
|
202
|
+
startChangeStepReplay: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays`, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
body: JSON.stringify(payload)
|
|
205
|
+
}),
|
|
206
|
+
getChangeStepReplay: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}`, {
|
|
207
|
+
method: "GET"
|
|
208
|
+
}),
|
|
209
|
+
getChangeStepReplayDiff: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}/diff`, {
|
|
210
|
+
method: "GET"
|
|
211
|
+
}),
|
|
212
|
+
listMergeRequests: (params) => {
|
|
213
|
+
const qs = new URLSearchParams();
|
|
214
|
+
if (params?.queue) qs.set("queue", params.queue);
|
|
215
|
+
if (params?.appId) qs.set("appId", params.appId);
|
|
216
|
+
if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
|
|
217
|
+
if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
|
|
218
|
+
if (Array.isArray(params?.status)) {
|
|
219
|
+
for (const status of params.status) qs.append("status", status);
|
|
220
|
+
} else if (typeof params?.status === "string") {
|
|
221
|
+
qs.set("status", params.status);
|
|
222
|
+
}
|
|
223
|
+
if (params?.kind) qs.set("kind", params.kind);
|
|
224
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
225
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
226
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
227
|
+
return request(`/v1/merge-requests${suffix}`, { method: "GET" });
|
|
228
|
+
},
|
|
229
|
+
openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
|
|
230
|
+
getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
|
|
231
|
+
updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
|
|
232
|
+
createOrganizationInvite: (orgId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations`, {
|
|
233
|
+
method: "POST",
|
|
234
|
+
body: JSON.stringify(payload)
|
|
235
|
+
}),
|
|
236
|
+
createProjectInvite: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations`, {
|
|
237
|
+
method: "POST",
|
|
238
|
+
body: JSON.stringify(payload)
|
|
239
|
+
}),
|
|
240
|
+
createAppInvite: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations`, {
|
|
241
|
+
method: "POST",
|
|
242
|
+
body: JSON.stringify(payload)
|
|
243
|
+
}),
|
|
244
|
+
listOrganizationMembers: (orgId, params) => {
|
|
245
|
+
const qs = new URLSearchParams();
|
|
246
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
247
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
248
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
249
|
+
return request(`/v1/organizations/${encodeURIComponent(orgId)}/members${suffix}`, { method: "GET" });
|
|
250
|
+
},
|
|
251
|
+
updateOrganizationMember: (orgId, userId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`, {
|
|
252
|
+
method: "PATCH",
|
|
253
|
+
body: JSON.stringify(payload)
|
|
254
|
+
}),
|
|
255
|
+
listProjectMembers: (projectId, params) => {
|
|
256
|
+
const qs = new URLSearchParams();
|
|
257
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
258
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
259
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
260
|
+
return request(`/v1/projects/${encodeURIComponent(projectId)}/members${suffix}`, { method: "GET" });
|
|
261
|
+
},
|
|
262
|
+
updateProjectMember: (projectId, userId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/members/${encodeURIComponent(userId)}`, {
|
|
263
|
+
method: "PATCH",
|
|
264
|
+
body: JSON.stringify(payload)
|
|
265
|
+
}),
|
|
266
|
+
listAppMembers: (appId, params) => {
|
|
267
|
+
const qs = new URLSearchParams();
|
|
268
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
269
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
270
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
271
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/members${suffix}`, { method: "GET" });
|
|
272
|
+
},
|
|
273
|
+
updateAppMember: (appId, userId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/members/${encodeURIComponent(userId)}`, {
|
|
274
|
+
method: "PATCH",
|
|
275
|
+
body: JSON.stringify(payload)
|
|
276
|
+
}),
|
|
277
|
+
listOrganizationInvites: (orgId, params) => {
|
|
278
|
+
const qs = new URLSearchParams();
|
|
279
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
280
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
281
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
282
|
+
return request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations${suffix}`, { method: "GET" });
|
|
283
|
+
},
|
|
284
|
+
listProjectInvites: (projectId, params) => {
|
|
285
|
+
const qs = new URLSearchParams();
|
|
286
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
287
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
288
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
289
|
+
return request(`/v1/projects/${encodeURIComponent(projectId)}/invitations${suffix}`, { method: "GET" });
|
|
290
|
+
},
|
|
291
|
+
listAppInvites: (appId, params) => {
|
|
292
|
+
const qs = new URLSearchParams();
|
|
293
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
294
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
295
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
296
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/invitations${suffix}`, { method: "GET" });
|
|
297
|
+
},
|
|
298
|
+
resendOrganizationInvite: (orgId, inviteId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
|
|
299
|
+
method: "POST",
|
|
300
|
+
body: JSON.stringify(payload ?? {})
|
|
301
|
+
}),
|
|
302
|
+
resendProjectInvite: (projectId, inviteId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
|
|
303
|
+
method: "POST",
|
|
304
|
+
body: JSON.stringify(payload ?? {})
|
|
305
|
+
}),
|
|
306
|
+
resendAppInvite: (appId, inviteId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
|
|
307
|
+
method: "POST",
|
|
308
|
+
body: JSON.stringify(payload ?? {})
|
|
309
|
+
}),
|
|
310
|
+
revokeOrganizationInvite: (orgId, inviteId) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}`, {
|
|
311
|
+
method: "DELETE"
|
|
312
|
+
}),
|
|
313
|
+
revokeProjectInvite: (projectId, inviteId) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations/${encodeURIComponent(inviteId)}`, {
|
|
314
|
+
method: "DELETE"
|
|
315
|
+
}),
|
|
316
|
+
revokeAppInvite: (appId, inviteId) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations/${encodeURIComponent(inviteId)}`, {
|
|
317
|
+
method: "DELETE"
|
|
318
|
+
}),
|
|
319
|
+
acceptInvitation: (payload) => request("/v1/invitations/accept", { method: "POST", body: JSON.stringify(payload) }),
|
|
320
|
+
syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
|
|
321
|
+
method: "POST",
|
|
322
|
+
body: JSON.stringify({})
|
|
323
|
+
}),
|
|
324
|
+
preflightAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/preflight`, {
|
|
325
|
+
method: "POST",
|
|
326
|
+
body: JSON.stringify(payload)
|
|
327
|
+
}),
|
|
328
|
+
startAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/start`, {
|
|
329
|
+
method: "POST",
|
|
330
|
+
body: JSON.stringify(payload)
|
|
331
|
+
}),
|
|
332
|
+
getAppReconcile: (appId, reconcileId) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}`, { method: "GET" }),
|
|
333
|
+
downloadAppReconcileBundle: (appId, reconcileId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}/download.bundle`, {
|
|
334
|
+
method: "GET"
|
|
335
|
+
}),
|
|
336
|
+
syncLocalApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-local`, {
|
|
337
|
+
method: "POST",
|
|
338
|
+
body: JSON.stringify(payload)
|
|
339
|
+
}),
|
|
340
|
+
initiateBundle: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles`, { method: "POST", body: JSON.stringify(payload) }),
|
|
341
|
+
getBundle: (appId, bundleId) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}`, { method: "GET" }),
|
|
342
|
+
getBundleDownloadUrl: (appId, bundleId, options) => request(
|
|
343
|
+
`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/download?redirect=${options?.redirect ?? false}`,
|
|
344
|
+
{ method: "GET" }
|
|
345
|
+
),
|
|
346
|
+
getBundleAssetsDownloadUrl: (appId, bundleId, options) => {
|
|
347
|
+
const qs = new URLSearchParams({
|
|
348
|
+
redirect: String(options?.redirect ?? false),
|
|
349
|
+
kind: options?.kind ?? "metro-assets"
|
|
350
|
+
});
|
|
351
|
+
return request(
|
|
352
|
+
`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/assets/download?${qs.toString()}`,
|
|
353
|
+
{ method: "GET" }
|
|
354
|
+
);
|
|
355
|
+
},
|
|
356
|
+
getAgentRun: (appId, runId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}`, { method: "GET" }),
|
|
357
|
+
listAgentRunEvents: (appId, runId, params) => {
|
|
358
|
+
const qs = new URLSearchParams();
|
|
359
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
360
|
+
if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
|
|
361
|
+
if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
|
|
362
|
+
if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
|
|
363
|
+
const suffix = qs.toString() ? `?${qs.toString()}` : "";
|
|
364
|
+
return request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}/events${suffix}`, {
|
|
365
|
+
method: "GET"
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
getSandboxStatus: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/status`, { method: "GET" })
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export {
|
|
373
|
+
createApiClient
|
|
374
|
+
};
|