@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
@@ -1,8 +1,18 @@
1
1
  type LoginArgs = {
2
+ /** Redirect URL returned by the browser for resumable login completion. */
3
+ callbackUrl?: string;
4
+ /** Pending resumable login session to complete. */
5
+ completeSessionId?: string;
6
+ /** Start a resumable login without waiting on stdin or a callback server. */
7
+ headless?: boolean;
8
+ /** Emit machine-readable output for resumable login. */
9
+ json?: boolean;
10
+ /** Open the browser without asking for confirmation. */
11
+ openBrowserWithoutPrompt?: boolean;
2
12
  /** Set this to show next steps after login
3
13
  * @default true
4
14
  */
5
- showNextSteps: boolean;
15
+ showNextSteps?: boolean;
6
16
  };
7
17
  /**
8
18
  * Handle the `@payloadcms/figma login` command
@@ -1,6 +1,7 @@
1
1
  import * as p from '@clack/prompts';
2
2
  import pc from 'picocolors';
3
3
  import { CallbackError } from '../auth/callback-server.js';
4
+ import { completeHeadlessOAuthFlow, startHeadlessOAuthFlow } from '../auth/headless-oauth-flow.js';
4
5
  import { executeOAuthFlow, getValidCredential, OAuthFlowError } from '../auth/oauth-flow.js';
5
6
  import { getTokenStore } from '../auth/token-store.js';
6
7
  import { getOAuthConfig } from '../config/oauth.js';
@@ -13,11 +14,47 @@ import * as log from '../utils/log.js';
13
14
  * Authenticates the user with Figma OAuth2 and stores tokens locally.
14
15
  * If valid tokens already exist, shows an error message.
15
16
  */ export async function loginCommand(args) {
16
- const { showNextSteps } = args || {
17
- showNextSteps: false
18
- };
17
+ const { callbackUrl, completeSessionId, headless = false, json = false, openBrowserWithoutPrompt = false, showNextSteps = false } = args ?? {};
19
18
  const env = getInfraEnvironment();
20
19
  const tokenStore = getTokenStore(env);
20
+ if (headless && completeSessionId) {
21
+ throw new Error('Use either --headless or --complete, not both.');
22
+ }
23
+ if (completeSessionId) {
24
+ if (!callbackUrl) {
25
+ throw new Error('--callback-url is required with --complete.');
26
+ }
27
+ const result = await completeHeadlessOAuthFlow({
28
+ callbackUrl,
29
+ sessionId: completeSessionId,
30
+ tokenStore
31
+ });
32
+ reportHeadlessLoginCompleted({
33
+ json,
34
+ userId: result.userId
35
+ });
36
+ return;
37
+ }
38
+ if (headless) {
39
+ try {
40
+ const credential = await getValidCredential(tokenStore);
41
+ if (credential) {
42
+ reportHeadlessLoginCompleted({
43
+ json,
44
+ userId: tokenStore.getOauthInfo()?.userId
45
+ });
46
+ return;
47
+ }
48
+ } catch {
49
+ // Invalid cached credentials should start a new login session.
50
+ }
51
+ const result = startHeadlessOAuthFlow(tokenStore);
52
+ reportHeadlessLoginStarted({
53
+ json,
54
+ ...result
55
+ });
56
+ return;
57
+ }
21
58
  // Check for existing valid tokens
22
59
  try {
23
60
  const existingCredential = await getValidCredential(tokenStore);
@@ -37,18 +74,43 @@ import * as log from '../utils/log.js';
37
74
  }
38
75
  // Start OAuth flow
39
76
  await handleAuthentication({
77
+ openBrowserWithoutPrompt,
40
78
  showNextSteps,
41
79
  tokenStore
42
80
  });
43
81
  }
