@remixhq/core 0.1.24 → 0.1.26

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,6 +278,7 @@ function createApiClient(config, opts) {
200
278
  method: "POST",
201
279
  body: JSON.stringify(payload ?? {})
202
280
  }),
281
+ getAppPreview: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/preview${buildAppPreviewQuery(params)}`, { method: "GET" }),
203
282
  runAppSandboxCommand: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/commands/run`, {
204
283
  method: "POST",
205
284
  body: JSON.stringify(payload)
@@ -207,14 +286,14 @@ function createApiClient(config, opts) {
207
286
  listAppSandboxCommandHistory: (appId, params) => {
208
287
  const qs = new URLSearchParams();
209
288
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
210
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
211
- 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" });
212
291
  },
213
292
  listProjectTriggerEvents: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/events`, { method: "GET" }),
214
293
  listProjectTriggers: (projectId, params) => {
215
- const qs = triggerQuery(params);
216
- const suffix = qs ? `?${qs}` : "";
217
- 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" });
218
297
  },
219
298
  createProjectTrigger: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers`, {
220
299
  method: "POST",
@@ -228,9 +307,9 @@ function createApiClient(config, opts) {
228
307
  method: "DELETE"
229
308
  }),
230
309
  resolveProjectTriggers: (projectId, params) => {
231
- const qs = triggerQuery(params);
232
- const suffix = qs ? `?${qs}` : "";
233
- 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" });
234
313
  },
235
314
  runAppTrigger: (appId, triggerId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/triggers/${encodeURIComponent(triggerId)}/run`, {
236
315
  method: "POST",
@@ -241,9 +320,9 @@ function createApiClient(config, opts) {
241
320
  body: JSON.stringify(payload)
242
321
  }),
243
322
  listProjectTriggerRuns: (projectId, params) => {
244
- const qs = triggerQuery(params);
245
- const suffix = qs ? `?${qs}` : "";
246
- 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" });
247
326
  },
248
327
  getProjectTriggerRun: (projectId, runId) => request(`/v1/projects/${encodeURIComponent(projectId)}/triggers/runs/${encodeURIComponent(runId)}`, {
249
328
  method: "GET"
@@ -261,6 +340,8 @@ function createApiClient(config, opts) {
261
340
  if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
262
341
  if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
263
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);
264
345
  qs.set("branchName", params.branchName);
265
346
  return request(`/v1/projects/bindings/resolve-lane?${qs.toString()}`, { method: "GET" });
266
347
  },
@@ -276,47 +357,19 @@ function createApiClient(config, opts) {
276
357
  method: "POST",
277
358
  body: JSON.stringify(payload ?? {})
278
359
  }),
279
- listApps: (params) => {
280
- const qs = new URLSearchParams();
281
- if (params?.projectId) qs.set("projectId", params.projectId);
282
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
283
- if (params?.ownership) qs.set("ownership", params.ownership);
284
- if (params?.accessScope) qs.set("accessScope", params.accessScope);
285
- if (params?.createdBy) qs.set("createdBy", params.createdBy);
286
- if (params?.forked) qs.set("forked", params.forked);
287
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
288
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
289
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
290
- return request(`/v1/apps${suffix}`, { method: "GET" });
291
- },
360
+ listApps: (params) => request(`/v1/apps${buildAppListQuery(params)}`, { method: "GET" }),
292
361
  getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
362
+ updateAppStatus: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/status`, {
363
+ method: "PATCH",
364
+ body: JSON.stringify(payload)
365
+ }),
293
366
  openApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/open`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
294
367
  getAppContext: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/context`, { method: "GET" }),
295
368
  getAppOverview: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/overview`, { method: "GET" }),
296
- listAppTimeline: (appId, params) => {
297
- const qs = new URLSearchParams();
298
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
299
- if (params?.cursor) qs.set("cursor", params.cursor);
300
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
301
- return request(`/v1/apps/${encodeURIComponent(appId)}/timeline${suffix}`, { method: "GET" });
302
- },
369
+ listAppTimeline: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/timeline${buildAppTimelineQuery(params)}`, { method: "GET" }),
303
370
  getAppTimelineEvent: (appId, eventId) => request(`/v1/apps/${encodeURIComponent(appId)}/timeline/${encodeURIComponent(eventId)}`, { method: "GET" }),
