@remixhq/core 0.1.25 → 0.1.27

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.
@@ -2,6 +2,113 @@ import {
2
2
  RemixError
3
3
  } from "./chunk-7XJGOKEO.js";
4
4
 
5
+ // src/api/clientQuery.ts
6
+ function appendStatus(qs, status) {
7
+ if (Array.isArray(status)) {
8
+ for (const value of status) qs.append("status", value);
9
+ } else if (typeof status === "string") {
10
+ qs.set("status", status);
11
+ }
12
+ }
13
+ function suffix(qs) {
14
+ const value = qs.toString();
15
+ return value ? `?${value}` : "";
16
+ }
17
+ function buildRuntimeEnvQuery(params) {
18
+ const qs = new URLSearchParams();
19
+ if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
20
+ if (params?.environment) qs.set("environment", params.environment);
21
+ if (params?.target) qs.set("target", params.target);
22
+ return qs.toString();
23
+ }
24
+ function buildRuntimeTargetQuery(params) {
25
+ const qs = new URLSearchParams();
26
+ if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
27
+ if (params?.environment) qs.set("environment", params.environment);
28
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
29
+ return qs.toString();
30
+ }
31
+ function buildTriggerQuery(params) {
32
+ const qs = new URLSearchParams();
33
+ if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
34
+ if (params?.environment) qs.set("environment", params.environment);
35
+ if (params?.eventType) qs.set("eventType", params.eventType);
36
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
37
+ if (params?.appId) qs.set("appId", params.appId);
38
+ return qs.toString();
39
+ }
40
+ function buildProjectListQuery(params) {
41
+ const qs = new URLSearchParams();
42
+ if (params?.organizationId) qs.set("organizationId", params.organizationId);
43
+ if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
44
+ return suffix(qs);
45
+ }
46
+ function buildAppPreviewQuery(params) {
47
+ const qs = new URLSearchParams();
48
+ if (params?.environment) qs.set("environment", params.environment);
49
+ if (params?.autostart !== void 0) qs.set("autostart", params.autostart ? "true" : "false");
50
+ if (params?.probe) qs.set("probe", params.probe);
51
+ return suffix(qs);
52
+ }
53
+ function buildAppListQuery(params) {
54
+ const qs = new URLSearchParams();
55
+ if (params?.projectId) qs.set("projectId", params.projectId);
56
+ if (params?.organizationId) qs.set("organizationId", params.organizationId);
57
+ if (params?.ownership) qs.set("ownership", params.ownership);
58
+ if (params?.accessScope) qs.set("accessScope", params.accessScope);
59
+ if (params?.createdBy) qs.set("createdBy", params.createdBy);
60
+ if (params?.forked) qs.set("forked", params.forked);
61
+ if (params?.status) qs.set("status", params.status);
62
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
63
+ if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
64
+ return suffix(qs);
65
+ }
66
+ function buildPaginationQuery(params) {
67
+ const qs = new URLSearchParams();
68
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
69
+ if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
70
+ return suffix(qs);
71
+ }
72
+ function buildAppTimelineQuery(params) {
73
+ const qs = new URLSearchParams();
74
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
75
+ if (params?.cursor) qs.set("cursor", params.cursor);
76
+ return suffix(qs);
77
+ }
78
+ function buildAppEditQueueQuery(params) {
79
+ return buildPaginationQuery(params);
80
+ }
81
+ function buildAppJobQueueQuery(params) {
82
+ const qs = new URLSearchParams();
83
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
84
+ if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
85
+ for (const kind of params?.kind ?? []) qs.append("kind", kind);
86
+ for (const status of params?.status ?? []) qs.append("status", status);
87
+ return suffix(qs);
88
+ }
89
+ function buildMergeRequestListQuery(params) {
90
+ const qs = new URLSearchParams();
91
+ if (params?.queue) qs.set("queue", params.queue);
92
+ if (params?.appId) qs.set("appId", params.appId);
93
+ if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
94
+ if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
95
+ appendStatus(qs, params?.status);
96
+ if (params?.kind) qs.set("kind", params.kind);
97
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
98
+ if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
99
+ return suffix(qs);
100
+ }
101
+ function buildMergeRequestInboxQuery(params) {
102
+ const qs = new URLSearchParams();
103
+ appendStatus(qs, params?.status);
104
+ if (params?.kind) qs.set("kind", params.kind);
105
+ if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
106
+ if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
107
+ if (typeof params?.includeReview === "boolean") qs.set("includeReview", String(params.includeReview));
108
+ if (typeof params?.includeDiffs === "boolean") qs.set("includeDiffs", String(params.includeDiffs));
109
+ return suffix(qs);
110
+ }
111
+
5
112
  // src/api/client.ts
