busabase-sdk 0.17.0 → 0.17.2
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/airapp-node.js +14 -1
- package/dist/airapp.d.ts +4 -1
- package/dist/airapp.js +23 -0
- package/package.json +3 -3
package/dist/airapp-node.js
CHANGED
|
@@ -43,7 +43,20 @@ var normalizeOrigin = (raw, fallback = DEFAULT_CLOUD_BASE_URL) => {
|
|
|
43
43
|
}
|
|
44
44
|
return url.origin;
|
|
45
45
|
};
|
|
46
|
-
var requestOrigin = (request) =>
|
|
46
|
+
var requestOrigin = (request) => {
|
|
47
|
+
const directOrigin = new URL(request.url).origin;
|
|
48
|
+
const forwardedHost = request.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
|
49
|
+
const forwardedProto = request.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
50
|
+
if (!forwardedHost || !forwardedProto || !["http", "https"].includes(forwardedProto))
|
|
51
|
+
return directOrigin;
|
|
52
|
+
try {
|
|
53
|
+
const forwardedOrigin = new URL(`${forwardedProto}://${forwardedHost}`).origin;
|
|
54
|
+
const browserOrigin = request.headers.get("origin");
|
|
55
|
+
return browserOrigin && browserOrigin !== forwardedOrigin ? directOrigin : forwardedOrigin;
|
|
56
|
+
} catch {
|
|
57
|
+
return directOrigin;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
47
60
|
var isLoopbackOrigin = (origin) => {
|
|
48
61
|
const url = new URL(origin);
|
|
49
62
|
return url.protocol === "http:" && LOOPBACK_HOSTNAMES.includes(url.hostname);
|
package/dist/airapp.d.ts
CHANGED
|
@@ -251,7 +251,7 @@ declare function inspectProvisionedResources(client: AirAppProvisioningClient, c
|
|
|
251
251
|
*/
|
|
252
252
|
declare function provisionDeclaredResources(client: AirAppProvisioningClient, config: AirAppResourceConfig): Promise<AirAppResources>;
|
|
253
253
|
/** The client surface `publishAirApp` needs, on top of provisioning. */
|
|
254
|
-
type AirAppPublishClient = AirAppProvisioningClient & Pick<BusabaseClient, "fileTrees">;
|
|
254
|
+
type AirAppPublishClient = AirAppProvisioningClient & Pick<BusabaseClient, "fileTrees" | "changeRequests">;
|
|
255
255
|
/** One file of the app's built AirApp bundle, as `publishAirApp` receives it. */
|
|
256
256
|
interface AirAppFileInput {
|
|
257
257
|
path: string;
|
|
@@ -264,6 +264,9 @@ type AirAppPublishResult = {
|
|
|
264
264
|
} | {
|
|
265
265
|
status: "updated";
|
|
266
266
|
changeRequestId: string;
|
|
267
|
+
} | {
|
|
268
|
+
status: "pending";
|
|
269
|
+
changeRequestId: string;
|
|
267
270
|
};
|
|
268
271
|
/**
|
|
269
272
|
* The create-vs-update operation list for one AirApp publish. Pure — no I/O —
|
package/dist/airapp.js
CHANGED
|
@@ -372,6 +372,25 @@ function buildAirAppFileOperations(localFiles, deployedPaths) {
|
|
|
372
372
|
})
|
|
373
373
|
);
|
|
374
374
|
}
|
|
375
|
+
async function findPendingAirAppCreate(client, slug) {
|
|
376
|
+
let cursor;
|
|
377
|
+
for (let page = 0; page < 10; page += 1) {
|
|
378
|
+
const result = await client.changeRequests.list({
|
|
379
|
+
status: ["in_review"],
|
|
380
|
+
...cursor ? { cursor } : {}
|
|
381
|
+
});
|
|
382
|
+
for (const changeRequest of result.changeRequests) {
|
|
383
|
+
const matches = (changeRequest.operations ?? []).some((operation) => {
|
|
384
|
+
const payload = operation.headCommit?.payload;
|
|
385
|
+
return payload?.kind === "create" && payload?.nodeType === "airapp" && payload?.slug === slug;
|
|
386
|
+
});
|
|
387
|
+
if (matches) return changeRequest.id;
|
|
388
|
+
}
|
|
389
|
+
if (!result.nextCursor) return null;
|
|
390
|
+
cursor = result.nextCursor;
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
375
394
|
async function publishAirApp(client, config, files) {
|
|
376
395
|
const airApp = config.airApp;
|
|
377
396
|
if (!airApp) {
|
|
@@ -385,6 +404,10 @@ async function publishAirApp(client, config, files) {
|
|
|
385
404
|
);
|
|
386
405
|
}
|
|
387
406
|
if (!current.airApp) {
|
|
407
|
+
const pendingChangeRequestId = await findPendingAirAppCreate(client, airApp.slug);
|
|
408
|
+
if (pendingChangeRequestId) {
|
|
409
|
+
return { status: "pending", changeRequestId: pendingChangeRequestId };
|
|
410
|
+
}
|
|
388
411
|
const changeRequest2 = await client.fileTrees.create({
|
|
389
412
|
type: "airapp",
|
|
390
413
|
parentNodeId: current.folder.nodeId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "busabase-sdk",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "Typed TypeScript/JavaScript SDK for the Busabase OpenAPI REST API. Talks to a local or remote `busabase server` (or Busabase Cloud).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/busabase/busabase/tree/main/apps/busabase-sdk",
|
|
@@ -64,8 +64,8 @@
|
|
|
64
64
|
"typescript": "^5.9.3",
|
|
65
65
|
"vitest": "^2.1.8",
|
|
66
66
|
"open-domains": "0.0.2",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
67
|
+
"busabase-contract": "0.17.2",
|
|
68
|
+
"openlib": "0.1.1"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=24.18.0"
|