@payloadcms/figma 0.0.1-alpha.5 → 0.0.1-alpha.50

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 (326) hide show
  1. package/dist/api/control-plane.d.ts +31 -1
  2. package/dist/api/control-plane.js +137 -67
  3. package/dist/api/figma-api.d.ts +20 -0
  4. package/dist/api/figma-api.js +77 -21
  5. package/dist/auth/callback-server.js +2 -1
  6. package/dist/auth/crypto-utils.js +5 -5
  7. package/dist/auth/jwt-validator.d.ts +2 -1
  8. package/dist/auth/jwt-validator.js +2 -2
  9. package/dist/auth/oauth-flow.d.ts +1 -1
  10. package/dist/auth/oauth-flow.js +15 -11
  11. package/dist/auth/project-token.js +11 -6
  12. package/dist/auth/refresh.d.ts +2 -1
  13. package/dist/auth/refresh.js +25 -12
  14. package/dist/auth/token-store.d.ts +40 -1
  15. package/dist/auth/token-store.js +65 -5
  16. package/dist/auth/types.d.ts +17 -4
  17. package/dist/cli.js +54 -6
  18. package/dist/commands/build-lambda-zip.d.ts +5 -0
  19. package/dist/commands/build-lambda-zip.js +19 -0
  20. package/dist/commands/debug.d.ts +8 -0
  21. package/dist/commands/debug.js +161 -0
  22. package/dist/commands/deploy.d.ts +6 -0
  23. package/dist/commands/deploy.js +94 -126
  24. package/dist/commands/env.d.ts +13 -0
  25. package/dist/commands/env.js +88 -0
  26. package/dist/commands/init.d.ts +3 -5
  27. package/dist/commands/init.js +118 -94
  28. package/dist/commands/list-tokens.d.ts +3 -3
  29. package/dist/commands/list-tokens.js +22 -7
  30. package/dist/commands/login.d.ts +8 -1
  31. package/dist/commands/login.js +30 -12
  32. package/dist/commands/logout.d.ts +5 -4
  33. package/dist/commands/logout.js +56 -13
  34. package/dist/config/oauth.d.ts +4 -14
  35. package/dist/config/oauth.js +18 -40
  36. package/dist/constants.d.ts +36 -19
  37. package/dist/constants.js +58 -20
  38. package/dist/db-content-api/README.md +98 -0
  39. package/dist/db-content-api/generated/content-api-types.d.ts +3746 -0
  40. package/dist/db-content-api/generated/content-api-types.js +7 -0
  41. package/dist/db-content-api/index.d.ts +20 -0
  42. package/dist/db-content-api/index.js +702 -0
  43. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  44. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  45. package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
  46. package/dist/db-content-api/temp-utilities/sorting.js +32 -0
  47. package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
  48. package/dist/db-content-api/temp-utilities/types.js +15 -0
  49. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +34 -0
  50. package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
  51. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  52. package/dist/db-content-api/utilities/auth.js +81 -0
  53. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
  54. package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
  55. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
  56. package/dist/db-content-api/utilities/data/castFieldValue.js +69 -0
  57. package/dist/db-content-api/utilities/data/index.d.ts +42 -0
  58. package/dist/db-content-api/utilities/data/index.js +211 -0
  59. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
  60. package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
  61. package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
  62. package/dist/db-content-api/utilities/data/stripFields.js +195 -0
  63. package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
  64. package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
  65. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  66. package/dist/db-content-api/utilities/joins.js +136 -0
  67. package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
  68. package/dist/db-content-api/utilities/locale/index.js +21 -0
  69. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
  70. package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +66 -0
  71. package/dist/db-content-api/utilities/meta/buildMeta.d.ts +37 -0
  72. package/dist/db-content-api/utilities/meta/buildMeta.js +33 -0
  73. package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +13 -0
  74. package/dist/db-content-api/utilities/meta/buildPathTypes.js +181 -0
  75. package/dist/db-content-api/utilities/where.d.ts +20 -0
  76. package/dist/db-content-api/utilities/where.js +127 -0
  77. package/dist/endpoints/health.d.ts +3 -0
  78. package/dist/endpoints/health.js +11 -0
  79. package/dist/endpoints/schema.d.ts +3 -0
  80. package/dist/endpoints/schema.js +29 -0
  81. package/dist/exports/client.d.ts +3 -0
  82. package/dist/exports/client.js +3 -0
  83. package/dist/index.d.ts +2 -1
  84. package/dist/index.js +3 -1
  85. package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
  86. package/dist/oauth/components/FigmaAvatar/index.js +27 -0
  87. package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
  88. package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
  89. package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
  90. package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
  91. package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
  92. package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
  93. package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
  94. package/dist/oauth/components/LoginButton/index.js +50 -6
  95. package/dist/oauth/components/LoginButton/index.scss +50 -3
  96. package/dist/oauth/components/LogoutButton/index.js +5 -4
  97. package/dist/oauth/defaults.js +67 -10
  98. package/dist/oauth/endpoints/getLoginEndpoint.js +69 -24
  99. package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
  100. package/dist/oauth/index.js +40 -5
  101. package/dist/oauth/strategy/index.d.ts +0 -2
  102. package/dist/oauth/strategy/index.js +40 -17
  103. package/dist/oauth/types.d.ts +6 -6
  104. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  105. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  106. package/dist/oauth/utilities/refreshTokens.js +3 -3
  107. package/dist/plugin/build-config.d.ts +21 -14
  108. package/dist/plugin/build-config.js +208 -17
  109. package/dist/storage-content-api/api-types.d.ts +168 -0
  110. package/dist/storage-content-api/api-types.js +6 -0
  111. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
  112. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
  113. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
  114. package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
  115. package/dist/storage-content-api/client.d.ts +6 -0
  116. package/dist/storage-content-api/client.js +36 -0
  117. package/dist/storage-content-api/generateURL.d.ts +7 -0
  118. package/dist/storage-content-api/generateURL.js +8 -0
  119. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  120. package/dist/storage-content-api/handleDelete.js +17 -0
  121. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  122. package/dist/storage-content-api/handleUpload.js +144 -0
  123. package/dist/storage-content-api/index.d.ts +5 -0
  124. package/dist/storage-content-api/index.js +31 -0
  125. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  126. package/dist/storage-content-api/staticHandler.js +56 -0
  127. package/dist/storage-content-api/types.d.ts +10 -0
  128. package/dist/storage-content-api/types.js +3 -0
  129. package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
  130. package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
  131. package/dist/storage-content-api/utilities/index.d.ts +2 -0
  132. package/dist/storage-content-api/utilities/index.js +3 -0
  133. package/dist/templates/.env.example +5 -0
  134. package/dist/templates/README.md +19 -0
  135. package/dist/types/config.d.ts +2 -1
  136. package/dist/types/config.js +0 -2
  137. package/dist/types.d.ts +3 -1
  138. package/dist/utils/asset-collection.d.ts +3 -6
  139. package/dist/utils/asset-collection.js +10 -34
  140. package/dist/utils/build-lambda-zip.d.ts +14 -0
  141. package/dist/utils/build-lambda-zip.js +81 -0
  142. package/dist/utils/cache-bootstrap.d.ts +8 -0
  143. package/dist/utils/cache-bootstrap.js +18 -0
  144. package/dist/utils/config.js +1 -1
  145. package/dist/utils/env-management.d.ts +16 -7
  146. package/dist/utils/env-management.js +85 -64
  147. package/dist/utils/format-env-suffix.d.ts +12 -0
  148. package/dist/utils/format-env-suffix.js +13 -0
  149. package/dist/utils/formatter.js +3 -5
  150. package/dist/utils/lambda-config.d.ts +3 -1
  151. package/dist/utils/lambda-config.js +38 -32
  152. package/dist/utils/messages.d.ts +1 -1
  153. package/dist/utils/messages.js +22 -8
  154. package/dist/utils/package-manager.d.ts +24 -0
  155. package/dist/utils/package-manager.js +53 -0
  156. package/dist/utils/payload-config-ast.d.ts +22 -3
  157. package/dist/utils/payload-config-ast.js +96 -31
  158. package/dist/utils/payload-config-finder.d.ts +2 -2
  159. package/dist/utils/payload-config-finder.js +48 -9
  160. package/dist/utils/payload-config-modifier.d.ts +1 -1
  161. package/dist/utils/payload-config-modifier.js +58 -9
  162. package/dist/utils/payload-package-check.d.ts +12 -1
  163. package/dist/utils/payload-package-check.js +63 -5
  164. package/dist/utils/project.d.ts +3 -2
  165. package/dist/utils/project.js +15 -7
  166. package/dist/utils/resolve-environment.d.ts +14 -0
  167. package/dist/utils/resolve-environment.js +28 -0
  168. package/dist/utils/s3-upload.d.ts +0 -1
  169. package/dist/utils/s3-upload.js +10 -3
  170. package/dist/utils/token-display.js +11 -5
  171. package/dist/utils/typescript-validator.js +4 -6
  172. package/dist/utils/version-check.d.ts +3 -0
  173. package/dist/utils/version-check.js +38 -0
  174. package/package.json +29 -10
  175. package/dist/api/control-plane.d.ts.map +0 -1
  176. package/dist/api/control-plane.js.map +0 -1
  177. package/dist/api/figma-api.d.ts.map +0 -1
  178. package/dist/api/figma-api.js.map +0 -1
  179. package/dist/auth/browser.d.ts.map +0 -1
  180. package/dist/auth/browser.js.map +0 -1
  181. package/dist/auth/callback-server.d.ts.map +0 -1
  182. package/dist/auth/callback-server.js.map +0 -1
  183. package/dist/auth/crypto-utils.d.ts.map +0 -1
  184. package/dist/auth/crypto-utils.js.map +0 -1
  185. package/dist/auth/jwt-validator.d.ts.map +0 -1
  186. package/dist/auth/jwt-validator.js.map +0 -1
  187. package/dist/auth/oauth-flow.d.ts.map +0 -1
  188. package/dist/auth/oauth-flow.js.map +0 -1
  189. package/dist/auth/pkce.d.ts.map +0 -1
  190. package/dist/auth/pkce.js.map +0 -1
  191. package/dist/auth/project-token.d.ts.map +0 -1
  192. package/dist/auth/project-token.js.map +0 -1
  193. package/dist/auth/refresh.d.ts.map +0 -1
  194. package/dist/auth/refresh.js.map +0 -1
  195. package/dist/auth/token-store.d.ts.map +0 -1
  196. package/dist/auth/token-store.js.map +0 -1
  197. package/dist/auth/types.d.ts.map +0 -1
  198. package/dist/auth/types.js.map +0 -1
  199. package/dist/cli.d.ts.map +0 -1
  200. package/dist/cli.js.map +0 -1
  201. package/dist/commands/deploy.d.ts.map +0 -1
  202. package/dist/commands/deploy.js.map +0 -1
  203. package/dist/commands/init.d.ts.map +0 -1
  204. package/dist/commands/init.js.map +0 -1
  205. package/dist/commands/list-tokens.d.ts.map +0 -1
  206. package/dist/commands/list-tokens.js.map +0 -1
  207. package/dist/commands/login.d.ts.map +0 -1
  208. package/dist/commands/login.js.map +0 -1
  209. package/dist/commands/logout.d.ts.map +0 -1
  210. package/dist/commands/logout.js.map +0 -1
  211. package/dist/config/oauth.d.ts.map +0 -1
  212. package/dist/config/oauth.js.map +0 -1
  213. package/dist/constants.d.ts.map +0 -1
  214. package/dist/constants.js.map +0 -1
  215. package/dist/exports/client.d.ts.map +0 -1
  216. package/dist/exports/client.js.map +0 -1
  217. package/dist/index.d.ts.map +0 -1
  218. package/dist/index.js.map +0 -1
  219. package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
  220. package/dist/oauth/components/LoginButton/index.js.map +0 -1
  221. package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
  222. package/dist/oauth/components/LogoutButton/index.js.map +0 -1
  223. package/dist/oauth/defaults.d.ts.map +0 -1
  224. package/dist/oauth/defaults.js.map +0 -1
  225. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
  226. package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
  227. package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
  228. package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
  229. package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
  230. package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
  231. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
  232. package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
  233. package/dist/oauth/exports/client.d.ts.map +0 -1
  234. package/dist/oauth/exports/client.js.map +0 -1
  235. package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
  236. package/dist/oauth/hooks/afterLogout.js.map +0 -1
  237. package/dist/oauth/hooks/me.d.ts.map +0 -1
  238. package/dist/oauth/hooks/me.js.map +0 -1
  239. package/dist/oauth/hooks/refresh.d.ts.map +0 -1
  240. package/dist/oauth/hooks/refresh.js.map +0 -1
  241. package/dist/oauth/index.d.ts.map +0 -1
  242. package/dist/oauth/index.js.map +0 -1
  243. package/dist/oauth/strategy/index.d.ts.map +0 -1
  244. package/dist/oauth/strategy/index.js.map +0 -1
  245. package/dist/oauth/types.d.ts.map +0 -1
  246. package/dist/oauth/types.js.map +0 -1
  247. package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
  248. package/dist/oauth/utilities/clearCookie.js.map +0 -1
  249. package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
  250. package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
  251. package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
  252. package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
  253. package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
  254. package/dist/oauth/utilities/extractOrigin.js.map +0 -1
  255. package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
  256. package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
  257. package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
  258. package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
  259. package/dist/oauth/utilities/getAdminPath.js +0 -9
  260. package/dist/oauth/utilities/getAdminPath.js.map +0 -1
  261. package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
  262. package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
  263. package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
  264. package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
  265. package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
  266. package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
  267. package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
  268. package/dist/oauth/utilities/getTokenExp.js.map +0 -1
  269. package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
  270. package/dist/oauth/utilities/getUsernameField.js.map +0 -1
  271. package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
  272. package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
  273. package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
  274. package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
  275. package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
  276. package/dist/oauth/utilities/refreshTokens.js.map +0 -1
  277. package/dist/plugin/adapter.d.ts.map +0 -1
  278. package/dist/plugin/adapter.js.map +0 -1
  279. package/dist/plugin/build-config.d.ts.map +0 -1
  280. package/dist/plugin/build-config.js.map +0 -1
  281. package/dist/types/config.d.ts.map +0 -1
  282. package/dist/types/config.js.map +0 -1
  283. package/dist/types.d.ts.map +0 -1
  284. package/dist/types.js.map +0 -1
  285. package/dist/utils/asset-collection.d.ts.map +0 -1
  286. package/dist/utils/asset-collection.js.map +0 -1
  287. package/dist/utils/build-detection.d.ts.map +0 -1
  288. package/dist/utils/build-detection.js.map +0 -1
  289. package/dist/utils/config.d.ts.map +0 -1
  290. package/dist/utils/config.js.map +0 -1
  291. package/dist/utils/download-template.d.ts.map +0 -1
  292. package/dist/utils/download-template.js.map +0 -1
  293. package/dist/utils/env-management.d.ts.map +0 -1
  294. package/dist/utils/env-management.js.map +0 -1
  295. package/dist/utils/format.d.ts.map +0 -1
  296. package/dist/utils/format.js.map +0 -1
  297. package/dist/utils/formatter.d.ts.map +0 -1
  298. package/dist/utils/formatter.js.map +0 -1
  299. package/dist/utils/git.d.ts.map +0 -1
  300. package/dist/utils/git.js.map +0 -1
  301. package/dist/utils/is-debug.d.ts.map +0 -1
  302. package/dist/utils/is-debug.js.map +0 -1
  303. package/dist/utils/lambda-config.d.ts.map +0 -1
  304. package/dist/utils/lambda-config.js.map +0 -1
  305. package/dist/utils/log.d.ts.map +0 -1
  306. package/dist/utils/log.js.map +0 -1
  307. package/dist/utils/messages.d.ts.map +0 -1
  308. package/dist/utils/messages.js.map +0 -1
  309. package/dist/utils/package-manager.d.ts.map +0 -1
  310. package/dist/utils/package-manager.js.map +0 -1
  311. package/dist/utils/payload-config-ast.d.ts.map +0 -1
  312. package/dist/utils/payload-config-ast.js.map +0 -1
  313. package/dist/utils/payload-config-finder.d.ts.map +0 -1
  314. package/dist/utils/payload-config-finder.js.map +0 -1
  315. package/dist/utils/payload-config-modifier.d.ts.map +0 -1
  316. package/dist/utils/payload-config-modifier.js.map +0 -1
  317. package/dist/utils/payload-package-check.d.ts.map +0 -1
  318. package/dist/utils/payload-package-check.js.map +0 -1
  319. package/dist/utils/project.d.ts.map +0 -1
  320. package/dist/utils/project.js.map +0 -1
  321. package/dist/utils/s3-upload.d.ts.map +0 -1
  322. package/dist/utils/s3-upload.js.map +0 -1
  323. package/dist/utils/token-display.d.ts.map +0 -1
  324. package/dist/utils/token-display.js.map +0 -1
  325. package/dist/utils/typescript-validator.d.ts.map +0 -1
  326. package/dist/utils/typescript-validator.js.map +0 -1