6
113
  async function readJsonSafe(res) {
7
114
  const ct = res.headers.get("content-type") ?? "";
@@ -58,29 +165,6 @@ function createApiClient(config, opts) {
58
165
  const json = await readJsonSafe(res);
59
166
  return json ?? null;
60
167
  }
61
- function runtimeEnvQuery(params) {
62
- const qs = new URLSearchParams();
63
- if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
64
- if (params?.environment) qs.set("environment", params.environment);
65
- if (params?.target) qs.set("target", params.target);
66
- return qs.toString();
67
- }
68
- function runtimeTargetQuery(params) {
69
- const qs = new URLSearchParams();
70
- if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
71
- if (params?.environment) qs.set("environment", params.environment);
72
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
73
- return qs.toString();
74
- }
75
- function triggerQuery(params) {
76
- const qs = new URLSearchParams();
77
- if (params?.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
78
- if (params?.environment) qs.set("environment", params.environment);
79
- if (params?.eventType) qs.set("eventType", params.eventType);
80
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
81
- if (params?.appId) qs.set("appId", params.appId);
82
- return qs.toString();
83
- }
84
168
  async function requestBinary(path, init, opts2) {
85
169
  if (!tokenProvider) {
86
170
  throw new RemixError("API client is missing a token provider.", {
@@ -126,18 +210,12 @@ function createApiClient(config, opts) {
126
210
  getMe: () => request("/v1/me", { method: "GET" }),
127
211
  listOrganizations: () => request("/v1/organizations", { method: "GET" }),
128
212
  getOrganization: (orgId) => request(`/v1/organizations/${encodeURIComponent(orgId)}`, { method: "GET" }),
129
- listProjects: (params) => {
130
- const qs = new URLSearchParams();
131
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
132
- if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
133
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
134
- return request(`/v1/projects${suffix}`, { method: "GET" });
135
- },
213
+ listProjects: (params) => request(`/v1/projects${buildProjectListQuery(params)}`, { method: "GET" }),
136
214
  getProject: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}`, { method: "GET" }),
137
215
  listProjectRuntimeEnv: (projectId, params) => {
138
- const qs = runtimeEnvQuery(params);
139
- const suffix = qs ? `?${qs}` : "";
140
- return request(`/v1/projects/${encodeURIComponent(projectId)}/repo-env${suffix}`, { method: "GET" });
216
+ const qs = buildRuntimeEnvQuery(params);
217
+ const suffix2 = qs ? `?${qs}` : "";
218
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/repo-env${suffix2}`, { method: "GET" });
141
219
  },
142
220
  setProjectRuntimeEnv: (projectId, name, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/repo-env/${encodeURIComponent(name)}`, {
143
221
  method: "PUT",
@@ -148,9 +226,9 @@ function createApiClient(config, opts) {
148
226
  body: JSON.stringify(payload)
149
227
  }),
150
228
  deleteProjectRuntimeEnv: (projectId, name, params) => {
151
- const qs = runtimeEnvQuery(params);
152
- const suffix = qs ? `?${qs}` : "";
153
- return request(`/v1/projects/${encodeURIComponent(projectId)}/repo-env/${encodeURIComponent(name)}${suffix}`, {
229
+ const qs = buildRuntimeEnvQuery(params);
230
+ const suffix2 = qs ? `?${qs}` : "";
231
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/repo-env/${encodeURIComponent(name)}${suffix2}`, {
154
232
  method: "DELETE"
155
233
  });
156
234
  },
@@ -159,9 +237,9 @@ function createApiClient(config, opts) {
159
237
  body: JSON.stringify(payload)
160
238
  }),
161
239
  listProjectRuntimeTargets: (projectId, params) => {
162
- const qs = runtimeTargetQuery(params);
163
- const suffix = qs ? `?${qs}` : "";
164
- return request(`/v1/projects/${encodeURIComponent(projectId)}/runtime-targets${suffix}`, { method: "GET" });
240
+ const qs = buildRuntimeTargetQuery(params);
241
+ const suffix2 = qs ? `?${qs}` : "";
242
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/runtime-targets${suffix2}`, { method: "GET" });
165
243
  },
166
244
  detectProjectRuntimeTargets: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/runtime-targets/detect`, {
167
245
  method: "POST",
@@ -172,9 +250,9 @@ function createApiClient(config, opts) {
172
250
  body: JSON.stringify(payload)
173
251
  }),
174
252
  deleteProjectRuntimeTarget: (projectId, targetId, params) => {
175
- const qs = runtimeTargetQuery(params);
176
- const suffix = qs ? `?${qs}` : "";
177
- return request(`/v1/projects/${encodeURIComponent(projectId)}/runtime-targets/${encodeURIComponent(targetId)}${suffix}`, {
253
+ const qs = buildRuntimeTargetQuery(params);
254
+ const suffix2 = qs ? `?${qs}` : "";
255
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/runtime-targets/${encodeURIComponent(targetId)}${suffix2}`, {
178
256
  method: "DELETE"
179
257
  });
180
258
  },
@@ -183,16 +261,16 @@ function createApiClient(config, opts) {
183
261
  body: JSON.stringify(payload ?? {})
184
262
  }),
185
263
  getAppRuntimeTargetStatus: (appId, targetId, params) => {
186
- const qs = runtimeTargetQuery(params);
187
- const suffix = qs ? `?${qs}` : "";
188
- return request(`/v1/apps/${encodeURIComponent(appId)}/runtime-targets/${encodeURIComponent(targetId)}/status${suffix}`, {
264
+ const qs = buildRuntimeTargetQuery(params);
265
+ const suffix2 = qs ? `?${qs}` : "";
266
+ return request(`/v1/apps/${encodeURIComponent(appId)}/runtime-targets/${encodeURIComponent(targetId)}/status${suffix2}`, {
189
267
  method: "GET"
190
268
  });
191
269
  },
192
270
  getAppRuntimeTargetLogs: (appId, targetId, params) => {
193
- const qs = runtimeTargetQuery(params);
194
- const suffix = qs ? `?${qs}` : "";
195
- return request(`/v1/apps/${encodeURIComponent(appId)}/runtime-targets/${encodeURIComponent(targetId)}/logs${suffix}`, {
271
+ const qs = buildRuntimeTargetQuery(params);
272
+ const suffix2 = qs ? `?${qs}` : "";
273
+ return request(`/v1/apps/${encodeURIComponent(appId)}/runtime-targets/${encodeURIComponent(targetId)}/logs${suffix2}`, {
196
274
  method: "GET"
197
275
  });
198
276
  },
@@ -200,14 +278,7 @@ function createApiClient(config, opts) {
200
278
  method: "POST",
201
279
  body: JSON.stringify(payload ?? {})
202
280
  }),
203
- getAppPreview: (appId, params) => {
204
- const qs = new URLSearchParams();
205
- if (params?.environment) qs.set("environment", params.environment);
206
- if (params?.autostart !== void 0) qs.set("autostart", params.autostart ? "true" : "false");
207
- if (params?.probe) qs.set("probe", params.probe);
208
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
209
- return request(`/v1/apps/${encodeURIComponent(appId)}/preview${suffix}`, { method: "GET" });
210
- },
281
+ getAppPreview: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/preview${buildAppPreviewQuery(params)}`, { method: "GET" }),
211
282
  runAppSandboxCommand: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/commands/run`, {
212
283
  method: "POST",
213
284
  body: JSON.stringify(payload)
@@ -215,14 +286,14 @@ function createApiClient(config, opts) {
215
286
  listAppSandboxCommandHistory: (appId, params) => {
216
287
  const qs = new URLSearchParams();
217
288
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
218
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
219
- return request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/commands/history${suffix}`, { method: "GET" });
289
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
290
+ return request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/commands/history${suffix2}`, { method: "GET" });
220
291
  },
221
292
  listProjectTriggerEvents: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/events`, { method: "GET" }),
222
293
  listProjectTriggers: (projectId, params) => {
223
- const qs = triggerQuery(params);
224
- const suffix = qs ? `?${qs}` : "";
225
- return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers${suffix}`, { method: "GET" });
294
+ const qs = buildTriggerQuery(params);
295
+ const suffix2 = qs ? `?${qs}` : "";
296
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers${suffix2}`, { method: "GET" });
226
297
  },
227
298
  createProjectTrigger: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers`, {
228
299
  method: "POST",
@@ -236,9 +307,9 @@ function createApiClient(config, opts) {
236
307
  method: "DELETE"
237
308
  }),
238
309
  resolveProjectTriggers: (projectId, params) => {
239
- const qs = triggerQuery(params);
240
- const suffix = qs ? `?${qs}` : "";
241
- return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/resolve${suffix}`, { method: "GET" });
310
+ const qs = buildTriggerQuery(params);
311
+ const suffix2 = qs ? `?${qs}` : "";
312
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/resolve${suffix2}`, { method: "GET" });
242
313
  },
243
314
  runAppTrigger: (appId, triggerId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/triggers/${encodeURIComponent(triggerId)}/run`, {
244
315
  method: "POST",
@@ -249,9 +320,9 @@ function createApiClient(config, opts) {
249
320
  body: JSON.stringify(payload)
250
321
  }),
251
322
  listProjectTriggerRuns: (projectId, params) => {
252
- const qs = triggerQuery(params);
253
- const suffix = qs ? `?${qs}` : "";
254
- return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/runs${suffix}`, { method: "GET" });
323
+ const qs = buildTriggerQuery(params);
324
+ const suffix2 = qs ? `?${qs}` : "";
325
+ return request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/runs${suffix2}`, { method: "GET" });
255
326
  },
