@animaapp/anima-sdk 0.7.3 → 0.9.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 +92 -96
- package/dist/index.js +1673 -1997
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
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';
|
|
2
|
+
import { GetMeResponse } from '@figma/rest-api-spec';
|
|
5
3
|
import { Node as Node_2 } from '@figma/rest-api-spec';
|
|
6
|
-
import { Style } from '@figma/rest-api-spec';
|
|
7
4
|
|
|
8
5
|
export declare class Anima {
|
|
9
6
|
#private;
|
|
10
|
-
constructor({ auth, apiBaseAddress, }?: {
|
|
7
|
+
constructor({ auth, apiBaseAddress, figmaRestApi, }?: {
|
|
11
8
|
auth?: Auth;
|
|
12
9
|
apiBaseAddress?: string;
|
|
13
10
|
path?: string;
|
|
11
|
+
figmaRestApi?: FigmaRestApi;
|
|
14
12
|
});
|
|
15
13
|
protected hasAuth(): boolean;
|
|
16
14
|
set auth(auth: Auth);
|
|
@@ -127,7 +125,7 @@ export declare type CodegenSettings = BaseSettings & {
|
|
|
127
125
|
language?: "typescript" | "javascript";
|
|
128
126
|
model?: string;
|
|
129
127
|
framework: "react" | "html";
|
|
130
|
-
styling: "plain_css" | "
|
|
128
|
+
styling: "plain_css" | "tailwind" | "inline_styles";
|
|
131
129
|
uiLibrary?: "mui" | "antd" | "radix" | "shadcn" | "clean_react";
|
|
132
130
|
responsivePages?: Array<{
|
|
133
131
|
name: string;
|
|
@@ -253,35 +251,47 @@ export declare const createLink2CodeResponseEventStream: (anima: Anima, params:
|
|
|
253
251
|
*/
|
|
254
252
|
export declare const createLink2CodeStream: (anima: Anima, params: GetLink2CodeParams) => ReadableStream<StreamL2CMessage>;
|
|
255
253
|
|
|
256
|
-
export declare
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
body: {
|
|
260
|
-
err: string;
|
|
261
|
-
status: number;
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export declare type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException" | "RequestTooLarge";
|
|
254
|
+
export declare class ExpiredFigmaToken extends Error {
|
|
255
|
+
constructor();
|
|
256
|
+
}
|
|
267
257
|
|
|
268
258
|
export declare type FigmaNode = Node_2;
|
|
269
259
|
|
|
270
|
-
export declare type
|
|
271
|
-
id: string;
|
|
272
|
-
name: string;
|
|
273
|
-
};
|
|
260
|
+
export declare type FigmaPlanTier = "enterprise" | "org" | "pro" | "starter" | "student";
|
|
274
261
|
|
|
275
|
-
export declare
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
262
|
+
export declare type FigmaRateLimitType = "low" | "high";
|
|
263
|
+
|
|
264
|
+
export declare class FigmaRestApi {
|
|
265
|
+
#private;
|
|
266
|
+
constructor({ fetch, baseAddress, defaultOptions, }?: FigmaRestApiConstructor);
|
|
267
|
+
hasDefaultToken(): boolean;
|
|
268
|
+
updateDefaultOptions(options: Options): void;
|
|
269
|
+
withOptions(options: Options): this;
|
|
270
|
+
getHeaders(token?: string): Record<string, string>;
|
|
271
|
+
getFile({ fileKey, nodeIds, depth, }: {
|
|
279
272
|
fileKey: string;
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
})
|
|
273
|
+
nodeIds?: string[];
|
|
274
|
+
depth?: number;
|
|
275
|
+
}): Promise<GetFileResponse>;
|
|
276
|
+
getNodeImages<As extends "links" | "arrayBuffer" = "arrayBuffer">({ fileKey, nodeIds, scale, as, format, }: {
|
|
277
|
+
fileKey: string;
|
|
278
|
+
nodeIds: string[];
|
|
279
|
+
scale?: number;
|
|
280
|
+
as?: As;
|
|
281
|
+
format?: "jpg" | "png" | "svg" | "pdf";
|
|
282
|
+
}): Promise<As extends "arrayBuffer" ? Record<string, ArrayBuffer | null> : Record<string, string | null>>;
|
|
283
|
+
getImageFills({ fileKey, }: {
|
|
284
|
+
fileKey: string;
|
|
285
|
+
}): Promise<Record<string, string>>;
|
|
286
|
+
getMe(): Promise<GetMeResponse>;
|
|
283
287
|
}
|
|
284
288
|
|
|
289
|
+
declare type FigmaRestApiConstructor = {
|
|
290
|
+
fetch?: typeof window.fetch;
|
|
291
|
+
baseAddress?: string;
|
|
292
|
+
defaultOptions?: Omit<Options, "abortSignal">;
|
|
293
|
+
};
|
|
294
|
+
|
|
285
295
|
export declare const findChildrenNode: (node: FigmaNode, targetNodeId: string) => FigmaNode | null;
|
|
286
296
|
|
|
287
297
|
export declare const formatToFigmaLink: ({ fileKey, nodeId, duplicate, }: {
|
|
@@ -426,6 +436,7 @@ export declare type GetCodeHandler = ((message: SSEGetCodeFromFigmaMessage) => v
|
|
|
426
436
|
export declare type GetCodeParams = {
|
|
427
437
|
fileKey: string;
|
|
428
438
|
figmaToken?: string;
|
|
439
|
+
figmaRateLimitMaxWait?: number;
|
|
429
440
|
nodesId: string[];
|
|
430
441
|
assetsStorage?: AssetsStorage;
|
|
431
442
|
settings: CodegenSettings;
|
|
@@ -437,50 +448,7 @@ export declare type GetCodeParams = {
|
|
|
437
448
|
}>;
|
|
438
449
|
};
|
|
439
450
|
|
|
440
|
-
export
|
|
441
|
-
|
|
442
|
-
export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, signal, }: GetFilePagesParams) => Promise<GetFileResponse>;
|
|
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
|
-
};
|
|
451
|
+
export { GetFileResponse }
|
|
484
452
|
|
|
485
453
|
/**
|
|
486
454
|
* @deprecated This type is deprecated and will be removed soon.
|
|
@@ -496,6 +464,8 @@ export declare type GetLink2CodeParams = {
|
|
|
496
464
|
tracking?: TrackingInfos;
|
|
497
465
|
};
|
|
498
466
|
|
|
467
|
+
export { GetMeResponse }
|
|
468
|
+
|
|
499
469
|
export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
500
470
|
files: AnimaFiles;
|
|
501
471
|
screenPath?: string;
|
|
@@ -503,8 +473,6 @@ export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
|
503
473
|
|
|
504
474
|
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
475
|
|
|
506
|
-
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
507
|
-
|
|
508
476
|
/**
|
|
509
477
|
* Check if the pair "design" + "node id" is valid for code generation.
|
|
510
478
|
* May recommend a node that is not the one passed as argument.
|
|
@@ -530,7 +498,7 @@ export declare type L2CParams = {
|
|
|
530
498
|
input: L2CParamsInput;
|
|
531
499
|
conventions: L2CParamsConvention;
|
|
532
500
|
assetsStorage: L2CParamsAssetsStorage;
|
|
533
|
-
viewports?: Array<
|
|
501
|
+
viewports?: Array<"desktop" | "tablet" | "mobile">;
|
|
534
502
|
};
|
|
535
503
|
|
|
536
504
|
/**
|
|
@@ -542,9 +510,9 @@ export declare type L2CParamsAssetsStorage = L2CParamsBundledAssetsStorage;
|
|
|
542
510
|
* @deprecated This type is deprecated and will be removed soon.
|
|
543
511
|
*/
|
|
544
512
|
export declare type L2CParamsBundledAssetsStorage = {
|
|
545
|
-
type:
|
|
513
|
+
type: "bundled";
|
|
546
514
|
referencePath?: string;
|
|
547
|
-
importMode?:
|
|
515
|
+
importMode?: "watermarked" | "original";
|
|
548
516
|
};
|
|
549
517
|
|
|
550
518
|
/**
|
|
@@ -555,13 +523,13 @@ export declare type L2CParamsConvention = L2CParamsHtmlConvention | L2CParamsRea
|
|
|
555
523
|
/**
|
|
556
524
|
* @deprecated This type is deprecated and will be removed soon.
|
|
557
525
|
*/
|
|
558
|
-
export declare type L2CParamsFramework =
|
|
526
|
+
export declare type L2CParamsFramework = "html" | "react";
|
|
559
527
|
|
|
560
528
|
/**
|
|
561
529
|
* @deprecated This type is deprecated and will be removed soon.
|
|
562
530
|
*/
|
|
563
531
|
export declare type L2CParamsHtmlConvention = {
|
|
564
|
-
framework:
|
|
532
|
+
framework: "html";
|
|
565
533
|
styling: L2CParamsStyling;
|
|
566
534
|
};
|
|
567
535
|
|
|
@@ -573,13 +541,13 @@ export declare type L2CParamsInput = L2CParamsUrlInput;
|
|
|
573
541
|
/**
|
|
574
542
|
* @deprecated This type is deprecated and will be removed soon.
|
|
575
543
|
*/
|
|
576
|
-
export declare type L2CParamsLanguage =
|
|
544
|
+
export declare type L2CParamsLanguage = "typescript";
|
|
577
545
|
|
|
578
546
|
/**
|
|
579
547
|
* @deprecated This type is deprecated and will be removed soon.
|
|
580
548
|
*/
|
|
581
549
|
export declare type L2CParamsReactConvention = {
|
|
582
|
-
framework:
|
|
550
|
+
framework: "react";
|
|
583
551
|
language: L2CParamsLanguage;
|
|
584
552
|
styling: L2CParamsStyling;
|
|
585
553
|
enableGeneratePackageLock?: boolean;
|
|
@@ -588,7 +556,7 @@ export declare type L2CParamsReactConvention = {
|
|
|
588
556
|
/**
|
|
589
557
|
* @deprecated This type is deprecated and will be removed soon.
|
|
590
558
|
*/
|
|
591
|
-
export declare type L2CParamsStyling =
|
|
559
|
+
export declare type L2CParamsStyling = "tailwind" | "inline-styles";
|
|
592
560
|
|
|
593
561
|
/**
|
|
594
562
|
* @deprecated This type is deprecated and will be removed soon.
|
|
@@ -598,16 +566,45 @@ export declare type L2CParamsUrlInput = {
|
|
|
598
566
|
url: string;
|
|
599
567
|
};
|
|
600
568
|
|
|
569
|
+
/**
|
|
570
|
+
* Figma REST API Errors
|
|
571
|
+
*/
|
|
572
|
+
export declare class MalformattedFigmaToken extends Error {
|
|
573
|
+
constructor();
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export declare class MissingFigmaToken extends Error {
|
|
577
|
+
constructor();
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
export declare class NeedsReauthFigmaToken extends Error {
|
|
581
|
+
constructor();
|
|
582
|
+
}
|
|
583
|
+
|
|
601
584
|
export declare class NotFound extends Error {
|
|
602
|
-
|
|
603
|
-
constructor({ fileKey, cause }: {
|
|
604
|
-
fileKey: string;
|
|
585
|
+
constructor({ cause }: {
|
|
605
586
|
cause?: unknown;
|
|
606
587
|
});
|
|
607
588
|
}
|
|
608
589
|
|
|
590
|
+
export declare type Options = {
|
|
591
|
+
token?: string;
|
|
592
|
+
abortSignal?: AbortSignal;
|
|
593
|
+
onForbidden?: (error: NeedsReauthFigmaToken | ExpiredFigmaToken | UnknownForbiddenFigmaError) => Promise<{
|
|
594
|
+
retry: {
|
|
595
|
+
newToken: string;
|
|
596
|
+
};
|
|
597
|
+
} | void>;
|
|
598
|
+
onRateLimited?: (headers: {
|
|
599
|
+
retryAfter: number;
|
|
600
|
+
figmaPlanTier: FigmaPlanTier;
|
|
601
|
+
figmaRateLimitType: FigmaRateLimitType;
|
|
602
|
+
}) => Promise<boolean>;
|
|
603
|
+
};
|
|
604
|
+
|
|
609
605
|
export declare type ProgressMessage = {
|
|
610
606
|
id: string;
|
|
607
|
+
type: "info" | "rate_limit";
|
|
611
608
|
title: string;
|
|
612
609
|
subtitle?: string;
|
|
613
610
|
body?: string;
|
|
@@ -615,17 +612,13 @@ export declare type ProgressMessage = {
|
|
|
615
612
|
};
|
|
616
613
|
|
|
617
614
|
export declare class RateLimitExceeded extends Error {
|
|
618
|
-
|
|
619
|
-
constructor({ fileKey, cause }: {
|
|
620
|
-
fileKey: string;
|
|
615
|
+
constructor({ cause }: {
|
|
621
616
|
cause?: unknown;
|
|
622
617
|
});
|
|
623
618
|
}
|
|
624
619
|
|
|
625
620
|
export declare class RequestTooLarge extends Error {
|
|
626
|
-
|
|
627
|
-
constructor({ fileKey, cause }: {
|
|
628
|
-
fileKey: string;
|
|
621
|
+
constructor({ cause }: {
|
|
629
622
|
cause?: unknown;
|
|
630
623
|
});
|
|
631
624
|
}
|
|
@@ -797,13 +790,18 @@ export declare type TrackingInfos = {
|
|
|
797
790
|
};
|
|
798
791
|
|
|
799
792
|
export declare class UnknownFigmaApiException extends Error {
|
|
800
|
-
|
|
801
|
-
constructor({ fileKey, cause }: {
|
|
802
|
-
fileKey: string;
|
|
793
|
+
constructor({ cause }: {
|
|
803
794
|
cause: unknown;
|
|
804
795
|
});
|
|
805
796
|
}
|
|
806
797
|
|
|
798
|
+
export declare class UnknownForbiddenFigmaError extends Error {
|
|
799
|
+
reason: string | null;
|
|
800
|
+
constructor({ reason }: {
|
|
801
|
+
reason: string | null;
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
|
|
807
805
|
declare type ValidateNodeForCodegenResult = {
|
|
808
806
|
isValid: true;
|
|
809
807
|
node: FigmaNode;
|
|
@@ -819,6 +817,4 @@ declare type ValidateNodeForCodegenResult = {
|
|
|
819
817
|
|
|
820
818
|
export declare const validateSettings: (obj: unknown) => CodegenSettings;
|
|
821
819
|
|
|
822
|
-
export declare const wrapFigmaApiError: (error: FigmaApiError, fileKey: string) => Error;
|
|
823
|
-
|
|
824
820
|
export { }
|