@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-alpha.11

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 (321) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
  3. package/dist/adapters/asset-collection.js +242 -0
  4. package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
  5. package/dist/adapters/build-lambda-zip.js +111 -0
  6. package/dist/adapters/configureNextjsCache.d.ts +8 -0
  7. package/dist/adapters/configureNextjsCache.js +55 -0
  8. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
  9. package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
  10. package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
  11. package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
  12. package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
  13. package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
  14. package/dist/adapters/deploy-output/isFile.d.ts +1 -0
  15. package/dist/adapters/deploy-output/isFile.js +4 -0
  16. package/dist/adapters/deploy-output/readJson.d.ts +1 -0
  17. package/dist/adapters/deploy-output/readJson.js +9 -0
  18. package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
  19. package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
  20. package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
  21. package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
  22. package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
  23. package/dist/adapters/deploy-output/resolveWithin.js +12 -0
  24. package/dist/adapters/fs-utils.d.ts +39 -0
  25. package/dist/adapters/fs-utils.js +135 -0
  26. package/dist/adapters/index.d.ts +4 -0
  27. package/dist/adapters/index.js +3 -0
  28. package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
  29. package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
  30. package/dist/adapters/nextjs.d.ts +12 -0
  31. package/dist/adapters/nextjs.js +67 -0
  32. package/dist/adapters/nitro.d.ts +8 -0
  33. package/dist/adapters/nitro.js +193 -0
  34. package/dist/adapters/secret-files.d.ts +25 -0
  35. package/dist/adapters/secret-files.js +50 -0
  36. package/dist/adapters/types.d.ts +42 -0
  37. package/dist/adapters/types.js +1 -0
  38. package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
  39. package/dist/adapters/vite.js +33 -0
  40. package/dist/api/check-project-subdomain-availability.d.ts +12 -0
  41. package/dist/api/check-project-subdomain-availability.js +32 -0
  42. package/dist/api/control-plane-error.d.ts +6 -0
  43. package/dist/api/control-plane-error.js +8 -0
  44. package/dist/api/control-plane-fetch.d.ts +7 -0
  45. package/dist/api/control-plane-fetch.js +37 -0
  46. package/dist/api/control-plane.d.ts +10 -9
  47. package/dist/api/control-plane.js +27 -48
  48. package/dist/api/create-project.d.ts +18 -0
  49. package/dist/api/create-project.js +37 -0
  50. package/dist/api/list-project-workspaces.d.ts +8 -0
  51. package/dist/api/list-project-workspaces.js +28 -0
  52. package/dist/api/project-resource-type.d.ts +1 -0
  53. package/dist/api/project-resource-type.js +1 -0
  54. package/dist/auth/headless-oauth-flow.d.ts +23 -0
  55. package/dist/auth/headless-oauth-flow.js +69 -0
  56. package/dist/auth/oauth-flow.d.ts +2 -0
  57. package/dist/auth/oauth-flow.js +13 -8
  58. package/dist/auth/token-store.d.ts +20 -1
  59. package/dist/auth/token-store.js +47 -0
  60. package/dist/auth/types.d.ts +12 -0
  61. package/dist/cli.d.ts +39 -0
  62. package/dist/cli.js +71 -36
  63. package/dist/commands/bootstrap.js +2 -1
  64. package/dist/commands/build-lambda-zip.js +1 -1
  65. package/dist/commands/deploy.d.ts +12 -0
  66. package/dist/commands/deploy.js +63 -25
  67. package/dist/commands/detect-project-resource-type.d.ts +3 -0
  68. package/dist/commands/detect-project-resource-type.js +28 -0
  69. package/dist/commands/init.d.ts +2 -2
  70. package/dist/commands/init.js +235 -80
  71. package/dist/commands/login.d.ts +11 -1
  72. package/dist/commands/login.js +66 -4
  73. package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
  74. package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
  75. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
  76. package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
  77. package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
  78. package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
  79. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
  80. package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
  81. package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
  82. package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
  83. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
  84. package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
  85. package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
  86. package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
  87. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
  88. package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
  89. package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
  90. package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
  91. package/dist/commands/prompt-to-create-project.d.ts +24 -0
  92. package/dist/commands/prompt-to-create-project.js +69 -0
  93. package/dist/commands/setup-agent.d.ts +12 -0
  94. package/dist/commands/setup-agent.js +123 -0
  95. package/dist/commands/upgrade.js +65 -1
  96. package/dist/commands/write-project-configuration.d.ts +12 -0
  97. package/dist/commands/write-project-configuration.js +16 -0
  98. package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
  99. package/dist/db-content-api/index.d.ts +1 -1
  100. package/dist/db-content-api/index.js +121 -72
  101. package/dist/db-content-api/utilities/data/index.js +8 -2
  102. package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
  103. package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
  104. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
  105. package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
  106. package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
  107. package/dist/db-content-api/utilities/isRecord.js +19 -0
  108. package/dist/db-content-api/utilities/joins.js +5 -1
  109. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
  110. package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
  111. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
  112. package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
  113. package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +9 -4
  114. package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
  115. package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
  116. package/dist/db-content-api/utilities/where.d.ts +2 -6
  117. package/dist/db-content-api/utilities/where.js +20 -9
  118. package/dist/exports/client.d.ts +2 -0
  119. package/dist/exports/client.js +2 -0
  120. package/dist/exports/views.d.ts +1 -0
  121. package/dist/exports/views.js +1 -0
  122. package/dist/imageSizeOptions.d.ts +23 -0
  123. package/dist/imageSizeOptions.js +26 -0
  124. package/dist/index.d.ts +2 -0
  125. package/dist/index.js +2 -0
  126. package/dist/lib/write-agent-config.d.ts +12 -0
  127. package/dist/lib/write-agent-config.js +52 -0
  128. package/dist/next/image-loader.d.ts +6 -0
  129. package/dist/next/image-loader.js +14 -0
  130. package/dist/oauth/components/LoginButton/index.js +66 -19
  131. package/dist/oauth/components/LoginButton/index.scss +121 -15
  132. package/dist/oauth/defaults.js +4 -1
  133. package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
  134. package/dist/oauth/index.js +8 -7
  135. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
  136. package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
  137. package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
  138. package/dist/plugin/build-config.d.ts +13 -3
  139. package/dist/plugin/build-config.js +181 -36
  140. package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
  141. package/dist/plugin/cache-revalidation-hooks.js +69 -0
  142. package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
  143. package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
  144. package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
  145. package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
  146. package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
  147. package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
  148. package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
  149. package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
  150. package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
  151. package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
  152. package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
  153. package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
  154. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +3 -0
  155. package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
  156. package/dist/plugin/cloud-limits/routes.d.ts +2 -0
  157. package/dist/plugin/cloud-limits/routes.js +4 -0
  158. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
  159. package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
  160. package/dist/plugin/cloud-limits/shared.d.ts +10 -0
  161. package/dist/plugin/cloud-limits/shared.js +52 -0
  162. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
  163. package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
  164. package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
  165. package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
  166. package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
  167. package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
  168. package/dist/plugin/sandbox-upload-fetch.d.ts +32 -0
  169. package/dist/plugin/sandbox-upload-fetch.js +53 -0
  170. package/dist/skills/deploy-to-figma/SKILL.md +234 -0
  171. package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
  172. package/dist/storage-content-api/api-types.d.ts +3 -0
  173. package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
  174. package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
  175. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
  176. package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
  177. package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
  178. package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
  179. package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
  180. package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -0
  181. package/dist/storage-content-api/client-uploads/generate.js +2 -1
  182. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
  183. package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +33 -0
  184. package/dist/storage-content-api/getMediaType.d.ts +1 -0
  185. package/dist/storage-content-api/getMediaType.js +3 -0
  186. package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
  187. package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
  188. package/dist/storage-content-api/index.js +1 -0
  189. package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
  190. package/dist/storage-content-api/mediaErrorResponse.js +12 -0
  191. package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
  192. package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
  193. package/dist/storage-content-api/shouldAttachMedia.d.ts +1 -0
  194. package/dist/storage-content-api/shouldAttachMedia.js +34 -0
  195. package/dist/storage-content-api/staticHandler.js +93 -25
  196. package/dist/storage-content-api/types.d.ts +4 -1
  197. package/dist/translations/ar.d.ts +12 -0
  198. package/dist/translations/ar.js +12 -0
  199. package/dist/translations/az.d.ts +12 -0
  200. package/dist/translations/az.js +12 -0
  201. package/dist/translations/bg.d.ts +12 -0
  202. package/dist/translations/bg.js +12 -0
  203. package/dist/translations/bnBd.d.ts +12 -0
  204. package/dist/translations/bnBd.js +12 -0
  205. package/dist/translations/bnIn.d.ts +12 -0
  206. package/dist/translations/bnIn.js +12 -0
  207. package/dist/translations/ca.d.ts +12 -0
  208. package/dist/translations/ca.js +12 -0
  209. package/dist/translations/cs.d.ts +12 -0
  210. package/dist/translations/cs.js +12 -0
  211. package/dist/translations/da.d.ts +12 -0
  212. package/dist/translations/da.js +12 -0
  213. package/dist/translations/de.d.ts +12 -0
  214. package/dist/translations/de.js +12 -0
  215. package/dist/translations/en.d.ts +12 -0
  216. package/dist/translations/en.js +12 -0
  217. package/dist/translations/es.d.ts +12 -0
  218. package/dist/translations/es.js +12 -0
  219. package/dist/translations/et.d.ts +12 -0
  220. package/dist/translations/et.js +12 -0
  221. package/dist/translations/fa.d.ts +12 -0
  222. package/dist/translations/fa.js +12 -0
  223. package/dist/translations/fr.d.ts +12 -0
  224. package/dist/translations/fr.js +12 -0
  225. package/dist/translations/he.d.ts +12 -0
  226. package/dist/translations/he.js +12 -0
  227. package/dist/translations/hr.d.ts +12 -0
  228. package/dist/translations/hr.js +12 -0
  229. package/dist/translations/hu.d.ts +12 -0
  230. package/dist/translations/hu.js +12 -0
  231. package/dist/translations/hy.d.ts +12 -0
  232. package/dist/translations/hy.js +12 -0
  233. package/dist/translations/id.d.ts +12 -0
  234. package/dist/translations/id.js +12 -0
  235. package/dist/translations/index.d.ts +533 -0
  236. package/dist/translations/index.js +90 -0
  237. package/dist/translations/is.d.ts +12 -0
  238. package/dist/translations/is.js +12 -0
  239. package/dist/translations/it.d.ts +12 -0
  240. package/dist/translations/it.js +12 -0
  241. package/dist/translations/ja.d.ts +12 -0
  242. package/dist/translations/ja.js +12 -0
  243. package/dist/translations/ko.d.ts +12 -0
  244. package/dist/translations/ko.js +12 -0
  245. package/dist/translations/lt.d.ts +12 -0
  246. package/dist/translations/lt.js +12 -0
  247. package/dist/translations/lv.d.ts +12 -0
  248. package/dist/translations/lv.js +12 -0
  249. package/dist/translations/my.d.ts +12 -0
  250. package/dist/translations/my.js +12 -0
  251. package/dist/translations/nb.d.ts +12 -0
  252. package/dist/translations/nb.js +12 -0
  253. package/dist/translations/nl.d.ts +12 -0
  254. package/dist/translations/nl.js +12 -0
  255. package/dist/translations/pl.d.ts +12 -0
  256. package/dist/translations/pl.js +12 -0
  257. package/dist/translations/pt.d.ts +12 -0
  258. package/dist/translations/pt.js +12 -0
  259. package/dist/translations/ro.d.ts +12 -0
  260. package/dist/translations/ro.js +12 -0
  261. package/dist/translations/rs.d.ts +12 -0
  262. package/dist/translations/rs.js +12 -0
  263. package/dist/translations/rsLatin.d.ts +12 -0
  264. package/dist/translations/rsLatin.js +12 -0
  265. package/dist/translations/ru.d.ts +12 -0
  266. package/dist/translations/ru.js +12 -0
  267. package/dist/translations/sk.d.ts +12 -0
  268. package/dist/translations/sk.js +12 -0
  269. package/dist/translations/sl.d.ts +12 -0
  270. package/dist/translations/sl.js +12 -0
  271. package/dist/translations/sv.d.ts +12 -0
  272. package/dist/translations/sv.js +12 -0
  273. package/dist/translations/ta.d.ts +12 -0
  274. package/dist/translations/ta.js +12 -0
  275. package/dist/translations/th.d.ts +12 -0
  276. package/dist/translations/th.js +12 -0
  277. package/dist/translations/tr.d.ts +12 -0
  278. package/dist/translations/tr.js +12 -0
  279. package/dist/translations/uk.d.ts +12 -0
  280. package/dist/translations/uk.js +12 -0
  281. package/dist/translations/vi.d.ts +12 -0
  282. package/dist/translations/vi.js +12 -0
  283. package/dist/translations/zh.d.ts +12 -0
  284. package/dist/translations/zh.js +12 -0
  285. package/dist/translations/zhTw.d.ts +12 -0
  286. package/dist/translations/zhTw.js +12 -0
  287. package/dist/types.d.ts +11 -0
  288. package/dist/utils/assert-never.d.ts +1 -0
  289. package/dist/utils/assert-never.js +3 -0
  290. package/dist/utils/build-detection.d.ts +6 -1
  291. package/dist/utils/build-detection.js +68 -89
  292. package/dist/utils/deploy-adapter.d.ts +3 -35
  293. package/dist/utils/deploy-adapter.js +25 -14
  294. package/dist/utils/env-management.d.ts +15 -0
  295. package/dist/utils/env-management.js +47 -0
  296. package/dist/utils/lambda-config.js +18 -23
  297. package/dist/utils/messages.js +24 -3
  298. package/dist/utils/next-image-loader-config.d.ts +2 -0
  299. package/dist/utils/next-image-loader-config.js +63 -0
  300. package/dist/utils/next-image-loader-file.d.ts +2 -0
  301. package/dist/utils/next-image-loader-file.js +11 -0
  302. package/dist/utils/payload-config-ast.js +5 -2
  303. package/dist/utils/payload-generate.d.ts +10 -0
  304. package/dist/utils/payload-generate.js +59 -0
  305. package/dist/utils/payload-secret.d.ts +28 -0
  306. package/dist/utils/payload-secret.js +34 -0
  307. package/dist/utils/pnpm-builds.d.ts +14 -0
  308. package/dist/utils/pnpm-builds.js +125 -0
  309. package/dist/utils/s3-upload.js +4 -1
  310. package/package.json +33 -7
  311. package/dist/lib/download-skill.d.ts +0 -12
  312. package/dist/lib/download-skill.js +0 -77
  313. package/dist/utils/adapters/nextjs.d.ts +0 -8
  314. package/dist/utils/adapters/nextjs.js +0 -61
  315. package/dist/utils/adapters/nitro.d.ts +0 -8
  316. package/dist/utils/adapters/nitro.js +0 -172
  317. package/dist/utils/adapters/vite.js +0 -31
  318. package/dist/utils/asset-collection.js +0 -144
  319. package/dist/utils/build-lambda-zip.js +0 -90
  320. package/dist/utils/fs-utils.d.ts +0 -12
  321. package/dist/utils/fs-utils.js +0 -55