256
327
  getProjectTriggerRun: (projectId, runId) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/runs/${encodeURIComponent(runId)}`, {
257
328
  method: "GET"
@@ -269,6 +340,8 @@ function createApiClient(config, opts) {
269
340
  if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
270
341
  if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
271
342
  if (params.defaultBranch) qs.set("defaultBranch", params.defaultBranch);
343
+ if (params.currentAppId) qs.set("currentAppId", params.currentAppId);
344
+ if (params.upstreamAppId) qs.set("upstreamAppId", params.upstreamAppId);
272
345
  qs.set("branchName", params.branchName);
273
346
  return request(`/v1/projects/bindings/resolve-lane?${qs.toString()}`, { method: "GET" });
274
347
  },
@@ -284,19 +357,7 @@ function createApiClient(config, opts) {
284
357
  method: "POST",
285
358
  body: JSON.stringify(payload ?? {})
286
359
  }),
287
- listApps: (params) => {
288
- const qs = new URLSearchParams();
289
- if (params?.projectId) qs.set("projectId", params.projectId);
290
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
291
- if (params?.ownership) qs.set("ownership", params.ownership);
292
- if (params?.accessScope) qs.set("accessScope", params.accessScope);
293
- if (params?.createdBy) qs.set("createdBy", params.createdBy);
294
- if (params?.forked) qs.set("forked", params.forked);
295
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
296
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
297
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
298
- return request(`/v1/apps${suffix}`, { method: "GET" });
299
- },
360
+ listApps: (params) => request(`/v1/apps${buildAppListQuery(params)}`, { method: "GET" }),
300
361
  getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
301
362
  updateAppStatus: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/status`, {
302
363
  method: "PATCH",
@@ -305,30 +366,10 @@ function createApiClient(config, opts) {
305
366
  openApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/open`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
306
367
  getAppContext: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/context`, { method: "GET" }),
307
368
  getAppOverview: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/overview`, { method: "GET" }),
308
- listAppTimeline: (appId, params) => {
309
- const qs = new URLSearchParams();
310
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
311
- if (params?.cursor) qs.set("cursor", params.cursor);
312
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
313
- return request(`/v1/apps/${encodeURIComponent(appId)}/timeline${suffix}`, { method: "GET" });
314
- },
369
+ listAppTimeline: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/timeline${buildAppTimelineQuery(params)}`, { method: "GET" }),
315
370
  getAppTimelineEvent: (appId, eventId) => request(`/v1/apps/${encodeURIComponent(appId)}/timeline/${encodeURIComponent(eventId)}`, { method: "GET" }),