304
- listAppEditQueue: (appId, params) => {
305
- const qs = new URLSearchParams();
306
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
307
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
308
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
309
- return request(`/v1/apps/${encodeURIComponent(appId)}/edit-queue${suffix}`, { method: "GET" });
310
- },
311
- listAppJobQueue: (appId, params) => {
312
- const qs = new URLSearchParams();
313
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
314
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
315
- for (const kind of params?.kind ?? []) qs.append("kind", kind);
316
- for (const status of params?.status ?? []) qs.append("status", status);
317
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
318
- return request(`/v1/apps/${encodeURIComponent(appId)}/job-queue${suffix}`, { method: "GET" });
319
- },
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" }),
320
373
  getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
321
374
  presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
322
375
  importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
@@ -339,8 +392,8 @@ function createApiClient(config, opts) {
339
392
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
340
393
  if (params?.offset !== void 0) qs.set("offset", String(params.offset));
341
394
  if (params?.idempotencyKey) qs.set("idempotencyKey", params.idempotencyKey);
342
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
343
- 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" });
344
397
  },
345
398
  createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
346
399
  method: "POST",
@@ -359,8 +412,8 @@ function createApiClient(config, opts) {
359
412
  if (params?.collabLaneId) qs.set("collabLaneId", params.collabLaneId);
360
413
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
361
414
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
362
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
363
- 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" });
364
417
  },
365
418
  getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
366
419
  method: "GET"
@@ -375,8 +428,8 @@ function createApiClient(config, opts) {
375
428
  if (params?.kinds?.length) {
376
429
  for (const kind of params.kinds) qs.append("kinds", kind);
377
430
  }
378
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
379
- 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" });
380
433
  },
381
434
  searchAgentMemory: (appId, params) => {
382
435
  const qs = new URLSearchParams();
@@ -404,38 +457,8 @@ function createApiClient(config, opts) {
404
457
  getChangeStepReplayDiff: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}/diff`, {
405
458
  method: "GET"
406
459
  }),
407
- listMergeRequests: (params) => {
408
- const qs = new URLSearchParams();
409
- if (params?.queue) qs.set("queue", params.queue);
410
- if (params?.appId) qs.set("appId", params.appId);
411
- if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
412
- if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
413
- if (Array.isArray(params?.status)) {
414
- for (const status of params.status) qs.append("status", status);
415
- } else if (typeof params?.status === "string") {
416
- qs.set("status", params.status);
417
- }
418
- if (params?.kind) qs.set("kind", params.kind);
419
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
420
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
421
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
422
- return request(`/v1/merge-requests${suffix}`, { method: "GET" });
423
- },
424
- listMergeRequestInbox: (params) => {
425
- const qs = new URLSearchParams();
426
- if (Array.isArray(params?.status)) {
427
- for (const status of params.status) qs.append("status", status);
428
- } else if (typeof params?.status === "string") {
429
- qs.set("status", params.status);
430
- }
431
- if (params?.kind) qs.set("kind", params.kind);
432
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
433
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
434
- if (typeof params?.includeReview === "boolean") qs.set("includeReview", String(params.includeReview));
435
- if (typeof params?.includeDiffs === "boolean") qs.set("includeDiffs", String(params.includeDiffs));
436
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
437
- return request(`/v1/merge-requests/inbox${suffix}`, { method: "GET" });
438
- },
460
+ listMergeRequests: (params) => request(`/v1/merge-requests${buildMergeRequestListQuery(params)}`, { method: "GET" }),
461
+ listMergeRequestInbox: (params) => request(`/v1/merge-requests/inbox${buildMergeRequestInboxQuery(params)}`, { method: "GET" }),
439
462
  openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
440
463
  getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
441
464
  updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
@@ -451,60 +474,24 @@ function createApiClient(config, opts) {
451
474
  method: "POST",
452
475
  body: JSON.stringify(payload)
453
476
  }),
454
- listOrganizationMembers: (orgId, params) => {
455
- const qs = new URLSearchParams();
456
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
457
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
458
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
459
- return request(`/v1/organizations/${encodeURIComponent(orgId)}/members${suffix}`, { method: "GET" });
460
- },
477
+ listOrganizationMembers: (orgId, params) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
461
478
  updateOrganizationMember: (orgId, userId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`, {
462
479
  method: "PATCH",
463
480
  body: JSON.stringify(payload)
464
481
  }),
