@animaapp/anima-sdk 0.6.12-beta.0 → 0.6.16
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -140
- package/dist/index.js +313 -371
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
- package/example.env +0 -2
- package/tsconfig.json +0 -6
package/dist/index.d.ts
CHANGED
|
@@ -17,39 +17,6 @@ export declare class Anima {
|
|
|
17
17
|
protected get headers(): Record<string, string>;
|
|
18
18
|
generateCode(params: GetCodeParams, handler?: GetCodeHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
19
19
|
generateCodeFromWebsite(params: GetCodeFromWebsiteParams, handler?: GetCodeFromWebsiteHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Generates code from a text prompt using AI.
|
|
22
|
-
*
|
|
23
|
-
* This method sends a prompt to the Anima API and generates code based on the description provided.
|
|
24
|
-
* It supports real-time streaming of the generation process through Server-Sent Events (SSE).
|
|
25
|
-
*
|
|
26
|
-
* @param params - The parameters for code generation
|
|
27
|
-
* @param params.prompt - The text prompt describing what code to generate
|
|
28
|
-
* @param params.settings - Code generation settings (framework, language, styling, etc.)
|
|
29
|
-
* @param params.assetsStorage - Optional asset storage configuration
|
|
30
|
-
* @param params.tracking - Optional tracking information
|
|
31
|
-
* @param params.webhookUrl - Optional webhook URL for completion notification
|
|
32
|
-
* @param handler - Event handler for processing SSE messages during generation
|
|
33
|
-
* @param signal - Optional AbortSignal to cancel the request
|
|
34
|
-
* @returns Promise resolving to AnimaSDKResult with generated files and metadata
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* const result = await anima.generateCodeFromPrompt({
|
|
39
|
-
* prompt: "Create a login form with email and password fields",
|
|
40
|
-
* settings: {
|
|
41
|
-
* framework: "react",
|
|
42
|
-
* language: "typescript",
|
|
43
|
-
* styling: "tailwind"
|
|
44
|
-
* }
|
|
45
|
-
* }, {
|
|
46
|
-
* onStart: ({ sessionId }) => console.log("Started:", sessionId),
|
|
47
|
-
* onGeneratingCode: ({ progress }) => console.log("Progress:", progress),
|
|
48
|
-
* onCodegenCompleted: () => console.log("Generation completed!")
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
generateCodeFromPrompt(params: GetCodeFromPromptParams, handler?: GetCodeFromPromptHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
53
20
|
/**
|
|
54
21
|
* @deprecated This method will be removed soon, please use `generateCodeFromWebsite` instead.
|
|
55
22
|
*/
|
|
@@ -86,8 +53,8 @@ export declare type Auth = {
|
|
|
86
53
|
|
|
87
54
|
export declare type BaseResult = {
|
|
88
55
|
sessionId: string;
|
|
89
|
-
figmaFileName
|
|
90
|
-
figmaSelectedFrameName
|
|
56
|
+
figmaFileName: string;
|
|
57
|
+
figmaSelectedFrameName: string;
|
|
91
58
|
tokenUsage: number;
|
|
92
59
|
};
|
|
93
60
|
|
|
@@ -96,7 +63,7 @@ export declare class CodegenError extends Error {
|
|
|
96
63
|
detail?: unknown;
|
|
97
64
|
constructor({ name, reason, status, detail, }: {
|
|
98
65
|
name: string;
|
|
99
|
-
reason: CodegenErrorReason | CodegenRouteErrorReason | SDKErrorReason | GetCodeFromWebsiteErrorReason
|
|
66
|
+
reason: CommonApiError | CodegenErrorReason | CodegenRouteErrorReason | SDKErrorReason | GetCodeFromWebsiteErrorReason;
|
|
100
67
|
status?: number;
|
|
101
68
|
detail?: unknown;
|
|
102
69
|
});
|
|
@@ -117,7 +84,7 @@ export declare type CodegenResult = BaseResult & {
|
|
|
117
84
|
/**
|
|
118
85
|
* Codegen errors from the "/codegen" route
|
|
119
86
|
*/
|
|
120
|
-
export declare type CodegenRouteErrorReason = "
|
|
87
|
+
export declare type CodegenRouteErrorReason = "Not all frames id from responsive pages are mentioned on the nodes id list" | "Too many screens to import";
|
|
121
88
|
|
|
122
89
|
export declare type CodegenSettings = {
|
|
123
90
|
language?: "typescript" | "javascript";
|
|
@@ -144,28 +111,9 @@ export declare type CodegenSettings = {
|
|
|
144
111
|
};
|
|
145
112
|
|
|
146
113
|
/**
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
* But, if the first message indicates an error (e.g., connection failed), the function returns a 500 response with the error message.
|
|
150
|
-
*
|
|
151
|
-
* @param {Anima} anima - The Anima instance to use for creating the data stream.
|
|
152
|
-
* @param {GetCodeFromPromptParams} params - The parameters for the code generation request.
|
|
153
|
-
* @returns {Promise<Response>} - A promise that resolves to an HTTP response.
|
|
154
|
-
*/
|
|
155
|
-
export declare const createCodeFromPromptResponseEventStream: (anima: Anima, params: GetCodeFromPromptParams) => Promise<Response>;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Prompt to Code (p2c) stream flow.
|
|
159
|
-
*
|
|
160
|
-
* Start the prompt to code generation and creates a ReadableStream to output its result.
|
|
161
|
-
*
|
|
162
|
-
* The stream is closed when the code generation ends.
|
|
163
|
-
*
|
|
164
|
-
* @param {Anima} anima - An Anima service instance to generate the code from.
|
|
165
|
-
* @param {GetCodeFromPromptParams} params - Parameters required for the code generation process.
|
|
166
|
-
* @returns {ReadableStream<StreamCodeFromPromptMessage>} - A ReadableStream that emits messages related to the code generation process.
|
|
114
|
+
* Errors from Anima API, common across multiple routes.
|
|
167
115
|
*/
|
|
168
|
-
export declare
|
|
116
|
+
export declare type CommonApiError = "Missing Authorization header" | "Invalid Authorization header" | "Missing teamId" | "Internal server error" | "Forbidden, no team access" | "Requested Usage Exceeds Limit" | "Too many concurrent jobs. Please wait for one to finish." | "Invalid Anima token";
|
|
169
117
|
|
|
170
118
|
/**
|
|
171
119
|
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the code generation from website stream.
|
|
@@ -282,46 +230,6 @@ export declare type GeneratingCodePayload = {
|
|
|
282
230
|
files: AnimaFiles;
|
|
283
231
|
};
|
|
284
232
|
|
|
285
|
-
/**
|
|
286
|
-
* Errors from the Prompt To Code Flow
|
|
287
|
-
*/
|
|
288
|
-
export declare type GetCodeFromPromptErrorReason = "Invalid prompt" | "Generation failed" | "Unknown";
|
|
289
|
-
|
|
290
|
-
export declare type GetCodeFromPromptHandler = ((message: SSEGetCodeFromPromptMessage) => void) | {
|
|
291
|
-
onQueueing?: () => void;
|
|
292
|
-
onStart?: ({ sessionId }: {
|
|
293
|
-
sessionId: string;
|
|
294
|
-
}) => void;
|
|
295
|
-
onAssetsUploaded?: () => void;
|
|
296
|
-
onAssetsList?: ({ assets, }: {
|
|
297
|
-
assets: Array<{
|
|
298
|
-
name: string;
|
|
299
|
-
url: string;
|
|
300
|
-
}>;
|
|
301
|
-
}) => void;
|
|
302
|
-
onGeneratingCode?: ({ status, progress, files, }: {
|
|
303
|
-
status: "success" | "running" | "failure";
|
|
304
|
-
progress: number;
|
|
305
|
-
files: AnimaFiles;
|
|
306
|
-
}) => void;
|
|
307
|
-
onCodegenCompleted?: () => void;
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
export declare type GetCodeFromPromptParams = {
|
|
311
|
-
prompt: string;
|
|
312
|
-
assetsStorage?: AssetsStorage;
|
|
313
|
-
settings: GetCodeFromPromptSettings;
|
|
314
|
-
tracking?: TrackingInfos;
|
|
315
|
-
webhookUrl?: string;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
export declare type GetCodeFromPromptSettings = {
|
|
319
|
-
language?: "typescript";
|
|
320
|
-
framework: "react" | "html";
|
|
321
|
-
styling: "tailwind" | "inline_styles";
|
|
322
|
-
uiLibrary?: "shadcn";
|
|
323
|
-
};
|
|
324
|
-
|
|
325
233
|
/**
|
|
326
234
|
* Errors from the Website To Code Flow
|
|
327
235
|
*/
|
|
@@ -647,46 +555,6 @@ export declare type SSECodgenMessageErrorPayload = {
|
|
|
647
555
|
reason: CodegenErrorReason;
|
|
648
556
|
};
|
|
649
557
|
|
|
650
|
-
export declare type SSEGetCodeFromPromptMessage = {
|
|
651
|
-
type: 'queueing';
|
|
652
|
-
} | {
|
|
653
|
-
type: 'start';
|
|
654
|
-
sessionId: string;
|
|
655
|
-
} | {
|
|
656
|
-
type: 'generating_code';
|
|
657
|
-
payload: GeneratingCodePayload;
|
|
658
|
-
} | {
|
|
659
|
-
type: 'generation_completed';
|
|
660
|
-
} | {
|
|
661
|
-
type: 'assets_uploaded';
|
|
662
|
-
} | {
|
|
663
|
-
type: 'assets_list';
|
|
664
|
-
payload: {
|
|
665
|
-
assets: Array<{
|
|
666
|
-
name: string;
|
|
667
|
-
url: string;
|
|
668
|
-
}>;
|
|
669
|
-
};
|
|
670
|
-
} | {
|
|
671
|
-
type: 'aborted';
|
|
672
|
-
} | {
|
|
673
|
-
type: 'error';
|
|
674
|
-
payload: SSEGetCodeFromPromptMessageErrorPayload;
|
|
675
|
-
} | {
|
|
676
|
-
type: 'done';
|
|
677
|
-
payload: {
|
|
678
|
-
sessionId: string;
|
|
679
|
-
tokenUsage: number;
|
|
680
|
-
};
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
export declare type SSEGetCodeFromPromptMessageErrorPayload = {
|
|
684
|
-
errorName: string;
|
|
685
|
-
task?: string;
|
|
686
|
-
reason: GetCodeFromPromptErrorReason;
|
|
687
|
-
sentryTraceId?: string;
|
|
688
|
-
};
|
|
689
|
-
|
|
690
558
|
export declare type SSEGetCodeFromWebsiteMessage = {
|
|
691
559
|
type: 'queueing';
|
|
692
560
|
} | {
|
|
@@ -732,8 +600,6 @@ export declare type SSEGetCodeFromWebsiteMessageErrorPayload = {
|
|
|
732
600
|
*/
|
|
733
601
|
export declare type SSEL2CMessage = SSEGetCodeFromWebsiteMessage;
|
|
734
602
|
|
|
735
|
-
export declare type StreamCodeFromPromptMessage = StreamMessage<SSEGetCodeFromPromptMessage>;
|
|
736
|
-
|
|
737
603
|
export declare type StreamCodeFromWebsiteMessage = StreamMessage<SSEGetCodeFromWebsiteMessage>;
|
|
738
604
|
|
|
739
605
|
export declare type StreamCodgenMessage = StreamMessage<SSECodgenMessage>;
|