@payloadcms/figma 0.1.0-alpha.1 → 0.1.0-alpha.11
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 +10 -9
- package/dist/api/control-plane.js +27 -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 +69 -0
- package/dist/auth/oauth-flow.d.ts +2 -0
- package/dist/auth/oauth-flow.js +13 -8
- package/dist/auth/token-store.d.ts +20 -1
- package/dist/auth/token-store.js +47 -0
- package/dist/auth/types.d.ts +12 -0
- package/dist/cli.d.ts +39 -0
- package/dist/cli.js +71 -36
- package/dist/commands/bootstrap.js +2 -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/write-project-configuration.d.ts +12 -0
- package/dist/commands/write-project-configuration.js +16 -0
- 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 +181 -36
- 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 +32 -0
- package/dist/plugin/sandbox-upload-fetch.js +53 -0
- 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 +3 -0
- 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.js +2 -1
- 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/hasSupportedContentEncoding.d.ts +1 -0
- package/dist/storage-content-api/hasSupportedContentEncoding.js +6 -0
- package/dist/storage-content-api/index.js +1 -0
- 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.js +93 -25
- package/dist/storage-content-api/types.d.ts +4 -1
- 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/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/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.js +5 -2
- 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 -7
- package/dist/lib/download-skill.d.ts +0 -12
- package/dist/lib/download-skill.js +0 -77
- 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,20 @@ 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';
|
|
27
|
+
import { createSandboxUploadFetchPlugin } from './sandbox-upload-fetch.js';
|
|
21
28
|
/**
|
|
22
29
|
* Worker-trusted marker injected by Figma's sites-worker after it validates the
|
|
23
30
|
* X-Figma-Job-Queues-Auth-Bypass secret on a Payload jobs endpoint. The default
|
|
@@ -27,7 +34,7 @@ import { getDevCookieNames } from './dev-cookie-names.js';
|
|
|
27
34
|
* KEEP_IN_SYNC(cloudflare/wrangler/sites-worker/src/auth.ts): FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER
|
|
28
35
|
*/ export const FIGMA_INTERNAL_FORWARDED_HAS_AUTH_BYPASS_HEADER = 'figma-internal-forwarded-has-auth-bypass';
|
|
29
36
|
/**
|
|
30
|
-
* Fields added to
|
|
37
|
+
* Fields added to the configured Payload Admin collection for Figma profile info
|
|
31
38
|
*/ const figmaUserFields = [
|
|
32
39
|
{
|
|
33
40
|
name: 'figmaHandle',
|
|
@@ -163,25 +170,71 @@ function missingOAuthCredential(name) {
|
|
|
163
170
|
function messageOf(error) {
|
|
164
171
|
return error instanceof Error ? error.message : 'Unknown error';
|
|
165
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Local-dev fallback: if the tenant config didn't supply a secret (usually
|
|
175
|
+
* because process.env.PAYLOAD_SECRET is unset), try the TokenStore cache,
|
|
176
|
+
* then fetch from the Control Plane. Skipped in Lambda — the platform
|
|
177
|
+
* injects PAYLOAD_SECRET as an env var there, and TokenStore throws in AWS.
|
|
178
|
+
* Returns undefined if we can't resolve one; the caller lets payload.init()
|
|
179
|
+
* throw its own error.
|
|
180
|
+
*/ async function resolvePayloadSecretForRuntime(store, projectId, environmentName, tenantInstanceId) {
|
|
181
|
+
const cached = store.getPayloadSecret({
|
|
182
|
+
projectInfo: {
|
|
183
|
+
environmentName,
|
|
184
|
+
projectId
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
if (cached) {
|
|
188
|
+
return cached;
|
|
189
|
+
}
|
|
190
|
+
let credential;
|
|
191
|
+
try {
|
|
192
|
+
credential = await getValidCredential(store);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
log.debug(`PAYLOAD_SECRET fetch skipped: ${messageOf(error)}`);
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
if (!credential) {
|
|
198
|
+
log.debug('PAYLOAD_SECRET fetch skipped: no cached CLI credential');
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
const secret = await getEnvironmentVariableByName(credential, tenantInstanceId, 'PAYLOAD_SECRET');
|
|
203
|
+
store.setPayloadSecret({
|
|
204
|
+
projectInfo: {
|
|
205
|
+
environmentName,
|
|
206
|
+
projectId
|
|
207
|
+
},
|
|
208
|
+
secret
|
|
209
|
+
});
|
|
210
|
+
return secret;
|
|
211
|
+
} catch (error) {
|
|
212
|
+
log.debug(`PAYLOAD_SECRET fetch failed: ${messageOf(error)}`);
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
166
216
|
/**
|
|
167
217
|
* Creates storage configuration for upload collections
|
|
168
|
-
*/ function createStorageConfig(url, contentSystemId) {
|
|
169
|
-
const storageConfig =
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
218
|
+
*/ function createStorageConfig(url, contentSystemId, uploadInstructionsAccess) {
|
|
219
|
+
const storageConfig = {
|
|
220
|
+
...process.env.FIGMA_CONTENT_API_ACCESS_KEY ? {
|
|
221
|
+
baseUrl: url,
|
|
222
|
+
contentApiKey: process.env.FIGMA_CONTENT_API_ACCESS_KEY
|
|
223
|
+
} : process.env.FIGMA_DEV_JWT === 'true' ? {
|
|
224
|
+
auth: {
|
|
225
|
+
mode: 'devJwt'
|
|
226
|
+
},
|
|
227
|
+
baseUrl: url,
|
|
228
|
+
contentSystemId
|
|
229
|
+
} : {
|
|
230
|
+
auth: {
|
|
231
|
+
mode: 'tokenStore',
|
|
232
|
+
tokenStore: getTokenStore()
|
|
233
|
+
},
|
|
234
|
+
baseUrl: url,
|
|
235
|
+
contentSystemId
|
|
182
236
|
},
|
|
183
|
-
|
|
184
|
-
contentSystemId
|
|
237
|
+
uploadInstructionsAccess
|
|
185
238
|
};
|
|
186
239
|
const adapter = contentApiStorageAdapter(storageConfig);
|
|
187
240
|
const storageClient = createStorageClient(storageConfig);
|
|
@@ -193,13 +246,13 @@ function messageOf(error) {
|
|
|
193
246
|
/**
|
|
194
247
|
* Plugin that applies cloud storage configuration to all upload-enabled collections.
|
|
195
248
|
* Runs at the end of the plugin chain so it sees collections added by user plugins too.
|
|
196
|
-
*/ function createStoragePlugin(url, contentSystemId) {
|
|
249
|
+
*/ function createStoragePlugin(url, contentSystemId, uploadInstructionsAccess) {
|
|
197
250
|
return (incomingConfig)=>{
|
|
198
251
|
const uploadCollections = (incomingConfig.collections || []).filter((c)=>c.upload);
|
|
199
252
|
if (uploadCollections.length === 0) {
|
|
200
253
|
return incomingConfig;
|
|
201
254
|
}
|
|
202
|
-
const { adapter } = createStorageConfig(url, contentSystemId);
|
|
255
|
+
const { adapter } = createStorageConfig(url, contentSystemId, uploadInstructionsAccess);
|
|
203
256
|
const collectionsMap = uploadCollections.reduce((acc, c)=>{
|
|
204
257
|
acc[c.slug] = {
|
|
205
258
|
adapter,
|
|
@@ -277,7 +330,8 @@ export async function buildFigmaConfig(config) {
|
|
|
277
330
|
}
|
|
278
331
|
// Determine database adapter based on environment
|
|
279
332
|
let db;
|
|
280
|
-
|
|
333
|
+
const usesContentSystem = config.figma.useContentSystem !== false;
|
|
334
|
+
if (!usesContentSystem) {
|
|
281
335
|
db = config.db;
|
|
282
336
|
} else if (process.env.FIGMA_CONTENT_API_ACCESS_KEY) {
|
|
283
337
|
db = contentAPIAdapter({
|
|
@@ -313,7 +367,31 @@ export async function buildFigmaConfig(config) {
|
|
|
313
367
|
});
|
|
314
368
|
}
|
|
315
369
|
const userJobsAccessRun = config.jobs?.access?.run;
|
|
316
|
-
|
|
370
|
+
const adminCollectionSlug = getAdminCollectionSlug(config);
|
|
371
|
+
// Lambda: env var is authoritative (TokenStore unusable in AWS). Local:
|
|
372
|
+
// TokenStore first so a leftover .env value can't shadow the platform
|
|
373
|
+
// secret; env var is only a last-resort fallback.
|
|
374
|
+
let resolvedSecret;
|
|
375
|
+
if (process.env.AWS_EXECUTION_ENV) {
|
|
376
|
+
resolvedSecret = process.env.PAYLOAD_SECRET;
|
|
377
|
+
} else {
|
|
378
|
+
const projectId = process.env.FIGMA_PROJECT_ID ?? getEnvVarSync(process.cwd(), 'FIGMA_PROJECT_ID');
|
|
379
|
+
const environmentName = process.env.FIGMA_ENVIRONMENT_NAME ?? getEnvVarSync(process.cwd(), 'FIGMA_ENVIRONMENT_NAME');
|
|
380
|
+
if (projectId && environmentName && environmentId) {
|
|
381
|
+
resolvedSecret = await resolvePayloadSecretForRuntime(getTokenStore(), projectId, environmentName, environmentId);
|
|
382
|
+
}
|
|
383
|
+
if (!resolvedSecret) {
|
|
384
|
+
// Config may be evaluated before the framework loads dotenv. Parse the
|
|
385
|
+
// file without mutating process.env, preserving quotes/comments correctly.
|
|
386
|
+
resolvedSecret = process.env.PAYLOAD_SECRET || getParsedEnvVarSync(process.cwd(), 'PAYLOAD_SECRET') || undefined;
|
|
387
|
+
if (resolvedSecret) {
|
|
388
|
+
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.');
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Build complete config with Figma platform defaults.
|
|
393
|
+
// `secret` may be undefined here; payload.init() enforces its presence at
|
|
394
|
+
// runtime, so we relax the intermediate type instead of forging a default.
|
|
317
395
|
const configWithFigmaDefaults = {
|
|
318
396
|
...config,
|
|
319
397
|
admin: {
|
|
@@ -322,11 +400,24 @@ export async function buildFigmaConfig(config) {
|
|
|
322
400
|
avatar: {
|
|
323
401
|
Component: '@payloadcms/figma/client#FigmaAvatar'
|
|
324
402
|
},
|
|
325
|
-
...config.admin
|
|
403
|
+
...config.admin,
|
|
404
|
+
components: {
|
|
405
|
+
...config.admin?.components,
|
|
406
|
+
providers: [
|
|
407
|
+
...config.admin?.components?.providers ?? [],
|
|
408
|
+
'@payloadcms/figma/client#FigmaCloudLimitProvider'
|
|
409
|
+
]
|
|
410
|
+
}
|
|
326
411
|
},
|
|
412
|
+
// Payload applies this policy during sanitization, after user plugins and
|
|
413
|
+
// generated resources have registered their collections and globals.
|
|
414
|
+
baseAccess: withMakeViewerWriteBaseAccessDefaults(config.baseAccess),
|
|
327
415
|
custom: {
|
|
328
416
|
figma: {
|
|
329
417
|
...config.figma,
|
|
418
|
+
...typeof config.figma.storage === 'object' ? {
|
|
419
|
+
storage: true
|
|
420
|
+
} : {},
|
|
330
421
|
contentSystemId,
|
|
331
422
|
environmentId
|
|
332
423
|
}
|
|
@@ -338,10 +429,15 @@ export async function buildFigmaConfig(config) {
|
|
|
338
429
|
health,
|
|
339
430
|
schema
|
|
340
431
|
],
|
|
432
|
+
i18n: {
|
|
433
|
+
...config.i18n,
|
|
434
|
+
translations: deepMergeSimple(figmaTranslations, config.i18n?.translations ?? {})
|
|
435
|
+
},
|
|
436
|
+
secret: resolvedSecret,
|
|
341
437
|
// Gate /api/payload-jobs/run and /api/payload-jobs/handle-schedules. Honor the
|
|
342
438
|
// sites-worker trust marker so Figma infra job runs never break, defer to the
|
|
343
|
-
// tenant's jobs.access.run if they set one, otherwise
|
|
344
|
-
//
|
|
439
|
+
// tenant's jobs.access.run if they set one, otherwise require an authenticated
|
|
440
|
+
// user who is not a known Make viewer.
|
|
345
441
|
jobs: {
|
|
346
442
|
...config.jobs ?? {},
|
|
347
443
|
access: {
|
|
@@ -353,26 +449,42 @@ export async function buildFigmaConfig(config) {
|
|
|
353
449
|
if (userJobsAccessRun) {
|
|
354
450
|
return userJobsAccessRun(args);
|
|
355
451
|
}
|
|
356
|
-
|
|
452
|
+
// Allow undefined Make permissions during rollout, but fail closed for empty,
|
|
453
|
+
// explicit view, and other unrecognized values.
|
|
454
|
+
return Boolean(args.req.user) && passesMakeViewerWriteGate(args.req.user);
|
|
357
455
|
}
|
|
358
|
-
}
|
|
456
|
+
},
|
|
457
|
+
// Remove Payload's default read/write denials so the jobs collection uses
|
|
458
|
+
// the standard access defaults and baseAccess Make-permission write gate.
|
|
459
|
+
// Preserve tenant-supplied overrides; jobs.access.run separately controls
|
|
460
|
+
// the job execution endpoints.
|
|
461
|
+
jobsCollectionOverrides: config.jobs?.jobsCollectionOverrides ?? (({ defaultJobsCollection })=>{
|
|
462
|
+
const { access: _access, ...rest } = defaultJobsCollection;
|
|
463
|
+
return rest;
|
|
464
|
+
})
|
|
359
465
|
},
|
|
360
466
|
...isProduction && !config.logger ? {
|
|
361
467
|
logger: {
|
|
362
468
|
options: {}
|
|
363
469
|
}
|
|
364
470
|
} : {},
|
|
365
|
-
|
|
471
|
+
// The platform owns rotation of PAYLOAD_SECRET; this compat entry lets
|
|
472
|
+
// data encrypted under the old shared hosted secret keep decrypting.
|
|
473
|
+
// Appended last so any tenant-supplied previousSecrets are honored first.
|
|
474
|
+
previousSecrets: [
|
|
475
|
+
...config.previousSecrets ?? [],
|
|
476
|
+
Buffer.from('TVlfU0VDUkVU', 'base64').toString('utf8')
|
|
477
|
+
],
|
|
366
478
|
// Add oauth to plugins if not already present
|
|
367
479
|
plugins: [
|
|
368
480
|
...config.plugins ?? [],
|
|
369
481
|
...config.figma.storage !== false ? [
|
|
370
|
-
createStoragePlugin(url, contentSystemId)
|
|
482
|
+
createStoragePlugin(url, contentSystemId, typeof config.figma.storage === 'object' ? config.figma.storage.uploadInstructionsAccess : undefined)
|
|
371
483
|
] : [],
|
|
372
484
|
oAuth2Plugin({
|
|
373
485
|
collections: [
|
|
374
486
|
{
|
|
375
|
-
slug:
|
|
487
|
+
slug: adminCollectionSlug,
|
|
376
488
|
// Use adapter because Figma app doesn't support OIDC scopes
|
|
377
489
|
authorizationURLParams: {
|
|
378
490
|
response_mode: 'query',
|
|
@@ -392,21 +504,54 @@ export async function buildFigmaConfig(config) {
|
|
|
392
504
|
debug: !!process.env.DEBUG,
|
|
393
505
|
disabled: false
|
|
394
506
|
}),
|
|
395
|
-
scheduleExtractPlugin()
|
|
507
|
+
scheduleExtractPlugin(),
|
|
508
|
+
// Not folded into createStoragePlugin, which is skipped when
|
|
509
|
+
// figma.storage is false and would break remote uploads for those apps.
|
|
510
|
+
createSandboxUploadFetchPlugin({
|
|
511
|
+
userCollections: config.collections
|
|
512
|
+
}),
|
|
513
|
+
// Keep last so hooks added by app plugins also get the missing Next cache
|
|
514
|
+
// context guard used by Payload CLI operations in the Make sandbox.
|
|
515
|
+
createCacheRevalidationHooksPlugin()
|
|
396
516
|
]
|
|
397
517
|
};
|
|
398
|
-
// Inject
|
|
518
|
+
// Inject Figma-managed identity fields only into the Payload Admin collection.
|
|
399
519
|
const collections = configWithFigmaDefaults.collections?.map((col)=>{
|
|
400
|
-
|
|
520
|
+
const views = col.admin?.components?.views;
|
|
521
|
+
const withLimitView = usesContentSystem ? {
|
|
522
|
+
...col,
|
|
523
|
+
admin: {
|
|
524
|
+
...col.admin,
|
|
525
|
+
components: {
|
|
526
|
+
...col.admin?.components,
|
|
527
|
+
edit: {
|
|
528
|
+
...col.admin?.components?.edit,
|
|
529
|
+
beforeDocumentControls: [
|
|
530
|
+
'@payloadcms/figma/client#FigmaCloudLimitSlugTracker',
|
|
531
|
+
...col.admin?.components?.edit?.beforeDocumentControls ?? []
|
|
532
|
+
]
|
|
533
|
+
},
|
|
534
|
+
views: {
|
|
535
|
+
...views,
|
|
536
|
+
[LIMIT_REACHED_VIEW_KEY]: {
|
|
537
|
+
Component: '@payloadcms/figma/views#LimitReachedView',
|
|
538
|
+
exact: true,
|
|
539
|
+
path: LIMIT_REACHED_VIEW_PATH
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
} : col;
|
|
545
|
+
if (col.slug === adminCollectionSlug) {
|
|
401
546
|
return {
|
|
402
|
-
...
|
|
547
|
+
...withLimitView,
|
|
403
548
|
fields: [
|
|
404
549
|
...col.fields || [],
|
|
405
550
|
...figmaUserFields
|
|
406
551
|
]
|
|
407
552
|
};
|
|
408
553
|
}
|
|
409
|
-
return
|
|
554
|
+
return withLimitView;
|
|
410
555
|
});
|
|
411
556
|
if (collections) {
|
|
412
557
|
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
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
4
|
+
import { FormErrorHandlerContext, useConfig, useFormErrorHandler, useModal, useTranslation } from '@payloadcms/ui';
|
|
5
|
+
import { DrawerDepthContext } from '@payloadcms/ui/elements/Drawer';
|
|
6
|
+
import { formatAdminURL, hasAutosaveEnabled } from 'payload/shared';
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
8
|
+
import { FigmaCloudLimitDocumentCountModal } from '../CloudLimitModal/index.js';
|
|
9
|
+
import { cloudLimitDocumentCountModalSlug, cloudLimitErrorCodes, getCloudLimitErrorCode } from '../shared.js';
|
|
10
|
+
import { FigmaCloudLimitSlugRegistryContext } from '../SlugRegistryContext/index.js';
|
|
11
|
+
import { cloudLimitInterceptor } from '../utilities/cloudLimitInterceptor.js';
|
|
12
|
+
import { dismissSubmittingToast, showCloudLimitToast } from '../utilities/toasts.js';
|
|
13
|
+
export function FigmaCloudLimitProvider({ children }) {
|
|
14
|
+
const { openModal } = useModal();
|
|
15
|
+
const { i18n, t } = useTranslation();
|
|
16
|
+
const { config, getEntityConfig } = useConfig();
|
|
17
|
+
const parentErrorHandler = useFormErrorHandler();
|
|
18
|
+
const adminRoute = config.routes?.admin ?? '/admin';
|
|
19
|
+
const apiRoute = config.routes?.api ?? '/api';
|
|
20
|
+
const [modal, setModal] = useState({
|
|
21
|
+
drawerDepth: 0
|
|
22
|
+
});
|
|
23
|
+
const retryRef = useRef(undefined);
|
|
24
|
+
const registrationsRef = useRef([]);
|
|
25
|
+
const register = useCallback((registration)=>{
|
|
26
|
+
registrationsRef.current.push(registration);
|
|
27
|
+
return ()=>{
|
|
28
|
+
const index = registrationsRef.current.indexOf(registration);
|
|
29
|
+
if (index !== -1) {
|
|
30
|
+
registrationsRef.current.splice(index, 1);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
useEffect(()=>cloudLimitInterceptor(apiRoute, (key)=>t(key)), [
|
|
35
|
+
apiRoute,
|
|
36
|
+
t
|
|
37
|
+
]);
|
|
38
|
+
const handleNonFieldError = useCallback((err, retry)=>{
|
|
39
|
+
const code = getCloudLimitErrorCode({
|
|
40
|
+
errors: [
|
|
41
|
+
err
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
if (!code) {
|
|
45
|
+
return parentErrorHandler?.(err, retry) ?? false;
|
|
46
|
+
}
|
|
47
|
+
dismissSubmittingToast(t('general:submitting'));
|
|
48
|
+
if (code !== cloudLimitErrorCodes.documentCount) {
|
|
49
|
+
showCloudLimitToast(code, t);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const registrations = registrationsRef.current;
|
|
53
|
+
let activeRegistration;
|
|
54
|
+
for(let index = registrations.length - 1; index >= 0; index--){
|
|
55
|
+
if (registrations[index]?.isSubmitting) {
|
|
56
|
+
activeRegistration = registrations[index];
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
activeRegistration ??= registrations[registrations.length - 1];
|
|
61
|
+
const adminPath = formatAdminURL({
|
|
62
|
+
adminRoute,
|
|
63
|
+
includeBasePath: true
|
|
64
|
+
});
|
|
65
|
+
const slug = activeRegistration?.slug ?? /^\/collections\/([^/?#]+)/.exec(window.location.pathname.slice(adminPath.length))?.[1];
|
|
66
|
+
const collectionConfig = slug ? getEntityConfig({
|
|
67
|
+
collectionSlug: slug
|
|
68
|
+
}) : undefined;
|
|
69
|
+
if (collectionConfig && hasAutosaveEnabled(collectionConfig)) {
|
|
70
|
+
showCloudLimitToast(code, t);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
setModal({
|
|
74
|
+
collectionLabel: collectionConfig?.labels?.plural != null ? getTranslation(collectionConfig.labels.plural, i18n) : slug,
|
|
75
|
+
collectionListURL: slug ? formatAdminURL({
|
|
76
|
+
adminRoute,
|
|
77
|
+
includeBasePath: true,
|
|
78
|
+
path: `/collections/${slug}`
|
|
79
|
+
}) : undefined,
|
|
80
|
+
drawerDepth: activeRegistration?.drawerDepth ?? 0
|
|
81
|
+
});
|
|
82
|
+
retryRef.current = retry;
|
|
83
|
+
openModal(cloudLimitDocumentCountModalSlug);
|
|
84
|
+
return true;
|
|
85
|
+
}, [
|
|
86
|
+
adminRoute,
|
|
87
|
+
getEntityConfig,
|
|
88
|
+
i18n,
|
|
89
|
+
openModal,
|
|
90
|
+
parentErrorHandler,
|
|
91
|
+
t
|
|
92
|
+
]);
|
|
93
|
+
return /*#__PURE__*/ _jsx(FigmaCloudLimitSlugRegistryContext, {
|
|
94
|
+
value: register,
|
|
95
|
+
children: /*#__PURE__*/ _jsxs(FormErrorHandlerContext, {
|
|
96
|
+
value: handleNonFieldError,
|
|
97
|
+
children: [
|
|
98
|
+
children,
|
|
99
|
+
/*#__PURE__*/ _jsx(DrawerDepthContext, {
|
|
100
|
+
value: modal.drawerDepth,
|
|
101
|
+
children: /*#__PURE__*/ _jsx(FigmaCloudLimitDocumentCountModal, {
|
|
102
|
+
collectionLabel: modal.collectionLabel,
|
|
103
|
+
collectionListURL: modal.collectionListURL,
|
|
104
|
+
onRetry: ()=>retryRef.current?.()
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
});
|
|
110
|
+
}
|