@animaapp/anima-sdk 0.6.4 → 0.6.9
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 +122 -25
- package/dist/index.js +487 -455
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,10 +16,9 @@ export declare class Anima {
|
|
|
16
16
|
set auth(auth: Auth);
|
|
17
17
|
protected get headers(): Record<string, string>;
|
|
18
18
|
generateCode(params: GetCodeParams, handler?: GetCodeHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
19
|
+
generateCodeFromWebsite(params: GetCodeFromWebsiteParams, handler?: GetCodeFromWebsiteHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
19
20
|
/**
|
|
20
|
-
* @
|
|
21
|
-
* This API is experimental and may change or be removed in future releases.
|
|
22
|
-
* Link2Code (l2c) flow.
|
|
21
|
+
* @deprecated This method will be removed soon, please use `generateCodeFromWebsite` instead.
|
|
23
22
|
*/
|
|
24
23
|
generateLink2Code(params: GetLink2CodeParams, handler?: GetLink2CodeHandler, signal?: AbortSignal): Promise<AnimaSDKResult>;
|
|
25
24
|
}
|
|
@@ -64,7 +63,7 @@ export declare class CodegenError extends Error {
|
|
|
64
63
|
detail?: unknown;
|
|
65
64
|
constructor({ name, reason, status, detail, }: {
|
|
66
65
|
name: string;
|
|
67
|
-
reason: CodegenErrorReason | CodegenRouteErrorReason | SDKErrorReason;
|
|
66
|
+
reason: CodegenErrorReason | CodegenRouteErrorReason | SDKErrorReason | GetCodeFromWebsiteErrorReason;
|
|
68
67
|
status?: number;
|
|
69
68
|
detail?: unknown;
|
|
70
69
|
});
|
|
@@ -110,6 +109,28 @@ export declare type CodegenSettings = {
|
|
|
110
109
|
codegenSettings?: Record<string, unknown>;
|
|
111
110
|
};
|
|
112
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the code generation from website stream.
|
|
114
|
+
*
|
|
115
|
+
* But, if the first message indicates an error (e.g., connection failed), the function returns a 500 response with the error message.
|
|
116
|
+
*
|
|
117
|
+
* @param {Anima} anima - The Anima instance to use for creating the data stream.
|
|
118
|
+
* @param {GetCodeFromWebsiteParams} params - The parameters for the code generation request.
|
|
119
|
+
* @returns {Promise<Response>} - A promise that resolves to an HTTP response.
|
|
120
|
+
*/
|
|
121
|
+
export declare const createCodeFromWebsiteResponseEventStream: (anima: Anima, params: GetCodeFromWebsiteParams) => Promise<Response>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Start the code generation from website and creates a ReadableStream to output its result.
|
|
125
|
+
*
|
|
126
|
+
* The stream is closed when the code generation ends.
|
|
127
|
+
*
|
|
128
|
+
* @param {Anima} anima - An Anima service instance to generate the code from.
|
|
129
|
+
* @param {GetCodeFromWebsiteParams} params - Parameters required for the code generation process.
|
|
130
|
+
* @returns {ReadableStream<StreamCodeFromWebsiteMessage>} - A ReadableStream that emits messages related to the code generation process.
|
|
131
|
+
*/
|
|
132
|
+
export declare const createCodeFromWebsiteStream: (anima: Anima, params: GetCodeFromWebsiteParams) => ReadableStream<StreamCodeFromWebsiteMessage>;
|
|
133
|
+
|
|
113
134
|
/**
|
|
114
135
|
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the code generation stream.
|
|
115
136
|
*
|
|
@@ -133,6 +154,7 @@ export declare const createCodegenResponseEventStream: (anima: Anima, params: Ge
|
|
|
133
154
|
export declare const createCodegenStream: (anima: Anima, params: GetCodeParams) => ReadableStream<StreamCodgenMessage>;
|
|
134
155
|
|
|
135
156
|
/**
|
|
157
|
+
* @deprecated This function will be removed soon, please use `createCodeFromWebsiteResponseEventStream` instead.
|
|
136
158
|
* Creates a Server-Sent Events (SSE) `Response` that forwards all messages from the URL to code generation stream.
|
|
137
159
|
*
|
|
138
160
|
* But, if the first message indicates an error (e.g., connection failed), the function returns a 500 response with the error message.
|
|
@@ -144,6 +166,7 @@ export declare const createCodegenStream: (anima: Anima, params: GetCodeParams)
|
|
|
144
166
|
export declare const createLink2CodeResponseEventStream: (anima: Anima, params: GetLink2CodeParams) => Promise<Response>;
|
|
145
167
|
|
|
146
168
|
/**
|
|
169
|
+
* @deprecated This function will be removed soon, please use `createCodeFromWebsiteStream` instead.
|
|
147
170
|
* @experimental
|
|
148
171
|
* This API is experimental and may change or be removed in future releases.
|
|
149
172
|
* Link2Code (l2c) stream flow.
|
|
@@ -201,6 +224,45 @@ export declare type GeneratingCodePayload = {
|
|
|
201
224
|
files: AnimaFiles;
|
|
202
225
|
};
|
|
203
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Errors from the Website To Code Flow
|
|
229
|
+
*/
|
|
230
|
+
export declare type GetCodeFromWebsiteErrorReason = "Scraping is blocked" | "Unknown";
|
|
231
|
+
|
|
232
|
+
export declare type GetCodeFromWebsiteHandler = ((message: SSEGetCodeFromWebsiteMessage) => void) | {
|
|
233
|
+
onQueueing?: () => void;
|
|
234
|
+
onStart?: ({ sessionId }: {
|
|
235
|
+
sessionId: string;
|
|
236
|
+
}) => void;
|
|
237
|
+
onAssetsUploaded?: () => void;
|
|
238
|
+
onAssetsList?: ({ assets, }: {
|
|
239
|
+
assets: Array<{
|
|
240
|
+
name: string;
|
|
241
|
+
url: string;
|
|
242
|
+
}>;
|
|
243
|
+
}) => void;
|
|
244
|
+
onGeneratingCode?: ({ status, progress, files, }: {
|
|
245
|
+
status: "success" | "running" | "failure";
|
|
246
|
+
progress: number;
|
|
247
|
+
files: AnimaFiles;
|
|
248
|
+
}) => void;
|
|
249
|
+
onCodegenCompleted?: () => void;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export declare type GetCodeFromWebsiteParams = {
|
|
253
|
+
url: string;
|
|
254
|
+
assetsStorage?: AssetsStorage;
|
|
255
|
+
settings: GetCodeFromWebsiteSettings;
|
|
256
|
+
tracking?: TrackingInfos;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export declare type GetCodeFromWebsiteSettings = {
|
|
260
|
+
language?: "typescript";
|
|
261
|
+
framework: "react" | "html";
|
|
262
|
+
styling: "tailwind" | "inline_styles";
|
|
263
|
+
uiLibrary?: "shadcn";
|
|
264
|
+
};
|
|
265
|
+
|
|
204
266
|
export declare type GetCodeHandler = ((message: SSECodgenMessage) => void) | {
|
|
205
267
|
onQueueing?: () => void;
|
|
206
268
|
onStart?: ({ sessionId }: {
|
|
@@ -282,26 +344,14 @@ export declare type GetFileParams = {
|
|
|
282
344
|
figmaRestApi?: FigmaRestApi;
|
|
283
345
|
};
|
|
284
346
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}) => void;
|
|
290
|
-
onAssetsUploaded?: () => void;
|
|
291
|
-
onAssetsList?: ({ assets, }: {
|
|
292
|
-
assets: Array<{
|
|
293
|
-
name: string;
|
|
294
|
-
url: string;
|
|
295
|
-
}>;
|
|
296
|
-
}) => void;
|
|
297
|
-
onGeneratingCode?: ({ status, progress, files, }: {
|
|
298
|
-
status: "success" | "running" | "failure";
|
|
299
|
-
progress: number;
|
|
300
|
-
files: AnimaFiles;
|
|
301
|
-
}) => void;
|
|
302
|
-
onCodegenCompleted?: () => void;
|
|
303
|
-
};
|
|
347
|
+
/**
|
|
348
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
349
|
+
*/
|
|
350
|
+
export declare type GetLink2CodeHandler = GetCodeFromWebsiteHandler;
|
|
304
351
|
|
|
352
|
+
/**
|
|
353
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
354
|
+
*/
|
|
305
355
|
export declare type GetLink2CodeParams = {
|
|
306
356
|
params: L2CParams;
|
|
307
357
|
assetsStorage?: AssetsStorage;
|
|
@@ -335,6 +385,9 @@ export declare const isUnknownFigmaApiException: (error: Error) => boolean;
|
|
|
335
385
|
|
|
336
386
|
export declare const isValidFigmaUrl: (figmaLink: string) => [hasCorrectPrefix: boolean, fileKey: string, nodeId: string];
|
|
337
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
390
|
+
*/
|
|
338
391
|
export declare type L2CParams = {
|
|
339
392
|
input: L2CParamsInput;
|
|
340
393
|
conventions: L2CParamsConvention;
|
|
@@ -342,27 +395,51 @@ export declare type L2CParams = {
|
|
|
342
395
|
viewports?: Array<'desktop' | 'tablet' | 'mobile'>;
|
|
343
396
|
};
|
|
344
397
|
|
|
398
|
+
/**
|
|
399
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
400
|
+
*/
|
|
345
401
|
export declare type L2CParamsAssetsStorage = L2CParamsBundledAssetsStorage;
|
|
346
402
|
|
|
403
|
+
/**
|
|
404
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
405
|
+
*/
|
|
347
406
|
export declare type L2CParamsBundledAssetsStorage = {
|
|
348
407
|
type: 'bundled';
|
|
349
408
|
referencePath?: string;
|
|
350
409
|
importMode?: 'watermarked' | 'original';
|
|
351
410
|
};
|
|
352
411
|
|
|
412
|
+
/**
|
|
413
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
414
|
+
*/
|
|
353
415
|
export declare type L2CParamsConvention = L2CParamsHtmlConvention | L2CParamsReactConvention;
|
|
354
416
|
|
|
417
|
+
/**
|
|
418
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
419
|
+
*/
|
|
355
420
|
export declare type L2CParamsFramework = 'html' | 'react';
|
|
356
421
|
|
|
422
|
+
/**
|
|
423
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
424
|
+
*/
|
|
357
425
|
export declare type L2CParamsHtmlConvention = {
|
|
358
426
|
framework: 'html';
|
|
359
427
|
styling: L2CParamsStyling;
|
|
360
428
|
};
|
|
361
429
|
|
|
430
|
+
/**
|
|
431
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
432
|
+
*/
|
|
362
433
|
export declare type L2CParamsInput = L2CParamsUrlInput;
|
|
363
434
|
|
|
435
|
+
/**
|
|
436
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
437
|
+
*/
|
|
364
438
|
export declare type L2CParamsLanguage = 'typescript';
|
|
365
439
|
|
|
440
|
+
/**
|
|
441
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
442
|
+
*/
|
|
366
443
|
export declare type L2CParamsReactConvention = {
|
|
367
444
|
framework: 'react';
|
|
368
445
|
language: L2CParamsLanguage;
|
|
@@ -370,8 +447,14 @@ export declare type L2CParamsReactConvention = {
|
|
|
370
447
|
enableGeneratePackageLock?: boolean;
|
|
371
448
|
};
|
|
372
449
|
|
|
450
|
+
/**
|
|
451
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
452
|
+
*/
|
|
373
453
|
export declare type L2CParamsStyling = 'tailwind' | 'inline-styles';
|
|
374
454
|
|
|
455
|
+
/**
|
|
456
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
457
|
+
*/
|
|
375
458
|
export declare type L2CParamsUrlInput = {
|
|
376
459
|
type: 'url';
|
|
377
460
|
url: string;
|
|
@@ -464,7 +547,7 @@ export declare type SSECodgenMessageErrorPayload = {
|
|
|
464
547
|
reason: CodegenErrorReason;
|
|
465
548
|
};
|
|
466
549
|
|
|
467
|
-
export declare type
|
|
550
|
+
export declare type SSEGetCodeFromWebsiteMessage = {
|
|
468
551
|
type: 'queueing';
|
|
469
552
|
} | {
|
|
470
553
|
type: 'start';
|
|
@@ -488,7 +571,7 @@ export declare type SSEL2CMessage = {
|
|
|
488
571
|
type: 'aborted';
|
|
489
572
|
} | {
|
|
490
573
|
type: 'error';
|
|
491
|
-
payload:
|
|
574
|
+
payload: SSEGetCodeFromWebsiteMessageErrorPayload;
|
|
492
575
|
} | {
|
|
493
576
|
type: 'done';
|
|
494
577
|
payload: {
|
|
@@ -497,6 +580,20 @@ export declare type SSEL2CMessage = {
|
|
|
497
580
|
};
|
|
498
581
|
};
|
|
499
582
|
|
|
583
|
+
export declare type SSEGetCodeFromWebsiteMessageErrorPayload = {
|
|
584
|
+
errorName: string;
|
|
585
|
+
task?: string;
|
|
586
|
+
reason: GetCodeFromWebsiteErrorReason;
|
|
587
|
+
sentryTraceId?: string;
|
|
588
|
+
};
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* @deprecated This type is deprecated and will be removed soon.
|
|
592
|
+
*/
|
|
593
|
+
export declare type SSEL2CMessage = SSEGetCodeFromWebsiteMessage;
|
|
594
|
+
|
|
595
|
+
export declare type StreamCodeFromWebsiteMessage = StreamMessage<SSEGetCodeFromWebsiteMessage>;
|
|
596
|
+
|
|
500
597
|
export declare type StreamCodgenMessage = StreamMessage<SSECodgenMessage>;
|
|
501
598
|
|
|
502
599
|
declare type StreamErrorPayload = {
|