@@ -1,19 +1,9 @@
1
1
  import type { OAuthConfig } from '../auth/types.js';
2
- export declare const URLS: Record<'prod' | 'staging', Pick<OAuthConfig, 'authorizationUrl' | 'refreshUrl' | 'tokenUrl'>>;
2
+ export declare const DEFAULT_CALLBACK_PORT = 34462;
3
3
  /**
4
- * Figma OAuth2 configuration for public CLI client
5
- *
6
- * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
7
- * No client secret is used because CLIs cannot securely store secrets.
8
- * PKCE provides security through the code_verifier/code_challenge mechanism.
9
- *
10
- * For production use, register a public OAuth app with Figma.
11
- * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
12
- */
13
- export declare const OAUTH_CONFIG: OAuthConfig;
14
- /**
15
- * Buffer time (in seconds) before token expiration to consider token as expired
16
- * This helps avoid using tokens that are about to expire
4
+ * Get OAuth configuration for current environment
5
+ * Uses getEnvConfig() to determine staging vs production
17
6
  */
7
+ export declare function getOAuthConfig(): OAuthConfig;
18
8
  export declare const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
19
9
  //# sourceMappingURL=oauth.d.ts.map
@@ -1,43 +1,21 @@
1
- import { FIGMA_CLIENT_IDS } from '../constants.js';
2
- export const URLS = {
3
- prod: {
4
- authorizationUrl: 'https://www.figma.com/oauth',
5
- refreshUrl: 'https://api.figma.com/v1/oauth/refresh',
6
- tokenUrl: 'https://api.figma.com/v1/oauth/token'
7
- },
8
- staging: {
9
- authorizationUrl: 'https://staging.figma.com/oauth',
10
- refreshUrl: 'https://api.staging.figma.com/v1/oauth/refresh',
11
- tokenUrl: 'https://api.staging.figma.com/v1/oauth/token'
12
- }
13
- };
1
+ import { getEnvConfig } from '../constants.js';
2
+ export const DEFAULT_CALLBACK_PORT = 34462;
14
3
  /**
15
- * Figma OAuth2 configuration for public CLI client
16
- *
17
- * This is a PUBLIC OAuth client using PKCE (Proof Key for Code Exchange).
18
- * No client secret is used because CLIs cannot securely store secrets.
19
- * PKCE provides security through the code_verifier/code_challenge mechanism.
20
- *
21
- * For production use, register a public OAuth app with Figma.
22
- * To register an OAuth app, visit: https://www.figma.com/developers/api#oauth2
23
- */ export const OAUTH_CONFIG = {
24
- // OAuth client ID (public client)
25
- // Uses staging client ID by default since we use staging endpoints
26
- clientId: process.env.FIGMA_CLIENT_ID || FIGMA_CLIENT_IDS.staging,
27
- // No client secret - this is a public OAuth client using PKCE
28
- // Public clients cannot securely store secrets in CLI environments
29
- redirectUri: process.env.FIGMA_REDIRECT_URI || 'http://localhost:3000/callback',
30
- // Only current_user:read scope is needed for basic user info
31
- scopes: [
32
- 'current_user:read'
33
- ],
34
- // TODO: Dynamically choose between prod and staging based on environment
35
- ...URLS.staging
36
- };
37
- /**
38
- * Buffer time (in seconds) before token expiration to consider token as expired
39
- * This helps avoid using tokens that are about to expire
40
- */ export const TOKEN_EXPIRY_BUFFER_SECONDS = 300 // 5 minutes
41
- ;
4
+ * Get OAuth configuration for current environment
5
+ * Uses getEnvConfig() to determine staging vs production
6
+ */ export function getOAuthConfig() {
7
+ const { apiBaseUrl, authorizationUrl, clientId } = getEnvConfig();
8
+ return {
9
+ authorizationUrl,
10
+ clientId: process.env.FIGMA_CLIENT_ID || clientId,
11
+ redirectUri: process.env.FIGMA_REDIRECT_URI || `http://localhost:${DEFAULT_CALLBACK_PORT}/callback`,
12
+ refreshUrl: `${apiBaseUrl}/v1/oauth/refresh`,
13
+ scopes: [
14
+ 'current_user:read'
15
+ ],
16
+ tokenUrl: `${apiBaseUrl}/v1/oauth/token`
17
+ };
18
+ }
19
+ export const TOKEN_EXPIRY_BUFFER_SECONDS = 300;
42
20
 
