@sampleapp.ai/sdk 1.0.29 → 1.0.30
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/guardian/app-layout-no-sidebar.js +8 -0
- package/dist/components/guardian/ask-ai-view.js +249 -0
- package/dist/components/guardian/code-focus-section.d.ts +41 -0
- package/dist/components/guardian/code-focus-section.js +174 -0
- package/dist/components/guardian/context/guardian-context.js +94 -0
- package/dist/components/guardian/context/vm-context.js +28 -0
- package/dist/components/guardian/default-guide-view.js +34 -0
- package/dist/components/guardian/demo/guardian-demo.js +35 -0
- package/dist/components/guardian/demo/left-view/toggle.js +28 -0
- package/dist/components/guardian/demo/left-view.js +49 -0
- package/dist/components/guardian/guardian-component.js +79 -0
- package/dist/components/guardian/guardian-demo.js +35 -0
- package/dist/components/guardian/guardian-home.d.ts +4 -0
- package/dist/components/guardian/guardian-home.js +61 -0
- package/dist/components/guardian/guardian-playground.js +45 -0
- package/dist/components/guardian/guardian-style-wrapper.js +29 -0
- package/dist/components/guardian/guardian-upload-spec.d.ts +14 -0
- package/dist/components/guardian/guardian-upload-spec.js +160 -0
- package/dist/components/guardian/header/glassmorphic-combobox.d.ts +15 -0
- package/dist/components/guardian/header/glassmorphic-combobox.js +30 -0
- package/dist/components/guardian/header.js +61 -0
- package/dist/components/guardian/hooks/use-frame-messages.js +65 -0
- package/dist/components/guardian/hooks/use-frame-params.js +44 -0
- package/dist/components/guardian/hooks/use-sandbox-url-loader.js +101 -0
- package/dist/components/guardian/ide/browser.js +538 -0
- package/dist/components/guardian/index.js +8 -0
- package/dist/components/guardian/layout/app-layout-no-sidebar.js +8 -0
- package/dist/components/guardian/layout/header/glassmorphic-combobox.js +48 -0
- package/dist/components/guardian/layout/header.js +63 -0
- package/dist/components/guardian/right-view/code-view.js +56 -0
- package/dist/components/guardian/right-view/pill-file-selector.js +233 -0
- package/dist/components/guardian/right-view/preview-control-bar.js +25 -0
- package/dist/components/guardian/right-view/right-panel-view.js +38 -0
- package/dist/components/guardian/right-view/right-top-down-view.js +289 -0
- package/dist/components/guardian/right-view/right-view.js +28 -0
- package/dist/components/guardian/right-view/simplified-editor.js +234 -0
- package/dist/components/guardian/types/ide-types.js +162 -0
- package/dist/components/guardian/types.js +3 -0
- package/dist/components/guardian/ui/ai-loader.js +48 -0
- package/dist/components/guardian/ui/badge.js +24 -0
- package/dist/components/guardian/ui/button.js +45 -0
- package/dist/components/guardian/ui/command.js +63 -0
- package/dist/components/guardian/ui/console-with-app.js +17 -0
- package/dist/components/guardian/ui/dialog.js +57 -0
- package/dist/components/guardian/ui/dropdown-menu.js +82 -0
- package/dist/components/guardian/ui/markdown.js +57 -0
- package/dist/components/guardian/ui/popover.js +25 -0
- package/dist/components/guardian/ui/tooltip.js +25 -0
- package/dist/components/guardian/utils.js +88 -0
- package/dist/components/guardian/zip-to-codebase.js +246 -0
- package/dist/components/guardian/zip-to-filetree.js +284 -0
- package/dist/components/icons.js +22 -0
- package/dist/components/sandbox/Sandbox.js +87 -0
- package/dist/components/sandbox/SandboxHome.js +141 -0
- package/dist/components/sandbox/api.js +108 -0
- package/dist/components/sandbox/guardian/app-layout-no-sidebar.js +8 -0
- package/dist/components/sandbox/guardian/ask-ai-view.js +249 -0
- package/dist/components/sandbox/guardian/code-focus-section.js +174 -0
- package/dist/components/sandbox/guardian/context/guardian-context.js +94 -0
- package/dist/components/sandbox/guardian/context/vm-context.js +28 -0
- package/dist/components/sandbox/guardian/default-guide-view.js +34 -0
- package/dist/components/sandbox/guardian/demo/guardian-demo.js +35 -0
- package/dist/components/sandbox/guardian/demo/left-view/toggle.js +28 -0
- package/dist/components/sandbox/guardian/demo/left-view.js +58 -0
- package/dist/components/sandbox/guardian/guardian-component.js +97 -0
- package/dist/components/sandbox/guardian/guardian-demo.js +35 -0
- package/dist/components/sandbox/guardian/guardian-home.d.ts +4 -0
- package/dist/components/sandbox/guardian/guardian-home.js +61 -0
- package/dist/components/sandbox/guardian/guardian-playground.js +45 -0
- package/dist/components/sandbox/guardian/guardian-style-wrapper.js +33 -0
- package/dist/components/sandbox/guardian/guardian-upload-spec.d.ts +14 -0
- package/dist/components/sandbox/guardian/guardian-upload-spec.js +160 -0
- package/dist/components/sandbox/guardian/header/glassmorphic-combobox.js +30 -0
- package/dist/components/sandbox/guardian/header.js +61 -0
- package/dist/components/sandbox/guardian/hooks/use-frame-messages.js +65 -0
- package/dist/components/sandbox/guardian/hooks/use-frame-params.js +44 -0
- package/dist/components/sandbox/guardian/hooks/use-sandbox-url-loader.js +145 -0
- package/dist/components/sandbox/guardian/ide/browser.js +538 -0
- package/dist/components/sandbox/guardian/index.js +8 -0
- package/dist/components/sandbox/guardian/right-view/code-view.js +60 -0
- package/dist/components/sandbox/guardian/right-view/pill-file-selector.js +233 -0
- package/dist/components/sandbox/guardian/right-view/preview-control-bar.js +25 -0
- package/dist/components/sandbox/guardian/right-view/right-panel-view.js +38 -0
- package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +289 -0
- package/dist/components/sandbox/guardian/right-view/right-view.js +28 -0
- package/dist/components/sandbox/guardian/right-view/simplified-editor.js +234 -0
- package/dist/components/sandbox/guardian/types/ide-types.js +162 -0
- package/dist/components/sandbox/guardian/types.js +3 -0
- package/dist/components/sandbox/guardian/ui/ai-loader.js +48 -0
- package/dist/components/sandbox/guardian/ui/badge.js +24 -0
- package/dist/components/sandbox/guardian/ui/button.js +45 -0
- package/dist/components/sandbox/guardian/ui/command.js +63 -0
- package/dist/components/sandbox/guardian/ui/console-with-app.js +17 -0
- package/dist/components/sandbox/guardian/ui/dialog.js +57 -0
- package/dist/components/sandbox/guardian/ui/dropdown-menu.js +82 -0
- package/dist/components/sandbox/guardian/ui/markdown/accordion-group/accordion.js +62 -0
- package/dist/components/sandbox/guardian/ui/markdown/accordion-group.js +23 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-check.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-error.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-info.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-note.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-tip.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/callout-warning.js +4 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/shared/callout.js +9 -0
- package/dist/components/sandbox/guardian/ui/markdown/callout/shared/types.js +1 -0
- package/dist/components/sandbox/guardian/ui/markdown/card-group/card.js +18 -0
- package/dist/components/sandbox/guardian/ui/markdown/card-group.js +25 -0
- package/dist/components/sandbox/guardian/ui/markdown/code-group/code-block.js +87 -0
- package/dist/components/sandbox/guardian/ui/markdown/code-group.js +101 -0
- package/dist/components/sandbox/guardian/ui/markdown/icon.js +31 -0
- package/dist/components/sandbox/guardian/ui/markdown.js +786 -0
- package/dist/components/sandbox/guardian/ui/popover.js +25 -0
- package/dist/components/sandbox/guardian/ui/tooltip.js +25 -0
- package/dist/components/sandbox/guardian/utils.js +88 -0
- package/dist/components/sandbox/guardian/zip-to-codebase.js +259 -0
- package/dist/components/sandbox/guardian/zip-to-filetree.js +284 -0
- package/dist/components/sandbox/index.js +4 -0
- package/dist/components/sandbox/sandbox-control-bar.js +91 -0
- package/dist/components/sandbox/sandbox-header.js +52 -0
- package/dist/components/sandbox/sandbox-home/SandboxCard.js +59 -0
- package/dist/components/sandbox/sandbox-home/SandboxHome.js +174 -0
- package/dist/components/sandbox/sandbox-home/SearchBar.js +12 -0
- package/dist/components/sandbox/sandbox-home/index.js +3 -0
- package/dist/components/sandbox/sandbox-left-panel.js +248 -0
- package/dist/components/sandbox/sandbox-loading.js +48 -0
- package/dist/components/sandbox/sandbox-right-panel.js +247 -0
- package/dist/components/sandbox/types.js +1 -0
- package/dist/components/sandbox.js +32 -0
- package/dist/components/tailwind-example.js +46 -0
- package/dist/index.d.ts +336 -1
- package/dist/index.es.js +90131 -421
- package/dist/index.js +13 -2
- package/dist/index.standalone.js +61 -53
- package/dist/index.standalone.umd.js +17 -24
- package/dist/lib/api-client.example.js +60 -0
- package/dist/lib/api-client.js +98 -0
- package/dist/lib/generated-css.js +4 -0
- package/dist/lib/inject-styles.js +42 -0
- package/dist/lib/shadow-dom-wrapper.js +42 -0
- package/dist/lib/utils.js +5 -0
- package/dist/sdk.css +1 -1
- package/dist/tailwind.css +1 -0
- package/package.json +32 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of the API client
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the API client to interact with
|
|
5
|
+
* the SampleApp backend API.
|
|
6
|
+
*
|
|
7
|
+
* The apiKey will be passed in from SandboxProps.apiKey (from types.ts)
|
|
8
|
+
*/
|
|
9
|
+
import { createApiClient } from "./api-client";
|
|
10
|
+
// Example: How to use the API client with apiKey from SandboxProps
|
|
11
|
+
function createClientFromSandboxProps(props, baseUrl = "http://127.0.0.1:8000") {
|
|
12
|
+
return createApiClient({
|
|
13
|
+
baseUrl,
|
|
14
|
+
apiKey: props.apiKey, // apiKey comes from SandboxProps
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
// Initialize the API client (example)
|
|
18
|
+
const client = createApiClient({
|
|
19
|
+
baseUrl: "http://127.0.0.1:8000", // or your production URL
|
|
20
|
+
apiKey: "your-api-key-here", // This will come from SandboxProps.apiKey
|
|
21
|
+
});
|
|
22
|
+
// Example 1: Get public sandbox content
|
|
23
|
+
// Note: sandboxId from SandboxProps maps to sandbox_content_uid
|
|
24
|
+
async function getSandboxContentExample(apiKey, sandboxId, baseUrl = "http://127.0.0.1:8000") {
|
|
25
|
+
try {
|
|
26
|
+
const client = createApiClient({
|
|
27
|
+
baseUrl,
|
|
28
|
+
apiKey, // apiKey from SandboxProps.apiKey
|
|
29
|
+
});
|
|
30
|
+
// sandboxId from SandboxProps maps to sandbox_content_uid
|
|
31
|
+
const sandboxContent = await client.sandboxContent.getPublic(sandboxId);
|
|
32
|
+
console.log("Sandbox content:", sandboxContent);
|
|
33
|
+
return sandboxContent;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.error("Error fetching sandbox content:", error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Example 2: Start a sandbox
|
|
41
|
+
async function startSandboxExample() {
|
|
42
|
+
try {
|
|
43
|
+
const response = await client.sdk.startSandbox({
|
|
44
|
+
env: {
|
|
45
|
+
API_KEY: "your-api-key",
|
|
46
|
+
ENVIRONMENT: "production",
|
|
47
|
+
},
|
|
48
|
+
apiKey: "your-sdk-api-key",
|
|
49
|
+
chatUid: "your-chat-uid",
|
|
50
|
+
});
|
|
51
|
+
console.log("Container URL:", response.container_url);
|
|
52
|
+
return response;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error("Error starting sandbox:", error);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Export examples for use in other files
|
|
60
|
+
export { getSandboxContentExample, startSandboxExample, createClientFromSandboxProps, };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK API Client for interacting with the SampleApp backend API
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Main API client class
|
|
6
|
+
*/
|
|
7
|
+
class ApiClient {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
/**
|
|
10
|
+
* Sandbox content endpoints
|
|
11
|
+
*/
|
|
12
|
+
this.sandboxContent = {
|
|
13
|
+
/**
|
|
14
|
+
* Get public sandbox content by UID
|
|
15
|
+
* @param sandboxContentUid - The UID of the sandbox content
|
|
16
|
+
* @returns The sandbox content data
|
|
17
|
+
*/
|
|
18
|
+
getPublic: async (sandboxContentUid) => {
|
|
19
|
+
return this.request([
|
|
20
|
+
"sandbox-content",
|
|
21
|
+
sandboxContentUid,
|
|
22
|
+
"public",
|
|
23
|
+
]);
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Get all sandbox contents for a specific playground
|
|
27
|
+
* @param playgroundUid - The UID of the playground
|
|
28
|
+
* @param skip - Number of records to skip (default: 0)
|
|
29
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
30
|
+
* @returns Array of sandbox content data
|
|
31
|
+
*/
|
|
32
|
+
getByPlayground: async (playgroundUid, skip = 0, limit = 100) => {
|
|
33
|
+
return this.request(["sandbox-content", "playground", playgroundUid], {
|
|
34
|
+
method: "GET",
|
|
35
|
+
}, true, // Use x-api-key header instead of Authorization Bearer
|
|
36
|
+
{ skip, limit });
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* SDK endpoints
|
|
41
|
+
*/
|
|
42
|
+
this.sdk = {
|
|
43
|
+
/**
|
|
44
|
+
* Start a sandbox
|
|
45
|
+
* @param request - The start sandbox request
|
|
46
|
+
* @returns The sandbox response with container URL
|
|
47
|
+
*/
|
|
48
|
+
startSandbox: async (request) => {
|
|
49
|
+
return this.request(["sdk", "start-sandbox"], {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: JSON.stringify(request),
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
this.baseUrl = config.baseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
56
|
+
this.apiKey = config.apiKey;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Makes a request to the API
|
|
60
|
+
*/
|
|
61
|
+
async request(endpoint, options = {}, useApiKeyHeader = false, queryParams) {
|
|
62
|
+
let url = `${this.baseUrl}/api/v1/${endpoint.join("/")}`;
|
|
63
|
+
if (queryParams) {
|
|
64
|
+
const params = new URLSearchParams();
|
|
65
|
+
Object.entries(queryParams).forEach(([key, value]) => {
|
|
66
|
+
params.append(key, value.toString());
|
|
67
|
+
});
|
|
68
|
+
url += `?${params.toString()}`;
|
|
69
|
+
}
|
|
70
|
+
const headers = Object.assign({ "Content-Type": "application/json" }, options.headers);
|
|
71
|
+
if (this.apiKey) {
|
|
72
|
+
if (useApiKeyHeader) {
|
|
73
|
+
headers["x-api-key"] = this.apiKey;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const response = await fetch(url, Object.assign(Object.assign({}, options), { headers }));
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
const errorText = await response.text();
|
|
82
|
+
throw new Error(`API request failed: ${response.status} ${response.statusText}. ${errorText}`);
|
|
83
|
+
}
|
|
84
|
+
return response.json();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Create an API client instance
|
|
89
|
+
* @param config - Configuration for the API client
|
|
90
|
+
* @returns An API client instance
|
|
91
|
+
*/
|
|
92
|
+
export function createApiClient(config) {
|
|
93
|
+
return new ApiClient(config);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default export for convenience
|
|
97
|
+
*/
|
|
98
|
+
export default ApiClient;
|