465
- listProjectMembers: (projectId, params) => {
466
- const qs = new URLSearchParams();
467
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
468
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
469
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
470
- return request(`/v1/projects/${encodeURIComponent(projectId)}/members${suffix}`, { method: "GET" });
471
- },
482
+ listProjectMembers: (projectId, params) => request(`/v1/projects/${encodeURIComponent(projectId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
472
483
  updateProjectMember: (projectId, userId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/members/${encodeURIComponent(userId)}`, {
473
484
  method: "PATCH",
474
485
  body: JSON.stringify(payload)
475
486
  }),
476
- listAppMembers: (appId, params) => {
477
- const qs = new URLSearchParams();
478
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
479
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
480
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
481
- return request(`/v1/apps/${encodeURIComponent(appId)}/members${suffix}`, { method: "GET" });
482
- },
487
+ listAppMembers: (appId, params) => request(`/v1/apps/${encodeURIComponent(appId)}/members${buildPaginationQuery(params)}`, { method: "GET" }),
483
488
  updateAppMember: (appId, userId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/members/${encodeURIComponent(userId)}`, {
484
489
  method: "PATCH",
485
490
  body: JSON.stringify(payload)
486
491
  }),
487
- listOrganizationInvites: (orgId, params) => {
488
- const qs = new URLSearchParams();
489
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
490
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
491
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
492
- return request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations${suffix}`, { method: "GET" });
493
- },
494
- listProjectInvites: (projectId, params) => {
495
- const qs = new URLSearchParams();
496
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
497
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
498
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
499
- return request(`/v1/projects/${encodeURIComponent(projectId)}/invitations${suffix}`, { method: "GET" });
500
- },
501
- listAppInvites: (appId, params) => {
502
- const qs = new URLSearchParams();
503
- if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
504
- if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
505
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
506
- return request(`/v1/apps/${encodeURIComponent(appId)}/invitations${suffix}`, { method: "GET" });
507
- },
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" }),
508
495
  resendOrganizationInvite: (orgId, inviteId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
509
496
  method: "POST",
510
497
  body: JSON.stringify(payload ?? {})
@@ -527,6 +514,15 @@ function createApiClient(config, opts) {
527
514
  method: "DELETE"
528
515
  }),
529
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
+ ),
530
526
  syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
531
527
  method: "POST",
532
528
  body: JSON.stringify({})
@@ -571,8 +567,8 @@ function createApiClient(config, opts) {
571
567
  if (params?.currentPhase) qs.set("currentPhase", params.currentPhase);
572
568
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
573
569
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
574
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
575
- 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" });
576
572
  },
577
573
  getAgentRun: (appId, runId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-runs/${encodeURIComponent(runId)}`, { method: "GET" }),
578
574
  listAgentRunEvents: (appId, runId, params) => {
@@ -581,8 +577,8 @@ function createApiClient(config, opts) {
581
577
  if (typeof params?.offset === "number") qs.set("offset", String(params.offset));
582
578
  if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
583
579
  if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
584
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
585
- 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}`, {
586
582
  method: "GET"
587
583
  });
588
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";