@payloadcms/figma 0.0.1-alpha.3 → 0.0.1-alpha.30

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 (209) hide show
  1. package/dist/api/control-plane.d.ts +22 -1
  2. package/dist/api/control-plane.d.ts.map +1 -1
  3. package/dist/api/control-plane.js +54 -15
  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 +42 -12
  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 +2 -1
  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/oauth-flow.d.ts +1 -1
  15. package/dist/auth/oauth-flow.d.ts.map +1 -1
  16. package/dist/auth/oauth-flow.js +5 -5
  17. package/dist/auth/oauth-flow.js.map +1 -1
  18. package/dist/auth/project-token.d.ts.map +1 -1
  19. package/dist/auth/project-token.js +9 -4
  20. package/dist/auth/project-token.js.map +1 -1
  21. package/dist/auth/token-store.d.ts +10 -0
  22. package/dist/auth/token-store.d.ts.map +1 -1
  23. package/dist/auth/token-store.js +20 -0
  24. package/dist/auth/token-store.js.map +1 -1
  25. package/dist/cli.js +3 -0
  26. package/dist/cli.js.map +1 -1
  27. package/dist/commands/deploy.d.ts +4 -0
  28. package/dist/commands/deploy.d.ts.map +1 -1
  29. package/dist/commands/deploy.js +68 -126
  30. package/dist/commands/deploy.js.map +1 -1
  31. package/dist/commands/init.d.ts +1 -5
  32. package/dist/commands/init.d.ts.map +1 -1
  33. package/dist/commands/init.js +90 -85
  34. package/dist/commands/init.js.map +1 -1
  35. package/dist/commands/list-tokens.js +2 -2
  36. package/dist/commands/list-tokens.js.map +1 -1
  37. package/dist/commands/login.d.ts +8 -1
  38. package/dist/commands/login.d.ts.map +1 -1
  39. package/dist/commands/login.js +12 -6
  40. package/dist/commands/login.js.map +1 -1
  41. package/dist/commands/logout.js +2 -2
  42. package/dist/commands/logout.js.map +1 -1
  43. package/dist/config/oauth.d.ts +5 -0
  44. package/dist/config/oauth.d.ts.map +1 -1
  45. package/dist/config/oauth.js +9 -4
  46. package/dist/config/oauth.js.map +1 -1
  47. package/dist/db-content-api/README.md +108 -0
  48. package/dist/db-content-api/generated/content-api-types.d.ts +3702 -0
  49. package/dist/db-content-api/generated/content-api-types.d.ts.map +1 -0
  50. package/dist/db-content-api/generated/content-api-types.js +7 -0
  51. package/dist/db-content-api/generated/content-api-types.js.map +1 -0
  52. package/dist/db-content-api/index.d.ts +18 -0
  53. package/dist/db-content-api/index.d.ts.map +1 -0
  54. package/dist/db-content-api/index.js +551 -0
  55. package/dist/db-content-api/index.js.map +1 -0
  56. package/dist/db-content-api/temp-utilities/pagination.d.ts +13 -0
  57. package/dist/db-content-api/temp-utilities/pagination.d.ts.map +1 -0
  58. package/dist/db-content-api/temp-utilities/pagination.js +45 -0
  59. package/dist/db-content-api/temp-utilities/pagination.js.map +1 -0
  60. package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
  61. package/dist/db-content-api/temp-utilities/slug.d.ts.map +1 -0
  62. package/dist/db-content-api/temp-utilities/slug.js +3 -0
  63. package/dist/db-content-api/temp-utilities/slug.js.map +1 -0
  64. package/dist/db-content-api/temp-utilities/sorting.d.ts +7 -0
  65. package/dist/db-content-api/temp-utilities/sorting.d.ts.map +1 -0
  66. package/dist/db-content-api/temp-utilities/sorting.js +71 -0
  67. package/dist/db-content-api/temp-utilities/sorting.js.map +1 -0
  68. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +4 -0
  69. package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts.map +1 -0
  70. package/dist/db-content-api/temp-utilities/unwrapDocument.js +45 -0
  71. package/dist/db-content-api/temp-utilities/unwrapDocument.js.map +1 -0
  72. package/dist/db-content-api/utilities/auth.d.ts +30 -0
  73. package/dist/db-content-api/utilities/auth.d.ts.map +1 -0
  74. package/dist/db-content-api/utilities/auth.js +81 -0
  75. package/dist/db-content-api/utilities/auth.js.map +1 -0
  76. package/dist/db-content-api/utilities/data.d.ts +24 -0
  77. package/dist/db-content-api/utilities/data.d.ts.map +1 -0
  78. package/dist/db-content-api/utilities/data.js +118 -0
  79. package/dist/db-content-api/utilities/data.js.map +1 -0
  80. package/dist/db-content-api/utilities/joins.d.ts +55 -0
  81. package/dist/db-content-api/utilities/joins.d.ts.map +1 -0
  82. package/dist/db-content-api/utilities/joins.js +130 -0
  83. package/dist/db-content-api/utilities/joins.js.map +1 -0
  84. package/dist/db-content-api/utilities/where.d.ts +12 -0
  85. package/dist/db-content-api/utilities/where.d.ts.map +1 -0
  86. package/dist/db-content-api/utilities/where.js +63 -0
  87. package/dist/db-content-api/utilities/where.js.map +1 -0
  88. package/dist/endpoints/health.d.ts +3 -0
  89. package/dist/endpoints/health.d.ts.map +1 -0
  90. package/dist/endpoints/health.js +11 -0
  91. package/dist/endpoints/health.js.map +1 -0
  92. package/dist/exports/client.d.ts +3 -0
  93. package/dist/exports/client.d.ts.map +1 -0
  94. package/dist/exports/client.js +4 -0
  95. package/dist/exports/client.js.map +1 -0
  96. package/dist/index.d.ts +2 -1
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +3 -1
  99. package/dist/index.js.map +1 -1
  100. package/dist/oauth/components/LoginButton/index.d.ts.map +1 -1
  101. package/dist/oauth/components/LoginButton/index.js +50 -6
  102. package/dist/oauth/components/LoginButton/index.js.map +1 -1
  103. package/dist/oauth/components/LoginButton/index.scss +50 -3
  104. package/dist/oauth/components/LogoutButton/index.d.ts.map +1 -1
  105. package/dist/oauth/components/LogoutButton/index.js +0 -1
  106. package/dist/oauth/components/LogoutButton/index.js.map +1 -1
  107. package/dist/oauth/defaults.d.ts.map +1 -1
  108. package/dist/oauth/defaults.js +29 -5
  109. package/dist/oauth/defaults.js.map +1 -1
  110. package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +1 -1
  111. package/dist/oauth/endpoints/getLoginEndpoint.js +1 -1
  112. package/dist/oauth/endpoints/getLoginEndpoint.js.map +1 -1
  113. package/dist/oauth/index.d.ts.map +1 -1
  114. package/dist/oauth/index.js +42 -6
  115. package/dist/oauth/index.js.map +1 -1
  116. package/dist/oauth/strategy/index.d.ts.map +1 -1
  117. package/dist/oauth/strategy/index.js +6 -2
  118. package/dist/oauth/strategy/index.js.map +1 -1
  119. package/dist/oauth/types.d.ts +6 -6
  120. package/dist/oauth/types.d.ts.map +1 -1
  121. package/dist/oauth/types.js.map +1 -1
  122. package/dist/oauth/utilities/createCookieOptions.d.ts.map +1 -1
  123. package/dist/oauth/utilities/createCookieOptions.js.map +1 -1
  124. package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
  125. package/dist/oauth/utilities/isDuplicateKeyError.d.ts.map +1 -0
  126. package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
  127. package/dist/oauth/utilities/isDuplicateKeyError.js.map +1 -0
  128. package/dist/oauth/utilities/refreshTokens.d.ts.map +1 -1
  129. package/dist/oauth/utilities/refreshTokens.js +1 -1
  130. package/dist/oauth/utilities/refreshTokens.js.map +1 -1
  131. package/dist/plugin/build-config.d.ts +21 -4
  132. package/dist/plugin/build-config.d.ts.map +1 -1
  133. package/dist/plugin/build-config.js +89 -9
  134. package/dist/plugin/build-config.js.map +1 -1
  135. package/dist/storage-content-api/api-types.d.ts +161 -0
  136. package/dist/storage-content-api/api-types.d.ts.map +1 -0
  137. package/dist/storage-content-api/api-types.js +6 -0
  138. package/dist/storage-content-api/api-types.js.map +1 -0
  139. package/dist/storage-content-api/client.d.ts +6 -0
  140. package/dist/storage-content-api/client.d.ts.map +1 -0
  141. package/dist/storage-content-api/client.js +36 -0
  142. package/dist/storage-content-api/client.js.map +1 -0
  143. package/dist/storage-content-api/generateURL.d.ts +7 -0
  144. package/dist/storage-content-api/generateURL.d.ts.map +1 -0
  145. package/dist/storage-content-api/generateURL.js +7 -0
  146. package/dist/storage-content-api/generateURL.js.map +1 -0
  147. package/dist/storage-content-api/handleDelete.d.ts +8 -0
  148. package/dist/storage-content-api/handleDelete.d.ts.map +1 -0
  149. package/dist/storage-content-api/handleDelete.js +15 -0
  150. package/dist/storage-content-api/handleDelete.js.map +1 -0
  151. package/dist/storage-content-api/handleUpload.d.ts +11 -0
  152. package/dist/storage-content-api/handleUpload.d.ts.map +1 -0
  153. package/dist/storage-content-api/handleUpload.js +126 -0
  154. package/dist/storage-content-api/handleUpload.js.map +1 -0
  155. package/dist/storage-content-api/index.d.ts +5 -0
  156. package/dist/storage-content-api/index.d.ts.map +1 -0
  157. package/dist/storage-content-api/index.js +31 -0
  158. package/dist/storage-content-api/index.js.map +1 -0
  159. package/dist/storage-content-api/staticHandler.d.ts +10 -0
  160. package/dist/storage-content-api/staticHandler.d.ts.map +1 -0
  161. package/dist/storage-content-api/staticHandler.js +35 -0
  162. package/dist/storage-content-api/staticHandler.js.map +1 -0
  163. package/dist/storage-content-api/types.d.ts +10 -0
  164. package/dist/storage-content-api/types.d.ts.map +1 -0
  165. package/dist/storage-content-api/types.js +3 -0
  166. package/dist/storage-content-api/types.js.map +1 -0
  167. package/dist/templates/README.md +19 -0
  168. package/dist/utils/env-management.d.ts +9 -8
  169. package/dist/utils/env-management.d.ts.map +1 -1
  170. package/dist/utils/env-management.js +73 -74
  171. package/dist/utils/env-management.js.map +1 -1
  172. package/dist/utils/formatter.d.ts.map +1 -1
  173. package/dist/utils/formatter.js +1 -7
  174. package/dist/utils/formatter.js.map +1 -1
  175. package/dist/utils/lambda-config.d.ts.map +1 -1
  176. package/dist/utils/lambda-config.js +1 -0
  177. package/dist/utils/lambda-config.js.map +1 -1
  178. package/dist/utils/messages.d.ts.map +1 -1
  179. package/dist/utils/messages.js +5 -7
  180. package/dist/utils/messages.js.map +1 -1
  181. package/dist/utils/payload-config-ast.d.ts +22 -3
  182. package/dist/utils/payload-config-ast.d.ts.map +1 -1
  183. package/dist/utils/payload-config-ast.js +89 -31
  184. package/dist/utils/payload-config-ast.js.map +1 -1
  185. package/dist/utils/payload-config-finder.d.ts +2 -2
  186. package/dist/utils/payload-config-finder.d.ts.map +1 -1
  187. package/dist/utils/payload-config-finder.js +48 -9
  188. package/dist/utils/payload-config-finder.js.map +1 -1
  189. package/dist/utils/payload-config-modifier.d.ts.map +1 -1
  190. package/dist/utils/payload-config-modifier.js +33 -4
  191. package/dist/utils/payload-config-modifier.js.map +1 -1
  192. package/dist/utils/payload-package-check.d.ts +5 -0
  193. package/dist/utils/payload-package-check.d.ts.map +1 -1
  194. package/dist/utils/payload-package-check.js +48 -4
  195. package/dist/utils/payload-package-check.js.map +1 -1
  196. package/dist/utils/project.d.ts.map +1 -1
  197. package/dist/utils/project.js +8 -6
  198. package/dist/utils/project.js.map +1 -1
  199. package/dist/utils/s3-upload.d.ts +0 -1
  200. package/dist/utils/s3-upload.d.ts.map +1 -1
  201. package/dist/utils/s3-upload.js +10 -3
  202. package/dist/utils/s3-upload.js.map +1 -1
  203. package/dist/utils/token-display.d.ts.map +1 -1
  204. package/dist/utils/token-display.js +11 -5
  205. package/dist/utils/token-display.js.map +1 -1
  206. package/dist/utils/typescript-validator.d.ts.map +1 -1
  207. package/dist/utils/typescript-validator.js +1 -6
  208. package/dist/utils/typescript-validator.js.map +1 -1
  209. package/package.json +24 -7
