@payloadcms/figma 0.0.1-alpha.5 → 0.0.1-alpha.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/control-plane.d.ts +31 -1
- package/dist/api/control-plane.js +137 -67
- package/dist/api/figma-api.d.ts +20 -0
- package/dist/api/figma-api.js +77 -21
- package/dist/auth/callback-server.js +2 -1
- package/dist/auth/crypto-utils.js +5 -5
- package/dist/auth/jwt-validator.d.ts +2 -1
- package/dist/auth/jwt-validator.js +2 -2
- package/dist/auth/oauth-flow.d.ts +1 -1
- package/dist/auth/oauth-flow.js +15 -11
- package/dist/auth/project-token.js +11 -6
- package/dist/auth/refresh.d.ts +2 -1
- package/dist/auth/refresh.js +25 -12
- package/dist/auth/token-store.d.ts +40 -1
- package/dist/auth/token-store.js +65 -5
- package/dist/auth/types.d.ts +17 -4
- package/dist/cli.js +54 -6
- package/dist/commands/build-lambda-zip.d.ts +5 -0
- package/dist/commands/build-lambda-zip.js +19 -0
- package/dist/commands/debug.d.ts +8 -0
- package/dist/commands/debug.js +161 -0
- package/dist/commands/deploy.d.ts +6 -0
- package/dist/commands/deploy.js +94 -126
- package/dist/commands/env.d.ts +13 -0
- package/dist/commands/env.js +88 -0
- package/dist/commands/init.d.ts +3 -5
- package/dist/commands/init.js +118 -94
- package/dist/commands/list-tokens.d.ts +3 -3
- package/dist/commands/list-tokens.js +22 -7
- package/dist/commands/login.d.ts +8 -1
- package/dist/commands/login.js +30 -12
- package/dist/commands/logout.d.ts +5 -4
- package/dist/commands/logout.js +56 -13
- package/dist/config/oauth.d.ts +4 -14
- package/dist/config/oauth.js +18 -40
- package/dist/constants.d.ts +36 -19
- package/dist/constants.js +58 -20
- package/dist/db-content-api/README.md +98 -0
- package/dist/db-content-api/generated/content-api-types.d.ts +3746 -0
- package/dist/db-content-api/generated/content-api-types.js +7 -0
- package/dist/db-content-api/index.d.ts +20 -0
- package/dist/db-content-api/index.js +702 -0
- package/dist/db-content-api/temp-utilities/slug.d.ts +2 -0
- package/dist/db-content-api/temp-utilities/slug.js +3 -0
- package/dist/db-content-api/temp-utilities/sorting.d.ts +3 -0
- package/dist/db-content-api/temp-utilities/sorting.js +32 -0
- package/dist/db-content-api/temp-utilities/types.d.ts +22 -0
- package/dist/db-content-api/temp-utilities/types.js +15 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.d.ts +34 -0
- package/dist/db-content-api/temp-utilities/unwrapDocument.js +53 -0
- package/dist/db-content-api/utilities/auth.d.ts +30 -0
- package/dist/db-content-api/utilities/auth.js +81 -0
- package/dist/db-content-api/utilities/data/applyDefaults.d.ts +7 -0
- package/dist/db-content-api/utilities/data/applyDefaults.js +59 -0
- package/dist/db-content-api/utilities/data/castFieldValue.d.ts +11 -0
- package/dist/db-content-api/utilities/data/castFieldValue.js +69 -0
- package/dist/db-content-api/utilities/data/index.d.ts +42 -0
- package/dist/db-content-api/utilities/data/index.js +211 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +12 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +54 -0
- package/dist/db-content-api/utilities/data/stripFields.d.ts +48 -0
- package/dist/db-content-api/utilities/data/stripFields.js +195 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.d.ts +23 -0
- package/dist/db-content-api/utilities/data/transformPublishedLocale.js +42 -0
- package/dist/db-content-api/utilities/joins.d.ts +55 -0
- package/dist/db-content-api/utilities/joins.js +136 -0
- package/dist/db-content-api/utilities/locale/index.d.ts +10 -0
- package/dist/db-content-api/utilities/locale/index.js +21 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.d.ts +11 -0
- package/dist/db-content-api/utilities/meta/buildLocalizedPaths.js +66 -0
- package/dist/db-content-api/utilities/meta/buildMeta.d.ts +37 -0
- package/dist/db-content-api/utilities/meta/buildMeta.js +33 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.d.ts +13 -0
- package/dist/db-content-api/utilities/meta/buildPathTypes.js +181 -0
- package/dist/db-content-api/utilities/where.d.ts +20 -0
- package/dist/db-content-api/utilities/where.js +127 -0
- package/dist/endpoints/health.d.ts +3 -0
- package/dist/endpoints/health.js +11 -0
- package/dist/endpoints/schema.d.ts +3 -0
- package/dist/endpoints/schema.js +29 -0
- package/dist/exports/client.d.ts +3 -0
- package/dist/exports/client.js +3 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/oauth/components/FigmaAvatar/index.d.ts +4 -0
- package/dist/oauth/components/FigmaAvatar/index.js +27 -0
- package/dist/oauth/components/FigmaAvatar/index.scss +12 -0
- package/dist/oauth/components/FigmaAvatarCell/index.d.ts +5 -0
- package/dist/oauth/components/FigmaAvatarCell/index.js +25 -0
- package/dist/oauth/components/FigmaAvatarCell/index.scss +5 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.d.ts +9 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.js +37 -0
- package/dist/oauth/components/FigmaAvatarPlaceholder/index.scss +28 -0
- package/dist/oauth/components/LoginButton/index.js +50 -6
- package/dist/oauth/components/LoginButton/index.scss +50 -3
- package/dist/oauth/components/LogoutButton/index.js +5 -4
- package/dist/oauth/defaults.js +67 -10
- package/dist/oauth/endpoints/getLoginEndpoint.js +69 -24
- package/dist/oauth/endpoints/getLogoutEndpoint.js +7 -4
- package/dist/oauth/index.js +40 -5
- package/dist/oauth/strategy/index.d.ts +0 -2
- package/dist/oauth/strategy/index.js +40 -17
- package/dist/oauth/types.d.ts +6 -6
- package/dist/oauth/utilities/isDuplicateKeyError.d.ts +7 -0
- package/dist/oauth/utilities/isDuplicateKeyError.js +14 -0
- package/dist/oauth/utilities/refreshTokens.js +3 -3
- package/dist/plugin/build-config.d.ts +21 -14
- package/dist/plugin/build-config.js +208 -17
- package/dist/storage-content-api/api-types.d.ts +168 -0
- package/dist/storage-content-api/api-types.js +6 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.d.ts +9 -0
- package/dist/storage-content-api/client-uploads/ClientUploadHandler.js +42 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.d.ts +13 -0
- package/dist/storage-content-api/client-uploads/generateSignedURL.js +39 -0
- package/dist/storage-content-api/client.d.ts +6 -0
- package/dist/storage-content-api/client.js +36 -0
- package/dist/storage-content-api/generateURL.d.ts +7 -0
- package/dist/storage-content-api/generateURL.js +8 -0
- package/dist/storage-content-api/handleDelete.d.ts +8 -0
- package/dist/storage-content-api/handleDelete.js +17 -0
- package/dist/storage-content-api/handleUpload.d.ts +11 -0
- package/dist/storage-content-api/handleUpload.js +144 -0
- package/dist/storage-content-api/index.d.ts +5 -0
- package/dist/storage-content-api/index.js +31 -0
- package/dist/storage-content-api/staticHandler.d.ts +10 -0
- package/dist/storage-content-api/staticHandler.js +56 -0
- package/dist/storage-content-api/types.d.ts +10 -0
- package/dist/storage-content-api/types.js +3 -0
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +12 -0
- package/dist/storage-content-api/utilities/getSafeFilename.js +61 -0
- package/dist/storage-content-api/utilities/index.d.ts +2 -0
- package/dist/storage-content-api/utilities/index.js +3 -0
- package/dist/templates/.env.example +5 -0
- package/dist/templates/README.md +19 -0
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.js +0 -2
- package/dist/types.d.ts +3 -1
- package/dist/utils/asset-collection.d.ts +3 -6
- package/dist/utils/asset-collection.js +10 -34
- package/dist/utils/build-lambda-zip.d.ts +14 -0
- package/dist/utils/build-lambda-zip.js +81 -0
- package/dist/utils/cache-bootstrap.d.ts +8 -0
- package/dist/utils/cache-bootstrap.js +18 -0
- package/dist/utils/config.js +1 -1
- package/dist/utils/env-management.d.ts +16 -7
- package/dist/utils/env-management.js +85 -64
- package/dist/utils/format-env-suffix.d.ts +12 -0
- package/dist/utils/format-env-suffix.js +13 -0
- package/dist/utils/formatter.js +3 -5
- package/dist/utils/lambda-config.d.ts +3 -1
- package/dist/utils/lambda-config.js +38 -32
- package/dist/utils/messages.d.ts +1 -1
- package/dist/utils/messages.js +22 -8
- package/dist/utils/package-manager.d.ts +24 -0
- package/dist/utils/package-manager.js +53 -0
- package/dist/utils/payload-config-ast.d.ts +22 -3
- package/dist/utils/payload-config-ast.js +96 -31
- package/dist/utils/payload-config-finder.d.ts +2 -2
- package/dist/utils/payload-config-finder.js +48 -9
- package/dist/utils/payload-config-modifier.d.ts +1 -1
- package/dist/utils/payload-config-modifier.js +58 -9
- package/dist/utils/payload-package-check.d.ts +12 -1
- package/dist/utils/payload-package-check.js +63 -5
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +15 -7
- package/dist/utils/resolve-environment.d.ts +14 -0
- package/dist/utils/resolve-environment.js +28 -0
- package/dist/utils/s3-upload.d.ts +0 -1
- package/dist/utils/s3-upload.js +10 -3
- package/dist/utils/token-display.js +11 -5
- package/dist/utils/typescript-validator.js +4 -6
- package/dist/utils/version-check.d.ts +3 -0
- package/dist/utils/version-check.js +38 -0
- package/package.json +29 -10
- package/dist/api/control-plane.d.ts.map +0 -1
- package/dist/api/control-plane.js.map +0 -1
- package/dist/api/figma-api.d.ts.map +0 -1
- package/dist/api/figma-api.js.map +0 -1
- package/dist/auth/browser.d.ts.map +0 -1
- package/dist/auth/browser.js.map +0 -1
- package/dist/auth/callback-server.d.ts.map +0 -1
- package/dist/auth/callback-server.js.map +0 -1
- package/dist/auth/crypto-utils.d.ts.map +0 -1
- package/dist/auth/crypto-utils.js.map +0 -1
- package/dist/auth/jwt-validator.d.ts.map +0 -1
- package/dist/auth/jwt-validator.js.map +0 -1
- package/dist/auth/oauth-flow.d.ts.map +0 -1
- package/dist/auth/oauth-flow.js.map +0 -1
- package/dist/auth/pkce.d.ts.map +0 -1
- package/dist/auth/pkce.js.map +0 -1
- package/dist/auth/project-token.d.ts.map +0 -1
- package/dist/auth/project-token.js.map +0 -1
- package/dist/auth/refresh.d.ts.map +0 -1
- package/dist/auth/refresh.js.map +0 -1
- package/dist/auth/token-store.d.ts.map +0 -1
- package/dist/auth/token-store.js.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/auth/types.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/deploy.d.ts.map +0 -1
- package/dist/commands/deploy.js.map +0 -1
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list-tokens.d.ts.map +0 -1
- package/dist/commands/list-tokens.js.map +0 -1
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js.map +0 -1
- package/dist/config/oauth.d.ts.map +0 -1
- package/dist/config/oauth.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/exports/client.d.ts.map +0 -1
- package/dist/exports/client.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/oauth/components/LoginButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LoginButton/index.js.map +0 -1
- package/dist/oauth/components/LogoutButton/index.d.ts.map +0 -1
- package/dist/oauth/components/LogoutButton/index.js.map +0 -1
- package/dist/oauth/defaults.d.ts.map +0 -1
- package/dist/oauth/defaults.js.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getLogoutEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getMetaEndpoint.js.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.d.ts.map +0 -1
- package/dist/oauth/endpoints/getRedirectToLoginEndpoint.js.map +0 -1
- package/dist/oauth/exports/client.d.ts.map +0 -1
- package/dist/oauth/exports/client.js.map +0 -1
- package/dist/oauth/hooks/afterLogout.d.ts.map +0 -1
- package/dist/oauth/hooks/afterLogout.js.map +0 -1
- package/dist/oauth/hooks/me.d.ts.map +0 -1
- package/dist/oauth/hooks/me.js.map +0 -1
- package/dist/oauth/hooks/refresh.d.ts.map +0 -1
- package/dist/oauth/hooks/refresh.js.map +0 -1
- package/dist/oauth/index.d.ts.map +0 -1
- package/dist/oauth/index.js.map +0 -1
- package/dist/oauth/strategy/index.d.ts.map +0 -1
- package/dist/oauth/strategy/index.js.map +0 -1
- package/dist/oauth/types.d.ts.map +0 -1
- package/dist/oauth/types.js.map +0 -1
- package/dist/oauth/utilities/clearCookie.d.ts.map +0 -1
- package/dist/oauth/utilities/clearCookie.js.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.d.ts.map +0 -1
- package/dist/oauth/utilities/createCookieOptions.js.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.d.ts.map +0 -1
- package/dist/oauth/utilities/createDebugLogger.js.map +0 -1
- package/dist/oauth/utilities/extractOrigin.d.ts.map +0 -1
- package/dist/oauth/utilities/extractOrigin.js.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminCollectionSlug.js.map +0 -1
- package/dist/oauth/utilities/getAdminPath.d.ts +0 -8
- package/dist/oauth/utilities/getAdminPath.d.ts.map +0 -1
- package/dist/oauth/utilities/getAdminPath.js +0 -9
- package/dist/oauth/utilities/getAdminPath.js.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts.map +0 -1
- package/dist/oauth/utilities/getAuthorizeURL.js.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.d.ts.map +0 -1
- package/dist/oauth/utilities/getCookieExpiration.js.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getSecondsFromTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getTokenExp.d.ts.map +0 -1
- package/dist/oauth/utilities/getTokenExp.js.map +0 -1
- package/dist/oauth/utilities/getUsernameField.d.ts.map +0 -1
- package/dist/oauth/utilities/getUsernameField.js.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.d.ts.map +0 -1
- package/dist/oauth/utilities/hasUserTokenPropsChanged.js.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.d.ts.map +0 -1
- package/dist/oauth/utilities/mergeHeaders.js.map +0 -1
- package/dist/oauth/utilities/refreshTokens.d.ts.map +0 -1
- package/dist/oauth/utilities/refreshTokens.js.map +0 -1
- package/dist/plugin/adapter.d.ts.map +0 -1
- package/dist/plugin/adapter.js.map +0 -1
- package/dist/plugin/build-config.d.ts.map +0 -1
- package/dist/plugin/build-config.js.map +0 -1
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils/asset-collection.d.ts.map +0 -1
- package/dist/utils/asset-collection.js.map +0 -1
- package/dist/utils/build-detection.d.ts.map +0 -1
- package/dist/utils/build-detection.js.map +0 -1
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/download-template.d.ts.map +0 -1
- package/dist/utils/download-template.js.map +0 -1
- package/dist/utils/env-management.d.ts.map +0 -1
- package/dist/utils/env-management.js.map +0 -1
- package/dist/utils/format.d.ts.map +0 -1
- package/dist/utils/format.js.map +0 -1
- package/dist/utils/formatter.d.ts.map +0 -1
- package/dist/utils/formatter.js.map +0 -1
- package/dist/utils/git.d.ts.map +0 -1
- package/dist/utils/git.js.map +0 -1
- package/dist/utils/is-debug.d.ts.map +0 -1
- package/dist/utils/is-debug.js.map +0 -1
- package/dist/utils/lambda-config.d.ts.map +0 -1
- package/dist/utils/lambda-config.js.map +0 -1
- package/dist/utils/log.d.ts.map +0 -1
- package/dist/utils/log.js.map +0 -1
- package/dist/utils/messages.d.ts.map +0 -1
- package/dist/utils/messages.js.map +0 -1
- package/dist/utils/package-manager.d.ts.map +0 -1
- package/dist/utils/package-manager.js.map +0 -1
- package/dist/utils/payload-config-ast.d.ts.map +0 -1
- package/dist/utils/payload-config-ast.js.map +0 -1
- package/dist/utils/payload-config-finder.d.ts.map +0 -1
- package/dist/utils/payload-config-finder.js.map +0 -1
- package/dist/utils/payload-config-modifier.d.ts.map +0 -1
- package/dist/utils/payload-config-modifier.js.map +0 -1
- package/dist/utils/payload-package-check.d.ts.map +0 -1
- package/dist/utils/payload-package-check.js.map +0 -1
- package/dist/utils/project.d.ts.map +0 -1
- package/dist/utils/project.js.map +0 -1
- package/dist/utils/s3-upload.d.ts.map +0 -1
- package/dist/utils/s3-upload.js.map +0 -1
- package/dist/utils/token-display.d.ts.map +0 -1
- package/dist/utils/token-display.js.map +0 -1
- package/dist/utils/typescript-validator.d.ts.map +0 -1
- package/dist/utils/typescript-validator.js.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
const PART_SIZE = 64 * 1024 * 1024 // 64MB per part
|
|
4
|
+
;
|
|
5
|
+
const MAX_FILE_SIZE_BEFORE_MULTIPART = 100 * 1024 * 1024 // 100MB
|
|
6
|
+
;
|
|
7
|
+
export const getHandleUpload = ({ client, collection, prefix = '' })=>{
|
|
8
|
+
return async ({ clientUploadContext, data, file })=>{
|
|
9
|
+
// Skip if client already uploaded THIS SPECIFIC file
|
|
10
|
+
// clientUploadContext.filename contains the original filename that was client-uploaded
|
|
11
|
+
// Resized versions (different filename) should still be uploaded
|
|
12
|
+
const clientUploadedFilename = clientUploadContext && typeof clientUploadContext === 'object' && 'filename' in clientUploadContext ? clientUploadContext.filename : undefined;
|
|
13
|
+
const isOriginalClientUploaded = clientUploadContext && typeof clientUploadContext === 'object' && 'clientUploaded' in clientUploadContext && clientUploadContext.clientUploaded && file.filename === clientUploadedFilename;
|
|
14
|
+
if (isOriginalClientUploaded) {
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
const collectionId = collection.slug;
|
|
18
|
+
const fileKey = path.posix.join(data.prefix || prefix, file.filename);
|
|
19
|
+
const fileData = file.tempFilePath ? fs.readFileSync(file.tempFilePath) : file.buffer;
|
|
20
|
+
const fileSize = file.filesize || fileData.length;
|
|
21
|
+
if (fileSize > MAX_FILE_SIZE_BEFORE_MULTIPART) {
|
|
22
|
+
await uploadMultipart({
|
|
23
|
+
client,
|
|
24
|
+
collectionId,
|
|
25
|
+
fileData,
|
|
26
|
+
fileKey,
|
|
27
|
+
mimeType: file.mimeType
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
await uploadSingleFile({
|
|
31
|
+
client,
|
|
32
|
+
collectionId,
|
|
33
|
+
fileData,
|
|
34
|
+
fileKey,
|
|
35
|
+
mimeType: file.mimeType
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
async function uploadSingleFile({ client, collectionId, fileData, fileKey, mimeType }) {
|
|
42
|
+
const { data, error } = await client.POST('/api/v0/uploads/sign', {
|
|
43
|
+
body: {
|
|
44
|
+
collectionId,
|
|
45
|
+
contentType: mimeType,
|
|
46
|
+
expiresIn: 3600,
|
|
47
|
+
filename: fileKey
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
if (error || !data) {
|
|
51
|
+
throw new Error(`Failed to get presigned upload URL: ${JSON.stringify(error)}`);
|
|
52
|
+
}
|
|
53
|
+
const uploadResponse = await fetch(data.url, {
|
|
54
|
+
body: fileData,
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': mimeType
|
|
57
|
+
},
|
|
58
|
+
method: 'PUT'
|
|
59
|
+
});
|
|
60
|
+
if (!uploadResponse.ok) {
|
|
61
|
+
throw new Error(`Failed to upload to S3: ${uploadResponse.status} ${uploadResponse.statusText}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function uploadMultipart({ client, collectionId, fileData, fileKey, mimeType }) {
|
|
65
|
+
const { data: initiateData, error: initiateError } = await client.POST('/api/v0/uploads/multipart/initiate', {
|
|
66
|
+
body: {
|
|
67
|
+
collectionId,
|
|
68
|
+
contentType: mimeType,
|
|
69
|
+
filename: fileKey
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (initiateError || !initiateData) {
|
|
73
|
+
throw new Error(`Failed to initiate multipart upload: ${JSON.stringify(initiateError)}`);
|
|
74
|
+
}
|
|
75
|
+
const { uploadId } = initiateData;
|
|
76
|
+
try {
|
|
77
|
+
const numParts = Math.ceil(fileData.length / PART_SIZE);
|
|
78
|
+
const partNumbers = Array.from({
|
|
79
|
+
length: numParts
|
|
80
|
+
}, (_, i)=>i + 1);
|
|
81
|
+
const { data: partsData, error: partsError } = await client.POST('/api/v0/uploads/multipart/parts', {
|
|
82
|
+
body: {
|
|
83
|
+
collectionId,
|
|
84
|
+
expiresIn: 3600,
|
|
85
|
+
filename: fileKey,
|
|
86
|
+
partNumbers,
|
|
87
|
+
uploadId
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (partsError || !partsData) {
|
|
91
|
+
throw new Error(`Failed to get part URLs: ${JSON.stringify(partsError)}`);
|
|
92
|
+
}
|
|
93
|
+
const { parts } = partsData;
|
|
94
|
+
if (!parts || !Array.isArray(parts)) {
|
|
95
|
+
throw new Error('Invalid response from part URLs endpoint: parts is not an array');
|
|
96
|
+
}
|
|
97
|
+
const uploadedParts = await Promise.all(parts.map(async ({ partNumber, url })=>{
|
|
98
|
+
const start = (partNumber - 1) * PART_SIZE;
|
|
99
|
+
const end = Math.min(start + PART_SIZE, fileData.length);
|
|
100
|
+
const partData = fileData.slice(start, end);
|
|
101
|
+
const uploadResponse = await fetch(url, {
|
|
102
|
+
body: partData,
|
|
103
|
+
headers: {
|
|
104
|
+
'Content-Type': mimeType
|
|
105
|
+
},
|
|
106
|
+
method: 'PUT'
|
|
107
|
+
});
|
|
108
|
+
const etag = uploadResponse.headers.get('ETag');
|
|
109
|
+
if (!etag) {
|
|
110
|
+
throw new Error(`No ETag returned for part ${partNumber}`);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
ETag: etag,
|
|
114
|
+
PartNumber: partNumber
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
const { error: completeError } = await client.POST('/api/v0/uploads/multipart/complete', {
|
|
118
|
+
body: {
|
|
119
|
+
collectionId,
|
|
120
|
+
filename: fileKey,
|
|
121
|
+
parts: uploadedParts,
|
|
122
|
+
uploadId
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
if (completeError) {
|
|
126
|
+
throw new Error(`Failed to complete multipart upload: ${JSON.stringify(completeError)}`);
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
try {
|
|
130
|
+
await client.POST('/api/v0/uploads/multipart/abort', {
|
|
131
|
+
body: {
|
|
132
|
+
collectionId,
|
|
133
|
+
filename: fileKey,
|
|
134
|
+
uploadId
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
} catch {
|
|
138
|
+
// Ignore abort errors
|
|
139
|
+
}
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=handleUpload.js.map
|
|
@@ -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,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,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,56 @@
|
|
|
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
|
+
collectionId: collection.slug,
|
|
16
|
+
expiresIn: 7200,
|
|
17
|
+
filename: key
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (error || !data) {
|
|
21
|
+
req.payload.logger.error(`Failed to get signed download URL: ${JSON.stringify(error)}`);
|
|
22
|
+
return new Response('Internal Server Error', {
|
|
23
|
+
status: 500
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Fetch file bytes from S3 (required for Payload's image processing)
|
|
27
|
+
const fileResponse = await fetch(data.url);
|
|
28
|
+
if (!fileResponse.ok) {
|
|
29
|
+
req.payload.logger.error(`S3 fetch failed: ${fileResponse.status} ${fileResponse.statusText}`);
|
|
30
|
+
return new Response('Failed to fetch file from storage', {
|
|
31
|
+
status: 502
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const contentType = fileResponse.headers.get('content-type') || 'application/octet-stream';
|
|
35
|
+
const contentLength = fileResponse.headers.get('content-length');
|
|
36
|
+
return new Response(fileResponse.body, {
|
|
37
|
+
headers: {
|
|
38
|
+
'Content-Type': contentType,
|
|
39
|
+
...contentLength && {
|
|
40
|
+
'Content-Length': contentLength
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
} catch (err) {
|
|
45
|
+
req.payload.logger.error({
|
|
46
|
+
err,
|
|
47
|
+
msg: 'Error in staticHandler'
|
|
48
|
+
});
|
|
49
|
+
return new Response('Internal Server Error', {
|
|
50
|
+
status: 500
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=staticHandler.js.map
|
|
@@ -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,12 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Get a safe filename that doesn't collide with existing documents
|
|
4
|
+
* Similar to Payload's getSafeFileName
|
|
5
|
+
*/
|
|
6
|
+
export declare function getSafeFilename({ collectionSlug, desiredFilename, prefix, req, }: {
|
|
7
|
+
collectionSlug: string;
|
|
8
|
+
desiredFilename: string;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
req: PayloadRequest;
|
|
11
|
+
}): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=getSafeFilename.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import sanitize from 'sanitize-filename';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a document with the given filename already exists in the database
|
|
4
|
+
* Matches Payload's docWithFilenameExists
|
|
5
|
+
*/ async function docWithFilenameExists({ collectionSlug, filename, prefix, req }) {
|
|
6
|
+
const where = {
|
|
7
|
+
filename: {
|
|
8
|
+
equals: filename
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
if (prefix) {
|
|
12
|
+
where.prefix = {
|
|
13
|
+
equals: prefix
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const doc = await req.payload.db.findOne({
|
|
17
|
+
collection: collectionSlug,
|
|
18
|
+
req,
|
|
19
|
+
where
|
|
20
|
+
});
|
|
21
|
+
return !!doc;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Increment filename by adding -1, -2, etc. suffix
|
|
25
|
+
* photo.jpg → photo-1.jpg
|
|
26
|
+
* photo-1.jpg → photo-2.jpg
|
|
27
|
+
* Matches Payload's incrementName
|
|
28
|
+
*/ function incrementFilename(name) {
|
|
29
|
+
const extension = name.split('.').pop();
|
|
30
|
+
const baseFilename = sanitize(name.substring(0, name.lastIndexOf('.')) || name);
|
|
31
|
+
let incrementedName = baseFilename;
|
|
32
|
+
const regex = /(.*)-(\d+)$/;
|
|
33
|
+
const found = baseFilename.match(regex);
|
|
34
|
+
if (found === null) {
|
|
35
|
+
incrementedName += '-1';
|
|
36
|
+
} else {
|
|
37
|
+
const matchedName = found[1];
|
|
38
|
+
const matchedNumber = found[2];
|
|
39
|
+
const incremented = Number(matchedNumber) + 1;
|
|
40
|
+
incrementedName = `${matchedName}-${incremented}`;
|
|
41
|
+
}
|
|
42
|
+
return `${incrementedName}.${extension}`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get a safe filename that doesn't collide with existing documents
|
|
46
|
+
* Similar to Payload's getSafeFileName
|
|
47
|
+
*/ export async function getSafeFilename({ collectionSlug, desiredFilename, prefix, req }) {
|
|
48
|
+
let modifiedFilename = desiredFilename;
|
|
49
|
+
// Keep incrementing until we find a filename that doesn't exist
|
|
50
|
+
while(await docWithFilenameExists({
|
|
51
|
+
collectionSlug,
|
|
52
|
+
filename: modifiedFilename,
|
|
53
|
+
prefix,
|
|
54
|
+
req
|
|
55
|
+
})){
|
|
56
|
+
modifiedFilename = incrementFilename(modifiedFilename);
|
|
57
|
+
}
|
|
58
|
+
return modifiedFilename;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=getSafeFilename.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
A Payload project configured for running on Figma infrastructure.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
{{RUN_COMMAND}} 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)
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Figma CMS Configuration Types
|
|
3
3
|
*/
|
|
4
|
+
import type { PackageManager } from '../utils/package-manager.js';
|
|
4
5
|
/**
|
|
5
6
|
* Tenant instance from Control Plane API
|
|
6
7
|
*/
|
|
@@ -25,7 +26,7 @@ export interface ProjectInfo {
|
|
|
25
26
|
/** Whether Payload is installed */
|
|
26
27
|
hasPayload: boolean;
|
|
27
28
|
/** Package manager detected (npm, pnpm, yarn) */
|
|
28
|
-
packageManager?:
|
|
29
|
+
packageManager?: PackageManager;
|
|
29
30
|
/** Project root path */
|
|
30
31
|
path: string;
|
|
31
32
|
/** Payload version if installed */
|
package/dist/types/config.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type arg from 'arg';
|
|
2
2
|
export interface Args extends arg.Spec {
|
|
3
3
|
'--debug': BooleanConstructor;
|
|
4
|
+
'--env': StringConstructor;
|
|
4
5
|
'--force': BooleanConstructor;
|
|
5
6
|
'--help': BooleanConstructor;
|
|
7
|
+
'--id': StringConstructor;
|
|
8
|
+
'--infra-env': StringConstructor;
|
|
6
9
|
'--list': BooleanConstructor;
|
|
7
10
|
'--logout': BooleanConstructor;
|
|
8
11
|
'--yes': BooleanConstructor;
|
|
@@ -37,7 +40,6 @@ interface Template {
|
|
|
37
40
|
name: string;
|
|
38
41
|
type: ProjectTemplate['type'];
|
|
39
42
|
}
|
|
40
|
-
export type PackageManager = 'bun' | 'npm' | 'pnpm' | 'yarn';
|
|
41
43
|
export type DbType = 'd1-sqlite' | 'mongodb' | 'postgres' | 'sqlite' | 'vercel-postgres';
|
|
42
44
|
export type DbDetails = {
|
|
43
45
|
dbUri?: string;
|
|
@@ -16,15 +16,12 @@ 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
|
|
20
20
|
*
|
|
21
|
-
*
|
|
22
|
-
* - Copies static files to standalone build
|
|
23
|
-
* - Creates lambda.zip from .next/standalone/
|
|
24
|
-
* - Places zip at project root
|
|
21
|
+
* Uses cross-platform Node.js implementation instead of shell script.
|
|
25
22
|
*
|
|
26
23
|
* @param projectPath - Path to project root
|
|
27
|
-
* @throws Error if
|
|
24
|
+
* @throws Error if build missing or zip creation fails
|
|
28
25
|
*/
|
|
29
26
|
export declare function createLambdaZip(projectPath: string): Promise<void>;
|
|
30
27
|
//# sourceMappingURL=asset-collection.d.ts.map
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { exec } from 'child_process';
|
|
2
1
|
import fs from 'fs/promises';
|
|
3
2
|
import path from 'path';
|
|
4
|
-
import {
|
|
3
|
+
import { buildLambdaZip } from './build-lambda-zip.js';
|
|
5
4
|
import * as log from './log.js';
|
|
6
|
-
const execAsync = promisify(exec);
|
|
7
5
|
// Maximum file size for static assets (S3 limitation)
|
|
8
6
|
const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
|
|
9
7
|
;
|
|
@@ -75,43 +73,21 @@ const MAX_ASSET_SIZE = 50 * 1024 * 1024 // 50MB
|
|
|
75
73
|
return [];
|
|
76
74
|
}
|
|
77
75
|
const files = await collectFiles(staticDir, projectPath);
|
|
78
|
-
//
|
|
79
|
-
return files.map((file)=>
|
|
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
|
+
});
|
|
80
81
|
}
|
|
81
82
|
/**
|
|
82
|
-
* Create Lambda deployment zip
|
|
83
|
+
* Create Lambda deployment zip
|
|
83
84
|
*
|
|
84
|
-
*
|
|
85
|
-
* - Copies static files to standalone build
|
|
86
|
-
* - Creates lambda.zip from .next/standalone/
|
|
87
|
-
* - Places zip at project root
|
|
85
|
+
* Uses cross-platform Node.js implementation instead of shell script.
|
|
88
86
|
*
|
|
89
87
|
* @param projectPath - Path to project root
|
|
90
|
-
* @throws Error if
|
|
88
|
+
* @throws Error if build missing or zip creation fails
|
|
91
89
|
*/ export async function createLambdaZip(projectPath) {
|
|
92
|
-
|
|
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
|
-
}
|
|
90
|
+
await buildLambdaZip(projectPath);
|
|
115
91
|
}
|
|
116
92
|
|
|
117
93
|
//# sourceMappingURL=asset-collection.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build Lambda deployment zip using pure Node.js
|
|
3
|
+
*
|
|
4
|
+
* Cross-platform replacement for build_for_lambda.sh:
|
|
5
|
+
* 1. Copies .next/static to .next/standalone/.next/static
|
|
6
|
+
* 2. Copies run.sh to .next/standalone/run.sh
|
|
7
|
+
* 3. Copies public/ to .next/standalone/public/ (if exists)
|
|
8
|
+
* 4. Creates lambda.zip from .next/standalone/
|
|
9
|
+
*
|
|
10
|
+
* @param projectPath - Path to project root
|
|
11
|
+
* @throws Error if standalone directory missing or zip creation fails
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildLambdaZip(projectPath: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=build-lambda-zip.d.ts.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import archiver from 'archiver';
|
|
2
|
+
import { createWriteStream } from 'fs';
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
/**
|
|
6
|
+
* Build Lambda deployment zip using pure Node.js
|
|
7
|
+
*
|
|
8
|
+
* Cross-platform replacement for build_for_lambda.sh:
|
|
9
|
+
* 1. Copies .next/static to .next/standalone/.next/static
|
|
10
|
+
* 2. Copies run.sh to .next/standalone/run.sh
|
|
11
|
+
* 3. Copies public/ to .next/standalone/public/ (if exists)
|
|
12
|
+
* 4. Creates lambda.zip from .next/standalone/
|
|
13
|
+
*
|
|
14
|
+
* @param projectPath - Path to project root
|
|
15
|
+
* @throws Error if standalone directory missing or zip creation fails
|
|
16
|
+
*/ export async function buildLambdaZip(projectPath) {
|
|
17
|
+
const standalonePath = path.join(projectPath, '.next', 'standalone');
|
|
18
|
+
const staticPath = path.join(projectPath, '.next', 'static');
|
|
19
|
+
const publicPath = path.join(projectPath, 'public');
|
|
20
|
+
const runShPath = path.join(projectPath, 'run.sh');
|
|
21
|
+
const zipPath = path.join(projectPath, 'lambda.zip');
|
|
22
|
+
if (!await isDirectory(standalonePath)) {
|
|
23
|
+
throw new Error('Standalone build not found at .next/standalone. ' + 'Ensure next.config.js has output: "standalone" and run build first.');
|
|
24
|
+
}
|
|
25
|
+
if (await isDirectory(staticPath)) {
|
|
26
|
+
const destStatic = path.join(standalonePath, '.next', 'static');
|
|
27
|
+
await copyDirectory(staticPath, destStatic);
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
await fs.copyFile(runShPath, path.join(standalonePath, 'run.sh'));
|
|
31
|
+
} catch {
|
|
32
|
+
// run.sh may not exist in all setups
|
|
33
|
+
}
|
|
34
|
+
if (await isDirectory(publicPath)) {
|
|
35
|
+
const destPublic = path.join(standalonePath, 'public');
|
|
36
|
+
await copyDirectory(publicPath, destPublic);
|
|
37
|
+
}
|
|
38
|
+
await createZip(standalonePath, zipPath);
|
|
39
|
+
}
|
|
40
|
+
async function isDirectory(dirPath) {
|
|
41
|
+
try {
|
|
42
|
+
const stats = await fs.stat(dirPath);
|
|
43
|
+
return stats.isDirectory();
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function copyDirectory(src, dest) {
|
|
49
|
+
await fs.mkdir(dest, {
|
|
50
|
+
recursive: true
|
|
51
|
+
});
|
|
52
|
+
const entries = await fs.readdir(src, {
|
|
53
|
+
withFileTypes: true
|
|
54
|
+
});
|
|
55
|
+
for (const entry of entries){
|
|
56
|
+
const srcPath = path.join(src, entry.name);
|
|
57
|
+
const destPath = path.join(dest, entry.name);
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
await copyDirectory(srcPath, destPath);
|
|
60
|
+
} else {
|
|
61
|
+
await fs.copyFile(srcPath, destPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function createZip(sourceDir, zipPath) {
|
|
66
|
+
return new Promise((resolve, reject)=>{
|
|
67
|
+
const output = createWriteStream(zipPath);
|
|
68
|
+
const archive = archiver('zip', {
|
|
69
|
+
zlib: {
|
|
70
|
+
level: 9
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
output.on('close', ()=>resolve());
|
|
74
|
+
archive.on('error', (err)=>reject(err));
|
|
75
|
+
archive.pipe(output);
|
|
76
|
+
archive.directory(sourceDir, false);
|
|
77
|
+
void archive.finalize();
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=build-lambda-zip.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BootstrapInfo } from '../api/control-plane.js';
|
|
2
|
+
import type { TokenStore } from '../auth/token-store.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cache bootstrap data for all environments in the local encrypted store.
|
|
5
|
+
* Called from init, env, and build-config to keep the store populated.
|
|
6
|
+
*/
|
|
7
|
+
export declare function cacheAllEnvironments(tokenStore: TokenStore, projectId: string, bootstrapInfo: BootstrapInfo): void;
|
|
8
|
+
//# sourceMappingURL=cache-bootstrap.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as log from './log.js';
|
|
2
|
+
/**
|
|
3
|
+
* Cache bootstrap data for all environments in the local encrypted store.
|
|
4
|
+
* Called from init, env, and build-config to keep the store populated.
|
|
5
|
+
*/ export function cacheAllEnvironments(tokenStore, projectId, bootstrapInfo) {
|
|
6
|
+
const { oauthCredentials } = bootstrapInfo;
|
|
7
|
+
for (const env of bootstrapInfo.environments){
|
|
8
|
+
tokenStore.setBootstrapData(projectId, env.name, {
|
|
9
|
+
contentSystemId: env.contentSystemId,
|
|
10
|
+
oauthClientId: oauthCredentials.oauthClientId,
|
|
11
|
+
oauthClientSecret: oauthCredentials.oauthClientSecret,
|
|
12
|
+
tenantInstanceId: env.tenantInstanceId
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
log.debug(`Cached bootstrap data for environments: ${bootstrapInfo.environments.map((e)=>e.name).join(', ')}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=cache-bootstrap.js.map
|
package/dist/utils/config.js
CHANGED
|
@@ -19,7 +19,7 @@ const GITIGNORE_FILENAME = '.gitignore';
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
// Parse existing entries
|
|
22
|
-
const existingLines = existingContent.split(
|
|
22
|
+
const existingLines = existingContent.split(/\r?\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));
|