@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
|
@@ -102,6 +102,10 @@ import { convertPayloadWhereToContentAPI } from './where.js';
|
|
|
102
102
|
const effectiveLimit = joinQuery.limit ?? foundJoin.defaultLimit;
|
|
103
103
|
// Add fallback sort for the joined collection
|
|
104
104
|
const sortWithFallback = addFallbackSort(joinQuery.sort, payload, foundJoin.collectionSlug, foundJoin.defaultSort);
|
|
105
|
+
// A join's `where` filters the *joined* collection, so id coercion resolves against
|
|
106
|
+
// that collection (the first target for a polymorphic join; `id` is coerced regardless).
|
|
107
|
+
const joinedSlug = Array.isArray(foundJoin.collectionSlug) ? foundJoin.collectionSlug[0] : foundJoin.collectionSlug;
|
|
108
|
+
const whereConverted = convertPayloadWhereToContentAPI(joinQuery.where, payload, joinedSlug, false);
|
|
105
109
|
const contentAPIJoin = {
|
|
106
110
|
count: joinQuery.count ?? false,
|
|
107
111
|
path: joinPath,
|
|
@@ -115,7 +119,7 @@ import { convertPayloadWhereToContentAPI } from './where.js';
|
|
|
115
119
|
sort: sortWithFallback
|
|
116
120
|
},
|
|
117
121
|
...joinQuery.where && {
|
|
118
|
-
where:
|
|
122
|
+
where: whereConverted
|
|
119
123
|
}
|
|
120
124
|
};
|
|
121
125
|
result.push(contentAPIJoin);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Field, Payload } from 'payload';
|
|
2
|
+
export interface ResolveContext {
|
|
3
|
+
readonly fieldCache: Map<string, boolean>;
|
|
4
|
+
readonly fields: Field[];
|
|
5
|
+
readonly isVersions: boolean;
|
|
6
|
+
readonly payload: Payload;
|
|
7
|
+
}
|
|
8
|
+
/** Walks a path's segments against a field list, reporting whether it lands on a
|
|
9
|
+
* relationship/upload field's id-bearing value. */
|
|
10
|
+
export declare function resolvesToRelationshipValue(segments: string[], fields: Field[], ctx: ResolveContext): boolean;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { resolveBlocks } from '../resolveBlocks.js';
|
|
2
|
+
/** Walks a path's segments against a field list, reporting whether it lands on a
|
|
3
|
+
* relationship/upload field's id-bearing value. */ export function resolvesToRelationshipValue(segments, fields, ctx) {
|
|
4
|
+
const [head, ...rest] = segments;
|
|
5
|
+
if (head == null) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const field = findNamedField(fields, head);
|
|
9
|
+
if (field == null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
switch(field.type){
|
|
13
|
+
case 'array':
|
|
14
|
+
return 'fields' in field && resolvesToRelationshipValue(skipLocaleSegment(rest, field, ctx), field.fields, ctx);
|
|
15
|
+
case 'blocks':
|
|
16
|
+
{
|
|
17
|
+
if (!('blocks' in field)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// Any block whose fields the remaining path resolves through makes it id-bearing:
|
|
21
|
+
// one path can only mean one thing, whichever block supplied the field.
|
|
22
|
+
const childSegments = skipLocaleSegment(rest, field, ctx);
|
|
23
|
+
return resolveBlocks(field.blocks, ctx.payload.config.blocks).some((block)=>resolvesToRelationshipValue(childSegments, block.fields, ctx));
|
|
24
|
+
}
|
|
25
|
+
case 'group':
|
|
26
|
+
return 'fields' in field && resolvesToRelationshipValue(rest, field.fields, ctx);
|
|
27
|
+
case 'relationship':
|
|
28
|
+
case 'upload':
|
|
29
|
+
// A polymorphic field's id sits at `<path>.value`; its `.relationTo` is a slug.
|
|
30
|
+
if (Array.isArray(field.relationTo)) {
|
|
31
|
+
return rest.length === 1 && rest[0] === 'value';
|
|
32
|
+
}
|
|
33
|
+
// A single-target field's id sits at the field's own path.
|
|
34
|
+
if (rest.length === 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
// Payload accepts an explicit `<path>.id` for that same value —
|
|
38
|
+
// `getTableColumnFromPath` treats the bare path and `.id` as one column — which the
|
|
39
|
+
// Content API resolves as a traversal into the related collection's, equally text, id.
|
|
40
|
+
return rest.length === 1 && rest[0] === 'id';
|
|
41
|
+
default:
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Finds the field a path segment names. Unnamed containers (row, collapsible, unnamed tab)
|
|
46
|
+
* are transparent to query paths, so their children are searched too; a named tab nests its
|
|
47
|
+
* fields under its own name, exactly like a group. */ function findNamedField(fields, name) {
|
|
48
|
+
for (const field of fields){
|
|
49
|
+
if ('name' in field && field.name) {
|
|
50
|
+
// A named container's children need its name consumed first, so only match the
|
|
51
|
+
// container itself here.
|
|
52
|
+
if (field.name === name) {
|
|
53
|
+
return field;
|
|
54
|
+
}
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if ('fields' in field && Array.isArray(field.fields)) {
|
|
58
|
+
const match = findNamedField(field.fields, name);
|
|
59
|
+
if (match) {
|
|
60
|
+
return match;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if ('tabs' in field && Array.isArray(field.tabs)) {
|
|
64
|
+
for (const tab of field.tabs){
|
|
65
|
+
if (!tab.fields) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!tab.name) {
|
|
69
|
+
const match = findNamedField(tab.fields, name);
|
|
70
|
+
if (match) {
|
|
71
|
+
return match;
|
|
72
|
+
}
|
|
73
|
+
} else if (tab.name === name) {
|
|
74
|
+
return {
|
|
75
|
+
name: tab.name,
|
|
76
|
+
type: 'group',
|
|
77
|
+
fields: tab.fields
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
// A localized array/blocks field is stored as a locale map, so its children's paths carry a
|
|
86
|
+
// locale key (`items.en.rel`) — see `normalizeLocaleInWhere`, which runs before this.
|
|
87
|
+
// Locale keys are *only* added to `array` and `blocks`.
|
|
88
|
+
function skipLocaleSegment(segments, field, ctx) {
|
|
89
|
+
const localization = ctx.payload.config.localization;
|
|
90
|
+
if (!localization || !('localized' in field) || !field.localized) {
|
|
91
|
+
return segments;
|
|
92
|
+
}
|
|
93
|
+
const [head] = segments;
|
|
94
|
+
return head != null && localization.localeCodes.includes(head) ? segments.slice(1) : segments;
|
|
95
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
|
+
/**
|
|
3
|
+
* Stringifies numeric operands on a Where clause's id-bearing paths (`id`, `parent` for
|
|
4
|
+
* versions, and relationship-value paths), so a custom-numeric-id filter matches the
|
|
5
|
+
* Content API's text storage. Returns the clause untouched when there is nothing to
|
|
6
|
+
* convert. `isVersions` treats `parent` (the parent document's id) as id-bearing and looks
|
|
7
|
+
* for the collection's own fields under `version.`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function stringifyIdsInWhere(where: undefined | Where, payload: Payload, collectionSlug: string, isVersions: boolean): undefined | Where;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { resolvesToRelationshipValue } from './resolvesToRelationshipValue.js';
|
|
2
|
+
// The Content API stores every document id and every relationship value as text, but
|
|
3
|
+
// Payload keeps a collection's custom numeric id as a `number`. So a filter that carries
|
|
4
|
+
// a numeric id would never match the stored string form. This is the sole place the
|
|
5
|
+
// adapter translates those query-side ids to the wire's string form (the data-side
|
|
6
|
+
// counterpart is `convertRelationshipIds`); `convertPayloadWhereToContentAPI` itself is
|
|
7
|
+
// purely structural.
|
|
8
|
+
//
|
|
9
|
+
// A condition's path is id-bearing when it resolves to:
|
|
10
|
+
// - `id` — the document's own id (always).
|
|
11
|
+
// - `parent` — the parent document's id, on a *versions* query (`isVersions`).
|
|
12
|
+
// - a relationship/upload field's value: the field's own path for a single-target field
|
|
13
|
+
// (`rel: { equals: 999 }`), or `<path>.value` for a polymorphic one
|
|
14
|
+
// (`rel.value: { equals: 999 }`). A polymorphic field's `.relationTo` is a slug, not
|
|
15
|
+
// an id, so it is deliberately left alone.
|
|
16
|
+
//
|
|
17
|
+
// Every stored id is text, so a bare "stringify any numeric operand on this path" is
|
|
18
|
+
// sufficient — no per-target id-type resolution is needed (which also handles a
|
|
19
|
+
// polymorphic `in` array that mixes targets).
|
|
20
|
+
/**
|
|
21
|
+
* Stringifies numeric operands on a Where clause's id-bearing paths (`id`, `parent` for
|
|
22
|
+
* versions, and relationship-value paths), so a custom-numeric-id filter matches the
|
|
23
|
+
* Content API's text storage. Returns the clause untouched when there is nothing to
|
|
24
|
+
* convert. `isVersions` treats `parent` (the parent document's id) as id-bearing and looks
|
|
25
|
+
* for the collection's own fields under `version.`.
|
|
26
|
+
*/ export function stringifyIdsInWhere(where, payload, collectionSlug, isVersions) {
|
|
27
|
+
if (!where) {
|
|
28
|
+
return where;
|
|
29
|
+
}
|
|
30
|
+
// An unknown slug names no fields, but `id` (and `parent` on a versions query) is
|
|
31
|
+
// id-bearing regardless of the config, so still walk the clause with an empty field list:
|
|
32
|
+
// discarding it here would turn the query into a match-all.
|
|
33
|
+
const config = payload.config.collections.find((c)=>c.slug === collectionSlug);
|
|
34
|
+
const fields = config?.fields ?? [];
|
|
35
|
+
const fieldCache = new Map();
|
|
36
|
+
return transformWhere(where, {
|
|
37
|
+
fieldCache,
|
|
38
|
+
fields,
|
|
39
|
+
isVersions,
|
|
40
|
+
payload
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Recursively transforms a Where clause, stringifying numeric operands on any condition
|
|
44
|
+
* whose path is id-bearing. */ function transformWhere(where, context) {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const [key, value] of Object.entries(where)){
|
|
47
|
+
const keyLower = key.toLowerCase();
|
|
48
|
+
if (keyLower === 'and' || keyLower === 'or') {
|
|
49
|
+
const targetValue = where[key];
|
|
50
|
+
if (targetValue == null || !Array.isArray(targetValue)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
result[key] = targetValue.map((clause)=>transformWhere(clause, context));
|
|
54
|
+
} else if (isIdBearingPath(key, context)) {
|
|
55
|
+
result[key] = stringifyNumericOperands(value);
|
|
56
|
+
} else {
|
|
57
|
+
result[key] = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
/** Whether a condition's path resolves to an id. */ function isIdBearingPath(path, context) {
|
|
63
|
+
const cachedResult = context.fieldCache.get(path);
|
|
64
|
+
if (cachedResult != null) {
|
|
65
|
+
return cachedResult;
|
|
66
|
+
}
|
|
67
|
+
// GraphQL spells a nested path with `__`, since dots are invalid in GraphQL names; the
|
|
68
|
+
// structural conversion normalizes those the same way.
|
|
69
|
+
const segments = path.replace(/__/g, '.').split('.');
|
|
70
|
+
// The document's own id — on a versions query, the version document's own id.
|
|
71
|
+
if (segments.length === 1 && segments[0] === 'id') {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (context.isVersions) {
|
|
75
|
+
// `parent` is a version-only field that contains an ID.
|
|
76
|
+
if (segments.length === 1) {
|
|
77
|
+
return segments[0] === 'parent';
|
|
78
|
+
}
|
|
79
|
+
// The only other paths that can contain IDs are in the version envelope.
|
|
80
|
+
if (segments[0] !== 'version') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Normalize the path segments by removing the `version` envelope for paths
|
|
85
|
+
// in document versions.
|
|
86
|
+
const normalizedSegments = context.isVersions ? segments.slice(1) : segments;
|
|
87
|
+
return resolvesToRelationshipValue(normalizedSegments, context.fields, context);
|
|
88
|
+
}
|
|
89
|
+
function stringifyNumericOperands(condition) {
|
|
90
|
+
// Payload's shorthand — `{ id: 999 }` rather than `{ id: { equals: 999 } }` — carries the
|
|
91
|
+
// operand directly, with no operator keys to walk. The structural conversion reads it as
|
|
92
|
+
// an implicit `equals`, so coerce it in place: walking a primitive as an operator map
|
|
93
|
+
// would drop the condition entirely and turn the query into a match-all.
|
|
94
|
+
if (condition === null || typeof condition !== 'object' || Array.isArray(condition)) {
|
|
95
|
+
return stringifyNumbers(condition);
|
|
96
|
+
}
|
|
97
|
+
const result = {};
|
|
98
|
+
for (const [operator, operand] of Object.entries(condition)){
|
|
99
|
+
result[operator] = stringifyNumbers(operand);
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
/** A number becomes its string form; a number inside an array does too (e.g. `in`);
|
|
104
|
+
* everything else passes through untouched. */ function stringifyNumbers(value) {
|
|
105
|
+
if (typeof value === 'number') {
|
|
106
|
+
return String(value);
|
|
107
|
+
}
|
|
108
|
+
if (Array.isArray(value)) {
|
|
109
|
+
return value.map((entry)=>typeof entry === 'number' ? String(entry) : entry);
|
|
110
|
+
}
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
@@ -29,11 +29,11 @@ export function buildDocumentSchema(config) {
|
|
|
29
29
|
};
|
|
30
30
|
const collections = {};
|
|
31
31
|
for (const collection of config.collections ?? []){
|
|
32
|
-
collections[collection.slug] = buildCollectionSchema(collection.slug, collection.fields, blockRegistry);
|
|
32
|
+
collections[collection.slug] = buildCollectionSchema(collection.slug, collection.fields, blockRegistry, collection.indexes ?? []);
|
|
33
33
|
}
|
|
34
34
|
for (const global of config.globals ?? []){
|
|
35
35
|
const slug = `_global-${global.slug}`;
|
|
36
|
-
collections[slug] = buildCollectionSchema(slug, global.fields, blockRegistry);
|
|
36
|
+
collections[slug] = buildCollectionSchema(slug, global.fields, blockRegistry, []);
|
|
37
37
|
}
|
|
38
38
|
return {
|
|
39
39
|
blocks: blockRegistry.blocksById,
|
|
@@ -41,7 +41,7 @@ export function buildDocumentSchema(config) {
|
|
|
41
41
|
version: 1
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function buildCollectionSchema(name, fields, blockRegistry) {
|
|
44
|
+
function buildCollectionSchema(name, fields, blockRegistry, indexes) {
|
|
45
45
|
const paths = {};
|
|
46
46
|
collectPaths(fields, paths, {
|
|
47
47
|
blockRegistry,
|
|
@@ -59,9 +59,14 @@ function buildCollectionSchema(name, fields, blockRegistry) {
|
|
|
59
59
|
localized: false
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
// Field-level unique flags cannot express Payload's compound collection indexes.
|
|
63
|
+
const hints = indexes.filter((index)=>index.unique).map((index)=>({
|
|
64
|
+
type: 'unique',
|
|
65
|
+
paths: index.fields
|
|
66
|
+
}));
|
|
62
67
|
return {
|
|
63
68
|
name,
|
|
64
|
-
hints
|
|
69
|
+
hints,
|
|
65
70
|
paths
|
|
66
71
|
};
|
|
67
72
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { buildDocumentSchema } from './buildDocumentSchema.js';
|
|
2
|
+
// The schema built by `getDocumentSchema`, keyed by the config it was built from.
|
|
3
|
+
// Weakly held so a config discarded by HMR takes its schema with it.
|
|
4
|
+
let schemaByConfig = new WeakMap();
|
|
5
|
+
// Retrieves a document schema for the given config, building it if necessary.
|
|
6
|
+
// The last output is memoized, so if this config matches the last config we just return
|
|
7
|
+
// the previous output instead of rebuilding it.
|
|
8
|
+
export function getDocumentSchema(config) {
|
|
9
|
+
const existing = schemaByConfig.get(config);
|
|
10
|
+
if (existing != null) {
|
|
11
|
+
return existing;
|
|
12
|
+
}
|
|
13
|
+
const schema = buildDocumentSchema(config);
|
|
14
|
+
// Clear the cache of any previous config, so only the most recent one is held.
|
|
15
|
+
// This ensures that we never accidentally leak memory by holding on to more
|
|
16
|
+
// and more schemas if the configs are never garbage collected.
|
|
17
|
+
schemaByConfig = new WeakMap([
|
|
18
|
+
[
|
|
19
|
+
config,
|
|
20
|
+
schema
|
|
21
|
+
]
|
|
22
|
+
]);
|
|
23
|
+
return schema;
|
|
24
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Where } from 'payload';
|
|
1
|
+
import type { Payload, Where } from 'payload';
|
|
2
2
|
import type { components } from '../generated/content-api-types.js';
|
|
3
3
|
type WhereClauseV1 = components['schemas']['WhereClauseV1'];
|
|
4
|
-
|
|
5
|
-
/** Internal flag to track if we're inside a logical operator (and/or) */
|
|
6
|
-
insideLogicalOperator?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function convertPayloadWhereToContentAPI(where: undefined | Where, options?: ConvertOptions): WhereClauseV1;
|
|
4
|
+
export declare function convertPayloadWhereToContentAPI(where: undefined | Where, payload: Payload, collectionSlug: string, isVersions: boolean): WhereClauseV1;
|
|
9
5
|
export {};
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { stringifyIdsInWhere } from './meta/stringifyIdsInWhere.js';
|
|
2
|
+
// Payload's format: { fieldName: { operator: value }, and: [...], or: [...] }
|
|
3
|
+
// Content API expects: { and: [{ path, operator, value }], or: [{ path, operator, value }] }
|
|
4
|
+
//
|
|
5
|
+
// The format stays different. This allows the Content API to evolve its filter schema,
|
|
6
|
+
// for example to support composite types like Point, which are not lexicographically sortable.
|
|
7
|
+
// Semantics must remain identical to Payload.
|
|
8
|
+
export function convertPayloadWhereToContentAPI(where, payload, collectionSlug, isVersions) {
|
|
9
|
+
// Normalize id-bearing operands to the wire's string form (custom numeric ids), then
|
|
10
|
+
// convert Payload's where shape to the Content API's. The two steps are inseparable —
|
|
11
|
+
// every id filter must be coerced — so they live behind this single entry point.
|
|
12
|
+
return convertStructure(stringifyIdsInWhere(where, payload, collectionSlug, isVersions), {
|
|
13
|
+
insideLogicalOperator: false
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
// The structural Payload → Content API conversion. Assumes id operands have already been
|
|
17
|
+
// coerced to the wire's string form (see `convertPayloadWhereToContentAPI`).
|
|
18
|
+
function convertStructure(where, options) {
|
|
2
19
|
// Empty where {} should be { and: [] } not undefined
|
|
3
20
|
// Content API requires a where clause structure even for "no filter"
|
|
4
21
|
if (!where || Object.keys(where).length === 0) {
|
|
@@ -10,7 +27,7 @@ export function convertPayloadWhereToContentAPI(where, options = {}) {
|
|
|
10
27
|
for (const [key, value] of Object.entries(where)){
|
|
11
28
|
const keyLower = key.toLowerCase();
|
|
12
29
|
if (keyLower === 'and' || keyLower === 'or') {
|
|
13
|
-
const nestedConditions = value.map((item)=>
|
|
30
|
+
const nestedConditions = value.map((item)=>convertStructure(item, {
|
|
14
31
|
...options,
|
|
15
32
|
insideLogicalOperator: true
|
|
16
33
|
})).filter((condition)=>{
|
|
@@ -42,7 +59,7 @@ export function convertPayloadWhereToContentAPI(where, options = {}) {
|
|
|
42
59
|
conditions.push({
|
|
43
60
|
operator: 'equals',
|
|
44
61
|
path: fieldPath,
|
|
45
|
-
value
|
|
62
|
+
value
|
|
46
63
|
});
|
|
47
64
|
continue;
|
|
48
65
|
}
|
|
@@ -67,12 +84,6 @@ export function convertPayloadWhereToContentAPI(where, options = {}) {
|
|
|
67
84
|
if (finalValue === 'null') {
|
|
68
85
|
finalValue = null;
|
|
69
86
|
}
|
|
70
|
-
// Content API stores all document IDs as strings.
|
|
71
|
-
// Payload sends numeric values for collections with custom numeric ID fields,
|
|
72
|
-
// so we must stringify to match.
|
|
73
|
-
if (fieldPath === 'id' && typeof finalValue === 'number') {
|
|
74
|
-
finalValue = String(finalValue);
|
|
75
|
-
}
|
|
76
87
|
conditions.push({
|
|
77
88
|
operator: op,
|
|
78
89
|
path: fieldPath,
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -2,3 +2,5 @@ export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
|
|
|
2
2
|
export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
3
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
4
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
5
|
+
export { FigmaCloudLimitProvider } from '../plugin/cloud-limits/CloudLimitProvider/index.js';
|
|
6
|
+
export { FigmaCloudLimitSlugTracker } from '../plugin/cloud-limits/SlugTracker/index.js';
|
package/dist/exports/client.js
CHANGED
|
@@ -2,3 +2,5 @@ export { FigmaAvatar } from '../oauth/components/FigmaAvatar/index.js';
|
|
|
2
2
|
export { FigmaAvatarCell } from '../oauth/components/FigmaAvatarCell/index.js';
|
|
3
3
|
export { DefaultLoginButton } from '../oauth/components/LoginButton/index.js';
|
|
4
4
|
export { LogoutButton } from '../oauth/components/LogoutButton/index.js';
|
|
5
|
+
export { FigmaCloudLimitProvider } from '../plugin/cloud-limits/CloudLimitProvider/index.js';
|
|
6
|
+
export { FigmaCloudLimitSlugTracker } from '../plugin/cloud-limits/SlugTracker/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LimitReachedView } from '../plugin/cloud-limits/LimitReachedView/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LimitReachedView } from '../plugin/cloud-limits/LimitReachedView/index.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RequestInitCfPropertiesImage } from '@cloudflare/workers-types';
|
|
2
|
+
type CloudflareWorkerImageOptions = RequestInitCfPropertiesImage;
|
|
3
|
+
export declare const supportedCloudflareImageOptionKeys: readonly ["anim", "background", "blur", "border", "brightness", "compression", "contrast", "dpr", "fit", "flip", "format", "gamma", "gravity", "height", "metadata", "quality", "rotate", "saturation", "segment", "sharpen", "trim", "upscale", "width", "zoom"];
|
|
4
|
+
type SupportedCloudflareImageOptionKey = (typeof supportedCloudflareImageOptionKeys)[number];
|
|
5
|
+
type SupportedCloudflareImageOptions = Pick<CloudflareWorkerImageOptions, SupportedCloudflareImageOptionKey>;
|
|
6
|
+
type CloudflareImageSizeFormat = Exclude<NonNullable<SupportedCloudflareImageOptions['format']>, 'json' | 'svg'>;
|
|
7
|
+
type CloudflareImageSizeOptionsExceptFormat = Omit<SupportedCloudflareImageOptions, 'format'>;
|
|
8
|
+
/**
|
|
9
|
+
* Options accepted for a reusable Payload image-size preset.
|
|
10
|
+
*
|
|
11
|
+
* Presets can control the generated image, but cannot use remote overlays or
|
|
12
|
+
* forward authentication to an image origin. Formats that do not produce a
|
|
13
|
+
* supported stored image are also excluded.
|
|
14
|
+
*/
|
|
15
|
+
export type CloudflareImageSizeOptions = {
|
|
16
|
+
format?: CloudflareImageSizeFormat;
|
|
17
|
+
} & CloudflareImageSizeOptionsExceptFormat;
|
|
18
|
+
declare module 'payload' {
|
|
19
|
+
interface RegisteredImageSizeOptions {
|
|
20
|
+
figma: CloudflareImageSizeOptions;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const supportedCloudflareImageOptionKeys = [
|
|
2
|
+
'anim',
|
|
3
|
+
'background',
|
|
4
|
+
'blur',
|
|
5
|
+
'border',
|
|
6
|
+
'brightness',
|
|
7
|
+
'compression',
|
|
8
|
+
'contrast',
|
|
9
|
+
'dpr',
|
|
10
|
+
'fit',
|
|
11
|
+
'flip',
|
|
12
|
+
'format',
|
|
13
|
+
'gamma',
|
|
14
|
+
'gravity',
|
|
15
|
+
'height',
|
|
16
|
+
'metadata',
|
|
17
|
+
'quality',
|
|
18
|
+
'rotate',
|
|
19
|
+
'saturation',
|
|
20
|
+
'segment',
|
|
21
|
+
'sharpen',
|
|
22
|
+
'trim',
|
|
23
|
+
'upscale',
|
|
24
|
+
'width',
|
|
25
|
+
'zoom'
|
|
26
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { contentAPIAdapter } from './db-content-api/index.js';
|
|
2
|
+
export type { CloudflareImageSizeOptions } from './imageSizeOptions.js';
|
|
2
3
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
3
4
|
export type { FigmaContentSystemOptions } from './plugin/adapter.js';
|
|
4
5
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
5
6
|
export type { FigmaConfig } from './plugin/build-config.js';
|
|
7
|
+
export { passesMakeViewerWriteGate } from './plugin/make-permission-access/make-permission-access.js';
|
package/dist/index.js
CHANGED
|
@@ -4,3 +4,5 @@ export { contentAPIAdapter } from './db-content-api/index.js';
|
|
|
4
4
|
export { figmaContentSystem } from './plugin/adapter.js';
|
|
5
5
|
// Export buildConfig wrapper and its config type
|
|
6
6
|
export { buildFigmaConfig } from './plugin/build-config.js';
|
|
7
|
+
// Export the Make permission predicate for slug-specific baseAccess overrides.
|
|
8
|
+
export { passesMakeViewerWriteGate } from './plugin/make-permission-access/make-permission-access.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type WriteAgentConfigResult = {
|
|
2
|
+
agentsMd: 'appended' | 'created' | 'unchanged';
|
|
3
|
+
claudeMd: 'appended' | 'created' | 'unchanged';
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Write the root AI-agent pointer files so assistants can find the Payload
|
|
7
|
+
* skill bundled in node_modules. Idempotent: creates when absent, appends the
|
|
8
|
+
* pointer when a file exists without it, and no-ops when already present.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeAgentConfigFiles(args: {
|
|
11
|
+
projectDir: string;
|
|
12
|
+
}): Promise<WriteAgentConfigResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
const SKILL_POINTER_PATH = 'node_modules/payload/skills/payload/SKILL.md';
|
|
4
|
+
const AGENTS_BLOCK = `# AI Agent
|
|
5
|
+
|
|
6
|
+
For any Payload-related work, reference the skill at
|
|
7
|
+
\`${SKILL_POINTER_PATH}\`.
|
|
8
|
+
`;
|
|
9
|
+
const CLAUDE_IMPORT = '@AGENTS.md';
|
|
10
|
+
/**
|
|
11
|
+
* Write the root AI-agent pointer files so assistants can find the Payload
|
|
12
|
+
* skill bundled in node_modules. Idempotent: creates when absent, appends the
|
|
13
|
+
* pointer when a file exists without it, and no-ops when already present.
|
|
14
|
+
*/ export async function writeAgentConfigFiles(args) {
|
|
15
|
+
const agentsMd = await ensureFileContains({
|
|
16
|
+
content: AGENTS_BLOCK,
|
|
17
|
+
filePath: path.join(args.projectDir, 'AGENTS.md'),
|
|
18
|
+
marker: SKILL_POINTER_PATH
|
|
19
|
+
});
|
|
20
|
+
const claudeMd = await ensureFileContains({
|
|
21
|
+
content: `${CLAUDE_IMPORT}\n`,
|
|
22
|
+
filePath: path.join(args.projectDir, 'CLAUDE.md'),
|
|
23
|
+
marker: CLAUDE_IMPORT
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
agentsMd,
|
|
27
|
+
claudeMd
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function ensureFileContains(args) {
|
|
31
|
+
const existing = await readFileOrNull(args.filePath);
|
|
32
|
+
if (existing === null) {
|
|
33
|
+
await fs.writeFile(args.filePath, args.content, 'utf8');
|
|
34
|
+
return 'created';
|
|
35
|
+
}
|
|
36
|
+
if (existing.includes(args.marker)) {
|
|
37
|
+
return 'unchanged';
|
|
38
|
+
}
|
|
39
|
+
const separator = existing.endsWith('\n') ? '\n' : '\n\n';
|
|
40
|
+
await fs.writeFile(args.filePath, `${existing}${separator}${args.content}`, 'utf8');
|
|
41
|
+
return 'appended';
|
|
42
|
+
}
|
|
43
|
+
async function readFileOrNull(filePath) {
|
|
44
|
+
try {
|
|
45
|
+
return await fs.readFile(filePath, 'utf8');
|
|
46
|
+
} catch (err) {
|
|
47
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
const PAYLOAD_FILE_PATH_PATTERN = /^\/(?!\/)(?:.+\/)?api\/[^/]+\/file\/.+$/;
|
|
3
|
+
export function figmaNextImageLoader({ quality, src, width }) {
|
|
4
|
+
const [pathname, search = ''] = src.split('?');
|
|
5
|
+
if (!PAYLOAD_FILE_PATH_PATTERN.test(pathname)) {
|
|
6
|
+
return src;
|
|
7
|
+
}
|
|
8
|
+
const searchParams = new URLSearchParams(search);
|
|
9
|
+
searchParams.set('w', String(width));
|
|
10
|
+
if (quality !== undefined) {
|
|
11
|
+
searchParams.set('q', String(quality));
|
|
12
|
+
}
|
|
13
|
+
return `${pathname}?${searchParams}`;
|
|
14
|
+
}
|