316
- listAppEditQueue: (appId, params) => {
317
- const qs = new URLSearchParams();
318
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
319
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
320
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
321
- return request(`/v1/apps/${encodeURIComponent(appId)}/edit-queue${suffix}`, { method: "GET" });
322
- },
323
- listAppJobQueue: (appId, params) => {
324
- const qs = new URLSearchParams();
325
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
326
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
327
- for (const kind of params?.kind ?? []) qs.append("kind", kind);
328
- for (const status of params?.status ?? []) qs.append("status", status);
329
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
330
- return request(`/v1/apps/${encodeURIComponent(appId)}/job-queue${suffix}`, { method: "GET" });
331
- },
371
+ listAppEditQueue: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/edit-queue${buildAppEditQueueQuery(params)}`, { method: "GET" }),
372
+ listAppJobQueue: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/job-queue${buildAppJobQueueQuery(params)}`, { method: "GET" }),
332
373
  getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
333
374
  presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
334
375
  importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
@@ -351,8 +392,8 @@ function createApiClient(config, opts) {
351
392
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
352
393
  if (params?.offset !== void 0) qs.set("offset", String(params.offset));
353
394
  if (params?.idempotencyKey) qs.set("idempotencyKey", params.idempotencyKey);
354
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
355
- return request(`/v1/apps/${encodeURIComponent(appId)}/change-steps${suffix}`, { method: "GET" });
395
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
396
+ return request(`/v1/apps/${encodeURIComponent(appId)}/change-steps${suffix2}`, { method: "GET" });
356
397
  },
