@payloadcms/figma 0.1.0-internal.e071575 → 0.1.0-internal.fbdc0d3
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/LICENSE.md +1 -1
- package/dist/{utils → adapters}/asset-collection.d.ts +17 -3
- package/dist/adapters/asset-collection.js +242 -0
- package/dist/{utils → adapters}/build-lambda-zip.d.ts +8 -7
- package/dist/adapters/build-lambda-zip.js +111 -0
- package/dist/adapters/configureNextjsCache.d.ts +8 -0
- package/dist/adapters/configureNextjsCache.js +55 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.d.ts +1 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput/getNextRelativeAppDir.js +15 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.d.ts +12 -0
- package/dist/adapters/deploy-output/inspectNextjsOutput.js +28 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.d.ts +9 -0
- package/dist/adapters/deploy-output/inspectNitroOutput.js +13 -0
- package/dist/adapters/deploy-output/isFile.d.ts +1 -0
- package/dist/adapters/deploy-output/isFile.js +4 -0
- package/dist/adapters/deploy-output/readJson.d.ts +1 -0
- package/dist/adapters/deploy-output/readJson.js +9 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.d.ts +8 -0
- package/dist/adapters/deploy-output/resolveNitroOutputLayout.js +16 -0
- package/dist/adapters/deploy-output/resolveOutputPath.d.ts +2 -0
- package/dist/adapters/deploy-output/resolveOutputPath.js +9 -0
- package/dist/adapters/deploy-output/resolveWithin.d.ts +1 -0
- package/dist/adapters/deploy-output/resolveWithin.js +12 -0
- package/dist/adapters/fs-utils.d.ts +39 -0
- package/dist/adapters/fs-utils.js +135 -0
- package/dist/adapters/index.d.ts +4 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.d.ts +40 -0
- package/dist/adapters/lambda-runtime/nextjs-cache.js +174 -0
- package/dist/adapters/nextjs.d.ts +12 -0
- package/dist/adapters/nextjs.js +67 -0
- package/dist/adapters/nitro.d.ts +8 -0
- package/dist/adapters/nitro.js +193 -0
- package/dist/adapters/secret-files.d.ts +25 -0
- package/dist/adapters/secret-files.js +50 -0
- package/dist/adapters/types.d.ts +42 -0
- package/dist/adapters/types.js +1 -0
- package/dist/{utils/adapters → adapters}/vite.d.ts +2 -2
- package/dist/adapters/vite.js +33 -0
- package/dist/api/check-project-subdomain-availability.d.ts +12 -0
- package/dist/api/check-project-subdomain-availability.js +32 -0
- package/dist/api/control-plane-error.d.ts +6 -0
- package/dist/api/control-plane-error.js +8 -0
- package/dist/api/control-plane-fetch.d.ts +7 -0
- package/dist/api/control-plane-fetch.js +37 -0
- package/dist/api/control-plane.d.ts +12 -9
- package/dist/api/control-plane.js +28 -48
- package/dist/api/create-project.d.ts +18 -0
- package/dist/api/create-project.js +37 -0
- package/dist/api/list-project-workspaces.d.ts +8 -0
- package/dist/api/list-project-workspaces.js +28 -0
- package/dist/api/project-resource-type.d.ts +1 -0
- package/dist/api/project-resource-type.js +1 -0
- package/dist/auth/headless-oauth-flow.d.ts +23 -0
- package/dist/auth/headless-oauth-flow.js +73 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +30 -8
- package/dist/auth/refresh.js +12 -12
- package/dist/auth/requested-scopes.d.ts +1 -0
- package/dist/auth/requested-scopes.js +3 -0
- package/dist/auth/token-store.d.ts +20 -1
- package/dist/auth/token-store.js +47 -0
- package/dist/auth/types.d.ts +17 -3
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +5 -1
- package/dist/commands/build-lambda-zip.js +1 -1
- package/dist/commands/deploy.d.ts +12 -0
- package/dist/commands/deploy.js +63 -25
- package/dist/commands/detect-project-resource-type.d.ts +3 -0
- package/dist/commands/detect-project-resource-type.js +28 -0
- package/dist/commands/init.d.ts +2 -2
- package/dist/commands/init.js +235 -80
- package/dist/commands/login.d.ts +11 -1
- package/dist/commands/login.js +66 -4
- package/dist/commands/prompt-to-create-project/format-project-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-project-subdomain.js +3 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/format-unavailable-subdomain-reason.js +7 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/get-default-project-name.js +13 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.d.ts +7 -0
- package/dist/commands/prompt-to-create-project/prompt-for-available-subdomain.js +32 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.d.ts +8 -0
- package/dist/commands/prompt-to-create-project/resolve-project-region.js +27 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-project-subdomain.js +54 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.d.ts +9 -0
- package/dist/commands/prompt-to-create-project/resolve-text-input.js +23 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.d.ts +12 -0
- package/dist/commands/prompt-to-create-project/resolve-workspace-plan-key.js +36 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.d.ts +1 -0
- package/dist/commands/prompt-to-create-project/validate-subdomain.js +9 -0
- package/dist/commands/prompt-to-create-project.d.ts +24 -0
- package/dist/commands/prompt-to-create-project.js +69 -0
- package/dist/commands/setup-agent.d.ts +12 -0
- package/dist/commands/setup-agent.js +123 -0
- package/dist/commands/upgrade.js +65 -1
- package/dist/commands/upload-schema.js +3 -4
- package/dist/commands/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- package/dist/config/oauth.js +6 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -3
- package/dist/db-content-api/generated/content-api-types.d.ts +6 -2
- package/dist/db-content-api/index.d.ts +1 -1
- package/dist/db-content-api/index.js +121 -72
- package/dist/db-content-api/utilities/data/index.js +8 -2
- package/dist/db-content-api/utilities/data/injectGlobalType.d.ts +6 -0
- package/dist/db-content-api/utilities/data/injectGlobalType.js +11 -0
- package/dist/db-content-api/utilities/data/removeVirtualFields.d.ts +3 -11
- package/dist/db-content-api/utilities/data/removeVirtualFields.js +12 -50
- package/dist/db-content-api/utilities/isRecord.d.ts +9 -0
- package/dist/db-content-api/utilities/isRecord.js +19 -0
- package/dist/db-content-api/utilities/joins.js +5 -1
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.d.ts +10 -0
- package/dist/db-content-api/utilities/meta/resolvesToRelationshipValue.js +95 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.d.ts +9 -0
- package/dist/db-content-api/utilities/meta/stringifyIdsInWhere.js +112 -0
- package/dist/db-content-api/utilities/schema/buildDocumentSchema.js +9 -4
- package/dist/db-content-api/utilities/schema/getDocumentSchema.d.ts +3 -0
- package/dist/db-content-api/utilities/schema/getDocumentSchema.js +24 -0
- package/dist/db-content-api/utilities/where.d.ts +2 -6
- package/dist/db-content-api/utilities/where.js +20 -9
- package/dist/exports/client.d.ts +2 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/views.d.ts +1 -0
- package/dist/exports/views.js +1 -0
- package/dist/imageSizeOptions.d.ts +23 -0
- package/dist/imageSizeOptions.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/lib/write-agent-config.d.ts +12 -0
- package/dist/lib/write-agent-config.js +52 -0
- package/dist/next/image-loader.d.ts +6 -0
- package/dist/next/image-loader.js +14 -0
- package/dist/oauth/components/LoginButton/index.js +66 -19
- package/dist/oauth/components/LoginButton/index.scss +121 -15
- package/dist/oauth/defaults.js +4 -1
- package/dist/oauth/endpoints/getLoginEndpoint.js +5 -2
- package/dist/oauth/index.js +8 -7
- package/dist/oauth/utilities/getAdminCollectionSlug.d.ts +1 -1
- package/dist/oauth/utilities/getAuthorizeURL.d.ts +1 -0
- package/dist/oauth/utilities/getAuthorizeURL.js +5 -1
- package/dist/plugin/build-config.d.ts +13 -3
- package/dist/plugin/build-config.js +250 -49
- package/dist/plugin/cache-revalidation-hooks.d.ts +6 -0
- package/dist/plugin/cache-revalidation-hooks.js +69 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.d.ts +9 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.js +66 -0
- package/dist/plugin/cloud-limits/CloudLimitModal/index.scss +56 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/CloudLimitProvider/index.js +110 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.css +14 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.d.ts +4 -0
- package/dist/plugin/cloud-limits/LimitReachedView/index.js +52 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.d.ts +7 -0
- package/dist/plugin/cloud-limits/SlugRegistryContext/index.js +3 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.d.ts +1 -0
- package/dist/plugin/cloud-limits/SlugTracker/index.js +27 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.d.ts +3 -0
- package/dist/plugin/cloud-limits/icons/ExternalLinkIcon.js +30 -0
- package/dist/plugin/cloud-limits/routes.d.ts +2 -0
- package/dist/plugin/cloud-limits/routes.js +4 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.d.ts +9 -0
- package/dist/plugin/cloud-limits/server/redirectInitialAutosaveCreate.js +28 -0
- package/dist/plugin/cloud-limits/shared.d.ts +10 -0
- package/dist/plugin/cloud-limits/shared.js +52 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.d.ts +2 -0
- package/dist/plugin/cloud-limits/utilities/cloudLimitInterceptor.js +134 -0
- package/dist/plugin/cloud-limits/utilities/toasts.d.ts +4 -0
- package/dist/plugin/cloud-limits/utilities/toasts.js +19 -0
- package/dist/plugin/make-permission-access/make-permission-access.d.ts +8 -0
- package/dist/plugin/make-permission-access/make-permission-access.js +24 -0
- package/dist/plugin/sandbox-upload-fetch.d.ts +22 -20
- package/dist/plugin/sandbox-upload-fetch.js +15 -21
- package/dist/skills/deploy-to-figma/SKILL.md +234 -0
- package/dist/skills/deploy-to-figma/references/cli-reference.md +146 -0
- package/dist/storage-content-api/api-types.d.ts +5 -2
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildBaseMediaResponseHeaders.js +8 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.d.ts +12 -0
- package/dist/storage-content-api/buildClientUploadFetchBackHeaders.js +26 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.d.ts +1 -0
- package/dist/storage-content-api/buildMediaRequestHeaders.js +14 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.d.ts +4 -0
- package/dist/storage-content-api/buildMediaResponseHeaders.js +52 -0
- package/dist/storage-content-api/client-uploads/generate.d.ts +7 -3
- package/dist/storage-content-api/client-uploads/generate.js +22 -21
- package/dist/storage-content-api/copyFile.d.ts +16 -0
- package/dist/storage-content-api/copyFile.js +90 -0
- package/dist/storage-content-api/deleteFile.d.ts +8 -0
- package/dist/storage-content-api/deleteFile.js +18 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.d.ts +11 -0
- package/dist/storage-content-api/getDownloadResponseHeaderPolicy.js +33 -0
- package/dist/storage-content-api/getMediaType.d.ts +1 -0
- package/dist/storage-content-api/getMediaType.js +3 -0
- package/dist/storage-content-api/handleUpload.d.ts +1 -2
- package/dist/storage-content-api/handleUpload.js +13 -157
- package/dist/storage-content-api/hasSupportedContentEncoding.d.ts +1 -0
- package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
- package/dist/storage-content-api/index.js +17 -8
- package/dist/storage-content-api/mediaErrorResponse.d.ts +1 -0
- package/dist/storage-content-api/mediaErrorResponse.js +12 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.d.ts +5 -0
- package/dist/storage-content-api/resolveDownloadResponseHeaders.js +13 -0
- package/dist/storage-content-api/shouldAttachMedia.d.ts +1 -0
- package/dist/storage-content-api/shouldAttachMedia.js +34 -0
- package/dist/storage-content-api/staticHandler.d.ts +2 -1
- package/dist/storage-content-api/staticHandler.js +87 -32
- package/dist/storage-content-api/types.d.ts +4 -1
- package/dist/storage-content-api/uploadFileData.d.ts +10 -0
- package/dist/storage-content-api/uploadFileData.js +145 -0
- package/dist/translations/ar.d.ts +12 -0
- package/dist/translations/ar.js +12 -0
- package/dist/translations/az.d.ts +12 -0
- package/dist/translations/az.js +12 -0
- package/dist/translations/bg.d.ts +12 -0
- package/dist/translations/bg.js +12 -0
- package/dist/translations/bnBd.d.ts +12 -0
- package/dist/translations/bnBd.js +12 -0
- package/dist/translations/bnIn.d.ts +12 -0
- package/dist/translations/bnIn.js +12 -0
- package/dist/translations/ca.d.ts +12 -0
- package/dist/translations/ca.js +12 -0
- package/dist/translations/cs.d.ts +12 -0
- package/dist/translations/cs.js +12 -0
- package/dist/translations/da.d.ts +12 -0
- package/dist/translations/da.js +12 -0
- package/dist/translations/de.d.ts +12 -0
- package/dist/translations/de.js +12 -0
- package/dist/translations/en.d.ts +12 -0
- package/dist/translations/en.js +12 -0
- package/dist/translations/es.d.ts +12 -0
- package/dist/translations/es.js +12 -0
- package/dist/translations/et.d.ts +12 -0
- package/dist/translations/et.js +12 -0
- package/dist/translations/fa.d.ts +12 -0
- package/dist/translations/fa.js +12 -0
- package/dist/translations/fr.d.ts +12 -0
- package/dist/translations/fr.js +12 -0
- package/dist/translations/he.d.ts +12 -0
- package/dist/translations/he.js +12 -0
- package/dist/translations/hr.d.ts +12 -0
- package/dist/translations/hr.js +12 -0
- package/dist/translations/hu.d.ts +12 -0
- package/dist/translations/hu.js +12 -0
- package/dist/translations/hy.d.ts +12 -0
- package/dist/translations/hy.js +12 -0
- package/dist/translations/id.d.ts +12 -0
- package/dist/translations/id.js +12 -0
- package/dist/translations/index.d.ts +533 -0
- package/dist/translations/index.js +90 -0
- package/dist/translations/is.d.ts +12 -0
- package/dist/translations/is.js +12 -0
- package/dist/translations/it.d.ts +12 -0
- package/dist/translations/it.js +12 -0
- package/dist/translations/ja.d.ts +12 -0
- package/dist/translations/ja.js +12 -0
- package/dist/translations/ko.d.ts +12 -0
- package/dist/translations/ko.js +12 -0
- package/dist/translations/lt.d.ts +12 -0
- package/dist/translations/lt.js +12 -0
- package/dist/translations/lv.d.ts +12 -0
- package/dist/translations/lv.js +12 -0
- package/dist/translations/my.d.ts +12 -0
- package/dist/translations/my.js +12 -0
- package/dist/translations/nb.d.ts +12 -0
- package/dist/translations/nb.js +12 -0
- package/dist/translations/nl.d.ts +12 -0
- package/dist/translations/nl.js +12 -0
- package/dist/translations/pl.d.ts +12 -0
- package/dist/translations/pl.js +12 -0
- package/dist/translations/pt.d.ts +12 -0
- package/dist/translations/pt.js +12 -0
- package/dist/translations/ro.d.ts +12 -0
- package/dist/translations/ro.js +12 -0
- package/dist/translations/rs.d.ts +12 -0
- package/dist/translations/rs.js +12 -0
- package/dist/translations/rsLatin.d.ts +12 -0
- package/dist/translations/rsLatin.js +12 -0
- package/dist/translations/ru.d.ts +12 -0
- package/dist/translations/ru.js +12 -0
- package/dist/translations/sk.d.ts +12 -0
- package/dist/translations/sk.js +12 -0
- package/dist/translations/sl.d.ts +12 -0
- package/dist/translations/sl.js +12 -0
- package/dist/translations/sv.d.ts +12 -0
- package/dist/translations/sv.js +12 -0
- package/dist/translations/ta.d.ts +12 -0
- package/dist/translations/ta.js +12 -0
- package/dist/translations/th.d.ts +12 -0
- package/dist/translations/th.js +12 -0
- package/dist/translations/tr.d.ts +12 -0
- package/dist/translations/tr.js +12 -0
- package/dist/translations/uk.d.ts +12 -0
- package/dist/translations/uk.js +12 -0
- package/dist/translations/vi.d.ts +12 -0
- package/dist/translations/vi.js +12 -0
- package/dist/translations/zh.d.ts +12 -0
- package/dist/translations/zh.js +12 -0
- package/dist/translations/zhTw.d.ts +12 -0
- package/dist/translations/zhTw.js +12 -0
- package/dist/types.d.ts +11 -0
- package/dist/utils/assert-never.d.ts +1 -0
- package/dist/utils/assert-never.js +3 -0
- package/dist/utils/build-detection.d.ts +6 -1
- package/dist/utils/build-detection.js +68 -89
- package/dist/utils/cache-bootstrap.js +1 -0
- package/dist/utils/deploy-adapter.d.ts +3 -35
- package/dist/utils/deploy-adapter.js +25 -14
- package/dist/utils/env-management.d.ts +15 -0
- package/dist/utils/env-management.js +47 -0
- package/dist/utils/lambda-config.js +18 -23
- package/dist/utils/load-payload-config.js +1 -6
- package/dist/utils/messages.js +24 -3
- package/dist/utils/next-image-loader-config.d.ts +2 -0
- package/dist/utils/next-image-loader-config.js +63 -0
- package/dist/utils/next-image-loader-file.d.ts +2 -0
- package/dist/utils/next-image-loader-file.js +11 -0
- package/dist/utils/payload-config-ast.d.ts +5 -0
- package/dist/utils/payload-config-ast.js +73 -4
- package/dist/utils/payload-config-modifier.js +3 -0
- package/dist/utils/payload-generate.d.ts +10 -0
- package/dist/utils/payload-generate.js +59 -0
- package/dist/utils/payload-secret.d.ts +28 -0
- package/dist/utils/payload-secret.js +34 -0
- package/dist/utils/pnpm-builds.d.ts +14 -0
- package/dist/utils/pnpm-builds.js +125 -0
- package/dist/utils/s3-upload.js +4 -1
- package/package.json +33 -8
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- package/dist/storage-content-api/handleDelete.d.ts +0 -7
- package/dist/storage-content-api/handleDelete.js +0 -15
- package/dist/storage-content-api/utilities/getSafeFilename.d.ts +0 -11
- package/dist/storage-content-api/utilities/getSafeFilename.js +0 -59
- package/dist/storage-content-api/utilities/index.d.ts +0 -2
- package/dist/storage-content-api/utilities/index.js +0 -2
- package/dist/storage-content-api/utilities/parseUploadReference.d.ts +0 -17
- package/dist/storage-content-api/utilities/parseUploadReference.js +0 -27
- package/dist/utils/adapters/nextjs.d.ts +0 -8
- package/dist/utils/adapters/nextjs.js +0 -61
- package/dist/utils/adapters/nitro.d.ts +0 -8
- package/dist/utils/adapters/nitro.js +0 -172
- package/dist/utils/adapters/vite.js +0 -31
- package/dist/utils/asset-collection.js +0 -144
- package/dist/utils/build-lambda-zip.js +0 -90
- package/dist/utils/fs-utils.d.ts +0 -12
- package/dist/utils/fs-utils.js +0 -55
|
@@ -1,40 +1,34 @@
|
|
|
1
1
|
import * as log from '../utils/log.js';
|
|
2
2
|
/**
|
|
3
|
-
* True inside the Make sandbox. agentplat injects `FIGMA=1
|
|
4
|
-
*
|
|
5
|
-
* accepted because the Make app template's `vite.config.ts` treats both as
|
|
6
|
-
* sandbox markers.
|
|
3
|
+
* True inside the Make sandbox. agentplat injects `FIGMA=1`, absent locally and
|
|
4
|
+
* in the deployed Lambda; `FIGMA=true` matches the app template's vite config.
|
|
7
5
|
*
|
|
8
6
|
* KEEP_IN_SYNC(services/agentplat/scriptrun/script_runner.go): EnvFigma
|
|
9
7
|
*/ export function isMakeSandbox() {
|
|
10
8
|
return process.env.FIGMA === '1' || process.env.FIGMA === 'true';
|
|
11
9
|
}
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
14
|
-
* maps external hostnames to unique-local IPv6 addresses (`fc00::/7`)
|
|
15
|
-
* `safeFetch` rejects
|
|
16
|
-
* sandbox this is a no-op.
|
|
11
|
+
* Defaults upload collections to skip `safeFetch` in the Make sandbox, where DNS
|
|
12
|
+
* maps external hostnames to unique-local IPv6 addresses (`fc00::/7`) that
|
|
13
|
+
* `safeFetch` rejects as non-unicast. A no-op elsewhere.
|
|
17
14
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
15
|
+
* Only a default: a collection that set `skipSafeFetch` itself keeps its value.
|
|
16
|
+
* `externalFileHeaderFilter` is left unset on purpose, since it would replace
|
|
17
|
+
* the cookie logic that forwards credentials for relative URLs.
|
|
21
18
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* hops only against `pasteURL.allowList`; any session can make the server GET
|
|
29
|
-
* an arbitrary URL and read the body; request cookies reach the fetch target.
|
|
30
|
-
*/ export function createSandboxUploadFetchPlugin() {
|
|
19
|
+
* SSRF risks, bounded by the routes' auth gate and sandbox network limits:
|
|
20
|
+
* `getExternalFile` re-validates redirects only against `pasteURL.allowList`,
|
|
21
|
+
* any session can GET an arbitrary URL and read the body, and request cookies
|
|
22
|
+
* reach the target.
|
|
23
|
+
*/ export function createSandboxUploadFetchPlugin({ userCollections }) {
|
|
24
|
+
const appOwnedSlugs = new Set((userCollections ?? []).filter((collection)=>typeof collection.upload === 'object' && 'skipSafeFetch' in collection.upload).map((collection)=>collection.slug));
|
|
31
25
|
return (config)=>{
|
|
32
26
|
if (!isMakeSandbox()) {
|
|
33
27
|
return config;
|
|
34
28
|
}
|
|
35
29
|
const modifiedSlugs = [];
|
|
36
30
|
const collections = (config.collections ?? []).map((collection)=>{
|
|
37
|
-
if (!collection.upload) {
|
|
31
|
+
if (!collection.upload || appOwnedSlugs.has(collection.slug)) {
|
|
38
32
|
return collection;
|
|
39
33
|
}
|
|
40
34
|
modifiedSlugs.push(collection.slug);
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deploy-to-figma
|
|
3
|
+
description: This skill should be used when the user asks to "deploy to Figma", "publish to Figma", "ship to Figma", "deploy my app to Figma Cloud", "put this Payload site on Figma", or otherwise wants to deploy the current project to Figma Cloud. You (the agent) inspect, classify, and build the target project; the @payloadcms/figma CLI only authenticates and deploys the verified artifact you hand it.
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
allowed-tools: Read, Bash, AskUserQuestion
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deploy to Figma Cloud
|
|
9
|
+
|
|
10
|
+
Deploy a project to Figma Cloud with the `@payloadcms/figma` CLI. **You** (the
|
|
11
|
+
agent) determine the deploy shape — you inspect the project, run the build, and
|
|
12
|
+
verify the real build artifacts, then hand the CLI an explicit adapter and
|
|
13
|
+
output root you have confirmed on disk. The CLI no longer inspects the project;
|
|
14
|
+
it only authenticates and ships the artifact you point it at.
|
|
15
|
+
|
|
16
|
+
**Golden rule:** detection is your job. Read files and inspect real artifacts —
|
|
17
|
+
do not ask `@payloadcms/figma` what framework this is, and do not guess. When the
|
|
18
|
+
evidence conflicts or the shape isn't one Figma Cloud supports, **stop** before
|
|
19
|
+
touching auth or deploy.
|
|
20
|
+
|
|
21
|
+
Run the CLI with `npx @payloadcms/figma@alpha <...>` **from the target folder**.
|
|
22
|
+
If a different invocation is already established in the repo (e.g.
|
|
23
|
+
`pnpm start --`), use that instead — but `npx @payloadcms/figma@alpha` is the
|
|
24
|
+
default.
|
|
25
|
+
|
|
26
|
+
If the user's request contains **“Figma staging”** (case-insensitive), append
|
|
27
|
+
`--infra-env staging` to every CLI invocation in this flow, including login,
|
|
28
|
+
login completion, deploy, and deploy retries. Otherwise omit the flag.
|
|
29
|
+
|
|
30
|
+
## Flow overview
|
|
31
|
+
|
|
32
|
+
1. **Resolve** the target project directory.
|
|
33
|
+
2. **Inspect & classify** the deploy shape from evidence — or stop if unsupported/ambiguous.
|
|
34
|
+
3. **Build & verify** the real artifact (buildable projects); static folders skip the build.
|
|
35
|
+
4. **Detect initialization** from `target/.env`; gather creation inputs if uninitialized.
|
|
36
|
+
5. **Preflight auth** with the resumable headless flow.
|
|
37
|
+
6. **Deploy** the verified artifact with an explicit `--adapter` and `--output`.
|
|
38
|
+
7. **Report** the deployed URL.
|
|
39
|
+
|
|
40
|
+
Exact CLI contracts (flags, JSON shapes, artifact signatures) live in
|
|
41
|
+
`references/cli-reference.md` — consult it when a flag or field is unclear.
|
|
42
|
+
|
|
43
|
+
## Step 1 — Resolve the target directory
|
|
44
|
+
|
|
45
|
+
- If the prompt names a directory, that is the target.
|
|
46
|
+
- Otherwise use the current folder.
|
|
47
|
+
- In a **monorepo**, operate from the target **package** folder — not the repo
|
|
48
|
+
root. If several plausible apps exist and none is clearly the target, **ask**
|
|
49
|
+
via `AskUserQuestion` rather than guessing.
|
|
50
|
+
|
|
51
|
+
Every command and the build run **from the target folder**.
|
|
52
|
+
|
|
53
|
+
## Step 2 — Inspect and classify the deploy shape
|
|
54
|
+
|
|
55
|
+
Gather evidence yourself with `Read`/`Bash`. Do **not** rely on
|
|
56
|
+
`@payloadcms/figma` for detection. Look at:
|
|
57
|
+
|
|
58
|
+
- `package.json` — `dependencies`/`devDependencies`, `scripts.build`, and
|
|
59
|
+
`packageManager`.
|
|
60
|
+
- Lockfiles — `pnpm-lock.yaml`, `package-lock.json`, `yarn.lock`, `bun.lockb`.
|
|
61
|
+
- Framework config — `next.config.*`, `vite.config.*`, `nitro.config.*`,
|
|
62
|
+
`nuxt.config.*`, `app.config.*`.
|
|
63
|
+
- Source layout and any build artifacts already on disk.
|
|
64
|
+
|
|
65
|
+
Map the evidence to one **supported deploy shape**:
|
|
66
|
+
|
|
67
|
+
| Evidence | Shape | `--adapter` |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `next` dependency / `next.config.*` / a `next build` script | Next.js | `nextjs` |
|
|
70
|
+
| Nitro, Nuxt, TanStack Start, or any other evidenced Nitro output | Nitro | `nitro` |
|
|
71
|
+
| A built (or buildable) Vite single-page app | Vite | `vite` |
|
|
72
|
+
| A simple static folder — `index.html` plus CSS/JS/assets, no build needed (even with **no** `package.json`) | Static | `vite`, output = that folder |
|
|
73
|
+
|
|
74
|
+
If the evidence fits **none** of these, or points at **more than one** framework
|
|
75
|
+
with no clear winner, or you otherwise can't land confidently on one supported
|
|
76
|
+
shape → **go to Step 8 and stop**. Do not build, authenticate, or deploy.
|
|
77
|
+
|
|
78
|
+
## Step 3 — Build and verify the artifact
|
|
79
|
+
|
|
80
|
+
**Buildable projects** (Next.js / Nitro / Vite): run the build **from the target
|
|
81
|
+
folder, before** any auth or project creation, with `FIGMA_EXTRACT_SCHEDULES=true`.
|
|
82
|
+
|
|
83
|
+
Pick the package manager by searching the **target folder and its ancestors**
|
|
84
|
+
(up to the repo/monorepo root) — in a monorepo the `packageManager` field and
|
|
85
|
+
the lockfile usually live at the workspace root, not in the target package.
|
|
86
|
+
Precedence: nearest `packageManager` field → nearest lockfile
|
|
87
|
+
(`pnpm-lock.yaml`→pnpm, `package-lock.json`→npm, `yarn.lock`→yarn,
|
|
88
|
+
`bun.lockb`→bun) → available tooling. Run the build itself **from the target
|
|
89
|
+
package folder** with whichever manager you resolved, e.g.:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
FIGMA_EXTRACT_SCHEDULES=true npm run build
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then **inspect the actual artifacts** to confirm the adapter and the output
|
|
96
|
+
**root**:
|
|
97
|
+
|
|
98
|
+
- **Next.js** — the root contains `BUILD_ID` and standalone server output. Pass
|
|
99
|
+
the root (e.g. `.next`) — **never** `.next/standalone`.
|
|
100
|
+
- **Nitro** — the root contains `server/index.mjs` (typically `.output`).
|
|
101
|
+
- **Vite** — the root contains `index.html` (typically `dist`).
|
|
102
|
+
|
|
103
|
+
**Static folders** skip the build entirely. The output is the exact folder that
|
|
104
|
+
contains `index.html` (often `.`).
|
|
105
|
+
|
|
106
|
+
If the build fails, or the artifacts don't match the shape you classified (the
|
|
107
|
+
evidence now conflicts), **stop** — go to Step 8. Never pass an `--output` root
|
|
108
|
+
you have not confirmed exists on disk.
|
|
109
|
+
|
|
110
|
+
## Step 4 — Detect initialization; gather creation inputs
|
|
111
|
+
|
|
112
|
+
Detect initialization **only** by testing whether `target/.env` contains a
|
|
113
|
+
nonempty `FIGMA_PROJECT_ID`, e.g.:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
test -f .env && grep -Eq '^FIGMA_PROJECT_ID=.+' .env && echo initialized || echo uninitialized
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Do **not** print the value or dump `.env`.
|
|
120
|
+
|
|
121
|
+
**Initialized** (`FIGMA_PROJECT_ID` present) → skip this step; pass no creation flags.
|
|
122
|
+
|
|
123
|
+
**Uninitialized** → gather the five project-creation fields across **two** grouped
|
|
124
|
+
`AskUserQuestion` interactions (a single call accepts at most four questions),
|
|
125
|
+
each field offering the CLI default so the user can accept as-is:
|
|
126
|
+
|
|
127
|
+
**Interaction 1 — naming** (three questions):
|
|
128
|
+
|
|
129
|
+
| Field | CLI default | Deploy flag |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| Project name | derived from the directory name | `--name` |
|
|
132
|
+
| Description | `"<name> project"` | `--description` |
|
|
133
|
+
| Subdomain | slugified from the project name | `--subdomain` |
|
|
134
|
+
|
|
135
|
+
**Interaction 2 — placement** (two questions):
|
|
136
|
+
|
|
137
|
+
| Field | CLI default | Deploy flag |
|
|
138
|
+
| --- | --- | --- |
|
|
139
|
+
| Workspace | the account's default Figma workspace | `--workspace` |
|
|
140
|
+
| Region | `us-east-1` | `--region` |
|
|
141
|
+
|
|
142
|
+
Present the defaults as the recommended option. For any field left at its
|
|
143
|
+
default, **omit** the corresponding flag and let the CLI apply the default — only
|
|
144
|
+
pass a flag when the user supplied a non-default value.
|
|
145
|
+
|
|
146
|
+
## Step 5 — Preflight authentication
|
|
147
|
+
|
|
148
|
+
The deploy command needs a valid credential and cannot open a browser in a
|
|
149
|
+
headless/agent context, so authenticate first with the resumable headless flow.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx @payloadcms/figma@alpha login --headless --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Parse `status`:
|
|
156
|
+
|
|
157
|
+
- `authenticated` — already logged in. Proceed to deploy.
|
|
158
|
+
- `authorization_required` — the JSON includes `authorizationUrl` and
|
|
159
|
+
`sessionId`. Give the user the `authorizationUrl`, ask them to open it,
|
|
160
|
+
approve, and paste back **the full redirected URL** (the
|
|
161
|
+
`http://localhost:.../callback?...` address the browser lands on). Then:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
npx @payloadcms/figma@alpha login --complete <sessionId> --callback-url '<redirect-url>' --json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Quote the callback URL in single quotes. Expect `{"status":"authenticated",...}`.
|
|
168
|
+
|
|
169
|
+
**Handle the callback URL as a one-time secret:** pass it directly to the
|
|
170
|
+
`--complete` command and nothing else. Do not echo it back, summarize it, store
|
|
171
|
+
it in a file, or repeat it in later messages.
|
|
172
|
+
|
|
173
|
+
If completion fails, report the CLI's error and let the user retry the login
|
|
174
|
+
step; do not loop silently.
|
|
175
|
+
|
|
176
|
+
## Step 6 — Deploy
|
|
177
|
+
|
|
178
|
+
Run **from the target folder**, non-interactively with `-y`. Always pass
|
|
179
|
+
`--skip-build` (you already built, or a static folder needs no build) and the
|
|
180
|
+
explicit `--adapter` / `--output` you verified in Steps 2–3:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx @payloadcms/figma@alpha deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <verified-root>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Add the project-creation flags from Step 4 only for an uninitialized project.
|
|
187
|
+
|
|
188
|
+
Examples:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Next.js app in a monorepo package (already initialized), built to .next
|
|
192
|
+
npx @payloadcms/figma@alpha deploy -y --skip-build --adapter nextjs --output .next
|
|
193
|
+
|
|
194
|
+
# Vite single-page app, built to dist
|
|
195
|
+
npx @payloadcms/figma@alpha deploy -y --skip-build --adapter vite --output dist
|
|
196
|
+
|
|
197
|
+
# Simple static folder (index.html at the folder root), no build
|
|
198
|
+
npx @payloadcms/figma@alpha deploy -y --skip-build --adapter vite --output .
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Deterministic retry — workspace selection
|
|
202
|
+
|
|
203
|
+
If deploy fails with a message like:
|
|
204
|
+
|
|
205
|
+
> Multiple eligible Figma workspaces. Pass --workspace `<plan-key>`. Available: Acme (plan_abc), Beta (plan_xyz)
|
|
206
|
+
|
|
207
|
+
re-run the exact same command with `--workspace <plan-key>` added, choosing the
|
|
208
|
+
plan key the user selected (ask via `AskUserQuestion` if not already known,
|
|
209
|
+
listing the workspaces from the error's `Available:` list). This is the only
|
|
210
|
+
retry to perform automatically. For other errors, surface the CLI message and stop.
|
|
211
|
+
|
|
212
|
+
## Step 7 — Report the result
|
|
213
|
+
|
|
214
|
+
On success the CLI prints a line like `URL: https://<subdomain>.<domain>`.
|
|
215
|
+
Extract that URL and report it to the user as the deployed address, noting the
|
|
216
|
+
CLI's own message that a deploy usually takes 2–3 minutes to finish.
|
|
217
|
+
|
|
218
|
+
## Step 8 — Unsupported or ambiguous → stop
|
|
219
|
+
|
|
220
|
+
If Steps 2–3 can't land confidently on one supported shape, **stop before auth
|
|
221
|
+
or deploy**. Tell the user what you found and quote the supported set:
|
|
222
|
+
|
|
223
|
+
> Figma Cloud supports Next.js, Vite single-page apps, and any Nitro-based app
|
|
224
|
+
> (including Nuxt and TanStack Start).
|
|
225
|
+
|
|
226
|
+
Never run `login` or `deploy` for an unsupported or ambiguous project. Decide
|
|
227
|
+
this **before** asking an uninitialized project's creation questions — never make
|
|
228
|
+
the user answer prompts only to fail on an unsupported framework.
|
|
229
|
+
|
|
230
|
+
## Additional resources
|
|
231
|
+
|
|
232
|
+
- **`references/cli-reference.md`** — the deploy/login flags this skill uses, the
|
|
233
|
+
`login ... --json` JSON shapes, and the on-disk artifact signatures that
|
|
234
|
+
confirm each adapter and output root.
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @payloadcms/figma CLI reference (deploy-to-figma)
|
|
2
|
+
|
|
3
|
+
Exact contracts the orchestration depends on. Source of truth is the CLI itself
|
|
4
|
+
(`payload/payload-plugin` in figma/figma); this file mirrors the flags and shapes
|
|
5
|
+
the skill reads. If something is unclear, run the command and inspect the raw
|
|
6
|
+
output rather than guessing.
|
|
7
|
+
|
|
8
|
+
The CLI does **not** inspect the project — there is no `deploy --inspect` and no
|
|
9
|
+
project-inspection JSON API. The agent classifies the deploy shape from evidence
|
|
10
|
+
(see `SKILL.md` Steps 2–3) and hands the CLI an explicit `--adapter` and
|
|
11
|
+
`--output`.
|
|
12
|
+
|
|
13
|
+
## Classifying the deploy shape (agent-driven)
|
|
14
|
+
|
|
15
|
+
Detect the shape yourself from files on disk. Do **not** call `@payloadcms/figma`
|
|
16
|
+
to detect it.
|
|
17
|
+
|
|
18
|
+
| Evidence | adapter | typical output root |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| Next.js — `next` dep, `next.config.*`, or a `next build` script | `nextjs` | `.next` |
|
|
21
|
+
| Nitro / Nuxt / TanStack Start / other evidenced Nitro output | `nitro` | `.output` |
|
|
22
|
+
| Built Vite single-page app | `vite` | `dist` |
|
|
23
|
+
| Simple static folder — `index.html` + CSS/JS/assets, no build (no `package.json` OK) | `vite` | the folder itself (often `.`) |
|
|
24
|
+
|
|
25
|
+
Framework config hints: Next.js `distDir` (`next.config.*`), Vite `build.outDir`
|
|
26
|
+
(`vite.config.*`), Nitro/Nuxt `output.dir` (`nitro.config.*` / `nuxt.config.*`).
|
|
27
|
+
Custom output dirs mean you must confirm the real root against artifacts below.
|
|
28
|
+
|
|
29
|
+
### On-disk artifact signatures (confirm before deploy)
|
|
30
|
+
|
|
31
|
+
After building (or for a static folder, as-is), confirm the output **root** by
|
|
32
|
+
what it contains:
|
|
33
|
+
|
|
34
|
+
- **Next.js** — root contains `BUILD_ID` **and** standalone server output. Pass
|
|
35
|
+
the root such as `.next`; **never** `.next/standalone`.
|
|
36
|
+
- **Nitro** — root contains `server/index.mjs` (typically `.output`).
|
|
37
|
+
- **Vite / static** — root contains `index.html` (typically `dist`; a static
|
|
38
|
+
folder may be `.`).
|
|
39
|
+
|
|
40
|
+
If the build fails or the artifacts don't match the classified shape, **stop** —
|
|
41
|
+
do not pass an unverified `--output`.
|
|
42
|
+
|
|
43
|
+
## Building
|
|
44
|
+
|
|
45
|
+
Run the target package's build **from the target folder**, before auth, with
|
|
46
|
+
`FIGMA_EXTRACT_SCHEDULES=true`. Choose the package manager by searching the
|
|
47
|
+
target folder **and its ancestors** (up to the repo/monorepo root) — the
|
|
48
|
+
`packageManager` field and the lockfile often live at the workspace root, not
|
|
49
|
+
the target package. Precedence: nearest `packageManager` field → nearest
|
|
50
|
+
lockfile (`pnpm-lock.yaml`→pnpm, `package-lock.json`→npm, `yarn.lock`→yarn,
|
|
51
|
+
`bun.lockb`→bun) → available tooling. Even so, run the build itself from the
|
|
52
|
+
target package folder. Static folders skip the build.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
FIGMA_EXTRACT_SCHEDULES=true npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## `login --headless --json`
|
|
59
|
+
|
|
60
|
+
Starts (or short-circuits) a resumable login without a live terminal.
|
|
61
|
+
|
|
62
|
+
Already authenticated:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{ "status": "authenticated", "userId": "..." }
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Authorization required:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"status": "authorization_required",
|
|
73
|
+
"authorizationUrl": "https://www.figma.com/oauth?...",
|
|
74
|
+
"sessionId": "sess_...",
|
|
75
|
+
"expiresAt": 1730000000000
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## `login --complete <sessionId> --callback-url '<url>' --json`
|
|
80
|
+
|
|
81
|
+
Completes a pending headless login using the full redirect URL the browser
|
|
82
|
+
landed on (`http://localhost:<port>/callback?code=...&state=...`). Returns:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{ "status": "authenticated", "userId": "..." }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Treat the callback URL as a one-time secret: pass it once, never echo or persist it.
|
|
89
|
+
|
|
90
|
+
## Infrastructure environment
|
|
91
|
+
|
|
92
|
+
When the user's request contains “Figma staging” (case-insensitive), append
|
|
93
|
+
`--infra-env staging` to every CLI command, including login, login completion,
|
|
94
|
+
deploy, and deploy retries. Otherwise omit the flag.
|
|
95
|
+
|
|
96
|
+
## `deploy` flags used by this skill
|
|
97
|
+
|
|
98
|
+
The deploy command is always explicit — the agent supplies the verified adapter
|
|
99
|
+
and output root and skips the build (it already ran, or the folder is static):
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx @payloadcms/figma@alpha deploy -y --skip-build --adapter <nextjs|nitro|vite> --output <root>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Flag | Purpose |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `-y`, `--yes` | Non-interactive; safe project-creation defaults |
|
|
108
|
+
| `--infra-env staging` | Target Figma staging when explicitly requested |
|
|
109
|
+
| `--skip-build` | Always passed — deploy the artifact as-is, never rebuild |
|
|
110
|
+
| `--adapter <name>` | `nextjs` \| `vite` \| `nitro` — the shape you classified |
|
|
111
|
+
| `--output <path>` | The exact, verified build output root |
|
|
112
|
+
| `--name <name>` | Project name (uninitialized project creation) |
|
|
113
|
+
| `--description <text>` | Project description (uninitialized) |
|
|
114
|
+
| `--subdomain <sub>` | Requested subdomain (uninitialized) |
|
|
115
|
+
| `--workspace <planKey>` | Workspace plan key (uninitialized; also the retry flag) |
|
|
116
|
+
| `--region <region>` | Region, e.g. `us-east-1` (uninitialized) |
|
|
117
|
+
|
|
118
|
+
Initialization is detected only by a nonempty `FIGMA_PROJECT_ID` in `target/.env`
|
|
119
|
+
(never printed). Initialized projects pass no creation flags.
|
|
120
|
+
|
|
121
|
+
## Deterministic deploy retry
|
|
122
|
+
|
|
123
|
+
When multiple eligible workspaces exist and none is a default, non-interactive
|
|
124
|
+
deploy fails with:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
Multiple eligible Figma workspaces. Pass --workspace <plan-key>. Available: <Name> (<plan-key>), ...
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Re-run the identical command with `--workspace <plan-key>` for the chosen
|
|
131
|
+
workspace. An invalid `--workspace` value fails with:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
Workspace plan key "<key>" is not eligible. Available: <Name> (<plan-key>), ...
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Success output
|
|
138
|
+
|
|
139
|
+
On success the CLI prints:
|
|
140
|
+
|
|
141
|
+
```text
|
|
142
|
+
URL: https://<subdomain>.<domain>
|
|
143
|
+
This usually takes 2-3 minutes to complete.
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Extract the `URL:` line as the deployed address.
|
|
@@ -34,7 +34,7 @@ export type UploadPaths = {
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
-
};
|
|
37
|
+
} & UploadErrorResponses;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
'/api/v0/uploads/download/sign': {
|
|
@@ -45,6 +45,9 @@ export type UploadPaths = {
|
|
|
45
45
|
collectionId: string;
|
|
46
46
|
expiresIn: number;
|
|
47
47
|
filename: string;
|
|
48
|
+
responseHeaders: {
|
|
49
|
+
cacheControl: string;
|
|
50
|
+
};
|
|
48
51
|
};
|
|
49
52
|
};
|
|
50
53
|
};
|
|
@@ -56,7 +59,7 @@ export type UploadPaths = {
|
|
|
56
59
|
};
|
|
57
60
|
};
|
|
58
61
|
};
|
|
59
|
-
};
|
|
62
|
+
} & UploadErrorResponses;
|
|
60
63
|
};
|
|
61
64
|
};
|
|
62
65
|
'/api/v0/uploads/multipart/abort': {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildBaseMediaResponseHeaders(): Headers;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* After a client upload, Payload reads the file from storage to determine image dimensions.
|
|
3
|
+
* For types outside the inline allowlist, such as SVG (which can contain scripts), omit
|
|
4
|
+
* Content-Type so Payload uses the original upload MIME type instead of application/octet-stream.
|
|
5
|
+
* Attachment and sandbox protections remain. This helper is only used when uploadReference
|
|
6
|
+
* is present; normal file requests use buildMediaResponseHeaders.
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, upstreamHeaders, }: {
|
|
9
|
+
fallbackContentType?: string;
|
|
10
|
+
filename: string;
|
|
11
|
+
upstreamHeaders: Headers;
|
|
12
|
+
}): Headers;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { buildMediaResponseHeaders } from './buildMediaResponseHeaders.js';
|
|
2
|
+
import { shouldAttachMedia } from './shouldAttachMedia.js';
|
|
3
|
+
/**
|
|
4
|
+
* After a client upload, Payload reads the file from storage to determine image dimensions.
|
|
5
|
+
* For types outside the inline allowlist, such as SVG (which can contain scripts), omit
|
|
6
|
+
* Content-Type so Payload uses the original upload MIME type instead of application/octet-stream.
|
|
7
|
+
* Attachment and sandbox protections remain. This helper is only used when uploadReference
|
|
8
|
+
* is present; normal file requests use buildMediaResponseHeaders.
|
|
9
|
+
*/ export function buildClientUploadFetchBackHeaders({ fallbackContentType, filename, upstreamHeaders }) {
|
|
10
|
+
const effectiveContentType = upstreamHeaders.get('Content-Type') || fallbackContentType;
|
|
11
|
+
const upstreamHeadersWithFallback = new Headers(upstreamHeaders);
|
|
12
|
+
if (effectiveContentType) {
|
|
13
|
+
upstreamHeadersWithFallback.set('Content-Type', effectiveContentType);
|
|
14
|
+
}
|
|
15
|
+
const headers = buildMediaResponseHeaders({
|
|
16
|
+
filename,
|
|
17
|
+
upstreamHeaders: upstreamHeadersWithFallback
|
|
18
|
+
});
|
|
19
|
+
if (effectiveContentType && shouldAttachMedia(upstreamHeadersWithFallback)) {
|
|
20
|
+
// Payload uses the response content type when processing an uploaded image.
|
|
21
|
+
// The sanitized type can hide the original upload MIME type.
|
|
22
|
+
// Remove it so Payload falls back to the original type.
|
|
23
|
+
headers.delete('Content-Type');
|
|
24
|
+
}
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildMediaRequestHeaders(incomingHeaders: Headers): Headers;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function buildMediaRequestHeaders(incomingHeaders) {
|
|
2
|
+
const headers = new Headers({
|
|
3
|
+
'Accept-Encoding': 'identity'
|
|
4
|
+
});
|
|
5
|
+
const range = incomingHeaders.get('Range');
|
|
6
|
+
if (range) {
|
|
7
|
+
headers.set('Range', range);
|
|
8
|
+
const ifRange = incomingHeaders.get('If-Range');
|
|
9
|
+
if (ifRange) {
|
|
10
|
+
headers.set('If-Range', ifRange);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return headers;
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { buildBaseMediaResponseHeaders } from './buildBaseMediaResponseHeaders.js';
|
|
2
|
+
import { getMediaType } from './getMediaType.js';
|
|
3
|
+
import { shouldAttachMedia } from './shouldAttachMedia.js';
|
|
4
|
+
const FORWARDED_MEDIA_RESPONSE_HEADERS = [
|
|
5
|
+
'Cache-Control',
|
|
6
|
+
'Content-Length',
|
|
7
|
+
'Content-Range',
|
|
8
|
+
'ETag',
|
|
9
|
+
'Last-Modified'
|
|
10
|
+
];
|
|
11
|
+
const ATTACHMENT_CSP = "sandbox; default-src 'none'; base-uri 'none'; form-action 'none'";
|
|
12
|
+
export function buildMediaResponseHeaders({ filename, upstreamHeaders }) {
|
|
13
|
+
const headers = buildBaseMediaResponseHeaders();
|
|
14
|
+
for (const name of FORWARDED_MEDIA_RESPONSE_HEADERS){
|
|
15
|
+
const value = upstreamHeaders.get(name);
|
|
16
|
+
if (value) {
|
|
17
|
+
headers.set(name, value);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (shouldAttachMedia(upstreamHeaders)) {
|
|
21
|
+
headers.set('Content-Type', 'application/octet-stream');
|
|
22
|
+
headers.set('Content-Disposition', attachmentDisposition(filename));
|
|
23
|
+
headers.set('Content-Security-Policy', ATTACHMENT_CSP);
|
|
24
|
+
} else {
|
|
25
|
+
// Send only the approved media type; do not pass through untrusted parameters.
|
|
26
|
+
headers.set('Content-Type', getMediaType(upstreamHeaders));
|
|
27
|
+
}
|
|
28
|
+
return headers;
|
|
29
|
+
}
|
|
30
|
+
function attachmentDisposition(filename) {
|
|
31
|
+
const sanitizedName = sanitizeFilename(filename);
|
|
32
|
+
const safeName = Array.from(sanitizedName).slice(0, 255).join('') || 'download';
|
|
33
|
+
let utf8Name;
|
|
34
|
+
try {
|
|
35
|
+
// encodeURIComponent leaves !, ', (, ), and * unchanged. Encode those five characters as % escapes.
|
|
36
|
+
utf8Name = encodeURIComponent(safeName).replace(/[!'()*]/g, (character)=>`%${character.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
37
|
+
} catch {
|
|
38
|
+
// Invalid UTF-16, such as an unpaired surrogate, cannot be encoded in filename*.
|
|
39
|
+
return `attachment; filename="download"; filename*=UTF-8''download`;
|
|
40
|
+
}
|
|
41
|
+
// Replace non-ASCII and control characters, quotes, backslashes, and % with underscores.
|
|
42
|
+
const asciiName = safeName.replace(/[^\x20-\x7e]/g, '_').replace(/["\\%]/g, '_');
|
|
43
|
+
return `attachment; filename="${asciiName}"; filename*=UTF-8''${utf8Name}`;
|
|
44
|
+
}
|
|
45
|
+
function sanitizeFilename(filename) {
|
|
46
|
+
// Replace control characters (0–31 and 127) and slashes with underscores.
|
|
47
|
+
// This keeps newlines and directory paths out of the download name.
|
|
48
|
+
return Array.from(filename, (character)=>{
|
|
49
|
+
const codePoint = character.codePointAt(0);
|
|
50
|
+
return codePoint < 32 || codePoint === 127 || character === '/' || character === '\\' ? '_' : character;
|
|
51
|
+
}).join('');
|
|
52
|
+
}
|
|
@@ -3,12 +3,16 @@ import type { StorageClient } from '../client.js';
|
|
|
3
3
|
type Args = {
|
|
4
4
|
access?: UploadInstructionsAccess;
|
|
5
5
|
client: StorageClient;
|
|
6
|
+
collectionPrefix?: string;
|
|
6
7
|
};
|
|
7
8
|
/**
|
|
8
9
|
* v4 client-upload entry point. Payload core calls this from
|
|
9
10
|
* `POST /api/upload-instructions`; we sign a Content API upload URL and hand the
|
|
10
|
-
* browser an `http` PUT instruction plus
|
|
11
|
-
*
|
|
11
|
+
* browser an `http` PUT instruction plus a signed upload receipt.
|
|
12
|
+
*
|
|
13
|
+
* Each upload gets its own `_objectKey`, so it never overwrites another object.
|
|
14
|
+
* Payload verifies the receipt before it reads the uploaded file back through
|
|
15
|
+
* `staticHandler`, and it does not upload the original again in `handleUpload`.
|
|
12
16
|
*/
|
|
13
|
-
export declare const getGenerateUploadInstructions: ({ access, client, }: Args) => GenerateUploadInstructions;
|
|
17
|
+
export declare const getGenerateUploadInstructions: ({ access, client, collectionPrefix, }: Args) => GenerateUploadInstructions;
|
|
14
18
|
export {};
|