@animaapp/anima-sdk 0.7.2 → 0.8.0
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 +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +71 -88
- package/dist/index.js +1644 -1993
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { Component } from '@figma/rest-api-spec';
|
|
2
|
-
import { ComponentSet } from '@figma/rest-api-spec';
|
|
3
|
-
import { FigmaRestApi } from '@animaapp/http-client-figma';
|
|
4
1
|
import { GetFileResponse } from '@figma/rest-api-spec';
|
|
5
2
|
import { Node as Node_2 } from '@figma/rest-api-spec';
|
|
6
|
-
import { Style } from '@figma/rest-api-spec';
|
|
7
3
|
|
|
8
4
|
export declare class Anima {
|
|
9
5
|
#private;
|
|
10
|
-
constructor({ auth, apiBaseAddress, }?: {
|
|
6
|
+
constructor({ auth, apiBaseAddress, figmaRestApi, }?: {
|
|
11
7
|
auth?: Auth;
|
|
12
8
|
apiBaseAddress?: string;
|
|
13
9
|
path?: string;
|
|
10
|
+
figmaRestApi?: FigmaRestApi;
|
|
14
11
|
});
|
|
15
12
|
protected hasAuth(): boolean;
|
|
16
13
|
set auth(auth: Auth);
|
|
@@ -127,7 +124,7 @@ export declare type CodegenSettings = BaseSettings & {
|
|
|
127
124
|
language?: "typescript" | "javascript";
|
|
128
125
|
model?: string;
|
|
129
126
|
framework: "react" | "html";
|
|
130
|
-
styling: "plain_css" | "
|
|
127
|
+
styling: "plain_css" | "tailwind" | "inline_styles";
|
|
131
128
|
uiLibrary?: "mui" | "antd" | "radix" | "shadcn" | "clean_react";
|
|
132
129
|
responsivePages?: Array<{
|
|
133
130
|
name: string;
|
|
@@ -253,31 +250,45 @@ export declare const createLink2CodeResponseEventStream: (anima: Anima, params:
|
|
|
253
250
|
*/
|
|
254
251
|
export declare const createLink2CodeStream: (anima: Anima, params: GetLink2CodeParams) => ReadableStream<StreamL2CMessage>;
|
|
255
252
|
|
|
256
|
-
export declare type FigmaApiError = {
|
|
257
|
-
cause: {
|
|
258
|
-
message?: string;
|
|
259
|
-
body: {
|
|
260
|
-
err: string;
|
|
261
|
-
status: number;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
|
-
|
|
266
253
|
export declare type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException" | "RequestTooLarge";
|
|
267
254
|
|
|
268
255
|
export declare type FigmaNode = Node_2;
|
|
269
256
|
|
|
270
|
-
export declare type
|
|
271
|
-
|
|
272
|
-
|
|
257
|
+
export declare type FigmaPlanTier = "enterprise" | "org" | "pro" | "starter" | "student";
|
|
258
|
+
|
|
259
|
+
export declare type FigmaRateLimitType = "low" | "high";
|
|
260
|
+
|
|
261
|
+
export declare class FigmaRestApi {
|
|
262
|
+
#private;
|
|
263
|
+
constructor({ fetch, baseAddress, defaultOptions, }?: FigmaRestApiConstructor);
|
|
264
|
+
updateDefaultOptions(options: Options): void;
|
|
265
|
+
withOptions(options: Options): this;
|
|
266
|
+
getHeaders(token?: string): Record<string, string>;
|
|
267
|
+
getFile({ fileKey, nodeIds, depth, }: {
|
|
268
|
+
fileKey: string;
|
|
269
|
+
nodeIds?: string[];
|
|
270
|
+
depth?: number;
|
|
271
|
+
}): Promise<GetFileResponse>;
|
|
272
|
+
getNodeImages<As extends "links" | "arrayBuffer" = "arrayBuffer">({ fileKey, nodeIds, scale, as, format, }: {
|
|
273
|
+
fileKey: string;
|
|
274
|
+
nodeIds: string[];
|
|
275
|
+
scale?: number;
|
|
276
|
+
as?: As;
|
|
277
|
+
format?: "jpg" | "png" | "svg" | "pdf";
|
|
278
|
+
}): Promise<As extends "arrayBuffer" ? Record<string, ArrayBuffer | null> : Record<string, string | null>>;
|
|
279
|
+
getImageFills({ fileKey, }: {
|
|
280
|
+
fileKey: string;
|
|
281
|
+
}): Promise<Record<string, string>>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare type FigmaRestApiConstructor = {
|
|
285
|
+
fetch?: typeof window.fetch;
|
|
286
|
+
baseAddress?: string;
|
|
287
|
+
defaultOptions?: Omit<Options, "abortSignal">;
|
|
273
288
|
};
|
|
274
289
|
|
|
275
290
|
export declare class FigmaTokenIssue extends Error {
|
|
276
|
-
|
|
277
|
-
reason: string;
|
|
278
|
-
constructor({ fileKey, reason, cause, }: {
|
|
279
|
-
fileKey: string;
|
|
280
|
-
reason: string;
|
|
291
|
+
constructor({ cause }: {
|
|
281
292
|
cause?: unknown;
|
|
282
293
|
});
|
|
283
294
|
}
|
|
@@ -426,6 +437,7 @@ export declare type GetCodeHandler = ((message: SSEGetCodeFromFigmaMessage) => v
|
|
|
426
437
|
export declare type GetCodeParams = {
|
|
427
438
|
fileKey: string;
|
|
428
439
|
figmaToken?: string;
|
|
440
|
+
figmaRateLimitMaxWait?: number;
|
|
429
441
|
nodesId: string[];
|
|
430
442
|
assetsStorage?: AssetsStorage;
|
|
431
443
|
settings: CodegenSettings;
|
|
@@ -439,48 +451,7 @@ export declare type GetCodeParams = {
|
|
|
439
451
|
|
|
440
452
|
export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
|
|
441
453
|
|
|
442
|
-
export
|
|
443
|
-
|
|
444
|
-
export declare const getFileNodes: ({ fileKey, authToken, nodeIds, figmaRestApi, params, signal, }: GetFileNodesParams) => Promise<{
|
|
445
|
-
[key: string]: {
|
|
446
|
-
document: Node_2;
|
|
447
|
-
components: {
|
|
448
|
-
[key: string]: Component;
|
|
449
|
-
};
|
|
450
|
-
componentSets: {
|
|
451
|
-
[key: string]: ComponentSet;
|
|
452
|
-
};
|
|
453
|
-
schemaVersion: number;
|
|
454
|
-
styles: {
|
|
455
|
-
[key: string]: Style;
|
|
456
|
-
};
|
|
457
|
-
};
|
|
458
|
-
}>;
|
|
459
|
-
|
|
460
|
-
export declare type GetFileNodesParams = {
|
|
461
|
-
fileKey: string;
|
|
462
|
-
authToken?: string;
|
|
463
|
-
nodeIds: string[];
|
|
464
|
-
figmaRestApi?: FigmaRestApi;
|
|
465
|
-
params?: Record<string, string | number>;
|
|
466
|
-
signal?: AbortSignal;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
export declare type GetFilePagesParams = {
|
|
470
|
-
fileKey: string;
|
|
471
|
-
authToken?: string;
|
|
472
|
-
figmaRestApi?: FigmaRestApi;
|
|
473
|
-
params?: Record<string, string | number | undefined>;
|
|
474
|
-
signal?: AbortSignal;
|
|
475
|
-
};
|
|
476
|
-
|
|
477
|
-
export declare type GetFilePagesResult = FigmaPage[] | undefined;
|
|
478
|
-
|
|
479
|
-
export declare type GetFileParams = {
|
|
480
|
-
fileKey: string;
|
|
481
|
-
authToken?: string;
|
|
482
|
-
figmaRestApi?: FigmaRestApi;
|
|
483
|
-
};
|
|
454
|
+
export { GetFileResponse }
|
|
484
455
|
|
|
485
456
|
/**
|
|
486
457
|
* @deprecated This type is deprecated and will be removed soon.
|
|
@@ -501,6 +472,13 @@ export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
|
501
472
|
screenPath?: string;
|
|
502
473
|
}) => AnimaFiles;
|
|
503
474
|
|
|
475
|
+
/**
|
|
476
|
+
* Figma REST API Errors
|
|
477
|
+
*/
|
|
478
|
+
export declare class InvalidFigmaAccessTokenError extends Error {
|
|
479
|
+
constructor();
|
|
480
|
+
}
|
|
481
|
+
|
|
504
482
|
declare type InvalidNodeForCodegenReason = "Selected node is a page with multiple children" | "Selected node is a page with no valid children" | "There is no node with the given id" | "Selected node type is not supported";
|
|
505
483
|
|
|
506
484
|
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
@@ -530,7 +508,7 @@ export declare type L2CParams = {
|
|
|
530
508
|
input: L2CParamsInput;
|
|
531
509
|
conventions: L2CParamsConvention;
|
|
532
510
|
assetsStorage: L2CParamsAssetsStorage;
|
|
533
|
-
viewports?: Array<
|
|
511
|
+
viewports?: Array<"desktop" | "tablet" | "mobile">;
|
|
534
512
|
};
|
|
535
513
|
|
|
536
514
|
/**
|
|
@@ -542,9 +520,9 @@ export declare type L2CParamsAssetsStorage = L2CParamsBundledAssetsStorage;
|
|
|
542
520
|
* @deprecated This type is deprecated and will be removed soon.
|
|
543
521
|
*/
|
|
544
522
|
export declare type L2CParamsBundledAssetsStorage = {
|
|
545
|
-
type:
|
|
523
|
+
type: "bundled";
|
|
546
524
|
referencePath?: string;
|
|
547
|
-
importMode?:
|
|
525
|
+
importMode?: "watermarked" | "original";
|
|
548
526
|
};
|
|
549
527
|
|
|
550
528
|
/**
|
|
@@ -555,13 +533,13 @@ export declare type L2CParamsConvention = L2CParamsHtmlConvention | L2CParamsRea
|
|
|
555
533
|
/**
|
|
556
534
|
* @deprecated This type is deprecated and will be removed soon.
|
|
557
535
|
*/
|
|
558
|
-
export declare type L2CParamsFramework =
|
|
536
|
+
export declare type L2CParamsFramework = "html" | "react";
|
|
559
537
|
|
|
560
538
|
/**
|
|
561
539
|
* @deprecated This type is deprecated and will be removed soon.
|
|
562
540
|
*/
|
|
563
541
|
export declare type L2CParamsHtmlConvention = {
|
|
564
|
-
framework:
|
|
542
|
+
framework: "html";
|
|
565
543
|
styling: L2CParamsStyling;
|
|
566
544
|
};
|
|
567
545
|
|
|
@@ -573,13 +551,13 @@ export declare type L2CParamsInput = L2CParamsUrlInput;
|
|
|
573
551
|
/**
|
|
574
552
|
* @deprecated This type is deprecated and will be removed soon.
|
|
575
553
|
*/
|
|
576
|
-
export declare type L2CParamsLanguage =
|
|
554
|
+
export declare type L2CParamsLanguage = "typescript";
|
|
577
555
|
|
|
578
556
|
/**
|
|
579
557
|
* @deprecated This type is deprecated and will be removed soon.
|
|
580
558
|
*/
|
|
581
559
|
export declare type L2CParamsReactConvention = {
|
|
582
|
-
framework:
|
|
560
|
+
framework: "react";
|
|
583
561
|
language: L2CParamsLanguage;
|
|
584
562
|
styling: L2CParamsStyling;
|
|
585
563
|
enableGeneratePackageLock?: boolean;
|
|
@@ -588,7 +566,7 @@ export declare type L2CParamsReactConvention = {
|
|
|
588
566
|
/**
|
|
589
567
|
* @deprecated This type is deprecated and will be removed soon.
|
|
590
568
|
*/
|
|
591
|
-
export declare type L2CParamsStyling =
|
|
569
|
+
export declare type L2CParamsStyling = "tailwind" | "inline-styles";
|
|
592
570
|
|
|
593
571
|
/**
|
|
594
572
|
* @deprecated This type is deprecated and will be removed soon.
|
|
@@ -598,16 +576,29 @@ export declare type L2CParamsUrlInput = {
|
|
|
598
576
|
url: string;
|
|
599
577
|
};
|
|
600
578
|
|
|
579
|
+
export declare class MissingFigmaToken extends Error {
|
|
580
|
+
constructor();
|
|
581
|
+
}
|
|
582
|
+
|
|
601
583
|
export declare class NotFound extends Error {
|
|
602
|
-
|
|
603
|
-
constructor({ fileKey, cause }: {
|
|
604
|
-
fileKey: string;
|
|
584
|
+
constructor({ cause }: {
|
|
605
585
|
cause?: unknown;
|
|
606
586
|
});
|
|
607
587
|
}
|
|
608
588
|
|
|
589
|
+
export declare type Options = {
|
|
590
|
+
token?: string;
|
|
591
|
+
abortSignal?: AbortSignal;
|
|
592
|
+
onRateLimited?: (headers: {
|
|
593
|
+
retryAfter: number;
|
|
594
|
+
figmaPlanTier: FigmaPlanTier;
|
|
595
|
+
figmaRateLimitType: FigmaRateLimitType;
|
|
596
|
+
}) => Promise<boolean>;
|
|
597
|
+
};
|
|
598
|
+
|
|
609
599
|
export declare type ProgressMessage = {
|
|
610
600
|
id: string;
|
|
601
|
+
type: "info" | "rate_limit";
|
|
611
602
|
title: string;
|
|
612
603
|
subtitle?: string;
|
|
613
604
|
body?: string;
|
|
@@ -615,17 +606,13 @@ export declare type ProgressMessage = {
|
|
|
615
606
|
};
|
|
616
607
|
|
|
617
608
|
export declare class RateLimitExceeded extends Error {
|
|
618
|
-
|
|
619
|
-
constructor({ fileKey, cause }: {
|
|
620
|
-
fileKey: string;
|
|
609
|
+
constructor({ cause }: {
|
|
621
610
|
cause?: unknown;
|
|
622
611
|
});
|
|
623
612
|
}
|
|
624
613
|
|
|
625
614
|
export declare class RequestTooLarge extends Error {
|
|
626
|
-
|
|
627
|
-
constructor({ fileKey, cause }: {
|
|
628
|
-
fileKey: string;
|
|
615
|
+
constructor({ cause }: {
|
|
629
616
|
cause?: unknown;
|
|
630
617
|
});
|
|
631
618
|
}
|
|
@@ -797,9 +784,7 @@ export declare type TrackingInfos = {
|
|
|
797
784
|
};
|
|
798
785
|
|
|
799
786
|
export declare class UnknownFigmaApiException extends Error {
|
|
800
|
-
|
|
801
|
-
constructor({ fileKey, cause }: {
|
|
802
|
-
fileKey: string;
|
|
787
|
+
constructor({ cause }: {
|
|
803
788
|
cause: unknown;
|
|
804
789
|
});
|
|
805
790
|
}
|
|
@@ -819,6 +804,4 @@ declare type ValidateNodeForCodegenResult = {
|
|
|
819
804
|
|
|
820
805
|
export declare const validateSettings: (obj: unknown) => CodegenSettings;
|
|
821
806
|
|
|
822
|
-
export declare const wrapFigmaApiError: (error: FigmaApiError, fileKey: string) => Error;
|
|
823
|
-
|
|
824
807
|
export { }
|