@lovable.dev/sdk 1.7.0 → 1.9.0
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/README.md +158 -301
- package/dist/index.d.ts +1138 -1150
- package/dist/index.js +22 -15
- package/dist/index.js.map +1 -1
- package/dist/schemas.d.ts +3029 -381
- package/dist/schemas.js +716 -279
- package/dist/schemas.js.map +1 -1
- package/package.json +2 -1
- package/src/client.ts +28 -20
- package/src/generated/paths.ts +1117 -1132
- package/src/generated/version.ts +1 -1
- package/src/generated/zod/zod.gen.ts +563 -274
- package/src/index.ts +1 -0
- package/src/schemas-deprecated.ts +234 -0
- package/src/schemas.ts +11 -17
- package/src/types.ts +19 -22
package/src/client.ts
CHANGED
|
@@ -321,7 +321,7 @@ export class LovableClient {
|
|
|
321
321
|
params: {
|
|
322
322
|
query: {
|
|
323
323
|
workspace_id: workspaceId,
|
|
324
|
-
|
|
324
|
+
query: options?.query,
|
|
325
325
|
visibility: options?.visibility,
|
|
326
326
|
publish_status: options?.publish_status,
|
|
327
327
|
folder_id: options?.folder_id,
|
|
@@ -1222,6 +1222,7 @@ export class LovableClient {
|
|
|
1222
1222
|
workspace_id: options.workspaceId,
|
|
1223
1223
|
source_project_id: sourceProjectId,
|
|
1224
1224
|
include_history: options.includeHistory,
|
|
1225
|
+
include_files: options.includeFiles,
|
|
1225
1226
|
include_custom_knowledge: options.includeCustomKnowledge,
|
|
1226
1227
|
description: options.description,
|
|
1227
1228
|
display_name: options.projectName,
|
|
@@ -1253,9 +1254,9 @@ export class LovableClient {
|
|
|
1253
1254
|
/**
|
|
1254
1255
|
* Wait for a remix operation to complete.
|
|
1255
1256
|
*
|
|
1256
|
-
* Polls the remix
|
|
1257
|
+
* Polls the remix job endpoint until the job reaches "completed" or "error" status.
|
|
1257
1258
|
*
|
|
1258
|
-
* @param sourceProjectId - The source project ID
|
|
1259
|
+
* @param sourceProjectId - The source project ID. Kept for backward compatibility; the public job endpoint is keyed by job ID.
|
|
1259
1260
|
* @param jobId - The job ID returned by `remixProject()`
|
|
1260
1261
|
* @param options.pollInterval - Time between polls in ms (default: 2000)
|
|
1261
1262
|
* @param options.timeout - Maximum time to wait in ms (default: 300000 = 5 minutes)
|
|
@@ -1269,29 +1270,34 @@ export class LovableClient {
|
|
|
1269
1270
|
const startTime = Date.now();
|
|
1270
1271
|
|
|
1271
1272
|
while (true) {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
}
|
|
1273
|
+
let delayMs = pollInterval;
|
|
1274
|
+
try {
|
|
1275
|
+
const { data } = await this.typed.GET("/v1/remix-jobs/{job_id}", {
|
|
1276
|
+
params: { path: { job_id: jobId } },
|
|
1277
|
+
});
|
|
1278
|
+
const progress = data!;
|
|
1279
|
+
const status = progress.status as RemixJobStatus;
|
|
1280
|
+
options?.onProgress?.(status, progress.step);
|
|
1281
|
+
|
|
1282
|
+
if (status === "completed" && progress.result) {
|
|
1283
|
+
return { projectId: progress.result.project_id };
|
|
1284
|
+
}
|
|
1285
1285
|
|
|
1286
|
-
|
|
1287
|
-
|
|
1286
|
+
if (status === "error") {
|
|
1287
|
+
throw new Error(progress.error_message ?? "Remix failed");
|
|
1288
|
+
}
|
|
1289
|
+
} catch (err) {
|
|
1290
|
+
// The route asks pollers to honor Retry-After on 429; anything else is final.
|
|
1291
|
+
if (!(err instanceof ApiError) || err.status !== 429) throw err;
|
|
1292
|
+
delayMs = Math.max(err.rateLimit?.retryAfterMs ?? pollInterval, pollInterval);
|
|
1288
1293
|
}
|
|
1289
1294
|
|
|
1290
|
-
|
|
1295
|
+
const remainingMs = timeout - (Date.now() - startTime);
|
|
1296
|
+
if (remainingMs <= 0) {
|
|
1291
1297
|
throw new Error(`Timeout waiting for remix of project ${sourceProjectId}`);
|
|
1292
1298
|
}
|
|
1293
1299
|
|
|
1294
|
-
await sleep(
|
|
1300
|
+
await sleep(Math.min(delayMs, remainingMs));
|
|
1295
1301
|
}
|
|
1296
1302
|
}
|
|
1297
1303
|
|
|
@@ -1509,6 +1515,7 @@ function terminalResultFromMessage(msg: GetMessageResponse, fallbackMessageId: s
|
|
|
1509
1515
|
if (ai && isTerminalAIStatus(ai.status)) {
|
|
1510
1516
|
return {
|
|
1511
1517
|
status: messageCompletionStatus(ai.status),
|
|
1518
|
+
...(ai.completion_reason ? { completion_reason: ai.completion_reason } : {}),
|
|
1512
1519
|
message_id: ai.message_id || fallbackMessageId,
|
|
1513
1520
|
content: ai.content,
|
|
1514
1521
|
edit_id: ai.edit_id,
|
|
@@ -1522,6 +1529,7 @@ function terminalResultFromMessage(msg: GetMessageResponse, fallbackMessageId: s
|
|
|
1522
1529
|
if (msg.role === "assistant" && isTerminalAIStatus(msg.status)) {
|
|
1523
1530
|
return {
|
|
1524
1531
|
status: messageCompletionStatus(msg.status),
|
|
1532
|
+
...(msg.completion_reason ? { completion_reason: msg.completion_reason } : {}),
|
|
1525
1533
|
message_id: msg.message_id || fallbackMessageId,
|
|
1526
1534
|
content: msg.content,
|
|
1527
1535
|
edit_id: msg.edit_id,
|