@@ -0,0 +1,8 @@
1
+ import type { AuthCredential } from '../auth/credentials.js';
2
+ interface ProjectWorkspace {
3
+ isDefault: boolean;
4
+ name: string;
5
+ planKey: string;
6
+ }
7
+ export declare function listProjectWorkspaces(credential: AuthCredential): Promise<ProjectWorkspace[]>;
8
+ export {};
@@ -0,0 +1,28 @@
1
+ import { getAuthHeaders } from '../auth/credentials.js';
2
+ import { getEnvConfig } from '../constants.js';
3
+ import { controlPlaneFetch } from './control-plane-fetch.js';
4
+ export async function listProjectWorkspaces(credential) {
5
+ if (process.env.FIGMA_MOCK_CONTROL_PLANE === 'true') {
6
+ return [
7
+ {
8
+ name: 'Mock workspace',
9
+ isDefault: true,
10
+ planKey: 'team::mock-workspace'
11
+ }
12
+ ];
13
+ }
14
+ const response = await controlPlaneFetch({
15
+ context: 'list project workspaces',
16
+ options: {
17
+ headers: getAuthHeaders(credential),
18
+ method: 'POST'
19
+ },
20
+ url: `${getEnvConfig().apiBaseUrl}/v1/cms/workspaces`
21
+ });
22
+ const workspaceResponse = await response.json();
23
+ return workspaceResponse.meta.workspaces.map((workspace)=>({
24
+ name: workspace.name,
25
+ isDefault: workspace.is_default,
26
+ planKey: workspace.plan_key
27
+ }));
28
+ }
@@ -0,0 +1 @@
1
+ export type ProjectResourceType = 'payload' | 'vite';
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,23 @@
1
+ import type { TokenStore } from './token-store.js';
2
+ export interface StartHeadlessOAuthFlowResult {
3
+ authorizationUrl: string;
4
+ expiresAt: number;
5
+ sessionId: string;
6
+ }
7
+ export declare class HeadlessOAuthFlowError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ /** Start OAuth without a callback listener so another process can resume it. */
11
+ export declare function startHeadlessOAuthFlow(tokenStore: TokenStore, options?: {
12
+ now?: number;
13
+ }): StartHeadlessOAuthFlowResult;
14
+ /** Complete a previously started headless OAuth flow and store its tokens. */
15
+ export declare function completeHeadlessOAuthFlow({ callbackUrl, now, sessionId, tokenStore, }: {
16
+ callbackUrl: string;
17
+ now?: number;
18
+ sessionId: string;
19
+ tokenStore: TokenStore;
20
+ }): Promise<{
21
+ tokens: import("./types.js").FigmaTokens;
22
+ userId: string | undefined;
23
+ }>;
@@ -0,0 +1,69 @@
1
+ import crypto from 'node:crypto';
2
+ import { getOAuthConfig } from '../config/oauth.js';
3
+ import { buildAuthorizationUrl } from './browser.js';
4
+ import { parsePastedCode } from './paste-code.js';
5
+ import { generatePKCEPair } from './pkce.js';
6
+ import { exchangeCodeForTokens } from './refresh.js';
7
+ const HEADLESS_OAUTH_SESSION_TTL_MS = 10 * 60 * 1000;
8
+ export class HeadlessOAuthFlowError extends Error {
9
+ constructor(message){
10
+ super(message);
11
+ this.name = 'HeadlessOAuthFlowError';
12
+ }
13
+ }
14
+ /** Start OAuth without a callback listener so another process can resume it. */ export function startHeadlessOAuthFlow(tokenStore, options = {}) {
15
+ const oauthConfig = getOAuthConfig();
16
+ const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
17
+ const now = options.now ?? Date.now();
18
+ const session = {
19
+ id: crypto.randomBytes(32).toString('base64url'),
20
+ clientId: oauthConfig.clientId,
21
+ codeVerifier,
22
+ expiresAt: now + HEADLESS_OAUTH_SESSION_TTL_MS,
23
+ redirectUri: oauthConfig.redirectUri,
24
+ state: crypto.randomBytes(32).toString('base64url')
25
+ };
26
+ tokenStore.setHeadlessOAuthSession(session);
27
+ return {
28
+ authorizationUrl: buildAuthorizationUrl({
29
+ authorizationUrl: oauthConfig.authorizationUrl,
30
+ clientId: session.clientId,
31
+ codeChallenge,
32
+ codeChallengeMethod,
33
+ redirectUri: session.redirectUri,
34
+ scopes: oauthConfig.scopes,
35
+ state: session.state
36
+ }),
37
+ expiresAt: session.expiresAt,
38
+ sessionId: session.id
39
+ };
40
+ }
41
+ /** Complete a previously started headless OAuth flow and store its tokens. */ export async function completeHeadlessOAuthFlow({ callbackUrl, now = Date.now(), sessionId, tokenStore }) {
42
+ const session = tokenStore.getHeadlessOAuthSession();
43
+ if (!session) {
44
+ throw new HeadlessOAuthFlowError('No pending login found. Start login again with --headless.');
45
+ }
46
+ if (session.id !== sessionId) {
47
+ throw new HeadlessOAuthFlowError('Login session does not match. Start login again with --headless.');
48
+ }
49
+ if (now >= session.expiresAt) {
50
+ tokenStore.clearHeadlessOAuthSession();
51
+ throw new HeadlessOAuthFlowError('Login session expired. Start login again with --headless.');
52
+ }
53
+ try {
54
+ try {
55
+ new URL(callbackUrl);
56
+ } catch {
57
+ throw new HeadlessOAuthFlowError('Paste the full redirected URL so the login state can be verified.');
58
+ }
59
+ const code = parsePastedCode(callbackUrl, session.state);
60
+ const tokens = await exchangeCodeForTokens(code, session.codeVerifier, session.redirectUri, session.clientId);
61
+ tokenStore.setTokens(tokens);
62
+ return {
63
+ tokens,
64
+ userId: tokens.userId
65
+ };
66
+ } finally{
67
+ tokenStore.clearHeadlessOAuthSession();
68
+ }
69
+ }
@@ -16,6 +16,8 @@ export interface OAuthFlowOptions {
16
16
  clientId?: string;
17
17
  /** Callback server fallback ports to try after port */
18
18
  fallbackPorts?: number[];
19
+ /** Open the browser without asking for confirmation */
20
+ openBrowserWithoutPrompt?: boolean;
19
21
  /** First callback server port to try */
20
22
  port?: number;
21
23
  /** Redirect URI (defaults to config) */
@@ -54,7 +54,7 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
54
54
  };