43
21
  //# sourceMappingURL=oauth.js.map
@@ -1,27 +1,44 @@
1
- export declare const FIGMA_CLIENT_IDS: {
2
- production: string;
3
- staging: string;
4
- };
5
- export declare const JWKS_URI: {
6
- production: string;
7
- staging: string;
8
- };
9
1
  /**
10
- * Figma environment (production or staging)
2
+ * Figma infrastructure environment (production or staging)
11
3
  */
12
4
  export type Environment = 'production' | 'staging';
5
+ type EnvironmentConfig = {
6
+ /** Figma API base URL. Override: FIGMA_API_BASE_URL */
7
+ apiBaseUrl: string;
8
+ /** OAuth authorization URL (CLI auth) */
9
+ authorizationUrl: string;
10
+ /** OAuth client ID. Override: FIGMA_CLIENT_ID or FIGMA_OAUTH_CLIENT_ID */
11
+ clientId: string;
12
+ /** Content API base URL. Override: FIGMA_CONTENT_API_URL */
13
+ contentApiUrl: string;
14
+ /** OIDC discovery endpoint */
15
+ identityMetadata: string;
16
+ /** JSON Web Key Set URL for token validation */
17
+ jwksUri: string;
18
+ };
19
+ /**
20
+ * Environment-specific configuration for Figma integration.
21
+ * Selected via FIGMA_INFRA_ENV ('production' | 'staging'), defaults to 'production'.
22
+ */
23
+ export declare const ENV_CONFIG: Record<Environment, EnvironmentConfig>;
24
+ /**
25
+ * User-facing error message when Content API returns 404 or 410.
26
+ * Used across CLI commands and the db adapter for consistent messaging.
27
+ */
28
+ export declare const CONTENT_SYSTEM_NOT_FOUND_MESSAGE = "Content system not found. Verify your Content System ID is correct, or contact your team admin for assistance.";
29
+ /**
30
+ * Set infrastructure environment override (used by --infra-env CLI flag)
31
+ * Pass undefined to clear the override
32
+ */
33
+ export declare function setInfraEnvironment(env: Environment | undefined): void;
13
34
  /**
14
- * Get current Figma environment from environment variable
15
- * Defaults to 'staging' if not specified
16
- *
17
- * @returns Current environment
35
+ * Get current Figma infrastructure environment
36
+ * Priority: 1) setInfraEnvironment override, 2) FIGMA_INFRA_ENV env var, 3) .env file, 4) 'production' default
18
37
  */