82
+ function reportHeadlessLoginStarted({ authorizationUrl, expiresAt, json, sessionId }) {
83
+ if (json) {
84
+ process.stdout.write(`${JSON.stringify({
85
+ authorizationUrl,
86
+ expiresAt,
87
+ sessionId,
88
+ status: 'authorization_required'
89
+ })}\n`);
90
+ return;
91
+ }
92
+ p.log.step(`Open this URL to authenticate:\n\n ${authorizationUrl}`);
93
+ p.note(`After approving, copy the full redirected URL and run:\n` + `@payloadcms/figma login --complete ${sessionId} --callback-url '<redirect-url>'`, 'Complete login');
94
+ }
95
+ function reportHeadlessLoginCompleted({ json, userId }) {
96
+ if (json) {
97
+ process.stdout.write(`${JSON.stringify({
98
+ status: 'authenticated',
99
+ userId
100
+ })}\n`);
101
+ return;
102
+ }
103
+ p.log.success(pc.green('✓ Logged in'));
104
+ }
44
105
  /**
45
106
  * Handle authentication flow
46
- */ async function handleAuthentication({ showNextSteps, tokenStore }) {
107
+ */ async function handleAuthentication({ openBrowserWithoutPrompt, showNextSteps, tokenStore }) {
47
108
  try {
48
109
  // Execute OAuth flow
49
110
  const oauthConfig = getOAuthConfig();
50
111
  const result = await executeOAuthFlow(tokenStore, {
51
112
  clientId: oauthConfig.clientId,
113
+ openBrowserWithoutPrompt,
52
114
  redirectUri: oauthConfig.redirectUri,
53
115
  scopes: oauthConfig.scopes
54
116
  });
@@ -0,0 +1 @@
1
+ export declare function formatProjectSubdomain(value: string): string;
@@ -0,0 +1,3 @@
1
+ export function formatProjectSubdomain(value) {
2
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, '-').slice(0, 60).replace(/^-|-$/g, '') || 'figma-project';
3
+ }
@@ -0,0 +1 @@
1
+ export declare function formatUnavailableSubdomainReason(reason: string): string;
@@ -0,0 +1,7 @@
1
+ export function formatUnavailableSubdomainReason(reason) {
2
+ if (reason === 'already_taken') {
3
+ return 'Subdomain is already taken. Choose another.';
4
+ }
5
+ const reasonDetail = reason ? `: ${reason.replaceAll('_', ' ')}` : '';
6
+ return `Subdomain is unavailable${reasonDetail}. Choose another.`;
7
+ }
@@ -0,0 +1 @@
1
+ export declare function getDefaultProjectName(projectPath: string): Promise<string>;
@@ -0,0 +1,13 @@
1
+ import fs from 'fs/promises';
2
+ import path from 'path';
3
+ export async function getDefaultProjectName(projectPath) {
4
+ try {
5
+ const packageJson = JSON.parse(await fs.readFile(path.join(projectPath, 'package.json'), 'utf-8'));
6
+ if (typeof packageJson.name === 'string' && packageJson.name.trim()) {
7
+ return packageJson.name.replace(/^@[^/]+\//, '');
8
+ }
9
+ } catch {
10
+ // Fall back to directory name.
11
+ }
12
+ return path.basename(path.resolve(projectPath)) || 'figma-project';
13
+ }
@@ -0,0 +1,7 @@
1
+ import type { AuthCredential } from '../../auth/credentials.js';
2
+ interface PromptForAvailableSubdomainArgs {
3
+ credential: AuthCredential;
4
+ initialValue: string;
5
+ }
6
+ export declare function promptForAvailableSubdomain({ credential, initialValue, }: PromptForAvailableSubdomainArgs): Promise<string>;
7
+ export {};
@@ -0,0 +1,32 @@
1
+ import * as p from '@clack/prompts';
2
+ import pc from 'picocolors';
3
+ import { checkProjectSubdomainAvailability } from '../../api/check-project-subdomain-availability.js';
4
+ import { formatUnavailableSubdomainReason } from './format-unavailable-subdomain-reason.js';
5
+ import { validateSubdomain } from './validate-subdomain.js';
6
+ export async function promptForAvailableSubdomain({ credential, initialValue }) {
7
+ let nextInitialValue = initialValue;
8
+ while(true){
9
+ const promptedSubdomain = await p.text({
10
+ initialValue: nextInitialValue,
11
+ message: 'Project subdomain:',
12
+ validate: validateSubdomain
13
+ });
14
+ const subdomain = unwrapPrompt(promptedSubdomain).trim();
15
+ const availability = await checkProjectSubdomainAvailability({
16
+ credential,
17
+ subdomain
18
+ });
19
+ if (availability.available) {
20
+ return subdomain;
21
+ }
22
+ p.log.error(pc.red(formatUnavailableSubdomainReason(availability.reason)));
23
+ nextInitialValue = subdomain;
24
+ }
25
+ }
26
+ function unwrapPrompt(value) {
27
+ if (p.isCancel(value)) {
28
+ p.cancel('Operation cancelled');
29
+ process.exit(0);
30
+ }
31
+ return value;
32
+ }
@@ -0,0 +1,8 @@
1
+ import type { ProjectResourceType } from '../../api/project-resource-type.js';
2
+ interface ResolveProjectRegionArgs {
3
+ nonInteractive?: boolean;
4
+ resourceType: ProjectResourceType;
5
+ value?: string;
6
+ }
7
+ export declare function resolveProjectRegion({ nonInteractive, resourceType, value, }: ResolveProjectRegionArgs): Promise<string>;
8
+ export {};
@@ -0,0 +1,27 @@
1
+ import * as p from '@clack/prompts';
2
+ export async function resolveProjectRegion({ nonInteractive, resourceType, value }) {
3
+ if (value !== undefined) {
4
+ const region = value.trim();
5
+ if (!region) {
6
+ throw new Error('Region is required');
7
+ }
8
+ return region;
9
+ }
10
+ if (resourceType === 'vite' || nonInteractive) {
11
+ return 'us-east-1';
12
+ }
13
+ const selectedRegion = await p.select({
14
+ message: 'Select a region:',
15
+ options: [
16
+ {
17
+ label: 'US East (us-east-1)',
18
+ value: 'us-east-1'
19
+ }
20
+ ]
21
+ });
22
+ if (p.isCancel(selectedRegion)) {
23
+ p.cancel('Operation cancelled');
24
+ process.exit(0);
25
+ }
26
+ return selectedRegion;
27
+ }
@@ -0,0 +1,9 @@
1
+ import type { AuthCredential } from '../../auth/credentials.js';
2
+ interface ResolveProjectSubdomainArgs {
3
+ credential: AuthCredential;
4
+ initialValue: string;
5
+ nonInteractive?: boolean;
6
+ value?: string;
7
+ }
8
+ export declare function resolveProjectSubdomain({ credential, initialValue, nonInteractive, value, }: ResolveProjectSubdomainArgs): Promise<string>;
9
+ export {};
@@ -0,0 +1,54 @@
1
+ import * as p from '@clack/prompts';
2
+ import pc from 'picocolors';
3
+ import { checkProjectSubdomainAvailability } from '../../api/check-project-subdomain-availability.js';
4
+ import { formatUnavailableSubdomainReason } from './format-unavailable-subdomain-reason.js';
5
+ import { promptForAvailableSubdomain } from './prompt-for-available-subdomain.js';
6
+ import { validateSubdomain } from './validate-subdomain.js';
7
+ const GENERATED_SUBDOMAIN_ATTEMPT_COUNT = 5;
8
+ export async function resolveProjectSubdomain({ credential, initialValue, nonInteractive, value }) {
9
+ const providedSubdomain = value === undefined ? undefined : validateProvidedSubdomain(value);
10
+ if (!nonInteractive) {
11
+ if (providedSubdomain) {
12
+ const availability = await checkProjectSubdomainAvailability({
13
+ credential,
14
+ subdomain: providedSubdomain
15
+ });
16
+ if (availability.available) {
17
+ return providedSubdomain;
18
+ }
19
+ p.log.error(pc.red(formatUnavailableSubdomainReason(availability.reason)));
20
+ }
21
+ return promptForAvailableSubdomain({
22
+ credential,
23
+ initialValue: providedSubdomain ?? initialValue
24
+ });
25
+ }
26
+ const baseSubdomain = providedSubdomain ?? initialValue;
27
+ for(let attempt = 0; attempt < GENERATED_SUBDOMAIN_ATTEMPT_COUNT; attempt++){
28
+ const subdomain = attempt === 0 ? baseSubdomain : addRandomSuffix(baseSubdomain);
29
+ const availability = await checkProjectSubdomainAvailability({
30
+ credential,
31
+ subdomain
32
+ });
33
+ if (availability.available) {
34
+ return subdomain;
35
+ }
36
+ if (providedSubdomain) {
37
+ throw new Error(`${formatUnavailableSubdomainReason(availability.reason)} Pass a different --subdomain.`);
38
+ }
39
+ }
40
+ throw new Error(`Could not generate an available subdomain after ${GENERATED_SUBDOMAIN_ATTEMPT_COUNT} attempts. Pass --subdomain.`);
41
+ }
42
+ function validateProvidedSubdomain(value) {
43
+ const validationError = validateSubdomain(value);
44
+ if (validationError) {
45
+ throw new Error(validationError);
46
+ }
47
+ return value.trim();
48
+ }
49
+ function addRandomSuffix(value) {
50
+ // Append a hyphen and six random lowercase alphanumeric characters, e.g. `-a1b2c3`.
51
+ const suffix = Math.random().toString(36).slice(2, 8).padEnd(6, '0');
52
+ const prefix = value.slice(0, 53).replace(/-+$/g, '');
53
+ return `${prefix}-${suffix}`;
54
+ }
@@ -0,0 +1,9 @@
1
+ interface ResolveTextInputArgs {
2
+ fieldName: string;
3
+ initialValue: string;
4
+ message: string;
5
+ nonInteractive?: boolean;
6
+ value?: string;
7
+ }
8
+ export declare function resolveTextInput({ fieldName, initialValue, message, nonInteractive, value, }: ResolveTextInputArgs): Promise<string>;
9
+ export {};
@@ -0,0 +1,23 @@
1
+ import * as p from '@clack/prompts';
2
+ export async function resolveTextInput({ fieldName, initialValue, message, nonInteractive, value }) {
3
+ if (value !== undefined) {
4
+ const trimmedValue = value.trim();
5
+ if (!trimmedValue) {
6
+ throw new Error(`${fieldName} is required`);
7
+ }
8
+ return trimmedValue;
9
+ }
10
+ if (nonInteractive) {
11
+ return initialValue;
12
+ }
13
+ const promptedValue = await p.text({
14
+ initialValue,
15
+ message,
16
+ validate: (candidate)=>candidate?.trim() ? undefined : `${fieldName} is required`
17
+ });
18
+ if (p.isCancel(promptedValue)) {
19
+ p.cancel('Operation cancelled');
20
+ process.exit(0);
21
+ }
22
+ return promptedValue.trim();
23
+ }
@@ -0,0 +1,12 @@
1
+ interface ProjectWorkspace {
2
+ isDefault: boolean;
3
+ name: string;
4
+ planKey: string;
5
+ }
6
+ interface ResolveWorkspacePlanKeyArgs {
7
+ nonInteractive?: boolean;
8
+ value?: string;
9
+ workspaces: ProjectWorkspace[];
10
+ }
11
+ export declare function resolveWorkspacePlanKey({ nonInteractive, value, workspaces, }: ResolveWorkspacePlanKeyArgs): Promise<string>;
12
+ export {};
@@ -0,0 +1,36 @@
1
+ import * as p from '@clack/prompts';
2
+ export async function resolveWorkspacePlanKey({ nonInteractive, value, workspaces }) {
3
+ if (value !== undefined) {
4
+ const planKey = value.trim();
5
+ const workspace = workspaces.find((candidate)=>candidate.planKey === planKey);
6
+ if (!workspace) {
7
+ throw new Error(`Workspace plan key "${planKey}" is not eligible. Available: ${formatWorkspaces(workspaces)}`);
8
+ }
9
+ return workspace.planKey;
10
+ }
11
+ if (workspaces.length === 1) {
12
+ return workspaces[0].planKey;
13
+ }
14
+ if (nonInteractive) {
15
+ const defaultWorkspace = workspaces.find((workspace)=>workspace.isDefault);
16
+ if (defaultWorkspace) {
17
+ return defaultWorkspace.planKey;
18
+ }
19
+ throw new Error(`Multiple eligible Figma workspaces. Pass --workspace <plan-key>. Available: ${formatWorkspaces(workspaces)}`);
20
+ }
21
+ const selectedWorkspacePlanKey = await p.select({
22
+ message: 'Select a Figma workspace:',
23
+ options: workspaces.map((workspace)=>({
24
+ label: workspace.name,
25
+ value: workspace.planKey
26
+ }))
27
+ });
28
+ if (p.isCancel(selectedWorkspacePlanKey)) {
29
+ p.cancel('Operation cancelled');
30
+ process.exit(0);
31
+ }
32
+ return selectedWorkspacePlanKey;
33
+ }
34
+ function formatWorkspaces(workspaces) {
35
+ return workspaces.map((workspace)=>`${workspace.name} (${workspace.planKey})`).join(', ');
36
+ }
@@ -0,0 +1 @@
1
+ export declare function validateSubdomain(value: string | undefined): "Subdomain is required" | "Use 1–60 lowercase letters, numbers, or hyphens" | undefined;
@@ -0,0 +1,9 @@
1
+ export function validateSubdomain(value) {
2
+ if (!value?.trim()) {
3
+ return 'Subdomain is required';
4
+ }
5
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,58}[a-z0-9])?$/.test(value.trim())) {
6
+ return 'Use 1–60 lowercase letters, numbers, or hyphens';
7
+ }
8
+ return undefined;
9
+ }
@@ -0,0 +1,24 @@
1
+ import type { ProjectResourceType } from '../api/project-resource-type.js';
2
+ import type { AuthCredential } from '../auth/credentials.js';
3
+ interface ProjectCreationInputs {
4
+ description?: string;
5
+ name?: string;
6
+ region?: string;
7
+ subdomain?: string;
8
+ workspacePlanKey?: string;
9
+ }
10
+ interface PromptToCreateProjectArgs {
11
+ credential: AuthCredential;
12
+ inputs?: ProjectCreationInputs;
13
+ nonInteractive?: boolean;
14
+ projectPath: string;
15
+ resourceType: ProjectResourceType;
16
+ }
17
+ interface PromptToCreateProjectResponse {
18
+ domainName: string;
19
+ id: string;
20
+ name: string;
21
+ }
22
+ /** Prompt for required project fields and create a blank Figma CMS project. */
23
+ export declare function promptToCreateProject({ credential, inputs, nonInteractive, projectPath, resourceType, }: PromptToCreateProjectArgs): Promise<PromptToCreateProjectResponse>;
24
+ export {};
@@ -0,0 +1,69 @@
1
+ import * as p from '@clack/prompts';
2
+ import pc from 'picocolors';
3
+ import { createProject } from '../api/create-project.js';
4
+ import { listProjectWorkspaces } from '../api/list-project-workspaces.js';
5
+ import { formatProjectSubdomain } from './prompt-to-create-project/format-project-subdomain.js';
6
+ import { getDefaultProjectName } from './prompt-to-create-project/get-default-project-name.js';
7
+ import { resolveProjectRegion } from './prompt-to-create-project/resolve-project-region.js';
8
+ import { resolveProjectSubdomain } from './prompt-to-create-project/resolve-project-subdomain.js';
9
+ import { resolveTextInput } from './prompt-to-create-project/resolve-text-input.js';
10
+ import { resolveWorkspacePlanKey } from './prompt-to-create-project/resolve-workspace-plan-key.js';
11
+ /** Prompt for required project fields and create a blank Figma CMS project. */ export async function promptToCreateProject({ credential, inputs, nonInteractive, projectPath, resourceType }) {
12
+ const workspaces = await listProjectWorkspaces(credential);
13
+ if (workspaces.length === 0) {
14
+ if (nonInteractive) {
15
+ throw new Error('No eligible Figma workspaces found.');
16
+ }
17
+ p.log.error(pc.red('No eligible Figma workspaces found.'));
18
+ process.exit(1);
19
+ }
20
+ const defaultProjectName = await getDefaultProjectName(projectPath);
21
+ const projectName = await resolveTextInput({
22
+ fieldName: 'Project name',
23
+ initialValue: defaultProjectName,
24
+ message: 'Project name:',
25
+ nonInteractive,
26
+ value: inputs?.name
27
+ });
28
+ const projectDescription = await resolveTextInput({
29
+ fieldName: 'Description',
30
+ initialValue: `${projectName} project`,
31
+ message: 'Project description:',
32
+ nonInteractive,
33
+ value: inputs?.description
34
+ });
35
+ const projectSubdomain = await resolveProjectSubdomain({
36
+ credential,
37
+ initialValue: formatProjectSubdomain(projectName),
38
+ nonInteractive,
39
+ value: inputs?.subdomain
40
+ });
41
+ const parentPlanKey = await resolveWorkspacePlanKey({
42
+ nonInteractive,
43
+ value: inputs?.workspacePlanKey,
44
+ workspaces
45
+ });
46
+ const region = await resolveProjectRegion({
47
+ nonInteractive,
48
+ resourceType,
49
+ value: inputs?.region
50
+ });
51
+ const spinner = p.spinner();
52
+ spinner.start('Creating Figma project...');
53
+ try {
54
+ const project = await createProject({
55
+ name: projectName,
56
+ credential,
57
+ description: projectDescription,
58
+ parentPlanKey,
59
+ region,
60
+ resourceType,
61
+ subdomain: projectSubdomain
62
+ });
63
+ spinner.stop(pc.green(`✓ Project created: ${project.domainName}`));
64
+ return project;
65
+ } catch (error) {
66
+ spinner.stop(pc.red('✗ Failed to create project'));
67
+ throw error;
68
+ }
69
+ }
@@ -0,0 +1,12 @@
1
+ export interface SetupAgentOptions {
2
+ global?: boolean;
3
+ project?: boolean;
4
+ yes?: boolean;
5
+ }
6
+ /** Install or update the bundled deploy skill through the standard skills CLI. */
7
+ export declare function setupAgentCommand(options: SetupAgentOptions, dependencies?: {
8
+ homeDir?: string;
9
+ isTTY?: boolean;
10
+ projectDir?: string;
11
+ skillDir?: string;
12
+ }): Promise<void>;
@@ -0,0 +1,123 @@
1
+ import * as p from '@clack/prompts';
2
+ import spawn from 'cross-spawn';
3
+ import crypto from 'node:crypto';
4
+ import fs from 'node:fs/promises';
5
+ import { createRequire } from 'node:module';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ const SKILL_NAME = 'deploy-to-figma';
9
+ const require = createRequire(import.meta.url);
10
+ const SKILLS_CLI_PATH = require.resolve('skills/bin/cli.mjs');
11
+ /** Install or update the bundled deploy skill through the standard skills CLI. */ export async function setupAgentCommand(options, dependencies = {}) {
12
+ if (options.global && options.project) {
13
+ throw new Error('Use either --global or --project, not both.');
14
+ }
15
+ const isTTY = dependencies.isTTY ?? Boolean(process.stdin.isTTY && process.stdout.isTTY);
16
+ const scope = await resolveScope(options, isTTY);
17
+ const projectDir = dependencies.projectDir ?? process.cwd();
18
+ const homeDir = dependencies.homeDir ?? os.homedir();
19
+ const skillDir = dependencies.skillDir ?? resolveBundledSkillDir();
20
+ const installedDir = path.join(scope === 'global' ? homeDir : projectDir, '.agents', 'skills', SKILL_NAME);
21
+ const [bundledHash, installedHash] = await Promise.all([
22
+ hashDirectory(skillDir),
23
+ hashDirectory(installedDir)
24
+ ]);
25
+ if (!bundledHash) {
26
+ throw new Error(`Bundled ${SKILL_NAME} skill was not found at ${skillDir}.`);
27
+ }
28
+ if (bundledHash === installedHash) {
29
+ p.log.success(`✓ ${SKILL_NAME} skill is already up to date (${scope})`);
30
+ return;
31
+ }
32
+ p.log.step(`${installedHash ? 'Updating' : 'Installing'} ${SKILL_NAME} skill (${scope})...`);
33
+ const args = [
34
+ 'add',
35
+ skillDir,
36
+ '--skill',
37
+ SKILL_NAME,
38
+ '--copy',
39
+ ...scope === 'global' ? [
40
+ '--global'
41
+ ] : [],
42
+ ...options.yes || !isTTY ? [
43
+ '--yes'
44
+ ] : []
45
+ ];
46
+ const exitCode = await run(process.execPath, [
47
+ SKILLS_CLI_PATH,
48
+ ...args
49
+ ], projectDir);
50
+ if (exitCode !== 0) {
51
+ throw new Error(`Skill installation failed with exit code ${exitCode}.`);
52
+ }
53
+ p.log.success(`✓ ${SKILL_NAME} skill ${installedHash ? 'updated' : 'installed'} (${scope})`);
54
+ }
55
+ async function resolveScope(options, isTTY) {
56
+ if (options.global) {
57
+ return 'global';
58
+ }
59
+ if (options.project) {
60
+ return 'project';
61
+ }
62
+ if (!isTTY) {
63
+ throw new Error('Non-interactive setup requires either --global or --project.');
64
+ }
65
+ const selected = await p.select({
66
+ initialValue: 'global',
67
+ message: 'Where should the Figma deploy skill be installed?',
68
+ options: [
69
+ {
70
+ label: 'Globally (recommended)',
71
+ value: 'global'
72
+ },
73
+ {
74
+ label: 'Current project only',
75
+ value: 'project'
76
+ }
77
+ ]
78
+ });
79
+ if (p.isCancel(selected)) {
80
+ throw new Error('Skill installation cancelled.');
81
+ }
82
+ return selected;
83
+ }
84
+ function resolveBundledSkillDir() {
85
+ return path.resolve(import.meta.dirname, '..', 'skills', SKILL_NAME);
86
+ }
87
+ async function hashDirectory(directory) {
88
+ if (!await pathExists(directory)) {
89
+ return null;
90
+ }
91
+ const hash = crypto.createHash('sha256');
92
+ async function visit(currentDir, relativeDir = '') {
93
+ const entries = await fs.readdir(currentDir, {
94
+ withFileTypes: true
95
+ });
96
+ entries.sort((left, right)=>left.name.localeCompare(right.name));
97
+ for (const entry of entries){
98
+ const relativePath = path.join(relativeDir, entry.name);
99
+ const absolutePath = path.join(currentDir, entry.name);
100
+ if (entry.isDirectory()) {
101
+ await visit(absolutePath, relativePath);
102
+ } else if (entry.isFile()) {
103
+ hash.update(relativePath);
104
+ hash.update(await fs.readFile(absolutePath));
105
+ }
106
+ }
107
+ }
108
+ await visit(directory);
109
+ return hash.digest('hex');
110
+ }
111
+ function run(command, args, cwd) {
112
+ return new Promise((resolve, reject)=>{
113
+ const child = spawn(command, args, {
114
+ cwd,
115
+ stdio: 'inherit'
116
+ });
117
+ child.once('error', reject);
118
+ child.once('close', (code)=>resolve(code ?? 1));
119
+ });
120
+ }
121
+ async function pathExists(filePath) {
122
+ return fs.access(filePath).then(()=>true).catch(()=>false);
123
+ }