@animaapp/anima-sdk 0.3.0 → 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.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +27 -6
- package/dist/index.js +3681 -3613
- package/dist/index.js.map +1 -1
- package/example.env +2 -0
- package/package.json +6 -3
- package/tsconfig.json +1 -0
- package/.turbo/turbo-build.log +0 -12
- package/.turbo/turbo-dev.log +0 -0
- package/.turbo/turbo-test.log +0 -21
- package/src/anima.ts +0 -281
- package/src/dataStream.ts +0 -129
- package/src/errors.ts +0 -47
- package/src/figma/figmaError.ts +0 -120
- package/src/figma/index.ts +0 -2
- package/src/figma/utils.ts +0 -73
- package/src/index.ts +0 -7
- package/src/settings.ts +0 -68
- package/src/types.ts +0 -106
- package/src/utils/figma.spec.ts +0 -31
- package/src/utils/figma.ts +0 -59
- package/src/utils/files.ts +0 -95
- package/src/utils/index.ts +0 -2
- package/vite.config.ts +0 -24
package/dist/index.d.ts
CHANGED
|
@@ -58,16 +58,16 @@ 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
|
-
*
|
|
68
|
+
* Codegen errors from the worker
|
|
69
69
|
*/
|
|
70
|
-
export declare type CodegenErrorReason = "Selected node type is not supported" | "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";
|
|
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
|
|
|
72
72
|
export declare type CodegenResult = BaseResult & {
|
|
73
73
|
files: Record<string, {
|
|
@@ -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<
|
|
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 { }
|