@animaapp/anima-sdk 0.8.0 → 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.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 type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException" | "RequestTooLarge";
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, }: {
@@ -449,8 +448,6 @@ export declare type GetCodeParams = {
449
448
  }>;
450
449
  };
451
450
 
452
- export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
453
-
454
451
  export { GetFileResponse }
455
452
 
456
453
  /**
@@ -467,22 +464,15 @@ export declare type GetLink2CodeParams = {
467
464
  tracking?: TrackingInfos;
468
465
  };
469
466
 
467
+ export { GetMeResponse }
468
+
470
469
  export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
471
470
  files: AnimaFiles;
472
471
  screenPath?: string;
473
472
  }) => AnimaFiles;
474
473
 
475
- /**
476
- * Figma REST API Errors
477
- */
478
- export declare class InvalidFigmaAccessTokenError extends Error {
479
- constructor();
480
- }
481
-
482
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";
483
475
 
484
- export declare const isFigmaTokenIssue: (error: Error) => boolean;
485
-
486
476
  /**
487
477
  * Check if the pair "design" + "node id" is valid for code generation.
488
478
  * May recommend a node that is not the one passed as argument.
@@ -576,10 +566,21 @@ export declare type L2CParamsUrlInput = {
576
566
  url: string;
577
567
  };
578
568
 
569
+ /**
570
+ * Figma REST API Errors
571
+ */
572
+ export declare class MalformattedFigmaToken extends Error {
573
+ constructor();
574
+ }
575
+
579
576
  export declare class MissingFigmaToken extends Error {
580
577
  constructor();
581
578
  }
582
579
 
580
+ export declare class NeedsReauthFigmaToken extends Error {
581
+ constructor();
582
+ }
583
+
583
584
  export declare class NotFound extends Error {
584
585
  constructor({ cause }: {
585
586
  cause?: unknown;
@@ -589,6 +590,11 @@ export declare class NotFound extends Error {
589
590
  export declare type Options = {
590
591
  token?: string;
591
592
  abortSignal?: AbortSignal;
593
+ onForbidden?: (error: NeedsReauthFigmaToken | ExpiredFigmaToken | UnknownForbiddenFigmaError) => Promise<{
594
+ retry: {
595
+ newToken: string;
596
+ };
597
+ } | void>;
592
598
  onRateLimited?: (headers: {
593
599
  retryAfter: number;
594
600
  figmaPlanTier: FigmaPlanTier;
@@ -789,6 +795,13 @@ export declare class UnknownFigmaApiException extends Error {
789
795
  });
790
796
  }
791
797
 
798
+ export declare class UnknownForbiddenFigmaError extends Error {
799
+ reason: string | null;
800
+ constructor({ reason }: {
801
+ reason: string | null;
802
+ });
803
+ }
804
+
792
805
  declare type ValidateNodeForCodegenResult = {
793
806
  isValid: true;
794
807
  node: FigmaNode;