357
398
  createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
358
399
  method: "POST",
@@ -371,8 +412,8 @@ function createApiClient(config, opts) {
371
412
  if (params?.collabLaneId) qs.set("collabLaneId", params.collabLaneId);
372
413
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
373
414
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
374
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
375
- return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix}`, { method: "GET" });
415
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
416
+ return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix2}`, { method: "GET" });
376
417
  },
377
418
  getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
378
419
  method: "GET"
@@ -387,8 +428,8 @@ function createApiClient(config, opts) {
387
428
  if (params?.kinds?.length) {
388
429
  for (const kind of params.kinds) qs.append("kinds", kind);
389
430
  }
390
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
391
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix}`, { method: "GET" });
431
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
432
+ return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix2}`, { method: "GET" });
392
433
  },
393
434
  searchAgentMemory: (appId, params) => {
394
435
  const qs = new URLSearchParams();
@@ -416,38 +457,8 @@ function createApiClient(config, opts) {
416
457
  getChangeStepReplayDiff: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}/diff`, {
417
458
  method: "GET"
418
459
  }),
419
- listMergeRequests: (params) => {
420
- const qs = new URLSearchParams();
421
- if (params?.queue) qs.set("queue", params.queue);
422
- if (params?.appId) qs.set("appId", params.appId);
423
- if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
424
- if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
425
- if (Array.isArray(params?.status)) {
426
- for (const status of params.status) qs.append("status", status);
427
- } else if (typeof params?.status === "string") {
428
- qs.set("status", params.status);
429
- }
430
- if (params?.kind) qs.set("kind", params.kind);
431
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
432
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
433
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
434
- return request(`/v1/merge-requests${suffix}`, { method: "GET" });
435
- },
436
- listMergeRequestInbox: (params) => {
437
- const qs = new URLSearchParams();
438
- if (Array.isArray(params?.status)) {
439
- for (const status of params.status) qs.append("status", status);
440
- } else if (typeof params?.status === "string") {
441
- qs.set("status", params.status);
442
- }
443
- if (params?.kind) qs.set("kind", params.kind);
444
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
445
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
446
- if (typeof params?.includeReview === "boolean") qs.set("includeReview", String(params.includeReview));
447
- if (typeof params?.includeDiffs === "boolean") qs.set("includeDiffs", String(params.includeDiffs));
448
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
449
- return request(`/v1/merge-requests/inbox${suffix}`, { method: "GET" });
450
- },
460
+ listMergeRequests: (params) => request(`/v1/merge-requests${buildMergeRequestListQuery(params)}`, { method: "GET" }),
461
+ listMergeRequestInbox: (params) => request(`/v1/merge-requests/inbox${buildMergeRequestInboxQuery(params)}`, { method: "GET" }),
451
462
  openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
452
463
  getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
453
464
  updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
@@ -463,60 +474,24 @@ function createApiClient(config, opts) {
463
474
  method: "POST",
464
475
  body: JSON.stringify(payload)
465
476
  }),
466
- listOrganizationMembers: (orgId, params) => {
467
- const qs = new URLSearchParams();
468
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
469
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
470
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
471
- return request(`/v1/organizations/${encodeURIComponent(orgId)}/members${suffix}`, { method: "GET" });
472
- },
477
+ listOrganizationMembers: (orgId, params) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
473
478
  updateOrganizationMember: (orgId, userId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`, {
474
479
  method: "PATCH",
475
480
  body: JSON.stringify(payload)
476
481
  }),
