@sampleapp.ai/sdk 1.0.42 → 1.0.43
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 +50 -29
- package/dist/components/sandbox/api.js +73 -1
- package/dist/components/sandbox/guardian/demo/guardian-demo.js +3 -3
- package/dist/components/sandbox/guardian/guardian-component.js +5 -3
- package/dist/components/sandbox/guardian/guardian-playground.js +10 -14
- package/dist/components/sandbox/guardian/header.js +26 -39
- package/dist/components/sandbox/guardian/hooks/use-sandbox-url-loader.js +16 -4
- package/dist/components/sandbox/guardian/index.js +1 -0
- package/dist/components/sandbox/guardian/right-view/pill-file-selector.js +68 -18
- package/dist/components/sandbox/guardian/right-view/preview-control-bar.js +5 -2
- package/dist/components/sandbox/guardian/right-view/right-top-down-view.js +3 -4
- package/dist/components/sandbox/guardian/right-view/right-view.js +2 -2
- package/dist/components/sandbox/guardian/right-view/simplified-editor.js +9 -2
- package/dist/components/sandbox/guardian/utils.js +4 -16
- package/dist/hooks/use-tree-selector.js +98 -0
- package/dist/index.d.ts +579 -20
- package/dist/index.es.js +17937 -17550
- package/dist/index.js +12 -4
- package/dist/lib/api-client.js +68 -0
- package/dist/lib/content-matcher.js +99 -0
- package/dist/lib/shadow-dom-wrapper.js +31 -10
- package/dist/lib/tree-utils.js +191 -0
- package/dist/lib/types/tree-config.js +18 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,150 @@ export declare interface AiChatSettings {
|
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Main API client class
|
|
13
|
+
*/
|
|
14
|
+
declare class ApiClient {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private apiKey;
|
|
17
|
+
constructor(config: ApiClientConfig);
|
|
18
|
+
/**
|
|
19
|
+
* Makes a request to the API
|
|
20
|
+
* Automatically includes Authorization: Bearer {apiKey} header
|
|
21
|
+
*/
|
|
22
|
+
private request;
|
|
23
|
+
/**
|
|
24
|
+
* Sandbox content endpoints
|
|
25
|
+
*/
|
|
26
|
+
sandboxContent: {
|
|
27
|
+
/**
|
|
28
|
+
* Get public sandbox content by UID
|
|
29
|
+
* @param sandboxContentUid - The UID of the sandbox content
|
|
30
|
+
* @returns The sandbox content data
|
|
31
|
+
*/
|
|
32
|
+
getPublic: (sandboxContentUid: string) => Promise<SandboxContent>;
|
|
33
|
+
/**
|
|
34
|
+
* Get all sandbox contents for a specific playground (public access with truncated fields)
|
|
35
|
+
* @param playgroundUid - The UID of the playground
|
|
36
|
+
* @param skip - Number of records to skip (default: 0)
|
|
37
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
38
|
+
* @returns Array of sandbox content data with only uid and markdown fields
|
|
39
|
+
*/
|
|
40
|
+
getByPlayground: (playgroundUid: string, skip?: number, limit?: number) => Promise<SandboxContentPublic[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get all sandbox contents for a specific use case
|
|
43
|
+
* Used for upfront loading to enable local filtering
|
|
44
|
+
* @param useCaseId - The ID of the use case
|
|
45
|
+
* @param skip - Number of records to skip (default: 0)
|
|
46
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
47
|
+
* @returns Array of sandbox content data
|
|
48
|
+
*/
|
|
49
|
+
getByUseCaseId: (useCaseId: number, skip?: number, limit?: number) => Promise<SandboxContent[]>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Sandbox use case endpoints
|
|
53
|
+
*/
|
|
54
|
+
sandboxUseCase: {
|
|
55
|
+
/**
|
|
56
|
+
* Get a sandbox use case by UID
|
|
57
|
+
* @param uid - The UID of the use case
|
|
58
|
+
* @returns The use case data including tech_stack_config
|
|
59
|
+
*/
|
|
60
|
+
getByUid: (uid: string) => Promise<SandboxUseCase>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a sandbox use case by ID
|
|
63
|
+
* @param id - The numeric ID of the use case
|
|
64
|
+
* @returns The use case data including tech_stack_config
|
|
65
|
+
*/
|
|
66
|
+
getById: (id: number) => Promise<SandboxUseCase>;
|
|
67
|
+
/**
|
|
68
|
+
* Get all sandbox use cases for a specific playground
|
|
69
|
+
* @param playgroundUid - The UID of the playground
|
|
70
|
+
* @param skip - Number of records to skip (default: 0)
|
|
71
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
72
|
+
* @returns Array of use case data
|
|
73
|
+
*/
|
|
74
|
+
getByPlayground: (playgroundUid: string, skip?: number, limit?: number) => Promise<SandboxUseCase[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Get all template use cases (public access)
|
|
77
|
+
* @param skip - Number of records to skip (default: 0)
|
|
78
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
79
|
+
* @returns Array of template use case data
|
|
80
|
+
*/
|
|
81
|
+
getTemplates: (skip?: number, limit?: number) => Promise<SandboxUseCase[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get all public use cases
|
|
84
|
+
* @param skip - Number of records to skip (default: 0)
|
|
85
|
+
* @param limit - Maximum number of records to return (default: 100)
|
|
86
|
+
* @returns Array of public use case data
|
|
87
|
+
*/
|
|
88
|
+
getPublic: (skip?: number, limit?: number) => Promise<SandboxUseCase[]>;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* SDK endpoints
|
|
92
|
+
*/
|
|
93
|
+
sdk: {
|
|
94
|
+
/**
|
|
95
|
+
* Start a sandbox
|
|
96
|
+
*
|
|
97
|
+
* Authentication: API key is sent as Bearer token in Authorization header.
|
|
98
|
+
* The apiKey must be set in ApiClientConfig when creating the client.
|
|
99
|
+
*
|
|
100
|
+
* @param request - The start sandbox request (env and chatUid)
|
|
101
|
+
* @returns The sandbox response with container URL
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const client = createApiClient({ apiKey: "your-api-key" });
|
|
106
|
+
* const response = await client.sdk.startSandbox({
|
|
107
|
+
* env: { ENV_VAR: "value" }, // required when published_url is not available
|
|
108
|
+
* chatUid: "chat-uid-123"
|
|
109
|
+
* });
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
startSandbox: (request: StartSandboxRequest) => Promise<StartSandboxResponse>;
|
|
113
|
+
/**
|
|
114
|
+
* Download code as zip file from GitHub repository
|
|
115
|
+
*
|
|
116
|
+
* Authentication: API key is sent as Bearer token in Authorization header.
|
|
117
|
+
* The apiKey must be set in ApiClientConfig when creating the client.
|
|
118
|
+
*
|
|
119
|
+
* @param sandboxId - The sandbox content UID
|
|
120
|
+
* @returns Promise that resolves when download is initiated
|
|
121
|
+
*/
|
|
122
|
+
downloadCode: (sandboxId: string) => Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Start VM endpoint that starts a desktop sandbox, launches Chrome,
|
|
125
|
+
* navigates to the target URL, and returns a VNC viewer URL
|
|
126
|
+
*
|
|
127
|
+
* Authentication: API key is sent as Bearer token in Authorization header.
|
|
128
|
+
* The apiKey must be set in ApiClientConfig when creating the client.
|
|
129
|
+
*
|
|
130
|
+
* @param request - The start VM request with url, optional mode, and optional resolution
|
|
131
|
+
* @returns The sandbox response with sandboxId and vncUrl (if mode=json)
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const client = createApiClient({ apiKey: "your-api-key" });
|
|
136
|
+
* const response = await client.sdk.startVm({
|
|
137
|
+
* url: "https://example.com",
|
|
138
|
+
* mode: "json",
|
|
139
|
+
* resolution: [1920, 1080]
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
startVm: (request: StartVmRequest) => Promise<StartVmResponse>;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export declare interface ApiClientConfig {
|
|
148
|
+
/**
|
|
149
|
+
* API key for authentication. Will be sent as Bearer token in Authorization header.
|
|
150
|
+
* Required for all authenticated endpoints.
|
|
151
|
+
*/
|
|
152
|
+
apiKey: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
11
155
|
export declare interface BaseSettings {
|
|
12
156
|
apiKey: string;
|
|
13
157
|
primaryBrandColor: string;
|
|
@@ -15,6 +159,11 @@ export declare interface BaseSettings {
|
|
|
15
159
|
[key: string]: any;
|
|
16
160
|
}
|
|
17
161
|
|
|
162
|
+
/**
|
|
163
|
+
* Build SandboxConfig from any SandboxContent (for switching between selections)
|
|
164
|
+
*/
|
|
165
|
+
export declare function buildConfigFromContent(content: SandboxContent): SandboxConfig;
|
|
166
|
+
|
|
18
167
|
/**
|
|
19
168
|
* Builds a nested GuardianConfig from use cases with nested frameworks.
|
|
20
169
|
* Returns a structure where config[useCaseId].frameworks[frameworkKey] gives you the full config.
|
|
@@ -117,8 +266,77 @@ declare interface CodeOutput {
|
|
|
117
266
|
full_code: string;
|
|
118
267
|
}
|
|
119
268
|
|
|
269
|
+
/**
|
|
270
|
+
* Create an API client instance
|
|
271
|
+
*
|
|
272
|
+
* @param config - Configuration for the API client
|
|
273
|
+
* @param config.apiKey - API key for authentication (sent as Bearer token in Authorization header)
|
|
274
|
+
* @returns An API client instance
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* // Create client with API key
|
|
279
|
+
* const client = createApiClient({
|
|
280
|
+
* apiKey: process.env.NEXT_PUBLIC_SAMPLEAPP_API_KEY
|
|
281
|
+
* });
|
|
282
|
+
*
|
|
283
|
+
* // All requests will automatically include: Authorization: Bearer {apiKey}
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
export declare function createApiClient(config: ApiClientConfig): ApiClient;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Create a TreeSelection object from a path
|
|
290
|
+
*/
|
|
291
|
+
export declare function createSelection(config: TechStackConfig, path: string[]): TreeSelection;
|
|
292
|
+
|
|
120
293
|
export declare const DEFAULT_THEME: ThemeName;
|
|
121
294
|
|
|
295
|
+
/**
|
|
296
|
+
* Extract container ID from a browser URL
|
|
297
|
+
* @param browserUrl - URL like "https://nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2.sampleapp.love/?_ts=1767897000670"
|
|
298
|
+
* @returns Container ID like "nextjs-a3fcd2bb-2a15-4f9b-bd13-aeac52baebd2" or null if not found
|
|
299
|
+
*/
|
|
300
|
+
export declare function extractContainerIdFromUrl(browserUrl: string): string | null;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Fetches sandbox configuration from the API (legacy method)
|
|
304
|
+
* @param apiKey - API key from SandboxProps
|
|
305
|
+
* @param sandboxId - Sandbox content UID (maps to sandbox_content_uid)
|
|
306
|
+
* @returns Sandbox configuration
|
|
307
|
+
* @deprecated Use fetchSandboxConfigWithContent for tree-based selection
|
|
308
|
+
*/
|
|
309
|
+
export declare function fetchSandboxConfig(apiKey: string, sandboxId: string): Promise<SandboxConfig>;
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Fetches sandbox configuration with all content for upfront loading
|
|
313
|
+
* This enables instant switching between tech stack options without API calls
|
|
314
|
+
*
|
|
315
|
+
* @param apiKey - API key from SandboxProps
|
|
316
|
+
* @param sandboxId - Sandbox content UID (maps to sandbox_content_uid)
|
|
317
|
+
* @returns Extended sandbox configuration with all content
|
|
318
|
+
*/
|
|
319
|
+
export declare function fetchSandboxConfigWithContent(apiKey: string, sandboxId: string): Promise<SandboxConfigWithContent>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Filter content entries by multiple criteria
|
|
323
|
+
*
|
|
324
|
+
* @param allContent - All sandbox content entries
|
|
325
|
+
* @param filters - Object with field names and values to filter by
|
|
326
|
+
* @returns Filtered array of content entries
|
|
327
|
+
*/
|
|
328
|
+
export declare function filterContent(allContent: SandboxContent[], filters: Partial<Pick<SandboxContent, "product" | "product_version" | "architecture" | "frontend" | "backend" | "framework">>): SandboxContent[];
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Find sandbox content that matches the current tree selection
|
|
332
|
+
* Matches against flat fields: product, product_version, architecture, frontend, backend, framework
|
|
333
|
+
*
|
|
334
|
+
* @param allContent - All sandbox content entries for the use case
|
|
335
|
+
* @param selection - Current tree selection
|
|
336
|
+
* @returns Matching content or null if not found
|
|
337
|
+
*/
|
|
338
|
+
export declare function findMatchingContent(allContent: SandboxContent[], selection: TreeSelection): SandboxContent | null;
|
|
339
|
+
|
|
122
340
|
export declare enum Framework {
|
|
123
341
|
FLASK = "flask",
|
|
124
342
|
EXPRESS = "express",
|
|
@@ -129,29 +347,70 @@ export declare enum Framework {
|
|
|
129
347
|
FASTMCP = "fastmcp"
|
|
130
348
|
}
|
|
131
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Get the default path through the tree (following isDefault flags or first child)
|
|
352
|
+
* @param root - The root node
|
|
353
|
+
* @returns Array of keys representing the default selection path
|
|
354
|
+
*/
|
|
355
|
+
export declare function getDefaultPath(root: TreeNode): string[];
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Navigate the tree to find a node at a specific path
|
|
359
|
+
* @param root - The root node to start from
|
|
360
|
+
* @param path - Array of keys to follow
|
|
361
|
+
* @returns The node at the path, or null if not found
|
|
362
|
+
*/
|
|
363
|
+
export declare function getNodeAtPath(root: TreeNode, path: string[]): TreeNode | null;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Get the display label for a node (falls back to key if no label)
|
|
367
|
+
*/
|
|
368
|
+
export declare function getNodeLabel(node: TreeNode): string;
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Get all nodes along a path (including the root)
|
|
372
|
+
* @param root - The root node
|
|
373
|
+
* @param path - Array of keys to follow
|
|
374
|
+
* @returns Array of nodes from root to the final node
|
|
375
|
+
*/
|
|
376
|
+
export declare function getNodesAlongPath(root: TreeNode, path: string[]): TreeNode[];
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Get selectable sections based on current selection path
|
|
380
|
+
* This builds the button groups shown in the header
|
|
381
|
+
* @param config - The tech stack configuration
|
|
382
|
+
* @param currentPath - Current selection path
|
|
383
|
+
* @returns Array of sections with their options
|
|
384
|
+
*/
|
|
385
|
+
export declare function getSelectableSections(config: TechStackConfig, currentPath: string[]): SelectorSection[];
|
|
386
|
+
|
|
132
387
|
export declare const getTheme: (themeName?: ThemeName) => ThemeColors;
|
|
133
388
|
|
|
134
|
-
|
|
389
|
+
/**
|
|
390
|
+
* Get all unique values for a specific field from content entries
|
|
391
|
+
* Useful for building filter options
|
|
392
|
+
*
|
|
393
|
+
* @param allContent - All sandbox content entries
|
|
394
|
+
* @param field - The field to extract unique values from
|
|
395
|
+
* @returns Array of unique non-null values
|
|
396
|
+
*/
|
|
397
|
+
export declare function getUniqueFieldValues(allContent: SandboxContent[], field: keyof Pick<SandboxContent, "product" | "product_version" | "architecture" | "frontend" | "backend" | "framework">): string[];
|
|
398
|
+
|
|
399
|
+
export declare function GuardianComponent({ sections, onSelect, currentFramework, currentUseCase, CustomConsole, GuideView, playgroundLogo, playgroundUid, browserUrl, useVm, sandboxUid, codeZipFile, completeCodeZipFile, variant, themeColor, hasPreview, isFrame, apiKey, env, chatUid, hideHeader, // Hardcoded to true by default, not exposed in Sandbox.tsx
|
|
135
400
|
gitUrl, }: GuardianComponentProps): default_2.JSX.Element;
|
|
136
401
|
|
|
137
402
|
export declare interface GuardianComponentProps {
|
|
138
403
|
name: string;
|
|
139
404
|
description: string;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
frameworkOptions: {
|
|
145
|
-
label: string;
|
|
146
|
-
value: string;
|
|
147
|
-
}[];
|
|
405
|
+
/** Dynamic sections from useTreeSelector hook */
|
|
406
|
+
sections: SelectorSection[];
|
|
407
|
+
/** Handler when user selects an option */
|
|
408
|
+
onSelect: (nodeType: string, key: string) => void;
|
|
148
409
|
CustomConsole: default_2.ComponentType<{
|
|
149
410
|
onReloadPreview: () => void;
|
|
150
411
|
onStageChange: (stage: "hidden" | "error" | "rebuilding") => void;
|
|
151
412
|
themeColor: string;
|
|
152
413
|
}> | string;
|
|
153
|
-
/** Maps use case ID to first available framework key */
|
|
154
|
-
firstFrameworkByUseCase?: Record<string, string>;
|
|
155
414
|
/** The current framework key for this sandbox */
|
|
156
415
|
currentFramework: string;
|
|
157
416
|
/** The current use case ID (for nested config navigation) */
|
|
@@ -231,14 +490,18 @@ declare interface GuardianFrameworkConfig extends Omit<GuardianComponentProps, '
|
|
|
231
490
|
export declare type GuardianNestedConfig = Record<string, GuardianUseCaseConfig>;
|
|
232
491
|
|
|
233
492
|
/**
|
|
234
|
-
* Guardian Playground component with
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* When isFrame=true, reads framework from URL params client-side.
|
|
493
|
+
* Guardian Playground component with tree-based tech stack selection.
|
|
494
|
+
* Uses sections from useTreeSelector for dynamic header rendering.
|
|
238
495
|
*/
|
|
239
|
-
export declare function GuardianPlayground({
|
|
240
|
-
|
|
241
|
-
|
|
496
|
+
export declare function GuardianPlayground({ sandboxConfig, sections, onSelect, useCase, framework: serverFramework, isFrame, apiKey, env, chatUid, theme, }: GuardianPlaygroundProps): default_2.JSX.Element;
|
|
497
|
+
|
|
498
|
+
declare interface GuardianPlaygroundProps {
|
|
499
|
+
/** Sandbox configuration */
|
|
500
|
+
sandboxConfig: SandboxConfig;
|
|
501
|
+
/** Dynamic sections from useTreeSelector hook */
|
|
502
|
+
sections: SelectorSection[];
|
|
503
|
+
/** Handler when user selects an option */
|
|
504
|
+
onSelect: (nodeType: string, key: string) => void;
|
|
242
505
|
/** Current use case ID */
|
|
243
506
|
useCase: string;
|
|
244
507
|
/** Current framework key (from server-side props) */
|
|
@@ -253,7 +516,7 @@ export declare function GuardianPlayground({ nestedConfig, useCase, framework: s
|
|
|
253
516
|
chatUid?: string;
|
|
254
517
|
/** Theme mode - "light", "dark", or "system". Defaults to "dark" */
|
|
255
518
|
theme?: ThemeMode;
|
|
256
|
-
}
|
|
519
|
+
}
|
|
257
520
|
|
|
258
521
|
export declare function GuardianProvider({ children }: {
|
|
259
522
|
children: ReactNode;
|
|
@@ -296,6 +559,40 @@ export declare interface GuardianUseCaseConfig {
|
|
|
296
559
|
frameworks: Record<string, GuardianFrameworkConfig>;
|
|
297
560
|
}
|
|
298
561
|
|
|
562
|
+
/**
|
|
563
|
+
* Check if content exists for a potential selection
|
|
564
|
+
* Used to disable/gray out options that have no content
|
|
565
|
+
*
|
|
566
|
+
* @param allContent - All sandbox content entries for the use case
|
|
567
|
+
* @param partialSelection - Partial selection to check (only specified fields are matched)
|
|
568
|
+
* @returns True if at least one content entry matches
|
|
569
|
+
*/
|
|
570
|
+
export declare function hasContentForSelection(allContent: SandboxContent[], partialSelection: Partial<TreeSelection["byType"]>): boolean;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Header component for dynamic tech stack selection
|
|
574
|
+
*
|
|
575
|
+
* Uses sections from useTreeSelector to render selector buttons
|
|
576
|
+
* based on the tech_stack_config tree structure.
|
|
577
|
+
*/
|
|
578
|
+
export declare function Header({ sections, onSelect, playgroundLogo, themecolor }: HeaderProps): default_2.JSX.Element;
|
|
579
|
+
|
|
580
|
+
export declare interface HeaderProps {
|
|
581
|
+
/** Dynamic sections from useTreeSelector hook */
|
|
582
|
+
sections: SelectorSection[];
|
|
583
|
+
/** Handler when user selects an option */
|
|
584
|
+
onSelect: (nodeType: string, key: string) => void;
|
|
585
|
+
/** Optional playground logo */
|
|
586
|
+
playgroundLogo?: default_2.ReactNode;
|
|
587
|
+
/** Theme color for selected state */
|
|
588
|
+
themecolor?: string;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Check if a path is complete (reaches a leaf node)
|
|
593
|
+
*/
|
|
594
|
+
export declare function isPathComplete(config: TechStackConfig, path: string[]): boolean;
|
|
595
|
+
|
|
299
596
|
export declare const ModalSearchAndChat: default_2.FC<ModalSearchAndChatProps>;
|
|
300
597
|
|
|
301
598
|
declare interface ModalSearchAndChatProps {
|
|
@@ -303,6 +600,19 @@ declare interface ModalSearchAndChatProps {
|
|
|
303
600
|
onClose?: () => void;
|
|
304
601
|
}
|
|
305
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Human-readable labels for node types
|
|
605
|
+
*/
|
|
606
|
+
export declare const NODE_TYPE_LABELS: Record<string, string>;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Convert a path to a byType map
|
|
610
|
+
* @param root - The root node
|
|
611
|
+
* @param path - Array of keys
|
|
612
|
+
* @returns Map of nodeType to selected key
|
|
613
|
+
*/
|
|
614
|
+
export declare function pathToByType(root: TreeNode, path: string[]): Record<string, string>;
|
|
615
|
+
|
|
306
616
|
declare class SampleAppSDK {
|
|
307
617
|
ModalSearchAndChat: (settings: SDKSettings, container?: HTMLElement) => {
|
|
308
618
|
unmount: () => void;
|
|
@@ -342,7 +652,81 @@ declare class SampleAppSDK {
|
|
|
342
652
|
* />
|
|
343
653
|
* ```
|
|
344
654
|
*/
|
|
345
|
-
export declare function Sandbox({ apiKey, sandboxId, env, themeColor, theme, }: SandboxProps): default_2.JSX.Element | null;
|
|
655
|
+
export declare function Sandbox({ apiKey, sandboxId, env, themeColor, theme, config, }: SandboxProps): default_2.JSX.Element | null;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Configuration fetched from the API for a sandbox
|
|
659
|
+
*/
|
|
660
|
+
declare interface SandboxConfig {
|
|
661
|
+
/** Sandbox identifier */
|
|
662
|
+
id: string;
|
|
663
|
+
/** Display name */
|
|
664
|
+
name: string;
|
|
665
|
+
/** Description */
|
|
666
|
+
description: string;
|
|
667
|
+
/** Theme color */
|
|
668
|
+
themeColor: string;
|
|
669
|
+
/** Whether preview is available */
|
|
670
|
+
hasPreview: boolean;
|
|
671
|
+
/** Optional playground logo */
|
|
672
|
+
playgroundLogo?: React.ReactNode;
|
|
673
|
+
/**
|
|
674
|
+
* Chat UID for starting the sandbox via API.
|
|
675
|
+
* NOTE: This is only used as a fallback when published_url is not available.
|
|
676
|
+
* If published_url exists in the framework config, it takes precedence and chatUid is not needed.
|
|
677
|
+
*/
|
|
678
|
+
chatUid?: string;
|
|
679
|
+
/** List of use cases with frameworks */
|
|
680
|
+
useCases: GuardianUseCase[];
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Extended sandbox configuration with tree-based tech stack selection
|
|
685
|
+
*/
|
|
686
|
+
export declare interface SandboxConfigWithContent {
|
|
687
|
+
/** The use case containing the tech stack config */
|
|
688
|
+
useCase: SandboxUseCase;
|
|
689
|
+
/** Parsed tech stack configuration tree */
|
|
690
|
+
techStackConfig: TechStackConfig;
|
|
691
|
+
/** ALL sandbox content entries for this use case (for local filtering) */
|
|
692
|
+
allContent: SandboxContent[];
|
|
693
|
+
/** The initially requested sandbox content */
|
|
694
|
+
initialContent: SandboxContent;
|
|
695
|
+
/** Initial selection path from the content */
|
|
696
|
+
initialSelectionPath: string[];
|
|
697
|
+
/** Legacy config for backward compatibility */
|
|
698
|
+
legacyConfig: SandboxConfig;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
export declare interface SandboxContent {
|
|
702
|
+
id: number;
|
|
703
|
+
uid: string;
|
|
704
|
+
use_case_id: number;
|
|
705
|
+
product: string | null;
|
|
706
|
+
product_version: string | null;
|
|
707
|
+
architecture: string | null;
|
|
708
|
+
frontend: string | null;
|
|
709
|
+
backend: string | null;
|
|
710
|
+
framework: string | null;
|
|
711
|
+
selection_path: string[] | null;
|
|
712
|
+
markdown: string | null;
|
|
713
|
+
github_url: string | null;
|
|
714
|
+
published_url: string | null;
|
|
715
|
+
is_vm_enabled: boolean;
|
|
716
|
+
generated_code_id: number | null;
|
|
717
|
+
generated_code?: UpdateContainerCodebaseType | null;
|
|
718
|
+
chat_uid: string | null;
|
|
719
|
+
playground_uid: string | null;
|
|
720
|
+
user_id: string | null;
|
|
721
|
+
has_preview: boolean;
|
|
722
|
+
created_at: string;
|
|
723
|
+
updated_at: string;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export declare interface SandboxContentPublic {
|
|
727
|
+
uid: string;
|
|
728
|
+
markdown: string | null;
|
|
729
|
+
}
|
|
346
730
|
|
|
347
731
|
export declare const SandboxHome: React_2.FC<SandboxHomeProps>;
|
|
348
732
|
|
|
@@ -378,6 +762,21 @@ export declare interface SandboxProps {
|
|
|
378
762
|
themeColor?: string;
|
|
379
763
|
/** Theme mode - "light", "dark", or "system". Defaults to "dark" */
|
|
380
764
|
theme?: ThemeMode;
|
|
765
|
+
/** Configuration for the sandbox */
|
|
766
|
+
config?: any;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
export declare interface SandboxUseCase {
|
|
770
|
+
id: number;
|
|
771
|
+
uid: string;
|
|
772
|
+
name: string;
|
|
773
|
+
description: string | null;
|
|
774
|
+
tech_stack_config: Record<string, any>;
|
|
775
|
+
playground_uid: string | null;
|
|
776
|
+
is_public: boolean;
|
|
777
|
+
is_template: boolean;
|
|
778
|
+
created_at: string;
|
|
779
|
+
updated_at: string;
|
|
381
780
|
}
|
|
382
781
|
|
|
383
782
|
declare const sdk: SampleAppSDK;
|
|
@@ -388,6 +787,61 @@ export declare interface SDKSettings {
|
|
|
388
787
|
aiChatSettings?: AiChatSettings;
|
|
389
788
|
}
|
|
390
789
|
|
|
790
|
+
/**
|
|
791
|
+
* A single option within a selector section
|
|
792
|
+
*/
|
|
793
|
+
export declare interface SelectorOption {
|
|
794
|
+
/** Unique key for this option */
|
|
795
|
+
key: string;
|
|
796
|
+
/** Display label */
|
|
797
|
+
label: string;
|
|
798
|
+
/** Whether this option is currently selected */
|
|
799
|
+
isSelected: boolean;
|
|
800
|
+
/** Whether this option has content available (for disabling unavailable options) */
|
|
801
|
+
hasContent?: boolean;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* A section of the selector (e.g., "Architecture:", "Frontend:", "Backend:")
|
|
806
|
+
*/
|
|
807
|
+
export declare interface SelectorSection {
|
|
808
|
+
/** The nodeType this section represents */
|
|
809
|
+
nodeType: string;
|
|
810
|
+
/** Display label for this section (e.g., "Architecture:") */
|
|
811
|
+
label: string;
|
|
812
|
+
/** Available options in this section */
|
|
813
|
+
options: SelectorOption[];
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
declare interface StartSandboxRequest {
|
|
817
|
+
/**
|
|
818
|
+
* Environment variables to pass to the sandbox.
|
|
819
|
+
* Required when published_url is not available (when starting a new sandbox).
|
|
820
|
+
* Optional when published_url exists (sandbox already exists).
|
|
821
|
+
*/
|
|
822
|
+
env?: Record<string, any>;
|
|
823
|
+
/** Chat UID for starting the sandbox */
|
|
824
|
+
chatUid: string;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
declare interface StartSandboxResponse {
|
|
828
|
+
container_url: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
declare interface StartVmRequest {
|
|
832
|
+
/** Target URL to navigate to in Chrome */
|
|
833
|
+
url: string;
|
|
834
|
+
/** Response mode: 'redirect' or 'json' (default: 'json') */
|
|
835
|
+
mode?: "redirect" | "json";
|
|
836
|
+
/** Desktop resolution [width, height] in pixels */
|
|
837
|
+
resolution?: [number, number];
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
declare interface StartVmResponse {
|
|
841
|
+
sandboxId: string;
|
|
842
|
+
vncUrl: string;
|
|
843
|
+
}
|
|
844
|
+
|
|
391
845
|
export declare const TailwindExample: React_2.FC<TailwindExampleProps>;
|
|
392
846
|
|
|
393
847
|
export declare interface TailwindExampleProps {
|
|
@@ -395,6 +849,13 @@ export declare interface TailwindExampleProps {
|
|
|
395
849
|
description?: string;
|
|
396
850
|
}
|
|
397
851
|
|
|
852
|
+
/**
|
|
853
|
+
* Root structure of the tech stack configuration
|
|
854
|
+
*/
|
|
855
|
+
export declare interface TechStackConfig {
|
|
856
|
+
root: TreeNode;
|
|
857
|
+
}
|
|
858
|
+
|
|
398
859
|
export declare interface ThemeColors {
|
|
399
860
|
primary: string;
|
|
400
861
|
shadow: {
|
|
@@ -434,8 +895,106 @@ export declare type ThemeName = "ocean" | "autumn" | "mint" | "sunset" | "lavend
|
|
|
434
895
|
|
|
435
896
|
export declare const themes: Record<ThemeName, ThemeColors>;
|
|
436
897
|
|
|
898
|
+
/**
|
|
899
|
+
* Tree configuration types for dynamic tech stack selection
|
|
900
|
+
* Matches the tech_stack_config structure from SandboxUseCase
|
|
901
|
+
*/
|
|
902
|
+
/**
|
|
903
|
+
* A node in the tech stack tree
|
|
904
|
+
*/
|
|
905
|
+
export declare interface TreeNode {
|
|
906
|
+
/** Unique key for this node (e.g., "javascript-sdk", "react", "node.js") */
|
|
907
|
+
key: string;
|
|
908
|
+
/** Human-readable label (defaults to key if not provided) */
|
|
909
|
+
label?: string;
|
|
910
|
+
/** Type of this node - determines which selector group it belongs to */
|
|
911
|
+
nodeType: string;
|
|
912
|
+
/** Child nodes (next level of selection) */
|
|
913
|
+
children?: TreeNode[];
|
|
914
|
+
/** Whether this is the default selection at this level */
|
|
915
|
+
isDefault?: boolean;
|
|
916
|
+
/** Optional metadata for this node */
|
|
917
|
+
metadata?: Record<string, unknown>;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Current selection state in the tree
|
|
922
|
+
*/
|
|
923
|
+
export declare interface TreeSelection {
|
|
924
|
+
/** Array of selected keys from root to leaf (e.g., ["javascript-sdk", "react", "node.js"]) */
|
|
925
|
+
path: string[];
|
|
926
|
+
/** Map of nodeType to selected key (e.g., { architecture: "javascript-sdk", frontend: "react", backend: "node.js" }) */
|
|
927
|
+
byType: Record<string, string>;
|
|
928
|
+
}
|
|
929
|
+
|
|
437
930
|
declare type UpdateContainerCodebaseType = Record<string, CodeOutput>;
|
|
438
931
|
|
|
932
|
+
/**
|
|
933
|
+
* Update the selection path when a user selects an option
|
|
934
|
+
* @param config - The tech stack configuration
|
|
935
|
+
* @param currentPath - Current selection path
|
|
936
|
+
* @param nodeType - The nodeType of the selection being changed
|
|
937
|
+
* @param selectedKey - The key of the newly selected option
|
|
938
|
+
* @returns New selection path
|
|
939
|
+
*/
|
|
940
|
+
export declare function updateSelectionPath(config: TechStackConfig, currentPath: string[], nodeType: string, selectedKey: string): string[];
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* Hook for managing tree-based tech stack selection
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```tsx
|
|
947
|
+
* const { selection, sections, currentContent, selectOption } = useTreeSelector({
|
|
948
|
+
* config: techStackConfig,
|
|
949
|
+
* allContent: sandboxContents,
|
|
950
|
+
* initialPath: ["javascript-sdk", "react", "node.js"],
|
|
951
|
+
* });
|
|
952
|
+
*
|
|
953
|
+
* // Render sections
|
|
954
|
+
* {sections.map(section => (
|
|
955
|
+
* <div key={section.nodeType}>
|
|
956
|
+
* <span>{section.label}</span>
|
|
957
|
+
* {section.options.map(opt => (
|
|
958
|
+
* <button
|
|
959
|
+
* key={opt.key}
|
|
960
|
+
* onClick={() => selectOption(section.nodeType, opt.key)}
|
|
961
|
+
* className={opt.isSelected ? "selected" : ""}
|
|
962
|
+
* >
|
|
963
|
+
* {opt.label}
|
|
964
|
+
* </button>
|
|
965
|
+
* ))}
|
|
966
|
+
* </div>
|
|
967
|
+
* ))}
|
|
968
|
+
* ```
|
|
969
|
+
*/
|
|
970
|
+
export declare function useTreeSelector({ config, allContent, initialPath, onSelectionChange, }: UseTreeSelectorOptions): UseTreeSelectorReturn;
|
|
971
|
+
|
|
972
|
+
export declare interface UseTreeSelectorOptions {
|
|
973
|
+
/** The tech stack configuration tree */
|
|
974
|
+
config: TechStackConfig;
|
|
975
|
+
/** All sandbox content entries for this use case (for local filtering) */
|
|
976
|
+
allContent: SandboxContent[];
|
|
977
|
+
/** Initial selection path (from URL or saved state) */
|
|
978
|
+
initialPath?: string[];
|
|
979
|
+
/** Callback when selection changes */
|
|
980
|
+
onSelectionChange?: (selection: TreeSelection, content: SandboxContent | null) => void;
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
export declare interface UseTreeSelectorReturn {
|
|
984
|
+
/** Current selection state */
|
|
985
|
+
selection: TreeSelection;
|
|
986
|
+
/** Sections to render in the UI (button groups) */
|
|
987
|
+
sections: SelectorSection[];
|
|
988
|
+
/** Currently matched content based on selection */
|
|
989
|
+
currentContent: SandboxContent | null;
|
|
990
|
+
/** Handler for when user selects an option */
|
|
991
|
+
selectOption: (nodeType: string, key: string) => void;
|
|
992
|
+
/** Reset to default selection */
|
|
993
|
+
resetToDefault: () => void;
|
|
994
|
+
/** Set selection from a path */
|
|
995
|
+
setSelectionPath: (path: string[]) => void;
|
|
996
|
+
}
|
|
997
|
+
|
|
439
998
|
export declare const VmProvider: ({ children }: {
|
|
440
999
|
children: ReactNode;
|
|
441
1000
|
}) => default_2.JSX.Element;
|