19
- export declare function getEnvironment(): Environment;
20
38
  /**
21
- * Get JWKS URI for a given environment
22
- *
23
- * @param env - Environment (defaults to current environment)
24
- * @returns JWKS URI for the environment
39
+ * Get the resolved EnvironmentConfig for the current infrastructure environment
25
40
  */
26
- export declare function getJWKSUri(env?: Environment): string;
41
+ export declare function getEnvConfig(): EnvironmentConfig;
42
+ export declare function getInfraEnvironment(): Environment;
43
+ export {};
27
44
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -1,27 +1,65 @@
1
- export const FIGMA_CLIENT_IDS = {
2
- production: '',
3
- staging: 'wqAToBAp4UI9AZ5M6wTfT9'
4
- };
5
- export const JWKS_URI = {
6
- production: 'https://static.figmacontent.com/.well_known/jwks.json',
7
- staging: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
1
+ import { getEnvVarSync } from './utils/env-management.js';
2
+ /**
3
+ * Environment-specific configuration for Figma integration.
4
+ * Selected via FIGMA_INFRA_ENV ('production' | 'staging'), defaults to 'production'.
5
+ */ export const ENV_CONFIG = {
6
+ production: {
7
+ apiBaseUrl: 'https://api.figma.com',
8
+ authorizationUrl: 'https://www.figma.com/oauth',
9
+ clientId: 'lelKVTAzOekFnirnlAMbuD',
10
+ contentApiUrl: 'https://us-east-1.cms-tenants-001-production.figmacontent.com',
11
+ identityMetadata: 'https://www.figma.com/.well-known/openid-configuration',
12
+ jwksUri: 'https://static.figmacontent.com/.well_known/jwks.json'
13
+ },
14
+ staging: {
15
+ apiBaseUrl: 'https://api.staging.figma.com',
16
+ authorizationUrl: 'https://staging.figma.com/oauth',
17
+ clientId: 'wqAToBAp4UI9AZ5M6wTfT9',
18
+ contentApiUrl: 'https://us-east-1.cms-tenants-001-staging.figmacontentstaging.com',
19
+ identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
20
+ jwksUri: 'https://static.figmacontentstaging.com/.well_known/jwks.json'
21
+ }
8
22
  };
9
23
  /**
10
- * Get current Figma environment from environment variable
11
- * Defaults to 'staging' if not specified
12
- *
13
- * @returns Current environment
14
- */ export function getEnvironment() {
15
- return process.env.FIGMA_ENV === 'production' ? 'production' : 'staging';
24
+ * User-facing error message when Content API returns 404 or 410.
25
+ * Used across CLI commands and the db adapter for consistent messaging.
26
+ */ export const CONTENT_SYSTEM_NOT_FOUND_MESSAGE = 'Content system not found. Verify your Content System ID is correct, or contact your team admin for assistance.';
27
+ let envOverride;
28
+ /**
29
+ * Set infrastructure environment override (used by --infra-env CLI flag)
30
+ * Pass undefined to clear the override
31
+ */ export function setInfraEnvironment(env) {
32
+ envOverride = env;
16
33
  }
17
34
  /**
18
- * Get JWKS URI for a given environment
19
- *
20
- * @param env - Environment (defaults to current environment)
21
- * @returns JWKS URI for the environment
22
- */ export function getJWKSUri(env) {
23
- const environment = env || getEnvironment();
24
- return JWKS_URI[environment];
35
+ * Get current Figma infrastructure environment
36
+ * Priority: 1) setInfraEnvironment override, 2) FIGMA_INFRA_ENV env var, 3) .env file, 4) 'production' default
37
+ */ /**
38
+ * Get the resolved EnvironmentConfig for the current infrastructure environment
39
+ */ export function getEnvConfig() {
40
+ return ENV_CONFIG[getInfraEnvironment()];
41
+ }
42
+ export function getInfraEnvironment() {
43
+ if (envOverride) {
44
+ return envOverride;
45
+ }
46
+ // Check process.env first (case-insensitive)
47
+ if (process.env.FIGMA_INFRA_ENV?.toLowerCase() === 'staging') {
48
+ return 'staging';
49
+ }
50
+ // Fall back to .env file in cwd
51
+ const envFileValue = getEnvVarSync(process.cwd(), 'FIGMA_INFRA_ENV');
52
+ if (envFileValue) {
53
+ const env = envFileValue.toLowerCase();
54
+ if (env === 'staging') {
55
+ return 'staging';
56
+ }
57
+ if (env !== 'production') {
58
+ console.warn(`Warning: Invalid FIGMA_INFRA_ENV value "${envFileValue}" in .env file. Using production.`);
59
+ }
60
+ return 'production';
61
+ }
62
+ return 'production';
25
63
  }