477
- listProjectMembers: (projectId, params) => {
478
- const qs = new URLSearchParams();
479
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
480
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
481
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
482
- return request(`/v1/projects/${encodeURIComponent(projectId)}/members${suffix}`, { method: "GET" });
483
- },
482
+ listProjectMembers: (projectId, params) => request(`/v1/projects/${encodeURIComponent(projectId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
484
483
  updateProjectMember: (projectId, userId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/members/${encodeURIComponent(userId)}`, {
485
484
  method: "PATCH",
486
485
  body: JSON.stringify(payload)
487
486
  }),
488
- listAppMembers: (appId, params) => {
489
- const qs = new URLSearchParams();
490
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
491
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
492
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
493
- return request(`/v1/apps/${encodeURIComponent(appId)}/members${suffix}`, { method: "GET" });
494
- },
487
+ listAppMembers: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
495
488
  updateAppMember: (appId, userId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/members/${encodeURIComponent(userId)}`, {
496
489
  method: "PATCH",
497
490
  body: JSON.stringify(payload)
498
491
  }),
499
- listOrganizationInvites: (orgId, params) => {
500
- const qs = new URLSearchParams();
501
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
502
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
503
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
504
- return request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations${suffix}`, { method: "GET" });
505
- },
506
- listProjectInvites: (projectId, params) => {
507
- const qs = new URLSearchParams();
508
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
509
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
510
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
511
- return request(`/v1/projects/${encodeURIComponent(projectId)}/invitations${suffix}`, { method: "GET" });
512
- },
513
- listAppInvites: (appId, params) => {
514
- const qs = new URLSearchParams();
515
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
516
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
517
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
518
- return request(`/v1/apps/${encodeURIComponent(appId)}/invitations${suffix}`, { method: "GET" });
519
- },
492
+ listOrganizationInvites: (orgId, params) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations${buildPaginationQuery(params)}`, { method: "GET" }),
493
+ listProjectInvites: (projectId, params) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations${buildPaginationQuery(params)}`, { method: "GET" }),
494
+ listAppInvites: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations${buildPaginationQuery(params)}`, { method: "GET" }),
520
495
  resendOrganizationInvite: (orgId, inviteId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
521
496
  method: "POST",
522
497
  body: JSON.stringify(payload ?? {})
@@ -539,6 +514,15 @@ function createApiClient(config, opts) {
539
514
  method: "DELETE"
540
515
  }),
541
516
  acceptInvitation: (payload) => request("/v1/invitations/accept", { method: "POST", body: JSON.stringify(payload) }),
517
+ listMyInvitations: () => request("/v1/me/invitations", { method: "GET" }),
518
+ acceptMyInvitation: (scope, inviteId) => request(
519
+ `/v1/me/invitations/${encodeURIComponent(scope)}/${encodeURIComponent(inviteId)}/accept`,
520
+ { method: "POST", body: JSON.stringify({}) }
521
+ ),
522
+ declineMyInvitation: (scope, inviteId) => request(
523
+ `/v1/me/invitations/${encodeURIComponent(scope)}/${encodeURIComponent(inviteId)}/decline`,
524
+ { method: "POST", body: JSON.stringify({}) }
525
+ ),
542
526
  syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
543
527
  method: "POST",
544
528
  body: JSON.stringify({})
@@ -583,8 +567,8 @@ function createApiClient(config, opts) {
583
567
  if (params?.currentPhase) qs.set("currentPhase", params.currentPhase);
584
568
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
585
569
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
586
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
587
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs${suffix}`, { method: "GET" });
570
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
571
+ return request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs${suffix2}`, { method: "GET" });
588
572
  },
589
573
  getAgentRun: (appId, runId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}`, { method: "GET" }),
