figma-inspect-cli 0.1.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.
Files changed (430) hide show
  1. package/README.md +156 -0
  2. package/dist/bin/figma-inspect.d.ts +3 -0
  3. package/dist/bin/figma-inspect.d.ts.map +1 -0
  4. package/dist/bin/figma-inspect.js +19 -0
  5. package/dist/bin/figma-inspect.js.map +1 -0
  6. package/dist/cli/errors.d.ts +3 -0
  7. package/dist/cli/errors.d.ts.map +1 -0
  8. package/dist/cli/errors.js +3 -0
  9. package/dist/cli/errors.js.map +1 -0
  10. package/dist/cli/export-component-set.d.ts +21 -0
  11. package/dist/cli/export-component-set.d.ts.map +1 -0
  12. package/dist/cli/export-component-set.js +173 -0
  13. package/dist/cli/export-component-set.js.map +1 -0
  14. package/dist/cli/export-contract.d.ts +20 -0
  15. package/dist/cli/export-contract.d.ts.map +1 -0
  16. package/dist/cli/export-contract.js +48 -0
  17. package/dist/cli/export-contract.js.map +1 -0
  18. package/dist/cli/export-node-contract.d.ts +17 -0
  19. package/dist/cli/export-node-contract.d.ts.map +1 -0
  20. package/dist/cli/export-node-contract.js +93 -0
  21. package/dist/cli/export-node-contract.js.map +1 -0
  22. package/dist/cli/export-result.d.ts +17 -0
  23. package/dist/cli/export-result.d.ts.map +1 -0
  24. package/dist/cli/export-result.js +22 -0
  25. package/dist/cli/export-result.js.map +1 -0
  26. package/dist/cli/export-team-index.d.ts +18 -0
  27. package/dist/cli/export-team-index.d.ts.map +1 -0
  28. package/dist/cli/export-team-index.js +121 -0
  29. package/dist/cli/export-team-index.js.map +1 -0
  30. package/dist/cli/index.d.ts +3 -0
  31. package/dist/cli/index.d.ts.map +1 -0
  32. package/dist/cli/index.js +3 -0
  33. package/dist/cli/index.js.map +1 -0
  34. package/dist/cli/output.d.ts +13 -0
  35. package/dist/cli/output.d.ts.map +1 -0
  36. package/dist/cli/output.js +26 -0
  37. package/dist/cli/output.js.map +1 -0
  38. package/dist/cli/parse-args.d.ts +3 -0
  39. package/dist/cli/parse-args.d.ts.map +1 -0
  40. package/dist/cli/parse-args.js +790 -0
  41. package/dist/cli/parse-args.js.map +1 -0
  42. package/dist/cli/run-cli.d.ts +3 -0
  43. package/dist/cli/run-cli.d.ts.map +1 -0
  44. package/dist/cli/run-cli.js +416 -0
  45. package/dist/cli/run-cli.js.map +1 -0
  46. package/dist/cli/types.d.ts +114 -0
  47. package/dist/cli/types.d.ts.map +1 -0
  48. package/dist/cli/types.js +2 -0
  49. package/dist/cli/types.js.map +1 -0
  50. package/dist/cli/usage.d.ts +2 -0
  51. package/dist/cli/usage.d.ts.map +1 -0
  52. package/dist/cli/usage.js +75 -0
  53. package/dist/cli/usage.js.map +1 -0
  54. package/dist/figma-api/cache/cached-request.d.ts +8 -0
  55. package/dist/figma-api/cache/cached-request.d.ts.map +1 -0
  56. package/dist/figma-api/cache/cached-request.js +100 -0
  57. package/dist/figma-api/cache/cached-request.js.map +1 -0
  58. package/dist/figma-api/cache/constants.d.ts +5 -0
  59. package/dist/figma-api/cache/constants.d.ts.map +1 -0
  60. package/dist/figma-api/cache/constants.js +5 -0
  61. package/dist/figma-api/cache/constants.js.map +1 -0
  62. package/dist/figma-api/cache/extract-metadata.d.ts +3 -0
  63. package/dist/figma-api/cache/extract-metadata.d.ts.map +1 -0
  64. package/dist/figma-api/cache/extract-metadata.js +13 -0
  65. package/dist/figma-api/cache/extract-metadata.js.map +1 -0
  66. package/dist/figma-api/cache/index.d.ts +3 -0
  67. package/dist/figma-api/cache/index.d.ts.map +1 -0
  68. package/dist/figma-api/cache/index.js +3 -0
  69. package/dist/figma-api/cache/index.js.map +1 -0
  70. package/dist/figma-api/cache/store.d.ts +10 -0
  71. package/dist/figma-api/cache/store.d.ts.map +1 -0
  72. package/dist/figma-api/cache/store.js +53 -0
  73. package/dist/figma-api/cache/store.js.map +1 -0
  74. package/dist/figma-api/cache/types.d.ts +20 -0
  75. package/dist/figma-api/cache/types.d.ts.map +1 -0
  76. package/dist/figma-api/cache/types.js +2 -0
  77. package/dist/figma-api/cache/types.js.map +1 -0
  78. package/dist/figma-api/cache/url.d.ts +5 -0
  79. package/dist/figma-api/cache/url.d.ts.map +1 -0
  80. package/dist/figma-api/cache/url.js +20 -0
  81. package/dist/figma-api/cache/url.js.map +1 -0
  82. package/dist/figma-api/constants.d.ts +2 -0
  83. package/dist/figma-api/constants.d.ts.map +1 -0
  84. package/dist/figma-api/constants.js +2 -0
  85. package/dist/figma-api/constants.js.map +1 -0
  86. package/dist/figma-api/fetch-with-retry.d.ts +2 -0
  87. package/dist/figma-api/fetch-with-retry.d.ts.map +1 -0
  88. package/dist/figma-api/fetch-with-retry.js +48 -0
  89. package/dist/figma-api/fetch-with-retry.js.map +1 -0
  90. package/dist/figma-api/figma-api-error.d.ts +4 -0
  91. package/dist/figma-api/figma-api-error.d.ts.map +1 -0
  92. package/dist/figma-api/figma-api-error.js +7 -0
  93. package/dist/figma-api/figma-api-error.js.map +1 -0
  94. package/dist/figma-api/figma-request.d.ts +2 -0
  95. package/dist/figma-api/figma-request.d.ts.map +1 -0
  96. package/dist/figma-api/figma-request.js +21 -0
  97. package/dist/figma-api/figma-request.js.map +1 -0
  98. package/dist/figma-api/format-figma-error.d.ts +2 -0
  99. package/dist/figma-api/format-figma-error.d.ts.map +1 -0
  100. package/dist/figma-api/format-figma-error.js +24 -0
  101. package/dist/figma-api/format-figma-error.js.map +1 -0
  102. package/dist/figma-api/get-component-set.d.ts +4 -0
  103. package/dist/figma-api/get-component-set.d.ts.map +1 -0
  104. package/dist/figma-api/get-component-set.js +8 -0
  105. package/dist/figma-api/get-component-set.js.map +1 -0
  106. package/dist/figma-api/get-file-images.d.ts +4 -0
  107. package/dist/figma-api/get-file-images.d.ts.map +1 -0
  108. package/dist/figma-api/get-file-images.js +45 -0
  109. package/dist/figma-api/get-file-images.js.map +1 -0
  110. package/dist/figma-api/get-file-node.d.ts +3 -0
  111. package/dist/figma-api/get-file-node.d.ts.map +1 -0
  112. package/dist/figma-api/get-file-node.js +8 -0
  113. package/dist/figma-api/get-file-node.js.map +1 -0
  114. package/dist/figma-api/get-file.d.ts +3 -0
  115. package/dist/figma-api/get-file.d.ts.map +1 -0
  116. package/dist/figma-api/get-file.js +6 -0
  117. package/dist/figma-api/get-file.js.map +1 -0
  118. package/dist/figma-api/index.d.ts +11 -0
  119. package/dist/figma-api/index.d.ts.map +1 -0
  120. package/dist/figma-api/index.js +11 -0
  121. package/dist/figma-api/index.js.map +1 -0
  122. package/dist/figma-api/list-file-component-sets.d.ts +4 -0
  123. package/dist/figma-api/list-file-component-sets.d.ts.map +1 -0
  124. package/dist/figma-api/list-file-component-sets.js +8 -0
  125. package/dist/figma-api/list-file-component-sets.js.map +1 -0
  126. package/dist/figma-api/list-file-components.d.ts +5 -0
  127. package/dist/figma-api/list-file-components.d.ts.map +1 -0
  128. package/dist/figma-api/list-file-components.js +13 -0
  129. package/dist/figma-api/list-file-components.js.map +1 -0
  130. package/dist/figma-api/list-file-pages.d.ts +4 -0
  131. package/dist/figma-api/list-file-pages.d.ts.map +1 -0
  132. package/dist/figma-api/list-file-pages.js +10 -0
  133. package/dist/figma-api/list-file-pages.js.map +1 -0
  134. package/dist/figma-api/list-project-files.d.ts +4 -0
  135. package/dist/figma-api/list-project-files.d.ts.map +1 -0
  136. package/dist/figma-api/list-project-files.js +8 -0
  137. package/dist/figma-api/list-project-files.js.map +1 -0
  138. package/dist/figma-api/list-team-component-sets.d.ts +4 -0
  139. package/dist/figma-api/list-team-component-sets.d.ts.map +1 -0
  140. package/dist/figma-api/list-team-component-sets.js +19 -0
  141. package/dist/figma-api/list-team-component-sets.js.map +1 -0
  142. package/dist/figma-api/list-team-project-files.d.ts +4 -0
  143. package/dist/figma-api/list-team-project-files.d.ts.map +1 -0
  144. package/dist/figma-api/list-team-project-files.js +19 -0
  145. package/dist/figma-api/list-team-project-files.js.map +1 -0
  146. package/dist/figma-api/list-team-projects.d.ts +4 -0
  147. package/dist/figma-api/list-team-projects.d.ts.map +1 -0
  148. package/dist/figma-api/list-team-projects.js +8 -0
  149. package/dist/figma-api/list-team-projects.js.map +1 -0
  150. package/dist/figma-api/schemas.d.ts +95 -0
  151. package/dist/figma-api/schemas.d.ts.map +1 -0
  152. package/dist/figma-api/schemas.js +154 -0
  153. package/dist/figma-api/schemas.js.map +1 -0
  154. package/dist/figma-api/types.d.ts +60 -0
  155. package/dist/figma-api/types.d.ts.map +1 -0
  156. package/dist/figma-api/types.js +2 -0
  157. package/dist/figma-api/types.js.map +1 -0
  158. package/dist/inspect/component-set-context.d.ts +11 -0
  159. package/dist/inspect/component-set-context.d.ts.map +1 -0
  160. package/dist/inspect/component-set-context.js +71 -0
  161. package/dist/inspect/component-set-context.js.map +1 -0
  162. package/dist/inspect/component-set-lookup.d.ts +6 -0
  163. package/dist/inspect/component-set-lookup.d.ts.map +1 -0
  164. package/dist/inspect/component-set-lookup.js +40 -0
  165. package/dist/inspect/component-set-lookup.js.map +1 -0
  166. package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts +3 -0
  167. package/dist/inspect/component-set-pseudocode/asset-backed-contract.d.ts.map +1 -0
  168. package/dist/inspect/component-set-pseudocode/asset-backed-contract.js +34 -0
  169. package/dist/inspect/component-set-pseudocode/asset-backed-contract.js.map +1 -0
  170. package/dist/inspect/component-set-pseudocode/assets-contract.d.ts +9 -0
  171. package/dist/inspect/component-set-pseudocode/assets-contract.d.ts.map +1 -0
  172. package/dist/inspect/component-set-pseudocode/assets-contract.js +4 -0
  173. package/dist/inspect/component-set-pseudocode/assets-contract.js.map +1 -0
  174. package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts +17 -0
  175. package/dist/inspect/component-set-pseudocode/baseline-contract.d.ts.map +1 -0
  176. package/dist/inspect/component-set-pseudocode/baseline-contract.js +67 -0
  177. package/dist/inspect/component-set-pseudocode/baseline-contract.js.map +1 -0
  178. package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts +24 -0
  179. package/dist/inspect/component-set-pseudocode/build-pseudocode.d.ts.map +1 -0
  180. package/dist/inspect/component-set-pseudocode/build-pseudocode.js +83 -0
  181. package/dist/inspect/component-set-pseudocode/build-pseudocode.js.map +1 -0
  182. package/dist/inspect/component-set-pseudocode/index.d.ts +2 -0
  183. package/dist/inspect/component-set-pseudocode/index.d.ts.map +1 -0
  184. package/dist/inspect/component-set-pseudocode/index.js +2 -0
  185. package/dist/inspect/component-set-pseudocode/index.js.map +1 -0
  186. package/dist/inspect/component-set-pseudocode/infer.d.ts +4 -0
  187. package/dist/inspect/component-set-pseudocode/infer.d.ts.map +1 -0
  188. package/dist/inspect/component-set-pseudocode/infer.js +426 -0
  189. package/dist/inspect/component-set-pseudocode/infer.js.map +1 -0
  190. package/dist/inspect/component-set-pseudocode/meta-contract.d.ts +27 -0
  191. package/dist/inspect/component-set-pseudocode/meta-contract.d.ts.map +1 -0
  192. package/dist/inspect/component-set-pseudocode/meta-contract.js +136 -0
  193. package/dist/inspect/component-set-pseudocode/meta-contract.js.map +1 -0
  194. package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts +14 -0
  195. package/dist/inspect/component-set-pseudocode/slim-node-guards.d.ts.map +1 -0
  196. package/dist/inspect/component-set-pseudocode/slim-node-guards.js +28 -0
  197. package/dist/inspect/component-set-pseudocode/slim-node-guards.js.map +1 -0
  198. package/dist/inspect/component-set-pseudocode/structure-contract.d.ts +71 -0
  199. package/dist/inspect/component-set-pseudocode/structure-contract.d.ts.map +1 -0
  200. package/dist/inspect/component-set-pseudocode/structure-contract.js +281 -0
  201. package/dist/inspect/component-set-pseudocode/structure-contract.js.map +1 -0
  202. package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts +3 -0
  203. package/dist/inspect/component-set-pseudocode/structure-dsl.d.ts.map +1 -0
  204. package/dist/inspect/component-set-pseudocode/structure-dsl.js +170 -0
  205. package/dist/inspect/component-set-pseudocode/structure-dsl.js.map +1 -0
  206. package/dist/inspect/component-set-pseudocode/types.d.ts +44 -0
  207. package/dist/inspect/component-set-pseudocode/types.d.ts.map +1 -0
  208. package/dist/inspect/component-set-pseudocode/types.js +2 -0
  209. package/dist/inspect/component-set-pseudocode/types.js.map +1 -0
  210. package/dist/inspect/component-set-pseudocode/universal.d.ts +14 -0
  211. package/dist/inspect/component-set-pseudocode/universal.d.ts.map +1 -0
  212. package/dist/inspect/component-set-pseudocode/universal.js +393 -0
  213. package/dist/inspect/component-set-pseudocode/universal.js.map +1 -0
  214. package/dist/inspect/component-set-spec/bound-variables.d.ts +14 -0
  215. package/dist/inspect/component-set-spec/bound-variables.d.ts.map +1 -0
  216. package/dist/inspect/component-set-spec/bound-variables.js +53 -0
  217. package/dist/inspect/component-set-spec/bound-variables.js.map +1 -0
  218. package/dist/inspect/component-set-spec/build-spec.d.ts +9 -0
  219. package/dist/inspect/component-set-spec/build-spec.d.ts.map +1 -0
  220. package/dist/inspect/component-set-spec/build-spec.js +102 -0
  221. package/dist/inspect/component-set-spec/build-spec.js.map +1 -0
  222. package/dist/inspect/component-set-spec/compact-spec.d.ts +3 -0
  223. package/dist/inspect/component-set-spec/compact-spec.d.ts.map +1 -0
  224. package/dist/inspect/component-set-spec/compact-spec.js +357 -0
  225. package/dist/inspect/component-set-spec/compact-spec.js.map +1 -0
  226. package/dist/inspect/component-set-spec/extract-slots.d.ts +5 -0
  227. package/dist/inspect/component-set-spec/extract-slots.d.ts.map +1 -0
  228. package/dist/inspect/component-set-spec/extract-slots.js +57 -0
  229. package/dist/inspect/component-set-spec/extract-slots.js.map +1 -0
  230. package/dist/inspect/component-set-spec/figma-node.d.ts +9 -0
  231. package/dist/inspect/component-set-spec/figma-node.d.ts.map +1 -0
  232. package/dist/inspect/component-set-spec/figma-node.js +31 -0
  233. package/dist/inspect/component-set-spec/figma-node.js.map +1 -0
  234. package/dist/inspect/component-set-spec/index.d.ts +2 -0
  235. package/dist/inspect/component-set-spec/index.d.ts.map +1 -0
  236. package/dist/inspect/component-set-spec/index.js +2 -0
  237. package/dist/inspect/component-set-spec/index.js.map +1 -0
  238. package/dist/inspect/component-set-spec/parse-props.d.ts +9 -0
  239. package/dist/inspect/component-set-spec/parse-props.d.ts.map +1 -0
  240. package/dist/inspect/component-set-spec/parse-props.js +96 -0
  241. package/dist/inspect/component-set-spec/parse-props.js.map +1 -0
  242. package/dist/inspect/component-set-spec/prop-name.d.ts +5 -0
  243. package/dist/inspect/component-set-spec/prop-name.d.ts.map +1 -0
  244. package/dist/inspect/component-set-spec/prop-name.js +26 -0
  245. package/dist/inspect/component-set-spec/prop-name.js.map +1 -0
  246. package/dist/inspect/component-set-spec/resolve-tokens.d.ts +4 -0
  247. package/dist/inspect/component-set-spec/resolve-tokens.d.ts.map +1 -0
  248. package/dist/inspect/component-set-spec/resolve-tokens.js +42 -0
  249. package/dist/inspect/component-set-spec/resolve-tokens.js.map +1 -0
  250. package/dist/inspect/component-set-spec/slim-context.d.ts +6 -0
  251. package/dist/inspect/component-set-spec/slim-context.d.ts.map +1 -0
  252. package/dist/inspect/component-set-spec/slim-context.js +2 -0
  253. package/dist/inspect/component-set-spec/slim-context.js.map +1 -0
  254. package/dist/inspect/component-set-spec/slim-node.d.ts +5 -0
  255. package/dist/inspect/component-set-spec/slim-node.d.ts.map +1 -0
  256. package/dist/inspect/component-set-spec/slim-node.js +393 -0
  257. package/dist/inspect/component-set-spec/slim-node.js.map +1 -0
  258. package/dist/inspect/component-set-spec/slim-text-export.d.ts +8 -0
  259. package/dist/inspect/component-set-spec/slim-text-export.d.ts.map +1 -0
  260. package/dist/inspect/component-set-spec/slim-text-export.js +74 -0
  261. package/dist/inspect/component-set-spec/slim-text-export.js.map +1 -0
  262. package/dist/inspect/component-set-spec/team-component-registry.d.ts +19 -0
  263. package/dist/inspect/component-set-spec/team-component-registry.d.ts.map +1 -0
  264. package/dist/inspect/component-set-spec/team-component-registry.js +96 -0
  265. package/dist/inspect/component-set-spec/team-component-registry.js.map +1 -0
  266. package/dist/inspect/component-set-spec/types.d.ts +127 -0
  267. package/dist/inspect/component-set-spec/types.d.ts.map +1 -0
  268. package/dist/inspect/component-set-spec/types.js +2 -0
  269. package/dist/inspect/component-set-spec/types.js.map +1 -0
  270. package/dist/inspect/component-set-spec/variable-registry.d.ts +8 -0
  271. package/dist/inspect/component-set-spec/variable-registry.d.ts.map +1 -0
  272. package/dist/inspect/component-set-spec/variable-registry.js +74 -0
  273. package/dist/inspect/component-set-spec/variable-registry.js.map +1 -0
  274. package/dist/inspect/component-set-spec/variant-axes.d.ts +2 -0
  275. package/dist/inspect/component-set-spec/variant-axes.d.ts.map +1 -0
  276. package/dist/inspect/component-set-spec/variant-axes.js +14 -0
  277. package/dist/inspect/component-set-spec/variant-axes.js.map +1 -0
  278. package/dist/inspect/contract/contract-format.d.ts +5 -0
  279. package/dist/inspect/contract/contract-format.d.ts.map +1 -0
  280. package/dist/inspect/contract/contract-format.js +26 -0
  281. package/dist/inspect/contract/contract-format.js.map +1 -0
  282. package/dist/inspect/contract/contract-lock.d.ts +75 -0
  283. package/dist/inspect/contract/contract-lock.d.ts.map +1 -0
  284. package/dist/inspect/contract/contract-lock.js +326 -0
  285. package/dist/inspect/contract/contract-lock.js.map +1 -0
  286. package/dist/inspect/contract/contract-schema.d.ts +51 -0
  287. package/dist/inspect/contract/contract-schema.d.ts.map +1 -0
  288. package/dist/inspect/contract/contract-schema.js +130 -0
  289. package/dist/inspect/contract/contract-schema.js.map +1 -0
  290. package/dist/inspect/contract/fingerprint.d.ts +9 -0
  291. package/dist/inspect/contract/fingerprint.d.ts.map +1 -0
  292. package/dist/inspect/contract/fingerprint.js +301 -0
  293. package/dist/inspect/contract/fingerprint.js.map +1 -0
  294. package/dist/inspect/contract/lock-metadata.d.ts +30 -0
  295. package/dist/inspect/contract/lock-metadata.d.ts.map +1 -0
  296. package/dist/inspect/contract/lock-metadata.js +101 -0
  297. package/dist/inspect/contract/lock-metadata.js.map +1 -0
  298. package/dist/inspect/contract/stable-stringify.d.ts +2 -0
  299. package/dist/inspect/contract/stable-stringify.d.ts.map +1 -0
  300. package/dist/inspect/contract/stable-stringify.js +14 -0
  301. package/dist/inspect/contract/stable-stringify.js.map +1 -0
  302. package/dist/inspect/contract/verify-component-contract.d.ts +19 -0
  303. package/dist/inspect/contract/verify-component-contract.d.ts.map +1 -0
  304. package/dist/inspect/contract/verify-component-contract.js +126 -0
  305. package/dist/inspect/contract/verify-component-contract.js.map +1 -0
  306. package/dist/inspect/errors.d.ts +4 -0
  307. package/dist/inspect/errors.d.ts.map +1 -0
  308. package/dist/inspect/errors.js +7 -0
  309. package/dist/inspect/errors.js.map +1 -0
  310. package/dist/inspect/export/assert-asset-exportable.d.ts +3 -0
  311. package/dist/inspect/export/assert-asset-exportable.d.ts.map +1 -0
  312. package/dist/inspect/export/assert-asset-exportable.js +45 -0
  313. package/dist/inspect/export/assert-asset-exportable.js.map +1 -0
  314. package/dist/inspect/export/export-nested-assets.d.ts +94 -0
  315. package/dist/inspect/export/export-nested-assets.d.ts.map +1 -0
  316. package/dist/inspect/export/export-nested-assets.js +333 -0
  317. package/dist/inspect/export/export-nested-assets.js.map +1 -0
  318. package/dist/inspect/export/export-node-preview.d.ts +24 -0
  319. package/dist/inspect/export/export-node-preview.d.ts.map +1 -0
  320. package/dist/inspect/export/export-node-preview.js +34 -0
  321. package/dist/inspect/export/export-node-preview.js.map +1 -0
  322. package/dist/inspect/export/export-variant-assets.d.ts +18 -0
  323. package/dist/inspect/export/export-variant-assets.d.ts.map +1 -0
  324. package/dist/inspect/export/export-variant-assets.js +127 -0
  325. package/dist/inspect/export/export-variant-assets.js.map +1 -0
  326. package/dist/inspect/export/normalize-exported-svg.d.ts +2 -0
  327. package/dist/inspect/export/normalize-exported-svg.d.ts.map +1 -0
  328. package/dist/inspect/export/normalize-exported-svg.js +15 -0
  329. package/dist/inspect/export/normalize-exported-svg.js.map +1 -0
  330. package/dist/inspect/export/rendered-image-bytes.d.ts +4 -0
  331. package/dist/inspect/export/rendered-image-bytes.d.ts.map +1 -0
  332. package/dist/inspect/export/rendered-image-bytes.js +24 -0
  333. package/dist/inspect/export/rendered-image-bytes.js.map +1 -0
  334. package/dist/inspect/export-contract-target.d.ts +7 -0
  335. package/dist/inspect/export-contract-target.d.ts.map +1 -0
  336. package/dist/inspect/export-contract-target.js +33 -0
  337. package/dist/inspect/export-contract-target.js.map +1 -0
  338. package/dist/inspect/fetch-file-entry.d.ts +4 -0
  339. package/dist/inspect/fetch-file-entry.d.ts.map +1 -0
  340. package/dist/inspect/fetch-file-entry.js +7 -0
  341. package/dist/inspect/fetch-file-entry.js.map +1 -0
  342. package/dist/inspect/fetch-file-node-entry.d.ts +4 -0
  343. package/dist/inspect/fetch-file-node-entry.d.ts.map +1 -0
  344. package/dist/inspect/fetch-file-node-entry.js +7 -0
  345. package/dist/inspect/fetch-file-node-entry.js.map +1 -0
  346. package/dist/inspect/figma-node-url.d.ts +3 -0
  347. package/dist/inspect/figma-node-url.d.ts.map +1 -0
  348. package/dist/inspect/figma-node-url.js +30 -0
  349. package/dist/inspect/figma-node-url.js.map +1 -0
  350. package/dist/inspect/get-node-component-set.d.ts +5 -0
  351. package/dist/inspect/get-node-component-set.d.ts.map +1 -0
  352. package/dist/inspect/get-node-component-set.js +10 -0
  353. package/dist/inspect/get-node-component-set.js.map +1 -0
  354. package/dist/inspect/index.d.ts +17 -0
  355. package/dist/inspect/index.d.ts.map +1 -0
  356. package/dist/inspect/index.js +17 -0
  357. package/dist/inspect/index.js.map +1 -0
  358. package/dist/inspect/list-all-component-sets.d.ts +3 -0
  359. package/dist/inspect/list-all-component-sets.d.ts.map +1 -0
  360. package/dist/inspect/list-all-component-sets.js +27 -0
  361. package/dist/inspect/list-all-component-sets.js.map +1 -0
  362. package/dist/inspect/list-component-set-properties.d.ts +4 -0
  363. package/dist/inspect/list-component-set-properties.d.ts.map +1 -0
  364. package/dist/inspect/list-component-set-properties.js +73 -0
  365. package/dist/inspect/list-component-set-properties.js.map +1 -0
  366. package/dist/inspect/node-contract/build-node-contract.d.ts +12 -0
  367. package/dist/inspect/node-contract/build-node-contract.d.ts.map +1 -0
  368. package/dist/inspect/node-contract/build-node-contract.js +212 -0
  369. package/dist/inspect/node-contract/build-node-contract.js.map +1 -0
  370. package/dist/inspect/node-contract/dependencies.d.ts +5 -0
  371. package/dist/inspect/node-contract/dependencies.d.ts.map +1 -0
  372. package/dist/inspect/node-contract/dependencies.js +84 -0
  373. package/dist/inspect/node-contract/dependencies.js.map +1 -0
  374. package/dist/inspect/node-contract/index.d.ts +6 -0
  375. package/dist/inspect/node-contract/index.d.ts.map +1 -0
  376. package/dist/inspect/node-contract/index.js +6 -0
  377. package/dist/inspect/node-contract/index.js.map +1 -0
  378. package/dist/inspect/node-contract/node-kind.d.ts +9 -0
  379. package/dist/inspect/node-contract/node-kind.d.ts.map +1 -0
  380. package/dist/inspect/node-contract/node-kind.js +31 -0
  381. package/dist/inspect/node-contract/node-kind.js.map +1 -0
  382. package/dist/inspect/node-contract/node-lock.d.ts +6 -0
  383. package/dist/inspect/node-contract/node-lock.d.ts.map +1 -0
  384. package/dist/inspect/node-contract/node-lock.js +181 -0
  385. package/dist/inspect/node-contract/node-lock.js.map +1 -0
  386. package/dist/inspect/node-contract/node-schema.d.ts +14 -0
  387. package/dist/inspect/node-contract/node-schema.d.ts.map +1 -0
  388. package/dist/inspect/node-contract/node-schema.js +137 -0
  389. package/dist/inspect/node-contract/node-schema.js.map +1 -0
  390. package/dist/inspect/node-contract/paths.d.ts +10 -0
  391. package/dist/inspect/node-contract/paths.d.ts.map +1 -0
  392. package/dist/inspect/node-contract/paths.js +29 -0
  393. package/dist/inspect/node-contract/paths.js.map +1 -0
  394. package/dist/inspect/node-contract/tokens.d.ts +4 -0
  395. package/dist/inspect/node-contract/tokens.d.ts.map +1 -0
  396. package/dist/inspect/node-contract/tokens.js +30 -0
  397. package/dist/inspect/node-contract/tokens.js.map +1 -0
  398. package/dist/inspect/node-contract/types.d.ts +84 -0
  399. package/dist/inspect/node-contract/types.d.ts.map +1 -0
  400. package/dist/inspect/node-contract/types.js +2 -0
  401. package/dist/inspect/node-contract/types.js.map +1 -0
  402. package/dist/inspect/node-contract/verify-node-contract.d.ts +20 -0
  403. package/dist/inspect/node-contract/verify-node-contract.d.ts.map +1 -0
  404. package/dist/inspect/node-contract/verify-node-contract.js +131 -0
  405. package/dist/inspect/node-contract/verify-node-contract.js.map +1 -0
  406. package/dist/inspect/resolve-team-component-set.d.ts +14 -0
  407. package/dist/inspect/resolve-team-component-set.d.ts.map +1 -0
  408. package/dist/inspect/resolve-team-component-set.js +77 -0
  409. package/dist/inspect/resolve-team-component-set.js.map +1 -0
  410. package/dist/inspect/schemas.d.ts +37 -0
  411. package/dist/inspect/schemas.d.ts.map +1 -0
  412. package/dist/inspect/schemas.js +79 -0
  413. package/dist/inspect/schemas.js.map +1 -0
  414. package/dist/inspect/team-index.d.ts +76 -0
  415. package/dist/inspect/team-index.d.ts.map +1 -0
  416. package/dist/inspect/team-index.js +361 -0
  417. package/dist/inspect/team-index.js.map +1 -0
  418. package/dist/inspect/types.d.ts +46 -0
  419. package/dist/inspect/types.d.ts.map +1 -0
  420. package/dist/inspect/types.js +2 -0
  421. package/dist/inspect/types.js.map +1 -0
  422. package/dist/test/fixtures.d.ts +3 -0
  423. package/dist/test/fixtures.d.ts.map +1 -0
  424. package/dist/test/fixtures.js +6 -0
  425. package/dist/test/fixtures.js.map +1 -0
  426. package/dist/zod/parse-valid-entries.d.ts +4 -0
  427. package/dist/zod/parse-valid-entries.d.ts.map +1 -0
  428. package/dist/zod/parse-valid-entries.js +20 -0
  429. package/dist/zod/parse-valid-entries.js.map +1 -0
  430. package/package.json +39 -0