55
55
  }
56
56
  // REAL OAUTH IMPLEMENTATION
57
- const { clientId = oauthConfig.clientId, fallbackPorts, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
57
+ const { clientId = oauthConfig.clientId, fallbackPorts, openBrowserWithoutPrompt = false, port, redirectUri = oauthConfig.redirectUri, scopes = oauthConfig.scopes, timeoutMs = 120000 } = options;
58
58
  // Generate PKCE pair for enhanced security
59
59
  const { codeChallenge, codeChallengeMethod, codeVerifier } = generatePKCEPair();
60
60
  // Generate random state for CSRF protection
@@ -85,13 +85,18 @@ import { exchangeCodeForTokens, refreshAccessToken, TokenRefreshError } from './
85
85
  scopes,
86
86
  state
87
87
  });
88
- // Prompt user to open browser
89
- const shouldOpenBrowser = await p.confirm({
90
- initialValue: true,
91
- message: 'Open browser to authenticate with Figma?'
92
- });
93
- if (p.isCancel(shouldOpenBrowser)) {
94
- throw new OAuthFlowError('Authentication cancelled by user');
88
+ // Ask interactive callers before opening a browser. Automated callers have
89
+ // already accepted defaults with -y, so proceed directly to authorization.
90
+ let shouldOpenBrowser = openBrowserWithoutPrompt;
91
+ if (!openBrowserWithoutPrompt) {
92
+ const browserConfirmation = await p.confirm({
93
+ initialValue: true,
94
+ message: 'Open browser to authenticate with Figma?'
95
+ });
96
+ if (p.isCancel(browserConfirmation)) {
97
+ throw new OAuthFlowError('Authentication cancelled by user');
98
+ }
99
+ shouldOpenBrowser = browserConfirmation;
95
100
  }
96
101
  let browserOpened = false;
97
102
  if (shouldOpenBrowser) {
@@ -1,5 +1,5 @@
1
1
  import type { Environment } from '../constants.js';
2
- import type { BootstrapData, FigmaTokens, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
2
+ import type { BootstrapData, FigmaTokens, HeadlessOAuthSession, ProjectStoreScope, ProjectToken, TokenStoreConfig } from './types.js';
3
3
  /**
4
4
  * Get the singleton TokenStore instance for an environment.
5
5
  */
@@ -23,6 +23,9 @@ export declare class TokenStore {
23
23
  getOauthInfo(): FigmaTokens | null;
24
24
  setTokens(tokens: FigmaTokens): void;
25
25
  clearTokens(): void;
26
+ getHeadlessOAuthSession(): HeadlessOAuthSession | null;
27
+ setHeadlessOAuthSession(session: HeadlessOAuthSession): void;
28
+ clearHeadlessOAuthSession(): void;
26
29
  hasValidOauthToken(): boolean;
27
30
  isOauthExpired(): boolean;
28
31
  getCurrentOauthToken(): null | string;
@@ -61,6 +64,22 @@ export declare class TokenStore {
61
64
  getBootstrapData(projectId: string, environmentName: string): BootstrapData | null;
62
65
  setBootstrapData(projectId: string, environmentName: string, data: BootstrapData): void;
63
66
  clearBootstrapData(projectId: string, environmentName: string): void;
67
+ /**
68
+ * PAYLOAD_SECRET is fetched from the Control Plane during `init` and
69
+ * cached here per (projectId, environmentName). buildFigmaConfig reads
70
+ * it at local dev startup when process.env.PAYLOAD_SECRET is unset.
71
+ * Platform-injected in Lambda, so this path is never hit there.
72
+ */
73
+ getPayloadSecret({ projectInfo }?: {
74
+ projectInfo?: ProjectStoreScope;
75
+ }): null | string;
76
+ setPayloadSecret({ projectInfo, secret, }: {
77
+ projectInfo?: ProjectStoreScope;
78
+ secret: string;
79
+ }): void;
80
+ clearPayloadSecret({ projectInfo }?: {
81
+ projectInfo?: ProjectStoreScope;
82
+ }): void;
64
83
  private buildOAuthConfigName;
65
84
  private buildOAuthStoreCwd;
66
85
  private buildProjectStoreConfigName;
@@ -186,11 +186,25 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
186
186
  clearTokens() {
187
187
  this.oauthConfig.delete('accessToken');
188
188
  this.oauthConfig.delete('expiresAt');
189
+ this.oauthConfig.delete('headlessOAuthSession');
189
190
  this.oauthConfig.delete('refreshToken');
190
191
  this.oauthConfig.delete('scopes');
191
192
  this.oauthConfig.delete('tokenType');
192
193
  this.oauthConfig.delete('userId');
193
194
  }
195
+ getHeadlessOAuthSession() {
196
+ return this.safeGet({
197
+ config: this.oauthConfig,
198
+ key: 'headlessOAuthSession'
199
+ }) ?? null;
200
+ }
201
+ setHeadlessOAuthSession(session) {
202
+ this.oauthConfig.set('_schemaVersion', OAUTH_STORE_SCHEMA_VERSION);
203
+ this.oauthConfig.set('headlessOAuthSession', session);
204
+ }
205
+ clearHeadlessOAuthSession() {
206
+ this.oauthConfig.delete('headlessOAuthSession');
207
+ }
194
208
  hasValidOauthToken() {
195
209
  const tokens = this.getOauthInfo();
196
210
  if (!tokens) {
@@ -340,6 +354,39 @@ const PROJECT_STORE_SCHEMA_VERSION = 1;
340
354
  });
341
355
  config.delete('bootstrapData');
342
356
  }
357
+ /**
358
+ * PAYLOAD_SECRET is fetched from the Control Plane during `init` and
359
+ * cached here per (projectId, environmentName). buildFigmaConfig reads
360
+ * it at local dev startup when process.env.PAYLOAD_SECRET is unset.
361
+ * Platform-injected in Lambda, so this path is never hit there.
362
+ */ getPayloadSecret({ projectInfo } = {}) {
363
+ const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
364
+ if (!resolvedProjectInfo) {
365
+ return null;
366
+ }
367
+ const config = this.getProjectStore(resolvedProjectInfo);
368
+ return this.safeGet({
369
+ config,
370
+ key: 'payloadSecret'
371
+ }) ?? null;
372
+ }
373
+ setPayloadSecret({ projectInfo, secret }) {
374
+ const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
375
+ if (!resolvedProjectInfo) {
376
+ throw new Error('Cannot set payload secret: FIGMA_PROJECT_ID and FIGMA_ENVIRONMENT_NAME must be set');
377
+ }
378
+ const config = this.getProjectStore(resolvedProjectInfo);
379
+ config.set('_schemaVersion', PROJECT_STORE_SCHEMA_VERSION);
380
+ config.set('payloadSecret', secret);
381
+ }
382
+ clearPayloadSecret({ projectInfo } = {}) {
383
+ const resolvedProjectInfo = projectInfo ?? this.getProjectInfoFromEnv();
384
+ if (!resolvedProjectInfo) {
385
+ return;
386
+ }
387
+ const config = this.getProjectStore(resolvedProjectInfo);
388
+ config.delete('payloadSecret');
389
+ }
343
390
  buildOAuthConfigName() {
344
391
  // For test isolation: if using a custom config name, use it as-is with -oauth suffix
345
392
  // Otherwise use the standard naming that includes environment
@@ -32,6 +32,18 @@ export interface FigmaTokens {
32
32
  /** Figma user ID string */
33
33
  userId?: string;
34
34
  }
35
+ /**
36
+ * Temporary state for a resumable OAuth login. Stored encrypted on the machine
37
+ * that generated the PKCE verifier and removed after completion or expiry.
38
+ */
39
+ export interface HeadlessOAuthSession {
40
+ clientId: string;
41
+ codeVerifier: string;
42
+ expiresAt: number;
43
+ id: string;
44
+ redirectUri: string;
45
+ state: string;
46
+ }
35
47
  /**
36
48
  * Raw token response from Figma OAuth2 token endpoint
37
49
  * Response from POST https://api.figma.com/v1/oauth/token
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,42 @@
1
+ export declare const cliArgSpec: {
2
+ readonly '--adapter': StringConstructor;
3
+ readonly '--all': BooleanConstructor;
4
+ readonly '--callback-url': StringConstructor;
5
+ readonly '--complete': StringConstructor;
6
+ readonly '--debug': BooleanConstructor;
7
+ readonly '--description': StringConstructor;
8
+ readonly '--dry-run': BooleanConstructor;
9
+ readonly '--env': StringConstructor;
10
+ readonly '--force': BooleanConstructor;
11
+ readonly '--global': BooleanConstructor;
12
+ readonly '--headless': BooleanConstructor;
13
+ readonly '--help': BooleanConstructor;
14
+ readonly '--id': StringConstructor;
15
+ readonly '--infra-env': StringConstructor;
16
+ readonly '--json': BooleanConstructor;
17
+ readonly '--name': StringConstructor;
18
+ readonly '--no-agent': BooleanConstructor;
19
+ readonly '--output': StringConstructor;
20
+ readonly '--payload-version': StringConstructor;
21
+ readonly '--project': BooleanConstructor;
22
+ readonly '--region': StringConstructor;
23
+ readonly '--skip-auth': BooleanConstructor;
24
+ readonly '--skip-build': BooleanConstructor;
25
+ readonly '--skip-size-check': BooleanConstructor;
26
+ readonly '--subdomain': StringConstructor;
27
+ readonly '--template': StringConstructor;
28
+ readonly '--version': BooleanConstructor;
29
+ readonly '--workspace': StringConstructor;
30
+ readonly '--yes': BooleanConstructor;
31
+ readonly '--environment': "--env";
32
+ readonly '-e': "--env";
33
+ readonly '-f': "--force";
34
+ readonly '-h': "--help";
35
+ readonly '-n': "--name";
36
+ readonly '-t': "--template";
37
+ readonly '-v': "--version";
38
+ readonly '-y': "--yes";
39
+ };
1
40
  /**
2
41
  * Entrypoint for bin/cli.js
3
42
  */
package/dist/cli.js CHANGED
@@ -11,10 +11,51 @@ import { initCommand } from './commands/init.js';
11
11
  import { listTokensCommand } from './commands/list-tokens.js';
12
12
  import { loginCommand } from './commands/login.js';
13
13
  import { logoutCommand } from './commands/logout.js';
14
+ import { setupAgentCommand } from './commands/setup-agent.js';
14
15
  import { upgradeCommand } from './commands/upgrade.js';
15
16
  import { uploadSchemaCommand } from './commands/upload-schema.js';
16
17
  import { setInfraEnvironment } from './constants.js';
17
18
  import { helpMessage } from './utils/messages.js';
19
+ export const cliArgSpec = {
20
+ '--adapter': String,
21
+ '--all': Boolean,
22
+ '--callback-url': String,
23
+ '--complete': String,
24
+ '--debug': Boolean,
25
+ '--description': String,
26
+ '--dry-run': Boolean,
27
+ '--env': String,
28
+ '--force': Boolean,
29
+ '--global': Boolean,
30
+ '--headless': Boolean,
31
+ '--help': Boolean,
32
+ '--id': String,
33
+ '--infra-env': String,
34
+ '--json': Boolean,
35
+ '--name': String,
36
+ '--no-agent': Boolean,
37
+ '--output': String,
38
+ '--payload-version': String,
39
+ '--project': Boolean,
40
+ '--region': String,
41
+ '--skip-auth': Boolean,
42
+ '--skip-build': Boolean,
43
+ '--skip-size-check': Boolean,
44
+ '--subdomain': String,
45
+ '--template': String,
46
+ '--version': Boolean,
47
+ '--workspace': String,
48
+ '--yes': Boolean,
49
+ // Aliases
50
+ '--environment': '--env',
51
+ '-e': '--env',
52
+ '-f': '--force',
53
+ '-h': '--help',
54
+ '-n': '--name',
55
+ '-t': '--template',
56
+ '-v': '--version',
57
+ '-y': '--yes'
58
+ };
18
59
  /**
19
60
  * Entrypoint for bin/cli.js
20
61
  */ export async function main() {
@@ -31,39 +72,7 @@ class Main {
31
72
  args;
32
73
  constructor(){
33
74
  // @ts-expect-error bad typings
34
- this.args = arg({
35
- // Hidden flag — intentionally not displayed in help output yet.
36
- // Auto-detection covers most cases; this is an escape hatch for testing.
37
- // May expose in help text once multi-framework support is public.
38
- '--adapter': String,
39
- '--all': Boolean,
40
- '--debug': Boolean,
41
- '--dry-run': Boolean,
42
- '--env': String,
43
- '--force': Boolean,
44
- '--help': Boolean,
45
- '--id': String,
46
- '--infra-env': String,
47
- '--json': Boolean,
48
- '--name': String,
49
- '--no-skill': Boolean,
50
- '--payload-version': String,
51
- '--skip-auth': Boolean,
52
- '--skip-build': Boolean,
53
- '--skip-size-check': Boolean,
54
- '--template': String,
55
- '--version': Boolean,
56
- '--yes': Boolean,
57
- // Aliases
58
- '--environment': '--env',
59
- '-e': '--env',
60
- '-f': '--force',
61
- '-h': '--help',
62
- '-n': '--name',
63
- '-t': '--template',
64
- '-v': '--version',
65
- '-y': '--yes'
66
- }, {
75
+ this.args = arg(cliArgSpec, {
67
76
  permissive: true
68
77
  });
69
78
  // Set debug flag globally
@@ -105,7 +114,16 @@ class Main {
105
114
  helpMessage();
106
115
  process.exit(0);
107
116
  }
108
- // Debug command outputs plain text for copy-paste — skip styled intro
117
+ // JSON and debug commands output plain text — skip styled intro.
118
+ if (subcommand === 'login' && this.args['--json']) {
119
+ await loginCommand({
120
+ callbackUrl: this.args['--callback-url'],
121
+ completeSessionId: this.args['--complete'],
122
+ headless: this.args['--headless'],
123
+ json: true
124
+ });
125
+ process.exit(0);
126
+ }
109
127
  if (subcommand === 'debug') {
110
128
  await debugCommand();
111
129
  process.exit(0);
@@ -133,11 +151,17 @@ class Main {
133
151
  case 'deploy':
134
152
  await deployCommand({
135
153
  id: this.args['--id'],
154
+ name: this.args['--name'],
136
155
  adapter: this.args['--adapter'],
137
156
  debug: this.args['--debug'],
157
+ description: this.args['--description'],
138
158
  env: this.args['--env'],
159
+ output: this.args['--output'],
160
+ region: this.args['--region'],
139
161
  skipBuild: this.args['--skip-build'],
140
162
  skipSizeCheck: this.args['--skip-size-check'],
163
+ subdomain: this.args['--subdomain'],
164
+ workspace: this.args['--workspace'],
141
165
  yes: this.args['--yes']
142
166
  });
143
167
  break;
@@ -153,7 +177,7 @@ class Main {
153
177
  debug: this.args['--debug'],
154
178
  env: this.args['--env'],
155
179
  force: this.args['--force'],
156
- noSkill: this.args['--no-skill'],
180
+ noAgent: this.args['--no-agent'],
157
181
  payloadVersion: this.args['--payload-version'],
158
182
  skipAuth: this.args['--skip-auth'],
159
183
  template: this.args['--template']
@@ -166,7 +190,11 @@ class Main {
166
190
  });
167
191
  break;
168
192
  case 'login':
169
- await loginCommand();
193
+ await loginCommand({
194
+ callbackUrl: this.args['--callback-url'],
195
+ completeSessionId: this.args['--complete'],
196
+ headless: this.args['--headless']
197
+ });
170
198
  break;
171
199
  case 'logout':
172
200
  await logoutCommand({
@@ -174,6 +202,13 @@ class Main {
174
202
  debug: this.args['--debug']
175
203
  });
176
204
  break;
205
+ case 'setup-agent':
206
+ await setupAgentCommand({
207
+ global: this.args['--global'],
208
+ project: this.args['--project'],
209
+ yes: this.args['--yes']
210
+ });
211
+ break;
177
212
  case 'upgrade':
178
213
  await upgradeCommand({
179
214
  isDryRun: this.args['--dry-run']
@@ -1,6 +1,7 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { ControlPlaneError, getBootstrapInfo } from '../api/control-plane.js';
3
+ import { getBootstrapInfo } from '../api/control-plane.js';
4
+ import { ControlPlaneError } from '../api/control-plane-error.js';
4
5
  import { getValidCredential } from '../auth/oauth-flow.js';
5
6
  import { getTokenStore } from '../auth/token-store.js';
6
7
  import { getInfraEnvironment } from '../constants.js';
@@ -1,6 +1,6 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
- import { buildLambdaZip } from '../utils/build-lambda-zip.js';
3
+ import { buildLambdaZip } from '../adapters/build-lambda-zip.js';
4
4
  /**
5
5
  * Build Lambda deployment zip from current directory
6
6
  */ export async function buildLambdaZipCommand() {
@@ -7,14 +7,26 @@ export interface DeployCommandOptions {
7
7
  adapter?: AdapterName;
8
8
  /** Enable debug mode */
9
9
  debug?: boolean;
10
+ /** Description used when creating an uninitialized project */
11
+ description?: string;
10
12
  /** Figma environment name (e.g. 'production', 'staging') */
11
13
  env?: string;
12
14
  /** CMS Resource ID (overrides FIGMA_PROJECT_ID) */
13
15
  id?: string;
16
+ /** Name used when creating an uninitialized project */
17
+ name?: string;
18
+ /** Exact framework build output root */
19
+ output?: string;
20
+ /** Region used when creating an uninitialized project */
21
+ region?: string;
14
22
  /** Skip the build step (use existing build) */
15
23
  skipBuild?: boolean;
16
24
  /** Skip the client-side unzipped bundle size pre-flight check */
17
25
  skipSizeCheck?: boolean;
26
+ /** Subdomain used when creating an uninitialized project */
27
+ subdomain?: string;
28
+ /** Workspace plan key used when creating an uninitialized project */
29
+ workspace?: string;
18
30
  /** Skip confirmation prompts */
19
31
  yes?: boolean;
20
32
  }