590
574
  listAgentRunEvents: (appId, runId, params) => {
@@ -593,8 +577,8 @@ function createApiClient(config, opts) {
593
577
  if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
594
578
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
595
579
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
596
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
597
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}/events${suffix}`, {
580
+ const suffix2 = qs.toString() ? `?${qs.toString()}` : "";
581
+ return request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}/events${suffix2}`, {
598
582
  method: "GET"
599
583
  });
600
584
  },
@@ -10,30 +10,68 @@ import fs from "fs/promises";
10
10
  import { createHash } from "crypto";
11
11
  import os from "os";
12
12
  import path from "path";
13
+
14
+ // src/infrastructure/git/gitAdapter.ts
13
15
  import { execa } from "execa";
16
+ function createGitCommandPlan(params) {
17
+ return {
18
+ command: "git",
19
+ args: [...params.args],
20
+ cwd: params.cwd,
21
+ ...params.env ? { env: params.env } : {},
22
+ ...params.timeoutMs !== void 0 ? { timeoutMs: params.timeoutMs } : {},
23
+ ...params.maxBuffer !== void 0 ? { maxBuffer: params.maxBuffer } : {},
24
+ ...params.stripFinalNewline !== void 0 ? { stripFinalNewline: params.stripFinalNewline } : {},
25
+ ...params.reject !== void 0 ? { reject: params.reject } : {},
26
+ ...params.stderr !== void 0 ? { stderr: params.stderr } : {}
27
+ };
28
+ }
29
+ function createSystemGitAdapter() {
30
+ return {
31
+ async run(plan) {
32
+ const res = await execa(plan.command, plan.args, {
33
+ cwd: plan.cwd,
34
+ reject: plan.reject ?? false,
35
+ stderr: plan.stderr ?? "pipe",
36
+ ...plan.env ? { env: plan.env } : {},
37
+ ...plan.timeoutMs !== void 0 ? { timeout: plan.timeoutMs } : {},
38
+ ...plan.maxBuffer !== void 0 ? { maxBuffer: plan.maxBuffer } : {},
39
+ ...plan.stripFinalNewline !== void 0 ? { stripFinalNewline: plan.stripFinalNewline } : {}
40
+ });
41
+ return {
42
+ exitCode: res.exitCode ?? -1,
43
+ stdout: String(res.stdout ?? ""),
44
+ stderr: String(res.stderr ?? ""),
45
+ timedOut: res.timedOut === true
46
+ };
47
+ }
48
+ };
49
+ }
50
+
51
+ // src/infrastructure/repo/gitRepo.ts
14
52
  var GIT_REMOTE_PROTOCOL_RE = /^(https?|ssh):\/\//i;
