@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,7 +1,8 @@
|
|
|
1
1
|
import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
|
|
2
2
|
import { lexicalEditor } from '@payloadcms/richtext-lexical';
|
|
3
3
|
import { buildConfig as payloadBuildConfig } from 'payload';
|
|
4
|
-
import {
|
|
4
|
+
import { deepMergeSimple } from 'payload/shared';
|
|
5
|
+
import { getBootstrapInfo, getEnvironmentVariableByName } from '../api/control-plane.js';
|
|
5
6
|
import { getValidCredential } from '../auth/oauth-flow.js';
|
|
6
7
|
import { getTokenStore } from '../auth/token-store.js';
|
|
7
8
|
import { getEnvConfig } from '../constants.js';
|
|
@@ -10,14 +11,19 @@ import { scheduleExtractPlugin } from '../deploy/schedule-extract-plugin.js';
|
|
|
10
11
|
import { health } from '../endpoints/health.js';
|
|
11
12
|
import { schema } from '../endpoints/schema.js';
|
|
12
13
|
import { oAuth2Plugin } from '../oauth/index.js';
|
|
14
|
+
import { getAdminCollectionSlug } from '../oauth/utilities/getAdminCollectionSlug.js';
|
|
13
15
|
import { createStorageClient } from '../storage-content-api/client.js';
|
|
14
16
|
import { contentApiStorageAdapter } from '../storage-content-api/index.js';
|
|
17
|
+
import { translations as figmaTranslations } from '../translations/index.js';
|
|
15
18
|
import { cacheAllEnvironments } from '../utils/cache-bootstrap.js';
|
|
16
|
-
import { getEnvVarSync } from '../utils/env-management.js';
|
|
19
|
+
import { getEnvVarSync, getParsedEnvVarSync } from '../utils/env-management.js';
|
|
17
20
|
import * as log from '../utils/log.js';
|
|
18
21
|
import { logMissingCliAuth } from './auth-preflight.js';
|
|
19
22
|
import { logMissingContentSystemId } from './bootstrap-preflight.js';
|
|
23
|
+
import { createCacheRevalidationHooksPlugin } from './cache-revalidation-hooks.js';
|
|
24
|
+
import { LIMIT_REACHED_VIEW_KEY, LIMIT_REACHED_VIEW_PATH } from './cloud-limits/routes.js';
|
|
20
25
|
import { getDevCookieNames } from './dev-cookie-names.js';
|
|
26
|
+
import { passesMakeViewerWriteGate, withMakeViewerWriteBaseAccessDefaults } from './make-permission-access/make-permission-access.js';
|
|
21
27
|
import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
|
|
22
28
|
/**
|
|
23
29
|
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
@@ -28,7 +34,7 @@ import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
|
|
|
28
34
|
* KEEP_IN_SYNC(cloudflare/wrangler/sites-worker/src/auth.ts): FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER
|
|
29
35
|
*/ export const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = 'figma-internal-forwarded-has-auth-bypass';
|
|
30
36
|
/**
|
|
31
|
-
* Fields added to
|
|
37
|
+
* Fields added to the configured Payload Admin collection for Figma profile info
|
|
32
38
|
*/ const figmaUserFields = [
|
|
33
39
|
{
|
|
34
40
|
name: 'figmaHandle',
|
|
@@ -161,28 +167,132 @@ function missingOAuthCredential(name) {
|
|
|
161
167
|
ok: true
|
|
162
168
|
};
|
|
163
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Project + environment named in process.env or .env. Uses getEnvVarSync because Next.js
|
|
172
|
+
* evaluates config before dotenv populates process.env.
|
|
173
|
+
*/ function readProjectScope() {
|
|
174
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
175
|
+
const environmentName = process.env.FIGMA_ENVIRONMENT_NAME ?? getEnvVarSync(process.cwd(), 'FIGMA_ENVIRONMENT_NAME');
|
|
176
|
+
if (!projectId || !environmentName) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
environmentName,
|
|
181
|
+
projectId
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function readCachedBootstrapData() {
|
|
185
|
+
const scope = readProjectScope();
|
|
186
|
+
return scope ? getTokenStore().getBootstrapData(scope.projectId, scope.environmentName) : null;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Resolve the Content API base URL: FIGMA_CONTENT_API_URL (injected in deployed environments),
|
|
190
|
+
* then the environment's regional URL from the bootstrap cache. A cached entry without a URL
|
|
191
|
+
* (written before bootstrap returned one) is refreshed from the API, unless this build already
|
|
192
|
+
* fetched bootstrap. Throws when no URL can be resolved.
|
|
193
|
+
*/ async function requireContentApiUrl(args) {
|
|
194
|
+
if (process.env.FIGMA_CONTENT_API_URL) {
|
|
195
|
+
return process.env.FIGMA_CONTENT_API_URL;
|
|
196
|
+
}
|
|
197
|
+
const cached = args.bootstrapData ?? readCachedBootstrapData();
|
|
198
|
+
if (cached?.contentApiUrl) {
|
|
199
|
+
return cached.contentApiUrl;
|
|
200
|
+
}
|
|
201
|
+
const scope = readProjectScope();
|
|
202
|
+
if (!scope) {
|
|
203
|
+
throw new Error('Could not resolve the Content API URL.');
|
|
204
|
+
}
|
|
205
|
+
const message = `Could not resolve the Content API URL for environment "${scope.environmentName}" of project ${scope.projectId}.`;
|
|
206
|
+
if (args.bootstrapFetched) {
|
|
207
|
+
throw new Error(message);
|
|
208
|
+
}
|
|
209
|
+
const resolution = await resolveAndCacheBootstrap(getTokenStore(), scope.projectId, scope.environmentName);
|
|
210
|
+
if (!resolution.ok) {
|
|
211
|
+
throw new Error(`${message} ${describeBootstrapFailure(resolution.reason)}`);
|
|
212
|
+
}
|
|
213
|
+
if (!resolution.data.contentApiUrl) {
|
|
214
|
+
throw new Error(message);
|
|
215
|
+
}
|
|
216
|
+
return resolution.data.contentApiUrl;
|
|
217
|
+
}
|
|
218
|
+
function describeBootstrapFailure(reason) {
|
|
219
|
+
switch(reason.kind){
|
|
220
|
+
case 'environment-not-found':
|
|
221
|
+
return 'Fetching bootstrap data failed: environment not found.';
|
|
222
|
+
case 'network':
|
|
223
|
+
return `Fetching bootstrap data failed: ${reason.message}`;
|
|
224
|
+
case 'unauthenticated':
|
|
225
|
+
return 'Fetching bootstrap data failed: not logged in.';
|
|
226
|
+
}
|
|
227
|
+
}
|
|
164
228
|
function messageOf(error) {
|
|
165
229
|
return error instanceof Error ? error.message : 'Unknown error';
|
|
166
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Local-dev fallback: if the tenant config didn't supply a secret (usually
|
|
233
|
+
* because process.env.PAYLOAD_SECRET is unset), try the TokenStore cache,
|
|
234
|
+
* then fetch from the Control Plane. Skipped in Lambda — the platform
|
|
235
|
+
* injects PAYLOAD_SECRET as an env var there, and TokenStore throws in AWS.
|
|
236
|
+
* Returns undefined if we can't resolve one; the caller lets payload.init()
|
|
237
|
+
* throw its own error.
|
|
238
|
+
*/ async function resolvePayloadSecretForRuntime(store, projectId, environmentName, tenantInstanceId) {
|
|
239
|
+
const cached = store.getPayloadSecret({
|
|
240
|
+
projectInfo: {
|
|
241
|
+
environmentName,
|
|
242
|
+
projectId
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
if (cached) {
|
|
246
|
+
return cached;
|
|
247
|
+
}
|
|
248
|
+
let credential;
|
|
249
|
+
try {
|
|
250
|
+
credential = await getValidCredential(store);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
log.debug(`PAYLOAD_SECRET fetch skipped: ${messageOf(error)}`);
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
if (!credential) {
|
|
256
|
+
log.debug('PAYLOAD_SECRET fetch skipped: no cached CLI credential');
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const secret = await getEnvironmentVariableByName(credential, tenantInstanceId, 'PAYLOAD_SECRET');
|
|
261
|
+
store.setPayloadSecret({
|
|
262
|
+
projectInfo: {
|
|
263
|
+
environmentName,
|
|
264
|
+
projectId
|
|
265
|
+
},
|
|
266
|
+
secret
|
|
267
|
+
});
|
|
268
|
+
return secret;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
log.debug(`PAYLOAD_SECRET fetch failed: ${messageOf(error)}`);
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
167
274
|
/**
|
|
168
275
|
* Creates storage configuration for upload collections
|
|
169
|
-
*/ function createStorageConfig(url, contentSystemId) {
|
|
170
|
-
const storageConfig =
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
276
|
+
*/ function createStorageConfig(url, contentSystemId, uploadInstructionsAccess) {
|
|
277
|
+
const storageConfig = {
|
|
278
|
+
...process.env.FIGMA_CONTENT_API_ACCESS_KEY ? {
|
|
279
|
+
baseUrl: url,
|
|
280
|
+
contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY
|
|
281
|
+
} : process.env.FIGMA_DEV_JWT === 'true' ? {
|
|
282
|
+
auth: {
|
|
283
|
+
mode: 'devJwt'
|
|
284
|
+
},
|
|
285
|
+
baseUrl: url,
|
|
286
|
+
contentSystemId
|
|
287
|
+
} : {
|
|
288
|
+
auth: {
|
|
289
|
+
mode: 'tokenStore',
|
|
290
|
+
tokenStore: getTokenStore()
|
|
291
|
+
},
|
|
292
|
+
baseUrl: url,
|
|
293
|
+
contentSystemId
|
|
183
294
|
},
|
|
184
|
-
|
|
185
|
-
contentSystemId
|
|
295
|
+
uploadInstructionsAccess
|
|
186
296
|
};
|
|
187
297
|
const adapter = contentApiStorageAdapter(storageConfig);
|
|
188
298
|
const storageClient = createStorageClient(storageConfig);
|
|
@@ -194,13 +304,13 @@ function messageOf(error) {
|
|
|
194
304
|
/**
|
|
195
305
|
* Plugin that applies cloud storage configuration to all upload-enabled collections.
|
|
196
306
|
* Runs at the end of the plugin chain so it sees collections added by user plugins too.
|
|
197
|
-
*/ function createStoragePlugin(url, contentSystemId) {
|
|
307
|
+
*/ function createStoragePlugin(url, contentSystemId, uploadInstructionsAccess) {
|
|
198
308
|
return (incomingConfig)=>{
|
|
199
309
|
const uploadCollections = (incomingConfig.collections || []).filter((c)=>c.upload);
|
|
200
310
|
if (uploadCollections.length === 0) {
|
|
201
311
|
return incomingConfig;
|
|
202
312
|
}
|
|
203
|
-
const { adapter } = createStorageConfig(url, contentSystemId);
|
|
313
|
+
const { adapter } = createStorageConfig(url, contentSystemId, uploadInstructionsAccess);
|
|
204
314
|
const collectionsMap = uploadCollections.reduce((acc, c)=>{
|
|
205
315
|
acc[c.slug] = {
|
|
206
316
|
adapter,
|
|
@@ -221,21 +331,22 @@ export async function buildFigmaConfig(config) {
|
|
|
221
331
|
let environmentId = config.figma.environmentId ?? process.env.FIGMA_EID;
|
|
222
332
|
contentSystemId ??= process.env.FIGMA_CONTENT_API_CONTENT_SYSTEM_ID;
|
|
223
333
|
let bootstrapData = null;
|
|
334
|
+
let bootstrapFetched = false;
|
|
224
335
|
let bootstrapReason = null;
|
|
225
336
|
// Local dev: resolve from project ID + bootstrap cache
|
|
226
|
-
// Use getEnvVarSync fallback because Next.js evaluates config before dotenv populates process.env
|
|
227
337
|
if (!contentSystemId) {
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
if (!projectId || !environmentName) {
|
|
338
|
+
const scope = readProjectScope();
|
|
339
|
+
if (!scope) {
|
|
231
340
|
bootstrapReason = {
|
|
232
341
|
kind: 'no-config'
|
|
233
342
|
};
|
|
234
343
|
} else {
|
|
344
|
+
const { environmentName, projectId } = scope;
|
|
235
345
|
const store = getTokenStore();
|
|
236
346
|
bootstrapData = store.getBootstrapData(projectId, environmentName);
|
|
237
347
|
// Runtime fallback: fetch from API if not cached (e.g. environment switch without re-init)
|
|
238
348
|
if (!bootstrapData) {
|
|
349
|
+
bootstrapFetched = true;
|
|
239
350
|
const resolution = await resolveAndCacheBootstrap(store, projectId, environmentName);
|
|
240
351
|
if (resolution.ok) {
|
|
241
352
|
bootstrapData = resolution.data;
|
|
@@ -250,12 +361,8 @@ export async function buildFigmaConfig(config) {
|
|
|
250
361
|
}
|
|
251
362
|
}
|
|
252
363
|
if (!environmentId) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (projectId && environmentName) {
|
|
256
|
-
bootstrapData ??= getTokenStore().getBootstrapData(projectId, environmentName);
|
|
257
|
-
environmentId = bootstrapData?.tenantInstanceId;
|
|
258
|
-
}
|
|
364
|
+
bootstrapData ??= readCachedBootstrapData();
|
|
365
|
+
environmentId = bootstrapData?.tenantInstanceId;
|
|
259
366
|
}
|
|
260
367
|
if (!environmentId) {
|
|
261
368
|
throw new Error('Environment ID could not be resolved. Set FIGMA_EID or initialize the project.');
|
|
@@ -266,7 +373,13 @@ export async function buildFigmaConfig(config) {
|
|
|
266
373
|
});
|
|
267
374
|
throw new Error('Content System ID could not be resolved. ' + 'Run `npx @payloadcms/figma init` to set up your project.');
|
|
268
375
|
}
|
|
269
|
-
|
|
376
|
+
// Only the content-system db adapter and cloud storage call the Content API, so a project on a
|
|
377
|
+
// custom db with storage disabled needs no URL; `url` stays '' and is unused in that case.
|
|
378
|
+
const usesContentSystem = config.figma.useContentSystem !== false;
|
|
379
|
+
const url = usesContentSystem || config.figma.storage !== false ? await requireContentApiUrl({
|
|
380
|
+
bootstrapData,
|
|
381
|
+
bootstrapFetched
|
|
382
|
+
}) : '';
|
|
270
383
|
const isProduction = process.env.NODE_ENV === 'production';
|
|
271
384
|
// The deployed Lambda runs all queued jobs; locally there is no runner, so the db adapter logs
|
|
272
385
|
// a heads-up whenever a job is queued. Deployed environments set DISABLE_LOCAL_JOB_QUEUE_NOTIFICATIONS=true
|
|
@@ -278,7 +391,7 @@ export async function buildFigmaConfig(config) {
|
|
|
278
391
|
}
|
|
279
392
|
// Determine database adapter based on environment
|
|
280
393
|
let db;
|
|
281
|
-
if (
|
|
394
|
+
if (!usesContentSystem) {
|
|
282
395
|
db = config.db;
|
|
283
396
|
} else if (process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
284
397
|
db = contentAPIAdapter({
|
|
@@ -314,7 +427,31 @@ export async function buildFigmaConfig(config) {
|
|
|
314
427
|
});
|
|
315
428
|
}
|
|
316
429
|
const userJobsAccessRun = config.jobs?.access?.run;
|
|
317
|
-
|
|
430
|
+
const adminCollectionSlug = getAdminCollectionSlug(config);
|
|
431
|
+
// Hosted runtimes inject the Content API key and PAYLOAD_SECRET together, so
|
|
432
|
+
// the process env is authoritative. Ordinary local dev still checks the
|
|
433
|
+
// TokenStore first so a leftover .env value cannot shadow the platform secret.
|
|
434
|
+
let resolvedSecret;
|
|
435
|
+
if (process.env.AWS_EXECUTION_ENV || process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
436
|
+
resolvedSecret = process.env.PAYLOAD_SECRET;
|
|
437
|
+
} else {
|
|
438
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
439
|
+
const environmentName = process.env.FIGMA_ENVIRONMENT_NAME ?? getEnvVarSync(process.cwd(), 'FIGMA_ENVIRONMENT_NAME');
|
|
440
|
+
if (projectId && environmentName && environmentId) {
|
|
441
|
+
resolvedSecret = await resolvePayloadSecretForRuntime(getTokenStore(), projectId, environmentName, environmentId);
|
|
442
|
+
}
|
|
443
|
+
if (!resolvedSecret) {
|
|
444
|
+
// Config may be evaluated before the framework loads dotenv. Parse the
|
|
445
|
+
// file without mutating process.env, preserving quotes/comments correctly.
|
|
446
|
+
resolvedSecret = process.env.PAYLOAD_SECRET || getParsedEnvVarSync(process.cwd(), 'PAYLOAD_SECRET') || undefined;
|
|
447
|
+
if (resolvedSecret) {
|
|
448
|
+
log.warning('Using a local PAYLOAD_SECRET fallback because the platform secret could not be resolved. ' + 'It may differ from the deployed secret. Run `npx @payloadcms/figma init --id <project-id> --force` to refresh it.');
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
// Build complete config with Figma platform defaults.
|
|
453
|
+
// `secret` may be undefined here; payload.init() enforces its presence at
|
|
454
|
+
// runtime, so we relax the intermediate type instead of forging a default.
|
|
318
455
|
const configWithFigmaDefaults = {
|
|
319
456
|
...config,
|
|
320
457
|
admin: {
|
|
@@ -323,11 +460,24 @@ export async function buildFigmaConfig(config) {
|
|
|
323
460
|
avatar: {
|
|
324
461
|
Component: '@payloadcms/figma/client#FigmaAvatar'
|
|
325
462
|
},
|
|
326
|
-
...config.admin
|
|
463
|
+
...config.admin,
|
|
464
|
+
components: {
|
|
465
|
+
...config.admin?.components,
|
|
466
|
+
providers: [
|
|
467
|
+
...config.admin?.components?.providers ?? [],
|
|
468
|
+
'@payloadcms/figma/client#FigmaCloudLimitProvider'
|
|
469
|
+
]
|
|
470
|
+
}
|
|
327
471
|
},
|
|
472
|
+
// Payload applies this policy during sanitization, after user plugins and
|
|
473
|
+
// generated resources have registered their collections and globals.
|
|
474
|
+
baseAccess: withMakeViewerWriteBaseAccessDefaults(config.baseAccess),
|
|
328
475
|
custom: {
|
|
329
476
|
figma: {
|
|
330
477
|
...config.figma,
|
|
478
|
+
...typeof config.figma.storage === 'object' ? {
|
|
479
|
+
storage: true
|
|
480
|
+
} : {},
|
|
331
481
|
contentSystemId,
|
|
332
482
|
environmentId
|
|
333
483
|
}
|
|
@@ -339,10 +489,15 @@ export async function buildFigmaConfig(config) {
|
|
|
339
489
|
health,
|
|
340
490
|
schema
|
|
341
491
|
],
|
|
492
|
+
i18n: {
|
|
493
|
+
...config.i18n,
|
|
494
|
+
translations: deepMergeSimple(figmaTranslations, config.i18n?.translations ?? {})
|
|
495
|
+
},
|
|
496
|
+
secret: resolvedSecret,
|
|
342
497
|
// Gate /api/payload-jobs/run and /api/payload-jobs/handle-schedules. Honor the
|
|
343
498
|
// sites-worker trust marker so Figma infra job runs never break, defer to the
|
|
344
|
-
// tenant's jobs.access.run if they set one, otherwise
|
|
345
|
-
//
|
|
499
|
+
// tenant's jobs.access.run if they set one, otherwise require an authenticated
|
|
500
|
+
// user who is not a known Make viewer.
|
|
346
501
|
jobs: {
|
|
347
502
|
...config.jobs ?? {},
|
|
348
503
|
access: {
|
|
@@ -354,26 +509,42 @@ export async function buildFigmaConfig(config) {
|
|
|
354
509
|
if (userJobsAccessRun) {
|
|
355
510
|
return userJobsAccessRun(args);
|
|
356
511
|
}
|
|
357
|
-
|
|
512
|
+
// Allow undefined Make permissions during rollout, but fail closed for empty,
|
|
513
|
+
// explicit view, and other unrecognized values.
|
|
514
|
+
return Boolean(args.req.user) && passesMakeViewerWriteGate(args.req.user);
|
|
358
515
|
}
|
|
359
|
-
}
|
|
516
|
+
},
|
|
517
|
+
// Remove Payload's default read/write denials so the jobs collection uses
|
|
518
|
+
// the standard access defaults and baseAccess Make-permission write gate.
|
|
519
|
+
// Preserve tenant-supplied overrides; jobs.access.run separately controls
|
|
520
|
+
// the job execution endpoints.
|
|
521
|
+
jobsCollectionOverrides: config.jobs?.jobsCollectionOverrides ?? (({ defaultJobsCollection })=>{
|
|
522
|
+
const { access: _access, ...rest } = defaultJobsCollection;
|
|
523
|
+
return rest;
|
|
524
|
+
})
|
|
360
525
|
},
|
|
361
526
|
...isProduction && !config.logger ? {
|
|
362
527
|
logger: {
|
|
363
528
|
options: {}
|
|
364
529
|
}
|
|
365
530
|
} : {},
|
|
366
|
-
|
|
531
|
+
// The platform owns rotation of PAYLOAD_SECRET; this compat entry lets
|
|
532
|
+
// data encrypted under the old shared hosted secret keep decrypting.
|
|
533
|
+
// Appended last so any tenant-supplied previousSecrets are honored first.
|
|
534
|
+
previousSecrets: [
|
|
535
|
+
...config.previousSecrets ?? [],
|
|
536
|
+
Buffer.from('TVlfU0VDUkVU', 'base64').toString('utf8')
|
|
537
|
+
],
|
|
367
538
|
// Add oauth to plugins if not already present
|
|
368
539
|
plugins: [
|
|
369
540
|
...config.plugins ?? [],
|
|
370
541
|
...config.figma.storage !== false ? [
|
|
371
|
-
createStoragePlugin(url, contentSystemId)
|
|
542
|
+
createStoragePlugin(url, contentSystemId, typeof config.figma.storage === 'object' ? config.figma.storage.uploadInstructionsAccess : undefined)
|
|
372
543
|
] : [],
|
|
373
544
|
oAuth2Plugin({
|
|
374
545
|
collections: [
|
|
375
546
|
{
|
|
376
|
-
slug:
|
|
547
|
+
slug: adminCollectionSlug,
|
|
377
548
|
// Use adapter because Figma app doesn't support OIDC scopes
|
|
378
549
|
authorizationURLParams: {
|
|
379
550
|
response_mode: 'query',
|
|
@@ -394,23 +565,53 @@ export async function buildFigmaConfig(config) {
|
|
|
394
565
|
disabled: false
|
|
395
566
|
}),
|
|
396
567
|
scheduleExtractPlugin(),
|
|
397
|
-
// Not folded into createStoragePlugin
|
|
398
|
-
// figma.storage is false
|
|
399
|
-
createSandboxUploadFetchPlugin(
|
|
568
|
+
// Not folded into createStoragePlugin, which is skipped when
|
|
569
|
+
// figma.storage is false and would break remote uploads for those apps.
|
|
570
|
+
createSandboxUploadFetchPlugin({
|
|
571
|
+
userCollections: config.collections
|
|
572
|
+
}),
|
|
573
|
+
// Keep last so hooks added by app plugins also get the missing Next cache
|
|
574
|
+
// context guard used by Payload CLI operations in the Make sandbox.
|
|
575
|
+
createCacheRevalidationHooksPlugin()
|
|
400
576
|
]
|
|
401
577
|
};
|
|
402
|
-
// Inject
|
|
578
|
+
// Inject Figma-managed identity fields only into the Payload Admin collection.
|
|
403
579
|
const collections = configWithFigmaDefaults.collections?.map((col)=>{
|
|
404
|
-
|
|
580
|
+
const views = col.admin?.components?.views;
|
|
581
|
+
const withLimitView = usesContentSystem ? {
|
|
582
|
+
...col,
|
|
583
|
+
admin: {
|
|
584
|
+
...col.admin,
|
|
585
|
+
components: {
|
|
586
|
+
...col.admin?.components,
|
|
587
|
+
edit: {
|
|
588
|
+
...col.admin?.components?.edit,
|
|
589
|
+
beforeDocumentControls: [
|
|
590
|
+
'@payloadcms/figma/client#FigmaCloudLimitSlugTracker',
|
|
591
|
+
...col.admin?.components?.edit?.beforeDocumentControls ?? []
|
|
592
|
+
]
|
|
593
|
+
},
|
|
594
|
+
views: {
|
|
595
|
+
...views,
|
|
596
|
+
[LIMIT_REACHED_VIEW_KEY]: {
|
|
597
|
+
Component: '@payloadcms/figma/views#LimitReachedView',
|
|
598
|
+
exact: true,
|
|
599
|
+
path: LIMIT_REACHED_VIEW_PATH
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
} : col;
|
|
605
|
+
if (col.slug === adminCollectionSlug) {
|
|
405
606
|
return {
|
|
406
|
-
...
|
|
607
|
+
...withLimitView,
|
|
407
608
|
fields: [
|
|
408
609
|
...col.fields || [],
|
|
409
610
|
...figmaUserFields
|
|
410
611
|
]
|
|
411
612
|
};
|
|
412
613
|
}
|
|
413
|
-
return
|
|
614
|
+
return withLimitView;
|
|
414
615
|
});
|
|
415
616
|
if (collections) {
|
|
416
617
|
configWithFigmaDefaults.collections = collections;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Prevent Next cache invalidation from turning a successful Payload mutation
|
|
4
|
+
* into an apparent failure when the mutation runs outside a Next request.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createCacheRevalidationHooksPlugin(): Plugin;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const missingNextCacheContext = /^Invariant: static generation store missing in (?:revalidateTag|revalidatePath|updateTag)\b/;
|
|
2
|
+
const unsupportedUpdateTagContext = /^updateTag can only be called from within a Server Action\./;
|
|
3
|
+
/**
|
|
4
|
+
* Next cache invalidation requires request-scoped state. Payload's Local API has
|
|
5
|
+
* no Next request when it runs from the CLI in a Make sandbox, so Next throws
|
|
6
|
+
* after the database write has already committed. Treat only that missing-
|
|
7
|
+
* context error as a no-op; cache invalidation still runs normally in a Next
|
|
8
|
+
* request, and all other hook failures retain their existing behavior.
|
|
9
|
+
*/ function isUnsupportedNextCacheContextError(error) {
|
|
10
|
+
if (!(error instanceof Error)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const errorCode = error.__NEXT_ERROR_CODE;
|
|
14
|
+
if (missingNextCacheContext.test(error.message)) {
|
|
15
|
+
return errorCode === undefined || errorCode === 'E263';
|
|
16
|
+
}
|
|
17
|
+
if (unsupportedUpdateTagContext.test(error.message)) {
|
|
18
|
+
return errorCode === undefined || errorCode === 'E872';
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
function reportIgnoredRevalidation(args, hookName) {
|
|
23
|
+
const hookArgs = args[0];
|
|
24
|
+
hookArgs?.req?.payload?.logger?.warn({
|
|
25
|
+
hook: hookName,
|
|
26
|
+
msg: 'Ignored Next cache invalidation outside a supported request context'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function wrapHook(hook, hookName) {
|
|
30
|
+
return async (...args)=>{
|
|
31
|
+
try {
|
|
32
|
+
return await hook(...args);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (isUnsupportedNextCacheContextError(error)) {
|
|
35
|
+
reportIgnoredRevalidation(args, hookName);
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function wrapHooks(hooks) {
|
|
43
|
+
if (!hooks) {
|
|
44
|
+
return hooks;
|
|
45
|
+
}
|
|
46
|
+
return Object.fromEntries(Object.entries(hooks).map(([name, value])=>[
|
|
47
|
+
name,
|
|
48
|
+
Array.isArray(value) ? value.map((hook)=>typeof hook === 'function' ? wrapHook(hook, name) : hook) : value
|
|
49
|
+
]));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Prevent Next cache invalidation from turning a successful Payload mutation
|
|
53
|
+
* into an apparent failure when the mutation runs outside a Next request.
|
|
54
|
+
*/ export function createCacheRevalidationHooksPlugin() {
|
|
55
|
+
const plugin = (config)=>({
|
|
56
|
+
...config,
|
|
57
|
+
collections: config.collections?.map((collection)=>({
|
|
58
|
+
...collection,
|
|
59
|
+
hooks: wrapHooks(collection.hooks)
|
|
60
|
+
})),
|
|
61
|
+
globals: config.globals?.map((global)=>({
|
|
62
|
+
...global,
|
|
63
|
+
hooks: wrapHooks(global.hooks)
|
|
64
|
+
}))
|
|
65
|
+
});
|
|
66
|
+
// Run after tenant plugins so hooks they add receive the same guard.
|
|
67
|
+
plugin.order = Number.POSITIVE_INFINITY;
|
|
68
|
+
return plugin;
|
|
69
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
type Props = {
|
|
4
|
+
collectionLabel?: string;
|
|
5
|
+
collectionListURL?: string;
|
|
6
|
+
onRetry: () => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function FigmaCloudLimitDocumentCountModal({ collectionLabel, collectionListURL, onRetry, }: Props): ReactElement;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, DialogBody, DialogCancel, DialogFooter, DialogHeader, DialogModal, useModal, useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { ExternalLinkIcon } from '../icons/ExternalLinkIcon.js';
|
|
5
|
+
import { cloudLimitDocumentCountModalSlug } from '../shared.js';
|
|
6
|
+
import './index.scss';
|
|
7
|
+
const baseClass = 'figma-cloud-limit-modal';
|
|
8
|
+
export function FigmaCloudLimitDocumentCountModal({ collectionLabel, collectionListURL, onRetry }) {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const { closeModal } = useModal();
|
|
11
|
+
return /*#__PURE__*/ _jsxs(DialogModal, {
|
|
12
|
+
size: "small",
|
|
13
|
+
slug: cloudLimitDocumentCountModalSlug,
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ _jsx(DialogHeader, {
|
|
16
|
+
showClose: true,
|
|
17
|
+
title: t('figma:cloudLimitModalHeading')
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ _jsx(DialogBody, {
|
|
20
|
+
children: /*#__PURE__*/ _jsx("p", {
|
|
21
|
+
className: `${baseClass}__body`,
|
|
22
|
+
children: t('figma:cloudLimitModalBody')
|
|
23
|
+
})
|
|
24
|
+
}),
|
|
25
|
+
/*#__PURE__*/ _jsx(DialogFooter, {
|
|
26
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
27
|
+
className: `${baseClass}__footer`,
|
|
28
|
+
children: [
|
|
29
|
+
collectionLabel && collectionListURL ? /*#__PURE__*/ _jsxs("a", {
|
|
30
|
+
className: `${baseClass}__review-btn`,
|
|
31
|
+
href: collectionListURL,
|
|
32
|
+
onClick: ()=>closeModal(cloudLimitDocumentCountModalSlug),
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsx("span", {
|
|
35
|
+
className: `${baseClass}__review-btn-label`,
|
|
36
|
+
children: t('figma:cloudLimitModalReviewCollection', {
|
|
37
|
+
collection: collectionLabel
|
|
38
|
+
})
|
|
39
|
+
}),
|
|
40
|
+
/*#__PURE__*/ _jsx(ExternalLinkIcon, {})
|
|
41
|
+
]
|
|
42
|
+
}) : null,
|
|
43
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
44
|
+
className: `${baseClass}__actions`,
|
|
45
|
+
children: [
|
|
46
|
+
/*#__PURE__*/ _jsx(DialogCancel, {
|
|
47
|
+
label: t('figma:cloudLimitModalConfirm')
|
|
48
|
+
}),
|
|
49
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
50
|
+
buttonStyle: "primary",
|
|
51
|
+
margin: false,
|
|
52
|
+
onClick: ()=>{
|
|
53
|
+
closeModal(cloudLimitDocumentCountModalSlug);
|
|
54
|
+
onRetry();
|
|
55
|
+
},
|
|
56
|
+
size: "medium",
|
|
57
|
+
children: t('figma:cloudLimitModalRetry')
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
.figma-cloud-limit-modal {
|
|
2
|
+
&__body {
|
|
3
|
+
margin: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
&__footer {
|
|
7
|
+
align-items: center;
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: var(--spacer-4);
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&__review-btn {
|
|
14
|
+
align-items: center;
|
|
15
|
+
background: none;
|
|
16
|
+
border: none;
|
|
17
|
+
color: var(--color-text-brand);
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
flex-shrink: 1;
|
|
21
|
+
font-size: var(--text-body-medium-font-size);
|
|
22
|
+
gap: var(--spacer-1);
|
|
23
|
+
min-width: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
|
|
26
|
+
.btn__content,
|
|
27
|
+
.btn__label {
|
|
28
|
+
min-width: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&:hover {
|
|
32
|
+
color: var(--ramp-blue-700);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&:active {
|
|
36
|
+
color: var(--ramp-blue-800);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__review-btn-label {
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Prevents the icon from shrinking when the label ellipses.
|
|
47
|
+
&__review-btn svg {
|
|
48
|
+
flex-shrink: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&__actions {
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: var(--spacer-2);
|
|
54
|
+
margin-inline-start: auto;
|
|
55
|
+
}
|
|
56
|
+
}
|