@animaapp/anima-sdk 0.3.1 → 0.3.5
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 +38 -17
- package/dist/index.js +3632 -3551
- package/dist/index.js.map +1 -1
- package/example.env +2 -0
- package/package.json +5 -2
- package/tsconfig.json +1 -0
- package/.turbo/turbo-build.log +0 -12
- package/.turbo/turbo-dev.log +0 -23
- 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,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
|
-
*
|
|
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;
|
|
@@ -113,16 +118,13 @@ export declare const createCodegenResponseEventStream: (anima: Anima, params: Ge
|
|
|
113
118
|
export declare const createCodegenStream: (anima: Anima, params: GetCodeParams) => ReadableStream<StreamCodgenMessage>;
|
|
114
119
|
|
|
115
120
|
export declare type FigmaApiError = {
|
|
116
|
-
cause
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
cause: {
|
|
122
|
+
message?: string;
|
|
123
|
+
body: {
|
|
124
|
+
err: string;
|
|
125
|
+
status: number;
|
|
120
126
|
};
|
|
121
127
|
};
|
|
122
|
-
body?: {
|
|
123
|
-
status?: number;
|
|
124
|
-
reason?: string;
|
|
125
|
-
};
|
|
126
128
|
};
|
|
127
129
|
|
|
128
130
|
export declare type FigmaApiErrorType = "FigmaTokenIssue" | "RateLimitExceeded" | "NotFound" | "UnknownFigmaApiException";
|
|
@@ -137,12 +139,15 @@ export declare type FigmaPage = {
|
|
|
137
139
|
export declare class FigmaTokenIssue extends Error {
|
|
138
140
|
fileKey: string;
|
|
139
141
|
reason: string;
|
|
140
|
-
constructor({ fileKey, reason }: {
|
|
142
|
+
constructor({ fileKey, reason, cause, }: {
|
|
141
143
|
fileKey: string;
|
|
142
144
|
reason: string;
|
|
145
|
+
cause?: unknown;
|
|
143
146
|
});
|
|
144
147
|
}
|
|
145
148
|
|
|
149
|
+
export declare const findChildrenNode: (node: FigmaNode, targetNodeId: string) => FigmaNode | null;
|
|
150
|
+
|
|
146
151
|
export declare const formatToFigmaLink: ({ fileKey, nodeId, duplicate, }: {
|
|
147
152
|
fileKey: string;
|
|
148
153
|
nodeId: string;
|
|
@@ -193,9 +198,7 @@ export declare type GetCodeParams = {
|
|
|
193
198
|
|
|
194
199
|
export declare const getFigmaApiErrorType: (error: Error) => FigmaApiErrorType;
|
|
195
200
|
|
|
196
|
-
export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, }: GetFilePagesParams) => Promise<
|
|
197
|
-
|
|
198
|
-
export declare type GetFigmaFileResult = GetFileResponse | undefined;
|
|
201
|
+
export declare const getFigmaFile: ({ fileKey, authToken, figmaRestApi, params, }: GetFilePagesParams) => Promise<GetFileResponse>;
|
|
199
202
|
|
|
200
203
|
export declare const getFileNodes: ({ fileKey, authToken, nodeIds, figmaRestApi, params, }: GetFileNodesParams) => Promise<{
|
|
201
204
|
[key: string]: {
|
|
@@ -241,10 +244,15 @@ export declare const getRelatedScreenFiles: ({ files, screenPath, }: {
|
|
|
241
244
|
screenPath?: string;
|
|
242
245
|
}) => AnimaFiles;
|
|
243
246
|
|
|
244
|
-
|
|
247
|
+
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";
|
|
245
248
|
|
|
246
249
|
export declare const isFigmaTokenIssue: (error: Error) => boolean;
|
|
247
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Check if the pair "design" + "node id" are valid for code generation.
|
|
253
|
+
*/
|
|
254
|
+
export declare const isNodeCodegenCompatible: (design: GetFileResponse, nodeId: string) => ValidateNodeForCodegenResult;
|
|
255
|
+
|
|
248
256
|
export declare const isNotFound: (error: Error) => boolean;
|
|
249
257
|
|
|
250
258
|
export declare const isRateLimitExceeded: (error: Error) => boolean;
|
|
@@ -255,15 +263,17 @@ export declare const isValidFigmaUrl: (figmaLink: string) => [hasCorrectPrefix:
|
|
|
255
263
|
|
|
256
264
|
export declare class NotFound extends Error {
|
|
257
265
|
fileKey: string;
|
|
258
|
-
constructor({ fileKey }: {
|
|
266
|
+
constructor({ fileKey, cause }: {
|
|
259
267
|
fileKey: string;
|
|
268
|
+
cause?: unknown;
|
|
260
269
|
});
|
|
261
270
|
}
|
|
262
271
|
|
|
263
272
|
export declare class RateLimitExceeded extends Error {
|
|
264
273
|
fileKey: string;
|
|
265
|
-
constructor({ fileKey }: {
|
|
274
|
+
constructor({ fileKey, cause }: {
|
|
266
275
|
fileKey: string;
|
|
276
|
+
cause?: unknown;
|
|
267
277
|
});
|
|
268
278
|
}
|
|
269
279
|
|
|
@@ -347,6 +357,17 @@ export declare class UnknownFigmaApiException extends Error {
|
|
|
347
357
|
});
|
|
348
358
|
}
|
|
349
359
|
|
|
360
|
+
declare type ValidateNodeForCodegenResult = {
|
|
361
|
+
isValid: true;
|
|
362
|
+
node: FigmaNode;
|
|
363
|
+
note?: "Selected node is a page with a single valid children - returning it instead";
|
|
364
|
+
} | {
|
|
365
|
+
isValid: false;
|
|
366
|
+
reason: InvalidNodeForCodegenReason;
|
|
367
|
+
};
|
|
368
|
+
|
|
350
369
|
export declare const validateSettings: (obj: unknown) => CodegenSettings;
|
|
351
370
|
|
|
371
|
+
export declare const wrapFigmaApiError: (error: FigmaApiError, fileKey: string) => Error;
|
|
372
|
+
|
|
352
373
|
export { }
|