@@ -0,0 +1,126 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ const PART_SIZE = 5 * 1024 * 1024 // 5MB per part
4
+ ;
5
+ export const getHandleUpload = ({ client, prefix = '' })=>{
6
+ return async ({ data, file })=>{
7
+ const fileKey = path.posix.join(data.prefix || prefix, file.filename);
8
+ const fileData = file.tempFilePath ? fs.readFileSync(file.tempFilePath) : file.buffer;
9
+ const fileSize = file.filesize || fileData.length;
10
+ if (fileSize > PART_SIZE) {
11
+ await uploadMultipart({
12
+ client,
13
+ fileData,
14
+ fileKey,
15
+ mimeType: file.mimeType
16
+ });
17
+ } else {
18
+ await uploadSingleFile({
19
+ client,
20
+ fileData,
21
+ fileKey,
22
+ mimeType: file.mimeType
23
+ });
24
+ }
25
+ return data;
26
+ };
27
+ };
28
+ async function uploadSingleFile({ client, fileData, fileKey, mimeType }) {
29
+ const { data, error } = await client.POST('/api/v0/uploads/sign', {
30
+ body: {
31
+ contentType: mimeType,
32
+ expiresIn: 3600,
33
+ filename: fileKey
34
+ }
35
+ });
36
+ if (error || !data) {
37
+ throw new Error(`Failed to get presigned upload URL: ${JSON.stringify(error)}`);
38
+ }
39
+ const uploadResponse = await fetch(data.url, {
40
+ body: fileData,
41
+ headers: {
42
+ 'Content-Type': mimeType
43
+ },
44
+ method: 'PUT'
45
+ });
46
+ if (!uploadResponse.ok) {
47
+ throw new Error(`Failed to upload to S3: ${uploadResponse.status} ${uploadResponse.statusText}`);
48
+ }
49
+ }
50
+ async function uploadMultipart({ client, fileData, fileKey, mimeType }) {
51
+ const { data: initiateData, error: initiateError } = await client.POST('/api/v0/uploads/multipart/initiate', {
52
+ body: {
53
+ contentType: mimeType,
54
+ filename: fileKey
55
+ }
56
+ });
57
+ if (initiateError || !initiateData) {
58
+ throw new Error(`Failed to initiate multipart upload: ${JSON.stringify(initiateError)}`);
59
+ }
60
+ const { uploadId } = initiateData;
61
+ try {
62
+ const numParts = Math.ceil(fileData.length / PART_SIZE);
63
+ const partNumbers = Array.from({
64
+ length: numParts
65
+ }, (_, i)=>i + 1);
66
+ const { data: partsData, error: partsError } = await client.POST('/api/v0/uploads/multipart/parts', {
67
+ body: {
68
+ expiresIn: 3600,
69
+ filename: fileKey,
70
+ partNumbers,
71
+ uploadId
72
+ }
73
+ });
74
+ if (partsError || !partsData) {
75
+ throw new Error(`Failed to get part URLs: ${JSON.stringify(partsError)}`);
76
+ }
77
+ const { parts } = partsData;
78
+ if (!parts || !Array.isArray(parts)) {
79
+ throw new Error('Invalid response from part URLs endpoint: parts is not an array');
80
+ }
81
+ const uploadedParts = await Promise.all(parts.map(async ({ partNumber, url })=>{
82
+ const start = (partNumber - 1) * PART_SIZE;
83
+ const end = Math.min(start + PART_SIZE, fileData.length);
84
+ const partData = fileData.slice(start, end);
85
+ const uploadResponse = await fetch(url, {
86
+ body: partData,
87
+ headers: {
88
+ 'Content-Type': mimeType
89
+ },
90
+ method: 'PUT'
91
+ });
92
+ const etag = uploadResponse.headers.get('ETag');
93
+ if (!etag) {
94
+ throw new Error(`No ETag returned for part ${partNumber}`);
95
+ }
96
+ return {
97
+ ETag: etag,
98
+ PartNumber: partNumber
99
+ };
100
+ }));
101
+ const { error: completeError } = await client.POST('/api/v0/uploads/multipart/complete', {
102
+ body: {
103
+ filename: fileKey,
104
+ parts: uploadedParts,
105
+ uploadId
106
+ }
107
+ });
108
+ if (completeError) {
109
+ throw new Error(`Failed to complete multipart upload: ${JSON.stringify(completeError)}`);
110
+ }
111
+ } catch (error) {
112
+ try {
113
+ await client.POST('/api/v0/uploads/multipart/abort', {
114
+ body: {
115
+ filename: fileKey,
116
+ uploadId
117
+ }
118
+ });
119
+ } catch {
120
+ // Ignore abort errors
121
+ }
122
+ throw error;
123
+ }
124
+ }
125
+
126
+ //# sourceMappingURL=handleUpload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/handleUpload.ts"],"sourcesContent":["import type { HandleUpload } from '@payloadcms/plugin-cloud-storage/types'\nimport type { CollectionConfig } from 'payload'\n\nimport fs from 'fs'\nimport path from 'path'\n\nimport type { StorageClient } from './client.js'\n\ntype Args = {\n client: StorageClient\n collection: CollectionConfig\n prefix?: string\n}\n\nconst PART_SIZE = 5 * 1024 * 1024 // 5MB per part\n\nexport const getHandleUpload = ({ client, prefix = '' }: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n const fileData = file.tempFilePath ? fs.readFileSync(file.tempFilePath) : file.buffer\n const fileSize = file.filesize || fileData.length\n\n if (fileSize > PART_SIZE) {\n await uploadMultipart({ client, fileData, fileKey, mimeType: file.mimeType })\n } else {\n await uploadSingleFile({ client, fileData, fileKey, mimeType: file.mimeType })\n }\n\n return data\n }\n}\n\nasync function uploadSingleFile({\n client,\n fileData,\n fileKey,\n mimeType,\n}: {\n client: StorageClient\n fileData: Buffer\n fileKey: string\n mimeType: string\n}): Promise<void> {\n const { data, error } = await client.POST('/api/v0/uploads/sign', {\n body: { contentType: mimeType, expiresIn: 3600, filename: fileKey },\n })\n\n if (error || !data) {\n throw new Error(`Failed to get presigned upload URL: ${JSON.stringify(error)}`)\n }\n\n const uploadResponse = await fetch(data.url, {\n body: fileData,\n headers: { 'Content-Type': mimeType },\n method: 'PUT',\n })\n\n if (!uploadResponse.ok) {\n throw new Error(`Failed to upload to S3: ${uploadResponse.status} ${uploadResponse.statusText}`)\n }\n}\n\nasync function uploadMultipart({\n client,\n fileData,\n fileKey,\n mimeType,\n}: {\n client: StorageClient\n fileData: Buffer\n fileKey: string\n mimeType: string\n}): Promise<void> {\n const { data: initiateData, error: initiateError } = await client.POST(\n '/api/v0/uploads/multipart/initiate',\n {\n body: { contentType: mimeType, filename: fileKey },\n },\n )\n\n if (initiateError || !initiateData) {\n throw new Error(`Failed to initiate multipart upload: ${JSON.stringify(initiateError)}`)\n }\n\n const { uploadId } = initiateData\n\n try {\n const numParts = Math.ceil(fileData.length / PART_SIZE)\n const partNumbers = Array.from({ length: numParts }, (_, i) => i + 1)\n\n const { data: partsData, error: partsError } = await client.POST(\n '/api/v0/uploads/multipart/parts',\n {\n body: { expiresIn: 3600, filename: fileKey, partNumbers, uploadId },\n },\n )\n\n if (partsError || !partsData) {\n throw new Error(`Failed to get part URLs: ${JSON.stringify(partsError)}`)\n }\n\n const { parts } = partsData\n\n if (!parts || !Array.isArray(parts)) {\n throw new Error('Invalid response from part URLs endpoint: parts is not an array')\n }\n\n const uploadedParts = await Promise.all(\n parts.map(async ({ partNumber, url }) => {\n const start = (partNumber - 1) * PART_SIZE\n const end = Math.min(start + PART_SIZE, fileData.length)\n const partData = fileData.slice(start, end)\n\n const uploadResponse = await fetch(url, {\n body: partData,\n headers: { 'Content-Type': mimeType },\n method: 'PUT',\n })\n\n const etag = uploadResponse.headers.get('ETag')\n if (!etag) {\n throw new Error(`No ETag returned for part ${partNumber}`)\n }\n\n return { ETag: etag, PartNumber: partNumber }\n }),\n )\n\n const { error: completeError } = await client.POST('/api/v0/uploads/multipart/complete', {\n body: { filename: fileKey, parts: uploadedParts, uploadId },\n })\n\n if (completeError) {\n throw new Error(`Failed to complete multipart upload: ${JSON.stringify(completeError)}`)\n }\n } catch (error) {\n try {\n await client.POST('/api/v0/uploads/multipart/abort', {\n body: { filename: fileKey, uploadId },\n })\n } catch {\n // Ignore abort errors\n }\n throw error\n }\n}\n"],"names":["fs","path","PART_SIZE","getHandleUpload","client","prefix","data","file","fileKey","posix","join","filename","fileData","tempFilePath","readFileSync","buffer","fileSize","filesize","length","uploadMultipart","mimeType","uploadSingleFile","error","POST","body","contentType","expiresIn","Error","JSON","stringify","uploadResponse","fetch","url","headers","method","ok","status","statusText","initiateData","initiateError","uploadId","numParts","Math","ceil","partNumbers","Array","from","_","i","partsData","partsError","parts","isArray","uploadedParts","Promise","all","map","partNumber","start","end","min","partData","slice","etag","get","ETag","PartNumber","completeError"],"mappings":"AAGA,OAAOA,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAUvB,MAAMC,YAAY,IAAI,OAAO,KAAK,eAAe;;AAEjD,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,SAAS,EAAE,EAAQ;IAC3D,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QACpE,MAAMC,WAAWL,KAAKM,YAAY,GAAGb,GAAGc,YAAY,CAACP,KAAKM,YAAY,IAAIN,KAA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,YAAY;YAC3D;YAEA,OAAO;gBAAEQ,MAAMF;gBAAMG,YAAYT;YAAW;QAC9C;QAGF,MAAM,EAAEnC,OAAO6C,aAAa,EAAE,GAAG,MAAM/D,OAAOmB,IAAI,CAAC,sCAAsC;YACvFC,MAAM;gBAAEb,UAAUH;gBAAS2C,OAAOE;gBAAeb;YAAS;QAC5D;QAEA,IAAI2B,eAAe;YACjB,MAAM,IAAIxC,MAAM,CAAC,qCAAqC,EAAEC,KAAKC,SAAS,CAACsC,gBAAgB;QACzF;IACF,EAAE,OAAO7C,OAAO;QACd,IAAI;YACF,MAAMlB,OAAOmB,IAAI,CAAC,mCAAmC;gBACnDC,MAAM;oBAAEb,UAAUH;oBAASgC;gBAAS;YACtC;QACF,EAAE,OAAM;QACN,sBAAsB;QACxB;QACA,MAAMlB;IACR;AACF"}
@@ -0,0 +1,5 @@
1
+ import type { Adapter } from '@payloadcms/plugin-cloud-storage/types';
2
+ import type { StorageClientConfig } from './types.js';
3
+ export type { StorageClientConfig } from './types.js';
4
+ export declare function contentApiStorageAdapter(config: StorageClientConfig): Adapter;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage-content-api/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,wCAAwC,CAAA;AAEvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAQrD,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAa7E"}
@@ -0,0 +1,31 @@
1
+ import { createStorageClient } from './client.js';
2
+ import { getGenerateURL } from './generateURL.js';
3
+ import { getHandleDelete } from './handleDelete.js';
4
+ import { getHandleUpload } from './handleUpload.js';
5
+ import { getHandler } from './staticHandler.js';
6
+ export function contentApiStorageAdapter(config) {
7
+ return ({ collection, prefix })=>{
8
+ const client = createStorageClient(config);
9
+ const baseUrl = config.baseUrl;
10
+ return {
11
+ name: 'content-api',
12
+ generateURL: getGenerateURL({
13
+ baseUrl
14
+ }),
15
+ handleDelete: getHandleDelete({
16
+ client
17
+ }),
18
+ handleUpload: getHandleUpload({
19
+ client,
20
+ collection,
21
+ prefix
22
+ }),
23
+ staticHandler: getHandler({
24
+ client,
25
+ collection
26
+ })
27
+ };
28
+ };
29
+ }
30
+
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/index.ts"],"sourcesContent":["import type { Adapter, GeneratedAdapter } from '@payloadcms/plugin-cloud-storage/types'\n\nimport type { StorageClientConfig } from './types.js'\n\nimport { createStorageClient } from './client.js'\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type { StorageClientConfig } from './types.js'\n\nexport function contentApiStorageAdapter(config: StorageClientConfig): Adapter {\n return ({ collection, prefix }): GeneratedAdapter => {\n const client = createStorageClient(config)\n const baseUrl = config.baseUrl\n\n return {\n name: 'content-api',\n generateURL: getGenerateURL({ baseUrl }),\n handleDelete: getHandleDelete({ client }),\n handleUpload: getHandleUpload({ client, collection, prefix }),\n staticHandler: getHandler({ client, collection }),\n }\n }\n}\n"],"names":["createStorageClient","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","contentApiStorageAdapter","config","collection","prefix","client","baseUrl","name","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,cAAa;AACjD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAI/C,OAAO,SAASC,yBAAyBC,MAA2B;IAClE,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,MAAMC,SAAST,oBAAoBM;QACnC,MAAMI,UAAUJ,OAAOI,OAAO;QAE9B,OAAO;YACLC,MAAM;YACNC,aAAaX,eAAe;gBAAES;YAAQ;YACtCG,cAAcX,gBAAgB;gBAAEO;YAAO;YACvCK,cAAcX,gBAAgB;gBAAEM;gBAAQF;gBAAYC;YAAO;YAC3DO,eAAeX,WAAW;gBAAEK;gBAAQF;YAAW;QACjD;IACF;AACF"}
@@ -0,0 +1,10 @@
1
+ import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types';
2
+ import type { CollectionConfig } from 'payload';
3
+ import type { StorageClient } from './client.js';
4
+ type Args = {
5
+ client: StorageClient;
6
+ collection: CollectionConfig;
7
+ };
8
+ export declare const getHandler: ({ client, collection }: Args) => StaticHandler;
9
+ export {};
10
+ //# sourceMappingURL=staticHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../src/storage-content-api/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAK/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,KAAK,IAAI,GAAG;IACV,MAAM,EAAE,aAAa,CAAA;IACrB,UAAU,EAAE,gBAAgB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,UAAU,2BAA4B,IAAI,KAAG,aAqBzD,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities';
2
+ import path from 'path';
3
+ export const getHandler = ({ client, collection })=>{
4
+ return async (req, { params: { clientUploadContext, filename } })=>{
5
+ try {
6
+ const prefix = await getFilePrefix({
7
+ clientUploadContext,
8
+ collection,
9
+ filename,
10
+ req
11
+ });
12
+ const key = path.posix.join(prefix, filename);
13
+ const { data, error } = await client.POST('/api/v0/uploads/download/sign', {
14
+ body: {
15
+ expiresIn: 7200,
16
+ filename: key
17
+ }
18
+ });
19
+ if (error || !data) {
20
+ req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`);
21
+ return new Response('Internal Server Error', {
22
+ status: 500
23
+ });
24
+ }
25
+ return Response.redirect(data.url, 302);
26
+ } catch (err) {
27
+ req.payload.logger.error(err);
28
+ return new Response('Internal Server Error', {
29
+ status: 500
30
+ });
31
+ }
32
+ };
33
+ };
34
+
35
+ //# sourceMappingURL=staticHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/staticHandler.ts"],"sourcesContent":["import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { CollectionConfig } from 'payload'\n\nimport { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities'\nimport path from 'path'\n\nimport type { StorageClient } from './client.js'\n\ntype Args = {\n client: StorageClient\n collection: CollectionConfig\n}\n\nexport const getHandler = ({ client, collection }: Args): StaticHandler => {\n return async (req, { params: { clientUploadContext, filename } }) => {\n try {\n const prefix = await getFilePrefix({ clientUploadContext, collection, filename, req })\n const key = path.posix.join(prefix, filename)\n\n const { data, error } = await client.POST('/api/v0/uploads/download/sign', {\n body: { expiresIn: 7200, filename: key },\n })\n\n if (error || !data) {\n req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`)\n return new Response('Internal Server Error', { status: 500 })\n }\n\n return Response.redirect(data.url, 302)\n } catch (err) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getFilePrefix","path","getHandler","client","collection","req","params","clientUploadContext","filename","prefix","key","posix","join","data","error","POST","body","expiresIn","payload","logger","JSON","stringify","Response","status","redirect","url","err"],"mappings":"AAGA,SAASA,aAAa,QAAQ,6CAA4C;AAC1E,OAAOC,UAAU,OAAM;AASvB,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAQ;IACrD,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,QAAQ,EAAE,EAAE;QAC9D,IAAI;YACF,MAAMC,SAAS,MAAMT,cAAc;gBAAEO;gBAAqBH;gBAAYI;gBAAUH;YAAI;YACpF,MAAMK,MAAMT,KAAKU,KAAK,CAACC,IAAI,CAACH,QAAQD;YAEpC,MAAM,EAAEK,IAAI,EAAEC,KAAK,EAAE,GAAG,MAAMX,OAAOY,IAAI,CAAC,iCAAiC;gBACzEC,MAAM;oBAAEC,WAAW;oBAAMT,UAAUE;gBAAI;YACzC;YAEA,IAAII,SAAS,CAACD,MAAM;gBAClBR,IAAIa,OAAO,CAACC,MAAM,CAACL,KAAK,CAAC,CAAC,mCAAmC,EAAEM,KAAKC,SAAS,CAACP,QAAQ;gBACtF,OAAO,IAAIQ,SAAS,yBAAyB;oBAAEC,QAAQ;gBAAI;YAC7D;YAEA,OAAOD,SAASE,QAAQ,CAACX,KAAKY,GAAG,EAAE;QACrC,EAAE,OAAOC,KAAK;YACZrB,IAAIa,OAAO,CAACC,MAAM,CAACL,KAAK,CAACY;YACzB,OAAO,IAAIJ,SAAS,yBAAyB;gBAAEC,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AuthMode } from '../db-content-api/utilities/auth.js';
2
+ export type StorageClientConfig = {
3
+ auth: AuthMode;
4
+ baseUrl: string;
5
+ contentSystemId: string;
6
+ } | {
7
+ baseUrl: string;
8
+ contentApiKey: string;
9
+ };
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/storage-content-api/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAEnE,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;CACxB,GACD;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { };
2
+
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/storage-content-api/types.ts"],"sourcesContent":["import type { AuthMode } from '../db-content-api/utilities/auth.js'\n\nexport type StorageClientConfig =\n | {\n auth: AuthMode\n baseUrl: string\n contentSystemId: string\n }\n | { baseUrl: string; contentApiKey: string }\n"],"names":[],"mappings":"AAEA,WAM8C"}
@@ -0,0 +1,19 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ A Payload project configured for running on Figma infrastructure.
4
+
5
+ ## Getting Started
6
+
7
+ pnpm dev
8
+
9
+ Open http://localhost:3000/admin to access the admin panel.
10
+
11
+ ## Deployment
12
+
13
+ npx @payloadcms/figma deploy
14
+
15
+ Deploys to Figma infrastructure.
16
+
17
+ ## Resources
18
+
19
+ - [Payload Docs](https://payloadcms.com/docs)
@@ -1,16 +1,17 @@
1
1
  /**
2
- * Generate a cryptographically secure secret for PAYLOAD_SECRET
2
+ * Get an environment variable value from .env file
3
3
  *
4
- * @returns 24-character hexadecimal string
4
+ * @param projectPath - Path to project directory
5
+ * @param key - Environment variable name to retrieve
6
+ * @returns The value if found, null otherwise
5
7
  */
6
- export declare function generateSecret(): string;
8
+ export declare function getEnvVar(projectPath: string, key: string): Promise<null | string>;
7
9
  /**
8
- * Manage environment files for a new project
9
- *
10
- * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
10
+ * Add or update an environment variable in .env file
11
11
  *
12
12
  * @param projectPath - Path to project directory
13
- * @returns The generated payload secret
13
+ * @param key - Environment variable name
14
+ * @param value - Environment variable value
14
15
  */
15
- export declare function manageEnvFiles(projectPath: string): Promise<string>;
16
+ export declare function addOrUpdateEnvVar(projectPath: string, key: string, value: string): Promise<void>;
16
17
  //# 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":"AAIA;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAoDD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8CzE"}
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,97 +1,96 @@
1
- import { randomBytes } from 'crypto';
2
1
  import fs from 'fs/promises';
3
2
  import path from 'path';
4
3
  /**
5
- * Generate a cryptographically secure secret for PAYLOAD_SECRET
4
+ * Get an environment variable value from .env file
6
5
  *
7
- * @returns 24-character hexadecimal string
8
- */ export function generateSecret() {
9
- return randomBytes(32).toString('hex').slice(0, 24);
10
- }
11
- /**
12
- * Sanitize and process environment file contents
13
- *
14
- * @param contents - Raw .env file contents
15
- * @param payloadSecret - Secret to use for PAYLOAD_SECRET
16
- * @returns Processed .env contents
17
- */ function sanitizeEnv(contents, payloadSecret) {
18
- const lines = contents.split('\n');
19
- const seenKeys = new Set();
20
- const processedLines = [];
21
- for (const line of lines){
22
- // Skip empty lines and comments
23
- if (!line.trim() || line.trim().startsWith('#')) {
24
- processedLines.push(line);
25
- continue;
26
- }
27
- // Skip lines without =
28
- if (!line.includes('=')) {
29
- processedLines.push(line);
30
- continue;
31
- }
32
- const [key] = line.split('=');
33
- const trimmedKey = key.trim();
34
- // Skip duplicate keys
35
- if (seenKeys.has(trimmedKey)) {
36
- continue;
37
- }
38
- seenKeys.add(trimmedKey);
39
- // Replace PAYLOAD_SECRET with actual value
40
- if (trimmedKey === 'PAYLOAD_SECRET' || trimmedKey === 'PAYLOAD_SECRET_KEY') {
41
- processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
42
- } else {
43
- processedLines.push(line);
6
+ * @param projectPath - Path to project directory
7
+ * @param key - Environment variable name to retrieve
8
+ * @returns The value if found, null otherwise
9
+ */ export async function getEnvVar(projectPath, key) {
10
+ const envPath = path.join(projectPath, '.env');
11
+ try {
12
+ const contents = await fs.readFile(envPath, 'utf-8');
13
+ const lines = contents.split('\n');
14
+ for (const line of lines){
15
+ // Skip empty lines and comments
16
+ if (!line.trim() || line.trim().startsWith('#')) {
17
+ continue;
18
+ }
19
+ // Skip lines without =
20
+ if (!line.includes('=')) {
21
+ continue;
22
+ }
23
+ const equalsIndex = line.indexOf('=');
24
+ const lineKey = line.substring(0, equalsIndex).trim();
25
+ if (lineKey === key) {
26
+ return line.substring(equalsIndex + 1);
27
+ }
44
28
  }
29
+ return null;
30
+ } catch {
31
+ // File doesn't exist or can't be read
32
+ return null;
45
33
  }
46
- // Add PAYLOAD_SECRET if not present
47
- if (!seenKeys.has('PAYLOAD_SECRET') && !seenKeys.has('PAYLOAD_SECRET_KEY')) {
48
- processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`);
49
- }
50
- return processedLines.join('\n');
51
34
  }
52
35
  /**
53
- * Manage environment files for a new project
54
- *
55
- * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET
36
+ * Add or update an environment variable in .env file
56
37
  *
57
38
  * @param projectPath - Path to project directory
58
- * @returns The generated payload secret
59
- */ export async function manageEnvFiles(projectPath) {
60
- const payloadSecret = generateSecret();
61
- const envExamplePath = path.join(projectPath, '.env.example');
39
+ * @param key - Environment variable name
40
+ * @param value - Environment variable value
41
+ */ export async function addOrUpdateEnvVar(projectPath, key, value) {
62
42
  const envPath = path.join(projectPath, '.env');
63
43
  try {
64
- // Check if .env.example exists
65
- let envExampleContents = '';
66
- try {
67
- envExampleContents = await fs.readFile(envExamplePath, 'utf-8');
68
- } catch {
69
- // No .env.example, create minimal .env
70
- envExampleContents = '';
71
- }
72
- // Check if .env already exists
44
+ let contents = '';
73
45
  let envExists = false;
46
+ // Try to read existing .env file
74
47
  try {
75
- await fs.access(envPath);
48
+ contents = await fs.readFile(envPath, 'utf-8');
76
49
  envExists = true;
77
50
  } catch {
78
- // .env doesn't exist
51
+ // .env doesn't exist, will create it
79
52
  }
80
- if (!envExists) {
81
- // Create .env from .env.example
82
- const sanitized = sanitizeEnv(envExampleContents, payloadSecret);
83
- await fs.writeFile(envPath, sanitized, 'utf-8');
84
- } else {
85
- // Update existing .env if it doesn't have PAYLOAD_SECRET
86
- const existingContents = await fs.readFile(envPath, 'utf-8');
87
- if (!existingContents.includes('PAYLOAD_SECRET=') && !existingContents.includes('PAYLOAD_SECRET_KEY=')) {
88
- const sanitized = sanitizeEnv(existingContents, payloadSecret);
89
- await fs.writeFile(envPath, sanitized, 'utf-8');
53
+ const lines = contents.split('\n');
54
+ const seenKeys = new Set();
55
+ const processedLines = [];
56
+ let keyUpdated = false;
57
+ for (const line of lines){
58
+ // Skip empty lines at start if file didn't exist
59
+ if (!envExists && !line.trim()) {
60
+ continue;
90
61
  }
62
+ // Preserve empty lines and comments
63
+ if (!line.trim() || line.trim().startsWith('#')) {
64
+ processedLines.push(line);
65
+ continue;
66
+ }
67
+ // Skip lines without =
68
+ if (!line.includes('=')) {
69
+ processedLines.push(line);
70
+ continue;
71
+ }
72
+ const [lineKey] = line.split('=');
73
+ const trimmedKey = lineKey.trim();
74
+ // Skip duplicate keys (keep first occurrence)
75
+ if (seenKeys.has(trimmedKey)) {
76
+ continue;
77
+ }
78
+ seenKeys.add(trimmedKey);
79
+ // Update or keep the line
80
+ if (trimmedKey === key) {
81
+ processedLines.push(`${key}=${value}`);
82
+ keyUpdated = true;
83
+ } else {
84
+ processedLines.push(line);
85
+ }
86
+ }
87
+ // Add key if not present
88
+ if (!keyUpdated) {
89
+ processedLines.push(`${key}=${value}`);
91
90
  }
92
- return payloadSecret;
91
+ await fs.writeFile(envPath, processedLines.join('\n'), 'utf-8');
93
92
  } catch (error) {
94
- throw new Error(`Failed to manage environment files: ${error instanceof Error ? error.message : 'Unknown error'}`);
93
+ throw new Error(`Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`);
95
94
  }
96
95
  }
97
96
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/env-management.ts"],"sourcesContent":["import { randomBytes } from 'crypto'\nimport fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Generate a cryptographically secure secret for PAYLOAD_SECRET\n *\n * @returns 24-character hexadecimal string\n */\nexport function generateSecret(): string {\n return randomBytes(32).toString('hex').slice(0, 24)\n}\n\n/**\n * Sanitize and process environment file contents\n *\n * @param contents - Raw .env file contents\n * @param payloadSecret - Secret to use for PAYLOAD_SECRET\n * @returns Processed .env contents\n */\nfunction sanitizeEnv(contents: string, payloadSecret: string): string {\n const lines = contents.split('\\n')\n const seenKeys = new Set<string>()\n const processedLines: string[] = []\n\n for (const line of lines) {\n // Skip empty lines and comments\n if (!line.trim() || line.trim().startsWith('#')) {\n processedLines.push(line)\n continue\n }\n\n // Skip lines without =\n if (!line.includes('=')) {\n processedLines.push(line)\n continue\n }\n\n const [key] = line.split('=')\n const trimmedKey = key.trim()\n\n // Skip duplicate keys\n if (seenKeys.has(trimmedKey)) {\n continue\n }\n seenKeys.add(trimmedKey)\n\n // Replace PAYLOAD_SECRET with actual value\n if (trimmedKey === 'PAYLOAD_SECRET' || trimmedKey === 'PAYLOAD_SECRET_KEY') {\n processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`)\n } else {\n processedLines.push(line)\n }\n }\n\n // Add PAYLOAD_SECRET if not present\n if (!seenKeys.has('PAYLOAD_SECRET') && !seenKeys.has('PAYLOAD_SECRET_KEY')) {\n processedLines.push(`PAYLOAD_SECRET=${payloadSecret}`)\n }\n\n return processedLines.join('\\n')\n}\n\n/**\n * Manage environment files for a new project\n *\n * Creates .env from .env.example (if exists) and populates PAYLOAD_SECRET\n *\n * @param projectPath - Path to project directory\n * @returns The generated payload secret\n */\nexport async function manageEnvFiles(projectPath: string): Promise<string> {\n const payloadSecret = generateSecret()\n const envExamplePath = path.join(projectPath, '.env.example')\n const envPath = path.join(projectPath, '.env')\n\n try {\n // Check if .env.example exists\n let envExampleContents = ''\n try {\n envExampleContents = await fs.readFile(envExamplePath, 'utf-8')\n } catch {\n // No .env.example, create minimal .env\n envExampleContents = ''\n }\n\n // Check if .env already exists\n let envExists = false\n try {\n await fs.access(envPath)\n envExists = true\n } catch {\n // .env doesn't exist\n }\n\n if (!envExists) {\n // Create .env from .env.example\n const sanitized = sanitizeEnv(envExampleContents, payloadSecret)\n await fs.writeFile(envPath, sanitized, 'utf-8')\n } else {\n // Update existing .env if it doesn't have PAYLOAD_SECRET\n const existingContents = await fs.readFile(envPath, 'utf-8')\n if (\n !existingContents.includes('PAYLOAD_SECRET=') &&\n !existingContents.includes('PAYLOAD_SECRET_KEY=')\n ) {\n const sanitized = sanitizeEnv(existingContents, payloadSecret)\n await fs.writeFile(envPath, sanitized, 'utf-8')\n }\n }\n\n return payloadSecret\n } catch (error) {\n throw new Error(\n `Failed to manage environment files: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n}\n"],"names":["randomBytes","fs","path","generateSecret","toString","slice","sanitizeEnv","contents","payloadSecret","lines","split","seenKeys","Set","processedLines","line","trim","startsWith","push","includes","key","trimmedKey","has","add","join","manageEnvFiles","projectPath","envExamplePath","envPath","envExampleContents","readFile","envExists","access","sanitized","writeFile","existingContents","error","Error","message"],"mappings":"AAAA,SAASA,WAAW,QAAQ,SAAQ;AACpC,OAAOC,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB;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B;QAC/B,IAAIG,qBAAqB;QACzB,IAAI;YACFA,qBAAqB,MAAM3B,GAAG4B,QAAQ,CAACH,gBAAgB;QACzD,EAAE,OAAM;YACN,uCAAuC;YACvCE,qBAAqB;QACvB;QAEA,+BAA+B;QAC/B,IAAIE,YAAY;QAChB,IAAI;YACF,MAAM7B,GAAG8B,MAAM,CAACJ;YAChBG,YAAY;QACd,EAAE,OAAM;QACN,qBAAqB;QACvB;QAEA,IAAI,CAACA,WAAW;YACd,gCAAgC;YAChC,MAAME,YAAY1B,YAAYsB,oBAAoBpB;YAClD,MAAMP,GAAGgC,SAAS,CAACN,SAASK,WAAW;QACzC,OAAO;YACL,yDAAyD;YACzD,MAAME,mBAAmB,MAAMjC,GAAG4B,QAAQ,CAACF,SAAS;YACpD,IACE,CAACO,iBAAiBhB,QAAQ,CAAC,sBAC3B,CAACgB,iBAAiBhB,QAAQ,CAAC,wBAC3B;gBACA,MAAMc,YAAY1B,YAAY4B,kBAAkB1B;gBAChD,MAAMP,GAAGgC,SAAS,CAACN,SAASK,WAAW;YACzC;QACF;QAEA,OAAOxB;IACT,EAAE,OAAO2B,OAAO;QACd,MAAM,IAAIC,MACR,CAAC,oCAAoC,EAAED,iBAAiBC,QAAQD,MAAME,OAAO,GAAG,iBAAiB;IAErG;AACF"}
1
+ {"version":3,"sources":["../../src/utils/env-management.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * Get an environment variable value from .env file\n *\n * @param projectPath - Path to project directory\n * @param key - Environment variable name to retrieve\n * @returns The value if found, null otherwise\n */\nexport async function getEnvVar(projectPath: string, key: string): Promise<null | string> {\n const envPath = path.join(projectPath, '.env')\n\n try {\n const contents = await fs.readFile(envPath, 'utf-8')\n const lines = contents.split('\\n')\n\n for (const line of lines) {\n // Skip empty lines and comments\n if (!line.trim() || line.trim().startsWith('#')) {\n continue\n }\n\n // Skip lines without =\n if (!line.includes('=')) {\n continue\n }\n\n const equalsIndex = line.indexOf('=')\n const lineKey = line.substring(0, equalsIndex).trim()\n\n if (lineKey === key) {\n return line.substring(equalsIndex + 1)\n }\n }\n\n return null\n } catch {\n // File doesn't exist or can't be read\n return null\n }\n}\n\n/**\n * Add or update an environment variable in .env file\n *\n * @param projectPath - Path to project directory\n * @param key - Environment variable name\n * @param value - Environment variable value\n */\nexport async function addOrUpdateEnvVar(\n projectPath: string,\n key: string,\n value: string,\n): Promise<void> {\n const envPath = path.join(projectPath, '.env')\n\n try {\n let contents = ''\n let envExists = false\n\n // Try to read existing .env file\n try {\n contents = await fs.readFile(envPath, 'utf-8')\n envExists = true\n } catch {\n // .env doesn't exist, will create it\n }\n\n const lines = contents.split('\\n')\n const seenKeys = new Set<string>()\n const processedLines: string[] = []\n let keyUpdated = false\n\n for (const line of lines) {\n // Skip empty lines at start if file didn't exist\n if (!envExists && !line.trim()) {\n continue\n }\n\n // Preserve empty lines and comments\n if (!line.trim() || line.trim().startsWith('#')) {\n processedLines.push(line)\n continue\n }\n\n // Skip lines without =\n if (!line.includes('=')) {\n processedLines.push(line)\n continue\n }\n\n const [lineKey] = line.split('=')\n const trimmedKey = lineKey.trim()\n\n // Skip duplicate keys (keep first occurrence)\n if (seenKeys.has(trimmedKey)) {\n continue\n }\n seenKeys.add(trimmedKey)\n\n // Update or keep the line\n if (trimmedKey === key) {\n processedLines.push(`${key}=${value}`)\n keyUpdated = true\n } else {\n processedLines.push(line)\n }\n }\n\n // Add key if not present\n if (!keyUpdated) {\n processedLines.push(`${key}=${value}`)\n }\n\n await fs.writeFile(envPath, processedLines.join('\\n'), 'utf-8')\n } catch (error) {\n throw new Error(\n `Failed to update .env file: ${error instanceof Error ? error.message : 'Unknown error'}`,\n )\n }\n}\n"],"names":["fs","path","getEnvVar","projectPath","key","envPath","join","contents","readFile","lines","split","line","trim","startsWith","includes","equalsIndex","indexOf","lineKey","substring","addOrUpdateEnvVar","value","envExists","seenKeys","Set","processedLines","keyUpdated","push","trimmedKey","has","add","writeFile","error","Error","message"],"mappings":"A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I;gBAC9B;YACF;YAEA,oCAAoC;YACpC,IAAI,CAACD,KAAKC,IAAI,MAAMD,KAAKC,IAAI,GAAGC,UAAU,CAAC,MAAM;gBAC/CW,eAAeE,IAAI,CAACf;gBACpB;YACF;YAEA,uBAAuB;YACvB,IAAI,CAACA,KAAKG,QAAQ,CAAC,MAAM;gBACvBU,eAAeE,IAAI,CAACf;gBACpB;YACF;YAEA,MAAM,CAACM,QAAQ,GAAGN,KAAKD,KAAK,CAAC;YAC7B,MAAMiB,aAAaV,QAAQL,IAAI;YAE/B,8CAA8C;YAC9C,IAAIU,SAASM,GAAG,CAACD,aAAa;gBAC5B;YACF;YACAL,SAASO,GAAG,CAACF;YAEb,0BAA0B;YAC1B,IAAIA,eAAevB,KAAK;gBACtBoB,eAAeE,IAAI,CAAC,GAAGtB,IAAI,CAAC,EAAEgB,OAAO;gBACrCK,aAAa;YACf,OAAO;gBACLD,eAAeE,IAAI,CAACf;YACtB;QACF;QAEA,yBAAyB;QACzB,IAAI,CAACc,YAAY;YACfD,eAAeE,IAAI,CAAC,GAAGtB,IAAI,CAAC,EAAEgB,OAAO;QACvC;QAEA,MAAMpB,GAAG8B,SAAS,CAACzB,SAASmB,eAAelB,IAAI,CAAC,OAAO;IACzD,EAAE,OAAOyB,OAAO;QACd,MAAM,IAAIC,MACR,CAAC,4BAA4B,EAAED,iBAAiBC,QAAQD,MAAME,OAAO,GAAG,iBAAiB;IAE7F;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/utils/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,YAAY,CAAC,CAmCvB"}
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/utils/formatter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAAC,YAAY,CAAC,CAiCvB"}
@@ -6,13 +6,7 @@ import path from 'path';
6
6
  */ export async function formatFile(filePath, packageManager) {
7
7
  return new Promise((resolve)=>{
8
8
  try {
9
- const args = [
10
- 'exec',
11
- 'prettier',
12
- '--write',
13
- filePath
14
- ];
15
- const child = spawn(packageManager, args, {
9
+ const child = spawn(`${packageManager} exec prettier --write "${filePath}"`, {
16
10
  cwd: path.dirname(filePath),
17
11
  shell: true,
18
12
  stdio: 'pipe'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/formatter.ts"],"sourcesContent":["import { spawn } from 'child_process'\nimport path from 'path'\n\nimport type { PackageManager } from './package-manager.js'\n\nexport type FormatResult = {\n success: boolean\n warning?: string\n}\n\n/**\n * Format file with Prettier\n * Returns warning if formatting fails but does not throw\n */\nexport async function formatFile(\n filePath: string,\n packageManager: PackageManager,\n): Promise<FormatResult> {\n return new Promise((resolve) => {\n try {\n const args = ['exec', 'prettier', '--write', filePath]\n\n const child = spawn(packageManager, args, {\n cwd: path.dirname(filePath),\n shell: true,\n stdio: 'pipe',\n })\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve({ success: true })\n } else {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n }\n })\n\n child.on('error', () => {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n })\n } catch {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n }\n })\n}\n"],"names":["spawn","path","formatFile","filePath","packageManager","Promise","resolve","args","child","cwd","dirname","shell","stdio","on","code","success","warning"],"mappings":"AAAA,SAASA,KAAK,QAAQ,gBAAe;AACrC,OAAOC,UAAU,OAAM;AASvB;;;CAGC,GACD,OAAO,eAAeC,WACpBC,QAAgB,EAChBC,cAA8B;IAE9B,OAAO,IAAIC,QAAQ,CAACC;QAClB,IAAI;YACF,MAAMC,OAAO;gBAAC;gBAAQ;gBAAY;gBAAWJ;aAAS;YAEtD,MAAMK,QAAQR,MAAMI,gBAAgBG,MAAM;gBACxCE,KAAKR,KAAKS,OAAO,CAACP;gBAClBQ,OAAO;gBACPC,OAAO;YACT;YAEAJ,MAAMK,EAAE,CAAC,SAAS,CAACC;gBACjB,IAAIA,SAAS,GAAG;oBACdR,QAAQ;wBAAES,SAAS;oBAAK;gBAC1B,OAAO;oBACLT,QAAQ;wBACNS,SAAS;wBACTC,SAAS;oBACX;gBACF;YACF;YAEAR,MAAMK,EAAE,CAAC,SAAS;gBAChBP,QAAQ;oBACNS,SAAS;oBACTC,SAAS;gBACX;YACF;QACF,EAAE,OAAM;YACNV,QAAQ;gBACNS,SAAS;gBACTC,SAAS;YACX;QACF;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/utils/formatter.ts"],"sourcesContent":["import { spawn } from 'child_process'\nimport path from 'path'\n\nimport type { PackageManager } from './package-manager.js'\n\nexport type FormatResult = {\n success: boolean\n warning?: string\n}\n\n/**\n * Format file with Prettier\n * Returns warning if formatting fails but does not throw\n */\nexport async function formatFile(\n filePath: string,\n packageManager: PackageManager,\n): Promise<FormatResult> {\n return new Promise((resolve) => {\n try {\n const child = spawn(`${packageManager} exec prettier --write \"${filePath}\"`, {\n cwd: path.dirname(filePath),\n shell: true,\n stdio: 'pipe',\n })\n\n child.on('close', (code) => {\n if (code === 0) {\n resolve({ success: true })\n } else {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n }\n })\n\n child.on('error', () => {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n })\n } catch {\n resolve({\n success: false,\n warning: 'Could not format file with Prettier',\n })\n }\n })\n}\n"],"names":["spawn","path","formatFile","filePath","packageManager","Promise","resolve","child","cwd","dirname","shell","stdio","on","code","success","warning"],"mappings":"AAAA,SAASA,KAAK,QAAQ,gBAAe;AACrC,OAAOC,UAAU,OAAM;AASvB;;;CAGC,GACD,OAAO,eAAeC,WACpBC,QAAgB,EAChBC,cAA8B;IAE9B,OAAO,IAAIC,QAAQ,CAACC;QAClB,IAAI;YACF,MAAMC,QAAQP,MAAM,GAAGI,eAAe,wBAAwB,EAAED,SAAS,CAAC,CAAC,EAAE;gBAC3EK,KAAKP,KAAKQ,OAAO,CAACN;gBAClBO,OAAO;gBACPC,OAAO;YACT;YAEAJ,MAAMK,EAAE,CAAC,SAAS,CAACC;gBACjB,IAAIA,SAAS,GAAG;oBACdP,QAAQ;wBAAEQ,SAAS;oBAAK;gBAC1B,OAAO;oBACLR,QAAQ;wBACNQ,SAAS;wBACTC,SAAS;oBACX;gBACF;YACF;YAEAR,MAAMK,EAAE,CAAC,SAAS;gBAChBN,QAAQ;oBACNQ,SAAS;oBACTC,SAAS;gBACX;YACF;QACF,EAAE,OAAM;YACNT,QAAQ;gBACNQ,SAAS;gBACTC,SAAS;YACX;QACF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"lambda-config.d.ts","sourceRoot":"","sources":["../../src/utils/lambda-config.ts"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCjF"}
1
+ {"version":3,"file":"lambda-config.d.ts","sourceRoot":"","sources":["../../src/utils/lambda-config.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCjF"}
@@ -11,6 +11,7 @@ const BUILD_FOR_LAMBDA_SH_CONTENT = `#!/bin/bash
11
11
 
12
12
  cp -r .next/static .next/standalone/.next/static
13
13
  cp run.sh .next/standalone/run.sh
14
+ [ -d public ] && cp -r public .next/standalone/public
14
15
  cd .next/standalone
15
16
  zip -r --symlinks lambda.zip .
16
17
  mv lambda.zip ../..