@@ -0,0 +1,2 @@
1
+ export declare const usage = "Usage:\n figma-inspect --list-team-projects [--json]\n figma-inspect --list-project-files --project-id <id> [--json]\n figma-inspect --list-team-project-files [--json]\n figma-inspect --export-team-index --output-dir <dir> [--screen-similarity-threshold <number>] [--screen-size-tolerance <px>]\n figma-inspect --list-team-component-sets [--json]\n figma-inspect --list-file-pages --file-key <key> [--json]\n figma-inspect --list-file-component-sets --file-key <key> [--json]\n figma-inspect --inspect-component-set-properties (--url <figma-url> | --file-key <key> --node-id <id> (--component-set-key <key> | --component-set-name <name>)) [--json]\n figma-inspect --inspect-component-set (--url <figma-url> | --file-key <key> --node-id <id> (--component-set-key <key> | --component-set-name <name>)) [--json]\n figma-inspect --inspect-team-component-set (--component-set-key <key> | --component-set-name <name>) [--json]\n figma-inspect --inspect-file-node (--url <figma-url> | --file-key <key> --node-id <id>) [--json]\n figma-inspect --build-component-set-spec --input <path> --variables <path> [--team-components <path>] [--json]\n figma-inspect --build-component-set-pseudocode --input <path> --variables <path> [--output-dir <dir>] [--team-components <path>] [--json]\n figma-inspect --verify-component-contract --contract-dir <dir> [--component-name <name>] [--json]\n figma-inspect --verify-node-contract --contract-dir <dir> [--node-name <name>] [--json]\n figma-inspect --export-contract --output-dir <dir> --variables <path> (--url <figma-url> | --file-key <key> --node-id <id>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-assets] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]\n figma-inspect --export-component-set --output-dir <dir> --variables <path> (--url <figma-url> | --component-set-key <key> | --component-set-name <name>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-assets] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]\n figma-inspect --export-node-contract --output-dir <dir> --variables <path> (--url <figma-url> | --file-key <key> --node-id <id>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]\n\nEnvironment:\n FIGMA_API_TOKEN Figma personal access token (required for --verify-component-contract, --verify-node-contract, and all API commands below)\n FIGMA_TEAM_ID Figma team id (required for team-scoped commands, --export-team-index, --export-component-set, and --export-contract when the target is a COMPONENT_SET)\n FIGMA_CACHE Set to 0 to disable the on-disk response cache (enabled by default)\n\nOptions:\n --list-team-projects List projects in a Figma team\n --list-project-files List files in a Figma project\n --list-team-project-files List files in all team projects\n --export-team-index Write a deterministic team inventory index as YAML: team.index.yaml plus one sibling *.index.yaml per Figma file\n --list-team-component-sets List published component sets in a Figma team\n --list-file-pages List pages in a Figma file\n --list-file-component-sets List component sets in a Figma file\n --inspect-component-set-properties List nested component sets exposed in a component set\n --inspect-component-set Print raw YAML for a COMPONENT_SET node in a file tree\n --inspect-team-component-set Find a published component set by name or key and print its raw YAML\n --inspect-file-node Print raw YAML for a file node\n --build-component-set-spec Build an AI-friendly spec from a local COMPONENT_SET JSON file; prints YAML by default\n --build-component-set-pseudocode Build component contracts from a local COMPONENT_SET JSON file; writes <ComponentName>.component-set.{visuals,geometry,meta}.yaml and <ComponentName>.component-set.structure.dsl\n --verify-component-contract Compare lock files to live Figma via the API; validates local contract schema\n --verify-node-contract Compare frame/component node lock files to live Figma via the API; validates local node contract schema\n --export-contract Export contract files for a Figma URL or node ref; auto-detects COMPONENT_SET, FRAME, or standalone COMPONENT\n --export-component-set Export component contract files for a published team component set as YAML; writes <ComponentName>.component-set.lock.yaml; with --export-assets also writes <ComponentName>.assets/*.svg and stores asset paths in meta.yaml\n --export-node-contract Export FRAME or standalone COMPONENT node contract files as YAML; writes <Name>.frame.* or <Name>.component.* plus lock\n --export-preview Export one root node preview image next to contract artifacts; writes <Name>.<node-type>.preview.png by default\n --preview-format <format> Preview export format; supports png or svg (default: png)\n --preview-scale <scale> PNG preview scale for the Figma Images API (default: 2)\n --export-assets Export one SVG asset per component variant via the Figma Images API (with --export-component-set or --export-contract targeting a COMPONENT_SET; variant props only, no TEXT layers)\n --export-nested-assets Export selected nested nodes as sidecar assets and write <Name>.<kind>.nested-assets.yaml\n --asset-node-id <id> Nested asset node id to export; repeatable; URL-style ids such as 208-43935 are accepted\n --asset-include-regex <regex> Select nested asset nodes whose name or path matches the regex\n --asset-node-types <csv> Comma-separated Figma node types allowed for regex selection (default: common visual nodes)\n --asset-max <number> Maximum nested asset nodes to export after selection\n --asset-format <format> Asset export format; svg for --export-assets, svg or png for --export-nested-assets (repeatable; default: svg)\n --asset-scale <scale> PNG nested asset scale for the Figma Images API (default: 2)\n --screen-similarity-threshold <number> Screen similarity threshold for --export-team-index (default: 0.9)\n --screen-size-tolerance <px> Screen frame size tolerance in pixels for --export-team-index (default: 2)\n --input <path> Input JSON file path (required with --build-component-set-spec and --build-component-set-pseudocode)\n --output-dir <dir> Output directory (optional with --build-component-set-pseudocode; defaults to the input file directory)\n --contract-dir <dir> Contract directory (required with --verify-component-contract and --verify-node-contract)\n --component-name <name> Component name (optional with --verify-component-contract; defaults to all lock files in --contract-dir)\n --node-name <name> Node contract base name (optional with --verify-node-contract; defaults to all frame/component lock files in --contract-dir)\n --output-dir <dir> Output directory (required with export commands and --export-team-index)\n --variables <path> Variables export JSON (required with --build-component-set-spec, --build-component-set-pseudocode, and export commands)\n --team-components <path> Team component sets JSON (optional with --build-component-set-spec and --build-component-set-pseudocode)\n --url <figma-url> Figma node URL; supports /design/<fileKey>/... and /file/<fileKey>/... with node-id\n --project-id <id> Project id (required with --list-project-files)\n --file-key <key> File key (required with --list-file-pages and --list-file-component-sets; also used with node inspect commands unless --url is set)\n --node-id <id> Node id (required with node inspect commands unless --url is set)\n --component-set-key <key> Component set key (required with --inspect-component-set-properties and --inspect-component-set unless --component-set-name is set; also works with --inspect-team-component-set and --export-component-set)\n --component-set-name <n> Component set name (required with --inspect-component-set-properties and --inspect-component-set unless --component-set-key is set; also works with --inspect-team-component-set and --export-component-set)\n --json Print or write JSON instead of the default YAML\n --help, -h Show this help message\n";
2
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK,wwRAyEjB,CAAC"}
@@ -0,0 +1,75 @@
1
+ export const usage = `Usage:
2
+ figma-inspect --list-team-projects [--json]
3
+ figma-inspect --list-project-files --project-id <id> [--json]
4
+ figma-inspect --list-team-project-files [--json]
5
+ figma-inspect --export-team-index --output-dir <dir> [--screen-similarity-threshold <number>] [--screen-size-tolerance <px>]
6
+ figma-inspect --list-team-component-sets [--json]
7
+ figma-inspect --list-file-pages --file-key <key> [--json]
8
+ figma-inspect --list-file-component-sets --file-key <key> [--json]
9
+ figma-inspect --inspect-component-set-properties (--url <figma-url> | --file-key <key> --node-id <id> (--component-set-key <key> | --component-set-name <name>)) [--json]
10
+ figma-inspect --inspect-component-set (--url <figma-url> | --file-key <key> --node-id <id> (--component-set-key <key> | --component-set-name <name>)) [--json]
11
+ figma-inspect --inspect-team-component-set (--component-set-key <key> | --component-set-name <name>) [--json]
12
+ figma-inspect --inspect-file-node (--url <figma-url> | --file-key <key> --node-id <id>) [--json]
13
+ figma-inspect --build-component-set-spec --input <path> --variables <path> [--team-components <path>] [--json]
14
+ figma-inspect --build-component-set-pseudocode --input <path> --variables <path> [--output-dir <dir>] [--team-components <path>] [--json]
15
+ figma-inspect --verify-component-contract --contract-dir <dir> [--component-name <name>] [--json]
16
+ figma-inspect --verify-node-contract --contract-dir <dir> [--node-name <name>] [--json]
17
+ figma-inspect --export-contract --output-dir <dir> --variables <path> (--url <figma-url> | --file-key <key> --node-id <id>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-assets] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]
18
+ figma-inspect --export-component-set --output-dir <dir> --variables <path> (--url <figma-url> | --component-set-key <key> | --component-set-name <name>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-assets] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]
19
+ figma-inspect --export-node-contract --output-dir <dir> --variables <path> (--url <figma-url> | --file-key <key> --node-id <id>) [--export-preview] [--preview-format png|svg] [--preview-scale <scale>] [--export-nested-assets (--asset-node-id <id> | --asset-include-regex <regex>)] [--asset-format svg|png] [--asset-scale <scale>] [--asset-node-types <csv>] [--asset-max <number>] [--json]
20
+
21
+ Environment:
22
+ FIGMA_API_TOKEN Figma personal access token (required for --verify-component-contract, --verify-node-contract, and all API commands below)
23
+ FIGMA_TEAM_ID Figma team id (required for team-scoped commands, --export-team-index, --export-component-set, and --export-contract when the target is a COMPONENT_SET)
24
+ FIGMA_CACHE Set to 0 to disable the on-disk response cache (enabled by default)
25
+
26
+ Options:
27
+ --list-team-projects List projects in a Figma team
28
+ --list-project-files List files in a Figma project
29
+ --list-team-project-files List files in all team projects
30
+ --export-team-index Write a deterministic team inventory index as YAML: team.index.yaml plus one sibling *.index.yaml per Figma file
31
+ --list-team-component-sets List published component sets in a Figma team
32
+ --list-file-pages List pages in a Figma file
33
+ --list-file-component-sets List component sets in a Figma file
34
+ --inspect-component-set-properties List nested component sets exposed in a component set
35
+ --inspect-component-set Print raw YAML for a COMPONENT_SET node in a file tree
36
+ --inspect-team-component-set Find a published component set by name or key and print its raw YAML
37
+ --inspect-file-node Print raw YAML for a file node
38
+ --build-component-set-spec Build an AI-friendly spec from a local COMPONENT_SET JSON file; prints YAML by default
39
+ --build-component-set-pseudocode Build component contracts from a local COMPONENT_SET JSON file; writes <ComponentName>.component-set.{visuals,geometry,meta}.yaml and <ComponentName>.component-set.structure.dsl
40
+ --verify-component-contract Compare lock files to live Figma via the API; validates local contract schema
41
+ --verify-node-contract Compare frame/component node lock files to live Figma via the API; validates local node contract schema
42
+ --export-contract Export contract files for a Figma URL or node ref; auto-detects COMPONENT_SET, FRAME, or standalone COMPONENT
43
+ --export-component-set Export component contract files for a published team component set as YAML; writes <ComponentName>.component-set.lock.yaml; with --export-assets also writes <ComponentName>.assets/*.svg and stores asset paths in meta.yaml
44
+ --export-node-contract Export FRAME or standalone COMPONENT node contract files as YAML; writes <Name>.frame.* or <Name>.component.* plus lock
45
+ --export-preview Export one root node preview image next to contract artifacts; writes <Name>.<node-type>.preview.png by default
46
+ --preview-format <format> Preview export format; supports png or svg (default: png)
47
+ --preview-scale <scale> PNG preview scale for the Figma Images API (default: 2)
48
+ --export-assets Export one SVG asset per component variant via the Figma Images API (with --export-component-set or --export-contract targeting a COMPONENT_SET; variant props only, no TEXT layers)
49
+ --export-nested-assets Export selected nested nodes as sidecar assets and write <Name>.<kind>.nested-assets.yaml
50
+ --asset-node-id <id> Nested asset node id to export; repeatable; URL-style ids such as 208-43935 are accepted
51
+ --asset-include-regex <regex> Select nested asset nodes whose name or path matches the regex
52
+ --asset-node-types <csv> Comma-separated Figma node types allowed for regex selection (default: common visual nodes)
53
+ --asset-max <number> Maximum nested asset nodes to export after selection
54
+ --asset-format <format> Asset export format; svg for --export-assets, svg or png for --export-nested-assets (repeatable; default: svg)
55
+ --asset-scale <scale> PNG nested asset scale for the Figma Images API (default: 2)
56
+ --screen-similarity-threshold <number> Screen similarity threshold for --export-team-index (default: 0.9)
57
+ --screen-size-tolerance <px> Screen frame size tolerance in pixels for --export-team-index (default: 2)
58
+ --input <path> Input JSON file path (required with --build-component-set-spec and --build-component-set-pseudocode)
59
+ --output-dir <dir> Output directory (optional with --build-component-set-pseudocode; defaults to the input file directory)
60
+ --contract-dir <dir> Contract directory (required with --verify-component-contract and --verify-node-contract)
61
+ --component-name <name> Component name (optional with --verify-component-contract; defaults to all lock files in --contract-dir)
62
+ --node-name <name> Node contract base name (optional with --verify-node-contract; defaults to all frame/component lock files in --contract-dir)
63
+ --output-dir <dir> Output directory (required with export commands and --export-team-index)
64
+ --variables <path> Variables export JSON (required with --build-component-set-spec, --build-component-set-pseudocode, and export commands)
65
+ --team-components <path> Team component sets JSON (optional with --build-component-set-spec and --build-component-set-pseudocode)
66
+ --url <figma-url> Figma node URL; supports /design/<fileKey>/... and /file/<fileKey>/... with node-id
67
+ --project-id <id> Project id (required with --list-project-files)
68
+ --file-key <key> File key (required with --list-file-pages and --list-file-component-sets; also used with node inspect commands unless --url is set)
69
+ --node-id <id> Node id (required with node inspect commands unless --url is set)
70
+ --component-set-key <key> Component set key (required with --inspect-component-set-properties and --inspect-component-set unless --component-set-name is set; also works with --inspect-team-component-set and --export-component-set)
71
+ --component-set-name <n> Component set name (required with --inspect-component-set-properties and --inspect-component-set unless --component-set-key is set; also works with --inspect-team-component-set and --export-component-set)
72
+ --json Print or write JSON instead of the default YAML
73
+ --help, -h Show this help message
74
+ `;
75
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/cli/usage.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyEpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare class CachedFigmaRequest {
2
+ private readonly token;
3
+ private readonly store;
4
+ constructor(token: string);
5
+ request(url: string | URL, fetchImpl: typeof fetch): Promise<unknown>;
6
+ private resolveCurrentFileVersion;
7
+ }
8
+ //# sourceMappingURL=cached-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cached-request.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/cached-request.ts"],"names":[],"mappings":"AAsDA,qBAAa,kBAAkB;IAGjB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;gBAEX,KAAK,EAAE,MAAM;IAIpC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,SAAS,EAAE,OAAO,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;YAwC7D,yBAAyB;CAyCxC"}
@@ -0,0 +1,100 @@
1
+ import { fetchFigmaResponse } from "../fetch-with-retry.js";
2
+ import { FigmaApiError } from "../figma-api-error.js";
3
+ import { formatFigmaError } from "../format-figma-error.js";
4
+ import { ENTRY_TTL_MS, FILE_VERSION_MAX_AGE_MS } from "./constants.js";
5
+ import { extractVersionMetadata } from "./extract-metadata.js";
6
+ import { FigmaCacheStore } from "./store.js";
7
+ import { buildFileProbeUrl, extractFileKey, normalizeRequestUrl, } from "./url.js";
8
+ function isExpired(cachedAt, ttlMs, now = Date.now()) {
9
+ return now - cachedAt >= ttlMs;
10
+ }
11
+ async function fetchFromNetwork(url, token, fetchImpl) {
12
+ const response = await fetchFigmaResponse(url, token, fetchImpl);
13
+ if (!response.ok) {
14
+ throw new FigmaApiError(await formatFigmaError(response));
15
+ }
16
+ const body = await response.json();
17
+ const metadata = extractVersionMetadata(body);
18
+ return {
19
+ body,
20
+ version: metadata.version,
21
+ lastModified: metadata.lastModified,
22
+ etag: response.headers.get("etag") ?? undefined,
23
+ };
24
+ }
25
+ function buildCacheEntry(url, fetched, cachedAt = Date.now()) {
26
+ return {
27
+ url,
28
+ cachedAt,
29
+ version: fetched.version,
30
+ lastModified: fetched.lastModified,
31
+ etag: fetched.etag,
32
+ body: fetched.body,
33
+ };
34
+ }
35
+ export class CachedFigmaRequest {
36
+ token;
37
+ store;
38
+ constructor(token) {
39
+ this.token = token;
40
+ this.store = new FigmaCacheStore(token);
41
+ }
42
+ async request(url, fetchImpl) {
43
+ const canonicalUrl = normalizeRequestUrl(url);
44
+ const entry = await this.store.readEntry(canonicalUrl);
45
+ if (entry && !isExpired(entry.cachedAt, ENTRY_TTL_MS)) {
46
+ return entry.body;
47
+ }
48
+ const fileKey = extractFileKey(canonicalUrl);
49
+ if (entry && fileKey && entry.version !== undefined) {
50
+ const currentVersion = await this.resolveCurrentFileVersion(fileKey, fetchImpl);
51
+ if (currentVersion === entry.version) {
52
+ await this.store.writeEntry(canonicalUrl, {
53
+ ...entry,
54
+ cachedAt: Date.now(),
55
+ });
56
+ return entry.body;
57
+ }
58
+ }
59
+ const fetched = await fetchFromNetwork(url, this.token, fetchImpl);
60
+ await this.store.writeEntry(canonicalUrl, buildCacheEntry(canonicalUrl, fetched));
61
+ if (fileKey && fetched.version !== undefined) {
62
+ await this.store.writeFileVersion(fileKey, {
63
+ version: fetched.version,
64
+ lastModified: fetched.lastModified,
65
+ checkedAt: Date.now(),
66
+ });
67
+ }
68
+ return fetched.body;
69
+ }
70
+ async resolveCurrentFileVersion(fileKey, fetchImpl) {
71
+ const fileVersion = await this.store.readFileVersion(fileKey);
72
+ if (fileVersion &&
73
+ !isExpired(fileVersion.checkedAt, FILE_VERSION_MAX_AGE_MS)) {
74
+ return fileVersion.version;
75
+ }
76
+ const probeUrl = buildFileProbeUrl(fileKey);
77
+ const probeEntry = await this.store.readEntry(probeUrl);
78
+ if (probeEntry?.version !== undefined &&
79
+ !isExpired(probeEntry.cachedAt, ENTRY_TTL_MS)) {
80
+ await this.store.writeFileVersion(fileKey, {
81
+ version: probeEntry.version,
82
+ lastModified: probeEntry.lastModified,
83
+ checkedAt: Date.now(),
84
+ });
85
+ return probeEntry.version;
86
+ }
87
+ const fetched = await fetchFromNetwork(probeUrl, this.token, fetchImpl);
88
+ await this.store.writeEntry(probeUrl, buildCacheEntry(probeUrl, fetched));
89
+ if (fetched.version === undefined) {
90
+ return undefined;
91
+ }
92
+ await this.store.writeFileVersion(fileKey, {
93
+ version: fetched.version,
94
+ lastModified: fetched.lastModified,
95
+ checkedAt: Date.now(),
96
+ });
97
+ return fetched.version;
98
+ }
99
+ }
100
+ //# sourceMappingURL=cached-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cached-request.js","sourceRoot":"","sources":["../../../src/figma-api/cache/cached-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,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KAAK,EAAE,SAAS,CAAC,CAAC;QACxE,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAE1E,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAClC,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE;YACzC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,OAAO,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export declare const CACHE_DIR_NAME = "figma-inspect-cli-cache";
2
+ export declare const ENTRY_TTL_MS: number;
3
+ export declare const FILE_VERSION_MAX_AGE_MS: number;
4
+ export declare const CACHE_DISABLED_ENV = "FIGMA_CACHE";
5
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD,eAAO,MAAM,YAAY,QAAiB,CAAC;AAE3C,eAAO,MAAM,uBAAuB,QAAgB,CAAC;AAErD,eAAO,MAAM,kBAAkB,gBAAgB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const CACHE_DIR_NAME = "figma-inspect-cli-cache";
2
+ export const ENTRY_TTL_MS = 60 * 60 * 1000;
3
+ export const FILE_VERSION_MAX_AGE_MS = 5 * 60 * 1000;
4
+ export const CACHE_DISABLED_ENV = "FIGMA_CACHE";
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/figma-api/cache/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAExD,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3C,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,MAAM,CAAC,MAAM,kBAAkB,GAAG,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FetchedResponse } from "./types.js";
2
+ export declare function extractVersionMetadata(body: unknown): Pick<FetchedResponse, "version" | "lastModified">;
3
+ //# sourceMappingURL=extract-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-metadata.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/extract-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,OAAO,GACZ,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,cAAc,CAAC,CAenD"}
@@ -0,0 +1,13 @@
1
+ export function extractVersionMetadata(body) {
2
+ if (typeof body !== "object" || body === null) {
3
+ return {};
4
+ }
5
+ const record = body;
6
+ return {
7
+ version: record.version === undefined || record.version === null
8
+ ? undefined
9
+ : String(record.version),
10
+ lastModified: typeof record.lastModified === "string" ? record.lastModified : undefined,
11
+ };
12
+ }
13
+ //# sourceMappingURL=extract-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-metadata.js","sourceRoot":"","sources":["../../../src/figma-api/cache/extract-metadata.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,sBAAsB,CACpC,IAAa;IAEb,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAG,IAA+B,CAAC;IAE/C,OAAO;QACL,OAAO,EACL,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI;YACrD,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QAC5B,YAAY,EACV,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;KAC5E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CachedFigmaRequest } from "./cached-request.js";
2
+ export { CACHE_DISABLED_ENV } from "./constants.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { CachedFigmaRequest } from "./cached-request.js";
2
+ export { CACHE_DISABLED_ENV } from "./constants.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/figma-api/cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { CacheEntry, FileVersionEntry } from "./types.js";
2
+ export declare class FigmaCacheStore {
3
+ private readonly cacheRoot;
4
+ constructor(token: string);
5
+ readEntry(url: string): Promise<CacheEntry | undefined>;
6
+ writeEntry(url: string, entry: CacheEntry): Promise<void>;
7
+ readFileVersion(fileKey: string): Promise<FileVersionEntry | undefined>;
8
+ writeFileVersion(fileKey: string, entry: FileVersionEntry): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/store.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAuC/D,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,KAAK,EAAE,MAAM;IAIzB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAIvD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAMvE,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1E"}
@@ -0,0 +1,53 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { CACHE_DIR_NAME } from "./constants.js";
6
+ import { hashValue, normalizeRequestUrl } from "./url.js";
7
+ function getCacheRoot(token) {
8
+ const tokenHash = createHash("sha256")
9
+ .update(token)
10
+ .digest("hex")
11
+ .slice(0, 16);
12
+ return join(tmpdir(), CACHE_DIR_NAME, tokenHash);
13
+ }
14
+ function entryPath(cacheRoot, url) {
15
+ return join(cacheRoot, "entries", `${hashValue(normalizeRequestUrl(url))}.json`);
16
+ }
17
+ function fileVersionPath(cacheRoot, fileKey) {
18
+ return join(cacheRoot, "files", `${hashValue(fileKey)}.json`);
19
+ }
20
+ async function writeJsonAtomic(path, value) {
21
+ await mkdir(join(path, ".."), { recursive: true });
22
+ const tempPath = `${path}.${process.pid}.tmp`;
23
+ await writeFile(tempPath, `${JSON.stringify(value)}\n`, "utf8");
24
+ await rename(tempPath, path);
25
+ }
26
+ async function readJsonFile(path) {
27
+ try {
28
+ const raw = await readFile(path, "utf8");
29
+ return JSON.parse(raw);
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ }
35
+ export class FigmaCacheStore {
36
+ cacheRoot;
37
+ constructor(token) {
38
+ this.cacheRoot = getCacheRoot(token);
39
+ }
40
+ readEntry(url) {
41
+ return readJsonFile(entryPath(this.cacheRoot, url));
42
+ }
43
+ writeEntry(url, entry) {
44
+ return writeJsonAtomic(entryPath(this.cacheRoot, url), entry);
45
+ }
46
+ readFileVersion(fileKey) {
47
+ return readJsonFile(fileVersionPath(this.cacheRoot, fileKey));
48
+ }
49
+ writeFileVersion(fileKey, entry) {
50
+ return writeJsonAtomic(fileVersionPath(this.cacheRoot, fileKey), entry);
51
+ }
52
+ }
53
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/figma-api/cache/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE1D,SAAS,YAAY,CAAC,KAAa;IACjC,MAAM,SAAS,GAAG,UAAU,CAAC,QAAQ,CAAC;SACnC,MAAM,CAAC,KAAK,CAAC;SACb,MAAM,CAAC,KAAK,CAAC;SACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,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S,EAAE,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,UAAU,CAAC,GAAW,EAAE,KAAiB;QACvC,OAAO,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAChE,CAAC;IAED,eAAe,CAAC,OAAe;QAC7B,OAAO,YAAY,CACjB,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CACzC,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,OAAe,EAAE,KAAuB;QACvD,OAAO,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ export interface CacheEntry {
2
+ url: string;
3
+ cachedAt: number;
4
+ version?: string;
5
+ lastModified?: string;
6
+ etag?: string;
7
+ body: unknown;
8
+ }
9
+ export interface FileVersionEntry {
10
+ version: string;
11
+ lastModified?: string;
12
+ checkedAt: number;
13
+ }
14
+ export interface FetchedResponse {
15
+ body: unknown;
16
+ version?: string;
17
+ lastModified?: string;
18
+ etag?: string;
19
+ }
20
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/figma-api/cache/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare function normalizeRequestUrl(url: string | URL): string;
2
+ export declare function hashValue(value: string): string;
3
+ export declare function extractFileKey(url: string): string | undefined;
4
+ export declare function buildFileProbeUrl(fileKey: string): string;
5
+ //# sourceMappingURL=url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../../src/figma-api/cache/url.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAK7D;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG9D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMzD"}
@@ -0,0 +1,20 @@
1
+ import { createHash } from "node:crypto";
2
+ export function normalizeRequestUrl(url) {
3
+ const parsed = new URL(url.toString());
4
+ parsed.hash = "";
5
+ parsed.searchParams.sort();
6
+ return parsed.toString();
7
+ }
8
+ export function hashValue(value) {
9
+ return createHash("sha256").update(value).digest("hex");
10
+ }
11
+ export function extractFileKey(url) {
12
+ const match = new URL(url).pathname.match(/^\/v1\/files\/([^/]+)(?:\/|$)/);
13
+ return match?.[1];
14
+ }
15
+ export function buildFileProbeUrl(fileKey) {
16
+ const url = new URL(`https://api.figma.com/v1/files/${encodeURIComponent(fileKey)}`);
17
+ url.searchParams.set("depth", "1");
18
+ return url.toString();
19
+ }
20
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../../../src/figma-api/cache/url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,mBAAmB,CAAC,GAAiB;IACnD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;IACjB,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAC3E,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CACjB,kCAAkC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAChE,CAAC;IACF,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const FIGMA_API_BASE_URL = "https://api.figma.com/v1";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/figma-api/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const FIGMA_API_BASE_URL = "https://api.figma.com/v1";
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/figma-api/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function fetchFigmaResponse(url: string | URL, token: string, fetchImpl?: typeof fetch): Promise<Response>;
2
+ //# sourceMappingURL=fetch-with-retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-with-retry.d.ts","sourceRoot":"","sources":["../../src/figma-api/fetch-with-retry.ts"],"names":[],"mappings":"AAqCA,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,QAAQ,CAAC,CAsBnB"}
@@ -0,0 +1,48 @@
1
+ const MAX_RATE_LIMIT_RETRIES = 10;
2
+ const MIN_RETRY_DELAY_MS = 1000;
3
+ const RATE_LIMIT_BUFFER_MS = 250;
4
+ function sleep(ms) {
5
+ return new Promise((resolve) => {
6
+ setTimeout(resolve, ms);
7
+ });
8
+ }
9
+ async function discardResponseBody(response) {
10
+ await response.arrayBuffer().catch(() => undefined);
11
+ }
12
+ function rateLimitDelayMs(response, now = Date.now()) {
13
+ const resetHeader = response.headers.get("x-ratelimit-reset");
14
+ if (resetHeader) {
15
+ const resetAtMs = Number.parseInt(resetHeader, 10) * 1000;
16
+ if (Number.isFinite(resetAtMs)) {
17
+ return Math.max(MIN_RETRY_DELAY_MS, resetAtMs - now + RATE_LIMIT_BUFFER_MS);
18
+ }
19
+ }
20
+ const retryAfter = response.headers.get("retry-after");
21
+ if (retryAfter) {
22
+ const retryAfterSeconds = Number.parseInt(retryAfter, 10);
23
+ if (Number.isFinite(retryAfterSeconds)) {
24
+ return Math.max(MIN_RETRY_DELAY_MS, retryAfterSeconds * 1000);
25
+ }
26
+ }
27
+ return MIN_RETRY_DELAY_MS;
28
+ }
29
+ export async function fetchFigmaResponse(url, token, fetchImpl = fetch) {
30
+ for (let attempt = 0; attempt <= MAX_RATE_LIMIT_RETRIES; attempt += 1) {
31
+ const response = await fetchImpl(url, {
32
+ headers: {
33
+ "X-FIGMA-TOKEN": token,
34
+ },
35
+ });
36
+ if (response.status !== 429) {
37
+ return response;
38
+ }
39
+ if (attempt === MAX_RATE_LIMIT_RETRIES) {
40
+ return response;
41
+ }
42
+ const delayMs = rateLimitDelayMs(response);
43
+ await discardResponseBody(response);
44
+ await sleep(delayMs);
45
+ }
46
+ throw new Error("Unreachable fetch retry loop.");
47
+ }
48
+ //# sourceMappingURL=fetch-with-retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-with-retry.js","sourceRoot":"","sources":["../../src/figma-api/fetch-with-retry.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,mBAAmB,CAAC,QAAkB;IACnD,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAkB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IAC5D,MAAM,WAAW,GAAG,QAA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AED,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAC3C,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare class FigmaApiError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ //# sourceMappingURL=figma-api-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-api-error.d.ts","sourceRoot":"","sources":["../../src/figma-api/figma-api-error.ts"],"names":[],"mappings":"AAAA,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1,7 @@
1
+ export class FigmaApiError extends Error {
2
+ constructor(message) {
3
+ super(message);
4
+ this.name = "FigmaApiError";
5
+ }
6
+ }
7
+ //# sourceMappingURL=figma-api-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-api-error.js","sourceRoot":"","sources":["../../src/figma-api/figma-api-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare function figmaRequest(url: string | URL, token: string, fetchImpl?: typeof fetch): Promise<unknown>;
2
+ //# sourceMappingURL=figma-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-request.d.ts","sourceRoot":"","sources":["../../src/figma-api/figma-request.ts"],"names":[],"mappings":"AAuBA,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,OAAO,CAAC,CAMlB"}
@@ -0,0 +1,21 @@
1
+ import { CACHE_DISABLED_ENV, CachedFigmaRequest } from "./cache/index.js";
2
+ import { fetchFigmaResponse } from "./fetch-with-retry.js";
3
+ import { FigmaApiError } from "./figma-api-error.js";
4
+ import { formatFigmaError } from "./format-figma-error.js";
5
+ function isCacheEnabled(env = process.env) {
6
+ return env[CACHE_DISABLED_ENV] !== "0";
7
+ }
8
+ async function fetchWithoutCache(url, token, fetchImpl) {
9
+ const response = await fetchFigmaResponse(url, token, fetchImpl);
10
+ if (!response.ok) {
11
+ throw new FigmaApiError(await formatFigmaError(response));
12
+ }
13
+ return response.json();
14
+ }
15
+ export async function figmaRequest(url, token, fetchImpl = fetch) {
16
+ if (!isCacheEnabled()) {
17
+ return fetchWithoutCache(url, token, fetchImpl);
18
+ }
19
+ return new CachedFigmaRequest(token).request(url, fetchImpl);
20
+ }
21
+ //# sourceMappingURL=figma-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figma-request.js","sourceRoot":"","sources":["../../src/figma-api/figma-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,SAAS,cAAc,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC1D,OAAO,GAAG,CAAC,kBAAkB,CAAC,KAAK,GAAG,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,iBAAiB,CAC9B,GAAiB,EACjB,KAAa,EACb,SAAuB;IAEvB,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAEjE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,aAAa,CAAC,MAAM,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAiB,EACjB,KAAa,EACb,YAA0B,KAAK;IAE/B,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,IAAI,kBAAkB,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function formatFigmaError(response: Response): Promise<string>;
2
+ //# sourceMappingURL=format-figma-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-figma-error.d.ts","sourceRoot":"","sources":["../../src/figma-api/format-figma-error.ts"],"names":[],"mappings":"AAuBA,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAI1E"}