@animaapp/anima-sdk 0.8.0 → 0.10.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 +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -18
- package/dist/index.js +811 -779
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GetFileResponse } from '@figma/rest-api-spec';
|
|
2
|
+
import { GetMeResponse } from '@figma/rest-api-spec';
|
|
2
3
|
import { Node as Node_2 } from '@figma/rest-api-spec';
|
|
3
4
|
|
|
4
5
|
export declare class Anima {
|
|
@@ -250,7 +251,9 @@ export declare const createLink2CodeResponseEventStream: (anima: Anima, params:
|
|
|
250
251
|
*/
|
|
251
252
|
export declare const createLink2CodeStream: (anima: Anima, params: GetLink2CodeParams) => ReadableStream<StreamL2CMessage>;
|
|
252
253
|
|
|
253
|
-
export declare
|
|
254
|
+
export declare class ExpiredFigmaToken extends Error {
|
|
255
|
+
constructor();
|
|
256
|
+
}
|
|
254
257
|
|
|
255
258
|
export declare type FigmaNode = Node_2;
|
|
256
259
|
|
|
@@ -261,6 +264,7 @@ export declare type FigmaRateLimitType = "low" | "high";
|
|
|
261
264
|
export declare class FigmaRestApi {
|
|
262
265
|
#private;
|
|
263
266
|
constructor({ fetch, baseAddress, defaultOptions, }?: FigmaRestApiConstructor);
|
|
267
|
+
hasDefaultToken(): boolean;
|
|
264
268
|
updateDefaultOptions(options: Options): void;
|
|
265
269
|
withOptions(options: Options): this;
|
|
266
270
|
getHeaders(token?: string): Record<string, string>;
|
|
@@ -279,6 +283,7 @@ export declare class FigmaRestApi {
|
|
|
279
283
|
getImageFills({ fileKey, }: {
|
|
280
284
|
fileKey: string;
|
|
281
285
|
}): Promise<Record<string, string>>;
|
|
286
|
+
getMe(): Promise<GetMeResponse>;
|
|
282
287
|
}
|
|
283
288
|
|
|
284
289
|
declare type FigmaRestApiConstructor = {
|
|
@@ -287,12 +292,6 @@ declare type FigmaRestApiConstructor = {
|
|
|
287
292
|
defaultOptions?: Omit<Options, "abortSignal">;
|
|
288
293
|
};
|
|
289
294
|
|
|
290
|
-
export declare class FigmaTokenIssue extends Error {
|
|
291
|
-
constructor({ cause }: {
|
|
292
|
-
cause?: unknown;
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
|
|
296
295
|
export declare const findChildrenNode: (node: FigmaNode, targetNodeId: string) => FigmaNode | null;
|
|
297
296
|
|
|
298
297
|
export declare const formatToFigmaLink: ({ fileKey, nodeId, duplicate, }: {
|
|
@@ -387,6 +386,7 @@ export declare type GetCodeFromWebsiteHandler = ((message: SSEGetCodeFromWebsite
|
|
|
387
386
|
export declare type GetCodeFromWebsiteParams = {
|
|
388
387
|
url?: string;
|
|
389
388
|
mhtml?: string;
|
|
389
|
+
mhtmlUrl?: string;
|
|
390
390
|
assetsStorage?: AssetsStorage;
|
|
391
391
|
settings: GetCodeFromWebsiteSettings;
|
|
392
392
|
tracking?: TrackingInfos;
|
|
@@ -449,8 +449,6 @@ export declare type GetCodeParams = {
|
|
|
449
449
|
}>;
|
|
450
450
|
};
|
|
451
451
|
|
|
452
|
-
export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
|
|
453
|
-
|
|
454
452
|
export { GetFileResponse }
|
|
455
453
|
|
|
456
454
|
/**
|
|
@@ -467,22 +465,15 @@ export declare type GetLink2CodeParams = {
|
|
|
467
465
|
tracking?: TrackingInfos;
|
|
468
466
|
};
|
|
469
467
|
|
|
468
|
+
export { GetMeResponse }
|
|
469
|
+
|
|
470
470
|
export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
471
471
|
files: AnimaFiles;
|
|
472
472
|
screenPath?: string;
|
|
473
473
|
}) => AnimaFiles;
|
|
474
474
|
|
|
475
|
-
/**
|
|
476
|
-
* Figma REST API Errors
|
|
477
|
-
*/
|
|
478
|
-
export declare class InvalidFigmaAccessTokenError extends Error {
|
|
479
|
-
constructor();
|
|
480
|
-
}
|
|
481
|
-
|
|
482
475
|
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";
|
|
483
476
|
|
|
484
|
-
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
485
|
-
|
|
486
477
|
/**
|
|
487
478
|
* Check if the pair "design" + "node id" is valid for code generation.
|
|
488
479
|
* May recommend a node that is not the one passed as argument.
|
|
@@ -576,10 +567,21 @@ export declare type L2CParamsUrlInput = {
|
|
|
576
567
|
url: string;
|
|
577
568
|
};
|
|
578
569
|
|
|
570
|
+
/**
|
|
571
|
+
* Figma REST API Errors
|
|
572
|
+
*/
|
|
573
|
+
export declare class MalformattedFigmaToken extends Error {
|
|
574
|
+
constructor();
|
|
575
|
+
}
|
|
576
|
+
|
|
579
577
|
export declare class MissingFigmaToken extends Error {
|
|
580
578
|
constructor();
|
|
581
579
|
}
|
|
582
580
|
|
|
581
|
+
export declare class NeedsReauthFigmaToken extends Error {
|
|
582
|
+
constructor();
|
|
583
|
+
}
|
|
584
|
+
|
|
583
585
|
export declare class NotFound extends Error {
|
|
584
586
|
constructor({ cause }: {
|
|
585
587
|
cause?: unknown;
|
|
@@ -589,6 +591,11 @@ export declare class NotFound extends Error {
|
|
|
589
591
|
export declare type Options = {
|
|
590
592
|
token?: string;
|
|
591
593
|
abortSignal?: AbortSignal;
|
|
594
|
+
onForbidden?: (error: NeedsReauthFigmaToken | ExpiredFigmaToken | UnknownForbiddenFigmaError) => Promise<{
|
|
595
|
+
retry: {
|
|
596
|
+
newToken: string;
|
|
597
|
+
};
|
|
598
|
+
} | void>;
|
|
592
599
|
onRateLimited?: (headers: {
|
|
593
600
|
retryAfter: number;
|
|
594
601
|
figmaPlanTier: FigmaPlanTier;
|
|
@@ -789,6 +796,13 @@ export declare class UnknownFigmaApiException extends Error {
|
|
|
789
796
|
});
|
|
790
797
|
}
|
|
791
798
|
|
|
799
|
+
export declare class UnknownForbiddenFigmaError extends Error {
|
|
800
|
+
reason: string | null;
|
|
801
|
+
constructor({ reason }: {
|
|
802
|
+
reason: string | null;
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
|
|
792
806
|
declare type ValidateNodeForCodegenResult = {
|
|
793
807
|
isValid: true;
|
|
794
808
|
node: FigmaNode;
|