@payloadcms/figma 0.0.1-alpha.38-2 → 0.0.1-alpha.4

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 (264) hide show
  1. package/dist/api/control-plane.d.ts +1 -22
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +22 -55
  4. package/dist/api/control-plane.js.map +1 -1
  5. package/dist/api/figma-api.d.ts.map +1 -1
  6. package/dist/api/figma-api.js +26 -45
  7. package/dist/api/figma-api.js.map +1 -1
  8. package/dist/auth/callback-server.d.ts.map +1 -1
  9. package/dist/auth/callback-server.js +1 -2
  10. package/dist/auth/callback-server.js.map +1 -1
  11. package/dist/auth/crypto-utils.d.ts.map +1 -1
  12. package/dist/auth/crypto-utils.js +5 -5
  13. package/dist/auth/crypto-utils.js.map +1 -1
  14. package/dist/auth/jwt-validator.d.ts +1 -2
  15. package/dist/auth/jwt-validator.d.ts.map +1 -1
  16. package/dist/auth/jwt-validator.js +2 -2
  17. package/dist/auth/jwt-validator.js.map +1 -1
  18. package/dist/auth/oauth-flow.d.ts +1 -1
  19. package/dist/auth/oauth-flow.d.ts.map +1 -1
  20. package/dist/auth/oauth-flow.js +8 -9
  21. package/dist/auth/oauth-flow.js.map +1 -1
  22. package/dist/auth/project-token.d.ts.map +1 -1
  23. package/dist/auth/project-token.js +4 -9
  24. package/dist/auth/project-token.js.map +1 -1
  25. package/dist/auth/refresh.d.ts.map +1 -1
  26. package/dist/auth/refresh.js +9 -14
  27. package/dist/auth/refresh.js.map +1 -1
  28. package/dist/auth/token-store.d.ts +0 -10
  29. package/dist/auth/token-store.d.ts.map +1 -1
  30. package/dist/auth/token-store.js +0 -20
  31. package/dist/auth/token-store.js.map +1 -1
  32. package/dist/cli.d.ts.map +1 -1
  33. package/dist/cli.js +0 -22
  34. package/dist/cli.js.map +1 -1
  35. package/dist/commands/deploy.d.ts +0 -4
  36. package/dist/commands/deploy.d.ts.map +1 -1
  37. package/dist/commands/deploy.js +129 -71
  38. package/dist/commands/deploy.js.map +1 -1
  39. package/dist/commands/init.d.ts +5 -1
  40. package/dist/commands/init.d.ts.map +1 -1
  41. package/dist/commands/init.js +85 -90
  42. package/dist/commands/init.js.map +1 -1
  43. package/dist/commands/list-tokens.d.ts.map +1 -1
  44. package/dist/commands/list-tokens.js +3 -6
  45. package/dist/commands/list-tokens.js.map +1 -1
  46. package/dist/commands/login.d.ts +1 -8
  47. package/dist/commands/login.d.ts.map +1 -1
  48. package/dist/commands/login.js +11 -21
  49. package/dist/commands/login.js.map +1 -1
  50. package/dist/commands/logout.js +2 -2
  51. package/dist/commands/logout.js.map +1 -1
  52. package/dist/config/oauth.d.ts +14 -4
  53. package/dist/config/oauth.d.ts.map +1 -1
  54. package/dist/config/oauth.js +40 -19
  55. package/dist/config/oauth.js.map +1 -1
  56. package/dist/constants.d.ts +18 -26
  57. package/dist/constants.d.ts.map +1 -1
  58. package/dist/constants.js +20 -34
  59. package/dist/constants.js.map +1 -1
  60. package/dist/index.d.ts +1 -2
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +1 -3
  63. package/dist/index.js.map +1 -1
  64. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  65. package/dist/oauth/components/LoginButton/index.js +6 -50
  66. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  67. package/dist/oauth/components/LoginButton/index.scss +3 -50
  68. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  69. package/dist/oauth/components/LogoutButton/index.js +1 -0
  70. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  71. package/dist/oauth/defaults.d.ts.map +1 -1
  72. package/dist/oauth/defaults.js +5 -29
  73. package/dist/oauth/defaults.js.map +1 -1
  74. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  75. package/dist/oauth/endpoints/getLoginEndpoint.js +4 -4
  76. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  77. package/dist/oauth/index.d.ts.map +1 -1
  78. package/dist/oauth/index.js +7 -42
  79. package/dist/oauth/index.js.map +1 -1
  80. package/dist/oauth/strategy/index.d.ts +2 -0
  81. package/dist/oauth/strategy/index.d.ts.map +1 -1
  82. package/dist/oauth/strategy/index.js +15 -38
  83. package/dist/oauth/strategy/index.js.map +1 -1
  84. package/dist/oauth/types.d.ts +6 -6
  85. package/dist/oauth/types.d.ts.map +1 -1
  86. package/dist/oauth/types.js.map +1 -1
  87. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  88. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  89. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  90. package/dist/oauth/utilities/refreshTokens.js +1 -1
  91. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  92. package/dist/plugin/build-config.d.ts +4 -21
  93. package/dist/plugin/build-config.d.ts.map +1 -1
  94. package/dist/plugin/build-config.js +8 -114
  95. package/dist/plugin/build-config.js.map +1 -1
  96. package/dist/types.d.ts +0 -1
  97. package/dist/types.d.ts.map +1 -1
  98. package/dist/types.js.map +1 -1
  99. package/dist/utils/asset-collection.d.ts +6 -3
  100. package/dist/utils/asset-collection.d.ts.map +1 -1
  101. package/dist/utils/asset-collection.js +34 -10
  102. package/dist/utils/asset-collection.js.map +1 -1
  103. package/dist/utils/config.js +1 -1
  104. package/dist/utils/config.js.map +1 -1
  105. package/dist/utils/env-management.d.ts +8 -9
  106. package/dist/utils/env-management.d.ts.map +1 -1
  107. package/dist/utils/env-management.js +74 -73
  108. package/dist/utils/env-management.js.map +1 -1
  109. package/dist/utils/formatter.d.ts.map +1 -1
  110. package/dist/utils/formatter.js +5 -3
  111. package/dist/utils/formatter.js.map +1 -1
  112. package/dist/utils/lambda-config.d.ts +1 -3
  113. package/dist/utils/lambda-config.d.ts.map +1 -1
  114. package/dist/utils/lambda-config.js +21 -13
  115. package/dist/utils/lambda-config.js.map +1 -1
  116. package/dist/utils/messages.js +7 -7
  117. package/dist/utils/messages.js.map +1 -1
  118. package/dist/utils/payload-config-ast.d.ts +3 -22
  119. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  120. package/dist/utils/payload-config-ast.js +31 -89
  121. package/dist/utils/payload-config-ast.js.map +1 -1
  122. package/dist/utils/payload-config-finder.d.ts +2 -2
  123. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  124. package/dist/utils/payload-config-finder.js +9 -48
  125. package/dist/utils/payload-config-finder.js.map +1 -1
  126. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  127. package/dist/utils/payload-config-modifier.js +6 -54
  128. package/dist/utils/payload-config-modifier.js.map +1 -1
  129. package/dist/utils/payload-package-check.d.ts +1 -12
  130. package/dist/utils/payload-package-check.d.ts.map +1 -1
  131. package/dist/utils/payload-package-check.js +5 -63
  132. package/dist/utils/payload-package-check.js.map +1 -1
  133. package/dist/utils/project.d.ts.map +1 -1
  134. package/dist/utils/project.js +5 -8
  135. package/dist/utils/project.js.map +1 -1
  136. package/dist/utils/s3-upload.d.ts +1 -0
  137. package/dist/utils/s3-upload.d.ts.map +1 -1
  138. package/dist/utils/s3-upload.js +3 -10
  139. package/dist/utils/s3-upload.js.map +1 -1
  140. package/dist/utils/token-display.d.ts.map +1 -1
  141. package/dist/utils/token-display.js +5 -11
  142. package/dist/utils/token-display.js.map +1 -1
  143. package/dist/utils/typescript-validator.d.ts.map +1 -1
  144. package/dist/utils/typescript-validator.js +6 -4
  145. package/dist/utils/typescript-validator.js.map +1 -1
  146. package/package.json +7 -31
  147. package/dist/commands/build-lambda-zip.d.ts +0 -5
  148. package/dist/commands/build-lambda-zip.d.ts.map +0 -1
  149. package/dist/commands/build-lambda-zip.js +0 -19
  150. package/dist/commands/build-lambda-zip.js.map +0 -1
  151. package/dist/db-content-api/README.md +0 -98
  152. package/dist/db-content-api/generated/content-api-types.d.ts +0 -3848
  153. package/dist/db-content-api/generated/content-api-types.d.ts.map +0 -1
  154. package/dist/db-content-api/generated/content-api-types.js +0 -7
  155. package/dist/db-content-api/generated/content-api-types.js.map +0 -1
  156. package/dist/db-content-api/index.d.ts +0 -18
  157. package/dist/db-content-api/index.d.ts.map +0 -1
  158. package/dist/db-content-api/index.js +0 -571
  159. package/dist/db-content-api/index.js.map +0 -1
  160. package/dist/db-content-api/temp-utilities/pagination.d.ts +0 -13
  161. package/dist/db-content-api/temp-utilities/pagination.d.ts.map +0 -1
  162. package/dist/db-content-api/temp-utilities/pagination.js +0 -45
  163. package/dist/db-content-api/temp-utilities/pagination.js.map +0 -1
  164. package/dist/db-content-api/temp-utilities/slug.d.ts +0 -2
  165. package/dist/db-content-api/temp-utilities/slug.d.ts.map +0 -1
  166. package/dist/db-content-api/temp-utilities/slug.js +0 -3
  167. package/dist/db-content-api/temp-utilities/slug.js.map +0 -1
  168. package/dist/db-content-api/temp-utilities/sorting.d.ts +0 -3
  169. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +0 -1
  170. package/dist/db-content-api/temp-utilities/sorting.js +0 -32
  171. package/dist/db-content-api/temp-utilities/sorting.js.map +0 -1
  172. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +0 -4
  173. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +0 -1
  174. package/dist/db-content-api/temp-utilities/unwrapDocument.js +0 -53
  175. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +0 -1
  176. package/dist/db-content-api/utilities/auth.d.ts +0 -30
  177. package/dist/db-content-api/utilities/auth.d.ts.map +0 -1
  178. package/dist/db-content-api/utilities/auth.js +0 -81
  179. package/dist/db-content-api/utilities/auth.js.map +0 -1
  180. package/dist/db-content-api/utilities/data/applyDefaults.d.ts +0 -7
  181. package/dist/db-content-api/utilities/data/applyDefaults.d.ts.map +0 -1
  182. package/dist/db-content-api/utilities/data/applyDefaults.js +0 -59
  183. package/dist/db-content-api/utilities/data/applyDefaults.js.map +0 -1
  184. package/dist/db-content-api/utilities/data/castFieldValue.d.ts +0 -11
  185. package/dist/db-content-api/utilities/data/castFieldValue.d.ts.map +0 -1
  186. package/dist/db-content-api/utilities/data/castFieldValue.js +0 -66
  187. package/dist/db-content-api/utilities/data/castFieldValue.js.map +0 -1
  188. package/dist/db-content-api/utilities/data/index.d.ts +0 -30
  189. package/dist/db-content-api/utilities/data/index.d.ts.map +0 -1
  190. package/dist/db-content-api/utilities/data/index.js +0 -173
  191. package/dist/db-content-api/utilities/data/index.js.map +0 -1
  192. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +0 -12
  193. package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts.map +0 -1
  194. package/dist/db-content-api/utilities/data/removeVirtualFields.js +0 -54
  195. package/dist/db-content-api/utilities/data/removeVirtualFields.js.map +0 -1
  196. package/dist/db-content-api/utilities/data/stripFields.d.ts +0 -48
  197. package/dist/db-content-api/utilities/data/stripFields.d.ts.map +0 -1
  198. package/dist/db-content-api/utilities/data/stripFields.js +0 -195
  199. package/dist/db-content-api/utilities/data/stripFields.js.map +0 -1
  200. package/dist/db-content-api/utilities/joins.d.ts +0 -55
  201. package/dist/db-content-api/utilities/joins.d.ts.map +0 -1
  202. package/dist/db-content-api/utilities/joins.js +0 -136
  203. package/dist/db-content-api/utilities/joins.js.map +0 -1
  204. package/dist/db-content-api/utilities/where.d.ts +0 -12
  205. package/dist/db-content-api/utilities/where.d.ts.map +0 -1
  206. package/dist/db-content-api/utilities/where.js +0 -107
  207. package/dist/db-content-api/utilities/where.js.map +0 -1
  208. package/dist/endpoints/health.d.ts +0 -3
  209. package/dist/endpoints/health.d.ts.map +0 -1
  210. package/dist/endpoints/health.js +0 -11
  211. package/dist/endpoints/health.js.map +0 -1
  212. package/dist/exports/client.d.ts +0 -4
  213. package/dist/exports/client.d.ts.map +0 -1
  214. package/dist/exports/client.js +0 -5
  215. package/dist/exports/client.js.map +0 -1
  216. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +0 -7
  217. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +0 -1
  218. package/dist/oauth/utilities/isDuplicateKeyError.js +0 -14
  219. package/dist/oauth/utilities/isDuplicateKeyError.js.map +0 -1
  220. package/dist/storage-content-api/api-types.d.ts +0 -161
  221. package/dist/storage-content-api/api-types.d.ts.map +0 -1
  222. package/dist/storage-content-api/api-types.js +0 -6
  223. package/dist/storage-content-api/api-types.js.map +0 -1
  224. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +0 -9
  225. package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts.map +0 -1
  226. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +0 -42
  227. package/dist/storage-content-api/client-uploads/ClientUploadHandler.js.map +0 -1
  228. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +0 -13
  229. package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts.map +0 -1
  230. package/dist/storage-content-api/client-uploads/generateSignedURL.js +0 -31
  231. package/dist/storage-content-api/client-uploads/generateSignedURL.js.map +0 -1
  232. package/dist/storage-content-api/client.d.ts +0 -6
  233. package/dist/storage-content-api/client.d.ts.map +0 -1
  234. package/dist/storage-content-api/client.js +0 -36
  235. package/dist/storage-content-api/client.js.map +0 -1
  236. package/dist/storage-content-api/generateURL.d.ts +0 -7
  237. package/dist/storage-content-api/generateURL.d.ts.map +0 -1
  238. package/dist/storage-content-api/generateURL.js +0 -7
  239. package/dist/storage-content-api/generateURL.js.map +0 -1
  240. package/dist/storage-content-api/handleDelete.d.ts +0 -8
  241. package/dist/storage-content-api/handleDelete.d.ts.map +0 -1
  242. package/dist/storage-content-api/handleDelete.js +0 -15
  243. package/dist/storage-content-api/handleDelete.js.map +0 -1
  244. package/dist/storage-content-api/handleUpload.d.ts +0 -11
  245. package/dist/storage-content-api/handleUpload.d.ts.map +0 -1
  246. package/dist/storage-content-api/handleUpload.js +0 -136
  247. package/dist/storage-content-api/handleUpload.js.map +0 -1
  248. package/dist/storage-content-api/index.d.ts +0 -5
  249. package/dist/storage-content-api/index.d.ts.map +0 -1
  250. package/dist/storage-content-api/index.js +0 -31
  251. package/dist/storage-content-api/index.js.map +0 -1
  252. package/dist/storage-content-api/staticHandler.d.ts +0 -10
  253. package/dist/storage-content-api/staticHandler.d.ts.map +0 -1
  254. package/dist/storage-content-api/staticHandler.js +0 -55
  255. package/dist/storage-content-api/staticHandler.js.map +0 -1
  256. package/dist/storage-content-api/types.d.ts +0 -10
  257. package/dist/storage-content-api/types.d.ts.map +0 -1
  258. package/dist/storage-content-api/types.js +0 -3
  259. package/dist/storage-content-api/types.js.map +0 -1
  260. package/dist/templates/README.md +0 -19
  261. package/dist/utils/build-lambda-zip.d.ts +0 -14
  262. package/dist/utils/build-lambda-zip.d.ts.map +0 -1
  263. package/dist/utils/build-lambda-zip.js +0 -81
  264. package/dist/utils/build-lambda-zip.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/oauth/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type jwt from 'jsonwebtoken'\nimport type {\n AuthStrategyResult,\n CollectionConfig,\n CustomComponent,\n EmailField,\n IncomingAuthType,\n Payload,\n PayloadRequest,\n TextField,\n} from 'payload'\n\nexport type Done = (error: any, user?: any, info?: unknown) => void\n\nexport type VerifyFunction = (args: {\n headers: Headers\n payload: Payload\n token: jwt.JwtPayload\n}) => Promise<AuthStrategyResult>\n\nexport type AfterOAuthLoginHookResult = {\n redirect?: string\n} | void\n\nexport type AfterOAuthLoginHook = (args: {\n access_token?: string\n id_token?: string\n refresh_token?: string\n req: PayloadRequest\n}) => AfterOAuthLoginHookResult | Promise<AfterOAuthLoginHookResult>\n\nexport interface CollectionOptions {\n authorizationURLParams?: Record<string, string>\n\n clientID: string\n clientSecret?: string\n\n /**\n * Whether to disable the local strategy for this collection.\n *\n * @default true\n */\n\n /**\n * By default, accept a JWT from the authorization header\n *\n * Set to false to only accept the JWT from cookies\n */\n disableJWTFromHeader?: boolean\n\n disableLocalStrategy?: false | IncomingAuthType['disableLocalStrategy']\n /**\n * The logout button will either redirect to the IDP logout screen or\n * automatically log the user out of the IDP depending on provider.\n *\n * @default false\n */\n endOAuthSessionOnLogout?: boolean\n hooks?: {\n afterLogin?: AfterOAuthLoginHook[]\n }\n /**\n * The OpenID metadata endpoint for the identity provider.\n *\n * @example http://localhost:8080/realms/master/.well-known/openid-configuration\n * @example https://myapp.auth0.com/.well-known/openid-configuration\n */\n identityMetadata: string\n /**\n * Custom React component to use as the login button on the login page.\n */\n LoginButton?: CustomComponent | false\n /**\n * The OAuth2.0 scope to request from the identity provider.\n *\n * @default ['openid', 'profile', 'email']\n */\n scope?: string[]\n /**\n * The Payload collection slug to apply the OAuth2.0 strategy to.\n */\n slug: string\n /**\n * Property to use as the token to decode from the OAuth2.0 response.\n *\n * This is passed to the default or custom `verify` function.\n *\n * @default 'access_token'\n */\n token?: 'access_token' | 'id_token'\n\n /**\n * Have Payload maintain the JWT cookie.\n *\n * This is for when the IDP does not support silently refreshing tokens in the background.\n */\n usePayloadJWT?: boolean\n\n /**\n * The Payload field to use as the username field for the user\n * When a text is used, the plugin will find the collection field with the name provided\n * Alternatively define the entire field to use\n * @default\n *\n * ```ts\n * {\n * type: 'text',\n * name: 'preferredUsername',\n * unique: true,\n * admin: {\n * position: 'sidebar',\n * readOnly: true,\n * },\n * }\n * ```\n */\n usernameField?: EmailField | string | TextField\n\n /**\n * Custom verify function that receives the token and performs any logic.\n * By default, the defaultVerify function is used.\n */\n verify?: VerifyFunction\n}\n\nexport interface PluginOptions {\n /**\n * The collections to apply the OAuth2.0 strategy to.\n */\n collections: CollectionOptions[]\n /**\n * The name of the cookie to use for storing the user's token.\n *\n * @default 'payload-oauth-token'\n */\n cookieName?: string\n /**\n * Accepts incoming request and allows for modification of cookie options\n */\n createCookieOptions?: (args: {\n collection: CollectionConfig\n cookieOptions: CookieOptions\n headers: Headers\n }) => CookieOptions\n\n /**\n * Debug mode will log additional information to the console.\n *\n * NOTE: This will log sensitive information to the console.\n */\n debug?: boolean\n /**\n * Disables the plugin functionality while leaving in types, fields and component modifications.\n * @default false\n */\n disabled?: boolean\n /**\n * OAuth2.0 requires a URL to redirect the user to.\n * If you do not have a `config.serverURL` defined in your Payload config, you must define this string to be set as where the identity provider should redirect users once logged in.\n */\n redirectServerURL?: string\n /**\n * Override the strategy name used for this plugin.\n *\n * This should only be overridden to accomodate multiple plugin\n * invocations against a single user collection.\n *\n * If you have a custom basePath defined in your Next config,\n * this value should not contain that path.\n *\n * @default 'oauth'\n */\n strategyName?: string\n}\n\nexport type CookieOptions = {\n domain?: string\n expires?: Date | number\n httpOnly?: boolean\n maxAge?: number\n path?: string\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n}\n\nexport type StateObj = {\n /**\n * Redirect to use if the login fails\n */\n failedRedirect?: string\n /**\n * Redirect to use after the login is successful\n */\n redirect?: string\n /**\n * The URL that will be used for Payload to redirect to\n */\n serverURL?: string\n /**\n * Encrypted signature to be verified\n */\n sig: string\n /**\n * Code verifier used for PKCE\n */\n verifier: string\n}\n\nexport type LogFn = {\n (msg: string, ...args: any[]): void\n (obj: unknown, msg?: string, ...args: any[]): void\n <T extends object>(obj: T, msg?: string, ...args: any[]): void\n}\n\nexport type DebugLogger = {\n error: LogFn\n info: LogFn\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GAuNrD,WAGC"}
1
+ {"version":3,"sources":["../../src/oauth/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type jwt from 'jsonwebtoken'\nimport type {\n AuthStrategyResult,\n CollectionConfig,\n CustomComponent,\n EmailField,\n IncomingAuthType,\n Payload,\n PayloadRequest,\n TextField,\n} from 'payload'\n\nexport type Done = (error: any, user?: any, info?: unknown) => void\n\nexport type VerifyFunction = (args: {\n headers: Headers\n payload: Payload\n token: jwt.JwtPayload\n}) => Promise<AuthStrategyResult>\n\nexport type AfterOAuthLoginHookResult = {\n redirect?: string\n} | void\n\nexport type AfterOAuthLoginHook = (args: {\n access_token?: string\n id_token?: string\n refresh_token?: string\n req: PayloadRequest\n}) => AfterOAuthLoginHookResult | Promise<AfterOAuthLoginHookResult>\n\nexport interface CollectionOptions {\n authorizationURLParams?: Record<string, string>\n\n clientID: string\n clientSecret?: string\n\n /**\n * Whether to disable the local strategy for this collection.\n *\n * @default true\n */\n\n /**\n * By default, accept a JWT from the authorization header\n *\n * Set to false to only accept the JWT from cookies\n */\n disableJWTFromHeader?: boolean\n\n disableLocalStrategy?: boolean | IncomingAuthType['disableLocalStrategy']\n /**\n * The logout button will either redirect to the IDP logout screen or\n * automatically log the user out of the IDP depending on provider.\n *\n * @default false\n */\n endOAuthSessionOnLogout?: boolean\n hooks?: {\n afterLogin?: AfterOAuthLoginHook[]\n }\n /**\n * The OpenID metadata endpoint for the identity provider.\n *\n * @example http://localhost:8080/realms/master/.well-known/openid-configuration\n * @example https://myapp.auth0.com/.well-known/openid-configuration\n */\n identityMetadata: string\n /**\n * Custom React component to use as the login button on the login page.\n */\n LoginButton?: CustomComponent | false\n /**\n * The OAuth2.0 scope to request from the identity provider.\n *\n * @default ['openid', 'profile', 'email']\n */\n scope?: string[]\n /**\n * The Payload collection slug to apply the OAuth2.0 strategy to.\n */\n slug: string\n /**\n * Property to use as the token to decode from the OAuth2.0 response.\n *\n * This is passed to the default or custom `verify` function.\n *\n * @default 'access_token'\n */\n token?: 'access_token' | 'id_token'\n\n /**\n * Have Payload maintain the JWT cookie.\n *\n * This is for when the IDP does not support silently refreshing tokens in the background.\n */\n usePayloadJWT?: boolean\n\n /**\n * The Payload field to use as the username field for the user\n * When a text is used, the plugin will find the collection field with the name provided\n * Alternatively define the entire field to use\n * @default\n *\n * ```ts\n * {\n * type: 'text',\n * name: 'preferredUsername',\n * unique: true,\n * admin: {\n * position: 'sidebar',\n * readOnly: true,\n * },\n * }\n * ```\n */\n usernameField?: EmailField | string | TextField\n\n /**\n * Custom verify function that receives the token and performs any logic.\n * By default, the defaultVerify function is used.\n */\n verify?: VerifyFunction\n}\n\nexport interface PluginOptions {\n /**\n * The collections to apply the OAuth2.0 strategy to.\n */\n collections: CollectionOptions[]\n /**\n * The name of the cookie to use for storing the user's token.\n *\n * @default 'payload-oauth-token'\n */\n cookieName?: string\n /**\n * Debug mode will log additional information to the console.\n *\n * NOTE: This will log sensitive information to the console.\n */\n\n /**\n * Accepts incoming request and allows for modification of cookie options\n */\n createCookieOptions?: (args: {\n collection: CollectionConfig\n cookieOptions: CookieOptions\n headers: Headers\n }) => CookieOptions\n\n debug?: boolean\n /**\n * Disables the plugin functionality while leaving in types, fields and component modifications.\n * @default false\n */\n disabled?: boolean\n /**\n * OAuth2.0 requires a URL to redirect the user to.\n * If you do not have a `config.serverURL` defined in your Payload config, you must define this string to be set as where the identity provider should redirect users once logged in.\n */\n redirectServerURL?: string\n /**\n * Override the strategy name used for this plugin.\n *\n * This should only be overridden to accomodate multiple plugin\n * invocations against a single user collection.\n *\n * If you have a custom basePath defined in your Next config,\n * this value should not contain that path.\n *\n * @default 'oauth'\n */\n strategyName?: string\n}\n\nexport type CookieOptions = {\n domain?: string\n expires?: Date | number\n httpOnly?: boolean\n maxAge?: number\n path?: string\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n}\n\nexport type StateObj = {\n /**\n * Redirect to use if the login fails\n */\n failedRedirect?: string\n /**\n * Redirect to use after the login is successful\n */\n redirect?: string\n /**\n * The URL that will be used for Payload to redirect to\n */\n serverURL?: string\n /**\n * Encrypted signature to be verified\n */\n sig: string\n /**\n * Code verifier used for PKCE\n */\n verifier: string\n}\n\nexport type LogFn = {\n (msg: string, ...args: any[]): void\n (obj: unknown, msg?: string, ...args: any[]): void\n <T extends object>(obj: T, msg?: string, ...args: any[]): void\n}\n\nexport type DebugLogger = {\n error: LogFn\n info: LogFn\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GAwNrD,WAGC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createCookieOptions.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE/D,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,eAAO,MAAM,mBAAmB,4CAI7B,IAAI,KAAG,aA8CT,CAAA"}
1
+ {"version":3,"file":"createCookieOptions.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAA;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE/D,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,aAAa,CAAA;CAC7B;AAED,eAAO,MAAM,mBAAmB,4CAI7B,IAAI,KAAG,aA8CT,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { CookieOptions, PluginOptions } from '../types.js'\n\ninterface Args {\n collection: CollectionConfig\n headers: Headers\n pluginOptions: PluginOptions\n}\n\nexport const createCookieOptions = ({\n collection,\n headers,\n pluginOptions,\n}: Args): CookieOptions => {\n let cookieOptions: CookieOptions = {\n domain: undefined,\n httpOnly: true,\n path: '/',\n sameSite: undefined,\n secure: false,\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n const { domain, sameSite, secure } = collection.auth.cookies\n if (typeof secure === 'boolean') {\n cookieOptions.secure = secure\n }\n if (typeof sameSite === 'string') {\n cookieOptions.sameSite = sameSite as 'Lax'\n }\n if (typeof domain === 'string') {\n cookieOptions.domain = domain\n }\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n if (collection.auth.cookies.secure) {\n cookieOptions.secure = true\n }\n if (collection.auth.cookies.sameSite) {\n cookieOptions.sameSite =\n typeof collection.auth.cookies.sameSite === 'string'\n ? collection.auth.cookies.sameSite\n : 'Lax'\n }\n if (collection.auth.cookies.domain) {\n cookieOptions.domain = collection.auth.cookies.domain\n }\n }\n\n if (typeof pluginOptions.createCookieOptions === 'function') {\n cookieOptions = pluginOptions.createCookieOptions({\n collection,\n cookieOptions,\n headers,\n })\n }\n\n return cookieOptions\n}\n"],"names":["createCookieOptions","collection","headers","pluginOptions","cookieOptions","domain","undefined","httpOnly","path","sameSite","secure","auth","cookies"],"mappings":"AAUA,OAAO,MAAMA,sBAAsB,CAAC,EAClCC,UAAU,EACVC,OAAO,EACPC,aAAa,EACR;IACL,IAAIC,gBAA+B;QACjCC,QAAQC;QACRC,UAAU;QACVC,MAAM;QACNC,UAAUH;QACVI,QAAQ;IACV;IAEA,IAAI,OAAOT,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,MAAM,EAAEP,MAAM,EAAEI,QAAQ,EAAEC,MAAM,EAAE,GAAGT,WAAWU,IAAI,CAACC,OAAO;QAC5D,IAAI,OAAOF,WAAW,WAAW;YAC/BN,cAAcM,MAAM,GAAGA;QACzB;QACA,IAAI,OAAOD,aAAa,UAAU;YAChCL,cAAcK,QAAQ,GAAGA;QAC3B;QACA,IAAI,OAAOJ,WAAW,UAAU;YAC9BD,cAAcC,MAAM,GAAGA;QACzB;IACF;IAEA,IAAI,OAAOJ,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,IAAIX,WAAWU,IAAI,CAACC,OAAO,CAACF,MAAM,EAAE;YAClCN,cAAcM,MAAM,GAAG;QACzB;QACA,IAAIT,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,EAAE;YACpCL,cAAcK,QAAQ,GACpB,OAAOR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,KAAK,WACxCR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,GAChC;QACR;QACA,IAAIR,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM,EAAE;YAClCD,cAAcC,MAAM,GAAGJ,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM;QACvD;IACF;IAEA,IAAI,OAAOF,cAAcH,mBAAmB,KAAK,YAAY;QAC3DI,gBAAgBD,cAAcH,mBAAmB,CAAC;YAChDC;YACAG;YACAF;QACF;IACF;IAEA,OAAOE;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/oauth/utilities/createCookieOptions.ts"],"sourcesContent":["import type { CollectionConfig, PayloadRequest } from 'payload'\n\nimport type { CookieOptions, PluginOptions } from '../types.js'\n\ninterface Args {\n collection: CollectionConfig\n headers: Headers\n pluginOptions: PluginOptions\n}\n\nexport const createCookieOptions = ({\n collection,\n headers,\n pluginOptions,\n}: Args): CookieOptions => {\n let cookieOptions: CookieOptions = {\n domain: undefined,\n httpOnly: true,\n path: '/',\n sameSite: undefined,\n secure: false,\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n const { domain, sameSite, secure } = collection.auth.cookies\n if (typeof secure === 'boolean') {\n cookieOptions.secure = secure\n }\n if (typeof sameSite === 'string') {\n cookieOptions.sameSite = sameSite as 'Lax'\n }\n if (typeof domain === 'string') {\n cookieOptions.domain = domain\n }\n }\n\n if (typeof collection.auth === 'object' && typeof collection.auth.cookies === 'object') {\n if (collection.auth.cookies.secure) {\n cookieOptions.secure = true\n }\n if (collection.auth.cookies.sameSite) {\n cookieOptions.sameSite =\n typeof collection.auth.cookies.sameSite === 'string'\n ? collection.auth.cookies.sameSite\n : 'Lax'\n }\n if (collection.auth.cookies.domain) {\n cookieOptions.domain = collection.auth.cookies.domain\n }\n }\n\n if (typeof pluginOptions.createCookieOptions === 'function') {\n cookieOptions = pluginOptions.createCookieOptions({\n collection,\n cookieOptions,\n headers,\n })\n }\n\n return cookieOptions\n}\n"],"names":["createCookieOptions","collection","headers","pluginOptions","cookieOptions","domain","undefined","httpOnly","path","sameSite","secure","auth","cookies"],"mappings":"AAUA,OAAO,MAAMA,sBAAsB,CAAC,EAClCC,UAAU,EACVC,OAAO,EACPC,aAAa,EACR;IACL,IAAIC,gBAA+B;QACjCC,QAAQC;QACRC,UAAU;QACVC,MAAM;QACNC,UAAUH;QACVI,QAAQ;IACV;IAEA,IAAI,OAAOT,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,MAAM,EAAEP,MAAM,EAAEI,QAAQ,EAAEC,MAAM,EAAE,GAAGT,WAAWU,IAAI,CAACC,OAAO;QAC5D,IAAI,OAAOF,WAAW,WAAW;YAC/BN,cAAcM,MAAM,GAAGA;QACzB;QACA,IAAI,OAAOD,aAAa,UAAU;YAChCL,cAAcK,QAAQ,GAAGA;QAC3B;QACA,IAAI,OAAOJ,WAAW,UAAU;YAC9BD,cAAcC,MAAM,GAAGA;QACzB;IACF;IAEA,IAAI,OAAOJ,WAAWU,IAAI,KAAK,YAAY,OAAOV,WAAWU,IAAI,CAACC,OAAO,KAAK,UAAU;QACtF,IAAIX,WAAWU,IAAI,CAACC,OAAO,CAACF,MAAM,EAAE;YAClCN,cAAcM,MAAM,GAAG;QACzB;QACA,IAAIT,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,EAAE;YACpCL,cAAcK,QAAQ,GACpB,OAAOR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,KAAK,WACxCR,WAAWU,IAAI,CAACC,OAAO,CAACH,QAAQ,GAChC;QACR;QACA,IAAIR,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM,EAAE;YAClCD,cAAcC,MAAM,GAAGJ,WAAWU,IAAI,CAACC,OAAO,CAACP,MAAM;QACvD;IACF;IAEA,IAAI,OAAOF,cAAcH,mBAAmB,KAAK,YAAY;QAC3DI,gBAAgBD,cAAcH,mBAAmB,CAAC;YAChDC;YACAG;YACAF;QACF;IACF;IAEA,OAAOE;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"refreshTokens.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/refreshTokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AASpD,UAAU,IAAI;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,KAAK,MAAM,GACP;IACE,iBAAiB,EAAE,GAAG,CAAC,UAAU,CAAA;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,GACD,KAAK,CAAA;AAET,eAAO,MAAM,aAAa,wCAA+C,IAAI,KAAG,OAAO,CAAC,MAAM,CAsE7F,CAAA"}
1
+ {"version":3,"file":"refreshTokens.d.ts","sourceRoot":"","sources":["../../../src/oauth/utilities/refreshTokens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAItC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAUpD,UAAU,IAAI;IACZ,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,KAAK,MAAM,GACP;IACE,iBAAiB,EAAE,GAAG,CAAC,UAAU,CAAA;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;CACd,GACD,KAAK,CAAA;AAET,eAAO,MAAM,aAAa,wCAA+C,IAAI,KAAG,OAAO,CAAC,MAAM,CAmE7F,CAAA"}
@@ -16,7 +16,7 @@ export const refreshTokens = async ({ payload, refreshToken, strategy })=>{
16
16
  // so we will refresh both tokens
17
17
  try {
18
18
  // Get another project token
19
- const { expiresAt, token } = await getProjectToken(refreshToken, payload.config.custom.figma.contentSystemId);
19
+ const { expiresAt, token } = await getProjectToken(refreshToken, 'someproject');
20
20
  debugLogger.info({
21
21
  expiresAt,
22
22
  msg: 'Received new tokens from Figma API',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/oauth/utilities/refreshTokens.ts"],"sourcesContent":["import type jwt from 'jsonwebtoken'\nimport type { Payload } from 'payload'\n\nimport { generateCookie } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { validateProjectToken } from '../../auth/jwt-validator.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from './createCookieOptions.js'\nimport { createDebugLogger } from './createDebugLogger.js'\nimport { getCookieExpiration } from './getCookieExpiration.js'\n\ninterface Args {\n payload: Payload\n refreshToken: string\n strategy: Strategy\n}\n\ntype Result =\n | {\n decodedOauthToken: jwt.JwtPayload\n headers: Headers\n token: string\n }\n | false\n\nexport const refreshTokens = async ({ payload, refreshToken, strategy }: Args): Promise<Result> => {\n const debugLogger = createDebugLogger(payload, strategy.debug)\n\n debugLogger.info({\n msg: 'Refreshing tokens',\n })\n\n const headers = new Headers()\n\n // At this point, access token is expired\n // but refresh token is still valid\n // so we will refresh both tokens\n\n try {\n // Get another project token\n const { expiresAt, token } = await getProjectToken(\n refreshToken,\n payload.config.custom.figma.contentSystemId,\n )\n\n debugLogger.info({\n expiresAt,\n msg: 'Received new tokens from Figma API',\n token,\n })\n\n // On error, no user\n if (!token) {\n debugLogger.error({\n msg: 'Error refreshing tokens',\n })\n return false\n }\n\n if (token) {\n debugLogger.info({\n msg: 'Successfully refreshed project token',\n token,\n })\n\n const expires_in = new Date(expiresAt)\n\n const cookieOptions = createCookieOptions({\n collection: strategy.collection,\n headers,\n pluginOptions: strategy.pluginOptions,\n })\n\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: getCookieExpiration(expires_in),\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n headers.append('Set-Cookie', tokenCookie)\n\n const decodedOauthToken = await validateProjectToken(token, getEnvironment())\n\n return { decodedOauthToken, headers, token }\n }\n } catch (error) {\n debugLogger.error({\n err: error,\n msg: 'Error refreshing tokens',\n })\n }\n\n return false\n}\n"],"names":["generateCookie","getProjectToken","validateProjectToken","getEnvironment","createCookieOptions","createDebugLogger","getCookieExpiration","refreshTokens","payload","refreshToken","strategy","debugLogger","debug","info","msg","headers","Headers","expiresAt","token","config","custom","figma","contentSystemId","error","expires_in","Date","cookieOptions","collection","pluginOptions","tokenCookie","name","cookieName","expires","returnCookieAsObject","value","append","decodedOauthToken","err"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,mBAAmB,QAAQ,2BAA0B;AAgB9D,OAAO,MAAMC,gBAAgB,OAAO,EAAEC,OAAO,EAAEC,YAAY,EAAEC,QAAQ,EAAQ;IAC3E,MAAMC,cAAcN,kBAAkBG,SAASE,SAASE,KAAK;IAE7DD,YAAYE,IAAI,CAAC;QACfC,KAAK;IACP;IAEA,MAAMC,UAAU,IAAIC;IAEpB,yCAAyC;IACzC,mCAAmC;IACnC,iCAAiC;IAEjC,IAAI;QACF,4BAA4B;QAC5B,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAG,MAAMjB,gBACjCQ,cACAD,QAAQW,MAAM,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe;QAG7CX,YAAYE,IAAI,CAAC;YACfI;YACAH,KAAK;YACLI;QACF;QAEA,oBAAoB;QACpB,IAAI,CAACA,OAAO;YACVP,YAAYY,KAAK,CAAC;gBAChBT,KAAK;YACP;YACA,OAAO;QACT;QAEA,IAAII,OAAO;YACTP,YAAYE,IAAI,CAAC;gBACfC,KAAK;gBACLI;YACF;YAEA,MAAMM,aAAa,IAAIC,KAAKR;YAE5B,MAAMS,gBAAgBtB,oBAAoB;gBACxCuB,YAAYjB,SAASiB,UAAU;gBAC/BZ;gBACAa,eAAelB,SAASkB,aAAa;YACvC;YAEA,MAAMC,cAAc7B,eAAe;gBACjC,GAAG0B,aAAa;gBAChBI,MAAMpB,SAASqB,UAAU;gBACzBC,SAAS1B,oBAAoBkB;gBAC7BS,sBAAsB;gBACtBC,OAAOhB;YACT;YAEAH,QAAQoB,MAAM,CAAC,cAAcN;YAE7B,MAAMO,oBAAoB,MAAMlC,qBAAqBgB,OAAOf;YAE5D,OAAO;gBAAEiC;gBAAmBrB;gBAASG;YAAM;QAC7C;IACF,EAAE,OAAOK,OAAO;QACdZ,YAAYY,KAAK,CAAC;YAChBc,KAAKd;YACLT,KAAK;QACP;IACF;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/oauth/utilities/refreshTokens.ts"],"sourcesContent":["import type jwt from 'jsonwebtoken'\nimport type { Payload } from 'payload'\n\nimport { generateCookie } from 'payload'\n\nimport type { Strategy } from '../strategy/index.js'\n\nimport { getProjectToken } from '../../api/figma-api.js'\nimport { validateProjectToken } from '../../auth/jwt-validator.js'\nimport { getEnvironment } from '../../constants.js'\nimport { createCookieOptions } from './createCookieOptions.js'\nimport { createDebugLogger } from './createDebugLogger.js'\nimport { getCookieExpiration } from './getCookieExpiration.js'\nimport { getTokenExp } from './getTokenExp.js'\n\ninterface Args {\n payload: Payload\n refreshToken: string\n strategy: Strategy\n}\n\ntype Result =\n | {\n decodedOauthToken: jwt.JwtPayload\n headers: Headers\n token: string\n }\n | false\n\nexport const refreshTokens = async ({ payload, refreshToken, strategy }: Args): Promise<Result> => {\n const debugLogger = createDebugLogger(payload, strategy.debug)\n\n debugLogger.info({\n msg: 'Refreshing tokens',\n })\n\n const headers = new Headers()\n\n // At this point, access token is expired\n // but refresh token is still valid\n // so we will refresh both tokens\n\n try {\n // Get another project token\n const { expiresAt, token } = await getProjectToken(refreshToken, 'someproject')\n\n debugLogger.info({\n expiresAt,\n msg: 'Received new tokens from Figma API',\n token,\n })\n\n // On error, no user\n if (!token) {\n debugLogger.error({\n msg: 'Error refreshing tokens',\n })\n return false\n }\n\n if (token) {\n debugLogger.info({\n msg: 'Successfully refreshed project token',\n token,\n })\n\n const expires_in = new Date(expiresAt)\n\n const cookieOptions = createCookieOptions({\n collection: strategy.collection,\n headers,\n pluginOptions: strategy.pluginOptions,\n })\n\n const tokenCookie = generateCookie({\n ...cookieOptions,\n name: strategy.cookieName,\n expires: getCookieExpiration(expires_in),\n returnCookieAsObject: false,\n value: token,\n }) as string\n\n headers.append('Set-Cookie', tokenCookie)\n\n const decodedOauthToken = await validateProjectToken(token, getEnvironment())\n\n return { decodedOauthToken, headers, token }\n }\n } catch (error) {\n debugLogger.error({\n err: error,\n msg: 'Error refreshing tokens',\n })\n }\n\n return false\n}\n"],"names":["generateCookie","getProjectToken","validateProjectToken","getEnvironment","createCookieOptions","createDebugLogger","getCookieExpiration","refreshTokens","payload","refreshToken","strategy","debugLogger","debug","info","msg","headers","Headers","expiresAt","token","error","expires_in","Date","cookieOptions","collection","pluginOptions","tokenCookie","name","cookieName","expires","returnCookieAsObject","value","append","decodedOauthToken","err"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,oBAAoB,QAAQ,8BAA6B;AAClE,SAASC,cAAc,QAAQ,qBAAoB;AACnD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,iBAA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imal config
12
12
  * const config: FigmaConfig = {
13
- * figma: {
14
- * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!
15
- * },
16
13
  * collections: [...]
17
14
  * }
18
15
  *
19
16
  * @example
20
17
  * // With custom editor
21
18
  * const config: FigmaConfig = {
22
- * figma: {
23
- * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!
24
- * },
25
19
  * collections: [...],
26
20
  * editor: lexicalEditor({ features: [...] })
27
21
  * }
28
- *
29
- * @example
30
- * // Disable Content System (use custom db)
31
- * const config: FigmaConfig = {
32
- * figma: {
33
- * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!,
34
- * useContentSystem: false
35
- * },
36
- * db: mongooseAdapter({ url: process.env.DATABASE_URI }),
37
- * collections: [...]
38
- * }
39
22
  */
40
23
  export type FigmaConfig = {
41
24
  editor?: Config['editor'];
42
25
  } & {
43
26
  figma: {
44
- contentSystemId: string;
45
- storage?: boolean;
27
+ region: string;
28
+ tenantId: string;
46
29
  useContentSystem?: boolean;
47
30
  };
48
- } & Omit<Config, 'db' | 'editor' | 'secret'> & Partial<Pick<Config, 'db'>>;
31
+ } & Omit<Config, 'editor' | 'secret' | 'db'> & Partial<Pick<Config, 'db'>>;
49
32
  /**
50
33
  * Figma platform wrapper for Payload's buildConfig.
51
34
  * Automatically injects:
@@ -56,5 +39,5 @@ export type FigmaConfig = {
56
39
  * @param config - Payload configuration (db and secret omitted, editor optional)
57
40
  * @returns Promise<SanitizedConfig> - Built Payload configuration
58
41
  */
59
- export declare function buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig>;
42
+ export declare function buildConfig(config: FigmaConfig): Promise<SanitizedConfig>;
60
43
  //# sourceMappingURL=build-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAkBtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,eAAe,EAAE,MAAM,CAAA;QACvB,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7B;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CA8HpF"}
1
+ {"version":3,"file":"build-config.d.ts","sourceRoot":"","sources":["../../src/plugin/build-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAQtD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;CAC1B,GAAG;IACF,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC3B,CAAA;CACF,GAAG,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC,GAC1C,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAE7B;;;;;;;;;GASG;AACH,wBAAsB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CAoC/E"}
@@ -1,15 +1,7 @@
1
- import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
2
- import { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities';
3
1
  import { lexicalEditor } from '@payloadcms/richtext-lexical';
4
2
  import { buildConfig as payloadBuildConfig } from 'payload';
5
- import { getTokenStore } from '../auth/token-store.js';
6
- import { ENV_CONFIG, getEnvironment } from '../constants.js';
7
- import { contentAPIAdapter } from '../db-content-api/index.js';
8
- import { health } from '../endpoints/health.js';
9
3
  import { oAuth2Plugin } from '../oauth/index.js';
10
- import { createStorageClient } from '../storage-content-api/client.js';
11
- import { getGenerateSignedURLHandler } from '../storage-content-api/client-uploads/generateSignedURL.js';
12
- import { contentApiStorageAdapter } from '../storage-content-api/index.js';
4
+ import { figmaContentSystem } from './adapter.js';
13
5
  /**
14
6
  * Figma platform wrapper for Payload's buildConfig.
15
7
  * Automatically injects:
@@ -19,115 +11,16 @@ import { contentApiStorageAdapter } from '../storage-content-api/index.js';
19
11
  *
20
12
  * @param config - Payload configuration (db and secret omitted, editor optional)
21
13
  * @returns Promise<SanitizedConfig> - Built Payload configuration
22
- */ export async function buildFigmaConfig(config) {
23
- // Validate required environment variable
24
- if (!config.figma.contentSystemId) {
25
- throw new Error('FIGMA_CONTENT_SYSTEM_ID is required. ' + 'Ensure your .env file contains: FIGMA_CONTENT_SYSTEM_ID=your-content-system-id');
26
- }
27
- const env = getEnvironment();
28
- const url = process.env.FIGMA_CONTENT_API_URL || ENV_CONFIG[env].contentApiUrl;
29
- const { contentSystemId } = config.figma;
30
- // Determine database adapter based on environment
31
- let db;
32
- if (config.figma.useContentSystem === false) {
33
- db = config.db;
34
- } else if (process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
35
- db = contentAPIAdapter({
36
- auth: {
37
- apiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY,
38
- mode: 'apiKey'
39
- },
40
- contentSystemId,
41
- url
42
- });
43
- } else if (process.env.FIGMA_DEV_JWT === 'true') {
44
- db = contentAPIAdapter({
45
- auth: {
46
- mode: 'devJwt'
47
- },
48
- contentSystemId,
49
- url
50
- });
51
- } else {
52
- db = contentAPIAdapter({
53
- auth: {
54
- mode: 'tokenStore',
55
- tokenStore: getTokenStore()
56
- },
57
- contentSystemId,
58
- url
59
- });
60
- }
61
- // Build storage plugin if there are upload collections and storage is not disabled
62
- const uploadCollections = (config.collections || []).filter((c)=>c.upload);
63
- let storagePlugin;
64
- if (uploadCollections.length > 0 && config.figma.storage !== false) {
65
- const storageConfig = process.env.FIGMA_CONTENT_API_ACCESS_KEY ? {
66
- baseUrl: url,
67
- contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY
68
- } : process.env.FIGMA_DEV_JWT === 'true' ? {
69
- auth: {
70
- mode: 'devJwt'
71
- },
72
- baseUrl: url,
73
- contentSystemId
74
- } : {
75
- auth: {
76
- mode: 'tokenStore',
77
- tokenStore: getTokenStore()
78
- },
79
- baseUrl: url,
80
- contentSystemId
81
- };
82
- const adapter = contentApiStorageAdapter(storageConfig);
83
- const storageClient = createStorageClient(storageConfig);
84
- const collectionsMap = uploadCollections.reduce((acc, c)=>{
85
- acc[c.slug] = {
86
- adapter,
87
- disableLocalStorage: true
88
- };
89
- return acc;
90
- }, {});
91
- initClientUploads({
92
- clientHandler: '@payloadcms/figma/client#ContentApiClientUploadHandler',
93
- collections: collectionsMap,
94
- config: config,
95
- enabled: true,
96
- serverHandler: getGenerateSignedURLHandler({
97
- client: storageClient
98
- }),
99
- serverHandlerPath: '/content-api-storage-signed-url'
100
- });
101
- storagePlugin = cloudStoragePlugin({
102
- collections: collectionsMap
103
- });
104
- }
14
+ */ export async function buildConfig(config) {
105
15
  // Build complete config with Figma platform defaults
106
16
  const configWithFigmaDefaults = {
107
17
  ...config,
108
- admin: {
109
- // Auto-refresh tokens before expiry to prevent unexpected logouts.
110
- // The project token (access token) expires in ~15 minutes, so the client
111
- // will automatically refresh at ~14 minutes to keep the session alive.
112
- autoRefresh: true,
113
- ...config.admin
114
- },
115
- custom: {
116
- figma: config.figma || {}
117
- },
118
- db,
18
+ db: config.figma.useContentSystem ? figmaContentSystem() : config.db,
119
19
  editor: config.editor ?? lexicalEditor(),
120
- endpoints: [
121
- ...config.endpoints ?? [],
122
- health
123
- ],
124
20
  secret: 'MY_SECRET',
125
21
  // Add oauth to plugins if not already present
126
22
  plugins: [
127
23
  ...config.plugins ?? [],
128
- ...storagePlugin ? [
129
- storagePlugin
130
- ] : [],
131
24
  oAuth2Plugin({
132
25
  collections: [
133
26
  {
@@ -137,9 +30,9 @@ import { contentApiStorageAdapter } from '../storage-content-api/index.js';
137
30
  response_mode: 'query',
138
31
  response_type: 'code'
139
32
  },
140
- clientID: process.env.FIGMA_OAUTH_CLIENT_ID || ENV_CONFIG[env].clientId,
33
+ clientID: process.env.FIGMA_OAUTH_CLIENT_ID,
141
34
  clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,
142
- identityMetadata: ENV_CONFIG[env].identityMetadata,
35
+ identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',
143
36
  scope: [
144
37
  'current_user:read'
145
38
  ],
@@ -147,8 +40,9 @@ import { contentApiStorageAdapter } from '../storage-content-api/index.js';
147
40
  usernameField: 'email'
148
41
  }
149
42
  ],
150
- debug: !!process.env.DEBUG,
151
- disabled: false
43
+ debug: true,
44
+ disabled: false,
45
+ redirectServerURL: 'http://localhost:3000'
152
46
  })
153
47
  ]
154
48
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\nimport { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities'\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport type { StorageClientConfig } from '../storage-content-api/index.js'\n\nimport { getTokenStore } from '../auth/token-store.js'\nimport { ENV_CONFIG, getEnvironment } from '../constants.js'\nimport { contentAPIAdapter } from '../db-content-api/index.js'\nimport { health } from '../endpoints/health.js'\nimport { oAuth2Plugin } from '../oauth/index.js'\nimport { createStorageClient } from '../storage-content-api/client.js'\nimport { getGenerateSignedURLHandler } from '../storage-content-api/client-uploads/generateSignedURL.js'\nimport { contentApiStorageAdapter } from '../storage-content-api/index.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!\n * },\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!\n * },\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n *\n * @example\n * // Disable Content System (use custom db)\n * const config: FigmaConfig = {\n * figma: {\n * contentSystemId: process.env.FIGMA_CONTENT_SYSTEM_ID!,\n * useContentSystem: false\n * },\n * db: mongooseAdapter({ url: process.env.DATABASE_URI }),\n * collections: [...]\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n contentSystemId: string\n storage?: boolean\n useContentSystem?: boolean\n }\n} & Omit<Config, 'db' | 'editor' | 'secret'> &\n Partial<Pick<Config, 'db'>>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildFigmaConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n // Validate required environment variable\n if (!config.figma.contentSystemId) {\n throw new Error(\n 'FIGMA_CONTENT_SYSTEM_ID is required. ' +\n 'Ensure your .env file contains: FIGMA_CONTENT_SYSTEM_ID=your-content-system-id',\n )\n }\n\n const env = getEnvironment()\n const url = process.env.FIGMA_CONTENT_API_URL || ENV_CONFIG[env].contentApiUrl\n const { contentSystemId } = config.figma\n\n // Determine database adapter based on environment\n let db: Config['db']\n\n if (config.figma.useContentSystem === false) {\n db = config.db!\n } else if (process.env.FIGMA_CONTENT_API_ACCESS_KEY) {\n db = contentAPIAdapter({\n auth: { apiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY, mode: 'apiKey' },\n contentSystemId,\n url,\n })\n } else if (process.env.FIGMA_DEV_JWT === 'true') {\n db = contentAPIAdapter({\n auth: { mode: 'devJwt' },\n contentSystemId,\n url,\n })\n } else {\n db = contentAPIAdapter({\n auth: { mode: 'tokenStore', tokenStore: getTokenStore() },\n contentSystemId,\n url,\n })\n }\n\n // Build storage plugin if there are upload collections and storage is not disabled\n const uploadCollections = (config.collections || []).filter((c) => c.upload)\n let storagePlugin: ReturnType<typeof cloudStoragePlugin> | undefined\n\n if (uploadCollections.length > 0 && config.figma.storage !== false) {\n const storageConfig: StorageClientConfig = process.env.FIGMA_CONTENT_API_ACCESS_KEY\n ? { baseUrl: url, contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY }\n : process.env.FIGMA_DEV_JWT === 'true'\n ? {\n auth: { mode: 'devJwt' },\n baseUrl: url,\n contentSystemId,\n }\n : {\n auth: { mode: 'tokenStore', tokenStore: getTokenStore() },\n baseUrl: url,\n contentSystemId,\n }\n\n const adapter = contentApiStorageAdapter(storageConfig)\n const storageClient = createStorageClient(storageConfig)\n\n const collectionsMap = uploadCollections.reduce(\n (acc, c) => {\n acc[c.slug] = { adapter, disableLocalStorage: true }\n return acc\n },\n {} as Record<string, { adapter: typeof adapter; disableLocalStorage: boolean }>,\n )\n\n initClientUploads({\n clientHandler: '@payloadcms/figma/client#ContentApiClientUploadHandler',\n collections: collectionsMap,\n config: config as unknown as Config,\n enabled: true,\n serverHandler: getGenerateSignedURLHandler({ client: storageClient }),\n serverHandlerPath: '/content-api-storage-signed-url',\n })\n\n storagePlugin = cloudStoragePlugin({ collections: collectionsMap })\n }\n\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n admin: {\n // Auto-refresh tokens before expiry to prevent unexpected logouts.\n // The project token (access token) expires in ~15 minutes, so the client\n // will automatically refresh at ~14 minutes to keep the session alive.\n autoRefresh: true,\n ...config.admin,\n },\n custom: {\n figma: config.figma || {},\n },\n db,\n editor: config.editor ?? lexicalEditor(),\n endpoints: [...(config.endpoints ?? []), health],\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n ...(storagePlugin ? [storagePlugin] : []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID || ENV_CONFIG[env].clientId,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: ENV_CONFIG[env].identityMetadata,\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: !!process.env.DEBUG,\n disabled: false,\n }),\n ],\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["cloudStoragePlugin","initClientUploads","lexicalEditor","buildConfig","payloadBuildConfig","getTokenStore","ENV_CONFIG","getEnvironment","contentAPIAdapter","health","oAuth2Plugin","createStorageClient","getGenerateSignedURLHandler","contentApiStorageAdapter","buildFigmaConfig","config","figma","contentSystemId","Error","env","url","process","FIGMA_CONTENT_API_URL","contentApiUrl","db","useContentSystem","FIGMA_CONTENT_API_ACCESS_KEY","auth","apiKey","mode","FIGMA_DEV_JWT","tokenStore","uploadCollections","collections","filter","c","upload","storagePlugin","length","storage","storageConfig","baseUrl","contentApiKey","adapter","storageClient","collectionsMap","reduce","acc","slug","disableLocalStorage","clientHandler","enabled","serverHandler","client","serverHandlerPath","configWithFigmaDefaults","admin","autoRefresh","custom","editor","endpoints","secret","plugins","authorizationURLParams","response_mode","response_type","clientID","FIGMA_OAUTH_CLIENT_ID","clientId","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","DEBUG","disabled"],"mappings":"AAEA,SAASA,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,iBAAiB,QAAQ,6CAA4C;AAC9E,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAI3D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,UAAU,EAAEC,cAAc,QAAQ,kBAAiB;AAC5D,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,2BAA2B,QAAQ,6DAA4D;AACxG,SAASC,wBAAwB,QAAQ,kCAAiC;AAmD1E;;;;;;;;;CASC,GACD,OAAO,eAAeC,iBAAiBC,MAAmB;IACxD,yCAAyC;IACzC,IAAI,CAACA,OAAOC,KAAK,CAACC,eAAe,EAAE;QACjC,MAAM,IAAIC,MACR,0CACE;IAEN;IAEA,MAAMC,MAAMZ;IACZ,MAAMa,MAAMC,QAAQF,GAAG,CAACG,qBAAqB,IAAIhB,UAAU,CAACa,IAAI,CAACI,aAAa;IAC9E,MAAM,EAAEN,eAAe,EAAE,GAAGF,OAAOC,KAAK;IAExC,kDAAkD;IAClD,IAAIQ;IAEJ,IAAIT,OAAOC,KAAK,CAACS,gBAAgB,KAAK,OAAO;QAC3CD,KAAKT,OAAOS,EAAE;IAChB,OAAO,IAAIH,QAAQF,GAAG,CAACO,4BAA4B,EAAE;QACnDF,KAAKhB,kBAAkB;YACrBmB,MAAM;gBAAEC,QAAQP,QAAQF,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mBAAmB;YAAEiC,aAAaY;QAAe;IACnE;IAEA,qDAAqD;IACrD,MAAMU,0BAAkC;QACtC,GAAGxC,MAAM;QACTyC,OAAO;YACL,mEAAmE;YACnE,yEAAyE;YACzE,uEAAuE;YACvEC,aAAa;YACb,GAAG1C,OAAOyC,KAAK;QACjB;QACAE,QAAQ;YACN1C,OAAOD,OAAOC,KAAK,IAAI,CAAC;QAC1B;QACAQ;QACAmC,QAAQ5C,OAAO4C,MAAM,IAAIzD;QACzB0D,WAAW;eAAK7C,OAAO6C,SAAS,IAAI,EAAE;YAAGnD;SAAO;QAChDoD,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACH/C,OAAO+C,OAAO,IAAI,EAAE;eACpBzB,gBAAgB;gBAACA;aAAc,GAAG,EAAE;YACxC3B,aAAa;gBACXuB,aAAa;oBACX;wBACEe,MAAM;wBACN,4DAA4D;wBAC5De,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAU7C,QAAQF,GAAG,CAACgD,qBAAqB,IAAI7D,UAAU,CAACa,IAAI,CAACiD,QAAQ;wBACvEC,cAAchD,QAAQF,GAAG,CAACmD,yBAAyB;wBACnDC,kBAAkBjE,UAAU,CAACa,IAAI,CAACoD,gBAAgB;wBAClDC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO,CAAC,CAACtD,QAAQF,GAAG,CAACyD,KAAK;gBAC1BC,UAAU;YACZ;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAMzE,mBAAmBmD;AAClC"}
1
+ {"version":3,"sources":["../../src/plugin/build-config.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload'\n\nimport { lexicalEditor } from '@payloadcms/richtext-lexical'\nimport { buildConfig as payloadBuildConfig } from 'payload'\n\nimport { oAuth2Plugin } from '../oauth/index.js'\nimport { figmaContentSystem } from './adapter.js'\n\n/**\n * Configuration type for Payload projects on the Figma platform.\n *\n * Differences from standard Payload Config:\n * - `db`: Omitted (auto-injected by Figma platform)\n * - `secret`: Omitted (auto-injected by Figma platform)\n * - `editor`: Optional (defaults to lexicalEditor() if not provided)\n *\n * @example\n * // Minimal config\n * const config: FigmaConfig = {\n * collections: [...]\n * }\n *\n * @example\n * // With custom editor\n * const config: FigmaConfig = {\n * collections: [...],\n * editor: lexicalEditor({ features: [...] })\n * }\n */\nexport type FigmaConfig = {\n editor?: Config['editor']\n} & {\n figma: {\n region: string\n tenantId: string\n useContentSystem?: boolean\n }\n} & Omit<Config, 'editor' | 'secret' | 'db'> &\n Partial<Pick<Config, 'db'>>\n\n/**\n * Figma platform wrapper for Payload's buildConfig.\n * Automatically injects:\n * - Figma database adapter\n * - Secret (platform-provided)\n * - Default lexicalEditor (if no custom editor specified)\n *\n * @param config - Payload configuration (db and secret omitted, editor optional)\n * @returns Promise<SanitizedConfig> - Built Payload configuration\n */\nexport async function buildConfig(config: FigmaConfig): Promise<SanitizedConfig> {\n // Build complete config with Figma platform defaults\n const configWithFigmaDefaults: Config = {\n ...config,\n db: config.figma.useContentSystem ? figmaContentSystem() : config.db!,\n editor: config.editor ?? lexicalEditor(),\n secret: 'MY_SECRET',\n // Add oauth to plugins if not already present\n plugins: [\n ...(config.plugins ?? []),\n oAuth2Plugin({\n collections: [\n {\n slug: 'users',\n // Use adapter because Figma app doesn't support OIDC scopes\n authorizationURLParams: {\n response_mode: 'query',\n response_type: 'code',\n },\n clientID: process.env.FIGMA_OAUTH_CLIENT_ID!,\n clientSecret: process.env.FIGMA_OAUTH_CLIENT_SECRET,\n identityMetadata: 'https://staging.figma.com/.well-known/openid-configuration',\n scope: ['current_user:read'],\n token: 'id_token', // Adapter creates JWT id_token from Figma user info\n usernameField: 'email',\n },\n ],\n debug: true,\n disabled: false,\n redirectServerURL: 'http://localhost:3000',\n }),\n ],\n }\n\n // Delegate to Payload's buildConfig\n return await payloadBuildConfig(configWithFigmaDefaults)\n}\n"],"names":["lexicalEditor","buildConfig","payloadBuildConfig","oAuth2Plugin","figmaContentSystem","config","configWithFigmaDefaults","db","figma","useContentSystem","editor","secret","plugins","collections","slug","authorizationURLParams","response_mode","response_type","clientID","process","env","FIGMA_OAUTH_CLIENT_ID","clientSecret","FIGMA_OAUTH_CLIENT_SECRET","identityMetadata","scope","token","usernameField","debug","disabled","redirectServerURL"],"mappings":"AAEA,SAASA,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,eAAeC,kBAAkB,QAAQ,UAAS;AAE3D,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,kBAAkB,QAAQ,eAAc;AAkCjD;;;;;;;;;CASC,GACD,OAAO,eAAeH,YAAYI,MAAmB;IACnD,qDAAqD;IACrD,MAAMC,0BAAkC;QACtC,GAAGD,MAAM;QACTE,IAAIF,OAAOG,KAAK,CAACC,gBAAgB,GAAGL,uBAAuBC,OAAOE,EAAE;QACpEG,QAAQL,OAAOK,MAAM,IAAIV;QACzBW,QAAQ;QACR,8CAA8C;QAC9CC,SAAS;eACHP,OAAOO,OAAO,IAAI,EAAE;YACxBT,aAAa;gBACXU,aAAa;oBACX;wBACEC,MAAM;wBACN,4DAA4D;wBAC5DC,wBAAwB;4BACtBC,eAAe;4BACfC,eAAe;wBACjB;wBACAC,UAAUC,QAAQC,GAAG,CAACC,qBAAqB;wBAC3CC,cAAcH,QAAQC,GAAG,CAACG,yBAAyB;wBACnDC,kBAAkB;wBAClBC,OAAO;4BAAC;yBAAoB;wBAC5BC,OAAO;wBACPC,eAAe;oBACjB;iBACD;gBACDC,OAAO;gBACPC,UAAU;gBACVC,mBAAmB;YACrB;SACD;IACH;IAEA,oCAAoC;IACpC,OAAO,MAAM5B,mBAAmBI;AAClC"}
package/dist/types.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import type arg from 'arg';
2
2
  export interface Args extends arg.Spec {
3
3
  '--debug': BooleanConstructor;
4
- '--env': StringConstructor;
5
4
  '--force': BooleanConstructor;
6
5
  '--help': BooleanConstructor;
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KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;AAEjD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,WAAW,GAAG,mBAAmB,CAAA"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--debug': BooleanConstructor\n '--env': StringConstructor\n '--force': BooleanConstructor\n '--help': BooleanConstructor\n '--list': BooleanConstructor\n '--logout': BooleanConstructor\n '--yes': BooleanConstructor\n\n // Aliases\n\n '-f': string\n '-h': string\n '-y': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres'\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'r2Storage' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AA2EA,WAAgF"}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type arg from 'arg'\n\nexport interface Args extends arg.Spec {\n '--debug': BooleanConstructor\n '--force': BooleanConstructor\n '--help': BooleanConstructor\n '--list': BooleanConstructor\n '--logout': BooleanConstructor\n '--yes': BooleanConstructor\n\n // Aliases\n\n '-f': string\n '-h': string\n '-y': string\n}\n\nexport type CliArgs = arg.Result<Args>\n\nexport type ProjectTemplate = GitTemplate | PluginTemplate\n\nexport type ProjectExample = {\n name: string\n url: string\n}\n\n/**\n * Template that is cloned verbatim from a git repo\n * Performs .env manipulation based upon input\n */\nexport interface GitTemplate extends Template {\n type: 'starter'\n url: string\n}\n\n/**\n * Type specifically for the plugin template\n * No .env manipulation is done\n */\nexport interface PluginTemplate extends Template {\n type: 'plugin'\n url: string\n}\n\ninterface Template {\n description?: string\n name: string\n type: ProjectTemplate['type']\n}\n\nexport type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn'\n\nexport type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres'\n\nexport type DbDetails = {\n dbUri?: string\n type: DbType\n}\n\nexport type EditorType = 'lexical' | 'slate'\n\nexport type NextAppDetails = {\n hasTopLevelLayout: boolean\n isPayloadInstalled?: boolean\n isSrcDir: boolean\n isSupportedNextVersion: boolean\n nextAppDir?: string\n nextConfigPath?: string\n nextConfigType?: NextConfigType\n nextVersion: null | string\n}\n\nexport type NextConfigType = 'cjs' | 'esm' | 'ts'\n\nexport type StorageAdapterType = 'localDisk' | 'r2Storage' | 'vercelBlobStorage'\n"],"names":[],"mappings":"AA0EA,WAAgF"}
@@ -16,12 +16,15 @@ export declare function getFileSize(filePath: string): Promise<number>;
16
16
  */
17
17
  export declare function collectStaticAssets(projectPath: string): Promise<string[]>;
18
18
  /**
19
- * Create Lambda deployment zip
19
+ * Create Lambda deployment zip using build_for_lambda.sh
20
20
  *
21
- * Uses cross-platform Node.js implementation instead of shell script.
21
+ * This script:
22
+ * - Copies static files to standalone build
23
+ * - Creates lambda.zip from .next/standalone/
24
+ * - Places zip at project root
22
25
  *
23
26
  * @param projectPath - Path to project root
24
- * @throws Error if build missing or zip creation fails
27
+ * @throws Error if script missing or execution fails
25
28
  */
26
29
  export declare function createLambdaZip(projectPath: string): Promise<void>;
27
30
  //# sourceMappingURL=asset-collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"asset-collection.d.ts","sourceRoot":"","sources":["../../src/utils/asset-collection.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAgDD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBhF;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE"}
1
+ {"version":3,"file":"asset-collection.d.ts","sourceRoot":"","sources":["../../src/utils/asset-collection.ts"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGnE;AAgDD;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAchF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBxE"}
@@ -1,7 +1,9 @@
1
+ import { exec } from 'child_process';
1
2
  import fs from 'fs/promises';
2
3
  import path from 'path';
3
- import { buildLambdaZip } from './build-lambda-zip.js';
4
+ import { promisify } from 'util';
4
5
  import * as log from './log.js';
6
+ const execAsync = promisify(exec);
5
7
  // Maximum file size for static assets (S3 limitation)
6
8
  const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
7
9
  ;
@@ -73,21 +75,43 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
73
75
  return [];
74
76
  }
75
77
  const files = await collectFiles(staticDir, projectPath);
76
- // Normalize paths to forward slashes (cross-platform) and convert prefix
77
- return files.map((file)=>{
78
- const normalized = file.split(path.sep).join('/');
79
- return normalized.replace(/^\.next\//, '_next/');
80
- });
78
+ // Convert .next/static to _next/static (Next.js convention)
79
+ return files.map((file)=>file.replace(/^\.next\//, '_next/'));
81
80
  }
82
81
  /**
83
- * Create Lambda deployment zip
82
+ * Create Lambda deployment zip using build_for_lambda.sh
84
83
  *
85
- * Uses cross-platform Node.js implementation instead of shell script.
84
+ * This script:
85
+ * - Copies static files to standalone build
86
+ * - Creates lambda.zip from .next/standalone/
87
+ * - Places zip at project root
86
88
  *
87
89
  * @param projectPath - Path to project root
88
- * @throws Error if build missing or zip creation fails
90
+ * @throws Error if script missing or execution fails
89
91
  */ export async function createLambdaZip(projectPath) {
90
- await buildLambdaZip(projectPath);
92
+ const scriptPath = path.join(projectPath, 'build_for_lambda.sh');
93
+ // Check if script exists
94
+ try {
95
+ await fs.stat(scriptPath);
96
+ } catch {
97
+ throw new Error('build_for_lambda.sh not found. Run init command to set up project.');
98
+ }
99
+ // Execute script
100
+ try {
101
+ await execAsync('./build_for_lambda.sh', {
102
+ cwd: projectPath
103
+ });
104
+ } catch (error) {
105
+ const message = error instanceof Error ? error.message : 'Unknown error';
106
+ throw new Error(`Failed to create Lambda zip: ${message}`);
107
+ }
108
+ // Verify zip was created
109
+ const zipPath = path.join(projectPath, 'lambda.zip');
110
+ try {
111
+ await fs.stat(zipPath);
112
+ } catch {
113
+ throw new Error('lambda.zip was not created by build_for_lambda.sh');
114
+ }
91
115
  }
92
116
 
93
117
  //# sourceMappingURL=asset-collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/asset-collection.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\nimport { buildLambdaZip } from './build-lambda-zip.js'\nimport * as log from './log.js'\n\n// Maximum file size for static assets (S3 limitation)\nconst MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB\n\n/**\n * Get file size in bytes\n *\n * @param filePath - Absolute path to file\n * @returns File size in bytes\n */\nexport async function getFileSize(filePath: string): Promise<number> {\n const stats = await fs.stat(filePath)\n return stats.size\n}\n\n/**\n * Recursively collect files from a directory\n *\n * Excludes files larger than 50MB (S3 limitation).\n * Warns user when files are excluded due to size.\n *\n * @param dir - Directory to scan\n * @param baseDir - Base directory for relative paths\n * @returns Array of relative file paths\n */\nasync function collectFiles(dir: string, baseDir: string): Promise<string[]> {\n const files: string[] = []\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively collect from subdirectories\n const subFiles = await collectFiles(fullPath, baseDir)\n files.push(...subFiles)\n } else if (entry.isFile()) {\n // Check file size before adding\n const stats = await fs.stat(fullPath)\n if (stats.size <= MAX_ASSET_SIZE) {\n // Add relative path from base directory\n const relativePath = path.relative(baseDir, fullPath)\n files.push(relativePath)\n } else {\n // Warn user about skipped files\n const sizeMB = (stats.size / (1024 * 1024)).toFixed(2)\n const relativePath = path.relative(baseDir, fullPath)\n log.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`)\n }\n }\n }\n } catch {\n // Directory doesn't exist or not accessible\n return []\n }\n\n return files\n}\n\n/**\n * Collect all static asset paths from .next/static\n *\n * Returns paths relative to project root, formatted for S3:\n * - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`\n *\n * @param projectPath - Path to project root\n * @returns Array of static asset paths (using _next prefix)\n */\nexport async function collectStaticAssets(projectPath: string): Promise<string[]> {\n const staticDir = path.join(projectPath, '.next', 'static')\n\n try {\n await fs.stat(staticDir)\n } catch {\n // No static directory\n return []\n }\n\n const files = await collectFiles(staticDir, projectPath)\n\n // Normalize paths to forward slashes (cross-platform) and convert prefix\n return files.map((file) => {\n const normalized = file.split(path.sep).join('/')\n return normalized.replace(/^\\.next\\//, '_next/')\n })\n}\n\n/**\n * Create Lambda deployment zip\n *\n * Uses cross-platform Node.js implementation instead of shell script.\n *\n * @param projectPath - Path to project root\n * @throws Error if build missing or zip creation fails\n */\nexport async function createLambdaZip(projectPath: string): Promise<void> {\n await buildLambdaZip(projectPath)\n}\n"],"names":["fs","path","buildLambdaZip","log","MAX_ASSET_SIZE","getFileSize","filePath","stats","stat","size","collectFiles","dir","baseDir","files","entries","readdir","withFileTypes","entry","fullPath","join","name","isDirectory","subFiles","push","isFile","relativePath","relative","sizeMB","toFixed","warning","collectStaticAssets","projectPath","staticDir","map","file","normalized","split","sep","replace","createLambdaZip"],"mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,SAASC,cAAc,QAAQ,wBAAuB;AACtD,YAAYC,SAAS,WAAU;AAE/B,sDAAsD;AACtD,MAAMC,iBAAiB,KAAK,OAAO,KAAK,OAAO;;AAE/C;;;;;CAKC,GACD,OAAO,eAAeC,YAAYC,QAAgB;IAChD,MAAMC,QAAQ,MAAMP,GAAGQ,IAAI,CAACF;IAC5B,OAAOC,MAAME,IAAI;AACnB;AAEA;;;;;;;;;CASC,GACD,eAAeC,aAAaC,GAAW,EAAEC,OAAe;IACtD,MAAMC,QAAkB,EAAE;IAE1B,IAAI;QACF,MAAMC,UAAU,MAAMd,GAAGe,OAAO,CAACJ,KAAK;YAAEK,eAAe;QAAK;QAE5D,KAAK,MAAMC,SAASH,QAAS;YAC3B,MAAMI,WAAWjB,KAAKkB,IAAI,CAACR,KAAKM,MAAMG,IAAI;YAE1C,IAAIH,MAAMI,WAAW,IAAI;gBACvB,0CAA0C;gBAC1C,MAAMC,WAAW,MAAMZ,aAAaQ,UAAUN;gBAC9CC,MAAMU,IAAI,IAAID;YAChB,OAAO,IAAIL,MAAMO,MAAM,IAAI;gBACzB,gCAAgC;gBAChC,MAAMjB,QAAQ,MAAMP,GAAGQ,IAAI,CAACU;gBAC5B,IAAIX,MAAME,IAAI,IAAIL,gBAAgB;oBAChC,wCAAwC;oBACxC,MAAMqB,eAAexB,KAAKyB,QAAQ,CAACd,SAASM;oBAC5CL,MAAMU,IAAI,CAACE;gBACb,OAAO;oBACL,gCAAgC;oBAChC,MAAME,SAAS,AAACpB,CAAAA,MAAME,IAAI,GAAI,CAAA,OAAO,IAAG,CAAC,EAAGmB,OAAO,CAAC;oBACpD,MAAMH,eAAexB,KAAKyB,QAAQ,CAACd,SAASM;oBAC5Cf,IAAI0B,OAAO,CAAC,CAAC,sBAAsB,EAAEJ,aAAa,EAAE,EAAEE,OAAO,sBAAsB,CAAC;gBACtF;YACF;QACF;IACF,EAAE,OAAM;QACN,4CAA4C;QAC5C,OAAO,EAAE;IACX;IAEA,OAAOd;AACT;AAEA;;;;;;;;CAQC,GACD,OAAO,eAAeiB,oBAAoBC,WAAmB;IAC3D,MAAMC,YAAY/B,KAAKkB,IAAI,CAACY,aAAa,SAAS;IAElD,IAAI;QACF,MAAM/B,GAAGQ,IAAI,CAACwB;IAChB,EAAE,OAAM;QACN,sBAAsB;QACtB,OAAO,EAAE;IACX;IAEA,MAAMnB,QAAQ,MAAMH,aAAasB,WAAWD;IAE5C,yEAAyE;IACzE,OAAOlB,MAAMoB,GAAG,CAAC,CAACC;QAChB,MAAMC,aAAaD,KAAKE,KAAK,CAACnC,KAAKoC,GAAG,EAAElB,IAAI,CAAC;QAC7C,OAAOgB,WAAWG,OAAO,CAAC,aAAa;IACzC;AACF;AAEA;;;;;;;CAOC,GACD,OAAO,eAAeC,gBAAgBR,WAAmB;IACvD,MAAM7B,eAAe6B;AACvB"}
1
+ {"version":3,"sources":["../../src/utils/asset-collection.ts"],"sourcesContent":["import { exec } from 'child_process'\nimport fs from 'fs/promises'\nimport path from 'path'\nimport { promisify } from 'util'\n\nimport * as log from './log.js'\n\nconst execAsync = promisify(exec)\n\n// Maximum file size for static assets (S3 limitation)\nconst MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB\n\n/**\n * Get file size in bytes\n *\n * @param filePath - Absolute path to file\n * @returns File size in bytes\n */\nexport async function getFileSize(filePath: string): Promise<number> {\n const stats = await fs.stat(filePath)\n return stats.size\n}\n\n/**\n * Recursively collect files from a directory\n *\n * Excludes files larger than 50MB (S3 limitation).\n * Warns user when files are excluded due to size.\n *\n * @param dir - Directory to scan\n * @param baseDir - Base directory for relative paths\n * @returns Array of relative file paths\n */\nasync function collectFiles(dir: string, baseDir: string): Promise<string[]> {\n const files: string[] = []\n\n try {\n const entries = await fs.readdir(dir, { withFileTypes: true })\n\n for (const entry of entries) {\n const fullPath = path.join(dir, entry.name)\n\n if (entry.isDirectory()) {\n // Recursively collect from subdirectories\n const subFiles = await collectFiles(fullPath, baseDir)\n files.push(...subFiles)\n } else if (entry.isFile()) {\n // Check file size before adding\n const stats = await fs.stat(fullPath)\n if (stats.size <= MAX_ASSET_SIZE) {\n // Add relative path from base directory\n const relativePath = path.relative(baseDir, fullPath)\n files.push(relativePath)\n } else {\n // Warn user about skipped files\n const sizeMB = (stats.size / (1024 * 1024)).toFixed(2)\n const relativePath = path.relative(baseDir, fullPath)\n log.warning(`Skipping large asset: ${relativePath} (${sizeMB}MB exceeds 50MB limit)`)\n }\n }\n }\n } catch {\n // Directory doesn't exist or not accessible\n return []\n }\n\n return files\n}\n\n/**\n * Collect all static asset paths from .next/static\n *\n * Returns paths relative to project root, formatted for S3:\n * - `.next/static/chunks/main.js` → `_next/static/chunks/main.js`\n *\n * @param projectPath - Path to project root\n * @returns Array of static asset paths (using _next prefix)\n */\nexport async function collectStaticAssets(projectPath: string): Promise<string[]> {\n const staticDir = path.join(projectPath, '.next', 'static')\n\n try {\n await fs.stat(staticDir)\n } catch {\n // No static directory\n return []\n }\n\n const files = await collectFiles(staticDir, projectPath)\n\n // Convert .next/static to _next/static (Next.js convention)\n return files.map((file) => file.replace(/^\\.next\\//, '_next/'))\n}\n\n/**\n * Create Lambda deployment zip using build_for_lambda.sh\n *\n * This script:\n * - Copies static files to standalone build\n * - Creates lambda.zip from .next/standalone/\n * - Places zip at project root\n *\n * @param projectPath - Path to project root\n * @throws Error if script missing or execution fails\n */\nexport async function createLambdaZip(projectPath: string): Promise<void> {\n const scriptPath = path.join(projectPath, 'build_for_lambda.sh')\n\n // Check if script exists\n try {\n await fs.stat(scriptPath)\n } catch {\n throw new Error('build_for_lambda.sh not found. Run init command to set up project.')\n }\n\n // Execute script\n try {\n await execAsync('./build_for_lambda.sh', { cwd: projectPath })\n } catch (error) {\n const message = error instanceof Error ? error.message : 'Unknown error'\n throw new Error(`Failed to create Lambda zip: ${message}`)\n }\n\n // Verify zip was created\n const zipPath = path.join(projectPath, 'lambda.zip')\n try {\n await fs.stat(zipPath)\n } catch {\n throw new Error('lambda.zip was not created by build_for_lambda.sh')\n }\n}\n"],"names":["exec","fs","path","promisify","log","execAsync","MAX_ASSET_SIZE","getFileSize","filePath","stats","stat","size","collectFiles","dir","baseDir","files","entries","readdir","withFileTypes","entry","fullPath","join","name","isDirectory","subFiles","push","isFile","relativePath","relative","sizeMB","toFixed","warning","collectStaticAssets","projectPath","staticDir","map","file","replace","createLambdaZip","scriptPath","Error","cwd","error","message","zipPath"],"mappings":"AAAA,SAASA,IAAI,QAAQ,gBAAe;AACpC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AACvB,SAASC,SAAS,QAAQ,OAAM;AAEhC,YAAYC,SAAS,WAAU;AAE/B,MAAMC,YAAYF,UAAUH;AAE5B,sDAAsD;AACtD,MAAMM,iBAAiB,KAAK,OAAO,KAAK,OAAO;;AAE/C;;;;;CAKC,GACD,OAAO,eAAeC,YAAYC,QAAgB;IAChD,MAAMC,QAAQ,MAAMR,GAAGS,IAAI,CAACF;IAC5B,OAAOC,MAAME,IAAI;AACnB;AAEA;;;;;;;;;CASC,GACD,eAAeC,aAAaC,GAAW,EAAEC,OAAe;IACtD,MAAMC,QAAkB,EAAE;IAE1B,IAAI;QACF,MAAMC,UA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;;;;;;;;CAUC,GACD,OAAO,eAAeC,gBAAgBL,WAAmB;IACvD,MAAMM,aAAarC,KAAKmB,IAAI,CAACY,aAAa;IAE1C,yBAAyB;IACzB,IAAI;QACF,MAAMhC,GAAGS,IAAI,CAAC6B;IAChB,EAAE,OAAM;QACN,MAAM,IAAIC,MAAM;IAClB;IAEA,iBAAiB;IACjB,IAAI;QACF,MAAMnC,UAAU,yBAAyB;YAAEoC,KAAKR;QAAY;IAC9D,EAAE,OAAOS,OAAO;QACd,MAAMC,UAAUD,iBAAiBF,QAAQE,MAAMC,OAAO,GAAG;QACzD,MAAM,IAAIH,MAAM,CAAC,6BAA6B,EAAEG,SAAS;IAC3D;IAEA,yBAAyB;IACzB,MAAMC,UAAU1C,KAAKmB,IAAI,CAACY,aAAa;IACvC,IAAI;QACF,MAAMhC,GAAGS,IAAI,CAACkC;IAChB,EAAE,OAAM;QACN,MAAM,IAAIJ,MAAM;IAClB;AACF"}
@@ -19,7 +19,7 @@ const GITIGNORE_FILENAME = '.gitignore';
19
19
  }
20
20
  }
21
21
  // Parse existing entries
22
- const existingLines = existingContent.split(/\r?\n/).filter((line)=>line.trim());
22
+ const existingLines = existingContent.split('\n').filter((line)=>line.trim());
23
23
  const existingSet = new Set(existingLines);
24
24
  // Add new entries that don't exist
25
25
  const newEntries = entries.filter((entry)=>!existingSet.has(entry));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\nconst GITIGNORE_FILENAME = '.gitignore'\n\n/**\n * Ensure .gitignore exists and optionally add entries\n *\n * @param projectPath - Path to project directory\n * @param entries - Optional entries to add to .gitignore\n */\nexport async function ensureGitignore(projectPath: string, entries: string[] = []): Promise<void> {\n const gitignorePath = path.join(projectPath, GITIGNORE_FILENAME)\n\n let existingContent = ''\n try {\n existingContent = await fs.readFile(gitignorePath, 'utf-8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw new Error(`Failed to read ${GITIGNORE_FILENAME}: ${(error as Error).message}`)\n }\n }\n\n // Parse existing entries\n const existingLines = existingContent.split(/\\r?\\n/).filter((line) => line.trim())\n const existingSet = new Set(existingLines)\n\n // Add new entries that don't exist\n const newEntries = entries.filter((entry) => !existingSet.has(entry))\n\n if (newEntries.length > 0) {\n const newContent = existingContent\n ? `${existingContent.trimEnd()}\\n\\n# Figma CMS\\n${newEntries.join('\\n')}\\n`\n : `# Figma CMS\\n${newEntries.join('\\n')}\\n`\n\n await fs.writeFile(gitignorePath, newContent, 'utf-8')\n }\n}\n"],"names":["fs","path","GITIGNORE_FILENAME","ensureGitignore","projectPath","entries","gitignorePath","join","existingContent","readFile","error","code","Error","message","existingLines","split","filter","line","trim","existingSet","Set","newEntries","entry","has","length","newContent","trimEnd","writeFile"],"mappings":"AAAA;;CAEC,GAED,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,OAAO,eAAeC,gBAAgBC,WAAmB,EAAEC,UAAoB,EAAE;IAC/E,MAAMC,gBAAgBL,KAAKM,IAAI,CAACH,aAAaF;IAE7C,IAAIM,kBAAkB;IACtB,IAAI;QACFA,kBAAkB,MAAMR,GAAGS,QAAQ,CAACH,eAAe;IACrD,EAAE,OAAOI,OAAO;QACd,IAAI,AAACA,MAAgCC,IAAI,KAAK,UAAU;YACtD,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEV,mBAAmB,EAAE,EAAE,AAACQ,MAAgBG,OAAO,EAAE;QACrF;IACF;IAEA,yBAAyB;IACzB,MAAMC,gBAAgBN,gBAAgBO,KAAK,CAAC,SAASC,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI;IAC/E,MAAMC,cAAc,IAAIC,IAAIN;IAE5B,mCAAmC;IACnC,MAAMO,aAAahB,QAAQW,MAAM,CAAC,CAACM,QAAU,CAACH,YAAYI,GAAG,CAACD;IAE9D,IAAID,WAAWG,MAAM,GAAG,GAAG;QACzB,MAAMC,aAAajB,kBACf,GAAGA,gBAAgBkB,OAAO,GAAG,iBAAiB,EAAEL,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC,GACzE,CAAC,aAAa,EAAEc,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC;QAE7C,MAAMP,GAAG2B,SAAS,CAACrB,eAAemB,YAAY;IAChD;AACF"}
1
+ {"version":3,"sources":["../../src/utils/config.ts"],"sourcesContent":["/**\n * Configuration file management utilities\n */\n\nimport fs from 'fs/promises'\nimport path from 'path'\n\nconst GITIGNORE_FILENAME = '.gitignore'\n\n/**\n * Ensure .gitignore exists and optionally add entries\n *\n * @param projectPath - Path to project directory\n * @param entries - Optional entries to add to .gitignore\n */\nexport async function ensureGitignore(projectPath: string, entries: string[] = []): Promise<void> {\n const gitignorePath = path.join(projectPath, GITIGNORE_FILENAME)\n\n let existingContent = ''\n try {\n existingContent = await fs.readFile(gitignorePath, 'utf-8')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw new Error(`Failed to read ${GITIGNORE_FILENAME}: ${(error as Error).message}`)\n }\n }\n\n // Parse existing entries\n const existingLines = existingContent.split('\\n').filter((line) => line.trim())\n const existingSet = new Set(existingLines)\n\n // Add new entries that don't exist\n const newEntries = entries.filter((entry) => !existingSet.has(entry))\n\n if (newEntries.length > 0) {\n const newContent = existingContent\n ? `${existingContent.trimEnd()}\\n\\n# Figma CMS\\n${newEntries.join('\\n')}\\n`\n : `# Figma CMS\\n${newEntries.join('\\n')}\\n`\n\n await fs.writeFile(gitignorePath, newContent, 'utf-8')\n }\n}\n"],"names":["fs","path","GITIGNORE_FILENAME","ensureGitignore","projectPath","entries","gitignorePath","join","existingContent","readFile","error","code","Error","message","existingLines","split","filter","line","trim","existingSet","Set","newEntries","entry","has","length","newContent","trimEnd","writeFile"],"mappings":"AAAA;;CAEC,GAED,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,OAAO,eAAeC,gBAAgBC,WAAmB,EAAEC,UAAoB,EAAE;IAC/E,MAAMC,gBAAgBL,KAAKM,IAAI,CAACH,aAAaF;IAE7C,IAAIM,kBAAkB;IACtB,IAAI;QACFA,kBAAkB,MAAMR,GAAGS,QAAQ,CAACH,eAAe;IACrD,EAAE,OAAOI,OAAO;QACd,IAAI,AAACA,MAAgCC,IAAI,KAAK,UAAU;YACtD,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEV,mBAAmB,EAAE,EAAE,AAACQ,MAAgBG,OAAO,EAAE;QACrF;IACF;IAEA,yBAAyB;IACzB,MAAMC,gBAAgBN,gBAAgBO,KAAK,CAAC,MAAMC,MAAM,CAAC,CAACC,OAASA,KAAKC,IAAI;IAC5E,MAAMC,cAAc,IAAIC,IAAIN;IAE5B,mCAAmC;IACnC,MAAMO,aAAahB,QAAQW,MAAM,CAAC,CAACM,QAAU,CAACH,YAAYI,GAAG,CAACD;IAE9D,IAAID,WAAWG,MAAM,GAAG,GAAG;QACzB,MAAMC,aAAajB,kBACf,GAAGA,gBAAgBkB,OAAO,GAAG,iBAAiB,EAAEL,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC,GACzE,CAAC,aAAa,EAAEc,WAAWd,IAAI,CAAC,MAAM,EAAE,CAAC;QAE7C,MAAMP,GAAG2B,SAAS,CAACrB,eAAemB,YAAY;IAChD;AACF"}
@@ -1,17 +1,16 @@
1
1
  /**
2
- * Get an environment variable value from .env file
2
+ * Generate a cryptographically secure secret for PAYLOAD_SECRET
3
3
  *
4
- * @param projectPath - Path to project directory
5
- * @param key - Environment variable name to retrieve
6
- * @returns The value if found, null otherwise
4
+ * @returns 24-character hexadecimal string
7
5
  */
8
- export declare function getEnvVar(projectPath: string, key: string): Promise<null | string>;
6
+ export declare function generateSecret(): string;
9
7
  /**
10
- * Add or update an environment variable in .env file
8
+ * Manage environment files for a new project
9
+ *
10
+ * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
11
11
  *
12
12
  * @param projectPath - Path to project directory
13
- * @param key - Environment variable name
14
- * @param value - Environment variable value
13
+ * @returns The generated payload secret
15
14
  */
16
- export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
15
+ export declare function manageEnvFiles(projectPath: string): Promise<string>;
17
16
  //# sourceMappingURL=env-management.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CA+BxF;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAmEf"}
1
+ {"version":3,"file":"env-management.d.ts","sourceRoot":"","sources":["../../src/utils/env-management.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAoDD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8CzE"}