15
53
  var SCP_LIKE_GIT_REMOTE_RE = /^(?<user>[^@\s]+)@(?<host>[^:\s]+):(?<path>[^\\\s]+)$/;
16
54
  var CANONICAL_GIT_REMOTE_RE = /^(?<host>(?:localhost|[a-z0-9.-]+))\/(?<path>[^\\\s]+)$/i;
17
55
  async function runGit(args, cwd) {
18
- const res = await execa("git", args, { cwd, stderr: "ignore" });
56
+ const res = await createSystemGitAdapter().run(createGitCommandPlan({ args, cwd, reject: true, stderr: "ignore" }));
19
57
  return String(res.stdout || "").trim();
20
58
  }
21
59
  async function runGitWithEnv(args, cwd, env) {
22
- const res = await execa("git", args, { cwd, env, stderr: "ignore" });
60
+ const res = await createSystemGitAdapter().run(createGitCommandPlan({ args, cwd, env, reject: true, stderr: "ignore" }));
23
61
  return String(res.stdout || "").trim();
24
62
  }
25
63
  async function runGitRaw(args, cwd) {
26
- const res = await execa("git", args, { cwd, stderr: "ignore", stripFinalNewline: false });
64
+ const res = await createSystemGitAdapter().run(createGitCommandPlan({ args, cwd, stripFinalNewline: false, reject: true, stderr: "ignore" }));
27
65
  return String(res.stdout || "");
28
66
  }
29
67
  async function runGitRawWithEnv(args, cwd, env) {
30
- const res = await execa("git", args, { cwd, env, stderr: "ignore", stripFinalNewline: false });
68
+ const res = await createSystemGitAdapter().run(createGitCommandPlan({ args, cwd, env, stripFinalNewline: false, reject: true, stderr: "ignore" }));
31
69
  return String(res.stdout || "");
32
70
  }
33
71
  async function runGitDetailed(args, cwd) {
34
- const res = await execa("git", args, { cwd, reject: false });
72
+ const res = await createSystemGitAdapter().run(createGitCommandPlan({ args, cwd }));
35
73
  return {
36
- exitCode: res.exitCode ?? 1,
74
+ exitCode: res.exitCode,
37
75
  stdout: String(res.stdout || ""),
38
76
  stderr: String(res.stderr || "")
39
77
  };
@@ -601,6 +639,8 @@ function summarizeUnifiedDiff(diff) {
601
639
  }
602
640
 
603
641
  export {
642
+ createGitCommandPlan,
643
+ createSystemGitAdapter,
604
644
  normalizeGitRemote,
605
645
  findGitRoot,
606
646
  getAbsoluteGitDir,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCurrentBranch
3
- } from "./chunk-S4ECO35X.js";
3
+ } from "./chunk-FA6PTZQI.js";
4
4
  import {
5
5
  RemixError
6
6
  } from "./chunk-7XJGOKEO.js";