@animaapp/anima-sdk 0.3.1 → 0.3.4

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
@@ -58,14 +58,14 @@ export declare class CodegenError extends Error {
58
58
  detail?: unknown;
59
59
  constructor({ name, reason, status, detail, }: {
60
60
  name: string;
61
- reason: CodegenErrorReason | SDKErrorReason;
61
+ reason: CodegenErrorReason | CodegenRouteErrorReason | SDKErrorReason;
62
62
  status?: number;
63
63
  detail?: unknown;
64
64
  });
65
65
  }
66
66
 
67
67
  /**
68
- * Errors from Public API
68
+ * Codegen errors from the worker
69
69
  */
70
70
  export declare type CodegenErrorReason = "Selected node type is not supported" | "Invisible group nodes are unsupported" | "Selected node is a page with multiple children" | "There is no node with the given id" | "Invalid Figma token" | "Anima API connection error" | "Figma token expired" | "Invalid user token" | "Figma file not found" | "Figma rate limit exceeded" | "Unknown";
71
71
 
@@ -76,6 +76,11 @@ export declare type CodegenResult = BaseResult & {
76
76
  }>;
77
77
  };
78
78
 
79
+ /**
80
+ * Codegen errors from the "/codegen" route
81
+ */
82
+ export declare type CodegenRouteErrorReason = "Missing Authorization header" | "Invalid Authorization header" | "Missing teamId" | "Internal server error" | "Forbidden, no team access" | "Requested Usage Exceeds Limit" | "Invalid Anima token";
83
+
79
84
  export declare type CodegenSettings = {
80
85
  language?: "typescript" | "javascript";
81
86
  model?: string;
@@ -143,6 +148,8 @@ export declare class FigmaTokenIssue extends Error {
143
148
  });
144
149
  }
145
150
 
151
+ export declare const findChildrenNode: (node: FigmaNode, targetNodeId: string) => FigmaNode | null;
152
+
146
153
  export declare const formatToFigmaLink: ({ fileKey, nodeId, duplicate, }: {
147
154
  fileKey: string;
148
155
  nodeId: string;
@@ -193,9 +200,7 @@ export declare type GetCodeParams = {
193
200
 
194
201
  export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
195
202
 
196
- export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, }: GetFilePagesParams) => Promise<GetFigmaFileResult>;
197
-
198
- export declare type GetFigmaFileResult = GetFileResponse | undefined;
203
+ export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, }: GetFilePagesParams) => Promise<GetFileResponse>;
199
204
 
200
205
  export declare const getFileNodes: ({ fileKey, authToken, nodeIds, figmaRestApi, params, }: GetFileNodesParams) => Promise<{
201
206
  [key: string]: {
@@ -243,8 +248,15 @@ export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
243
248
 
244
249
  export declare const handleFigmaApiError: (error: FigmaApiError, fileKey: string) => never;
245
250
 
251
+ declare type InvalidNodeForCodegenReason = "Selected node is a page with multiple children" | "There is no node with the given id" | "Selected node type is not supported";
252
+
246
253
  export declare const isFigmaTokenIssue: (error: Error) => boolean;
247
254
 
255
+ /**
256
+ * Check if the pair "design" + "node id" are valid for code generation.
257
+ */
258
+ export declare const isNodeCodegenCompatible: (design: GetFileResponse, nodeId: string) => ValidateNodeForCodegenResult;
259
+
248
260
  export declare const isNotFound: (error: Error) => boolean;
249
261
 
250
262
  export declare const isRateLimitExceeded: (error: Error) => boolean;
@@ -347,6 +359,15 @@ export declare class UnknownFigmaApiException extends Error {
347
359
  });
348
360
  }
349
361
 
362
+ declare type ValidateNodeForCodegenResult = {
363
+ isValid: true;
364
+ node: FigmaNode;
365
+ note?: "Selected node is a page with a single valid children - returning it instead";
366
+ } | {
367
+ isValid: false;
368
+ reason: InvalidNodeForCodegenReason;
369
+ };
370
+
350
371
  export declare const validateSettings: (obj: unknown) => CodegenSettings;
351
372
 
352
373
  export { }