26
64
 
27
65
  //# sourceMappingURL=constants.js.map
@@ -0,0 +1,98 @@
1
+ # Content API Database Adapter Parity
2
+
3
+ This document explains how the Content API database adapter differs from Payload today and how it will behave once alignment is complete.
4
+
5
+ The Content API is an internal service built exclusively for Payload. Because of that, the adapter should match Payload by default and only diverge when there is a strong technical reason.
6
+
7
+ ## Where
8
+
9
+ Now
10
+ `{ path: "slug", operator: "equals", value: "hello", type: "text" }`
11
+
12
+ Future
13
+ `{ path: "slug", operator: "equals", value: "hello", type: "text" }`
14
+
15
+ The format stays different. This allows the Content API to evolve its filter schema, for example to support composite types like Point, which are not lexicographically sortable. Semantics must remain identical to Payload.
16
+
17
+ ## Pagination
18
+
19
+ ~~Now~~
20
+ ~~`{ limit: 10, offset: 20 }`~~
21
+
22
+ ✅ Partially Implemented
23
+ `{ limit: 10, page: 3 }`
24
+
25
+ **Status:**
26
+
27
+ - ✅ Content API main endpoints use `page` (matches Payload)
28
+
29
+ - ⚠️ **Issue #1 (Joins):** `JoinClause` still uses `offset` instead of `page`
30
+ - Payload `JoinQuery`: `{ page?: number, limit?: number }`
31
+ - Content API `JoinClause`: `{ offset?: number, limit?: number }`
32
+ - **Inconsistent** with main endpoints which use `page`
33
+
34
+ **Current workaround for joins:** The adapter converts `page` to `offset`:
35
+
36
+ ```typescript
37
+ // Payload join query
38
+ { page: 2, limit: 5 }
39
+ // Adapter converts to offset for Content API
40
+ { offset: 5, limit: 5 }
41
+ ```
42
+
43
+ **Future:**
44
+
45
+ 1. Content API should support `skip` parameter for main endpoints
46
+ 2. Content API `JoinClause` should use `page` instead of `offset` (consistent with main endpoints)
47
+ 3. Content API pagination response should match Payload's flat structure
48
+
49
+ ### Pagination Response Structure
50
+
51
+ **Payload format (flat):**
52
+
53
+ ```typescript
54
+ {
55
+ docs: [...],
56
+ hasNextPage: boolean,
57
+ hasPrevPage: boolean,
58
+ limit: number,
59
+ nextPage: number | null,
60
+ page: number,
61
+ pagingCounter: number,
62
+ prevPage: number | null,
63
+ totalDocs: number,
64
+ totalPages: number
65
+ }
66
+ ```
67
+
68
+ **Content API format (nested):**
69
+
70
+ ```typescript
71
+ {
72
+ data: [...],
73
+ pagination: {
74
+ total: number,
75
+ current: { limit: number, page: number },
76
+ next?: { limit: number, page: number },
77
+ prev?: { limit: number, page: number }
78
+ }
79
+ }
80
+ ```
81
+
82
+ **Current workaround:** The adapter transforms Content API's nested structure to Payload's flat structure using `getPaginationData()` utility.
83
+
84
+ ## Slugs
85
+
86
+ Now
87
+ `{ collection: { key: "posts" } }`
88
+
89
+ Future
90
+ `{ collection: { slug: "posts" } }`
91
+
92
+ Collection identifiers will match Payload. Consumers should not be aware of internal collection IDs.
93
+
94
+ ## Temporary Conversions
95
+
96
+ Helpers that translate Payload queries into the current Content API format are temporary and placed in the `temp-utilities` folder.
97
+
98
+ They live in the `temp-utilities` folder until the Content API is fully aligned with Payload.