@sampleapp.ai/sdk 1.0.30 → 1.0.31
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/components/sandbox/Sandbox.js +3 -2
- package/dist/components/sandbox/api.js +4 -28
- package/dist/components/sandbox/guardian/app-layout-no-sidebar.js +6 -3
- package/dist/components/sandbox/guardian/demo/guardian-demo.js +2 -2
- package/dist/components/sandbox/guardian/demo/left-view.js +17 -5
- package/dist/components/sandbox/guardian/guardian-component.js +7 -5
- package/dist/components/sandbox/guardian/guardian-playground.js +2 -2
- package/dist/components/sandbox/guardian/guardian-style-wrapper.js +17 -3
- package/dist/components/sandbox/guardian/hooks/use-sandbox-url-loader.js +0 -20
- package/dist/components/sandbox/guardian/right-view/pill-file-selector.js +13 -0
- package/dist/components/sandbox/guardian/right-view/right-panel-view.js +17 -4
- package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +42 -50
- package/dist/components/sandbox/guardian/ui/ai-loader.js +56 -13
- package/dist/components/sandbox/guardian/ui/download-and-open-buttons.js +117 -0
- package/dist/components/sandbox/guardian/ui/markdown/code-group/code-block.js +33 -66
- package/dist/components/sandbox/guardian/ui/markdown.js +15 -10
- package/dist/components/sandbox/guardian/utils.js +1 -0
- package/dist/components/sandbox/sandbox-home/SandboxCard.js +14 -8
- package/dist/components/sandbox/sandbox-home/SandboxHome.js +22 -81
- package/dist/components/sandbox/sandbox-home/SearchBar.js +1 -1
- package/dist/components/ui/skeleton.js +18 -0
- package/dist/index.d.ts +32 -438
- package/dist/index.es.js +23944 -23548
- package/dist/index.standalone.umd.js +13 -13
- package/dist/lib/api-client.js +47 -5
- package/dist/lib/generated-css.js +1 -1
- package/dist/sdk.css +1 -1
- package/dist/tailwind.css +1 -1
- package/package.json +12 -7
package/dist/lib/api-client.js
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SDK API Client for interacting with the SampleApp backend API
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Extract container ID from a browser URL
|
|
6
|
+
* @param browserUrl - URL like "https://nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2.sampleapp.love/?_ts=1767897000670"
|
|
7
|
+
* @returns Container ID like "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2" or null if not found
|
|
8
|
+
*/
|
|
9
|
+
export function extractContainerIdFromUrl(browserUrl) {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(browserUrl);
|
|
12
|
+
// Hostname is like "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2.sampleapp.love"
|
|
13
|
+
const hostname = url.hostname;
|
|
14
|
+
// Split by the first dot to get the container ID
|
|
15
|
+
const parts = hostname.split(".");
|
|
16
|
+
if (parts.length >= 2) {
|
|
17
|
+
return parts[0]; // e.g., "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2"
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const getBaseUrl = () => {
|
|
26
|
+
return process.env.BASE_API_URL || "https://api.sampleapp.ai";
|
|
27
|
+
};
|
|
4
28
|
/**
|
|
5
29
|
* Main API client class
|
|
6
30
|
*/
|
|
@@ -23,16 +47,16 @@ class ApiClient {
|
|
|
23
47
|
]);
|
|
24
48
|
},
|
|
25
49
|
/**
|
|
26
|
-
* Get all sandbox contents for a specific playground
|
|
50
|
+
* Get all sandbox contents for a specific playground (public access with truncated fields)
|
|
27
51
|
* @param playgroundUid - The UID of the playground
|
|
28
52
|
* @param skip - Number of records to skip (default: 0)
|
|
29
53
|
* @param limit - Maximum number of records to return (default: 100)
|
|
30
|
-
* @returns Array of sandbox content data
|
|
54
|
+
* @returns Array of sandbox content data with only uid and markdown fields
|
|
31
55
|
*/
|
|
32
56
|
getByPlayground: async (playgroundUid, skip = 0, limit = 100) => {
|
|
33
|
-
return this.request(["sandbox-content", "playground", playgroundUid], {
|
|
57
|
+
return this.request(["sandbox-content", "playground", playgroundUid, "public"], {
|
|
34
58
|
method: "GET",
|
|
35
|
-
},
|
|
59
|
+
}, false, // Public endpoint, no API key required
|
|
36
60
|
{ skip, limit });
|
|
37
61
|
},
|
|
38
62
|
};
|
|
@@ -51,8 +75,26 @@ class ApiClient {
|
|
|
51
75
|
body: JSON.stringify(request),
|
|
52
76
|
});
|
|
53
77
|
},
|
|
78
|
+
/**
|
|
79
|
+
* Get the download URL for a container's code
|
|
80
|
+
* @param containerId - The container ID (extracted from browserUrl)
|
|
81
|
+
* @returns The full URL to download the code
|
|
82
|
+
*/
|
|
83
|
+
getDownloadCodeUrl: (containerId) => {
|
|
84
|
+
return `${this.baseUrl}/api/v1/sdk/download-code?container_id=${encodeURIComponent(containerId)}`;
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
87
|
+
* Download code from a container
|
|
88
|
+
* @param containerId - The container ID (extracted from browserUrl)
|
|
89
|
+
* @returns Triggers a file download
|
|
90
|
+
*/
|
|
91
|
+
downloadCode: (containerId) => {
|
|
92
|
+
const url = this.sdk.getDownloadCodeUrl(containerId);
|
|
93
|
+
window.open(url, "_blank");
|
|
94
|
+
},
|
|
54
95
|
};
|
|
55
|
-
|
|
96
|
+
const defaultBaseUrl = getBaseUrl();
|
|
97
|
+
this.baseUrl = defaultBaseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
56
98
|
this.apiKey = config.apiKey;
|
|
57
99
|
}
|
|
58
100
|
/**
|